-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert 'Customize Titlebar' dialog's listbox into tree, and make it's columns resizable. Fixes #25. #74
Convert 'Customize Titlebar' dialog's listbox into tree, and make it's columns resizable. Fixes #25. #74
Changes from all commits
6b156e6
ada18bd
7febb0d
ba06511
66c0392
5500fc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,68 @@ | |
* | ||
* ***** END LICENSE BLOCK ***** */ | ||
|
||
function arrayBasedTreeView(treeViewData) { | ||
this.data = treeViewData; | ||
} | ||
|
||
arrayBasedTreeView.prototype = { | ||
data: [], | ||
|
||
get rowCount() { | ||
return this.data.length; | ||
}, | ||
|
||
getCellText: function (aRow, aColumn) { | ||
return this.data[aRow][aColumn.id]; | ||
}, | ||
|
||
setTree: function (aTreebox) { | ||
this.treebox = aTreebox; | ||
}, | ||
|
||
isContainer: function (aRow) { | ||
return false; | ||
}, | ||
|
||
isSeparator: function (aRow) { | ||
return false; | ||
}, | ||
|
||
isSorted: function () { | ||
return false; | ||
}, | ||
|
||
getLevel: function (aRow) { | ||
return 0; | ||
}, | ||
|
||
getImageSrc: function (aRow, aCol) { | ||
return null; | ||
}, | ||
|
||
getRowProperties: function (aRow, aProps) { | ||
}, | ||
|
||
getCellProperties: function (aRow, aCol, aProps) { | ||
}, | ||
|
||
getColumnProperties: function (aColID, aCol, aProps) { | ||
}, | ||
|
||
cycleHeader: function (aCol) { | ||
}, | ||
}; | ||
|
||
|
||
var paneTitle = { | ||
|
||
bundle: null, | ||
variables: [], | ||
|
||
init: function() | ||
init: function(aEvent) | ||
{ | ||
aEvent.originalTarget.defaultView.removeEventListener("load", paneTitle.init, false); | ||
|
||
var mediator = Components.classes['@mozilla.org/appshell/window-mediator;1'] | ||
.getService(Components.interfaces.nsIWindowMediator); | ||
var window = mediator.getMostRecentWindow("navigator:browser"); | ||
|
@@ -76,13 +132,12 @@ init: function() | |
paneTitle.addVariable("Compiler"); | ||
paneTitle.addVariable("Toolkit"); | ||
paneTitle.addVariable("Profile"); | ||
|
||
paneTitle.setupTree(); | ||
}, | ||
|
||
addVariable: function(name) | ||
{ | ||
var list = document.getElementById("varList"); | ||
var item = document.createElement("listitem"); | ||
item.appendChild(document.createElement("listcell")).setAttribute('label',"${"+name+"}"); | ||
var text = null; | ||
try | ||
{ | ||
|
@@ -92,29 +147,46 @@ addVariable: function(name) | |
{ | ||
text=""; | ||
} | ||
item.appendChild(document.createElement("listcell")).setAttribute('label',text); | ||
var value = paneTitle.nightly.getVariable(name); | ||
if (value==null) | ||
{ | ||
value="Undefined"; | ||
} | ||
item.appendChild(document.createElement("listcell")).setAttribute('label',value); | ||
item.addEventListener("click", function() { | ||
var titlebox = document.getElementById("customTitle"); | ||
var template = titlebox.value + " ${" + name + "}"; | ||
titlebox.value = template; | ||
// manually set pref, pref change isn't triggered if we just set the value | ||
paneTitle.nightly.preferences.setCharPref("templates.title", template); | ||
}, true); | ||
list.appendChild(item); | ||
paneTitle.variables.push({variable: "${"+name+"}", description: text, value: value}); | ||
}, | ||
|
||
toggled: function() | ||
{ | ||
var checkbox = document.getElementById("enableTitleBar"); | ||
var text = document.getElementById("customTitle"); | ||
text.disabled=!checkbox.checked; | ||
}, | ||
|
||
setupTree: function () { | ||
var tree = document.getElementById("variableTree"); | ||
tree.view = new arrayBasedTreeView(paneTitle.variables); | ||
tree.addEventListener("click", treeOnClickListener, true); | ||
}, | ||
} | ||
|
||
function treeOnClickListener(aEvent) { | ||
if (aEvent.originalTarget.tagName === "treechildren") { | ||
var tree = aEvent.originalTarget.parentNode; | ||
var tbo = tree.treeBoxObject; | ||
|
||
// get the row, col and child element at the point | ||
var row = { }, col = { }, child = { }; | ||
tbo.getCellAt(aEvent.clientX, aEvent.clientY, row, col, child); | ||
|
||
// a workaround to skip extraneous clicks | ||
if (tree.view.selection.currentIndex === row.value) { | ||
var titlebox = document.getElementById("customTitle"); | ||
var template = titlebox.value + " " + paneTitle.variables[row.value]["variable"]; | ||
titlebox.value = template; | ||
// manually set pref, pref change isn't triggered if we just set the value | ||
paneTitle.nightly.preferences.setCharPref("templates.title", template); | ||
} | ||
} | ||
} | ||
|
||
window.addEventListener("load",paneTitle.init,false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Beside note: I think we should remove the listener in paneTitle.init(). It's not necessary anymore once the window has been initialized. It will save a bit of memory. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* ***** BEGIN LICENSE BLOCK ***** | ||
* Version: MPL 1.1/GPL 2.0/LGPL 2.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 Nightly Tester Tools. | ||
* | ||
* The Initial Developer of the Original Code is | ||
* Dave Townsend <dtownsend@oxymoronical.com>. | ||
* | ||
* Portions created by the Initial Developer are Copyright (C) 2007 | ||
* the Initial Developer. All Rights Reserved. | ||
* | ||
* Contributor(s): | ||
* | ||
* Alternatively, the contents of this file may be used under the terms of | ||
* either the GNU General Public License Version 2 or later (the "GPL"), or | ||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), | ||
* in which case the provisions of the GPL or the LGPL are applicable instead | ||
* of those above. If you wish to allow use of your version of this file only | ||
* under the terms of either the GPL or the LGPL, and not to allow others to | ||
* use your version of this file under the terms of the MPL, indicate your | ||
* decision by deleting the provisions above and replace them with the notice | ||
* and other provisions required by the GPL or the LGPL. If you do not delete | ||
* the provisions above, a recipient may use your version of this file under | ||
* the terms of any one of the MPL, the GPL or the LGPL. | ||
* | ||
* ***** END LICENSE BLOCK ***** */ | ||
|
||
#variableTree { | ||
height: 17em; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we also need: https://github.com/mozilla/nightlytt/pull/79/files#r1014458 |
||
|
||
#NightlyTesterOptions { | ||
width: 42.75em; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: please add an empty line before this CSS declaration. Something I forgot and don't know if we talked about already, why don't we need the height? Is it set automatically based on the number of maximum visible rows of the tree? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, I left it out. See below!
Yes, it is set automatically. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So with all the template entries we have right now, which height of the window do we get? I just want to be sure that we do not extend the screen height of the users machine. At least not for a resolution of 1024x768. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. xabolcs wrote
Hmm. A height is set by whimboo wrote:
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind moving this callback method into the global scope? You will have access to the tree via
event.originalTarget
.