benmanns-atreides 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (449) hide show
  1. data/LICENSE +7 -0
  2. data/README.rdoc +1 -0
  3. data/app/assets/javascripts/atreides/admin.facebook.js +137 -0
  4. data/app/assets/javascripts/atreides/admin.js +23 -0
  5. data/app/assets/javascripts/atreides/admin_base.js.erb +273 -0
  6. data/app/assets/javascripts/atreides/admin_edit.js +9 -0
  7. data/app/assets/javascripts/atreides/application.js +15 -0
  8. data/app/assets/javascripts/atreides/public.js +24 -0
  9. data/app/assets/javascripts/atreides/public_base.js.erb +119 -0
  10. data/app/assets/javascripts/atreides/terryblr.js +57 -0
  11. data/app/assets/stylesheets/atreides/admin.css +21 -0
  12. data/app/assets/stylesheets/atreides/admin_base.css.erb +1693 -0
  13. data/app/assets/stylesheets/atreides/application.css +13 -0
  14. data/app/assets/stylesheets/atreides/formtastic_changes.css +10 -0
  15. data/app/assets/stylesheets/atreides/iphone-checkboxes.css.erb +97 -0
  16. data/app/assets/stylesheets/atreides/jBreadCrumb.css +109 -0
  17. data/app/assets/stylesheets/atreides/public.css +15 -0
  18. data/app/assets/stylesheets/atreides/public_base.css +101 -0
  19. data/app/assets/stylesheets/atreides/swfupload.css.erb +63 -0
  20. data/app/controllers/admin/atreides/content_parts_controller.rb +43 -0
  21. data/app/controllers/admin/atreides/dropbox_controller.rb +40 -0
  22. data/app/controllers/admin/atreides/facebook_controller.rb +38 -0
  23. data/app/controllers/admin/atreides/features_controller.rb +63 -0
  24. data/app/controllers/admin/atreides/github_controller.rb +35 -0
  25. data/app/controllers/admin/atreides/links_controller.rb +3 -0
  26. data/app/controllers/admin/atreides/messages_controller.rb +3 -0
  27. data/app/controllers/admin/atreides/orders_controller.rb +35 -0
  28. data/app/controllers/admin/atreides/pages_controller.rb +59 -0
  29. data/app/controllers/admin/atreides/photos_controller.rb +79 -0
  30. data/app/controllers/admin/atreides/posts_controller.rb +109 -0
  31. data/app/controllers/admin/atreides/products_controller.rb +39 -0
  32. data/app/controllers/admin/atreides/sessions_controller.rb +7 -0
  33. data/app/controllers/admin/atreides/sizes_controller.rb +4 -0
  34. data/app/controllers/admin/atreides/tags_controller.rb +20 -0
  35. data/app/controllers/admin/atreides/users_controller.rb +50 -0
  36. data/app/controllers/admin/atreides/videos_controller.rb +53 -0
  37. data/app/controllers/atreides/admin_controller.rb +96 -0
  38. data/app/controllers/atreides/admin_home_controller.rb +215 -0
  39. data/app/controllers/atreides/application_controller.rb +93 -0
  40. data/app/controllers/atreides/home_controller.rb +71 -0
  41. data/app/controllers/atreides/likes_controller.rb +44 -0
  42. data/app/controllers/atreides/pages_controller.rb +34 -0
  43. data/app/controllers/atreides/posts_controller.rb +119 -0
  44. data/app/controllers/atreides/public_controller.rb +43 -0
  45. data/app/helpers/admin/atreides/dropbox_helper.rb +42 -0
  46. data/app/helpers/admin/atreides/features_helper.rb +4 -0
  47. data/app/helpers/admin/atreides/github_helper.rb +43 -0
  48. data/app/helpers/admin/atreides/links_helper.rb +4 -0
  49. data/app/helpers/admin/atreides/messages_helper.rb +4 -0
  50. data/app/helpers/admin/atreides/orders_helper.rb +30 -0
  51. data/app/helpers/admin/atreides/pages_helper.rb +17 -0
  52. data/app/helpers/admin/atreides/photos_helper.rb +14 -0
  53. data/app/helpers/admin/atreides/posts_helper.rb +41 -0
  54. data/app/helpers/admin/atreides/products_helper.rb +37 -0
  55. data/app/helpers/admin/atreides/sizes_helper.rb +4 -0
  56. data/app/helpers/admin/atreides/user_sessions_helper.rb +4 -0
  57. data/app/helpers/admin/atreides/users_helper.rb +8 -0
  58. data/app/helpers/admin/atreides/videos_helper.rb +4 -0
  59. data/app/helpers/atreides/admin_helper.rb +243 -0
  60. data/app/helpers/atreides/admin_home_helper.rb +4 -0
  61. data/app/helpers/atreides/application_helper.rb +210 -0
  62. data/app/helpers/atreides/home_helper.rb +4 -0
  63. data/app/helpers/atreides/posts_helper.rb +119 -0
  64. data/app/inputs/files_input.rb +13 -0
  65. data/app/inputs/price_input.rb +18 -0
  66. data/app/inputs/underline_input.rb +16 -0
  67. data/app/models/atreides/ability.rb +24 -0
  68. data/app/models/atreides/content_part.rb +106 -0
  69. data/app/models/atreides/facebook_user.rb +103 -0
  70. data/app/models/atreides/feature.rb +90 -0
  71. data/app/models/atreides/github.rb +74 -0
  72. data/app/models/atreides/like.rb +35 -0
  73. data/app/models/atreides/line_item.rb +4 -0
  74. data/app/models/atreides/link.rb +32 -0
  75. data/app/models/atreides/message.rb +34 -0
  76. data/app/models/atreides/order.rb +209 -0
  77. data/app/models/atreides/page.rb +114 -0
  78. data/app/models/atreides/photo.rb +130 -0
  79. data/app/models/atreides/post.rb +271 -0
  80. data/app/models/atreides/preferences.rb +31 -0
  81. data/app/models/atreides/product.rb +75 -0
  82. data/app/models/atreides/site.rb +59 -0
  83. data/app/models/atreides/size.rb +44 -0
  84. data/app/models/atreides/tag.rb +31 -0
  85. data/app/models/atreides/tweet.rb +123 -0
  86. data/app/models/atreides/user.rb +129 -0
  87. data/app/models/atreides/video.rb +206 -0
  88. data/app/models/atreides/vote.rb +43 -0
  89. data/app/models/fb_post_publisher_job.rb +72 -0
  90. data/app/models/settings.rb +19 -0
  91. data/app/models/tumblr_post_publisher_job.rb +75 -0
  92. data/app/models/tw_post_publisher_job.rb +54 -0
  93. data/app/views/admin/_edit_head_content.html.haml +2 -0
  94. data/app/views/admin/atreides/content_parts/_form.html.haml +21 -0
  95. data/app/views/admin/atreides/content_parts/_photos.html.haml +18 -0
  96. data/app/views/admin/atreides/content_parts/_text.html.haml +1 -0
  97. data/app/views/admin/atreides/content_parts/_videos.html.haml +12 -0
  98. data/app/views/admin/atreides/content_parts/destroy.js.haml +3 -0
  99. data/app/views/admin/atreides/content_parts/edit.html.haml +0 -0
  100. data/app/views/admin/atreides/content_parts/new.html.haml +0 -0
  101. data/app/views/admin/atreides/content_parts/new.js.haml +11 -0
  102. data/app/views/admin/atreides/dropbox/_uploader.html.haml +134 -0
  103. data/app/views/admin/atreides/dropbox/list.html.haml +27 -0
  104. data/app/views/admin/atreides/dropbox/setup.html.haml +8 -0
  105. data/app/views/admin/atreides/facebook/index.html.haml +29 -0
  106. data/app/views/admin/atreides/features/_form.html.haml +60 -0
  107. data/app/views/admin/atreides/features/edit.html.haml +1 -0
  108. data/app/views/admin/atreides/features/index.html.haml +24 -0
  109. data/app/views/admin/atreides/features/new.html.haml +1 -0
  110. data/app/views/admin/atreides/github/index.html.haml +26 -0
  111. data/app/views/admin/atreides/github/show.html.haml +19 -0
  112. data/app/views/admin/atreides/likes/create.js.haml +2 -0
  113. data/app/views/admin/atreides/orders/_sidebar.html.haml +20 -0
  114. data/app/views/admin/atreides/orders/edit.html.haml +52 -0
  115. data/app/views/admin/atreides/orders/index.html.haml +8 -0
  116. data/app/views/admin/atreides/pages/_form.html.haml +31 -0
  117. data/app/views/admin/atreides/pages/edit.html.haml +3 -0
  118. data/app/views/admin/atreides/pages/index.html.haml +15 -0
  119. data/app/views/admin/atreides/pages/index.js.haml +4 -0
  120. data/app/views/admin/atreides/pages/new.html.haml +2 -0
  121. data/app/views/admin/atreides/photos/create.js.haml +18 -0
  122. data/app/views/admin/atreides/photos/destroy.js.haml +3 -0
  123. data/app/views/admin/atreides/posts/_archives.html.haml +19 -0
  124. data/app/views/admin/atreides/posts/_form.html.haml +66 -0
  125. data/app/views/admin/atreides/posts/_form_buttons.html.haml +9 -0
  126. data/app/views/admin/atreides/posts/_form_sidebar.html.haml +85 -0
  127. data/app/views/admin/atreides/posts/edit.html.haml +2 -0
  128. data/app/views/admin/atreides/posts/index.html.haml +24 -0
  129. data/app/views/admin/atreides/posts/index.js.haml +1 -0
  130. data/app/views/admin/atreides/posts/new.html.haml +2 -0
  131. data/app/views/admin/atreides/products/edit.html.haml +69 -0
  132. data/app/views/admin/atreides/products/index.html.haml +31 -0
  133. data/app/views/admin/atreides/sessions/new.html.haml +13 -0
  134. data/app/views/admin/atreides/user_sessions/new.html.haml +10 -0
  135. data/app/views/admin/atreides/users/_form.html.haml +19 -0
  136. data/app/views/admin/atreides/users/edit.html.haml +6 -0
  137. data/app/views/admin/atreides/users/index.html.haml +11 -0
  138. data/app/views/admin/atreides/users/new.html.haml +6 -0
  139. data/app/views/admin/atreides/users/show.html.haml +4 -0
  140. data/app/views/admin/atreides/videos/create.js.haml +9 -0
  141. data/app/views/admin/atreides/videos/destroy.js.haml +3 -0
  142. data/app/views/admin/common/_archive_sidebar.html.haml +28 -0
  143. data/app/views/admin/common/_list_table.html.erb +37 -0
  144. data/app/views/admin/common/_list_table_row.html.erb +18 -0
  145. data/app/views/admin/common/_pagination.html.erb +1 -0
  146. data/app/views/admin/common/_search_form.html.erb +6 -0
  147. data/app/views/admin/common/access_denied.html.haml +1 -0
  148. data/app/views/atreides/admin/_content_nav.html.haml +7 -0
  149. data/app/views/atreides/admin_home/_analytics.html.haml +93 -0
  150. data/app/views/atreides/admin_home/_fb_page_likes_analytics_tbody.haml +10 -0
  151. data/app/views/atreides/admin_home/_fb_page_views_analytics_tbody.haml +10 -0
  152. data/app/views/atreides/admin_home/_top_landing_pages_analytics_tbody.haml +14 -0
  153. data/app/views/atreides/admin_home/_top_referrers_analytics_tbody.haml +12 -0
  154. data/app/views/atreides/admin_home/_tweets_analytics_tbody.html.haml +8 -0
  155. data/app/views/atreides/admin_home/_visitors_analytics_tbody.html.haml +12 -0
  156. data/app/views/atreides/admin_home/index.html.haml +57 -0
  157. data/app/views/atreides/admin_home/search.html.haml +11 -0
  158. data/app/views/atreides/admin_home/setup.html.haml +15 -0
  159. data/app/views/atreides/common/_gallery_params.xml.erb +174 -0
  160. data/app/views/atreides/common/slideshow.xml.haml +6 -0
  161. data/app/views/atreides/errors/404.html.haml +10 -0
  162. data/app/views/atreides/errors/500.html.haml +4 -0
  163. data/app/views/atreides/home/index.html.haml +30 -0
  164. data/app/views/atreides/home/index.js.haml +1 -0
  165. data/app/views/atreides/home/robots.txt.erb +5 -0
  166. data/app/views/atreides/home/sitemap.xml.builder +35 -0
  167. data/app/views/atreides/pages/show.html.haml +3 -0
  168. data/app/views/atreides/posts/_archives.html.haml +19 -0
  169. data/app/views/atreides/posts/_featured_posts.html.haml +10 -0
  170. data/app/views/atreides/posts/_list.html.haml +9 -0
  171. data/app/views/atreides/posts/archives.html.haml +3 -0
  172. data/app/views/atreides/posts/archives.js.haml +1 -0
  173. data/app/views/atreides/posts/gallery_params.xml.haml +1 -0
  174. data/app/views/atreides/posts/index.atom.builder +22 -0
  175. data/app/views/atreides/posts/index.html.haml +13 -0
  176. data/app/views/atreides/posts/index.rss.builder +21 -0
  177. data/app/views/atreides/posts/show.html.haml +8 -0
  178. data/app/views/atreides/posts/tagged.html.haml +4 -0
  179. data/app/views/atreides/posts/tagged.js.haml +1 -0
  180. data/app/views/layouts/admin.html.haml +65 -0
  181. data/app/views/layouts/application.html.haml +37 -0
  182. data/app/views/layouts/atreides/application.html.erb +14 -0
  183. data/app/views/layouts/public.html.haml +39 -0
  184. data/config/cucumber.yml +11 -0
  185. data/config/locales/en.yml +207 -0
  186. data/config/locales/fr.yml +199 -0
  187. data/config/routes.rb +119 -0
  188. data/lib/assets/images/atreides/admin/add.png +0 -0
  189. data/lib/assets/images/atreides/admin/add_btn.png +0 -0
  190. data/lib/assets/images/atreides/admin/add_dashboard.png +0 -0
  191. data/lib/assets/images/atreides/admin/add_photo_button_sprite.png +0 -0
  192. data/lib/assets/images/atreides/admin/add_photos_btn.png +0 -0
  193. data/lib/assets/images/atreides/admin/background.png +0 -0
  194. data/lib/assets/images/atreides/admin/calendar.png +0 -0
  195. data/lib/assets/images/atreides/admin/chevron.gif +0 -0
  196. data/lib/assets/images/atreides/admin/chevron_overlay.png +0 -0
  197. data/lib/assets/images/atreides/admin/choose_photos_button_sprite.png +0 -0
  198. data/lib/assets/images/atreides/admin/content_bg.png +0 -0
  199. data/lib/assets/images/atreides/admin/content_bg_edit_form.png +0 -0
  200. data/lib/assets/images/atreides/admin/content_part_break.png +0 -0
  201. data/lib/assets/images/atreides/admin/content_part_drop_target.png +0 -0
  202. data/lib/assets/images/atreides/admin/content_part_icons.png +0 -0
  203. data/lib/assets/images/atreides/admin/content_part_photos.png +0 -0
  204. data/lib/assets/images/atreides/admin/content_part_text.png +0 -0
  205. data/lib/assets/images/atreides/admin/content_part_videos.png +0 -0
  206. data/lib/assets/images/atreides/admin/content_top_edit_form.png +0 -0
  207. data/lib/assets/images/atreides/admin/dashboard-indicator.gif +0 -0
  208. data/lib/assets/images/atreides/admin/dashboard_controls_activity.png +0 -0
  209. data/lib/assets/images/atreides/admin/dashboard_controls_customize.png +0 -0
  210. data/lib/assets/images/atreides/admin/dashboard_controls_drafts.png +0 -0
  211. data/lib/assets/images/atreides/admin/dashboard_controls_open.png +0 -0
  212. data/lib/assets/images/atreides/admin/dashboard_controls_posts.png +0 -0
  213. data/lib/assets/images/atreides/admin/dashboard_controls_queue.png +0 -0
  214. data/lib/assets/images/atreides/admin/dashboard_nav_border.png +0 -0
  215. data/lib/assets/images/atreides/admin/delete_bg.png +0 -0
  216. data/lib/assets/images/atreides/admin/down_arrow.png +0 -0
  217. data/lib/assets/images/atreides/admin/dropbox_big.jpg +0 -0
  218. data/lib/assets/images/atreides/admin/dropbox_btn.png +0 -0
  219. data/lib/assets/images/atreides/admin/dropbox_folder.png +0 -0
  220. data/lib/assets/images/atreides/admin/dropbox_icon.gif +0 -0
  221. data/lib/assets/images/atreides/admin/dropbox_icon.png +0 -0
  222. data/lib/assets/images/atreides/admin/expand_collapse.png +0 -0
  223. data/lib/assets/images/atreides/admin/form_sidebar_divider.png +0 -0
  224. data/lib/assets/images/atreides/admin/grey_hatch_bg.png +0 -0
  225. data/lib/assets/images/atreides/admin/header.png +0 -0
  226. data/lib/assets/images/atreides/admin/icon_dropbox.gif +0 -0
  227. data/lib/assets/images/atreides/admin/icon_home.gif +0 -0
  228. data/lib/assets/images/atreides/admin/input_bg.gif +0 -0
  229. data/lib/assets/images/atreides/admin/large_loading.gif +0 -0
  230. data/lib/assets/images/atreides/admin/new_content_icons.png +0 -0
  231. data/lib/assets/images/atreides/admin/off.png +0 -0
  232. data/lib/assets/images/atreides/admin/on.png +0 -0
  233. data/lib/assets/images/atreides/admin/page_icon.png +0 -0
  234. data/lib/assets/images/atreides/admin/permalink.png +0 -0
  235. data/lib/assets/images/atreides/admin/photos-display-type-gallery.png +0 -0
  236. data/lib/assets/images/atreides/admin/photos-display-type-photos.png +0 -0
  237. data/lib/assets/images/atreides/admin/product.png +0 -0
  238. data/lib/assets/images/atreides/admin/remove.png +0 -0
  239. data/lib/assets/images/atreides/admin/resize.png +0 -0
  240. data/lib/assets/images/atreides/admin/save_btn.png +0 -0
  241. data/lib/assets/images/atreides/admin/search_icon.png +0 -0
  242. data/lib/assets/images/atreides/admin/select_arrows.png +0 -0
  243. data/lib/assets/images/atreides/admin/slider.png +0 -0
  244. data/lib/assets/images/atreides/admin/slider_center.png +0 -0
  245. data/lib/assets/images/atreides/admin/slider_left.png +0 -0
  246. data/lib/assets/images/atreides/admin/slider_right.png +0 -0
  247. data/lib/assets/images/atreides/admin/sprite.png +0 -0
  248. data/lib/assets/images/atreides/admin/upload_btn.png +0 -0
  249. data/lib/assets/images/atreides/admin/video_bg.png +0 -0
  250. data/lib/assets/images/atreides/blank.gif +0 -0
  251. data/lib/assets/images/atreides/closelabel.png +0 -0
  252. data/lib/assets/images/atreides/loading.gif +0 -0
  253. data/lib/assets/images/atreides/sprite.png +0 -0
  254. data/lib/assets/images/atreides/tipsy.gif +0 -0
  255. data/lib/atreides.rb +81 -0
  256. data/lib/atreides/base/aasmstates.rb +117 -0
  257. data/lib/atreides/base/base.rb +40 -0
  258. data/lib/atreides/base/taggable.rb +43 -0
  259. data/lib/atreides/base/validation.rb +23 -0
  260. data/lib/atreides/configuration.rb +61 -0
  261. data/lib/atreides/engine.rb +41 -0
  262. data/lib/atreides/extendable.rb +12 -0
  263. data/lib/atreides/i18n_helpers.rb +65 -0
  264. data/lib/atreides/railties/tasks.rake +68 -0
  265. data/lib/atreides/time_formats.rb +19 -0
  266. data/lib/atreides/validators.rb +15 -0
  267. data/lib/atreides/version.rb +4 -0
  268. data/lib/generators/atreides/USAGE +0 -0
  269. data/lib/generators/atreides/atreides_generator.rb +57 -0
  270. data/lib/generators/templates/Procfile +2 -0
  271. data/lib/generators/templates/add_role_to_users.rb +16 -0
  272. data/lib/generators/templates/add_userid_to_resources.rb +15 -0
  273. data/lib/generators/templates/create_content_parts.rb +66 -0
  274. data/lib/generators/templates/create_features.rb +21 -0
  275. data/lib/generators/templates/create_likes.rb +16 -0
  276. data/lib/generators/templates/create_line_items.rb +21 -0
  277. data/lib/generators/templates/create_links.rb +16 -0
  278. data/lib/generators/templates/create_messages.rb +24 -0
  279. data/lib/generators/templates/create_orders.rb +31 -0
  280. data/lib/generators/templates/create_pages.rb +29 -0
  281. data/lib/generators/templates/create_photos.rb +22 -0
  282. data/lib/generators/templates/create_posts.rb +36 -0
  283. data/lib/generators/templates/create_preferences.rb +14 -0
  284. data/lib/generators/templates/create_products.rb +22 -0
  285. data/lib/generators/templates/create_sessions.rb +16 -0
  286. data/lib/generators/templates/create_sites.rb +35 -0
  287. data/lib/generators/templates/create_sizes.rb +16 -0
  288. data/lib/generators/templates/create_tweets.rb +25 -0
  289. data/lib/generators/templates/create_videos.rb +24 -0
  290. data/lib/generators/templates/create_votes.rb +20 -0
  291. data/lib/generators/templates/delayed_job.rb +5 -0
  292. data/lib/generators/templates/devise_create_users.rb +42 -0
  293. data/lib/generators/templates/em-net-http_override.rb +74 -0
  294. data/lib/generators/templates/initializer.rb +21 -0
  295. data/lib/generators/templates/new_relic.rb +6 -0
  296. data/lib/generators/templates/oembed.yml +63 -0
  297. data/lib/generators/templates/settings.yml +78 -0
  298. data/lib/generators/templates/string_extensions.rb +20 -0
  299. data/lib/generators/templates/unicorn.rb +2 -0
  300. data/lib/tasks/atreides_tasks.rake +4 -0
  301. data/lib/tasks/cucumber.rake +58 -0
  302. data/lib/tasks/tasks.rake +403 -0
  303. data/lib/tasks/yard.rake +18 -0
  304. data/vendor/assets/flash/atreides/player.swf +0 -0
  305. data/vendor/assets/flash/atreides/slideshowpro.swf +0 -0
  306. data/vendor/assets/flash/atreides/swfupload.swf +0 -0
  307. data/vendor/assets/images/atreides/share/aim_16.png +0 -0
  308. data/vendor/assets/images/atreides/share/apple_16.png +0 -0
  309. data/vendor/assets/images/atreides/share/bebo_16.png +0 -0
  310. data/vendor/assets/images/atreides/share/blogger_16.png +0 -0
  311. data/vendor/assets/images/atreides/share/brightkite_16.png +0 -0
  312. data/vendor/assets/images/atreides/share/cargo_16.png +0 -0
  313. data/vendor/assets/images/atreides/share/delicious_16.png +0 -0
  314. data/vendor/assets/images/atreides/share/designfloat_16.png +0 -0
  315. data/vendor/assets/images/atreides/share/designmoo_16.png +0 -0
  316. data/vendor/assets/images/atreides/share/deviantart_16.png +0 -0
  317. data/vendor/assets/images/atreides/share/digg_16.png +0 -0
  318. data/vendor/assets/images/atreides/share/digg_alt_16.png +0 -0
  319. data/vendor/assets/images/atreides/share/dopplr_16.png +0 -0
  320. data/vendor/assets/images/atreides/share/dribbble_16.png +0 -0
  321. data/vendor/assets/images/atreides/share/email_16.png +0 -0
  322. data/vendor/assets/images/atreides/share/ember_16.png +0 -0
  323. data/vendor/assets/images/atreides/share/evernote_16.png +0 -0
  324. data/vendor/assets/images/atreides/share/facebook_16.png +0 -0
  325. data/vendor/assets/images/atreides/share/flickr_16.png +0 -0
  326. data/vendor/assets/images/atreides/share/friendfeed_16.png +0 -0
  327. data/vendor/assets/images/atreides/share/gamespot_16.png +0 -0
  328. data/vendor/assets/images/atreides/share/google_16.png +0 -0
  329. data/vendor/assets/images/atreides/share/google_voice_16.png +0 -0
  330. data/vendor/assets/images/atreides/share/google_wave_16.png +0 -0
  331. data/vendor/assets/images/atreides/share/googletalk_16.png +0 -0
  332. data/vendor/assets/images/atreides/share/gowalla_16.png +0 -0
  333. data/vendor/assets/images/atreides/share/grooveshark_16.png +0 -0
  334. data/vendor/assets/images/atreides/share/ilike_16.png +0 -0
  335. data/vendor/assets/images/atreides/share/komodomedia_azure_16.png +0 -0
  336. data/vendor/assets/images/atreides/share/komodomedia_wood_16.png +0 -0
  337. data/vendor/assets/images/atreides/share/lastfm_16.png +0 -0
  338. data/vendor/assets/images/atreides/share/license.txt +9 -0
  339. data/vendor/assets/images/atreides/share/linkedin_16.png +0 -0
  340. data/vendor/assets/images/atreides/share/mixx_16.png +0 -0
  341. data/vendor/assets/images/atreides/share/mobileme_16.png +0 -0
  342. data/vendor/assets/images/atreides/share/mynameise_16.png +0 -0
  343. data/vendor/assets/images/atreides/share/myspace_16.png +0 -0
  344. data/vendor/assets/images/atreides/share/netvibes_16.png +0 -0
  345. data/vendor/assets/images/atreides/share/newsvine_16.png +0 -0
  346. data/vendor/assets/images/atreides/share/openid_16.png +0 -0
  347. data/vendor/assets/images/atreides/share/orkut_16.png +0 -0
  348. data/vendor/assets/images/atreides/share/pandora_16.png +0 -0
  349. data/vendor/assets/images/atreides/share/paypal_16.png +0 -0
  350. data/vendor/assets/images/atreides/share/picasa_16.png +0 -0
  351. data/vendor/assets/images/atreides/share/plurk_16.png +0 -0
  352. data/vendor/assets/images/atreides/share/posterous_16.png +0 -0
  353. data/vendor/assets/images/atreides/share/qik_16.png +0 -0
  354. data/vendor/assets/images/atreides/share/readernaut_16.png +0 -0
  355. data/vendor/assets/images/atreides/share/reddit_16.png +0 -0
  356. data/vendor/assets/images/atreides/share/roboto_16.png +0 -0
  357. data/vendor/assets/images/atreides/share/rss_16.png +0 -0
  358. data/vendor/assets/images/atreides/share/sharethis_16.png +0 -0
  359. data/vendor/assets/images/atreides/share/skype_16.png +0 -0
  360. data/vendor/assets/images/atreides/share/stumbleupon_16.png +0 -0
  361. data/vendor/assets/images/atreides/share/technorati_16.png +0 -0
  362. data/vendor/assets/images/atreides/share/tumblr_16.png +0 -0
  363. data/vendor/assets/images/atreides/share/twitter_16.png +0 -0
  364. data/vendor/assets/images/atreides/share/viddler_16.png +0 -0
  365. data/vendor/assets/images/atreides/share/vimeo_16.png +0 -0
  366. data/vendor/assets/images/atreides/share/virb_16.png +0 -0
  367. data/vendor/assets/images/atreides/share/windows_16.png +0 -0
  368. data/vendor/assets/images/atreides/share/wordpress_16.png +0 -0
  369. data/vendor/assets/images/atreides/share/xing_16.png +0 -0
  370. data/vendor/assets/images/atreides/share/yahoo_16.png +0 -0
  371. data/vendor/assets/images/atreides/share/yahoobuzz_16.png +0 -0
  372. data/vendor/assets/images/atreides/share/yelp_16.png +0 -0
  373. data/vendor/assets/images/atreides/share/youtube_16.png +0 -0
  374. data/vendor/assets/javascripts/atreides/backbone-0.3.3.js +1100 -0
  375. data/vendor/assets/javascripts/atreides/cufon-yui.js +7 -0
  376. data/vendor/assets/javascripts/atreides/facebox.js +309 -0
  377. data/vendor/assets/javascripts/atreides/fileuploader.js +1250 -0
  378. data/vendor/assets/javascripts/atreides/g.raphael-min.js +7 -0
  379. data/vendor/assets/javascripts/atreides/galleria.js +2 -0
  380. data/vendor/assets/javascripts/atreides/galleria/src/galleria.js +3816 -0
  381. data/vendor/assets/javascripts/atreides/galleria/src/plugins/galleria.flickr.js +221 -0
  382. data/vendor/assets/javascripts/atreides/galleria/src/plugins/galleria.history.js +602 -0
  383. data/vendor/assets/javascripts/atreides/galleria/src/themes/classic/classic-loader.gif +0 -0
  384. data/vendor/assets/javascripts/atreides/galleria/src/themes/classic/classic-map.png +0 -0
  385. data/vendor/assets/javascripts/atreides/galleria/src/themes/classic/galleria.classic.css +202 -0
  386. data/vendor/assets/javascripts/atreides/galleria/src/themes/classic/galleria.classic.js +92 -0
  387. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/b.png +0 -0
  388. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/down.gif +0 -0
  389. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/fix.gif +0 -0
  390. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/fullscreen-demo.html +34 -0
  391. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/galleria.fullscreen.css +46 -0
  392. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/galleria.fullscreen.js +193 -0
  393. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/i.png +0 -0
  394. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/l.gif +0 -0
  395. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/l2.png +0 -0
  396. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/loader.gif +0 -0
  397. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/n.gif +0 -0
  398. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/p.gif +0 -0
  399. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/r.gif +0 -0
  400. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/r2.png +0 -0
  401. data/vendor/assets/javascripts/atreides/galleria/src/themes/fullscreen/up.gif +0 -0
  402. data/vendor/assets/javascripts/atreides/jquery-1.7.js +4 -0
  403. data/vendor/assets/javascripts/atreides/jquery-ui.js +11603 -0
  404. data/vendor/assets/javascripts/atreides/jquery.autogrow.js +132 -0
  405. data/vendor/assets/javascripts/atreides/jquery.cookie.js +96 -0
  406. data/vendor/assets/javascripts/atreides/jquery.countdown.js +759 -0
  407. data/vendor/assets/javascripts/atreides/jquery.cycle.js +918 -0
  408. data/vendor/assets/javascripts/atreides/jquery.easing.1.3.js +205 -0
  409. data/vendor/assets/javascripts/atreides/jquery.flash.js +288 -0
  410. data/vendor/assets/javascripts/atreides/jquery.iphone-checkboxes.js +214 -0
  411. data/vendor/assets/javascripts/atreides/jquery.jBreadCrumb.1.1.js +240 -0
  412. data/vendor/assets/javascripts/atreides/jquery.multipleselectbox-min.js +15 -0
  413. data/vendor/assets/javascripts/atreides/jquery.multipleselectbox.js +446 -0
  414. data/vendor/assets/javascripts/atreides/jquery.swfupload.js +64 -0
  415. data/vendor/assets/javascripts/atreides/jquery.tipsy.js +104 -0
  416. data/vendor/assets/javascripts/atreides/jquery.uniform.js +461 -0
  417. data/vendor/assets/javascripts/atreides/jquery_ujs.js +316 -0
  418. data/vendor/assets/javascripts/atreides/jtags.js +125 -0
  419. data/vendor/assets/javascripts/atreides/raphael-min.js +7 -0
  420. data/vendor/assets/javascripts/atreides/raphael.analytics.js +205 -0
  421. data/vendor/assets/javascripts/atreides/raphael.path.methods.js +53 -0
  422. data/vendor/assets/javascripts/atreides/raphael.pie.js +44 -0
  423. data/vendor/assets/javascripts/atreides/sifr.js +18 -0
  424. data/vendor/assets/javascripts/atreides/swfobject.js +4 -0
  425. data/vendor/assets/javascripts/atreides/swfupload/handlers.js +290 -0
  426. data/vendor/assets/javascripts/atreides/swfupload/swfupload.cookies.js +53 -0
  427. data/vendor/assets/javascripts/atreides/swfupload/swfupload.js +980 -0
  428. data/vendor/assets/javascripts/atreides/swfupload/swfupload.queue.js +98 -0
  429. data/vendor/assets/javascripts/atreides/swfupload/swfupload.speed.js +342 -0
  430. data/vendor/assets/javascripts/atreides/swfupload/swfupload.swfobject.js +111 -0
  431. data/vendor/assets/javascripts/atreides/underscore-1.1.6.js +807 -0
  432. data/vendor/assets/stylesheets/atreides/admin_grid.css +258 -0
  433. data/vendor/assets/stylesheets/atreides/facebox.css +80 -0
  434. data/vendor/assets/stylesheets/atreides/formtastic.css +144 -0
  435. data/vendor/assets/stylesheets/atreides/galleria.css +24 -0
  436. data/vendor/assets/stylesheets/atreides/ie.css +35 -0
  437. data/vendor/assets/stylesheets/atreides/images/bg_fallback.png +0 -0
  438. data/vendor/assets/stylesheets/atreides/images/icon_sprite.png +0 -0
  439. data/vendor/assets/stylesheets/atreides/images/progress_bar.gif +0 -0
  440. data/vendor/assets/stylesheets/atreides/images/slider_handles.png +0 -0
  441. data/vendor/assets/stylesheets/atreides/images/ui-icons_222222_256x240.png +0 -0
  442. data/vendor/assets/stylesheets/atreides/images/ui-icons_454545_256x240.png +0 -0
  443. data/vendor/assets/stylesheets/atreides/jquery-ui.css +738 -0
  444. data/vendor/assets/stylesheets/atreides/multipleselectbox.css +33 -0
  445. data/vendor/assets/stylesheets/atreides/print.css +29 -0
  446. data/vendor/assets/stylesheets/atreides/public_grid.css +258 -0
  447. data/vendor/assets/stylesheets/atreides/tipsy.css +7 -0
  448. data/vendor/assets/stylesheets/atreides/uniform.default.css +476 -0
  449. metadata +1566 -0
