[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [14360] ResponsiveTabs: update from upstream
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [14360] ResponsiveTabs: update from upstream |
Date: |
Sun, 15 Nov 2015 21:50:53 +0000 |
Revision: 14360
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=14360
Author: sigurdne
Date: 2015-11-15 21:50:53 +0000 (Sun, 15 Nov 2015)
Log Message:
-----------
ResponsiveTabs: update from upstream
Modified Paths:
--------------
branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.js
branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.min.js
Modified:
branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.js
===================================================================
--- branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.js
2015-11-14 00:13:52 UTC (rev 14359)
+++ branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.js
2015-11-15 21:50:53 UTC (rev 14360)
@@ -1,8 +1,8 @@
-/*
+/*!
* Project: jquery.responsiveTabs.js
* Description: A plugin that creates responsive tabs, optimized for all
devices
* Author: Jelle Kralt (address@hidden)
- * Version: 1.4.0
+ * Version: 1.5.1
* License: MIT
*/
@@ -11,13 +11,18 @@
/** Default settings */
var defaults = {
active: null,
+ event: 'click',
disabled: [],
collapsible: 'accordion',
startCollapsed: false,
rotate: false,
setHash: false,
animation: 'default',
+ animationQueue: false,
duration: 500,
+ scrollToAccordion: false,
+ scrollToAccordionOffset: 0,
+ accordionTabElement: '<div></div>',
activate: function(){},
deactivate: function(){},
load: function(){},
@@ -27,6 +32,8 @@
stateActive: 'r-tabs-state-active',
stateDisabled: 'r-tabs-state-disabled',
stateExcluded: 'r-tabs-state-excluded',
+ container: 'r-tabs',
+ ul: 'r-tabs-nav',
tab: 'r-tabs-tab',
anchor: 'r-tabs-anchor',
panel: 'r-tabs-panel',
@@ -108,36 +115,26 @@
// Load: this event is called when the plugin has been loaded
this.$element.bind('tabs-load', function(e) {
- var tabRef = _this._getTabRefBySelector(window.location.hash);
- var firstTab;
+ var startTab;
_this._setState(e); // Set state
// Check if the panel should be collaped on load
if(_this.options.startCollapsed !== true &&
!(_this.options.startCollapsed === 'accordion' && _this.state === 'accordion'))
{
- // Check if the page has a hash set that is linked to a tab
- if(tabRef >= 0 && !_this._getTab(tabRef).disabled) {
- // If so, set the current tab to the linked tab
- firstTab = _this._getTab(tabRef);
- } else if(_this.options.active > 0 &&
!_this._getTab(_this.options.active).disabled) {
- firstTab = _this._getTab(_this.options.active);
- } else {
- // If not, just get the first one
- firstTab = _this._getTab(0);
- }
+ startTab = _this._getStartTab();
// Open the initial tab
- _this._openTab(e, firstTab); // Open first tab
+ _this._openTab(e, startTab); // Open first tab
// Call the callback function
- _this.options.load.call(this, e, firstTab); // Call the load
callback
+ _this.options.load.call(this, e, startTab); // Call the load
callback
}
});
// Trigger loaded event
this.$element.trigger('tabs-load');
};
-
+
//
// PRIVATE FUNCTIONS
//
@@ -153,8 +150,8 @@
var id = 0;
// Add the classes to the basic html elements
- this.$element.addClass('r-tabs'); // Tab container
- $ul.addClass('r-tabs-nav'); // List container
+ this.$element.addClass(_this.options.classes.container); // Tab
container
+ $ul.addClass(_this.options.classes.ul); // List container
// Get tab buttons and store their data in an array
$('li', $ul).each(function() {
@@ -169,11 +166,11 @@
panelSelector = $anchor.attr('href');
onClickMethod = $anchor.attr('onclick');
$panel = $(panelSelector);
- $accordionTab = $('<div></div>').insertBefore($panel);
- $accordionAnchor = $('<a></a>').attr('href', panelSelector);
+ $accordionTab =
$(_this.options.accordionTabElement).insertBefore($panel);
+ $accordionAnchor = $('<a></a>').attr('href',
panelSelector).html($anchor.html()).appendTo($accordionTab);
$accordionAnchor.attr('onclick', onClickMethod);
- $accordionAnchor.html($anchor.html()).appendTo($accordionTab);
+
var oTab = {
_ignoreHashChange: false,
id: id,
@@ -219,32 +216,39 @@
*/
ResponsiveTabs.prototype._loadEvents = function() {
var _this = this;
- // Define click event on a tab element
- var fClick = function(e) {
+
+ // Define activate event on a tab element
+ var fActivate = function(e) {
var current = _this._getCurrentTab(); // Fetch current tab
- var clickedTab = e.data.tab;
+ var activatedTab = e.data.tab;
e.preventDefault();
// Make sure this tab isn't disabled
- if(!clickedTab.disabled) {
+ if(!activatedTab.disabled) {
// Check if hash has to be set in the URL location
if(_this.options.setHash) {
- window.location.hash = clickedTab.selector;
+ // Set the hash using the history api if available to
tackle Chromes repaint bug on hash change
+ if(history.pushState) {
+ history.pushState(null, null, activatedTab.selector);
+ } else {
+ // Otherwise fallback to the hash update for sites
that don't support the history api
+ window.location.hash = activatedTab.selector;
+ }
}
e.data.tab._ignoreHashChange = true;
- // Check if the clicked tab isnt the current one or if its
collapsible. If not, do nothing
- if(current !== clickedTab || _this._isCollapisble()) {
- // The clicked tab is either another tab of the current
one. If it's the current tab it is collapsible
+ // Check if the activated tab isnt the current one or if its
collapsible. If not, do nothing
+ if(current !== activatedTab || _this._isCollapisble()) {
+ // The activated tab is either another tab of the current
one. If it's the current tab it is collapsible
// Either way, the current tab can be closed
_this._closeTab(e, current);
- // Check if the clicked tab isnt the current one or if it
isnt collapsible
- if(current !== clickedTab || !_this._isCollapisble()) {
- _this._openTab(e, clickedTab, false, true);
+ // Check if the activated tab isnt the current one or if
it isnt collapsible
+ if(current !== activatedTab || !_this._isCollapisble()) {
+ _this._openTab(e, activatedTab, false, true);
}
}
}
@@ -252,19 +256,43 @@
// Loop tabs
for (var i=0; i<this.tabs.length; i++) {
- // Add click function to the tab and accordion selection element
- this.tabs[i].anchor.on('click', {tab: _this.tabs[i]}, fClick);
- this.tabs[i].accordionAnchor.on('click', {tab: _this.tabs[i]},
fClick);
+ // Add activate function to the tab and accordion selection element
+ this.tabs[i].anchor.on(_this.options.event, {tab: _this.tabs[i]},
fActivate);
+ this.tabs[i].accordionAnchor.on(_this.options.event, {tab:
_this.tabs[i]}, fActivate);
}
};
/**
+ * This function gets the tab that should be opened at start
+ * @returns {Object} Tab object
+ */
+ ResponsiveTabs.prototype._getStartTab = function() {
+ var tabRef = this._getTabRefBySelector(window.location.hash);
+ var startTab;
+
+ // Check if the page has a hash set that is linked to a tab
+ if(tabRef >= 0 && !this._getTab(tabRef).disabled) {
+ // If so, set the current tab to the linked tab
+ startTab = this._getTab(tabRef);
+ } else if(this.options.active > 0 &&
!this._getTab(this.options.active).disabled) {
+ startTab = this._getTab(this.options.active);
+ } else {
+ // If not, just get the first one
+ startTab = this._getTab(0);
+ }
+
+ return startTab;
+ };
+
+ /**
* This function sets the current state of the plugin
* @param {Event} e - The event that triggers the state change
*/
- ResponsiveTabs.prototype._setState = function() {
+ ResponsiveTabs.prototype._setState = function(e) {
var $ul = $('ul', this.$element);
var oldState = this.state;
+ var startCollapsedIsState = (typeof this.options.startCollapsed ===
'string');
+ var startTab;
// The state is based on the visibility of the tabs list
if($ul.is(':visible')){
@@ -275,9 +303,18 @@
this.state = 'accordion';
}
- // If the new state is different from the old state, the state
activate trigger must be called
+ // If the new state is different from the old state
if(this.state !== oldState) {
+ // If so, the state activate trigger must be called
this.$element.trigger('tabs-activate-state', {oldState: oldState,
newState: this.state});
+
+ // Check if the state switch should open a tab
+ if(oldState && startCollapsedIsState &&
this.options.startCollapsed !== this.state && this._getCurrentTab() ===
undefined) {
+ // Get initial tab
+ startTab = this._getStartTab(e);
+ // Open the initial tab
+ this._openTab(e, startTab); // Open first tab
+ }
}
};
@@ -290,6 +327,7 @@
*/
ResponsiveTabs.prototype._openTab = function(e, oTab, closeCurrent,
stopRotation) {
var _this = this;
+ var scrollOffset;
// Check if the current tab has to be closed
if(closeCurrent) {
@@ -311,6 +349,24 @@
_this._doTransition(oTab.panel, _this.options.animation, 'open',
function() {
// When finished, set active class to the panel
oTab.panel.removeClass(_this.options.classes.stateDefault).addClass(_this.options.classes.stateActive);
+
+ // And if enabled and state is accordion, scroll to the accordion
tab
+ if(_this.getState() === 'accordion' &&
_this.options.scrollToAccordion && (!_this._isInView(oTab.accordionTab) ||
_this.options.animation !== 'default')) {
+
+ // Add offset element's height to scroll position
+ scrollOffset = oTab.accordionTab.offset().top -
_this.options.scrollToAccordionOffset;
+
+ // Check if the animation option is enabled, and if the
duration isn't 0
+ if(_this.options.animation !== 'default' &&
_this.options.duration > 0) {
+ // If so, set scrollTop with animate and use the
'animation' duration
+ $('html, body').animate({
+ scrollTop: scrollOffset
+ }, _this.options.duration);
+ } else {
+ // If not, just set scrollTop
+ $('html, body').scrollTop(scrollOffset);
+ }
+ }
});
this.$element.trigger('tabs-activate', oTab);
@@ -323,8 +379,17 @@
*/
ResponsiveTabs.prototype._closeTab = function(e, oTab) {
var _this = this;
+ var doQueueOnState = typeof _this.options.animationQueue === 'string';
+ var doQueue;
if(oTab !== undefined) {
+ if(doQueueOnState && _this.getState() ===
_this.options.animationQueue) {
+ doQueue = true;
+ } else if(doQueueOnState) {
+ doQueue = false;
+ } else {
+ doQueue = _this.options.animationQueue;
+ }
// Deactivate tab
oTab.active = false;
@@ -336,7 +401,7 @@
// Set default class to the accordion tab button and tab panel
oTab.accordionTab.removeClass(_this.options.classes.stateActive).addClass(_this.options.classes.stateDefault);
oTab.panel.removeClass(_this.options.classes.stateActive).addClass(_this.options.classes.stateDefault);
- }, true);
+ }, !doQueue);
this.$element.trigger('tabs-deactivate', oTab);
}
@@ -468,6 +533,18 @@
};
//
+ // HELPER FUNCTIONS
+ //
+
+ ResponsiveTabs.prototype._isInView = function($element) {
+ var docViewTop = $(window).scrollTop(),
+ docViewBottom = docViewTop + $(window).height(),
+ elemTop = $element.offset().top,
+ elemBottom = elemTop + $element.height();
+ return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
+ };
+
+ //
// PUBLIC FUNCTIONS
//
@@ -497,6 +574,32 @@
};
/**
+ * This function enables a tab
+ * @param {Integer} tabRef - Numeric tab reference
+ */
+ ResponsiveTabs.prototype.enable = function(tabRef) {
+ var oTab = this._getTab(tabRef);
+ if(oTab){
+ oTab.disabled = false;
+
oTab.tab.addClass(this.options.classes.stateDefault).removeClass(this.options.classes.stateDisabled);
+
oTab.accordionTab.addClass(this.options.classes.stateDefault).removeClass(this.options.classes.stateDisabled);
+ }
+ };
+
+ /**
+ * This function disable a tab
+ * @param {Integer} tabRef - Numeric tab reference
+ */
+ ResponsiveTabs.prototype.disable = function(tabRef) {
+ var oTab = this._getTab(tabRef);
+ if(oTab){
+ oTab.disabled = true;
+
oTab.tab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled);
+
oTab.accordionTab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled);
+ }
+ };
+
+ /**
* This function gets the current state of the plugin
* @returns {String} State of the plugin
*/
@@ -529,6 +632,17 @@
this.rotateInterval = 0;
};
+ /**
+ * This function can be used to get/set options
+ * @return {any} Option value
+ */
+ ResponsiveTabs.prototype.option = function(key, value) {
+ if(value) {
+ this.options[key] = value;
+ }
+ return this.options[key];
+ };
+
/** jQuery wrapper */
$.fn.responsiveTabs = function ( options ) {
var args = arguments;
@@ -555,4 +669,4 @@
}
};
-}(jQuery, window));
+}(jQuery, window));
\ No newline at end of file
Modified:
branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.min.js
===================================================================
---
branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.min.js
2015-11-14 00:13:52 UTC (rev 14359)
+++
branches/dev-syncromind/phpgwapi/js/jquery/tabs/jquery.responsiveTabs.min.js
2015-11-15 21:50:53 UTC (rev 14360)
@@ -2,6 +2,7 @@
* Project: jquery.responsiveTabs.js
* Description: A plugin that creates responsive tabs, optimized for all
devices
* Author: Jelle Kralt (address@hidden)
- * Version: 1.4.0
+ * Version: 1.5.1
* License: MIT
- */(function(e,t,n){function
i(t,n){this.element=t;this.$element=e(t);this.tabs=[];this.state="";this.rotateInterval=0;this.$queue=e({});this.options=e.extend({},r,n);this.init()}var
r={active:null,disabled:[],collapsible:"accordion",startCollapsed:!1,rotate:!1,setHash:!1,animation:"default",duration:500,activate:function(){},deactivate:function(){},load:function(){},activateState:function(){},classes:{stateDefault:"r-tabs-state-default",stateActive:"r-tabs-state-active",stateDisabled:"r-tabs-state-disabled",stateExcluded:"r-tabs-state-excluded",tab:"r-tabs-tab",anchor:"r-tabs-anchor",panel:"r-tabs-panel",accordionTitle:"r-tabs-accordion-title"}};i.prototype.init=function(){var
n=this;this.tabs=this._loadElements();this._loadClasses();this._loadEvents();e(t).on("resize",function(e){n._setState(e)});e(t).on("hashchange",function(e){var
r=n._getTabRefBySelector(t.location.hash),i=n._getTab(r);r>=0&&!i._ignoreHashChange&&!i.disabled&&n._openTab(e,n._getTab(r),!0)});this.options.rotate!==!1&&this.startRotation();this.$element.bind("tabs-activate",function(e,t){n.options.activate.call(this,e,t)});this.$element.bind("tabs-deactivate",function(e,t){n.options.deactivate.call(this,e,t)});this.$element.bind("tabs-activate-state",function(e,t){n.options.activateState.call(this,e,t)});this.$element.bind("tabs-load",function(e){var
r=n._getTabRefBySelector(t.location.hash),i;n._setState(e);if(n.options.startCollapsed!==!0&&(n.options.startCollapsed!=="accordion"||n.state!=="accordion")){r>=0&&!n._getTab(r).disabled?i=n._getTab(r):n.options.active>0&&!n._getTab(n.options.active).disabled?i=n._getTab(n.options.active):i=n._getTab(0);n._openTab(e,i);n.options.load.call(this,e,i)}});this.$element.trigger("tabs-load")};i.prototype._loadElements=function(){var
t=this,n=this.$element.children("ul"),r=[],i=0;this.$element.addClass("r-tabs");n.addClass("r-tabs-nav");e("li",n).each(function(){var
n=e(this),s=n.hasClass(t.options.classes.stateExcluded),o,u,a,f,l;if(!s){o=e("a",n);l=o.attr("href");u=e(l);a=e("<div></div>").insertBefore(u);f=e("<a></a>").attr("href",l).html(o.html()).appendTo(a);var
c={_ignoreHashChange:!1,id:i,disabled:e.inArray(i,t.options.disabled)!==-1,tab:e(this),anchor:e("a",n),panel:u,selector:l,accordionTab:a,accordionAnchor:f,active:!1};i++;r.push(c)}});return
r};i.prototype._loadClasses=function(){for(var
e=0;e<this.tabs.length;e++){this.tabs[e].tab.addClass(this.options.classes.stateDefault).addClass(this.options.classes.tab);this.tabs[e].anchor.addClass(this.options.classes.anchor);this.tabs[e].panel.addClass(this.options.classes.stateDefault).addClass(this.options.classes.panel);this.tabs[e].accordionTab.addClass(this.options.classes.accordionTitle);this.tabs[e].accordionAnchor.addClass(this.options.classes.anchor);if(this.tabs[e].disabled){this.tabs[e].tab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled);this.tabs[e].accordionTab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled)}}};i.prototype._loadEvents=function(){var
e=this,n=function(n){var
r=e._getCurrentTab(),i=n.data.tab;n.preventDefault();if(!i.disabled){e.options.setHash&&(t.location.hash=i.selector);n.data.tab._ignoreHashChange=!0;if(r!==i||e._isCollapisble()){e._closeTab(n,r);(r!==i||!e._isCollapisble())&&e._openTab(n,i,!1,!0)}}};for(var
r=0;r<this.tabs.length;r++){this.tabs[r].anchor.on("click",{tab:e.tabs[r]},n);this.tabs[r].accordionAnchor.on("click",{tab:e.tabs[r]},n)}};i.prototype._setState=function(){var
t=e("ul",this.$element),n=this.state;t.is(":visible")?this.state="tabs":this.state="accordion";this.state!==n&&this.$element.trigger("tabs-activate-state",{oldState:n,newState:this.state})};i.prototype._openTab=function(e,t,n,r){var
i=this;n&&this._closeTab(e,this._getCurrentTab());r&&this.rotateInterval>0&&this.stopRotation();t.active=!0;t.tab.removeClass(i.options.classes.stateDefault).addClass(i.options.classes.stateActive);t.accordionTab.removeClass(i.options.classes.stateDefault).addClass(i.options.classes.stateActive);i._doTransition(t.panel,i.options.animation,"open",function(){t.panel.removeClass(i.options.classes.stateDefault).addClass(i.options.classes.stateActive)});this.$element.trigger("tabs-activate",t)};i.prototype._closeTab=function(e,t){var
r=this;if(t!==n){t.active=!1;t.tab.removeClass(r.options.classes.stateActive).addClass(r.options.classes.stateDefault);r._doTransition(t.panel,r.options.animation,"close",function(){t.accordionTab.removeClass(r.options.classes.stateActive).addClass(r.options.classes.stateDefault);t.panel.removeClass(r.options.classes.stateActive).addClass(r.options.classes.stateDefault)},!0);this.$element.trigger("tabs-deactivate",t)}};i.prototype._doTransition=function(e,t,n,r,i){var
s,o=this;switch(t){case"slide":s=n==="open"?"slideDown":"slideUp";break;case"fade":s=n==="open"?"fadeIn":"fadeOut";break;default:s=n==="open"?"show":"hide";o.options.duration=0}this.$queue.queue("responsive-tabs",function(i){e[s]({duration:o.options.duration,complete:function(){r.call(e,t,n);i()}})});(n==="open"||i)&&this.$queue.dequeue("responsive-tabs")};i.prototype._isCollapisble=function(){return
typeof this.options.collapsible=="boolean"&&this.options.collapsible||typeof
this.options.collapsible=="string"&&this.options.collapsible===this.getState()};i.prototype._getTab=function(e){return
this.tabs[e]};i.prototype._getTabRefBySelector=function(e){for(var
t=0;t<this.tabs.length;t++)if(this.tabs[t].selector===e)return
t;return-1};i.prototype._getCurrentTab=function(){return
this._getTab(this._getCurrentTabRef())};i.prototype._getNextTabRef=function(e){var
t=e||this._getCurrentTabRef(),n=t===this.tabs.length-1?0:t+1;return
this._getTab(n).disabled?this._getNextTabRef(n):n};i.prototype._getPreviousTabRef=function(){return
this._getCurrentTabRef()===0?this.tabs.length-1:this._getCurrentTabRef()-1};i.prototype._getCurrentTabRef=function(){for(var
e=0;e<this.tabs.length;e++)if(this.tabs[e].active)return
e;return-1};i.prototype.activate=function(e,t){var
n=jQuery.Event("tabs-activate"),r=this._getTab(e);r.disabled||this._openTab(n,r,!0,t||!0)};i.prototype.deactivate=function(e){var
t=jQuery.Event("tabs-dectivate"),n=this._getTab(e);n.disabled||this._closeTab(t,n)};i.prototype.getState=function(){return
this.state};i.prototype.startRotation=function(t){var
n=this;if(!(this.tabs.length>this.options.disabled.length))throw new
Error("Rotation is not possible if all tabs are
disabled");this.rotateInterval=setInterval(function(){var
e=jQuery.Event("rotate");n._openTab(e,n._getTab(n._getNextTabRef()),!0)},t||(e.isNumeric(n.options.rotate)?n.options.rotate:4e3))};i.prototype.stopRotation=function(){t.clearInterval(this.rotateInterval);this.rotateInterval=0};e.fn.responsiveTabs=function(t){var
r=arguments;if(t===n||typeof t=="object")return
this.each(function(){e.data(this,"responsivetabs")||e.data(this,"responsivetabs",new
i(this,t))});if(typeof t=="string"&&t[0]!=="_"&&t!=="init")return
this.each(function(){var n=e.data(this,"responsivetabs");n instanceof i&&typeof
n[t]=="function"&&n[t].apply(n,Array.prototype.slice.call(r,1));t==="destroy"&&e.data(this,"responsivetabs",null)})}})(jQuery,window);
\ No newline at end of file
+ */
+!function(t,s,a){function
e(s,a){this.element=s,this.$element=t(s),this.tabs=[],this.state="",this.rotateInterval=0,this.$queue=t({}),this.options=t.extend({},o,a),this.init()}var
o={active:null,event:"click",disabled:[],collapsible:"accordion",startCollapsed:!1,rotate:!1,setHash:!1,animation:"default",animationQueue:!1,duration:500,scrollToAccordion:!1,scrollToAccordionOffset:0,accordionTabElement:"<div></div>",activate:function(){},deactivate:function(){},load:function(){},activateState:function(){},classes:{stateDefault:"r-tabs-state-default",stateActive:"r-tabs-state-active",stateDisabled:"r-tabs-state-disabled",stateExcluded:"r-tabs-state-excluded",container:"r-tabs",ul:"r-tabs-nav",tab:"r-tabs-tab",anchor:"r-tabs-anchor",panel:"r-tabs-panel",accordionTitle:"r-tabs-accordion-title"}};e.prototype.init=function(){var
a=this;this.tabs=this._loadElements(),this._loadClasses(),this._loadEvents(),t(s).on("resize",function(t){a._setState(t)}),t(s).on("hashchange",function(t){var
e=a._getTabRefBySelector(s.location.hash),o=a._getTab(e);e>=0&&!o._ignoreHashChange&&!o.disabled&&a._openTab(t,a._getTab(e),!0)}),this.options.rotate!==!1&&this.startRotation(),this.$element.bind("tabs-activate",function(t,s){a.options.activate.call(this,t,s)}),this.$element.bind("tabs-deactivate",function(t,s){a.options.deactivate.call(this,t,s)}),this.$element.bind("tabs-activate-state",function(t,s){a.options.activateState.call(this,t,s)}),this.$element.bind("tabs-load",function(t){var
s;a._setState(t),a.options.startCollapsed===!0||"accordion"===a.options.startCollapsed&&"accordion"===a.state||(s=a._getStartTab(),a._openTab(t,s),a.options.load.call(this,t,s))}),this.$element.trigger("tabs-load")},e.prototype._loadElements=function(){var
s=this,a=this.$element.children("ul"),e=[],o=0;return
this.$element.addClass(s.options.classes.container),a.addClass(s.options.classes.ul),t("li",a).each(function(){var
a,i,n,l,r,c,h=t(this),p=h.hasClass(s.options.classes.stateExcluded);if(!p){a=t("a",h),r=a.attr("href"),c=a.attr("onclick"),i=t(r),n=t(s.options.accordionTabElement).insertBefore(i),l=t("<a></a>").attr("href",r).html(a.html()).appendTo(n),l.attr("onclick",c);var
d={_ignoreHashChange:!1,id:o,disabled:-1!==t.inArray(o,s.options.disabled),tab:t(this),anchor:t("a",h),panel:i,selector:r,accordionTab:n,accordionAnchor:l,active:!1};o++,e.push(d)}}),e},e.prototype._loadClasses=function(){for(var
t=0;t<this.tabs.length;t++)this.tabs[t].tab.addClass(this.options.classes.stateDefault).addClass(this.options.classes.tab),this.tabs[t].anchor.addClass(this.options.classes.anchor),this.tabs[t].panel.addClass(this.options.classes.stateDefault).addClass(this.options.classes.panel),this.tabs[t].accordionTab.addClass(this.options.classes.accordionTitle),this.tabs[t].accordionAnchor.addClass(this.options.classes.anchor),this.tabs[t].disabled&&(this.tabs[t].tab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled),this.tabs[t].accordionTab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled))},e.prototype._loadEvents=function(){for(var
t=this,a=function(a){var
e=t._getCurrentTab(),o=a.data.tab;a.preventDefault(),o.disabled||(t.options.setHash&&(history.pushState?history.pushState(null,null,o.selector):s.location.hash=o.selector),a.data.tab._ignoreHashChange=!0,(e!==o||t._isCollapisble())&&(t._closeTab(a,e),e===o&&t._isCollapisble()||t._openTab(a,o,!1,!0)))},e=0;e<this.tabs.length;e++)this.tabs[e].anchor.on(t.options.event,{tab:t.tabs[e]},a),this.tabs[e].accordionAnchor.on(t.options.event,{tab:t.tabs[e]},a)},e.prototype._getStartTab=function(){var
t,a=this._getTabRefBySelector(s.location.hash);return
t=a>=0&&!this._getTab(a).disabled?this._getTab(a):this.options.active>0&&!this._getTab(this.options.active).disabled?this._getTab(this.options.active):this._getTab(0)},e.prototype._setState=function(s){var
e,o=t("ul",this.$element),i=this.state,n="string"==typeof
this.options.startCollapsed;o.is(":visible")?this.state="tabs":this.state="accordion",this.state!==i&&(this.$element.trigger("tabs-activate-state",{oldState:i,newState:this.state}),i&&n&&this.options.startCollapsed!==this.state&&this._getCurrentTab()===a&&(e=this._getStartTab(s),this._openTab(s,e)))},e.prototype._openTab=function(s,a,e,o){var
i,n=this;e&&this._closeTab(s,this._getCurrentTab()),o&&this.rotateInterval>0&&this.stopRotation(),a.active=!0,a.tab.removeClass(n.options.classes.stateDefault).addClass(n.options.classes.stateActive),a.accordionTab.removeClass(n.options.classes.stateDefault).addClass(n.options.classes.stateActive),n._doTransition(a.panel,n.options.animation,"open",function(){a.panel.removeClass(n.options.classes.stateDefault).addClass(n.options.classes.stateActive),"accordion"!==n.getState()||!n.options.scrollToAccordion||n._isInView(a.accordionTab)&&"default"===n.options.animation||(i=a.accordionTab.offset().top-n.options.scrollToAccordionOffset,"default"!==n.options.animation&&n.options.duration>0?t("html,
body").animate({scrollTop:i},n.options.duration):t("html,
body").scrollTop(i))}),this.$element.trigger("tabs-activate",a)},e.prototype._closeTab=function(t,s){var
e,o=this,i="string"==typeof
o.options.animationQueue;s!==a&&(e=i&&o.getState()===o.options.animationQueue?!0:i?!1:o.options.animationQueue,s.active=!1,s.tab.removeClass(o.options.classes.stateActive).addClass(o.options.classes.stateDefault),o._doTransition(s.panel,o.options.animation,"close",function(){s.accordionTab.removeClass(o.options.classes.stateActive).addClass(o.options.classes.stateDefault),s.panel.removeClass(o.options.classes.stateActive).addClass(o.options.classes.stateDefault)},!e),this.$element.trigger("tabs-deactivate",s))},e.prototype._doTransition=function(t,s,a,e,o){var
i,n=this;switch(s){case"slide":i="open"===a?"slideDown":"slideUp";break;case"fade":i="open"===a?"fadeIn":"fadeOut";break;default:i="open"===a?"show":"hide",n.options.duration=0}this.$queue.queue("responsive-tabs",function(o){t[i]({duration:n.options.duration,complete:function(){e.call(t,s,a),o()}})}),("open"===a||o)&&this.$queue.dequeue("responsive-tabs")},e.prototype._isCollapisble=function(){return"boolean"==typeof
this.options.collapsible&&this.options.collapsible||"string"==typeof
this.options.collapsible&&this.options.collapsible===this.getState()},e.prototype._getTab=function(t){return
this.tabs[t]},e.prototype._getTabRefBySelector=function(t){for(var
s=0;s<this.tabs.length;s++)if(this.tabs[s].selector===t)return
s;return-1},e.prototype._getCurrentTab=function(){return
this._getTab(this._getCurrentTabRef())},e.prototype._getNextTabRef=function(t){var
s=t||this._getCurrentTabRef(),a=s===this.tabs.length-1?0:s+1;return
this._getTab(a).disabled?this._getNextTabRef(a):a},e.prototype._getPreviousTabRef=function(){return
0===this._getCurrentTabRef()?this.tabs.length-1:this._getCurrentTabRef()-1},e.prototype._getCurrentTabRef=function(){for(var
t=0;t<this.tabs.length;t++)if(this.tabs[t].active)return
t;return-1},e.prototype._isInView=function(a){var
e=t(s).scrollTop(),o=e+t(s).height(),i=a.offset().top,n=i+a.height();return
o>=n&&i>=e},e.prototype.activate=function(t,s){var
a=jQuery.Event("tabs-activate"),e=this._getTab(t);e.disabled||this._openTab(a,e,!0,s||!0)},e.prototype.deactivate=function(t){var
s=jQuery.Event("tabs-dectivate"),a=this._getTab(t);a.disabled||this._closeTab(s,a)},e.prototype.enable=function(t){var
s=this._getTab(t);s&&(s.disabled=!1,s.tab.addClass(this.options.classes.stateDefault).removeClass(this.options.classes.stateDisabled),s.accordionTab.addClass(this.options.classes.stateDefault).removeClass(this.options.classes.stateDisabled))},e.prototype.disable=function(t){var
s=this._getTab(t);s&&(s.disabled=!0,s.tab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled),s.accordionTab.removeClass(this.options.classes.stateDefault).addClass(this.options.classes.stateDisabled))},e.prototype.getState=function(){return
this.state},e.prototype.startRotation=function(s){var
a=this;if(!(this.tabs.length>this.options.disabled.length))throw new
Error("Rotation is not possible if all tabs are
disabled");this.rotateInterval=setInterval(function(){var
t=jQuery.Event("rotate");a._openTab(t,a._getTab(a._getNextTabRef()),!0)},s||(t.isNumeric(a.options.rotate)?a.options.rotate:4e3))},e.prototype.stopRotation=function(){s.clearInterval(this.rotateInterval),this.rotateInterval=0},e.prototype.option=function(t,s){return
s&&(this.options[t]=s),this.options[t]},t.fn.responsiveTabs=function(s){var
o=arguments;return s===a||"object"==typeof
s?this.each(function(){t.data(this,"responsivetabs")||t.data(this,"responsivetabs",new
e(this,s))}):"string"==typeof
s&&"_"!==s[0]&&"init"!==s?this.each(function(){var
a=t.data(this,"responsivetabs");a instanceof e&&"function"==typeof
a[s]&&a[s].apply(a,Array.prototype.slice.call(o,1)),"destroy"===s&&t.data(this,"responsivetabs",null)}):void
0}}(jQuery,window);
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [14360] ResponsiveTabs: update from upstream,
Sigurd Nes <=