diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..959e169 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,4 @@ +{ + "directory": "bower_components", + "analytics": false +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5d5dea4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,33 @@ +# EditorConfig helps developers define and maintain consistent +# coding styles between different editors and IDEs +# editorconfig.org + +root = true + + +[*] +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 + +[*.js] +indent_style = space +indent_size = 2 + +[*.hbs] +indent_style = space +indent_size = 2 + +[*.css] +indent_style = space +indent_size = 2 + +[*.html] +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.ember-cli b/.ember-cli new file mode 100644 index 0000000..ee64cfe --- /dev/null +++ b/.ember-cli @@ -0,0 +1,9 @@ +{ + /** + Ember CLI sends analytics information by default. The data is completely + anonymous, but there are times when you might want to disable this behavior. + + Setting `disableAnalytics` to true will prevent any data from being sent. + */ + "disableAnalytics": false +} diff --git a/.gitignore b/.gitignore index 069ebc6..86fceae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,17 @@ -lib-cov -*.seed -*.log -*.csv -*.dat -*.out -*.pid -*.gz +# See http://help.github.com/ignore-files/ for more about ignoring files. -pids -logs -results +# compiled output +/dist +/tmp +# dependencies +/node_modules +/bower_components + +# misc +/.sass-cache +/connect.lock +/coverage/* +/libpeerconnection.log npm-debug.log -node_modules -/.idea +testem.log diff --git a/.jshintrc b/.jshintrc index d8efa00..08096ef 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,22 +1,32 @@ { - "node" : true, - "browser" : true, - + "predef": [ + "document", + "window", + "-Promise" + ], + "browser": true, + "boss": true, "curly": true, - "latedef": "nofunc", + "debug": false, + "devel": true, "eqeqeq": true, - "immed": true, + "evil": true, + "forin": false, + "immed": false, + "laxbreak": false, "newcap": true, "noarg": true, + "noempty": false, + "nonew": false, + "nomen": false, + "onevar": false, + "plusplus": false, + "regexp": false, + "undef": true, "sub": true, - "undef": "nofunc", - "strict": true, - "white": true, - "indent": 2, - "trailing": true, - "quotmark": "single", - "multistr": true, - "predef": [ - "Ember" - ] + "strict": false, + "white": false, + "eqnull": true, + "esnext": true, + "unused": true } diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cf23938 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +--- +language: node_js + +sudo: false + +cache: + directories: + - node_modules + +before_install: + - "npm config set spin false" + - "npm install -g npm@^2" + +install: + - npm install -g bower + - npm install + - bower install + +script: + - npm test diff --git a/Brocfile.js b/Brocfile.js new file mode 100644 index 0000000..a5cc849 --- /dev/null +++ b/Brocfile.js @@ -0,0 +1,23 @@ +/* jshint node: true */ +/* global require, module */ + +var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); + +var app = new EmberAddon(); + +// Use `app.import` to add additional libraries to the generated +// output files. +// +// If you need to use different assets in different +// environments, specify an object as the first parameter. That +// object's keys should be the environment name and the values +// should be the asset to use in that environment. +// +// If the library that you are including contains AMD or ES6 +// modules that you would like to import into your application +// please specify an object with the list of modules as keys +// along with the exports of each module as its value. +app.import('bower_components/bootstrap/dist/css/bootstrap.css'); +app.import('bower_components/bootstrap/dist/js/bootstrap.js'); + +module.exports = app.toTree(); diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8c3fda3..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Ilya Radchenko - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..b6c71bd --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2014 + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 5a87d42..2004ba9 100644 --- a/README.md +++ b/README.md @@ -1,85 +1,25 @@ -pagination-pager -================ +# Pagination-pager -Ember Component for Bootstrap 3 Pagination & Pager components +This README outlines the details of collaborating on this Ember addon. -```hbs -{{pagination-pager current=2 count=10}} -``` +## Installation -Here's a [demo][1] jsbin, and these are the original Bootstrap Components: [Pagination][2] and [Pager][3]. +* `git clone` this repository +* `npm install` +* `bower install` -## Getting Started +## Running -Install via Bower, `bower install pagination-pager --save`, then include in your app. +* `ember server` +* Visit your app at http://localhost:4200. -### Available Options -- `pager` -- Switches to the pager component, defaults to `false` -- `hide` -- Hide the component if `count` equals `1`, defaults to `false` +## Running Tests -#### Required -- `count` -- The number of pages in total, required -- `current` -- The current page number, required +* `ember test` +* `ember test --server` -#### Pagination Only -- `paginationNext` -- The text to display for pagination next button -- `paginationPrevious` -- The text to display for pagination previous button -- `paginationSize` -- The size of the element, default is '', available options include `lg` and `sm`. -- `countOut` -- The number of page links in the begin and end of whole range -- `countIn` -- The number of page links on each side of current page +## Building -#### Pager Only -- `pagerNext` -- The text to display for the pager next button -- `pagerPrevious` -- The text to display for the pager previous button -- `pagerSpread` -- Pager buttons spaced out, defaults to false +* `ember build` -By default the first page is `1`, and the last is the value of `count`, you can change these by setting `firstPage` and `lastPage`. - -## Testing - -```bash -# install & start server -npm install -npm start - -# start watch (in new terminal) -gulp dev -``` - -## Example Usage - - -```html - - - - - - pagination-pager - - - - - - - - - - - - - - - - - - -``` - -[1]: http://emberjs.jsbin.com/nuroraxe/2/ -[2]: http://getbootstrap.com/components/#pagination -[3]: http://getbootstrap.com/components/#pagination-pager +For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/). diff --git a/addon/.gitkeep b/addon/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/addon/components/page-item.js b/addon/components/page-item.js new file mode 100644 index 0000000..59f14e7 --- /dev/null +++ b/addon/components/page-item.js @@ -0,0 +1,26 @@ +import Ember from 'ember'; + +var computed = Ember.computed; + +export default Ember.Component.extend({ + tagName: 'li', + classNameBindings: ['isActive:active'], + seperator: '…', + + isActive: computed('page', 'selected', function () { + return this.get('page') === this.get('selected'); + }), + + isDots: computed('page', function () { + var seperator = this.get('seperator'); + var page = this.get('page'); + + return page === seperator; + }), + + actions: { + setCurrent: function () { + this.set('selected', this.get('page')); + } + } +}); diff --git a/src/component.js b/addon/components/pagination-pager.js similarity index 74% rename from src/component.js rename to addon/components/pagination-pager.js index 1126f40..4eb903f 100644 --- a/src/component.js +++ b/addon/components/pagination-pager.js @@ -1,6 +1,9 @@ -'use strict'; +import Ember from 'ember'; -var PaginationPagerComponent = Ember.Component.extend({ +var computed = Ember.computed; +var alias = computed.alias; + +export default Ember.Component.extend({ tagName: 'ul', classNameBindings: ['pager:pager:pagination', 'isHidden:hidden', 'paginationSizeClass'], pager: false, @@ -14,42 +17,42 @@ var PaginationPagerComponent = Ember.Component.extend({ countIn: 2, firstPage: 1, current: 1, - lastPage: Ember.computed.alias('count'), + lastPage: alias('count'), - currentPage: function () { + currentPage: computed('current', function () { return Number(this.get('current')); - }.property('current'), - - paginationSizeClass: function () { + }), + + paginationSizeClass: computed('paginationSize', function () { var size = this.get('size'); var pager = this.get('pager'); - + return !pager && size && (size === 'lg' || size === 'sm') ? 'pagination-' + size : ''; - }.property('paginationSize'), - - isFirst: function () { + }), + + isFirst: computed('firstPage', 'current', function () { return this.get('current') === this.get('firstPage'); - }.property('firstPage', 'current'), - - isLast: function () { + }), + + isLast: computed('lastPage', 'current', function () { return this.get('current') === this.get('lastPage'); - }.property('lastPage', 'current'), + }), - isHidden: function () { + isHidden: computed('hide', 'count', function () { if (this.get('hide')) { return (this.get('count') === 1); } return false; - }.property('hide', 'count'), - - pages: function () { - var seperator = this.get('seperator'), - current = this.get('current'), - count = this.get('count'), - countOut = this.get('countOut'), - countIn = this.get('countIn'), - result = [], - i; + }), + + pages: computed('count', 'current', 'countOut', 'countIn', function () { + var seperator = this.get('seperator'); + var current = this.get('current'); + var count = this.get('count'); + var countOut = this.get('countOut'); + var countIn = this.get('countIn'); + var result = []; + var i; // Beginning group of pages: n1...n2 var n1 = 1; @@ -100,13 +103,13 @@ var PaginationPagerComponent = Ember.Component.extend({ }); return result; - }.property('count', 'current', 'countOut', 'countIn'), + }), click: function (event) { // stop `#` from jumping to top of page event.preventDefault(); }, - + actions: { next: function () { if (!this.get('isLast')) { @@ -115,7 +118,7 @@ var PaginationPagerComponent = Ember.Component.extend({ this.set('current', parseInt(current, 10) + 1); } }, - + previous: function () { if (!this.get('isFirst')) { var current = this.get('current'); diff --git a/addon/templates/components/page-item.hbs b/addon/templates/components/page-item.hbs new file mode 100644 index 0000000..d4d2c6e --- /dev/null +++ b/addon/templates/components/page-item.hbs @@ -0,0 +1,5 @@ +{{#if isDots}} + {{content}} +{{else}} + {{content}} +{{/if}} diff --git a/src/template.hbs b/addon/templates/components/pagination-pager.hbs similarity index 64% rename from src/template.hbs rename to addon/templates/components/pagination-pager.hbs index b6305df..0fd0e76 100644 --- a/src/template.hbs +++ b/addon/templates/components/pagination-pager.hbs @@ -1,18 +1,14 @@ +{{log pages}} +{{log pager}} {{#unless pager}}
  • {{paginationPrevious}}
  • - {{#each pages itemController='paginationPage'}} - {{#if isDots}} -
  • - {{content}} -
  • - {{else}} -
  • - {{content}} -
  • - {{/if}} + + {{#each page in pages}} + {{page-item page=page selected=current seperator=seperator}} {{/each}} +
  • {{paginationNext}}
  • diff --git a/app/.gitkeep b/app/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/components/pagination-pager.js b/app/components/pagination-pager.js new file mode 100644 index 0000000..0102052 --- /dev/null +++ b/app/components/pagination-pager.js @@ -0,0 +1,4 @@ +import Ember from 'ember'; +import PaginationPager from 'pagination-pager/components/pagination-pager'; + +export default PaginationPager; diff --git a/bower.json b/bower.json index 3faf89e..d015c49 100644 --- a/bower.json +++ b/bower.json @@ -1,28 +1,20 @@ { "name": "pagination-pager", - "version": "0.2.0", - "description": "{{pagination-pager}} - Ember.js Component for Bootstrap 3 pagination & pager components", - "homepage": "https://github.com/knownasilya/pagination-pager", - "authors": [ - "Ilya Radchenko " - ], - "main": "dist/pagination-pager.js", - "keywords": [ - "pagination", - "pager", - "bootstrap", - "bs3", - "component", - "ember", - "emberjs", - "web-components" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] + "dependencies": { + "handlebars": "~1.3.0", + "jquery": "^1.11.1", + "ember": "1.8.1", + "ember-data": "1.0.0-beta.12", + "ember-resolver": "~0.1.10", + "loader.js": "stefanpenner/loader.js#1.0.1", + "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3", + "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4", + "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2", + "ember-qunit": "0.1.8", + "ember-qunit-notifications": "0.0.4", + "qunit": "~1.15.0" + }, + "devDependencies": { + "bootstrap": "~3.3.1" + } } diff --git a/config/environment.js b/config/environment.js new file mode 100644 index 0000000..0dfaed4 --- /dev/null +++ b/config/environment.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function(/* environment, appConfig */) { + return { }; +}; diff --git a/dist/pagination-pager.js b/dist/pagination-pager.js deleted file mode 100644 index c4b48c8..0000000 --- a/dist/pagination-pager.js +++ /dev/null @@ -1,158 +0,0 @@ -(function (Ember) { -var PaginationPageController = Ember.ObjectController.extend({ - isActive: function () { - return this.get('content') == this.get('parentController.current'); - }.property('content', 'parentController.current'), - - isDots: function () { - var parentController = this.get('parentController'); - var seperator = parentController ? parentController.get('seperator') : '…'; - var content = this.get('content'); - - return content === seperator; - }.property('content'), - - actions: { - setCurrent: function () { - this.set('parentController.current', this.get('content')); - } - } -}); - -var PaginationPagerComponent = Ember.Component.extend({ - tagName: 'ul', - classNameBindings: ['pager:pager:pagination', 'isHidden:hidden', 'paginationSizeClass'], - pager: false, - hide: false, - pagerNext: 'Next', - pagerPrevious: 'Previous', - paginationPrevious: '«', - paginationNext: '»', - seperator: '…', - countOut: 2, - countIn: 2, - firstPage: 1, - current: 1, - lastPage: Ember.computed.alias('count'), - - currentPage: function () { - return Number(this.get('current')); - }.property('current'), - - paginationSizeClass: function () { - var size = this.get('size'); - var pager = this.get('pager'); - - return !pager && size && (size === 'lg' || size === 'sm') ? 'pagination-' + size : ''; - }.property('paginationSize'), - - isFirst: function () { - return this.get('current') == this.get('firstPage'); - }.property('firstPage', 'current'), - - isLast: function () { - return this.get('current') == this.get('lastPage'); - }.property('lastPage', 'current'), - - isHidden: function () { - if (this.get('hide')) { - return (this.get('count') === 1); - } - return false; - }.property('hide', 'count'), - - pages: function () { - var seperator = this.get('seperator'), - current = this.get('current'), - count = this.get('count'), - countOut = this.get('countOut'), - countIn = this.get('countIn'), - result = [], - i; - - // Beginning group of pages: n1...n2 - var n1 = 1; - var n2 = Math.min(countOut, count); - - // Ending group of pages: n7...n8 - var n7 = Math.max(1, (count - countOut + 1)); - var n8 = count; - - // Middle group of pages: n4...n5 - var n4 = Math.max(n2 + 1, current - countIn); - var n5 = Math.min(n7 - 1, current + countIn); - var useMiddle = (n5 >= n4); - - // Point n3 between n2 and n4 - var n3 = Math.floor((n2 + n4) / 2); - var useN3 = (useMiddle && ((n4 - n2) > 1)); - - // Point $n6 between $n5 and $n7 - var n6 = Math.floor((n5 + n7) / 2); - var useN6 = (useMiddle && ((n7 - n5) > 1)); - - var links = []; - - // Generate links data in accordance with calculated numbers - for (var n = n1; n <= n2; n++) { - links[n] = n; - } - - if (useN3) { - links[n3] = seperator; - } - - for (i = n4; i <= n5; i++) { - links[i] = i; - } - - if (useN6) { - links[n6] = seperator; - } - - for (i = n7; i <= n8; i++) { - links[i] = i; - } - - links.forEach(function (content, number) { - result.push(content); - }); - - return result; - }.property('count', 'current', 'countOut', 'countIn'), - - click: function (event) { - // stop `#` from jumping to top of page - event.preventDefault(); - }, - - actions: { - next: function () { - if (!this.get('isLast')) { - var current = this.get('current'); - - this.set('current', parseInt(current, 10) + 1); - } - }, - - previous: function () { - if (!this.get('isFirst')) { - var current = this.get('current'); - - this.set('current', parseInt(current, 10) - 1); - } - } - } -}); - -Ember.Application.initializer({ - name: 'pagination-pager', - - initialize: function(container, application) { - container.register('component:pagination-pager', PaginationPagerComponent); - container.register('controller:paginationPage', PaginationPageController); - application.inject('component:pagination-pager', 'paginationPage', 'controller:paginationPage'); - } -}); - -}(window.Ember)); \ No newline at end of file diff --git a/dist/pagination-pager.min.js b/dist/pagination-pager.min.js deleted file mode 100644 index eadae07..0000000 --- a/dist/pagination-pager.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){var e=t.ObjectController.extend({isActive:function(){return this.get("content")==this.get("parentController.current")}.property("content","parentController.current"),isDots:function(){var t=this.get("parentController"),e=t?t.get("seperator"):"…",n=this.get("content");return n===e}.property("content"),actions:{setCurrent:function(){this.set("parentController.current",this.get("content"))}}}),n=t.Component.extend({tagName:"ul",classNameBindings:["pager:pager:pagination","isHidden:hidden","paginationSizeClass"],pager:!1,hide:!1,pagerNext:"Next",pagerPrevious:"Previous",paginationPrevious:"«",paginationNext:"»",seperator:"…",countOut:2,countIn:2,firstPage:1,current:1,lastPage:t.computed.alias("count"),currentPage:function(){return Number(this.get("current"))}.property("current"),paginationSizeClass:function(){var t=this.get("size"),e=this.get("pager");return e||!t||"lg"!==t&&"sm"!==t?"":"pagination-"+t}.property("paginationSize"),isFirst:function(){return this.get("current")==this.get("firstPage")}.property("firstPage","current"),isLast:function(){return this.get("current")==this.get("lastPage")}.property("lastPage","current"),isHidden:function(){return this.get("hide")?1===this.get("count"):!1}.property("hide","count"),pages:function(){for(var t,e=this.get("seperator"),n=this.get("current"),r=this.get("count"),i=this.get("countOut"),o=this.get("countIn"),a=[],s=1,u=Math.min(i,r),c=Math.max(1,r-i+1),g=r,p=Math.max(u+1,n-o),h=Math.min(c-1,n+o),l=h>=p,f=Math.floor((u+p)/2),d=l&&p-u>1,m=Math.floor((h+c)/2),P=l&&c-h>1,v=[],C=s;u>=C;C++)v[C]=C;for(d&&(v[f]=e),t=p;h>=t;t++)v[t]=t;for(P&&(v[m]=e),t=c;g>=t;t++)v[t]=t;return v.forEach(function(t){a.push(t)}),a}.property("count","current","countOut","countIn"),click:function(t){t.preventDefault()},actions:{next:function(){if(!this.get("isLast")){var t=this.get("current");this.set("current",parseInt(t,10)+1)}},previous:function(){if(!this.get("isFirst")){var t=this.get("current");this.set("current",parseInt(t,10)-1)}}}});t.Application.initializer({name:"pagination-pager",initialize:function(t,r){t.register("component:pagination-pager",n),t.register("controller:paginationPage",e),r.inject("component:pagination-pager","paginationPage","controller:paginationPage")}})}(window.Ember); \ No newline at end of file diff --git a/dist/pagination-pager.template.js b/dist/pagination-pager.template.js deleted file mode 100644 index babe70d..0000000 --- a/dist/pagination-pager.template.js +++ /dev/null @@ -1,105 +0,0 @@ -this["Ember"] = this["Ember"] || {}; -this["Ember"]["TEMPLATES"] = this["Ember"]["TEMPLATES"] || {}; -this["Ember"]["TEMPLATES"]["components/pagination-pager"] = Ember.Handlebars.template(function (Handlebars,depth0,helpers,partials,data) { - this.compilerInfo = [4,'>= 1.0.0']; -helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; - var buffer = '', stack1, escapeExpression=this.escapeExpression, self=this; - -function program1(depth0,data) { - - var buffer = '', stack1; - data.buffer.push("\n
  • \n "); - stack1 = helpers._triageMustache.call(depth0, "paginationPrevious", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n "); - stack1 = helpers.each.call(depth0, "pages", {hash:{ - 'itemController': ("paginationPage") - },hashTypes:{'itemController': "STRING"},hashContexts:{'itemController': depth0},inverse:self.noop,fn:self.program(2, program2, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n "); - stack1 = helpers._triageMustache.call(depth0, "paginationNext", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n"); - return buffer; - } -function program2(depth0,data) { - - var buffer = '', stack1; - data.buffer.push("\n "); - stack1 = helpers['if'].call(depth0, "isDots", {hash:{},hashTypes:{},hashContexts:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n "); - return buffer; - } -function program3(depth0,data) { - - var buffer = '', stack1; - data.buffer.push("\n
  • \n "); - stack1 = helpers._triageMustache.call(depth0, "content", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n "); - return buffer; - } - -function program5(depth0,data) { - - var buffer = '', stack1; - data.buffer.push("\n
  • \n "); - stack1 = helpers._triageMustache.call(depth0, "content", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n "); - return buffer; - } - -function program7(depth0,data) { - - var buffer = '', stack1; - data.buffer.push("\n
  • \n "); - stack1 = helpers._triageMustache.call(depth0, "pagerPrevious", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n\n
  • \n "); - stack1 = helpers._triageMustache.call(depth0, "pagerNext", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n
  • \n"); - return buffer; - } - - stack1 = helpers.unless.call(depth0, "pager", {hash:{},hashTypes:{},hashContexts:{},inverse:self.program(7, program7, data),fn:self.program(1, program1, data),contexts:[depth0],types:["ID"],data:data}); - if(stack1 || stack1 === 0) { data.buffer.push(stack1); } - data.buffer.push("\n"); - return buffer; - }); \ No newline at end of file diff --git a/dist/pagination-pager.template.min.js b/dist/pagination-pager.template.min.js deleted file mode 100644 index c70c943..0000000 --- a/dist/pagination-pager.template.min.js +++ /dev/null @@ -1 +0,0 @@ -this.Ember=this.Ember||{},this.Ember.TEMPLATES=this.Ember.TEMPLATES||{},this.Ember.TEMPLATES["components/pagination-pager"]=Ember.Handlebars.template(function(s,a,e,t,h){function n(s,a){var t,h="";return a.buffer.push("\n
  • \n "),t=e._triageMustache.call(s,"paginationPrevious",{hash:{},hashTypes:{},hashContexts:{},contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n "),t=e.each.call(s,"pages",{hash:{itemController:"paginationPage"},hashTypes:{itemController:"STRING"},hashContexts:{itemController:s},inverse:o.noop,fn:o.program(2,r,a),contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n "),t=e._triageMustache.call(s,"paginationNext",{hash:{},hashTypes:{},hashContexts:{},contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n"),h}function r(s,a){var t,h="";return a.buffer.push("\n "),t=e["if"].call(s,"isDots",{hash:{},hashTypes:{},hashContexts:{},inverse:o.program(5,p,a),fn:o.program(3,u,a),contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n "),h}function u(s,a){var t,h="";return a.buffer.push("\n
  • \n "),t=e._triageMustache.call(s,"content",{hash:{},hashTypes:{},hashContexts:{},contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n "),h}function p(s,a){var t,h="";return a.buffer.push("\n
  • \n "),t=e._triageMustache.call(s,"content",{hash:{},hashTypes:{},hashContexts:{},contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n "),h}function f(s,a){var t,h="";return a.buffer.push("\n
  • \n "),t=e._triageMustache.call(s,"pagerPrevious",{hash:{},hashTypes:{},hashContexts:{},contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n\n
  • \n "),t=e._triageMustache.call(s,"pagerNext",{hash:{},hashTypes:{},hashContexts:{},contexts:[s],types:["ID"],data:a}),(t||0===t)&&a.buffer.push(t),a.buffer.push("\n
  • \n"),h}this.compilerInfo=[4,">= 1.0.0"],e=this.merge(e,Ember.Handlebars.helpers),h=h||{};var l,c="",i=this.escapeExpression,o=this;return l=e.unless.call(a,"pager",{hash:{},hashTypes:{},hashContexts:{},inverse:o.program(7,f,h),fn:o.program(1,n,h),contexts:[a],types:["ID"],data:h}),(l||0===l)&&h.buffer.push(l),h.buffer.push("\n"),c}); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 9625eac..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,77 +0,0 @@ -var gulp = require('gulp'); -var concat = require('gulp-concat'); -var uglify = require('gulp-uglify'); -var rename = require('gulp-rename'); -var clean = require('gulp-clean'); -var wrap = require('gulp-wrap'); -var declare = require('gulp-declare'); -var precompile = require('ember-template-compiler').precompile; -var livereload = require('gulp-livereload'); -var serve = require('gulp-serve'); -var jshint = require('gulp-jshint'); -var stylish = require('jshint-stylish'); -var through = require('through2'); -var name = 'pagination-pager'; - -gulp.task('clean-dist', function () { - gulp.src('dist', { read: false }) - .pipe(clean()); -}); - -gulp.task('lint', function () { - return gulp.src(['./src/**/*.js']) - .pipe(jshint()) - .pipe(jshint.reporter(stylish)) - .pipe(jshint.reporter('fail')); -}); - -gulp.task('templates', function(){ - gulp.src('src/template.hbs') - .pipe(through.obj(function (file, encoding, done) { - if (file.isBuffer()) { - var contents = file._contents.toString(); - var precompiled = precompile(contents, false); - - file._contents = new Buffer(precompiled); - } - - this.push(file); - return done(); - })) - .pipe(wrap('Ember.Handlebars.template(<%= contents %>)')) - .pipe(declare({ - namespace: 'Ember.TEMPLATES', - noRedeclare: true, // Avoid duplicate declarations - processName: function () { - return 'components/' + name; - } - })) - .pipe(rename(name + '.template.js')) - .pipe(gulp.dest('dist')) - .pipe(uglify()) - .pipe(rename(name + '.template.min.js')) - .pipe(gulp.dest('dist')); -}); - -gulp.task('scripts', function () { - gulp.src(['src/item-controller.js', 'src/component.js', 'src/initializer.js']) - .pipe(concat(name + '.js')) - .pipe(wrap('(function (Ember) {\n<%= contents %>\n}(window.Ember));')) - .pipe(gulp.dest('dist')) - .pipe(uglify()) - .pipe(rename(name + '.min.js')) - .pipe(gulp.dest('dist')); -}); - -gulp.task('serve', serve(['test', 'dist'])); - -gulp.task('dev', ['default'], function() { - livereload.listen(); - - gulp.watch('src/*', ['templates', 'scripts']); - gulp.watch('dist/*.js').on('change', livereload.changed); - gulp.watch('test/index.html').on('change', livereload.changed); -}); - -gulp.task('default', ['clean-dist', 'lint', 'templates', 'scripts']); - diff --git a/index.js b/index.js new file mode 100644 index 0000000..48458a3 --- /dev/null +++ b/index.js @@ -0,0 +1,6 @@ +/* jshint node: true */ +'use strict'; + +module.exports = { + name: 'pagination-pager' +}; diff --git a/package.json b/package.json index 7f073af..4ddd988 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,46 @@ { "name": "pagination-pager", - "version": "0.2.0", - "description": "{{pagination-pager}} - Ember.js Component for Bootstrap 3 pagination & pager components", - "main": "pagination-pager.js", + "version": "1.0.0", + "directories": { + "doc": "doc", + "test": "tests" + }, "scripts": { - "test": "mocha", - "start": "rm -rf dist && mkdir dist && gulp && goat -e test/index.html dist" + "start": "ember server", + "build": "ember build", + "test": "ember test" }, "repository": { "type": "git", "url": "git://github.com/knownasilya/pagination-pager.git" }, + "bugs": { + "url": "https://github.com/knownasilya/pagination-pager/issues" + }, + "homepage": "https://github.com/knownasilya/pagination-pager", + "repository": "", + "engines": { + "node": ">= 0.10.0" + }, + "author": "Ilya Radchenko ", + "license": "MIT", + "devDependencies": { + "broccoli-asset-rev": "^1.0.0", + "broccoli-ember-hbs-template-compiler": "^1.6.1", + "ember-cli": "0.1.4", + "ember-cli-dependency-checker": "0.0.6", + "ember-cli-esnext": "0.1.1", + "ember-cli-ic-ajax": "0.1.1", + "ember-cli-inject-live-reload": "^1.3.0", + "ember-cli-qunit": "0.1.2", + "ember-data": "1.0.0-beta.12", + "ember-export-application-global": "^1.0.0", + "express": "^4.8.5", + "glob": "^4.0.5" + }, + "description": "{{pagination-pager}} - Ember.js Component for Bootstrap 3 pagination & pager components", "keywords": [ + "ember-addon", "pagination", "pager", "bootstrap", @@ -20,29 +49,7 @@ "ember", "emberjs" ], - "author": "Ilya Radchenko ", - "license": "MIT", - "bugs": { - "url": "https://github.com/knownasilya/pagination-pager/issues" - }, - "homepage": "https://github.com/knownasilya/pagination-pager", - "devDependencies": { - "ember-template-compiler": "^1.6.1", - "goat": "^0.4.1", - "gulp": "^3.8.8", - "gulp-clean": "^0.3.1", - "gulp-concat": "^2.2.0", - "gulp-declare": "^0.3.0", - "gulp-livereload": "^2.1.1", - "gulp-rename": "^1.2.0", - "gulp-serve": "^0.2.0", - "gulp-uglify": "^1.0.1", - "gulp-wrap": "^0.3.0", - "gulp-jshint": "^1.6.1", - "jshint": "^2.5.0", - "jshint-stylish": "^0.4.0", - "handlebars": "^1.3.0", - "mocha": "^1.18.2", - "through2": "^0.6.1" + "ember-addon": { + "configPath": "tests/dummy/config" } } diff --git a/src/initializer.js b/src/initializer.js deleted file mode 100644 index e681551..0000000 --- a/src/initializer.js +++ /dev/null @@ -1,12 +0,0 @@ -/* global PaginationPagerComponent, PaginationPageController */ -'use strict'; - -Ember.Application.initializer({ - name: 'pagination-pager', - - initialize: function(container, application) { - container.register('component:pagination-pager', PaginationPagerComponent); - container.register('controller:paginationPage', PaginationPageController); - application.inject('component:pagination-pager', 'paginationPage', 'controller:paginationPage'); - } -}); diff --git a/src/item-controller.js b/src/item-controller.js deleted file mode 100644 index 4a80e3b..0000000 --- a/src/item-controller.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var PaginationPageController = Ember.ObjectController.extend({ - isActive: function () { - return this.get('content') === this.get('parentController.current'); - }.property('content', 'parentController.current'), - - isDots: function () { - var parentController = this.get('parentController'); - var seperator = parentController ? parentController.get('seperator') : '…'; - var content = this.get('content'); - - return content === seperator; - }.property('content'), - - actions: { - setCurrent: function () { - this.set('parentController.current', this.get('content')); - } - } -}); diff --git a/test/index.html b/test/index.html deleted file mode 100644 index adfbac4..0000000 --- a/test/index.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - pagination-pager - - - - - - - - - - - - - - - - - diff --git a/testem.json b/testem.json new file mode 100644 index 0000000..eff93f9 --- /dev/null +++ b/testem.json @@ -0,0 +1,11 @@ +{ + "framework": "qunit", + "test_page": "tests/index.html", + "launch_in_ci": [ + "PhantomJS" + ], + "launch_in_dev": [ + "PhantomJS", + "Chrome" + ] +} diff --git a/tests/.jshintrc b/tests/.jshintrc new file mode 100644 index 0000000..6ebf71a --- /dev/null +++ b/tests/.jshintrc @@ -0,0 +1,74 @@ +{ + "predef": [ + "document", + "window", + "location", + "setTimeout", + "$", + "-Promise", + "QUnit", + "define", + "console", + "equal", + "notEqual", + "notStrictEqual", + "test", + "asyncTest", + "testBoth", + "testWithDefault", + "raises", + "throws", + "deepEqual", + "start", + "stop", + "ok", + "strictEqual", + "module", + "moduleFor", + "moduleForComponent", + "moduleForModel", + "process", + "expect", + "visit", + "exists", + "fillIn", + "click", + "keyEvent", + "triggerEvent", + "find", + "findWithAssert", + "wait", + "DS", + "isolatedContainer", + "startApp", + "andThen", + "currentURL", + "currentPath", + "currentRouteName" + ], + "node": false, + "browser": false, + "boss": true, + "curly": false, + "debug": false, + "devel": false, + "eqeqeq": true, + "evil": true, + "forin": false, + "immed": false, + "laxbreak": false, + "newcap": true, + "noarg": true, + "noempty": false, + "nonew": false, + "nomen": false, + "onevar": false, + "plusplus": false, + "regexp": false, + "undef": true, + "sub": true, + "strict": false, + "white": false, + "eqnull": true, + "esnext": true +} diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js new file mode 100644 index 0000000..757df38 --- /dev/null +++ b/tests/dummy/app/app.js @@ -0,0 +1,16 @@ +import Ember from 'ember'; +import Resolver from 'ember/resolver'; +import loadInitializers from 'ember/load-initializers'; +import config from './config/environment'; + +Ember.MODEL_FACTORY_INJECTIONS = true; + +var App = Ember.Application.extend({ + modulePrefix: config.modulePrefix, + podModulePrefix: config.podModulePrefix, + Resolver: Resolver +}); + +loadInitializers(App, config.modulePrefix); + +export default App; diff --git a/tests/dummy/app/components/.gitkeep b/tests/dummy/app/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/app/controllers/.gitkeep b/tests/dummy/app/controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/app/helpers/.gitkeep b/tests/dummy/app/helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/app/index.html b/tests/dummy/app/index.html new file mode 100644 index 0000000..1c49d36 --- /dev/null +++ b/tests/dummy/app/index.html @@ -0,0 +1,25 @@ + + + + + + Dummy + + + + {{content-for 'head'}} + + + + + {{content-for 'head-footer'}} + + + {{content-for 'body'}} + + + + + {{content-for 'body-footer'}} + + diff --git a/tests/dummy/app/models/.gitkeep b/tests/dummy/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js new file mode 100644 index 0000000..cef554b --- /dev/null +++ b/tests/dummy/app/router.js @@ -0,0 +1,11 @@ +import Ember from 'ember'; +import config from './config/environment'; + +var Router = Ember.Router.extend({ + location: config.locationType +}); + +Router.map(function() { +}); + +export default Router; diff --git a/tests/dummy/app/routes/.gitkeep b/tests/dummy/app/routes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/app/styles/app.css b/tests/dummy/app/styles/app.css new file mode 100644 index 0000000..9adb5ad --- /dev/null +++ b/tests/dummy/app/styles/app.css @@ -0,0 +1,3 @@ +html, body { + margin: 20px; +} diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs new file mode 100644 index 0000000..34d54bc --- /dev/null +++ b/tests/dummy/app/templates/application.hbs @@ -0,0 +1,14 @@ +

    pagination-pager

    + +{{outlet}} + +{{pagination-pager count=5 current=2 pager=true pagerNext='New' pagerPrevious='Old'}}
    +{{pagination-pager count=5 current=1 pager=true pagerSpread=true}}
    +{{pagination-pager count=5 current=2}}
    +{{pagination-pager count=5 current=1}}
    +{{pagination-pager count=50 current=1}}
    +{{pagination-pager count=5 current=5 size='lg'}}
    +{{pagination-pager count=5 current=5 size='lg' paginationNext='next' paginationPrevious='previous'}}
    +{{pagination-pager count=1 current=1}}
    +{{pagination-pager count=1 current=1 hide=true}} +{{pagination-pager count=1 current=1 pager=true hide=true}} diff --git a/tests/dummy/app/templates/components/.gitkeep b/tests/dummy/app/templates/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/app/views/.gitkeep b/tests/dummy/app/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js new file mode 100644 index 0000000..d3f169f --- /dev/null +++ b/tests/dummy/config/environment.js @@ -0,0 +1,47 @@ +/* jshint node: true */ + +module.exports = function(environment) { + var ENV = { + modulePrefix: 'dummy', + environment: environment, + baseURL: '/', + locationType: 'auto', + EmberENV: { + FEATURES: { + // Here you can enable experimental features on an ember canary build + // e.g. 'with-controller': true + } + }, + + APP: { + // Here you can pass flags/options to your application instance + // when it is created + } + }; + + if (environment === 'development') { + // ENV.APP.LOG_RESOLVER = true; + ENV.APP.LOG_ACTIVE_GENERATION = true; + // ENV.APP.LOG_TRANSITIONS = true; + // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; + ENV.APP.LOG_VIEW_LOOKUPS = true; + } + + if (environment === 'test') { + // Testem prefers this... + ENV.baseURL = '/'; + ENV.locationType = 'none'; + + // keep test console output quieter + ENV.APP.LOG_ACTIVE_GENERATION = false; + ENV.APP.LOG_VIEW_LOOKUPS = false; + + ENV.APP.rootElement = '#ember-testing'; + } + + if (environment === 'production') { + + } + + return ENV; +}; diff --git a/tests/dummy/public/.gitkeep b/tests/dummy/public/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/dummy/public/crossdomain.xml b/tests/dummy/public/crossdomain.xml new file mode 100644 index 0000000..29a035d --- /dev/null +++ b/tests/dummy/public/crossdomain.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/tests/dummy/public/robots.txt b/tests/dummy/public/robots.txt new file mode 100644 index 0000000..5debfa4 --- /dev/null +++ b/tests/dummy/public/robots.txt @@ -0,0 +1,2 @@ +# http://www.robotstxt.org +User-agent: * diff --git a/tests/helpers/resolver.js b/tests/helpers/resolver.js new file mode 100644 index 0000000..28f4ece --- /dev/null +++ b/tests/helpers/resolver.js @@ -0,0 +1,11 @@ +import Resolver from 'ember/resolver'; +import config from '../../config/environment'; + +var resolver = Resolver.create(); + +resolver.namespace = { + modulePrefix: config.modulePrefix, + podModulePrefix: config.podModulePrefix +}; + +export default resolver; diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js new file mode 100644 index 0000000..e087e48 --- /dev/null +++ b/tests/helpers/start-app.js @@ -0,0 +1,19 @@ +import Ember from 'ember'; +import Application from '../../app'; +import Router from '../../router'; +import config from '../../config/environment'; + +export default function startApp(attrs) { + var App; + + var attributes = Ember.merge({}, config.APP); + attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; + + Ember.run(function() { + App = Application.create(attributes); + App.setupForTesting(); + App.injectTestHelpers(); + }); + + return App; +} diff --git a/tests/index.html b/tests/index.html new file mode 100644 index 0000000..4112b61 --- /dev/null +++ b/tests/index.html @@ -0,0 +1,49 @@ + + + + + + Dummy Tests + + + + {{content-for 'head'}} + {{content-for 'test-head'}} + + + + + + + {{content-for 'head-footer'}} + {{content-for 'test-head-footer'}} + + + + {{content-for 'body'}} + {{content-for 'test-body'}} + + + + + + + {{content-for 'body-footer'}} + {{content-for 'test-body-footer'}} + + diff --git a/tests/test-helper.js b/tests/test-helper.js new file mode 100644 index 0000000..b5f6449 --- /dev/null +++ b/tests/test-helper.js @@ -0,0 +1,12 @@ +import resolver from './helpers/resolver'; +import { + setResolver +} from 'ember-qunit'; + +setResolver(resolver); + +document.write('
    '); + +QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'}); +var containerVisibility = QUnit.urlParams.nocontainer ? 'hidden' : 'visible'; +document.getElementById('ember-testing-container').style.visibility = containerVisibility; diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/components/pagination-pager-test.js b/tests/unit/components/pagination-pager-test.js new file mode 100644 index 0000000..206e095 --- /dev/null +++ b/tests/unit/components/pagination-pager-test.js @@ -0,0 +1,21 @@ +import { + moduleForComponent, + test +} from 'ember-qunit'; + +moduleForComponent('pagination-pager', 'PaginationPagerComponent', { + // specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'] +}); + +test('it renders', function() { + expect(2); + + // creates the component instance + var component = this.subject(); + equal(component._state, 'preRender'); + + // appends the component to the page + this.append(); + equal(component._state, 'inDOM'); +}); diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 0000000..e69de29