2009-02-16 17:23:30 +01:00
|
|
|
$(document).ready (function () {
|
|
|
|
var dummyFunc = function () {
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
|
|
|
$.extend ({
|
|
|
|
pandoraSelectGroup: new function() {
|
|
|
|
this.defaults = {
|
2009-02-23 17:23:58 +01:00
|
|
|
agentSelect: "select#id_agent",
|
|
|
|
loading: "#agent_loading",
|
2009-02-16 17:23:30 +01:00
|
|
|
callbackBefore: dummyFunc,
|
|
|
|
callbackPre: dummyFunc,
|
|
|
|
callbackPost: dummyFunc,
|
|
|
|
callbackAfter: dummyFunc,
|
|
|
|
debug: false
|
|
|
|
};
|
|
|
|
|
|
|
|
/* public methods */
|
|
|
|
this.construct = function (settings) {
|
|
|
|
return this.each (function() {
|
|
|
|
this.config = {};
|
|
|
|
|
2009-02-23 17:23:58 +01:00
|
|
|
this.config = $.extend (this.config, $.pandoraSelectGroup.defaults, settings);
|
|
|
|
var config = this.config;
|
2009-02-16 17:23:30 +01:00
|
|
|
|
|
|
|
$(this).change (function () {
|
2009-02-23 17:23:58 +01:00
|
|
|
var $select = $(config.agentSelect).disable ();
|
|
|
|
$(config.loading).show ();
|
2009-02-16 17:23:30 +01:00
|
|
|
$("option[value!=0]", $select).remove ();
|
2009-02-18 13:29:30 +01:00
|
|
|
config.callbackBefore (this);
|
2009-02-16 17:23:30 +01:00
|
|
|
|
|
|
|
jQuery.post ("ajax.php",
|
|
|
|
{"page" : "godmode/groups/group_list",
|
|
|
|
"get_group_agents" : 1,
|
|
|
|
"id_group" : this.value
|
|
|
|
},
|
|
|
|
function (data, status) {
|
|
|
|
jQuery.each (data, function (id, value) {
|
|
|
|
config.callbackPre ();
|
|
|
|
option = $("<option></option>")
|
|
|
|
.attr ("value", id)
|
|
|
|
.html (value);
|
|
|
|
config.callbackPost (id, value, option);
|
2009-02-23 17:23:58 +01:00
|
|
|
$(config.agentSelect).append (option);
|
2009-02-16 17:23:30 +01:00
|
|
|
});
|
2009-02-23 17:23:58 +01:00
|
|
|
$(config.loading).hide ();
|
2009-02-16 17:23:30 +01:00
|
|
|
$select.enable ();
|
|
|
|
config.callbackAfter ();
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2009-02-18 13:29:30 +01:00
|
|
|
$.extend ({
|
|
|
|
pandoraSelectAgent: new function() {
|
|
|
|
this.defaults = {
|
2009-02-23 17:23:58 +01:00
|
|
|
moduleSelect: "select#id_agent_module",
|
|
|
|
loading: "module_loading",
|
2009-02-18 13:29:30 +01:00
|
|
|
callbackBefore: dummyFunc,
|
|
|
|
callbackPre: dummyFunc,
|
|
|
|
callbackPost: dummyFunc,
|
|
|
|
callbackAfter: dummyFunc,
|
|
|
|
debug: false
|
|
|
|
};
|
|
|
|
|
|
|
|
/* public methods */
|
|
|
|
this.construct = function (settings) {
|
|
|
|
return this.each (function() {
|
|
|
|
this.config = {};
|
|
|
|
|
2009-02-23 17:23:58 +01:00
|
|
|
this.config = $.extend (this.config, $.pandoraSelectAgent.defaults, settings);
|
2009-02-18 13:29:30 +01:00
|
|
|
|
2009-02-23 17:23:58 +01:00
|
|
|
var config = this.config;
|
|
|
|
|
2009-02-18 13:29:30 +01:00
|
|
|
$(this).change (function () {
|
2009-02-23 17:23:58 +01:00
|
|
|
var $select = $(config.moduleSelect).disable ();
|
|
|
|
$(config.loading).show ();
|
2009-02-18 13:29:30 +01:00
|
|
|
$("option[value!=0]", $select).remove ();
|
|
|
|
config.callbackBefore (this);
|
|
|
|
|
|
|
|
jQuery.post ('ajax.php',
|
|
|
|
{"page": "operation/agentes/ver_agente",
|
|
|
|
"get_agent_modules_json": 1,
|
|
|
|
"id_agent": this.value
|
|
|
|
},
|
|
|
|
function (data) {
|
|
|
|
jQuery.each (data, function (i, value) {
|
|
|
|
config.callbackPre ();
|
|
|
|
option = $("<option></option>")
|
|
|
|
.attr ("value", value['id_agente_modulo'])
|
|
|
|
.html (html_entity_decode (value['nombre']));
|
|
|
|
config.callbackPost (i, value, option);
|
2009-02-23 17:23:58 +01:00
|
|
|
$(config.moduleSelect).append (option);
|
2009-02-18 13:29:30 +01:00
|
|
|
});
|
2009-02-23 17:23:58 +01:00
|
|
|
$(config.loading).hide ();
|
2009-02-18 13:29:30 +01:00
|
|
|
$select.enable ();
|
|
|
|
config.callbackAfter ();
|
|
|
|
},
|
|
|
|
"json"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
2009-02-16 17:23:30 +01:00
|
|
|
$.fn.extend({
|
2009-02-18 13:29:30 +01:00
|
|
|
pandoraSelectGroup: $.pandoraSelectGroup.construct,
|
|
|
|
pandoraSelectAgent: $.pandoraSelectAgent.construct,
|
2009-02-16 17:23:30 +01:00
|
|
|
});
|
|
|
|
});
|