lady_josephine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/fonts/lady_josephine/icons/icons.eot +0 -0
  5. data/app/assets/fonts/lady_josephine/icons/icons.svg +215 -0
  6. data/app/assets/fonts/lady_josephine/icons/icons.ttf +0 -0
  7. data/app/assets/fonts/lady_josephine/icons/icons.woff +0 -0
  8. data/app/assets/javascripts/lady_josephine/blocks/facebook.js +25 -0
  9. data/app/assets/javascripts/lady_josephine/blocks/instagram.js +22 -0
  10. data/app/assets/javascripts/lady_josephine/blocks/soundcloud.js +24 -0
  11. data/app/assets/javascripts/lady_josephine/blocks/twitter.js +25 -0
  12. data/app/assets/javascripts/lady_josephine/blocks/vimeo.js +55 -0
  13. data/app/assets/javascripts/lady_josephine/blocks/youtube.js +64 -0
  14. data/app/assets/javascripts/lady_josephine/editor.js +40 -0
  15. data/app/assets/javascripts/lady_josephine/lady_josephine.js +4 -0
  16. data/app/assets/javascripts/lady_josephine/lady_josephine_view.js +6 -0
  17. data/app/assets/stylesheets/lady_josephine/content.sass +33 -0
  18. data/app/assets/stylesheets/lady_josephine/icons.sass +175 -0
  19. data/app/assets/stylesheets/lady_josephine/lady_josephine.sass +6 -0
  20. data/app/assets/stylesheets/lady_josephine/sir_trevor.sass +619 -0
  21. data/app/assets/stylesheets/lady_josephine/vars.sass +36 -0
  22. data/app/controllers/lady_josephine/application_controller.rb +4 -0
  23. data/app/controllers/lady_josephine/editor_controller.rb +40 -0
  24. data/app/controllers/lady_josephine/images_controller.rb +26 -0
  25. data/app/helpers/lady_josephine/helper.rb +25 -0
  26. data/app/helpers/lady_josephine/sir_trevor_helper.rb +172 -0
  27. data/app/models/lady_josephine/concerns/model.rb +29 -0
  28. data/app/models/lady_josephine/concerns/pingable.rb +28 -0
  29. data/app/models/lady_josephine/concerns/server_uuid.rb +24 -0
  30. data/app/models/lady_josephine/concerns/sir_trevor_images.rb +38 -0
  31. data/app/models/lady_josephine/image.rb +41 -0
  32. data/app/uploader/lady_josephine/base_uploader.rb +47 -0
  33. data/app/uploader/lady_josephine/image_uploader.rb +149 -0
  34. data/app/views/lady_josephine/blocks/_audio_block.haml +2 -0
  35. data/app/views/lady_josephine/blocks/_definition_block.haml +4 -0
  36. data/app/views/lady_josephine/blocks/_divider_block.haml +2 -0
  37. data/app/views/lady_josephine/blocks/_extended_image_block.haml +63 -0
  38. data/app/views/lady_josephine/blocks/_extended_quote_block.haml +5 -0
  39. data/app/views/lady_josephine/blocks/_extended_tweet_block.haml +2 -0
  40. data/app/views/lady_josephine/blocks/_facebook_post_block.haml +2 -0
  41. data/app/views/lady_josephine/blocks/_heading_block.haml +2 -0
  42. data/app/views/lady_josephine/blocks/_html_block.haml +1 -0
  43. data/app/views/lady_josephine/blocks/_instagram_block.haml +2 -0
  44. data/app/views/lady_josephine/blocks/_list_block.haml +3 -0
  45. data/app/views/lady_josephine/blocks/_quote_block.haml +5 -0
  46. data/app/views/lady_josephine/blocks/_text_block.html.haml +2 -0
  47. data/app/views/lady_josephine/blocks/_video_block.haml +9 -0
  48. data/config/routes.rb +9 -0
  49. data/db/migrate/20160222151500_lady_josephine_image.rb +18 -0
  50. data/lib/generators/lady_josephine_migration/USAGE +9 -0
  51. data/lib/generators/lady_josephine_migration/lady_josephine_migration_generator.rb +17 -0
  52. data/lib/generators/lady_josephine_migration/templates/migration.rb +9 -0
  53. data/lib/lady_josephine.rb +18 -0
  54. data/lib/lady_josephine/engine.rb +18 -0
  55. data/lib/lady_josephine/redcarpet/custom_markdown_formatter.rb +63 -0
  56. data/lib/lady_josephine/renderer/sir_trevor_renderer.rb +16 -0
  57. data/lib/lady_josephine/version.rb +3 -0
  58. data/lib/lady_josephine/whitelist.rb +26 -0
  59. data/lib/tasks/lady_josephine_tasks.rake +4 -0
  60. data/spec/controllers/lady_josephine/editor_controller_spec.rb +58 -0
  61. data/spec/dummy/README.rdoc +28 -0
  62. data/spec/dummy/Rakefile +6 -0
  63. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  64. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  65. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  66. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  67. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/spec/dummy/bin/bundle +3 -0
  69. data/spec/dummy/bin/rails +4 -0
  70. data/spec/dummy/bin/rake +4 -0
  71. data/spec/dummy/bin/setup +29 -0
  72. data/spec/dummy/config.ru +4 -0
  73. data/spec/dummy/config/application.rb +26 -0
  74. data/spec/dummy/config/boot.rb +5 -0
  75. data/spec/dummy/config/database.yml +25 -0
  76. data/spec/dummy/config/environment.rb +5 -0
  77. data/spec/dummy/config/environments/development.rb +41 -0
  78. data/spec/dummy/config/environments/production.rb +79 -0
  79. data/spec/dummy/config/environments/test.rb +42 -0
  80. data/spec/dummy/config/initializers/assets.rb +11 -0
  81. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  82. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  83. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  84. data/spec/dummy/config/initializers/inflections.rb +16 -0
  85. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  86. data/spec/dummy/config/initializers/session_store.rb +3 -0
  87. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  88. data/spec/dummy/config/locales/en.yml +23 -0
  89. data/spec/dummy/config/routes.rb +4 -0
  90. data/spec/dummy/config/secrets.yml +22 -0
  91. data/spec/dummy/db/development.sqlite3 +0 -0
  92. data/spec/dummy/db/schema.rb +16 -0
  93. data/spec/dummy/db/test.sqlite3 +0 -0
  94. data/spec/dummy/log/bla +0 -0
  95. data/spec/dummy/public/404.html +67 -0
  96. data/spec/dummy/public/422.html +67 -0
  97. data/spec/dummy/public/500.html +66 -0
  98. data/spec/dummy/public/favicon.ico +0 -0
  99. data/spec/spec_helper.rb +17 -0
  100. data/vendor/assets/components/Eventable/README.md +12 -0
  101. data/vendor/assets/components/Eventable/bower.json +10 -0
  102. data/vendor/assets/components/Eventable/component.json +11 -0
  103. data/vendor/assets/components/Eventable/eventable.js +207 -0
  104. data/vendor/assets/components/Eventable/package.json +15 -0
  105. data/vendor/assets/components/jquery-autosize/bower.json +30 -0
  106. data/vendor/assets/components/jquery-autosize/demo.html +36 -0
  107. data/vendor/assets/components/jquery-autosize/jquery.autosize.js +273 -0
  108. data/vendor/assets/components/jquery-autosize/jquery.autosize.min.js +6 -0
  109. data/vendor/assets/components/jquery-autosize/package.json +32 -0
  110. data/vendor/assets/components/jquery-autosize/readme.md +216 -0
  111. data/vendor/assets/components/jquery/AUTHORS.txt +163 -0
  112. data/vendor/assets/components/jquery/CONTRIBUTING.md +216 -0
  113. data/vendor/assets/components/jquery/Gruntfile.js +496 -0
  114. data/vendor/assets/components/jquery/MIT-LICENSE.txt +21 -0
  115. data/vendor/assets/components/jquery/README.md +415 -0
  116. data/vendor/assets/components/jquery/build/release-notes.js +59 -0
  117. data/vendor/assets/components/jquery/build/release.js +246 -0
  118. data/vendor/assets/components/jquery/component.json +13 -0
  119. data/vendor/assets/components/jquery/composer.json +35 -0
  120. data/vendor/assets/components/jquery/jquery-migrate.js +496 -0
  121. data/vendor/assets/components/jquery/jquery-migrate.min.js +3 -0
  122. data/vendor/assets/components/jquery/jquery.js +9597 -0
  123. data/vendor/assets/components/jquery/jquery.min.js +5 -0
  124. data/vendor/assets/components/jquery/jquery.min.map +1 -0
  125. data/vendor/assets/components/jquery/package.json +39 -0
  126. data/vendor/assets/components/jquery/speed/benchmark.js +15 -0
  127. data/vendor/assets/components/jquery/speed/benchmarker.css +65 -0
  128. data/vendor/assets/components/jquery/speed/benchmarker.js +181 -0
  129. data/vendor/assets/components/jquery/speed/closest.html +39 -0
  130. data/vendor/assets/components/jquery/speed/css.html +82 -0
  131. data/vendor/assets/components/jquery/speed/event.html +58 -0
  132. data/vendor/assets/components/jquery/speed/filter.html +183 -0
  133. data/vendor/assets/components/jquery/speed/find.html +179 -0
  134. data/vendor/assets/components/jquery/speed/index.html +72 -0
  135. data/vendor/assets/components/jquery/speed/jquery-basis.js +6238 -0
  136. data/vendor/assets/components/jquery/speed/slice.vs.concat.html +47 -0
  137. data/vendor/assets/components/jquery/src/ajax.js +851 -0
  138. data/vendor/assets/components/jquery/src/ajax/jsonp.js +80 -0
  139. data/vendor/assets/components/jquery/src/ajax/script.js +86 -0
  140. data/vendor/assets/components/jquery/src/ajax/xhr.js +207 -0
  141. data/vendor/assets/components/jquery/src/attributes.js +661 -0
  142. data/vendor/assets/components/jquery/src/callbacks.js +196 -0
  143. data/vendor/assets/components/jquery/src/core.js +949 -0
  144. data/vendor/assets/components/jquery/src/css.js +679 -0
  145. data/vendor/assets/components/jquery/src/data.js +340 -0
  146. data/vendor/assets/components/jquery/src/deferred.js +141 -0
  147. data/vendor/assets/components/jquery/src/deprecated.js +4 -0
  148. data/vendor/assets/components/jquery/src/dimensions.js +41 -0
  149. data/vendor/assets/components/jquery/src/effects.js +730 -0
  150. data/vendor/assets/components/jquery/src/event-alias.js +15 -0
  151. data/vendor/assets/components/jquery/src/event.js +991 -0
  152. data/vendor/assets/components/jquery/src/exports.js +18 -0
  153. data/vendor/assets/components/jquery/src/intro.js +20 -0
  154. data/vendor/assets/components/jquery/src/manipulation.js +796 -0
  155. data/vendor/assets/components/jquery/src/offset.js +169 -0
  156. data/vendor/assets/components/jquery/src/outro.js +2 -0
  157. data/vendor/assets/components/jquery/src/queue.js +147 -0
  158. data/vendor/assets/components/jquery/src/serialize.js +99 -0
  159. data/vendor/assets/components/jquery/src/sizzle-jquery.js +9 -0
  160. data/vendor/assets/components/jquery/src/support.js +241 -0
  161. data/vendor/assets/components/jquery/src/traversing.js +275 -0
  162. data/vendor/assets/components/jquery/test/csp.php +16 -0
  163. data/vendor/assets/components/jquery/test/data/1x1.jpg +0 -0
  164. data/vendor/assets/components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
  165. data/vendor/assets/components/jquery/test/data/atom+xml.php +4 -0
  166. data/vendor/assets/components/jquery/test/data/badcall.js +1 -0
  167. data/vendor/assets/components/jquery/test/data/badjson.js +1 -0
  168. data/vendor/assets/components/jquery/test/data/cleanScript.html +10 -0
  169. data/vendor/assets/components/jquery/test/data/core/cc_on.html +22 -0
  170. data/vendor/assets/components/jquery/test/data/dashboard.xml +11 -0
  171. data/vendor/assets/components/jquery/test/data/dimensions/documentLarge.html +17 -0
  172. data/vendor/assets/components/jquery/test/data/dimensions/documentSmall.html +21 -0
  173. data/vendor/assets/components/jquery/test/data/echoData.php +1 -0
  174. data/vendor/assets/components/jquery/test/data/echoQuery.php +1 -0
  175. data/vendor/assets/components/jquery/test/data/errorWithText.php +5 -0
  176. data/vendor/assets/components/jquery/test/data/etag.php +21 -0
  177. data/vendor/assets/components/jquery/test/data/evalScript.php +1 -0
  178. data/vendor/assets/components/jquery/test/data/event/longLoadScript.php +4 -0
  179. data/vendor/assets/components/jquery/test/data/event/promiseReady.html +17 -0
  180. data/vendor/assets/components/jquery/test/data/event/syncReady.html +23 -0
  181. data/vendor/assets/components/jquery/test/data/headers.php +18 -0
  182. data/vendor/assets/components/jquery/test/data/if_modified_since.php +20 -0
  183. data/vendor/assets/components/jquery/test/data/iframe.html +8 -0
  184. data/vendor/assets/components/jquery/test/data/jquery-1.8.2.ajax_xhr.min.js +2 -0
  185. data/vendor/assets/components/jquery/test/data/json.php +13 -0
  186. data/vendor/assets/components/jquery/test/data/json_obj.js +1 -0
  187. data/vendor/assets/components/jquery/test/data/jsonp.php +14 -0
  188. data/vendor/assets/components/jquery/test/data/manipulation/iframe-denied.html +36 -0
  189. data/vendor/assets/components/jquery/test/data/name.html +1 -0
  190. data/vendor/assets/components/jquery/test/data/name.php +24 -0
  191. data/vendor/assets/components/jquery/test/data/nocontent.php +5 -0
  192. data/vendor/assets/components/jquery/test/data/offset/absolute.html +41 -0
  193. data/vendor/assets/components/jquery/test/data/offset/body.html +26 -0
  194. data/vendor/assets/components/jquery/test/data/offset/fixed.html +34 -0
  195. data/vendor/assets/components/jquery/test/data/offset/relative.html +31 -0
  196. data/vendor/assets/components/jquery/test/data/offset/scroll.html +39 -0
  197. data/vendor/assets/components/jquery/test/data/offset/static.html +31 -0
  198. data/vendor/assets/components/jquery/test/data/offset/table.html +43 -0
  199. data/vendor/assets/components/jquery/test/data/params_html.php +12 -0
  200. data/vendor/assets/components/jquery/test/data/readywaitasset.js +1 -0
  201. data/vendor/assets/components/jquery/test/data/readywaitloader.js +25 -0
  202. data/vendor/assets/components/jquery/test/data/script.php +11 -0
  203. data/vendor/assets/components/jquery/test/data/selector/html5_selector.html +114 -0
  204. data/vendor/assets/components/jquery/test/data/selector/sizzle_cache.html +21 -0
  205. data/vendor/assets/components/jquery/test/data/statusText.php +5 -0
  206. data/vendor/assets/components/jquery/test/data/support/bodyBackground.html +28 -0
  207. data/vendor/assets/components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
  208. data/vendor/assets/components/jquery/test/data/support/testElementCrash.html +17 -0
  209. data/vendor/assets/components/jquery/test/data/test.html +7 -0
  210. data/vendor/assets/components/jquery/test/data/test.js +3 -0
  211. data/vendor/assets/components/jquery/test/data/test.php +7 -0
  212. data/vendor/assets/components/jquery/test/data/test2.html +5 -0
  213. data/vendor/assets/components/jquery/test/data/test3.html +3 -0
  214. data/vendor/assets/components/jquery/test/data/testinit.js +269 -0
  215. data/vendor/assets/components/jquery/test/data/testrunner.js +368 -0
  216. data/vendor/assets/components/jquery/test/data/testsuite.css +155 -0
  217. data/vendor/assets/components/jquery/test/data/text.php +12 -0
  218. data/vendor/assets/components/jquery/test/data/ua.txt +272 -0
  219. data/vendor/assets/components/jquery/test/data/with_fries.xml +25 -0
  220. data/vendor/assets/components/jquery/test/data/with_fries_over_jsonp.php +7 -0
  221. data/vendor/assets/components/jquery/test/delegatetest.html +228 -0
  222. data/vendor/assets/components/jquery/test/hovertest.html +158 -0
  223. data/vendor/assets/components/jquery/test/index.html +330 -0
  224. data/vendor/assets/components/jquery/test/localfile.html +75 -0
  225. data/vendor/assets/components/jquery/test/networkerror.html +84 -0
  226. data/vendor/assets/components/jquery/test/polluted.php +110 -0
  227. data/vendor/assets/components/jquery/test/readywait.html +70 -0
  228. data/vendor/assets/components/jquery/test/unit/ajax.js +1971 -0
  229. data/vendor/assets/components/jquery/test/unit/attributes.js +1332 -0
  230. data/vendor/assets/components/jquery/test/unit/callbacks.js +326 -0
  231. data/vendor/assets/components/jquery/test/unit/core.js +1332 -0
  232. data/vendor/assets/components/jquery/test/unit/css.js +1036 -0
  233. data/vendor/assets/components/jquery/test/unit/data.js +636 -0
  234. data/vendor/assets/components/jquery/test/unit/deferred.js +440 -0
  235. data/vendor/assets/components/jquery/test/unit/deprecated.js +1 -0
  236. data/vendor/assets/components/jquery/test/unit/dimensions.js +461 -0
  237. data/vendor/assets/components/jquery/test/unit/effects.js +2050 -0
  238. data/vendor/assets/components/jquery/test/unit/event.js +2690 -0
  239. data/vendor/assets/components/jquery/test/unit/exports.js +7 -0
  240. data/vendor/assets/components/jquery/test/unit/manipulation.js +2242 -0
  241. data/vendor/assets/components/jquery/test/unit/offset.js +549 -0
  242. data/vendor/assets/components/jquery/test/unit/queue.js +316 -0
  243. data/vendor/assets/components/jquery/test/unit/selector.js +185 -0
  244. data/vendor/assets/components/jquery/test/unit/serialize.js +146 -0
  245. data/vendor/assets/components/jquery/test/unit/support.js +384 -0
  246. data/vendor/assets/components/jquery/test/unit/traversing.js +667 -0
  247. data/vendor/assets/components/jquery/test/xhtml.php +5 -0
  248. data/vendor/assets/components/sir-trevor-js/CHANGELOG.md +44 -0
  249. data/vendor/assets/components/sir-trevor-js/Gemfile +3 -0
  250. data/vendor/assets/components/sir-trevor-js/Gemfile.lock +10 -0
  251. data/vendor/assets/components/sir-trevor-js/Gruntfile.js +109 -0
  252. data/vendor/assets/components/sir-trevor-js/MIT-LICENCE +20 -0
  253. data/vendor/assets/components/sir-trevor-js/Readme.md +84 -0
  254. data/vendor/assets/components/sir-trevor-js/bower.json +21 -0
  255. data/vendor/assets/components/sir-trevor-js/component.json +42 -0
  256. data/vendor/assets/components/sir-trevor-js/contributing.md +74 -0
  257. data/vendor/assets/components/sir-trevor-js/examples-component/component.json +14 -0
  258. data/vendor/assets/components/sir-trevor-js/examples-component/index.html +33 -0
  259. data/vendor/assets/components/sir-trevor-js/examples-component/index.js +29 -0
  260. data/vendor/assets/components/sir-trevor-js/examples-component/javascript/example_block.js +203 -0
  261. data/vendor/assets/components/sir-trevor-js/examples-component/javascript/limit_chars.js +46 -0
  262. data/vendor/assets/components/sir-trevor-js/examples-component/sir-trevor.gif +0 -0
  263. data/vendor/assets/components/sir-trevor-js/locales/cn.js +51 -0
  264. data/vendor/assets/components/sir-trevor-js/locales/de.js +51 -0
  265. data/vendor/assets/components/sir-trevor-js/locales/es.js +51 -0
  266. data/vendor/assets/components/sir-trevor-js/locales/fi.js +51 -0
  267. data/vendor/assets/components/sir-trevor-js/locales/fr.js +51 -0
  268. data/vendor/assets/components/sir-trevor-js/locales/pt.js +52 -0
  269. data/vendor/assets/components/sir-trevor-js/package.json +23 -0
  270. data/vendor/assets/components/sir-trevor-js/sir-trevor-icons.css +6 -0
  271. data/vendor/assets/components/sir-trevor-js/sir-trevor.css +393 -0
  272. data/vendor/assets/components/sir-trevor-js/sir-trevor.css.map +7 -0
  273. data/vendor/assets/components/sir-trevor-js/sir-trevor.js +5481 -0
  274. data/vendor/assets/components/sir-trevor-js/sir-trevor.min.js +13 -0
  275. data/vendor/assets/components/underscore/CNAME +1 -0
  276. data/vendor/assets/components/underscore/CONTRIBUTING.md +9 -0
  277. data/vendor/assets/components/underscore/LICENSE +22 -0
  278. data/vendor/assets/components/underscore/README.md +19 -0
  279. data/vendor/assets/components/underscore/Rakefile +10 -0
  280. data/vendor/assets/components/underscore/docs/docco.css +192 -0
  281. data/vendor/assets/components/underscore/docs/favicon.ico +0 -0
  282. data/vendor/assets/components/underscore/docs/images/background.png +0 -0
  283. data/vendor/assets/components/underscore/docs/images/underscore.png +0 -0
  284. data/vendor/assets/components/underscore/docs/underscore.html +823 -0
  285. data/vendor/assets/components/underscore/favicon.ico +0 -0
  286. data/vendor/assets/components/underscore/index.html +2467 -0
  287. data/vendor/assets/components/underscore/index.js +1 -0
  288. data/vendor/assets/components/underscore/package.json +16 -0
  289. data/vendor/assets/components/underscore/test/arrays.js +200 -0
  290. data/vendor/assets/components/underscore/test/chaining.js +59 -0
  291. data/vendor/assets/components/underscore/test/collections.js +453 -0
  292. data/vendor/assets/components/underscore/test/functions.js +265 -0
  293. data/vendor/assets/components/underscore/test/index.html +44 -0
  294. data/vendor/assets/components/underscore/test/objects.js +570 -0
  295. data/vendor/assets/components/underscore/test/speed.js +75 -0
  296. data/vendor/assets/components/underscore/test/utility.js +266 -0
  297. data/vendor/assets/components/underscore/test/vendor/jquery.js +9404 -0
  298. data/vendor/assets/components/underscore/test/vendor/jslitmus.js +670 -0
  299. data/vendor/assets/components/underscore/test/vendor/qunit.css +235 -0
  300. data/vendor/assets/components/underscore/test/vendor/qunit.js +1977 -0
  301. data/vendor/assets/components/underscore/test/vendor/runner.js +98 -0
  302. data/vendor/assets/components/underscore/underscore-min.js +1 -0
  303. data/vendor/assets/components/underscore/underscore.js +1226 -0
  304. metadata +473 -0
