summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2011-03-24 20:37:26 (GMT)
committer Earl Miles2011-03-24 20:37:26 (GMT)
commit1217bf4e4421f2a00fadd2625188e742b97f9cd3 (patch)
treea27239542d2494715032ebeda3aced037c2dad41
parent7bb7d7408ff37b711f95d527dd212cc44a0980b2 (diff)
A hack to make collapsible fieldsets inside the modal more palatable.
-rw-r--r--js/ajax.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/js/ajax.js b/js/ajax.js
index 8e53d3b..560c5a7 100644
--- a/js/ajax.js
+++ b/js/ajax.js
@@ -127,6 +127,7 @@
}
Drupal.behaviors.viewsAjax = {
+ collapseReplaced: false,
attach: function (context, settings) {
if (!settings.views) {
return;
@@ -186,6 +187,29 @@
});
});
+ if (!this.collapseReplaced && Drupal.collapseScrollIntoView) {
+ this.collapseReplaced = true;
+ Drupal.collapseScrollIntoView = function (node) {
+ for (var $parent = $(node); $parent.get(0) != document && $parent.size() != 0; $parent = $parent.parent()) {
+ if ($parent.css('overflow') == 'scroll' || $parent.css('overflow') == 'auto') {
+ return;
+ }
+ }
+
+ var h = document.documentElement.clientHeight || document.body.clientHeight || 0;
+ var offset = document.documentElement.scrollTop || document.body.scrollTop || 0;
+ var posY = $(node).offset().top;
+ var fudge = 55;
+ if (posY + node.offsetHeight + fudge > h + offset) {
+ if (node.offsetHeight > h) {
+ window.scrollTo(0, posY);
+ }
+ else {
+ window.scrollTo(0, posY + node.offsetHeight - h + fudge);
+ }
+ }
+ };
+ }
}
};