From 1ac4bceecd94d26059f0bb12b0561e7d7f9dce2d Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 5 Dec 2013 16:04:59 +0000 Subject: [PATCH] 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 --- Gruntfile.js | 2 +- src/wp-admin/js/wp-fullscreen.js | 79 ++++++++++++++++---------------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 3682fca7e0..2a3323dd8c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -136,7 +136,7 @@ module.exports = function(grunt) { colors: { options: { processContent: function( src ) { - return src.replace( /([^/]+)\.css/gi, "$1-rtl.css" ); + return src.replace( /([^/]+)\.css/gi, '$1-rtl.css' ); } }, expand: true, diff --git a/src/wp-admin/js/wp-fullscreen.js b/src/wp-admin/js/wp-fullscreen.js index fa17ce4409..6ffde31dc0 100644 --- a/src/wp-admin/js/wp-fullscreen.js +++ b/src/wp-admin/js/wp-fullscreen.js @@ -1,3 +1,4 @@ +/* global ajaxurl, deleteUserSetting, setUserSetting, switchEditors, tinymce, tinyMCEPreInit, wp_fullscreen_settings, wpActiveEditor:true, wpLink */ /** * PubSub * @@ -63,7 +64,7 @@ PubSub.prototype.publish = function( topic, args ) { */ (function($){ - var api, ps, bounder, s; + var api, ps, bounder, s, timer, block, set_title_hint; // Initialize the fullscreen/api object fullscreen = api = {}; @@ -80,7 +81,7 @@ PubSub.prototype.publish = function( topic, args ) { title_id : '', timer : 0, toolbar_shown : false - } + }; /** * Bounder @@ -156,7 +157,7 @@ PubSub.prototype.publish = function( topic, args ) { if ( ! s.element ) 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' ); }; @@ -227,7 +228,7 @@ PubSub.prototype.publish = function( topic, args ) { }, 'json'); hidden.val(old); - } + }; api.savecontent = function() { var ed, content; @@ -235,7 +236,7 @@ PubSub.prototype.publish = function( topic, args ) { if ( s.title_id ) $('#' + 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(); } else { content = $('#wp_mce_fullscreen').val(); @@ -243,14 +244,14 @@ PubSub.prototype.publish = function( topic, args ) { $('#' + s.editor_id).val( content ); $(document).triggerHandler('wpcountwords', [ content ]); - } + }; set_title_hint = function( title ) { if ( ! title.val().length ) title.siblings('label').css( 'visibility', '' ); else title.siblings('label').css( 'visibility', 'hidden' ); - } + }; api.dfw_width = function(n) { var el = $('#wp-fullscreen-wrap'), w = el.width(); @@ -268,7 +269,7 @@ PubSub.prototype.publish = function( topic, args ) { el.width( w ); setUserSetting('dfw_width', w); - } + }; ps.subscribe( 'showToolbar', function() { 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; if ( s.has_tinymce && s.mode === 'tinymce' ) - tinyMCE.execCommand('wpFullScreenInit'); + tinymce.execCommand('wpFullScreenInit'); s.orig_y = $(window).scrollTop(); }); @@ -349,7 +350,7 @@ PubSub.prototype.publish = function( topic, args ) { }; tinymce.onAddEditor.add(interim_init); - tinyMCE.init(tinyMCEPreInit.mceInit[s.editor_id]); + tinymce.init(tinyMCEPreInit.mceInit[s.editor_id]); s.is_mce_on = true; } @@ -373,7 +374,7 @@ PubSub.prototype.publish = function( topic, args ) { $(s.textarea_obj).unbind('.grow'); if ( s.has_tinymce && s.mode === 'tinymce' ) - tinyMCE.execCommand('wpFullScreenSave'); + tinymce.execCommand('wpFullScreenSave'); if ( 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'); if ( s.has_tinymce && s.is_mce_on ) - tinyMCE.execCommand('wpFullScreenClose'); + tinymce.execCommand('wpFullScreenClose'); s.textarea_obj.value = ''; api.oldheight = 0; @@ -406,15 +407,15 @@ PubSub.prototype.publish = function( topic, args ) { if ( !s.has_tinymce || !s.is_mce_on ) return; - ed = tinyMCE.get('wp_mce_fullscreen'); + ed = tinymce.get('wp_mce_fullscreen'); 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 ); if ( 'undefined' == typeof(ed) ) - tinyMCE.execCommand('wpFullScreenInit'); + tinymce.execCommand('wpFullScreenInit'); else ed.show(); @@ -436,55 +437,55 @@ PubSub.prototype.publish = function( topic, args ) { */ api.b = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('Bold'); - } + tinymce.execCommand('Bold'); + }; api.i = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('Italic'); - } + tinymce.execCommand('Italic'); + }; api.ul = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('InsertUnorderedList'); - } + tinymce.execCommand('InsertUnorderedList'); + }; api.ol = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('InsertOrderedList'); - } + tinymce.execCommand('InsertOrderedList'); + }; api.link = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('WP_Link'); + tinymce.execCommand('WP_Link'); else wpLink.open(); - } + }; api.unlink = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('unlink'); - } + tinymce.execCommand('unlink'); + }; api.atd = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('mceWritingImprovementTool'); - } + tinymce.execCommand('mceWritingImprovementTool'); + }; api.help = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('WP_Help'); - } + tinymce.execCommand('WP_Help'); + }; api.blockquote = function() { if ( s.has_tinymce && 'tinymce' === s.mode ) - tinyMCE.execCommand('mceBlockQuote'); - } + tinymce.execCommand('mceBlockQuote'); + }; api.medialib = function() { if ( typeof wp !== 'undefined' && wp.media && wp.media.editor ) wp.media.editor.open(s.editor_id); - } + }; api.refresh_buttons = function( fade ) { fade = fade || false; @@ -509,7 +510,7 @@ PubSub.prototype.publish = function( topic, args ) { else $('#wp-fullscreen-button-bar').removeClass('wp-html-mode'); } - } + }; /** * 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'); $( document ).unbind( '.fullscreen' ); clearTimeout( s.timer ); s.timer = 0; - }).mouseleave(function(e){ + }).mouseleave(function(){ s.toolbars.removeClass('fullscreen-make-sticky'); if ( s.visible ) @@ -619,7 +620,7 @@ PubSub.prototype.publish = function( topic, args ) { api.fade.Out( s.element, 600, function() { if ( 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(){ setTimeout( api.resize_textarea, 200 ); }); - } + }; api.oldheight = 0; api.resize_textarea = function() {