1/* 2 javascript functions for wp-monalisa edit form 3*/ 4 5 6/* 7 diese funktion haengt die smilies an den vorhandenen im editor text an 8 9*/ 10function smile2edit(textid,smile,replace) 11{ 12 var itext; 13 var tedit = null; 14 15 // einzufügenden text ermitteln 16 if ( replace == 1) 17 itext = "<img class='wpml_ico' alt='' src='" + smile + "' />"; 18 else 19 itext = " " + smile + " "; // add space to separate smilies 20 21 // editor objekt holen, falls vorhanden 22 if ( typeof tinyMCE != "undefined" ) 23 tedit = tinyMCE.get('content'); 24 25 if ( tedit == null || tedit.isHidden() == true) 26 { 27 // text in html editor einfügen 28 tarea = document.getElementById(textid); 29 insert_text(itext, tarea); 30 } else if ( (tedit.isHidden() == false) && window.tinyMCE) 31 { 32 // füge den text in den tinymce ein 33 var tmce_ver=window.tinyMCE.majorVersion; 34 if (tmce_ver=="4") { 35 window.tinyMCE.execCommand('mceInsertContent', false, itext); 36 } else { 37 window.tinyMCE.execInstanceCommand('content', 'mceInsertContent', false, itext); 38 } 39 } 40} 41 42 43/* 44 diese funktion fügt den text stxt an der aktuellen position des cursors 45 der textarea obj ein. obj ist als objekt zu übergeben 46 47*/ 48function smile2comment(textid,smile,replace,myid){ 49 //tarea = document.getElementById(textid); 50 var tedit = null; 51 52 tarea = jQuery('#'+myid).parent().find('textarea')[0]; 53 if (tarea == null) 54 { 55 tarea = jQuery('#'+myid).parent().parent().find('textarea')[0]; 56 } 57 if (tarea == null) 58 { 59 tarea = jQuery('#'+myid).parent().parent().parent().find('textarea')[0]; 60 } 61 // for jetpack support #FIXME 62 if (tarea == null) 63 { 64 tarea = jQuery('jetpack_remote_comment').contents().find('textarea')[1]; 65 } 66 // if tables are active search for the table tag first 67 if (tarea == null) 68 { 69 tarea = jQuery('#'+myid).parents('table').parent().parent().parent().find('textarea')[0]; 70 } 71 if (tarea == null) { 72 tarea = jQuery('#'+textid)[0]; 73 } 74 75 // maybe we are using TinyMCE 76 // editor objekt holen, falls vorhanden 77 if ( typeof tinyMCE != "undefined" ) { 78 teid=tinyMCE.activeEditor.editorId; 79 // this is for bbPress with tinyMCE 4 80 if (typeof teid == "undefined") 81 teid=tinyMCE.activeEditor.id; 82 tedit = tinyMCE.get(teid); 83 } 84 85 if (tarea == null && tedit == null) { 86 alert('wp-monalisa: Textarea not found. Please contact the webmaster of this site.'); 87 return; 88 } 89 90 // calculate text to insert 91 var itext=""; 92 if ( replace == 1) 93 itext="<img class='wpml_ico' alt='" + smile + "' src='" + smile + "' />"; 94 else 95 itext=" " + smile + " "; // add space to separate smilies 96 97 98 // insert text into editor and or textarea 99 if ( tarea != null) { 100 insert_text(itext, tarea); 101 } 102 103 if ( tedit != null && tedit.isHidden() == false) 104 { 105 var tmce_ver=window.tinyMCE.majorVersion; 106 107 if (tmce_ver=="4") { 108 window.tinyMCE.execCommand('mceInsertContent', false, itext); 109 } else { 110 window.tinyMCE.execInstanceCommand(teid, 'mceInsertContent', false, itext); 111 } 112 } 113} 114 115/* 116 diese funktion fügt den text stxt an der aktuellen stelle des cursors 117 der textarea obj ein. obj ist als objekt zu übergeben 118*/ 119function insert_text(stxt,obj) 120{ 121 try { 122 // pruefe of fckeditor aktiv ist entweder 123 // als comment editor oder als text editor 124 if(typeof window.CKEDITOR.instances.comment!='undefined') 125 { 126 // wenn ja, nutzen wir die fckeditor funktion 127 // um den text einzufügen 128 window.CKEDITOR.instances.comment.insertHtml(stxt); 129 return; 130 } 131 132 if(typeof CKEDITOR.instances.content!='undefined') 133 { 134 // wenn ja, nutzen wir die fckeditor funktion 135 // um den text einzufügen 136 CKEDITOR.instances.content.insertHtml(stxt); 137 return; 138 } 139 } 140 catch(e) {} 141 142 if(document.selection) 143 { 144 obj.focus(); 145 document.selection.createRange().text=stxt; 146 document.selection.createRange().select(); 147 } 148 else if (obj.selectionStart || obj.selectionStart == '0') 149 { 150 intStart = obj.selectionStart; 151 intEnd = obj.selectionEnd; 152 obj.value = (obj.value).substring(0, intStart) + stxt + (obj.value).substring(intEnd, obj.value.length); 153 obj.selectionStart = obj.selectionEnd = intStart + stxt.length; 154 obj.focus(); 155 } 156 else 157 { 158 obj.value += stxt; 159 } 160 161 162} 163 164/* 165 diese funktion(en) dient zum auf und zuklappen der gesamten smilies 166 im comment form und zwar ajax-like 167*/ 168/* does not work with bwp minify 169jQuery(function() { 170 // show all smilies 171 jQuery("#buttonm").click(function() { 172 jQuery("#smiley1").toggle("slow"); 173 jQuery("#smiley2").toggle("slow"); 174 }); 175 // hide all smilies 176 jQuery("#buttonl").click(function() { 177 jQuery("#smiley2").toggle("slow"); 178 jQuery("#smiley1").toggle("slow"); 179 }); 180 }); 181*/ 182// globale javascript variable um zu kontrollieren, dass jedes bild nur einmal geladen wird 183var wpml_first_preload=true; 184// globales array für die smileyliste 185var wpml_imglist = new Array(); 186// globales array für die html strings 187var wpml_more_html = new Array(); 188 189// startet das vorladen der smilies an, nach 2000ms 190jQuery(document).load( setTimeout( function() {wpml_preload();}, 2000)); 191 192// 193// diese funktion lädt die bilder im hintergrund genau einmal 194// die bilder urls stehen im array wpml_imglist 195// 196function wpml_preload() { 197 if (wpml_first_preload) { 198 var i=0; 199 for (i = 0; i < wpml_imglist.length; i++) { 200 var wpml_image = new Image(); 201 wpml_image.src = wpml_imglist[i]; 202 } 203 wpml_first_preload=false; 204 } 205} 206 207// 208// diese funktion fügt das vorbereitete html in das div ein 209// das html steht im array wpml_more_html 210//
211function wpml_more_smilies(muid) { 212 if (jQuery('#smiley2-'+muid).html() == ' ' ) { 213 jQuery('#smiley2-'+muid).html(unescape(wpml_more_html[muid])); 214 } 215} 216 217function wpml_toggle_smilies(uid) { 218 jQuery("#smiley1-"+uid).toggle("slow"); 219 jQuery("#smiley2-"+uid).toggle("slow"); 220} 221 222//calls wpml_edit with a post call and the id of the post to disable comment smilies on 223//puts the returned string into the element with id message 224function wpml_comment_exclude(postid) { 225 jQuery("#wpml_messages").html(''); 226 // ajax call to itself 227 jQuery.post("../wp-content/plugins/wp-monalisa/wpml_edit.php", {postid: postid}, 228 function(data){jQuery("#wpml_messages").html(data);}); 229 230 return false; 231}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.