From 49c45563546af97eaab0c6f083d68fbc3b4a0ce6 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Wed, 29 Apr 2015 12:11:58 +0300 Subject: [PATCH] Comply to the new JSCS rules. --- .../assets/js/ie10-viewport-bug-workaround.js | 4 +- docs/assets/js/src/application.js | 41 ++++++++++--------- docs/assets/js/src/customizer.js | 41 ++++++++++--------- js/tab.js | 2 + js/tests/unit/modal.js | 18 ++++---- 5 files changed, 56 insertions(+), 50 deletions(-) diff --git a/docs/assets/js/ie10-viewport-bug-workaround.js b/docs/assets/js/ie10-viewport-bug-workaround.js index 7f53b61458..cdf26e9239 100644 --- a/docs/assets/js/ie10-viewport-bug-workaround.js +++ b/docs/assets/js/ie10-viewport-bug-workaround.js @@ -1,6 +1,6 @@ /*! * IE10 viewport hack for Surface/desktop Windows 8 bug - * Copyright 2014 Twitter, Inc. + * Copyright 2014-2015 Twitter, Inc. * Licensed under the Creative Commons Attribution 3.0 Unported License. For * details, see http://creativecommons.org/licenses/by/3.0/. */ @@ -10,6 +10,7 @@ (function () { 'use strict'; + if (navigator.userAgent.match(/IEMobile\/10\.0/)) { var msViewportStyle = document.createElement('style') msViewportStyle.appendChild( @@ -19,4 +20,5 @@ ) document.querySelector('head').appendChild(msViewportStyle) } + })(); diff --git a/docs/assets/js/src/application.js b/docs/assets/js/src/application.js index 56528367c7..35f39f6f03 100644 --- a/docs/assets/js/src/application.js +++ b/docs/assets/js/src/application.js @@ -58,12 +58,12 @@ // theme toggler ;(function () { - var stylesheetLink = $('#bs-theme-stylesheet') - var themeBtn = $('.bs-docs-theme-toggle') + var $stylesheetLink = $('#bs-theme-stylesheet') + var $themeBtn = $('.bs-docs-theme-toggle') var activateTheme = function () { - stylesheetLink.attr('href', stylesheetLink.attr('data-href')) - themeBtn.text('Disable theme preview') + $stylesheetLink.attr('href', $stylesheetLink.attr('data-href')) + $themeBtn.text('Disable theme preview') localStorage.setItem('previewTheme', true) } @@ -71,13 +71,13 @@ activateTheme() } - themeBtn.click(function () { - var href = stylesheetLink.attr('href') + $themeBtn.click(function () { + var href = $stylesheetLink.attr('href') if (!href || href.indexOf('data') === 0) { activateTheme() } else { - stylesheetLink.attr('href', '') - themeBtn.text('Preview theme') + $stylesheetLink.attr('href', '') + $themeBtn.text('Preview theme') localStorage.removeItem('previewTheme') } }) @@ -102,22 +102,22 @@ // Button state demo $('#loading-example-btn').on('click', function () { - var btn = $(this) - btn.button('loading') + var $btn = $(this) + $btn.button('loading') setTimeout(function () { - btn.button('reset') + $btn.button('reset') }, 3000) }) // Modal relatedTarget demo $('#exampleModal').on('show.bs.modal', function (event) { - var button = $(event.relatedTarget) // Button that triggered the modal - var recipient = button.data('whatever') // Extract info from data-* attributes + var $button = $(event.relatedTarget) // Button that triggered the modal + var recipient = $button.data('whatever') // Extract info from data-* attributes // If necessary, you could initiate an AJAX request here (and then do the updating in a callback). // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead. - var modal = $(this) - modal.find('.modal-title').text('New message to ' + recipient) - modal.find('.modal-body input').val(recipient) + var $modal = $(this) + $modal.find('.modal-title').text('New message to ' + recipient) + $modal.find('.modal-body input').val(recipient) }) // Activate animated progress bar @@ -137,11 +137,11 @@ $(this).before(btnHtml) }) var zeroClipboard = new ZeroClipboard($('.btn-clipboard')) - var htmlBridge = $('#global-zeroclipboard-html-bridge') + var $htmlBridge = $('#global-zeroclipboard-html-bridge') // Handlers for ZeroClipboard zeroClipboard.on('load', function () { - htmlBridge + $htmlBridge .data('placement', 'top') .attr('title', 'Copy to clipboard') .tooltip() @@ -155,7 +155,7 @@ // Notify copy success and reset tooltip title zeroClipboard.on('complete', function () { - htmlBridge + $htmlBridge .attr('title', 'Copied!') .tooltip('fixTitle') .tooltip('show') @@ -177,5 +177,6 @@ ;(function () { 'use strict'; - addAnchors('.bs-docs-section > h1, .bs-docs-section > h2, .bs-docs-section > h3, .bs-docs-section > h4, .bs-docs-section > h5'); + + addAnchors('.bs-docs-section > h1, .bs-docs-section > h2, .bs-docs-section > h3, .bs-docs-section > h4, .bs-docs-section > h5') })(); diff --git a/docs/assets/js/src/customizer.js b/docs/assets/js/src/customizer.js index a6d46b5a3b..9b440daa2c 100644 --- a/docs/assets/js/src/customizer.js +++ b/docs/assets/js/src/customizer.js @@ -11,6 +11,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 'use strict'; + var cw = '/*!\n' + ' * Bootstrap v3.3.4 (http://getbootstrap.com)\n' + ' * Copyright 2011-' + new Date().getFullYear() + ' Twitter, Inc.\n' + @@ -18,7 +19,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 ' */\n\n' var supportsFile = window.File && window.FileReader && window.FileList && window.Blob - var importDropTarget = $('#import-drop-target') + var $importDropTarget = $('#import-drop-target') function showError(msg, err) { $('
' + @@ -39,15 +40,15 @@ window.onload = function () { // wait for load in a dumb way because B-0 } function showCallout(msg, showUpTop) { - var callout = $('
' + + var $callout = $('
' + '

