From fa392246ec57c59614e02645aa0fe74a0bd71ac7 Mon Sep 17 00:00:00 2001 From: Einar Egilsson Date: Thu, 8 Oct 2009 08:03:15 +0000 Subject: UI refactoring and added skin git-svn-id: http://einaregilsson.googlecode.com/svn/mozilla/redirector/trunk@256 119bf307-c92d-0410-89bd-8f53e6181181 --- chrome/content/code/browserOverlay.xul.js | 2 +- chrome/content/code/redirectList.xul.js | 47 ++++++++++++----------------- chrome/content/code/redirector.prototype.js | 2 ++ 3 files changed, 22 insertions(+), 29 deletions(-) (limited to 'chrome/content/code') diff --git a/chrome/content/code/browserOverlay.xul.js b/chrome/content/code/browserOverlay.xul.js index 968e9c4..5c84859 100644 --- a/chrome/content/code/browserOverlay.xul.js +++ b/chrome/content/code/browserOverlay.xul.js @@ -81,7 +81,7 @@ var RedirectorOverlay = { } else { window.openDialog("chrome://redirector/content/ui/redirectList.xul", windowName, - "chrome,dialog,resizable=no,centerscreen", this); + "chrome,dialog,resizable=yes,centerscreen", this); } }, diff --git a/chrome/content/code/redirectList.xul.js b/chrome/content/code/redirectList.xul.js index 81dd4a4..c980178 100644 --- a/chrome/content/code/redirectList.xul.js +++ b/chrome/content/code/redirectList.xul.js @@ -9,6 +9,8 @@ var RedirectList = { lstRedirects: null, btnDelete : null, btnEdit : null, + btnUp : null, + btnDown : null, addItemsToListBox : function(items) { @@ -22,9 +24,10 @@ var RedirectList = { newItem.getElementsByAttribute('name', 'dscrRedirectTo')[0].setAttribute('value', item.redirectUrl); var checkEnabled = newItem.getElementsByAttribute('name', 'chkEnabled')[0]; checkEnabled.setAttribute('checked', !item.disabled); + newItem.setAttribute('class', item.disabled ? 'disabledRedirect' : ''); newItem.item = item; this.lstRedirects.appendChild(newItem); - newItem.setAttribute('selected', false); + newItem.setAttribute('selected', false) } //Enable, disable functionality @@ -35,11 +38,12 @@ var RedirectList = { parent = parent.parentNode; } parent.item.disabled = !ev.originalTarget.hasAttribute('checked'); + parent.setAttribute('class', parent.item.disabled ? 'disabledRedirect' : ''); Redirector.save(); } },false); }, - + onLoad : function() { try { this.lstRedirects = document.getElementById('lstRedirects'); @@ -48,6 +52,8 @@ var RedirectList = { this.lstRedirects.removeChild(this.template); this.btnDelete = document.getElementById('btnDelete'); this.btnEdit = document.getElementById('btnEdit'); + this.btnUp = document.getElementById('btnUp'); + this.btnDown = document.getElementById('btnDown'); this.addItemsToListBox(Redirector.list); this.strings = document.getElementById('redirector-strings'); } catch(e) { @@ -55,25 +61,6 @@ var RedirectList = { } }, - openHelp : function() { - var windowName = 'redirectorHelp'; - var windowsMediator = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); - var win; - var iter = windowsMediator.getEnumerator(null); - while (iter.hasMoreElements()) { - win = iter.getNext(); - if (win.name == windowName) { - win.focus(); - return; - } - } - window.openDialog("chrome://redirector/content/ui/help.html", windowName, "chrome,dialog,resizable=yes,location=0,toolbar=0,status=0,width=800px,height=600px,centerscreen", this); - }, - - close : function() { - window.close(); - }, - moveUp : function(){ if (this.lstRedirects.selectedIndex <= 0) { return; @@ -89,14 +76,16 @@ var RedirectList = { }, switchItems : function(firstIndex) { - var first = Redirector.list[firstIndex]; - var second = Redirector.list[firstIndex+1]; - Redirector.list[firstIndex] = second; - Redirector.list[firstIndex+1] = first; - this.setListItemValues(this.lstRedirects.children[firstIndex+1], first); - this.setListItemValues(this.lstRedirects.children[firstIndex], second); - this.lstRedirects.selectedIndex -= 1; + var firstRedirect = Redirector.list[firstIndex]; + var secondRedirect = Redirector.list[firstIndex+1]; + Redirector.list[firstIndex] = secondRedirect; + Redirector.list[firstIndex+1] = firstRedirect; + var firstItem = this.lstRedirects.children[firstIndex]; + var secondItem = this.lstRedirects.children[firstIndex+1]; + this.lstRedirects.removeChild(secondItem); + this.lstRedirects.insertBefore(secondItem, firstItem); Redirector.save(); + this.selectionChange(); }, setListItemValues : function(listItem, item){ @@ -163,6 +152,8 @@ var RedirectList = { this.btnEdit.disabled = (index == -1); this.btnDelete.disabled = (index == -1); + this.btnUp.disabled = (index <= 0); + this.btnDown.disabled = (index == -1 || index >= Redirector.list.length-1); }, importExport : function(mode, captionKey, func) { diff --git a/chrome/content/code/redirector.prototype.js b/chrome/content/code/redirector.prototype.js index 3f6c0fb..8218395 100644 --- a/chrome/content/code/redirector.prototype.js +++ b/chrome/content/code/redirector.prototype.js @@ -91,6 +91,7 @@ Redirector.prototype = { if (!aContext || !aContext.loadURI) { return nsIContentPolicy.ACCEPT; } + this.debug("START: " + new Date().getTime()); this.debug("Checking " + contentLocation.spec); var url = contentLocation.spec; @@ -112,6 +113,7 @@ Redirector.prototype = { } catch(e) { this.debug(e); } + this.debug("END: " + new Date().getTime()); return nsIContentPolicy.ACCEPT; }, -- cgit v1.2.3-70-g09d2