Index: trunk/admin/editor/FCKeditor/js/fck_editor.js =================================================================== diff -u -r13 -r767 --- trunk/admin/editor/FCKeditor/js/fck_editor.js (.../fck_editor.js) (revision 13) +++ trunk/admin/editor/FCKeditor/js/fck_editor.js (.../fck_editor.js) (revision 767) @@ -1,619 +1,311 @@ /* * FCKeditor - The text editor for internet - * Copyright (C) 2003 Frederico Caldeira Knabben - * - * Licensed under the terms of the GNU Lesser General Public License - * (http://www.opensource.org/licenses/lgpl-license.php) - * - * For further information go to http://www.fredck.com/FCKeditor/ - * or contact fckeditor@fredck.com. - * - * fck_editor.js: Main script that initializes the editor. - * - * Authors: - * Frederico Caldeira Knabben (fckeditor@fredck.com) - */ - - var bInitialized = false ; - var bDataLoaded = false ; - - function initEditor() - { - if (! bInitialized) - { - bInitialized = true ; - - loadToolbarSet() ; - loadToolbarSourceSet() ; - - objContent.BaseURL = config.BaseUrl ; - } - - if (! bDataLoaded && ! objContent.Busy) - { - bDataLoaded = true ; - - objContent.DOM.body.onpaste = onPaste ; - objContent.DOM.body.ondrop = onDrop ; - - objContent.DOM.body.onkeydown = onKeyDown ; - - objContent.ShowBorders = config.StartupShowBorders ; - objContent.ShowDetails = config.StartupShowDetails ; - - //alert(config.EditorAreaCSS); - objContent.DOM.createStyleSheet(config.EditorAreaCSS) ; - setLinkedField() ; - setTimeout("loadStylesheet()",1000); - } - } - - // Method: loadToolbarSet() - // Description: Loads a toobar buttons set from an array inside the Toolbar holder. - // Author: FredCK - function loadToolbarSet() - { - var sToolBarSet = URLParams["Toolbar"] == null ? "Default" : URLParams["Toolbar"] ; - - // FredCK: Toobar holder (DIV) - var oToolbarHolder = document.getElementById("divToolbar") ; - - var oToolbar = new TBToolbar() ; - oToolbar.LoadButtonsSet( sToolBarSet ) ; - oToolbarHolder.innerHTML = oToolbar.GetHTML() ; - - } - - function loadToolbarSourceSet() - { - // FredCK: Toobar holder (DIV) - var oToolbarHolder = document.getElementById("divToolbarSource") ; - - var oToolbar = new TBToolbar() ; - oToolbar.LoadButtonsSet( "Source" ) ; - oToolbarHolder.innerHTML = oToolbar.GetHTML() ; - } - - function switchEditMode() - { - var bSource = (trSource.style.display == "none") ; - - if (bSource) - txtSource.value = objContent.DOM.body.innerHTML ; - else - { - objContent.DOM.body.innerHTML = "
 
" + txtSource.value ; - objContent.DOM.getElementById('__tmpFCKRemove__').removeNode(true) ; - } - - trEditor.style.display = bSource ? "none" : "inline" ; - trSource.style.display = bSource ? "inline" : "none" ; - - events.fireEvent('onViewMode', bSource) ; - } - - // setValue(): called from reset() to make a select list show the current font - // or style attributes - function selValue(el, str, text) - { - //if (!RichEditor.txtView) return; // Disabled in View Source mode - for (var i = 0; i < el.length; i++) - { - if (((text || !el[i].value) && el[i].text == str) || ((!text || el[i].value) && el[i].value == str)) - { - el.selectedIndex = i; - return; - } - } - el.selectedIndex = 0; - } - - var oLinkedField = null ; - function setLinkedField() - { - if (! URLParams['FieldName']) return ; - - oLinkedField = parent.document.getElementsByName(URLParams['FieldName'])[0] ; - - if (! oLinkedField) return ; - - // __tmpFCKRemove__ added and removed to solve DHTML component error when loading "


" - objContent.DOM.body.innerHTML = "
 
" + oLinkedField.value ; - objContent.DOM.getElementById('__tmpFCKRemove__').removeNode(true) ; - - var oForm = oLinkedField.form ; - - if (!oForm) return ; - - // Attaches the field update to the onsubmit event - oForm.attachEvent("onsubmit", setFieldValue) ; - - // Attaches the field update to the submit method (IE doesn't fire onsubmit on this case) - if (! oForm.updateFCKEditor) oForm.updateFCKEditor = new Array() ; - oForm.updateFCKEditor[oForm.updateFCKEditor.length] = setFieldValue ; - if (! oForm.originalSubmit) - { - oForm.originalSubmit = oForm.submit ; - oForm.submit = function() - { - if (this.updateFCKEditor) - { - for (var i = 0 ; i < this.updateFCKEditor.length ; i++) - { - this.updateFCKEditor[i]() ; - } - } - this.originalSubmit() ; - } - } - } - - function setFieldValue() - { - if (trSource.style.display != "none") - { - switchEditMode() ; - } - - if (config.EnableXHTML) - { - window.status = lang["ProcessingXHTML"] ; - oLinkedField.value = getXhtml( objContent.DOM.body ) ; - window.status = 'Done' ; - } - else - oLinkedField.value = objContent.DOM.body.innerHTML ; - } - - function onPaste() - { - if (config.ForcePasteAsPlainText) - { - pastePlainText() ; - return false ; - } - else if (config.AutoDetectPasteFromWord && BrowserInfo.IsIE55OrMore) - { - var sHTML = GetClipboardHTML() ; - var re = /<\w[^>]* class="?MsoNormal"?/gi ; - if ( re.test( sHTML ) ) - { - if ( confirm( lang["PasteWordConfirm"] ) ) - { - cleanAndPaste( sHTML ) ; - return false ; - } - } - } - else - return true ; - } - - function onDrop() - { - if (config.ForcePasteAsPlainText) - { - var sText = HTMLEncode( objContent.DOM.parentWindow.event.dataTransfer.getData("Text") ) ; - sText = sText.replace(/\n/g,'
') ; - insertHtml(sText) ; - return false ; - } - else if (config.AutoDetectPasteFromWord && BrowserInfo.IsIE55OrMore) - { - // TODO - // To find a way to get the HTML that is dropped, - // clean it and insert it into the document. - return true ; - } - else - return true ; - } - - function onKeyDown() - { - var oWindow = objContent.DOM.parentWindow ; - - if ( oWindow.event.ctrlKey || oWindow.event.altKey || oWindow.event.shiftKey ) - { - oWindow.event.returnValue = true ; - return ; - } - - if ( oWindow.event.keyCode == 9 && config.TabSpaces > 0 ) // added tab support - { - var sSpaces = "" ; - for ( i = 0 ; i < config.TabSpaces ; i++ ) - sSpaces += " " ; - insertHtml( sSpaces ) ; - } - else if ( oWindow.event.keyCode == 13 && config.UseBROnCarriageReturn ) - { - if ( objContent.DOM.queryCommandState( 'InsertOrderedList' ) || objContent.DOM.queryCommandState( 'InsertUnorderedList' ) ) - { - oWindow.event.returnValue = true ; - return ; - } - - insertHtml("
 ") ; - - var oRange = objContent.DOM.selection.createRange() ; - oRange.moveStart('character',-1) ; - oRange.select() ; - objContent.DOM.selection.clear() ; - - oWindow.event.returnValue = false ; - } - } - - function loadStylesheet() - { - var a,b; - var styleList = new Array(); - - passedValue = objContent.DOM.styleSheets; - - for (var i = 0; passedValue && i < passedValue.length; i++) - { - for (var j = 0; j < passedValue[i].rules.length; j++) - { - // Extract the rule and the rule definition from the passed style - // data. - a = passedValue[i].rules[j].selectorText.toString(); - b = passedValue[i].rules[j].style.cssText; - //alert(a + " --> " + b); - //document.body.innerHTML += a + " --> " + b + "
"; - // Ignore non-style entries - if (!a || !b) continue; - - // Id: These are added to the document style sheet but are not - // available in the style dropdown - if (a.indexOf("#") != -1) - { - continue; - } - - // Class: Append a cless element to the style list - if (a.indexOf(".") == 0) - { - styleList[styleList.length] = [a.substr(1), "Class " + a, 1]; - //alert('Adding class '+a); - } - - // SubClass: Append the sub-class to the style list - else if(a.indexOf(".") > 0) - { - l = a.split("."); - styleList[styleList.length] = [l[1], a, 1]; - } - - // Otherwise, assume it's a tag and select the existing tag entry - // in the style list. - else - { - styleList[styleList.length] = [a, a.toLowerCase(), 1]; - } - } - } - - for (var i = 0; i < styleList.length; i++) - { - var oOption = document.createElement("OPTION"); - if (styleList[i][0]) oOption.value = styleList[i][0]; - oOption.text = styleList[i][1]; - oOption.style.backgroundColor = 'white'; - // Choose the combobox, in this case cmbFontStyle - if(document.all.cmbFontStyle) - { - document.all.cmbFontStyle.add(oOption); - } - } - } \ No newline at end of file