vendor/assets/javascripts/uikit/components/pagination.js in uikit-sass-rails-1.3.0 vs vendor/assets/javascripts/uikit/components/pagination.js in uikit-sass-rails-1.4.0

- old
+ new

@@ -1,24 +1,24 @@ -/*! UIkit 2.11.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +/*! UIkit 2.20.3 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /* * Based on simplePagination - Copyright (c) 2012 Flavius Matis - http://flaviusmatis.github.com/simplePagination.js/ (MIT) */ (function(addon) { var component; - if (jQuery && jQuery.UIkit) { - component = addon(jQuery, jQuery.UIkit); + if (window.UIkit) { + component = addon(UIkit); } if (typeof define == "function" && define.amd) { define("uikit-pagination", ["uikit"], function(){ - return component || addon(jQuery, jQuery.UIkit); + return component || addon(UIkit); }); } -})(function($, UI){ +})(function(UI){ "use strict"; UI.component('pagination', { @@ -32,21 +32,36 @@ lblPrev : false, lblNext : false, onSelectPage : function() {} }, + boot: function() { + + // init code + UI.ready(function(context) { + + UI.$("[data-uk-pagination]", context).each(function(){ + var ele = UI.$(this); + + if (!ele.data("pagination")) { + var obj = UI.pagination(ele, UI.Utils.options(ele.attr("data-uk-pagination"))); + } + }); + }); + }, + init: function() { var $this = this; this.pages = this.options.pages ? this.options.pages : Math.ceil(this.options.items / this.options.itemsOnPage) ? Math.ceil(this.options.items / this.options.itemsOnPage) : 1; this.currentPage = this.options.currentPage - 1; this.halfDisplayed = this.options.displayedPages / 2; this.on("click", "a[data-page]", function(e){ e.preventDefault(); - $this.selectPage($(this).data("page")); + $this.selectPage(UI.$(this).data("page")); }); this._render(); }, @@ -66,11 +81,11 @@ selectPage: function(pageIndex, pages) { this.currentPage = pageIndex; this.render(pages); this.options.onSelectPage.apply(this, [pageIndex]); - this.trigger('uk.pagination.select', [pageIndex, this]); + this.trigger('select.uk.pagination', [pageIndex, this]); }, _render: function() { var o = this.options, interval = this._getInterval(), i; @@ -118,28 +133,16 @@ _append: function(pageIndex, opts) { var $this = this, item, link, options; pageIndex = pageIndex < 0 ? 0 : (pageIndex < this.pages ? pageIndex : this.pages - 1); - options = $.extend({ text: pageIndex + 1 }, opts); + options = UI.$.extend({ text: pageIndex + 1 }, opts); item = (pageIndex == this.currentPage) ? '<li class="uk-active"><span>' + (options.text) + '</span></li>' : '<li><a href="#page-'+(pageIndex+1)+'" data-page="'+pageIndex+'">'+options.text+'</a></li>'; this.element.append(item); } }); - // init code - UI.ready(function(context) { - - $("[data-uk-pagination]", context).each(function(){ - var ele = $(this); - - if (!ele.data("pagination")) { - var obj = UI.pagination(ele, UI.Utils.options(ele.attr("data-uk-pagination"))); - } - }); - }); - return UI.pagination; -}); \ No newline at end of file +});