-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #654 from tf/file-configuration
File configuration
- Loading branch information
Showing
72 changed files
with
1,973 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/pageflow/editor/initializers/setup_file_uploader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pageflow.app.addInitializer(function(options) { | ||
pageflow.fileUploader = new pageflow.FileUploader({ | ||
entry: pageflow.entry, | ||
fileTypes: pageflow.editor.fileTypes | ||
}); | ||
|
||
pageflow.ConfirmUploadView.watch(pageflow.fileUploader, | ||
pageflow.editor.fileTypes, | ||
pageflow.files); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/pageflow/editor/models/file_configuration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pageflow.FileConfiguration = pageflow.Configuration.extend({ | ||
defaults: { | ||
}, | ||
|
||
applyUpdaters: function(updaters, newAttributes) { | ||
_(updaters).each(function(updater) { | ||
updater(this, newAttributes); | ||
}, this); | ||
} | ||
}); |
46 changes: 46 additions & 0 deletions
46
app/assets/javascripts/pageflow/editor/models/file_uploader.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
pageflow.FileUploader = pageflow.Object.extend({ | ||
initialize: function(options) { | ||
this.fileTypes = options.fileTypes; | ||
this.entry = options.entry; | ||
|
||
this.deferreds = []; | ||
}, | ||
|
||
add: function(upload) { | ||
var fileType = this.fileTypes.findByUpload(upload); | ||
var file = new fileType.model({ | ||
state: 'uploadable', | ||
file_name: upload.name | ||
}, { | ||
fileType: fileType | ||
}); | ||
|
||
this.entry.getFileCollection(fileType).add(file); | ||
|
||
var deferred = new $.Deferred(); | ||
this.deferreds.push(deferred); | ||
|
||
if (this.deferreds.length == 1) { | ||
this.trigger('new:batch'); | ||
} | ||
|
||
return deferred.promise().then( | ||
function() { | ||
file.set('state', 'uploading'); | ||
return file; | ||
}, | ||
function() { | ||
file.destroy(); | ||
}); | ||
}, | ||
|
||
submit: function() { | ||
_(this.deferreds).invoke('resolve'); | ||
this.deferreds = []; | ||
}, | ||
|
||
abort: function() { | ||
_(this.deferreds).invoke('reject'); | ||
this.deferreds = []; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/assets/javascripts/pageflow/editor/templates/confirm_upload.jst.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="box"> | ||
<h1 class="dialog-header"><%= I18n.t('pageflow.editor.templates.confirm_upload.header') %></h1> | ||
<p class="dialog-hint"><%= I18n.t('pageflow.editor.templates.confirm_upload.hint') %></p> | ||
|
||
<div class="files_panel"> | ||
</div> | ||
|
||
<div class="selected_file_panel"> | ||
<h2><%= I18n.t('pageflow.editor.templates.confirm_upload.edit_file_header') %></h2> | ||
<div class="selected_file_region"> | ||
</div> | ||
</div> | ||
|
||
<div class="footer"> | ||
<button class="upload"><%= I18n.t('pageflow.editor.templates.confirm_upload.upload') %></button> | ||
<button class="close"><%= I18n.t('pageflow.editor.templates.confirm_upload.close') %></button> | ||
</div> | ||
</div> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/pageflow/editor/templates/file_settings_dialog.jst.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div class="box"> | ||
<div class="content"> | ||
</div> | ||
|
||
<div class="footer"> | ||
<a href="" class="close"> | ||
<%= I18n.t('pageflow.editor.templates.file_settings_dialog.close') %> | ||
</a> | ||
</div> | ||
</div> |
1 change: 1 addition & 0 deletions
1
app/assets/javascripts/pageflow/editor/templates/uploadable_files.jst.ejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h2></h2> |
17 changes: 17 additions & 0 deletions
17
app/assets/javascripts/pageflow/editor/utils/form_data_utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
pageflow.formDataUtils = { | ||
fromModel: function(model) { | ||
var object = {}; | ||
object[model.modelName] = model.toJSON(); | ||
|
||
return this.fromObject(object); | ||
}, | ||
|
||
fromObject: function(object) { | ||
return _(decodeURIComponent($.param(object)).split('&')).reduce(function(result, param) { | ||
var pair = param.split('='); | ||
result[pair[0]] = pair[1]; | ||
|
||
return result; | ||
}, {}); | ||
} | ||
}; |
Oops, something went wrong.