From 5aedce1521db51e0580dc7c394a64ebd1b655534 Mon Sep 17 00:00:00 2001 From: rob1n Date: Mon, 28 May 2007 19:30:05 +0000 Subject: [PATCH] Update TinyMCE to 2.1.1.1 (look at all those 1's...). fixes #4262 git-svn-id: http://svn.automattic.com/wordpress/trunk@5577 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/tinymce/license.html | 465 -- .../plugins/inlinepopups/editor_plugin.js | 17 +- .../themes/advanced/css/editor_popup.css | 2 +- .../themes/advanced/editor_template.js | 102 +- .../js/tinymce/themes/advanced/image.htm | 16 +- .../themes/advanced/jscripts/color_picker.js | 13 +- .../tinymce/themes/advanced/jscripts/link.js | 14 +- .../js/tinymce/themes/advanced/langs/en.js | 8 +- .../js/tinymce/themes/advanced/link.htm | 5 +- .../tinymce/themes/advanced/source_editor.htm | 4 +- wp-includes/js/tinymce/tiny_mce.js | 4029 +++++++++-------- wp-includes/js/tinymce/tiny_mce_popup.js | 54 +- wp-includes/script-loader.php | 4 +- 13 files changed, 2157 insertions(+), 2576 deletions(-) delete mode 100644 wp-includes/js/tinymce/license.html diff --git a/wp-includes/js/tinymce/license.html b/wp-includes/js/tinymce/license.html deleted file mode 100644 index c0c9c9ad5..000000000 --- a/wp-includes/js/tinymce/license.html +++ /dev/null @@ -1,465 +0,0 @@ - - - -TinyMCE License (LGPL) - - - - -
-

TinyMCE License (LGPL)

-
- -
-

-Visit the FAQ for general answers surrounding TinyMCE. Or visit http://www.fsf.org for more information about Open-Source licenses. -

-
-		  GNU LIBRARY GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL.  It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it.  You can use it for
-your libraries, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library.  If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-.
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software.  To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
-  Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs.  This
-license, the GNU Library General Public License, applies to certain
-designated libraries.  This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
-  The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it.  Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program.  However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
-  Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries.  We
-concluded that weaker conditions might promote sharing better.
-
-  However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves.  This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them.  (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.)  The hope is that this
-will lead to faster development of free libraries.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, while the latter only
-works together with the library.
-
-  Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-.
-		  GNU LIBRARY GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License").  Each licensee is
-addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-  
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-.
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-.
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-.
-  6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    c) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    d) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-.
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-.
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-.
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-			    NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-
- - - - - diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js index ffb623957..691703207 100644 --- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js @@ -1,5 +1,5 @@ /** - * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ + * $Id: editor_plugin_src.js 268 2007-04-28 15:52:59Z spocke $ * * Moxiecode DHTML Windows script. * @@ -82,22 +82,28 @@ TinyMCE_Engine.prototype.openWindow = function(template, args) { // Center div in editor area pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2)); pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2)); - - url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; // WordPress cache buster + + // WordPress cache buster + url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : ''; mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop + ",minWidth=" + minWidth + ",minHeight=" + minHeight ); }; TinyMCE_Engine.prototype.closeWindow = function(win) { var gotit = false, n, w; + for (n in mcWindows.windows) { w = mcWindows.windows[n]; - if (typeof(w) == 'function') continue; + + if (typeof(w) == 'function') + continue; + if (win.name == w.id + '_iframe') { w.close(); gotit = true; } } + if (!gotit) this.orgCloseWindow(win); @@ -392,7 +398,10 @@ TinyMCE_Windows.prototype.open = function(url, name, features) { html += ''; html += ''; html += 'Wrapper iframe'; + + // WordPress: put the window buttons on the left as in Macs if (this.isMac) html += ''; + html += ''; html += ''; html += ''; diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css index 079470c65..e7853e4d8 100644 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css @@ -355,4 +355,4 @@ input.invalid { border: 1px solid #EE0000; } #styleSelectRow { display: none; -} +} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js index b8e368523..be0e234ee 100644 --- a/wp-includes/js/tinymce/themes/advanced/editor_template.js +++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js @@ -1,5 +1,5 @@ /** - * $Id: editor_template_src.js 218 2007-02-13 11:08:01Z spocke $ + * $Id: editor_template_src.js 256 2007-04-24 09:03:20Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. @@ -140,10 +140,10 @@ var TinyMCE_AdvancedTheme = { case "|": case "separator": - return ''; + return ''; case "spacer": - return ''; + return ''; case "rowseparator": return '
'; @@ -1242,7 +1242,7 @@ var TinyMCE_AdvancedTheme = { if (set_w) tableElm.style.width = w + "px"; - + if ( !tinyMCE.isMSIE || tinyMCE.isMSIE7 || tinyMCE.isOpera ) // WordPress: do this later to avoid creeping toolbar bug in MSIE6 tableElm.style.height = h + "px"; @@ -1251,8 +1251,8 @@ var TinyMCE_AdvancedTheme = { iw = iw < 1 ? 30 : iw; ih = ih < 1 ? 30 : ih; - -/* WordPress found that this led to a shrinking editor with every resize. (Gray background creeps in 1px at a time.) +/* WordPress: found that this led to a shrinking editor with every resize. + (Gray background creeps in 1px at a time.) if (tinyMCE.isGecko) { iw -= 2; ih -= 2; @@ -1274,7 +1274,7 @@ var TinyMCE_AdvancedTheme = { inst.iframeElement.style.width = (iw + dx) + "px"; } } - + tableElm.style.height = h + "px"; // WordPress: see above // Remove pesky table controls @@ -1404,7 +1404,7 @@ var TinyMCE_AdvancedTheme = { h += ''; if (tinyMCE.getParam("theme_advanced_more_colors", true)) - h += '' + tinyMCE.getLang('lang_more_colors') + ''; + h += '' + tinyMCE.getLang('lang_more_colors') + ''; return h; }, @@ -1424,78 +1424,20 @@ var TinyMCE_AdvancedTheme = { }, _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) { - tinyMCE.execCommand('mceBeginUndoLevel'); - - if (src == "") - return; - - if (!tinyMCE.imgElement && tinyMCE.isSafari) { - var html = ""; - - html += '' + alt + ''; - - tinyMCE.execCommand("mceInsertContent", false, html); - } else { - if (!tinyMCE.imgElement && tinyMCE.selectedInstance) { - if (tinyMCE.isSafari) - tinyMCE.execCommand("mceInsertContent", false, ''); - else - tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL); - - tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL); - } - } - - if (tinyMCE.imgElement) { - var needsRepaint = false; - var msrc = src; - - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);"); - - if (tinyMCE.getParam('convert_urls')) - msrc = src; - - if (onmouseover && onmouseover != "") - onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';"; - - if (onmouseout && onmouseout != "") - onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';"; - - // Use alt as title if it's undefined - if (typeof(title) == "undefined") - title = alt; - - if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align")) - needsRepaint = true; - - tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src); - tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc); - tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt); - tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title); - tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align); - tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true); - tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover); - tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout); - - // Fix for bug #989846 - Image resize bug - if (width && width != "") - tinyMCE.imgElement.style.pixelWidth = width; - - if (height && height != "") - tinyMCE.imgElement.style.pixelHeight = height; - - if (needsRepaint) - tinyMCE.selectedInstance.repaint(); - } - - tinyMCE.execCommand('mceEndUndoLevel'); + tinyMCE.execCommand("mceInsertContent", false, tinyMCE.createTagHTML('img', { + src : tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src), // Force absolute + mce_src : src, + alt : alt, + border : border, + hspace : hspace, + vspace : vspace, + width : width, + height : height, + align : align, + title : title, + onmouseover : onmouseover, + onmouseout : onmouseout + })); }, _insertLink : function(href, target, title, onclick, style_class) { diff --git a/wp-includes/js/tinymce/themes/advanced/image.htm b/wp-includes/js/tinymce/themes/advanced/image.htm index 4826a8deb..bcebfb13d 100644 --- a/wp-includes/js/tinymce/themes/advanced/image.htm +++ b/wp-includes/js/tinymce/themes/advanced/image.htm @@ -7,6 +7,7 @@ +
@@ -22,7 +23,7 @@ - +
 
@@ -47,7 +48,7 @@ - + @@ -66,27 +67,28 @@ - + x - + - + - + - +
+
diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js index 78425e48d..6fe6b9039 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js @@ -153,7 +153,7 @@ function generateWebColors() { for (i=0; i' - + '' + + '' + '' + colors[i] +  ''; if ((i+1) % 18 == 0) h += ''; @@ -173,22 +173,13 @@ function generateNamedColors() { for (n in named) { v = named[n]; - h += '' + h += '' } el.innerHTML = h; el.className = 'generated'; } -function selectColor() { - var color = document.getElementById("color").value; - - if(window.opener) - window.opener.tinyMCE.execInstanceCommand(tinyMCE.getWindowArg('editor_id'),tinyMCE.getWindowArg('command'),false,color); - - window.close(); -} - function dechex(n) { return strhex.charAt(Math.floor(n / 16)) + strhex.charAt(n % 16); } diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js index 9adac22ca..36df14e45 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js @@ -24,10 +24,12 @@ function init() { if (option.value == tinyMCE.getWindowArg('target')) option.selected = true; } - + + // WordPress -- next 3 lines document.forms[0].href.value = tinyMCE.getWindowArg('href') || 'http://'; document.forms[0].href.select(); document.forms[0].href.focus(); + document.forms[0].linktitle.value = tinyMCE.getWindowArg('title'); document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); @@ -52,6 +54,14 @@ function init() { } } +function checkPrefix(n) { + if (Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCE.getLang('lang_is_email'))) + n.value = 'mailto:' + n.value; + + if (/^\s*www./i.test(n.value) && confirm(tinyMCE.getLang('lang_is_external'))) + n.value = 'http://' + n.value; +} + function insertLink() { var href = document.forms[0].href.value; var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value; @@ -61,7 +71,7 @@ function insertLink() { // WordPress: Make anchors absolute; if (href.charAt(0) == '#') - href = tinyMCE.settings['document_base_url'] + href; + href = tinyMCE.settings.document_base_url + href; if (target == '_self') target = ''; diff --git a/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js index 25726e72c..62e0053f1 100644 --- a/wp-includes/js/tinymce/themes/advanced/langs/en.js +++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js @@ -82,10 +82,12 @@ invalid_data : 'Error: Invalid values entered, these are marked in red.', more_colors : 'More colors', color_picker_tab : 'Picker', color_picker : 'Color picker', -web_colors_tab : 'Web safe', -web_colors : 'Web safe colors', +web_colors_tab : 'Palette', +web_colors : 'Palette colors', named_colors_tab : 'Named', named_colors : 'Named colors', color : 'Color:', -color_name : 'Name:' +color_name : 'Name:', +is_email : 'The URL you entered seems to be an email address, do you want to add the required mailto: prefix?', +is_external : 'The URL you entered seems to external link, do you want to add the required http:// prefix?' }); diff --git a/wp-includes/js/tinymce/themes/advanced/link.htm b/wp-includes/js/tinymce/themes/advanced/link.htm index 98d2f1716..54220b7db 100644 --- a/wp-includes/js/tinymce/themes/advanced/link.htm +++ b/wp-includes/js/tinymce/themes/advanced/link.htm @@ -4,9 +4,11 @@ + +
@@ -23,7 +25,7 @@ - +
 
@@ -87,6 +89,7 @@
+
diff --git a/wp-includes/js/tinymce/themes/advanced/source_editor.htm b/wp-includes/js/tinymce/themes/advanced/source_editor.htm index a3b82c968..bb3a79b00 100644 --- a/wp-includes/js/tinymce/themes/advanced/source_editor.htm +++ b/wp-includes/js/tinymce/themes/advanced/source_editor.htm @@ -6,6 +6,7 @@ +
{$lang_theme_code_title}
@@ -16,9 +17,10 @@
- +
+
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index e425a1ec0..0e83794a8 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -5,22 +5,23 @@ function TinyMCE_Engine() { var ua; this.majorVersion = "2"; - this.minorVersion = "1.0"; - this.releaseDate = "2007-02-13"; + this.minorVersion = "1.1.1"; + this.releaseDate = "2007-05-14"; - this.instances = new Array(); - this.switchClassCache = new Array(); - this.windowArgs = new Array(); - this.loadedFiles = new Array(); - this.pendingFiles = new Array(); + this.instances = []; + this.switchClassCache = []; + this.windowArgs = []; + this.loadedFiles = []; + this.pendingFiles = []; this.loadingIndex = 0; - this.configs = new Array(); + this.configs = []; this.currentConfig = 0; - this.eventHandlers = new Array(); - this.log = new Array(); + this.eventHandlers = []; + this.log = []; this.undoLevels = []; this.undoIndex = 0; this.typingUndoIndex = -1; + this.settings = []; // Browser check ua = navigator.userAgent; @@ -28,18 +29,18 @@ function TinyMCE_Engine() { this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1); - this.isGecko = ua.indexOf('Gecko') != -1; + this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari this.isSafari = ua.indexOf('Safari') != -1; - this.isOpera = ua.indexOf('Opera') != -1; + this.isOpera = window['opera'] && opera.buildNumber ? true : false; this.isMac = ua.indexOf('Mac') != -1; this.isNS7 = ua.indexOf('Netscape/7') != -1; this.isNS71 = ua.indexOf('Netscape/7.1') != -1; this.dialogCounter = 0; - this.plugins = new Array(); - this.themes = new Array(); - this.menus = new Array(); - this.loadedPlugins = new Array(); - this.buttonMap = new Array(); + this.plugins = []; + this.themes = []; + this.menus = []; + this.loadedPlugins = []; + this.buttonMap = []; this.isLoaded = false; // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those @@ -58,7 +59,7 @@ function TinyMCE_Engine() { TinyMCE_Engine.prototype = { init : function(settings) { - var theme, nl, baseHREF = "", i; + var theme, nl, baseHREF = "", i, cssPath, entities, h, p, src, elements = [], head; // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry. if (this.isMSIE5_0) @@ -72,7 +73,17 @@ TinyMCE_Engine.prototype = { // Get script base path if (!tinyMCE.baseURL) { - var elements = document.getElementsByTagName('script'); + // Search through head + head = document.getElementsByTagName('head')[0]; + + if (head) { + for (i=0, nl = head.getElementsByTagName('script'); i 0 && document.location.protocol != "file:") { p = h.indexOf('/', p + 3); h = h.substring(0, p); @@ -225,66 +237,54 @@ TinyMCE_Engine.prototype = { if (baseHREF.indexOf('://') == -1) baseHREF = h + baseHREF; - tinyMCE.settings['document_base_url'] = baseHREF; - tinyMCE.settings['document_base_prefix'] = h; + tinyMCE.settings.document_base_url = baseHREF; + tinyMCE.settings.document_base_prefix = h; } // Trim away query part if (baseHREF.indexOf('?') != -1) baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); - this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; + this.settings.base_href = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; - theme = this.settings['theme']; + theme = this.settings.theme; this.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment'; this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment'; - this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; + this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i"); - this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); + this.posKeyCodes = [13,45,36,35,33,34,37,38,39,40]; this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL this.uniqueTag = ''; - this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance'); + this.callbacks = ['onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance']; // Theme url - this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme; + this.settings.theme_href = tinyMCE.baseURL + "/themes/" + theme; if (!tinyMCE.isIE || tinyMCE.isOpera) - this.settings['force_br_newlines'] = false; + this.settings.force_br_newlines = false; if (tinyMCE.getParam("popups_css", false)) { - var cssPath = tinyMCE.getParam("popups_css", ""); + cssPath = tinyMCE.getParam("popups_css", ""); // Is relative if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['popups_css'] = this.documentBasePath + "/" + cssPath; + this.settings.popups_css = this.documentBasePath + "/" + cssPath; else - this.settings['popups_css'] = cssPath; + this.settings.popups_css = cssPath; } else - this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; + this.settings.popups_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; if (tinyMCE.getParam("editor_css", false)) { - var cssPath = tinyMCE.getParam("editor_css", ""); + cssPath = tinyMCE.getParam("editor_css", ""); // Is relative if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['editor_css'] = this.documentBasePath + "/" + cssPath; + this.settings.editor_css = this.documentBasePath + "/" + cssPath; else - this.settings['editor_css'] = cssPath; + this.settings.editor_css = cssPath; } else { - if (this.settings.editor_css != '') - this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; - } - - if (tinyMCE.settings['debug']) { - var msg = "Debug: \n"; - - msg += "baseURL: " + this.baseURL + "\n"; - msg += "documentBasePath: " + this.documentBasePath + "\n"; - msg += "content_css: " + this.settings['content_css'] + "\n"; - msg += "popups_css: " + this.settings['popups_css'] + "\n"; - msg += "editor_css: " + this.settings['editor_css'] + "\n"; - - alert(msg); + if (this.settings.editor_css !== '') + this.settings.editor_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; } // Only do this once @@ -304,14 +304,14 @@ TinyMCE_Engine.prototype = { } } - this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js'); - this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js'); - this.loadCSS(this.settings['editor_css']); + this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings.theme + '/editor_template' + tinyMCE.srcMode + '.js'); + this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings.language + '.js'); + this.loadCSS(this.settings.editor_css); // Add plugins - var p = tinyMCE.getParam('plugins', '', true, ','); + p = tinyMCE.getParam('plugins', '', true, ','); if (p.length > 0) { - for (var i=0; i&"\']', 'g'); this.xmlEncodeRe = new RegExp('[<>&"]', 'g'); -// this.xmlEncodeEnts = {'&':'&','"':'"',"'":''','<':'<','>':'>'}; }, _addUnloadEvents : function() { + var st = tinyMCE.settings.add_unload_trigger; + if (tinyMCE.isIE) { - if (tinyMCE.settings['add_unload_trigger']) { + if (st) { tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler); tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler); } } else { - if (tinyMCE.settings['add_unload_trigger']) + if (st) tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); } }, @@ -449,8 +450,7 @@ TinyMCE_Engine.prototype = { loadCSS : function(url) { var ar = url.replace(/\s+/, '').split(','); - var lflen = 0, csslen = 0; - var skip = false; + var lflen = 0, csslen = 0, skip = false; var x = 0, i = 0, nl, le; for (x = 0,csslen = ar.length; x", "gi"); content = tinyMCE.regexpReplace(content, "\r", "
", "gi"); content = tinyMCE.regexpReplace(content, "\n", "
", "gi"); @@ -951,10 +966,10 @@ TinyMCE_Engine.prototype = { // Ugly!!! window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500); - if (tinyMCE.settings["force_br_newlines"]) + if (tinyMCE.settings.force_br_newlines) doc.styleSheets[0].addRule("p", "margin: 0;"); - var body = inst.getBody(); + body = inst.getBody(); body.editorId = editor_id; } @@ -962,27 +977,27 @@ TinyMCE_Engine.prototype = { // Fix for bug #958637 if (!tinyMCE.isIE) { - var contentElement = inst.getDoc().createElement("body"); - var doc = inst.getDoc(); + contentElement = inst.getDoc().createElement("body"); + doc = inst.getDoc(); contentElement.innerHTML = content; - // Remove weridness! - if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) - content = content.replace(new RegExp('<>', 'g'), ""); - - if (tinyMCE.settings['cleanup_on_startup']) + if (tinyMCE.settings.cleanup_on_startup) tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); else tinyMCE.setInnerHTML(inst.getBody(), content); tinyMCE.convertAllRelativeURLs(inst.getBody()); } else { - if (tinyMCE.settings['cleanup_on_startup']) { + if (tinyMCE.settings.cleanup_on_startup) { tinyMCE._setHTML(inst.getDoc(), content); // Produces permission denied error in MSIE 5.5 - eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}'); + try { + tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody())); + } catch(e) { + // Ignore + } } else tinyMCE._setHTML(inst.getDoc(), content); } @@ -990,7 +1005,7 @@ TinyMCE_Engine.prototype = { // Fix for bug #957681 //inst.getDoc().designMode = inst.getDoc().designMode; - tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst); + tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings.visual, inst); tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); // Re-add design mode on mozilla @@ -1106,7 +1121,7 @@ TinyMCE_Engine.prototype = { }, handleEvent : function(e) { - var inst = tinyMCE.selectedInstance; + var inst = tinyMCE.selectedInstance, i, elm, keys; // Remove odd, error if (typeof(tinyMCE) == "undefined") @@ -1149,19 +1164,17 @@ TinyMCE_Engine.prototype = { } } - window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);tinyMCE._resetIframeHeight();", 1); + window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings.base_href);tinyMCE._resetIframeHeight();", 1); return; case "submit": - tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target); - tinyMCE.triggerSave(); - tinyMCE.isNotDirty = true; + tinyMCE.formSubmit(tinyMCE.isMSIE ? window.event.srcElement : e.target); return; case "reset": var formObj = tinyMCE.isIE ? window.event.srcElement : e.target; - for (var i=0; i'; - h += ''; + h += '{$'+lang+'}'; h += ''; } else { // Normal button h += ''; - h += ''; + h += '{$'+lang+'}'; h += ''; } @@ -1500,15 +1516,45 @@ TinyMCE_Engine.prototype = { this.buttonMap[a[i]] = i; }, + formSubmit : function(f, p) { + var n, inst, found = false; + + if (f.form) + f = f.form; + + // Is it a form that has a TinyMCE instance + for (n in tinyMCE.instances) { + inst = tinyMCE.instances[n]; + + if (!tinyMCE.isInstance(inst)) + continue; + + if (inst.formElement) { + if (f == inst.formElement.form) { + found = true; + inst.isNotDirty = true; + } + } + } + + // Is valid + if (found) { + tinyMCE.removeTinyMCEFormElements(f); + tinyMCE.triggerSave(); + } + + // Is it patched + if (f.mceOldSubmit && p) + f.mceOldSubmit(); + }, + submitPatch : function() { - tinyMCE.removeTinyMCEFormElements(this); - tinyMCE.triggerSave(); - tinyMCE.isNotDirty = true; - this.mceOldSubmit(); + tinyMCE.formSubmit(this, true); }, onLoad : function() { - var r; + var r, i, c, mode, trigger, elements, element, settings, elementId, elm; + var selector, deselector, elementRefAr, form; // Wait for everything to be loaded first if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) { @@ -1527,7 +1573,7 @@ TinyMCE_Engine.prototype = { // IE produces JS error if TinyMCE is placed in a frame // It seems to have something to do with the selection not beeing // correctly initialized in IE so this hack solves the problem - if (tinyMCE.isRealIE && document.body) { + if (tinyMCE.isRealIE && document.body && window.location.href != window.top.location.href) { r = document.body.createTextRange(); r.collapse(true); r.select(); @@ -1535,24 +1581,24 @@ TinyMCE_Engine.prototype = { tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad'); - for (var c=0; c 0); - if (tinyMCE.settings['custom_undo_redo']) { + if (tinyMCE.settings.custom_undo_redo) { undoIndex = inst.undoRedo.undoIndex; undoLevels = inst.undoRedo.undoLevels.length; } @@ -1756,15 +1799,15 @@ TinyMCE_Engine.prototype = { }, _customCleanup : function(inst, type, content) { - var pl, po, i; + var pl, po, i, customCleanup; // Call custom cleanup - var customCleanup = tinyMCE.settings['cleanup_callback']; - if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") - content = eval(customCleanup + "(type, content, inst);"); + customCleanup = tinyMCE.settings.cleanup_callback; + if (customCleanup != '') + content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst); // Trigger theme cleanup - po = tinyMCE.themes[tinyMCE.settings['theme']]; + po = tinyMCE.themes[tinyMCE.settings.theme]; if (po && po.cleanup) content = po.cleanup(type, content, inst); @@ -1789,9 +1832,9 @@ TinyMCE_Engine.prototype = { importThemeLanguagePack : function(name) { if (typeof(name) == "undefined") - name = tinyMCE.settings['theme']; + name = tinyMCE.settings.theme; - tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js'); + tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings.language + '.js'); }, importPluginLanguagePack : function(name) { @@ -1800,16 +1843,16 @@ TinyMCE_Engine.prototype = { if (this.plugins[name]) b = this.plugins[name].baseURL; - tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings['language'] + '.js'); + tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings.language + '.js'); }, - applyTemplate : function(h, as) { + applyTemplate : function(h, ag) { return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) { if (s.indexOf('lang_') == 0 && tinyMCELang[s]) return tinyMCELang[s]; - if (as && as[s]) - return as[s]; + if (ag && ag[s]) + return ag[s]; if (tinyMCE.settings[s]) return tinyMCE.settings[s]; @@ -1826,20 +1869,20 @@ TinyMCE_Engine.prototype = { }, openWindow : function(template, args) { - var html, width, height, x, y, resizable, scrollbars, url; + var html, width, height, x, y, resizable, scrollbars, url, name, win, modal, features; args = !args ? {} : args; - args['mce_template_file'] = template['file']; - args['mce_width'] = template['width']; - args['mce_height'] = template['height']; + args.mce_template_file = template.file; + args.mce_width = template.width; + args.mce_height = template.height; tinyMCE.windowArgs = args; - html = template['html']; - if (!(width = parseInt(template['width']))) + html = template.html; + if (!(width = parseInt(template.width))) width = 320; - if (!(height = parseInt(template['height']))) + if (!(height = parseInt(template.height))) height = 200; // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! @@ -1851,16 +1894,16 @@ TinyMCE_Engine.prototype = { x = parseInt(screen.width / 2.0) - (width / 2.0); y = parseInt(screen.height / 2.0) - (height / 2.0); - resizable = (args && args['resizable']) ? args['resizable'] : "no"; - scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; + resizable = (args && args.resizable) ? args.resizable : "no"; + scrollbars = (args && args.scrollbars) ? args.scrollbars : "no"; - if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1) - url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; + if (template.file.charAt(0) != '/' && template.file.indexOf('://') == -1) + url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template.file; else - url = template['file']; + url = template.file; // Replace all args as variables in URL - for (var name in args) { + for (name in args) { if (typeof(args[name]) == 'function') continue; @@ -1868,12 +1911,12 @@ TinyMCE_Engine.prototype = { } if (html) { - html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']); + html = tinyMCE.replaceVar(html, "css", this.settings.popups_css); html = tinyMCE.applyTemplate(html, args); - var win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); + win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); if (win == null) { - alert(tinyMCELang['lang_popup_blocked']); + alert(tinyMCELang.lang_popup_blocked); return; } @@ -1882,34 +1925,35 @@ TinyMCE_Engine.prototype = { win.resizeTo(width, height); win.focus(); } else { - if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") { + if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings.dialog_type == "modal") { height += 10; - var features = "resizable:" + resizable - + ";scroll:" - + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" - + width + "px;dialogHeight:" + height + "px;"; + features = "resizable:" + resizable + ";scroll:" + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;"; window.showModalDialog(url, window, features); } else { - var modal = (resizable == "yes") ? "no" : "yes"; + modal = (resizable == "yes") ? "no" : "yes"; if (tinyMCE.isGecko && tinyMCE.isMac) modal = "no"; - if (template['close_previous'] != "no") + if (template.close_previous != "no") try {tinyMCE.lastWindow.close();} catch (ex) {} - var win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable); + win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable); if (win == null) { - alert(tinyMCELang['lang_popup_blocked']); + alert(tinyMCELang.lang_popup_blocked); return; } - if (template['close_previous'] != "no") + if (template.close_previous != "no") tinyMCE.lastWindow = win; - eval('try { win.resizeTo(width, height); } catch(e) { }'); + try { + win.resizeTo(width, height); + } catch(e) { + // Ignore + } // Make it bigger if statusbar is forced if (tinyMCE.isGecko) { @@ -1927,19 +1971,19 @@ TinyMCE_Engine.prototype = { }, getVisualAidClass : function(class_name, state) { - var aidClass = tinyMCE.settings['visual_table_class']; + var i, classNames, ar, className, aidClass = tinyMCE.settings.visual_table_class; if (typeof(state) == "undefined") - state = tinyMCE.settings['visual']; + state = tinyMCE.settings.visual; // Split - var classNames = new Array(); - var ar = class_name.split(' '); - for (var i=0; i 0) className += " "; @@ -1959,30 +2003,32 @@ TinyMCE_Engine.prototype = { }, handleVisualAid : function(el, deep, state, inst, skip_dispatch) { + var i, x, y, tableElement, anchorName, oldW, oldH, bo, cn; + if (!el) return; if (!skip_dispatch) tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst); - var tableElement = null; + tableElement = null; switch (el.nodeName) { case "TABLE": - var oldW = el.style.width; - var oldH = el.style.height; - var bo = tinyMCE.getAttrib(el, "border"); + oldW = el.style.width; + oldH = el.style.height; + bo = tinyMCE.getAttrib(el, "border"); - bo = bo == "" || bo == "0" ? true : false; + bo = bo == '' || bo == "0" ? true : false; tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); el.style.width = oldW; el.style.height = oldH; - for (var y=0; y', 'gi'), ''); @@ -2112,11 +2127,12 @@ TinyMCE_Engine.prototype = { } // Content duplication bug fix - if (tinyMCE.isIE && tinyMCE.settings['fix_content_duplication']) { + if (tinyMCE.isIE && tinyMCE.settings.fix_content_duplication) { // Remove P elements in P elements - var paras = doc.getElementsByTagName("P"); - for (var i=0; i<\/o:p>", "
"); - html = tinyMCE.regexpReplace(html, " <\/o:p>", ""); - html = tinyMCE.regexpReplace(html, "", ""); - html = tinyMCE.regexpReplace(html, "

<\/p>", ""); - html = tinyMCE.regexpReplace(html, "

<\/p>\r\n

<\/p>", ""); - html = tinyMCE.regexpReplace(html, "

 <\/p>", "
"); - html = tinyMCE.regexpReplace(html, "

\s*(

\s*)?", "

"); - html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "

"); - }*/ + html = doc.body.innerHTML; // Always set the htmlText output tinyMCE.setInnerHTML(doc.body, html); @@ -2156,6 +2154,7 @@ TinyMCE_Engine.prototype = { getEditorId : function(form_element) { var inst = this.getInstanceById(form_element); + if (!inst) return null; @@ -2163,25 +2162,27 @@ TinyMCE_Engine.prototype = { }, getInstanceById : function(editor_id) { - var inst = this.instances[editor_id]; + var inst = this.instances[editor_id], n; + if (!inst) { - for (var n in tinyMCE.instances) { - var instance = tinyMCE.instances[n]; - if (!tinyMCE.isInstance(instance)) + for (n in tinyMCE.instances) { + inst = tinyMCE.instances[n]; + + if (!tinyMCE.isInstance(inst)) continue; - if (instance.formTargetElementId == editor_id) { - inst = instance; - break; - } + if (inst.formTargetElementId == editor_id) + return inst; } - } + } else + return inst; - return inst; + return null; }, queryInstanceCommandValue : function(editor_id, command) { var inst = tinyMCE.getInstanceById(editor_id); + if (inst) return inst.queryCommandValue(command); @@ -2190,6 +2191,7 @@ TinyMCE_Engine.prototype = { queryInstanceCommandState : function(editor_id, command) { var inst = tinyMCE.getInstanceById(editor_id); + if (inst) return inst.queryCommandState(command); @@ -2205,76 +2207,72 @@ TinyMCE_Engine.prototype = { }, getCSSClasses : function(editor_id, doc) { - var inst = tinyMCE.getInstanceById(editor_id); + var i, c, x, rule, styles, rules, csses, selectorText, inst = tinyMCE.getInstanceById(editor_id); + var cssClass, addClass, p; + + if (!inst) + inst = tinyMCE.selectedInstance; + + if (!inst) + return []; + + if (!doc) + doc = inst.getDoc(); // Is cached, use that if (inst && inst.cssClasses.length > 0) return inst.cssClasses; - if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") { - var instance; + if (!doc) + return; - for (var instanceName in tinyMCE.instances) { - instance = tinyMCE.instances[instanceName]; - if (!tinyMCE.isInstance(instance)) - continue; + styles = doc.styleSheets; - break; - } + if (styles && styles.length > 0) { + for (x=0; x 0) { - for (var x=0; x' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + ''; @@ -2324,8 +2325,8 @@ TinyMCE_Engine.prototype = { } } - o = tinyMCE.themes[tinyMCE.settings['theme']]; - if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { + o = tinyMCE.themes[tinyMCE.settings.theme]; + if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') { if (rtl) return '' + v + ''; @@ -2361,7 +2362,7 @@ TinyMCE_Engine.prototype = { l = tinyMCE.getParam(p, ''); - if (l != '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) + if (l !== '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) return true; if (ins != null) { @@ -2384,8 +2385,20 @@ TinyMCE_Engine.prototype = { return false; }, - xmlEncode : function(s, skip_apos) { - return s ? ('' + s).replace(!skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe, function (c, b) { + resolveDots : function(s, o) { + var i; + + if (typeof(s) == 'string') { + for (i=0, s=s.split('.'); i 0) { for (i=0; i 1 && tinyMCE.currentConfig != this.settings['index']) { + if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings.index) { tinyMCE.settings = this.settings; - tinyMCE.currentConfig = this.settings['index']; + tinyMCE.currentConfig = this.settings.index; } }, @@ -2709,10 +2727,12 @@ TinyMCE_Control.prototype = { isDirty : function() { // Is content modified and not in a submit procedure - return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty; + return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !this.isNotDirty; }, _mergeElements : function(scmd, pa, ch, override) { + var st, stc, className, n; + if (scmd == "removeformat") { pa.className = ""; pa.style.cssText = ""; @@ -2721,22 +2741,22 @@ TinyMCE_Control.prototype = { return; } - var st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style")); - var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style")); - var className = tinyMCE.getAttrib(pa, "class"); + st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style")); + stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style")); + className = tinyMCE.getAttrib(pa, "class"); // Removed class adding due to bug #1478272 className = tinyMCE.getAttrib(ch, "class"); if (override) { - for (var n in st) { + for (n in st) { if (typeof(st[n]) == 'function') continue; stc[n] = st[n]; } } else { - for (var n in stc) { + for (n in stc) { if (typeof(stc[n]) == 'function') continue; @@ -2752,6 +2772,55 @@ TinyMCE_Control.prototype = { ch.removeAttribute("style"); }, + _fixRootBlocks : function() { + var rb, b, ne, be, nx, bm; + + rb = tinyMCE.getParam('forced_root_block'); + if (!rb) + return; + + b = this.getBody(); + ne = b.firstChild; + + while (ne) { + nx = ne.nextSibling; + + // If text node or inline element wrap it in a block element + if (ne.nodeType == 3 || !tinyMCE.blockRegExp.test(ne.nodeName)) { + if (!bm) + bm = this.selection.getBookmark(); + + if (!be) { + be = this.getDoc().createElement(rb); + be.appendChild(ne.cloneNode(true)); + b.replaceChild(be, ne); + } else { + be.appendChild(ne.cloneNode(true)); + b.removeChild(ne); + } + } else + be = null; + + ne = nx; + } + + if (bm) + this.selection.moveToBookmark(bm); + }, + + _fixTrailingNbsp : function() { + var s = this.selection, e = s.getFocusElement(), bm, v; + + if (e && tinyMCE.blockRegExp.test(e.nodeName) && e.firstChild) { + v = e.firstChild.nodeValue; + + if (v && v.length > 1 && /(^\u00a0|\u00a0$)/.test(v)) { + e.firstChild.nodeValue = v.replace(/(^\u00a0|\u00a0$)/, ''); + s.selectNode(e.firstChild, true, false, false); // Select and collapse + } + } + }, + _setUseCSS : function(b) { var d = this.getDoc(); @@ -2766,7 +2835,7 @@ TinyMCE_Control.prototype = { }, execCommand : function(command, user_interface, value) { - var doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement(); + var i, x, z, align, img, div, doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement(); // Is not a undo specific command if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) @@ -2789,8 +2858,8 @@ TinyMCE_Control.prototype = { // Fix align on images if (focusElm && focusElm.nodeName == "IMG") { - var align = focusElm.getAttribute('align'); - var img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm; + align = focusElm.getAttribute('align'); + img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm; switch (command) { case "JustifyLeft": @@ -2800,7 +2869,7 @@ TinyMCE_Control.prototype = { img.setAttribute('align', 'left'); // Remove the div - var div = focusElm.parentNode; + div = focusElm.parentNode; if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) div.parentNode.replaceChild(img, div); @@ -2813,14 +2882,14 @@ TinyMCE_Control.prototype = { img.removeAttribute('align'); // Is centered - var div = tinyMCE.getParentElement(focusElm, "div"); + div = tinyMCE.getParentElement(focusElm, "div"); if (div && div.style.textAlign == "center") { // Remove div if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) div.parentNode.replaceChild(img, div); } else { // Add div - var div = this.getDoc().createElement("div"); + div = this.getDoc().createElement("div"); div.style.textAlign = 'center'; div.appendChild(img); focusElm.parentNode.replaceChild(div, focusElm); @@ -2838,7 +2907,7 @@ TinyMCE_Control.prototype = { img.setAttribute('align', 'right'); // Remove the div - var div = focusElm.parentNode; + div = focusElm.parentNode; if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) div.parentNode.replaceChild(img, div); @@ -2849,7 +2918,7 @@ TinyMCE_Control.prototype = { } } - if (tinyMCE.settings['force_br_newlines']) { + if (tinyMCE.settings.force_br_newlines) { var alignValue = ""; if (doc.selection.type != "Control") { @@ -2871,7 +2940,7 @@ TinyMCE_Control.prototype = { break; } - if (alignValue != "") { + if (alignValue !== '') { var rng = doc.selection.createRange(); if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) @@ -2925,7 +2994,7 @@ TinyMCE_Control.prototype = { break; case "FormatBlock": - if (value == null || value == "") { + if (value == null || value == '') { var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp"); if (elm) @@ -2970,7 +3039,7 @@ TinyMCE_Control.prototype = { case "mceSelectNodeDepth": var parentNode = this.getFocusElement(); - for (var i=0; parentNode; i++) { + for (i=0; parentNode; i++) { if (parentNode.nodeName.toLowerCase() == "body") break; @@ -2996,14 +3065,14 @@ TinyMCE_Control.prototype = { case "SetStyleInfo": var rng = this.getRng(); var sel = this.getSel(); - var scmd = value['command']; - var sname = value['name']; - var svalue = value['value'] == null ? '' : value['value']; + var scmd = value.command; + var sname = value.name; + var svalue = value.value == null ? '' : value.value; //var svalue = value['value'] == null ? '' : value['value']; - var wrapper = value['wrapper'] ? value['wrapper'] : "span"; + var wrapper = value.wrapper ? value.wrapper : "span"; var parentElm = null; var invalidRe = new RegExp("^BODY|HTML$", "g"); - var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null; + var invalidParentsRe = tinyMCE.settings.merge_styles_invalid_parents !== '' ? new RegExp(tinyMCE.settings.merge_styles_invalid_parents, "gi") : null; // Whole element selected check if (tinyMCE.isIE) { @@ -3022,7 +3091,7 @@ TinyMCE_Control.prototype = { } } else { var felm = this.getFocusElement(); - if (sel.isCollapsed || (new RegExp('td|tr|tbody|table', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode)) + if (sel.isCollapsed || (new RegExp('td|tr|tbody|table|img', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode)) parentElm = felm; } @@ -3040,8 +3109,8 @@ TinyMCE_Control.prototype = { } // Remove style/attribs from all children - var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1); - for (var z=0; z=0; i--) { + for (i=nodes.length-1; i>=0; i--) { var elm = nodes[i]; var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; @@ -3132,9 +3201,8 @@ TinyMCE_Control.prototype = { // Remove empty wrappers var nodes = doc.getElementsByTagName(wrapper); - for (var i=nodes.length-1; i>=0; i--) { - var elm = nodes[i]; - var isEmpty = true; + for (i=nodes.length-1; i>=0; i--) { + var elm = nodes[i], isEmpty = true; // Check if it has any attribs var tmp = doc.createElement("body"); @@ -3144,7 +3212,7 @@ TinyMCE_Control.prototype = { tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); //tinyMCE.debug(tmp.innerHTML); if (new RegExp('', 'gi').test(tmp.innerHTML)) { - for (var x=0; x' + editorTemplate['html']; + deltaWidth = editorTemplate.delta_width ? editorTemplate.delta_width : 0; + deltaHeight = editorTemplate.delta_height ? editorTemplate.delta_height : 0; + html = '' + editorTemplate.html; html = tinyMCE.replaceVar(html, "editor_id", this.editorId); - this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm"; - this.settings['old_width'] = this.settings['width']; - this.settings['old_height'] = this.settings['height']; + if (!this.settings.default_document) + this.settings.default_document = tinyMCE.baseURL + "/blank.htm"; + + this.settings.old_width = this.settings.width; + this.settings.old_height = this.settings.height; // Set default width, height - if (this.settings['width'] == -1) - this.settings['width'] = replace_element.offsetWidth; + if (this.settings.width == -1) + this.settings.width = replace_element.offsetWidth; - if (this.settings['height'] == -1) - this.settings['height'] = replace_element.offsetHeight; + if (this.settings.height == -1) + this.settings.height = replace_element.offsetHeight; // Try the style width - if (this.settings['width'] == 0) - this.settings['width'] = replace_element.style.width; + if (this.settings.width == 0) + this.settings.width = replace_element.style.width; // Try the style height - if (this.settings['height'] == 0) - this.settings['height'] = replace_element.style.height; + if (this.settings.height == 0) + this.settings.height = replace_element.style.height; // If no width/height then default to 320x240, better than nothing - if (this.settings['width'] == 0) - this.settings['width'] = 320; + if (this.settings.width == 0) + this.settings.width = 320; - if (this.settings['height'] == 0) - this.settings['height'] = 240; + if (this.settings.height == 0) + this.settings.height = 240; - this.settings['area_width'] = parseInt(this.settings['width']); - this.settings['area_height'] = parseInt(this.settings['height']); - this.settings['area_width'] += deltaWidth; - this.settings['area_height'] += deltaHeight; - - this.settings['width_style'] = "" + this.settings['width']; - this.settings['height_style'] = "" + this.settings['height']; + this.settings.area_width = parseInt(this.settings.width); + this.settings.area_height = parseInt(this.settings.height); + this.settings.area_width += deltaWidth; + this.settings.area_height += deltaHeight; + this.settings.width_style = "" + this.settings.width; + this.settings.height_style = "" + this.settings.height; // Special % handling - if (("" + this.settings['width']).indexOf('%') != -1) - this.settings['area_width'] = "100%"; + if (("" + this.settings.width).indexOf('%') != -1) + this.settings.area_width = "100%"; else - this.settings['width_style'] += 'px'; + this.settings.width_style += 'px'; - if (("" + this.settings['height']).indexOf('%') != -1) - this.settings['area_height'] = "100%"; + if (("" + this.settings.height).indexOf('%') != -1) + this.settings.area_height = "100%"; else - this.settings['height_style'] += 'px'; + this.settings.height_style += 'px'; if (("" + replace_element.style.width).indexOf('%') != -1) { - this.settings['width'] = replace_element.style.width; - this.settings['area_width'] = "100%"; - this.settings['width_style'] = "100%"; + this.settings.width = replace_element.style.width; + this.settings.area_width = "100%"; + this.settings.width_style = "100%"; } if (("" + replace_element.style.height).indexOf('%') != -1) { - this.settings['height'] = replace_element.style.height; - this.settings['area_height'] = "100%"; - this.settings['height_style'] = "100%"; + this.settings.height = replace_element.style.height; + this.settings.area_height = "100%"; + this.settings.height_style = "100%"; } html = tinyMCE.applyTemplate(html); - this.settings['width'] = this.settings['old_width']; - this.settings['height'] = this.settings['old_height']; + this.settings.width = this.settings.old_width; + this.settings.height = this.settings.old_height; - this.visualAid = this.settings['visual']; + this.visualAid = this.settings.visual; this.formTargetElementId = form_element_name; // Get replace_element contents @@ -3716,13 +3794,9 @@ TinyMCE_Control.prototype = { this.oldTargetElement = replace_element; // Debug mode - if (tinyMCE.settings['debug']) { - hc = ''; - } else { - hc = ''; - this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); - this.oldTargetElement.style.display = "none"; - } + hc = ''; + this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); + this.oldTargetElement.style.display = "none"; html += ''; @@ -3733,10 +3807,10 @@ TinyMCE_Control.prototype = { // Output HTML and set editable if (tinyMCE.isGecko) { - var rng = replace_element.ownerDocument.createRange(); + rng = replace_element.ownerDocument.createRange(); rng.setStartBefore(replace_element); - var fragment = rng.createContextualFragment(html); + fragment = rng.createContextualFragment(html); tinyMCE.insertAfter(fragment, replace_element); } else replace_element.insertAdjacentHTML("beforeBegin", html); @@ -3746,25 +3820,23 @@ TinyMCE_Control.prototype = { // Just hide the textarea element this.oldTargetElement = replace_element; - if (!tinyMCE.settings['debug']) { - this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); - this.oldTargetElement.style.display = "none"; - } + this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); + this.oldTargetElement.style.display = "none"; // Output HTML and set editable if (tinyMCE.isGecko) { - var rng = replace_element.ownerDocument.createRange(); + rng = replace_element.ownerDocument.createRange(); rng.setStartBefore(replace_element); - var fragment = rng.createContextualFragment(html); + fragment = rng.createContextualFragment(html); tinyMCE.insertAfter(fragment, replace_element); } else replace_element.insertAdjacentHTML("beforeBegin", html); } // Setup iframe - var dynamicIFrame = false; - var tElm = targetDoc.getElementById(this.editorId); + dynamicIFrame = false; + tElm = targetDoc.getElementById(this.editorId); if (!tinyMCE.isIE) { // Node case is preserved in XML strict mode @@ -3801,9 +3873,9 @@ TinyMCE_Control.prototype = { } // Setup base HTML - var doc = this.contentDocument; + doc = this.contentDocument; if (dynamicIFrame) { - var html = tinyMCE.getParam('doctype') + 'blank_page'; + html = tinyMCE.getParam('doctype') + 'blank_page'; try { if (!this.isHidden()) @@ -3824,7 +3896,7 @@ TinyMCE_Control.prototype = { window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1); // Setup element references - var parentElm = this.targetDoc.getElementById(this.editorId + '_parent'); + parentElm = this.targetDoc.getElementById(this.editorId + '_parent'); this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; tinyMCE.setupContent(this.editorId, true); @@ -3847,7 +3919,7 @@ TinyMCE_Control.prototype = { b.setAttribute('href', u); h.appendChild(b); } else { - if (u == "" || u == null) + if (u == '' || u == null) b.parentNode.removeChild(b); else b.setAttribute('href', u); @@ -3886,7 +3958,10 @@ TinyMCE_Control.prototype = { }, triggerSave : function(skip_cleanup, skip_callback) { - var e, nl = [], i, s; + var e, nl = [], i, s, content, htm; + + if (!this.enabled) + return; this.switchSettings(); s = tinyMCE.settings; @@ -3908,7 +3983,7 @@ TinyMCE_Control.prototype = { } while ((e = e.parentNode) != null) } - tinyMCE.settings['preformatted'] = false; + tinyMCE.settings.preformatted = false; // Default to false if (typeof(skip_cleanup) == "undefined") @@ -3921,17 +3996,17 @@ TinyMCE_Control.prototype = { tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML); // Remove visual aids when cleanup is disabled - if (this.settings['cleanup'] == false) { + if (this.settings.cleanup == false) { tinyMCE.handleVisualAid(this.getBody(), true, false, this); tinyMCE._setEventsEnabled(this.getBody(), true); } tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body); - var htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true); + htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true); htm = tinyMCE._customCleanup(this, "submit_content", htm); - if (!skip_callback && tinyMCE.settings['save_callback'] != "") - var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());"); + if (!skip_callback && tinyMCE.settings.save_callback !== '') + content = tinyMCE.resolveDots(tinyMCE.settings.save_callback, window)(this.formTargetElementId,htm,this.getBody()); // Use callback content if available if ((typeof(content) != "undefined") && content != null) @@ -3963,444 +4038,441 @@ TinyMCE_Control.prototype = { /* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */ -TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) { - s = s.replace(new RegExp('

