Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan committed May 29, 2017
0 parents commit 81d0bb3
Show file tree
Hide file tree
Showing 50 changed files with 6,633 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "bower_components",
"analytics": false
}
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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

[*.hbs]
insert_final_newline = false

[*.{diff,md}]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .ember-cli
Original file line number Diff line number Diff line change
@@ -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
}
13 changes: 13 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
extends: 'eslint:recommended',
env: {
browser: true
},
rules: {
}
};
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log*
testem.log
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.eslintrc.js
.watchmanconfig
.travis.yml
bower.json
ember-cli-build.js
testem.js
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
language: node_js
node_js:
- "6"

sudo: false

cache:
directories:
- $HOME/.npm
- $HOME/.cache # includes bowers cache

env:
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
- EMBER_TRY_SCENARIO=ember-lts-2.4
- EMBER_TRY_SCENARIO=ember-lts-2.8
- EMBER_TRY_SCENARIO=ember-release
- EMBER_TRY_SCENARIO=ember-beta
- EMBER_TRY_SCENARIO=ember-canary
- EMBER_TRY_SCENARIO=ember-default

matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary

before_install:
- npm config set spin false
- npm install -g bower phantomjs-prebuilt
- bower --version
- phantomjs --version

install:
- npm install
- bower install

script:
# Usually, it's ok to finish the test scenario without reverting
# to the addon's original dependency state, skipping "cleanup".
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2017

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.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# ember-paper-dual-slider

This README outlines the details of collaborating on this Ember addon.

## Installation

* `git clone <repository-url>` this repository
* `cd ember-paper-dual-slider`
* `npm install`
* `bower install`

## Running

* `ember serve`
* Visit your app at [http://localhost:4200](http://localhost:4200).

## Running Tests

* `npm test` (Runs `ember try:each` to test your addon against multiple Ember versions)
* `ember test`
* `ember test --server`

## Building

* `ember build`

For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
Empty file added addon/.gitkeep
Empty file.
77 changes: 77 additions & 0 deletions addon/components/paper-dual-slider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import Ember from 'ember';
import layout from '../templates/components/paper-dual-slider';

import FocusableMixin from 'ember-paper/mixins/focusable-mixin';
import ColorMixin from 'ember-paper/mixins/color-mixin';
import clamp from 'ember-paper/utils/clamp';
import Component from 'ember-paper/components/paper-slider';

const {
String: {
htmlSafe
},
computed
} = Ember;

const percentStyleComputed = (key) => computed(key, function() {
const percent = this.get(key);
return htmlSafe(`left: ${(percent || 0) * 100}%;`);
});

const percentComputed = (key) => computed(key, 'min', 'max', function() {
const value = this.get(key);
const min = parseFloat(this.get('min') || 0, 10);
const max = parseFloat(this.get('max') || 0, 10);

return clamp((value - min) / (max - min), 0, 1);
});

export default Component.extend(FocusableMixin, ColorMixin, {
layout,
leftPercent: percentComputed('from'),
rightPercent: percentComputed('to'),

leftThumbStyle: percentStyleComputed('leftPercent'),
rightThumbStyle: percentStyleComputed('rightPercent'),

activeTrackStyle: computed('leftPercent', 'rightPercent', function() {
let left = this.get('leftPercent');
let right = this.get('rightPercent');
left *= 100;
right *= 100;
return htmlSafe(`left: ${left}%; width: ${right - left}%;`);
}),

isMinimum: computed('leftPercent', 'min', function() {
return this.get('leftPercent') === this.get('min');
}),

stepValidator(value) {
let step = parseFloat(this.get('step'), 10);
return parseFloat((Math.round(value / step) * step).toFixed(1), 10);
},

getClosestState(value) {
const fromDistance = Math.abs(this.get('from') - value);
const toDistance = Math.abs(this.get('to') - value);
if (toDistance < fromDistance) {
return 'to';
} else {
return 'from';
}
},

setValueFromEvent(value) {
let states = {
from: this.get('from'),
to: this.get('to')
};

let exactVal = this.percentToValue(this.positionToPercent(value));
let closestVal = this.minMaxValidator(this.stepValidator(exactVal));

states[this.getClosestState(closestVal)] = closestVal;

this.sendAction('onChange', states);
}
});
27 changes: 27 additions & 0 deletions addon/templates/components/paper-dual-slider.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="md-slider-wrapper">
<div class="md-slider-content">
<div class="md-track-container">
<div class="md-track"></div>
<div class="md-track md-track-fill" style={{activeTrackStyle}}></div>
<div class="md-track-ticks"></div>
</div>
<div class="md-thumb-container" style={{leftThumbStyle}}>
<div class="md-thumb" style="touch-action: none"></div>
<div class="md-focus-thumb"></div>
<div class="md-focus-ring"></div>
<div class="md-sign">
<span class="md-thumb-text">{{value}}</span>
</div>
<div class="md-disabled-thumb"></div>
</div>
<div class="md-thumb-container" style={{rightThumbStyle}}>
<div class="md-thumb" style="touch-action: none"></div>
<div class="md-focus-thumb"></div>
<div class="md-focus-ring"></div>
<div class="md-sign">
<span class="md-thumb-text">{{value}}</span>
</div>
<div class="md-disabled-thumb"></div>
</div>
</div>
</div>
Empty file added app/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions app/components/paper-dual-slider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-paper-dual-slider/components/paper-dual-slider';
4 changes: 4 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "ember-paper-dual-slider",
"dependencies": {}
}
91 changes: 91 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/* eslint-env node */
module.exports = {
scenarios: [
{
name: 'ember-lts-2.4',
bower: {
dependencies: {
'ember': 'components/ember#lts-2-4'
},
resolutions: {
'ember': 'lts-2-4'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-lts-2.8',
bower: {
dependencies: {
'ember': 'components/ember#lts-2-8'
},
resolutions: {
'ember': 'lts-2-8'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-release',
bower: {
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-beta',
bower: {
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-canary',
bower: {
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
},
npm: {
devDependencies: {
'ember-source': null
}
}
},
{
name: 'ember-default',
npm: {
devDependencies: {}
}
}
]
};
6 changes: 6 additions & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-env node */
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
};
17 changes: 17 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-env node */
const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
// Add options here
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/

return app.toTree();
};
Loading

0 comments on commit 81d0bb3

Please sign in to comment.