Define globals and add semicolons to wp-fullscreen.js.

`grunt jshint` now runs clean for WordPress core!

props mattwiebe.
fixes #26029.


git-svn-id: https://develop.svn.wordpress.org/trunk@26667 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-12-05 16:04:59 +00:00
parent 37c9f8df03
commit 1ac4bceecd
2 changed files with 41 additions and 40 deletions

View File

@ -136,7 +136,7 @@ module.exports = function(grunt) {
colors: { colors: {
options: { options: {
processContent: function( src ) { processContent: function( src ) {
return src.replace( /([^/]+)\.css/gi, "$1-rtl.css" ); return src.replace( /([^/]+)\.css/gi, '$1-rtl.css' );
} }
}, },
expand: true, expand: true,

View File

@ -1,3 +1,4 @@
/* global ajaxurl, deleteUserSetting, setUserSetting, switchEditors, tinymce, tinyMCEPreInit, wp_fullscreen_settings, wpActiveEditor:true, wpLink */
/** /**
* PubSub * PubSub
* *
@ -63,7 +64,7 @@ PubSub.prototype.publish = function( topic, args ) {
*/ */
(function($){ (function($){
var api, ps, bounder, s; var api, ps, bounder, s, timer, block, set_title_hint;
// Initialize the fullscreen/api object // Initialize the fullscreen/api object
fullscreen = api = {}; fullscreen = api = {};
@ -80,7 +81,7 @@ PubSub.prototype.publish = function( topic, args ) {
title_id : '', title_id : '',
timer : 0, timer : 0,
toolbar_shown : false toolbar_shown : false
} };
/** /**
* Bounder * Bounder
@ -156,7 +157,7 @@ PubSub.prototype.publish = function( topic, args ) {
if ( ! s.element ) if ( ! s.element )
api.ui.init(); api.ui.init();
s.is_mce_on = s.has_tinymce && typeof( tinyMCE.get(s.editor_id) ) != 'undefined'; s.is_mce_on = s.has_tinymce && typeof( tinymce.get(s.editor_id) ) != 'undefined';
api.ui.fade( 'show', 'showing', 'shown' ); api.ui.fade( 'show', 'showing', 'shown' );
}; };
@ -227,7 +228,7 @@ PubSub.prototype.publish = function( topic, args ) {
}, 'json'); }, 'json');
hidden.val(old); hidden.val(old);
} };
api.savecontent = function() { api.savecontent = function() {
var ed, content; var ed, content;
@ -235,7 +236,7 @@ PubSub.prototype.publish = function( topic, args ) {
if ( s.title_id ) if ( s.title_id )
$('#' + s.title_id).val( $('#wp-fullscreen-title').val() ); $('#' + s.title_id).val( $('#wp-fullscreen-title').val() );
if ( s.mode === 'tinymce' && (ed = tinyMCE.get('wp_mce_fullscreen')) ) { if ( s.mode === 'tinymce' && (ed = tinymce.get('wp_mce_fullscreen')) ) {
content = ed.save(); content = ed.save();
} else { } else {
content = $('#wp_mce_fullscreen').val(); content = $('#wp_mce_fullscreen').val();
@ -243,14 +244,14 @@ PubSub.prototype.publish = function( topic, args ) {
$('#' + s.editor_id).val( content ); $('#' + s.editor_id).val( content );
$(document).triggerHandler('wpcountwords', [ content ]); $(document).triggerHandler('wpcountwords', [ content ]);
} };
set_title_hint = function( title ) { set_title_hint = function( title ) {
if ( ! title.val().length ) 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.dfw_width = function(n) { api.dfw_width = function(n) {
var el = $('#wp-fullscreen-wrap'), w = el.width(); var el = $('#wp-fullscreen-wrap'), w = el.width();
@ -268,7 +269,7 @@ PubSub.prototype.publish = function( topic, args ) {
el.width( w ); el.width( w );
setUserSetting('dfw_width', w); setUserSetting('dfw_width', w);
} };
ps.subscribe( 'showToolbar', function() { ps.subscribe( 'showToolbar', function() {
s.toolbars.removeClass('fade-1000').addClass('fade-300'); s.toolbars.removeClass('fade-1000').addClass('fade-300');
@ -305,7 +306,7 @@ PubSub.prototype.publish = function( topic, args ) {
s.textarea_obj.value = s.qt_canvas.value; s.textarea_obj.value = s.qt_canvas.value;
if ( s.has_tinymce && s.mode === 'tinymce' ) if ( s.has_tinymce && s.mode === 'tinymce' )
tinyMCE.execCommand('wpFullScreenInit'); tinymce.execCommand('wpFullScreenInit');
s.orig_y = $(window).scrollTop(); s.orig_y = $(window).scrollTop();
}); });
@ -349,7 +350,7 @@ PubSub.prototype.publish = function( topic, args ) {
}; };
tinymce.onAddEditor.add(interim_init); tinymce.onAddEditor.add(interim_init);
tinyMCE.init(tinyMCEPreInit.mceInit[s.editor_id]); tinymce.init(tinyMCEPreInit.mceInit[s.editor_id]);
s.is_mce_on = true; s.is_mce_on = true;
} }
@ -373,7 +374,7 @@ PubSub.prototype.publish = function( topic, args ) {
$(s.textarea_obj).unbind('.grow'); $(s.textarea_obj).unbind('.grow');
if ( s.has_tinymce && s.mode === 'tinymce' ) if ( s.has_tinymce && s.mode === 'tinymce' )
tinyMCE.execCommand('wpFullScreenSave'); tinymce.execCommand('wpFullScreenSave');
if ( s.title_id ) if ( s.title_id )
set_title_hint( $('#' + s.title_id) ); set_title_hint( $('#' + s.title_id) );
@ -393,7 +394,7 @@ PubSub.prototype.publish = function( topic, args ) {
$('#wp_mce_fullscreen, #wp-fullscreen-title').removeAttr('style'); $('#wp_mce_fullscreen, #wp-fullscreen-title').removeAttr('style');
if ( s.has_tinymce && s.is_mce_on ) if ( s.has_tinymce && s.is_mce_on )
tinyMCE.execCommand('wpFullScreenClose'); tinymce.execCommand('wpFullScreenClose');
s.textarea_obj.value = ''; s.textarea_obj.value = '';
api.oldheight = 0; api.oldheight = 0;
@ -406,15 +407,15 @@ PubSub.prototype.publish = function( topic, args ) {
if ( !s.has_tinymce || !s.is_mce_on ) if ( !s.has_tinymce || !s.is_mce_on )
return; return;
ed = tinyMCE.get('wp_mce_fullscreen'); ed = tinymce.get('wp_mce_fullscreen');
if ( from === 'html' && to === 'tinymce' ) { if ( from === 'html' && to === 'tinymce' ) {
if ( tinyMCE.get(s.editor_id).getParam('wpautop') && typeof(switchEditors) != 'undefined' ) if ( tinymce.get(s.editor_id).getParam('wpautop') && typeof(switchEditors) != 'undefined' )
s.textarea_obj.value = switchEditors.wpautop( s.textarea_obj.value ); s.textarea_obj.value = switchEditors.wpautop( s.textarea_obj.value );
if ( 'undefined' == typeof(ed) ) if ( 'undefined' == typeof(ed) )
tinyMCE.execCommand('wpFullScreenInit'); tinymce.execCommand('wpFullScreenInit');
else else
ed.show(); ed.show();
@ -436,55 +437,55 @@ PubSub.prototype.publish = function( topic, args ) {
*/ */
api.b = function() { api.b = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Bold'); tinymce.execCommand('Bold');
} };
api.i = function() { api.i = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('Italic'); tinymce.execCommand('Italic');
} };
api.ul = function() { api.ul = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertUnorderedList'); tinymce.execCommand('InsertUnorderedList');
} };
api.ol = function() { api.ol = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('InsertOrderedList'); tinymce.execCommand('InsertOrderedList');
} };
api.link = function() { api.link = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('WP_Link'); tinymce.execCommand('WP_Link');
else else
wpLink.open(); wpLink.open();
} };
api.unlink = function() { api.unlink = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('unlink'); tinymce.execCommand('unlink');
} };
api.atd = function() { api.atd = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('mceWritingImprovementTool'); tinymce.execCommand('mceWritingImprovementTool');
} };
api.help = function() { api.help = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('WP_Help'); tinymce.execCommand('WP_Help');
} };
api.blockquote = function() { api.blockquote = function() {
if ( s.has_tinymce && 'tinymce' === s.mode ) if ( s.has_tinymce && 'tinymce' === s.mode )
tinyMCE.execCommand('mceBlockQuote'); tinymce.execCommand('mceBlockQuote');
} };
api.medialib = function() { api.medialib = function() {
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) if ( typeof wp !== 'undefined' && wp.media && wp.media.editor )
wp.media.editor.open(s.editor_id); wp.media.editor.open(s.editor_id);
} };
api.refresh_buttons = function( fade ) { api.refresh_buttons = function( fade ) {
fade = fade || false; fade = fade || false;
@ -509,7 +510,7 @@ PubSub.prototype.publish = function( topic, args ) {
else else
$('#wp-fullscreen-button-bar').removeClass('wp-html-mode'); $('#wp-fullscreen-button-bar').removeClass('wp-html-mode');
} }
} };
/** /**
* UI Elements * UI Elements
@ -591,12 +592,12 @@ PubSub.prototype.publish = function( topic, args ) {
}); });
} }
topbar.mouseenter(function(e){ topbar.mouseenter(function(){
s.toolbars.addClass('fullscreen-make-sticky'); s.toolbars.addClass('fullscreen-make-sticky');
$( document ).unbind( '.fullscreen' ); $( document ).unbind( '.fullscreen' );
clearTimeout( s.timer ); clearTimeout( s.timer );
s.timer = 0; s.timer = 0;
}).mouseleave(function(e){ }).mouseleave(function(){
s.toolbars.removeClass('fullscreen-make-sticky'); s.toolbars.removeClass('fullscreen-make-sticky');
if ( s.visible ) if ( s.visible )
@ -619,7 +620,7 @@ PubSub.prototype.publish = function( topic, args ) {
api.fade.Out( s.element, 600, function() { api.fade.Out( s.element, 600, function() {
if ( after ) if ( after )
ps.publish( after ); ps.publish( after );
}) });
}); });
} }
}; };
@ -712,7 +713,7 @@ PubSub.prototype.publish = function( topic, args ) {
$(s.textarea_obj).bind('keypress.grow click.grow paste.grow', function(){ $(s.textarea_obj).bind('keypress.grow click.grow paste.grow', function(){
setTimeout( api.resize_textarea, 200 ); setTimeout( api.resize_textarea, 200 );
}); });
} };
api.oldheight = 0; api.oldheight = 0;
api.resize_textarea = function() { api.resize_textarea = function() {