From ecd4228a58b12ca473e92ec437aba67874379524 Mon Sep 17 00:00:00 2001 From: Mathijs Lagerberg Date: Fri, 15 Jun 2012 11:36:34 +0200 Subject: [PATCH] Added source for PreviewBox addon --- PreviewBox/chrome.manifest | 7 ++ PreviewBox/chrome/content/contents.rdf | 33 +++++ PreviewBox/chrome/content/previewbox.js | 108 +++++++++++++++++ PreviewBox/chrome/content/previewbox.xul | 114 ++++++++++++++++++ PreviewBox/chrome/locale/en-US/contents.rdf | 32 +++++ PreviewBox/chrome/locale/en-US/previewbox.dtd | 6 + PreviewBox/chrome/skin/contents.rdf | 33 +++++ PreviewBox/chrome/skin/icon.png | Bin 0 -> 3312 bytes PreviewBox/chrome/skin/prevb.css | 108 +++++++++++++++++ PreviewBox/install.rdf | 49 ++++++++ README.md | 24 ++-- chrome/icons/default/Thumbs.db | Bin 8192 -> 0 bytes chrome/skin/classic/images/Thumbs.db | Bin 78336 -> 0 bytes chrome/skin/classic/images/tooltips/Thumbs.db | Bin 28672 -> 0 bytes defaults/preferences/prefs.js | 17 +++ 15 files changed, 520 insertions(+), 11 deletions(-) create mode 100644 PreviewBox/chrome.manifest create mode 100644 PreviewBox/chrome/content/contents.rdf create mode 100644 PreviewBox/chrome/content/previewbox.js create mode 100644 PreviewBox/chrome/content/previewbox.xul create mode 100644 PreviewBox/chrome/locale/en-US/contents.rdf create mode 100644 PreviewBox/chrome/locale/en-US/previewbox.dtd create mode 100644 PreviewBox/chrome/skin/contents.rdf create mode 100644 PreviewBox/chrome/skin/icon.png create mode 100644 PreviewBox/chrome/skin/prevb.css create mode 100644 PreviewBox/install.rdf delete mode 100644 chrome/icons/default/Thumbs.db delete mode 100644 chrome/skin/classic/images/Thumbs.db delete mode 100644 chrome/skin/classic/images/tooltips/Thumbs.db diff --git a/PreviewBox/chrome.manifest b/PreviewBox/chrome.manifest new file mode 100644 index 0000000..ca96b72 --- /dev/null +++ b/PreviewBox/chrome.manifest @@ -0,0 +1,7 @@ +overlay chrome://findthatfont/content/main.xul chrome://previewbox/content/previewbox.xul + +content previewbox jar:chrome/previewbox.jar!/content/ + +skin previewbox classic/1.0 jar:chrome/previewbox.jar!/skin/ + +locale previewbox en jar:chrome/previewbox.jar!/locale/en-US/ diff --git a/PreviewBox/chrome/content/contents.rdf b/PreviewBox/chrome/content/contents.rdf new file mode 100644 index 0000000..8f7adfe --- /dev/null +++ b/PreviewBox/chrome/content/contents.rdf @@ -0,0 +1,33 @@ + + + + + + + + + + + + chrome://previewbox/content/previewbox.xul + + + diff --git a/PreviewBox/chrome/content/previewbox.js b/PreviewBox/chrome/content/previewbox.js new file mode 100644 index 0000000..651cb49 --- /dev/null +++ b/PreviewBox/chrome/content/previewbox.js @@ -0,0 +1,108 @@ +/* +* This file is part of FindThatFont! +* +* FindThatFont! is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* FindThatFont! is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with FindThatFont!. If not, see . +*/ + +// Add an event listener to make sure the extension is +// initialized when FtF loads +window.addEventListener("load", function(e) { PreviewBox.init(); }, false); + +// Bundle all functions in an object, for convenience and avoiding conflicts +var PreviewBox = { + + // Called when FindThatFont! loads + init: function() { + var rlb = document.getElementById("font-list"); + rlb.setAttribute("onselect", "PreviewBox.updateSampleBox();"); + this.loadChars(); + }, + + loadChars: function() { + try { + var box = document.getElementById("prevb-chars-container"); + var str = ""; + + // Most common characters + for(var i=33; i<255; i++) { + if(i<127 || i>160) + str += this.createCharacterCode(i); + } + // Greek + var extraChars = new Array(402,915,916,920,923,926,928,931,933,934,936,937,945,946,947); + for(var i=0; i' + + '
' + i + '
' + // For hex codes (left out because of too much clutter) + //+ '
#' + i.toString(16).toUpperCase() + '
' + + '
&#' + i + ';
' + + ''; + }, + + // Opens the sample box + showSample: function() { + var split = document.getElementById("prevb-splitter"); + split.setAttribute("state", "open"); + this.updateSampleBox(); + }, + + // Hides the sample box + hideSample: function() { + var split = document.getElementById("prevb-splitter"); + split.setAttribute("state", "collapsed"); + }, + + // Updates the sample box to the selected font + updateSampleBox: function() { + // be sure to call the original onselect function: + if(classHeaderSelected()) return; + var preview1 = document.getElementById("prevb-preview"); + preview1.setAttribute("style", 'font-family: "'+getSelectedFont()+'";'); + var preview2 = document.getElementById("prevb-chars"); + preview2.setAttribute("style", 'font-family: "'+getSelectedFont()+'";'); + }, + + // Switches between Lipsum box and Unicode box + switchMode: function() { + var mode = document.getElementById("sample-option"); + var preview1 = document.getElementById("prevb-chars"); + var preview2 = document.getElementById("prevb-preview"); + if(mode.value=="1") { + preview2.setAttribute("hidden", "false"); + preview1.setAttribute("hidden", "true"); + } else { + preview1.setAttribute("hidden", "false"); + preview2.setAttribute("hidden", "true"); + } + } +} \ No newline at end of file diff --git a/PreviewBox/chrome/content/previewbox.xul b/PreviewBox/chrome/content/previewbox.xul new file mode 100644 index 0000000..a07f652 --- /dev/null +++ b/PreviewBox/chrome/content/previewbox.xul @@ -0,0 +1,114 @@ + + + + + + + +