pageflow 0.2.1 → 0.3.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 (99) hide show
  1. checksums.yaml +8 -8
  2. data/admins/pageflow/accounts.rb +3 -1
  3. data/admins/pageflow/entry.rb +2 -1
  4. data/app/assets/javascripts/pageflow/admin.js +1 -0
  5. data/app/assets/javascripts/pageflow/admin/accounts.js +30 -0
  6. data/app/assets/javascripts/pageflow/asset_urls.js.erb +2 -2
  7. data/app/assets/javascripts/pageflow/editor/api.js +136 -0
  8. data/app/assets/javascripts/pageflow/editor/api/failure.js +54 -0
  9. data/app/assets/javascripts/pageflow/editor/api/failures.js +47 -0
  10. data/app/assets/javascripts/pageflow/editor/base.js +8 -0
  11. data/app/assets/javascripts/pageflow/editor/collections/chapters_collection.js +1 -1
  12. data/app/assets/javascripts/pageflow/editor/collections/mixins/ordered_collection.js +9 -4
  13. data/app/assets/javascripts/pageflow/editor/controllers/sidebar_controller.js +9 -10
  14. data/app/assets/javascripts/pageflow/editor/initializers/additional_initializers.js +8 -0
  15. data/app/assets/javascripts/pageflow/editor/initializers/boot.js +1 -8
  16. data/app/assets/javascripts/pageflow/editor/initializers/routing.js +17 -0
  17. data/app/assets/javascripts/pageflow/editor/initializers/setup_collections.js +5 -5
  18. data/app/assets/javascripts/pageflow/editor/models/configuration.js +11 -2
  19. data/app/assets/javascripts/pageflow/editor/models/entry.js +2 -2
  20. data/app/assets/javascripts/pageflow/editor/models/mixins/retryable.js +2 -2
  21. data/app/assets/javascripts/pageflow/editor/models/page_configuration_file_selection_handler.js +37 -0
  22. data/app/assets/javascripts/pageflow/editor/models/theming.js +8 -0
  23. data/app/assets/javascripts/pageflow/editor/object.js +14 -0
  24. data/app/assets/javascripts/pageflow/editor/routers/sidebar_router.js +4 -4
  25. data/app/assets/javascripts/pageflow/editor/templates/edit_entry.jst.ejs +4 -4
  26. data/app/assets/javascripts/pageflow/editor/templates/notifications.jst.ejs +1 -1
  27. data/app/assets/javascripts/pageflow/editor/views/back_button_decorator_view.js +3 -2
  28. data/app/assets/javascripts/pageflow/editor/views/configuration_editors/audio.js +2 -1
  29. data/app/assets/javascripts/pageflow/editor/views/configuration_editors/video.js +2 -1
  30. data/app/assets/javascripts/pageflow/editor/views/edit_entry_view.js +23 -11
  31. data/app/assets/javascripts/pageflow/editor/views/edit_meta_data_view.js +28 -22
  32. data/app/assets/javascripts/pageflow/editor/views/entry_preview_view.js +5 -1
  33. data/app/assets/javascripts/pageflow/editor/views/file_item_view.js +3 -2
  34. data/app/assets/javascripts/pageflow/editor/views/files_view.js +3 -10
  35. data/app/assets/javascripts/pageflow/editor/views/input_view.js +39 -1
  36. data/app/assets/javascripts/pageflow/editor/views/inputs/check_box_input_view.js +13 -2
  37. data/app/assets/javascripts/pageflow/editor/views/inputs/file_input_view.js +9 -4
  38. data/app/assets/javascripts/pageflow/editor/views/inputs/text_area_input_view.js +14 -1
  39. data/app/assets/javascripts/pageflow/editor/views/inputs/text_input_view.js +11 -0
  40. data/app/assets/javascripts/pageflow/editor/views/mixins/failure_indicating_view.js +3 -3
  41. data/app/assets/javascripts/pageflow/editor/views/notifications_view.js +7 -6
  42. data/app/assets/javascripts/pageflow/editor/views/page_preview_view.js +2 -1
  43. data/app/assets/javascripts/pageflow/page_types/audio.js +13 -8
  44. data/app/assets/javascripts/pageflow/page_types/video.js +9 -5
  45. data/app/assets/javascripts/pageflow/widgets/navigation.js +3 -2
  46. data/app/assets/javascripts/pageflow/widgets/player_controls.js +3 -2
  47. data/app/assets/javascripts/pageflow/widgets/{home_button.js → top_button.js} +4 -4
  48. data/app/assets/stylesheets/pageflow/editor/back_button_decorator.css.scss +3 -0
  49. data/app/assets/stylesheets/pageflow/editor/base.css.scss +1 -0
  50. data/app/assets/stylesheets/pageflow/editor/tabs_view.css.scss +1 -0
  51. data/app/assets/stylesheets/pageflow/ie9.css.scss +8 -7
  52. data/app/assets/stylesheets/pageflow/lt_ie9.css.scss +2 -2
  53. data/app/assets/stylesheets/pageflow/navigation_bar.css.scss +16 -2
  54. data/app/assets/stylesheets/pageflow/themes/default/anchors.css.scss +0 -3
  55. data/app/assets/stylesheets/pageflow/themes/default/navigation.css.scss +13 -4
  56. data/app/controllers/pageflow/entries_controller.rb +4 -9
  57. data/app/helpers/pageflow/entries_helper.rb +2 -6
  58. data/app/helpers/pageflow/themes_helper.rb +9 -0
  59. data/app/helpers/pageflow/themings_helper.rb +11 -0
  60. data/app/jobs/pageflow/poll_zencoder_job.rb +2 -2
  61. data/app/models/pageflow/cname_theming_request_scope.rb +7 -0
  62. data/app/models/pageflow/draft_entry.rb +9 -1
  63. data/app/models/pageflow/entry.rb +3 -1
  64. data/app/models/pageflow/home_button.rb +37 -0
  65. data/app/models/pageflow/published_entry.rb +8 -0
  66. data/app/models/pageflow/revision.rb +6 -0
  67. data/app/models/pageflow/theming.rb +3 -0
  68. data/app/models/pageflow/zencoder_attachment.rb +35 -17
  69. data/app/views/admin/accounts/_form.html.erb +14 -2
  70. data/app/views/admin/entries/_attributes_table.html.arb +1 -1
  71. data/app/views/admin/entries/_links.html.arb +1 -1
  72. data/app/views/layouts/pageflow/_ie_include_tags.html.erb +4 -4
  73. data/app/views/pageflow/editor/entries/_analytics.html.erb +1 -0
  74. data/app/views/pageflow/editor/entries/_entry.json.jbuilder +4 -0
  75. data/app/views/pageflow/editor/themings/_theming.json.jbuilder +2 -0
  76. data/app/views/pageflow/entries/_navigation.html.erb +2 -2
  77. data/app/views/pageflow/entries/edit.html.erb +3 -0
  78. data/app/views/pageflow/entries/navigation/_bar_top.html.erb +2 -1
  79. data/app/views/pageflow/entries/navigation/_home_button.html.erb +8 -0
  80. data/config/initializers/zencoder.rb +11 -1
  81. data/config/locales/activerecord.de.yml +5 -0
  82. data/config/locales/editor.de.yml +5 -0
  83. data/config/routes.rb +1 -0
  84. data/db/migrate/20140819081454_add_home_url_attributes_to_themings_and_revisions.rb +9 -0
  85. data/lib/generators/pageflow/seeds/seeds_generator.rb +4 -4
  86. data/lib/generators/pageflow/seeds/templates/seeds.rb +30 -0
  87. data/lib/pageflow/configuration.rb +47 -1
  88. data/lib/pageflow/page_type.rb +25 -0
  89. data/lib/pageflow/revision_component.rb +39 -0
  90. data/lib/pageflow/seeds.rb +153 -71
  91. data/lib/pageflow/theme.rb +7 -2
  92. data/lib/pageflow/themes.rb +2 -2
  93. data/lib/pageflow/version.rb +1 -1
  94. data/lib/pageflow/zencoder_audio_output_definition.rb +3 -3
  95. data/lib/pageflow/zencoder_output_definition.rb +46 -7
  96. data/lib/pageflow/zencoder_video_output_definition.rb +51 -35
  97. data/spec/factories/entries.rb +6 -2
  98. metadata +687 -668
  99. data/app/assets/javascripts/pageflow/editor/collections/failed_records_collection.js +0 -18
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGI1ZGVmY2NmOTFiNTVmOGRjMTY0NWVlYmM1MjlhMzQwMWVlYThhZQ==
4
+ MjhlOGVhOTIyNDNiMDdkM2ViMjUwODE4NDUzM2M3NmZkOGEzOGU5ZQ==
5
5
  data.tar.gz: !binary |-
