Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewpaprotsky committed Dec 14, 2009
0 parents commit 80ce59b
Show file tree
Hide file tree
Showing 30 changed files with 5,016 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
syntax: glob

*.swp
3 changes: 3 additions & 0 deletions extension/Firefox/chrome.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
content abitbetterrtm content/
overlay chrome://browser/content/browser.xul chrome://abitbetterrtm/content/initialize.xul
overlay chrome://webrunner/content/webrunner.xul chrome://abitbetterrtm/content/initialize.xul
Binary file added extension/Firefox/content/.initialize.xul.swp
Binary file not shown.
Binary file added extension/Firefox/content/.listTabs.js.swp
Binary file not shown.
Binary file added extension/Firefox/content/.location.js.swp
Binary file not shown.
84 changes: 84 additions & 0 deletions extension/Firefox/content/aBitBetterRTM.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
var ABBRTM = window.ABBRTM || {};

ABBRTM.ABitBetterRTM = function() {
this.settings = new ABBRTM.Settings();
this.settings.init();
this.taskList = new ABBRTM.TaskList(this);
this.listList = new ABBRTM.ListList();
this.listTabs = new ABBRTM.ListTabs(this);
this.listTabs.blitDiv();

this.autocompletes = {};
this.shortcuts = [];

this.initAutocompletes();
this.initShortcuts();
this.overrideBodyKeyPressHandler();

settingsTabs.addEntry("A Bit Better RTM");
settingsView.addState("A Bit Better RTM", [this.settings], settingsTabs);
settingsTabs.blitDiv();
}

ABBRTM.ABitBetterRTM.prototype.initShortcuts = function() {
this.shortcuts.push(new ABBRTM.Shortcut(103, this.autocompletes.goTo, this.autocompletes.goTo.show, true, false, false));
this.shortcuts.push(new ABBRTM.Shortcut(109, this.autocompletes.moveTo, this.autocompletes.moveTo.show, true, false, false));
this.shortcuts.push(new ABBRTM.Shortcut(47, null, function(){$("#listFilter").focus().effect('highlight', '', 'slow');}, false, false, false));

if (ABBRTM.configuration.displayTabsToTheLeft()) {
this.shortcuts.push(new ABBRTM.Shortcut(74, this.listTabs, this.listTabs.selectNextList, false, true, false));
this.shortcuts.push(new ABBRTM.Shortcut(75, this.listTabs, this.listTabs.selectPreviousList, false, true, false));
this.shortcuts.push(new ABBRTM.Shortcut(79, this.listTabs, this.listTabs.openSelectedList, false, true, false));

if (ABBRTM.configuration.quickAddList()) {
this.shortcuts.push(new ABBRTM.Shortcut(113, this.listTabs.listAdder, this.listTabs.listAdder.showListEntryBox, false, false, false));
}
}
};

ABBRTM.ABitBetterRTM.prototype.initAutocompletes = function() {
this.autocompletes.goTo = new ABBRTM.Autocomplete("GO TO: ", new ABBRTM.ListAutocompleteStore(this.listTabs), this.listTabs, this.listTabs.selectListByName);
this.autocompletes.moveTo = new ABBRTM.Autocomplete("MOVE TO: ", new ABBRTM.ListAutocompleteStore(this.listTabs), this.listTabs, this.listTabs.moveSelectedTasksToListByName);
}

ABBRTM.ABitBetterRTM.prototype.overrideBodyKeyPressHandler = function()
{
var that = this;
var handleKeyPressEvent = function(ev, ignoreCombo)
{
ev || (ev = window.event);
var target = utility.getEventTarget(ev);

if (target == null) {
return true;
}

var pressed = (ev.charCode) ? ev.charCode : ((ev.which) ? ev.which : ev.keyCode);

if (target && (/^(textarea|input|text|password|select|button|submit)/i.test(target.type) || target.id == "map")) {
return true;
}

for (var i = 0; i < that.shortcuts.length; ++i) {
if ((that.shortcuts[i].key === pressed) && (that.shortcuts[i].ctrlKey === ev.ctrlKey) && (that.shortcuts[i].shiftKey === ev.shiftKey) && (that.shortcuts[i].altKey === ev.altKey) && (ev.metaKey === false)) {
that.shortcuts[i].run();
utility.stopEvent(ev);
return false;
}
}

return true;
}

if (eventMgr) {
var oldBodyKeyPressHandler = eventMgr.bodyKeyPressHandler;

eventMgr.bodyKeyPressHandler = function(ev, ignoreCombo) {
if (handleKeyPressEvent(ev, ignoreCombo) === true) {
return oldBodyKeyPressHandler.call(eventMgr, ev, ignoreCombo);
}

return true;
};
}
}
141 changes: 141 additions & 0 deletions extension/Firefox/content/autocomplete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
var ABBRTM = window.ABBRTM || {};

