Mercurial > snowl
changeset 270:06a6f44f34ae
move browser integration code into its own JavaScript file
author | Myk Melez <myk@mozilla.org> |
---|---|
date | Thu, 28 Aug 2008 13:48:51 -0700 |
parents | e4070f697baa |
children | 54b59324bd71 |
files | content/browser.js content/browser.xul content/list.js |
diffstat | 3 files changed, 79 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/content/browser.js Thu Aug 28 13:48:51 2008 -0700 @@ -0,0 +1,77 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Snowl. + * + * The Initial Developer of the Original Code is Mozilla. + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Myk Melez <myk@mozilla.org> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +let Snowl = { + // The Preferences service that is imported from the Preferences module below. + // XXX Could we import it lazily when this property is first accessed? + Preferences: null, + + get _prefs() { + delete this._prefs; + return this._prefs = new this.Preferences("extensions.snowl."); + }, + + get _version() { + let em = Cc["@mozilla.org/extensions/manager;1"]. + getService(Ci.nsIExtensionManager); + let addon = em.getItemForID("snowl@mozilla.org"); + delete this._version; + return this._version = addon.version; + }, + + init: function() { + let lastVersion = this._prefs.get("lastVersion"); + + if (!lastVersion) { + let url = "chrome://snowl/content/firstrun.html"; + setTimeout(function() { window.openUILinkIn(url, "tab") }, 500); + } + else if (lastVersion != this._version) { + // We don't use this code yet because we haven't yet set up update.html + // to properly list changes yet. + // FIXME: make this work. + //let url = "chrome://snowl/content/update.html?old=" + lastVersion + + // "&new=" + this._version; + //setTimeout(function() { window.openUILinkIn(url, "tab"); }, 500); + } + + this._prefs.set("lastVersion", this._version); + } +}; + +Cu.import("resource://snowl/modules/Preferences.js", Snowl); + +window.addEventListener("load", function() { Snowl.init() }, false);
--- a/content/browser.xul Wed Aug 27 18:51:10 2008 -0700 +++ b/content/browser.xul Thu Aug 28 13:48:51 2008 -0700 @@ -41,6 +41,8 @@ <overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" id="snowlBrowserOverlay"> + <script type="application/javascript" src="chrome://snowl/content/browser.js"/> + <menupopup id="viewSidebarMenu"> <menuitem observes="viewSnowlStream"/> </menupopup>
--- a/content/list.js Wed Aug 27 18:51:10 2008 -0700 +++ b/content/list.js Thu Aug 28 13:48:51 2008 -0700 @@ -44,41 +44,6 @@ Cu.import("resource://snowl/modules/collection.js"); Cu.import("resource://snowl/modules/utils.js"); -let Snowl = { - get _prefs() { - delete this._prefs; - return this._prefs = new Preferences("extensions.snowl."); - }, - - get _version() { - let em = Cc["@mozilla.org/extensions/manager;1"]. - getService(Ci.nsIExtensionManager); - let addon = em.getItemForID("snowl@mozilla.org"); - delete this._version; - return this._version = addon.version; - }, - - init: function() { - let lastVersion = this._prefs.get("lastVersion"); - - if (!lastVersion) { - let url = "chrome://snowl/content/firstrun.html"; - setTimeout(function() { window.openUILinkIn(url, "tab") }, 500); - } - else if (lastVersion != this._version) { - // We don't use this code yet because we haven't yet set up update.html - // to properly list changes yet. - // FIXME: make this work. - //let url = "chrome://snowl/content/update.html?old=" + lastVersion + - // "&new=" + this._version; - //setTimeout(function() { window.openUILinkIn(url, "tab"); }, 500); - } - - this._prefs.set("lastVersion", this._version); - } -}; - - let SnowlMessageView = { _log: null, @@ -513,5 +478,4 @@ } }; -window.addEventListener("load", function() { Snowl.init() }, false); window.addEventListener("load", function() { SnowlMessageView.init() }, false);