/** * 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.pager', ['kendo.data'], f); }(function () { var __meta__ = { id: 'pager', name: 'Pager', category: 'framework', depends: ['data'], advanced: true }; (function ($, undefined) { var kendo = window.kendo, ui = kendo.ui, Widget = ui.Widget, proxy = $.proxy, FIRST = '.k-i-seek-w', LAST = '.k-i-seek-e', PREV = '.k-i-arrow-w', NEXT = '.k-i-arrow-e', CHANGE = 'change', NS = '.kendoPager', CLICK = 'click', KEYDOWN = 'keydown', DISABLED = 'disabled', iconTemplate = kendo.template('#=text#'); function button(template, idx, text, numeric, title) { return template({ idx: idx, text: text, ns: kendo.ns, numeric: numeric, title: title || '' }); } function icon(className, text, wrapClassName) { return iconTemplate({ className: className.substring(1), text: text, wrapClassName: wrapClassName || '' }); } function update(element, selector, page, disabled) { element.find(selector).parent().attr(kendo.attr('page'), page).attr('tabindex', -1).toggleClass('k-state-disabled', disabled); } function first(element, page) { update(element, FIRST, 1, page <= 1); } function prev(element, page) { update(element, PREV, Math.max(1, page - 1), page <= 1); } function next(element, page, totalPages) { update(element, NEXT, Math.min(totalPages, page + 1), page >= totalPages); } function last(element, page, totalPages) { update(element, LAST, totalPages, page >= totalPages); } var Pager = Widget.extend({ init: function (element, options) { var that = this, page, totalPages; Widget.fn.init.call(that, element, options); options = that.options; that.dataSource = kendo.data.DataSource.create(options.dataSource); that.linkTemplate = kendo.template(that.options.linkTemplate); that.selectTemplate = kendo.template(that.options.selectTemplate); that.currentPageTemplate = kendo.template(that.options.currentPageTemplate); page = that.page(); totalPages = that.totalPages(); that._refreshHandler = proxy(that.refresh, that); that.dataSource.bind(CHANGE, that._refreshHandler); if (options.previousNext) { if (!that.element.find(FIRST).length) { that.element.append(icon(FIRST, options.messages.first, 'k-pager-first')); first(that.element, page, totalPages); } if (!that.element.find(PREV).length) { that.element.append(icon(PREV, options.messages.previous)); prev(that.element, page, totalPages); } } if (options.numeric) { that.list = that.element.find('.k-pager-numbers'); if (!that.list.length) { that.list = $('