Add JS files
This commit is contained in:
76
modules/EcmDocumentTemplates/EcmDocumentTemplates.js
Executable file
76
modules/EcmDocumentTemplates/EcmDocumentTemplates.js
Executable file
@@ -0,0 +1,76 @@
|
||||
|
||||
function doRequest(where,post,doFunction,error) {
|
||||
this.Display = function(result) { doFunction(result.responseText); }
|
||||
this.Fail = function(result){ if(error) alert(error);}
|
||||
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
|
||||
}
|
||||
|
||||
function changeValidateRequired(formname,name,required) {
|
||||
for(var i=0; i<validate[formname].length; i++)
|
||||
if(validate[formname][i][0] == name) { validate[formname][i][2] = required; break; }
|
||||
}
|
||||
|
||||
function set_focus() { document.getElementById('name').focus(); }
|
||||
|
||||
function my_popup(module, field_array, call_back_function, form_name) {
|
||||
if(!call_back_function) call_back_function = "set_return";
|
||||
if(!form_name) form_name = "EditView";
|
||||
return open_popup(module, 600, 400, "", true, false, {"call_back_function":call_back_function,"form_name":form_name,"field_to_name_array":field_array});
|
||||
}
|
||||
|
||||
function addEvent(object,eventName,do_function) {
|
||||
if(typeof(object) == "string") object = document.getElementById(object);
|
||||
if(!object) { alert('No object in function addEvent!'); return; }
|
||||
if(object.addEventListener) {
|
||||
object.addEventListener(eventName, do_function, false);
|
||||
} else {
|
||||
object.attachEvent('on'+eventName, do_function);
|
||||
}
|
||||
}
|
||||
|
||||
function updatePreviewNumber() {
|
||||
doRequest(
|
||||
'index.php',
|
||||
'module=EcmDocumentTemplates&action=formatDocumentNumber&to_pdf=1&ex=1&f='+document.getElementById('document_number_format_id').value+'&d='+document.getElementById('documents_per_day_id').value,
|
||||
function (response) { var dnfp = document.getElementById('doc_num_for_prev'); if(dnfp) dnfp.innerHTML = '('+response+')'; }
|
||||
)
|
||||
}
|
||||
|
||||
function deleteLogo() {
|
||||
var div = document.getElementById('logoDiv');
|
||||
if(div) div.parentNode.removeChild(div);
|
||||
}
|
||||
|
||||
var accountFL;
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function () {
|
||||
|
||||
//adding a div to document_number_format_id
|
||||
var dnfi = document.getElementById('document_number_format_id');
|
||||
if(dnfi) {
|
||||
var span = document.createElement('span');
|
||||
span.id = 'doc_num_for_prev';
|
||||
span.appendChild(document.createTextNode('()'));
|
||||
dnfi.parentNode.appendChild(span);
|
||||
}
|
||||
addEvent(dnfi, 'change', function () {updatePreviewNumber();});
|
||||
addEvent('documents_per_day_id', 'change', function () {updatePreviewNumber();});
|
||||
updatePreviewNumber();
|
||||
|
||||
|
||||
//create Account
|
||||
accountFL = new FormLoader();
|
||||
accountFL.load('EcmDocumentTemplates','Accounts','accountFL');
|
||||
accountFL.onResponseData = function(data) {
|
||||
document.forms.EditView.account_id.value = data['id'];
|
||||
document.forms.EditView.account_name.value = data['name'];
|
||||
};
|
||||
accountFL.setEditDblClick(document.forms.EditView.account_name);
|
||||
accountFL.onEditDblClick = function() { return "&fl_record="+document.forms.EditView.account_id.value; }
|
||||
accountFL.onButtonClick = function() { return "&fl_name="+document.forms.EditView.account_name.value; }
|
||||
//document.forms.EditView.account_id.parentNode.appendChild(accountFL.createButton());
|
||||
}
|
||||
);
|
||||
82
modules/EcmDocumentTemplates/formloader.js
Executable file
82
modules/EcmDocumentTemplates/formloader.js
Executable file
@@ -0,0 +1,82 @@
|
||||
|
||||
function doRequest(where,post,doFunction,error) {
|
||||
this.Display = function(result) { doFunction(result.responseText); }
|
||||
this.Fail = function(result){ if(error) alert(error);}
|
||||
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
|
||||
}
|
||||
|
||||
function changeValidateRequired(formname,name,required) {
|
||||
for(var i=0; i<validate[formname].length; i++)
|
||||
if(validate[formname][i][0] == name) { validate[formname][i][2] = required; break; }
|
||||
}
|
||||
|
||||
function my_popup(module, field_array, call_back_function, form_name) {
|
||||
if(!call_back_function) call_back_function = "set_return";
|
||||
if(!form_name) form_name = "EditView";
|
||||
return open_popup(module, 600, 400, "", true, false, {"call_back_function":call_back_function,"form_name":form_name,"field_to_name_array":field_array});
|
||||
}
|
||||
|
||||
function addEvent(object,eventName,do_function) {
|
||||
if(typeof(object) == "string") object = document.getElementById(object);
|
||||
if(!object) { alert('No object in function addEvent!'); return; }
|
||||
if(object.addEventListener) {
|
||||
object.addEventListener(eventName, do_function, false);
|
||||
} else {
|
||||
object.attachEvent('on'+eventName, do_function);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function FormLoader() {
|
||||
|
||||
this.module;
|
||||
this.createModule;
|
||||
this.fieldName;
|
||||
this.buttonName = 'FormLoaderButton';
|
||||
|
||||
this.load = function(module,createModule,fieldName) {
|
||||
this.module = module;
|
||||
this.createModule = createModule;
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
this.createButton = function() {
|
||||
var b = document.createElement('input');
|
||||
b.type = 'button';
|
||||
b.className = 'button';
|
||||
b.name = this.buttonName;
|
||||
b.value = 'Create';
|
||||
b.FL = this;
|
||||
b.onclick = function() {
|
||||
if(this.FL.createModule == '') return;
|
||||
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
|
||||
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create","resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
|
||||
this.editDblClick = function() {
|
||||
if(this.FL.createModule == '') return;
|
||||
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
|
||||
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create","resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
}
|
||||
|
||||
this.responseData = function(data) {
|
||||
if(this.onResponseData) this.onResponseData(data);
|
||||
}
|
||||
|
||||
this.onResponseData;
|
||||
|
||||
this.addPostData = function() {
|
||||
if(this.onAddPostData)
|
||||
return this.onAddPostData();
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
this.onAddPostData;
|
||||
this.onButtonClick;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user