Distraction Free Writing mode, see #17136

git-svn-id: http://svn.automattic.com/wordpress/trunk@17695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz
2011-04-25 01:01:34 +00:00
parent a69059331c
commit 258a8f6844
23 changed files with 1232 additions and 63 deletions

View File

@@ -1468,6 +1468,68 @@ case 'date_format' :
case 'time_format' :
die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
break;
case 'wp-fullscreen-save-post' :
if ( isset($_POST['post_ID']) )
$post_id = (int) $_POST['post_ID'];
else
$post_id = 0;
$post = null;
$post_type_object = null;
$post_type = null;
if ( $post_id ) {
$post = get_post($post_id);
if ( $post ) {
$post_type_object = get_post_type_object($post->post_type);
if ( $post_type_object ) {
$post_type = $post->post_type;
$current_screen->post_type = $post->post_type;
$current_screen->id = $current_screen->post_type;
}
}
} elseif ( isset($_POST['post_type']) ) {
$post_type_object = get_post_type_object($_POST['post_type']);
if ( $post_type_object ) {
$post_type = $post_type_object->name;
$current_screen->post_type = $post_type;
$current_screen->id = $current_screen->post_type;
}
}
check_ajax_referer('update-' . $post_type . '_' . $post_id, '_wpnonce');
$post_id = edit_post();
if ( is_wp_error($post_id) ) {
if ( $post_id->get_error_message() )
$message = $post_id->get_error_message();
else
$message = __('Save failed');
echo json_encode( array( 'message' => $message, 'last_edited' => '' ) );
die();
} else {
$message = __('Saved.');
}
if ( $post ) {
$last_date = mysql2date( get_option('date_format'), $post->post_modified );
$last_time = mysql2date( get_option('time_format'), $post->post_modified );
} else {
$last_date = date_i18n( get_option('date_format') );
$last_time = date_i18n( get_option('time_format') );
}
if ( $last_id = get_post_meta($post_id, '_edit_last', true) ) {
$last_user = get_userdata($last_id);
$last_edited = sprintf( __('Last edited by %1$s on %2$s at %3$s'), esc_html( $last_user->display_name ), $last_date, $last_time );
} else {
$last_edited = sprintf( __('Last edited on %1$s at %2$s'), $last_date, $last_time );
}
echo json_encode( array( 'message' => $message, 'last_edited' => $last_edited ) );
die();
break;
default :
do_action( 'wp_ajax_' . $_POST['action'] );
die('0');

View File

@@ -68,8 +68,6 @@ var userSettings = {
<?php
if ( in_array( $pagenow, array('post.php', 'post-new.php') ) ) {
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 );
wp_enqueue_script('quicktags');
}

File diff suppressed because one or more lines are too long

View File