', 'gi'), '

 

'); - s = s.replace(new RegExp('

\\s*<\\/p>', 'gi'), '

 

'); +tinyMCE.add(TinyMCE_Engine, { + cleanupHTMLCode : function(s) { + s = s.replace(new RegExp('

', 'gi'), '

 

'); + s = s.replace(new RegExp('

\\s*<\\/p>', 'gi'), '

 

'); - // Fix close BR elements - s = s.replace(new RegExp('
\\s*<\\/br>', 'gi'), '
'); + // Fix close BR elements + s = s.replace(new RegExp('
\\s*<\\/br>', 'gi'), '
'); - // Open closed tags like to - s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3>'); + // Open closed tags like to + s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3>'); - // Remove trailing space to - s = s.replace(new RegExp('\\s+> to + s = s.replace(new RegExp('\\s+> to - s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />'); + // Close tags to + s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />'); - // Weird MSIE bug,


breaks runtime? - if (tinyMCE.isIE) - s = s.replace(new RegExp('


<\\/p>', 'gi'), "
"); + // Weird MSIE bug,


breaks runtime? + if (tinyMCE.isIE) + s = s.replace(new RegExp('


<\\/p>', 'gi'), "
"); - // Weird tags will make IE error #bug: 1538495 - if (tinyMCE.isIE) - s = s.replace(//g, ''); + // Weird tags will make IE error #bug: 1538495 + if (tinyMCE.isIE) + s = s.replace(//g, ''); - // Convert relative anchors to absolute URLs ex: #something to file.htm#something - // Removed: Since local document anchors should never be forced absolute example edit.php?id=something - //if (tinyMCE.getParam('convert_urls')) - // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#"); + // Convert relative anchors to absolute URLs ex: #something to file.htm#something + // Removed: Since local document anchors should never be forced absolute example edit.php?id=something + //if (tinyMCE.getParam('convert_urls')) + // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings.document_base_url + "#"); - return s; -}; + return s; + }, -TinyMCE_Engine.prototype.parseStyle = function(str) { - var ar = new Array(); + parseStyle : function(str) { + var ar = [], st, i, re, pa; + + if (str == null) + return ar; + + st = str.split(';'); + + tinyMCE.clearArray(ar); + + for (i=0; i 1) - val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')"; - } - - // Force HEX colors - if (tinyMCE.getParam("force_hex_style_colors")) - val = tinyMCE.convertRGBToHex(val, true); - - val = val.replace(/\"/g, '\''); - - if (val != "url('')") - str += key.toLowerCase() + ": " + val + "; "; - } - } - - if (new RegExp('; $').test(str)) - str = str.substring(0, str.length - 2); - - return str; -}; - -TinyMCE_Engine.prototype.convertRGBToHex = function(s, k) { - if (s.toLowerCase().indexOf('rgb') != -1) { - var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); - var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); - if (rgb.length == 5) { - r = parseInt(rgb[1]).toString(16); - g = parseInt(rgb[2]).toString(16); - b = parseInt(rgb[3]).toString(16); - - r = r.length == 1 ? '0' + r : r; - g = g.length == 1 ? '0' + g : g; - b = b.length == 1 ? '0' + b : b; - - s = "#" + r + g + b; - - if (k) - s = rgb[0] + s + rgb[4]; - } - } - - return s; -}; - -TinyMCE_Engine.prototype.convertHexToRGB = function(s) { - if (s.indexOf('#') != -1) { - s = s.replace(new RegExp('[^0-9A-F]', 'gi'), ''); - return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")"; - } - - return s; -}; - -TinyMCE_Engine.prototype.convertSpansToFonts = function(doc) { - var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); - - /*var h = doc.body.innerHTML; - h = h.replace(/ 0) { - tinyMCE.setAttrib(s[i], 'size', fSize); - s[i].style.fontSize = ''; + // They are all the same + ar[res] = box[0]; + ar[pr + '-top' + sf] = null; + ar[pr + '-left' + sf] = null; + ar[pr + '-right' + sf] = null; + ar[pr + '-bottom' + sf] = null; + }, + + serializeStyle : function(ar) { + var str = "", key, val, m; + + // Compress box + tinyMCE.compressStyle(ar, "border", "", "border"); + tinyMCE.compressStyle(ar, "border", "-width", "border-width"); + tinyMCE.compressStyle(ar, "border", "-color", "border-color"); + tinyMCE.compressStyle(ar, "border", "-style", "border-style"); + tinyMCE.compressStyle(ar, "padding", "", "padding"); + tinyMCE.compressStyle(ar, "margin", "", "margin"); + + for (key in ar) { + val = ar[key]; + + if (typeof(val) == 'function') + continue; + + if (key.indexOf('mso-') == 0) + continue; + + if (val != null && val !== '') { + val = '' + val; // Force string + + // Fix style URL + val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')"); + + // Convert URL + if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) { + m = new RegExp("url\\('(.*?)'\\)").exec(val); + + if (m.length > 1) + val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')"; + } + + // Force HEX colors + if (tinyMCE.getParam("force_hex_style_colors")) + val = tinyMCE.convertRGBToHex(val, true); + + val = val.replace(/\"/g, '\''); + + if (val != "url('')") + str += key.toLowerCase() + ": " + val + "; "; + } } - var fFace = s[i].style.fontFamily; - if (fFace != null && fFace != "") { - tinyMCE.setAttrib(s[i], 'face', fFace); - s[i].style.fontFamily = ''; + if (new RegExp('; $').test(str)) + str = str.substring(0, str.length - 2); + + return str; + }, + + convertRGBToHex : function(s, k) { + var re, rgb; + + if (s.toLowerCase().indexOf('rgb') != -1) { + re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); + rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); + + if (rgb.length == 5) { + r = parseInt(rgb[1]).toString(16); + g = parseInt(rgb[2]).toString(16); + b = parseInt(rgb[3]).toString(16); + + r = r.length == 1 ? '0' + r : r; + g = g.length == 1 ? '0' + g : g; + b = b.length == 1 ? '0' + b : b; + + s = "#" + r + g + b; + + if (k) + s = rgb[0] + s + rgb[4]; + } } - var fColor = s[i].style.color; - if (fColor != null && fColor != "") { - tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); - s[i].style.color = ''; + return s; + }, + + convertHexToRGB : function(s) { + if (s.indexOf('#') != -1) { + s = s.replace(new RegExp('[^0-9A-F]', 'gi'), ''); + return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")"; } - } -}; -TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) { - var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); + return s; + }, -/* var h = doc.body.innerHTML; - h = h.replace(/ 0 && fSize < 8) { - if (fsClasses != null) - tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); - else - s[i].style.fontSize = sizes[fSize-1]; + for (x=0; x 0) { + tinyMCE.setAttrib(s[i], 'size', fSize); + s[i].style.fontSize = ''; + } + + fFace = s[i].style.fontFamily; + if (fFace != null && fFace !== '') { + tinyMCE.setAttrib(s[i], 'face', fFace); + s[i].style.fontFamily = ''; + } + + fColor = s[i].style.color; + if (fColor != null && fColor !== '') { + tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); + s[i].style.color = ''; + } } + }, - if (fFace != "") { - s[i].style.fontFamily = fFace; - s[i].removeAttribute('face'); + convertFontsToSpans : function(doc) { + var fsClasses, s, i, fSize, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); + + fsClasses = tinyMCE.getParam('font_size_classes'); + if (fsClasses !== '') + fsClasses = fsClasses.replace(/\s+/, '').split(','); + else + fsClasses = null; + + s = tinyMCE.selectElements(doc, 'span,font'); + for (i=0; i 0 && fSize < 8) { + if (fsClasses != null) + tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); + else + s[i].style.fontSize = sizes[fSize-1]; + } + + s[i].removeAttribute('size'); + } + + if (fFace !== '') { + s[i].style.fontFamily = fFace; + s[i].removeAttribute('face'); + } + + if (fColor !== '') { + s[i].style.color = fColor; + s[i].removeAttribute('color'); + } } + }, - if (fColor != "") { - s[i].style.color = fColor; - s[i].removeAttribute('color'); + cleanupAnchors : function(doc) { + var i, cn, x, an = doc.getElementsByTagName("a"); + + // Loops backwards due to bug #1467987 + for (i=an.length-1; i>=0; i--) { + if (tinyMCE.getAttrib(an[i], "name") !== '' && tinyMCE.getAttrib(an[i], "href") == '') { + cn = an[i].childNodes; + + for (x=cn.length-1; x>=0; x--) + tinyMCE.insertAfter(cn[x], an[i]); + } } - } -}; + }, -TinyMCE_Engine.prototype.cleanupAnchors = function(doc) { - var i, cn, x, an = doc.getElementsByTagName("a"); + getContent : function(editor_id) { + if (typeof(editor_id) != "undefined") + tinyMCE.getInstanceById(editor_id).select(); - // Loops backwards due to bug #1467987 - for (i=an.length-1; i>=0; i--) { - if (tinyMCE.getAttrib(an[i], "name") != "" && tinyMCE.getAttrib(an[i], "href") == "") { - cn = an[i].childNodes; + if (tinyMCE.selectedInstance) + return tinyMCE.selectedInstance.getHTML(); - for (x=cn.length-1; x>=0; x--) - tinyMCE.insertAfter(cn[x], an[i]); + return null; + }, + + _fixListElements : function(d) { + var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np; + + for (x=0; x]*>/gi, ''); + h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), ''); + h = h.replace(/


<\/p>/g, '
'); + h = h.replace(/

( | )<\/p>


( | )<\/p>/g, '


'); + h = h.replace(/\s*
\s*<\/td>/g, '' + nb + ''); + h = h.replace(/

\s*
\s*<\/p>/g, '

' + nb + '

'); + h = h.replace(/
$/, ''); // Remove last BR for Gecko + h = h.replace(/
<\/p>/g, '

'); // Remove last BR in P tags for Gecko + h = h.replace(/

\s*( | )\s*
\s*( | )\s*<\/p>/g, '

' + nb + '

'); + h = h.replace(/

\s*( | )\s*
\s*<\/p>/g, '

' + nb + '

'); + h = h.replace(/

\s*
\s* \s*<\/p>/g, '

' + nb + '

'); + h = h.replace(new RegExp('(.*?)<\\/a>', 'g'), '$1'); + h = h.replace(/]*)>\s*<\/p>/g, '' + nb + '

'); + + // Clean body + if (/^\s*(
|

 <\/p>|

 <\/p>|

<\/p>)\s*$/.test(h)) + h = ''; + + // If preformatted + if (s.preformatted) { + h = h.replace(/^

