pageflow-sitemap 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.jshintrc +18 -0
- data/Gemfile +24 -0
- data/LICENSE.md +20 -0
- data/README.md +47 -0
- data/Rakefile +32 -0
- data/app/assets/images/pageflow/sitemap/.keep +0 -0
- data/app/assets/javascripts/pageflow/sitemap/.keep +0 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/controllers/abstract_controller.js +68 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/controllers/editor_mode_controller.js +301 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/controllers/fragment_parser.js +31 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_mode_controller.js +37 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/controllers/selection_navigator.js +43 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/mouse_wheel.js +43 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/multi_drag.js +73 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/scroll_and_zoom.js +286 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/selection_rect.js +104 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/behaviors/tooltip_target.js +24 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/graph_view.js +277 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/chapter_collision.js +33 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/collision.js +116 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/dragging_decorator.js +58 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/grid.js +238 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout/link_dragging_decorator.js +42 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/layout.js +94 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/options.js +25 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/paths/follow_path.js +36 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/paths/linkpath.js +64 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/paths/successor_path.js +49 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/utils.js +33 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/view_model.js +202 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/add_button_view.js +28 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/chapter_placeholders_view.js +22 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/chapters_view.js +89 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/group_view.js +104 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/page_links_view.js +7 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/pages_view.js +112 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/selectable_links_view.js +104 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/storylines_view.js +86 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/successor_links_view.js +7 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3/views/text_label_view.js +45 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/d3.js +20 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/feature.js +126 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/models/selection.js +41 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/templates/scroll_bar.jst.ejs +2 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/templates/sitemap.jst.ejs +85 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/views/scroll_bar_view.js +130 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/views/scroll_pane_view.js +73 -0
- data/app/assets/javascripts/pageflow/sitemap/editor/views/sitemap_view.js +137 -0
- data/app/assets/javascripts/pageflow/sitemap/editor.js +14 -0
- data/app/assets/javascripts/pageflow/sitemap/feature.js +3 -0
- data/app/assets/javascripts/pageflow/sitemap/scroll_navigator.js +112 -0
- data/app/assets/javascripts/pageflow/sitemap.js +5 -0
- data/app/assets/stylesheets/pageflow/sitemap/.keep +0 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/add_button.scss +29 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/chapter_placeholders.scss +14 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/chapters.scss +62 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/page_links.scss +19 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/pages.scss +78 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/scroll_bar.css.scss +33 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/scroll_pane.scss +15 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/selectable_links.scss +88 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/selection_rect.scss +12 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/storylines.scss +59 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/successor_links.scss +42 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/text_label.scss +23 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor/toolbar.css.scss +45 -0
- data/app/assets/stylesheets/pageflow/sitemap/editor.css.scss +96 -0
- data/config/locales/de.yml +16 -0
- data/config/locales/en.yml +48 -0
- data/config/locales/new/help_button.de.yml +7 -0
- data/config/locales/new/help_button.en.yml +7 -0
- data/config/locales/new/tooltips.de.yml +11 -0
- data/config/locales/new/tooltips.en.yml +11 -0
- data/config/routes.rb +7 -0
- data/config/spring.rb +1 -0
- data/exec/rails +12 -0
- data/exec/spring +18 -0
- data/exec/teaspoon +17 -0
- data/lib/pageflow/sitemap/engine.rb +10 -0
- data/lib/pageflow/sitemap/plugin.rb +11 -0
- data/lib/pageflow/sitemap/version.rb +5 -0
- data/lib/pageflow-sitemap.rb +9 -0
- data/pageflow-sitemap.gemspec +29 -0
- data/spec/d/r/.gitignore +16 -0
- data/spec/d/r/README.rdoc +28 -0
- data/spec/d/r/Rakefile +6 -0
- data/spec/d/r/app/admin/dashboard.rb +33 -0
- data/spec/d/r/app/assets/images/.keep +0 -0
- data/spec/d/r/app/assets/javascripts/active_admin.js.coffee +2 -0
- data/spec/d/r/app/assets/javascripts/application.js +16 -0
- data/spec/d/r/app/assets/javascripts/pageflow/application.js +1 -0
- data/spec/d/r/app/assets/javascripts/pageflow/editor.js +4 -0
- data/spec/d/r/app/assets/stylesheets/active_admin.css.scss +18 -0
- data/spec/d/r/app/assets/stylesheets/application.css +13 -0
- data/spec/d/r/app/assets/stylesheets/pageflow/application.css.scss +1 -0
- data/spec/d/r/app/assets/stylesheets/pageflow/editor.css.scss +1 -0
- data/spec/d/r/app/controllers/application_controller.rb +5 -0
- data/spec/d/r/app/controllers/concerns/.keep +0 -0
- data/spec/d/r/app/helpers/application_helper.rb +2 -0
- data/spec/d/r/app/mailers/.keep +0 -0
- data/spec/d/r/app/models/.keep +0 -0
- data/spec/d/r/app/models/ability.rb +12 -0
- data/spec/d/r/app/models/concerns/.keep +0 -0
- data/spec/d/r/app/models/user.rb +9 -0
- data/spec/d/r/app/views/layouts/application.html.erb +14 -0
- data/spec/d/r/bin/bundle +3 -0
- data/spec/d/r/bin/rails +4 -0
- data/spec/d/r/bin/rake +4 -0
- data/spec/d/r/config/application.rb +31 -0
- data/spec/d/r/config/boot.rb +4 -0
- data/spec/d/r/config/database.yml +39 -0
- data/spec/d/r/config/environment.rb +5 -0
- data/spec/d/r/config/environments/development.rb +29 -0
- data/spec/d/r/config/environments/production.rb +80 -0
- data/spec/d/r/config/environments/test.rb +37 -0
- data/spec/d/r/config/initializers/active_admin.rb +225 -0
- data/spec/d/r/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/d/r/config/initializers/devise.rb +252 -0
- data/spec/d/r/config/initializers/devise_async.rb +6 -0
- data/spec/d/r/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/d/r/config/initializers/friendly_id.rb +88 -0
- data/spec/d/r/config/initializers/inflections.rb +16 -0
- data/spec/d/r/config/initializers/mime_types.rb +5 -0
- data/spec/d/r/config/initializers/pageflow.rb +76 -0
- data/spec/d/r/config/initializers/resque.rb +4 -0
- data/spec/d/r/config/initializers/resque_enqueue_after_commit_patch.rb +25 -0
- data/spec/d/r/config/initializers/resque_logger.rb +16 -0
- data/spec/d/r/config/initializers/resque_mailer.rb +4 -0
- data/spec/d/r/config/initializers/secret_token.rb +12 -0
- data/spec/d/r/config/initializers/session_store.rb +3 -0
- data/spec/d/r/config/initializers/wrap_parameters.rb +14 -0
- data/spec/d/r/config/locales/devise.en.yml +59 -0
- data/spec/d/r/config/locales/en.yml +23 -0
- data/spec/d/r/config/routes.rb +59 -0
- data/spec/d/r/config.ru +4 -0
- data/spec/d/r/db/migrate/00000000000000_create_test_hosted_file.rb +7 -0
- data/spec/d/r/db/migrate/00000000000001_create_test_revision_component.rb +10 -0
- data/spec/d/r/db/migrate/20150209101518_create_active_admin_comments.rb +19 -0
- data/spec/d/r/db/migrate/20150209101524_devise_create_users.rb +46 -0
- data/spec/d/r/db/migrate/20150209101530_create_friendly_id_slugs.rb +15 -0
- data/spec/d/r/db/migrate/20150209101540_setup_schema.pageflow.rb +208 -0
- data/spec/d/r/db/migrate/20150209101541_add_attributes_to_users.pageflow.rb +16 -0
- data/spec/d/r/db/migrate/20150209101542_create_themings.pageflow.rb +16 -0
- data/spec/d/r/db/migrate/20150209101543_create_themings_for_existing_accounts.pageflow.rb +27 -0
- data/spec/d/r/db/migrate/20150209101544_change_theme_references_to_theming_references.pageflow.rb +46 -0
- data/spec/d/r/db/migrate/20150209101545_remove_attributes_from_themes.pageflow.rb +11 -0
- data/spec/d/r/db/migrate/20150209101546_create_accounts_themes_join_table.pageflow.rb +9 -0
- data/spec/d/r/db/migrate/20150209101547_move_cname_from_account_to_theming.pageflow.rb +22 -0
- data/spec/d/r/db/migrate/20150209101548_drop_themes.pageflow.rb +15 -0
- data/spec/d/r/db/migrate/20150209101549_add_confirmed_by_to_encoded_files.pageflow.rb +7 -0
- data/spec/d/r/db/migrate/20150209101550_add_home_url_attributes_to_themings_and_revisions.pageflow.rb +10 -0
- data/spec/d/r/db/migrate/20150209101551_create_widgets.pageflow.rb +12 -0
- data/spec/d/r/db/migrate/20150209101552_add_emphasize_chapter_beginning_to_revisions.pageflow.rb +6 -0
- data/spec/d/r/db/migrate/20150209101553_add_emphasize_new_pages_to_revisions.pageflow.rb +6 -0
- data/spec/d/r/db/migrate/20150209101554_add_sharing_image_to_revisions.pageflow.rb +8 -0
- data/spec/d/r/db/schema.rb +316 -0
- data/spec/d/r/db/seeds.rb +30 -0
- data/spec/d/r/lib/assets/.keep +0 -0
- data/spec/d/r/lib/tasks/.keep +0 -0
- data/spec/d/r/lib/tasks/resque.rake +7 -0
- data/spec/d/r/public/404.html +58 -0
- data/spec/d/r/public/422.html +58 -0
- data/spec/d/r/public/500.html +57 -0
- data/spec/d/r/public/favicon.ico +0 -0
- data/spec/d/r/public/javascripts/translations.js +2 -0
- data/spec/d/r/public/robots.txt +5 -0
- data/spec/d/r/vendor/assets/javascripts/.keep +0 -0
- data/spec/d/r/vendor/assets/stylesheets/.keep +0 -0
- data/spec/javascripts/.jshintrc +26 -0
- data/spec/javascripts/pageflow/sitemap/editor/controllers/selection_navigator_spec.js +52 -0
- data/spec/javascripts/pageflow/sitemap/editor/d3/layout/collision_spec.js +99 -0
- data/spec/javascripts/pageflow/sitemap/editor/d3/layout/dragging_decorator_spec.js +114 -0
- data/spec/javascripts/pageflow/sitemap/editor/d3/layout/grid_spec.js +183 -0
- data/spec/javascripts/pageflow/sitemap/editor/d3/layout_spec.js +31 -0
- data/spec/javascripts/pageflow/sitemap/editor/d3/view_model_spec.js +56 -0
- data/spec/javascripts/pageflow/sitemap/editor/models/selection_spec.js +62 -0
- data/spec/javascripts/pageflow/sitemap/scroll_navigator_spec.js +5 -0
- data/spec/javascripts/spec_helper.js +13 -0
- data/spec/javascripts/support/factories.js +81 -0
- data/spec/teaspoon_env.rb +182 -0
- data/vendor/assets/javascripts/d3.v3.js +9215 -0
- metadata +379 -0
@@ -0,0 +1,277 @@
|
|
1
|
+
(function() {
|
2
|
+
var s = pageflow.sitemap;
|
3
|
+
|
4
|
+
s.GraphView = function(svgElement, controller, options) {
|
5
|
+
options = options || {};
|
6
|
+
|
7
|
+
var svg = d3.select(svgElement)
|
8
|
+
.attr('width', '100%')
|
9
|
+
.attr('height', '100%');
|
10
|
+
|
11
|
+
var svgGroup = svg.select('g.all');
|
12
|
+
var svgStorylines = svg.select('g.lines');
|
13
|
+
var svgChapters = svg.select('g.chapters');
|
14
|
+
var svgPages = svg.select('g.pages');
|
15
|
+
var svgLinks = svg.select('g.links');
|
16
|
+
|
17
|
+
var scrollAndZoom = s.behavior.scrollAndZoom({
|
18
|
+
margin: 50,
|
19
|
+
change: function(event) {
|
20
|
+
svgGroup.attr('transform', 'translate(' + event.translate + ')scale(' + event.scale + ')');
|
21
|
+
}
|
22
|
+
});
|
23
|
+
|
24
|
+
var selectionRect = s.behavior.selectionRect({
|
25
|
+
container: 'g.all',
|
26
|
+
targets: '.storyline',
|
27
|
+
selected: function(storylines) {
|
28
|
+
controller.storylinesSelected(_(storylines).pluck('storyline'));
|
29
|
+
}
|
30
|
+
});
|
31
|
+
|
32
|
+
this.resize = function() {
|
33
|
+
scrollAndZoom.updateSize(parseInt(svg.style('width'), 10),
|
34
|
+
parseInt(svg.style('height'), 10));
|
35
|
+
};
|
36
|
+
|
37
|
+
d3.rebind(this, scrollAndZoom,
|
38
|
+
'on',
|
39
|
+
'getViewport',
|
40
|
+
'scrollBy',
|
41
|
+
'getScale', 'setScale',
|
42
|
+
'getScrollX', 'setScrollX',
|
43
|
+
'getScrollY', 'setScrollY',
|
44
|
+
'getScrollWindowProportionX',
|
45
|
+
'getScrollWindowProportionY');
|
46
|
+
|
47
|
+
svg
|
48
|
+
.call(scrollAndZoom)
|
49
|
+
.call(selectionRect);
|
50
|
+
|
51
|
+
controller.addUpdateHandler(update);
|
52
|
+
|
53
|
+
function updateScrollAndZoom(session, layout) {
|
54
|
+
var selection = session.selection;
|
55
|
+
|
56
|
+
scrollAndZoom.updateConstraints({
|
57
|
+
minX: -(layout.size.x + layout.laneWidth / 2),
|
58
|
+
minY: -(layout.size.y + layout.rowHeight / 2),
|
59
|
+
maxX: layout.laneWidth / 2,
|
60
|
+
maxY: layout.rowHeight / 2,
|
61
|
+
});
|
62
|
+
|
63
|
+
var centerTarget = session.highlightedPage ||
|
64
|
+
selection.get('pages')[0] ||
|
65
|
+
selection.get('chapters')[0];
|
66
|
+
|
67
|
+
scrollAndZoom.ensureViewport({
|
68
|
+
centerAt: centerTarget && layout.position(centerTarget),
|
69
|
+
defaultViewport: options.defaultViewport
|
70
|
+
});
|
71
|
+
}
|
72
|
+
|
73
|
+
function update(session, layoutOptions) {
|
74
|
+
var entry = session.entry;
|
75
|
+
var selection = session.selection;
|
76
|
+
|
77
|
+
var layout =
|
78
|
+
s.layout.create(entry, selection, layoutOptions);
|
79
|
+
|
80
|
+
var viewModel =
|
81
|
+
new s.ViewModel(session, layout);
|
82
|
+
|
83
|
+
updateScrollAndZoom(session, layout);
|
84
|
+
|
85
|
+
svg
|
86
|
+
.on('dblclick', function() {
|
87
|
+
if (d3.event.target !== svg.node()) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
controller.addStoryline(layout.laneAndRowFromPoint(scrollAndZoom.pointTo({
|
92
|
+
x: d3.event.clientX,
|
93
|
+
y: d3.event.clientY,
|
94
|
+
})));
|
95
|
+
});
|
96
|
+
|
97
|
+
svgStorylines.call(s.storylinesView(viewModel.storylines, {
|
98
|
+
mousedown: function(source) {
|
99
|
+
controller.storylineSelected(source.storyline, d3.event);
|
100
|
+
},
|
101
|
+
|
102
|
+
dblclick: function(source) {
|
103
|
+
controller.storylineDblClick(source.storyline, d3.event);
|
104
|
+
},
|
105
|
+
|
106
|
+
drag: function(options) {
|
107
|
+
update(session, {dragDelta: {x: options.dx, y: options.dy}});
|
108
|
+
},
|
109
|
+
|
110
|
+
dragend: function(options) {
|
111
|
+
var layout = s.layout.create(entry, selection, {
|
112
|
+
dragDelta: {
|
113
|
+
x: options.dx,
|
114
|
+
y: options.dy
|
115
|
+
}
|
116
|
+
});
|
117
|
+
|
118
|
+
controller.storylinesPositioned(_.map(selection.get('storylines'), function(storyline) {
|
119
|
+
var coordinates = layout.laneAndRowFromPoint(layout.position(storyline));
|
120
|
+
|
121
|
+
return {
|
122
|
+
storyline: storyline,
|
123
|
+
lane: coordinates.lane,
|
124
|
+
row: coordinates.row
|
125
|
+
};
|
126
|
+
}));
|
127
|
+
|
128
|
+
update(session);
|
129
|
+
},
|
130
|
+
}));
|
131
|
+
|
132
|
+
svgChapters.call(s.chaptersView(viewModel.chapters, {
|
133
|
+
mousedown: function(source) {
|
134
|
+
controller.chapterSelected(source.chapter, d3.event);
|
135
|
+
},
|
136
|
+
|
137
|
+
drag: function(options) {
|
138
|
+
update(session, {dragDelta: {x: options.dx, y: options.dy}});
|
139
|
+
},
|
140
|
+
|
141
|
+
dragend: function(options) {
|
142
|
+
var layout = s.layout.create(entry, selection, {
|
143
|
+
dragDelta: {
|
144
|
+
x: options.dx,
|
145
|
+
y: options.dy
|
146
|
+
}
|
147
|
+
});
|
148
|
+
|
149
|
+
controller.chaptersMoved(layout.chaptersGroupedByStorylines,
|
150
|
+
layout.laneAndRowFromPoint(scrollAndZoom.pointTo({
|
151
|
+
x: d3.event.sourceEvent.clientX,
|
152
|
+
y: d3.event.sourceEvent.clientY
|
153
|
+
})));
|
154
|
+
|
155
|
+
update(session);
|
156
|
+
},
|
157
|
+
|
158
|
+
addChapterButtonClick: function(d) {
|
159
|
+
controller.insertChapterAfter(d.chapter);
|
160
|
+
}
|
161
|
+
}));
|
162
|
+
|
163
|
+
svgPages.call(s.pagesView(viewModel.nodes, {
|
164
|
+
mousedown: function(source) {
|
165
|
+
controller.pageSelected(source.page, d3.event);
|
166
|
+
},
|
167
|
+
|
168
|
+
dblclick: function(source) {
|
169
|
+
controller.pageDblClick(source.page, d3.event);
|
170
|
+
},
|
171
|
+
|
172
|
+
drag: function(options) {
|
173
|
+
update(session, {dragDelta: {x: options.dx, y: options.dy}});
|
174
|
+
},
|
175
|
+
|
176
|
+
dragend: function(options) {
|
177
|
+
if (Math.abs(options.dx) > 10 || Math.abs(options.dy) > 10) {
|
178
|
+
var layout = s.layout.create(entry, selection, {
|
179
|
+
dragDelta: {
|
180
|
+
x: options.dx,
|
181
|
+
y: options.dy
|
182
|
+
}
|
183
|
+
});
|
184
|
+
|
185
|
+
controller.pagesMoved(layout.pagesGroupedByChapters,
|
186
|
+
layout.laneAndRowFromPoint(scrollAndZoom.pointTo({
|
187
|
+
x: d3.event.sourceEvent.clientX,
|
188
|
+
y: d3.event.sourceEvent.clientY
|
189
|
+
})));
|
190
|
+
}
|
191
|
+
|
192
|
+
update(session);
|
193
|
+
},
|
194
|
+
|
195
|
+
addPageButtonClick: function(d) {
|
196
|
+
controller.insertPageAfter(d.page);
|
197
|
+
}
|
198
|
+
}));
|
199
|
+
|
200
|
+
svgLinks.call(s.pageLinksView(viewModel.links, {
|
201
|
+
click: function (d) {
|
202
|
+
controller.pageLinkSelected(d.link, d3.event);
|
203
|
+
},
|
204
|
+
|
205
|
+
drag: function(options) {
|
206
|
+
update(session, {dragPosition: options.position});
|
207
|
+
},
|
208
|
+
|
209
|
+
dragend: function(options) {
|
210
|
+
var layout = s.layout.create(entry, selection, {
|
211
|
+
dragPosition: options.position
|
212
|
+
});
|
213
|
+
|
214
|
+
var page = layout.pageFromPoint(options.position);
|
215
|
+
|
216
|
+
if (page) {
|
217
|
+
if (options.data.link.placeholder) {
|
218
|
+
controller.newPageLinkDroppedOnPage(options.data.links,
|
219
|
+
page);
|
220
|
+
}
|
221
|
+
else {
|
222
|
+
controller.pageLinkDroppedOnPage(options.data.links,
|
223
|
+
options.data.link,
|
224
|
+
page);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
else if (layout.chapterPlaceholder) {
|
228
|
+
if (options.data.link.placeholder) {
|
229
|
+
controller.newPageLinkDroppedOnPlaceholder(options.data.sourcePage,
|
230
|
+
options.data.links,
|
231
|
+
layout.chapterPlaceholder.laneAndRow);
|
232
|
+
}
|
233
|
+
else {
|
234
|
+
controller.pageLinkDroppedOnPlaceholder(options.data.sourcePage,
|
235
|
+
options.data.links,
|
236
|
+
options.data.link,
|
237
|
+
layout.chapterPlaceholder.laneAndRow);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
update(session);
|
242
|
+
}
|
243
|
+
}));
|
244
|
+
|
245
|
+
svgLinks.call(s.successorLinksView(viewModel.successorLinks, {
|
246
|
+
click: function (d) {
|
247
|
+
controller.successorLinkSelected(d.link, d3.event);
|
248
|
+
},
|
249
|
+
|
250
|
+
drag: function(options) {
|
251
|
+
update(session, {dragPosition: options.position});
|
252
|
+
},
|
253
|
+
|
254
|
+
dragend: function(options) {
|
255
|
+
var layout = s.layout.create(entry, selection, {
|
256
|
+
dragPosition: options.position
|
257
|
+
});
|
258
|
+
|
259
|
+
var targetPage = layout.pageFromPoint(options.position);
|
260
|
+
|
261
|
+
if (targetPage) {
|
262
|
+
controller.successorLinkDroppedOnPage(options.data.storyline,
|
263
|
+
targetPage);
|
264
|
+
}
|
265
|
+
else if (layout.chapterPlaceholder) {
|
266
|
+
controller.successorLinkDroppedOnPlaceholder(options.data.storyline,
|
267
|
+
layout.chapterPlaceholder.laneAndRow);
|
268
|
+
}
|
269
|
+
|
270
|
+
update(session);
|
271
|
+
}
|
272
|
+
}));
|
273
|
+
|
274
|
+
svgChapters.call(s.chapterPlaceholdersView(viewModel.chapterPlaceholders));
|
275
|
+
}
|
276
|
+
};
|
277
|
+
}());
|
@@ -0,0 +1,33 @@
|
|
1
|
+
pageflow.sitemap.layout.ChapterCollision = function(pagesGroupedByChapters) {
|
2
|
+
this.pagesGroupedByChapters = function() {
|
3
|
+
var laneHeights = {};
|
4
|
+
|
5
|
+
return _(pagesGroupedByChapters).map(function(group) {
|
6
|
+
var chapter = group.chapter;
|
7
|
+
|
8
|
+
if (!chapter) {
|
9
|
+
return group;
|
10
|
+
}
|
11
|
+
|
12
|
+
var lane = chapter.configuration.get('lane') || 0;
|
13
|
+
var row = chapter.configuration.get('row') || 0;
|
14
|
+
|
15
|
+
return {
|
16
|
+
chapter: chapter,
|
17
|
+
pages: group.pages,
|
18
|
+
lane: lane,
|
19
|
+
row: freeRow(lane, row, group.pages.length)
|
20
|
+
};
|
21
|
+
|
22
|
+
function freeRow(lane, row, pagesCount) {
|
23
|
+
var laneHeight = laneHeights[lane] || 0;
|
24
|
+
var result;
|
25
|
+
|
26
|
+
result = Math.max(laneHeight, row);
|
27
|
+
laneHeights[lane] = result + pagesCount + 1;
|
28
|
+
|
29
|
+
return result;
|
30
|
+
}
|
31
|
+
}, []);
|
32
|
+
};
|
33
|
+
};
|
@@ -0,0 +1,116 @@
|
|
1
|
+
pageflow.sitemap.layout.Collision = function(draggedLayout, targetLayout) {
|
2
|
+
this.pagesGroupedByDragTargetChapters = function() {
|
3
|
+
return this._pagesGroupedByDragTargetChapters;
|
4
|
+
};
|
5
|
+
|
6
|
+
this.chaptersGroupedByDragTargetStorylines = function() {
|
7
|
+
return this._chaptersGroupedByDragTargetStorylines;
|
8
|
+
};
|
9
|
+
|
10
|
+
var fff = false;
|
11
|
+
|
12
|
+
this._chaptersGroupedByDragTargetStorylines = (function() {
|
13
|
+
var found = false;
|
14
|
+
var result = [];
|
15
|
+
|
16
|
+
_(targetLayout.chaptersGroupedByStorylines).each(function(group) {
|
17
|
+
var chapters = [];
|
18
|
+
|
19
|
+
result.push({
|
20
|
+
storyline: group.storyline,
|
21
|
+
chapters: chapters
|
22
|
+
});
|
23
|
+
|
24
|
+
_(group.chapters).each(function(chapter) {
|
25
|
+
if (draggedLayout.draggedChapters.length) {
|
26
|
+
if (targetLayout.isAboveChapter(chapter, draggedLayout.position(draggedLayout.draggedChapters[0]))) {
|
27
|
+
pushAll(draggedLayout.draggedChapters);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
chapters.push(chapter);
|
32
|
+
});
|
33
|
+
|
34
|
+
if (draggedLayout.draggedChapters.length) {
|
35
|
+
if (targetLayout.isBelowStoryline(group.storyline, draggedLayout.position(draggedLayout.draggedChapters[0]))) {
|
36
|
+
pushAll(draggedLayout.draggedChapters);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
function pushAll(addedChapters) {
|
41
|
+
found = true;
|
42
|
+
|
43
|
+
_.each(addedChapters, function(chapter) {
|
44
|
+
chapters.push(chapter);
|
45
|
+
});
|
46
|
+
}
|
47
|
+
}, []);
|
48
|
+
|
49
|
+
if (!found) {
|
50
|
+
result.push({
|
51
|
+
storyline: null,
|
52
|
+
chapters: draggedLayout.draggedChapters
|
53
|
+
});
|
54
|
+
|
55
|
+
fff = true;
|
56
|
+
}
|
57
|
+
|
58
|
+
return result;
|
59
|
+
}());
|
60
|
+
|
61
|
+
|
62
|
+
this._pagesGroupedByDragTargetChapters = (function() {
|
63
|
+
var found = false;
|
64
|
+
var result = [];
|
65
|
+
|
66
|
+
_(targetLayout.pagesGroupedByChapters).each(function(group) {
|
67
|
+
var pages = [];
|
68
|
+
|
69
|
+
result.push({
|
70
|
+
chapter: group.chapter,
|
71
|
+
pages: pages
|
72
|
+
});
|
73
|
+
|
74
|
+
_(group.pages).each(function(page) {
|
75
|
+
if (draggedLayout.draggedPages.length) {
|
76
|
+
if (targetLayout.isAbovePage(page, draggedLayout.position(draggedLayout.draggedPages[0]))) {
|
77
|
+
pushAll(draggedLayout.draggedPages);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
pages.push(page);
|
82
|
+
});
|
83
|
+
|
84
|
+
if (draggedLayout.draggedPages.length) {
|
85
|
+
if (targetLayout.isBelowChapter(group.chapter, draggedLayout.position(draggedLayout.draggedPages[0]))) {
|
86
|
+
pushAll(draggedLayout.draggedPages);
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
function pushAll(addedPages) {
|
91
|
+
found = true;
|
92
|
+
|
93
|
+
_.each(addedPages, function(page) {
|
94
|
+
pages.push(page);
|
95
|
+
});
|
96
|
+
}
|
97
|
+
}, []);
|
98
|
+
|
99
|
+
if (draggedLayout.draggedChapters.length) {
|
100
|
+
_.each(draggedLayout.draggedChapters, function(chapter) {
|
101
|
+
result.push({
|
102
|
+
chapter: chapter,
|
103
|
+
pages: chapter.pages.toArray()
|
104
|
+
});
|
105
|
+
});
|
106
|
+
}
|
107
|
+
else if (!found) {
|
108
|
+
result.push({
|
109
|
+
chapter: null,
|
110
|
+
pages: draggedLayout.draggedPages
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
return result;
|
115
|
+
}());
|
116
|
+
};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
pageflow.sitemap.layout.DraggingDecorator = function(selection, layout, selectionLayout, options) {
|
2
|
+
var x = options.delta ? options.delta.x : 0;
|
3
|
+
var y = options.delta ? options.delta.y : 0;
|
4
|
+
|
5
|
+
var decorator = function() {
|
6
|
+
this.position = function(target) {
|
7
|
+
var pos = layout.position(target);
|
8
|
+
|
9
|
+
if (selection.contains(target) ||
|
10
|
+
(target.chapter && selection.contains(target.chapter)) ||
|
11
|
+
(target.chapter && target.chapter.storyline && selection.contains(target.chapter.storyline)) ||
|
12
|
+
(target.storyline && selection.contains(target.storyline))) {
|
13
|
+
|
14
|
+
pos = selectionLayout.position(target);
|
15
|
+
|
16
|
+
return {
|
17
|
+
x: pos.x + x,
|
18
|
+
y: pos.y + y
|
19
|
+
};
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
return layout.position(target);
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
this.isDragging = isDragging;
|
27
|
+
|
28
|
+
this.draggedChapters = options.delta ? selection.get('chapters') : [];
|
29
|
+
|
30
|
+
this.nonDraggedChaptersGroupedByStorylines = _(layout.chaptersGroupedByStorylines).map(function(group) {
|
31
|
+
return {
|
32
|
+
storyline: group.storyline,
|
33
|
+
chapters: _.reject(group.chapters, isDragging)
|
34
|
+
};
|
35
|
+
});
|
36
|
+
|
37
|
+
this.draggedPages = options.delta ? selection.get('pages') : [];
|
38
|
+
|
39
|
+
this.nonDraggedPagesGroupedByChapters = _.chain(layout.pagesGroupedByChapters)
|
40
|
+
.reject(function(group) {
|
41
|
+
return group.chapter && isDragging(group.chapter);
|
42
|
+
})
|
43
|
+
.map(function(group) {
|
44
|
+
return {
|
45
|
+
chapter: group.chapter,
|
46
|
+
pages: _.reject(group.pages, isDragging)
|
47
|
+
};
|
48
|
+
})
|
49
|
+
.value();
|
50
|
+
};
|
51
|
+
|
52
|
+
decorator.prototype = layout;
|
53
|
+
return new decorator();
|
54
|
+
|
55
|
+
function isDragging(target) {
|
56
|
+
return options.delta && selection.contains(target);
|
57
|
+
}
|
58
|
+
};
|