Attention!

' + '

' + msg + '

' + '
') if (showUpTop) { - callout.appendTo('.bs-docs-container') + $callout.appendTo('.bs-docs-container') } else { - callout.insertAfter('.bs-customize-download') + $callout.insertAfter('.bs-customize-download') } } @@ -200,8 +201,8 @@ window.onload = function () { // wait for load in a dumb way because B-0 } function generateFonts() { - var glyphicons = $('#less-section [value="glyphicons.less"]:checked') - if (glyphicons.length) { + var $glyphicons = $('#less-section [value="glyphicons.less"]:checked') + if ($glyphicons.length) { return __fonts } } @@ -358,7 +359,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 } function removeImportAlerts() { - importDropTarget.nextAll('.alert').remove() + $importDropTarget.nextAll('.alert').remove() } function handleConfigFileSelect(e) { @@ -380,9 +381,9 @@ window.onload = function () { // wait for load in a dumb way because B-0 } updateCustomizerFromJson(json) - showAlert('success', 'Woohoo! Your configuration was successfully uploaded. Tweak your settings, then hit Download.', importDropTarget) + showAlert('success', 'Woohoo! Your configuration was successfully uploaded. Tweak your settings, then hit Download.', $importDropTarget) } catch (err) { - return showAlert('danger', 'Shucks. We can only read valid .json files. Please try again.', importDropTarget) + return showAlert('danger', 'Shucks. We can only read valid .json files. Please try again.', $importDropTarget) } } @@ -398,7 +399,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 } if (supportsFile) { - importDropTarget + $importDropTarget .on('dragover', handleConfigDragOver) .on('drop', handleConfigFileSelect) } @@ -406,23 +407,23 @@ window.onload = function () { // wait for load in a dumb way because B-0 $('#import-file-select').on('change', handleConfigFileSelect) $('#import-manual-trigger').on('click', removeImportAlerts) - var inputsComponent = $('#less-section input') - var inputsPlugin = $('#plugin-section input') - var inputsVariables = $('#less-variables-section input') + var $inputsComponent = $('#less-section input') + var $inputsPlugin = $('#plugin-section input') + var $inputsVariables = $('#less-variables-section input') $('#less-section .toggle').on('click', function (e) { e.preventDefault() - inputsComponent.prop('checked', !inputsComponent.is(':checked')) + $inputsComponent.prop('checked', !$inputsComponent.is(':checked')) }) $('#plugin-section .toggle').on('click', function (e) { e.preventDefault() - inputsPlugin.prop('checked', !inputsPlugin.is(':checked')) + $inputsPlugin.prop('checked', !$inputsPlugin.is(':checked')) }) $('#less-variables-section .toggle').on('click', function (e) { e.preventDefault() - inputsVariables.val('') + $inputsVariables.val('') }) $('[data-dependencies]').on('click', function () { @@ -431,8 +432,8 @@ window.onload = function () { // wait for load in a dumb way because B-0 if (!dependencies) return dependencies = dependencies.split(',') for (var i = 0; i < dependencies.length; i++) { - var dependency = $('[value="' + dependencies[i] + '"]') - dependency && dependency.prop('checked', true) + var $dependency = $('[value="' + dependencies[i] + '"]') + $dependency && $dependency.prop('checked', true) } }) @@ -442,8 +443,8 @@ window.onload = function () { // wait for load in a dumb way because B-0 if (!dependents) return dependents = dependents.split(',') for (var i = 0; i < dependents.length; i++) { - var dependent = $('[value="' + dependents[i] + '"]') - dependent && dependent.prop('checked', false) + var $dependent = $('[value="' + dependents[i] + '"]') + $dependent && $dependent.prop('checked', false) } }) diff --git a/js/tab.js b/js/tab.js index 685bbc91fc..416189e3d1 100644 --- a/js/tab.js +++ b/js/tab.js @@ -14,7 +14,9 @@ // ==================== var Tab = function (element) { + // jscs:disable requireDollarBeforejQueryAssignment this.element = $(element) + // jscs:enable requireDollarBeforejQueryAssignment } Tab.VERSION = '3.3.4' diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 3c51c2fe2e..217e4d7f76 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -166,16 +166,16 @@ $(function () { assert.expect(3) var done = assert.async() - var div = $('