6
- NWExZTYwMWI4MWFlYjkzMjA1N2NjZGE1NzAxZTM3MmMxZDYyNTI1MQ==
6
+ ZWE2YTAzZDFkZTZlODk3OGM0ZWY1ODIwMTBjYzJlNmEwNWQwY2ZkYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YzBhYTViN2ZmOGQwZGRmNmQxOTY5Njk0ZjZiYjAyNDE2NDFjYjYxOGIxNThh
10
- MTNjNTNjMjczMDdjOWRjN2I0MTk1MTZkMjY0OTRhZWZiNjdiM2U1ODZiNWRh
11
- YTBjMjUwNDcyZDk4ZTJkMjA5NmY4NDkwNjlhOWQwYTBiNjAyYzU=
9
+ ZWYxZjhmNDk0ODZmMGNiMDc1NGE1ODc5OWVlNzMyZjg2MDk3OWE2MmNmNGVj
10
+ NmViNTgzYTgwODYxZTJiNTQ5MjQxNGY0N2I0MzIxNTM2OWNhMDM4YzA1YzAz
11
+ OTllNzVmZDMzN2E5YzQ3ODA2ZTAzYmNiOTMzZDM5ZTZiYTFlYTE=
12
12
  data.tar.gz: !binary |-
13
- YmY1MzBjNDNkNmY5OTI5ODNlYTIwMmQxOTZiOGFhZDEyMGE5NDBmZTMzY2M5
14
- ZGY0Zjc5NDZhZWVhYzJjNWI3MDg0OTIwMTc1OWVlY2U1ZTczYTQ3YzRiMGM3
15
- YzAxNWM0MjEzOWIzOGQ4OGUwNGUxMDZhMDQzMTVlMWNlNmIzY2U=
13
+ MjdmYmY5MTA3MGQ5MzM0MGE4M2FkMDI4Yjk4OTM0ZmFhNDJiODBiZWUzMjk5
14
+ NTZkODFmNjg4MmY0MDAzZmY3ZjVjN2RmOGJiMmY0NTQ0YjhmZGUzOWFjZWIy
15
+ ODRjY2E4MTA5OWQ5NGM1YmI4ZWEyNDQ1NWZlN2NlNzYxYmFmOTM=
@@ -24,6 +24,8 @@ module Pageflow
24
24
  end
