HTML mode for Distraction Free Writing, props koopersmith, see #17136

git-svn-id: http://svn.automattic.com/wordpress/trunk@17785 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-05-02 08:10:23 +00:00
parent 2081fd0504
commit 1ffb2468a5
14 changed files with 521 additions and 185 deletions

File diff suppressed because one or more lines are too long

View File

@ -589,7 +589,8 @@ form.upgrade .hint {
filter: inherit; filter: inherit;
} }
.fullscreen-active .fullscreen-overlay { .fullscreen-active .fullscreen-overlay,
.fullscreen-active #wp-fullscreen-body {
display: block; display: block;
} }
@ -613,7 +614,7 @@ form.upgrade .hint {
} }
#wp-fullscreen-wrap { #wp-fullscreen-wrap {
margin: 75px auto 50px; margin: 60px auto 50px;
position: relative; position: relative;
} }
@ -627,7 +628,7 @@ form.upgrade .hint {
} }
#wp-fullscreen-container { #wp-fullscreen-container {
padding: 4px 9px; padding: 4px 10px;
} }
#wp-fullscreen-title, #wp-fullscreen-title,
@ -657,6 +658,12 @@ form.upgrade .hint {
width: 100%; width: 100%;
min-height: 300px; min-height: 300px;
border: 0; border: 0;
background: transparent;
line-height: 1.6em;
padding: 0;
overflow-y: hidden;
outline: none;
resize: none;
} }
/* =Top bar /* =Top bar
@ -671,26 +678,32 @@ form.upgrade .hint {
border-bottom: 1px solid #C6C6C6; border-bottom: 1px solid #C6C6C6;
min-width: 800px; min-width: 800px;
width: 100%; width: 100%;
height: 62px; height: 40px;
background: #d9d9d9; background-color: #d9d9d9;
background: -moz-linear-gradient(bottom, #d7d7d7, #e4e4e4); background-image: -moz-linear-gradient(bottom, #d7d7d7, #e4e4e4);
background: -webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4)); background-image: -webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
} }
#wp-fullscreen-toolbar { #wp-fullscreen-toolbar {
padding: 6px 12px 0; padding: 6px 2% 0;
clear: both; clear: both;
} }
#wp-fullscreen-mode-bar,
#wp-fullscreen-button-bar,
#wp-fullscreen-close { #wp-fullscreen-close {
float: left; float: left;
} }
#wp-fullscreen-save, #wp-fullscreen-save,
#wp-fullscreen-buttons #wp-fullscreen-count { #wp-fullscreen-count {
float: right; float: right;
} }
#wp-fullscreen-save {
padding-top: 2px;
}
#wp-fullscreen-count, #wp-fullscreen-count,
#wp-fullscreen-close { #wp-fullscreen-close {
padding-top: 5px; padding-top: 5px;
@ -699,9 +712,11 @@ form.upgrade .hint {
#wp-fullscreen-info { #wp-fullscreen-info {
float: right; float: right;
padding: 3px 10px; padding: 3px 10px;
display: none;
} }
#wp-fullscreen-buttons { #wp-fullscreen-central-toolbar {
margin: auto; margin: auto;
padding: 0; padding: 0;
} }
@ -710,6 +725,92 @@ form.upgrade .hint {
float: left; float: left;
} }
#wp-fullscreen-mode-bar {
padding: 1px 14px 0 0;
}
#wp-fullscreen-modes a {
display: block;
font-size: 11px;
text-decoration: none;
float: left;
margin: 1px 0 0 0;
padding: 2px 6px 2px;
border-width: 1px 1px 1px 0;
border-style: solid;
border-color: #bbb;
color: #777;
text-shadow: 0 1px 0 #fff;
background-color: #f4f4f4;
background-image: -moz-linear-gradient(bottom, #e4e4e4, #f9f9f9);
background-image: -webkit-gradient(linear, left bottom, left top, from(#e4e4e4), to(#f9f9f9));
}
#wp-fullscreen-modes a:hover,
.wp-html-mode #wp-fullscreen-modes a:last-child,
.wp-tmce-mode #wp-fullscreen-modes a:first-child {
color: #333;
border-color: #999;
background-color: #eee;
background-image: -moz-linear-gradient(bottom, #f9f9f9, #e0e0e0);
background-image: -webkit-gradient(linear, left bottom, left top, from(#f9f9f9), to(#e0e0e0));
}
#wp-fullscreen-modes a:first-child {
border-width: 1px;
-moz-border-radius: 4px 0 0 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-khtml-border-top-left-radius: 4px;
-khtml-border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
#wp-fullscreen-modes a:last-child {
-moz-border-radius: 0 4px 4px 0;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
-khtml-border-top-right-radius: 4px;
-khtml-border-bottom-right-radius: 4px;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
#wp-fullscreen-buttons .active a {
background: inherit;
}
#wp-fullscreen-buttons .hidden {
display: none;
}
#wp-fullscreen-buttons .disabled {
opacity: 0.5;
}
.wp-html-mode #wp-fullscreen-buttons div {
display: none;
}
.wp-html-mode #wp-fullscreen-buttons div.wp-fullscreen-both {
display: block;
}
#fullscreen-topbar.fullscreen-make-sticky {
display: block !important;
}
#wp-fullscreen-save img {
vertical-align: middle;
}
#wp-fullscreen-save img,
#wp-fullscreen-save span {
padding-right: 4px;
display: none;
}
/* =Thickbox Adjustments /* =Thickbox Adjustments
-------------------------------------------------------------- */ -------------------------------------------------------------- */
.fullscreen-active #TB_overlay { .fullscreen-active #TB_overlay {

View File