@@ -0,0 +1,9 @@
1
+ If you use these icons, please place an attribution link to komodomedia.com. Social Network Icon Pack by Rogie King is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License (http://creativecommons.org/licenses/by-nc-sa/3.0/).
2
+
3
+ Based on a work at www.komodomedia.com.
4
+
5
+ More rad downloads can be found at http://www.komodomedia.com/download/
6
+
7
+ Feelin' the love? Donate to Paypal: rogie@komodomedia.com
8
+
9
+ I claim no right of ownership to the respective company logos and glyphs in each one of these icons.
@@ -0,0 +1,1100 @@
1
+ // Backbone.js 0.3.3
2
+ // (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // Backbone may be freely distributed under the MIT license.
4
+ // For all details and documentation:
5
+ // http://documentcloud.github.com/backbone
6
+
7
+ (function(){
8
+
9
+ // Initial Setup
10
+ // -------------
11
+
12
+ // Save a reference to the global object.
13
+ var root = this;
14
+
15
+ // Save the previous value of the `Backbone` variable.
16
+ var previousBackbone = root.Backbone;
17
+
18
+ // The top-level namespace. All public Backbone classes and modules will
19
+ // be attached to this. Exported for both CommonJS and the browser.
20
+ var Backbone;
21
+ if (typeof exports !== 'undefined') {
22
+ Backbone = exports;
23
+ } else {
24
+ Backbone = root.Backbone = {};
25
+ }
26
+
27
+ // Current version of the library. Keep in sync with `package.json`.
28
+ Backbone.VERSION = '0.3.3';
29
+
30
+ // Require Underscore, if we're on the server, and it's not already present.
31
+ var _ = root._;
32
+ if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;
33
+
34
+ // For Backbone's purposes, jQuery or Zepto owns the `$` variable.
35
+ var $ = root.jQuery || root.Zepto;
36
+
37
+ // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
38
+ // to its previous owner. Returns a reference to this Backbone object.
39
+ Backbone.noConflict = function() {
40
+ root.Backbone = previousBackbone;
41
+ return this;
42
+ };
43
+
44
+ // Turn on `emulateHTTP` to use support legacy HTTP servers. Setting this option will
45
+ // fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and set a
46
+ // `X-Http-Method-Override` header.
47
+ Backbone.emulateHTTP = false;
48
+
49
+ // Turn on `emulateJSON` to support legacy servers that can't deal with direct
50
+ // `application/json` requests ... will encode the body as
51
+ // `application/x-www-form-urlencoded` instead and will send the model in a
52
+ // form param named `model`.
53
+ Backbone.emulateJSON = false;
54
+
55
+ // Backbone.Events
56
+ // -----------------
57
+
58
+ // A module that can be mixed in to *any object* in order to provide it with
59
+ // custom events. You may `bind` or `unbind` a callback function to an event;
60
+ // `trigger`-ing an event fires all callbacks in succession.
61
+ //
62
+ // var object = {};
63
+ // _.extend(object, Backbone.Events);
64
+ // object.bind('expand', function(){ alert('expanded'); });
65
+ // object.trigger('expand');
66
+ //
67
+ Backbone.Events = {
68
+
69
+ // Bind an event, specified by a string name, `ev`, to a `callback` function.
70
+ // Passing `"all"` will bind the callback to all events fired.
71
+ bind : function(ev, callback) {
72
+ var calls = this._callbacks || (this._callbacks = {});
73
+ var list = this._callbacks[ev] || (this._callbacks[ev] = []);
74
+ list.push(callback);
75
+ return this;
76
+ },
77
+
78
+ // Remove one or many callbacks. If `callback` is null, removes all
79
+ // callbacks for the event. If `ev` is null, removes all bound callbacks
80
+ // for all events.
81
+ unbind : function(ev, callback) {
82
+ var calls;
83
+ if (!ev) {
84
+ this._callbacks = {};
85
+ } else if (calls = this._callbacks) {
86
+ if (!callback) {
87
+ calls[ev] = [];
88
+ } else {
89
+ var list = calls[ev];
90
+ if (!list) return this;
91
+ for (var i = 0, l = list.length; i < l; i++) {
92
+ if (callback === list[i]) {
93
+ list[i] = null;
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ }
99
+ return this;
100
+ },
101
+
102
+ // Trigger an event, firing all bound callbacks. Callbacks are passed the
103
+ // same arguments as `trigger` is, apart from the event name.
104
+ // Listening for `"all"` passes the true event name as the first argument.
105
+ trigger : function(eventName) {
106
+ var list, calls, ev, callback, args, i, l;
107
+ var both = 2;
108
+ if (!(calls = this._callbacks)) return this;
109
+ while (both--) {
110
+ ev = both ? eventName : 'all';
111
+ if (list = calls[ev]) {
112
+ for (i = 0, l = list.length; i < l; i++) {
113
+ if (!(callback = list[i])) {
114
+ list.splice(i, 1); i--; l--;
115
+ } else {
116
+ args = both ? Array.prototype.slice.call(arguments, 1) : arguments;
117
+ callback.apply(this, args);
118
+ }
119
+ }
120
+ }
121
+ }
122
+ return this;
123
+ }
124
+
125
+ };
126
+
127
+ // Backbone.Model
128
+ // --------------
129
+
130
+ // Create a new model, with defined attributes. A client id (`cid`)
131
+ // is automatically generated and assigned for you.
132
+ Backbone.Model = function(attributes, options) {
133
+ var defaults;
134
+ attributes || (attributes = {});
135
+ if (defaults = this.defaults) {
136
+ if (_.isFunction(defaults)) defaults = defaults();
137
+ attributes = _.extend({}, defaults, attributes);
138
+ }
139
+ this.attributes = {};
140
+ this._escapedAttributes = {};
141
+ this.cid = _.uniqueId('c');
142
+ this.set(attributes, {silent : true});
143
+ this._changed = false;
144
+ this._previousAttributes = _.clone(this.attributes);
145
+ if (options && options.collection) this.collection = options.collection;
146
+ this.initialize(attributes, options);
147
+ };
148
+
149
+ // Attach all inheritable methods to the Model prototype.
150
+ _.extend(Backbone.Model.prototype, Backbone.Events, {
151
+
152
+ // A snapshot of the model's previous attributes, taken immediately
153
+ // after the last `"change"` event was fired.
154
+ _previousAttributes : null,
155
+
156
+ // Has the item been changed since the last `"change"` event?
157
+ _changed : false,
158
+
159
+ // The default name for the JSON `id` attribute is `"id"`. MongoDB and
160
+ // CouchDB users may want to set this to `"_id"`.
161
+ idAttribute : 'id',
162
+
163
+ // Initialize is an empty function by default. Override it with your own
164
+ // initialization logic.
165
+ initialize : function(){},
166
+
167
+ // Return a copy of the model's `attributes` object.
168
+ toJSON : function() {
169
+ return _.clone(this.attributes);
170
+ },
171
+
172
+ // Get the value of an attribute.
173
+ get : function(attr) {
174
+ return this.attributes[attr];
175
+ },
176
+
177
+ // Get the HTML-escaped value of an attribute.
178
+ escape : function(attr) {
179
+ var html;
180
+ if (html = this._escapedAttributes[attr]) return html;
181
+ var val = this.attributes[attr];
182
+ return this._escapedAttributes[attr] = escapeHTML(val == null ? '' : '' + val);
183
+ },
184
+
185
+ // Returns `true` if the attribute contains a value that is not null
186
+ // or undefined.
187
+ has : function(attr) {
188
+ return this.attributes[attr] != null;
189
+ },
190
+
191
+ // Set a hash of model attributes on the object, firing `"change"` unless you
192
+ // choose to silence it.
193
+ set : function(attrs, options) {
194
+
195
+ // Extract attributes and options.
196
+ options || (options = {});
197
+ if (!attrs) return this;
198
+ if (attrs.attributes) attrs = attrs.attributes;
199
+ var now = this.attributes, escaped = this._escapedAttributes;
200
+
201
+ // Run validation.
202
+ if (!options.silent && this.validate && !this._performValidation(attrs, options)) return false;
203
+
204
+ // Check for changes of `id`.
205
+ if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
206
+
207
+ // Update attributes.
208
+ for (var attr in attrs) {
209
+ var val = attrs[attr];
210
+ if (!_.isEqual(now[attr], val)) {
211
+ now[attr] = val;
212
+ delete escaped[attr];
213
+ this._changed = true;
214
+ if (!options.silent) this.trigger('change:' + attr, this, val, options);
215
+ }
216
+ }
217
+
218
+ // Fire the `"change"` event, if the model has been changed.
219
+ if (!options.silent && this._changed) this.change(options);
220
+ return this;
221
+ },
222
+
223
+ // Remove an attribute from the model, firing `"change"` unless you choose
224
+ // to silence it. `unset` is a noop if the attribute doesn't exist.
225
+ unset : function(attr, options) {
226
+ if (!(attr in this.attributes)) return this;
227
+ options || (options = {});
228
+ var value = this.attributes[attr];
229
+
230
+ // Run validation.
231
+ var validObj = {};
232
+ validObj[attr] = void 0;
233
+ if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;
234
+
235
+ // Remove the attribute.
236
+ delete this.attributes[attr];
237
+ delete this._escapedAttributes[attr];
238
+ if (attr == this.idAttribute) delete this.id;
239
+ this._changed = true;
240
+ if (!options.silent) {
241
+ this.trigger('change:' + attr, this, void 0, options);
242
+ this.change(options);
243
+ }
244
+ return this;
245
+ },
246
+
247
+ // Clear all attributes on the model, firing `"change"` unless you choose
248
+ // to silence it.
249
+ clear : function(options) {
250
+ options || (options = {});
251
+ var old = this.attributes;
252
+
253
+ // Run validation.
254
+ var validObj = {};
255
+ for (attr in old) validObj[attr] = void 0;
256
+ if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;
257
+
258
+ this.attributes = {};
259
+ this._escapedAttributes = {};
260
+ this._changed = true;
261
+ if (!options.silent) {
262
+ for (attr in old) {
263
+ this.trigger('change:' + attr, this, void 0, options);
264
+ }
265
+ this.change(options);
266
+ }
267
+ return this;
268
+ },
269
+
270
+ // Fetch the model from the server. If the server's representation of the
271
+ // model differs from its current attributes, they will be overriden,
272
+ // triggering a `"change"` event.
273
+ fetch : function(options) {
274
+ options || (options = {});
275
+ var model = this;
276
+ var success = options.success;
277
+ options.success = function(resp, status, xhr) {
278
+ if (!model.set(model.parse(resp, xhr), options)) return false;
279
+ if (success) success(model, resp);
280
+ };
281
+ options.error = wrapError(options.error, model, options);
282
+ return (this.sync || Backbone.sync).call(this, 'read', this, options);
283
+ },
284
+
285
+ // Set a hash of model attributes, and sync the model to the server.
286
+ // If the server returns an attributes hash that differs, the model's
287
+ // state will be `set` again.
288
+ save : function(attrs, options) {
289
+ options || (options = {});
290
+ if (attrs && !this.set(attrs, options)) return false;
291
+ var model = this;
292
+ var success = options.success;
293
+ options.success = function(resp, status, xhr) {
294
+ if (!model.set(model.parse(resp, xhr), options)) return false;
295
+ if (success) success(model, resp, xhr);
296
+ };
297
+ options.error = wrapError(options.error, model, options);
298
+ var method = this.isNew() ? 'create' : 'update';
299
+ return (this.sync || Backbone.sync).call(this, method, this, options);
300
+ },
301
+
302
+ // Destroy this model on the server. Upon success, the model is removed
303
+ // from its collection, if it has one.
304
+ destroy : function(options) {
305
+ options || (options = {});
306
+ var model = this;
307
+ var success = options.success;
308
+ options.success = function(resp) {
309
+ model.trigger('destroy', model, model.collection, options);
310
+ if (success) success(model, resp);
311
+ };
312
+ options.error = wrapError(options.error, model, options);
313
+ return (this.sync || Backbone.sync).call(this, 'delete', this, options);
314
+ },
315
+
316
+ // Default URL for the model's representation on the server -- if you're
317
+ // using Backbone's restful methods, override this to change the endpoint
318
+ // that will be called.
319
+ url : function() {
320
+ var base = getUrl(this.collection) || this.urlRoot || urlError();
321
+ if (this.isNew()) return base;
322
+ return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);
323
+ },
324
+
325
+ // **parse** converts a response into the hash of attributes to be `set` on
326
+ // the model. The default implementation is just to pass the response along.
327
+ parse : function(resp, xhr) {
328
+ return resp;
329
+ },
330
+
331
+ // Create a new model with identical attributes to this one.
332
+ clone : function() {
333
+ return new this.constructor(this);
334
+ },
335
+
336
+ // A model is new if it has never been saved to the server, and has a negative
337
+ // ID.
338
+ isNew : function() {
339
+ return !this.id;
340
+ },
341
+
342
+ // Call this method to manually fire a `change` event for this model.
343
+ // Calling this will cause all objects observing the model to update.
344
+ change : function(options) {
345
+ this.trigger('change', this, options);
346
+ this._previousAttributes = _.clone(this.attributes);
347
+ this._changed = false;
348
+ },
349
+
350
+ // Determine if the model has changed since the last `"change"` event.
351
+ // If you specify an attribute name, determine if that attribute has changed.
352
+ hasChanged : function(attr) {
353
+ if (attr) return this._previousAttributes[attr] != this.attributes[attr];
354
+ return this._changed;
355
+ },
356
+
357
+ // Return an object containing all the attributes that have changed, or false
358
+ // if there are no changed attributes. Useful for determining what parts of a
359
+ // view need to be updated and/or what attributes need to be persisted to
360
+ // the server.
361
+ changedAttributes : function(now) {
362
+ now || (now = this.attributes);
363
+ var old = this._previousAttributes;
364
+ var changed = false;
365
+ for (var attr in now) {
366
+ if (!_.isEqual(old[attr], now[attr])) {
367
+ changed = changed || {};
368
+ changed[attr] = now[attr];
369
+ }
370
+ }
371
+ return changed;
372
+ },
373
+
374
+ // Get the previous value of an attribute, recorded at the time the last
375
+ // `"change"` event was fired.
376
+ previous : function(attr) {
377
+ if (!attr || !this._previousAttributes) return null;
378
+ return this._previousAttributes[attr];
379
+ },
380
+
381
+ // Get all of the attributes of the model at the time of the previous
382
+ // `"change"` event.
383
+ previousAttributes : function() {
384
+ return _.clone(this._previousAttributes);
385
+ },
386
+
387
+ // Run validation against a set of incoming attributes, returning `true`
388
+ // if all is well. If a specific `error` callback has been passed,
389
+ // call that instead of firing the general `"error"` event.
390
+ _performValidation : function(attrs, options) {
391
+ var error = this.validate(attrs);
392
+ if (error) {
393
+ if (options.error) {
394
+ options.error(this, error);
395
+ } else {
396
+ this.trigger('error', this, error, options);
397
+ }
398
+ return false;
399
+ }
400
+ return true;
401
+ }
402
+
403
+ });
404
+
405
+ // Backbone.Collection
406
+ // -------------------
407
+
408
+ // Provides a standard collection class for our sets of models, ordered
409
+ // or unordered. If a `comparator` is specified, the Collection will maintain
410
+ // its models in sort order, as they're added and removed.
411
+ Backbone.Collection = function(models, options) {
412
+ options || (options = {});
413
+ if (options.comparator) {
414
+ this.comparator = options.comparator;
415
+ delete options.comparator;
416
+ }
417
+ _.bindAll(this, '_onModelEvent', '_removeReference');
418
+ this._reset();
419
+ if (models) this.refresh(models, {silent: true});
420
+ this.initialize(models, options);
421
+ };
422
+
423
+ // Define the Collection's inheritable methods.
424
+ _.extend(Backbone.Collection.prototype, Backbone.Events, {
425
+
426
+ // The default model for a collection is just a **Backbone.Model**.
427
+ // This should be overridden in most cases.
428
+ model : Backbone.Model,
429
+
430
+ // Initialize is an empty function by default. Override it with your own
431
+ // initialization logic.
432
+ initialize : function(){},
433
+
434
+ // The JSON representation of a Collection is an array of the
435
+ // models' attributes.
436
+ toJSON : function() {
437
+ return this.map(function(model){ return model.toJSON(); });
438
+ },
439
+
440
+ // Add a model, or list of models to the set. Pass **silent** to avoid
441
+ // firing the `added` event for every new model.
442
+ add : function(models, options) {
443
+ if (_.isArray(models)) {
444
+ for (var i = 0, l = models.length; i < l; i++) {
445
+ this._add(models[i], options);
446
+ }
447
+ } else {
448
+ this._add(models, options);
449
+ }
450
+ return this;
451
+ },
452
+
453
+ // Remove a model, or a list of models from the set. Pass silent to avoid
454
+ // firing the `removed` event for every model removed.
455
+ remove : function(models, options) {
456
+ if (_.isArray(models)) {
457
+ for (var i = 0, l = models.length; i < l; i++) {
458
+ this._remove(models[i], options);
459
+ }
460
+ } else {
461
+ this._remove(models, options);
462
+ }
463
+ return this;
464
+ },
465
+
466
+ // Get a model from the set by id.
467
+ get : function(id) {
468
+ if (id == null) return null;
469
+ return this._byId[id.id != null ? id.id : id];
470
+ },
471
+
472
+ // Get a model from the set by client id.
473
+ getByCid : function(cid) {
474
+ return cid && this._byCid[cid.cid || cid];
475
+ },
476
+
477
+ // Get the model at the given index.
478
+ at: function(index) {
479
+ return this.models[index];
480
+ },
481
+
482
+ // Force the collection to re-sort itself. You don't need to call this under normal
483
+ // circumstances, as the set will maintain sort order as each item is added.
484
+ sort : function(options) {
485
+ options || (options = {});
486
+ if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
487
+ this.models = this.sortBy(this.comparator);
488
+ if (!options.silent) this.trigger('refresh', this, options);
489
+ return this;
490
+ },
491
+
492
+ // Pluck an attribute from each model in the collection.
493
+ pluck : function(attr) {
494
+ return _.map(this.models, function(model){ return model.get(attr); });
495
+ },
496
+
497
+ // When you have more items than you want to add or remove individually,
498
+ // you can refresh the entire set with a new list of models, without firing
499
+ // any `added` or `removed` events. Fires `refresh` when finished.
500
+ refresh : function(models, options) {
501
+ models || (models = []);
502
+ options || (options = {});
503
+ this.each(this._removeReference);
504
+ this._reset();
505
+ this.add(models, {silent: true});
506
+ if (!options.silent) this.trigger('refresh', this, options);
507
+ return this;
508
+ },
509
+
510
+ // Fetch the default set of models for this collection, refreshing the
511
+ // collection when they arrive. If `add: true` is passed, appends the
512
+ // models to the collection instead of refreshing.
513
+ fetch : function(options) {
514
+ options || (options = {});
515
+ var collection = this;
516
+ var success = options.success;
517
+ options.success = function(resp, status, xhr) {
518
+ collection[options.add ? 'add' : 'refresh'](collection.parse(resp, xhr), options);
519
+ if (success) success(collection, resp);
520
+ };
521
+ options.error = wrapError(options.error, collection, options);
522
+ return (this.sync || Backbone.sync).call(this, 'read', this, options);
523
+ },
524
+
525
+ // Create a new instance of a model in this collection. After the model
526
+ // has been created on the server, it will be added to the collection.
527
+ create : function(model, options) {
528
+ var coll = this;
529
+ options || (options = {});
530
+ if (!(model instanceof Backbone.Model)) {
531
+ var attrs = model;
532
+ model = new this.model(null, {collection: coll});
533
+ if (!model.set(attrs, options)) return false;
534
+ } else {
535
+ model.collection = coll;
536
+ }
537
+ var success = options.success;
538
+ options.success = function(nextModel, resp, xhr) {
539
+ coll.add(nextModel);
540
+ if (success) success(nextModel, resp, xhr);
541
+ };
542
+ model.save(null, options);
543
+ return model;
544
+ },
545
+
546
+ // **parse** converts a response into a list of models to be added to the
547
+ // collection. The default implementation is just to pass it through.
548
+ parse : function(resp, xhr) {
549
+ return resp;
550
+ },
551
+
552
+ // Proxy to _'s chain. Can't be proxied the same way the rest of the
553
+ // underscore methods are proxied because it relies on the underscore
554
+ // constructor.
555
+ chain: function () {
556
+ return _(this.models).chain();
557
+ },
558
+
559
+ // Reset all internal state. Called when the collection is refreshed.
560
+ _reset : function(options) {
561
+ this.length = 0;
562
+ this.models = [];
563
+ this._byId = {};
564
+ this._byCid = {};
565
+ },
566
+
567
+ // Internal implementation of adding a single model to the set, updating
568
+ // hash indexes for `id` and `cid` lookups.
569
+ _add : function(model, options) {
570
+ options || (options = {});
571
+ if (!(model instanceof Backbone.Model)) {
572
+ model = new this.model(model, {collection: this});
573
+ }
574
+ var already = this.getByCid(model);
575
+ if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
576
+ this._byId[model.id] = model;
577
+ this._byCid[model.cid] = model;
578
+ if (!model.collection) {
579
+ model.collection = this;
580
+ }
581
+ var index = this.comparator ? this.sortedIndex(model, this.comparator) : this.length;
582
+ this.models.splice(index, 0, model);
583
+ model.bind('all', this._onModelEvent);
584
+ this.length++;
585
+ if (!options.silent) model.trigger('add', model, this, options);
586
+ return model;
587
+ },
588
+
589
+ // Internal implementation of removing a single model from the set, updating
590
+ // hash indexes for `id` and `cid` lookups.
591
+ _remove : function(model, options) {
592
+ options || (options = {});
593
+ model = this.getByCid(model) || this.get(model);
594
+ if (!model) return null;
595
+ delete this._byId[model.id];
596
+ delete this._byCid[model.cid];
597
+ this.models.splice(this.indexOf(model), 1);
598
+ this.length--;
599
+ if (!options.silent) model.trigger('remove', model, this, options);
600
+ this._removeReference(model);
601
+ return model;
602
+ },
603
+
604
+ // Internal method to remove a model's ties to a collection.
605
+ _removeReference : function(model) {
606
+ if (this == model.collection) {
607
+ delete model.collection;
608
+ }
609
+ model.unbind('all', this._onModelEvent);
610
+ },
611
+
612
+ // Internal method called every time a model in the set fires an event.
613
+ // Sets need to update their indexes when models change ids. All other
614
+ // events simply proxy through. "add" and "remove" events that originate
615
+ // in other collections are ignored.
616
+ _onModelEvent : function(ev, model, collection, options) {
617
+ if ((ev == 'add' || ev == 'remove') && collection != this) return;
618
+ if (ev == 'destroy') {
619
+ this._remove(model, options);
620
+ }
621
+ if (model && ev === 'change:' + model.idAttribute) {
622
+ delete this._byId[model.previous(model.idAttribute)];
623
+ this._byId[model.id] = model;
624
+ }
625
+ this.trigger.apply(this, arguments);
626
+ }
627
+
628
+ });
629
+
630
+ // Underscore methods that we want to implement on the Collection.
631
+ var methods = ['forEach', 'each', 'map', 'reduce', 'reduceRight', 'find', 'detect',
632
+ 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', 'include',
633
+ 'invoke', 'max', 'min', 'sortBy', 'sortedIndex', 'toArray', 'size',
634
+ 'first', 'rest', 'last', 'without', 'indexOf', 'lastIndexOf', 'isEmpty'];
635
+
636
+ // Mix in each Underscore method as a proxy to `Collection#models`.
637
+ _.each(methods, function(method) {
638
+ Backbone.Collection.prototype[method] = function() {
639
+ return _[method].apply(_, [this.models].concat(_.toArray(arguments)));
640
+ };
641
+ });
642
+
643
+ // Backbone.Controller
644
+ // -------------------
645
+
646
+ // Controllers map faux-URLs to actions, and fire events when routes are
647
+ // matched. Creating a new one sets its `routes` hash, if not set statically.
648
+ Backbone.Controller = function(options) {
649
+ options || (options = {});
650
+ if (options.routes) this.routes = options.routes;
651
+ this._bindRoutes();
652
+ this.initialize(options);
653
+ };
654
+
655
+ // Cached regular expressions for matching named param parts and splatted
656
+ // parts of route strings.
657
+ var namedParam = /:([\w\d]+)/g;
658
+ var splatParam = /\*([\w\d]+)/g;
659
+ var escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
660
+
661
+ // Set up all inheritable **Backbone.Controller** properties and methods.
662
+ _.extend(Backbone.Controller.prototype, Backbone.Events, {
663
+
664
+ // Initialize is an empty function by default. Override it with your own
665
+ // initialization logic.
666
+ initialize : function(){},
667
+
668
+ // Manually bind a single named route to a callback. For example:
669
+ //
670
+ // this.route('search/:query/p:num', 'search', function(query, num) {
671
+ // ...
672
+ // });
673
+ //
674
+ route : function(route, name, callback) {
675
+ Backbone.history || (Backbone.history = new Backbone.History);
676
+ if (!_.isRegExp(route)) route = this._routeToRegExp(route);
677
+ Backbone.history.route(route, _.bind(function(fragment) {
678
+ var args = this._extractParameters(route, fragment);
679
+ callback.apply(this, args);
680
+ this.trigger.apply(this, ['route:' + name].concat(args));
681
+ }, this));
682
+ },
683
+
684
+ // Simple proxy to `Backbone.history` to save a fragment into the history,
685
+ // without triggering routes.
686
+ saveLocation : function(fragment) {
687
+ Backbone.history.saveLocation(fragment);
688
+ },
689
+
690
+ // Bind all defined routes to `Backbone.history`. We have to reverse the
691
+ // order of the routes here to support behavior where the most general
692
+ // routes can be defined at the bottom of the route map.
693
+ _bindRoutes : function() {
694
+ if (!this.routes) return;
695
+ var routes = [];
696
+ for (var route in this.routes) {
697
+ routes.unshift([route, this.routes[route]]);
698
+ }
699
+ for (var i = 0, l = routes.length; i < l; i++) {
700
+ this.route(routes[i][0], routes[i][1], this[routes[i][1]]);
701
+ }
702
+ },
703
+
704
+ // Convert a route string into a regular expression, suitable for matching
705
+ // against the current location fragment.
706
+ _routeToRegExp : function(route) {
707
+ route = route.replace(escapeRegExp, "\\$&")
708
+ .replace(namedParam, "([^\/]*)")
709
+ .replace(splatParam, "(.*?)");
710
+ return new RegExp('^' + route + '$');
711
+ },
712
+
713
+ // Given a route, and a URL fragment that it matches, return the array of
714
+ // extracted parameters.
715
+ _extractParameters : function(route, fragment) {
716
+ return route.exec(fragment).slice(1);
717
+ }
718
+
719
+ });
720
+
721
+ // Backbone.History
722
+ // ----------------
723
+
724
+ // Handles cross-browser history management, based on URL hashes. If the
725
+ // browser does not support `onhashchange`, falls back to polling.
726
+ Backbone.History = function() {
727
+ this.handlers = [];
728
+ this.fragment = this.getFragment();
729
+ _.bindAll(this, 'checkUrl');
730
+ };
731
+
732
+ // Cached regex for cleaning hashes.
733
+ var hashStrip = /^#*!?/;
734
+
735
+ // Cached regex for detecting MSIE.
736
+ var isExplorer = /msie [\w.]+/;
737
+
738
+ // Has the history handling already been started?
739
+ var historyStarted = false;
740
+
741
+ // Set up all inheritable **Backbone.History** properties and methods.
742
+ _.extend(Backbone.History.prototype, {
743
+
744
+ // The default interval to poll for hash changes, if necessary, is
745
+ // twenty times a second.
746
+ interval: 50,
747
+
748
+ // Get the cross-browser normalized URL fragment.
749
+ getFragment : function(loc) {
750
+ return (loc || window.location).hash.replace(hashStrip, '');
751
+ },
752
+
753
+ // Start the hash change handling, returning `true` if the current URL matches
754
+ // an existing route, and `false` otherwise.
755
+ start : function() {
756
+ if (historyStarted) throw new Error("Backbone.history has already been started");
757
+ var docMode = document.documentMode;
758
+ var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
759
+ if (oldIE) {
760
+ this.iframe = $('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
761
+ }
762
+ if ('onhashchange' in window && !oldIE) {
763
+ $(window).bind('hashchange', this.checkUrl);
764
+ } else {
765
+ setInterval(this.checkUrl, this.interval);
766
+ }
767
+ historyStarted = true;
768
+ return this.loadUrl();
769
+ },
770
+
771
+ // Add a route to be tested when the hash changes. Routes added later may
772
+ // override previous routes.
773
+ route : function(route, callback) {
774
+ this.handlers.unshift({route : route, callback : callback});
775
+ },
776
+
777
+ // Checks the current URL to see if it has changed, and if it has,
778
+ // calls `loadUrl`, normalizing across the hidden iframe.
779
+ checkUrl : function() {
780
+ var current = this.getFragment();
781
+ if (current == this.fragment && this.iframe) {
782
+ current = this.getFragment(this.iframe.location);
783
+ }
784
+ if (current == this.fragment ||
785
+ current == decodeURIComponent(this.fragment)) return false;
786
+ if (this.iframe) {
787
+ window.location.hash = this.iframe.location.hash = current;
788
+ }
789
+ this.loadUrl();
790
+ },
791
+
792
+ // Attempt to load the current URL fragment. If a route succeeds with a
793
+ // match, returns `true`. If no defined routes matches the fragment,
794
+ // returns `false`.
795
+ loadUrl : function() {
796
+ var fragment = this.fragment = this.getFragment();
797
+ var matched = _.any(this.handlers, function(handler) {
798
+ if (handler.route.test(fragment)) {
799
+ handler.callback(fragment);
800
+ return true;
801
+ }
802
+ });
803
+ return matched;
804
+ },
805
+
806
+ // Save a fragment into the hash history. You are responsible for properly
807
+ // URL-encoding the fragment in advance. This does not trigger
808
+ // a `hashchange` event.
809
+ saveLocation : function(fragment) {
810
+ fragment = (fragment || '').replace(hashStrip, '');
811
+ if (this.fragment == fragment) return;
812
+ window.location.hash = this.fragment = fragment;
813
+ if (this.iframe && (fragment != this.getFragment(this.iframe.location))) {
814
+ this.iframe.document.open().close();
815
+ this.iframe.location.hash = fragment;
816
+ }
817
+ }
818
+
819
+ });
820
+
821
+ // Backbone.View
822
+ // -------------
823
+
824
+ // Creating a Backbone.View creates its initial element outside of the DOM,
825
+ // if an existing element is not provided...
826
+ Backbone.View = function(options) {
827
+ this.cid = _.uniqueId('view');
828
+ this._configure(options || {});
829
+ this._ensureElement();
830
+ this.delegateEvents();
831
+ this.initialize(options);
832
+ };
833
+
834
+ // Element lookup, scoped to DOM elements within the current view.
835
+ // This should be prefered to global lookups, if you're dealing with
836
+ // a specific view.
837
+ var selectorDelegate = function(selector) {
838
+ return $(selector, this.el);
839
+ };
840
+
841
+ // Cached regex to split keys for `delegate`.
842
+ var eventSplitter = /^(\w+)\s*(.*)$/;
843
+
844
+ // List of view options to be merged as properties.
845
+ var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
846
+
847
+ // Set up all inheritable **Backbone.View** properties and methods.
848
+ _.extend(Backbone.View.prototype, Backbone.Events, {
849
+
850
+ // The default `tagName` of a View's element is `"div"`.
851
+ tagName : 'div',
852
+
853
+ // Attach the `selectorDelegate` function as the `$` property.
854
+ $ : selectorDelegate,
855
+
856
+ // Initialize is an empty function by default. Override it with your own
857
+ // initialization logic.
858
+ initialize : function(){},
859
+
860
+ // **render** is the core function that your view should override, in order
861
+ // to populate its element (`this.el`), with the appropriate HTML. The
862
+ // convention is for **render** to always return `this`.
863
+ render : function() {
864
+ return this;
865
+ },
866
+
867
+ // Remove this view from the DOM. Note that the view isn't present in the
868
+ // DOM by default, so calling this method may be a no-op.
869
+ remove : function() {
870
+ $(this.el).remove();
871
+ return this;
872
+ },
873
+
874
+ // For small amounts of DOM Elements, where a full-blown template isn't
875
+ // needed, use **make** to manufacture elements, one at a time.
876
+ //
877
+ // var el = this.make('li', {'class': 'row'}, this.model.escape('title'));
878
+ //
879
+ make : function(tagName, attributes, content) {
880
+ var el = document.createElement(tagName);
881
+ if (attributes) $(el).attr(attributes);
882
+ if (content) $(el).html(content);
883
+ return el;
884
+ },
885
+
886
+ // Set callbacks, where `this.callbacks` is a hash of
887
+ //
888
+ // *{"event selector": "callback"}*
889
+ //
890
+ // {
891
+ // 'mousedown .title': 'edit',
892
+ // 'click .button': 'save'
893
+ // }
894
+ //
895
+ // pairs. Callbacks will be bound to the view, with `this` set properly.
896
+ // Uses event delegation for efficiency.
897
+ // Omitting the selector binds the event to `this.el`.
898
+ // This only works for delegate-able events: not `focus`, `blur`, and
899
+ // not `change`, `submit`, and `reset` in Internet Explorer.
900
+ delegateEvents : function(events) {
901
+ if (!(events || (events = this.events))) return;
902
+ $(this.el).unbind('.delegateEvents' + this.cid);
903
+ for (var key in events) {
904
+ var methodName = events[key];
905
+ var match = key.match(eventSplitter);
906
+ var eventName = match[1], selector = match[2];
907
+ var method = _.bind(this[methodName], this);
908
+ eventName += '.delegateEvents' + this.cid;
909
+ if (selector === '') {
910
+ $(this.el).bind(eventName, method);
911
+ } else {
912
+ $(this.el).delegate(selector, eventName, method);
913
+ }
914
+ }
915
+ },
916
+
917
+ // Performs the initial configuration of a View with a set of options.
918
+ // Keys with special meaning *(model, collection, id, className)*, are
919
+ // attached directly to the view.
920
+ _configure : function(options) {
921
+ if (this.options) options = _.extend({}, this.options, options);
922
+ for (var i = 0, l = viewOptions.length; i < l; i++) {
923
+ var attr = viewOptions[i];
924
+ if (options[attr]) this[attr] = options[attr];
925
+ }
926
+ this.options = options;
927
+ },
928
+
929
+ // Ensure that the View has a DOM element to render into.
930
+ // If `this.el` is a string, pass it through `$()`, take the first
931
+ // matching element, and re-assign it to `el`. Otherwise, create
932
+ // an element from the `id`, `className` and `tagName` proeprties.
933
+ _ensureElement : function() {
934
+ if (!this.el) {
935
+ var attrs = this.attributes || {};
936
+ if (this.id) attrs.id = this.id;
937
+ if (this.className) attrs['class'] = this.className;
938
+ this.el = this.make(this.tagName, attrs);
939
+ } else if (_.isString(this.el)) {
940
+ this.el = $(this.el).get(0);
941
+ }
942
+ }
943
+
944
+ });
945
+
946
+ // The self-propagating extend function that Backbone classes use.
947
+ var extend = function (protoProps, classProps) {
948
+ var child = inherits(this, protoProps, classProps);
949
+ child.extend = this.extend;
950
+ return child;
951
+ };
952
+
953
+ // Set up inheritance for the model, collection, and view.
954
+ Backbone.Model.extend = Backbone.Collection.extend =
955
+ Backbone.Controller.extend = Backbone.View.extend = extend;
956
+
957
+ // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
958
+ var methodMap = {
959
+ 'create': 'POST',
960
+ 'update': 'PUT',
961
+ 'delete': 'DELETE',
962
+ 'read' : 'GET'
963
+ };
964
+
965
+ // Backbone.sync
966
+ // -------------
967
+
968
+ // Override this function to change the manner in which Backbone persists
969
+ // models to the server. You will be passed the type of request, and the
970
+ // model in question. By default, uses makes a RESTful Ajax request
971
+ // to the model's `url()`. Some possible customizations could be:
972
+ //
973
+ // * Use `setTimeout` to batch rapid-fire updates into a single request.
974
+ // * Send up the models as XML instead of JSON.
975
+ // * Persist models via WebSockets instead of Ajax.
976
+ //
977
+ // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
978
+ // as `POST`, with a `_method` parameter containing the true HTTP method,
979
+ // as well as all requests with the body as `application/x-www-form-urlencoded` instead of
980
+ // `application/json` with the model in a param named `model`.
981
+ // Useful when interfacing with server-side languages like **PHP** that make
982
+ // it difficult to read the body of `PUT` requests.
983
+ Backbone.sync = function(method, model, options) {
984
+ var type = methodMap[method];
985
+
986
+ // Default JSON-request options.
987
+ var params = _.extend({
988
+ type: type,
989
+ dataType: 'json',
990
+ processData: false
991
+ }, options);
992
+
993
+ // Ensure that we have a URL.
994
+ if (!params.url) {
995
+ params.url = getUrl(model) || urlError();
996
+ }
997
+
998
+ // Ensure that we have the appropriate request data.
999
+ if (!params.data && model && (method == 'create' || method == 'update')) {
1000
+ params.contentType = 'application/json';
1001
+ params.data = JSON.stringify(model.toJSON());
1002
+ }
1003
+
1004
+ // For older servers, emulate JSON by encoding the request into an HTML-form.
1005
+ if (Backbone.emulateJSON) {
1006
+ params.contentType = 'application/x-www-form-urlencoded';
1007
+ params.processData = true;
1008
+ params.data = params.data ? {model : params.data} : {};
1009
+ }
1010
+
1011
+ // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
1012
+ // And an `X-HTTP-Method-Override` header.
1013
+ if (Backbone.emulateHTTP) {
1014
+ if (type === 'PUT' || type === 'DELETE') {
1015
+ if (Backbone.emulateJSON) params.data._method = type;
1016
+ params.type = 'POST';
1017
+ params.beforeSend = function(xhr) {
1018
+ xhr.setRequestHeader('X-HTTP-Method-Override', type);
1019
+ };
1020
+ }
1021
+ }
1022
+
1023
+ // Make the request.
1024
+ return $.ajax(params);
1025
+ };
1026
+
1027
+ // Helpers
1028
+ // -------
1029
+
1030
+ // Shared empty constructor function to aid in prototype-chain creation.
1031
+ var ctor = function(){};
1032
+
1033
+ // Helper function to correctly set up the prototype chain, for subclasses.
1034
+ // Similar to `goog.inherits`, but uses a hash of prototype properties and
1035
+ // class properties to be extended.
1036
+ var inherits = function(parent, protoProps, staticProps) {
1037
+ var child;
1038
+
1039
+ // The constructor function for the new subclass is either defined by you
1040
+ // (the "constructor" property in your `extend` definition), or defaulted
1041
+ // by us to simply call `super()`.
1042
+ if (protoProps && protoProps.hasOwnProperty('constructor')) {
1043
+ child = protoProps.constructor;
1044
+ } else {
1045
+ child = function(){ return parent.apply(this, arguments); };
1046
+ }
1047
+
1048
+ // Inherit class (static) properties from parent.
1049
+ _.extend(child, parent);
1050
+
1051
+ // Set the prototype chain to inherit from `parent`, without calling
1052
+ // `parent`'s constructor function.
1053
+ ctor.prototype = parent.prototype;
1054
+ child.prototype = new ctor();
1055
+
1056
+ // Add prototype properties (instance properties) to the subclass,
1057
+ // if supplied.
1058
+ if (protoProps) _.extend(child.prototype, protoProps);
1059
+
1060
+ // Add static properties to the constructor function, if supplied.
1061
+ if (staticProps) _.extend(child, staticProps);
1062
+
1063
+ // Correctly set child's `prototype.constructor`.
1064
+ child.prototype.constructor = child;
1065
+
1066
+ // Set a convenience property in case the parent's prototype is needed later.
1067
+ child.__super__ = parent.prototype;
1068
+
1069
+ return child;
1070
+ };
1071
+
1072
+ // Helper function to get a URL from a Model or Collection as a property
1073
+ // or as a function.
1074
+ var getUrl = function(object) {
1075
+ if (!(object && object.url)) return null;
1076
+ return _.isFunction(object.url) ? object.url() : object.url;
1077
+ };
1078
+
1079
+ // Throw an error when a URL is needed, and none is supplied.
1080
+ var urlError = function() {
1081
+ throw new Error("A 'url' property or function must be specified");
1082
+ };
1083
+
1084
+ // Wrap an optional error callback with a fallback error event.
1085
+ var wrapError = function(onError, model, options) {
1086
+ return function(resp) {
1087
+ if (onError) {
1088
+ onError(model, resp, options);
1089
+ } else {
1090
+ model.trigger('error', model, resp, options);
1091
+ }
1092
+ };
1093
+ };
1094
+
1095
+ // Helper function to escape a string for HTML rendering.
1096
+ var escapeHTML = function(string) {
1097
+ return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
1098
+ };
1099
+
1100
+ }).call(this);