Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clipperz-firefox-extension/chrome.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
content clipperzbutton chrome/clipperzbutton/content/
skin clipperzbutton classic/1.0 chrome/clipperzbutton/skin/global/
style chrome://global/content/customizeToolbar.xul chrome://clipperzbutton/skin/clipperzMain.css

locale clipperzbutton en-US chrome/clipperzbutton/locale/en-US/
overlay chrome://browser/content/browser.xul chrome://clipperzbutton/content/clipperzMain.xul
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
const CLIPPERZ_PREF_PREFIX = "clipperzbutton.";
const CLIPPERZ_PREF_TB_ITEM_INSTALLED = CLIPPERZ_PREF_PREFIX + "toolbariteminstalled";
const CLIPPERZ_TOOLBAR_BUTTON_ID = "clipperz-toolbar-button";

var clipperz_panel = null;
var clipperz_pref = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var clipperz_panel_top = "50";
var clipperz_panel_left = "50";
var clipperz_panel_width = "330";
var clipperz_panel_height = "500";

function saveParams(){
if(clipperz_panel != null){
if(clipperz_panel.closed){
clipperz_pref.setCharPref("clipperz.window-opened", "0");
}
else{
clipperz_panel_top = clipperz_panel.screenY;
clipperz_panel_left = clipperz_panel.screenX;
clipperz_panel_width = clipperz_panel.innerWidth;
clipperz_panel_height = clipperz_panel.innerHeight;
clipperz_pref.setCharPref("clipperz.position-top", clipperz_panel_top);
clipperz_pref.setCharPref("clipperz.position-left", clipperz_panel_left);
clipperz_pref.setCharPref("clipperz.position-width", clipperz_panel_width);
clipperz_pref.setCharPref("clipperz.position-height", clipperz_panel_height);
}
}
}

function initClipperz(){
installClipperzButton();
clipperz_pref.setCharPref("clipperz.window-opened", "0");
var modifiers = clipperz_pref.getCharPref("clipperz.shortcut-modifiers");
var letter = clipperz_pref.getCharPref("clipperz.shortcut-letter");
var shortcut = document.getElementById("open-clipperz");
shortcut.setAttribute("modifiers", modifiers);
shortcut.setAttribute("key", letter);
clipperz_panel_top = clipperz_pref.getCharPref("clipperz.position-top");
clipperz_panel_left = clipperz_pref.getCharPref("clipperz.position-left");
clipperz_panel_width = clipperz_pref.getCharPref("clipperz.position-width");
clipperz_panel_height = clipperz_pref.getCharPref("clipperz.position-height");
params = setInterval(saveParams, 1000);
if (navigator.appVersion.indexOf("Mac")!=-1){
document.getElementById("ctrl").setAttribute("hidden","true");
}
}

function restartFirefox(){
a=Components.interfaces.nsIAppStartup,Components.classes["@mozilla.org/toolkit/app-startup;1"].getService(a).quit(a.eRestart | a.eAttemptQuit);
}

function keyChanged(){
if (confirm("Shortcut changed. Restart Firefox now?"))
restartFirefox();
}

function modChanged(val){
if(val != clipperz_pref.getCharPref("clipperz.shortcut-modifiers")){
if (confirm("Shortcut changed. Restart Firefox now?"))
restartFirefox();
}
}

function resetWindow(){
clipperz_pref.setCharPref("clipperz.position-top", "50");
clipperz_pref.setCharPref("clipperz.position-left", "50");
clipperz_pref.setCharPref("clipperz.position-width", "330");
clipperz_pref.setCharPref("clipperz.position-height", "500");
clipperz_panel_top = "50";
clipperz_panel_left = "50";
clipperz_panel_width = "330";
clipperz_panel_height = "500";

if (confirm("Window properties resetted. Restart Firefox now?"))
restartFirefox();
}

