spine_paginator 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SpinePaginator
2
2
 
3
- Paginator for [Spine](https://github.com/spine/spine).
3
+ Paginator/Pagination for [Spine](https://github.com/spine/spine).
4
4
 
5
5
 
6
6
  ## Installation
@@ -23,5 +23,5 @@ Add the following to your `app/assets/javascripts/application.js` file.
23
23
  //= require spine.paginator
24
24
  //= require spine.pagination_controller
25
25
 
26
- Then, see https://github.com/vkill/spine_paginator/examples/spine_pagination.coffee
26
+ Then, see https://github.com/vkill/spine_paginator/blob/master/examples/spine_pagination.coffee
27
27
 
data/component.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "spine.paginator",
3
3
  "repo": "vkill/spine_paginator",
4
- "description": "Paginator for Spine.",
5
- "version": "0.1.0",
4
+ "description": "Paginator/Pagination for Spine.",
5
+ "version": "0.1.1",
6
6
  "keywords": [
7
7
  "paginator",
8
8
  "spine",
@@ -1,5 +1,5 @@
1
1
  // spine.paginator.js
2
- // version: 0.1.0
2
+ // version: 0.1.1
3
3
  // author: vkill
4
4
  // license: MIT
5
5
  (function() {
@@ -14,7 +14,7 @@
14
14
 
15
15
  Usage
16
16
 
17
- see https://github.com/vkill/spine_paginator/examples/spine_pagination.coffee
17
+ see https://github.com/vkill/spine_paginator/blob/master/examples/spine_pagination.coffee
18
18
  */
19
19
 
20
20
 
@@ -1,5 +1,5 @@
1
1
  // spine.paginator.js
2
- // version: 0.1.0
2
+ // version: 0.1.1
3
3
  // author: vkill
4
4
  // license: MIT
5
5
  (function(){var t,s=function(t,s){return function(){return t.apply(s,arguments)}},e={}.hasOwnProperty,i=function(t,s){function i(){this.constructor=t}for(var r in s)e.call(s,r)&&(t[r]=s[r]);return i.prototype=s.prototype,t.prototype=new i,t.__super__=s.prototype,t};t=this.Spine||require("spine"),t.PaginationController=function(t){function e(){if(this.templateHtmlDataEmpty=s(this.templateHtmlDataEmpty,this),this.render=s(this.render,this),e.__super__.constructor.apply(this,arguments),null==this.constructor.MODEL)throw Error("please defined class variable MODEL");if(this.constructor.PER_PAGE=this.constructor.PER_PAGES[0],null==this.constructor.PER_PAGE)throw Error("please defined class variable PER_PAGES");this.constructor.MODEL.bind(this.constructor.PAGINATE_EVENT,this.render)}return i(e,t),e.MODEL=null,e.PER_PAGES=[10,20,30,40],e.PAGINATE_EVENT="paginate",e.PAGE=1,e.PER_PAGE=null,e.PAGINATION=null,e.refresh=function(){return this.PAGE=1,this.load()},e.toPage=function(t){return this.PAGE=t,this.load()},e.load=function(){var t;return t=this.MODEL.page(this.PAGE,{perPage:this.PER_PAGE}),this.PAGINATION=t,this.MODEL.trigger(this.PAGINATE_EVENT)},e.prototype.render=function(){var t;return t=this.constructor.PAGINATION,t.records.length>0?this.html(this.templateHtml()):this.html(this.templateHtmlDataEmpty())},e.prototype.events={"click a[data-page]":"clickPage"},e.prototype.clickPage=function(t){var s;return t.preventDefault(),s=this.getPageFromE(t),null!=s?this.constructor.toPage(s):void 0},e.prototype.getPageFromE=function(t){var s,e,i;if(s=$(t.target),s.parent(".disabled, .active").length>0)return null;switch(i=s.data("page"),e=null,i){case"first":e=this.constructor.PAGINATION.firstPage();break;case"prev":e=this.constructor.PAGINATION.currentPage()-1;break;case"next":e=this.constructor.PAGINATION.currentPage()+1;break;case"last":e=this.constructor.PAGINATION.lastPage();break;case"gap":e=null;break;default:e=i}return e},e.prototype.templateHtmlDataEmpty=function(){return""},e.prototype.templateHtml=function(){var t,s;return t=this.constructor.PAGINATION,s='<div class="pagination pagination-small pull-right">\n <ul>\n <li {{#unless hasFirst}}class="disabled"{{/unless}}>\n <a href="javascript:void(0);" data-page="first">first</a>\n </li>\n <li {{#unless hasPrev}}class="disabled"{{/unless}}>\n <a href="javascript:void(0);" data-page="prev">prev</a>\n </li>\n {{#each pages}}\n {{#if this.gap}}\n <li class="disabled">\n <a href="javascript:void(0);" data-page=\'gap\'>...</a>\n </li>\n {{else}}\n <li {{#if this.current}}class="active"{{/if}}>\n <a href="javascript:void(0);" data-page={{this.number}}>{{this.number}}</a>\n </li>\n {{/if}}\n {{/each}}\n <li {{#unless hasNext}}class="disabled"{{/unless}}>\n <a href=\'javascript:void(0);\' data-page="next">next</a>\n </li>\n <li {{#unless hasLast}}class="disabled"{{/unless}}>\n <a href=\'javascript:void(0);\' data-page="last">last</a>\n </li>\n </ul>\n</div>',Handlebars.compile(s)(t.locals)},e}(t.Controller)}).call(this);
@@ -1,5 +1,5 @@
1
1
  // spine.paginator.js
2
- // version: 0.1.0
2
+ // version: 0.1.1
3
3
  // author: vkill
4
4
  // license: MIT
5
5
  /*
@@ -1,5 +1,5 @@
1
1
  // spine.paginator.js
2
- // version: 0.1.0
2
+ // version: 0.1.1
3
3
  // author: vkill
4
4
  // license: MIT
5
5
  (function(){var t,s,i;t=function(){function t(t,s,e){var r;this._page=s,null==e&&(e={}),i(t)||(t=[t]),this.originalRecords=t,this.totalCount=this.originalRecords.length,this._page=parseInt(this._page),(isNaN(this._page)||0>=this._page)&&(this._page=1),this._originalPage=this._page,this.perPage=e.perPage||this.constructor.DEFAULT_PER_PAGE,this.perPage=parseInt(this.perPage),(isNaN(this.perPage)||0>=this.perPage)&&(this.perPage=this.constructor.DEFAULT_PER_PAGE),this.maxPerPage=e.maxPerPage||this.constructor.MAX_PER_PAGE,this.window=e.window||e.inner_window||this.constructor.WINDOW,r=e.outer_window||this.constructor.OUTER_WINDOW,this.left=e.left||this.constructor.LEFT,0===this.left&&(this.left=r),this.right=e.right||this.constructor.RIGHT,0===this.right&&(this.right=r),this.skipbuildButtonsAndLocals=e.skipbuildButtonsAndLocals,this.records=[],this.buttons=[],this.locals={},this.per()}return t.DEFAULT_PER_PAGE=25,t.MAX_PER_PAGE=null,t.WINDOW=4,t.OUTER_WINDOW=0,t.LEFT=0,t.RIGHT=0,t.PAGE_TEXTS={first:"first",prev:"prev",current:"current",next:"next",last:"last",gap:"gap"},t.prototype.per=function(t){var s,i,e;return i=parseInt(t),!isNaN(i)&&i>0&&(this.perPage=i,this._page=this._originalPage),s=this.offsetValue(),e=s+this.limitValue(),this.records=this.originalRecords.slice(s,e),null==this.skipbuildButtonsAndLocals&&this.buildButtonsAndLocals(),this},t.prototype.totalPages=function(){return Math.ceil(this.totalCount/this.limitValue())},t.prototype.currentPage=function(){return null==this.limitValue()?this.firstPage():this.offsetValue()/this.limitValue()+1},t.prototype.firstPage=function(){return 1},t.prototype.isFirstPage=function(){return this.currentPage()===this.firstPage()},t.prototype.lastPage=function(){return this.totalPages()},t.prototype.isLastPage=function(){return this.currentPage()>=this.lastPage()},t.prototype.limitValue=function(){return this.perPage>this.totalCount&&(this.perPage=this.totalCount),null!=this.maxPerPage&&this.perPage>this.maxPerPage&&(this.perPage=this.maxPerPage),this.perPage},t.prototype.offsetValue=function(){var t;return t=this.totalPages(),this._page>t&&(this._page=t),(this._page-1)*this.limitValue()},t.prototype.buildPage=function(t,s,i,e,r){return{number:t,isCurrent:t===i,isFirst:t===e,isLast:t===r,isPrev:t===i-1,isNext:t===i+1,isLeftOuter:this.left>=t,isRightOuter:this.right>r-t,isInsideWindow:Math.abs(i-t)<=this.window,isWasTruncated:s===this.constructor.PAGE_TEXTS.gap}},t.prototype.curPage=function(){var t,s,i;return t=this.currentPage(),s=this.firstPage(),i=this.lastPage(),this.buildPage(t,null,t,s,i)},t.prototype.pages=function(){var t,s,i,e,r,n,a,h;for(t=this.currentPage(),s=this.firstPage(),e=this.lastPage(),h=[],i=null,r=a=s;e>=s?e>=a:a>=e;r=e>=s?++a:--a)n=this.buildPage(r,i,t,s,e),i=n.isLeftOuter||n.isRightOuter||n.isInsideWindow?null:this.constructor.PAGE_TEXTS.gap,h.push(n);return h},t.prototype.buildButtonsAndLocals=function(){var t,s,i,e,r,n,a;for(e=[],a={},t=this.curPage(),i=this.pages(),t.isFirst?a.hasFirst=!1:(e.push(this.constructor.PAGE_TEXTS.first),a.hasFirst=!0),t.isFirst?a.hasPrev=!1:(e.push(this.constructor.PAGE_TEXTS.prev),a.hasPrev=!0),a.pages=[],r=0,n=i.length;n>r;r++)s=i[r],s.isLeftOuter||s.isRightOuter||s.isInsideWindow?s.isCurrent?(e.push(this.constructor.PAGE_TEXTS.current),a.pages.push({number:s.number,current:!0})):(e.push(s.number),a.pages.push({number:s.number,current:!1})):s.isWasTruncated||(e.push(this.constructor.PAGE_TEXTS.gap),a.pages.push({number:s.number,gap:!0}));return t.isLast?a.hasNext=!1:(e.push(this.constructor.PAGE_TEXTS.next),a.hasNext=!0),t.isLast?a.hasLast=!1:(e.push(this.constructor.PAGE_TEXTS.last),a.hasLast=!0),a.first=this.firstPage(),a.current=this.currentPage(),a.last=this.lastPage(),a.numStart=0===this.records.length?0:this.offsetValue()+1,a.numEnd=this.offsetValue()+this.records.length,a.numTotal=this.totalCount,this.buttons=e,this.locals=a},t}(),i=function(t){return"[object Array]"===Object.prototype.toString.call(t)},t.isArray=i,null!=this.MyPaginatorName&&(this[this.MyPaginatorName]=t),null!=this.Spine&&(t.SpineModelExtend={page:function(s,i){return null==i&&(i={}),new t(this._perPaginateRecords(),s,i)},_perPaginateRecords:function(){return this.all()}},s=this.Spine,s.Paginator=t,s.Model.Paginator={extended:function(){return this.extend(t.SpineModelExtend)}})}).call(this);
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><title>Spine Pagination Demo</title><link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" /><link href="./spine_pagination.css" rel="stylesheet" /><script type="text/javascript">window.MyPaginationName = "Paginator"</script><script src="http://code.jquery.com/jquery-1.9.1.min.js"></script><script src="../spec/lib/spine.js"></script><script src="../spec/lib/handlebars.js"></script><script src="../dist/spine.paginator.js"></script><script src="../dist/spine.pagination_controller.js"></script><script src="./spine_pagination.js"></script></head><body><h1>Spine Pagination Demo</h1><div id="users"><table class="table table-hover"><thead><tr><td>ID</td><td>Name</td></tr></thead><tbody></tbody></table><div id="pagination"></div></div></body></html>
1
+ <!DOCTYPE html><html><head><title>Spine Pagination Demo</title><link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet" /><link href="./spine_pagination.css" rel="stylesheet" /><script type="text/javascript">window.MyPaginatorName = "Paginator"</script><script src="http://code.jquery.com/jquery-1.9.1.min.js"></script><script src="../spec/lib/spine.js"></script><script src="../spec/lib/handlebars.js"></script><script src="../dist/spine.paginator.js"></script><script src="../dist/spine.pagination_controller.js"></script><script src="./spine_pagination.js"></script></head><body><h1>Spine Pagination Demo</h1><div id="users"><table class="table table-hover"><thead><tr><td>ID</td><td>Name</td></tr></thead><tbody></tbody></table><div id="pagination"></div></div></body></html>
@@ -5,7 +5,7 @@ html
5
5
  link href="http://twitter.github.io/bootstrap/assets/css/bootstrap.css" rel="stylesheet"
6
6
  link href="./spine_pagination.css" rel="stylesheet"
7
7
  javascript:
8
- window.MyPaginationName = "Paginator"
8
+ window.MyPaginatorName = "Paginator"
9
9
  script src="http://code.jquery.com/jquery-1.9.1.min.js"
10
10
  script src="../spec/lib/spine.js"
11
11
  script src="../spec/lib/handlebars.js"
@@ -2,9 +2,10 @@
2
2
  module SpinePaginator
3
3
  class Railtie < ::Rails::Railtie
4
4
 
5
- initializer "sprockets.spine_paginator", after: "append_asset_paths" do |app|
5
+ initializer "sprockets.spine_paginator", after: "append_asset_paths", group: :all do |app|
6
6
  next unless app.config.assets.enabled
7
- app.config.assets.paths << File.expand_path("../../../dist", __FILE__)
7
+ path = File.expand_path("../../../dist", __FILE__)
8
+ app.config.assets.paths << path unless app.config.assets.paths.include?(path)
8
9
  end
9
10
 
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module SpinePaginator
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "spine.paginator",
3
- "description": "Paginator for Spine.",
3
+ "description": "Paginator / Pagination for Spine.",
4
+ "keywords": [
5
+ "paginator",
6
+ "spine",
7
+ "pagination"
8
+ ],
4
9
  "version": "0.1.1",
5
10
  "author": "vkill",
6
11
  "url": "https://github.com/vkill/spine_paginator",
@@ -4,7 +4,7 @@ Spine = @Spine or require('spine')
4
4
 
5
5
  Usage
6
6
 
7
- see https://github.com/vkill/spine_paginator/examples/spine_pagination.coffee
7
+ see https://github.com/vkill/spine_paginator/blob/master/examples/spine_pagination.coffee
8
8
 
9
9
  ###
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spine_paginator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-11 00:00:00.000000000 Z
12
+ date: 2013-05-25 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Paginator for Spine
15
15
  email: