Skip to content

Commit

Permalink
MINOR Moved 'delete files' logic from AssetAdmin.DragDrop.js into Ass…
Browse files Browse the repository at this point in the history
…etTableField.js

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92803 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 21, 2009
1 parent 067b7bc commit c2e1c12
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
39 changes: 0 additions & 39 deletions javascript/AssetAdmin.DragDrop.js
@@ -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();


Expand Down
41 changes: 41 additions & 0 deletions javascript/AssetTableField.js
Expand Up @@ -94,4 +94,45 @@ 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;
}
} }

0 comments on commit c2e1c12

Please sign in to comment.