//click handler
var clipperzButton = {
openPanel: function () {
if (clipperz_pref.getCharPref("clipperz.window-opened") == "0"){
clipperz_panel = window.open("https://www.clipperz.com/beta/index.html?compact", "Clipperz", "toolbar=no,resizable=yes,scrollbars=no,titlebar=yes,location=no,menubar=no,status=no,top="+clipperz_panel_top+",left="+clipperz_panel_left+",width="+clipperz_panel_width+",height="+clipperz_panel_height);
clipperz_pref.setCharPref("clipperz.window-opened", "1");
}
else{
clipperz_panel.blur();
clipperz_panel.focus();
}
},

openPreferences : function() {
if (null == this._preferencesWindow || this._preferencesWindow.closed) {
let instantApply = Application.prefs.get("browser.preferences.instantApply");
let features = "chrome,titlebar,toolbar,centerscreen" + (instantApply.value ? ",dialog=no" : ",modal");
this._preferencesWindow = window.openDialog( "chrome://clipperzbutton/content/options.xul", "preferences-window", features);
}
this._preferencesWindow.focus();
}
}

//install button
function installClipperzButton() {
var prefs = Components.classes["@mozilla.org/preferences;1"].getService(Components.interfaces.nsIPrefService);
var db = prefs.getBranch(null);

try {
if (db.getBoolPref(CLIPPERZ_PREF_TB_ITEM_INSTALLED)) return;
}
catch(e) {
}

var buttonId = CLIPPERZ_TOOLBAR_BUTTON_ID;
var afterId;
var toolbarId;

// check toolbar
toolbarId = "nav-bar";
var tb = document.getElementById(toolbarId);
if (tb) {
afterId = "home-button";
} else {
toolbarId = "mail-bar";
tb = document.getElementById(toolbarId);
if (tb) {
afterId = "button-stop";
} else {
toolbarId = "composeToolbar";
tb = document.getElementById(toolbarId);
if (tb) {
afterId = "button-save";
} else {
return;
}
}
}

// check button
var currentSet = tb.getAttribute(tb.hasAttribute("currentset") ? "currentset" : "defaultset");
if (!currentSet) return;
db.setBoolPref(CLIPPERZ_PREF_TB_ITEM_INSTALLED, true);
var ids = currentSet.split(",");
var len = ids.length;
var j = -1;
for (var i = 0; i < len; i++) {
if (ids[i] == buttonId) return;
if (ids[i] == afterId) j = i;
}

// not found - add
var newSet;
if (j == -1) {
newSet = currentSet + "," + buttonId;
} else {
var k = 0;
for (var n = 0; n <= j ; n++) {
k = currentSet.indexOf(",", k) + 1;
}
newSet = currentSet.slice(0, k) + buttonId + "," + currentSet.slice(k);
}
tb.setAttribute("currentset", newSet);
tb.currentSet = newSet;
document.persist(toolbarId, "currentset");

try {
BrowserToolboxCustomizeDone(true);
}
catch (e) { }
}

window.addEventListener("load", initClipperz, false);
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://clipperzbutton/skin/clipperzMain.css" type="text/css" ?>

<!DOCTYPE overlay [
<!ENTITY % clipperzDTD SYSTEM
"chrome://clipperzbutton/locale/clipperzbutton.dtd" >
%clipperzDTD;
]>

<overlay id="clipperz-toolbar-button-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script type="application/x-javascript" src="chrome://clipperzbutton/content/clipperzMain.js" />

<toolbarpalette id="BrowserToolbarPalette">
<toolbarbutton id="clipperz-toolbar-button" class="toolbarbutton-1 chromeclass-toolbar-additional custombutton"
label="&clipperz.toolbar.button.label;" tooltiptext="&clipperz.toolbar.button.tooltip;"
oncommand="clipperzButton.openPanel();"/>
</toolbarpalette>

<keyset>
<key id="open-clipperz" modifiers="control" key="B" oncommand="clipperzButton.openPanel();"/>
</keyset>

<menupopup id="menu_ToolsPopup">
<menuitem id="menu-clipperz" label="&clipperz.toolbar.menu.options;"
oncommand="clipperzButton.openPreferences();"/>
</menupopup>
</overlay>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://clipperzbutton/skin/clipperzMain.css" type="text/css" ?>

