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;
}
.fullscreen-active .fullscreen-overlay {
.fullscreen-active .fullscreen-overlay,
.fullscreen-active #wp-fullscreen-body {
display: block;
}
@ -613,7 +614,7 @@ form.upgrade .hint {
}
#wp-fullscreen-wrap {
margin: 75px auto 50px;
margin: 60px auto 50px;
position: relative;
}
@ -627,7 +628,7 @@ form.upgrade .hint {
}
#wp-fullscreen-container {
padding: 4px 9px;
padding: 4px 10px;
}
#wp-fullscreen-title,
@ -657,6 +658,12 @@ form.upgrade .hint {
width: 100%;
min-height: 300px;
border: 0;
background: transparent;
line-height: 1.6em;
padding: 0;
overflow-y: hidden;
outline: none;
resize: none;
}
/* =Top bar
@ -671,26 +678,32 @@ form.upgrade .hint {
border-bottom: 1px solid #C6C6C6;
min-width: 800px;
width: 100%;
height: 62px;
background: #d9d9d9;
background: -moz-linear-gradient(bottom, #d7d7d7, #e4e4e4);
background: -webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
height: 40px;
background-color: #d9d9d9;
background-image: -moz-linear-gradient(bottom, #d7d7d7, #e4e4e4);
background-image: -webkit-gradient(linear, left bottom, left top, from(#d7d7d7), to(#e4e4e4));
}
#wp-fullscreen-toolbar {
padding: 6px 12px 0;
padding: 6px 2% 0;
clear: both;
}
#wp-fullscreen-mode-bar,
#wp-fullscreen-button-bar,
#wp-fullscreen-close {
float: left;
}
#wp-fullscreen-save,
#wp-fullscreen-buttons #wp-fullscreen-count {
#wp-fullscreen-count {
float: right;
}
#wp-fullscreen-save {
padding-top: 2px;
}
#wp-fullscreen-count,
#wp-fullscreen-close {
padding-top: 5px;
@ -699,9 +712,11 @@ form.upgrade .hint {
#wp-fullscreen-info {
float: right;
padding: 3px 10px;
display: none;
}
#wp-fullscreen-buttons {
#wp-fullscreen-central-toolbar {
margin: auto;
padding: 0;
}
@ -710,6 +725,92 @@ form.upgrade .hint {
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
-------------------------------------------------------------- */
.fullscreen-active #TB_overlay {
@ -4078,7 +4179,7 @@ input.button-highlighted,
margin: 20px 0;
}
.pressthis a {
.pressthis a {
display: inline-block;
width: 113px;
position: relative;
@ -4098,13 +4199,13 @@ input.button-highlighted,
rgb(216,216,216) 77%
);
background-repeat: no-repeat;
background-image-position: 10px 8px;
background-image-position: 10px 8px;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-o-border-radius: 5px;
-o-border-radius: 5px;
border: 1px #b4b4b4 solid;
font: normal normal normal 14px/16px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
font: normal normal normal 14px/16px Georgia, "Times New Roman", "Bitstream Charter", Times, serif;
text-decoration: none;
text-shadow: #fff 0 1px 0px;
-webkit-text-shadow: #fff 0 1px 0px;
@ -4121,33 +4222,33 @@ input.button-highlighted,
transform: skew(20deg) rotate(9deg);
-webkit-transform: skew(20deg) rotate(9deg);
-moz-transform: skew(20deg) rotate(9deg);
box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
-webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
-moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.7);
}
.pressthis a span {
background: url(../images/press-this.png) no-repeat 10px 7px ;
background: url(../images/press-this.png) no-repeat 10px 7px ;
padding: 8px 0 8px 32px;
display: inline-block;
}
.pressthis a:after {
content: '';
width: 70%;
.pressthis a:after {
content: '';
width: 70%;
height: 55%;
z-index: -1;
position: absolute;
right: 10px;
bottom: 9px;
background: transparent;
z-index: -1;
position: absolute;
right: 10px;
bottom: 9px;
background: transparent;
transform: skew(20deg) rotate(6deg);
-webkit-transform: skew(20deg) rotate(6deg);
-moz-transform: skew(20deg) rotate(6deg);
box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
-webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
-moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
}
box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
-webkit-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
-moz-box-shadow: 0 10px 8px rgba(0, 0, 0, 0.6);
}
/*------------------------------------------------------------------------------

View File

@ -1647,7 +1647,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
$mce_options = rtrim( trim($mce_options), '\n\r,' );
wp_print_scripts('editor'); ?>
do_action('before_wp_tiny_mce', $initArray); ?>
<script type="text/javascript">
/* <![CDATA[ */
@ -1688,11 +1688,12 @@ tinyMCE.init(tinyMCEPreInit.mceInit);
</script>
<?php
do_action('tiny_mce_preload_dialogs', $plugins);
do_action('after_wp_tiny_mce', $initArray);
}
// 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 ) ) {
wp_print_scripts('wpdialogs-popup');
@ -1716,7 +1717,11 @@ function wp_preload_dialogs($plugins) {
}
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() {
@ -1725,19 +1730,31 @@ function wp_fullscreen_html() {
$width = isset($content_width) && 800 > $content_width ? $content_width : 800;
$width = $width + 10; // compensate for the padding
$save = $post->post_status == 'publish' ? __('Update') : __('Save');
?>
?>
<div id="wp-fullscreen-body">
<div id="fullscreen-topbar" class="fade-600">
<div id="wp-fullscreen-info">
<span id="wp-fullscreen-saved"> </span>
<span class="autosave-message">&nbsp;</span>
<span id="wp-fullscreen-last-edit"> </span>
<span id="wp-fullscreen-last-edit"> </span>
</div>
<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-save"><input type="button" class="button-primary" value="<?php echo $save; ?>" onclick="fullscreen.save();" /></div>
<div id="wp-fullscreen-buttons" style="width:<?php echo $width; ?>px;" class="wp_themeSkin">
<div id="wp-fullscreen-save">
<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>
<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>
@ -1774,18 +1791,18 @@ function wp_fullscreen_html() {
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</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">
<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>
</a>
</div>
<div>
<div class="wp-fullscreen-both">
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</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">
<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>
@ -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>
</a>
</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>

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;
@ -38,7 +41,7 @@ PubSub.prototype.unsubscribe = function( topic, callback ) {
};
PubSub.prototype.publish = function( topic, args ) {
var i, l,
var i, l, broken,
topics = this.topics[ topic ];
if ( ! topics )
@ -47,221 +50,406 @@ PubSub.prototype.publish = function( topic, args ) {
args = args || [];
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($){
var api, ps, bounder;
var api, ps, bounder, s;
// Initialize the fullscreen/api object
fullscreen = api = {};
// Create the PubSub (publish/subscribe) interface.
ps = api.pubsub = new PubSub();
api.timer = 0;
api.block = false;
timer = 0;
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.
* Use to throttle events.
* Used to throttle events.
*/
bounder = function( start, stop, delay ) {
delay = delay || 1250;
if ( api.block )
if ( block )
return;
api.block = true;
block = true;
setTimeout( function() {
api.block = false;
block = false;
}, 400 );
if ( api.timer )
clearTimeout( api.timer );
if ( s.timer )
clearTimeout( s.timer );
else
ps.publish( start );
function timed() {
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() {
if ( ! api.ui.element )
if ( s.visible )
return;
s.mode = $('#' + s.editor_id).is(':hidden') ? 'tinymce' : 'html';
if ( ! s.element )
api.ui.init();
if ( ! api.visible )
api.ui.fade( 'show', 'showing', 'shown' );
};
s.is_mce_on = s.has_tinymce && typeof( tinyMCE.get(s.editor_id) ) != 'undefined';
api.off = function() {
if ( api.ui.element && api.visible )
api.ui.fade( 'hide', 'hiding', 'hidden' );
api.ui.fade( 'show', 'showing', 'shown' );
};
/**
* 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() {
$('#title').val( $('#wp-fullscreen-title').val() );
tinyMCE.execCommand('wpFullScreenSaveContent');
$('#hiddenaction').val('wp-fullscreen-save-post');
var hidden = $('#hiddenaction'), old = hidden.val(), spinner = $('#wp-fullscreen-save img'),
message = $('#wp-fullscreen-save span');
spinner.show();
api.savecontent();
hidden.val('wp-fullscreen-save-post');
$.post( ajaxurl, $('form#post').serialize(), function(r){
spinner.hide();
message.show();
if ( r.message )
$('#wp-fullscreen-saved').html(r.message);
setTimeout( function(){
message.fadeOut(800);
}, 3000 );
if ( r.last_edited )
$('#wp-fullscreen-last-edit').html(r.last_edited);
$('#wp-fullscreen-save input').attr( 'title', r.last_edited );
}, 'json');
hidden.val(old);
}
set_title_hint = function(title) {
if ( !title.val().length )
api.savecontent = function() {
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', '' );
else
title.siblings('label').css( 'visibility', 'hidden' );
}
api._make_sticky = function() {
$( document ).unbind( '.fullscreen' );
clearTimeout( api.timer );
api.timer = 0;
}
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');
});
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');
api.toolbarShown = false;
});
ps.subscribe( 'toolbarShown', function() {
api.topbarshown = true;
if ( api.mouseisover )
api._make_sticky();
ps.subscribe( 'show', function() { // This event occurs before the overlay blocks the UI.
var title = $('#wp-fullscreen-title').val( $('#' + s.title_id).val() );
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() {
$( document ).unbind( '.fullscreen2' )
.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();
ps.subscribe( 'showing', function() { // This event occurs while the DFW overlay blocks the UI.
var scrollY = s.mode === 'html' ? 220 + s._edCanvas.scrollTop : 140 + tinyMCE.get(s.editor_id).getBody().scrollTop;
$( document.body ).addClass( 'fullscreen-active' );
bounder( 'showToolbar', 'hideToolbar', 3000 );
$('#wp-fullscreen-last-edit').html( $('#last-edit').html() );
api.refresh_buttons();
$( 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() {
$('#wp-fullscreen-body').hide();
ps.subscribe( 'shown', function() { // This event occurs after the DFW overlay is shown
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' );
$('#last-edit').html( $('#wp-fullscreen-last-edit').html() );
scrollTo(0, s.orig_y);
});
ps.subscribe( 'shown', function() {
api.visible = true;
});
ps.subscribe( 'hidden', function() {
api.visible = false;
ps.subscribe( 'hidden', function() { // This event occurs after DFW is removed.
s.visible = false;
$('#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
*/
api.b = function() {
tinyMCE.execCommand('Bold');
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Bold');
}
api.i = function() {
tinyMCE.execCommand('Italic');
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Italic');
}
api.ul = function() {
tinyMCE.execCommand('InsertUnorderedList');
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertUnorderedList');
}
api.ol = function() {
tinyMCE.execCommand('InsertOrderedList');
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertOrderedList');
}
api.link = function() {
tinyMCE.execCommand('WP_Link');
if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('WP_Link');
else
wpLink.open();
}
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 = {
/**
* Undefined api.ui properties:
* element, topbar
*/
init: function() {
var topbar = api.ui.topbar = $('#fullscreen-topbar');
api.ui.element = $('#fullscreen-fader');
var topbar = s.topbar = $('#fullscreen-topbar');
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 )
wptitlehint('wp-fullscreen-title');
topbar.mouseenter(function(e){
api.mouseisover = true;
if ( api.topbarshown )
api._make_sticky();
$('#fullscreen-topbar').addClass('fullscreen-make-sticky');
$( document ).unbind( '.fullscreen' );
clearTimeout( s.timer );
s.timer = 0;
}).mouseleave(function(e){
api.mouseisover = false;
$( document ).bind( 'mousemove.fullscreen2', function(e) { bounder( 'showToolbar', 'hideToolbar', 600 ); } );
$('#fullscreen-topbar').removeClass('fullscreen-make-sticky');
$( document ).bind( 'mousemove.fullscreen', function(e) { bounder( 'showToolbar', 'hideToolbar', 2500 ); } );
});
},
fade: function( before, during, after ) {
if ( before )
ps.publish( before );
if ( ! s.element )
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 )
ps.publish( during );
api.fade.Out( api.ui.element, 600, function() {
api.fade.Out( s.element, 600, function() {
if ( after )
ps.publish( after );
})
@ -322,7 +510,7 @@ PubSub.prototype.publish = function( topic, args ) {
return element;
},
transitions: (function() {
transitions: (function() { // Check if the browser supports CSS 3.0 transitions
var s = document.documentElement.style;
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);

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( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' );
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
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_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
document.write('</div>');
}

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,7 @@
}, 10);
}
});
ed.addCommand('wpFullScreenSave', function() {
var ed = tinyMCE.get('wp_mce_fullscreen'), edd;
@ -30,14 +30,13 @@
edd.setContent( ed.getContent({format : 'raw'}), {format : 'raw'} );
});
ed.addCommand('wpFullScreenSaveContent', function() {
ed.execCommand('wpFullScreenSave');
tinyMCE.triggerSave();
});
ed.addCommand('wpFullScreenOpen', function() {
var d = ed.getDoc(), b = d.body;
ed.addCommand('wpFullScreenInit', function() {
var d = ed.getDoc(), b = d.body, fsed;
// Only init the editor if necessary. Needed?
if ( ed.id == 'wp_mce_fullscreen' )
return;
tinyMCE.oldSettings = tinyMCE.settings; // Store old settings
@ -53,27 +52,33 @@
s.theme_advanced_statusbar_location = 'none';
s.content_css = s.wp_fullscreen_content_css || '';
s.height = tinymce.isIE ? b.scrollHeight : b.offsetHeight;
s.save_onsavecallback = function() {
ed.setContent(tinyMCE.get(s.id).getContent({format : 'raw'}), {format : 'raw'});
ed.execCommand('mceSave');
};
// s.setup = function(ed) {
// }
tinymce.each(ed.getParam('wp_fullscreen_settings'), function(v, k) {
s[k] = v;
});
t.fullscreenEditor = new tinymce.Editor('wp_mce_fullscreen', s);
t.fullscreenEditor.onInit.add(function() {
t.fullscreenEditor.setContent(ed.getContent());
t.fullscreenEditor.focus();
fsed = new tinymce.Editor('wp_mce_fullscreen', s);
fsed.onInit.add(function(edd) {
if ( !ed.isHidden() )
edd.setContent( ed.getContent() );
else
edd.setContent( switchEditors.wpautop( edd.getElement().value ) );
edd.focus();
});
fullscreen.on();
t.fullscreenEditor.render();
fsed.render();
});
// 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
//----------------------------------------------------------------
@ -115,7 +120,6 @@
ed.onPostRender.add(resize);
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)) {
@ -132,7 +136,7 @@
}
// 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() {

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,
keySensitivity: 100,
lastSearch: '',
textarea: edCanvas,
textarea: function() { return edCanvas; },
init : function() {
inputs.dialog = $('#wp-link');
@ -49,7 +49,7 @@ var wpLink;
wpLink.range = null;
if ( ! wpLink.isMCE() && document.selection ) {
wpLink.textarea.focus();
wpLink.textarea().focus();
wpLink.range = document.selection.createRange();
}
},
@ -127,7 +127,7 @@ var wpLink;
onClose: function() {
if ( ! wpLink.isMCE() ) {
wpLink.textarea.focus();
wpLink.textarea().focus();
if ( wpLink.range ) {
wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
wpLink.range.select();
@ -152,7 +152,7 @@ var wpLink;
htmlUpdate : function() {
var attrs, html, start, end, cursor,
textarea = wpLink.textarea;
textarea = wpLink.textarea();
if ( ! textarea )
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'),
'enterImageURL' => __('Enter the URL 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){};'
) );
@ -93,8 +95,8 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('utils','jquery'), '20110411' );
$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( '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_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->localize( 'wplink', 'wpLinkL10n', array(
'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
$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_data( 'ie', 'conditional', 'lte IE 7' );

View File

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