mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-09-06 01:31:09 +02:00
ENHANCEMENT Refactored CSS applied to filter boxes by using common selector git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@65173 467b73ca-7a2a-4603-9d3b-597d59a354a9
102 lines
2.7 KiB
JavaScript
102 lines
2.7 KiB
JavaScript
AssetTableField = Class.create();
|
|
AssetTableField.applyTo('#Form_EditForm_Files');
|
|
AssetTableField.prototype = {
|
|
|
|
initialize: function() {
|
|
Behaviour.register({
|
|
'#Form_EditForm div.FileFilter input' : {
|
|
onkeypress : this.prepareSearch.bind(this)
|
|
},
|
|
|
|
'#Form_EditForm' : {
|
|
changeDetection_fieldsToIgnore : {
|
|
'ctf[start]' : true,
|
|
'ctf[ID]' : true,
|
|
'FileFilterButton' : true,
|
|
'FileFieldName' : true,
|
|
'FileSearch' : true
|
|
}
|
|
}
|
|
});
|
|
},
|
|
|
|
// prevent submission of wrong form-button (FileFilterButton)
|
|
prepareSearch: function(e) {
|
|
// IE6 doesnt send an event-object with onkeypress
|
|
var event = (e) ? e : window.event;
|
|
var keyCode = (event.keyCode) ? event.keyCode : event.which;
|
|
|
|
if(keyCode == Event.KEY_RETURN) {
|
|
var el = Event.element(event);
|
|
$('FileFilterButton').onclick(event);
|
|
Event.stop(event);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|
|
FileFilterButton = Class.create();
|
|
FileFilterButton.applyTo('#FileFilterButton');
|
|
FileFilterButton.prototype = {
|
|
initialize: function() {
|
|
this.inputFields = new Array();
|
|
|
|
var childNodes = this.parentNode.parentNode.getElementsByTagName('input');
|
|
|
|
for( var index = 0; index < childNodes.length; index++ ) {
|
|
if( childNodes[index].tagName ) {
|
|
childNodes[index].resetChanged = function() { return false; }
|
|
childNodes[index].isChanged = function() { return false; }
|
|
this.inputFields.push( childNodes[index] );
|
|
}
|
|
}
|
|
|
|
childNodes = this.parentNode.getElementsByTagName('select');
|
|
|
|
for( var index = 0; index < childNodes.length; index++ ) {
|
|
if( childNodes[index].tagName ) {
|
|
childNodes[index].resetChanged = function() { return false; }
|
|
childNodes[index].field_changed = function() { return false; }
|
|
this.inputFields.push( childNodes[index] );
|
|
}
|
|
}
|
|
},
|
|
|
|
isChanged: function() {
|
|
return false;
|
|
},
|
|
|
|
onclick: function(e) {
|
|
if(!$('ctf-ID') || !$('FileFieldName')) {
|
|
return false;
|
|
}
|
|
|
|
try {
|
|
var form = Event.findElement(e, 'form');
|
|
var fieldName = $('FileFieldName').value;
|
|
var fieldID = form.id + '_' + fieldName;
|
|
|
|
var updateURL = form.action + '/field/' + fieldName + '?ajax=1';
|
|
for(var index = 0; index < this.inputFields.length; index++) {
|
|
if(this.inputFields[index].tagName) {
|
|
updateURL += '&' + this.inputFields[index].name + '=' + encodeURIComponent(this.inputFields[index].value);
|
|
}
|
|
}
|
|
|
|
updateURL += ($('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '');
|
|
|
|
new Ajax.Updater(fieldID, updateURL, {
|
|
onComplete: function() {
|
|
Behaviour.apply($(fieldID), true);
|
|
},
|
|
onFailure: function(response) {
|
|
errorMessage('Could not filter results: ' + response.responseText );
|
|
}
|
|
});
|
|
} catch(er) {
|
|
errorMessage('Error searching');
|
|
}
|
|
|
|
return false;
|
|
}
|
|
} |