@@ -512,3 +512,34 @@ div.error p {
.wrap h2.long-header {
padding-right: 0;
}
/* =CSS 3 transitions
-------------------------------------------------------------- */
.fade-600 {
opacity: 0;
-moz-transition-property: opacity;
-moz-transition-duration: 0.6s;
-webkit-transition-property: opacity;
-webkit-transition-duration: 0.6s;
-o-transition-property: opacity;
-o-transition-duration: 0.6s;
transition-property: opacity;
transition-duration: 0.6s;
}
.fade-400 {
opacity: 0;
-moz-transition-property: opacity;
-moz-transition-duration: 0.4s;
-webkit-transition-property: opacity;
-webkit-transition-duration: 0.4s;
-o-transition-property: opacity;
-o-transition-duration: 0.4s;
transition-property: opacity;
transition-duration: 0.4s;
}
.fade-trigger {
opacity: 1;
}

File diff suppressed because one or more lines are too long

View File

@@ -574,6 +574,167 @@ form.upgrade .hint {
border-radius: 3px;
}
/* Distraction Free Writing mode
* =Overlay Styles
-------------------------------------------------------------- */
.fullscreen-overlay {
z-index: 149999;
display: none;
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: #f9f9f9;
filter: inherit;
}
.fullscreen-active .fullscreen-overlay {
display: block;
}
.fullscreen-fader {
z-index: 200000;
}
.fullscreen-active .fullscreen-fader {
display: none;
}
/* =Overlay Body
-------------------------------------------------------------- */
#wp-fullscreen-body {
width: 100%;
z-index: 150005;
display: none;
position: absolute;
top: 0;
left: 0;
}
#wp-fullscreen-wrap {
margin: 75px auto 50px;
position: relative;
}
#wp-fullscreen-title {
font-size: 1.7em;
line-height: 100%;
outline: medium none;
padding: 6px 7px;
width: 100%;
margin-bottom: 30px;
}
#wp-fullscreen-container {
padding: 2px 7px;
}
#wp-fullscreen-title,
#wp-fullscreen-container {
-moz-border-radius: 0;
-khtml-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
border: 1px dashed transparent;
background: transparent;
-moz-transition-property: border-color;
-moz-transition-duration: 0.6s;
-webkit-transition-property: border-color;
-webkit-transition-duration: 0.6s;
-o-transition-property: border-color;
-o-transition-duration: 0.6s;
transition-property: border-color;
transition-duration: 0.6s;
}
.wp-fullscreen-focus #wp-fullscreen-title,
.wp-fullscreen-focus #wp-fullscreen-container {
border-color: #ccc;
}
#wp_mce_fullscreen {
width: 100%;
min-height: 300px;
border: 0;
}
/* =Top bar
-------------------------------------------------------------- */
#fullscreen-topbar {
position: fixed;
display: none;
filter: inherit;
top: 0;
left: 0;
z-index: 150050;
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));
}
#wp-fullscreen-toolbar {
padding: 6px 12px 0;
clear: both;
}
#wp-fullscreen-close {
float: left;
}
#wp-fullscreen-save,
#wp-fullscreen-buttons #wp-fullscreen-count {
float: right;
}
#wp-fullscreen-count,
#wp-fullscreen-close {
padding-top: 5px;
}
#wp-fullscreen-info {
float: right;
padding: 3px 10px;
}
#wp-fullscreen-buttons {
margin: auto;
padding: 0;
}
#wp-fullscreen-buttons > div {
float: left;
}
/* =Thickbox Adjustments
-------------------------------------------------------------- */
.fullscreen-active #TB_overlay {
z-index: 150100;
}
.fullscreen-active #TB_window {
z-index: 150102;
}
/* =TinyMCS Adjustments
-------------------------------------------------------------- */
#wp_mce_fullscreen_ifr {
background: transparent;
}
#wp_mce_fullscreen_parent div:first-child,
#wp_mce_fullscreen_parent #wp_mce_fullscreen_external_close {
display : none;
}
#wp-fullscreen-container .wp_themeSkin table td {
vertical-align: top;
}
/*------------------------------------------------------------------------------
6.0 - Admin Header
@@ -1866,13 +2027,19 @@ table .inline-edit-row fieldset ul.cat-hover {
outline: none;
}
#titlediv #title-prompt-text {
#titlediv #title-prompt-text,
#wp-fullscreen-title-prompt-text {
color: #bbb;
position: absolute;
font-size: 1.7em;
padding: 8px;
}
#wp-fullscreen-title-prompt-text {
top: 3px;
left: 0;
}
#poststuff .inside-submitbox,
#side-sortables .inside-submitbox {
margin: 0 3px;

View File

@@ -12,12 +12,6 @@ if ( !defined('ABSPATH') )
wp_enqueue_script('post');
if ( post_type_supports($post_type, 'editor') ) {
if ( user_can_richedit() )
wp_enqueue_script('editor');
wp_enqueue_script('word-count');
}
if ( post_type_supports($post_type, 'editor') || post_type_supports($post_type, 'thumbnail') ) {
add_thickbox();
wp_enqueue_script('media-upload');

View File

@@ -1410,7 +1410,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
$plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'fullscreen', 'wordpress', 'wplink', 'wpdialogs') );
$ext_plugins = '';
} else {
$plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'fullscreen', 'media', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink', 'wpdialogs' );
$plugins = array( 'inlinepopups', 'spellchecker', 'tabfocus', 'paste', 'media', 'wordpress', 'wpfullscreen', 'wpeditimage', 'wpgallery', 'wplink', 'wpdialogs' );
/*
The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
@@ -1561,6 +1561,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
'paste_text_use_dialog' => true,
'extended_valid_elements' => 'article[*],aside[*],audio[*],canvas[*],command[*],datalist[*],details[*],embed[*],figcaption[*],figure[*],footer[*],header[*],hgroup[*],keygen[*],mark[*],meter[*],nav[*],output[*],progress[*],section[*],source[*],summary,time[*],video[*],wbr',
'wpeditimage_disable_captions' => $no_captions,
'wp_fullscreen_content_css' => "$baseurl/plugins/wpfullscreen/css/content.css",
'plugins' => implode( ',', $plugins ),
);
@@ -1644,7 +1645,9 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
$mce_options .= $k . ':"' . $v . '", ';
}
$mce_options = rtrim( trim($mce_options), '\n\r,' ); ?>
$mce_options = rtrim( trim($mce_options), '\n\r,' );
wp_print_scripts('editor'); ?>
<script type="text/javascript">
/* <![CDATA[ */
@@ -1685,20 +1688,135 @@ tinyMCE.init(tinyMCEPreInit.mceInit);
</script>
<?php
// Load additional inline scripts based on active plugins.
if ( in_array( 'wpdialogs', $plugins ) ) {
wp_print_scripts( array( 'wpdialogs-popup' ) );
do_action('tiny_mce_preload_dialogs', $plugins);
}
// Load additional inline scripts based on active plugins.
function wp_preload_dialogs($plugins) {
if ( in_array( 'wpdialogs', $plugins, true ) ) {
wp_print_scripts('wpdialogs-popup');
wp_print_styles('wp-jquery-ui-dialog');
}
if ( in_array( 'wplink', $plugins ) ) {
if ( in_array( 'wplink', $plugins, true ) ) {
require_once ABSPATH . 'wp-admin/includes/internal-linking.php';
add_action('tiny_mce_preload_dialogs', 'wp_link_dialog');
?><div style="display:none;"><?php wp_link_dialog(); ?></div><?php
wp_print_scripts('wplink');
wp_print_styles('wplink');
}
// Distraction Free Writing mode
if ( in_array( 'wpfullscreen', $plugins, true ) ) {
wp_fullscreen_html();
wp_print_scripts('wp-fullscreen');
}
wp_print_scripts('word-count');
}
function wp_tiny_mce_preload_dialogs() { ?>
<div id="preloaded-dialogs" style="display:none;">
<?php do_action('tiny_mce_preload_dialogs'); ?>
function wp_quicktags() {
wp_preload_dialogs( array( 'wpdialogs', 'wplink', 'wp_fullscreen' ) );
}
function wp_fullscreen_html() {
global $content_width, $post;
$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>
</div>
<?php }
<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>
<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 id="wp_fs_bold_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Bold (Ctrl + B)'); ?></span>
</a>
</div>
<div>
<a title="<?php _e('Italic (Ctrl + I)'); ?>" aria-labelledby="wp_fs_italic_voice" onclick="fullscreen.i();return false;" class="mceButton mceButtonEnabled mce_italic" href="javascript:;" id="wp_fs_italic" role="button" tabindex="-1" aria-pressed="false">
<span class="mceIcon mce_italic"></span>
<span id="wp_fs_italic_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Italic (Ctrl + I)'); ?></span>
</a>
</div>
<div>
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</div>
<div>
<a title="<?php _e('Unordered list (Alt + Shift + U)'); ?>" aria-labelledby="wp_fs_bullist_voice" onclick="fullscreen.ul();return false;" onmousedown="return false;" class="mceButton mceButtonEnabled mce_bullist" href="javascript:;" id="wp_fs_bullist" role="button" tabindex="-1" aria-pressed="false">
<span class="mceIcon mce_bullist"></span>
<span id="wp_fs_bullist_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Unordered list (Alt + Shift + U)'); ?></span>
</a>
</div>
<div>
<a title="<?php _e('Ordered list (Alt + Shift + O)'); ?>" aria-labelledby="wp_fs_numlist_voice" onclick="fullscreen.ol();return false;" class="mceButton mceButtonEnabled mce_numlist" href="javascript:;" id="wp_fs_numlist" role="button" tabindex="-1" aria-pressed="false">
<span class="mceIcon mce_numlist"></span>
<span id="wp_fs_numlist_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Ordered list (Alt + Shift + O)'); ?></span>
</a>
</div>
<div>
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</div>
<div>
<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>
<span tabindex="-1" aria-orientation="vertical" role="separator" class="mceSeparator"></span>
</div>
<div>
<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>
</a>
</div>
<div>
<a title="<?php _e('Unlink (Alt + Shift + S)'); ?>" aria-labelledby="wp_fs_unlink_voice" onclick="fullscreen.unlink();return false;" class="mceButton mce_unlink mceButtonEnabled" href="javascript:;" id="wp_fs_unlink" role="button" tabindex="-1" aria-pressed="false">
<span class="mceIcon mce_unlink"></span>
<span id="wp_fs_unlink_voice" style="display: none;" class="mceVoiceLabel mceIconOnly"><?php _e('Unlink (Alt + Shift + S)'); ?></span>
</a>
</div>
<div id="wp-fullscreen-count"><?php _e('Word Count:'); ?> <span class="word-count">0</span></div>
</div>
</div>
</div>
<div id="wp-fullscreen-wrap" style="width:<?php echo $width; ?>px;">
<label id="wp-fullscreen-title-prompt-text" for="wp-fullscreen-title"><?php echo apply_filters( 'enter_title_here', __( 'Enter title here' ), $post ); ?></label>
<input type="text" id="wp-fullscreen-title" value="" autocomplete="off" />
<div id="wp-fullscreen-container">
<textarea id="wp_mce_fullscreen"></textarea>
</div>
</div>
</div>
<div class="fullscreen-overlay" id="fullscreen-overlay"></div>
<div class="fullscreen-overlay fullscreen-fader fade-600" id="fullscreen-fader"></div>
<?php
}

View File

@@ -1,4 +1,4 @@
var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail;
var tagBox, commentsBox, editPermalink, makeSlugeditClickable, WPSetThumbnailHTML, WPSetThumbnailID, WPRemoveThumbnail, wptitlehint;
// return an array with any duplicate, whitespace or values removed
function array_unique_noempty(a) {
@@ -600,18 +600,29 @@ jQuery(document).ready( function($) {
makeSlugeditClickable();
}
if ( $('#title').val() == '' )
$('#title').siblings('#title-prompt-text').css('visibility', '');
$('#title-prompt-text').click(function(){
$(this).css('visibility', 'hidden').siblings('#title').focus();
});
$('#title').blur(function(){
if (this.value == '')
$(this).siblings('#title-prompt-text').css('visibility', '');
}).focus(function(){
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
}).keydown(function(e){
$(this).siblings('#title-prompt-text').css('visibility', 'hidden');
$(this).unbind(e);
});
wptitlehint = function(id) {
id = id || 'title';
var title = $('#' + id), titleprompt = $('#' + id + '-prompt-text');
if ( title.val() == '' )
titleprompt.css('visibility', '');
titleprompt.click(function(){
$(this).css('visibility', 'hidden');
title.focus();
});
title.blur(function(){
if ( this.value == '' )
titleprompt.css('visibility', '');
}).focus(function(){
titleprompt.css('visibility', 'hidden');
}).keydown(function(e){
titleprompt.css('visibility', 'hidden');
$(this).unbind(e);
});
}
wptitlehint();
});

File diff suppressed because one or more lines are too long

View File

@@ -5,7 +5,7 @@
init : function() {
var t = this, last = 0, co = $('#content');
$('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span id="word-count">0</span>' ) );
$('#wp-word-count').html( wordCountL10n.count.replace( /%d/, '<span class="word-count">0</span>' ) );
t.block = 0;
t.wc(co.val());
co.keyup( function(e) {
@@ -17,7 +17,7 @@
},
wc : function(tx) {
var t = this, w = $('#word-count'), tc = 0;
var t = this, w = $('.word-count'), tc = 0;
if ( t.block ) return;
t.block = 1;

View File

@@ -1 +1 @@
(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span id="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a("#word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));
(function(a){wpWordCount={init:function(){var b=this,c=0,d=a("#content");a("#wp-word-count").html(wordCountL10n.count.replace(/%d/,'<span class="word-count">0</span>'));b.block=0;b.wc(d.val());d.keyup(function(f){if(f.keyCode==c){return true}if(13==f.keyCode||8==c||46==c){b.wc(d.val())}c=f.keyCode;return true})},wc:function(d){var e=this,c=a(".word-count"),b=0;if(e.block){return}e.block=1;setTimeout(function(){if(d){d=d.replace(/<.[^<>]*?>/g," ").replace(/&nbsp;|&#160;/gi," ");d=d.replace(/[0-9.(),;:!?%#$¿'"_+=\\/-]*/g,"");d.replace(/\S\s+/g,function(){b++})}c.html(b.toString());setTimeout(function(){e.block=0},2000)},1)}};a(document).ready(function(){wpWordCount.init()})}(jQuery));

View File

@@ -0,0 +1,314 @@
/**
* PubSub -- A lightweight publish/subscribe implementation. Private use only!
*/
var PubSub = function() {
this.topics = {};
};
PubSub.prototype.subscribe = function( topic, callback ) {
if ( ! this.topics[ topic ] )
this.topics[ topic ] = [];
this.topics[ topic ].push( callback );
return callback;
};
PubSub.prototype.unsubscribe = function( topic, callback ) {
var i, l,
topics = this.topics[ topic ];
if ( ! topics )
return callback || [];
// Clear matching callbacks
if ( callback ) {
for ( i = 0, l = topics.length; i < l; i++ ) {
if ( callback == topics[i] )
topics.splice( i, 1 );
}
return callback;
// Clear all callbacks
} else {
this.topics[ topic ] = [];
return topics;
}
};
PubSub.prototype.publish = function( topic, args ) {
var i, l,
topics = this.topics[ topic ];
if ( ! topics )
return;
args = args || [];
for ( i = 0, l = topics.length; i < l; i++ ) {
topics[i].apply( null, args );
}
};
// Distraction Free Writing (wp-fullscreen) access the API globally using the fullscreen variable.
var fullscreen, wp_fullscreen_enabled = false;
(function($){
var api, ps, bounder;
// Initialize the fullscreen/api object
fullscreen = api = {};
// Create the PubSub (publish/subscribe) interface.
ps = api.pubsub = new PubSub();
api.timer = 0;
api.block = false;
/**
* BOUNDER
*
* Creates a function that publishes start/stop topics.
* Use to throttle events.
*/
bounder = function( start, stop, delay ) {
delay = delay || 1250;
if ( api.block )
return;
api.block = true;
setTimeout( function() {
api.block = false;
}, 500 );
if ( api.timer )
clearTimeout( api.timer );
else
ps.publish( start );
function timed() {
ps.publish( stop );
api.timer = 0;
}
api.timer = setTimeout( timed, delay );
};
/**
* ON / OFF API
*/
api.on = function() {
if ( ! api.ui.element )
api.ui.init();
if ( ! api.visible )
api.ui.fade( 'show', 'showing', 'shown' );
};
api.off = function() {
if ( api.ui.element && api.visible )
api.ui.fade( 'hide', 'hiding', 'hidden' );
};
/**
* GENERAL
*/
api.save = function() {
$('#title').val( $('#wp-fullscreen-title').val() );
tinyMCE.execCommand('wpFullScreenSaveContent');
$('#hiddenaction').val('wp-fullscreen-save-post');
$.post( ajaxurl, $('form#post').serialize(), function(r){
if ( r.message )
$('#wp-fullscreen-saved').html(r.message);
if ( r.last_edited )
$('#wp-fullscreen-last-edit').html(r.last_edited);
}, 'json');
}
set_title_hint = function(title) {
if ( !title.val().length )
title.siblings('label').css( 'visibility', '' );
else
title.siblings('label').css( 'visibility', 'hidden' );
}
ps.subscribe( 'showToolbar', function() {
api.fade.fadein( api.ui.topbar, 600 );
$('#wp-fullscreen-body').addClass('wp-fullscreen-focus');
});
ps.subscribe( 'hideToolbar', function() {
api.fade.fadeout( api.ui.topbar, 600 );
$('#wp-fullscreen-body').removeClass('wp-fullscreen-focus');
});
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', 3000 ); } );
});
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' );
bounder( 'showToolbar', 'hideToolbar', 3000 );
$('#wp-fullscreen-last-edit').html( $('#last-edit').html() );
});
ps.subscribe( 'hiding', function() {
$('#wp-fullscreen-body').hide();
$( document.body ).removeClass( 'fullscreen-active' );
$('#last-edit').html( $('#wp-fullscreen-last-edit').html() );
});
ps.subscribe( 'shown', function() {
api.visible = wp_fullscreen_enabled = true;
});
ps.subscribe( 'hidden', function() {
api.visible = wp_fullscreen_enabled = false;
$('#wp_mce_fullscreen').removeAttr('style');
tinyMCE.execCommand('wpFullScreenClose');
});
/**
* Buttons
*/
api.b = function() {
tinyMCE.execCommand('Bold');
}
api.i = function() {
tinyMCE.execCommand('Italic');
}
api.ul = function() {
tinyMCE.execCommand('InsertUnorderedList');
}
api.ol = function() {
tinyMCE.execCommand('InsertOrderedList');
}
api.link = function() {
tinyMCE.execCommand('WP_Link');
}
api.unlink = function() {
tinyMCE.execCommand('unlink');
}
/**
* UI elements (used for transitioning)
*/
api.ui = {
/**
* Undefined api.ui properties:
* element, topbar
*/
init: function() {
api.ui.element = $('#fullscreen-fader');
api.ui.topbar = $('#fullscreen-topbar');
if ( 'undefined' != wptitlehint )
wptitlehint('wp-fullscreen-title');
},
fade: function( before, during, after ) {
if ( before )
ps.publish( before );
api.fade.fadein( api.ui.element, 600, function() {
if ( during )
ps.publish( during );
api.fade.fadeout( api.ui.element, 600, function() {
if ( after )
ps.publish( after );
})
});
}
};
api.fade = {
transitionend: 'transitionend webkitTransitionEnd OTransitionEnd',
// Sensitivity to allow browsers to render the blank element before animating.
sensitivity: 100,
fadein: function( element, speed, callback ) {
callback = callback || $.noop;
speed = speed || 400;
if ( api.fade.transitions ) {
if ( element.is(':visible') ) {
element.addClass( 'fade-trigger' );
return element;
}
element.show();
setTimeout( function() { element.addClass( 'fade-trigger' ); }, this.sensitivity );
element.one( this.transitionend, function() {
callback();
});
} else {
element.css( 'opacity', 1 ).fadeIn( speed, callback );
}
return element;
},
fadeout: function( element, speed, callback ) {
callback = callback || $.noop;
speed = speed || 400;
if ( ! element.is(':visible') )
return element;
if ( api.fade.transitions ) {
element.removeClass( 'fade-trigger' );
element.one( api.fade.transitionend, function() {
if ( element.hasClass('fade-trigger') )
return;
element.hide();
callback();
});
} else {
element.fadeOut( speed, callback );
}
return element;
},
transitions: (function() {
var s = document.documentElement.style;
return ( typeof ( s.WebkitTransition ) == 'string' ||
typeof ( s.MozTransition ) == 'string' ||
typeof ( s.OTransition ) == 'string' ||
typeof ( s.transition ) == 'string' );
})()
};
/*
api.editor = function() {
return $('#content, #content_ifr').filter(':visible');
};
*/
})(jQuery);

View File

@@ -0,0 +1 @@
var PubSub=function(){this.topics={}};PubSub.prototype.subscribe=function(a,b){if(!this.topics[a]){this.topics[a]=[]}this.topics[a].push(b);return b};PubSub.prototype.unsubscribe=function(b,e){var c,a,d=this.topics[b];if(!d){return e||[]}if(e){for(c=0,a=d.length;c<a;c++){if(e==d[c]){d.splice(c,1)}}return e}else{this.topics[b]=[];return d}};PubSub.prototype.publish=function(c,b){var d,a,e=this.topics[c];if(!e){return}b=b||[];for(d=0,a=e.length;d<a;d++){e[d].apply(null,b)}};var fullscreen,wp_fullscreen_enabled=false;(function(b){var a,d,c;fullscreen=a={};d=a.pubsub=new PubSub();a.timer=0;a.block=false;c=function(h,g,f){f=f||1250;if(a.block){return}a.block=true;setTimeout(function(){a.block=false},500);if(a.timer){clearTimeout(a.timer)}else{d.publish(h)}function e(){d.publish(g);a.timer=0}a.timer=setTimeout(e,f)};a.on=function(){if(!a.ui.element){a.ui.init()}if(!a.visible){a.ui.fade("show","showing","shown")}};a.off=function(){if(a.ui.element&&a.visible){a.ui.fade("hide","hiding","hidden")}};a.save=function(){b("#title").val(b("#wp-fullscreen-title").val());tinyMCE.execCommand("wpFullScreenSaveContent");b("#hiddenaction").val("wp-fullscreen-save-post");b.post(ajaxurl,b("form#post").serialize(),function(e){if(e.message){b("#wp-fullscreen-saved").html(e.message)}if(e.last_edited){b("#wp-fullscreen-last-edit").html(e.last_edited)}},"json")};set_title_hint=function(e){if(!e.val().length){e.siblings("label").css("visibility","")}else{e.siblings("label").css("visibility","hidden")}};d.subscribe("showToolbar",function(){a.fade.fadein(a.ui.topbar,600);b("#wp-fullscreen-body").addClass("wp-fullscreen-focus")});d.subscribe("hideToolbar",function(){a.fade.fadeout(a.ui.topbar,600);b("#wp-fullscreen-body").removeClass("wp-fullscreen-focus")});d.subscribe("show",function(){var e=b("#wp-fullscreen-title").val(b("#title").val());this.set_title_hint(e);b(document).bind("mousemove.fullscreen",function(f){c("showToolbar","hideToolbar",3000)})});d.subscribe("hide",function(){var e=b("#title").val(b("#wp-fullscreen-title").val());this.set_title_hint(e);tinyMCE.execCommand("wpFullScreenSave");b(document).unbind(".fullscreen")});d.subscribe("showing",function(){b("#wp-fullscreen-body").show();b(document.body).addClass("fullscreen-active");c("showToolbar","hideToolbar",3000);b("#wp-fullscreen-last-edit").html(b("#last-edit").html())});d.subscribe("hiding",function(){b("#wp-fullscreen-body").hide();b(document.body).removeClass("fullscreen-active");b("#last-edit").html(b("#wp-fullscreen-last-edit").html())});d.subscribe("shown",function(){a.visible=wp_fullscreen_enabled=true});d.subscribe("hidden",function(){a.visible=wp_fullscreen_enabled=false;b("#wp_mce_fullscreen").removeAttr("style");tinyMCE.execCommand("wpFullScreenClose")});a.b=function(){tinyMCE.execCommand("Bold")};a.i=function(){tinyMCE.execCommand("Italic")};a.ul=function(){tinyMCE.execCommand("InsertUnorderedList")};a.ol=function(){tinyMCE.execCommand("InsertOrderedList")};a.link=function(){tinyMCE.execCommand("WP_Link")};a.unlink=function(){tinyMCE.execCommand("unlink")};a.ui={init:function(){a.ui.element=b("#fullscreen-fader");a.ui.topbar=b("#fullscreen-topbar");if("undefined"!=wptitlehint){wptitlehint("wp-fullscreen-title")}},fade:function(f,e,g){if(f){d.publish(f)}a.fade.fadein(a.ui.element,600,function(){if(e){d.publish(e)}a.fade.fadeout(a.ui.element,600,function(){if(g){d.publish(g)}})})}};a.fade={transitionend:"transitionend webkitTransitionEnd OTransitionEnd",sensitivity:100,fadein:function(e,f,g){g=g||b.noop;f=f||400;if(a.fade.transitions){if(e.is(":visible")){e.addClass("fade-trigger");return e}e.show();setTimeout(function(){e.addClass("fade-trigger")},this.sensitivity);e.one(this.transitionend,function(){g()})}else{e.css("opacity",1).fadeIn(f,g)}return e},fadeout:function(e,f,g){g=g||b.noop;f=f||400;if(!e.is(":visible")){return e}if(a.fade.transitions){e.removeClass("fade-trigger");e.one(a.fade.transitionend,function(){if(e.hasClass("fade-trigger")){return}e.hide();g()})}else{e.fadeOut(f,g)}return e},transitions:(function(){var e=document.documentElement.style;return(typeof(e.WebkitTransition)=="string"||typeof(e.MozTransition)=="string"||typeof(e.OTransition)=="string"||typeof(e.transition)=="string")})()}})(jQuery);

View File

@@ -345,7 +345,7 @@ var photostorage = false;
if ( user_can_richedit() ) {
wp_tiny_mce( true, array( 'height' => '370' ) );
add_action( 'admin_print_footer_scripts', 'wp_tiny_mce_preload_dialogs', 30 );
add_action( 'admin_print_footer_scripts', 'wp_preload_dialogs', 30 );
}
?>
<script type="text/javascript">