pageflow 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pageflow might be problematic. Click here for more details.

Files changed (263) hide show
  1. checksums.yaml +5 -13
  2. data/CHANGELOG.md +193 -11
  3. data/README.md +9 -1
  4. data/Rakefile +5 -0
  5. data/admins/pageflow/accounts.rb +2 -1
  6. data/admins/pageflow/entry.rb +21 -1
  7. data/admins/pageflow/revisions.rb +1 -1
  8. data/app/assets/fonts/pageflow/entypo-license.txt +358 -0
  9. data/app/assets/fonts/pageflow/fontawesome-license.txt +1 -0
  10. data/app/assets/fonts/pageflow/sourcesanspro-bold-webfont.eot +0 -0
  11. data/app/assets/fonts/pageflow/sourcesanspro-bold-webfont.svg +1236 -194
  12. data/app/assets/fonts/pageflow/sourcesanspro-bold-webfont.ttf +0 -0
  13. data/app/assets/fonts/pageflow/sourcesanspro-bold-webfont.woff +0 -0
  14. data/app/assets/fonts/pageflow/sourcesanspro-license.txt +93 -0
  15. data/app/assets/fonts/pageflow/sourcesanspro-light-webfont.eot +0 -0
  16. data/app/assets/fonts/pageflow/sourcesanspro-light-webfont.svg +1153 -839
  17. data/app/assets/fonts/pageflow/sourcesanspro-light-webfont.ttf +0 -0
  18. data/app/assets/fonts/pageflow/sourcesanspro-light-webfont.woff +0 -0
  19. data/app/assets/fonts/pageflow/sourcesanspro-regular-webfont.eot +0 -0
  20. data/app/assets/fonts/pageflow/sourcesanspro-regular-webfont.svg +1252 -199
  21. data/app/assets/fonts/pageflow/sourcesanspro-regular-webfont.ttf +0 -0
  22. data/app/assets/fonts/pageflow/sourcesanspro-regular-webfont.woff +0 -0
  23. data/app/assets/javascripts/pageflow/base.js +2 -0
  24. data/app/assets/javascripts/pageflow/browser/agent.js +25 -0
  25. data/app/assets/javascripts/pageflow/browser/css_animations.js +18 -0
  26. data/app/assets/javascripts/pageflow/browser/mobile_platform.js +1 -4
  27. data/app/assets/javascripts/pageflow/browser/video.js +8 -1
  28. data/app/assets/javascripts/pageflow/chapter_filter.js +6 -16
  29. data/app/assets/javascripts/pageflow/editor/api.js +6 -2
  30. data/app/assets/javascripts/pageflow/editor/api/page_type.js +12 -0
  31. data/app/assets/javascripts/pageflow/editor/base.js +4 -0
  32. data/app/assets/javascripts/pageflow/editor/collections/chapter_pages_collection.js +4 -1
  33. data/app/assets/javascripts/pageflow/editor/collections/chapters_collection.js +1 -5
  34. data/app/assets/javascripts/pageflow/editor/collections/mixins/add_and_return_model.js +11 -0
  35. data/app/assets/javascripts/pageflow/editor/collections/mixins/ordered_collection.js +6 -4
  36. data/app/assets/javascripts/pageflow/editor/collections/ordered_page_links_collection.js +9 -0
  37. data/app/assets/javascripts/pageflow/editor/collections/page_links_collection.js +78 -0
  38. data/app/assets/javascripts/pageflow/editor/collections/pages_collection.js +9 -3
  39. data/app/assets/javascripts/pageflow/editor/collections/storyline_chapters_collection.js +35 -0
  40. data/app/assets/javascripts/pageflow/editor/collections/storylines_collection.js +33 -0
  41. data/app/assets/javascripts/pageflow/editor/controllers/sidebar_controller.js +19 -2
  42. data/app/assets/javascripts/pageflow/editor/initializers/edit_lock.js +1 -1
  43. data/app/assets/javascripts/pageflow/editor/initializers/setup_collections.js +11 -0
  44. data/app/assets/javascripts/pageflow/editor/initializers/setup_common_seed.js +3 -0
  45. data/app/assets/javascripts/pageflow/editor/initializers/stylesheet_reloading.js +11 -0
  46. data/app/assets/javascripts/pageflow/editor/models/chapter.js +14 -7
  47. data/app/assets/javascripts/pageflow/editor/models/chapter_scaffold.js +13 -0
  48. data/app/assets/javascripts/pageflow/editor/models/edit_lock_container.js +4 -4
  49. data/app/assets/javascripts/pageflow/editor/models/entry.js +33 -4
  50. data/app/assets/javascripts/pageflow/editor/models/mixins/persited_promise.js +18 -0
  51. data/app/assets/javascripts/pageflow/editor/models/page.js +4 -0
  52. data/app/assets/javascripts/pageflow/editor/models/page_link.js +37 -0
  53. data/app/assets/javascripts/pageflow/editor/models/page_link_file_selection_handler.js +14 -0
  54. data/app/assets/javascripts/pageflow/editor/models/preview_entry_data.js +15 -0
  55. data/app/assets/javascripts/pageflow/editor/models/scaffold.js +26 -0
  56. data/app/assets/javascripts/pageflow/editor/models/storyline.js +99 -0
  57. data/app/assets/javascripts/pageflow/editor/models/storyline_configuration.js +15 -0
  58. data/app/assets/javascripts/pageflow/editor/models/storyline_ordering.js +117 -0
  59. data/app/assets/javascripts/pageflow/editor/models/storyline_scaffold.js +23 -0
  60. data/app/assets/javascripts/pageflow/editor/models/storyline_transitive_child_pages.js +33 -0
  61. data/app/assets/javascripts/pageflow/editor/routers/sidebar_router.js +3 -0
  62. data/app/assets/javascripts/pageflow/editor/templates/edit_entry.jst.ejs +1 -6
  63. data/app/assets/javascripts/pageflow/editor/templates/edit_page_link.jst.ejs +3 -0
  64. data/app/assets/javascripts/pageflow/editor/templates/edit_storyline.jst.ejs +12 -0
  65. data/app/assets/javascripts/pageflow/editor/templates/page_link_item.jst.ejs +1 -0
  66. data/app/assets/javascripts/pageflow/editor/templates/page_selection.jst.ejs +2 -2
  67. data/app/assets/javascripts/pageflow/editor/templates/storyline_outline.jst.ejs +4 -0
  68. data/app/assets/javascripts/pageflow/editor/templates/storyline_picker.jst.ejs +7 -0
  69. data/app/assets/javascripts/pageflow/editor/utils/reload_stylesheet.js +9 -0
  70. data/app/assets/javascripts/pageflow/editor/views/configuration_editors/groups/options.js +2 -2
  71. data/app/assets/javascripts/pageflow/editor/views/configuration_editors/groups/page_link.js +10 -0
  72. data/app/assets/javascripts/pageflow/editor/views/edit_chapter_view.js +0 -4
  73. data/app/assets/javascripts/pageflow/editor/views/edit_entry_view.js +9 -15
  74. data/app/assets/javascripts/pageflow/editor/views/edit_meta_data_view.js +14 -6
  75. data/app/assets/javascripts/pageflow/editor/views/edit_page_link_view.js +47 -0
  76. data/app/assets/javascripts/pageflow/editor/views/edit_storyline_view.js +97 -0
  77. data/app/assets/javascripts/pageflow/editor/views/editor_view.js +6 -3
  78. data/app/assets/javascripts/pageflow/editor/views/entry_preview_view.js +13 -7
  79. data/app/assets/javascripts/pageflow/editor/views/file_item_view.js +1 -1
  80. data/app/assets/javascripts/pageflow/editor/views/inputs/page_link_input_view.js +3 -1
  81. data/app/assets/javascripts/pageflow/editor/views/locked_view.js +3 -3
  82. data/app/assets/javascripts/pageflow/editor/views/mixins/loadable.js +1 -1
  83. data/app/assets/javascripts/pageflow/editor/views/page_item_view.js +2 -0
  84. data/app/assets/javascripts/pageflow/editor/views/page_link_configuration_editor_view.js +7 -0
  85. data/app/assets/javascripts/pageflow/editor/views/page_link_item_view.js +8 -1
  86. data/app/assets/javascripts/pageflow/editor/views/page_preview_view.js +1 -1
  87. data/app/assets/javascripts/pageflow/editor/views/page_selection_view.js +13 -12
  88. data/app/assets/javascripts/pageflow/editor/views/storyline_outline_view.js +33 -0
  89. data/app/assets/javascripts/pageflow/editor/views/storyline_picker_view.js +114 -0
  90. data/app/assets/javascripts/pageflow/entry_data.js +38 -4
  91. data/app/assets/javascripts/pageflow/highlighted_page.js +5 -5
  92. data/app/assets/javascripts/pageflow/history.js +1 -1
  93. data/app/assets/javascripts/pageflow/native_scrolling.js +14 -0
  94. data/app/assets/javascripts/pageflow/page_transitions.js +3 -1
  95. data/app/assets/javascripts/pageflow/page_type.js +2 -0
  96. data/app/assets/javascripts/pageflow/ready.js +4 -1
  97. data/app/assets/javascripts/pageflow/seed_entry_data.js +28 -1
  98. data/app/assets/javascripts/pageflow/slideshow.js +11 -8
  99. data/app/assets/javascripts/pageflow/slideshow/dom_order_scroll_navigator.js +93 -8
  100. data/app/assets/javascripts/pageflow/slideshow/hidden_text_indicator_widget.js +5 -3
  101. data/app/assets/javascripts/pageflow/slideshow/lazy_page_widget.js +4 -0
  102. data/app/assets/javascripts/pageflow/slideshow/page_widget.js +15 -6
  103. data/app/assets/javascripts/pageflow/ui/templates/tooltip.jst.ejs +2 -0
  104. data/app/assets/javascripts/pageflow/ui/views/inputs/text_area_input_view.js +17 -4
  105. data/app/assets/javascripts/pageflow/ui/views/mixins/tooltip_container.js +42 -0
  106. data/app/assets/javascripts/pageflow/ui/views/tooltip_view.js +49 -0
  107. data/app/assets/javascripts/pageflow/video_player.js +2 -2
  108. data/app/assets/javascripts/pageflow/video_player/{filter_for_silk.js → filter_sources.js} +2 -2
  109. data/app/assets/javascripts/pageflow/widgets/navigation.js +17 -14
  110. data/app/assets/javascripts/pageflow/widgets/navigation_mobile.js +7 -2
  111. data/app/assets/javascripts/pageflow/widgets/overview.js +9 -6
  112. data/app/assets/javascripts/pageflow/widgets/page_navigation_list.js +51 -13
  113. data/app/assets/javascripts/pageflow/widgets/page_navigation_list_animation.js +48 -0
  114. data/app/assets/javascripts/pageflow/widgets/parent_page_button.js +9 -2
  115. data/app/assets/stylesheets/pageflow/admin.css.scss +2 -15
  116. data/app/assets/stylesheets/pageflow/admin/features.scss +5 -0
  117. data/app/assets/stylesheets/pageflow/admin/forms.scss +18 -0
  118. data/app/assets/stylesheets/pageflow/animations.css.scss +1 -0
  119. data/app/assets/stylesheets/pageflow/animations/navigation_bar.scss +89 -0
  120. data/app/assets/stylesheets/pageflow/delayed_text_fade_in.css.scss +1 -1
  121. data/app/assets/stylesheets/pageflow/editor/base.css.scss +5 -0
  122. data/app/assets/stylesheets/pageflow/editor/menu.css.scss +1 -0
  123. data/app/assets/stylesheets/pageflow/editor/outline.css.scss +5 -0
  124. data/app/assets/stylesheets/pageflow/editor/page_links.css.scss +9 -1
  125. data/app/assets/stylesheets/pageflow/editor/page_selection.css.scss +7 -1
  126. data/app/assets/stylesheets/pageflow/editor/storyline_picker.css.scss +32 -0
  127. data/app/assets/stylesheets/pageflow/extendables.scss +26 -0
  128. data/app/assets/stylesheets/pageflow/mixins/pageflow.css.scss +25 -0
  129. data/app/assets/stylesheets/pageflow/navigation_bar.css.scss +64 -4
  130. data/app/assets/stylesheets/pageflow/navigation_mobile.css.scss +56 -0
  131. data/app/assets/stylesheets/pageflow/page_transitions.css.scss +4 -1
  132. data/app/assets/stylesheets/pageflow/page_transitions/scroll_over_from_left.scss +12 -0
  133. data/app/assets/stylesheets/pageflow/page_transitions/scroll_over_from_right.scss +12 -0
  134. data/app/assets/stylesheets/pageflow/page_types/video.css.scss +5 -1
  135. data/app/assets/stylesheets/pageflow/themes/default/page.css.scss +180 -42
  136. data/app/assets/stylesheets/pageflow/ui.css.scss +1 -0
  137. data/app/assets/stylesheets/pageflow/ui/forms.css.scss +11 -2
  138. data/app/assets/stylesheets/pageflow/ui/input/extended_select_input.css.scss +1 -0
  139. data/app/assets/stylesheets/pageflow/ui/tabs_view.css.scss +0 -3
  140. data/app/assets/stylesheets/pageflow/ui/tooltip.scss +57 -0
  141. data/app/controllers/concerns/pageflow/entry_password_protection.rb +13 -0
  142. data/app/controllers/pageflow/chapters_controller.rb +24 -9
  143. data/app/controllers/pageflow/edit_locks_controller.rb +2 -2
  144. data/app/controllers/pageflow/editor/files_controller.rb +0 -2
  145. data/app/controllers/pageflow/editor/widgets_controller.rb +1 -1
  146. data/app/controllers/pageflow/entries_controller.rb +5 -9
  147. data/app/controllers/pageflow/files_controller.rb +3 -0
  148. data/app/controllers/pageflow/storylines_controller.rb +69 -0
  149. data/app/helpers/pageflow/admin/features_helper.rb +17 -6
  150. data/app/helpers/pageflow/admin/widgets_helper.rb +18 -0
  151. data/app/helpers/pageflow/audio_files_helper.rb +2 -2
  152. data/app/helpers/pageflow/common_entry_seed_helper.rb +52 -0
  153. data/app/helpers/pageflow/entries_helper.rb +7 -1
  154. data/app/helpers/pageflow/entry_json_seed_helper.rb +27 -10
  155. data/app/helpers/pageflow/meta_tags_helper.rb +11 -0
  156. data/app/helpers/pageflow/page_types_helper.rb +9 -5
  157. data/app/helpers/pageflow/pages_helper.rb +9 -96
  158. data/app/helpers/pageflow/public_i18n_helper.rb +13 -0
  159. data/app/helpers/pageflow/social_share_helper.rb +1 -1
  160. data/app/helpers/pageflow/video_files_helper.rb +133 -0
  161. data/app/helpers/pageflow/widgets_helper.rb +3 -9
  162. data/app/models/concerns/pageflow/feature_target.rb +21 -3
  163. data/app/models/concerns/pageflow/hosted_file.rb +4 -0
  164. data/app/models/pageflow/account.rb +2 -2
  165. data/app/models/pageflow/chapter.rb +4 -4
  166. data/app/models/pageflow/chapter_scaffold.rb +33 -0
  167. data/app/models/pageflow/cname_theming_request_scope.rb +7 -1
  168. data/app/models/pageflow/draft_entry.rb +13 -2
  169. data/app/models/pageflow/edit_lock.rb +2 -2
  170. data/app/models/pageflow/entry.rb +3 -2
  171. data/app/models/pageflow/image_file.rb +6 -0
  172. data/app/models/pageflow/published_entry.rb +13 -2
  173. data/app/models/pageflow/revision.rb +17 -4
  174. data/app/models/pageflow/storyline.rb +23 -0
  175. data/app/models/pageflow/storyline_scaffold.rb +27 -0
  176. data/app/models/pageflow/theming.rb +4 -0
  177. data/app/models/pageflow/widget.rb +16 -12
  178. data/app/views/admin/accounts/_form.html.erb +8 -12
  179. data/app/views/admin/accounts/_widgets_inline_help.html.erb +5 -0
  180. data/app/views/layouts/pageflow/application.html.erb +4 -1
  181. data/app/views/pageflow/admin/widgets/_fields.html.erb +9 -0
  182. data/app/views/pageflow/config/_editor_seeds.json.jbuilder +1 -1
  183. data/app/views/pageflow/editor/entries/_entry.json.jbuilder +2 -2
  184. data/app/views/pageflow/editor/entries/_other_entry.json.jbuilder +1 -0
  185. data/app/views/pageflow/editor/entries/index.json.jbuilder +1 -1
  186. data/app/views/pageflow/editor/entries/seed.json.erb +4 -1
  187. data/app/views/pageflow/editor/files/_file.json.jbuilder +4 -0
  188. data/app/views/pageflow/editor/themings/_theming.json.jbuilder +1 -0
  189. data/app/views/pageflow/entries/_entry.html.erb +2 -2
  190. data/app/views/pageflow/entries/_ie8_hint.html.erb +2 -2
  191. data/app/views/pageflow/entries/_indicators.html.erb +3 -3
  192. data/app/views/pageflow/entries/_mobile_navigation.html.erb +6 -5
  193. data/app/views/pageflow/entries/_multimedia_alert.html.erb +6 -6
  194. data/app/views/pageflow/entries/_non_js_hint.html.erb +1 -1
  195. data/app/views/pageflow/entries/_skip_links.html.erb +3 -3
  196. data/app/views/pageflow/entries/edit.html.erb +4 -2
  197. data/app/views/pageflow/entries/navigation/_bar_bottom.html.erb +6 -5
  198. data/app/views/pageflow/entries/navigation/_bar_top.html.erb +13 -13
  199. data/app/views/pageflow/entries/navigation/_home_button.html.erb +2 -2
  200. data/app/views/pageflow/entries/navigation/_page.html.erb +1 -1
  201. data/app/views/pageflow/entries/overview/_chapter.html.erb +1 -1
  202. data/app/views/pageflow/entries/overview/_entry.html.erb +7 -6
  203. data/app/views/pageflow/entries/share_menu/_facebook_link.html.erb +1 -1
  204. data/app/views/pageflow/entries/share_menu/_google_link.html.erb +1 -1
  205. data/app/views/pageflow/entries/share_menu/_twitter_link.html.erb +1 -1
  206. data/app/views/pageflow/entries/show.html.erb +4 -1
  207. data/app/views/pageflow/file_types/_thumbnails.css.erb +2 -0
  208. data/app/views/pageflow/meta_tags/_entry.html.erb +4 -0
  209. data/app/views/pageflow/pages/_page.html.erb +2 -2
  210. data/app/views/pageflow/pages/templates/_audio.html.erb +2 -2
  211. data/app/views/pageflow/pages/templates/_audio_loop.html.erb +1 -1
  212. data/app/views/pageflow/pages/templates/_background_video.html.erb +8 -3
  213. data/app/views/pageflow/pages/templates/_video.html.erb +9 -4
  214. data/app/views/pageflow/public_i18n/_javascript_tag.html.erb +5 -0
  215. data/app/views/pageflow/social_share/_entry_meta_tags.html.erb +1 -1
  216. data/app/views/pageflow/video_files/_script_tag.html.erb +3 -0
  217. data/app/views/pageflow/video_files/_video_file.html.erb +4 -1
  218. data/app/views/pageflow/video_files/_video_tag.html.erb +7 -0
  219. data/config/initializers/admin_resource_tabs.rb +1 -0
  220. data/config/initializers/features.rb +3 -1
  221. data/config/initializers/paperclip.rb +5 -0
  222. data/config/locales/de.yml +205 -601
  223. data/config/locales/en.yml +198 -405
  224. data/config/routes.rb +10 -2
  225. data/db/migrate/20150826125417_create_pageflow_storylines.rb +12 -0
  226. data/db/migrate/20150826125744_add_storyline_id_to_chapters.rb +6 -0
  227. data/db/migrate/20150826125745_insert_main_storylines.rb +28 -0
  228. data/db/migrate/20150830105831_remove_revision_id_from_chapters.rb +5 -0
  229. data/db/migrate/20150830110006_remove_entry_id_from_chapters.rb +5 -0
  230. data/db/migrate/20160201130118_add_additional_cnames_to_themings.rb +5 -0
  231. data/db/migrate/20160216130336_add_meta_fields_to_revision.rb +7 -0
  232. data/lib/generators/pageflow/initializer/templates/pageflow.rb +7 -0
  233. data/lib/pageflow/ability_mixin.rb +7 -1
  234. data/lib/pageflow/configuration.rb +27 -2
  235. data/lib/pageflow/engine.rb +4 -1
  236. data/lib/pageflow/features.rb +24 -0
  237. data/lib/pageflow/global_config_api.rb +1 -0
  238. data/lib/pageflow/seeds.rb +4 -2
  239. data/lib/pageflow/theme.rb +4 -0
  240. data/lib/pageflow/version.rb +1 -1
  241. data/spec/factories/chapters.rb +6 -3
  242. data/spec/factories/storylines.rb +13 -0
  243. metadata +1021 -928
  244. data/app/assets/fonts/pageflow/FranklinGothic-Demi-webfont.eot +0 -0
  245. data/app/assets/fonts/pageflow/FranklinGothic-Demi-webfont.svg +0 -768
  246. data/app/assets/fonts/pageflow/FranklinGothic-Demi-webfont.ttf +0 -0
  247. data/app/assets/fonts/pageflow/FranklinGothic-Demi-webfont.woff +0 -0
  248. data/app/assets/fonts/pageflow/FranklinGothic-Hvy-webfont.eot +0 -0
  249. data/app/assets/fonts/pageflow/FranklinGothic-Hvy-webfont.svg +0 -968
  250. data/app/assets/fonts/pageflow/FranklinGothic-Hvy-webfont.ttf +0 -0
  251. data/app/assets/fonts/pageflow/FranklinGothic-Hvy-webfont.woff +0 -0
  252. data/app/assets/fonts/pageflow/thesansboldplain.eot +0 -0
  253. data/app/assets/fonts/pageflow/thesansboldplain.svg +0 -228
  254. data/app/assets/fonts/pageflow/thesansboldplain.ttf +0 -0
  255. data/app/assets/fonts/pageflow/thesansboldplain.woff +0 -0
  256. data/app/assets/fonts/pageflow/thesanssemiboldplain.eot +0 -0
  257. data/app/assets/fonts/pageflow/thesanssemiboldplain.svg +0 -228
  258. data/app/assets/fonts/pageflow/thesanssemiboldplain.ttf +0 -0
  259. data/app/assets/fonts/pageflow/thesanssemiboldplain.woff +0 -0
  260. data/app/assets/javascripts/pageflow/browser/hashchange_support.js +0 -8
  261. data/app/assets/javascripts/pageflow/widgets/button.js +0 -22
  262. data/app/views/layouts/pageflow/_meta_tags.html.erb +0 -5
  263. data/app/views/pageflow/pages/_video_tag.html.erb +0 -13