ABBRTM.Autocomplete = function(name, autocompleteStore, owner, callback)
{
var autocompleteBox = document.createElement('div');
autocompleteBox.setAttribute("id", "autocompleteBox_" + name);
autocompleteBox.style.width = "240px";
autocompleteBox.style.position = "absolute";
autocompleteBox.style.zIndex = "999";
autocompleteBox.innerHTML = '<div class="white_rbroundbox"> <div class="white_rbtop"> <div> <div></div> </div> </div> <div class="white_rbcontentwrap"> <div class="white_rbcontent"> <div class="taskcloudcontent" style="padding: 0px 5px 0px 5px; height: 17px;" id="listtabscontainer"><div style="width: 70px; font-weight: bold; float: left; height: 17px; padding-top: 1px;">' + name + '</div><div style="text-align: right; float: right; width: 155px; padding-right: 2px;"><input type="text" id="autocompleteInputField_' + name + '" name="text" style="width: 151px; ";/></div> </div> </div> </div> <div class="white_rbbot"> <div><div></div> </div> </div> </div> ';

document.body.appendChild(autocompleteBox);

this.inputField = document.getElementById("autocompleteInputField_" + name);
this.box = document.getElementById("autocompleteBox_" + name);
this.autocompleteList = new ABBRTM.AutocompleteList(this.inputField, autocompleteStore, this);
this.owner = owner;
this.callback = callback;
this.hide();
this.bind();

function centerAutoCompleteBox()
{
var left = window.innerWidth / 2 - 120 + window.scrollX;
var top = window.innerHeight / 2 - 10 + window.scrollY;

autocompleteBox.style.left = left + "px";
autocompleteBox.style.top = top + "px";
}

centerAutoCompleteBox();
window.addEventListener("scroll", centerAutoCompleteBox, false);
window.addEventListener("resize", centerAutoCompleteBox, false);

return this;
}

ABBRTM.Autocomplete.prototype.show = function()
{
this.box.style.display = "block";
if (this.inputField)
{
this.inputField.focus();
}
};

ABBRTM.Autocomplete.prototype.hide = function()
{
this.box.style.display = "none";
if (this.inputField)
{
this.inputField.value = "";
}

this.autocompleteList.clearOutput();
};

ABBRTM.Autocomplete.prototype.doCallback = function()
{
var completion = this.autocompleteList.getCurrentCompletion();
this.hide();

if (this.owner)
{
this.callback.call(this.owner, completion);
}
else
{
this.callback(completion);
}
};

ABBRTM.Autocomplete.prototype.bind = function()
{
var autocompleteList = this.autocompleteList;
var inputField = this.inputField;
var currentText = "";

var _handleKeyPressEvent = function(event)
{
currentText = inputField.value;
if (event.keyCode == 9) // Tab
{
if (utility) {
utility.stopEvent(event);
}

return false;
}
else if (autocompleteList.isVisible)
{
if (event.keyCode == 13)// Enter
{
autocompleteList.parent.doCallback();
}
if (event.keyCode == 40)// Key down
{
autocompleteList.highlightNextCompletion();
}
else if (event.keyCode == 38) // Key up
{
autocompleteList.highlightPreviousCompletion();
}
else if (event.keyCode == 27) // Esc
{
autocompleteList.clearOutput();
}
}
else if (event.keyCode == 27)
{
autocompleteList.parent.hide();
}

return true;
};
var handleKeyUpEvent = function(event)
{
if (currentText === null || currentText != inputField.value)
{
autocompleteList.update();
}
};
var handleClickEvent = function(event)
{
if (autocompleteList.isVisible)
{
autocompleteList.hideOutput();
}

if (utility)
{
utility.stopEvent(event);
}
};

this.inputField.setAttribute("autocomplete", "off");
this.inputField.addEventListener("keypress", _handleKeyPressEvent, false);
this.inputField.addEventListener("keyup", handleKeyUpEvent, false);
this.box.addEventListener("click", handleClickEvent, false);
this.autocompleteList.createOutput();
};
163 changes: 163 additions & 0 deletions extension/Firefox/content/autocompleteList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
var ABBRTM = window.ABBRTM || {};

