MINOR Moved 'delete files' logic from AssetAdmin.DragDrop.js into AssetTableField.js

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92803 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-21 03:19:08 +00:00
parent 067b7bcaeb
commit c2e1c12bba
2 changed files with 41 additions and 39 deletions

View File

@ -1,42 +1,3 @@
MarkingPropertiesButton = Class.create();
MarkingPropertiesButton.applyTo('#Form_EditForm_deletemarked', "Please select some files to delete!", 'deletemarked', 'Do you really want to delete the marked files?');
MarkingPropertiesButton.prototype = {
initialize: function(noneCheckedError, action, confirmMessage) {
this.noneCheckedError = noneCheckedError;
this.action = action;
this.confirmMessage = confirmMessage;
},
onclick: function() {
var i, list = "", checkboxes = $('Form_EditForm').elements['Files[]'];
if(!checkboxes) checkboxes = [];
if(!checkboxes.length) checkboxes = [ checkboxes ];
for(i=0;i<checkboxes.length;i++) {
if(checkboxes[i].checked) list += (list?',':'') + checkboxes[i].value;
}
if(list == "") {
alert(this.noneCheckedError);
return false;
} else {
$('Form_EditForm_FileIDs').value = list;
}
// If there is a confirmation message, show it before submitting
if('' != this.confirmMessage) {
// Only submit if OK button is clicked
if (confirm(this.confirmMessage)) {
$('Form_EditForm').save(false, null, this.action);
}
} else {
$('Form_EditForm').save(false, null, this.action);
}
return false;
}
}
// CheckBoxRange adapted from: http://jroller.com/page/rmcmahon?entry=checkboxrange_with_prototype // CheckBoxRange adapted from: http://jroller.com/page/rmcmahon?entry=checkboxrange_with_prototype
var CheckBoxRange = Class.create(); var CheckBoxRange = Class.create();

View File

@ -95,3 +95,44 @@ FileFilterButton.prototype = {
return false; return false;
} }
} }
MarkingPropertiesButton = Class.create();
MarkingPropertiesButton.applyTo(
'#Form_EditForm_deletemarked',
"Please select some files to delete!", 'deletemarked', 'Do you really want to delete the marked files?'
);
MarkingPropertiesButton.prototype = {
initialize: function(noneCheckedError, action, confirmMessage) {
this.noneCheckedError = noneCheckedError;
this.action = action;
this.confirmMessage = confirmMessage;
},
onclick: function() {
var i, list = "", checkboxes = $('Form_EditForm').elements['Files[]'];
if(!checkboxes) checkboxes = [];
if(!checkboxes.length) checkboxes = [ checkboxes ];
for(i=0;i<checkboxes.length;i++) {
if(checkboxes[i].checked) list += (list?',':'') + checkboxes[i].value;
}
if(list == "") {
alert(this.noneCheckedError);
return false;
} else {
$('Form_EditForm_FileIDs').value = list;
}
// If there is a confirmation message, show it before submitting
if('' != this.confirmMessage) {
// Only submit if OK button is clicked
if (confirm(this.confirmMessage)) {
$('Form_EditForm').save(false, null, this.action);
}
} else {
$('Form_EditForm').save(false, null, this.action);
}
return false;
}
}