2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* File: CommentTableField.js
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class: CommentTableField
|
|
|
|
*/
|
2007-08-08 08:00:20 +02:00
|
|
|
CommentTableField = Class.create();
|
|
|
|
CommentTableField.prototype = {
|
2010-05-08 04:45:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor: initialize
|
|
|
|
*/
|
2007-08-08 08:00:20 +02:00
|
|
|
initialize: function() {
|
|
|
|
var rules = {};
|
|
|
|
|
|
|
|
rules['#'+this.id+' table.data a.spamlink'] = {
|
|
|
|
onclick: this.removeRowAfterAjax.bind(this)
|
|
|
|
};
|
|
|
|
|
2007-08-13 00:19:06 +02:00
|
|
|
rules['#'+this.id+' table.data a.approvelink'] = {
|
2007-08-08 08:00:20 +02:00
|
|
|
onclick: this.removeRowAfterAjax.bind(this)
|
|
|
|
};
|
|
|
|
|
|
|
|
rules['#'+this.id+' table.data a.hamlink'] = {
|
|
|
|
onclick: this.removeRowAfterAjax.bind(this)
|
|
|
|
};
|
2007-08-10 02:03:30 +02:00
|
|
|
rules['#Form_EditForm div.CommentFilter input'] = {
|
|
|
|
onkeypress : this.prepareSearch.bind(this)
|
|
|
|
};
|
|
|
|
|
2007-08-10 02:20:08 +02:00
|
|
|
rules['#Form_EditForm'] = {
|
|
|
|
changeDetection_fieldsToIgnore : {
|
|
|
|
'ctf[start]' : true,
|
|
|
|
'ctf[ID]' : true,
|
|
|
|
'CommentFilterButton' : true,
|
|
|
|
'CommentFieldName' : true,
|
|
|
|
'Name' : true,
|
|
|
|
'Comment' : true,
|
2007-08-10 03:02:08 +02:00
|
|
|
'Comments[]' : true,
|
2007-08-10 02:20:08 +02:00
|
|
|
'Page' : true,
|
|
|
|
'CommentSearch' : true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-08 08:00:20 +02:00
|
|
|
Behaviour.register(rules);
|
|
|
|
},
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: removeRowAfterAjax
|
|
|
|
*/
|
2007-08-08 08:00:20 +02:00
|
|
|
removeRowAfterAjax: function(e) {
|
|
|
|
var img = Event.element(e);
|
|
|
|
var link = Event.findElement(e,"a");
|
|
|
|
var row = Event.findElement(e,"tr");
|
|
|
|
|
|
|
|
img.setAttribute("src",'cms/images/network-save.gif'); // TODO doesn't work in Firefox1.5+
|
2011-03-02 05:15:20 +01:00
|
|
|
jQuery.ajax({
|
|
|
|
'url': link.getAttribute("href")
|
|
|
|
'method': 'post',
|
|
|
|
'data': 'forceajax=1',
|
|
|
|
'success': function(){
|
|
|
|
Effect.Fade(row);
|
|
|
|
},
|
|
|
|
'error': function(response) {errorMessage('Server Error', response);}
|
|
|
|
});
|
2007-08-08 08:00:20 +02:00
|
|
|
Event.stop(e);
|
2007-08-10 02:03:30 +02:00
|
|
|
},
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: prepareSearch
|
|
|
|
*
|
|
|
|
* prevent submission of wrong form-button (CommentFilterButton)
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2007-08-10 02:03:30 +02:00
|
|
|
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);
|
|
|
|
$('CommentFilterButton').onclick(event);
|
|
|
|
Event.stop(event);
|
|
|
|
return false;
|
|
|
|
}
|
2007-08-08 08:00:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-10 02:03:30 +02:00
|
|
|
CommentTableField.applyTo('div.CommentTableField');
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Class: CommentFilterButton
|
|
|
|
*/
|
2007-08-10 02:03:30 +02:00
|
|
|
CommentFilterButton = Class.create();
|
2008-08-28 06:26:59 +02:00
|
|
|
CommentFilterButton.applyTo('#CommentFilterButton');
|
2007-08-10 02:03:30 +02:00
|
|
|
CommentFilterButton.prototype = {
|
2010-05-08 04:45:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor: initialize
|
|
|
|
*/
|
2007-08-10 02:03:30 +02:00
|
|
|
initialize: function() {
|
|
|
|
this.inputFields = new Array();
|
|
|
|
|
2009-04-29 03:44:28 +02:00
|
|
|
var childNodes = this.parentNode.parentNode.getElementsByTagName('input');
|
2007-08-10 02:03:30 +02:00
|
|
|
|
|
|
|
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] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: isChanged
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* (boolean)
|
|
|
|
*/
|
2007-08-10 02:03:30 +02:00
|
|
|
isChanged: function() {
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2010-05-08 04:45:05 +02:00
|
|
|
/**
|
|
|
|
* Function: onclick
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* (Event) e
|
|
|
|
*/
|
2007-08-10 02:03:30 +02:00
|
|
|
onclick: function(e) {
|
2008-08-28 06:26:59 +02:00
|
|
|
try {
|
|
|
|
var form = Event.findElement(e,"form");
|
|
|
|
var fieldName = $('CommentFieldName').value;
|
|
|
|
var fieldID = form.id + '_' + fieldName;
|
2009-04-29 03:44:28 +02:00
|
|
|
|
2008-08-28 06:26:59 +02:00
|
|
|
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 : '');
|
2007-08-10 02:03:30 +02:00
|
|
|
|
2008-08-28 06:26:59 +02:00
|
|
|
new Ajax.Updater( fieldID, updateURL, {
|
2009-04-29 03:44:28 +02:00
|
|
|
onComplete: function() {
|
|
|
|
Behaviour.apply($(fieldID), true);
|
2008-08-28 06:26:59 +02:00
|
|
|
},
|
|
|
|
onFailure: function( response ) {
|
|
|
|
errorMessage('Could not filter results: ' + response.responseText );
|
|
|
|
}.bind(this)
|
|
|
|
});
|
|
|
|
} catch(er) {
|
|
|
|
errorMessage('Error searching');
|
|
|
|
}
|
2007-08-10 02:03:30 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|