1/** 2 * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. 3 * @license GNU General Public License version 2 or later; see LICENSE.txt 4 */ 5 6/** 7 * JavaScript behavior to allow selected tab to be remained after save or page reload 8 * keeping state in localstorage 9 */ 10 11jQuery(function() { 12 13 var loadTab = function() { 14 var $ = jQuery.noConflict(); 15 16 jQuery(document).find('a[data-toggle="tab"]').on('click', function(e) { 17 // Store the selected tab href in localstorage 18 window.localStorage.setItem('tab-href', $(e.target).attr('href')); 19 }); 20 21 var activateTab = function(href) { 22 var $el = $('a[data-toggle="tab"]a[href*=' + href + ']'); 23 $el.tab('show'); 24 }; 25 26 var hasTab = function(href){ 27 return $('a[data-toggle="tab"]a[href*=' + href + ']').length; 28 }; 29 30 if (localStorage.getItem('tab-href')) { 31 // When moving from tab area to a different view 32 if(!hasTab(localStorage.getItem('tab-href'))){ 33 localStorage.removeItem('tab-href'); 34 return true; 35 } 36 // Clean default tabs 37 $('a[data-toggle="tab"]').parent().removeClass('active'); 38 var tabhref = localStorage.getItem('tab-href'); 39 // Add active attribute for selected tab indicated by url 40 activateTab(tabhref); 41 // Check whether internal tab is selected (in format <tabname>-<id>) 42 var seperatorIndex = tabhref.indexOf('-'); 43 if (seperatorIndex !== -1) { 44 var singular = tabhref.substring(0, seperatorIndex); 45 var plural = singular + "s"; 46 activateTab(plural); 47 } 48 } 49 }; 50 setTimeout(loadTab, 100); 51 52});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.