Skip to content

Commit

Permalink
Merge branch 'master' into issue-55
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvold committed Sep 27, 2010
2 parents 694ed9e + 0fc3145 commit 6c7e958
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 161 deletions.
2 changes: 1 addition & 1 deletion content/closewindow.xul
Expand Up @@ -2,7 +2,7 @@
<overlay id="scriptish-close-window-overlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<commandset>
<command id="cmd_close" oncommand="Scriptish_onClose &amp;&amp; Scriptish_onClose(); window.close();" />
<command id="cmd_close" oncommand="window.close();" />
</commandset>

<keyset>
Expand Down
28 changes: 7 additions & 21 deletions content/install.xul
Expand Up @@ -3,49 +3,35 @@
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://mozapps/skin/xpinstall/xpinstallConfirm.css" type="text/css"?>
<?xml-stylesheet href="chrome://scriptish/skin/install.css" type="text/css"?>

<!DOCTYPE overlay SYSTEM "chrome://scriptish/locale/scriptish.dtd">

<dialog xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
id="scriptish"
title="&install.title;"
style="width: 32em; height:32em;"
onload="Scriptish_Install.init();"
ondialogaccept="return Scriptish_Install.onOK();"
ondialogcancel="return Scriptish_Install.onCancel();"
ondialogextra1="return Scriptish_Install.onShowSource();"
buttons="accept,cancel,extra1"
buttonlabelaccept="&install.installbutton;"
buttonlabelextra1="&install.showscriptsource;"
defaultButton="accept">
<stringbundle id="scriptish-browser-bundle" src="chrome://scriptish/locale/scriptish.properties" />

defaultButton="cancel">
<script type="application/x-javascript" src="chrome://scriptish/content/js/install.js" />

<vbox id="dialogContentBox" flex="1">
<description id="heading"/>
<vbox id="itemBox" flex="1">
<vbox id="script-desc-vbox">
<description id="scriptDescription"/>
</vbox>
<vbox id="matches">
<label value="&install.matches;" />
<label id="matches-label"/>
<description id="matches-desc"/>
</vbox>
<vbox id="includes">
<label value="&install.runson;" />
<label id="includes-label"/>
<description id="includes-desc"/>
</vbox>
<vbox id="excludes">
<label value="&install.butnoton;" />
<label id="excludes-label"/>
<description id="excludes-desc"/>
</vbox>
<spacer flex="1" />
<spacer flex="1"/>
</vbox>

<description style="margin-top:1em">&install.warning1;</description>
<description style="margin-bottom:1em" class="warning"
>&install.warning2;</description>
<description id="warning1" style="margin-top:1em"/>
<description id="warning2" style="margin-bottom:1em" class="warning"/>
</vbox>
</dialog>
118 changes: 38 additions & 80 deletions content/js/install.js
@@ -1,8 +1,11 @@

Components.utils.import("resource://scriptish/logging.js");
Components.utils.import("resource://scriptish/utils/Scriptish_stringBundle.js");

