📄 email.js
字号:
} tiny.setHTML(currValTiny); } // Remove this row from the list this.parentNode.parentNode.removeChild( this.parentNode ); // Decrement counter this.parentNode.element.multi_selector.count--; // Re-enable input element (if it's disabled) this.parentNode.element.multi_selector.current_element.disabled = false; // Appease Safari // without it Safari wants to reload the browser window // which nixes your already queued uploads return false; }; new_row_button_embed.onclick= function(){ var filename = element.value.replace(/\\/g,'/') var text = filename.split("/"); nbr_elements = text.length; //check if the file name has a space text[nbr_elements-1]=text[nbr_elements-1].replace(/ /g,' '); if(text[nbr_elements-1].indexOf('gif')>=0 || text[nbr_elements-1].indexOf('bmp') >= 0 || text[nbr_elements-1].indexOf('png') >= 0 || text[nbr_elements-1].indexOf('jpg') >= 0 || text[nbr_elements-1].indexOf('GIF')>=0 || text[nbr_elements-1].indexOf('BMP') >= 0 || text[nbr_elements-1].indexOf('PNG') >= 0 || text[nbr_elements-1].indexOf('JPG') >= 0) { cid='cid:'+text[nbr_elements-1]; var imglocation = unescape(document.location.pathname.substr(1)); imglocation = imglocation.substring(0,imglocation.lastIndexOf('/')+1); imglocation='/'+imglocation+'cache/images/'; embedImage="<img src="+imglocation+unescape(text[nbr_elements-1])+'>'; //var tiny = tinyMCE.getInstanceById('body_text'); embedImage = embedImage; embedImage1="<img src=cid:"+text[nbr_elements-1]+' width="1" height="1" >'; //insert_variable(embedImage1); insert_variable(embedImage); this.parentNode.childNodes[2].checked='true'; } else{ alert(select_image); } }; // Set row value /* var oas = new ActiveXObject("Scripting.FileSystemObject"); var d = document.a.b.value; var e = oas.getFile(d); var f = e.size; alert(f + " bytes"); alert(element); */ //new_row_file_name.value =element.value; new_row_file_name_tab = element.value.split("\\"); //alert(new_row_file_name_tab); nbr_elements = new_row_file_name_tab.length; new_row_file_name.value = new_row_file_name_tab[nbr_elements-1]; //new_row.innerHTML = element.value; //add all the elements //new_row.appendChild(new_row_attach_file); new_row.appendChild(imgElement); new_row.appendChild(new_row_button_embed); new_row.appendChild(new_row_chk_box); new_row.appendChild( new_row_file_name); // Add button new_row.appendChild( new_row_button_remove); // Add it to the list this.list_target.appendChild( new_row ); //document.getElementById(list_target).appendChild(new_row); };};function docUpload() { //var theForm = document.getElementById('EditView'); //var theForm = document.getElementById('upload_form'); //AJAX call begins var rets =''; var callback = { upload:function(r) { //console.log("response object: %o", r); rets = JSON.parse(r.responseText); } } var url ='index.php?module=EmailTemplates&action=AttachDocuments'; //YAHOO.util.Connect.setForm(document.getElementById("upload_form"), true,true); YAHOO.util.Connect.asyncRequest('POST', url, callback,null); //AJAX call ends var element = document.getElementById('documentName'); //alert(element.value); var element1 = document.getElementById('documentId'); var element2 = document.getElementById('docRevId'); var element3 = document.getElementById('documentType'); var elm = document.createElement('div'); elm.setAttribute('id','file'+uploadIndex); var sugarDoc = document.createElement('input'); sugarDoc.setAttribute('type', 'label'); sugarDoc.setAttribute('disabled', 'true'); sugarDoc.setAttribute('font', 'bold'); sugarDoc.setAttribute('value',"Sugar Document"); var new_row_button_embed_doc = document.createElement( 'input' ); new_row_button_embed_doc.type = 'button'; new_row_button_embed_doc.value = 'Embed'; var new_row_chk_box = document.createElement( 'input' ); new_row_chk_box.setAttribute('id','checkBoxDoc'+uploadIndex); new_row_chk_box.setAttribute('name','checkBoxDoc'+uploadIndex); new_row_chk_box.type = 'checkbox'; new_row_chk_box.checked =false; new_row_chk_box.disabled='true'; var eah = document.createElement('input'); eah.setAttribute('id', 'documentId'+uploadIndex); eah.setAttribute('name', 'documentId'+uploadIndex); eah.setAttribute('tabindex', '120'); eah.setAttribute('type', 'hidden'); eah.setAttribute('value',element1.value); var attId = document.createElement('input'); attId.setAttribute('id', 'docRevId'+uploadIndex); attId.setAttribute('name', 'docRevId'+uploadIndex); attId.setAttribute('tabindex', '120'); attId.setAttribute('type', 'hidden'); attId.setAttribute('value',element2.value); var attType = document.createElement('input'); attType.setAttribute('id', 'documentType'+uploadIndex); attType.setAttribute('name', 'documentType'+uploadIndex); attType.setAttribute('tabindex', '120'); attType.setAttribute('type', 'hidden'); attType.setAttribute('value',element3.value); var ea = document.createElement('input'); ea.setAttribute('id', 'document[]'); ea.setAttribute('name', 'document[]'); ea.setAttribute('tabindex', '120'); ea.setAttribute('size', '40'); ea.setAttribute('type', 'text'); ea.setAttribute('disabled',true); ea.setAttribute('value',element.value); var eai = document.createElement('input'); eai.setAttribute('type', 'button'); //eai.setAttribute('onclick', 'deleteFile('+uploadIndex+');'); eai.setAttribute('value', lbl_remove); eai.onclick=function(){ var filename = this.parentNode.childNodes[4].value; if(filename != null){ var tiny = tinyMCE.getInstanceById('body_text'); var currValTiny = tinyMCE.getContent('body_text'); while(currValTiny.indexOf(unescape(filename)) != -1){ currValTiny = currValTiny.replace(unescape(filename),'QW%%^%%WQ'); currValTiny = currValTiny.replace(/<img[^<]*QW%%\^%%WQ[^>]*>?/,' '); } tiny.setHTML(currValTiny); } this.parentNode.parentNode.removeChild(this.parentNode); } var new_row_button_embed = document.createElement("img"); new_row_button_embed.setAttribute("src", "themes/default/images/attachment.gif"); new_row_button_embed.setAttribute("align","absmiddle"); new_row_button_embed.setAttribute("alt","Embed"); new_row_button_embed.setAttribute("border","0"); new_row_button_embed.setAttribute("height","16"); new_row_button_embed.setAttribute("width","16"); new_row_button_embed.onclick= function(){ //retrieve the documentid this.parentNode.childNodes[2].checked='true'; var documentRevisionId = this.parentNode.childNodes[4].value; var mime_type = this.parentNode.childNodes[5].value; if(mime_type == "image/gif" || mime_type == "image/bmp" || mime_type == "image/png" || mime_type == "image/jpg") { var imglocation = unescape(document.location.pathname.substr(1)); imglocation = imglocation.substring(0,imglocation.lastIndexOf('/')+1); imglocation='/'+imglocation+'cache/upload/'; embedImage='<img src='+imglocation+documentRevisionId+'>'; // var tiny = tinyMCE.getInstanceById('body_text'); embedImage1='<img src=cid:'+documentRevisionId+' width="1" height="1" >'; //insert_variable(embedImage1); insert_variable(embedImage); } else{ new_row_chk_box.checked =false; alert(select_image); } }; var SugarDoc = document.createElement("img"); SugarDoc.setAttribute("src", "themes/default/images/sugar_document.png"); SugarDoc.setAttribute("align","absmiddle"); SugarDoc.setAttribute("alt","Embed"); SugarDoc.setAttribute("border","0"); SugarDoc.setAttribute("height","16"); SugarDoc.setAttribute("width","16"); //elm.appendChild(eah); elm.appendChild(SugarDoc); elm.appendChild(new_row_button_embed); elm.appendChild(new_row_chk_box); elm.appendChild(eah); elm.appendChild(attId); elm.appendChild(attType); elm.appendChild(ea); elm.appendChild(eai); elm.style.display = 'block'; var rN= document.getElementById('attachments_div'); rN.appendChild(elm); uploadIndex++;}function addUploadFiles(form_name) { var chForm = document.getElementById('upload_div'); var theForm = document.getElementById(form_name); var elems = chForm.getElementsByTagName("input"); //get the count of all the email_attachment file elements var count = 0; //Use the count to add the documents count=this.multi_selector.id; for (var i=0; i<count-1; i++) { // find out all the email_attachments and append to the EditView form var el = document.getElementsByName('email_attachment'+i); if(el[0] != null){ theForm.appendChild(el[0]); } } var chForm = document.getElementById("upload_form"); var elems = chForm.getElementsByTagName("input"); var num = 0; for (var i=0; i<elems.length; i++) { //find out all the email_attachments and append to the EditView form var el = elems[i]; //var el = document.getElementsByName('checkBoxFile[]'); if(el.id == 'checkBoxFile[]'){ var eah = document.createElement('input'); eah.setAttribute('id', 'embedded'+num); eah.setAttribute('name', 'embedded'+num); eah.setAttribute('tabindex', '120'); eah.setAttribute('type', 'hidden'); eah.setAttribute('value',el.checked); num++; theForm.appendChild(eah); } } }function addUploadDocs(form_name) { var chForm = document.getElementById("upload_form"); var theForm = document.getElementById(form_name); var attDiv = document.getElementById("attachments_div"); var elems = chForm.getElementsByTagName("input"); var elems1 = attDiv.getElementsByTagName("input"); for (var i=0; i<elems1.length; i++) { //if (elems[i].type == "file") { var el = elems1[i]; if(el.id=='document[]') { theForm.appendChild(el); } } for (var i=0; i<elems.length; i++) { //if (elems[i].type == "file") { var el = elems[i]; if(el.id=='document[]') { theForm.appendChild(el); } if(el.id.indexOf('documentId')>=0 || el.id=='document[]') { theForm.appendChild(el); } } }function form_reset_doc() { // var theForm = document.getElementById('upload_form'); var theForm = document.getElementById('upload_div'); var elems = theForm.getElementsByTagName("input"); for (var i=0; i<elems.length; i++) { if (elems[i].type == "text" || "hidden" ) { var el = elems[i]; if(el.id == 'documentName') { var new_el =document.createElement('input'); new_el.type = 'hidden'; new_el.name = el.name; new_el.id = el.id; new_el.onchange = el.onchange; //new_el.disabled=true; //new_el.style.visibility="hidden"; new_el.siz=true; el.parentNode.replaceChild(new_el, el); // el.parentNode.insertBefore(new_el, el); // el.parentNode.removeChild(el); } if(el.id == 'documentId') { var new_el =document.createElement('input'); new_el.type = 'hidden'; new_el.name = el.name; new_el.id = el.id; //new_el.onchange = el.onchange; //new_el.DISABLED='true'; el.parentNode.replaceChild(new_el, el); // el.parentNode.insertBefore(new_el, el); // el.parentNode.removeChild(el); } } }}function selectDoc() { URL="index.php?module=EmailTemplates&action=PopupDocumentsCampaignTemplate&to_pdf=true&target=" ; windowName = 'selectDocument'; windowFeatures = 'width=800' + ',height=600' + ',resizable=1,scrollbars=1'; win = window.open(URL, windowName, windowFeatures); if(window.focus) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -