pageflow-sitemap 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.jshintrc +18 -0
  4. data/Gemfile +24 -0
  5. data/LICENSE.md +20 -0
  6. data/README.md +47 -0
  7. data/Rakefile +32 -0
  8. data/app/assets/images/pageflow/sitemap/.keep +0 -0
  9. data/app/assets/javascripts/pageflow/sitemap/.keep +0 -0
  10. data/app/assets/javascripts/pageflow/sitemap/editor/controllers/abstract_controller.js +68 -0
  11. data/app/assets/javascripts/pageflow/sitemap/editor/controllers/editor_mode_controller.js +301 -0
  12. data/app/assets/javascripts/pageflow/sitemap/editor/controllers/fragment_parser.js +31 -0
  13. data/app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_mode_controller.js +37 -0
  14. data/app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js +43 -0
  15. data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/mouse_wheel.js +43 -0
  16. data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/multi_drag.js +73 -0
  17. data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/scroll_and_zoom.js +286 -0
  18. data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/selection_rect.js +104 -0
  19. data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/tooltip_target.js +24 -0
  20. data/app/assets/javascripts/pageflow/sitemap/editor/d3/graph_view.js +277 -0
  21. data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js +33 -0
  22. data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/collision.js +116 -0
  23. data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/dragging_decorator.js +58 -0
  24. data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/grid.js +238 -0
  25. data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/link_dragging_decorator.js +42 -0
  26. data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout.js +94 -0
  27. data/app/assets/javascripts/pageflow/sitemap/editor/d3/options.js +25 -0
  28. data/app/assets/javascripts/pageflow/sitemap/editor/d3/paths/follow_path.js +36 -0
  29. data/app/assets/javascripts/pageflow/sitemap/editor/d3/paths/linkpath.js +64 -0
  30. data/app/assets/javascripts/pageflow/sitemap/editor/d3/paths/successor_path.js +49 -0
  31. data/app/assets/javascripts/pageflow/sitemap/editor/d3/utils.js +33 -0
  32. data/app/assets/javascripts/pageflow/sitemap/editor/d3/view_model.js +202 -0
  33. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/add_button_view.js +28 -0
  34. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/chapter_placeholders_view.js +22 -0
  35. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/chapters_view.js +89 -0
  36. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/group_view.js +104 -0
  37. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/page_links_view.js +7 -0
  38. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/pages_view.js +112 -0
  39. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/selectable_links_view.js +104 -0
  40. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/storylines_view.js +86 -0
  41. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/successor_links_view.js +7 -0
  42. data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/text_label_view.js +45 -0
  43. data/app/assets/javascripts/pageflow/sitemap/editor/d3.js +20 -0
  44. data/app/assets/javascripts/pageflow/sitemap/editor/feature.js +126 -0
  45. data/app/assets/javascripts/pageflow/sitemap/editor/models/selection.js +41 -0
  46. data/app/assets/javascripts/pageflow/sitemap/editor/templates/scroll_bar.jst.ejs +2 -0
  47. data/app/assets/javascripts/pageflow/sitemap/editor/templates/sitemap.jst.ejs +85 -0
  48. data/app/assets/javascripts/pageflow/sitemap/editor/views/scroll_bar_view.js +130 -0
  49. data/app/assets/javascripts/pageflow/sitemap/editor/views/scroll_pane_view.js +73 -0
  50. data/app/assets/javascripts/pageflow/sitemap/editor/views/sitemap_view.js +137 -0
  51. data/app/assets/javascripts/pageflow/sitemap/editor.js +14 -0
  52. data/app/assets/javascripts/pageflow/sitemap/feature.js +3 -0
  53. data/app/assets/javascripts/pageflow/sitemap/scroll_navigator.js +112 -0
  54. data/app/assets/javascripts/pageflow/sitemap.js +5 -0
  55. data/app/assets/stylesheets/pageflow/sitemap/.keep +0 -0
  56. data/app/assets/stylesheets/pageflow/sitemap/editor/add_button.scss +29 -0
  57. data/app/assets/stylesheets/pageflow/sitemap/editor/chapter_placeholders.scss +14 -0
  58. data/app/assets/stylesheets/pageflow/sitemap/editor/chapters.scss +62 -0
  59. data/app/assets/stylesheets/pageflow/sitemap/editor/page_links.scss +19 -0
  60. data/app/assets/stylesheets/pageflow/sitemap/editor/pages.scss +78 -0
  61. data/app/assets/stylesheets/pageflow/sitemap/editor/scroll_bar.css.scss +33 -0
  62. data/app/assets/stylesheets/pageflow/sitemap/editor/scroll_pane.scss +15 -0
  63. data/app/assets/stylesheets/pageflow/sitemap/editor/selectable_links.scss +88 -0
  64. data/app/assets/stylesheets/pageflow/sitemap/editor/selection_rect.scss +12 -0
  65. data/app/assets/stylesheets/pageflow/sitemap/editor/storylines.scss +59 -0
  66. data/app/assets/stylesheets/pageflow/sitemap/editor/successor_links.scss +42 -0
  67. data/app/assets/stylesheets/pageflow/sitemap/editor/text_label.scss +23 -0
  68. data/app/assets/stylesheets/pageflow/sitemap/editor/toolbar.css.scss +45 -0
  69. data/app/assets/stylesheets/pageflow/sitemap/editor.css.scss +96 -0
  70. data/config/locales/de.yml +16 -0
  71. data/config/locales/en.yml +48 -0
  72. data/config/locales/new/help_button.de.yml +7 -0
  73. data/config/locales/new/help_button.en.yml +7 -0
  74. data/config/locales/new/tooltips.de.yml +11 -0
  75. data/config/locales/new/tooltips.en.yml +11 -0
  76. data/config/routes.rb +7 -0
  77. data/config/spring.rb +1 -0
  78. data/exec/rails +12 -0
  79. data/exec/spring +18 -0
  80. data/exec/teaspoon +17 -0
  81. data/lib/pageflow/sitemap/engine.rb +10 -0
  82. data/lib/pageflow/sitemap/plugin.rb +11 -0
  83. data/lib/pageflow/sitemap/version.rb +5 -0
  84. data/lib/pageflow-sitemap.rb +9 -0
  85. data/pageflow-sitemap.gemspec +29 -0
  86. data/spec/d/r/.gitignore +16 -0
  87. data/spec/d/r/README.rdoc +28 -0
  88. data/spec/d/r/Rakefile +6 -0
  89. data/spec/d/r/app/admin/dashboard.rb +33 -0
  90. data/spec/d/r/app/assets/images/.keep +0 -0
  91. data/spec/d/r/app/assets/javascripts/active_admin.js.coffee +2 -0
  92. data/spec/d/r/app/assets/javascripts/application.js +16 -0
  93. data/spec/d/r/app/assets/javascripts/pageflow/application.js +1 -0
  94. data/spec/d/r/app/assets/javascripts/pageflow/editor.js +4 -0
  95. data/spec/d/r/app/assets/stylesheets/active_admin.css.scss +18 -0
  96. data/spec/d/r/app/assets/stylesheets/application.css +13 -0
  97. data/spec/d/r/app/assets/stylesheets/pageflow/application.css.scss +1 -0
  98. data/spec/d/r/app/assets/stylesheets/pageflow/editor.css.scss +1 -0
  99. data/spec/d/r/app/controllers/application_controller.rb +5 -0
  100. data/spec/d/r/app/controllers/concerns/.keep +0 -0
  101. data/spec/d/r/app/helpers/application_helper.rb +2 -0
  102. data/spec/d/r/app/mailers/.keep +0 -0
  103. data/spec/d/r/app/models/.keep +0 -0
  104. data/spec/d/r/app/models/ability.rb +12 -0
  105. data/spec/d/r/app/models/concerns/.keep +0 -0
  106. data/spec/d/r/app/models/user.rb +9 -0
  107. data/spec/d/r/app/views/layouts/application.html.erb +14 -0
  108. data/spec/d/r/bin/bundle +3 -0
  109. data/spec/d/r/bin/rails +4 -0
  110. data/spec/d/r/bin/rake +4 -0
  111. data/spec/d/r/config/application.rb +31 -0
  112. data/spec/d/r/config/boot.rb +4 -0
  113. data/spec/d/r/config/database.yml +39 -0
  114. data/spec/d/r/config/environment.rb +5 -0
  115. data/spec/d/r/config/environments/development.rb +29 -0
  116. data/spec/d/r/config/environments/production.rb +80 -0
  117. data/spec/d/r/config/environments/test.rb +37 -0
  118. data/spec/d/r/config/initializers/active_admin.rb +225 -0
  119. data/spec/d/r/config/initializers/backtrace_silencers.rb +7 -0
  120. data/spec/d/r/config/initializers/devise.rb +252 -0
  121. data/spec/d/r/config/initializers/devise_async.rb +6 -0
  122. data/spec/d/r/config/initializers/filter_parameter_logging.rb +4 -0
  123. data/spec/d/r/config/initializers/friendly_id.rb +88 -0
  124. data/spec/d/r/config/initializers/inflections.rb +16 -0
  125. data/spec/d/r/config/initializers/mime_types.rb +5 -0
  126. data/spec/d/r/config/initializers/pageflow.rb +76 -0
  127. data/spec/d/r/config/initializers/resque.rb +4 -0
  128. data/spec/d/r/config/initializers/resque_enqueue_after_commit_patch.rb +25 -0
  129. data/spec/d/r/config/initializers/resque_logger.rb +16 -0
  130. data/spec/d/r/config/initializers/resque_mailer.rb +4 -0
  131. data/spec/d/r/config/initializers/secret_token.rb +12 -0
  132. data/spec/d/r/config/initializers/session_store.rb +3 -0
  133. data/spec/d/r/config/initializers/wrap_parameters.rb +14 -0
  134. data/spec/d/r/config/locales/devise.en.yml +59 -0
  135. data/spec/d/r/config/locales/en.yml +23 -0
  136. data/spec/d/r/config/routes.rb +59 -0
  137. data/spec/d/r/config.ru +4 -0
  138. data/spec/d/r/db/migrate/00000000000000_create_test_hosted_file.rb +7 -0
  139. data/spec/d/r/db/migrate/00000000000001_create_test_revision_component.rb +10 -0
  140. data/spec/d/r/db/migrate/20150209101518_create_active_admin_comments.rb +19 -0
  141. data/spec/d/r/db/migrate/20150209101524_devise_create_users.rb +46 -0
  142. data/spec/d/r/db/migrate/20150209101530_create_friendly_id_slugs.rb +15 -0
  143. data/spec/d/r/db/migrate/20150209101540_setup_schema.pageflow.rb +208 -0
  144. data/spec/d/r/db/migrate/20150209101541_add_attributes_to_users.pageflow.rb +16 -0
  145. data/spec/d/r/db/migrate/20150209101542_create_themings.pageflow.rb +16 -0
  146. data/spec/d/r/db/migrate/20150209101543_create_themings_for_existing_accounts.pageflow.rb +27 -0
  147. data/spec/d/r/db/migrate/20150209101544_change_theme_references_to_theming_references.pageflow.rb +46 -0
  148. data/spec/d/r/db/migrate/20150209101545_remove_attributes_from_themes.pageflow.rb +11 -0
  149. data/spec/d/r/db/migrate/20150209101546_create_accounts_themes_join_table.pageflow.rb +9 -0
  150. data/spec/d/r/db/migrate/20150209101547_move_cname_from_account_to_theming.pageflow.rb +22 -0
  151. data/spec/d/r/db/migrate/20150209101548_drop_themes.pageflow.rb +15 -0
  152. data/spec/d/r/db/migrate/20150209101549_add_confirmed_by_to_encoded_files.pageflow.rb +7 -0
  153. data/spec/d/r/db/migrate/20150209101550_add_home_url_attributes_to_themings_and_revisions.pageflow.rb +10 -0
  154. data/spec/d/r/db/migrate/20150209101551_create_widgets.pageflow.rb +12 -0
  155. data/spec/d/r/db/migrate/20150209101552_add_emphasize_chapter_beginning_to_revisions.pageflow.rb +6 -0
  156. data/spec/d/r/db/migrate/20150209101553_add_emphasize_new_pages_to_revisions.pageflow.rb +6 -0
  157. data/spec/d/r/db/migrate/20150209101554_add_sharing_image_to_revisions.pageflow.rb +8 -0
  158. data/spec/d/r/db/schema.rb +316 -0
  159. data/spec/d/r/db/seeds.rb +30 -0
  160. data/spec/d/r/lib/assets/.keep +0 -0
  161. data/spec/d/r/lib/tasks/.keep +0 -0
  162. data/spec/d/r/lib/tasks/resque.rake +7 -0
  163. data/spec/d/r/public/404.html +58 -0
  164. data/spec/d/r/public/422.html +58 -0
  165. data/spec/d/r/public/500.html +57 -0
  166. data/spec/d/r/public/favicon.ico +0 -0
  167. data/spec/d/r/public/javascripts/translations.js +2 -0
  168. data/spec/d/r/public/robots.txt +5 -0
  169. data/spec/d/r/vendor/assets/javascripts/.keep +0 -0
  170. data/spec/d/r/vendor/assets/stylesheets/.keep +0 -0
  171. data/spec/javascripts/.jshintrc +26 -0
  172. data/spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js +52 -0
  173. data/spec/javascripts/pageflow/sitemap/editor/d3/layout/collision_spec.js +99 -0
  174. data/spec/javascripts/pageflow/sitemap/editor/d3/layout/dragging_decorator_spec.js +114 -0
  175. data/spec/javascripts/pageflow/sitemap/editor/d3/layout/grid_spec.js +183 -0
  176. data/spec/javascripts/pageflow/sitemap/editor/d3/layout_spec.js +31 -0
  177. data/spec/javascripts/pageflow/sitemap/editor/d3/view_model_spec.js +56 -0
  178. data/spec/javascripts/pageflow/sitemap/editor/models/selection_spec.js +62 -0
  179. data/spec/javascripts/pageflow/sitemap/scroll_navigator_spec.js +5 -0
  180. data/spec/javascripts/spec_helper.js +13 -0
  181. data/spec/javascripts/support/factories.js +81 -0
  182. data/spec/teaspoon_env.rb +182 -0
  183. data/vendor/assets/javascripts/d3.v3.js +9215 -0
  184. metadata +379 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7700735a3babaf67d6d170705527fd3598b57735