<!DOCTYPE overlay [
<!ENTITY % clipperzDTD SYSTEM
"chrome://clipperzbutton/locale/clipperzbutton.dtd" >
%clipperzDTD;
]>

<prefwindow id="clipperzbutton-prefs"
title="Clipperz Options"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

<script type="application/x-javascript" src="chrome://clipperzbutton/content/clipperzMain.js" />

<prefpane id="clipperz-pane" label="Clipperz Settings">
<preferences>
<preference id="pref_shortcut_modifiers" name="clipperz.shortcut-modifiers" type="string"/>
<preference id="pref_shortcut_letter" name="clipperz.shortcut-letter" type="string"/>
<preference id="pref_top" name="clipperz.position-top" type="string"/>
<preference id="pref_left" name="clipperz.position-left" type="string"/>
<preference id="pref_width" name="clipperz.position-width" type="string"/>
<preference id="pref_height" name="clipperz.position-height" type="string"/>
<preference id="pref_opened" name="clipperz.window-opened" type="string"/>
</preferences>

<hbox align="left">
<image src="chrome://clipperzbutton/skin/logo.png"/>
<vbox>
<label value="Clipperz" class="header"/>
<label value="Clipperz S.r.l." class="srl"/>
</vbox>
</hbox>

<hbox align="center">
<groupbox>
<caption label="Open window shortcut"/>
<menulist id="mod" preference="pref_shortcut_modifiers">
<menupopup>
<menuitem id="ctrl" label="ctrl" value="control" onclick="modChanged(this.value);" />
<menuitem id="alt" label="alt/option" value="alt" onclick="modChanged(this.value);" />
<menuitem id="shift" label="shift" value="shift" onclick="modChanged(this.value);" />
<menuitem id="cmd" label="cmd (only Mac)" value="accel" onclick="modChanged(this.value);" />
</menupopup>
</menulist>
<textbox id="key" preference="pref_shortcut_letter" maxlength="1" onchange="keyChanged();"/>
</groupbox>
</hbox>
<vbox pack="center">
<groupbox>
<caption label="Window size/location"/>
<button label="&clipperz.toolbar.reset.label;" oncommand="resetWindow();"/>
</groupbox>
</vbox>
</prefpane>

</prefwindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!ENTITY clipperz.toolbar.button.label "Clipperz">
<!ENTITY clipperz.toolbar.button.tooltip "Launch Clipperz">
<!ENTITY clipperz.toolbar.menu.options "Clipperz">
<!ENTITY clipperz.toolbar.reset.label "Reset to defaults">
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");

#clipperz-toolbar-button
{list-style-image: url("chrome://clipperzbutton/skin/favicon.png");}

.srl{
font-size:11px;
color: #acacac;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions clipperz-firefox-extension/defaults/preferences/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pref("clipperz.shortcut-modifiers", "control");
pref("clipperz.shortcut-letter", "T");
pref("clipperz.position-top", "50");
pref("clipperz.position-left", "50");
pref("clipperz.position-width", "330");
pref("clipperz.position-height", "500");
pref("clipperz.window-opened", "0");
20 changes: 20 additions & 0 deletions clipperz-firefox-extension/install.rdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" ?><RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:name>Clipperz</em:name>
<em:description>Clipperz Firefox extension</em:description>
<em:version>1.0.4</em:version>
<em:targetApplication>
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>3.5</em:minVersion>
<em:maxVersion>8.*</em:maxVersion>
</Description>
</em:targetApplication>
<em:creator>Clipperz S.r.l.</em:creator>
<em:homepageURL>http://www.clipperz.com</em:homepageURL>
<em:updateURL> </em:updateURL>
<em:iconURL>chrome://clipperzbutton/skin/logo.png</em:iconURL>
<em:optionsURL>chrome://clipperzbutton/content/options.xul</em:optionsURL>
</Description>
</RDF>