{"version":3,"file":"kendo.pager.min.js","sources":["kendo.pager.js"],"sourcesContent":["(function(f, define) {\n define('kendo.pager',[ \"kendo.data\" ], f);\n})(function() {\n\nvar __meta__ = {\n id: \"pager\",\n name: \"Pager\",\n category: \"framework\",\n depends: [ \"data\" ],\n advanced: true\n};\n\n(function($, undefined) {\n var kendo = window.kendo,\n ui = kendo.ui,\n Widget = ui.Widget,\n keys = kendo.keys,\n template = kendo.template,\n FIRST = \".k-i-arrow-end-left\",\n LAST = \".k-i-arrow-end-right\",\n PREV = \".k-i-arrow-60-left\",\n NEXT = \".k-i-arrow-60-right\",\n SIZE = \"k-pager-md k-pager-sm\",\n FOCUSABLE = \":kendoFocusable:not([tabindex='-1'])\",\n CHANGE = \"change\",\n NS = \".kendoPager\",\n CLICK = \"click\",\n KEYDOWN = \"keydown\",\n DISABLED = \"disabled\",\n MOUSEDOWN = \"down\",\n MAX_VALUE = Number.MAX_VALUE,\n isRtl = false,\n iconTemplate = kendo.template('');\n\n function button(options) {\n return options.template( {\n idx: options.idx,\n text: options.text,\n ns: kendo.ns,\n numeric: options.numeric,\n title: options.title || \"\",\n tabindex: options.navigatable ? 0 : -1,\n navigatable: options.navigatable\n });\n }\n\n function selectOption(template, idx, text, selected) {\n return template( {\n idx: idx,\n text: text || idx,\n selected: selected || false\n });\n }\n\n function icon(className, text, wrapClassName, id) {\n return iconTemplate({\n className: className.substring(1),\n text: text,\n wrapClassName: wrapClassName || \"\",\n id: id || \"\"\n });\n }\n\n function update(element, selector, page, disabled) {\n element.find(selector)\n .parent()\n .attr(kendo.attr(\"page\"), page)\n .attr(\"tabindex\", disabled ? -1 : 0)\n .attr(\"aria-disabled\", disabled)\n .toggleClass(\"k-disabled\", disabled);\n }\n\n function first(element, page) {\n update(element, FIRST, 1, page <= 1);\n }\n\n function prev(element, page) {\n update(element, PREV, Math.max(1, page - 1), page <= 1);\n }\n\n function next(element, page, totalPages) {\n update(element, NEXT, Math.min(totalPages, page + 1), page >= totalPages);\n }\n\n function last(element, page, totalPages) {\n update(element, LAST, totalPages, page >= totalPages);\n }\n\n var Pager = Widget.extend( {\n init: function(element, options) {\n var that = this, page, totalPages;\n var sizeClassName = null;\n\n Widget.fn.init.call(that, element, options);\n\n options = that.options;\n that._createDataSource(options);\n that.linkTemplate = kendo.template(that.options.linkTemplate);\n that.selectTemplate = kendo.template(that.options.selectTemplate);\n that.numericSelectItemTemplate = kendo.template(that.options.numericSelectItemTemplate);\n\n page = that.page();\n totalPages = that.totalPages();\n\n that._refreshHandler = that.refresh.bind(that);\n\n that.dataSource.bind(CHANGE, that._refreshHandler);\n that.downEvent = kendo.applyEventMap(MOUSEDOWN, kendo.guid());\n\n isRtl = kendo.support.isRtl(element);\n\n if (options.navigatable) {\n that._id = that.element.attr(\"id\") || kendo.guid();\n }\n that._template();\n\n if (options.previousNext) {\n if (!that.element.find(FIRST).length) {\n that.element.append(icon(FIRST, options.messages.first, \"k-pager-first\", that._id));\n\n first(that.element, page, totalPages);\n }\n\n if (!that.element.find(PREV).length) {\n that.element.append(icon(PREV, options.messages.previous, null, that._id));\n\n prev(that.element, page, totalPages);\n }\n }\n\n if (options.numeric) {\n if (!that._numericWrap) {\n that._numericWrap = that.element.find(\".k-pager-numbers-wrap\");\n\n if (that._numericWrap.length === 0) {\n that._numericWrap = $(\"
\").appendTo(that.element);\n }\n }\n\n if (!that._numericSelect) {\n that._numericSelect = that._numericWrap.find(\".k-dropdown\");\n\n if (that._numericSelect.length === 0) {\n that._numericSelect = $(\"' +\n kendo.format(options.messages.of, totalPages) +\n '');\n }\n\n that.element.on(KEYDOWN + NS, \".k-pager-input input\", that._keydown.bind(that));\n }\n\n if (options.previousNext) {\n if (!that.element.find(NEXT).length) {\n that.element.append(icon(NEXT, options.messages.next, null, that._id));\n\n next(that.element, page, totalPages);\n }\n\n if (!that.element.find(LAST).length) {\n that.element.append(icon(LAST, options.messages.last, \"k-pager-last\", that._id));\n\n last(that.element, page, totalPages);\n }\n }\n\n if (options.pageSizes) {\n if (!that.element.find(\".k-pager-sizes\").length) {\n var pageSizes = options.pageSizes.length ? options.pageSizes : [\"all\", 5, 10, 20];\n var pageItems = $.map(pageSizes, function(size) {\n if (size.toLowerCase && size.toLowerCase() === \"all\") {\n return \"\";\n }\n\n return \"\";\n });\n\n $('' + options.messages.itemsPerPage + \"\")\n .appendTo(that.element)\n .find(\"select\").html(pageItems.join(\"\")).end()\n .appendTo(that.element);\n }\n\n that.element.find(\".k-pager-sizes select\").val(that.pageSize());\n\n if (kendo.ui.DropDownList) {\n that.element.find(\".k-pager-sizes select\").show().attr(\"aria-label\", options.messages.pageSizeDropDownLabel).kendoDropDownList();\n }\n\n that.element.on(CHANGE + NS, \".k-pager-sizes select\", that._change.bind(that));\n }\n\n if (options.refresh) {\n if (!that.element.find(\".k-pager-refresh\").length) {\n that.element.append('');\n }\n\n that.element.on(CLICK + NS, \".k-pager-refresh\", that._refreshClick.bind(that));\n }\n\n if (options.info) {\n if (!that.element.find(\".k-pager-info\").length) {\n that.element.append('');\n }\n }\n\n that.element\n .on(CLICK + NS , \"a\", that._click.bind(that))\n .on(CHANGE + NS , \"select.k-dropdown\", that._numericSelectChange.bind(that))\n .addClass(\"k-pager-wrap k-widget k-floatwrap\");\n\n if (options.autoBind) {\n that.refresh();\n }\n\n that._resizeHandler = that.resize.bind(that, true);\n $(window).on(\"resize\" + NS, that._resizeHandler);\n\n sizeClassName = that._getWidthSizeClass(that.element.outerWidth());\n\n if (sizeClassName) {\n that.element.addClass(sizeClassName);\n }\n\n that._navigatable();\n\n kendo.notify(that);\n },\n\n destroy: function() {\n var that = this;\n\n Widget.fn.destroy.call(that);\n\n that.element.off(NS);\n that.dataSource.unbind(CHANGE, that._refreshHandler);\n that._refreshHandler = null;\n $(window).off(\"resize\" + NS, this._resizeHandler);\n\n kendo.destroy(that.element);\n that.element = that.list = null;\n },\n\n events: [\n CHANGE\n ],\n\n options: {\n name: \"Pager\",\n ARIATemplate: \"Page navigation, page #=page# of #=totalPages#\",\n selectTemplate: '
  • #=text#
  • ',\n linkTemplate: '
  • #=text#
  • ',\n numericSelectItemTemplate: '',\n buttonCount: 10,\n autoBind: true,\n numeric: true,\n info: true,\n input: false,\n previousNext: true,\n pageSizes: false,\n refresh: false,\n responsive: true,\n navigatable: false,\n messages: {\n allPages: \"All\",\n display: \"{0} - {1} of {2} items\",\n empty: \"No items to display\",\n page: \"Page\",\n of: \"of {0}\",\n itemsPerPage: \"items per page\",\n pageButtonLabel: \"Page {0}\",\n pageSizeDropDownLabel: \"Page sizes drop down\",\n numbersSelectLabel: \"Page select\",\n first: \"Go to the first page\",\n previous: \"Go to the previous page\",\n next: \"Go to the next page\",\n last: \"Go to the last page\",\n refresh: \"Refresh\",\n morePages: \"More pages\"\n }\n },\n\n setDataSource: function(dataSource) {\n var that = this;\n\n that.dataSource.unbind(CHANGE, that._refreshHandler);\n that.dataSource = that.options.dataSource = dataSource;\n dataSource.bind(CHANGE, that._refreshHandler);\n\n if (that.options.autoBind) {\n dataSource.fetch();\n }\n },\n\n _aria: function() {\n this.element.attr({\n \"role\": \"application\",\n \"aria-roledescription\": \"pager\",\n \"aria-keyshortcuts\": \"Enter ArrowRight ArrowLeft\"\n });\n },\n\n _resize: function(size) {\n if (size.width) {\n var sizeClassName = this._getWidthSizeClass(size.width);\n var el = this.element;\n\n if (!sizeClassName) {\n el.removeClass(SIZE);\n } else if (!el.hasClass(sizeClassName)) {\n el.removeClass(SIZE);\n el.addClass(sizeClassName);\n }\n }\n },\n\n _createDataSource: function(options) {\n this.dataSource = kendo.data.DataSource.create(options.dataSource);\n },\n\n refresh: function(e) {\n var that = this,\n idx,\n end,\n start = 1,\n reminder,\n page = that.page(),\n html = \"\",\n selectHtml = \"\",\n options = that.options,\n pageSize = that.pageSize(),\n collapsedTotal = that._collapsedTotal(),\n total = that.dataSource._isGroupPaged() ? that.dataSource.groupsTotal(true) : that.dataSource.total(),\n totalPages = that.totalPages(),\n linkTemplate = that.linkTemplate,\n navigatable = options.navigatable,\n numericSelectItemTemplate = that.numericSelectItemTemplate,\n buttonCount = options.buttonCount;\n\n if (e && e.action == \"itemchange\") {\n return;\n }\n\n if (options.numeric) {\n\n if (page > buttonCount) {\n reminder = (page % buttonCount);\n start = (reminder === 0) ? (page - buttonCount) + 1 : (page - reminder) + 1;\n }\n\n end = Math.min((start + buttonCount) - 1, totalPages);\n\n if (start > 1) {\n html += button({\n template: linkTemplate,\n navigatable: navigatable,\n idx: start - 1,\n text: \"...\",\n numeric: false,\n title: options.messages.morePages\n });\n selectHtml += selectOption(numericSelectItemTemplate, start - 1, options.messages.morePages);\n }\n\n for (idx = start; idx <= end; idx++) {\n html += button({\n template: idx == page ? that.selectTemplate : linkTemplate,\n navigatable: navigatable,\n idx: idx,\n text: idx,\n numeric: true,\n title: kendo.format(options.messages.pageButtonLabel, idx)\n });\n selectHtml += selectOption(numericSelectItemTemplate, idx, idx, idx == page);\n }\n\n if (end < totalPages) {\n html += button({\n template: linkTemplate,\n navigatable: navigatable,\n idx: idx,\n text: \"...\",\n numeric: numericSelectItemTemplate,\n title: options.messages.morePages\n });\n selectHtml += selectOption(numericSelectItemTemplate, idx, options.messages.morePages);\n }\n\n if (html === \"\") {\n html = that.selectTemplate({ text: 0, tabindex: navigatable ? 0 : -1, navigatable: navigatable, title: kendo.format(options.messages.pageButtonLabel, 0) });\n selectHtml = $(\"