catarse_full 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (865) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +19 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +45 -0
  5. data/app/assets/fonts/icomoon.eot +0 -0
  6. data/app/assets/fonts/icomoon.json +1 -0
  7. data/app/assets/fonts/icomoon.svg +30 -0
  8. data/app/assets/fonts/icomoon.ttf +0 -0
  9. data/app/assets/fonts/icomoon.woff +0 -0
  10. data/app/assets/images/.gitkeep +0 -0
  11. data/app/assets/images/auth/facebook_64.png +0 -0
  12. data/app/assets/images/auth/twitter_64.png +0 -0
  13. data/app/assets/images/catarse/ProjectUpdate.jpg +0 -0
  14. data/app/assets/images/catarse/back_icons.png +0 -0
  15. data/app/assets/images/catarse/back_statistics.gif +0 -0
  16. data/app/assets/images/catarse/backed_icon.png +0 -0
  17. data/app/assets/images/catarse/backer_city.png +0 -0
  18. data/app/assets/images/catarse/backer_info.gif +0 -0
  19. data/app/assets/images/catarse/backer_info.png +0 -0
  20. data/app/assets/images/catarse/background.png +0 -0
  21. data/app/assets/images/catarse/background_full.jpg +0 -0
  22. data/app/assets/images/catarse/banner-10-milhoes.png +0 -0
  23. data/app/assets/images/catarse/bg64x64_s3.png +0 -0
  24. data/app/assets/images/catarse/bg_air.jpg +0 -0
  25. data/app/assets/images/catarse/bg_explore.jpg +0 -0
  26. data/app/assets/images/catarse/bg_finish.jpg +0 -0
  27. data/app/assets/images/catarse/bg_guardian.jpg +0 -0
  28. data/app/assets/images/catarse/bg_heartbacker.jpg +0 -0
  29. data/app/assets/images/catarse/bg_money.jpg +0 -0
  30. data/app/assets/images/catarse/bg_moneytag.jpg +0 -0
  31. data/app/assets/images/catarse/bg_requirements.png +0 -0
  32. data/app/assets/images/catarse/bg_rewards.jpg +0 -0
  33. data/app/assets/images/catarse/bg_s3.png +0 -0
  34. data/app/assets/images/catarse/bg_send.png +0 -0
  35. data/app/assets/images/catarse/bg_steps.png +0 -0
  36. data/app/assets/images/catarse/bg_tips.png +0 -0
  37. data/app/assets/images/catarse/bg_tips1.png +0 -0
  38. data/app/assets/images/catarse/bg_tips2.png +0 -0
  39. data/app/assets/images/catarse/bg_tips3.png +0 -0
  40. data/app/assets/images/catarse/bg_tips4.png +0 -0
  41. data/app/assets/images/catarse/bg_tips5.png +0 -0
  42. data/app/assets/images/catarse/bg_tips6.png +0 -0
  43. data/app/assets/images/catarse/bg_tips7.png +0 -0
  44. data/app/assets/images/catarse/bg_tips8.png +0 -0
  45. data/app/assets/images/catarse/blog_icon17x14.png +0 -0
  46. data/app/assets/images/catarse/boleto_icon.png +0 -0
  47. data/app/assets/images/catarse/bot_guidelines.gif +0 -0
  48. data/app/assets/images/catarse/bot_profileUser.png +0 -0
  49. data/app/assets/images/catarse/box_alert.png +0 -0
  50. data/app/assets/images/catarse/box_download.png +0 -0
  51. data/app/assets/images/catarse/box_en.jpg +0 -0
  52. data/app/assets/images/catarse/box_pt.jpg +0 -0
  53. data/app/assets/images/catarse/bullet-green.png +0 -0
  54. data/app/assets/images/catarse/button_explore.png +0 -0
  55. data/app/assets/images/catarse/button_send.png +0 -0
  56. data/app/assets/images/catarse/category_icon14x14.png +0 -0
  57. data/app/assets/images/catarse/cc_icon.png +0 -0
  58. data/app/assets/images/catarse/comments_icon28x18.png +0 -0
  59. data/app/assets/images/catarse/comum_logo127x27.png +0 -0
  60. data/app/assets/images/catarse/confirmed_icon.png +0 -0
  61. data/app/assets/images/catarse/delete_16.png +0 -0
  62. data/app/assets/images/catarse/embed_icon19x9.png +0 -0
  63. data/app/assets/images/catarse/expiring_icon20x22.png +0 -0
  64. data/app/assets/images/catarse/explore_icon21x14.png +0 -0
  65. data/app/assets/images/catarse/explore_icon23x15.png +0 -0
  66. data/app/assets/images/catarse/facebook_black_icon.png +0 -0
  67. data/app/assets/images/catarse/facebook_icon13x26.png +0 -0
  68. data/app/assets/images/catarse/faq_icon18x18.png +0 -0
  69. data/app/assets/images/catarse/faq_video.png +0 -0
  70. data/app/assets/images/catarse/flagCity.png +0 -0
  71. data/app/assets/images/catarse/flagCityMg.png +0 -0
  72. data/app/assets/images/catarse/flagCityPoa.png +0 -0
  73. data/app/assets/images/catarse/flagCityRJ.png +0 -0
  74. data/app/assets/images/catarse/flagName.png +0 -0
  75. data/app/assets/images/catarse/flagNameMg.png +0 -0
  76. data/app/assets/images/catarse/flagNamePoa.png +0 -0
  77. data/app/assets/images/catarse/flagNameRJ.png +0 -0
  78. data/app/assets/images/catarse/flagNameSP.png +0 -0
  79. data/app/assets/images/catarse/gift-reward.png +0 -0
  80. data/app/assets/images/catarse/gift.png +0 -0
  81. data/app/assets/images/catarse/glyphicons-halflings-white.png +0 -0
  82. data/app/assets/images/catarse/glyphicons-halflings.png +0 -0
  83. data/app/assets/images/catarse/goal_icon36x17.png +0 -0
  84. data/app/assets/images/catarse/grey.png +0 -0
  85. data/app/assets/images/catarse/heart_icon17x14.png +0 -0
  86. data/app/assets/images/catarse/icon-fb.png +0 -0
  87. data/app/assets/images/catarse/icon-moip.png +0 -0
  88. data/app/assets/images/catarse/icon-paypal.png +0 -0
  89. data/app/assets/images/catarse/icon-tw.png +0 -0
  90. data/app/assets/images/catarse/icon_about.png +0 -0
  91. data/app/assets/images/catarse/icon_backerstep1.png +0 -0
  92. data/app/assets/images/catarse/icon_backerstep2.png +0 -0
  93. data/app/assets/images/catarse/icon_backerstep3.png +0 -0
  94. data/app/assets/images/catarse/icon_backerstep4.png +0 -0
  95. data/app/assets/images/catarse/icon_backerstep5.png +0 -0
  96. data/app/assets/images/catarse/icon_backersucessfull.png +0 -0
  97. data/app/assets/images/catarse/icon_backproject.png +0 -0
  98. data/app/assets/images/catarse/icon_bold.png +0 -0
  99. data/app/assets/images/catarse/icon_calc.png +0 -0
  100. data/app/assets/images/catarse/icon_colective.png +0 -0
  101. data/app/assets/images/catarse/icon_creative.png +0 -0
  102. data/app/assets/images/catarse/icon_credits.png +0 -0
  103. data/app/assets/images/catarse/icon_creditsmoney.png +0 -0
  104. data/app/assets/images/catarse/icon_datestart.png +0 -0
  105. data/app/assets/images/catarse/icon_donation.png +0 -0
  106. data/app/assets/images/catarse/icon_faq.png +0 -0
  107. data/app/assets/images/catarse/icon_gift.png +0 -0
  108. data/app/assets/images/catarse/icon_guidebacker.png +0 -0
  109. data/app/assets/images/catarse/icon_guidelinesstart.png +0 -0
  110. data/app/assets/images/catarse/icon_heart.png +0 -0
  111. data/app/assets/images/catarse/icon_italic.png +0 -0
  112. data/app/assets/images/catarse/icon_licosts.png +0 -0
  113. data/app/assets/images/catarse/icon_limagic.png +0 -0
  114. data/app/assets/images/catarse/icon_limoney.png +0 -0
  115. data/app/assets/images/catarse/icon_link.png +0 -0
  116. data/app/assets/images/catarse/icon_linktext.png +0 -0
  117. data/app/assets/images/catarse/icon_liwork.png +0 -0
  118. data/app/assets/images/catarse/icon_logo.png +0 -0
  119. data/app/assets/images/catarse/icon_media.png +0 -0
  120. data/app/assets/images/catarse/icon_new.png +0 -0
  121. data/app/assets/images/catarse/icon_nonprofit.png +0 -0
  122. data/app/assets/images/catarse/icon_projectnotfunded.png +0 -0
  123. data/app/assets/images/catarse/icon_projectsuccess.png +0 -0
  124. data/app/assets/images/catarse/icon_refreshproject.png +0 -0
  125. data/app/assets/images/catarse/icon_rewards.png +0 -0
  126. data/app/assets/images/catarse/icon_social.png +0 -0
  127. data/app/assets/images/catarse/icon_soldout.png +0 -0
  128. data/app/assets/images/catarse/icon_step1.png +0 -0
  129. data/app/assets/images/catarse/icon_step2.png +0 -0
  130. data/app/assets/images/catarse/icon_step3.png +0 -0
  131. data/app/assets/images/catarse/icon_step4.png +0 -0
  132. data/app/assets/images/catarse/icon_submitbacker.png +0 -0
  133. data/app/assets/images/catarse/icon_tag.png +0 -0
  134. data/app/assets/images/catarse/icon_time.png +0 -0
  135. data/app/assets/images/catarse/icon_url.png +0 -0
  136. data/app/assets/images/catarse/icon_video.png +0 -0
  137. data/app/assets/images/catarse/icon_vimeo.png +0 -0
  138. data/app/assets/images/catarse/institutional_video_icon16x16.png +0 -0
  139. data/app/assets/images/catarse/label_green.png +0 -0
  140. data/app/assets/images/catarse/label_green_list.png +0 -0
  141. data/app/assets/images/catarse/label_orange.png +0 -0
  142. data/app/assets/images/catarse/label_orange_list.png +0 -0
  143. data/app/assets/images/catarse/link_icon14x14.png +0 -0
  144. data/app/assets/images/catarse/logo-fb.jpg +0 -0
  145. data/app/assets/images/catarse/logo.png +0 -0
  146. data/app/assets/images/catarse/min_star12x11.png +0 -0
  147. data/app/assets/images/catarse/moip-choice.png +0 -0
  148. data/app/assets/images/catarse/multide_logo55x36.png +0 -0
  149. data/app/assets/images/catarse/newsletter_icon18x15.png +0 -0
  150. data/app/assets/images/catarse/opendata_icon26x26.png +0 -0
  151. data/app/assets/images/catarse/partners_icon26x26.png +0 -0
  152. data/app/assets/images/catarse/payment_account.jpg +0 -0
  153. data/app/assets/images/catarse/payment_boleto.jpg +0 -0
  154. data/app/assets/images/catarse/payment_cards.jpg +0 -0
  155. data/app/assets/images/catarse/paypal-choice.png +0 -0
  156. data/app/assets/images/catarse/pencil_16.png +0 -0
  157. data/app/assets/images/catarse/play89x89.png +0 -0
  158. data/app/assets/images/catarse/post_title_image.png +0 -0
  159. data/app/assets/images/catarse/power_logo200x43.png +0 -0
  160. data/app/assets/images/catarse/profile_icon19x14.png +0 -0
  161. data/app/assets/images/catarse/project_about.png +0 -0
  162. data/app/assets/images/catarse/recents_icon18x23.png +0 -0
  163. data/app/assets/images/catarse/recents_icon31x17.png +0 -0
  164. data/app/assets/images/catarse/recompensa24x20.png +0 -0
  165. data/app/assets/images/catarse/reward_box.png +0 -0
  166. data/app/assets/images/catarse/reward_count_icon18x17.png +0 -0
  167. data/app/assets/images/catarse/reward_icon.png +0 -0
  168. data/app/assets/images/catarse/schedule_icon19x22.png +0 -0
  169. data/app/assets/images/catarse/search_submit15x15.png +0 -0
  170. data/app/assets/images/catarse/sidebar_backers_icon26x19.png +0 -0
  171. data/app/assets/images/catarse/social_big_icons.png +0 -0
  172. data/app/assets/images/catarse/social_icons.png +0 -0
  173. data/app/assets/images/catarse/submit_back_icon25x22.png +0 -0
  174. data/app/assets/images/catarse/submit_project_icon25x13.png +0 -0
  175. data/app/assets/images/catarse/team_adriano.jpg +0 -0
  176. data/app/assets/images/catarse/team_diego.jpg +0 -0
  177. data/app/assets/images/catarse/team_diogo.jpg +0 -0
  178. data/app/assets/images/catarse/team_evelise.jpg +0 -0
  179. data/app/assets/images/catarse/team_luciana.jpg +0 -0
  180. data/app/assets/images/catarse/team_luis.jpg +0 -0
  181. data/app/assets/images/catarse/team_renato.jpg +0 -0
  182. data/app/assets/images/catarse/team_rodrigo.jpg +0 -0
  183. data/app/assets/images/catarse/team_ton.jpg +0 -0
  184. data/app/assets/images/catarse/thumb_step.jpg +0 -0
  185. data/app/assets/images/catarse/thumbs_up_icon16x16.png +0 -0
  186. data/app/assets/images/catarse/tick_16.png +0 -0
  187. data/app/assets/images/catarse/time_icon19x30.png +0 -0
  188. data/app/assets/images/catarse/title_component149x40.png +0 -0
  189. data/app/assets/images/catarse/title_component241x40.png +0 -0
  190. data/app/assets/images/catarse/twitter_black_icon.png +0 -0
  191. data/app/assets/images/catarse/twitter_icon28x24.png +0 -0
  192. data/app/assets/images/catarse/video_sample_cover477x330.jpg +0 -0
  193. data/app/assets/images/catarse_bootstrap/botao_bemvindo_EN_big.png +0 -0
  194. data/app/assets/images/catarse_bootstrap/botao_bemvindo_PT_big.png +0 -0
  195. data/app/assets/images/catarse_bootstrap/catarse-assets.png +0 -0
  196. data/app/assets/images/catarse_bootstrap/feedback-close.png +0 -0
  197. data/app/assets/images/catarse_bootstrap/feedback-key.png +0 -0
  198. data/app/assets/images/catarse_bootstrap/feedback-open.png +0 -0
  199. data/app/assets/images/catarse_bootstrap/logo_icon_catarse.png +0 -0
  200. data/app/assets/images/catarse_full/.gitkeep +0 -0
  201. data/app/assets/images/channels/avatar.png +0 -0
  202. data/app/assets/images/channels/banner.png +0 -0
  203. data/app/assets/images/channels/banner_tile.jpg +0 -0
  204. data/app/assets/images/channels/capa_asas.jpg +0 -0
  205. data/app/assets/images/channels/header_system.png +0 -0
  206. data/app/assets/images/channels/logo_asas_notificacao.png +0 -0
  207. data/app/assets/images/channels/successful.png +0 -0
  208. data/app/assets/images/delete_16.png +0 -0
  209. data/app/assets/images/dropdown.png +0 -0
  210. data/app/assets/images/facebook_share.png +0 -0
  211. data/app/assets/images/favicon.ico +0 -0
  212. data/app/assets/images/gravatar.png +0 -0
  213. data/app/assets/images/icon_alertheader.png +0 -0
  214. data/app/assets/images/jquery-ui/ui-bg_diagonals-small_0_aaaaaa_40x40.png +0 -0
  215. data/app/assets/images/jquery-ui/ui-bg_diagonals-thick_15_444444_40x40.png +0 -0
  216. data/app/assets/images/jquery-ui/ui-bg_diagonals-thick_95_ffdc2e_40x40.png +0 -0
  217. data/app/assets/images/jquery-ui/ui-bg_glass_55_fbf5d0_1x400.png +0 -0
  218. data/app/assets/images/jquery-ui/ui-bg_highlight-hard_30_285c00_1x100.png +0 -0
  219. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_33_3a8104_1x100.png +0 -0
  220. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_50_4eb305_1x100.png +0 -0
  221. data/app/assets/images/jquery-ui/ui-bg_highlight-soft_60_4ca20b_1x100.png +0 -0
  222. data/app/assets/images/jquery-ui/ui-bg_inset-soft_10_285c00_1x100.png +0 -0
  223. data/app/assets/images/jquery-ui/ui-icons_4eb305_256x240.png +0 -0
  224. data/app/assets/images/jquery-ui/ui-icons_72b42d_256x240.png +0 -0
  225. data/app/assets/images/jquery-ui/ui-icons_cd0a0a_256x240.png +0 -0
  226. data/app/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  227. data/app/assets/images/list_cards.jpg +0 -0
  228. data/app/assets/images/loading.gif +0 -0
  229. data/app/assets/images/locales/en.png +0 -0
  230. data/app/assets/images/locales/es.png +0 -0
  231. data/app/assets/images/locales/list.txt +278 -0
  232. data/app/assets/images/locales/pt.png +0 -0
  233. data/app/assets/images/login_with_facebook_button310x60.png +0 -0
  234. data/app/assets/images/login_with_facebook_button356x60.png +0 -0
  235. data/app/assets/images/logo.png +0 -0
  236. data/app/assets/images/not_successful.en.png +0 -0
  237. data/app/assets/images/not_successful.es.png +0 -0
  238. data/app/assets/images/not_successful.pt.png +0 -0
  239. data/app/assets/images/pencil_16.png +0 -0
  240. data/app/assets/images/project_about.png +0 -0
  241. data/app/assets/images/project_menu_selected.png +0 -0
  242. data/app/assets/images/rewards_left_border.png +0 -0
  243. data/app/assets/images/rewards_right_border.png +0 -0
  244. data/app/assets/images/successful.en.png +0 -0
  245. data/app/assets/images/successful.es.png +0 -0
  246. data/app/assets/images/successful.pt.png +0 -0
  247. data/app/assets/images/tick_16.png +0 -0
  248. data/app/assets/images/tick_32.png +0 -0
  249. data/app/assets/images/twitter_share.png +0 -0
  250. data/app/assets/images/user.png +0 -0
  251. data/app/assets/images/waiting_confirmation.en.png +0 -0
  252. data/app/assets/images/waiting_confirmation.es.png +0 -0
  253. data/app/assets/images/waiting_confirmation.pt.png +0 -0
  254. data/app/assets/javascripts/.gitkeep +0 -0
  255. data/app/assets/javascripts/app/.gitkeep +1 -0
  256. data/app/assets/javascripts/app/adm/users.js +50 -0
  257. data/app/assets/javascripts/app/app.js +50 -0
  258. data/app/assets/javascripts/app/backer.js +60 -0
  259. data/app/assets/javascripts/app/devise/feedback_support.js +23 -0
  260. data/app/assets/javascripts/app/explore.js +65 -0
  261. data/app/assets/javascripts/app/mix_panel.js +76 -0
  262. data/app/assets/javascripts/app/payment.js +23 -0
  263. data/app/assets/javascripts/app/project.js +47 -0
  264. data/app/assets/javascripts/app/project/project_backers.js +27 -0
  265. data/app/assets/javascripts/app/project/project_comments.js +14 -0
  266. data/app/assets/javascripts/app/project/project_sidebar.js +74 -0
  267. data/app/assets/javascripts/app/project/updates.js +44 -0
  268. data/app/assets/javascripts/app/project_form.js +60 -0
  269. data/app/assets/javascripts/app/registration.js +23 -0
  270. data/app/assets/javascripts/app/review_form.js +48 -0
  271. data/app/assets/javascripts/app/user.js +21 -0
  272. data/app/assets/javascripts/app/user/user_backers.js +15 -0
  273. data/app/assets/javascripts/app/user/user_projects.js +20 -0
  274. data/app/assets/javascripts/application.js +23 -0
  275. data/app/assets/javascripts/catarse_full/.gitkeep +0 -0
  276. data/app/assets/javascripts/lib/backbone.js +1571 -0
  277. data/app/assets/javascripts/lib/bootstrap.min.js +7 -0
  278. data/app/assets/javascripts/lib/form.js +24 -0
  279. data/app/assets/javascripts/lib/infinite_scroll.js +43 -0
  280. data/app/assets/javascripts/lib/jquery-ui.js +2252 -0
  281. data/app/assets/javascripts/lib/jquery.js +8842 -0
  282. data/app/assets/javascripts/lib/jquery.maskedinput.js +338 -0
  283. data/app/assets/javascripts/lib/modal.js +43 -0
  284. data/app/assets/javascripts/lib/skull.js +78 -0
  285. data/app/assets/javascripts/lib/tabs.js +27 -0
  286. data/app/assets/javascripts/lib/timed_input.js +18 -0
  287. data/app/assets/javascripts/lib/twitter.js +1 -0
  288. data/app/assets/javascripts/lib/underscore.js +1227 -0
  289. data/app/assets/stylesheets/.gitkeep +0 -0
  290. data/app/assets/stylesheets/animate.min.css +1 -0
  291. data/app/assets/stylesheets/application.css.sass +47 -0
  292. data/app/assets/stylesheets/catarse.css.sass +26 -0
  293. data/app/assets/stylesheets/catarse.sass +26 -0
  294. data/app/assets/stylesheets/catarse_bootstrap/_alerts.sass +16 -0
  295. data/app/assets/stylesheets/catarse_bootstrap/_buttons.sass +35 -0
  296. data/app/assets/stylesheets/catarse_bootstrap/_colors.sass +39 -0
  297. data/app/assets/stylesheets/catarse_bootstrap/_dropdown.sass +29 -0
  298. data/app/assets/stylesheets/catarse_bootstrap/_elements.sass +43 -0
  299. data/app/assets/stylesheets/catarse_bootstrap/_fonts.sass +46 -0
  300. data/app/assets/stylesheets/catarse_bootstrap/_header.sass +101 -0
  301. data/app/assets/stylesheets/catarse_bootstrap/_main_sidebar.sass +91 -0
  302. data/app/assets/stylesheets/catarse_bootstrap/_notices.sass +27 -0
  303. data/app/assets/stylesheets/catarse_bootstrap/_project_box.sass +104 -0
  304. data/app/assets/stylesheets/catarse_bootstrap/_settings.sass +72 -0
  305. data/app/assets/stylesheets/catarse_bootstrap/grid/foundation.sass +667 -0
  306. data/app/assets/stylesheets/catarse_bootstrap/grid/normalize.sass +327 -0
  307. data/app/assets/stylesheets/catarse_bootstrap/pages/devise.sass +102 -0
  308. data/app/assets/stylesheets/catarse_bootstrap/pages/passwords/new.sass +3 -0
  309. data/app/assets/stylesheets/catarse_full/.gitkeep +0 -0
  310. data/app/assets/stylesheets/content/_body.sass +82 -0
  311. data/app/assets/stylesheets/content/_explore.sass +68 -0
  312. data/app/assets/stylesheets/content/_footer.sass +88 -0
  313. data/app/assets/stylesheets/content/_header.sass +102 -0
  314. data/app/assets/stylesheets/content/_recommended_header.sass +174 -0
  315. data/app/assets/stylesheets/content/_sessions.sass +111 -0
  316. data/app/assets/stylesheets/content/_sidebar.sass +179 -0
  317. data/app/assets/stylesheets/jquery-ui.css.scss +572 -0
  318. data/app/assets/stylesheets/miv/_alert.scss +57 -0
  319. data/app/assets/stylesheets/miv/_bootstrap.scss +4652 -0
  320. data/app/assets/stylesheets/miv/_buttons.sass +41 -0
  321. data/app/assets/stylesheets/miv/_colors.sass +75 -0
  322. data/app/assets/stylesheets/miv/_dropdown.sass +28 -0
  323. data/app/assets/stylesheets/miv/_embed.sass +112 -0
  324. data/app/assets/stylesheets/miv/_flash.sass +18 -0
  325. data/app/assets/stylesheets/miv/_form.scss +626 -0
  326. data/app/assets/stylesheets/miv/_index.sass +151 -0
  327. data/app/assets/stylesheets/miv/_locales.sass +34 -0
  328. data/app/assets/stylesheets/miv/_modal.sass +38 -0
  329. data/app/assets/stylesheets/miv/_overlay.sass +10 -0
  330. data/app/assets/stylesheets/miv/_projects.sass +159 -0
  331. data/app/assets/stylesheets/miv/_projects_land.sass +177 -0
  332. data/app/assets/stylesheets/miv/_table.scss +134 -0
  333. data/app/assets/stylesheets/miv/_tabs.sass +31 -0
  334. data/app/assets/stylesheets/resources/adm/adm.sass +109 -0
  335. data/app/assets/stylesheets/resources/backers/_create.sass +432 -0
  336. data/app/assets/stylesheets/resources/backers/_new.sass +237 -0
  337. data/app/assets/stylesheets/resources/backers/_thank_you.sass +83 -0
  338. data/app/assets/stylesheets/resources/channels/_about.sass +67 -0
  339. data/app/assets/stylesheets/resources/channels/_general.sass +60 -0
  340. data/app/assets/stylesheets/resources/channels/_icomoon.sass +47 -0
  341. data/app/assets/stylesheets/resources/channels/_profile.sass +120 -0
  342. data/app/assets/stylesheets/resources/projects/_index.sass +43 -0
  343. data/app/assets/stylesheets/resources/projects/_new.sass +117 -0
  344. data/app/assets/stylesheets/resources/projects/_pending_backers.sass +80 -0
  345. data/app/assets/stylesheets/resources/projects/_rewards.sass +22 -0
  346. data/app/assets/stylesheets/resources/projects/_show.sass +749 -0
  347. data/app/assets/stylesheets/resources/projects/_start.sass +191 -0
  348. data/app/assets/stylesheets/resources/static/_about.sass +125 -0
  349. data/app/assets/stylesheets/resources/static/_default.sass +576 -0
  350. data/app/assets/stylesheets/resources/users/_show.sass +284 -0
  351. data/app/controllers/.gitkeep +0 -0
  352. data/app/controllers/adm/backers_controller.rb +40 -0
  353. data/app/controllers/adm/base_controller.rb +37 -0
  354. data/app/controllers/adm/financials_controller.rb +49 -0
  355. data/app/controllers/adm/projects_controller.rb +32 -0
  356. data/app/controllers/adm/reports/backer_reports_controller.rb +6 -0
  357. data/app/controllers/adm/reports/base_controller.rb +6 -0
  358. data/app/controllers/adm/statistics_controller.rb +6 -0
  359. data/app/controllers/adm/users_controller.rb +26 -0
  360. data/app/controllers/application_controller.rb +118 -0
  361. data/app/controllers/channels/adm/projects_controller.rb +36 -0
  362. data/app/controllers/channels/adm/reports/subscriber_reports_controller.rb +7 -0
  363. data/app/controllers/channels/adm/statistics_controller.rb +13 -0
  364. data/app/controllers/channels/base_controller.rb +6 -0
  365. data/app/controllers/channels/channels_subscribers_controller.rb +35 -0
  366. data/app/controllers/channels/profiles_controller.rb +11 -0
  367. data/app/controllers/channels/projects_controller.rb +22 -0
  368. data/app/controllers/explore_controller.rb +6 -0
  369. data/app/controllers/omniauth_callbacks_controller.rb +28 -0
  370. data/app/controllers/passwords_controller.rb +21 -0
  371. data/app/controllers/projects/backers_controller.rb +85 -0
  372. data/app/controllers/projects/updates_controller.rb +28 -0
  373. data/app/controllers/projects_controller.rb +84 -0
  374. data/app/controllers/reports/backer_reports_for_project_owners_controller.rb +36 -0
  375. data/app/controllers/reports/base_controller.rb +6 -0
  376. data/app/controllers/rewards_controller.rb +36 -0
  377. data/app/controllers/static_controller.rb +28 -0
  378. data/app/controllers/unsubscribes_controller.rb +18 -0
  379. data/app/controllers/users/backers_controller.rb +29 -0
  380. data/app/controllers/users/projects_controller.rb +13 -0
  381. data/app/controllers/users_controller.rb +63 -0
  382. data/app/decorators/channel_decorator.rb +7 -0
  383. data/app/decorators/project_decorator.rb +69 -0
  384. data/app/decorators/user_decorator.rb +34 -0
  385. data/app/helpers/.gitkeep +0 -0
  386. data/app/helpers/channels/base_helper.rb +2 -0
  387. data/app/mailers/.gitkeep +0 -0
  388. data/app/mailers/credits_mailer.rb +9 -0
  389. data/app/mailers/notifications_mailer.rb +21 -0
  390. data/app/models/.gitkeep +0 -0
  391. data/app/models/ability.rb +129 -0
  392. data/app/models/authorization.rb +4 -0
  393. data/app/models/backer.rb +242 -0
  394. data/app/models/backer_report.rb +3 -0
  395. data/app/models/backer_reports_for_project_owner.rb +2 -0
  396. data/app/models/backers_by_period.rb +9 -0
  397. data/app/models/category.rb +17 -0
  398. data/app/models/channel.rb +22 -0
  399. data/app/models/channels_subscriber.rb +5 -0
  400. data/app/models/configuration.rb +36 -0
  401. data/app/models/notification.rb +35 -0
  402. data/app/models/notification_type.rb +4 -0
  403. data/app/models/oauth_provider.rb +6 -0
  404. data/app/models/payment_notification.rb +4 -0
  405. data/app/models/project.rb +335 -0
  406. data/app/models/project_total.rb +2 -0
  407. data/app/models/projects_by_period.rb +9 -0
  408. data/app/models/projects_for_home.rb +11 -0
  409. data/app/models/reward.rb +70 -0
  410. data/app/models/state.rb +13 -0
  411. data/app/models/statistics.rb +2 -0
  412. data/app/models/subscriber_report.rb +3 -0
  413. data/app/models/unsubscribe.rb +10 -0
  414. data/app/models/update.rb +57 -0
  415. data/app/models/user.rb +250 -0
  416. data/app/models/user_total.rb +3 -0
  417. data/app/observers/backer_observer.rb +61 -0
  418. data/app/observers/notification_observer.rb +7 -0
  419. data/app/observers/payment_notification_observer.rb +16 -0
  420. data/app/observers/project_observer.rb +113 -0
  421. data/app/observers/update_observer.rb +7 -0
  422. data/app/observers/user_observer.rb +16 -0
  423. data/app/uploaders/image_uploader.rb +24 -0
  424. data/app/uploaders/project_uploader.rb +29 -0
  425. data/app/uploaders/user_uploader.rb +12 -0
  426. data/app/views/.gitkeep +0 -0
  427. data/app/views/adm/backers/index.html.slim +170 -0
  428. data/app/views/adm/financials/index.html.slim +99 -0
  429. data/app/views/adm/projects/index.html.slim +128 -0
  430. data/app/views/adm/statistics/index.html.slim +40 -0
  431. data/app/views/adm/users/index.html.slim +74 -0
  432. data/app/views/catarse_bootstrap/devise/mailer/reset_password_instructions.en.html.slim +15 -0
  433. data/app/views/catarse_bootstrap/devise/mailer/reset_password_instructions.pt.html.slim +16 -0
  434. data/app/views/catarse_bootstrap/devise/mailer/unlock_instructions.html.erb +7 -0
  435. data/app/views/catarse_bootstrap/devise/passwords/edit.html.slim +26 -0
  436. data/app/views/catarse_bootstrap/devise/passwords/new.html.slim +21 -0
  437. data/app/views/catarse_bootstrap/devise/registrations/new.html.slim +48 -0
  438. data/app/views/catarse_bootstrap/devise/sessions/new.html.slim +40 -0
  439. data/app/views/catarse_bootstrap/devise/shared/_alert.html.slim +11 -0
  440. data/app/views/catarse_bootstrap/devise/shared/_header.html.slim +5 -0
  441. data/app/views/catarse_bootstrap/layouts/_login_feedback_support.html.slim +16 -0
  442. data/app/views/catarse_bootstrap/layouts/_mailer_styles.html.erb +22 -0
  443. data/app/views/catarse_bootstrap/layouts/_uservoice.html.slim +2 -0
  444. data/app/views/catarse_bootstrap/layouts/catarse_bootstrap.html.slim +21 -0
  445. data/app/views/catarse_bootstrap/layouts/email.html.slim +39 -0
  446. data/app/views/catarse_bootstrap/notifications_mailer/new_user_registration.en.html.slim +44 -0
  447. data/app/views/catarse_bootstrap/notifications_mailer/new_user_registration.pt.html.slim +45 -0
  448. data/app/views/catarse_bootstrap/notifications_mailer/updates.en.html.slim +4 -0
  449. data/app/views/catarse_bootstrap/notifications_mailer/updates.pt.html.slim +4 -0
  450. data/app/views/channels/adm/projects/index.html.slim +121 -0
  451. data/app/views/channels/adm/statistics/index.html.slim +21 -0
  452. data/app/views/channels/base/index.html.slim +2 -0
  453. data/app/views/channels/profiles/_footer.html.slim +13 -0
  454. data/app/views/channels/profiles/how_it_works.html.slim +67 -0
  455. data/app/views/channels/profiles/show.html.slim +47 -0
  456. data/app/views/channels/projects/_banner.html.slim +8 -0
  457. data/app/views/channels/projects/_project.html.slim +12 -0
  458. data/app/views/channels/projects/new.html.slim +128 -0
  459. data/app/views/credits_mailer/request_refund_from.text.erb +11 -0
  460. data/app/views/custom/.gitkeep +0 -0
  461. data/app/views/explore/index.html.slim +47 -0
  462. data/app/views/layouts/_analytics.html.slim +9 -0
  463. data/app/views/layouts/_announcement.html.slim +4 -0
  464. data/app/views/layouts/_catarse_bootstrap_notices.html.slim +4 -0
  465. data/app/views/layouts/_classic_uservoice.html.slim +31 -0
  466. data/app/views/layouts/_facebook_like.html.slim +2 -0
  467. data/app/views/layouts/_facebook_sdk.html.slim +20 -0
  468. data/app/views/layouts/_flash.html.slim +6 -0
  469. data/app/views/layouts/_header.html.slim +49 -0
  470. data/app/views/layouts/_locales.html.slim +7 -0
  471. data/app/views/layouts/_new_uservoice.html.slim +20 -0
  472. data/app/views/layouts/_twitter.html.erb +1 -0
  473. data/app/views/layouts/application.html.slim +71 -0
  474. data/app/views/layouts/channel_email.html.slim +23 -0
  475. data/app/views/layouts/email.html.slim +26 -0
  476. data/app/views/layouts/embed.html.slim +13 -0
  477. data/app/views/notifications_mailer/adm_project_deadline.en.html.slim +3 -0
  478. data/app/views/notifications_mailer/adm_project_deadline.pt.html.slim +3 -0
  479. data/app/views/notifications_mailer/backer_canceled_after_confirmed.html.slim +12 -0
  480. data/app/views/notifications_mailer/backer_confirmed_after_project_was_closed.en.html.slim +8 -0
  481. data/app/views/notifications_mailer/backer_confirmed_after_project_was_closed.pt.html.slim +8 -0
  482. data/app/views/notifications_mailer/backer_project_successful.en.html.slim +48 -0
  483. data/app/views/notifications_mailer/backer_project_successful.pt.html.slim +50 -0
  484. data/app/views/notifications_mailer/backer_project_unsuccessful.en.html.slim +39 -0
  485. data/app/views/notifications_mailer/backer_project_unsuccessful.pt.html.slim +41 -0
  486. data/app/views/notifications_mailer/confirm_backer.en.html.slim +43 -0
  487. data/app/views/notifications_mailer/confirm_backer.pt.html.slim +45 -0
  488. data/app/views/notifications_mailer/credits_warning.en.html.slim +41 -0
  489. data/app/views/notifications_mailer/credits_warning.pt.html.slim +40 -0
  490. data/app/views/notifications_mailer/new_draft_project.en.html.slim +34 -0
  491. data/app/views/notifications_mailer/new_draft_project.pt.html.slim +34 -0
  492. data/app/views/notifications_mailer/new_draft_project_channel.en.html.slim +34 -0
  493. data/app/views/notifications_mailer/new_draft_project_channel.pt.html.slim +34 -0
  494. data/app/views/notifications_mailer/new_features.en.html.slim +30 -0
  495. data/app/views/notifications_mailer/new_features.pt.html.slim +30 -0
  496. data/app/views/notifications_mailer/payment_slip.en.html.slim +19 -0
  497. data/app/views/notifications_mailer/payment_slip.pt.html.slim +24 -0
  498. data/app/views/notifications_mailer/pending_backer_project_unsuccessful.en.html.slim +44 -0
  499. data/app/views/notifications_mailer/pending_backer_project_unsuccessful.pt.html.slim +44 -0
  500. data/app/views/notifications_mailer/processing_payment.en.html.slim +24 -0
  501. data/app/views/notifications_mailer/processing_payment.pt.html.slim +29 -0
  502. data/app/views/notifications_mailer/project_in_wainting_funds.en.html.slim +35 -0
  503. data/app/views/notifications_mailer/project_in_wainting_funds.pt.html.slim +35 -0
  504. data/app/views/notifications_mailer/project_owner_backer_confirmed.en.html.slim +33 -0
  505. data/app/views/notifications_mailer/project_owner_backer_confirmed.pt.html.slim +34 -0
  506. data/app/views/notifications_mailer/project_received.en.html.slim +38 -0
  507. data/app/views/notifications_mailer/project_received.pt.html.slim +50 -0
  508. data/app/views/notifications_mailer/project_received_channel.en.html.slim +52 -0
  509. data/app/views/notifications_mailer/project_received_channel.pt.html.slim +52 -0
  510. data/app/views/notifications_mailer/project_rejected.en.html.slim +33 -0
  511. data/app/views/notifications_mailer/project_rejected.pt.html.slim +33 -0
  512. data/app/views/notifications_mailer/project_success.en.html.slim +30 -0
  513. data/app/views/notifications_mailer/project_success.pt.html.slim +30 -0
  514. data/app/views/notifications_mailer/project_unsuccessful.en.html.slim +42 -0
  515. data/app/views/notifications_mailer/project_unsuccessful.pt.html.slim +42 -0
  516. data/app/views/notifications_mailer/project_visible.en.html.slim +65 -0
  517. data/app/views/notifications_mailer/project_visible.pt.html.slim +65 -0
  518. data/app/views/projects/_admin_fields.html.slim +15 -0
  519. data/app/views/projects/_draft_warning.html.slim +23 -0
  520. data/app/views/projects/_failed_warning.html.slim +21 -0
  521. data/app/views/projects/_formatting_tips.en.html.slim +19 -0
  522. data/app/views/projects/_formatting_tips.pt.html.slim +20 -0
  523. data/app/views/projects/_online_warning.html.slim +33 -0
  524. data/app/views/projects/_project.html.slim +23 -0
  525. data/app/views/projects/_project_about.html.slim +20 -0
  526. data/app/views/projects/_project_edit.html.slim +32 -0
  527. data/app/views/projects/_project_header.html.slim +34 -0
  528. data/app/views/projects/_project_reports.html.slim +22 -0
  529. data/app/views/projects/_project_templates.html.slim +3 -0
  530. data/app/views/projects/_recommended_header.html.slim +19 -0
  531. data/app/views/projects/_rejected_warning.html.slim +10 -0
  532. data/app/views/projects/_successful_warning.html.slim +29 -0
  533. data/app/views/projects/_twitter_timeline.html.slim +2 -0
  534. data/app/views/projects/_waiting_funds_warning.html.slim +34 -0
  535. data/app/views/projects/backers/_anonymous_warning.en.html.slim +5 -0
  536. data/app/views/projects/backers/_anonymous_warning.pt.html.slim +5 -0
  537. data/app/views/projects/backers/_back_text.en.html.slim +11 -0
  538. data/app/views/projects/backers/_back_text.pt.html.slim +11 -0
  539. data/app/views/projects/backers/_backer.html.slim +42 -0
  540. data/app/views/projects/backers/create.html.slim +75 -0
  541. data/app/views/projects/backers/new.html.slim +40 -0
  542. data/app/views/projects/backers/show.html.slim +26 -0
  543. data/app/views/projects/embed.html.slim +2 -0
  544. data/app/views/projects/embed_panel.html.slim +11 -0
  545. data/app/views/projects/index.html.slim +70 -0
  546. data/app/views/projects/new.html.slim +134 -0
  547. data/app/views/projects/show.html.slim +169 -0
  548. data/app/views/projects/start.html.slim +121 -0
  549. data/app/views/projects/updates/_update.html.slim +17 -0
  550. data/app/views/projects/updates/new.html.slim +22 -0
  551. data/app/views/projects/video_embed.html.slim +8 -0
  552. data/app/views/projects_mailer/start_project_email.html.slim +29 -0
  553. data/app/views/rewards/_form.html.slim +19 -0
  554. data/app/views/rewards/edit.html.slim +1 -0
  555. data/app/views/rewards/index.html.slim +55 -0
  556. data/app/views/rewards/new.html.slim +1 -0
  557. data/app/views/static/_guidelines_text.pt.html.slim +17 -0
  558. data/app/views/static/_how_it_works.en.html.slim +11 -0
  559. data/app/views/static/_how_it_works.pt.html.slim +11 -0
  560. data/app/views/static/_more_tips.pt.html.slim +20 -0
  561. data/app/views/static/about.html.slim +79 -0
  562. data/app/views/static/guidelines.html.slim +22 -0
  563. data/app/views/static/guidelines_backers.html.slim +94 -0
  564. data/app/views/static/guidelines_start.html.slim +90 -0
  565. data/app/views/static/guidelines_tips.html.slim +68 -0
  566. data/app/views/static/sitemap.builder +61 -0
  567. data/app/views/users/_credits.html.slim +44 -0
  568. data/app/views/users/_current_user_fields.html.slim +76 -0
  569. data/app/views/users/_project.html.slim +60 -0
  570. data/app/views/users/_unsubscribes.html.slim +23 -0
  571. data/app/views/users/backers/index.html.slim +2 -0
  572. data/app/views/users/projects/index.html.slim +3 -0
  573. data/app/views/users/set_email.html.slim +16 -0
  574. data/app/views/users/show.html.slim +72 -0
  575. data/app/views/users/uservoice_gadget.html.slim +45 -0
  576. data/app/workers/notify_update_worker.rb +9 -0
  577. data/config/boot.rb +13 -0
  578. data/config/compass.rb +5 -0
  579. data/config/environment.rb +5 -0
  580. data/config/environments/development.rb +46 -0
  581. data/config/environments/production.rb +70 -0
  582. data/config/environments/test.rb +44 -0
  583. data/config/initializers/backtrace_silencers.rb +7 -0
  584. data/config/initializers/capybara.rb +5 -0
  585. data/config/initializers/carrierwave.rb +13 -0
  586. data/config/initializers/default_url_options.rb +6 -0
  587. data/config/initializers/devise.rb +252 -0
  588. data/config/initializers/formtastic.rb +9 -0
  589. data/config/initializers/google_analytics.rb +3 -0
  590. data/config/initializers/http_accept_language.rb +7 -0
  591. data/config/initializers/inflections.rb +13 -0
  592. data/config/initializers/locale.rb +9 -0
  593. data/config/initializers/mailchimp.rb +1 -0
  594. data/config/initializers/mime_types.rb +5 -0
  595. data/config/initializers/pluralize.rb +5 -0
  596. data/config/initializers/schema_associations.rb +3 -0
  597. data/config/initializers/secret_token.rb +16 -0
  598. data/config/initializers/sendgrid.rb +15 -0
  599. data/config/initializers/session_store.rb +15 -0
  600. data/config/initializers/statistics_loader_development.rb +4 -0
  601. data/config/initializers/timeout.rb +1 -0
  602. data/config/initializers/wrap_parameters.rb +14 -0
  603. data/config/locales/.wti.sample +14 -0
  604. data/config/locales/adm.en.yml +107 -0
  605. data/config/locales/adm.pt.yml +150 -0
  606. data/config/locales/catarse_bootstrap/models/user.en.yml +13 -0
  607. data/config/locales/catarse_bootstrap/models/user.pt.yml +13 -0
  608. data/config/locales/catarse_bootstrap/pages/forgot_password.en.yml +14 -0
  609. data/config/locales/catarse_bootstrap/pages/forgot_password.pt.yml +14 -0
  610. data/config/locales/catarse_bootstrap/pages/login.en.yml +16 -0
  611. data/config/locales/catarse_bootstrap/pages/login.pt.yml +16 -0
  612. data/config/locales/catarse_bootstrap/pages/reset_password.en.yml +14 -0
  613. data/config/locales/catarse_bootstrap/pages/reset_password.pt.yml +14 -0
  614. data/config/locales/catarse_bootstrap/pages/sign_up.en.yml +18 -0
  615. data/config/locales/catarse_bootstrap/pages/sign_up.pt.yml +17 -0
  616. data/config/locales/channels.pt.yml +100 -0
  617. data/config/locales/devise.en.yml +99 -0
  618. data/config/locales/devise.pt.yml +98 -0
  619. data/config/locales/en.yml +872 -0
  620. data/config/locales/notifications.en.yml +74 -0
  621. data/config/locales/notifications.pt.yml +74 -0
  622. data/config/locales/pt.yml +896 -0
  623. data/config/locales/rails.en.yml +209 -0
  624. data/config/locales/rails.pt.yml +211 -0
  625. data/config/locales/will_paginate.en.yml +5 -0
  626. data/config/locales/will_paginate.pt.yml +5 -0
  627. data/config/newrelic.yml +227 -0
  628. data/config/routes.rb +150 -0
  629. data/config/sidekiq.yml +1 -0
  630. data/config/unicorn.rb +38 -0
  631. data/db/migrate/20121226120921_initial_schema.rb +1836 -0
  632. data/db/migrate/20121227012003_user_totals_back_to_state_machine.rb +53 -0
  633. data/db/migrate/20121227012324_statistics_back_to_state_machine.rb +47 -0
  634. data/db/migrate/20121230111351_add_online_date_to_projects.rb +5 -0
  635. data/db/migrate/20130102180139_update_projects_to_state_machine_again.rb +25 -0
  636. data/db/migrate/20130104005632_add_moip_login_to_users.rb +5 -0
  637. data/db/migrate/20130104104501_add_how_know_and_more_links_to_projects.rb +6 -0
  638. data/db/migrate/20130105123546_add_first_backers_to_projects.rb +5 -0
  639. data/db/migrate/20130110191750_add_uploaded_image_to_projects.rb +5 -0
  640. data/db/migrate/20130117205659_alter_projects_drop_video_url_constraint.rb +15 -0
  641. data/db/migrate/20130118193907_fix_statistics_view.rb +45 -0
  642. data/db/migrate/20130121162447_create_backer_reports.rb +41 -0
  643. data/db/migrate/20130121204224_fix_projects_states.rb +11 -0
  644. data/db/migrate/20130121212325_fix_statistcs_again.rb +45 -0
  645. data/db/migrate/20130131121553_add_cpf_to_backer_report.rb +75 -0
  646. data/db/migrate/20130201200604_remove_curated_pages.rb +9 -0
  647. data/db/migrate/20130201202648_remove_projects_managers.rb +9 -0
  648. data/db/migrate/20130201202829_remove_active_admin_comments.rb +9 -0
  649. data/db/migrate/20130201205659_remove_institutional_videos.rb +9 -0
  650. data/db/migrate/20130204192704_create_backer_reports_for_project_owner.rb +33 -0
  651. data/db/migrate/20130205143533_remove_credits_from_users.rb +9 -0
  652. data/db/migrate/20130206121758_fix_view_backer_reports_for_project_owner.rb +34 -0
  653. data/db/migrate/20130211174609_add_name_en_to_categories.rb +5 -0
  654. data/db/migrate/20130212145115_rename_name_to_name_pt.rb +5 -0
  655. data/db/migrate/20130213184141_change_permalink_to_not_null.rb +17 -0
  656. data/db/migrate/20130218201312_create_users_oauth_providers.rb +10 -0
  657. data/db/migrate/20130218201751_migrate_user_data_to_users_oath_providers.rb +12 -0
  658. data/db/migrate/20130221171018_rename_users_oath_providers.rb +21 -0
  659. data/db/migrate/20130221172840_populate_authorizations.rb +12 -0
  660. data/db/migrate/20130221175717_remove_static_contents.rb +13 -0
  661. data/db/migrate/20130221184144_update_oauth_provider_name_to_lower.rb +8 -0
  662. data/db/migrate/20130221185532_recreate_statistics_with_new_users.rb +62 -0
  663. data/db/migrate/20130221201732_remove_secondary_users.rb +82 -0
  664. data/db/migrate/20130222163633_add_state_inscription_to_user.rb +5 -0
  665. data/db/migrate/20130225135512_update_user_emails_from_backers.rb +15 -0
  666. data/db/migrate/20130225141802_alter_user_drop_provider_uid_constraints.rb +15 -0
  667. data/db/migrate/20130228141234_add_unique_index_to_configuration.rb +5 -0
  668. data/db/migrate/20130304193806_create_channel_profiles.rb +12 -0
  669. data/db/migrate/20130307074614_create_versions.rb +24 -0
  670. data/db/migrate/20130307090153_add_reindex_versions_to_rewards.rb +5 -0
  671. data/db/migrate/20130308200907_add_user_name_on_backer_report_for_project_owner.rb +62 -0
  672. data/db/migrate/20130311191444_drop_uid_and_provider_constraint_on_users.rb +13 -0
  673. data/db/migrate/20130311192846_remove_unnecessary_user_indexes.rb +14 -0
  674. data/db/migrate/20130312001021_fix_duplicate_emails.rb +26 -0
  675. data/db/migrate/20130313032607_rename_channels_profiles_to_channels.rb +9 -0
  676. data/db/migrate/20130313034356_create_channels_projects.rb +8 -0
  677. data/db/migrate/20130319131919_create_channels_trustees.rb +12 -0
  678. data/db/migrate/20130410181958_add_twitter_and_facebook_and_email_to_channels.rb +7 -0
  679. data/db/migrate/20130410190247_add_image_to_channels.rb +5 -0
  680. data/db/migrate/20130410191240_add_website_to_channels.rb +5 -0
  681. data/db/migrate/20130411193016_create_channels_subscribers.rb +13 -0
  682. data/db/migrate/20130419184530_add_state_to_backers.rb +5 -0
  683. data/db/migrate/20130422071805_add_notification_type_draft_channel.rb +13 -0
  684. data/db/migrate/20130422072051_add_notification_type_project_received_channel.rb +13 -0
  685. data/db/migrate/20130423162359_update_user_total_to_backer_state_machine.rb +59 -0
  686. data/db/migrate/20130424173128_add_backer_state_machine_into_statistics.rb +61 -0
  687. data/db/migrate/20130426204503_add_row_order_to_rewards.rb +7 -0
  688. data/db/migrate/20130429142823_rename_categories.rb +12 -0
  689. data/db/migrate/20130429144749_add_new_categories.rb +27 -0
  690. data/db/migrate/20130429153115_move_projects_to_art_and_remove_old_categories.rb +15 -0
  691. data/db/migrate/20130430203333_add_layout_to_notification_type.rb +5 -0
  692. data/db/migrate/20130502175814_add_anonymous_to_reports_to_project_owner.rb +37 -0
  693. data/db/migrate/20130505013655_update_backers_state_machine.rb +35 -0
  694. data/db/migrate/20130506191243_update_backer_reports_to_project_owner_view_to_backer_state_machine.rb +65 -0
  695. data/db/migrate/20130506191508_update_backer_reports_to_backer_state_machine.rb +74 -0
  696. data/db/migrate/20130514132519_add_waiting_confirmation_on_statistics_view.rb +63 -0
  697. data/db/migrate/20130514185010_drop_views.rb +35 -0
  698. data/db/migrate/20130514185116_fix_project_owner_view.rb +66 -0
  699. data/db/migrate/20130514185926_remove_boolean_fields_from_projects.rb +18 -0
  700. data/db/migrate/20130515192404_remove_boolean_fields_from_backers.rb +14 -0
  701. data/db/migrate/20130523144013_fix_project_total_to_use_refunded_and_requested_refund_too.rb +15 -0
  702. data/db/migrate/20130523173609_fix_project_total_again_some_regex_error.rb +15 -0
  703. data/db/migrate/20130527204639_add_video_embed_url_to_projects.rb +5 -0
  704. data/db/migrate/20130529171845_update_backers_that_are_in_refunded_when_project_is_online.rb +17 -0
  705. data/db/migrate/20130604171730_add_index_to_payment_notification_on_backer_id.rb +5 -0
  706. data/db/migrate/20130604172253_update_online_date_for_legacy_projects.rb +10 -0
  707. data/db/migrate/20130604175953_remove_expires_at_from_views.rb +11 -0
  708. data/db/migrate/20130604180503_remove_expires_at_from_projects.rb +11 -0
  709. data/db/migrate/20130607222330_remove_image_url_from_projects.rb +9 -0
  710. data/db/migrate/20130617175402_create_projects_chart_view.rb +51 -0
  711. data/db/migrate/20130618175432_create_backers_by_period_view.rb +57 -0
  712. data/db/migrate/20130626122439_add_expires_at_function.rb +12 -0
  713. data/db/migrate/20130626124055_drop_payment_logs.rb +8 -0
  714. data/db/migrate/20130702192659_update_backers_by_period_view_with_deleted_backer_state.rb +107 -0
  715. data/db/migrate/20130703171547_add_exclusive_to_updates.rb +5 -0
  716. data/db/migrate/20130705131825_replace_expires_at_to_include_timezone.rb +18 -0
  717. data/db/migrate/20130705184845_alter_statistics_view_add_deleted_backer_state.rb +61 -0
  718. data/db/migrate/20130710122804_add_days_to_delivery_into_rewards.rb +5 -0
  719. data/db/migrate/20130722222945_remove_legacy_columns_from_users.rb +10 -0
  720. data/db/migrate/20130730232043_add_total_payments_service_fee_into_project_totals.rb +27 -0
  721. data/db/migrate/20130805230126_add_total_backed_projects_to_user_total.rb +60 -0
  722. data/db/migrate/20130812191450_show_refunded_on_backers_report.rb +74 -0
  723. data/db/migrate/20130814174329_alter_timestamp_to_include_timezone.rb +17 -0
  724. data/db/migrate/20130815161926_create_recommendations_view.rb +64 -0
  725. data/db/migrate/20130818015857_add_projects_home_view.rb +37 -0
  726. data/db/migrate/20130822215532_fix_credits_into_user_totals_view.rb +67 -0
  727. data/db/migrate/20130827210414_revert_expires_at.rb +12 -0
  728. data/db/migrate/20130828160026_use_expires_at_in_view.rb +11 -0
  729. data/db/migrate/20130829180232_use_timezone_instead_of_hardcoded_3.rb +12 -0
  730. data/db/migrate/20130905153553_add_sessions_table.rb +12 -0
  731. data/db/migrate/20130911180657_create_subscriber_reports.rb +8 -0
  732. data/db/seeds.rb +122 -0
  733. data/db/seeds/add-users.rb +40 -0
  734. data/db/seeds/my-seeds-local.example.rb +85 -0
  735. data/lib/blog.rb +14 -0
  736. data/lib/calendar.rb +19 -0
  737. data/lib/catarse_auto_html.rb +23 -0
  738. data/lib/catarse_full.rb +4 -0
  739. data/lib/catarse_full/engine.rb +77 -0
  740. data/lib/catarse_full/version.rb +3 -0
  741. data/lib/payment_engines.rb +26 -0
  742. data/lib/tasks/.gitkeep +0 -0
  743. data/lib/tasks/catarse_full_tasks.rake +4 -0
  744. data/lib/tasks/config.rake +56 -0
  745. data/lib/tasks/cron.rake +76 -0
  746. data/lib/tasks/db_seed.rake +15 -0
  747. data/lib/tasks/jasmine.rake +8 -0
  748. data/lib/tasks/send_old_posts_to_tumblr.rake +14 -0
  749. data/lib/tasks/users.rake +82 -0
  750. data/lib/uservoice_sso.rb +20 -0
  751. data/spec/abilities/trustee_ability_spec.rb +53 -0
  752. data/spec/config/initializers/secret_token_spec.rb +19 -0
  753. data/spec/controllers/adm/backers_controller_spec.rb +119 -0
  754. data/spec/controllers/adm/statistics_controller.rb +17 -0
  755. data/spec/controllers/adm/users_controller_spec.rb +29 -0
  756. data/spec/controllers/channels/adm/reports/subscriber_reports_controller_spec.rb +24 -0
  757. data/spec/controllers/channels/base_controller_spec.rb +5 -0
  758. data/spec/controllers/channels/channels_subscribers_controller_spec.rb +59 -0
  759. data/spec/controllers/channels/profiles_controller_spec.rb +16 -0
  760. data/spec/controllers/omniauth_callbacks_controller_spec.rb +113 -0
  761. data/spec/controllers/projects/backers_controller_spec.rb +198 -0
  762. data/spec/controllers/projects/updates_controller_spec.rb +57 -0
  763. data/spec/controllers/projects_controller_spec.rb +178 -0
  764. data/spec/controllers/rewards_controller_spec.rb +107 -0
  765. data/spec/controllers/static_controller_spec.rb +37 -0
  766. data/spec/controllers/unsubscribes_controller_spec.rb +31 -0
  767. data/spec/controllers/users/backers_controller_spec.rb +86 -0
  768. data/spec/controllers/users/projects_controller_spec.rb +19 -0
  769. data/spec/controllers/users_controller_spec.rb +92 -0
  770. data/spec/decorators/project_decorator_spec.rb +146 -0
  771. data/spec/decorators/user_decorator_spec.rb +87 -0
  772. data/spec/dummy/README.rdoc +261 -0
  773. data/spec/dummy/Rakefile +7 -0
  774. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  775. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  776. data/spec/dummy/app/mailers/.gitkeep +0 -0
  777. data/spec/dummy/app/models/.gitkeep +0 -0
  778. data/spec/dummy/config.ru +4 -0
  779. data/spec/dummy/config/application.rb +69 -0
  780. data/spec/dummy/config/boot.rb +10 -0
  781. data/spec/dummy/config/database.sample.yml +50 -0
  782. data/spec/dummy/config/environment.rb +5 -0
  783. data/spec/dummy/config/environments/development.rb +37 -0
  784. data/spec/dummy/config/environments/production.rb +67 -0
  785. data/spec/dummy/config/environments/test.rb +37 -0
  786. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  787. data/spec/dummy/config/initializers/devise_secret_key.rb +3 -0
  788. data/spec/dummy/config/initializers/inflections.rb +15 -0
  789. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  790. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  791. data/spec/dummy/config/initializers/session_store.rb +8 -0
  792. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  793. data/spec/dummy/config/locales/en.yml +5 -0
  794. data/spec/dummy/config/routes.rb +58 -0
  795. data/spec/dummy/db/structure.sql +2434 -0
  796. data/spec/dummy/lib/assets/.gitkeep +0 -0
  797. data/spec/dummy/log/.gitkeep +0 -0
  798. data/spec/dummy/public/404.html +26 -0
  799. data/spec/dummy/public/422.html +26 -0
  800. data/spec/dummy/public/500.html +25 -0
  801. data/spec/dummy/public/favicon.ico +0 -0
  802. data/spec/dummy/script/rails +6 -0
  803. data/spec/factories.rb +125 -0
  804. data/spec/factories/users_oauth_providers.rb +9 -0
  805. data/spec/features/channel_moderation_spec.rb +27 -0
  806. data/spec/features/projects_spec.rb +95 -0
  807. data/spec/features/users_spec.rb +43 -0
  808. data/spec/fixtures/image.png +0 -0
  809. data/spec/helpers/channels/base_helper_spec.rb +15 -0
  810. data/spec/javascripts/app_spec.js +85 -0
  811. data/spec/javascripts/backer_spec.js +74 -0
  812. data/spec/javascripts/explore_spec.js +211 -0
  813. data/spec/javascripts/feedback_support_spec.js +41 -0
  814. data/spec/javascripts/helpers/.gitkeep +0 -0
  815. data/spec/javascripts/mix_panel_spec.js +101 -0
  816. data/spec/javascripts/permalink_spec.js +50 -0
  817. data/spec/javascripts/project_comments_spec.js +66 -0
  818. data/spec/javascripts/project_sidebar_spec.js +105 -0
  819. data/spec/javascripts/project_spec.js +175 -0
  820. data/spec/javascripts/registration_spec.js +38 -0
  821. data/spec/javascripts/review_form_spec.js +140 -0
  822. data/spec/javascripts/skull_spec.js +103 -0
  823. data/spec/javascripts/support/jasmine.yml +93 -0
  824. data/spec/javascripts/timed_input_spec.js +64 -0
  825. data/spec/javascripts/updates_spec.js +49 -0
  826. data/spec/javascripts/video_url_spec.js +42 -0
  827. data/spec/lib/blog_spec.rb +12 -0
  828. data/spec/lib/payment_engines_spec.rb +61 -0
  829. data/spec/mailers/notifications_mailer_spec.rb +20 -0
  830. data/spec/models/ability_spec.rb +123 -0
  831. data/spec/models/authorizations_spec.rb +6 -0
  832. data/spec/models/backer_report_spec.rb +5 -0
  833. data/spec/models/backer_spec.rb +459 -0
  834. data/spec/models/category_spec.rb +13 -0
  835. data/spec/models/channel_spec.rb +47 -0
  836. data/spec/models/channels_subscriber_spec.rb +13 -0
  837. data/spec/models/configuration_spec.rb +31 -0
  838. data/spec/models/notification_spec.rb +105 -0
  839. data/spec/models/oauth_provider_spec.rb +7 -0
  840. data/spec/models/payment_notification_spec.rb +17 -0
  841. data/spec/models/project_spec.rb +771 -0
  842. data/spec/models/project_total_spec.rb +26 -0
  843. data/spec/models/projects_for_home_spec.rb +44 -0
  844. data/spec/models/reward_spec.rb +141 -0
  845. data/spec/models/statistics_spec.rb +46 -0
  846. data/spec/models/subscriber_report_spec.rb +42 -0
  847. data/spec/models/unsubscribe_spec.rb +27 -0
  848. data/spec/models/update_spec.rb +95 -0
  849. data/spec/models/user_spec.rb +357 -0
  850. data/spec/models/user_total_spec.rb +5 -0
  851. data/spec/observers/backer_observer_spec.rb +119 -0
  852. data/spec/observers/notification_observer_spec.rb +13 -0
  853. data/spec/observers/payment_notification_observer_spec.rb +34 -0
  854. data/spec/observers/project_observer_spec.rb +224 -0
  855. data/spec/observers/update_observer_spec.rb +17 -0
  856. data/spec/observers/user_observer_spec.rb +23 -0
  857. data/spec/spec_helper.rb +82 -0
  858. data/spec/support/devise.rb +3 -0
  859. data/spec/support/factory_girl.rb +2 -0
  860. data/spec/support/feature_helpers.rb +19 -0
  861. data/spec/uploaders/image_uploader_spec.rb +58 -0
  862. data/spec/uploaders/project_uploader_spec.rb +37 -0
  863. data/spec/uploaders/user_uploader_spec.rb +23 -0
  864. data/spec/views/channels/base/index.html.slim_spec.rb +5 -0
  865. metadata +1915 -0
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Bootstrap.js by @fat & @mdo
3
+ * plugins: bootstrap-modal.js, bootstrap-dropdown.js
4
+ * Copyright 2013 Twitter, Inc.
5
+ * http://www.apache.org/licenses/LICENSE-2.0.txt
6
+ */
7
+ !function(a){var b=function(b,c){this.options=c,this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this)),this.options.remote&&this.$element.find(".modal-body").load(this.options.remote)};b.prototype={constructor:b,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this,c=a.Event("show");this.$element.trigger(c);if(this.isShown||c.isDefaultPrevented())return;this.isShown=!0,this.escape(),this.backdrop(function(){var c=a.support.transition&&b.$element.hasClass("fade");b.$element.parent().length||b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in").attr("aria-hidden",!1),b.enforceFocus(),c?b.$element.one(a.support.transition.end,function(){b.$element.focus().trigger("shown")}):b.$element.focus().trigger("shown")})},hide:function(b){b&&b.preventDefault();var c=this;b=a.Event("hide"),this.$element.trigger(b);if(!this.isShown||b.isDefaultPrevented())return;this.isShown=!1,this.escape(),a(document).off("focusin.modal"),this.$element.removeClass("in").attr("aria-hidden",!0),a.support.transition&&this.$element.hasClass("fade")?this.hideWithTransition():this.hideModal()},enforceFocus:function(){var b=this;a(document).on("focusin.modal",function(a){b.$element[0]!==a.target&&!b.$element.has(a.target).length&&b.$element.focus()})},escape:function(){var a=this;this.isShown&&this.options.keyboard?this.$element.on("keyup.dismiss.modal",function(b){b.which==27&&a.hide()}):this.isShown||this.$element.off("keyup.dismiss.modal")},hideWithTransition:function(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),b.hideModal()},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),b.hideModal()})},hideModal:function(){var a=this;this.$element.hide(),this.backdrop(function(){a.removeBackdrop(),a.$element.trigger("hidden")})},removeBackdrop:function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},backdrop:function(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?a.proxy(this.$element[0].focus,this.$element[0]):a.proxy(this.hide,this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in");if(!b)return;e?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,b):b()):b&&b()}};var c=a.fn.modal;a.fn.modal=function(c){return this.each(function(){var d=a(this),e=d.data("modal"),f=a.extend({},a.fn.modal.defaults,d.data(),typeof c=="object"&&c);e||d.data("modal",e=new b(this,f)),typeof c=="string"?e[c]():f.show&&e.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},a.fn.modal.Constructor=b,a.fn.modal.noConflict=function(){return a.fn.modal=c,this},a(document).on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d=c.attr("href"),e=a(c.attr("data-target")||d&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({remote:!/#/.test(d)&&d},e.data(),c.data());b.preventDefault(),e.modal(f).one("hide",function(){c.focus()})})}(window.jQuery),!function(a){function d(){a(".dropdown-backdrop").remove(),a(b).each(function(){e(a(this)).removeClass("open")})}function e(b){var c=b.attr("data-target"),d;c||(c=b.attr("href"),c=c&&/#/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,"")),d=c&&a(c);if(!d||!d.length)d=b.parent();return d}var b="[data-toggle=dropdown]",c=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};c.prototype={constructor:c,toggle:function(b){var c=a(this),f,g;if(c.is(".disabled, :disabled"))return;return f=e(c),g=f.hasClass("open"),d(),g||("ontouchstart"in document.documentElement&&a('<div class="dropdown-backdrop"/>').insertBefore(a(this)).on("click",d),f.toggleClass("open")),c.focus(),!1},keydown:function(c){var d,f,g,h,i,j;if(!/(38|40|27)/.test(c.keyCode))return;d=a(this),c.preventDefault(),c.stopPropagation();if(d.is(".disabled, :disabled"))return;h=e(d),i=h.hasClass("open");if(!i||i&&c.keyCode==27)return c.which==27&&h.find(b).focus(),d.click();f=a("[role=menu] li:not(.divider):visible a",h);if(!f.length)return;j=f.index(f.filter(":focus")),c.keyCode==38&&j>0&&j--,c.keyCode==40&&j<f.length-1&&j++,~j||(j=0),f.eq(j).focus()}};var f=a.fn.dropdown;a.fn.dropdown=function(b){return this.each(function(){var d=a(this),e=d.data("dropdown");e||d.data("dropdown",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.dropdown.Constructor=c,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=f,this},a(document).on("click.dropdown.data-api",d).on("click.dropdown.data-api",".dropdown form",function(a){a.stopPropagation()}).on("click.dropdown.data-api",b,c.prototype.toggle).on("keydown.dropdown.data-api",b+", [role=menu]",c.prototype.keydown)}(window.jQuery)
@@ -0,0 +1,24 @@
1
+ Skull.Form = {
2
+ checkInput: function(event){
3
+ if(event.currentTarget.checkValidity()){
4
+ this.$(event.currentTarget).removeClass("error");
5
+ }
6
+ },
7
+
8
+ setupForm: function(){
9
+ this.$('input').on('invalid', this.invalid);
10
+ },
11
+
12
+ invalid: function(event){
13
+ this.$(event.currentTarget).addClass("error");
14
+ },
15
+
16
+ validate: function(){
17
+ var valid = true;
18
+ this.$('input:visible').each(function(){
19
+ valid = valid && this.checkValidity();
20
+ });
21
+ this.$('input.error:visible:first').select();
22
+ return valid;
23
+ }
24
+ };
@@ -0,0 +1,43 @@
1
+ Skull.InfiniteScroll = {
2
+ setupScroll: function(){
3
+ this.firstPage();
4
+ this.$window().scroll(this.onScroll);
5
+ },
6
+
7
+ firstPage: function(){
8
+ this.EOF = false;
9
+ this.filter.page = 1;
10
+ this.$results.html('');
11
+ },
12
+
13
+ fetchPage: function(){
14
+ // the isLoaderDivVisible check if the div is already in the view pane to load more content
15
+ // the $loader.is(:visible) is here to avoid trigerring two concurrent fetchPage calls
16
+ if(this.isLoaderDivVisible() && !this.$loader.is(':visible') && !this.EOF){
17
+ this.$loader.show();
18
+ $.get(this.path, this.filter).success(this.onSuccess);
19
+ this.filter.page += 1;
20
+ }
21
+ },
22
+
23
+ onSuccess: function(data){
24
+ if($.trim(data) == ''){
25
+ this.EOF = true;
26
+ }
27
+ this.$results.append(data);
28
+ this.$loader.hide();
29
+ this.trigger('scroll:success', data);
30
+ },
31
+
32
+ $window: function(){
33
+ return $(window);
34
+ },
35
+
36
+ isLoaderDivVisible: function(){
37
+ return this.$loaderDiv.is(':visible') && this.$window().scrollTop() + this.$window().height() > this.$loaderDiv.offset().top;
38
+ },
39
+
40
+ onScroll: function(event){
41
+ this.fetchPage();
42
+ }
43
+ };
@@ -0,0 +1,2252 @@
1
+ /*! jQuery UI - v1.10.3 - 2013-06-03
2
+ * http://jqueryui.com
3
+ * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.sortable.js
4
+ * Copyright 2013 jQuery Foundation and other contributors Licensed MIT */
5
+
6
+ (function( $, undefined ) {
7
+
8
+ var uuid = 0,
9
+ runiqueId = /^ui-id-\d+$/;
10
+
11
+ // $.ui might exist from components with no dependencies, e.g., $.ui.position
12
+ $.ui = $.ui || {};
13
+
14
+ $.extend( $.ui, {
15
+ version: "1.10.3",
16
+
17
+ keyCode: {
18
+ BACKSPACE: 8,
19
+ COMMA: 188,
20
+ DELETE: 46,
21
+ DOWN: 40,
22
+ END: 35,
23
+ ENTER: 13,
24
+ ESCAPE: 27,
25
+ HOME: 36,
26
+ LEFT: 37,
27
+ NUMPAD_ADD: 107,
28
+ NUMPAD_DECIMAL: 110,
29
+ NUMPAD_DIVIDE: 111,
30
+ NUMPAD_ENTER: 108,
31
+ NUMPAD_MULTIPLY: 106,
32
+ NUMPAD_SUBTRACT: 109,
33
+ PAGE_DOWN: 34,
34
+ PAGE_UP: 33,
35
+ PERIOD: 190,
36
+ RIGHT: 39,
37
+ SPACE: 32,
38
+ TAB: 9,
39
+ UP: 38
40
+ }
41
+ });
42
+
43
+ // plugins
44
+ $.fn.extend({
45
+ focus: (function( orig ) {
46
+ return function( delay, fn ) {
47
+ return typeof delay === "number" ?
48
+ this.each(function() {
49
+ var elem = this;
50
+ setTimeout(function() {
51
+ $( elem ).focus();
52
+ if ( fn ) {
53
+ fn.call( elem );
54
+ }
55
+ }, delay );
56
+ }) :
57
+ orig.apply( this, arguments );
58
+ };
59
+ })( $.fn.focus ),
60
+
61
+ scrollParent: function() {
62
+ var scrollParent;
63
+ if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
64
+ scrollParent = this.parents().filter(function() {
65
+ return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
66
+ }).eq(0);
67
+ } else {
68
+ scrollParent = this.parents().filter(function() {
69
+ return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
70
+ }).eq(0);
71
+ }
72
+
73
+ return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
74
+ },
75
+
76
+ zIndex: function( zIndex ) {
77
+ if ( zIndex !== undefined ) {
78
+ return this.css( "zIndex", zIndex );
79
+ }
80
+
81
+ if ( this.length ) {
82
+ var elem = $( this[ 0 ] ), position, value;
83
+ while ( elem.length && elem[ 0 ] !== document ) {
84
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
85
+ // This makes behavior of this function consistent across browsers
86
+ // WebKit always returns auto if the element is positioned
87
+ position = elem.css( "position" );
88
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
89
+ // IE returns 0 when zIndex is not specified
90
+ // other browsers return a string
91
+ // we ignore the case of nested elements with an explicit value of 0
92
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
93
+ value = parseInt( elem.css( "zIndex" ), 10 );
94
+ if ( !isNaN( value ) && value !== 0 ) {
95
+ return value;
96
+ }
97
+ }
98
+ elem = elem.parent();
99
+ }
100
+ }
101
+
102
+ return 0;
103
+ },
104
+
105
+ uniqueId: function() {
106
+ return this.each(function() {
107
+ if ( !this.id ) {
108
+ this.id = "ui-id-" + (++uuid);
109
+ }
110
+ });
111
+ },
112
+
113
+ removeUniqueId: function() {
114
+ return this.each(function() {
115
+ if ( runiqueId.test( this.id ) ) {
116
+ $( this ).removeAttr( "id" );
117
+ }
118
+ });
119
+ }
120
+ });
121
+
122
+ // selectors
123
+ function focusable( element, isTabIndexNotNaN ) {
124
+ var map, mapName, img,
125
+ nodeName = element.nodeName.toLowerCase();
126
+ if ( "area" === nodeName ) {
127
+ map = element.parentNode;
128
+ mapName = map.name;
129
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
130
+ return false;
131
+ }
132
+ img = $( "img[usemap=#" + mapName + "]" )[0];
133
+ return !!img && visible( img );
134
+ }
135
+ return ( /input|select|textarea|button|object/.test( nodeName ) ?
136
+ !element.disabled :
137
+ "a" === nodeName ?
138
+ element.href || isTabIndexNotNaN :
139
+ isTabIndexNotNaN) &&
140
+ // the element and all of its ancestors must be visible
141
+ visible( element );
142
+ }
143
+
144
+ function visible( element ) {
145
+ return $.expr.filters.visible( element ) &&
146
+ !$( element ).parents().addBack().filter(function() {
147
+ return $.css( this, "visibility" ) === "hidden";
148
+ }).length;
149
+ }
150
+
151
+ $.extend( $.expr[ ":" ], {
152
+ data: $.expr.createPseudo ?
153
+ $.expr.createPseudo(function( dataName ) {
154
+ return function( elem ) {
155
+ return !!$.data( elem, dataName );
156
+ };
157
+ }) :
158
+ // support: jQuery <1.8
159
+ function( elem, i, match ) {
160
+ return !!$.data( elem, match[ 3 ] );
161
+ },
162
+
163
+ focusable: function( element ) {
164
+ return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
165
+ },
166
+
167
+ tabbable: function( element ) {
168
+ var tabIndex = $.attr( element, "tabindex" ),
169
+ isTabIndexNaN = isNaN( tabIndex );
170
+ return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
171
+ }
172
+ });
173
+
174
+ // support: jQuery <1.8
175
+ if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
176
+ $.each( [ "Width", "Height" ], function( i, name ) {
177
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
178
+ type = name.toLowerCase(),
179
+ orig = {
180
+ innerWidth: $.fn.innerWidth,
181
+ innerHeight: $.fn.innerHeight,
182
+ outerWidth: $.fn.outerWidth,
183
+ outerHeight: $.fn.outerHeight
184
+ };
185
+
186
+ function reduce( elem, size, border, margin ) {
187
+ $.each( side, function() {
188
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
189
+ if ( border ) {
190
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
191
+ }
192
+ if ( margin ) {
193
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
194
+ }
195
+ });
196
+ return size;
197
+ }
198
+
199
+ $.fn[ "inner" + name ] = function( size ) {
200
+ if ( size === undefined ) {
201
+ return orig[ "inner" + name ].call( this );
202
+ }
203
+
204
+ return this.each(function() {
205
+ $( this ).css( type, reduce( this, size ) + "px" );
206
+ });
207
+ };
208
+
209
+ $.fn[ "outer" + name] = function( size, margin ) {
210
+ if ( typeof size !== "number" ) {
211
+ return orig[ "outer" + name ].call( this, size );
212
+ }
213
+
214
+ return this.each(function() {
215
+ $( this).css( type, reduce( this, size, true, margin ) + "px" );
216
+ });
217
+ };
218
+ });
219
+ }
220
+
221
+ // support: jQuery <1.8
222
+ if ( !$.fn.addBack ) {
223
+ $.fn.addBack = function( selector ) {
224
+ return this.add( selector == null ?
225
+ this.prevObject : this.prevObject.filter( selector )
226
+ );
227
+ };
228
+ }
229
+
230
+ // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
231
+ if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
232
+ $.fn.removeData = (function( removeData ) {
233
+ return function( key ) {
234
+ if ( arguments.length ) {
235
+ return removeData.call( this, $.camelCase( key ) );
236
+ } else {
237
+ return removeData.call( this );
238
+ }
239
+ };
240
+ })( $.fn.removeData );
241
+ }
242
+
243
+
244
+
245
+
246
+
247
+ // deprecated
248
+ $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
249
+
250
+ $.support.selectstart = "onselectstart" in document.createElement( "div" );
251
+ $.fn.extend({
252
+ disableSelection: function() {
253
+ return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
254
+ ".ui-disableSelection", function( event ) {
255
+ event.preventDefault();
256
+ });
257
+ },
258
+
259
+ enableSelection: function() {
260
+ return this.unbind( ".ui-disableSelection" );
261
+ }
262
+ });
263
+
264
+ $.extend( $.ui, {
265
+ // $.ui.plugin is deprecated. Use $.widget() extensions instead.
266
+ plugin: {
267
+ add: function( module, option, set ) {
268
+ var i,
269
+ proto = $.ui[ module ].prototype;
270
+ for ( i in set ) {
271
+ proto.plugins[ i ] = proto.plugins[ i ] || [];
272
+ proto.plugins[ i ].push( [ option, set[ i ] ] );
273
+ }
274
+ },
275
+ call: function( instance, name, args ) {
276
+ var i,
277
+ set = instance.plugins[ name ];
278
+ if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
279
+ return;
280
+ }
281
+
282
+ for ( i = 0; i < set.length; i++ ) {
283
+ if ( instance.options[ set[ i ][ 0 ] ] ) {
284
+ set[ i ][ 1 ].apply( instance.element, args );
285
+ }
286
+ }
287
+ }
288
+ },
289
+
290
+ // only used by resizable
291
+ hasScroll: function( el, a ) {
292
+
293
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
294
+ if ( $( el ).css( "overflow" ) === "hidden") {
295
+ return false;
296
+ }
297
+
298
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
299
+ has = false;
300
+
301
+ if ( el[ scroll ] > 0 ) {
302
+ return true;
303
+ }
304
+
305
+ // TODO: determine which cases actually cause this to happen
306
+ // if the element doesn't have the scroll set, see if it's possible to
307
+ // set the scroll
308
+ el[ scroll ] = 1;
309
+ has = ( el[ scroll ] > 0 );
310
+ el[ scroll ] = 0;
311
+ return has;
312
+ }
313
+ });
314
+
315
+ })( jQuery );
316
+ (function( $, undefined ) {
317
+
318
+ var uuid = 0,
319
+ slice = Array.prototype.slice,
320
+ _cleanData = $.cleanData;
321
+ $.cleanData = function( elems ) {
322
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
323
+ try {
324
+ $( elem ).triggerHandler( "remove" );
325
+ // http://bugs.jquery.com/ticket/8235
326
+ } catch( e ) {}
327
+ }
328
+ _cleanData( elems );
329
+ };
330
+
331
+ $.widget = function( name, base, prototype ) {
332
+ var fullName, existingConstructor, constructor, basePrototype,
333
+ // proxiedPrototype allows the provided prototype to remain unmodified
334
+ // so that it can be used as a mixin for multiple widgets (#8876)
335
+ proxiedPrototype = {},
336
+ namespace = name.split( "." )[ 0 ];
337
+
338
+ name = name.split( "." )[ 1 ];
339
+ fullName = namespace + "-" + name;
340
+
341
+ if ( !prototype ) {
342
+ prototype = base;
343
+ base = $.Widget;
344
+ }
345
+
346
+ // create selector for plugin
347
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
348
+ return !!$.data( elem, fullName );
349
+ };
350
+
351
+ $[ namespace ] = $[ namespace ] || {};
352
+ existingConstructor = $[ namespace ][ name ];
353
+ constructor = $[ namespace ][ name ] = function( options, element ) {
354
+ // allow instantiation without "new" keyword
355
+ if ( !this._createWidget ) {
356
+ return new constructor( options, element );
357
+ }
358
+
359
+ // allow instantiation without initializing for simple inheritance
360
+ // must use "new" keyword (the code above always passes args)
361
+ if ( arguments.length ) {
362
+ this._createWidget( options, element );
363
+ }
364
+ };
365
+ // extend with the existing constructor to carry over any static properties
366
+ $.extend( constructor, existingConstructor, {
367
+ version: prototype.version,
368
+ // copy the object used to create the prototype in case we need to
369
+ // redefine the widget later
370
+ _proto: $.extend( {}, prototype ),
371
+ // track widgets that inherit from this widget in case this widget is
372
+ // redefined after a widget inherits from it
373
+ _childConstructors: []
374
+ });
375
+
376
+ basePrototype = new base();
377
+ // we need to make the options hash a property directly on the new instance
378
+ // otherwise we'll modify the options hash on the prototype that we're
379
+ // inheriting from
380
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
381
+ $.each( prototype, function( prop, value ) {
382
+ if ( !$.isFunction( value ) ) {
383
+ proxiedPrototype[ prop ] = value;
384
+ return;
385
+ }
386
+ proxiedPrototype[ prop ] = (function() {
387
+ var _super = function() {
388
+ return base.prototype[ prop ].apply( this, arguments );
389
+ },
390
+ _superApply = function( args ) {
391
+ return base.prototype[ prop ].apply( this, args );
392
+ };
393
+ return function() {
394
+ var __super = this._super,
395
+ __superApply = this._superApply,
396
+ returnValue;
397
+
398
+ this._super = _super;
399
+ this._superApply = _superApply;
400
+
401
+ returnValue = value.apply( this, arguments );
402
+
403
+ this._super = __super;
404
+ this._superApply = __superApply;
405
+
406
+ return returnValue;
407
+ };
408
+ })();
409
+ });
410
+ constructor.prototype = $.widget.extend( basePrototype, {
411
+ // TODO: remove support for widgetEventPrefix
412
+ // always use the name + a colon as the prefix, e.g., draggable:start
413
+ // don't prefix for widgets that aren't DOM-based
414
+ widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
415
+ }, proxiedPrototype, {
416
+ constructor: constructor,
417
+ namespace: namespace,
418
+ widgetName: name,
419
+ widgetFullName: fullName
420
+ });
421
+
422
+ // If this widget is being redefined then we need to find all widgets that
423
+ // are inheriting from it and redefine all of them so that they inherit from
424
+ // the new version of this widget. We're essentially trying to replace one
425
+ // level in the prototype chain.
426
+ if ( existingConstructor ) {
427
+ $.each( existingConstructor._childConstructors, function( i, child ) {
428
+ var childPrototype = child.prototype;
429
+
430
+ // redefine the child widget using the same prototype that was
431
+ // originally used, but inherit from the new version of the base
432
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
433
+ });
434
+ // remove the list of existing child constructors from the old constructor
435
+ // so the old child constructors can be garbage collected
436
+ delete existingConstructor._childConstructors;
437
+ } else {
438
+ base._childConstructors.push( constructor );
439
+ }
440
+
441
+ $.widget.bridge( name, constructor );
442
+ };
443
+
444
+ $.widget.extend = function( target ) {
445
+ var input = slice.call( arguments, 1 ),
446
+ inputIndex = 0,
447
+ inputLength = input.length,
448
+ key,
449
+ value;
450
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
451
+ for ( key in input[ inputIndex ] ) {
452
+ value = input[ inputIndex ][ key ];
453
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
454
+ // Clone objects
455
+ if ( $.isPlainObject( value ) ) {
456
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
457
+ $.widget.extend( {}, target[ key ], value ) :
458
+ // Don't extend strings, arrays, etc. with objects
459
+ $.widget.extend( {}, value );
460
+ // Copy everything else by reference
461
+ } else {
462
+ target[ key ] = value;
463
+ }
464
+ }
465
+ }
466
+ }
467
+ return target;
468
+ };
469
+
470
+ $.widget.bridge = function( name, object ) {
471
+ var fullName = object.prototype.widgetFullName || name;
472
+ $.fn[ name ] = function( options ) {
473
+ var isMethodCall = typeof options === "string",
474
+ args = slice.call( arguments, 1 ),
475
+ returnValue = this;
476
+
477
+ // allow multiple hashes to be passed on init
478
+ options = !isMethodCall && args.length ?
479
+ $.widget.extend.apply( null, [ options ].concat(args) ) :
480
+ options;
481
+
482
+ if ( isMethodCall ) {
483
+ this.each(function() {
484
+ var methodValue,
485
+ instance = $.data( this, fullName );
486
+ if ( !instance ) {
487
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
488
+ "attempted to call method '" + options + "'" );
489
+ }
490
+ if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
491
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
492
+ }
493
+ methodValue = instance[ options ].apply( instance, args );
494
+ if ( methodValue !== instance && methodValue !== undefined ) {
495
+ returnValue = methodValue && methodValue.jquery ?
496
+ returnValue.pushStack( methodValue.get() ) :
497
+ methodValue;
498
+ return false;
499
+ }
500
+ });
501
+ } else {
502
+ this.each(function() {
503
+ var instance = $.data( this, fullName );
504
+ if ( instance ) {
505
+ instance.option( options || {} )._init();
506
+ } else {
507
+ $.data( this, fullName, new object( options, this ) );
508
+ }
509
+ });
510
+ }
511
+
512
+ return returnValue;
513
+ };
514
+ };
515
+
516
+ $.Widget = function( /* options, element */ ) {};
517
+ $.Widget._childConstructors = [];
518
+
519
+ $.Widget.prototype = {
520
+ widgetName: "widget",
521
+ widgetEventPrefix: "",
522
+ defaultElement: "<div>",
523
+ options: {
524
+ disabled: false,
525
+
526
+ // callbacks
527
+ create: null
528
+ },
529
+ _createWidget: function( options, element ) {
530
+ element = $( element || this.defaultElement || this )[ 0 ];
531
+ this.element = $( element );
532
+ this.uuid = uuid++;
533
+ this.eventNamespace = "." + this.widgetName + this.uuid;
534
+ this.options = $.widget.extend( {},
535
+ this.options,
536
+ this._getCreateOptions(),
537
+ options );
538
+
539
+ this.bindings = $();
540
+ this.hoverable = $();
541
+ this.focusable = $();
542
+
543
+ if ( element !== this ) {
544
+ $.data( element, this.widgetFullName, this );
545
+ this._on( true, this.element, {
546
+ remove: function( event ) {
547
+ if ( event.target === element ) {
548
+ this.destroy();
549
+ }
550
+ }
551
+ });
552
+ this.document = $( element.style ?
553
+ // element within the document
554
+ element.ownerDocument :
555
+ // element is window or document
556
+ element.document || element );
557
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
558
+ }
559
+
560
+ this._create();
561
+ this._trigger( "create", null, this._getCreateEventData() );
562
+ this._init();
563
+ },
564
+ _getCreateOptions: $.noop,
565
+ _getCreateEventData: $.noop,
566
+ _create: $.noop,
567
+ _init: $.noop,
568
+
569
+ destroy: function() {
570
+ this._destroy();
571
+ // we can probably remove the unbind calls in 2.0
572
+ // all event bindings should go through this._on()
573
+ this.element
574
+ .unbind( this.eventNamespace )
575
+ // 1.9 BC for #7810
576
+ // TODO remove dual storage
577
+ .removeData( this.widgetName )
578
+ .removeData( this.widgetFullName )
579
+ // support: jquery <1.6.3
580
+ // http://bugs.jquery.com/ticket/9413
581
+ .removeData( $.camelCase( this.widgetFullName ) );
582
+ this.widget()
583
+ .unbind( this.eventNamespace )
584
+ .removeAttr( "aria-disabled" )
585
+ .removeClass(
586
+ this.widgetFullName + "-disabled " +
587
+ "ui-state-disabled" );
588
+
589
+ // clean up events and states
590
+ this.bindings.unbind( this.eventNamespace );
591
+ this.hoverable.removeClass( "ui-state-hover" );
592
+ this.focusable.removeClass( "ui-state-focus" );
593
+ },
594
+ _destroy: $.noop,
595
+
596
+ widget: function() {
597
+ return this.element;
598
+ },
599
+
600
+ option: function( key, value ) {
601
+ var options = key,
602
+ parts,
603
+ curOption,
604
+ i;
605
+
606
+ if ( arguments.length === 0 ) {
607
+ // don't return a reference to the internal hash
608
+ return $.widget.extend( {}, this.options );
609
+ }
610
+
611
+ if ( typeof key === "string" ) {
612
+ // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
613
+ options = {};
614
+ parts = key.split( "." );
615
+ key = parts.shift();
616
+ if ( parts.length ) {
617
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
618
+ for ( i = 0; i < parts.length - 1; i++ ) {
619
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
620
+ curOption = curOption[ parts[ i ] ];
621
+ }
622
+ key = parts.pop();
623
+ if ( value === undefined ) {
624
+ return curOption[ key ] === undefined ? null : curOption[ key ];
625
+ }
626
+ curOption[ key ] = value;
627
+ } else {
628
+ if ( value === undefined ) {
629
+ return this.options[ key ] === undefined ? null : this.options[ key ];
630
+ }
631
+ options[ key ] = value;
632
+ }
633
+ }
634
+
635
+ this._setOptions( options );
636
+
637
+ return this;
638
+ },
639
+ _setOptions: function( options ) {
640
+ var key;
641
+
642
+ for ( key in options ) {
643
+ this._setOption( key, options[ key ] );
644
+ }
645
+
646
+ return this;
647
+ },
648
+ _setOption: function( key, value ) {
649
+ this.options[ key ] = value;
650
+
651
+ if ( key === "disabled" ) {
652
+ this.widget()
653
+ .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
654
+ .attr( "aria-disabled", value );
655
+ this.hoverable.removeClass( "ui-state-hover" );
656
+ this.focusable.removeClass( "ui-state-focus" );
657
+ }
658
+
659
+ return this;
660
+ },
661
+
662
+ enable: function() {
663
+ return this._setOption( "disabled", false );
664
+ },
665
+ disable: function() {
666
+ return this._setOption( "disabled", true );
667
+ },
668
+
669
+ _on: function( suppressDisabledCheck, element, handlers ) {
670
+ var delegateElement,
671
+ instance = this;
672
+
673
+ // no suppressDisabledCheck flag, shuffle arguments
674
+ if ( typeof suppressDisabledCheck !== "boolean" ) {
675
+ handlers = element;
676
+ element = suppressDisabledCheck;
677
+ suppressDisabledCheck = false;
678
+ }
679
+
680
+ // no element argument, shuffle and use this.element
681
+ if ( !handlers ) {
682
+ handlers = element;
683
+ element = this.element;
684
+ delegateElement = this.widget();
685
+ } else {
686
+ // accept selectors, DOM elements
687
+ element = delegateElement = $( element );
688
+ this.bindings = this.bindings.add( element );
689
+ }
690
+
691
+ $.each( handlers, function( event, handler ) {
692
+ function handlerProxy() {
693
+ // allow widgets to customize the disabled handling
694
+ // - disabled as an array instead of boolean
695
+ // - disabled class as method for disabling individual parts
696
+ if ( !suppressDisabledCheck &&
697
+ ( instance.options.disabled === true ||
698
+ $( this ).hasClass( "ui-state-disabled" ) ) ) {
699
+ return;
700
+ }
701
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
702
+ .apply( instance, arguments );
703
+ }
704
+
705
+ // copy the guid so direct unbinding works
706
+ if ( typeof handler !== "string" ) {
707
+ handlerProxy.guid = handler.guid =
708
+ handler.guid || handlerProxy.guid || $.guid++;
709
+ }
710
+
711
+ var match = event.match( /^(\w+)\s*(.*)$/ ),
712
+ eventName = match[1] + instance.eventNamespace,
713
+ selector = match[2];
714
+ if ( selector ) {
715
+ delegateElement.delegate( selector, eventName, handlerProxy );
716
+ } else {
717
+ element.bind( eventName, handlerProxy );
718
+ }
719
+ });
720
+ },
721
+
722
+ _off: function( element, eventName ) {
723
+ eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
724
+ element.unbind( eventName ).undelegate( eventName );
725
+ },
726
+
727
+ _delay: function( handler, delay ) {
728
+ function handlerProxy() {
729
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
730
+ .apply( instance, arguments );
731
+ }
732
+ var instance = this;
733
+ return setTimeout( handlerProxy, delay || 0 );
734
+ },
735
+
736
+ _hoverable: function( element ) {
737
+ this.hoverable = this.hoverable.add( element );
738
+ this._on( element, {
739
+ mouseenter: function( event ) {
740
+ $( event.currentTarget ).addClass( "ui-state-hover" );
741
+ },
742
+ mouseleave: function( event ) {
743
+ $( event.currentTarget ).removeClass( "ui-state-hover" );
744
+ }
745
+ });
746
+ },
747
+
748
+ _focusable: function( element ) {
749
+ this.focusable = this.focusable.add( element );
750
+ this._on( element, {
751
+ focusin: function( event ) {
752
+ $( event.currentTarget ).addClass( "ui-state-focus" );
753
+ },
754
+ focusout: function( event ) {
755
+ $( event.currentTarget ).removeClass( "ui-state-focus" );
756
+ }
757
+ });
758
+ },
759
+
760
+ _trigger: function( type, event, data ) {
761
+ var prop, orig,
762
+ callback = this.options[ type ];
763
+
764
+ data = data || {};
765
+ event = $.Event( event );
766
+ event.type = ( type === this.widgetEventPrefix ?
767
+ type :
768
+ this.widgetEventPrefix + type ).toLowerCase();
769
+ // the original event may come from any element
770
+ // so we need to reset the target on the new event
771
+ event.target = this.element[ 0 ];
772
+
773
+ // copy original event properties over to the new event
774
+ orig = event.originalEvent;
775
+ if ( orig ) {
776
+ for ( prop in orig ) {
777
+ if ( !( prop in event ) ) {
778
+ event[ prop ] = orig[ prop ];
779
+ }
780
+ }
781
+ }
782
+
783
+ this.element.trigger( event, data );
784
+ return !( $.isFunction( callback ) &&
785
+ callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
786
+ event.isDefaultPrevented() );
787
+ }
788
+ };
789
+
790
+ $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
791
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
792
+ if ( typeof options === "string" ) {
793
+ options = { effect: options };
794
+ }
795
+ var hasOptions,
796
+ effectName = !options ?
797
+ method :
798
+ options === true || typeof options === "number" ?
799
+ defaultEffect :
800
+ options.effect || defaultEffect;
801
+ options = options || {};
802
+ if ( typeof options === "number" ) {
803
+ options = { duration: options };
804
+ }
805
+ hasOptions = !$.isEmptyObject( options );
806
+ options.complete = callback;
807
+ if ( options.delay ) {
808
+ element.delay( options.delay );
809
+ }
810
+ if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
811
+ element[ method ]( options );
812
+ } else if ( effectName !== method && element[ effectName ] ) {
813
+ element[ effectName ]( options.duration, options.easing, callback );
814
+ } else {
815
+ element.queue(function( next ) {
816
+ $( this )[ method ]();
817
+ if ( callback ) {
818
+ callback.call( element[ 0 ] );
819
+ }
820
+ next();
821
+ });
822
+ }
823
+ };
824
+ });
825
+
826
+ })( jQuery );
827
+ (function( $, undefined ) {
828
+
829
+ var mouseHandled = false;
830
+ $( document ).mouseup( function() {
831
+ mouseHandled = false;
832
+ });
833
+
834
+ $.widget("ui.mouse", {
835
+ version: "1.10.3",
836
+ options: {
837
+ cancel: "input,textarea,button,select,option",
838
+ distance: 1,
839
+ delay: 0
840
+ },
841
+ _mouseInit: function() {
842
+ var that = this;
843
+
844
+ this.element
845
+ .bind("mousedown."+this.widgetName, function(event) {
846
+ return that._mouseDown(event);
847
+ })
848
+ .bind("click."+this.widgetName, function(event) {
849
+ if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
850
+ $.removeData(event.target, that.widgetName + ".preventClickEvent");
851
+ event.stopImmediatePropagation();
852
+ return false;
853
+ }
854
+ });
855
+
856
+ this.started = false;
857
+ },
858
+
859
+ // TODO: make sure destroying one instance of mouse doesn't mess with
860
+ // other instances of mouse
861
+ _mouseDestroy: function() {
862
+ this.element.unbind("."+this.widgetName);
863
+ if ( this._mouseMoveDelegate ) {
864
+ $(document)
865
+ .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
866
+ .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
867
+ }
868
+ },
869
+
870
+ _mouseDown: function(event) {
871
+ // don't let more than one widget handle mouseStart
872
+ if( mouseHandled ) { return; }
873
+
874
+ // we may have missed mouseup (out of window)
875
+ (this._mouseStarted && this._mouseUp(event));
876
+
877
+ this._mouseDownEvent = event;
878
+
879
+ var that = this,
880
+ btnIsLeft = (event.which === 1),
881
+ // event.target.nodeName works around a bug in IE 8 with
882
+ // disabled inputs (#7620)
883
+ elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
884
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
885
+ return true;
886
+ }
887
+
888
+ this.mouseDelayMet = !this.options.delay;
889
+ if (!this.mouseDelayMet) {
890
+ this._mouseDelayTimer = setTimeout(function() {
891
+ that.mouseDelayMet = true;
892
+ }, this.options.delay);
893
+ }
894
+
895
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
896
+ this._mouseStarted = (this._mouseStart(event) !== false);
897
+ if (!this._mouseStarted) {
898
+ event.preventDefault();
899
+ return true;
900
+ }
901
+ }
902
+
903
+ // Click event may never have fired (Gecko & Opera)
904
+ if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
905
+ $.removeData(event.target, this.widgetName + ".preventClickEvent");
906
+ }
907
+
908
+ // these delegates are required to keep context
909
+ this._mouseMoveDelegate = function(event) {
910
+ return that._mouseMove(event);
911
+ };
912
+ this._mouseUpDelegate = function(event) {
913
+ return that._mouseUp(event);
914
+ };
915
+ $(document)
916
+ .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
917
+ .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
918
+
919
+ event.preventDefault();
920
+
921
+ mouseHandled = true;
922
+ return true;
923
+ },
924
+
925
+ _mouseMove: function(event) {
926
+ // IE mouseup check - mouseup happened when mouse was out of window
927
+ if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
928
+ return this._mouseUp(event);
929
+ }
930
+
931
+ if (this._mouseStarted) {
932
+ this._mouseDrag(event);
933
+ return event.preventDefault();
934
+ }
935
+
936
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
937
+ this._mouseStarted =
938
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
939
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
940
+ }
941
+
942
+ return !this._mouseStarted;
943
+ },
944
+
945
+ _mouseUp: function(event) {
946
+ $(document)
947
+ .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
948
+ .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
949
+
950
+ if (this._mouseStarted) {
951
+ this._mouseStarted = false;
952
+
953
+ if (event.target === this._mouseDownEvent.target) {
954
+ $.data(event.target, this.widgetName + ".preventClickEvent", true);
955
+ }
956
+
957
+ this._mouseStop(event);
958
+ }
959
+
960
+ return false;
961
+ },
962
+
963
+ _mouseDistanceMet: function(event) {
964
+ return (Math.max(
965
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
966
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
967
+ ) >= this.options.distance
968
+ );
969
+ },
970
+
971
+ _mouseDelayMet: function(/* event */) {
972
+ return this.mouseDelayMet;
973
+ },
974
+
975
+ // These are placeholder methods, to be overriden by extending plugin
976
+ _mouseStart: function(/* event */) {},
977
+ _mouseDrag: function(/* event */) {},
978
+ _mouseStop: function(/* event */) {},
979
+ _mouseCapture: function(/* event */) { return true; }
980
+ });
981
+
982
+ })(jQuery);
983
+ (function( $, undefined ) {
984
+
985
+ /*jshint loopfunc: true */
986
+
987
+ function isOverAxis( x, reference, size ) {
988
+ return ( x > reference ) && ( x < ( reference + size ) );
989
+ }
990
+
991
+ function isFloating(item) {
992
+ return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
993
+ }
994
+
995
+ $.widget("ui.sortable", $.ui.mouse, {
996
+ version: "1.10.3",
997
+ widgetEventPrefix: "sort",
998
+ ready: false,
999
+ options: {
1000
+ appendTo: "parent",
1001
+ axis: false,
1002
+ connectWith: false,
1003
+ containment: false,
1004
+ cursor: "auto",
1005
+ cursorAt: false,
1006
+ dropOnEmpty: true,
1007
+ forcePlaceholderSize: false,
1008
+ forceHelperSize: false,
1009
+ grid: false,
1010
+ handle: false,
1011
+ helper: "original",
1012
+ items: "> *",
1013
+ opacity: false,
1014
+ placeholder: false,
1015
+ revert: false,
1016
+ scroll: true,
1017
+ scrollSensitivity: 20,
1018
+ scrollSpeed: 20,
1019
+ scope: "default",
1020
+ tolerance: "intersect",
1021
+ zIndex: 1000,
1022
+
1023
+ // callbacks
1024
+ activate: null,
1025
+ beforeStop: null,
1026
+ change: null,
1027
+ deactivate: null,
1028
+ out: null,
1029
+ over: null,
1030
+ receive: null,
1031
+ remove: null,
1032
+ sort: null,
1033
+ start: null,
1034
+ stop: null,
1035
+ update: null
1036
+ },
1037
+ _create: function() {
1038
+
1039
+ var o = this.options;
1040
+ this.containerCache = {};
1041
+ this.element.addClass("ui-sortable");
1042
+
1043
+ //Get the items
1044
+ this.refresh();
1045
+
1046
+ //Let's determine if the items are being displayed horizontally
1047
+ this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
1048
+
1049
+ //Let's determine the parent's offset
1050
+ this.offset = this.element.offset();
1051
+
1052
+ //Initialize mouse events for interaction
1053
+ this._mouseInit();
1054
+
1055
+ //We're ready to go
1056
+ this.ready = true;
1057
+
1058
+ },
1059
+
1060
+ _destroy: function() {
1061
+ this.element
1062
+ .removeClass("ui-sortable ui-sortable-disabled");
1063
+ this._mouseDestroy();
1064
+
1065
+ for ( var i = this.items.length - 1; i >= 0; i-- ) {
1066
+ this.items[i].item.removeData(this.widgetName + "-item");
1067
+ }
1068
+
1069
+ return this;
1070
+ },
1071
+
1072
+ _setOption: function(key, value){
1073
+ if ( key === "disabled" ) {
1074
+ this.options[ key ] = value;
1075
+
1076
+ this.widget().toggleClass( "ui-sortable-disabled", !!value );
1077
+ } else {
1078
+ // Don't call widget base _setOption for disable as it adds ui-state-disabled class
1079
+ $.Widget.prototype._setOption.apply(this, arguments);
1080
+ }
1081
+ },
1082
+
1083
+ _mouseCapture: function(event, overrideHandle) {
1084
+ var currentItem = null,
1085
+ validHandle = false,
1086
+ that = this;
1087
+
1088
+ if (this.reverting) {
1089
+ return false;
1090
+ }
1091
+
1092
+ if(this.options.disabled || this.options.type === "static") {
1093
+ return false;
1094
+ }
1095
+
1096
+ //We have to refresh the items data once first
1097
+ this._refreshItems(event);
1098
+
1099
+ //Find out if the clicked node (or one of its parents) is a actual item in this.items
1100
+ $(event.target).parents().each(function() {
1101
+ if($.data(this, that.widgetName + "-item") === that) {
1102
+ currentItem = $(this);
1103
+ return false;
1104
+ }
1105
+ });
1106
+ if($.data(event.target, that.widgetName + "-item") === that) {
1107
+ currentItem = $(event.target);
1108
+ }
1109
+
1110
+ if(!currentItem) {
1111
+ return false;
1112
+ }
1113
+ if(this.options.handle && !overrideHandle) {
1114
+ $(this.options.handle, currentItem).find("*").addBack().each(function() {
1115
+ if(this === event.target) {
1116
+ validHandle = true;
1117
+ }
1118
+ });
1119
+ if(!validHandle) {
1120
+ return false;
1121
+ }
1122
+ }
1123
+
1124
+ this.currentItem = currentItem;
1125
+ this._removeCurrentsFromItems();
1126
+ return true;
1127
+
1128
+ },
1129
+
1130
+ _mouseStart: function(event, overrideHandle, noActivation) {
1131
+
1132
+ var i, body,
1133
+ o = this.options;
1134
+
1135
+ this.currentContainer = this;
1136
+
1137
+ //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
1138
+ this.refreshPositions();
1139
+
1140
+ //Create and append the visible helper
1141
+ this.helper = this._createHelper(event);
1142
+
1143
+ //Cache the helper size
1144
+ this._cacheHelperProportions();
1145
+
1146
+ /*
1147
+ * - Position generation -
1148
+ * This block generates everything position related - it's the core of draggables.
1149
+ */
1150
+
1151
+ //Cache the margins of the original element
1152
+ this._cacheMargins();
1153
+
1154
+ //Get the next scrolling parent
1155
+ this.scrollParent = this.helper.scrollParent();
1156
+
1157
+ //The element's absolute position on the page minus margins
1158
+ this.offset = this.currentItem.offset();
1159
+ this.offset = {
1160
+ top: this.offset.top - this.margins.top,
1161
+ left: this.offset.left - this.margins.left
1162
+ };
1163
+
1164
+ $.extend(this.offset, {
1165
+ click: { //Where the click happened, relative to the element
1166
+ left: event.pageX - this.offset.left,
1167
+ top: event.pageY - this.offset.top
1168
+ },
1169
+ parent: this._getParentOffset(),
1170
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
1171
+ });
1172
+
1173
+ // Only after we got the offset, we can change the helper's position to absolute
1174
+ // TODO: Still need to figure out a way to make relative sorting possible
1175
+ this.helper.css("position", "absolute");
1176
+ this.cssPosition = this.helper.css("position");
1177
+
1178
+ //Generate the original position
1179
+ this.originalPosition = this._generatePosition(event);
1180
+ this.originalPageX = event.pageX;
1181
+ this.originalPageY = event.pageY;
1182
+
1183
+ //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
1184
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
1185
+
1186
+ //Cache the former DOM position
1187
+ this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
1188
+
1189
+ //If the helper is not the original, hide the original so it's not playing any role during the drag, won't cause anything bad this way
1190
+ if(this.helper[0] !== this.currentItem[0]) {
1191
+ this.currentItem.hide();
1192
+ }
1193
+
1194
+ //Create the placeholder
1195
+ this._createPlaceholder();
1196
+
1197
+ //Set a containment if given in the options
1198
+ if(o.containment) {
1199
+ this._setContainment();
1200
+ }
1201
+
1202
+ if( o.cursor && o.cursor !== "auto" ) { // cursor option
1203
+ body = this.document.find( "body" );
1204
+
1205
+ // support: IE
1206
+ this.storedCursor = body.css( "cursor" );
1207
+ body.css( "cursor", o.cursor );
1208
+
1209
+ this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
1210
+ }
1211
+
1212
+ if(o.opacity) { // opacity option
1213
+ if (this.helper.css("opacity")) {
1214
+ this._storedOpacity = this.helper.css("opacity");
1215
+ }
1216
+ this.helper.css("opacity", o.opacity);
1217
+ }
1218
+
1219
+ if(o.zIndex) { // zIndex option
1220
+ if (this.helper.css("zIndex")) {
1221
+ this._storedZIndex = this.helper.css("zIndex");
1222
+ }
1223
+ this.helper.css("zIndex", o.zIndex);
1224
+ }
1225
+
1226
+ //Prepare scrolling
1227
+ if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
1228
+ this.overflowOffset = this.scrollParent.offset();
1229
+ }
1230
+
1231
+ //Call callbacks
1232
+ this._trigger("start", event, this._uiHash());
1233
+
1234
+ //Recache the helper size
1235
+ if(!this._preserveHelperProportions) {
1236
+ this._cacheHelperProportions();
1237
+ }
1238
+
1239
+
1240
+ //Post "activate" events to possible containers
1241
+ if( !noActivation ) {
1242
+ for ( i = this.containers.length - 1; i >= 0; i-- ) {
1243
+ this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
1244
+ }
1245
+ }
1246
+
1247
+ //Prepare possible droppables
1248
+ if($.ui.ddmanager) {
1249
+ $.ui.ddmanager.current = this;
1250
+ }
1251
+
1252
+ if ($.ui.ddmanager && !o.dropBehaviour) {
1253
+ $.ui.ddmanager.prepareOffsets(this, event);
1254
+ }
1255
+
1256
+ this.dragging = true;
1257
+
1258
+ this.helper.addClass("ui-sortable-helper");
1259
+ this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
1260
+ return true;
1261
+
1262
+ },
1263
+
1264
+ _mouseDrag: function(event) {
1265
+ var i, item, itemElement, intersection,
1266
+ o = this.options,
1267
+ scrolled = false;
1268
+
1269
+ //Compute the helpers position
1270
+ this.position = this._generatePosition(event);
1271
+ this.positionAbs = this._convertPositionTo("absolute");
1272
+
1273
+ if (!this.lastPositionAbs) {
1274
+ this.lastPositionAbs = this.positionAbs;
1275
+ }
1276
+
1277
+ //Do scrolling
1278
+ if(this.options.scroll) {
1279
+ if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
1280
+
1281
+ if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
1282
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
1283
+ } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
1284
+ this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
1285
+ }
1286
+
1287
+ if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
1288
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
1289
+ } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
1290
+ this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
1291
+ }
1292
+
1293
+ } else {
1294
+
1295
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
1296
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
1297
+ } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
1298
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
1299
+ }
1300
+
1301
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
1302
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
1303
+ } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
1304
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
1305
+ }
1306
+
1307
+ }
1308
+
1309
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
1310
+ $.ui.ddmanager.prepareOffsets(this, event);
1311
+ }
1312
+ }
1313
+
1314
+ //Regenerate the absolute position used for position checks
1315
+ this.positionAbs = this._convertPositionTo("absolute");
1316
+
1317
+ //Set the helper position
1318
+ if(!this.options.axis || this.options.axis !== "y") {
1319
+ this.helper[0].style.left = this.position.left+"px";
1320
+ }
1321
+ if(!this.options.axis || this.options.axis !== "x") {
1322
+ this.helper[0].style.top = this.position.top+"px";
1323
+ }
1324
+
1325
+ //Rearrange
1326
+ for (i = this.items.length - 1; i >= 0; i--) {
1327
+
1328
+ //Cache variables and intersection, continue if no intersection
1329
+ item = this.items[i];
1330
+ itemElement = item.item[0];
1331
+ intersection = this._intersectsWithPointer(item);
1332
+ if (!intersection) {
1333
+ continue;
1334
+ }
1335
+
1336
+ // Only put the placeholder inside the current Container, skip all
1337
+ // items form other containers. This works because when moving
1338
+ // an item from one container to another the
1339
+ // currentContainer is switched before the placeholder is moved.
1340
+ //
1341
+ // Without this moving items in "sub-sortables" can cause the placeholder to jitter
1342
+ // beetween the outer and inner container.
1343
+ if (item.instance !== this.currentContainer) {
1344
+ continue;
1345
+ }
1346
+
1347
+ // cannot intersect with itself
1348
+ // no useless actions that have been done before
1349
+ // no action if the item moved is the parent of the item checked
1350
+ if (itemElement !== this.currentItem[0] &&
1351
+ this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
1352
+ !$.contains(this.placeholder[0], itemElement) &&
1353
+ (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
1354
+ ) {
1355
+
1356
+ this.direction = intersection === 1 ? "down" : "up";
1357
+
1358
+ if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
1359
+ this._rearrange(event, item);
1360
+ } else {
1361
+ break;
1362
+ }
1363
+
1364
+ this._trigger("change", event, this._uiHash());
1365
+ break;
1366
+ }
1367
+ }
1368
+
1369
+ //Post events to containers
1370
+ this._contactContainers(event);
1371
+
1372
+ //Interconnect with droppables
1373
+ if($.ui.ddmanager) {
1374
+ $.ui.ddmanager.drag(this, event);
1375
+ }
1376
+
1377
+ //Call callbacks
1378
+ this._trigger("sort", event, this._uiHash());
1379
+
1380
+ this.lastPositionAbs = this.positionAbs;
1381
+ return false;
1382
+
1383
+ },
1384
+
1385
+ _mouseStop: function(event, noPropagation) {
1386
+
1387
+ if(!event) {
1388
+ return;
1389
+ }
1390
+
1391
+ //If we are using droppables, inform the manager about the drop
1392
+ if ($.ui.ddmanager && !this.options.dropBehaviour) {
1393
+ $.ui.ddmanager.drop(this, event);
1394
+ }
1395
+
1396
+ if(this.options.revert) {
1397
+ var that = this,
1398
+ cur = this.placeholder.offset(),
1399
+ axis = this.options.axis,
1400
+ animation = {};
1401
+
1402
+ if ( !axis || axis === "x" ) {
1403
+ animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
1404
+ }
1405
+ if ( !axis || axis === "y" ) {
1406
+ animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
1407
+ }
1408
+ this.reverting = true;
1409
+ $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
1410
+ that._clear(event);
1411
+ });
1412
+ } else {
1413
+ this._clear(event, noPropagation);
1414
+ }
1415
+
1416
+ return false;
1417
+
1418
+ },
1419
+
1420
+ cancel: function() {
1421
+
1422
+ if(this.dragging) {
1423
+
1424
+ this._mouseUp({ target: null });
1425
+
1426
+ if(this.options.helper === "original") {
1427
+ this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
1428
+ } else {
1429
+ this.currentItem.show();
1430
+ }
1431
+
1432
+ //Post deactivating events to containers
1433
+ for (var i = this.containers.length - 1; i >= 0; i--){
1434
+ this.containers[i]._trigger("deactivate", null, this._uiHash(this));
1435
+ if(this.containers[i].containerCache.over) {
1436
+ this.containers[i]._trigger("out", null, this._uiHash(this));
1437
+ this.containers[i].containerCache.over = 0;
1438
+ }
1439
+ }
1440
+
1441
+ }
1442
+
1443
+ if (this.placeholder) {
1444
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
1445
+ if(this.placeholder[0].parentNode) {
1446
+ this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
1447
+ }
1448
+ if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
1449
+ this.helper.remove();
1450
+ }
1451
+
1452
+ $.extend(this, {
1453
+ helper: null,
1454
+ dragging: false,
1455
+ reverting: false,
1456
+ _noFinalSort: null
1457
+ });
1458
+
1459
+ if(this.domPosition.prev) {
1460
+ $(this.domPosition.prev).after(this.currentItem);
1461
+ } else {
1462
+ $(this.domPosition.parent).prepend(this.currentItem);
1463
+ }
1464
+ }
1465
+
1466
+ return this;
1467
+
1468
+ },
1469
+
1470
+ serialize: function(o) {
1471
+
1472
+ var items = this._getItemsAsjQuery(o && o.connected),
1473
+ str = [];
1474
+ o = o || {};
1475
+
1476
+ $(items).each(function() {
1477
+ var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
1478
+ if (res) {
1479
+ str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
1480
+ }
1481
+ });
1482
+
1483
+ if(!str.length && o.key) {
1484
+ str.push(o.key + "=");
1485
+ }
1486
+
1487
+ return str.join("&");
1488
+
1489
+ },
1490
+
1491
+ toArray: function(o) {
1492
+
1493
+ var items = this._getItemsAsjQuery(o && o.connected),
1494
+ ret = [];
1495
+
1496
+ o = o || {};
1497
+
1498
+ items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
1499
+ return ret;
1500
+
1501
+ },
1502
+
1503
+ /* Be careful with the following core functions */
1504
+ _intersectsWith: function(item) {
1505
+
1506
+ var x1 = this.positionAbs.left,
1507
+ x2 = x1 + this.helperProportions.width,
1508
+ y1 = this.positionAbs.top,
1509
+ y2 = y1 + this.helperProportions.height,
1510
+ l = item.left,
1511
+ r = l + item.width,
1512
+ t = item.top,
1513
+ b = t + item.height,
1514
+ dyClick = this.offset.click.top,
1515
+ dxClick = this.offset.click.left,
1516
+ isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
1517
+ isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
1518
+ isOverElement = isOverElementHeight && isOverElementWidth;
1519
+
1520
+ if ( this.options.tolerance === "pointer" ||
1521
+ this.options.forcePointerForContainers ||
1522
+ (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
1523
+ ) {
1524
+ return isOverElement;
1525
+ } else {
1526
+
1527
+ return (l < x1 + (this.helperProportions.width / 2) && // Right Half
1528
+ x2 - (this.helperProportions.width / 2) < r && // Left Half
1529
+ t < y1 + (this.helperProportions.height / 2) && // Bottom Half
1530
+ y2 - (this.helperProportions.height / 2) < b ); // Top Half
1531
+
1532
+ }
1533
+ },
1534
+
1535
+ _intersectsWithPointer: function(item) {
1536
+
1537
+ var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
1538
+ isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
1539
+ isOverElement = isOverElementHeight && isOverElementWidth,
1540
+ verticalDirection = this._getDragVerticalDirection(),
1541
+ horizontalDirection = this._getDragHorizontalDirection();
1542
+
1543
+ if (!isOverElement) {
1544
+ return false;
1545
+ }
1546
+
1547
+ return this.floating ?
1548
+ ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
1549
+ : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
1550
+
1551
+ },
1552
+
1553
+ _intersectsWithSides: function(item) {
1554
+
1555
+ var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
1556
+ isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
1557
+ verticalDirection = this._getDragVerticalDirection(),
1558
+ horizontalDirection = this._getDragHorizontalDirection();
1559
+
1560
+ if (this.floating && horizontalDirection) {
1561
+ return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
1562
+ } else {
1563
+ return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
1564
+ }
1565
+
1566
+ },
1567
+
1568
+ _getDragVerticalDirection: function() {
1569
+ var delta = this.positionAbs.top - this.lastPositionAbs.top;
1570
+ return delta !== 0 && (delta > 0 ? "down" : "up");
1571
+ },
1572
+
1573
+ _getDragHorizontalDirection: function() {
1574
+ var delta = this.positionAbs.left - this.lastPositionAbs.left;
1575
+ return delta !== 0 && (delta > 0 ? "right" : "left");
1576
+ },
1577
+
1578
+ refresh: function(event) {
1579
+ this._refreshItems(event);
1580
+ this.refreshPositions();
1581
+ return this;
1582
+ },
1583
+
1584
+ _connectWith: function() {
1585
+ var options = this.options;
1586
+ return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
1587
+ },
1588
+
1589
+ _getItemsAsjQuery: function(connected) {
1590
+
1591
+ var i, j, cur, inst,
1592
+ items = [],
1593
+ queries = [],
1594
+ connectWith = this._connectWith();
1595
+
1596
+ if(connectWith && connected) {
1597
+ for (i = connectWith.length - 1; i >= 0; i--){
1598
+ cur = $(connectWith[i]);
1599
+ for ( j = cur.length - 1; j >= 0; j--){
1600
+ inst = $.data(cur[j], this.widgetFullName);
1601
+ if(inst && inst !== this && !inst.options.disabled) {
1602
+ queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), inst]);
1603
+ }
1604
+ }
1605
+ }
1606
+ }
1607
+
1608
+ queries.push([$.isFunction(this.options.items) ? this.options.items.call(this.element, null, { options: this.options, item: this.currentItem }) : $(this.options.items, this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), this]);
1609
+
1610
+ for (i = queries.length - 1; i >= 0; i--){
1611
+ queries[i][0].each(function() {
1612
+ items.push(this);
1613
+ });
1614
+ }
1615
+
1616
+ return $(items);
1617
+
1618
+ },
1619
+
1620
+ _removeCurrentsFromItems: function() {
1621
+
1622
+ var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
1623
+
1624
+ this.items = $.grep(this.items, function (item) {
1625
+ for (var j=0; j < list.length; j++) {
1626
+ if(list[j] === item.item[0]) {
1627
+ return false;
1628
+ }
1629
+ }
1630
+ return true;
1631
+ });
1632
+
1633
+ },
1634
+
1635
+ _refreshItems: function(event) {
1636
+
1637
+ this.items = [];
1638
+ this.containers = [this];
1639
+
1640
+ var i, j, cur, inst, targetData, _queries, item, queriesLength,
1641
+ items = this.items,
1642
+ queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
1643
+ connectWith = this._connectWith();
1644
+
1645
+ if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
1646
+ for (i = connectWith.length - 1; i >= 0; i--){
1647
+ cur = $(connectWith[i]);
1648
+ for (j = cur.length - 1; j >= 0; j--){
1649
+ inst = $.data(cur[j], this.widgetFullName);
1650
+ if(inst && inst !== this && !inst.options.disabled) {
1651
+ queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
1652
+ this.containers.push(inst);
1653
+ }
1654
+ }
1655
+ }
1656
+ }
1657
+
1658
+ for (i = queries.length - 1; i >= 0; i--) {
1659
+ targetData = queries[i][1];
1660
+ _queries = queries[i][0];
1661
+
1662
+ for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
1663
+ item = $(_queries[j]);
1664
+
1665
+ item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
1666
+
1667
+ items.push({
1668
+ item: item,
1669
+ instance: targetData,
1670
+ width: 0, height: 0,
1671
+ left: 0, top: 0
1672
+ });
1673
+ }
1674
+ }
1675
+
1676
+ },
1677
+
1678
+ refreshPositions: function(fast) {
1679
+
1680
+ //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
1681
+ if(this.offsetParent && this.helper) {
1682
+ this.offset.parent = this._getParentOffset();
1683
+ }
1684
+
1685
+ var i, item, t, p;
1686
+
1687
+ for (i = this.items.length - 1; i >= 0; i--){
1688
+ item = this.items[i];
1689
+
1690
+ //We ignore calculating positions of all connected containers when we're not over them
1691
+ if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
1692
+ continue;
1693
+ }
1694
+
1695
+ t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
1696
+
1697
+ if (!fast) {
1698
+ item.width = t.outerWidth();
1699
+ item.height = t.outerHeight();
1700
+ }
1701
+
1702
+ p = t.offset();
1703
+ item.left = p.left;
1704
+ item.top = p.top;
1705
+ }
1706
+
1707
+ if(this.options.custom && this.options.custom.refreshContainers) {
1708
+ this.options.custom.refreshContainers.call(this);
1709
+ } else {
1710
+ for (i = this.containers.length - 1; i >= 0; i--){
1711
+ p = this.containers[i].element.offset();
1712
+ this.containers[i].containerCache.left = p.left;
1713
+ this.containers[i].containerCache.top = p.top;
1714
+ this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
1715
+ this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
1716
+ }
1717
+ }
1718
+
1719
+ return this;
1720
+ },
1721
+
1722
+ _createPlaceholder: function(that) {
1723
+ that = that || this;
1724
+ var className,
1725
+ o = that.options;
1726
+
1727
+ if(!o.placeholder || o.placeholder.constructor === String) {
1728
+ className = o.placeholder;
1729
+ o.placeholder = {
1730
+ element: function() {
1731
+
1732
+ var nodeName = that.currentItem[0].nodeName.toLowerCase(),
1733
+ element = $( "<" + nodeName + ">", that.document[0] )
1734
+ .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
1735
+ .removeClass("ui-sortable-helper");
1736
+
1737
+ if ( nodeName === "tr" ) {
1738
+ that.currentItem.children().each(function() {
1739
+ $( "<td>&#160;</td>", that.document[0] )
1740
+ .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
1741
+ .appendTo( element );
1742
+ });
1743
+ } else if ( nodeName === "img" ) {
1744
+ element.attr( "src", that.currentItem.attr( "src" ) );
1745
+ }
1746
+
1747
+ if ( !className ) {
1748
+ element.css( "visibility", "hidden" );
1749
+ }
1750
+
1751
+ return element;
1752
+ },
1753
+ update: function(container, p) {
1754
+
1755
+ // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
1756
+ // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
1757
+ if(className && !o.forcePlaceholderSize) {
1758
+ return;
1759
+ }
1760
+
1761
+ //If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
1762
+ if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
1763
+ if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
1764
+ }
1765
+ };
1766
+ }
1767
+
1768
+ //Create the placeholder
1769
+ that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
1770
+
1771
+ //Append it after the actual current item
1772
+ that.currentItem.after(that.placeholder);
1773
+
1774
+ //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
1775
+ o.placeholder.update(that, that.placeholder);
1776
+
1777
+ },
1778
+
1779
+ _contactContainers: function(event) {
1780
+ var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
1781
+ innermostContainer = null,
1782
+ innermostIndex = null;
1783
+
1784
+ // get innermost container that intersects with item
1785
+ for (i = this.containers.length - 1; i >= 0; i--) {
1786
+
1787
+ // never consider a container that's located within the item itself
1788
+ if($.contains(this.currentItem[0], this.containers[i].element[0])) {
1789
+ continue;
1790
+ }
1791
+
1792
+ if(this._intersectsWith(this.containers[i].containerCache)) {
1793
+
1794
+ // if we've already found a container and it's more "inner" than this, then continue
1795
+ if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
1796
+ continue;
1797
+ }
1798
+
1799
+ innermostContainer = this.containers[i];
1800
+ innermostIndex = i;
1801
+
1802
+ } else {
1803
+ // container doesn't intersect. trigger "out" event if necessary
1804
+ if(this.containers[i].containerCache.over) {
1805
+ this.containers[i]._trigger("out", event, this._uiHash(this));
1806
+ this.containers[i].containerCache.over = 0;
1807
+ }
1808
+ }
1809
+
1810
+ }
1811
+
1812
+ // if no intersecting containers found, return
1813
+ if(!innermostContainer) {
1814
+ return;
1815
+ }
1816
+
1817
+ // move the item into the container if it's not there already
1818
+ if(this.containers.length === 1) {
1819
+ if (!this.containers[innermostIndex].containerCache.over) {
1820
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
1821
+ this.containers[innermostIndex].containerCache.over = 1;
1822
+ }
1823
+ } else {
1824
+
1825
+ //When entering a new container, we will find the item with the least distance and append our item near it
1826
+ dist = 10000;
1827
+ itemWithLeastDistance = null;
1828
+ floating = innermostContainer.floating || isFloating(this.currentItem);
1829
+ posProperty = floating ? "left" : "top";
1830
+ sizeProperty = floating ? "width" : "height";
1831
+ base = this.positionAbs[posProperty] + this.offset.click[posProperty];
1832
+ for (j = this.items.length - 1; j >= 0; j--) {
1833
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
1834
+ continue;
1835
+ }
1836
+ if(this.items[j].item[0] === this.currentItem[0]) {
1837
+ continue;
1838
+ }
1839
+ if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
1840
+ continue;
1841
+ }
1842
+ cur = this.items[j].item.offset()[posProperty];
1843
+ nearBottom = false;
1844
+ if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
1845
+ nearBottom = true;
1846
+ cur += this.items[j][sizeProperty];
1847
+ }
1848
+
1849
+ if(Math.abs(cur - base) < dist) {
1850
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
1851
+ this.direction = nearBottom ? "up": "down";
1852
+ }
1853
+ }
1854
+
1855
+ //Check if dropOnEmpty is enabled
1856
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
1857
+ return;
1858
+ }
1859
+
1860
+ if(this.currentContainer === this.containers[innermostIndex]) {
1861
+ return;
1862
+ }
1863
+
1864
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
1865
+ this._trigger("change", event, this._uiHash());
1866
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
1867
+ this.currentContainer = this.containers[innermostIndex];
1868
+
1869
+ //Update the placeholder
1870
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
1871
+
1872
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
1873
+ this.containers[innermostIndex].containerCache.over = 1;
1874
+ }
1875
+
1876
+
1877
+ },
1878
+
1879
+ _createHelper: function(event) {
1880
+
1881
+ var o = this.options,
1882
+ helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
1883
+
1884
+ //Add the helper to the DOM if that didn't happen already
1885
+ if(!helper.parents("body").length) {
1886
+ $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
1887
+ }
1888
+
1889
+ if(helper[0] === this.currentItem[0]) {
1890
+ this._storedCSS = { width: this.currentItem[0].style.width, height: this.currentItem[0].style.height, position: this.currentItem.css("position"), top: this.currentItem.css("top"), left: this.currentItem.css("left") };
1891
+ }
1892
+
1893
+ if(!helper[0].style.width || o.forceHelperSize) {
1894
+ helper.width(this.currentItem.width());
1895
+ }
1896
+ if(!helper[0].style.height || o.forceHelperSize) {
1897
+ helper.height(this.currentItem.height());
1898
+ }
1899
+
1900
+ return helper;
1901
+
1902
+ },
1903
+
1904
+ _adjustOffsetFromHelper: function(obj) {
1905
+ if (typeof obj === "string") {
1906
+ obj = obj.split(" ");
1907
+ }
1908
+ if ($.isArray(obj)) {
1909
+ obj = {left: +obj[0], top: +obj[1] || 0};
1910
+ }
1911
+ if ("left" in obj) {
1912
+ this.offset.click.left = obj.left + this.margins.left;
1913
+ }
1914
+ if ("right" in obj) {
1915
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
1916
+ }
1917
+ if ("top" in obj) {
1918
+ this.offset.click.top = obj.top + this.margins.top;
1919
+ }
1920
+ if ("bottom" in obj) {
1921
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
1922
+ }
1923
+ },
1924
+
1925
+ _getParentOffset: function() {
1926
+
1927
+
1928
+ //Get the offsetParent and cache its position
1929
+ this.offsetParent = this.helper.offsetParent();
1930
+ var po = this.offsetParent.offset();
1931
+
1932
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
1933
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
1934
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
1935
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
1936
+ if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
1937
+ po.left += this.scrollParent.scrollLeft();
1938
+ po.top += this.scrollParent.scrollTop();
1939
+ }
1940
+
1941
+ // This needs to be actually done for all browsers, since pageX/pageY includes this information
1942
+ // with an ugly IE fix
1943
+ if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
1944
+ po = { top: 0, left: 0 };
1945
+ }
1946
+
1947
+ return {
1948
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
1949
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
1950
+ };
1951
+
1952
+ },
1953
+
1954
+ _getRelativeOffset: function() {
1955
+
1956
+ if(this.cssPosition === "relative") {
1957
+ var p = this.currentItem.position();
1958
+ return {
1959
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
1960
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
1961
+ };
1962
+ } else {
1963
+ return { top: 0, left: 0 };
1964
+ }
1965
+
1966
+ },
1967
+
1968
+ _cacheMargins: function() {
1969
+ this.margins = {
1970
+ left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
1971
+ top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
1972
+ };
1973
+ },
1974
+
1975
+ _cacheHelperProportions: function() {
1976
+ this.helperProportions = {
1977
+ width: this.helper.outerWidth(),
1978
+ height: this.helper.outerHeight()
1979
+ };
1980
+ },
1981
+
1982
+ _setContainment: function() {
1983
+
1984
+ var ce, co, over,
1985
+ o = this.options;
1986
+ if(o.containment === "parent") {
1987
+ o.containment = this.helper[0].parentNode;
1988
+ }
1989
+ if(o.containment === "document" || o.containment === "window") {
1990
+ this.containment = [
1991
+ 0 - this.offset.relative.left - this.offset.parent.left,
1992
+ 0 - this.offset.relative.top - this.offset.parent.top,
1993
+ $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
1994
+ ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
1995
+ ];
1996
+ }
1997
+
1998
+ if(!(/^(document|window|parent)$/).test(o.containment)) {
1999
+ ce = $(o.containment)[0];
2000
+ co = $(o.containment).offset();
2001
+ over = ($(ce).css("overflow") !== "hidden");
2002
+
2003
+ this.containment = [
2004
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
2005
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
2006
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
2007
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
2008
+ ];
2009
+ }
2010
+
2011
+ },
2012
+
2013
+ _convertPositionTo: function(d, pos) {
2014
+
2015
+ if(!pos) {
2016
+ pos = this.position;
2017
+ }
2018
+ var mod = d === "absolute" ? 1 : -1,
2019
+ scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
2020
+ scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
2021
+
2022
+ return {
2023
+ top: (
2024
+ pos.top + // The absolute mouse position
2025
+ this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
2026
+ this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
2027
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
2028
+ ),
2029
+ left: (
2030
+ pos.left + // The absolute mouse position
2031
+ this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
2032
+ this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
2033
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
2034
+ )
2035
+ };
2036
+
2037
+ },
2038
+
2039
+ _generatePosition: function(event) {
2040
+
2041
+ var top, left,
2042
+ o = this.options,
2043
+ pageX = event.pageX,
2044
+ pageY = event.pageY,
2045
+ scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
2046
+
2047
+ // This is another very weird special case that only happens for relative elements:
2048
+ // 1. If the css position is relative
2049
+ // 2. and the scroll parent is the document or similar to the offset parent
2050
+ // we have to refresh the relative offset during the scroll so there are no jumps
2051
+ if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
2052
+ this.offset.relative = this._getRelativeOffset();
2053
+ }
2054
+
2055
+ /*
2056
+ * - Position constraining -
2057
+ * Constrain the position to a mix of grid, containment.
2058
+ */
2059
+
2060
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
2061
+
2062
+ if(this.containment) {
2063
+ if(event.pageX - this.offset.click.left < this.containment[0]) {
2064
+ pageX = this.containment[0] + this.offset.click.left;
2065
+ }
2066
+ if(event.pageY - this.offset.click.top < this.containment[1]) {
2067
+ pageY = this.containment[1] + this.offset.click.top;
2068
+ }
2069
+ if(event.pageX - this.offset.click.left > this.containment[2]) {
2070
+ pageX = this.containment[2] + this.offset.click.left;
2071
+ }
2072
+ if(event.pageY - this.offset.click.top > this.containment[3]) {
2073
+ pageY = this.containment[3] + this.offset.click.top;
2074
+ }
2075
+ }
2076
+
2077
+ if(o.grid) {
2078
+ top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
2079
+ pageY = this.containment ? ( (top - this.offset.click.top >= this.containment[1] && top - this.offset.click.top <= this.containment[3]) ? top : ((top - this.offset.click.top >= this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
2080
+
2081
+ left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
2082
+ pageX = this.containment ? ( (left - this.offset.click.left >= this.containment[0] && left - this.offset.click.left <= this.containment[2]) ? left : ((left - this.offset.click.left >= this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
2083
+ }
2084
+
2085
+ }
2086
+
2087
+ return {
2088
+ top: (
2089
+ pageY - // The absolute mouse position
2090
+ this.offset.click.top - // Click offset (relative to the element)
2091
+ this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
2092
+ this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
2093
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
2094
+ ),
2095
+ left: (
2096
+ pageX - // The absolute mouse position
2097
+ this.offset.click.left - // Click offset (relative to the element)
2098
+ this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
2099
+ this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
2100
+ ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
2101
+ )
2102
+ };
2103
+
2104
+ },
2105
+
2106
+ _rearrange: function(event, i, a, hardRefresh) {
2107
+
2108
+ a ? a[0].appendChild(this.placeholder[0]) : i.item[0].parentNode.insertBefore(this.placeholder[0], (this.direction === "down" ? i.item[0] : i.item[0].nextSibling));
2109
+
2110
+ //Various things done here to improve the performance:
2111
+ // 1. we create a setTimeout, that calls refreshPositions
2112
+ // 2. on the instance, we have a counter variable, that get's higher after every append
2113
+ // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
2114
+ // 4. this lets only the last addition to the timeout stack through
2115
+ this.counter = this.counter ? ++this.counter : 1;
2116
+ var counter = this.counter;
2117
+
2118
+ this._delay(function() {
2119
+ if(counter === this.counter) {
2120
+ this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
2121
+ }
2122
+ });
2123
+
2124
+ },
2125
+
2126
+ _clear: function(event, noPropagation) {
2127
+
2128
+ this.reverting = false;
2129
+ // We delay all events that have to be triggered to after the point where the placeholder has been removed and
2130
+ // everything else normalized again
2131
+ var i,
2132
+ delayedTriggers = [];
2133
+
2134
+ // We first have to update the dom position of the actual currentItem
2135
+ // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
2136
+ if(!this._noFinalSort && this.currentItem.parent().length) {
2137
+ this.placeholder.before(this.currentItem);
2138
+ }
2139
+ this._noFinalSort = null;
2140
+
2141
+ if(this.helper[0] === this.currentItem[0]) {
2142
+ for(i in this._storedCSS) {
2143
+ if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
2144
+ this._storedCSS[i] = "";
2145
+ }
2146
+ }
2147
+ this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
2148
+ } else {
2149
+ this.currentItem.show();
2150
+ }
2151
+
2152
+ if(this.fromOutside && !noPropagation) {
2153
+ delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
2154
+ }
2155
+ if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
2156
+ delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
2157
+ }
2158
+
2159
+ // Check if the items Container has Changed and trigger appropriate
2160
+ // events.
2161
+ if (this !== this.currentContainer) {
2162
+ if(!noPropagation) {
2163
+ delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
2164
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
2165
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
2166
+ }
2167
+ }
2168
+
2169
+
2170
+ //Post events to containers
2171
+ for (i = this.containers.length - 1; i >= 0; i--){
2172
+ if(!noPropagation) {
2173
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
2174
+ }
2175
+ if(this.containers[i].containerCache.over) {
2176
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
2177
+ this.containers[i].containerCache.over = 0;
2178
+ }
2179
+ }
2180
+
2181
+ //Do what was originally in plugins
2182
+ if ( this.storedCursor ) {
2183
+ this.document.find( "body" ).css( "cursor", this.storedCursor );
2184
+ this.storedStylesheet.remove();
2185
+ }
2186
+ if(this._storedOpacity) {
2187
+ this.helper.css("opacity", this._storedOpacity);
2188
+ }
2189
+ if(this._storedZIndex) {
2190
+ this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
2191
+ }
2192
+
2193
+ this.dragging = false;
2194
+ if(this.cancelHelperRemoval) {
2195
+ if(!noPropagation) {
2196
+ this._trigger("beforeStop", event, this._uiHash());
2197
+ for (i=0; i < delayedTriggers.length; i++) {
2198
+ delayedTriggers[i].call(this, event);
2199
+ } //Trigger all delayed events
2200
+ this._trigger("stop", event, this._uiHash());
2201
+ }
2202
+
2203
+ this.fromOutside = false;
2204
+ return false;
2205
+ }
2206
+
2207
+ if(!noPropagation) {
2208
+ this._trigger("beforeStop", event, this._uiHash());
2209
+ }
2210
+
2211
+ //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
2212
+ this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
2213
+
2214
+ if(this.helper[0] !== this.currentItem[0]) {
2215
+ this.helper.remove();
2216
+ }
2217
+ this.helper = null;
2218
+
2219
+ if(!noPropagation) {
2220
+ for (i=0; i < delayedTriggers.length; i++) {
2221
+ delayedTriggers[i].call(this, event);
2222
+ } //Trigger all delayed events
2223
+ this._trigger("stop", event, this._uiHash());
2224
+ }
2225
+
2226
+ this.fromOutside = false;
2227
+ return true;
2228
+
2229
+ },
2230
+
2231
+ _trigger: function() {
2232
+ if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
2233
+ this.cancel();
2234
+ }
2235
+ },
2236
+
2237
+ _uiHash: function(_inst) {
2238
+ var inst = _inst || this;
2239
+ return {
2240
+ helper: inst.helper,
2241
+ placeholder: inst.placeholder || $([]),
2242
+ position: inst.position,
2243
+ originalPosition: inst.originalPosition,
2244
+ offset: inst.positionAbs,
2245
+ item: inst.currentItem,
2246
+ sender: _inst ? _inst.element : null
2247
+ };
2248
+ }
2249
+
2250
+ });
2251
+
2252
+ })(jQuery);