Minor cleanup (jshint) of wp-fullscreen.js and /wordpress/plugin.js, see #24067

git-svn-id: https://develop.svn.wordpress.org/trunk@27085 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2014-02-03 21:30:25 +00:00
parent 5ff41a8635
commit 840423ea10
2 changed files with 31 additions and 33 deletions

View File

@ -1,4 +1,4 @@
/* global ajaxurl, deleteUserSetting, setUserSetting, switchEditors, tinymce, tinyMCEPreInit, wp_fullscreen_settings, wpActiveEditor:true, wpLink */ /* global deleteUserSetting, setUserSetting, switchEditors, tinymce, tinyMCEPreInit */
/** /**
* Distraction Free Writing * Distraction Free Writing
* (wp-fullscreen) * (wp-fullscreen)
@ -7,7 +7,6 @@
*/ */
( function( $, window ) { ( function( $, window ) {
var api, ps, s, toggleUI, uiTimer, PubSub, var api, ps, s, toggleUI, uiTimer, PubSub,
oldheight = 0,
uiScrollTop = 0, uiScrollTop = 0,
transitionend = 'transitionend webkitTransitionEnd', transitionend = 'transitionend webkitTransitionEnd',
$body = $( document.body ), $body = $( document.body ),
@ -86,7 +85,6 @@
function _hideUI() { function _hideUI() {
$body.removeClass('wp-dfw-show-ui'); $body.removeClass('wp-dfw-show-ui');
uiShown = false;
} }
/** /**
@ -136,7 +134,7 @@
* @param string mode Optional. Switch to the given mode before opening. * @param string mode Optional. Switch to the given mode before opening.
*/ */
api.on = function() { api.on = function() {
var id, $dfwWrap, editor, titleId; var id, $dfwWrap, titleId;
if ( s.visible ) { if ( s.visible ) {
return; return;
@ -264,7 +262,7 @@
var $hidden = $('#hiddenaction'), var $hidden = $('#hiddenaction'),
oldVal = $hidden.val(), oldVal = $hidden.val(),
$spinner = $('#wp-fullscreen-save .spinner'), $spinner = $('#wp-fullscreen-save .spinner'),
$saveMessage = $('#wp-fullscreen-save .wp-fullscreen-saved-message') $saveMessage = $('#wp-fullscreen-save .wp-fullscreen-saved-message'),
$errorMessage = $('#wp-fullscreen-save .wp-fullscreen-error-message'); $errorMessage = $('#wp-fullscreen-save .wp-fullscreen-error-message');
$spinner.show(); $spinner.show();
@ -405,7 +403,7 @@
$( '#wp-fullscreen-title-placeholder' ).before( s.$dfwTitle.removeClass('wp-fullscreen-title').css( 'width', '' ) ).remove(); $( '#wp-fullscreen-title-placeholder' ).before( s.$dfwTitle.removeClass('wp-fullscreen-title').css( 'width', '' ) ).remove();
} }
s.$dfwWrap.removeClass( 'wp-fullscreen-wrap' ) s.$dfwWrap.removeClass( 'wp-fullscreen-wrap' );
s.$editorContainer.css( 'width', '' ); s.$editorContainer.css( 'width', '' );
s.$dfwTextarea.add( '#' + s.id + '_ifr' ).height( s.origHeight ); s.$dfwTextarea.add( '#' + s.id + '_ifr' ).height( s.origHeight );
@ -455,7 +453,7 @@
*/ */
api.ui = { api.ui = {
init: function() { init: function() {
var toolbar, last = 0; var toolbar;
s.toolbar = toolbar = $('#fullscreen-topbar'); s.toolbar = toolbar = $('#fullscreen-topbar');
s.$fullscreenFader = $('#fullscreen-fader'); s.$fullscreenFader = $('#fullscreen-fader');
@ -465,29 +463,29 @@
$('#wp-fullscreen-mode-bar').hide(); $('#wp-fullscreen-mode-bar').hide();
$document.keyup( function(e) { $document.keyup( function(e) {
var c = e.keyCode || e.charCode, a, data; var c = e.keyCode || e.charCode, modKey;
if ( ! s.visible ) { if ( ! s.visible ) {
return; return;
} }
if ( navigator.platform && navigator.platform.indexOf('Mac') !== -1 ) { if ( navigator.platform && navigator.platform.indexOf('Mac') !== -1 ) {
a = e.ctrlKey; // Ctrl key for Mac modKey = e.ctrlKey; // Ctrl key for Mac
} else { } else {
a = e.altKey; // Alt key for Win & Linux modKey = e.altKey; // Alt key for Win & Linux
} }
if ( a && (61 == c || 107 == c || 187 == c) ) { // + if ( modKey && ( 61 === c || 107 === c || 187 === c ) ) { // +
api.dfwWidth( 25 ); api.dfwWidth( 25 );
e.preventDefault(); e.preventDefault();
} }
if ( a && (45 == c || 109 == c || 189 == c) ) { // - if ( modKey && ( 45 === c || 109 === c || 189 === c ) ) { // -
api.dfwWidth( -25 ); api.dfwWidth( -25 );
e.preventDefault(); e.preventDefault();
} }
if ( a && 48 == c ) { // 0 if ( modKey && 48 === c ) { // 0
api.dfwWidth( 0 ); api.dfwWidth( 0 );
e.preventDefault(); e.preventDefault();
} }
@ -664,12 +662,12 @@
* Automatically updates textarea height. * Automatically updates textarea height.
*/ */
api.bind_resize = function() { api.bind_resize = function() {
s.$dfwTextarea.on( 'keydown.wp-dfw-resize click.wp-dfw-resize paste.wp-dfw-resize', function(e) { s.$dfwTextarea.on( 'keydown.wp-dfw-resize click.wp-dfw-resize paste.wp-dfw-resize', function() {
api.resizeTextarea(e); api.resizeTextarea();
}); });
}; };
api.resizeTextarea = function( event ) { api.resizeTextarea = function() {
var node = s.$dfwTextarea[0]; var node = s.$dfwTextarea[0];
if ( node.scrollHeight > node.clientHeight ) { if ( node.scrollHeight > node.clientHeight ) {

View File

@ -1,4 +1,4 @@
/* global tinymce, autosave, getUserSetting, setUserSetting, switchEditors */ /* global tinymce, getUserSetting, setUserSetting, switchEditors */
tinymce.PluginManager.add( 'wordpress', function( editor ) { tinymce.PluginManager.add( 'wordpress', function( editor ) {
var DOM = tinymce.DOM, wpAdvButton, modKey, style, var DOM = tinymce.DOM, wpAdvButton, modKey, style,
last = 0; last = 0;
@ -127,25 +127,25 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
}); });
// Make sure the "more" tag is in a separate paragraph // Make sure the "more" tag is in a separate paragraph
editor.on( 'PreProcess', function( event ) { editor.on( 'PreProcess', function( event ) {
var more; var more;
if ( event.save ) { if ( event.save ) {
more = editor.dom.select( 'img.wp-more-tag', event.node ); more = editor.dom.select( 'img.wp-more-tag', event.node );
if ( more.length ) { if ( more.length ) {
tinymce.each( more, function( node ) { tinymce.each( more, function( node ) {
var parent = node.parentNode, p; var parent = node.parentNode, p;
if ( parent.nodeName === 'P' && parent.childNodes.length > 1 ) { if ( parent.nodeName === 'P' && parent.childNodes.length > 1 ) {
p = editor.dom.create('p'); p = editor.dom.create('p');
parent.parentNode.insertBefore( p, parent ); parent.parentNode.insertBefore( p, parent );
p.appendChild( node ); p.appendChild( node );
} }
}); });
} }
} }
}); });
// Register commands // Register commands
editor.addCommand( 'WP_More', function( tag ) { editor.addCommand( 'WP_More', function( tag ) {