25
25
 
26
26
  controller do
27
+ helper ThemesHelper
28
+
27
29
  def new
28
30
  @account = Account.new
29
31
  @account.default_theming = Theming.new
@@ -36,7 +38,7 @@ module Pageflow
36
38
  end
37
39
 
38
40
  def permitted_params
39
- params.permit(:account => [:name, :default_file_rights, :default_theming_attributes => [:cname, :theme_name, :imprint_link_url, :imprint_link_label, :copyright_link_url, :copyright_link_label]])
41
+ params.permit(:account => [:name, :default_file_rights, :default_theming_attributes => [:cname, :theme_name, :imprint_link_url, :imprint_link_label, :copyright_link_url, :copyright_link_label, :home_url, :home_button_enabled_by_default]])
40
42
  end
41
43
  end
42
44
  end
@@ -25,7 +25,7 @@ module Pageflow
25
25
  end
26
26
  span(link_to(I18n.t("admin.entries.preview"), preview_admin_entry_path(entry), :class => 'preview button'))
27
27
  if entry.published?
28
- span(link_to(I18n.t("admin.entries.show_public"), pageflow.entry_path(entry), :class => 'show_public button'))
28
+ span(link_to(I18n.t("admin.entries.show_public"), pretty_entry_url(entry), :class => 'show_public button'))
29
29
  end