@@ -0,0 +1,549 @@
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
+ // get offset tests
99
+ var tests = [
100
+ { "id": "#absolute-1", "top": 1, "left": 1 },
101
+ { "id": "#absolute-1-1", "top": 5, "left": 5 },
102
+ { "id": "#absolute-1-1-1", "top": 9, "left": 9 },
103
+ { "id": "#absolute-2", "top": 20, "left": 20 }
104
+ ];
105
+ jQuery.each( tests, function() {
106
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
107
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
108
+ });
109
+
110
+
111
+ // get position
112
+ tests = [
113
+ { "id": "#absolute-1", "top": 0, "left": 0 },
114
+ { "id": "#absolute-1-1", "top": 1, "left": 1 },
115
+ { "id": "#absolute-1-1-1", "top": 1, "left": 1 },
116
+ { "id": "#absolute-2", "top": 19, "left": 19 }
117
+ ];
118
+ jQuery.each( tests, function() {
119
+ equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
120
+ equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
121
+ });
122
+
123
+ // test #5781
124
+ var offset = $( "#positionTest" ).offset({ "top": 10, "left": 10 }).offset();
125
+ equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." );
126
+ equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." );
127
+
128
+
129
+ // set offset
130
+ tests = [
131
+ { "id": "#absolute-2", "top": 30, "left": 30 },
132
+ { "id": "#absolute-2", "top": 10, "left": 10 },
133
+ { "id": "#absolute-2", "top": -1, "left": -1 },
134
+ { "id": "#absolute-2", "top": 19, "left": 19 },
135
+ { "id": "#absolute-1-1-1", "top": 15, "left": 15 },
136
+ { "id": "#absolute-1-1-1", "top": 5, "left": 5 },
137
+ { "id": "#absolute-1-1-1", "top": -1, "left": -1 },
138
+ { "id": "#absolute-1-1-1", "top": 9, "left": 9 },
139
+ { "id": "#absolute-1-1", "top": 10, "left": 10 },
140
+ { "id": "#absolute-1-1", "top": 0, "left": 0 },
141
+ { "id": "#absolute-1-1", "top": -1, "left": -1 },
142
+ { "id": "#absolute-1-1", "top": 5, "left": 5 },
143
+ { "id": "#absolute-1", "top": 2, "left": 2 },
144
+ { "id": "#absolute-1", "top": 0, "left": 0 },
145
+ { "id": "#absolute-1", "top": -1, "left": -1 },
146
+ { "id": "#absolute-1", "top": 1, "left": 1 }
147
+ ];
148
+ jQuery.each( tests, function() {
149
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
150
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
151
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
152
+
153
+ var top = this["top"], left = this["left"];
154
+
155
+ $( this["id"] ).offset(function(i, val){
156
+ equal( val.top, top, "Verify incoming top position." );
157
+ equal( val.left, left, "Verify incoming top position." );
158
+ return { "top": top + 1, "left": left + 1 };
159
+ });
160
+ equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + " })" );
161
+ equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + " })" );
162
+
163
+ $( this["id"] )
164
+ .offset({ "left": this["left"] + 2 })
165
+ .offset({ "top": this["top"] + 2 });
166
+ equal( $( this["id"] ).offset().top, this["top"] + 2, "Setting one property at a time." );
167
+ equal( $( this["id"] ).offset().left, this["left"] + 2, "Setting one property at a time." );
168
+
169
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
170
+ $( this ).css({
171
+ "top": props.top + 1,
172
+ "left": props.left + 1
173
+ });
174
+ }});
175
+ equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
176
+ equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
177
+ });
178
+ });
179
+
180
+ testIframe("offset/relative", "relative", function( $ ) {
181
+ expect(60);
182
+
183
+ // IE is collapsing the top margin of 1px; detect and adjust accordingly
184
+ var ie = $("#relative-1").offset().top === 6;
185
+
186
+ // get offset
187
+ var tests = [
188
+ { "id": "#relative-1", "top": ie ? 6 : 7, "left": 7 },
189
+ { "id": "#relative-1-1", "top": ie ? 13 : 15, "left": 15 },
190
+ { "id": "#relative-2", "top": ie ? 141 : 142, "left": 27 }
191
+ ];
192
+ jQuery.each( tests, function() {
193
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
194
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
195
+ });
196
+
197
+
198
+ // get position
199
+ tests = [
200
+ { "id": "#relative-1", "top": ie ? 5 : 6, "left": 6 },
201
+ { "id": "#relative-1-1", "top": ie ? 4 : 5, "left": 5 },
202
+ { "id": "#relative-2", "top": ie ? 140 : 141, "left": 26 }
203
+ ];
204
+ jQuery.each( tests, function() {
205
+ equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
206
+ equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["id"] + "').position().left" );
207
+ });
208
+
209
+
210
+ // set offset
211
+ tests = [
212
+ { "id": "#relative-2", "top": 200, "left": 50 },
213
+ { "id": "#relative-2", "top": 100, "left": 10 },
214
+ { "id": "#relative-2", "top": -5, "left": -5 },
215
+ { "id": "#relative-2", "top": 142, "left": 27 },
216
+ { "id": "#relative-1-1", "top": 100, "left": 100 },
217
+ { "id": "#relative-1-1", "top": 5, "left": 5 },
218
+ { "id": "#relative-1-1", "top": -1, "left": -1 },
219
+ { "id": "#relative-1-1", "top": 15, "left": 15 },
220
+ { "id": "#relative-1", "top": 100, "left": 100 },
221
+ { "id": "#relative-1", "top": 0, "left": 0 },
222
+ { "id": "#relative-1", "top": -1, "left": -1 },
223
+ { "id": "#relative-1", "top": 7, "left": 7 }
224
+ ];
225
+ jQuery.each( tests, function() {
226
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
227
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
228
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
229
+
230
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
231
+ $( this ).css({
232
+ "top": props.top + 1,
233
+ "left": props.left + 1
234
+ });
235
+ }});
236
+ equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
237
+ equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
238
+ });
239
+ });
240
+
241
+ testIframe("offset/static", "static", function( $ ) {
242
+
243
+ // IE is collapsing the top margin of 1px; detect and adjust accordingly
244
+ var ie = $("#static-1").offset().top === 6;
245
+
246
+ expect( 80 );
247
+
248
+ // get offset
249
+ var tests = [
250
+ { "id": "#static-1", "top": ie ? 6 : 7, "left": 7 },
251
+ { "id": "#static-1-1", "top": ie ? 13 : 15, "left": 15 },
252
+ { "id": "#static-1-1-1", "top": ie ? 20 : 23, "left": 23 },
253
+ { "id": "#static-2", "top": ie ? 121 : 122, left: 7 }
254
+ ];
255
+ jQuery.each( tests, function() {
256
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
257
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset().left" );
258
+ });
259
+
260
+
261
+ // get position
262
+ tests = [
263
+ { "id": "#static-1", "top": ie ? 5 : 6, "left": 6 },
264
+ { "id": "#static-1-1", "top": ie ? 12 : 14, "left": 14 },
265
+ { "id": "#static-1-1-1", "top": ie ? 19 : 22, "left": 22 },
266
+ { "id": "#static-2", "top": ie ? 120 : 121, "left": 6 }
267
+ ];
268
+ jQuery.each( tests, function() {
269
+ equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
270
+ equal( $( this["id"] ).position().left, this["left"], "jQuery('" + this["left"] +"').position().left" );
271
+ });
272
+
273
+
274
+ // set offset
275
+ tests = [
276
+ { "id": "#static-2", "top": 200, "left": 200 },
277
+ { "id": "#static-2", "top": 100, "left": 100 },
278
+ { "id": "#static-2", "top": -2, "left": -2 },
279
+ { "id": "#static-2", "top": 121, "left": 6 },
280
+ { "id": "#static-1-1-1", "top": 50, "left": 50 },
281
+ { "id": "#static-1-1-1", "top": 10, "left": 10 },
282
+ { "id": "#static-1-1-1", "top": -1, "left": -1 },
283
+ { "id": "#static-1-1-1", "top": 22, "left": 22 },
284
+ { "id": "#static-1-1", "top": 25, "left": 25 },
285
+ { "id": "#static-1-1", "top": 10, "left": 10 },
286
+ { "id": "#static-1-1", "top": -3, "left": -3 },
287
+ { "id": "#static-1-1", "top": 14, "left": 14 },
288
+ { "id": "#static-1", "top": 30, "left": 30 },
289
+ { "id": "#static-1", "top": 2, "left": 2 },
290
+ { "id": "#static-1", "top": -2, "left": -2 },
291
+ { "id": "#static-1", "top": 7, "left": 7 }
292
+ ];
293
+ jQuery.each( tests, function() {
294
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
295
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
296
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
297
+
298
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
299
+ $( this ).css({
300
+ "top": props.top + 1,
301
+ "left": props.left + 1
302
+ });
303
+ }});
304
+ equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
305
+ equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
306
+ });
307
+ });
308
+
309
+ testIframe("offset/fixed", "fixed", function( $ ) {
310
+ // IE is collapsing the top margin of 1px; detect and adjust accordingly
311
+ var ie = $("#fixed-1").position().top === 2;
312
+
313
+ expect(34);
314
+
315
+ var tests = [
316
+ {
317
+ "id": "#fixed-1",
318
+ "offsetTop": 1001,
319
+ "offsetLeft": 1001,
320
+ "positionTop": ie ? 2 : 0,
321
+ "positionLeft": ie ? 2 : 0
322
+ },
323
+ {
324
+ "id": "#fixed-2",
325
+ "offsetTop": 1021,
326
+ "offsetLeft": 1021,
327
+ "positionTop": ie ? 22 : 20,
328
+ "positionLeft": ie ? 22 : 20
329
+ }
330
+ ];
331
+
332
+ jQuery.each( tests, function() {
333
+ if ( !window.supportsScroll ) {
334
+ ok( true, "Browser doesn't support scroll position." );
335
+ ok( true, "Browser doesn't support scroll position." );
336
+ ok( true, "Browser doesn't support scroll position." );
337
+ ok( true, "Browser doesn't support scroll position." );
338
+
339
+ } else if ( window.supportsFixedPosition ) {
340
+ equal( $( this["id"] ).offset().top, this["offsetTop"], "jQuery('" + this["id"] + "').offset().top" );
341
+ equal( $( this["id"] ).position().top, this["positionTop"], "jQuery('" + this["id"] + "').position().top" );
342
+ equal( $( this["id"] ).offset().left, this["offsetLeft"], "jQuery('" + this["id"] + "').offset().left" );
343
+ equal( $( this["id"] ).position().left, this["positionLeft"], "jQuery('" + this["id"] + "').position().left" );
344
+ } else {
345
+ // need to have same number of assertions
346
+ ok( true, "Fixed position is not supported" );
347
+ ok( true, "Fixed position is not supported" );
348
+ ok( true, "Fixed position is not supported" );
349
+ ok( true, "Fixed position is not supported" );
350
+ }
351
+ });
352
+
353
+ tests = [
354
+ { "id": "#fixed-1", "top": 100, "left": 100 },
355
+ { "id": "#fixed-1", "top": 0, "left": 0 },
356
+ { "id": "#fixed-1", "top": -4, "left": -4 },
357
+ { "id": "#fixed-2", "top": 200, "left": 200 },
358
+ { "id": "#fixed-2", "top": 0, "left": 0 },
359
+ { "id": "#fixed-2", "top": -5, "left": -5 }
360
+ ];
361
+
362
+ jQuery.each( tests, function() {
363
+ if ( window.supportsFixedPosition ) {
364
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"] });
365
+ equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset({ top: " + this["top"] + " })" );
366
+ equal( $( this["id"] ).offset().left, this["left"], "jQuery('" + this["id"] + "').offset({ left: " + this["left"] + " })" );
367
+
368
+ $( this["id"] ).offset({ "top": this["top"], "left": this["left"], "using": function( props ) {
369
+ $( this ).css({
370
+ "top": props.top + 1,
371
+ "left": props.left + 1
372
+ });
373
+ }});
374
+ equal( $( this["id"] ).offset().top, this["top"] + 1, "jQuery('" + this["id"] + "').offset({ top: " + (this["top"] + 1) + ", using: fn })" );
375
+ equal( $( this["id"] ).offset().left, this["left"] + 1, "jQuery('" + this["id"] + "').offset({ left: " + (this["left"] + 1) + ", using: fn })" );
376
+ } else {
377
+ // need to have same number of assertions
378
+ ok( true, "Fixed position is not supported" );
379
+ ok( true, "Fixed position is not supported" );
380
+ ok( true, "Fixed position is not supported" );
381
+ ok( true, "Fixed position is not supported" );
382
+ }
383
+ });
384
+
385
+ // Bug 8316
386
+ var $noTopLeft = $("#fixed-no-top-left");
387
+ if ( window.supportsFixedPosition ) {
388
+ equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
389
+ equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
390
+ } else {
391
+ // need to have same number of assertions
392
+ ok( true, "Fixed position is not supported" );
393
+ ok( true, "Fixed position is not supported" );
394
+ }
395
+ });
396
+
397
+ testIframe("offset/table", "table", function( $ ) {
398
+ expect(4);
399
+
400
+ equal( $("#table-1").offset().top, 6, "jQuery('#table-1').offset().top" );
401
+ equal( $("#table-1").offset().left, 6, "jQuery('#table-1').offset().left" );
402
+
403
+ equal( $("#th-1").offset().top, 10, "jQuery('#th-1').offset().top" );
404
+ equal( $("#th-1").offset().left, 10, "jQuery('#th-1').offset().left" );
405
+ });
406
+
407
+ testIframe("offset/scroll", "scroll", function( $, win ) {
408
+ expect(24);
409
+
410
+ // If we're going to bastardize the tests, let's just DO it
411
+ var ie = /msie [678]/i.test( navigator.userAgent );
412
+
413
+ if ( ie ) {
414
+ ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
415
+ } else {
416
+ equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
417
+ }
418
+ equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
419
+
420
+ if ( ie ) {
421
+ ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
422
+ } else {
423
+ equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
424
+ }
425
+ equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
426
+
427
+ // scroll offset tests .scrollTop/Left
428
+ equal( $("#scroll-1").scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" );
429
+ equal( $("#scroll-1").scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" );
430
+
431
+ equal( $("#scroll-1-1").scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" );
432
+ equal( $("#scroll-1-1").scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" );
433
+
434
+ // scroll method chaining
435
+ equal( $("#scroll-1").scrollTop(undefined).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" );
436
+ equal( $("#scroll-1").scrollLeft(undefined).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" );
437
+
438
+ win.name = "test";
439
+
440
+ if ( !window.supportsScroll ) {
441
+ ok( true, "Browser doesn't support scroll position." );
442
+ ok( true, "Browser doesn't support scroll position." );
443
+
444
+ ok( true, "Browser doesn't support scroll position." );
445
+ ok( true, "Browser doesn't support scroll position." );
446
+ } else {
447
+ equal( $(win).scrollTop(), 1000, "jQuery(window).scrollTop()" );
448
+ equal( $(win).scrollLeft(), 1000, "jQuery(window).scrollLeft()" );
449
+
450
+ equal( $(win.document).scrollTop(), 1000, "jQuery(document).scrollTop()" );
451
+ equal( $(win.document).scrollLeft(), 1000, "jQuery(document).scrollLeft()" );
452
+ }
453
+
454
+ // test jQuery using parent window/document
455
+ // jQuery reference here is in the iframe
456
+ window.scrollTo(0,0);
457
+ equal( $(window).scrollTop(), 0, "jQuery(window).scrollTop() other window" );
458
+ equal( $(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" );
459
+ equal( $(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" );
460
+ equal( $(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" );
461
+
462
+ // Tests scrollTop/Left with empty jquery objects
463
+ notEqual( $().scrollTop(100), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
464
+ notEqual( $().scrollLeft(100), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
465
+ notEqual( $().scrollTop(null), null, "jQuery().scrollTop(null) testing setter on empty jquery object" );
466
+ notEqual( $().scrollLeft(null), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" );
467
+ strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" );
468
+ strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" );
469
+ });
470
+
471
+ testIframe("offset/body", "body", function( $ ) {
472
+ expect(4);
473
+
474
+ equal( $("body").offset().top, 1, "jQuery('#body').offset().top" );
475
+ equal( $("body").offset().left, 1, "jQuery('#body').offset().left" );
476
+ equal( $("#firstElement").position().left, 5, "$('#firstElement').position().left" );
477
+ equal( $("#firstElement").position().top, 5, "$('#firstElement').position().top" );
478
+ });
479
+
480
+ test("chaining", function() {
481
+ expect(3);
482
+ var coords = { "top": 1, "left": 1 };
483
+ equal( jQuery("#absolute-1").offset(coords).selector, "#absolute-1", "offset(coords) returns jQuery object" );
484
+ equal( jQuery("#non-existent").offset(coords).selector, "#non-existent", "offset(coords) with empty jQuery set returns jQuery object" );
485
+ equal( jQuery("#absolute-1").offset(undefined).selector, "#absolute-1", "offset(undefined) returns jQuery object (#5571)" );
486
+ });
487
+
488
+ test("offsetParent", function(){
489
+ expect(13);
490
+
491
+ var body = jQuery("body").offsetParent();
492
+ equal( body.length, 1, "Only one offsetParent found." );
493
+ equal( body[0], document.documentElement, "The html element is the offsetParent of the body." );
494
+
495
+ var header = jQuery("#qunit").offsetParent();
496
+ equal( header.length, 1, "Only one offsetParent found." );
497
+ equal( header[0], document.documentElement, "The html element is the offsetParent of #qunit." );
498
+
499
+ var div = jQuery("#nothiddendivchild").offsetParent();
500
+ equal( div.length, 1, "Only one offsetParent found." );
501
+ equal( div[0], document.getElementById("qunit-fixture"), "The #qunit-fixture is the offsetParent of #nothiddendivchild." );
502
+
503
+ jQuery("#nothiddendiv").css("position", "relative");
504
+
505
+ div = jQuery("#nothiddendivchild").offsetParent();
506
+ equal( div.length, 1, "Only one offsetParent found." );
507
+ equal( div[0], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
508
+
509
+ div = jQuery("body, #nothiddendivchild").offsetParent();
510
+ equal( div.length, 2, "Two offsetParent found." );
511
+ equal( div[0], document.documentElement, "The html element is the offsetParent of the body." );
512
+ equal( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
513
+
514
+ var area = jQuery("#imgmap area").offsetParent();
515
+ equal( area[0], document.documentElement, "The html element is the offsetParent of the body." );
516
+
517
+ div = jQuery("<div>").css({ "position": "absolute" }).appendTo("body");
518
+ equal( div.offsetParent()[0], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" );
519
+
520
+ div.remove();
521
+ });
522
+
523
+ test("fractions (see #7730 and #7885)", function() {
524
+ expect(2);
525
+
526
+ jQuery("body").append("<div id='fractions'/>");
527
+
528
+ var expected = { "top": 1000, "left": 1000 };
529
+ var div = jQuery("#fractions");
530
+
531
+ div.css({
532
+ "position": "absolute",
533
+ "left": "1000.7432222px",
534
+ "top": "1000.532325px",
535
+ "width": 100,
536
+ "height": 100
537
+ });
538
+
539
+ div.offset(expected);
540
+
541
+ var result = div.offset();
542
+
543
+ equal( result.top, expected.top, "Check top" );
544
+ equal( result.left, expected.left, "Check left" );
545
+
546
+ div.remove();
547
+ });
548
+
549
+ })();