From 90723baa596d15b60f8e7d58fe14c12c47bfc728 Mon Sep 17 00:00:00 2001 From: suVene Date: Sat, 6 Dec 2008 18:51:26 +0000 Subject: 変更通知framework.& それを利用したGrowl風plugin(途中) git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@26017 d0d07461-0603-4401-acd4-de1884942a52 --- notifier/jquery.jgrowl.css | 87 ++++++++++++++++++++++++++++++++ notifier/observer_growl.js | 120 +++++++++++++++++++++++++++++++++++++++++++++ notifier/subject_test.js | 52 ++++++++++++++++++++ 3 files changed, 259 insertions(+) create mode 100644 notifier/jquery.jgrowl.css create mode 100644 notifier/observer_growl.js create mode 100644 notifier/subject_test.js (limited to 'notifier') diff --git a/notifier/jquery.jgrowl.css b/notifier/jquery.jgrowl.css new file mode 100644 index 0000000..5cbd9ed --- /dev/null +++ b/notifier/jquery.jgrowl.css @@ -0,0 +1,87 @@ + +div.observer_growl { + padding: 10px; + z-index: 9999; +} + +/** Normal Style Positions **/ +body > div.observer_growl { + position: fixed; +} + +body > div.observer_growl.top-left { + left: 0px; + top: 0px; +} + +body > div.observer_growl.top-right { + right: 0px; + top: 0px; +} + +body > div.observer_growl.bottom-left { + left: 0px; + bottom: 0px; +} + +body > div.observer_growl.bottom-right { + right: 0px; + bottom: 0px; +} + +body > div.observer_growl.center { + top: 0px; + width: 50%; + left: 25%; +} + +/** Cross Browser Styling **/ +div.center div.observer_growl_notification, div.center div.observer_growl-closer { + margin-left: auto; + margin-right: auto; +} + +div.observer_growl div.observer_growl_notification, div.observer_growl div.observer_growl-closer { + background-color: #000; + color: #fff; + opacity: .85; + filter: alpha(opacity = 85); + zoom: 1; + width: 235px; + padding: 10px; + margin-top: 5px; + margin-bottom: 5px; + font-family: Tahoma, Arial, Helvetica, sans-serif; + font-size: 12px; + text-align: left; + display: none; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +div.observer_growl div.observer_growl_notification { + min-height: 40px; +} + +div.observer_growl div.observer_growl_notification div.header { + font-weight: bold; + font-size: 10px; +} + +div.observer_growl div.observer_growl_notification div.close { + float: right; + font-weight: bold; + font-size: 12px; + cursor: pointer; +} + +div.observer_growl div.observer_growl-closer { + height: 15px; + padding-top: 4px; + padding-bottom: 4px; + cursor: pointer; + font-size: 11px; + font-weight: bold; + text-align: center; +} + diff --git a/notifier/observer_growl.js b/notifier/observer_growl.js new file mode 100644 index 0000000..b6f1d96 --- /dev/null +++ b/notifier/observer_growl.js @@ -0,0 +1,120 @@ +/** + * 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 + */ +(function() { + +var notifier = liberator.plugins.notifier; +if (!notifier) return; + +var lib = notifier.lib; +var $U = lib.$U; +var logger = $U.getLogger('observer_growl'); + +var Growl = function() {//{{{ + this.initialize.apply(this, arguments); +} +Growl.prototype = { + defaults: { + life: 3000 + }, + initialize: function(dom, container) { + this.dom = dom; + this.container = container; + this.created = new Date(); + this.life = this.defaults.life; + dom.childNodes[0].addEventListener("click", $U.bind(this, this.remove), false); + }, + remove: function() { + this.container.removeChild(this.dom); + }, + +}//}}} + +notifier.observer.register({ + initialize: function () { + logger.log('initialize'); + this.count = 1; + + io.getRuntimeDirectories('').forEach(function(dir) { + let path = io.expandPath(dir.path + '/plugin/notifier'); + $U.readDirectory(path, '^jquery' , function(f) { + try { + io.source(f.path, true) + logger.log('load success: ' + f.leafName); + } catch (e) { + logger.log('load failed: ' + f.leafName); + } + }); + }); + }, + update: function(message) { + logger.log('update:' + this.count); + + var doc = window.content.document; + var container = doc.getElementById("observer_growl"); + if (!container) { + doc.body.appendChild(util.xmlToDom(
, doc)); + container = doc.getElementById("observer_growl"); + } + + this.createPopup(doc, message, container); + container.appendChild(this.createPopup(doc, message, container)); + + if (container.childNodes.length == 1) { + var interval = setInterval($U.bind(this, this.checkStatus), 1000); + container.__interval__ = interval; + } + + this.count++; + }, + createPopup: function(doc, message, nodes) { + var dom; + var html = +