iugu-ux 0.8.0 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. data/README.md +2 -0
  2. data/lib/iugu-ux/version.rb +1 -1
  3. data/sandbox/app/assets/javascripts/web-app/presenters/main-view.jst.eco +31 -12
  4. data/sandbox/app/assets/javascripts/web-app/usecode/root-view.coffee +0 -2
  5. data/sandbox/app/controllers/ui_library_controller.rb +0 -3
  6. data/sandbox/app/views/layouts/ui.html.haml +0 -1
  7. data/sandbox/app/views/ui_library/boiler.html.haml +2 -4
  8. data/sandbox/config/routes.rb +0 -1
  9. data/sandbox/log/development.log +20329 -0
  10. data/sandbox/tmp/cache/assets/BE9/020/sprockets%2Fe93a611416f4149c006c589432090903 +0 -0
  11. data/sandbox/tmp/cache/assets/C24/5F0/sprockets%2Fcb3028925f1090968337df085236f532 +0 -0
  12. data/sandbox/tmp/cache/assets/C3E/260/sprockets%2F4262142496540e6691d5bc0260a21eb5 +0 -0
  13. data/sandbox/tmp/cache/assets/C45/3F0/sprockets%2F0a178290fa722133d544643d13708fc6 +0 -0
  14. data/sandbox/tmp/cache/assets/C48/D00/sprockets%2F4a51b39094a347e3e325005c7847551c +0 -0
  15. data/sandbox/tmp/cache/assets/C49/3B0/sprockets%2F405c7112191eed23e8b860254281e763 +0 -0
  16. data/sandbox/tmp/cache/assets/C4F/3A0/sprockets%2F41918e8d7b402652a5649e4b7134d620 +0 -0
  17. data/sandbox/tmp/cache/assets/C53/BD0/sprockets%2F00196765c6f95bc1b670b0941172f829 +0 -0
  18. data/sandbox/tmp/cache/assets/C55/1B0/sprockets%2F413864885359794c0b415c5c012fd8b4 +0 -0
  19. data/sandbox/tmp/cache/assets/C5E/340/sprockets%2Fcaec1317015c08109f31f190314243b2 +0 -0
  20. data/sandbox/tmp/cache/assets/C60/360/sprockets%2Fb7a62e5a9315f80120493f865587d982 +0 -0
  21. data/sandbox/tmp/cache/assets/C62/3A0/sprockets%2Fad550974fd1050311169d4c5004a2e20 +0 -0
  22. data/sandbox/tmp/cache/assets/C6B/870/sprockets%2Fa90a46599772a03198988b6d444a678f +0 -0
  23. data/sandbox/tmp/cache/assets/C75/E10/sprockets%2Fb04a483530140d3348c160f58dc56d49 +0 -0
  24. data/sandbox/tmp/cache/assets/C7A/440/sprockets%2F3828a635611b4f542d38731a1e308f4e +0 -0
  25. data/sandbox/tmp/cache/assets/C7A/7B0/sprockets%2Fb5fc25d37349717a231120228a0e8d99 +0 -0
  26. data/sandbox/tmp/cache/assets/C7A/F30/sprockets%2F70249181577b261a3ea8851b530f1e7c +0 -0
  27. data/sandbox/tmp/cache/assets/C7F/4D0/sprockets%2F8e4b454014428723ac77c713ebf49613 +0 -0
  28. data/sandbox/tmp/cache/assets/C91/150/sprockets%2F084d158b90125d3acd60b07300f3324a +0 -0
  29. data/sandbox/tmp/cache/assets/CA2/760/sprockets%2Fb298c140b2372622351f1ef6b0815f3e +0 -0
  30. data/sandbox/tmp/cache/assets/CA3/610/sprockets%2F06183b0fa253d1afbf76a29801554914 +0 -0
  31. data/sandbox/tmp/cache/assets/CAB/2A0/sprockets%2F35a28a06551a3891e0582ee18e880d0d +0 -0
  32. data/sandbox/tmp/cache/assets/CAC/060/sprockets%2Fe72c3ba435988731c168b6441f1bc622 +0 -0
  33. data/sandbox/tmp/cache/assets/CB4/F00/sprockets%2Fb95d8a0b377ead5c5c59405670734228 +0 -0
  34. data/sandbox/tmp/cache/assets/CB9/9D0/sprockets%2F893272529e62fea11982e442c0df4c49 +0 -0
  35. data/sandbox/tmp/cache/assets/CBA/6A0/sprockets%2F964d3e9f13da420a6098981857d20c8b +0 -0
  36. data/sandbox/tmp/cache/assets/CBB/3F0/sprockets%2Feed6910664fe0a469ee6355e91212395 +0 -0
  37. data/sandbox/tmp/cache/assets/CBB/AA0/sprockets%2F34b613f862555697eb944a2ff6ac3526 +0 -0
  38. data/sandbox/tmp/cache/assets/CBB/E20/sprockets%2F00b2c2691b3a8da5553b13d123137c0c +0 -0
  39. data/sandbox/tmp/cache/assets/CBD/650/sprockets%2F1774801e748257cd49a236d458ce44fd +0 -0
  40. data/sandbox/tmp/cache/assets/CBF/870/sprockets%2F9de5a39e373d70d1455989c3a1c16676 +0 -0
  41. data/sandbox/tmp/cache/assets/CC7/EB0/sprockets%2F079d3b368c9e843b78c90079f26d628b +0 -0
  42. data/sandbox/tmp/cache/assets/CC8/510/sprockets%2F868a1670f8822e6b7847dd22e747a66f +0 -0
  43. data/sandbox/tmp/cache/assets/CCA/850/sprockets%2F1d05d32f046ec7313b0d3619a232d73f +0 -0
  44. data/sandbox/tmp/cache/assets/CCB/400/sprockets%2F1530d5680131ba31d7175dcb56e235ce +0 -0
  45. data/sandbox/tmp/cache/assets/CD0/590/sprockets%2F34362b49bb86e23a636817b55bab30c0 +0 -0
  46. data/sandbox/tmp/cache/assets/CD1/920/sprockets%2F570c0b1741c64e149720c9a70ef31a5e +0 -0
  47. data/sandbox/tmp/cache/assets/CD3/7E0/sprockets%2Fe1da4188365b15d4e56321fe11aa3476 +0 -0
  48. data/sandbox/tmp/cache/assets/CD7/0E0/sprockets%2Fb7291915fd78d50026c443b2c63fa6b0 +0 -0
  49. data/sandbox/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  50. data/sandbox/tmp/cache/assets/CDB/E30/sprockets%2F918458a88fec2cd01991c003b2318ab7 +0 -0
  51. data/sandbox/tmp/cache/assets/CDE/5C0/sprockets%2F794c70924436be60f2ec52426aa8cd61 +0 -0
  52. data/sandbox/tmp/cache/assets/CDF/2A0/sprockets%2Faceafc712241955028dc5b137364e869 +0 -0
  53. data/sandbox/tmp/cache/assets/CDF/EC0/sprockets%2Fa90760fc2f137785c7b810dcb9a40196 +0 -0
  54. data/sandbox/tmp/cache/assets/CE3/1C0/sprockets%2Ff617335dbdd40d03704f3d1249939f9c +0 -0
  55. data/sandbox/tmp/cache/assets/CE6/910/sprockets%2F4f1ef52dd511139b0d3f12f3879f6648 +0 -0
  56. data/sandbox/tmp/cache/assets/CE8/0F0/sprockets%2F12795deec07b2046d9467dd3f2e25809 +0 -0
  57. data/sandbox/tmp/cache/assets/CEA/5C0/sprockets%2Ff07ef674251629759e234ea642a3cc8e +0 -0
  58. data/sandbox/tmp/cache/assets/CED/340/sprockets%2F2f33f5d63e037a9f9b859f6c25139e30 +0 -0
  59. data/sandbox/tmp/cache/assets/CF1/CD0/sprockets%2Ff604c432d2de9f942882ecd8462578f0 +0 -0
  60. data/sandbox/tmp/cache/assets/CF5/E20/sprockets%2Ff31c0130a87c513e0e5ecea55135117c +0 -0
  61. data/sandbox/tmp/cache/assets/CFA/EE0/sprockets%2Fd95b64bc8b83485c8f3960c625885dc6 +0 -0
  62. data/sandbox/tmp/cache/assets/CFD/6C0/sprockets%2F1203d4bbdfe1aac02f896e2447006951 +0 -0
  63. data/sandbox/tmp/cache/assets/D05/8E0/sprockets%2F58046c1329c03b4cc2e5fa962f431ca8 +0 -0
  64. data/sandbox/tmp/cache/assets/D05/F60/sprockets%2Fb2725d240fe20257dc6a9e0b6a22399d +0 -0
  65. data/sandbox/tmp/cache/assets/D08/ED0/sprockets%2Fcb1aee736d3b287a872298b7741b012b +0 -0
  66. data/sandbox/tmp/cache/assets/D09/DB0/sprockets%2F21a7ee2fd49111e1378c6f7118fd230e +0 -0
  67. data/sandbox/tmp/cache/assets/D10/6D0/sprockets%2F966130263a0cbcd9c69c2f06789ad3d3 +0 -0
  68. data/sandbox/tmp/cache/assets/D10/8C0/sprockets%2F5d1e20d279d209b6fc1606d7de41f728 +0 -0
  69. data/sandbox/tmp/cache/assets/D10/E50/sprockets%2F86dbab9960f9195090301e2c42e1eeb8 +0 -0
  70. data/sandbox/tmp/cache/assets/D18/2F0/sprockets%2Fcc2e1640b5601b34eb61a4c333a2e31b +0 -0
  71. data/sandbox/tmp/cache/assets/D1A/B70/sprockets%2F47ae92dd9d034b32098b19bf8f2475a9 +0 -0
  72. data/sandbox/tmp/cache/assets/D1B/8C0/sprockets%2Fa2e16c5e5e97e98b526e7a6516f4622a +0 -0
  73. data/sandbox/tmp/cache/assets/D1E/7C0/sprockets%2Fb590b97f48766ae095ccf7b821361c6d +0 -0
  74. data/sandbox/tmp/cache/assets/D26/0C0/sprockets%2F44ba33f7338d8b57eb37f98e8c861e08 +0 -0
  75. data/sandbox/tmp/cache/assets/D2B/9B0/sprockets%2F4de45f7ee4e3076777bd571c66f8666b +0 -0
  76. data/sandbox/tmp/cache/assets/D2D/8C0/sprockets%2F6403fb17fb855b2dd047b010fbf8204d +0 -0
  77. data/sandbox/tmp/cache/assets/D2D/AF0/sprockets%2Fff24230f8cf22d156618240bb72ddb2a +0 -0
  78. data/sandbox/tmp/cache/assets/D2E/9D0/sprockets%2F9c0a2445ab6c0967470b5b22d4b1f8ba +0 -0
  79. data/sandbox/tmp/cache/assets/D2F/500/sprockets%2F4b69a31fdeabf6b46a1656d06b036043 +0 -0
  80. data/sandbox/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  81. data/sandbox/tmp/cache/assets/D34/280/sprockets%2F0fcf69c7e8fd9961e1158d70583e8f95 +0 -0
  82. data/sandbox/tmp/cache/assets/D34/3E0/sprockets%2F46a73c17c9a561115944df004dbbdd7b +0 -0
  83. data/sandbox/tmp/cache/assets/D35/AC0/sprockets%2F67d23b05f2a7bc455d0f5f408ca6d523 +0 -0
  84. data/sandbox/tmp/cache/assets/D36/930/sprockets%2Fc2a0ff7004c8ff6a483b33c8d17c2417 +0 -0
  85. data/sandbox/tmp/cache/assets/D37/1E0/sprockets%2Fc42800bd200fbf8edbdf9410949590a4 +0 -0
  86. data/sandbox/tmp/cache/assets/D37/B30/sprockets%2F9e0ec117e9064c55401b50c2abb8ff76 +0 -0
  87. data/sandbox/tmp/cache/assets/D39/880/sprockets%2F30ace94e10312e02fdf5d4a398393f8b +0 -0
  88. data/sandbox/tmp/cache/assets/D39/E50/sprockets%2F2e903f41216c9a5bfde3b77d1b9c1390 +0 -0
  89. data/sandbox/tmp/cache/assets/D3B/BC0/sprockets%2F19510a763bd1521ff5fc70ffe0d837d3 +0 -0
  90. data/sandbox/tmp/cache/assets/D3D/B80/sprockets%2F75df7c9d480cfbe1f976999e7647d771 +0 -0
  91. data/sandbox/tmp/cache/assets/D40/6C0/sprockets%2F5331b2ee1f23f57b9b2a96fd0a85b577 +0 -0
  92. data/sandbox/tmp/cache/assets/D40/8A0/sprockets%2F4483a17992b57cddb5dee15e327d30e3 +0 -0
  93. data/sandbox/tmp/cache/assets/D44/320/sprockets%2F27989e358a4a57b48c5e4062bff2aa4a +0 -0
  94. data/sandbox/tmp/cache/assets/D46/650/sprockets%2Fba1459a80d8874a816f88ffec22019ac +0 -0
  95. data/sandbox/tmp/cache/assets/D47/BA0/sprockets%2F6d287a845e176586f4aaa3f6b5f6ab51 +0 -0
  96. data/sandbox/tmp/cache/assets/D47/FD0/sprockets%2F279dd54295ff5a0e283a0e5730fff28c +0 -0
  97. data/sandbox/tmp/cache/assets/D48/370/sprockets%2Fb654fd37f9f63ec202a3636e29b94ef0 +0 -0
  98. data/sandbox/tmp/cache/assets/D4A/1A0/sprockets%2Fb746360a8b3ce79c57e74a9c15309fdd +0 -0
  99. data/sandbox/tmp/cache/assets/D4D/5C0/sprockets%2F66eaa47a7875ec8a24a5dbe465e75753 +0 -0
  100. data/sandbox/tmp/cache/assets/D4D/9B0/sprockets%2Febcc4e9d10b747864a29d16c13f5d899 +0 -0
  101. data/sandbox/tmp/cache/assets/D4F/810/sprockets%2Fa10070d6497ba2b4ea552d4a1bb444cb +0 -0
  102. data/sandbox/tmp/cache/assets/D55/310/sprockets%2F2b9be79ca64ec7d294d4825e21696ce9 +0 -0
  103. data/sandbox/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  104. data/sandbox/tmp/cache/assets/D5C/200/sprockets%2Fcd323e6f7545cee0b3ba1e84d7520b00 +0 -0
  105. data/sandbox/tmp/cache/assets/D5D/310/sprockets%2F5bbf50c40bff0ad1722051c86fe680e2 +0 -0
  106. data/sandbox/tmp/cache/assets/D5E/290/sprockets%2F22fb620af04e31f058ba64ec4386bb8a +0 -0
  107. data/sandbox/tmp/cache/assets/D62/490/sprockets%2Fd7c71cd09b0f551a237150dae69ca93a +0 -0
  108. data/sandbox/tmp/cache/assets/D62/690/sprockets%2F11532c31a6be258097db31bbeb9ff35d +0 -0
  109. data/sandbox/tmp/cache/assets/D66/BB0/sprockets%2F190ee4571dbbf206b6b26007fd9be9a2 +0 -0
  110. data/sandbox/tmp/cache/assets/D6A/ED0/sprockets%2Ff5d445fff783322a14283beb4eb5bc33 +0 -0
  111. data/sandbox/tmp/cache/assets/D6B/0F0/sprockets%2F3609df3f470bd24af26a51de476cef05 +0 -0
  112. data/sandbox/tmp/cache/assets/D6C/110/sprockets%2F2d5d9cd3d0adf965d07e64a3049d106e +0 -0
  113. data/sandbox/tmp/cache/assets/D6D/AA0/sprockets%2F1cb4a75912d38d0bdde6ee6770644d0f +0 -0
  114. data/sandbox/tmp/cache/assets/D6E/AE0/sprockets%2Fe193ea7b03f186ad2a9515fc78fa8c21 +0 -0
  115. data/sandbox/tmp/cache/assets/D6F/690/sprockets%2F1aa0aa2e0ecc490b1b0ede43013535c1 +0 -0
  116. data/sandbox/tmp/cache/assets/D70/320/sprockets%2Fb81a3eab4ea93cf21fd7585436b8a169 +0 -0
  117. data/sandbox/tmp/cache/assets/D70/5D0/sprockets%2F2ff973bae9120e8358ccbaa6395c2b19 +0 -0
  118. data/sandbox/tmp/cache/assets/D72/250/sprockets%2F68bd0a6d091ef3ba0a64b9762794d6de +0 -0
  119. data/sandbox/tmp/cache/assets/D72/680/sprockets%2F56c41c78c49d45b9ca0c358adea917f0 +0 -0
  120. data/sandbox/tmp/cache/assets/D74/0A0/sprockets%2Fc1392b79af6b88250b634479cbf2bcfc +0 -0
  121. data/sandbox/tmp/cache/assets/D79/5A0/sprockets%2Feb399a6f39a8dcd0bf011768e7153d8d +0 -0
  122. data/sandbox/tmp/cache/assets/D7A/D40/sprockets%2F4d2bc08f2787a3870ff93e0e0f7bc67e +0 -0
  123. data/sandbox/tmp/cache/assets/D7C/270/sprockets%2Fc15bcc081286a12c1751bfad1ac2f2a4 +0 -0
  124. data/sandbox/tmp/cache/assets/D7D/2C0/sprockets%2Fdc76b19d5f8ce4e6e4e9c735c223091f +0 -0
  125. data/sandbox/tmp/cache/assets/D88/B70/sprockets%2F9b378be843af782b809c5ce3d6f6d47f +0 -0
  126. data/sandbox/tmp/cache/assets/D89/670/sprockets%2Fbf838afe9adf908d9ec59bc552833285 +0 -0
  127. data/sandbox/tmp/cache/assets/D8C/D40/sprockets%2Fc4a00154a0e1c15a495ce4d49c9f0ccf +0 -0
  128. data/sandbox/tmp/cache/assets/D96/460/sprockets%2F510545dac5cc61f17bc4d1e8e740fec5 +0 -0
  129. data/sandbox/tmp/cache/assets/D96/940/sprockets%2F6a2c3af22b173eb975f382b4cdcd8c41 +0 -0
  130. data/sandbox/tmp/cache/assets/D96/E90/sprockets%2F0d5f451deca7e6811663f30afc3a4fd4 +0 -0
  131. data/sandbox/tmp/cache/assets/D97/180/sprockets%2F933323d1c368cfeda7a0cacdbd295933 +0 -0
  132. data/sandbox/tmp/cache/assets/D9E/000/sprockets%2F1e365d6ecdad349c6f900a3aa829cf18 +0 -0
  133. data/sandbox/tmp/cache/assets/D9F/020/sprockets%2Fd21cfdfa8182a8866e0ba904ef6561ea +0 -0
  134. data/sandbox/tmp/cache/assets/DA5/EA0/sprockets%2Fc2e6b41187b059dbddd8dbd7cb884482 +0 -0
  135. data/sandbox/tmp/cache/assets/DA7/DE0/sprockets%2Ff022dcf0c3c5fd7de3989f600dc7585c +0 -0
  136. data/sandbox/tmp/cache/assets/DA9/420/sprockets%2F4be564f02ffc16e32df33e92e43fb8f9 +0 -0
  137. data/sandbox/tmp/cache/assets/DAD/190/sprockets%2Fbee62a5d7a8cd35a33763f1cd879de59 +0 -0
  138. data/sandbox/tmp/cache/assets/DB5/EC0/sprockets%2Fde17edd0f2eca28280c1a27ac5c510c3 +0 -0
  139. data/sandbox/tmp/cache/assets/DBE/5E0/sprockets%2F7663abb4baaadfc7e6a48f1150f32b62 +0 -0
  140. data/sandbox/tmp/cache/assets/DBE/A00/sprockets%2F266ad056a1ae59c1b2934fcd2cad6cf0 +0 -0
  141. data/sandbox/tmp/cache/assets/DCA/FD0/sprockets%2F0b59a77adfc61bb863e708ba262ce6bd +0 -0
  142. data/sandbox/tmp/cache/assets/DCB/100/sprockets%2Fd313bd7561b538fb7f2c4ab89dba5b7b +0 -0
  143. data/sandbox/tmp/cache/assets/DCD/930/sprockets%2F6fd2f59e45a7f3c88a183ee00d1cccd0 +0 -0
  144. data/sandbox/tmp/cache/assets/DD0/140/sprockets%2Ff9c3eeef5e04c483a3d2e3fbf458a413 +0 -0
  145. data/sandbox/tmp/cache/assets/DD5/040/sprockets%2F8b8bc1dd8d844edda81c52b7bd29a926 +0 -0
  146. data/sandbox/tmp/cache/assets/DD6/B70/sprockets%2F2f433efcb60c276ccd93cfdce59687a1 +0 -0
  147. data/sandbox/tmp/cache/assets/DD7/9B0/sprockets%2F9f2c0826bd7ae7b745ae8da6db48c26e +0 -0
  148. data/sandbox/tmp/cache/assets/DD8/3B0/sprockets%2Fef4ddeef4487be0bf8c6412714f61e8a +0 -0
  149. data/sandbox/tmp/cache/assets/DE5/390/sprockets%2F24a1cda6893cebd53997dc859def67cd +0 -0
  150. data/sandbox/tmp/cache/assets/DF5/EF0/sprockets%2Fd1e83d1a6f55fafac76b4a2ac8541fd1 +0 -0
  151. data/sandbox/tmp/cache/assets/DFC/890/sprockets%2F2a2c6a1ea98a0cd7b5f7ff4ef7264b3c +0 -0
  152. data/sandbox/tmp/cache/assets/E05/2E0/sprockets%2F92ecbfa92baf6e394ce6c39d731b7cd2 +0 -0
  153. data/sandbox/tmp/cache/assets/E12/710/sprockets%2F7e9ee2069eafc7ddd7aff731dc9186d2 +0 -0
  154. data/sandbox/tmp/cache/assets/E38/420/sprockets%2Fd5e6ba266c8ebddcbf04b3099cf747ff +0 -0
  155. data/sandbox/tmp/cache/assets/E3F/FE0/sprockets%2Fbbbb6f82edbdac31a0c71ce0b04718ac +0 -0
  156. data/sandbox/tmp/cache/assets/E40/840/sprockets%2F0b2c9ee1f1fe00aad3bec06cbd08cd15 +0 -0
  157. data/sandbox/tmp/cache/assets/EC9/D10/sprockets%2F8dfe5ddb2cf1a7f77098fd9eb4ddbcab +0 -0
  158. data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/components.sassc +0 -0
  159. data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/reset.sassc +0 -0
  160. data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/variables.sassc +0 -0
  161. data/sandbox/tmp/cache/sass/e18337f0c19dfad20daa699fa9a096f70c37cd66/experiment.sassc +0 -0
  162. data/vendor/assets/javascripts/iugu-ux/components/base_resource.js.coffee +21 -0
  163. data/vendor/assets/javascripts/iugu-ux/components/base_resources.js.coffee +65 -0
  164. data/vendor/assets/javascripts/iugu-ux/components/iugu-ux-components.js +7 -1
  165. data/vendor/assets/javascripts/iugu-ux/components/iugu-ux-main.js.coffee +4 -2
  166. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-alert.jst.eco +6 -0
  167. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-dataset-record.jst.eco +6 -0
  168. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-dataset.jst.eco +2 -0
  169. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-navigator.jst.eco +6 -0
  170. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-paginator.jst.eco +19 -0
  171. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-responsive-box.jst.eco +2 -0
  172. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-scrollable-container.jst.eco +4 -0
  173. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search-filter.jst.eco +15 -0
  174. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search-range.jst.eco +5 -0
  175. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-search.jst.eco +3 -0
  176. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-table-row.jst.eco +3 -0
  177. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-table.jst.eco +19 -0
  178. data/vendor/assets/javascripts/iugu-ux/components/usecode/// +83 -0
  179. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-alert.js.coffee +17 -0
  180. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-base.js.coffee +83 -0
  181. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-dataset-record.js.coffee +17 -0
  182. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-dataset.js.coffee +47 -0
  183. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-navigator.js.coffee +47 -0
  184. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-paginator.js.coffee +58 -0
  185. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-responsive-box.js.coffee +83 -0
  186. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-scrollable-content.js.coffee +13 -0
  187. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-filter.js.coffee +55 -0
  188. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search-range.js.coffee +35 -0
  189. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-search.js.coffee +28 -0
  190. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-table.js.coffee +39 -0
  191. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee +78 -0
  192. data/vendor/assets/javascripts/iugu-ux/iugu-ui-helpers.js.coffee +52 -0
  193. data/vendor/assets/javascripts/iugu-ux/iugu-ux.js +0 -1
  194. data/vendor/assets/javascripts/iugu-ux/web-app.js +5 -1
  195. data/vendor/assets/javascripts/vendor.js +5 -0
  196. data/vendor/assets/javascripts/vendor/async.js +700 -0
  197. data/vendor/assets/javascripts/vendor/backbone.paginator.js +833 -0
  198. data/vendor/assets/javascripts/vendor/backbone.validation.js +538 -0
  199. data/vendor/assets/javascripts/vendor/rivets.js +583 -0
  200. data/vendor/assets/javascripts/vendor/tasks.js.coffee +16 -0
  201. data/vendor/assets/javascripts/web-app/config.js.erb +2 -0
  202. data/vendor/assets/javascripts/web-app/helpers.coffee +5 -0
  203. data/vendor/assets/stylesheets/iugu-ux/components.sass +186 -0
  204. data/vendor/assets/stylesheets/iugu-ux/reset.sass +5 -0
  205. data/vendor/assets/stylesheets/iugu-ux/variables.sass +28 -0
  206. metadata +260 -44
  207. data/sandbox/app/assets/stylesheets/application.css +0 -3
  208. data/sandbox/app/assets/stylesheets/default-sprites.sass +0 -12
  209. data/sandbox/app/assets/stylesheets/experiment.sass +0 -181
  210. data/sandbox/app/assets/stylesheets/mq-styles.sass +0 -50
  211. data/sandbox/app/assets/stylesheets/mqtest.css +0 -6
  212. data/sandbox/app/assets/stylesheets/sandbox-sprites.css +0 -6
  213. data/sandbox/app/views/ui_library/mediaquery.html.haml +0 -5