@@ -4,9 +4,10 @@ pageflow.SidebarController = Backbone.Marionette.Controller.extend({
4
4
  this.entry = options.entry;
5
5
  },
6
6
 
7
- index: function() {
7
+ index: function(storylineId) {
8
8
  this.region.show(new pageflow.EditEntryView({
9
- model: this.entry
9
+ model: this.entry,
10
+ storylineId: storylineId
10
11
  }));
11
12
  },
12
13
 
@@ -45,6 +46,12 @@ pageflow.SidebarController = Backbone.Marionette.Controller.extend({
45
46
  pageflow.editor.setDefaultHelpEntry('pageflow.help_entries.publish');
46
47
  },
47
48
 
49
+ storyline: function(id) {
50
+ this.region.show(new pageflow.EditStorylineView({
51
+ model: this.entry.storylines.get(id)
52
+ }));
53
+ },
54
+
48
55
  chapter: function(id) {
49
56
  this.region.show(new pageflow.EditChapterView({
50
57
  model: this.entry.chapters.get(id)
@@ -60,5 +67,15 @@ pageflow.SidebarController = Backbone.Marionette.Controller.extend({
60
67
  }));
61
68
 
62
69
  pageflow.editor.setDefaultHelpEntry(page.pageType().help_entry_translation_key);
70
+ },
71
+
72
+ pageLink: function(linkId) {
73
+ var pageId = linkId.split(':')[0];
74
+ var page = pageflow.pages.getByPermaId(pageId);
75
+
76
+ this.region.show(new pageflow.EditPageLinkView({
77
+ model: page.pageLinks().get(linkId),
78
+ page: page
79
+ }));
63
80
  }
64
81
  });
@@ -2,5 +2,5 @@ pageflow.app.addInitializer(function(options) {
2
2
  pageflow.editLock = new pageflow.EditLockContainer();
3
3
 
4
4
  pageflow.editLock.watchForErrors();
5
- pageflow.editLock.aquire();
5
+ pageflow.editLock.acquire();
6
6
  });
@@ -7,18 +7,29 @@ pageflow.app.addInitializer(function(options) {
7
7
 
8
8
  pageflow.pages = new pageflow.PagesCollection(options.pages);
9
9
  pageflow.chapters = new pageflow.ChaptersCollection(options.chapters);
10
+ pageflow.storylines = new pageflow.StorylinesCollection(options.storylines);
10
11
  pageflow.entry = new pageflow.Entry(options.entry);
11
12
  pageflow.theming = new pageflow.Theming(options.theming);
12
13
  pageflow.account = new Backbone.Model(options.account);
13
14
 
14
15
  pageflow.entryData = new pageflow.PreviewEntryData({
16
+ storylines: pageflow.storylines,
15
17
  chapters: pageflow.chapters,
16
18
  pages: pageflow.pages,
17
19
  theming: pageflow.theming
18
20
  });
19
21
 
22
+ pageflow.storylineOrdering = new pageflow.StorylineOrdering(pageflow.storylines, pageflow.pages);
23
+ pageflow.storylineOrdering.sort({silent: true});
24
+ pageflow.storylineOrdering.watch();
25
+
20
26
  pageflow.pages.sort();
21
27
 
28
+ // TODO
29
+ pageflow.storylines.on('sort', _.debounce(function() {
30
+ pageflow.storylines.saveOrder();
31
+ }, 100));
32
+
22
33
  pageflow.editor.failures.watch(pageflow.entry);
23
34
  pageflow.editor.failures.watch(pageflow.pages);
24
35
  pageflow.editor.failures.watch(pageflow.chapters);
@@ -0,0 +1,3 @@
1
+ pageflow.app.addInitializer(function(options) {
2
+ pageflow.seed = options.common;
3
+ });
@@ -0,0 +1,11 @@
1
+ pageflow.app.addInitializer(function(options) {
2
+ pageflow.entry.on('change:pending_files_count', function(model, value) {
3
+ if (value < pageflow.entry.previous('pending_files_count')) {
4
+ pageflow.reloadStylesheet('entry');
5
+ }
6
+ });
7
+
8
+ pageflow.entry.on('use:file', function() {
9
+ pageflow.reloadStylesheet('entry');
10
+ });
11
+ });
@@ -29,17 +29,24 @@ pageflow.Chapter = Backbone.Model.extend({
29
29
  return this.isNew() ? this.collection.url() : '/chapters';
30
30
  },
31
31
 
32
- addPage: function(options) {
33
- options = options || {};
32
+ storylinePosition: function() {
33
+ return (this.storyline && this.storyline.get('position')) || -1;
34
+ },
35
+
36
+ addPage: function(attributes) {
37
+ var page = this.buildPage(attributes);
38
+ page.save();
34
39
 
35
- var pos = ('position' in options) ? options.position : this.pages.length;
40
+ return page;
41
+ },
36
42
 
37
- var create_opts = {
38
- chapter_id: this.get('id'),
39
- position: pos
43
+ buildPage: function(attributes) {
44
+ var defaults = {
45
+ chapter_id: this.id,
46
+ position: this.pages.length
40
47
  };
41
48
 
42
- return this.pages.create(create_opts);
49
+ return this.pages.addAndReturnModel(_.extend(defaults, attributes));
43
50
  },
44
51
 
45
52
  toJSON: function() {
@@ -0,0 +1,13 @@
1
+ pageflow.ChapterScaffold = pageflow.Scaffold.extend({
2
+ build: function() {
3
+ this.chapter = this.parent.buildChapter(this.options.chapterAttributes);
4
+ this.page = this.chapter.buildPage();
5
+
6
+ return this.chapter;
7
+ },
8
+
9
+ load: function(response) {
10
+ this.chapter.set(response.chapter);
11
+ this.page.set(response.page);
12
+ }
13
+ });
@@ -3,7 +3,7 @@ pageflow.EditLockContainer = Backbone.Model.extend({
3
3
  this.storageKey = 'pageflow.edit_lock.' + pageflow.entry.id;
4
4
  },
5
5
 
6
- aquire: function(options) {
6
+ acquire: function(options) {
7
7
  options = options || {};
8
8
  var container = this;
9
9
 
@@ -18,7 +18,7 @@ pageflow.EditLockContainer = Backbone.Model.extend({
18
18
  sessionStorage[container.storageKey] = lock.id;
19
19
 
20
20
  container.lock = lock;
21
- container.trigger('aquired');
21
+ container.trigger('acquired');
22
22
 
23
23
  container.startPolling();
24
24
  }
@@ -28,7 +28,7 @@ pageflow.EditLockContainer = Backbone.Model.extend({
28
28
  startPolling: function() {
29
29
  if (!this.pollingInteval) {
30
30
  this.pollingInteval = setInterval(_.bind(function() {
31
- this.aquire({polling: true});
31
+ this.acquire({polling: true});
32
32
  }, this), 2000);
33
33
  }
34
34
  },
@@ -78,7 +78,7 @@ pageflow.EditLockContainer = Backbone.Model.extend({
78
78
  this.trigger('locked',
79
79
  xhr.responseJSON || {},
80
80
  {
81
- context: (settings.url.match(/\/edit_lock/) && !settings.polling) ? 'aquire' : 'other'
81
+ context: (settings.url.match(/\/edit_lock/) && !settings.polling) ? 'acquire' : 'other'
82
82
  });
83
83
 
84
84
  this.stopPolling();
@@ -19,6 +19,8 @@ pageflow.Entry = Backbone.Model.extend({
19
19
  this.configuration.parent = this;
20
20
 
21
21
  this.files = options.files || pageflow.files;
22
+ this.storylines = options.storylines || pageflow.storylines;
23
+ this.storylines.parentModel = this;
22
24
  this.chapters = options.chapters || pageflow.chapters;
23
25
  this.chapters.parentModel = this;
24
26
  this.pages = pageflow.pages;
@@ -31,6 +33,10 @@ pageflow.Entry = Backbone.Model.extend({
31
33
  this.watchFileCollection(fileType.collectionName, this.getFileCollection(fileType));
32
34
  }, this);
33
35
 
36
+ this.listenTo(this.storylines, 'sort', function() {
37
+ this.pages.sort();
38
+ });
39
+
34
40
  this.listenTo(this.chapters, 'sort', function() {
35
41
  this.pages.sort();
36
42
  });
@@ -49,13 +55,34 @@ pageflow.Entry = Backbone.Model.extend({
49
55
  });
50
56
  },
51
57
 
52
- addChapter: function(params) {
58
+ addStoryline: function(attributes) {
59
+ var storyline = this.buildStoryline(attributes);
60
+ storyline.save();
61
+
62
+ return storyline;
63
+ },
64
+
65
+ buildStoryline: function(attributes) {
53
66
  var defaults = {
54
- entry_id: this.get('id'),
55
67
  title: '',
56
- position: this.chapters.length
57
68
  };
58
- return this.chapters.create(_.extend(defaults, params));
69
+
70
+ return this.storylines.addAndReturnModel(_.extend(defaults, attributes));
71
+ },
72
+
73
+ scaffoldStoryline: function(options) {
74
+ var scaffold = new pageflow.StorylineScaffold(this, options);
75
+ scaffold.create();
76
+
77
+ return scaffold;
78
+ },
79
+
80
+ addChapterInNewStoryline: function(options) {
81
+ return this.scaffoldStoryline(_.extend({depth: 'chapter'}, options)).chapter;
82
+ },
83
+
84
+ addPageInNewStoryline: function(options) {
85
+ return this.scaffoldStoryline(_.extend({depth: 'page'}, options)).page;
59
86
  },
60
87
 
61
88
  addFileUpload: function(upload) {
@@ -78,6 +105,8 @@ pageflow.Entry = Backbone.Model.extend({
78
105
  fileUsages.createForFile(file, { success: function(usage) {
79
106
  file.set('usage_id', usage.get('id'));
80
107
  this.getFileCollection(file.fileType()).add(file);
108
+
109
+ this.trigger('use:file', file);
81
110
  }.bind(this)});
82
111
  },
83
112
 
@@ -0,0 +1,18 @@
1
+ pageflow.persistedPromise = {
2
+ persisted: function() {
3
+ var model = this;
4
+
5
+ this._persistedDeferred = this._persistedDeferred || jQuery.Deferred(function(deferred) {
6
+ if (model.isNew()) {
7
+ model.once('change:id', deferred.resolve);
8
+ }
9
+ else {
10
+ deferred.resolve();
11
+ }
12
+ });
13
+
14
+ return this._persistedDeferred.promise();
15
+ }
16
+ };
17
+
18
+ Cocktail.mixin(Backbone.Model, pageflow.persistedPromise);
@@ -39,6 +39,10 @@ pageflow.Page = Backbone.Model.extend({
39
39
  return this.isNew() ? this.collection.url() : '/pages';
40
40
  },
41
41
 
42
+ storylinePosition: function() {
43
+ return (this.chapter && this.chapter.storylinePosition()) || -1;
44
+ },
45
+
42
46
  chapterPosition: function() {
43
47
  return (this.chapter && this.chapter.get('position')) || -1;
44
48
  },
@@ -0,0 +1,37 @@
1
+ pageflow.PageLink = Backbone.Model.extend({
2
+ mixins: [pageflow.transientReferences],
3
+
4
+ i18nKey: 'pageflow/page_link',
5
+
6
+ targetPage: function() {
7
+ return pageflow.pages.getByPermaId(this.get('target_page_id'));
8
+ },
9
+
10
+ label: function() {
11
+ return this.get('label');
12
+ },
13
+
14
+ editPath: function() {
15
+ return '/page_links/' + this.id;
16
+ },
17
+
18
+ getPageId: function() {
19
+ return this.collection.page.id;
20
+ },
21
+
22
+ toSerializedJSON: function() {
23
+ return _.omit(this.attributes, 'highlighted', 'position');
24
+ },
25
+
26
+ highlight: function() {
27
+ this.set('highlighted', true);
28
+ },
29
+
30
+ resetHighlight: function() {
31
+ this.unset('highlighted');
32
+ },
33
+
34
+ remove: function() {
35
+ this.collection.remove(this);
36
+ }
37
+ });
@@ -0,0 +1,14 @@
1
+ pageflow.PageLinkFileSelectionHandler = function(options) {
2
+ var page = pageflow.pages.getByPermaId(options.id.split(':')[0]);
3
+ var pageLink = page.pageLinks().get(options.id);
4
+
5
+ this.call = function(file) {
6
+ pageLink.setReference(options.attributeName, file);
7
+ };
8
+
9
+ this.getReferer = function() {
10
+ return '/page_links/' + pageLink.id;
11
+ };
12
+ };
13
+
14
+ pageflow.editor.registerFileSelectionHandler('pageLink', pageflow.PageLinkFileSelectionHandler);
@@ -1,5 +1,6 @@
1
1
  pageflow.PreviewEntryData = pageflow.EntryData.extend({
2
2
  initialize: function(options) {
3
+ this.storylines = options.storylines;
3
4
  this.chapters = options.chapters;
4
5
  this.pages = options.pages;
5
6
  this.theming = options.theming;
@@ -9,6 +10,11 @@ pageflow.PreviewEntryData = pageflow.EntryData.extend({
9
10
  return this.theming.get(name);
10
11
  },
11
12
 
13
+ getStorylineConfiguration: function(id) {
14
+ var storyline = this.storylines.get(id);
15
+ return storyline ? storyline.configuration.attributes : {};
16
+ },
17
+
12
18
  getChapterConfiguration: function(id) {
13
19
  var chapter = this.chapters.get(id);
14
20
  return chapter ? chapter.configuration.attributes : {};
@@ -19,6 +25,11 @@ pageflow.PreviewEntryData = pageflow.EntryData.extend({
19
25
  return chapter ? chapter.pages.pluck('perma_id') : [];
20
26
  },
21
27
 
28
+ getStorylineIdByChapterId: function(id) {
29
+ var chapter = this.chapters.get(id);
30
+ return chapter && chapter.get('storyline_id');
31
+ },
32
+
22
33
  getChapterIdByPagePermaId: function(permaId) {
23
34
  var page = this.pages.getByPermaId(permaId);
24
35
  return page && page.get('chapter_id');
@@ -27,5 +38,9 @@ pageflow.PreviewEntryData = pageflow.EntryData.extend({
27
38
  getPageConfiguration: function(permaId) {
28
39
  var page = this.pages.getByPermaId(permaId);
29
40
  return page ? page.configuration.attributes : {};
41
+ },
42
+
43
+ getPagePosition: function(permaId) {
44
+ return this.pages.indexOf(this.pages.getByPermaId(permaId));
30
45
  }
31
46
  });
@@ -0,0 +1,26 @@
1
+ pageflow.Scaffold = pageflow.Object.extend({
2
+ initialize: function(parent, options) {
3
+ this.parent = parent;
4
+ this.options = options || {};
5
+ },
6
+
7
+ create: function() {
8
+ var scaffold = this;
9
+ var query = this.options.depth ? '?depth=' + this.options.depth : '';
10
+
11
+ this.model = this.build();
12
+
13
+ Backbone.sync('create', this.model, {
14
+ url: this.model.url() + '/scaffold' + query,
15
+
16
+ success: function(response) {
17
+ scaffold.load(response);
18
+ scaffold.model.trigger('sync', scaffold.model, response, {});
19
+ }
20
+ });
21
+ },
22
+
23
+ build: function() {},
24
+
25
+ load: function() {}
26
+ });
@@ -0,0 +1,99 @@
1
+ pageflow.Storyline = Backbone.Model.extend({
2
+ modelName: 'storyline',
3
+ paramRoot: 'storyline',
4
+ i18nKey: 'pageflow/storyline',
5
+
6
+ mixins: [pageflow.failureTracking, pageflow.delayedDestroying],
7
+
8
+ initialize: function(attributes, options) {
9
+ this.chapters = new pageflow.StorylineChaptersCollection({
10
+ chapters: options.chapters || pageflow.chapters,
11
+ storyline: this
12
+ });
13
+
14
+ this.configuration = new pageflow.StorylineConfiguration(this.get('configuration') || {});
15
+
16
+ this.listenTo(this.configuration, 'change', function() {
17
+ this.save();
18
+ this.trigger('change:configuration', this);
19
+ });
20
+
21
+ this.listenTo(this.configuration, 'change:main', function(model, value) {
22
+ this.trigger('change:main', this, value);
23
+ });
24
+ },
25
+
26
+ urlRoot: function() {
27
+ return this.isNew() ? this.collection.url() : '/storylines';
28
+ },
29
+
30
+ displayTitle: function() {
31
+ return _([
32
+ this.title() ||
33
+ (!this.isMain() && I18n.t('pageflow.storylines.untitled')),
34
+ this.isMain() && I18n.t('pageflow.storylines.main')
35
+ ]).compact().join(' - ');
36
+ },
37
+
38
+ title: function() {
39
+ return this.configuration.get('title');
40
+ },
41
+
42
+ isMain: function() {
43
+ return !!this.configuration.get('main');
44
+ },
45
+
46
+ lane: function() {
47
+ return this.configuration.get('lane');
48
+ },
49
+
50
+ row: function() {
51
+ return this.configuration.get('row');
52
+ },
53
+
54
+ parentPagePermaId: function() {
55
+ return this.configuration.get('parent_page_perma_id');
56
+ },
57
+
58
+ parentPage: function() {
59
+ return pageflow.pages.getByPermaId(this.parentPagePermaId());
60
+ },
61
+
62
+ transitiveChildPages: function() {
63
+ return new pageflow.StorylineTransitiveChildPages(this, pageflow.storylines, pageflow.pages);
64
+ },
65
+
66
+ addChapter: function(attributes) {
67
+ var chapter = this.buildChapter(attributes);
68
+ chapter.save();
69
+
70
+ return chapter;
71
+ },
72
+
73
+ buildChapter: function(attributes) {
74
+ var defaults = {
75
+ storyline_id: this.id,
76
+ title: '',
77
+ position: this.chapters.length
78
+ };
79
+
80
+ return this.chapters.addAndReturnModel(_.extend(defaults, attributes));
81
+ },
82
+
83
+ scaffoldChapter: function(options) {
84
+ var scaffold = new pageflow.ChapterScaffold(this, options);
85
+ scaffold.create();
86
+
87
+ return scaffold;
88
+ },
89
+
90
+ toJSON: function() {
91
+ return {
92
+ configuration: this.configuration.toJSON()
93
+ };
94
+ },
95
+
96
+ destroy: function() {
97
+ this.destroyWithDelay();
98
+ }
99
+ });