Skip to content

Commit

Permalink
Merge pull request #75 from John-Henrique/master
Browse files Browse the repository at this point in the history
Notifications intl
  • Loading branch information
qathom committed Jan 31, 2016
2 parents 02f7964 + 6c26961 commit b8580eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Empty file.
9 changes: 5 additions & 4 deletions dist/js/components/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@
}
};

var buildNotif = function(text, timeout, showButton) {
var buildNotif = function(text, timeout, showButton, textButton) {
if(typeof text !== 'string') text = '';
timeout = (typeof timeout === 'number' ? timeout : 5000);
textButton = (typeof textButton === 'string' ? textButton : 'CANCEL');

var progress = '<div class="progress"><div class="determinate"></div></div>';
var btn = (showButton === true ? '<button class="btn pull-right" data-hide-notif="true">CANCEL</button>' : '');
var btn = (showButton === true ? '<button class="btn pull-right" data-hide-notif="true">'+ textButton +'</button>' : '');

var div = document.createElement('div');
div.setAttribute('class', 'notification');
Expand Down Expand Up @@ -202,12 +203,12 @@
}
}

phonon.notif = function(el, timeout, showButton) {
phonon.notif = function(el, timeout, showButton, textButton) {

if(arguments.length > 1) {

var text = el;
var nBuild = buildNotif(text, timeout, showButton);
var nBuild = buildNotif(text, timeout, showButton, textButton);
window.setTimeout(function() {
show(document.querySelector('#'+nBuild.id));
}, 10);
Expand Down
9 changes: 5 additions & 4 deletions dist/js/phonon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3085,12 +3085,13 @@ phonon.tagManager = (function () {
}
};

var buildNotif = function(text, timeout, showButton) {
var buildNotif = function(text, timeout, showButton, textButton) {
if(typeof text !== 'string') text = '';
timeout = (typeof timeout === 'number' ? timeout : 5000);
textButton = (typeof textButton === 'string' ? textButton : 'CANCEL');

var progress = '<div class="progress"><div class="determinate"></div></div>';
var btn = (showButton === true ? '<button class="btn pull-right" data-hide-notif="true">CANCEL</button>' : '');
var btn = (showButton === true ? '<button class="btn pull-right" data-hide-notif="true">'+ textButton +'</button>' : '');

var div = document.createElement('div');
div.setAttribute('class', 'notification');
Expand Down Expand Up @@ -3176,12 +3177,12 @@ phonon.tagManager = (function () {
}
}

phonon.notif = function(el, timeout, showButton) {
phonon.notif = function(el, timeout, showButton, textButton) {

if(arguments.length > 1) {

var text = el;
var nBuild = buildNotif(text, timeout, showButton);
var nBuild = buildNotif(text, timeout, showButton, textButton);
window.setTimeout(function() {
show(document.querySelector('#'+nBuild.id));
}, 10);
Expand Down
6 changes: 6 additions & 0 deletions examples/components/notifications-example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ <h1 class="title">Notifications</h1>
</header>
<div class="content">
<div class="padded-full">

<button class="btn btn-flat padded-bottom positive" id="show-notif-button">Show notification custom button</button>

<button class="btn btn-flat padded-bottom primary" id="show-auto-notif">Show another notification</button>

Expand Down Expand Up @@ -55,6 +57,10 @@ <h1 class="title">Notifications</h1>
document.querySelector('#show-auto-notif').on('tap', function() {
phonon.notif('HELLO', 3000, false);
});

document.querySelector('#show-notif-button').on('tap', function() {
phonon.notif('HELLO AGAIN :-p', 3000, true, 'Close' );
});

document.querySelector('#show-notif').on('tap', function() {
phonon.notif('#notif-example').show();
Expand Down

0 comments on commit b8580eb

Please sign in to comment.