Skip to content

Commit

Permalink
added support for vertical margins on element zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidj committed Jul 21, 2009
1 parent 56a66ef commit 6eae05b
Show file tree
Hide file tree
Showing 28 changed files with 1,435 additions and 0 deletions.
1 change: 1 addition & 0 deletions chrome/content/.#prefs.js
21 changes: 21 additions & 0 deletions chrome/content/about.js
@@ -0,0 +1,21 @@
function Donate()
{
var bundle = document.getElementById("bundle");
var url = bundle.getString("DonateURL");
OpenURL(url);
}

function OpenURL(aURL)
{
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService();
var windowMediator = wm.QueryInterface(Components.interfaces.nsIWindowMediator);

var win = windowMediator.getMostRecentWindow("navigator:browser");
if (!win)
win = window.openDialog("chrome://browser/content/browser.xul", "_blank", "chrome,all,dialog=no", aURL, null, null);
else
{
var content = win.document.getElementById("content");
content.selectedTab = content.addTab(aURL);
}
}
105 changes: 105 additions & 0 deletions chrome/content/about.xul
@@ -0,0 +1,105 @@
<?xml version='1.0'?>

<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.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 the Glazoom extension for Mozilla Firefox.
-
- The Initial Developer of the Original Code is
- DISRUPTIVE INNOVATIONS SARL
- Portions created by the Initial Developer are Copyright (C) 2008
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-
- ***** END LICENSE BLOCK ***** -->

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://glazoom/skin/about.css" type="text/css"?>

<!DOCTYPE window SYSTEM "chrome://glazoom/locale/about.dtd">

<window id="glazoom_prefs"
title="&about.title;"
orient="vertical"
xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>

<script type='application/x-javascript'
src='chrome://glazoom/content/about.js'></script>

<stringbundle id="bundle" src="chrome://glazoom/locale/about.properties" />

<hbox id="page">
<spacer flex="1"/>
<vbox id="main">
<grid>
<columns><column/><column flex="1"/></columns>
<rows>
<row align="center">
<image src="chrome://glazoom/skin/glazoom.png"/>
<hbox align="center" id="titleBox">
<label value="Glazoom"/>
<label value="&version.label;"/>
</hbox>
</row>
<row align="center">
<spacer/>
<hbox>
<label value="&author.control;"/>
<label value="&author.label;"/>
</hbox>
</row>
</rows>
</grid>

<tabbox flex="1" id="tabbox">
<tabs>
<tab label="&about.tab;"/>
<tab label="&whatsnew.tab;"/>
</tabs>
<tabpanels>
<vbox>
<description>&about.text1;</description>
<description>&about.text2;</description>
<vbox class="indent">
<description>&about.feature1;</description>
<description>&about.feature2;</description>
<description>&about.feature3;</description>
<description>&about.feature4;</description>
<description>&about.feature5;</description>
</vbox>
<description id="donate1">&donate.text1;</description>
<vbox id="donate2">
<hbox>
<spacer flex="1"/>
<button label="&donate.label;"
id="donateButton"
oncommand="Donate()"/>
<spacer flex="1"/>
</hbox>
<description >&donate.text2;</description>
</vbox>
</vbox>
<vbox>
<description>&whatsnew.label;</description>
<vbox class="indent">
<description>&whatsnew2.text;</description>
<description>&whatsnew1.text;</description>
</vbox>
</vbox>
</tabpanels>
</tabbox>
</vbox>
<spacer flex="1"/>
</hbox>
</window>
116 changes: 116 additions & 0 deletions chrome/content/elementPinger.js
@@ -0,0 +1,116 @@


var GlazoomElementPinger = {

mDocument: null,
mHighlightElement: null,
mOldStyles: "",
mInspectMode: false,

cancelInspection: function(aNotif, aDesc)
{
GlazoomElementPinger.shutdown();
},

inspect: function(aDocument)
{
var notifBox = getBrowser().getNotificationBox();
var bundle = document.getElementById("creatorString");
var buttons = [ { label: bundle.getString("cancel"),
accessKey: bundle.getString("cancelAccessKey"),
callback: this.cancelInspection,
popup: null} ];
notifBox.appendNotification(bundle.getString("cancelInspectionNotifLabel"),
"GlazoomInspectDocument",
"chrome://glazoom/skin/glazoom.png",
notifBox.PRIORITY_INFO_HIGH,
buttons);
this.mDocument = aDocument;

aDocument.addEventListener("mouseover", this.onMouseOver, true);
aDocument.addEventListener("click", this.onClick, true);

this.mInspectMode = true;
},

shutdown: function()
{
var notifBox = getBrowser().getNotificationBox();
var notif = notifBox.getNotificationWithValue("GlazoomInspectDocument")
if (notif)
notif.close();

if (!this.mDocument || !this.mInspectMode)
return;
this.mDocument.removeEventListener("mouseover", this.onMouseOver, true);
this.mDocument.removeEventListener("click", this.onClick, true);
if (this.mHighlightElement)
{
this.mHighlightElement.setAttribute("style", this.mOldStyles);
}
this.mDocument = null;
this.mInspectMode = false;
},

getComputedDisplay: function(aElt)
{
var doc = aElt.ownerDocument;
return doc.defaultView.getComputedStyle(aElt, "").getPropertyValue("display");
},

getContainer: function(aElt)
{
var elt = aElt;
var d = GlazoomElementPinger.getComputedDisplay(elt);
while (elt && d == "inline")
{
elt = elt.parentNode;
d = GlazoomElementPinger.getComputedDisplay(elt);
}
return elt;
},

onMouseOver: function(aEvent) {

var elt = GlazoomElementPinger.getContainer(aEvent.target);

if (GlazoomElementPinger.mHighlightElement)
{
if (GlazoomElementPinger.mHighlightElement != elt)
GlazoomElementPinger.mHighlightElement.setAttribute("style", GlazoomElementPinger.mOldStyles);
else
return;
}

var name = elt.nodeName.toLowerCase();
if (name == "html" || name == "body")
{
GlazoomElementPinger.mHighlightElement = null;
}
else
{
GlazoomElementPinger.mHighlightElement = elt;
GlazoomElementPinger.mOldStyles = GlazoomElementPinger.mHighlightElement.getAttribute("style");
GlazoomElementPinger.mHighlightElement.style.outline="1px solid blue";
GlazoomElementPinger.mHighlightElement.style.MozOpacity = "0.5";
GlazoomElementPinger.mHighlightElement.style.backgroundColor = "silver";
GlazoomElementPinger.mHighlightElement.style.backgroundImage = "url('chrome://glazoom/skin/glazoom.png')";
GlazoomElementPinger.mHighlightElement.style.backgroundRepeat = "no-repeat";
GlazoomElementPinger.mHighlightElement.style.backgroundPosition = "top right";
}

aEvent.stopPropagation();
aEvent.preventDefault();
},

onClick: function(aEvent) {
var node = GlazoomElementPinger.mHighlightElement;
aEvent.stopPropagation();
aEvent.preventDefault();
GlazoomElementPinger.shutdown();
diGlazoom.zoomNode(node);
}

};


0 comments on commit 6eae05b

Please sign in to comment.