Ticket #4262: 4262.diff
File 4262.diff, 220.3 KB (added by , 17 years ago) |
---|
-
wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
1 1 /** 2 * $Id: editor_plugin_src.js 2 01 2007-02-12 15:56:56Z spocke $2 * $Id: editor_plugin_src.js 268 2007-04-28 15:52:59Z spocke $ 3 3 * 4 4 * Moxiecode DHTML Windows script. 5 5 * … … 82 82 // Center div in editor area 83 83 pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2)); 84 84 pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2)); 85 86 // WordPress cache buster 87 url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; 85 88 86 url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; // WordPress cache buster87 88 89 mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight ); 89 90 }; 90 91 91 92 TinyMCE_Engine.prototype.closeWindow = function(win) { 92 93 var gotit = false, n, w; 94 93 95 for (n in mcWindows.windows) { 94 96 w = mcWindows.windows[n]; 95 if (typeof(w) == 'function') continue; 97 98 if (typeof(w) == 'function') 99 continue; 100 96 101 if (win.name == w.id + '_iframe') { 97 102 w.close(); 98 103 gotit = true; 99 104 } 100 105 } 106 101 107 if (!gotit) 102 108 this.orgCloseWindow(win); 103 109 … … 392 398 html += '<html>'; 393 399 html += '<head>'; 394 400 html += '<title>Wrapper iframe</title>'; 401 402 // WordPress: put the window buttons on the left as in Macs 395 403 if (this.isMac) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;width:100%;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>'; 404 396 405 html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'; 397 406 html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />'; 398 407 html += '</head>'; -
wp-includes/js/tinymce/tiny_mce.js
5 5 var ua; 6 6 7 7 this.majorVersion = "2"; 8 this.minorVersion = "1. 0";9 this.releaseDate = "2007-0 2-13";8 this.minorVersion = "1.1.1"; 9 this.releaseDate = "2007-05-14"; 10 10 11 this.instances = new Array();12 this.switchClassCache = new Array();13 this.windowArgs = new Array();14 this.loadedFiles = new Array();15 this.pendingFiles = new Array();11 this.instances = []; 12 this.switchClassCache = []; 13 this.windowArgs = []; 14 this.loadedFiles = []; 15 this.pendingFiles = []; 16 16 this.loadingIndex = 0; 17 this.configs = new Array();17 this.configs = []; 18 18 this.currentConfig = 0; 19 this.eventHandlers = new Array();20 this.log = new Array();19 this.eventHandlers = []; 20 this.log = []; 21 21 this.undoLevels = []; 22 22 this.undoIndex = 0; 23 23 this.typingUndoIndex = -1; 24 this.settings = []; 24 25 25 26 // Browser check 26 27 ua = navigator.userAgent; … … 28 29 this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); 29 30 this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); 30 31 this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1); 31 this.isGecko = ua.indexOf('Gecko') != -1; 32 this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari 32 33 this.isSafari = ua.indexOf('Safari') != -1; 33 this.isOpera = ua.indexOf('Opera') != -1;34 this.isOpera = window['opera'] && opera.buildNumber ? true : false; 34 35 this.isMac = ua.indexOf('Mac') != -1; 35 36 this.isNS7 = ua.indexOf('Netscape/7') != -1; 36 37 this.isNS71 = ua.indexOf('Netscape/7.1') != -1; 37 38 this.dialogCounter = 0; 38 this.plugins = new Array();39 this.themes = new Array();40 this.menus = new Array();41 this.loadedPlugins = new Array();42 this.buttonMap = new Array();39 this.plugins = []; 40 this.themes = []; 41 this.menus = []; 42 this.loadedPlugins = []; 43 this.buttonMap = []; 43 44 this.isLoaded = false; 44 45 45 46 // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those … … 58 59 59 60 TinyMCE_Engine.prototype = { 60 61 init : function(settings) { 61 var theme, nl, baseHREF = "", i ;62 var theme, nl, baseHREF = "", i, cssPath, entities, h, p, src, elements = [], head; 62 63 63 64 // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry. 64 65 if (this.isMSIE5_0) … … 72 73 73 74 // Get script base path 74 75 if (!tinyMCE.baseURL) { 75 var elements = document.getElementsByTagName('script'); 76 // Search through head 77 head = document.getElementsByTagName('head')[0]; 76 78 79 if (head) { 80 for (i=0, nl = head.getElementsByTagName('script'); i<nl.length; i++) 81 elements.push(nl[i]); 82 } 83 84 // Search through rest of document 85 for (i=0, nl = document.getElementsByTagName('script'); i<nl.length; i++) 86 elements.push(nl[i]); 87 77 88 // If base element found, add that infront of baseURL 78 89 nl = document.getElementsByTagName('base'); 79 90 for (i=0; i<nl.length; i++) { … … 81 92 baseHREF = nl[i].href; 82 93 } 83 94 84 for ( vari=0; i<elements.length; i++) {95 for (i=0; i<elements.length; i++) { 85 96 if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_dev.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) { 86 varsrc = elements[i].src;97 src = elements[i].src; 87 98 88 99 tinyMCE.srcMode = (src.indexOf('_src') != -1 || src.indexOf('_dev') != -1) ? '_src' : ''; 89 100 tinyMCE.gzipMode = src.indexOf('_gzip') != -1; … … 93 104 tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : ''; 94 105 95 106 // Force it absolute if page has a base href 96 if (baseHREF != ""&& src.indexOf('://') == -1)107 if (baseHREF !== '' && src.indexOf('://') == -1) 97 108 tinyMCE.baseURL = baseHREF + src; 98 109 else 99 110 tinyMCE.baseURL = src; … … 121 132 this._def("theme", "advanced"); 122 133 this._def("plugins", "", true); 123 134 this._def("language", "en"); 124 this._def("docs_language", this.settings ['language']);135 this._def("docs_language", this.settings.language); 125 136 this._def("elements", ""); 126 137 this._def("textarea_trigger", "mce_editable"); 127 138 this._def("editor_selector", ""); … … 132 143 this._def("encoding", ""); 133 144 this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL")); 134 145 this._def("save_callback", ""); 135 this._def("debug", false);136 146 this._def("force_br_newlines", false); 137 147 this._def("force_p_newlines", true); 138 148 this._def("add_form_submit_trigger", true); … … 193 203 this._def("display_tab_class", ''); 194 204 this._def("gecko_spellcheck", false); 195 205 this._def("hide_selects_on_submit", true); 206 this._def("forced_root_block", false); 207 this._def("remove_trailing_nbsp", false); 196 208 197 209 // Force strict loading mode to false on non Gecko browsers 198 210 if (this.isMSIE && !this.isOpera) 199 211 this.settings.strict_loading_mode = false; 200 212 201 213 // Browser check IE 202 if (this.isMSIE && this.settings ['browsers'].indexOf('msie') == -1)214 if (this.isMSIE && this.settings.browsers.indexOf('msie') == -1) 203 215 return; 204 216 205 217 // Browser check Gecko 206 if (this.isGecko && this.settings ['browsers'].indexOf('gecko') == -1)218 if (this.isGecko && this.settings.browsers.indexOf('gecko') == -1) 207 219 return; 208 220 209 221 // Browser check Safari 210 if (this.isSafari && this.settings ['browsers'].indexOf('safari') == -1)222 if (this.isSafari && this.settings.browsers.indexOf('safari') == -1) 211 223 return; 212 224 213 225 // Browser check Opera 214 if (this.isOpera && this.settings ['browsers'].indexOf('opera') == -1)226 if (this.isOpera && this.settings.browsers.indexOf('opera') == -1) 215 227 return; 216 228 217 229 // If not super absolute make it so 218 baseHREF = tinyMCE.settings ['document_base_url'];219 varh = document.location.href;220 varp = h.indexOf('://');230 baseHREF = tinyMCE.settings.document_base_url; 231 h = document.location.href; 232 p = h.indexOf('://'); 221 233 if (p > 0 && document.location.protocol != "file:") { 222 234 p = h.indexOf('/', p + 3); 223 235 h = h.substring(0, p); … … 225 237 if (baseHREF.indexOf('://') == -1) 226 238 baseHREF = h + baseHREF; 227 239 228 tinyMCE.settings ['document_base_url']= baseHREF;229 tinyMCE.settings ['document_base_prefix']= h;240 tinyMCE.settings.document_base_url = baseHREF; 241 tinyMCE.settings.document_base_prefix = h; 230 242 } 231 243 232 244 // Trim away query part 233 245 if (baseHREF.indexOf('?') != -1) 234 246 baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); 235 247 236 this.settings ['base_href']= baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";248 this.settings.base_href = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; 237 249 238 theme = this.settings ['theme'];250 theme = this.settings.theme; 239 251 this.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment'; 240 252 this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment'; 241 this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD| BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';253 this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; 242 254 this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i"); 243 this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);255 this.posKeyCodes = [13,45,36,35,33,34,37,38,39,40]; 244 256 this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL 245 257 this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>'; 246 this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance');258 this.callbacks = ['onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance']; 247 259 248 260 // Theme url 249 this.settings ['theme_href']= tinyMCE.baseURL + "/themes/" + theme;261 this.settings.theme_href = tinyMCE.baseURL + "/themes/" + theme; 250 262 251 263 if (!tinyMCE.isIE || tinyMCE.isOpera) 252 this.settings ['force_br_newlines']= false;264 this.settings.force_br_newlines = false; 253 265 254 266 if (tinyMCE.getParam("popups_css", false)) { 255 varcssPath = tinyMCE.getParam("popups_css", "");267 cssPath = tinyMCE.getParam("popups_css", ""); 256 268 257 269 // Is relative 258 270 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') 259 this.settings ['popups_css']= this.documentBasePath + "/" + cssPath;271 this.settings.popups_css = this.documentBasePath + "/" + cssPath; 260 272 else 261 this.settings ['popups_css']= cssPath;273 this.settings.popups_css = cssPath; 262 274 } else 263 this.settings ['popups_css']= tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";275 this.settings.popups_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; 264 276 265 277 if (tinyMCE.getParam("editor_css", false)) { 266 varcssPath = tinyMCE.getParam("editor_css", "");278 cssPath = tinyMCE.getParam("editor_css", ""); 267 279 268 280 // Is relative 269 281 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') 270 this.settings ['editor_css']= this.documentBasePath + "/" + cssPath;282 this.settings.editor_css = this.documentBasePath + "/" + cssPath; 271 283 else 272 this.settings ['editor_css']= cssPath;284 this.settings.editor_css = cssPath; 273 285 } else { 274 if (this.settings.editor_css != '')275 this.settings ['editor_css']= tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";286 if (this.settings.editor_css !== '') 287 this.settings.editor_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; 276 288 } 277 289 278 if (tinyMCE.settings['debug']) {279 var msg = "Debug: \n";280 281 msg += "baseURL: " + this.baseURL + "\n";282 msg += "documentBasePath: " + this.documentBasePath + "\n";283 msg += "content_css: " + this.settings['content_css'] + "\n";284 msg += "popups_css: " + this.settings['popups_css'] + "\n";285 msg += "editor_css: " + this.settings['editor_css'] + "\n";286 287 alert(msg);288 }289 290 290 // Only do this once 291 291 if (this.configs.length == 0) { 292 292 if (typeof(TinyMCECompressed) == "undefined") { … … 304 304 } 305 305 } 306 306 307 this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings ['theme']+ '/editor_template' + tinyMCE.srcMode + '.js');308 this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings ['language']+ '.js');309 this.loadCSS(this.settings ['editor_css']);307 this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings.theme + '/editor_template' + tinyMCE.srcMode + '.js'); 308 this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings.language + '.js'); 309 this.loadCSS(this.settings.editor_css); 310 310 311 311 // Add plugins 312 varp = tinyMCE.getParam('plugins', '', true, ',');312 p = tinyMCE.getParam('plugins', '', true, ','); 313 313 if (p.length > 0) { 314 for ( vari=0; i<p.length; i++) {314 for (i=0; i<p.length; i++) { 315 315 if (p[i].charAt(0) != '-') 316 316 this.loadScript(tinyMCE.baseURL + '/plugins/' + p[i] + '/editor_plugin' + tinyMCE.srcMode + '.js'); 317 317 } … … 319 319 320 320 // Setup entities 321 321 if (tinyMCE.getParam('entity_encoding') == 'named') { 322 settings ['cleanup_entities'] = new Array();323 varentities = tinyMCE.getParam('entities', '', true, ',');324 for ( vari=0; i<entities.length; i+=2)325 settings ['cleanup_entities']['c' + entities[i]] = entities[i+1];322 settings.cleanup_entities = []; 323 entities = tinyMCE.getParam('entities', '', true, ','); 324 for (i=0; i<entities.length; i+=2) 325 settings.cleanup_entities['c' + entities[i]] = entities[i+1]; 326 326 } 327 327 328 328 // Save away this config 329 settings ['index']= this.configs.length;329 settings.index = this.configs.length; 330 330 this.configs[this.configs.length] = settings; 331 331 332 332 // Start loading first one in chain … … 337 337 try { 338 338 document.execCommand('BackgroundImageCache', false, true); 339 339 } catch (e) { 340 // Ignore 340 341 } 341 342 } 342 343 343 344 // Setup XML encoding regexps 344 this.xmlEncodeAposRe = new RegExp('[<>&"\']', 'g');345 345 this.xmlEncodeRe = new RegExp('[<>&"]', 'g'); 346 // this.xmlEncodeEnts = {'&':'&','"':'"',"'":''','<':'<','>':'>'};347 346 }, 348 347 349 348 _addUnloadEvents : function() { 349 var st = tinyMCE.settings.add_unload_trigger; 350 350 351 if (tinyMCE.isIE) { 351 if ( tinyMCE.settings['add_unload_trigger']) {352 if (st) { 352 353 tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler); 353 354 tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler); 354 355 } 355 356 } else { 356 if ( tinyMCE.settings['add_unload_trigger'])357 if (st) 357 358 tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); 358 359 } 359 360 }, … … 449 450 450 451 loadCSS : function(url) { 451 452 var ar = url.replace(/\s+/, '').split(','); 452 var lflen = 0, csslen = 0; 453 var skip = false; 453 var lflen = 0, csslen = 0, skip = false; 454 454 var x = 0, i = 0, nl, le; 455 455 456 456 for (x = 0,csslen = ar.length; x<csslen; x++) { … … 514 514 515 515 tinyMCE.settings = settings; 516 516 517 if (tinyMCE.settings ['convert_on_click'] || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])))517 if (tinyMCE.settings.convert_on_click || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang.lang_edit_confirm))) 518 518 tinyMCE.addMCEControl(elm, elementId); 519 519 520 520 elm.setAttribute('mce_noask', 'true'); 521 521 }, 522 522 523 523 updateContent : function(form_element_name) { 524 var formElement, n, inst, doc; 525 524 526 // Find MCE instance linked to given form element and copy it's value 525 var formElement = document.getElementById(form_element_name); 526 for (var n in tinyMCE.instances) { 527 var inst = tinyMCE.instances[n]; 527 formElement = document.getElementById(form_element_name); 528 for (n in tinyMCE.instances) { 529 inst = tinyMCE.instances[n]; 530 528 531 if (!tinyMCE.isInstance(inst)) 529 532 continue; 530 533 531 534 inst.switchSettings(); 532 535 533 536 if (inst.formElement == formElement) { 534 vardoc = inst.getDoc();535 537 doc = inst.getDoc(); 538 536 539 tinyMCE._setHTML(doc, inst.formElement.value); 537 540 538 541 if (!tinyMCE.isIE) … … 681 684 }, 682 685 683 686 execCommand : function(command, user_interface, value) { 684 var inst = tinyMCE.selectedInstance ;687 var inst = tinyMCE.selectedInstance, n, pe, te; 685 688 686 689 // Default input 687 690 user_interface = user_interface ? user_interface : false; … … 721 724 return true; 722 725 723 726 case 'mceFocus': 724 var inst = tinyMCE.getInstanceById(value); 727 inst = tinyMCE.getInstanceById(value); 728 725 729 if (inst) 726 730 inst.getWin().focus(); 727 731 return; … … 732 736 return; 733 737 734 738 case "mceAddFrameControl": 735 tinyMCE.addMCEControl(tinyMCE._getElementById(value ['element'], value['document']), value['element'], value['document']);739 tinyMCE.addMCEControl(tinyMCE._getElementById(value.element, value.document), value.element, value.document); 736 740 return; 737 741 738 742 case "mceRemoveControl": … … 741 745 return; 742 746 743 747 case "mceToggleEditor": 744 var inst = tinyMCE.getInstanceById(value), pe, te;748 inst = tinyMCE.getInstanceById(value); 745 749 746 750 if (inst) { 747 751 pe = document.getElementById(inst.editorId + '_parent'); … … 754 758 755 759 if (!inst.enabled) { 756 760 pe.style.display = 'none'; 757 te.value = inst.getHTML(); 761 762 if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') 763 te.value = inst.getHTML(); 764 else 765 te.innerHTML = inst.getHTML(); 766 758 767 te.style.display = inst.oldTargetDisplay; 759 768 tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); 760 769 } else { 761 770 pe.style.display = 'block'; 762 771 te.style.display = 'none'; 763 inst.setHTML(te.value); 772 773 if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') 774 inst.setHTML(te.value); 775 else 776 inst.setHTML(te.innerHTML); 777 764 778 inst.useCSS = false; 765 779 tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst); 766 780 } … … 771 785 772 786 case "mceResetDesignMode": 773 787 // Resets the designmode state of the editors in Gecko 774 if ( !tinyMCE.isIE) {775 for ( varn in tinyMCE.instances) {788 if (tinyMCE.isGecko) { 789 for (n in tinyMCE.instances) { 776 790 if (!tinyMCE.isInstance(tinyMCE.instances[n])) 777 791 continue; 778 792 779 793 try { 794 tinyMCE.instances[n].getDoc().designMode = "off"; 780 795 tinyMCE.instances[n].getDoc().designMode = "on"; 796 tinyMCE.instances[n].useCSS = false; 781 797 } catch (e) { 782 798 // Ignore any errors 783 799 } … … 789 805 790 806 if (inst) { 791 807 inst.execCommand(command, user_interface, value); 792 } else if (tinyMCE.settings ['focus_alert'])793 alert(tinyMCELang ['lang_focus_alert']);808 } else if (tinyMCE.settings.focus_alert) 809 alert(tinyMCELang.lang_focus_alert); 794 810 }, 795 811 796 812 _createIFrame : function(replace_element, doc, win) { … … 805 821 806 822 iframe = doc.createElement("iframe"); 807 823 808 aw = "" + tinyMCE.settings ['area_width'];809 ah = "" + tinyMCE.settings ['area_height'];824 aw = "" + tinyMCE.settings.area_width; 825 ah = "" + tinyMCE.settings.area_height; 810 826 811 827 if (aw.indexOf('%') == -1) { 812 828 aw = parseInt(aw); … … 834 850 iframe.setAttribute("allowtransparency", "true"); 835 851 iframe.className = 'mceEditorIframe'; 836 852 837 if (tinyMCE.settings ["auto_resize"])853 if (tinyMCE.settings.auto_resize) 838 854 iframe.setAttribute("scrolling", "no"); 839 855 840 856 // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs 841 857 if (tinyMCE.isRealIE) 842 iframe.setAttribute("src", this.settings ['default_document']);858 iframe.setAttribute("src", this.settings.default_document); 843 859 844 860 iframe.style.width = aw; 845 861 iframe.style.height = ah; … … 861 877 }, 862 878 863 879 setupContent : function(editor_id) { 864 var inst = tinyMCE.instances[editor_id], i; 865 var doc = inst.getDoc(); 866 var head = doc.getElementsByTagName('head').item(0); 867 var content = inst.startContent; 880 var inst = tinyMCE.instances[editor_id], i, doc = inst.getDoc(), head = doc.getElementsByTagName('head').item(0); 881 var content = inst.startContent, contentElement, body; 868 882 869 883 // HTML values get XML encoded in strict mode 870 884 if (tinyMCE.settings.strict_loading_mode) { … … 886 900 return; 887 901 } 888 902 889 if (!head) { 903 // Wait for it to load 904 if (!head || !doc.body) { 890 905 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10); 891 906 return; 892 907 } 893 908 894 909 // Import theme specific content CSS the user specific 895 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings ['theme']+ "/css/editor_content.css");896 tinyMCE.importCSS(inst.getDoc(), inst.settings ['content_css']);910 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings.theme + "/css/editor_content.css"); 911 tinyMCE.importCSS(inst.getDoc(), inst.settings.content_css); 897 912 tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst); 898 913 899 914 // Setup keyboard shortcuts … … 921 936 if (tinyMCE.getParam("convert_fonts_to_spans")) 922 937 inst.getBody().setAttribute('id', 'mceSpanFonts'); 923 938 924 if (tinyMCE.settings ['nowrap'])939 if (tinyMCE.settings.nowrap) 925 940 doc.body.style.whiteSpace = "nowrap"; 926 941 927 doc.body.dir = this.settings ['directionality'];942 doc.body.dir = this.settings.directionality; 928 943 doc.editorId = editor_id; 929 944 930 945 // Add on document element in Mozilla 931 946 if (!tinyMCE.isIE) 932 947 doc.documentElement.editorId = editor_id; 933 948 934 inst.setBaseHREF(tinyMCE.settings ['base_href']);949 inst.setBaseHREF(tinyMCE.settings.base_href); 935 950 936 951 // Replace new line characters to BRs 937 if (tinyMCE.settings ['convert_newlines_to_brs']) {952 if (tinyMCE.settings.convert_newlines_to_brs) { 938 953 content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi"); 939 954 content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi"); 940 955 content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi"); … … 951 966 // Ugly!!! 952 967 window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500); 953 968 954 if (tinyMCE.settings ["force_br_newlines"])969 if (tinyMCE.settings.force_br_newlines) 955 970 doc.styleSheets[0].addRule("p", "margin: 0;"); 956 971 957 varbody = inst.getBody();972 body = inst.getBody(); 958 973 body.editorId = editor_id; 959 974 } 960 975 … … 962 977 963 978 // Fix for bug #958637 964 979 if (!tinyMCE.isIE) { 965 varcontentElement = inst.getDoc().createElement("body");966 vardoc = inst.getDoc();980 contentElement = inst.getDoc().createElement("body"); 981 doc = inst.getDoc(); 967 982 968 983 contentElement.innerHTML = content; 969 984 970 // Remove weridness! 971 if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) 972 content = content.replace(new RegExp('<>', 'g'), ""); 973 974 if (tinyMCE.settings['cleanup_on_startup']) 985 if (tinyMCE.settings.cleanup_on_startup) 975 986 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); 976 987 else 977 988 tinyMCE.setInnerHTML(inst.getBody(), content); 978 989 979 990 tinyMCE.convertAllRelativeURLs(inst.getBody()); 980 991 } else { 981 if (tinyMCE.settings ['cleanup_on_startup']) {992 if (tinyMCE.settings.cleanup_on_startup) { 982 993 tinyMCE._setHTML(inst.getDoc(), content); 983 994 984 995 // Produces permission denied error in MSIE 5.5 985 eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}'); 996 try { 997 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody())); 998 } catch(e) { 999 // Ignore 1000 } 986 1001 } else 987 1002 tinyMCE._setHTML(inst.getDoc(), content); 988 1003 } … … 990 1005 // Fix for bug #957681 991 1006 //inst.getDoc().designMode = inst.getDoc().designMode; 992 1007 993 tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings ['visual'], inst);1008 tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings.visual, inst); 994 1009 tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); 995 1010 996 1011 // Re-add design mode on mozilla … … 1106 1121 }, 1107 1122 1108 1123 handleEvent : function(e) { 1109 var inst = tinyMCE.selectedInstance ;1124 var inst = tinyMCE.selectedInstance, i, elm, keys; 1110 1125 1111 1126 // Remove odd, error 1112 1127 if (typeof(tinyMCE) == "undefined") … … 1149 1164 } 1150 1165 } 1151 1166 1152 window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings ['base_href']);tinyMCE._resetIframeHeight();", 1);1167 window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings.base_href);tinyMCE._resetIframeHeight();", 1); 1153 1168 return; 1154 1169 1155 1170 case "submit": 1156 tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target); 1157 tinyMCE.triggerSave(); 1158 tinyMCE.isNotDirty = true; 1171 tinyMCE.formSubmit(tinyMCE.isMSIE ? window.event.srcElement : e.target); 1159 1172 return; 1160 1173 1161 1174 case "reset": 1162 1175 var formObj = tinyMCE.isIE ? window.event.srcElement : e.target; 1163 1176 1164 for ( vari=0; i<document.forms.length; i++) {1177 for (i=0; i<document.forms.length; i++) { 1165 1178 if (document.forms[i] == formObj) 1166 1179 window.setTimeout('tinyMCE.resetForm(' + i + ');', 10); 1167 1180 } … … 1183 1196 tinyMCE.selectedInstance.switchSettings(); 1184 1197 1185 1198 // Insert P element 1186 if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings ['force_p_newlines']&& e.keyCode == 13 && !e.shiftKey) {1199 if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings.force_p_newlines && e.keyCode == 13 && !e.shiftKey) { 1187 1200 // Insert P element instead of BR 1188 1201 if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) { 1189 1202 // Cancel event … … 1193 1206 } 1194 1207 1195 1208 // Handle backspace 1196 if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings ['force_p_newlines']&& (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {1209 if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { 1197 1210 // Insert P element instead of BR 1198 1211 if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { 1199 1212 // Cancel event … … 1203 1216 } 1204 1217 1205 1218 // Return key pressed 1206 if (tinyMCE.isIE && tinyMCE.settings ['force_br_newlines']&& e.keyCode == 13) {1219 if (tinyMCE.isIE && tinyMCE.settings.force_br_newlines && e.keyCode == 13) { 1207 1220 if (e.target.editorId) 1208 1221 tinyMCE.instances[e.target.editorId].select(); 1209 1222 … … 1238 1251 } 1239 1252 1240 1253 return false; 1241 break;1242 1254 1243 1255 case "keyup": 1244 1256 case "keydown": … … 1248 1260 if (inst && inst.handleShortcut(e)) 1249 1261 return false; 1250 1262 1263 inst._fixRootBlocks(); 1264 1265 if (inst.settings.remove_trailing_nbsp) 1266 inst._fixTrailingNbsp(); 1267 1251 1268 if (e.target.editorId) 1252 1269 tinyMCE.instances[e.target.editorId].select(); 1253 1270 1254 1271 if (tinyMCE.selectedInstance) 1255 1272 tinyMCE.selectedInstance.switchSettings(); 1256 1273 1257 varinst = tinyMCE.selectedInstance;1274 inst = tinyMCE.selectedInstance; 1258 1275 1259 1276 // Handle backspace 1260 if (tinyMCE.isGecko && tinyMCE.settings ['force_p_newlines']&& (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {1277 if (tinyMCE.isGecko && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { 1261 1278 // Insert P element instead of BR 1262 1279 if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { 1263 1280 // Cancel event … … 1269 1286 1270 1287 tinyMCE.selectedElement = null; 1271 1288 tinyMCE.selectedNode = null; 1272 varelm = tinyMCE.selectedInstance.getFocusElement();1289 elm = tinyMCE.selectedInstance.getFocusElement(); 1273 1290 tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); 1274 1291 tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); 1275 1292 tinyMCE.selectedElement = elm; 1276 1293 1277 1294 // Update visualaids on tabs 1278 1295 if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) 1279 tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings ['visual'], tinyMCE.selectedInstance);1296 tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings.visual, tinyMCE.selectedInstance); 1280 1297 1281 1298 // Fix empty elements on return/enter, check where enter occured 1282 1299 if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13) … … 1284 1301 1285 1302 // Fix empty elements on return/enter 1286 1303 if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) { 1287 varelm = tinyMCE.enterKeyElement;1304 elm = tinyMCE.enterKeyElement; 1288 1305 if (elm) { 1289 1306 var re = new RegExp('^HR|IMG|BR$','g'); // Skip these 1290 1307 var dre = new RegExp('^H[1-6]$','g'); // Add double on these … … 1299 1316 } 1300 1317 1301 1318 // Check if it's a position key 1302 varkeys = tinyMCE.posKeyCodes;1319 keys = tinyMCE.posKeyCodes; 1303 1320 var posKey = false; 1304 for ( vari=0; i<keys.length; i++) {1321 for (i=0; i<keys.length; i++) { 1305 1322 if (keys[i] == e.keyCode) { 1306 1323 posKey = true; 1307 1324 break; … … 1309 1326 } 1310 1327 1311 1328 // MSIE custom key handling 1312 if (tinyMCE.isIE && tinyMCE.settings ['custom_undo_redo']) {1313 var keys = new Array(8,46); // Backspace,Delete1329 if (tinyMCE.isIE && tinyMCE.settings.custom_undo_redo) { 1330 keys = [8, 46]; // Backspace,Delete 1314 1331 1315 for ( vari=0; i<keys.length; i++) {1332 for (i=0; i<keys.length; i++) { 1316 1333 if (keys[i] == e.keyCode) { 1317 1334 if (e.type == "keyup") 1318 1335 tinyMCE.triggerNodeChange(false); … … 1369 1386 if (!tinyMCE.isInstance(tinyMCE.instances[instanceName])) 1370 1387 continue; 1371 1388 1372 varinst = tinyMCE.instances[instanceName];1389 inst = tinyMCE.instances[instanceName]; 1373 1390 1374 1391 // Reset design mode if lost (on everything just in case) 1375 1392 inst.autoResetDesignMode(); … … 1403 1420 tinyMCE.instances[e.target.editorId].select(); 1404 1421 1405 1422 return false; 1406 break;1407 1423 } 1408 1424 }, 1409 1425 … … 1429 1445 // Tiled button 1430 1446 x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20); 1431 1447 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceTiledButton mceButtonNormal" target="_self">'; 1432 h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />';1448 h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" alt="{$'+lang+'}" title="{$' + lang + '}" />'; 1433 1449 h += '</a>'; 1434 1450 } else { 1435 1451 // Normal button 1436 1452 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">'; 1437 h += '<img src="' + img + '" title="{$' + lang + '}" />';1453 h += '<img src="' + img + '" alt="{$'+lang+'}" title="{$' + lang + '}" />'; 1438 1454 h += '</a>'; 1439 1455 } 1440 1456 … … 1500 1516 this.buttonMap[a[i]] = i; 1501 1517 }, 1502 1518 1519 formSubmit : function(f, p) { 1520 var n, inst, found = false; 1521 1522 if (f.form) 1523 f = f.form; 1524 1525 // Is it a form that has a TinyMCE instance 1526 for (n in tinyMCE.instances) { 1527 inst = tinyMCE.instances[n]; 1528 1529 if (!tinyMCE.isInstance(inst)) 1530 continue; 1531 1532 if (inst.formElement) { 1533 if (f == inst.formElement.form) { 1534 found = true; 1535 inst.isNotDirty = true; 1536 } 1537 } 1538 } 1539 1540 // Is valid 1541 if (found) { 1542 tinyMCE.removeTinyMCEFormElements(f); 1543 tinyMCE.triggerSave(); 1544 } 1545 1546 // Is it patched 1547 if (f.mceOldSubmit && p) 1548 f.mceOldSubmit(); 1549 }, 1550 1503 1551 submitPatch : function() { 1504 tinyMCE.removeTinyMCEFormElements(this); 1505 tinyMCE.triggerSave(); 1506 tinyMCE.isNotDirty = true; 1507 this.mceOldSubmit(); 1552 tinyMCE.formSubmit(this, true); 1508 1553 }, 1509 1554 1510 1555 onLoad : function() { 1511 var r; 1556 var r, i, c, mode, trigger, elements, element, settings, elementId, elm; 1557 var selector, deselector, elementRefAr, form; 1512 1558 1513 1559 // Wait for everything to be loaded first 1514 1560 if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) { … … 1527 1573 // IE produces JS error if TinyMCE is placed in a frame 1528 1574 // It seems to have something to do with the selection not beeing 1529 1575 // correctly initialized in IE so this hack solves the problem 1530 if (tinyMCE.isRealIE && document.body ) {1576 if (tinyMCE.isRealIE && document.body && window.location.href != window.top.location.href) { 1531 1577 r = document.body.createTextRange(); 1532 1578 r.collapse(true); 1533 1579 r.select(); … … 1535 1581 1536 1582 tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad'); 1537 1583 1538 for ( varc=0; c<tinyMCE.configs.length; c++) {1584 for (c=0; c<tinyMCE.configs.length; c++) { 1539 1585 tinyMCE.settings = tinyMCE.configs[c]; 1540 1586 1541 varselector = tinyMCE.getParam("editor_selector");1542 vardeselector = tinyMCE.getParam("editor_deselector");1543 var elementRefAr = new Array();1587 selector = tinyMCE.getParam("editor_selector"); 1588 deselector = tinyMCE.getParam("editor_deselector"); 1589 elementRefAr = []; 1544 1590 1545 1591 // Add submit triggers 1546 if (document.forms && tinyMCE.settings ['add_form_submit_trigger']&& !tinyMCE.submitTriggers) {1547 for ( vari=0; i<document.forms.length; i++) {1548 varform = document.forms[i];1592 if (document.forms && tinyMCE.settings.add_form_submit_trigger && !tinyMCE.submitTriggers) { 1593 for (i=0; i<document.forms.length; i++) { 1594 form = document.forms[i]; 1549 1595 1550 1596 tinyMCE.addEvent(form, "submit", TinyMCE_Engine.prototype.handleEvent); 1551 1597 tinyMCE.addEvent(form, "reset", TinyMCE_Engine.prototype.handleEvent); 1552 1598 tinyMCE.submitTriggers = true; // Do it only once 1553 1599 1554 1600 // Patch the form.submit function 1555 if (tinyMCE.settings ['submit_patch']) {1601 if (tinyMCE.settings.submit_patch) { 1556 1602 try { 1557 1603 form.mceOldSubmit = form.submit; 1558 1604 form.submit = TinyMCE_Engine.prototype.submitPatch; … … 1564 1610 } 1565 1611 1566 1612 // Add editor instances based on mode 1567 var mode = tinyMCE.settings['mode'];1613 mode = tinyMCE.settings.mode; 1568 1614 switch (mode) { 1569 1615 case "exact": 1570 varelements = tinyMCE.getParam('elements', '', true, ',');1616 elements = tinyMCE.getParam('elements', '', true, ','); 1571 1617 1572 for ( vari=0; i<elements.length; i++) {1573 varelement = tinyMCE._getElementById(elements[i]);1574 var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";1618 for (i=0; i<elements.length; i++) { 1619 element = tinyMCE._getElementById(elements[i]); 1620 trigger = element ? element.getAttribute(tinyMCE.settings.textarea_trigger) : ""; 1575 1621 1576 1622 if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class"))) 1577 1623 continue; … … 1579 1625 if (trigger == "false") 1580 1626 continue; 1581 1627 1582 if ((tinyMCE.settings ['ask'] || tinyMCE.settings['convert_on_click']) && element) {1628 if ((tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) && element) { 1583 1629 elementRefAr[elementRefAr.length] = element; 1584 1630 continue; 1585 1631 } 1586 1632 1587 1633 if (element) 1588 1634 tinyMCE.addMCEControl(element, elements[i]); 1589 else if (tinyMCE.settings['debug'])1590 alert("Error: Could not find element by id or name: " + elements[i]);1591 1635 } 1592 1636 break; 1593 1637 1594 1638 case "specific_textareas": 1595 1639 case "textareas": 1596 var nodeList= document.getElementsByTagName("textarea");1640 elements = document.getElementsByTagName("textarea"); 1597 1641 1598 for ( var i=0; i<nodeList.length; i++) {1599 var elm = nodeList.item(i);1600 var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);1642 for (i=0; i<elements.length; i++) { 1643 elm = elements.item(i); 1644 trigger = elm.getAttribute(tinyMCE.settings.textarea_trigger); 1601 1645 1602 if (selector != '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class")))1646 if (selector !== '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class"))) 1603 1647 continue; 1604 1648 1605 if (selector != '')1606 trigger = selector != ""? "true" : "";1649 if (selector !== '') 1650 trigger = selector !== '' ? "true" : ""; 1607 1651 1608 1652 if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class"))) 1609 1653 continue; … … 1614 1658 break; 1615 1659 } 1616 1660 1617 for ( vari=0; i<elementRefAr.length; i++) {1618 varelement = elementRefAr[i];1619 varelementId = element.name ? element.name : element.id;1661 for (i=0; i<elementRefAr.length; i++) { 1662 element = elementRefAr[i]; 1663 elementId = element.name ? element.name : element.id; 1620 1664 1621 if (tinyMCE.settings ['ask'] || tinyMCE.settings['convert_on_click']) {1665 if (tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) { 1622 1666 // Focus breaks in Mozilla 1623 1667 if (tinyMCE.isGecko) { 1624 varsettings = tinyMCE.settings;1668 settings = tinyMCE.settings; 1625 1669 1626 1670 tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); 1627 1671 … … 1629 1673 tinyMCE.addEvent(element, "click", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); 1630 1674 // tinyMCE.addEvent(element, "mouseover", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); 1631 1675 } else { 1632 varsettings = tinyMCE.settings;1676 settings = tinyMCE.settings; 1633 1677 1634 1678 tinyMCE.addEvent(element, "focus", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); 1635 1679 tinyMCE.addEvent(element, "click", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); … … 1640 1684 } 1641 1685 1642 1686 // Handle auto focus 1643 if (tinyMCE.settings ['auto_focus']) {1687 if (tinyMCE.settings.auto_focus) { 1644 1688 window.setTimeout(function () { 1645 var inst = tinyMCE.getInstanceById(tinyMCE.settings ['auto_focus']);1689 var inst = tinyMCE.getInstanceById(tinyMCE.settings.auto_focus); 1646 1690 inst.selection.selectNode(inst.getBody(), true, true); 1647 1691 inst.contentWindow.focus(); 1648 1692 }, 100); … … 1657 1701 }, 1658 1702 1659 1703 getParam : function(name, default_value, strip_whitespace, split_chr) { 1660 var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];1704 var i, outArray, value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; 1661 1705 1662 1706 // Fix bool values 1663 1707 if (value == "true" || value == "false") … … 1668 1712 1669 1713 if (typeof(split_chr) != "undefined" && split_chr != null) { 1670 1714 value = value.split(split_chr); 1671 var outArray = new Array();1715 outArray = []; 1672 1716 1673 for ( vari=0; i<value.length; i++) {1674 if (value[i] && value[i] != "")1717 for (i=0; i<value.length; i++) { 1718 if (value[i] && value[i] !== '') 1675 1719 outArray[outArray.length] = value[i]; 1676 1720 } 1677 1721 … … 1700 1744 1701 1745 e.innerHTML = s; 1702 1746 1703 return e.firstChild.nodeValue;1747 return !e.firstChild ? s : e.firstChild.nodeValue; 1704 1748 }, 1705 1749 1706 1750 addToLang : function(prefix, ar) { 1707 for (var key in ar) { 1708 if (typeof(ar[key]) == 'function') 1751 var k; 1752 1753 for (k in ar) { 1754 if (typeof(ar[k]) == 'function') 1709 1755 continue; 1710 1756 1711 tinyMCELang[(k ey.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key];1757 tinyMCELang[(k.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix !== '' ? (prefix + "_") : '') + k] = ar[k]; 1712 1758 } 1713 1759 1714 1760 this.loadNextScript(); 1715 1716 // for (var key in ar)1717 // tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|";1718 1761 }, 1719 1762 1720 1763 triggerNodeChange : function(focus, setup_content) { … … 1743 1786 if (tinyMCE.selectedElement) 1744 1787 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0); 1745 1788 1746 if (tinyMCE.settings ['custom_undo_redo']) {1789 if (tinyMCE.settings.custom_undo_redo) { 1747 1790 undoIndex = inst.undoRedo.undoIndex; 1748 1791 undoLevels = inst.undoRedo.undoLevels.length; 1749 1792 } … … 1756 1799 }, 1757 1800 1758 1801 _customCleanup : function(inst, type, content) { 1759 var pl, po, i ;1802 var pl, po, i, customCleanup; 1760 1803 1761 1804 // Call custom cleanup 1762 var customCleanup = tinyMCE.settings['cleanup_callback'];1763 if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")1764 content = eval(customCleanup + "(type, content, inst);");1805 customCleanup = tinyMCE.settings.cleanup_callback; 1806 if (customCleanup != '') 1807 content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst); 1765 1808 1766 1809 // Trigger theme cleanup 1767 po = tinyMCE.themes[tinyMCE.settings ['theme']];1810 po = tinyMCE.themes[tinyMCE.settings.theme]; 1768 1811 if (po && po.cleanup) 1769 1812 content = po.cleanup(type, content, inst); 1770 1813 … … 1789 1832 1790 1833 importThemeLanguagePack : function(name) { 1791 1834 if (typeof(name) == "undefined") 1792 name = tinyMCE.settings ['theme'];1835 name = tinyMCE.settings.theme; 1793 1836 1794 tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings ['language']+ '.js');1837 tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings.language + '.js'); 1795 1838 }, 1796 1839 1797 1840 importPluginLanguagePack : function(name) { … … 1800 1843 if (this.plugins[name]) 1801 1844 b = this.plugins[name].baseURL; 1802 1845 1803 tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings ['language']+ '.js');1846 tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings.language + '.js'); 1804 1847 }, 1805 1848 1806 applyTemplate : function(h, a s) {1849 applyTemplate : function(h, ag) { 1807 1850 return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) { 1808 1851 if (s.indexOf('lang_') == 0 && tinyMCELang[s]) 1809 1852 return tinyMCELang[s]; 1810 1853 1811 if (a s && as[s])1812 return a s[s];1854 if (ag && ag[s]) 1855 return ag[s]; 1813 1856 1814 1857 if (tinyMCE.settings[s]) 1815 1858 return tinyMCE.settings[s]; … … 1826 1869 }, 1827 1870 1828 1871 openWindow : function(template, args) { 1829 var html, width, height, x, y, resizable, scrollbars, url ;1872 var html, width, height, x, y, resizable, scrollbars, url, name, win, modal, features; 1830 1873 1831 1874 args = !args ? {} : args; 1832 1875 1833 args ['mce_template_file'] = template['file'];1834 args ['mce_width'] = template['width'];1835 args ['mce_height'] = template['height'];1876 args.mce_template_file = template.file; 1877 args.mce_width = template.width; 1878 args.mce_height = template.height; 1836 1879 tinyMCE.windowArgs = args; 1837 1880 1838 html = template ['html'];1839 if (!(width = parseInt(template ['width'])))1881 html = template.html; 1882 if (!(width = parseInt(template.width))) 1840 1883 width = 320; 1841 1884 1842 if (!(height = parseInt(template ['height'])))1885 if (!(height = parseInt(template.height))) 1843 1886 height = 200; 1844 1887 1845 1888 // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! … … 1851 1894 x = parseInt(screen.width / 2.0) - (width / 2.0); 1852 1895 y = parseInt(screen.height / 2.0) - (height / 2.0); 1853 1896 1854 resizable = (args && args ['resizable']) ? args['resizable']: "no";1855 scrollbars = (args && args ['scrollbars']) ? args['scrollbars']: "no";1897 resizable = (args && args.resizable) ? args.resizable : "no"; 1898 scrollbars = (args && args.scrollbars) ? args.scrollbars : "no"; 1856 1899 1857 if (template ['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)1858 url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template ['file'];1900 if (template.file.charAt(0) != '/' && template.file.indexOf('://') == -1) 1901 url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template.file; 1859 1902 else 1860 url = template ['file'];1903 url = template.file; 1861 1904 1862 1905 // Replace all args as variables in URL 1863 for ( varname in args) {1906 for (name in args) { 1864 1907 if (typeof(args[name]) == 'function') 1865 1908 continue; 1866 1909 … … 1868 1911 } 1869 1912 1870 1913 if (html) { 1871 html = tinyMCE.replaceVar(html, "css", this.settings ['popups_css']);1914 html = tinyMCE.replaceVar(html, "css", this.settings.popups_css); 1872 1915 html = tinyMCE.applyTemplate(html, args); 1873 1916 1874 varwin = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable);1917 win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); 1875 1918 if (win == null) { 1876 alert(tinyMCELang ['lang_popup_blocked']);1919 alert(tinyMCELang.lang_popup_blocked); 1877 1920 return; 1878 1921 } 1879 1922 … … 1882 1925 win.resizeTo(width, height); 1883 1926 win.focus(); 1884 1927 } else { 1885 if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings ["dialog_type"]== "modal") {1928 if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings.dialog_type == "modal") { 1886 1929 height += 10; 1887 1930 1888 var features = "resizable:" + resizable 1889 + ";scroll:" 1890 + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" 1891 + width + "px;dialogHeight:" + height + "px;"; 1931 features = "resizable:" + resizable + ";scroll:" + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;"; 1892 1932 1893 1933 window.showModalDialog(url, window, features); 1894 1934 } else { 1895 varmodal = (resizable == "yes") ? "no" : "yes";1935 modal = (resizable == "yes") ? "no" : "yes"; 1896 1936 1897 1937 if (tinyMCE.isGecko && tinyMCE.isMac) 1898 1938 modal = "no"; 1899 1939 1900 if (template ['close_previous']!= "no")1940 if (template.close_previous != "no") 1901 1941 try {tinyMCE.lastWindow.close();} catch (ex) {} 1902 1942 1903 varwin = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable);1943 win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable); 1904 1944 if (win == null) { 1905 alert(tinyMCELang ['lang_popup_blocked']);1945 alert(tinyMCELang.lang_popup_blocked); 1906 1946 return; 1907 1947 } 1908 1948 1909 if (template ['close_previous']!= "no")1949 if (template.close_previous != "no") 1910 1950 tinyMCE.lastWindow = win; 1911 1951 1912 eval('try { win.resizeTo(width, height); } catch(e) { }'); 1952 try { 1953 win.resizeTo(width, height); 1954 } catch(e) { 1955 // Ignore 1956 } 1913 1957 1914 1958 // Make it bigger if statusbar is forced 1915 1959 if (tinyMCE.isGecko) { … … 1927 1971 }, 1928 1972 1929 1973 getVisualAidClass : function(class_name, state) { 1930 var aidClass = tinyMCE.settings['visual_table_class'];1974 var i, classNames, ar, className, aidClass = tinyMCE.settings.visual_table_class; 1931 1975 1932 1976 if (typeof(state) == "undefined") 1933 state = tinyMCE.settings ['visual'];1977 state = tinyMCE.settings.visual; 1934 1978 1935 1979 // Split 1936 var classNames = new Array();1937 varar = class_name.split(' ');1938 for ( vari=0; i<ar.length; i++) {1980 classNames = []; 1981 ar = class_name.split(' '); 1982 for (i=0; i<ar.length; i++) { 1939 1983 if (ar[i] == aidClass) 1940 1984 ar[i] = ""; 1941 1985 1942 if (ar[i] != "")1986 if (ar[i] !== '') 1943 1987 classNames[classNames.length] = ar[i]; 1944 1988 } 1945 1989 … … 1947 1991 classNames[classNames.length] = aidClass; 1948 1992 1949 1993 // Glue 1950 varclassName = "";1951 for ( vari=0; i<classNames.length; i++) {1994 className = ""; 1995 for (i=0; i<classNames.length; i++) { 1952 1996 if (i > 0) 1953 1997 className += " "; 1954 1998 … … 1959 2003 }, 1960 2004 1961 2005 handleVisualAid : function(el, deep, state, inst, skip_dispatch) { 2006 var i, x, y, tableElement, anchorName, oldW, oldH, bo, cn; 2007 1962 2008 if (!el) 1963 2009 return; 1964 2010 1965 2011 if (!skip_dispatch) 1966 2012 tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst); 1967 2013 1968 vartableElement = null;2014 tableElement = null; 1969 2015 1970 2016 switch (el.nodeName) { 1971 2017 case "TABLE": 1972 varoldW = el.style.width;1973 varoldH = el.style.height;1974 varbo = tinyMCE.getAttrib(el, "border");2018 oldW = el.style.width; 2019 oldH = el.style.height; 2020 bo = tinyMCE.getAttrib(el, "border"); 1975 2021 1976 bo = bo == ""|| bo == "0" ? true : false;2022 bo = bo == '' || bo == "0" ? true : false; 1977 2023 1978 2024 tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); 1979 2025 1980 2026 el.style.width = oldW; 1981 2027 el.style.height = oldH; 1982 2028 1983 for ( vary=0; y<el.rows.length; y++) {1984 for ( varx=0; x<el.rows[y].cells.length; x++) {1985 varcn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);2029 for (y=0; y<el.rows.length; y++) { 2030 for (x=0; x<el.rows[y].cells.length; x++) { 2031 cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo); 1986 2032 tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn); 1987 2033 } 1988 2034 } … … 1990 2036 break; 1991 2037 1992 2038 case "A": 1993 varanchorName = tinyMCE.getAttrib(el, "name");2039 anchorName = tinyMCE.getAttrib(el, "name"); 1994 2040 1995 if (anchorName != '' && state) {2041 if (anchorName !== '' && state) { 1996 2042 el.title = anchorName; 1997 2043 tinyMCE.addCSSClass(el, 'mceItemAnchor'); 1998 } else if (anchorName != '' && !state)2044 } else if (anchorName !== '' && !state) 1999 2045 el.className = ''; 2000 2046 2001 2047 break; 2002 2048 } 2003 2049 2004 2050 if (deep && el.hasChildNodes()) { 2005 for ( vari=0; i<el.childNodes.length; i++)2051 for (i=0; i<el.childNodes.length; i++) 2006 2052 tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true); 2007 2053 } 2008 2054 }, 2009 2055 2010 /*2011 applyClassesToFonts : function(doc, size) {2012 var f = doc.getElementsByTagName("font");2013 for (var i=0; i<f.length; i++) {2014 var s = tinyMCE.getAttrib(f[i], "size");2015 2016 if (s != "")2017 tinyMCE.setAttrib(f[i], 'class', "mceItemFont" + s);2018 }2019 2020 if (typeof(size) != "undefined") {2021 var css = "";2022 2023 for (var x=0; x<doc.styleSheets.length; x++) {2024 for (var i=0; i<doc.styleSheets[x].rules.length; i++) {2025 if (doc.styleSheets[x].rules[i].selectorText == '#mceSpanFonts .mceItemFont' + size) {2026 css = doc.styleSheets[x].rules[i].style.cssText;2027 break;2028 }2029 }2030 2031 if (css != "")2032 break;2033 }2034 2035 if (doc.styleSheets[0].rules[0].selectorText == "FONT")2036 doc.styleSheets[0].removeRule(0);2037 2038 doc.styleSheets[0].addRule("FONT", css, 0);2039 }2040 },2041 */2042 2043 2056 fixGeckoBaseHREFBug : function(m, e, h) { 2044 2057 var xsrc, xhref; 2045 2058 … … 2059 2072 xsrc = tinyMCE.getAttrib(n, "mce_tsrc"); 2060 2073 xhref = tinyMCE.getAttrib(n, "mce_thref"); 2061 2074 2062 if (xsrc != "") {2075 if (xsrc !== '') { 2063 2076 try { 2064 n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings ['base_href'], xsrc);2077 n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, xsrc); 2065 2078 } catch (e) { 2066 2079 // Ignore, Firefox cast exception if local file wasn't found 2067 2080 } … … 2069 2082 n.removeAttribute("mce_tsrc"); 2070 2083 } 2071 2084 2072 if (xhref != "") {2085 if (xhref !== '') { 2073 2086 try { 2074 n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings ['base_href'], xhref);2087 n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, xhref); 2075 2088 } catch (e) { 2076 2089 // Ignore, Firefox cast exception if local file wasn't found 2077 2090 } … … 2098 2111 }, 2099 2112 2100 2113 _setHTML : function(doc, html_content) { 2114 var i, html, paras, node; 2115 2101 2116 // Force closed anchors open 2102 2117 //html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>'); 2103 2118 … … 2112 2127 } 2113 2128 2114 2129 // Content duplication bug fix 2115 if (tinyMCE.isIE && tinyMCE.settings ['fix_content_duplication']) {2130 if (tinyMCE.isIE && tinyMCE.settings.fix_content_duplication) { 2116 2131 // Remove P elements in P elements 2117 var paras = doc.getElementsByTagName("P"); 2118 for (var i=0; i<paras.length; i++) { 2119 var node = paras[i]; 2132 paras = doc.getElementsByTagName("P"); 2133 for (i=0; i<paras.length; i++) { 2134 node = paras[i]; 2135 2120 2136 while ((node = node.parentNode) != null) { 2121 2137 if (node.nodeName == "P") 2122 2138 node.outerHTML = node.innerHTML; … … 2124 2140 } 2125 2141 2126 2142 // Content duplication bug fix (Seems to be word crap) 2127 var html = doc.body.innerHTML; 2128 /* 2129 if (html.indexOf('="mso') != -1) { 2130 for (var i=0; i<doc.body.all.length; i++) { 2131 var el = doc.body.all[i]; 2132 el.removeAttribute("className","",0); 2133 el.removeAttribute("style","",0); 2134 } 2143 html = doc.body.innerHTML; 2135 2144 2136 html = doc.body.innerHTML;2137 html = tinyMCE.regexpReplace(html, "<o:p><\/o:p>", "<br />");2138 html = tinyMCE.regexpReplace(html, "<o:p> <\/o:p>", "");2139 html = tinyMCE.regexpReplace(html, "<st1:.*?>", "");2140 html = tinyMCE.regexpReplace(html, "<p><\/p>", "");2141 html = tinyMCE.regexpReplace(html, "<p><\/p>\r\n<p><\/p>", "");2142 html = tinyMCE.regexpReplace(html, "<p> <\/p>", "<br />");2143 html = tinyMCE.regexpReplace(html, "<p>\s*(<p>\s*)?", "<p>");2144 html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "</p>");2145 }*/2146 2147 2145 // Always set the htmlText output 2148 2146 tinyMCE.setInnerHTML(doc.body, html); 2149 2147 } … … 2156 2154 2157 2155 getEditorId : function(form_element) { 2158 2156 var inst = this.getInstanceById(form_element); 2157 2159 2158 if (!inst) 2160 2159 return null; 2161 2160 … … 2163 2162 }, 2164 2163 2165 2164 getInstanceById : function(editor_id) { 2166 var inst = this.instances[editor_id]; 2165 var inst = this.instances[editor_id], n; 2166 2167 2167 if (!inst) { 2168 for (var n in tinyMCE.instances) { 2169 var instance = tinyMCE.instances[n]; 2170 if (!tinyMCE.isInstance(instance)) 2168 for (n in tinyMCE.instances) { 2169 inst = tinyMCE.instances[n]; 2170 2171 if (!tinyMCE.isInstance(inst)) 2171 2172 continue; 2172 2173 2173 if (instance.formTargetElementId == editor_id) { 2174 inst = instance; 2175 break; 2176 } 2174 if (inst.formTargetElementId == editor_id) 2175 return inst; 2177 2176 } 2178 } 2177 } else 2178 return inst; 2179 2179 2180 return inst;2180 return null; 2181 2181 }, 2182 2182 2183 2183 queryInstanceCommandValue : function(editor_id, command) { 2184 2184 var inst = tinyMCE.getInstanceById(editor_id); 2185 2185 2186 if (inst) 2186 2187 return inst.queryCommandValue(command); 2187 2188 … … 2190 2191 2191 2192 queryInstanceCommandState : function(editor_id, command) { 2192 2193 var inst = tinyMCE.getInstanceById(editor_id); 2194 2193 2195 if (inst) 2194 2196 return inst.queryCommandState(command); 2195 2197 … … 2205 2207 }, 2206 2208 2207 2209 getCSSClasses : function(editor_id, doc) { 2208 var inst = tinyMCE.getInstanceById(editor_id); 2210 var i, c, x, rule, styles, rules, csses, selectorText, inst = tinyMCE.getInstanceById(editor_id); 2211 var cssClass, addClass, p; 2209 2212 2213 if (!inst) 2214 inst = tinyMCE.selectedInstance; 2215 2216 if (!inst) 2217 return []; 2218 2219 if (!doc) 2220 doc = inst.getDoc(); 2221 2210 2222 // Is cached, use that 2211 2223 if (inst && inst.cssClasses.length > 0) 2212 2224 return inst.cssClasses; 2213 2225 2214 if ( typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {2215 var instance;2226 if (!doc) 2227 return; 2216 2228 2217 for (var instanceName in tinyMCE.instances) { 2218 instance = tinyMCE.instances[instanceName]; 2219 if (!tinyMCE.isInstance(instance)) 2220 continue; 2229 styles = doc.styleSheets; 2221 2230 2222 break; 2223 } 2231 if (styles && styles.length > 0) { 2232 for (x=0; x<styles.length; x++) { 2233 csses = null; 2224 2234 2225 doc = instance.getDoc(); 2226 } 2235 try { 2236 csses = tinyMCE.isIE ? doc.styleSheets(x).rules : styles[x].cssRules; 2237 } catch(e) { 2238 // Just ignore any errors I know this is ugly!! 2239 } 2240 2241 if (!csses) 2242 return []; 2227 2243 2228 if (typeof(doc) == "undefined") { 2229 var instance = tinyMCE.getInstanceById(editor_id); 2230 doc = instance.getDoc(); 2231 } 2244 for (i=0; i<csses.length; i++) { 2245 selectorText = csses[i].selectorText; 2232 2246 2233 if (doc) { 2234 var styles = doc.styleSheets; 2247 // Can be multiple rules per selector 2248 if (selectorText) { 2249 rules = selectorText.split(','); 2250 for (c=0; c<rules.length; c++) { 2251 rule = rules[c]; 2235 2252 2236 if (styles && styles.length > 0) {2237 for (var x=0; x<styles.length; x++) {2238 var csses = null;2253 // Strip spaces between selectors 2254 while (rule.indexOf(' ') == 0) 2255 rule = rule.substring(1); 2239 2256 2240 // Just ignore any errors 2241 eval("try {var csses = tinyMCE.isIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}"); 2242 if (!csses) 2243 return new Array(); 2257 // Invalid rule 2258 if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1) 2259 continue; 2244 2260 2245 for (var i=0; i<csses.length; i++) {2246 var selectorText = csses[i].selectorText;2261 if (rule.indexOf(tinyMCE.settings.visual_table_class) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1) 2262 continue; 2247 2263 2248 // Can be multiple rules per selector 2249 if (selectorText) { 2250 var rules = selectorText.split(','); 2251 for (var c=0; c<rules.length; c++) { 2252 var rule = rules[c]; 2264 // Is class rule 2265 if (rule.indexOf('.') != -1) { 2266 cssClass = rule.substring(rule.indexOf('.') + 1); 2267 addClass = true; 2253 2268 2254 // Strip spaces between selectors 2255 while (rule.indexOf(' ') == 0) 2256 rule = rule.substring(1); 2269 for (p=0; p<inst.cssClasses.length && addClass; p++) { 2270 if (inst.cssClasses[p] == cssClass) 2271 addClass = false; 2272 } 2257 2273 2258 // Invalid rule 2259 if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1) 2260 continue; 2261 2262 if (rule.indexOf(tinyMCE.settings['visual_table_class']) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1) 2263 continue; 2264 2265 // Is class rule 2266 if (rule.indexOf('.') != -1) { 2267 var cssClass = rule.substring(rule.indexOf('.') + 1); 2268 var addClass = true; 2269 2270 for (var p=0; p<inst.cssClasses.length && addClass; p++) { 2271 if (inst.cssClasses[p] == cssClass) 2272 addClass = false; 2273 } 2274 2275 if (addClass) 2276 inst.cssClasses[inst.cssClasses.length] = cssClass; 2277 } 2274 if (addClass) 2275 inst.cssClasses[inst.cssClasses.length] = cssClass; 2278 2276 } 2279 2277 } 2280 2278 } … … 2286 2284 }, 2287 2285 2288 2286 regexpReplace : function(in_str, reg_exp, replace_str, opts) { 2287 var re; 2288 2289 2289 if (in_str == null) 2290 2290 return in_str; 2291 2291 2292 2292 if (typeof(opts) == "undefined") 2293 2293 opts = 'g'; 2294 2294 2295 var re = new RegExp(reg_exp, opts); 2295 re = new RegExp(reg_exp, opts); 2296 2296 2297 return in_str.replace(re, replace_str); 2297 2298 }, 2298 2299 … … 2316 2317 for (n in l) { 2317 2318 o = l[n]; 2318 2319 2319 if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {2320 if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') { 2320 2321 if (rtl) 2321 2322 return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>'; 2322 2323 … … 2324 2325 } 2325 2326 } 2326 2327 2327 o = tinyMCE.themes[tinyMCE.settings ['theme']];2328 if (o.getControlHTML && (v = o.getControlHTML(c)) != '') {2328 o = tinyMCE.themes[tinyMCE.settings.theme]; 2329 if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') { 2329 2330 if (rtl) 2330 2331 return '<span dir="rtl">' + v + '</span>'; 2331 2332 … … 2361 2362 2362 2363 l = tinyMCE.getParam(p, ''); 2363 2364 2364 if (l != '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0)2365 if (l !== '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) 2365 2366 return true; 2366 2367 2367 2368 if (ins != null) { … … 2384 2385 return false; 2385 2386 }, 2386 2387 2387 xmlEncode : function(s, skip_apos) { 2388 return s ? ('' + s).replace(!skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe, function (c, b) { 2388 resolveDots : function(s, o) { 2389 var i; 2390 2391 if (typeof(s) == 'string') { 2392 for (i=0, s=s.split('.'); i<s.length; i++) 2393 o = o[s[i]]; 2394 } else 2395 o = s; 2396 2397 return o; 2398 }, 2399 2400 xmlEncode : function(s) { 2401 return s ? ('' + s).replace(this.xmlEncodeRe, function (c, b) { 2389 2402 switch (c) { 2390 2403 case '&': 2391 2404 return '&'; … … 2393 2406 case '"': 2394 2407 return '"'; 2395 2408 2396 case '\'':2397 return '''; // ' is not working in MSIE2398 2399 2409 case '<': 2400 2410 return '<'; 2401 2411 … … 2407 2417 }) : s; 2408 2418 }, 2409 2419 2420 add : function(c, m) { 2421 var n; 2422 2423 for (n in m) 2424 c.prototype[n] = m[n]; 2425 }, 2426 2410 2427 extend : function(p, np) { 2411 var o = {} ;2428 var o = {}, n; 2412 2429 2413 2430 o.parent = p; 2414 2431 … … 2445 2462 /* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */ 2446 2463 2447 2464 function TinyMCE_Control(settings) { 2448 var t, i, to , fu, p, x, fn, fu, pn, s = settings;2465 var t, i, tos, fu, p, x, fn, fu, pn, s = settings; 2449 2466 2450 2467 this.undoRedoLevel = true; 2451 2468 this.isTinyMCE_Control = true; 2452 2469 2453 2470 // Default settings 2471 this.enabled = true; 2454 2472 this.settings = s; 2455 this.settings ['theme']= tinyMCE.getParam("theme", "default");2456 this.settings ['width']= tinyMCE.getParam("width", -1);2457 this.settings ['height']= tinyMCE.getParam("height", -1);2473 this.settings.theme = tinyMCE.getParam("theme", "default"); 2474 this.settings.width = tinyMCE.getParam("width", -1); 2475 this.settings.height = tinyMCE.getParam("height", -1); 2458 2476 this.selection = new TinyMCE_Selection(this); 2459 2477 this.undoRedo = new TinyMCE_UndoRedo(this); 2460 2478 this.cleanup = new TinyMCE_Cleanup(); 2461 this.shortcuts = new Array();2479 this.shortcuts = []; 2462 2480 this.hasMouseMoved = false; 2463 2481 this.foreColor = this.backColor = "#999999"; 2464 2482 this.data = {}; … … 2479 2497 }); 2480 2498 2481 2499 // Wrap old theme 2482 t = this.settings ['theme'];2500 t = this.settings.theme; 2483 2501 if (!tinyMCE.hasTheme(t)) { 2484 2502 fn = tinyMCE.callbacks; 2485 to = {};2503 tos = {}; 2486 2504 2487 2505 for (i=0; i<fn.length; i++) { 2488 2506 if ((fu = window['TinyMCE_' + t + "_" + fn[i]])) 2489 to [fn[i]] = fu;2507 tos[fn[i]] = fu; 2490 2508 } 2491 2509 2492 tinyMCE.addTheme(t, to );2510 tinyMCE.addTheme(t, tos); 2493 2511 } 2494 2512 2495 2513 // Wrap old plugins 2496 this.plugins = new Array();2514 this.plugins = []; 2497 2515 p = tinyMCE.getParam('plugins', '', true, ','); 2498 2516 if (p.length > 0) { 2499 2517 for (i=0; i<p.length; i++) { … … 2504 2522 2505 2523 if (!tinyMCE.hasPlugin(pn)) { 2506 2524 fn = tinyMCE.callbacks; 2507 to = {};2525 tos = {}; 2508 2526 2509 2527 for (x=0; x<fn.length; x++) { 2510 2528 if ((fu = window['TinyMCE_' + pn + "_" + fn[x]])) 2511 to [fn[x]] = fu;2529 tos[fn[x]] = fu; 2512 2530 } 2513 2531 2514 tinyMCE.addPlugin(pn, to );2532 tinyMCE.addPlugin(pn, tos); 2515 2533 } 2516 2534 2517 2535 this.plugins[this.plugins.length] = pn; … … 2573 2591 }, 2574 2592 2575 2593 switchSettings : function() { 2576 if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings ['index']) {2594 if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings.index) { 2577 2595 tinyMCE.settings = this.settings; 2578 tinyMCE.currentConfig = this.settings ['index'];2596 tinyMCE.currentConfig = this.settings.index; 2579 2597 } 2580 2598 }, 2581 2599 … … 2709 2727 2710 2728 isDirty : function() { 2711 2729 // Is content modified and not in a submit procedure 2712 return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !t inyMCE.isNotDirty;2730 return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !this.isNotDirty; 2713 2731 }, 2714 2732 2715 2733 _mergeElements : function(scmd, pa, ch, override) { 2734 var st, stc, className, n; 2735 2716 2736 if (scmd == "removeformat") { 2717 2737 pa.className = ""; 2718 2738 pa.style.cssText = ""; … … 2721 2741 return; 2722 2742 } 2723 2743 2724 varst = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style"));2725 varstc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));2726 varclassName = tinyMCE.getAttrib(pa, "class");2744 st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style")); 2745 stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style")); 2746 className = tinyMCE.getAttrib(pa, "class"); 2727 2747 2728 2748 // Removed class adding due to bug #1478272 2729 2749 className = tinyMCE.getAttrib(ch, "class"); 2730 2750 2731 2751 if (override) { 2732 for ( varn in st) {2752 for (n in st) { 2733 2753 if (typeof(st[n]) == 'function') 2734 2754 continue; 2735 2755 2736 2756 stc[n] = st[n]; 2737 2757 } 2738 2758 } else { 2739 for ( varn in stc) {2759 for (n in stc) { 2740 2760 if (typeof(stc[n]) == 'function') 2741 2761 continue; 2742 2762 … … 2752 2772 ch.removeAttribute("style"); 2753 2773 }, 2754 2774 2775 _fixRootBlocks : function() { 2776 var rb, b, ne, be, nx, bm; 2777 2778 rb = tinyMCE.getParam('forced_root_block'); 2779 if (!rb) 2780 return; 2781 2782 b = this.getBody(); 2783 ne = b.firstChild; 2784 2785 while (ne) { 2786 nx = ne.nextSibling; 2787 2788 // If text node or inline element wrap it in a block element 2789 if (ne.nodeType == 3 || !tinyMCE.blockRegExp.test(ne.nodeName)) { 2790 if (!bm) 2791 bm = this.selection.getBookmark(); 2792 2793 if (!be) { 2794 be = this.getDoc().createElement(rb); 2795 be.appendChild(ne.cloneNode(true)); 2796 b.replaceChild(be, ne); 2797 } else { 2798 be.appendChild(ne.cloneNode(true)); 2799 b.removeChild(ne); 2800 } 2801 } else 2802 be = null; 2803 2804 ne = nx; 2805 } 2806 2807 if (bm) 2808 this.selection.moveToBookmark(bm); 2809 }, 2810 2811 _fixTrailingNbsp : function() { 2812 var s = this.selection, e = s.getFocusElement(), bm, v; 2813 2814 if (e && tinyMCE.blockRegExp.test(e.nodeName) && e.firstChild) { 2815 v = e.firstChild.nodeValue; 2816 2817 if (v && v.length > 1 && /(^\u00a0|\u00a0$)/.test(v)) { 2818 e.firstChild.nodeValue = v.replace(/(^\u00a0|\u00a0$)/, ''); 2819 s.selectNode(e.firstChild, true, false, false); // Select and collapse 2820 } 2821 } 2822 }, 2823 2755 2824 _setUseCSS : function(b) { 2756 2825 var d = this.getDoc(); 2757 2826 … … 2766 2835 }, 2767 2836 2768 2837 execCommand : function(command, user_interface, value) { 2769 var doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement();2838 var i, x, z, align, img, div, doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement(); 2770 2839 2771 2840 // Is not a undo specific command 2772 2841 if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) … … 2789 2858 2790 2859 // Fix align on images 2791 2860 if (focusElm && focusElm.nodeName == "IMG") { 2792 varalign = focusElm.getAttribute('align');2793 varimg = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm;2861 align = focusElm.getAttribute('align'); 2862 img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm; 2794 2863 2795 2864 switch (command) { 2796 2865 case "JustifyLeft": … … 2800 2869 img.setAttribute('align', 'left'); 2801 2870 2802 2871 // Remove the div 2803 vardiv = focusElm.parentNode;2872 div = focusElm.parentNode; 2804 2873 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) 2805 2874 div.parentNode.replaceChild(img, div); 2806 2875 … … 2813 2882 img.removeAttribute('align'); 2814 2883 2815 2884 // Is centered 2816 vardiv = tinyMCE.getParentElement(focusElm, "div");2885 div = tinyMCE.getParentElement(focusElm, "div"); 2817 2886 if (div && div.style.textAlign == "center") { 2818 2887 // Remove div 2819 2888 if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) 2820 2889 div.parentNode.replaceChild(img, div); 2821 2890 } else { 2822 2891 // Add div 2823 vardiv = this.getDoc().createElement("div");2892 div = this.getDoc().createElement("div"); 2824 2893 div.style.textAlign = 'center'; 2825 2894 div.appendChild(img); 2826 2895 focusElm.parentNode.replaceChild(div, focusElm); … … 2838 2907 img.setAttribute('align', 'right'); 2839 2908 2840 2909 // Remove the div 2841 vardiv = focusElm.parentNode;2910 div = focusElm.parentNode; 2842 2911 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) 2843 2912 div.parentNode.replaceChild(img, div); 2844 2913 … … 2849 2918 } 2850 2919 } 2851 2920 2852 if (tinyMCE.settings ['force_br_newlines']) {2921 if (tinyMCE.settings.force_br_newlines) { 2853 2922 var alignValue = ""; 2854 2923 2855 2924 if (doc.selection.type != "Control") { … … 2871 2940 break; 2872 2941 } 2873 2942 2874 if (alignValue != "") {2943 if (alignValue !== '') { 2875 2944 var rng = doc.selection.createRange(); 2876 2945 2877 2946 if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) … … 2925 2994 break; 2926 2995 2927 2996 case "FormatBlock": 2928 if (value == null || value == "") {2997 if (value == null || value == '') { 2929 2998 var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp"); 2930 2999 2931 3000 if (elm) … … 2970 3039 2971 3040 case "mceSelectNodeDepth": 2972 3041 var parentNode = this.getFocusElement(); 2973 for ( vari=0; parentNode; i++) {3042 for (i=0; parentNode; i++) { 2974 3043 if (parentNode.nodeName.toLowerCase() == "body") 2975 3044 break; 2976 3045 … … 2996 3065 case "SetStyleInfo": 2997 3066 var rng = this.getRng(); 2998 3067 var sel = this.getSel(); 2999 var scmd = value ['command'];3000 var sname = value ['name'];3001 var svalue = value ['value'] == null ? '' : value['value'];3068 var scmd = value.command; 3069 var sname = value.name; 3070 var svalue = value.value == null ? '' : value.value; 3002 3071 //var svalue = value['value'] == null ? '' : value['value']; 3003 var wrapper = value ['wrapper'] ? value['wrapper']: "span";3072 var wrapper = value.wrapper ? value.wrapper : "span"; 3004 3073 var parentElm = null; 3005 3074 var invalidRe = new RegExp("^BODY|HTML$", "g"); 3006 var invalidParentsRe = tinyMCE.settings ['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;3075 var invalidParentsRe = tinyMCE.settings.merge_styles_invalid_parents !== '' ? new RegExp(tinyMCE.settings.merge_styles_invalid_parents, "gi") : null; 3007 3076 3008 3077 // Whole element selected check 3009 3078 if (tinyMCE.isIE) { … … 3022 3091 } 3023 3092 } else { 3024 3093 var felm = this.getFocusElement(); 3025 if (sel.isCollapsed || (new RegExp('td|tr|tbody|table ', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode))3094 if (sel.isCollapsed || (new RegExp('td|tr|tbody|table|img', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode)) 3026 3095 parentElm = felm; 3027 3096 } 3028 3097 … … 3040 3109 } 3041 3110 3042 3111 // Remove style/attribs from all children 3043 var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);3044 for ( varz=0; z<ch.length; z++) {3112 var ch = tinyMCE.getNodeTree(parentElm, [], 1); 3113 for (z=0; z<ch.length; z++) { 3045 3114 if (ch[z] == parentElm) 3046 3115 continue; 3047 3116 … … 3062 3131 var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#"); 3063 3132 3064 3133 // Change them all 3065 for ( varx=0; x<elementArray.length; x++) {3134 for (x=0; x<elementArray.length; x++) { 3066 3135 elm = elementArray[x]; 3067 3136 if (elm) { 3068 3137 var spanElm = doc.createElement(wrapper); … … 3079 3148 } 3080 3149 3081 3150 if (elm.hasChildNodes()) { 3082 for ( vari=0; i<elm.childNodes.length; i++)3151 for (i=0; i<elm.childNodes.length; i++) 3083 3152 spanElm.appendChild(elm.childNodes[i].cloneNode(true)); 3084 3153 } 3085 3154 … … 3087 3156 elm.parentNode.replaceChild(spanElm, elm); 3088 3157 3089 3158 // Remove style/attribs from all children 3090 var ch = tinyMCE.getNodeTree(spanElm, new Array(), 1);3091 for ( varz=0; z<ch.length; z++) {3159 var ch = tinyMCE.getNodeTree(spanElm, [], 1); 3160 for (z=0; z<ch.length; z++) { 3092 3161 if (ch[z] == spanElm) 3093 3162 continue; 3094 3163 … … 3109 3178 3110 3179 // Cleaup wrappers 3111 3180 var nodes = doc.getElementsByTagName(wrapper); 3112 for ( vari=nodes.length-1; i>=0; i--) {3181 for (i=nodes.length-1; i>=0; i--) { 3113 3182 var elm = nodes[i]; 3114 3183 var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; 3115 3184 … … 3132 3201 3133 3202 // Remove empty wrappers 3134 3203 var nodes = doc.getElementsByTagName(wrapper); 3135 for (var i=nodes.length-1; i>=0; i--) { 3136 var elm = nodes[i]; 3137 var isEmpty = true; 3204 for (i=nodes.length-1; i>=0; i--) { 3205 var elm = nodes[i], isEmpty = true; 3138 3206 3139 3207 // Check if it has any attribs 3140 3208 var tmp = doc.createElement("body"); … … 3144 3212 tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); 3145 3213 //tinyMCE.debug(tmp.innerHTML); 3146 3214 if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) { 3147 for ( varx=0; x<elm.childNodes.length; x++) {3215 for (x=0; x<elm.childNodes.length; x++) { 3148 3216 if (elm.parentNode != null) 3149 3217 elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm); 3150 3218 } … … 3269 3337 3270 3338 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this); 3271 3339 tinyMCE._setEventsEnabled(this.getBody(), false); 3340 this._addBogusBR(); 3341 3272 3342 return true; 3273 3343 3274 3344 case "mceCleanup": … … 3283 3353 3284 3354 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this); 3285 3355 tinyMCE._setEventsEnabled(this.getBody(), false); 3356 this._addBogusBR(); 3286 3357 this.repaint(); 3287 3358 this.selection.moveToBookmark(b); 3288 3359 tinyMCE.triggerNodeChange(); … … 3308 3379 tinyMCE.execCommand('mceInsertContent', false, value); 3309 3380 } 3310 3381 3382 this._addBogusBR(); 3311 3383 tinyMCE.triggerNodeChange(); 3312 3384 break; 3313 3385 3314 3386 case "mceSetAttribute": 3315 3387 if (typeof(value) == 'object') { 3316 var targetElms = (typeof(value ['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];3388 var targetElms = (typeof(value.targets) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value.targets; 3317 3389 var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); 3318 3390 3319 3391 if (targetNode) { 3320 targetNode.setAttribute(value ['name'], value['value']);3392 targetNode.setAttribute(value.name, value.value); 3321 3393 tinyMCE.triggerNodeChange(); 3322 3394 } 3323 3395 } … … 3412 3484 value = rng.createContextualFragment(value); 3413 3485 } else { 3414 3486 // Setup text node 3415 var el = document.createElement("div"); 3416 el.innerHTML = value; 3417 value = el.firstChild.nodeValue; 3418 value = doc.createTextNode(value); 3487 value = doc.createTextNode(tinyMCE.entityDecode(value)); 3419 3488 } 3420 3489 3421 3490 // Insert plain text in Safari … … 3485 3554 break; 3486 3555 3487 3556 case "mceStartTyping": 3488 if (tinyMCE.settings ['custom_undo_redo']&& this.undoRedo.typingUndoIndex == -1) {3557 if (tinyMCE.settings.custom_undo_redo && this.undoRedo.typingUndoIndex == -1) { 3489 3558 this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex; 3490 3559 tinyMCE.typingUndoIndex = tinyMCE.undoIndex; 3491 3560 this.execCommand('mceAddUndoLevel'); … … 3493 3562 break; 3494 3563 3495 3564 case "mceEndTyping": 3496 if (tinyMCE.settings ['custom_undo_redo']&& this.undoRedo.typingUndoIndex != -1) {3565 if (tinyMCE.settings.custom_undo_redo && this.undoRedo.typingUndoIndex != -1) { 3497 3566 this.execCommand('mceAddUndoLevel'); 3498 3567 this.undoRedo.typingUndoIndex = -1; 3499 3568 } … … 3511 3580 break; 3512 3581 3513 3582 case "mceAddUndoLevel": 3514 if (tinyMCE.settings ['custom_undo_redo']&& this.undoRedoLevel) {3583 if (tinyMCE.settings.custom_undo_redo && this.undoRedoLevel) { 3515 3584 if (this.undoRedo.add()) 3516 3585 tinyMCE.triggerNodeChange(false); 3517 3586 } 3518 3587 break; 3519 3588 3520 3589 case "Undo": 3521 if (tinyMCE.settings ['custom_undo_redo']) {3590 if (tinyMCE.settings.custom_undo_redo) { 3522 3591 tinyMCE.execCommand("mceEndTyping"); 3523 3592 this.undoRedo.undo(); 3524 3593 tinyMCE.triggerNodeChange(); … … 3527 3596 break; 3528 3597 3529 3598 case "Redo": 3530 if (tinyMCE.settings ['custom_undo_redo']) {3599 if (tinyMCE.settings.custom_undo_redo) { 3531 3600 tinyMCE.execCommand("mceEndTyping"); 3532 3601 this.undoRedo.redo(); 3533 3602 tinyMCE.triggerNodeChange(); … … 3613 3682 return this.getDoc().queryCommandState(c); 3614 3683 }, 3615 3684 3685 _addBogusBR : function() { 3686 var b = this.getBody(); 3687 3688 if (tinyMCE.isGecko && !b.hasChildNodes()) 3689 b.innerHTML = '<br _moz_editor_bogus_node="TRUE" />'; 3690 }, 3691 3616 3692 _onAdd : function(replace_element, form_element_name, target_document) { 3617 var hc, th, to, editorTemplate; 3693 var hc, th, tos, editorTemplate, targetDoc, deltaWidth, deltaHeight, html, rng, fragment; 3694 var dynamicIFrame, tElm, doc, parentElm; 3618 3695 3619 th = this.settings ['theme'];3620 to = tinyMCE.themes[th];3696 th = this.settings.theme; 3697 tos = tinyMCE.themes[th]; 3621 3698 3622 vartargetDoc = target_document ? target_document : document;3699 targetDoc = target_document ? target_document : document; 3623 3700 3624 3701 this.targetDoc = targetDoc; 3625 3702 3626 tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings ['theme'];3627 this.settings ['themeurl']= tinyMCE.themeURL;3703 tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings.theme; 3704 this.settings.themeurl = tinyMCE.themeURL; 3628 3705 3629 3706 if (!replace_element) { 3630 3707 alert("Error: Could not find the target element."); 3631 3708 return false; 3632 3709 } 3633 3710 3634 if (to .getEditorTemplate)3635 editorTemplate = to .getEditorTemplate(this.settings, this.editorId);3711 if (tos.getEditorTemplate) 3712 editorTemplate = tos.getEditorTemplate(this.settings, this.editorId); 3636 3713 3637 var deltaWidth = editorTemplate['delta_width'] ? editorTemplate['delta_width']: 0;3638 var deltaHeight = editorTemplate['delta_height'] ? editorTemplate['delta_height']: 0;3639 var html = '<span id="' + this.editorId + '_parent" class="mceEditorContainer">' + editorTemplate['html'];3714 deltaWidth = editorTemplate.delta_width ? editorTemplate.delta_width : 0; 3715 deltaHeight = editorTemplate.delta_height ? editorTemplate.delta_height : 0; 3716 html = '<span id="' + this.editorId + '_parent" class="mceEditorContainer">' + editorTemplate.html; 3640 3717 3641 3718 html = tinyMCE.replaceVar(html, "editor_id", this.editorId); 3642 this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm";3643 3719 3644 this.settings['old_width'] = this.settings['width'];3645 this.settings['old_height'] = this.settings['height'];3720 if (!this.settings.default_document) 3721 this.settings.default_document = tinyMCE.baseURL + "/blank.htm"; 3646 3722 3723 this.settings.old_width = this.settings.width; 3724 this.settings.old_height = this.settings.height; 3725 3647 3726 // Set default width, height 3648 if (this.settings ['width']== -1)3649 this.settings ['width']= replace_element.offsetWidth;3727 if (this.settings.width == -1) 3728 this.settings.width = replace_element.offsetWidth; 3650 3729 3651 if (this.settings ['height']== -1)3652 this.settings ['height']= replace_element.offsetHeight;3730 if (this.settings.height == -1) 3731 this.settings.height = replace_element.offsetHeight; 3653 3732 3654 3733 // Try the style width 3655 if (this.settings ['width']== 0)3656 this.settings ['width']= replace_element.style.width;3734 if (this.settings.width == 0) 3735 this.settings.width = replace_element.style.width; 3657 3736 3658 3737 // Try the style height 3659 if (this.settings ['height']== 0)3660 this.settings ['height']= replace_element.style.height;3738 if (this.settings.height == 0) 3739 this.settings.height = replace_element.style.height; 3661 3740 3662 3741 // If no width/height then default to 320x240, better than nothing 3663 if (this.settings ['width']== 0)3664 this.settings ['width']= 320;3742 if (this.settings.width == 0) 3743 this.settings.width = 320; 3665 3744 3666 if (this.settings ['height']== 0)3667 this.settings ['height']= 240;3745 if (this.settings.height == 0) 3746 this.settings.height = 240; 3668 3747 3669 this.settings['area_width'] = parseInt(this.settings['width']); 3670 this.settings['area_height'] = parseInt(this.settings['height']); 3671 this.settings['area_width'] += deltaWidth; 3672 this.settings['area_height'] += deltaHeight; 3748 this.settings.area_width = parseInt(this.settings.width); 3749 this.settings.area_height = parseInt(this.settings.height); 3750 this.settings.area_width += deltaWidth; 3751 this.settings.area_height += deltaHeight; 3752 this.settings.width_style = "" + this.settings.width; 3753 this.settings.height_style = "" + this.settings.height; 3673 3754 3674 this.settings['width_style'] = "" + this.settings['width'];3675 this.settings['height_style'] = "" + this.settings['height'];3676 3677 3755 // Special % handling 3678 if (("" + this.settings ['width']).indexOf('%') != -1)3679 this.settings ['area_width']= "100%";3756 if (("" + this.settings.width).indexOf('%') != -1) 3757 this.settings.area_width = "100%"; 3680 3758 else 3681 this.settings ['width_style']+= 'px';3759 this.settings.width_style += 'px'; 3682 3760 3683 if (("" + this.settings ['height']).indexOf('%') != -1)3684 this.settings ['area_height']= "100%";3761 if (("" + this.settings.height).indexOf('%') != -1) 3762 this.settings.area_height = "100%"; 3685 3763 else 3686 this.settings ['height_style']+= 'px';3764 this.settings.height_style += 'px'; 3687 3765 3688 3766 if (("" + replace_element.style.width).indexOf('%') != -1) { 3689 this.settings ['width']= replace_element.style.width;3690 this.settings ['area_width']= "100%";3691 this.settings ['width_style']= "100%";3767 this.settings.width = replace_element.style.width; 3768 this.settings.area_width = "100%"; 3769 this.settings.width_style = "100%"; 3692 3770 } 3693 3771 3694 3772 if (("" + replace_element.style.height).indexOf('%') != -1) { 3695 this.settings ['height']= replace_element.style.height;3696 this.settings ['area_height']= "100%";3697 this.settings ['height_style']= "100%";3773 this.settings.height = replace_element.style.height; 3774 this.settings.area_height = "100%"; 3775 this.settings.height_style = "100%"; 3698 3776 } 3699 3777 3700 3778 html = tinyMCE.applyTemplate(html); 3701 3779 3702 this.settings ['width'] = this.settings['old_width'];3703 this.settings ['height'] = this.settings['old_height'];3780 this.settings.width = this.settings.old_width; 3781 this.settings.height = this.settings.old_height; 3704 3782 3705 this.visualAid = this.settings ['visual'];3783 this.visualAid = this.settings.visual; 3706 3784 this.formTargetElementId = form_element_name; 3707 3785 3708 3786 // Get replace_element contents … … 3716 3794 this.oldTargetElement = replace_element; 3717 3795 3718 3796 // Debug mode 3719 if (tinyMCE.settings['debug']) { 3720 hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>'; 3721 } else { 3722 hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />'; 3723 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); 3724 this.oldTargetElement.style.display = "none"; 3725 } 3797 hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />'; 3798 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); 3799 this.oldTargetElement.style.display = "none"; 3726 3800 3727 3801 html += '</span>'; 3728 3802 … … 3733 3807 3734 3808 // Output HTML and set editable 3735 3809 if (tinyMCE.isGecko) { 3736 varrng = replace_element.ownerDocument.createRange();3810 rng = replace_element.ownerDocument.createRange(); 3737 3811 rng.setStartBefore(replace_element); 3738 3812 3739 varfragment = rng.createContextualFragment(html);3813 fragment = rng.createContextualFragment(html); 3740 3814 tinyMCE.insertAfter(fragment, replace_element); 3741 3815 } else 3742 3816 replace_element.insertAdjacentHTML("beforeBegin", html); … … 3746 3820 // Just hide the textarea element 3747 3821 this.oldTargetElement = replace_element; 3748 3822 3749 if (!tinyMCE.settings['debug']) { 3750 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); 3751 this.oldTargetElement.style.display = "none"; 3752 } 3823 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); 3824 this.oldTargetElement.style.display = "none"; 3753 3825 3754 3826 // Output HTML and set editable 3755 3827 if (tinyMCE.isGecko) { 3756 varrng = replace_element.ownerDocument.createRange();3828 rng = replace_element.ownerDocument.createRange(); 3757 3829 rng.setStartBefore(replace_element); 3758 3830 3759 varfragment = rng.createContextualFragment(html);3831 fragment = rng.createContextualFragment(html); 3760 3832 tinyMCE.insertAfter(fragment, replace_element); 3761 3833 } else 3762 3834 replace_element.insertAdjacentHTML("beforeBegin", html); 3763 3835 } 3764 3836 3765 3837 // Setup iframe 3766 vardynamicIFrame = false;3767 vartElm = targetDoc.getElementById(this.editorId);3838 dynamicIFrame = false; 3839 tElm = targetDoc.getElementById(this.editorId); 3768 3840 3769 3841 if (!tinyMCE.isIE) { 3770 3842 // Node case is preserved in XML strict mode … … 3801 3873 } 3802 3874 3803 3875 // Setup base HTML 3804 vardoc = this.contentDocument;3876 doc = this.contentDocument; 3805 3877 if (dynamicIFrame) { 3806 var html = tinyMCE.getParam('doctype') + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + tinyMCE.settings['base_href']+ '" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';3878 html = tinyMCE.getParam('doctype') + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + tinyMCE.settings.base_href + '" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>'; 3807 3879 3808 3880 try { 3809 3881 if (!this.isHidden()) … … 3824 3896 window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1); 3825 3897 3826 3898 // Setup element references 3827 varparentElm = this.targetDoc.getElementById(this.editorId + '_parent');3899 parentElm = this.targetDoc.getElementById(this.editorId + '_parent'); 3828 3900 this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; 3829 3901 3830 3902 tinyMCE.setupContent(this.editorId, true); … … 3847 3919 b.setAttribute('href', u); 3848 3920 h.appendChild(b); 3849 3921 } else { 3850 if (u == ""|| u == null)3922 if (u == '' || u == null) 3851 3923 b.parentNode.removeChild(b); 3852 3924 else 3853 3925 b.setAttribute('href', u); … … 3886 3958 }, 3887 3959 3888 3960 triggerSave : function(skip_cleanup, skip_callback) { 3889 var e, nl = [], i, s ;3961 var e, nl = [], i, s, content, htm; 3890 3962 3963 if (!this.enabled) 3964 return; 3965 3891 3966 this.switchSettings(); 3892 3967 s = tinyMCE.settings; 3893 3968 … … 3908 3983 } while ((e = e.parentNode) != null) 3909 3984 } 3910 3985 3911 tinyMCE.settings ['preformatted']= false;3986 tinyMCE.settings.preformatted = false; 3912 3987 3913 3988 // Default to false 3914 3989 if (typeof(skip_cleanup) == "undefined") … … 3921 3996 tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML); 3922 3997 3923 3998 // Remove visual aids when cleanup is disabled 3924 if (this.settings ['cleanup']== false) {3999 if (this.settings.cleanup == false) { 3925 4000 tinyMCE.handleVisualAid(this.getBody(), true, false, this); 3926 4001 tinyMCE._setEventsEnabled(this.getBody(), true); 3927 4002 } 3928 4003 3929 4004 tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body); 3930 varhtm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);4005 htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true); 3931 4006 htm = tinyMCE._customCleanup(this, "submit_content", htm); 3932 4007 3933 if (!skip_callback && tinyMCE.settings ['save_callback'] != "")3934 var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());");4008 if (!skip_callback && tinyMCE.settings.save_callback !== '') 4009 content = tinyMCE.resolveDots(tinyMCE.settings.save_callback, window)(this.formTargetElementId,htm,this.getBody()); 3935 4010 3936 4011 // Use callback content if available 3937 4012 if ((typeof(content) != "undefined") && content != null) … … 3963 4038 3964 4039 /* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */ 3965 4040 3966 TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) { 3967 s = s.replace(new RegExp('<p \\/>', 'gi'), '<p> </p>'); 3968 s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p> </p>'); 4041 tinyMCE.add(TinyMCE_Engine, { 4042 cleanupHTMLCode : function(s) { 4043 s = s.replace(new RegExp('<p \\/>', 'gi'), '<p> </p>'); 4044 s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p> </p>'); 3969 4045 3970 // Fix close BR elements3971 s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />');4046 // Fix close BR elements 4047 s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />'); 3972 4048 3973 // Open closed tags like <b/> to <b></b>3974 s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3></$1$2>');4049 // Open closed tags like <b/> to <b></b> 4050 s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3></$1$2>'); 3975 4051 3976 // Remove trailing space <b > to <b>3977 s = s.replace(new RegExp('\\s+></', 'gi'), '></');4052 // Remove trailing space <b > to <b> 4053 s = s.replace(new RegExp('\\s+></', 'gi'), '></'); 3978 4054 3979 // Close tags <img></img> to <img/>3980 s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />');4055 // Close tags <img></img> to <img/> 4056 s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />'); 3981 4057 3982 // Weird MSIE bug, <p><hr /></p> breaks runtime?3983 if (tinyMCE.isIE)3984 s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");4058 // Weird MSIE bug, <p><hr /></p> breaks runtime? 4059 if (tinyMCE.isIE) 4060 s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>"); 3985 4061 3986 // Weird tags will make IE error #bug: 15384953987 if (tinyMCE.isIE)3988 s = s.replace(/<!(\s*)\/>/g, '');4062 // Weird tags will make IE error #bug: 1538495 4063 if (tinyMCE.isIE) 4064 s = s.replace(/<!(\s*)\/>/g, ''); 3989 4065 3990 // Convert relative anchors to absolute URLs ex: #something to file.htm#something3991 // Removed: Since local document anchors should never be forced absolute example edit.php?id=something3992 //if (tinyMCE.getParam('convert_urls'))3993 // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url']+ "#");4066 // Convert relative anchors to absolute URLs ex: #something to file.htm#something 4067 // Removed: Since local document anchors should never be forced absolute example edit.php?id=something 4068 //if (tinyMCE.getParam('convert_urls')) 4069 // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings.document_base_url + "#"); 3994 4070 3995 return s;3996 }; 4071 return s; 4072 }, 3997 4073 3998 TinyMCE_Engine.prototype.parseStyle =function(str) {3999 var ar = new Array();4074 parseStyle : function(str) { 4075 var ar = [], st, i, re, pa; 4000 4076 4001 if (str == null)4002 return ar;4077 if (str == null) 4078 return ar; 4003 4079 4004 varst = str.split(';');4080 st = str.split(';'); 4005 4081 4006 tinyMCE.clearArray(ar);4082 tinyMCE.clearArray(ar); 4007 4083 4008 for (vari=0; i<st.length; i++) {4009 if (st[i] == '')4010 continue;4084 for (i=0; i<st.length; i++) { 4085 if (st[i] == '') 4086 continue; 4011 4087 4012 varre = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');4013 varpa = st[i].replace(re, '$1||$2').split('||');4014 //tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2'));4015 if (pa.length == 2)4016 ar[pa[0].toLowerCase()] = pa[1];4017 }4088 re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$'); 4089 pa = st[i].replace(re, '$1||$2').split('||'); 4090 //tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2')); 4091 if (pa.length == 2) 4092 ar[pa[0].toLowerCase()] = pa[1]; 4093 } 4018 4094 4019 return ar;4020 }; 4095 return ar; 4096 }, 4021 4097 4022 TinyMCE_Engine.prototype.compressStyle =function(ar, pr, sf, res) {4023 var box = new Array();4098 compressStyle : function(ar, pr, sf, res) { 4099 var box = [], i, a; 4024 4100 4025 box[0] = ar[pr + '-top' + sf];4026 box[1] = ar[pr + '-left' + sf];4027 box[2] = ar[pr + '-right' + sf];4028 box[3] = ar[pr + '-bottom' + sf];4101 box[0] = ar[pr + '-top' + sf]; 4102 box[1] = ar[pr + '-left' + sf]; 4103 box[2] = ar[pr + '-right' + sf]; 4104 box[3] = ar[pr + '-bottom' + sf]; 4029 4105 4030 for (vari=0; i<box.length; i++) {4031 if (box[i] == null)4032 return;4106 for (i=0; i<box.length; i++) { 4107 if (box[i] == null) 4108 return; 4033 4109 4034 for (var a=0; a<box.length; a++) { 4035 if (box[a] != box[i]) 4036 return; 4110 for (a=0; a<box.length; a++) { 4111 if (box[a] != box[i]) 4112 return; 4113 } 4037 4114 } 4038 }4039 4115 4040 // They are all the same4041 ar[res] = box[0];4042 ar[pr + '-top' + sf] = null;4043 ar[pr + '-left' + sf] = null;4044 ar[pr + '-right' + sf] = null;4045 ar[pr + '-bottom' + sf] = null;4046 }; 4116 // They are all the same 4117 ar[res] = box[0]; 4118 ar[pr + '-top' + sf] = null; 4119 ar[pr + '-left' + sf] = null; 4120 ar[pr + '-right' + sf] = null; 4121 ar[pr + '-bottom' + sf] = null; 4122 }, 4047 4123 4048 TinyMCE_Engine.prototype.serializeStyle =function(ar) {4049 var str = "";4124 serializeStyle : function(ar) { 4125 var str = "", key, val, m; 4050 4126 4051 // Compress box4052 tinyMCE.compressStyle(ar, "border", "", "border");4053 tinyMCE.compressStyle(ar, "border", "-width", "border-width");4054 tinyMCE.compressStyle(ar, "border", "-color", "border-color");4055 tinyMCE.compressStyle(ar, "border", "-style", "border-style");4056 tinyMCE.compressStyle(ar, "padding", "", "padding");4057 tinyMCE.compressStyle(ar, "margin", "", "margin");4127 // Compress box 4128 tinyMCE.compressStyle(ar, "border", "", "border"); 4129 tinyMCE.compressStyle(ar, "border", "-width", "border-width"); 4130 tinyMCE.compressStyle(ar, "border", "-color", "border-color"); 4131 tinyMCE.compressStyle(ar, "border", "-style", "border-style"); 4132 tinyMCE.compressStyle(ar, "padding", "", "padding"); 4133 tinyMCE.compressStyle(ar, "margin", "", "margin"); 4058 4134 4059 for (varkey in ar) {4060 varval = ar[key];4135 for (key in ar) { 4136 val = ar[key]; 4061 4137 4062 if (typeof(val) == 'function')4063 continue;4138 if (typeof(val) == 'function') 4139 continue; 4064 4140 4065 if (key.indexOf('mso-') == 0)4066 continue;4141 if (key.indexOf('mso-') == 0) 4142 continue; 4067 4143 4068 if (val != null && val != '') {4069 val = '' + val; // Force string4144 if (val != null && val !== '') { 4145 val = '' + val; // Force string 4070 4146 4071 // Fix style URL4072 val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')");4147 // Fix style URL 4148 val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')"); 4073 4149 4074 // Convert URL4075 if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) {4076 varm = new RegExp("url\\('(.*?)'\\)").exec(val);4150 // Convert URL 4151 if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) { 4152 m = new RegExp("url\\('(.*?)'\\)").exec(val); 4077 4153 4078 if (m.length > 1)4079 val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')";4080 }4154 if (m.length > 1) 4155 val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')"; 4156 } 4081 4157 4082 // Force HEX colors4083 if (tinyMCE.getParam("force_hex_style_colors"))4084 val = tinyMCE.convertRGBToHex(val, true);4158 // Force HEX colors 4159 if (tinyMCE.getParam("force_hex_style_colors")) 4160 val = tinyMCE.convertRGBToHex(val, true); 4085 4161 4086 val = val.replace(/\"/g, '\'');4162 val = val.replace(/\"/g, '\''); 4087 4163 4088 if (val != "url('')") 4089 str += key.toLowerCase() + ": " + val + "; "; 4164 if (val != "url('')") 4165 str += key.toLowerCase() + ": " + val + "; "; 4166 } 4090 4167 } 4091 }4092 4168 4093 if (new RegExp('; $').test(str))4094 str = str.substring(0, str.length - 2);4169 if (new RegExp('; $').test(str)) 4170 str = str.substring(0, str.length - 2); 4095 4171 4096 return str;4097 }; 4172 return str; 4173 }, 4098 4174 4099 TinyMCE_Engine.prototype.convertRGBToHex = function(s, k) { 4100 if (s.toLowerCase().indexOf('rgb') != -1) { 4101 var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); 4102 var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); 4103 if (rgb.length == 5) { 4104 r = parseInt(rgb[1]).toString(16); 4105 g = parseInt(rgb[2]).toString(16); 4106 b = parseInt(rgb[3]).toString(16); 4175 convertRGBToHex : function(s, k) { 4176 var re, rgb; 4107 4177 4108 r = r.length == 1 ? '0' + r : r;4109 g = g.length == 1 ? '0' + g : g;4110 b = b.length == 1 ? '0' + b : b;4178 if (s.toLowerCase().indexOf('rgb') != -1) { 4179 re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); 4180 rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); 4111 4181 4112 s = "#" + r + g + b; 4182 if (rgb.length == 5) { 4183 r = parseInt(rgb[1]).toString(16); 4184 g = parseInt(rgb[2]).toString(16); 4185 b = parseInt(rgb[3]).toString(16); 4113 4186 4114 if (k) 4115 s = rgb[0] + s + rgb[4]; 4187 r = r.length == 1 ? '0' + r : r; 4188 g = g.length == 1 ? '0' + g : g; 4189 b = b.length == 1 ? '0' + b : b; 4190 4191 s = "#" + r + g + b; 4192 4193 if (k) 4194 s = rgb[0] + s + rgb[4]; 4195 } 4116 4196 } 4117 }4118 4197 4119 return s;4120 }; 4198 return s; 4199 }, 4121 4200 4122 TinyMCE_Engine.prototype.convertHexToRGB =function(s) {4123 if (s.indexOf('#') != -1) {4124 s = s.replace(new RegExp('[^0-9A-F]', 'gi'), '');4125 return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")";4126 }4201 convertHexToRGB : function(s) { 4202 if (s.indexOf('#') != -1) { 4203 s = s.replace(new RegExp('[^0-9A-F]', 'gi'), ''); 4204 return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")"; 4205 } 4127 4206 4128 return s;4129 }; 4207 return s; 4208 }, 4130 4209 4131 TinyMCE_Engine.prototype.convertSpansToFonts =function(doc) {4132 varsizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');4210 convertSpansToFonts : function(doc) { 4211 var s, i, size, fSize, x, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); 4133 4212 4134 /*var h = doc.body.innerHTML;4135 h = h.replace(/<span/gi, '<font');4136 h = h.replace(/<\/span/gi, '</font');4137 tinyMCE.setInnerHTML(doc.body, h);*/4213 s = tinyMCE.selectElements(doc, 'span,font'); 4214 for (i=0; i<s.length; i++) { 4215 size = tinyMCE.trim(s[i].style.fontSize).toLowerCase(); 4216 fSize = 0; 4138 4217 4139 var s = tinyMCE.selectElements(doc, 'span,font'); 4140 for (var i=0; i<s.length; i++) { 4141 var size = tinyMCE.trim(s[i].style.fontSize).toLowerCase(); 4142 var fSize = 0; 4218 for (x=0; x<sizes.length; x++) { 4219 if (sizes[x] == size) { 4220 fSize = x + 1; 4221 break; 4222 } 4223 } 4143 4224 4144 for (var x=0; x<sizes.length; x++) { 4145 if (sizes[x] == size) { 4146 fSize = x + 1; 4147 break; 4225 if (fSize > 0) { 4226 tinyMCE.setAttrib(s[i], 'size', fSize); 4227 s[i].style.fontSize = ''; 4148 4228 } 4149 }4150 4229 4151 if (fSize > 0) { 4152 tinyMCE.setAttrib(s[i], 'size', fSize); 4153 s[i].style.fontSize = ''; 4154 } 4230 fFace = s[i].style.fontFamily; 4231 if (fFace != null && fFace !== '') { 4232 tinyMCE.setAttrib(s[i], 'face', fFace); 4233 s[i].style.fontFamily = ''; 4234 } 4155 4235 4156 var fFace = s[i].style.fontFamily; 4157 if (fFace != null && fFace != "") { 4158 tinyMCE.setAttrib(s[i], 'face', fFace); 4159 s[i].style.fontFamily = ''; 4236 fColor = s[i].style.color; 4237 if (fColor != null && fColor !== '') { 4238 tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); 4239 s[i].style.color = ''; 4240 } 4160 4241 } 4242 }, 4161 4243 4162 var fColor = s[i].style.color; 4163 if (fColor != null && fColor != "") { 4164 tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); 4165 s[i].style.color = ''; 4166 } 4167 } 4168 }; 4244 convertFontsToSpans : function(doc) { 4245 var fsClasses, s, i, fSize, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); 4169 4246 4170 TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) { 4171 var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); 4247 fsClasses = tinyMCE.getParam('font_size_classes'); 4248 if (fsClasses !== '') 4249 fsClasses = fsClasses.replace(/\s+/, '').split(','); 4250 else 4251 fsClasses = null; 4172 4252 4173 /* var h = doc.body.innerHTML; 4174 h = h.replace(/<font/gi, '<span'); 4175 h = h.replace(/<\/font/gi, '</span'); 4176 tinyMCE.setInnerHTML(doc.body, h);*/ 4253 s = tinyMCE.selectElements(doc, 'span,font'); 4254 for (i=0; i<s.length; i++) { 4255 fSize = tinyMCE.getAttrib(s[i], 'size'); 4256 fFace = tinyMCE.getAttrib(s[i], 'face'); 4257 fColor = tinyMCE.getAttrib(s[i], 'color'); 4177 4258 4178 var fsClasses = tinyMCE.getParam('font_size_classes'); 4179 if (fsClasses != '') 4180 fsClasses = fsClasses.replace(/\s+/, '').split(','); 4181 else 4182 fsClasses = null; 4259 if (fSize !== '') { 4260 fSize = parseInt(fSize); 4183 4261 4184 var s = tinyMCE.selectElements(doc, 'span,font'); 4185 for (var i=0; i<s.length; i++) { 4186 var fSize, fFace, fColor; 4262 if (fSize > 0 && fSize < 8) { 4263 if (fsClasses != null) 4264 tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); 4265 else 4266 s[i].style.fontSize = sizes[fSize-1]; 4267 } 4187 4268 4188 fSize = tinyMCE.getAttrib(s[i], 'size'); 4189 fFace = tinyMCE.getAttrib(s[i], 'face'); 4190 fColor = tinyMCE.getAttrib(s[i], 'color'); 4269 s[i].removeAttribute('size'); 4270 } 4191 4271 4192 if (fSize != "") { 4193 fSize = parseInt(fSize); 4272 if (fFace !== '') { 4273 s[i].style.fontFamily = fFace; 4274 s[i].removeAttribute('face'); 4275 } 4194 4276 4195 if (fSize > 0 && fSize < 8) { 4196 if (fsClasses != null) 4197 tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); 4198 else 4199 s[i].style.fontSize = sizes[fSize-1]; 4277 if (fColor !== '') { 4278 s[i].style.color = fColor; 4279 s[i].removeAttribute('color'); 4200 4280 } 4201 4202 s[i].removeAttribute('size');4203 4281 } 4282 }, 4204 4283 4205 if (fFace != "") { 4206 s[i].style.fontFamily = fFace; 4207 s[i].removeAttribute('face'); 4208 } 4284 cleanupAnchors : function(doc) { 4285 var i, cn, x, an = doc.getElementsByTagName("a"); 4209 4286 4210 if (fColor != "") { 4211 s[i].style.color = fColor; 4212 s[i].removeAttribute('color'); 4213 } 4214 } 4215 }; 4287 // Loops backwards due to bug #1467987 4288 for (i=an.length-1; i>=0; i--) { 4289 if (tinyMCE.getAttrib(an[i], "name") !== '' && tinyMCE.getAttrib(an[i], "href") == '') { 4290 cn = an[i].childNodes; 4216 4291 4217 TinyMCE_Engine.prototype.cleanupAnchors = function(doc) { 4218 var i, cn, x, an = doc.getElementsByTagName("a"); 4219 4220 // Loops backwards due to bug #1467987 4221 for (i=an.length-1; i>=0; i--) { 4222 if (tinyMCE.getAttrib(an[i], "name") != "" && tinyMCE.getAttrib(an[i], "href") == "") { 4223 cn = an[i].childNodes; 4224 4225 for (x=cn.length-1; x>=0; x--) 4226 tinyMCE.insertAfter(cn[x], an[i]); 4292 for (x=cn.length-1; x>=0; x--) 4293 tinyMCE.insertAfter(cn[x], an[i]); 4294 } 4227 4295 } 4228 } 4229 }; 4296 }, 4230 4297 4231 TinyMCE_Engine.prototype.getContent =function(editor_id) {4232 if (typeof(editor_id) != "undefined")4233 tinyMCE.getInstanceById(editor_id).select();4298 getContent : function(editor_id) { 4299 if (typeof(editor_id) != "undefined") 4300 tinyMCE.getInstanceById(editor_id).select(); 4234 4301 4235 if (tinyMCE.selectedInstance)4236 return tinyMCE.selectedInstance.getHTML();4302 if (tinyMCE.selectedInstance) 4303 return tinyMCE.selectedInstance.getHTML(); 4237 4304 4238 return null;4239 }; 4305 return null; 4306 }, 4240 4307 4241 TinyMCE_Engine.prototype._fixListElements =function(d) {4242 var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np;4308 _fixListElements : function(d) { 4309 var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np; 4243 4310 4244 for (x=0; x<a.length; x++) {4245 nl = d.getElementsByTagName(a[x]);4311 for (x=0; x<a.length; x++) { 4312 nl = d.getElementsByTagName(a[x]); 4246 4313 4247 for (i=0; i<nl.length; i++) {4248 n = nl[i];4249 p = n.parentNode;4314 for (i=0; i<nl.length; i++) { 4315 n = nl[i]; 4316 p = n.parentNode; 4250 4317 4251 if (r.test(p.nodeName)) {4252 np = tinyMCE.prevNode(n, 'LI');4318 if (r.test(p.nodeName)) { 4319 np = tinyMCE.prevNode(n, 'LI'); 4253 4320 4254 if (!np) { 4255 np = d.createElement('li'); 4256 np.innerHTML = ' '; 4257 np.appendChild(n); 4258 p.insertBefore(np, p.firstChild); 4259 } else 4260 np.appendChild(n); 4321 if (!np) { 4322 np = d.createElement('li'); 4323 np.innerHTML = ' '; 4324 np.appendChild(n); 4325 p.insertBefore(np, p.firstChild); 4326 } else 4327 np.appendChild(n); 4328 } 4261 4329 } 4262 4330 } 4263 } 4264 }; 4331 }, 4265 4332 4266 TinyMCE_Engine.prototype._fixTables =function(d) {4267 var nl, i, n, p, np, x, t;4333 _fixTables : function(d) { 4334 var nl, i, n, p, np, x, t; 4268 4335 4269 nl = d.getElementsByTagName('table');4270 for (i=0; i<nl.length; i++) {4271 n = nl[i];4336 nl = d.getElementsByTagName('table'); 4337 for (i=0; i<nl.length; i++) { 4338 n = nl[i]; 4272 4339 4273 if ((p = tinyMCE.getParentElement(n, 'p,h1,h2,h3,h4,h5,h6')) != null) {4274 np = p.cloneNode(false);4275 np.removeAttribute('id');4340 if ((p = tinyMCE.getParentElement(n, 'p,h1,h2,h3,h4,h5,h6')) != null) { 4341 np = p.cloneNode(false); 4342 np.removeAttribute('id'); 4276 4343 4277 t = n;4344 t = n; 4278 4345 4279 while ((n = n.nextSibling))4280 np.appendChild(n);4346 while ((n = n.nextSibling)) 4347 np.appendChild(n); 4281 4348 4282 tinyMCE.insertAfter(np, p); 4283 tinyMCE.insertAfter(t, p); 4349 tinyMCE.insertAfter(np, p); 4350 tinyMCE.insertAfter(t, p); 4351 } 4284 4352 } 4285 } 4286 }; 4353 }, 4287 4354 4288 TinyMCE_Engine.prototype._cleanupHTML =function(inst, doc, config, elm, visual, on_save, on_submit, inn) {4289 var h, d, t1, t2, t3, t4, t5, c, s, nb;4355 _cleanupHTML : function(inst, doc, config, elm, visual, on_save, on_submit, inn) { 4356 var h, d, t1, t2, t3, t4, t5, c, s, nb; 4290 4357 4291 if (!tinyMCE.getParam('cleanup'))4292 return elm.innerHTML;4358 if (!tinyMCE.getParam('cleanup')) 4359 return elm.innerHTML; 4293 4360 4294 on_save = typeof(on_save) == 'undefined' ? false : on_save;4361 on_save = typeof(on_save) == 'undefined' ? false : on_save; 4295 4362 4296 c = inst.cleanup;4297 s = inst.settings;4298 d = c.settings.debug;4363 c = inst.cleanup; 4364 s = inst.settings; 4365 d = c.settings.debug; 4299 4366 4300 if (d)4301 t1 = new Date().getTime();4367 if (d) 4368 t1 = new Date().getTime(); 4302 4369 4303 if (tinyMCE.getParam("convert_fonts_to_spans")) 4304 tinyMCE.convertFontsToSpans(doc); 4370 inst._fixRootBlocks(); 4305 4371 4306 if (tinyMCE.getParam("fix_list_elements"))4307 tinyMCE._fixListElements(doc);4372 if (tinyMCE.getParam("convert_fonts_to_spans")) 4373 tinyMCE.convertFontsToSpans(doc); 4308 4374 4309 if (tinyMCE.getParam("fix_table_elements"))4310 tinyMCE._fixTables(doc);4375 if (tinyMCE.getParam("fix_list_elements")) 4376 tinyMCE._fixListElements(doc); 4311 4377 4312 // Call custom cleanup code4313 tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);4378 if (tinyMCE.getParam("fix_table_elements")) 4379 tinyMCE._fixTables(doc); 4314 4380 4315 if (d)4316 t 2 = new Date().getTime();4381 // Call custom cleanup code 4382 tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body); 4317 4383 4318 c.settings.on_save = on_save;4319 //for (var i=0; i<100; i++)4384 if (d) 4385 t2 = new Date().getTime(); 4320 4386 4321 c.idCount = 0; 4322 c.serializationId++; 4323 c.serializedNodes = new Array(); 4324 c.sourceIndex = -1; 4387 c.settings.on_save = on_save; 4325 4388 4326 if (s.cleanup_serializer == "xml")4327 h = c.serializeNodeAsXML(elm, inn);4328 else4329 h = c.serializeNodeAsHTML(elm, inn);4389 c.idCount = 0; 4390 c.serializationId = new Date().getTime().toString(32); // Unique ID needed for the content duplication bug 4391 c.serializedNodes = []; 4392 c.sourceIndex = -1; 4330 4393 4331 if (d) 4332 t3 = new Date().getTime(); 4394 if (s.cleanup_serializer == "xml") 4395 h = c.serializeNodeAsXML(elm, inn); 4396 else 4397 h = c.serializeNodeAsHTML(elm, inn); 4333 4398 4334 // Post processing 4335 nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? ' ' : ' '; 4336 h = h.replace(/<\/?(body|head|html)[^>]*>/gi, ''); 4337 h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), ''); 4338 h = h.replace(/<p><hr \/><\/p>/g, '<hr />'); 4339 h = h.replace(/<p>( | )<\/p><hr \/><p>( | )<\/p>/g, '<hr />'); 4340 h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>'); 4341 h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>'); 4342 h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko 4343 h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko 4344 h = h.replace(/<p>\s*( | )\s*<br \/>\s*( | )\s*<\/p>/g, '<p>' + nb + '</p>'); 4345 h = h.replace(/<p>\s*( | )\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>'); 4346 h = h.replace(/<p>\s*<br \/>\s* \s*<\/p>/g, '<p>' + nb + '</p>'); 4347 h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1'); 4348 h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>'); 4399 if (d) 4400 t3 = new Date().getTime(); 4349 4401 4350 // Clean body 4351 if (/^\s*(<br \/>|<p> <\/p>|<p> <\/p>|<p><\/p>)\s*$/.test(h)) 4352 h = ''; 4402 // Post processing 4403 nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? ' ' : ' '; 4404 h = h.replace(/<\/?(body|head|html)[^>]*>/gi, ''); 4405 h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), ''); 4406 h = h.replace(/<p><hr \/><\/p>/g, '<hr />'); 4407 h = h.replace(/<p>( | )<\/p><hr \/><p>( | )<\/p>/g, '<hr />'); 4408 h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>'); 4409 h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>'); 4410 h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko 4411 h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko 4412 h = h.replace(/<p>\s*( | )\s*<br \/>\s*( | )\s*<\/p>/g, '<p>' + nb + '</p>'); 4413 h = h.replace(/<p>\s*( | )\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>'); 4414 h = h.replace(/<p>\s*<br \/>\s* \s*<\/p>/g, '<p>' + nb + '</p>'); 4415 h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1'); 4416 h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>'); 4353 4417 4354 // If preformatted 4355 if (s.preformatted) { 4356 h = h.replace(/^<pre>/, ''); 4357 h = h.replace(/<\/pre>$/, ''); 4358 h = '<pre>' + h + '</pre>'; 4359 } 4418 // Clean body 4419 if (/^\s*(<br \/>|<p> <\/p>|<p> <\/p>|<p><\/p>)\s*$/.test(h)) 4420 h = ''; 4360 4421 4361 // Gecko specific processing 4362 if (tinyMCE.isGecko) { 4363 h = h.replace(/<o:p _moz-userdefined="" \/>/g, ''); 4364 h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>'); 4365 } 4422 // If preformatted 4423 if (s.preformatted) { 4424 h = h.replace(/^<pre>/, ''); 4425 h = h.replace(/<\/pre>$/, ''); 4426 h = '<pre>' + h + '</pre>'; 4427 } 4366 4428 4367 if (s.force_br_newlines) 4368 h = h.replace(/<p>( | )<\/p>/g, '<br />'); 4429 // Gecko specific processing 4430 if (tinyMCE.isGecko) { 4431 // Makes no sence but FF generates it!! 4432 h = h.replace(/<br \/>\s*<\/li>/g, '</li>'); 4433 h = h.replace(/ \s*<\/(dd|dt)>/g, '</$1>'); 4434 h = h.replace(/<o:p _moz-userdefined="" \/>/g, ''); 4435 h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>'); 4436 } 4369 4437 4370 // Call custom cleanup code4371 h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h);4438 if (s.force_br_newlines) 4439 h = h.replace(/<p>( | )<\/p>/g, '<br />'); 4372 4440 4373 // Remove internal classes 4374 if (on_save) { 4375 h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), ''); 4376 h = h.replace(new RegExp(' ?class=""', 'g'), ''); 4377 } 4441 // Call custom cleanup code 4442 h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h); 4378 4443 4379 if (s.remove_linebreaks && !c.settings.indent) 4380 h = h.replace(/\n|\r/g, ' '); 4444 // Remove internal classes 4445 if (on_save) { 4446 h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), ''); 4447 h = h.replace(new RegExp(' ?class=""', 'g'), ''); 4448 } 4381 4449 4382 if (d)4383 t4 = new Date().getTime();4450 if (s.remove_linebreaks && !c.settings.indent) 4451 h = h.replace(/\n|\r/g, ' '); 4384 4452 4385 if (on_save && c.settings.indent)4386 h = c.formatHTML(h);4453 if (d) 4454 t4 = new Date().getTime(); 4387 4455 4388 // If encoding (not recommended option) 4389 if (on_submit && (s.encoding == "xml" || s.encoding == "html")) 4390 h = c.xmlEncode(h); 4456 if (on_save && c.settings.indent) 4457 h = c.formatHTML(h); 4391 4458 4392 if (d) 4393 t5 = new Date().getTime(); 4459 // If encoding (not recommended option) 4460 if (on_submit && (s.encoding == "xml" || s.encoding == "html")) 4461 h = c.xmlEncode(h); 4394 4462 4395 if (c.settings.debug)4396 tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + ".");4463 if (d) 4464 t5 = new Date().getTime(); 4397 4465 4398 return h;4399 };4466 if (c.settings.debug) 4467 tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + "."); 4400 4468 4469 return h; 4470 } 4471 }); 4472 4401 4473 function TinyMCE_Cleanup() { 4402 4474 this.isIE = (navigator.appName == "Microsoft Internet Explorer"); 4403 this.rules = tinyMCE.clearArray( new Array());4475 this.rules = tinyMCE.clearArray([]); 4404 4476 4405 4477 // Default config 4406 4478 this.settings = { … … 4418 4490 verify_html : false 4419 4491 }; 4420 4492 4421 this.vElements = tinyMCE.clearArray( new Array());4493 this.vElements = tinyMCE.clearArray([]); 4422 4494 this.vElementsRe = ''; 4423 4495 this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/; 4424 4496 this.codeElementsRe = /^(SCRIPT|STYLE)$/; … … 4448 4520 this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>'); 4449 4521 this.serializedNodes = []; 4450 4522 4451 if (s.invalid_elements != '')4523 if (s.invalid_elements !== '') 4452 4524 this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$'); 4453 4525 else 4454 4526 this.iveRe = null; … … 4469 4541 this.fillStr = s.entity_encoding == "named" ? " " : " "; 4470 4542 this.idCount = 0; 4471 4543 this.xmlEncodeRe = new RegExp('[\u007F-\uFFFF<>&"]', 'g'); 4472 this.xmlEncodeAposRe = new RegExp('[\u007F-\uFFFF<>&"\']', 'g');4473 4544 }, 4474 4545 4475 4546 addRuleStr : function(s) { 4476 var r = this.parseRuleStr(s); 4477 var n; 4547 var r = this.parseRuleStr(s), n; 4478 4548 4479 4549 for (n in r) { 4480 4550 if (r[n]) 4481 4551 this.rules[n] = r[n]; 4482 4552 } 4483 4553 4484 this.vElements = tinyMCE.clearArray( new Array());4554 this.vElements = tinyMCE.clearArray([]); 4485 4555 4486 4556 for (n in this.rules) { 4487 4557 if (this.rules[n]) … … 4492 4562 }, 4493 4563 4494 4564 isValid : function(n) { 4495 this._setupRules(); // Will initialize cleanup rules 4565 if (!this.rulesDone) 4566 this._setupRules(); // Will initialize cleanup rules 4496 4567 4497 4568 // Empty is true since it removes formatting 4498 4569 if (!n) … … 4548 4619 } 4549 4620 4550 4621 r += ')$'; 4551 //tinyMCE.debug(t + "=" + r); 4622 4552 4623 if (this.childRules == null) 4553 this.childRules = tinyMCE.clearArray( new Array());4624 this.childRules = tinyMCE.clearArray([]); 4554 4625 4555 4626 this.childRules[tn[y]] = new RegExp(r); 4556 4627 … … 4561 4632 }, 4562 4633 4563 4634 parseRuleStr : function(s) { 4564 var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray( new Array()), dv;4635 var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray([]), dv; 4565 4636 4566 4637 if (s == null || s.length == 0) 4567 4638 return or; … … 4621 4692 if (av && av.length > 0) { 4622 4693 if (av[0].charAt(0) == ':') { 4623 4694 if (!r.forceAttribs) 4624 r.forceAttribs = tinyMCE.clearArray( new Array());4695 r.forceAttribs = tinyMCE.clearArray([]); 4625 4696 4626 4697 r.forceAttribs[t.toLowerCase()] = av[0].substring(1); 4627 4698 } else if (av[0].charAt(0) == '=') { 4628 4699 if (!r.defaultAttribs) 4629 r.defaultAttribs = tinyMCE.clearArray( new Array());4700 r.defaultAttribs = tinyMCE.clearArray([]); 4630 4701 4631 4702 dv = av[0].substring(1); 4632 4703 4633 r.defaultAttribs[t.toLowerCase()] = dv == ""? "mce_empty" : dv;4704 r.defaultAttribs[t.toLowerCase()] = dv == '' ? "mce_empty" : dv; 4634 4705 } else if (av[0].charAt(0) == '<') { 4635 4706 if (!r.validAttribValues) 4636 r.validAttribValues = tinyMCE.clearArray( new Array());4707 r.validAttribValues = tinyMCE.clearArray([]); 4637 4708 4638 4709 r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i'); 4639 4710 } … … 4656 4727 //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC); 4657 4728 } else { 4658 4729 r.vAttribsRe = ''; 4659 r.vAttribs = tinyMCE.clearArray( new Array());4730 r.vAttribs = tinyMCE.clearArray([]); 4660 4731 r.vAttribsReIsWild = false; 4661 4732 } 4662 4733 … … 4745 4816 serializeNodeAsHTML : function(n, inn) { 4746 4817 var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr, nn; 4747 4818 4748 this._setupRules(); // Will initialize cleanup rules 4819 if (!this.rulesDone) 4820 this._setupRules(); // Will initialize cleanup rules 4749 4821 4750 4822 if (tinyMCE.isRealIE && this._isDuplicate(n)) 4751 4823 return ''; … … 4767 4839 if (st) 4768 4840 break; 4769 4841 4770 // MSIE sometimes produces <//tag>4771 if ((tinyMCE.isRealIE) && n.nodeName.indexOf('/') != -1)4772 break;4773 4774 4842 nn = n.nodeName; 4775 4843 4844 if (tinyMCE.isRealIE) { 4845 // MSIE sometimes produces <//tag> 4846 if (n.nodeName.indexOf('/') != -1) 4847 break; 4848 4849 // MSIE has it's NS in a separate attrib 4850 if (n.scopeName && n.scopeName != 'HTML') 4851 nn = n.scopeName.toUpperCase() + ':' + nn.toUpperCase(); 4852 } else if (tinyMCE.isOpera && nn.indexOf(':') > 0) 4853 nn = nn.toUpperCase(); 4854 4776 4855 // Convert fonts to spans 4777 4856 if (this.settings.convert_fonts_to_spans) { 4778 4857 // On get content FONT -> SPAN … … 4959 5038 return o; 4960 5039 }, 4961 5040 4962 xmlEncode : function(s , skip_apos) {4963 var cl = this, re = !skip_apos ? this.xmlEncodeAposRe :this.xmlEncodeRe;5041 xmlEncode : function(s) { 5042 var cl = this, re = this.xmlEncodeRe; 4964 5043 4965 this._setupEntities(); // Will intialize lookup table 5044 if (!this.entitiesDone) 5045 this._setupEntities(); // Will intialize lookup table 4966 5046 4967 5047 switch (this.settings.entity_encoding) { 4968 5048 case "raw": 4969 return tinyMCE.xmlEncode(s , skip_apos);5049 return tinyMCE.xmlEncode(s); 4970 5050 4971 5051 case "named": 4972 return s.replace(re, function (c , b) {4973 b = cl.entities[c.charCodeAt(0)];5052 return s.replace(re, function (c) { 5053 var b = cl.entities[c.charCodeAt(0)]; 4974 5054 4975 5055 return b ? '&' + b + ';' : c; 4976 5056 }); 4977 5057 4978 5058 case "numeric": 4979 return s.replace(re, function (c , b) {4980 return b ? '&#' + c.charCodeAt(0) + ';' : c;5059 return s.replace(re, function (c) { 5060 return '&#' + c.charCodeAt(0) + ';'; 4981 5061 }); 4982 5062 } 4983 5063 … … 4985 5065 }, 4986 5066 4987 5067 split : function(re, s) { 4988 var c = s.split(re); 4989 var i, l, o = new Array(); 5068 var i, l, o = [], c = s.split(re); 4990 5069 4991 5070 for (i=0, l=c.length; i<l; i++) { 4992 if (c[i] != '')5071 if (c[i] !== '') 4993 5072 o[i] = c[i]; 4994 5073 } 4995 5074 … … 5038 5117 5039 5118 if (nn == "INPUT" && n == "maxlength" && v == "2147483647") 5040 5119 v = ""; 5120 5121 // Images 5122 if (n == "width" || n == "height") 5123 v = e.getAttribute(n, 2); 5041 5124 } 5042 5125 5043 5126 if (n == 'style' && v) { … … 5047 5130 v = tinyMCE.serializeStyle(tinyMCE.parseStyle(v)); 5048 5131 } 5049 5132 5050 if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v != "")5133 if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v !== '') 5051 5134 v = tinyMCE.cleanupEventStr(v); 5052 5135 5053 return (v && v != "") ? '' + v : d;5136 return (v && v !== '') ? '' + v : d; 5054 5137 }, 5055 5138 5056 5139 _urlConverter : function(c, n, v) { … … 5095 5178 var n, a, i, s = this.settings; 5096 5179 5097 5180 // Setup entities 5098 if (!this.entitiesDone) { 5099 if (s.entity_encoding == "named") { 5100 n = tinyMCE.clearArray(new Array()); 5101 a = this.split(',', s.entities); 5102 for (i=0; i<a.length; i+=2) 5103 n[a[i]] = a[i+1]; 5181 if (s.entity_encoding == "named") { 5182 n = tinyMCE.clearArray([]); 5183 a = this.split(',', s.entities); 5184 for (i=0; i<a.length; i+=2) 5185 n[a[i]] = a[i+1]; 5104 5186 5105 5106 5187 this.entities = n; 5188 } 5107 5189 5108 this.entitiesDone = true; 5109 } 5190 this.entitiesDone = true; 5110 5191 }, 5111 5192 5112 5193 _setupRules : function() { 5113 5194 var s = this.settings; 5114 5195 5115 5196 // Setup default rule 5116 if (!this.rulesDone) { 5117 this.addRuleStr(s.valid_elements); 5118 this.addRuleStr(s.extended_valid_elements); 5119 this.addChildRemoveRuleStr(s.valid_child_elements); 5197 this.addRuleStr(s.valid_elements); 5198 this.addRuleStr(s.extended_valid_elements); 5199 this.addChildRemoveRuleStr(s.valid_child_elements); 5120 5200 5121 this.rulesDone = true; 5122 } 5201 this.rulesDone = true; 5123 5202 }, 5124 5203 5125 5204 _isDuplicate : function(n) { 5126 var i ;5205 var i, l, sn; 5127 5206 5128 5207 if (!this.settings.fix_content_duplication) 5129 5208 return false; … … 5135 5214 5136 5215 n.setAttribute('mce_serialized', this.serializationId); 5137 5216 } else { 5217 sn = this.serializedNodes; 5218 5138 5219 // Search lookup table for text nodes and comments 5139 for (i=0 ; i<this.serializedNodes.length; i++) {5140 if ( this.serializedNodes[i] == n)5220 for (i=0, l = sn.length; i<l; i++) { 5221 if (sn[i] == n) 5141 5222 return true; 5142 5223 } 5143 5224 5144 this.serializedNodes[this.serializedNodes.length] = n;5225 sn.push(n); 5145 5226 } 5146 5227 5147 5228 return false; … … 5151 5232 5152 5233 /* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */ 5153 5234 5154 TinyMCE_Engine.prototype.createTagHTML = function(tn, a, h) { 5155 var o = '', f = tinyMCE.xmlEncode; 5235 tinyMCE.add(TinyMCE_Engine, { 5236 createTagHTML : function(tn, a, h) { 5237 var o = '', f = tinyMCE.xmlEncode, n; 5156 5238 5157 o = '<' + tn;5239 o = '<' + tn; 5158 5240 5159 if (a) { 5160 for (n in a) { 5161 if (typeof(a[n]) != 'function' && a[n] != null) 5162 o += ' ' + f(n) + '="' + f('' + a[n]) + '"'; 5241 if (a) { 5242 for (n in a) { 5243 if (typeof(a[n]) != 'function' && a[n] != null) 5244 o += ' ' + f(n) + '="' + f('' + a[n]) + '"'; 5245 } 5163 5246 } 5164 }5165 5247 5166 o += !h ? ' />' : '>' + h + '</' + tn + '>';5248 o += !h ? ' />' : '>' + h + '</' + tn + '>'; 5167 5249 5168 return o;5169 }; 5250 return o; 5251 }, 5170 5252 5171 TinyMCE_Engine.prototype.createTag =function(d, tn, a, h) {5172 var o = d.createElement(tn);5253 createTag : function(d, tn, a, h) { 5254 var o = d.createElement(tn), n; 5173 5255 5174 if (a) { 5175 for (n in a) { 5176 if (typeof(a[n]) != 'function' && a[n] != null) 5177 tinyMCE.setAttrib(o, n, a[n]); 5256 if (a) { 5257 for (n in a) { 5258 if (typeof(a[n]) != 'function' && a[n] != null) 5259 tinyMCE.setAttrib(o, n, a[n]); 5260 } 5178 5261 } 5179 }5180 5262 5181 if (h)5182 o.innerHTML = h;5263 if (h) 5264 o.innerHTML = h; 5183 5265 5184 return o;5185 }; 5266 return o; 5267 }, 5186 5268 5187 TinyMCE_Engine.prototype.getElementByAttributeValue =function(n, e, a, v) {5188 return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];5189 }; 5269 getElementByAttributeValue : function(n, e, a, v) { 5270 return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0]; 5271 }, 5190 5272 5191 TinyMCE_Engine.prototype.getElementsByAttributeValue =function(n, e, a, v) {5192 var i, nl = n.getElementsByTagName(e), o = new Array();5273 getElementsByAttributeValue : function(n, e, a, v) { 5274 var i, nl = n.getElementsByTagName(e), o = []; 5193 5275 5194 for (i=0; i<nl.length; i++) {5195 if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)5196 o[o.length] = nl[i];5197 }5276 for (i=0; i<nl.length; i++) { 5277 if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1) 5278 o[o.length] = nl[i]; 5279 } 5198 5280 5199 return o;5200 }; 5281 return o; 5282 }, 5201 5283 5202 TinyMCE_Engine.prototype.isBlockElement =function(n) {5203 return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);5204 }; 5284 isBlockElement : function(n) { 5285 return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName); 5286 }, 5205 5287 5206 TinyMCE_Engine.prototype.getParentBlockElement =function(n, r) {5207 return this.getParentNode(n, function(n) {5208 return tinyMCE.isBlockElement(n);5209 }, r);5288 getParentBlockElement : function(n, r) { 5289 return this.getParentNode(n, function(n) { 5290 return tinyMCE.isBlockElement(n); 5291 }, r); 5210 5292 5211 return null;5212 }; 5293 return null; 5294 }, 5213 5295 5214 TinyMCE_Engine.prototype.insertAfter =function(n, r){5215 if (r.nextSibling)5216 r.parentNode.insertBefore(n, r.nextSibling);5217 else5218 r.parentNode.appendChild(n);5219 }; 5296 insertAfter : function(n, r){ 5297 if (r.nextSibling) 5298 r.parentNode.insertBefore(n, r.nextSibling); 5299 else 5300 r.parentNode.appendChild(n); 5301 }, 5220 5302 5221 TinyMCE_Engine.prototype.setInnerHTML =function(e, h) {5222 var i, nl, n;5303 setInnerHTML : function(e, h) { 5304 var i, nl, n; 5223 5305 5224 // Convert all strong/em to b/i in Gecko5225 if (tinyMCE.isGecko) {5226 h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>');5227 h = h.replace(/<em([^>]*)>/gi, '<i$1>');5228 h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>');5229 h = h.replace(/<strong([^>]*)>/gi, '<b$1>');5230 h = h.replace(/<\/strong>/gi, '</b>');5231 h = h.replace(/<\/em>/gi, '</i>');5232 }5306 // Convert all strong/em to b/i in Gecko 5307 if (tinyMCE.isGecko) { 5308 h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>'); 5309 h = h.replace(/<em([^>]*)>/gi, '<i$1>'); 5310 h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>'); 5311 h = h.replace(/<strong([^>]*)>/gi, '<b$1>'); 5312 h = h.replace(/<\/strong>/gi, '</b>'); 5313 h = h.replace(/<\/em>/gi, '</i>'); 5314 } 5233 5315 5234 if (tinyMCE.isRealIE) {5235 // Since MSIE handles invalid HTML better that valid XHTML we5236 // need to make some things invalid. <hr /> gets converted to <hr>.5237 h = h.replace(/\s\/>/g, '>');5316 if (tinyMCE.isRealIE) { 5317 // Since MSIE handles invalid HTML better that valid XHTML we 5318 // need to make some things invalid. <hr /> gets converted to <hr>. 5319 h = h.replace(/\s\/>/g, '>'); 5238 5320 5239 // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones5240 h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs5241 h = h.replace(/<p([^>]*)>\s* \s*<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs5242 h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs5321 // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones 5322 h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 5323 h = h.replace(/<p([^>]*)>\s* \s*<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 5324 h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 5243 5325 5244 // Remove first comment5245 e.innerHTML = tinyMCE.uniqueTag + h;5246 e.firstChild.removeNode(true);5326 // Remove first comment 5327 e.innerHTML = tinyMCE.uniqueTag + h; 5328 e.firstChild.removeNode(true); 5247 5329 5248 // Remove weird auto generated empty paragraphs unless it's supposed to be there5249 nl = e.getElementsByTagName("p");5250 for (i=nl.length-1; i>=0; i--) {5251 n = nl[i];5330 // Remove weird auto generated empty paragraphs unless it's supposed to be there 5331 nl = e.getElementsByTagName("p"); 5332 for (i=nl.length-1; i>=0; i--) { 5333 n = nl[i]; 5252 5334 5253 if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) 5254 n.parentNode.removeChild(n); 5335 if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) 5336 n.parentNode.removeChild(n); 5337 } 5338 } else { 5339 h = this.fixGeckoBaseHREFBug(1, e, h); 5340 e.innerHTML = h; 5341 this.fixGeckoBaseHREFBug(2, e, h); 5255 5342 } 5256 } else { 5257 h = this.fixGeckoBaseHREFBug(1, e, h); 5258 e.innerHTML = h; 5259 this.fixGeckoBaseHREFBug(2, e, h); 5260 } 5261 }; 5343 }, 5262 5344 5263 TinyMCE_Engine.prototype.getOuterHTML = function(e) { 5264 if (tinyMCE.isIE) 5265 return e.outerHTML; 5345 getOuterHTML : function(e) { 5346 var d; 5266 5347 5267 var d = e.ownerDocument.createElement("body"); 5268 d.appendChild(e.cloneNode(true)); 5269 return d.innerHTML; 5270 }; 5348 if (tinyMCE.isIE) 5349 return e.outerHTML; 5271 5350 5272 TinyMCE_Engine.prototype.setOuterHTML = function(e, h, d) { 5273 var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t;5351 d = e.ownerDocument.createElement("body"); 5352 d.appendChild(e.cloneNode(true)); 5274 5353 5275 if (tinyMCE.isIE && e.nodeType == 1) 5276 e.outerHTML = h; 5277 else { 5278 t = d.createElement("body"); 5279 t.innerHTML = h; 5354 return d.innerHTML; 5355 }, 5280 5356 5281 for (i=0, nl=t.childNodes; i<nl.length; i++)5282 e.parentNode.insertBefore(nl[i].cloneNode(true), e);5357 setOuterHTML : function(e, h, d) { 5358 var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t; 5283 5359 5284 e.parentNode.removeChild(e); 5285 } 5286 }; 5360 if (tinyMCE.isIE && e.nodeType == 1) 5361 e.outerHTML = h; 5362 else { 5363 t = d.createElement("body"); 5364 t.innerHTML = h; 5287 5365 5288 TinyMCE_Engine.prototype._getElementById = function(id, d) { 5289 var e, i, j, f;5366 for (i=0, nl=t.childNodes; i<nl.length; i++) 5367 e.parentNode.insertBefore(nl[i].cloneNode(true), e); 5290 5368 5291 if (typeof(d) == "undefined") 5292 d = document; 5369 e.parentNode.removeChild(e); 5370 } 5371 }, 5293 5372 5294 e = d.getElementById(id); 5295 if (!e) { 5296 f = d.forms; 5373 _getElementById : function(id, d) { 5374 var e, i, j, f; 5297 5375 5298 for (i=0; i<f.length; i++) { 5299 for (j=0; j<f[i].elements.length; j++) { 5300 if (f[i].elements[j].name == id) { 5301 e = f[i].elements[j]; 5302 break; 5376 if (typeof(d) == "undefined") 5377 d = document; 5378 5379 e = d.getElementById(id); 5380 if (!e) { 5381 f = d.forms; 5382 5383 for (i=0; i<f.length; i++) { 5384 for (j=0; j<f[i].elements.length; j++) { 5385 if (f[i].elements[j].name == id) { 5386 e = f[i].elements[j]; 5387 break; 5388 } 5303 5389 } 5304 5390 } 5305 5391 } 5306 }5307 5392 5308 return e;5309 }; 5393 return e; 5394 }, 5310 5395 5311 TinyMCE_Engine.prototype.getNodeTree =function(n, na, t, nn) {5312 return this.selectNodes(n, function(n) {5313 return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);5314 }, na ? na : new Array());5315 }; 5396 getNodeTree : function(n, na, t, nn) { 5397 return this.selectNodes(n, function(n) { 5398 return (!t || n.nodeType == t) && (!nn || n.nodeName == nn); 5399 }, na ? na : []); 5400 }, 5316 5401 5317 TinyMCE_Engine.prototype.getParentElement =function(n, na, f, r) {5318 var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v;5402 getParentElement : function(n, na, f, r) { 5403 var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v; 5319 5404 5320 // Compatiblity with old scripts where f param was a attribute string5321 if (f && typeof(f) == 'string')5322 return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) != '';});5405 // Compatiblity with old scripts where f param was a attribute string 5406 if (f && typeof(f) == 'string') 5407 return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) !== '';}); 5323 5408 5324 return this.getParentNode(n, function(n) {5325 return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n));5326 }, r);5327 }; 5409 return this.getParentNode(n, function(n) { 5410 return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n)); 5411 }, r); 5412 }, 5328 5413 5329 TinyMCE_Engine.prototype.getParentNode =function(n, f, r) {5330 while (n) {5331 if (n == r)5332 return null;5414 getParentNode : function(n, f, r) { 5415 while (n) { 5416 if (n == r) 5417 return null; 5333 5418 5334 if (f(n))5335 return n;5419 if (f(n)) 5420 return n; 5336 5421 5337 n = n.parentNode;5338 }5422 n = n.parentNode; 5423 } 5339 5424 5340 return null;5341 }; 5425 return null; 5426 }, 5342 5427 5343 TinyMCE_Engine.prototype.getAttrib =function(elm, name, dv) {5344 var v;5428 getAttrib : function(elm, name, dv) { 5429 var v; 5345 5430 5346 if (typeof(dv) == "undefined")5347 dv = "";5431 if (typeof(dv) == "undefined") 5432 dv = ""; 5348 5433 5349 // Not a element5350 if (!elm || elm.nodeType != 1)5351 return dv;5434 // Not a element 5435 if (!elm || elm.nodeType != 1) 5436 return dv; 5352 5437 5353 try {5354 v = elm.getAttribute(name, 0);5355 } catch (ex) {5356 // IE 7 may cast exception on invalid attributes5357 v = elm.getAttribute(name, 2);5358 }5438 try { 5439 v = elm.getAttribute(name, 0); 5440 } catch (ex) { 5441 // IE 7 may cast exception on invalid attributes 5442 v = elm.getAttribute(name, 2); 5443 } 5359 5444 5360 // Try className for class attrib5361 if (name == "class" && !v)5362 v = elm.className;5445 // Try className for class attrib 5446 if (name == "class" && !v) 5447 v = elm.className; 5363 5448 5364 // Workaround for a issue with Firefox 1.5rc2+ 5365 if (tinyMCE.isGecko && name == "src" && elm.src != null && elm.src != "") 5366 v = elm.src; 5449 // Workaround for a issue with Firefox 1.5rc2+ 5450 if (tinyMCE.isGecko) { 5451 if (name == "src" && elm.src != null && elm.src !== '') 5452 v = elm.src; 5367 5453 5368 // Workaround for a issue with Firefox 1.5rc2+ 5369 if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "") 5370 v = elm.href; 5454 // Workaround for a issue with Firefox 1.5rc2+ 5455 if (name == "href" && elm.href != null && elm.href !== '') 5456 v = elm.href; 5457 } else if (tinyMCE.isIE) { 5458 switch (name) { 5459 case "http-equiv": 5460 v = elm.httpEquiv; 5461 break; 5371 5462 5372 if (name == "http-equiv" && tinyMCE.isIE) 5373 v = elm.httpEquiv; 5463 case "width": 5464 case "height": 5465 v = elm.getAttribute(name, 2); 5466 break; 5467 } 5468 } 5374 5469 5375 if (name == "style" && !tinyMCE.isOpera)5376 v = elm.style.cssText;5470 if (name == "style" && !tinyMCE.isOpera) 5471 v = elm.style.cssText; 5377 5472 5378 return (v && v != "") ? v : dv;5379 }; 5473 return (v && v !== '') ? v : dv; 5474 }, 5380 5475 5381 TinyMCE_Engine.prototype.setAttrib =function(el, name, va, fix) {5382 if (typeof(va) == "number" && va != null)5383 va = "" + va;5476 setAttrib : function(el, name, va, fix) { 5477 if (typeof(va) == "number" && va != null) 5478 va = "" + va; 5384 5479 5385 if (fix) {5386 if (va == null)5387 va = "";5480 if (fix) { 5481 if (va == null) 5482 &nbs