/, '');
+			h = h.replace(/<\/pre>$/, '');
+			h = '
' + h + '
'; } + + // Gecko specific processing + if (tinyMCE.isGecko) { + // Makes no sence but FF generates it!! + h = h.replace(/
\s*<\/li>/g, ''); + h = h.replace(/ \s*<\/(dd|dt)>/g, ''); + h = h.replace(//g, ''); + h = h.replace(/]*)>\s*
\s*<\/td>/g, '' + nb + ''); + } + + if (s.force_br_newlines) + h = h.replace(/

( | )<\/p>/g, '
'); + + // Call custom cleanup code + h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h); + + // Remove internal classes + if (on_save) { + h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), ''); + h = h.replace(new RegExp(' ?class=""', 'g'), ''); + } + + if (s.remove_linebreaks && !c.settings.indent) + h = h.replace(/\n|\r/g, ' '); + + if (d) + t4 = new Date().getTime(); + + if (on_save && c.settings.indent) + h = c.formatHTML(h); + + // If encoding (not recommended option) + if (on_submit && (s.encoding == "xml" || s.encoding == "html")) + h = c.xmlEncode(h); + + if (d) + t5 = new Date().getTime(); + + if (c.settings.debug) + tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + "."); + + return h; } -}; - -TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit, inn) { - var h, d, t1, t2, t3, t4, t5, c, s, nb; - - if (!tinyMCE.getParam('cleanup')) - return elm.innerHTML; - - on_save = typeof(on_save) == 'undefined' ? false : on_save; - - c = inst.cleanup; - s = inst.settings; - d = c.settings.debug; - - if (d) - t1 = new Date().getTime(); - - if (tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertFontsToSpans(doc); - - if (tinyMCE.getParam("fix_list_elements")) - tinyMCE._fixListElements(doc); - - if (tinyMCE.getParam("fix_table_elements")) - tinyMCE._fixTables(doc); - - // Call custom cleanup code - tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body); - - if (d) - t2 = new Date().getTime(); - - c.settings.on_save = on_save; - //for (var i=0; i<100; i++) - - c.idCount = 0; - c.serializationId++; - c.serializedNodes = new Array(); - c.sourceIndex = -1; - - if (s.cleanup_serializer == "xml") - h = c.serializeNodeAsXML(elm, inn); - else - h = c.serializeNodeAsHTML(elm, inn); - - if (d) - t3 = new Date().getTime(); - - // Post processing - nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? ' ' : ' '; - h = h.replace(/<\/?(body|head|html)[^>]*>/gi, ''); - h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), ''); - h = h.replace(/


<\/p>/g, '
'); - h = h.replace(/

( | )<\/p>


( | )<\/p>/g, '


'); - h = h.replace(/\s*
\s*<\/td>/g, '' + nb + ''); - h = h.replace(/

\s*
\s*<\/p>/g, '

' + nb + '

'); - h = h.replace(/
$/, ''); // Remove last BR for Gecko - h = h.replace(/
<\/p>/g, '

