138 lines
4.4 KiB
JavaScript
138 lines
4.4 KiB
JavaScript
var SysSiteModules = (function() {
|
|
|
|
function SysSiteModules(){
|
|
var _this = this;
|
|
|
|
_this.oTable = new CTable("data");
|
|
_this.oTable.loadTableData();
|
|
}
|
|
|
|
// Rewrite CBase form callback
|
|
CBlank.prototype.viewCallback = function(jqObj, d){
|
|
var _this = this;
|
|
|
|
jqObj.find(".settings").find("h3").click(function(){
|
|
var jqParent = $(this).parent();
|
|
if(jqParent.hasClass("load"))
|
|
_this.loadBlankBlockSubContent(jqParent);
|
|
else
|
|
_this.showHideSubContentPanel(jqParent);
|
|
});
|
|
|
|
_this.tabs = new Tabs($(jqObj).find(".tabs"));
|
|
|
|
_this.oBtnPan.find("#fcancel").click(function(){
|
|
CBase.message.hide();
|
|
if(_this.isModiffied){
|
|
CBase.oTable.filterTableData(false);
|
|
}else{
|
|
CBase.oTable.show();
|
|
}
|
|
});
|
|
|
|
_this.oBtnPan.find("#fsave").click(function(){
|
|
_this.saveBlankView();
|
|
});
|
|
|
|
CBase.jsModule.bindRadioOptions(jqObj);
|
|
|
|
CBase.jsModule.bindAdditionalFunctionality(jqObj);
|
|
|
|
_this.bindBlankActions(jqObj);
|
|
};
|
|
|
|
// Base settings Checkboxes Binds
|
|
SysSiteModules.prototype.bindAdditionalFunctionality = function(jqObj){
|
|
|
|
var _this = this;
|
|
var jqClassName = jqObj.find("input#class_name");
|
|
|
|
jqObj.find("input#title").bind({
|
|
focusout : function(){
|
|
// When entering module title copy it to class name if no class name given
|
|
if(!jqClassName.val().length) jqClassName.val($(this).val()).focus();
|
|
}
|
|
});
|
|
|
|
// Validate class name on blur
|
|
jqClassName.bind({
|
|
focusout : function(){
|
|
$(this).val(_this.validateClassName($(this).val()));
|
|
}
|
|
});
|
|
// Validate class name on blur
|
|
jqObj.find("input#p_name, input#db_name").bind({
|
|
focusout : function(){
|
|
$(this).val($(this).val().trim().replace(/[^A-Z0-9]+/ig, "_"));
|
|
}
|
|
});
|
|
|
|
|
|
// Focus in query fields when cicked
|
|
jqObj.find(".queries > div > div").click(function(){
|
|
var selection = window.getSelection();
|
|
var txt = $(this);
|
|
var range = document.createRange();
|
|
range.selectNodeContents(txt[0]);
|
|
selection.removeAllRanges();
|
|
selection.addRange(range);
|
|
})
|
|
|
|
// Focus in query fields when cicked
|
|
jqObj.find(".queries .plus_btn").click(function(){
|
|
$(this).parent().next().slideToggle("normal");
|
|
})
|
|
|
|
};
|
|
|
|
// Base settings Checkboxes Binds
|
|
SysSiteModules.prototype.bindRadioOptions = function(jqObj){
|
|
|
|
var jqDbName = jqObj.find("input#db_name");
|
|
var jqPermissions = jqObj.find("input#p_name");
|
|
jqObj.find(".nRadioBox .chk").each(function(){
|
|
var _i = $(this), _p = _i.closest("li");
|
|
$(_i).add(_p.find("> label")).click(function(){
|
|
jqObj.find(".nRadioBox .chk.chked").removeClass("chked");
|
|
_i.addClass("chked");
|
|
|
|
jqObj.find("input#db_name").closest("ul").find("li.vtop > a").html(_i.attr("id") + "_");
|
|
jqObj.find("input#p_name").closest("ul").find("li.vtop > a").html(_i.attr("id") + "_");
|
|
});
|
|
});
|
|
};
|
|
|
|
SysSiteModules.prototype.validateClassName = function(str){
|
|
var arr = str.trim().split(/[\W_]/g);
|
|
//var arr = str.trim().split(/\s|_/);
|
|
for(var i=0,l=arr.length; i<l; i++) {
|
|
arr[i] = arr[i].substr(0,1).toUpperCase() +
|
|
(arr[i].length > 1 ? arr[i].substr(1) : "");// (arr[i].length > 1 ? arr[i].substr(1).toLowerCase() : "");
|
|
}
|
|
return arr.join("");
|
|
|
|
};
|
|
|
|
CBlank.prototype.saveBlankViewCallback = function(d){
|
|
|
|
// If new id then remove module select type and show selected module type;
|
|
if(d && d.jsonok){
|
|
if(d.newid){
|
|
var jqBase = $("#mBase");
|
|
var jqPMod = jqBase.find(" > p.module_type." + jqBase.find(".nRadioBox > .chked").attr("id"));
|
|
|
|
jqBase.find("ul.m_type").remove();
|
|
jqPMod.css({display : "inline-block"});
|
|
}
|
|
|
|
if(d.p_sql) $("div.p_query > div").html(d.p_sql);
|
|
if(d.t_sql) $("div.table_query > div").html(d.t_sql);
|
|
}
|
|
|
|
};
|
|
|
|
|
|
return SysSiteModules;
|
|
})();
|
|
|