晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/akaindir/www/crm/layouts/v7/modules/Documents/resources/ |
Upload File : |
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*************************************************************************************/
Vtiger_Edit_Js("Documents_Edit_Js", {
file : false
} ,{
INTERNAL_FILE_LOCATION_TYPE : 'I',
EXTERNAL_FILE_LOCATION_TYPE : 'E',
getMaxiumFileUploadingSize : function(container) {
//TODO : get it from the server
return container.find('.maxUploadSize').data('value');
},
isFileLocationInternalType : function(fileLocationElement) {
if(fileLocationElement.val() == this.INTERNAL_FILE_LOCATION_TYPE) {
return true;
}
return false;
},
isFileLocationExternalType : function(fileLocationElement) {
if(fileLocationElement.val() == this.EXTERNAL_FILE_LOCATION_TYPE) {
return true;
}
return false;
},
convertFileSizeInToDisplayFormat : function(fileSizeInBytes) {
var i = -1;
var byteUnits = [' kB', ' MB', ' GB', ' TB', 'PB', 'EB', 'ZB', 'YB'];
do {
fileSizeInBytes = fileSizeInBytes / 1024;
i++;
} while (fileSizeInBytes > 1024);
return Math.max(fileSizeInBytes, 0.1).toFixed(1) + byteUnits[i];
},
registerFileLocationTypeChangeEvent : function(container) {
var thisInstance = this;
container.on('change', 'select[name="filelocationtype"],input[name="filelocationtype"]', function(e){
var fileLocationTypeElement = container.find('select[name="filelocationtype"]');
var fileNameElement = container.find('[name="filename"]');
jQuery(fileNameElement).removeClass('input-error').trigger('Vtiger.Validation.Hide.Messsage');
var dragDropElement = fileNameElement.closest('table').find('#dragandrophandler');
var replaceElement = fileNameElement;
if(thisInstance.isFileLocationInternalType(fileLocationTypeElement)) {
var newFileNameElement = jQuery(
'<div class="fileUploadBtn btn btn-primary">'+
'<span><i class="fa fa-laptop"></i> '+
app.vtranslate("JS_UPLOAD")+
'</span>'+
'<input type="file"/>'+
'</div>'
);
if(dragDropElement.length) dragDropElement.removeClass('hide');
}else{
var newFileNameElement = jQuery('<input type="text" data-rule-url="true" data-rule-required="true"/>');
if(dragDropElement.length) dragDropElement.addClass('hide');
replaceElement = fileNameElement.closest('.fileUploadBtn');
}
var oldElementAttributeList = fileNameElement.get(0).attributes;
for(var index=0; index<oldElementAttributeList.length; index++) {
var attributeObject = oldElementAttributeList[index];
//Dont update the type attribute
if(attributeObject.name=='type' || attributeObject.name == 'value' || attributeObject.name == 'style'){
continue;
}
if(newFileNameElement.hasClass('fileUploadBtn')) {
newFileNameElement.find('input[type="file"]').attr(attributeObject.name, attributeObject.value);
} else {
newFileNameElement.attr(attributeObject.name, attributeObject.value);
}
}
replaceElement.replaceWith(newFileNameElement);
var fileNameElementTd = newFileNameElement.closest('td');
if(thisInstance.isFileLocationExternalType(fileLocationTypeElement)){
fileNameElementTd.prev('td.fieldLabel').empty().append('<label class="">'+app.vtranslate('JS_EXTERNAL_FILE_URL')+' '+'<span class="redColor">*</span></label>');
} else {
fileNameElementTd.prev('td.fieldLabel').empty().append('<label class="">'+app.vtranslate('JS_FILE_NAME')+' </label>');
}
var uploadFileDetails = fileNameElementTd.find('.uploadedFileDetails');
if(thisInstance.isFileLocationExternalType(fileLocationTypeElement)) {
uploadFileDetails.addClass('hide').removeClass('show');
}else{
uploadFileDetails.addClass('show').removeClass('hide');
}
});
if(container.find('input[name="filelocationtype"]').val() == 'E'){
jQuery('select[name="filelocationtype"],input[name="filelocationtype"]').trigger('change');
}
},
registerFileElementChangeEvent : function(container) {
var thisInstance = this;
container.on('change', 'input[name="filename"]', function(e){
vtUtils.hideValidationMessage(container.find('input[name="filename"]'));
if(e.target.type == "text") return false;
Documents_Edit_Js.file = e.target.files[0];
var element = container.find('[name="filename"]');
//ignore all other types than file
if(element.attr('type') != 'file'){
return ;
}
var uploadFileSizeHolder = element.closest('.fileUploadContainer').find('.uploadedFileSize');
var fileSize = e.target.files[0].size;
var fileName = e.target.files[0].name;
var maxFileSize = thisInstance.getMaxiumFileUploadingSize(container);
if(fileSize > maxFileSize) {
alert(app.vtranslate('JS_EXCEEDS_MAX_UPLOAD_SIZE'));
element.val('');
uploadFileSizeHolder.text('');
}else{
if(container.length > 1){
jQuery('div.fieldsContainer').find('form#I_form').find('input[name="filename"]').css('width','80px');
jQuery('div.fieldsContainer').find('form#W_form').find('input[name="filename"]').css('width','80px');
} else {
container.find('input[name="filename"]').css('width','80px');
}
uploadFileSizeHolder.text(fileName+' '+thisInstance.convertFileSizeInToDisplayFormat(fileSize));
}
});
},
/**
* Function to register event for ckeditor for description field
*/
registerEventForCkEditor : function(container){
var form = this.getForm();
if(typeof container != 'undefined'){
form = container;
}
var noteContentElement = form.find('[name="notecontent"]');
if(noteContentElement.length > 0){
noteContentElement.removeAttr('data-validation-engine').addClass('ckEditorSource');
var ckEditorInstance = new Vtiger_CkEditor_Js();
ckEditorInstance.loadCkEditor(noteContentElement);
}
},
quickCreatePreSave : function(form) {
var textAreaElement = form.find('textarea[name="notecontent"]');
if(textAreaElement.length){
var notecontent = CKEDITOR.instances.Documents_editView_fieldName_notecontent.getData();
textAreaElement.val(notecontent);
}
},
/**
* Function to save the quickcreate module
* @param accepts form element as parameter
* @return returns deferred promise
*/
quickCreateSave: function(forms) {
var thisInstance = this;
var aDeferred = jQuery.Deferred();
forms.each(function(index,domEle){
var form = jQuery(domEle);
var params = {};
params.submitHandler = function(domForm){
var form = jQuery(domForm);
thisInstance.quickCreatePreSave(form);
var contentsContainer = form;
//To handle tabs in quickcreate
if(form.find('div.active').length){
contentsContainer = form.find('div.active');
}
//Using formData object to send data to server as a multipart/form-data form submit
var formData = new FormData(form[0]);
var fileLocationTypeElement = form.find('[name="filelocationtype"]');
if(Documents_Edit_Js.file != false && thisInstance.isFileLocationInternalType(fileLocationTypeElement)){
formData.append("filename", Documents_Edit_Js.file);
if(!contentsContainer.find('input[name="notes_title"]').length){
formData.append('notes_title',Documents_Edit_Js.file.name);
}
delete Documents_Edit_Js.file;
} else{
if(!contentsContainer.find('input[name="notes_title"]').length){
var filename = contentsContainer.find('input[name="filename"]').val();
formData.append('notes_title',filename);
}
}
// to Prevent submit if already submitted
if(this.numberOfInvalids() > 0) {
return false;
}
var e = jQuery.Event(Vtiger_Edit_Js.recordPresaveEvent);
app.event.trigger(e);
if(e.isDefaultPrevented()) {
return false;
}
contentsContainer.find("button[name='saveButton']").attr("disabled",true);
if(formData){
var params = {
url: "index.php",
type: "POST",
data: formData,
processData: false,
contentType: false
};
app.request.post(params).then(function(err,data){
app.event.trigger("post.QuickCreateForm.save",data);
if(err === null){
app.helper.hideModal();
aDeferred.resolve(data);
}
});
}
return false;
}
form.vtValidate(params);
});
return aDeferred.promise();
},
documentsQuickCreateConfig : function(container){
var form = this.getForm();
if(form.attr('id') != 'EditView' && container.attr('id') != 'overlayPageContent'){
var externalDocContentsElement = container.find('#EQuickCreateContent');
var fileNameElement = externalDocContentsElement.find('[name="filename"]');
var newFileNameElement = jQuery('<input type="text" data-rule-url="true" data-rule-required="true"/>');
var oldElementAttributeList = fileNameElement.get(0).attributes;
for(var index=0; index<oldElementAttributeList.length; index++) {
var attributeObject = oldElementAttributeList[index];
//Dont update the type attribute
if(attributeObject.name=='type' || attributeObject.name == 'value' || attributeObject.name == 'style'){
continue;
}
var value = attributeObject.value
if(attributeObject.name=='data-fieldinfo') {
value = JSON.parse(value);
value['type'] = 'url';
value['mandatory'] = true;
value = JSON.stringify(value);
}
newFileNameElement.attr(attributeObject.name, value);
}
externalDocContentsElement.find('.fileUploadContainer').replaceWith(newFileNameElement);
var fileNameElementTd = newFileNameElement.closest('td');
fileNameElementTd.prev('td.fieldLabel').empty().append('<label class="muted pull-right"><span class="redColor">*</span>'+app.vtranslate('JS_EXTERNAL_FILE_URL')+'</label>');
var uploadFileDetails = fileNameElementTd.find('.uploadedFileDetails');
uploadFileDetails.addClass('hide').removeClass('show');
var webDocContentsElement = container.find('#WQuickCreateContent');
app.helper.showVerticalScroll(webDocContentsElement, {
'setHeight': '450px'
});
}
},
handleDragDropEvents : function(container){
var thisInstance = this;
var dragDropElement = container.find("#dragandrophandler");
dragDropElement.on('dragenter', function (e) {
e.stopPropagation();
e.preventDefault();
jQuery(this).removeClass('dragdrop-dotted');
jQuery(this).addClass('dragdrop-solid');
});
dragDropElement.on('dragover', function (e) {
e.stopPropagation();
e.preventDefault();
});
jQuery(document).on('dragenter', function (e) {
e.stopPropagation();
e.preventDefault();
});
jQuery(document).on('dragover', function (e) {
e.stopPropagation();
e.preventDefault();
dragDropElement.removeClass('dragdrop-solid');
dragDropElement.addClass('dragdrop-dotted');
});
jQuery(document).on('drop', function (e) {
e.stopPropagation();
e.preventDefault();
});
dragDropElement.on('drop', function (e) {
e.preventDefault();
jQuery(this).removeClass('dragdrop-solid');
jQuery(this).addClass('dragdrop-dotted');
var fileObj = e.originalEvent.dataTransfer.files;
Documents_Edit_Js.file = fileObj[0];
var element = container.find('input[name="filename"]');
element.val(null);
var uploadFileSizeHolder = element.closest('.fileUploadContainer').find('.uploadedFileSize');
var fileSize = Documents_Edit_Js.file.size;
var fileName = Documents_Edit_Js.file.name;
var maxFileSize = thisInstance.getMaxiumFileUploadingSize(container);
if(fileSize > maxFileSize) {
alert(app.vtranslate('JS_EXCEEDS_MAX_UPLOAD_SIZE'));
element.val('');
uploadFileSizeHolder.text('');
}else{
//hide the no file chosen msg for internal and webdoc types
if(container.length > 1){
jQuery('div.fieldsContainer').find('form#I_form').find('input[name="filename"]').css('width','80px');
jQuery('div.fieldsContainer').find('form#W_form').find('input[name="filename"]').css('width','80px');
}
else{
container.find('input[name="filename"]').css('width','80px');
}
uploadFileSizeHolder.text(fileName+' '+thisInstance.convertFileSizeInToDisplayFormat(fileSize));
}
});
},
registerCustomValidationForFileElement : function(container) {
var thisInstance = this;
app.event.on(Vtiger_Edit_Js.recordPresaveEvent, function(e, data) {
var form = container;
if(container.length > 1)
form = jQuery('div.fieldsContainer').find('div.active').find('form');
// file is required only for internal document type
if(Documents_Edit_Js.file == false && (form.attr('id') == 'I_form' || form.data('type') == 'I')){
var msg = app.vtranslate('JS_PLEASE_SELECT_A_FILE');
var params = {};
params.position = {
my: 'bottom left',
at: 'top left',
container:form
};
vtUtils.showValidationMessage(form.find('input[name="filename"]'),msg,params);
e.preventDefault();
}else{
vtUtils.hideValidationMessage(form.find('input[name="filename"]'));
}
thisInstance.quickCreatePreSave(form);
});
},
registerBasicEvents : function(container) {
this._super(container);
this.registerFileLocationTypeChangeEvent(container);
this.registerFileElementChangeEvent(container);
this.registerEventForCkEditor(container);
this.documentsQuickCreateConfig(container);
this.handleDragDropEvents(container);
this.registerCustomValidationForFileElement(container);
},
});