guff-compass 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +21 -0
- data/.gitignore +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/demo/bower_components/jquery/.bower.json +21 -0
- data/demo/bower_components/jquery/.editorconfig +43 -0
- data/demo/bower_components/jquery/.gitattributes +2 -0
- data/demo/bower_components/jquery/.gitignore +14 -0
- data/demo/bower_components/jquery/.gitmodules +6 -0
- data/demo/bower_components/jquery/.jshintrc +17 -0
- data/demo/bower_components/jquery/.mailmap +94 -0
- data/demo/bower_components/jquery/AUTHORS.txt +170 -0
- data/demo/bower_components/jquery/CONTRIBUTING.md +216 -0
- data/demo/bower_components/jquery/Gruntfile.js +594 -0
- data/demo/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/demo/bower_components/jquery/README.md +398 -0
- data/demo/bower_components/jquery/bower.json +11 -0
- data/demo/bower_components/jquery/build/release-notes.js +59 -0
- data/demo/bower_components/jquery/build/release.js +316 -0
- data/demo/bower_components/jquery/component.json +15 -0
- data/demo/bower_components/jquery/composer.json +35 -0
- data/demo/bower_components/jquery/jquery-migrate.js +511 -0
- data/demo/bower_components/jquery/jquery-migrate.min.js +3 -0
- data/demo/bower_components/jquery/jquery.js +9789 -0
- data/demo/bower_components/jquery/jquery.min.js +6 -0
- data/demo/bower_components/jquery/jquery.min.map +1 -0
- data/demo/bower_components/jquery/package.json +38 -0
- data/demo/bower_components/jquery/speed/benchmark.js +15 -0
- data/demo/bower_components/jquery/speed/benchmarker.css +65 -0
- data/demo/bower_components/jquery/speed/benchmarker.js +181 -0
- data/demo/bower_components/jquery/speed/closest.html +39 -0
- data/demo/bower_components/jquery/speed/css.html +82 -0
- data/demo/bower_components/jquery/speed/event.html +58 -0
- data/demo/bower_components/jquery/speed/filter.html +183 -0
- data/demo/bower_components/jquery/speed/find.html +179 -0
- data/demo/bower_components/jquery/speed/index.html +72 -0
- data/demo/bower_components/jquery/speed/jquery-basis.js +6238 -0
- data/demo/bower_components/jquery/speed/slice.vs.concat.html +47 -0
- data/demo/bower_components/jquery/src/.jshintrc +27 -0
- data/demo/bower_components/jquery/src/ajax.js +855 -0
- data/demo/bower_components/jquery/src/ajax/jsonp.js +80 -0
- data/demo/bower_components/jquery/src/ajax/script.js +86 -0
- data/demo/bower_components/jquery/src/ajax/xhr.js +207 -0
- data/demo/bower_components/jquery/src/attributes.js +659 -0
- data/demo/bower_components/jquery/src/callbacks.js +197 -0
- data/demo/bower_components/jquery/src/core.js +981 -0
- data/demo/bower_components/jquery/src/css.js +661 -0
- data/demo/bower_components/jquery/src/data.js +336 -0
- data/demo/bower_components/jquery/src/deferred.js +141 -0
- data/demo/bower_components/jquery/src/deprecated.js +11 -0
- data/demo/bower_components/jquery/src/dimensions.js +41 -0
- data/demo/bower_components/jquery/src/effects.js +732 -0
- data/demo/bower_components/jquery/src/event-alias.js +32 -0
- data/demo/bower_components/jquery/src/event.js +995 -0
- data/demo/bower_components/jquery/src/exports.js +21 -0
- data/demo/bower_components/jquery/src/intro.js +20 -0
- data/demo/bower_components/jquery/src/manipulation.js +744 -0
- data/demo/bower_components/jquery/src/offset.js +169 -0
- data/demo/bower_components/jquery/src/outro.js +2 -0
- data/demo/bower_components/jquery/src/queue.js +146 -0
- data/demo/bower_components/jquery/src/serialize.js +99 -0
- data/demo/bower_components/jquery/src/sizzle-jquery.js +7 -0
- data/demo/bower_components/jquery/src/support.js +246 -0
- data/demo/bower_components/jquery/src/traversing.js +283 -0
- data/demo/bower_components/jquery/src/wrap.js +66 -0
- data/demo/bower_components/jquery/test/.jshintignore +3 -0
- data/demo/bower_components/jquery/test/.jshintrc +60 -0
- data/demo/bower_components/jquery/test/data/1x1.jpg +0 -0
- data/demo/bower_components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
- data/demo/bower_components/jquery/test/data/atom+xml.php +4 -0
- data/demo/bower_components/jquery/test/data/badcall.js +1 -0
- data/demo/bower_components/jquery/test/data/badjson.js +1 -0
- data/demo/bower_components/jquery/test/data/cleanScript.html +10 -0
- data/demo/bower_components/jquery/test/data/core/cc_on.html +22 -0
- data/demo/bower_components/jquery/test/data/dashboard.xml +11 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentLarge.html +17 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentSmall.html +21 -0
- data/demo/bower_components/jquery/test/data/echoData.php +1 -0
- data/demo/bower_components/jquery/test/data/echoQuery.php +1 -0
- data/demo/bower_components/jquery/test/data/errorWithJSON.php +6 -0
- data/demo/bower_components/jquery/test/data/errorWithText.php +5 -0
- data/demo/bower_components/jquery/test/data/etag.php +21 -0
- data/demo/bower_components/jquery/test/data/evalScript.php +1 -0
- data/demo/bower_components/jquery/test/data/event/focusElem.html +16 -0
- data/demo/bower_components/jquery/test/data/event/longLoadScript.php +4 -0
- data/demo/bower_components/jquery/test/data/event/promiseReady.html +17 -0
- data/demo/bower_components/jquery/test/data/event/syncReady.html +23 -0
- data/demo/bower_components/jquery/test/data/headers.php +18 -0
- data/demo/bower_components/jquery/test/data/if_modified_since.php +20 -0
- data/demo/bower_components/jquery/test/data/iframe.html +8 -0
- data/demo/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js +5 -0
- data/demo/bower_components/jquery/test/data/json.php +13 -0
- data/demo/bower_components/jquery/test/data/json_obj.js +1 -0
- data/demo/bower_components/jquery/test/data/jsonp.php +14 -0
- data/demo/bower_components/jquery/test/data/manipulation/iframe-denied.html +36 -0
- data/demo/bower_components/jquery/test/data/name.html +1 -0
- data/demo/bower_components/jquery/test/data/name.php +24 -0
- data/demo/bower_components/jquery/test/data/nocontent.php +5 -0
- data/demo/bower_components/jquery/test/data/offset/absolute.html +41 -0
- data/demo/bower_components/jquery/test/data/offset/body.html +26 -0
- data/demo/bower_components/jquery/test/data/offset/fixed.html +34 -0
- data/demo/bower_components/jquery/test/data/offset/relative.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/scroll.html +39 -0
- data/demo/bower_components/jquery/test/data/offset/static.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/table.html +43 -0
- data/demo/bower_components/jquery/test/data/params_html.php +12 -0
- data/demo/bower_components/jquery/test/data/readywaitasset.js +1 -0
- data/demo/bower_components/jquery/test/data/readywaitloader.js +25 -0
- data/demo/bower_components/jquery/test/data/script.php +11 -0
- data/demo/bower_components/jquery/test/data/selector/html5_selector.html +114 -0
- data/demo/bower_components/jquery/test/data/selector/sizzle_cache.html +21 -0
- data/demo/bower_components/jquery/test/data/statusText.php +5 -0
- data/demo/bower_components/jquery/test/data/support/bodyBackground.html +28 -0
- data/demo/bower_components/jquery/test/data/support/boxSizing.html +19 -0
- data/demo/bower_components/jquery/test/data/support/csp.js +3 -0
- data/demo/bower_components/jquery/test/data/support/csp.php +22 -0
- data/demo/bower_components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
- data/demo/bower_components/jquery/test/data/support/testElementCrash.html +17 -0
- data/demo/bower_components/jquery/test/data/test.html +7 -0
- data/demo/bower_components/jquery/test/data/test.js +3 -0
- data/demo/bower_components/jquery/test/data/test.php +7 -0
- data/demo/bower_components/jquery/test/data/test2.html +5 -0
- data/demo/bower_components/jquery/test/data/test3.html +3 -0
- data/demo/bower_components/jquery/test/data/testinit.js +264 -0
- data/demo/bower_components/jquery/test/data/testrunner.js +371 -0
- data/demo/bower_components/jquery/test/data/testsuite.css +155 -0
- data/demo/bower_components/jquery/test/data/text.php +12 -0
- data/demo/bower_components/jquery/test/data/ua.txt +272 -0
- data/demo/bower_components/jquery/test/data/with_fries.xml +25 -0
- data/demo/bower_components/jquery/test/data/with_fries_over_jsonp.php +7 -0
- data/demo/bower_components/jquery/test/delegatetest.html +228 -0
- data/demo/bower_components/jquery/test/hovertest.html +158 -0
- data/demo/bower_components/jquery/test/index.html +337 -0
- data/demo/bower_components/jquery/test/jquery.js +5 -0
- data/demo/bower_components/jquery/test/localfile.html +75 -0
- data/demo/bower_components/jquery/test/networkerror.html +84 -0
- data/demo/bower_components/jquery/test/readywait.html +70 -0
- data/demo/bower_components/jquery/test/unit/ajax.js +2016 -0
- data/demo/bower_components/jquery/test/unit/attributes.js +1388 -0
- data/demo/bower_components/jquery/test/unit/callbacks.js +342 -0
- data/demo/bower_components/jquery/test/unit/core.js +1360 -0
- data/demo/bower_components/jquery/test/unit/css.js +1056 -0
- data/demo/bower_components/jquery/test/unit/data.js +645 -0
- data/demo/bower_components/jquery/test/unit/deferred.js +436 -0
- data/demo/bower_components/jquery/test/unit/deprecated.js +8 -0
- data/demo/bower_components/jquery/test/unit/dimensions.js +472 -0
- data/demo/bower_components/jquery/test/unit/effects.js +2242 -0
- data/demo/bower_components/jquery/test/unit/event.js +2755 -0
- data/demo/bower_components/jquery/test/unit/exports.js +7 -0
- data/demo/bower_components/jquery/test/unit/manipulation.js +2120 -0
- data/demo/bower_components/jquery/test/unit/offset.js +559 -0
- data/demo/bower_components/jquery/test/unit/queue.js +314 -0
- data/demo/bower_components/jquery/test/unit/selector.js +172 -0
- data/demo/bower_components/jquery/test/unit/serialize.js +148 -0
- data/demo/bower_components/jquery/test/unit/support.js +370 -0
- data/demo/bower_components/jquery/test/unit/traversing.js +797 -0
- data/demo/bower_components/jquery/test/unit/wrap.js +265 -0
- data/demo/bower_components/jquery/test/xhtml.php +5 -0
- data/demo/index.html +347 -0
- data/demo/styles/main.css +208 -0
- data/demo/styles/main.scss +138 -0
- data/docs/docco.css +506 -0
- data/docs/guff.html +1127 -0
- data/docs/public/fonts/aller-bold.eot +0 -0
- data/docs/public/fonts/aller-bold.ttf +0 -0
- data/docs/public/fonts/aller-bold.woff +0 -0
- data/docs/public/fonts/aller-light.eot +0 -0
- data/docs/public/fonts/aller-light.ttf +0 -0
- data/docs/public/fonts/aller-light.woff +0 -0
- data/docs/public/fonts/novecento-bold.eot +0 -0
- data/docs/public/fonts/novecento-bold.ttf +0 -0
- data/docs/public/fonts/novecento-bold.woff +0 -0
- data/docs/public/stylesheets/normalize.css +375 -0
- data/guff.gemspec +16 -0
- data/guff.scss +514 -0
- data/gulpfile.js +67 -0
- data/lib/guff.rb +4 -0
- data/lib/stylesheets/_guff.scss +514 -0
- data/package.json +19 -0
- data/src/_functions.scss +57 -0
- data/src/_mixins.scss +301 -0
- data/src/_reset.scss +67 -0
- data/src/_settings.scss +22 -0
- data/src/_typography.scss +67 -0
- metadata +259 -0
@@ -0,0 +1,559 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
if ( !jQuery.fn.offset ) {
|
4
|
+
return;
|
5
|
+
}
|
6
|
+
|
7
|
+
var supportsScroll, supportsFixedPosition,
|
8
|
+
forceScroll = jQuery("<div/>").css({ width: 2000, height: 2000 }),
|
9
|
+
checkSupport = function() {
|
10
|
+
// Only run once
|
11
|
+
checkSupport = false;
|
12
|
+
|
13
|
+
var checkFixed = jQuery("<div/>").css({ position: "fixed", top: "20px" }).appendTo("#qunit-fixture");
|
14
|
+
|
15
|
+
// Must append to body because #qunit-fixture is hidden and elements inside it don't have a scrollTop
|
16
|
+
forceScroll.appendTo("body");
|
17
|
+
window.scrollTo( 200, 200 );
|
18
|
+
supportsScroll = document.documentElement.scrollTop || document.body.scrollTop;
|
19
|
+
forceScroll.detach();
|
20
|
+
|
21
|
+
// Safari subtracts parent border width here (which is 5px)
|
22
|
+
supportsFixedPosition = checkFixed[0].offsetTop === 20 || checkFixed[0].offsetTop === 15;
|
23
|
+
checkFixed.remove();
|
24
|
+
};
|
25
|
+
|
26
|
+
module("offset", { setup: function(){
|
27
|
+
if ( typeof checkSupport === "function" ) {
|
28
|
+
checkSupport();
|
29
|
+
}
|
30
|
+
|
31
|
+
// Force a scroll value on the main window to ensure incorrect results
|
32
|
+
// if offset is using the scroll offset of the parent window
|
33
|
+
forceScroll.appendTo("body");
|
34
|
+
window.scrollTo( 1, 1 );
|
35
|
+
forceScroll.detach();
|
36
|
+
}, teardown: moduleTeardown });
|
37
|
+
|
38
|
+
/*
|
39
|
+
Closure-compiler will roll static methods off of the jQuery object and so they will
|
40
|
+
not be passed with the jQuery object across the windows. To differentiate this, the
|
41
|
+
testIframe callbacks use the "$" symbol to refer to the jQuery object passed from
|
42
|
+
the iframe window and the "jQuery" symbol is used to access any static methods.
|
43
|
+
*/
|
44
|
+
|
45
|
+
test("empty set", function() {
|
46
|
+
expect(2);
|
47
|
+
strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" );
|
48
|
+
strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" );
|
49
|
+
});
|
50
|
+
|
51
|
+
test("object without getBoundingClientRect", function() {
|
52
|
+
expect(2);
|
53
|
+
|
54
|
+
// Simulates a browser without gBCR on elements, we just want to return 0,0
|
55
|
+
var result = jQuery({ ownerDocument: document }).offset();
|
56
|
+
equal( result.top, 0, "Check top" );
|
57
|
+
equal( result.left, 0, "Check left" );
|
58
|
+
});
|
59
|
+
|
60
|
+
test("disconnected node", function() {
|
61
|
+
expect(2);
|
62
|
+
|
63
|
+
var result = jQuery( document.createElement("div") ).offset();
|
64
|
+
|
65
|
+
equal( result.top, 0, "Check top" );
|
66
|
+
equal( result.left, 0, "Check left" );
|
67
|
+
});
|
68
|
+
|
69
|
+
testIframe("offset/absolute", "absolute", function($, iframe) {
|
70
|
+
expect(4);
|
71
|
+
|
72
|
+
var doc = iframe.document,
|
73
|
+
tests;
|
74
|
+
|
75
|
+
// get offset
|
76
|
+
tests = [
|
77
|
+
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
78
|
+
];
|
79
|
+
jQuery.each( tests, function() {
|
80
|
+
equal( jQuery( this["id"], doc ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
81
|
+
equal( jQuery( this["id"], doc ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
82
|
+
});
|
83
|
+
|
84
|
+
|
85
|
+
// get position
|
86
|
+
tests = [
|
87
|
+
{ "id": "#absolute-1", "top": 0, "left": 0 }
|
88
|
+
];
|
89
|
+
jQuery.each( tests, function() {
|
90
|
+
equal( jQuery( this["id"], doc ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
91
|
+
equal( jQuery( this["id"], doc ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
92
|
+
});
|
93
|
+
});
|
94
|
+
|
95
|
+
testIframe("offset/absolute", "absolute", function( $ ) {
|
96
|
+
expect(178);
|
97
|
+
|
98
|
+
var tests, offset;
|
99
|
+
|
100
|
+
// get offset tests
|
101
|
+
tests = [
|
102
|
+
{ "id": "#absolute-1", "top": 1, "left": 1 },
|
103
|
+
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
|
104
|
+
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
|
105
|
+
{ "id": "#absolute-2", "top": 20, "left": 20 }
|
106
|
+
];
|
107
|
+
jQuery.each( tests, function() {
|
108
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
109
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
110
|
+
});
|
111
|
+
|
112
|
+
|
113
|
+
// get position
|
114
|
+
tests = [
|
115
|
+
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
116
|
+
{ "id": "#absolute-1-1", "top": 1, "left": 1 },
|
117
|
+
{ "id": "#absolute-1-1-1", "top": 1, "left": 1 },
|
118
|
+
{ "id": "#absolute-2", "top": 19, "left": 19 }
|
119
|
+
];
|
120
|
+
jQuery.each( tests, function() {
|
121
|
+
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
122
|
+
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
123
|
+
});
|
124
|
+
|
125
|
+
// test #5781
|
126
|
+
offset = $( "#positionTest" ).offset({ "top": 10, "left": 10 }).offset();
|
127
|
+
equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
|
128
|
+
equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
|
129
|
+
|
130
|
+
|
131
|
+
// set offset
|
132
|
+
tests = [
|
133
|
+
{ "id": "#absolute-2", "top": 30, "left": 30 },
|
134
|
+
{ "id": "#absolute-2", "top": 10, "left": 10 },
|
135
|
+
{ "id": "#absolute-2", "top": -1, "left": -1 },
|
136
|
+
{ "id": "#absolute-2", "top": 19, "left": 19 },
|
137
|
+
{ "id": "#absolute-1-1-1", "top": 15, "left": 15 },
|
138
|
+
{ "id": "#absolute-1-1-1", "top": 5, "left": 5 },
|
139
|
+
{ "id": "#absolute-1-1-1", "top": -1, "left": -1 },
|
140
|
+
{ "id": "#absolute-1-1-1", "top": 9, "left": 9 },
|
141
|
+
{ "id": "#absolute-1-1", "top": 10, "left": 10 },
|
142
|
+
{ "id": "#absolute-1-1", "top": 0, "left": 0 },
|
143
|
+
{ "id": "#absolute-1-1", "top": -1, "left": -1 },
|
144
|
+
{ "id": "#absolute-1-1", "top": 5, "left": 5 },
|
145
|
+
{ "id": "#absolute-1", "top": 2, "left": 2 },
|
146
|
+
{ "id": "#absolute-1", "top": 0, "left": 0 },
|
147
|
+
{ "id": "#absolute-1", "top": -1, "left": -1 },
|
148
|
+
{ "id": "#absolute-1", "top": 1, "left": 1 }
|
149
|
+
];
|
150
|
+
jQuery.each( tests, function() {
|
151
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
152
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
153
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
154
|
+
|
155
|
+
var top = this["top"], left = this["left"];
|
156
|
+
|
157
|
+
$( this["id"] ).offset(function(i, val){
|
158
|
+
equal( val.top, top, "Verify incoming top position." );
|
159
|
+
equal( val.left, left, "Verify incoming top position." );
|
160
|
+
return { "top": top + 1, "left": left + 1 };
|
161
|
+
});
|
162
|
+
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + " })" );
|
163
|
+
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + " })" );
|
164
|
+
|
165
|
+
$( this["id"] )
|
166
|
+
.offset({ "left": this["left"] + 2 })
|
167
|
+
.offset({ "top": this["top"] + 2 });
|
168
|
+
equal( $( this["id"] ).offset().top, this["top"] + 2, "Setting one property at a time." );
|
169
|
+
equal( $( this["id"] ).offset().left, this["left"] + 2, "Setting one property at a time." );
|
170
|
+
|
171
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
172
|
+
$( this ).css({
|
173
|
+
"top": props.top + 1,
|
174
|
+
"left": props.left + 1
|
175
|
+
});
|
176
|
+
}});
|
177
|
+
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
178
|
+
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
179
|
+
});
|
180
|
+
});
|
181
|
+
|
182
|
+
testIframe("offset/relative", "relative", function( $ ) {
|
183
|
+
expect(60);
|
184
|
+
|
185
|
+
var ie, tests;
|
186
|
+
|
187
|
+
// IE is collapsing the top margin of 1px; detect and adjust accordingly
|
188
|
+
ie = $("#relative-1").offset().top === 6;
|
189
|
+
|
190
|
+
// get offset
|
191
|
+
tests = [
|
192
|
+
{ "id": "#relative-1", "top": ie ? 6 : 7, "left": 7 },
|
193
|
+
{ "id": "#relative-1-1", "top": ie ? 13 : 15, "left": 15 },
|
194
|
+
{ "id": "#relative-2", "top": ie ? 141 : 142, "left": 27 }
|
195
|
+
];
|
196
|
+
jQuery.each( tests, function() {
|
197
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
198
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
199
|
+
});
|
200
|
+
|
201
|
+
|
202
|
+
// get position
|
203
|
+
tests = [
|
204
|
+
{ "id": "#relative-1", "top": ie ? 5 : 6, "left": 6 },
|
205
|
+
{ "id": "#relative-1-1", "top": ie ? 4 : 5, "left": 5 },
|
206
|
+
{ "id": "#relative-2", "top": ie ? 140 : 141, "left": 26 }
|
207
|
+
];
|
208
|
+
jQuery.each( tests, function() {
|
209
|
+
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
|
210
|
+
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
|
211
|
+
});
|
212
|
+
|
213
|
+
|
214
|
+
// set offset
|
215
|
+
tests = [
|
216
|
+
{ "id": "#relative-2", "top": 200, "left": 50 },
|
217
|
+
{ "id": "#relative-2", "top": 100, "left": 10 },
|
218
|
+
{ "id": "#relative-2", "top": -5, "left": -5 },
|
219
|
+
{ "id": "#relative-2", "top": 142, "left": 27 },
|
220
|
+
{ "id": "#relative-1-1", "top": 100, "left": 100 },
|
221
|
+
{ "id": "#relative-1-1", "top": 5, "left": 5 },
|
222
|
+
{ "id": "#relative-1-1", "top": -1, "left": -1 },
|
223
|
+
{ "id": "#relative-1-1", "top": 15, "left": 15 },
|
224
|
+
{ "id": "#relative-1", "top": 100, "left": 100 },
|
225
|
+
{ "id": "#relative-1", "top": 0, "left": 0 },
|
226
|
+
{ "id": "#relative-1", "top": -1, "left": -1 },
|
227
|
+
{ "id": "#relative-1", "top": 7, "left": 7 }
|
228
|
+
];
|
229
|
+
jQuery.each( tests, function() {
|
230
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
231
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
232
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
233
|
+
|
234
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
235
|
+
$( this ).css({
|
236
|
+
"top": props.top + 1,
|
237
|
+
"left": props.left + 1
|
238
|
+
});
|
239
|
+
}});
|
240
|
+
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
241
|
+
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
242
|
+
});
|
243
|
+
});
|
244
|
+
|
245
|
+
testIframe("offset/static", "static", function( $ ) {
|
246
|
+
expect( 80 );
|
247
|
+
|
248
|
+
var ie, tests;
|
249
|
+
|
250
|
+
// IE is collapsing the top margin of 1px; detect and adjust accordingly
|
251
|
+
ie = $("#static-1").offset().top === 6;
|
252
|
+
|
253
|
+
// get offset
|
254
|
+
tests = [
|
255
|
+
{ "id": "#static-1", "top": ie ? 6 : 7, "left": 7 },
|
256
|
+
{ "id": "#static-1-1", "top": ie ? 13 : 15, "left": 15 },
|
257
|
+
{ "id": "#static-1-1-1", "top": ie ? 20 : 23, "left": 23 },
|
258
|
+
{ "id": "#static-2", "top": ie ? 121 : 122, left: 7 }
|
259
|
+
];
|
260
|
+
jQuery.each( tests, function() {
|
261
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
|
262
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
|
263
|
+
});
|
264
|
+
|
265
|
+
|
266
|
+
// get position
|
267
|
+
tests = [
|
268
|
+
{ "id": "#static-1", "top": ie ? 5 : 6, "left": 6 },
|
269
|
+
{ "id": "#static-1-1", "top": ie ? 12 : 14, "left": 14 },
|
270
|
+
{ "id": "#static-1-1-1", "top": ie ? 19 : 22, "left": 22 },
|
271
|
+
{ "id": "#static-2", "top": ie ? 120 : 121, "left": 6 }
|
272
|
+
];
|
273
|
+
jQuery.each( tests, function() {
|
274
|
+
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
|
275
|
+
equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" );
|
276
|
+
});
|
277
|
+
|
278
|
+
|
279
|
+
// set offset
|
280
|
+
tests = [
|
281
|
+
{ "id": "#static-2", "top": 200, "left": 200 },
|
282
|
+
{ "id": "#static-2", "top": 100, "left": 100 },
|
283
|
+
{ "id": "#static-2", "top": -2, "left": -2 },
|
284
|
+
{ "id": "#static-2", "top": 121, "left": 6 },
|
285
|
+
{ "id": "#static-1-1-1", "top": 50, "left": 50 },
|
286
|
+
{ "id": "#static-1-1-1", "top": 10, "left": 10 },
|
287
|
+
{ "id": "#static-1-1-1", "top": -1, "left": -1 },
|
288
|
+
{ "id": "#static-1-1-1", "top": 22, "left": 22 },
|
289
|
+
{ "id": "#static-1-1", "top": 25, "left": 25 },
|
290
|
+
{ "id": "#static-1-1", "top": 10, "left": 10 },
|
291
|
+
{ "id": "#static-1-1", "top": -3, "left": -3 },
|
292
|
+
{ "id": "#static-1-1", "top": 14, "left": 14 },
|
293
|
+
{ "id": "#static-1", "top": 30, "left": 30 },
|
294
|
+
{ "id": "#static-1", "top": 2, "left": 2 },
|
295
|
+
{ "id": "#static-1", "top": -2, "left": -2 },
|
296
|
+
{ "id": "#static-1", "top": 7, "left": 7 }
|
297
|
+
];
|
298
|
+
jQuery.each( tests, function() {
|
299
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
300
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
301
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
302
|
+
|
303
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
304
|
+
$( this ).css({
|
305
|
+
"top": props.top + 1,
|
306
|
+
"left": props.left + 1
|
307
|
+
});
|
308
|
+
}});
|
309
|
+
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
310
|
+
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
311
|
+
});
|
312
|
+
});
|
313
|
+
|
314
|
+
testIframe("offset/fixed", "fixed", function( $ ) {
|
315
|
+
expect(34);
|
316
|
+
|
317
|
+
var ie, tests, $noTopLeft;
|
318
|
+
|
319
|
+
// IE is collapsing the top margin of 1px; detect and adjust accordingly
|
320
|
+
ie = $("#fixed-1").position().top === 2;
|
321
|
+
|
322
|
+
tests = [
|
323
|
+
{
|
324
|
+
"id": "#fixed-1",
|
325
|
+
"offsetTop": 1001,
|
326
|
+
"offsetLeft": 1001,
|
327
|
+
"positionTop": ie ? 2 : 0,
|
328
|
+
"positionLeft": ie ? 2 : 0
|
329
|
+
},
|
330
|
+
{
|
331
|
+
"id": "#fixed-2",
|
332
|
+
"offsetTop": 1021,
|
333
|
+
"offsetLeft": 1021,
|
334
|
+
"positionTop": ie ? 22 : 20,
|
335
|
+
"positionLeft": ie ? 22 : 20
|
336
|
+
}
|
337
|
+
];
|
338
|
+
|
339
|
+
jQuery.each( tests, function() {
|
340
|
+
if ( !window.supportsScroll ) {
|
341
|
+
ok( true, "Browser doesn't support scroll position." );
|
342
|
+
ok( true, "Browser doesn't support scroll position." );
|
343
|
+
ok( true, "Browser doesn't support scroll position." );
|
344
|
+
ok( true, "Browser doesn't support scroll position." );
|
345
|
+
|
346
|
+
} else if ( window.supportsFixedPosition ) {
|
347
|
+
equal( $( this["id"] ).offset().top, this["offsetTop"], "jQuery('" + this["id"] + "').offset().top" );
|
348
|
+
equal( $( this["id"] ).position().top, this["positionTop"], "jQuery('" + this["id"] + "').position().top" );
|
349
|
+
equal( $( this["id"] ).offset().left, this["offsetLeft"], "jQuery('" + this["id"] + "').offset().left" );
|
350
|
+
equal( $( this["id"] ).position().left, this["positionLeft"], "jQuery('" + this["id"] + "').position().left" );
|
351
|
+
} else {
|
352
|
+
// need to have same number of assertions
|
353
|
+
ok( true, "Fixed position is not supported" );
|
354
|
+
ok( true, "Fixed position is not supported" );
|
355
|
+
ok( true, "Fixed position is not supported" );
|
356
|
+
ok( true, "Fixed position is not supported" );
|
357
|
+
}
|
358
|
+
});
|
359
|
+
|
360
|
+
tests = [
|
361
|
+
{ "id": "#fixed-1", "top": 100, "left": 100 },
|
362
|
+
{ "id": "#fixed-1", "top": 0, "left": 0 },
|
363
|
+
{ "id": "#fixed-1", "top": -4, "left": -4 },
|
364
|
+
{ "id": "#fixed-2", "top": 200, "left": 200 },
|
365
|
+
{ "id": "#fixed-2", "top": 0, "left": 0 },
|
366
|
+
{ "id": "#fixed-2", "top": -5, "left": -5 }
|
367
|
+
];
|
368
|
+
|
369
|
+
jQuery.each( tests, function() {
|
370
|
+
if ( window.supportsFixedPosition ) {
|
371
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
|
372
|
+
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
|
373
|
+
equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
|
374
|
+
|
375
|
+
$( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
|
376
|
+
$( this ).css({
|
377
|
+
"top": props.top + 1,
|
378
|
+
"left": props.left + 1
|
379
|
+
});
|
380
|
+
}});
|
381
|
+
equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
|
382
|
+
equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
|
383
|
+
} else {
|
384
|
+
// need to have same number of assertions
|
385
|
+
ok( true, "Fixed position is not supported" );
|
386
|
+
ok( true, "Fixed position is not supported" );
|
387
|
+
ok( true, "Fixed position is not supported" );
|
388
|
+
ok( true, "Fixed position is not supported" );
|
389
|
+
}
|
390
|
+
});
|
391
|
+
|
392
|
+
// Bug 8316
|
393
|
+
$noTopLeft = $("#fixed-no-top-left");
|
394
|
+
if ( window.supportsFixedPosition ) {
|
395
|
+
equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
|
396
|
+
equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
|
397
|
+
} else {
|
398
|
+
// need to have same number of assertions
|
399
|
+
ok( true, "Fixed position is not supported" );
|
400
|
+
ok( true, "Fixed position is not supported" );
|
401
|
+
}
|
402
|
+
});
|
403
|
+
|
404
|
+
testIframe("offset/table", "table", function( $ ) {
|
405
|
+
expect(4);
|
406
|
+
|
407
|
+
equal( $("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
|
408
|
+
equal( $("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
|
409
|
+
|
410
|
+
equal( $("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
|
411
|
+
equal( $("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
|
412
|
+
});
|
413
|
+
|
414
|
+
testIframe("offset/scroll", "scroll", function( $, win ) {
|
415
|
+
expect(24);
|
416
|
+
|
417
|
+
// If we're going to bastardize the tests, let's just DO it
|
418
|
+
var ie = /msie [678]/i.test( navigator.userAgent );
|
419
|
+
|
420
|
+
if ( ie ) {
|
421
|
+
ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
|
422
|
+
} else {
|
423
|
+
equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
|
424
|
+
}
|
425
|
+
equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
|
426
|
+
|
427
|
+
if ( ie ) {
|
428
|
+
ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
|
429
|
+
} else {
|
430
|
+
equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
|
431
|
+
}
|
432
|
+
equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
|
433
|
+
|
434
|
+
// scroll offset tests .scrollTop/Left
|
435
|
+
equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
|
436
|
+
equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
|
437
|
+
|
438
|
+
equal( $("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
|
439
|
+
equal( $("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
|
440
|
+
|
441
|
+
// scroll method chaining
|
442
|
+
equal( $("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
|
443
|
+
equal( $("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
|
444
|
+
|
445
|
+
win.name = "test";
|
446
|
+
|
447
|
+
if ( !window.supportsScroll ) {
|
448
|
+
ok( true, "Browser doesn't support scroll position." );
|
449
|
+
ok( true, "Browser doesn't support scroll position." );
|
450
|
+
|
451
|
+
ok( true, "Browser doesn't support scroll position." );
|
452
|
+
ok( true, "Browser doesn't support scroll position." );
|
453
|
+
} else {
|
454
|
+
equal( $(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
|
455
|
+
equal( $(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
|
456
|
+
|
457
|
+
equal( $(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
|
458
|
+
equal( $(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
|
459
|
+
}
|
460
|
+
|
461
|
+
// test jQuery using parent window/document
|
462
|
+
// jQuery reference here is in the iframe
|
463
|
+
window.scrollTo(0,0);
|
464
|
+
equal( $(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
|
465
|
+
equal( $(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
|
466
|
+
equal( $(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
|
467
|
+
equal( $(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
|
468
|
+
|
469
|
+
// Tests scrollTop/Left with empty jquery objects
|
470
|
+
notEqual( $().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
471
|
+
notEqual( $().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
472
|
+
notEqual( $().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
|
473
|
+
notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
|
474
|
+
strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
|
475
|
+
strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
|
476
|
+
});
|
477
|
+
|
478
|
+
testIframe("offset/body", "body", function( $ ) {
|
479
|
+
expect(4);
|
480
|
+
|
481
|
+
equal( $("body").offset().top, 1, "jQuery('#body').offset().top" );
|
482
|
+
equal( $("body").offset().left, 1, "jQuery('#body').offset().left" );
|
483
|
+
equal( $("#firstElement").position().left, 5, "$('#firstElement').position().left" );
|
484
|
+
equal( $("#firstElement").position().top, 5, "$('#firstElement').position().top" );
|
485
|
+
});
|
486
|
+
|
487
|
+
test("chaining", function() {
|
488
|
+
expect(3);
|
489
|
+
var coords = { "top": 1, "left": 1 };
|
490
|
+
equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
|
491
|
+
equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
|
492
|
+
equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
|
493
|
+
});
|
494
|
+
|
495
|
+
test("offsetParent", function(){
|
496
|
+
expect(13);
|
497
|
+
|
498
|
+
var body, header, div, area;
|
499
|
+
|
500
|
+
body = jQuery("body").offsetParent();
|
501
|
+
equal( body.length, 1, "Only one offsetParent found." );
|
502
|
+
equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
|
503
|
+
|
504
|
+
header = jQuery("#qunit").offsetParent();
|
505
|
+
equal( header.length, 1, "Only one offsetParent found." );
|
506
|
+
equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
|
507
|
+
|
508
|
+
div = jQuery("#nothiddendivchild").offsetParent();
|
509
|
+
equal( div.length, 1, "Only one offsetParent found." );
|
510
|
+
equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
|
511
|
+
|
512
|
+
jQuery("#nothiddendiv").css("position", "relative");
|
513
|
+
|
514
|
+
div = jQuery("#nothiddendivchild").offsetParent();
|
515
|
+
equal( div.length, 1, "Only one offsetParent found." );
|
516
|
+
equal( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
517
|
+
|
518
|
+
div = jQuery("body, #nothiddendivchild").offsetParent();
|
519
|
+
equal( div.length, 2, "Two offsetParent found." );
|
520
|
+
equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
|
521
|
+
equal( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
|
522
|
+
|
523
|
+
area = jQuery("#imgmap area").offsetParent();
|
524
|
+
equal( area[0], document.documentElement, "The html element is the offsetParent of the body." );
|
525
|
+
|
526
|
+
div = jQuery("<div>").css({ "position": "absolute" }).appendTo("body");
|
527
|
+
equal( div.offsetParent()[0], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" );
|
528
|
+
|
529
|
+
div.remove();
|
530
|
+
});
|
531
|
+
|
532
|
+
test("fractions (see #7730 and #7885)", function() {
|
533
|
+
expect(2);
|
534
|
+
|
535
|
+
jQuery("body").append("<div id='fractions'/>");
|
536
|
+
|
537
|
+
var result,
|
538
|
+
expected = { "top": 1000, "left": 1000 },
|
539
|
+
div = jQuery("#fractions");
|
540
|
+
|
541
|
+
div.css({
|
542
|
+
"position": "absolute",
|
543
|
+
"left": "1000.7432222px",
|
544
|
+
"top": "1000.532325px",
|
545
|
+
"width": 100,
|
546
|
+
"height": 100
|
547
|
+
});
|
548
|
+
|
549
|
+
div.offset(expected);
|
550
|
+
|
551
|
+
result = div.offset();
|
552
|
+
|
553
|
+
equal( result.top, expected.top, "Check top" );
|
554
|
+
equal( result.left, expected.left, "Check left" );
|
555
|
+
|
556
|
+
div.remove();
|
557
|
+
});
|
558
|
+
|
559
|
+
})();
|