code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
// tabs 2 /** * @fileoverview By Adam Wright, for The University of Western Australia * * Distributed under the same terms as Xinha itself. * This notice MUST stay intact for use (see license.txt). * * Heavily modified by Yermo Lamers of DTLink, LLC, College Park, Md., USA. * For more info see http://www.areaedit.com */ /** * plugin Info */ EnterParagraphs._pluginInfo = { name : "EnterParagraphs", version : "1.0", developer : "Adam Wright", developer_url : "http://www.hipikat.org/", sponsor : "The University of Western Australia", sponsor_url : "http://www.uwa.edu.au/", license : "htmlArea" }; // ------------------------------------------------------------------ // "constants" /** * Whitespace Regex */ EnterParagraphs.prototype._whiteSpace = /^\s*$/; /** * The pragmatic list of which elements a paragraph may not contain */ EnterParagraphs.prototype._pExclusions = /^(address|blockquote|body|dd|div|dl|dt|fieldset|form|h1|h2|h3|h4|h5|h6|hr|li|noscript|ol|p|pre|table|ul)$/i; /** * elements which may contain a paragraph */ EnterParagraphs.prototype._pContainers = /^(body|del|div|fieldset|form|ins|map|noscript|object|td|th)$/i; /** * Elements which may not contain paragraphs, and would prefer a break to being split */ EnterParagraphs.prototype._pBreak = /^(address|pre|blockquote)$/i; /** * Elements which may not contain children */ EnterParagraphs.prototype._permEmpty = /^(area|base|basefont|br|col|frame|hr|img|input|isindex|link|meta|param)$/i; /** * Elements which count as content, as distinct from whitespace or containers */ EnterParagraphs.prototype._elemSolid = /^(applet|br|button|hr|img|input|table)$/i; /** * Elements which should get a new P, before or after, when enter is pressed at either end */ EnterParagraphs.prototype._pifySibling = /^(address|blockquote|del|div|dl|fieldset|form|h1|h2|h3|h4|h5|h6|hr|ins|map|noscript|object|ol|p|pre|table|ul|)$/i; EnterParagraphs.prototype._pifyForced = /^(ul|ol|dl|table)$/i; /** * Elements which should get a new P, before or after a close parent, when enter is pressed at either end */ EnterParagraphs.prototype._pifyParent = /^(dd|dt|li|td|th|tr)$/i; // --------------------------------------------------------------------- /** * EnterParagraphs Constructor */ function EnterParagraphs(editor) { this.editor = editor; // hook into the event handler to intercept key presses if we are using // gecko (Mozilla/FireFox) if (Xinha.is_gecko) { this.onKeyPress = this.__onKeyPress; } } // end of constructor. // ------------------------------------------------------------------ /** * name member for debugging * * This member is used to identify objects of this class in debugging * messages. */ EnterParagraphs.prototype.name = "EnterParagraphs"; /** * Gecko's a bit lacking in some odd ways... */ EnterParagraphs.prototype.insertAdjacentElement = function(ref,pos,el) { if ( pos == 'BeforeBegin' ) { ref.parentNode.insertBefore(el,ref); } else if ( pos == 'AfterEnd' ) { ref.nextSibling ? ref.parentNode.insertBefore(el,ref.nextSibling) : ref.parentNode.appendChild(el); } else if ( pos == 'AfterBegin' && ref.firstChild ) { ref.insertBefore(el,ref.firstChild); } else if ( pos == 'BeforeEnd' || pos == 'AfterBegin' ) { ref.appendChild(el); } }; // end of insertAdjacentElement() // ---------------------------------------------------------------- /** * Passes a global parent node or document fragment to forEachNode * * @param root node root node to start search from. * @param mode string function to apply to each node. * @param direction string traversal direction "ltr" (left to right) or "rtl" (right_to_left) * @param init boolean */ EnterParagraphs.prototype.forEachNodeUnder = function ( root, mode, direction, init ) { // Identify the first and last nodes to deal with var start, end; // nodeType 11 is DOCUMENT_FRAGMENT_NODE which is a container. if ( root.nodeType == 11 && root.firstChild ) { start = root.firstChild; end = root.lastChild; } else { start = end = root; } // traverse down the right hand side of the tree getting the last child of the last // child in each level until we reach bottom. while ( end.lastChild ) { end = end.lastChild; } return this.forEachNode( start, end, mode, direction, init); }; // end of forEachNodeUnder() // ----------------------------------------------------------------------- /** * perform a depth first descent in the direction requested. * * @param left_node node "start node" * @param right_node node "end node" * @param mode string function to apply to each node. cullids or emptyset. * @param direction string traversal direction "ltr" (left to right) or "rtl" (right_to_left) * @param init boolean or object. */ EnterParagraphs.prototype.forEachNode = function (left_node, right_node, mode, direction, init) { // returns "Brother" node either left or right. var getSibling = function(elem, direction) { return ( direction == "ltr" ? elem.nextSibling : elem.previousSibling ); }; var getChild = function(elem, direction) { return ( direction == "ltr" ? elem.firstChild : elem.lastChild ); }; var walk, lookup, fnReturnVal; // FIXME: init is a boolean in the emptyset case and an object in // the cullids case. Used inconsistently. var next_node = init; // used to flag having reached the last node. var done_flag = false; // loop ntil we've hit the last node in the given direction. // if we're going left to right that's the right_node and visa-versa. while ( walk != direction == "ltr" ? right_node : left_node ) { // on first entry, walk here is null. So this is how // we prime the loop with the first node. if ( !walk ) { walk = direction == "ltr" ? left_node : right_node; } else { // is there a child node? if ( getChild(walk,direction) ) { // descend down into the child. walk = getChild(walk,direction); } else { // is there a sibling node on this level? if ( getSibling(walk,direction) ) { // move to the sibling. walk = getSibling(walk,direction); } else { lookup = walk; // climb back up the tree until we find a level where we are not the end // node on the level (i.e. that we have a sibling in the direction // we are searching) or until we reach the end. while ( !getSibling(lookup,direction) && lookup != (direction == "ltr" ? right_node : left_node) ) { lookup = lookup.parentNode; } // did we find a level with a sibling? // walk = ( lookup.nextSibling ? lookup.nextSibling : lookup ) ; walk = ( getSibling(lookup,direction) ? getSibling(lookup,direction) : lookup ) ; } } } // end of else walk. // have we reached the end? either as a result of the top while loop or climbing // back out above. done_flag = (walk==( direction == "ltr" ? right_node : left_node)); // call the requested function on the current node. Functions // return an array. // // Possible functions are _fenCullIds, _fenEmptySet // // The situation is complicated by the fact that sometimes we want to // return the base node and sometimes we do not. // // next_node can be an object (this.takenIds), a node (text, el, etc) or false. switch( mode ) { case "cullids": fnReturnVal = this._fenCullIds(walk, next_node ); break; case "find_fill": fnReturnVal = this._fenEmptySet(walk, next_node, mode, done_flag); break; case "find_cursorpoint": fnReturnVal = this._fenEmptySet(walk, next_node, mode, done_flag); break; } // If this node wants us to return, return next_node if ( fnReturnVal[0] ) { return fnReturnVal[1]; } // are we done with the loop? if ( done_flag ) { break; } // Otherwise, pass to the next node if ( fnReturnVal[1] ) { next_node = fnReturnVal[1]; } } // end of while loop return false; }; // end of forEachNode() // ------------------------------------------------------------------- /** * Find a post-insertion node, only if all nodes are empty, or the first content * * @param node node current node beinge examined. * @param next_node node next node to be examined. * @param node string "find_fill" or "find_cursorpoint" * @param last_flag boolean is this the last node? */ EnterParagraphs.prototype._fenEmptySet = function( node, next_node, mode, last_flag) { // Mark this if it's the first base if ( !next_node && !node.firstChild ) { next_node = node; } // Is it an element node and is it considered content? (br, hr, etc) // or is it a text node that is not just whitespace? // or is it not an element node and not a text node? if ( (node.nodeType == 1 && this._elemSolid.test(node.nodeName)) || (node.nodeType == 3 && !this._whiteSpace.test(node.nodeValue)) || (node.nodeType != 1 && node.nodeType != 3) ) { switch( mode ) { case "find_fill": // does not return content. return new Array(true, false ); break; case "find_cursorpoint": // returns content return new Array(true, node ); break; } } // In either case (fill or findcursor) we return the base node. The avoids // problems in terminal cases (beginning or end of document or container tags) if ( last_flag ) { return new Array( true, next_node ); } return new Array( false, next_node ); }; // end of _fenEmptySet() // ------------------------------------------------------------------------------ /** * remove duplicate Id's. * * @param ep_ref enterparagraphs reference to enterparagraphs object */ EnterParagraphs.prototype._fenCullIds = function ( ep_ref, node, pong ) { // Check for an id, blast it if it's in the store, otherwise add it if ( node.id ) { pong[node.id] ? node.id = '' : pong[node.id] = true; } return new Array(false,pong); }; // --------------------------------------------------------------------------------- /** * Grabs a range suitable for paragraph stuffing * * @param rng Range * @param search_direction string "left" or "right" * * @todo check blank node issue in roaming loop. */ EnterParagraphs.prototype.processSide = function( rng, search_direction) { var next = function(element, search_direction) { return ( search_direction == "left" ? element.previousSibling : element.nextSibling ); }; var node = search_direction == "left" ? rng.startContainer : rng.endContainer; var offset = search_direction == "left" ? rng.startOffset : rng.endOffset; var roam, start = node; // Never start with an element, because then the first roaming node might // be on the exclusion list and we wouldn't know until it was too late while ( start.nodeType == 1 && !this._permEmpty.test(start.nodeName) ) { start = ( offset ? start.lastChild : start.firstChild ); } // Climb the tree, left or right, until our course of action presents itself // // if roam is NULL try start. // if roam is NOT NULL, try next node in our search_direction // If that node is NULL, get our parent node. // // If all the above turns out NULL end the loop. // // FIXME: gecko (firefox 1.0.3) - enter "test" into an empty document and press enter. // sometimes this loop finds a blank text node, sometimes it doesn't. while ( roam = roam ? ( next(roam,search_direction) ? next(roam,search_direction) : roam.parentNode ) : start ) { // next() is an inline function defined above that returns the next node depending // on the direction we're searching. if ( next(roam,search_direction) ) { // If the next sibling's on the exclusion list, stop before it if ( this._pExclusions.test(next(roam,search_direction).nodeName) ) { return this.processRng(rng, search_direction, roam, next(roam,search_direction), (search_direction == "left"?'AfterEnd':'BeforeBegin'), true, false); } } else { // If our parent's on the container list, stop inside it if (this._pContainers.test(roam.parentNode.nodeName)) { return this.processRng(rng, search_direction, roam, roam.parentNode, (search_direction == "left"?'AfterBegin':'BeforeEnd'), true, false); } else if (this._pExclusions.test(roam.parentNode.nodeName)) { // chop without wrapping if (this._pBreak.test(roam.parentNode.nodeName)) { return this.processRng(rng, search_direction, roam, roam.parentNode, (search_direction == "left"?'AfterBegin':'BeforeEnd'), false, (search_direction == "left" ?true:false)); } else { // the next(roam,search_direction) in this call is redundant since we know it's false // because of the "if next(roam,search_direction)" above. // // the final false prevents this range from being wrapped in <p>'s most likely // because it's already wrapped. return this.processRng(rng, search_direction, (roam = roam.parentNode), (next(roam,search_direction) ? next(roam,search_direction) : roam.parentNode), (next(roam,search_direction) ? (search_direction == "left"?'AfterEnd':'BeforeBegin') : (search_direction == "left"?'AfterBegin':'BeforeEnd')), false, false); } } } } }; // end of processSide() // ------------------------------------------------------------------------------ /** * processRng - process Range. * * Neighbour and insertion identify where the new node, roam, needs to enter * the document; landmarks in our selection will be deleted before insertion * * @param rn Range original selected range * @param search_direction string Direction to search in. * @param roam node * @param insertion string may be AfterBegin of BeforeEnd * @return array */ EnterParagraphs.prototype.processRng = function(rng, search_direction, roam, neighbour, insertion, pWrap, preBr) { var node = search_direction == "left" ? rng.startContainer : rng.endContainer; var offset = search_direction == "left" ? rng.startOffset : rng.endOffset; // Define the range to cut, and extend the selection range to the same boundary var editor = this.editor; var newRng = editor._doc.createRange(); newRng.selectNode(roam); // extend the range in the given direction. if ( search_direction == "left") { newRng.setEnd(node, offset); rng.setStart(newRng.startContainer, newRng.startOffset); } else if ( search_direction == "right" ) { newRng.setStart(node, offset); rng.setEnd(newRng.endContainer, newRng.endOffset); } // Clone the range and remove duplicate ids it would otherwise produce var cnt = newRng.cloneContents(); // in this case "init" is an object not a boolen. this.forEachNodeUnder( cnt, "cullids", "ltr", this.takenIds, false, false); // Special case, for inserting paragraphs before some blocks when caret is at // their zero offset. // // Used to "open up space" in front of a list, table. Usefull if the list is at // the top of the document. (otherwise you'd have no way of "moving it down"). var pify, pifyOffset, fill; pify = search_direction == "left" ? (newRng.endContainer.nodeType == 3 ? true:false) : (newRng.startContainer.nodeType == 3 ? false:true); pifyOffset = pify ? newRng.startOffset : newRng.endOffset; pify = pify ? newRng.startContainer : newRng.endContainer; if ( this._pifyParent.test(pify.nodeName) && pify.parentNode.childNodes.item(0) == pify ) { while ( !this._pifySibling.test(pify.nodeName) ) { pify = pify.parentNode; } } // NODE TYPE 11 is DOCUMENT_FRAGMENT NODE // I do not profess to understand any of this, simply applying a patch that others say is good - ticket:446 if ( cnt.nodeType == 11 && !cnt.firstChild) { if (pify.nodeName != "BODY" || (pify.nodeName == "BODY" && pifyOffset != 0)) { //WKR: prevent body tag in empty doc cnt.appendChild(editor._doc.createElement(pify.nodeName)); } } // YmL: Added additional last parameter for fill case to work around logic // error in forEachNode() fill = this.forEachNodeUnder(cnt, "find_fill", "ltr", false ); if ( fill && this._pifySibling.test(pify.nodeName) && ( (pifyOffset == 0) || ( pifyOffset == 1 && this._pifyForced.test(pify.nodeName) ) ) ) { roam = editor._doc.createElement( 'p' ); roam.innerHTML = "&nbsp;"; // roam = editor._doc.createElement('p'); // roam.appendChild(editor._doc.createElement('br')); // for these cases, if we are processing the left hand side we want it to halt // processing instead of doing the right hand side. (Avoids adding another <p>&nbsp</p> // after the list etc. if ((search_direction == "left" ) && pify.previousSibling) { return new Array(pify.previousSibling, 'AfterEnd', roam); } else if (( search_direction == "right") && pify.nextSibling) { return new Array(pify.nextSibling, 'BeforeBegin', roam); } else { return new Array(pify.parentNode, (search_direction == "left"?'AfterBegin':'BeforeEnd'), roam); } } // If our cloned contents are 'content'-less, shove a break in them if ( fill ) { // Ill-concieved? // // 3 is a TEXT node and it should be empty. // if ( fill.nodeType == 3 ) { // fill = fill.parentNode; fill = editor._doc.createDocumentFragment(); } if ( (fill.nodeType == 1 && !this._elemSolid.test()) || fill.nodeType == 11 ) { // FIXME:/CHECKME: When Xinha is switched from WYSIWYG to text mode // Xinha.getHTMLWrapper() will strip out the trailing br. Not sure why. // fill.appendChild(editor._doc.createElement('br')); var pterminator = editor._doc.createElement( 'p' ); pterminator.innerHTML = "&nbsp;"; fill.appendChild( pterminator ); } else { // fill.parentNode.insertBefore(editor._doc.createElement('br'),fill); var pterminator = editor._doc.createElement( 'p' ); pterminator.innerHTML = "&nbsp;"; fill.parentNode.insertBefore(parentNode,fill); } } // YmL: If there was no content replace with fill // (previous code did not use fill and we ended up with the // <p>test</p><p></p> because Gecko was finding two empty text nodes // when traversing on the right hand side of an empty document. if ( fill ) { roam = fill; } else { // And stuff a shiny new object with whatever contents we have roam = (pWrap || (cnt.nodeType == 11 && !cnt.firstChild)) ? editor._doc.createElement('p') : editor._doc.createDocumentFragment(); roam.appendChild(cnt); } if (preBr) { roam.appendChild(editor._doc.createElement('br')); } // Return the nearest relative, relative insertion point and fragment to insert return new Array(neighbour, insertion, roam); }; // end of processRng() // ---------------------------------------------------------------------------------- /** * are we an <li> that should be handled by the browser? * * there is no good way to "get out of" ordered or unordered lists from Javascript. * We have to pass the onKeyPress 13 event to the browser so it can take care of * getting us "out of" the list. * * The Gecko engine does a good job of handling all the normal <li> cases except the "press * enter at the first position" where we want a <p>&nbsp</p> inserted before the list. The * built-in behavior is to open up a <li> before the current entry (not good). * * @param rng Range range. */ EnterParagraphs.prototype.isNormalListItem = function(rng) { var node, listNode; node = rng.startContainer; if (( typeof node.nodeName != 'undefined') && ( node.nodeName.toLowerCase() == 'li' )) { // are we a list item? listNode = node; } else if (( typeof node.parentNode != 'undefined' ) && ( typeof node.parentNode.nodeName != 'undefined' ) && ( node.parentNode.nodeName.toLowerCase() == 'li' )) { // our parent is a list item. listNode = node.parentNode; } else { // neither we nor our parent are a list item. this is not a normal // li case. return false; } // at this point we have a listNode. Is it the first list item? if ( ! listNode.previousSibling ) { // are we on the first character of the first li? if ( rng.startOffset == 0 ) { return false; } } return true; }; // end of isNormalListItem() // ---------------------------------------------------------------------------------- /** * Called when a key is pressed in the editor */ EnterParagraphs.prototype.__onKeyPress = function(ev) { // If they've hit enter and shift is not pressed, handle it if (ev.keyCode == 13 && !ev.shiftKey && this.editor._iframe.contentWindow.getSelection) { return this.handleEnter(ev); } }; // end of _onKeyPress() // ----------------------------------------------------------------------------------- /** * Handles the pressing of an unshifted enter for Gecko */ EnterParagraphs.prototype.handleEnter = function(ev) { var cursorNode; // Grab the selection and associated range var sel = this.editor.getSelection(); var rng = this.editor.createRange(sel); // if we are at the end of a list and the node is empty let the browser handle // it to get us out of the list. if ( this.isNormalListItem(rng) ) { return true; } // as far as I can tell this isn't actually used. this.takenIds = new Object(); // Grab ranges for document re-stuffing, if appropriate // // pStart and pEnd are arrays consisting of // [0] neighbor node // [1] insertion type // [2] roam var pStart = this.processSide(rng, "left"); var pEnd = this.processSide(rng, "right"); // used to position the cursor after insertion. cursorNode = pEnd[2]; // Get rid of everything local to the selection sel.removeAllRanges(); rng.deleteContents(); // Grab a node we'll have after insertion, since fragments will be lost // // we'll use this to position the cursor. var holdEnd = this.forEachNodeUnder( cursorNode, "find_cursorpoint", "ltr", false, true); if ( ! holdEnd ) { alert( "INTERNAL ERROR - could not find place to put cursor after ENTER" ); } // Insert our carefully chosen document fragments if ( pStart ) { this.insertAdjacentElement(pStart[0], pStart[1], pStart[2]); } if ( pEnd && pEnd.nodeType != 1) { this.insertAdjacentElement(pEnd[0], pEnd[1], pEnd[2]); } // Move the caret in front of the first good text element if ((holdEnd) && (this._permEmpty.test(holdEnd.nodeName) )) { var prodigal = 0; while ( holdEnd.parentNode.childNodes.item(prodigal) != holdEnd ) { prodigal++; } sel.collapse( holdEnd.parentNode, prodigal); } else { // holdEnd might be false. try { sel.collapse(holdEnd, 0); // interestingly, scrollToElement() scroll so the top if holdEnd is a text node. if ( holdEnd.nodeType == 3 ) { holdEnd = holdEnd.parentNode; } this.editor.scrollToElement(holdEnd); } catch (e) { // we could try to place the cursor at the end of the document. } } this.editor.updateToolbar(); Xinha._stopEvent(ev); return true; }; // end of handleEnter() // END
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Gecko/paraHandlerBest.js
JavaScript
art
24,567
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the Gecko compatability plugin, part of the Xinha core. -- -- The file is loaded as a special plugin by the Xinha Core when -- Xinha is being run under a Gecko based browser with the Midas -- editing API. -- -- It provides implementation and specialisation for various methods -- in the core where different approaches per browser are required. -- -- Design Notes:: -- Most methods here will simply be overriding Xinha.prototype.<method> -- and should be called that, but methods specific to Gecko should -- be a part of the Gecko.prototype, we won't trample on namespace -- that way. -- -- $HeadURL: http://svn.xinha.org/trunk/modules/Gecko/Gecko.js $ -- $LastChangedDate: 2008-10-13 06:42:42 +1300 (Mon, 13 Oct 2008) $ -- $LastChangedRevision: 1084 $ -- $LastChangedBy: ray $ --------------------------------------------------------------------------*/ Gecko._pluginInfo = { name : "Gecko", origin : "Xinha Core", version : "$LastChangedRevision: 1084 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/Gecko/Gecko.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; function Gecko(editor) { this.editor = editor; editor.Gecko = this; } /** Allow Gecko to handle some key events in a special way. */ Gecko.prototype.onKeyPress = function(ev) { var editor = this.editor; var s = editor.getSelection(); // Handle shortcuts if(editor.isShortCut(ev)) { switch(editor.getKey(ev).toLowerCase()) { case 'z': { if(editor._unLink && editor._unlinkOnUndo) { Xinha._stopEvent(ev); editor._unLink(); editor.updateToolbar(); return true; } } break; case 'a': { // KEY select all sel = editor.getSelection(); sel.removeAllRanges(); range = editor.createRange(); range.selectNodeContents(editor._doc.body); sel.addRange(range); Xinha._stopEvent(ev); return true; } break; case 'v': { // If we are not using htmlareaPaste, don't let Xinha try and be fancy but let the // event be handled normally by the browser (don't stopEvent it) if(!editor.config.htmlareaPaste) { return true; } } break; } } // Handle normal characters switch(editor.getKey(ev)) { // Space, see if the text just typed looks like a URL, or email address // and link it appropriatly case ' ': { var autoWrap = function (textNode, tag) { var rightText = textNode.nextSibling; if ( typeof tag == 'string') { tag = editor._doc.createElement(tag); } var a = textNode.parentNode.insertBefore(tag, rightText); Xinha.removeFromParent(textNode); a.appendChild(textNode); rightText.data = ' ' + rightText.data; s.collapse(rightText, 1); editor._unLink = function() { var t = a.firstChild; a.removeChild(t); a.parentNode.insertBefore(t, a); Xinha.removeFromParent(a); editor._unLink = null; editor._unlinkOnUndo = false; }; editor._unlinkOnUndo = true; return a; }; if ( editor.config.convertUrlsToLinks && s && s.isCollapsed && s.anchorNode.nodeType == 3 && s.anchorNode.data.length > 3 && s.anchorNode.data.indexOf('.') >= 0 ) { var midStart = s.anchorNode.data.substring(0,s.anchorOffset).search(/\S{4,}$/); if ( midStart == -1 ) { break; } if ( editor._getFirstAncestor(s, 'a') ) { break; // already in an anchor } var matchData = s.anchorNode.data.substring(0,s.anchorOffset).replace(/^.*?(\S*)$/, '$1'); var mEmail = matchData.match(Xinha.RE_email); if ( mEmail ) { var leftTextEmail = s.anchorNode; var rightTextEmail = leftTextEmail.splitText(s.anchorOffset); var midTextEmail = leftTextEmail.splitText(midStart); autoWrap(midTextEmail, 'a').href = 'mailto:' + mEmail[0]; break; } RE_date = /([0-9]+\.)+/; //could be date or ip or something else ... RE_ip = /(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/; var mUrl = matchData.match(Xinha.RE_url); if ( mUrl ) { if (RE_date.test(matchData)) { break; //ray: disabling linking of IP numbers because of general bugginess (see Ticket #1085) /*if (!RE_ip.test(matchData)) { break; }*/ } var leftTextUrl = s.anchorNode; var rightTextUrl = leftTextUrl.splitText(s.anchorOffset); var midTextUrl = leftTextUrl.splitText(midStart); autoWrap(midTextUrl, 'a').href = (mUrl[1] ? mUrl[1] : 'http://') + mUrl[2]; break; } } } break; } // Handle special keys switch ( ev.keyCode ) { /* This is now handled by a plugin case 13: // ENTER break;*/ case 27: // ESCAPE { if ( editor._unLink ) { editor._unLink(); Xinha._stopEvent(ev); } break; } break; case 8: // KEY backspace case 46: // KEY delete { // We handle the mozilla backspace directly?? if ( !ev.shiftKey && this.handleBackspace() ) { Xinha._stopEvent(ev); } } default: { editor._unlinkOnUndo = false; // Handle the "auto-linking", specifically this bit of code sets up a handler on // an self-titled anchor (eg <a href="http://www.gogo.co.nz/">www.gogo.co.nz</a>) // when the text content is edited, such that it will update the href on the anchor if ( s.anchorNode && s.anchorNode.nodeType == 3 ) { // See if we might be changing a link var a = editor._getFirstAncestor(s, 'a'); // @todo: we probably need here to inform the setTimeout below that we not changing a link and not start another setTimeout if ( !a ) { break; // not an anchor } if ( !a._updateAnchTimeout ) { if ( s.anchorNode.data.match(Xinha.RE_email) && a.href.match('mailto:' + s.anchorNode.data.trim()) ) { var textNode = s.anchorNode; var fnAnchor = function() { a.href = 'mailto:' + textNode.data.trim(); // @fixme: why the hell do another timeout is started ? // This lead to never ending timer if we dont remove this line // But when removed, the email is not correctly updated // // - to fix this we should make fnAnchor check to see if textNode.data has // stopped changing for say 5 seconds and if so we do not make this setTimeout a._updateAnchTimeout = setTimeout(fnAnchor, 250); }; a._updateAnchTimeout = setTimeout(fnAnchor, 1000); break; } var m = s.anchorNode.data.match(Xinha.RE_url); if ( m && a.href.match(new RegExp( 'http(s)?://' + Xinha.escapeStringForRegExp( s.anchorNode.data.trim() ) ) ) ) { var txtNode = s.anchorNode; var fnUrl = function() { // Sometimes m is undefined becase the url is not an url anymore (was www.url.com and become for example www.url) // ray: shouldn't the link be un-linked then? m = txtNode.data.match(Xinha.RE_url); if(m) { a.href = (m[1] ? m[1] : 'http://') + m[2]; } // @fixme: why the hell do another timeout is started ? // This lead to never ending timer if we dont remove this line // But when removed, the url is not correctly updated // // - to fix this we should make fnUrl check to see if textNode.data has // stopped changing for say 5 seconds and if so we do not make this setTimeout a._updateAnchTimeout = setTimeout(fnUrl, 250); }; a._updateAnchTimeout = setTimeout(fnUrl, 1000); } } } } break; } return false; // Let other plugins etc continue from here. } /** When backspace is hit, the Gecko onKeyPress will execute this method. * I don't remember what the exact purpose of this is though :-( */ Gecko.prototype.handleBackspace = function() { var editor = this.editor; setTimeout( function() { var sel = editor.getSelection(); var range = editor.createRange(sel); var SC = range.startContainer; var SO = range.startOffset; var EC = range.endContainer; var EO = range.endOffset; var newr = SC.nextSibling; if ( SC.nodeType == 3 ) { SC = SC.parentNode; } if ( ! ( /\S/.test(SC.tagName) ) ) { var p = document.createElement("p"); while ( SC.firstChild ) { p.appendChild(SC.firstChild); } SC.parentNode.insertBefore(p, SC); Xinha.removeFromParent(SC); var r = range.cloneRange(); r.setStartBefore(newr); r.setEndAfter(newr); r.extractContents(); sel.removeAllRanges(); sel.addRange(r); } }, 10); }; Gecko.prototype.inwardHtml = function(html) { // Midas uses b and i internally instead of strong and em // Xinha will use strong and em externally (see Xinha.prototype.outwardHtml) html = html.replace(/<(\/?)strong(\s|>|\/)/ig, "<$1b$2"); html = html.replace(/<(\/?)em(\s|>|\/)/ig, "<$1i$2"); // Both IE and Gecko use strike internally instead of del (#523) // Xinha will present del externally (see Xinha.prototype.outwardHtml html = html.replace(/<(\/?)del(\s|>|\/)/ig, "<$1strike$2"); return html; } Gecko.prototype.outwardHtml = function(html) { // ticket:56, the "greesemonkey" plugin for Firefox adds this junk, // so we strip it out. Original submitter gave a plugin, but that's // a bit much just for this IMHO - james html = html.replace(/<script[\s]*src[\s]*=[\s]*['"]chrome:\/\/.*?["']>[\s]*<\/script>/ig, ''); return html; } Gecko.prototype.onExecCommand = function(cmdID, UI, param) { try { // useCSS deprecated & replaced by styleWithCSS this.editor._doc.execCommand('useCSS', false, true); //switch useCSS off (true=off) this.editor._doc.execCommand('styleWithCSS', false, false); //switch styleWithCSS off } catch (ex) {} switch(cmdID) { case 'paste': { alert(Xinha._lc("The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.")); return true; // Indicate paste is done, stop command being issued to browser by Xinha.prototype.execCommand } break; case 'removeformat': var editor = this.editor; var sel = editor.getSelection(); var selSave = editor.saveSelection(sel); var range = editor.createRange(sel); var els = editor._doc.body.getElementsByTagName('*'); var start = ( range.startContainer.nodeType == 1 ) ? range.startContainer : range.startContainer.parentNode; var i, el; if (sel.isCollapsed) range.selectNodeContents(editor._doc.body); for (i=0; i<els.length;i++) { el = els[i]; if ( range.isPointInRange(el, 0) || (els[i] == start && range.startOffset == 0)) { el.removeAttribute('style'); } } this.editor._doc.execCommand(cmdID, UI, param); editor.restoreSelection(selSave); return true; break; } return false; } Gecko.prototype.onMouseDown = function(ev) { // Gecko doesn't select hr's on single click if (ev.target.tagName.toLowerCase() == "hr") { var sel = this.editor.getSelection(); var range = this.editor.createRange(sel); range.selectNode(ev.target); } } /*--------------------------------------------------------------------------*/ /*------- IMPLEMENTATION OF THE ABSTRACT "Xinha.prototype" METHODS ---------*/ /*--------------------------------------------------------------------------*/ /** Insert a node at the current selection point. * @param toBeInserted DomNode */ Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { if ( toBeInserted.ownerDocument != this._doc ) // as of FF3, Gecko is strict regarding the ownerDocument of an element { try { toBeInserted = this._doc.adoptNode( toBeInserted ); } catch (e) {} } var sel = this.getSelection(); var range = this.createRange(sel); // remove the current selection sel.removeAllRanges(); range.deleteContents(); var node = range.startContainer; var pos = range.startOffset; var selnode = toBeInserted; switch ( node.nodeType ) { case 3: // Node.TEXT_NODE // we have to split it at the caret position. if ( toBeInserted.nodeType == 3 ) { // do optimized insertion node.insertData(pos, toBeInserted.data); range = this.createRange(); range.setEnd(node, pos + toBeInserted.length); range.setStart(node, pos + toBeInserted.length); sel.addRange(range); } else { node = node.splitText(pos); if ( toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */ ) { selnode = selnode.firstChild; } node.parentNode.insertBefore(toBeInserted, node); this.selectNodeContents(selnode); this.updateToolbar(); } break; case 1: // Node.ELEMENT_NODE if ( toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */ ) { selnode = selnode.firstChild; } node.insertBefore(toBeInserted, node.childNodes[pos]); this.selectNodeContents(selnode); this.updateToolbar(); break; } }; /** Get the parent element of the supplied or current selection. * @param sel optional selection as returned by getSelection * @returns DomNode */ Xinha.prototype.getParentElement = function(sel) { if ( typeof sel == 'undefined' ) { sel = this.getSelection(); } var range = this.createRange(sel); try { var p = range.commonAncestorContainer; if ( !range.collapsed && range.startContainer == range.endContainer && range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes() ) { p = range.startContainer.childNodes[range.startOffset]; } while ( p.nodeType == 3 ) { p = p.parentNode; } return p; } catch (ex) { return null; } }; /** * Returns the selected element, if any. That is, * the element that you have last selected in the "path" * at the bottom of the editor, or a "control" (eg image) * * @returns null | DomNode */ Xinha.prototype.activeElement = function(sel) { if ( ( sel === null ) || this.selectionEmpty(sel) ) { return null; } // For Mozilla we just see if the selection is not collapsed (something is selected) // and that the anchor (start of selection) is an element. This might not be totally // correct, we possibly should do a simlar check to IE? if ( !sel.isCollapsed ) { if ( sel.anchorNode.childNodes.length > sel.anchorOffset && sel.anchorNode.childNodes[sel.anchorOffset].nodeType == 1 ) { return sel.anchorNode.childNodes[sel.anchorOffset]; } else if ( sel.anchorNode.nodeType == 1 ) { return sel.anchorNode; } else { return null; // return sel.anchorNode.parentNode; } } return null; }; /** * Determines if the given selection is empty (collapsed). * @param selection Selection object as returned by getSelection * @returns true|false */ Xinha.prototype.selectionEmpty = function(sel) { if ( !sel ) { return true; } if ( typeof sel.isCollapsed != 'undefined' ) { return sel.isCollapsed; } return true; }; /** * Returns a range object to be stored * and later restored with Xinha.prototype.restoreSelection() * * @returns Range */ Xinha.prototype.saveSelection = function() { return this.createRange(this.getSelection()).cloneRange(); } /** * Restores a selection previously stored * @param savedSelection Range object as returned by Xinha.prototype.restoreSelection() */ Xinha.prototype.restoreSelection = function(savedSelection) { try { var sel = this.getSelection(); sel.removeAllRanges(); sel.addRange(savedSelection); } catch (e) {} } /** * Selects the contents of the given node. If the node is a "control" type element, (image, form input, table) * the node itself is selected for manipulation. * * @param node DomNode * @param collapseToStart A boolean that, when supplied, says to collapse the selection. True collapses to the start, and false to the end. */ Xinha.prototype.selectNodeContents = function(node, collapseToStart) { this.focusEditor(); this.forceRedraw(); var range; var collapsed = typeof collapseToStart == "undefined" ? true : false; var sel = this.getSelection(); range = this._doc.createRange(); if ( !node ) { sel.removeAllRanges(); return; } // Tables and Images get selected as "objects" rather than the text contents if ( collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|textarea|select/) ) { range.selectNode(node); } else { range.selectNodeContents(node); } sel.removeAllRanges(); sel.addRange(range); if (typeof collapseToStart != "undefined") { if (collapseToStart) { sel.collapse(range.startContainer, range.startOffset); } else { sel.collapse(range.endContainer, range.endOffset); } } }; /** Insert HTML at the current position, deleting the selection if any. * * @param html string */ Xinha.prototype.insertHTML = function(html) { var sel = this.getSelection(); var range = this.createRange(sel); this.focusEditor(); // construct a new document fragment with the given HTML var fragment = this._doc.createDocumentFragment(); var div = this._doc.createElement("div"); div.innerHTML = html; while ( div.firstChild ) { // the following call also removes the node from div fragment.appendChild(div.firstChild); } // this also removes the selection var node = this.insertNodeAtSelection(fragment); }; /** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML. * * @returns string */ Xinha.prototype.getSelectedHTML = function() { var sel = this.getSelection(); if (sel.isCollapsed) return ''; var range = this.createRange(sel); return Xinha.getHTML(range.cloneContents(), false, this); }; /** Get a Selection object of the current selection. Note that selection objects are browser specific. * * @returns Selection */ Xinha.prototype.getSelection = function() { return this._iframe.contentWindow.getSelection(); }; /** Create a Range object from the given selection. Note that range objects are browser specific. * * @param sel Selection object (see getSelection) * @returns Range */ Xinha.prototype.createRange = function(sel) { this.activateEditor(); if ( typeof sel != "undefined" ) { try { return sel.getRangeAt(0); } catch(ex) { return this._doc.createRange(); } } else { return this._doc.createRange(); } }; /** Determine if the given event object is a keydown/press event. * * @param event Event * @returns true|false */ Xinha.prototype.isKeyEvent = function(event) { return event.type == "keypress"; } /** Return the character (as a string) of a keyEvent - ie, press the 'a' key and * this method will return 'a', press SHIFT-a and it will return 'A'. * * @param keyEvent * @returns string */ Xinha.prototype.getKey = function(keyEvent) { return String.fromCharCode(keyEvent.charCode); } /** Return the HTML string of the given Element, including the Element. * * @param element HTML Element DomNode * @returns string */ Xinha.getOuterHTML = function(element) { return (new XMLSerializer()).serializeToString(element); }; //Control character for retaining edit location when switching modes Xinha.cc = String.fromCharCode(8286); Xinha.prototype.setCC = function ( target ) { var cc = Xinha.cc; try { if ( target == "textarea" ) { var ta = this._textArea; var index = ta.selectionStart; var before = ta.value.substring( 0, index ) var after = ta.value.substring( index, ta.value.length ); if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, entities, and inside the body) { var tagEnd = after.indexOf(">") + 1; ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); } else ta.value = before + cc + after; ta.value = ta.value.replace(new RegExp ('(&[^'+cc+']*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); } else { var sel = this.getSelection(); sel.getRangeAt(0).insertNode( this._doc.createTextNode( cc ) ); } } catch (e) {} }; Xinha.prototype.findCC = function ( target ) { if ( target == 'textarea' ) { var ta = this._textArea; var pos = ta.value.indexOf( Xinha.cc ); if ( pos == -1 ) return; var end = pos + Xinha.cc.length; var before = ta.value.substring( 0, pos ); var after = ta.value.substring( end, ta.value.length ); ta.value = before ; ta.scrollTop = ta.scrollHeight; var scrollPos = ta.scrollTop; ta.value += after; ta.setSelectionRange(pos,pos); ta.focus(); ta.scrollTop = scrollPos; } else { try { var doc = this._doc; doc.body.innerHTML = doc.body.innerHTML.replace(new RegExp(Xinha.cc),'<span id="XinhaEditingPostion"></span>'); var posEl = doc.getElementById('XinhaEditingPostion'); this.selectNodeContents(posEl); this.scrollToElement(posEl); posEl.parentNode.removeChild(posEl); this._iframe.contentWindow.focus(); } catch (e) {} } }; /*--------------------------------------------------------------------------*/ /*------------ EXTEND SOME STANDARD "Xinha.prototype" METHODS --------------*/ /*--------------------------------------------------------------------------*/ Xinha.prototype._standardToggleBorders = Xinha.prototype._toggleBorders; Xinha.prototype._toggleBorders = function() { var result = this._standardToggleBorders(); // flashing the display forces moz to listen (JB:18-04-2005) - #102 var tables = this._doc.getElementsByTagName('TABLE'); for(var i = 0; i < tables.length; i++) { tables[i].style.display="none"; tables[i].style.display="table"; } return result; }; /** Return the doctype of a document, if set * * @param doc DOM element document * @returns string the actual doctype */ Xinha.getDoctype = function (doc) { var d = ''; if (doc.doctype) { d += '<!DOCTYPE ' + doc.doctype.name + " PUBLIC "; d += doc.doctype.publicId ? '"' + doc.doctype.publicId + '"' : ''; d += doc.doctype.systemId ? ' "'+ doc.doctype.systemId + '"' : ''; d += ">"; } return d; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Gecko/Gecko.js
JavaScript
art
24,872
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the Opera compatability plugin, part of the Xinha core. -- -- The file is loaded as a special plugin by the Xinha Core when -- Xinha is being run under an Opera based browser with the Midas -- editing API. -- -- It provides implementation and specialisation for various methods -- in the core where different approaches per browser are required. -- -- Design Notes:: -- Most methods here will simply be overriding Xinha.prototype.<method> -- and should be called that, but methods specific to Opera should -- be a part of the Opera.prototype, we won't trample on namespace -- that way. -- -- $HeadURL: http://svn.xinha.org/trunk/modules/Opera/Opera.js $ -- $LastChangedDate: 2008-10-13 06:42:42 +1300 (Mon, 13 Oct 2008) $ -- $LastChangedRevision: 1084 $ -- $LastChangedBy: ray $ --------------------------------------------------------------------------*/ Opera._pluginInfo = { name : "Opera", origin : "Xinha Core", version : "$LastChangedRevision: 1084 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/Opera/Opera.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "Gogo Internet Services Limited", sponsor_url : "http://www.gogo.co.nz/", license : "htmlArea" }; function Opera(editor) { this.editor = editor; editor.Opera = this; } /** Allow Opera to handle some key events in a special way. */ Opera.prototype.onKeyPress = function(ev) { var editor = this.editor; var s = editor.getSelection(); // Handle shortcuts if(editor.isShortCut(ev)) { switch(editor.getKey(ev).toLowerCase()) { case 'z': { if(editor._unLink && editor._unlinkOnUndo) { Xinha._stopEvent(ev); editor._unLink(); editor.updateToolbar(); return true; } } break; case 'a': { // KEY select all sel = editor.getSelection(); sel.removeAllRanges(); range = editor.createRange(); range.selectNodeContents(editor._doc.body); sel.addRange(range); Xinha._stopEvent(ev); return true; } break; case 'v': { // If we are not using htmlareaPaste, don't let Xinha try and be fancy but let the // event be handled normally by the browser (don't stopEvent it) if(!editor.config.htmlareaPaste) { return true; } } break; } } // Handle normal characters switch(editor.getKey(ev)) { // Space, see if the text just typed looks like a URL, or email address // and link it appropriatly case ' ': { var autoWrap = function (textNode, tag) { var rightText = textNode.nextSibling; if ( typeof tag == 'string') { tag = editor._doc.createElement(tag); } var a = textNode.parentNode.insertBefore(tag, rightText); Xinha.removeFromParent(textNode); a.appendChild(textNode); rightText.data = ' ' + rightText.data; s.collapse(rightText, 1); editor._unLink = function() { var t = a.firstChild; a.removeChild(t); a.parentNode.insertBefore(t, a); Xinha.removeFromParent(a); editor._unLink = null; editor._unlinkOnUndo = false; }; editor._unlinkOnUndo = true; return a; }; if ( editor.config.convertUrlsToLinks && s && s.isCollapsed && s.anchorNode.nodeType == 3 && s.anchorNode.data.length > 3 && s.anchorNode.data.indexOf('.') >= 0 ) { var midStart = s.anchorNode.data.substring(0,s.anchorOffset).search(/\S{4,}$/); if ( midStart == -1 ) { break; } if ( editor._getFirstAncestor(s, 'a') ) { break; // already in an anchor } var matchData = s.anchorNode.data.substring(0,s.anchorOffset).replace(/^.*?(\S*)$/, '$1'); var mEmail = matchData.match(Xinha.RE_email); if ( mEmail ) { var leftTextEmail = s.anchorNode; var rightTextEmail = leftTextEmail.splitText(s.anchorOffset); var midTextEmail = leftTextEmail.splitText(midStart); autoWrap(midTextEmail, 'a').href = 'mailto:' + mEmail[0]; break; } RE_date = /([0-9]+\.)+/; //could be date or ip or something else ... RE_ip = /(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/; var mUrl = matchData.match(Xinha.RE_url); if ( mUrl ) { if (RE_date.test(matchData)) { break; //ray: disabling linking of IP numbers because of general bugginess (see Ticket #1085) /*if (!RE_ip.test(matchData)) { break; }*/ } var leftTextUrl = s.anchorNode; var rightTextUrl = leftTextUrl.splitText(s.anchorOffset); var midTextUrl = leftTextUrl.splitText(midStart); autoWrap(midTextUrl, 'a').href = (mUrl[1] ? mUrl[1] : 'http://') + mUrl[2]; break; } } } break; } // Handle special keys switch ( ev.keyCode ) { /* This is now handled by a plugin case 13: // ENTER break;*/ case 27: // ESCAPE { if ( editor._unLink ) { editor._unLink(); Xinha._stopEvent(ev); } break; } break; case 8: // KEY backspace case 46: // KEY delete { // We handle the mozilla backspace directly?? if ( !ev.shiftKey && this.handleBackspace() ) { Xinha._stopEvent(ev); } } default: { editor._unlinkOnUndo = false; // Handle the "auto-linking", specifically this bit of code sets up a handler on // an self-titled anchor (eg <a href="http://www.gogo.co.nz/">www.gogo.co.nz</a>) // when the text content is edited, such that it will update the href on the anchor if ( s.anchorNode && s.anchorNode.nodeType == 3 ) { // See if we might be changing a link var a = editor._getFirstAncestor(s, 'a'); // @todo: we probably need here to inform the setTimeout below that we not changing a link and not start another setTimeout if ( !a ) { break; // not an anchor } if ( !a._updateAnchTimeout ) { if ( s.anchorNode.data.match(Xinha.RE_email) && a.href.match('mailto:' + s.anchorNode.data.trim()) ) { var textNode = s.anchorNode; var fnAnchor = function() { a.href = 'mailto:' + textNode.data.trim(); // @fixme: why the hell do another timeout is started ? // This lead to never ending timer if we dont remove this line // But when removed, the email is not correctly updated // // - to fix this we should make fnAnchor check to see if textNode.data has // stopped changing for say 5 seconds and if so we do not make this setTimeout a._updateAnchTimeout = setTimeout(fnAnchor, 250); }; a._updateAnchTimeout = setTimeout(fnAnchor, 1000); break; } var m = s.anchorNode.data.match(Xinha.RE_url); if ( m && a.href.match(new RegExp( 'http(s)?://' + Xinha.escapeStringForRegExp( s.anchorNode.data.trim() ) ) ) ) { var txtNode = s.anchorNode; var fnUrl = function() { // Sometimes m is undefined becase the url is not an url anymore (was www.url.com and become for example www.url) // ray: shouldn't the link be un-linked then? m = txtNode.data.match(Xinha.RE_url); if(m) { a.href = (m[1] ? m[1] : 'http://') + m[2]; } // @fixme: why the hell do another timeout is started ? // This lead to never ending timer if we dont remove this line // But when removed, the url is not correctly updated // // - to fix this we should make fnUrl check to see if textNode.data has // stopped changing for say 5 seconds and if so we do not make this setTimeout a._updateAnchTimeout = setTimeout(fnUrl, 250); }; a._updateAnchTimeout = setTimeout(fnUrl, 1000); } } } } break; } return false; // Let other plugins etc continue from here. } /** When backspace is hit, the Opera onKeyPress will execute this method. * I don't remember what the exact purpose of this is though :-( */ Opera.prototype.handleBackspace = function() { var editor = this.editor; setTimeout( function() { var sel = editor.getSelection(); var range = editor.createRange(sel); var SC = range.startContainer; var SO = range.startOffset; var EC = range.endContainer; var EO = range.endOffset; var newr = SC.nextSibling; if ( SC.nodeType == 3 ) { SC = SC.parentNode; } if ( ! ( /\S/.test(SC.tagName) ) ) { var p = document.createElement("p"); while ( SC.firstChild ) { p.appendChild(SC.firstChild); } SC.parentNode.insertBefore(p, SC); Xinha.removeFromParent(SC); var r = range.cloneRange(); r.setStartBefore(newr); r.setEndAfter(newr); r.extractContents(); sel.removeAllRanges(); sel.addRange(r); } }, 10); }; Opera.prototype.inwardHtml = function(html) { // Both IE and Opera use strike internally instead of del (#523) // Xinha will present del externally (see Xinha.prototype.outwardHtml html = html.replace(/<(\/?)del(\s|>|\/)/ig, "<$1strike$2"); return html; } Opera.prototype.outwardHtml = function(html) { return html; } Opera.prototype.onExecCommand = function(cmdID, UI, param) { switch(cmdID) { /*case 'paste': { alert(Xinha._lc("The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.")); return true; // Indicate paste is done, stop command being issued to browser by Xinha.prototype.execCommand } break;*/ case 'removeformat': var editor = this.editor; var sel = editor.getSelection(); var selSave = editor.saveSelection(sel); var range = editor.createRange(sel); var els = editor._doc.body.getElementsByTagName('*'); var start = ( range.startContainer.nodeType == 1 ) ? range.startContainer : range.startContainer.parentNode; var i, el; if (sel.isCollapsed) range.selectNodeContents(editor._doc.body); for (i=0; i<els.length;i++) { el = els[i]; if ( range.isPointInRange(el, 0) || (els[i] == start && range.startOffset == 0)) { el.removeAttribute('style'); } } this.editor._doc.execCommand(cmdID, UI, param); editor.restoreSelection(selSave); return true; break; } return false; } Opera.prototype.onMouseDown = function(ev) { } /*--------------------------------------------------------------------------*/ /*------- IMPLEMENTATION OF THE ABSTRACT "Xinha.prototype" METHODS ---------*/ /*--------------------------------------------------------------------------*/ /** Insert a node at the current selection point. * @param toBeInserted DomNode */ Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { if ( toBeInserted.ownerDocument != this._doc ) { try { toBeInserted = this._doc.adoptNode( toBeInserted ); } catch (e) {} } this.focusEditor(); var sel = this.getSelection(); var range = this.createRange(sel); range.deleteContents(); var node = range.startContainer; var pos = range.startOffset; var selnode = toBeInserted; sel.removeAllRanges(); switch ( node.nodeType ) { case 3: // Node.TEXT_NODE // we have to split it at the caret position. if ( toBeInserted.nodeType == 3 ) { // do optimized insertion node.insertData(pos, toBeInserted.data); range = this.createRange(); range.setEnd(node, pos + toBeInserted.length); range.setStart(node, pos + toBeInserted.length); sel.addRange(range); } else { node = node.splitText(pos); if ( toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */ ) { selnode = selnode.firstChild; } node.parentNode.insertBefore(toBeInserted, node); this.selectNodeContents(selnode); this.updateToolbar(); } break; case 1: // Node.ELEMENT_NODE if ( toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */ ) { selnode = selnode.firstChild; } node.insertBefore(toBeInserted, node.childNodes[pos]); this.selectNodeContents(selnode); this.updateToolbar(); break; } }; /** Get the parent element of the supplied or current selection. * @param sel optional selection as returned by getSelection * @returns DomNode */ Xinha.prototype.getParentElement = function(sel) { if ( typeof sel == 'undefined' ) { sel = this.getSelection(); } var range = this.createRange(sel); try { var p = range.commonAncestorContainer; if ( !range.collapsed && range.startContainer == range.endContainer && range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes() ) { p = range.startContainer.childNodes[range.startOffset]; } while ( p.nodeType == 3 ) { p = p.parentNode; } return p; } catch (ex) { return null; } }; /** * Returns the selected element, if any. That is, * the element that you have last selected in the "path" * at the bottom of the editor, or a "control" (eg image) * * @returns null | DomNode */ Xinha.prototype.activeElement = function(sel) { if ( ( sel === null ) || this.selectionEmpty(sel) ) { return null; } // For Mozilla we just see if the selection is not collapsed (something is selected) // and that the anchor (start of selection) is an element. This might not be totally // correct, we possibly should do a simlar check to IE? if ( !sel.isCollapsed ) { if ( sel.anchorNode.childNodes.length > sel.anchorOffset && sel.anchorNode.childNodes[sel.anchorOffset].nodeType == 1 ) { return sel.anchorNode.childNodes[sel.anchorOffset]; } else if ( sel.anchorNode.nodeType == 1 ) { return sel.anchorNode; } else { return null; // return sel.anchorNode.parentNode; } } return null; }; /** * Determines if the given selection is empty (collapsed). * @param selection Selection object as returned by getSelection * @returns true|false */ Xinha.prototype.selectionEmpty = function(sel) { if ( !sel ) { return true; } if ( typeof sel.isCollapsed != 'undefined' ) { return sel.isCollapsed; } return true; }; /** * Returns a range object to be stored * and later restored with Xinha.prototype.restoreSelection() * * @returns Range */ Xinha.prototype.saveSelection = function() { return this.createRange(this.getSelection()).cloneRange(); } /** * Restores a selection previously stored * @param savedSelection Range object as returned by Xinha.prototype.restoreSelection() */ Xinha.prototype.restoreSelection = function(savedSelection) { var sel = this.getSelection(); sel.removeAllRanges(); sel.addRange(savedSelection); } /** * Selects the contents of the given node. If the node is a "control" type element, (image, form input, table) * the node itself is selected for manipulation. * * @param node DomNode * @param collapseToStart A boolean that, when supplied, says to collapse the selection. True collapses to the start, and false to the end. */ Xinha.prototype.selectNodeContents = function(node, collapseToStart) { this.focusEditor(); this.forceRedraw(); var range; var collapsed = typeof collapseToStart == "undefined" ? true : false; var sel = this.getSelection(); range = this._doc.createRange(); // Tables and Images get selected as "objects" rather than the text contents if ( collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|textarea|select/) ) { range.selectNode(node); } else { range.selectNodeContents(node); } sel.removeAllRanges(); sel.addRange(range); if (typeof collapseToStart != "undefined") { if (collapseToStart) { sel.collapse(range.startContainer, range.startOffset); } else { sel.collapse(range.endContainer, range.endOffset); } } }; /** Insert HTML at the current position, deleting the selection if any. * * @param html string */ Xinha.prototype.insertHTML = function(html) { var sel = this.getSelection(); var range = this.createRange(sel); this.focusEditor(); // construct a new document fragment with the given HTML var fragment = this._doc.createDocumentFragment(); var div = this._doc.createElement("div"); div.innerHTML = html; while ( div.firstChild ) { // the following call also removes the node from div fragment.appendChild(div.firstChild); } // this also removes the selection var node = this.insertNodeAtSelection(fragment); }; /** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML. * * @returns string */ Xinha.prototype.getSelectedHTML = function() { var sel = this.getSelection(); if (sel.isCollapsed) return ''; var range = this.createRange(sel); return Xinha.getHTML(range.cloneContents(), false, this); }; /** Get a Selection object of the current selection. Note that selection objects are browser specific. * * @returns Selection */ Xinha.prototype.getSelection = function() { var sel = this._iframe.contentWindow.getSelection(); if(sel && sel.focusNode && sel.focusNode.tagName && sel.focusNode.tagName == 'HTML') { // Bad news batman, this selection is wonky var bod = this._doc.getElementsByTagName('body')[0]; var rng = this.createRange(); rng.selectNodeContents(bod); sel.removeAllRanges(); sel.addRange(rng); sel.collapseToEnd(); } return sel; }; /** Create a Range object from the given selection. Note that range objects are browser specific. * * @param sel Selection object (see getSelection) * @returns Range */ Xinha.prototype.createRange = function(sel) { this.activateEditor(); if ( typeof sel != "undefined" ) { try { return sel.getRangeAt(0); } catch(ex) { return this._doc.createRange(); } } else { return this._doc.createRange(); } }; /** Determine if the given event object is a keydown/press event. * * @param event Event * @returns true|false */ Xinha.prototype.isKeyEvent = function(event) { return event.type == "keypress"; } /** Return the character (as a string) of a keyEvent - ie, press the 'a' key and * this method will return 'a', press SHIFT-a and it will return 'A'. * * @param keyEvent * @returns string */ Xinha.prototype.getKey = function(keyEvent) { return String.fromCharCode(keyEvent.charCode); } /** Return the HTML string of the given Element, including the Element. * * @param element HTML Element DomNode * @returns string */ Xinha.getOuterHTML = function(element) { return (new XMLSerializer()).serializeToString(element); }; /* Caret position remembering when switch between text and html mode. * Largely this is the same as for Gecko except: * * Opera does not have window.find() so we use instead an element with known * id (<span id="XinhaOperaCaretMarker">MARK</span>) so that we can * do _doc.getElementById() on it. * * Opera for some reason will not set the insert point (flashing caret) * anyway though, in theory, the iframe is focused (in findCC below) and then * the selection (containing the span above) is collapsed, it should show * caret. I don't know why not. Seems to require user to actually * click to get the caret to show (or type anything without it acting wierd)? * Very annoying. * */ Xinha.cc = String.fromCharCode(8286); Xinha.prototype.setCC = function ( target ) { // Do a two step caret insertion, first a single char, then we'll replace that with the // id'd span. var cc = Xinha.cc; try { if ( target == "textarea" ) { var ta = this._textArea; var index = ta.selectionStart; var before = ta.value.substring( 0, index ) var after = ta.value.substring( index, ta.value.length ); if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, entities, and inside the body) { var tagEnd = after.indexOf(">") + 1; ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); } else ta.value = before + cc + after; ta.value = ta.value.replace(new RegExp ('(&[^'+cc+']*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); ta.value = ta.value.replace(cc, '<span id="XinhaOperaCaretMarker">MARK</span>'); } else { var sel = this.getSelection(); var mark = this._doc.createElement('span'); mark.id = 'XinhaOperaCaretMarker'; sel.getRangeAt(0).insertNode( mark ); } } catch (e) {} }; Xinha.prototype.findCC = function ( target ) { if ( target == 'textarea' ) { var ta = this._textArea; var pos = ta.value.search( /(<span\s+id="XinhaOperaCaretMarker"\s*\/?>((\s|(MARK))*<\/span>)?)/ ); if ( pos == -1 ) return; var cc = RegExp.$1; var end = pos + cc.length; var before = ta.value.substring( 0, pos ); var after = ta.value.substring( end, ta.value.length ); ta.value = before ; ta.scrollTop = ta.scrollHeight; var scrollPos = ta.scrollTop; ta.value += after; ta.setSelectionRange(pos,pos); ta.focus(); ta.scrollTop = scrollPos; } else { var marker = this._doc.getElementById('XinhaOperaCaretMarker'); if(marker) { this.focusEditor();// this._iframe.contentWindow.focus(); var rng = this.createRange(); rng.selectNode(marker); var sel = this.getSelection(); sel.addRange(rng); sel.collapseToStart(); this.scrollToElement(marker); marker.parentNode.removeChild(marker); return; } } }; /*--------------------------------------------------------------------------*/ /*------------ EXTEND SOME STANDARD "Xinha.prototype" METHODS --------------*/ /*--------------------------------------------------------------------------*/ /* Xinha.prototype._standardToggleBorders = Xinha.prototype._toggleBorders; Xinha.prototype._toggleBorders = function() { var result = this._standardToggleBorders(); // flashing the display forces moz to listen (JB:18-04-2005) - #102 var tables = this._doc.getElementsByTagName('TABLE'); for(var i = 0; i < tables.length; i++) { tables[i].style.display="none"; tables[i].style.display="table"; } return result; }; */ /** Return the doctype of a document, if set * * @param doc DOM element document * @returns string the actual doctype */ Xinha.getDoctype = function (doc) { var d = ''; if (doc.doctype) { d += '<!DOCTYPE ' + doc.doctype.name + " PUBLIC "; d += doc.doctype.publicId ? '"' + doc.doctype.publicId + '"' : ''; d += doc.doctype.systemId ? ' "'+ doc.doctype.systemId + '"' : ''; d += ">"; } return d; }; Xinha.prototype._standardInitIframe = Xinha.prototype.initIframe; Xinha.prototype.initIframe = function() { if(!this._iframeLoadDone) { if(this._iframe.contentWindow && this._iframe.contentWindow.xinhaReadyToRoll) { this._iframeLoadDone = true; this._standardInitIframe(); } else { // Timeout a little (Opera is a bit dodgy about using an event) var editor = this; setTimeout( function() { editor.initIframe() }, 5); } } } // For some reason, Opera doesn't listen to addEventListener for at least select elements with event = change // so we will have to intercept those and use a Dom0 event, these are used eg for the fontname/size/format // dropdowns in the toolbar Xinha._addEventOperaOrig = Xinha._addEvent; Xinha._addEvent = function(el, evname, func) { if(el.tagName && el.tagName.toLowerCase() == 'select' && evname == 'change') { return Xinha.addDom0Event(el,evname,func); } return Xinha._addEventOperaOrig(el,evname,func); }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Opera/Opera.js
JavaScript
art
26,242
// Paste Plain Text plugin for Xinha // Distributed under the same terms as Xinha itself. // This notice MUST stay intact for use (see license.txt). (function(){ Xinha.plugins.AboutBox = AboutBox; function AboutBox(editor) { this.editor = editor; } AboutBox._pluginInfo = { name : "AboutBox", developer : "The Xinha Core Developer Team" }; AboutBox.prototype._lc = function(string) { return Xinha._lc(string, 'AboutBox'); }; AboutBox.prototype._prepareDialog = function() { var self = this; var editor = this.editor; Xinha.loadStyle ('about.css', 'AboutBox', 'aboutCSS'); /// Now we have everything we need, so we can build the dialog. this.dialog = new Xinha.Dialog(editor, AboutBox.html, 'Xinha',{width:600}) this.dialog.getElementById('close').onclick = function() { self.dialog.hide()}; this.dialog.getElementById('xinha_logo').src = _editor_url + 'images/xinha_logo.gif'; var tabs = this.dialog.getElementsByClassName('tab'); this.currentTab = tabs[0]; tabs.forEach(function(tab){ //alert (tab); tab.onclick = function() { if (self.currentTab) { Xinha._removeClass(self.currentTab,'tab-current'); self.dialog.getElementById(self.currentTab.rel).style.display = 'none'; } Xinha._addClass(tab, 'tab-current'); tab.blur(); self.currentTab = tab; self.dialog.getElementById(tab.rel).style.display = 'block'; } }) this.fillPlugins(); this.fillVersion(); this.dialog.onresize = function () { this.getElementById("content").style.height = parseInt(this.height,10) // the actual height of the dialog - this.getElementById('h1').offsetHeight // the title bar - this.getElementById('buttons').offsetHeight // the buttons - 100 // we have a padding at the bottom, gotta take this into acount + 'px'; // don't forget this ;) //this.getElementById("content").style.width =(this.width - 2) + 'px'; // and the width } }; AboutBox.prototype.fillPlugins = function() { var e = this.editor; var tbody = this.dialog.getElementById('plugins_table'); var tr,td,a; var j = 0; for (var i in e.plugins) { var info = e.plugins[i]; tr = document.createElement('tr'); if (j%2) tr.style.backgroundColor = '#e5e5e5'; tbody.appendChild(tr); td = document.createElement('td'); td.innerHTML = info.name; if (info.version) td.innerHTML += ' v'+info.version; tr.appendChild(td); td = document.createElement('td'); if (info.developer) { if (info.developer_url) { td.innerHTML = '<a target="_blank" href="'+info.developer_url+'">'+info.developer+'</a>'; } else { td.innerHTML = info.developer } } tr.appendChild(td); td = document.createElement('td'); if (info.sponsor) { if (info.sponsor_url) { td.innerHTML = '<a target="_blank" href="'+info.sponsor_url+'">'+info.sponsor+'</a>'; } else { td.innerHTML = info.sponsor } } tr.appendChild(td); td = document.createElement('td'); if (info.license) { td.innerHTML = info.license; } else { td.innerHTML = 'htmlArea'; } tr.appendChild(td); j++; } } AboutBox.prototype.fillVersion = function() { var ver = Xinha.version; this.dialog.getElementById('version').innerHTML = '<pre>' + '\nRelease: ' + ver.Release + ' (' + ver.Date + ')' + '\nHead: ' + ver.Head + '\nRevision: ' + ver.Revision + '\nLast Changed By: ' + ver.RevisionBy + '\n' + '</pre>'; } AboutBox.prototype.show = function() { var self = this; if (!AboutBox.html) { if (AboutBox.loading) return; AboutBox.loading = true; Xinha._getback(Xinha.getPluginDir("AboutBox") + '/dialog.html', function(getback) { AboutBox.html = getback; self.show()}); return; } if (!this.dialog) this._prepareDialog(); // here we can pass values to the dialog // each property pair consists of the "name" of the input we want to populate, and the value to be set var inputs = { inputArea : '' // we want the textarea always to be empty on showing } // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog this.dialog.show(inputs); // Init the sizes (only if we have set up the custom resize function) //this.dialog.onresize(); }; })()
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/AboutBox/AboutBox.js
JavaScript
art
4,729
<h1 id="[h1]"> <l10n>About this editor</l10n> </h1> <img alt="Xinha" src="" id="[xinha_logo]" /> <div id="[content]" class="about content" style="padding:10px;"> <div id="[about]" class="tab-content"> <p> A free WYSIWYG editor replacement for <tt> &lt;textarea&gt; </tt> fields. </p> <p> Visit the <a href="http://xinha.gogo.co.nz/">Xinha Website</a> for more information. </p> <p> Use of Xinha is granted by the terms of the htmlArea License (based on BSD license) </p> <pre> Copyright (c) 2005-2009 Xinha Developer Team and contributors</pre> <p> Xinha was originally based on work by Mihai Bazon which is: </p> <pre> Copyright (c) 2003-2004 dynarch.com. Copyright (c) 2002-2003 interactivetools.com, inc. This copyright notice MUST stay intact for use. </pre> </div> <div id="[thanks]" style="display:none" class="tab-content"> The development of Xinha would not have been possible without the original work of Mihai Bazon, InteractiveTools.com, and the many sponsors and contributors from around the world. </div> <div id="[license]" style="display:none" class="tab-content"> <pre>htmlArea License (based on BSD license) Copyright (c) 2005-2009 Xinha Developer Team and contributors Copyright (c) 2002-2004, interactivetools.com, inc. Copyright (c) 2003-2004 dynarch.com All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3) Neither the name of interactivetools.com, inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</pre> </div> <div id="[plugins]" style="display:none" class="tab-content"> <p>The following plugins have been loaded.</p> <table class="plugins"> <thead> <tr> <th>Name</th> <th>Developer</th> <th>Sponsored by</th> <th>License</th> </tr> </thead> <tbody id="[plugins_table]"></tbody> </table> <p>License "htmlArea" means that the plugin is distributed under the same terms as Xinha itself.</p> </div> <div id="[version]" style="display:none" class="tab-content"> </div> </div> <div class="buttons about" id="[buttons]"> <input style="float:right" type="button" id="[close]" value="_(Close)" /> <div style="float:left"> <a rel="about" class="tab tab-current" href="javascript:void(0)">About</a> <a rel="thanks" class="tab" href="javascript:void(0)">Thanks</a> <a rel="license" class="tab" href="javascript:void(0)">License</a> <a rel="plugins" class="tab" href="javascript:void(0)">Plugins</a> <a rel="version" class="tab" href="javascript:void(0)">Version</a> </div> </div>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/AboutBox/dialog.html
HTML
art
4,229
.dialog .about.buttons a.tab { color: #000; cursor: pointer; margin-left: -5px; float: left; position: relative; border: 1px solid #555; top: -3px; left: -2px; padding: 2px 10px 3px 10px; border-top: none; background-color: #CCC; -moz-border-radius: 0px 0px 4px 4px; -webkit-border-radius: 4px; -webkit-border-top-left-radius:0; -webkit-border-top-right-radius:0; z-index: 0; text-decoration:none; } .dialog .about.buttons a.tab-current { top: -4px; background-color: #f5f6f6; padding: 3px 10px 4px 10px; z-index: 10; } .dialog .about.buttons { background-color:white; padding:3px 3px 0 10px; } .dialog .about.content .tab-content { padding-bottom:15px; width:95%; } .dialog .about.content { height:300px; overflow:auto; background-color:#f5f6f6; } .dialog .about.content table.plugins{ width:95%; border: 1px solid black; margin: 1em; } .dialog .about.content table.plugins th{ font-weight: bold; background-color: #CCC; } .dialog .about.content table.plugins td{ padding:3px; }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/AboutBox/about.css
CSS
art
1,046
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the standard implementation of the method for rendering HTML code from the DOM -- -- The file is loaded by the Xinha Core when no alternative method (plugin) is loaded. -- -- -- $HeadURL: http://svn.xinha.org/trunk/modules/GetHtml/DOMwalk.js $ -- $LastChangedDate: 2009-04-14 21:07:43 +1200 (Tue, 14 Apr 2009) $ -- $LastChangedRevision: 1185 $ -- $LastChangedBy: ray $ --------------------------------------------------------------------------*/ function GetHtmlImplementation(editor) { this.editor = editor; } GetHtmlImplementation._pluginInfo = { name : "GetHtmlImplementation DOMwalk", origin : "Xinha Core", version : "$LastChangedRevision: 1185 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/GetHtml/DOMwalk.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; // Retrieves the HTML code from the given node. This is a replacement for // getting innerHTML, using standard DOM calls. // Wrapper legacy see #442 Xinha.getHTML = function(root, outputRoot, editor) { return Xinha.getHTMLWrapper(root,outputRoot,editor); }; Xinha.emptyAttributes = " checked disabled ismap readonly nowrap compact declare selected defer multiple noresize noshade " Xinha.getHTMLWrapper = function(root, outputRoot, editor, indent) { var html = ""; if ( !indent ) { indent = ''; } switch ( root.nodeType ) { case 10:// Node.DOCUMENT_TYPE_NODE case 6: // Node.ENTITY_NODE case 12:// Node.NOTATION_NODE // this all are for the document type, probably not necessary break; case 2: // Node.ATTRIBUTE_NODE // Never get here, this has to be handled in the ELEMENT case because // of IE crapness requring that some attributes are grabbed directly from // the attribute (nodeValue doesn't return correct values), see //http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=3porgu4mc4ofcoa1uqkf7u8kvv064kjjb4%404ax.com // for information break; case 4: // Node.CDATA_SECTION_NODE // Mozilla seems to convert CDATA into a comment when going into wysiwyg mode, // don't know about IE html += (Xinha.is_ie ? ('\n' + indent) : '') + '<![CDATA[' + root.data + ']]>' ; break; case 5: // Node.ENTITY_REFERENCE_NODE html += '&' + root.nodeValue + ';'; break; case 7: // Node.PROCESSING_INSTRUCTION_NODE // PI's don't seem to survive going into the wysiwyg mode, (at least in moz) // so this is purely academic html += (Xinha.is_ie ? ('\n' + indent) : '') + '<'+'?' + root.target + ' ' + root.data + ' ?>'; break; case 1: // Node.ELEMENT_NODE case 11: // Node.DOCUMENT_FRAGMENT_NODE case 9: // Node.DOCUMENT_NODE var closed; var i; var root_tag = (root.nodeType == 1) ? root.tagName.toLowerCase() : ''; if ( ( root_tag == "script" || root_tag == "noscript" ) && editor.config.stripScripts ) { break; } if ( outputRoot ) { outputRoot = !(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(root_tag)); } if ( Xinha.is_ie && root_tag == "head" ) { if ( outputRoot ) { html += (Xinha.is_ie ? ('\n' + indent) : '') + "<head>"; } var save_multiline = RegExp.multiline; RegExp.multiline = true; var txt = root.innerHTML .replace(Xinha.RE_tagName, function(str, p1, p2) { return p1 + p2.toLowerCase(); }) // lowercasize .replace(/\s*=\s*(([^'"][^>\s]*)([>\s])|"([^"]+)"|'([^']+)')/g, '="$2$4$5"$3') //add attribute quotes .replace(/<(link|meta)((\s*\S*="[^"]*")*)>([\n\r]*)/g, '<$1$2 />\n'); //terminate singlet tags RegExp.multiline = save_multiline; html += txt + '\n'; if ( outputRoot ) { html += (Xinha.is_ie ? ('\n' + indent) : '') + "</head>"; } break; } else if ( outputRoot ) { closed = (!(root.hasChildNodes() || Xinha.needsClosingTag(root))); html += ((Xinha.isBlockElement(root)) ? ('\n' + indent) : '') + "<" + root.tagName.toLowerCase(); var attrs = root.attributes; for ( i = 0; i < attrs.length; ++i ) { var a = attrs.item(i); // In certain browsers (*cough* firefox) the dom node loses // information if the image is currently broken. In order to prevent // corrupting the height and width of image tags, we strip height and // width from the image rather than reporting bad information. if (Xinha.is_real_gecko && (root.tagName.toLowerCase() == 'img') && ((a.nodeName.toLowerCase() == 'height') || (a.nodeName.toLowerCase() == 'width'))) { if (!root.complete || root.naturalWidth === 0) { // This means that firefox has been unable to read the dimensions from the actual image continue; } } if (typeof a.nodeValue == 'object' ) continue; // see #684 if (root.tagName.toLowerCase() == "input" && root.type.toLowerCase() == "checkbox" && a.nodeName.toLowerCase() == "value" && a.nodeValue.toLowerCase() == "on") { continue; } if ( !a.specified // IE claims these are !a.specified even though they are. Perhaps others too? && !(root.tagName.toLowerCase().match(/input|option/) && a.nodeName == 'value') && !(root.tagName.toLowerCase().match(/area/) && a.nodeName.match(/shape|coords/i)) ) { continue; } var name = a.nodeName.toLowerCase(); if ( /_moz_editor_bogus_node/.test(name) || ( name == 'class' && a.nodeValue == 'webkit-block-placeholder') ) { html = ""; break; } if ( /(_moz)|(contenteditable)|(_msh)/.test(name) ) { // avoid certain attributes continue; } var value; if ( Xinha.emptyAttributes.indexOf(" "+name+" ") != -1) { value = name; } else if ( name != "style" ) { // IE5.5 reports 25 when cellSpacing is // 1; other values might be doomed too. // For this reason we extract the // values directly from the root node. // I'm starting to HATE JavaScript // development. Browser differences // suck. // // Using Gecko the values of href and src are converted to absolute links // unless we get them using nodeValue() if ( typeof root[a.nodeName] != "undefined" && name != "href" && name != "src" && !(/^on/.test(name)) ) { value = root[a.nodeName]; } else { value = a.nodeValue; if (name == 'class') { value = value.replace(/Apple-style-span/,''); if (!value) continue; } // IE seems not willing to return the original values - it converts to absolute // links using a.nodeValue, a.value, a.stringValue, root.getAttribute("href") // So we have to strip the baseurl manually :-/ if ( Xinha.is_ie && (name == "href" || name == "src") ) { value = editor.stripBaseURL(value); } // High-ascii (8bit) characters in links seem to cause problems for some sites, // while this seems to be consistent with RFC 3986 Section 2.4 // because these are not "reserved" characters, it does seem to // cause links to international resources not to work. See ticket:167 // IE always returns high-ascii characters un-encoded in links even if they // were supplied as % codes (it unescapes them when we pul the value from the link). // Hmmm, very strange if we use encodeURI here, or encodeURIComponent in place // of escape below, then the encoding is wrong. I mean, completely. // Nothing like it should be at all. Using escape seems to work though. // It's in both browsers too, so either I'm doing something wrong, or // something else is going on? if ( editor.config.only7BitPrintablesInURLs && ( name == "href" || name == "src" ) ) { value = value.replace(/([^!-~]+)/g, function(match) { return escape(match); }); } } } else if ( !Xinha.is_ie ) { value = root.style.cssText.replace(/rgb\(.*?\)/ig,function(rgb){ return Xinha._colorToRgb(rgb) }); } else if (!value) // IE8 has style in attributes (see below), but it's empty! { continue; } if ( /^(_moz)?$/.test(value) ) { // Mozilla reports some special tags // here; we don't need them. continue; } html += " " + name + '="' + Xinha.htmlEncode(value) + '"'; } //IE fails to put style in attributes list & cssText is UPPERCASE if ( Xinha.is_ie && root.style.cssText ) { html += ' style="' + root.style.cssText.replace(/(^)?([^:]*):(.*?)(;|$)/g, function(m0, m1,m2,m3, m4){return m2.toLowerCase() + ':' + m3 + m4;}) + '"'; } if ( Xinha.is_ie && root.tagName.toLowerCase() == "option" && root.selected ) { html += ' selected="selected"'; } if ( html !== "" ) { if ( closed && root_tag=="p" ) { //never use <p /> as empty paragraphs won't be visible html += ">&nbsp;</p>"; } else if ( closed ) { html += " />"; } else { html += ">"; } } } var containsBlock = false; if ( root_tag == "script" || root_tag == "noscript" ) { if ( !editor.config.stripScripts ) { if (Xinha.is_ie) { var innerText = "\n" + root.innerHTML.replace(/^[\n\r]*/,'').replace(/\s+$/,'') + '\n' + indent; } else { var innerText = (root.hasChildNodes()) ? root.firstChild.nodeValue : ''; } html += innerText + '</'+root_tag+'>' + ((Xinha.is_ie) ? '\n' : ''); } } else if (root_tag == "pre") { html += ((Xinha.is_ie) ? '\n' : '') + root.innerHTML.replace(/<br>/g,'\n') + '</'+root_tag+'>'; } else { for ( i = root.firstChild; i; i = i.nextSibling ) { if ( !containsBlock && i.nodeType == 1 && Xinha.isBlockElement(i) ) { containsBlock = true; } html += Xinha.getHTMLWrapper(i, true, editor, indent + ' '); } if ( outputRoot && !closed ) { html += (((Xinha.isBlockElement(root) && containsBlock) || root_tag == 'head' || root_tag == 'html') ? ('\n' + indent) : '') + "</" + root.tagName.toLowerCase() + ">"; } } break; case 3: // Node.TEXT_NODE if ( /^script|noscript|style$/i.test(root.parentNode.tagName) ) { html = root.data; } else if(root.data.trim() == '') { if(root.data) { html = ' '; } else { html = ''; } } else { html = Xinha.htmlEncode(root.data); } break; case 8: // Node.COMMENT_NODE html = "<!--" + root.data + "-->"; break; } return html; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/GetHtml/DOMwalk.js
JavaScript
art
12,569
/** * Based on XML_Utility functions submitted by troels_kn. * credit also to adios, who helped with reg exps: * http://www.sitepoint.com/forums/showthread.php?t=201052 * * A replacement for Xinha.getHTML * * Features: * - Generates XHTML code * - Much faster than Xinha.getHTML * - Eliminates the hacks to accomodate browser quirks * - Returns correct code for Flash objects and scripts * - Formats html in an indented, readable format in html mode * - Preserves script and pre formatting * - Preserves formatting in comments * - Removes contenteditable from body tag in full-page mode * - Supports only7BitPrintablesInURLs config option * - Supports htmlRemoveTags config option */ function GetHtmlImplementation(editor) { this.editor = editor; } GetHtmlImplementation._pluginInfo = { name : "GetHtmlImplementation TransformInnerHTML", version : "1.0", developer : "Nelson Bright", developer_url : "http://www.brightworkweb.com/", sponsor : "", sponsor_url : "", license : "htmlArea" }; Xinha.RegExpCache = [ /*00*/ /<\s*\/?([^\s\/>]+)[\s*\/>]/gi,//lowercase tags /*01*/ /(\s+)_moz[^=>]*=[^\s>]*/gi,//strip _moz attributes /*02*/ /\s*=\s*(([^'"][^>\s]*)([>\s])|"([^"]+)"|'([^']+)')/g,// find attributes /*03*/ /\/>/g,//strip singlet terminators /*04*/ /<(br|hr|img|input|link|meta|param|embed|area)((\s*\S*="[^"]*")*)>/g,//terminate singlet tags /*05*/ /(<\w+\s+(\w*="[^"]*"\s+)*)(checked|compact|declare|defer|disabled|ismap|multiple|no(href|resize|shade|wrap)|readonly|selected)([\s>])/gi,//expand singlet attributes /*06*/ /(="[^']*)'([^'"]*")/,//check quote nesting /*07*/ /&(?=(?!(#[0-9]{2,5};|[a-zA-Z0-9]{2,6};|#x[0-9a-fA-F]{2,4};))[^<]*>)/g,//expand query ampersands not in html entities /*08*/ /<\s+/g,//strip tagstart whitespace /*09*/ /\s+(\/)?>/g,//trim whitespace /*10*/ /\s{2,}/g,//trim extra whitespace /*11*/ /\s+([^=\s]+)((="[^"]+")|([\s>]))/g,// lowercase attribute names /*12*/ /\s+contenteditable(=[^>\s\/]*)?/gi,//strip contenteditable /*13*/ /((href|src)=")([^\s]*)"/g, //find href and src for stripBaseHref() /*14*/ /<\/?(div|p|h[1-6]|table|tr|td|th|ul|ol|li|dl|dt|dd|blockquote|object|br|hr|img|embed|param|pre|script|html|head|body|meta|link|title|area|input|form|textarea|select|option)[^>]*>/g, /*15*/ /<\/(div|p|h[1-6]|table|tr|ul|ol|dl|blockquote|html|head|body|script|form|select)( [^>]*)?>/g,//blocklevel closing tag /*16*/ /<(div|p|h[1-6]|table|tr|ul|ol|dl|blockquote|object|html|head|body|script|form|select)( [^>]*)?>/g,//blocklevel opening tag /*17*/ /<(td|th|li|dt|dd|option|br|hr|embed|param|pre|meta|link|title|area|input|textarea)[^>]*>/g,//singlet tag or output on 1 line /*18*/ /(^|<\/(pre|script)>)(\s|[^\s])*?(<(pre|script)[^>]*>|$)/g,//find content NOT inside pre and script tags /*19*/ /(<pre[^>]*>)([\s\S])*?(<\/pre>)/g,//find content inside pre tags /*20*/ /(^|<!--[\s\S]*?-->)([\s\S]*?)(?=<!--[\s\S]*?-->|$)/g,//find content NOT inside comments /*21*/ /\S*=""/g, //find empty attributes /*22*/ /<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<\/?\w[^>]*>/g, //find all tags, including comments and php /*23*/ /(^|<\/script>)[\s\S]*?(<script[^>]*>|$)/g //find content NOT inside script tags ]; // compile for performance; WebKit doesn't support this var testRE = new RegExp().compile(Xinha.RegExpCache[3]); if (typeof testRE != 'undefined') { for (var i=0; i<Xinha.RegExpCache.length;i++ ) { Xinha.RegExpCache[i] = new RegExp().compile(Xinha.RegExpCache[i]); } } /** * Cleans HTML into wellformed xhtml */ Xinha.prototype.cleanHTML = function(sHtml) { var c = Xinha.RegExpCache; sHtml = sHtml. replace(c[0], function(str) { return str.toLowerCase(); } ).//lowercase tags/attribute names replace(c[1], ' ').//strip _moz attributes replace(c[12], ' ').//strip contenteditable replace(c[2], '="$2$4$5"$3').//add attribute quotes replace(c[21], ' ').//strip empty attributes replace(c[11], function(str, p1, p2) { return ' '+p1.toLowerCase()+p2; }).//lowercase attribute names replace(c[3], '>').//strip singlet terminators replace(c[9], '$1>').//trim whitespace replace(c[5], '$1$3="$3"$5').//expand singlet attributes replace(c[4], '<$1$2 />').//terminate singlet tags replace(c[6], '$1$2').//check quote nesting replace(c[7], '&amp;').//expand query ampersands replace(c[8], '<').//strip tagstart whitespace replace(c[10], ' ');//trim extra whitespace if(Xinha.is_ie && c[13].test(sHtml)) { sHtml = sHtml.replace(c[13],'$1'+Xinha._escapeDollars(this.stripBaseURL(RegExp.$3))+'"'); } if(this.config.only7BitPrintablesInURLs) { if (Xinha.is_ie) c[13].test(sHtml); // oddly the test below only triggers when we call this once before (IE6), in Moz it fails if tested twice if ( c[13].test(sHtml)) { try { //Mozilla returns an incorrectly encoded value with innerHTML sHtml = sHtml.replace(c[13], '$1'+Xinha._escapeDollars(decodeURIComponent(RegExp.$3).replace(/([^!-~]+)/g, function(chr) {return escape(chr);}))+'"'); } catch (e) { // once the URL is escape()ed, you can't decodeURIComponent() it anymore sHtml = sHtml.replace(c[13], Xinha._escapeDollars('$1'+RegExp.$3.replace(/([^!-~]+)/g,function(chr){return escape(chr);})+'"')); } } } return sHtml; }; /** * Prettyfies html by inserting linebreaks before tags, and indenting blocklevel tags */ Xinha.indent = function(s, sindentChar) { Xinha.__nindent = 0; Xinha.__sindent = ""; Xinha.__sindentChar = (typeof sindentChar == "undefined") ? " " : sindentChar; var c = Xinha.RegExpCache; if(Xinha.is_gecko) { //moz changes returns into <br> inside <pre> tags s = s.replace(c[19], function(str){return str.replace(/<br \/>/g,"\n")}); } s = s.replace(c[18], function(strn) { //skip pre and script tags strn = strn.replace(c[20], function(st,$1,$2) { //exclude comments string = $2.replace(/[\n\r]/gi, " ").replace(/\s+/gi," ").replace(c[14], function(str) { if (str.match(c[16])) { var s = "\n" + Xinha.__sindent + str; // blocklevel openingtag - increase indent Xinha.__sindent += Xinha.__sindentChar; ++Xinha.__nindent; return s; } else if (str.match(c[15])) { // blocklevel closingtag - decrease indent --Xinha.__nindent; Xinha.__sindent = ""; for (var i=Xinha.__nindent;i>0;--i) { Xinha.__sindent += Xinha.__sindentChar; } return "\n" + Xinha.__sindent + str; } else if (str.match(c[17])) { // singlet tag return "\n" + Xinha.__sindent + str; } return str; // this won't actually happen }); return $1 + string; });return strn; }); //final cleanup s = s.replace(/^\s*/,'').//strip leading whitespace replace(/ +\n/g,'\n').//strip spaces at end of lines replace(/[\r\n]+(\s+)<\/script>/g,'\n$1</script>');//strip returns added into scripts return s; }; Xinha.getHTML = function(root, outputRoot, editor) { var html = ""; var c = Xinha.RegExpCache; if(root.nodeType == 11) {//document fragment //we can't get innerHTML from the root (type 11) node, so we //copy all the child nodes into a new div and get innerHTML from the div var div = document.createElement("div"); var temp = root.insertBefore(div,root.firstChild); for (j = temp.nextSibling; j; j = j.nextSibling) { temp.appendChild(j.cloneNode(true)); } html += temp.innerHTML.replace(c[23], function(strn) { //skip content inside script tags strn = strn.replace(c[22], function(tag){ if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags else return editor.cleanHTML(tag)}); return strn; }); } else { var root_tag = (root.nodeType == 1) ? root.tagName.toLowerCase() : ''; if (outputRoot) { //only happens with <html> tag in fullpage mode html += "<" + root_tag; var attrs = root.attributes; // strangely, this doesn't work in moz for (i = 0; i < attrs.length; ++i) { var a = attrs.item(i); if (!a.specified) { continue; } var name = a.nodeName.toLowerCase(); var value = a.nodeValue; html += " " + name + '="' + value + '"'; } html += ">"; } if(root_tag == "html") { innerhtml = editor._doc.documentElement.innerHTML; } else { innerhtml = root.innerHTML; } //pass tags to cleanHTML() one at a time //includes support for htmlRemoveTags config option html += innerhtml.replace(c[23], function(strn) { //skip content inside script tags strn = strn.replace(c[22], function(tag){ if(/^<[!\?]/.test(tag)) return tag; //skip comments and php tags else if(!(editor.config.htmlRemoveTags && editor.config.htmlRemoveTags.test(tag.replace(/<([^\s>\/]+)/,'$1')))) return editor.cleanHTML(tag); else return ''}); return strn; }); //IE drops all </li>,</dt>,</dd> tags in a list except the last one if(Xinha.is_ie) { html = html.replace(/<(li|dd|dt)( [^>]*)?>/g,'</$1><$1$2>'). replace(/(<[uod]l[^>]*>[\s\S]*?)<\/(li|dd|dt)>/g, '$1'). replace(/\s*<\/(li|dd|dt)>(\s*<\/(li|dd|dt)>)+/g, '</$1>'). replace(/(<dt[\s>][\s\S]*?)(<\/d[dt]>)+/g, '$1</dt>'); } if(Xinha.is_gecko) html = html.replace(/<br \/>\n$/, ''); //strip trailing <br> added by moz //Cleanup redundant whitespace before </li></dd></dt> in IE and Mozilla html = html.replace(/\s*(<\/(li|dd|dt)>)/g, '$1'); if (outputRoot) { html += "</" + root_tag + ">"; } html = Xinha.indent(html); }; // html = Xinha.htmlEncode(html); return html; }; /** * Escapes dollar signs ($) to make them safe to use in regex replacement functions by replacing each $ in the input with $$. * * This is advisable any time the replacement string for a call to replace() is a variable and could contain dollar signs that should not be interpreted as references to captured groups (e.g., when you want the text "$10" and not the first captured group followed by a 0). * See http://trac.xinha.org/ticket/1337 */ Xinha._escapeDollars = function(str) { return str.replace(/\$/g, "$$$$"); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/GetHtml/TransformInnerHTML.js
JavaScript
art
10,180
// I18N constants // // LANG: "pt_br", ENCODING: UTF-8 // Portuguese Brazilian Translation // // Author: Marcio Barbosa, <marcio@mpg.com.br> // MSN: tomarshall@msn.com - ICQ: 69419933 // Site: http://www.mpg.com.br // // Last revision: 06 september 2007 // Please don´t remove this information // If you modify any source, please insert a comment with your name and e-mail // // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt). { "Your Document is not well formed. Check JavaScript console for details.": "Seu documento não está formatado corretamente. Verifique os detalhes no console do Javascript." }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/GetHtml/lang/pt_br.js
JavaScript
art
675
Xinha.InlineStyler = function(element, editor, dialog, doc) { this.element = element; this.editor = editor; this.dialog = dialog; this.doc = doc ? doc : document; this.inputs = { styles : {}, aux : {} } this.styles = {}; this.auxData = {}; //units and such } Xinha.InlineStyler.getLength = function(value) { var len = parseInt(value); if (isNaN(len)) { len = ""; } return len; }; // Applies the style found in "params" to the given element. Xinha.InlineStyler.prototype.applyStyle = function(params) { var element = this.element; var style = element.style; for (var i in params) { if (typeof params[i] == 'function') continue; if (params[i] != null) var val = params[i].value || params[i]; switch (i) { case "backgroundImage": if (/\S/.test(val)) { style.backgroundImage = "url(" + val + ")"; } else { style.backgroundImage = "none"; } break; case "borderCollapse": style.borderCollapse = params[i] == "on" ? "collapse" : "separate"; break; case "width": if (/\S/.test(val)) { style.width = val + this.inputs.aux["widthUnit"].value; } else { style.width = ""; } break; case "height": if (/\S/.test(val)) { style.height = val + this.inputs.aux["heightUnit"].value; } else { style.height = ""; } break; case "textAlign": if (val == "char") { var ch = this.inputs.aux["textAlignChar"].value; if (ch == '"') { ch = '\\"'; } style.textAlign = '"' + ch + '"'; } else if (val == "-") { style.textAlign = ""; } else { style.textAlign = val; } break; case "verticalAlign": element.vAlign = ""; if (val == "-") { style.verticalAlign = ""; } else { style.verticalAlign = val; } break; case "float": if (Xinha.is_ie) { style.styleFloat = val; } else { style.cssFloat = val; } break; case "borderWidth": style[i] = val ? val + "px" : '0px'; break; default: style[i] = val; break; // case "f_st_margin": // style.margin = val + "px"; // break; // case "f_st_padding": // style.padding = val + "px"; // break; } } }; Xinha.InlineStyler.prototype.createStyleLayoutFieldset = function() { var self = this; var editor = this.editor; var doc = this.doc; var el = this.element; var fieldset = doc.createElement("fieldset"); var legend = doc.createElement("legend"); fieldset.appendChild(legend); legend.innerHTML = Xinha._lc("Layout", "TableOperations"); var table = doc.createElement("table"); fieldset.appendChild(table); table.style.width = "100%"; var tbody = doc.createElement("tbody"); table.appendChild(tbody); var tagname = el.tagName.toLowerCase(); var tr, td, input, select, option, options, i; if (tagname != "td" && tagname != "tr" && tagname != "th") { tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); td.className = "label"; tr.appendChild(td); td.innerHTML = Xinha._lc("Float", "TableOperations") + ":"; td = doc.createElement("td"); tr.appendChild(td); select = doc.createElement("select"); select.name = this.dialog.createId("float"); td.appendChild(select); this.inputs.styles['float'] = select; options = ["None", "Left", "Right"]; for (var i = 0; i < options.length; ++i) { var Val = options[i]; var val = options[i].toLowerCase(); option = doc.createElement("option"); option.innerHTML = Xinha._lc(Val, "TableOperations"); option.value = val; if (Xinha.is_ie) { option.selected = (("" + el.style.styleFloat).toLowerCase() == val); } else { option.selected = (("" + el.style.cssFloat).toLowerCase() == val); } select.appendChild(option); } } tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); td.className = "label"; tr.appendChild(td); td.innerHTML = Xinha._lc("Width", "TableOperations") + ":"; td = doc.createElement("td"); tr.appendChild(td); input = doc.createElement("input"); input.name = this.dialog.createId("width"); input.type = "text"; input.value = Xinha.InlineStyler.getLength(el.style.width); input.size = "5"; this.inputs.styles['width'] = input; input.style.marginRight = "0.5em"; td.appendChild(input); select = doc.createElement("select"); select.name = this.dialog.createId("widthUnit"); this.inputs.aux['widthUnit'] = select; option = doc.createElement("option"); option.innerHTML = Xinha._lc("percent", "TableOperations"); option.value = "%"; option.selected = /%/.test(el.style.width); select.appendChild(option); option = doc.createElement("option"); option.innerHTML = Xinha._lc("pixels", "TableOperations"); option.value = "px"; option.selected = /px/.test(el.style.width); select.appendChild(option); td.appendChild(select); select.style.marginRight = "0.5em"; td.appendChild(doc.createTextNode(Xinha._lc("Text align", "TableOperations") + ":")); select = doc.createElement("select"); select.name = this.dialog.createId("textAlign"); select.style.marginLeft = select.style.marginRight = "0.5em"; td.appendChild(select); this.inputs.styles['textAlign'] = select; options = ["Left", "Center", "Right", "Justify", "-"]; if (tagname == "td") { options.push("Char"); } input = doc.createElement("input"); this.inputs.aux['textAlignChar'] = input; input.name= this.dialog.createId("textAlignChar"); input.size = "1"; input.style.fontFamily = "monospace"; td.appendChild(input); for (var i = 0; i < options.length; ++i) { var Val = options[i]; var val = Val.toLowerCase(); option = doc.createElement("option"); option.value = val; option.innerHTML = Xinha._lc(Val, "TableOperations"); option.selected = ((el.style.textAlign.toLowerCase() == val) || (el.style.textAlign == "" && Val == "-")); select.appendChild(option); } var textAlignCharInput = input; function setCharVisibility(value) { textAlignCharInput.style.visibility = value ? "visible" : "hidden"; if (value) { textAlignCharInput.focus(); textAlignCharInput.select(); } } select.onchange = function() { setCharVisibility(this.value == "char"); }; setCharVisibility(select.value == "char"); tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); td.className = "label"; tr.appendChild(td); td.innerHTML = Xinha._lc("Height", "TableOperations") + ":"; td = doc.createElement("td"); tr.appendChild(td); input = doc.createElement("input"); input.name = this.dialog.createId("height"); input.type = "text"; input.value = Xinha.InlineStyler.getLength(el.style.height); input.size = "5"; this.inputs.styles['height'] = input; input.style.marginRight = "0.5em"; td.appendChild(input); select = doc.createElement("select"); select.name = this.dialog.createId("heightUnit"); this.inputs.aux['heightUnit'] = select; option = doc.createElement("option"); option.innerHTML = Xinha._lc("percent", "TableOperations"); option.value = "%"; option.selected = /%/.test(el.style.height); select.appendChild(option); option = doc.createElement("option"); option.innerHTML = Xinha._lc("pixels", "TableOperations"); option.value = "px"; option.selected = /px/.test(el.style.height); select.appendChild(option); td.appendChild(select); select.style.marginRight = "0.5em"; td.appendChild(doc.createTextNode(Xinha._lc("Vertical align", "TableOperations") + ":")); select = doc.createElement("select"); select.name = this.dialog.createId("verticalAlign"); this.inputs.styles['verticalAlign'] = select; select.style.marginLeft = "0.5em"; td.appendChild(select); options = ["Top", "Middle", "Bottom", "Baseline", "-"]; for (var i = 0; i < options.length; ++i) { var Val = options[i]; var val = Val.toLowerCase(); option = doc.createElement("option"); option.value = val; option.innerHTML = Xinha._lc(Val, "TableOperations"); option.selected = ((el.style.verticalAlign.toLowerCase() == val) || (el.style.verticalAlign == "" && Val == "-")); select.appendChild(option); } return fieldset; }; // Returns an HTML element containing the style attributes for the given // element. This can be easily embedded into any dialog; the functionality is // also provided. Xinha.InlineStyler.prototype.createStyleFieldset = function() { var editor = this.editor; var doc = this.doc; var el = this.element; var fieldset = doc.createElement("fieldset"); var legend = doc.createElement("legend"); fieldset.appendChild(legend); legend.innerHTML = Xinha._lc("CSS Style", "TableOperations"); var table = doc.createElement("table"); fieldset.appendChild(table); table.style.width = "100%"; var tbody = doc.createElement("tbody"); table.appendChild(tbody); var tr, td, input, select, option, options, i; tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); tr.appendChild(td); td.className = "label"; td.innerHTML = Xinha._lc("Background", "TableOperations") + ":"; td = doc.createElement("td"); tr.appendChild(td); input = doc.createElement("input"); input.name = this.dialog.createId("backgroundColor"); input.value = Xinha._colorToRgb( el.style.backgroundColor ); input.type = "hidden"; this.inputs.styles['backgroundColor'] = input; input.style.marginRight = "0.5em"; td.appendChild(input); new Xinha.colorPicker.InputBinding(input) td.appendChild(doc.createTextNode(" " + Xinha._lc("Image URL", "TableOperations") + ": ")); input = doc.createElement("input"); input.name = this.dialog.createId("backgroundImage"); input.type = "text"; this.inputs.styles['backgroundImage'] = input; if (el.style.backgroundImage.match(/url\(\s*(.*?)\s*\)/)) input.value = RegExp.$1; // input.style.width = "100%"; td.appendChild(input); tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); tr.appendChild(td); td.className = "label"; td.innerHTML = Xinha._lc("FG Color", "TableOperations") + ":"; td = doc.createElement("td"); tr.appendChild(td); input = doc.createElement("input"); input.name = this.dialog.createId("color"); input.value = Xinha._colorToRgb( el.style.color ); input.type = "hidden"; this.inputs.styles['color'] = input; input.style.marginRight = "0.5em"; td.appendChild(input); new Xinha.colorPicker.InputBinding(input) // for better alignment we include an invisible field. input = doc.createElement("input"); input.style.visibility = "hidden"; input.type = "text"; td.appendChild(input); tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); tr.appendChild(td); td.className = "label"; td.innerHTML = Xinha._lc("Border", "TableOperations") + ":"; td = doc.createElement("td"); tr.appendChild(td); input = doc.createElement("input"); input.name = this.dialog.createId("borderColor"); input.value = Xinha._colorToRgb( el.style.borderColor ); input.type = "hidden"; this.inputs.styles['borderColor'] = input; input.style.marginRight = "0.5em"; td.appendChild(input); new Xinha.colorPicker.InputBinding(input) select = doc.createElement("select"); select.name = this.dialog.createId("borderStyle"); var borderFields = []; td.appendChild(select); this.inputs.styles['borderStyle'] = select; options = ["none", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]; var currentBorderStyle = el.style.borderStyle; // Gecko reports "solid solid solid solid" for "border-style: solid". // That is, "top right bottom left" -- we only consider the first // value. if (currentBorderStyle.match(/([^\s]*)\s/)) currentBorderStyle = RegExp.$1; for (var i=0;i<options.length;i++) { var val = options[i]; option = doc.createElement("option"); option.value = val; option.innerHTML = val; if (val == currentBorderStyle) option.selected = true; select.appendChild(option); } select.style.marginRight = "0.5em"; function setBorderFieldsStatus(value) { for (var i = 0; i < borderFields.length; ++i) { var el = borderFields[i]; el.style.visibility = value ? "hidden" : "visible"; if (!value && (el.tagName.toLowerCase() == "input")) { el.focus(); el.select(); } } } select.onchange = function() { setBorderFieldsStatus(this.value == "none"); }; input = doc.createElement("input"); input.name = this.dialog.createId("borderWidth"); borderFields.push(input); input.type = "text"; this.inputs.styles['borderWidth'] = input; input.value = Xinha.InlineStyler.getLength(el.style.borderWidth); input.size = "5"; td.appendChild(input); input.style.marginRight = "0.5em"; var span = doc.createElement("span"); span.innerHTML = Xinha._lc("pixels", "TableOperations"); td.appendChild(span); borderFields.push(span); setBorderFieldsStatus(select.value == "none"); if (el.tagName.toLowerCase() == "table") { // the border-collapse style is only for tables tr = doc.createElement("tr"); tbody.appendChild(tr); td = doc.createElement("td"); td.className = "label"; tr.appendChild(td); input = doc.createElement("input"); input.name = this.dialog.createId("borderCollapse"); input.type = "checkbox"; input.value = "on"; this.inputs.styles['borderCollapse'] = input; input.id = "f_st_borderCollapse"; var val = (/collapse/i.test(el.style.borderCollapse)); input.checked = val ? 1 : 0; td.appendChild(input); td = doc.createElement("td"); tr.appendChild(td); var label = doc.createElement("label"); label.htmlFor = "f_st_borderCollapse"; label.innerHTML = Xinha._lc("Collapsed borders", "TableOperations"); td.appendChild(label); } // tr = doc.createElement("tr"); // tbody.appendChild(tr); // td = doc.createElement("td"); // td.className = "label"; // tr.appendChild(td); // td.innerHTML = Xinha._lc("Margin", "TableOperations") + ":"; // td = doc.createElement("td"); // tr.appendChild(td); // input = doc.createElement("input"); // input.type = "text"; // input.size = "5"; // input.name = "f_st_margin"; // td.appendChild(input); // input.style.marginRight = "0.5em"; // td.appendChild(doc.createTextNode(Xinha._lc("Padding", "TableOperations") + ":")); // input = doc.createElement("input"); // input.type = "text"; // input.size = "5"; // input.name = "f_st_padding"; // td.appendChild(input); // input.style.marginLeft = "0.5em"; // input.style.marginRight = "0.5em"; // td.appendChild(doc.createTextNode(Xinha._lc("pixels", "TableOperations"))); return fieldset; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InlineStyler/InlineStyler.js
JavaScript
art
15,365
<h1 id="[h1]"><l10n>Insert Table</l10n></h1> <form action="" method="get" style="margin-top:10px"> <div id="[columns_alert]" style="color:red;display:none"><l10n>You must enter a number of columns</l10n></div> <div id="[rows_alert]" style="color:red;display:none"><l10n>You must enter a number of rows</l10n></div> <table border="0" style="padding: 0px; margin: 0px"> <tbody> <tr> <td> <l10n>Caption</l10n>: </td> <td colspan="4"> <input type="text" name="[caption]" id="[caption]" style="width:90%" title="_(Caption for the table)" /> </td> </tr> <tr> <td style="width: 4em; text-align: right"><l10n>Rows:</l10n></td> <td><input type="text" name="[rows]" id="[rows]" size="5" title="_(Number of rows)" /></td> <td style="width: 4em; text-align: right">Width:</td> <td><input type="text" name="[width]" id="[width]" size="5" title="_(Width of the table)" /></td> <td><select size="1" name="[unit]" id="[unit]" title="Width unit"> <option value="%" ><l10n>Percent</l10n></option> <option value="px" ><l10n>Pixels</l10n></option> <option value="em" >Em</option> </select></td> </tr> <tr> <td style="width: 4em; text-align: right">Cols:</td> <td><input type="text" name="[cols]" id="[cols]" size="5" title="_(Number of columns)" /></td> <td style="text-align: right"><input type="checkbox" name="[fixed]" id="[fixed]" value="on" /></td> <td colspan="2"><label ><l10n>Fixed width columns</l10n></label></td> </tr> </tbody> </table> <br /> <fieldset id="[layout_fieldset]" style="float: left; margin-left: 10px;"> <legend><l10n>Layou</l10n>t</legend> <div class="space"></div> <div class="fl"><l10n>Alignment:</l10n></div> <select size="1" name="[align]" id="[align]" title="Positioning of this table"> <option value="" ><l10n>Not set</l10n></option> <option value="left" ><l10n>Left</l10n></option> <option value="right" ><l10n>Right</l10n></option> <option value="texttop" ><l10n>Texttop</l10n></option> <option value="absmiddle" ><l10n>Absmiddle</l10n></option> <option value="baseline" ><l10n>Baseline</l10n></option> <option value="absbottom" ><l10n>Absbottom</l10n></option> <option value="bottom" ><l10n>Bottom</l10n></option> <option value="middle" ><l10n>Middle</option> <option value="top" ><l10n>Top</l10n></option> </select> <br /> <div class="fl"><l10n>Border</l10n></div> <input type="text" name="[border]" id="[border]" size="2" title="_(Leave empty for no border)" /> <l10n>Pixels</l10n> <select size="1" name="[border_style]" id="[border_style]" title="_(Style of the border)"> <option value="solid" >Solid</option> <option value="dotted" >Dotted</option> <option value="dashed" >Dashed</option> <option value="double" >Double</option> <option value="groove" >Groove</option> <option value="ridge" >Ridge</option> <option value="inset" >Inset</option> <option value="outset" >outset</option> </select> <input type="text" size="7" id="[border_color]" name="[border_color]"/> <br /><l10n>Collapse borders:</l10n> <input type="checkbox" name="[border_collapse]" id="[border_collapse]" value="on" /> <div class="space"></div> </fieldset> <fieldset id="[spacing_fieldset]"> <legend><l10n>Spacing</l10n></legend> <div class="space"></div> <div class="fr"><l10n>Cell spacing:</l10n></div> <input type="text" name="[spacing]" id="[spacing]" size="5" title="_(Space between adjacent cells)" /> <br /> <div class="fr"><l10n>Cell padding:</l10n></div> <input type="text" name="[padding]" id="[padding]" size="5" title="_(Space between content and border in cell)" /> </fieldset> <div class="buttons" style="clear:left"> <input type="button" id="[ok]" value="_(OK)" /> <input type="button" id="[cancel]" value="_(Cancel)" /> </div> </form>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertTable/dialog.html
HTML
art
4,184
InsertTable.prototype.show = function(image) { if (!this.dialog) this.prepareDialog(); var editor = this.editor; var values = { "caption" : '', "rows" : '2', "cols" : '4', "width" : '100', "unit" : '%', "fixed" : '', "align" : '', "border" : '1', "border_style" : 'dotted', "border_color" : '#000000', "border_collapse" : 'on', "spacing" : '', "padding" : '5' } // update the color of the picker manually this.borderColorPicker.setColor('#000000'); // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog this.dialog.show(values); this.dialog.onresize(); }; InsertTable.prototype.apply = function() { var editor = this.editor; var doc = editor._doc; var param = this.dialog.getValues(); if (!param.rows || !param.cols) { if (!param.rows) { this.dialog.getElementById("rows_alert").style.display = ''; } if (!param.cols) { this.dialog.getElementById("columns_alert").style.display = ''; } return; } // selection is only restored on dialog.hide() this.dialog.hide(); // create the table element var table = doc.createElement("table"); // assign the given arguments for ( var field in param ) { var value = param[field]; if ( !value ) { continue; } switch (field) { case "width": table.style.width = value + param.unit.value; break; case "align": table.align = value.value; break; case "border": table.style.border = value + 'px ' + param.border_style.value + ' ' + param.border_color; break; case "border_collapse": table.style.borderCollapse = (value == 'on') ? 'collapse' : '' ; break; case "spacing": table.cellSpacing = parseInt(value, 10); break; case "padding": table.cellPadding = parseInt(value, 10); break; } } if (param.caption) { var caption = table.createCaption(); caption.appendChild(doc.createTextNode(param.caption)); } var cellwidth = 0; if ( param.fixed ) { cellwidth = Math.floor(100 / parseInt(param.cols, 10)); } var tbody = doc.createElement("tbody"); table.appendChild(tbody); for ( var i = 0; i < param.rows; ++i ) { var tr = doc.createElement("tr"); tbody.appendChild(tr); for ( var j = 0; j < param.cols; ++j ) { var td = doc.createElement("td"); // @todo : check if this line doesnt stop us to use pixel width in cells if (cellwidth && i===0) { td.style.width = cellwidth + "%"; } if (param.border) { td.style.border = param.border + 'px ' + param.border_style.value + ' ' + param.border_color; } tr.appendChild(td); // Browsers like to see something inside the cell (&nbsp;). td.appendChild(doc.createTextNode('\u00a0')); } } // insert the table editor.insertNodeAtSelection(table); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertTable/pluginMethods.js
JavaScript
art
3,108
<html> <head> <title>Insert Table</title> <script type="text/javascript" src="../../popups/popup.js"></script> <link rel="stylesheet" type="text/css" href="../../popups/popup.css" /> <script type="text/javascript"> window.resizeTo(425, 250); Xinha = window.opener.Xinha; function i18n(str) { return (Xinha._lc(str, 'Xinha')); } function Init() { Xinha = window.opener.Xinha; // load the Xinha plugin and lang file __dlg_translate('Xinha'); __dlg_init(null, Xinha.is_ie ? null : {width:425,height:250}); // Make sure the translated string appears in the drop down. (for gecko) document.getElementById("f_unit").selectedIndex = 1; document.getElementById("f_unit").selectedIndex = 0; document.getElementById("f_align").selectedIndex = 1; document.getElementById("f_align").selectedIndex = 0; document.getElementById("f_rows").focus(); } function onOK() { var required = { "f_rows": i18n("You must enter a number of rows"), "f_cols": i18n("You must enter a number of columns") }; for (var i in required) { var el = document.getElementById(i); if (!el.value) { alert(required[i]); el.focus(); return false; } } var fields = ["f_rows", "f_cols", "f_width", "f_unit", "f_fixed", "f_align", "f_border", "f_spacing", "f_padding"]; var param = new Object(); for (var i in fields) { var id = fields[i]; var el = document.getElementById(id); param[id] = (el.type == "checkbox") ? el.checked : el.value; } __dlg_close(param); return false; } function onCancel() { __dlg_close(null); return false; } </script> </head> <body class="dialog" onload="Init()"> <div class="title">Insert Table</div> <form action="" method="get"> <table border="0" style="padding: 0px; margin: 0px"> <tbody> <tr> <td style="width: 4em; text-align: right">Rows:</td> <td><input type="text" name="rows" id="f_rows" size="5" title="Number of rows" value="2" /></td> <td style="width: 4em; text-align: right">Width:</td> <td><input type="text" name="width" id="f_width" size="5" title="Width of the table" value="100" /></td> <td><select size="1" name="unit" id="f_unit" title="Width unit"> <option value="%" selected="selected" >Percent</option> <option value="px" >Pixels</option> <option value="em" >Em</option> </select></td> </tr> <tr> <td style="width: 4em; text-align: right">Cols:</td> <td><input type="text" name="cols" id="f_cols" size="5" title="Number of columns" value="4" /></td> <td style="text-align: right"><input type="checkbox" checked="checked" name="fixed" id="f_fixed" value="on" /></td> <td colspan="2"><label for="f_fixed" >Fixed width columns</label></td> </tr> </tbody> </table> <p /> <fieldset style="float: left; margin-left: 5px;"> <legend>Layout</legend> <div class="space"></div> <div class="fl">Alignment:</div> <select size="1" name="align" id="f_align" title="Positioning of this table"> <option value="" selected="selected" >Not set</option> <option value="left" >Left</option> <option value="right" >Right</option> <option value="texttop" >Texttop</option> <option value="absmiddle" >Absmiddle</option> <option value="baseline" >Baseline</option> <option value="absbottom" >Absbottom</option> <option value="bottom" >Bottom</option> <option value="middle" >Middle</option> <option value="top" >Top</option> </select> <p /> <div class="fl">Border thickness:</div> <input type="text" name="border" id="f_border" size="5" value="1" title="Leave empty for no border" /> <!-- <p /> <div class="fl">Collapse borders:</div> <input type="checkbox" name="collapse" id="f_collapse" /> --> <div class="space"></div> </fieldset> <fieldset style="float:right; margin-right: 5px;"> <legend>Spacing</legend> <div class="space"></div> <div class="fr">Cell spacing:</div> <input type="text" name="spacing" id="f_spacing" size="5" value="1" title="Space between adjacent cells" /> <p /> <div class="fr">Cell padding:</div> <input type="text" name="padding" id="f_padding" size="5" value="1" title="Space between content and border in cell" /> <div class="space"></div> </fieldset> <div style="margin-top: 85px; border-top: 1px solid #999; padding: 2px; text-align: right;"> <button type="button" name="ok" onclick="return onOK();">OK</button> <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> </div> </form> </body> </html>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertTable/insert_table.html
HTML
art
4,703
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-2008 Xinha Developer Team and contributors -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the Xinha standard implementation of a table insertion plugin -- -- The file is loaded by the Xinha Core when no alternative method (plugin) is loaded. -- -- -- $HeadURL: http://svn.xinha.org/trunk/modules/InsertTable/insert_table.js $ -- $LastChangedDate: 2008-10-13 06:52:26 +1300 (Mon, 13 Oct 2008) $ -- $LastChangedRevision: 1085 $ -- $LastChangedBy: ray $ --------------------------------------------------------------------------*/ InsertTable._pluginInfo = { name : "InsertTable", origin : "Xinha Core", version : "$LastChangedRevision: 1085 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/InsertTable/insert_table.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; function InsertTable(editor) { this.editor = editor; var cfg = editor.config; var self = this; editor.config.btnList.inserttable[3] = function() { self.show(); } } InsertTable.prototype._lc = function(string) { return Xinha._lc(string, 'Xinha'); }; InsertTable.prototype.onGenerateOnce = function() { InsertTable.loadAssets(); }; InsertTable.loadAssets = function() { var self = InsertTable; if (self.loading) return; self.loading = true; Xinha._getback(_editor_url + 'modules/InsertTable/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); Xinha._getback(_editor_url + 'modules/InsertTable/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); }; InsertTable.prototype.onUpdateToolbar = function() { if (!(InsertTable.dialogReady && InsertTable.methodsReady)) { this.editor._toolbarObjects.inserttable.state("enabled", false); } else this.onUpdateToolbar = null; }; InsertTable.prototype.prepareDialog = function() { var self = this; var editor = this.editor; var dialog = this.dialog = new Xinha.Dialog(editor, InsertTable.html, 'Xinha',{width:400}) // Connect the OK and Cancel buttons dialog.getElementById('ok').onclick = function() {self.apply();} dialog.getElementById('cancel').onclick = function() { self.dialog.hide()}; this.borderColorPicker = new Xinha.colorPicker.InputBinding(dialog.getElementById('border_color')); this.dialog.onresize = function () { this.getElementById("layout_fieldset").style.width =(this.width / 2) + 50 + 'px'; this.getElementById("spacing_fieldset").style.width =(this.width / 2) - 120 + 'px'; } this.dialogReady = true; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertTable/insert_table.js
JavaScript
art
3,244
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-2008 Xinha Developer Team and contributors -- -- This is the Xinha standard implementation of an image insertion plugin -- -- he file is loaded as a special plugin by the Xinha Core when no alternative method (plugin) is loaded. -- -- -- $HeadURL: http://svn.xinha.org/trunk/modules/InsertImage/insert_image.js $ -- $LastChangedDate: 2010-02-18 15:14:45 +1300 (Thu, 18 Feb 2010) $ -- $LastChangedRevision: 1239 $ -- $LastChangedBy: gogo $ --------------------------------------------------------------------------*/ InsertImage._pluginInfo = { name : "InsertImage", origin : "Xinha Core", version : "$LastChangedRevision: 1239 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/InsertImage/insert_image.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; function InsertImage(editor) { this.editor = editor; var cfg = editor.config; var self = this; if(typeof editor._insertImage == 'undefined') { editor._insertImage = function() { self.show(); }; // editor.config.btnList.insertimage[3] = function() { self.show(); } } } InsertImage.prototype._lc = function(string) { return Xinha._lc(string, 'Xinha'); }; InsertImage.prototype.onGenerateOnce = function() { InsertImage.loadAssets(); }; InsertImage.loadAssets = function() { var self = InsertImage; if (self.loading) return; self.loading = true; Xinha._getback(_editor_url + 'modules/InsertImage/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); Xinha._getback(_editor_url + 'modules/InsertImage/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); }; InsertImage.prototype.onUpdateToolbar = function() { if (!(InsertImage.dialogReady && InsertImage.methodsReady)) { this.editor._toolbarObjects.insertimage.state("enabled", false); } else this.onUpdateToolbar = null; }; InsertImage.prototype.prepareDialog = function() { var self = this; var editor = this.editor; var dialog = this.dialog = new Xinha.Dialog(editor, InsertImage.html, 'Xinha',{width:410}) // Connect the OK and Cancel buttons dialog.getElementById('ok').onclick = function() {self.apply();} dialog.getElementById('cancel').onclick = function() { self.dialog.hide()}; dialog.getElementById('preview').onclick = function() { var f_url = dialog.getElementById("f_url"); var url = f_url.value; if (!url) { alert(dialog._lc("You must enter the URL")); f_url.focus(); return false; } dialog.getElementById('ipreview').src = url; return false; } this.dialog.onresize = function () { var newHeightForPreview = parseInt(this.height,10) - this.getElementById('h1').offsetHeight - this.getElementById('buttons').offsetHeight - this.getElementById('inputs').offsetHeight - parseInt(this.rootElem.style.paddingBottom,10); // we have a padding at the bottom, gotta take this into acount this.getElementById("ipreview").style.height = ((newHeightForPreview > 0) ? newHeightForPreview : 0) + "px"; // no-go beyond 0 this.getElementById("ipreview").style.width = this.width - 2 + 'px'; // and the width } this.dialogReady = true; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertImage/insert_image.js
JavaScript
art
3,729
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Insert Image</title> <script type="text/javascript" src="../../popups/popup.js"></script> <link rel="stylesheet" type="text/css" href="../../popups/popup.css" /> <script type="text/javascript"> Xinha = window.opener.Xinha; function i18n(str) { return (Xinha._lc(str, 'Xinha')); } function Init() { __dlg_translate('Xinha'); __dlg_init(null,{width:410,height:400}); // Make sure the translated string appears in the drop down. (for gecko) document.getElementById("f_align").selectedIndex = 1; document.getElementById("f_align").selectedIndex = 5; var param = window.dialogArguments; if (param["f_base"]) { document.getElementById("f_base").value = param["f_base"]; } document.getElementById("f_url").value = param["f_url"] ? param["f_url"] : ""; document.getElementById("f_alt").value = param["f_alt"] ? param["f_alt"] : ""; document.getElementById("f_border").value = (typeof param["f_border"]!="undefined") ? param["f_border"] : ""; document.getElementById("f_align").value = param["f_align"] ? param["f_align"] : ""; document.getElementById("f_vert").value = (typeof param["f_vert"]!="undefined") ? param["f_vert"] : ""; document.getElementById("f_horiz").value = (typeof param["f_horiz"]!="undefined") ? param["f_horiz"] : ""; if (param["f_url"]) { window.ipreview.location.replace(Xinha._resolveRelativeUrl(param.f_base, param.f_url)); } document.getElementById("f_url").focus(); } function onOK() { var required = { "f_url": i18n("You must enter the URL") }; for (var i in required) { var el = document.getElementById(i); if (!el.value) { alert(required[i]); el.focus(); return false; } } // pass data back to the calling window var fields = ["f_url", "f_alt", "f_align", "f_border", "f_horiz", "f_vert"]; var param = new Object(); for (var i in fields) { var id = fields[i]; var el = document.getElementById(id); param[id] = el.value; } __dlg_close(param); return false; } function onCancel() { __dlg_close(null); return false; } function onPreview() { var f_url = document.getElementById("f_url"); var url = f_url.value; var base = document.getElementById("f_base").value; if (!url) { alert(i18n("You must enter the URL")); f_url.focus(); return false; } window.ipreview.location.replace(Xinha._resolveRelativeUrl(base, url)); return false; } </script> </head> <body class="dialog" onload="Init()"> <div class="title">Insert Image</div> <!--- new stuff ---> <form action="" method="get"> <input type="hidden" name="base" id="f_base"/> <table border="0" width="100%" style="padding: 0px; margin: 0px"> <tbody> <tr> <td style="width: 7em; text-align: right">Image URL:</td> <td><input type="text" name="url" id="f_url" style="width:75%" title="Enter the image URL here" /> <button name="preview" onclick="return onPreview();" title="Preview the image in a new window">Preview</button> </td> </tr> <tr> <td style="width: 7em; text-align: right">Alternate text:</td> <td><input type="text" name="alt" id="f_alt" style="width:100%" title="For browsers that don't support images" /></td> </tr> </tbody> </table> <fieldset style="float: left; margin-left: 5px;"> <legend>Layout</legend> <div class="space"></div> <div class="fl">Alignment:</div> <select size="1" name="align" id="f_align" title="Positioning of this image"> <option value="" >Not set</option> <option value="left" >Left</option> <option value="right" >Right</option> <option value="texttop" >Texttop</option> <option value="absmiddle" >Absmiddle</option> <option value="baseline" selected="selected" >Baseline</option> <option value="absbottom" >Absbottom</option> <option value="bottom" >Bottom</option> <option value="middle" >Middle</option> <option value="top" >Top</option> </select> <br /> <div class="fl">Border thickness:</div> <input type="text" name="border" id="f_border" size="5" title="Leave empty for no border" /> <div class="space"></div> </fieldset> <fieldset> <legend>Spacing</legend> <div class="space"></div> <div class="fr">Horizontal:</div> <input type="text" name="horiz" id="f_horiz" size="5" title="Horizontal padding" /> <br /> <div class="fr">Vertical:</div> <input type="text" name="vert" id="f_vert" size="5" title="Vertical padding" /> <div class="space"></div> </fieldset> <div class="space" style="clear:all"></div> <div> Image Preview:<br /> <iframe name="ipreview" id="ipreview" frameborder="0" style="border : 1px solid gray;" height="200" width="100%" src="../../popups/blank.html"></iframe> </div> <div id="buttons"> <button type="submit" name="ok" onclick="return onOK();">OK</button> <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> </div> </form> </body> </html>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertImage/insert_image.html
HTML
art
5,295
<h1 id="[h1]"><l10n>Insert Image</l10n></h1> <!--- new stuff ---> <form action="" method="get" style="padding-top:10px" id="[inputs]"> <table border="0" width="95%" style="padding: 0px; margin: 0px"> <tbody> <tr> <td style="width: 7em; text-align: right"><l10n>Image URL:</l10n></td> <td><input type="text" name="[f_url]" id="[f_url]" style="width:75%" title="_(Enter the image URL here)" /> <button id="[preview]" title="_(Preview the image in a new window)"><l10n>Preview</l10n></button> </td> </tr> <tr> <td style="width: 7em; text-align: right"><l10n>Alternate text:</l10n></td> <td><input type="text" name="[f_alt]" id="[f_alt]" style="width:100%" title="_(For browsers that don't support images)" /></td> </tr> </tbody> </table> <br /> <fieldset style="float: left; margin-left: 5px;"> <legend><l10n>Layout</l10n></legend> <div class="space"></div> <div class="fl"><l10n>Alignment:</l10n></div> <select size="1" name="[f_align]" id="[f_align]" title="_(Positioning of this image)"> <option value="" ><l10n>Not set</l10n></option> <option value="left" ><l10n>Left</l10n></option> <option value="right" ><l10n>Right</l10n></option> <option value="texttop" ><l10n>Texttop</l10n></option> <option value="absmiddle" ><l10n>Absmiddle</l10n></option> <option value="baseline" ><l10n>Baseline</l10n></option> <option value="absbottom" ><l10n>Absbottom</l10n></option> <option value="bottom" ><l10n>Bottom</l10n></option> <option value="middle" ><l10n>Middle</l10n></option> <option value="top" ><l10n>Top</l10n></option> </select> <br /> <div class="fl"><l10n>Border thickness:</l10n></div> <input type="text" name="[f_border]" id="[f_border]" size="5" title="_(Leave empty for no border)" /> <div class="space"></div> </fieldset> <fieldset> <legend><l10n>Spacing</l10n></legend> <div class="space"></div> <div class="fr"><l10n>Horizontal:</l10n></div> <input type="text" name="[f_horiz]" id="[f_horiz]" size="5" title="_(Horizontal padding)" /> <br /> <div class="fr"><l10n>Vertical:</l10n></div> <input type="text" name="[f_vert]" id="[f_vert]" size="5" title="_(Vertical padding)" /> <div class="space"></div> </fieldset> </form> <div> <l10n>Image Preview:</l10n><br /> <iframe id="[ipreview]" frameborder="0" style="border : 1px solid gray;" height="200" width="100%" src="about:blank"></iframe> </div> <div class="buttons" id="[buttons]"> <input type="button" id="[ok]" value="_(OK)" /> <input type="button" id="[cancel]" value="_(Cancel)" /> </div>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertImage/dialog.html
HTML
art
2,783
InsertImage.prototype.show = function(image) { if (!this.dialog) this.prepareDialog(); var editor = this.editor; if ( typeof image == "undefined" ) { image = editor.getParentElement(); if ( image && image.tagName.toLowerCase() != 'img' ) { image = null; } } if ( image ) { function getSpecifiedAttribute(element,attribute) { var a = element.attributes; for (var i=0;i<a.length;i++) { if (a[i].nodeName == attribute && a[i].specified) { return a[i].value; } } return ''; } outparam = { f_url : editor.stripBaseURL(image.getAttribute('src',2)), // the second parameter makes IE return the value as it is set, as opposed to an "interpolated" (as MSDN calls it) value f_alt : image.alt, f_border : image.border, f_align : image.align, f_vert : getSpecifiedAttribute(image,'vspace'), f_horiz : getSpecifiedAttribute(image,'hspace'), f_width : image.width, f_height : image.height }; } else{ { outparam = { f_url : '', f_alt : '', f_border : '', f_align : '', f_vert : '', f_horiz : '', f_width : '', f_height : '' }; } } this.image = image; // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog this.dialog.show(outparam); }; // and finally ... take some action InsertImage.prototype.apply = function() { var param = this.dialog.hide(); if (!param.f_url) { return; } var editor = this.editor; var img = this.image; if ( !img ) { if ( Xinha.is_ie ) { var sel = editor.getSelection(); var range = editor.createRange(sel); editor._doc.execCommand("insertimage", false, param.f_url); img = range.parentElement(); // wonder if this works... if ( img.tagName.toLowerCase() != "img" ) { img = img.previousSibling; } } else { img = document.createElement('img'); img.src = param.f_url; editor.insertNodeAtSelection(img); if ( !img.tagName ) { // if the cursor is at the beginning of the document img = range.startContainer.firstChild; } } } else { img.src = param.f_url; } for ( var field in param ) { var value = param[field]; switch (field) { case "f_alt": if (value) img.alt = value; else img.removeAttribute("alt"); break; case "f_border": if (value) img.border = parseInt(value || "0"); else img.removeAttribute("border"); break; case "f_align": if (value.value) img.align = value.value; else img.removeAttribute("align"); break; case "f_vert": if (value != "") img.vspace = parseInt(value || "0"); else img.removeAttribute("vspace"); break; case "f_horiz": if (value != "") img.hspace = parseInt(value || "0"); else img.removeAttribute("hspace"); break; case "f_width": if (value) img.width = parseInt(value || "0"); else img.removeAttribute("width"); break; case "f_height": if (value) img.height = parseInt(value || "0"); else img.removeAttribute("height"); break; } } };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InsertImage/pluginMethods.js
JavaScript
art
3,429
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the Internet Explorer compatability plugin, part of the -- Xinha core. -- -- The file is loaded as a special plugin by the Xinha Core when -- Xinha is being run under an Internet Explorer based browser. -- -- It provides implementation and specialisation for various methods -- in the core where different approaches per browser are required. -- -- Design Notes:: -- Most methods here will simply be overriding Xinha.prototype.<method> -- and should be called that, but methods specific to IE should -- be a part of the InternetExplorer.prototype, we won't trample on -- namespace that way. -- -- $HeadURL: http://svn.xinha.org/trunk/modules/InternetExplorer/InternetExplorer.js $ -- $LastChangedDate: 2010-05-12 00:31:04 +1200 (Wed, 12 May 2010) $ -- $LastChangedRevision: 1260 $ -- $LastChangedBy: gogo $ --------------------------------------------------------------------------*/ InternetExplorer._pluginInfo = { name : "Internet Explorer", origin : "Xinha Core", version : "$LastChangedRevision: 1260 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/InternetExplorer/InternetExplorer.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; function InternetExplorer(editor) { this.editor = editor; editor.InternetExplorer = this; // So we can do my_editor.InternetExplorer.doSomethingIESpecific(); } /** Allow Internet Explorer to handle some key events in a special way. */ InternetExplorer.prototype.onKeyPress = function(ev) { // Shortcuts if(this.editor.isShortCut(ev)) { switch(this.editor.getKey(ev).toLowerCase()) { case 'n': { this.editor.execCommand('formatblock', false, '<p>'); Xinha._stopEvent(ev); return true; } break; case '1': case '2': case '3': case '4': case '5': case '6': { this.editor.execCommand('formatblock', false, '<h'+this.editor.getKey(ev).toLowerCase()+'>'); Xinha._stopEvent(ev); return true; } break; } } switch(ev.keyCode) { case 8: // KEY backspace case 46: // KEY delete { if(this.handleBackspace()) { Xinha._stopEvent(ev); return true; } } break; case 9: // KEY tab, see ticket #1121 { Xinha._stopEvent(ev); return true; } } return false; } /** When backspace is hit, the IE onKeyPress will execute this method. * It preserves links when you backspace over them and apparently * deletes control elements (tables, images, form fields) in a better * way. * * @returns true|false True when backspace has been handled specially * false otherwise (should pass through). */ InternetExplorer.prototype.handleBackspace = function() { var editor = this.editor; var sel = editor.getSelection(); if ( sel.type == 'Control' ) { var elm = editor.activeElement(sel); Xinha.removeFromParent(elm); return true; } // This bit of code preseves links when you backspace over the // endpoint of the link in IE. Without it, if you have something like // link_here | // where | is the cursor, and backspace over the last e, then the link // will de-link, which is a bit tedious var range = editor.createRange(sel); var r2 = range.duplicate(); r2.moveStart("character", -1); var a = r2.parentElement(); // @fixme: why using again a regex to test a single string ??? if ( a != range.parentElement() && ( /^a$/i.test(a.tagName) ) ) { r2.collapse(true); r2.moveEnd("character", 1); r2.pasteHTML(''); r2.select(); return true; } }; InternetExplorer.prototype.inwardHtml = function(html) { // Both IE and Gecko use strike internally instead of del (#523) // Xinha will present del externally (see Xinha.prototype.outwardHtml html = html.replace(/<(\/?)del(\s|>|\/)/ig, "<$1strike$2"); // ie eats scripts and comments at beginning of page, so // make sure there is something before the first script on the page html = html.replace(/(<script|<!--)/i,"&nbsp;$1"); // We've got a workaround for certain issues with saving and restoring // selections that may cause us to fill in junk span tags. We'll clean // those here html = html.replace(/<span[^>]+id="__InsertSpan_Workaround_[a-z]+".*?>([\s\S]*?)<\/span>/i,"$1"); return html; } InternetExplorer.prototype.outwardHtml = function(html) { // remove space added before first script on the page html = html.replace(/&nbsp;(\s*)(<script|<!--)/i,"$1$2"); // We've got a workaround for certain issues with saving and restoring // selections that may cause us to fill in junk span tags. We'll clean // those here html = html.replace(/<span[^>]+id="__InsertSpan_Workaround_[a-z]+".*?>([\s\S]*?)<\/span>/i,"$1"); return html; } InternetExplorer.prototype.onExecCommand = function(cmdID, UI, param) { switch(cmdID) { // #645 IE only saves the initial content of the iframe, so we create a temporary iframe with the current editor contents case 'saveas': var doc = null; var editor = this.editor; var iframe = document.createElement("iframe"); iframe.src = "about:blank"; iframe.style.display = 'none'; document.body.appendChild(iframe); try { if ( iframe.contentDocument ) { doc = iframe.contentDocument; } else { doc = iframe.contentWindow.document; } } catch(ex) { //hope there's no exception } doc.open("text/html","replace"); var html = ''; if ( editor.config.browserQuirksMode === false ) { var doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; } else if ( editor.config.browserQuirksMode === true ) { var doctype = ''; } else { var doctype = Xinha.getDoctype(document); } if ( !editor.config.fullPage ) { html += doctype + "\n"; html += "<html>\n"; html += "<head>\n"; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + editor.config.charSet + "\">\n"; if ( typeof editor.config.baseHref != 'undefined' && editor.config.baseHref !== null ) { html += "<base href=\"" + editor.config.baseHref + "\"/>\n"; } if ( typeof editor.config.pageStyleSheets !== 'undefined' ) { for ( var i = 0; i < editor.config.pageStyleSheets.length; i++ ) { if ( editor.config.pageStyleSheets[i].length > 0 ) { html += "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + editor.config.pageStyleSheets[i] + "\">"; //html += "<style> @import url('" + editor.config.pageStyleSheets[i] + "'); </style>\n"; } } } if ( editor.config.pageStyle ) { html += "<style type=\"text/css\">\n" + editor.config.pageStyle + "\n</style>"; } html += "</head>\n"; html += "<body>\n"; html += editor.getEditorContent(); html += "</body>\n"; html += "</html>"; } else { html = editor.getEditorContent(); if ( html.match(Xinha.RE_doctype) ) { editor.setDoctype(RegExp.$1); } } doc.write(html); doc.close(); doc.execCommand(cmdID, UI, param); document.body.removeChild(iframe); return true; break; case 'removeformat': var editor = this.editor; var sel = editor.getSelection(); var selSave = editor.saveSelection(sel); var i, el, els; function clean (el) { if (el.nodeType != 1) return; el.removeAttribute('style'); for (var j=0; j<el.childNodes.length;j++) { clean(el.childNodes[j]); } if ( (el.tagName.toLowerCase() == 'span' && !el.attributes.length ) || el.tagName.toLowerCase() == 'font') { el.outerHTML = el.innerHTML; } } if ( editor.selectionEmpty(sel) ) { els = editor._doc.body.childNodes; for (i = 0; i < els.length; i++) { el = els[i]; if (el.nodeType != 1) continue; if (el.tagName.toLowerCase() == 'span') { newNode = editor.convertNode(el, 'div'); el.parentNode.replaceChild(newNode, el); el = newNode; } clean(el); } } editor._doc.execCommand(cmdID, UI, param); editor.restoreSelection(selSave); return true; break; } return false; }; /*--------------------------------------------------------------------------*/ /*------- IMPLEMENTATION OF THE ABSTRACT "Xinha.prototype" METHODS ---------*/ /*--------------------------------------------------------------------------*/ /** Insert a node at the current selection point. * @param toBeInserted DomNode */ Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { this.insertHTML(toBeInserted.outerHTML); }; /** Get the parent element of the supplied or current selection. * @param sel optional selection as returned by getSelection * @returns DomNode */ Xinha.prototype.getParentElement = function(sel) { if ( typeof sel == 'undefined' ) { sel = this.getSelection(); } var range = this.createRange(sel); switch ( sel.type ) { case "Text": // try to circumvent a bug in IE: // the parent returned is not always the real parent element var parent = range.parentElement(); while ( true ) { var TestRange = range.duplicate(); TestRange.moveToElementText(parent); if ( TestRange.inRange(range) ) { break; } if ( ( parent.nodeType != 1 ) || ( parent.tagName.toLowerCase() == 'body' ) ) { break; } parent = parent.parentElement; } return parent; case "None": // It seems that even for selection of type "None", // there _is_ a parent element and it's value is not // only correct, but very important to us. MSIE is // certainly the buggiest browser in the world and I // wonder, God, how can Earth stand it? try { return range.parentElement(); } catch(e) { return this._doc.body; // ?? } case "Control": return range.item(0); default: return this._doc.body; } }; /** * Returns the selected element, if any. That is, * the element that you have last selected in the "path" * at the bottom of the editor, or a "control" (eg image) * * @returns null | DomNode */ Xinha.prototype.activeElement = function(sel) { if ( ( sel === null ) || this.selectionEmpty(sel) ) { return null; } if ( sel.type.toLowerCase() == "control" ) { return sel.createRange().item(0); } else { // If it's not a control, then we need to see if // the selection is the _entire_ text of a parent node // (this happens when a node is clicked in the tree) var range = sel.createRange(); var p_elm = this.getParentElement(sel); if ( p_elm.innerHTML == range.htmlText ) { return p_elm; } /* if ( p_elm ) { var p_rng = this._doc.body.createTextRange(); p_rng.moveToElementText(p_elm); if ( p_rng.isEqual(range) ) { return p_elm; } } if ( range.parentElement() ) { var prnt_range = this._doc.body.createTextRange(); prnt_range.moveToElementText(range.parentElement()); if ( prnt_range.isEqual(range) ) { return range.parentElement(); } } */ return null; } }; /** * Determines if the given selection is empty (collapsed). * @param selection Selection object as returned by getSelection * @returns true|false */ Xinha.prototype.selectionEmpty = function(sel) { if ( !sel ) { return true; } return this.createRange(sel).htmlText === ''; }; /** * Returns a range object to be stored * and later restored with Xinha.prototype.restoreSelection() * * @returns Range */ Xinha.prototype.saveSelection = function(sel) { return this.createRange(sel ? sel : this.getSelection()) } /** * Restores a selection previously stored * @param savedSelection Range object as returned by Xinha.prototype.restoreSelection() */ Xinha.prototype.restoreSelection = function(savedSelection) { if (!savedSelection) return; // Ticket #1387 // avoid problem where savedSelection does not implement parentElement(). // This condition occurs if there was no text selection at the time saveSelection() was called. In the case // an image selection, the situation is confusing... the image may be selected in two different ways: 1) by // simply clicking the image it will appear to be selected by a box with sizing handles; or 2) by clicking and // dragging over the image as you might click and drag over text. In the first case, the resulting selection // object does not implement parentElement(), leading to a crash later on in the code below. The following // hack avoids that problem. // Ticket #1488 // fix control selection in IE8 var savedParentElement = null; if (savedSelection.parentElement) { savedParentElement = savedSelection.parentElement(); } else { savedParentElement = savedSelection.item(0); } // In order to prevent triggering the IE bug mentioned below, we will try to // optimize by not restoring the selection if it happens to match the current // selection. var range = this.createRange(this.getSelection()); var rangeParentElement = null; if (range.parentElement) { rangeParentElement = range.parentElement(); } else { rangeParentElement = range.item(0); } // We can't compare two selections that come from different documents, so we // must make sure they're from the same document. var findDoc = function(el) { for (var root=el; root; root=root.parentNode) { if (root.tagName.toLowerCase() == 'html') { return root.parentNode; } } return null; } if (savedSelection.parentElement && findDoc(savedParentElement) == findDoc(rangeParentElement)) { if (range.isEqual(savedSelection)) { // The selection hasn't moved, no need to restore. return; } } try { savedSelection.select() } catch (e) {}; range = this.createRange(this.getSelection()); if (range.parentElement) { rangeParentElement = range.parentElement(); } else { rangeParentElement = range.item(0); } if (rangeParentElement != savedParentElement) { // IE has a problem with selections at the end of text nodes that // immediately precede block nodes. Example markup: // <div>Text Node<p>Text in Block</p></div> // ^ // The problem occurs when the cursor is after the 'e' in Node. var solution = this.config.selectWorkaround || 'VisibleCue'; switch (solution) { case 'SimulateClick': // Try to get the bounding box of the selection and then simulate a // mouse click in the upper right corner to return the cursor to the // correct location. // No code yet, fall through to InsertSpan case 'InsertSpan': // This workaround inserts an empty span element so that we are no // longer trying to select a text node, var parentDoc = findDoc(savedParentElement); // A function used to generate a unique ID for our temporary span. var randLetters = function(count) { // Build a list of 26 letters. var Letters = ''; for (var index = 0; index<26; ++index) { Letters += String.fromCharCode('a'.charCodeAt(0) + index); } var result = ''; for (var index=0; index<count; ++index) { result += Letters.substr(Math.floor(Math.random()*Letters.length + 1), 1); } return result; } // We'll try to find a unique ID to use for finding our element. var keyLength = 1; var tempId = '__InsertSpan_Workaround_' + randLetters(keyLength); while (parentDoc.getElementById(tempId)) { // Each time there's a collision, we'll increase our key length by // one, making the chances of a collision exponentially more rare. keyLength += 1; tempId = '__InsertSpan_Workaround_' + randLetters(keyLength); } // Now that we have a uniquely identifiable element, we'll stick it and // and use it to orient our selection. savedSelection.pasteHTML('<span id="' + tempId + '"></span>'); var tempSpan = parentDoc.getElementById(tempId); savedSelection.moveToElementText(tempSpan); savedSelection.select(); break; case 'JustificationHack': // Setting the justification on an element causes IE to alter the // markup so that the selection we want to make is possible. // Unfortunately, this can force block elements to be kicked out of // their containing element, so it is not recommended. // Set a non-valid character and use it to anchor our selection. var magicString = String.fromCharCode(1); savedSelection.pasteHTML(magicString); savedSelection.findText(magicString,-1); savedSelection.select(); // I don't know how to find out if there's an existing justification on // this element. Hopefully, you're doing all of your styling outside, // so I'll just clear. I already told you this was a hack. savedSelection.execCommand('JustifyNone'); savedSelection.pasteHTML(''); break; case 'VisibleCue': default: // This method will insert a little box character to hold our selection // in the desired spot. We're depending on the user to see this ugly // box and delete it themselves. var magicString = String.fromCharCode(1); savedSelection.pasteHTML(magicString); savedSelection.findText(magicString,-1); savedSelection.select(); } } } /** * Selects the contents of the given node. If the node is a "control" type element, (image, form input, table) * the node itself is selected for manipulation. * * @param node DomNode * @param collapseToStart A boolean that, when supplied, says to collapse the selection. True collapses to the start, and false to the end. */ Xinha.prototype.selectNodeContents = function(node, collapseToStart) { this.focusEditor(); this.forceRedraw(); var range; var collapsed = typeof collapseToStart == "undefined" ? true : false; // Tables and Images get selected as "objects" rather than the text contents if ( collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|select|textarea/) ) { range = this._doc.body.createControlRange(); range.add(node); } else { range = this._doc.body.createTextRange(); if (3 == node.nodeType) { // Special handling for text nodes, since moveToElementText fails when // attempting to select a text node // Since the TextRange has a quite limited API, our strategy here is to // select (where possible) neighboring nodes, and then move our ranges // endpoints to be just inside of neighboring selections. if (node.parentNode) { range.moveToElementText(node.parentNode); } else { range.moveToElementText(this._doc.body); } var trimmingRange = this._doc.body.createTextRange(); // In rare situations (mostly html that's been monkeyed about with by // javascript, but that's what we're doing) there can be two adjacent // text nodes. Since we won't be able to handle these, we'll have to // hack an offset by 'move'ing the number of characters they contain. var texthackOffset = 0; var borderElement=node.previousSibling; for (; borderElement && (1 != borderElement.nodeType); borderElement = borderElement.previousSibling) { if (3 == borderElement.nodeType) { // IE doesn't count '\r' as a character, so we have to adjust the offset. texthackOffset += borderElement.nodeValue.length-borderElement.nodeValue.split('\r').length-1; } } if (borderElement && (1 == borderElement.nodeType)) { trimmingRange.moveToElementText(borderElement); range.setEndPoint('StartToEnd', trimmingRange); } if (texthackOffset) { // We now need to move the selection forward the number of characters // in all text nodes in between our text node and our ranges starting // border. range.moveStart('character',texthackOffset); } // Youpi! Now we get to repeat this trimming on the right side. texthackOffset = 0; borderElement=node.nextSibling; for (; borderElement && (1 != borderElement.nodeType); borderElement = borderElement.nextSibling) { if (3 == borderElement.nodeType) { // IE doesn't count '\r' as a character, so we have to adjust the offset. texthackOffset += borderElement.nodeValue.length-borderElement.nodeValue.split('\r').length-1; if (!borderElement.nextSibling) { // When a text node is the last child, IE adds an extra selection // "placeholder" for the newline character. We need to adjust for // this character as well. texthackOffset += 1; } } } if (borderElement && (1 == borderElement.nodeType)) { trimmingRange.moveToElementText(borderElement); range.setEndPoint('EndToStart', trimmingRange); } if (texthackOffset) { // We now need to move the selection backward the number of characters // in all text nodes in between our text node and our ranges ending // border. range.moveEnd('character',-texthackOffset); } if (!node.nextSibling) { // Above we performed a slight adjustment to the offset if the text // node contains a selectable "newline". We need to do the same if the // node we are trying to select contains a newline. range.moveEnd('character',-1); } } else { range.moveToElementText(node); } } if (typeof collapseToStart != "undefined") { range.collapse(collapseToStart); if (!collapseToStart) { range.moveStart('character',-1); range.moveEnd('character',-1); } } range.select(); }; /** Insert HTML at the current position, deleting the selection if any. * * @param html string */ Xinha.prototype.insertHTML = function(html) { this.focusEditor(); var sel = this.getSelection(); var range = this.createRange(sel); range.pasteHTML(html); }; /** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML. * * @returns string */ Xinha.prototype.getSelectedHTML = function() { var sel = this.getSelection(); if (this.selectionEmpty(sel)) return ''; var range = this.createRange(sel); // Need to be careful of control ranges which won't have htmlText if( range.htmlText ) { return range.htmlText; } else if(range.length >= 1) { return range.item(0).outerHTML; } return ''; }; /** Get a Selection object of the current selection. Note that selection objects are browser specific. * * @returns Selection */ Xinha.prototype.getSelection = function() { return this._doc.selection; }; /** Create a Range object from the given selection. Note that range objects are browser specific. * * @param sel Selection object (see getSelection) * @returns Range */ Xinha.prototype.createRange = function(sel) { if (!sel) sel = this.getSelection(); // ticket:1508 - when you do a key event within a // absolute position div, in IE, the toolbar update // for formatblock etc causes a getParentElement() (above) // which produces a "None" select, then if we focusEditor() it // defocuses the absolute div and focuses into the iframe outside of the // div somewhere. // // Removing this is probably a workaround and maybe it breaks something else // focusEditor is used in a number of spots, I woudl have thought it should // do nothing if the editor is already focused. // // if(sel.type == 'None') this.focusEditor(); return sel.createRange(); }; /** Determine if the given event object is a keydown/press event. * * @param event Event * @returns true|false */ Xinha.prototype.isKeyEvent = function(event) { return event.type == "keydown"; } /** Return the character (as a string) of a keyEvent - ie, press the 'a' key and * this method will return 'a', press SHIFT-a and it will return 'A'. * * @param keyEvent * @returns string */ Xinha.prototype.getKey = function(keyEvent) { return String.fromCharCode(keyEvent.keyCode); } /** Return the HTML string of the given Element, including the Element. * * @param element HTML Element DomNode * @returns string */ Xinha.getOuterHTML = function(element) { return element.outerHTML; }; // Control character for retaining edit location when switching modes Xinha.cc = String.fromCharCode(0x2009); Xinha.prototype.setCC = function ( target ) { var cc = Xinha.cc; if ( target == "textarea" ) { var ta = this._textArea; var pos = document.selection.createRange(); pos.collapse(); pos.text = cc; var index = ta.value.indexOf( cc ); var before = ta.value.substring( 0, index ); var after = ta.value.substring( index + cc.length , ta.value.length ); if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, entities, and inside the body) { var tagEnd = after.indexOf(">") + 1; ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); } else ta.value = before + cc + after; ta.value = ta.value.replace(new RegExp ('(&[^'+cc+']*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); } else { var sel = this.getSelection(); var r = sel.createRange(); if ( sel.type == 'Control' ) { var control = r.item(0); control.outerHTML += cc; } else { r.collapse(); r.text = cc; } } }; Xinha.prototype.findCC = function ( target ) { var findIn = ( target == 'textarea' ) ? this._textArea : this._doc.body; range = findIn.createTextRange(); // in case the cursor is inside a link automatically created from a url // the cc also appears in the url and we have to strip it out additionally if( range.findText( escape(Xinha.cc) ) ) { range.select(); range.text = ''; range.select(); } if( range.findText( Xinha.cc ) ) { range.select(); range.text = ''; range.select(); } if ( target == 'textarea' ) this._textArea.focus(); }; /** Return a doctype or empty string depending on whether the document is in Qirksmode or Standards Compliant Mode * It's hardly possible to detect the actual doctype without unreasonable effort, so we set HTML 4.01 just to trigger the rendering mode * * @param doc DOM element document * @returns string doctype || empty */ Xinha.getDoctype = function (doc) { return (doc.compatMode == "CSS1Compat" && Xinha.ie_version < 8 ) ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' : ''; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/InternetExplorer/InternetExplorer.js
JavaScript
art
30,189
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the WebKit (Safari) compatability plugin, part of the Xinha core. -- -- The file is loaded as a special plugin by the Xinha Core when -- Xinha is being run under a Webkit based browser such as Safari -- -- It provides implementation and specialisation for various methods -- in the core where different approaches per browser are required. -- -- Design Notes:: -- Most methods here will simply be overriding Xinha.prototype.<method> -- and should be called that, but methods specific to Webkit should -- be a part of the WebKit.prototype, we won't trample on namespace -- that way. -- -- $HeadURL: http://svn.xinha.org/trunk/modules/WebKit/WebKit.js $ -- $LastChangedDate: 2008-12-31 08:18:54 +1300 (Wed, 31 Dec 2008) $ -- $LastChangedRevision: 1146 $ -- $LastChangedBy: nicholasbs $ --------------------------------------------------------------------------*/ WebKit._pluginInfo = { name : "WebKit", origin : "Xinha Core", version : "$LastChangedRevision: 1146 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/WebKit/WebKit.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; function WebKit(editor) { this.editor = editor; editor.WebKit = this; } /** Allow Webkit to handle some key events in a special way. */ WebKit.prototype.onKeyPress = function(ev) { var editor = this.editor; var s = editor.getSelection(); // Handle shortcuts if(editor.isShortCut(ev)) { switch(editor.getKey(ev).toLowerCase()) { case 'z': if(editor._unLink && editor._unlinkOnUndo) { Xinha._stopEvent(ev); editor._unLink(); editor.updateToolbar(); return true; } break; case 'a': // ctrl-a selects all, but break; case 'v': // If we are not using htmlareaPaste, don't let Xinha try and be fancy but let the // event be handled normally by the browser (don't stopEvent it) if(!editor.config.htmlareaPaste) { return true; } break; } } // Handle normal characters switch(editor.getKey(ev)) { // Space, see if the text just typed looks like a URL, or email address // and link it appropriatly case ' ': var autoWrap = function (textNode, tag) { var rightText = textNode.nextSibling; if ( typeof tag == 'string') { tag = editor._doc.createElement(tag); } var a = textNode.parentNode.insertBefore(tag, rightText); Xinha.removeFromParent(textNode); a.appendChild(textNode); rightText.data = ' ' + rightText.data; s.collapse(rightText, 1); editor._unLink = function() { var t = a.firstChild; a.removeChild(t); a.parentNode.insertBefore(t, a); Xinha.removeFromParent(a); editor._unLink = null; editor._unlinkOnUndo = false; }; editor._unlinkOnUndo = true; return a; }; if ( editor.config.convertUrlsToLinks && s && s.isCollapsed && s.anchorNode.nodeType == 3 && s.anchorNode.data.length > 3 && s.anchorNode.data.indexOf('.') >= 0 ) { var midStart = s.anchorNode.data.substring(0,s.anchorOffset).search(/\S{4,}$/); if ( midStart == -1 ) { break; } if ( editor._getFirstAncestor(s, 'a') ) { break; // already in an anchor } var matchData = s.anchorNode.data.substring(0,s.anchorOffset).replace(/^.*?(\S*)$/, '$1'); var mEmail = matchData.match(Xinha.RE_email); if ( mEmail ) { var leftTextEmail = s.anchorNode; var rightTextEmail = leftTextEmail.splitText(s.anchorOffset); var midTextEmail = leftTextEmail.splitText(midStart); autoWrap(midTextEmail, 'a').href = 'mailto:' + mEmail[0]; break; } RE_date = /([0-9]+\.)+/; //could be date or ip or something else ... RE_ip = /(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/; var mUrl = matchData.match(Xinha.RE_url); if ( mUrl ) { if (RE_date.test(matchData)) { break; //ray: disabling linking of IP numbers because of general bugginess (see Ticket #1085) /*if (!RE_ip.test(matchData)) { break; }*/ } var leftTextUrl = s.anchorNode; var rightTextUrl = leftTextUrl.splitText(s.anchorOffset); var midTextUrl = leftTextUrl.splitText(midStart); autoWrap(midTextUrl, 'a').href = (mUrl[1] ? mUrl[1] : 'http://') + mUrl[2]; break; } } break; } // Handle special keys switch ( ev.keyCode ) { case 13: // ENTER if( ev.shiftKey ) { //TODO: here we need to add insert new line } break; case 27: // ESCAPE if ( editor._unLink ) { editor._unLink(); Xinha._stopEvent(ev); } break; case 8: // KEY backspace case 46: // KEY delete // We handle the mozilla backspace directly?? if ( !ev.shiftKey && this.handleBackspace() ) { Xinha._stopEvent(ev); } break; default: editor._unlinkOnUndo = false; // Handle the "auto-linking", specifically this bit of code sets up a handler on // an self-titled anchor (eg <a href="http://www.gogo.co.nz/">www.gogo.co.nz</a>) // when the text content is edited, such that it will update the href on the anchor if ( s.anchorNode && s.anchorNode.nodeType == 3 ) { // See if we might be changing a link var a = editor._getFirstAncestor(s, 'a'); // @todo: we probably need here to inform the setTimeout below that we not changing a link and not start another setTimeout if ( !a ) { break; // not an anchor } if ( !a._updateAnchTimeout ) { if ( s.anchorNode.data.match(Xinha.RE_email) && a.href.match('mailto:' + s.anchorNode.data.trim()) ) { var textNode = s.anchorNode; var fnAnchor = function() { a.href = 'mailto:' + textNode.data.trim(); // @fixme: why the hell do another timeout is started ? // This lead to never ending timer if we dont remove this line // But when removed, the email is not correctly updated // // - to fix this we should make fnAnchor check to see if textNode.data has // stopped changing for say 5 seconds and if so we do not make this setTimeout a._updateAnchTimeout = setTimeout(fnAnchor, 250); }; a._updateAnchTimeout = setTimeout(fnAnchor, 1000); break; } var m = s.anchorNode.data.match(Xinha.RE_url); if ( m && a.href.match(new RegExp( 'http(s)?://' + Xinha.escapeStringForRegExp( s.anchorNode.data.trim() ) ) ) ) { var txtNode = s.anchorNode; var fnUrl = function() { // Sometimes m is undefined becase the url is not an url anymore (was www.url.com and become for example www.url) // ray: shouldn't the link be un-linked then? m = txtNode.data.match(Xinha.RE_url); if(m) { a.href = (m[1] ? m[1] : 'http://') + m[2]; } // @fixme: why the hell do another timeout is started ? // This lead to never ending timer if we dont remove this line // But when removed, the url is not correctly updated // // - to fix this we should make fnUrl check to see if textNode.data has // stopped changing for say 5 seconds and if so we do not make this setTimeout a._updateAnchTimeout = setTimeout(fnUrl, 250); }; a._updateAnchTimeout = setTimeout(fnUrl, 1000); } } } break; } return false; // Let other plugins etc continue from here. } /** When backspace is hit, the Gecko onKeyPress will execute this method. * I don't remember what the exact purpose of this is though :-( * */ WebKit.prototype.handleBackspace = function() { var editor = this.editor; setTimeout( function() { var sel = editor.getSelection(); var range = editor.createRange(sel); var SC = range.startContainer; var SO = range.startOffset; var EC = range.endContainer; var EO = range.endOffset; var newr = SC.nextSibling; if ( SC.nodeType == 3 ) { SC = SC.parentNode; } if ( ! ( /\S/.test(SC.tagName) ) ) { var p = document.createElement("p"); while ( SC.firstChild ) { p.appendChild(SC.firstChild); } SC.parentNode.insertBefore(p, SC); Xinha.removeFromParent(SC); var r = range.cloneRange(); r.setStartBefore(newr); r.setEndAfter(newr); r.extractContents(); sel.removeAllRanges(); sel.addRange(r); } }, 10); }; WebKit.prototype.inwardHtml = function(html) { return html; } WebKit.prototype.outwardHtml = function(html) { return html; } WebKit.prototype.onExecCommand = function(cmdID, UI, param) { this.editor._doc.execCommand('styleWithCSS', false, false); //switch styleWithCSS off; seems to make no difference though switch(cmdID) { case 'paste': alert(Xinha._lc("The Paste button does not work in the Safari browser for security reasons. Press CTRL-V on your keyboard to paste directly.")); return true; // Indicate paste is done, stop command being issued to browser by Xinha.prototype.execCommand break; case 'removeformat': var editor = this.editor; var sel = editor.getSelection(); var selSave = editor.saveSelection(sel); var range = editor.createRange(sel); var els = editor._doc.getElementsByTagName('*'); els = Xinha.collectionToArray(els); var start = ( range.startContainer.nodeType == 1 ) ? range.startContainer : range.startContainer.parentNode; var i,el,newNode, fragment, child,r2 = editor._doc.createRange(); function clean (el) { if (el.nodeType != 1) return; el.removeAttribute('style'); for (var j=0; j<el.childNodes.length;j++) { clean(el.childNodes[j]); } if ( (el.tagName.toLowerCase() == 'span' && !el.attributes.length ) || el.tagName.toLowerCase() == 'font') { r2.selectNodeContents(el); fragment = r2.extractContents(); while (fragment.firstChild) { child = fragment.removeChild(fragment.firstChild); el.parentNode.insertBefore(child, el); } el.parentNode.removeChild(el); } } if (sel.isCollapsed) { els = editor._doc.body.childNodes; for (i = 0; i < els.length; i++) { el = els[i]; if (el.nodeType != 1) continue; if (el.tagName.toLowerCase() == 'span') { newNode = editor.convertNode(el, 'div'); el.parentNode.replaceChild(newNode, el); el = newNode; } clean(el); } } else { for (i=0; i<els.length;i++) { el = els[i]; if ( range.isPointInRange(el, 0) || (els[i] == start && range.startOffset == 0)) { clean(el); } } } r2.detach(); editor.restoreSelection(selSave); return true; break; } return false; } WebKit.prototype.onMouseDown = function(ev) { // selection of hr in Safari seems utterly impossible :( if (ev.target.tagName.toLowerCase() == "hr" || ev.target.tagName.toLowerCase() == "img") { this.editor.selectNodeContents(ev.target); } } /*--------------------------------------------------------------------------*/ /*------- IMPLEMENTATION OF THE ABSTRACT "Xinha.prototype" METHODS ---------*/ /*--------------------------------------------------------------------------*/ /** Insert a node at the current selection point. * @param toBeInserted DomNode */ Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { var sel = this.getSelection(); var range = this.createRange(sel); // remove the current selection sel.removeAllRanges(); range.deleteContents(); var node = range.startContainer; var pos = range.startOffset; var selnode = toBeInserted; switch ( node.nodeType ) { case 3: // Node.TEXT_NODE // we have to split it at the caret position. if ( toBeInserted.nodeType == 3 ) { // do optimized insertion node.insertData(pos, toBeInserted.data); range = this.createRange(); range.setEnd(node, pos + toBeInserted.length); range.setStart(node, pos + toBeInserted.length); sel.addRange(range); } else { node = node.splitText(pos); if ( toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */ ) { selnode = selnode.firstChild; } node.parentNode.insertBefore(toBeInserted, node); this.selectNodeContents(selnode); this.updateToolbar(); } break; case 1: // Node.ELEMENT_NODE if ( toBeInserted.nodeType == 11 /* Node.DOCUMENT_FRAGMENT_NODE */ ) { selnode = selnode.firstChild; } node.insertBefore(toBeInserted, node.childNodes[pos]); this.selectNodeContents(selnode); this.updateToolbar(); break; } }; /** Get the parent element of the supplied or current selection. * @param sel optional selection as returned by getSelection * @returns DomNode */ Xinha.prototype.getParentElement = function(sel) { if ( typeof sel == 'undefined' ) { sel = this.getSelection(); } var range = this.createRange(sel); try { var p = range.commonAncestorContainer; if ( !range.collapsed && range.startContainer == range.endContainer && range.startOffset - range.endOffset <= 1 && range.startContainer.hasChildNodes() ) { p = range.startContainer.childNodes[range.startOffset]; } while ( p.nodeType == 3 ) { p = p.parentNode; } return p; } catch (ex) { return null; } }; /** * Returns the selected element, if any. That is, * the element that you have last selected in the "path" * at the bottom of the editor, or a "control" (eg image) * * @returns null | DomNode */ Xinha.prototype.activeElement = function(sel) { if ( ( sel === null ) || this.selectionEmpty(sel) ) { return null; } // For Mozilla we just see if the selection is not collapsed (something is selected) // and that the anchor (start of selection) is an element. This might not be totally // correct, we possibly should do a simlar check to IE? if ( !sel.isCollapsed ) { if ( sel.anchorNode.childNodes.length > sel.anchorOffset && sel.anchorNode.childNodes[sel.anchorOffset].nodeType == 1 ) { return sel.anchorNode.childNodes[sel.anchorOffset]; } else if ( sel.anchorNode.nodeType == 1 ) { return sel.anchorNode; } else { return null; // return sel.anchorNode.parentNode; } } return null; }; /** * Determines if the given selection is empty (collapsed). * @param selection Selection object as returned by getSelection * @returns true|false */ Xinha.prototype.selectionEmpty = function(sel) { if ( !sel ) { return true; } if ( typeof sel.isCollapsed != 'undefined' ) { return sel.isCollapsed; } return true; }; /** * Returns a range object to be stored * and later restored with Xinha.prototype.restoreSelection() * * @returns Range */ Xinha.prototype.saveSelection = function() { return this.createRange(this.getSelection()).cloneRange(); } /** * Restores a selection previously stored * @param savedSelection Range object as returned by Xinha.prototype.restoreSelection() */ Xinha.prototype.restoreSelection = function(savedSelection) { var sel = this.getSelection(); sel.removeAllRanges(); sel.addRange(savedSelection); } /** * Selects the contents of the given node. If the node is a "control" type element, (image, form input, table) * the node itself is selected for manipulation. * * @param node DomNode * @param collapseToStart A boolean that, when supplied, says to collapse the selection. True collapses to the start, and false to the end. */ Xinha.prototype.selectNodeContents = function(node, collapseToStart) { this.focusEditor(); this.forceRedraw(); var range; var collapsed = typeof collapseToStart == "undefined" ? true : false; var sel = this.getSelection(); range = this._doc.createRange(); // Tables and Images get selected as "objects" rather than the text contents if ( collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|textarea|select/) ) { range.selectNode(node); } else { range.selectNodeContents(node); } sel.removeAllRanges(); sel.addRange(range); if (typeof collapseToStart != "undefined") { if (collapseToStart) { sel.collapse(range.startContainer, range.startOffset); } else { sel.collapse(range.endContainer, range.endOffset); } } }; /** Insert HTML at the current position, deleting the selection if any. * * @param html string */ Xinha.prototype.insertHTML = function(html) { var sel = this.getSelection(); var range = this.createRange(sel); this.focusEditor(); // construct a new document fragment with the given HTML var fragment = this._doc.createDocumentFragment(); var div = this._doc.createElement("div"); div.innerHTML = html; while ( div.firstChild ) { // the following call also removes the node from div fragment.appendChild(div.firstChild); } // this also removes the selection var node = this.insertNodeAtSelection(fragment); }; /** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML. * * @returns string */ Xinha.prototype.getSelectedHTML = function() { var sel = this.getSelection(); if (sel.isCollapsed) return ''; var range = this.createRange(sel); if ( range ) { return Xinha.getHTML(range.cloneContents(), false, this); } else return ''; }; /** Get a Selection object of the current selection. Note that selection objects are browser specific. * * @returns Selection */ Xinha.prototype.getSelection = function() { return this._iframe.contentWindow.getSelection(); }; /** Create a Range object from the given selection. Note that range objects are browser specific. * * @param sel Selection object (see getSelection) * @returns Range */ Xinha.prototype.createRange = function(sel) { this.activateEditor(); if ( typeof sel != "undefined" ) { try { return sel.getRangeAt(0); } catch(ex) { return this._doc.createRange(); } } else { return this._doc.createRange(); } }; /** Determine if the given event object is a keydown/press event. * * @param event Event * @returns true|false */ Xinha.prototype.isKeyEvent = function(event) { return event.type == "keydown"; } /** Return the character (as a string) of a keyEvent - ie, press the 'a' key and * this method will return 'a', press SHIFT-a and it will return 'A'. * * @param keyEvent * @returns string */ Xinha.prototype.getKey = function(keyEvent) { // with ctrl pressed Safari does not give the charCode, unfortunately this (shortcuts) is about the only thing this function is for var key = String.fromCharCode(parseInt(keyEvent.keyIdentifier.replace(/^U\+/,''),16)); if (keyEvent.shiftKey) return key; else return key.toLowerCase(); } /** Return the HTML string of the given Element, including the Element. * * @param element HTML Element DomNode * @returns string */ Xinha.getOuterHTML = function(element) { return (new XMLSerializer()).serializeToString(element); }; Xinha.cc = String.fromCharCode(8286); Xinha.prototype.setCC = function ( target ) { var cc = Xinha.cc; try { if ( target == "textarea" ) { var ta = this._textArea; var index = ta.selectionStart; var before = ta.value.substring( 0, index ) var after = ta.value.substring( index, ta.value.length ); if ( after.match(/^[^<]*>/) ) // make sure cursor is in an editable area (outside tags, script blocks, enities and inside the body) { var tagEnd = after.indexOf(">") + 1; ta.value = before + after.substring( 0, tagEnd ) + cc + after.substring( tagEnd, after.length ); } else ta.value = before + cc + after; ta.value = ta.value.replace(new RegExp ('(&[^'+cc+';]*?)('+cc+')([^'+cc+']*?;)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('(<script[^>]*>[^'+cc+']*?)('+cc+')([^'+cc+']*?<\/script>)'), "$1$3$2"); ta.value = ta.value.replace(new RegExp ('^([^'+cc+']*)('+cc+')([^'+cc+']*<body[^>]*>)(.*?)'), "$1$3$2$4"); } else { var sel = this.getSelection(); sel.getRangeAt(0).insertNode( this._doc.createTextNode( cc ) ); } } catch (e) {} }; Xinha.prototype.findCC = function ( target ) { var cc = Xinha.cc; if ( target == 'textarea' ) { var ta = this._textArea; var pos = ta.value.indexOf( cc ); if ( pos == -1 ) return; var end = pos + cc.length; var before = ta.value.substring( 0, pos ); var after = ta.value.substring( end, ta.value.length ); ta.value = before ; ta.scrollTop = ta.scrollHeight; var scrollPos = ta.scrollTop; ta.value += after; ta.setSelectionRange(pos,pos); ta.focus(); ta.scrollTop = scrollPos; } else { var self = this; try { var doc = this._doc; doc.body.innerHTML = doc.body.innerHTML.replace(new RegExp(cc),'<span id="XinhaEditingPostion"></span>'); var posEl = doc.getElementById('XinhaEditingPostion'); this.selectNodeContents(posEl); this.scrollToElement(posEl); posEl.parentNode.removeChild(posEl); this._iframe.contentWindow.focus(); } catch (e) {} } }; /*--------------------------------------------------------------------------*/ /*------------ EXTEND SOME STANDARD "Xinha.prototype" METHODS --------------*/ /*--------------------------------------------------------------------------*/ Xinha.prototype._standardToggleBorders = Xinha.prototype._toggleBorders; Xinha.prototype._toggleBorders = function() { var result = this._standardToggleBorders(); // flashing the display forces moz to listen (JB:18-04-2005) - #102 var tables = this._doc.getElementsByTagName('TABLE'); for(var i = 0; i < tables.length; i++) { tables[i].style.display="none"; tables[i].style.display="table"; } return result; }; /** Return the doctype of a document, if set * * @param doc DOM element document * @returns string the actual doctype */ Xinha.getDoctype = function (doc) { var d = ''; if (doc.doctype) { d += '<!DOCTYPE ' + doc.doctype.name + " PUBLIC "; d += doc.doctype.publicId ? '"' + doc.doctype.publicId + '"' : ''; d += doc.doctype.systemId ? ' "'+ doc.doctype.systemId + '"' : ''; d += ">"; } return d; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/WebKit/WebKit.js
JavaScript
art
24,683
// I18N constants // LANG: "nl", ENCODING: UTF-8 // translated: Arthur Bogaart a.bogaart@onehippo.org { "Maximize/Minimize Editor": "Editor maximaliseren/verkleinen" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/nl.js
JavaScript
art
171
// I18N constants // LANG: "de", ENCODING: UTF-8 // translated: Raimund Meyer xinha@ray-of-light.org { "Maximize/Minimize Editor": "Editor maximieren/verkleinern" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/de.js
JavaScript
art
168
// I18N constants // LANG: "pl", ENCODING: UTF-8 // translated: Krzysztof Kotowicz, koto1sa@o2.pl, http://www.eskot.krakow.pl/portfolio { "Maximize/Minimize Editor": "Maksymalizuj/minimalizuj edytor" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/pl.js
JavaScript
art
205
// I18N constants // LANG: "ru", ENCODING: UTF-8 // Author: Andrei Blagorazumov, a@fnr.ru { "Maximize/Minimize Editor": "Развернуть/Свернуть редактор" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/ru.js
JavaScript
art
189
// I18N constants // LANG: "sv" (Swedish), ENCODING: UTF-8 // translated: Erik Dalén, <dalen@jpl.se> { "Maximize/Minimize Editor": "Maximera/Minimera WYSIWYG fönster" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/sv.js
JavaScript
art
174
// I18N constants // LANG: "fr", ENCODING: UTF-8 { "Maximize/Minimize Editor": "Agrandir/Réduire l'éditeur" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/fr.js
JavaScript
art
114
// I18N constants // LANG: "ja", ENCODING: UTF-8 { "Maximize/Minimize Editor": "エディタの最大化/最小化" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/ja.js
JavaScript
art
120
// I18N constants // LANG: "nb", ENCODING: UTF-8 // translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com { "Maximize/Minimize Editor": "Maksimer/Minimer WYSIWYG vindu" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/nb.js
JavaScript
art
191
// I18N constants // LANG: "es", ENCODING: UTF-8 // translated: Derick Leony <dleony@gmail.com> { "Maximize/Minimize Editor": "Maximizar/Minimizar Editor" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/es.js
JavaScript
art
159
// I18N constants // // LANG: "pt_br", ENCODING: UTF-8 // Portuguese Brazilian Translation // // Author: Marcio Barbosa, <marcio@mpg.com.br> // MSN: tomarshall@msn.com - ICQ: 69419933 // Site: http://www.mpg.com.br // // Last revision: 06 september 2007 // Please don´t remove this information // If you modify any source, please insert a comment with your name and e-mail // // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt). { "Maximize/Minimize Editor": "Maximizar/Minimizar Editor" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/lang/pt_br.js
JavaScript
art
559
function FullScreen(editor, args) { this.editor = editor; this.originalSizes = null; editor._superclean_on = false; var cfg = editor.config; cfg.registerIcon('fullscreen', [_editor_url + cfg.imgURL + 'ed_buttons_main.png',8,0]); cfg.registerIcon('fullscreenrestore', [_editor_url + cfg.imgURL + 'ed_buttons_main.png',9,0]); cfg.registerButton ( 'fullscreen', this._lc("Maximize/Minimize Editor"), cfg.iconList.fullscreen, true, function(e, objname, obj) { e._fullScreen(); } ); // See if we can find 'popupeditor' and replace it with fullscreen cfg.addToolbarElement("fullscreen", "popupeditor", 0); } FullScreen._pluginInfo = { name : "FullScreen", version : "1.0", developer: "James Sleeman", developer_url: "http://www.gogo.co.nz/", c_owner : "Gogo Internet Services", license : "htmlArea", sponsor : "Gogo Internet Services", sponsor_url : "http://www.gogo.co.nz/" }; FullScreen.prototype._lc = function(string) { return Xinha._lc(string, {url : _editor_url + 'modules/FullScreen/lang/',context:"FullScreen"}); }; /** fullScreen makes an editor take up the full window space (and resizes when the browser is resized) * the principle is the same as the "popupwindow" functionality in the original htmlArea, except * this one doesn't popup a window (it just uses to positioning hackery) so it's much more reliable * and much faster to switch between */ Xinha.prototype._fullScreen = function() { var e = this; var cfg = e.config; function sizeItUp() { if(!e._isFullScreen || e._sizing) return false; e._sizing = true; // Width & Height of window var dim = Xinha.viewportSize(); if(e.config.fullScreenSizeDownMethod == 'restore') { e.originalSizes = { x: parseInt(e._htmlArea.style.width), y: parseInt(e._htmlArea.style.height), dim: dim }; } var h = dim.y - e.config.fullScreenMargins[0] - e.config.fullScreenMargins[2]; var w = dim.x - e.config.fullScreenMargins[1] - e.config.fullScreenMargins[3]; e.sizeEditor(w + 'px', h + 'px',true,true); e._sizing = false; if ( e._toolbarObjects.fullscreen ) e._toolbarObjects.fullscreen.swapImage(cfg.iconList.fullscreenrestore); } function sizeItDown() { if(e._isFullScreen || e._sizing) return false; e._sizing = true; if(e.originalSizes != null) { var os = e.originalSizes; var nDim = Xinha.viewportSize(); var nW = os.x + (nDim.x - os.dim.x); var nH = os.y + (nDim.y - os.dim.y); e.sizeEditor( nW + 'px', nH + 'px', e.config.sizeIncludesBars, e.config.sizeIncludesPanels); e.originalSizes = null; } else e.initSize(); e._sizing = false; if ( e._toolbarObjects.fullscreen ) e._toolbarObjects.fullscreen.swapImage(cfg.iconList.fullscreen); } /** It's not possible to reliably get scroll events, particularly when we are hiding the scrollbars * so we just reset the scroll ever so often while in fullscreen mode */ function resetScroll() { if(e._isFullScreen) { window.scroll(0,0); window.setTimeout(resetScroll,150); } } if(typeof this._isFullScreen == 'undefined') { this._isFullScreen = false; if(e.target != e._iframe) { Xinha._addEvent(window, 'resize', sizeItUp); } } // Gecko has a bug where if you change position/display on a // designMode iframe that designMode dies. if(Xinha.is_gecko) { this.deactivateEditor(); } if(this._isFullScreen) { // Unmaximize this._htmlArea.style.position = ''; if (!Xinha.is_ie ) this._htmlArea.style.border = ''; try { if(Xinha.is_ie && document.compatMode == 'CSS1Compat') { var bod = document.getElementsByTagName('html'); } else { var bod = document.getElementsByTagName('body'); } bod[0].style.overflow=''; } catch(e) { // Nutthin } this._isFullScreen = false; sizeItDown(); // Restore all ancestor positions var ancestor = this._htmlArea; while((ancestor = ancestor.parentNode) && ancestor.style) { ancestor.style.position = ancestor._xinha_fullScreenOldPosition; ancestor._xinha_fullScreenOldPosition = null; } if ( Xinha.ie_version < 7 ) { var selects = document.getElementsByTagName("select"); for ( var i=0;i<selects.length;++i ) { selects[i].style.visibility = 'visible'; } } window.scroll(this._unScroll.x, this._unScroll.y); } else { // Get the current Scroll Positions this._unScroll = { x:(window.pageXOffset)?(window.pageXOffset):(document.documentElement)?document.documentElement.scrollLeft:document.body.scrollLeft, y:(window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop }; // Make all ancestors position = static var ancestor = this._htmlArea; while((ancestor = ancestor.parentNode) && ancestor.style) { ancestor._xinha_fullScreenOldPosition = ancestor.style.position; ancestor.style.position = 'static'; } // very ugly bug in IE < 7 shows select boxes through elements that are positioned over them if ( Xinha.ie_version < 7 ) { var selects = document.getElementsByTagName("select"); var s, currentEditor; for ( var i=0;i<selects.length;++i ) { s = selects[i]; currentEditor = false; while ( s = s.parentNode ) { if ( s == this._htmlArea ) { currentEditor = true; break; } } if ( !currentEditor && selects[i].style.visibility != 'hidden') { selects[i].style.visibility = 'hidden'; } } } // Maximize window.scroll(0,0); this._htmlArea.style.position = 'absolute'; this._htmlArea.style.zIndex = 999; this._htmlArea.style.left = e.config.fullScreenMargins[3] + 'px'; this._htmlArea.style.top = e.config.fullScreenMargins[0] + 'px'; if ( !Xinha.is_ie && !Xinha.is_webkit ) this._htmlArea.style.border = 'none'; this._isFullScreen = true; resetScroll(); try { if(Xinha.is_ie && document.compatMode == 'CSS1Compat') { var bod = document.getElementsByTagName('html'); } else { var bod = document.getElementsByTagName('body'); } bod[0].style.overflow='hidden'; } catch(e) { // Nutthin } sizeItUp(); } if(Xinha.is_gecko) { this.activateEditor(); } this.focusEditor(); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/FullScreen/full-screen.js
JavaScript
art
6,736
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-2008 Xinha Developer Team and contributors -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the new all-in-one implementation of dialogs for Xinha -- -- -- $HeadURL: http://svn.xinha.org/trunk/modules/Dialogs/XinhaDialog.js $ -- $LastChangedDate: 2010-02-15 07:13:26 +1300 (Mon, 15 Feb 2010) $ -- $LastChangedRevision: 1238 $ -- $LastChangedBy: wymsy $ --------------------------------------------------------------------------*/ /*jslint regexp: false, rhino: false, browser: true, bitwise: false, forin: false, adsafe: false, evil: true, nomen: false, glovar: false, debug: false, eqeqeq: false, passfail: false, sidebar: false, laxbreak: false, on: false, cap: true, white: false, widget: false, undef: true, plusplus: false*/ /*global Xinha */ /** Xinha Dialog * * @constructor * @version $LastChangedRevision: 1238 $ $LastChangedDate: 2010-02-15 07:13:26 +1300 (Mon, 15 Feb 2010) $ * @param {Xinha} editor Xinha object * @param {String} html string The HTML for the dialog's UI * @param {String} localizer string the "context" parameter for Xinha._lc(), typically the name of the plugin * @param {Object} size object with two possible properties of the size: width & height as int, where height is optional * @param {Object} options dictionary with optional boolean attributes 'modal', 'closable', 'resizable', and 'centered', as well as integer attribute 'layer' */ Xinha.Dialog = function(editor, html, localizer, size, options) { var dialog = this; /** Used for dialog.getElementById() * @type Object * @private */ this.id = { }; /** Used for dialog.getElementById() * @type Object * @private */ this.r_id = { }; // reverse lookup id /** The calling Xinha instance * @type Xinha * @private */ this.editor = editor; /** * @private * @type Document */ this.document = document; /** Object with width, height as numbers * @type Object */ this.size = size; /** * @type Boolean * @private */ this.modal = (options && options.modal === false) ? false : true; /** * @type Boolean * @private */ this.closable = (options && options.closable === false) ? false : true; /** * @type Boolean * @private */ this.resizable = (options && options.resizable === false) ? false : true; /** * @type Number * @private */ this.layer = (options && options.layer) ? options.layer : 0; /** * @type Boolean * @private */ this.centered = (options && options.centered === true) ? true : false; /** * @type Boolean * @private */ this.closeOnEscape = (options && options.closeOnEscape === true) ? true : false; /** The div that is the actual dialog * @type DomNode */ this.rootElem = null; /** The caption at the top of the dialog that is used to dragged the dialog. It is automatically created from the first h1 in the dialog's HTML * @type DomNode */ this.captionBar = null; /** This div contains the content * @type DomNode */ this.main = null; /** Each dialog has a background * @type DomNode * @private */ this.background = null; /** * @type Boolean * @private */ this.centered = null; /** * @type Boolean * @private */ this.greyout = null; /** * @type DomNode * @private */ this.buttons = null; /** * @type DomNode * @private */ this.closer = null; /** * @type DomNode * @private */ this.icon = null; /** * @type DomNode * @private */ this.resizer = null; /** * @type Number * @private */ this.initialZ = null; /* Check global config to see if we should override any of the above options If a global option is set, it will apply to all dialogs, regardless of their individual settings (i.e., it will override them). If the global option is undefined, the options passed in above will be used. */ var globalOptions = editor.config.dialogOptions; if (globalOptions) { if (typeof globalOptions.centered != 'undefined') { this.centered = globalOptions.centered; } if (typeof globalOptions.resizable != 'undefined') { this.resizable = globalOptions.resizable; } if (typeof globalOptions.closable != 'undefined') { this.closable = globalOptions.closable; } if (typeof globalOptions.greyout != 'undefined') { this.greyout = globalOptions.greyout; } if (typeof globalOptions.closeOnEscape != 'undefined') { this.closeOnEscape = globalOptions.closeOnEscape; } } var backG; if (Xinha.is_ie) { // IE6 needs the iframe to hide select boxes backG = document.createElement("iframe"); backG.src = "about:blank"; backG.onreadystatechange = function () { var doc = window.event.srcElement.contentWindow.document; if (this.readyState == 'complete' && doc && doc.body) { var div = doc.createElement('div'); //insert styles to make background color skinable var styles, stylesheets = document.styleSheets; for (var i=0;i<stylesheets.length;i++) { if (stylesheets[i].id.indexOf('Xinha') != -1 && stylesheets[i].cssText) { styles += stylesheets[i].cssText; } } div.innerHTML = '<br><style type="text/css">\n'+styles+'\n</style>'; // strange way, but didn't work otherwise doc.getElementsByTagName('body')[0].appendChild(div); doc.body.className = 'xinha_dialog_background'; if (dialog.modal) { doc.body.className += '_modal'; } if (dialog.greyout) { doc.body.className += '_greyout'; } } }; } else { // Mozilla (<FF3) can't have the iframe, because it hides the caret in text fields // see https://bugzilla.mozilla.org/show_bug.cgi?id=226933 backG = document.createElement("div"); } backG.className = "xinha_dialog_background"; if (this.modal) { backG.className += '_modal'; } if (this.greyout) { backG.className += '_greyout'; } var z = 1000; if (!Xinha.Dialog.initialZ) { var p = editor._htmlArea; while (p) { if (p.style && parseInt(p.style.zIndex, 10) > z) { z = parseInt(p.style.zIndex, 10); } p = p.parentNode; } Xinha.Dialog.initialZ = z; } z = Xinha.Dialog.initialZ; var s = backG.style; s.position = "absolute"; s.top = 0; s.left = 0; s.border = 'none'; s.overflow = "hidden"; s.display = "none"; s.zIndex = (this.modal ? z + 25 : z +1 ) + this.layer; document.body.appendChild(backG); this.background = backG; backG = null; Xinha.freeLater(this, "background"); var rootElem = document.createElement('div'); //I've got the feeling dragging is much slower in IE7 w/ pos:fixed, besides the strange fact that it only works in Strict mode //rootElem.style.position = (Xinha.ie_version < 7 ||(Xinha.is_ie && document.compatMode == "BackCompat") || !this.modal) ? "absolute" : "fixed"; rootElem.style.position = (Xinha.is_ie || !this.modal) ? "absolute" : "fixed"; rootElem.style.zIndex = (this.modal ? z + 27 : z + 3 ) + this.layer; rootElem.style.display = 'none'; if (!this.modal) { Xinha._addEvent(rootElem,'mousedown', function () { Xinha.Dialog.activateModeless(dialog);}); } // FIXME: This is nice, but I don't manage to get it switched off on text inputs :( // rootElem.style.MozUserSelect = "none"; rootElem.className = 'dialog' + (this.modal ? '' : ' modeless'); if (Xinha.is_chrome) rootElem.className += ' chrome'; // Hack because border-radius & box-shadow don't go well together in chrome // this.background[1].appendChild(rootElem); document.body.appendChild(rootElem); rootElem.style.paddingBottom = "10px"; rootElem.style.width = ( size && size.width ) ? size.width + 'px' : ''; if (size && size.height) { if (Xinha.ie_version < 7) { rootElem.style.height = size.height + 'px'; } else { rootElem.style.minHeight = size.height + 'px'; } } html = this.translateHtml(html,localizer); var main = document.createElement('div'); rootElem.appendChild(main); main.innerHTML = html; // If the localizer is a string containing a plugin name, it can be used to // lookup the plugin. this.fixupDOM(main, localizer); //make the first h1 to drag&drop the rootElem var captionBar = main.removeChild( main.getElementsByTagName("h1")[0]); rootElem.insertBefore(captionBar,main); Xinha._addEvent(captionBar, 'mousedown',function(ev) { dialog.dragStart(ev); }); captionBar.style.MozUserSelect = "none"; captionBar.style.WebkitUserSelect = "none"; //seems to have no effect captionBar.unselectable = "on"; captionBar.onselectstart = function() {return false;}; this.buttons = document.createElement('div'); s = this.buttons.style; s.position = "absolute"; s.top = "0"; s.right = "2px"; rootElem.appendChild(this.buttons); if (this.closable && this.closeOnEscape) { Xinha._addEvent(document, 'keypress', function(ev) { if (ev.keyCode == 27) // ESC key { if (Xinha.Dialog.activeModeless == dialog || dialog.modal) { dialog.hide(); return true; } } }); } this.closer = null; if ( this.closable ) { this.closer = document.createElement('div'); this.closer.className= 'closeButton'; this.closer.onmousedown = function(ev) { this.className = "closeButton buttonClick"; Xinha._stopEvent(Xinha.getEvent(ev)); return false;}; this.closer.onmouseout = function(ev) { this.className = "closeButton"; Xinha._stopEvent(Xinha.getEvent(ev)); return false;}; this.closer.onmouseup = function() { this.className = "closeButton"; dialog.hide(); return false;}; this.buttons.appendChild(this.closer); var butX = document.createElement('span'); butX.className = 'innerX'; butX.style.position = 'relative'; butX.style.top = '-3px'; butX.appendChild(document.createTextNode('\u00D7')); // cross //below different symbols for future use //butX.appendChild(document.createTextNode('\u25AC')); //bar //butX.appendChild(document.createTextNode('\u25BA')); //triangle right //butX.appendChild(document.createTextNode('\u25B2')); //triangle up //butX.appendChild(document.createTextNode('\u25BC')); //triangle down this.closer.appendChild(butX); butX = null; } this.icon = document.createElement('img'); var icon = this.icon; icon.className = 'icon'; icon.src = editor.config.iconList.dialogCaption; icon.style.position = 'absolute'; icon.style.top = '3px'; icon.style.left = '2px'; icon.ondrag = function () {return false;}; //captionBar.style.paddingLeft = '22px'; rootElem.appendChild(this.icon); var all = rootElem.getElementsByTagName("*"); for (var i=0; i<all.length;i++) { var el = all[i]; if (el.tagName.toLowerCase() == 'textarea' || el.tagName.toLowerCase() == 'input') { // FIXME: this doesn't work //el.style.MozUserSelect = "text"; } else { el.unselectable = "on"; } } this.resizer = null; if (this.resizable) { this.resizer = document.createElement('div'); this.resizer.className = "resizeHandle"; s = this.resizer.style; s.position = "absolute"; s.bottom = "0px"; s.right= "0px"; s.MozUserSelect = 'none'; Xinha._addEvent(this.resizer, 'mousedown', function(ev) { dialog.resizeStart(ev); }); rootElem.appendChild(this.resizer); } this.rootElem = rootElem; this.captionBar = captionBar; this.main = main; captionBar = null; rootElem = null; main = null; Xinha.freeLater(this,"rootElem"); Xinha.freeLater(this,"captionBar"); Xinha.freeLater(this,"main"); Xinha.freeLater(this, "buttons"); Xinha.freeLater(this, "closer"); Xinha.freeLater(this, "icon"); Xinha.freeLater(this, "resizer"); Xinha.freeLater(this, "document"); // for caching size & position after dragging & resizing this.size = {}; }; /** This function is called when the dialog is resized. * By default it does nothing, but you can override it in your Xinha.Dialog object e.g. to resize elements within you Dialog. * Example:<br /> * <code> * var dialog = this.dialog; //The plugin's dialog instance; * dialog.onresize = function() * { * var el = dialog.getElementById('foo'); * el.style.width = dialog.width; * } * </code> */ Xinha.Dialog.prototype.onresize = function() { return true; }; /** This function shows the dialog and populates form elements with values. * Example:<br /> * Given your dialog contains an input element like <code>&lt;input name="[myInput]" type="text" /&gt;</code> * <code> * var dialog = this.dialog; //The plugin's dialog instance; * var values = {myInput : 'My input value'} * dialog.show(values); * </code> * @see #setValues * @param {Object} values Object indexed by names of input elements */ Xinha.Dialog.prototype.show = function(values) { var rootElem = this.rootElem; var rootElemStyle = rootElem.style; var modal = this.modal; var scrollPos = this.editor.scrollPos(); this.scrollPos = scrollPos; var dialog = this; //dialog.main.style.height = ''; if ( this.attached ) { this.editor.showPanel(rootElem); } // We need to preserve the selection // if this is called before some editor has been activated, it activates the editor if (Xinha._someEditorHasBeenActivated) { this._lastRange = this.editor.saveSelection(); if (Xinha.is_ie && !modal) { dialog.saveSelection = function() { dialog._lastRange = dialog.editor.saveSelection();}; Xinha._addEvent(this.editor._doc,'mouseup', dialog.saveSelection); } } if ( modal ) { this.editor.deactivateEditor(); this.editor.suspendUpdateToolbar = true; this.editor.currentModal = dialog; } // unfortunately we have to hide the editor (iframe/caret bug) if (Xinha.is_ff2 && modal) { this._restoreTo = [this.editor._textArea.style.display, this.editor._iframe.style.visibility, this.editor.hidePanels()]; this.editor._textArea.style.display = 'none'; this.editor._iframe.style.visibility = 'hidden'; } if ( !this.attached ) { if (modal) { this.showBackground(); this.posBackground({ top: 0, left: 0 }); this.resizeBackground(Xinha.Dialog.calcFullBgSize()); } else { this.background.style.display = ''; } //this.onResizeWin = function () {dialog.sizeBackground()}; //Xinha._addEvent(window, 'resize', this.onResizeWin ); //rootElemStyle.display = ''; Xinha.Dialog.fadeIn(this.rootElem, 100,function() { //this is primarily to work around a bug in IE where absolutely positioned elements have a frame that renders above all #1268 //but could also be seen as a feature ;) if (modal) { var input = dialog.rootElem.getElementsByTagName('input'); for (var i=0;i<input.length;i++) { if (input[i].type == 'text') { try { input[i].focus(); break; } catch (e) {} } } } }); var dialogHeight = rootElem.offsetHeight; var dialogWidth = rootElem.offsetWidth; var viewport = Xinha.viewportSize(); var viewportHeight = viewport.y; var viewportWidth = viewport.x; if (dialogHeight > viewportHeight) { rootElemStyle.height = viewportHeight + "px"; if (rootElem.scrollHeight > dialogHeight) { dialog.main.style.overflowY = "auto"; } } if(this.size.top && this.size.left) { rootElemStyle.top = parseInt(this.size.top,10) + 'px'; rootElemStyle.left = parseInt(this.size.left,10) + 'px'; } else if (this.editor.btnClickEvent && !this.centered) { var btnClickEvent = this.editor.btnClickEvent; if (rootElemStyle.position == 'absolute') { rootElemStyle.top = btnClickEvent.clientY + this.scrollPos.y +'px'; } else { rootElemStyle.top = btnClickEvent.clientY +'px'; } if (dialogHeight + rootElem.offsetTop > viewportHeight) { rootElemStyle.top = (rootElemStyle.position == 'absolute' ? this.scrollPos.y : 0 ) + "px" ; } if (rootElemStyle.position == 'absolute') { rootElemStyle.left = btnClickEvent.clientX + this.scrollPos.x +'px'; } else { rootElemStyle.left = btnClickEvent.clientX +'px'; } if (dialogWidth + rootElem.offsetLeft > viewportWidth) { rootElemStyle.left = btnClickEvent.clientX - dialogWidth + 'px'; if (rootElem.offsetLeft < 0) { rootElemStyle.left = 0; } } this.editor.btnClickEvent = null; } else { var top = ( viewportHeight - dialogHeight) / 2; var left = ( viewportWidth - dialogWidth) / 2; rootElemStyle.top = ((top > 0) ? top : 0) +'px'; rootElemStyle.left = ((left > 0) ? left : 0)+'px'; } } this.width = dialogWidth; this.height = dialogHeight; if (!modal) { this.resizeBackground({width: dialogWidth + 'px', height: dialogHeight + 'px' }); this.posBackground({top: rootElemStyle.top, left: rootElemStyle.left}); } if(typeof values != 'undefined') { this.setValues(values); } this.dialogShown = true; }; /** Hides the dialog and returns an object with the valuse of form elements * @see #getValues * @type Object */ Xinha.Dialog.prototype.hide = function() { if ( this.attached ) { this.editor.hidePanel(this.rootElem); } else { //this.rootElem.style.display = 'none'; Xinha.Dialog.fadeOut(this.rootElem); this.hideBackground(); var dialog = this; if (Xinha.is_ff2 && this.modal) { this.editor._textArea.style.display = this._restoreTo[0]; this.editor._iframe.style.visibility = this._restoreTo[1]; this.editor.showPanels(this._restoreTo[2]); } if (!this.editor._isFullScreen && this.modal) { window.scroll(this.scrollPos.x, this.scrollPos.y); } if (Xinha.is_ie && !this.modal) { Xinha._removeEvent(this.editor._doc,'mouseup', dialog.saveSelection); } if (this.modal) { this.editor.suspendUpdateToolbar = false; this.editor.currentModal = null; this.editor.activateEditor(); } } if (this.modal) { this.editor.restoreSelection(this._lastRange); } this.dialogShown = false; this.editor.updateToolbar(); this.editor.focusEditor(); return this.getValues(); }; /** Shows/hides the dialog * */ Xinha.Dialog.prototype.toggle = function() { if(this.rootElem.style.display == 'none') { this.show(); } else { this.hide(); } }; /** Reduces the dialog to the size of the caption bar * */ Xinha.Dialog.prototype.collapse = function() { if(this.collapsed) { this.collapsed = false; this.show(); } else { this.main.style.height = 0; this.collapsed = true; } }; /** Equivalent to document.getElementById. You can't use document.getElementById because id's are dynamic to avoid id clashes between plugins * @type DomNode * @param {String} id */ Xinha.Dialog.prototype.getElementById = function(id) { if(!this.rootElem.parentNode) { this.document.body.appendChild(this.rootElem); } return this.document.getElementById(this.id[id] ? this.id[id] : id); }; /** Equivalent to document.getElementByName. You can't use document.getElementByName because names are dynamic to avoid name clashes between plugins * @type Array * @param {String} name */ Xinha.Dialog.prototype.getElementsByName = function(name) { if(!this.rootElem.parentNode) { this.document.body.appendChild(this.rootElem); } var els = this.document.getElementsByName(this.id[name] ? this.id[name] : name); return Xinha.collectionToArray(els); }; /** Return all elements in the dialog that have the given class * @type Array * @param {String} className */ Xinha.Dialog.prototype.getElementsByClassName = function(className) { return Xinha.getElementsByClassName(this.rootElem,className); }; /** Initiates dragging * @private * @param {Object} ev Mousedown event */ Xinha.Dialog.prototype.dragStart = function (ev) { if ( this.attached || this.dragging) { return; } if (!this.modal) { this.posBackground({top:0, left:0}); this.resizeBackground(Xinha.Dialog.calcFullBgSize()); this.editor.suspendUpdateToolbar = true; } ev = Xinha.getEvent(ev); var dialog = this; dialog.dragging = true; dialog.scrollPos = dialog.editor.scrollPos(); var st = dialog.rootElem.style; dialog.xOffs = ev.offsetX || ev.layerX; //first value for IE/Opera/Safari, second value for Gecko (or should I say "netscape";)) dialog.yOffs = ev.offsetY || ev.layerY; dialog.mouseMove = function(ev) { dialog.dragIt(ev); }; Xinha._addEvent(document,"mousemove", dialog.mouseMove ); if (Xinha.is_ie) { Xinha._addEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove); } dialog.mouseUp = function (ev) { dialog.dragEnd(ev); }; Xinha._addEvent(document,"mouseup", dialog.mouseUp); if (Xinha.is_ie) { Xinha._addEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); } }; /** Sets the position while dragging * @private * @param {Object} ev Mousemove event */ Xinha.Dialog.prototype.dragIt = function(ev) { var dialog = this; if (!dialog.dragging) { return false; } var posY, posX, newPos; if (dialog.rootElem.style.position == 'absolute') { posY = (ev.clientY + this.scrollPos.y) - dialog.yOffs + "px"; posX = (ev.clientX + this.scrollPos.x) - dialog.xOffs + "px"; newPos = {top: posY,left: posX}; } else if (dialog.rootElem.style.position == 'fixed') { posY = ev.clientY - dialog.yOffs + "px"; posX = ev.clientX - dialog.xOffs + "px"; newPos = {top: posY,left: posX}; } dialog.posDialog(newPos); }; /** Ends dragging * @private * @param {Object} ev Mouseup event */ Xinha.Dialog.prototype.dragEnd = function(ev) { var dialog = this; if (!this.modal) { this.editor.suspendUpdateToolbar = false; } if (!dialog.dragging) { return false; } dialog.dragging = false; Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); if (Xinha.is_ie) { Xinha._removeEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove); } Xinha._removeEvent(document, "mouseup", dialog.mouseUp); if (Xinha.is_ie) { Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); } var rootElemStyle = dialog.rootElem.style; dialog.size.top = rootElemStyle.top; dialog.size.left = rootElemStyle.left; if (!this.modal) { this.sizeBgToDialog(); } }; /** Initiates resizing * @private * @param {Object} ev Mousedown event */ Xinha.Dialog.prototype.resizeStart = function (ev) { var dialog = this; if (dialog.resizing) { return; } dialog.resizing = true; if (!this.modal) { this.editor.suspendUpdateToolbar = true; this.posBackground({top:0, left:0}); this.resizeBackground(Xinha.Dialog.calcFullBgSize()); } dialog.scrollPos = dialog.editor.scrollPos(); var st = dialog.rootElem.style; st.minHeight = ''; st.overflow = 'hidden'; dialog.xOffs = parseInt(st.left,10); dialog.yOffs = parseInt(st.top,10); dialog.mouseMove = function(ev) { dialog.resizeIt(ev); }; Xinha._addEvent(document,"mousemove", dialog.mouseMove ); if (Xinha.is_ie) { Xinha._addEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove); } dialog.mouseUp = function (ev) { dialog.resizeEnd(ev); }; Xinha._addEvent(document,"mouseup", dialog.mouseUp); if (Xinha.is_ie) { Xinha._addEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); } }; /** Sets the size while resiziong * @private * @param {Object} ev Mousemove event */ Xinha.Dialog.prototype.resizeIt = function(ev) { var dialog = this; if (!dialog.resizing) { return false; } var posY, posX; if (dialog.rootElem.style.position == 'absolute') { posY = ev.clientY + dialog.scrollPos.y; posX = ev.clientX + dialog.scrollPos.x; } else { posY = ev.clientY; posX = ev.clientX; } posX -= dialog.xOffs; posY -= dialog.yOffs; var newSize = {}; newSize.width = (( posX > 10) ? posX : 10) + 8 + "px"; newSize.height = (( posY > 10) ? posY : 10) + "px"; dialog.sizeDialog(newSize); dialog.width = dialog.rootElem.offsetWidth; dialog.height = dialog.rootElem.offsetHeight; dialog.onresize(); }; /** Ends resizing * @private * @param {Object} ev Mouseup event */ Xinha.Dialog.prototype.resizeEnd = function(ev) { var dialog = this; dialog.resizing = false; if (!this.modal) { this.editor.suspendUpdateToolbar = false; } Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); if (Xinha.is_ie) { Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); } Xinha._removeEvent(document, "mouseup", dialog.mouseUp); if (Xinha.is_ie) { Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); } dialog.size.width = dialog.rootElem.offsetWidth; dialog.size.height = dialog.rootElem.offsetHeight; if (!this.modal) { this.sizeBgToDialog(); } }; /** Attaches a modeless dialog to a panel on the given side * Triggers a notifyOf panel_change event * @param {String} side one of 'left', 'right', 'top', 'bottom' */ Xinha.Dialog.prototype.attachToPanel = function(side) { var dialog = this; var rootElem = this.rootElem; var editor = this.editor; this.attached = true; this.rootElem.side = side; this.captionBar.ondblclick = function(ev) { dialog.detachFromPanel(Xinha.getEvent(ev)); }; rootElem.style.position = "static"; rootElem.parentNode.removeChild(rootElem); this.background.style.display = 'none'; this.captionBar.style.paddingLeft = "3px"; this.resizer.style.display = 'none'; if (this.closable) { this.closer.style.display = 'none'; } this.icon.style.display = 'none'; if ( side == 'left' || side == 'right' ) { rootElem.style.width = editor.config.panel_dimensions[side]; } else { rootElem.style.width = ''; } Xinha.addClasses(rootElem, 'panel'); editor._panels[side].panels.push(rootElem); editor._panels[side].div.appendChild(rootElem); editor.notifyOf('panel_change', {'action':'add','panel':rootElem}); }; /** Removes a panel dialog from its panel and makes it float * */ Xinha.Dialog.prototype.detachFromPanel = function() { var dialog = this; var rootElem = dialog.rootElem; var rootElemStyle = rootElem.style; var editor = dialog.editor; dialog.attached = false; var pos = Xinha.getElementTopLeft(rootElem); rootElemStyle.position = "absolute"; rootElemStyle.top = pos.top + "px"; rootElemStyle.left = pos.left + "px"; //dialog.captionBar.style.paddingLeft = "22px"; dialog.resizer.style.display = ''; if (dialog.closable) { dialog.closer.style.display = ''; } dialog.icon.style.display = ''; if (dialog.size.width) { rootElem.style.width = dialog.size.width + 'px'; } Xinha.removeClasses(rootElem, 'panel'); editor.removePanel(rootElem); document.body.appendChild(rootElem); dialog.captionBar.ondblclick = function() { dialog.attachToPanel(rootElem.side); }; this.background.style.display = ''; this.sizeBgToDialog(); }; /** * @private * @type Object Object with width, height strings incl. "px" for CSS */ Xinha.Dialog.calcFullBgSize = function() { var page = Xinha.pageSize(); var viewport = Xinha.viewportSize(); return {width:(page.x > viewport.x ? page.x : viewport.x ) + "px",height:(page.x > viewport.y ? page.y : viewport.y ) + "px"}; }; /** Sizes the background to the size of the dialog * @private */ Xinha.Dialog.prototype.sizeBgToDialog = function() { var rootElemStyle = this.rootElem.style; var bgStyle = this.background.style; bgStyle.top = rootElemStyle.top; bgStyle.left = rootElemStyle.left; bgStyle.width = rootElemStyle.width; bgStyle.height = rootElemStyle.height; }; /** Hides the background * @private */ Xinha.Dialog.prototype.hideBackground = function() { //this.background.style.display = 'none'; Xinha.Dialog.fadeOut(this.background); }; /** Shows the background * @private */ Xinha.Dialog.prototype.showBackground = function() { //this.background.style.display = ''; Xinha.Dialog.fadeIn(this.background,70); }; /** Positions the background * @private * @param {Object} pos Object with top, left strings incl. "px" for CSS */ Xinha.Dialog.prototype.posBackground = function(pos) { if (this.background.style.display != 'none') { this.background.style.top = pos.top; this.background.style.left = pos.left; } }; /** Resizes the background * @private * @param {Object} size Object with width, height strings incl. "px" for CSS */ Xinha.Dialog.prototype.resizeBackground = function(size) { if (this.background.style.display != 'none') { this.background.style.width = size.width; this.background.style.height = size.height; } }; /** Positions the dialog * @param {Object} pos Object with top, left strings incl. "px" for CSS */ Xinha.Dialog.prototype.posDialog = function(pos) { var st = this.rootElem.style; st.left = pos.left; st.top = pos.top; }; /** Resizes the dialog * * @param {Object} size Object with width, height strings incl. "px" for CSS */ Xinha.Dialog.prototype.sizeDialog = function(size) { var st = this.rootElem.style; st.height = size.height; st.width = size.width; var width = parseInt(size.width, 10); var height = parseInt(size.height,10) - this.captionBar.offsetHeight; this.main.style.height = (height > 20) ? height : 20 + "px"; this.main.style.width = (width > 10) ? width : 10 + 'px'; }; /** Sets the values like Xinha.Dialog.prototype.show(values) * @see #show * @param {Object} values */ Xinha.Dialog.prototype.setValues = function(values) { for(var i in values) { if (typeof i == 'string') { var elems = this.getElementsByName(i); if (!elems) { continue; } for(var x = 0; x < elems.length; x++) { var e = elems[x]; switch(e.tagName.toLowerCase()) { case 'select' : for(var j = 0; j < e.options.length; j++) { if(typeof values[i] == 'object') { for(var k = 0; k < values[i].length; k++) { if(values[i][k] == e.options[j].value) { e.options[j].selected = true; } } } else if(values[i] == e.options[j].value) { e.options[j].selected = true; } } break; case 'textarea': case 'input' : switch(e.getAttribute('type')) { case 'radio' : if(e.value == values[i]) { e.checked = true; } break; case 'checkbox': if(typeof values[i] == 'object') { for(j in values[i]) { if(values[i][j] == e.value) { e.checked = true; } } } else { if(values[i] == e.value) { e.checked = true; } } break; default: e.value = values[i]; break; } } } } } }; /** Retrieves the values like Xinha.Dialog.prototype.hide() * @see #hide * @type Object values */ Xinha.Dialog.prototype.getValues = function() { var values = [ ]; var inputs = Xinha.collectionToArray(this.rootElem.getElementsByTagName('input')) .append(Xinha.collectionToArray(this.rootElem.getElementsByTagName('textarea'))) .append(Xinha.collectionToArray(this.rootElem.getElementsByTagName('select'))); for(var x = 0; x < inputs.length; x++) { var i = inputs[x]; if (!(i.name && this.r_id[i.name])) { continue; } if(typeof values[this.r_id[i.name]] == 'undefined') { values[this.r_id[i.name]] = null; } var v = values[this.r_id[i.name]]; switch(i.tagName.toLowerCase()) { case 'select': if(i.multiple) { if(!v.push) { if(v !== null) { v = [v]; } else { v = []; } } for(var j = 0; j < i.options.length; j++) { if(i.options[j].selected) { v.push(i.options[j].value); } } } else { if(i.selectedIndex >= 0) { v = i.options[i.selectedIndex]; } } break; /* case 'textarea': case 'input' : */ default: switch(i.type.toLowerCase()) { case 'radio': if(i.checked) { v = i.value; } break; case 'checkbox': if(v === null) { if(this.getElementsByName(this.r_id[i.name]).length > 1) { v = []; } } if(i.checked) { if(v !== null && typeof v == 'object' && v.push) { v.push(i.value); } else { v = i.value; } } break; default: v = i.value; break; } } values[this.r_id[i.name]] = v; } return values; }; /** Sets the localizer to use for the dialog * @param function|string Either a function which takes a string as a parameter and returns * a localized string, or the name of a contact to pass to the standard Xinha localizer * the "context" usually means the name of a plugin. */ Xinha.Dialog.prototype.setLocalizer = function(localizer) { var dialog = this; if(typeof localizer == 'function') { dialog._lc = localizer; } else if(localizer) { this._lc = function(string) { return Xinha._lc(string,localizer); }; } else { this._lc = function(string) { return string; }; } } /** Localizes strings in the dialog. * @private * @param {String} html The HTML to translate * @param {String} localizer Context for translation, usually plugin's name (optional if setLocalizer() has been used) */ Xinha.Dialog.prototype.translateHtml = function(html,localizer) { var dialog = this; if(localizer) this.setLocalizer(localizer); // looking for strings of the form name='[foo]' or id="[bar]" html = html.replace(/((?:name)|(?:id))=(['"])\[([a-z0-9_]+)\]\2/ig, function(fullString, type, quote, id) { return type + "=" + quote + dialog.createId(id) + quote; } ).replace(/<l10n>(.*?)<\/l10n>/ig, function(fullString,translate) { return dialog._lc(translate) ; } ).replace(/\="_\((.*?)\)"/g, function(fullString, translate) { return '="' + dialog._lc(translate) + '"'; } ); return html; }; /** * Fixup links in the elements to allow linking to Xinha resources * @private */ Xinha.Dialog.prototype.fixupDOM = function(root,plugin) { var dialog = this; if(typeof plugin != 'string') { plugin = 'GenericPlugin'; } var linkReplace = function(fullString, resource) { switch(resource) { case "editor": return _editor_url; case "plugin": return Xinha.getPluginDir(plugin); case "images": return dialog.editor.imgURL('images'); }; }; var images = Xinha.collectionToArray(root.getElementsByTagName('img')); for (var index=0; index<images.length; ++index) { var image = images[index]; var reference = image.getAttribute('src'); if (reference) { var fixedReference = reference.replace(/^\[(editor|plugin|images)\]/, linkReplace); if (fixedReference != reference) { image.setAttribute('src', fixedReference); } } } var links = Xinha.collectionToArray(root.getElementsByTagName('a')); for (var index=0; index<links.length; ++index) { var link = links[index]; var reference = link.getAttribute('href'); if (reference) { var fixedReference = reference.replace(/^\[(editor|plugin|images)\]/, linkReplace); if (fixedReference != reference) { link.setAttribute('href', fixedReference); } } } }; /** Use this function when adding an element with a new ID/name to a * dialog after it has already been created. This function ensures * that the dialog has the id/name stored in its reverse-lookup table * (which is required for form values to be properly returned by * Xinha.Dialog.hide). * * @param {id} the id (or name) to add * * Returns the internal ID to which the passed in ID maps * * TODO: createId is a really awful name, but I can't think of anything better... */ Xinha.Dialog.prototype.createId = function(id) { var dialog = this; if (typeof dialog.id[id] == 'undefined') { dialog.id[id] = Xinha.uniq('Dialog'); dialog.r_id[dialog.id[id]] = id; } return dialog.id[id]; }; /** When several modeless dialogs are shown, one can be brought to front with this function (as happens on mouseclick) * * @param {XinhaDialog} dialog The dialog to activate */ Xinha.Dialog.activateModeless = function(dialog) { if (Xinha.Dialog.activeModeless == dialog || dialog.attached ) { return; } if (Xinha.Dialog.activeModeless ) { Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex, 10) -10; } Xinha.Dialog.activeModeless = dialog; Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex, 10) + 10; }; /** Set opacity cross browser * * @param {DomNode} el The element to set the opacity * @param {Object} value opacity value (percent) */ Xinha.Dialog.setOpacity = function(el,value) { if (typeof el.style.filter != 'undefined') { el.style.filter = (value < 100) ? 'alpha(opacity='+value+')' : ''; } else { el.style.opacity = value/100; } }; /** Fade in an element * * @param {DomNode} el The element to fade * @param {Number} delay Time for one step in ms * @param {Number} endOpacity stop when this value is reached (percent) * @param {Number} step Fade this much per step (percent) */ Xinha.Dialog.fadeIn = function(el,endOpacity,callback, delay,step) { delay = delay || 1; step = step || 25; endOpacity = endOpacity || 100; el.op = el.op || 0; var op = el.op; if (el.style.display == 'none') { Xinha.Dialog.setOpacity(el,0); el.style.display = ''; } if (op < endOpacity) { el.op += step; Xinha.Dialog.setOpacity(el,op); el.timeOut = setTimeout(function(){Xinha.Dialog.fadeIn(el, endOpacity, callback, delay, step);},delay); } else { Xinha.Dialog.setOpacity(el,endOpacity); el.op = endOpacity; el.timeOut = null; if (typeof callback == 'function') { callback.call(); } } }; /** Fade out an element * * @param {DomNode} el The element to fade * @param {Number} delay Time for one step in ms * @param {Number} step Fade this much per step (percent) */ Xinha.Dialog.fadeOut = function(el,delay,step) { delay = delay || 1; step = step || 30; if (typeof el.op == 'undefined') { el.op = 100; } var op = el.op; if (op >= 0) { el.op -= step; Xinha.Dialog.setOpacity(el,op); el.timeOut = setTimeout(function(){Xinha.Dialog.fadeOut(el,delay,step);},delay); } else { Xinha.Dialog.setOpacity(el,0); el.style.display = 'none'; el.op = 0; el.timeOut = null; } };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Dialogs/XinhaDialog.js
JavaScript
art
41,484
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- $HeadURL: http://svn.xinha.webfactional.com/trunk/modules/Dialogs/inline-dialog.js $ -- $LastChangedDate: 2007-01-24 03:26:04 +1300 (Wed, 24 Jan 2007) $ -- $LastChangedRevision: 694 $ -- $LastChangedBy: gogo $ --------------------------------------------------------------------------*/ /** The DivDialog is used as a semi-independant means of using a Plugin outside of * Xinha, it does not depend on having a Xinha editor available - not that of of course * Plugins themselves may (and very likely do) require an editor. * * @param Div into which the dialog will draw itself. * * @param HTML for the dialog, with the special subtitutions... * id="[someidhere]" will assign a unique id to the element in question * and this can be retrieved with yourDialog.getElementById('someidhere') * _(Some Text Here) will localize the text, this is used for within attributes * <l10n>Some Text Here</l10n> will localize the text, this is used outside attributes * * @param A function which can take a native (english) string and return a localized version, * OR; A "context" to be used with the standard Xinha._lc() method, * OR; Null - no localization will happen, only native strings will be used. * */ Xinha.DetachedDialog = function( html, localizer, size, options) { var fakeeditor = { 'config': new Xinha.Config(), 'scrollPos': Xinha.prototype.scrollPos, '_someEditorHasBeenActivated': false, 'saveSelection': function() { }, 'deactivateEditor' : function() { }, '_textArea': document.createElement('textarea'), '_iframe' : document.createElement('div'), '_doc' : document, 'hidePanels': function() { }, 'showPanels': function() { }, '_isFullScreen': false, // maybe not ? 'activateEditor': function() { }, 'restoreSelection': function() { }, 'updateToolbar': function() { }, 'focusEditor': function() { } }; Xinha.Dialog.initialZ = 100; this.attached = false; Xinha.DetachedDialog.parentConstructor.call(this, fakeeditor, html, localizer, size, options); } Xinha.extend(Xinha.DetachedDialog, Xinha.Dialog); Xinha.DetachedDialog.prototype.attachToPanel = function() { return false; } Xinha.DetachedDialog.prototype.detachFromToPanel = function() { return false; }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Dialogs/DetachedDialog.js
JavaScript
art
2,900
Xinha.PanelDialog = function(editor, side, html, localizer) { this.id = { }; this.r_id = { }; // reverse lookup id this.editor = editor; this.document = document; this.rootElem = editor.addPanel(side); var dialog = this; if(typeof localizer == 'function') { this._lc = localizer; } else if(localizer) { this._lc = function(string) { return Xinha._lc(string,localizer); }; } else { this._lc = function(string) { return string; }; } html = html.replace(/\[([a-z0-9_]+)\]/ig, function(fullString, id) { if(typeof dialog.id[id] == 'undefined') { dialog.id[id] = Xinha.uniq('Dialog'); dialog.r_id[dialog.id[id]] = id; } return dialog.id[id]; } ).replace(/<l10n>(.*?)<\/l10n>/ig, function(fullString,translate) { return dialog._lc(translate) ; } ).replace(/="_\((.*?)\)"/g, function(fullString, translate) { return '="' + dialog._lc(translate) + '"'; } ); this.rootElem.innerHTML = html; }; Xinha.PanelDialog.prototype.show = function(values) { this.setValues(values); this.editor.showPanel(this.rootElem); }; Xinha.PanelDialog.prototype.hide = function() { this.editor.hidePanel(this.rootElem); return this.getValues(); }; Xinha.PanelDialog.prototype.onresize = Xinha.Dialog.prototype.onresize; Xinha.PanelDialog.prototype.toggle = Xinha.Dialog.prototype.toggle; Xinha.PanelDialog.prototype.setValues = Xinha.Dialog.prototype.setValues; Xinha.PanelDialog.prototype.getValues = Xinha.Dialog.prototype.getValues; Xinha.PanelDialog.prototype.getElementById = Xinha.Dialog.prototype.getElementById; Xinha.PanelDialog.prototype.getElementsByName = Xinha.Dialog.prototype.getElementsByName;
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Dialogs/panel-dialog.js
JavaScript
art
2,131
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- $HeadURL: http://svn.xinha.webfactional.com/trunk/modules/Dialogs/inline-dialog.js $ -- $LastChangedDate: 2007-01-24 03:26:04 +1300 (Wed, 24 Jan 2007) $ -- $LastChangedRevision: 694 $ -- $LastChangedBy: gogo $ --------------------------------------------------------------------------*/ /** The DivDialog is used as a semi-independant means of using a Plugin outside of * Xinha, it does not depend on having a Xinha editor available - not that of of course * Plugins themselves may (and very likely do) require an editor. * * @param Div into which the dialog will draw itself. * * @param HTML for the dialog, with the special subtitutions... * id="[someidhere]" will assign a unique id to the element in question * and this can be retrieved with yourDialog.getElementById('someidhere') * _(Some Text Here) will localize the text, this is used for within attributes * <l10n>Some Text Here</l10n> will localize the text, this is used outside attributes * * @param A function which can take a native (english) string and return a localized version, * OR; A "context" to be used with the standard Xinha._lc() method, * OR; Null - no localization will happen, only native strings will be used. * */ Xinha.DivDialog = function(rootElem, html, localizer) { this.id = { }; this.r_id = { }; // reverse lookup id this.document = document; this.rootElem = rootElem; this.rootElem.className += ' dialog'; this.rootElem.style.display = 'none'; this.width = this.rootElem.offsetWidth + 'px'; this.height = this.rootElem.offsetHeight + 'px'; this.setLocalizer(localizer); this.rootElem.innerHTML = this.translateHtml(html); } Xinha.extend(Xinha.DivDialog, Xinha.Dialog); Xinha.DivDialog.prototype.show = function(values) { if(typeof values != 'undefined') { this.setValues(values); } this.rootElem.style.display = ''; }; Xinha.DivDialog.prototype.hide = function() { this.rootElem.style.display = 'none'; return this.getValues(); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Dialogs/div-dialog.js
JavaScript
art
2,631
// (c) dynarch.com 2003-2004 // Distributed under the same terms as HTMLArea itself. function PopupWin(editor, title, handler, initFunction) { this.editor = editor; this.handler = handler; var dlg = window.open("", "__ha_dialog", "toolbar=no,menubar=no,personalbar=no,width=600,height=600,left=20,top=40,scrollbars=no,resizable=yes"); this.window = dlg; var doc = dlg.document; this.doc = doc; var self = this; var base = document.baseURI || document.URL; if ( base && base.match(/(.*)\/([^\/]+)/) ) { base = RegExp.$1 + "/"; } // @fixme: why using a regex here and not a simple string test ? if ( typeof _editor_url != "undefined" && ! ( /^\//.test(_editor_url) ) && ! ( /http:\/\//.test(_editor_url) ) ) { // _editor_url doesn't start with '/' which means it's relative // FIXME: there's a problem here, it could be http:// which // doesn't start with slash but it's not relative either. base += _editor_url; } else { base = _editor_url; } // @fixme: why using a regex here and not a simple string test ? if ( ! ( /\/$/.test(base) ) ) { // base does not end in slash, add it now base += '/'; } this.baseURL = base; doc.open(); var html = "<html><head><title>" + title + "</title>\n"; // html += "<base href='" + base + "htmlarea.js' />\n"; html += '<style type="text/css">@import url(' + _editor_url + 'Xinha.css);</style>\n'; if ( _editor_skin != "" ) { html += '<style type="text/css">@import url(' + _editor_url + 'skins/' + _editor_skin + '/skin.css);</style>\n'; } html += "</head>\n"; html += '<body class="dialog popupwin" id="--HA-body"></body></html>'; doc.write(html); doc.close(); // sometimes I Hate Mozilla... ;-( function init2() { var body = doc.body; if ( !body ) { setTimeout(init2, 25); return false; } dlg.title = title; doc.documentElement.style.padding = "0px"; doc.documentElement.style.margin = "0px"; var content = doc.createElement("div"); content.className = "content"; self.content = content; body.appendChild(content); self.element = body; initFunction(self); dlg.focus(); } init2(); } PopupWin.prototype.callHandler = function() { var tags = ["input", "textarea", "select"]; var params = {}; for ( var ti = tags.length; --ti >= 0; ) { var tag = tags[ti]; var els = this.content.getElementsByTagName(tag); for ( var j = 0; j < els.length; ++j ) { var el = els[j]; var val = el.value; if ( el.tagName.toLowerCase() == "input" ) { if ( el.type == "checkbox" ) { val = el.checked; } } params[el.name] = val; } } this.handler(this, params); return false; }; PopupWin.prototype.close = function() { this.window.close(); }; PopupWin.prototype.addButtons = function() { // @fixme: isn't self a predefined variable used to access self frame in most browsers ? // if yes, then we break it here var self = this; var div = this.doc.createElement("div"); this.content.appendChild(div); div.id = "buttons"; div.className = "buttons"; for ( var i = 0; i < arguments.length; ++i ) { var btn = arguments[i]; var button = this.doc.createElement("button"); div.appendChild(button); button.innerHTML = Xinha._lc(btn, 'Xinha'); switch (btn.toLowerCase()) { case "ok": Xinha.addDom0Event(button, 'click', function() { self.callHandler(); self.close(); return false; } ); break; case "cancel": Xinha.addDom0Event(button, 'click', function() { self.close(); return false; } ); break; } } }; PopupWin.prototype.showAtElement = function() { var self = this; // Mozilla needs some time to realize what's goin' on.. setTimeout(function() { var w = self.content.offsetWidth + 4; var h = self.content.offsetHeight + 4; // size to content -- that's fuckin' buggy in all fuckin' browsers!!! // so that we set a larger size for the dialog window and then center // the element inside... phuck! // center... var el = self.content; var s = el.style; // s.width = el.offsetWidth + "px"; // s.height = el.offsetHeight + "px"; s.position = "absolute"; s.left = parseInt((w - el.offsetWidth) / 2, 10) + "px"; s.top = parseInt((h - el.offsetHeight) / 2, 10) + "px"; if (Xinha.is_gecko) { self.window.innerWidth = w; self.window.innerHeight = h; } else { self.window.resizeTo(w + 8, h + 70); } }, 25); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Dialogs/popupwin.js
JavaScript
art
4,788
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the implementation of the standard popup dialog -- -- Though "Dialog" looks like an object, it isn't really an object. Instead -- it's just namespace for protecting global symbols. -- -- -- $HeadURL: http://svn.xinha.org/trunk/modules/Dialogs/dialog.js $ -- $LastChangedDate: 2008-10-13 06:42:42 +1300 (Mon, 13 Oct 2008) $ -- $LastChangedRevision: 1084 $ -- $LastChangedBy: ray $ --------------------------------------------------------------------------*/ function Dialog(url, action, init) { if (typeof init == "undefined") { init = window; // pass this window object by default } if (typeof window.showModalDialog == 'function' && !Xinha.is_webkit) // webkit easily looses the selection with window.showModalDialog { Dialog._return = function(retVal) { if (typeof action == 'function') action (retVal); } var r = window.showModalDialog(url, init, "dialogheight=300;dialogwidth=400;resizable=yes"); } else { Dialog._geckoOpenModal(url, action, init); } } Dialog._parentEvent = function(ev) { setTimeout( function() { if (Dialog._modal && !Dialog._modal.closed) { Dialog._modal.focus() } }, 50); try { if (Dialog._modal && !Dialog._modal.closed) { Xinha._stopEvent(ev); } } catch (e) { //after closing the popup in IE the events are not released and trying to access Dialog._modal.closed causes an error } }; // should be a function, the return handler of the currently opened dialog. Dialog._return = null; // constant, the currently opened dialog Dialog._modal = null; // the dialog will read it's args from this variable Dialog._arguments = null; Dialog._selection = null; Dialog._geckoOpenModal = function(url, action, init) { var dlg = window.open(url, "hadialog", "toolbar=no,menubar=no,personalbar=no,width=10,height=10," + "scrollbars=no,resizable=yes,modal=yes,dependable=yes"); Dialog._modal = dlg; Dialog._arguments = init; // capture some window's events function capwin(w) { Xinha._addEvent(w, "click", Dialog._parentEvent); Xinha._addEvent(w, "mousedown", Dialog._parentEvent); Xinha._addEvent(w, "focus", Dialog._parentEvent); } // release the captured events function relwin(w) { Xinha._removeEvent(w, "click", Dialog._parentEvent); Xinha._removeEvent(w, "mousedown", Dialog._parentEvent); Xinha._removeEvent(w, "focus", Dialog._parentEvent); } capwin(window); // capture other frames, note the exception trapping, this is because // we are not permitted to add events to frames outside of the current // window's domain. for (var i = 0; i < window.frames.length; i++) {try { capwin(window.frames[i]); } catch(e) { } }; // make up a function to be called when the Dialog ends. Dialog._return = function (val) { if (val && action) { action(val); } relwin(window); // capture other frames for (var i = 0; i < window.frames.length; i++) { try { relwin(window.frames[i]); } catch(e) { } }; Dialog._modal = null; }; Dialog._modal.focus(); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/Dialogs/dialog.js
JavaScript
art
3,585
// I18N constants // // LANG: "pt_br", ENCODING: UTF-8 // Portuguese Brazilian Translation // // Author: Marcio Barbosa, <marcio@mpg.com.br> // MSN: tomarshall@msn.com - ICQ: 69419933 // Site: http://www.mpg.com.br // // Last revision: 06 september 2007 // Please don´t remove this information // If you modify any source, please insert a comment with your name and e-mail // // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt). { "Click a color...": "Selecione uma côr...", "Close": "Fechar", "Color: ": "Côr:", "Sample": "Exemplo", "Web Safe: ": "Web Segura:" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/ColorPicker/lang/pt_br.js
JavaScript
art
642
/** * Gogo Internet Services Color Picker Javascript Widget * colorPicker for short. * * @author James Sleeman <james@gogo.co.nz> * @date June, 2005 * * The colorPicker class provides access to a color map for selecting * colors which will be passed back to a callback (usually such a callback would * write the RGB hex value returned into a field, but that's up to you). * * The color map presented is a standard rectangular pallate with 0->360 degrees of * hue on the Y axis and 0->100% saturation on the X axis, the value (brightness) is * selectable as a vertical column of grey values. Also present is a one row of * white->grey->black for easy selection of these colors. * * A checkbox is presented, which when checked will force the palatte into "web safe" * mode, only colours in the "web safe palatte" of 216 colors will be shown, the palatte * is adjusted so that the normal blend of colours are "rounded" to the nearest web safe * one. It should be noted that "web safe" colours really are a thing of the past, * not only can pretty much every body display several million colours, but it's actually * been found that of those 216 web safe colours only 20 to 30 are actually going to be * displayed equally on the majority of monitors, and those are mostly yellows! * * =Usage Example= * {{{ * <!-- Here is the field --> <!-- And we will use this button to open the picker" * <input type="text" id="myField" /> <input type="button" value="..." id="myButton" /> * <script> * // now when the window loads link everything up * window.onload = function() * { * * var myField = document.getElementById('myField'); // Get our field * var myButton = document.getElementById('myButton'); // And the button * var myPicker = new colorPicker // Make a picker * ( * { * // Cellsize is the width and height of each colour cell * cellsize: '5px', * // Callback is the function to execute when we are done, * // this one puts the color value into the field * callback: function(color){myField.value=color}, * // Granularity defines the maximum number of colors per row/column * // more colors (high number) gives a smooth gradient of colors * // but it will take (much) longer to display, while a small number * // displays quickly, but doesn't show as many different colors. * // Experiement with it, 18 seems like a good number. * granularity: 18, * // Websafe specifies whether or not to include the Web Safe checkbox * websafe: false, * // Savecolors specifies the number of recently-selected colors to remember * savecolors: 20 * } * ); * * // And now hookup the button to open the picker, * // the function to do that is myPicker.open() * // it accepts two parameters, the "anchorage" and the element to anchor to, * // and an optional third parameter, an initial color code to show in * // the text box and sample. * // * // anchorage is made up of two of the keywords bottom,top,left and right * // left: the left edge of the picker will align to the left edge of the element * // or right: the right edgeof the picker aligns to the right edge of the element * // top: the picker will appear above the element * // or bottom: the picker will appear below the element * * myButton.onclick = * function() * { // anchorage , element to anchor to * myPicker.open('bottom,right', myButton, initcolor) * }; * } * </script> * }}} */ ColorPicker._pluginInfo = { name : "colorPicker", version : "$LastChangedRevision: 1237 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer: "James Sleeman", developer_url: "http://www.gogo.co.nz/", c_owner : "Gogo Internet Services", license : "htmlArea", sponsor : "Gogo Internet Services", sponsor_url : "http://www.gogo.co.nz/" }; function ColorPicker() { // dummy function for Xinha plugin api, note the different names } try { if (window.opener && window.opener.Xinha) { // this prevents that the Xinha.colorPicker object of the opening window is replaced by the one loaded in the popup var openerColorPicker = window.opener.Xinha.colorPicker; Xinha._addEvent(window,'unload', function() {Xinha.colorPicker = openerColorPicker;}); } } catch(e) {} //the actual function is below Xinha.colorPicker = function (params) { // if the savedColors is empty, try to read the savedColors from cookie if ( Xinha.colorPicker.savedColors.length === 0 ) { Xinha.colorPicker.loadColors(); } this.is_ie_6 = (Xinha.is_ie && Xinha.ie_version < 7); var picker = this; var enablepick = false; var enablevalue = false; var pickrow = 0; var pickcol = 0; this.callback = params.callback?params.callback:function(color){alert('You picked ' + color );}; this.websafe = params.websafe?params.websafe:false; this.savecolors = params.savecolors? params.savecolors: 20; this.cellsize = parseInt(params.cellsize?params.cellsize:'10px', 10); this.side = params.granularity?params.granularity:18; var valuecol = this.side + 1; var valuerow = this.side - 1; this.value = 1; this.saved_cells = null; this.table = document.createElement('table'); this.table.className = "dialog"; this.table.cellSpacing = this.table.cellPadding = 0; this.table.onmouseup = function() { enablepick = false; enablevalue = false; }; this.tbody = document.createElement('tbody'); this.table.appendChild(this.tbody); this.table.style.border = '1px solid WindowFrame'; this.table.style.zIndex = '1050'; // Add a title bar and close button var tr = document.createElement('tr'); var td = document.createElement('td'); td.colSpan = this.side; td.className= "title"; td.style.fontFamily = 'small-caption,caption,sans-serif'; td.style.fontSize = 'x-small'; td.unselectable = "on"; td.style.MozUserSelect = "none"; td.style.cursor = "default"; td.appendChild(document.createTextNode(Xinha._lc('Click a color...'))); td.style.borderBottom = '1px solid WindowFrame'; tr.appendChild(td); td = null; var td = document.createElement('td'); td.className= "title"; td.colSpan = 2; td.style.fontFamily = 'Tahoma,Verdana,sans-serif'; td.style.borderBottom = '1px solid WindowFrame'; td.style.paddingRight = '0'; tr.appendChild(td); var but = document.createElement('div'); but.title = Xinha._lc("Close"); but.className= 'buttonColor'; but.style.height = '11px'; but.style.width = '11px'; but.style.cursor = 'pointer'; but.onclick = function() { picker.close(); }; but.appendChild(document.createTextNode('\u00D7')); but.align = 'center'; but.style.verticalAlign = 'top'; but.style.position = 'relative'; but.style.cssFloat = 'right'; but.style.styleFloat = 'right'; but.style.padding = '0'; but.style.margin = '2px'; but.style.backgroundColor = 'transparent'; but.style.fontSize= '11px'; if ( !Xinha.is_ie) but.style.lineHeight= '9px'; // line-height:9px is better for centering the x, but IE cuts it off at the bottom :( but.style.letterSpacing= '0'; td.appendChild(but); this.tbody.appendChild(tr); but = tr = td = null; this.constrain_cb = document.createElement('input'); this.constrain_cb.type = 'checkbox'; this.chosenColor = document.createElement('input'); this.chosenColor.type = 'text'; this.chosenColor.maxLength = 7; this.chosenColor.style.width = '50px'; this.chosenColor.style.fontSize = '11px'; this.chosenColor.onchange = function() { if(/#[0-9a-f]{6,6}/i.test(this.value)) { picker.backSample.style.backgroundColor = this.value; picker.foreSample.style.color = this.value; } }; this.backSample = document.createElement('div'); this.backSample.appendChild(document.createTextNode('\u00A0')); this.backSample.style.fontWeight = 'bold'; this.backSample.style.fontFamily = 'small-caption,caption,sans-serif'; this.backSample.fontSize = 'x-small'; this.foreSample = document.createElement('div'); this.foreSample.appendChild(document.createTextNode(Xinha._lc('Sample'))); this.foreSample.style.fontWeight = 'bold'; this.foreSample.style.fontFamily = 'small-caption,caption,sans-serif'; this.foreSample.fontSize = 'x-small'; /** Convert a decimal number to a two byte hexadecimal representation. * Zero-pads if necessary. * * @param integer dec Integer from 0 -> 255 * @returns string 2 character hexadecimal (zero padded) */ function toHex(dec) { var h = dec.toString(16); if(h.length < 2) { h = '0' + h; } return h; } /** Convert a color object {red:x, green:x, blue:x} to an RGB hex triplet * @param object tuple {red:0->255, green:0->255, blue:0->255} * @returns string hex triplet (#rrggbb) */ function tupleToColor(tuple) { return '#' + toHex(tuple.red) + toHex(tuple.green) + toHex(tuple.blue); } /** Determine the nearest power of a number to another number * (eg nearest power of 4 to 5 => 4, of 4 to 7 => 8) * * @usedby rgbToWebsafe * @param number num number to round to nearest power of <power> * @param number power number to find the nearest power of * @returns number Nearest power of <power> to num. */ function nearestPowerOf(num,power) { return Math.round(Math.round(num / power) * power); } /** Concatenate the hex representation of dec to itself and return as an integer. * eg dec = 10 -> A -> AA -> 170 * * @usedby rgbToWebsafe * @param dec integer * @returns integer */ function doubleHexDec(dec) { return parseInt(dec.toString(16) + dec.toString(16), 16); } /** Convert a given RGB color to the nearest "Web-Safe" color. A websafe color only has the values * 00, 33, 66, 99, CC and FF for each of the red, green and blue components (thus 6 shades of each * in combination to produce 6 * 6 * 6 = 216 colors). * * @param color object {red:0->255, green:0->255, blue:0->255} * @returns object {red:51|102|153|204|255, green:51|102|153|204|255, blue:51|102|153|204|255} */ function rgbToWebsafe(color) { // For each take the high byte, divide by three, round and multiply by three before rounding again color.red = doubleHexDec(nearestPowerOf(parseInt(toHex(color.red).charAt(0), 16), 3)); color.blue = doubleHexDec(nearestPowerOf(parseInt(toHex(color.blue).charAt(0), 16), 3)); color.green = doubleHexDec(nearestPowerOf(parseInt(toHex(color.green).charAt(0), 16), 3)); return color; } /** Convert a combination of hue, saturation and value into an RGB color. * Hue is defined in degrees, saturation and value as a floats between 0 and 1 (0% -> 100%) * * @param h float angle of hue around color wheel 0->360 * @param s float saturation of color (no color (grey)) 0->1 (vibrant) * @param v float value (brightness) of color (black) 0->1 (bright) * @returns object {red:0->255, green:0->255, blue:0->255} * @seealso http://en.wikipedia.org/wiki/HSV_color_space */ function hsvToRGB(h,s,v) { var colors; if(s === 0) { // GREY colors = {red:v,green:v,blue:v}; } else { h /= 60; var i = Math.floor(h); var f = h - i; var p = v * (1 - s); var q = v * (1 - s * f); var t = v * (1 - s * (1 - f) ); switch(i) { case 0: colors = {red:v, green:t, blue:p}; break; case 1: colors = {red:q, green:v, blue:p}; break; case 2: colors = {red:p, green:v, blue:t}; break; case 3: colors = {red:p, green:q, blue:v}; break; case 4: colors = {red:t, green:p, blue:v}; break; default:colors = {red:v, green:p, blue:q}; break; } } colors.red = Math.ceil(colors.red * 255); colors.green = Math.ceil(colors.green * 255); colors.blue = Math.ceil(colors.blue * 255); return colors; } var self = this; function closeOnBodyClick (ev) { ev = ev ? ev : window.event; el = ev.target ? ev.target : ev.srcElement; do { if (el == self.table) return; } while (el = el.parentNode); self.close(); } /** Open the color picker * * @param string anchorage pair of sides of element to anchor the picker to * "top,left" "top,right" "bottom,left" or "bottom,right" * @param HTML_ELEMENT element the element to anchor the picker to sides of * * @note The element is just referenced here for positioning (anchoring), it * does not automatically get the color copied into it. See the usage instructions * for the class. */ this.open = function(anchorage,element,initcolor) { this.table.style.display = ''; this.pick_color(); if(initcolor && /#[0-9a-f]{6,6}/i.test(initcolor)) { this.chosenColor.value = initcolor; this.backSample.style.backgroundColor = initcolor; this.foreSample.style.color = initcolor; } Xinha._addEvent(document.body,'mousedown',closeOnBodyClick); // Find position of the element this.table.style.position = 'absolute'; var e = element; var top = 0; var left = 0; do { if (e.style.position == 'fixed') { this.table.style.position = 'fixed'; } top += e.offsetTop - e.scrollTop; left += e.offsetLeft - e.scrollLeft; e = e.offsetParent; } while(e); var x, y; if(/top/.test(anchorage) || (top + this.table.offsetHeight > document.body.offsetHeight)) { if(top - this.table.offsetHeight > 0) { this.table.style.top = (top - this.table.offsetHeight) + 'px'; } else { this.table.style.top = 0; } } else { this.table.style.top = (top + element.offsetHeight) + 'px'; } if(/left/.test(anchorage) || (left + this.table.offsetWidth > document.body.offsetWidth)) { if(left - (this.table.offsetWidth - element.offsetWidth) > 0 ) { this.table.style.left = (left - (this.table.offsetWidth - element.offsetWidth)) + 'px'; } else { this.table.style.left = 0; } } else { this.table.style.left = left + 'px'; } // IE6 ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker if (this.is_ie_6) { this.iframe.style.top = this.table.style.top; this.iframe.style.left = this.table.style.left; } }; function pickCell(cell) { picker.chosenColor.value = cell.colorCode; picker.backSample.style.backgroundColor = cell.colorCode; picker.foreSample.style.color = cell.colorCode; if((cell.hue >= 195 && cell.saturation > 0.5) || (cell.hue === 0 && cell.saturation === 0 && cell.value < 0.5) || (cell.hue !== 0 && picker.value < 0.75)) { cell.style.borderColor = '#fff'; } else { cell.style.borderColor = '#000'; } pickrow = cell.thisrow; pickcol = cell.thiscol; } function pickValue(cell) { // cell.style.borderWidth = '1px'; // cell.style.borderStyle = 'solid'; if(picker.value < 0.5) { cell.style.borderColor = '#fff'; } else { cell.style.borderColor = '#000'; } valuerow = cell.thisrow; valuecol = cell.thiscol; picker.chosenColor.value = picker.saved_cells[pickrow][pickcol].colorCode; picker.backSample.style.backgroundColor = picker.saved_cells[pickrow][pickcol].colorCode; picker.foreSample.style.color = picker.saved_cells[pickrow][pickcol].colorCode; } function unpickCell(row,col) { picker.saved_cells[row][col].style.borderColor = picker.saved_cells[row][col].colorCode; } /** Draw the color picker. */ this.pick_color = function() { var rows, cols; var picker = this; var huestep = 359/(this.side); var saturstep = 1/(this.side - 1); var valustep = 1/(this.side - 1); var constrain = this.constrain_cb.checked; if(this.saved_cells === null) { this.saved_cells = []; for(var row = 0; row < this.side; row++) { var tr = document.createElement('tr'); this.saved_cells[row] = []; for(var col = 0; col < this.side; col++) { var td = document.createElement('td'); if(constrain) { td.colorCode = tupleToColor(rgbToWebsafe(hsvToRGB(huestep*row, saturstep*col, this.value))); } else { td.colorCode = tupleToColor(hsvToRGB(huestep*row, saturstep*col, this.value)); } this.saved_cells[row][col] = td; td.style.height = this.cellsize + 'px'; td.style.width = this.cellsize -2 +'px'; td.style.borderWidth = '1px'; td.style.borderStyle = 'solid'; td.style.borderColor = td.colorCode; td.style.backgroundColor = td.colorCode; if(row == pickrow && col == pickcol) { td.style.borderColor = '#000'; this.chosenColor.value = td.colorCode; this.backSample.style.backgroundColor = td.colorCode; this.foreSample.style.color = td.colorCode; } td.hue = huestep * row; td.saturation = saturstep*col; td.thisrow = row; td.thiscol = col; td.onmousedown = function() { enablepick = true; // unpickCell(pickrow,pickcol); picker.saved_cells[pickrow][pickcol].style.borderColor = picker.saved_cells[pickrow][pickcol].colorCode; pickCell(this); }; td.onmouseover = function() { if(enablepick) { pickCell(this); } }; td.onmouseout = function() { if(enablepick) { // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode; this.style.borderColor = this.colorCode; } }; td.ondblclick = function() { Xinha.colorPicker.remember(this.colorCode, picker.savecolors); picker.callback(this.colorCode); picker.close(); }; td.appendChild(document.createTextNode(' ')); td.style.cursor = 'pointer'; tr.appendChild(td); td = null; } // Add a blank and then a value column var td = document.createElement('td'); td.appendChild(document.createTextNode(' ')); td.style.width = this.cellsize + 'px'; tr.appendChild(td); td = null; var td = document.createElement('td'); this.saved_cells[row][col+1] = td; td.appendChild(document.createTextNode(' ')); td.style.width = this.cellsize -2 + 'px'; td.style.height = this.cellsize + 'px'; td.constrainedColorCode = tupleToColor(rgbToWebsafe(hsvToRGB(0,0,valustep*row))); td.style.backgroundColor = td.colorCode = tupleToColor(hsvToRGB(0,0,valustep*row)); td.style.borderWidth = '1px'; td.style.borderStyle = 'solid'; // td.style.borderColor = td.style.backgroundColor; td.style.borderColor = td.colorCode; if(row == valuerow) { td.style.borderColor = 'black'; } td.hue = huestep * row; td.saturation = saturstep*col; td.hsv_value = valustep*row; td.thisrow = row; td.thiscol = col + 1; td.onmousedown = function() { enablevalue = true; // unpickCell(valuerow,valuecol); picker.saved_cells[valuerow][valuecol].style.borderColor = picker.saved_cells[valuerow][valuecol].colorCode; picker.value = this.hsv_value; picker.pick_color(); pickValue(this); }; td.onmouseover = function() { if(enablevalue) { picker.value = this.hsv_value; picker.pick_color(); pickValue(this); } }; td.onmouseout = function() { if(enablevalue) { // this.style.borderWidth = 0; // this.style.borderStyle = 'none'; this.style.borderColor = this.colorCode;//''; } }; td.style.cursor = 'pointer'; tr.appendChild(td); td = null; this.tbody.appendChild(tr); tr = null; } // Add one row of greys var tr = document.createElement('tr'); this.saved_cells[row] = []; for(var col = 0; col < this.side; col++) { var td = document.createElement('td'); if(constrain) { td.colorCode = tupleToColor(rgbToWebsafe(hsvToRGB(0, 0, valustep*(this.side-col-1)))); } else { td.colorCode = tupleToColor(hsvToRGB(0, 0, valustep*(this.side-col-1))); } this.saved_cells[row][col] = td; td.style.height = this.cellsize + 'px'; td.style.width = this.cellsize -2 +'px'; td.style.borderWidth = '1px'; td.style.borderStyle = 'solid'; td.style.borderColor = td.colorCode; td.style.backgroundColor = td.colorCode; td.hue = 0; td.saturation = 0; td.value = valustep*(this.side-col-1); td.thisrow = row; td.thiscol = col; td.onmousedown = function() { enablepick = true; // unpickCell(pickrow,pickcol); picker.saved_cells[pickrow][pickcol].style.borderColor = picker.saved_cells[pickrow][pickcol].colorCode; pickCell(this); }; td.onmouseover = function() { if(enablepick) { pickCell(this); } }; td.onmouseout = function() { if(enablepick) { // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode; this.style.borderColor = this.colorCode; } }; td.ondblclick = function() { Xinha.colorPicker.remember(this.colorCode, picker.savecolors); picker.callback(this.colorCode); picker.close(); }; td.appendChild(document.createTextNode(' ')); td.style.cursor = 'pointer'; tr.appendChild(td); td = null; } this.tbody.appendChild(tr); tr = null; var tr = document.createElement('tr'); var td = document.createElement('td'); tr.appendChild(td); td.colSpan = this.side + 2; td.style.padding = '3px'; if ( this.websafe ) { var div = document.createElement('div'); var label = document.createElement('label'); label.appendChild(document.createTextNode(Xinha._lc('Web Safe: '))); this.constrain_cb.onclick = function() { picker.pick_color(); }; label.appendChild(this.constrain_cb); label.style.fontFamily = 'small-caption,caption,sans-serif'; label.style.fontSize = 'x-small'; div.appendChild(label); td.appendChild(div); div = null; } var div = document.createElement('div'); var label = document.createElement('label'); label.style.fontFamily = 'small-caption,caption,sans-serif'; label.style.fontSize = 'x-small'; label.appendChild(document.createTextNode(Xinha._lc('Color: '))); label.appendChild(this.chosenColor); div.appendChild(label); var but = document.createElement('span'); but.className = "buttonColor "; but.style.fontSize = '13px'; but.style.width = '24px'; but.style.marginLeft = '2px'; but.style.padding = '0px 4px'; but.style.cursor = 'pointer'; but.onclick = function() { Xinha.colorPicker.remember(picker.chosenColor.value, picker.savecolors); picker.callback(picker.chosenColor.value); picker.close(); }; but.appendChild(document.createTextNode(Xinha._lc('OK'))); but.align = 'center'; div.appendChild(but); td.appendChild(div); var sampleTable = document.createElement('table'); sampleTable.style.width = '100%'; var sampleBody = document.createElement('tbody'); sampleTable.appendChild(sampleBody); var sampleRow = document.createElement('tr'); sampleBody.appendChild(sampleRow); var leftSampleCell = document.createElement('td'); sampleRow.appendChild(leftSampleCell); leftSampleCell.appendChild(this.backSample); leftSampleCell.style.width = '50%'; var rightSampleCell = document.createElement('td'); sampleRow.appendChild(rightSampleCell); rightSampleCell.appendChild(this.foreSample); rightSampleCell.style.width = '50%'; td.appendChild(sampleTable); var savedColors = document.createElement('div'); savedColors.style.clear = 'both'; function createSavedColors(color) { var is_ie = Xinha.is_ie; var div = document.createElement('div'); div.style.width = picker.cellsize + 'px';//13px'; div.style.height = picker.cellsize + 'px';//13px'; div.style.margin = '1px'; div.style.border = '1px solid black'; div.style.cursor = 'pointer'; div.style.backgroundColor = color; div.style[ is_ie ? 'styleFloat' : 'cssFloat'] = 'left'; // div.onclick = function() { picker.callback(color); picker.close(); }; div.ondblclick = function() { picker.callback(color); picker.close(); }; // div.onmouseover = function() div.onclick = function() { picker.chosenColor.value = color; picker.backSample.style.backgroundColor = color; picker.foreSample.style.color = color; }; savedColors.appendChild(div); } for ( var savedCols = 0; savedCols < Xinha.colorPicker.savedColors.length; savedCols++ ) { createSavedColors(Xinha.colorPicker.savedColors[savedCols]); } td.appendChild(savedColors); this.tbody.appendChild(tr); document.body.appendChild(this.table); //put an iframe behind the table to mask select lists in ie // IE6 ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker if (this.is_ie_6) { if ( !this.iframe ) { this.iframe = document.createElement('iframe'); this.iframe.frameBorder = 0; this.iframe.src = "javascript:;"; this.iframe.style.position = "absolute"; this.iframe.style.width = this.table.offsetWidth; this.iframe.style.height = this.table.offsetHeight; this.iframe.style.zIndex = '1049'; document.body.insertBefore(this.iframe, this.table); } this.iframe.style.display = ''; } } else { for(var row = 0; row < this.side; row++) { for(var col = 0; col < this.side; col++) { if(constrain) { this.saved_cells[row][col].colorCode = tupleToColor(rgbToWebsafe(hsvToRGB(huestep*row, saturstep*col, this.value))); } else { this.saved_cells[row][col].colorCode = tupleToColor(hsvToRGB(huestep*row, saturstep*col, this.value)); } this.saved_cells[row][col].style.backgroundColor = this.saved_cells[row][col].colorCode; this.saved_cells[row][col].style.borderColor = this.saved_cells[row][col].colorCode; } } var pickcell = this.saved_cells[pickrow][pickcol]; this.chosenColor.value = pickcell.colorCode; this.backSample.style.backgroundColor = pickcell.colorCode; this.foreSample.style.color = pickcell.colorCode; if((pickcell.hue >= 195 && pickcell.saturation > 0.5) || (pickcell.hue === 0 && pickcell.saturation === 0 && pickcell.value < 0.5) || (pickcell.hue !== 0 && picker.value < 0.75)) { pickcell.style.borderColor = '#fff'; } else { pickcell.style.borderColor = '#000'; } } }; /** Close the color picker */ this.close = function() { Xinha._removeEvent(document.body,'mousedown',closeOnBodyClick); this.table.style.display = 'none'; // IE6 ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker if (this.is_ie_6) { if ( this.iframe ) { this.iframe.style.display = 'none'; } } }; } // end Xinha.colorPicker // array of the saved colors Xinha.colorPicker.savedColors = []; // add the color to the savedColors Xinha.colorPicker.remember = function(color, savecolors) { // check if this color is known for ( var i = Xinha.colorPicker.savedColors.length; i--; ) { if ( Xinha.colorPicker.savedColors[i] == color ) { return false; } } // insert the new color Xinha.colorPicker.savedColors.splice(0, 0, color); // limit elements Xinha.colorPicker.savedColors = Xinha.colorPicker.savedColors.slice(0, savecolors); //[mokhet] probably some more parameters to send to the cookie definition // like domain, secure and such, especially with https connection i presume // save the cookie var expdate = new Date(); expdate.setMonth(expdate.getMonth() + 1); document.cookie = 'XinhaColorPicker=' + escape (Xinha.colorPicker.savedColors.join('-')) + ';expires=' + expdate.toGMTString(); return true; }; // try to read the colors from the cookie Xinha.colorPicker.loadColors = function() { var index = document.cookie.indexOf('XinhaColorPicker'); if ( index != -1 ) { var begin = (document.cookie.indexOf('=', index) + 1); var end = document.cookie.indexOf(';', index); if ( end == -1 ) { end = document.cookie.length; } Xinha.colorPicker.savedColors = unescape(document.cookie.substring(begin, end)).split('-'); } }; /** Create a neat little box next to an input field * * shows actual color * * opens colorPicker on click * * has a button to clear the color with a click * * @param input (DOM element) * @param optional pickerConfig configuration object for Xinha.colorPicker() */ Xinha.colorPicker.InputBinding = function(input,pickerConfig) { var doc = input.ownerDocument; var main = doc.createElement('span'); main.className = "buttonColor"; var chooser = this.chooser = doc.createElement('span'); chooser.className = "chooser"; if (input.value) chooser.style.backgroundColor = input.value; chooser.onmouseover = function() {chooser.className = "chooser buttonColor-hilite";}; chooser.onmouseout = function() {chooser.className = "chooser";}; chooser.appendChild(doc.createTextNode('\u00a0')); main.appendChild(chooser); var clearColor = doc.createElement('span'); clearColor.className = "nocolor"; clearColor.onmouseover = function() {clearColor.className = "nocolor buttonColor-hilite"; clearColor.style.color='#f00'}; clearColor.onmouseout = function() {clearColor.className = "nocolor"; clearColor.style.color='#000'}; clearColor.onclick = function() {input.value ='';chooser.style.backgroundColor = ''}; clearColor.appendChild(doc.createTextNode('\u00d7')); main.appendChild(clearColor); input.parentNode.insertBefore(main,input.nextSibling); Xinha._addEvent(input,'change',function() {chooser.style.backgroundColor = this.value;}) pickerConfig = (pickerConfig) ? Xinha.cloneObject(pickerConfig) : { cellsize:'5px' }; pickerConfig.callback = (pickerConfig.callback) ? pickerConfig.callback : function(color) {chooser.style.backgroundColor = color;input.value=color}; chooser.onclick = function() { var colPicker = new Xinha.colorPicker(pickerConfig); colPicker.open("",chooser, input.value ); } Xinha.freeLater(this,"chooser"); } Xinha.colorPicker.InputBinding.prototype.setColor = function (color) { this.chooser.style.backgroundColor = color; }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/ColorPicker/ColorPicker.js
JavaScript
art
33,648
<html> <head> <title>Insert/Modify Link</title> <script type="text/javascript" src="../../popups/popup.js"></script> <link rel="stylesheet" type="text/css" href="../../popups/popup.css" /> <script type="text/javascript"> window.resizeTo(400, 200); Xinha = window.opener.Xinha; function i18n(str) { return (Xinha._lc(str, 'Xinha')); } function onTargetChanged() { var f = document.getElementById("f_other_target"); if (this.value == "_other") { f.style.visibility = "visible"; f.select(); f.focus(); } else f.style.visibility = "hidden"; } function Init() { __dlg_translate('Xinha'); __dlg_init(); // Make sure the translated string appears in the drop down. (for gecko) document.getElementById("f_target").selectedIndex = 1; document.getElementById("f_target").selectedIndex = 0; var param = window.dialogArguments; var target_select = document.getElementById("f_target"); var use_target = true; if (param) { if ( typeof param["f_usetarget"] != "undefined" ) { use_target = param["f_usetarget"]; } if ( typeof param["f_href"] != "undefined" ) { document.getElementById("f_href").value = param["f_href"]; document.getElementById("f_title").value = param["f_title"]; comboSelectValue(target_select, param["f_target"]); if (target_select.value != param.f_target) { var opt = document.createElement("option"); opt.value = param.f_target; opt.innerHTML = opt.value; target_select.appendChild(opt); opt.selected = true; } } } if (! use_target) { document.getElementById("f_target_label").style.visibility = "hidden"; document.getElementById("f_target").style.visibility = "hidden"; document.getElementById("f_other_target").style.visibility = "hidden"; } var opt = document.createElement("option"); opt.value = "_other"; opt.innerHTML = i18n("Other"); target_select.appendChild(opt); target_select.onchange = onTargetChanged; document.getElementById("f_href").focus(); document.getElementById("f_href").select(); } function onOK() { var required = { // f_href shouldn't be required or otherwise removing the link by entering an empty // url isn't possible anymore. // "f_href": i18n("You must enter the URL where this link points to") }; for (var i in required) { var el = document.getElementById(i); if (!el.value) { alert(required[i]); el.focus(); return false; } } // pass data back to the calling window var fields = ["f_href", "f_title", "f_target" ]; var param = new Object(); for (var i in fields) { var id = fields[i]; var el = document.getElementById(id); param[id] = el.value; } if (param.f_target == "_other") param.f_target = document.getElementById("f_other_target").value; __dlg_close(param); return false; } function onCancel() { __dlg_close(null); return false; } </script> </head> <body class="dialog" onload="Init()"> <div class="title">Insert/Modify Link</div> <form> <table border="0" style="width: 100%;"> <tr> <td class="label">URL:</td> <td><input type="text" id="f_href" style="width: 100%" /></td> </tr> <tr> <td class="label">Title (tooltip):</td> <td><input type="text" id="f_title" style="width: 100%" /></td> </tr> <tr> <td class="label"><span id="f_target_label">Target:</span></td> <td><select id="f_target"> <option value="">None (use implicit)</option> <option value="_blank">New window (_blank)</option> <option value="_self">Same frame (_self)</option> <option value="_top">Top frame (_top)</option> </select> <input type="text" name="f_other_target" id="f_other_target" size="10" style="visibility: hidden" /> </td> </tr> </table> <div id="buttons"> <button type="submit" name="ok" onclick="return onOK();">OK</button> <button type="button" name="cancel" onclick="return onCancel();">Cancel</button> </div> </form> </body> </html>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/CreateLink/link.html
HTML
art
4,010
<h1 id="[h1]"><l10n>Insert/Modify Link</l10n></h1> <table border="0" style="margin-top:10px;width: 100%;"> <tr> <td class="label"><l10n>URL:</l10n></td> <td style="width: 70%"><input type="text" id="[f_href]" name="[f_href]" style="width: 90%" /></td> </tr> <tr> <td class="label"><l10n>Title (tooltip):</l10n></td> <td><input type="text" id="[f_title]" name="[f_title]" style="width: 90%" /></td> </tr> <tr> <td class="label"><span id="[f_target_label]"><l10n>Target:</l10n></span></td> <td><select id="[f_target]" name="[f_target]"> <option value=""><l10n>None (use implicit)</l10n></option> <option value="_blank"><l10n>New window (_blank)</l10n></option> <option value="_self"><l10n>Same frame (_self)</l10n></option> <option value="_top"><l10n>Top frame (_top)</l10n></option> <option value="_other"><l10n>Other</l10n></option> </select> <input type="text" name="[f_other_target]" id="[f_other_target]" size="10" style="visibility: hidden" /> </td> </tr> </table> <div class="buttons" id="[buttons]"> <input type="button" id="[ok]" value="_(OK)" /> <input type="button" id="[cancel]" value="_(Cancel)" /> </div>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/CreateLink/dialog.html
HTML
art
1,207
CreateLink.prototype.show = function(a) { if (!this.dialog) { this.prepareDialog(); } var editor = this.editor; this.a = a; if(!a && this.editor.selectionEmpty(this.editor.getSelection())) { alert(this._lc("You need to select some text before creating a link")); return false; } var inputs = { f_href : '', f_title : '', f_target : '', f_other_target : '' }; if(a && a.tagName.toLowerCase() == 'a') { inputs.f_href = this.editor.fixRelativeLinks(a.getAttribute('href')); inputs.f_title = a.title; if (a.target) { if (!/_self|_top|_blank/.test(a.target)) { inputs.f_target = '_other'; inputs.f_other_target = a.target; } else { inputs.f_target = a.target; inputs.f_other_target = ''; } } } // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog this.dialog.show(inputs); }; // and finally ... take some action CreateLink.prototype.apply = function() { var values = this.dialog.hide(); var a = this.a; var editor = this.editor; var atr = { href: '', target:'', title:'' }; if(values.f_href) { atr.href = values.f_href; atr.title = values.f_title; if (values.f_target.value) { if (values.f_target.value == 'other') atr.target = values.f_other_target; else atr.target = values.f_target.value; } } if (values.f_target.value) { if (values.f_target.value != '_other') { atr.target = values.f_target.value; } else { atr.target = values.f_other_target; } } if(a && a.tagName.toLowerCase() == 'a') { if(!atr.href) { if(confirm(this._lc('Are you sure you wish to remove this link?'))) { var p = a.parentNode; while(a.hasChildNodes()) { p.insertBefore(a.removeChild(a.childNodes[0]), a); } p.removeChild(a); editor.updateToolbar(); return; } } else { // Update the link for(var i in atr) { a.setAttribute(i, atr[i]); } // If we change a mailto link in IE for some hitherto unknown // reason it sets the innerHTML of the link to be the // href of the link. Stupid IE. if(Xinha.is_ie) { if(/mailto:([^?<>]*)(\?[^<]*)?$/i.test(a.innerHTML)) { a.innerHTML = RegExp.$1; } } } } else { if(!atr.href) return true; // Insert a link, we let the browser do this, we figure it knows best var tmp = Xinha.uniq('http://www.example.com/Link'); editor._doc.execCommand('createlink', false, tmp); // Fix them up var anchors = editor._doc.getElementsByTagName('a'); for(var i = 0; i < anchors.length; i++) { var anchor = anchors[i]; if(anchor.href == tmp) { // Found one. if (!a) a = anchor; for(var j in atr) { anchor.setAttribute(j, atr[j]); } } } } editor.selectNodeContents(a); editor.updateToolbar(); }; CreateLink.prototype._getSelectedAnchor = function() { var sel = this.editor.getSelection(); var rng = this.editor.createRange(sel); var a = this.editor.activeElement(sel); if(a != null && a.tagName.toLowerCase() == 'a') { return a; } else { a = this.editor._getFirstAncestor(sel, 'a'); if(a != null) { return a; } } return null; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/CreateLink/pluginMethods.js
JavaScript
art
3,231
// I18N constants // // LANG: "pt_br", ENCODING: UTF-8 // Portuguese Brazilian Translation // // Author: Marcio Barbosa, <marcio@mpg.com.br> // MSN: tomarshall@msn.com - ICQ: 69419933 // Site: http://www.mpg.com.br // // Last revision: 06 september 2007 // Please don´t remove this information // If you modify any source, please insert a comment with your name and e-mail // // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt). { "You need to select some text before creating a link": "Você precisa selecionar um texto antes de criar um link" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/CreateLink/lang/pt_br.js
JavaScript
art
615
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-2008 Xinha Developer Team and contributors -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- This is the standard implementation of the Xinha.prototype._createLink method, -- which provides the functionality to insert a hyperlink in the editor. -- -- The file is loaded as a special plugin by the Xinha Core when no alternative method (plugin) is loaded. -- -- -- $HeadURL: http://svn.xinha.org/trunk/modules/CreateLink/link.js $ -- $LastChangedDate: 2008-10-13 06:42:42 +1300 (Mon, 13 Oct 2008) $ -- $LastChangedRevision: 1084 $ -- $LastChangedBy: ray $ --------------------------------------------------------------------------*/ function CreateLink(editor) { this.editor = editor; var cfg = editor.config; var self = this; editor.config.btnList.createlink[3] = function() { self.show(self._getSelectedAnchor()); } } CreateLink._pluginInfo = { name : "CreateLink", origin : "Xinha Core", version : "$LastChangedRevision: 1084 $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), developer : "The Xinha Core Developer Team", developer_url : "$HeadURL: http://svn.xinha.org/trunk/modules/CreateLink/link.js $".replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), sponsor : "", sponsor_url : "", license : "htmlArea" }; CreateLink.prototype._lc = function(string) { return Xinha._lc(string, 'Xinha'); }; CreateLink.prototype.onGenerateOnce = function() { CreateLink.loadAssets(); }; CreateLink.loadAssets = function() { var self = CreateLink; if (self.loading) return; self.loading = true; Xinha._getback(_editor_url + 'modules/CreateLink/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); Xinha._getback(_editor_url + 'modules/CreateLink/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); } CreateLink.prototype.onUpdateToolbar = function() { if (!(CreateLink.dialogReady && CreateLink.methodsReady)) { this.editor._toolbarObjects.createlink.state("enabled", false); } else this.onUpdateToolbar = null; }; CreateLink.prototype.prepareDialog = function() { var self = this; var editor = this.editor; var dialog = this.dialog = new Xinha.Dialog(editor, CreateLink.html, 'Xinha',{width:400}) // Connect the OK and Cancel buttons dialog.getElementById('ok').onclick = function() {self.apply();} dialog.getElementById('cancel').onclick = function() { self.dialog.hide()}; if (!editor.config.makeLinkShowsTarget) { dialog.getElementById("f_target_label").style.visibility = "hidden"; dialog.getElementById("f_target").style.visibility = "hidden"; dialog.getElementById("f_other_target").style.visibility = "hidden"; } dialog.getElementById('f_target').onchange= function() { var f = dialog.getElementById("f_other_target"); if (this.value == "_other") { f.style.visibility = "visible"; f.select(); f.focus(); } else f.style.visibility = "hidden"; }; this.dialogReady = true; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/modules/CreateLink/link.js
JavaScript
art
3,526
@echo off FOR %%V IN (%*) DO copy %%V %%V_uncompressed.js FOR %%V IN (%*) DO java -jar %~p0dojo_js_compressor.jar -c %%V_uncompressed.js > %%V 2>&1 FOR %%V IN (%*) DO del %%V_uncompressed.js # pause
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/compress.bat
Batchfile
art
206
#!/usr/bin/python """Runs a very basic file server so that we can test Xinha. By default, the server runs on port 8080, but you can pass the -p or --port option to change the port used.""" import os import SimpleHTTPServer import SocketServer # File server for testing Xinha def __main(): """Use the embed_url.py program from the command-line The embed_url.py program downloads files and processes links in the case of HTML files. See embed_url.py -h for more info. This procedure has the sole purpose of reading in and verifying the command-line arguments before passing them to the embed_url funtion.""" from getopt import getopt, GetoptError from sys import argv, exit, stderr try: options, arguments = getopt(argv[1:], "p:", ["port="]) except GetoptError: print "Invalid option" __usage() exit(2) PORT = 8080 for option, value in options: if option in ("-p", "--port"): try: PORT = int(value) except ValueError: print "'%s' is not a valid port number" % value __usage() exit(2) # SimpleHTTPRequestHandler serves data from the current directory, so if we # are running from inside contrib, we have to change our current working # directory if os.path.split(os.getcwd())[1] == 'contrib': os.chdir('..') Handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("", PORT), Handler) print "Serving at port %s" % PORT print "Try viewing the example at http://localhost:%s/examples/Newbie.html" % PORT httpd.serve_forever() def __usage(): """ Print the usage information contained in the module docstring """ print __doc__ if __name__ == '__main__': __main()
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/.svn/text-base/test_server.py.svn-base
Python
art
1,835
<?php /** Write the appropriate xinha_config directives to pass data to a PHP (Plugin) backend file. * * ImageManager Example: * The following would be placed in step 3 of your configuration (see the NewbieGuide * (http://xinha.python-hosting.com/wiki/NewbieGuide) * * <script language="javascript"> * with (xinha_config.ImageManager) * { * <?php * xinha_pass_to_php_backend * ( * array * ( * 'images_dir' => '/home/your/directory', * 'images_url' => '/directory' * ) * ) * ?> * } * </script> * */ function xinha_pass_to_php_backend($Data, $KeyLocation = 'Xinha:BackendKey', $ReturnPHP = FALSE) { $bk = array(); $bk['data'] = serialize($Data); @session_start(); if(!isset($_SESSION[$KeyLocation])) { $_SESSION[$KeyLocation] = uniqid('Key_'); } $bk['session_name'] = session_name(); $bk['key_location'] = $KeyLocation; $bk['hash'] = function_exists('sha1') ? sha1($_SESSION[$KeyLocation] . $bk['data']) : md5($_SESSION[$KeyLocation] . $bk['data']); // The data will be passed via a postback to the // backend, we want to make sure these are going to come // out from the PHP as an array like $bk above, so // we need to adjust the keys. $backend_data = array(); foreach($bk as $k => $v) { $backend_data["backend_data[$k]"] = $v; } // The session_start() above may have been after data was sent, so cookies // wouldn't have worked. $backend_data[session_name()] = session_id(); if($ReturnPHP) { return array('backend_data' => $backend_data); } else { echo 'backend_data = ' . xinha_to_js($backend_data) . "; \n"; } } /** Convert PHP data structure to Javascript */ function xinha_to_js($var, $tabs = 0) { if(is_numeric($var)) { return $var; } if(is_string($var)) { return "'" . xinha_js_encode($var) . "'"; } if(is_bool($var)) { return $var ? 'true': 'false'; } if(is_array($var)) { $useObject = false; foreach(array_keys($var) as $k) { if(!is_numeric($k)) $useObject = true; } $js = array(); foreach($var as $k => $v) { $i = ""; if($useObject) { if(preg_match('#^[a-zA-Z]+[a-zA-Z0-9]*$#', $k)) { $i .= "$k: "; } else { $i .= "'$k': "; } } $i .= xinha_to_js($v, $tabs + 1); $js[] = $i; } if($useObject) { $ret = "{\n" . xinha_tabify(implode(",\n", $js), $tabs) . "\n}"; } else { $ret = "[\n" . xinha_tabify(implode(",\n", $js), $tabs) . "\n]"; } return $ret; } return 'null'; } /** Like htmlspecialchars() except for javascript strings. */ function xinha_js_encode($string) { static $strings = "\\,\",',%,&,<,>,{,},@,\n,\r"; if(!is_array($strings)) { $tr = array(); foreach(explode(',', $strings) as $chr) { $tr[$chr] = sprintf('\x%02X', ord($chr)); } $strings = $tr; } return strtr($string, $strings); } /** Used by plugins to get the config passed via * xinha_pass_to_backend() * returns either the structure given, or NULL * if none was passed or a security error was encountered. */ function xinha_read_passed_data($KeyLocation = 'Xinha:BackendKey') { if(isset($_REQUEST['backend_data']) && is_array($_REQUEST['backend_data'])) { $bk = $_REQUEST['backend_data']; session_name($bk['session_name']); @session_start(); if(!isset($_SESSION[$bk['key_location']])) return NULL; if($KeyLocation !== $bk['key_location']) { trigger_error('Programming Error - please contact the website administrator/programmer to alert them to this problem. A non-default backend key location is being used to pass backend data to Xinha, but the same key location is not being used to receive data. The special backend configuration has been ignored. To resolve this, find where you are using xinha_pass_to_php_backend and remove the non default key, or find the locations where xinha_read_passed_data is used (in Xinha) and add a parameter with the non default key location, or edit contrib/php-xinha.php and change the default key location in both these functions. See: http://trac.xinha.org/ticket/1518', E_USER_ERROR); return NULL; } if($bk['hash'] === function_exists('sha1') ? sha1($_SESSION[$bk['key_location']] . $bk['data']) : md5($_SESSION[$bk['key_location']] . $bk['data'])) { return unserialize(ini_get('magic_quotes_gpc') ? stripslashes($bk['data']) : $bk['data']); } } return NULL; } /** Used by plugins to get a query string that can be sent to the backend * (or another part of the backend) to send the same data. */ function xinha_passed_data_querystring() { $qs = array(); if(isset($_REQUEST['backend_data']) && is_array($_REQUEST['backend_data'])) { foreach($_REQUEST['backend_data'] as $k => $v) { $v = ini_get('magic_quotes_gpc') ? stripslashes($v) : $v; $qs[] = "backend_data[" . rawurlencode($k) . "]=" . rawurlencode($v); } } $qs[] = session_name() . '=' . session_id(); return implode('&', $qs); } /** Just space-tab indent some text */ function xinha_tabify($text, $tabs) { if($text) { return str_repeat(" ", $tabs) . preg_replace('/\n(.)/', "\n" . str_repeat(" ", $tabs) . "\$1", $text); } } /** Return upload_max_filesize value from php.ini in kilobytes (function adapted from php.net)**/ function upload_max_filesize_kb() { $val = ini_get('upload_max_filesize'); $val = trim($val); $last = strtolower($val{strlen($val)-1}); switch($last) { // The 'G' modifier is available since PHP 5.1.0 case 'g': $val *= 1024; case 'm': $val *= 1024; } return $val; } ?>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/php-xinha.php
PHP
art
6,320
<?php die("this script is disabled for security"); /** * LC-Parse-Strings-Script * * This script parses all xinhas source-files and creates base lang-files * in the lang-folders (one for base and one every plugin) * * How To use it: - remove the die() in line 2 (security) * - make sure all lang-folders are writeable for your webserver * - open the contrib/lc_parse_strings.php in your browser * - lang/base.js will be written * - open base.js, translate all strings into your language and save it * as yourlangauge.js * - send the translated file to the xinha-team **/ error_reporting(E_ALL); $ret = array(); $files = getFiles("../", "js$"); foreach($files as $file) { $fp = fopen($file, "r"); $data = ""; while(!feof($fp)) { $data .= fread($fp, 1024); } preg_match_all('#_lc\("([^"]+)"\)|_lc\(\'([^\']+)\'\)#', $data, $m); foreach($m[1] as $i) { if(trim($i)=="") continue; $ret[] = $i; } foreach($m[2] as $i) { if(trim($i)=="") continue; $ret[] = $i; } if(eregi('htmlarea\\.js$', $file)) { //toolbar-buttons //bold: [ "Bold" preg_match_all('#[a-z]+: *\[ * "([^"]+)"#', $data, $m); foreach($m[1] as $i) { if(trim($i)=="") continue; $ret[] = $i; } //HTMLArea._lc({key: 'button_bold', string preg_match_all('#HTMLArea\\._lc\\({key: \'([^\']*)\'#', $data, $m); foreach($m[1] as $i) { if(trim($i)=="") continue; $ret[] = $i; } //config.fontname, fontsize and formatblock $data = substr($data, strpos($data, "this.fontname = {"), strpos($data, "this.customSelects = {};")-strpos($data, "this.fontname = {")); preg_match_all('#"([^"]+)"[ \t]*:[ \t]*["\'][^"\']*["\'],?#', $data, $m); foreach($m[1] as $i) { if(trim($i)=="") continue; $ret[] = $i; } } } $files = getFiles("../popups/", "html$"); foreach($files as $file) { if(preg_match("#custom2.html$#", $file)) continue; if(preg_match('#old_#', $file)) continue; $ret = array_merge($ret, parseHtmlFile($file)); } $ret = array_unique($ret); $langData['HTMLArea'] = $ret; $plugins = getFiles("../plugins/"); foreach($plugins as $pluginDir) { $plugin = substr($pluginDir, 12); if($plugin=="ibrowser") continue; $ret = array(); $files = getFiles("$pluginDir/", "js$"); $files = array_merge($files, getFiles("$pluginDir/popups/", "html$")); $files = array_merge($files, getFiles("$pluginDir/", "php$")); foreach($files as $file) { $fp = fopen($file, "r"); $data = ""; if($fp) { echo "$file open...<br>"; while(!feof($fp)) { $data .= fread($fp, 1024); } preg_match_all('#_lc\("([^"]+)"|_lc\(\'([^\']+)\'#', $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } foreach($m[2] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } } } if($plugin=="TableOperations") { preg_match_all('#options = \\[([^\\]]+)\\];#', $data, $m); foreach($m[1] as $i) { preg_match_all('#"([^"]+)"#', $i, $m1); foreach($m1[1] as $i) { $ret[] = $i; } } //["cell-delete", "td", "Delete cell"], preg_match_all('#\\["[^"]+",[ \t]*"[^"]+",[ \t]*"([^"]+)"\\]#', $data, $m); foreach($m[1] as $i) { $ret[] = $i; } } $files = getFiles("$pluginDir/", "html$"); $files = array_merge($files, getFiles("$pluginDir/", "php$")); foreach($files as $file) { $ret = array_merge($ret, parseHtmlFile($file, $plugin)); } $files = getFiles("$pluginDir/popups/", "html$"); foreach($files as $file) { $ret = array_merge($ret, parseHtmlFile($file, $plugin)); } $ret = array_unique($ret); $langData[$plugin] = $ret; } $plugins = getFiles("../modules/"); foreach($plugins as $pluginDir) { $plugin = substr($pluginDir, 12); $ret = array(); $files = getFiles("$pluginDir/", "js$"); foreach($files as $file) { $fp = fopen($file, "r"); $data = ""; if($fp) { echo "$file open...<br>"; while(!feof($fp)) { $data .= fread($fp, 1024); } preg_match_all('#_lc\("([^"]+)"|_lc\(\'([^\']+)\'#', $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } foreach($m[2] as $i) { if(trim(strip_tags($i))=="") continue; $ret[] = $i; } } } $ret = array_unique($ret); $langData[$plugin] = $ret; } foreach($langData as $plugin=>$strings) { if(sizeof($strings)==0) continue; $data = "// I18N constants\n"; $data .= "//\n"; $data .= "// LANG: \"base\", ENCODING: UTF-8\n"; $data .= "// Author: Translator-Name, <email@example.com>\n"; $data .= "//\n"; $data .= "// Last revision: 06 september 2007\n"; $data .= "// Please don´t remove this information\n"; $data .= "// If you modify any source, please insert a comment with your name and e-mail\n"; $data .= "//\n"; $data .= "// Distributed under the same terms as HTMLArea itself.\n"; $data .= "// This notice MUST stay intact for use (see license.txt).\n"; $data .= "//\n"; $data .= "// (Please, remove information below)\n"; $data .= "// FOR TRANSLATORS:\n"; $data .= "//\n"; $data .= "// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE\n"; $data .= "// (at least a valid email address)\n"; $data .= "//\n"; $data .= "// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;\n"; $data .= "// (if this is not possible, please include a comment\n"; $data .= "// that states what encoding is necessary.)\n"; $data .= "\n"; $data .= "{\n"; sort($strings); foreach($strings as $string) { $string = str_replace(array('\\', '"'), array('\\\\', '\\"'), $string); $data .= " \"".$string."\": \"\",\n"; } $data = substr($data, 0, -2); $data .= "\n"; $data .= "}\n"; if($plugin=="HTMLArea") { $file = "../lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...<br>"; } elseif (($plugin=="InternetExplorer")||($plugin=="InsertTable")||($plugin=="InsertImage")||($plugin=="GetHtml")||($plugin=="Gecko")||($plugin=="Dialogs")||($plugin=="CreateLink")||($plugin=="ColorPicker")) { $file = "../modules/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...<br>"; } elseif ($plugin=="FullScreen") { $file = "../modules/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...<br>"; $file = "../plugins/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...<br>"; } else { $file = "../plugins/$plugin/lang/base.js"; $fp = fopen($file, "w"); if(!$fp) continue; fwrite($fp, $data); fclose($fp); echo "$file written...<br>"; } } function parseHtmlFile($file, $plugin="") { $ret = array(); $fp = fopen($file, "r"); if(!$fp) { die("invalid fp"); } $data = ""; while(!feof($fp)) { $data .= fread($fp, 1024); } if($plugin=="FormOperations" || $plugin=="SuperClean" || $plugin=="Linker") { //<l10n>-tags for inline-dialog or panel-dialog based dialogs $elems = array("l10n"); } else { $elems = array("title", "input", "select", "legend", "span", "option", "td", "button", "div", "label"); } foreach($elems as $elem) { preg_match_all("#<{$elem}[^>]*>([^<^\"]+)</$elem>#i", $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; if($i=="/") continue; if($plugin=="ImageManager" && preg_match('#^--+$#', $i)) continue; //skip those ------ if($plugin=="CharacterMap" && preg_match('#&[a-z0-9]+;#i', trim($i)) || $i=="@") continue; if($plugin=="SpellChecker" && preg_match('#^\'\\.\\$[a-z]+\\.\'$#', $i)) continue; $ret[] = trim($i); } } if($plugin=="FormOperations" || $plugin=="SuperClean" || $plugin=="Linker") { //_( for inline-dialog or panel-dialog based dialogs preg_match_all('#"_\(([^"]+)\)"#i', $data, $m); foreach($m[1] as $i) { if(trim($i)=="") continue; $ret[] = $i; } } else { preg_match_all('#title="([^"]+)"#i', $data, $m); foreach($m[1] as $i) { if(trim(strip_tags($i))=="") continue; if(strip_tags($i)==" - ") continue; //skip those - (ImageManager) $ret[] = $i; } } return($ret); } function getFiles($rootdirpath, $eregi_match='') { $array = array(); if ($dir = @opendir($rootdirpath)) { $array = array(); while (($file = readdir($dir)) !== false) { if($file=="." || $file==".." || $file==".svn") continue; if($eregi_match=="") $array[] = $rootdirpath."/".$file; else if(eregi($eregi_match,$file)) $array[] = $rootdirpath."/".$file; } closedir($dir); } return $array; } ?>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/lc_parse_strings.php
PHP
art
9,969
<? die("Run this script to batch-compress the current Xinha snapshot. To run the script, open the file and comment out the die() command"); $repository_url = 'http://svn.xinha.org/trunk'; $version =''; $date = date('r'); error_reporting(E_ALL); ini_set('show_errors',1); $return = array(); function scan($dir, $durl = '',$min_size="0") { static $seen = array(); global $return; $files = array(); $dir = realpath($dir); if(isset($seen[$dir])) { return $files; } $seen[$dir] = TRUE; $dh = @opendir($dir); while($dh && ($file = readdir($dh))) { if($file !== '.' && $file !== '..') { $path = realpath($dir . '/' . $file); $url = $durl . '/' . $file; if(preg_match("/\.svn|lang/",$path)) continue; if(is_dir($path)) { scan($path); } elseif(is_file($path)) { if(!preg_match("/\.js$/",$path) || filesize($path) < $min_size) continue; $return[] = $path; } } } @closedir($dh); return $files; } scan("../"); $cwd = getcwd(); $root_dir = realpath($cwd.'/..'); print "Processing ".count($return)." files<br />"; $prefix = "/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */"; if ($version) $prefix .= "\n/* This file is part of version $version released $date */"; $core_prefix = ' /*-------------------------------------------------------------------------- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-2008 Xinha Developer Team and contributors -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -------------------------------------------------------------------------*/ '; foreach ($return as $file) { set_time_limit ( 60 ); print "Processed $file<br />"; flush(); $file_url = $repository_url.str_replace($root_dir,'',$file); copy($file,$file."_uncompr.js"); $file_prefix = $prefix."\n/* The URL of the most recent version of this file is $file_url */"; exec("echo \"".(preg_match('/XinhaCore.js$/',$file) ? $file_prefix.$core_prefix : $file_prefix)."\" > $file && java -jar ${cwd}/dojo_js_compressor.jar -c ${file}_uncompr.js >> $file 2>&1"); if (preg_match('/js: ".*?", line \d+:/',file_get_contents($file)) || preg_match('/sh: java: command not found/', file_get_contents($file))) { unlink($file); rename($file."_uncompr.js",$file); } else { unlink($file."_uncompr.js"); } } print "Operation complete." ?>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/compress.php
PHP
art
2,770
<? // This is script that uses the YUI compressor (http://www.julienlecomte.net/blog/2007/08/11/) // It yields gradually better results than the dojo comressor, but it produces unreadable code //die("Run this script to batch-compress the current Xinha snapshot. To run the script, open the file and comment out the die() command"); $repository_url = 'http://svn.xinha.org/trunk'; $version =''; $date = date('r'); $xinha_root = realpath(dirname(__FILE__).'/..'); error_reporting(E_ALL); ini_set('show_errors',1); $return = array(); function scan($dir, $durl = '',$min_size="3000") { static $seen = array(); global $return; $files = array(); $dir = realpath($dir); if(isset($seen[$dir])) { return $files; } $seen[$dir] = TRUE; $dh = @opendir($dir); while($dh && ($file = readdir($dh))) { if($file !== '.' && $file !== '..') { $path = realpath($dir . '/' . $file); $url = $durl . '/' . $file; if(preg_match("/\.svn|lang/",$path)) continue; if(is_dir($path)) { scan($path); } elseif(is_file($path)) { if(!preg_match("/\.(js|css)$/",$path) || filesize($path) < $min_size) continue; $return[] = $path; } } } @closedir($dh); return $files; } scan($xinha_root,0); print "Processing ".count($return)." files<br />"; $prefix = "/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */"; if ($version) $prefix .= "\n/* This file is part of version $version released $date */"; $core_prefix = ' /*-------------------------------------------------------------------------- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-'.date('Y').' Xinha Developer Team and contributors -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -------------------------------------------------------------------------*/ '; foreach ($return as $file) { set_time_limit ( 60 ); print "Processing $file\n"; flush(); $file_url = $repository_url.str_replace($xinha_root,'',$file); copy($file,$file."_uncompr.js"); $file_prefix = $prefix."\n/* The URL of the most recent uncompressed version of this file is $file_url */"; $ext = preg_replace('/.*?(\.js|\.css)$/','$1',$file); file_put_contents($file."_uncompr${ext}", preg_replace('/(\/\/[^\n]*)?(?![*])\\\[\n]/','',file_get_contents($file))); passthru("echo \"".(preg_match('/XinhaCore.js$/',$file) ? $file_prefix.$core_prefix : $prefix)."\" > $file && java -jar {$xinha_root}/contrib/yuicompressor-2.4.2.jar --charset UTF-8 ${file}_uncompr${ext} >> $file 2>&1"); if (preg_match('/\d+:\d+:syntax error/',file_get_contents($file)) || preg_match('/sh: java: command not found/', file_get_contents($file))) { unlink($file); rename($file."_uncompr${ext}",$file); } else { unlink($file."_uncompr${ext}"); } } print "Operation complete." ?>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/compress_yui.php
PHP
art
3,216
<?php // Author: Niels Baggesen, <nba@users.sourceforge.net>, 2009-08-16 // Distributed under the same terms as Xinha itself. // This notice MUST stay intact for use (see license.txt). // merge-strings.php - merge translation strings from master into // individual language files. function usage() { print "merge-strings.php - merge translation strings\n"; print "Options:\n"; print " -l xx Process language xx. Required option\n"; print " -m master Master file. Defaults to 'de.js'\n"; print " -m base Base directory. Defaults to '..'\n"; print " -v Verbose\n"; print " -c Tell about files that must be created\n"; print " -d Debug. Very noisy\n"; exit(1); } // This function taken from the php.net manual page for glob function rglob($pattern='*', $flags = 0, $path='') { $paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT); $files=glob($path.$pattern, $flags); foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); } return $files; } error_reporting(E_ALL); $opts = getopt('l:b:m:cvd'); if ($opts === false) usage; // here we should check extra options, but php lacks that functionality $lang = 'xx'; // The language we process $create = 0; // Tell about missing files? $verbose = 0; // Log the details to stdout? $debug = 0; // ? $basedir = '..'; // Base directory to process $mastername = 'de.js'; // The best bet on a complete translation file if (isset($opts['l'])) $lang = $opts['l']; else die("Missing -l option\n"); if (isset($opts['c'])) $create = 1; if (isset($opts['v'])) $verbose = 1; if (isset($opts['d'])) $debug = 1; if (isset($opts['b'])) $basedir = $opts['b']; if (isset($opts['m'])) $mastername = $opts['m']; if (!preg_match('#/$#', $basedir)) $basedir .= '/'; // So, find all the master files $files = rglob($mastername, 0, $basedir); if (count($files) == 0) { print "No master files found. Check your -b and -m options!\n"; exit(1); } // and process them $filenum = 0; foreach ($files as $masterjs) { $langjs = preg_replace("/$mastername/", "$lang.js", $masterjs); $langnew = $langjs.'.new'; if (!file_exists($langjs)) { if ($create) print "Missing file: $langjs\n"; continue; } // Populate $trans with the strings that must be translated $filenum++; $min = fopen($masterjs, "r"); $trans = array(); $strings = 0; while ($str = fgets($min)) { $str = trim($str); if (preg_match('#^ *"([^"]*)" *: *"([^"]*)"(,)? *(//.*)?$#', $str, $m)) { if (isset($trans[$m[1]])) { print "Duplicate string in $masterjs: $m[1]\n"; continue; } if ($debug) print "Translate: $m[1]\n"; $trans[$m[1]] = 1; $strings++; } } fclose($min); // Now copy from $lin to $lout while verifying that the strings // are still current. // Break out when we hit the last string in the master (no ',' // after the translation. $lin = fopen($langjs, "r"); $lout = fopen($langnew, "w"); $obsolete = 0; $new = 0; $kept = 0; while ($fstr = fgets($lin)) { $str = trim($fstr); if (preg_match('#^ *"([^"]*)" *: *"([^"]*)"(,)? *(//.*)?$#', $str, $m)) { if (!isset($trans[$m[1]])) { if ($verbose) print "Obsolete: $m[1]\n"; $obsolete++; fprintf($lout, " // \"%s\": \"%s\" // OBSOLETE\n", $m[1], $m[2]); } else { if ($debug) print "Keep: $m[1]\n"; unset($trans[$m[1]]); $strings--; $kept++; fprintf($lout, " \"%s\": \"%s\"%s\n", $m[1], $m[2], $strings ? ',' : ''); } if (!isset($m[3]) || $m[3] != ',') break; } else fprintf($lout, "%s", $fstr); } // Add the strings that are missing foreach ($trans as $tr => $v) { if ($verbose) print("New: $tr\n"); $new++; $strings--; fprintf($lout, " \"%s\": \"%s\"%s // NEW\n", $tr, $tr, $strings ? ',' : ''); } // And then the final part of $lin while ($str = fgets($lin)) fprintf($lout, "%s", $str); // Clean up, and tell user what happened fclose($lin); fclose($lout); if ($obsolete == 0 && $new == 0) { if ($verbose) print "$langjs: Unchanged\n"; unlink($langnew); } else { print "$langnew: $new new, $obsolete obsoleted, $kept unchanged entries.\n"; // rename($langnew, $langjs); } } print "$filenum files processed.\n"; ?>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/contrib/lc_merge_strings.php
PHP
art
4,451
.htmlarea { background: #fff; } .htmlarea td { margin:0;padding:0; } .htmlarea .toolbarRow { width:1px; } .htmlarea .toolbar { cursor: default; background: ButtonFace; padding: 3px; border: 1px solid; border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } .htmlarea .toolbar table { margin: 0; font-family: Tahoma, Verdana,sans-serif; font-size: 11px; } .htmlarea .toolbar img { border: none; vertical-align: top; } .htmlarea .toolbar .label { padding: 0 3px; } .htmlarea .toolbar .button { background: ButtonFace; color: ButtonText; border: 1px solid ButtonFace; padding: 1px; margin: 0; width: 18px; height: 18px; } .htmlarea .toolbar a.button:hover { border: 1px solid; border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } .htmlarea .toolbar a.buttonDisabled:hover { border-color: ButtonFace; } .htmlarea .toolbar .buttonActive, .htmlarea .toolbar .buttonPressed { padding: 2px 0 0 2px; border: 1px solid; border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; } .htmlarea .toolbar .buttonPressed { background: ButtonHighlight; } .htmlarea .toolbar .indicator { padding: 0 3px; overflow: hidden; width: 20px; text-align: center; cursor: default; border: 1px solid ButtonShadow; } .htmlarea .toolbar .buttonDisabled img { filter: gray() alpha(opacity = 25); -moz-opacity: 0.25; opacity: 0.25; } .htmlarea .toolbar .separator { /*position: relative;*/ margin:0 3px; border-left: 1px solid ButtonShadow; border-right: 1px solid ButtonHighlight; width: 0; height: 18px; padding: 0; } .htmlarea .toolbar .space { width: 5px; } .htmlarea .toolbar select, .htmlarea .toolbar option { font: 11px Tahoma,Verdana,sans-serif;} .htmlarea .toolbar select, .htmlarea .toolbar select:hover, .htmlarea .toolbar select:active { position:relative; top:-2px; margin-bottom:-2px; color: ButtonText; } .htmlarea iframe.xinha_iframe, .htmlarea textarea.xinha_textarea { border: none; /*1px solid;*/ } .htmlarea .statusBar { border: 1px solid; border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; padding: 2px 4px; background-color: ButtonFace; color: ButtonText; font: 11px Tahoma,Verdana,sans-serif; height:16px; overflow: hidden; } .htmlarea .statusBar .statusBarTree a { padding: 2px 5px; color: #00f; } .htmlarea .statusBar .statusBarTree a:visited { color: #00f; } .htmlarea .statusBar .statusBarTree a:hover { background-color: Highlight; color: HighlightText; padding: 1px 4px; border: 1px solid HighlightText; } .statusBarWidgetContainer { background-color: ButtonFace; } /* popup dialogs */ .dialog { color: ButtonText; background: ButtonFace; border: 1px outset; border-color: WindowFrame; } div.dialog { padding-bottom:10px; border-radius: 8px 8px 0 0; -moz-border-radius: 8px 8px 0 0; -webkit-border-top-left-radius: 8px; -webkit-border-top-right-radius: 8px; box-shadow: 9px 9px 10px #444; -moz-box-shadow: 9px 9px 10px #444; -webkit-box-shadow: 9px 9px 10px #444; } div.dialog.modeless { box-shadow: 4px 4px 5px #888; -moz-box-shadow: 4px 4px 5px #888; -webkit-box-shadow: 4px 4px 5px #888; } div.dialog.chrome { -webkit-box-shadow: none !IMPORTANT; } .panels div.dialog.panel { border-radius:0; -moz-border-radius: 0; -webkit-border-radius:0; box-shadow: none; -moz-box-shadow: none; -webkit-box-shadow: none; } .xinha_dialog_background { filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0; border:none; } .xinha_dialog_background_modal_greyout { background-color:#666; filter: alpha(opacity=70) !IMPORTANT; -moz-opacity: 0.7; opacity: 0.7; } .xinha_dialog_background_modal { filter: alpha(opacity=0) !IMPORTANT; -moz-opacity: 0; opacity: 0; border:none; } body.xinha_dialog_background_modal_greyout { filter: alpha(opacity=100) !IMPORTANT; } body.xinha_dialog_background_modal { filter: alpha(opacity=0); } .dialog .content { padding: 2px; } .dialog, .dialog button, .dialog input, .dialog select, .dialog textarea, .dialog table { font: 11px Tahoma,Verdana,sans-serif; } .dialog table { border-collapse: collapse; } .dialog .title, .dialog h1 { background: ActiveCaption; color: CaptionText; border-bottom: 1px solid #000; padding: 1px 0 2px 5px; font-size: 12px; font-weight: bold; cursor: default; letter-spacing: 0.01em; } .dialog h1 { padding-left:22px; margin:0; border-radius: 8px 8px 0 0; -moz-border-radius: 8px 8px 0 0; -webkit-border-top-left-radius: 8px; -webkit-border-top-right-radius: 8px; } .panels .dialog.panel h1 { -moz-border-radius: 0; -webkit-border-radius:0; } .dialog .title .button { float: right; border: 1px solid #66a; padding: 0 1px 0 2px; margin-right: 1px; color: #fff; text-align: center; } .dialog .title .button-hilite { border-color: #88f; background: #44c; } .dialog button { width: 5.5em; padding: 0; } .dialog .closeButton { padding: 0; cursor: default; border: 1px solid; border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; height : 11px; width : 11px; vertical-align : top; position : absolute; top : 3px; right : 2px; background-color: ButtonFace; color: ButtonText; font-size: 13px; font-family: Tahoma,Verdana,sans-serif; text-align:center; letter-spacing:0; overflow:hidden; } .dialog .buttonColor { width :1em; padding: 1px; cursor: default; border: 1px solid; border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } .dialog .buttonColor .chooser, .dialog .buttonColor .nocolor { height: 0.6em; border: 1px solid; padding: 0 1em; border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; } .dialog .buttonClick { border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; } .dialog .buttonColor-hilite { border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow; } .dialog .buttonColor .nocolor { padding: 0; } .dialog .buttonColor .nocolor-hilite { background-color: #fff; color: #f00; } .dialog .label { text-align: right; width: 6em; } .dialog .value input { width: 100%; } .dialog legend { font-weight: bold; } .dialog fieldset table { margin: 2px 0; } .dialog .buttons { padding: 1em; text-align: center; } .dialog .resizeHandle { -moz-appearance : resizer; width: 12px; height: 12px; border-bottom: 2px solid #000; border-right: 2px solid #000; cursor : se-resize; } .popupwin { padding: 0; margin: 0; } .popupwin .title { background: #fff; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 10px; border-bottom: 1px solid black; letter-spacing: 2px; } form { margin: 0; border: none; } /** Panels **/ .htmlarea .panels_top { border-bottom : 1px solid; border-color: ButtonShadow; } .htmlarea .panels_right { border-left : 1px solid; border-color: ButtonShadow; } .htmlarea .panels_left { border-right : 1px solid; border-color: ButtonShadow; } .htmlarea .panels_bottom { border-top : 1px solid; border-color: ButtonShadow; } .htmlarea .panel h1 { clear:left; font-size:0.9em; } .htmlarea .panel { overflow:hidden; background-color:white; padding-bottom:0 !IMPORTANT; border: none !IMPORTANT; } .htmlarea .panels_left .panel { border-right:none; border-left:none; } .htmlarea .panels_left h1 { border-right:none; } .htmlarea .panels_right .panel { border-right:none; border-left:none; } .htmlarea .panels_left h1 { border-left:none; } .htmlarea { border: 1px solid black; } .loading { font-family:sans-serif; position:absolute; z-index:998; text-align:center; width:212px; padding: 55px 0 5px 0; border:2px solid #ccc; /* border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;*/ background: url(images/xinha_logo.gif) no-repeat #fff center 5px; } .loading_main { font-size:11px; color:#000; } .loading_sub { font-size:9px; color:#666; text-align:center; } /* Classes for filemanager styles in a dialog. */ .dialog a img { border: 0 none transparent; } .dialog fieldset.collapsed { border: 0 none transparent; } .dialog fieldset.collapsed form { display: none; } .hidden { display: none; } .placesmanager { width: 95%; overflow: auto; } .filemanager { width: 95%; height: 200px; overflow: auto; background-color: #fff; } .filemanager div.file { min-width: 80px; height: 100px; position: relative; float: left; border: 1px outset #666; margin: 4px; } .placesmanager div.file { min-width: 60px; height: 70px; position: relative; float: left; border: 1px outset #666; margin: 4px; } .filemanager div.file:hover, .placesmanager div.file:hover { border: 1px solid #333; background: #fffff3; } .filemanager div.selected, .filemanager div.selected:hover, .placesmanager div.selected, .placesmanager div.selected:hover { background: #ffffda; border: 1px solid #000; } .filemanager .filename { margin: 0.5em; color: #222; } .filemanager div.selected .filename { color: #000; } .filemanager img.thumb { width: 50px; height: 50px; position: absolute; top: 50%; left: 50%; margin: -25px 0 0 -25px; border: 1px solid black; } .filemanager img.icon { width: 32px; height: 32px; position: absolute; top: 50%; left: 50%; margin: -16px 0 0 -16px; } .filemanager img.action { width: 15px; height: 15px; position: absolute; } .filemanager img.delete { bottom: 3px; left: 20px; } .filemanager img.copy { bottom: 3px; left: 3px; }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/Xinha.css
CSS
art
9,639
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- COMPATABILITY FILE -- htmlarea.js is now XinhaCore.js -- -- $HeadURL:http://svn.xinha.webfactional.com/trunk/htmlarea.js $ -- $LastChangedDate:2007-01-15 15:28:57 +0100 (Mo, 15 Jan 2007) $ -- $LastChangedRevision:659 $ -- $LastChangedBy:gogo $ --------------------------------------------------------------------------*/ if ( typeof _editor_url == "string" ) { // Leave exactly one backslash at the end of _editor_url _editor_url = _editor_url.replace(/\x2f*$/, '/'); } else { alert("WARNING: _editor_url is not set! You should set this variable to the editor files path; it should preferably be an absolute path, like in '/htmlarea/', but it can be relative if you prefer. Further we will try to load the editor files correctly but we'll probably fail."); _editor_url = ''; } document.write('<script type="text/javascript" src="'+_editor_url+'XinhaCore.js"></script>');
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/htmlarea.js
JavaScript
art
1,012
// I18N constants // LANG: "si", ENCODING: UTF-8 // Author: Tomaz Kregar, x_tomo_x@email.si // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Krepko", "Italic": "Ležeče", "Underline": "Podčrtano", "Strikethrough": "Prečrtano", "Subscript": "Podpisano", "Superscript": "Nadpisano", "Justify Left": "Poravnaj levo", "Justify Center": "Na sredino", "Justify Right": "Poravnaj desno", "Justify Full": "Porazdeli vsebino", "Ordered List": "Oštevilčevanje", "Bulleted List": "Označevanje", "Decrease Indent": "Zmanjšaj zamik", "Increase Indent": "Povečaj zamik", "Font Color": "Barva pisave", "Background Color": "Barva ozadja", "Horizontal Rule": "Vodoravna črta", "Insert Web Link": "Vstavi hiperpovezavo", "Insert/Modify Image": "Vstavi sliko", "Insert Table": "Vstavi tabelo", "Toggle HTML Source": "Preklopi na HTML kodo", "Enlarge Editor": "Povečaj urejevalnik", "About this editor": "Vizitka za urejevalnik", "Help using editor": "Pomoč za urejevalnik", "Current style": "Trenutni slog", "Undoes your last action": "Razveljavi zadnjo akcijo", "Redoes your last action": "Uveljavi zadnjo akcijo", "Cut selection": "Izreži", "Copy selection": "Kopiraj", "Paste from clipboard": "Prilepi", "OK": "V redu", "Cancel": "Prekliči", "Path": "Pot", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Si v tekstovnem načinu. Uporabi [<>] gumb za prklop nazaj na WYSIWYG." }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/si.js
JavaScript
art
1,713
// I18N constants // LANG: "nl", ENCODING: UTF-8 // Author: Michel Weegeerink (info@mmc-shop.nl), http://mmc-shop.nl // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Vet", "Italic": "Cursief", "Underline": "Onderstrepen", "Strikethrough": "Doorhalen", "Subscript": "Subscript", "Superscript": "Superscript", "Justify Left": "Links uitlijnen", "Justify Center": "Centreren", "Justify Right": "Rechts uitlijnen", "Justify Full": "Uitvullen", "Ordered List": "Nummering", "Bulleted List": "Opsommingstekens", "Decrease Indent": "Inspringing verkleinen", "Increase Indent": "Inspringing vergroten", "Font Color": "Tekstkleur", "Background Color": "Achtergrondkleur", "Horizontal Rule": "Horizontale lijn", "Insert Web Link": "Hyperlink invoegen/aanpassen", "Insert/Modify Image": "Afbeelding invoegen/aanpassen", "Insert Table": "Tabel invoegen", "Toggle HTML Source": "HTML broncode", "Enlarge Editor": "Vergroot Editor", "About this editor": "Over deze editor", "Help using editor": "Xinha help", "Current style": "Huidige stijl", "Undoes your last action": "Ongedaan maken", "Redoes your last action": "Herhalen", "Cut selection": "Knippen", "Copy selection": "Kopi?ren", "Paste from clipboard": "Plakken", "Direction left to right": "Tekstrichting links naar rechts", "Direction right to left": "Tekstrichting rechts naar links", "OK": "OK", "Cancel": "Annuleren", "Path": "Pad", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Je bent in TEKST-mode. Gebruik de [<>] knop om terug te keren naar WYSIWYG-mode.", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "Fullscreen-mode veroorzaakt problemen met Internet Explorer door bugs in de webbrowser die we niet kunnen omzeilen. Hierdoor kunnen de volgende effecten optreden: verknoeide teksten, een verlies aan editor-functionaliteit en/of willekeurig vastlopen van de webbrowser. Als u Windows 95 of 98 gebruikt, is het zeer waarschijnlijk dat u een algemene beschermingsfout (", "Cancel": "Annuleren", "Insert/Modify Link": "Hyperlink invoegen/aanpassen", "New window (_blank)": "Nieuw venster (_blank)", "None (use implicit)": "Geen", "Other": "Ander", "Same frame (_self)": "Zelfde frame (_self)", "Target:": "Doel:", "Title (tooltip):": "Titel (tooltip):", "Top frame (_top)": "Bovenste frame (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "Geef de URL in waar de link naar verwijst" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/nl.js
JavaScript
art
2,794
// I18N constants // LANG: "it", ENCODING: UTF-8 // Author: Mattia Landoni, http://www.webpresident.org/ { "Bold": "Grassetto", "Italic": "Corsivo", "Underline": "Sottolineato", "Strikethrough": "Barrato", "Subscript": "Pedice", "Superscript": "Apice", "Justify Left": "Sinistra", "Justify Center": "Centrato", "Justify Right": "Destra", "Justify Full": "Giustificato", "Ordered List": "Lista numerata", "Bulleted List": "Lista non numerata", "Decrease Indent": "Diminuisci indentazione", "Increase Indent": "Aumenta indentazione", "Font Color": "Colore font", "Background Color": "Colore sfondo", "Horizontal Rule": "Righello orizzontale", "Insert Web Link": "Inserisci link", "Insert/Modify Image": "Inserisci/modifica Immagine", "Insert Table": "Inserisci tabella", "Toggle HTML Source": "Visualizza/nascondi sorgente HTML", "Enlarge Editor": "Allarga editor", "About this editor": "Informazioni su Xinha", "Help using editor": "Aiuto", "Current style": "Stile corrente", "Undoes your last action": "Annulla ultima azione", "Redoes your last action": "Ripeti ultima azione", "Cut selection": "Taglia", "Copy selection": "Copia", "Paste from clipboard": "Incolla", "Direction left to right": "Testo da sx a dx", "Direction right to left": "Testo da dx a sx", "OK": "OK", "Cancel": "Annulla", "Path": "Percorso", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Sei in MODALITA", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "E", "Cancel": "Annulla", "Insert/Modify Link": "Inserisci/modifica link", "New window (_blank)": "Nuova finestra (_blank)", "None (use implicit)": "Niente (usa implicito)", "Other": "Altro", "Same frame (_self)": "Stessa frame (_self)", "Target:": "Target:", "Title (tooltip):": "Title (suggerimento):", "Top frame (_top)": "Pagina intera (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "Devi inserire l'indirizzo a cui punta il link" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/it.js
JavaScript
art
2,080
// I18N constants // LANG: "de", ENCODING: UTF-8 { "Bold": "Fett", "Italic": "Kursiv", "Underline": "Unterstrichen", "Strikethrough": "Durchgestrichen", "Subscript": "Tiefgestellt", "Superscript": "Hochgestellt", "Justify Left": "Linksbündig", "Justify Center": "Zentriert", "Justify Right": "Rechtsbündig", "Justify Full": "Blocksatz", "Ordered List": "Nummerierte Liste", "Bulleted List": "Aufzählungsliste", "Decrease Indent": "Einzug verkleinern", "Increase Indent": "Einzug vergrößern", "Font Color": "Schriftfarbe", "Background Color": "Hindergrundfarbe", "Horizontal Rule": "Horizontale Linie", "Insert Web Link": "Hyperlink einfügen", "Insert/Modify Image": "Bild einfügen/verändern", "Insert Table": "Tabelle einfügen", "Toggle HTML Source": "HTML Quelltext ein/ausschalten", "Enlarge Editor": "Editor vergrößern", "About this editor": "Über diesen Editor", "Help using editor": "Hilfe", "Current style": "Derzeitiger Stil", "Undoes your last action": "Rückgängig", "Redoes your last action": "Wiederholen", "Cut selection": "Ausschneiden", "Copy selection": "Kopieren", "Paste from clipboard": "Einfügen aus der Zwischenablage", "Direction left to right": "Textrichtung von Links nach Rechts", "Direction right to left": "Textrichtung von Rechts nach Links", "Remove formatting": "Formatierung entfernen", "Select all": "Alles markieren", "Print document": "Dokument ausdrucken", "Clear MSOffice tags": "MSOffice filter", "Clear Inline Font Specifications": "Zeichensatz Formatierungen entfernen", "Would you like to clear font typefaces?": "Wollen Sie Zeichensatztypen entfernen", "Would you like to clear font sizes?": "Wollen Sie Zeichensatzgrößen entfernen", "Would you like to clear font colours?": "Wollen sie Zeichensatzfarben entfernen", "Split Block": "Block teilen", "Toggle Borders": "Tabellenränder ein/ausblenden", "Save as": "speichern unter", "Insert/Overwrite": "Einfügen/Überschreiben", "&#8212; format &#8212;": "&#8212; Format &#8212;", "Heading 1": "Überschrift 1", "Heading 2": "Überschrift 2", "Heading 3": "Überschrift 3", "Heading 4": "Überschrift 4", "Heading 5": "Überschrift 5", "Heading 6": "Überschrift 6", "Normal": "Normal (Absatz)", "Address": "Adresse", "Formatted": "Formatiert", //dialogs "OK": "OK", "Cancel": "Abbrechen", "Path": "Pfad", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Sie sind im Text-Modus. Benutzen Sie den [<>] Button, um in den visuellen Modus (WYSIWIG) zu gelangen.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Aus Sicherheitsgründen dürfen Skripte normalerweise nicht auf Ausschneiden/Kopieren/Einfügen zugreifen. Benutzen Sie bitte die entsprechenden Tastatur-Kommandos (Strg + x/c/v).", "You need to select some text before create a link": "Sie müssen einen Text markieren, um einen Link zu erstellen", "Your Document is not well formed. Check JavaScript console for details.": "Ihr Dokument ist in keinem sauberen Format. Benutzen Sie die Javascript Console für weitere Informationen.", "Alignment:": "Ausrichtung:", "Not set": "nicht eingestellt", "Left": "links", "Right": "rechts", "Texttop": "oben bündig", "Absmiddle": "mittig", "Baseline": "Grundlinie", "Absbottom": "unten bündig", "Bottom": "unten", "Middle": "zentriert", "Top": "oben", "Layout": "Layout", "Spacing": "Abstand", "Horizontal:": "horizontal:", "Horizontal padding": "horizontaler Inhaltsabstand", "Vertical:": "vertikal:", "Vertical padding": "vertikaler Inhaltsabstand", "Border thickness:": "Randstärke:", "Leave empty for no border": "leer lassen für keinen Rand", //Insert Link "Insert/Modify Link": "Verknüpfung hinzufügen/ändern", "None (use implicit)": "k.A. (implizit)", "New window (_blank)": "Neues Fenster (_blank)", "Same frame (_self)": "Selber Rahmen (_self)", "Top frame (_top)": "Oberster Rahmen (_top)", "Other": "Anderes", "Target:": "Ziel:", "Title (tooltip):": "Titel (Tooltip):", "URL:": "URL:", "You must enter the URL where this link points to": "Sie müssen eine Ziel-URL angeben für die Verknüpfung angeben", // Insert Table "Insert Table": "Tabelle einfügen", "Rows:": "Zeilen:", "Number of rows": "Zeilenanzahl", "Cols:": "Spalten:", "Number of columns": "Spaltenanzahl", "Width:": "Breite:", "Width of the table": "Tabellenbreite", "Percent": "Prozent", "Pixels": "Pixel", "Em": "Geviert", "Width unit": "Größeneinheit", "Fixed width columns": "Spalten mit fester Breite", "Positioning of this table": "Positionierung der Tabelle", "Cell spacing:": "Zellenabstand:", "Space between adjacent cells": "Raum zwischen angrenzenden Zellen", "Cell padding:": "Innenabstand:", "Space between content and border in cell": "Raum zwischen Inhalt und Rand der Zelle", "You must enter a number of rows": "Bitte geben Sie die Anzahl der Zeilen an", "You must enter a number of columns": "Bitte geben Sie die Anzahl der Spalten an", // Insert Image "Insert Image": "Bild einfügen", "Image URL:": "Bild URL:", "Enter the image URL here": "Bitte geben sie hier die Bild URL ein", "Preview": "Voransicht", "Preview the image in a new window": "Voransicht des Bildes in einem neuen Fenster", "Alternate text:": "Alternativer Text:", "For browsers that don't support images": "für Browser, die keine Bilder unterstützen", "Positioning of this image": "Positionierung dieses Bildes", "Image Preview:": "Bild Voransicht:", "You must enter the URL": "Bitte geben Sie die URL ein", /* "button_bold": "de/bold.gif", "button_italic": "de/italic.gif", "button_underline": "de/underline.gif", */ // Editor Help "Keyboard shortcuts": "Tastaturkürzel", "The editor provides the following key combinations:": "Der Editor unterstützt die folgenden kombinationen:", "new paragraph": "Neuer Absatz(Paragraph)", "insert linebreak": "Harter Umbruch einfügen", "Set format to paragraph": "Setze Formatierung auf Absatz", "Clean content pasted from Word": "Von Word eingefügter Text bereinigen", "Headings": "Überschrift Typ 1 bis 6", "Close": "Schließen", // Loading messages "Loading in progress. Please wait!": "Editor wird geladen. Bitte warten !", "Loading plugin $plugin" : "Plugin $plugin wird geladen", "Register plugin $plugin" : "Plugin $plugin wird registriert", "Constructing object": "Objekt wird generiert", "Generate Xinha framework": "Xinha Framework wird generiert", "Init editor size":"Größe wird berechnet", "Create Toolbar": "Werkzeugleiste wird generiert", "Create Statusbar" : "Statusleiste wird generiert", "Register right panel" : "Rechtes Panel wird generiert", "Register left panel" : "Linkes Panel wird generiert", "Register bottom panel" : "Unteres Panel wird generiert", "Register top panel" : "Oberes Panel wird generiert", "Finishing" : "Laden wird abgeschlossen", // ColorPicker "Click a color..." : "Farbe wählen", "Sample" : "Beispiel", "Web Safe: " : "Web Safe: ", "Color: " : "Farbe: " };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/de.js
JavaScript
art
7,274
// I18N constants // LANG: "pl", ENCODING: UTF-8 // translated: Krzysztof Kotowicz, http://www.eskot.krakow.pl/portfolio/, koto@webworkers.pl { "Bold": "Pogrubienie", "Italic": "Pochylenie", "Underline": "Podkreślenie", "Strikethrough": "Przekreślenie", "Subscript": "Indeks dolny", "Superscript": "Indeks górny", "Justify Left": "Wyrównaj do lewej", "Justify Center": "Wyśrodkuj", "Justify Right": "Wyrównaj do prawej", "Justify Full": "Wyjustuj", "Ordered List": "Numerowanie", "Bulleted List": "Wypunktowanie", "Decrease Indent": "Zmniejsz wcięcie", "Increase Indent": "Zwiększ wcięcie", "Font Color": "Kolor czcionki", "Background Color": "Kolor tła", "Horizontal Rule": "Linia pozioma", "Insert Web Link": "Wstaw adres sieci Web", "Insert/Modify Image": "Wstaw obraz", "Insert Table": "Wstaw tabelę", "Toggle HTML Source": "Edycja WYSIWYG/w źródle strony", "Enlarge Editor": "Pełny ekran", "About this editor": "Informacje o tym edytorze", "Help using editor": "Pomoc", "Current style": "Obecny styl", "Undoes your last action": "Cofa ostatnio wykonane polecenie", "Redoes your last action": "Ponawia ostatnio wykonane polecenie", "Cut selection": "Wycina zaznaczenie do schowka", "Copy selection": "Kopiuje zaznaczenie do schowka", "Paste from clipboard": "Wkleja zawartość schowka", "Direction left to right": "Kierunek tekstu lewo-prawo", "Direction right to left": "Kierunek tekstu prawo-lewo", "Remove formatting": "Usuń formatowanie", "Select all": "Zaznacz wszystko", "Print document": "Drukuj dokument", "Clear MSOffice tags": "Wyczyść tagi MSOffice", "Clear Inline Font Specifications": "Wycisz bezpośrednie przypisania czcionek", "Split Block": "Podziel blok", "Toggle Borders": "Włącz / wyłącz ramki", "&#8212; format &#8212;": "&#8212; Format &#8212;", "Heading 1": "Nagłówek 1", "Heading 2": "Nagłówek 2", "Heading 3": "Nagłówek 3", "Heading 4": "Nagłówek 4", "Heading 5": "Nagłówek 5", "Heading 6": "Nagłówek 6", "Normal": "Normalny", "Address": "Adres", "Formatted": "Preformatowany", //dialogs "OK": "OK", "Cancel": "Anuluj", "Path": "Ścieżka", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Jesteś w TRYBIE TEKSTOWYM. Użyj przycisku [<>], aby przełączyć się na tryb WYSIWYG.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Przycisk Wklej nie działa w przeglądarkach Mozilla z uwagi na ustawienia bezpieczeństwa. Naciśnij CRTL-V, aby wkleić zawartość schowka.", "Alignment:": "Wyrównanie:", "Not set": "Nie ustawione", "Left": "Do lewej", "Right": "Do prawej", "Texttop": "Góra tekstu", "Absmiddle": "Abs. środek", "Baseline": "Linia bazowa", "Absbottom": "Abs. dół", "Bottom": "Dół", "Middle": "Środek", "Top": "Góra", "Layout": "Layout", "Spacing": "Spacjowanie", "Horizontal:": "Poziome:", "Horizontal padding": "Wcięcie poziome", "Vertical:": "Pionowe:", "Vertical padding": "Wcięcie pionowe", "Border thickness:": "Grubość obramowania:", "Leave empty for no border": "Bez ramek - zostaw puste", //Insert Link "Insert/Modify Link": "Wstaw/edytuj odnośnik", "None (use implicit)": "Brak", "New window (_blank)": "Nowe okno (_blank)", "Same frame (_self)": "Ta sama ramka (_self)", "Top frame (_top)": "Główna ramka (_top)", "Other": "Inne", "Target:": "Okno docelowe:", "Title (tooltip):": "Tytuł (tooltip):", "URL:": "URL:", "You must enter the URL where this link points to": "Musisz podać URL, na jaki będzie wskazywał odnośnik", // Insert Table "Insert Table": "Wstaw tabelę", "Rows:": "Wierszy:", "Number of rows": "Liczba wierszy", "Cols:": "Kolumn:", "Number of columns": "Liczba kolumn", "Width:": "Szerokość:", "Width of the table": "Szerokość tabeli", "Percent": "Procent", "Pixels": "Pikseli", "Em": "Em", "Width unit": "Jednostka", "Fixed width columns": "Kolumny o stałej szerokości", "Positioning of this table": "Pozycjonowanie tabeli", "Cell spacing:": "Odstęp komórek:", "Space between adjacent cells": "Przestrzeń pomiędzy komórkami", "Cell padding:": "Wcięcie komórek:", "Space between content and border in cell": "Przestrzeń między krawędzią a zawartością komórki", // Insert Image "Insert Image": "Wstaw obrazek", "Image URL:": "URL obrazka:", "Enter the image URL here": "Podaj URL obrazka", "Preview": "Podgląd", "Preview the image in a new window": "Podgląd obrazka w nowym oknie", "Alternate text:": "Tekst alternatywny:", "For browsers that don't support images": "Dla przeglądarek, które nie obsługują obrazków", "Positioning of this image": "Pozycjonowanie obrazka", "Image Preview:": "Podgląd obrazka:" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/pl.js
JavaScript
art
4,918
// I18N constants // LANG: "hu", ENCODING: UTF-8 // Author: Miklós Somogyi, <somogyine@vnet.hu> // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Félkövér", "Italic": "Dőlt", "Underline": "Aláhúzott", "Strikethrough": "Áthúzott", "Subscript": "Alsó index", "Superscript": "Felső index", "Justify Left": "Balra zárt", "Justify Center": "Középre zárt", "Justify Right": "Jobbra zárt", "Justify Full": "Sorkizárt", "Ordered List": "Számozott lista", "Bulleted List": "Számozatlan lista", "Decrease Indent": "Behúzás csökkentése", "Increase Indent": "Behúzás növelése", "Font Color": "Karakterszín", "Background Color": "Háttérszín", "Horizontal Rule": "Elválasztó vonal", "Insert Web Link": "Hiperhivatkozás beszúrása", "Insert/Modify Image": "Kép beszúrása", "Insert Table": "Táblázat beszúrása", "Toggle HTML Source": "HTML forrás be/ki", "Enlarge Editor": "Szerkesztő külön ablakban", "About this editor": "Névjegy", "Help using editor": "Súgó", "Current style": "Aktuális stílus", "Undoes your last action": "Visszavonás", "Redoes your last action": "Újra végrehajtás", "Cut selection": "Kivágás", "Copy selection": "Másolás", "Paste from clipboard": "Beillesztés", "Direction left to right": "Irány balról jobbra", "Direction right to left": "Irány jobbról balra", "OK": "Rendben", "Cancel": "Mégsem", "Path": "Hierarchia", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Forrás mód. Visszaváltás [<>] gomb", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "A teljesképrenyős szerkesztés hibát okozhat Internet Explorer használata esetén, ez a böngésző a hibája, amit nem tudunk kikerülni. Szemetet észlelhet a képrenyőn, illetve néhány funkció hiányozhat és/vagy véletlenszerűen lefagyhat a böngésző. Windows 9x operaciós futtatása esetén elég valószínű, hogy ", "Cancel": "Mégsem", "Insert/Modify Link": "Hivatkozás Beszúrása/Módosítása", "New window (_blank)": "Új ablak (_blank)", "None (use implicit)": "Nincs (use implicit)", "Other": "Más", "Same frame (_self)": "Ugyanabba a keretbe (_self)", "Target:": "Cél:", "Title (tooltip):": "Cím (tooltip):", "Top frame (_top)": "Felső keret (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "Be kell írnia az URL-t, ahova a hivatkozás mutasson" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/hu.js
JavaScript
art
2,765
// I18N constants // LANG: "ru", ENCODING: UTF-8 // Author: Yulya Shtyryakova, <yulya@vdcom.ru> // Some additions by: Alexey Kirpichnikov, <alexkir@kiwistudio.ru> // I took French version as a source of English phrases because French version was the most comprehensive // (fr.js was the largest file, actually) %) // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Полужирный", "Italic": "Наклонный", "Underline": "Подчеркнутый", "Strikethrough": "Перечеркнутый", "Subscript": "Нижний индекс", "Superscript": "Верхний индекс", "Justify Left": "По левому краю", "Justify Center": "По центру", "Justify Right": "По правому краю", "Justify Full": "По ширине", "Ordered List": "Нумерованный список", "Bulleted List": "Маркированный список", "Decrease Indent": "Уменьшить отступ", "Increase Indent": "Увеличить отступ", "Font Color": "Цвет шрифта", "Background Color": "Цвет фона", "Horizontal Rule": "Горизонтальный разделитель", "Insert Web Link": "Вставить гиперссылку", "Insert/Modify Image": "Вставить изображение", "Insert Table": "Вставить таблицу", "Toggle HTML Source": "Показать Html-код", "Enlarge Editor": "Увеличить редактор", "About this editor": "О редакторе", "Help using editor": "Помощь", "Current style": "Текущий стиль", "Undoes your last action": "Отменить", "Redoes your last action": "Повторить", "Cut selection": "Вырезать", "Copy selection": "Копировать", "Paste from clipboard": "Вставить", "Direction left to right": "Направление слева направо", "Direction right to left": "Направление справа налево", "Remove formatting": "Убрать форматирование", "Select all": "Выделить все", "Print document": "Печать", "Clear MSOffice tags": "Удалить разметку MSOffice", "Clear Inline Font Specifications": "Удалить непосредственное задание шрифтов", "Would you like to clear font typefaces?": "Удалить типы шрифтов?", "Would you like to clear font sizes?": "Удалить размеры шрифтов ?", "Would you like to clear font colours?": "Удалить цвета шрифтов ?", "Split Block": "Разделить блок", "Toggle Borders": "Включить/выключить отображение границ", "Save as": "Сохранить как", "Insert/Overwrite": "Вставка/замена", "&#8212; format &#8212;": "&#8212; форматирование &#8212;", "Heading 1": "Заголовок 1", "Heading 2": "Заголовок 2", "Heading 3": "Заголовок 3", "Heading 4": "Заголовок 4", "Heading 5": "Заголовок 5", "Heading 6": "Заголовок 6", "Normal": "Обычный текст", "Address": "Адрес", "Formatted": "Отформатированный текст", "&#8212; font &#8212;": "&#8212; шрифт &#8212;", "&#8212; size &#8212;": "&#8212; размер &#8212;", // Диалоги "OK": "OK", "Cancel": "Отмена", "Path": "Путь", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Вы в режиме отображения Html-кода. нажмите кнопку [<>], чтобы переключиться в визуальный режим.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Кнопка Вставить не работает в браузерах на основе Mozilla (по техническим причинам, связанным с безопасностью). Нажмите Ctrl-V на клавиатуре, чтобы вставить.", "Your Document is not well formed. Check JavaScript console for details.": "Ваш документ неправильно сформирован. Посмотрите Консоль JavaScript, чтобы узнать подробности.", "Alignment:": "Выравнивание", "Not set": "Не установлено", "Left": "По левому краю", "Right": "По правому краю", "Texttop": "По верхней границе текста", "Absmiddle": "По середине текста", "Baseline": "По нижней границе текста", "Absbottom": "По нижней границе", "Bottom": "По нижнему краю", "Middle": "Посредине", "Top": "По верхнему краю", "Layout": "Расположение", "Spacing": "Поля", "Horizontal:": "По горизонтали", "Horizontal padding": "Горизонтальные поля", "Vertical:": "По вертикали", "Vertical padding": "Вертикальные поля", "Border thickness:": "Толщина рамки", "Leave empty for no border": "Оставьте пустым, чтобы убрать рамку", //Insert Link "Insert/Modify Link": "Вставка/изменение ссылки", "None (use implicit)": "По умолчанию", "New window (_blank)": "Новое окно (_blank)", "Same frame (_self)": "То же окно (_self)", "Top frame (_top)": "Родительское окно (_top)", "Other": "Другое", "Target:": "Открывать в окне:", "Title (tooltip):": "Всплывающая подсказка", "URL:": "URL:", "You must enter the URL where this link points to": "Вы должны указать URL, на который будет указывать ссылка", "You need to select some text before creating a link": "Вы должны выделить текст, который будет преобразован в ссылку", // Insert Table "Insert Table": "Вставка таблицы", "Rows:": "Строки", "Number of rows": "Количество строк", "Cols:": "Столбцы", "Number of columns": "Количество столбцов", "Width:": "Ширина", "Width of the table": "Ширина таблицы", "Percent": "проценты", "Pixels": "пикселы", "Em": "em", "Width unit": "Единицы измерения", "Fixed width columns": "Столбцы фиксированной ширины", "Positioning of this table": "Расположение таблицы", "Cell spacing:": "Расстояние между ячейками", "Space between adjacent cells": "Расстояние между соседними ячейками", "Cell padding:": "Поля в ячейках", "Space between content and border in cell": "Расстояние между границей ячейки и текстом", "You must enter a number of rows": "Вы должны ввести количество строк", "You must enter a number of columns": "Вы должны ввести количество столбцов", // Insert Image "Insert Image": "Вставка изображения", "Image URL:": "URL изображения", "Enter the image URL here": "Вставьте адрес изображения", "Preview": "Предварительный просмотр", "Preview the image in a new window": "Предварительный просмотр в отдельном окне", "Alternate text:": "Альтернативный текст", "For browsers that don't support images": "Для браузеров, которые не отображают картинки", "Positioning of this image": "Расположение изображения", "Image Preview:": "Предварительный просмотр", "You must enter the URL": "Вы должны ввести URL", // Editor Help "Xinha Help": "Помощь", "Editor Help": "Помощь", "Keyboard shortcuts": "Горячие клавиши", "The editor provides the following key combinations:": "Редактор поддерживает следующие комбинации клавиш:", "ENTER": "ENTER", "new paragraph": "новый абзац", "SHIFT-ENTER": "SHIFT+ENTER", "insert linebreak": "перенос строки", "Set format to paragraph": "Отформатировать абзац", "Clean content pasted from Word": "Очистить текст, вставленный из Word", "Headings": "Заголовки", "Close": "Закрыть", // Loading messages "Loading in progress. Please wait !": "Загрузка... Пожалуйста, подождите.", "Constructing main object": "Создание главного объекта", "Constructing object": "Создание объекта", "Register panel right": "Регистрация правой панели", "Register panel left": "Регистрация левой панели", "Register panel top": "Регистрация верхней панели", "Register panel bottom": "Регистрация нижней панели", "Create Toolbar": "Создание панели инструментов", "Create StatusBar": "Создание панели состояния", "Generate Xinha object": "Создание объекта Xinha", "Init editor size": "Инициализация размера редактора", "Init IFrame": "инициализация iframe", "Register plugin $plugin": "Регистрация $plugin" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/ru.js
JavaScript
art
10,096
// I18N constants -- Chinese GB // by Dave Lo -- dlo@interactivetools.com { "Bold": "粗体", "Italic": "斜体", "Underline": "底线", "Strikethrough": "删除线", "Subscript": "下标", "Superscript": "上标", "Justify Left": "位置靠左", "Justify Center": "位置居中", "Justify Right": "位置靠右", "Justify Full": "位置左右平等", "Ordered List": "顺序清单", "Bulleted List": "无序清单", "Decrease Indent": "减小行前空白", "Increase Indent": "加宽行前空白", "Font Color": "文字颜色", "Background Color": "背景颜色", "Horizontal Rule": "水平线", "Insert Web Link": "插入连结", "Insert/Modify Image": "插入图形", "Insert Table": "插入表格", "Toggle HTML Source": "切换HTML原始码", "Enlarge Editor": "放大", "About this editor": "关於 Xinha", "Help using editor": "说明", "Current style": "字体例子" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/gb.js
JavaScript
art
928
// I18N constants // LANG: "sv", ENCODING: UTF-8 // Swedish version for htmlArea v3.0 // Initital translation by pat <pat@engvall.nu> // Synced with additional contants in rev. 477 (Mar 2006) by Thomas Loo <tloo@saltstorm.net> { "Bold": "Fet", "Italic": "Kursiv", "Underline": "Understruken", "Strikethrough": "Genomstruken", "Subscript": "Nedsänkt", "Superscript": "Upphöjd", "Justify Left": "Vänsterjustera", "Justify Center": "Centrera", "Justify Right": "Högerjustera", "Justify Full": "Marginaljustera", "Ordered List": "Numrerad lista", "Bulleted List": "Punktlista", "Decrease Indent": "Minska indrag", "Increase Indent": "Öka indrag", "Font Color": "Textfärg", "Background Color": "Bakgrundsfärg", "Horizontal Rule": "Vågrät linje", "Insert Web Link": "Infoga länk", "Insert/Modify Image": "Infoga bild", "Toggle HTML Source": "Visa källkod", "Enlarge Editor": "Visa i eget fönster", "About this editor": "Om denna editor", "Help using editor": "Hjälp", "Current style": "Nuvarande stil", "Undoes your last action": "Ångra kommando", "Redoes your last action": "Upprepa kommando", "Select all": "Markera allt", "Print document": "Skriv ut", "Clear MSOffice tags": "Städa bort MS Office taggar", "Clear Inline Font Specifications": "Rensa inbäddad typsnittsinformation", "Remove formatting": "Rensa formattering", "Toggle Borders": "Objektramar", "Split Block": "Dela block", "Direction left to right": "Vänster till höger", "Direction right to left": "Höger till vänster", "Insert/Overwrite": "Infoga/Skriv över", "OK": "OK", "Cancel": "Avbryt", "Path": "Objekt", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Du befinner dig i texläge. Klicka på ikonen [<>] ovan för att växla tillbaka till WYSIWIG läge", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "Visning i fullskärmsläga fungerar dåligt i din webläsare. Möjliga problem resulterar i en ryckig editor, saknade editorfunktioner och/eller att webläsaren kraschar. Om du använder Windows 95/98 finns också möjligheten att Windows kraschar.\n\nTryck ", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Denna knapp fungerar ej i Mozillabaserad webläsare, använd istället snabbtangenterna CTRL-V på tangentbordet för att klistra in.", "Insert/Modify Link": "Redigera länk", "New window (_blank)": "Nytt fönster (_blank)", "None (use implicit)": "Ingen (använd standardinställing)", "Other": "Annan", "Same frame (_self)": "Samma ram (_self)", "Target:": "Mål:", "Title (tooltip):": "Titel (tooltip):", "Top frame (_top)": "Toppram (_top)", "URL:": "Sökväg:", "You must enter the URL where this link points to": "Du måsta ange en adress till vilken länken skall peka på", "Would you like to clear font typefaces?": "Radera alla typsnittsinformation ?", "Would you like to clear font sizes?": "Radera alla fontstorlekar ?", "Would you like to clear font colours?": "Ta bort all textfärger ?", "You need to select some text before creating a link": "Du måsta markera ett objekt att applicera länken på!", // Insert Table "Insert Table": "Infoga tabell", "Rows:": "Rader:", "Number of rows": "Antal rader", "Cols:": "Kolumner:", "Number of columns": "Antal kolumner", "Width:": "Bredd:", "Width of the table": "Tabellbredd", "Percent": "Procent", "Pixels": "Pixlar", "Em": "", "Width unit": "Breddenheter", "Fixed width columns": "Fixerad bredd", "Alignment:": "Marginaljustering", "Positioning of this table": "Tabellposition", "Border thickness:": "Ramtjocklek", "Leave empty for no border": "Lämna fältet tomt för att undvika ramar", "Spacing": "Cellegenskaper", "Cell spacing:": "Cellmarginaler:", "Space between adjacent cells": "Utrymme mellan celler", "Cell padding:": "Cellindrag:", "Space between content and border in cell": "Utrymme mellan ram och cellinnehåll", "You must enter a number of rows": "Ange ental rader", "You must enter a number of columns": "Ange antal kolumner", // Editor Help "Keyboard shortcuts": "Snabbtangenter", "The editor provides the following key combinations:": "Editorn nyttjar följande kombinationer:", "new paragraph": "Ny paragraf ", "insert linebreak": "Infoga radbrytning ", "Set format to paragraph": "Aktivera paragrafläge", "Clean content pasted from Word": "Rensa innehåll inklistrat från MS Word", "Headings": "Skapa standardrubrik", "Cut selection": "Klipp ut markering", "Copy selection": "Kopiera markering", "Paste from clipboard": "Klistra in", "Close": "Stäng", // Loading messages "Loading in progress. Please wait !": "Editorn laddas. Vänta...", "Constructing main object": "Skapar huvudobjekt", "Create Toolbar": "Skapar verktygspanel", "Register panel right": "Registerar panel höger", "Register panel left": "Registerar panel vänster", "Register panel top": "Registerar toppanel", "Register panel bottom": "Registerar fotpanel" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/sv.js
JavaScript
art
5,207
// I18N constants // LANG: "fr", ENCODING: UTF-8 { "Bold": "Gras", "Italic": "Italique", "Underline": "Souligné", "Strikethrough": "Barré", "Subscript": "Indice", "Superscript": "Exposant", "Justify Left": "Aligner à gauche", "Justify Center": "Centrer", "Justify Right": "Aligner à droite", "Justify Full": "Justifier", "Ordered List": "Liste numérotée", "Bulleted List": "Liste à puces", "Decrease Indent": "Diminuer le retrait", "Increase Indent": "Augmenter le retrait", "Font Color": "Couleur de police", "Background Color": "Surlignage", "Horizontal Rule": "Ligne horizontale", "Insert Web Link": "Insérer un lien", "Insert/Modify Image": "Insérer / Modifier une image", "Insert Table": "Insérer un tableau", "Toggle HTML Source": "Afficher / Masquer code source", "Enlarge Editor": "Agrandir l'éditeur", "About this editor": "A propos", "Help using editor": "Aide", "Current style": "Style courant", "Undoes your last action": "Annuler la dernière action", "Redoes your last action": "Répéter la dernière action", "Cut selection": "Couper la sélection", "Copy selection": "Copier la sélection", "Paste from clipboard": "Coller depuis le presse-papier", "Direction left to right": "Direction de gauche à droite", "Direction right to left": "Direction de droite à gauche", "Remove formatting": "Supprimer mise en forme", "Select all": "Tout sélectionner", "Print document": "Imprimer document", "Clear MSOffice tags": "Supprimer tags MSOffice", "Clear Inline Font Specifications": "Supprimer paramètres inline de la police", "Would you like to clear font typefaces?": "Voulez-vous supprimer les types ?", "Would you like to clear font sizes?": "Voulez-vous supprimer les tailles ?", "Would you like to clear font colours?": "Voulez-vous supprimer les couleurs ?", "Split Block": "Séparer les blocs", "Toggle Borders": "Afficher / Masquer les bordures", "Save as": "Enregistrer sous", "Insert/Overwrite": "Insertion / Remplacement", "&#8212; format &#8212;": "&#8212; Format &#8212;", "Heading 1": "Titre 1", "Heading 2": "Titre 2", "Heading 3": "Titre 3", "Heading 4": "Titre 4", "Heading 5": "Titre 5", "Heading 6": "Titre 6", "Normal": "Normal", "Address": "Adresse", "Formatted": "Formaté", //dialogs "OK": "OK", "Cancel": "Annuler", "Path": "Chemin", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Vous êtes en MODE TEXTE. Appuyez sur le bouton [<>] pour retourner au mode WYSIWYG.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Le bouton Coller ne fonctionne pas sur les navigateurs basés sur Mozilla (pour des raisons de sécurité). Pressez CTRL-V au clavier pour coller directement.", "Your Document is not well formed. Check JavaScript console for details.": "Le document est mal formé. Vérifiez la console JavaScript pour plus de détails.", "Alignment:": "Alignement", "Not set": "Indéfini", "Left": "Gauche", "Right": "Droite", "Texttop": "Texttop", "Absmiddle": "Absmiddle", "Baseline": "Baseline", "Absbottom": "Absbottom", "Bottom": "Bas", "Middle": "Milieu", "Top": "Haut", "Layout": "Mise en page", "Spacing": "Espacement", "Horizontal:": "Horizontal", "Horizontal padding": "Marge horizontale interne", "Vertical:": "Vertical", "Vertical padding": "Marge verticale interne", "Border thickness:": "Epaisseur de bordure", "Leave empty for no border": "Laisser vide pour pas de bordure", //Insert Link "Insert/Modify Link": "Insérer / Modifier un lien", "None (use implicit)": "Aucune (implicite)", "New window (_blank)": "Nouvelle fenêtre (_blank)", "Same frame (_self)": "Même frame (_self)", "Top frame (_top)": "Frame principale (_top)", "Other": "Autre", "Target:": "Cible", "Title (tooltip):": "Texte alternatif", "URL:": "URL:", "You must enter the URL where this link points to": "Vous devez entrer l'URL de ce lien", "You need to select some text before creating a link": "Vous devez sélectionner du texte avant de créer un lien", // Insert Table "Insert Table": "Insérer un tableau", "Rows:": "Lignes", "Number of rows": "Nombre de lignes", "Cols:": "Colonnes", "Number of columns": "Nombre de colonnes", "Width:": "Largeur", "Width of the table": "Largeur du tableau", "Percent": "Pourcent", "Pixels": "Pixels", "Em": "Em", "Width unit": "Unités de largeur", "Fixed width columns": "Colonnes à taille fixe", "Positioning of this table": "Position du tableau", "Cell spacing:": "Espacement", "Space between adjacent cells": "Espace entre les cellules adjacentes", "Cell padding:": "Marge interne", "Space between content and border in cell": "Espace entre le contenu et la bordure d'une cellule", "You must enter a number of rows": "Vous devez entrer le nombre de lignes", "You must enter a number of columns": "Vous devez entrer le nombre de colonnes", // Insert Image "Insert Image": "Insérer une image", "Image URL:": "URL image", "Enter the image URL here": "Entrer l'URL de l'image ici", "Preview": "Prévisualiser", "Preview the image in a new window": "Prévisualiser l'image dans une nouvelle fenêtre", "Alternate text:": "Texte alternatif", "For browsers that don't support images": "Pour les navigateurs qui ne supportent pas les images", "Positioning of this image": "Position de l'image", "Image Preview:": "Prévisualisation", "You must enter the URL": "Vous devez entrer l'URL", // toolbar /* "button_bold": "fr/bold.gif", "button_underline": "fr/underline.gif", "button_strikethrough": "fr/strikethrough.gif", */ // Editor Help "Xinha Help": "Aide Xinha", "Editor Help": "Aide de l'éditeur", "Keyboard shortcuts": "Raccourcis clavier", "The editor provides the following key combinations:": "L'éditeur fournit les combinaisons de touches suivantes :", "ENTER": "ENTREE", "new paragraph": "Nouveau paragraphe", "SHIFT-ENTER": "SHIFT+ENTREE", "insert linebreak": "Insère un saut de ligne", "Set format to paragraph": "Applique le format paragraphe", "Clean content pasted from Word": "Nettoyage du contenu copié depuis Word", "Headings": "Titres", "Close": "Fermer", // Loading messages "Loading in progress. Please wait!": "Chargement en cours. Veuillez patienter!", "Finishing" : "Chargement bientôt terminé", "Constructing object": "Construction de l'objet", "Create Toolbar": "Construction de la barre d'icones", "Create Statusbar": "Construction de la barre de status", "Register right panel" : "Enregistrement du panneau droit", "Register left panel" : "Enregistrement du panneau gauche", "Register bottom panel" : "Enregistrement du panneau supérieur", "Register top panel" : "Enregistrement du panneau inférieur", "Generate Xinha framework": "Génération de Xinha", "Init editor size": "Initialisation de la taille d'édition", "Init IFrame": "Initialisation de l'iframe", "Register plugin $plugin": "Enregistrement du plugin $plugin", "Loading plugin $plugin" : "Chargement du plugin $plugin" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/fr.js
JavaScript
art
7,246
// I18N constants // LANG: "ja", ENCODING: UTF-8N { "Bold": "太字", "Italic": "斜体", "Underline": "下線", "Strikethrough": "打ち消し線", "Subscript": "下付き添え字", "Superscript": "上付き添え字", "Justify Left": "左寄せ", "Justify Center": "中央寄せ", "Justify Right": "右寄せ", "Justify Full": "均等割付", "Ordered List": "番号付き箇条書き", "Bulleted List": "記号付き箇条書き", "Decrease Indent": "インデント解除", "Increase Indent": "インデント設定", "Font Color": "文字色", "Background Color": "背景色", "Horizontal Rule": "水平線", "Insert Web Link": "リンクの挿入", "Insert/Modify Image": "画像の挿入/修正", "Insert Table": "テーブルを挿入", "Toggle HTML Source": "HTML編集モードを切替", "Enlarge Editor": "エディタを最大化", "About this editor": "バージョン情報", "Help using editor": "ヘルプ", "Current style": "現在のスタイル", "Undoes your last action": "元に戻す", "Redoes your last action": "やり直し", "Cut selection": "切り取り", "Copy selection": "コピー", "Paste from clipboard": "貼り付け", "Direction left to right": "左から右へ", "Direction right to left": "右から左へ", "Remove formatting": "書式削除", "Select all": "すべて選択", "Print document": "印刷", "Clear MSOffice tags": "MSOfficeタグをクリア", "Clear Inline Font Specifications": "インラインフォント指定をクリア", "Would you like to clear font typefaces?": "フォント名をクリアしますか?", "Would you like to clear font sizes?": "サイズをクリアしますか?", "Would you like to clear font colours?": "色をクリアしますか?", "Split Block": "領域分割", "Toggle Borders": "境界線の切替", "Save as": "名前をつけて保存", "Insert/Overwrite": "挿入/上書き", "&#8212; format &#8212;": "&#8212; 書式 &#8212;", "Heading 1": "見出し1", "Heading 2": "見出し2", "Heading 3": "見出し3", "Heading 4": "見出し4", "Heading 5": "見出し5", "Heading 6": "見出し6", "Normal": "標準", "Address": "アドレス", "Formatted": "整形済み", "&#8212; font &#8212;": "&#8212; フォント &#8212;", "&#8212; size &#8212;": "&#8212; サイズ &#8212;", //dialogs "OK": "OK", "Cancel": "中止", "Path": "パス", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "テキストモードで操作しています。WYSIWYG編集に戻るには[<>]ボタンを使ってください。", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "MozillaベースのWebブラウザでは、貼り付けボタンは機能しません(技術的なセキュリティ上の理由で)。Ctrl+Vキーを押して直接貼り付けてください。", "Your Document is not well formed. Check JavaScript console for details.": "この文書には構文的な問題があります。詳細はJavaScriptコンソールを参照してください。", "You need to select some text before creating a link": "リンクを作成するにはテキストを選択する必要があります", "Alignment:": "行揃え:", "Not set": "なし", "Left": "左", "Right": "右", "Texttop": "テキスト上部", "Absmiddle": "中央(絶対的)", "Baseline": "ベースライン", "Absbottom": "下(絶対的)", "Bottom": "下", "Middle": "中央", "Top": "上", "Layout": "レイアウト", "Spacing": "間隔", "Horizontal:": "水平:", "Horizontal padding": "水平余白", "Vertical:": "垂直:", "Vertical padding": "垂直余白", "Border thickness:": "境界線の太さ:", "Leave empty for no border": "境界線がない場合は空のままにする", //Insert Link "Insert/Modify Link": "リンクの挿入/修正", "None (use implicit)": "なし (デフォルトに任せる)", "New window (_blank)": "新しいウィンドウ (_blank)", "Same frame (_self)": "自己フレーム内 (_self)", "Top frame (_top)": "最上位フレーム (_top)", "Other": "その他", "Target:": "ターゲット:", "Title (tooltip):": "タイトル:", "URL:": "URL:", "You must enter the URL where this link points to": "このリンクが指し示すURLを入力してください", // Insert Table "Insert Table": "テーブルの挿入", "Rows:": "行:", "Number of rows": "行数", "Cols:": "列:", "Number of columns": "列数", "Width:": "幅:", "Width of the table": "テーブルの幅", "Percent": "パーセント(%)", "Pixels": "ピクセル(px)", "Em": "相対値(em)", "Width unit": "幅の単位", "Fixed width columns": "列の幅を固定", "Positioning of this table": "このテーブルの配置", "Cell spacing:": "セル間隔:", "Space between adjacent cells": "隣接するセル間の距離", "Cell padding:": "セル余白:", "Space between content and border in cell": "セル内における内容と境界線との距離", "You must enter a number of rows": "行数を入力してください", "You must enter a number of columns": "列数を入力してください", // Insert Image "Insert Image": "画像の挿入", "Image URL:": "画像URL:", "Enter the image URL here": "画像のURLをここに入力します", "Preview": "表示", "Preview the image in a new window": "ウィンドウで画像を表示", "Alternate text:": "代替テキスト:", "For browsers that don't support images": "画像表示をサポートしないブラウザに必要です", "Positioning of this image": "画像の配置", "Image Preview:": "画像表示:", "You must enter the URL": "URLを入力する必要があります", //"button_bold": "fr/bold.gif", //"button_underline": "fr/underline.gif", //"button_strikethrough": "fr/strikethrough.gif", // Editor Help "Xinha Help": "ヘルプ", "Editor Help": "エディタのヘルプ", "Keyboard shortcuts": "キーボードショートカット", "The editor provides the following key combinations:": "エディタは以下のキー操作を提供しています:", "ENTER": "ENTER", "new paragraph": "新規段落", "SHIFT-ENTER": "SHIFT+ENTER", "insert linebreak": "段落内改行の挿入", "Set format to paragraph": "段落書式の設定", "Clean content pasted from Word": "Wordから貼り付けられた内容の清書", "Headings": "見出し", "Close": "閉じる", // Loading messages "Loading in progress. Please wait!": "ロード中です。しばらくお待ちください", "Loading plugin $plugin" : "ロード中プラグイン $plugin", "Register plugin $plugin" : "登録中プラグイン $plugin", "Constructing object": "オブジェクト構築中", "Generate Xinha framework": "Xinhaフレームワーク生成中", "Init editor size":"エディタサイズの初期化", "Create Toolbar": "ツールバーの作成", "Create Statusbar" : "ステータスバーの作成", "Register right panel" : "登録 右パネル", "Register left panel" : "登録 左パネル", "Register bottom panel" : "登録 下パネル", "Register top panel" : "登録 上パネル", "Finishing" : "完了", // ColorPicker "Click a color..." : "色をクリック...", "Sample" : "サンプル", "Web Safe: " : "Webセーフ: ", "Color: " : "色: " };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/ja.js
JavaScript
art
7,571
// I18N constants // LANG: "cz", ENCODING: UTF-8 // Author: Jiri Löw, <jirilow@jirilow.com> // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Tučně", "Italic": "Kurzíva", "Underline": "Podtržení", "Strikethrough": "Přeškrtnutí", "Subscript": "Dolní index", "Superscript": "Horní index", "Justify Left": "Zarovnat doleva", "Justify Center": "Na střed", "Justify Right": "Zarovnat doprava", "Justify Full": "Zarovnat do stran", "Ordered List": "Seznam", "Bulleted List": "Odrážky", "Decrease Indent": "Předsadit", "Increase Indent": "Odsadit", "Font Color": "Barva písma", "Background Color": "Barva pozadí", "Horizontal Rule": "Vodorovná čára", "Insert Web Link": "Vložit odkaz", "Insert/Modify Image": "Vložit obrázek", "Insert Table": "Vložit tabulku", "Toggle HTML Source": "Přepnout HTML", "Enlarge Editor": "Nové okno editoru", "About this editor": "O této aplikaci", "Help using editor": "Nápověda aplikace", "Current style": "Zvolený styl", "Undoes your last action": "Vrátí poslední akci", "Redoes your last action": "Opakuje poslední akci", "Cut selection": "Vyjmout", "Copy selection": "Kopírovat", "Paste from clipboard": "Vložit", "OK": "OK", "Cancel": "Zrušit", "Path": "Cesta", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Jste v TEXTOVÉM REŽIMU. Použijte tlačítko [<>] pro přepnutí do WYSIWIG." }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/cz.js
JavaScript
art
1,694
// I18N constants // LANG: "da", ENCODING: UTF-8 // Author: rene, <rene@laerke.net> // Niels Baggesen, <nba@users.sourceforge.net>, 0.95, 2009-08-15 { "Bold": "Fed", "Italic": "Kursiv", "Underline": "Understregning", "Strikethrough": "Gennemstregning", "Subscript": "Sænket skrift", "Superscript": "Hævet skrift", "Justify Left": "Venstrejuster", "Justify Center": "Centrer", "Justify Right": "Højrejuster", "Justify Full": "Lige margener", "Ordered List": "Ordnet liste", "Bulleted List": "Punktliste", "Decrease Indent": "Formindsk indrykning", "Increase Indent": "Forøg indrykning", "Font Color": "Skriftfarve", "Background Color": "Baggrundsfarve", "Horizontal Rule": "Vandret streg", "Insert Web Link": "Indsæt hyperlink", "Insert/Modify Image": "Indsæt/udskift billede", "Insert Table": "Indsæt tabel", "Toggle HTML Source": "HTML visning", "Enlarge Editor": "Vis editor i popup", "About this editor": "Om Xinha", "Help using editor": "Hjælp", "Current style": "Anvendt stil", "Undoes your last action": "Fortryd sidste ændring", "Redoes your last action": "Gentag sidste ændring", "Cut selection": "Klip", "Copy selection": "Kopier", "Paste from clipboard": "Indsæt", "Direction left to right": "Tekst venstre mod højre", "Direction right to left": "Tekst højre mod venstre", "Remove formatting": "Fjern formatering", "Select all": "Vælg alt", "Print document": "Udskriv dokument", "Clear MSOffice tags": "MSOffice filter", "Clear Inline Font Specifications": "Fjern skrift valg", "Would you like to clear font typefaces?": "Vil du fjern skriftsnit valg", "Would you like to clear font sizes?": "Vil du fjerne skriftstørrelse valg", "Would you like to clear font colours?": "Vil du fjerne skriftfarve valg", "Split Block": "Del blok", "Toggle Borders": "Tabelkanter til/fra", "Save as": "Gem som", "Insert/Overwrite": "Indsæt/Overskriv", "&mdash; format &mdash;": "&mdash; Format &mdash;", "Heading 1": "Overskrift 1", "Heading 2": "Overskrift 2", "Heading 3": "Overskrift 3", "Heading 4": "Overskrift 4", "Heading 5": "Overskrift 5", "Heading 6": "Overskrift 6", "Normal": "Normal", "Address": "Adresse", "Formatted": "Formateret", //dialogs "OK": "OK", "Cancel": "Fortryd", "Path": "STi", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Du er i TEXT mode. Brug [<>] knappen til at skifte til visuel editering.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Indsæt-knappen virker ikke i Mozilla-baserede browsere. Brug Ctrl-V på tastaturet for at indsætte.", "You need to select some text before create a link": "Du skal markere noget tekst for at indsætte et hyperlink", "Your Document is not well formed. Check JavaScript console for details.": "Dit dokument er ikke syntaktisk korrekt. Åbn Javascript konsollen for at få flere detaljer.", "Alignment:": "Justering:", "Not set": "Ubestemt", "Left": "Venstre", "Right": "Højre", "Texttop": "Teksttop", "Absmiddle": "Centreret", "Baseline": "Grundlinje", "Absbottom": "Bund", "Bottom": "Tekstbund", "Middle": "Midt", "Top": "Top", "Layout": "Layout", "Spacing": "Afstand", "Horizontal:": "vandret:", "Horizontal padding": "Vandret fyld", "Vertical:": "lodret:", "Vertical padding": "Lodret fyld", "Border thickness:": "Kantbredde:", "Leave empty for no border": "Tom hvis ingen kant", //Insert Link "Insert/Modify Link": "Indsæt/rediger hyperlink", "None (use implicit)": "ingen (implicit)", "New window (_blank)": "Nyt vindue (_blank)", "Same frame (_self)": "Samme ramme (_self)", "Top frame (_top)": "Topramme (_top)", "Other": "Andet", "Target:": "Placering:", "Title (tooltip):": "Titel (Tooltip):", "URL:": "URL:", "You must enter the URL where this link points to": "Du skal angive en mål-URL for linket", // Insert Table "Insert Table": "Indsæt tabel", "Rows:": "Rækker:", "Number of rows": "Antal rækker", "Cols:": "Søjler:", "Number of columns": "Antal søjler", "Width:": "Bredde:", "Width of the table": "Tabelbredde", "Percent": "Procent", "Pixels": "Pixel", "Em": "Geviert (Em)", "Width unit": "Breddeenhed", "Fixed width columns": "Fast-bredde søjler", "Positioning of this table": "Placering af tabel", "Cell spacing:": "Celleafstand:", "Space between adjacent cells": "Afstand mellem celler", "Cell padding:": "Cellefyld:", "Space between content and border in cell": "Luft mellem indhold og kanter", "You must enter a number of rows": "Du skal skrive antallet af rækker", "You must enter a number of columns": "Du skal skrive antallet af søjler", // Insert Image "Insert Image": "Indsæt billede", "Image URL:": "Billede URL:", "Enter the image URL here": "Angiv billedets URL", "Preview": "Smugkig", "Preview the image in a new window": "Smugkig af billedet i et nyt vindue", "Alternate text:": "Alternativ text:", "For browsers that don't support images": "for browsere der ikke understøtter billeder", "Positioning of this image": "Placering af billedet", "Image Preview:": "Billede smugkig:", "You must enter the URL": "Du skal angive en URL", // de-buttons have letters matching danish :-) "button_bold": "de/bold.gif", "button_italic": "de/italic.gif", "button_underline": "de/underline.gif", // Editor Help "Keyboard shortcuts": "Tastaturgenveje", "The editor provides the following key combinations:": "Editoren kender følgende kombinationer:", "new paragraph": "Nyt afsnit", "insert linebreak": "Indsæt linjeskift", "Set format to paragraph": "Formater afsnit", "Clean content pasted from Word": "Rens indhold kopieret fra Word", "Headings": "Overskrift 1 til 6", "Close": "Luk", // Loading messages "Loading in progress. Please wait!": "Editoren hentes ind. Vent venligst.", "Loading plugin $plugin" : "Plugin $plugin hentes", "Register plugin $plugin" : "Plugin $plugin registreres", "Constructing object": "Objekt registreres", "Generate Xinha framework": "Xinha Framework genereres", "Init editor size":"Størrelsen beregnes", "Create Toolbar": "Opretter værktøjslinje", "Create Statusbar" : "Opretter statuslinje", "Register right panel" : "Registrerer højre panel", "Register left panel" : "Registrerer venstre panel", "Register bottom panel" : "Registrerer nederste panel", "Register top panel" : "Registrerer øverste panel", "Finishing" : "Afslutter", // ColorPicker "Click a color..." : "Vælg farve", "Sample" : "Eksempel", "Web Safe: " : "Web Safe: ", "Color: " : "Farve: " }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/da.js
JavaScript
art
6,769
// I18N constants // LANG: "eu", ENCODING: UTF-8 { "Bold": "Lodia", "Italic": "Etzana", "Underline": "Azpimarratua", "Strikethrough": "Marratua", "Subscript": "Azpindizea", "Superscript": "Goi-indizea", "Justify Left": "Ezkerretara lerrokatu", "Justify Center": "Zentratu", "Justify Right": "Eskuinetara lerrokatu", "Justify Full": "Justifikatu", "Ordered List": "Zerrenda ordenatua", "Bulleted List": "Zerrenda ez ordenatua", "Decrease Indent": "Koska handitu", "Increase Indent": "Koska txikitu", "Font Color": "Testu-kolorea", "Background Color": "Atzeko kolorea", "Horizontal Rule": "Marra horizontala", "Insert Web Link": "Lotura txertatu", "Insert/Modify Image": "Irudia txertatu", "Insert Table": "Taula txertatu", "Toggle HTML Source": "Ikusi dokumentua HTML-n", "Enlarge Editor": "Editorea handitu", "About this editor": "Editoreari buruz...", "Help using editor": "Laguntza", "Current style": "Uneko estiloa", "Undoes your last action": "Desegin", "Redoes your last action": "Berregin", "Cut selection": "Ebaki hautaketa", "Copy selection": "Kopiatu hautaketa", "Paste from clipboard": "Itsatsi arbelean dagoena", "Direction left to right": "Ezkerretik eskuinetarako norabidea", "Direction right to left": "Eskuinetik ezkerretarako norabidea", "Remove formatting": "Formatoa kendu", "Select all": "Dena aukeratu", "Print document": "Dokumentua inprimatu", "Clear MSOffice tags": "MSOffice etiketak ezabatu", "Clear Inline Font Specifications": "Ezabatu testuaren ezaugarriak", "Would you like to clear font typefaces?": "Letra-tipoak ezabatu nahi al dituzu?", "Would you like to clear font sizes?": "Letra-tipoen neurriak ezabatu nahi al dituzu?", "Would you like to clear font colours?": "Letra-tipoen koloreak ezabatu nahi al dituzu?", "Split Block": "Blokea zatitu", "Toggle Borders": "Ertzak trukatu", "Save as": "Gorde honela:", "Insert/Overwrite": "Txertatu/Gainidatzi", "&#8212; format &#8212;": "&#8212; Formatua &#8212;", "Heading 1": "Goiburua 1", "Heading 2": "Goiburua 2", "Heading 3": "Goiburua 3", "Heading 4": "Goiburua 4", "Heading 5": "Goiburua 5", "Heading 6": "Goiburua 6", "Normal": "Normala", "Address": "Helbidea", "Formatted": "Formateatua", //dialogs "OK": "Ados", "Cancel": "Utzi", "Path": "Bidea", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "TESTU eran ari zara. Erabil ezazu [<>] botoia WYSIWIG erara itzultzeko.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Itsatsi botoia ez dabil Mozillan oinarritutako nabigatzaileetan (arrazoi teknikoengatik). Sacatu CTRL-V zure teklatuan, zuzenean itsasteko.", "You need to select some text before create a link": "Testu-atal bat aukeratu behar duzu lehendabizi, lotura bat sortzeko", "Your Document is not well formed. Check JavaScript console for details.": "Zure dokumentuak ez du formatu zuzena. Begira ezazu JavaScript kontsola xehetasunetarako.", "Alignment:": "Lerrokatzea:", "Not set": "Ez gaitua", "Left": "Ezkerretara", "Right": "Eskuinetara", "Texttop": "Irudiaren goialdean", "Absmiddle": "Irudiaren erdian", "Baseline": "Irudiaren oinean", "Absbottom": "Irudiaren behekaldean", "Bottom": "Behean", "Middle": "Erdian", "Top": "Goian", "Layout": "Diseinua", "Spacing": "Tartea", "Horizontal:": "Horizontala:", "Horizontal padding": "Betegarri horizontala", "Vertical:": "Bertikala:", "Vertical padding": "Betegarri bertikala", "Border thickness:": "Ertzaren lodiera:", "Leave empty for no border": "Uztazu hutsik ertzik ez sortzeko", //Insert Link "Insert/Modify Link": "Lotura txertatu/aldatu", "None (use implicit)": "Bat ere ez (implizituki erabili)", "New window (_blank)": "Lehio berrian (_blank)", "Same frame (_self)": "Frame berean (_self)", "Top frame (_top)": "Goiko frame-an (_top)", "Other": "Beste bat", "Target:": "Helburua:", "Title (tooltip):": "Izenburua (argibidea):", "URL:": "URL-a:", "You must enter the URL where this link points to": "Loturaren helburu den URL-a idatzi behar duzu", // Insert Table "Insert Table": "Taula txertatu", "Rows:": "Lerroak:", "Number of rows": "Lerro-kopurua", "Cols:": "Zutabeak:", "Number of columns": "Zutabe-kopurua", "Width:": "Zabalera:", "Width of the table": "Taularen zabalera", "Percent": "Portzentaia", "Pixels": "Pixelak", "Em": "Em", "Width unit": "Zabalera-unitatea", "Fixed width columns": "Zabalera finkodun zutabeak", "Positioning of this table": "Taula honen kokapena", "Cell spacing:": "Gelaxka-tartea:", "Space between adjacent cells": "Gelaxka auzokideen arteko tartea", "Cell padding:": "Gelaxkaren betegarria:", "Space between content and border in cell": "Gelaxkaren edukia eta ertzaren arteko tartea", "You must enter a number of rows": "Lerro-kopurua idatzi behar duzu", "You must enter a number of columns": "Zutabe-kopurua idatzi behar duzu", // Insert Image "Insert Image": "Irudia txertatu", "Image URL:": "Irudiaren URL-a:", "Enter the image URL here": "Idatz ezazu irudiaren URL-a hemen", "Preview": "Aurrebista", "Preview the image in a new window": "Aurreikusi irudia beste lehio batean", "Alternate text:": "Testu alternatiboa:", "For browsers that don't support images": "Irudirik onartzen ez duten nabigatzaileentzat", "Positioning of this image": "Irudiaren kokapena", "Image Preview:": "Irudiaren aurrebista:", "You must enter the URL": "URL-a idatzi behar duzu", "button_bold": "de/bold.gif", "button_italic": "de/italic.gif", "button_underline": "de/underline.gif", // Editor Help "Keyboard shortcuts": "Laster-teklak", "The editor provides the following key combinations:": "Editoreak ondorengo tekla-konbinazioak eskaintzen ditu:", "new paragraph": "Paragrafo berria", "insert linebreak": "Lerro-jauzia txertatu", "Set format to paragraph": "Formatua ezarri paragrafoari", "Clean content pasted from Word": "Word-etik itsatsitako edukia ezabatu", "Headings": "Goiburuak", "Close": "Itxi", // Loading messages "Loading in progress. Please wait!": "Kargatzen. Itxaron mesedez", "Loading plugin $plugin" : "$plugin plugina kargatzen", "Register plugin $plugin" : "$plugin plugina erregistratu", "Constructing object": "Objektua eraikitzen", "Generate Xinha framework": "Xinha Framework sortzen", "Init editor size":"Editorearen hasierako neurria", "Create Toolbar": "Tresna-barra sortu", "Create Statusbar" : "Egoera-barra sortu", "Register right panel" : "Eskuin-panela erregistratu", "Register left panel" : "Ezker-panela erregistratu", "Register bottom panel" : "Beheko panela erregistratu", "Register top panel" : "Goiko panela erregistratu", "Finishing" : "Bukatzen", // ColorPicker "Click a color..." : "Kolore bat aukeratu...", "Sample" : "Lagina", "Web Safe: " : "Web Safe: ", "Color: " : "Kolorea: " };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/eu.js
JavaScript
art
7,049
// I18N constants // LANG: "nb", ENCODING: UTF-8 // - translated by ses<ses@online.no> // Additional translations by Håvard Wigtil <havardw@extend.no> // Additional translations by Kim Steinhaug <kim@steinhaug.com> { "Bold": "Fet", "Italic": "Kursiv", "Underline": "Understreket", "Strikethrough": "Gjennomstreket", "Subscript": "Nedsenket", "Superscript": "Opphøyet", "Justify Left": "Venstrejuster", "Justify Center": "Midtjuster", "Justify Right": "Høyrejuster", "Justify Full": "Blokkjuster", "Ordered List": "Nummerert liste", "Bulleted List": "Punktliste", "Decrease Indent": "Reduser innrykk", "Increase Indent": "Øke innrykk", "Font Color": "Tekstfarge", "Background Color": "Bakgrundsfarge", "Horizontal Rule": "Vannrett linje", "Insert Web Link": "Lag lenke", "Insert/Modify Image": "Sett inn bilde", "Insert Table": "Sett inn tabell", "Toggle HTML Source": "Vis kildekode", "Enlarge Editor": "Vis i eget vindu", "About this editor": "Om denne editor", "Help using editor": "Hjelp", "Current style": "Nåværende stil", "Undoes your last action": "Angrer siste redigering", "Redoes your last action": "Gjør om siste angring", "Cut selection": "Klipp ut område", "Copy selection": "Kopier område", "Save as": "Lagre som", "Paste from clipboard": "Lim inn", "Remove formatting": "Fjern formattering", "Direction left to right": "Fra venstre mot høyre", "Direction right to left": "Fra høyre mot venstre", "Insert/Overwrite": "Sett inn/Overskriv", "OK": "OK", "Cancel": "Avbryt", "Path": "Tekstvelger", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Du er i tekstmodus Klikk på [<>] for å gå tilbake til WYSIWIG.", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "Visning i eget vindu har kjente problemer med Internet Explorer, på grunn av problemer med denne nettleseren. Mulige problemer er et uryddig skjermbilde, manglende editorfunksjoner og/eller at nettleseren crasher. Hvis du bruker Windows 95 eller Windows 98 er det også muligheter for at Windows will crashe.\n\nTrykk ", "Cancel": "Avbryt", "Insert/Modify Link": "Rediger lenke", "New window (_blank)": "Eget vindu (_blank)", "None (use implicit)": "Ingen (bruk standardinnstilling)", "Other": "Annen", "Same frame (_self)": "Samme ramme (_self)", "Target:": "Mål:", "Title (tooltip):": "Tittel (tooltip):", "Top frame (_top)": "Toppramme (_top)", "URL:": "Adresse:", "You must enter the URL where this link points to": "Du må skrive inn en adresse som denne lenken skal peke til", "Clear Inline Font Specifications": "Fjerne inline font spesifikasjoner", "Would you like to clear font typefaces?": "Ønsker du å fjerne skrifttyper", "Would you like to clear font sizes?": "Ønsker du å fjerne skrift størrelser", "Would you like to clear font colours?": "Ønsker du å fjerne farger på skriften", "Print document": "Skriv ut dokumentet", "Split Block": "Seperasjonsblokk", "Toggle Borders": "Skru av/på hjelpelinjer på tabeller", "Select all": "Merk alt", // Loading messages "Loading in progress. Please wait !": "WYSIWYG laster, vennligst vent!", "Constructing main object": "Vennligst vent", "Create Toolbar": "Lag verktøylinje", "Register panel right": "Registrer høyrepanel", "Register panel left": "Registrer venstrepanel", "Register panel top": "Registrer toppanel", "Register panel bottom": "Registrer bunnpanel" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/nb.js
JavaScript
art
3,546
// I18N constants // LANG: "lt", ENCODING: UTF-8 // Author: Jaroslav Šatkevič, <jaro@akl.lt> { "Bold": "Paryškinti", "Italic": "Kursyvas", "Underline": "Pabraukti", "Strikethrough": "Perbraukti", "Subscript": "Apatinis indeksas", "Superscript": "Viršutinis indeksas", "Justify Left": "Lygiavimas pagal kairę", "Justify Center": "Lygiavimas pagal centrą", "Justify Right": "Lygiavimas pagal dešinę", "Justify Full": "Lygiuoti pastraipą", "Ordered List": "Numeruotas sąrašas", "Bulleted List": "Suženklintas sąrašas", "Decrease Indent": "Sumažinti paraštę", "Increase Indent": "Padidinti paraštę", "Font Color": "Šrifto spalva", "Background Color": "Fono spalva", "Horizontal Rule": "Horizontali linija", "Insert Web Link": "Įterpti nuorodą", "Insert/Modify Image": "Įterpti paveiksliuką", "Insert Table": "Įterpti lentelę", "Toggle HTML Source": "Perjungti į HTML/WYSIWYG", "Enlarge Editor": "Išplėstas redagavimo ekranas/Enlarge Editor", "About this editor": "Apie redaktorių", "Help using editor": "Pagalba naudojant redaktorių", "Current style": "Dabartinis stilius", "Undoes your last action": "Atšaukia paskutini jūsų veiksmą", "Redoes your last action": "Pakartoja paskutinį atšauktą jūsų veiksmą", "Cut selection": "Iškirpti", "Copy selection": "Kopijuoti", "Paste from clipboard": "Įterpti", "OK": "OK", "Cancel": "Atšaukti", "Path": "Kelias", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Jūs esete teksto režime. Naudokite [<>] mygtuką grįžimui į WYSIWYG.", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren", "Cancel": "Atšaukti", "Insert/Modify Link": "Idėti/Modifikuoti", "New window (_blank)": "Naujas langas (_blank)", "None (use implicit)": "None (use implicit)", "Other": "Kitas", "Same frame (_self)": "Same frame (_self)", "Target:": "Target:", "Title (tooltip):": "Pavadinimas (tooltip):", "Top frame (_top)": "Top frame (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "Jus privalote nurodyti URL į kuri rodo šitą nuoroda" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/lt.js
JavaScript
art
2,317
// I18N constants // LANG: "el", ENCODING: UTF-8 // Author: Dimitris Glezos, dimitris@glezos.com { "Bold": "ΞˆΞ½Ο„ΞΏΞ½Ξ±", "Italic": "Πλάγια", "Underline": "Ξ�πογραμμισμένα", "Strikethrough": "Διαγραμμένα", "Subscript": "ΔΡίκτης", "Superscript": "ΔΡίκτης", "Justify Left": "Στοίχιση ΑριστΡρά", "Justify Center": "Στοίχιση ΞšΞ­Ξ½Ο„ΟΞΏ", "Justify Right": "Στοίχιση ΔΡξιά", "Justify Full": "Ξ Ξ»Ξ�ρης Στοίχιση", "Ordered List": "Αρίθμηση", "Bulleted List": "ΞšΞΏΟ…ΞΊΞΊΞ―Ξ΄Ξ΅Ο‚", "Decrease Indent": "ΞœΞ΅Ξ―Ο‰ΟƒΞ· ΕσοχΞ�Ο‚", "Increase Indent": "Αύξηση ΕσοχΞ�Ο‚", "Font Color": "Χρώμα ΓραμματοσΡιράς", "Background Color": "Χρώμα Ξ¦ΟŒΞ½Ο„ΞΏΟ…", "Horizontal Rule": "ΞŸΟΞΉΞΆΟŒΞ½Ο„ΞΉΞ± ΓραμμΞ�", "Insert Web Link": "ΕισαγωγΞ� Συνδέσμου", "Insert/Modify Image": "ΕισαγωγΞ�/Ξ�ροποποίηση Ξ•ΞΉΞΊΟŒΞ½Ξ±Ο‚", "Insert Table": "ΕισαγωγΞ� Ξ Ξ―Ξ½Ξ±ΞΊΞ±", "Toggle HTML Source": "ΕναλλαγΞ� σΡ/Ξ±Ο€ΟŒ HTML", "Enlarge Editor": "ΞœΞ΅Ξ³Ξ­Ξ½ΞΈΟ…Ξ½ΟƒΞ· ΡπΡξΡργαστΞ�", "About this editor": "ΠληροφορίΡς", "Help using editor": "Ξ’ΞΏΞ�θΡια", "Current style": "Παρών στυλ", "Undoes your last action": "ΑναίρΡση τΡλΡυταίας ΡνέργΡιας", "Redoes your last action": "Επαναφορά Ξ±Ο€ΟŒ αναίρΡση", "Cut selection": "ΑποκοπΞ�", "Copy selection": "ΑντιγραφΞ�", "Paste from clipboard": "Ξ•Ο€ΞΉΞΊΟŒΞ»Ξ»Ξ·ΟƒΞ·", "Direction left to right": "ΞšΞ±Ο„Ξ΅ΟΞΈΟ…Ξ½ΟƒΞ· αριστΡρά προς δΡξιά", "Direction right to left": "ΞšΞ±Ο„Ξ΅ΟΞΈΟ…Ξ½ΟƒΞ· Ξ±Ο€ΟŒ δΡξιά προς τα αριστΡρά", "OK": "OK", "Cancel": "Ακύρωση", "Path": "ΔιαδρομΞ�", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "ΕίστΡ σΡ TEXT MODE. ΧρησιμοποιΞ�στΡ το κουμπί [<>] Ξ³ΞΉΞ± Ξ½Ξ± ΡπανέρθΡτΡ στο WYSIWIG.", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "Ξ— κατάσταση πλΞ�ρης ΞΏΞΈΟŒΞ½Ξ·Ο‚ έχΡι προβλΞ�ματα ΞΌΞ΅ τον Internet Explorer, Ξ»ΟŒΞ³Ο‰ σφαλμάτων στον ίδιο τον browser. Αν το σύστημα σας Ρίναι Windows 9x μπορΡί ΞΊΞ±ΞΉ Ξ½Ξ± χρΡιαστΡίτΡ reboot. Αν ΡίστΡ σίγουροι, πατΞ�στΡ ΟΚ.", "Cancel": "Ακύρωση", "Insert/Modify Link": "ΕισαγωγΞ�/Ξ�ροποποίηση σύνδΡσμου", "New window (_blank)": "Νέο παράθυρο (_blank)", "None (use implicit)": "Κανένα (χρΞ�ση Ξ±Ο€ΟŒΞ»Ο…Ο„ΞΏΟ…)", "Other": "Αλλο", "Same frame (_self)": "Ίδιο frame (_self)", "Target:": "Target:", "Title (tooltip):": "Ξ�ίτλος (tooltip):", "Top frame (_top)": "Πάνω frame (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "ΠρέπΡι Ξ½Ξ± ΡισάγΡτΡ το URL που οδηγΡί Ξ±Ο…Ο„ΟŒΟ‚ ΞΏ σύνδΡσμος" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/el.js
JavaScript
art
4,723
// I18N constants // LANG: "th", ENCODING: UTF-8 // Author: Suchin Prasongbundit, <suchin@joolsoft.com> // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "ตัวหนา", "Italic": "ตัวเอียง", "Underline": "ขีดเส้นใต้", "Strikethrough": "ขีดทับ", "Subscript": "ตัวห้อย", "Superscript": "ตัวยก", "Justify Left": "จัดชิดซ้าย", "Justify Center": "จัดกึ่งกลาง", "Justify Right": "จัดชิดขวา", "Justify Full": "จัดเต็มขอบ", "Ordered List": "เลขลำดับ", "Bulleted List": "ลำดับ", "Decrease Indent": "ลดย่อหน้า", "Increase Indent": "เพิ่มย่อหน้า", "Font Color": "สีขอบแบบอักษร", "Background Color": "สีพื้นหลัง", "Horizontal Rule": "เส้นกึ่งกลาง", "Insert Web Link": "ิเพิ่มลิ้งค์", "Insert/Modify Image": "เพิ่ม/แก้ไขภาพ", "Insert Table": "เพิ่มตาราง", "Toggle HTML Source": "สลับการแสดงโค้ด HTML", "Enlarge Editor": "ขยายให้เต็มจอ", "About this editor": "เกี่ยวกับโปรแกรมนี้", "Help using editor": "การใช้งานโปรแกรม", "Current style": "รูปแบบปัจจุบัน", "Undoes your last action": "ย้อนกลับ", "Redoes your last action": "ทำซ้ำ", "Cut selection": "ตัดส่วนที่เลือก", "Copy selection": "สำเนาส่วนที่เลือก", "Paste from clipboard": "วางจากคลิปบอร์ด", "OK": "ตกลง", "Cancel": "ยกเลิก", "Path": "เส้นทาง", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "คุณอยู่ในโหมดธรรมดา กดที่ปุ่ม [<>] เพื่อสลับกลับไปยังโหมดพิมพ์งานแบบเวิร์ด" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/th.js
JavaScript
art
2,509
// I18N constants // LANG: "de", ENCODING: UTF-8 { "Bold": "Negrita", "Italic": "Cursiva", "Underline": "Subrayado", "Strikethrough": "Tachado", "Subscript": "Subíndice", "Superscript": "Superíndice", "Justify Left": "Alinear a la izquierda", "Justify Center": "Alinear al centro", "Justify Right": "Alinear a la derecha", "Justify Full": "Justificar", "Ordered List": "Lista numerada", "Bulleted List": "Lista no numerada", "Decrease Indent": "Reducir sangría", "Increase Indent": "Aumentar sangría", "Font Color": "Color de la fuente", "Background Color": "Color de fondo", "Horizontal Rule": "Regla horizontal", "Insert Web Link": "Insertar enlace web", "Insert/Modify Image": "Insertar/modificar imagen", "Insert Table": "Insertar una tabla", "Toggle HTML Source": "Ver HTML", "Enlarge Editor": "Editor a pantalla completa", "About this editor": "Sobre este Editor", "Help using editor": "Ayuda", "Current style": "Estilo actual", "Undoes your last action": "Deshacer", "Redoes your last action": "Rehacer", "Cut selection": "Cortar", "Copy selection": "Copiar", "Paste from clipboard": "Pegar desde el portapapeles", "Direction left to right": "Dirección de izquierda a derecha", "Direction right to left": "Dirección de derecha a izquierda", "Remove formatting": "Borrar formato", "Select all": "Seleccionar todo", "Print document": "Imprimir documento", "Clear MSOffice tags": "Borrar etiquetas de MSOffice", "Clear Inline Font Specifications": "Borrar las etiquetas de fuente", "Would you like to clear font typefaces?": "¿Desea eliminar las definiciaones de tipo de fuente?", "Would you like to clear font sizes?": "¿Desea eliminar las definiciones de tamaño de fuente?", "Would you like to clear font colours?": "¿Desea eliminar las definiciones de color de fuente?", "Split Block": "Dividir el bloque", "Toggle Borders": "Añadir/Quitar bordes", "Save as": "Guardar como", "Insert/Overwrite": "Insertar/Sobreescribir", "&#8212; format &#8212;": "&#8212; formato &#8212;", "&#8212; font &#8212;": "&#8212; fuente &#8212;", "&#8212; size &#8212;": "&#8212; tamaño &#8212;", "Heading 1": "Cabecera 1", "Heading 2": "Cabecera 2", "Heading 3": "Cabecera 3", "Heading 4": "Cabecera 4", "Heading 5": "Cabecera 5", "Heading 6": "Cabecera 6", "Normal": "Normal", "Address": "Dirección", "Formatted": "Formateado", //dialogs "OK": "Aceptar", "Cancel": "Cancelar", "Path": "Ruta", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Se encuentra en MODO TEXTO. Use el botón [<>] para cambiar de nuevo al modo WYSIWYG", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "El botón de pegar no funciona en los navegadores de Mozilla por motivos de seguridad. Presione CTRL-V en su teclado para pegarlo directamente", "You need to select some text before create a link": "Necesita seleccionar algún texto antes de crear un link", "Your Document is not well formed. Check JavaScript console for details.": "Su documento no está bien formado. Compruebe la consola de JavaScript para obtener más detalles", "Alignment:": "Alineación:", "Not set": "No definido", "Left": "Izquierda", "Right": "Derecha", "Texttop": "Texto Superior", "Absmiddle": "Medio Absoluto", "Baseline": "Línea base", "Absbottom": "Inferior absoluto", "Bottom": "Inferior", "Middle": "Medio", "Top": "Superior", "Layout": "Distribución", "Spacing": "Espaciado", "Horizontal:": "horizontal:", "Horizontal padding": "Relleno horizontal", "Vertical:": "Vertical:", "Vertical padding": "Relleno Vertical", "Border thickness:": "Tamaño del borde:", "Leave empty for no border": "Vacío si no desea ningún borde", //Insert Link "Insert/Modify Link": "Insertar/Modificar un enlace", "None (use implicit)": "Vacío ( usar implícito )", "New window (_blank)": "Nueva ventana (_blank)", "Same frame (_self)": "Mismo marco (_self)", "Top frame (_top)": "Marco superior (_top)", "Other": "Otro", "Target:": "Destino:", "Title (tooltip):": "Título (Tooltip):", "URL:": "URL:", "You must enter the URL where this link points to": "Debe introducir la URL a donde apunta este enlace", // Insert Table "Insert Table": "Añadir una tabla", "Rows:": "Filas:", "Number of rows": "Número de filas", "Cols:": "Columnas:", "Number of columns": "Número de columnas", "Width:": "Ancho:", "Width of the table": "Ancho de la tabla", "Percent": "Porcentaje", "Pixels": "Pixels", "Em": "Em", "Width unit": "Unidad de anchura", "Fixed width columns": "Columnas de ancho fijo", "Positioning of this table": "Posición de esta tabla", "Cell spacing:": "Espaciado entre celdas:", "Space between adjacent cells": "Espaciado entre celdas adyacentes", "Cell padding:": "Relleno de celdas:", "Space between content and border in cell": "Escapcio entre el contenido y el borde de la celda", "You must enter a number of rows": "Debe introducir un número de filas", "You must enter a number of columns": "Debe introducir un número de columnas", // Insert Image "Insert Image": "Insertar una imagen", "Image URL:": "Imagen URL:", "Enter the image URL here": "", "Preview": "Previsualizar", "Preview the image in a new window": "Previsualizar en una nueva ventana", "Alternate text:": "Texto alternativo:", "For browsers that don't support images": "Para navegadores que no soportan imágenes", "Positioning of this image": "Posición de la imagen", "Image Preview:": "Previsualización de la imagen:", "You must enter the URL": "Debe introducir la URL", // Editor Help "Keyboard shortcuts": "Atajos de teclado", "The editor provides the following key combinations:": "El editor proporciona las siguientes combinaciones:", "new paragraph": "Nuevo parrafo", "insert linebreak": "Insertar salto de línea", "Set format to paragraph": "EStablecer el formato a parrafo", "Clean content pasted from Word": "Limpiar el contenido pegado desde Word", "Headings": "Cabeceras", "Close": "Cerrar", // Loading messages "Loading in progress. Please wait!": "Carga en proceso. Por favor espere.", "Loading plugin $plugin" : "Cargando el plugin $plugin", "Register plugin $plugin" : "Registro de plugin $plugin", "Constructing object": "Construyendo objeto", "Generate Xinha framework": "Generar Xinha framework", "Init editor size":"Iniciar el tamaño del editor", "Create Toolbar": "Crear barra de herramientas", "Create Statusbar" : "Crear barra de estado", "Register right panel" : "Registrar panel derecho", "Register left panel" : "Registrar panel izquierdo", "Register bottom panel" : "Registar panel inferior", "Register top panel" : "Registar panel superior", "Finishing" : "Finalizando", // ColorPicker "Click a color..." : "Seleccione un color...", "Sample" : "Muestra", "Web Safe: " : "Color web: ", "Color: " : "Color: " }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/es.js
JavaScript
art
7,110
// I18N constants // LANG: "en", ENCODING: UTF-8 { "Bold": "Lihavoitu", "Italic": "Kursivoitu", "Underline": "Alleviivattu", "Strikethrough": "Yliviivattu", "Subscript": "Alaindeksi", "Superscript": "Yläindeksi", "Justify Left": "Tasaa vasemmat reunat", "Justify Center": "Keskitä", "Justify Right": "Tasaa oikeat reunat", "Justify Full": "Tasaa molemmat reunat", "Ordered List": "Numerointi", "Bulleted List": "Luettelomerkit", "Decrease Indent": "Pienennä sisennystä", "Increase Indent": "Lisää sisennystä", "Font Color": "Fontin väri", "Background Color": "Taustaväri", "Horizontal Rule": "Vaakaviiva", "Insert Web Link": "Lisää linkki", "Insert/Modify Image": "Lisää kuva", "Insert Table": "Lisää taulukko", "Toggle HTML Source": "HTML-lähdekoodi vs WYSIWYG", "Enlarge Editor": "Suurenna editori", "About this editor": "Tietoja editorista", "Help using editor": "Näytä ohje", "Current style": "Nykyinen tyyli", "Undoes your last action": "Peruuta viimeinen toiminto", "Redoes your last action": "Palauta viimeinen toiminto", "Cut selection": "Leikkaa maalattu", "Copy selection": "Kopioi maalattu", "Paste from clipboard": "Liitä leikepyödältä", "OK": "Hyväksy", "Cancel": "Peruuta" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/fi.js
JavaScript
art
1,278
// I18N constants : Vietnamese // LANG: "en", ENCODING: UTF-8 // Author: Nguyễn Đình Nam, <hncryptologist@yahoo.com> // Modified 21/07/2004 by Phạm Mai Quân <pmquan@4vn.org> { "Bold": "Đậm", "Italic": "Nghiêng", "Underline": "Gạch Chân", "Strikethrough": "Gạch Xóa", "Subscript": "Viết Xuống Dưới", "Superscript": "Viết Lên Trên", "Justify Left": "Căn Trái", "Justify Center": "Căn Giữa", "Justify Right": "Căn Phải", "Justify Full": "Căn Đều", "Ordered List": "Danh Sách Có Thứ Tự (1, 2, 3)", "Bulleted List": "Danh Sách Phi Thứ Tự (Chấm đầu dòng)", "Decrease Indent": "Lùi Ra Ngoài", "Increase Indent": "Thụt Vào Trong", "Font Color": "Màu Chữ", "Background Color": "Màu Nền", "Horizontal Rule": "Dòng Kẻ Ngang", "Insert Web Link": "Tạo Liên Kết", "Insert/Modify Image": "Chèn Ảnh", "Insert Table": "Chèn Bảng", "Toggle HTML Source": "Chế Độ Mã HTML", "Enlarge Editor": "Phóng To Ô Soạn Thảo", "About this editor": "Tự Giới Thiệu", "Help using editor": "Giúp Đỡ", "Current style": "Định Dạng Hiện Thời", "Undoes your last action": "Hủy thao tác trước", "Redoes your last action": "Lấy lại thao tác vừa bỏ", "Cut selection": "Cắt", "Copy selection": "Sao chép", "Paste from clipboard": "Dán", "Direction left to right": "Viết từ trái sang phải", "Direction right to left": "Viết từ phải sang trái", "OK": "Đồng ý", "Cancel": "Hủy", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "Chế độ phóng to ô soạn thảo có thể gây lỗi với Internet Explorer vì một số lỗi của trình duyệt này, vì thế chế độ này có thể sẽ không chạy. Hiển thị không đúng, lộn xộn, không có đầy đủ chức năng, và cũng có thể làm trình duyệt của bạn bị tắt ngang. Nếu bạn đang sử dụng Windows 9x bạn có thể bị báo lỗi ", "Path": "Đường Dẫn", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Bạn đang ở chế độ text. Sử dụng nút [<>] để chuyển lại chế độ WYSIWIG.", "Cancel": "Hủy", "Insert/Modify Link": "Thêm/Chỉnh sửa đường dẫn", "New window (_blank)": "Cửa sổ mới (_blank)", "None (use implicit)": "Không (sử dụng implicit)", "OK": "Đồng ý", "Other": "Khác", "Same frame (_self)": "Trên cùng khung (_self)", "Target:": "Nơi hiện thị:", "Title (tooltip):": "Tiêu đề (của hướng dẫn):", "Top frame (_top)": "Khung trên cùng (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "Bạn phải điền địa chỉ (URL) mà đường dẫn sẽ liên kết tới" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/vn.js
JavaScript
art
2,882
// I18N constants // LANG: "fa", ENCODING: UTF-8 { "Bold": "ضخیم", "Italic": "مورب", "Underline": "زیر خط", "Strikethrough": "رو خط", "Subscript": "زیروند", "Superscript": "بالاوند", "Justify Left": "تراز از چپ", "Justify Center": "تراز در وسط", "Justify Right": "تراز در راست", "Justify Full": "تراز از چپ و راست", "Ordered List": "فهرست مرتب", "Bulleted List": "فهرست گلوله ای", "Decrease Indent": "کاهش سر خط", "Increase Indent": "افزایش سر خط", "Font Color": "رنگ فلم", "Background Color": "رنگ پس زمینه", "Horizontal Rule": "خط افقی", "Insert Web Link": "افزودن لینک وب", "Insert/Modify Image": "افزودن یا ویرایش تصویر", "Insert Table": "افزودن جدول", "Toggle HTML Source": "مشاهده یا عدم مشاهده متن در قالب HTML", "Enlarge Editor": "بزرگ کردن ویرایش گر", "About this editor": "درباره این ویرایش گر", "Help using editor": "راهنمای استفاده ویرایش گر", "Current style": "شیوه کنونی", "Undoes your last action": "برگرداندن آخرین عمل", "Redoes your last action": "انجام مجدد آخرین عمل", "Cut selection": "بریدن انتخاب شده", "Copy selection": "کپی انتخاب شده", "Paste from clipboard": "چسباندن از تخته کار", "Direction left to right": "جهت از چپ به راست", "Direction right to left": "جهت از راست به چپ", "Remove formatting": "حذف فرمت بندی", "Select all": "انتخاب همه", "Print document": "چاپ سند", "Clear MSOffice tags": "پاک کردن متن از برچسب های MSOffice", "Clear Inline Font Specifications": "پاک کردن متن از مشخصات فونت", "Would you like to clear font typefaces?": "آیا تمایل دارید ظاهر فلم را پاک کنید؟", "Would you like to clear font sizes?": "آیا تمایل دارید اندازه قلم را پاک کنید", "Would you like to clear font colours?": "آیا تمایل دارید رنگ قلم را پاک کنید؟", "Split Block": "بلاک جداسازی", "Toggle Borders": "فعال/غیر فعال کردن لبه ها", "Save as": "ذخیره مانند...", "Insert/Overwrite": "افزودن/جانویسی", "&#8212; format &#8212;": "&#8212; قالب &#8212;", "Heading 1": "تیتر 1", "Heading 2": "تیتر 2", "Heading 3": "تیتر 3", "Heading 4": "تیتر 4", "Heading 5": "تیتر 5", "Heading 6": "تیتر 6", "Normal": "معمولی", "Address": "آدرس", "Formatted": "قالب بندی شده", //dialogs "OK": "بله", "Cancel": "انصراف", "Path": "مسیر", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "در مد متنی هستید. از دکمه [<>] استفاده نمایید تا به مد WYSIWYG برگردید.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "دکمه چسباندن در مرورگرهای سری Mozilla کار نمی کند (به دلایل فنی امنیتی).برای چسباندن مستقیم ، دکمه CTRL-V را در صفحه کلید بزنید.", "Your Document is not well formed. Check JavaScript console for details.": "سند شما بدرستی قالب بندی نشده است. برای اطلاعات بیشتر پایانه نمایش جاوااسکریپت را بررسی کنید.", "Alignment:": "تراز بندی", "Not set": "تنظیم نشده", "Left": "چپ", "Right": "راست", "Texttop": "بالای متن", "Absmiddle": "دقیقا وسط", "Baseline": "ابتدای خط", "Absbottom": "دقیقا پایین", "Bottom": "پایین", "Middle": "وسط", "Top": "بالا", "Layout": "لایه", "Spacing": "فاصله گذاری", "Horizontal:": "افقی", "Horizontal padding": "پرکننده افقی", "Vertical:": "عمودی", "Vertical padding": "پرکننده عمودی", "Border thickness:": "ضخامت لبه", "Leave empty for no border": "برای بدون لبه خالی رها کن", //Insert Link "Insert/Modify Link": "افزودن / ویرایش لینک", "None (use implicit)": "هیچکدام (استفاده از بدون شرط)", "New window (_blank)": "پنجره جدید (_blank)", "Same frame (_self)": "فریم یکسان (_self)", "Top frame (_top)": "فریم بالایی (_top)", "Other": "سایر", "Target:": "هدف", "Title (tooltip):": "عنوان (راهنمای یک خطی)", "URL:": "URL:", "You must enter the URL where this link points to": "باید URLی که این لینک به آن اشاره دارد را وارد کنید", "You need to select some text before creating a link": "باید قبل از ساخت لینک ، متنی را انتخاب نمایید", // Insert Table "Insert Table": "افزودن جدول", "Rows:": "ردیف ها", "Number of rows": "تعداد ردیف ها", "Cols:": "ستون ها", "Number of columns": "تعداد ستون ها", "Width:": "طول", "Width of the table": "طول جدول", "Percent": "درصد", "Pixels": "پیکسل ها", "Em": "Em", "Width unit": "واحد طول", "Fixed width columns": "ستون های طول ثابت", "Positioning of this table": "موقعیت یابی این جدول", "Cell spacing:": "فاصله سلول ها", "Space between adjacent cells": "فاصله بین سلول های همجوار", "Cell padding:": "پر کننده سلول", "Space between content and border in cell": "فاصله بین محتوا و لبه در سلول", "You must enter a number of rows": "باید تعداد ردیف ها را وارد کنید", "You must enter a number of columns": "باید تعداد ستون ها را وارد کنید", // Insert Image "Insert Image": "افزودن تصویر", "Image URL:": "URL تصویر", "Enter the image URL here": "URL تصویر را اینجا وارد کنید", "Preview": "پیش نمایش", "Preview the image in a new window": "پیش نمایش تصویر در پنجره ای جدید", "Alternate text:": "متن جایگزین", "For browsers that don't support images": "برای مرورگرهایی که از تصاویر پشتیبانی نمی کنند", "Positioning of this image": "موقعیت یابی تصویر", "Image Preview:": "پیش نمایش تصویر", "You must enter the URL": "شما باید URL را وارد کنید", // toolbar /* "button_bold": "fr/bold.gif", "button_underline": "fr/underline.gif", "button_strikethrough": "fr/strikethrough.gif", */ // Editor Help "Xinha Help": "راهنمای Xinha", "Editor Help": "راهنمای ویرایشگر", "Keyboard shortcuts": "میانبرهای صفحه کلید", "The editor provides the following key combinations:": "ویرایشگر استفاده از کلید های گروهی زیر را مسیر می سازد :", "ENTER": "ENTREE", "new paragraph": "پاراگراف جدید", "SHIFT-ENTER": "SHIFT+ENTREE", "insert linebreak": "افزودن جدا کننده خط", "Set format to paragraph": "تغییر قالب به پاراگراف", "Clean content pasted from Word": "تمیز کردن محتوای چسبانده شده از Word", "Headings": "عنوان گذاری", "Close": "بستن", // Loading messages "Loading in progress. Please wait !": "بارگذاری در حال انجام است. لطفا صبر کنید !", "Constructing main object": "ساختن شیء اصلی", "Constructing object": "ساختن شیء", "Register panel right": "ثبت قاب راست", "Register panel left": "ثبت قاب چپ", "Register panel top": "ثبت قاب بالا", "Register panel bottom": "ثبت قاب پایین", "Create Toolbar": "ساخت نوار ابزار", "Create StatusBar": "ساخت نوار وضعیت", "Generate Xinha object": "تولید شیء Xinha", "Init editor size": "مقدار دهی اندازه ویرایشگر", "Init IFrame": "مقدار دهی IFrame", "Register plugin $plugin": "ثبت پلاگین $plugin" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/fa.js
JavaScript
art
8,650
// I18N constants // LANG: "ro", ENCODING: UTF-8 // Author: Mihai Bazon, http://dynarch.com/mishoo // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Îngroşat", "Italic": "Italic", "Underline": "Subliniat", "Strikethrough": "Tăiat", "Subscript": "Indice jos", "Superscript": "Indice sus", "Justify Left": "Aliniere la stânga", "Justify Center": "Aliniere pe centru", "Justify Right": "Aliniere la dreapta", "Justify Full": "Aliniere în ambele părţi", "Ordered List": "Listă ordonată", "Bulleted List": "Listă marcată", "Decrease Indent": "Micşorează alineatul", "Increase Indent": "Măreşte alineatul", "Font Color": "Culoarea textului", "Background Color": "Culoare de fundal", "Horizontal Rule": "Linie orizontală", "Insert Web Link": "Inserează/modifică link", "Insert/Modify Image": "Inserează/modifică imagine", "Insert Table": "Inserează un tabel", "Toggle HTML Source": "Sursa HTML / WYSIWYG", "Enlarge Editor": "Maximizează editorul", "About this editor": "Despre editor", "Help using editor": "Documentaţie (devel)", "Current style": "Stilul curent", "Undoes your last action": "Anulează ultima acţiune", "Redoes your last action": "Reface ultima acţiune anulată", "Cut selection": "Taie în clipboard", "Copy selection": "Copie în clipboard", "Paste from clipboard": "Aduce din clipboard", "Direction left to right": "Direcţia de scriere: stânga - dreapta", "Direction right to left": "Direcţia de scriere: dreapta - stânga", "OK": "OK", "Cancel": "Anulează", "Path": "Calea", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Eşti în modul TEXT. Apasă butonul [<>] pentru a te întoarce în modul WYSIWYG.", "Cancel": "Renunţă", "Insert/Modify Link": "Inserează/modifcă link", "New window (_blank)": "Fereastră nouă (_blank)", "None (use implicit)": "Nimic (foloseşte ce-i implicit)", "Other": "Alt target", "Same frame (_self)": "Aceeaşi fereastră (_self)", "Target:": "Ţinta:", "Title (tooltip):": "Titlul (tooltip):", "Top frame (_top)": "Fereastra principală (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "Trebuie să introduceţi un URL" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/ro.js
JavaScript
art
2,492
// I18N constants // LANG: "sh", ENCODING: UTF-8 | ISO-8859-5 // Author: Ljuba Ranković, http://www.rankovic.net/ljubar // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Масно", "Italic": "Курзив", "Underline": "Подвучено", "Strikethrough": "Прецртано", "Subscript": "Индекс-текст", "Superscript": "Експонент-текст", "Justify Left": "Равнање улево", "Justify Center": "Равнање по симетрали", "Justify Right": "Равнање удесно", "Justify Full": "Пуно равнање", "Ordered List": "Листа са редним бројевима", "Bulleted List": "Листа са симболима", "Decrease Indent": "Смањи увлачење", "Increase Indent": "Повећај увлачење", "Font Color": "Боја слова", "Background Color": "Боја позадине", "Horizontal Rule": "Хоризонтална линија", "Insert Web Link": "додај веб линк", "Insert/Modify Image": "додај/промени слику", "Insert Table": "Убаци табелу", "Toggle HTML Source": "Пребаци на приказ ХТМЛ кода", "Enlarge Editor": "Повећај едитор", "About this editor": "О овом едитору", "Help using editor": "Помоћ при коришћењу едитора", "Current style": "Важећи стил", "Undoes your last action": "Поништава последњу радњу", "Redoes your last action": "Враћа последњу радњу", "Cut selection": "Исеци изабрано", "Copy selection": "Копирај изабрано", "Paste from clipboard": "Залепи из клипборда", "Direction left to right": "Правац с лева на десно", "Direction right to left": "Правац с десна на лево", "Remove formatting": "Уклони форматирање", "Select all": "Изабери све", "Print document": "Штампај документ", "Clear MSOffice tags": "Обриши MSOffice тагове", "Clear Inline Font Specifications": "Обриши примењене особине фонта", "Split Block": "Подели блок", "Toggle Borders": "Пребаци оквирне линије", "&#8212; format &#8212;": "&#8212; Format &#8212;", "Heading 1": "Заглавље 1", "Heading 2": "Заглавље 2", "Heading 3": "Заглавље 3", "Heading 4": "Заглавље 4", "Heading 5": "Заглавље 5", "Heading 6": "Заглавље 6", "Normal": "обичан", "Address": "адреса", "Formatted": "форматиран", // dialogs "OK": "OK", "Cancel": "Поништи", "Path": "Путања", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Налазите се у ТЕКСТ режиму. Користите [<>] дугме за повратак на ШВТИД (WYSIWYG).", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "Дугме 'залепи' не ради у претраживачима породице Mozilla (из разлога сигурности). Притисните CTRL-V на тастатури да директно залепите.", "Alignment:": "Равнање", "Not set": "Није постављено", "Left": "Лево", "Right": "Десно", "Texttop": "Врх текста", "Absmiddle": "Апсолутна средина", "Baseline": "Доња линија", "Absbottom": "Апсолутно дно", "Bottom": "Дно", "Middle": "Средина", "Top": "Врх", "Layout": "Прелом", "Spacing": "Размак", "Horizontal:": "По хоризонтали", "Horizontal padding": "Хортизонтално одстојање", "Vertical:": "По вертикали", "Vertical padding": "Вертикално одстојање", "Border thickness:": "Дебљина оквира", "Leave empty for no border": "Остави празно кад нема оквира", // Insert Link "Insert/Modify Link": "додај/промени линк", "None (use implicit)": "користи подразумевано", "New window (_blank)": "Новом прозору (_blank)", "Same frame (_self)": "Исти фрејм (_self)", "Top frame (_top)": "Главни фрејм (_top)", "Other": "Друго", "Target:": "Отвори у:", "Title (tooltip):": "Назив (tooltip):", "URL:": "УРЛ:", "You must enter the URL where this link points to": "Морате унети УРЛ на који води овај линк", // Insert Table "Insert Table": "Убаци табелу", "Rows:": "Редови", "Number of rows": "Број редова", "Cols:": "Колоне", "Number of columns": "Број колона", "Width:": "Ширина", "Width of the table": "Ширина табеле", "Percent": "Процената", "Pixels": "Пиксела", "Em": "Ем", "Width unit": "Јединица ширине", "Fixed width columns": "Фиксирана ширина колоне", "Positioning of this table": "Постављање ове табеле", "Cell spacing:": "Размак између ћелија", "Space between adjacent cells": "Размак између наспрамних ћелија", "Cell padding:": "Унутрашња одстојања од ивица ћелије", "Space between content and border in cell": "Растојање између садржаја у ћелији и њеног оквира", // Insert Image "Insert Image": "Убаци слику", "Image URL:": "УРЛ слике", "Enter the image URL here": "Унесите УРЛ слике овде", "Preview": "Преглед", "Preview the image in a new window": "Прегледај слику у новом прозору", "Alternate text:": "алтернативни текст", "For browsers that don't support images": "За претраживаче који не подржавају слике", "Positioning of this image": "Постављање ове слике", "Image Preview:": "Преглед слике", // Select Color popup "Select Color": "Изабери боју" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/sr.js
JavaScript
art
7,060
// I18N constants // LANG: "he", ENCODING: UTF-8 // Author: Liron Newman, http://www.eesh.net, <plastish at ultinet dot org> // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "מודגש", "Italic": "נטוי", "Underline": "קו תחתי", "Strikethrough": "קו אמצע", "Subscript": "כתב עילי", "Superscript": "כתב תחתי", "Justify Left": " ישור לשמאל", "Justify Center": "ישור למרכז", "Justify Right": "ישור לימין", "Justify Full": "ישור לשורה מלאה", "Ordered List": "רשימה ממוספרת", "Bulleted List": "רשימה לא ממוספרת", "Decrease Indent": "הקטן כניסה", "Increase Indent": "הגדל כניסה", "Font Color": "צבע גופן", "Background Color": "צבע רקע", "Horizontal Rule": "קו אנכי", "Insert Web Link": "הכנס היפר-קישור", "Insert/Modify Image": "הכנס/שנה תמונה", "Insert Table": "הכנס טבלה", "Toggle HTML Source": "שנה מצב קוד HTML", "Enlarge Editor": "הגדל את העורך", "About this editor": "אודות עורך זה", "Help using editor": "עזרה לשימוש בעורך", "Current style": "סגנון נוכחי", "Undoes your last action": "מבטל את פעולתך האחרונה", "Redoes your last action": "מבצע מחדש את הפעולה האחרונה שביטלת", "Cut selection": "גזור בחירה", "Copy selection": "העתק בחירה", "Paste from clipboard": "הדבק מהלוח", "Direction left to right": "כיוון משמאל לימין", "Direction right to left": "כיוון מימין לשמאל", "OK": "אישור", "Cancel": "ביטול", "Path": "נתיב עיצוב", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "אתה במצב טקסט נקי (קוד). השתמש בכפתור [<>] כדי לחזור למצב WYSIWYG (תצוגת עיצוב).", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "מצב מסך מלא יוצר בעיות בדפדפן Internet Explorer, עקב באגים בדפדפן לא יכולנו לפתור את זה. את/ה עלול/ה לחוות תצוגת זבל, בעיות בתפקוד העורך ו/או קריסה של הדפדפן. אם המערכת שלך היא Windows 9x סביר להניח שתקבל/י ", "Cancel": "ביטול", "Insert/Modify Link": "הוסף/שנה קישור", "New window (_blank)": "חלון חדש (_blank)", "None (use implicit)": "ללא (השתמש ב-frame הקיים)", "Other": "אחר", "Same frame (_self)": "אותו frame (_self)", "Target:": "יעד:", "Title (tooltip):": "כותרת (tooltip):", "Top frame (_top)": "Frame עליון (_top)", "URL:": "URL:", "You must enter the URL where this link points to": "חובה לכתוב URL שאליו קישור זה מצביע" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/he.js
JavaScript
art
3,188
// I18N constants -- UTF-8 // by Dave Lo -- dlo@interactivetools.com { "Bold": "粗體", "Italic": "斜體", "Underline": "底線", "Strikethrough": "刪除線", "Subscript": "下標", "Superscript": "上標", "Justify Left": "位置靠左", "Justify Center": "位置居中", "Justify Right": "位置靠右", "Justify Full": "位置左右平等", "Ordered List": "順序清單", "Bulleted List": "無序清單", "Decrease Indent": "減小行前空白", "Increase Indent": "加寬行前空白", "Font Color": "文字顏色", "Background Color": "背景顏色", "Horizontal Rule": "水平線", "Insert Web Link": "插入連結", "Insert/Modify Image": "插入圖形", "Insert Table": "插入表格", "Toggle HTML Source": "切換HTML原始碼", "Enlarge Editor": "放大", "About this editor": "關於 Xinha", "Help using editor": "說明", "Current style": "字體例子" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/b5.js
JavaScript
art
923
// I18N constants // // LANG: "pt_br", ENCODING: UTF-8 // Portuguese Brazilian Translation // // Initial basic work by Alex Piaz <webmaster@globalmap.com> // // Author: Marcio Barbosa, <marcio@mpg.com.br> // MSN: tomarshall@msn.com - ICQ: 69419933 // Site: http://www.mpg.com.br // // Last revision: 06 september 2007 // Please don´t remove this information // If you modify any source, please insert a comment with your name and e-mail // // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt) { "About": "Sobre", "About Xinha": "Sobre o Xinha", "Absbottom": "Inferior absoluto", "Absmiddle": "Meio absoluto", "Alignment:": "Alinhamento", "Alternate text:": "Texto alternativo", "Baseline": "Linha base", "Bold": "Negrito", "Border thickness:": "Espessura da borda", "Bottom": "Botão", "CTRL-0 (zero)": "CTRL-0 (zero)", "CTRL-1 .. CTRL-6": "CTRL-1 .. CTRL-6", "CTRL-A": "CTRL-A", "CTRL-B": "CTRL-B", "CTRL-C": "CTRL-C", "CTRL-E": "CTRL-E", "CTRL-I": "CTRL-I", "CTRL-J": "CTRL-J", "CTRL-L": "CTRL-L", "CTRL-N": "CTRL-N", "CTRL-R": "CTRL-R", "CTRL-S": "CTRL-S", "CTRL-U": "CTRL-U", "CTRL-V": "CTRL-V", "CTRL-X": "CTRL-X", "CTRL-Y": "CTRL-Y", "CTRL-Z": "CTRL-Z", "Cancel": "Cancelar", "Cell padding:": "Espaçamento interno da célula:", "Cell spacing:": "Espaçamento da célula:", "Clean content pasted from Word": "Limpar conteúdo copiado do Word", "Close": "Fechar", "Collapse borders:": "Bordas fechadas:", "Cols:": "Colunas:", "Constructing object": "Construindo objeto", "Copy selection": "Copiar seleção", "Create Statusbar": "Criar barra de informação (statusbar)", "Create Toolbar": "Criar Barra de Ferramentas", "Current style": "Estilo Atual", "Cut selection": "Recortar seleção", "Developer": "Desenvolvedor", "ENTER": "ENTRAR", "Editor Help": "Ajuda do Editor", "Em": "Em", "Enter the image URL here": "Entre aqui com a URL da imagem", "Finishing": "Terminando", "Fixed width columns": "Colunas com largura fixa", "For browsers that don't support images": "Para navegadores que não suportam imagens", "Generate Xinha framework": "Gerar Área de Trabalho do Xinha", "Headings": "Títulos", "Horizontal padding": "Espaçamento interno horizontal", "Horizontal:": "Horizontal:", "Image Preview:": "Visualização da Imagem:", "Image URL:": "URL da imagem:", "Init editor size": "Iniciar tamanho do editor", "Insert Image": "Inserir Imagem", "Insert Table": "Inserir Tabela", "Insert/Modify Link": "Inserir/Modificar Link", "Italic": "Itálico", "Justify Center": "Justificar Centralizado", "Justify Full": "Justificar Completamente", "Justify Left": "Justificar à Esquerda", "Justify Right": "Justificar à Direita", "Keyboard shortcuts": "Atalhos de Teclado", "Layout": "Esquema", "Leave empty for no border": "Deixe em branco para não ter bordas", "Left": "Esquerda", "License": "Licença", "Loading in progress. Please wait!": "Carregamento em processo. Por favor, aguarde!", "Middle": "Meio", "Name": "Nome", "New window (_blank)": "Nova janela (_blank)", "None (use implicit)": "Nenhum (uso implicito)", "Not set": "Não definido", "Number of columns": "Número de colunas", "Number of rows": "Número de linhas", "OK": "OK", "Paste from clipboard": "Colar da Área de Transferência", "Path": "Caminho", "Percent": "Porcentagem", "Pixels": "Pixels", "Plugins": "Plugins", "Positioning of this image": "Posicionamento desta imagem", "Positioning of this table": "Posicionamento desta tabela", "Preview": "Visualização", "Preview the image in a new window": "Visualizar a imagem em uma nova janela", "Redoes your last action": "Refazer sua última ação", "Right": "Direita", "Rows:": "Linhas:", "SHIFT-ENTER": "SHIFT-ENTER", "Same frame (_self)": "Mesmo frame (_self)", "Select Color": "Selecionar côr", "Select all": "Selecionar tudo", "Set format to paragraph": "Definir formato para o parágrafo", "Space between adjacent cells": "Espaço entre células adjacentes", "Space between content and border in cell": "Espaço entre conteúdo e borda na célula", "Spacing": "Espaçamento", "Sponsored by": "Patrocinado por", "Strikethrough": "Tachado", "Target:": "Destino:", "Texttop": "Texto no topo", "Thanks": "Agradecimentos", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "O botão Colar não funciona em navegadores baseado no Mozilla (por razões técnicas de segurança). Pressione CTRL-V no seu teclado para colar diretamente.", "The editor provides the following key combinations:": "Este editor fornece a seguinte combinação de teclas:", "Title (tooltip):": "Título (tooltip)", "Top": "Topo", "Top frame (_top)": "Frame no topo (_top)", "URL:": "URL:", "Underline": "Sublinhado", "Undoes your last action": "Desfazer sua última ação", "Version": "Versão", "Vertical padding": "Espaçamento interno vertical", "Vertical:": "Vertical:", "Width of the table": "Larguran da tabela", "Width unit": "Unidade de largura", "Width:": "Largura:", "Would you like to clear font colours?": "Deseja limpar as cores de fonte", "Would you like to clear font sizes?": "Deseja limpar os tamanhos de fonte", "Would you like to clear font typefaces?": "Deseja limpar os tipos de fonte", "Xinha Help": "Ajuda do Xinha", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Você está no MODO TEXTO. Use o botão [<>] para mudar para o modo de Visualização (WYSIWYG)", "Your Document is not well formed. Check JavaScript console for details.": "Seu Documento não está formatado corretamente. Verifique o console do JavaScript para maiores detalhes.", "insert linebreak": "inserir quebra de linha", "new paragraph": "novo parágrafo", // not find with lc_parse_strings.php "Subscript": "Subescrito", "Superscript": "Sobrescrito", "Direction left to right": "Da esquerda para direita", "Direction right to left": "Da direita para esquerda", "Remove formatting": "Remover formatação", "Select all": "Selecionar tudo", "Print document": "Imprimir documento", "Clear MSOffice tags": "Limpar tags do MS Office", "Clear Inline Font Specifications": "Limpar especificações de fontes inline", "Split Block": "Dividir Bloco", "Toggle Borders": "Mudar Bordas", "Save as": "Salvar como", "Insert/Overwrite": "Inserir/Sobrescrever", "&#8212; format &#8212;": "&#8212; formato &#8212;", "Heading 1": "Título 1", "Heading 2": "Título 2", "Heading 3": "Título 3", "Heading 4": "Título 4", "Heading 5": "Título 5", "Heading 6": "Título 6", "Normal": "Normal", "Address": "Endereço", "Formatted": "Formatado", "&#8212; font &#8212;": "&#8212; fonte &#8212;", "&#8212; size &#8212;": "&#8212; tamanho &#8212;", "Ordered List": "Lista Numerada", "Bulleted List": "Lista Marcadores", "Decrease Indent": "Diminuir Indentação", "Increase Indent": "Aumentar Indentação", "Font Color": "Cor da Fonte", "Background Color": "Cor do Fundo", "Horizontal Rule": "Linha Horizontal", "Insert Web Link": "Inserir Link", "Insert/Modify Image": "Inserir/Modificar Imagem", "Insert Table": "Inserir Tabela", "Toggle HTML Source": "Ver Código-Fonte", "Enlarge Editor": "Expandir Editor", "About this editor": "Sobre este editor", "Help using editor": "Ajuda - Usando o editor" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/pt_br.js
JavaScript
art
7,600
// I18N constants // LANG: "sh", ENCODING: UTF-8 | ISO-8859-2 // Author: Ljuba Ranković, http://www.rankovic.net/ljubar // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Masno", "Italic": "Kurziv", "Underline": "Podvučeno", "Strikethrough": "Precrtano", "Subscript": "Indeks-tekst", "Superscript": "Eksponent-tekst", "Justify Left":"Ravnanje ulevo", "Justify Center": "Ravnanje po simetrali", "Justify Right": "Ravnanje udesno", "Justify Full": "Puno ravnanje", "Ordered List": "Lista sa rednim brojevima", "Bulleted List": "Lista sa simbolima", "Decrease Indent": "smanji uvlačenje", "Increase Indent": "Povećaj uvlačenje", "Font Color": "Boja slova", "Background Color": "Boja pozadine", "Horizontal Rule": "Horizontalna linija", "Insert Web Link": "Dodaj web link", "Insert/Modify Image": "Dodaj/promeni sliku", "Insert Table": "Ubaci tabelu", "Toggle HTML Source": "Prebaci na HTML kod", "Enlarge Editor": "Povećaj editor", "About this editor": "O ovom editoru", "Help using editor": "Pomoć pri korišćenju editora", "Current style": "Važeći stil", "Undoes your last action": "Poništava poslednju radnju", "Redoes your last action": "Vraća poslednju radnju", "Cut selection": "Iseci izabrano", "Copy selection": "Kopiraj izabrano", "Paste from clipboard": "Zalepi iz klipborda", "Direction left to right": "Pravac s leva na desno", "Direction right to left": "Pravac s desna na levo", "Remove formatting": "Ukoni formatiranje", "Select all": "Izaberi sve", "Print document": "Štampaj dokument", "Clear MSOffice tags": "Obriši MSOffice tagove", "Clear Inline Font Specifications": "Obriši dodeljene osobine fonta", "Split Block": "Podeli blok", "Toggle Borders": "Izmeni okvire", "&#8212; format &#8212;": "&#8212; Format &#8212;", "Heading 1": "Zaglavlje 1", "Heading 2": "Zaglavlje 2", "Heading 3": "Zaglavlje 3", "Heading 4": "Zaglavlje 4", "Heading 5": "Zaglavlje 5", "Heading 6": "Zaglavlje 6", "Normal": "Običan", "Address": "Adresa", "Formatted": "Formatiran", // dialogs "OK": "OK", "Cancel": "Poništi", "Path": "Putanja", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Nalazite se u TEXT režimu. Koristite [<>] dugme za povratak na WYSIWYG.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "", "Alignment:": "Ravnanje", "Not set": "Nije postavljeno", "Left": "Levo", "Right": "Desno", "Texttop": "Vrh teksta", "Absmiddle": "Apsolutna sredina", "Baseline": "Donja linija", "Absbottom": "Apsolutno dno", "Bottom": "Dno", "Middle": "Sredina", "Top": "Vrh", "Layout": "Prelom", "Spacing": "Razmak", "Horizontal:": "Po horizontali", "Horizontal padding": "Horizontalno odstojanje", "Vertical:": "Po vertikali", "Vertical padding": "Vertikalno odstojanje", "Border thickness:": "Debljina okvira", "Leave empty for no border": "Ostavi prazno kad nema okvira", // Insert Link "Insert/Modify Link": "Dodaj/promeni Link", "None (use implicit)": "koristi podrazumevano", "New window (_blank)": "Novom prozoru (_blank)", "Same frame (_self)": "Isti frejm (_self)", "Top frame (_top)": "Glavni frejm (_top)", "Other": "Drugo", "Target:": "Otvori u:", "Title (tooltip):": "Naziv (tooltip):", "URL:": "URL:", "You must enter the URL where this link points to": "Morate uneti URL na koji vodi ovaj link", // Insert Table "Insert Table": "Ubaci tabelu", "Rows:": "Redovi", "Number of rows": "Broj redova", "Cols:": "Kolone", "Number of columns": "Broj kolona", "Width:": "Širina", "Width of the table": "Širina tabele", "Percent": "Procenat", "Pixels": "Pikseli", "Em": "Em", "Width unit": "Jedinica širine", "Fixed width columns": "Fiksirana širina kolona", "Positioning of this table": "Postavljanje ove tabele", "Cell spacing:": "Rastojanje ćelija", "Space between adjacent cells": "Rastojanje naspramnih ćelija", "Cell padding:": "Unutrašnja odstojanja u ćeliji", "Space between content and border in cell": "Rastojanje između sadržaja i okvira ćelije", // Insert Image "Insert Image": "Ubaci sliku", "Image URL:": "URL slike", "Enter the image URL here": "Unesite URL slike ovde", "Preview": "Pregled", "Preview the image in a new window": "Pregledaj sliku u novom prozoru", "Alternate text:": "Alternativni tekst", "For browsers that don't support images": "Za pretraživače koji ne podržavaju slike", "Positioning of this image": "Postavljanje ove slike", "Image Preview:": "Pregled slike", // Select Color popup "Select Color": "Izaberite boju" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/sh.js
JavaScript
art
5,411
// I18N constants // LANG: "ch", ENCODING: UTF-8 // Samuel Stone, http://stonemicro.com/ { "Bold": "粗體", "Italic": "斜體", "Underline": "底線", "Strikethrough": "刪線", "Subscript": "下標", "Superscript": "上標", "Justify Left": "靠左", "Justify Center": "居中", "Justify Right": "靠右", "Justify Full": "整齊", "Ordered List": "順序清單", "Bulleted List": "無序清單", "Decrease Indent": "伸排", "Increase Indent": "縮排", "Font Color": "文字顏色", "Background Color": "背景顏色", "Horizontal Rule": "水平線", "Insert Web Link": "插入連結", "Insert/Modify Image": "插入圖像", "Insert Table": "插入表格", "Toggle HTML Source": "切換HTML原始碼", "Enlarge Editor": "伸出編輯系統", "About this editor": "關於 Xinha", "Help using editor": "說明", "Current style": "字體例子", "Undoes your last action": "回原", "Redoes your last action": "重来", "Cut selection": "剪制选项", "Copy selection": "复制选项", "Paste from clipboard": "贴上", "Direction left to right": "从左到右", "Direction right to left": "从右到左", "OK": "好", "Cancel": "取消", "Path": "途徑", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "你在用純字編輯方式. 用 [<>] 按鈕轉回 所見即所得 編輯方式.", "The full screen mode is known to cause problems with Internet Explorer, due to browser bugs that we weren": "整頁式在Internet Explorer 上常出問題, 因為這是 Internet Explorer 的無名問題,我們無法解決。你可能看見一些垃圾,或遇到其他問題。我們已警告了你. 如果要轉到 正頁式 請按 好.", "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.": "The Paste button does not work in Mozilla based web browsers (technical security reasons). Press CTRL-V on your keyboard to paste directly.", "Cancel": "取消", "Insert/Modify Link": "插入/改寫連結", "New window (_blank)": "新窗户(_blank)", "None (use implicit)": "無(use implicit)", "Other": "其他", "Same frame (_self)": "本匡 (_self)", "Target:": "目標匡:", "Title (tooltip):": "主題 (tooltip):", "Top frame (_top)": "上匡 (_top)", "URL:": "網址:", "You must enter the URL where this link points to": "你必須輸入你要连结的網址" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/ch.js
JavaScript
art
2,474
// I18N constants // LANG: "ee", ENCODING: UTF-8 // Author: Martin Raie, <albertvill@hot.ee> // FOR TRANSLATORS: // // 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE // (at least a valid email address) // // 2. PLEASE TRY TO USE UTF-8 FOR ENCODING; // (if this is not possible, please include a comment // that states what encoding is necessary.) { "Bold": "Paks", "Italic": "Kursiiv", "Underline": "Allakriipsutatud", "Strikethrough": "Läbikriipsutatud", "Subscript": "Allindeks", "Superscript": "Ülaindeks", "Justify Left": "Joonda vasakule", "Justify Center": "Joonda keskele", "Justify Right": "Joonda paremale", "Justify Full": "Rööpjoonda", "Ordered List": "Nummerdus", "Bulleted List": "Täpploend", "Decrease Indent": "Vähenda taanet", "Increase Indent": "Suurenda taanet", "Font Color": "Fondi värv", "Background Color": "Tausta värv", "Horizontal Rule": "Horisontaaljoon", "Insert Web Link": "Lisa viit", "Insert/Modify Image": "Lisa pilt", "Insert Table": "Lisa tabel", "Toggle HTML Source": "HTML/tavaline vaade", "Enlarge Editor": "Suurenda toimeti aken", "About this editor": "Teave toimeti kohta", "Help using editor": "Spikker", "Current style": "Kirjastiil", "Undoes your last action": "Võta tagasi", "Redoes your last action": "Tee uuesti", "Cut selection": "Lõika", "Copy selection": "Kopeeri", "Paste from clipboard": "Kleebi", "OK": "OK", "Cancel": "Loobu", "Path": "Path", "You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.": "Sa oled tekstireziimis. Kasuta nuppu [<>] lülitamaks tagasi WYSIWIG reziimi." }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/lang/ee.js
JavaScript
art
1,654
/*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- -- Xinha (is not htmlArea) - http://xinha.org -- -- Use of Xinha is granted by the terms of the htmlArea License (based on -- BSD license) please read license.txt in this package for details. -- -- Copyright (c) 2005-2008 Xinha Developer Team and contributors -- -- Xinha was originally based on work by Mihai Bazon which is: -- Copyright (c) 2003-2004 dynarch.com. -- Copyright (c) 2002-2003 interactivetools.com, inc. -- This copyright notice MUST stay intact for use. -- -- Developers - Coding Style: -- Before you are going to work on Xinha code, please see http://trac.xinha.org/wiki/Documentation/StyleGuide -- -- $HeadURL: http://svn.xinha.org/trunk/XinhaCore.js $ -- $LastChangedDate: 2010-05-12 09:40:06 +1200 (Wed, 12 May 2010) $ -- $LastChangedRevision: 1263 $ -- $LastChangedBy: gogo $ --------------------------------------------------------------------------*/ /*jslint regexp: false, rhino: false, browser: true, bitwise: false, forin: true, adsafe: false, evil: true, nomen: false, glovar: false, debug: false, eqeqeq: false, passfail: false, sidebar: false, laxbreak: false, on: false, cap: true, white: false, widget: false, undef: true, plusplus: false*/ /*global Dialog , _editor_css , _editor_icons, _editor_lang , _editor_skin , _editor_url, dumpValues, ActiveXObject, HTMLArea, _editor_lcbackend*/ /** Information about the Xinha version * @type Object */ Xinha.version = { 'Release' : 'Trunk', 'Head' : '$HeadURL: http://svn.xinha.org/trunk/XinhaCore.js $'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), 'Date' : '$LastChangedDate: 2010-05-12 09:40:06 +1200 (Wed, 12 May 2010) $'.replace(/^[^:]*:\s*([0-9\-]*) ([0-9:]*) ([+0-9]*) \((.*)\)\s*\$/, '$4 $2 $3'), 'Revision' : '$LastChangedRevision: 1263 $'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), 'RevisionBy': '$LastChangedBy: gogo $'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1') }; //must be here. it is called while converting _editor_url to absolute Xinha._resolveRelativeUrl = function( base, url ) { if(url.match(/^([^:]+\:)?\/\//)) { return url; } else { var b = base.split("/"); if(b[b.length - 1] === "") { b.pop(); } var p = url.split("/"); if(p[0] == ".") { p.shift(); } while(p[0] == "..") { b.pop(); p.shift(); } return b.join("/") + "/" + p.join("/"); } }; if ( typeof _editor_url == "string" ) { // Leave exactly one backslash at the end of _editor_url _editor_url = _editor_url.replace(/\x2f*$/, '/'); // convert _editor_url to absolute if(!_editor_url.match(/^([^:]+\:)?\//)) { (function() { var tmpPath = window.location.toString().replace(/\?.*$/,'').split("/"); tmpPath.pop(); _editor_url = Xinha._resolveRelativeUrl(tmpPath.join("/"), _editor_url); })(); } } else { alert("WARNING: _editor_url is not set! You should set this variable to the editor files path; it should preferably be an absolute path, like in '/xinha/', but it can be relative if you prefer. Further we will try to load the editor files correctly but we'll probably fail."); _editor_url = ''; } // make sure we have a language if ( typeof _editor_lang == "string" ) { _editor_lang = _editor_lang.toLowerCase(); } else { _editor_lang = "en"; } // skin stylesheet to load if ( typeof _editor_skin !== "string" ) { _editor_skin = ""; } if ( typeof _editor_icons !== "string" ) { _editor_icons = ""; } /** * The list of Xinha editors on the page. May be multiple editors. * You can access each editor object through this global variable. * * Example:<br /> * <code> * var html = __xinhas[0].getEditorContent(); // gives you the HTML of the first editor in the page * </code> */ var __xinhas = []; // browser identification /** Cache the user agent for the following checks * @type String * @private */ Xinha.agt = navigator.userAgent.toLowerCase(); /** Browser is Microsoft Internet Explorer * @type Boolean */ Xinha.is_ie = ((Xinha.agt.indexOf("msie") != -1) && (Xinha.agt.indexOf("opera") == -1)); /** Version Number, if browser is Microsoft Internet Explorer * @type Float */ Xinha.ie_version= parseFloat(Xinha.agt.substring(Xinha.agt.indexOf("msie")+5)); /** Browser is Opera * @type Boolean */ Xinha.is_opera = (Xinha.agt.indexOf("opera") != -1); /** Version Number, if browser is Opera * @type Float */ if(Xinha.is_opera && Xinha.agt.match(/opera[\/ ]([0-9.]+)/)) { Xinha.opera_version = parseFloat(RegExp.$1); } else { Xinha.opera_version = 0; } /** Browserengine is KHTML (Konqueror, Safari) * @type Boolean */ Xinha.is_khtml = (Xinha.agt.indexOf("khtml") != -1); /** Browser is WebKit * @type Boolean */ Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); /** Webkit build number * @type Integer */ Xinha.webkit_version = parseInt(navigator.appVersion.replace(/.*?AppleWebKit\/([\d]).*?/,'$1'), 10); /** Browser is Safari * @type Boolean */ Xinha.is_safari = (Xinha.agt.indexOf("safari") != -1); /** Browser is Google Chrome * @type Boolean */ Xinha.is_chrome = (Xinha.agt.indexOf("chrome") != -1); /** OS is MacOS * @type Boolean */ Xinha.is_mac = (Xinha.agt.indexOf("mac") != -1); /** Browser is Microsoft Internet Explorer Mac * @type Boolean */ Xinha.is_mac_ie = (Xinha.is_ie && Xinha.is_mac); /** Browser is Microsoft Internet Explorer Windows * @type Boolean */ Xinha.is_win_ie = (Xinha.is_ie && !Xinha.is_mac); /** Browser engine is Gecko (Mozilla), applies also to Safari and Opera which work * largely similar. *@type Boolean */ Xinha.is_gecko = (navigator.product == "Gecko") || Xinha.is_opera; /** Browser engine is really Gecko, i.e. Browser is Firefox (or Netscape, SeaMonkey, Flock, Songbird, Beonex, K-Meleon, Camino, Galeon, Kazehakase, Skipstone, or whatever derivate might exist out there...) * @type Boolean */ Xinha.is_real_gecko = (navigator.product == "Gecko" && !Xinha.is_webkit); /** Gecko version lower than 1.9 * @type Boolean */ Xinha.is_ff2 = Xinha.is_real_gecko && parseInt(navigator.productSub.substr(0,10), 10) < 20071210; /** File is opened locally opened ("file://" protocol) * @type Boolean * @private */ Xinha.isRunLocally = document.URL.toLowerCase().search(/^file:/) != -1; /** Editing is enabled by document.designMode (Gecko, Opera), as opposed to contenteditable (IE) * @type Boolean * @private */ Xinha.is_designMode = (typeof document.designMode != 'undefined' && !Xinha.is_ie); // IE has designMode, but we're not using it /** Check if Xinha can run in the used browser, otherwise the textarea will be remain unchanged * @type Boolean * @private */ Xinha.checkSupportedBrowser = function() { return Xinha.is_real_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.2) || Xinha.ie_version >= 5.5 || Xinha.webkit_version >= 522; }; /** Cache result of checking for browser support * @type Boolean * @private */ Xinha.isSupportedBrowser = Xinha.checkSupportedBrowser(); if ( Xinha.isRunLocally && Xinha.isSupportedBrowser) { alert('Xinha *must* be installed on a web server. Locally opened files (those that use the "file://" protocol) cannot properly function. Xinha will try to initialize but may not be correctly loaded.'); } /** Creates a new Xinha object * @version $Rev: 1263 $ $LastChangedDate: 2010-05-12 09:40:06 +1200 (Wed, 12 May 2010) $ * @constructor * @param {String|DomNode} textarea the textarea to replace; can be either only the id or the DOM object as returned by document.getElementById() * @param {Xinha.Config} config optional if no Xinha.Config object is passed, the default config is used */ function Xinha(textarea, config) { if ( !Xinha.isSupportedBrowser ) { return; } if ( !textarea ) { throw new Error ("Tried to create Xinha without textarea specified."); } if ( typeof config == "undefined" ) { /** The configuration used in the editor * @type Xinha.Config */ this.config = new Xinha.Config(); } else { this.config = config; } if ( typeof textarea != 'object' ) { textarea = Xinha.getElementById('textarea', textarea); } /** This property references the original textarea, which is at the same time the editor in text mode * @type DomNode textarea */ this._textArea = textarea; this._textArea.spellcheck = false; Xinha.freeLater(this, '_textArea'); // /** Before we modify anything, get the initial textarea size * @private * @type Object w,h */ this._initial_ta_size = { w: textarea.style.width ? textarea.style.width : ( textarea.offsetWidth ? ( textarea.offsetWidth + 'px' ) : ( textarea.cols + 'em') ), h: textarea.style.height ? textarea.style.height : ( textarea.offsetHeight ? ( textarea.offsetHeight + 'px' ) : ( textarea.rows + 'em') ) }; if ( document.getElementById("loading_" + textarea.id) || this.config.showLoading ) { if (!document.getElementById("loading_" + textarea.id)) { Xinha.createLoadingMessage(textarea); } this.setLoadingMessage(Xinha._lc("Constructing object")); } /** the current editing mode * @private * @type string "wysiwyg"|"text" */ this._editMode = "wysiwyg"; /** this object holds the plugins used in the editor * @private * @type Object */ this.plugins = {}; /** periodically updates the toolbar * @private * @type timeout */ this._timerToolbar = null; /** periodically takes a snapshot of the current editor content * @private * @type timeout */ this._timerUndo = null; /** holds the undo snapshots * @private * @type Array */ this._undoQueue = [this.config.undoSteps]; /** the current position in the undo queue * @private * @type integer */ this._undoPos = -1; /** use our own undo implementation (true) or the browser's (false) * @private * @type Boolean */ this._customUndo = true; /** the document object of the page Xinha is embedded in * @private * @type document */ this._mdoc = document; // cache the document, we need it in plugins /** doctype of the edited document (fullpage mode) * @private * @type string */ this.doctype = ''; /** running number that identifies the current editor * @public * @type integer */ this.__htmlarea_id_num = __xinhas.length; __xinhas[this.__htmlarea_id_num] = this; /** holds the events for use with the notifyOn/notifyOf system * @private * @type Object */ this._notifyListeners = {}; // Panels var panels = { right: { on: true, container: document.createElement('td'), panels: [] }, left: { on: true, container: document.createElement('td'), panels: [] }, top: { on: true, container: document.createElement('td'), panels: [] }, bottom: { on: true, container: document.createElement('td'), panels: [] } }; for ( var i in panels ) { if(!panels[i].container) { continue; } // prevent iterating over wrong type panels[i].div = panels[i].container; // legacy panels[i].container.className = 'panels panels_' + i; Xinha.freeLater(panels[i], 'container'); Xinha.freeLater(panels[i], 'div'); } /** holds the panels * @private * @type Array */ // finally store the variable this._panels = panels; // Init some properties that are defined later /** The statusbar container * @type DomNode statusbar div */ this._statusBar = null; /** The DOM path that is shown in the statusbar in wysiwyg mode * @private * @type DomNode */ this._statusBarTree = null; /** The message that is shown in the statusbar in text mode * @private * @type DomNode */ this._statusBarTextMode = null; /** Holds the items of the DOM path that is shown in the statusbar in wysiwyg mode * @private * @type Array tag names */ this._statusBarItems = []; /** Holds the parts (table cells) of the UI (toolbar, panels, statusbar) * @type Object framework parts */ this._framework = {}; /** Them whole thing (table) * @private * @type DomNode */ this._htmlArea = null; /** This is the actual editable area.<br /> * Technically it's an iframe that's made editable using window.designMode = 'on', respectively document.body.contentEditable = true (IE).<br /> * Use this property to get a grip on the iframe's window features<br /> * * @type window */ this._iframe = null; /** The document object of the iframe.<br /> * Use this property to perform DOM operations on the edited document * @type document */ this._doc = null; /** The toolbar * @private * @type DomNode */ this._toolBar = this._toolbar = null; //._toolbar is for legacy, ._toolBar is better thanks. /** Holds the botton objects * @private * @type Object */ this._toolbarObjects = {}; //hook in config.Events as as a "plugin" this.plugins.Events = { name: 'Events', developer : 'The Xinha Core Developer Team', instance: config.Events }; }; // ray: What is this for? Do we need it? Xinha.onload = function() { }; Xinha.init = function() { Xinha.onload(); }; // cache some regexps /** Identifies HTML tag names * @type RegExp */ Xinha.RE_tagName = /(<\/|<)\s*([^ \t\n>]+)/ig; /** Exracts DOCTYPE string from HTML * @type RegExp */ Xinha.RE_doctype = /(<!doctype((.|\n)*?)>)\n?/i; /** Finds head section in HTML * @type RegExp */ Xinha.RE_head = /<head>((.|\n)*?)<\/head>/i; /** Finds body section in HTML * @type RegExp */ Xinha.RE_body = /<body[^>]*>((.|\n|\r|\t)*?)<\/body>/i; /** Special characters that need to be escaped when dynamically creating a RegExp from an arbtrary string * @private * @type RegExp */ Xinha.RE_Specials = /([\/\^$*+?.()|{}\[\]])/g; /** When dynamically creating a RegExp from an arbtrary string, some charactes that have special meanings in regular expressions have to be escaped. * Run any string through this function to escape reserved characters. * @param {string} string the string to be escaped * @returns string */ Xinha.escapeStringForRegExp = function (string) { return string.replace(Xinha.RE_Specials, '\\$1'); }; /** Identifies email addresses * @type RegExp */ Xinha.RE_email = /^[_a-z\d\-\.]{3,}@[_a-z\d\-]{2,}(\.[_a-z\d\-]{2,})+$/i; /** Identifies URLs * @type RegExp */ Xinha.RE_url = /(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_\-]{2,}(\.[a-z0-9_\-]{2,}){2,}(:[0-9]+)?(\/\S+)*)/i; /** * This class creates an object that can be passed to the Xinha constructor as a parameter. * Set the object's properties as you need to configure the editor (toolbar etc.) * @version $Rev: 1263 $ $LastChangedDate: 2010-05-12 09:40:06 +1200 (Wed, 12 May 2010) $ * @constructor */ Xinha.Config = function() { /** The svn revision number * @type Number */ this.version = Xinha.version.Revision; /** This property controls the width of the editor.<br /> * Allowed values are 'auto', 'toolbar' or a numeric value followed by "px".<br /> * <code>auto</code>: let Xinha choose the width to use.<br /> * <code>toolbar</code>: compute the width size from the toolbar width.<br /> * <code>numeric value</code>: forced width in pixels ('600px').<br /> * * Default: <code>"auto"</code> * @type String */ this.width = "auto"; /** This property controls the height of the editor.<br /> * Allowed values are 'auto' or a numeric value followed by px.<br /> * <code>"auto"</code>: let Xinha choose the height to use.<br /> * <code>numeric value</code>: forced height in pixels ('200px').<br /> * Default: <code>"auto"</code> * @type String */ this.height = "auto"; /** Specifies whether the toolbar should be included * in the size, or are extra to it. If false then it's recommended * to have the size set as explicit pixel sizes (either in Xinha.Config or on your textarea)<br /> * * Default: <code>true</code> * * @type Boolean */ this.sizeIncludesBars = true; /** * Specifies whether the panels should be included * in the size, or are extra to it. If false then it's recommended * to have the size set as explicit pixel sizes (either in Xinha.Config or on your textarea)<br /> * * Default: <code>true</code> * * @type Boolean */ this.sizeIncludesPanels = true; /** * each of the panels has a dimension, for the left/right it's the width * for the top/bottom it's the height. * * WARNING: PANEL DIMENSIONS MUST BE SPECIFIED AS PIXEL WIDTHS<br /> *Default values: *<pre> * xinha_config.panel_dimensions = * { * left: '200px', // Width * right: '200px', * top: '100px', // Height * bottom: '100px' * } *</pre> * @type Object */ this.panel_dimensions = { left: '200px', // Width right: '200px', top: '100px', // Height bottom: '100px' }; /** To make the iframe width narrower than the toolbar width, e.g. to maintain * the layout when editing a narrow column of text, set the next parameter (in pixels).<br /> * * Default: <code>true</code> * * @type Integer|null */ this.iframeWidth = null; /** Enable creation of the status bar?<br /> * * Default: <code>true</code> * * @type Boolean */ this.statusBar = true; /** Intercept ^V and use the Xinha paste command * If false, then passes ^V through to browser editor widget, which is the only way it works without problems in Mozilla<br /> * * Default: <code>false</code> * * @type Boolean */ this.htmlareaPaste = false; /** <strong>Gecko only:</strong> Let the built-in routine for handling the <em>return</em> key decide if to enter <em>br</em> or <em>p</em> tags, * or use a custom implementation.<br /> * For information about the rules applied by Gecko, <a href="http://www.mozilla.org/editor/rules.html">see Mozilla website</a> <br /> * Possible values are <em>built-in</em> or <em>best</em><br /> * * Default: <code>"best"</code> * * @type String */ this.mozParaHandler = 'best'; /** This determines the method how the HTML output is generated. * There are two choices: * *<table border="1"> * <tr> * <td><em>DOMwalk</em></td> * <td>This is the classic and proven method. It recusively traverses the DOM tree * and builds the HTML string "from scratch". Tends to be a bit slow, especially in IE.</td> * </tr> * <tr> * <td><em>TransformInnerHTML</em></td> * <td>This method uses the JavaScript innerHTML property and relies on Regular Expressions to produce * clean XHTML output. This method is much faster than the other one.</td> * </tr> * </table> * * Default: <code>"DOMwalk"</code> * * @type String */ this.getHtmlMethod = 'DOMwalk'; /** Maximum size of the undo queue<br /> * Default: <code>20</code> * @type Integer */ this.undoSteps = 20; /** The time interval at which undo samples are taken<br /> * Default: <code>500</code> (1/2 sec) * @type Integer milliseconds */ this.undoTimeout = 500; /** Set this to true if you want to explicitly right-justify when setting the text direction to right-to-left<br /> * Default: <code>false</code> * @type Boolean */ this.changeJustifyWithDirection = false; /** If true then Xinha will retrieve the full HTML, starting with the &lt;HTML&gt; tag.<br /> * Default: <code>false</code> * @type Boolean */ this.fullPage = false; /** Raw style definitions included in the edited document<br /> * When a lot of inline style is used, perhaps it is wiser to use one or more external stylesheets.<br /> * To set tags P in red, H1 in blue andn A not underlined, we may do the following *<pre> * xinha_config.pageStyle = * 'p { color:red; }\n' + * 'h1 { color:bleu; }\n' + * 'a {text-decoration:none; }'; *</pre> * Default: <code>""</code> (empty) * @type String */ this.pageStyle = ""; /** Array of external stylesheets to load. (Reference these absolutely)<br /> * Example<br /> * <pre>xinha_config.pageStyleSheets = ["/css/myPagesStyleSheet.css","/css/anotherOne.css"];</pre> * Default: <code>[]</code> (empty) * @type Array */ this.pageStyleSheets = []; // specify a base href for relative links /** Specify a base href for relative links<br /> * ATTENTION: this does not work as expected and needs t be changed, see Ticket #961 <br /> * Default: <code>null</code> * @type String|null */ this.baseHref = null; /** If true, relative URLs (../) will be made absolute. * When the editor is in different directory depth * as the edited page relative image sources will break the display of your images. * this fixes an issue where Mozilla converts the urls of images and links that are on the same server * to relative ones (../) when dragging them around in the editor (Ticket #448)<br /> * Default: <code>true</code> * @type Boolean */ this.expandRelativeUrl = true; /** We can strip the server part out of URL to make/leave them semi-absolute, reason for this * is that the browsers will prefix the server to any relative links to make them absolute, * which isn't what you want most the time.<br /> * Default: <code>true</code> * @type Boolean */ this.stripBaseHref = true; /** We can strip the url of the editor page from named links (eg &lt;a href="#top"&gt;...&lt;/a&gt;) and links * that consist only of URL parameters (eg &lt;a href="?parameter=value"&gt;...&lt;/a&gt;) * reason for this is that browsers tend to prefixe location.href to any href that * that don't have a full url<br /> * Default: <code>true</code> * @type Boolean */ this.stripSelfNamedAnchors = true; /** In URLs all characters above ASCII value 127 have to be encoded using % codes<br /> * Default: <code>true</code> * @type Boolean */ this.only7BitPrintablesInURLs = true; /** If you are putting the HTML written in Xinha into an email you might want it to be 7-bit * characters only. This config option will convert all characters consuming * more than 7bits into UNICODE decimal entity references (actually it will convert anything * below <space> (chr 20) except cr, lf and tab and above <tilde> (~, chr 7E))<br /> * Default: <code>false</code> * @type Boolean */ this.sevenBitClean = false; /** Sometimes we want to be able to replace some string in the html coming in and going out * so that in the editor we use the "internal" string, and outside and in the source view * we use the "external" string this is useful for say making special codes for * your absolute links, your external string might be some special code, say "{server_url}" * an you say that the internal represenattion of that should be http://your.server/<br /> * Example: <code>{ 'html_string' : 'wysiwyg_string' }</code><br /> * Default: <code>{}</code> (empty) * @type Object */ this.specialReplacements = {}; //{ 'html_string' : 'wysiwyg_string' } /** A filter function for the HTML used inside the editor<br /> * Default: function (html) { return html } * * @param {String} html The whole document's HTML content * @return {String} The processed HTML */ this.inwardHtml = function (html) { return html; }; /** A filter function for the generated HTML<br /> * Default: function (html) { return html } * * @param {String} html The whole document's HTML content * @return {String} The processed HTML */ this.outwardHtml = function (html) { return html; }; /** This setting determines whether or not the editor will be automatically activated and focused when the page loads. * If the page contains only a single editor, autofocus can be set to true to focus it. * Alternatively, if the page contains multiple editors, autofocus may be set to the ID of the text area of the editor to be focused. * For example, the following setting would focus the editor attached to the text area whose ID is "myTextArea": * <code>xinha_config.autofocus = "myTextArea";</code> * Default: <code>false</code> * @type Boolean|String */ this.autofocus = false; /** Set to true if you want Word code to be cleaned upon Paste. This only works if * you use the toolbr button to paste, not ^V. This means that due to the restrictions * regarding pasting, this actually has no real effect in Mozilla <br /> * Default: <code>true</code> * @type Boolean */ this.killWordOnPaste = true; /** Enable the 'Target' field in the Make Link dialog. Note that the target attribute is invalid in (X)HTML strict<br /> * Default: <code>true</code> * @type Boolean */ this.makeLinkShowsTarget = true; /** CharSet of the iframe, default is the charset of the document * @type String */ this.charSet = (typeof document.characterSet != 'undefined') ? document.characterSet : document.charset; /** Whether the edited document should be rendered in Quirksmode or Standard Compliant (Strict) Mode.<br /> * This is commonly known as the "doctype switch"<br /> * for details read here http://www.quirksmode.org/css/quirksmode.html * * Possible values:<br /> * true : Quirksmode is used<br /> * false : Strict mode is used<br /> * null (default): the mode of the document Xinha is in is used * @type Boolean|null */ this.browserQuirksMode = null; // URL-s this.imgURL = "images/"; this.popupURL = "popups/"; /** RegExp allowing to remove certain HTML tags when rendering the HTML.<br /> * Example: remove span and font tags * <code> * xinha_config.htmlRemoveTags = /span|font/; * </code> * Default: <code>null</code> * @type RegExp|null */ this.htmlRemoveTags = null; /** Turning this on will turn all "linebreak" and "separator" items in your toolbar into soft-breaks, * this means that if the items between that item and the next linebreak/separator can * fit on the same line as that which came before then they will, otherwise they will * float down to the next line. * If you put a linebreak and separator next to each other, only the separator will * take effect, this allows you to have one toolbar that works for both flowToolbars = true and false * infact the toolbar below has been designed in this way, if flowToolbars is false then it will * create explictly two lines (plus any others made by plugins) breaking at justifyleft, however if * flowToolbars is false and your window is narrow enough then it will create more than one line * even neater, if you resize the window the toolbars will reflow. <br /> * Default: <code>true</code> * @type Boolean */ this.flowToolbars = true; /** Set to center or right to change button alignment in toolbar * @type String */ this.toolbarAlign = "left"; /** Set to true to display the font names in the toolbar font select list in their actual font. * Note that this doesn't work in IE, but doesn't hurt anything either. * Default: <code>false</code> * @type Boolean */ this.showFontStylesInToolbar = false; /** Set to true if you want the loading panel to show at startup<br /> * Default: <code>false</code> * @type Boolean */ this.showLoading = false; /** Set to false if you want to allow JavaScript in the content, otherwise &lt;script&gt; tags are stripped out.<br /> * This currently only affects the "DOMwalk" getHtmlMethod.<br /> * Default: <code>true</code> * @type Boolean */ this.stripScripts = true; /** See if the text just typed looks like a URL, or email address * and link it appropriatly * Note: Setting this option to false only affects Mozilla based browsers. * In InternetExplorer this is native behaviour and cannot be turned off.<br /> * Default: <code>true</code> * @type Boolean */ this.convertUrlsToLinks = true; /** Size of color picker cells<br /> * Use number + "px"<br /> * Default: <code>"6px"</code> * @type String */ this.colorPickerCellSize = '6px'; /** Granularity of color picker cells (number per column/row)<br /> * Default: <code>18</code> * @type Integer */ this.colorPickerGranularity = 18; /** Position of color picker from toolbar button<br /> * Default: <code>"bottom,right"</code> * @type String */ this.colorPickerPosition = 'bottom,right'; /** Set to true to show only websafe checkbox in picker<br /> * Default: <code>false</code> * @type Boolean */ this.colorPickerWebSafe = false; /** Number of recent colors to remember<br /> * Default: <code>20</code> * @type Integer */ this.colorPickerSaveColors = 20; /** Start up the editor in fullscreen mode<br /> * Default: <code>false</code> * @type Boolean */ this.fullScreen = false; /** You can tell the fullscreen mode to leave certain margins on each side.<br /> * The value is an array with the values for <code>[top,right,bottom,left]</code> in that order<br /> * Default: <code>[0,0,0,0]</code> * @type Array */ this.fullScreenMargins = [0,0,0,0]; /** Specify the method that is being used to calculate the editor's size<br/> * when we return from fullscreen mode. * There are two choices: * * <table border="1"> * <tr> * <td><em>initSize</em></td> * <td>Use the internal Xinha.initSize() method to calculate the editor's * dimensions. This is suitable for most usecases.</td> * </tr> * <tr> * <td><em>restore</em></td> * <td>The editor's dimensions will be stored before going into fullscreen * mode and restored when we return to normal mode, taking a possible * window resize during fullscreen in account.</td> * </tr> * </table> * * Default: <code>"initSize"</code> * @type String */ this.fullScreenSizeDownMethod = 'initSize'; /** This array orders all buttons except plugin buttons in the toolbar. Plugin buttons typically look for one * a certain button in the toolbar and place themselves next to it. * Default value: *<pre> *xinha_config.toolbar = * [ * ["popupeditor"], * ["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"], * ["separator","forecolor","hilitecolor","textindicator"], * ["separator","subscript","superscript"], * ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"], * ["separator","insertorderedlist","insertunorderedlist","outdent","indent"], * ["separator","inserthorizontalrule","createlink","insertimage","inserttable"], * ["linebreak","separator","undo","redo","selectall","print"], (Xinha.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]), * ["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright", "righttoleft"], * ["separator","htmlmode","showhelp","about"] * ]; *</pre> * @type Array */ this.toolbar = [ ["popupeditor"], ["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"], ["separator","forecolor","hilitecolor","textindicator"], ["separator","subscript","superscript"], ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"], ["separator","insertorderedlist","insertunorderedlist","outdent","indent"], ["separator","inserthorizontalrule","createlink","insertimage","inserttable"], ["linebreak","separator","undo","redo","selectall","print"], (Xinha.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]), ["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright", "righttoleft"], ["separator","htmlmode","showhelp","about"] ]; /** The fontnames listed in the fontname dropdown * Default value: *<pre> *xinha_config.fontname = *{ * "&#8212; font &#8212;" : '', * "Arial" : 'arial,helvetica,sans-serif', * "Courier New" : 'courier new,courier,monospace', * "Georgia" : 'georgia,times new roman,times,serif', * "Tahoma" : 'tahoma,arial,helvetica,sans-serif', * "Times New Roman" : 'times new roman,times,serif', * "Verdana" : 'verdana,arial,helvetica,sans-serif', * "impact" : 'impact', * "WingDings" : 'wingdings' *}; *</pre> * @type Object */ this.fontname = { "&#8212; font &#8212;": "", // &#8212; is mdash "Arial" : 'arial,helvetica,sans-serif', "Courier New" : 'courier new,courier,monospace', "Georgia" : 'georgia,times new roman,times,serif', "Tahoma" : 'tahoma,arial,helvetica,sans-serif', "Times New Roman" : 'times new roman,times,serif', "Verdana" : 'verdana,arial,helvetica,sans-serif', "impact" : 'impact', "WingDings" : 'wingdings' }; /** The fontsizes listed in the fontsize dropdown * Default value: *<pre> *xinha_config.fontsize = *{ * "&#8212; size &#8212;": "", * "1 (8 pt)" : "1", * "2 (10 pt)": "2", * "3 (12 pt)": "3", * "4 (14 pt)": "4", * "5 (18 pt)": "5", * "6 (24 pt)": "6", * "7 (36 pt)": "7" *}; *</pre> * @type Object */ this.fontsize = { "&#8212; size &#8212;": "", // &#8212; is mdash "1 (8 pt)" : "1", "2 (10 pt)": "2", "3 (12 pt)": "3", "4 (14 pt)": "4", "5 (18 pt)": "5", "6 (24 pt)": "6", "7 (36 pt)": "7" }; /** The tags listed in the formatblock dropdown * Default value: *<pre> *xinha_config.formatblock = *{ * "&#8212; size &#8212;": "", * "1 (8 pt)" : "1", * "2 (10 pt)": "2", * "3 (12 pt)": "3", * "4 (14 pt)": "4", * "5 (18 pt)": "5", * "6 (24 pt)": "6", * "7 (36 pt)": "7" *}; *</pre> * @type Object */ this.formatblock = { "&#8212; format &#8212;": "", // &#8212; is mdash "Heading 1": "h1", "Heading 2": "h2", "Heading 3": "h3", "Heading 4": "h4", "Heading 5": "h5", "Heading 6": "h6", "Normal" : "p", "Address" : "address", "Formatted": "pre" }; this.dialogOptions = { 'centered' : true, //true: dialog is shown in the center the screen, false dialog is shown near the clicked toolbar button 'greyout':true, //true: when showing modal dialogs, the page behind the dialoge is greyed-out 'closeOnEscape':true }; /** You can add functions to this object to be executed on specific events * Example: * <pre> * xinha_config.Events.onKeyPress = function (event) * { * //do something * return false; * } * </pre> * Note that <em>this</em> inside the function refers to the respective Xinha object * The possible function names are documented at <a href="http://trac.xinha.org/wiki/Documentation/EventHooks">http://trac.xinha.org/wiki/Documentation/EventHooks</a> */ this.Events = {}; /** ?? * Default: <code>{}</code> * @type Object */ this.customSelects = {}; /** Switches on some debugging (only in execCommand() as far as I see at the moment)<br /> * * Default: <code>false</code> * @type Boolean */ this.debug = false; this.URIs = { "blank": _editor_url + "popups/blank.html", "link": _editor_url + "modules/CreateLink/link.html", "insert_image": _editor_url + "modules/InsertImage/insert_image.html", "insert_table": _editor_url + "modules/InsertTable/insert_table.html", "select_color": _editor_url + "popups/select_color.html", "help": _editor_url + "popups/editor_help.html" }; /** The button list conains the definitions of the toolbar button. Normally, there's nothing to change here :) * <div style="white-space:pre">ADDING CUSTOM BUTTONS: please read below! * format of the btnList elements is "ID: [ ToolTip, Icon, Enabled in text mode?, ACTION ]" * - ID: unique ID for the button. If the button calls document.execCommand * it's wise to give it the same name as the called command. * - ACTION: function that gets called when the button is clicked. * it has the following prototype: * function(editor, buttonName) * - editor is the Xinha object that triggered the call * - buttonName is the ID of the clicked button * These 2 parameters makes it possible for you to use the same * handler for more Xinha objects or for more different buttons. * - ToolTip: tooltip, will be translated below * - Icon: path to an icon image file for the button * OR; you can use an 18x18 block of a larger image by supllying an array * that has three elemtents, the first is the larger image, the second is the column * the third is the row. The ros and columns numbering starts at 0 but there is * a header row and header column which have numbering to make life easier. * See images/buttons_main.gif to see how it's done. * - Enabled in text mode: if false the button gets disabled for text-only mode; otherwise enabled all the time.</div> * @type Object */ this.btnList = { bold: [ "Bold", Xinha._lc({key: 'button_bold', string: ["ed_buttons_main.png",3,2]}, 'Xinha'), false, function(e) { e.execCommand("bold"); } ], italic: [ "Italic", Xinha._lc({key: 'button_italic', string: ["ed_buttons_main.png",2,2]}, 'Xinha'), false, function(e) { e.execCommand("italic"); } ], underline: [ "Underline", Xinha._lc({key: 'button_underline', string: ["ed_buttons_main.png",2,0]}, 'Xinha'), false, function(e) { e.execCommand("underline"); } ], strikethrough: [ "Strikethrough", Xinha._lc({key: 'button_strikethrough', string: ["ed_buttons_main.png",3,0]}, 'Xinha'), false, function(e) { e.execCommand("strikethrough"); } ], subscript: [ "Subscript", Xinha._lc({key: 'button_subscript', string: ["ed_buttons_main.png",3,1]}, 'Xinha'), false, function(e) { e.execCommand("subscript"); } ], superscript: [ "Superscript", Xinha._lc({key: 'button_superscript', string: ["ed_buttons_main.png",2,1]}, 'Xinha'), false, function(e) { e.execCommand("superscript"); } ], justifyleft: [ "Justify Left", ["ed_buttons_main.png",0,0], false, function(e) { e.execCommand("justifyleft"); } ], justifycenter: [ "Justify Center", ["ed_buttons_main.png",1,1], false, function(e){ e.execCommand("justifycenter"); } ], justifyright: [ "Justify Right", ["ed_buttons_main.png",1,0], false, function(e) { e.execCommand("justifyright"); } ], justifyfull: [ "Justify Full", ["ed_buttons_main.png",0,1], false, function(e) { e.execCommand("justifyfull"); } ], orderedlist: [ "Ordered List", ["ed_buttons_main.png",0,3], false, function(e) { e.execCommand("insertorderedlist"); } ], unorderedlist: [ "Bulleted List", ["ed_buttons_main.png",1,3], false, function(e) { e.execCommand("insertunorderedlist"); } ], insertorderedlist: [ "Ordered List", ["ed_buttons_main.png",0,3], false, function(e) { e.execCommand("insertorderedlist"); } ], insertunorderedlist: [ "Bulleted List", ["ed_buttons_main.png",1,3], false, function(e) { e.execCommand("insertunorderedlist"); } ], outdent: [ "Decrease Indent", ["ed_buttons_main.png",1,2], false, function(e) { e.execCommand("outdent"); } ], indent: [ "Increase Indent",["ed_buttons_main.png",0,2], false, function(e) { e.execCommand("indent"); } ], forecolor: [ "Font Color", ["ed_buttons_main.png",3,3], false, function(e) { e.execCommand("forecolor"); } ], hilitecolor: [ "Background Color", ["ed_buttons_main.png",2,3], false, function(e) { e.execCommand("hilitecolor"); } ], undo: [ "Undoes your last action", ["ed_buttons_main.png",4,2], false, function(e) { e.execCommand("undo"); } ], redo: [ "Redoes your last action", ["ed_buttons_main.png",5,2], false, function(e) { e.execCommand("redo"); } ], cut: [ "Cut selection", ["ed_buttons_main.png",5,0], false, function (e, cmd) { e.execCommand(cmd); } ], copy: [ "Copy selection", ["ed_buttons_main.png",4,0], false, function (e, cmd) { e.execCommand(cmd); } ], paste: [ "Paste from clipboard", ["ed_buttons_main.png",4,1], false, function (e, cmd) { e.execCommand(cmd); } ], selectall: [ "Select all", ["ed_buttons_main.png",3,5], false, function(e) {e.execCommand("selectall");} ], inserthorizontalrule: [ "Horizontal Rule", ["ed_buttons_main.png",6,0], false, function(e) { e.execCommand("inserthorizontalrule"); } ], createlink: [ "Insert Web Link", ["ed_buttons_main.png",6,1], false, function(e) { e._createLink(); } ], insertimage: [ "Insert/Modify Image", ["ed_buttons_main.png",6,3], false, function(e) { e.execCommand("insertimage"); } ], inserttable: [ "Insert Table", ["ed_buttons_main.png",6,2], false, function(e) { e.execCommand("inserttable"); } ], htmlmode: [ "Toggle HTML Source", ["ed_buttons_main.png",7,0], true, function(e) { e.execCommand("htmlmode"); } ], toggleborders: [ "Toggle Borders", ["ed_buttons_main.png",7,2], false, function(e) { e._toggleBorders(); } ], print: [ "Print document", ["ed_buttons_main.png",8,1], false, function(e) { if(Xinha.is_gecko) {e._iframe.contentWindow.print(); } else { e.focusEditor(); print(); } } ], saveas: [ "Save as", ["ed_buttons_main.png",9,1], false, function(e) { e.execCommand("saveas",false,"noname.htm"); } ], about: [ "About this editor", ["ed_buttons_main.png",8,2], true, function(e) { e.getPluginInstance("AboutBox").show(); } ], showhelp: [ "Help using editor", ["ed_buttons_main.png",9,2], true, function(e) { e.execCommand("showhelp"); } ], splitblock: [ "Split Block", "ed_splitblock.gif", false, function(e) { e._splitBlock(); } ], lefttoright: [ "Direction left to right", ["ed_buttons_main.png",0,2], false, function(e) { e.execCommand("lefttoright"); } ], righttoleft: [ "Direction right to left", ["ed_buttons_main.png",1,2], false, function(e) { e.execCommand("righttoleft"); } ], overwrite: [ "Insert/Overwrite", "ed_overwrite.gif", false, function(e) { e.execCommand("overwrite"); } ], wordclean: [ "MS Word Cleaner", ["ed_buttons_main.png",5,3], false, function(e) { e._wordClean(); } ], clearfonts: [ "Clear Inline Font Specifications", ["ed_buttons_main.png",5,4], true, function(e) { e._clearFonts(); } ], removeformat: [ "Remove formatting", ["ed_buttons_main.png",4,4], false, function(e) { e.execCommand("removeformat"); } ], killword: [ "Clear MSOffice tags", ["ed_buttons_main.png",4,3], false, function(e) { e.execCommand("killword"); } ] }; /** A hash of double click handlers for the given elements, each element may have one or more double click handlers * called in sequence. The element may contain a class selector ( a.somethingSpecial ) * */ this.dblclickList = { "a": [function(e, target) {e._createLink(target);}], "img": [function(e, target) {e._insertImage(target);}] }; /** A container for additional icons that may be swapped within one button (like fullscreen) * @private */ this.iconList = { dialogCaption : _editor_url + 'images/xinha-small-icon.gif', wysiwygmode : [_editor_url + 'images/ed_buttons_main.png',7,1] }; // initialize tooltips from the I18N module and generate correct image path for ( var i in this.btnList ) { var btn = this.btnList[i]; // prevent iterating over wrong type if ( typeof btn != 'object' ) { continue; } if ( typeof btn[1] != 'string' ) { btn[1][0] = _editor_url + this.imgURL + btn[1][0]; } else { btn[1] = _editor_url + this.imgURL + btn[1]; } btn[0] = Xinha._lc(btn[0]); //initialize tooltip } }; /** A plugin may require more than one icon for one button, this has to be registered in order to work with the iconsets (see FullScreen) * * @param {String} id * @param {String|Array} icon definition like in registerButton */ Xinha.Config.prototype.registerIcon = function (id, icon) { this.iconList[id] = icon; }; /** ADDING CUSTOM BUTTONS * --------------------- * * * Example on how to add a custom button when you construct the Xinha: * * var editor = new Xinha("your_text_area_id"); * var cfg = editor.config; // this is the default configuration * cfg.btnList["my-hilite"] = * [ "Highlight selection", // tooltip * "my_hilite.gif", // image * false // disabled in text mode * function(editor) { editor.surroundHTML('<span style="background:yellow">', '</span>'); }, // action * ]; * cfg.toolbar.push(["linebreak", "my-hilite"]); // add the new button to the toolbar * * An alternate (also more convenient and recommended) way to * accomplish this is to use the registerButton function below. */ /** Helper function: register a new button with the configuration. It can be * called with all 5 arguments, or with only one (first one). When called with * only one argument it must be an object with the following properties: id, * tooltip, image, textMode, action.<br /> * * Examples:<br /> *<pre> * config.registerButton("my-hilite", "Hilite text", "my-hilite.gif", false, function(editor) {...}); * config.registerButton({ * id : "my-hilite", // the ID of your button * tooltip : "Hilite text", // the tooltip * image : "my-hilite.gif", // image to be displayed in the toolbar * textMode : false, // disabled in text mode * action : function(editor) { // called when the button is clicked * editor.surroundHTML('<span class="hilite">', '</span>'); * }, * context : "p" // will be disabled if outside a <p> element * });</pre> */ Xinha.Config.prototype.registerButton = function(id, tooltip, image, textMode, action, context) { if ( typeof id == "string" ) { this.btnList[id] = [ tooltip, image, textMode, action, context ]; } else if ( typeof id == "object" ) { this.btnList[id.id] = [ id.tooltip, id.image, id.textMode, id.action, id.context ]; } else { alert("ERROR [Xinha.Config::registerButton]:\ninvalid arguments"); return false; } }; Xinha.prototype.registerPanel = function(side, object) { if ( !side ) { side = 'right'; } this.setLoadingMessage('Register ' + side + ' panel '); var panel = this.addPanel(side); if ( object ) { object.drawPanelIn(panel); } }; /** The following helper function registers a dropdown box with the editor * configuration. You still have to add it to the toolbar, same as with the * buttons. Call it like this: * * FIXME: add example */ Xinha.Config.prototype.registerDropdown = function(object) { // check for existing id // if ( typeof this.customSelects[object.id] != "undefined" ) // { // alert("WARNING [Xinha.Config::registerDropdown]:\nA dropdown with the same ID already exists."); // } // if ( typeof this.btnList[object.id] != "undefined" ) // { // alert("WARNING [Xinha.Config::registerDropdown]:\nA button with the same ID already exists."); // } this.customSelects[object.id] = object; }; /** Call this function to remove some buttons/drop-down boxes from the toolbar. * Pass as the only parameter a string containing button/drop-down names * delimited by spaces. Note that the string should also begin with a space * and end with a space. Example: * * config.hideSomeButtons(" fontname fontsize textindicator "); * * It's useful because it's easier to remove stuff from the defaul toolbar than * create a brand new toolbar ;-) */ Xinha.Config.prototype.hideSomeButtons = function(remove) { var toolbar = this.toolbar; for ( var i = toolbar.length; --i >= 0; ) { var line = toolbar[i]; for ( var j = line.length; --j >= 0; ) { if ( remove.indexOf(" " + line[j] + " ") >= 0 ) { var len = 1; if ( /separator|space/.test(line[j + 1]) ) { len = 2; } line.splice(j, len); } } } }; /** Helper Function: add buttons/drop-downs boxes with title or separator to the toolbar * if the buttons/drop-downs boxes doesn't allready exists. * id: button or selectbox (as array with separator or title) * where: button or selectbox (as array if the first is not found take the second and so on) * position: * -1 = insert button (id) one position before the button (where) * 0 = replace button (where) by button (id) * +1 = insert button (id) one position after button (where) * * cfg.addToolbarElement(["T[title]", "button_id", "separator"] , ["first_id","second_id"], -1); */ Xinha.Config.prototype.addToolbarElement = function(id, where, position) { var toolbar = this.toolbar; var a, i, j, o, sid; var idIsArray = false; var whereIsArray = false; var whereLength = 0; var whereJ = 0; var whereI = 0; var exists = false; var found = false; // check if id and where are arrys if ( ( id && typeof id == "object" ) && ( id.constructor == Array ) ) { idIsArray = true; } if ( ( where && typeof where == "object" ) && ( where.constructor == Array ) ) { whereIsArray = true; whereLength = where.length; } if ( idIsArray ) //find the button/select box in input array { for ( i = 0; i < id.length; ++i ) { if ( ( id[i] != "separator" ) && ( id[i].indexOf("T[") !== 0) ) { sid = id[i]; } } } else { sid = id; } for ( i = 0; i < toolbar.length; ++i ) { a = toolbar[i]; for ( j = 0; j < a.length; ++j ) { // check if button/select box exists if ( a[j] == sid ) { return; // cancel to add elements if same button already exists } } } for ( i = 0; !found && i < toolbar.length; ++i ) { a = toolbar[i]; for ( j = 0; !found && j < a.length; ++j ) { if ( whereIsArray ) { for ( o = 0; o < whereLength; ++o ) { if ( a[j] == where[o] ) { if ( o === 0 ) { found = true; j--; break; } else { whereI = i; whereJ = j; whereLength = o; } } } } else { // find the position to insert if ( a[j] == where ) { found = true; break; } } } } //if check found any other as the first button if ( !found && whereIsArray ) { if ( where.length != whereLength ) { j = whereJ; a = toolbar[whereI]; found = true; } } if ( found ) { // replace the found button if ( position === 0 ) { if ( idIsArray) { a[j] = id[id.length-1]; for ( i = id.length-1; --i >= 0; ) { a.splice(j, 0, id[i]); } } else { a[j] = id; } } else { // insert before/after the found button if ( position < 0 ) { j = j + position + 1; //correct position before } else if ( position > 0 ) { j = j + position; //correct posion after } if ( idIsArray ) { for ( i = id.length; --i >= 0; ) { a.splice(j, 0, id[i]); } } else { a.splice(j, 0, id); } } } else { // no button found toolbar[0].splice(0, 0, "separator"); if ( idIsArray) { for ( i = id.length; --i >= 0; ) { toolbar[0].splice(0, 0, id[i]); } } else { toolbar[0].splice(0, 0, id); } } }; /** Alias of Xinha.Config.prototype.hideSomeButtons() * @type Function */ Xinha.Config.prototype.removeToolbarElement = Xinha.Config.prototype.hideSomeButtons; /** Helper function: replace all TEXTAREA-s in the document with Xinha-s. * @param {Xinha.Config} optional config */ Xinha.replaceAll = function(config) { var tas = document.getElementsByTagName("textarea"); // @todo: weird syntax, doesnt help to read the code, doesnt obfuscate it and doesnt make it quicker, better rewrite this part for ( var i = tas.length; i > 0; new Xinha(tas[--i], config).generate() ) { // NOP } }; /** Helper function: replaces the TEXTAREA with the given ID with Xinha. * @param {string} id id of the textarea to replace * @param {Xinha.Config} optional config */ Xinha.replace = function(id, config) { var ta = Xinha.getElementById("textarea", id); return ta ? new Xinha(ta, config).generate() : null; }; /** Creates the toolbar and appends it to the _htmlarea * @private * @returns {DomNode} toolbar */ Xinha.prototype._createToolbar = function () { this.setLoadingMessage(Xinha._lc('Create Toolbar')); var editor = this; // to access this in nested functions var toolbar = document.createElement("div"); // ._toolbar is for legacy, ._toolBar is better thanks. this._toolBar = this._toolbar = toolbar; toolbar.className = "toolbar"; toolbar.align = this.config.toolbarAlign; Xinha.freeLater(this, '_toolBar'); Xinha.freeLater(this, '_toolbar'); var tb_row = null; var tb_objects = {}; this._toolbarObjects = tb_objects; this._createToolbar1(editor, toolbar, tb_objects); // IE8 is totally retarded, if you click on a toolbar element (eg button) // and it doesn't have unselectable="on", then it defocuses the editor losing the selection // so nothing works. Particularly prevalent with TableOperations function noselect(e) { if(e.tagName) e.unselectable = "on"; if(e.childNodes) { for(var i = 0; i < e.childNodes.length; i++) if(e.tagName) noselect(e.childNodes(i)); } } if(Xinha.is_ie) noselect(toolbar); this._htmlArea.appendChild(toolbar); return toolbar; }; /** FIXME : function never used, can probably be removed from source * @private * @deprecated */ Xinha.prototype._setConfig = function(config) { this.config = config; }; /** FIXME: How can this be used?? * @private */ Xinha.prototype._rebuildToolbar = function() { this._createToolbar1(this, this._toolbar, this._toolbarObjects); // We only want ONE editor at a time to be active if ( Xinha._currentlyActiveEditor ) { if ( Xinha._currentlyActiveEditor == this ) { this.activateEditor(); } } else { this.disableToolbar(); } }; /** * Create a break element to add in the toolbar * * @return {DomNode} HTML element to add * @private */ Xinha._createToolbarBreakingElement = function() { var brk = document.createElement('div'); brk.style.height = '1px'; brk.style.width = '1px'; brk.style.lineHeight = '1px'; brk.style.fontSize = '1px'; brk.style.clear = 'both'; return brk; }; /** separate from previous createToolBar to allow dynamic change of toolbar * @private * @return {DomNode} toolbar */ Xinha.prototype._createToolbar1 = function (editor, toolbar, tb_objects) { // We will clean out any existing toolbar elements. while (toolbar.lastChild) { toolbar.removeChild(toolbar.lastChild); } var tb_row; // This shouldn't be necessary, but IE seems to float outside of the container // when we float toolbar sections, so we have to clear:both here as well // as at the end (which we do have to do). if ( editor.config.flowToolbars ) { toolbar.appendChild(Xinha._createToolbarBreakingElement()); } // creates a new line in the toolbar function newLine() { if ( typeof tb_row != 'undefined' && tb_row.childNodes.length === 0) { return; } var table = document.createElement("table"); table.border = "0px"; table.cellSpacing = "0px"; table.cellPadding = "0px"; if ( editor.config.flowToolbars ) { if ( Xinha.is_ie ) { table.style.styleFloat = "left"; } else { table.style.cssFloat = "left"; } } toolbar.appendChild(table); // TBODY is required for IE, otherwise you don't see anything // in the TABLE. var tb_body = document.createElement("tbody"); table.appendChild(tb_body); tb_row = document.createElement("tr"); tb_body.appendChild(tb_row); table.className = 'toolbarRow'; // meh, kinda. } // END of function: newLine // init first line newLine(); // updates the state of a toolbar element. This function is member of // a toolbar element object (unnamed objects created by createButton or // createSelect functions below). function setButtonStatus(id, newval) { var oldval = this[id]; var el = this.element; if ( oldval != newval ) { switch (id) { case "enabled": if ( newval ) { Xinha._removeClass(el, "buttonDisabled"); el.disabled = false; } else { Xinha._addClass(el, "buttonDisabled"); el.disabled = true; } break; case "active": if ( newval ) { Xinha._addClass(el, "buttonPressed"); } else { Xinha._removeClass(el, "buttonPressed"); } break; } this[id] = newval; } } // END of function: setButtonStatus // this function will handle creation of combo boxes. Receives as // parameter the name of a button as defined in the toolBar config. // This function is called from createButton, above, if the given "txt" // doesn't match a button. function createSelect(txt) { var options = null; var el = null; var cmd = null; var customSelects = editor.config.customSelects; var context = null; var tooltip = ""; switch (txt) { case "fontsize": case "fontname": case "formatblock": // the following line retrieves the correct // configuration option because the variable name // inside the Config object is named the same as the // button/select in the toolbar. For instance, if txt // == "formatblock" we retrieve config.formatblock (or // a different way to write it in JS is // config["formatblock"]. options = editor.config[txt]; cmd = txt; break; default: // try to fetch it from the list of registered selects cmd = txt; var dropdown = customSelects[cmd]; if ( typeof dropdown != "undefined" ) { options = dropdown.options; context = dropdown.context; if ( typeof dropdown.tooltip != "undefined" ) { tooltip = dropdown.tooltip; } } else { alert("ERROR [createSelect]:\nCan't find the requested dropdown definition"); } break; } if ( options ) { el = document.createElement("select"); el.title = tooltip; el.style.width = 'auto'; el.name = txt; var obj = { name : txt, // field name element : el, // the UI element (SELECT) enabled : true, // is it enabled? text : false, // enabled in text mode? cmd : cmd, // command ID state : setButtonStatus, // for changing state context : context }; Xinha.freeLater(obj); tb_objects[txt] = obj; for ( var i in options ) { // prevent iterating over wrong type if ( typeof options[i] != 'string' ) { continue; } var op = document.createElement("option"); op.innerHTML = Xinha._lc(i); op.value = options[i]; if (txt =='fontname' && editor.config.showFontStylesInToolbar) { op.style.fontFamily = options[i]; } el.appendChild(op); } Xinha._addEvent(el, "change", function () { editor._comboSelected(el, txt); } ); } return el; } // END of function: createSelect // appends a new button to toolbar function createButton(txt) { // the element that will be created var el, btn, obj = null; switch (txt) { case "separator": if ( editor.config.flowToolbars ) { newLine(); } el = document.createElement("div"); el.className = "separator"; break; case "space": el = document.createElement("div"); el.className = "space"; break; case "linebreak": newLine(); return false; case "textindicator": el = document.createElement("div"); el.appendChild(document.createTextNode("A")); el.className = "indicator"; el.title = Xinha._lc("Current style"); obj = { name : txt, // the button name (i.e. 'bold') element : el, // the UI element (DIV) enabled : true, // is it enabled? active : false, // is it pressed? text : false, // enabled in text mode? cmd : "textindicator", // the command ID state : setButtonStatus // for changing state }; Xinha.freeLater(obj); tb_objects[txt] = obj; break; default: btn = editor.config.btnList[txt]; } if ( !el && btn ) { el = document.createElement("a"); el.style.display = 'block'; el.href = 'javascript:void(0)'; el.style.textDecoration = 'none'; el.title = btn[0]; el.className = "button"; el.style.direction = "ltr"; // let's just pretend we have a button object, and // assign all the needed information to it. obj = { name : txt, // the button name (i.e. 'bold') element : el, // the UI element (DIV) enabled : true, // is it enabled? active : false, // is it pressed? text : btn[2], // enabled in text mode? cmd : btn[3], // the command ID state : setButtonStatus, // for changing state context : btn[4] || null // enabled in a certain context? }; Xinha.freeLater(el); Xinha.freeLater(obj); tb_objects[txt] = obj; // prevent drag&drop of the icon to content area el.ondrag = function() { return false; }; // handlers to emulate nice flat toolbar buttons Xinha._addEvent( el, "mouseout", function(ev) { if ( obj.enabled ) { //Xinha._removeClass(el, "buttonHover"); Xinha._removeClass(el, "buttonActive"); if ( obj.active ) { Xinha._addClass(el, "buttonPressed"); } } } ); Xinha._addEvent( el, "mousedown", function(ev) { if ( obj.enabled ) { Xinha._addClass(el, "buttonActive"); Xinha._removeClass(el, "buttonPressed"); Xinha._stopEvent(Xinha.is_ie ? window.event : ev); } } ); // when clicked, do the following: Xinha._addEvent( el, "click", function(ev) { ev = ev || window.event; editor.btnClickEvent = {clientX : ev.clientX, clientY : ev.clientY}; if ( obj.enabled ) { Xinha._removeClass(el, "buttonActive"); //Xinha._removeClass(el, "buttonHover"); if ( Xinha.is_gecko ) { editor.activateEditor(); } // We pass the event to the action so they can can use it to // enhance the UI (e.g. respond to shift or ctrl-click) obj.cmd(editor, obj.name, obj, ev); Xinha._stopEvent(ev); } } ); var i_contain = Xinha.makeBtnImg(btn[1]); var img = i_contain.firstChild; Xinha.freeLater(i_contain); Xinha.freeLater(img); el.appendChild(i_contain); obj.imgel = img; obj.swapImage = function(newimg) { if ( typeof newimg != 'string' ) { img.src = newimg[0]; img.style.position = 'relative'; img.style.top = newimg[2] ? ('-' + (18 * (newimg[2] + 1)) + 'px') : '-18px'; img.style.left = newimg[1] ? ('-' + (18 * (newimg[1] + 1)) + 'px') : '-18px'; } else { obj.imgel.src = newimg; img.style.top = '0px'; img.style.left = '0px'; } }; } else if( !el ) { el = createSelect(txt); } return el; } var first = true; for ( var i = 0; i < this.config.toolbar.length; ++i ) { if ( !first ) { // createButton("linebreak"); } else { first = false; } if ( this.config.toolbar[i] === null ) { this.config.toolbar[i] = ['separator']; } var group = this.config.toolbar[i]; for ( var j = 0; j < group.length; ++j ) { var code = group[j]; var tb_cell; if ( /^([IT])\[(.*?)\]/.test(code) ) { // special case, create text label var l7ed = RegExp.$1 == "I"; // localized? var label = RegExp.$2; if ( l7ed ) { label = Xinha._lc(label); } tb_cell = document.createElement("td"); tb_row.appendChild(tb_cell); tb_cell.className = "label"; tb_cell.innerHTML = label; } else if ( typeof code != 'function' ) { var tb_element = createButton(code); if ( tb_element ) { tb_cell = document.createElement("td"); tb_cell.className = 'toolbarElement'; tb_row.appendChild(tb_cell); tb_cell.appendChild(tb_element); } else if ( tb_element === null ) { alert("FIXME: Unknown toolbar item: " + code); } } } } if ( editor.config.flowToolbars ) { toolbar.appendChild(Xinha._createToolbarBreakingElement()); } return toolbar; }; /** creates a button (i.e. container element + image) * @private * @return {DomNode} conteainer element */ Xinha.makeBtnImg = function(imgDef, doc) { if ( !doc ) { doc = document; } if ( !doc._xinhaImgCache ) { doc._xinhaImgCache = {}; Xinha.freeLater(doc._xinhaImgCache); } var i_contain = null; if ( Xinha.is_ie && ( ( !doc.compatMode ) || ( doc.compatMode && doc.compatMode == "BackCompat" ) ) ) { i_contain = doc.createElement('span'); } else { i_contain = doc.createElement('div'); i_contain.style.position = 'relative'; } i_contain.style.overflow = 'hidden'; i_contain.style.width = "18px"; i_contain.style.height = "18px"; i_contain.className = 'buttonImageContainer'; var img = null; if ( typeof imgDef == 'string' ) { if ( doc._xinhaImgCache[imgDef] ) { img = doc._xinhaImgCache[imgDef].cloneNode(); } else { if (Xinha.ie_version < 7 && /\.png$/.test(imgDef[0])) { img = doc.createElement("span"); img.style.display = 'block'; img.style.width = '18px'; img.style.height = '18px'; img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef+'")'; img.unselectable = 'on'; } else { img = doc.createElement("img"); img.src = imgDef; } } } else { if ( doc._xinhaImgCache[imgDef[0]] ) { img = doc._xinhaImgCache[imgDef[0]].cloneNode(); } else { if (Xinha.ie_version < 7 && /\.png$/.test(imgDef[0])) { img = doc.createElement("span"); img.style.display = 'block'; img.style.width = '18px'; img.style.height = '18px'; img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef[0]+'")'; img.unselectable = 'on'; } else { img = doc.createElement("img"); img.src = imgDef[0]; } img.style.position = 'relative'; } // @todo: Using 18 dont let us use a theme with its own icon toolbar height // and width. Probably better to calculate this value 18 // var sizeIcon = img.width / nb_elements_per_image; img.style.top = imgDef[2] ? ('-' + (18 * (imgDef[2] + 1)) + 'px') : '-18px'; img.style.left = imgDef[1] ? ('-' + (18 * (imgDef[1] + 1)) + 'px') : '-18px'; } i_contain.appendChild(img); return i_contain; }; /** creates the status bar * @private * @return {DomNode} status bar */ Xinha.prototype._createStatusBar = function() { // TODO: Move styling into separate stylesheet this.setLoadingMessage(Xinha._lc('Create Statusbar')); var statusBar = document.createElement("div"); statusBar.style.position = "relative"; statusBar.className = "statusBar"; statusBar.style.width = "100%"; Xinha.freeLater(this, '_statusBar'); var widgetContainer = document.createElement("div"); widgetContainer.className = "statusBarWidgetContainer"; widgetContainer.style.position = "absolute"; widgetContainer.style.right = "0"; widgetContainer.style.top = "0"; widgetContainer.style.padding = "3px 3px 3px 10px"; statusBar.appendChild(widgetContainer); // statusbar.appendChild(document.createTextNode(Xinha._lc("Path") + ": ")); // creates a holder for the path view var statusBarTree = document.createElement("span"); statusBarTree.className = "statusBarTree"; statusBarTree.innerHTML = Xinha._lc("Path") + ": "; this._statusBarTree = statusBarTree; Xinha.freeLater(this, '_statusBarTree'); statusBar.appendChild(statusBarTree); var statusBarTextMode = document.createElement("span"); statusBarTextMode.innerHTML = Xinha.htmlEncode(Xinha._lc("You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.")); statusBarTextMode.style.display = "none"; this._statusBarTextMode = statusBarTextMode; Xinha.freeLater(this, '_statusBarTextMode'); statusBar.appendChild(statusBarTextMode); statusBar.style.whiteSpace = "nowrap"; var self = this; this.notifyOn("before_resize", function(evt, size) { self._statusBar.style.width = null; }); this.notifyOn("resize", function(evt, size) { // HACK! IE6 doesn't update the width properly when resizing if it's // given in pixels, but does hide the overflow content correctly when // using 100% as the width. (FF, Safari and IE7 all require fixed // pixel widths to do the overflow hiding correctly.) if (Xinha.is_ie && Xinha.ie_version == 6) { self._statusBar.style.width = "100%"; } else { var width = size['width']; self._statusBar.style.width = width + "px"; } }); this.notifyOn("modechange", function(evt, mode) { // Loop through all registered status bar items // and show them only if they're turned on for // the new mode. for (var i in self._statusWidgets) { var widget = self._statusWidgets[i]; for (var index=0; index<widget.modes.length; index++) { if (widget.modes[index] == mode.mode) { var found = true; } } if (typeof found == 'undefined') { widget.block.style.display = "none"; } else { widget.block.style.display = ""; } } }); if ( !this.config.statusBar ) { // disable it... statusBar.style.display = "none"; } return statusBar; }; /** Registers and inserts a new block for a widget in the status bar @param id unique string identifer for this block @param modes list of modes this block should be shown in @returns reference to HTML element inserted into the status bar */ Xinha.prototype.registerStatusWidget = function(id, modes) { modes = modes || ['wysiwyg']; if (!this._statusWidgets) { this._statusWidgets = {}; } var block = document.createElement("div"); block.className = "statusBarWidget"; block = this._statusBar.firstChild.appendChild(block); var showWidget = false; for (var i=0; i<modes.length; i++) { if (modes[i] == this._editMode) { showWidget = true; } } block.style.display = showWidget == true ? "" : "none"; this._statusWidgets[id] = {block: block, modes: modes}; return block; }; /** Creates the Xinha object and replaces the textarea with it. Loads required files. * @returns {Boolean} */ Xinha.prototype.generate = function () { if ( !Xinha.isSupportedBrowser ) { return; } var i; var editor = this; // we'll need "this" in some nested functions var url; var found = false; var links = document.getElementsByTagName("link"); if (!document.getElementById("XinhaCoreDesign")) { _editor_css = (typeof _editor_css == "string") ? _editor_css : "Xinha.css"; for(i = 0; i<links.length; i++) { if ( ( links[i].rel == "stylesheet" ) && ( links[i].href == _editor_url + _editor_css ) ) { found = true; } } if ( !found ) { Xinha.loadStyle(_editor_css,null,"XinhaCoreDesign",true); } } if ( _editor_skin !== "" && !document.getElementById("XinhaSkin")) { found = false; for(i = 0; i<links.length; i++) { if ( ( links[i].rel == "stylesheet" ) && ( links[i].href == _editor_url + 'skins/' + _editor_skin + '/skin.css' ) ) { found = true; } } if ( !found ) { Xinha.loadStyle('skins/' + _editor_skin + '/skin.css',null,"XinhaSkin"); } } var callback = function() { editor.generate(); }; // Now load a specific browser plugin which will implement the above for us. if (Xinha.is_ie) { url = _editor_url + 'modules/InternetExplorer/InternetExplorer.js'; if ( !Xinha.loadPlugins([{plugin:"InternetExplorer",url:url}], callback ) ) { return false; } if (!this.plugins.InternetExplorer) { editor._browserSpecificPlugin = editor.registerPlugin('InternetExplorer'); } } else if (Xinha.is_webkit) { url = _editor_url + 'modules/WebKit/WebKit.js'; if ( !Xinha.loadPlugins([{plugin:"WebKit",url:url}], callback ) ) { return false; } if (!this.plugins.Webkit) { editor._browserSpecificPlugin = editor.registerPlugin('WebKit'); } } else if (Xinha.is_opera) { url = _editor_url + 'modules/Opera/Opera.js'; if ( !Xinha.loadPlugins([{plugin:"Opera",url:url}], callback ) ) { return false; } if (!this.plugins.Opera) { editor._browserSpecificPlugin = editor.registerPlugin('Opera'); } } else if (Xinha.is_gecko) { url = _editor_url + 'modules/Gecko/Gecko.js'; if ( !Xinha.loadPlugins([{plugin:"Gecko",url:url}], callback ) ) { return false; } if (!this.plugins.Gecko) { editor._browserSpecificPlugin = editor.registerPlugin('Gecko'); } } if ( typeof Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/dialog.js', callback, this ) ) { return false; } if ( typeof Xinha.Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/XinhaDialog.js' , callback, this ) ) { return false; } url = _editor_url + 'modules/FullScreen/full-screen.js'; if ( !Xinha.loadPlugins([{plugin:"FullScreen",url:url}], callback )) { return false; } url = _editor_url + 'modules/ColorPicker/ColorPicker.js'; if ( !Xinha.loadPlugins([{plugin:"ColorPicker",url:url}], callback ) ) { return false; } else if ( typeof Xinha.getPluginConstructor('ColorPicker') != 'undefined' && !this.plugins.colorPicker) { editor.registerPlugin('ColorPicker'); } var toolbar = editor.config.toolbar; for ( i = toolbar.length; --i >= 0; ) { for ( var j = toolbar[i].length; --j >= 0; ) { switch (toolbar[i][j]) { case "popupeditor": if (!this.plugins.FullScreen) { editor.registerPlugin('FullScreen'); } break; case "insertimage": url = _editor_url + 'modules/InsertImage/insert_image.js'; if ( typeof Xinha.prototype._insertImage == 'undefined' && !Xinha.loadPlugins([{plugin:"InsertImage",url:url}], callback ) ) { return false; } else if ( typeof Xinha.getPluginConstructor('InsertImage') != 'undefined' && !this.plugins.InsertImage) { editor.registerPlugin('InsertImage'); } break; case "createlink": url = _editor_url + 'modules/CreateLink/link.js'; if ( typeof Xinha.getPluginConstructor('Linker') == 'undefined' && !Xinha.loadPlugins([{plugin:"CreateLink",url:url}], callback )) { return false; } else if ( typeof Xinha.getPluginConstructor('CreateLink') != 'undefined' && !this.plugins.CreateLink) { editor.registerPlugin('CreateLink'); } break; case "inserttable": url = _editor_url + 'modules/InsertTable/insert_table.js'; if ( !Xinha.loadPlugins([{plugin:"InsertTable",url:url}], callback ) ) { return false; } else if ( typeof Xinha.getPluginConstructor('InsertTable') != 'undefined' && !this.plugins.InsertTable) { editor.registerPlugin('InsertTable'); } break; case "about": url = _editor_url + 'modules/AboutBox/AboutBox.js'; if ( !Xinha.loadPlugins([{plugin:"AboutBox",url:url}], callback ) ) { return false; } else if ( typeof Xinha.getPluginConstructor('AboutBox') != 'undefined' && !this.plugins.AboutBox) { editor.registerPlugin('AboutBox'); } break; } } } // If this is gecko, set up the paragraph handling now if ( Xinha.is_gecko && editor.config.mozParaHandler != 'built-in' ) { if ( !Xinha.loadPlugins([{plugin:"EnterParagraphs",url: _editor_url + 'modules/Gecko/paraHandlerBest.js'}], callback ) ) { return false; } if (!this.plugins.EnterParagraphs) { editor.registerPlugin('EnterParagraphs'); } } var getHtmlMethodPlugin = this.config.getHtmlMethod == 'TransformInnerHTML' ? _editor_url + 'modules/GetHtml/TransformInnerHTML.js' : _editor_url + 'modules/GetHtml/DOMwalk.js'; if ( !Xinha.loadPlugins([{plugin:"GetHtmlImplementation",url:getHtmlMethodPlugin}], callback)) { return false; } else if (!this.plugins.GetHtmlImplementation) { editor.registerPlugin('GetHtmlImplementation'); } function getTextContent(node) { return node.textContent || node.text; } if (_editor_skin) { this.skinInfo = {}; var skinXML = Xinha._geturlcontent(_editor_url + 'skins/' + _editor_skin + '/skin.xml', true); if (skinXML) { var meta = skinXML.getElementsByTagName('meta'); for (i=0;i<meta.length;i++) { this.skinInfo[meta[i].getAttribute('name')] = meta[i].getAttribute('value'); } var recommendedIcons = skinXML.getElementsByTagName('recommendedIcons'); if (!_editor_icons && recommendedIcons.length && getTextContent(recommendedIcons[0])) { _editor_icons = getTextContent(recommendedIcons[0]); } } } if (_editor_icons) { var iconsXML = Xinha._geturlcontent(_editor_url + 'iconsets/' + _editor_icons + '/iconset.xml', true); if (iconsXML) { var icons = iconsXML.getElementsByTagName('icon'); var icon, id, path, type, x, y; for (i=0;i<icons.length;i++) { icon = icons[i]; id = icon.getAttribute('id'); if (icon.getElementsByTagName(_editor_lang).length) { icon = icon.getElementsByTagName(_editor_lang)[0]; } else { icon = icon.getElementsByTagName('default')[0]; } path = getTextContent(icon.getElementsByTagName('path')[0]); path = (!/^\//.test(path) ? _editor_url : '') + path; type = icon.getAttribute('type'); if (type == 'map') { x = parseInt(getTextContent(icon.getElementsByTagName('x')[0]), 10); y = parseInt(getTextContent(icon.getElementsByTagName('y')[0]), 10); if (this.config.btnList[id]) { this.config.btnList[id][1] = [path, x, y]; } if (this.config.iconList[id]) { this.config.iconList[id] = [path, x, y]; } } else { if (this.config.btnList[id]) { this.config.btnList[id][1] = path; } if (this.config.iconList[id]) { this.config.iconList[id] = path; } } } } } // create the editor framework, yah, table layout I know, but much easier // to get it working correctly this way, sorry about that, patches welcome. this.setLoadingMessage(Xinha._lc('Generate Xinha framework')); this._framework = { 'table': document.createElement('table'), 'tbody': document.createElement('tbody'), // IE will not show the table if it doesn't have a tbody! 'tb_row': document.createElement('tr'), 'tb_cell': document.createElement('td'), // Toolbar 'tp_row': document.createElement('tr'), 'tp_cell': this._panels.top.container, // top panel 'ler_row': document.createElement('tr'), 'lp_cell': this._panels.left.container, // left panel 'ed_cell': document.createElement('td'), // editor 'rp_cell': this._panels.right.container, // right panel 'bp_row': document.createElement('tr'), 'bp_cell': this._panels.bottom.container,// bottom panel 'sb_row': document.createElement('tr'), 'sb_cell': document.createElement('td') // status bar }; Xinha.freeLater(this._framework); var fw = this._framework; fw.table.border = "0"; fw.table.cellPadding = "0"; fw.table.cellSpacing = "0"; fw.tb_row.style.verticalAlign = 'top'; fw.tp_row.style.verticalAlign = 'top'; fw.ler_row.style.verticalAlign= 'top'; fw.bp_row.style.verticalAlign = 'top'; fw.sb_row.style.verticalAlign = 'top'; fw.ed_cell.style.position = 'relative'; // Put the cells in the rows set col & rowspans // note that I've set all these so that all panels are showing // but they will be redone in sizeEditor() depending on which // panels are shown. It's just here to clarify how the thing // is put togethor. fw.tb_row.appendChild(fw.tb_cell); fw.tb_cell.colSpan = 3; fw.tp_row.appendChild(fw.tp_cell); fw.tp_cell.colSpan = 3; fw.ler_row.appendChild(fw.lp_cell); fw.ler_row.appendChild(fw.ed_cell); fw.ler_row.appendChild(fw.rp_cell); fw.bp_row.appendChild(fw.bp_cell); fw.bp_cell.colSpan = 3; fw.sb_row.appendChild(fw.sb_cell); fw.sb_cell.colSpan = 3; // Put the rows in the table body fw.tbody.appendChild(fw.tb_row); // Toolbar fw.tbody.appendChild(fw.tp_row); // Left, Top, Right panels fw.tbody.appendChild(fw.ler_row); // Editor/Textarea fw.tbody.appendChild(fw.bp_row); // Bottom panel fw.tbody.appendChild(fw.sb_row); // Statusbar // and body in the table fw.table.appendChild(fw.tbody); var xinha = fw.table; this._htmlArea = xinha; Xinha.freeLater(this, '_htmlArea'); xinha.className = "htmlarea"; // create the toolbar and put in the area fw.tb_cell.appendChild( this._createToolbar() ); // create the IFRAME & add to container var iframe = document.createElement("iframe"); iframe.src = this.popupURL(editor.config.URIs.blank); iframe.id = "XinhaIFrame_" + this._textArea.id; fw.ed_cell.appendChild(iframe); this._iframe = iframe; this._iframe.className = 'xinha_iframe'; Xinha.freeLater(this, '_iframe'); // creates & appends the status bar var statusbar = this._createStatusBar(); this._statusBar = fw.sb_cell.appendChild(statusbar); // insert Xinha before the textarea. var textarea = this._textArea; textarea.parentNode.insertBefore(xinha, textarea); textarea.className = 'xinha_textarea'; // extract the textarea and insert it into the xinha framework Xinha.removeFromParent(textarea); fw.ed_cell.appendChild(textarea); // if another editor is activated while this one is in text mode, toolbar is disabled Xinha.addDom0Event( this._textArea, 'click', function() { if ( Xinha._currentlyActiveEditor != this) { editor.updateToolbar(); } return true; }); // Set up event listeners for saving the iframe content to the textarea if ( textarea.form ) { // onsubmit get the Xinha content and update original textarea. Xinha.prependDom0Event( this._textArea.form, 'submit', function() { editor.firePluginEvent('onBeforeSubmit'); editor._textArea.value = editor.outwardHtml(editor.getHTML()); return true; } ); var initialTAContent = textarea.value; // onreset revert the Xinha content to the textarea content Xinha.prependDom0Event( this._textArea.form, 'reset', function() { editor.setHTML(editor.inwardHtml(initialTAContent)); editor.updateToolbar(); return true; } ); // attach onsubmit handler to form.submit() // note: catch error in IE if any form element has id="submit" if ( !textarea.form.xinha_submit ) { try { textarea.form.xinha_submit = textarea.form.submit; textarea.form.submit = function() { this.onsubmit(); this.xinha_submit(); }; } catch(ex) {} } } // add a handler for the "back/forward" case -- on body.unload we save // the HTML content into the original textarea and restore it in its place. // apparently this does not work in IE? Xinha.prependDom0Event( window, 'unload', function() { editor.firePluginEvent('onBeforeUnload'); textarea.value = editor.outwardHtml(editor.getHTML()); if (!Xinha.is_ie) { xinha.parentNode.replaceChild(textarea,xinha); } return true; } ); // Hide textarea textarea.style.display = "none"; // Initalize size editor.initSize(); this.setLoadingMessage(Xinha._lc('Finishing')); // Add an event to initialize the iframe once loaded. editor._iframeLoadDone = false; if (Xinha.is_opera) { editor.initIframe(); } else { Xinha._addEvent( this._iframe, 'load', function(e) { if ( !editor._iframeLoadDone ) { editor._iframeLoadDone = true; editor.initIframe(); } return true; } ); } }; /** * Size the editor according to the INITIAL sizing information. * config.width * The width may be set via three ways * auto = the width is inherited from the original textarea * toolbar = the width is set to be the same size as the toolbar * <set size> = the width is an explicit size (any CSS measurement, eg 100em should be fine) * * config.height * auto = the height is inherited from the original textarea * <set size> = an explicit size measurement (again, CSS measurements) * * config.sizeIncludesBars * true = the tool & status bars will appear inside the width & height confines * false = the tool & status bars will appear outside the width & height confines * * @private */ Xinha.prototype.initSize = function() { this.setLoadingMessage(Xinha._lc('Init editor size')); var editor = this; var width = null; var height = null; switch ( this.config.width ) { case 'auto': width = this._initial_ta_size.w; break; case 'toolbar': width = this._toolBar.offsetWidth + 'px'; break; default : // @todo: check if this is better : // width = (parseInt(this.config.width, 10) == this.config.width)? this.config.width + 'px' : this.config.width; width = /[^0-9]/.test(this.config.width) ? this.config.width : this.config.width + 'px'; break; } // @todo: check if this is better : // height = (parseInt(this.config.height, 10) == this.config.height)? this.config.height + 'px' : this.config.height; height = this.config.height == 'auto' ? this._initial_ta_size.h : /[^0-9]/.test(this.config.height) ? this.config.height : this.config.height + 'px'; this.sizeEditor(width, height, this.config.sizeIncludesBars, this.config.sizeIncludesPanels); // why can't we use the following line instead ? // this.notifyOn('panel_change',this.sizeEditor); this.notifyOn('panel_change',function() { editor.sizeEditor(); }); }; /** * Size the editor to a specific size, or just refresh the size (when window resizes for example) * @param {string} width optional width (CSS specification) * @param {string} height optional height (CSS specification) * @param {Boolean} includingBars optional to indicate if the size should include or exclude tool & status bars * @param {Boolean} includingPanels optional to indicate if the size should include or exclude panels */ Xinha.prototype.sizeEditor = function(width, height, includingBars, includingPanels) { if (this._risizing) { return; } this._risizing = true; var framework = this._framework; this.notifyOf('before_resize', {width:width, height:height}); this.firePluginEvent('onBeforeResize', width, height); // We need to set the iframe & textarea to 100% height so that the htmlarea // isn't "pushed out" when we get it's height, so we can change them later. this._iframe.style.height = '100%'; //here 100% can lead to an effect that the editor is considerably higher in text mode this._textArea.style.height = '1px'; this._iframe.style.width = '0px'; this._textArea.style.width = '0px'; if ( includingBars !== null ) { this._htmlArea.sizeIncludesToolbars = includingBars; } if ( includingPanels !== null ) { this._htmlArea.sizeIncludesPanels = includingPanels; } if ( width ) { this._htmlArea.style.width = width; if ( !this._htmlArea.sizeIncludesPanels ) { // Need to add some for l & r panels var rPanel = this._panels.right; if ( rPanel.on && rPanel.panels.length && Xinha.hasDisplayedChildren(rPanel.div) ) { this._htmlArea.style.width = (this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.right, 10)) + 'px'; } var lPanel = this._panels.left; if ( lPanel.on && lPanel.panels.length && Xinha.hasDisplayedChildren(lPanel.div) ) { this._htmlArea.style.width = (this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.left, 10)) + 'px'; } } } if ( height ) { this._htmlArea.style.height = height; if ( !this._htmlArea.sizeIncludesToolbars ) { // Need to add some for toolbars this._htmlArea.style.height = (this._htmlArea.offsetHeight + this._toolbar.offsetHeight + this._statusBar.offsetHeight) + 'px'; } if ( !this._htmlArea.sizeIncludesPanels ) { // Need to add some for t & b panels var tPanel = this._panels.top; if ( tPanel.on && tPanel.panels.length && Xinha.hasDisplayedChildren(tPanel.div) ) { this._htmlArea.style.height = (this._htmlArea.offsetHeight + parseInt(this.config.panel_dimensions.top, 10)) + 'px'; } var bPanel = this._panels.bottom; if ( bPanel.on && bPanel.panels.length && Xinha.hasDisplayedChildren(bPanel.div) ) { this._htmlArea.style.height = (this._htmlArea.offsetHeight + parseInt(this.config.panel_dimensions.bottom, 10)) + 'px'; } } } // At this point we have this._htmlArea.style.width & this._htmlArea.style.height // which are the size for the OUTER editor area, including toolbars and panels // now we size the INNER area and position stuff in the right places. width = this._htmlArea.offsetWidth; height = this._htmlArea.offsetHeight; // Set colspan for toolbar, and statusbar, rowspan for left & right panels, and insert panels to be displayed // into thier rows var panels = this._panels; var editor = this; var col_span = 1; function panel_is_alive(pan) { if ( panels[pan].on && panels[pan].panels.length && Xinha.hasDisplayedChildren(panels[pan].container) ) { panels[pan].container.style.display = ''; return true; } // Otherwise make sure it's been removed from the framework else { panels[pan].container.style.display='none'; return false; } } if ( panel_is_alive('left') ) { col_span += 1; } // if ( panel_is_alive('top') ) // { // NOP // } if ( panel_is_alive('right') ) { col_span += 1; } // if ( panel_is_alive('bottom') ) // { // NOP // } framework.tb_cell.colSpan = col_span; framework.tp_cell.colSpan = col_span; framework.bp_cell.colSpan = col_span; framework.sb_cell.colSpan = col_span; // Put in the panel rows, top panel goes above editor row if ( !framework.tp_row.childNodes.length ) { Xinha.removeFromParent(framework.tp_row); } else { if ( !Xinha.hasParentNode(framework.tp_row) ) { framework.tbody.insertBefore(framework.tp_row, framework.ler_row); } } // bp goes after the editor if ( !framework.bp_row.childNodes.length ) { Xinha.removeFromParent(framework.bp_row); } else { if ( !Xinha.hasParentNode(framework.bp_row) ) { framework.tbody.insertBefore(framework.bp_row, framework.ler_row.nextSibling); } } // finally if the statusbar is on, insert it if ( !this.config.statusBar ) { Xinha.removeFromParent(framework.sb_row); } else { if ( !Xinha.hasParentNode(framework.sb_row) ) { framework.table.appendChild(framework.sb_row); } } // Size and set colspans, link up the framework framework.lp_cell.style.width = this.config.panel_dimensions.left; framework.rp_cell.style.width = this.config.panel_dimensions.right; framework.tp_cell.style.height = this.config.panel_dimensions.top; framework.bp_cell.style.height = this.config.panel_dimensions.bottom; framework.tb_cell.style.height = this._toolBar.offsetHeight + 'px'; framework.sb_cell.style.height = this._statusBar.offsetHeight + 'px'; var edcellheight = height - this._toolBar.offsetHeight - this._statusBar.offsetHeight; if ( panel_is_alive('top') ) { edcellheight -= parseInt(this.config.panel_dimensions.top, 10); } if ( panel_is_alive('bottom') ) { edcellheight -= parseInt(this.config.panel_dimensions.bottom, 10); } this._iframe.style.height = edcellheight + 'px'; var edcellwidth = width; if ( panel_is_alive('left') ) { edcellwidth -= parseInt(this.config.panel_dimensions.left, 10); } if ( panel_is_alive('right') ) { edcellwidth -= parseInt(this.config.panel_dimensions.right, 10); } var iframeWidth = this.config.iframeWidth ? parseInt(this.config.iframeWidth,10) : null; this._iframe.style.width = (iframeWidth && iframeWidth < edcellwidth) ? iframeWidth + "px": edcellwidth + "px"; this._textArea.style.height = this._iframe.style.height; this._textArea.style.width = this._iframe.style.width; this.notifyOf('resize', {width:this._htmlArea.offsetWidth, height:this._htmlArea.offsetHeight}); this.firePluginEvent('onResize',this._htmlArea.offsetWidth, this._htmlArea.offsetWidth); this._risizing = false; }; /** FIXME: Never used, what is this for? * @param {string} side * @param {Object} */ Xinha.prototype.registerPanel = function(side, object) { if ( !side ) { side = 'right'; } this.setLoadingMessage('Register ' + side + ' panel '); var panel = this.addPanel(side); if ( object ) { object.drawPanelIn(panel); } }; /** Creates a panel in the panel container on the specified side * @param {String} side the panel container to which the new panel will be added<br /> * Possible values are: "right","left","top","bottom" * @returns {DomNode} Panel div */ Xinha.prototype.addPanel = function(side) { var div = document.createElement('div'); div.side = side; if ( side == 'left' || side == 'right' ) { div.style.width = this.config.panel_dimensions[side]; if (this._iframe) { div.style.height = this._iframe.style.height; } } Xinha.addClasses(div, 'panel'); this._panels[side].panels.push(div); this._panels[side].div.appendChild(div); this.notifyOf('panel_change', {'action':'add','panel':div}); this.firePluginEvent('onPanelChange','add',div); return div; }; /** Removes a panel * @param {DomNode} panel object as returned by Xinha.prototype.addPanel() */ Xinha.prototype.removePanel = function(panel) { this._panels[panel.side].div.removeChild(panel); var clean = []; for ( var i = 0; i < this._panels[panel.side].panels.length; i++ ) { if ( this._panels[panel.side].panels[i] != panel ) { clean.push(this._panels[panel.side].panels[i]); } } this._panels[panel.side].panels = clean; this.notifyOf('panel_change', {'action':'remove','panel':panel}); this.firePluginEvent('onPanelChange','remove',panel); }; /** Hides a panel * @param {DomNode} panel object as returned by Xinha.prototype.addPanel() */ Xinha.prototype.hidePanel = function(panel) { if ( panel && panel.style.display != 'none' ) { try { var pos = this.scrollPos(this._iframe.contentWindow); } catch(e) { } panel.style.display = 'none'; this.notifyOf('panel_change', {'action':'hide','panel':panel}); this.firePluginEvent('onPanelChange','hide',panel); try { this._iframe.contentWindow.scrollTo(pos.x,pos.y); } catch(e) { } } }; /** Shows a panel * @param {DomNode} panel object as returned by Xinha.prototype.addPanel() */ Xinha.prototype.showPanel = function(panel) { if ( panel && panel.style.display == 'none' ) { try { var pos = this.scrollPos(this._iframe.contentWindow); } catch(e) {} panel.style.display = ''; this.notifyOf('panel_change', {'action':'show','panel':panel}); this.firePluginEvent('onPanelChange','show',panel); try { this._iframe.contentWindow.scrollTo(pos.x,pos.y); } catch(e) { } } }; /** Hides the panel(s) on one or more sides * @param {Array} sides the sides on which the panels shall be hidden */ Xinha.prototype.hidePanels = function(sides) { if ( typeof sides == 'undefined' ) { sides = ['left','right','top','bottom']; } var reShow = []; for ( var i = 0; i < sides.length;i++ ) { if ( this._panels[sides[i]].on ) { reShow.push(sides[i]); this._panels[sides[i]].on = false; } } this.notifyOf('panel_change', {'action':'multi_hide','sides':sides}); this.firePluginEvent('onPanelChange','multi_hide',sides); }; /** Shows the panel(s) on one or more sides * @param {Array} sides the sides on which the panels shall be hidden */ Xinha.prototype.showPanels = function(sides) { if ( typeof sides == 'undefined' ) { sides = ['left','right','top','bottom']; } var reHide = []; for ( var i = 0; i < sides.length; i++ ) { if ( !this._panels[sides[i]].on ) { reHide.push(sides[i]); this._panels[sides[i]].on = true; } } this.notifyOf('panel_change', {'action':'multi_show','sides':sides}); this.firePluginEvent('onPanelChange','multi_show',sides); }; /** Returns an array containig all properties that are set in an object * @param {Object} obj * @returns {Array} */ Xinha.objectProperties = function(obj) { var props = []; for ( var x in obj ) { props[props.length] = x; } return props; }; /** Checks if editor is active *<br /> * EDITOR ACTIVATION NOTES:<br /> * when a page has multiple Xinha editors, ONLY ONE should be activated at any time (this is mostly to * work around a bug in Mozilla, but also makes some sense). No editor should be activated or focused * automatically until at least one editor has been activated through user action (by mouse-clicking in * the editor). * @private * @returns {Boolean} */ Xinha.prototype.editorIsActivated = function() { try { return Xinha.is_designMode ? this._doc.designMode == 'on' : this._doc.body.contentEditable; } catch (ex) { return false; } }; /** We need to know that at least one editor on the page has been activated * this is because we will not focus any editor until an editor has been activated * @private * @type {Boolean} */ Xinha._someEditorHasBeenActivated = false; /** Stores a reference to the currently active editor * @private * @type {Xinha} */ Xinha._currentlyActiveEditor = null; /** Enables one editor for editing, e.g. by a click in the editing area or after it has been * deactivated programmatically before * @private * @returns {Boolean} */ Xinha.prototype.activateEditor = function() { if (this.currentModal) { return; } // We only want ONE editor at a time to be active if ( Xinha._currentlyActiveEditor ) { if ( Xinha._currentlyActiveEditor == this ) { return true; } Xinha._currentlyActiveEditor.deactivateEditor(); } if ( Xinha.is_designMode && this._doc.designMode != 'on' ) { try { // cannot set design mode if no display if ( this._iframe.style.display == 'none' ) { this._iframe.style.display = ''; this._doc.designMode = 'on'; this._iframe.style.display = 'none'; } else { this._doc.designMode = 'on'; } // Opera loses some of it's event listeners when the designMode is set to on. // the true just shortcuts the method to only set some listeners. if(Xinha.is_opera) this.setEditorEvents(true); } catch (ex) {} } else if ( Xinha.is_ie&& this._doc.body.contentEditable !== true ) { this._doc.body.contentEditable = true; } Xinha._someEditorHasBeenActivated = true; Xinha._currentlyActiveEditor = this; var editor = this; this.enableToolbar(); }; /** Disables the editor * @private */ Xinha.prototype.deactivateEditor = function() { // If the editor isn't active then the user shouldn't use the toolbar this.disableToolbar(); if ( Xinha.is_designMode && this._doc.designMode != 'off' ) { try { this._doc.designMode = 'off'; } catch (ex) {} } else if ( !Xinha.is_designMode && this._doc.body.contentEditable !== false ) { this._doc.body.contentEditable = false; } if ( Xinha._currentlyActiveEditor != this ) { // We just deactivated an editor that wasn't marked as the currentlyActiveEditor return; // I think this should really be an error, there shouldn't be a situation where // an editor is deactivated without first being activated. but it probably won't // hurt anything. } Xinha._currentlyActiveEditor = false; }; /** Creates the iframe (editable area) * @private */ Xinha.prototype.initIframe = function() { this.disableToolbar(); var doc = null; var editor = this; try { if ( editor._iframe.contentDocument ) { this._doc = editor._iframe.contentDocument; } else { this._doc = editor._iframe.contentWindow.document; } doc = this._doc; // try later if ( !doc ) { if ( Xinha.is_gecko ) { setTimeout(function() { editor.initIframe(); }, 50); return false; } else { alert("ERROR: IFRAME can't be initialized."); } } } catch(ex) { // try later setTimeout(function() { editor.initIframe(); }, 50); return false; } Xinha.freeLater(this, '_doc'); doc.open("text/html","replace"); var html = '', doctype; if ( editor.config.browserQuirksMode === false ) { doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; } else if ( editor.config.browserQuirksMode === true ) { doctype = ''; } else { doctype = Xinha.getDoctype(document); } if ( !editor.config.fullPage ) { html += doctype + "\n"; html += "<html>\n"; html += "<head>\n"; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + editor.config.charSet + "\">\n"; if ( typeof editor.config.baseHref != 'undefined' && editor.config.baseHref !== null ) { html += "<base href=\"" + editor.config.baseHref + "\"/>\n"; } html += Xinha.addCoreCSS(); if ( typeof editor.config.pageStyleSheets !== 'undefined' ) { for ( var i = 0; i < editor.config.pageStyleSheets.length; i++ ) { if ( editor.config.pageStyleSheets[i].length > 0 ) { html += "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + editor.config.pageStyleSheets[i] + "\">"; //html += "<style> @import url('" + editor.config.pageStyleSheets[i] + "'); </style>\n"; } } } if ( editor.config.pageStyle ) { html += "<style type=\"text/css\">\n" + editor.config.pageStyle + "\n</style>"; } html += "</head>\n"; html += "<body" + (editor.config.bodyID ? (" id=\"" + editor.config.bodyID + "\"") : '') + (editor.config.bodyClass ? (" class=\"" + editor.config.bodyClass + "\"") : '') + ">\n"; html += editor.inwardHtml(editor._textArea.value); html += "</body>\n"; html += "</html>"; } else { html = editor.inwardHtml(editor._textArea.value); if ( html.match(Xinha.RE_doctype) ) { editor.setDoctype(RegExp.$1); //html = html.replace(Xinha.RE_doctype, ""); } //Fix Firefox problem with link elements not in right place (just before head) var match = html.match(/<link\s+[\s\S]*?["']\s*\/?>/gi); html = html.replace(/<link\s+[\s\S]*?["']\s*\/?>\s*/gi, ''); if (match) { html = html.replace(/<\/head>/i, match.join('\n') + "\n</head>"); } } doc.write(html); doc.close(); if ( this.config.fullScreen ) { this._fullScreen(); } this.setEditorEvents(); // If this IFRAME had been configured for autofocus, we'll focus it now, // since everything needed to do so is now fully loaded. if ((typeof editor.config.autofocus != "undefined") && editor.config.autofocus !== false && ((editor.config.autofocus == editor._textArea.id) || editor.config.autofocus == true)) { editor.activateEditor(); editor.focusEditor(); } }; /** * Delay a function until the document is ready for operations. * See ticket:547 * @public * @param {Function} f The function to call once the document is ready */ Xinha.prototype.whenDocReady = function(f) { var e = this; if ( this._doc && this._doc.body ) { f(); } else { setTimeout(function() { e.whenDocReady(f); }, 50); } }; /** Switches editor mode between wysiwyg and text (HTML) * @param {String} mode optional "textmode" or "wysiwyg", if omitted, toggles between modes. */ Xinha.prototype.setMode = function(mode) { var html; if ( typeof mode == "undefined" ) { mode = this._editMode == "textmode" ? "wysiwyg" : "textmode"; } switch ( mode ) { case "textmode": this.firePluginEvent('onBeforeMode', 'textmode'); this._toolbarObjects.htmlmode.swapImage(this.config.iconList.wysiwygmode); this.setCC("iframe"); html = this.outwardHtml(this.getHTML()); this.setHTML(html); // Hide the iframe this.deactivateEditor(); this._iframe.style.display = 'none'; this._textArea.style.display = ''; if ( this.config.statusBar ) { this._statusBarTree.style.display = "none"; this._statusBarTextMode.style.display = ""; } this.findCC("textarea"); this.notifyOf('modechange', {'mode':'text'}); this.firePluginEvent('onMode', 'textmode'); break; case "wysiwyg": this.firePluginEvent('onBeforeMode', 'wysiwyg'); this._toolbarObjects.htmlmode.swapImage([this.imgURL('images/ed_buttons_main.png'),7,0]); this.setCC("textarea"); html = this.inwardHtml(this.getHTML()); this.deactivateEditor(); this.setHTML(html); this._iframe.style.display = ''; this._textArea.style.display = "none"; this.activateEditor(); if ( this.config.statusBar ) { this._statusBarTree.style.display = ""; this._statusBarTextMode.style.display = "none"; } this.findCC("iframe"); this.notifyOf('modechange', {'mode':'wysiwyg'}); this.firePluginEvent('onMode', 'wysiwyg'); break; default: alert("Mode <" + mode + "> not defined!"); return false; } this._editMode = mode; }; /** Sets the HTML in fullpage mode. Actually the whole iframe document is rewritten. * @private * @param {String} html */ Xinha.prototype.setFullHTML = function(html) { var save_multiline = RegExp.multiline; RegExp.multiline = true; if ( html.match(Xinha.RE_doctype) ) { this.setDoctype(RegExp.$1); // html = html.replace(Xinha.RE_doctype, ""); } RegExp.multiline = save_multiline; // disabled to save body attributes see #459 if ( 0 ) { if ( html.match(Xinha.RE_head) ) { this._doc.getElementsByTagName("head")[0].innerHTML = RegExp.$1; } if ( html.match(Xinha.RE_body) ) { this._doc.getElementsByTagName("body")[0].innerHTML = RegExp.$1; } } else { // FIXME - can we do this without rewriting the entire document // does the above not work for IE? var reac = this.editorIsActivated(); if ( reac ) { this.deactivateEditor(); } var html_re = /<html>((.|\n)*?)<\/html>/i; html = html.replace(html_re, "$1"); this._doc.open("text/html","replace"); this._doc.write(html); this._doc.close(); if ( reac ) { this.activateEditor(); } this.setEditorEvents(); return true; } }; /** Initialize some event handlers * @private */ Xinha.prototype.setEditorEvents = function(resetting_events_for_opera) { var editor=this; var doc = this._doc; editor.whenDocReady( function() { if(!resetting_events_for_opera) { // if we have multiple editors some bug in Mozilla makes some lose editing ability Xinha._addEvents( doc, ["mousedown"], function() { editor.activateEditor(); return true; } ); if (Xinha.is_ie) { // #1019 Cusor not jumping to editable part of window when clicked in IE, see also #1039 Xinha._addEvent( editor._doc.getElementsByTagName("html")[0], "click", function() { if (editor._iframe.contentWindow.event.srcElement.tagName.toLowerCase() == 'html') // if clicked below the text (=body), the text cursor does not appear, see #1019 { var r = editor._doc.body.createTextRange(); r.collapse(); r.select(); //setTimeout (function () { r.collapse(); r.select();},100); // won't do without timeout, dunno why } return true; } ); } } // intercept some events; for updating the toolbar & keyboard handlers Xinha._addEvents( doc, ["keydown", "keypress", "mousedown", "mouseup", "drag"], function (event) { return editor._editorEvent(Xinha.is_ie ? editor._iframe.contentWindow.event : event); } ); Xinha._addEvents( doc, ["dblclick"], function (event) { return editor._onDoubleClick(Xinha.is_ie ? editor._iframe.contentWindow.event : event); } ); if(resetting_events_for_opera) return; // FIXME - this needs to be cleaned up and use editor.firePluginEvent // I don't like both onGenerate and onGenerateOnce, we should only // have onGenerate and it should only be called when the editor is // generated (once and only once) // check if any plugins have registered refresh handlers for ( var i in editor.plugins ) { var plugin = editor.plugins[i].instance; Xinha.refreshPlugin(plugin); } // specific editor initialization if ( typeof editor._onGenerate == "function" ) { editor._onGenerate(); } //ticket #1407 IE8 fires two resize events on one actual resize, seemingly causing an infinite loop (but not when Xinha is in an frame/iframe) Xinha.addDom0Event(window, 'resize', function(e) { if (Xinha.ie_version > 7 && !window.parent) { if (editor.execResize) { editor.sizeEditor(); editor.execResize = false; } else { editor.execResize = true; } } else { editor.sizeEditor(); } }); editor.removeLoadingMessage(); } ); }; /*************************************************** * Category: PLUGINS ***************************************************/ /** Plugins may either reside in the golbal scope (not recommended) or in Xinha.plugins. * This function looks in both locations and is used to check the loading status and finally retrieve the plugin's constructor * @private * @type {Function|undefined} * @param {String} pluginName */ Xinha.getPluginConstructor = function(pluginName) { return Xinha.plugins[pluginName] || window[pluginName]; }; /** Create the specified plugin and register it with this Xinha * return the plugin created to allow refresh when necessary.<br /> * <strong>This is only useful if Xinha is generated without using Xinha.makeEditors()</strong> */ Xinha.prototype.registerPlugin = function() { if (!Xinha.isSupportedBrowser) { return; } var plugin = arguments[0]; // We can only register plugins that have been succesfully loaded if ( plugin === null || typeof plugin == 'undefined' || (typeof plugin == 'string' && Xinha.getPluginConstructor(plugin) == 'undefined') ) { return false; } var args = []; for ( var i = 1; i < arguments.length; ++i ) { args.push(arguments[i]); } return this.registerPlugin2(plugin, args); }; /** This is the variant of the function above where the plugin arguments are * already packed in an array. Externally, it should be only used in the * full-screen editor code, in order to initialize plugins with the same * parameters as in the opener window. * @private */ Xinha.prototype.registerPlugin2 = function(plugin, args) { if ( typeof plugin == "string" && typeof Xinha.getPluginConstructor(plugin) == 'function' ) { var pluginName = plugin; plugin = Xinha.getPluginConstructor(plugin); } if ( typeof plugin == "undefined" ) { /* FIXME: This should never happen. But why does it do? */ return false; } if (!plugin._pluginInfo) { plugin._pluginInfo = { name: pluginName }; } var obj = new plugin(this, args); if ( obj ) { var clone = {}; var info = plugin._pluginInfo; for ( var i in info ) { clone[i] = info[i]; } clone.instance = obj; clone.args = args; this.plugins[plugin._pluginInfo.name] = clone; return obj; } else { Xinha.debugMsg("Can't register plugin " + plugin.toString() + ".", 'warn'); } }; /** Dynamically returns the directory from which the plugins are loaded<br /> * This could be overridden to change the dir<br /> * @TODO: Wouldn't this be better as a config option? * @private * @param {String} pluginName * @param {Boolean} return the directory for an unsupported plugin * @returns {String} path to plugin */ Xinha.getPluginDir = function(plugin, forceUnsupported) { if (Xinha.externalPlugins[plugin]) { return Xinha.externalPlugins[plugin][0]; } if (forceUnsupported || // If the plugin is fully loaded, it's supported status is already set. (Xinha.getPluginConstructor(plugin) && (typeof Xinha.getPluginConstructor(plugin).supported != 'undefined') && !Xinha.getPluginConstructor(plugin).supported)) { return _editor_url + "unsupported_plugins/" + plugin ; } return _editor_url + "plugins/" + plugin ; }; /** Static function that loads the given plugin * @param {String} pluginName * @param {Function} callback function to be called when file is loaded * @param {String} plugin_file URL of the file to load * @returns {Boolean} true if plugin loaded, false otherwise */ Xinha.loadPlugin = function(pluginName, callback, url) { if (!Xinha.isSupportedBrowser) { return; } Xinha.setLoadingMessage (Xinha._lc("Loading plugin $plugin="+pluginName+"$")); // Might already be loaded if ( typeof Xinha.getPluginConstructor(pluginName) != 'undefined' ) { if ( callback ) { callback(pluginName); } return true; } Xinha._pluginLoadStatus[pluginName] = 'loading'; // This function will try to load a plugin in multiple passes. It tries to // load the plugin from either the plugin or unsupported directory, using // both naming schemes in this order: // 1. /plugins -> CurrentNamingScheme // 2. /plugins -> old-naming-scheme // 3. /unsupported -> CurrentNamingScheme // 4. /unsupported -> old-naming-scheme function multiStageLoader(stage,pluginName) { var nextstage, dir, file, success_message; switch (stage) { case 'start': nextstage = 'old_naming'; dir = Xinha.getPluginDir(pluginName); file = pluginName + ".js"; break; case 'old_naming': nextstage = 'unsupported'; dir = Xinha.getPluginDir(pluginName); file = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js"; success_message = 'You are using an obsolete naming scheme for the Xinha plugin '+pluginName+'. Please rename '+file+' to '+pluginName+'.js'; break; case 'unsupported': nextstage = 'unsupported_old_name'; dir = Xinha.getPluginDir(pluginName, true); file = pluginName + ".js"; success_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/ticket/1297'; break; case 'unsupported_old_name': nextstage = ''; dir = Xinha.getPluginDir(pluginName, true); file = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js"; success_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/ticket/1297'; break; default: Xinha._pluginLoadStatus[pluginName] = 'failed'; Xinha.debugMsg('Xinha was not able to find the plugin '+pluginName+'. Please make sure the plugin exists.', 'warn'); return; } var url = dir + "/" + file; // This is a callback wrapper that allows us to set the plugin's status // once it loads. function statusCallback(pluginName) { Xinha.getPluginConstructor(pluginName).supported = stage.indexOf('unsupported') !== 0; callback(pluginName); } // To speed things up, we start loading the script file before pinging it. // If the load fails, we'll just clean up afterwards. Xinha._loadback(url, statusCallback, this, pluginName); Xinha.ping(url, // On success, we'll display a success message if there is one. function() { if (success_message) { Xinha.debugMsg(success_message); } }, // On failure, we'll clean up the failed load and try the next stage function() { Xinha.removeFromParent(document.getElementById(url)); multiStageLoader(nextstage, pluginName); }); } if(!url) { if (Xinha.externalPlugins[pluginName]) { Xinha._loadback(Xinha.externalPlugins[pluginName][0]+Xinha.externalPlugins[pluginName][1], callback, this, pluginName); } else { var editor = this; multiStageLoader('start',pluginName); } } else { Xinha._loadback(url, callback, this, pluginName); } return false; }; /** Stores a status for each loading plugin that may be one of "loading","ready", or "failed" * @private * @type {Object} */ Xinha._pluginLoadStatus = {}; /** Stores the paths to plugins that are not in the default location * @private * @type {Object} */ Xinha.externalPlugins = {}; /** The namespace for plugins * @private * @type {Object} */ Xinha.plugins = {}; /** Static function that loads the plugins (see xinha_plugins in NewbieGuide) * @param {Array} plugins * @param {Function} callbackIfNotReady function that is called repeatedly until all files are * @param {String} optional url URL of the plugin file; obviously plugins should contain only one item if url is given * @returns {Boolean} true if all plugins are loaded, false otherwise */ Xinha.loadPlugins = function(plugins, callbackIfNotReady,url) { if (!Xinha.isSupportedBrowser) { return; } //Xinha.setLoadingMessage (Xinha._lc("Loading plugins")); var m,i; for (i=0;i<plugins.length;i++) { if (typeof plugins[i] == 'object') { m = plugins[i].url.match(/(.*)(\/[^\/]*)$/); Xinha.externalPlugins[plugins[i].plugin] = [m[1],m[2]]; plugins[i] = plugins[i].plugin; } } // Rip the ones that are loaded and look for ones that have failed var retVal = true; var nuPlugins = Xinha.cloneObject(plugins); for (i=0;i<nuPlugins.length;i++ ) { var p = nuPlugins[i]; if (p == 'FullScreen' && !Xinha.externalPlugins.FullScreen) { continue; //prevent trying to load FullScreen plugin from the plugins folder } if ( typeof Xinha._pluginLoadStatus[p] == 'undefined') { // Load it Xinha.loadPlugin(p, function(plugin) { Xinha.setLoadingMessage (Xinha._lc("Finishing")); if ( typeof Xinha.getPluginConstructor(plugin) != 'undefined' ) { Xinha._pluginLoadStatus[plugin] = 'ready'; } else { Xinha._pluginLoadStatus[plugin] = 'failed'; } }, url); retVal = false; } else if ( Xinha._pluginLoadStatus[p] == 'loading') { retVal = false; } } // All done, just return if ( retVal ) { return true; } // Waiting on plugins to load, return false now and come back a bit later // if we have to callback if ( callbackIfNotReady ) { setTimeout(function() { if ( Xinha.loadPlugins(plugins, callbackIfNotReady) ) { callbackIfNotReady(); } }, 50); } return retVal; }; // /** Refresh plugin by calling onGenerate or onGenerateOnce method. * @private * @param {PluginInstance} plugin */ Xinha.refreshPlugin = function(plugin) { if ( plugin && typeof plugin.onGenerate == "function" ) { plugin.onGenerate(); } if ( plugin && typeof plugin.onGenerateOnce == "function" ) { //#1392: in fullpage mode this function is called recusively by setFullHTML() when it is used to set the editor content // this is a temporary fix, that should better be handled by a better implemetation of setFullHTML plugin._ongenerateOnce = plugin.onGenerateOnce; delete(plugin.onGenerateOnce); plugin._ongenerateOnce(); delete(plugin._ongenerateOnce); } }; /** Call a method of all plugins which define the method using the supplied arguments.<br /><br /> * * Example: <code>editor.firePluginEvent('onExecCommand', 'paste')</code><br /> * The plugin would then define a method<br /> * <code>PluginName.prototype.onExecCommand = function (cmdID, UI, param) {do something...}</code><br /><br /> * The following methodNames are currently available:<br /> * <table border="1"> * <tr> * <th>methodName</th><th>Parameters</th> * </tr> * <tr> * <td>onExecCommand</td><td> cmdID, UI, param</td> * </tr> * <tr> * <td>onKeyPress</td><td>ev</td> * </tr> * <tr> * <td>onMouseDown</td><td>ev</td> * </tr> * </table><br /><br /> * * The browser specific plugin (if any) is called last. The result of each call is * treated as boolean. A true return means that the event will stop, no further plugins * will get the event, a false return means the event will continue to fire. * * @param {String} methodName * @param {mixed} arguments to pass to the method, optional [2..n] * @returns {Boolean} */ Xinha.prototype.firePluginEvent = function(methodName) { // arguments is not a real array so we can't just .shift() it unfortunatly. var argsArray = [ ]; for(var i = 1; i < arguments.length; i++) { argsArray[i-1] = arguments[i]; } for ( i in this.plugins ) { var plugin = this.plugins[i].instance; // Skip the browser specific plugin if (plugin == this._browserSpecificPlugin) { continue; } if ( plugin && typeof plugin[methodName] == "function" ) { var thisArg = (i == 'Events') ? this : plugin; if ( plugin[methodName].apply(thisArg, argsArray) ) { return true; } } } // Now the browser speific plugin = this._browserSpecificPlugin; if ( plugin && typeof plugin[methodName] == "function" ) { if ( plugin[methodName].apply(plugin, argsArray) ) { return true; } } return false; }; /** Adds a stylesheet to the document * @param {String} style name of the stylesheet file * @param {String} plugin optional name of a plugin; if passed this function looks for the stylesheet file in the plugin directory * @param {String} id optional a unique id for identifiing the created link element, e.g. for avoiding double loading * or later removing it again */ Xinha.loadStyle = function(style, plugin, id,prepend) { var url = _editor_url || ''; if ( plugin ) { url = Xinha.getPluginDir( plugin ) + "/"; } url += style; // @todo: would not it be better to check the first character instead of a regex ? // if ( typeof style == 'string' && style.charAt(0) == '/' ) // { // url = style; // } if ( /^\//.test(style) ) { url = style; } var head = document.getElementsByTagName("head")[0]; var link = document.createElement("link"); link.rel = "stylesheet"; link.href = url; link.type = "text/css"; if (id) { link.id = id; } if (prepend && head.getElementsByTagName('link')[0]) { head.insertBefore(link,head.getElementsByTagName('link')[0]); } else { head.appendChild(link); } }; /** Adds a script to the document * * Warning: Browsers may cause the script to load asynchronously. * * @param {String} style name of the javascript file * @param {String} plugin optional name of a plugin; if passed this function looks for the stylesheet file in the plugin directory * */ Xinha.loadScript = function(script, plugin, callback) { var url = _editor_url || ''; if ( plugin ) { url = Xinha.getPluginDir( plugin ) + "/"; } url += script; // @todo: would not it be better to check the first character instead of a regex ? // if ( typeof style == 'string' && style.charAt(0) == '/' ) // { // url = style; // } if ( /^\//.test(script) ) { url = script; } Xinha._loadback(url, callback); }; /** Load one or more assets, sequentially, where an asset is a CSS file, or a javascript file. * * Example Usage: * * Xinha.includeAssets( 'foo.css', 'bar.js', [ 'foo.css', 'MyPlugin' ], { type: 'text/css', url: 'foo.php', plugin: 'MyPlugin } ); * * Alternative usage, use Xinha.includeAssets() to make a loader, then use loadScript, loadStyle and whenReady methods * on your loader object as and when you wish, you can chain the calls if you like. * * You may add any number of callbacks using .whenReady() multiple times. * * var myAssetLoader = Xinha.includeAssets(); * myAssetLoader.loadScript('foo.js', 'MyPlugin') * .loadStyle('foo.css', 'MyPlugin'); * */ Xinha.includeAssets = function() { var assetLoader = { pendingAssets: [ ], loaderRunning: false, loadedScripts: [ ] }; assetLoader.callbacks = [ ]; assetLoader.loadNext = function() { var self = this; this.loaderRunning = true; if(this.pendingAssets.length) { var nxt = this.pendingAssets[0]; this.pendingAssets.splice(0,1); // Remove 1 element switch(nxt.type) { case 'text/css': Xinha.loadStyle(nxt.url, nxt.plugin); return this.loadNext(); case 'text/javascript': Xinha.loadScript(nxt.url, nxt.plugin, function() { self.loadNext(); }); } } else { this.loaderRunning = false; this.runCallback(); } }; assetLoader.loadScript = function(url, plugin) { var self = this; this.pendingAssets.push({ 'type': 'text/javascript', 'url': url, 'plugin': plugin }); if(!this.loaderRunning) this.loadNext(); return this; }; assetLoader.loadScriptOnce = function(url, plugin) { for(var i = 0; i < this.loadedScripts.length; i++) { if(this.loadedScripts[i].url == url && this.loadedScripts[i].plugin == plugin) return this; // Already done (or in process) } return this.loadScript(url, plugin); } assetLoader.loadStyle = function(url, plugin) { var self = this; this.pendingAssets.push({ 'type': 'text/css', 'url': url, 'plugin': plugin }); if(!this.loaderRunning) this.loadNext(); return this; }; assetLoader.whenReady = function(callback) { this.callbacks.push(callback); if(!this.loaderRunning) this.loadNext(); return this; }; assetLoader.runCallback = function() { while(this.callbacks.length) { var _callback = this.callbacks.splice(0,1); _callback[0](); _callback = null; } return this; } for(var i = 0 ; i < arguments.length; i++) { if(typeof arguments[i] == 'string') { if(arguments[i].match(/\.css$/i)) { assetLoader.loadStyle(arguments[i]); } else { assetLoader.loadScript(arguments[i]); } } else if(arguments[i].type) { if(arguments[i].type.match(/text\/css/i)) { assetLoader.loadStyle(arguments[i].url, arguments[i].plugin); } else if(arguments[i].type.match(/text\/javascript/i)) { assetLoader.loadScript(arguments[i].url, arguments[i].plugin); } } else if(arguments[i].length >= 1) { if(arguments[i][0].match(/\.css$/i)) { assetLoader.loadStyle(arguments[i][0], arguments[i][1]); } else { assetLoader.loadScript(arguments[i][0], arguments[i][1]); } } } return assetLoader; } /*************************************************** * Category: EDITOR UTILITIES ***************************************************/ /** Utility function: Outputs the structure of the edited document */ Xinha.prototype.debugTree = function() { var ta = document.createElement("textarea"); ta.style.width = "100%"; ta.style.height = "20em"; ta.value = ""; function debug(indent, str) { for ( ; --indent >= 0; ) { ta.value += " "; } ta.value += str + "\n"; } function _dt(root, level) { var tag = root.tagName.toLowerCase(), i; var ns = Xinha.is_ie ? root.scopeName : root.prefix; debug(level, "- " + tag + " [" + ns + "]"); for ( i = root.firstChild; i; i = i.nextSibling ) { if ( i.nodeType == 1 ) { _dt(i, level + 2); } } } _dt(this._doc.body, 0); document.body.appendChild(ta); }; /** Extracts the textual content of a given node * @param {DomNode} el */ Xinha.getInnerText = function(el) { var txt = '', i; for ( i = el.firstChild; i; i = i.nextSibling ) { if ( i.nodeType == 3 ) { txt += i.data; } else if ( i.nodeType == 1 ) { txt += Xinha.getInnerText(i); } } return txt; }; /** Cleans dirty HTML from MS word; always cleans the whole editor content * @TODO: move this in a separate file * @TODO: turn this into a static function that cleans a given string */ Xinha.prototype._wordClean = function() { var editor = this; var stats = { empty_tags : 0, cond_comm : 0, mso_elmts : 0, mso_class : 0, mso_style : 0, mso_xmlel : 0, orig_len : this._doc.body.innerHTML.length, T : new Date().getTime() }; var stats_txt = { empty_tags : "Empty tags removed: ", cond_comm : "Conditional comments removed", mso_elmts : "MSO invalid elements removed", mso_class : "MSO class names removed: ", mso_style : "MSO inline style removed: ", mso_xmlel : "MSO XML elements stripped: " }; function showStats() { var txt = "Xinha word cleaner stats: \n\n"; for ( var i in stats ) { if ( stats_txt[i] ) { txt += stats_txt[i] + stats[i] + "\n"; } } txt += "\nInitial document length: " + stats.orig_len + "\n"; txt += "Final document length: " + editor._doc.body.innerHTML.length + "\n"; txt += "Clean-up took " + ((new Date().getTime() - stats.T) / 1000) + " seconds"; alert(txt); } function clearClass(node) { var newc = node.className.replace(/(^|\s)mso.*?(\s|$)/ig, ' '); if ( newc != node.className ) { node.className = newc; if ( !/\S/.test(node.className)) { node.removeAttribute("className"); ++stats.mso_class; } } } function clearStyle(node) { var declarations = node.style.cssText.split(/\s*;\s*/); for ( var i = declarations.length; --i >= 0; ) { if ( /^mso|^tab-stops/i.test(declarations[i]) || /^margin\s*:\s*0..\s+0..\s+0../i.test(declarations[i]) ) { ++stats.mso_style; declarations.splice(i, 1); } } node.style.cssText = declarations.join("; "); } function removeElements(el) { if (('link' == el.tagName.toLowerCase() && (el.attributes && /File-List|Edit-Time-Data|themeData|colorSchemeMapping/.test(el.attributes.rel.nodeValue))) || /^(style|meta)$/i.test(el.tagName)) { Xinha.removeFromParent(el); ++stats.mso_elmts; return true; } return false; } function checkEmpty(el) { // @todo : check if this is quicker // if (!['A','SPAN','B','STRONG','I','EM','FONT'].contains(el.tagName) && !el.firstChild) if ( /^(a|span|b|strong|i|em|font|div|p)$/i.test(el.tagName) && !el.firstChild) { Xinha.removeFromParent(el); ++stats.empty_tags; return true; } return false; } function parseTree(root) { clearClass(root); clearStyle(root); var next; for (var i = root.firstChild; i; i = next ) { next = i.nextSibling; if ( i.nodeType == 1 && parseTree(i) ) { if ((Xinha.is_ie && root.scopeName != 'HTML') || (!Xinha.is_ie && /:/.test(i.tagName))) { // Nowadays, Word spits out tags like '<o:something />'. Since the // document being cleaned might be HTML4 and not XHTML, this tag is // interpreted as '<o:something /="/">'. For HTML tags without // closing elements (e.g. IMG) these two forms are equivalent. Since // HTML does not recognize these tags, however, they end up as // parents of elements that should be their siblings. We reparent // the children and remove them from the document. for (var index=i.childNodes && i.childNodes.length-1; i.childNodes && i.childNodes.length && i.childNodes[index]; --index) { if (i.nextSibling) { i.parentNode.insertBefore(i.childNodes[index],i.nextSibling); } else { i.parentNode.appendChild(i.childNodes[index]); } } Xinha.removeFromParent(i); continue; } if (checkEmpty(i)) { continue; } if (removeElements(i)) { continue; } } else if (i.nodeType == 8) { // 8 is a comment node, and can contain conditional comments, which // will be interpreted by IE as if they were not comments. if (/(\s*\[\s*if\s*(([gl]te?|!)\s*)?(IE|mso)\s*(\d+(\.\d+)?\s*)?\]>)/.test(i.nodeValue)) { // We strip all conditional comments directly from the tree. Xinha.removeFromParent(i); ++stats.cond_comm; } } } return true; } parseTree(this._doc.body); // showStats(); // this.debugTree(); // this.setHTML(this.getHTML()); // this.setHTML(this.getInnerHTML()); // this.forceRedraw(); this.updateToolbar(); }; /** Removes &lt;font&gt; tags; always cleans the whole editor content * @TODO: move this in a separate file * @TODO: turn this into a static function that cleans a given string */ Xinha.prototype._clearFonts = function() { var D = this.getInnerHTML(); if ( confirm(Xinha._lc("Would you like to clear font typefaces?")) ) { D = D.replace(/face="[^"]*"/gi, ''); D = D.replace(/font-family:[^;}"']+;?/gi, ''); } if ( confirm(Xinha._lc("Would you like to clear font sizes?")) ) { D = D.replace(/size="[^"]*"/gi, ''); D = D.replace(/font-size:[^;}"']+;?/gi, ''); } if ( confirm(Xinha._lc("Would you like to clear font colours?")) ) { D = D.replace(/color="[^"]*"/gi, ''); D = D.replace(/([^\-])color:[^;}"']+;?/gi, '$1'); } D = D.replace(/(style|class)="\s*"/gi, ''); D = D.replace(/<(font|span)\s*>/gi, ''); this.setHTML(D); this.updateToolbar(); }; Xinha.prototype._splitBlock = function() { this._doc.execCommand('formatblock', false, 'div'); }; /** Sometimes the display has to be refreshed to make DOM changes visible (?) (Gecko bug?) */ Xinha.prototype.forceRedraw = function() { this._doc.body.style.visibility = "hidden"; this._doc.body.style.visibility = ""; // this._doc.body.innerHTML = this.getInnerHTML(); }; /** Focuses the iframe window. * @returns {document} a reference to the editor document */ Xinha.prototype.focusEditor = function() { switch (this._editMode) { // notice the try { ... } catch block to avoid some rare exceptions in FireFox // (perhaps also in other Gecko browsers). Manual focus by user is required in // case of an error. Somebody has an idea? case "wysiwyg" : try { // We don't want to focus the field unless at least one field has been activated. if ( Xinha._someEditorHasBeenActivated ) { this.activateEditor(); // Ensure *this* editor is activated this._iframe.contentWindow.focus(); // and focus it } } catch (ex) {} break; case "textmode": try { this._textArea.focus(); } catch (e) {} break; default: alert("ERROR: mode " + this._editMode + " is not defined"); } return this._doc; }; /** Takes a snapshot of the current text (for undo) * @private */ Xinha.prototype._undoTakeSnapshot = function() { ++this._undoPos; if ( this._undoPos >= this.config.undoSteps ) { // remove the first element this._undoQueue.shift(); --this._undoPos; } // use the fasted method (getInnerHTML); var take = true; var txt = this.getInnerHTML(); if ( this._undoPos > 0 ) { take = (this._undoQueue[this._undoPos - 1] != txt); } if ( take ) { this._undoQueue[this._undoPos] = txt; } else { this._undoPos--; } }; /** Custom implementation of undo functionality * @private */ Xinha.prototype.undo = function() { if ( this._undoPos > 0 ) { var txt = this._undoQueue[--this._undoPos]; if ( txt ) { this.setHTML(txt); } else { ++this._undoPos; } } }; /** Custom implementation of redo functionality * @private */ Xinha.prototype.redo = function() { if ( this._undoPos < this._undoQueue.length - 1 ) { var txt = this._undoQueue[++this._undoPos]; if ( txt ) { this.setHTML(txt); } else { --this._undoPos; } } }; /** Disables (greys out) the buttons of the toolbar * @param {Array} except this array contains ids of toolbar objects that will not be disabled */ Xinha.prototype.disableToolbar = function(except) { if ( this._timerToolbar ) { clearTimeout(this._timerToolbar); } if ( typeof except == 'undefined' ) { except = [ ]; } else if ( typeof except != 'object' ) { except = [except]; } for ( var i in this._toolbarObjects ) { var btn = this._toolbarObjects[i]; if ( except.contains(i) ) { continue; } // prevent iterating over wrong type if ( typeof btn.state != 'function' ) { continue; } btn.state("enabled", false); } }; /** Enables the toolbar again when disabled by disableToolbar() */ Xinha.prototype.enableToolbar = function() { this.updateToolbar(); }; /** Updates enabled/disable/active state of the toolbar elements, the statusbar and other things * This function is called on every key stroke as well as by a timer on a regular basis.<br /> * Plugins have the opportunity to implement a prototype.onUpdateToolbar() method, which will also * be called by this function. * @param {Boolean} noStatus private use Exempt updating of statusbar */ // FIXME : this function needs to be splitted in more functions. // It is actually to heavy to be understable and very scary to manipulate Xinha.prototype.updateToolbar = function(noStatus) { if (this.suspendUpdateToolbar) { return; } var doc = this._doc; var text = (this._editMode == "textmode"); var ancestors = null; if ( !text ) { ancestors = this.getAllAncestors(); if ( this.config.statusBar && !noStatus ) { while ( this._statusBarItems.length ) { var item = this._statusBarItems.pop(); item.el = null; item.editor = null; item.onclick = null; item.oncontextmenu = null; item._xinha_dom0Events.click = null; item._xinha_dom0Events.contextmenu = null; item = null; } this._statusBarTree.innerHTML = ' '; this._statusBarTree.appendChild(document.createTextNode(Xinha._lc("Path") + ": ")); for ( var i = ancestors.length; --i >= 0; ) { var el = ancestors[i]; if ( !el ) { // hell knows why we get here; this // could be a classic example of why // it's good to check for conditions // that are impossible to happen ;-) continue; } var a = document.createElement("a"); a.href = "javascript:void(0);"; a.el = el; a.editor = this; this._statusBarItems.push(a); Xinha.addDom0Event( a, 'click', function() { this.blur(); this.editor.selectNodeContents(this.el); this.editor.updateToolbar(true); return false; } ); Xinha.addDom0Event( a, 'contextmenu', function() { // TODO: add context menu here this.blur(); var info = "Inline style:\n\n"; info += this.el.style.cssText.split(/;\s*/).join(";\n"); alert(info); return false; } ); var txt = el.tagName.toLowerCase(); switch (txt) { case 'b': txt = 'strong'; break; case 'i': txt = 'em'; break; case 'strike': txt = 'del'; break; } if (typeof el.style != 'undefined') { a.title = el.style.cssText; } if ( el.id ) { txt += "#" + el.id; } if ( el.className ) { txt += "." + el.className; } a.appendChild(document.createTextNode(txt)); this._statusBarTree.appendChild(a); if ( i !== 0 ) { this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb))); } Xinha.freeLater(a); } } } for ( var cmd in this._toolbarObjects ) { var btn = this._toolbarObjects[cmd]; var inContext = true; // prevent iterating over wrong type if ( typeof btn.state != 'function' ) { continue; } if ( btn.context && !text ) { inContext = false; var context = btn.context; var attrs = []; if ( /(.*)\[(.*?)\]/.test(context) ) { context = RegExp.$1; attrs = RegExp.$2.split(","); } context = context.toLowerCase(); var match = (context == "*"); for ( var k = 0; k < ancestors.length; ++k ) { if ( !ancestors[k] ) { // the impossible really happens. continue; } if ( match || ( ancestors[k].tagName.toLowerCase() == context ) ) { inContext = true; var contextSplit = null; var att = null; var comp = null; var attVal = null; for ( var ka = 0; ka < attrs.length; ++ka ) { contextSplit = attrs[ka].match(/(.*)(==|!=|===|!==|>|>=|<|<=)(.*)/); att = contextSplit[1]; comp = contextSplit[2]; attVal = contextSplit[3]; if (!eval(ancestors[k][att] + comp + attVal)) { inContext = false; break; } } if ( inContext ) { break; } } } } btn.state("enabled", (!text || btn.text) && inContext); if ( typeof cmd == "function" ) { continue; } // look-it-up in the custom dropdown boxes var dropdown = this.config.customSelects[cmd]; if ( ( !text || btn.text ) && ( typeof dropdown != "undefined" ) ) { dropdown.refresh(this); continue; } switch (cmd) { case "fontname": case "fontsize": if ( !text ) { try { var value = ("" + doc.queryCommandValue(cmd)).toLowerCase(); if ( !value ) { btn.element.selectedIndex = 0; break; } // HACK -- retrieve the config option for this // combo box. We rely on the fact that the // variable in config has the same name as // button name in the toolbar. var options = this.config[cmd]; var sIndex = 0; for ( var j in options ) { // FIXME: the following line is scary. if ( ( j.toLowerCase() == value ) || ( options[j].substr(0, value.length).toLowerCase() == value ) ) { btn.element.selectedIndex = sIndex; throw "ok"; } ++sIndex; } btn.element.selectedIndex = 0; } catch(ex) {} } break; // It's better to search for the format block by tag name from the // current selection upwards, because IE has a tendancy to return // things like 'heading 1' for 'h1', which breaks things if you want // to call your heading blocks 'header 1'. Stupid MS. case "formatblock": var blocks = []; for ( var indexBlock in this.config.formatblock ) { // prevent iterating over wrong type if ( typeof this.config.formatblock[indexBlock] == 'string' ) { blocks[blocks.length] = this.config.formatblock[indexBlock]; } } var deepestAncestor = this._getFirstAncestor(this.getSelection(), blocks); if ( deepestAncestor ) { for ( var x = 0; x < blocks.length; x++ ) { if ( blocks[x].toLowerCase() == deepestAncestor.tagName.toLowerCase() ) { btn.element.selectedIndex = x; } } } else { btn.element.selectedIndex = 0; } break; case "textindicator": if ( !text ) { try { var style = btn.element.style; style.backgroundColor = Xinha._makeColor(doc.queryCommandValue(Xinha.is_ie ? "backcolor" : "hilitecolor")); if ( /transparent/i.test(style.backgroundColor) ) { // Mozilla style.backgroundColor = Xinha._makeColor(doc.queryCommandValue("backcolor")); } style.color = Xinha._makeColor(doc.queryCommandValue("forecolor")); style.fontFamily = doc.queryCommandValue("fontname"); style.fontWeight = doc.queryCommandState("bold") ? "bold" : "normal"; style.fontStyle = doc.queryCommandState("italic") ? "italic" : "normal"; } catch (ex) { // alert(e + "\n\n" + cmd); } } break; case "htmlmode": btn.state("active", text); break; case "lefttoright": case "righttoleft": var eltBlock = this.getParentElement(); while ( eltBlock && !Xinha.isBlockElement(eltBlock) ) { eltBlock = eltBlock.parentNode; } if ( eltBlock ) { btn.state("active", (eltBlock.style.direction == ((cmd == "righttoleft") ? "rtl" : "ltr"))); } break; default: cmd = cmd.replace(/(un)?orderedlist/i, "insert$1orderedlist"); try { btn.state("active", (!text && doc.queryCommandState(cmd))); } catch (ex) {} break; } } // take undo snapshots if ( this._customUndo && !this._timerUndo ) { this._undoTakeSnapshot(); var editor = this; this._timerUndo = setTimeout(function() { editor._timerUndo = null; }, this.config.undoTimeout); } this.firePluginEvent('onUpdateToolbar'); }; /** Returns a editor object referenced by the id or name of the textarea or the textarea node itself * For example to retrieve the HTML of an editor made out of the textarea with the id "myTextArea" you would do<br /> * <code> * var editor = Xinha.getEditor("myTextArea"); * var html = editor.getEditorContent(); * </code> * @returns {Xinha|null} * @param {String|DomNode} ref id or name of the textarea or the textarea node itself */ Xinha.getEditor = function(ref) { for ( var i = __xinhas.length; i--; ) { var editor = __xinhas[i]; if ( editor && ( editor._textArea.id == ref || editor._textArea.name == ref || editor._textArea == ref ) ) { return editor; } } return null; }; /** Sometimes one wants to call a plugin method directly, e.g. from outside the editor. * This function returns the respective editor's instance of a plugin. * For example you might want to have a button to trigger SaveSubmit's save() method:<br /> * <code> * &lt;button type="button" onclick="Xinha.getEditor('myTextArea').getPluginInstance('SaveSubmit').save();return false;"&gt;Save&lt;/button&gt; * </code> * @returns {PluginObject|null} * @param {String} plugin name of the plugin */ Xinha.prototype.getPluginInstance = function (plugin) { if (this.plugins[plugin]) { return this.plugins[plugin].instance; } else { return null; } }; /** Returns an array with all the ancestor nodes of the selection or current cursor position. * @returns {Array} */ Xinha.prototype.getAllAncestors = function() { var p = this.getParentElement(); var a = []; while ( p && (p.nodeType == 1) && ( p.tagName.toLowerCase() != 'body' ) ) { a.push(p); p = p.parentNode; } a.push(this._doc.body); return a; }; /** Traverses the DOM upwards and returns the first element that is of one of the specified types * @param {Selection} sel Selection object as returned by getSelection * @param {Array} types Array of matching criteria. Each criteria is either a string containing the tag name, or a callback used to select the element. * @returns {DomNode|null} */ Xinha.prototype._getFirstAncestor = function(sel, types) { var prnt = this.activeElement(sel); if ( prnt === null ) { // Hmm, I think Xinha.getParentElement() would do the job better?? - James try { prnt = (Xinha.is_ie ? this.createRange(sel).parentElement() : this.createRange(sel).commonAncestorContainer); } catch(ex) { return null; } } if ( typeof types == 'string' ) { types = [types]; } while ( prnt ) { if ( prnt.nodeType == 1 ) { if ( types === null ) { return prnt; } for (var index=0; index<types.length; ++index) { if (typeof types[index] == 'string' && types[index] == prnt.tagName.toLowerCase()){ // Criteria is a tag name. It matches return prnt; } else if (typeof types[index] == 'function' && types[index](this, prnt)) { // Criteria is a callback. It matches return prnt; } } if ( prnt.tagName.toLowerCase() == 'body' ) { break; } if ( prnt.tagName.toLowerCase() == 'table' ) { break; } } prnt = prnt.parentNode; } return null; }; /** Traverses the DOM upwards and returns the first element that is a block level element * @param {Selection} sel Selection object as returned by getSelection * @returns {DomNode|null} */ Xinha.prototype._getAncestorBlock = function(sel) { // Scan upwards to find a block level element that we can change or apply to var prnt = (Xinha.is_ie ? this.createRange(sel).parentElement : this.createRange(sel).commonAncestorContainer); while ( prnt && ( prnt.nodeType == 1 ) ) { switch ( prnt.tagName.toLowerCase() ) { case 'div': case 'p': case 'address': case 'blockquote': case 'center': case 'del': case 'ins': case 'pre': case 'h1': case 'h2': case 'h3': case 'h4': case 'h5': case 'h6': case 'h7': // Block Element return prnt; case 'body': case 'noframes': case 'dd': case 'li': case 'th': case 'td': case 'noscript' : // Halting element (stop searching) return null; default: // Keep lookin break; } } return null; }; /** What's this? does nothing, has to be removed * * @deprecated */ Xinha.prototype._createImplicitBlock = function(type) { // expand it until we reach a block element in either direction // then wrap the selection in a block and return var sel = this.getSelection(); if ( Xinha.is_ie ) { sel.empty(); } else { sel.collapseToStart(); } var rng = this.createRange(sel); // Expand UP // Expand DN }; /** * Call this function to surround the existing HTML code in the selection with * your tags. FIXME: buggy! Don't use this * @todo: when will it be deprecated ? Can it be removed already ? * @private (tagged private to not further promote use of this function) * @deprecated */ Xinha.prototype.surroundHTML = function(startTag, endTag) { var html = this.getSelectedHTML(); // the following also deletes the selection this.insertHTML(startTag + html + endTag); }; /** Return true if we have some selection * @returns {Boolean} */ Xinha.prototype.hasSelectedText = function() { // FIXME: come _on_ mishoo, you can do better than this ;-) return this.getSelectedHTML() !== ''; }; /*************************************************** * Category: EVENT HANDLERS ***************************************************/ /** onChange handler for dropdowns in toolbar * @private * @param {DomNode} el Reference to the SELECT object * @param {String} txt The name of the select field, as in config.toolbar * @returns {DomNode|null} */ Xinha.prototype._comboSelected = function(el, txt) { this.focusEditor(); var value = el.options[el.selectedIndex].value; switch (txt) { case "fontname": case "fontsize": this.execCommand(txt, false, value); break; case "formatblock": // Mozilla inserts an empty tag (<>) if no parameter is passed if ( !value ) { this.updateToolbar(); break; } if( !Xinha.is_gecko || value !== 'blockquote' ) { value = "<" + value + ">"; } this.execCommand(txt, false, value); break; default: // try to look it up in the registered dropdowns var dropdown = this.config.customSelects[txt]; if ( typeof dropdown != "undefined" ) { dropdown.action(this, value, el, txt); } else { alert("FIXME: combo box " + txt + " not implemented"); } break; } }; /** Open a popup to select the hilitecolor or forecolor * @private * @param {String} cmdID The commande ID (hilitecolor or forecolor) */ Xinha.prototype._colorSelector = function(cmdID) { var editor = this; // for nested functions // backcolor only works with useCSS/styleWithCSS (see mozilla bug #279330 & Midas doc) // and its also nicer as <font> if ( Xinha.is_gecko ) { try { editor._doc.execCommand('useCSS', false, false); // useCSS deprecated & replaced by styleWithCSS editor._doc.execCommand('styleWithCSS', false, true); } catch (ex) {} } var btn = editor._toolbarObjects[cmdID].element; var initcolor; if ( cmdID == 'hilitecolor' ) { if ( Xinha.is_ie ) { cmdID = 'backcolor'; initcolor = Xinha._colorToRgb(editor._doc.queryCommandValue("backcolor")); } else { initcolor = Xinha._colorToRgb(editor._doc.queryCommandValue("hilitecolor")); } } else { initcolor = Xinha._colorToRgb(editor._doc.queryCommandValue("forecolor")); } var cback = function(color) { editor._doc.execCommand(cmdID, false, color); }; if ( Xinha.is_ie ) { var range = editor.createRange(editor.getSelection()); cback = function(color) { range.select(); editor._doc.execCommand(cmdID, false, color); }; } var picker = new Xinha.colorPicker( { cellsize:editor.config.colorPickerCellSize, callback:cback, granularity:editor.config.colorPickerGranularity, websafe:editor.config.colorPickerWebSafe, savecolors:editor.config.colorPickerSaveColors }); picker.open(editor.config.colorPickerPosition, btn, initcolor); }; /** This is a wrapper for the browser's execCommand function that handles things like * formatting, inserting elements, etc.<br /> * It intercepts some commands and replaces them with our own implementation.<br /> * It provides a hook for the "firePluginEvent" system ("onExecCommand").<br /><br /> * For reference see:<br /> * <a href="http://www.mozilla.org/editor/midas-spec.html">Mozilla implementation</a><br /> * <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/execcommand.asp">MS implementation</a> * * @see Xinha#firePluginEvent * @param {String} cmdID command to be executed as defined in the browsers implemantations or Xinha custom * @param {Boolean} UI for compatibility with the execCommand syntax; false in most (all) cases * @param {Mixed} param Some commands require parameters * @returns {Boolean} always false */ Xinha.prototype.execCommand = function(cmdID, UI, param) { var editor = this; // for nested functions this.focusEditor(); cmdID = cmdID.toLowerCase(); // See if any plugins want to do something special if(this.firePluginEvent('onExecCommand', cmdID, UI, param)) { this.updateToolbar(); return false; } switch (cmdID) { case "htmlmode": this.setMode(); break; case "hilitecolor": case "forecolor": this._colorSelector(cmdID); break; case "createlink": this._createLink(); break; case "undo": case "redo": if (this._customUndo) { this[cmdID](); } else { this._doc.execCommand(cmdID, UI, param); } break; case "inserttable": this._insertTable(); break; case "insertimage": this._insertImage(); break; case "showhelp": this._popupDialog(editor.config.URIs.help, null, this); break; case "killword": this._wordClean(); break; case "cut": case "copy": case "paste": this._doc.execCommand(cmdID, UI, param); if ( this.config.killWordOnPaste ) { this._wordClean(); } break; case "lefttoright": case "righttoleft": if (this.config.changeJustifyWithDirection) { this._doc.execCommand((cmdID == "righttoleft") ? "justifyright" : "justifyleft", UI, param); } var dir = (cmdID == "righttoleft") ? "rtl" : "ltr"; var el = this.getParentElement(); while ( el && !Xinha.isBlockElement(el) ) { el = el.parentNode; } if ( el ) { if ( el.style.direction == dir ) { el.style.direction = ""; } else { el.style.direction = dir; } } break; case 'justifyleft' : case 'justifyright' : cmdID.match(/^justify(.*)$/); var ae = this.activeElement(this.getSelection()); if(ae && ae.tagName.toLowerCase() == 'img') { ae.align = ae.align == RegExp.$1 ? '' : RegExp.$1; } else { this._doc.execCommand(cmdID, UI, param); } break; default: try { this._doc.execCommand(cmdID, UI, param); } catch(ex) { if ( this.config.debug ) { alert(ex + "\n\nby execCommand(" + cmdID + ");"); } } break; } this.updateToolbar(); return false; }; /** A generic event handler for things that happen in the IFRAME's document.<br /> * It provides two hooks for the "firePluginEvent" system:<br /> * "onKeyPress"<br /> * "onMouseDown" * @see Xinha#firePluginEvent * @param {Event} ev */ Xinha.prototype._editorEvent = function(ev) { var editor = this; //call events of textarea if ( typeof editor._textArea['on'+ev.type] == "function" ) { editor._textArea['on'+ev.type](ev); } if ( this.isKeyEvent(ev) ) { // Run the ordinary plugins first if(editor.firePluginEvent('onKeyPress', ev)) { return false; } // Handle the core shortcuts if ( this.isShortCut( ev ) ) { this._shortCuts(ev); } } if ( ev.type == 'mousedown' ) { if(editor.firePluginEvent('onMouseDown', ev)) { return false; } } // update the toolbar state after some time if ( editor._timerToolbar ) { clearTimeout(editor._timerToolbar); } if (!this.suspendUpdateToolbar) { editor._timerToolbar = setTimeout( function() { editor.updateToolbar(); editor._timerToolbar = null; }, 250); } }; /** Handle double click events. * See dblclickList in the config. */ Xinha.prototype._onDoubleClick = function(ev) { var editor=this; var target = Xinha.is_ie ? ev.srcElement : ev.target; var tag = target.tagName; var className = target.className; if (tag) { tag = tag.toLowerCase(); if (className && (this.config.dblclickList[tag+"."+className] != undefined)) this.config.dblclickList[tag+"."+className][0](editor, target); else if (this.config.dblclickList[tag] != undefined) this.config.dblclickList[tag][0](editor, target); }; }; /** Handles ctrl + key shortcuts * @TODO: make this mor flexible * @private * @param {Event} ev */ Xinha.prototype._shortCuts = function (ev) { var key = this.getKey(ev).toLowerCase(); var cmd = null; var value = null; switch (key) { // simple key commands follow case 'b': cmd = "bold"; break; case 'i': cmd = "italic"; break; case 'u': cmd = "underline"; break; case 's': cmd = "strikethrough"; break; case 'l': cmd = "justifyleft"; break; case 'e': cmd = "justifycenter"; break; case 'r': cmd = "justifyright"; break; case 'j': cmd = "justifyfull"; break; case 'z': cmd = "undo"; break; case 'y': cmd = "redo"; break; case 'v': cmd = "paste"; break; case 'n': cmd = "formatblock"; value = "p"; break; case '0': cmd = "killword"; break; // headings case '1': case '2': case '3': case '4': case '5': case '6': cmd = "formatblock"; value = "h" + key; break; } if ( cmd ) { // execute simple command this.execCommand(cmd, false, value); Xinha._stopEvent(ev); } }; /** Changes the type of a given node * @param {DomNode} el The element to convert * @param {String} newTagName The type the element will be converted to * @returns {DomNode} A reference to the new element */ Xinha.prototype.convertNode = function(el, newTagName) { var newel = this._doc.createElement(newTagName); while ( el.firstChild ) { newel.appendChild(el.firstChild); } return newel; }; /** Scrolls the editor iframe to a given element or to the cursor * @param {DomNode} e optional The element to scroll to; if ommitted, element the element the cursor is in */ Xinha.prototype.scrollToElement = function(e) { if(!e) { e = this.getParentElement(); if(!e) { return; } } // This was at one time limited to Gecko only, but I see no reason for it to be. - James var position = Xinha.getElementTopLeft(e); this._iframe.contentWindow.scrollTo(position.left, position.top); }; /** Get the edited HTML * * @public * @returns {String} HTML content */ Xinha.prototype.getEditorContent = function() { return this.outwardHtml(this.getHTML()); }; /** Completely change the HTML inside the editor * * @public * @param {String} html new content */ Xinha.prototype.setEditorContent = function(html) { this.setHTML(this.inwardHtml(html)); }; /** Saves the contents of all Xinhas to their respective textareas * @public */ Xinha.updateTextareas = function() { var e; for (var i=0;i<__xinhas.length;i++) { e = __xinhas[i]; e._textArea.value = e.getEditorContent(); } } /** Get the raw edited HTML, should not be used without Xinha.prototype.outwardHtml() * * @private * @returns {String} HTML content */ Xinha.prototype.getHTML = function() { var html = ''; switch ( this._editMode ) { case "wysiwyg": if ( !this.config.fullPage ) { html = Xinha.getHTML(this._doc.body, false, this).trim(); } else { html = this.doctype + "\n" + Xinha.getHTML(this._doc.documentElement, true, this); } break; case "textmode": html = this._textArea.value; break; default: alert("Mode <" + this._editMode + "> not defined!"); return false; } return html; }; /** Performs various transformations of the HTML used internally, complement to Xinha.prototype.inwardHtml() * Plugins can provide their own, additional transformations by defining a plugin.prototype.outwardHtml() implematation, * which is called by this function * * @private * @see Xinha#inwardHtml * @param {String} html * @returns {String} HTML content */ Xinha.prototype.outwardHtml = function(html) { for ( var i in this.plugins ) { var plugin = this.plugins[i].instance; if ( plugin && typeof plugin.outwardHtml == "function" ) { html = plugin.outwardHtml(html); } } html = html.replace(/<(\/?)b(\s|>|\/)/ig, "<$1strong$2"); html = html.replace(/<(\/?)i(\s|>|\/)/ig, "<$1em$2"); html = html.replace(/<(\/?)strike(\s|>|\/)/ig, "<$1del$2"); // remove disabling of inline event handle inside Xinha iframe html = html.replace(/(<[^>]*on(click|mouse(over|out|up|down))=['"])if\(window\.parent &amp;&amp; window\.parent\.Xinha\)\{return false\}/gi,'$1'); // Figure out what our server name is, and how it's referenced var serverBase = location.href.replace(/(https?:\/\/[^\/]*)\/.*/, '$1') + '/'; // IE puts this in can't figure out why // leaving this in the core instead of InternetExplorer // because it might be something we are doing so could present itself // in other browsers - James html = html.replace(/https?:\/\/null\//g, serverBase); // Make semi-absolute links to be truely absolute // we do this just to standardize so that special replacements knows what // to expect html = html.replace(/((href|src|background)=[\'\"])\/+/ig, '$1' + serverBase); html = this.outwardSpecialReplacements(html); html = this.fixRelativeLinks(html); if ( this.config.sevenBitClean ) { html = html.replace(/[^ -~\r\n\t]/g, function(c) { return (c != Xinha.cc) ? '&#'+c.charCodeAt(0)+';' : c; }); } //prevent execution of JavaScript (Ticket #685) html = html.replace(/(<script[^>]*((type=[\"\']text\/)|(language=[\"\'])))(freezescript)/gi,"$1javascript"); // If in fullPage mode, strip the coreCSS if(this.config.fullPage) { html = Xinha.stripCoreCSS(html); } if (typeof this.config.outwardHtml == 'function' ) { html = this.config.outwardHtml(html); } return html; }; /** Performs various transformations of the HTML to be edited * Plugins can provide their own, additional transformations by defining a plugin.prototype.inwardHtml() implematation, * which is called by this function * * @private * @see Xinha#outwardHtml * @param {String} html * @returns {String} transformed HTML */ Xinha.prototype.inwardHtml = function(html) { for ( var i in this.plugins ) { var plugin = this.plugins[i].instance; if ( plugin && typeof plugin.inwardHtml == "function" ) { html = plugin.inwardHtml(html); } } // Both IE and Gecko use strike instead of del (#523) html = html.replace(/<(\/?)del(\s|>|\/)/ig, "<$1strike$2"); // disable inline event handle inside Xinha iframe html = html.replace(/(<[^>]*on(click|mouse(over|out|up|down))=["'])/gi,'$1if(window.parent &amp;&amp; window.parent.Xinha){return false}'); html = this.inwardSpecialReplacements(html); html = html.replace(/(<script[^>]*((type=[\"\']text\/)|(language=[\"\'])))(javascript)/gi,"$1freezescript"); // For IE's sake, make any URLs that are semi-absolute (="/....") to be // truely absolute var nullRE = new RegExp('((href|src|background)=[\'"])/+', 'gi'); html = html.replace(nullRE, '$1' + location.href.replace(/(https?:\/\/[^\/]*)\/.*/, '$1') + '/'); html = this.fixRelativeLinks(html); // If in fullPage mode, add the coreCSS if(this.config.fullPage) { html = Xinha.addCoreCSS(html); } if (typeof this.config.inwardHtml == 'function' ) { html = this.config.inwardHtml(html); } return html; }; /** Apply the replacements defined in Xinha.Config.specialReplacements * * @private * @see Xinha#inwardSpecialReplacements * @param {String} html * @returns {String} transformed HTML */ Xinha.prototype.outwardSpecialReplacements = function(html) { for ( var i in this.config.specialReplacements ) { var from = this.config.specialReplacements[i]; var to = i; // why are declaring a new variable here ? Seems to be better to just do : for (var to in config) // prevent iterating over wrong type if ( typeof from.replace != 'function' || typeof to.replace != 'function' ) { continue; } // alert('out : ' + from + '=>' + to); var reg = new RegExp(Xinha.escapeStringForRegExp(from), 'g'); html = html.replace(reg, to.replace(/\$/g, '$$$$')); //html = html.replace(from, to); } return html; }; /** Apply the replacements defined in Xinha.Config.specialReplacements * * @private * @see Xinha#outwardSpecialReplacements * @param {String} html * @returns {String} transformed HTML */ Xinha.prototype.inwardSpecialReplacements = function(html) { // alert("inward"); for ( var i in this.config.specialReplacements ) { var from = i; // why are declaring a new variable here ? Seems to be better to just do : for (var from in config) var to = this.config.specialReplacements[i]; // prevent iterating over wrong type if ( typeof from.replace != 'function' || typeof to.replace != 'function' ) { continue; } // alert('in : ' + from + '=>' + to); // // html = html.replace(reg, to); // html = html.replace(from, to); var reg = new RegExp(Xinha.escapeStringForRegExp(from), 'g'); html = html.replace(reg, to.replace(/\$/g, '$$$$')); // IE uses doubled dollar signs to escape backrefs, also beware that IE also implements $& $_ and $' like perl. } return html; }; /** Transforms the paths in src & href attributes * * @private * @see Xinha.Config#expandRelativeUrl * @see Xinha.Config#stripSelfNamedAnchors * @see Xinha.Config#stripBaseHref * @see Xinha.Config#baseHref * @param {String} html * @returns {String} transformed HTML */ Xinha.prototype.fixRelativeLinks = function(html) { if ( typeof this.config.expandRelativeUrl != 'undefined' && this.config.expandRelativeUrl ) { if (html == null) { return ""; } var src = html.match(/(src|href)="([^"]*)"/gi); var b = document.location.href; if ( src ) { var url,url_m,relPath,base_m,absPath; for ( var i=0;i<src.length;++i ) { url = src[i].match(/(src|href)="([^"]*)"/i); url_m = url[2].match( /\.\.\//g ); if ( url_m ) { relPath = new RegExp( "(.*?)(([^\/]*\/){"+ url_m.length+"})[^\/]*$" ); base_m = b.match( relPath ); absPath = url[2].replace(/(\.\.\/)*/,base_m[1]); html = html.replace( new RegExp(Xinha.escapeStringForRegExp(url[2])),absPath ); } } } } if ( typeof this.config.stripSelfNamedAnchors != 'undefined' && this.config.stripSelfNamedAnchors ) { var stripRe = new RegExp("((href|src|background)=\")("+Xinha.escapeStringForRegExp(window.unescape(document.location.href.replace(/&/g,'&amp;'))) + ')([#?][^\'" ]*)', 'g'); html = html.replace(stripRe, '$1$4'); } if ( typeof this.config.stripBaseHref != 'undefined' && this.config.stripBaseHref ) { var baseRe = null; if ( typeof this.config.baseHref != 'undefined' && this.config.baseHref !== null ) { baseRe = new RegExp( "((href|src|background|action)=\")(" + Xinha.escapeStringForRegExp(this.config.baseHref.replace(/([^\/]\/)(?=.+\.)[^\/]*$/, "$1")) + ")", 'g' ); html = html.replace(baseRe, '$1'); } baseRe = new RegExp( "((href|src|background|action)=\")(" + Xinha.escapeStringForRegExp(document.location.href.replace( /^(https?:\/\/[^\/]*)(.*)/, '$1' )) + ")", 'g' ); html = html.replace(baseRe, '$1'); } return html; }; /** retrieve the HTML (fastest version, but uses innerHTML) * * @private * @returns {String} HTML content */ Xinha.prototype.getInnerHTML = function() { if ( !this._doc.body ) { return ''; } var html = ""; switch ( this._editMode ) { case "wysiwyg": if ( !this.config.fullPage ) { // return this._doc.body.innerHTML; html = this._doc.body.innerHTML; } else { html = this.doctype + "\n" + this._doc.documentElement.innerHTML; } break; case "textmode" : html = this._textArea.value; break; default: alert("Mode <" + this._editMode + "> not defined!"); return false; } return html; }; /** Completely change the HTML inside * * @private * @param {String} html new content, should have been run through inwardHtml() first */ Xinha.prototype.setHTML = function(html) { if ( !this.config.fullPage ) { this._doc.body.innerHTML = html; } else { this.setFullHTML(html); } this._textArea.value = html; }; /** sets the given doctype (useful only when config.fullPage is true) * * @private * @param {String} doctype */ Xinha.prototype.setDoctype = function(doctype) { this.doctype = doctype; }; /*************************************************** * Category: UTILITY FUNCTIONS ***************************************************/ /** Variable used to pass the object to the popup editor window. * @FIXME: Is this in use? * @deprecated * @private * @type {Object} */ Xinha._object = null; /** Arrays are identified as "object" in typeof calls. Adding this tag to the Array prototype allows to distinguish between the two */ Array.prototype.isArray = true; /** RegExps are identified as "object" in typeof calls. Adding this tag to the RegExp prototype allows to distinguish between the two */ RegExp.prototype.isRegExp = true; /** function that returns a clone of the given object * * @private * @param {Object} obj * @returns {Object} cloned object */ Xinha.cloneObject = function(obj) { if ( !obj ) { return null; } var newObj = obj.isArray ? [] : {}; // check for function and RegExp objects (as usual, IE is fucked up) if ( obj.constructor.toString().match( /\s*function Function\(/ ) || typeof obj == 'function' ) { newObj = obj; // just copy reference to it } else if ( obj.isRegExp ) { newObj = eval( obj.toString() ); //see no way without eval } else { for ( var n in obj ) { var node = obj[n]; if ( typeof node == 'object' ) { newObj[n] = Xinha.cloneObject(node); } else { newObj[n] = node; } } } return newObj; }; /** Extend one class from another, that is, make a sub class. * This manner of doing it was probably first devised by Kevin Lindsey * * http://kevlindev.com/tutorials/javascript/inheritance/index.htm * * It has subsequently been used in one form or another by various toolkits * such as the YUI. * * I make no claim as to understanding it really, but it works. * * Example Usage: * {{{ * ------------------------------------------------------------------------- // ========= MAKING THE INITIAL SUPER CLASS =========== document.write("<h1>Superclass Creation And Test</h1>"); function Vehicle(name, sound) { this.name = name; this.sound = sound } Vehicle.prototype.pressHorn = function() { document.write(this.name + ': ' + this.sound + '<br/>'); } var Bedford = new Vehicle('Bedford Van', 'Honk Honk'); Bedford.pressHorn(); // Vehicle::pressHorn() is defined // ========= MAKING A SUBCLASS OF A SUPER CLASS ========= document.write("<h1>Subclass Creation And Test</h1>"); // Make the sub class constructor first Car = function(name) { // This is how we call the parent's constructor, note that // we are using Car.parent.... not "this", we can't use this. Car.parentConstructor.call(this, name, 'Toot Toot'); } // Remember the subclass comes first, then the base class, you are extending // Car with the methods and properties of Vehicle. Xinha.extend(Car, Vehicle); var MazdaMx5 = new Car('Mazda MX5'); MazdaMx5.pressHorn(); // Car::pressHorn() is inherited from Vehicle::pressHorn() // ========= ADDING METHODS TO THE SUB CLASS =========== document.write("<h1>Add Method to Sub Class And Test</h1>"); Car.prototype.isACar = function() { document.write(this.name + ": Car::isACar() is implemented, this is a car! <br/>"); this.pressHorn(); } MazdaMx5.isACar(); // Car::isACar() is defined as above try { Bedford.isACar(); } // Vehicle::isACar() is not defined, will throw this exception catch(e) { document.write("Bedford: Vehicle::onGettingCutOff() not implemented, this is not a car!<br/>"); } // ========= EXTENDING A METHOD (CALLING MASKED PARENT METHODS) =========== document.write("<h1>Extend/Override Inherited Method in Sub Class And Test</h1>"); Car.prototype.pressHorn = function() { document.write(this.name + ': I am going to press the horn... <br/>'); Car.superClass.pressHorn.call(this); } MazdaMx5.pressHorn(); // Car::pressHorn() Bedford.pressHorn(); // Vehicle::pressHorn() // ========= MODIFYING THE SUPERCLASS AFTER SUBCLASSING =========== document.write("<h1>Add New Method to Superclass And Test In Subclass</h1>"); Vehicle.prototype.startUp = function() { document.write(this.name + ": Vroooom <br/>"); } MazdaMx5.startUp(); // Cars get the prototype'd startUp() also. * ------------------------------------------------------------------------- * }}} * * @param subclass_constructor (optional) Constructor function for the subclass * @param superclass Constructor function for the superclass */ Xinha.extend = function(subClass, baseClass) { function inheritance() {} inheritance.prototype = baseClass.prototype; subClass.prototype = new inheritance(); subClass.prototype.constructor = subClass; subClass.parentConstructor = baseClass; subClass.superClass = baseClass.prototype; } /** Event Flushing * To try and work around memory leaks in the rather broken * garbage collector in IE, Xinha.flushEvents can be called * onunload, it will remove any event listeners (that were added * through _addEvent(s)) and clear any DOM-0 events. * @private * */ Xinha.flushEvents = function() { var x = 0; // @todo : check if Array.prototype.pop exists for every supported browsers var e = Xinha._eventFlushers.pop(); while ( e ) { try { if ( e.length == 3 ) { Xinha._removeEvent(e[0], e[1], e[2]); x++; } else if ( e.length == 2 ) { e[0]['on' + e[1]] = null; e[0]._xinha_dom0Events[e[1]] = null; x++; } } catch(ex) { // Do Nothing } e = Xinha._eventFlushers.pop(); } /* // This code is very agressive, and incredibly slow in IE, so I've disabled it. if(document.all) { for(var i = 0; i < document.all.length; i++) { for(var j in document.all[i]) { if(/^on/.test(j) && typeof document.all[i][j] == 'function') { document.all[i][j] = null; x++; } } } } */ // alert('Flushed ' + x + ' events.'); }; /** Holds the events to be flushed * @type Array */ Xinha._eventFlushers = []; if ( document.addEventListener ) { /** adds an event listener for the specified element and event type * * @public * @see Xinha#_addEvents * @see Xinha#addDom0Event * @see Xinha#prependDom0Event * @param {DomNode} el the DOM element the event should be attached to * @param {String} evname the name of the event to listen for (without leading "on") * @param {function} func the function to be called when the event is fired */ Xinha._addEvent = function(el, evname, func) { el.addEventListener(evname, func, false); Xinha._eventFlushers.push([el, evname, func]); }; /** removes an event listener previously added * * @public * @see Xinha#_removeEvents * @param {DomNode} el the DOM element the event should be removed from * @param {String} evname the name of the event the listener should be removed from (without leading "on") * @param {function} func the function to be removed */ Xinha._removeEvent = function(el, evname, func) { el.removeEventListener(evname, func, false); }; /** stops bubbling of the event, if no further listeners should be triggered * * @public * @param {event} ev the event to be stopped */ Xinha._stopEvent = function(ev) { ev.preventDefault(); ev.stopPropagation(); }; } /** same as above, for IE * */ else if ( document.attachEvent ) { Xinha._addEvent = function(el, evname, func) { el.attachEvent("on" + evname, func); Xinha._eventFlushers.push([el, evname, func]); }; Xinha._removeEvent = function(el, evname, func) { el.detachEvent("on" + evname, func); }; Xinha._stopEvent = function(ev) { try { ev.cancelBubble = true; ev.returnValue = false; } catch (ex) { // Perhaps we could try here to stop the window.event // window.event.cancelBubble = true; // window.event.returnValue = false; } }; } else { Xinha._addEvent = function(el, evname, func) { alert('_addEvent is not supported'); }; Xinha._removeEvent = function(el, evname, func) { alert('_removeEvent is not supported'); }; Xinha._stopEvent = function(ev) { alert('_stopEvent is not supported'); }; } /** add several events at once to one element * * @public * @see Xinha#_addEvent * @param {DomNode} el the DOM element the event should be attached to * @param {Array} evs the names of the event to listen for (without leading "on") * @param {function} func the function to be called when the event is fired */ Xinha._addEvents = function(el, evs, func) { for ( var i = evs.length; --i >= 0; ) { Xinha._addEvent(el, evs[i], func); } }; /** remove several events at once to from element * * @public * @see Xinha#_removeEvent * @param {DomNode} el the DOM element the events should be remove from * @param {Array} evs the names of the events the listener should be removed from (without leading "on") * @param {function} func the function to be removed */ Xinha._removeEvents = function(el, evs, func) { for ( var i = evs.length; --i >= 0; ) { Xinha._removeEvent(el, evs[i], func); } }; /** Adds a function that is executed in the moment the DOM is ready, but as opposed to window.onload before images etc. have been loaded * http://dean.edwards.name/weblog/2006/06/again/ * IE part from jQuery * @public * @author Dean Edwards/Matthias Miller/ John Resig / Diego Perini * @param {Function} func the function to be executed * @param {Window} scope the window that is listened to */ Xinha.addOnloadHandler = function (func, scope) { scope = scope ? scope : window; var init = function () { // quit if this function has already been called if (arguments.callee.done) { return; } // flag this function so we don't do the same thing twice arguments.callee.done = true; // kill the timer if (Xinha.onloadTimer) { clearInterval(Xinha.onloadTimer); } func(); }; if (Xinha.is_ie) { // ensure firing before onload, // maybe late but safe also for iframes document.attachEvent("onreadystatechange", function(){ if ( document.readyState === "complete" ) { document.detachEvent( "onreadystatechange", arguments.callee ); init(); } }); if ( document.documentElement.doScroll && typeof window.frameElement === "undefined" ) (function(){ if (arguments.callee.done) return; try { // If IE is used, use the trick by Diego Perini // http://javascript.nwbox.com/IEContentLoaded/ document.documentElement.doScroll("left"); } catch( error ) { setTimeout( arguments.callee, 0 ); return; } // and execute any waiting functions init(); })(); } else if (/applewebkit|KHTML/i.test(navigator.userAgent) ) /* Safari/WebKit/KHTML */ { Xinha.onloadTimer = scope.setInterval(function() { if (/loaded|complete/.test(scope.document.readyState)) { init(); // call the onload handler } }, 10); } else /* for Mozilla/Opera9 */ { scope.document.addEventListener("DOMContentLoaded", init, false); } Xinha._addEvent(scope, 'load', init); // incase anything went wrong }; /** * Adds a standard "DOM-0" event listener to an element. * The DOM-0 events are those applied directly as attributes to * an element - eg element.onclick = stuff; * * By using this function instead of simply overwriting any existing * DOM-0 event by the same name on the element it will trigger as well * as the existing ones. Handlers are triggered one after the other * in the order they are added. * * Remember to return true/false from your handler, this will determine * whether subsequent handlers will be triggered (ie that the event will * continue or be canceled). * * @public * @see Xinha#_addEvent * @see Xinha#prependDom0Event * @param {DomNode} el the DOM element the event should be attached to * @param {String} ev the name of the event to listen for (without leading "on") * @param {function} fn the function to be called when the event is fired */ Xinha.addDom0Event = function(el, ev, fn) { Xinha._prepareForDom0Events(el, ev); el._xinha_dom0Events[ev].unshift(fn); }; /** See addDom0Event, the difference is that handlers registered using * prependDom0Event will be triggered before existing DOM-0 events of the * same name on the same element. * * @public * @see Xinha#_addEvent * @see Xinha#addDom0Event * @param {DomNode} the DOM element the event should be attached to * @param {String} the name of the event to listen for (without leading "on") * @param {function} the function to be called when the event is fired */ Xinha.prependDom0Event = function(el, ev, fn) { Xinha._prepareForDom0Events(el, ev); el._xinha_dom0Events[ev].push(fn); }; Xinha.getEvent = function(ev) { return ev || window.event; }; /** * Prepares an element to receive more than one DOM-0 event handler * when handlers are added via addDom0Event and prependDom0Event. * * @private */ Xinha._prepareForDom0Events = function(el, ev) { // Create a structure to hold our lists of event handlers if ( typeof el._xinha_dom0Events == 'undefined' ) { el._xinha_dom0Events = {}; Xinha.freeLater(el, '_xinha_dom0Events'); } // Create a list of handlers for this event type if ( typeof el._xinha_dom0Events[ev] == 'undefined' ) { el._xinha_dom0Events[ev] = [ ]; if ( typeof el['on'+ev] == 'function' ) { el._xinha_dom0Events[ev].push(el['on'+ev]); } // Make the actual event handler, which runs through // each of the handlers in the list and executes them // in the correct context. el['on'+ev] = function(event) { var a = el._xinha_dom0Events[ev]; // call previous submit methods if they were there. var allOK = true; for ( var i = a.length; --i >= 0; ) { // We want the handler to be a member of the form, not the array, so that "this" will work correctly el._xinha_tempEventHandler = a[i]; if ( el._xinha_tempEventHandler(event) === false ) { el._xinha_tempEventHandler = null; allOK = false; break; } el._xinha_tempEventHandler = null; } return allOK; }; Xinha._eventFlushers.push([el, ev]); } }; Xinha.prototype.notifyOn = function(ev, fn) { if ( typeof this._notifyListeners[ev] == 'undefined' ) { this._notifyListeners[ev] = []; Xinha.freeLater(this, '_notifyListeners'); } this._notifyListeners[ev].push(fn); }; Xinha.prototype.notifyOf = function(ev, args) { if ( this._notifyListeners[ev] ) { for ( var i = 0; i < this._notifyListeners[ev].length; i++ ) { this._notifyListeners[ev][i](ev, args); } } }; /** List of tag names that are defined as block level elements in HTML * * @private * @see Xinha#isBlockElement * @type {String} */ Xinha._blockTags = " body form textarea fieldset ul ol dl li div " + "p h1 h2 h3 h4 h5 h6 quote pre table thead " + "tbody tfoot tr td th iframe address blockquote title meta link style head "; /** Checks if one element is in the list of elements that are defined as block level elements in HTML * * @param {DomNode} el The DOM element to check * @returns {Boolean} */ Xinha.isBlockElement = function(el) { return el && el.nodeType == 1 && (Xinha._blockTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); }; /** List of tag names that are allowed to contain a paragraph * * @private * @see Xinha#isParaContainer * @type {String} */ Xinha._paraContainerTags = " body td th caption fieldset div "; /** Checks if one element is in the list of elements that are allowed to contain a paragraph in HTML * * @param {DomNode} el The DOM element to check * @returns {Boolean} */ Xinha.isParaContainer = function(el) { return el && el.nodeType == 1 && (Xinha._paraContainerTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); }; /** These are all the tags for which the end tag is not optional or forbidden, taken from the list at: * http: www.w3.org/TR/REC-html40/index/elements.html * * @private * @see Xinha#needsClosingTag * @type String */ Xinha._closingTags = " a abbr acronym address applet b bdo big blockquote button caption center cite code del dfn dir div dl em fieldset font form frameset h1 h2 h3 h4 h5 h6 i iframe ins kbd label legend map menu noframes noscript object ol optgroup pre q s samp script select small span strike strong style sub sup table textarea title tt u ul var "; /** Checks if one element is in the list of elements for which the end tag is not optional or forbidden in HTML * * @param {DomNode} el The DOM element to check * @returns {Boolean} */ Xinha.needsClosingTag = function(el) { return el && el.nodeType == 1 && (Xinha._closingTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); }; /** Performs HTML encoding of some given string (converts HTML special characters to entities) * * @param {String} str The unencoded input * @returns {String} The encoded output */ Xinha.htmlEncode = function(str) { if (!str) { return ''; } if ( typeof str.replace == 'undefined' ) { str = str.toString(); } // we don't need regexp for that, but.. so be it for now. str = str.replace(/&/ig, "&amp;"); str = str.replace(/</ig, "&lt;"); str = str.replace(/>/ig, "&gt;"); str = str.replace(/\xA0/g, "&nbsp;"); // Decimal 160, non-breaking-space str = str.replace(/\x22/g, "&quot;"); // \x22 means '"' -- we use hex reprezentation so that we don't disturb // JS compressors (well, at least mine fails.. ;) return str; }; /** Strips host-part of URL which is added by browsers to links relative to server root * * @param {String} string * @returns {String} */ Xinha.prototype.stripBaseURL = function(string) { if ( this.config.baseHref === null || !this.config.stripBaseHref ) { return string; } var baseurl = this.config.baseHref.replace(/^(https?:\/\/[^\/]+)(.*)$/, '$1'); var basere = new RegExp(baseurl); return string.replace(basere, ""); }; if (typeof String.prototype.trim != 'function') { /** Removes whitespace from beginning and end of a string. Custom implementation for JS engines that don't support it natively * * @returns {String} */ String.prototype.trim = function() { return this.replace(/^\s+/, '').replace(/\s+$/, ''); }; } /** Creates a rgb-style rgb(r,g,b) color from a (24bit) number * * @param {Integer} * @returns {String} rgb(r,g,b) color definition */ Xinha._makeColor = function(v) { if ( typeof v != "number" ) { // already in rgb (hopefully); IE doesn't get here. return v; } // IE sends number; convert to rgb. var r = v & 0xFF; var g = (v >> 8) & 0xFF; var b = (v >> 16) & 0xFF; return "rgb(" + r + "," + g + "," + b + ")"; }; /** Returns hexadecimal color representation from a number or a rgb-style color. * * @param {String|Integer} v rgb(r,g,b) or 24bit color definition * @returns {String} #RRGGBB color definition */ Xinha._colorToRgb = function(v) { if ( !v ) { return ''; } var r,g,b; // @todo: why declaring this function here ? This needs to be a public methode of the object Xinha._colorToRgb // returns the hex representation of one byte (2 digits) function hex(d) { return (d < 16) ? ("0" + d.toString(16)) : d.toString(16); } if ( typeof v == "number" ) { // we're talking to IE here r = v & 0xFF; g = (v >> 8) & 0xFF; b = (v >> 16) & 0xFF; return "#" + hex(r) + hex(g) + hex(b); } if ( v.substr(0, 3) == "rgb" ) { // in rgb(...) form -- Mozilla var re = /rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/; if ( v.match(re) ) { r = parseInt(RegExp.$1, 10); g = parseInt(RegExp.$2, 10); b = parseInt(RegExp.$3, 10); return "#" + hex(r) + hex(g) + hex(b); } // doesn't match RE?! maybe uses percentages or float numbers // -- FIXME: not yet implemented. return null; } if ( v.substr(0, 1) == "#" ) { // already hex rgb (hopefully :D ) return v; } // if everything else fails ;) return null; }; /** Modal popup dialogs * * @param {String} url URL to the popup dialog * @param {Function} action A function that receives one value; this function will get called * after the dialog is closed, with the return value of the dialog. * @param {Mixed} init A variable that is passed to the popup window to pass arbitrary data */ Xinha.prototype._popupDialog = function(url, action, init) { Dialog(this.popupURL(url), action, init); }; /** Creates a path in the form _editor_url + "plugins/" + plugin + "/img/" + file * * @deprecated * @param {String} file Name of the image * @param {String} plugin optional If omitted, simply _editor_url + file is returned * @returns {String} */ Xinha.prototype.imgURL = function(file, plugin) { if ( typeof plugin == "undefined" ) { return _editor_url + file; } else { return Xinha.getPluginDir(plugin) + "/img/" + file; } }; /** Creates a path * * @deprecated * @param {String} file Name of the popup * @returns {String} */ Xinha.prototype.popupURL = function(file) { var url = ""; if ( file.match(/^plugin:\/\/(.*?)\/(.*)/) ) { var plugin = RegExp.$1; var popup = RegExp.$2; if ( !/\.(html?|php)$/.test(popup) ) { popup += ".html"; } url = Xinha.getPluginDir(plugin) + "/popups/" + popup; } else if ( file.match(/^\/.*?/) || file.match(/^https?:\/\//)) { url = file; } else { url = _editor_url + this.config.popupURL + file; } return url; }; /** FIX: Internet Explorer returns an item having the _name_ equal to the given * id, even if it's not having any id. This way it can return a different form * field, even if it's not a textarea. This workarounds the problem by * specifically looking to search only elements having a certain tag name. * @param {String} tag The tag name to limit the return to * @param {String} id * @returns {DomNode} */ Xinha.getElementById = function(tag, id) { var el, i, objs = document.getElementsByTagName(tag); for ( i = objs.length; --i >= 0 && (el = objs[i]); ) { if ( el.id == id ) { return el; } } return null; }; /** Use some CSS trickery to toggle borders on tables * @returns {Boolean} always true */ Xinha.prototype._toggleBorders = function() { var tables = this._doc.getElementsByTagName('TABLE'); if ( tables.length !== 0 ) { if ( !this.borders ) { this.borders = true; } else { this.borders = false; } for ( var i=0; i < tables.length; i++ ) { if ( this.borders ) { Xinha._addClass(tables[i], 'htmtableborders'); } else { Xinha._removeClass(tables[i], 'htmtableborders'); } } } return true; }; /** Adds the styles for table borders to the iframe during generation * * @private * @see Xinha#stripCoreCSS * @param {String} html optional * @returns {String} html HTML with added styles or only styles if html omitted */ Xinha.addCoreCSS = function(html) { var coreCSS = "<style title=\"XinhaInternalCSS\" type=\"text/css\">" + ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;}\n" + "html, body { border: 0px; } \n" + "body { background-color: #ffffff; } \n" + "img, hr { cursor: default } \n" + "</style>\n"; if( html && /<head>/i.test(html)) { return html.replace(/<head>/i, '<head>' + coreCSS); } else if ( html) { return coreCSS + html; } else { return coreCSS; } }; /** Allows plugins to add a stylesheet for internal use to the edited document that won't appear in the HTML output * * @see Xinha#stripCoreCSS * @param {String} stylesheet URL of the styleshett to be added */ Xinha.prototype.addEditorStylesheet = function (stylesheet) { var style = this._doc.createElement("link"); style.rel = 'stylesheet'; style.type = 'text/css'; style.title = 'XinhaInternalCSS'; style.href = stylesheet; this._doc.getElementsByTagName("HEAD")[0].appendChild(style); }; /** Remove internal styles * * @private * @see Xinha#addCoreCSS * @param {String} html * @returns {String} */ Xinha.stripCoreCSS = function(html) { return html.replace(/<style[^>]+title="XinhaInternalCSS"(.|\n)*?<\/style>/ig, '').replace(/<link[^>]+title="XinhaInternalCSS"(.|\n)*?>/ig, ''); }; /** Removes one CSS class (that is one of possible more parts * separated by spaces) from a given element * * @see Xinha#_removeClasses * @param {DomNode} el The DOM element the class will be removed from * @param {String} className The class to be removed */ Xinha._removeClass = function(el, className) { if ( ! ( el && el.className ) ) { return; } var cls = el.className.split(" "); var ar = []; for ( var i = cls.length; i > 0; ) { if ( cls[--i] != className ) { ar[ar.length] = cls[i]; } } el.className = ar.join(" "); }; /** Adds one CSS class to a given element (that is, it expands its className property by the given string, * separated by a space) * * @see Xinha#addClasses * @param {DomNode} el The DOM element the class will be added to * @param {String} className The class to be added */ Xinha._addClass = function(el, className) { // remove the class first, if already there Xinha._removeClass(el, className); el.className += " " + className; }; /** Adds CSS classes to a given element (that is, it expands its className property by the given string, * separated by a space, thereby checking that no class is doubly added) * * @see Xinha#addClass * @param {DomNode} el The DOM element the classes will be added to * @param {String} classes The classes to be added */ Xinha.addClasses = function(el, classes) { if ( el !== null ) { var thiers = el.className.trim().split(' '); var ours = classes.split(' '); for ( var x = 0; x < ours.length; x++ ) { var exists = false; for ( var i = 0; exists === false && i < thiers.length; i++ ) { if ( thiers[i] == ours[x] ) { exists = true; } } if ( exists === false ) { thiers[thiers.length] = ours[x]; } } el.className = thiers.join(' ').trim(); } }; /** Removes CSS classes (that is one or more of possibly several parts * separated by spaces) from a given element * * @see Xinha#_removeClasses * @param {DomNode} el The DOM element the class will be removed from * @param {String} className The class to be removed */ Xinha.removeClasses = function(el, classes) { var existing = el.className.trim().split(); var new_classes = []; var remove = classes.trim().split(); for ( var i = 0; i < existing.length; i++ ) { var found = false; for ( var x = 0; x < remove.length && !found; x++ ) { if ( existing[i] == remove[x] ) { found = true; } } if ( !found ) { new_classes[new_classes.length] = existing[i]; } } return new_classes.join(' '); }; /** Alias of Xinha._addClass() * @see Xinha#_addClass */ Xinha.addClass = Xinha._addClass; /** Alias of Xinha.Xinha._removeClass() * @see Xinha#_removeClass */ Xinha.removeClass = Xinha._removeClass; /** Alias of Xinha.addClasses() * @see Xinha#addClasses */ Xinha._addClasses = Xinha.addClasses; /** Alias of Xinha.removeClasses() * @see Xinha#removeClasses */ Xinha._removeClasses = Xinha.removeClasses; /** Checks if one element has set the given className * * @param {DomNode} el The DOM element to check * @param {String} className The class to be looked for * @returns {Boolean} */ Xinha._hasClass = function(el, className) { if ( ! ( el && el.className ) ) { return false; } var cls = el.className.split(" "); for ( var i = cls.length; i > 0; ) { if ( cls[--i] == className ) { return true; } } return false; }; /** * Use XMLHTTPRequest to post some data back to the server and do something * with the response (asyncronously!), this is used by such things as the tidy * functions * @param {String} url The address for the HTTPRequest * @param {Object} data The data to be passed to the server like {name:"value"} * @param {Function} success A function that is called when an answer is * received from the server with the responseText as argument. * @param {Function} failure A function that is called when we fail to receive * an answer from the server. We pass it the request object. */ /** mod_security (an apache module which scans incoming requests for potential hack attempts) * has a rule which triggers when it gets an incoming Content-Type with a charset * see ticket:1028 to try and work around this, if we get a failure in a postback * then Xinha._postback_send_charset will be set to false and the request tried again (once) * @type Boolean * @private */ // // // Xinha._postback_send_charset = true; /** Use XMLHTTPRequest to send some some data to the server and do something * with the getback (asyncronously!) * @param {String} url The address for the HTTPRequest * @param {Function} success A function that is called when an answer is * received from the server with the responseText as argument. * @param {Function} failure A function that is called when we fail to receive * an answer from the server. We pass it the request object. */ Xinha._postback = function(url, data, success, failure) { var req = null; req = Xinha.getXMLHTTPRequestObject(); var content = ''; if (typeof data == 'string') { content = data; } else if(typeof data == "object") { for ( var i in data ) { content += (content.length ? '&' : '') + i + '=' + encodeURIComponent(data[i]); } } function callBack() { if ( req.readyState == 4 ) { if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) { if ( typeof success == 'function' ) { success(req.responseText, req); } } else if(Xinha._postback_send_charset) { Xinha._postback_send_charset = false; Xinha._postback(url,data,success, failure); } else if (typeof failure == 'function') { failure(req); } else { alert('An error has occurred: ' + req.statusText + '\nURL: ' + url); } } } req.onreadystatechange = callBack; req.open('POST', url, true); req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'+(Xinha._postback_send_charset ? '; charset=UTF-8' : '')); req.send(content); }; /** Use XMLHTTPRequest to receive some data from the server and do something * with the it (asyncronously!) * @param {String} url The address for the HTTPRequest * @param {Function} success A function that is called when an answer is * received from the server with the responseText as argument. * @param {Function} failure A function that is called when we fail to receive * an answer from the server. We pass it the request object. */ Xinha._getback = function(url, success, failure) { var req = null; req = Xinha.getXMLHTTPRequestObject(); function callBack() { if ( req.readyState == 4 ) { if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) { success(req.responseText, req); } else if (typeof failure == 'function') { failure(req); } else { alert('An error has occurred: ' + req.statusText + '\nURL: ' + url); } } } req.onreadystatechange = callBack; req.open('GET', url, true); req.send(null); }; Xinha.ping = function(url, successHandler, failHandler) { var req = null; req = Xinha.getXMLHTTPRequestObject(); function callBack() { if ( req.readyState == 4 ) { if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) { if (successHandler) { successHandler(req); } } else { if (failHandler) { failHandler(req); } } } } // Opera seems to have some problems mixing HEAD requests with GET requests. // The GET is slower, so it's a net slowdown for Opera, but it keeps things // from breaking. var method = 'GET'; req.onreadystatechange = callBack; req.open(method, url, true); req.send(null); }; /** Use XMLHTTPRequest to receive some data from the server syncronously * @param {String} url The address for the HTTPRequest */ Xinha._geturlcontent = function(url, returnXML) { var req = null; req = Xinha.getXMLHTTPRequestObject(); // Synchronous! req.open('GET', url, false); req.send(null); if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) { return (returnXML) ? req.responseXML : req.responseText; } else { return ''; } }; // Unless somebody already has, make a little function to debug things if (typeof dumpValues == 'undefined') { dumpValues = function(o) { var s = ''; for (var prop in o) { if (window.console && typeof window.console.log == 'function') { if (typeof console.firebug != 'undefined') { console.log(o); } else { console.log(prop + ' = ' + o[prop] + '\n'); } } else { s += prop + ' = ' + o[prop] + '\n'; } } if (s) { if (document.getElementById('errors')) { document.getElementById('errors').value += s; } else { var x = window.open("", "debugger"); x.document.write('<pre>' + s + '</pre>'); } } }; } if ( !Array.prototype.contains ) { /** Walks through an array and checks if the specified item exists in it * @param {String} needle The string to search for * @returns {Boolean} True if item found, false otherwise */ Array.prototype.contains = function(needle) { var haystack = this; for ( var i = 0; i < haystack.length; i++ ) { if ( needle == haystack[i] ) { return true; } } return false; }; } if ( !Array.prototype.indexOf ) { /** Walks through an array and, if the specified item exists in it, returns the position * @param {String} needle The string to search for * @returns {Integer|null} Index position if item found, null otherwise */ Array.prototype.indexOf = function(needle) { var haystack = this; for ( var i = 0; i < haystack.length; i++ ) { if ( needle == haystack[i] ) { return i; } } return null; }; } if ( !Array.prototype.append ) { /** Adds an item to an array * @param {Mixed} a Item to add * @returns {Array} The array including the newly added item */ Array.prototype.append = function(a) { for ( var i = 0; i < a.length; i++ ) { this.push(a[i]); } return this; }; } /** Executes a provided function once per array element. * Custom implementation for JS engines that don't support it natively * @source http://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/Array/ForEach * @param {Function} fn Function to execute for each element * @param {Object} thisObject Object to use as this when executing callback. */ if (!Array.prototype.forEach) { Array.prototype.forEach = function(fn /*, thisObject*/) { var len = this.length; if (typeof fn != "function") { throw new TypeError(); } var thisObject = arguments[1]; for (var i = 0; i < len; i++) { if (i in this) { fn.call(thisObject, this[i], i, this); } } }; } /** Returns all elements within a given class name inside an element * @type Array * @param {DomNode|document} el wherein to search * @param {Object} className */ Xinha.getElementsByClassName = function(el,className) { if (el.getElementsByClassName) { return Array.prototype.slice.call(el.getElementsByClassName(className)); } else { var els = el.getElementsByTagName('*'); var result = []; var classNames; for (var i=0;i<els.length;i++) { classNames = els[i].className.split(' '); if (classNames.contains(className)) { result.push(els[i]); } } return result; } }; /** Returns true if all elements of <em>a2</em> are also contained in <em>a1</em> (at least I think this is what it does) * @param {Array} a1 * @param {Array} a2 * @returns {Boolean} */ Xinha.arrayContainsArray = function(a1, a2) { var all_found = true; for ( var x = 0; x < a2.length; x++ ) { var found = false; for ( var i = 0; i < a1.length; i++ ) { if ( a1[i] == a2[x] ) { found = true; break; } } if ( !found ) { all_found = false; break; } } return all_found; }; /** Walks through an array and applies a filter function to each item * @param {Array} a1 The array to filter * @param {Function} filterfn If this function returns true, the item is added to the new array * @returns {Array} Filtered array */ Xinha.arrayFilter = function(a1, filterfn) { var new_a = [ ]; for ( var x = 0; x < a1.length; x++ ) { if ( filterfn(a1[x]) ) { new_a[new_a.length] = a1[x]; } } return new_a; }; /** Converts a Collection object to an array * @param {Collection} collection The array to filter * @returns {Array} Array containing the item of collection */ Xinha.collectionToArray = function(collection) { try { return collection.length ? Array.prototype.slice.call(collection) : []; //Collection to Array } catch(e) { // In certain implementations (*cough* IE), you can't call slice on a // collection. We'll fallback to using the simple, non-native iterative // approach. } var array = [ ]; for ( var i = 0; i < collection.length; i++ ) { array.push(collection.item(i)); } return array; }; /** Index for Xinha.uniq function * @private */ Xinha.uniq_count = 0; /** Returns a string that is unique on the page * @param {String} prefix This string is prefixed to a running number * @returns {String} */ Xinha.uniq = function(prefix) { return prefix + Xinha.uniq_count++; }; // New language handling functions /** Load a language file. * This function should not be used directly, Xinha._lc will use it when necessary. * @private * @param {String} context Case sensitive context name, eg 'Xinha', 'TableOperations', ... * @returns {Object} */ Xinha._loadlang = function(context,url) { var lang; if ( typeof _editor_lcbackend == "string" ) { //use backend url = _editor_lcbackend; url = url.replace(/%lang%/, _editor_lang); url = url.replace(/%context%/, context); } else if (!url) { //use internal files if ( context != 'Xinha') { url = Xinha.getPluginDir(context)+"/lang/"+_editor_lang+".js"; } else { Xinha.setLoadingMessage("Loading language"); url = _editor_url+"lang/"+_editor_lang+".js"; } } var langData = Xinha._geturlcontent(url); if ( langData !== "" ) { try { eval('lang = ' + langData); } catch(ex) { alert('Error reading Language-File ('+url+'):\n'+Error.toString()); lang = {}; } } else { lang = {}; } return lang; }; /** Return a localised string. * @param {String} string English language string. It can also contain variables in the form "Some text with $variable=replaced text$". * This replaces $variable in "Some text with $variable" with "replaced text" * @param {String} context Case sensitive context name, eg 'Xinha' (default), 'TableOperations'... * @param {Object} replace Replace $variables in String, eg {foo: 'replaceText'} ($foo in string will be replaced by replaceText) */ Xinha._lc = function(string, context, replace) { var url,ret; if (typeof context == 'object' && context.url && context.context) { url = context.url + _editor_lang + ".js"; context = context.context; } var m = null; if (typeof string == 'string') { m = string.match(/\$(.*?)=(.*?)\$/g); } if (m) { if (!replace) { replace = {}; } for (var i = 0;i<m.length;i++) { var n = m[i].match(/\$(.*?)=(.*?)\$/); replace[n[1]] = n[2]; string = string.replace(n[0],'$'+n[1]); } } if ( _editor_lang == "en" ) { if ( typeof string == 'object' && string.string ) { ret = string.string; } else { ret = string; } } else { if ( typeof Xinha._lc_catalog == 'undefined' ) { Xinha._lc_catalog = [ ]; } if ( typeof context == 'undefined' ) { context = 'Xinha'; } if ( typeof Xinha._lc_catalog[context] == 'undefined' ) { Xinha._lc_catalog[context] = Xinha._loadlang(context,url); } var key; if ( typeof string == 'object' && string.key ) { key = string.key; } else if ( typeof string == 'object' && string.string ) { key = string.string; } else { key = string; } if ( typeof Xinha._lc_catalog[context][key] == 'undefined' ) { if ( context=='Xinha' ) { // Indicate it's untranslated if ( typeof string == 'object' && string.string ) { ret = string.string; } else { ret = string; } } else { //if string is not found and context is not Xinha try if it is in Xinha return Xinha._lc(string, 'Xinha', replace); } } else { ret = Xinha._lc_catalog[context][key]; } } if ( typeof string == 'object' && string.replace ) { replace = string.replace; } if ( typeof replace != "undefined" ) { for ( i in replace ) { ret = ret.replace('$'+i, replace[i]); } } return ret; }; /** Walks through the children of a given element and checks if any of the are visible (= not display:none) * @param {DomNode} el * @returns {Boolean} */ Xinha.hasDisplayedChildren = function(el) { var children = el.childNodes; for ( var i = 0; i < children.length; i++ ) { if ( children[i].tagName ) { if ( children[i].style.display != 'none' ) { return true; } } } return false; }; /** Load a javascript file by inserting it in the HEAD tag and eventually call a function when loaded * * Note that this method cannot be abstracted into browser specific files * because this method LOADS the browser specific files. Hopefully it should work for most * browsers as it is. * * @param {String} url Source url of the file to load * @param {Object} callback optional Callback function to launch once ready * @param {Object} scope optional Application scope for the callback function * @param {Object} bonus optional Arbitrary object send as a param to the callback function */ Xinha._loadback = function(url, callback, scope, bonus) { if ( document.getElementById(url) ) { return true; } var t = !Xinha.is_ie ? "onload" : 'onreadystatechange'; var s = document.createElement("script"); s.type = "text/javascript"; s.src = url; s.id = url; if ( callback ) { s[t] = function() { if (Xinha.is_ie && (!/loaded|complete/.test(window.event.srcElement.readyState))) { return; } callback.call(scope ? scope : this, bonus); s[t] = null; }; } document.getElementsByTagName("head")[0].appendChild(s); return false; }; /** Xinha's main loading function (see NewbieGuide) * @param {Array} editor_names * @param {Xinha.Config} default_config * @param {Array} plugin_names * @returns {Object} An object that contains references to all created editors indexed by the IDs of the textareas */ Xinha.makeEditors = function(editor_names, default_config, plugin_names) { if (!Xinha.isSupportedBrowser) { return; } if ( typeof default_config == 'function' ) { default_config = default_config(); } var editors = {}; var textarea; for ( var x = 0; x < editor_names.length; x++ ) { if ( typeof editor_names[x] == 'string' ) // the regular case, an id of a textarea { textarea = Xinha.getElementById('textarea', editor_names[x] ); if (!textarea) // the id may be specified for a textarea that is maybe on another page; we simply skip it and go on { editor_names[x] = null; continue; } } // make it possible to pass a reference instead of an id, for example from document.getElementsByTagName('textarea') else if ( typeof editor_names[x] == 'object' && editor_names[x].tagName && editor_names[x].tagName.toLowerCase() == 'textarea' ) { textarea = editor_names[x]; if ( !textarea.id ) // we'd like to have the textarea have an id { textarea.id = 'xinha_id_' + x; } } var editor = new Xinha(textarea, Xinha.cloneObject(default_config)); editor.registerPlugins(plugin_names); editors[textarea.id] = editor; } return editors; }; /** Another main loading function (see NewbieGuide) * @param {Object} editors As returned by Xinha.makeEditors() */ Xinha.startEditors = function(editors) { if (!Xinha.isSupportedBrowser) { return; } for ( var i in editors ) { if ( editors[i].generate ) { editors[i].generate(); } } }; /** Registers the loaded plugins with the editor * @private * @param {Array} plugin_names */ Xinha.prototype.registerPlugins = function(plugin_names) { if (!Xinha.isSupportedBrowser) { return; } if ( plugin_names ) { for ( var i = 0; i < plugin_names.length; i++ ) { this.setLoadingMessage(Xinha._lc('Register plugin $plugin', 'Xinha', {'plugin': plugin_names[i]})); this.registerPlugin(plugin_names[i]); } } }; /** Utility function to base64_encode some arbitrary data, uses the builtin btoa() if it exists (Moz) * @param {String} input * @returns {String} */ Xinha.base64_encode = function(input) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; do { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if ( isNaN(chr2) ) { enc3 = enc4 = 64; } else if ( isNaN(chr3) ) { enc4 = 64; } output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); } while ( i < input.length ); return output; }; /** Utility function to base64_decode some arbitrary data, uses the builtin atob() if it exists (Moz) * @param {String} input * @returns {String} */ Xinha.base64_decode = function(input) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; // remove all characters that are not A-Z, a-z, 0-9, +, /, or = input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do { enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if ( enc3 != 64 ) { output = output + String.fromCharCode(chr2); } if ( enc4 != 64 ) { output = output + String.fromCharCode(chr3); } } while ( i < input.length ); return output; }; /** Removes a node from the DOM * @param {DomNode} el The element to be removed * @returns {DomNode} The removed element */ Xinha.removeFromParent = function(el) { if ( !el.parentNode ) { return; } var pN = el.parentNode; return pN.removeChild(el); }; /** Checks if some element has a parent node * @param {DomNode} el * @returns {Boolean} */ Xinha.hasParentNode = function(el) { if ( el.parentNode ) { // When you remove an element from the parent in IE it makes the parent // of the element a document fragment. Moz doesn't. if ( el.parentNode.nodeType == 11 ) { return false; } return true; } return false; }; /** Detect the size of visible area * @param {Window} scope optional When calling from a popup window, pass its window object to get the values of the popup * @returns {Object} Object with Integer properties x and y */ Xinha.viewportSize = function(scope) { scope = (scope) ? scope : window; var x,y; if (scope.innerHeight) // all except Explorer { x = scope.innerWidth; y = scope.innerHeight; } else if (scope.document.documentElement && scope.document.documentElement.clientHeight) // Explorer 6 Strict Mode { x = scope.document.documentElement.clientWidth; y = scope.document.documentElement.clientHeight; } else if (scope.document.body) // other Explorers { x = scope.document.body.clientWidth; y = scope.document.body.clientHeight; } return {'x':x,'y':y}; }; /** Detect the size of the whole document * @param {Window} scope optional When calling from a popup window, pass its window object to get the values of the popup * @returns {Object} Object with Integer properties x and y */ Xinha.pageSize = function(scope) { scope = (scope) ? scope : window; var x,y; var test1 = scope.document.body.scrollHeight; //IE Quirks var test2 = scope.document.documentElement.scrollHeight; // IE Standard + Moz Here quirksmode.org errs! if (test1 > test2) { x = scope.document.body.scrollWidth; y = scope.document.body.scrollHeight; } else { x = scope.document.documentElement.scrollWidth; y = scope.document.documentElement.scrollHeight; } return {'x':x,'y':y}; }; /** Detect the current scroll position * @param {Window} scope optional When calling from a popup window, pass its window object to get the values of the popup * @returns {Object} Object with Integer properties x and y */ Xinha.prototype.scrollPos = function(scope) { scope = (scope) ? scope : window; var x,y; if (typeof scope.pageYOffset != 'undefined') // all except Explorer { x = scope.pageXOffset; y = scope.pageYOffset; } else if (scope.document.documentElement && typeof document.documentElement.scrollTop != 'undefined') // Explorer 6 Strict { x = scope.document.documentElement.scrollLeft; y = scope.document.documentElement.scrollTop; } else if (scope.document.body) // all other Explorers { x = scope.document.body.scrollLeft; y = scope.document.body.scrollTop; } return {'x':x,'y':y}; }; /** Calculate the top and left pixel position of an element in the DOM. * @param {DomNode} element HTML Element * @returns {Object} Object with Integer properties top and left */ Xinha.getElementTopLeft = function(element) { var curleft = 0; var curtop = 0; if (element.offsetParent) { curleft = element.offsetLeft; curtop = element.offsetTop; while (element = element.offsetParent) { curleft += element.offsetLeft; curtop += element.offsetTop; } } return { top:curtop, left:curleft }; }; /** Find left pixel position of an element in the DOM. * @param {DomNode} element HTML Element * @returns {Integer} */ Xinha.findPosX = function(obj) { var curleft = 0; if ( obj.offsetParent ) { return Xinha.getElementTopLeft(obj).left; } else if ( obj.x ) { curleft += obj.x; } return curleft; }; /** Find top pixel position of an element in the DOM. * @param {DomNode} element HTML Element * @returns {Integer} */ Xinha.findPosY = function(obj) { var curtop = 0; if ( obj.offsetParent ) { return Xinha.getElementTopLeft(obj).top; } else if ( obj.y ) { curtop += obj.y; } return curtop; }; Xinha.createLoadingMessages = function(xinha_editors) { if ( Xinha.loadingMessages || !Xinha.isSupportedBrowser ) { return; } Xinha.loadingMessages = []; for (var i=0;i<xinha_editors.length;i++) { if (!document.getElementById(xinha_editors[i])) { continue; } Xinha.loadingMessages.push(Xinha.createLoadingMessage(Xinha.getElementById('textarea', xinha_editors[i]))); } }; Xinha.createLoadingMessage = function(textarea,text) { if ( document.getElementById("loading_" + textarea.id) || !Xinha.isSupportedBrowser) { return; } // Create and show the main loading message and the sub loading message for details of loading actions // global element var loading_message = document.createElement("div"); loading_message.id = "loading_" + textarea.id; loading_message.className = "loading"; loading_message.style.left = (Xinha.findPosX(textarea) + textarea.offsetWidth / 2) - 106 + 'px'; loading_message.style.top = (Xinha.findPosY(textarea) + textarea.offsetHeight / 2) - 50 + 'px'; // main static message var loading_main = document.createElement("div"); loading_main.className = "loading_main"; loading_main.id = "loading_main_" + textarea.id; loading_main.appendChild(document.createTextNode(Xinha._lc("Loading in progress. Please wait!"))); // sub dynamic message var loading_sub = document.createElement("div"); loading_sub.className = "loading_sub"; loading_sub.id = "loading_sub_" + textarea.id; text = text ? text : Xinha._lc("Loading Core"); loading_sub.appendChild(document.createTextNode(text)); loading_message.appendChild(loading_main); loading_message.appendChild(loading_sub); document.body.appendChild(loading_message); Xinha.freeLater(loading_message); Xinha.freeLater(loading_main); Xinha.freeLater(loading_sub); return loading_sub; }; Xinha.prototype.setLoadingMessage = function(subMessage, mainMessage) { if ( !document.getElementById("loading_sub_" + this._textArea.id) ) { return; } document.getElementById("loading_main_" + this._textArea.id).innerHTML = mainMessage ? mainMessage : Xinha._lc("Loading in progress. Please wait!"); document.getElementById("loading_sub_" + this._textArea.id).innerHTML = subMessage; }; Xinha.setLoadingMessage = function(string) { if (!Xinha.loadingMessages) { return; } for ( var i = 0; i < Xinha.loadingMessages.length; i++ ) { Xinha.loadingMessages[i].innerHTML = string; } }; Xinha.prototype.removeLoadingMessage = function() { if (document.getElementById("loading_" + this._textArea.id) ) { document.body.removeChild(document.getElementById("loading_" + this._textArea.id)); } }; Xinha.removeLoadingMessages = function(xinha_editors) { for (var i=0;i< xinha_editors.length;i++) { if (!document.getElementById(xinha_editors[i])) { continue; } var main = document.getElementById("loading_" + document.getElementById(xinha_editors[i]).id); main.parentNode.removeChild(main); } Xinha.loadingMessages = null; }; /** List of objects that have to be trated on page unload in order to work around the broken * Garbage Collector in IE * @private * @see Xinha#freeLater * @see Xinha#free * @see Xinha#collectGarbageForIE */ Xinha.toFree = []; /** Adds objects to Xinha.toFree * @param {Object} object The object to free memory * @param (String} prop optional The property to release * @private * @see Xinha#toFree * @see Xinha#free * @see Xinha#collectGarbageForIE */ Xinha.freeLater = function(obj,prop) { Xinha.toFree.push({o:obj,p:prop}); }; /** Release memory properties from object * @param {Object} object The object to free memory * @param (String} prop optional The property to release * @private * @see Xinha#collectGarbageForIE * @see Xinha#free */ Xinha.free = function(obj, prop) { if ( obj && !prop ) { for ( var p in obj ) { Xinha.free(obj, p); } } else if ( obj ) { if ( prop.indexOf('src') == -1 ) // if src (also lowsrc, and maybe dynsrc ) is set to null, a file named "null" is requested from the server (see #1001) { try { obj[prop] = null; } catch(x) {} } } }; /** IE's Garbage Collector is broken very badly. We will do our best to * do it's job for it, but we can't be perfect. Takes all objects from Xinha.free and releases sets the null * @private * @see Xinha#toFree * @see Xinha#free */ Xinha.collectGarbageForIE = function() { Xinha.flushEvents(); for ( var x = 0; x < Xinha.toFree.length; x++ ) { Xinha.free(Xinha.toFree[x].o, Xinha.toFree[x].p); Xinha.toFree[x].o = null; } }; // The following methods may be over-ridden or extended by the browser specific // javascript files. /** Insert a node at the current selection point. * @param {DomNode} toBeInserted */ Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { Xinha.notImplemented("insertNodeAtSelection"); }; /** Get the parent element of the supplied or current selection. * @param {Selection} sel optional selection as returned by getSelection * @returns {DomNode} */ Xinha.prototype.getParentElement = function(sel) { Xinha.notImplemented("getParentElement"); }; /** * Returns the selected element, if any. That is, * the element that you have last selected in the "path" * at the bottom of the editor, or a "control" (eg image) * * @returns {DomNode|null} */ Xinha.prototype.activeElement = function(sel) { Xinha.notImplemented("activeElement"); }; /** * Determines if the given selection is empty (collapsed). * @param {Selection} sel Selection object as returned by getSelection * @returns {Boolean} */ Xinha.prototype.selectionEmpty = function(sel) { Xinha.notImplemented("selectionEmpty"); }; /** * Returns a range object to be stored * and later restored with Xinha.prototype.restoreSelection() * @returns {Range} */ Xinha.prototype.saveSelection = function() { Xinha.notImplemented("saveSelection"); }; /** Restores a selection previously stored * @param {Range} savedSelection Range object as returned by Xinha.prototype.restoreSelection() */ Xinha.prototype.restoreSelection = function(savedSelection) { Xinha.notImplemented("restoreSelection"); }; /** * Selects the contents of the given node. If the node is a "control" type element, (image, form input, table) * the node itself is selected for manipulation. * * @param {DomNode} node * @param {Integer} pos Set to a numeric position inside the node to collapse the cursor here if possible. */ Xinha.prototype.selectNodeContents = function(node,pos) { Xinha.notImplemented("selectNodeContents"); }; /** Insert HTML at the current position, deleting the selection if any. * * @param {String} html */ Xinha.prototype.insertHTML = function(html) { Xinha.notImplemented("insertHTML"); }; /** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML. * * @returns {String} */ Xinha.prototype.getSelectedHTML = function() { Xinha.notImplemented("getSelectedHTML"); }; /** Get a Selection object of the current selection. Note that selection objects are browser specific. * * @returns {Selection} */ Xinha.prototype.getSelection = function() { Xinha.notImplemented("getSelection"); }; /** Create a Range object from the given selection. Note that range objects are browser specific. * @see Xinha#getSelection * @param {Selection} sel Selection object * @returns {Range} */ Xinha.prototype.createRange = function(sel) { Xinha.notImplemented("createRange"); }; /** Determine if the given event object is a keydown/press event. * * @param {Event} event * @returns {Boolean} */ Xinha.prototype.isKeyEvent = function(event) { Xinha.notImplemented("isKeyEvent"); }; /** Determines if the given key event object represents a combination of CTRL-<key>, * which for Xinha is a shortcut. Note that CTRL-ALT-<key> is not a shortcut. * * @param {Event} keyEvent * @returns {Boolean} */ Xinha.prototype.isShortCut = function(keyEvent) { if(keyEvent.ctrlKey && !keyEvent.altKey) { return true; } return false; }; /** Return the character (as a string) of a keyEvent - ie, press the 'a' key and * this method will return 'a', press SHIFT-a and it will return 'A'. * * @param {Event} keyEvent * @returns {String} */ Xinha.prototype.getKey = function(keyEvent) { Xinha.notImplemented("getKey"); }; /** Return the HTML string of the given Element, including the Element. * * @param {DomNode} element HTML Element * @returns {String} */ Xinha.getOuterHTML = function(element) { Xinha.notImplemented("getOuterHTML"); }; /** Get a new XMLHTTPRequest Object ready to be used. * * @returns {XMLHTTPRequest} */ Xinha.getXMLHTTPRequestObject = function() { try { if (typeof XMLHttpRequest != "undefined" && typeof XMLHttpRequest.constructor == 'function' ) // Safari's XMLHttpRequest is typeof object { return new XMLHttpRequest(); } else if (typeof ActiveXObject == "function") { return new ActiveXObject("Microsoft.XMLHTTP"); } } catch(e) { Xinha.notImplemented('getXMLHTTPRequestObject'); } }; // Compatability - all these names are deprecated and will be removed in a future version /** Alias of activeElement() * @see Xinha#activeElement * @deprecated * @returns {DomNode|null} */ Xinha.prototype._activeElement = function(sel) { return this.activeElement(sel); }; /** Alias of selectionEmpty() * @see Xinha#selectionEmpty * @deprecated * @param {Selection} sel Selection object as returned by getSelection * @returns {Boolean} */ Xinha.prototype._selectionEmpty = function(sel) { return this.selectionEmpty(sel); }; /** Alias of getSelection() * @see Xinha#getSelection * @deprecated * @returns {Selection} */ Xinha.prototype._getSelection = function() { return this.getSelection(); }; /** Alias of createRange() * @see Xinha#createRange * @deprecated * @param {Selection} sel Selection object * @returns {Range} */ Xinha.prototype._createRange = function(sel) { return this.createRange(sel); }; HTMLArea = Xinha; //what is this for? Do we need it? Xinha.init(); if ( Xinha.ie_version < 8 ) { Xinha.addDom0Event(window,'unload',Xinha.collectGarbageForIE); } /** Print some message to Firebug, Webkit, Opera, or IE8 console * * @param {String} text * @param {String} level one of 'warn', 'info', or empty */ Xinha.debugMsg = function(text, level) { if (typeof console != 'undefined' && typeof console.log == 'function') { if (level && level == 'warn' && typeof console.warn == 'function') { console.warn(text); } else if (level && level == 'info' && typeof console.info == 'function') { console.info(text); } else { console.log(text); } } else if (typeof opera != 'undefined' && typeof opera.postError == 'function') { opera.postError(text); } }; Xinha.notImplemented = function(methodName) { throw new Error("Method Not Implemented", "Part of Xinha has tried to call the " + methodName + " method which has not been implemented."); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/XinhaCore.js
JavaScript
art
242,194
<h1 class="title" ><l10n>Insert Snippet</l10n></h1> <form action="" method="get"> <div class="IScattabs" id="[cattabs]"></div> <div id="[insert_div]" style="overflow:auto;height:330px;float: left;width:50%"> <table style="border: 0;width:100%"> <tbody id="[snippettable]" class="ISsnippettable"></tbody> </table> </div> <div><iframe src="about:blank" style="float:left; border:none;width: 50%;height: 330px" id="[preview_iframe]"></iframe> <div class="space" style="clear: left;"></div> <div class="buttons"> <div style="float:left"> <label for="[search]"><l10n>Filter</l10n></label> <input type="text" id="[search]" /> <input type="checkbox" id="[wordbegin]" checked="checked" value="on" /><label for="[wordbegin]"><l10n>Only search word beginning</l10n></label> </div> <button type="button" id="[cancel]" style="float: right;"><l10n>Cancel</l10n></button> </div> </form>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertSnippet2/dialog.html
HTML
art
945
html > body .ISsnippettable button { min-width:70px;white-space:nowrap;} .ISsnippettable td { background:white; vertical-align:top; } .ISsnippettable td { padding:5px; border:1px solid; border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } .ISsnippettable button {text-align:center;} .ISsnippettable a.button {/*background:ButtonFace;*/padding:1px 5px 1px 5px;color:black;text-decoration:none} .ISpreview { background-color: white; padding: 5px; display : none; position : absolute; top : 12px; left :100px; border : 1px dotted black; z-index:100; } .IScattabs {line-height:18px; } .IScattabs a { white-space:nowrap; border-width:1px 1px 0px 1px; border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; border-style:solid; padding:4px; margin-left:1px; text-decoration:none; color:black; -moz-border-radius:10px 10px 0px 0px; height:12px; background-repeat:repeat-x; } .IScattabs .tab1 { background-image:url(img/1.PNG); } .IScattabs .tab2 { background-image:url(img/2.PNG); } .IScattabs .tab3 { background-image:url(img/3.PNG); } .IScattabs .tab4 { background-image:url(img/4.PNG); } .IScattabs .tab5 { background-image:url(img/5.PNG); } .IScattabs .tab6 { background-image:url(img/6.PNG); } .IScattabs .tab7 { background-image:url(img/7.PNG); } .IScattabs .tab8 { background-image:url(img/8.PNG); } .IScattabs .tab9 { background-image:url(img/9.PNG); } .IScattabs .tab10 { background-image:url(img/10.PNG); } .IScattabs .tab11 { background-image:url(img/11.PNG); } .IScattabs .tab12 { background-image:url(img/12.PNG); } .IScattabs .tab13 { background-image:url(img/13.PNG); } .IScattabs .tab14 { background-image:url(img/14.PNG); } .IScattabs .tab15 { background-image:url(img/15.PNG); } .IScattabs .tab16 { background-image:url(img/16.PNG); } .IScattabs a.active { font-weight:bold; border-width:1px 2px 0px 2px }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertSnippet2/InsertSnippet.css
CSS
art
1,909
// I18N constants // LANG: "de", ENCODING: UTF-8 { "Insert Snippet": "Snippet einfügen", "Insert as HTML": "Als HTML einfügen", "HTML": "HTML", "Insert as template variable": "Als Template-Variable einfügen", "Variable": "Variable", "All Categories" : "Alle Kategorien", "Only search word beginning" : "Nur nach Wortanfang suchen", "Filter" : "Filter" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertSnippet2/lang/de.js
JavaScript
art
369
<?php /** * This is a reference implementation of how to get your snippets dynamically from a PHP data structure into InsertSnippet2's XML format. * <?php * $categories = array('cat1','etc...'); //categories are optional * $snippets = array( * array('name'= 'snippet1','text'=>'some text'), * array('name'= 'snippet2','text'=>'<p>some HTML</p>', 'varname'=>'{$var}','category'=>'cat1') //varname and category are optional * ) * * ?> */ header("Content-type: text/xml"); print '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE snXML PUBLIC "Xinha InsertSnippet Data File" "http://x-webservice.net/res/snXML.dtd">'; ?> <snXML> <categories> <?php foreach ((array)$categories as $c) { print '<c n="'.$c.'" />'."\n"; } ?> </categories> <snippets> <?php foreach ((array)$snippets as $s) { print '<s n="'.$s['name'].'" v="'.$s['varname'].'" c="'.$s['category'].'"> <![CDATA[ '.$s['text'].' ]]> </s>'."\n"; } ?> </snippets> </snXML>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertSnippet2/snippets.php
PHP
art
955
/*------------------------------------------*\ InsertSnippet2 for Xinha _______________________ Insert HTML fragments or template variables \*------------------------------------------*/ function InsertSnippet2(editor) { this.editor = editor; var cfg = editor.config; var self = this; cfg.registerButton({ id : "InsertSnippet2", tooltip : this._lc("Insert Snippet"), image : editor.imgURL("ed_snippet.gif", "InsertSnippet2"), textMode : false, action : function(editor) { self.buttonPress(editor); } }); cfg.addToolbarElement("InsertSnippet2", "insertimage", -1); this.snippets = null; this.categories = null; this.html =null; Xinha._getback(cfg.InsertSnippet2.snippets,function (txt,req) { var xml=req.responseXML; var c = xml.getElementsByTagName('c'); self.categories = []; for (var i=0;i<c.length;i++) { self.categories.push(c[i].getAttribute('n')); } var s = xml.getElementsByTagName('s'); self.snippets = []; var textContent,item; for (var i=0;i<s.length;i++) { item = {}; for (var j=0;j<s[i].attributes.length;j++) { item[s[i].attributes[j].nodeName] = s[i].attributes[j].nodeValue; } item.html = s[i].text || s[i].textContent; self.snippets.push(item); } }); Xinha.loadStyle('InsertSnippet.css','InsertSnippet2','IScss'); } InsertSnippet2.prototype.onUpdateToolbar = function() { if (!this.snippets) { this.editor._toolbarObjects.InsertSnippet2.state("enabled", false); } else InsertSnippet2.prototype.onUpdateToolbar = null; } InsertSnippet2._pluginInfo = { name : "InsertSnippet2", version : "1.2", developer : "Raimund Meyer", developer_url : "http://x-webservice.net", c_owner : "Raimund Meyer", sponsor : "", sponsor_url : "", license : "htmlArea" }; Xinha.Config.prototype.InsertSnippet2 = { 'snippets' : Xinha.getPluginDir('InsertSnippet2')+'/snippets.xml' }; InsertSnippet2.prototype._lc = function(string) { return Xinha._lc(string, 'InsertSnippet2'); }; InsertSnippet2.prototype.onGenerateOnce = function() { this._prepareDialog(); }; InsertSnippet2.prototype._prepareDialog = function() { var self = this; if(!this.html) // retrieve the raw dialog contents { Xinha._getback(Xinha.getPluginDir('InsertSnippet2')+'/dialog.html', function(getback) { self.html = getback; self._prepareDialog(); }); return; } if (!this.snippets) { setTimeout(function(){self._prepareDialog()},50); return; } var editor = this.editor; var InsertSnippet2 = this; this.dialog = new Xinha.Dialog(editor, this.html, 'InsertSnippet2',{width:800,height:400},{modal:true}); Xinha._addClass( this.dialog.rootElem, 'InsertSnippet2' ); var dialog = this.dialog; var main = this.dialog.main; var caption = this.dialog.captionBar; this.snippetTable = dialog.getElementById('snippettable'); this.drawCatTabs(); this.drawSnippetTable(); this.preparePreview(); dialog.onresize = function() {self.resize(); } this.dialog.getElementById('search').onkeyup = function() { self.search ()}; this.dialog.getElementById('wordbegin').onclick = function() { self.search ()}; this.dialog.getElementById('cancel').onclick = function() { self.dialog.hide ()}; } InsertSnippet2.prototype.drawSnippetTable = function() { if (!this.snippets.length) return; var self = this; var tbody = this.snippetTable; var snippets = this.snippets; while (tbody.hasChildNodes()) { tbody.removeChild(tbody.lastChild); } var id,snippet_name, snippet_html, snippet_cat, snippet_varname, trow, newCell, cellNo, btn; for(var i = 0,trowNo=0; i < snippets.length; i++) { id = i; snippet_name = snippets[i]['n']; snippet_cat = snippets[i]['c']; snippet_varname = snippets[i]['v'] snippet_html = snippets[i]['html']; if (this.categoryFilter && snippet_cat != this.categoryFilter && this.categoryFilter != 'all') continue; trow = tbody.insertRow(trowNo); trowNo++; cellNo = 0; newCell = trow.insertCell(cellNo); newCell.onmouseover = function(event) {return self.preview(event || window.event)}; newCell.onmouseout = function() {return self.preview()}; newCell.appendChild(document.createTextNode(snippet_name)); newCell.snID = id; newCell.id = 'cell' + id; cellNo++; newCell = trow.insertCell(cellNo); newCell.style.whiteSpace = 'nowrap'; btn = document.createElement('button'); btn.snID = id; btn._insAs = 'html'; btn.onclick = function(event) {self.doInsert(event || window.event); return false}; btn.appendChild(document.createTextNode(this._lc("HTML"))); btn.title = this._lc("Insert as HTML"); newCell.appendChild(btn); if (snippet_varname) { newCell.appendChild(document.createTextNode(' ')); var btn = document.createElement('button'); btn.snID = id; btn._insAs = 'variable'; btn.onclick = function(event) {self.doInsert(event || window.event); return false}; btn.appendChild(document.createTextNode(this._lc("Variable"))); btn.title = this._lc("Insert as template variable"); newCell.appendChild(btn); } cellNo++; } } InsertSnippet2.prototype.drawCatTabs = function() { if (!this.categories.length) return; var self = this; var tabsdiv = this.dialog.getElementById("cattabs"); while (tabsdiv.hasChildNodes()) { tabsdiv.removeChild(tabsdiv.lastChild); } var tabs_i = 1; var tab = document.createElement('a'); tab.href = "javascript:void(0);"; tab.appendChild(document.createTextNode(this._lc("All Categories"))); tab.cat = 'all'; tab.className = "tab"+tabs_i; tab.onclick = function() {self.categoryFilter = self.cat; self.drawCatTabs();self.drawSnippetTable(); self.search ()} if (!this.categoryFilter || this.categoryFilter == 'all') { Xinha._addClass(tab,'active'); tab.onclick = null; } tabsdiv.appendChild(tab); tabs_i++; for (var i = 0;i < this.categories.length;i++) { var name = this.categories[i]; var tab = document.createElement('a'); tab.href = "javascript:void(0);"; tab.appendChild(document.createTextNode(name)); tab.cat = name; tab.className = "tab"+tabs_i; tab.onclick = function() {self.categoryFilter = this.cat; self.drawCatTabs();self.drawSnippetTable(); self.search ()} if (name == this.categoryFilter) { Xinha._addClass(tab,'active'); tab.onclick = null; } tabsdiv.appendChild(tab); if (Xinha.is_gecko) tabsdiv.appendChild(document.createTextNode(String.fromCharCode(8203))); tabs_i = (tabs_i<16) ? tabs_i +1 : 1; } if (!this.catTabsH) { this.catTabsH = tabsdiv.offsetHeight; } } InsertSnippet2.prototype.search = function () { var tbody = this.dialog.getElementById("snippettable"); var searchField =this.dialog.getElementById('search'); if (searchField.value) { var val = searchField.value; val = val.replace(/\.?([*?+])/g,'.$1'); var wordstart = (this.dialog.getElementById('wordbegin').checked) ? '^' : ''; try { var re = new RegExp (wordstart+val,'i'); } catch (e) {var re = null}; } else var re = null; for (var i=0;i<tbody.childNodes.length;i++) { var tr = tbody.childNodes[i]; var name = tr.firstChild.firstChild.data; if (re && !name.match(re)) { tr.style.display = 'none'; } else { tr.style.display = ''; } } } InsertSnippet2.prototype.preview = function(event) { if (!event) { this.previewBody.innerHTML = ''; return; } var target = event.target || event.srcElement; var snID = target.snID; if (!this.previewBody) { this.preparePreview(); return; } if (this.previewIframe.style.display == 'none') { this.previewIframe.style.display = 'block'; } this.previewBody.innerHTML = this.snippets[snID].html; } InsertSnippet2.prototype.preparePreview = function() { var editor = this.editor; var self = this; var preview_iframe = this.previewIframe = this.dialog.getElementById('preview_iframe'); var doc = null; try { if ( preview_iframe.contentDocument ) { doc = preview_iframe.contentDocument; } else { doc = preview_iframe.contentWindow.document; } // try later if ( !doc ) { if ( Xinha.is_gecko ) { setTimeout(function() { self.preparePreview(snID); }, 50); return false; } else { throw("ERROR: IFRAME can't be initialized."); } } } catch(ex) { // try later setTimeout(function() { self.preparePreview(snID); }, 50); } doc.open("text/html","replace"); var html = '<html><head><title></title>'; html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + editor.config.charSet + "\">\n"; html += '<style type="text/css">body {background-color:#fff} </style>'; if ( typeof editor.config.baseHref != 'undefined' && editor.config.baseHref !== null ) { html += "<base href=\"" + editor.config.baseHref + "\"/>\n"; } if ( editor.config.pageStyle ) { html += "<style type=\"text/css\">\n" + editor.config.pageStyle + "\n</style>"; } if ( typeof editor.config.pageStyleSheets !== 'undefined' ) { for ( var i = 0; i < editor.config.pageStyleSheets.length; i++ ) { if ( editor.config.pageStyleSheets[i].length > 0 ) { html += "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + editor.config.pageStyleSheets[i] + "\">"; //html += "<style> @import url('" + editor.config.pageStyleSheets[i] + "'); </style>\n"; } } } html += "</head>\n"; html += "<body>\n"; html += "</body>\n"; html += "</html>"; doc.write(html); doc.close(); setTimeout(function() { self.previewBody = doc.getElementsByTagName('body')[0]; },100); } InsertSnippet2.prototype.buttonPress = function(editor) { this.dialog.toggle(); } InsertSnippet2.prototype.doInsert = function(event) { var target = event.target || event.srcElement; var sn = this.snippets[target.snID]; this.dialog.hide(); var cfg = this.editor.config.InsertSnippet2; if (target._insAs == 'variable') { this.editor.insertHTML(sn.v); } else { this.editor.insertHTML(sn.html); } } InsertSnippet2.prototype.resize = function () { var insertDiv = this.dialog.getElementById('insert_div'); var preview_iframe = this.dialog.getElementById('preview_iframe'); var win = {h:this.dialog.height,w:this.dialog.width}; var h = win.h - 90; if (this.categories.length) h -= this.catTabsH; insertDiv.style.height = preview_iframe.style.height = h + 'px'; //insertDiv.style.width = win.w + 'px'; return true; }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertSnippet2/InsertSnippet2.js
JavaScript
art
11,296
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head> <title>InsertSnippet for Xinha</title> <style type="text/css"> body { font-family: sans-serif; } pre {border: dotted grey thin; background-color:LightYellow;padding:10px } p { width:500px } </style> </head> <body> <h1>InsertSnippet2 for Xinha</h1> <p>Insert HTML fragments or template variables in your document.</p> <h2>Features</h2> <ul> <li>Categorization to organize your snippets if you have a lot (optional)</li> <li>Search for name</li> <li>Insert as literal text/html or variable (optional)&nbsp;</li> <li>XML data format<br /></li> </ul> <h2>Usage</h2> <p> In order to use your own snippets you have to add a parameter to your xinha_config: </p> <pre>xinha_config.InsertSnippet2.snippets = "/path/to/your/snippets.xml"; </pre> <p>This path should point to a XML file that has the following format:</p> <pre>&lt;snXML&gt; &lt;categories&gt; &lt;c n="the name" /&gt; &lt;/categories&gt; &lt;snippets&gt; &lt;s n="the name" v="optional variable name to be inserted" c="the category"&gt; &amp;lt;p&amp;gt;some text or HTML, please entize HTML tags&amp;lt;/p&amp;gt; &lt;/s&gt; &lt;s n="another"&gt; &lt;![CDATA[ &lt;p&gt;or put HTML in a CDATA section&lt;/p&gt; ]]&gt; &lt;/s&gt; &lt;/snipptes&gt; &lt;/snXML&gt; </pre> <p> </p> <h3>&nbsp;Tags</h3> <dl><dt>&lt;snXML&gt;&lt;/snXML&gt;</dt><dd>&nbsp;The root tag</dd><dt>&lt;categories&gt;&lt;/categories&gt;<br /></dt><dd>&nbsp;This tag contains the categories (optional)<br /></dd><dt>&nbsp;&lt;c /&gt;</dt><dd>&nbsp;Each category <br /></dd><dt>&nbsp;&lt;snippets&gt;&lt;/snippets&gt;</dt><dd> This tag contains the actual snippet. As this is XML, you cannot put HTML here literally. You have to either entize the &lt;,&gt;, and &amp; characters or wrap the contents in a CDATA section<br /></dd></dl> <h3>Attributes</h3> <dl><dt>&nbsp;n</dt><dd>&nbsp;The name of one snippet or category. It is obligatory for both.<br /></dd><dt>&nbsp;v</dt><dd> If this attribute is present in a snippet tag, there is a button in the UI that allows to insert this variable instead of the textual content of the snippet. <br /></dd><dt> c<br /></dt><dd>&nbsp;The category<br /></dd></dl> <p>Inside the plugin's directory, there is a sample XML file and PHP script that shows how to create the XML dynamically.<br /></p> <p style="font-size: 80%;">3 October 2008 Raimund Meyer (xinha@raimundmeyer.de)</p> </body> </html>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertSnippet2/readme.html
HTML
art
2,717
// Double Click Plugin for Xinha // Implementation by Marijn Kampf http://www.marijn.org // Sponsored by http://www.smiling-faces.com // // (c) Marijn Kampf 2004. // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt). // // Cut-n-paste version of double click plugin. // Almost no original code used. Based on // Luis HTMLarea and Mihai Bazon Context Menu // // // DoubleClick._pluginInfo = { name : "DoubleClick", version : "1.0", developer : "Marijn Kampf", developer_url : "http://www.marijn.org", c_owner : "Marijn Kampf", sponsor : "smiling-faces.com", sponsor_url : "http://www.smiling-faces.com", license : "htmlArea" }; function DoubleClick(editor) { this.editor = editor; // ADDING CUSTOM DOUBLE CLICK ACTIONS // format of the dblClickList elements is "TAGNAME: [ ACTION ]" // - TAGNAME: tagname of the tag that is double clicked // - ACTION: function that gets called when the button is clicked. // it has the following prototype: // function(editor, event) // - editor is the Xinha object that triggered the call // - target is the selected object this.editor.dblClickList = { // Edit Link dialog a: [ function(e) {e.config.btnList['createlink'][3](e); } ], // Follow link //a: [ function(editor, target) { window.location = target.href; properties(target); } ], img: [ function(e) {e.execCommand("insertimage");} ], td: [ function(e) {e.execCommand("inserttable");} ] }; } DoubleClick.prototype.onGenerate = function() { var self = this; var doc = this.editordoc = this.editor._iframe.contentWindow.document; Xinha._addEvents(doc, ["dblclick"], function (event) { return self.onDoubleClick(Xinha.is_ie ? self.editor._iframe.contentWindow.event : event); }); this.currentClick = null; }; DoubleClick.prototype.onDoubleClick = function(ev) { var target = Xinha.is_ie ? ev.srcElement : ev.target; var tagName = target.tagName.toLowerCase(); if (this.editor.dblClickList[tagName] != undefined) { this.editor.dblClickList[tagName][0](this.editor, target); } };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/DoubleClick/DoubleClick.js
JavaScript
art
2,311
<h1 id="[h1]"><l10n>Insert Note</l10n></h1> <div style="margin: 10px 10px 0px 10px;"> <label><l10n>Insert</l10n></label> <select id="[noteMenu]" name="[noteMenu]" style="margin-bottom: 6px; width: 200px;"> <option selected value="new" id="[newNoteOption]">New footnote</option> </select> <textarea id="[noteContent]" name="[noteContent]" style="width: 375px;" rows="6"></textarea> </div> <div class="buttons"> <input type="button" id="[ok]" value="_(Insert)" /> <input type="button" id="[cancel]" value="_(Cancel)" /> </div>
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertNote/dialog.html
HTML
art
541
/*------------------------------------------*\ InsertNote plugin for Xinha ___________________________ This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License (at http://www.gnu.org/licenses/lgpl.html) for more details. InsertNote ---------- Allows for the insertion of footnotes/endnotes. Supports: * Automatic numbering * Automatic linking to anchors * Links back to each specific citation * Saves previously referenced notes for easy reuse * Cleanup of unreferenced notes (or references to non-existent notes) \*------------------------------------------*/ function InsertNote(editor) { this.editor = editor; var cfg = editor.config; var self = this; cfg.registerButton({ id : "insert-note", tooltip : this._lc("Insert footnote"), image : editor.imgURL("insert-note.gif", "InsertNote"), textMode : false, action : function() { self.show(); } }); cfg.addToolbarElement("insert-note", "createlink", 1); }; InsertNote._pluginInfo = { name : "InsertNote", version : "0.4", developer : "Nicholas Bergson-Shilcock", developer_url : "http://www.nicholasbs.com", c_owner : "Nicholas Bergson-Shilcock", sponsor : "The Open Planning Project", sponsor_url : "http://topp.openplans.org", license : "LGPL" }; InsertNote.prototype.onGenerateOnce = function () { this.notes = {}; this.noteNums = {}; this.ID_PREFIX = "InsertNoteID_"; // This should suffice to be unique... this.MARKER_SUFFIX = "_marker"; this.MARKER_CLASS = "InsertNoteMarker"; this.LINK_BACK_SUFFIX = "_LinkBacks"; this.NOTE_LIST_ID = "InsertNote_NoteList"; this._prepareDialog(); }; InsertNote.prototype._prepareDialog = function() { var self = this; var editor = this.editor; if (!this.html) { Xinha._getback(Xinha.getPluginDir("InsertNote") + "/dialog.html", function(getback) { self.html = getback; self._prepareDialog(); }); return; } this.dialog = new Xinha.Dialog(editor, this.html, "InsertNote", {width: 400, closeOnEscape: true, resizable: false, centered: true, modal: true }); this.dialog.getElementById("ok").onclick = function() {self.apply();}; this.dialog.getElementById("cancel").onclick = function() {self.dialog.hide();}; this.dialog.getElementById("noteMenu").onchange = function() { var noteId = this.options[this.selectedIndex].value; var text = self.notes[noteId] || ""; var textArea = self.dialog.getElementById("noteContent") textArea.value = text; if (text) { textArea.disabled = true; } else { textArea.disabled = false; textArea.focus(); } }; this.ready = true; }; InsertNote.prototype.show = function() { if (!this.ready) { var self = this; window.setTimeout(function() {self.show();}, 80); return; } var editor = this.editor; // All of the Xinha dialogs are part of the main document, not the editor // document, so we have to use the correct document reference to modify them. var doc = document; this.repairNotes(); // Can't insert footnotes inside of other footnotes... if (this.cursorInFootnote()) { alert("Footnotes cannot be inserted inside of other footnotes."); return } this.dialog.show(); var popupMenu = this.dialog.getElementById("noteMenu"); while (popupMenu.lastChild.value != "new") { // Remove all menu options except "New note" popupMenu.removeChild(popupMenu.lastChild); } var temp, displayName, n; var orderedIds = this._getOrderedNoteIds(); for (var i=0; i<orderedIds.length; i++) { n = orderedIds[i]; temp = doc.createElement("option"); temp.setAttribute("value", n); displayName = this.notes[n]; displayName = displayName.replace(/<[^>]*>/gi, ""); // XXX TODO: Strip HTML less naively. if (displayName.length > 50) // Truncate preview text to 50 chars { displayName = displayName.substr(0,50) + "..."; } displayName = this._getNumFromNoteId(n) + ". " + displayName; temp.appendChild(doc.createTextNode(displayName)); popupMenu.appendChild(temp); } var textArea = this.dialog.getElementById("noteContent"); textArea.disabled = false; textArea.focus(); textArea.value = ""; }; // Checks to see whether or not the cursor is placed inside of a footnote InsertNote.prototype.cursorInFootnote = function(ignoreMarkers) { var ancestors = this.editor.getAllAncestors(); for (var i=0; i<ancestors.length; i++) { if (ancestors[i].id == this.NOTE_LIST_ID) return true; if (ancestors[i].className == this.MARKER_CLASS && !ignoreMarkers) return true; } return false; } /* This function makes sure all of the notes are consistent. Specifically: * If a note exists but is never referred to, that note is removed * Conversely, if a note is referred to but does not exist, the references are removed * If the markup for a note marker exists but contains no visible text, the markup is removed * All numbering is updated as follows: - the first note is numbered 1 - each note thereafter is numbered sequentially, unless it has already been referenced, in which case it's given the same number as it was the first time it was referenced. * The note text stored in the this.notes hash is updated to reflect any changes made by the user (so if the user changes the citation body in Xinha we don't overwrite these changes next time we update things) * The noteNums array is regenerated so as to be up to date */ InsertNote.prototype.repairNotes = function() { var self = this; var note; var markers; var marker; var isEmpty; var temp; var doc = this.editor._doc; this.repairScheduled = false; // First, we remove any markers if they reference a note that doesn't exist. // If the note does exist, we make sure we have a reference to it by // calling this._saveNote() markers = this._getMarkers(); for (var i=0; i<markers.length; i++) { marker = markers[i]; // Remove empty markers isEmpty = false; if (marker) // check if anchor is empty isEmpty = marker.innerHTML.match(/^(<span[^>]*>)?(<sup>)?(<a[^>]*>)?[\s]*(<\/a>)?(<\/sup>)?(<\/span>)?$/m); if (isEmpty) marker.parentNode.removeChild(marker); var noteId = this._getIdFromMarkerId(marker.id); if (!this.notes[noteId]) { // We don't have this note stored, let's see if // it actually exists... note = doc.getElementById(noteId); if (note) { this._saveNote(note); } else { if (marker) marker.parentNode.removeChild(marker); } } } // Now we iterate through all the note ids we have stored... for (var id in this.notes) { // Get reference to note note = doc.getElementById(id); markers = this._getMarkers(id); if (note) { if (markers.length == 0) // Remove note if it's not referenced anywhere { // remove the note note.parentNode.removeChild(note); delete this.notes[id]; } else { // The note exists and *is* referenced, so we save its contents this._saveNote(note); } } else { // Note no longer exists. Remove any references to it. for (var i=0; i<markers.length; i++) { markers[i].parentNode.removeChild(markers[i]); } delete this.notes[id]; } } // Correct marker numbering this._updateRefNums(); // At this point we now have all of the note markers correctly // numbered, an up-to-date hash (this.noteNums) of note numbers // keyed to note ids, and no stray markers or unreferenced notes. // Final step: Correct the numbering/order of the actual notes var noteList = doc.getElementById(this.NOTE_LIST_ID); var newNoteList = this._createNoteList(); if (newNoteList) { noteList.parentNode.replaceChild(newNoteList, noteList); } else { if (noteList) noteList.parentNode.removeChild(noteList); } }; InsertNote.prototype._saveNote = function(note) { var doc = this.editor._doc; // Before saving a note's contents, we do two things: // 1) we remove the markup we inserted so we don't end up with duplicate links // 2) check to see if the note is empty, and if so, we remove it var temp = doc.getElementById(this._getLinkBackSpanId(note.id)); if (temp) temp.parentNode.removeChild(temp); if (note.innerHTML) { this.notes[note.id] = note.innerHTML; } else { // If we're here then the note is empty, // so we delete it and any markers for it. delete this.notes[note.id]; markers = this._getMarkers(note.id); for (var i=0; i<markers.length; i++) markers[i].parentNode.removeChild(markers[i]); } }; InsertNote.prototype._updateRefNums = function() { var runningCount = 1; // first reference is 1 var num; var marker; var noteId; // Reset all note numbering... this.noteNums = {}; var markers = this._getMarkers(); for (var i=0; i<markers.length; i++) { marker = markers[i]; noteId = this._getIdFromMarkerId(marker.id); if (this.noteNums[noteId]) { num = this.noteNums[noteId]; } else { this.noteNums[noteId] = runningCount; num = runningCount++; } // span -> sup -> anchor marker.firstChild.firstChild.innerHTML = num; // XXX TODO: don't use firstChild.firstChild? } }; InsertNote.prototype.apply = function() { var editor = this.editor; var param = this.dialog.hide(); var noteId = param['noteMenu'].value; var newNote = (noteId == "new"); var noteContent = param['noteContent']; var doc = editor._doc; if (newNote) // Inserting a new note noteId = this._getNextId(this.ID_PREFIX); this.notes[noteId] = noteContent; var markerTemplate = this._createNoteMarker(noteId) editor.insertNodeAtSelection(markerTemplate); var marker = doc.getElementById(markerTemplate.id); var currentNoteList = doc.getElementById(this.NOTE_LIST_ID); var newNoteList = this._createNoteList(); var body = doc.body; if (currentNoteList) { body.replaceChild(newNoteList, currentNoteList); } else { body.appendChild(newNoteList); } var newel = doc.createTextNode('\u00a0'); if (marker.nextSibling) { newel = marker.parentNode.insertBefore(newel, marker.nextSibling); } else { newel = marker.parentNode.appendChild(newel); } this.repairNotes(); editor.selectNodeContents(newel,false); }; InsertNote.prototype._createNoteList = function() { var doc = this.editor._doc; var noteList = doc.createElement("ol"); noteList.id = this.NOTE_LIST_ID; var orderedIds = this._getOrderedNoteIds(); if (orderedIds.length == 0) return null; var note, id; for (var i=0; i<orderedIds.length; i++) { id = orderedIds[i]; note = this._createNoteNode(id, this.notes[id]); noteList.appendChild(note); } return noteList; }; InsertNote.prototype._createNoteMarker = function(noteId) { // Create the note marker, i.e., the # superscript var doc = this.editor._doc; var noteNum = this._getNumFromNoteId(noteId); var link = doc.createElement("a"); link.href = "#" + noteId; link.innerHTML = noteNum; var superscript = doc.createElement("sup"); superscript.appendChild(link); var span = doc.createElement("span"); span.id = this._getNextMarkerId(noteId); span.className = this.MARKER_CLASS; span.appendChild(superscript); return span }; InsertNote.prototype._createNoteNode = function(noteId, noteContent) { var doc = this.editor._doc; var anchor; var superscript = doc.createElement("sup"); var markers = this._getMarkers(noteId); var temp; for (var i=0; i<markers.length; i++) { anchor = doc.createElement("a"); if (markers.length == 1) { anchor.innerHTML = "^"; } else { anchor.innerHTML = this._letterNum(i); } anchor.href = "#" + markers[i].id; superscript.appendChild(anchor); if (i < markers.length-1) { temp = doc.createTextNode(", "); superscript.appendChild(temp); } } var span = doc.createElement("span"); span.id = this._getLinkBackSpanId(noteId); span.appendChild(superscript); var li = doc.createElement("li"); li.id = noteId; li.innerHTML = noteContent; li.appendChild(span); return li; }; InsertNote.prototype._getNextId = function(prefix) { // We can't just use Xinha.uniq here because it doesn't // work across editing sessions. E.g., it will break if // the user copies the html from one editor to another. var id = Xinha.uniq(prefix); while (this.editor._doc.getElementById(id)) id = Xinha.uniq(prefix); return id; }; InsertNote.prototype._getOrderedNoteIds = function() { var self = this; var orderedIds = new Array(); for (var id in this.notes) orderedIds.push(id); orderedIds.sort(function(a,b) { var n1 = self._getNumFromNoteId(a); var n2 = self._getNumFromNoteId(b); return (n1 - n2); }); return orderedIds; }; InsertNote.prototype._getNumFromNoteId = function(noteId) { if (!this.noteNums[noteId]) return 0; return this.noteNums[noteId]; }; // Return array of all markers that reference the specified note. // If noteId is not supplied, *all* markers are returned. InsertNote.prototype._getMarkers = function(noteId) { var doc = this.editor._doc; var markers = Xinha.getElementsByClassName(doc, this.MARKER_CLASS); if (!noteId) return markers; var els = new Array(); for (var i=0; i<markers.length; i++) { if (this._getIdFromMarkerId(markers[i].id) == noteId) { els.push(markers[i]); } } return els; }; InsertNote.prototype._getNextMarkerId = function(noteId) { return this._getNextId(noteId + this.MARKER_SUFFIX); }; InsertNote.prototype._getIdFromMarkerId = function(markerId) { return markerId.substr(0, markerId.search(this.MARKER_SUFFIX)); }; InsertNote.prototype._getLinkBackSpanId = function(noteId) { return noteId + this.LINK_BACK_SUFFIX; }; InsertNote.prototype._lc = function(string) { return Xinha._lc(string, "InsertNote"); }; // Probably overkill, but it does the job InsertNote.prototype._letterNum = function(num) { var letters = "abcdefghijklmnopqrstuvwxyz"; var len = Math.floor(num/letters.length) + 1; var s = ""; for (var i=0; i<len; i++) s += letters.substr(num % letters.length,1); return s; }; InsertNote.prototype.inwardHtml = function(html) { return html; }; InsertNote.prototype.outwardHtml = function(html) { this.repairNotes(); return this.editor.getHTML(); }; InsertNote.prototype.onKeyPress = function (event) { // This seems a bit hacky, but I don't presently see // a better way. if (event.keyCode == 8 || event.keyCode == 46) { var self = this; if (!this.repairScheduled && !this.cursorInFootnote(true)) // ignore if in a footnote { this.repairScheduled = true; window.setTimeout(function() { self.repairNotes(); }, 1000); } } return false; }; /** * * @param {String} mode either 'textmode' or 'wysiwyg' */ InsertNote.prototype.onMode = function (mode) { return false; }; /** * * @param {String} mode either 'textmode' or 'wysiwyg' */ InsertNote.prototype.onBeforeMode = function (mode) { return false; };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/InsertNote/InsertNote.js
JavaScript
art
16,146
// Character Map plugin for Xinha // Sponsored by http://www.systemconcept.de // Implementation by Holger Hees based on HTMLArea XTD 1.5 (http://mosforge.net/projects/htmlarea3xtd/) // Original Author - Bernhard Pfeifer novocaine@gmx.net // // (c) systemconcept.de 2004 // Distributed under the same terms as Xinha itself. // This notice MUST stay intact for use (see license.txt). function EditTag(editor) { this.editor = editor; var cfg = editor.config; var self = this; cfg.registerButton({ id : "edittag", tooltip : this._lc("Edit HTML for selected text"), image : editor.imgURL("ed_edit_tag.gif", "EditTag"), textMode : false, action : function(editor) { self.buttonPress(editor); } }); cfg.addToolbarElement("edittag", "htmlmode",1); } EditTag._pluginInfo = { name : "EditTag", version : "1.0", developer : "Pegoraro Marco", developer_url : "http://www.sin-italia.com/", c_owner : "Marco Pegoraro", sponsor : "Sin Italia", sponsor_url : "http://www.sin-italia.com/", license : "htmlArea" }; EditTag.prototype._lc = function(string) { return Xinha._lc(string, 'EditTag'); }; EditTag.prototype.buttonPress = function(editor) { // Costruzione dell'oggetto parametri da passare alla dialog. outparam = { content : editor.getSelectedHTML() }; // Fine costruzione parametri per il passaggio alla dialog. editor._popupDialog( "plugin://EditTag/edit_tag", function( html ) { if ( !html ) { //user must have pressed Cancel return false; } editor.insertHTML( html ); }, outparam); };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/EditTag.js
JavaScript
art
1,788
// I18N constants // LANG: "nl", ENCODING: UTF-8 // Author: Maarten Molenschot, maarten@nrgmm.nl { "Edit HTML for selected text": "HTML bewerken voor geselecteerde tekst", "Tag Editor": "HTML tag Editor" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/lang/nl.js
JavaScript
art
218
// I18N constants // LANG: "de", ENCODING: UTF-8 // translated: Udo Schmal (gocher), http://www.schaffrath-neuemedien.de/, udo.schmal@t-online.de { "Edit HTML for selected text": "HTML im ausgewählten Bereich bearbeiten", "Tag Editor": "HTML tag Editor" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/lang/de.js
JavaScript
art
262
// I18N constants // LANG: "fr", ENCODING: UTF-8 { "Edit HTML for selected text": "Editer le code HTML du texte sélectionné", "Tag Editor": "Editeur de tag HTML" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/lang/fr.js
JavaScript
art
175
// I18N constants // LANG: "ja", ENCODING: UTF-8 { "Edit HTML for selected text": "選択中テキストのHTMLを編集します", "Tag Editor": "タグエディタ" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/lang/ja.js
JavaScript
art
173
// I18N constants // LANG: "nb", ENCODING: UTF-8 // translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com { "Edit HTML for selected text": "Rediger HTML for den valgte teksten" };
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/lang/nb.js
JavaScript
art
199
// I18N constants // LANG: "pt_br", ENCODING: UTF-8 // Portuguese Brazilian Translation // Author: Marcio Barbosa, <marcio@mpg.com.br> // MSN: tomarshall@msn.com - ICQ: 69419933 // Site: http://www.mpg.com.br // Last revision: 05 september 2007 // Please don´t remove this information // If you modify any source, please insert a comment with your name and e-mail // Distributed under the same terms as HTMLArea itself. // This notice MUST stay intact for use (see license.txt). { "Cancel": "Cancelar", "Edit HTML for selected text": "Editar HTML para texto selecionado", "Edit Tag By Peg": "Editar Tag por Peg", "OK": "OK", "Tag Editor": "Editor de Tag" }
zzh-simple-hr
ZJs/webapp/html-editor/XinHa/plugins/EditTag/lang/pt_br.js
JavaScript
art
675