Committer: afedorov
Delete from release #82: LJSUP-9159, LJSUP-8974, LJSUP-9184, LJSUP-9183U branches/r82/bin/upgrading/en.dat U branches/r82/cgi-bin/LJ/Widget/EntryForm.pm D branches/r82/htdocs/js/ck/ U branches/r82/htdocs/js/entry.js U branches/r82/htdocs/js/rte.js U branches/r82/htdocs/stc/fck/editor/dialog/common/fck_dialog_common.js U branches/r82/htdocs/stc/fck/editor/dialog/fck_link/fck_link.js U branches/r82/htdocs/stc/fck/editor/js/fckeditorcode_gecko.js U branches/r82/htdocs/stc/lj_base.css D branches/r82/htdocs/tools/ck_poll_questions.bml D branches/r82/htdocs/tools/ck_poll_setup.bml
Modified: branches/r82/bin/upgrading/en.dat =================================================================== --- branches/r82/bin/upgrading/en.dat 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/bin/upgrading/en.dat 2011-07-08 10:38:28 UTC (rev 19457) @@ -2676,22 +2676,6 @@ fcklang.userprompt=Enter their username - -fcklang.ljlike.name=Like buttons - -fcklang.ljlike.dialog.text=Check buttons - -fcklang.ljlike.button.google=Google +1 - -fcklang.ljlike.button.facebook=Facebook - -fcklang.ljlike.button.vkontakte=Vkontakte - -fcklang.ljlike.button.twitter=Twitter - -fcklang.ljlike.button.give=10 Give - - fcklang.videoprompt=Please enter the YouTube, PhotoBucket, or Google Video URL: feeds.link=syndicated feeds Modified: branches/r82/cgi-bin/LJ/Widget/EntryForm.pm =================================================================== --- branches/r82/cgi-bin/LJ/Widget/EntryForm.pm 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/cgi-bin/LJ/Widget/EntryForm.pm 2011-07-08 10:38:28 UTC (rev 19457) @@ -148,7 +148,7 @@ push @ret, qw( js/ippu.js js/lj_ippu.js - js/ck/ckeditor.js + stc/ck/ckeditor.js js/rte.js stc/display_none.css ); @@ -623,7 +623,7 @@ my $switch_rte_link = BML::ml("entryform.htmlokay.rich4", { 'opts' => 'href="javascript:void(0);" '. 'onclick="return useRichText(\'draft\', \'' . - $LJ::JSPREFIX. '\');"' + $LJ::WSTATPREFIX. '\');"' }); my $switch_rte_tab = ''; @@ -1453,13 +1453,6 @@ 'Poll_AccountLevelNotice' => 'poll.accountlevelnotice', 'Poll_PollWizardTitle' => 'poll.pollwizardtitle', 'Poll' => 'poll', - 'LJLike_name' => 'ljlike.name', - 'LJLike_dialogText' => 'ljlike.dialog.text', - 'LJLike_button_google' => 'ljlike.button.google', - 'LJLike_button_facebook' => 'ljlike.button.facebook', - 'LJLike_button_vkontakte' => 'ljlike.button.vkontakte', - 'LJLike_button_twitter' => 'ljlike.button.twitter', - 'LJLike_button_give' => 'ljlike.button.give', ); my %langmap_translated = map { $_ => BML::ml("fcklang.$langmap{$_}") } @@ -1471,8 +1464,9 @@ $out .= $self->wrap_js(qq{ var CKLang = CKEDITOR.lang[CKEDITOR.lang.detect()] || {}; jQuery.extend(CKLang, $langmap); - document.getElementById('htmltools').style.display = 'block'; - usePlainText('draft'); + document.getElementById('htmltools').style.display = 'block'; + document.write("$jnorich"); + usePlainText('draft'); }); $out .= qq{ @@ -1483,7 +1477,7 @@ }; if ($opts->{'richtext_default'}) { - $$onload .= 'useRichText("draft", "' . LJ::ejs($LJ::JSPREFIX) . '");'; + $$onload .= 'useRichText("draft", "' . LJ::ejs($LJ::WSTATPREFIX) . '");'; } } Modified: branches/r82/htdocs/js/entry.js =================================================================== --- branches/r82/htdocs/js/entry.js 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/htdocs/js/entry.js 2011-07-08 10:38:28 UTC (rev 19457) @@ -119,16 +119,14 @@ return false; } - var security = $('security'); - var custom_boxes = $('custom_boxes'); if(! custom_boxes){ return false; } - updateRepostButtons(security.selectedIndex); + updateRepostButtons(f.security.selectedIndex); - if(security.selectedIndex != 3){ + if(f.security.selectedIndex != 3){ custom_boxes.style.display = 'none'; return false; } @@ -136,7 +134,7 @@ var altlogin_username = $('altlogin_username'); if(altlogin_username != undefined && (altlogin_username.style.display == 'table-row' || altlogin_username.style .display == 'block')){ - security.selectedIndex = 0; + f.security.selectedIndex = 0; custom_boxes.style.display = 'none'; alert("Custom security is only available when posting as the logged in user."); } else { @@ -1369,6 +1367,8 @@ } }; + drafttext = convertToDraft(drafttext); + HTTPReq.getJSON({ method: 'POST', url: '/tools/endpoints/draft.bml', Modified: branches/r82/htdocs/js/rte.js =================================================================== --- branches/r82/htdocs/js/rte.js 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/htdocs/js/rte.js 2011-07-08 10:38:28 UTC (rev 19457) @@ -36,7 +36,71 @@ CKEditor.container.show(); CKEditor.element.hide(); - var ljTags = CKEditor.document.getElementsByTag('lj-template').$,i = ljTags.length; + var ljTags = CKEditor.document.getElementsByTag('lj').$, + i = ljTags.length; + + while(i--){ + var ljTag = ljTags[i], + userName = ljTag.getAttribute('user') || ljTag.getAttribute('comm'), + T = ljTag.getAttribute('title'), + cacheName = T ? userName + ':' + T : userName; + if(cache.hasOwnProperty(cacheName)){ + if(cache[cacheName].html){ + updateLJUser(ljTag, cache[cacheName].html); + } else { + cache[cacheName].queue.push(ljTag); + } + continue; + } + + cache[cacheName] = { + queue: [ljTag] + }; + + var postData = { + username: userName + }; + + if(T){ + postData.usertitle = T; + } + + var gotError = (function(username){ + return function(err){ + alert(err + ' "' + username + '"'); + } + })(userName); + + var gotInfo = (function(username, cachename){ + return function (data){ + if(data.error){ + return alert(data.error + ' "' + username + '"'); + } + if(!data.success){ + return; + } + + data.ljuser = data.ljuser.replace("<span class='useralias-value'>*</span>", ''); + + var ljTag; + while(ljTag = cache[cachename].queue.shift()){ + updateLJUser(ljTag, data.ljuser); + } + + cache[cachename].html = data.ljuser; + } + })(userName, cacheName); + + HTTPReq.getJSON({ + data: HTTPReq.formEncoded(postData), + method: 'POST', + url: Site.siteroot + '/tools/endpoints/ljuser.bml', + onError: gotError, + onData: gotInfo + }); + } + + ljTags = CKEditor.document.getElementsByTag('lj-template').$,i = ljTags.length; var styleNoEdit = 'cursor: default; -moz-user-select: all; -moz-user-input: none; -moz-user-focus: none; -khtml-user-select: all;'; while(i--){ ljTag = ljTags[i]; @@ -75,14 +139,13 @@ window.useRichText = function (textArea, statPrefix){ if(!switchedRteOn){ - window.switchedRteOn = true; + switchedRteOn = true; $('switched_rte_on').value = '1'; if(!CKEditor && CKEDITOR && CKEDITOR.env.isCompatible){ - CKEDITOR.basePath = statPrefix + '/ck/'; var editor = CKEDITOR.replace(textArea, { skin: 'v2', - baseHref: CKEDITOR.basePath, + baseHref: statPrefix + '/ck/', height: 350 }); @@ -91,10 +154,11 @@ $('updateForm').onsubmit = function(){ if(switchedRteOn){ - this['draft'].value = CKEditor.getData(); + var html = closeEmptyTags(CKEditor.element.getValue()); + CKEditor.setData(html); } }; - + CKEditor.on('dataReady', LJToHtml); }); } else { @@ -116,11 +180,12 @@ window.usePlainText = function(textArea){ if(switchedRteOn){ - window.switchedRteOn = false; + switchedRteOn = false; $('switched_rte_on').value = '0'; if(CKEditor){ var data = CKEditor.getData(); + data = convertUserAndPool(data); CKEditor.element.setValue(data); CKEditor.container.hide(); @@ -160,4 +225,48 @@ return false; }; + + function convertUserAndPool(html){ + html = html.replace(/<form.*?class="ljpoll" data="([^"]*)"[\s\S]*?<\/form>/gi, function(form, data){ + return unescape(data); + }) + .replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/(?:community|syndicated)\.[-.\w]+\/([\w]+)\/.*?<b>\1<\/b><\/a><\/span>/g, '<lj comm="$1"/>') + .replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/(?:community|syndicated)\.[-.\w]+\/([\w]+)\/.*?<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj comm="$1" title="$2"/>') + .replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/users\.[-.\w]+\/([\w]+)\/.*?<b>\1<\/b><\/a><\/span>/g, '<lj user="$1"/>') + .replace(/<span[^>]*?class="ljuser[^>]*?lj:user="([^"]*?)".+(?!<\/a>).*?<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj user="$1" title="$2"/>') + .replace(/<\/lj>/g, ''); + + //change user-name to user_name + var ljUser, rex = /<lj user="([-\w]+)"([^>]+)?\/>/g; + while(ljUser = rex.exec(html)){ + html = html.replace(ljUser[0], '<lj user="' + ljUser[1].replace(/-/g, '_') + '"' + (ljUser[2] || '') + '/>'); + } + + return html.replace(/<lj user="([\w]+)" title="\1"\/>/g, '<lj user="$1"/>'); + } + + window.convertToLJTags = function(html){ + return convertUserAndPool(html) + .replace(/<div(?=[^>]*class="ljvideo")[^>]*url="(\S+)"[^>]*><img.+?\/><\/div>/g, '<lj-template name="video">$1</lj-template>') + .replace(/<div(?=[^>]*class="ljvideo")[^>]*url="\S+"[^>]*>([\s\S]+?)<\/div>/g, '<p>$1</p>') + .replace(/<div class=['"]ljembed['"](\s*embedid="(\d*)")?\s*>([\s\S]*?)<\/div>/gi, '<lj-embed id="$2">$3</lj-embed>') + .replace(/<div\s*(embedid="(\d*)")?\s*class=['"]ljembed['"]\s*>([\s\S]*?)<\/div>/gi, '<lj-embed id="$2">$3</lj-embed>')// convert qotd + .replace(/<div([^>]*)qotdid="(\d+)"([^>]*)>[^\b]*<\/div>(<br \/>)*/g, '<lj-template id="$2"$1$3 /><br />')// div tag and qotdid attrib + .replace(/(<lj-template id="\d+" )([^>]*)class="ljqotd"?([^>]*\/>)/g, '$1name="qotd" $2$3')// class attrib + .replace(/(<lj-template id="\d+" name="qotd" )[^>]*(lang="\w+")[^>]*\/>/g, '$1$2 \/>'); // lang attrib + }; + + window.convertToHTMLTags = function(html){ + return html + .replace(/<lj-template name=['"]video['"]>(\S+?)<\/lj-template>/g, '<div class="ljvideo" url="$1"><img src="' + Site.statprefix + '/fck/editor/plugins/livejournal/ljvideo.gif" /></div>') + .replace(/<lj-embed\s*(?:id="(\d*)")?\s*>([\s\S]*?)<\/lj-embed>/gi, '<div class="ljembed" embedid="$1">$2</div>') + .replace(/<lj-poll .*?>[^b]*?<\/lj-poll>/gm, function(ljtags){ + return new Poll(ljtags).outputHTML(); + }) + .replace(/<lj-template(.*?)><\/lj-template>/g, "<lj-template$1 />"); + }; + + window.convertToDraft = function(html){ + return switchedRteOn ? convertUserAndPool(html) : html; + } })(); \ No newline at end of file Modified: branches/r82/htdocs/stc/fck/editor/dialog/common/fck_dialog_common.js =================================================================== --- branches/r82/htdocs/stc/fck/editor/dialog/common/fck_dialog_common.js 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/htdocs/stc/fck/editor/dialog/common/fck_dialog_common.js 2011-07-08 10:38:28 UTC (rev 19457) @@ -1,6 +1,6 @@ /* * FCKeditor - The text editor for Internet - http://www.fckeditor.net - * Copyright (C) 2003-2010 Frederico Caldeira Knabben + * Copyright (C) 2003-2009 Frederico Caldeira Knabben * * == BEGIN LICENSE == * @@ -23,303 +23,328 @@ */ // Automatically detect the correct document.domain (#123). -(function(){ - var d = document.domain; +(function() +{ + var d = document.domain ; - while(true){ + while ( true ) + { // Test if we can access a parent property. - try{ - var test = window.parent.document.domain; - break; - } catch(e){ + try + { + var test = window.parent.document.domain ; + break ; } + catch( e ) {} // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... - d = d.replace(/.*?(?:\.|$)/, ''); + d = d.replace( /.*?(?:\.|$)/, '' ) ; - if(d.length == 0){ - break; - } // It was not able to detect the domain. + if ( d.length == 0 ) + break ; // It was not able to detect the domain. - try{ - document.domain = d; - } catch (e){ - break; + try + { + document.domain = d ; } + catch (e) + { + break ; + } } -})(); +})() ; // Attention: FCKConfig must be available in the page. -function GetCommonDialogCss(prefix){ +function GetCommonDialogCss( prefix ) +{ // CSS minified by http://iceyboard.no-ip.org/projects/css_compressor (see _dev/css_compression.txt). - return FCKConfig - .BasePath + 'dialog/common/' + '|.ImagePreviewArea{border:#000 1px solid;overflow:auto;width:100%;height:170px;background-color:#fff}.FlashPreviewArea{border:#000 1px solid;padding:5px;overflow:auto;width:100%;height:170px;background-color:#fff}.BtnReset{float:left;background-position:center center;background-image:url(images/reset.gif);width:16px;height:16px;background-repeat:no-repeat;border:1px none;font-size:1px}.BtnLocked,.BtnUnlocked{float:left;background-position:center center;background-image:url(images/locked.gif);width:16px;height:16px;background-repeat:no-repeat;border:none 1px;font-size:1px}.BtnUnlocked{background-image:url(images/unlocked.gif)}.BtnOver{border:outset 1px;cursor:pointer;cursor:hand}'; + return FCKConfig.BasePath + 'dialog/common/' + '|.ImagePreviewArea{border:#000 1px solid;overflow:auto;width:100%;height:170px;background-color:#fff}.FlashPreviewArea{border:#000 1px solid;padding:5px;overflow:auto;width:100%;height:170px;background-color:#fff}.BtnReset{float:left;background-position:center center;background-image:url(images/reset.gif);width:16px;height:16px;background-repeat:no-repeat;border:1px none;font-size:1px}.BtnLocked,.BtnUnlocked{float:left;background-position:center center;background-image:url(images/locked.gif);width:16px;height:16px;background-repeat:no-repeat;border:none 1px;font-size:1px}.BtnUnlocked{background-image:url(images/unlocked.gif)}.BtnOver{border:outset 1px;cursor:pointer;cursor:hand}' ; } // Gets a element by its Id. Used for shorter coding. -function GetE(elementId){ - return document.getElementById(elementId); +function GetE( elementId ) +{ + return document.getElementById( elementId ) ; } -function ShowE(element, isVisible){ - if(typeof( element ) == 'string'){ - element = GetE(element); - } - element.style.display = isVisible ? '' : 'none'; +function ShowE( element, isVisible ) +{ + if ( typeof( element ) == 'string' ) + element = GetE( element ) ; + element.style.display = isVisible ? '' : 'none' ; } -function SetAttribute(element, attName, attValue){ - if(attValue == null || attValue.length == 0){ - element.removeAttribute(attName, 0); - } // 0 : Case Insensitive - else { - element.setAttribute(attName, attValue, 0); - } // 0 : Case Insensitive +function SetAttribute( element, attName, attValue ) +{ + if ( attValue == null || attValue.length == 0 ) + element.removeAttribute( attName, 0 ) ; // 0 : Case Insensitive + else + element.setAttribute( attName, attValue, 0 ) ; // 0 : Case Insensitive } -function GetAttribute(element, attName, valueIfNull){ - var oAtt = element.attributes[attName]; +function GetAttribute( element, attName, valueIfNull ) +{ + var oAtt = element.attributes[attName] ; - if(oAtt == null || !oAtt.specified){ - return valueIfNull ? valueIfNull : ''; - } + if ( oAtt == null || !oAtt.specified ) + return valueIfNull ? valueIfNull : '' ; - var oValue = element.getAttribute(attName, 2); + var oValue = element.getAttribute( attName, 2 ) ; - if(oValue == null){ - oValue = oAtt.nodeValue; - } + if ( oValue == null ) + oValue = oAtt.nodeValue ; - return ( oValue == null ? valueIfNull : oValue ); + return ( oValue == null ? valueIfNull : oValue ) ; } -function SelectField(elementId){ - var element = GetE(elementId); - element.focus(); +function SelectField( elementId ) +{ + //added try catch because the tab can be hidden at this moment + try { + var element = GetE( elementId ) ; + element.focus() ; + } catch( e ) {}; // element.select may not be available for some fields (like <select>). - if(element.select){ - element.select(); - } + if ( element.select ) + element.select() ; } // Functions used by text fields to accept numbers only. -var IsDigit = ( function(){ - var KeyIdentifierMap = { - End : 35, - Home : 36, - Left : 37, - Right : 39, - 'U+00007F' : 46 // Delete - }; +var IsDigit = ( function() + { + var KeyIdentifierMap = + { + End : 35, + Home : 36, + Left : 37, + Right : 39, + 'U+00007F' : 46 // Delete + } ; - return function (e){ - if(!e){ - e = event; - } + return function ( e ) + { + if ( !e ) + e = event ; - var iCode = ( e.keyCode || e.charCode ); + var iCode = ( e.keyCode || e.charCode ) ; - if(!iCode && e.keyIdentifier && ( e.keyIdentifier in KeyIdentifierMap )){ - iCode = KeyIdentifierMap[ e.keyIdentifier ]; - } + if ( !iCode && e.keyIdentifier && ( e.keyIdentifier in KeyIdentifierMap ) ) + iCode = KeyIdentifierMap[ e.keyIdentifier ] ; - return ( - ( iCode >= 48 && iCode <= 57 ) // Numbers || (iCode >= 35 && iCode <= 40) // Arrows, Home, End || iCode == 8 // Backspace || iCode == 46 // Delete || iCode == 9 // Tab - ); - } -} )(); + return ( + ( iCode >= 48 && iCode <= 57 ) // Numbers + || (iCode >= 35 && iCode <= 40) // Arrows, Home, End + || iCode == 8 // Backspace + || iCode == 46 // Delete + || iCode == 9 // Tab + ) ; + } + } )() ; -String.prototype.Trim = function(){ - return this.replace(/(^\s*)|(\s*$)/g, ''); -}; +String.prototype.Trim = function() +{ + return this.replace( /(^\s*)|(\s*$)/g, '' ) ; +} -String.prototype.StartsWith = function(value){ - return ( this.substr(0, value.length) == value ); -}; +String.prototype.StartsWith = function( value ) +{ + return ( this.substr( 0, value.length ) == value ) ; +} -String.prototype.Remove = function(start, length){ - var s = ''; +String.prototype.Remove = function( start, length ) +{ + var s = '' ; - if(start > 0){ - s = this.substring(0, start); - } + if ( start > 0 ) + s = this.substring( 0, start ) ; - if(start + length < this.length){ - s += this.substring(start + length, this.length); - } + if ( start + length < this.length ) + s += this.substring( start + length , this.length ) ; - return s; -}; + return s ; +} -String.prototype.ReplaceAll = function(searchArray, replaceArray){ - var replaced = this; +String.prototype.ReplaceAll = function( searchArray, replaceArray ) +{ + var replaced = this ; - for(var i = 0; i < searchArray.length; i++){ - replaced = replaced.replace(searchArray[i], replaceArray[i]); + for ( var i = 0 ; i < searchArray.length ; i++ ) + { + replaced = replaced.replace( searchArray[i], replaceArray[i] ) ; } - return replaced; -}; + return replaced ; +} -function OpenFileBrowser(url, width, height){ +function OpenFileBrowser( url, width, height ) +{ // oEditor must be defined. - var iLeft = ( oEditor.FCKConfig.ScreenWidth - width ) / 2; - var iTop = ( oEditor.FCKConfig.ScreenHeight - height ) / 2; + var iLeft = ( oEditor.FCKConfig.ScreenWidth - width ) / 2 ; + var iTop = ( oEditor.FCKConfig.ScreenHeight - height ) / 2 ; - var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes"; - sOptions += ",width=" + width; - sOptions += ",height=" + height; - sOptions += ",left=" + iLeft; - sOptions += ",top=" + iTop; + var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ; + sOptions += ",width=" + width ; + sOptions += ",height=" + height ; + sOptions += ",left=" + iLeft ; + sOptions += ",top=" + iTop ; - window.open(url, 'FCKBrowseWindow', sOptions); + window.open( url, 'FCKBrowseWindow', sOptions ) ; } /** Utility function to create/update an element with a name attribute in IE, so it behaves properly when moved around It also allows to change the name or other special attributes in an existing node - oEditor : instance of FCKeditor where the element will be created - oOriginal : current element being edited or null if it has to be created - nodeName : string with the name of the element to create - oAttributes : Hash object with the attributes that must be set at creation time in IE - Those attributes will be set also after the element has been - created for any other browser to avoid redudant code - */ -function CreateNamedElement(oEditor, oOriginal, nodeName, oAttributes){ - var oNewNode; + oEditor : instance of FCKeditor where the element will be created + oOriginal : current element being edited or null if it has to be created + nodeName : string with the name of the element to create + oAttributes : Hash object with the attributes that must be set at creation time in IE + Those attributes will be set also after the element has been + created for any other browser to avoid redudant code +*/ +function CreateNamedElement( oEditor, oOriginal, nodeName, oAttributes ) +{ + var oNewNode ; // IE doesn't allow easily to change properties of an existing object, // so remove the old and force the creation of a new one. - var oldNode = null; - if(oOriginal && oEditor.FCKBrowserInfo.IsIE){ + var oldNode = null ; + if ( oOriginal && oEditor.FCKBrowserInfo.IsIE ) + { // Force the creation only if some of the special attributes have changed: var bChanged = false; - for(var attName in oAttributes){ - bChanged |= ( oOriginal.getAttribute(attName, 2) != oAttributes[attName] ); - } + for( var attName in oAttributes ) + bChanged |= ( oOriginal.getAttribute( attName, 2) != oAttributes[attName] ) ; - if(bChanged){ - oldNode = oOriginal; - oOriginal = null; + if ( bChanged ) + { + oldNode = oOriginal ; + oOriginal = null ; } } // If the node existed (and it's not IE), then we just have to update its attributes - if(oOriginal){ - oNewNode = oOriginal; - } else { + if ( oOriginal ) + { + oNewNode = oOriginal ; + } + else + { // #676, IE doesn't play nice with the name or type attribute - if(oEditor.FCKBrowserInfo.IsIE){ - var sbHTML = []; - sbHTML.push('<' + nodeName); - for(var prop in oAttributes){ - sbHTML.push(' ' + prop + '="' + oAttributes[prop] + '"'); + if ( oEditor.FCKBrowserInfo.IsIE ) + { + var sbHTML = [] ; + sbHTML.push( '<' + nodeName ) ; + for( var prop in oAttributes ) + { + sbHTML.push( ' ' + prop + '="' + oAttributes[prop] + '"' ) ; } - sbHTML.push('>'); - if(!oEditor.FCKListsLib.EmptyElements[nodeName.toLowerCase()]){ - sbHTML.push('</' + nodeName + '>'); - } + sbHTML.push( '>' ) ; + if ( !oEditor.FCKListsLib.EmptyElements[nodeName.toLowerCase()] ) + sbHTML.push( '</' + nodeName + '>' ) ; - oNewNode = oEditor.FCK.EditorDocument.createElement(sbHTML.join('')); + oNewNode = oEditor.FCK.EditorDocument.createElement( sbHTML.join('') ) ; // Check if we are just changing the properties of an existing node: copy its properties - if(oldNode){ - CopyAttributes(oldNode, oNewNode, oAttributes); - oEditor.FCKDomTools.MoveChildren(oldNode, oNewNode); - oldNode.parentNode.removeChild(oldNode); - oldNode = null; + if ( oldNode ) + { + CopyAttributes( oldNode, oNewNode, oAttributes ) ; + oEditor.FCKDomTools.MoveChildren( oldNode, oNewNode ) ; + oldNode.parentNode.removeChild( oldNode ) ; + oldNode = null ; - if(oEditor.FCK.Selection.SelectionData){ + if ( oEditor.FCK.Selection.SelectionData ) + { // Trick to refresh the selection object and avoid error in // fckdialog.html Selection.EnsureSelection - var oSel = oEditor.FCK.EditorDocument.selection; - oEditor.FCK.Selection.SelectionData = oSel.createRange(); // Now oSel.type will be 'None' reflecting the real situation + var oSel = oEditor.FCK.EditorDocument.selection ; + oEditor.FCK.Selection.SelectionData = oSel.createRange() ; // Now oSel.type will be 'None' reflecting the real situation } } - oNewNode = oEditor.FCK.InsertElement(oNewNode); + oNewNode = oEditor.FCK.InsertElement( oNewNode ) ; // FCK.Selection.SelectionData is broken by now since we've // deleted the previously selected element. So we need to reassign it. - if(oEditor.FCK.Selection.SelectionData){ - var range = oEditor.FCK.EditorDocument.body.createControlRange(); - range.add(oNewNode); - oEditor.FCK.Selection.SelectionData = range; + if ( oEditor.FCK.Selection.SelectionData ) + { + var range = oEditor.FCK.EditorDocument.body.createControlRange() ; + range.add( oNewNode ) ; + oEditor.FCK.Selection.SelectionData = range ; } - } else { - oNewNode = oEditor.FCK.InsertElement(nodeName); } + else + { + oNewNode = oEditor.FCK.InsertElement( nodeName ) ; + } } // Set the basic attributes - for(var attName in oAttributes){ - oNewNode.setAttribute(attName, oAttributes[attName], 0); - } // 0 : Case Insensitive + for( var attName in oAttributes ) + oNewNode.setAttribute( attName, oAttributes[attName], 0 ) ; // 0 : Case Insensitive - return oNewNode; + return oNewNode ; } // Copy all the attributes from one node to the other, kinda like a clone // But oSkipAttributes is an object with the attributes that must NOT be copied -function CopyAttributes(oSource, oDest, oSkipAttributes){ - var aAttributes = oSource.attributes; +function CopyAttributes( oSource, oDest, oSkipAttributes ) +{ + var aAttributes = oSource.attributes ; - for(var n = 0; n < aAttributes.length; n++){ - var oAttribute = aAttributes[n]; + for ( var n = 0 ; n < aAttributes.length ; n++ ) + { + var oAttribute = aAttributes[n] ; - if(oAttribute.specified){ - var sAttName = oAttribute.nodeName; + if ( oAttribute.specified ) + { + var sAttName = oAttribute.nodeName ; // We can set the type only once, so do it with the proper value, not copying it. - if(sAttName in oSkipAttributes){ - continue; - } + if ( sAttName in oSkipAttributes ) + continue ; - var sAttValue = oSource.getAttribute(sAttName, 2); - if(sAttValue == null){ - sAttValue = oAttribute.nodeValue; - } + var sAttValue = oSource.getAttribute( sAttName, 2 ) ; + if ( sAttValue == null ) + sAttValue = oAttribute.nodeValue ; - oDest.setAttribute(sAttName, sAttValue, 0); // 0 : Case Insensitive + oDest.setAttribute( sAttName, sAttValue, 0 ) ; // 0 : Case Insensitive } } // The style: - if(oSource.style.cssText !== ''){ - oDest.style.cssText = oSource.style.cssText; - } + if ( oSource.style.cssText !== '' ) + oDest.style.cssText = oSource.style.cssText ; } /** - * Replaces a tag with another one, keeping its contents: - * for example TD --> TH, and TH --> TD. - * input: the original node, and the new tag name - * http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode - */ -function RenameNode(oNode, newTag){ +* Replaces a tag with another one, keeping its contents: +* for example TD --> TH, and TH --> TD. +* input: the original node, and the new tag name +* http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-renameNode +*/ +function RenameNode( oNode , newTag ) +{ // TODO: if the browser natively supports document.renameNode call it. // does any browser currently support it in order to test? // Only rename element nodes. - if(oNode.nodeType != 1){ - return null; - } + if ( oNode.nodeType != 1 ) + return null ; // If it's already correct exit here. - if(oNode.nodeName == newTag){ - return oNode; - } + if ( oNode.nodeName == newTag ) + return oNode ; - var oDoc = oNode.ownerDocument; + var oDoc = oNode.ownerDocument ; // Create the new node - var newNode = oDoc.createElement(newTag); + var newNode = oDoc.createElement( newTag ) ; // Copy all attributes - CopyAttributes(oNode, newNode, {}); + CopyAttributes( oNode, newNode, {} ) ; // Move children to the new node - FCKDomTools.MoveChildren(oNode, newNode); + FCKDomTools.MoveChildren( oNode, newNode ) ; // Finally replace the node and return the new one - oNode.parentNode.replaceChild(newNode, oNode); + oNode.parentNode.replaceChild( newNode, oNode ) ; - return newNode; + return newNode ; } Modified: branches/r82/htdocs/stc/fck/editor/dialog/fck_link/fck_link.js =================================================================== --- branches/r82/htdocs/stc/fck/editor/dialog/fck_link/fck_link.js 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/htdocs/stc/fck/editor/dialog/fck_link/fck_link.js 2011-07-08 10:38:28 UTC (rev 19457) @@ -79,235 +79,255 @@ // This method simply returns the two inputs in numerical order. You can even // provide strings, as the method would parseInt() the values. -oParser.SortNumerical = function(a, b){ - return parseInt(a, 10) - parseInt(b, 10); -}; +oParser.SortNumerical = function(a, b) +{ + return parseInt( a, 10 ) - parseInt( b, 10 ) ; +} -oParser.ParseEMailParams = function(sParams){ +oParser.ParseEMailParams = function(sParams) +{ // Initialize the oEMailParams object. - var oEMailParams = new Object(); - oEMailParams.Subject = ''; - oEMailParams.Body = ''; + var oEMailParams = new Object() ; + oEMailParams.Subject = '' ; + oEMailParams.Body = '' ; - var aMatch = sParams.match(/(^|^\?|&)subject=([^&]+)/i); - if(aMatch) oEMailParams.Subject = decodeURIComponent(aMatch[2]); + var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ; + if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ; - aMatch = sParams.match(/(^|^\?|&)body=([^&]+)/i); - if(aMatch) oEMailParams.Body = decodeURIComponent(aMatch[2]); + aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ; + if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ; - return oEMailParams; -}; + return oEMailParams ; +} // This method returns either an object containing the email info, or FALSE // if the parameter is not an email link. -oParser.ParseEMailUri = function(sUrl){ +oParser.ParseEMailUri = function( sUrl ) +{ // Initializes the EMailInfo object. - var oEMailInfo = new Object(); - oEMailInfo.Address = ''; - oEMailInfo.Subject = ''; - oEMailInfo.Body = ''; + var oEMailInfo = new Object() ; + oEMailInfo.Address = '' ; + oEMailInfo.Subject = '' ; + oEMailInfo.Body = '' ; - var aLinkInfo = sUrl.match(/^(\w+):(.*)$/); - if(aLinkInfo && aLinkInfo[1] == 'mailto'){ + var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ; + if ( aLinkInfo && aLinkInfo[1] == 'mailto' ) + { // This seems to be an unprotected email link. - var aParts = aLinkInfo[2].match(/^([^\?]+)\??(.+)?/); - if(aParts){ + var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ; + if ( aParts ) + { // Set the e-mail address. - oEMailInfo.Address = aParts[1]; + oEMailInfo.Address = aParts[1] ; // Look for the optional e-mail parameters. - if(aParts[2]){ - var oEMailParams = oParser.ParseEMailParams(aParts[2]); - oEMailInfo.Subject = oEMailParams.Subject; - oEMailInfo.Body = oEMailParams.Body; + if ( aParts[2] ) + { + var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ; + oEMailInfo.Subject = oEMailParams.Subject ; + oEMailInfo.Body = oEMailParams.Body ; } } - return oEMailInfo; - } else if(aLinkInfo && aLinkInfo[1] == 'javascript'){ + return oEMailInfo ; + } + else if ( aLinkInfo && aLinkInfo[1] == 'javascript' ) + { // This may be a protected email. // Try to match the url against the EMailProtectionFunction. - var func = FCKConfig.EMailProtectionFunction; - if(func != null){ - try{ + var func = FCKConfig.EMailProtectionFunction ; + if ( func != null ) + { + try + { // Escape special chars. - func = func.replace(/([\/^$*+.?()\[\]])/g, '\\$1'); + func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ; // Define the possible keys. - var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY'); + var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ; // Get the order of the keys (hold them in the array <pos>) and // the function replaced by regular expression patterns. - var sFunc = func; - var pos = new Array(); - for(var i = 0; i < keys.length; i ++){ - var rexp = new RegExp(keys[i]); - var p = func.search(rexp); - if(p >= 0){ - sFunc = sFunc.replace(rexp, '\'([^\']*)\''); - pos[pos.length] = p + ':' + keys[i]; + var sFunc = func ; + var pos = new Array() ; + for ( var i = 0 ; i < keys.length ; i ++ ) + { + var rexp = new RegExp( keys[i] ) ; + var p = func.search( rexp ) ; + if ( p >= 0 ) + { + sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ; + pos[pos.length] = p + ':' + keys[i] ; } } // Sort the available keys. - pos.sort(oParser.SortNumerical); + pos.sort( oParser.SortNumerical ) ; // Replace the excaped single quotes in the url, such they do // not affect the regexp afterwards. - aLinkInfo[2] = aLinkInfo[2].replace(/\\'/g, '###SINGLE_QUOTE###'); + aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ; // Create the regexp and execute it. - var rFunc = new RegExp('^' + sFunc + '$'); - var aMatch = rFunc.exec(aLinkInfo[2]); - if(aMatch){ + var rFunc = new RegExp( '^' + sFunc + '$' ) ; + var aMatch = rFunc.exec( aLinkInfo[2] ) ; + if ( aMatch ) + { var aInfo = new Array(); - for(var i = 1; i < aMatch.length; i ++){ - var k = pos[i - 1].match(/^\d+:(.+)$/); - aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\''); + for ( var i = 1 ; i < aMatch.length ; i ++ ) + { + var k = pos[i-1].match(/^\d+:(.+)$/) ; + aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ; } // Fill the EMailInfo object that will be returned - oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN']; - oEMailInfo.Subject = decodeURIComponent(aInfo['SUBJECT']); - oEMailInfo.Body = decodeURIComponent(aInfo['BODY']); + oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ; + oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ; + oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ; - return oEMailInfo; + return oEMailInfo ; } - } catch (e){ } + catch (e) + { + } } // Try to match the email against the encode protection. - var aMatch = aLinkInfo[2].match(/^(?:void\()?location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'\)?$/); - if(aMatch){ + var aMatch = aLinkInfo[2].match( /^(?:void\()?location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'\)?$/ ) ; + if ( aMatch ) + { // The link is encoded - oEMailInfo.Address = eval(aMatch[1]); - if(aMatch[2]){ - var oEMailParams = oParser.ParseEMailParams(aMatch[2]); - oEMailInfo.Subject = oEMailParams.Subject; - oEMailInfo.Body = oEMailParams.Body; + oEMailInfo.Address = eval( aMatch[1] ) ; + if ( aMatch[2] ) + { + var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ; + oEMailInfo.Subject = oEMailParams.Subject ; + oEMailInfo.Body = oEMailParams.Body ; } - return oEMailInfo; + return oEMailInfo ; } } return false; -}; +} -oParser.CreateEMailUri = function(address, subject, body){ +oParser.CreateEMailUri = function( address, subject, body ) +{ // Switch for the EMailProtection setting. - switch(FCKConfig.EMailProtection){ + switch ( FCKConfig.EMailProtection ) + { case 'function' : - var func = FCKConfig.EMailProtectionFunction; - if(func == null){ - if(FCKConfig.Debug){ - alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"'); + var func = FCKConfig.EMailProtectionFunction ; + if ( func == null ) + { + if ( FCKConfig.Debug ) + { + alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ; } return ''; } // Split the email address into name and domain parts. - var aAddressParts = address.split('@', 2); - if(aAddressParts[1] == undefined){ - aAddressParts[1] = ''; + var aAddressParts = address.split( '@', 2 ) ; + if ( aAddressParts[1] == undefined ) + { + aAddressParts[1] = '' ; } // Replace the keys by their values (embedded in single quotes). - func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'"); - func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'"); - func = func.replace(/SUBJECT/g, "'" + encodeURIComponent(subject).replace(/'/g, '\\\'') + "'"); - func = func.replace(/BODY/g, "'" + encodeURIComponent(body).replace(/'/g, '\\\'') + "'"); + func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ; + func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ; + func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ; + func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ; - return 'javascript:' + func; + return 'javascript:' + func ; case 'encode' : - var aParams = []; - var aAddressCode = []; + var aParams = [] ; + var aAddressCode = [] ; - if(subject.length > 0) - aParams.push('subject=' + encodeURIComponent(subject)); - if(body.length > 0) - aParams.push('body=' + encodeURIComponent(body)); - for(var i = 0; i < address.length; i++) - aAddressCode.push(address.charCodeAt(i)); + if ( subject.length > 0 ) + aParams.push( 'subject='+ encodeURIComponent( subject ) ) ; + if ( body.length > 0 ) + aParams.push( 'body=' + encodeURIComponent( body ) ) ; + for ( var i = 0 ; i < address.length ; i++ ) + aAddressCode.push( address.charCodeAt( i ) ) ; - return 'javascript:void(location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join(',') + ')+\'?' + aParams.join('&') + '\')'; + return 'javascript:void(location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\')' ; } // EMailProtection 'none' - var sBaseUri = 'mailto:' + address; + var sBaseUri = 'mailto:' + address ; - var sParams = ''; + var sParams = '' ; - if(subject.length > 0) - sParams = '?subject=' + encodeURIComponent(subject); + if ( subject.length > 0 ) + sParams = '?subject=' + encodeURIComponent( subject ) ; - if(body.length > 0){ - sParams += ( sParams.length == 0 ? '?' : '&' ); - sParams += 'body=' + encodeURIComponent(body); + if ( body.length > 0 ) + { + sParams += ( sParams.length == 0 ? '?' : '&' ) ; + sParams += 'body=' + encodeURIComponent( body ) ; } - return sBaseUri + sParams; -}; -var oLink; -function onLoad(){ + return sBaseUri + sParams ; +} - //#### Initialization Code +//#### Initialization Code - // oLink: The actual selected link in the editor. - oLink = dialog.Selection.GetSelection().MoveToAncestorNode('A'); - if(oLink) - FCK.Selection.SelectNode(oLink); - +// oLink: The actual selected link in the editor. +var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; +if ( oLink ) + FCK.Selection.SelectNode( oLink ) ; + +window.onload = function() +{ // Translate the dialog box texts. - oEditor.FCKLanguageManager.TranslatePage(document); + oEditor.FCKLanguageManager.TranslatePage(document) ; // Fill the Anchor Names and Ids combos. - LoadAnchorNamesAndIds(); + LoadAnchorNamesAndIds() ; // Load the selected link information (if any). - LoadSelection(); + LoadSelection() ; // Update the dialog box. - SetLinkType(GetE('cmbLinkType').value); + SetLinkType( GetE('cmbLinkType').value ) ; // Show/Hide the "Browse Server" button. - GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none'; + GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; // Show the initial dialog content. - GetE('divInfo').style.display = ''; + GetE('divInfo').style.display = '' ; // Set the actual uploader URL. - if(FCKConfig.LinkUpload) - GetE('frmUpload').action = FCKConfig.LinkUploadURL; + if ( FCKConfig.LinkUpload ) + GetE('frmUpload').action = FCKConfig.LinkUploadURL ; // Set the default target (from configuration). - SetDefaultTarget(); + SetDefaultTarget() ; // Activate the "OK" button. - dialog.SetOkButton(true); + dialog.SetOkButton( true ) ; // Select the first field. - switch(GetE('cmbLinkType').value){ + switch( GetE('cmbLinkType').value ) + { case 'url' : - SelectField('txtUrl'); - break; + SelectField( 'txtUrl' ) ; + break ; case 'email' : - SelectField('txtEMailAddress'); - break; + SelectField( 'txtEMailAddress' ) ; + break ; case 'anchor' : - if(GetE('divSelAnchor').style.display != 'none') - SelectField('cmbAnchorName'); else - SelectField('cmbLinkType'); + if ( GetE('divSelAnchor').style.display != 'none' ) + SelectField( 'cmbAnchorName' ) ; + else + SelectField( 'cmbLinkType' ) ; } } -if(window.addEventListener){ - window.addEventListener('load', onLoad, false); -} else { - window.attachEvent('onload', onLoad); -} - var bHasAnchors ; function LoadAnchorNamesAndIds() Modified: branches/r82/htdocs/stc/fck/editor/js/fckeditorcode_gecko.js =================================================================== --- branches/r82/htdocs/stc/fck/editor/js/fckeditorcode_gecko.js 2011-07-08 08:41:57 UTC (rev 19456) +++ branches/r82/htdocs/stc/fck/editor/js/fckeditorcode_gecko.js 2011-07-08 10:38:28 UTC (rev 19457) @@ -22,11309 +22,88 @@ * can be found at "editor/_source". */ -var FCK_STATUS_NOTLOADED = window.parent.FCK_STATUS_NOTLOADED = 0; -var FCK_STATUS_ACTIVE = window.parent.FCK_STATUS_ACTIVE = 1; -var FCK_STATUS_COMPLETE = window.parent.FCK_STATUS_COMPLETE = 2; -var FCK_TRISTATE_OFF = window.parent.FCK_TRISTATE_OFF = 0; -var FCK_TRISTATE_ON = window.parent.FCK_TRISTATE_ON = 1; -var FCK_TRISTATE_DISABLED = window.parent.FCK_TRISTATE_DISABLED = -1; -var FCK_UNKNOWN = window.parent.FCK_UNKNOWN = -9; -var FCK_TOOLBARITEM_ONLYICON = window.parent.FCK_TOOLBARITEM_ONLYICON = 0; -var FCK_TOOLBARITEM_ONLYTEXT = window.parent.FCK_TOOLBARITEM_ONLYTEXT = 1; -var FCK_TOOLBARITEM_ICONTEXT = window.parent.FCK_TOOLBARITEM_ICONTEXT = 2; -var FCK_EDITMODE_WYSIWYG = window.parent.FCK_EDITMODE_WYSIWYG = 0; -var FCK_EDITMODE_SOURCE = window.parent.FCK_EDITMODE_SOURCE = 1; -var FCK_IMAGES_PATH = 'images/'; -var FCK_SPACER_PATH = 'images/spacer.gif'; -var CTRL = 1000; -var SHIFT = 2000; -var ALT = 4000; -var FCK_STYLE_BLOCK = 0; -var FCK_STYLE_INLINE = 1; -var FCK_STYLE_OBJECT = 2; -String.prototype.Contains = function(A){ - return (this.indexOf(A) > -1); -}; -String.prototype.Equals = function(){ - var A = arguments; - if(A.length == 1 && A[0].pop){ - A = A[0]; - } - for(var i = 0; i < A.length; i++){ - if(this == A[i]){ - return true; - } - } - ; - return false; -}; -String.prototype.IEquals = function(){ - var A = this.toUpperCase(); - var B = arguments; - if(B.length == 1 && B[0].pop){ - B = B[0]; - } - for(var i = 0; i < B.length; i++){ - if(A == B[i].toUpperCase()){ - return true; - } - } - ; - return false; -}; -String.prototype.ReplaceAll = function(A, B){ - var C = this; - for(var i = 0; i < A.length; i++){ - C = C.replace(A[i], B[i]); - } - ; - return C; -}; -String.prototype.StartsWith = function(A){ - return (this.substr(0, A.length) == A); -}; -String.prototype.EndsWith = function(A, B){ - var C = this.length; - var D = A.length; - if(D > C){ - return false; - } - if(B){ - var E = new RegExp(A + '$', 'i'); - return E.test(this); - } else { - return (D == 0 || this.substr(C - D, D) == A); - } -}; -String.prototype.Remove = function(A, B){ - var s = ''; - if(A > 0){ - s = this.substring(0, A); - } - if(A + B < this.length){ - s += this.substring(A + B, this.length); - } - return s; -}; -String.prototype.Trim = function(){ - return this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, ''); -}; -String.prototype.LTrim = function(){ - return this.replace(/^[ \t\n\r]*/g, ''); -}; -String.prototype.RTrim = function(){ - return this.replace(/[ \t\n\r]*$/g, ''); -}; -String.prototype.ReplaceNewLineChars = function(A){ - return this.replace(/\n/g, A); -}; -String.prototype.Replace = function(A, B, C){ - if(typeof B == 'function'){ - return this.replace(A, function(){ - return B.apply(C || this, arguments); - }); - } else { - return this.replace(A, B); - } -}; -Array.prototype.IndexOf = function(A){ - for(var i = 0; i < this.length; i++){ - if(this[i] == A){ - return i; - } - } - ; - return-1; -}; -var s = navigator.userAgent.toLowerCase(); -var FCKBrowserInfo = {IsIE:/*@cc_on!@*/false,IsIE7:/*@cc_on!@*/false && (parseInt(s.match(/msie (\d+)/)[1], 10) >= 7),IsIE6:/*@cc_on!@*/false && (parseInt(s.match(/msie (\d+)/)[1], 10) >= 6),IsSafari:s.Contains(' applewebkit/'),IsOpera:!!window.opera,IsAIR:s.Contains(' adobeair/'),IsMac:s.Contains('macintosh')}; -(function(A){ - A.IsGecko = (navigator.product == 'Gecko') && !A.IsSafari && !A.IsOpera; - A.IsGeckoLike = (A.IsGecko || A.IsSafari || A.IsOpera); - if(A.IsGecko){ - var B = s.match(/rv:(\d+\.\d+)/); - var C = B && parseFloat(B[1]); - if(C){ - A.IsGecko10 = (C < 1.8); - A.IsGecko19 = (C > 1.8); - } - } -})(FCKBrowserInfo); -var FCKURLParams = {}; -(function(){ - var A = document.location.search.substr(1).split('&'); - for(var i = 0; i < A.length; i++){ - var B = A[i].split('='); - var C = decodeURIComponent(B[0]); - var D = decodeURIComponent(B[1]); - FCKURLParams[C] = D; - } -})(); -var FCKEvents = function(A){ - this.Owner = A; - this._RegisteredEvents = {}; -}; -FCKEvents.prototype.AttachEvent = function(A, B){ - var C; - if(!(C = this._RegisteredEvents[A])){ - this._RegisteredEvents[A] = [B]; - } else { - if(C.IndexOf(B) == -1){ - C.push(B); - } - } -}; -FCKEvents.prototype.FireEvent = function(A, B){ - var C = true; - var D = this._RegisteredEvents[A]; - if(D){ - for(var i = 0; i < D.length; i++){ - try{ - C = (D[i](this.Owner, B) && C); - } catch(e){ - if(e.number != -2146823277){ - throw e; - } - } - } - } - ; - return C; -}; -var FCKDataProcessor = function(){ -}; -FCKDataProcessor.prototype = {ConvertToHtml:function(A){ - if(FCKConfig.FullPage){ - FCK.DocTypeDeclaration = A.match(FCKRegexLib.DocTypeTag); - if(!FCKRegexLib.HasBodyTag.test(A)){ - A = '<body>' + A + '</body>'; - } - if(!FCKRegexLib.HtmlOpener.test(A)){ - A = '<html dir="' + FCKConfig.ContentLangDirection + '">' + A + '</html>'; - } - if(!FCKRegexLib.HeadOpener.test(A)){ - A = A.replace(FCKRegexLib.HtmlOpener, '$&<head><title></title></head>'); - } - return A; - } else { - var B = FCKConfig.DocType + '<html dir="' + FCKConfig.ContentLangDirection + '"'; - if(FCKBrowserInfo.IsIE && FCKConfig.DocType.length > 0 && !FCKRegexLib.Html4DocType.test(FCKConfig.DocType)){ - B += ' style="overflow-y: scroll"'; - } - B += '><head><title></title></head><body' + FCKConfig.GetBodyAttributes() + '>' + A + '</body></html>'; - return B; - } -},ConvertToDataFormat:function(A, B, C, D){ - var E = FCKXHtml.GetXHTML(A, !B, D); - if(C && FCKRegexLib.EmptyOutParagraph.test(E)){ - return ''; - } - return E; -},FixHtml:function(A){ - return A; -}}; -var FCK = {Name:FCKURLParams['InstanceName'],Status:0,EditMode:0,Toolbar:null,HasFocus:false,DataProcessor:new FCKDataProcessor(),GetInstanceObject:(function(){ - var w = window; - return function(name){ - return w[name]; - } -})(),AttachToOnSelectionChange:function(A){ - this.Events.AttachEvent('OnSelectionChange', A); -},GetLinkedFieldValue:function(){ - return this.LinkedField.value; -},GetParentForm:function(){ - return this.LinkedField.form; -},StartupValue:'',IsDirty:function(){ - if(this.EditMode == 1){ - return (this.StartupValue != this.EditingArea.Textarea.value); - } else { - if(!this.EditorDocument){ - return false; - } - return (this.StartupValue != this.EditorDocument.body.innerHTML); - } -},ResetIsDirty:function(){ - if(this.EditMode == 1){ - this.StartupValue = this.EditingArea.Textarea.value; - } else if(this.EditorDocument.body){ - this.StartupValue = this.EditorDocument.body.innerHTML; - } -},StartEditor:function(){ - this.TempBaseTag = FCKConfig.BaseHref.length > 0 ? '<base href="' + FCKConfig.BaseHref + '" _fcktemp="true"></base>' : ''; - var A = FCK.KeystrokeHandler = new FCKKeystrokeHandler(); - A.OnKeystroke = _FCK_KeystrokeHandler_OnKeystroke; - A.SetKeystrokes(FCKConfig.Keystrokes); - if(FCKBrowserInfo.IsIE7){ - if((CTRL + 86) in A.Keystrokes){ - A.SetKeystrokes([CTRL + 86,true]); - } - if((SHIFT + 45) in A.Keystrokes){ - A.SetKeystrokes([SHIFT + 45,true]); - } - } - ; - A.SetKeystrokes([CTRL + 8,true]); - this.EditingArea = new FCKEditingArea(document.getElementById('xEditingArea')); - this.EditingArea.FFSpellChecker = FCKConfig.FirefoxSpellChecker; - this.SetData(this.GetLinkedFieldValue(), true); - FCKTools.AddEventListener(document, "keydown", this._TabKeyHandler); - this.AttachToOnSelectionChange(_FCK_PaddingNodeListener); - if(FCKBrowserInfo.IsGecko){ - this.AttachToOnSelectionChange(this._ExecCheckEmptyBlock); - } -},Focus:function(){ - FCK.EditingArea.Focus(); -},SetStatus:function(A){ - this.Status = A; - if(A == 1){ - FCKFocusManager.AddWindow(window, true); - if(FCKBrowserInfo.IsIE){ - FCKFocusManager.AddWindow(window.frameElement, true); - } - if(FCKConfig.StartupFocus){ - FCK.Focus(); - } - } - ; - this.Events.FireEvent('OnStatusChange', A); -},FixBody:function(){ - var A = FCKConfig.EnterMode; - if(A != 'p' && A != 'div'){ - return; - } - var B = this.EditorDocument; - if(!B){ - return; - } - var C = B.body; - if(!C){ - return; - } - FCKDomTools.TrimNode(C); - var D = C.firstChild; - var E; - while(D){ - var F = false; - switch(D.nodeType){case 1:var G = D.nodeName.toLowerCase();if(!FCKListsLib.BlockElements[G] && G != 'li' && !D.getAttribute('_fckfakelement') && D.getAttribute('_moz_dirty') == null){ - F = true; - }break;case 3:if(E || D.nodeValue.Trim().length > 0){ - F = true; - }break;case 8:if(E){ - F = true; - }break; - } - ; - if(F){ - var H = D.parentNode; - if(!E){ - E = H.insertBefore(B.createElement(A), D); - } - E.appendChild(H.removeChild(D)); - D = E.nextSibling; - } else { - if(E){ - FCKDomTools.TrimNode(E); - E = null; - } - ; - D = D.nextSibling; - } - } - ; - if(E){ - FCKDomTools.TrimNode(E); - } -},GetData:function(A){ - FCK.Events.FireEvent("OnBeforeGetData"); - if(FCK.EditMode == 1){ - return FCK.EditingArea.Textarea.value; - } - this.FixBody(); - var B = FCK.EditorDocument; - if(!B){ - return null; - } - var C = FCKConfig.FullPage; - var D = FCK.DataProcessor.ConvertToDataFormat(C ? B.documentElement : B.body, !C, FCKConfig.IgnoreEmptyParagraphValue, A); - D = FCK.ProtectEventsRestore(D); - if(FCKBrowserInfo.IsIE){ - D = D.replace(FCKRegexLib.ToReplace, '$1'); - } - if(C){ - if(FCK.DocTypeDeclaration && FCK.DocTypeDeclaration.length > 0){ - D = FCK.DocTypeDeclaration + '\n' + D; - } - if(FCK.XmlDeclaration && FCK.XmlDeclaration.length > 0){ - D = FCK.XmlDeclaration + '\n' + D; - } - } - ; - D = FCKConfig.ProtectedSource.Revert(D); - setTimeout(function(){ - FCK.Events.FireEvent("OnAfterGetData"); - }, 0); - return D; -},UpdateLinkedField:function(){ - var A = FCK.GetXHTML(FCKConfig.FormatOutput); - if(FCKConfig.HtmlEncodeOutput){ - A = FCKTools.HTMLEncode(A); - } - FCK.LinkedField.value = A; - FCK.Events.FireEvent('OnAfterLinkedFieldUpdate'); -},RegisteredDoubleClickHandlers:{},OnDoubleClick:function(A){ - var B = FCK.RegisteredDoubleClickHandlers[A.tagName.toUpperCase()]; - if(B){ - for(var i = 0; i < B.length; i++){ - B[i](A); - } - } - ; - B = FCK.RegisteredDoubleClickHandlers['*']; - if(B){ - for(var i = 0; i < B.length; i++){ - B[i](A); - } - } -},RegisterDoubleClickHandler:function(A, B){ - var C = B || '*'; - C = C.toUpperCase(); - var D; - if(!(D = FCK.RegisteredDoubleClickHandlers[C])){ - FCK.RegisteredDoubleClickHandlers[C] = [A]; - } else { - if(D.IndexOf(A) == -1){ - D.push(A); - } - } -},OnAfterSetHTML:function(){ - FCKDocumentProcessor.Process(FCK.EditorDocument); - FCKUndo.SaveUndoStep(); - FCK.Events.FireEvent('OnSelectionChange'); - FCK.Events.FireEvent('OnAfterSetHTML'); -},ProtectUrls:function(A){ - A = A.replace(FCKRegexLib.ProtectUrlsA, '$& _fcksavedurl=$1'); - A = A.replace(FCKRegexLib.ProtectUrlsImg, '$& _fcksavedurl=$1'); - A = A.replace(FCKRegexLib.ProtectUrlsArea, '$& _fcksavedurl=$1'); - return A; -},ProtectEvents:function(A){ - return A.replace(FCKRegexLib.TagsWithEvent, _FCK_ProtectEvents_ReplaceTags); -},ProtectEventsRestore:function(A){ - return A.replace(FCKRegexLib.ProtectedEvents, _FCK_ProtectEvents_RestoreEvents); -},ProtectTags:function(A){ - var B = FCKConfig.ProtectedTags; - if(FCKBrowserInfo.IsIE){ - B += B.length > 0 ? '|ABBR|XML|EMBED|OBJECT' : 'ABBR|XML|EMBED|OBJECT'; - } - var C; - if(B.length > 0){ - C = new RegExp('<(' + B + ')(?!\w|:)', 'gi'); - A = A.replace(C, '<FCK:$1'); - C = new RegExp('<\/(' + B + ')>', 'gi'); - A = A.replace(C, '<\/FCK:$1>'); - } - ; - B = 'META'; - if(FCKBrowserInfo.IsIE){ - B += '|HR'; - } - C = new RegExp('<((' + B + ')(?=\\s|>|/)[\\s\\S]*?)/?>', 'gi'); - A = A.replace(C, '<FCK:$1 />'); - return A; -},SetData:function(A, B){ - this.EditingArea.Mode = FCK.EditMode; - if(FCKBrowserInfo.IsIE && FCK.EditorDocument){ - FCK.EditorDocument.detachEvent("onselectionchange", Doc_OnSelectionChange); - } - ; - FCKTempBin.Reset(); - FCK.Selection.Release(); - if(FCK.EditMode == 0){ - this._ForceResetIsDirty = (B === true); - A = FCKConfig.ProtectedSource.Protect(A); - A = FCK.DataProcessor.ConvertToHtml(A); - A = A.replace(FCKRegexLib.InvalidSelfCloseTags, '$1></$2>'); - A = FCK.ProtectEvents(A); - A = FCK.ProtectUrls(A); - A = FCK.ProtectTags(A); - if(FCK.TempBaseTag.length > 0 && !FCKRegexLib.HasBaseTag.test(A)){ - A = A.replace(FCKRegexLib.HeadOpener, '$&' + FCK.TempBaseTag); - } - var C = ''; - if(!FCKConfig.FullPage){ - C += _FCK_GetEditorAreaStyleTags(); - } - if(FCKBrowserInfo.IsIE){ - C += FCK._GetBehaviorsStyle(); - } else if(FCKConfig.ShowBorders){ - C += FCKTools.GetStyleHtml(FCK_ShowTableBordersCSS, true); - } - C += FCKTools.GetStyleHtml(FCK_InternalCSS, true); - A = A.replace(FCKRegexLib.HeadCloser, C + '$&'); - this.EditingArea.OnLoad = _FCK_EditingArea_OnLoad; - this.EditingArea.Start(A); - } else { - FCK.EditorWindow = null; - FCK.EditorDocument = null; - FCKDomTools.PaddingNode = null; - this.EditingArea.OnLoad = null; - this.EditingArea.Start(A); - this.EditingArea.Textarea._FCKShowContextMenu = true; - FCK.EnterKeyHandler = null; - if(B){ - this.ResetIsDirty(); - } - FCK.KeystrokeHandler.AttachToElement(this.EditingArea.Textarea); - this.EditingArea.Textarea.focus(); - FCK.Events.FireEvent('OnAfterSetHTML'); - } - ; - if(window.onresize){ - window.onresize(); - } -},RedirectNamedCommands:{},ExecuteNamedCommand:function(A, B, C, D){ - if(!D){ - FCKUndo.SaveUndoStep(); - } - if(!C && FCK.RedirectNamedCommands[A] != null){ - FCK.ExecuteRedirectedNamedCommand(A, B); - } else { - FCK.Focus(); - FCK.EditorDocument.execCommand(A, false, B); - FCK.Events.FireEvent('OnSelectionChange'); - } - ; - if(!D){ - FCKUndo.SaveUndoStep(); - } -},GetNamedCommandState:function(A){ - try{ - if(FCKBrowserInfo.IsSafari && FCK.EditorWindow && A.IEquals('Paste')){ - return 0; - } - if(!FCK.EditorDocument.queryCommandEnabled(A)){ - return -1; - } else { - return FCK.EditorDocument.queryCommandState(A) ? 1 : 0; - } - } catch (e){ - return 0; - } -},GetNamedCommandValue:function(A){ - var B = ''; - var C = FCK.GetNamedCommandState(A); - if(C == -1){ - return null; - } - try{ - B = this.EditorDocument.queryCommandValue(A); - } catch(e){ - } - ; - return B ? B : ''; -},Paste:function(A){ - if(FCK.Status != 2 || !FCK.Events.FireEvent('OnPaste')){ - return false; - } - return A || FCK._ExecPaste(); -},PasteFromWord:function(){ - FCKDialog.OpenDialog('FCKDialog_Paste', FCKLang.PasteFromWord, 'dialog/fck_paste.html', 400, 330, 'Word'); -},Preview:function(){ - var A; - if(FCKConfig.FullPage){ - if(FCK.TempBaseTag.length > 0){ - A = FCK.TempBaseTag + FCK.GetXHTML(); - } else { - A = FCK.GetXHTML(); - } - } else { - A = FCKConfig.DocType + '<html dir="' + FCKConfig.ContentLangDirection + '"><head>' + FCK.TempBaseTag + '<title>' + FCKLang.Preview + '</title>' + _FCK_GetEditorAreaStyleTags() + '</head><body' + FCKConfig.GetBodyAttributes() + '>' + FCK.GetXHTML() + '</body></html>'; - } - ; - var B = FCKConfig.ScreenWidth * 0.8; - var C = FCKConfig.ScreenHeight * 0.7; - var D = (FCKConfig.ScreenWidth - B) / 2; - var E = ''; - if(FCK_IS_CUSTOM_DOMAIN && FCKBrowserInfo.IsIE){ - window._FCKHtmlToLoad = A; - E = 'javascript:void( (function(){document.open() ;document.domain="' + document.domain + '" ;document.write( window.opener._FCKHtmlToLoad );document.close() ;window.opener._FCKHtmlToLoad = null ;})() )'; - } - ; - var F = window.open(E, null, 'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + B + ',height=' + C + ',left=' + D); - if(!FCK_IS_CUSTOM_DOMAIN || !FCKBrowserInfo.IsIE){ - F.document.write(A); - F.document.close(); - } -},SwitchEditMode:function(A){ - var B = (FCK.EditMode == 0); - var C = FCK.IsDirty(); - var D; - if(B){ - FCKCommands.GetCommand('ShowBlocks').SaveState(); - if(!A && FCKBrowserInfo.IsIE){ - FCKUndo.SaveUndoStep(); - } - D = FCK.GetXHTML(FCKConfig.FormatSource); - if(FCKBrowserInfo.IsIE){ - FCKTempBin.ToHtml(); - } - if(D == null){ - return false; - } - } else { - D = this.EditingArea.Textarea.value; - } - FCK.EditMode = B ? 1 : 0; - FCK.SetData(D, !C); - FCK.Focus(); - FCKTools.RunFunction(FCK.ToolbarSet.RefreshModeState, FCK.ToolbarSet); - return true; -},InsertElement:function(A){ - if(typeof A == 'string'){ - A = this.EditorDocument.createElement(A); - } - var B = A.nodeName.toLowerCase(); - FCKSelection.Restore(); - var C = new FCKDomRange(this.EditorWindow); - C.MoveToSelection(); - C.DeleteContents(); - if(FCKListsLib.BlockElements[B] != null){ - if(C.StartBlock){ - if(C.CheckStartOfBlock()){ - C.MoveToPosition(C.StartBlock, 3); - } else if(C.CheckEndOfBlock()){ - C.MoveToPosition(C.StartBlock, 4); - } else { - C.SplitBlock(); - } - } - ; - C.InsertNode(A); - var D = FCKDomTools.GetNextSourceElement(A, false, null, ['hr','br','param','img','area','input'], true); - if(!D && FCKConfig.EnterMode != 'br'){ - D = this.EditorDocument.body.appendChild(this.EditorDocument.createElement(FCKConfig.EnterMode)); - if(FCKBrowserInfo.IsGeckoLike){ - FCKTools.AppendBogusBr(D); - } - } - ; - if(FCKListsLib.EmptyElements[B] == null){ - C.MoveToElementEditStart(A); - } else if(D){ - C.MoveToElementEditStart(D); - } else { - C.MoveToPosition(A, 4); - } - if(FCKBrowserInfo.IsGeckoLike){ - if(D){ - FCKDomTools.ScrollIntoView(D, false); - } - FCKDomTools.ScrollIntoView(A, false); - } - } else { - C.InsertNode(A); - C.SetStart(A, 4); - C.SetEnd(A, 4); - } - ; - C.Select(); - C.Release(); - this.Focus(); - return A; -},_InsertBlockElement:function(A){ -},_IsFunctionKey:function(A){ - if(A >= 16 && A <= 20){ - return true; - } - if(A == 27 || (A >= 33 && A <= 40)){ - return true; - } - if(A == 45){ - return true; - } - return false; -},_KeyDownListener:function(A){ - if(!A){ - A = FCK.EditorWindow.event; - } - if(FCK.EditorWindow){ - if(!FCK._IsFunctionKey(A.keyCode) && !(A.ctrlKey || A.metaKey) && ... (truncated)