171 lines
6.2 KiB
JavaScript
171 lines
6.2 KiB
JavaScript
var SysTranslationsPub = (function() {
|
|
|
|
function SysTranslationsPub(){
|
|
var _this = this;
|
|
|
|
_this.oTable = new CTable("data");
|
|
_this.oTable.loadTableData();
|
|
|
|
_this.setupFileUpload();
|
|
}
|
|
|
|
// Rewrite CTable object callback
|
|
CTable.prototype.tableObjectCallback = function(oTable){
|
|
var _this = this;
|
|
oTable.find("#icleartable").click(function(){
|
|
|
|
CBase.oDialog.show({
|
|
closeBtn: true,
|
|
title : $.isDefined(CBase.gM.clearTitle)?CBase.gM.clearTitle:"...",
|
|
message :$.isDefined(CBase.gM.clearMessage)?CBase.gM.clearMessage:"-",
|
|
buttons : {
|
|
1 : {
|
|
lbl : $.isDefined(CBase.gM.clearYes)?CBase.gM.clearYes:"Ok",
|
|
id : "buttonYes",
|
|
click : function(){
|
|
CBase.oDialog.hide();
|
|
_this.sendAjaxAction("clearAll", {force : 1}, function(d){
|
|
if(d && $.isDefined(d.jsonok))
|
|
_this.filterTableData(true);
|
|
});
|
|
}
|
|
},
|
|
2 : {
|
|
lbl :$.isDefined(CBase.gM.clearCancel)?CBase.gM.clearCancel:"Cancel",
|
|
id : "buttonNo",
|
|
click : function(){
|
|
CBase.oDialog.hide();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
oTable.find("#icleanup").click(function(){
|
|
|
|
CBase.oDialog.show({
|
|
closeBtn: true,
|
|
title : $.isDefined(CBase.gM.cleanupTitle)?CBase.gM.cleanupTitle:"...",
|
|
message :$.isDefined(CBase.gM.cleanupMessage)?CBase.gM.cleanupMessage:"-",
|
|
buttons : {
|
|
1 : {
|
|
lbl : $.isDefined(CBase.gM.cleanupYes)?CBase.gM.cleanupYes:"Ok",
|
|
id : "buttonYes",
|
|
click : function(){
|
|
CBase.oDialog.hide();
|
|
_this.sendAjaxAction("cleanupAll", {force : 1}, function(d){
|
|
if(d && $.isDefined(d.jsonok))
|
|
_this.filterTableData(true);
|
|
});
|
|
}
|
|
},
|
|
2 : {
|
|
lbl :$.isDefined(CBase.gM.clearCancel)?CBase.gM.clearCancel:"Cancel",
|
|
id : "buttonNo",
|
|
click : function(){
|
|
CBase.oDialog.hide();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
// Export translation data into excel file
|
|
oTable.find("#iExport").click(function(){
|
|
_this.sendAjaxActionAdvanced({
|
|
action : "fileExport"
|
|
}, function(d){
|
|
if(d && d.jsonok){
|
|
if(d.msg && d.file){
|
|
CBase.oDialog.show({
|
|
closeBtn: true,
|
|
title : "Data export to Excel (.xlsx)",
|
|
message : d.msg,
|
|
buttons : {
|
|
1 : {
|
|
lbl : "Download file",
|
|
id : "buttonYes",
|
|
href : d.file
|
|
},
|
|
2 : {
|
|
lbl : "Continue",
|
|
id : "buttonNo",
|
|
click : function(){
|
|
CBase.oDialog.hide();
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// Import translation data from excel file
|
|
oTable.find("#iImport").click(function(){
|
|
$("#upload-global").click();
|
|
});
|
|
|
|
};
|
|
|
|
// Rewrite CBase form callback
|
|
CBlank.prototype.viewCallback = function(jqObj){
|
|
var _this = this;
|
|
|
|
_this.tabs = new Tabs(jqObj.find(".tabs"));
|
|
|
|
this.oBtnPan.find("#fcancel").click(function(){
|
|
CBase.message.hide();
|
|
if(_this.isModiffied){
|
|
CBase.oTable.filterTableData(true);
|
|
}else{
|
|
CBase.oTable.show();
|
|
}
|
|
});
|
|
|
|
this.oBtnPan.find("#fsave").click(function(){
|
|
_this.saveBlankView();
|
|
});
|
|
|
|
this.bindBlankActions(jqObj);
|
|
};
|
|
// File upload bind + cfg
|
|
SysTranslationsPub.prototype.setupFileUpload = function(){
|
|
var _this = this;
|
|
|
|
if($.isDefined(CBase.dt.upload)){
|
|
_this.cfg = CBase.dt.upload;
|
|
|
|
$("#upload-global").fileupload({
|
|
url: _this.cfg.script,
|
|
dataType: 'json',
|
|
formData: _this.cfg.scriptData,
|
|
acceptFileTypes: /(\.|\/)(xls|xlsx)$/i,
|
|
maxFileSize: 6291456, // 6 MB
|
|
// Enable image resizing, except for Android and Opera,
|
|
// which actually support image resizing, but fail to
|
|
// send Blob objects via XHR requests:
|
|
disableImageResize: true,
|
|
previewCrop: false,
|
|
done: function (e, data) {
|
|
// if(data.result.jsonok)
|
|
_this.oTable.sendAjaxActionAdvanced({
|
|
action : "importData",
|
|
file : data.result
|
|
}, function(d){
|
|
_this.oTable.filterTableData(false);
|
|
if(d && $.isDefined(d.msg))
|
|
CBase.message.show(($.isDefined(d.error) ? true : false), true, ($.isDefined(d.msg)? d.msg: false));
|
|
|
|
});
|
|
}
|
|
}).prop('disabled', !$.support.fileInput)
|
|
.parent().addClass($.support.fileInput ? undefined : 'disabled');
|
|
}
|
|
};
|
|
|
|
return SysTranslationsPub;
|
|
|
|
})();
|