aboutsummaryrefslogtreecommitdiffstats
path: root/notifier/observer_growl.js
diff options
context:
space:
mode:
authorsuVene2008-12-08 18:04:17 +0000
committersuVene2008-12-08 18:04:17 +0000
commit4012d388f4e4698ac13e30f0d8d3c310cdfe55d5 (patch)
treea5759baaed32f98fefc96af30d3b930d4675e9e8 /notifier/observer_growl.js
parenta9eaeea1f3d7fdff871a94801d7b278b5def26ba (diff)
downloadvimperator-plugins-4012d388f4e4698ac13e30f0d8d3c310cdfe55d5.tar.bz2
*SubjectHttp定義.
*registerするときに下位クラスから基底クラスを指定するように変更. *notifier/observer/subject の PLUGIN_INFO対応 @see http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/pluginManager.js *ほか. git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26152 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'notifier/observer_growl.js')
-rw-r--r--notifier/observer_growl.js60
1 files changed, 30 insertions, 30 deletions
diff --git a/notifier/observer_growl.js b/notifier/observer_growl.js
index e8d61e5..0a3d1d3 100644
--- a/notifier/observer_growl.js
+++ b/notifier/observer_growl.js
@@ -1,17 +1,17 @@
-/**
- * notifier.js plugin observer
- * @name observer_growl.js
- * @description growl when notified.
- * @description-ja Growl風通知。
- * @author suVene suvene@zeromemory.info
- * @version 0.1.0
- * Last Change: 07-Dec-2008.
- *
- * use jQuery
- * http://jquery.com/
- * use JGrowl
- * http://stanlemon.net/projects/jgrowl.html
- */
+// PLUGIN_INFO//{{{
+var PLUGIN_INFO =
+<VimperatorPlugin>
+ <name>{name}</name>
+ <description>notification from the subjects is notified to you by the Growl style.</description>
+ <description lang="ja">Growl風通知。</description>
+ <author mail="suvene@zeromemory.info" homepage="http://zeromemory.sblo.jp/">suVene</author>
+ <version>0.1.0</version>
+ <minVersion>2.0pre</minVersion>
+ <maxVersion>2.0pre</maxVersion>
+ <detail><![CDATA[
+ ]]></detail>
+</VimperatorPlugin>;
+//}}}
(function() {
var notifier = liberator.plugins.notifier;
@@ -28,22 +28,23 @@ Growl.prototype = {
defaults: {
life: 5000
},
- initialize: function(dom, container) {
+ initialize: function(dom, container, options) {
this.dom = dom;
this.container = container;
this.created = new Date();
- this.life = this.defaults.life;
+ this.options = $U.extend(this.defaults, (options || {}));
+ this.life = this.options.life;
dom.childNodes[0].addEventListener("click", $U.bind(this, this.remove), false);
},
remove: function() {
+ // TODO: animation!!!!
this.container.removeChild(this.dom);
},
}//}}}
-notifier.observer.register({
+notifier.observer.register(notifier.Observer, {
initialize: function () {
- logger.log('initialize');
this.count = 1;
io.getRuntimeDirectories('').forEach(function(dir) {
@@ -59,7 +60,6 @@ notifier.observer.register({
});
},
update: function(message) {
- logger.log('update:' + this.count);
var doc = window.content.document;
var container = doc.getElementById("observer_growl");
@@ -68,8 +68,9 @@ notifier.observer.register({
container = doc.getElementById("observer_growl");
}
- this.createPopup(doc, message, container);
- container.appendChild(this.createPopup(doc, message, container));
+ var notification = this.createPopup(message, doc, container);
+ // TODO: animation!!!
+ container.appendChild(notification);
if (container.childNodes.length == 1) {
let interval = setInterval($U.bind(this, this.checkStatus), 1000);
@@ -78,17 +79,16 @@ notifier.observer.register({
this.count++;
},
- createPopup: function(doc, message, nodes) {
+ createPopup: function(message, doc, nodes) {
var dom;
var html =
- <div class="observer_growl_notification" style="display: block;">
- <div class="close">&#215;</div>
- <div class="header">{util.escapeHTML(this.count + ': ' + message.title)}</div>
- <div class="message">{util.escapeHTML(message.message)}</div>
- </div>;
+ <div class="observer_growl_notification" style="display: block;">
+ <div class="close">&#215;</div>
+ <div class="header">{new XMLList(this.count + ': ' + message.title)}</div>
+ <div class="message">{new XMLList(message.message || '')}</div>
+ </div>;
dom = util.xmlToDom(html, doc, nodes);
- dom.__data__ = new Growl(dom, nodes);
-
+ dom.__data__ = new Growl(dom, nodes, message.options.growl);
return dom;
},
checkStatus: function() {
@@ -106,7 +106,7 @@ notifier.observer.register({
removeNodes.push(item);
}
}
- removeNodes.forEach(function(n) container.removeChild(n));
+ removeNodes.forEach(function(element) element.__data__.remove());
if (container.childNodes.length == 0)
clearInterval(container.__interval__);