mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
MINOR Fixed merge error from r99117 (from r101076)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@111634 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8ea6dddba5
commit
10081b2911
36
thirdparty/multifile/multifile.js
vendored
36
thirdparty/multifile/multifile.js
vendored
@ -43,6 +43,26 @@
|
|||||||
|
|
||||||
// Modified by: Silverstripe Ltd. (changed naming of file-input-elements)
|
// Modified by: Silverstripe Ltd. (changed naming of file-input-elements)
|
||||||
|
|
||||||
|
function ObservableObject() {
|
||||||
|
this.functions = [];
|
||||||
|
}
|
||||||
|
ObservableObject.prototype = {
|
||||||
|
subscribe : function(evt, fn) {
|
||||||
|
this.functions.push([evt, fn]);
|
||||||
|
},
|
||||||
|
unsubscribe : function(evt, fn) {
|
||||||
|
this.functions = this.fns.filter(function(el) {if (el !== [evt, fn]) return el;});
|
||||||
|
},
|
||||||
|
fire : function(evt, data, scope) {
|
||||||
|
scope = scope || window
|
||||||
|
this.functions.forEach(function(el) {
|
||||||
|
if (el[0] == evt) el[1].call(scope, data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var MultiSelectorObserver = new ObservableObject();
|
||||||
|
|
||||||
function MultiSelector( list_target, max, upload_button ){
|
function MultiSelector( list_target, max, upload_button ){
|
||||||
|
|
||||||
this.upload_button = upload_button;
|
this.upload_button = upload_button;
|
||||||
@ -130,6 +150,7 @@ function MultiSelector( list_target, max, upload_button ){
|
|||||||
* Add a new row to the list of files
|
* Add a new row to the list of files
|
||||||
*/
|
*/
|
||||||
this.addListRow = function( element ){
|
this.addListRow = function( element ){
|
||||||
|
var fileId = this.id -1;
|
||||||
|
|
||||||
// Modified 2006-11-06 by Silverstripe Ltd.
|
// Modified 2006-11-06 by Silverstripe Ltd.
|
||||||
var filenameMatches = element.value.match(/([^\/\\]+)$/);
|
var filenameMatches = element.value.match(/([^\/\\]+)$/);
|
||||||
@ -137,6 +158,7 @@ function MultiSelector( list_target, max, upload_button ){
|
|||||||
|
|
||||||
// Row div
|
// Row div
|
||||||
var new_row = document.createElement('div');
|
var new_row = document.createElement('div');
|
||||||
|
new_row.className = 'fileBox';
|
||||||
|
|
||||||
// Delete button
|
// Delete button
|
||||||
var new_row_button = document.createElement('input');
|
var new_row_button = document.createElement('input');
|
||||||
@ -175,15 +197,29 @@ function MultiSelector( list_target, max, upload_button ){
|
|||||||
// Modified 2006-11-06 by Silverstripe Ltd.
|
// Modified 2006-11-06 by Silverstripe Ltd.
|
||||||
new_row.innerHTML = filename;
|
new_row.innerHTML = filename;
|
||||||
|
|
||||||
|
MultiSelectorObserver.fire('onBeforeCreateRow', [fileId, new_row], this);
|
||||||
|
|
||||||
// Add button
|
// Add button
|
||||||
new_row.appendChild( new_row_button );
|
new_row.appendChild( new_row_button );
|
||||||
|
|
||||||
// Add it to the list
|
// Add it to the list
|
||||||
this.list_target.appendChild( new_row );
|
this.list_target.appendChild( new_row );
|
||||||
|
|
||||||
|
MultiSelectorObserver.fire('onAfterCreateRow', [fileId, new_row], this);
|
||||||
|
|
||||||
// Modified 2006-11-06 by Silverstripe Ltd.
|
// Modified 2006-11-06 by Silverstripe Ltd.
|
||||||
if(typeof(window.ontabschanged) != 'undefined') window.ontabschanged();
|
if(typeof(window.ontabschanged) != 'undefined') window.ontabschanged();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MultiSelectorObserver.subscribe('onBeforeCreateRow', function(data) {
|
||||||
|
if (jQuery('#metadataFormTemplate')) {
|
||||||
|
var parameters = jQuery('#metadataFormTemplate').clone(true);
|
||||||
|
parameters.get(0).id = '';
|
||||||
|
parameters.find(":input[name!='']").each(function(i) { this.name = this.name.replace(/__X__/g, data[0]); });
|
||||||
|
parameters.find(":input[id!='']").each(function(i) { this.id = this.id.replace(/__X__/g, data[0]); });
|
||||||
|
data[1].innerHTML = data[1].innerHTML + '<div id="MetadataFor-'+data[0]+'">'+parameters.html()+'</div>';
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user