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}}