/** * Kendo UI v2016.1.112 (http://www.telerik.com/kendo-ui) * Copyright 2016 Telerik AD. All rights reserved. * * Kendo UI commercial licenses may be obtained at * http://www.telerik.com/purchase/license-agreement/kendo-ui-complete * If you do not own a commercial license, this file shall be governed by the trial license terms. */ (function (f, define) { define('kendo.tabstrip', ['kendo.data'], f); }(function () { var __meta__ = { id: 'tabstrip', name: 'TabStrip', category: 'web', description: 'The TabStrip widget displays a collection of tabs with associated tab content.', depends: ['data'] }; (function ($, undefined) { var kendo = window.kendo, ui = kendo.ui, keys = kendo.keys, map = $.map, each = $.each, trim = $.trim, extend = $.extend, template = kendo.template, Widget = ui.Widget, excludedNodesRegExp = /^(a|div)$/i, NS = '.kendoTabStrip', IMG = 'img', HREF = 'href', PREV = 'prev', SHOW = 'show', LINK = 'k-link', LAST = 'k-last', CLICK = 'click', ERROR = 'error', EMPTY = ':empty', IMAGE = 'k-image', FIRST = 'k-first', SELECT = 'select', ACTIVATE = 'activate', CONTENT = 'k-content', CONTENTURL = 'contentUrl', MOUSEENTER = 'mouseenter', MOUSELEAVE = 'mouseleave', CONTENTLOAD = 'contentLoad', DISABLEDSTATE = 'k-state-disabled', DEFAULTSTATE = 'k-state-default', ACTIVESTATE = 'k-state-active', FOCUSEDSTATE = 'k-state-focused', HOVERSTATE = 'k-state-hover', TABONTOP = 'k-tab-on-top', NAVIGATABLEITEMS = '.k-item:not(.' + DISABLEDSTATE + ')', HOVERABLEITEMS = '.k-tabstrip-items > ' + NAVIGATABLEITEMS + ':not(.' + ACTIVESTATE + ')', templates = { content: template('
#= content(item) #
'), itemWrapper: template('<#= tag(item) # class=\'k-link\'#= contentUrl(item) ##= textAttributes(item) #>' + '#= image(item) ##= sprite(item) ##= text(item) #' + ''), item: template('
  • ' + '#= itemWrapper(data) #' + '
  • '), image: template('\'\''), sprite: template(''), empty: template('') }, rendering = { wrapperCssClass: function (group, item) { var result = 'k-item', index = item.index; if (item.enabled === false) { result += ' k-state-disabled'; } else { result += ' k-state-default'; } if (index === 0) { result += ' k-first'; } if (index == group.length - 1) { result += ' k-last'; } return result; }, textAttributes: function (item) { return item.url ? ' href=\'' + item.url + '\'' : ''; }, text: function (item) { return item.encoded === false ? item.text : kendo.htmlEncode(item.text); }, tag: function (item) { return item.url ? 'a' : 'span'; }, contentAttributes: function (content) { return content.active !== true ? ' style=\'display:none\' aria-hidden=\'true\' aria-expanded=\'false\'' : ''; }, content: function (item) { return item.content ? item.content : item.contentUrl ? '' : ' '; }, contentUrl: function (item) { return item.contentUrl ? kendo.attr('content-url') + '="' + item.contentUrl + '"' : ''; } }; function updateTabClasses(tabs) { tabs.children(IMG).addClass(IMAGE); tabs.children('a').addClass(LINK).children(IMG).addClass(IMAGE); tabs.filter(':not([disabled]):not([class*=k-state-disabled])').addClass(DEFAULTSTATE); tabs.filter('li[disabled]').addClass(DISABLEDSTATE).removeAttr('disabled'); tabs.filter(':not([class*=k-state])').children('a').filter(':focus').parent().addClass(ACTIVESTATE + ' ' + TABONTOP); tabs.attr('role', 'tab'); tabs.filter('.' + ACTIVESTATE).attr('aria-selected', true); tabs.each(function () { var item = $(this); if (!item.children('.' + LINK).length) { item.contents().filter(function () { return !this.nodeName.match(excludedNodesRegExp) && !(this.nodeType == 3 && !trim(this.nodeValue)); }).wrapAll(''); } }); } function updateFirstLast(tabGroup) { var tabs = tabGroup.children('.k-item'); tabs.filter('.k-first:not(:first-child)').removeClass(FIRST); tabs.filter('.k-last:not(:last-child)').removeClass(LAST); tabs.filter(':first-child').addClass(FIRST); tabs.filter(':last-child').addClass(LAST); } function scrollButtonHtml(buttonClass, iconClass) { return ''; } var TabStrip = Widget.extend({ init: function (element, options) { var that = this, value; Widget.fn.init.call(that, element, options); that._animations(that.options); options = that.options; that._wrapper(); that._isRtl = kendo.support.isRtl(that.wrapper); that._tabindex(); that._updateClasses(); that._dataSource(); if (options.dataSource) { that.dataSource.fetch(); } that._tabPosition(); that._scrollable(); if (that.options.contentUrls) { that.wrapper.find('.k-tabstrip-items > .k-item').each(function (index, item) { $(item).find('>.' + LINK).data(CONTENTURL, that.options.contentUrls[index]); }); } that.wrapper.on(MOUSEENTER + NS + ' ' + MOUSELEAVE + NS, HOVERABLEITEMS, that._toggleHover).on('focus' + NS, $.proxy(that._active, that)).on('blur' + NS, function () { that._current(null); }); that._keyDownProxy = $.proxy(that._keydown, that); if (options.navigatable) { that.wrapper.on('keydown' + NS, that._keyDownProxy); } if (that.options.value) { value = that.options.value; } that.wrapper.children('.k-tabstrip-items').on(CLICK + NS, '.k-state-disabled .k-link', false).on(CLICK + NS, ' > ' + NAVIGATABLEITEMS, function (e) { var wr = that.wrapper[0]; if (wr !== document.activeElement) { var msie = kendo.support.browser.msie; if (msie) { try { wr.setActive(); } catch (j) { wr.focus(); } } else { wr.focus(); } } if (that._click($(e.currentTarget))) { e.preventDefault(); } }); var selectedItems = that.tabGroup.children('li.' + ACTIVESTATE), content = that.contentHolder(selectedItems.index()); if (selectedItems[0] && content.length > 0 && content[0].childNodes.length === 0) { that.activateTab(selectedItems.eq(0)); } that.element.attr('role', 'tablist'); if (that.element[0].id) { that._ariaId = that.element[0].id + '_ts_active'; } that.value(value); kendo.notify(that); }, _active: function () { var item = this.tabGroup.children().filter('.' + ACTIVESTATE); item = item[0] ? item : this._endItem('first'); if (item[0]) { this._current(item); } }, _endItem: function (action) { return this.tabGroup.children(NAVIGATABLEITEMS)[action](); }, _item: function (item, action) { var endItem; if (action === PREV) { endItem = 'last'; } else { endItem = 'first'; } if (!item) { return this._endItem(endItem); } item = item[action](); if (!item[0]) { item = this._endItem(endItem); } if (item.hasClass(DISABLEDSTATE)) { item = this._item(item, action); } return item; }, _current: function (candidate) { var that = this, focused = that._focused, id = that._ariaId; if (candidate === undefined) { return focused; } if (focused) { if (focused[0].id === id) { focused.removeAttr('id'); } focused.removeClass(FOCUSEDSTATE); } if (candidate) { if (!candidate.hasClass(ACTIVESTATE)) { candidate.addClass(FOCUSEDSTATE); } that.element.removeAttr('aria-activedescendant'); id = candidate[0].id || id; if (id) { candidate.attr('id', id); that.element.attr('aria-activedescendant', id); } } that._focused = candidate; }, _keydown: function (e) { var that = this, key = e.keyCode, current = that._current(), rtl = that._isRtl, action; if (e.target != e.currentTarget) { return; } if (key == keys.DOWN || key == keys.RIGHT) { action = rtl ? PREV : 'next'; } else if (key == keys.UP || key == keys.LEFT) { action = rtl ? 'next' : PREV; } else if (key == keys.ENTER || key == keys.SPACEBAR) { that._click(current); e.preventDefault(); } else if (key == keys.HOME) { that._click(that._endItem('first')); e.preventDefault(); return; } else if (key == keys.END) { that._click(that._endItem('last')); e.preventDefault(); return; } if (action) { that._click(that._item(current, action)); e.preventDefault(); } }, _dataSource: function () { var that = this; if (that.dataSource && that._refreshHandler) { that.dataSource.unbind('change', that._refreshHandler); } else { that._refreshHandler = $.proxy(that.refresh, that); } that.dataSource = kendo.data.DataSource.create(that.options.dataSource).bind('change', that._refreshHandler); }, setDataSource: function (dataSource) { var that = this; that.options.dataSource = dataSource; that._dataSource(); that.dataSource.fetch(); }, _animations: function (options) { if (options && 'animation' in options && !options.animation) { options.animation = { open: { effects: {} }, close: { effects: {} } }; } }, refresh: function (e) { var that = this, options = that.options, text = kendo.getter(options.dataTextField), content = kendo.getter(options.dataContentField), contentUrl = kendo.getter(options.dataContentUrlField), image = kendo.getter(options.dataImageUrlField), url = kendo.getter(options.dataUrlField), sprite = kendo.getter(options.dataSpriteCssClass), idx, tabs = [], tab, action, view = that.dataSource.view(), length; e = e || {}; action = e.action; if (action) { view = e.items; } for (idx = 0, length = view.length; idx < length; idx++) { tab = { text: text(view[idx]) }; if (options.dataContentField) { tab.content = content(view[idx]); } if (options.dataContentUrlField) { tab.contentUrl = contentUrl(view[idx]); } if (options.dataUrlField) { tab.url = url(view[idx]); } if (options.dataImageUrlField) { tab.imageUrl = image(view[idx]); } if (options.dataSpriteCssClass) { tab.spriteCssClass = sprite(view[idx]); } tabs[idx] = tab; } if (e.action == 'add') { if (e.index < that.tabGroup.children().length) { that.insertBefore(tabs, that.tabGroup.children().eq(e.index)); } else { that.append(tabs); } } else if (e.action == 'remove') { for (idx = 0; idx < view.length; idx++) { that.remove(e.index); } } else if (e.action == 'itemchange') { idx = that.dataSource.view().indexOf(view[0]); if (e.field === options.dataTextField) { that.tabGroup.children().eq(idx).find('.k-link').text(view[0].get(e.field)); } } else { that.trigger('dataBinding'); that.remove('li'); that.append(tabs); that.trigger('dataBound'); } }, value: function (value) { var that = this; if (value !== undefined) { if (value != that.value()) { that.tabGroup.children().each(function () { if ($.trim($(this).text()) == value) { that.select(this); } }); } } else { return that.select().text(); } }, items: function () { return this.tabGroup[0].children; }, setOptions: function (options) { var that = this, animation = that.options.animation; that._animations(options); options.animation = extend(true, animation, options.animation); if (options.navigatable) { that.wrapper.on('keydown' + NS, that._keyDownProxy); } else { that.wrapper.off('keydown' + NS, that._keyDownProxy); } Widget.fn.setOptions.call(that, options); }, events: [ SELECT, ACTIVATE, SHOW, ERROR, CONTENTLOAD, 'change', 'dataBinding', 'dataBound' ], options: { name: 'TabStrip', dataTextField: '', dataContentField: '', dataImageUrlField: '', dataUrlField: '', dataSpriteCssClass: '', dataContentUrlField: '', tabPosition: 'top', animation: { open: { effects: 'expand:vertical fadeIn', duration: 200 }, close: { duration: 200 } }, collapsible: false, navigatable: true, contentUrls: false, scrollable: { distance: 200 } }, destroy: function () { var that = this, scrollWrap = that.scrollWrap; Widget.fn.destroy.call(that); if (that._refreshHandler) { that.dataSource.unbind('change', that._refreshHandler); } that.wrapper.off(NS); that.wrapper.children('.k-tabstrip-items').off(NS); if (that._scrollableModeActive) { that._scrollPrevButton.off().remove(); that._scrollNextButton.off().remove(); } kendo.destroy(that.wrapper); scrollWrap.children('.k-tabstrip').unwrap(); }, select: function (element) { var that = this; if (arguments.length === 0) { return that.tabGroup.children('li.' + ACTIVESTATE); } if (!isNaN(element)) { element = that.tabGroup.children().get(element); } element = that.tabGroup.find(element); $(element).each(function (index, item) { item = $(item); if (!item.hasClass(ACTIVESTATE) && !that.trigger(SELECT, { item: item[0], contentElement: that.contentHolder(item.index())[0] })) { that.activateTab(item); } }); return that; }, enable: function (element, state) { this._toggleDisabled(element, state !== false); return this; }, disable: function (element) { this._toggleDisabled(element, false); return this; }, reload: function (element) { element = this.tabGroup.find(element); var that = this; element.each(function () { var item = $(this), contentUrl = item.find('.' + LINK).data(CONTENTURL), content = that.contentHolder(item.index()); if (contentUrl) { that.ajaxRequest(item, content, null, contentUrl); } }); return that; }, append: function (tab) { var that = this, inserted = that._create(tab); each(inserted.tabs, function (idx) { var contents = inserted.contents[idx]; that.tabGroup.append(this); if (that.options.tabPosition == 'bottom') { that.tabGroup.before(contents); } else if (that._scrollableModeActive) { that._scrollPrevButton.before(contents); } else { that.wrapper.append(contents); } that.angular('compile', function () { return { elements: [contents] }; }); }); updateFirstLast(that.tabGroup); that._updateContentElements(); that.resize(true); return that; }, insertBefore: function (tab, referenceTab) { referenceTab = this.tabGroup.find(referenceTab); var that = this, inserted = that._create(tab), referenceContent = $(that.contentElement(referenceTab.index())); each(inserted.tabs, function (idx) { var contents = inserted.contents[idx]; referenceTab.before(this); referenceContent.before(contents); that.angular('compile', function () { return { elements: [contents] }; }); }); updateFirstLast(that.tabGroup); that._updateContentElements(); that.resize(true); return that; }, insertAfter: function (tab, referenceTab) { referenceTab = this.tabGroup.find(referenceTab); var that = this, inserted = that._create(tab), referenceContent = $(that.contentElement(referenceTab.index())); each(inserted.tabs, function (idx) { var contents = inserted.contents[idx]; referenceTab.after(this); referenceContent.after(contents); that.angular('compile', function () { return { elements: [contents] }; }); }); updateFirstLast(that.tabGroup); that._updateContentElements(); that.resize(true); return that; }, remove: function (elements) { var that = this; var type = typeof elements; var contents; if (type === 'string') { elements = that.tabGroup.find(elements); } else if (type === 'number') { elements = that.tabGroup.children().eq(elements); } contents = elements.map(function () { var content = that.contentElement($(this).index()); kendo.destroy(content); return content; }); elements.remove(); contents.remove(); that._updateContentElements(); that.resize(true); return that; }, _create: function (tab) { var plain = $.isPlainObject(tab), that = this, tabs, contents, content; if (plain || $.isArray(tab)) { tab = $.isArray(tab) ? tab : [tab]; tabs = map(tab, function (value, idx) { return $(TabStrip.renderItem({ group: that.tabGroup, item: extend(value, { index: idx }) })); }); contents = map(tab, function (value, idx) { if (typeof value.content == 'string' || value.contentUrl) { return $(TabStrip.renderContent({ item: extend(value, { index: idx }) })); } }); } else { if (typeof tab == 'string' && tab[0] != '<') { tabs = that.element.find(tab); } else { tabs = $(tab); } contents = $(); tabs.each(function () { content = $('
    '); if (/k-tabstrip-items/.test(this.parentNode.className)) { var index = parseInt(this.getAttribute('aria-controls').replace(/^.*-/, ''), 10) - 1; content = $(that.contentElement(index)); } contents = contents.add(content); }); updateTabClasses(tabs); } return { tabs: tabs, contents: contents }; }, _toggleDisabled: function (element, enable) { element = this.tabGroup.find(element); element.each(function () { $(this).toggleClass(DEFAULTSTATE, enable).toggleClass(DISABLEDSTATE, !enable); }); }, _updateClasses: function () { var that = this, tabs, activeItem, activeTab; that.wrapper.addClass('k-widget k-header k-tabstrip'); that.tabGroup = that.wrapper.children('ul').addClass('k-tabstrip-items k-reset'); if (!that.tabGroup[0]) { that.tabGroup = $('