Joeytje50 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/184138

Change subject: Fix jslint errors.
......................................................................

Fix jslint errors.

On the previous commit, jslint didn't mention these errors until
jenkins-bot decided to merge it, so this will have to be a seperate
commit.
See https://integration.wikimedia.org/ci/job/mwext-Tabs-jslint/3/console

Change-Id: Ic437dfdb79fea6f983531914951b875929723385
---
M ext.tabs.js
1 file changed, 35 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Tabs 
refs/changes/38/184138/1

diff --git a/ext.tabs.js b/ext.tabs.js
index 5ed0c87..3e71a30 100644
--- a/ext.tabs.js
+++ b/ext.tabs.js
@@ -1,7 +1,29 @@
-$(function() {
+jQuery(function($) {
+       /**
+        * Imitates the normal feature in browsers to scroll to an id that has 
the same id as the url fragment/hash.
+        * This makes it unnecessary to use actual ids on the tabs, which could 
cause the same id to occur twice in the same document.
+        * Does not scroll to exactly the tab's height, but just a bit above it.
+        */
+       function moveToHash() {
+               var hash = location.hash.substr(1).replace(/_/g,' ').trim();
+               if (!hash || $(location.hash).length) {
+                       return; // if there's no hash defined, or an element on 
the page with the same hash already, stop looking for tabs
+               }
+               $('.tabs-tabbox 
.tabs-label:contains('+hash+')').each(function() {
+                       // double-check if the hash is indeed exactly the same 
as the label.
+                       // Does not match if hash is only a part of the label's 
contents, unlike jQuery's :contains() selector
+                       if (this.innerHTML.trim() !== hash) {
+                               return true; // continue the $.each() function
+                       }
+                       this.click(); // open the selected tab by default.
+                       document.documentElement.scrollTop = this.offsetTop;
+                       return false; // stop the $.each() function after the 
first match.
+               });
+       }
+
        // Credit for this testing method: 2astalavista @ 
http://stackoverflow.com/a/21095568/1256925
        // The font will be sans-serif if the :not() property is supported. The 
margin will be 1px if the sibling selector is supported.
-       if ($('#tabs-inputform').css('font-family').replace(/["']/g,'') == 
'sans-serif' && $('#tabs-inputform').css('margin') == '1px') {
+       if ($('#tabs-inputform').css('font-family').replace(/["']/g,'') === 
'sans-serif' && $('#tabs-inputform').css('margin') === '1px') {
                $(function() {
                        $('body').addClass('tabs-oldbrowserscript'); // Make 
the unselected tabs hide when the browser loads this script
                        $('.tabs-label').click(function(e) {
@@ -9,9 +31,13 @@
                                return false;
                        });
                        $('.tabs-input').each(function() {
-                               if (this.checked) $(this).addClass('checked'); 
// Adds checked class to each checked box
+                               if (this.checked) {
+                                       $(this).addClass('checked'); // Adds 
checked class to each checked box
+                               }
                        }).change(function() {
-                               if (!this.checked) return 
$(this).removeClass('checked'); // for toggleboxes
+                               if (!this.checked) {
+                                       return $(this).removeClass('checked'); 
// for toggleboxes
+                               }
                                
$(this).siblings('.checked').removeClass('checked'); // Uncheck all currently 
checked siblings
                                $(this).addClass('checked'); // and do check 
this box
                                
$(this).parents('.tabs').toggleClass('tabs').toggleClass('tabs'); // remove and 
readd class to recalculate styles for its children.
@@ -22,23 +48,6 @@
        } else {
                $(moveToHash);
        }
-       /**
-        * Imitates the normal feature in browsers to scroll to an id that has 
the same id as the url fragment/hash.
-        * This makes it unnecessary to use actual ids on the tabs, which could 
cause the same id to occur twice in the same document.
-        * Does not scroll to exactly the tab's height, but just a bit above it.
-        */
-       function moveToHash() {
-               var hash = location.hash.substr(1).replace(/_/g,' ').trim();
-               if (!hash || $(location.hash).length) return; // if there's no 
hash defined, or an element on the page with the same hash already, stop 
looking for tabs
-               $('.tabs-tabbox 
.tabs-label:contains('+hash+')').each(function() {
-                       // double-check if the hash is indeed exactly the same 
as the label.
-                       // Does not match if hash is only a part of the label's 
contents, unlike jQuery's :contains() selector
-                       if (this.innerHTML.trim() !== hash) return true; // 
continue the $.each() function
-                       this.click(); // open the selected tab by default.
-                       document.documentElement.scrollTop = this.offsetTop;
-                       return false; // stop the $.each() function after the 
first match.
-               });
-       }
 
        /*
         * System to fix toggle boxes in Android Browser
@@ -46,17 +55,19 @@
         * Idea for the use of <detail> and <summary> based on 
http://stackoverflow.com/q/21357641/1256925
         */
        var nua = navigator.userAgent;
-       var is_android = (nua.indexOf('Mozilla/5.0') > -1 && 
nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1 && 
nua.indexOf('Chrome') === -1);
+       var isAndroid = (nua.indexOf('Mozilla/5.0') > -1 && 
nua.indexOf('Android ') > -1 && nua.indexOf('AppleWebKit') > -1 && 
nua.indexOf('Chrome') === -1);
        function replaces() { //General replacement function for both tags
                var tagName = $(this).is('.tabs-container') ? 'details' : 
'summary'; //determine the required tag name
                var $newNode = $('<'+tagName+'/>').html($(this).html());
                for (var i=0;i<this.attributes.length;i++) { //copy all 
attributes from the original element
-                       if (this.attributes[i].nodeName === 'for') continue; 
//don't copy the label's for="" attribute, since it's not needed here.
+                       if (this.attributes[i].nodeName === 'for') {
+                               continue; //don't copy the label's for="" 
attribute, since it's not needed here.
+                       }
                        $newNode.attr(this.attributes[i].nodeName, 
this.attributes[i].value);
                }
                return $newNode;
        }
-       if (is_android) {
+       if (isAndroid) {
                $('.tabs-togglebox .tabs-container').not('.tabs-dropdown 
.tabs-container').replaceWith(replaces); //do not select dropdowns, which 
already work in Android
                $('.tabs-togglebox .tabs-label').not('.tabs-dropdown 
.tabs-label').each(function() {
                        if ($(this).prevAll('input').prop('checked')) { 
//preserve open state of the toggle box

-- 
To view, visit https://gerrit.wikimedia.org/r/184138
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic437dfdb79fea6f983531914951b875929723385
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Tabs
Gerrit-Branch: master
Gerrit-Owner: Joeytje50 <joeytj...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to