summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2010-05-14 16:44:37 (GMT)
committerDries Buytaert2010-05-14 16:44:37 (GMT)
commit24db763b78cdf6509a33c1312996b633ffcdcf36 (patch)
treee0d82757315955134febea6e9b923cddf978665f
parente14705f4faed5703f547f95790ee1cc3524b46a4 (diff)
- Patch #787940 by casey, Kiphaas7: generic approach for position:fixed elements like toolbar.
-rw-r--r--misc/displace.js17
-rw-r--r--misc/drupal.js18
2 files changed, 23 insertions, 12 deletions
diff --git a/misc/displace.js b/misc/displace.js
index 6345ff2..261d8ac 100644
--- a/misc/displace.js
+++ b/misc/displace.js
@@ -4,7 +4,7 @@
/**
* Provides a generic method to position elements fixed to the viewport.
*
- * Fixed positioning (CSS declaration position:fixed) is done relatively to the
+ * Fixed positioning (CSS declaration position:fixed) is done relative to the
* viewport. This makes it hard to position multiple fixed positioned element
* relative to each other (e.g. multiple toolbars should come after each other,
* not on top of each other).
@@ -14,7 +14,7 @@
* port add the class "displace-bottom".
*
* When a browser doesn't support position:fixed (like IE6) the element gets
- * positioned absolutely by default, but this can be overriden by using the
+ * positioned absolutely by default, but this can be overridden by using the
* "displace-unsupported" class.
*/
@@ -23,16 +23,9 @@
*/
Drupal.behaviors.displace = {
attach: function (context, settings) {
- // Test for position:fixed support as IE6 does not.
- // http://yura.thinkweb2.com/cft/#IS_POSITION_FIXED_SUPPORTED
- if (this.supported === undefined) {
- var el = $('<div style="position:fixed;top:10px"/>').appendTo(document.body);
- this.supported = el[0].offsetTop === 10;
- el.remove();
-
- if (!this.supported) {
- $(document.documentElement).addClass('displace-unsupported');
- }
+ // Test for position:fixed support.
+ if (!Drupal.positionFixedSupported()) {
+ $(document.documentElement).addClass('displace-unsupported');
}
$(document.body).once('displace', function () {
diff --git a/misc/drupal.js b/misc/drupal.js
index d6f7597..9d7ec80 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -300,6 +300,24 @@ Drupal.getSelection = function (element) {
};
/**
+ * Checks if position:fixed is supported.
+ *
+ * @return
+ * Boolean indicating whether or not position:fixed is supported.
+ *
+ * @see http://yura.thinkweb2.com/cft/#IS_POSITION_FIXED_SUPPORTED
+ */
+Drupal.positionFixedSupported = function () {
+ if (this._positionFixedSupported === undefined) {
+ var el = $('<div style="position:fixed; top:10px" />').appendTo(document.body);
+ this._positionFixedSupported = el[0].offsetTop === 10;
+ el.remove();
+ }
+
+ return this._positionFixedSupported;
+};
+
+/**
* Build an error message from an AJAX response.
*/
Drupal.ajaxError = function (xmlhttp, uri) {