'); // Remove last BR in P tags for Gecko - h = h.replace(/

\s*( | )\s*
\s*( | )\s*<\/p>/g, '

' + nb + '

'); - h = h.replace(/

\s*( | )\s*
\s*<\/p>/g, '

' + nb + '

'); - h = h.replace(/

\s*
\s* \s*<\/p>/g, '

' + nb + '

'); - h = h.replace(new RegExp('
(.*?)<\\/a>', 'g'), '$1'); - h = h.replace(/]*)>\s*<\/p>/g, '' + nb + '

'); - - // Clean body - if (/^\s*(
|

 <\/p>|

 <\/p>|

<\/p>)\s*$/.test(h)) - h = ''; - - // If preformatted - if (s.preformatted) { - h = h.replace(/^

/, '');
-		h = h.replace(/<\/pre>$/, '');
-		h = '
' + h + '
'; - } - - // Gecko specific processing - if (tinyMCE.isGecko) { - h = h.replace(//g, ''); - h = h.replace(/]*)>\s*
\s*<\/td>/g, '' + nb + ''); - } - - if (s.force_br_newlines) - h = h.replace(/

( | )<\/p>/g, '
'); - - // Call custom cleanup code - h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h); - - // Remove internal classes - if (on_save) { - h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), ''); - h = h.replace(new RegExp(' ?class=""', 'g'), ''); - } - - if (s.remove_linebreaks && !c.settings.indent) - h = h.replace(/\n|\r/g, ' '); - - if (d) - t4 = new Date().getTime(); - - if (on_save && c.settings.indent) - h = c.formatHTML(h); - - // If encoding (not recommended option) - if (on_submit && (s.encoding == "xml" || s.encoding == "html")) - h = c.xmlEncode(h); - - if (d) - t5 = new Date().getTime(); - - if (c.settings.debug) - tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + "."); - - return h; -}; +}); function TinyMCE_Cleanup() { this.isIE = (navigator.appName == "Microsoft Internet Explorer"); - this.rules = tinyMCE.clearArray(new Array()); + this.rules = tinyMCE.clearArray([]); // Default config this.settings = { @@ -4418,7 +4490,7 @@ function TinyMCE_Cleanup() { verify_html : false }; - this.vElements = tinyMCE.clearArray(new Array()); + this.vElements = tinyMCE.clearArray([]); this.vElementsRe = ''; this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/; this.codeElementsRe = /^(SCRIPT|STYLE)$/; @@ -4448,7 +4520,7 @@ TinyMCE_Cleanup.prototype = { this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>'); this.serializedNodes = []; - if (s.invalid_elements != '') + if (s.invalid_elements !== '') this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$'); else this.iveRe = null; @@ -4469,19 +4541,17 @@ TinyMCE_Cleanup.prototype = { this.fillStr = s.entity_encoding == "named" ? " " : " "; this.idCount = 0; this.xmlEncodeRe = new RegExp('[\u007F-\uFFFF<>&"]', 'g'); - this.xmlEncodeAposRe = new RegExp('[\u007F-\uFFFF<>&"\']', 'g'); }, addRuleStr : function(s) { - var r = this.parseRuleStr(s); - var n; + var r = this.parseRuleStr(s), n; for (n in r) { if (r[n]) this.rules[n] = r[n]; } - this.vElements = tinyMCE.clearArray(new Array()); + this.vElements = tinyMCE.clearArray([]); for (n in this.rules) { if (this.rules[n]) @@ -4492,7 +4562,8 @@ TinyMCE_Cleanup.prototype = { }, isValid : function(n) { - this._setupRules(); // Will initialize cleanup rules + if (!this.rulesDone) + this._setupRules(); // Will initialize cleanup rules // Empty is true since it removes formatting if (!n) @@ -4548,9 +4619,9 @@ TinyMCE_Cleanup.prototype = { } r += ')$'; -//tinyMCE.debug(t + "=" + r); + if (this.childRules == null) - this.childRules = tinyMCE.clearArray(new Array()); + this.childRules = tinyMCE.clearArray([]); this.childRules[tn[y]] = new RegExp(r); @@ -4561,7 +4632,7 @@ TinyMCE_Cleanup.prototype = { }, parseRuleStr : function(s) { - var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray(new Array()), dv; + var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray([]), dv; if (s == null || s.length == 0) return or; @@ -4621,19 +4692,19 @@ TinyMCE_Cleanup.prototype = { if (av && av.length > 0) { if (av[0].charAt(0) == ':') { if (!r.forceAttribs) - r.forceAttribs = tinyMCE.clearArray(new Array()); + r.forceAttribs = tinyMCE.clearArray([]); r.forceAttribs[t.toLowerCase()] = av[0].substring(1); } else if (av[0].charAt(0) == '=') { if (!r.defaultAttribs) - r.defaultAttribs = tinyMCE.clearArray(new Array()); + r.defaultAttribs = tinyMCE.clearArray([]); dv = av[0].substring(1); - r.defaultAttribs[t.toLowerCase()] = dv == "" ? "mce_empty" : dv; + r.defaultAttribs[t.toLowerCase()] = dv == '' ? "mce_empty" : dv; } else if (av[0].charAt(0) == '<') { if (!r.validAttribValues) - r.validAttribValues = tinyMCE.clearArray(new Array()); + r.validAttribValues = tinyMCE.clearArray([]); r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i'); } @@ -4656,7 +4727,7 @@ TinyMCE_Cleanup.prototype = { //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC); } else { r.vAttribsRe = ''; - r.vAttribs = tinyMCE.clearArray(new Array()); + r.vAttribs = tinyMCE.clearArray([]); r.vAttribsReIsWild = false; } @@ -4745,7 +4816,8 @@ TinyMCE_Cleanup.prototype = { serializeNodeAsHTML : function(n, inn) { var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr, nn; - this._setupRules(); // Will initialize cleanup rules + if (!this.rulesDone) + this._setupRules(); // Will initialize cleanup rules if (tinyMCE.isRealIE && this._isDuplicate(n)) return ''; @@ -4767,12 +4839,19 @@ TinyMCE_Cleanup.prototype = { if (st) break; - // MSIE sometimes produces - if ((tinyMCE.isRealIE) && n.nodeName.indexOf('/') != -1) - break; - nn = n.nodeName; + if (tinyMCE.isRealIE) { + // MSIE sometimes produces + if (n.nodeName.indexOf('/') != -1) + break; + + // MSIE has it's NS in a separate attrib + if (n.scopeName && n.scopeName != 'HTML') + nn = n.scopeName.toUpperCase() + ':' + nn.toUpperCase(); + } else if (tinyMCE.isOpera && nn.indexOf(':') > 0) + nn = nn.toUpperCase(); + // Convert fonts to spans if (this.settings.convert_fonts_to_spans) { // On get content FONT -> SPAN @@ -4959,25 +5038,26 @@ TinyMCE_Cleanup.prototype = { return o; }, - xmlEncode : function(s, skip_apos) { - var cl = this, re = !skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe; + xmlEncode : function(s) { + var cl = this, re = this.xmlEncodeRe; - this._setupEntities(); // Will intialize lookup table + if (!this.entitiesDone) + this._setupEntities(); // Will intialize lookup table switch (this.settings.entity_encoding) { case "raw": - return tinyMCE.xmlEncode(s, skip_apos); + return tinyMCE.xmlEncode(s); case "named": - return s.replace(re, function (c, b) { - b = cl.entities[c.charCodeAt(0)]; + return s.replace(re, function (c) { + var b = cl.entities[c.charCodeAt(0)]; return b ? '&' + b + ';' : c; }); case "numeric": - return s.replace(re, function (c, b) { - return b ? '&#' + c.charCodeAt(0) + ';' : c; + return s.replace(re, function (c) { + return '&#' + c.charCodeAt(0) + ';'; }); } @@ -4985,11 +5065,10 @@ TinyMCE_Cleanup.prototype = { }, split : function(re, s) { - var c = s.split(re); - var i, l, o = new Array(); + var i, l, o = [], c = s.split(re); for (i=0, l=c.length; i' : '>' + h + ''; + o += !h ? ' />' : '>' + h + ''; - return o; -}; + return o; + }, -TinyMCE_Engine.prototype.createTag = function(d, tn, a, h) { - var o = d.createElement(tn); + createTag : function(d, tn, a, h) { + var o = d.createElement(tn), n; - if (a) { - for (n in a) { - if (typeof(a[n]) != 'function' && a[n] != null) - tinyMCE.setAttrib(o, n, a[n]); + if (a) { + for (n in a) { + if (typeof(a[n]) != 'function' && a[n] != null) + tinyMCE.setAttrib(o, n, a[n]); + } } - } - if (h) - o.innerHTML = h; + if (h) + o.innerHTML = h; - return o; -}; + return o; + }, -TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) { - return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0]; -}; + getElementByAttributeValue : function(n, e, a, v) { + return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0]; + }, -TinyMCE_Engine.prototype.getElementsByAttributeValue = function(n, e, a, v) { - var i, nl = n.getElementsByTagName(e), o = new Array(); + getElementsByAttributeValue : function(n, e, a, v) { + var i, nl = n.getElementsByTagName(e), o = []; - for (i=0; i]*)>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/]*)>/gi, ''); - h = h.replace(/<\/strong>/gi, '
'); - h = h.replace(/<\/em>/gi, ''); - } - - if (tinyMCE.isRealIE) { - // Since MSIE handles invalid HTML better that valid XHTML we - // need to make some things invalid.


gets converted to
. - h = h.replace(/\s\/>/g, '>'); - - // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones - h = h.replace(/]*)>\u00A0?<\/p>/gi, ' 

'); // Keep empty paragraphs - h = h.replace(/]*)>\s* \s*<\/p>/gi, ' 

'); // Keep empty paragraphs - h = h.replace(/]*)>\s+<\/p>/gi, ' 

'); // Keep empty paragraphs - - // Remove first comment - e.innerHTML = tinyMCE.uniqueTag + h; - e.firstChild.removeNode(true); - - // Remove weird auto generated empty paragraphs unless it's supposed to be there - nl = e.getElementsByTagName("p"); - for (i=nl.length-1; i>=0; i--) { - n = nl[i]; - - if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) - n.parentNode.removeChild(n); + for (i=0; i]*)>/gi, ''); + h = h.replace(/]*)>/gi, ''); + h = h.replace(/]*)>/gi, ''); + h = h.replace(/]*)>/gi, ''); + h = h.replace(/<\/strong>/gi, '
'); + h = h.replace(/<\/em>/gi, ''); + } + + if (tinyMCE.isRealIE) { + // Since MSIE handles invalid HTML better that valid XHTML we + // need to make some things invalid.
gets converted to
. + h = h.replace(/\s\/>/g, '>'); + + // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones + h = h.replace(/]*)>\u00A0?<\/p>/gi, ' 

'); // Keep empty paragraphs + h = h.replace(/]*)>\s* \s*<\/p>/gi, ' 

'); // Keep empty paragraphs + h = h.replace(/]*)>\s+<\/p>/gi, ' 

'); // Keep empty paragraphs + + // Remove first comment + e.innerHTML = tinyMCE.uniqueTag + h; + e.firstChild.removeNode(true); + + // Remove weird auto generated empty paragraphs unless it's supposed to be there + nl = e.getElementsByTagName("p"); + for (i=nl.length-1; i>=0; i--) { + n = nl[i]; + + if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) + n.parentNode.removeChild(n); + } + } else { + h = this.fixGeckoBaseHREFBug(1, e, h); + e.innerHTML = h; + this.fixGeckoBaseHREFBug(2, e, h); + } + }, + + getOuterHTML : function(e) { + var d; + + if (tinyMCE.isIE) + return e.outerHTML; + + d = e.ownerDocument.createElement("body"); + d.appendChild(e.cloneNode(true)); + + return d.innerHTML; + }, + + setOuterHTML : function(e, h, d) { + var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t; + + if (tinyMCE.isIE && e.nodeType == 1) + e.outerHTML = h; + else { + t = d.createElement("body"); + t.innerHTML = h; + + for (i=0, nl=t.childNodes; i-1; i--) { + if (ar[i].specified && ar[i].nodeValue) + ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); + } + + ar = e.childNodes; + for (i=0; i= strTok2.length) { + for (i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { + breakPoint = i + 1; break; } } } - } - return e; -}; - -TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) { - return this.selectNodes(n, function(n) { - return (!t || n.nodeType == t) && (!nn || n.nodeName == nn); - }, na ? na : new Array()); -}; - -TinyMCE_Engine.prototype.getParentElement = function(n, na, f, r) { - var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v; - - // Compatiblity with old scripts where f param was a attribute string - if (f && typeof(f) == 'string') - return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) != '';}); - - return this.getParentNode(n, function(n) { - return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n)); - }, r); -}; - -TinyMCE_Engine.prototype.getParentNode = function(n, f, r) { - while (n) { - if (n == r) - return null; - - if (f(n)) - return n; - - n = n.parentNode; - } - - return null; -}; - -TinyMCE_Engine.prototype.getAttrib = function(elm, name, dv) { - var v; - - if (typeof(dv) == "undefined") - dv = ""; - - // Not a element - if (!elm || elm.nodeType != 1) - return dv; - - try { - v = elm.getAttribute(name, 0); - } catch (ex) { - // IE 7 may cast exception on invalid attributes - v = elm.getAttribute(name, 2); - } - - // Try className for class attrib - if (name == "class" && !v) - v = elm.className; - - // Workaround for a issue with Firefox 1.5rc2+ - if (tinyMCE.isGecko && name == "src" && elm.src != null && elm.src != "") - v = elm.src; - - // Workaround for a issue with Firefox 1.5rc2+ - if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "") - v = elm.href; - - if (name == "http-equiv" && tinyMCE.isIE) - v = elm.httpEquiv; - - if (name == "style" && !tinyMCE.isOpera) - v = elm.style.cssText; - - return (v && v != "") ? v : dv; -}; - -TinyMCE_Engine.prototype.setAttrib = function(el, name, va, fix) { - if (typeof(va) == "number" && va != null) - va = "" + va; - - if (fix) { - if (va == null) - va = ""; - - va = va.replace(/[^0-9%]/g, ''); - } - - if (name == "style") - el.style.cssText = va; - - if (name == "class") - el.className = va; - - if (va != null && va != "" && va != -1) - el.setAttribute(name, va); - else - el.removeAttribute(name); -}; - -TinyMCE_Engine.prototype.setStyleAttrib = function(e, n, v) { - e.style[n] = v; - - // Style attrib deleted in IE - if (tinyMCE.isIE && v == null || v == '') { - v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText)); - e.style.cssText = v; - e.setAttribute("style", v); - } -}; - -TinyMCE_Engine.prototype.switchClass = function(ei, c) { - var e; - - if (tinyMCE.switchClassCache[ei]) - e = tinyMCE.switchClassCache[ei]; - else - e = tinyMCE.switchClassCache[ei] = document.getElementById(ei); - - if (e) { - // Keep tile mode - if (tinyMCE.settings.button_tile_map && e.className && e.className.indexOf('mceTiledButton') == 0) - c = 'mceTiledButton ' + c; - - e.className = c; - } -}; - -TinyMCE_Engine.prototype.getAbsPosition = function(n, cn) { - var l = 0, t = 0; - - while (n && n != cn) { - l += n.offsetLeft; - t += n.offsetTop; - n = n.offsetParent; - } - - return {absLeft : l, absTop : t}; -}; - -TinyMCE_Engine.prototype.prevNode = function(e, n) { - var a = n.split(','), i; - - while ((e = e.previousSibling) != null) { - for (i=0; i-1; i--) { - if (ar[i].specified && ar[i].nodeValue) - ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); - } - - ar = e.childNodes; - for (i=0; i= strTok2.length) { - for (var i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { - breakPoint = i + 1; - break; - } - } - } - - if (strTok1.length < strTok2.length) { - for (var i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { - breakPoint = i + 1; - break; - } - } - } - - if (breakPoint == 1) - return targetURL.path; - - for (var i=0; i<(strTok1.length-(breakPoint-1)); i++) - outPath += "../"; - - for (var i=breakPoint-1; i=0; i--) { - if (baseURLParts[i].length == 0) - continue; - - newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; - } - baseURLParts = newBaseURLParts.reverse(); - - // Merge relURLParts chunks - var newRelURLParts = new Array(); - var numBack = 0; - for (var i=relURLParts.length-1; i>=0; i--) { - if (relURLParts[i].length == 0 || relURLParts[i] == ".") - continue; - - if (relURLParts[i] == '..') { - numBack++; - continue; - } - - if (numBack > 0) { - numBack--; - continue; - } - - newRelURLParts[newRelURLParts.length] = relURLParts[i]; - } - - relURLParts = newRelURLParts.reverse(); - - // Remove end from absolute path - var len = baseURLParts.length-numBack; - var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); - var start = "", end = ""; - - // Build output URL - relURL.protocol = baseURL.protocol; - relURL.host = baseURL.host; - relURL.port = baseURL.port; - - // Re-add trailing slash if it's removed - if (relURL.path.charAt(relURL.path.length-1) == "/") - absPath += "/"; - - relURL.path = absPath; - - return this.serializeURL(relURL); -}; - -TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) { - var prot = document.location.protocol; - var host = document.location.hostname; - var port = document.location.port; - - // Pass through file protocol - if (prot == "file:") - return url; - - // Something is wrong, remove weirdness - url = tinyMCE.regexpReplace(url, '(http|https):///', '/'); - - // Mailto link or anchor (Pass through) - if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || tinyMCE.regexpReplace(url,'[ \t\r\n\+]|%20','').charAt(0) == "#") - return url; - - // Fix relative/Mozilla - if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/') - return tinyMCE.settings['base_href'] + url; - - // Handle relative URLs - if (on_save && tinyMCE.getParam('relative_urls')) { - var curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url); - if (curl.charAt(0) == '/') - curl = tinyMCE.settings['document_base_prefix'] + curl; - - var urlParts = tinyMCE.parseURL(curl); - var tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings['document_base_url']); - - // Force relative - if (urlParts['host'] == tmpUrlParts['host'] && (urlParts['port'] == tmpUrlParts['port'])) - return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings['document_base_url'], curl); - } - - // Handle absolute URLs - if (!tinyMCE.getParam('relative_urls')) { - var urlParts = tinyMCE.parseURL(url); - var baseUrlParts = tinyMCE.parseURL(tinyMCE.settings['base_href']); - - // Force absolute URLs from relative URLs - url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url); - - // If anchor and path is the same page - if (urlParts['anchor'] && urlParts['path'] == baseUrlParts['path']) - return "#" + urlParts['anchor']; - } - - // Remove current domain - if (tinyMCE.getParam('remove_script_host')) { - var start = "", portPart = ""; - - if (port != "") - portPart = ":" + port; - - start = prot + "//" + host + portPart + "/"; - - if (url.indexOf(start) == 0) - url = url.substring(start.length-1); - } - - return url; -}; - -TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) { - var i, elms, src, href, mhref, msrc; - - // Convert all image URL:s to absolute URL - elms = body.getElementsByTagName("img"); - for (i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { + breakPoint = i + 1; + break; } } } - } -}; -TinyMCE_Engine.prototype._eventPatch = function(editor_id) { - var n, inst, win, e; + if (breakPoint == 1) + return targetURL.path; - // Remove odd, error - if (typeof(tinyMCE) == "undefined") - return true; + for (i=0; i<(strTok1.length-(breakPoint-1)); i++) + outPath += "../"; - try { - // Try selected instance first - if (tinyMCE.selectedInstance) { - win = tinyMCE.selectedInstance.getWin(); + for (i=breakPoint-1; i=0; i--) { + if (baseURLParts[i].length == 0) + continue; + + newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; + } + baseURLParts = newBaseURLParts.reverse(); + + // Merge relURLParts chunks + newRelURLParts = []; + numBack = 0; + for (i=relURLParts.length-1; i>=0; i--) { + if (relURLParts[i].length == 0 || relURLParts[i] == ".") + continue; + + if (relURLParts[i] == '..') { + numBack++; + continue; + } + + if (numBack > 0) { + numBack--; + continue; + } + + newRelURLParts[newRelURLParts.length] = relURLParts[i]; + } + + relURLParts = newRelURLParts.reverse(); + + // Remove end from absolute path + len = baseURLParts.length-numBack; + absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); + start = ""; + end = ""; + + // Build output URL + relURL.protocol = baseURL.protocol; + relURL.host = baseURL.host; + relURL.port = baseURL.port; + + // Re-add trailing slash if it's removed + if (relURL.path.charAt(relURL.path.length-1) == "/") + absPath += "/"; + + relURL.path = absPath; + + return this.serializeURL(relURL); + }, + + convertURL : function(url, node, on_save) { + var dl = document.location, start, portPart, urlParts, baseUrlParts, tmpUrlParts, curl; + var prot = dl.protocol, host = dl.hostname, port = dl.port; + + // Pass through file protocol + if (prot == "file:") + return url; + + // Something is wrong, remove weirdness + url = tinyMCE.regexpReplace(url, '(http|https):///', '/'); + + // Mailto link or anchor (Pass through) + if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || /^[ \t\r\n\+]*[#\?]/.test(url)) + return url; + + // Fix relative/Mozilla + if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/') + return tinyMCE.settings.base_href + url; + + // Handle relative URLs + if (on_save && tinyMCE.getParam('relative_urls')) { + curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url); + if (curl.charAt(0) == '/') + curl = tinyMCE.settings.document_base_prefix + curl; + + urlParts = tinyMCE.parseURL(curl); + tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings.document_base_url); + + // Force relative + if (urlParts.host == tmpUrlParts.host && (urlParts.port == tmpUrlParts.port)) + return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings.document_base_url, curl); + } + + // Handle absolute URLs + if (!tinyMCE.getParam('relative_urls')) { + urlParts = tinyMCE.parseURL(url); + baseUrlParts = tinyMCE.parseURL(tinyMCE.settings.base_href); + + // Force absolute URLs from relative URLs + url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url); + + // If anchor and path is the same page + if (urlParts.anchor && urlParts.path == baseUrlParts.path) + return "#" + urlParts.anchor; + } + + // Remove current domain + if (tinyMCE.getParam('remove_script_host')) { + start = ""; + portPart = ""; + + if (port !== '') + portPart = ":" + port; + + start = prot + "//" + host + portPart + "/"; + + if (url.indexOf(start) == 0) + url = url.substring(start.length-1); + } + + return url; + }, + + convertAllRelativeURLs : function(body) { + var i, elms, src, href, mhref, msrc; + + // Convert all image URL:s to absolute URL + elms = body.getElementsByTagName("img"); + for (i=0; i 0) rng.selectNodeContents(nodes[0]); else @@ -6706,7 +6799,7 @@ TinyMCE_Selection.prototype = { function TinyMCE_UndoRedo(inst) { this.instance = inst; - this.undoLevels = new Array(); + this.undoLevels = []; this.undoIndex = 0; this.typingUndoIndex = -1; this.undoRedo = true; @@ -6732,10 +6825,13 @@ TinyMCE_UndoRedo.prototype = { if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) { //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content); + // Is dirty again + inst.isNotDirty = false; + tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst); // Time to compress - customUndoLevels = tinyMCE.settings['custom_undo_redo_levels']; + customUndoLevels = tinyMCE.settings.custom_undo_redo_levels; if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) { for (i=0; i 1 ? ',' : '') + 'a[' + i + ']'; - - o = s._fu; - s._fu = this; - r = eval('s._fu(' + as + ')'); - s._fu = o; - - return r; - }; -}; - /* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */ -TinyMCE_Engine.prototype.debug = function() { - var m = "", a, i, l = tinyMCE.log.length; +tinyMCE.add(TinyMCE_Engine, { + debug : function() { + var m = "", a, i, l = tinyMCE.log.length; - for (i=0, a = this.debug.arguments; i 0) { elms = document.forms[0].elements; for (i=0; i=0; i--) { + for (i=nodes.length-1; i>=0; i--) { if (wrapper.hasChildNodes()) wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild); else @@ -164,7 +165,7 @@ TinyMCE_Popup.prototype = { // Create iframe iframe = document.createElement("iframe"); iframe.id = "mcWinIframe"; - iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document']; + iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings.default_document; iframe.width = "100%"; iframe.height = "100%"; iframe.style.margin = '0'; @@ -191,6 +192,7 @@ TinyMCE_Popup.prototype = { resizeToContent : function() { var isMSIE = (navigator.appName == "Microsoft Internet Explorer"); var isOpera = (navigator.userAgent.indexOf("Opera") != -1); + var elm, width, height, x, y, dx, dy; if (isOpera) return; @@ -198,11 +200,11 @@ TinyMCE_Popup.prototype = { if (isMSIE) { try { window.resizeTo(10, 10); } catch (e) {} - var elm = document.body; - var width = elm.offsetWidth; - var height = elm.offsetHeight; - var dx = (elm.scrollWidth - width) + 4; - var dy = elm.scrollHeight - height; + elm = document.body; + width = elm.offsetWidth; + height = elm.offsetHeight; + dx = (elm.scrollWidth - width) + 4; + dy = elm.scrollHeight - height; try { window.resizeBy(dx, dy); } catch (e) {} } else { @@ -211,8 +213,8 @@ TinyMCE_Popup.prototype = { window.resizeBy(window.innerWidth * 2, window.innerHeight * 2); window.sizeToContent(); window.scrollTo(0, 0); - var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0); - var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0); + x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0); + y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0); window.moveTo(x, y); } } @@ -223,8 +225,10 @@ TinyMCE_Popup.prototype = { }, restoreSelection : function() { + var inst; + if (this.storeSelection) { - var inst = tinyMCE.selectedInstance; + inst = tinyMCE.selectedInstance; inst.getWin().focus(); @@ -272,9 +276,11 @@ TinyMCE_Popup.prototype = { }, importClass : function(c) { + var n; + window[c] = function() {}; - for (var n in window.opener[c].prototype) + for (n in window.opener[c].prototype) window[c].prototype[n] = window.opener[c].prototype[n]; window[c].constructor = window.opener[c].constructor; diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index bc180cfe0..b5cf3b931 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -31,9 +31,9 @@ class WP_Scripts { $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' ); - $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070326' ); + $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070528' ); $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); - $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070225' ); + $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070528' ); $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.1');