Make WordPress Core

Changeset 4506


Ignore:
Timestamp:
11/21/2006 12:55:06 AM (20 years ago)
Author:
ryan
Message:

TinyMCE 2.0.8

Location:
trunk
Files:
1 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upload-js.php

    r4466 r4506  
    9898                        h += "<table>";
    9999                        if ( this.currentImage.thumb ) {
    100                                 h += "<tr><th style='padding-bottom:.5em'>Show:</th><td style='padding-bottom:.5em'>";
    101                                 h += "<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' checked='checked' /> Thumbnail</label><br />";
    102                                 h += "<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> Full size</label>";
     100                                h += "<tr><th style='padding-bottom:.5em'><?php echo addslashes(__('Show:')); ?></th><td style='padding-bottom:.5em'>";
     101                                h += "<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' checked='checked' /> <?php echo addslashes(__('Thumbnail')); ?></label><br />";
     102                                h += "<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> <?php echo addslashes(__('Full size')); ?></label>";
    103103                                h += "</td></tr>";
    104104                        }
    105105
    106                         h += "<tr><th>Link to:</th><td>";
    107                         h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> File</label><br />";
    108                         h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> Page</label><br />";
    109                         h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> None</label>";
     106                        h += "<tr><th><?php echo addslashes(__('Link to:')); ?></th><td>";
     107                        h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> <?php echo addslashes(__('File')); ?></label><br />";
     108                        h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> <?php echo addslashes(__('Page')); ?></label><br />";
     109                        h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> <?php echo addslashes(__('None')); ?></label>";
    110110                        h += "</td></tr>";
    111111
    112112                        h += "<tr><td colspan='2'><p class='submit'>";
    113                         h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='Send to editor &raquo;' />";
     113                        h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='<?php echo addslashes(__('Send to editor')); ?> &raquo;' />";
    114114                        h += "</p></td></tr></table>";
    115115                        h += "</form>";
    … …  
    244244
    245245                deleteFile: function(id) {
    246                         if ( confirm("Are you sure you want to delete the file '" + this.currentImage.title + "'?\nClick ok to delete or cancel to go back.") ) {
     246                        if ( confirm("<?php printf(addslashes(__("Are you sure you want to delete the file %s?\nClick ok to delete or cancel to go back.")), '" + this.currentImage.title + "'); ?>") {
    247247                                $('action-value').value = 'delete';
    248248                                $('upload-file').submit();
  • trunk/wp-includes/js/autosave.js.php

    r4441 r4506  
    44var autosaveLast = '';
    55var autosavePeriodical;
     6
    67function autosave_start_timer() {
    78        var form = $('post');
    89        autosaveLast = form.post_title.value+form.content.value;
    9         autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '60'); ?>);
     10        autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '16'); ?>);
     11        //Disable autosave after the form has been submitted
     12//      if(form.addEventListener) {
     13//              form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
     14//      }
     15        if(form.attachEvent) {
     16                form.attachEvent("onsubmit", function () { autosavePeriodical.currentlyExecuting = true; });
     17        }
    1018}
    1119addLoadEvent(autosave_start_timer)
  • trunk/wp-includes/js/tinymce/license.txt

    r3163 r4506  
    1                   GNU LIBRARY GENERAL PUBLIC LICENSE
    2                        Version 2, June 1991
    3 
    4  Copyright (C) 1991 Free Software Foundation, Inc.
    5  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     1                  GNU LESSER GENERAL PUBLIC LICENSE
     2                       Version 2.1, February 1999
     3
     4 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
     5 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    66 Everyone is permitted to copy and distribute verbatim copies
    77 of this license document, but changing it is not allowed.
    88
    9 [This is the first released version of the library GPL.  It is
    10  numbered 2 because it goes with version 2 of the ordinary GPL.]
     9[This is the first released version of the Lesser GPL.  It also counts
     10 as the successor of the GNU Library Public License, version 2, hence
     11 the version number 2.1.]
    1112
    1213                            Preamble
    … …  
    1718free software--to make sure the software is free for all its users.
    1819
    19   This license, the Library General Public License, applies to some
    20 specially designated Free Software Foundation software, and to any
    21 other libraries whose authors decide to use it.  You can use it for
    22 your libraries, too.
    23 
    24   When we speak of free software, we are referring to freedom, not
    25 price.  Our General Public Licenses are designed to make sure that you
    26 have the freedom to distribute copies of free software (and charge for
    27 this service if you wish), that you receive source code or can get it
    28 if you want it, that you can change the software or use pieces of it
    29 in new free programs; and that you know you can do these things.
     20  This license, the Lesser General Public License, applies to some
     21specially designated software packages--typically libraries--of the
     22Free Software Foundation and other authors who decide to use it.  You
     23can use it too, but we suggest you first think carefully about whether
     24this license or the ordinary General Public License is the better
     25strategy to use in any particular case, based on the explanations below.
     26
     27  When we speak of free software, we are referring to freedom of use,
     28not price.  Our General Public Licenses are designed to make sure that
     29you have the freedom to distribute copies of free software (and charge
     30for this service if you wish); that you receive source code or can get
     31it if you want it; that you can change the software and use pieces of
     32it in new free programs; and that you are informed that you can do
     33these things.
    3034
    3135  To protect your rights, we need to make restrictions that forbid
    32 anyone to deny you these rights or to ask you to surrender the rights.
    33 These restrictions translate to certain responsibilities for you if
    34 you distribute copies of the library, or if you modify it.
     36distributors to deny you these rights or to ask you to surrender these
     37rights.  These restrictions translate to certain responsibilities for
     38you if you distribute copies of the library or if you modify it.
    3539
    3640  For example, if you distribute copies of the library, whether gratis
    3741or for a fee, you must give the recipients all the rights that we gave
    3842you.  You must make sure that they, too, receive or can get the source
    39 code.  If you link a program with the library, you must provide
    40 complete object files to the recipients so that they can relink them
    41 with the library, after making changes to the library and recompiling
     43code.  If you link other code with the library, you must provide
     44complete object files to the recipients, so that they can relink them
     45with the library after making changes to the library and recompiling
    4246it.  And you must show them these terms so they know their rights.
    4347
    44   Our method of protecting your rights has two steps: (1) copyright
    45 the library, and (2) offer you this license which gives you legal
     48  We protect your rights with a two-step method: (1) we copyright the
     49library, and (2) we offer you this license, which gives you legal
    4650permission to copy, distribute and/or modify the library.
    4751
    48   Also, for each distributor's protection, we want to make certain
    49 that everyone understands that there is no warranty for this free
    50 library.  If the library is modified by someone else and passed on, we
    51 want its recipients to know that what they have is not the original
    52 version, so that any problems introduced by others will not reflect on
    53 the original authors' reputations.
    54 .
    55   Finally, any free program is threatened constantly by software
    56 patents.  We wish to avoid the danger that companies distributing free
    57 software will individually obtain patent licenses, thus in effect
    58 transforming the program into proprietary software.  To prevent this,
    59 we have made it clear that any patent must be licensed for everyone's
    60 free use or not licensed at all.
    61 
    62   Most GNU software, including some libraries, is covered by the ordinary
    63 GNU General Public License, which was designed for utility programs.  This
    64 license, the GNU Library General Public License, applies to certain
    65 designated libraries.  This license is quite different from the ordinary
    66 one; be sure to read it in full, and don't assume that anything in it is
    67 the same as in the ordinary license.
    68 
    69   The reason we have a separate public license for some libraries is that
    70 they blur the distinction we usually make between modifying or adding to a
    71 program and simply using it.  Linking a program with a library, without
    72 changing the library, is in some sense simply using the library, and is
    73 analogous to running a utility program or application program.  However, in
    74 a textual and legal sense, the linked executable is a combined work, a
    75 derivative of the original library, and the ordinary General Public License
    76 treats it as such.
    77 
    78   Because of this blurred distinction, using the ordinary General
    79 Public License for libraries did not effectively promote software
    80 sharing, because most developers did not use the libraries.  We
    81 concluded that weaker conditions might promote sharing better.
    82 
    83   However, unrestricted linking of non-free programs would deprive the
    84 users of those programs of all benefit from the free status of the
    85 libraries themselves.  This Library General Public License is intended to
    86 permit developers of non-free programs to use free libraries, while
    87 preserving your freedom as a user of such programs to change the free
    88 libraries that are incorporated in them.  (We have not seen how to achieve
    89 this as regards changes in header files, but we have achieved it as regards
    90 changes in the actual functions of the Library.)  The hope is that this
    91 will lead to faster development of free libraries.
     52  To protect each distributor, we want to make it very clear that
     53there is no warranty for the free library.  Also, if the library is
     54modified by someone else and passed on, the recipients should know
     55that what they have is not the original version, so that the original
     56author's reputation will not be affected by problems that might be
     57introduced by others.
     58
     59  Finally, software patents pose a constant threat to the existence of
     60any free program.  We wish to make sure that a company cannot
     61effectively restrict the users of a free program by obtaining a
     62restrictive license from a patent holder.  Therefore, we insist that
     63any patent license obtained for a version of the library must be
     64consistent with the full freedom of use specified in this license.
     65
     66  Most GNU software, including some libraries, is covered by the
     67ordinary GNU General Public License.  This license, the GNU Lesser
     68General Public License, applies to certain designated libraries, and
     69is quite different from the ordinary General Public License.  We use
     70this license for certain libraries in order to permit linking those
     71libraries into non-free programs.
     72
     73  When a program is linked with a library, whether statically or using
     74a shared library, the combination of the two is legally speaking a
     75combined work, a derivative of the original library.  The ordinary
     76General Public License therefore permits such linking only if the
     77entire combination fits its criteria of freedom.  The Lesser General
     78Public License permits more lax criteria for linking other code with
     79the library.
     80
     81  We call this license the "Lesser" General Public License because it
     82does Less to protect the user's freedom than the ordinary General
     83Public License.  It also provides other free software developers Less
     84of an advantage over competing non-free programs.  These disadvantages
     85are the reason we use the ordinary General Public License for many
     86libraries.  However, the Lesser license provides advantages in certain
     87special circumstances.
     88
     89  For example, on rare occasions, there may be a special need to
     90encourage the widest possible use of a certain library, so that it becomes
     91a de-facto standard.  To achieve this, non-free programs must be
     92allowed to use the library.  A more frequent case is that a free
     93library does the same job as widely used non-free libraries.  In this
     94case, there is little to gain by limiting the free library to free
     95software only, so we use the Lesser General Public License.
     96
     97  In other cases, permission to use a particular library in non-free
     98programs enables a greater number of people to use a large body of
     99free software.  For example, permission to use the GNU C Library in
     100non-free programs enables many more people to use the whole GNU
     101operating system, as well as its variant, the GNU/Linux operating
     102system.
     103
     104  Although the Lesser General Public License is Less protective of the
     105users' freedom, it does ensure that the user of a program that is
     106linked with the Library has the freedom and the wherewithal to run
     107that program using a modified version of the Library.
    92108
    93109  The precise terms and conditions for copying, distribution and
    94110modification follow.  Pay close attention to the difference between a
    95111"work based on the library" and a "work that uses the library".  The
    96 former contains code derived from the library, while the latter only
    97 works together with the library.
    98 
    99   Note that it is possible for a library to be covered by the ordinary
    100 General Public License rather than by this special one.
    101 .
    102                   GNU LIBRARY GENERAL PUBLIC LICENSE
     112former contains code derived from the library, whereas the latter must
     113be combined with the library in order to run.
     114
     115                  GNU LESSER GENERAL PUBLIC LICENSE
    103116   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    104117
    105   0. This License Agreement applies to any software library which
    106 contains a notice placed by the copyright holder or other authorized
    107 party saying it may be distributed under the terms of this Library
    108 General Public License (also called "this License").  Each licensee is
    109 addressed as "you".
     118  0. This License Agreement applies to any software library or other
     119program which contains a notice placed by the copyright holder or
     120other authorized party saying it may be distributed under the terms of
     121this Lesser General Public License (also called "this License").
     122Each licensee is addressed as "you".
    110123
    111124  A "library" means a collection of software functions and/or data
    … …  
    146159and you may at your option offer warranty protection in exchange for a
    147160fee.
    148 .
     161
    149162  2. You may modify your copy or copies of the Library or any portion
    150163of it, thus forming a work based on the Library, and copy and
    … …  
    204217that version instead if you wish.)  Do not make any other change in
    205218these notices.
    206 .
     219
    207220  Once this change is made in a given copy, it is irreversible for
    208221that copy, so the ordinary GNU General Public License applies to all
    … …  
    255268Any executables containing that work also fall under Section 6,
    256269whether or not they are linked directly with the Library itself.
    257 .
    258   6. As an exception to the Sections above, you may also compile or
     270
     271  6. As an exception to the Sections above, you may also combine or
    259272link a "work that uses the Library" with the Library to produce a
    260273work containing portions of the Library, and distribute that work
    … …  
    283296    to use the modified definitions.)
    284297
    285     b) Accompany the work with a written offer, valid for at
     298    b) Use a suitable shared library mechanism for linking with the
     299    Library.  A suitable mechanism is one that (1) uses at run time a
     300    copy of the library already present on the user's computer system,
     301    rather than copying library functions into the executable, and (2)
     302    will operate properly with a modified version of the library, if
     303    the user installs one, as long as the modified version is
     304    interface-compatible with the version that the work was made with.
     305
     306    c) Accompany the work with a written offer, valid for at
    286307    least three years, to give the same user the materials
    287308    specified in Subsection 6a, above, for a charge no more
    288309    than the cost of performing this distribution.
    289310
    290     c) If distribution of the work is made by offering access to copy
     311    d) If distribution of the work is made by offering access to copy
    291312    from a designated place, offer equivalent access to copy the above
    292313    specified materials from the same place.
    293314
    294     d) Verify that the user has already received a copy of these
     315    e) Verify that the user has already received a copy of these
    295316    materials or that you have already sent this user a copy.
    296317
    … …  
    298319Library" must include any data and utility programs needed for
    299320reproducing the executable from it.  However, as a special exception,
    300 the source code distributed need not include anything that is normally
    301 distributed (in either source or binary form) with the major
     321the materials to be distributed need not include anything that is
     322normally distributed (in either source or binary form) with the major
    302323components (compiler, kernel, and so on) of the operating system on
    303324which the executable runs, unless that component itself accompanies
    … …  
    309330use both them and the Library together in an executable that you
    310331distribute.
    311 .
     332
    312333  7. You may place library facilities that are a work based on the
    313334Library side-by-side in a single library together with other library
    … …  
    348369subject to these terms and conditions.  You may not impose any further
    349370restrictions on the recipients' exercise of the rights granted herein.
    350 You are not responsible for enforcing compliance by third parties to
     371You are not responsible for enforcing compliance by third parties with
    351372this License.
    352 .
     373
    353374  11. If, as a consequence of a court judgment or allegation of patent
    354375infringement or for any other reason (not limited to patent issues),
    … …  
    391412
    392413  13. The Free Software Foundation may publish revised and/or new
    393 versions of the Library General Public License from time to time.
     414versions of the Lesser General Public License from time to time.
    394415Such new versions will be similar in spirit to the present version,
    395416but may differ in detail to address new problems or concerns.
    … …  
    402423license version number, you may choose any version ever published by
    403424the Free Software Foundation.
    404 .
     425
    405426  14. If you wish to incorporate parts of the Library into other free
    406427programs whose distribution conditions are incompatible with these,
    … …  
    436457
    437458                     END OF TERMS AND CONDITIONS
     459
     460           How to Apply These Terms to Your New Libraries
     461
     462  If you develop a new library, and you want it to be of the greatest
     463possible use to the public, we recommend making it free software that
     464everyone can redistribute and change.  You can do so by permitting
     465redistribution under these terms (or, alternatively, under the terms of the
     466ordinary General Public License).
     467
     468  To apply these terms, attach the following notices to the library.  It is
     469safest to attach them to the start of each source file to most effectively
     470convey the exclusion of warranty; and each file should have at least the
     471"copyright" line and a pointer to where the full notice is found.
     472
     473    <one line to give the library's name and a brief idea of what it does.>
     474    Copyright (C) <year>  <name of author>
     475
     476    This library is free software; you can redistribute it and/or
     477    modify it under the terms of the GNU Lesser General Public
     478    License as published by the Free Software Foundation; either
     479    version 2.1 of the License, or (at your option) any later version.
     480
     481    This library is distributed in the hope that it will be useful,
     482    but WITHOUT ANY WARRANTY; without even the implied warranty of
     483    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     484    Lesser General Public License for more details.
     485
     486    You should have received a copy of the GNU Lesser General Public
     487    License along with this library; if not, write to the Free Software
     488    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
     489
     490Also add information on how to contact you by electronic and paper mail.
     491
     492You should also get your employer (if you work as a programmer) or your
     493school, if any, to sign a "copyright disclaimer" for the library, if
     494necessary.  Here is a sample; alter the names:
     495
     496  Yoyodyne, Inc., hereby disclaims all copyright interest in the
     497  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
     498
     499  <signature of Ty Coon>, 1 April 1990
     500  Ty Coon, President of Vice
     501
     502That's all there is to it!
     503
     504
  • trunk/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js

    r3664 r4506  
    11/**
    2  * $RCSfile: editor_plugin_src.js,v $
    3  * $Revision: 1.11 $
    4  * $Date: 2006/03/22 12:21:21 $
     2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
    53 *
    64 * @author Moxiecode
    … …  
    97
    108/* Import plugin specific language pack */
    11 tinyMCE.importPluginLanguagePack('autosave', 'en,tr,sv,cs,he,nb,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl,pt_br');
     9tinyMCE.importPluginLanguagePack('autosave');
    1210
    1311var TinyMCE_AutoSavePlugin = {
    … …  
    1513                return {
    1614                        longname : 'Auto save',
    17                         author : 'Moxiecode Systems',
     15                        author : 'Moxiecode Systems AB',
    1816                        authorurl : 'http://tinymce.moxiecode.com',
    1917                        infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
  • trunk/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js

    r4080 r4506  
    11/**
    2  * $RCSfile: editor_plugin_src.js,v $
    3  * $Revision: 1.16 $
    4  * $Date: 2006/02/10 21:34:28 $
     2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
    53 *
    64 * @author Moxiecode
    … …  
    97
    108/* Import plugin specific language pack */
    11 tinyMCE.importPluginLanguagePack('directionality', 'en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');
     9tinyMCE.importPluginLanguagePack('directionality');
    1210
    1311var TinyMCE_DirectionalityPlugin = {
    … …  
    1513                return {
    1614                        longname : 'Directionality',
    17                         author : 'Moxiecode Systems',
     15                        author : 'Moxiecode Systems AB',
    1816                        authorurl : 'http://tinymce.moxiecode.com',
    1917                        infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
  • trunk/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js

    r3703 r4506  
    11/**
    2  * $RCSfile: editor_plugin_src.js,v $
    3  * $Revision: 1.8 $
    4  * $Date: 2006/02/06 20:02:38 $
     2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
    53 *
    64 * Moxiecode DHTML Windows script.
    … …  
    1614                return {
    1715                        longname : 'Inline Popups',
    18                         author : 'Moxiecode Systems',
     16                        author : 'Moxiecode Systems AB',
    1917                        authorurl : 'http://tinymce.moxiecode.com',
    2018                        infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
    … …  
    437435TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
    438436        var iframe = document.createElement("iframe");
    439         var div = document.createElement("div");
     437        var div = document.createElement("div"), doc;
    440438
    441439        width = parseInt(width);
    … …  
    489487                // Give Safari some time to setup
    490488                window.setTimeout(function() {
    491                         doc = window.frames[id_prefix + '_iframe'].document;
     489                        var doc = window.frames[id_prefix + '_iframe'].document;
    492490                        doc.open();
    493491                        doc.write(html);
  • trunk/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js

    r3664 r4506  
    11/**
    2  * $RCSfile: mcwindows.js,v $
    3  * $Revision: 1.2 $
    4  * $Date: 2005/10/18 13:59:43 $
     2 * $Id: mcwindows.js 18 2006-06-29 14:11:23Z spocke $
    53 *
    64 * Moxiecode DHTML Windows script.
  • trunk/wp-includes/js/tinymce/plugins/paste/editor_plugin.js

    r4080 r4506  
    1 tinyMCE.importPluginLanguagePack('paste','en,tr,sv,cs,zh_cn,fr_ca,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_PastePlugin={getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){if(tinyMCE.isMSIE&&tinyMCE.getParam("paste_auto_cleanup_on_paste",false))tinyMCE.addEvent(inst.getBody(),"paste",TinyMCE_PastePlugin._handlePasteEvent);},getControlHTML:function(cn){switch(cn){case"pastetext":return tinyMCE.getButtonHTML(cn,'lang_paste_text_desc','{$pluginurl}/images/pastetext.gif','mcePasteText',true);case"pasteword":return tinyMCE.getButtonHTML(cn,'lang_paste_word_desc','{$pluginurl}/images/pasteword.gif','mcePasteWord',true);case"selectall":return tinyMCE.getButtonHTML(cn,'lang_selectall_desc','{$pluginurl}/images/selectall.gif','mceSelectAll',true);}return'';},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mcePasteText":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false))TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"),true);else{var template=new Array();template['file']='../../plugins/paste/pastetext.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertText(value['html'],value['linebreaks']);return true;case"mcePasteWord":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false)){var html=TinyMCE_PastePlugin._clipboardHTML();if(html&&html.length>0)TinyMCE_PastePlugin._insertWordContent(html);}else{var template=new Array();template['file']='../../plugins/paste/pasteword.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertWordContent(value);return true;case"mceSelectAll":tinyMCE.execInstanceCommand(editor_id,'selectall');return true;}return false;},_handlePasteEvent:function(e){switch(e.type){case"paste":var html=TinyMCE_PastePlugin._clipboardHTML();var r,inst=tinyMCE.selectedInstance;if(inst&&(r=inst.getRng())&&r.text.length>0)tinyMCE.execCommand('delete');if(html&&html.length>0)tinyMCE.execCommand('mcePasteWord',false,html);tinyMCE.cancelEvent(e);return false;}return true;},_insertText:function(content,bLinebreaks){if(content&&content.length>0){if(bLinebreaks){if(tinyMCE.getParam("paste_create_paragraphs",true)){var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=tinyMCE.regexpReplace(content,"\r\n\r\n","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\r\r","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\n\n","</p><p>","gi");if((pos=content.indexOf('</p><p>'))!=-1){tinyMCE.execCommand("Delete");var node=tinyMCE.selectedInstance.getFocusElement();var breakElms=new Array();do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(tinyMCE.getParam("paste_create_linebreaks",true)){content=tinyMCE.regexpReplace(content,"\r\n","<br />","gi");content=tinyMCE.regexpReplace(content,"\r","<br />","gi");content=tinyMCE.regexpReplace(content,"\n","<br />","gi");}}tinyMCE.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);var cb;if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('before', content)");var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(new RegExp('<(!--)([^>]*)(--)>','g'),"");if(tinyMCE.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(tinyMCE.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(tinyMCE.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+TinyMCE_PastePlugin._reEscape(""+document.location)+'','gi'),'href="'+tinyMCE.settings['document_base_url']);content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!tinyMCE.settings['force_p_newlines']){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinyMCE.isMSIE&&!tinyMCE.settings['force_p_newlines']){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(tinyMCE.getParam("paste_convert_middot_lists",true)){var div=document.createElement("div");div.innerHTML=content;var className=tinyMCE.getParam("paste_unindented_list_class","unIndentedList");while(TinyMCE_PastePlugin._convertMiddots(div,"--list--"));while(TinyMCE_PastePlugin._convertMiddots(div,middot,className));while(TinyMCE_PastePlugin._convertMiddots(div,bull));content=div.innerHTML;}if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi,'<p>&nbsp;&nbsp;</p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b>&nbsp;<\/b>/gi,'<b>&nbsp;&nbsp;</b>');content=content.replace(/^(&nbsp;)*/gi,'');}content=content.replace(/--list--/gi,"");if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('after', content)");tinyMCE.execCommand("mceInsertContent",false,content);window.setTimeout('tinyMCE.execCommand("mceCleanup");',1);}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var mdot=String.fromCharCode(183);var bull=String.fromCharCode(8226);var nodes=div.getElementsByTagName("p");var prevul;for(var i=0;i<nodes.length;i++){var p=nodes[i];if(p.innerHTML.indexOf(search)==0){var ul=document.createElement("ul");if(class_name)ul.className=class_name;var li=document.createElement("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');ul.appendChild(li);var np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)){if(!prevul){prevul=ul;ul=document.createElement("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}var cp=np.nextSibling;var li=document.createElement("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}};tinyMCE.addPlugin("paste",TinyMCE_PastePlugin);
     1/**
     2 * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
     3 *
     4 * @author Moxiecode
     5 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
     6 */
     7
     8/* Import plugin specific language pack */
     9tinyMCE.importPluginLanguagePack('paste');
     10
     11var TinyMCE_PastePlugin = {
     12        getInfo : function() {
     13                return {
     14                        longname : 'Paste text/word',
     15                        author : 'Moxiecode Systems AB',
     16                        authorurl : 'http://tinymce.moxiecode.com',
     17                        infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',
     18                        version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
     19                };
     20        },
     21
     22        initInstance : function(inst) {
     23                if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false))
     24                        tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent);
     25        },
     26
     27        getControlHTML : function(cn) {
     28                switch (cn) {
     29                        case "pastetext":
     30                                return tinyMCE.getButtonHTML(cn, 'lang_paste_text_desc', '{$pluginurl}/images/pastetext.gif', 'mcePasteText', true);
     31
     32                        case "pasteword":
     33                                return tinyMCE.getButtonHTML(cn, 'lang_paste_word_desc', '{$pluginurl}/images/pasteword.gif', 'mcePasteWord', true);
     34
     35                        case "selectall":
     36                                return tinyMCE.getButtonHTML(cn, 'lang_selectall_desc', '{$pluginurl}/images/selectall.gif', 'mceSelectAll', true);
     37                }
     38
     39                return '';
     40        },
     41
     42        execCommand : function(editor_id, element, command, user_interface, value) {
     43                switch (command) {
     44                        case "mcePasteText":
     45                                if (user_interface) {
     46                                        if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false))
     47                                                TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true);
     48                                        else {
     49                                                var template = new Array();
     50                                                template['file']        = '../../plugins/paste/pastetext.htm'; // Relative to theme
     51                                                template['width']  = 450;
     52                                                template['height'] = 400;
     53                                                var plain_text = "";
     54                                                tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'});
     55                                        }
     56                                } else
     57                                        TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']);
     58
     59                                return true;
     60
     61                        case "mcePasteWord":
     62                                if (user_interface) {
     63                                        if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) {
     64                                                TinyMCE_PastePlugin._insertWordContent(TinyMCE_PastePlugin._clipboardHTML());
     65                                        } else {
     66                                                var template = new Array();
     67                                                template['file']        = '../../plugins/paste/pasteword.htm'; // Relative to theme
     68                                                template['width']  = 450;
     69                                                template['height'] = 400;
     70                                                var plain_text = "";
     71                                                tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'});
     72                                        }
     73                                } else
     74                                        TinyMCE_PastePlugin._insertWordContent(value);
     75
     76                                return true;
     77
     78                        case "mceSelectAll":
     79                                tinyMCE.execInstanceCommand(editor_id, 'selectall');
     80                                return true;
     81
     82                }
     83
     84                // Pass to next handler in chain
     85                return false;
     86        },
     87
     88        // Private plugin internal methods
     89
     90        _handlePasteEvent : function(e) {
     91                switch (e.type) {
     92                        case "paste":
     93                                var html = TinyMCE_PastePlugin._clipboardHTML();
     94                                var r, inst = tinyMCE.selectedInstance;
     95
     96                                // Removes italic, strong etc, the if was needed due to bug #1437114
     97                                if (inst && (r = inst.getRng()) && r.text.length > 0)
     98                                        tinyMCE.execCommand('delete');
     99
     100                                if (html && html.length > 0)
     101                                        tinyMCE.execCommand('mcePasteWord', false, html);
     102
     103                                tinyMCE.cancelEvent(e);
     104                                return false;
     105                }
     106
     107                return true;
     108        },
     109
     110        _insertText : function(content, bLinebreaks) {
     111                if (content && content.length > 0) {
     112                        if (bLinebreaks) {
     113                                // Special paragraph treatment
     114                                if (tinyMCE.getParam("paste_create_paragraphs", true)) {
     115                                        var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
     116                                        for (var i=0; i<rl.length; i+=2)
     117                                                content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
     118
     119                                        content = tinyMCE.regexpReplace(content, "\r\n\r\n", "</p><p>", "gi");
     120                                        content = tinyMCE.regexpReplace(content, "\r\r", "</p><p>", "gi");
     121                                        content = tinyMCE.regexpReplace(content, "\n\n", "</p><p>", "gi");
     122
     123                                        // Has paragraphs
     124                                        if ((pos = content.indexOf('</p><p>')) != -1) {
     125                                                tinyMCE.execCommand("Delete");
     126
     127                                                var node = tinyMCE.selectedInstance.getFocusElement();
     128
     129                                                // Get list of elements to break
     130                                                var breakElms = new Array();
     131
     132                                                do {
     133                                                        if (node.nodeType == 1) {
     134                                                                // Don't break tables and break at body
     135                                                                if (node.nodeName == "TD" || node.nodeName == "BODY")
     136                                                                        break;
     137               
     138                                                                breakElms[breakElms.length] = node;
     139                                                        }
     140                                                } while(node = node.parentNode);
     141
     142                                                var before = "", after = "</p>";
     143                                                before += content.substring(0, pos);
     144
     145                                                for (var i=0; i<breakElms.length; i++) {
     146                                                        before += "</" + breakElms[i].nodeName + ">";
     147                                                        after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">";
     148                                                }
     149
     150                                                before += "<p>";
     151                                                content = before + content.substring(pos+7) + after;
     152                                        }
     153                                }
     154
     155                                if (tinyMCE.getParam("paste_create_linebreaks", true)) {
     156                                        content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
     157                                        content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
     158                                        content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
     159                                }
     160                        }
     161               
     162                        tinyMCE.execCommand("mceInsertRawHTML", false, content);
     163                }
     164        },
     165
     166        _insertWordContent : function(content) {
     167                if (content && content.length > 0) {
     168                        // Cleanup Word content
     169                        var bull = String.fromCharCode(8226);
     170                        var middot = String.fromCharCode(183);
     171                        var cb;
     172
     173                        if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "")
     174                                content = eval(cb + "('before', content)");
     175
     176                        var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
     177                        for (var i=0; i<rl.length; i+=2)
     178                                content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
     179
     180                        if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) {
     181                                content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
     182                        }
     183
     184                        content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
     185                        content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
     186                        content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
     187                        content = content.replace(/<o:p><\/o:p>/gi, "");
     188                        content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
     189                        content = content.replace(new RegExp('<(!--)([^>]*)(--)>', 'g'), "");  // Word comments
     190
     191                        if (tinyMCE.getParam("paste_remove_spans", true))
     192                                content = content.replace(/<\/?span[^>]*>/gi, "");
     193
     194                        if (tinyMCE.getParam("paste_remove_styles", true))
     195                                content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3");
     196
     197                        content = content.replace(/<\/?font[^>]*>/gi, "");
     198
     199                        // Strips class attributes.
     200                        switch (tinyMCE.getParam("paste_strip_class_attributes", "all")) {
     201                                case "all":
     202                                        content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
     203                                        break;
     204
     205                                case "mso":
     206                                        content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3");
     207                                        break;
     208                        }
     209
     210                        content = content.replace(new RegExp('href="?' + TinyMCE_PastePlugin._reEscape("" + document.location) + '', 'gi'), 'href="' + tinyMCE.settings['document_base_url']);
     211                        content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
     212                        content = content.replace(/<\\?\?xml[^>]*>/gi, "");
     213                        content = content.replace(/<\/?\w+:[^>]*>/gi, "");
     214                        content = content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi, ""); // Remove pagebreaks
     215                        content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks
     216
     217        //              content = content.replace(/\/?&nbsp;*/gi, ""); &nbsp;
     218        //              content = content.replace(/<p>&nbsp;<\/p>/gi, '');
     219
     220                        if (!tinyMCE.settings['force_p_newlines']) {
     221                                content = content.replace('', '' ,'gi');
     222                                content = content.replace('</p>', '<br /><br />' ,'gi');
     223                        }
     224
     225                        if (!tinyMCE.isMSIE && !tinyMCE.settings['force_p_newlines']) {
     226                                content = content.replace(/<\/?p[^>]*>/gi, "");
     227                        }
     228
     229                        content = content.replace(/<\/?div[^>]*>/gi, "");
     230
     231                        // Convert all middlot lists to UL lists
     232                        if (tinyMCE.getParam("paste_convert_middot_lists", true)) {
     233                                var div = document.createElement("div");
     234                                div.innerHTML = content;
     235
     236                                // Convert all middot paragraphs to li elements
     237                                var className = tinyMCE.getParam("paste_unindented_list_class", "unIndentedList");
     238
     239                                while (TinyMCE_PastePlugin._convertMiddots(div, "--list--")) ; // bull
     240                                while (TinyMCE_PastePlugin._convertMiddots(div, middot, className)) ; // Middot
     241                                while (TinyMCE_PastePlugin._convertMiddots(div, bull)) ; // bull
     242
     243                                content = div.innerHTML;
     244                        }
     245
     246                        // Replace all headers with strong and fix some other issues
     247                        if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) {
     248                                content = content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi, '<p>&nbsp;&nbsp;</p>');
     249                                content = content.replace(/<h[1-6]>/gi, '<p><b>');
     250                                content = content.replace(/<\/h[1-6]>/gi, '</b></p>');
     251                                content = content.replace(/<b>&nbsp;<\/b>/gi, '<b>&nbsp;&nbsp;</b>');
     252                                content = content.replace(/^(&nbsp;)*/gi, '');
     253                        }
     254
     255                        content = content.replace(/--list--/gi, ""); // Remove --list--
     256
     257                        if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "")
     258                                content = eval(cb + "('after', content)");
     259
     260                        // Insert cleaned content
     261                        tinyMCE.execCommand("mceInsertContent", false, content);
     262
     263                        if (tinyMCE.getParam('paste_force_cleanup_wordpaste', true))
     264                                window.setTimeout('tinyMCE.execCommand("mceCleanup");', 1); // Do normal cleanup detached from this thread
     265                }
     266        },
     267
     268        _reEscape : function(s) {
     269                var l = "?.\\*[](){}+^$:";
     270                var o = "";
     271
     272                for (var i=0; i<s.length; i++) {
     273                        var c = s.charAt(i);
     274
     275                        if (l.indexOf(c) != -1)
     276                                o += '\\' + c;
     277                        else
     278                                o += c;
     279                }
     280
     281                return o;
     282        },
     283
     284        _convertMiddots : function(div, search, class_name) {
     285                var mdot = String.fromCharCode(183);
     286                var bull = String.fromCharCode(8226);
     287
     288                var nodes = div.getElementsByTagName("p");
     289                var prevul;
     290                for (var i=0; i<nodes.length; i++) {
     291                        var p = nodes[i];
     292
     293                        // Is middot
     294                        if (p.innerHTML.indexOf(search) == 0) {
     295                                var ul = document.createElement("ul");
     296
     297                                if (class_name)
     298                                        ul.className = class_name;
     299
     300                                // Add the first one
     301                                var li = document.createElement("li");
     302                                li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
     303                                ul.appendChild(li);
     304
     305                                // Add the rest
     306                                var np = p.nextSibling;
     307                                while (np) {
     308                                // If the node is whitespace, then
     309                                // ignore it and continue on.
     310                                if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) {
     311                                        np = np.nextSibling;
     312                                        continue;
     313                                }
     314
     315                                        if (search == mdot) {
     316                                                if (np.nodeType == 1 && new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)) {
     317                                                        // Second level of nesting
     318                                                        if (!prevul) {
     319                                                                prevul = ul;
     320                                                                ul = document.createElement("ul");
     321                                                                prevul.appendChild(ul);
     322                                                        }
     323                                                        np.innerHTML = np.innerHTML.replace(/^o/, '');
     324                                                } else {
     325                                                        // Pop the stack if we're going back up to the first level
     326                                                        if (prevul) {
     327                                                                ul = prevul;
     328                                                                prevul = null;
     329                                                        }
     330                                                        // Not element or middot paragraph
     331                                                        if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
     332                                                                break;
     333                                                }
     334                                        } else {
     335                                                // Not element or middot paragraph
     336                                                if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
     337                                                        break;
     338                                        }
     339
     340                                        var cp = np.nextSibling;
     341                                        var li = document.createElement("li");
     342                                        li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
     343                                        np.parentNode.removeChild(np);
     344                                        ul.appendChild(li);
     345                                        np = cp;
     346                                }
     347
     348                                p.parentNode.replaceChild(ul, p);
     349
     350                                return true;
     351                        }
     352                }
     353
     354                return false;
     355        },
     356
     357        _clipboardHTML : function() {
     358                var div = document.getElementById('_TinyMCE_clipboardHTML');
     359
     360                if (!div) {
     361                        var div = document.createElement('DIV');
     362                        div.id = '_TinyMCE_clipboardHTML';
     363
     364                        with (div.style) {
     365                                visibility = 'hidden';
     366                                overflow = 'hidden';
     367                                position = 'absolute';
     368                                width = 1;
     369                                height = 1;
     370                        }
     371
     372                        document.body.appendChild(div);
     373                }
     374
     375                div.innerHTML = '';
     376                var rng = document.body.createTextRange();
     377                rng.moveToElementText(div);
     378                rng.execCommand('Paste');
     379                var html = div.innerHTML;
     380                div.innerHTML = '';
     381                return html;
     382        }
     383};
     384
     385tinyMCE.addPlugin("paste", TinyMCE_PastePlugin);
  • trunk/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js

    r3664 r4506  
    1515function onLoadInit() {
    1616        tinyMCEPopup.resizeToInnerSize();
     17
     18        // Remove Gecko spellchecking
     19        if (tinyMCE.isGecko)
     20                document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
    1721
    1822        resizeInputs();
  • trunk/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js

    r3664 r4506  
    2626function initIframe(doc) {
    2727        var dir = tinyMCE.selectedInstance.settings['directionality'];
     28
    2829        doc.body.dir = dir;
     30
     31        // Remove Gecko spellchecking
     32        if (tinyMCE.isGecko)
     33                doc.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
     34
    2935        resizeInputs();
    3036}
  • trunk/wp-includes/js/tinymce/themes/advanced/charmap.htm

    r3664 r4506  
    77        <base target="_self" />
    88</head>
    9 <body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="display: none">
     9<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
    1010<table align="center" border="0" cellspacing="0" cellpadding="2">
    1111    <tr>
  • trunk/wp-includes/js/tinymce/themes/advanced/color_picker.htm

    r3664 r4506  
    66        <base target="_self" />
    77</head>
    8 <body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="margin: 3px; display: none">
     8<body onload="tinyMCEPopup.executeOnLoad('init();');" style="margin: 3px; display: none">
    99        <div align="center">
    1010           <script language="javascript" type="text/javascript">renderColorMap();</script>
  • trunk/wp-includes/js/tinymce/themes/advanced/css/editor_content.css

    r3664 r4506  
    1313.mceVisualAid {
    1414        border: 1px dashed #BBBBBB !important;
     15}
     16
     17div.mceVisualAid {
     18        background-image:url('../images/spacer.gif');
     19        visibility: visible !important;
    1520}
    1621
  • trunk/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css

    r3664 r4506  
    312312        height: 190px;
    313313}
     314
     315label.msg { display: none; }
     316label.invalid { color: #EE0000; display: inline; }
     317input.invalid { border: 1px solid #EE0000; }
    314318
    315319/* Disables the advanced tab in the table plugin. */
  • trunk/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css

    r3664 r4506  
    11/* This file contains the CSS data for the editor UI of TinyMCE instances */
    22
    3 .mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {
    4         border: 0; margin: 0; padding: 0; background: transparent;
    5 }
    6 
    7 .mceSeparatorLine {
    8         border: 0;
    9         padding: 0;
    10         margin-left: 4px;
    11         margin-right: 2px;
    12 }
    13 
    14 .mceSelectList {
    15         font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
    16         font-size: 7pt !important;
    17         font-weight: normal;
    18         margin-top: 3px;
    19         padding: 0;
    20         display: inline;
    21         vertical-align: top;
    22         background-color: #F0F0EE;
    23 }
    24 
    25 .mceLabel, .mceLabelDisabled {
    26         font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
    27         font-size: 9pt;
    28 }
    29 
    30 .mceLabel {
    31         color: #000000;
    32 }
    33 
    34 .mceLabelDisabled {
    35         cursor: text;
    36         color: #999999;
    37 }
    38 
    39 .mceEditor {
    40         background: #F0F0EE;
    41         border: 1px solid #cccccc;
    42         padding: 0;
    43         margin: 0;
    44 }
    45 
    46 .mceEditorArea {
    47         font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
    48         background: #FFFFFF;
    49         padding: 0;
    50         margin: 0;
    51 }
    52 
    53 .mceToolbarTop, .mceToolbarBottom {
    54         background: #F0F0EE;
    55         line-height: 1px;
    56         font-size: 1px;
    57 }
    58 
    59 .mceToolbarTop {
    60         border-bottom: 1px solid #cccccc;
    61         padding-bottom: 1px;
    62 }
    63 
    64 .mceToolbarBottom {
    65         border-top: 1px solid #cccccc;
    66 }
    67 
    68 .mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {
    69         height: 20px;
    70 }
    71 
    72 .mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {
    73         font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
    74         font-size: 9pt;
    75         padding: 2px;
    76         line-height: 16px;
    77         overflow: visible;
    78 }
    79 
    80 .mceStatusbarTop {
    81         border-bottom: 1px solid #cccccc;
    82 }
    83 
    84 .mceStatusbarBottom {
    85         border-top: 1px solid #cccccc;
    86 }
    87 
    88 .mceStatusbar {
    89         border-bottom: 1px solid #cccccc;
    90 }
    91 
    92 .mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {
    93         text-decoration: none;
    94         font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
    95         font-size: 9pt;
    96         color: #000000;
    97 }
    98 
    99 .mcePathItem:hover {
    100         text-decoration: underline;
    101 }
    102 
    103 .mceStatusbarPathText {
    104         float: left;
    105 }
    106 
    107 .mceStatusbarResize {
    108         float: right;
    109         background-image: url('../images/statusbar_resize.gif');
    110         background-repeat: no-repeat;
    111         width: 11px;
    112         height: 20px;
    113         cursor: se-resize;
    114 }
    115 
    116 .mceResizeBox {
    117         width: 10px;
    118         height: 10px;
    119         display: none;
    120         border: 1px dotted gray;
    121         margin: 0;
    122         padding: 0;
    123 }
     3.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0;  margin: 0;  padding: 0;  background: transparent;}
     4.mceSeparatorLine {border: 0; padding: 0; margin-left: 4px; margin-right: 2px;}
     5.mceSelectList {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 7pt !important; font-weight: normal; margin-top: 3px; padding: 0; display: inline; vertical-align: top; background-color: #F0F0EE;}
     6.mceLabel, .mceLabelDisabled {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;}
     7.mceLabel {color: #000000;}
     8.mceLabelDisabled {cursor: text;  color: #999999;}
     9.mceEditor {background: #F0F0EE;  border: 1px solid #cccccc;  padding: 0;  margin: 0;}
     10.mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;  background: #FFFFFF;  padding: 0;  margin: 0;  }
     11.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE;  line-height: 1px;  font-size: 1px;}
     12.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;}
     13.mceToolbarBottom {border-top: 1px solid #cccccc;}
     14.mceToolbarContainer {position: relative;  left: 0;  top: 0;  display: block;}
     15.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;}
     16.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;  font-size: 9pt;  padding: 2px;  line-height: 16px;  overflow: visible;}
     17.mceStatusbarTop {border-bottom: 1px solid #cccccc;}
     18.mceStatusbarBottom {border-top: 1px solid #cccccc;}
     19.mceStatusbar {border-bottom: 1px solid #cccccc;}
     20.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none;  font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;  font-size: 9pt;  color: #000000;}
     21.mcePathItem:hover {text-decoration: underline;}
     22.mceStatusbarPathText {float: left;}
     23.mceStatusbarResize {float: right;  background-image: url('../images/statusbar_resize.gif');  background-repeat: no-repeat;  width: 11px;  height: 20px;  cursor: se-resize;}
     24.mceResizeBox {width: 10px;  height: 10px;  display: none;  border: 1px dotted gray;  margin: 0;  padding: 0;}
     25.mceEditorIframe {border: 0;}
    12426
    12527/* Button CSS rules */
    12628
    127 a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {
    128         width: 20px;
    129         height: 20px;
    130         cursor: default;
    131         margin-top: 1px;
    132         margin-left: 1px;
    133 }
    134 
    135 a.mceButtonDisabled img {
    136         border: 0 !important;
    137 }
    138 
    139 a.mceButtonNormal img, a.mceButtonSelected img {
    140         border: 1px solid #F0F0EE !important;
    141 }
    142 
    143 a.mceButtonSelected img {
    144         border: 1px solid #6779AA !important;
    145         background-color: #D4D5D8;
    146 }
    147 
    148 a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {
    149         border: 1px solid #0A246A !important;
    150         cursor: default;
    151         background-color: #B6BDD2;
    152 }
    153 
    154 a.mceButtonDisabled img {
    155         -moz-opacity:0.3;
    156         opacity: 0.3;
    157         border: 1px solid #F0F0EE !important;
    158         cursor: default;
    159 }
    160 
    161 a.mceTiledButton img {
    162         background-image: url('../images/buttons.gif');
    163         background-repeat: no-repeat;
    164 }
    165 
    166 /* MSIE specific rules */
    167 
    168 * html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {
    169         border: 0 !important;
    170         margin-top: 2px;
    171         margin-bottom: 1px;
    172 }
    173 
    174 * html a.mceButtonDisabled img {
    175         filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
    176         border: 0 !important;
    177 }
    178 
    179 * html a.mceButtonDisabled {
    180         border: 1px solid #F0F0EE !important;
    181 }
    182 
    183 * html a.mceButtonNormal, * html a.mceButtonSelected {
    184         border: 1px solid #F0F0EE !important;
    185         cursor: default;
    186 }
    187 
    188 * html a.mceButtonSelected {
    189         border: 1px solid #6779AA !important;
    190         background-color: #D4D5D8;
    191 }
    192 
    193 * html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {
    194         border: 1px solid #0A246A !important;
    195         cursor: default;
    196         background-color: #B6BDD2;
    197 }
    198 
    199 * html .mceSelectList {
    200         margin-top: 2px;
    201 }
     29a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {width: 20px;  height: 20px;  cursor: default;  margin-top: 1px;  margin-left: 1px;}
     30a.mceButtonDisabled img {border: 0 !important;}
     31a.mceButtonNormal img, a.mceButtonSelected img {border: 1px solid #F0F0EE !important;}
     32a.mceButtonSelected img {border: 1px solid #6779AA !important;  background-color: #D4D5D8;}
     33a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {border: 1px solid #0A246A !important;  cursor: default;  background-color: #B6BDD2;}
     34a.mceButtonDisabled img {-moz-opacity:0.3;  opacity: 0.3;  border: 1px solid #F0F0EE !important;  cursor: default;}
     35a.mceTiledButton img {background-image: url('../images/buttons.gif');  background-repeat: no-repeat;}
    20236
    20337/* Menu button CSS rules */
    20438
    205 span.mceMenuButton img, span.mceMenuButtonSelected img {
    206         border: 1px solid #F0F0EE;
    207         margin-left: 1px;
    208 }
    209 
    210 span.mceMenuButtonSelected img {
    211         border: 1px solid #6779AA;
    212         background-color: #B6BDD2;
    213 }
    214 
    215 span.mceMenuButtonSelected img.mceMenuButton {
    216         border: 1px solid #F0F0EE;
    217         background-color: transparent;
    218 }
    219 
    220 span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {
    221         border-left: 0;
    222         margin-left: 0;
    223 }
    224 
    225 span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {
    226         border: 1px solid #0A246A;
    227         background-color: #B6BDD2;
    228 }
    229 
    230 span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {
    231         border-left: 0;
    232 }
    233 
    234 span.mceMenuButtonFocus img {
    235         border: 1px solid gray;
    236         border-right: 0;
    237         margin-left: 1px;
    238         background-color: #F5F4F2;
    239 }
    240 
    241 span.mceMenuButtonFocus img.mceMenuButton {
    242         border: 1px solid gray;
    243         border-left: 1px solid #F5F4F2;
    244         margin-left: 0;
    245 }
    246 
    247 /* Menu button MSIE specific rules */
    248 
    249 * html span.mceMenuButton, * html span.mceMenuButtonFocus {
    250         position: relative;
    251         left: 0;
    252         top: 0;
    253 }
    254 
    255 * html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {
    256         position: relative;
    257         top: 1px;
    258 }
    259 
    260 * html span.mceMenuHover img {
    261         border: 1px solid #0A246A;
    262         background-color: #B6BDD2;
    263 }
    264 
    265 * html span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {
    266         border: 1px solid #0A246A;
    267         background-color: #B6BDD2;
    268         border-left: 0;
    269 }
     39span.mceMenuButton img, span.mceMenuButtonSelected img {border: 1px solid #F0F0EE;  margin-left: 1px;}
     40span.mceMenuButtonSelected img {border: 1px solid #6779AA;  background-color: #B6BDD2;}
     41span.mceMenuButtonSelected img.mceMenuButton {border: 1px solid #F0F0EE;  background-color: transparent;}
     42span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {border-left: 0;  margin-left: 0;}
     43span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {border: 1px solid #0A246A;  background-color: #B6BDD2;}
     44span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {border-left: 0;}
     45span.mceMenuButtonFocus img {border: 1px solid gray;  border-right: 0;  margin-left: 1px;  background-color: #F5F4F2;}
     46span.mceMenuButtonFocus img.mceMenuButton {border: 1px solid gray;  border-left: 1px solid #F5F4F2;  margin-left: 0;}
     47span.mceMenuHover img {border: 1px solid #0A246A;  background-color: #B6BDD2;}
     48span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {border: 1px solid #0A246A;  background-color: #B6BDD2;  border-left: 0;}
    27049
    27150/* Menu */
    27251
    273 .mceMenu {
    274         position: absolute;
    275         left: 0;
    276         top: 0;
    277         display: none;
    278         z-index: 100;
    279         background-color: white;
    280         border: 1px solid gray;
    281         font-weight: normal;
    282 }
     52.mceMenu {position: absolute;  left: 0;  top: 0;  display: none;  z-index: 100;  background-color: white;  border: 1px solid gray;  font-weight: normal;}
     53.mceMenu a, .mceMenuTitle, .mceMenuDisabled {display: block;  width: 100%;  text-decoration: none;  background-color: white;  font-family: Tahoma, Verdana, Arial, Helvetica;  font-size: 11px;  line-height: 20px;  color: black;}
     54.mceMenu a:hover {background-color: #B6BDD2;  color: black;  text-decoration: none !important;}
     55.mceMenu span {padding-left: 10px;  padding-right: 10px;  display: block;  line-height: 20px;}
     56.mceMenuSeparator {border-bottom: 1px solid gray;  background-color: gray;  height: 1px;}
     57.mceMenuTitle span {padding-left: 5px;}
     58.mceMenuTitle {background-color: #DDDDDD;  font-weight: bold;}
     59.mceMenuDisabled {color: gray;}
     60span.mceMenuSelectedItem {background-image: url('../images/menu_check.gif');  background-repeat: no-repeat;  background-position: 5px 8px;  padding-left: 20px;}
     61span.mceMenuCheckItem {padding-left: 20px;}
     62span.mceMenuLine {display: block;  position: absolute;  left: 0;  top: -1px;  background-color: #F5F4F2;  width: 30px;  height: 1px;  overflow: hidden;  padding-left: 0;  padding-right: 0;}
     63.mceColors table, .mceColors td {margin: 0;  padding: 2px;}
     64a.mceMoreColors {width: 130px;  margin: 0;  padding: 0;  margin-left: 3px;  margin-bottom: 3px;  text-align: center;  border: 1px solid white;}
     65.mceColorPreview {position: absolute;  left: 0;  top: 0;  margin-left: 3px;  margin-top: 15px;  width: 16px;  height: 4px;  background-color: red;}
     66a.mceMoreColors:hover {border: 1px solid #0A246A;}
     67.mceColors td a {width: 9px;  height: 9px;  overflow: hidden;  border: 1px solid #808080;}
    28368
    284 .mceMenu a, .mceMenuTitle, .mceMenuDisabled {
    285         display: block;
    286         width: 100%;
    287         text-decoration: none;
    288         background-color: white;
    289         font-family: Tahoma, Verdana, Arial, Helvetica;
    290         font-size: 11px;
    291         line-height: 20px;
    292         color: black;
    293 }
     69/* MSIE 6 specific rules */
    29470
    295 .mceMenu a:hover {
    296         background-color: #B6BDD2;
    297         color: black;
    298 }
     71* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {border: 0 !important;  margin-top: 2px;  margin-bottom: 1px;}
     72* html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);  border: 0 !important;}
     73* html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;}
     74* html a.mceButtonNormal, * html a.mceButtonSelected {border: 1px solid #F0F0EE !important;  cursor: default;}
     75* html a.mceButtonSelected {border: 1px solid #6779AA !important;  background-color: #D4D5D8;}
     76* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {border: 1px solid #0A246A !important;  background-color: #B6BDD2;  cursor: default;}
     77* html .mceSelectList {margin-top: 2px;}
     78* html span.mceMenuButton, * html span.mceMenuButtonFocus {position: relative;  left: 0;  top: 0;}
     79* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {position: relative;  top: 1px;}
     80* html a.mceMoreColors {width: 132px;}
     81* html .mceColors td a {width: 10px;  height: 10px;}
     82* html .mceColorPreview {margin-left: 2px;  margin-top: 14px;}
    29983
    300 .mceMenu span {
    301         padding-left: 10px;
    302         padding-right: 10px;
    303         display: block;
    304         line-height: 20px;
    305 }
     84/* MSIE 7 specific rules */
    30685
    307 .mceMenuSeparator {
    308         border-bottom: 1px solid gray;
    309         background-color: gray;
    310         height: 1px;
    311 }
    312 
    313 .mceMenuTitle span {
    314         padding-left: 5px;
    315 }
    316 
    317 .mceMenuTitle {
    318         background-color: #DDDDDD;
    319         font-weight: bold;
    320 }
    321 
    322 .mceMenuDisabled {
    323         color: gray;
    324 }
    325 
    326 span.mceMenuSelectedItem {
    327         background-image: url('../images/menu_check.gif');
    328         background-repeat: no-repeat;
    329         background-position: 5px 8px;
    330         padding-left: 20px;
    331 }
    332 
    333 span.mceMenuCheckItem {
    334         padding-left: 20px;
    335 }
    336 
    337 span.mceMenuLine {
    338         display: block;
    339         position: absolute;
    340         left: 0;
    341         top: -1px;
    342         background-color: #F5F4F2;
    343         width: 30px;
    344         height: 1px;
    345         overflow: hidden;
    346         padding-left: 0;
    347         padding-right: 0;
    348 }
     86*:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important;  margin-top: 2px;  margin-bottom: 1px;}
     87*:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);  border: 0 !important;}
     88*:first-child+html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;}
     89*:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important;  cursor: default;}
     90*:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important;  background-color: #D4D5D8;}
     91*:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important;  background-color: #B6BDD2;  cursor: default;}
     92*:first-child+html .mceSelectList {margin-top: 2px;}
     93*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative;  left: 0;  top: 0;}
     94*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative;  top: 1px;}
     95*:first-child+html a.mceMoreColors {width: 132px;}
     96*:first-child+html .mceColors td a {width: 10px;  height: 10px;}
     97*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px;  margin-top: 14px; width: 14px;}
  • trunk/wp-includes/js/tinymce/themes/advanced/editor_template.js

    r4080 r4506  
    11/**
    2  * $RCSfile: editor_template_src.js,v $
    3  * $Revision: 1.96 $
    4  * $Date: 2006/04/18 13:32:52 $
     2 * $Id: editor_template_src.js 129 2006-10-23 09:45:17Z spocke $
    53 *
    64 * @author Moxiecode
    … …  
    1311var TinyMCE_AdvancedTheme = {
    1412        // Private theme fields
     13        _defColors : "000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",
    1514        _autoImportCSSClasses : true,
    1615        _resizer : {},
    … …  
    4443                ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
    4544                ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
    46                 ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'mceForeColor', true],
    47                 ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'mceBackColor', true],
     45                ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
     46                ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', true],
    4847                ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
    4948                ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
    … …  
    5251        ],
    5352
    54         _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells',
     53        _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells,delete_table',
    5554
    5655        /**
    … …  
    5857         */
    5958        getControlHTML : function(button_name) {
    60                 var i, x;
     59                var i, x, but;
    6160
    6261                // Lookup button in button list
    6362                for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
    64                         var but = TinyMCE_AdvancedTheme._buttons[i];
     63                        but = TinyMCE_AdvancedTheme._buttons[i];
     64
     65                        if (but[0] == button_name && (button_name == "forecolor" || button_name == "backcolor"))
     66                                return tinyMCE.getMenuButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3] + "Menu", but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
    6567
    6668                        if (but[0] == button_name)
    … …  
    154156        execCommand : function(editor_id, element, command, user_interface, value) {
    155157                switch (command) {
     158                        case 'mceHelp':
     159                                tinyMCE.openWindow({
     160                                        file : 'about.htm',
     161                                        width : 480,
     162                                        height : 380
     163                                }, {
     164                                        tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
     165                                        tinymce_releasedate : tinyMCE.releaseDate,
     166                                        inline : "yes"
     167                                });
     168                        return true;
     169
    156170                        case "mceLink":
    157171                                var inst = tinyMCE.getInstanceById(editor_id);
    … …  
    318332                                return true;
    319333
    320                         case "mceForeColor":
    321                                 var template = new Array();
    322                                 var elm = tinyMCE.selectedInstance.getFocusElement();
    323                                 var inputColor = tinyMCE.getAttrib(elm, "color");
    324 
    325                                 if (inputColor == '')
    326                                         inputColor = elm.style.color;
    327 
    328                                 if (!inputColor)
    329                                         inputColor = "#000000";
    330 
    331                                 template['file'] = 'color_picker.htm';
    332                                 template['width'] = 220;
    333                                 template['height'] = 190;
    334 
    335                                 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
     334                        case "forecolor":
     335                                var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm;
     336
     337                                TinyMCE_AdvancedTheme._hideMenus(editor_id);
     338
     339                                if (!fcp.exists()) {
     340                                        fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
     341                                        elm = fcp.getElement();
     342                                        elm._editor_id = editor_id;
     343                                        elm._command = "forecolor";
     344                                        elm._switchId = editor_id + "_forecolor";
     345                                        tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
     346                                        tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
     347                                        tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
     348                                }
     349
     350                                img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0];
     351                                p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
     352
     353                                fcp.moveTo(p.absLeft, p.absTop);
     354                                fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor;
     355                                fcp.show();
     356
     357                                return false;
     358
     359                        case "forecolorMenu":
     360                                TinyMCE_AdvancedTheme._hideMenus(editor_id);
     361
     362                                // Create color layer
     363                                var ml = new TinyMCE_Layer(editor_id + '_fcMenu');
     364
     365                                if (!ml.exists())
     366                                        ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor'));
     367
     368                                tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus');
     369                                ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl');
     370
     371                                ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
     372
     373                                if (tinyMCE.isOpera)
     374                                        ml.moveBy(0, -2);
     375
     376                                ml.show();
    336377                        return true;
    337378
    338                         case "mceBackColor":
    339                                 var template = new Array();
    340                                 var elm = tinyMCE.selectedInstance.getFocusElement();
    341                                 var inputColor = elm.style.backgroundColor;
    342 
    343                                 if (!inputColor)
    344                                         inputColor = "#000000";
    345 
    346                                 template['file'] = 'color_picker.htm';
    347                                 template['width'] = 220;
    348                                 template['height'] = 190;
    349 
    350                                 template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
    351                                 template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
    352 
    353                                 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
    354                                 //mceBackColor
     379                        case "HiliteColor":
     380                                var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img;
     381
     382                                TinyMCE_AdvancedTheme._hideMenus(editor_id);
     383
     384                                if (!bcp.exists()) {
     385                                        bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
     386                                        elm = bcp.getElement();
     387                                        elm._editor_id = editor_id;
     388                                        elm._command = "HiliteColor";
     389                                        elm._switchId = editor_id + "_backcolor";
     390                                        tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
     391                                        tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
     392                                        tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
     393                                }
     394
     395                                img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0];
     396                                p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
     397
     398                                bcp.moveTo(p.absLeft, p.absTop);
     399                                bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor;
     400                                bcp.show();
     401
     402                                return false;
     403
     404                        case "HiliteColorMenu":
     405                                TinyMCE_AdvancedTheme._hideMenus(editor_id);
     406
     407                                // Create color layer
     408                                var ml = new TinyMCE_Layer(editor_id + '_bcMenu');
     409
     410                                if (!ml.exists())
     411                                        ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor'));
     412
     413                                tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus');
     414                                ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl');
     415
     416                                ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
     417
     418                                if (tinyMCE.isOpera)
     419                                        ml.moveBy(0, -2);
     420
     421                                ml.show();
    355422                        return true;
    356423
    … …  
    434501        getEditorTemplate : function(settings, editorId) {
    435502                function removeFromArray(in_array, remove_array) {
    436                         var outArray = new Array();
     503                        var outArray = new Array(), skip;
    437504                       
    438505                        for (var i=0; i<in_array.length; i++) {
    … …  
    531598
    532599                                // Setup template html
    533                                 template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
     600                                template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
    534601
    535602                                if (toolbarLocation == "top") {
    536                                         template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
     603                                        template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
    537604                                }
    538605
    … …  
    545612
    546613                                if (toolbarLocation == "bottom") {
    547                                         template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
     614                                        template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
    548615                                }
    549616
    … …  
    616683                                                var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
    617684
    618                                                 for (var j=0; j<curContainer.length; j++) {
     685                                                curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
     686
     687                                                for (var j=0; j<curContainer.length; j++)
    619688                                                        curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
    620                                                 }
    621689
    622690                                                if (curContainer.length > 0) {
    … …  
    665733        },
    666734
     735        _handleMenuEvent : function(e) {
     736                var te = tinyMCE.isMSIE ? window.event.srcElement : e.target;
     737                tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId));
     738
     739                if (e.type == "click")
     740                        tinyMCE.execInstanceCommand(te._editor_id, te._command);
     741        },
     742
     743        _hideMenus : function(id) {
     744                var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu');
     745
     746                if (fcml.exists() && fcml.isVisible()) {
     747                        tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton');
     748                        fcml.hide();
     749                }
     750
     751                if (bcml.exists() && bcml.isVisible()) {
     752                        tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton');
     753                        bcml.hide();
     754                }
     755        },
     756
    667757        /**
    668758         * Node change handler.
    669759         */
    670760        handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
     761                var alignNode, breakOut, classNode;
     762
    671763                function selectByValue(select_elm, value, first_index) {
    672764                        first_index = typeof(first_index) == "undefined" ? false : true;
    … …  
    703795                var inst = tinyMCE.getInstanceById(editor_id);
    704796                var doc = inst.getDoc();
     797                TinyMCE_AdvancedTheme._hideMenus(editor_id);
    705798
    706799                if (pathElm) {
    … …  
    728821                                var nodeData = "";
    729822
     823                                if (nodeName.indexOf("html:") == 0)
     824                                        nodeName = nodeName.substring(5);
     825
    730826                                if (nodeName == "b") {
    731827                                        nodeName = "strong";
    … …  
    782878                                }
    783879
    784                                 if (getAttrib(path[i], 'href') != "") {
     880                                if (path[i].nodeName == 'A' && getAttrib(path[i], 'href') != "") {
    785881                                        var href = tinyMCE.getAttrib(path[i], "mce_href");
    786882
    … …  
    791887                                }
    792888
    793                                 if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
    794                                         nodeName = "flash";
    795                                         nodeData = "src: " + path[i].getAttribute('title');
     889                                className = tinyMCE.getAttrib(path[i], "class");
     890                                if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) {
     891                                        nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase();
     892                                        nodeData = path[i].getAttribute('title');
    796893                                }
    797894
    … …  
    10281125
    10291126                                case "IMG":
    1030                                 if (getAttrib(node, 'name').indexOf('mce_') != 0) {
     1127                                if (getAttrib(node, 'name').indexOf('mce_') != 0 && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) {
    10311128                                        tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
    10321129                                }
    … …  
    11491246                        }
    11501247                }
     1248
     1249                // Remove pesky table controls
     1250                inst.useCSS = false;
    11511251        },
    11521252
    … …  
    12561356        },
    12571357
     1358        _getColorHTML : function(id, n, cm) {
     1359                var i, h, cl;
     1360
     1361                h = '<span class="mceMenuLine"></span>';
     1362                cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(',');
     1363
     1364                h += '<table class="mceColors"><tr>';
     1365                for (i=0; i<cl.length; i++) {
     1366                        c = 'tinyMCE.execInstanceCommand(\'' + id + '\', \'' + cm + '\', false, \'#' + cl[i] + '\');';
     1367                        h += '<td><a href="javascript:' + c + '" style="background-color: #' + cl[i] + '" onclick="' + c + ';return false;"></a></td>';
     1368
     1369                        if ((i+1) % 8 == 0)
     1370                                h += '</tr><tr>';
     1371                }
     1372
     1373                h += '</tr></table>';
     1374                /*
     1375                h += '<a href="" class="mceMoreColors">More colors</a>';
     1376                */
     1377
     1378                return h;
     1379        },
     1380
    12581381        _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
    12591382                tinyMCE.execCommand('mceBeginUndoLevel');
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js

    r3664 r4506  
    44}
    55
    6 // Fixes some charcode issues
    7 function fixContent(html) {
    8 /*      html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
    9         html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');
    10         html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');
    11         html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');*/
    12         return html;
    13 }
    14 
    156function onLoadInit() {
    167        tinyMCEPopup.resizeToInnerSize();
    178
    18         document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
     9        // Remove Gecko spellchecking
     10        if (tinyMCE.isGecko)
     11                document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
     12
     13        document.getElementById('htmlSource').value = tinyMCE.getContent(tinyMCE.getWindowArg('editor_id'));
     14
    1915        resizeInputs();
     16
     17        if (tinyMCE.getParam("theme_advanced_source_editor_wrap", true)) {
     18                setWrap('soft');
     19                document.getElementById('wraped').checked = true;
     20        }
    2021}
    2122
    2223function setWrap(val) {
    23         var s = document.forms[0].htmlSource;
     24        var s = document.getElementById('htmlSource');
    2425
    2526        s.wrap = val;
    … …  
    4445
    4546function resizeInputs() {
     47        var el = document.getElementById('htmlSource');
     48
    4649        if (!tinyMCE.isMSIE) {
    4750                 wHeight = self.innerHeight-80;
    … …  
    5255        }
    5356
    54         document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
    55         document.forms[0].htmlSource.style.width  = Math.abs(wWidth) + 'px';
     57        el.style.height = Math.abs(wHeight) + 'px';
     58        el.style.width  = Math.abs(wWidth) + 'px';
    5659}
    5760
    58 function renderWordWrap() {
    59         if (tinyMCE.isMSIE || tinyMCE.isGecko)
    60                 document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');
    61 }
  • trunk/wp-includes/js/tinymce/themes/advanced/langs/en.js

    r3664 r4506  
    3939theme_h5 : 'Heading 5',
    4040theme_h6 : 'Heading 6',
     41theme_blockquote : 'Blockquote',
     42theme_code : 'Code',
     43theme_samp : 'Code sample',
     44theme_dt : 'Definition term ',
     45theme_dd : 'Definition description',
    4146theme_colorpicker_title : 'Select a color',
    4247theme_colorpicker_apply : 'Apply',
    … …  
    7378not_set : '-- Not set --',
    7479close : 'Close',
    75 toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X'
     80toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X',
     81invalid_data : 'Error: Invalid values entered, these are marked in red.'
    7682});
  • trunk/wp-includes/js/tinymce/tiny_mce.js

    r4080 r4506  
    33
    44function TinyMCE_Engine() {
     5        var ua;
     6
    57        this.majorVersion = "2";
    6         this.minorVersion = "0.6.1";
    7         this.releaseDate = "2006-05-04";
     8        this.minorVersion = "0.8";
     9        this.releaseDate = "2006-10-23";
    810
    911        this.instances = new Array();
    … …  
    1618        this.currentConfig = 0;
    1719        this.eventHandlers = new Array();
     20        this.log = new Array();
     21        this.undoLevels = [];
     22        this.undoIndex = 0;
     23        this.typingUndoIndex = -1;
    1824
    1925        // Browser check
    20         var ua = navigator.userAgent;
     26        ua = navigator.userAgent;
    2127        this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
    2228        this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
    2329        this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
     30        this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1);
    2431        this.isGecko = ua.indexOf('Gecko') != -1;
    2532        this.isSafari = ua.indexOf('Safari') != -1;
    … …  
    4350        }
    4451
     52        this.isIE = this.isMSIE;
     53        this.isRealIE = this.isMSIE && !this.isOpera;
     54
    4555        // TinyMCE editor id instance counter
    4656        this.idCounter = 0;
    … …  
    4959TinyMCE_Engine.prototype = {
    5060        init : function(settings) {
    51                 var theme;
     61                var theme, nl, baseHREF = "", i;
     62
     63                // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry.
     64                if (this.isMSIE5_0)
     65                        return;
    5266
    5367                this.settings = settings;
    … …  
    6175                        var elements = document.getElementsByTagName('script');
    6276
     77                        // If base element found, add that infront of baseURL
     78                        nl = document.getElementsByTagName('base');
     79                        for (i=0; i<nl.length; i++) {
     80                                if (nl[i].href)
     81                                        baseHREF = nl[i].href;
     82                        }
     83
    6384                        for (var i=0; i<elements.length; i++) {
    6485                                if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_dev.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
    … …  
    7293                                                tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
    7394
    74                                         tinyMCE.baseURL = src;
     95                                        // Force it absolute if page has a base href
     96                                        if (baseHREF != "" && src.indexOf('://') == -1)
     97                                                tinyMCE.baseURL = baseHREF + src;
     98                                        else
     99                                                tinyMCE.baseURL = src;
     100
    75101                                        break;
    76102                                }
    … …  
    101127                this._def("editor_selector", "");
    102128                this._def("editor_deselector", "mceNoEditor");
    103                 this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]");
     129                this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],#td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang],cite[title|id|class|style|dir|lang],abbr[title|id|class|style|dir|lang],acronym[title|id|class|style|dir|lang],del[title|id|class|style|dir|lang|datetime|cite],ins[title|id|class|style|dir|lang|datetime|cite]");
    104130                this._def("extended_valid_elements", "");
    105131                this._def("invalid_elements", "");
    … …  
    123149                this._def("custom_undo_redo_keyboard_shortcuts", true);
    124150                this._def("custom_undo_redo_restore_selection", true);
     151                this._def("custom_undo_redo_global", false);
    125152                this._def("verify_html", true);
    126153                this._def("apply_source_formatting", false);
    … …  
    165192                this._def("hidden_tab_class", '');
    166193                this._def("display_tab_class", '');
     194                this._def("gecko_spellcheck", false);
    167195
    168196                // Force strict loading mode to false on non Gecko browsers
    … …  
    187215
    188216                // If not super absolute make it so
    189                 var baseHREF = tinyMCE.settings['document_base_url'];
     217                baseHREF = tinyMCE.settings['document_base_url'];
    190218                var h = document.location.href;
    191219                var p = h.indexOf('://');
    … …  
    208236
    209237                theme = this.settings['theme'];
    210                 this.blockRegExp = new RegExp("^(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)$", "i");
     238                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';
     239                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';
     240                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';
     241                this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
    211242                this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
    212243                this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
    … …  
    217248                this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
    218249
    219                 if (!tinyMCE.isMSIE)
     250                if (!tinyMCE.isIE || tinyMCE.isOpera)
    220251                        this.settings['force_br_newlines'] = false;
    221252
    … …  
    239270                        else
    240271                                this.settings['editor_css'] = cssPath;
    241                 } else
    242                         this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
     272                } else {
     273                        if (this.settings.editor_css != '')
     274                                this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
     275                }
    243276
    244277                if (tinyMCE.settings['debug']) {
    … …  
    256289                // Only do this once
    257290                if (this.configs.length == 0) {
    258                         // Is Safari enabled
    259                         if (this.isSafari && this.getParam('safari_warning', false))
    260                                 alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
    261 
    262291                        if (typeof(TinyMCECompressed) == "undefined") {
    263292                                tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
    264293
    265                                 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     294                                if (tinyMCE.isRealIE) {
    266295                                        if (document.body)
    267296                                                tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
    … …  
    289318
    290319                // Setup entities
    291                 settings['cleanup_entities'] = new Array();
    292                 var entities = tinyMCE.getParam('entities', '', true, ',');
    293                 for (var i=0; i<entities.length; i+=2)
    294                         settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
     320                if (tinyMCE.getParam('entity_encoding') == 'named') {
     321                        settings['cleanup_entities'] = new Array();
     322                        var entities = tinyMCE.getParam('entities', '', true, ',');
     323                        for (var i=0; i<entities.length; i+=2)
     324                                settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
     325                }
    295326
    296327                // Save away this config
    … …  
    300331                // Start loading first one in chain
    301332                this.loadNextScript();
     333
     334                // Force flicker free CSS backgrounds in IE
     335                if (this.isIE && !this.isOpera) {
     336                        try {
     337                                document.execCommand('BackgroundImageCache', false, true);
     338                        } catch (e) {
     339                        }
     340                }
    302341        },
    303342
    304343        _addUnloadEvents : function() {
    305                 if (tinyMCE.isMSIE) {
     344                if (tinyMCE.isIE) {
    306345                        if (tinyMCE.settings['add_unload_trigger']) {
    307346                                tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
    … …  
    317356                var v = tinyMCE.getParam(key, def_val);
    318357
    319                 v = t ? v.replace(/\s+/g,"") : v;
     358                v = t ? v.replace(/\s+/g, "") : v;
    320359
    321360                this.settings[key] = v;
    … …  
    410449
    411450                for (x = 0,csslen = ar.length; x<csslen; x++) {
    412                         ignore_css = false;
    413 
    414451                        if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) {
    415452                                /* Make sure it doesn't exist. */
    … …  
    467504
    468505        confirmAdd : function(e, settings) {
    469                 var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
     506                var elm = tinyMCE.isIE ? event.srcElement : e.target;
    470507                var elementId = elm.name ? elm.name : elm.id;
    471508
    … …  
    493530                                tinyMCE._setHTML(doc, inst.formElement.value);
    494531
    495                                 if (!tinyMCE.isMSIE)
     532                                if (!tinyMCE.isIE)
    496533                                        doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
    497534                        }
    … …  
    509546        },
    510547
     548        removeInstance : function(ti) {
     549                var t = [], n, i;
     550
     551                // Remove from instances
     552                for (n in tinyMCE.instances) {
     553                        i = tinyMCE.instances[n];
     554
     555                        if (tinyMCE.isInstance(i) && ti != i)
     556                                        t[n] = i;
     557                }
     558
     559                tinyMCE.instances = t;
     560
     561                // Remove from global undo/redo
     562                n = [];
     563                t = tinyMCE.undoLevels;
     564
     565                for (i=0; i<t.length; i++) {
     566                        if (t[i] != ti)
     567                                n.push(t[i]);
     568                }
     569
     570                tinyMCE.undoLevels = n;
     571                tinyMCE.undoIndex = n.length;
     572
     573                return ti;
     574        },
     575
    511576        removeMCEControl : function(editor_id) {
    512                 var inst = tinyMCE.getInstanceById(editor_id);
     577                var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn;
    513578
    514579                if (inst) {
    … …  
    516581
    517582                        editor_id = inst.editorId;
    518                         var html = tinyMCE.getContent(editor_id);
    519 
    520                         // Remove editor instance from instances array
    521                         var tmpInstances = new Array();
    522                         for (var instanceName in tinyMCE.instances) {
    523                                 var instance = tinyMCE.instances[instanceName];
    524                                 if (!tinyMCE.isInstance(instance))
    525                                         continue;
    526 
    527                                 if (instanceName != editor_id)
    528                                                 tmpInstances[instanceName] = instance;
    529                         }
    530                         tinyMCE.instances = tmpInstances;
     583                        h = tinyMCE.getContent(editor_id);
     584
     585                        this.removeInstance(inst);
    531586
    532587                        tinyMCE.selectedElement = null;
    … …  
    534589
    535590                        // Remove element
    536                         var replaceElement = document.getElementById(editor_id + "_parent");
    537                         var oldTargetElement = inst.oldTargetElement;
    538                         var targetName = oldTargetElement.nodeName.toLowerCase();
    539 
    540                         if (targetName == "textarea" || targetName == "input") {
    541                                 // Just show the old text area
    542                                 replaceElement.parentNode.removeChild(replaceElement);
    543                                 oldTargetElement.style.display = "inline";
    544                                 oldTargetElement.value = html;
     591                        re = document.getElementById(editor_id + "_parent");
     592                        ot = inst.oldTargetElement;
     593                        tn = ot.nodeName.toLowerCase();
     594
     595                        if (tn == "textarea" || tn == "input") {
     596                                re.parentNode.removeChild(re);
     597                                ot.style.display = "inline";
     598                                ot.value = h;
    545599                        } else {
    546                                 oldTargetElement.innerHTML = html;
    547                                 oldTargetElement.style.display = 'block';
    548 
    549                                 replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
    550                                 replaceElement.parentNode.removeChild(replaceElement);
     600                                ot.innerHTML = h;
     601                                ot.style.display = 'block';
     602                                re.parentNode.insertBefore(ot, re);
     603                                re.parentNode.removeChild(re);
    551604                        }
    552605                }
    … …  
    594647
    595648        execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
    596                 var inst = tinyMCE.getInstanceById(editor_id);
     649                var inst = tinyMCE.getInstanceById(editor_id), r;
     650
    597651                if (inst) {
     652                        r = inst.selection.getRng();
     653
    598654                        if (typeof(focus) == "undefined")
    599655                                focus = true;
    600656
    601                         if (focus)
     657                        // IE bug lost focus on images in absolute divs Bug #1534575
     658                        if (focus && (!r || !r.item))
    602659                                inst.contentWindow.focus();
    603660
    … …  
    606663
    607664                        this.selectedElement = inst.getFocusElement();
    608                         this.selectedInstance = inst;
     665                        inst.select();
    609666                        tinyMCE.execCommand(command, user_interface, value);
    610667
    611668                        // Cancel event so it doesn't call onbeforeonunlaod
    612                         if (tinyMCE.isMSIE && window.event != null)
     669                        if (tinyMCE.isIE && window.event != null)
    613670                                tinyMCE.cancelEvent(window.event);
    614671                }
    … …  
    616673
    617674        execCommand : function(command, user_interface, value) {
     675                var inst = tinyMCE.selectedInstance;
     676
    618677                // Default input
    619678                user_interface = user_interface ? user_interface : false;
    620679                value = value ? value : null;
    621680
    622                 if (tinyMCE.selectedInstance)
    623                         tinyMCE.selectedInstance.switchSettings();
     681                if (inst)
     682                        inst.switchSettings();
    624683
    625684                switch (command) {
    626                         case 'mceHelp':
    627                                 tinyMCE.openWindow({
    628                                         file : 'about.htm',
    629                                         width : 480,
    630                                         height : 380
    631                                 }, {
    632                                         tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
    633                                         tinymce_releasedate : tinyMCE.releaseDate,
    634                                         inline : "yes"
    635                                 });
    636                         return;
     685                        case "Undo":
     686                                if (this.getParam('custom_undo_redo_global')) {
     687                                        if (this.undoIndex > 0) {
     688                                                tinyMCE.nextUndoRedoAction = 'Undo';
     689                                                inst = this.undoLevels[--this.undoIndex];
     690                                                inst.select();
     691
     692                                                if (!tinyMCE.nextUndoRedoInstanceId)
     693                                                        inst.execCommand('Undo');
     694                                        }
     695                                } else
     696                                        inst.execCommand('Undo');
     697                                return true;
     698
     699                        case "Redo":
     700                                if (this.getParam('custom_undo_redo_global')) {
     701                                        if (this.undoIndex <= this.undoLevels.length - 1) {
     702                                                tinyMCE.nextUndoRedoAction = 'Redo';
     703                                                inst = this.undoLevels[this.undoIndex++];
     704                                                inst.select();
     705
     706                                                if (!tinyMCE.nextUndoRedoInstanceId)
     707                                                        inst.execCommand('Redo');
     708                                        }
     709                                } else
     710                                        inst.execCommand('Redo');
     711
     712                                return true;
    637713
    638714                        case 'mceFocus':
    639715                                var inst = tinyMCE.getInstanceById(value);
    640716                                if (inst)
    641                                         inst.contentWindow.focus();
     717                                        inst.getWin().focus();
    642718                        return;
    643719
    … …  
    658734                        case "mceResetDesignMode":
    659735                                // Resets the designmode state of the editors in Gecko
    660                                 if (!tinyMCE.isMSIE) {
     736                                if (!tinyMCE.isIE) {
    661737                                        for (var n in tinyMCE.instances) {
    662738                                                if (!tinyMCE.isInstance(tinyMCE.instances[n]))
    … …  
    674750                }
    675751
    676                 if (this.selectedInstance) {
    677                         this.selectedInstance.execCommand(command, user_interface, value);
     752                if (inst) {
     753                        inst.execCommand(command, user_interface, value);
    678754                } else if (tinyMCE.settings['focus_alert'])
    679755                        alert(tinyMCELang['lang_focus_alert']);
    … …  
    697773                if (aw.indexOf('%') == -1) {
    698774                        aw = parseInt(aw);
    699                         aw = aw < 0 ? 300 : aw;
     775                        aw = (isNaN(aw) || aw < 0) ? 300 : aw;
    700776                        aw = aw + "px";
    701777                }
    … …  
    703779                if (ah.indexOf('%') == -1) {
    704780                        ah = parseInt(ah);
    705                         ah = ah < 0 ? 240 : ah;
     781                        ah = (isNaN(ah) || ah < 0) ? 240 : ah;
    706782                        ah = ah + "px";
    707783                }
    708784
    709785                iframe.setAttribute("id", id);
     786                iframe.setAttribute("name", id);
    710787                iframe.setAttribute("class", "mceEditorIframe");
    711788                iframe.setAttribute("border", "0");
    … …  
    724801
    725802                // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
    726                 if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     803                if (tinyMCE.isRealIE)
    727804                        iframe.setAttribute("src", this.settings['default_document']);
    728805
    … …  
    735812
    736813                // MSIE 5.0 issue
    737                 if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     814                if (tinyMCE.isRealIE)
    738815                        replace_element.outerHTML = iframe.outerHTML;
    739816                else
    740817                        replace_element.parentNode.replaceChild(iframe, replace_element);
    741818
    742                 if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     819                if (tinyMCE.isRealIE)
    743820                        return win.frames[id];
    744821                else
    … …  
    747824
    748825        setupContent : function(editor_id) {
    749                 var inst = tinyMCE.instances[editor_id];
     826                var inst = tinyMCE.instances[editor_id], i;
    750827                var doc = inst.getDoc();
    751828                var head = doc.getElementsByTagName('head').item(0);
    … …  
    763840
    764841                // Not loaded correctly hit it again, Mozilla bug #997860
    765                 if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
     842                if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
    766843                        // This part will remove the designMode status
    767844                        // Failes first time in Firefox 1.5b2 on Mac
    … …  
    787864                }
    788865
     866                // BlockFormat shortcuts keys
     867                for (i=1; i<=6; i++)
     868                        inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, '<h' + i + '>');
     869
     870                inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '<p>');
     871                inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '<div>');
     872                inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '<address>');
     873
    789874                // Add default shortcuts for gecko
    790875                if (tinyMCE.isGecko) {
    … …  
    796881                // Setup span styles
    797882                if (tinyMCE.getParam("convert_fonts_to_spans"))
    798                         inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
     883                        inst.getBody().setAttribute('id', 'mceSpanFonts');
    799884
    800885                if (tinyMCE.settings['nowrap'])
    … …  
    805890
    806891                // Add on document element in Mozilla
    807                 if (!tinyMCE.isMSIE)
     892                if (!tinyMCE.isIE)
    808893                        doc.documentElement.editorId = editor_id;
    809894
    … …  
    824909                content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
    825910
    826                 if (tinyMCE.isMSIE) {
     911                if (tinyMCE.isIE) {
    827912                        // Ugly!!!
    828913                        window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
    … …  
    838923
    839924                // Fix for bug #958637
    840                 if (!tinyMCE.isMSIE) {
     925                if (!tinyMCE.isIE) {
    841926                        var contentElement = inst.getDoc().createElement("body");
    842927                        var doc = inst.getDoc();
    … …  
    850935                        if (tinyMCE.settings['cleanup_on_startup'])
    851936                                tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
    852                         else {
    853                                 // Convert all strong/em to b/i
    854                                 content = tinyMCE.regexpReplace(content, "<strong", "<b", "gi");
    855                                 content = tinyMCE.regexpReplace(content, "<em(/?)>", "<i$1>", "gi");
    856                                 content = tinyMCE.regexpReplace(content, "<em ", "<i ", "gi");
    857                                 content = tinyMCE.regexpReplace(content, "</strong>", "</b>", "gi");
    858                                 content = tinyMCE.regexpReplace(content, "</em>", "</i>", "gi");
     937                        else
    859938                                tinyMCE.setInnerHTML(inst.getBody(), content);
    860                         }
    861939
    862940                        tinyMCE.convertAllRelativeURLs(inst.getBody());
    … …  
    882960
    883961                // Re-add design mode on mozilla
    884                 if (!tinyMCE.isMSIE)
     962                if (!tinyMCE.isIE)
    885963                        tinyMCE.addEventHandlers(inst);
    886964
    887965                // Add blur handler
    888                 if (tinyMCE.isMSIE) {
     966                if (tinyMCE.isIE) {
    889967                        tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
    890968                        tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
    … …  
    899977
    900978                // Trigger node change, this call locks buttons for tables and so forth
    901                 tinyMCE.selectedInstance = inst;
     979                inst.select();
    902980                tinyMCE.selectedElement = inst.contentWindow.document.body;
    903981
    … …  
    918996                        // Remove mce_src from textnodes and comments
    919997                        tinyMCE.selectNodes(inst.getBody(), function(n) {
    920                                 if (n.nodeType == 3 || n.nodeType == 8) {
    921                                         n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
    922                                         n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
    923                                 }
     998                                if (n.nodeType == 3 || n.nodeType == 8)
     999                                        n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
    9241000
    9251001                                return false;
    … …  
    9271003                }
    9281004
     1005                // Remove Gecko spellchecking
     1006                if (tinyMCE.isGecko)
     1007                        inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck");
     1008
    9291009                // Cleanup any mess left from storyAwayURLs
    9301010                tinyMCE._removeInternal(inst.getBody());
    9311011
    932                 tinyMCE.selectedInstance = inst;
     1012                inst.select();
    9331013                tinyMCE.triggerNodeChange(false, true);
    9341014        },
    … …  
    9511031                        // Remove mce_src from textnodes and comments
    9521032                        tinyMCE.selectNodes(n, function(n) {
    953                                 if (n.nodeType == 3 || n.nodeType == 8) {
    954                                         n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
    955                                         n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
    956                                 }
     1033                                if (n.nodeType == 3 || n.nodeType == 8)
     1034                                        n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
    9571035
    9581036                                return false;
    9591037                        });
    960                 }
    961         },
    962 
    963         removeTinyMCEFormElements : function(form_obj) {
    964                 // Check if form is valid
    965                 if (typeof(form_obj) == "undefined" || form_obj == null)
    966                         return;
    967 
    968                 // If not a form, find the form
    969                 if (form_obj.nodeName != "FORM") {
    970                         if (form_obj.form)
    971                                 form_obj = form_obj.form;
    972                         else
    973                                 form_obj = tinyMCE.getParentElement(form_obj, "form");
    974                 }
    975 
    976                 // Still nothing
    977                 if (form_obj == null)
    978                         return;
    979 
    980                 // Disable all UI form elements that TinyMCE created
    981                 for (var i=0; i<form_obj.elements.length; i++) {
    982                         var elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
    983 
    984                         if (elementId.indexOf('mce_editor_') == 0)
    985                                 form_obj.elements[i].disabled = true;
    9861038                }
    9871039        },
    … …  
    10171069                                // Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks
    10181070                                // This logic forces the width/height to be in pixels while the user is drag/dropping
    1019                                 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     1071                                if (tinyMCE.isRealIE) {
    10201072                                        var ife = tinyMCE.selectedInstance.iframeElement;
    10211073
    … …  
    10351087
    10361088                        case "submit":
    1037                                 tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);
    10381089                                tinyMCE.triggerSave();
    10391090                                tinyMCE.isNotDirty = true;
    … …  
    10411092
    10421093                        case "reset":
    1043                                 var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;
     1094                                var formObj = tinyMCE.isIE ? window.event.srcElement : e.target;
    10441095
    10451096                                for (var i=0; i<document.forms.length; i++) {
    … …  
    10551106
    10561107                                if (e.target.editorId) {
    1057                                         tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1108                                        tinyMCE.instances[e.target.editorId].select();
    10581109                                } else {
    10591110                                        if (e.target.ownerDocument.editorId)
    1060                                                 tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];
     1111                                                tinyMCE.instances[e.target.ownerDocument.editorId].select();
    10611112                                }
    10621113
    … …  
    10651116
    10661117                                // Insert P element
    1067                                 if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
     1118                                if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
    10681119                                        // Insert P element instead of BR
    10691120                                        if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) {
    10701121                                                // Cancel event
    10711122                                                tinyMCE.execCommand("mceAddUndoLevel");
    1072                                                 tinyMCE.cancelEvent(e);
    1073                                                 return false;
     1123                                                return tinyMCE.cancelEvent(e);
    10741124                                        }
    10751125                                }
    10761126
    10771127                                // Handle backspace
    1078                                 if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
     1128                                if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
    10791129                                        // Insert P element instead of BR
    10801130                                        if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
    10811131                                                // Cancel event
    10821132                                                tinyMCE.execCommand("mceAddUndoLevel");
    1083                                                 tinyMCE.cancelEvent(e);
    1084                                                 return false;
     1133                                                return tinyMCE.cancelEvent(e);
    10851134                                        }
    10861135                                }
    10871136
    10881137                                // Return key pressed
    1089                                 if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
     1138                                if (tinyMCE.isIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
    10901139                                        if (e.target.editorId)
    1091                                                 tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1140                                                tinyMCE.instances[e.target.editorId].select();
    10921141
    10931142                                        if (tinyMCE.selectedInstance) {
    … …  
    11331182
    11341183                                if (e.target.editorId)
    1135                                         tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
    1136                                 else
    1137                                         return;
     1184                                        tinyMCE.instances[e.target.editorId].select();
    11381185
    11391186                                if (tinyMCE.selectedInstance)
    … …  
    11651212
    11661213                                // Fix empty elements on return/enter, check where enter occured
    1167                                 if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
     1214                                if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13)
    11681215                                        tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
    11691216
    11701217                                // Fix empty elements on return/enter
    1171                                 if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
     1218                                if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) {
    11721219                                        var elm = tinyMCE.enterKeyElement;
    11731220                                        if (elm) {
    … …  
    11951242
    11961243                                // MSIE custom key handling
    1197                                 if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {
     1244                                if (tinyMCE.isIE && tinyMCE.settings['custom_undo_redo']) {
    11981245                                        var keys = new Array(8,46); // Backspace,Delete
     1246
    11991247                                        for (var i=0; i<keys.length; i++) {
    12001248                                                if (keys[i] == e.keyCode) {
    … …  
    12111259                                // Handle Undo/Redo when typing content
    12121260
    1213                                 // Start typing (non position key)
    1214                                 if (!posKey && e.type == "keyup")
    1215                                         tinyMCE.execCommand("mceStartTyping");
     1261                                if (tinyMCE.isGecko) {
     1262                                        // Start typing (not a position key or ctrl key, but ctrl+x and ctrl+p is ok)
     1263                                        if (!posKey && e.type == "keyup" && !e.ctrlKey || (e.ctrlKey && (e.keyCode == 86 || e.keyCode == 88)))
     1264                                                tinyMCE.execCommand("mceStartTyping");
     1265                                } else {
     1266                                        // IE seems to be working better with this setting
     1267                                        if (!posKey && e.type == "keyup")
     1268                                                tinyMCE.execCommand("mceStartTyping");
     1269                                }
    12161270
    12171271                                // Store undo bookmark
    … …  
    12261280                                        tinyMCE.triggerNodeChange(false);
    12271281
    1228                                 if (tinyMCE.isMSIE && e.ctrlKey)
     1282                                if (tinyMCE.isIE && e.ctrlKey)
    12291283                                        window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
    12301284                        break;
    … …  
    12331287                        case "mouseup":
    12341288                        case "click":
     1289                        case "dblclick":
    12351290                        case "focus":
    12361291                                tinyMCE.hideMenus();
    … …  
    12421297
    12431298                                // Check instance event trigged on
    1244                                 var targetBody = tinyMCE.getParentElement(e.target, "body");
     1299                                var targetBody = tinyMCE.getParentElement(e.target, "html");
    12451300                                for (var instanceName in tinyMCE.instances) {
    12461301                                        if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
    … …  
    12521307                                        inst.autoResetDesignMode();
    12531308
    1254                                         if (inst.getBody() == targetBody) {
    1255                                                 tinyMCE.selectedInstance = inst;
     1309                                        // Use HTML element since users might click outside of body element
     1310                                        if (inst.getBody().parentNode == targetBody) {
     1311                                                inst.select();
    12561312                                                tinyMCE.selectedElement = e.target;
    12571313                                                tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
    … …  
    12621318
    12631319                                // Add first bookmark location
    1264                                 if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark)
     1320                                if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark && (e.type == "mouseup" || e.type == "dblclick"))
    12651321                                        tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
    1266 
    1267                                 if (tinyMCE.isSafari) {
    1268                                         tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.selection.getBookmark();
    1269                                         tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;
    1270 
    1271                                         var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
    1272 
    1273                                         // Patch the darned link
    1274                                         if (lnk && e.type == "mousedown") {
    1275                                                 lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));
    1276                                                 lnk.setAttribute("href", "javascript:void(0);");
    1277                                         }
    1278 
    1279                                         // Patch back
    1280                                         if (lnk && e.type == "click") {
    1281                                                 window.setTimeout(function() {
    1282                                                         lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));
    1283                                                         lnk.removeAttribute("mce_real_href");
    1284                                                 }, 10);
    1285                                         }
    1286                                 }
    12871322
    12881323                                // Reset selected node
    … …  
    12981333                                // Just in case
    12991334                                if (!tinyMCE.selectedInstance && e.target.editorId)
    1300                                         tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1335                                        tinyMCE.instances[e.target.editorId].select();
    13011336
    13021337                                return false;
    … …  
    13061341
    13071342        getButtonHTML : function(id, lang, img, cmd, ui, val) {
    1308                 var h = '', m, x;
     1343                var h = '', m, x, io = '';
    13091344
    13101345                cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
    … …  
    13181353                cmd += ');';
    13191354
     1355                // Patch for IE7 bug with hover out not restoring correctly
     1356                if (tinyMCE.isRealIE)
     1357                        io = 'onmouseover="tinyMCE.lastHover = this;"';
     1358
    13201359                // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
    1321                 if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isMSIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
     1360                if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
    13221361                        // Tiled button
    13231362                        x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
    1324                         h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';
     1363                        h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceTiledButton mceButtonNormal" target="_self">';
    13251364                        h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />';
    13261365                        h += '</a>';
    13271366                } else {
    13281367                        // Normal button
    1329                         h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceButtonNormal" target="_self">';
     1368                        h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">';
    13301369                        h += '<img src="' + img + '" title="{$' + lang + '}" />';
    13311370                        h += '</a>';
    … …  
    13351374        },
    13361375
     1376        getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) {
     1377                var h = '', m, x;
     1378
     1379                mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');';
     1380                cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
     1381
     1382                if (typeof(ui) != "undefined" && ui != null)
     1383                        cmd += ',' + ui;
     1384
     1385                if (typeof(val) != "undefined" && val != null)
     1386                        cmd += ",'" + val + "'";
     1387
     1388                cmd += ');';
     1389
     1390                // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
     1391                if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
     1392                        x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
     1393
     1394                        if (tinyMCE.isRealIE)
     1395                                h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
     1396                        else
     1397                                h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
     1398
     1399                        h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceMenuButtonNormal" target="_self">';
     1400                        h += '<img src="{$themeurl}/images/spacer.gif" style="width: 20px; height: 20px; background-position: ' + x + 'px 0" title="{$' + lang + '}" /></a>';
     1401                        h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
     1402                        h += '</a></span>';
     1403                } else {
     1404                        if (tinyMCE.isRealIE)
     1405                                h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
     1406                        else
     1407                                h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
     1408
     1409                        h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
     1410                        h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
     1411                        h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
     1412                        h += '</a></span>';
     1413                }
     1414
     1415                return h;
     1416        },
     1417
     1418        _menuButtonEvent : function(e, o) {
     1419                if (o.className == 'mceMenuButtonFocus')
     1420                        return;
     1421
     1422                if (e == 'over')
     1423                        o.className = o.className + ' mceMenuHover';
     1424                else
     1425                        o.className = o.className.replace(/\s.*$/, '');
     1426        },
     1427
    13371428        addButtonMap : function(m) {
    13381429                var i, a = m.replace(/\s+/, '').split(',');
    … …  
    13431434
    13441435        submitPatch : function() {
    1345                 tinyMCE.removeTinyMCEFormElements(this);
    13461436                tinyMCE.triggerSave();
     1437                tinyMCE.isNotDirty = true;
    13471438                this.mceOldSubmit();
    1348                 tinyMCE.isNotDirty = true;
    13491439        },
    13501440
    13511441        onLoad : function() {
     1442                var r;
     1443
    13521444                // Wait for everything to be loaded first
    13531445                if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) {
    … …  
    13561448                }
    13571449
    1358                 if (tinyMCE.isMSIE && !tinyMCE.isOpera && window.event.type == "readystatechange" && document.readyState != "complete")
     1450                if (tinyMCE.isRealIE && window.event.type == "readystatechange" && document.readyState != "complete")
    13591451                        return true;
    13601452
    … …  
    13631455
    13641456                tinyMCE.isLoaded = true;
     1457
     1458                // IE produces JS error if TinyMCE is placed in a frame
     1459                // It seems to have something to do with the selection not beeing
     1460                // correctly initialized in IE so this hack solves the problem
     1461                if (tinyMCE.isRealIE && document.body) {
     1462                        r = document.body.createTextRange();
     1463                        r.collapse(true);
     1464                        r.select();
     1465                }
    13651466
    13661467                tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad');
    … …  
    14041505                                                var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";
    14051506
    1406                                                 if (tinyMCE.getAttrib(element, "class").indexOf(deselector) != -1)
     1507                                                if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class")))
    14071508                                                        continue;
    14081509
    … …  
    14301531                                                var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);
    14311532
    1432                                                 if (selector != '' && tinyMCE.getAttrib(elm, "class").indexOf(selector) == -1)
     1533                                                if (selector != '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
    14331534                                                        continue;
    14341535
    … …  
    14361537                                                        trigger = selector != "" ? "true" : "";
    14371538
    1438                                                 if (tinyMCE.getAttrib(elm, "class").indexOf(deselector) != -1)
     1539                                                if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
    14391540                                                        continue;
    14401541
    … …  
    14761577                                        inst.selection.selectNode(inst.getBody(), true, true);
    14771578                                        inst.contentWindow.focus();
    1478                                 }, 10);
     1579                                }, 100);
    14791580                        }
    14801581
    … …  
    15281629        entityDecode : function(s) {
    15291630                var e = document.createElement("div");
     1631
    15301632                e.innerHTML = s;
    1531                 return e.innerHTML;
     1633
     1634                return e.firstChild.nodeValue;
    15321635        },
    15331636
    … …  
    15511654                        var editorId = inst.editorId;
    15521655                        var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
    1553                         var undoIndex = -1;
     1656                        var undoIndex = -1, doc;
    15541657                        var undoLevels = -1;
    15551658                        var anySelection = false;
    15561659                        var selectedText = inst.selection.getSelectedText();
    15571660
     1661                        if (tinyMCE.settings.auto_resize)
     1662                                inst.resizeToContent();
     1663
    15581664                        if (setup_content && tinyMCE.isGecko && inst.isHidden())
    15591665                                elm = inst.getBody();
    15601666
    15611667                        inst.switchSettings();
    1562 
    1563                         if (tinyMCE.settings["auto_resize"]) {
    1564                                 var doc = inst.getDoc();
    1565 
    1566                                 inst.iframeElement.style.width = doc.body.offsetWidth + "px";
    1567                                 inst.iframeElement.style.height = doc.body.offsetHeight + "px";
    1568                         }
    15691668
    15701669                        if (tinyMCE.selectedElement)
    … …  
    15911690                        content = eval(customCleanup + "(type, content, inst);");
    15921691
     1692                // Trigger theme cleanup
     1693                po = tinyMCE.themes[tinyMCE.settings['theme']];
     1694                if (po && po.cleanup)
     1695                        content = po.cleanup(type, content, inst);
     1696
    15931697                // Trigger plugin cleanups
    15941698                pl = inst.plugins;
    … …  
    16171721        },
    16181722
    1619         importPluginLanguagePack : function(name, valid_languages) {
    1620                 var lang = "en", b = tinyMCE.baseURL + '/plugins/' + name;
    1621 
    1622                 valid_languages = valid_languages.split(',');
    1623                 for (var i=0; i<valid_languages.length; i++) {
    1624                         if (tinyMCE.settings['language'] == valid_languages[i])
    1625                                 lang = tinyMCE.settings['language'];
    1626                 }
     1723        importPluginLanguagePack : function(name) {
     1724                var b = tinyMCE.baseURL + '/plugins/' + name;
    16271725
    16281726                if (this.plugins[name])
    16291727                        b = this.plugins[name].baseURL;
    16301728
    1631                 tinyMCE.loadScript(b + '/langs/' + lang +  '.js');
     1729                tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings['language'] +  '.js');
    16321730        },
    16331731
    16341732        applyTemplate : function(h, as) {
    1635                 var i, s, ar = h.match(new RegExp('\\{\\$[a-z0-9_]+\\}', 'gi'));
    1636 
    1637                 if (ar && ar.length > 0) {
    1638                         for (i=ar.length-1; i>=0; i--) {
    1639                                 s = ar[i].substring(2, ar[i].length-1);
    1640 
    1641                                 if (s.indexOf('lang_') == 0 && tinyMCELang[s])
    1642                                         h = tinyMCE.replaceVar(h, s, tinyMCELang[s]);
    1643                                 else if (as && as[s])
    1644                                         h = tinyMCE.replaceVar(h, s, as[s]);
    1645                                 else if (tinyMCE.settings[s])
    1646                                         h = tinyMCE.replaceVar(h, s, tinyMCE.settings[s]);
    1647                         }
    1648                 }
    1649 
    1650                 h = tinyMCE.replaceVar(h, "themeurl", tinyMCE.themeURL);
    1651 
    1652                 return h;
     1733                return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) {
     1734                        if (s.indexOf('lang_') == 0 && tinyMCELang[s])
     1735                                return tinyMCELang[s];
     1736
     1737                        if (as && as[s])
     1738                                return as[s];
     1739
     1740                        if (tinyMCE.settings[s])
     1741                                return tinyMCE.settings[s];
     1742
     1743                        if (m == 'themeurl')
     1744                                return tinyMCE.themeURL;
     1745
     1746                        return m;
     1747                });
    16531748        },
    16541749
    … …  
    16731768
    16741769                // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
    1675                 if (tinyMCE.isMSIE)
     1770                if (tinyMCE.isIE)
    16761771                        height += 40;
    16771772                else
    … …  
    17121807                        win.focus();
    17131808                } else {
    1714                         if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
     1809                        if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
    17151810                                height += 10;
    17161811
    … …  
    18241919                                if (anchorName != '' && state) {
    18251920                                        el.title = anchorName;
    1826                                         el.className = 'mceItemAnchor';
     1921                                        tinyMCE.addCSSClass(el, 'mceItemAnchor');
    18271922                                } else if (anchorName != '' && !state)
    18281923                                        el.className = '';
    … …  
    18711966
    18721967        fixGeckoBaseHREFBug : function(m, e, h) {
    1873                 var nl, i, a, n, xsrc, xhref, el;
     1968                var xsrc, xhref;
    18741969
    18751970                if (tinyMCE.isGecko) {
    … …  
    18801975                                return h;
    18811976                        } else {
    1882                                 el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
    1883 
    1884                                 for (a=0; a<el.length; a++) {
    1885                                         n = e.getElementsByTagName(el[a]);
    1886 
    1887                                         for (i=0; i<n.length; i++) {
    1888                                                 xsrc = tinyMCE.getAttrib(n[i], "mce_tsrc");
    1889                                                 xhref = tinyMCE.getAttrib(n[i], "mce_thref");
    1890 
    1891                                                 if (xsrc != "") {
    1892                                                         try {
    1893                                                                 n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
    1894                                                         } catch (e) {
    1895                                                                 // Ignore, Firefox cast exception if local file wasn't found
    1896                                                         }
    1897 
    1898                                                         n[i].removeAttribute("mce_tsrc");
     1977                                // Why bother if there is no src or href broken
     1978                                if (!new RegExp('(src|href)=', 'g').test(h))
     1979                                        return h;
     1980
     1981                                // Restore src and href that gets messed up by Gecko
     1982                                tinyMCE.selectElements(e, 'A,IMG,SELECT,AREA,IFRAME,BASE,INPUT,SCRIPT,EMBED,OBJECT,LINK', function (n) {
     1983                                        xsrc = tinyMCE.getAttrib(n, "mce_tsrc");
     1984                                        xhref = tinyMCE.getAttrib(n, "mce_thref");
     1985
     1986                                        if (xsrc != "") {
     1987                                                try {
     1988                                                        n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
     1989                                                } catch (e) {
     1990                                                        // Ignore, Firefox cast exception if local file wasn't found
    18991991                                                }
    19001992
    1901                                                 if (xhref != "") {
    1902                                                         try {
    1903                                                                 n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
    1904                                                         } catch (e) {
    1905                                                                 // Ignore, Firefox cast exception if local file wasn't found
    1906                                                         }
    1907 
    1908                                                         n[i].removeAttribute("mce_thref");
     1993                                                n.removeAttribute("mce_tsrc");
     1994                                        }
     1995
     1996                                        if (xhref != "") {
     1997                                                try {
     1998                                                        n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
     1999                                                } catch (e) {
     2000                                                        // Ignore, Firefox cast exception if local file wasn't found
    19092001                                                }
     2002
     2003                                                n.removeAttribute("mce_thref");
    19102004                                        }
    1911                                 }
    1912 
    1913                                 el = tinyMCE.selectNodes(e, function(n) {
     2005
     2006                                        return false;
     2007                                });
     2008
     2009                                // Restore text/comment nodes
     2010                                tinyMCE.selectNodes(e, function(n) {
    19142011                                        if (n.nodeType == 3 || n.nodeType == 8) {
    19152012                                                n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src=");
    … …  
    19402037
    19412038                // Content duplication bug fix
    1942                 if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
     2039                if (tinyMCE.isIE && tinyMCE.settings['fix_content_duplication']) {
    19432040                        // Remove P elements in P elements
    19442041                        var paras = doc.getElementsByTagName("P");
    … …  
    20662163
    20672164                                        // Just ignore any errors
    2068                                         eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
     2165                                        eval("try {var csses = tinyMCE.isIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
    20692166                                        if (!csses)
    20702167                                                return new Array();
    … …  
    21592256        },
    21602257
    2161         evalFunc : function(f, idx, a) {
     2258        evalFunc : function(f, idx, a, o) {
    21622259                var s = '(', i;
    21632260
    … …  
    21712268                s += ');';
    21722269
    2173                 return eval("f" + s);
     2270                return o ? eval("o." + f + s) : eval("f" + s);
    21742271        },
    21752272
    … …  
    22002297                                o = tinyMCE.plugins[l[i]];
    22012298
    2202                                 if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
     2299                                if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
    22032300                                        return true;
    22042301                        }
    … …  
    22092306                        o = l[on];
    22102307
    2211                         if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
     2308                        if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
    22122309                                return true;
    22132310                }
    … …  
    22172314
    22182315        xmlEncode : function(s) {
    2219                 s = "" + s;
    2220                 s = s.replace(/&/g, '&amp;');
    2221                 s = s.replace(new RegExp('"', 'g'), '&quot;');
    2222                 s = s.replace(/\'/g, '&#39;'); // &apos; is not working in MSIE
    2223                 s = s.replace(/</g, '&lt;');
    2224                 s = s.replace(/>/g, '&gt;');
    2225 
    2226                 return s;
     2316                return s ? ('' + s).replace(new RegExp('[<>&"\']', 'g'), function (c, b) {
     2317                        switch (c) {
     2318                                case '&':
     2319                                        return '&amp;';
     2320
     2321                                case '"':
     2322                                        return '&quot;';
     2323
     2324                                case '\'':
     2325                                        return '&#39;'; // &apos; is not working in MSIE
     2326
     2327                                case '<':
     2328                                        return '&lt;';
     2329
     2330                                case '>':
     2331                                        return '&gt;';
     2332                        }
     2333
     2334                        return c;
     2335                }) : s;
    22272336        },
    22282337
    … …  
    22532362                        tinyMCE.lastSelectedMenuBtn = null;
    22542363                }
    2255         },
    2256 
    2257         explode : function(d, s) {
    2258                 var ar = s.split(d), oar = new Array(), i;
    2259        
    2260                 for (i = 0; i<ar.length; i++) {
    2261                         if (ar[i] != "")
    2262                                 oar[oar.length] = ar[i];
    2263                 }
    2264        
    2265                 return oar;
    22662364        }
    2267 };
     2365
     2366        };
    22682367
    22692368// Global instances
    … …  
    22902389        this.shortcuts = new Array();
    22912390        this.hasMouseMoved = false;
     2391        this.foreColor = this.backColor = "#999999";
     2392        this.data = {};
    22922393
    22932394        this.cleanup.init({
    22942395                valid_elements : s.valid_elements,
    22952396                extended_valid_elements : s.extended_valid_elements,
     2397                valid_child_elements : s.valid_child_elements,
    22962398                entities : s.entities,
    22972399                entity_encoding : s.entity_encoding,
    … …  
    23462448
    23472449TinyMCE_Control.prototype = {
     2450        selection : null,
     2451
     2452        settings : null,
     2453
     2454        cleanup : null,
     2455
     2456        getData : function(na) {
     2457                var o = this.data[na];
     2458
     2459                if (!o)
     2460                        o = this.data[na] = {};
     2461
     2462                return o;
     2463        },
     2464
    23482465        hasPlugin : function(n) {
    23492466                var i;
    … …  
    23652482
    23662483        repaint : function() {
    2367                 if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     2484                var s, b, ex;
     2485
     2486                if (tinyMCE.isRealIE)
    23682487                        return;
    23692488
    23702489                try {
    2371                         var s = this.selection;
    2372                         var b = s.getBookmark(true);
     2490                        s = this.selection;
     2491                        b = s.getBookmark(true);
    23732492                        this.getBody().style.display = 'none';
    23742493                        this.getDoc().execCommand('selectall', false, null);
    … …  
    23882507        },
    23892508
     2509        select : function() {
     2510                var oldInst = tinyMCE.selectedInstance;
     2511
     2512                if (oldInst != this) {
     2513                        if (oldInst)
     2514                                oldInst.execCommand('mceEndTyping');
     2515
     2516                        tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst);
     2517                        tinyMCE.selectedInstance = this;
     2518                }
     2519        },
     2520
    23902521        getBody : function() {
    2391                 return this.getDoc().body;
     2522                return this.contentBody ? this.contentBody : this.getDoc().body;
    23922523        },
    23932524
    23942525        getDoc : function() {
     2526//              return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ?
    23952527                return this.contentWindow.document;
    23962528        },
    … …  
    24002532        },
    24012533
     2534        getContainerWin : function() {
     2535                return this.containerWindow ? this.containerWindow : window;
     2536        },
     2537
     2538        getViewPort : function() {
     2539                return tinyMCE.getViewPort(this.getWin());
     2540        },
     2541
     2542        getParentNode : function(n, f) {
     2543                return tinyMCE.getParentNode(n, f, this.getBody());
     2544        },
     2545
     2546        getParentElement : function(n, na, f) {
     2547                return tinyMCE.getParentElement(n, na, f, this.getBody());
     2548        },
     2549
     2550        getParentBlockElement : function(n) {
     2551                return tinyMCE.getParentBlockElement(n, this.getBody());
     2552        },
     2553
     2554        resizeToContent : function() {
     2555                var d = this.getDoc(), b = d.body, de = d.documentElement;
     2556
     2557                this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px';
     2558        },
     2559
    24022560        addShortcut : function(m, k, d, cmd, ui, va) {
    2403                 var n = typeof(k) == "number", ie = tinyMCE.isMSIE, c, sc, i;
    2404                 var scl = this.shortcuts;
     2561                var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts;
    24052562
    24062563                if (!tinyMCE.getParam('custom_shortcuts'))
    … …  
    24412598                for (i=0; i<s.length; i++) {
    24422599                        o = s[i];
     2600
    24432601                        if (o.alt == e.altKey && o.ctrl == e.ctrlKey && (o.keyCode == e.keyCode || o.charCode == e.charCode)) {
    24442602                                if (o.cmd && (e.type == "keydown" || (e.type == "keypress" && !tinyMCE.isOpera)))
    … …  
    24552613        autoResetDesignMode : function() {
    24562614                // Add fix for tab/style.display none/block problems in Gecko
    2457                 if (!tinyMCE.isMSIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
    2458                         eval('try { this.getDoc().designMode = "On"; } catch(e) {}');
     2615                if (!tinyMCE.isIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
     2616                        eval('try { this.getDoc().designMode = "On"; this.useCSS = false; } catch(e) {}');
    24592617        },
    24602618
    24612619        isHidden : function() {
    2462                 if (tinyMCE.isMSIE)
     2620                var s;
     2621
     2622                if (tinyMCE.isIE)
    24632623                        return false;
    24642624
    2465                 var s = this.getSel();
     2625                s = this.getSel();
    24662626
    24672627                // Weird, wheres that cursor selection?
    … …  
    24712631        isDirty : function() {
    24722632                // Is content modified and not in a submit procedure
    2473                 return this.startContent != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
     2633                return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
    24742634        },
    24752635
    … …  
    24872647                var className = tinyMCE.getAttrib(pa, "class");
    24882648
    2489                 className += " " + tinyMCE.getAttrib(ch, "class");
     2649                // Removed class adding due to bug #1478272
     2650                className = tinyMCE.getAttrib(ch, "class");
    24902651
    24912652                if (override) {
    … …  
    25272688
    25282689        execCommand : function(command, user_interface, value) {
    2529                 var doc = this.getDoc();
    2530                 var win = this.getWin();
    2531                 var focusElm = this.getFocusElement();
    2532 
    2533                 // Is non udno specific command
     2690                var doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement();
     2691
     2692                // Is not a undo specific command
    25342693                if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command))
    25352694                        this.undoBookmark = null;
    25362695
    2537                 if (this.lastSafariSelection && !new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) {
    2538                         this.selection.moveToBookmark(this.lastSafariSelection);
    2539                         tinyMCE.selectedElement = this.lastSafariSelectedElement;
    2540                 }
    2541 
    25422696                // Mozilla issue
    2543                 if (!tinyMCE.isMSIE && !this.useCSS) {
     2697                if (!tinyMCE.isIE && !this.useCSS) {
    25442698                        this._setUseCSS(false);
    25452699                        this.useCSS = true;
    … …  
    26552809                                return true;
    26562810
     2811                        case "unlink":
     2812                                // Unlink if caret is inside link
     2813                                if (tinyMCE.isGecko && this.getSel().isCollapsed) {
     2814                                        focusElm = tinyMCE.getParentElement(focusElm, 'A');
     2815
     2816                                        if (focusElm)
     2817                                                this.selection.selectNode(focusElm, false);
     2818                                }
     2819
     2820                                this.getDoc().execCommand(command, user_interface, value);
     2821
     2822                                tinyMCE.isGecko && this.getSel().collapseToEnd();
     2823
     2824                                tinyMCE.triggerNodeChange();
     2825
     2826                                return true;
     2827
     2828                        case "FormatBlock":
     2829                                if (!this.cleanup.isValid(value))
     2830                                        return true;
     2831
     2832                                this.getDoc().execCommand(command, user_interface, value);
     2833                                tinyMCE.triggerNodeChange();
     2834                                break;
     2835
    26572836                        case "InsertUnorderedList":
    26582837                        case "InsertOrderedList":
    2659                                 var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
    2660 
    2661                                 if (tinyMCE.isSafari)
    2662                                         this.execCommand("mceInsertContent", false, "<" + tag + "><li>&nbsp;</li><" + tag + ">");
    2663                                 else
    2664                                         this.getDoc().execCommand(command, user_interface, value);
    2665 
     2838                                this.getDoc().execCommand(command, user_interface, value);
    26662839                                tinyMCE.triggerNodeChange();
    26672840                                break;
    26682841
    26692842                        case "Strikethrough":
    2670                                 if (tinyMCE.isSafari)
    2671                                         this.execCommand("mceInsertContent", false, "<strike>" + this.selection.getSelectedHTML() + "</strike>");
    2672                                 else
    2673                                         this.getDoc().execCommand(command, user_interface, value);
    2674 
     2843                                this.getDoc().execCommand(command, user_interface, value);
    26752844                                tinyMCE.triggerNodeChange();
    26762845                                break;
    … …  
    26922861                                                value = value.replace(/[^a-z]/gi, '');
    26932862
    2694                                         if (tinyMCE.isMSIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
     2863                                        if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
    26952864                                                var b = this.selection.getBookmark();
    26962865                                                this.getDoc().execCommand("FormatBlock", false, '<p>');
    … …  
    27092878                                        value = tinyMCE.getParentElement(this.getFocusElement());
    27102879
    2711                                 if (tinyMCE.isMSIE) {
     2880                                if (tinyMCE.isIE) {
    27122881                                        value.outerHTML = value.innerHTML;
    27132882                                } else {
    … …  
    27602929
    27612930                                // Whole element selected check
    2762                                 if (tinyMCE.isMSIE) {
     2931                                if (tinyMCE.isIE) {
    27632932                                        // Control range
    27642933                                        if (rng.item)
    … …  
    29543123
    29553124                        case "forecolor":
     3125                                value = value == null ? this.foreColor : value;
     3126                                value = tinyMCE.trim(value);
     3127                                value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
     3128
     3129                                this.foreColor = value;
    29563130                                this.getDoc().execCommand('forecolor', false, value);
    29573131                                break;
    29583132
    29593133                        case "HiliteColor":
     3134                                value = value == null ? this.backColor : value;
     3135                                value = tinyMCE.trim(value);
     3136                                value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
     3137                                this.backColor = value;
     3138
    29603139                                if (tinyMCE.isGecko) {
    29613140                                        this._setUseCSS(true);
    … …  
    29953174                                value = tinyMCE.storeAwayURLs(value);
    29963175                                value = tinyMCE._customCleanup(this, "insert_to_editor", value);
    2997                                 tinyMCE._setHTML(doc, value);
    2998                                 tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body));
    2999                                 tinyMCE.convertAllRelativeURLs(doc.body);
     3176
     3177                                if (this.getBody().nodeName == 'BODY')
     3178                                        tinyMCE._setHTML(doc, value);
     3179                                else
     3180                                        this.getBody().innerHTML = value;
     3181
     3182                                tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, doc, this.settings, this.getBody(), false, false, false, true));
     3183                                tinyMCE.convertAllRelativeURLs(this.getBody());
    30003184
    30013185                                // Cleanup any mess left from storyAwayURLs
    … …  
    30063190                                        tinyMCE.convertSpansToFonts(doc);
    30073191
    3008                                 tinyMCE.handleVisualAid(doc.body, true, this.visualAid, this);
    3009                                 tinyMCE._setEventsEnabled(doc.body, false);
     3192                                tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
     3193                                tinyMCE._setEventsEnabled(this.getBody(), false);
    30103194                                return true;
    30113195
    … …  
    30363220                                var selectedText = "";
    30373221
    3038                                 if (tinyMCE.isMSIE) {
     3222                                if (tinyMCE.isIE) {
    30393223                                        var rng = doc.selection.createRange();
    30403224                                        selectedText = rng.text;
    … …  
    30753259
    30763260                                // Store away scroll pos
    3077                                 var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
    3078                                 var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
     3261                                var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft;
     3262                                var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop;
    30793263
    30803264                                // Find marker and replace with RAW HTML
    … …  
    30963280
    30973281                                var insertHTMLFailed = false;
    3098                                 this.getWin().focus();
     3282
     3283                                // Removed since it produced problems in IE
     3284                                // this.getWin().focus();
    30993285
    31003286                                if (tinyMCE.isGecko || tinyMCE.isOpera) {
    … …  
    31323318                                }
    31333319
    3134                                 // Ugly hack in Opera due to non working "inserthtml"
    3135                                 if (tinyMCE.isOpera && insertHTMLFailed) {
    3136                                         this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);
    3137                                         var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);
    3138                                         ar[0].outerHTML = value;
    3139                                         return;
    3140                                 }
    3141 
    3142                                 if (!tinyMCE.isMSIE) {
     3320                                if (!tinyMCE.isIE) {
    31433321                                        var isHTML = value.indexOf('<') != -1;
    31443322                                        var sel = this.getSel();
    … …  
    32013379                                        tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
    32023380                                } else {
    3203                                         var rng = doc.selection.createRange();
     3381                                        var rng = doc.selection.createRange(), tmpRng = null;
    32043382                                        var c = value.indexOf('<!--') != -1;
    32053383
    … …  
    32073385                                        if (c)
    32083386                                                value = tinyMCE.uniqueTag + value;
     3387
     3388                                        //      tmpRng = rng.duplicate(); // Store away range (Fixes Undo bookmark bug in IE)
    32093389
    32103390                                        if (rng.item)
    … …  
    32123392                                        else
    32133393                                                rng.pasteHTML(value);
     3394
     3395                                        //if (tmpRng)
     3396                                        //      tmpRng.select(); // Restore range  (Fixes Undo bookmark bug in IE)
    32143397
    32153398                                        // Remove unique tag
    … …  
    32203403                                }
    32213404
     3405                                tinyMCE.execCommand("mceAddUndoLevel");
    32223406                                tinyMCE.triggerNodeChange();
    32233407                        break;
    … …  
    32263410                                if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex == -1) {
    32273411                                        this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex;
     3412                                        tinyMCE.typingUndoIndex = tinyMCE.undoIndex;
    32283413                                        this.execCommand('mceAddUndoLevel');
    3229                                         //tinyMCE.debug("mceStartTyping");
    32303414                                }
    32313415                                break;
    … …  
    32353419                                        this.execCommand('mceAddUndoLevel');
    32363420                                        this.undoRedo.typingUndoIndex = -1;
    3237                                         //tinyMCE.debug("mceEndTyping");
    32383421                                }
     3422
     3423                                tinyMCE.typingUndoIndex = -1;
    32393424                                break;
    32403425
    … …  
    32823467                                this.getDoc().execCommand(command, user_interface, value);
    32833468                                tinyMCE.triggerNodeChange();
    3284                                 if (tinyMCE.isMSIE) {
     3469
     3470                                if (tinyMCE.isIE) {
    32853471                                        var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
    32863472                                        do {
    … …  
    33013487                                }
    33023488
    3303                                 if (tinyMCE.isMSIE) {
     3489                                if (tinyMCE.isIE) {
    33043490                                        try {
    33053491                                                var rng = doc.selection.createRange();
    … …  
    34073593                this.settings['area_height'] += deltaHeight;
    34083594
     3595                this.settings['width_style'] = "" + this.settings['width'];
     3596                this.settings['height_style'] = "" + this.settings['height'];
     3597
    34093598                // Special % handling
    34103599                if (("" + this.settings['width']).indexOf('%') != -1)
    34113600                        this.settings['area_width'] = "100%";
     3601                else
     3602                        this.settings['width_style'] += 'px';
    34123603
    34133604                if (("" + this.settings['height']).indexOf('%') != -1)
    34143605                        this.settings['area_height'] = "100%";
     3606                else
     3607                        this.settings['height_style'] += 'px';
    34153608
    34163609                if (("" + replace_element.style.width).indexOf('%') != -1) {
    34173610                        this.settings['width'] = replace_element.style.width;
    34183611                        this.settings['area_width'] = "100%";
     3612                        this.settings['width_style'] = "100%";
    34193613                }
    34203614
    … …  
    34223616                        this.settings['height'] = replace_element.style.height;
    34233617                        this.settings['area_height'] = "100%";
     3618                        this.settings['height_style'] = "100%";
    34243619                }
    34253620
    … …  
    34903685                var tElm = targetDoc.getElementById(this.editorId);
    34913686
    3492                 if (!tinyMCE.isMSIE) {
     3687                if (!tinyMCE.isIE) {
    34933688                        // Node case is preserved in XML strict mode
    34943689                        if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) {
    … …  
    35443739                // This timeout is needed in MSIE 5.5 for some odd reason
    35453740                // it seems that the document.frames isn't initialized yet?
    3546                 if (tinyMCE.isMSIE)
     3741                if (tinyMCE.isIE)
    35473742                        window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
    35483743
    … …  
    35743769        },
    35753770
     3771        getHTML : function(r) {
     3772                var h, d = this.getDoc(), b = this.getBody();
     3773
     3774                if (r)
     3775                        return b.innerHTML;
     3776
     3777                h = tinyMCE._cleanupHTML(this, d, this.settings, b, false, true, false, true);
     3778
     3779                if (tinyMCE.getParam("convert_fonts_to_spans"))
     3780                        tinyMCE.convertSpansToFonts(d);
     3781
     3782                return h;
     3783        },
     3784
     3785        setHTML : function(h) {
     3786                this.execCommand('mceSetContent', false, h);
     3787                this.repaint();
     3788        },
     3789
    35763790        getFocusElement : function() {
    35773791                return this.selection.getFocusElement();
    … …  
    35873801
    35883802        triggerSave : function(skip_cleanup, skip_callback) {
    3589                 var e, nl = new Array(), i, s;
     3803                var e, nl = [], i, s;
    35903804
    35913805                this.switchSettings();
    … …  
    35933807
    35943808                // Force hidden tabs visible while serializing
    3595                 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     3809                if (tinyMCE.isRealIE) {
    35963810                        e = this.iframeElement;
    35973811
    … …  
    36593873                }
    36603874        }
    3661 };
     3875
     3876        };
    36623877
    36633878/* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
    … …  
    36803895
    36813896        // Weird MSIE bug, <p><hr /></p> breaks runtime?
    3682         if (tinyMCE.isMSIE)
     3897        if (tinyMCE.isIE)
    36833898                s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");
    36843899
     3900        // Weird tags will make IE error #bug: 1538495
     3901        if (tinyMCE.isIE)
     3902                s = s.replace(/<!(\s*)\/>/g, '');
     3903
    36853904        // Convert relative anchors to absolute URLs ex: #something to file.htm#something
    3686         if (tinyMCE.getParam('convert_urls'))
    3687                 s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
     3905        // Removed: Since local document anchors should never be forced absolute example edit.php?id=something
     3906        //if (tinyMCE.getParam('convert_urls'))
     3907        //      s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
    36883908
    36893909        return s;
    … …  
    38274047        h = h.replace(/<span/gi, '<font');
    38284048        h = h.replace(/<\/span/gi, '</font');
    3829         doc.body.innerHTML = h;
     4049        tinyMCE.setInnerHTML(doc.body, h);
    38304050
    38314051        var s = doc.getElementsByTagName("font");
    … …  
    38664086        h = h.replace(/<font/gi, '<span');
    38674087        h = h.replace(/<\/font/gi, '</span');
    3868         doc.body.innerHTML = h;
     4088        tinyMCE.setInnerHTML(doc.body, h);
    38694089
    38704090        var fsClasses = tinyMCE.getParam('font_size_classes');
    … …  
    39224142
    39234143TinyMCE_Engine.prototype.getContent = function(editor_id) {
    3924         var h;
    3925 
    39264144        if (typeof(editor_id) != "undefined")
    3927                 tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);
    3928 
    3929         if (tinyMCE.selectedInstance) {
    3930                 h = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);
    3931 
    3932                 // When editing always use fonts internaly
    3933                 if (tinyMCE.getParam("convert_fonts_to_spans"))
    3934                         tinyMCE.convertSpansToFonts(this.selectedInstance.getDoc());
    3935 
    3936                 return h;
    3937         }
     4145                 tinyMCE.getInstanceById(editor_id).select();
     4146
     4147        if (tinyMCE.selectedInstance)
     4148                return tinyMCE.selectedInstance.getHTML();
    39384149
    39394150        return null;
    … …  
    39874198};
    39884199
    3989 TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit) {
    3990         var h, d, t1, t2, t3, t4, t5, c, s;
     4200TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit, inn) {
     4201        var h, d, t1, t2, t3, t4, t5, c, s, nb;
    39914202
    39924203        if (!tinyMCE.getParam('cleanup'))
    … …  
    40264237
    40274238        if (s.cleanup_serializer == "xml")
    4028                 h = c.serializeNodeAsXML(elm);
     4239                h = c.serializeNodeAsXML(elm, inn);
    40294240        else
    4030                 h = c.serializeNodeAsHTML(elm);
     4241                h = c.serializeNodeAsHTML(elm, inn);
    40314242
    40324243        if (d)
    … …  
    40344245
    40354246        // Post processing
     4247        nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? '&#160;' : '&nbsp;';
    40364248        h = h.replace(/<\/?(body|head|html)[^>]*>/gi, '');
    40374249        h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), '');
    40384250        h = h.replace(/<p><hr \/><\/p>/g, '<hr />');
    40394251        h = h.replace(/<p>(&nbsp;|&#160;)<\/p><hr \/><p>(&nbsp;|&#160;)<\/p>/g, '<hr />');
    4040         h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>&nbsp;</td>');
    4041         h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
    4042         h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>&nbsp;</p>');
    4043         h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
    4044         h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>&nbsp;</p>');
     4252        h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>');
     4253        h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
     4254        h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko
     4255        h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko
     4256        h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>' + nb + '</p>');
     4257        h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
     4258        h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>' + nb + '</p>');
    40454259        h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1');
    4046         h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>&nbsp;</p>');
     4260        h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>');
    40474261
    40484262        // Clean body
    … …  
    40604274        if (tinyMCE.isGecko) {
    40614275                h = h.replace(/<o:p _moz-userdefined="" \/>/g, '');
    4062                 h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>&nbsp;</td>');
     4276                h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>');
    40634277        }
    40644278
    … …  
    40984312
    40994313function TinyMCE_Cleanup() {
    4100         this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
     4314        this.isIE = (navigator.appName == "Microsoft Internet Explorer");
    41014315        this.rules = tinyMCE.clearArray(new Array());
    41024316
    … …  
    41194333        this.vElements = tinyMCE.clearArray(new Array());
    41204334        this.vElementsRe = '';
    4121         this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON|AREA)$/;
     4335        this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/;
    41224336        this.codeElementsRe = /^(SCRIPT|STYLE)$/;
    41234337        this.serializationId = 0;
    … …  
    41454359                this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(',  ')([^>]*)>');
    41464360                this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>');
     4361                this.serializedNodes = [];
    41474362
    41484363                if (s.invalid_elements != '')
    … …  
    41854400
    41864401                this.vElementsRe = this._arrayToRe(this.vElements, '');
     4402        },
     4403
     4404        isValid : function(n) {
     4405                this._setupRules(); // Will initialize cleanup rules
     4406
     4407                // Clean the name up a bit
     4408                n = n.replace(/[^a-z0-9]+/gi, '').toUpperCase();
     4409
     4410                return !tinyMCE.getParam('cleanup') || this.vElementsRe.test(n);
     4411        },
     4412
     4413        addChildRemoveRuleStr : function(s) {
     4414                var x, y, p, i, t, tn, ta, cl, r;
     4415
     4416                if (!s)
     4417                        return;
     4418
     4419                ta = s.split(',');
     4420                for (x=0; x<ta.length; x++) {
     4421                        s = ta[x];
     4422
     4423                        // Split tag/children
     4424                        p = this.split(/\[|\]/, s);
     4425                        if (p == null || p.length < 1)
     4426                                t = s.toUpperCase();
     4427                        else
     4428                                t = p[0].toUpperCase();
     4429
     4430                        // Handle all tag names
     4431                        tn = this.split('/', t);
     4432                        for (y=0; y<tn.length; y++) {
     4433                                r = "^(";
     4434
     4435                                // Build regex
     4436                                cl = this.split(/\|/, p[1]);
     4437                                for (i=0; i<cl.length; i++) {
     4438                                        if (cl[i] == '%istrict')
     4439                                                r += tinyMCE.inlineStrict;
     4440                                        else if (cl[i] == '%itrans')
     4441                                                r += tinyMCE.inlineTransitional;
     4442                                        else if (cl[i] == '%istrict_na')
     4443                                                r += tinyMCE.inlineStrict.substring(2);
     4444                                        else if (cl[i] == '%itrans_na')
     4445                                                r += tinyMCE.inlineTransitional.substring(2);
     4446                                        else if (cl[i] == '%btrans')
     4447                                                r += tinyMCE.blockElms;
     4448                                        else if (cl[i] == '%strict')
     4449                                                r += tinyMCE.blockStrict;
     4450                                        else
     4451                                                r += (cl[i].charAt(0) != '#' ? cl[i].toUpperCase() : cl[i]);
     4452
     4453                                        r += (i != cl.length - 1 ? '|' : '');
     4454                                }
     4455
     4456                                r += ')$';
     4457//tinyMCE.debug(t + "=" + r);
     4458                                if (this.childRules == null)
     4459                                        this.childRules = tinyMCE.clearArray(new Array());
     4460
     4461                                this.childRules[tn[y]] = new RegExp(r);
     4462
     4463                                if (p.length > 1)
     4464                                        this.childRules[tn[y]].wrapTag = p[2];
     4465                        }
     4466                }
    41874467        },
    41884468
    … …  
    42344514                                                t = a[i];
    42354515
     4516                                                if (t.charAt(0) == '!') {
     4517                                                        a[i] = t = t.substring(1);
     4518
     4519                                                        if (!r.reqAttribsRe)
     4520                                                                r.reqAttribsRe = '\\s+(' + t;
     4521                                                        else
     4522                                                                r.reqAttribsRe += '|' + t;
     4523                                                }
     4524
    42364525                                                av = new RegExp('(=|:|<)(.*?)$').exec(t);
    42374526                                                t = t.replace(new RegExp('(=|:|<).*?$'), '');
    … …  
    42534542                                                                        r.validAttribValues = tinyMCE.clearArray(new Array());
    42544543
    4255                                                                 r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), '');
     4544                                                                r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i');
    42564545                                                        }
    42574546                                                }
    … …  
    42614550                                                a[i] = t.toLowerCase();
    42624551                                        }
     4552
     4553                                        if (r.reqAttribsRe)
     4554                                                r.reqAttribsRe = new RegExp(r.reqAttribsRe + ')=\"', 'g');
    42634555
    42644556                                        r.vAttribsRe += ')$';
    … …  
    42864578
    42874579                if (!this.xmlDoc) {
    4288                         if (this.isMSIE) {
     4580                        if (this.isIE) {
    42894581                                try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
    42904582
    … …  
    43064598                this._convertToXML(n, b);
    43074599
    4308                 if (this.isMSIE)
     4600                if (this.isIE)
    43094601                        return this.xmlDoc.xml;
    43104602                else
    … …  
    43574649        },
    43584650
    4359         serializeNodeAsHTML : function(n) {
    4360                 var en, no, h = '', i, l, r, cn, va = false, f = false, at, hc;
     4651        serializeNodeAsHTML : function(n, inn) {
     4652                var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr;
    43614653
    43624654                this._setupRules(); // Will initialize cleanup rules
    … …  
    43644656                if (this._isDuplicate(n))
    43654657                        return '';
     4658
     4659                // Skip non valid child elements
     4660                if (n.parentNode && this.childRules != null) {
     4661                        cr = this.childRules[n.parentNode.nodeName];
     4662
     4663                        if (typeof(cr) != "undefined" && !cr.test(n.nodeName)) {
     4664                                st = true;
     4665                                t = null;
     4666                        }
     4667                }
    43664668
    43674669                switch (n.nodeType) {
    … …  
    43694671                                hc = n.hasChildNodes();
    43704672
     4673                                if (st)
     4674                                        break;
     4675
    43714676                                // MSIE sometimes produces <//tag>
    4372                                 if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && n.nodeName.indexOf('/') != -1)
     4677                                if ((tinyMCE.isRealIE) && n.nodeName.indexOf('/') != -1)
    43734678                                        break;
    43744679
    4375                                 if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName))) {
     4680                                if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName)) && !inn) {
    43764681                                        va = true;
    43774682
    … …  
    43934698                                                return "";
    43944699
    4395                                         h += '<' + en;
     4700                                        t = '<' + en;
    43964701
    43974702                                        if (r.vAttribsReIsWild) {
    … …  
    44014706                                                        no = at[i];
    44024707                                                        if (no.specified && r.vAttribsRe.test(no.nodeName))
    4403                                                                 h += this._serializeAttribute(n, r, no.nodeName);
     4708                                                                t += this._serializeAttribute(n, r, no.nodeName);
    44044709                                                }
    44054710                                        } else {
    44064711                                                // Serialize specific attributes
    44074712                                                for (i=r.vAttribs.length-1; i>-1; i--)
    4408                                                         h += this._serializeAttribute(n, r, r.vAttribs[i]);
     4713                                                        t += this._serializeAttribute(n, r, r.vAttribs[i]);
    44094714                                        }
    44104715
    … …  
    44154720                                                for (no in at) {
    44164721                                                        if (at[no])
    4417                                                                 h += this._serializeAttribute(n, r, at[no]);
     4722                                                                t += this._serializeAttribute(n, r, at[no]);
    44184723                                                }
    44194724                                        }
    44204725
     4726                                        // Check for required attribs
     4727                                        if (r.reqAttribsRe && !t.match(r.reqAttribsRe))
     4728                                                t = null;
     4729
    44214730                                        // Close these
    4422                                         if (this.closeElementsRe.test(n.nodeName))
    4423                                                 return h + ' />';
    4424 
    4425                                         h += '>';
    4426 
    4427                                         if (this.isMSIE && this.codeElementsRe.test(n.nodeName))
     4731                                        if (t != null && this.closeElementsRe.test(n.nodeName))
     4732                                                return t + ' />';
     4733
     4734                                        if (t != null)
     4735                                                h += t + '>';
     4736
     4737                                        if (this.isIE && this.codeElementsRe.test(n.nodeName))
    44284738                                                h += n.innerHTML;
    44294739                                }
    … …  
    44314741
    44324742                        case 3: // Text
     4743                                if (st)
     4744                                        break;
     4745
    44334746                                if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
    4434                                         return this.isMSIE ? '' : n.nodeValue;
     4747                                        return this.isIE ? '' : n.nodeValue;
    44354748
    44364749                                return this.xmlEncode(n.nodeValue);
    44374750
    44384751                        case 8: // Comment
     4752                                if (st)
     4753                                        break;
     4754
    44394755                                return "<!--" + this._trimComment(n.nodeValue) + "-->";
    44404756                }
    … …  
    44524768
    44534769                // End element
    4454                 if (va)
     4770                if (t != null && va)
    44554771                        h += '</' + en + '>';
    44564772
    … …  
    44894805                        av = "uid_" + (this.idCount++);
    44904806
    4491                 if (av.length != 0)
    4492                         return " " + an + "=" + '"' + this.xmlEncode(av) + '"';
     4807                if (av.length != 0) {
     4808                        if (an.indexOf('on') != 0)
     4809                                av = this.xmlEncode(av);
     4810
     4811                        return " " + an + "=" + '"' + av + '"';
     4812                }
    44934813
    44944814                return "";
    … …  
    44974817        formatHTML : function(h) {
    44984818                var s = this.settings, p = '', i = 0, li = 0, o = '', l;
     4819
     4820                // Replace BR in pre elements to \n
     4821                h = h.replace(/<pre([^>]*)>(.*?)<\/pre>/gi, function (a, b, c) {
     4822                        c = c.replace(/<br\s*\/>/gi, '\n');
     4823                        return '<pre' + b + '>' + c + '</pre>';
     4824                });
    44994825
    45004826                h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :)
    … …  
    45284854
    45294855        xmlEncode : function(s) {
    4530                 var i, l, e, o = '', c;
     4856                var cl = this;
    45314857
    45324858                this._setupEntities(); // Will intialize lookup table
    … …  
    45374863
    45384864                        case "named":
    4539                                 for (i=0, l=s.length; i<l; i++) {
    4540                                         c = s.charCodeAt(i);
    4541                                         e = this.entities[c];
    4542 
    4543                                         if (e && e != '')
    4544                                                 o += '&' + e + ';';
    4545                                         else
    4546                                                 o += String.fromCharCode(c);
    4547                                 }
    4548 
    4549                                 return o;
     4865                                return s.replace(new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {
     4866                                        b = cl.entities[c.charCodeAt(0)];
     4867
     4868                                        return b ? '&' + b + ';' : c;
     4869                                });
    45504870
    45514871                        case "numeric":
    4552                                 for (i=0, l=s.length; i<l; i++) {
    4553                                         c = s.charCodeAt(i);
    4554 
    4555                                         if (c > 127 || c == 60 || c == 62 || c == 38 || c == 39 || c == 34)
    4556                                                 o += '&#' + c + ";";
    4557                                         else
    4558                                                 o += String.fromCharCode(c);
    4559                                 }
    4560 
    4561                                 return o;
     4872                                return s.replace(new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {
     4873                                        return b ? '&#' + c.charCodeAt(0) + ';' : c;
     4874                                });
    45624875                }
    45634876
    … …  
    45974910                        v = e.className;
    45984911
    4599                 if (this.isMSIE && n == "http-equiv")
     4912                if (this.isIE && n == "http-equiv")
    46004913                        v = e.httpEquiv;
    46014914
    4602                 if (this.isMSIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
     4915                if (this.isIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
    46034916                        v = "";
    46044917
    4605                 if (this.isMSIE && e.nodeName == "INPUT" && n == "size" && v == "20")
     4918                if (this.isIE && e.nodeName == "INPUT" && n == "size" && v == "20")
    46064919                        v = "";
    46074920
    4608                 if (this.isMSIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
     4921                if (this.isIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
    46094922                        v = "";
    46104923
    … …  
    46804993                        this.addRuleStr(s.valid_elements);
    46814994                        this.addRuleStr(s.extended_valid_elements);
     4995                        this.addChildRemoveRuleStr(s.valid_child_elements);
    46824996
    46834997                        this.rulesDone = true;
    … …  
    46915005                        return false;
    46925006
    4693                 if (tinyMCE.isMSIE && !tinyMCE.isOpera && n.nodeType == 1) {
     5007                if (tinyMCE.isRealIE && n.nodeType == 1) {
    46945008                        // Mark elements
    46955009                        if (n.mce_serialized == this.serializationId)
    … …  
    47095023                return false;
    47105024        }
     5025
     5026        };
     5027
     5028/* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
     5029
     5030TinyMCE_Engine.prototype.createTagHTML = function(tn, a, h) {
     5031        var o = '', f = tinyMCE.xmlEncode;
     5032
     5033        o = '<' + tn;
     5034
     5035        if (a) {
     5036                for (n in a) {
     5037                        if (typeof(a[n]) != 'function' && a[n] != null)
     5038                                o += ' ' + f(n) + '="' + f('' + a[n]) + '"';
     5039                }
     5040        }
     5041
     5042        o += !h ? ' />' : '>' + h + '</' + tn + '>';
     5043
     5044        return o;
    47115045};
    47125046
    4713 /* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
     5047TinyMCE_Engine.prototype.createTag = function(d, tn, a, h) {
     5048        var o = d.createElement(tn);
     5049
     5050        if (a) {
     5051                for (n in a) {
     5052                        if (typeof(a[n]) != 'function' && a[n] != null)
     5053                                tinyMCE.setAttrib(o, n, a[n]);
     5054                }
     5055        }
     5056
     5057        if (h)
     5058                o.innerHTML = h;
     5059
     5060        return o;
     5061};
    47145062
    47155063TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) {
    … …  
    47325080};
    47335081
    4734 TinyMCE_Engine.prototype.getParentBlockElement = function(n) {
    4735         while (n) {
    4736                 if (this.isBlockElement(n))
    4737                         return n;
    4738 
    4739                 n = n.parentNode;
    4740         }
     5082TinyMCE_Engine.prototype.getParentBlockElement = function(n, r) {
     5083        return this.getParentNode(n, function(n) {
     5084                return tinyMCE.isBlockElement(n);
     5085        }, r);
    47415086
    47425087        return null;
    … …  
    47535098        var i, nl, n;
    47545099
    4755         if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     5100        // Convert all strong/em to b/i in Gecko
     5101        if (tinyMCE.isGecko) {
     5102                h = h.replace(/<strong/gi, '<b');
     5103                h = h.replace(/<em(\/?)/gi, '<i');
     5104                h = h.replace(/<em /gi, '<i');
     5105                h = h.replace(/<\/strong>/gi, '</b>');
     5106                h = h.replace(/<\/em>/gi, '</i>');
     5107        }
     5108
     5109        if (tinyMCE.isRealIE) {
    47565110                // Since MSIE handles invalid HTML better that valid XHTML we
    47575111                // need to make some things invalid. <hr /> gets converted to <hr>.
    … …  
    47835137
    47845138TinyMCE_Engine.prototype.getOuterHTML = function(e) {
    4785         if (tinyMCE.isMSIE)
     5139        if (tinyMCE.isIE)
    47865140                return e.outerHTML;
    47875141
    47885142        var d = e.ownerDocument.createElement("body");
    4789         d.appendChild(e);
     5143        d.appendChild(e.cloneNode(true));
    47905144        return d.innerHTML;
    47915145};
    47925146
    4793 TinyMCE_Engine.prototype.setOuterHTML = function(e, h) {
    4794         if (tinyMCE.isMSIE) {
     5147TinyMCE_Engine.prototype.setOuterHTML = function(e, h, d) {
     5148        var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t;
     5149
     5150        if (tinyMCE.isIE && e.nodeType == 1)
    47955151                e.outerHTML = h;
    4796                 return;
     5152        else {
     5153                t = d.createElement("body");
     5154                t.innerHTML = h;
     5155
     5156                for (i=0, nl=t.childNodes; i<nl.length; i++)
     5157                        e.parentNode.insertBefore(nl[i].cloneNode(true), e);
     5158
     5159                e.parentNode.removeChild(e);
    47975160        }
    4798 
    4799         var d = e.ownerDocument.createElement("body");
    4800         d.innerHTML = h;
    4801         e.parentNode.replaceChild(d.firstChild, e);
    48025161};
    48035162
    … …  
    48265185
    48275186TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) {
    4828         var i;
    4829 
    4830         if (typeof(t) == "undefined" || n.nodeType == t && (typeof(nn) == "undefined" || n.nodeName == nn))
    4831                 na[na.length] = n;
    4832 
    4833         if (n.hasChildNodes()) {
    4834                 for (i=0; i<n.childNodes.length; i++)
    4835                         tinyMCE.getNodeTree(n.childNodes[i], na, t, nn);
     5187        return this.selectNodes(n, function(n) {
     5188                return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
     5189        }, na ? na : new Array());
     5190};
     5191
     5192TinyMCE_Engine.prototype.getParentElement = function(n, na, f, r) {
     5193        var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v;
     5194
     5195        // Compatiblity with old scripts where f param was a attribute string
     5196        if (f && typeof(f) == 'string')
     5197                return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) != '';});
     5198
     5199        return this.getParentNode(n, function(n) {
     5200                return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n));
     5201        }, r);
     5202};
     5203
     5204TinyMCE_Engine.prototype.getParentNode = function(n, f, r) {
     5205        while (n) {
     5206                if (n == r)
     5207                        return null;
     5208
     5209                if (f(n))
     5210                        return n;
     5211
     5212                n = n.parentNode;
    48365213        }
    4837 
    4838         return na;
    4839 };
    4840 
    4841 TinyMCE_Engine.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {
    4842         if (typeof(names) == "undefined") {
    4843                 if (node.nodeType == 1)
    4844                         return node;
    4845 
    4846                 // Find parent node that is a element
    4847                 while ((node = node.parentNode) != null && node.nodeType != 1) ;
    4848 
    4849                 return node;
    4850         }
    4851 
    4852         if (node == null)
    4853                 return null;
    4854 
    4855         var namesAr = names.toUpperCase().split(',');
    4856 
    4857         do {
    4858                 for (var i=0; i<namesAr.length; i++) {
    4859                         if (node.nodeName == namesAr[i] || names == "*") {
    4860                                 if (typeof(attrib_name) == "undefined")
    4861                                         return node;
    4862                                 else if (node.getAttribute(attrib_name)) {
    4863                                         if (typeof(attrib_value) == "undefined") {
    4864                                                 if (node.getAttribute(attrib_name) != "")
    4865                                                         return node;
    4866                                         } else if (node.getAttribute(attrib_name) == attrib_value)
    4867                                                 return node;
    4868                                 }
    4869                         }
    4870                 }
    4871         } while ((node = node.parentNode) != null);
    48725214
    48735215        return null;
    48745216};
    48755217
    4876 TinyMCE_Engine.prototype.getParentNode = function(n, f) {
    4877         while (n) {
    4878                 if (f(n))
    4879                         return n;
    4880 
    4881                 n = n.parentNode;
    4882         }
    4883 
    4884         return null;
    4885 };
    4886 
    4887 TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
    4888         if (typeof(default_value) == "undefined")
    4889                 default_value = "";
     5218TinyMCE_Engine.prototype.getAttrib = function(elm, name, dv) {
     5219        var v;
     5220
     5221        if (typeof(dv) == "undefined")
     5222                dv = "";
    48905223
    48915224        // Not a element
    48925225        if (!elm || elm.nodeType != 1)
    4893                 return default_value;
    4894 
    4895         var v = elm.getAttribute(name);
     5226                return dv;
     5227
     5228        v = elm.getAttribute(name);
    48965229
    48975230        // Try className for class attrib
    … …  
    49075240                v = elm.href;
    49085241
    4909         if (name == "http-equiv" && tinyMCE.isMSIE)
     5242        if (name == "http-equiv" && tinyMCE.isIE)
    49105243                v = elm.httpEquiv;
    49115244
    … …  
    49135246                v = elm.style.cssText;
    49145247
    4915         return (v && v != "") ? v : default_value;
     5248        return (v && v != "") ? v : dv;
    49165249};
    49175250
    4918 TinyMCE_Engine.prototype.setAttrib = function(element, name, value, fix_value) {
    4919         if (typeof(value) == "number" && value != null)
    4920                 value = "" + value;
    4921 
    4922         if (fix_value) {
    4923                 if (value == null)
    4924                         value = "";
    4925 
    4926                 var re = new RegExp('[^0-9%]', 'g');
    4927                 value = value.replace(re, '');
     5251TinyMCE_Engine.prototype.setAttrib = function(el, name, va, fix) {
     5252        if (typeof(va) == "number" && va != null)
     5253                va = "" + va;
     5254
     5255        if (fix) {
     5256                if (va == null)
     5257                        va = "";
     5258
     5259                va = va.replace(/[^0-9%]/g, '');
    49285260        }
    49295261
    49305262        if (name == "style")
    4931                 element.style.cssText = value;
     5263                el.style.cssText = va;
    49325264
    49335265        if (name == "class")
    4934                 element.className = value;
    4935 
    4936         if (value != null && value != "" && value != -1)
    4937                 element.setAttribute(name, value);
     5266                el.className = va;
     5267
     5268        if (va != null && va != "" && va != -1)
     5269                el.setAttribute(name, va);
    49385270        else
    4939                 element.removeAttribute(name);
     5271                el.removeAttribute(name);
    49405272};
    49415273
    4942 TinyMCE_Engine.prototype.setStyleAttrib = function(elm, name, value) {
    4943         eval('elm.style.' + name + '=value;');
    4944 
    4945         // Style attrib deleted
    4946         if (tinyMCE.isMSIE && value == null || value == '') {
    4947                 var str = tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));
    4948                 elm.style.cssText = str;
    4949                 elm.setAttribute("style", str);
     5274TinyMCE_Engine.prototype.setStyleAttrib = function(e, n, v) {
     5275        e.style[n] = v;
     5276
     5277        // Style attrib deleted in IE
     5278        if (tinyMCE.isIE && v == null || v == '') {
     5279                v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText));
     5280                e.style.cssText = v;
     5281                e.setAttribute("style", v);
    49505282        }
    49515283};
    … …  
    49685300};
    49695301
    4970 TinyMCE_Engine.prototype.getAbsPosition = function(n) {
    4971         var p = {absLeft : 0, absTop : 0};
    4972 
    4973         while (n) {
    4974                 p.absLeft += n.offsetLeft;
    4975                 p.absTop += n.offsetTop;
     5302TinyMCE_Engine.prototype.getAbsPosition = function(n, cn) {
     5303        var l = 0, t = 0;
     5304
     5305        while (n && n != cn) {
     5306                l += n.offsetLeft;
     5307                t += n.offsetTop;
    49765308                n = n.offsetParent;
    49775309        }
    49785310
    4979         return p;
     5311        return {absLeft : l, absTop : t};
    49805312};
    49815313
    … …  
    50065338};
    50075339
     5340TinyMCE_Engine.prototype.selectElements = function(n, na, f) {
     5341        var i, a = [], nl, x;
     5342
     5343        for (x=0, na = na.split(','); x<na.length; x++)
     5344                for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
     5345                        (!f || f(nl[i])) && a.push(nl[i]);
     5346
     5347        return a;
     5348};
     5349
    50085350TinyMCE_Engine.prototype.selectNodes = function(n, f, a) {
    50095351        var i;
    … …  
    50255367TinyMCE_Engine.prototype.addCSSClass = function(e, c, b) {
    50265368        var o = this.removeCSSClass(e, c);
    5027 
    50285369        return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
    50295370};
    50305371
    50315372TinyMCE_Engine.prototype.removeCSSClass = function(e, c) {
    5032         var a = this.explode(' ', e.className), i;
    5033 
    5034         for (i=0; i<a.length; i++) {
    5035                 if (a[i] == c)
    5036                         a[i] = '';
    5037         }
    5038 
    5039         return e.className = a.join(' ');
     5373        c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
     5374        return e.className = c != ' ' ? c : '';
     5375};
     5376
     5377TinyMCE_Engine.prototype.hasCSSClass = function(n, c) {
     5378        return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
    50405379};
    50415380
    … …  
    50605399                e.parentNode.replaceChild(ne, e);
    50615400        }
     5401};
     5402
     5403TinyMCE_Engine.prototype.getViewPort = function(w) {
     5404        var d = w.document, m = d.compatMode == 'CSS1Compat', b = d.body, de = d.documentElement;
     5405
     5406        return {
     5407                left : w.pageXOffset || (m ? de.scrollLeft : b.scrollLeft),
     5408                top : w.pageYOffset || (m ? de.scrollTop : b.scrollTop),
     5409                width : w.innerWidth || (m ? de.clientWidth : b.clientWidth),
     5410                height : w.innerHeight || (m ? de.clientHeight : b.clientHeight)
     5411        };
    50625412};
    50635413
    … …  
    52295579
    52305580TinyMCE_Engine.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) {
    5231         var baseURL = this.parseURL(base_url);
     5581        var baseURL = this.parseURL(base_url), baseURLParts, relURLParts;
    52325582        var relURL = this.parseURL(relative_url);
    52335583
    5234         if (relative_url == "" || relative_url.charAt(0) == '/' || relative_url.indexOf('://') != -1 || relative_url.indexOf('mailto:') != -1 || relative_url.indexOf('javascript:') != -1)
     5584        if (relative_url == "" || relative_url.indexOf('://') != -1 || /^(mailto:|javascript:|#|\/)/.test(relative_url))
    52355585                return relative_url;
    52365586
    … …  
    53075657
    53085658        // Fix relative/Mozilla
    5309         if (!tinyMCE.isMSIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
     5659        if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
    53105660                return tinyMCE.settings['base_href'] + url;
    53115661
    … …  
    53545704
    53555705TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
     5706        var i, elms, src, href, mhref, msrc;
     5707
    53565708        // Convert all image URL:s to absolute URL
    5357         var elms = body.getElementsByTagName("img");
    5358         for (var i=0; i<elms.length; i++) {
    5359                 var src = tinyMCE.getAttrib(elms[i], 'src');
    5360 
    5361                 var msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
     5709        elms = body.getElementsByTagName("img");
     5710        for (i=0; i<elms.length; i++) {
     5711                src = tinyMCE.getAttrib(elms[i], 'src');
     5712
     5713                msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
    53625714                if (msrc != "")
    53635715                        src = msrc;
    … …  
    53705722
    53715723        // Convert all link URL:s to absolute URL
    5372         var elms = body.getElementsByTagName("a");
    5373         for (var i=0; i<elms.length; i++) {
    5374                 var href = tinyMCE.getAttrib(elms[i], 'href');
    5375 
    5376                 var mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
     5724        elms = body.getElementsByTagName("a");
     5725        for (i=0; i<elms.length; i++) {
     5726                href = tinyMCE.getAttrib(elms[i], 'href');
     5727
     5728                mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
    53775729                if (mhref != "")
    53785730                        href = mhref;
    … …  
    53885740
    53895741TinyMCE_Engine.prototype.clearArray = function(a) {
    5390         for (var k in a)
    5391                 a[k] = null;
     5742        var n;
     5743
     5744        for (n in a)
     5745                a[n] = null;
    53925746
    53935747        return a;
    53945748};
    53955749
     5750TinyMCE_Engine.prototype.explode = function(d, s) {
     5751        var ar = s.split(d), oar = new Array(), i;
     5752
     5753        for (i = 0; i<ar.length; i++) {
     5754                if (ar[i] != "")
     5755                        oar[oar.length] = ar[i];
     5756        }
     5757
     5758        return oar;
     5759};
     5760
    53965761/* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */
    53975762
    53985763TinyMCE_Engine.prototype._setEventsEnabled = function(node, state) {
    5399         var events = new Array('onfocus','onblur','onclick','ondblclick',
     5764        var evs, x, y, elms, i, event;
     5765        var events = ['onfocus','onblur','onclick','ondblclick',
    54005766                                'onmousedown','onmouseup','onmouseover','onmousemove',
    5401                                 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');
    5402 
    5403         var evs = tinyMCE.settings['event_elements'].split(',');
    5404         for (var y=0; y<evs.length; y++){
    5405                 var elms = node.getElementsByTagName(evs[y]);
    5406                 for (var i=0; i<elms.length; i++) {
    5407                         var event = "";
    5408 
    5409                         for (var x=0; x<events.length; x++) {
     5767                                'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'];
     5768
     5769        evs = tinyMCE.settings['event_elements'].split(',');
     5770        for (y=0; y<evs.length; y++){
     5771                elms = node.getElementsByTagName(evs[y]);
     5772                for (i=0; i<elms.length; i++) {
     5773                        event = "";
     5774
     5775                        for (x=0; x<events.length; x++) {
    54105776                                if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') {
    54115777                                        event = tinyMCE.cleanupEventStr("" + event);
    … …  
    54545820                                continue;
    54555821
    5456                         tinyMCE.selectedInstance = inst;
     5822                        inst.select();
    54575823                        win = inst.getWin();
    54585824
    … …  
    54725838};
    54735839
     5840TinyMCE_Engine.prototype.findEvent = function(e) {
     5841        var n, inst;
     5842
     5843        if (e)
     5844                return e;
     5845
     5846        for (n in tinyMCE.instances) {
     5847                inst = tinyMCE.instances[n];
     5848
     5849                if (tinyMCE.isInstance(inst) && inst.getWin().event)
     5850                        return inst.getWin().event;
     5851        }
     5852
     5853        return null;
     5854};
     5855
    54745856TinyMCE_Engine.prototype.unloadHandler = function() {
    54755857        tinyMCE.triggerSave(true, true);
    … …  
    54775859
    54785860TinyMCE_Engine.prototype.addEventHandlers = function(inst) {
    5479         var doc = inst.getDoc();
     5861        this.setEventHandlers(inst, 1);
     5862};
     5863
     5864TinyMCE_Engine.prototype.setEventHandlers = function(inst, s) {
     5865        var doc = inst.getDoc(), ie, ot, i, f = s ? tinyMCE.addEvent : tinyMCE.removeEvent;
     5866
     5867        ie = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick'];
     5868        ot = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'focus', 'blur', 'dragdrop'];
    54805869
    54815870        inst.switchSettings();
    54825871
    5483         if (tinyMCE.isMSIE) {
    5484                 tinyMCE.addEvent(doc, "keypress", TinyMCE_Engine.prototype._eventPatch);
    5485                 tinyMCE.addEvent(doc, "keyup", TinyMCE_Engine.prototype._eventPatch);
    5486                 tinyMCE.addEvent(doc, "keydown", TinyMCE_Engine.prototype._eventPatch);
    5487                 tinyMCE.addEvent(doc, "mouseup", TinyMCE_Engine.prototype._eventPatch);
    5488                 tinyMCE.addEvent(doc, "mousedown", TinyMCE_Engine.prototype._eventPatch);
    5489                 tinyMCE.addEvent(doc, "click", TinyMCE_Engine.prototype._eventPatch);
     5872        if (tinyMCE.isIE) {
     5873                for (i=0; i<ie.length; i++)
     5874                        f(doc, ie[i], TinyMCE_Engine.prototype._eventPatch);
    54905875        } else {
    5491                 tinyMCE.addEvent(doc, "keypress", tinyMCE.handleEvent);
    5492                 tinyMCE.addEvent(doc, "keydown", tinyMCE.handleEvent);
    5493                 tinyMCE.addEvent(doc, "keyup", tinyMCE.handleEvent);
    5494                 tinyMCE.addEvent(doc, "click", tinyMCE.handleEvent);
    5495                 tinyMCE.addEvent(doc, "mouseup", tinyMCE.handleEvent);
    5496                 tinyMCE.addEvent(doc, "mousedown", tinyMCE.handleEvent);
    5497                 tinyMCE.addEvent(doc, "focus", tinyMCE.handleEvent);
    5498                 tinyMCE.addEvent(doc, "blur", tinyMCE.handleEvent);
     5876                for (i=0; i<ot.length; i++)
     5877                        f(doc, ot[i], tinyMCE.handleEvent);
    54995878
    55005879                eval('try { doc.designMode = "On"; } catch(e) {}'); // Force designmode
    … …  
    55035882
    55045883TinyMCE_Engine.prototype.onMouseMove = function() {
    5505         var inst;
     5884        var inst, lh;
     5885
     5886        // Fix for IE7 bug where it's not restoring hover on anchors correctly
     5887        if (tinyMCE.lastHover) {
     5888                lh = tinyMCE.lastHover;
     5889
     5890                // Call out on menus and refresh class on normal buttons
     5891                if (lh.className.indexOf('mceMenu') != -1)
     5892                        tinyMCE._menuButtonEvent('out', lh);
     5893                else
     5894                        lh.className = lh.className;
     5895
     5896                tinyMCE.lastHover = null;
     5897        }
    55065898
    55075899        if (!tinyMCE.hasMouseMoved) {
    … …  
    55205912
    55215913TinyMCE_Engine.prototype.cancelEvent = function(e) {
    5522         if (tinyMCE.isMSIE) {
     5914        if (!e)
     5915                return false;
     5916
     5917        if (tinyMCE.isIE) {
    55235918                e.returnValue = false;
    55245919                e.cancelBubble = true;
    5525         } else
     5920        } else {
    55265921                e.preventDefault();
     5922                e.stopPropagation && e.stopPropagation();
     5923        }
     5924
     5925        return false;
    55275926};
    55285927
    55295928TinyMCE_Engine.prototype.addEvent = function(o, n, h) {
     5929        // Add cleanup for all non unload events
     5930        if (n != 'unload') {
     5931                function clean() {
     5932                        var ex;
     5933
     5934                        try {
     5935                                tinyMCE.removeEvent(o, n, h);
     5936                                tinyMCE.removeEvent(window, 'unload', clean);
     5937                                o = n = h = null;
     5938                        } catch (ex) {
     5939                                // IE may produce access denied exception on unload
     5940                        }
     5941                }
     5942
     5943                // Add memory cleaner
     5944                tinyMCE.addEvent(window, 'unload', clean);
     5945        }
     5946
    55305947        if (o.attachEvent)
    55315948                o.attachEvent("on" + n, h);
    55325949        else
    55335950                o.addEventListener(n, h, false);
     5951};
     5952
     5953TinyMCE_Engine.prototype.removeEvent = function(o, n, h) {
     5954        if (o.detachEvent)
     5955                o.detachEvent("on" + n, h);
     5956        else
     5957                o.removeEventListener(n, h, false);
    55345958};
    55355959
    … …  
    55485972TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
    55495973        var win = this._win;
    5550         e = tinyMCE.isMSIE ? win.event : e;
    5551         var elm = tinyMCE.isMSIE ? e.srcElement : e.target;
     5974        e = tinyMCE.isIE ? win.event : e;
     5975        var elm = tinyMCE.isIE ? e.srcElement : e.target;
    55525976
    55535977        // Unpiggyback onchange on blur
    … …  
    55836007        var ife;
    55846008
    5585         if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     6009        if (tinyMCE.isRealIE) {
    55866010                ife = tinyMCE.selectedInstance.iframeElement;
    55876011
    … …  
    56096033                var e, r = this.getRng(), h;
    56106034
    5611                 if (tinyMCE.isSafari) {
    5612                         // Not realy perfect!!
    5613                         return r.toString();
    5614                 }
     6035                if (!r)
     6036                        return null;
    56156037
    56166038                e = document.createElement("body");
    56176039
    5618                 if (tinyMCE.isGecko)
     6040                if (r.cloneContents)
    56196041                        e.appendChild(r.cloneContents());
    5620                 else
     6042                else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined')
    56216043                        e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
     6044                else
     6045                        e.innerHTML = r.toString(); // Failed, use text for now
    56226046
    56236047                h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
    … …  
    56346058                var d, r, s, t;
    56356059
    5636                 if (tinyMCE.isMSIE) {
     6060                if (tinyMCE.isIE) {
    56376061                        d = inst.getDoc();
    56386062
    … …  
    56556079
    56566080        getBookmark : function(simple) {
     6081                var inst = this.instance;
    56576082                var rng = this.getRng();
    5658                 var doc = this.instance.getDoc();
    5659                 var sp, le, s, e, nl, i, si, ei;
    5660                 var trng, sx, sy, xx = -999999999;
    5661 
    5662                 // Skip Opera for now
    5663                 if (tinyMCE.isOpera)
    5664                         return null;
    5665 
    5666                 sx = doc.body.scrollLeft + doc.documentElement.scrollLeft;
    5667                 sy = doc.body.scrollTop + doc.documentElement.scrollTop;
    5668 
    5669                 if (tinyMCE.isSafari || tinyMCE.isGecko)
     6083                var doc = inst.getDoc(), b = inst.getBody();
     6084                var sp, le, s, e, nl, i, si, ei, w;
     6085                var trng, sx, sy, xx = -999999999, vp = inst.getViewPort();
     6086
     6087                sx = vp.left;
     6088                sy = vp.top;
     6089
     6090                if (tinyMCE.isSafari || tinyMCE.isOpera || simple)
    56706091                        return {rng : rng, scrollX : sx, scrollY : sy};
    56716092
    5672                 if (tinyMCE.isMSIE) {
    5673                         if (simple)
    5674                                 return {rng : rng};
    5675 
     6093                if (tinyMCE.isIE) {
    56766094                        if (rng.item) {
    56776095                                e = rng.item(0);
    56786096
    5679                                 nl = doc.getElementsByTagName(e.nodeName);
     6097                                nl = b.getElementsByTagName(e.nodeName);
    56806098                                for (i=0; i<nl.length; i++) {
    56816099                                        if (e == nl[i]) {
    … …  
    56926110                                };
    56936111                        } else {
     6112                                trng = doc.body.createTextRange();
     6113                                trng.moveToElementText(inst.getBody());
     6114                                trng.collapse(true);
     6115                                bp = Math.abs(trng.move('character', xx));
     6116
    56946117                                trng = rng.duplicate();
    56956118                                trng.collapse(true);
    … …  
    57016124
    57026125                                return {
    5703                                         start : sp,
     6126                                        start : sp - bp,
    57046127                                        length : le,
    57056128                                        scrollX : sx,
    … …  
    57106133
    57116134                if (tinyMCE.isGecko) {
    5712                         s = tinyMCE.getParentElement(rng.startContainer);
    5713                         for (si=0; si<s.childNodes.length && s.childNodes[si] != rng.startContainer; si++) ;
    5714 
    5715                         nl = doc.getElementsByTagName(s.nodeName);
    5716                         for (i=0; i<nl.length; i++) {
    5717                                         if (s == nl[i]) {
     6135                        s = this.getSel();
     6136                        e = this.getFocusElement();
     6137
     6138                        if (!s)
     6139                                return null;
     6140
     6141                        if (e && e.nodeName == 'IMG') {
     6142                                /*nl = b.getElementsByTagName('IMG');
     6143                                for (i=0; i<nl.length; i++) {
     6144                                        if (e == nl[i]) {
    57186145                                                sp = i;
    57196146                                                break;
    57206147                                        }
    5721                         }
    5722 
    5723                         e = tinyMCE.getParentElement(rng.endContainer);
    5724                         for (ei=0; ei<e.childNodes.length && e.childNodes[ei] != rng.endContainer; ei++) ;
    5725 
    5726                         nl = doc.getElementsByTagName(e.nodeName);
    5727                         for (i=0; i<nl.length; i++) {
    5728                                         if (e == nl[i]) {
    5729                                                 le = i;
    5730                                                 break;
    5731                                         }
    5732                         }
    5733 
    5734                         //tinyMCE.debug(s.nodeName, sp, rng.startOffset, '-' , e.nodeName, le, rng.endOffset);
    5735                         //tinyMCE.debug(sx, sy);
    5736 
    5737                         return {
    5738                                 startTag : s.nodeName,
    5739                                 start : sp,
    5740                                 startIndex : si,
    5741                                 endTag : e.nodeName,
    5742                                 end : le,
    5743                                 endIndex : ei,
    5744                                 startOffset : rng.startOffset,
    5745                                 endOffset : rng.endOffset,
    5746                                 scrollX : sx,
    5747                                 scrollY : sy
    5748                         };
     6148                                }*/
     6149
     6150                                return {
     6151                                        start : -1,
     6152                                        end : -1,
     6153                                        index : sp,
     6154                                        scrollX : sx,
     6155                                        scrollY : sy
     6156                                };
     6157                        }
     6158
     6159                        // Caret or selection
     6160                        if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
     6161                                e = this._getPosText(b, s.anchorNode, s.focusNode);
     6162
     6163                                if (!e)
     6164                                        return {scrollX : sx, scrollY : sy};
     6165
     6166                                return {
     6167                                        start : e.start + s.anchorOffset,
     6168                                        end : e.end + s.focusOffset,
     6169                                        scrollX : sx,
     6170                                        scrollY : sy
     6171                                };
     6172                        } else {
     6173                                e = this._getPosText(b, rng.startContainer, rng.endContainer);
     6174
     6175                                if (!e)
     6176                                        return {scrollX : sx, scrollY : sy};
     6177
     6178                                return {
     6179                                        start : e.start + rng.startOffset,
     6180                                        end : e.end + rng.endOffset,
     6181                                        scrollX : sx,
     6182                                        scrollY : sy
     6183                                };
     6184                        }
    57496185                }
    57506186
    … …  
    57536189
    57546190        moveToBookmark : function(bookmark) {
    5755                 var rng, nl, i;
    57566191                var inst = this.instance;
     6192                var rng, nl, i, ex, b = inst.getBody(), sd;
    57576193                var doc = inst.getDoc();
    57586194                var win = inst.getWin();
    … …  
    57636199
    57646200                if (tinyMCE.isSafari) {
    5765                         sel.setBaseAndExtent(bookmark.startContainer, bookmark.startOffset, bookmark.endContainer, bookmark.endOffset);
     6201                        sel.setBaseAndExtent(bookmark.rng.startContainer, bookmark.rng.startOffset, bookmark.rng.endContainer, bookmark.rng.endOffset);
    57666202                        return true;
    57676203                }
    57686204
    5769                 if (tinyMCE.isMSIE) {
     6205                if (tinyMCE.isRealIE) {
    57706206                        if (bookmark.rng) {
    5771                                 bookmark.rng.select();
     6207                                try {
     6208                                        bookmark.rng.select();
     6209                                } catch (ex) {
     6210                                        // Ignore
     6211                                }
     6212
    57726213                                return true;
    57736214                        }
    … …  
    57766217
    57776218                        if (bookmark.tag) {
    5778                                 rng = inst.getBody().createControlRange();
    5779 
    5780                                 nl = doc.getElementsByTagName(bookmark.tag);
     6219                                rng = b.createControlRange();
     6220
     6221                                nl = b.getElementsByTagName(bookmark.tag);
    57816222
    57826223                                if (nl.length > bookmark.index) {
    … …  
    57886229                                }
    57896230                        } else {
    5790                                 rng = inst.getSel().createRange();
    5791                                 rng.moveToElementText(inst.getBody());
    5792                                 rng.collapse(true);
    5793                                 rng.moveStart('character', bookmark.start);
    5794                                 rng.moveEnd('character', bookmark.length);
     6231                                // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
     6232                                try {
     6233                                        // Incorrect bookmark
     6234                                        if (bookmark.start < 0)
     6235                                                return true;
     6236
     6237                                        rng = inst.getSel().createRange();
     6238                                        rng.moveToElementText(inst.getBody());
     6239                                        rng.collapse(true);
     6240                                        rng.moveStart('character', bookmark.start);
     6241                                        rng.moveEnd('character', bookmark.length);
     6242                                } catch (ex) {
     6243                                        return true;
     6244                                }
    57956245                        }
    57966246
    … …  
    58016251                }
    58026252
    5803                 if (tinyMCE.isGecko && bookmark.rng) {
    5804                         sel.removeAllRanges();
    5805                         sel.addRange(bookmark.rng);
     6253                if (tinyMCE.isGecko || tinyMCE.isOpera) {
     6254                        if (bookmark.rng) {
     6255                                sel.removeAllRanges();
     6256                                sel.addRange(bookmark.rng);
     6257                        }
     6258
     6259                        if (bookmark.start != -1 && bookmark.end != -1) {
     6260                                try {
     6261                                        sd = this._getTextPos(b, bookmark.start, bookmark.end);
     6262                                        rng = doc.createRange();
     6263                                        rng.setStart(sd.startNode, sd.startOffset);
     6264                                        rng.setEnd(sd.endNode, sd.endOffset);
     6265                                        sel.removeAllRanges();
     6266                                        sel.addRange(rng);
     6267                                        win.focus();
     6268                                } catch (ex) {
     6269                                        // Ignore
     6270                                }
     6271                        }
     6272
     6273                        /*
     6274                        if (typeof(bookmark.index) != 'undefined') {
     6275                                tinyMCE.selectElements(b, 'IMG', function (n) {
     6276                                        if (bookmark.index-- == 0) {
     6277                                                // Select image in Gecko here
     6278                                        }
     6279
     6280                                        return false;
     6281                                });
     6282                        }
     6283                        */
     6284
    58066285                        win.scrollTo(bookmark.scrollX, bookmark.scrollY);
    58076286                        return true;
    58086287                }
    58096288
    5810                 if (tinyMCE.isGecko) {
    5811         //              try {
    5812                                 rng = doc.createRange();
    5813 
    5814                                 nl = doc.getElementsByTagName(bookmark.startTag);
    5815                                 if (nl.length > bookmark.start)
    5816                                         rng.setStart(nl[bookmark.start].childNodes[bookmark.startIndex], bookmark.startOffset);
    5817 
    5818                                 nl = doc.getElementsByTagName(bookmark.endTag);
    5819                                 if (nl.length > bookmark.end)
    5820                                         rng.setEnd(nl[bookmark.end].childNodes[bookmark.endIndex], bookmark.endOffset);
    5821 
    5822                                 sel.removeAllRanges();
    5823                                 sel.addRange(rng);
    5824         /*              } catch {
    5825                                 // Ignore
    5826                         }*/
    5827 
    5828                         win.scrollTo(bookmark.scrollX, bookmark.scrollY);
    5829                         return true;
    5830                 }
    5831 
    58326289                return false;
     6290        },
     6291
     6292        _getPosText : function(r, sn, en) {
     6293                var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
     6294
     6295                while ((n = w.nextNode()) != null) {
     6296                        if (n == sn)
     6297                                d.start = p;
     6298
     6299                        if (n == en) {
     6300                                d.end = p;
     6301                                return d;
     6302                        }
     6303
     6304                        p += n.nodeValue ? n.nodeValue.length : 0;
     6305                }
     6306
     6307                return null;
     6308        },
     6309
     6310        _getTextPos : function(r, sp, ep) {
     6311                var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
     6312
     6313                while ((n = w.nextNode()) != null) {
     6314                        p += n.nodeValue ? n.nodeValue.length : 0;
     6315
     6316                        if (p >= sp && !d.startNode) {
     6317                                d.startNode = n;
     6318                                d.startOffset = sp - (p - n.nodeValue.length);
     6319                        }
     6320
     6321                        if (p >= ep) {
     6322                                d.endNode = n;
     6323                                d.endOffset = ep - (p - n.nodeValue.length);
     6324
     6325                                return d;
     6326                        }
     6327                }
     6328
     6329                return null;
    58336330        },
    58346331
    … …  
    58486345                        to_start = true;
    58496346
    5850                 if (tinyMCE.isMSIE) {
    5851                         rng = inst.getBody().createTextRange();
     6347                if (inst.settings.auto_resize)
     6348                        inst.resizeToContent();
     6349
     6350                if (tinyMCE.isRealIE) {
     6351                        rng = inst.getDoc().body.createTextRange();
    58526352
    58536353                        try {
    … …  
    59166416
    59176417        scrollToNode : function(node) {
    5918                 var inst = this.instance;
    5919                 var pos, doc, scrollX, scrollY, height;
    5920 
    5921                 // Scroll to node position
    5922                 pos = tinyMCE.getAbsPosition(node);
    5923                 doc = inst.getDoc();
    5924                 scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
    5925                 scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
    5926                 height = tinyMCE.isMSIE ? document.getElementById(inst.editorId).style.pixelHeight : inst.targetElement.clientHeight;
     6418                var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin;
    59276419
    59286420                // Only scroll if out of visible area
    5929                 if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
    5930                         inst.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
     6421                if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25))
     6422                        w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25);
     6423
     6424                // Scroll container window
     6425                if (inst.settings.auto_resize) {
     6426                        cwin = inst.getContainerWin();
     6427                        cvp = tinyMCE.getViewPort(cwin);
     6428                        p = this.getAbsPosition(node);
     6429
     6430                        if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height)
     6431                                cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25);
     6432                }
     6433        },
     6434
     6435        getAbsPosition : function(n) {
     6436                var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement);
     6437
     6438                return {
     6439                        absLeft : ipos.absLeft + pos.absLeft,
     6440                        absTop : ipos.absTop + pos.absTop
     6441                };
    59316442        },
    59326443
    … …  
    59346445                var inst = this.instance;
    59356446
    5936                 if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     6447                if (tinyMCE.isRealIE)
    59376448                        return inst.getDoc().selection;
    59386449
    … …  
    59416452
    59426453        getRng : function() {
    5943                 var inst = this.instance;
    5944                 var sel = this.getSel();
    5945 
    5946                 if (sel == null)
     6454                var s = this.getSel();
     6455
     6456                if (s == null)
    59476457                        return null;
    59486458
    5949                 if (tinyMCE.isMSIE && !tinyMCE.isOpera)
    5950                         return sel.createRange();
    5951 
    5952                 if (tinyMCE.isSafari && !sel.getRangeAt)
     6459                if (tinyMCE.isRealIE)
     6460                        return s.createRange();
     6461
     6462                if (tinyMCE.isSafari && !s.getRangeAt)
    59536463                        return '' + window.getSelection();
    59546464
    5955                 return sel.getRangeAt(0);
     6465                return s.getRangeAt(0);
    59566466        },
    59576467
    59586468        getFocusElement : function() {
    5959                 var inst = this.instance;
    5960 
    5961                 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
    5962                         var doc = inst.getDoc();
    5963                         var rng = doc.selection.createRange();
     6469                var inst = this.instance, doc, rng, sel, elm;
     6470
     6471                if (tinyMCE.isRealIE) {
     6472                        doc = inst.getDoc();
     6473                        rng = doc.selection.createRange();
    59646474
    59656475        //              if (rng.collapse)
    59666476        //                      rng.collapse(true);
    59676477
    5968                         var elm = rng.item ? rng.item(0) : rng.parentElement();
     6478                        elm = rng.item ? rng.item(0) : rng.parentElement();
    59696479                } else {
    5970                         if (inst.isHidden())
     6480                        if (!tinyMCE.isSafari && inst.isHidden())
    59716481                                return inst.getBody();
    59726482
    5973                         var sel = this.getSel();
    5974                         var rng = this.getRng();
     6483                        sel = this.getSel();
     6484                        rng = this.getRng();
    59756485
    59766486                        if (!sel || !rng)
    59776487                                return null;
    59786488
    5979                         var elm = rng.commonAncestorContainer;
    5980                         //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
     6489                        elm = rng.commonAncestorContainer;
     6490                        //elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
    59816491
    59826492                        // Handle selection a image or other control like element such as anchors
    … …  
    60006510                return elm;
    60016511        }
    6002 };
     6512
     6513        };
    60036514
    60046515/* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */
    … …  
    60146525TinyMCE_UndoRedo.prototype = {
    60156526        add : function(l) {
    6016                 var b;
     6527                var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur;
    60176528
    60186529                if (l) {
    … …  
    60216532                }
    60226533
    6023                 var inst = this.instance;
    6024 
    60256534                if (this.typingUndoIndex != -1) {
    60266535                        this.undoIndex = this.typingUndoIndex;
    6027                         // tinyMCE.debug("Override: " + this.undoIndex);
    6028                 }
    6029 
    6030                 var newHTML = tinyMCE.trim(inst.getBody().innerHTML);
     6536
     6537                        if (tinyMCE.typingUndoIndex != -1)
     6538                                tinyMCE.undoIndex = tinyMCE.typingUndoIndex;
     6539                }
     6540
     6541                newHTML = tinyMCE.trim(inst.getBody().innerHTML);
    60316542                if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
    6032                         //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex]);
     6543                        //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content);
    60336544
    60346545                        tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
    60356546
    60366547                        // Time to compress
    6037                         var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
     6548                        customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
    60386549                        if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
    6039                                 for (var i=0; i<this.undoLevels.length-1; i++) {
    6040                                         //tinyMCE.debug(this.undoLevels[i] + "=" + this.undoLevels[i+1]);
     6550                                for (i=0; i<this.undoLevels.length-1; i++)
    60416551                                        this.undoLevels[i] = this.undoLevels[i+1];
    6042                                 }
    60436552
    60446553                                this.undoLevels.length--;
    60456554                                this.undoIndex--;
     6555
     6556                                // Todo: Implement global undo/redo logic here
    60466557                        }
    60476558
    60486559                        b = inst.undoBookmark;
     6560
    60496561                        if (!b)
    60506562                                b = inst.selection.getBookmark();
    … …  
    60566568                        };
    60576569
     6570                        // Remove all above from global undo/redo
     6571                        ul = tinyMCE.undoLevels;
     6572                        for (i=tinyMCE.undoIndex + 1; i<ul.length; i++) {
     6573                                ur = ul[i].undoRedo;
     6574
     6575                                if (ur.undoIndex == ur.undoLevels.length -1)
     6576                                        ur.undoIndex--;
     6577
     6578                                ur.undoLevels.length--;
     6579                        }
     6580
     6581                        // Add global undo level
     6582                        tinyMCE.undoLevels[tinyMCE.undoIndex++] = inst;
     6583                        tinyMCE.undoLevels.length = tinyMCE.undoIndex;
     6584
    60586585                        this.undoLevels.length = this.undoIndex + 1;
    60596586
    6060                         //tinyMCE.debug("level added" + this.undoIndex);
    60616587                        return true;
    6062 
    6063                         // tinyMCE.debug(this.undoIndex + "," + (this.undoLevels.length-1));
    60646588                }
    60656589
    … …  
    60736597                if (this.undoIndex > 0) {
    60746598                        this.undoIndex--;
     6599
    60756600                        tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
    60766601                        inst.repaint();
     6602
    60776603                        if (inst.settings.custom_undo_redo_restore_selection)
    60786604                                inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
    60796605                }
    6080 
    6081                 // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
    60826606        },
    60836607
    … …  
    60896613                if (this.undoIndex < (this.undoLevels.length-1)) {
    60906614                        this.undoIndex++;
     6615
    60916616                        tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
    60926617                        inst.repaint();
    6093 //                                      if (this.undoIndex > 0)
    6094 //                                              inst.selection.moveToBookmark(this.undoLevels[this.undoIndex-1].bookmark);
     6618
    60956619                        if (inst.settings.custom_undo_redo_restore_selection)
    60966620                                inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
    6097                         // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
    60986621                }
    60996622
    61006623                tinyMCE.triggerNodeChange();
    61016624        }
    6102 };
     6625
     6626        };
    61036627
    61046628/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
    … …  
    61066630var TinyMCE_ForceParagraphs = {
    61076631        _insertPara : function(inst, e) {
     6632                var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0);
     6633                var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock;
     6634                var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null;
     6635                var paraBefore, paraAfter, startChop, endChop, contents;
     6636
    61086637                function isEmpty(para) {
    61096638                        function isEmptyHTML(html) {
    … …  
    61346663                }
    61356664
    6136                 var doc = inst.getDoc();
    6137                 var sel = inst.getSel();
    6138                 var win = inst.contentWindow;
    6139                 var rng = sel.getRangeAt(0);
    6140                 var body = doc.body;
    6141                 var rootElm = doc.documentElement;
    6142                 var blockName = "P";
    6143 
    61446665        //      tinyMCE.debug(body.innerHTML);
    61456666
    … …  
    61476668
    61486669                // Setup before range
    6149                 var rngBefore = doc.createRange();
     6670                rngBefore = doc.createRange();
    61506671                rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
    61516672                rngBefore.collapse(true);
    61526673
    61536674                // Setup after range
    6154                 var rngAfter = doc.createRange();
     6675                rngAfter = doc.createRange();
    61556676                rngAfter.setStart(sel.focusNode, sel.focusOffset);
    61566677                rngAfter.collapse(true);
    61576678
    61586679                // Setup start/end points
    6159                 var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
    6160                 var startNode = direct ? sel.anchorNode : sel.focusNode;
    6161                 var startOffset = direct ? sel.anchorOffset : sel.focusOffset;
    6162                 var endNode = direct ? sel.focusNode : sel.anchorNode;
    6163                 var endOffset = direct ? sel.focusOffset : sel.anchorOffset;
     6680                direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
     6681                startNode = direct ? sel.anchorNode : sel.focusNode;
     6682                startOffset = direct ? sel.anchorOffset : sel.focusOffset;
     6683                endNode = direct ? sel.focusNode : sel.anchorNode;
     6684                endOffset = direct ? sel.focusOffset : sel.anchorOffset;
    61646685
    61656686                startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;
    61666687                endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;
    61676688
    6168                 // tinyMCE.debug(startNode, endNode);
    6169 
    61706689                // Get block elements
    6171                 var startBlock = tinyMCE.getParentBlockElement(startNode);
    6172                 var endBlock = tinyMCE.getParentBlockElement(endNode);
     6690                startBlock = inst.getParentBlockElement(startNode);
     6691                endBlock = inst.getParentBlockElement(endNode);
    61736692
    61746693                // If absolute force paragraph generation within
    … …  
    61896708
    61906709                // Within a list use normal behaviour
    6191                 if (tinyMCE.getParentElement(startBlock, "OL,UL") != null)
     6710                if (tinyMCE.getParentElement(startBlock, "OL,UL", null, body) != null)
    61926711                        return false;
    61936712
    … …  
    61976716
    61986717                // Setup new paragraphs
    6199                 var paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
    6200                 var paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
     6718                paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
     6719                paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
    62016720
    62026721                // Is header, then force paragraph under
    … …  
    62056724
    62066725                // Setup chop nodes
    6207                 var startChop = startNode;
    6208                 var endChop = endNode;
     6726                startChop = startNode;
     6727                endChop = endNode;
    62096728
    62106729                // Get startChop node
    … …  
    62376756                        // Delete selection
    62386757                        rng.deleteContents();
    6239                         sel.removeAllRanges();
     6758
     6759                        if (!tinyMCE.isSafari)
     6760                                sel.removeAllRanges();
    62406761
    62416762                        if (startChop != rootElm && endChop != rootElm) {
    … …  
    62616782                                        rngBefore.setEndAfter(endChop);
    62626783
    6263                                 var contents = rng.cloneContents();
     6784                                contents = rng.cloneContents();
    62646785                                if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
    62656786                                        paraAfter.innerHTML = contents.firstChild.innerHTML;
    … …  
    62816802
    62826803                                // Insert new paragraphs
    6283                                 paraAfter.normalize();
    6284                                 rngBefore.insertNode(paraAfter);
    6285                                 paraBefore.normalize();
    6286                                 rngBefore.insertNode(paraBefore);
    6287 
    6288                                 // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
     6804                                if (tinyMCE.isOpera) {
     6805                                        paraBefore.normalize();
     6806                                        rngBefore.insertNode(paraBefore);
     6807                                        paraAfter.normalize();
     6808                                        rngBefore.insertNode(paraAfter);
     6809                                } else {
     6810                                        paraAfter.normalize();
     6811                                        rngBefore.insertNode(paraAfter);
     6812                                        paraBefore.normalize();
     6813                                        rngBefore.insertNode(paraBefore);
     6814                                }
     6815
     6816                                //tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
    62896817                        } else {
    62906818                                body.innerHTML = "<" + blockName + ">&nbsp;</" + blockName + "><" + blockName + ">&nbsp;</" + blockName + ">";
    … …  
    62926820                        }
    62936821
     6822                        inst.selection.moveToBookmark(b);
    62946823                        inst.selection.selectNode(paraAfter, true, true);
    62956824
    … …  
    63096838                rngAfter.setEndAfter(endChop);
    63106839                rngAfter.setStart(endNode, endOffset);
    6311                 var contents = rngAfter.cloneContents();
     6840                contents = rngAfter.cloneContents();
    63126841
    63136842                if (contents.firstChild && contents.firstChild.nodeName == blockName) {
    … …  
    63326861
    63336862                // Create a range around everything
    6334                 var rng = doc.createRange();
     6863                rng = doc.createRange();
    63356864
    63366865                if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
    … …  
    63506879                // Delete all contents and insert new paragraphs
    63516880                rng.deleteContents();
    6352                 rng.insertNode(paraAfter);
    6353                 rng.insertNode(paraBefore);
     6881
     6882                if (tinyMCE.isOpera) {
     6883                        rng.insertNode(paraBefore);
     6884                        rng.insertNode(paraAfter);
     6885                } else {
     6886                        rng.insertNode(paraAfter);
     6887                        rng.insertNode(paraBefore);
     6888                }
     6889
    63546890                //tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
    63556891
    … …  
    63586894                paraBefore.normalize();
    63596895
     6896                inst.selection.moveToBookmark(b);
    63606897                inst.selection.selectNode(paraAfter, true, true);
    63616898
    … …  
    63666903                var r = inst.getRng(), sn = r.startContainer, nv, s = false;
    63676904
    6368                 if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR") {
     6905                // Added body check for bug #1527787
     6906                if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR" && sn.parentNode.nodeName != "BODY") {
    63696907                        nv = sn.nodeValue;
    63706908
    6371                         // Handle if a backspace is pressed after a space character #bug 1466054
    6372                         if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
    6373                                 s = true;
     6909                        // Handle if a backspace is pressed after a space character #bug 1466054 removed since fix for #1527787
     6910                        /*if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
     6911                                s = true;*/
    63746912
    63756913                        // Only remove BRs if we are at the end of line #bug 1464152
    … …  
    63786916                }
    63796917
     6918                if (inst.settings.auto_resize)
     6919                        inst.resizeToContent();
     6920
    63806921                return s;
    63816922        }
    6382 };
     6923
     6924        };
    63836925
    63846926/* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */
    … …  
    65167058                if (!this.blockerElement && this.blockMode) {
    65177059                        d = this.doc;
    6518                         b = d.createElement("iframe");
    6519 
    6520                         b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
    6521                         b.src = 'javascript:false;';
    6522                         b.frameBorder = '0';
    6523                         b.scrolling = 'no';
    6524 
    6525                         d.body.appendChild(b);
     7060                        b = d.getElementById(this.id + "_blocker");
     7061
     7062                        if (!b) {
     7063                                b = d.createElement("iframe");
     7064
     7065                                b.setAttribute('id', this.id + "_blocker");
     7066                                b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
     7067                                b.src = 'javascript:false;';
     7068                                b.frameBorder = '0';
     7069                                b.scrolling = 'no';
     7070       
     7071                                d.body.appendChild(b);
     7072                        }
     7073
    65267074                        this.blockerElement = b;
    65277075                }
    … …  
    65427090        },
    65437091
    6544         create : function(n, c, p) {
     7092        create : function(n, c, p, h) {
    65457093                var d = this.doc, e = d.createElement(n);
    65467094
    … …  
    65537101                        p = d.body;
    65547102
     7103                if (h)
     7104                        e.innerHTML = h;
     7105
    65557106                p.appendChild(e);
    65567107
    65577108                return this.element = e;
     7109        },
     7110
     7111        exists : function() {
     7112                return this.doc.getElementById(this.id) != null;
    65587113        },
    65597114
    … …  
    65647119                return parseInt(s);
    65657120        }
    6566 };
     7121
     7122        };
    65677123
    65687124/* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */
    … …  
    65837139};
    65847140
    6585 // Extends the TinyMCE_Layer class
    65867141TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
    65877142        init : function(s) {
    … …  
    66547209
    66557210                                default:
    6656                                         h += '<tr><td><a href="javascript:void(0);" onmousedown="' + tinyMCE.xmlEncode(m[i].js) + ';return false;"><span' + c +'>' + t + '</span></a>';
     7211                                        h += '<tr><td><a href="#" onclick="return tinyMCE.cancelEvent(event);" onmousedown="return tinyMCE.cancelEvent(event);" onmouseup="' + tinyMCE.xmlEncode(m[i].js) + ';return tinyMCE.cancelEvent(event);"><span' + c +'>' + t + '</span></a>';
    66577212                        }
    66587213
    … …  
    66917246                tinyMCE.lastMenu = this;
    66927247        }
    6693 });
     7248
     7249        });
     7250
     7251/* file:jscripts/tiny_mce/classes/TinyMCE_Compatibility.class.js */
     7252
     7253if (!Function.prototype.call) {
     7254        Function.prototype.call = function() {
     7255                var a = arguments, s = a[0], i, as = '', r, o;
     7256
     7257                for (i=1; i<a.length; i++)
     7258                        as += (i > 1 ? ',' : '') + 'a[' + i + ']';
     7259
     7260                o = s._fu;
     7261                s._fu = this;
     7262                r = eval('s._fu(' + as + ')');
     7263                s._fu = o;
     7264
     7265                return r;
     7266        };
     7267};
    66947268
    66957269/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
    66967270
    66977271TinyMCE_Engine.prototype.debug = function() {
    6698         var m = "", e, a, i;
    6699 
    6700         e = document.getElementById("tinymce_debug");
    6701         if (!e) {
    6702                 var d = document.createElement("div");
    6703                 d.setAttribute("className", "debugger");
    6704                 d.className = "debugger";
    6705                 d.innerHTML = 'Debug output:<textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap" mce_editable="false"></textarea>';
    6706 
    6707                 document.body.appendChild(d);
    6708                 e = document.getElementById("tinymce_debug");
    6709         }
    6710 
    6711         a = this.debug.arguments;
    6712         for (i=0; i<a.length; i++) {
     7272        var m = "", a, i, l = tinyMCE.log.length;
     7273
     7274        for (i=0, a = this.debug.arguments; i<a.length; i++) {
    67137275                m += a[i];
     7276
    67147277                if (i<a.length-1)
    67157278                        m += ', ';
    67167279        }
    67177280
    6718         e.value += m + "\n";
     7281        if (l < 1000)
     7282                tinyMCE.log[l] = "[debug] " + m;
    67197283};
     7284
  • trunk/wp-includes/js/tinymce/tiny_mce_popup.js

    r4080 r4506  
    1 
    2 
    31// Some global instances, this will be filled later
    42var tinyMCE = null, tinyMCELang = null;
    53
    6 
    74function TinyMCE_Popup() {
    85};
    96
    10 
    11 TinyMCE_Popup.prototype.init = function() {
    12         var win = window.opener ? window.opener : window.dialogArguments;
    13         var inst;
    14 
    15         if (!win) {
    16                 // Try parent
    17                 win = parent.parent;
     7TinyMCE_Popup.prototype = {
     8        findWin : function(w) {
     9                var c;
     10
     11                // Check parents
     12                c = w;
     13                while (c && (c = c.parent) != null) {
     14                        if (typeof(c.tinyMCE) != "undefined")
     15                                return c;
     16                }
     17
     18                // Check openers
     19                c = w;
     20                while (c && (c = c.opener) != null) {
     21                        if (typeof(c.tinyMCE) != "undefined")
     22                                return c;
     23                }
    1824
    1925                // Try top
    20                 if (typeof(win.tinyMCE) == "undefined")
    21                         win = top;
    22         }
    23 
    24         window.opener = win;
    25         this.windowOpener = win;
    26         this.onLoadEval = "";
    27 
    28         // Setup parent references
    29         tinyMCE = win.tinyMCE;
    30         tinyMCELang = win.tinyMCELang;
    31 
    32         if (!tinyMCE) {
    33                 alert("tinyMCE object reference not found from popup.");
    34                 return;
    35         }
    36 
    37         inst = tinyMCE.selectedInstance;
    38         this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
    39         this.storeSelection = (tinyMCE.isMSIE && !tinyMCE.isOpera) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
    40 
    41         if (this.isWindow)
    42                 window.focus();
    43 
    44         // Store selection
    45         if (this.storeSelection)
    46                 inst.selectionBookmark = inst.selection.getBookmark(true);
    47 
    48         // Setup dir
    49         if (tinyMCELang['lang_dir'])
    50                 document.dir = tinyMCELang['lang_dir'];
    51 
    52         // Setup title
    53         var re = new RegExp('{|\\\$|}', 'g');
    54         var title = document.title.replace(re, "");
    55         if (typeof tinyMCELang[title] != "undefined") {
    56                 var divElm = document.createElement("div");
    57                 divElm.innerHTML = tinyMCELang[title];
    58                 document.title = divElm.innerHTML;
    59 
    60                 if (tinyMCE.setWindowTitle != null)
    61                         tinyMCE.setWindowTitle(window, divElm.innerHTML);
    62         }
    63 
    64         // Output Popup CSS class
    65         document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
    66 
    67         tinyMCE.addEvent(window, "load", this.onLoad);
    68 };
    69 
    70 
    71 TinyMCE_Popup.prototype.onLoad = function() {
    72         var dir, i, elms, body = document.body;
    73 
    74         body.onkeydown = function (e) {
    75                 e = e ? e : window.event;
    76                 if ( e.keyCode == 27 && !e.shiftKey && !e.controlKey && !e.altKey ) {
    77                         tinyMCE.closeWindow(window);
    78                 }
    79         }
    80 
    81         if (tinyMCE.getWindowArg('mce_replacevariables', true))
    82                 body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
    83 
    84         dir = tinyMCE.selectedInstance.settings['directionality'];
    85         if (dir == "rtl" && document.forms && document.forms.length > 0) {
    86                 elms = document.forms[0].elements;
    87                 for (i=0; i<elms.length; i++) {
    88                         if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
    89                                 elms[i].dir = dir;
    90                 }
    91         }
    92 
    93         if (body.style.display == 'none')
    94                 body.style.display = 'block';
    95 
    96         // Execute real onload (Opera fix)
    97         if (tinyMCEPopup.onLoadEval != "")
    98                 eval(tinyMCEPopup.onLoadEval);
    99 };
    100 
    101 
    102 TinyMCE_Popup.prototype.executeOnLoad = function(str) {
    103         if (tinyMCE.isOpera)
    104                 this.onLoadEval = str;
    105         else
    106                 eval(str);
    107 };
    108 
    109 
    110 TinyMCE_Popup.prototype.resizeToInnerSize = function() {
    111         // Netscape 7.1 workaround
    112         if (this.isWindow && tinyMCE.isNS71) {
    113                 window.resizeBy(0, 10);
    114                 return;
    115         }
    116 
    117         if (this.isWindow) {
    118                 var doc = document;
    119                 var body = doc.body;
    120                 var oldMargin, wrapper, iframe, nodes, dx, dy;
     26                if (typeof(top.tinyMCE) != "undefined")
     27                        return top;
     28
     29                return null;
     30        },
     31
     32        init : function() {
     33                var win = window.opener ? window.opener : window.dialogArguments, c;
     34                var inst;
     35
     36                if (!win)
     37                        win = this.findWin(window);
     38
     39                if (!win) {
     40                        alert("tinyMCE object reference not found from popup.");
     41                        return;
     42                }
     43
     44                window.opener = win;
     45                this.windowOpener = win;
     46                this.onLoadEval = "";
     47
     48                // Setup parent references
     49                tinyMCE = win.tinyMCE;
     50                tinyMCELang = win.tinyMCELang;
     51
     52                inst = tinyMCE.selectedInstance;
     53                this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
     54                this.storeSelection = (tinyMCE.isRealIE) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
     55
     56                if (this.isWindow)
     57                        window.focus();
     58
     59                // Store selection
     60                if (this.storeSelection)
     61                        inst.selectionBookmark = inst.selection.getBookmark(true);
     62
     63                // Setup dir
     64                if (tinyMCELang['lang_dir'])
     65                        document.dir = tinyMCELang['lang_dir'];
     66
     67                // Setup title
     68                var re = new RegExp('{|\\\$|}', 'g');
     69                var title = document.title.replace(re, "");
     70                if (typeof tinyMCELang[title] != "undefined") {
     71                        var divElm = document.createElement("div");
     72                        divElm.innerHTML = tinyMCELang[title];
     73                        document.title = divElm.innerHTML;
     74
     75                        if (tinyMCE.setWindowTitle != null)
     76                                tinyMCE.setWindowTitle(window, divElm.innerHTML);
     77                }
     78
     79                // Output Popup CSS class
     80                document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
     81
     82                if (tinyMCE.getParam("popups_css_add")) {
     83                        c = tinyMCE.getParam("popups_css_add");
     84
     85                        // Is relative
     86                        if (c.indexOf('://') == -1 && c.charAt(0) != '/')
     87                                c = tinyMCE.documentBasePath + "/" + c;
     88
     89                        document.write('<link href="' + c + '" rel="stylesheet" type="text/css">');
     90                }
     91
     92                tinyMCE.addEvent(window, "load", this.onLoad);
     93        },
     94
     95        onLoad : function() {
     96                var dir, i, elms, body = document.body;
     97
     98                if (tinyMCE.getWindowArg('mce_replacevariables', true))
     99                        body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
     100
     101                dir = tinyMCE.selectedInstance.settings['directionality'];
     102                if (dir == "rtl" && document.forms && document.forms.length > 0) {
     103                        elms = document.forms[0].elements;
     104                        for (i=0; i<elms.length; i++) {
     105                                if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
     106                                        elms[i].dir = dir;
     107                        }
     108                }
    121109
    122110                if (body.style.display == 'none')
    123111                        body.style.display = 'block';
    124112
    125                 // Remove margin
    126                 oldMargin = body.style.margin;
    127                 body.style.margin = '0';
    128 
    129                 // Create wrapper
    130                 wrapper = doc.createElement("div");
    131                 wrapper.id = 'mcBodyWrapper';
    132                 wrapper.style.display = 'none';
    133                 wrapper.style.margin = '0';
    134 
    135                 // Wrap body elements
    136                 nodes = doc.body.childNodes;
    137                 for (var i=nodes.length-1; i>=0; i--) {
    138                         if (wrapper.hasChildNodes())
    139                                 wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
    140                         else
    141                                 wrapper.appendChild(nodes[i].cloneNode(true));
    142 
    143                         nodes[i].parentNode.removeChild(nodes[i]);
    144                 }
    145 
    146                 // Add wrapper
    147                 doc.body.appendChild(wrapper);
    148 
    149                 // Create iframe
    150                 iframe = document.createElement("iframe");
    151                 iframe.id = "mcWinIframe";
    152                 iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
    153                 iframe.width = "100%";
    154                 iframe.height = "100%";
    155                 iframe.style.margin = '0';
    156 
    157                 // Add iframe
    158                 doc.body.appendChild(iframe);
    159 
    160                 // Measure iframe
    161                 iframe = document.getElementById('mcWinIframe');
    162                 dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
    163                 dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
    164 
    165                 // Resize window
    166                 // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
    167                 window.resizeBy(dx, dy);
    168 
    169                 // Hide iframe and show wrapper
    170                 body.style.margin = oldMargin;
    171                 iframe.style.display = 'none';
    172                 wrapper.style.display = 'block';
     113                // Execute real onload (Opera fix)
     114                if (tinyMCEPopup.onLoadEval != "")
     115                        eval(tinyMCEPopup.onLoadEval);
     116        },
     117
     118        executeOnLoad : function(str) {
     119                if (tinyMCE.isOpera)
     120                        this.onLoadEval = str;
     121                else
     122                        eval(str);
     123        },
     124
     125        resizeToInnerSize : function() {
     126                // Netscape 7.1 workaround
     127                if (this.isWindow && tinyMCE.isNS71) {
     128                        window.resizeBy(0, 10);
     129                        return;
     130                }
     131
     132                if (this.isWindow) {
     133                        var doc = document;
     134                        var body = doc.body;
     135                        var oldMargin, wrapper, iframe, nodes, dx, dy;
     136
     137                        if (body.style.display == 'none')
     138                                body.style.display = 'block';
     139
     140                        // Remove margin
     141                        oldMargin = body.style.margin;
     142                        body.style.margin = '0';
     143
     144                        // Create wrapper
     145                        wrapper = doc.createElement("div");
     146                        wrapper.id = 'mcBodyWrapper';
     147                        wrapper.style.display = 'none';
     148                        wrapper.style.margin = '0';
     149
     150                        // Wrap body elements
     151                        nodes = doc.body.childNodes;
     152                        for (var i=nodes.length-1; i>=0; i--) {
     153                                if (wrapper.hasChildNodes())
     154                                        wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
     155                                else
     156                                        wrapper.appendChild(nodes[i].cloneNode(true));
     157
     158                                nodes[i].parentNode.removeChild(nodes[i]);
     159                        }
     160
     161                        // Add wrapper
     162                        doc.body.appendChild(wrapper);
     163
     164                        // Create iframe
     165                        iframe = document.createElement("iframe");
     166                        iframe.id = "mcWinIframe";
     167                        iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
     168                        iframe.width = "100%";
     169                        iframe.height = "100%";
     170                        iframe.style.margin = '0';
     171
     172                        // Add iframe
     173                        doc.body.appendChild(iframe);
     174
     175                        // Measure iframe
     176                        iframe = document.getElementById('mcWinIframe');
     177                        dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
     178                        dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
     179
     180                        // Resize window
     181                        // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
     182                        window.resizeBy(dx, dy);
     183
     184                        // Hide iframe and show wrapper
     185                        body.style.margin = oldMargin;
     186                        iframe.style.display = 'none';
     187                        wrapper.style.display = 'block';
     188                }
     189        },
     190
     191        resizeToContent : function() {
     192                var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
     193                var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
     194
     195                if (isOpera)
     196                        return;
     197
     198                if (isMSIE) {
     199                        try { window.resizeTo(10, 10); } catch (e) {}
     200
     201                        var elm = document.body;
     202                        var width = elm.offsetWidth;
     203                        var height = elm.offsetHeight;
     204                        var dx = (elm.scrollWidth - width) + 4;
     205                        var dy = elm.scrollHeight - height;
     206
     207                        try { window.resizeBy(dx, dy); } catch (e) {}
     208                } else {
     209                        window.scrollBy(1000, 1000);
     210                        if (window.scrollX > 0 || window.scrollY > 0) {
     211                                window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
     212                                window.sizeToContent();
     213                                window.scrollTo(0, 0);
     214                                var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
     215                                var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
     216                                window.moveTo(x, y);
     217                        }
     218                }
     219        },
     220
     221        getWindowArg : function(name, default_value) {
     222                return tinyMCE.getWindowArg(name, default_value);
     223        },
     224
     225        restoreSelection : function() {
     226                if (this.storeSelection) {
     227                        var inst = tinyMCE.selectedInstance;
     228
     229                        inst.getWin().focus();
     230
     231                        if (inst.selectionBookmark)
     232                                inst.selection.moveToBookmark(inst.selectionBookmark);
     233                }
     234        },
     235
     236        execCommand : function(command, user_interface, value) {
     237                var inst = tinyMCE.selectedInstance;
     238
     239                this.restoreSelection();
     240                inst.execCommand(command, user_interface, value);
     241
     242                // Store selection
     243                if (this.storeSelection)
     244                        inst.selectionBookmark = inst.selection.getBookmark(true);
     245        },
     246
     247        close : function() {
     248                tinyMCE.closeWindow(window);
     249        },
     250
     251        pickColor : function(e, element_id) {
     252                tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
     253                        element_id : element_id,
     254                        document : document,
     255                        window : window,
     256                        store_selection : false
     257                });
     258        },
     259
     260        openBrowser : function(element_id, type, option) {
     261                var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
     262                var url = document.getElementById(element_id).value;
     263
     264                tinyMCE.setWindowArg("window", window);
     265                tinyMCE.setWindowArg("document", document);
     266
     267                // Call to external callback
     268                if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
     269                        alert("Callback function: " + cb + " could not be found.");
     270                else
     271                        eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
     272        },
     273
     274        importClass : function(c) {
     275                window[c] = function() {};
     276
     277                for (var n in window.opener[c].prototype)
     278                        window[c].prototype[n] = window.opener[c].prototype[n];
     279
     280                window[c].constructor = window.opener[c].constructor;
    173281        }
    174 };
    175 
    176 
    177 TinyMCE_Popup.prototype.resizeToContent = function() {
    178         var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
    179         var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
    180 
    181         if (isOpera)
    182                 return;
    183 
    184         if (isMSIE) {
    185                 try { window.resizeTo(10, 10); } catch (e) {}
    186 
    187                 var elm = document.body;
    188                 var width = elm.offsetWidth;
    189                 var height = elm.offsetHeight;
    190                 var dx = (elm.scrollWidth - width) + 4;
    191                 var dy = elm.scrollHeight - height;
    192 
    193                 try { window.resizeBy(dx, dy); } catch (e) {}
    194         } else {
    195                 window.scrollBy(1000, 1000);
    196                 if (window.scrollX > 0 || window.scrollY > 0) {
    197                         window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
    198                         window.sizeToContent();
    199                         window.scrollTo(0, 0);
    200                         var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
    201                         var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
    202                         window.moveTo(x, y);
    203                 }
    204         }
    205 };
    206 
    207 
    208 TinyMCE_Popup.prototype.getWindowArg = function(name, default_value) {
    209         return tinyMCE.getWindowArg(name, default_value);
    210 };
    211 
    212 
    213 TinyMCE_Popup.prototype.restoreSelection = function() {
    214         if (this.storeSelection) {
    215                 var inst = tinyMCE.selectedInstance;
    216 
    217                 inst.getWin().focus();
    218 
    219                 if (inst.selectionBookmark)
    220                         inst.selection.moveToBookmark(inst.selectionBookmark);
    221         }
    222 };
    223 
    224 
    225 TinyMCE_Popup.prototype.execCommand = function(command, user_interface, value) {
    226         var inst = tinyMCE.selectedInstance;
    227 
    228         this.restoreSelection();
    229         inst.execCommand(command, user_interface, value);
    230 
    231         // Store selection
    232         if (this.storeSelection)
    233                 inst.selectionBookmark = inst.selection.getBookmark(true);
    234 };
    235 
    236 
    237 TinyMCE_Popup.prototype.close = function() {
    238         tinyMCE.closeWindow(window);
    239 };
    240 
    241 
    242 TinyMCE_Popup.prototype.pickColor = function(e, element_id) {
    243         tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
    244                 element_id : element_id,
    245                 document : document,
    246                 window : window,
    247                 store_selection : false
    248         });
    249 };
    250 
    251 
    252 TinyMCE_Popup.prototype.openBrowser = function(element_id, type, option) {
    253         var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
    254         var url = document.getElementById(element_id).value;
    255 
    256         tinyMCE.setWindowArg("window", window);
    257         tinyMCE.setWindowArg("document", document);
    258 
    259         // Call to external callback
    260         if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
    261                 alert("Callback function: " + cb + " could not be found.");
    262         else
    263                 eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
    264 };
    265 
    266 TinyMCE_Popup.prototype.importClass = function(c) {
    267         window[c] = function() {};
    268 
    269         for (var n in window.opener[c].prototype)
    270                 window[c].prototype[n] = window.opener[c].prototype[n];
    271 
    272         window[c].constructor = window.opener[c].constructor;
    273 };
     282
     283        };
    274284
    275285// Setup global instance
  • trunk/wp-includes/js/tinymce/utils/form_utils.js

    r3664 r4506  
    11/**
    2  * $RCSfile: form_utils.js,v $
    3  * $Revision: 1.10 $
    4  * $Date: 2006/03/22 12:21:24 $
     2 * $Id: form_utils.js 43 2006-08-08 16:10:07Z spocke $
    53 *
    64 * Various form utilitiy functions.
    … …  
    108 */
    119
     10var themeBaseURL = tinyMCE.baseURL + '/themes/' + tinyMCE.getParam("theme");
     11
    1212function getColorPickerHTML(id, target_form_element) {
    13         var html = "";
    14 
    15         html += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">';
    16         html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/color.gif"';
    17         html += ' onmouseover="this.className=\'mceButtonOver\'"';
    18         html += ' onmouseout="this.className=\'mceButtonNormal\'"';
    19         html += ' onmousedown="this.className=\'mceButtonDown\'"';
    20         html += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
    21         html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
    22 
    23         return html;
     13        var h = "";
     14
     15        h += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">';
     16        h += '<img id="' + id + '" src="' + themeBaseURL + '/images/color.gif"';
     17        h += ' onmouseover="this.className=\'mceButtonOver\'"';
     18        h += ' onmouseout="this.className=\'mceButtonNormal\'"';
     19        h += ' onmousedown="this.className=\'mceButtonDown\'"';
     20        h += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
     21        h += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
     22
     23        return h;
    2424}
    2525
    … …  
    5858
    5959        html += '<a id="' + id + '_link" href="javascript:openBrower(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';
    60         html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/browse.gif"';
     60        html += '<img id="' + id + '" src="' + themeBaseURL + '/images/browse.gif"';
    6161        html += ' onmouseover="this.className=\'mceButtonOver\';"';
    6262        html += ' onmouseout="this.className=\'mceButtonNormal\';"';
    … …  
    9393
    9494        if (!found && add_custom && value != '') {
    95                 var option = new Option('Value: ' + value, value);
     95                var option = new Option(value, value);
    9696                option.selected = true;
    9797                sel.options[sel.options.length] = option;
     98                sel.selectedIndex = sel.options.length - 1;
    9899        }
    99100
  • trunk/wp-includes/js/tinymce/utils/mclayer.js

    r3664 r4506  
    11/**
    2  * $RCSfile: mclayer.js,v $
    3  * $Revision: 1.2 $
    4  * $Date: 2006/02/06 20:11:09 $
     2 * $Id: mclayer.js 18 2006-06-29 14:11:23Z spocke $
    53 *
    64 * Moxiecode floating layer script.
  • trunk/wp-includes/js/tinymce/utils/mctabs.js

    r3664 r4506  
    11/**
    2  * $RCSfile: mctabs.js,v $
    3  * $Revision: 1.2 $
    4  * $Date: 2006/02/06 20:11:09 $
     2 * $Id: mctabs.js 18 2006-06-29 14:11:23Z spocke $
    53 *
    64 * Moxiecode DHTML Tabs script.
  • trunk/wp-includes/js/tinymce/utils/validate.js

    r3664 r4506  
    11/**
    2  * $RCSfile: validate.js,v $
    3  * $Revision: 1.3 $
    4  * $Date: 2006/02/06 20:11:09 $
     2 * $Id: validate.js 65 2006-08-24 15:54:55Z spocke $
    53 *
    64 * Various form validation methods.
    … …  
    108 */
    119
    12 function testRegExp(form_name, element_name, re) {
    13         return new RegExp(re).test(document.forms[form_name].elements[element_name].value);
    14 }
    15 
    16 function validateString(form_name, element_name) {
    17         return (document.forms[form_name].elements[element_name].value.length > 0);
    18 }
    19 
    20 function validateSelection(form_name, element_name) {
    21         return (document.forms[form_name].elements[element_name].selectedIndex > 0);
    22 }
    23 
    24 function validateCheckBox(form_name, element_name) {
    25         return document.forms[form_name].elements[element_name].checked;
    26 }
    27 
    28 function validateCleanString(form_name, element_name) {
    29         return testRegExp(form_name, element_name, '^[A-Za-z0-9_]+$');
    30 }
    31 
    32 function validateEmail(form_name, element_name) {
    33         return testRegExp(form_name, element_name, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
    34 }
    35 
    36 function validateAbsUrl(form_name, element_name) {
    37         return testRegExp(form_name, element_name, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+$');
    38 }
    39 
    40 function validateNumber(form_name, element_name, allow_blank) {
    41         return (!allow_blank && value == '') ? false : testRegExp(form_name, element_name, '^-?[0-9]*\\.?[0-9]*$');
    42 }
    43 
    44 function validateSize(form_name, element_name,) {
    45         return testRegExp(form_name, element_name, '^[0-9]+(px|%)?$');
    46 }
    47 
    48 function validateID(form_name, element_name,) {
    49         return testRegExp(form_name, element_name, '^[A-Za-z_]([A-Za-z0-9_])*$');
    50 }
     10/**
     11        // String validation:
     12
     13        if (!Validator.isEmail('myemail'))
     14                alert('Invalid email.');
     15
     16        // Form validation:
     17
     18        var f = document.forms['myform'];
     19
     20        if (!Validator.isEmail(f.myemail))
     21                alert('Invalid email.');
     22*/
     23
     24var Validator = {
     25        isEmail : function(s) {
     26                return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
     27        },
     28
     29        isAbsUrl : function(s) {
     30                return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
     31        },
     32
     33        isSize : function(s) {
     34                return this.test(s, '^[0-9]+(px|%)?$');
     35        },
     36
     37        isId : function(s) {
     38                return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
     39        },
     40
     41        isEmpty : function(s) {
     42                var nl, i;
     43
     44                if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
     45                        return true;
     46
     47                if (s.type == 'checkbox' && !s.checked)
     48                        return true;
     49
     50                if (s.type == 'radio') {
     51                        for (i=0, nl = s.form.elements; i<nl.length; i++) {
     52                                if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
     53                                        return false;
     54                        }
     55
     56                        return true;
     57                }
     58
     59                return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
     60        },
     61
     62        isNumber : function(s, d) {
     63                return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
     64        },
     65
     66        test : function(s, p) {
     67                s = s.nodeType == 1 ? s.value : s;
     68
     69                return s == '' || new RegExp(p).test(s);
     70        }
     71};
     72
     73var AutoValidator = {
     74        settings : {
     75                id_cls : 'id',
     76                int_cls : 'int',
     77                url_cls : 'url',
     78                number_cls : 'number',
     79                email_cls : 'email',
     80                size_cls : 'size',
     81                required_cls : 'required',
     82                invalid_cls : 'invalid',
     83                min_cls : 'min',
     84                max_cls : 'max'
     85        },
     86
     87        init : function(s) {
     88                var n;
     89
     90                for (n in s)
     91                        this.settings[n] = s[n];
     92        },
     93
     94        validate : function(f) {
     95                var i, nl, s = this.settings, c = 0;
     96
     97                nl = this.tags(f, 'label');
     98                for (i=0; i<nl.length; i++)
     99                        this.removeClass(nl[i], s.invalid_cls);
     100
     101                c += this.validateElms(f, 'input');
     102                c += this.validateElms(f, 'select');
     103                c += this.validateElms(f, 'textarea');
     104
     105                return c == 3;
     106        },
     107
     108        invalidate : function(n) {
     109                this.mark(n.form, n);
     110        },
     111
     112        reset : function(e) {
     113                var t = new Array('label', 'input', 'select', 'textarea');
     114                var i, j, nl, s = this.settings;
     115
     116                if (e == null)
     117                        return;
     118
     119                for (i=0; i<t.length; i++) {
     120                        nl = this.tags(e.form ? e.form : e, t[i]);
     121                        for (j=0; j<nl.length; j++)
     122                                this.removeClass(nl[j], s.invalid_cls);
     123                }
     124        },
     125
     126        validateElms : function(f, e) {
     127                var nl, i, n, s = this.settings, st = true, va = Validator, v;
     128
     129                nl = this.tags(f, e);
     130                for (i=0; i<nl.length; i++) {
     131                        n = nl[i];
     132
     133                        this.removeClass(n, s.invalid_cls);
     134
     135                        if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
     136                                st = this.mark(f, n);
     137
     138                        if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
     139                                st = this.mark(f, n);
     140
     141                        if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
     142                                st = this.mark(f, n);
     143
     144                        if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
     145                                st = this.mark(f, n);
     146
     147                        if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
     148                                st = this.mark(f, n);
     149
     150                        if (this.hasClass(n, s.size_cls) && !va.isSize(n))
     151                                st = this.mark(f, n);
     152
     153                        if (this.hasClass(n, s.id_cls) && !va.isId(n))
     154                                st = this.mark(f, n);
     155
     156                        if (this.hasClass(n, s.min_cls, true)) {
     157                                v = this.getNum(n, s.min_cls);
     158
     159                                if (isNaN(v) || parseInt(n.value) < parseInt(v))
     160                                        st = this.mark(f, n);
     161                        }
     162
     163                        if (this.hasClass(n, s.max_cls, true)) {
     164                                v = this.getNum(n, s.max_cls);
     165
     166                                if (isNaN(v) || parseInt(n.value) > parseInt(v))
     167                                        st = this.mark(f, n);
     168                        }
     169                }
     170
     171                return st;
     172        },
     173
     174        hasClass : function(n, c, d) {
     175                return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
     176        },
     177
     178        getNum : function(n, c) {
     179                c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
     180                c = c.replace(/[^0-9]/g, '');
     181
     182                return c;
     183        },
     184
     185        addClass : function(n, c, b) {
     186                var o = this.removeClass(n, c);
     187                n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
     188        },
     189
     190        removeClass : function(n, c) {
     191                c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
     192                return n.className = c != ' ' ? c : '';
     193        },
     194
     195        tags : function(f, s) {
     196                return f.getElementsByTagName(s);
     197        },
     198
     199        mark : function(f, n) {
     200                var s = this.settings;
     201
     202                this.addClass(n, s.invalid_cls);
     203                this.markLabels(f, n, s.invalid_cls);
     204
     205                return false;
     206        },
     207
     208        markLabels : function(f, n, ic) {
     209                var nl, i;
     210
     211                nl = this.tags(f, "label");
     212                for (i=0; i<nl.length; i++) {
     213                        if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
     214                                this.addClass(nl[i], ic);
     215                }
     216
     217                return null;
     218        }
     219};
  • trunk/wp-includes/script-loader.php

    r4495 r4506  
    1616                $this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3517' );
    1717                $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
    18                 $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '09212006' );
    19                 $this->add( 'wp_tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('tiny_mce'), '09212006' );
     18                $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20061113' );
     19                $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
     20                $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061113' );
    2021                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
    2122                $this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4206');
Note: See TracChangeset for help on using the changeset viewer.