@ -1647,7 +1647,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
$mce_options = rtrim( trim($mce_options), '\n\r,' ); $mce_options = rtrim( trim($mce_options), '\n\r,' );
wp_print_scripts('editor'); ?> do_action('before_wp_tiny_mce', $initArray); ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
@ -1688,11 +1688,12 @@ tinyMCE.init(tinyMCEPreInit.mceInit);
</script> </script>
<?php <?php
do_action('tiny_mce_preload_dialogs', $plugins); do_action('after_wp_tiny_mce', $initArray);
} }
// Load additional inline scripts based on active plugins. // Load additional inline scripts based on active plugins.
function wp_preload_dialogs($plugins) { function wp_preload_dialogs($init) {
$plugins = (array) $init['plugins'];
if ( in_array( 'wpdialogs', $plugins, true ) ) { if ( in_array( 'wpdialogs', $plugins, true ) ) {
wp_print_scripts('wpdialogs-popup'); wp_print_scripts('wpdialogs-popup');
@ -1716,7 +1717,11 @@ function wp_preload_dialogs($plugins) {
} }
function wp_quicktags() { function wp_quicktags() {
wp_preload_dialogs( array( 'wpdialogs', 'wplink', 'wp_fullscreen' ) ); wp_preload_dialogs( array( 'plugins' => array( 'wpdialogs', 'wplink', 'wpfullscreen' ) ) );
}
function wp_print_editor_js() {
wp_print_scripts('editor');
} }
function wp_fullscreen_html() { function wp_fullscreen_html() {
@ -1735,9 +1740,21 @@ function wp_fullscreen_html() {
</div> </div>
<div id="wp-fullscreen-toolbar"> <div id="wp-fullscreen-toolbar">
<div id="wp-fullscreen-close"><a href="#" onclick="fullscreen.off();return false;"><?php _e('Back'); ?></a></div> <div id="wp-fullscreen-close"><a href="#" onclick="fullscreen.off();return false;"><?php _e('Back'); ?></a></div>
<div id="wp-fullscreen-save"><input type="button" class="button-primary" value="<?php echo $save; ?>" onclick="fullscreen.save();" /></div> <div id="wp-fullscreen-save">
<div id="wp-fullscreen-buttons" style="width:<?php echo $width; ?>px;" class="wp_themeSkin"> <span><?php if ( $post->post_status == 'publish' ) _e('Updated.'); else _e('Saved.'); ?></span>
<img src="images/wpspin_light.gif" alt="" />
<input type="button" class="button-primary" value="<?php echo $save; ?>" onclick="fullscreen.save();" />
</div>
<div id="wp-fullscreen-central-toolbar" style="width:<?php echo $width; ?>px;">
<div id="wp-fullscreen-mode-bar"><div id="wp-fullscreen-modes">
<a href="#" onclick="fullscreen.switchmode('tinymce');return false;"><?php _e('Visual'); ?></a>
<a href="#" onclick="fullscreen.switchmode('html');return false;"><?php _e('HTML'); ?></a>
</div></div>
<div id="wp-fullscreen-button-bar"><div id="wp-fullscreen-buttons" class="wp_themeSkin">
<div> <div>
<a title="<?php _e('Bold (Ctrl + B)'); ?>" aria-labelledby="wp_fs_bold_voice" onclick="fullscreen.b();return false;" class="mceButton mceButtonEnabled mce_bold" href="javascript:;" id="wp_fs_bold" role="button" tabindex="-1" aria-pressed="false"> <a title="<?php _e('Bold (Ctrl + B)'); ?>" aria-labelledby="wp_fs_bold_voice" onclick="fullscreen.b();return false;" class="mceButton mceButtonEnabled mce_bold" href="javascript:;" id="wp_fs_bold" role="button" tabindex="-1" aria-pressed="false">
<span class="mceIcon mce_bold"></span> <span class="mceIcon mce_bold"></span>
@ -1774,18 +1791,18 @@ function wp_fullscreen_html() {
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span> <span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</div> </div>
<div> <div class="wp-fullscreen-both">
<a title="<?php _e('Insert/edit image (Alt + Shift + M)'); ?>" aria-labelledby="wp_fs_image_voice" onclick="jQuery('#add_image').click();return false;" class="mceButton mceButtonEnabled mce_image" href="javascript:;" id="wp_fs_image" role="button" tabindex="-1"> <a title="<?php _e('Insert/edit image (Alt + Shift + M)'); ?>" aria-labelledby="wp_fs_image_voice" onclick="jQuery('#add_image').click();return false;" class="mceButton mceButtonEnabled mce_image" href="javascript:;" id="wp_fs_image" role="button" tabindex="-1">
<span class="mceIcon mce_image"></span> <span class="mceIcon mce_image"></span>
<span id="wp_fs_image_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Insert/edit image (Alt + Shift + M)'); ?></span> <span id="wp_fs_image_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Insert/edit image (Alt + Shift + M)'); ?></span>
</a> </a>
</div> </div>
<div> <div class="wp-fullscreen-both">
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span> <span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</div> </div>
<div> <div class="wp-fullscreen-both">
<a title="<?php _e('Insert/edit link (Alt + Shift + A)'); ?>" aria-labelledby="wp_fs_link_voice" onclick="fullscreen.link();return false;" class="mceButton mce_link mceButtonEnabled" href="javascript:;" id="wp_fs_link" role="button" tabindex="-1" aria-pressed="false"> <a title="<?php _e('Insert/edit link (Alt + Shift + A)'); ?>" aria-labelledby="wp_fs_link_voice" onclick="fullscreen.link();return false;" class="mceButton mce_link mceButtonEnabled" href="javascript:;" id="wp_fs_link" role="button" tabindex="-1" aria-pressed="false">
<span class="mceIcon mce_link"></span> <span class="mceIcon mce_link"></span>
<span id="wp_fs_link_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Insert/edit link (Alt + Shift + A)'); ?></span> <span id="wp_fs_link_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Insert/edit link (Alt + Shift + A)'); ?></span>
@ -1798,9 +1815,11 @@ function wp_fullscreen_html() {
<span id="wp_fs_unlink_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Unlink (Alt + Shift + S)'); ?></span> <span id="wp_fs_unlink_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Unlink (Alt + Shift + S)'); ?></span>
</a> </a>
</div> </div>
</div></div>
<div id="wp-fullscreen-count"><?php _e('Word Count:'); ?> <span class="word-count">0</span></div> <div id="wp-fullscreen-count"><?php _e('Word Count:'); ?> <span class="word-count">0</span></div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,8 @@
/** /**
* PubSub -- A lightweight publish/subscribe implementation. Private use only! * PubSub
*
* A lightweight publish/subscribe implementation.
* Private use only!
*/ */
var PubSub, fullscreen, wptitlehint; var PubSub, fullscreen, wptitlehint;
@ -38,7 +41,7 @@ PubSub.prototype.unsubscribe = function( topic, callback ) {
}; };
PubSub.prototype.publish = function( topic, args ) { PubSub.prototype.publish = function( topic, args ) {
var i, l, var i, l, broken,
topics = this.topics[ topic ]; topics = this.topics[ topic ];
if ( ! topics ) if ( ! topics )
@ -47,221 +50,406 @@ PubSub.prototype.publish = function( topic, args ) {
args = args || []; args = args || [];
for ( i = 0, l = topics.length; i < l; i++ ) { for ( i = 0, l = topics.length; i < l; i++ ) {
topics[i].apply( null, args ); broken = ( topics[i].apply( null, args ) === false || broken );
} }
return ! broken;
}; };
// Distraction Free Writing (wp-fullscreen) access the API globally using the fullscreen variable. /**
* Distraction Free Writing
* (wp-fullscreen)
*
* Access the API globally using the fullscreen variable.
*/
(function($){ (function($){
var api, ps, bounder; var api, ps, bounder, s;
// Initialize the fullscreen/api object // Initialize the fullscreen/api object
fullscreen = api = {}; fullscreen = api = {};
// Create the PubSub (publish/subscribe) interface. // Create the PubSub (publish/subscribe) interface.
ps = api.pubsub = new PubSub(); ps = api.pubsub = new PubSub();
api.timer = 0; timer = 0;
api.block = false; block = false;
s = api.settings = { // Settings
visible : false,
mode : 'tinymce',
editor_id : 'content',
title_id : 'title',
timer : 0
}
/** /**
* BOUNDER * Bounder
* *
* Creates a function that publishes start/stop topics. * Creates a function that publishes start/stop topics.
* Use to throttle events. * Used to throttle events.
*/ */
bounder = function( start, stop, delay ) { bounder = function( start, stop, delay ) {
delay = delay || 1250; delay = delay || 1250;
if ( api.block ) if ( block )
return; return;
api.block = true; block = true;
setTimeout( function() { setTimeout( function() {
api.block = false; block = false;
}, 400 ); }, 400 );
if ( api.timer ) if ( s.timer )
clearTimeout( api.timer ); clearTimeout( s.timer );
else else
ps.publish( start ); ps.publish( start );
function timed() { function timed() {
ps.publish( stop ); ps.publish( stop );
api.timer = 0; s.timer = 0;
} }
api.timer = setTimeout( timed, delay ); s.timer = setTimeout( timed, delay );
}; };
/** /**
* ON / OFF API * on()
*
* Turns fullscreen on.
*
* @param string mode Optional. Switch to the given mode before opening.
*/ */
api.on = function() { api.on = function() {
if ( ! api.ui.element ) if ( s.visible )
return;
s.mode = $('#' + s.editor_id).is(':hidden') ? 'tinymce' : 'html';
if ( ! s.element )
api.ui.init(); api.ui.init();
if ( ! api.visible ) s.is_mce_on = s.has_tinymce && typeof( tinyMCE.get(s.editor_id) ) != 'undefined';
api.ui.fade( 'show', 'showing', 'shown' );
};
api.off = function() { api.ui.fade( 'show', 'showing', 'shown' );
if ( api.ui.element && api.visible )
api.ui.fade( 'hide', 'hiding', 'hidden' );
}; };
/** /**
* GENERAL * off()
*
* Turns fullscreen off.
*/
api.off = function() {
if ( ! s.visible )
return;
api.ui.fade( 'hide', 'hiding', 'hidden' );
};
/**
* switchmode()
*
* @return string - The current mode.
*
* @param string to - The fullscreen mode to switch to.
* @event switchMode
* @eventparam string to - The new mode.
* @eventparam string from - The old mode.
*/
api.switchmode = function( to ) {
var from = s.mode;
if ( ! to || ! s.visible || ! s.has_tinymce )
return from;
// Don't switch if the mode is the same.
if ( from == to )
return from;
ps.publish( 'switchMode', [ from, to ] );
s.mode = to;
ps.publish( 'switchedMode', [ from, to ] );
return to;
};
/**
* General
*/ */
api.save = function() { api.save = function() {
$('#title').val( $('#wp-fullscreen-title').val() ); var hidden = $('#hiddenaction'), old = hidden.val(), spinner = $('#wp-fullscreen-save img'),
tinyMCE.execCommand('wpFullScreenSaveContent'); message = $('#wp-fullscreen-save span');
$('#hiddenaction').val('wp-fullscreen-save-post');
spinner.show();
api.savecontent();
hidden.val('wp-fullscreen-save-post');
$.post( ajaxurl, $('form#post').serialize(), function(r){ $.post( ajaxurl, $('form#post').serialize(), function(r){
spinner.hide();
message.show();
if ( r.message ) setTimeout( function(){
$('#wp-fullscreen-saved').html(r.message); message.fadeOut(800);
}, 3000 );
if ( r.last_edited ) if ( r.last_edited )
$('#wp-fullscreen-last-edit').html(r.last_edited); $('#wp-fullscreen-save input').attr( 'title', r.last_edited );
}, 'json'); }, 'json');
hidden.val(old);
} }
set_title_hint = function(title) { api.savecontent = function() {
if ( !title.val().length ) var ed, content;
$('#' + s.title_id).val( $('#wp-fullscreen-title').val() );
if ( s.mode === 'tinymce' && (ed = tinyMCE.get('wp_mce_fullscreen')) ) {
content = ed.save();
} else {
content = $('#wp_mce_fullscreen').val();
}
$('#' + s.editor_id).val( content );
}
set_title_hint = function( title ) {
if ( ! title.val().length )
title.siblings('label').css( 'visibility', '' ); title.siblings('label').css( 'visibility', '' );
else else
title.siblings('label').css( 'visibility', 'hidden' ); title.siblings('label').css( 'visibility', 'hidden' );
} }
api._make_sticky = function() {
$( document ).unbind( '.fullscreen' );
clearTimeout( api.timer );
api.timer = 0;
}
ps.subscribe( 'showToolbar', function() { ps.subscribe( 'showToolbar', function() {
api.fade.In( api.ui.topbar, 600, function(){ ps.publish('toolbarShown'); } ); api.fade.In( s.topbar, 600, function(){ ps.publish('toolbarShown'); } );
$('#wp-fullscreen-body').addClass('wp-fullscreen-focus'); $('#wp-fullscreen-body').addClass('wp-fullscreen-focus');
}); });
ps.subscribe( 'hideToolbar', function() { ps.subscribe( 'hideToolbar', function() {
api.fade.Out( api.ui.topbar, 600, function(){ ps.publish('toolbarHidden'); } ); api.fade.Out( s.topbar, 600, function(){ ps.publish('toolbarHidden'); } );
$('#wp-fullscreen-body').removeClass('wp-fullscreen-focus'); $('#wp-fullscreen-body').removeClass('wp-fullscreen-focus');
api.toolbarShown = false;
}); });
ps.subscribe( 'toolbarShown', function() { ps.subscribe( 'show', function() { // This event occurs before the overlay blocks the UI.
api.topbarshown = true; var title = $('#wp-fullscreen-title').val( $('#' + s.title_id).val() );
if ( api.mouseisover )
api._make_sticky(); set_title_hint( title );
$('#wp-fullscreen-save input').attr( 'title', $('#last-edit').text() );
s.textarea_obj.value = edCanvas.value;
if ( s.has_tinymce && s.mode === 'tinymce' )
tinyMCE.execCommand('wpFullScreenInit');
s._edCanvas = edCanvas;
edCanvas = s.textarea_obj;
s.orig_y = $(window).scrollTop();
}); });
ps.subscribe( 'toolbarHidden', function() { ps.subscribe( 'showing', function() { // This event occurs while the DFW overlay blocks the UI.
$( document ).unbind( '.fullscreen2' ) var scrollY = s.mode === 'html' ? 220 + s._edCanvas.scrollTop : 140 + tinyMCE.get(s.editor_id).getBody().scrollTop;
.bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2500 ); } );
});
ps.subscribe( 'show', function() {
var title = $('#wp-fullscreen-title').val( $('#title').val() );
this.set_title_hint(title);
$( document ).bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2500 ); } );
});
ps.subscribe( 'hide', function() {
var title = $('#title').val( $('#wp-fullscreen-title').val() );
this.set_title_hint(title);
tinyMCE.execCommand('wpFullScreenSave');
$( document ).unbind( '.fullscreen' );
});
ps.subscribe( 'showing', function() {
$('#wp-fullscreen-body').show();
$( document.body ).addClass( 'fullscreen-active' ); $( document.body ).addClass( 'fullscreen-active' );
bounder( 'showToolbar', 'hideToolbar', 3000 ); api.refresh_buttons();
$('#wp-fullscreen-last-edit').html( $('#last-edit').html() );
$( document ).bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2500 ); } );
bounder( 'showToolbar', 'hideToolbar', 2500 );
api.bind_resize();
setTimeout( api.resize_textarea, 200 );
if ( scrollY < 171 )
scrollY = 0;
scrollTo(0, scrollY);
}); });
ps.subscribe( 'hiding', function() { ps.subscribe( 'shown', function() { // This event occurs after the DFW overlay is shown
$('#wp-fullscreen-body').hide(); s.visible = true;
// init the standard TinyMCE instance if missing
if ( s.has_tinymce && ! s.is_mce_on ) {
htmled = document.getElementById(s.editor_id), old_val = htmled.value;
htmled.value = switchEditors.wpautop( old_val );
tinyMCE.settings.setup = function(ed) {
ed.onInit.add(function(ed) {
ed.hide();
delete tinyMCE.settings.setup;
ed.getElement().value = old_val;
});
}
tinyMCE.execCommand("mceAddControl", false, s.editor_id);
s.is_mce_on = true;
}
});
ps.subscribe( 'hide', function() { // This event occurs before the overlay blocks DFW.
api.savecontent();
$( document ).unbind( '.fullscreen' );
$(s.textarea_obj).unbind('.grow');
if ( s.has_tinymce && s.mode === 'tinymce' )
tinyMCE.execCommand('wpFullScreenSave');
set_title_hint( $('#' + s.title_id) );
// Restore and update edCanvas.
edCanvas = s._edCanvas;
edCanvas.value = s.textarea_obj.value;
});
ps.subscribe( 'hiding', function() { // This event occurs while the overlay blocks the DFW UI.
// Make sure the correct editor is displaying.
if ( s.has_tinymce && s.mode === 'tinymce' && $('#' + s.editor_id).is(':visible') ) {
switchEditors.go( s.editor_id, 'tinymce' );
} else if ( s.mode == 'html' && $('#' + s.editor_id).is(':hidden') ) {
switchEditors.go( s.editor_id, 'html' );
}
$( document.body ).removeClass( 'fullscreen-active' ); $( document.body ).removeClass( 'fullscreen-active' );
$('#last-edit').html( $('#wp-fullscreen-last-edit').html() ); scrollTo(0, s.orig_y);
}); });
ps.subscribe( 'shown', function() { ps.subscribe( 'hidden', function() { // This event occurs after DFW is removed.
api.visible = true; s.visible = false;
});
ps.subscribe( 'hidden', function() {
api.visible = false;
$('#wp_mce_fullscreen').removeAttr('style'); $('#wp_mce_fullscreen').removeAttr('style');
tinyMCE.execCommand('wpFullScreenClose');
if ( s.has_tinymce && s.is_mce_on )
tinyMCE.execCommand('wpFullScreenClose');
s.textarea_obj.value = '';
api.oldheight = 0;
});
ps.subscribe( 'switchMode', function( from, to ) {
var ed;
if ( !s.has_tinymce || !s.is_mce_on )
return;
ed = tinyMCE.get('wp_mce_fullscreen');
if ( from === 'html' && to === 'tinymce' ) {
s.textarea_obj.value = switchEditors.wpautop( s.textarea_obj.value );
if ( 'undefined' == typeof(ed) )
tinyMCE.execCommand('wpFullScreenInit');
else
ed.show();
} else if ( from === 'tinymce' && to === 'html' ) {
if ( ed )
ed.hide();
}
});
ps.subscribe( 'switchedMode', function( from, to ) {
api.refresh_buttons();
if ( to === 'html' )
setTimeout( api.resize_textarea, 200 );
}); });
/** /**
* Buttons * Buttons
*/ */
api.b = function() { api.b = function() {
tinyMCE.execCommand('Bold'); if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Bold');
} }
api.i = function() { api.i = function() {
tinyMCE.execCommand('Italic'); if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Italic');
} }
api.ul = function() { api.ul = function() {
tinyMCE.execCommand('InsertUnorderedList'); if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertUnorderedList');
} }
api.ol = function() { api.ol = function() {
tinyMCE.execCommand('InsertOrderedList'); if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertOrderedList');
} }
api.link = function() { api.link = function() {
tinyMCE.execCommand('WP_Link'); if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('WP_Link');
else
wpLink.open();
} }
api.unlink = function() { api.unlink = function() {
tinyMCE.execCommand('unlink'); if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('unlink');
}
api.refresh_buttons = function() {
if ( s.mode === 'html' ) {
$('#wp-fullscreen-mode-bar').removeClass('wp-tmce-mode').addClass('wp-html-mode');
$('#wp-fullscreen-button-bar').fadeOut( 200, function(){
$(this).addClass('wp-html-mode').fadeIn( 250 );
});
} else if ( s.mode === 'tinymce' ) {
$('#wp-fullscreen-mode-bar').removeClass('wp-html-mode').addClass('wp-tmce-mode');
$('#wp-fullscreen-button-bar').fadeOut( 200, function(){
$(this).removeClass('wp-html-mode').fadeIn( 250 );
});
}
} }
/** /**
* UI elements (used for transitioning) * UI Elements
*
* Used for transitioning between states.
*/ */
api.ui = { api.ui = {
/**
* Undefined api.ui properties:
* element, topbar
*/
init: function() { init: function() {
var topbar = api.ui.topbar = $('#fullscreen-topbar'); var topbar = s.topbar = $('#fullscreen-topbar');
api.ui.element = $('#fullscreen-fader'); s.element = $('#fullscreen-fader');
s.textarea_obj = document.getElementById('wp_mce_fullscreen');
s.has_tinymce = typeof(tinyMCE) != 'undefined';
if ( !s.has_tinymce )
$('#wp-fullscreen-mode-bar').hide();
if ( wptitlehint ) if ( wptitlehint )
wptitlehint('wp-fullscreen-title'); wptitlehint('wp-fullscreen-title');
topbar.mouseenter(function(e){ topbar.mouseenter(function(e){
api.mouseisover = true; $('#fullscreen-topbar').addClass('fullscreen-make-sticky');
if ( api.topbarshown ) $( document ).unbind( '.fullscreen' );
api._make_sticky(); clearTimeout( s.timer );
s.timer = 0;
}).mouseleave(function(e){ }).mouseleave(function(e){
api.mouseisover = false; $('#fullscreen-topbar').removeClass('fullscreen-make-sticky');
$( document ).bind( 'mousemove.fullscreen2', function(e) { bounder( 'showToolbar', 'hideToolbar', 600 ); } ); $( document ).bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2500 ); } );
}); });
}, },
fade: function( before, during, after ) { fade: function( before, during, after ) {
if ( before ) if ( ! s.element )
ps.publish( before ); api.ui.init();
api.fade.In( api.ui.element, 600, function() { // If any callback bound to before returns false, bail.
if ( before && ! ps.publish( before ) )
return;
api.fade.In( s.element, 600, function() {
if ( during ) if ( during )
ps.publish( during ); ps.publish( during );
api.fade.Out( api.ui.element, 600, function() { api.fade.Out( s.element, 600, function() {
if ( after ) if ( after )
ps.publish( after ); ps.publish( after );
}) })
@ -322,7 +510,7 @@ PubSub.prototype.publish = function( topic, args ) {
return element; return element;
}, },
transitions: (function() { transitions: (function() { // Check if the browser supports CSS 3.0 transitions
var s = document.documentElement.style; var s = document.documentElement.style;
return ( typeof ( s.WebkitTransition ) == 'string' || return ( typeof ( s.WebkitTransition ) == 'string' ||
@ -332,10 +520,30 @@ PubSub.prototype.publish = function( topic, args ) {
})() })()
}; };
/*
api.editor = function() { /**
return $('#content, #content_ifr').filter(':visible'); * Resize API
*
* Automatically updates textarea height.
*/
api.bind_resize = function() {
$(s.textarea_obj).bind('keypress.grow click.grow paste.grow', function(){
setTimeout( api.resize_textarea, 200 );
});
}
api.oldheight = 0;
api.resize_textarea = function() {
var txt = s.textarea_obj, newheight, scroll = document.body.scrollTop || document.documentElement.scrollTop;
newheight = txt.scrollHeight > 300 ? txt.scrollHeight : 300;
if ( newheight != api.oldheight ) {
txt.style.height = newheight + 'px';
// window.scrollTo(0, scroll);
api.oldheight = newheight;
}
}; };
*/
})(jQuery); })(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -246,7 +246,8 @@ add_action( 'save_post', '_save_post_hook', 5, 2 );
add_action( 'transition_post_status', '_transition_post_status', 5, 3 ); add_action( 'transition_post_status', '_transition_post_status', 5, 3 );
add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' ); add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
add_action( 'tiny_mce_preload_dialogs', 'wp_preload_dialogs', 10, 1 ); add_action( 'before_wp_tiny_mce', 'wp_print_editor_js' );
add_action( 'after_wp_tiny_mce', 'wp_preload_dialogs', 10, 1 );
// Navigation menu actions // Navigation menu actions
add_action( 'delete_post', '_wp_delete_post_menu_item' ); add_action( 'delete_post', '_wp_delete_post_menu_item' );

View File

@ -259,6 +259,7 @@ function edToolbar() {
} }
document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />'); document.write('<input type="button" id="ed_spell" class="ed_button" onclick="edSpell(edCanvas);" title="' + quicktagsL10n.dictionaryLookup + '" value="' + quicktagsL10n.lookup + '" />');
document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />'); document.write('<input type="button" id="ed_close" class="ed_button" onclick="edCloseAllTags();" title="' + quicktagsL10n.closeAllOpenTags + '" value="' + quicktagsL10n.closeTags + '" />');
document.write('<input type="button" id="ed_fullscreen" class="ed_button" onclick="fullscreen.on();" title="' + quicktagsL10n.toggleFullscreen + '" value="' + quicktagsL10n.fullscreen + '" />');
// edShowLinks(); // disabled by default // edShowLinks(); // disabled by default
document.write('</div>'); document.write('</div>');
} }

File diff suppressed because one or more lines are too long

View File

@ -31,13 +31,12 @@
edd.setContent( ed.getContent({format : 'raw'}), {format : 'raw'} ); edd.setContent( ed.getContent({format : 'raw'}), {format : 'raw'} );
}); });
ed.addCommand('wpFullScreenSaveContent', function() { ed.addCommand('wpFullScreenInit', function() {
ed.execCommand('wpFullScreenSave'); var d = ed.getDoc(), b = d.body, fsed;
tinyMCE.triggerSave();
});
ed.addCommand('wpFullScreenOpen', function() { // Only init the editor if necessary. Needed?
var d = ed.getDoc(), b = d.body; if ( ed.id == 'wp_mce_fullscreen' )
return;
tinyMCE.oldSettings = tinyMCE.settings; // Store old settings tinyMCE.oldSettings = tinyMCE.settings; // Store old settings
@ -53,27 +52,33 @@
s.theme_advanced_statusbar_location = 'none'; s.theme_advanced_statusbar_location = 'none';
s.content_css = s.wp_fullscreen_content_css || ''; s.content_css = s.wp_fullscreen_content_css || '';
s.height = tinymce.isIE ? b.scrollHeight : b.offsetHeight; s.height = tinymce.isIE ? b.scrollHeight : b.offsetHeight;
s.save_onsavecallback = function() { // s.setup = function(ed) {
ed.setContent(tinyMCE.get(s.id).getContent({format : 'raw'}), {format : 'raw'}); // }
ed.execCommand('mceSave');
};
tinymce.each(ed.getParam('wp_fullscreen_settings'), function(v, k) { tinymce.each(ed.getParam('wp_fullscreen_settings'), function(v, k) {
s[k] = v; s[k] = v;
}); });
t.fullscreenEditor = new tinymce.Editor('wp_mce_fullscreen', s); fsed = new tinymce.Editor('wp_mce_fullscreen', s);
t.fullscreenEditor.onInit.add(function() { fsed.onInit.add(function(edd) {
t.fullscreenEditor.setContent(ed.getContent());
t.fullscreenEditor.focus(); if ( !ed.isHidden() )
edd.setContent( ed.getContent() );
else
edd.setContent( switchEditors.wpautop( edd.getElement().value ) );
edd.focus();
}); });
fullscreen.on(); fsed.render();
t.fullscreenEditor.render();
}); });
// Register buttons // Register buttons
ed.addButton('fullscreen', {title : 'fullscreen.desc', cmd : 'wpFullScreenOpen'}); if ( 'undefined' != fullscreen )
ed.addButton('fullscreen', {
title : 'fullscreen.desc',
onclick : function(){ fullscreen.on(); }
});
// END fullscreen // END fullscreen
//---------------------------------------------------------------- //----------------------------------------------------------------
@ -115,7 +120,6 @@
ed.onPostRender.add(resize); ed.onPostRender.add(resize);
ed.getBody().style.overflowY = "hidden"; ed.getBody().style.overflowY = "hidden";
ed.dom.setStyle( ed.getBody(), 'paddingBottom', ed.getParam('autoresize_bottom_margin', 50) + 'px' );
}); });
if (ed.getParam('autoresize_on_init', true)) { if (ed.getParam('autoresize_on_init', true)) {
@ -132,7 +136,7 @@
} }
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
ed.addCommand('mceAutoResize', resize); ed.addCommand('wpAutoResize', resize);
}, },
getInfo : function() { getInfo : function() {

View File

@ -1 +1 @@
(function(){tinymce.create("tinymce.plugins.wpFullscreenPlugin",{init:function(a,c){var d=this,g=0,e={},f=tinymce.DOM;a.addCommand("wpFullScreenClose",function(){if(a.getParam("wp_fullscreen_is_enabled")){f.win.setTimeout(function(){tinyMCE.remove(a);f.remove("wp_mce_fullscreen_parent");tinyMCE.settings=tinyMCE.oldSettings},10)}});a.addCommand("wpFullScreenSave",function(){var h=tinyMCE.get("wp_mce_fullscreen"),i;h.focus();i=tinyMCE.get(h.getParam("wp_fullscreen_editor_id"));i.setContent(h.getContent({format:"raw"}),{format:"raw"})});a.addCommand("wpFullScreenSaveContent",function(){a.execCommand("wpFullScreenSave");tinyMCE.triggerSave()});a.addCommand("wpFullScreenOpen",function(){var i=a.getDoc(),h=i.body;tinyMCE.oldSettings=tinyMCE.settings;tinymce.each(a.settings,function(j,k){e[k]=j});e.id="wp_mce_fullscreen";e.wp_fullscreen_is_enabled=true;e.wp_fullscreen_editor_id=a.id;e.theme_advanced_resizing=false;e.theme_advanced_toolbar_location="external";e.theme_advanced_statusbar_location="none";e.content_css=e.wp_fullscreen_content_css||"";e.height=tinymce.isIE?h.scrollHeight:h.offsetHeight;e.save_onsavecallback=function(){a.setContent(tinyMCE.get(e.id).getContent({format:"raw"}),{format:"raw"});a.execCommand("mceSave")};tinymce.each(a.getParam("wp_fullscreen_settings"),function(l,j){e[j]=l});d.fullscreenEditor=new tinymce.Editor("wp_mce_fullscreen",e);d.fullscreenEditor.onInit.add(function(){d.fullscreenEditor.setContent(a.getContent());d.fullscreenEditor.focus()});fullscreen.on();d.fullscreenEditor.render()});a.addButton("fullscreen",{title:"fullscreen.desc",cmd:"wpFullScreenOpen"});if(a.getParam("fullscreen_is_enabled")||!a.getParam("wp_fullscreen_is_enabled")){return}function b(){var k=a.getDoc(),h=k.body,m=k.documentElement,j=tinymce.DOM,l,i;if(tinymce.isIE){i=h.scrollHeight}else{if(tinymce.isWebKit){i=h.offsetHeight}else{i=m.offsetHeight}}l=(i>300)?i:300;if(g!=l){g=l;j.setStyle(j.get(a.id+"_ifr"),"height",l+"px")}}a.onInit.add(function(i,h){i.onChange.add(b);i.onSetContent.add(b);i.onPaste.add(b);i.onKeyUp.add(b);i.onPostRender.add(b);i.getBody().style.overflowY="hidden";i.dom.setStyle(i.getBody(),"paddingBottom",i.getParam("autoresize_bottom_margin",50)+"px")});if(a.getParam("autoresize_on_init",true)){a.onLoadContent.add(function(i,h){setTimeout(function(){b()},1200)})}a.addCommand("mceAutoResize",b)},getInfo:function(){return{longname:"WP Fullscreen",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpfullscreen",tinymce.plugins.wpFullscreenPlugin)})(); (function(){tinymce.create("tinymce.plugins.wpFullscreenPlugin",{init:function(a,c){var d=this,g=0,e={},f=tinymce.DOM;a.addCommand("wpFullScreenClose",function(){if(a.getParam("wp_fullscreen_is_enabled")){f.win.setTimeout(function(){tinyMCE.remove(a);f.remove("wp_mce_fullscreen_parent");tinyMCE.settings=tinyMCE.oldSettings},10)}});a.addCommand("wpFullScreenSave",function(){var h=tinyMCE.get("wp_mce_fullscreen"),i;h.focus();i=tinyMCE.get(h.getParam("wp_fullscreen_editor_id"));i.setContent(h.getContent({format:"raw"}),{format:"raw"})});a.addCommand("wpFullScreenInit",function(){var j=a.getDoc(),h=j.body,i;if(a.id=="wp_mce_fullscreen"){return}tinyMCE.oldSettings=tinyMCE.settings;tinymce.each(a.settings,function(k,l){e[l]=k});e.id="wp_mce_fullscreen";e.wp_fullscreen_is_enabled=true;e.wp_fullscreen_editor_id=a.id;e.theme_advanced_resizing=false;e.theme_advanced_toolbar_location="external";e.theme_advanced_statusbar_location="none";e.content_css=e.wp_fullscreen_content_css||"";e.height=tinymce.isIE?h.scrollHeight:h.offsetHeight;tinymce.each(a.getParam("wp_fullscreen_settings"),function(m,l){e[l]=m});i=new tinymce.Editor("wp_mce_fullscreen",e);i.onInit.add(function(k){if(!a.isHidden()){k.setContent(a.getContent())}else{k.setContent(switchEditors.wpautop(k.getElement().value))}k.focus()});i.render()});if("undefined"!=fullscreen){a.addButton("fullscreen",{title:"fullscreen.desc",onclick:function(){fullscreen.on()}})}if(a.getParam("fullscreen_is_enabled")||!a.getParam("wp_fullscreen_is_enabled")){return}function b(){var k=a.getDoc(),h=k.body,m=k.documentElement,j=tinymce.DOM,l,i;if(tinymce.isIE){i=h.scrollHeight}else{if(tinymce.isWebKit){i=h.offsetHeight}else{i=m.offsetHeight}}l=(i>300)?i:300;if(g!=l){g=l;j.setStyle(j.get(a.id+"_ifr"),"height",l+"px")}}a.onInit.add(function(i,h){i.onChange.add(b);i.onSetContent.add(b);i.onPaste.add(b);i.onKeyUp.add(b);i.onPostRender.add(b);i.getBody().style.overflowY="hidden"});if(a.getParam("autoresize_on_init",true)){a.onLoadContent.add(function(i,h){setTimeout(function(){b()},1200)})}a.addCommand("wpAutoResize",b)},getInfo:function(){return{longname:"WP Fullscreen",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wpfullscreen",tinymce.plugins.wpFullscreenPlugin)})();

View File

@ -9,7 +9,7 @@ var wpLink;
riverBottomThreshold: 5, riverBottomThreshold: 5,
keySensitivity: 100, keySensitivity: 100,
lastSearch: '', lastSearch: '',
textarea: edCanvas, textarea: function() { return edCanvas; },
init : function() { init : function() {
inputs.dialog = $('#wp-link'); inputs.dialog = $('#wp-link');
@ -49,7 +49,7 @@ var wpLink;
wpLink.range = null; wpLink.range = null;
if ( ! wpLink.isMCE() && document.selection ) { if ( ! wpLink.isMCE() && document.selection ) {
wpLink.textarea.focus(); wpLink.textarea().focus();
wpLink.range = document.selection.createRange(); wpLink.range = document.selection.createRange();
} }
}, },
@ -127,7 +127,7 @@ var wpLink;
onClose: function() { onClose: function() {
if ( ! wpLink.isMCE() ) { if ( ! wpLink.isMCE() ) {
wpLink.textarea.focus(); wpLink.textarea().focus();
if ( wpLink.range ) { if ( wpLink.range ) {
wpLink.range.moveToBookmark( wpLink.range.getBookmark() ); wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
wpLink.range.select(); wpLink.range.select();
@ -152,7 +152,7 @@ var wpLink;
htmlUpdate : function() { htmlUpdate : function() {
var attrs, html, start, end, cursor, var attrs, html, start, end, cursor,
textarea = wpLink.textarea; textarea = wpLink.textarea();
if ( ! textarea ) if ( ! textarea )
return; return;

File diff suppressed because one or more lines are too long

View File

@ -86,6 +86,8 @@ function wp_default_scripts( &$scripts ) {
'enterURL' => __('Enter the URL'), 'enterURL' => __('Enter the URL'),
'enterImageURL' => __('Enter the URL of the image'), 'enterImageURL' => __('Enter the URL of the image'),
'enterImageDescription' => __('Enter a description of the image'), 'enterImageDescription' => __('Enter a description of the image'),
'fullscreen' => __('fullscreen'),
'toggleFullscreen' => esc_attr( __('Toggle fullscreen mode') ),
'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};' 'l10n_print_after' => 'try{convertEntities(quicktagsL10n);}catch(e){};'
) ); ) );
@ -94,7 +96,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' ); $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' );
$scripts->add_data( 'editor', 'group', 1 ); $scripts->add_data( 'editor', 'group', 1 );
$scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110425b' ); $scripts->add( 'wp-fullscreen', "/wp-admin/js/wp-fullscreen$suffix.js", array('jquery'), '20110501' );
$scripts->add_data( 'wp-fullscreen', 'group', 1 ); $scripts->add_data( 'wp-fullscreen', 'group', 1 );
$scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1'); $scripts->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6.1');
@ -271,7 +273,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' ); $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", false, '20110131' );
$scripts->add_data( 'admin-bar', 'group', 1 ); $scripts->add_data( 'admin-bar', 'group', 1 );
$scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110421' ); $scripts->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), '20110501' );
$scripts->add_data( 'wplink', 'group', 1 ); $scripts->add_data( 'wplink', 'group', 1 );
$scripts->localize( 'wplink', 'wpLinkL10n', array( $scripts->localize( 'wplink', 'wpLinkL10n', array(
'title' => __('Insert/edit link'), 'title' => __('Insert/edit link'),
@ -483,7 +485,7 @@ function wp_default_styles( &$styles ) {
// Any rtl stylesheets that don't have a .dev version for ltr // Any rtl stylesheets that don't have a .dev version for ltr
$no_suffix = array( 'farbtastic' ); $no_suffix = array( 'farbtastic' );
$styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110428' ); $styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array(), '20110501' );
$styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' ); $styles->add( 'ie', "/wp-admin/css/ie$suffix.css", array(), '20101102' );
$styles->add_data( 'ie', 'conditional', 'lte IE 7' ); $styles->add_data( 'ie', 'conditional', 'lte IE 7' );

View File

@ -36,7 +36,7 @@ $wp_db_version = 17516;
* *
* @global string $tinymce_version * @global string $tinymce_version
*/ */
$tinymce_version = '342-20110425'; $tinymce_version = '342-20110501';
/** /**
* Holds the cache manifest version * Holds the cache manifest version