WordPress.org

Make WordPress Core

Changeset 3283


Ignore:
Timestamp:
12/09/2005 07:24:14 PM (14 years ago)
Author:
ryan
Message:

MCE fix-em-ups from skeltoac. fixes #1962

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-functions.php

    r3276 r3283  
    10781078    // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
    10791079    if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari'))
    1080         : echo '
    1081             <div id="quicktags">
     1080        echo '
     1081        <div id="quicktags">
    10821082            <script src="../wp-includes/js/quicktags.js" type="text/javascript"></script>
    1083             <script type="text/javascript">edToolbar();</script>
    1084         ';
    1085     echo '</div>';
    1086     endif;
     1083            <script type="text/javascript">if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) edToolbar();</script>
     1084        </div>
     1085';
     1086    else echo '
     1087<script type="text/javascript">
     1088function edInsertContent(myField, myValue) {
     1089    //IE support
     1090    if (document.selection) {
     1091        myField.focus();
     1092        sel = document.selection.createRange();
     1093        sel.text = myValue;
     1094        myField.focus();
     1095    }
     1096    //MOZILLA/NETSCAPE support
     1097    else if (myField.selectionStart || myField.selectionStart == "0") {
     1098        var startPos = myField.selectionStart;
     1099        var endPos = myField.selectionEnd;
     1100        myField.value = myField.value.substring(0, startPos)
     1101                      + myValue
     1102                      + myField.value.substring(endPos, myField.value.length);
     1103        myField.focus();
     1104        myField.selectionStart = startPos + myValue.length;
     1105        myField.selectionEnd = startPos + myValue.length;
     1106    } else {
     1107        myField.value += myValue;
     1108        myField.focus();
     1109    }
     1110}
     1111</script>
     1112';
    10871113}
    10881114
     
    18021828}
    18031829
     1830function user_can_richedit() {
     1831    if ( 'true' != get_user_option('rich_editing') )
     1832        return false;
     1833
     1834    if ( preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
     1835        return false;
     1836
     1837    return true; // Best guess
     1838}
     1839
    18041840?>
  • trunk/wp-admin/admin-header.php

    r3265 r3283  
    8080<script type="text/javascript" src="list-manipulation.js"></script>
    8181<?php if ( isset( $editing ) ) : ?>
    82 <?php if ( $editing && 'true' == get_user_option('rich_editing') ) :
     82<?php if ( $editing && user_can_richedit() ) :
    8383$mce_plugins = apply_filters('mce_plugins', array('wordpress', 'autosave', 'wphelp'));
    8484$mce_plugins = implode($mce_plugins, ',');
    8585$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'emotions', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp'));
    8686$mce_buttons = implode($mce_buttons, ',');
     87$mce_buttons_2 = apply_filters('mce_buttons_2', array());
     88$mce_buttons_2 = implode($mce_buttons_2, ',');
    8789?>
    8890<script language="javascript" type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?index=0&theme=advanced&plugins=<?php echo $mce_plugins; ?>"></script>
     
    9496    theme : "advanced",
    9597    theme_advanced_buttons1 : "<?php echo $mce_buttons; ?>",
    96     theme_advanced_buttons2 : "",
     98    theme_advanced_buttons2 : "<?php echo $mce_buttons_2; ?>",
    9799    theme_advanced_buttons3 : "",
    98100    theme_advanced_toolbar_location : "top",
     
    111113    remove_linebreaks : true,
    112114    save_callback : "wp_save_callback",
    113     valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],thead[class|rowspan|width|height|align|valign|dir],tr[class|rowspan|width|height|align|valign|dir],th[dir|class|colspan|rowspan|width|height|align|valign|scope],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
     115<?php if (current_user_can('unfiltered_html') == false) : ?>
     116valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],thead[class|rowspan|width|height|align|valign|dir],tr[class|rowspan|width|height|align|valign|dir],th[dir|class|colspan|rowspan|width|height|align|valign|scope],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
     117<?php endif; ?>
    114118    plugins : "<?php echo $mce_plugins; ?>"
    115119    <?php do_action('mce_options'); ?>
     
    152156 
    153157function newCatAddIn() {
     158    if ( !document.getElementById('jaxcat') ) return false;
    154159    var ajaxcat = document.createElement('p');
    155160    ajaxcat.id = 'ajaxcat';
  • trunk/wp-admin/edit-form-advanced.php

    r3268 r3283  
    77<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    88<?php endif; ?>
    9 
    10 <?php $richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true; ?>
    119
    1210<form name="post" action="post.php" method="post" id="post">
     
    140138</fieldset>
    141139
    142 <fieldset id="<?php echo $richedit ? 'postdivrich' : 'postdiv'; ?>">
     140<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
    143141<legend><?php _e('Post') ?></legend>
    144142
     
    149147 }
    150148?>
    151 <?php if ( !$richedit ) the_quicktags(); ?>
    152 
    153 <div><textarea <?php if ( $richedit ) echo 'title="true"'; ?> rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo $richedit ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
    154 </fieldset>
    155 
    156 <?php if ( !$richedit ) : ?>
     149<?php the_quicktags(); ?>
     150
     151<div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
     152</fieldset>
     153
    157154<script type="text/javascript">
    158155<!--
    159156edCanvas = document.getElementById('content');
    160 //-->
    161 </script>
    162 <?php else : ?>
    163 <script type="text/javascript">
    164 <!--
     157<?php if ( user_can_richedit() ) : ?>
    165158// This code is meant to allow tabbing from Title to Post (TinyMCE).
    166159if ( tinyMCE.isMSIE )
     
    194187            }
    195188        }
    196 
     189<?php endif; ?>
    197190//-->
    198191</script>
    199 <?php endif; ?>
    200192
    201193<?php echo $form_pingback ?>
  • trunk/wp-admin/edit-form-comment.php

    r3275 r3283  
    55$form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='".$comment->comment_post_ID;
    66?>
    7 <?php $richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true; ?>
    87
    98<form name="post" action="post.php" method="post" id="post">
     
    3332        <legend><?php _e('URI:') ?></legend>
    3433        <div>
    35           <input type="text" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
     34          <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
    3635    </div>
    3736</fieldset>
     
    3938<fieldset style="clear: both;">
    4039        <legend><?php _e('Comment') ?></legend>
    41 <?php if ( !$richedit ) the_quicktags(); ?>
     40<?php the_quicktags(); ?>
    4241
    4342<?php
     
    4746 }
    4847?>
    49 <div><textarea <?php if ( $richedit ) echo 'title="true"'; ?> rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content" style="width: 99%"><?php echo $richedit ? wp_richedit_pre($comment->comment_content) : $comment->comment_content; ?></textarea></div>
     48<div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content" style="width: 99%"><?php echo user_can_richedit() ? wp_richedit_pre($comment->comment_content) : $comment->comment_content; ?></textarea></div>
    5049</fieldset>
    5150
    52 <?php if ( !$richedit ) : ?>
    5351<script type="text/javascript">
    5452<!--
    5553edCanvas = document.getElementById('content');
     54<?php if ( user_can_richedit() ) : ?>
     55// This code is meant to allow tabbing from Author URL to Post (TinyMCE).
     56if ( tinyMCE.isMSIE )
     57    document.getElementById('newcomment_author_url').onkeydown = function (e)
     58        {
     59            e = e ? e : window.event;
     60            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
     61                var i = tinyMCE.selectedInstance;
     62                if(typeof i ==  'undefined')
     63                    return true;
     64                                tinyMCE.execCommand("mceStartTyping");
     65                this.blur();
     66                i.contentWindow.focus();
     67                e.returnValue = false;
     68                return false;
     69            }
     70        }
     71else
     72    document.getElementById('newcomment_author_url').onkeypress = function (e)
     73        {
     74            e = e ? e : window.event;
     75            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
     76                var i = tinyMCE.selectedInstance;
     77                if(typeof i ==  'undefined')
     78                    return true;
     79                                tinyMCE.execCommand("mceStartTyping");
     80                this.blur();
     81                i.contentWindow.focus();
     82                e.returnValue = false;
     83                return false;
     84            }
     85        }
     86<?php endif; ?>
    5687//-->
    5788</script>
    58 <?php endif; ?>
    5989
    6090<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
  • trunk/wp-admin/edit-page-form.php

    r3149 r3283  
    2020
    2121?>
    22 
    23 <?php $richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true; ?>
    2422
    2523<form name="post" action="post.php" method="post" id="post">
     
    120118
    121119
    122 <fieldset id="<?php echo ( $richedit) ? 'postdivrich' : 'postdiv'; ?>">
     120<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
    123121    <legend><?php _e('Page Content') ?></legend>
    124122<?php
     
    128126 }
    129127?>
    130 <?php if (! $richedit ) the_quicktags(); ?>
    131 
    132 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $richedit ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
    133 </fieldset>
    134 
    135 <?php if ( !$richedit ) : ?>
     128<?php the_quicktags(); ?>
     129
     130<div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
     131</fieldset>
     132
    136133<script type="text/javascript">
    137134<!--
    138135edCanvas = document.getElementById('content');
     136<?php if ( user_can_richedit() ) : ?>
     137// This code is meant to allow tabbing from Title to Post (TinyMCE).
     138if ( tinyMCE.isMSIE )
     139    document.getElementById('title').onkeydown = function (e)
     140        {
     141            e = e ? e : window.event;
     142            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
     143                var i = tinyMCE.selectedInstance;
     144                if(typeof i ==  'undefined')
     145                    return true;
     146                                tinyMCE.execCommand("mceStartTyping");
     147                this.blur();
     148                i.contentWindow.focus();
     149                e.returnValue = false;
     150                return false;
     151            }
     152        }
     153else
     154    document.getElementById('title').onkeypress = function (e)
     155        {
     156            e = e ? e : window.event;
     157            if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
     158                var i = tinyMCE.selectedInstance;
     159                if(typeof i ==  'undefined')
     160                    return true;
     161                                tinyMCE.execCommand("mceStartTyping");
     162                this.blur();
     163                i.contentWindow.focus();
     164                e.returnValue = false;
     165                return false;
     166            }
     167        }
     168<?php endif; ?>
    139169//-->
    140170</script>
    141 <?php endif; ?>
    142171
    143172<p class="submit">
  • trunk/wp-admin/inline-uploading.php

    r3263 r3283  
    151151$uwidth_sum = 0;
    152152$html = '';
     153$popups = '';
    153154$style = '';
    154155$script = '';
     
    163164    $__using_original = __('Using Original');
    164165    $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>';
     166    $__send_to_editor = __('Send to editor');
    165167    $__close = __('Close Options');
    166168    $__confirmdelete = __('Delete this file from the server?');
     
    191193        }
    192194        $attachment = array_merge($attachment, $meta);
    193         $delete_cancel = "<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
     195        $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
     196<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
    194197        <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
    195198";
     
    220223";
    221224            $html .= "<div id='target{$ID}' class='attwrap left'>
    222     <div id='popup{$ID}' class='popup'>
    223         <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
    224         <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
    225         {$delete_cancel}
    226     </div>
    227225    <div id='div{$ID}' class='imagewrap' onclick=\"doPopup({$ID});\">
    228226        <img id=\"image{$ID}\" src=\"$src\" alt=\"{$image['post_title']}\" $height_width />
     
    230228</div>
    231229";
     230            $popups .= "<div id='popup{$ID}' class='popup'>
     231    <a id=\"I{$ID}\" onclick=\"if($thumb)toggleImage({$ID});else alert('$__nothumb');return false;\" href=\"javascript:void()\">$thumbtext</a>
     232    <a id=\"L{$ID}\" onclick=\"toggleLink({$ID});return false;\" href=\"javascript:void()\">$__not_linked</a>
     233    {$send_delete_cancel}
     234</div>
     235";
    232236        } else {
    233             $script .= "a{$ID}a = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>';
    234 a{$ID}b = '<a id=\"{$ID}\" href=\"{$attachment['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>';
     237            $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>';
     238ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$attachment['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>';
    235239";
    236240            $html .= "<div id='target{$ID}' class='attwrap left'>
    237     <div id='popup{$ID}' class='popup'>
    238         <div class='filetype'>File Type: ".str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
    239         <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
    240         {$delete_cancel}
    241     </div>
    242241    <div id='div{$ID}' class='otherwrap' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">
    243242        <a id=\"{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$attachment['post_title']}</a>
    244243    </div>
     244</div>
     245";
     246            $popups .= "<div id='popup{$ID}' class='popup'>
     247    <div class='filetype'>File Type: ".str_replace('/',"/\n",$attachment['post_mime_type'])."</div>
     248    <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a>
     249    {$send_delete_cancel}
    245250</div>
    246251";
     
    279284    popup = document.getElementById('popup'+i);
    280285    popup.style.left = (target.offsetLeft) + 'px';
     286    popup.style.top = (target.offsetTop) + 'px';
    281287    popup.style.display = 'block';
    282288}
    283 function init() {
    284     popup = false;
    285 }
     289popup = false;
    286290function selectLink(n) {
    287291    o=document.getElementById('div'+n);
     292    if ( typeof document.body.createTextRange == 'undefined' || typeof win.tinyMCE == 'undefined' || win.tinyMCE.configs.length < 1 )
     293        return;
    288294    r = document.body.createTextRange();
    289295    if ( typeof r != 'undefined' ) {
     
    334340    }
    335341}
     342
     343var win = window.opener ? window.opener : window.dialogArguments;
     344if (!win) win = top;
     345tinyMCE = win.tinyMCE;
     346richedit = ( typeof tinyMCE == 'object' && tinyMCE.configs.length > 0 );
     347function sendToEditor(n) {
     348    o = document.getElementById('div'+n);
     349    h = o.innerHTML.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // Trim
     350    h = h.replace(new RegExp(' (class|title|width|height|id|onclick|onmousedown)=([^\'"][^ ]*)( |/|>)', 'g'), ' $1="$2"$3'); // Enclose attribs in quotes
     351    h = h.replace(new RegExp(' on(click|mousedown)="[^"]*"', 'g'), ''); // Drop menu events
     352    h = h.replace(new RegExp('<(/?)A', 'g'), '<$1a'); // Lowercase tagnames
     353    h = h.replace(new RegExp('<IMG', 'g'), '<img'); // Lowercase again
     354    h = h.replace(new RegExp('(<img .+?")>', 'g'), '$1 />'); // XHTML
     355    if ( richedit )
     356        win.tinyMCE.execCommand('mceInsertContent', false, h);
     357    else
     358        win.edInsertContent(win.edCanvas, h);
     359}
    336360</script>
    337361<style type="text/css">
     
    352376}
    353377#images {
     378    position: absolute;
    354379    clear: both;
    355380    margin: 0px;
    356     padding: 3px 15px;
     381    padding: 15px 15px;
    357382    height: 96px;
    358383/*  white-space: nowrap;*/
     
    493518</style>
    494519</head>
    495 <body onload="init()">
     520<body>
    496521<ul id="upload-menu">
    497522<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__); ?>?action=upload&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>"><?php _e('Upload'); ?></a></li>
     
    522547<?php if ( $action == 'view' ) : ?>
    523548<div id="wrap">
    524 <div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>
     549<!--<div class="tip"><?php _e('You can drag and drop these items into your post. Click on one for more options.'); ?></div>-->
    525550<div id="images">
    526551<?php echo $html; ?>
     552<?php echo $popups; ?>
    527553</div>
    528554</div>
  • trunk/wp-admin/wp-admin.css

    r3282 r3283  
    22    height: 100%; /* kill peekaboo bug in IE */
    33}
    4 
     4body {
     5    border: none;
     6}
    57a {
    68    border-bottom: 1px solid #69c;
  • trunk/wp-includes/js/tinymce/tiny_mce.js

    r3276 r3283  
    55275527            var insertHTMLFailed = false;
    55285528            this.getWin().focus();
    5529 
     5529/* WP
    55305530            if (tinyMCE.isGecko || tinyMCE.isOpera) {
    55315531                try {
     
    55615561                }
    55625562            }
    5563 
     5563*/
    55645564            // Ugly hack in Opera due to non working "inserthtml"
    55655565            if (tinyMCE.isOpera && insertHTMLFailed) {
Note: See TracChangeset for help on using the changeset viewer.