4
+ data.tar.gz: 79164f85a72ea5f24efe2973d49d1417c71a5dbe
5
+ SHA512:
6
+ metadata.gz: 1ee7d4b0eafdf0a66db2d1cad94a1481652eb7cdd793417b9bb7387b34c3876c53d1b8eaa2fae1ea8b65486d4adc3e84664bfe46817fcc4d53e90f165dc69ed7
7
+ data.tar.gz: cc0f75e0cb6a56798a18cf1b50b7b984e14fcee706052aa5634827f88ebe2f07226cccb664c785b37191e036ff36d1929c959a322d8080f1d31c41f1c6fc5eba
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sqlite3
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ log
19
+ Gemfile.lock
20
+ .bundle/
21
+ log/*.log
22
+ pkg/
23
+ spec/dummy
24
+
25
+ .localeapp
data/.jshintrc ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "browser": true,
3
+ "undef": true,
4
+ "immed": true,
5
+ "trailing": true,
6
+ "globals": {
7
+ "jQuery": true,
8
+ "$": true,
9
+ "Backbone": true,
10
+ "Cocktail": true,
11
+ "I18n": true,
12
+ "_": true,
13
+ "d3": true,
14
+
15
+ "pageflow": true,
16
+ "sitemap": true
17
+ }
18
+ }
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in pageflow/sitemap.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ gem 'pageflow', path: '.bundle/linked/pageflow' #, git: 'https://github.com/codevise/pageflow.git', :branch => 'master'
9
+
10
+ gem 'sqlite3'
11
+
12
+ gem 'activeadmin', :git => 'https://github.com/codevise/active_admin.git', :branch => 'rails4'
13
+ gem 'ransack'
14
+ gem 'inherited_resources', '1.4.1'
15
+ gem 'formtastic', '2.3.0.rc2'
16
+
17
+ gem 'ejs'
18
+
19
+ gem 'pageflow-support', path: '../pageflow/spec/support'
20
+
21
+ gem 'teaspoon', '~> 0.9.0'
22
+
23
+ gem "spring-commands-rspec", group: :development
24
+ gem "spring-commands-teaspoon", group: :development
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Codevise Solutions Ltd.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Pageflow Sitemap
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pageflow-sitemap.svg)](http://badge.fury.io/rb/pageflow-sitemap)
4
+
5
+ An interactive sitemap for the Pageflow editor.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ # Gemfile
12
+ gem 'pageflow-sitemap'
13
+
14
+ Register the plugin:
15
+
16
+ # config/initializers/pageflow.rb
17
+ Pageflow.configure do |config|
18
+ config.plugin(Pageflow::Sitemap.plugin)
19
+ end
20
+
21
+ Include javascripts and stylesheets:
22
+
23
+ # app/assets/javascripts/pageflow/editor.js
24
+ //= require pageflow/sitemap/editor
25
+
26
+ # app/assets/stylesheets/pageflow/themes/default.css.scss
27
+ @import "pageflow/sitemap/themes/default";
28
+
29
+ Execute `bundle install` and restart the application server.
30
+
31
+ Now you can enable the "Sitemap" feature in your feature settings.
32
+
33
+ ## Troubleshooting
34
+
35
+ If you run into problems while installing the page type, please also
36
+ refer to the
37
+ [Troubleshooting](https://github.com/codevise/pageflow/wiki/Troubleshooting)
38
+ wiki page in the
39
+ [Pageflow repository](https://github.com/codevise/pageflow). If that
40
+ doesn't help, consider
41
+ [filing an issue](https://github.com/codevise/pageflow-sitemap/issues).
42
+
43
+ ## Contributing Locales
44
+
45
+ Edit the translations directly on the
46
+ [pageflow-sitemap](http://www.localeapp.com/projects/public?search=tf/pageflow-sitemap)
47
+ locale project.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'PageflowSitemap'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ require 'semmy'
20
+ Semmy::Tasks.install
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
File without changes
File without changes
@@ -0,0 +1,68 @@
1
+ /*globals _, sitemap, pageflow */
2
+
3
+ sitemap.AbstractController = pageflow.Object.extend({
4
+ lineSelected: function (line, event) {},
5
+
6
+ storylineSelected: function (storyline, event) {},
7
+
8
+ storylinesSelected: function (storylines) {},
9
+
10
+ chapterSelected: function (chapter, event) {},
11
+
12
+ pageSelected: function (page, event) {},
13
+
14
+ pageDblClick: function (page, event) {},
15
+
16
+ pageLinkSelected: function (pageLink) {},
17
+
18
+ pageLinkDroppedOnPage: function(links, link, page) {},
19
+
20
+ newPageLinkDroppedOnPage: function(links, page) {},
21
+
22
+ pageLinkDroppedOnPlaceholder: function(sourcePage, links, link, laneAndRow) {},
23
+
24
+ newPageLinkDroppedOnPlaceholder: function(sourcePage, links, laneAndRow) {},
25
+
26
+ successorLinkSelected: function (link) {},
27
+
28
+ successorLinkDroppedOnPage: function(page, targetPage) {},
29
+
30
+ successorLinkDroppedOnPlaceholder: function(page, laneAndRow) {},
31
+
32
+ storylinesPositioned: function(updates) {},
33
+
34
+ pagesMoved: function(pagesGroupedByChapters) {},
35
+
36
+ addPage: function (chapter) {},
37
+
38
+ insertPageAfter: function (page) {},
39
+
40
+ addChapter: function(storyline, configuration) {},
41
+
42
+ insertChapterAfter: function(targetChapter) {},
43
+
44
+ chaptersMoved: function(chaptersGroupedByStorylines) {},
45
+
46
+ addStoryline: function(configuration) {},
47
+
48
+ addUpdateHandler: function (handler) {
49
+ var timeout;
50
+
51
+ this.addDebouncedUpdateHandler(function(/* args */) {
52
+ var args = arguments;
53
+
54
+ timeout = timeout || setTimeout(function() {
55
+ timeout = null;
56
+ handler.apply(this, args);
57
+ }, 1);
58
+ });
59
+ },
60
+
61
+ addDebouncedUpdateHandler: function(handler) {},
62
+
63
+ dispose: function() {
64
+ this.stopListening();
65
+ }
66
+ });
67
+
68
+ _.extend(sitemap.AbstractController, Backbone.Events);
@@ -0,0 +1,301 @@
1
+ pageflow.sitemap.EditorModeController = pageflow.sitemap.AbstractController.extend({
2
+ name: 'editor_mode',
3
+
4
+ initialize: function() {
5
+ var s = pageflow.sitemap;
6
+
7
+ this.selection = new s.Selection();
8
+
9
+ new s.FragmentParser(
10
+ pageflow.entry,
11
+ Backbone.history.fragment
12
+ ).select(this.selection);
13
+
14
+ new s.SelectionNavigator({
15
+ selection: this.selection,
16
+ multiSelectionPath: '/'
17
+ }).attach();
18
+ },
19
+
20
+ storylinesSelected: function (storylines) {
21
+ this.selection.select('storylines', storylines);
22
+ },
23
+
24
+ storylineSelected: function (storyline, event) {
25
+ if (!this.selection.contains(storyline)) {
26
+ this.selection.select('storylines', [storyline], {
27
+ additive: event.ctrlKey
28
+ });
29
+ }
30
+ },
31
+
32
+ storylineDblClick: function(storyline) {
33
+ this.trigger('showStoryline', storyline);
34
+ },
35
+
36
+ chapterSelected: function (chapter, event) {
37
+ if (!this.selection.contains(chapter)) {
38
+ this.selection.select('chapters', [chapter], {
39
+ additive: event.ctrlKey
40
+ });
41
+ }
42
+ },
43
+
44
+ pageSelected: function (page, event) {
45
+ if (!this.selection.contains(page)) {
46
+ this.selection.select('pages', [page], {
47
+ additive: event.ctrlKey
48
+ });
49
+ }
50
+ },
51
+
52
+ pageDblClick: function(page) {
53
+ this.trigger('showPage', page);
54
+ },
55
+
56
+ pageLinkSelected: function (pageLink) {
57
+ this.selection.select('pageLinks', [pageLink]);
58
+ },
59
+
60
+ pageLinkDroppedOnPage: function(links, link, page) {
61
+ links.updateLink(link, page.get('perma_id'));
62
+ },
63
+
64
+ newPageLinkDroppedOnPage: function(links, page) {
65
+ links.addLink(page.get('perma_id'));
66
+ },
67
+
68
+ pageLinkDroppedOnPlaceholder: function(sourcePage, links, link, laneAndRow) {
69
+ var configuration = _.extend({
70
+ parent_page_perma_id: sourcePage.get('perma_id')
71
+ }, laneAndRow);
72
+
73
+ pageflow.entry.addPageInNewStoryline({
74
+ storylineAttributes: {configuration: configuration}
75
+ }).persisted().then(function(page) {
76
+ links.updateLink(link, page.get('perma_id'));
77
+ });
78
+ },
79
+
80
+ newPageLinkDroppedOnPlaceholder: function(sourcePage, links, laneAndRow) {
81
+ var configuration = _.extend({
82
+ parent_page_perma_id: sourcePage.get('perma_id')
83
+ }, laneAndRow);
84
+
85
+ pageflow.entry.addPageInNewStoryline({
86
+ storylineAttributes: {configuration: configuration}
87
+ }).persisted().then(function(page) {
88
+ links.addLink(page.get('perma_id'));
89
+ });
90
+ },
91
+
92
+ successorLinkSelected: function (link) {
93
+ this.selection.select('successorLinks', [link]);
94
+ },
95
+
96
+ successorLinkDroppedOnPage: function(storyline, targetPage) {
97
+ if (targetPage) {
98
+ storyline.configuration.set('scroll_successor_id', targetPage.get('perma_id'));
99
+ }
100
+ },
101
+
102
+ successorLinkDroppedOnPlaceholder: function(storyline, configuration) {
103
+ pageflow.entry.addPageInNewStoryline({
104
+ storylineAttributes: {configuration: configuration}
105
+ }).persisted().then(function(page) {
106
+ storyline.configuration.set('scroll_successor_id', page.get('perma_id'));
107
+ });
108
+ },
109
+
110
+ storylinesPositioned: function(updates) {
111
+ // FIXME should have batch update for chapters
112
+ _.each(updates, function(update) {
113
+ update.storyline.configuration.set({
114
+ row: update.row,
115
+ lane: update.lane
116
+ });
117
+ }, this);
118
+ },
119
+
120
+ chaptersMoved: function(chaptersGroupedByStorylines, laneAndRow) {
121
+ _.each(chaptersGroupedByStorylines, function(update) {
122
+ if (!update.storyline &&
123
+ update.chapters.length === update.chapters[0].storyline.chapters.length) {
124
+
125
+ update.chapters[0].storyline.configuration.set(laneAndRow);
126
+ return;
127
+ }
128
+
129
+ var storyline = update.storyline || pageflow.entry.addStoryline({configuration: laneAndRow});
130
+ var changeFound = false;
131
+
132
+ _.each(update.chapters, function(chapter, index) {
133
+ if (chapter.get('position') !== index) {
134
+ changeFound = true;
135
+ chapter.set('position', index);
136
+ }
137
+
138
+ if (chapter.storyline !== storyline) {
139
+ changeFound = true;
140
+
141
+ chapter.storyline.chapters.remove(chapter);
142
+ storyline.chapters.add(chapter);
143
+ }
144
+ });
145
+
146
+ if (changeFound) {
147
+ storyline.chapters.sort();
148
+
149
+ storyline.persisted().then(function() {
150
+ storyline.chapters.saveOrder();
151
+ });
152
+ }
153
+ });
154
+ },
155
+
156
+ pagesMoved: function(pagesGroupedByChapters, laneAndRow) {
157
+ _.each(pagesGroupedByChapters, function(update) {
158
+ if (!update.chapter &&
159
+ update.pages.length === update.pages[0].chapter.pages.length) {
160
+
161
+ update.pages[0].chapter.configuration.set(laneAndRow);
162
+ return;
163
+ }
164
+
165
+ var chapter = update.chapter || pageflow.entry.addChapterInNewStoryline({
166
+ storylineAttributes: {configuration: laneAndRow}
167
+ });
168
+
169
+ var changeFound = false;
170
+
171
+ _.each(update.pages, function(page, index) {
172
+ if (page.get('position') !== index) {
173
+ changeFound = true;
174
+ page.set('position', index);
175
+ }
176
+
177
+ if (page.chapter !== chapter) {
178
+ changeFound = true;
179
+
180
+ page.chapter.pages.remove(page);
181
+ chapter.pages.add(page);
182
+ }
183
+ });
184
+
185
+ if (changeFound) {
186
+ chapter.pages.sort();
187
+
188
+ chapter.persisted().then(function() {
189
+ chapter.pages.saveOrder();
190
+ });
191
+ }
192
+ });
193
+ },
194
+
195
+ addPage: function (chapter) {
196
+ var page = chapter.addPage();
197
+ var selection = this.selection;
198
+
199
+ page.once('sync', function() {
200
+ selection.select('pages', [page]);
201
+ });
202
+ },
203
+
204
+ insertPageAfter: function (targetPage) {
205
+ var chapter = targetPage.chapter;
206
+ var selection = this.selection;
207
+ var delta = 0;
208
+
209
+ chapter.pages.each(function(page, index) {
210
+ page.set('position', index + delta);
211
+
212
+ if (page === targetPage) {
213
+ delta = 1;
214
+ }
215
+ });
216
+
217
+ var newPage = chapter.addPage({
218
+ position: targetPage.get('position') + 1
219
+ });
220
+
221
+ chapter.pages.sort();
222
+ chapter.pages.saveOrder();
223
+
224
+ newPage.once('sync', function() {
225
+ selection.select('pages', [newPage]);
226
+ });
227
+ },
228
+
229
+ addChapter: function(storyline, configuration) {
230
+ var selection = this.selection;
231
+ var chapter = storyline.scaffoldChapter({configuration: configuration}).chapter;
232
+
233
+ chapter.once('sync', function() {
234
+ selection.select('chapters', [chapter]);
235
+ });
236
+ },
237
+
238
+ insertChapterAfter: function(targetChapter) {
239
+ var storyline = targetChapter.storyline;
240
+ var selection = this.selection;
241
+ var delta = 0;
242
+
243
+ storyline.chapters.each(function(chapter, index) {
244
+ chapter.set('position', index + delta);
245
+
246
+ if (chapter === targetChapter) {
247
+ delta = 1;
248
+ }
249
+ });
250
+
251
+ var newChapter = storyline.scaffoldChapter({
252
+ chapterAttributes: {position: targetChapter.get('position') + 1}
253
+ }).chapter;
254
+
255
+ storyline.chapters.sort();
256
+ storyline.chapters.saveOrder();
257
+
258
+ newChapter.once('sync', function() {
259
+ selection.select('chapters', [newChapter]);
260
+ });
261
+ },
262
+
263
+ addStoryline: function(configuration) {
264
+ pageflow.entry.addPageInNewStoryline({
265
+ storylineAttributes: {configuration: configuration}
266
+ });
267
+ },
268
+
269
+ addDebouncedUpdateHandler: function (handler) {
270
+ var session = {
271
+ entry: pageflow.entry,
272
+ selection: this.selection
273
+ };
274
+
275
+ handler(session);
276
+
277
+ this.listenTo(pageflow.chapters, 'remove', function() {
278
+ this.selection.reset();
279
+ });
280
+
281
+ this.listenTo(pageflow.pages, 'destroying', function() {
282
+ this.selection.reset();
283
+ });
284
+
285
+ this.listenTo(pageflow.storylines, 'add remove destroying change change:configuration', function() {
286
+ handler(session);
287
+ });
288
+
289
+ this.listenTo(pageflow.chapters, 'add remove destroying change change:configuration', function() {
290
+ handler(session);
291
+ });
292
+
293
+ this.listenTo(pageflow.pages, 'add remove destroying destroy change change:configuration', function() {
294
+ handler(session);
295
+ });
296
+
297
+ this.listenTo(this.selection, 'change', function() {
298
+ handler(session);
299
+ });
300
+ }
301
+ });
@@ -0,0 +1,31 @@
1
+ pageflow.sitemap.FragmentParser = pageflow.Object.extend({
2
+ patterns: {
3
+ storylines: /^\/?storylines\/(\d+)/,
4
+ chapters: /^\/?chapters\/(\d+)/,
5
+ pages: /^\/?pages\/(\d+)/
6
+ },
7
+
8
+ initialize: function(entry, fragment) {
9
+ this.entry = entry;
10
+ this.fragment = fragment;
11
+ },
12
+
13
+ select: function(selection) {
14
+ _(this.patterns).any(function(pattern, name) {
15
+ var model = this.getModel(name);
16
+
17
+ if (model) {
18
+ selection.select(name, model);
19
+ return true;
20
+ }
21
+ }, this);
22
+ },
23
+
24
+ getModel: function(name) {
25
+ var match = this.fragment.match(this.patterns[name]);
26
+
27
+ if (match) {
28
+ return this.entry[name].get(match[1]);
29
+ }
30
+ }
31
+ });
@@ -0,0 +1,37 @@
1
+ pageflow.sitemap.SelectionModeController = pageflow.sitemap.AbstractController.extend({
2
+ name: 'selection_mode',
3
+
4
+ initialize: function(entry, options) {
5
+ this.entry = entry;
6
+ this.options = options || {};
7
+ },
8
+
9
+ pageSelected: function (page) {
10
+ this.trigger('selected', page);
11
+ },
12
+
13
+ addDebouncedUpdateHandler: function (handler) {
14
+ var fragmentParser = new pageflow.sitemap.FragmentParser(this.entry, Backbone.history.fragment);
15
+ var options = this.options;
16
+
17
+ var session = {
18
+ entry: this.entry,
19
+ selection: new pageflow.sitemap.Selection(),
20
+ isPageDisabled: function(page) {
21
+ return options.isAllowed && !options.isAllowed(page);
22
+ },
23
+ highlightedPage: this.options.noHighlight ? null : fragmentParser.getModel('pages'),
24
+ highlightedStoryline: this.options.noHighlight ? null : fragmentParser.getModel('storylines')
25
+ };
26
+
27
+ handler(session);
28
+
29
+ this.listenTo(this.entry.chapters, 'add remove destroying change:configuration', function() {
30
+ handler(session);
31
+ });
32
+
33
+ this.listenTo(this.entry.pages, 'add remove destroying destroy change change:configuration', function() {
34
+ handler(session);
35
+ });
36
+ }
37
+ });
@@ -0,0 +1,43 @@
1
+ pageflow.sitemap.SelectionNavigator = pageflow.Object.extend({
2
+ initialize: function(options) {
3
+ this.api = options.api || pageflow.editor;
4
+ this.selection = options.selection;
5
+ this.options = options;
6
+ },
7
+
8
+ attach: function() {
9
+ this.listenToSelection('pages', function(page) {
10
+ return '/pages/' + page.id;
11
+ });
12
+
13
+ this.listenToSelection('chapters', function(chapter) {
14
+ return '/chapters/' + chapter.id;
15
+ });
16
+
17
+ this.listenToSelection('storylines', function(storyline) {
18
+ return '/storylines/' + storyline.id;
19
+ });
20
+
21
+ this.listenToSelection('successorLinks', function(link) {
22
+ return '/storylines/' + link.successor.id;
23
+ });
24
+
25
+ this.listenToSelection('pageLinks', function(pageLink) {
26
+ return pageLink.editPath ? pageLink.editPath() : this.options.emptySelectionPath;
27
+ });
28
+ },
29
+
30
+ listenToSelection: function(name, path) {
31
+ this.listenTo(this.selection, 'select:' + name, function(models) {
32
+ if (models.length === 1) {
33
+ this.api.navigate(path(models[0]), {trigger: true});
34
+ }
35
+ else if (models.length > 1) {
36
+ this.api.navigate(this.options.multiSelectionPath, {trigger: true});
37
+ }
38
+ else {
39
+ this.api.navigate(this.options.emptySelectionPath, {trigger: true});
40
+ }
41
+ });
42
+ }
43
+ });