30
30
  end
31
31
  end
@@ -89,6 +89,7 @@ module Pageflow
89
89
 
90
90
  controller do
91
91
  helper FoldersHelper
92
+ helper EntriesHelper
92
93
  helper Admin::RevisionsHelper
93
94
 
94
95
  def scoped_collection
@@ -1 +1,2 @@
1
+ //= require ./admin/accounts
1
2
  //= require ./admin/entries
@@ -0,0 +1,30 @@
1
+ jQuery(function($) {
2
+ $('.admin_accounts form.pageflow_account').each(function() {
3
+ var themeSelect = $('#account_default_theming_attributes_theme_name', this);
4
+ var themeOptions = JSON.parse($('script#theme_options', this).text());
5
+ var homeButtonCheckBox = $('#account_default_theming_attributes_home_button_enabled_by_default', this);
6
+
7
+ updateThemeFeatures();
8
+ themeSelect.on('change', updateThemeFeatures);
9
+
10
+ function updateThemeFeatures() {
11
+ toggleDisabled(homeButtonCheckBox, !selectedThemeSupportsHomeButton());
12
+ }
13
+
14
+ function selectedThemeSupportsHomeButton() {
15
+ return !themeOptions[themeSelect.val()].no_home_button;
16
+ }
17
+
18
+ function toggleDisabled(checkBox, disabled) {
19
+ if (disabled) {
20
+ checkBox.data('wasChecked', checkBox.is(':checked'));
21
+ checkBox.prop('checked', false);
22
+ checkBox.prop('disabled', true);
23
+ }
24
+ else {
25
+ checkBox.removeAttr('disabled');
26
+ checkBox.prop('checked', checkBox.data('wasChecked'));
27
+ }
28
+ }
29
+ });
30
+ });
@@ -1,6 +1,6 @@
1
1
  pageflow.assetUrls = {
2
- largeBandwidthProbe: '<%= Rails.env.test? ? asset_path("bandwidth_probe_large.png") : "http://#{File.join(Pageflow.config.zencoder_options[:s3_host_alias], "bandwidth_probe_large.png")}" %>',
3
- smallBandwidthProbe: '<%= Rails.env.test? ? asset_path("bandwidth_probe_small.png") : "http://#{File.join(Pageflow.config.zencoder_options[:s3_host_alias], "bandwidth_probe_small.png")}" %>',
2
+ largeBandwidthProbe: '<%= Rails.env.test? ? asset_path("bandwidth_probe_large.png") : "//#{File.join(Pageflow.config.zencoder_options[:s3_host_alias], "bandwidth_probe_large.png")}" %>',
3
+ smallBandwidthProbe: '<%= Rails.env.test? ? asset_path("bandwidth_probe_small.png") : "//#{File.join(Pageflow.config.zencoder_options[:s3_host_alias], "bandwidth_probe_small.png")}" %>',
4
4
  audioSwf: '<%= asset_path "pageflow/audio5js.swf" %>',
5
5
  emptyMp4: '<%= asset_path "pageflow/empty.mp4" %>',
6
6
  emptyWebm: '<%= asset_path "pageflow/empty.webm" %>'
@@ -0,0 +1,136 @@
1
+ //= require_tree ./api
2
+ //= require_self
3
+
4
+ /**
5
+ * Interface for engines providing editor extensions.
6
+ */
7
+ pageflow.EditorApi = pageflow.Object.extend({
8
+ initialize: function() {
9
+ this.sideBarRoutings = [];
10
+ this.mainMenuItems = [];
11
+ this.initializers = [];
12
+ this.fileSelectionHandlers = {};
13
+
14
+ /**
15
+ * Register additional router and controller for sidebar.
16
+ *
17
+ * Supported options:
18
+ * - router: constructor function of Backbone Marionette app router
19
+ * - controller: constructor function of Backbone Marionette controller
20
+ */
21
+ this.registerSideBarRouting = function(options) {
22
+ this.sideBarRoutings.push(options);
23
+ };
24
+
25
+ /**
26
+ * Register additional menu item to be displayed on the root sidebar
27
+ * view.
28
+ *
29
+ * Supported options:
30
+ * - translationKey: for the label
31
+ * - path: route to link to
32
+ */
33
+ this.registerMainMenuItem = function(options) {
34
+ this.mainMenuItems.push(options);
35
+ };
36
+
37
+ /**
38
+ * Register a custom initializer which will be run before the boot
39
+ * initializer of the editor.
40
+ */
41
+ this.addInitializer = function(fn) {
42
+ this.initializers.push(fn);
43
+ };
44
+
45
+ /**
46
+ * Navigate to the given path.
47
+ */
48
+ this.navigate = function(path, options) {
49
+ editor.navigate(path, options);
50
+ };
51
+
52
+ /**
53
+ * Extend the interface of page configuration objects. This is
54
+ * especially convenient to wrap structured data from the page
55
+ * configuration as Backbone objects.
56
+ *
57
+ * Example:
58
+ *
59
+ * pageflow.editor.registerPageConfigurationMixin({
60
+ * externalLinks: function() {
61
+ * return new Backbone.Collection(this.get('external_links'));
62
+ * }
63
+ * }
64
+ *
65
+ * pageflow.pages.get(1).configuration.externalLinks().each(...);
66
+ */
67
+ this.registerPageConfigurationMixin = function(mixin) {
68
+ Cocktail.mixin(pageflow.Configuration, mixin);
69
+ };
70
+
71
+ /**
72
+ * File selection handlers let editor extensions use the files view
73
+ * to select files for usage in their custom models.
74
+ *
75
+ * See selectFile method for details how to trigger file selection.
76
+ *
77
+ * Example:
78
+ *
79
+ * function MyFileSelectionHandler(options) {
80
+ * this.call = function(file) {
81
+ * // invoked with the selected file
82
+ * };
83
+ *
84
+ * this.getReferer = function() {
85
+ * // the path to return to when the back button is clicked
86
+ * // or after file selection
87
+ * return '/some/path';
88
+ * }
89
+ * }
90
+ *
91
+ * pageflow.editor.registerFileSelectionHandler('my_file_selection_handler', MyFileSelectionHandler);
92
+ */
93
+ this.registerFileSelectionHandler = function(name, handler) {
94
+ this.fileSelectionHandlers[name] = handler;
95
+ };
96
+
97
+ /**
98
+ * Trigger selection of the given file type with the given
99
+ * handler. Payload hash is passed to selection handler as options.
100
+ *
101
+ * Example:
102
+ *
103
+ * pageflow.editor.selectFile('image_files', 'my_file_selection_handler', {some: 'option for handler'});
104
+ */
105
+ this.selectFile = function(fileType, handlerName, payload) {
106
+ this.navigate('/files/' + fileType + '?handler=' + handlerName + '&payload=' + encodeURIComponent(JSON.stringify(payload)), {trigger: true});
107
+ };
108
+
109
+ /**
110
+ * Failures API
111
+ *
112
+ * Can watch collections for errors saving models and display the error
113
+ * allong with a retry button.
114
+ *
115
+ * pageflow.editor.failures.watch(collection);
116
+ *
117
+ * It's possible to add failures to the UI by adding instances of subclasses of pageflow.Failure:
118
+ *
119
+ * pageflow.editor.failures.add(new pageflow.OrderingFailure(model, collection));
120
+ *
121
+ */
122
+ this.failures = new pageflow.FailuresAPI();
123
+
124
+
125
+ /** @private */
126
+ this.createFileSelectionHandler = function(handlerName, encodedPayload) {
127
+ /** @private */
128
+ if (!this.fileSelectionHandlers[handlerName]) {
129
+ throw 'Unknown FileSelectionHandler ' + handlerName;
130
+ }
131
+
132
+ var payloadJson = JSON.parse(decodeURIComponent(encodedPayload));
133
+ return new this.fileSelectionHandlers[handlerName](payloadJson);
134
+ };
135
+ }
136
+ });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * pageflow.Failure and subclasses are used in the failures api.
3
+ *
4
+ * Subclasses that represent failures that are can not be retried should
5
+ * override `catRetry` with false.
6
+ * Retryable failures should implement `retryAction`.
7
+ */
8
+ pageflow.Failure = pageflow.Object.extend({
9
+ canRetry: true,
10
+ type: 'Failure',
11
+
12
+ initialize: function(model) {
13
+ this.model = model;
14
+ },
15
+
16
+ retry: function() {
17
+ if (this.canRetry) {
18
+ return this.retryAction();
19
+ }
20
+ },
21
+
22
+ retryAction: function() {
23
+ return this.model.save();
24
+ },
25
+
26
+ key: function() {
27
+ return this.model.cid + '-' + this.type;
28
+ }
29
+ });
30
+
31
+ /**
32
+ * SavingFailure represents a unsuccessful attempt to save
33
+ * a model on the server.
34
+ */
35
+ pageflow.SavingFailure = pageflow.Failure.extend({
36
+ type: 'SavingFailure'
37
+ });
38
+
39
+ /**
40
+ * OrderingFailure represent a unsuccessful attempt to save
41
+ * the ordering of a pageflow.orderedCollection.
42
+ */
43
+ pageflow.OrderingFailure = pageflow.Failure.extend({
44
+ type: 'OrderingFailure',
45
+
46
+ initialize: function(model, collection) {
47
+ pageflow.Failure.prototype.initialize.call(this, model);
48
+ this.collection = collection;
49
+ },
50
+
51
+ retryAction: function() {
52
+ return this.collection.saveOrder();
53
+ }
54
+ });
@@ -0,0 +1,47 @@
1
+ /**
2
+ * API to allow access to failure UI and recovery.
3
+ * Global instance at pageflow.failures.
4
+ */
5
+ pageflow.FailuresAPI = pageflow.Object.extend({
6
+ initialize: function() {
7
+ this.failures = {};
8
+ this.length = 0;
9
+ },
10
+
11
+ watch: function(collection) {
12
+ this.listenTo(collection, 'sync', this.remove);
13
+
14
+ this.listenTo(collection, 'error', function(model) {
15
+ if (!model.isNew()) {
16
+ this.add(new pageflow.SavingFailure(model));
17
+ }
18
+ });
19
+ },
20
+
21
+ retry: function() {
22
+ _.each(this.failures, function(failure, key) {
23
+ this.remove(key);
24
+ failure.retry();
25
+ }, this);
26
+ },
27
+
28
+ isEmpty: function() {
29
+ return _.size(this.failures) === 0;
30
+ },
31
+
32
+ add: function(failure) {
33
+ this.failures[failure.key()] = failure;
34
+ this.length = _.size(this.failures);
35
+ },
36
+
37
+ remove: function(key) {
38
+ delete this.failures[key];
39
+ this.length = _.size(this.failures);
40
+ },
41
+
42
+ count: function() {
43
+ return this.length;
44
+ }
45
+ });
46
+
47
+ _.extend(pageflow.FailuresAPI.prototype, Backbone.Events);
@@ -5,6 +5,7 @@
5
5
 
6
6
  //= require jquery.ui.all
7
7
  //= require jquery/layout
8
+
8
9
  //= require jquery-fileupload/vendor/load-image
9
10
  //= require jquery-fileupload/vendor/canvas-to-blob
10
11
  //= require jquery-fileupload/jquery.fileupload
@@ -14,6 +15,10 @@
14
15
  //= require parser_rules/simple
15
16
 
16
17
  //= require i18n
18
+ //= require i18n/translations
19
+
20
+ //= require ./object
21
+ //= require ./api
17
22
 
18
23
  //= require_self
19
24
 
@@ -40,6 +45,9 @@
40
45
  //= require ./initializers/setup_page_types
41
46
  //= require ./initializers/edit_lock
42
47
  //= require ./initializers/files_polling
48
+ //= require ./initializers/routing
49
+ //= require ./initializers/additional_initializers
43
50
  //= require ./initializers/boot
44
51
 
45
52
  pageflow.app = new Backbone.Marionette.Application();
53
+ pageflow.editor = new pageflow.EditorApi();
@@ -10,4 +10,4 @@ pageflow.ChaptersCollection = Backbone.Collection.extend({
10
10
  comparator: function(chapter) {
11
11
  return chapter.get('position');
12
12
  }
13
- });
13
+ });
@@ -1,15 +1,20 @@
1
1
  pageflow.orderedCollection = {
2
2
  saveOrder: function() {
3
3
  var parentModel = this.parentModel;
4
+ var collection = this;
4
5
 
5
- Backbone.sync('patch', parentModel, {
6
- url: this.url() + '/order',
7
- attrs: {ids: this.pluck('id')},
6
+ return Backbone.sync('patch', parentModel, {
7
+ url: collection.url() + '/order',
8
+ attrs: {ids: collection.pluck('id')},
8
9
 
9
10
  success: function(response) {
10
11
  parentModel.trigger('sync', parentModel, response, {});
11
12
  parentModel.trigger('sync:order', parentModel, response, {});
13
+ },
14
+
15
+ error: function(jqXHR, textStatus, errorThrown) {
16
+ pageflow.editor.failures.add(new pageflow.OrderingFailure(parentModel, collection));
12
17
  }
13
18
  });
14
19
  }
15
- };
20
+ };
@@ -10,23 +10,22 @@ pageflow.SidebarController = Backbone.Marionette.Controller.extend({
10
10
  }));
