-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Max Gorin
committed
Dec 25, 2015
1 parent
4f1a738
commit ba29bd6
Showing
13 changed files
with
117 additions
and
94 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
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,32 +1,43 @@ | ||
// FeedbackGhost is a little class that displays unified feedback from Netzke components. | ||
Ext.define('Netzke.FeedbackGhost', { | ||
showFeedback: function(msg, options){ | ||
options = options || {}; | ||
options.delay = options.delay || Netzke.Core.FeedbackDelay; | ||
if (Ext.isObject(msg)) { | ||
this.msg(msg.level.camelize(), msg.msg, options.delay); | ||
} else if (Ext.isArray(msg)) { | ||
Ext.each(msg, function(m) { this.showFeedback(m); }, this); | ||
} else { | ||
this.msg(null, msg, options.delay); // no header for now | ||
} | ||
}, | ||
/** | ||
* Class creating simple notifications. Borrowed from http://dev.sencha.com/extjs/5.1.0/examples/shared/examples.js | ||
* @class Netzke.Notifier | ||
*/ | ||
Ext.define('Netzke.Notifier', function(){ | ||
var msgCt; | ||
|
||
function createBox(t, s){ | ||
return t ? | ||
'<div class="msg ' + Ext.baseCSSPrefix + 'border-box"><h3>' + t + '</h3><p>' + s + '</p></div>' | ||
: | ||
'<div class="msg ' + Ext.baseCSSPrefix + 'border-box"><p>' + s + '</p></div>'; | ||
} | ||
|
||
|
||
return { | ||
/** | ||
* Shows notification on the screen. | ||
* @method msg | ||
* @param {String} msg Notification body HTML | ||
* @param {Object} options May contain the following keys: | ||
* | ||
* * **title** - title of notification | ||
* * **delay** (ms) - time notification should stay on the screen | ||
*/ | ||
msg: function(msg, options){ | ||
if (options == undefined) options = {}; | ||
|
||
msg: function(title, format, delay){ | ||
if(!this.msgCt){ | ||
this.msgCt = Ext.core.DomHelper.insertFirst(document.body, {id:'msg-div'}, true); | ||
if (Ext.isArray(msg)) { | ||
msg = msg.join("<br>") | ||
} | ||
var s = Ext.String.format.apply(String, Array.prototype.slice.call(arguments, 1)); | ||
var m = Ext.core.DomHelper.append(this.msgCt, this.createBox(title, s), true); | ||
m.hide(); | ||
m.slideIn('t').ghost("t", { delay: delay, remove: true}); | ||
}, | ||
|
||
createBox: function(t, s){ | ||
if (t) { | ||
return '<div class="msg"><h3>' + t + '</h3><p>' + s + '</p></div>'; | ||
} else { | ||
return '<div class="msg"><p>' + s + '</p></div>'; | ||
if (msgCt) { | ||
document.body.appendChild(msgCt.dom); | ||
} else { | ||
msgCt = Ext.DomHelper.append(document.body, {id:'msg-div'}, true); | ||
} | ||
var m = Ext.DomHelper.append(msgCt, createBox(options.title, msg), true); | ||
m.hide(); | ||
m.slideIn('t').ghost("t", { delay: options.delay || Netzke.Core.NotificationDelay, remove: true}); | ||
} | ||
} | ||
}; | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
describe "Notifier component", -> | ||
it "fires various notifications", (done) -> | ||
click button "Notify" | ||
expectToSee somewhere "Local feedback" | ||
expectToSee somewhere "Local notification" | ||
|
||
click button "Multiple notify" | ||
expectToSee somewhere "Line one" | ||
expectToSee somewhere "Line two" | ||
|
||
click button "Server notify" | ||
wait -> | ||
expectToSee somewhere "Message from server" | ||
expectToSee somewhere "Server notification" | ||
done() |
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
class Notifier < Netzke::Base | ||
action :notify | ||
action :multiple_notify | ||
action :server_notify | ||
|
||
def configure(c) | ||
super | ||
c.bbar = [:notify, :multiple_notify, :server_notify] | ||
end | ||
|
||
endpoint :notify do | ||
client.netzke_notify("Message from server", delay: 3000, title: 'Server notification') | ||
end | ||
end |
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,13 @@ | ||
{ | ||
handleNotify: function(){ | ||
this.netzkeNotify('Local' + ' feedback', {title: 'Local' + ' notification'}); | ||
}, | ||
|
||
handleServerNotify: function(){ | ||
this.server.notify(); | ||
}, | ||
|
||
handleMultipleNotify: function(){ | ||
this.netzkeNotify(['Line' + ' one', 'Line' + ' two']); | ||
} | ||
} |
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