Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v3.0 uses a component + helper architecture that removes several hack…
…s in previous versions, and is an ember-cli addon.
- Loading branch information
1 parent
e5b0707
commit c2abf62
Showing
64 changed files
with
810 additions
and
1,106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"directory": "bower_components", | ||
"analytics": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
node_modules/ | ||
bower_components/ | ||
tmp/ | ||
# See http://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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,20 @@ | ||
--- | ||
language: node_js | ||
node_js: | ||
- "0.11" | ||
- "0.10" | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
var makeModules = require('broccoli-dist-es6-module'), | ||
mergeTrees = require('broccoli-merge-trees'), | ||
templateCompiler = require('ember-cli-htmlbars'), | ||
exportTree = require('broccoli-export-tree'); | ||
/* jshint node: true */ | ||
/* global require, module */ | ||
|
||
var dist = makeModules('lib/', { | ||
global: 'EmberNotify', | ||
packageName: 'ember-notify', | ||
main: 'main', | ||
shim: { | ||
'ember': 'Ember' | ||
} | ||
}); | ||
var assets = templateCompiler('assets/'); | ||
var tree = mergeTrees([dist, assets]); | ||
//tree = exportTree(tree, {destDir: 'dist'}); | ||
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); | ||
|
||
module.exports = tree; | ||
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('vendor/ember-notify.css'); | ||
|
||
module.exports = app.toTree(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Changelog | ||
|
||
## v3.0 | ||
|
||
v3.0 uses a component + helper architecture that removes several hacks in previous versions, and | ||
integrates with ember-cli as an addon. | ||
|
||
- Projects that don't use ember-cli will need to stay on the v2.0 branch | ||
- You now need to add `{{ember-notify}}` to one of your templates, usually in `application.hbs`. | ||
- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import Ember from 'ember'; | ||
import Notify from 'ember-notify/main'; | ||
import {Message} from 'ember-notify/main'; | ||
|
||
export default Ember.Component.extend({ | ||
primary: true, | ||
messages: null, // this should be a Stream, maybe in Ember 2 | ||
|
||
classNames: ['ember-notify-cn'], | ||
messageStyle: 'foundation', | ||
|
||
init: function() { | ||
this._super(); | ||
if (!this.get('messages')) this.set('messages', []); | ||
|
||
if (this.get('primary')) Notify.set('primary', this); | ||
var style = this.get('messageStyle'), klass; | ||
if (style) { | ||
if ('foundation' === style) klass = FoundationView; | ||
else if ('bootstrap' === style) klass = BootstrapView; | ||
else throw new Error( | ||
"Unknown messageStyle %s: options are 'foundation' and 'bootstrap'".fmt(style) | ||
); | ||
} | ||
this.set('messageClass', klass || this.constructor.defaultViewClass); | ||
}, | ||
show: function(message) { | ||
if (!(message instanceof Message)) { | ||
message = Message.create(message); | ||
} | ||
this.messages.pushObject(message); | ||
return message; | ||
} | ||
}); | ||
|
||
export var BaseView = Ember.View.extend({ | ||
message: null, | ||
|
||
classNames: ['ember-notify'], | ||
classNameBindings: ['typeCss', 'message.visible:ember-notify-show:ember-notify-hidden'], | ||
attributeBindings: ['data-alert'], | ||
'data-alert': '', | ||
|
||
didInsertElement: function() { | ||
if (Ember.isNone(this.get('message.visible'))) { | ||
// the element is added to the DOM in its hidden state, so that | ||
// adding the 'ember-notify-show' class triggers the CSS transition | ||
Ember.run.schedule('afterRender', this, function() { | ||
this.set('message.visible', true); | ||
}); | ||
} | ||
var closeAfter = this.get('message.closeAfter'); | ||
if (closeAfter) { | ||
Ember.run.later(this, function() { | ||
if (this.get('isDestroyed')) return; | ||
this.set('message.visible', false); | ||
this.send('close'); | ||
}, closeAfter); | ||
} | ||
}, | ||
typeCss: function() { | ||
var cssClass = this.get('message.type'); | ||
if (cssClass === 'error') cssClass = 'alert error'; | ||
return cssClass; | ||
}.property('message.type'), | ||
close: function() { | ||
this.send('close'); | ||
}, | ||
actions: { | ||
close: function() { | ||
var that = this, removeAfter; | ||
this.set('message.visible', false); | ||
if (removeAfter = this.get('message.removeAfter')) { | ||
Ember.run.later(this, remove, removeAfter); | ||
} | ||
else { | ||
remove(); | ||
} | ||
function remove() { | ||
var parentView = that.get('parentView'); | ||
if (parentView) parentView.get('messages').removeObject(that.get('message')); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
export var FoundationView = BaseView.extend({ | ||
classNames: ['alert-box'], | ||
classNameBindings: ['radius::'] | ||
}); | ||
|
||
export var BootstrapView = BaseView.extend({ | ||
classNames: ['alert'], | ||
typeCss: function() { | ||
var type = this.get('type'); | ||
if (type === 'alert' || type === 'error') type = 'danger'; | ||
return 'alert-%@'.fmt(type); | ||
}.property('type') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Object.extend({ | ||
|
||
info: aliasToShow('info'), | ||
success: aliasToShow('success'), | ||
warning: aliasToShow('warning'), | ||
alert: aliasToShow('alert'), | ||
error: aliasToShow('error'), | ||
|
||
show: function(type, message, options) { | ||
if (typeof message === 'object') { | ||
options = message; | ||
message = null; | ||
} | ||
return this.get('primary').show(Ember.merge({ | ||
message: message, | ||
type: type | ||
}, options)); | ||
}, | ||
|
||
primary: function(key, val) { | ||
if (arguments.length === 1) { | ||
Ember.assert("Can't display notifications without a {{ember-notify}} in your " + | ||
"templates, usually in application.hbs", | ||
this._primary | ||
); | ||
} | ||
if (arguments.length === 2) { | ||
Ember.assert("Only one <ember-notify> should be primary=true. " + | ||
"If you want more than one then use <ember-notify primary=false messages=boundProperty>", | ||
!this._primary || this._primary.get('isDestroyed') | ||
); | ||
this._primary = val; | ||
} | ||
return this._primary; | ||
}.property() | ||
|
||
}).create(); | ||
|
||
export var Message = Ember.Object.extend({ | ||
message: null, | ||
raw: '', | ||
type: 'info', | ||
closeAfter: 2500, | ||
removeAfter: 250, // allow time for the close animation to finish | ||
|
||
visible: undefined // set to false to disable auto-showing | ||
}); | ||
|
||
function aliasToShow(type) { | ||
return function(message, options) { | ||
return this.show(type, message, options); | ||
}; | ||
} |
Oops, something went wrong.