@@ -0,0 +1,833 @@
1
+ /*! backbone.paginator - v0.1.54 - 8/18/2012
2
+ * http://github.com/addyosmani/backbone.paginator
3
+ * Copyright (c) 2012 Addy Osmani; Licensed MIT */
4
+
5
+ Backbone.Paginator = (function ( Backbone, _, $ ) {
6
+ "use strict";
7
+
8
+ var Paginator = {};
9
+ Paginator.version = "0.15";
10
+
11
+ // @name: clientPager
12
+ //
13
+ // @tagline: Paginator for client-side data
14
+ //
15
+ // @description:
16
+ // This paginator is responsible for providing pagination
17
+ // and sort capabilities for a single payload of data
18
+ // we wish to paginate by the UI for easier browsering.
19
+ //
20
+ Paginator.clientPager = Backbone.Collection.extend({
21
+
22
+ // Default values used when sorting and/or filtering.
23
+ initialize: function(){
24
+ this.useDiacriticsPlugin = true; // use diacritics plugin if available
25
+ this.useLevenshteinPlugin = true; // use levenshtein plugin if available
26
+
27
+ this.sortColumn = "";
28
+ this.sortDirection = "desc";
29
+ this.lastSortColumn = "";
30
+
31
+ this.fieldFilterRules = [];
32
+ this.lastFieldFilterRules = [];
33
+
34
+ this.filterFields = "";
35
+ this.filterExpression = "";
36
+ this.lastFilterExpression = "";
37
+ },
38
+
39
+ sync: function ( method, model, options ) {
40
+
41
+ var self = this;
42
+
43
+ // Create default values if no others are specified
44
+ _.defaults(self.paginator_ui, {
45
+ firstPage: 0,
46
+ currentPage: 1,
47
+ perPage: 5,
48
+ totalPages: 10
49
+ });
50
+
51
+ // Change scope of 'paginator_ui' object values
52
+ _.each(self.paginator_ui, function(value, key) {
53
+ if( _.isUndefined(self[key]) ) {
54
+ self[key] = self.paginator_ui[key];
55
+ }
56
+ });
57
+
58
+ // Some values could be functions, let's make sure
59
+ // to change their scope too and run them
60
+ var queryAttributes = {};
61
+ _.each(self.server_api, function(value, key){
62
+ if( _.isFunction(value) ) {
63
+ value = _.bind(value, self);
64
+ value = value();
65
+ }
66
+ queryAttributes[key] = value;
67
+ });
68
+
69
+ var queryOptions = _.clone(self.paginator_core);
70
+ _.each(queryOptions, function(value, key){
71
+ if( _.isFunction(value) ) {
72
+ value = _.bind(value, self);
73
+ value = value();
74
+ }
75
+ queryOptions[key] = value;
76
+ });
77
+
78
+ // Create default values if no others are specified
79
+ queryOptions = _.defaults(queryOptions, {
80
+ timeout: 25000,
81
+ cache: false,
82
+ type: 'GET',
83
+ dataType: 'jsonp'
84
+ });
85
+
86
+ queryOptions = _.extend(queryOptions, {
87
+ jsonpCallback: 'callback',
88
+ data: decodeURIComponent($.param(queryAttributes)),
89
+ processData: false,
90
+ url: _.result(queryOptions, 'url')
91
+ }, options);
92
+
93
+ return $.ajax( queryOptions );
94
+
95
+ },
96
+
97
+ nextPage: function () {
98
+ this.currentPage = ++this.currentPage;
99
+ this.pager();
100
+ },
101
+
102
+ previousPage: function () {
103
+ this.currentPage = --this.currentPage || 1;
104
+ this.pager();
105
+ },
106
+
107
+ goTo: function ( page ) {
108
+ if(page !== undefined){
109
+ this.currentPage = parseInt(page, 10);
110
+ this.pager();
111
+ }
112
+ },
113
+
114
+ howManyPer: function ( perPage ) {
115
+ if(perPage !== undefined){
116
+ var lastPerPage = this.perPage;
117
+ this.perPage = parseInt(perPage, 10);
118
+ this.currentPage = Math.ceil( ( lastPerPage * ( this.currentPage - 1 ) + 1 ) / perPage);
119
+ this.pager();
120
+ }
121
+ },
122
+
123
+
124
+ // setSort is used to sort the current model. After
125
+ // passing 'column', which is the model's field you want
126
+ // to filter and 'direction', which is the direction
127
+ // desired for the ordering ('asc' or 'desc'), pager()
128
+ // and info() will be called automatically.
129
+ setSort: function ( column, direction ) {
130
+ if(column !== undefined && direction !== undefined){
131
+ this.lastSortColumn = this.sortColumn;
132
+ this.sortColumn = column;
133
+ this.sortDirection = direction;
134
+ this.pager();
135
+ this.info();
136
+ }
137
+ },
138
+
139
+ // setFieldFilter is used to filter each value of each model
140
+ // according to `rules` that you pass as argument.
141
+ // Example: You have a collection of books with 'release year' and 'author'.
142
+ // You can filter only the books that were released between 1999 and 2003
143
+ // And then you can add another `rule` that will filter those books only to
144
+ // authors who's name start with 'A'.
145
+ setFieldFilter: function ( fieldFilterRules ) {
146
+ if( !_.isEmpty( fieldFilterRules ) ) {
147
+ this.lastFieldFilterRules = this.fieldFilterRules;
148
+ this.fieldFilterRules = fieldFilterRules;
149
+ this.pager();
150
+ this.info();
151
+ }
152
+ },
153
+
154
+ // doFakeFieldFilter can be used to get the number of models that will remain
155
+ // after calling setFieldFilter with a filter rule(s)
156
+ doFakeFieldFilter: function ( fieldFilterRules ) {
157
+ if( !_.isEmpty( fieldFilterRules ) ) {
158
+ var bkp_lastFieldFilterRules = this.lastFieldFilterRules;
159
+ var bkp_fieldFilterRules = this.fieldFilterRules;
160
+
161
+ this.lastFieldFilterRules = this.fieldFilterRules;
162
+ this.fieldFilterRules = fieldFilterRules;
163
+ this.pager();
164
+ this.info();
165
+
166
+ var cmodels = this.models.length;
167
+
168
+ this.lastFieldFilterRules = bkp_lastFieldFilterRules;
169
+ this.fieldFilterRules = bkp_fieldFilterRules;
170
+ this.pager();
171
+ this.info();
172
+
173
+ // Return size
174
+ return cmodels;
175
+ }
176
+ },
177
+
178
+ // setFilter is used to filter the current model. After
179
+ // passing 'fields', which can be a string referring to
180
+ // the model's field, an array of strings representing
181
+ // each of the model's fields or an object with the name
182
+ // of the model's field(s) and comparing options (see docs)
183
+ // you wish to filter by and
184
+ // 'filter', which is the word or words you wish to
185
+ // filter by, pager() and info() will be called automatically.
186
+ setFilter: function ( fields, filter ) {
187
+ if( fields !== undefined && filter !== undefined ){
188
+ this.filterFields = fields;
189
+ this.lastFilterExpression = this.filterExpression;
190
+ this.filterExpression = filter;
191
+ this.pager();
192
+ this.info();
193
+ }
194
+ },
195
+
196
+ // doFakeFilter can be used to get the number of models that will
197
+ // remain after calling setFilter with a `fields` and `filter` args.
198
+ doFakeFilter: function ( fields, filter ) {
199
+ if( fields !== undefined && filter !== undefined ){
200
+ var bkp_filterFields = this.filterFields;
201
+ var bkp_lastFilterExpression = this.lastFilterExpression;
202
+ var bkp_filterExpression = this.filterExpression;
203
+
204
+ this.filterFields = fields;
205
+ this.lastFilterExpression = this.filterExpression;
206
+ this.filterExpression = filter;
207
+ this.pager();
208
+ this.info();
209
+
210
+ var cmodels = this.models.length;
211
+
212
+ this.filterFields = bkp_filterFields;
213
+ this.lastFilterExpression = bkp_lastFilterExpression;
214
+ this.filterExpression = bkp_filterExpression;
215
+ this.pager();
216
+ this.info();
217
+
218
+ // Return size
219
+ return cmodels;
220
+ }
221
+ },
222
+
223
+ // pager is used to sort, filter and show the data
224
+ // you expect the library to display.
225
+ pager: function () {
226
+ var self = this,
227
+ disp = this.perPage,
228
+ start = (self.currentPage - 1) * disp,
229
+ stop = start + disp;
230
+
231
+ // Saving the original models collection is important
232
+ // as we could need to sort or filter, and we don't want
233
+ // to loose the data we fetched from the server.
234
+ if (self.origModels === undefined) {
235
+ self.origModels = self.models;
236
+ }
237
+
238
+ self.models = self.origModels;
239
+
240
+ // Check if sorting was set using setSort.
241
+ if ( this.sortColumn !== "" ) {
242
+ self.models = self._sort(self.models, this.sortColumn, this.sortDirection);
243
+ }
244
+
245
+ // Check if field-filtering was set using setFieldFilter
246
+ if ( !_.isEmpty( this.fieldFilterRules ) ) {
247
+ self.models = self._fieldFilter(self.models, this.fieldFilterRules);
248
+ }
249
+
250
+ // Check if filtering was set using setFilter.
251
+ if ( this.filterExpression !== "" ) {
252
+ self.models = self._filter(self.models, this.filterFields, this.filterExpression);
253
+ }
254
+
255
+ // If the sorting or the filtering was changed go to the first page
256
+ if ( this.lastSortColumn !== this.sortColumn || this.lastFilterExpression !== this.filterExpression || !_.isEqual(this.fieldFilterRules, this.lastFieldFilterRules) ) {
257
+ start = 0;
258
+ stop = start + disp;
259
+ self.currentPage = 1;
260
+
261
+ this.lastSortColumn = this.sortColumn;
262
+ this.lastFieldFilterRules = this.fieldFilterRules;
263
+ this.lastFilterExpression = this.filterExpression;
264
+ }
265
+
266
+ // We need to save the sorted and filtered models collection
267
+ // because we'll use that sorted and filtered collection in info().
268
+ self.sortedAndFilteredModels = self.models;
269
+
270
+ self.reset(self.models.slice(start, stop));
271
+ },
272
+
273
+ // The actual place where the collection is sorted.
274
+ // Check setSort for arguments explicacion.
275
+ _sort: function ( models, sort, direction ) {
276
+ models = models.sort(function (a, b) {
277
+ var ac = a.get(sort),
278
+ bc = b.get(sort);
279
+
280
+ if ( !ac || !bc ) {
281
+ return 0;
282
+ } else {
283
+ /* Make sure that both ac and bc are lowercase strings.
284
+ * .toString() first so we don't have to worry if ac or bc
285
+ * have other String-only methods.
286
+ */
287
+ ac = ac.toString().toLowerCase();
288
+ bc = bc.toString().toLowerCase();
289
+ }
290
+
291
+ if (direction === 'desc') {
292
+
293
+ // We need to know if there aren't any non-number characters
294
+ // and that there are numbers-only characters and maybe a dot
295
+ // if we have a float.
296
+ if((!ac.match(/[^\d\.]/) && ac.match(/[\d\.]*/)) &&
297
+ (!bc.match(/[^\d\.]/) && bc.match(/[\d\.]*/))
298
+ ){
299
+
300
+ if( (ac - 0) < (bc - 0) ) {
301
+ return 1;
302
+ }
303
+ if( (ac - 0) > (bc - 0) ) {
304
+ return -1;
305
+ }
306
+ } else {
307
+ if (ac < bc) {
308
+ return 1;
309
+ }
310
+ if (ac > bc) {
311
+ return -1;
312
+ }
313
+ }
314
+
315
+ } else {
316
+
317
+ //Same as the regexp check in the 'if' part.
318
+ if((!ac.match(/[^\d\.]/) && ac.match(/[\d\.]*/)) &&
319
+ (!bc.match(/[^\d\.]/) && bc.match(/[\d\.]*/))
320
+ ){
321
+ if( (ac - 0) < (bc - 0) ) {
322
+ return -1;
323
+ }
324
+ if( (ac - 0) > (bc - 0) ) {
325
+ return 1;
326
+ }
327
+ } else {
328
+ if (ac < bc) {
329
+ return -1;
330
+ }
331
+ if (ac > bc) {
332
+ return 1;
333
+ }
334
+ }
335
+
336
+ }
337
+
338
+ return 0;
339
+ });
340
+
341
+ return models;
342
+ },
343
+
344
+ // The actual place where the collection is field-filtered.
345
+ // Check setFieldFilter for arguments explicacion.
346
+ _fieldFilter: function( models, rules ) {
347
+
348
+ // Check if there are any rules
349
+ if ( _.isEmpty(rules) ) {
350
+ return models;
351
+ }
352
+
353
+ var filteredModels = [];
354
+
355
+ // Iterate over each rule
356
+ _.each(models, function(model){
357
+
358
+ var should_push = true;
359
+
360
+ // Apply each rule to each model in the collection
361
+ _.each(rules, function(rule){
362
+
363
+ // Don't go inside the switch if we're already sure that the model won't be included in the results
364
+ if( !should_push ){
365
+ return false;
366
+ }
367
+
368
+ should_push = false;
369
+
370
+ // The field's value will be passed to a custom function, which should
371
+ // return true (if model should be included) or false (model should be ignored)
372
+ if(rule.type === "function"){
373
+ var f = _.wrap(rule.value, function(func){
374
+ return func( model.get(rule.field) );
375
+ });
376
+ if( f() ){
377
+ should_push = true;
378
+ }
379
+
380
+ // The field's value is required to be non-empty
381
+ }else if(rule.type === "required"){
382
+ if( !_.isEmpty( model.get(rule.field).toString() ) ) {
383
+ should_push = true;
384
+ }
385
+
386
+ // The field's value is required to be greater tan N (numbers only)
387
+ }else if(rule.type === "min"){
388
+ if( !_.isNaN( Number( model.get(rule.field) ) ) &&
389
+ !_.isNaN( Number( rule.value ) ) &&
390
+ Number( model.get(rule.field) ) >= Number( rule.value ) ) {
391
+ should_push = true;
392
+ }
393
+
394
+ // The field's value is required to be smaller tan N (numbers only)
395
+ }else if(rule.type === "max"){
396
+ if( !_.isNaN( Number( model.get(rule.field) ) ) &&
397
+ !_.isNaN( Number( rule.value ) ) &&
398
+ Number( model.get(rule.field) ) <= Number( rule.value ) ) {
399
+ should_push = true;
400
+ }
401
+
402
+ // The field's value is required to be between N and M (numbers only)
403
+ }else if(rule.type === "range"){
404
+ if( !_.isNaN( Number( model.get(rule.field) ) ) &&
405
+ _.isObject( rule.value ) &&
406
+ !_.isNaN( Number( rule.value.min ) ) &&
407
+ !_.isNaN( Number( rule.value.max ) ) &&
408
+ Number( model.get(rule.field) ) >= Number( rule.value.min ) &&
409
+ Number( model.get(rule.field) ) <= Number( rule.value.max ) ) {
410
+ should_push = true;
411
+ }
412
+
413
+ // The field's value is required to be more than N chars long
414
+ }else if(rule.type === "minLength"){
415
+ if( model.get(rule.field).toString().length >= rule.value ) {
416
+ should_push = true;
417
+ }
418
+
419
+ // The field's value is required to be no more than N chars long
420
+ }else if(rule.type === "maxLength"){
421
+ if( model.get(rule.field).toString().length <= rule.value ) {
422
+ should_push = true;
423
+ }
424
+
425
+ // The field's value is required to be more than N chars long and no more than M chars long
426
+ }else if(rule.type === "rangeLength"){
427
+ if( _.isObject( rule.value ) &&
428
+ !_.isNaN( Number( rule.value.min ) ) &&
429
+ !_.isNaN( Number( rule.value.max ) ) &&
430
+ model.get(rule.field).toString().length >= rule.value.min &&
431
+ model.get(rule.field).toString().length <= rule.value.max ) {
432
+ should_push = true;
433
+ }
434
+
435
+ // The field's value is required to be equal to one of the values in rules.value
436
+ }else if(rule.type === "oneOf"){
437
+ if( _.isArray( rule.value ) &&
438
+ _.include( rule.value, model.get(rule.field) ) ) {
439
+ should_push = true;
440
+ }
441
+
442
+ // The field's value is required to be equal to the value in rules.value
443
+ }else if(rule.type === "equalTo"){
444
+ if( rule.value === model.get(rule.field) ) {
445
+ should_push = true;
446
+ }
447
+
448
+ // The field's value is required to match the regular expression
449
+ }else if(rule.type === "pattern"){
450
+ if( model.get(rule.field).toString().match(rule.value) ) {
451
+ should_push = true;
452
+ }
453
+
454
+ //Unknown type
455
+ }else{
456
+ should_push = false;
457
+ }
458
+
459
+ });
460
+
461
+ if( should_push ){
462
+ filteredModels.push(model);
463
+ }
464
+
465
+ });
466
+
467
+ return filteredModels;
468
+ },
469
+
470
+ // The actual place where the collection is filtered.
471
+ // Check setFilter for arguments explicacion.
472
+ _filter: function ( models, fields, filter ) {
473
+
474
+ // For example, if you had a data model containing cars like { color: '', description: '', hp: '' },
475
+ // your fields was set to ['color', 'description', 'hp'] and your filter was set
476
+ // to "Black Mustang 300", the word "Black" will match all the cars that have black color, then
477
+ // "Mustang" in the description and then the HP in the 'hp' field.
478
+ // NOTE: "Black Musta 300" will return the same as "Black Mustang 300"
479
+
480
+ // We accept fields to be a string, an array or an object
481
+ // but if string or array is passed we need to convert it
482
+ // to an object.
483
+
484
+ var self = this;
485
+
486
+ var obj_fields = {};
487
+
488
+ if( _.isString( fields ) ) {
489
+ obj_fields[fields] = {cmp_method: 'regexp'};
490
+ }else if( _.isArray( fields ) ) {
491
+ _.each(fields, function(field){
492
+ obj_fields[field] = {cmp_method: 'regexp'};
493
+ });
494
+ }else{
495
+ _.each(fields, function( cmp_opts, field ) {
496
+ obj_fields[field] = _.defaults(cmp_opts, { cmp_method: 'regexp' });
497
+ });
498
+ }
499
+
500
+ fields = obj_fields;
501
+
502
+ //Remove diacritic characters if diacritic plugin is loaded
503
+ if( _.has(Backbone.Paginator, 'removeDiacritics') && self.useDiacriticsPlugin ){
504
+ filter = Backbone.Paginator.removeDiacritics(filter);
505
+ }
506
+
507
+ // 'filter' can be only a string.
508
+ // If 'filter' is string we need to convert it to
509
+ // a regular expression.
510
+ // For example, if 'filter' is 'black dog' we need
511
+ // to find every single word, remove duplicated ones (if any)
512
+ // and transform the result to '(black|dog)'
513
+ if( filter === '' || !_.isString(filter) ) {
514
+ return models;
515
+ } else {
516
+ var words = filter.match(/\w+/ig);
517
+ var pattern = "(" + _.uniq(words).join("|") + ")";
518
+ var regexp = new RegExp(pattern, "igm");
519
+ }
520
+
521
+ var filteredModels = [];
522
+
523
+ // We need to iterate over each model
524
+ _.each( models, function( model ) {
525
+
526
+ var matchesPerModel = [];
527
+
528
+ // and over each field of each model
529
+ _.each( fields, function( cmp_opts, field ) {
530
+
531
+ var value = model.get( field );
532
+
533
+ if( value ) {
534
+
535
+ // The regular expression we created earlier let's us detect if a
536
+ // given string contains each and all of the words in the regular expression
537
+ // or not, but in both cases match() will return an array containing all
538
+ // the words it matched.
539
+ var matchesPerField = [];
540
+
541
+ if( _.has(Backbone.Paginator, 'removeDiacritics') && self.useDiacriticsPlugin ){
542
+ value = Backbone.Paginator.removeDiacritics(value.toString());
543
+ }else{
544
+ value = value.toString();
545
+ }
546
+
547
+ // Levenshtein cmp
548
+ if( cmp_opts.cmp_method === 'levenshtein' && _.has(Backbone.Paginator, 'levenshtein') && self.useLevenshteinPlugin ) {
549
+ var distance = Backbone.Paginator.levenshtein(value, filter);
550
+
551
+ _.defaults(cmp_opts, { max_distance: 0 });
552
+
553
+ if( distance <= cmp_opts.max_distance ) {
554
+ matchesPerField = _.uniq(words);
555
+ }
556
+
557
+ // Default (RegExp) cmp
558
+ }else{
559
+ matchesPerField = value.match( regexp );
560
+ }
561
+
562
+ matchesPerField = _.map(matchesPerField, function(match) {
563
+ return match.toString().toLowerCase();
564
+ });
565
+
566
+ _.each(matchesPerField, function(match){
567
+ matchesPerModel.push(match);
568
+ });
569
+
570
+ }
571
+
572
+ });
573
+
574
+ // We just need to check if the returned array contains all the words in our
575
+ // regex, and if it does, it means that we have a match, so we should save it.
576
+ matchesPerModel = _.uniq( _.without(matchesPerModel, "") );
577
+
578
+ if( _.isEmpty( _.difference(words, matchesPerModel) ) ) {
579
+ filteredModels.push(model);
580
+ }
581
+
582
+ });
583
+
584
+ return filteredModels;
585
+ },
586
+
587
+ // You shouldn't need to call info() as this method is used to
588
+ // calculate internal data as first/prev/next/last page...
589
+ info: function () {
590
+ var self = this,
591
+ info = {},
592
+ totalRecords = (self.sortedAndFilteredModels) ? self.sortedAndFilteredModels.length : self.length,
593
+ totalPages = Math.ceil(totalRecords / self.perPage);
594
+
595
+ info = {
596
+ totalUnfilteredRecords: self.origModels.length,
597
+ totalRecords: totalRecords,
598
+ currentPage: self.currentPage,
599
+ perPage: this.perPage,
600
+ totalPages: totalPages,
601
+ lastPage: totalPages,
602
+ previous: false,
603
+ next: false,
604
+ startRecord: totalRecords === 0 ? 0 : (self.currentPage - 1) * this.perPage + 1,
605
+ endRecord: Math.min(totalRecords, self.currentPage * this.perPage)
606
+ };
607
+
608
+ if (self.currentPage > 1) {
609
+ info.previous = self.currentPage - 1;
610
+ }
611
+
612
+ if (self.currentPage < info.totalPages) {
613
+ info.next = self.currentPage + 1;
614
+ }
615
+
616
+ info.pageSet = self.setPagination(info);
617
+
618
+ self.information = info;
619
+ return info;
620
+ },
621
+
622
+
623
+ // setPagination also is an internal function that shouldn't be called directly.
624
+ // It will create an array containing the pages right before and right after the
625
+ // actual page.
626
+ setPagination: function ( info ) {
627
+ var pages = [], i = 0, l = 0;
628
+
629
+
630
+ // How many adjacent pages should be shown on each side?
631
+ var ADJACENT = 3,
632
+ ADJACENTx2 = ADJACENT * 2,
633
+ LASTPAGE = Math.ceil(info.totalRecords / info.perPage),
634
+ LPM1 = -1;
635
+
636
+ if (LASTPAGE > 1) {
637
+ // not enough pages to bother breaking it up
638
+ if (LASTPAGE < (7 + ADJACENTx2)) {
639
+ for (i = 1, l = LASTPAGE; i <= l; i++) {
640
+ pages.push(i);
641
+ }
642
+ }
643
+ // enough pages to hide some
644
+ else if (LASTPAGE > (5 + ADJACENTx2)) {
645
+
646
+ //close to beginning; only hide later pages
647
+ if (info.currentPage < (1 + ADJACENTx2)) {
648
+ for (i = 1, l = 4 + ADJACENTx2; i < l; i++) {
649
+ pages.push(i);
650
+ }
651
+ }
652
+
653
+ // in middle; hide some front and some back
654
+ else if (LASTPAGE - ADJACENTx2 > info.currentPage && info.currentPage > ADJACENTx2) {
655
+ for (i = info.currentPage - ADJACENT; i <= info.currentPage + ADJACENT; i++) {
656
+ pages.push(i);
657
+ }
658
+ }
659
+ // close to end; only hide early pages
660
+ else {
661
+ for (i = LASTPAGE - (2 + ADJACENTx2); i <= LASTPAGE; i++) {
662
+ pages.push(i);
663
+ }
664
+ }
665
+ }
666
+ }
667
+
668
+ return pages;
669
+ }
670
+
671
+ });
672
+
673
+
674
+ // @name: requestPager
675
+ //
676
+ // Paginator for server-side data being requested from a backend/API
677
+ //
678
+ // @description:
679
+ // This paginator is responsible for providing pagination
680
+ // and sort capabilities for requests to a server-side
681
+ // data service (e.g an API)
682
+ //
683
+ Paginator.requestPager = Backbone.Collection.extend({
684
+
685
+ sync: function ( method, model, options ) {
686
+
687
+ var self = this;
688
+
689
+ // Create default values if no others are specified
690
+ _.defaults(self.paginator_ui, {
691
+ firstPage: 0,
692
+ currentPage: 1,
693
+ perPage: 5,
694
+ totalPages: 10
695
+ });
696
+
697
+ // Change scope of 'paginator_ui' object values
698
+ _.each(self.paginator_ui, function(value, key) {
699
+ if( _.isUndefined(self[key]) ) {
700
+ self[key] = self.paginator_ui[key];
701
+ }
702
+ });
703
+
704
+ // Some values could be functions, let's make sure
705
+ // to change their scope too and run them
706
+ var queryAttributes = {};
707
+ _.each(self.server_api, function(value, key){
708
+ if( _.isFunction(value) ) {
709
+ value = _.bind(value, self);
710
+ value = value();
711
+ }
712
+ queryAttributes[key] = value;
713
+ });
714
+
715
+ var queryOptions = _.clone(self.paginator_core);
716
+ _.each(queryOptions, function(value, key){
717
+ if( _.isFunction(value) ) {
718
+ value = _.bind(value, self);
719
+ value = value();
720
+ }
721
+ queryOptions[key] = value;
722
+ });
723
+
724
+ // Create default values if no others are specified
725
+ queryOptions = _.defaults(queryOptions, {
726
+ timeout: 25000,
727
+ cache: false,
728
+ type: 'GET',
729
+ dataType: 'jsonp'
730
+ });
731
+
732
+ // Allows the passing in of {data: {foo: 'bar'}} at request time to overwrite server_api defaults
733
+ if( options.data ){
734
+ options.data = decodeURIComponent($.param(_.extend(queryAttributes,options.data)));
735
+ }else{
736
+ options.data = decodeURIComponent($.param(queryAttributes));
737
+ }
738
+
739
+ queryOptions = _.extend(queryOptions, {
740
+ jsonpCallback: 'callback',
741
+ processData: false,
742
+ url: _.result(queryOptions, 'url')
743
+ }, options);
744
+
745
+ return $.ajax( queryOptions );
746
+
747
+ },
748
+
749
+ requestNextPage: function ( options ) {
750
+ if ( this.currentPage !== undefined ) {
751
+ this.currentPage += 1;
752
+ return this.pager( options );
753
+ } else {
754
+ var response = new $.Deferred();
755
+ response.reject();
756
+ return response.promise();
757
+ }
758
+ },
759
+
760
+ requestPreviousPage: function ( options ) {
761
+ if ( this.currentPage !== undefined ) {
762
+ this.currentPage -= 1;
763
+ return this.pager( options );
764
+ } else {
765
+ var response = new $.Deferred();
766
+ response.reject();
767
+ return response.promise();
768
+ }
769
+ },
770
+
771
+ updateOrder: function ( column ) {
772
+ if (column !== undefined) {
773
+ this.sortField = column;
774
+ this.pager();
775
+ }
776
+
777
+ },
778
+
779
+ goTo: function ( page, options ) {
780
+ if ( page !== undefined ) {
781
+ this.currentPage = parseInt(page, 10);
782
+ return this.pager( options );
783
+ } else {
784
+ var response = new $.Deferred();
785
+ response.reject();
786
+ return response.promise();
787
+ }
788
+ },
789
+
790
+ howManyPer: function ( count ) {
791
+ if( count !== undefined ){
792
+ this.currentPage = this.firstPage;
793
+ this.perPage = count;
794
+ this.pager();
795
+ }
796
+ },
797
+
798
+ sort: function () {
799
+ //assign to as needed.
800
+ },
801
+
802
+ info: function () {
803
+
804
+ var info = {
805
+ // If parse() method is implemented and totalRecords is set to the length
806
+ // of the records returned, make it available. Else, default it to 0
807
+ totalRecords: this.totalRecords || 0,
808
+
809
+ currentPage: this.currentPage,
810
+ firstPage: this.firstPage,
811
+ totalPages: this.totalPages,
812
+ lastPage: this.totalPages,
813
+ perPage: this.perPage
814
+ };
815
+
816
+ this.information = info;
817
+ return info;
818
+ },
819
+
820
+ // fetches the latest results from the server
821
+ pager: function ( options ) {
822
+ if ( !_.isObject(options) ) {
823
+ options = {};
824
+ }
825
+ return this.fetch( options );
826
+ }
827
+
828
+
829
+ });
830
+
831
+ return Paginator;
832
+
833
+ }( Backbone, _, jQuery ));