11
11
  },
12
12
 
13
- imageFiles: function(pageId, attributeName) {
14
- this.files(pageId, attributeName, 'image_files');
13
+ imageFiles: function(handler, payload) {
14
+ this.files(handler, payload, 'image_files');
15
15
  },
16
16
 
17
- videoFiles: function(pageId, attributeName) {
18
- this.files(pageId, attributeName, 'video_files');
17
+ videoFiles: function(handler, payload) {
18
+ this.files(handler, payload, 'video_files');
19
19
  },
20
20
 
21
- audioFiles: function(pageId, attributeName) {
22
- this.files(pageId, attributeName, 'audio_files');
21
+ audioFiles: function(handler, payload) {
22
+ this.files(handler, payload, 'audio_files');
23
23
  },
24
24
 
25
- files: function(pageId, attributeName, tabName) {
25
+ files: function(handler, payload, tabName) {
26
26
  this.region.show(new pageflow.FilesView({
27
27
  model: this.entry,
28
- page: this.entry.pages.get(pageId),
29
- pageAttributeName: attributeName,
28
+ selectionHandler: handler && pageflow.editor.createFileSelectionHandler(handler, payload),
30
29
  tabName: tabName
31
30
  }));
32
31
  },
@@ -62,4 +61,4 @@ pageflow.SidebarController = Backbone.Marionette.Controller.extend({
62
61
  tab: tab
63
62
  }));
64
63
  }
65
- });
64
+ });
@@ -0,0 +1,8 @@
1
+ pageflow.app.addInitializer(function(/* args */) {
2
+ var context = this;
3
+ var args = arguments;
4
+
5
+ _.each(pageflow.editor.initializers, function(fn) {
6
+ fn.call(context, args);
7
+ });
8
+ });