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,86 @@
|
|
1
|
+
sitemap.storylinesView = sitemap.groupView.define('storyline', function(s) {
|
2
|
+
var width = s.settings.page.width + 35;
|
3
|
+
var options = this.options;
|
4
|
+
|
5
|
+
this.update()
|
6
|
+
.classed('selected', s.utils.fn.d('selected'))
|
7
|
+
.classed('highlighted', s.utils.fn.d('highlighted'))
|
8
|
+
.classed('main', s.utils.fn.d('main'))
|
9
|
+
.attr('transform', function(d) {
|
10
|
+
return s.utils.translate(
|
11
|
+
d.x - s.settings.page.width / 2 - 17,
|
12
|
+
d.y - s.settings.page.height / 2 - 50
|
13
|
+
);
|
14
|
+
})
|
15
|
+
;
|
16
|
+
|
17
|
+
this.child('rect.border', function() {
|
18
|
+
this.enter()
|
19
|
+
.attr('rx', 5)
|
20
|
+
.attr('ry', 5)
|
21
|
+
.attr('width', width)
|
22
|
+
;
|
23
|
+
|
24
|
+
this.update()
|
25
|
+
.attr('height', function (d) {
|
26
|
+
return d.height + 25;
|
27
|
+
})
|
28
|
+
;
|
29
|
+
});
|
30
|
+
|
31
|
+
this.child('path.handle', function() {
|
32
|
+
var height = 20;
|
33
|
+
|
34
|
+
this.enter()
|
35
|
+
.attr('d', rectRounedAtTop)
|
36
|
+
.attr('width', width)
|
37
|
+
.attr('height', height)
|
38
|
+
.on('mouseover', function() {
|
39
|
+
d3.select(this.parentNode).classed('hover', true);
|
40
|
+
})
|
41
|
+
.on('mouseout', function() {
|
42
|
+
d3.select(this.parentNode).classed('hover', false);
|
43
|
+
})
|
44
|
+
.on('click', function() {
|
45
|
+
if (options.clicked) {
|
46
|
+
options.clicked.apply(this, arguments);
|
47
|
+
}
|
48
|
+
})
|
49
|
+
.on('dblclick', s.utils.fn.trigger(this.options.dblclick))
|
50
|
+
.on('mousedown', function() {
|
51
|
+
if (options.mousedown) {
|
52
|
+
options.mousedown.apply(this, arguments);
|
53
|
+
}
|
54
|
+
})
|
55
|
+
;
|
56
|
+
|
57
|
+
function rectRounedAtTop() {
|
58
|
+
var radius = 5;
|
59
|
+
|
60
|
+
return 'M' + radius + ',' + 0 +
|
61
|
+
'h' + (width - 2 * radius) +
|
62
|
+
'a' + radius + ',' + radius + ' 0 0 1 ' + radius + ',' + radius +
|
63
|
+
'v' + (height - radius) +
|
64
|
+
'h' + (-width) +
|
65
|
+
'v' + (radius - height) +
|
66
|
+
'a' + radius + ',' + radius + ' 0 0 1 ' + radius + ',' + -radius +
|
67
|
+
'z';
|
68
|
+
}
|
69
|
+
});
|
70
|
+
|
71
|
+
|
72
|
+
this.child('text', function() {
|
73
|
+
this.enter()
|
74
|
+
.attr('transform', s.utils.translate(7, 15))
|
75
|
+
;
|
76
|
+
|
77
|
+
this.update()
|
78
|
+
.text(s.utils.fn.d('title'))
|
79
|
+
;
|
80
|
+
});
|
81
|
+
|
82
|
+
this.enter().call(sitemap.behavior.multiDrag({
|
83
|
+
drag: options.drag,
|
84
|
+
dragend: options.dragend
|
85
|
+
}));
|
86
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
pageflow.sitemap.textLabelView = pageflow.sitemap.groupView.define('text_label', function(s) {
|
2
|
+
var padding = this.options.padding || 5;
|
3
|
+
var dist = 10;
|
4
|
+
|
5
|
+
this.update()
|
6
|
+
.classed('empty', function(d) { return !d.label; })
|
7
|
+
.classed('anchor_right', function(d) { return d.anchor === 'right'; })
|
8
|
+
.attr('transform', s.utils.fn.translate('x', 'y'))
|
9
|
+
;
|
10
|
+
|
11
|
+
this.child('rect');
|
12
|
+
|
13
|
+
this.child('text', function() {
|
14
|
+
this.update()
|
15
|
+
.attr('transform', function(d) {
|
16
|
+
if (d.anchor === 'right') {
|
17
|
+
return s.utils.translate(-dist, -dist);
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
return s.utils.translate(dist, -dist);
|
21
|
+
}
|
22
|
+
})
|
23
|
+
.text(s.utils.fn.d('label'))
|
24
|
+
;
|
25
|
+
});
|
26
|
+
|
27
|
+
this.update().each(function(d) {
|
28
|
+
resizeRectToText(this.getElementsByTagName('rect'),
|
29
|
+
this.getElementsByTagName('text'),
|
30
|
+
d.anchor);
|
31
|
+
});
|
32
|
+
|
33
|
+
function resizeRectToText(rect, text, anchor) {
|
34
|
+
var textRect = text[0].getBoundingClientRect();
|
35
|
+
|
36
|
+
d3.selectAll(rect)
|
37
|
+
.attr('transform', s.utils.translate(anchor === 'right' ?
|
38
|
+
-textRect.width - padding - dist :
|
39
|
+
dist - padding,
|
40
|
+
-textRect.height - padding / 2 - dist))
|
41
|
+
.attr('width', textRect.width + 2 * padding)
|
42
|
+
.attr('height', textRect.height + 2 * padding)
|
43
|
+
;
|
44
|
+
}
|
45
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
//= require ./d3/utils
|
2
|
+
//= require_tree ./d3/behaviors
|
3
|
+
//= require_tree ./d3/paths
|
4
|
+
|
5
|
+
//= require ./d3/options
|
6
|
+
//= require ./d3/layout
|
7
|
+
//= require ./d3/view_model
|
8
|
+
|
9
|
+
//= require ./d3/views/group_view
|
10
|
+
//= require ./d3/views/selectable_links_view
|
11
|
+
|
12
|
+
//= require ./d3/graph_view
|
13
|
+
//= require ./d3/views/storylines_view
|
14
|
+
//= require ./d3/views/chapters_view
|
15
|
+
//= require ./d3/views/chapter_placeholders_view
|
16
|
+
//= require ./d3/views/pages_view
|
17
|
+
//= require ./d3/views/page_links_view
|
18
|
+
//= require ./d3/views/successor_links_view
|
19
|
+
//= require ./d3/views/add_button_view
|
20
|
+
//= require ./d3/views/text_label_view
|
@@ -0,0 +1,126 @@
|
|
1
|
+
pageflow.features.register('editor', 'sitemap', function() {
|
2
|
+
var s = pageflow.sitemap;
|
3
|
+
var currentSitemapView = null;
|
4
|
+
|
5
|
+
pageflow.editor.selectPage = function (options) {
|
6
|
+
options = options || {};
|
7
|
+
|
8
|
+
var result = $.Deferred();
|
9
|
+
var controller = new s.SelectionModeController(pageflow.entry, options);
|
10
|
+
var graphView = new s.SitemapView({
|
11
|
+
controller: controller,
|
12
|
+
headerText: I18n.t(options.header || 'pageflow.sitemap.editor.headers.select_page'),
|
13
|
+
cancelButton: true
|
14
|
+
});
|
15
|
+
|
16
|
+
if (currentSitemapView) {
|
17
|
+
result.always(showSitemap);
|
18
|
+
}
|
19
|
+
|
20
|
+
controller.once('selected', function (selected) {
|
21
|
+
graphView.close();
|
22
|
+
result.resolve(selected);
|
23
|
+
});
|
24
|
+
|
25
|
+
graphView.once('closed', result.reject);
|
26
|
+
|
27
|
+
pageflow.editor.showViewInMainPanel(graphView);
|
28
|
+
|
29
|
+
return result.promise();
|
30
|
+
};
|
31
|
+
|
32
|
+
pageflow.editor.registerMainMenuItem({
|
33
|
+
translationKey: 'pageflow.sitemap.editor.main_menu_item',
|
34
|
+
click: function() {
|
35
|
+
showSitemap();
|
36
|
+
this.blur();
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
pageflow.editor.on('scaffold:storyline', function(storyline) {
|
41
|
+
if (!storyline.configuration.has('lane')) {
|
42
|
+
storyline.configuration.set({
|
43
|
+
row: 0,
|
44
|
+
lane: firstEmptyLane()
|
45
|
+
});
|
46
|
+
}
|
47
|
+
});
|
48
|
+
|
49
|
+
function firstEmptyLane() {
|
50
|
+
return Math.max(-1, _.max(pageflow.storylines.map(function(storyline) {
|
51
|
+
return storyline.configuration.get('lane') || 0;
|
52
|
+
}))) + 1;
|
53
|
+
}
|
54
|
+
|
55
|
+
pageflow.editor.on('add:chapter', function(chapter) {
|
56
|
+
rearrangeLane(chapter.storyline);
|
57
|
+
});
|
58
|
+
|
59
|
+
pageflow.editor.on('add:page', function(page) {
|
60
|
+
rearrangeLane(page.chapter.storyline);
|
61
|
+
});
|
62
|
+
|
63
|
+
function rearrangeLane(changedStoryline) {
|
64
|
+
var storylinesBelow = pageflow.storylines.select(function(storyline) {
|
65
|
+
return (storyline.configuration.get('lane') ===
|
66
|
+
changedStoryline.configuration.get('lane') &&
|
67
|
+
storyline.configuration.get('row') >
|
68
|
+
changedStoryline.configuration.get('row'));
|
69
|
+
});
|
70
|
+
|
71
|
+
if (!storylinesBelow.length) {
|
72
|
+
return;
|
73
|
+
}
|
74
|
+
|
75
|
+
var minRowBelow = _.min(_(storylinesBelow).map(function(storyline) {
|
76
|
+
return storyline.configuration.get('row');
|
77
|
+
}));
|
78
|
+
|
79
|
+
var height = Math.ceil(changedStoryline.chapters.reduce(function(result, chapter) {
|
80
|
+
return result + chapter.pages.length + 0.5;
|
81
|
+
}, 0) + 0.5);
|
82
|
+
|
83
|
+
var delta = changedStoryline.configuration.get('row') + height - minRowBelow;
|
84
|
+
|
85
|
+
if (delta > 0) {
|
86
|
+
_(storylinesBelow).each(function(storyline) {
|
87
|
+
storyline.configuration.set({
|
88
|
+
row: (storyline.configuration.get('row') || 0) + delta
|
89
|
+
});
|
90
|
+
});
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
$(document).on('keydown', function(event) {
|
95
|
+
if (event.altKey && event.which === 83) {
|
96
|
+
toggleSitemap();
|
97
|
+
}
|
98
|
+
});
|
99
|
+
|
100
|
+
function toggleSitemap() {
|
101
|
+
if (currentSitemapView) {
|
102
|
+
hideSitemap();
|
103
|
+
}
|
104
|
+
else {
|
105
|
+
showSitemap();
|
106
|
+
}
|
107
|
+
}
|
108
|
+
|
109
|
+
function showSitemap() {
|
110
|
+
if (!currentSitemapView) {
|
111
|
+
currentSitemapView = new s.SitemapView({
|
112
|
+
controller: new s.EditorModeController(pageflow.entry)
|
113
|
+
});
|
114
|
+
|
115
|
+
currentSitemapView.once('close', function() {
|
116
|
+
currentSitemapView = null;
|
117
|
+
});
|
118
|
+
|
119
|
+
pageflow.editor.showViewInMainPanel(currentSitemapView);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
function hideSitemap() {
|
124
|
+
currentSitemapView.close();
|
125
|
+
}
|
126
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
pageflow.sitemap.Selection = Backbone.Model.extend({
|
2
|
+
defaults: function() {
|
3
|
+
return {
|
4
|
+
storylines: [],
|
5
|
+
pages: [],
|
6
|
+
chapters: [],
|
7
|
+
pageLinks: [],
|
8
|
+
successorLinks: []
|
9
|
+
};
|
10
|
+
},
|
11
|
+
|
12
|
+
contains: function(model) {
|
13
|
+
return _(this.get('storylines')).contains(model) ||
|
14
|
+
_(this.get('chapters')).contains(model) ||
|
15
|
+
_(this.get('pages')).contains(model) ||
|
16
|
+
_(this.get('pageLinks')).some(function(link) {
|
17
|
+
return link === model |
|
18
|
+
(link.id && link.id === model.id) ||
|
19
|
+
(link.placeholder && link.placeholder === model.placeholder);
|
20
|
+
}) ||
|
21
|
+
_(this.get('successorLinks')).some(function(link) {
|
22
|
+
return link.successor && link.successor === model.successor;
|
23
|
+
});
|
24
|
+
},
|
25
|
+
|
26
|
+
select: function(name, models, options) {
|
27
|
+
options = options || {};
|
28
|
+
|
29
|
+
var base = options.additive ? this.get(name) : [];
|
30
|
+
var attributes = this.defaults();
|
31
|
+
|
32
|
+
attributes[name] = base.concat(models);
|
33
|
+
this.set(attributes);
|
34
|
+
|
35
|
+
this.trigger('select:' + name, attributes[name]);
|
36
|
+
},
|
37
|
+
|
38
|
+
reset: function() {
|
39
|
+
this.select('pages', []);
|
40
|
+
}
|
41
|
+
});
|
@@ -0,0 +1,85 @@
|
|
1
|
+
<div class="close button">
|
2
|
+
</div>
|
3
|
+
|
4
|
+
<h2></h2>
|
5
|
+
|
6
|
+
<div class="svgcontainer">
|
7
|
+
<svg>
|
8
|
+
<defs>
|
9
|
+
<marker id="Triangle"
|
10
|
+
viewBox="0 0 10 10"
|
11
|
+
refX="1" refY="5"
|
12
|
+
markerWidth="6"
|
13
|
+
markerHeight="6"
|
14
|
+
orient="auto">
|
15
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
16
|
+
</marker>
|
17
|
+
|
18
|
+
<marker id="page_link_triangle"
|
19
|
+
viewBox="0 0 10 10"
|
20
|
+
refX="1" refY="5"
|
21
|
+
markerWidth="6"
|
22
|
+
markerHeight="6"
|
23
|
+
orient="auto">
|
24
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
25
|
+
</marker>
|
26
|
+
|
27
|
+
<marker id="page_link_triangle_highlight"
|
28
|
+
viewBox="0 0 10 10"
|
29
|
+
refX="1" refY="5"
|
30
|
+
markerWidth="6"
|
31
|
+
markerHeight="6"
|
32
|
+
orient="auto">
|
33
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
34
|
+
</marker>
|
35
|
+
|
36
|
+
<marker id="successor_link_triangle"
|
37
|
+
viewBox="0 0 10 10"
|
38
|
+
refX="1" refY="5"
|
39
|
+
markerWidth="6"
|
40
|
+
markerHeight="6"
|
41
|
+
orient="auto">
|
42
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
43
|
+
</marker>
|
44
|
+
|
45
|
+
<marker id="successor_link_triangle_highlight"
|
46
|
+
viewBox="0 0 10 10"
|
47
|
+
refX="1" refY="5"
|
48
|
+
markerWidth="6"
|
49
|
+
markerHeight="6"
|
50
|
+
orient="auto">
|
51
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
52
|
+
</marker>
|
53
|
+
|
54
|
+
<marker id="follow_triangle"
|
55
|
+
viewBox="0 0 10 10"
|
56
|
+
refX="1" refY="5"
|
57
|
+
markerWidth="6"
|
58
|
+
markerHeight="6"
|
59
|
+
orient="90">
|
60
|
+
<path d="M 0 0 L 10 5 L 0 10 z" />
|
61
|
+
</marker>
|
62
|
+
</defs>
|
63
|
+
<g class="all">
|
64
|
+
<g class="lines"> </g>
|
65
|
+
<g class="chapters"> </g>
|
66
|
+
<g class="links"> </g>
|
67
|
+
<g class="pages"> </g>
|
68
|
+
<g class="controls"> </g>
|
69
|
+
</g>
|
70
|
+
</svg>
|
71
|
+
</div>
|
72
|
+
|
73
|
+
<div class="toolbar">
|
74
|
+
<div class="items">
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div class="scale_minus"></div>
|
78
|
+
<div class="scale_slider"></div>
|
79
|
+
<div class="scale_plus"></div>
|
80
|
+
|
81
|
+
<a class="help_button" title="<%= I18n.t('pageflow.sitemap.editor.templates.sitemap.help') %>"></a>
|
82
|
+
</div>
|
83
|
+
|
84
|
+
<div class="scroll_bar_x"></div>
|
85
|
+
<div class="scroll_bar_y"></div>
|
@@ -0,0 +1,130 @@
|
|
1
|
+
sitemap.ScrollBarView = Backbone.Marionette.ItemView.extend({
|
2
|
+
template: 'pageflow/sitemap/editor/templates/scroll_bar',
|
3
|
+
|
4
|
+
ui: {
|
5
|
+
slider: '.slider'
|
6
|
+
},
|
7
|
+
|
8
|
+
onRender: function() {
|
9
|
+
this.$el.addClass('scroll_bar');
|
10
|
+
|
11
|
+
this.setupSlider();
|
12
|
+
},
|
13
|
+
|
14
|
+
onClose: function() {
|
15
|
+
this.options.graphView.on(this.graphViewChangeEvent, null);
|
16
|
+
},
|
17
|
+
|
18
|
+
setupSlider: function() {
|
19
|
+
var graphView = this.options.graphView;
|
20
|
+
var view = this;
|
21
|
+
var coord = this.options.orientation === 'vertical' ? 'Y' : 'X';
|
22
|
+
|
23
|
+
this.ui.slider.slider({
|
24
|
+
orientation: this.options.orientation,
|
25
|
+
slide: function(event, ui) {
|
26
|
+
graphView['setScroll' + coord](ui.value);
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
this.graphViewChangeEvent = 'change.scrollBar' + coord;
|
31
|
+
|
32
|
+
this.options.graphView.on(this.graphViewChangeEvent, function() {
|
33
|
+
view.ui.slider.slider('value', graphView['getScroll' + coord]());
|
34
|
+
view.resizeHandle();
|
35
|
+
});
|
36
|
+
|
37
|
+
this.wrapHandleInHelper();
|
38
|
+
this.resizeSliderToHelperDuringDrag();
|
39
|
+
this.resizeHandle();
|
40
|
+
},
|
41
|
+
|
42
|
+
wrapHandleInHelper: function() {
|
43
|
+
this.ui.handle = this.ui.slider.find('.ui-slider-handle');
|
44
|
+
this.ui.handleHelper = this.ui.handle
|
45
|
+
.wrap("<div class='ui-handle-helper-parent'></div>" )
|
46
|
+
.parent();
|
47
|
+
},
|
48
|
+
|
49
|
+
resizeSliderToHelperDuringDrag: function() {
|
50
|
+
var view = this;
|
51
|
+
var sizeMethod = this.options.orientation === 'vertical' ? 'height' : 'width';
|
52
|
+
|
53
|
+
this.ui.handle.on('mousedown', function() {
|
54
|
+
view.sliding = true;
|
55
|
+
|
56
|
+
var marginTop = view.ui.handleHelper.prop('offsetTop');
|
57
|
+
var marginLeft = view.ui.handleHelper.prop('offsetLeft');
|
58
|
+
|
59
|
+
view.ui.slider
|
60
|
+
.width(view.ui.handleHelper.width())
|
61
|
+
.height(view.ui.handleHelper.height())
|
62
|
+
.css({
|
63
|
+
'margin-top': marginTop + 'px',
|
64
|
+
'margin-left': marginLeft + 'px'
|
65
|
+
});
|
66
|
+
|
67
|
+
view.ui.handleHelper.css({
|
68
|
+
'margin-top': 0,
|
69
|
+
'margin-left': 0
|
70
|
+
});
|
71
|
+
|
72
|
+
$(document).one('mouseup', function() {
|
73
|
+
view.sliding = false;
|
74
|
+
|
75
|
+
view.ui.slider
|
76
|
+
.width('100%')
|
77
|
+
.height('100%')
|
78
|
+
.css({
|
79
|
+
'margin-top': 0,
|
80
|
+
'margin-left': 0
|
81
|
+
});
|
82
|
+
|
83
|
+
view.ui.handleHelper.css({
|
84
|
+
'margin-top': marginTop + 'px',
|
85
|
+
'margin-left': marginLeft + 'px'
|
86
|
+
});
|
87
|
+
});
|
88
|
+
});
|
89
|
+
},
|
90
|
+
|
91
|
+
resizeHandle: function() {
|
92
|
+
if (this.sliding) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
var handleSize;
|
97
|
+
var handle = this.ui.slider.find('.ui-slider-handle');
|
98
|
+
|
99
|
+
if (this.options.orientation === 'vertical') {
|
100
|
+
handleSize = this.options.graphView.getScrollWindowProportionY() * this.$el.height();
|
101
|
+
|
102
|
+
handle.css({
|
103
|
+
height: handleSize,
|
104
|
+
'margin-bottom': -handleSize / 2
|
105
|
+
});
|
106
|
+
|
107
|
+
this.ui.handleHelper.css({
|
108
|
+
height: this.$el.height() - handleSize,
|
109
|
+
'margin-top': handleSize / 2
|
110
|
+
});
|
111
|
+
|
112
|
+
this.ui.slider.toggle(this.options.graphView.getScrollWindowProportionY() < 1);
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
handleSize = this.options.graphView.getScrollWindowProportionX() * this.$el.width();
|
116
|
+
|
117
|
+
handle.css({
|
118
|
+
width: handleSize,
|
119
|
+
'margin-left': -handleSize / 2
|
120
|
+
});
|
121
|
+
|
122
|
+
this.ui.handleHelper.css({
|
123
|
+
width: this.$el.width() - handleSize,
|
124
|
+
'margin-left': handleSize / 2
|
125
|
+
});
|
126
|
+
|
127
|
+
this.ui.slider.toggle(this.options.graphView.getScrollWindowProportionX() < 1);
|
128
|
+
}
|
129
|
+
}
|
130
|
+
});
|
@@ -0,0 +1,73 @@
|
|
1
|
+
(function() {
|
2
|
+
var KEY_SHIFT = 16;
|
3
|
+
var KEY_CTRL = 17;
|
4
|
+
|
5
|
+
sitemap.ScrollPaneView = Backbone.Marionette.View.extend({
|
6
|
+
className: 'scroll_pane',
|
7
|
+
|
8
|
+
events: {
|
9
|
+
mousedown: function(event) {
|
10
|
+
this.scrolling = true;
|
11
|
+
this.lastX = event.pageX;
|
12
|
+
this.lastY = event.pageY;
|
13
|
+
},
|
14
|
+
|
15
|
+
mousemove: function(event) {
|
16
|
+
if (!event.ctrlKey) {
|
17
|
+
this.deactivate();
|
18
|
+
}
|
19
|
+
|
20
|
+
if (this.scrolling) {
|
21
|
+
var diffX = event.pageX - this.lastX;
|
22
|
+
var diffY = event.pageY - this.lastY;
|
23
|
+
|
24
|
+
this.options.graphView.scrollBy(diffX, diffY);
|
25
|
+
|
26
|
+
this.lastX = event.pageX;
|
27
|
+
this.lastY = event.pageY;
|
28
|
+
}
|
29
|
+
},
|
30
|
+
|
31
|
+
mouseup: function(event) {
|
32
|
+
this.scrolling = false;
|
33
|
+
},
|
34
|
+
},
|
35
|
+
|
36
|
+
initialize: function() {
|
37
|
+
this.keydownHandler = _.bind(this.onKeydown, this);
|
38
|
+
this.keyupHandler = _.bind(this.onKeyup, this);
|
39
|
+
|
40
|
+
$(document).on('keydown', this.keydownHandler);
|
41
|
+
$(document).on('keyup', this.keyupHandler);
|
42
|
+
},
|
43
|
+
|
44
|
+
onClose: function() {
|
45
|
+
$(document).off('keydown', this.keydownHandler);
|
46
|
+
$(document).off('keyup', this.keyupHandler);
|
47
|
+
},
|
48
|
+
|
49
|
+
onKeydown: function(event) {
|
50
|
+
if ((event.which === KEY_CTRL && event.shiftKey) ||
|
51
|
+
(event.which === KEY_SHIFT && event.ctrlKey)) {
|
52
|
+
this.activate();
|
53
|
+
}
|
54
|
+
},
|
55
|
+
|
56
|
+
onKeyup: function(event) {
|
57
|
+
if (event.which === KEY_CTRL || event.which === KEY_SHIFT) {
|
58
|
+
this.deactivate();
|
59
|
+
}
|
60
|
+
},
|
61
|
+
|
62
|
+
activate: function() {
|
63
|
+
this.$el.addClass('active');
|
64
|
+
document.body.style.cursor = 'move';
|
65
|
+
},
|
66
|
+
|
67
|
+
deactivate: function() {
|
68
|
+
this.scrolling = false;
|
69
|
+
this.$el.removeClass('active');
|
70
|
+
document.body.style.cursor = 'default';
|
71
|
+
}
|
72
|
+
});
|
73
|
+
}());
|