var Core = function(){}
var Form = function(){}
var Link = function(){}
/* Base class */
Core.prototype.open_loader = function(){
$('body').append('<div id="load"><img src="'+imgLoader.src+'" /></div>');
$('#load').show();
}
Core.prototype.close_loader = function(){
$('#load').remove();
}
Core.prototype.response_parser = function( response ){
action = response.action;
var insert_errors = function(){
$("input").removeClass('error');
jQuery.each(action.args.errors, function(){
if ( this == '__all__' ) {
$("input").addClass('error');
} else {
$("[name="+this+"]").addClass('error');
}
})
}
var redirect = function(){
window.location = action.args.location;
}
var event = function(){
$.ItqEvent(action.args.text, {'theme': action.args.theme});
}
var new_rating = function(){
var rating = (!action.args.rating)? "0" : action.args.rating;
$('#rating-' + action.args.id).html(rating);
$.ItqEvent(action.args.text, {'theme': action.args.theme})
}
var add_answer = function(){
if(action.args.success == true) {
$('#answers').append(action.args.html);
} else {
$.ItqEvent(action.args.text, {'theme': action.args.theme});
}
}
var bookmark_del = function(){
$('#bookmark-' + action.args.id).remove();
$.ItqEvent(action.args.text, {'theme': 'success'})
}
var profile_save = function(){
$.ItqEvent(action.args.text, {'theme': action.args.theme});
}
eval(action.func + '()');
}
/* Ajax links working class */
Link.prototype = new Core();
Link.prototype.ajax_link = function(o, d){
$.ajax({
type: 'post',
data: d,
url: o.href,
success: this.response_parser,
dataType: 'json'
});
}
/* Form working class */
Form.prototype = new Core();
Form.prototype.ajax_form = function( selector ){
$(selector).ajaxForm({
data: {'selector': selector },
success: this.response_parser,
dataType: 'json'
});
}