var Scriptish_Install = {
init: function() {
this.doc = document;
var $ = function(aID) document.getElementById(aID);

var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);

Expand All @@ -16,78 +19,35 @@ var Scriptish_Install = {
this.setupIncludes("include", "excludes", "excludes-desc", script.excludes);

this.dialog_ = document.documentElement;
this.dialog_.setAttribute("title", Scriptish_stringBundle("install.title"));

this.extraButton_ = this.dialog_.getButton("extra1");
this.extraButton_.setAttribute("type", "checkbox");
this.extraButton_.setAttribute("label",
Scriptish_stringBundle("install.showscriptsource"));
this.extraButton_.addEventListener(
"command", function() { Scriptish_Install.onShowSource() }, false);

this.acceptButton_ = this.dialog_.getButton("accept");
this.acceptButton_.baseLabel = this.acceptButton_.label;

this.timer_ = null;
this.seconds_ = 0;
this.startTimer();

this.bundle = document.getElementById("scriptish-browser-bundle");
this.greetz = new Array();
for(var i = 0; i < 6; i++){
this.greetz.push(this.bundle.getString("greetz." + i));
}

var pick = Math.round(Math.random() * (this.greetz.length - 1));
var heading = document.getElementById("heading");
heading.appendChild(document.createElementNS(this.htmlNs_, "strong"));
heading.firstChild.appendChild(document.createTextNode(this.greetz[pick]));
heading.appendChild(document.createTextNode(" " + this.bundle.getString("greeting.msg")));

var desc = document.getElementById("scriptDescription");
desc.appendChild(document.createElementNS(this.htmlNs_, "strong"));
desc.firstChild.appendChild(document.createTextNode(script.name + " " + script.version));
desc.appendChild(document.createElementNS(this.htmlNs_, "br"));
desc.appendChild(document.createTextNode(script.description));
},

onFocus: function(e) {
this.startTimer();
},

onBlur: function(e) {
this.stopTimer();
},

startTimer: function() {
this.seconds_ = 4;
this.updateLabel();

if (this.timer_) {
window.clearInterval(this.timer_);
}

this.timer_ = window.setInterval(function() { Scriptish_Install.onInterval() }, 500);
},

onInterval: function() {
this.seconds_--;
this.updateLabel();

if (this.seconds_ == 0) {
this.timer_ = window.clearInterval(this.timer_);
}
},

stopTimer: function() {
this.seconds_ = 5;
this.timer_ = window.clearInterval(this.timer_);
this.updateLabel();
},

updateLabel: function() {
if (this.seconds_ > 0) {
this.acceptButton_.focus();
this.acceptButton_.disabled = true;
this.acceptButton_.label = this.acceptButton_.baseLabel + " (" + this.seconds_ + ")";
} else {
this.acceptButton_.disabled = false;
this.acceptButton_.label = this.acceptButton_.baseLabel;
}
this.acceptButton_.setAttribute("label",
Scriptish_stringBundle("install.installbutton"));
this.acceptButton_.addEventListener(
"command", function() { Scriptish_Install.onOK() }, false);

this.dialog_.getButton("cancel").addEventListener(
"command", function() { Scriptish_Install.onCancel() }, false);

$("matches-label").setAttribute("value", Scriptish_stringBundle("install.matches"));
$("includes-label").setAttribute("value", Scriptish_stringBundle("install.runson"));
$("excludes-label").setAttribute("value", Scriptish_stringBundle("install.butnoton"));
$("warning1").setAttribute("value", Scriptish_stringBundle("install.warning1"));
$("warning2").setAttribute("value", Scriptish_stringBundle("install.warning2"));

var desc = $("scriptDescription");
desc.appendChild(this.doc.createElementNS(this.htmlNs_, "strong"));
desc.firstChild.appendChild(this.doc.createTextNode(script.name + " " + script.version));
desc.appendChild(this.doc.createElementNS(this.htmlNs_, "br"));
desc.appendChild(this.doc.createTextNode(script.description));
},

setupIncludes: function(type, box, desc, includes) {
Expand All @@ -112,20 +72,18 @@ var Scriptish_Install = {
},

onOK: function() {
window.removeEventListener("unload", Scriptish_Install.cleanup, false);
this.scriptDownloader_.installScript();
window.setTimeout("window.close()", 0);
Scriptish_Install.close();
},

onCancel: function(){
this.scriptDownloader_.cleanupTempFiles();
window.close();
},

onCancel: function() Scriptish_Install.close(),
onShowSource: function() {
this.scriptDownloader_.showScriptView();
window.setTimeout("window.close()", 0);
}
Scriptish_Install.close();
},
cleanup: function() Scriptish_Install.scriptDownloader_.cleanupTempFiles(),
close: function() window.setTimeout(function() { window.close() }, 0)
};

// See: closewindow.xul
function Scriptish_onClose() { Scriptish.onCancel(); }
window.addEventListener("unload", Scriptish_Install.cleanup, false);
window.addEventListener("load", function() { Scriptish_Install.init() }, false);
35 changes: 0 additions & 35 deletions locale/en-US/scriptish.dtd

This file was deleted.

6 changes: 0 additions & 6 deletions locale/en-US/scriptish.properties
Expand Up @@ -10,12 +10,6 @@ tooltip.loading=Loading...
greeting.msg=This is a user script. Click install to start using it.
greeting.btn=Install
greeting.btnAccess=I
greetz.0=Huzzah!
greetz.1=Hallo!
greetz.2=Howdy!
greetz.3=Sup...
greetz.4=Greetings, fellow traveler.
greetz.5=G'Day!
alert.fromURI=Downloading user script...
alert.fromURI.failure=Could not download user script
alert.success=Installed successfully.
Expand Down
26 changes: 8 additions & 18 deletions skin/install.css
@@ -1,16 +1,14 @@

#install {
margin-bottom:1em;
}
#install{margin-bottom:1em;}

#itemBox {
#itemBox{
style="padding:0;
overflow:auto;
-moz-appearance:textfield;
margin:2px 4px;
}

#script-desc-vbox {
#script-desc-vbox{
background:InfoBackground;
color: InfoText;
border-bottom:1px black dotted;
Expand All @@ -19,23 +17,15 @@
margin-bottom:0.5em;
}

#scriptDescription {
margin:0;
}
#scriptDescription{margin:0;}

#scriptDescription strong {
font-size: 1.25em;
}
#scriptDescription strong{font-size: 1.25em;}

#includes, #matches, #excludes {
#itemBox vbox:not(#script-desc-vbox){
margin:0 0 1em 1em;
display:none;
}

#excludes-desc, #includes-desc, #matches-desc {
font-style:italic;
}
#excludes-desc, #includes-desc, #matches-desc{font-style:italic;}

#includes.display, #match.display, #excludes.display {
display:inherit;
}
#itemBox vbox.display:not(#script-desc-vbox){display:inherit;}

0 comments on commit 6c7e958

Please sign in to comment.