⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jitk_jquery_ui_tabs.js

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JS
📖 第 1 页 / 共 2 页
字号:
/* * Tabs 3 - New Wave Tabs * * Copyright (c) 2007 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * http://docs.jquery.com/UI/Tabs */;(function($) {    // if the UI scope is not availalable, add it    $.ui = $.ui || {};    // tabs API methods    $.fn.tabs = function() {        var method = typeof arguments[0] == 'string' && arguments[0];        var args = method && Array.prototype.slice.call(arguments, 1) || arguments;        return method == 'length' ?            $.data(this[0], 'tabs').$tabs.length :            this.each(function() {                if (method) {                    var tabs = $.data(this, 'tabs');                    if (tabs) tabs[method].apply(tabs, args);                } else                    new $.ui.tabs(this, args[0] || {});            });    };    // tabs class    $.ui.tabs = function(el, options) {        var self = this;                this.options = $.extend({}, $.ui.tabs.defaults, options);        this.element = el;        // doesn't extend with null        if (options.selected === null)            this.options.selected = null;        this.options.event += '.tabs'; // namespace event        $(el).bind('setData.tabs', function(event, key, value) {            if ((/^selected/).test(key))                self.select(value);            else {                self.options[key] = value;                self.tabify();            }        }).bind('getData.tabs', function(event, key) {            return self.options[key];        });        // save instance for later        $.data(el, 'tabs', this);        // create tabs        this.tabify(true);    };        $.ui.tabs.defaults = {        // basic setup        selected: 0,        unselect: false,        event: 'click',        disabled: [],        cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }        // TODO history: false,        // Ajax        spinner: 'Loading&#8230;',        cache: false,        idPrefix: 'ui-tabs-',        ajaxOptions: {},        // animations        fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }        // templates        tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>',        panelTemplate: '<div></div>',        // CSS classes        navClass: 'ui-tabs-nav',        selectedClass: 'ui-tabs-selected',        unselectClass: 'ui-tabs-unselect',        disabledClass: 'ui-tabs-disabled',        panelClass: 'ui-tabs-panel',        hideClass: 'ui-tabs-hide',        loadingClass: 'ui-tabs-loading'    };    // instance methods    $.extend($.ui.tabs.prototype, {        tabId: function(a) {            return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9\-_:\.]/g, '')                || this.options.idPrefix + $.data(a);        },        ui: function(tab, panel) {            return {                instance: this,                options: this.options,                tab: tab,                panel: panel            };        },        tabify: function(init) {            this.$lis = $('li:has(a[href])', this.element);            this.$tabs = this.$lis.map(function() { return $('a', this)[0]; });            this.$panels = $([]);            var self = this, o = this.options;            this.$tabs.each(function(i, a) {                // inline tab                if (a.hash && a.hash.replace('#', '')) // Safari 2 reports '#' for an empty hash                    self.$panels = self.$panels.add(a.hash);                // remote tab                else if ($(a).attr('href') != '#') { // prevent loading the page itself if href is just "#"                    $.data(a, 'href.tabs', a.href); // required for restore on destroy                    $.data(a, 'load.tabs', a.href); // mutable                    var id = self.tabId(a);                    a.href = '#' + id;                    var $panel = $('#' + id);                    if (!$panel.length) {                        $panel = $(o.panelTemplate).attr('id', id).addClass(o.panelClass)                            .insertAfter( self.$panels[i - 1] || self.element );                        $panel.data('destroy.tabs', true);                    }                    self.$panels = self.$panels.add( $panel );                }                // invalid tab href                else                    o.disabled.push(i + 1);            });            if (init) {                // attach necessary classes for styling if not present                $(this.element).hasClass(o.navClass) || $(this.element).addClass(o.navClass);                this.$panels.each(function() {                    var $this = $(this);                    $this.hasClass(o.panelClass) || $this.addClass(o.panelClass);                });                // Try to retrieve selected tab:                // 1. from fragment identifier in url if present                // 2. from cookie                // 3. from selected class attribute on <li>                // 4. otherwise use given "selected" option                // 5. check if tab is disabled                this.$tabs.each(function(i, a) {                    if (location.hash) {                        if (a.hash == location.hash) {                            o.selected = i;                            // prevent page scroll to fragment                            //if (($.browser.msie || $.browser.opera) && !o.remote) {                            if ($.browser.msie || $.browser.opera) {                                var $toShow = $(location.hash), toShowId = $toShow.attr('id');                                $toShow.attr('id', '');                                setTimeout(function() {                                    $toShow.attr('id', toShowId); // restore id                                }, 500);                            }                            scrollTo(0, 0);                            return false; // break                        }                    } else if (o.cookie) {                        var index = parseInt($.cookie('ui-tabs' + $.data(self.element)),10);                        if (index && self.$tabs[index]) {                            o.selected = index;                            return false; // break                        }                    } else if ( self.$lis.eq(i).hasClass(o.selectedClass) ) {                        o.selected = i;                        return false; // break                    }                });                // highlight selected tab                this.$panels.addClass(o.hideClass);                this.$lis.removeClass(o.selectedClass);                if (o.selected !== null) {                    this.$panels.eq(o.selected).show().removeClass(o.hideClass); // use show and remove class to show in any case no matter how it has been hidden before                    this.$lis.eq(o.selected).addClass(o.selectedClass);                }                // load if remote tab                var href = o.selected !== null && $.data(this.$tabs[o.selected], 'load.tabs');                if (href)                    this.load(o.selected);                // Take disabling tabs via class attribute from HTML                // into account and update option properly...                o.disabled = $.unique(o.disabled.concat(                    $.map(this.$lis.filter('.' + o.disabledClass),                        function(n, i) { return self.$lis.index(n); } )                )).sort();                                // clean up to avoid memory leaks in certain versions of IE 6                $(window).bind('unload', function() {                    self.$tabs.unbind('.tabs');                    self.$lis = self.$tabs = self.$panels = null;                });            }            // disable tabs            for (var i = 0, li; li = this.$lis[i]; i++)                $(li)[$.inArray(i, o.disabled) != -1 && !$(li).hasClass(o.selectedClass) ? 'addClass' : 'removeClass'](o.disabledClass);            // reset cache if switching from cached to not cached            if (o.cache === false)                this.$tabs.removeData('cache.tabs');                        // set up animations            var hideFx, showFx, baseFx = { 'min-width': 0, duration: 1 }, baseDuration = 'normal';            if (o.fx && o.fx.constructor == Array)                hideFx = o.fx[0] || baseFx, showFx = o.fx[1] || baseFx;            else                hideFx = showFx = o.fx || baseFx;            // reset some styles to maintain print style sheets etc.            var resetCSS = { display: '', overflow: '', height: '' };            if (!$.browser.msie) // not in IE to prevent ClearType font issue                resetCSS.opacity = '';            // Hide a tab, animation prevents browser scrolling to fragment,            // $show is optional.            function hideTab(clicked, $hide, $show) {                $hide.animate(hideFx, hideFx.duration || baseDuration, function() { //                    $hide.addClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.                    if ($.browser.msie && hideFx.opacity)                        $hide[0].style.filter = '';                    if ($show)                        showTab(clicked, $show, $hide);                });            }            // Show a tab, animation prevents browser scrolling to fragment,            // $hide is optional.            function showTab(clicked, $show, $hide) {                if (showFx === baseFx)                    $show.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab panels                $show.animate(showFx, showFx.duration || baseDuration, function() {                    $show.removeClass(o.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.                    if ($.browser.msie && showFx.opacity)                        $show[0].style.filter = '';                    // callback                    $(self.element).triggerHandler('tabsshow', [self.ui(clicked, $show[0])], o.show);                });            }            // switch a tab            function switchTab(clicked, $li, $hide, $show) {                /*if (o.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click                    $.ajaxHistory.update(clicked.hash);                }*/                $li.addClass(o.selectedClass)                    .siblings().removeClass(o.selectedClass);                hideTab(clicked, $hide, $show);            }            // attach tab event handler, unbind to avoid duplicates from former tabifying...            this.$tabs.unbind('.tabs').bind(o.event, function() {                //var trueClick = e.clientX; // add to history only if true click occured, not a triggered click                var $li = $(this).parents('li:eq(0)'),                    $hide = self.$panels.filter(':visible'),                    $show = $(this.hash);                // If tab is already selected and not unselectable or tab disabled or                 // or is already loading or click callback returns false stop here.                // Check if click handler returns false last so that it is not executed

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -