item-position-data.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>item position data &middot; Isotope </title>
  6. <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  7. <link rel="stylesheet" href="../css/style.css" />
  8. <!-- scripts at bottom of page -->
  9. </head>
  10. <body class="tests ">
  11. <nav id="site-nav">
  12. <h1><a href="../index.html">Isotope</a></h1>
  13. <h2>Docs</h2>
  14. <ul>
  15. <li><a href="../docs/introduction.html">Introduction</a>
  16. <li><a href="../docs/options.html">Options</a>
  17. <li><a href="../docs/methods.html">Methods</a>
  18. <li><a href="../docs/layout-modes.html">Layout modes</a>
  19. <li><a href="../docs/filtering.html">Filtering</a>
  20. <li><a href="../docs/sorting.html">Sorting</a>
  21. <li><a href="../docs/animating.html">Animating</a>
  22. <li><a href="../docs/adding-items.html">Adding items</a>
  23. <li><a href="../docs/extending-isotope.html">Extending Isotope</a>
  24. <li><a href="../docs/hash-history-jquery-bbq.html">Hash history with jQuery BBQ</a>
  25. <li><a href="../docs/help.html">Help</a>
  26. <li><a href="../docs/license.html">License</a>
  27. </ul>
  28. <h2>Demos</h2>
  29. <ul>
  30. <li><a href="../demos/basic.html">Basic</a>
  31. <li><a href="../demos/elements-complete.html">Elements Complete</a>
  32. <li><a href="../demos/elements-partial.html">Elements Partial</a>
  33. <li><a href="../demos/layout-modes.html">Layout modes</a>
  34. <li><a href="../demos/filtering.html">Filtering</a>
  35. <li><a href="../demos/sorting.html">Sorting</a>
  36. <li><a href="../demos/relayout.html">reLayout</a>
  37. <li><a href="../demos/adding-items.html">Adding items</a>
  38. <li><a href="../demos/infinite-scroll.html">Infinite Scroll</a>
  39. <li><a href="../demos/images.html">Images</a>
  40. <li><a href="../demos/combination-filters.html">Combination filters</a>
  41. <li><a href="../demos/hash-history.html">Hash history</a>
  42. <li><a href="../demos/fluid-responsive.html">Fluid / responsive</a>
  43. </ul>
  44. <h2>Custom layout modes</h2>
  45. <ul>
  46. <li><a href="../custom-layout-modes/centered-masonry.html">Centered Masonry</a>
  47. <li><a href="../custom-layout-modes/category-rows.html">Category rows</a>
  48. <li><a href="../custom-layout-modes/masonry-corner-stamp.html">Masonry corner stamp</a>
  49. <li><a href="../custom-layout-modes/masonry-gutters.html">Masonry gutters</a>
  50. <li><a href="../custom-layout-modes/spine-align.html">Spine align</a>
  51. </ul>
  52. <h2><a href="../tests/index.html">Tests</a></h2>
  53. </nav> <!-- #site-nav -->
  54. <section id="content">
  55. <h1>item position data</h1>
  56. <section id="copy">
  57. <p><code>itemPositionDataEnabled</code> option is enabled. </p>
  58. </section>
  59. <section id="options" class="clearfix">
  60. <h3>Sort</h3>
  61. <ul id="sort-by" class="option-set clearfix" data-option-key="sortBy">
  62. <li><a href="#sortBy=original-order" data-option-value="original-order" class="selected" data>original-order</a></li>
  63. <li><a href="#sortBy=name" data-option-value="name">name</a></li>
  64. <li><a href="#sortBy=symbol" data-option-value="symbol">symbol</a></li>
  65. <li><a href="#sortBy=number" data-option-value="number">number</a></li>
  66. <li><a href="#sortBy=weight" data-option-value="weight">weight</a></li>
  67. <li><a href="#sortBy=category" data-option-value="category">category</a></li>
  68. <li><a href="#sortBy=random" data-option-value="random">random</a></li>
  69. </ul>
  70. <h3>Sort direction</h3>
  71. <ul id="sort-direction" class="option-set clearfix" data-option-key="sortAscending">
  72. <li><a href="#sortAscending=true" data-option-value="true" class="selected">sort ascending</a></li>
  73. <li><a href="#sortAscending=false" data-option-value="false">sort descending</a></li>
  74. </ul>
  75. <h3>Etc</h3>
  76. <ul id="etc" class="clearfix">
  77. <li id="toggle-sizes"><a href="#toggle-sizes">Toggle variable sizes</a></li>
  78. </ul>
  79. </section> <!-- #options -->
  80. <div id="container" class="clickable clearfix">
  81. <div class="element other nonmetal " data-symbol="H" data-category="other">
  82. <p class="number">1</p>
  83. <h3 class="symbol">H</h3>
  84. <h2 class="name">Hydrogen</h2>
  85. <p class="weight">1.00794</p>
  86. </div>
  87. <div class="element noble-gas nonmetal " data-symbol="He" data-category="noble-gas">
  88. <p class="number">2</p>
  89. <h3 class="symbol">He</h3>
  90. <h2 class="name">Helium</h2>
  91. <p class="weight">4.002602</p>
  92. </div>
  93. <div class="element alkali metal " data-symbol="Li" data-category="alkali">
  94. <p class="number">3</p>
  95. <h3 class="symbol">Li</h3>
  96. <h2 class="name">Lithium</h2>
  97. <p class="weight">6.941</p>
  98. </div>
  99. <div class="element alkaline-earth metal " data-symbol="Be" data-category="alkaline-earth">
  100. <p class="number">4</p>
  101. <h3 class="symbol">Be</h3>
  102. <h2 class="name">Beryllium</h2>
  103. <p class="weight">9.012182</p>
  104. </div>
  105. <div class="element metalloid " data-symbol="B" data-category="metalloid">
  106. <p class="number">5</p>
  107. <h3 class="symbol">B</h3>
  108. <h2 class="name">Boron</h2>
  109. <p class="weight">10.811</p>
  110. </div>
  111. <div class="element other nonmetal " data-symbol="C" data-category="other">
  112. <p class="number">6</p>
  113. <h3 class="symbol">C</h3>
  114. <h2 class="name">Carbon</h2>
  115. <p class="weight">12.0107</p>
  116. </div>
  117. <div class="element other nonmetal " data-symbol="N" data-category="other">
  118. <p class="number">7</p>
  119. <h3 class="symbol">N</h3>
  120. <h2 class="name">Nitrogen</h2>
  121. <p class="weight">14.0067</p>
  122. </div>
  123. <div class="element other nonmetal " data-symbol="O" data-category="other">
  124. <p class="number">8</p>
  125. <h3 class="symbol">O</h3>
  126. <h2 class="name">Oxygen</h2>
  127. <p class="weight">15.9994</p>
  128. </div>
  129. <div class="element halogen nonmetal " data-symbol="F" data-category="halogen">
  130. <p class="number">9</p>
  131. <h3 class="symbol">F</h3>
  132. <h2 class="name">Fluorine</h2>
  133. <p class="weight">18.9984032</p>
  134. </div>
  135. <div class="element noble-gas nonmetal " data-symbol="Ne" data-category="noble-gas">
  136. <p class="number">10</p>
  137. <h3 class="symbol">Ne</h3>
  138. <h2 class="name">Neon</h2>
  139. <p class="weight">20.1797</p>
  140. </div>
  141. <div class="element alkali metal " data-symbol="Na" data-category="alkali">
  142. <p class="number">11</p>
  143. <h3 class="symbol">Na</h3>
  144. <h2 class="name">Sodium</h2>
  145. <p class="weight">22.98976928</p>
  146. </div>
  147. <div class="element alkaline-earth metal " data-symbol="Mg" data-category="alkaline-earth">
  148. <p class="number">12</p>
  149. <h3 class="symbol">Mg</h3>
  150. <h2 class="name">Magnesium</h2>
  151. <p class="weight">24.305</p>
  152. </div>
  153. <div class="element post-transition metal " data-symbol="Al" data-category="post-transition">
  154. <p class="number">13</p>
  155. <h3 class="symbol">Al</h3>
  156. <h2 class="name">Aluminium</h2>
  157. <p class="weight">26.9815386</p>
  158. </div>
  159. <div class="element metalloid " data-symbol="Si" data-category="metalloid">
  160. <p class="number">14</p>
  161. <h3 class="symbol">Si</h3>
  162. <h2 class="name">Silicon</h2>
  163. <p class="weight">28.0855</p>
  164. </div>
  165. <div class="element other nonmetal " data-symbol="P" data-category="other">
  166. <p class="number">15</p>
  167. <h3 class="symbol">P</h3>
  168. <h2 class="name">Phosphorus</h2>
  169. <p class="weight">30.973762</p>
  170. </div>
  171. <div class="element other nonmetal " data-symbol="S" data-category="other">
  172. <p class="number">16</p>
  173. <h3 class="symbol">S</h3>
  174. <h2 class="name">Sulfur</h2>
  175. <p class="weight">32.065</p>
  176. </div>
  177. <div class="element halogen nonmetal " data-symbol="Cl" data-category="halogen">
  178. <p class="number">17</p>
  179. <h3 class="symbol">Cl</h3>
  180. <h2 class="name">Chlorine</h2>
  181. <p class="weight">35.453</p>
  182. </div>
  183. <div class="element noble-gas nonmetal " data-symbol="Ar" data-category="noble-gas">
  184. <p class="number">18</p>
  185. <h3 class="symbol">Ar</h3>
  186. <h2 class="name">Argon</h2>
  187. <p class="weight">39.948</p>
  188. </div>
  189. <div class="element alkali metal " data-symbol="K" data-category="alkali">
  190. <p class="number">19</p>
  191. <h3 class="symbol">K</h3>
  192. <h2 class="name">Potassium</h2>
  193. <p class="weight">39.0983</p>
  194. </div>
  195. <div class="element alkaline-earth metal " data-symbol="Ca" data-category="alkaline-earth">
  196. <p class="number">20</p>
  197. <h3 class="symbol">Ca</h3>
  198. <h2 class="name">Calcium</h2>
  199. <p class="weight">40.078</p>
  200. </div>
  201. <div class="element transition metal " data-symbol="Sc" data-category="transition">
  202. <p class="number">21</p>
  203. <h3 class="symbol">Sc</h3>
  204. <h2 class="name">Scandium</h2>
  205. <p class="weight">44.955912</p>
  206. </div>
  207. <div class="element transition metal " data-symbol="Ti" data-category="transition">
  208. <p class="number">22</p>
  209. <h3 class="symbol">Ti</h3>
  210. <h2 class="name">Titanium</h2>
  211. <p class="weight">47.867</p>
  212. </div>
  213. <div class="element transition metal " data-symbol="V" data-category="transition">
  214. <p class="number">23</p>
  215. <h3 class="symbol">V</h3>
  216. <h2 class="name">Vanadium</h2>
  217. <p class="weight">50.9415</p>
  218. </div>
  219. <div class="element transition metal " data-symbol="Cr" data-category="transition">
  220. <p class="number">24</p>
  221. <h3 class="symbol">Cr</h3>
  222. <h2 class="name">Chromium</h2>
  223. <p class="weight">51.9961</p>
  224. </div>
  225. <div class="element transition metal " data-symbol="Mn" data-category="transition">
  226. <p class="number">25</p>
  227. <h3 class="symbol">Mn</h3>
  228. <h2 class="name">Manganese</h2>
  229. <p class="weight">54.938045</p>
  230. </div>
  231. <div class="element transition metal " data-symbol="Fe" data-category="transition">
  232. <p class="number">26</p>
  233. <h3 class="symbol">Fe</h3>
  234. <h2 class="name">Iron</h2>
  235. <p class="weight">55.845</p>
  236. </div>
  237. <div class="element transition metal " data-symbol="Co" data-category="transition">
  238. <p class="number">27</p>
  239. <h3 class="symbol">Co</h3>
  240. <h2 class="name">Cobalt</h2>
  241. <p class="weight">58.933195</p>
  242. </div>
  243. <div class="element transition metal " data-symbol="Ni" data-category="transition">
  244. <p class="number">28</p>
  245. <h3 class="symbol">Ni</h3>
  246. <h2 class="name">Nickel</h2>
  247. <p class="weight">58.6934</p>
  248. </div>
  249. <div class="element transition metal " data-symbol="Cu" data-category="transition">
  250. <p class="number">29</p>
  251. <h3 class="symbol">Cu</h3>
  252. <h2 class="name">Copper</h2>
  253. <p class="weight">63.546</p>
  254. </div>
  255. <div class="element transition metal " data-symbol="Zn" data-category="transition">
  256. <p class="number">30</p>
  257. <h3 class="symbol">Zn</h3>
  258. <h2 class="name">Zinc</h2>
  259. <p class="weight">65.38</p>
  260. </div>
  261. <div class="element post-transition metal " data-symbol="Ga" data-category="post-transition">
  262. <p class="number">31</p>
  263. <h3 class="symbol">Ga</h3>
  264. <h2 class="name">Gallium</h2>
  265. <p class="weight">69.723</p>
  266. </div>
  267. <div class="element metalloid " data-symbol="Ge" data-category="metalloid">
  268. <p class="number">32</p>
  269. <h3 class="symbol">Ge</h3>
  270. <h2 class="name">Germanium</h2>
  271. <p class="weight">72.64</p>
  272. </div>
  273. <div class="element metalloid " data-symbol="As" data-category="metalloid">
  274. <p class="number">33</p>
  275. <h3 class="symbol">As</h3>
  276. <h2 class="name">Arsenic</h2>
  277. <p class="weight">74.9216</p>
  278. </div>
  279. <div class="element other nonmetal " data-symbol="Se" data-category="other">
  280. <p class="number">34</p>
  281. <h3 class="symbol">Se</h3>
  282. <h2 class="name">Selenium</h2>
  283. <p class="weight">78.96</p>
  284. </div>
  285. <div class="element halogen nonmetal " data-symbol="Br" data-category="halogen">
  286. <p class="number">35</p>
  287. <h3 class="symbol">Br</h3>
  288. <h2 class="name">Bromine</h2>
  289. <p class="weight">79.904</p>
  290. </div>
  291. <div class="element noble-gas nonmetal " data-symbol="Kr" data-category="noble-gas">
  292. <p class="number">36</p>
  293. <h3 class="symbol">Kr</h3>
  294. <h2 class="name">Krypton</h2>
  295. <p class="weight">83.798</p>
  296. </div>
  297. <div class="element alkali metal " data-symbol="Rb" data-category="alkali">
  298. <p class="number">37</p>
  299. <h3 class="symbol">Rb</h3>
  300. <h2 class="name">Rubidium</h2>
  301. <p class="weight">85.4678</p>
  302. </div>
  303. <div class="element alkaline-earth metal " data-symbol="Sr" data-category="alkaline-earth">
  304. <p class="number">38</p>
  305. <h3 class="symbol">Sr</h3>
  306. <h2 class="name">Strontium</h2>
  307. <p class="weight">87.62</p>
  308. </div>
  309. <div class="element transition metal " data-symbol="Y" data-category="transition">
  310. <p class="number">39</p>
  311. <h3 class="symbol">Y</h3>
  312. <h2 class="name">Yttrium</h2>
  313. <p class="weight">88.90585</p>
  314. </div>
  315. <div class="element transition metal " data-symbol="Zr" data-category="transition">
  316. <p class="number">40</p>
  317. <h3 class="symbol">Zr</h3>
  318. <h2 class="name">Zirconium</h2>
  319. <p class="weight">91.224</p>
  320. </div>
  321. </div> <!-- #container -->
  322. <script src="../js/jquery-1.6.4.min.js"></script>
  323. <script src="../jquery.isotope.min.js"></script>
  324. <script>
  325. $(function(){
  326. var $container = $('#container');
  327. // add randomish size classes
  328. $container.find('.element').each(function(){
  329. var $this = $(this),
  330. number = parseInt( $this.find('.number').text(), 10 );
  331. if ( number % 7 % 2 === 1 ) {
  332. $this.addClass('width2');
  333. }
  334. if ( number % 3 === 0 ) {
  335. $this.addClass('height2');
  336. }
  337. });
  338. $container.isotope({
  339. itemSelector: '.element',
  340. itemPositionDataEnabled: true,
  341. masonry: {
  342. columnWidth : 120
  343. },
  344. getSortData : {
  345. symbol : function( $elem ) {
  346. return $elem.attr('data-symbol');
  347. },
  348. category : function( $elem ) {
  349. return $elem.attr('data-category');
  350. },
  351. number : function( $elem ) {
  352. return parseInt( $elem.find('.number').text(), 10 );
  353. },
  354. weight : function( $elem ) {
  355. return parseFloat( $elem.find('.weight').text().replace( /[\(\)]/g, '') );
  356. },
  357. name : function ( $elem ) {
  358. return $elem.find('.name').text();
  359. }
  360. }
  361. });
  362. var $optionSets = $('#options .option-set'),
  363. $optionLinks = $optionSets.find('a');
  364. $optionLinks.click(function(){
  365. var $this = $(this);
  366. // don't proceed if already selected
  367. if ( $this.hasClass('selected') ) {
  368. return false;
  369. }
  370. var $optionSet = $this.parents('.option-set');
  371. $optionSet.find('.selected').removeClass('selected');
  372. $this.addClass('selected');
  373. // make option object dynamically, i.e. { filter: '.my-filter-class' }
  374. var options = {},
  375. key = $optionSet.attr('data-option-key'),
  376. value = $this.attr('data-option-value');
  377. // parse 'false' as false boolean
  378. value = value === 'false' ? false : value;
  379. options[ key ] = value;
  380. if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
  381. // changes in layout modes need extra logic
  382. changeLayoutMode( $this, options )
  383. } else {
  384. // otherwise, apply new options
  385. $container.isotope( options );
  386. }
  387. return false;
  388. });
  389. // change size of clicked element
  390. $container.delegate( '.element', 'click', function(){
  391. $(this).toggleClass('large');
  392. $container.isotope('reLayout');
  393. });
  394. // toggle variable sizes of all elements
  395. $('#toggle-sizes').find('a').click(function(){
  396. $container
  397. .toggleClass('variable-sizes')
  398. .isotope('reLayout');
  399. return false;
  400. });
  401. });
  402. </script>
  403. <footer>
  404. Isotope by <a href="http://desandro.com">David DeSandro</a> / <a href="http://metafizzy.co">Metafizzy</a>
  405. </footer>
  406. </section> <!-- #content -->
  407. </body>
  408. </html>