ABBRTM.AutocompleteList = function(inputField, autocompleteStore, parent)
{
this.inputField = inputField;
this.autocompleteStore = autocompleteStore;
this.parent = parent;
this.output = null;
this.completions = null;
this.position = -1;
this.isVisible = false;
}

ABBRTM.AutocompleteList.prototype.createOutput = function()
{
if (!this.inputField)
{
return;
}

this.output = document.createElement('div');
this.output.setAttribute('id','autoCompleteList_' + this.inputField.id);
this.output.style.border = "solid 1px black";
this.output.style.background = "white";
this.output.style.position = "absolute";
this.output.style.width = "150px";
this.output.style.visibility = "hidden";

this.inputField.parentNode.insertBefore(this.output, this.inputField.nextSibling);
};

ABBRTM.AutocompleteList.prototype.showOutput = function()
{
if (this.output)
{
this.output.style.visibility = "visible";
}

this.isVisible = true;
};

ABBRTM.AutocompleteList.prototype.hideOutput = function()
{
if (this.output)
{
this.output.style.visibility = "hidden";
}

this.isVisible = false;
};

ABBRTM.AutocompleteList.prototype.clearOutput = function()
{
while(this.output && this.output.childNodes.length)
{
this.output.removeChild(this.output.firstChild);
}

this.position = -1;
this.hideOutput();
};

ABBRTM.AutocompleteList.prototype.addCompletion = function(completion)
{
var autocompleteList = this;

var mouseOverHandler = function(event)
{
autocompleteList.position = this.position;
autocompleteList.highlightCompletion();
};

var mouseClickHandler = function(event)
{
autocompleteList.parent.doCallback();
};

var completionBox = document.createElement("div");
completionBox.style.textAlign = "left";
completionBox.style.paddingLeft = "2px";
completionBox.appendChild(document.createTextNode(completion));
completionBox.position = this.output.childNodes.length;
completionBox.addEventListener("mouseover", mouseOverHandler, false);
completionBox.addEventListener("click", mouseClickHandler, false);
this.output.appendChild(completionBox);
};

ABBRTM.AutocompleteList.prototype.highlightCompletion = function()
{
if (this.output && this.output.childNodes)
{
for (var i = 0; i < this.output.childNodes.length; ++i)
{
if (i == this.position)
{
this.output.childNodes[i].style.color = "white";
this.output.childNodes[i].style.background = "#316ac5";
}
else
{
this.output.childNodes[i].style.color = "black";
this.output.childNodes[i].style.background = "white";
}
}
}
};

ABBRTM.AutocompleteList.prototype.highlightNextCompletion = function()
{
if (this.completions && this.completions.length > 0 && this.position < this.completions.length - 1)
{
++this.position;
this.highlightCompletion();
}
};

ABBRTM.AutocompleteList.prototype.highlightPreviousCompletion = function()
{
if (this.completions && this.completions.length > 1 && this.position > 0)
{
--this.position;
this.highlightCompletion();
}
};

ABBRTM.AutocompleteList.prototype.getCurrentCompletion = function()
{
if (this.completions && this.completions.length > 0)
{
return this.completions[this.position];
}

return null;
};

ABBRTM.AutocompleteList.prototype.update = function()
{
if (this.inputField.value.length > 0)
{
this.completions = this.autocompleteStore.getCompletions(this.inputField.value);
if (this.completions && this.completions.length > 0)
{
this.clearOutput();
for (var i = 0; i < this.completions.length; ++i)
{
this.addCompletion(this.completions[i]);
}

this.showOutput();
this.highlightNextCompletion();
}
else
{
this.hideOutput();
this.position = -1;
}
}
else
{
this.hideOutput();
this.position = -1;
}
};
Loading

0 comments on commit 80ce59b

Please sign in to comment.