Commit 120f379c authored by Franco Fichtner's avatar Franco Fichtner

javascript: apply whitespace cleanups

parent b50b4cd7
...@@ -100,7 +100,7 @@ function NetUtils_loadMaskIPv6(obj, sel, min, max) { ...@@ -100,7 +100,7 @@ function NetUtils_loadMaskIPv6(obj, sel, min, max) {
max = max - i; max = max - i;
break; break;
} }
} }
} }
for (var i = max; i >= min; i -= 4) { for (var i = max; i >= min; i -= 4) {
...@@ -111,4 +111,3 @@ function NetUtils_loadMaskIPv6(obj, sel, min, max) { ...@@ -111,4 +111,3 @@ function NetUtils_loadMaskIPv6(obj, sel, min, max) {
j++; j++;
} }
} }
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
* @class * @class
* @scope public * @scope public
*/ */
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) { oProvider /*:SuggestionProvider*/) {
/** /**
* The currently selected suggestions. * The currently selected suggestions.
* @scope private * @scope private
*/ */
this.cur /*:int*/ = -1; this.cur /*:int*/ = -1;
/** /**
...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
* @scope private * @scope private
*/ */
this.layer = null; this.layer = null;
/** /**
* Suggestion provider for the autosuggest feature. * Suggestion provider for the autosuggest feature.
* @scope private. * @scope private.
*/ */
this.provider /*:SuggestionProvider*/ = oProvider; this.provider /*:SuggestionProvider*/ = oProvider;
/** /**
* The textbox to capture. * The textbox to capture.
* @scope private * @scope private
*/ */
this.textbox /*:HTMLInputElement*/ = oTextbox; this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control //initialize the control
this.init(); this.init();
} }
/** /**
...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
*/ */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/, AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion //make sure there's at least one suggestion
if (aSuggestions.length > 0) { if (aSuggestions.length > 0) {
if (bTypeAhead) { if (bTypeAhead) {
this.typeAhead(aSuggestions[0]); this.typeAhead(aSuggestions[0]);
} }
this.showSuggestions(aSuggestions); this.showSuggestions(aSuggestions);
} else { } else {
this.hideSuggestions(); this.hideSuggestions();
...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () {
this.layer.className = "suggestions"; this.layer.className = "suggestions";
this.layer.style.visibility = "hidden"; this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth; this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML) //when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox //and place it into a textbox
this.layer.onmousedown = this.layer.onmousedown =
this.layer.onmouseup = this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) { this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event; oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement; oTarget = oEvent.target || oEvent.srcElement;
...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () {
oThis.textbox.focus(); oThis.textbox.focus();
} }
}; };
document.body.appendChild(this.layer); document.body.appendChild(this.layer);
}; };
...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ { ...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iLeft = 0; var iLeft = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft; iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iLeft; return iLeft;
}; };
...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ { ...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iTop = 0; var iTop = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop; iTop += oNode.offsetTop;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iTop; return iTop;
}; };
...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) { ...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
case 38: //up arrow case 38: //up arrow
this.previousSuggestion(); this.previousSuggestion();
break; break;
case 40: //down arrow case 40: //down arrow
this.nextSuggestion(); this.nextSuggestion();
break; break;
case 13: //enter case 13: //enter
...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) { ...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
//for backspace (8) and delete (46), shows suggestions without typeahead //for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) { if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false); this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys //make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) { } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore //ignore
...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () { ...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () {
* @param oSuggestionNode The node representing a suggestion in the dropdown. * @param oSuggestionNode The node representing a suggestion in the dropdown.
*/ */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) { AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) { for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i]; var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) { if (oNode == oSuggestionNode) {
...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () { ...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () {
//save a reference to this object //save a reference to this object
var oThis = this; var oThis = this;
//assign the onkeyup event handler //assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) { this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyUp() method with the event object //call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent); oThis.handleKeyUp(oEvent);
}; };
//assign onkeydown event handler //assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) { this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyDown() method with the event object //call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent); oThis.handleKeyDown(oEvent);
}; };
//assign onblur event handler (hides suggestions) //assign onblur event handler (hides suggestions)
this.textbox.onblur = function () { this.textbox.onblur = function () {
oThis.hideSuggestions(); oThis.hideSuggestions();
}; };
//create the suggestions dropdown //create the suggestions dropdown
this.createDropDown(); this.createDropDown();
}; };
...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () { ...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) { if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur]; var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () { ...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur > 0) { if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur]; var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
//use text ranges for Internet Explorer //use text ranges for Internet Explorer
if (this.textbox.createTextRange) { if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange(); var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart); oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length); oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select(); oRange.select();
//use setSelectionRange() for Mozilla //use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) { } else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength); this.textbox.setSelectionRange(iStart, iLength);
} }
//set focus back to the textbox //set focus back to the textbox
this.textbox.focus(); this.textbox.focus();
}; };
/** /**
* Builds the suggestion layer contents, moves it into position, * Builds the suggestion layer contents, moves it into position,
...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
* @param aSuggestions An array of suggestions for the control. * @param aSuggestions An array of suggestions for the control.
*/ */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) { AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null; var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) { for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div"); oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i])); oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv); this.layer.appendChild(oDiv);
} }
this.layer.style.left = this.getLeft() + "px"; this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px"; this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible"; this.layer.style.visibility = "visible";
...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/ ...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/
}; };
/** /**
* Inserts a suggestion into the textbox, highlighting the * Inserts a suggestion into the textbox, highlighting the
* suggested part of the text. * suggested part of the text.
* @scope private * @scope private
* @param sSuggestion The suggestion for the textbox. * @param sSuggestion The suggestion for the textbox.
...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) { ...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality //check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){ if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length; var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion; this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length); this.selectRange(iLen, sSuggestion.length);
} }
}; };
...@@ -4,92 +4,92 @@ ...@@ -4,92 +4,92 @@
* http://www.webtoolkit.info/ * http://www.webtoolkit.info/
* http://www.webtoolkit.info/licence * http://www.webtoolkit.info/licence
**/ **/
var Base64 = { var Base64 = {
// private property // private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding // public method for encoding
encode : function (input) { encode : function (input) {
var output = ""; var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0; var i = 0;
input = Base64._utf8_encode(input); input = Base64._utf8_encode(input);
while (i < input.length) { while (i < input.length) {
chr1 = input.charCodeAt(i++); chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2; enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63; enc4 = chr3 & 63;
if (isNaN(chr2)) { if (isNaN(chr2)) {
enc3 = enc4 = 64; enc3 = enc4 = 64;
} else if (isNaN(chr3)) { } else if (isNaN(chr3)) {
enc4 = 64; enc4 = 64;
} }
output = output + output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
} }
return output; return output;
}, },
// public method for decoding // public method for decoding
decode : function (input) { decode : function (input) {
var output = ""; var output = "";
var chr1, chr2, chr3; var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4; var enc1, enc2, enc3, enc4;
var i = 0; var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) { while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++)); enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4); chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4; chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1); output = output + String.fromCharCode(chr1);
if (enc3 != 64) { if (enc3 != 64) {
output = output + String.fromCharCode(chr2); output = output + String.fromCharCode(chr2);
} }
if (enc4 != 64) { if (enc4 != 64) {
output = output + String.fromCharCode(chr3); output = output + String.fromCharCode(chr3);
} }
} }
output = Base64._utf8_decode(output); output = Base64._utf8_decode(output);
return output; return output;
}, },
// private method for UTF-8 encoding // private method for UTF-8 encoding
_utf8_encode : function (string) { _utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n"); string = string.replace(/\r\n/g,"\n");
var utftext = ""; var utftext = "";
for (var n = 0; n < string.length; n++) { for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n); var c = string.charCodeAt(n);
if (c < 128) { if (c < 128) {
utftext += String.fromCharCode(c); utftext += String.fromCharCode(c);
} }
...@@ -102,22 +102,22 @@ var Base64 = { ...@@ -102,22 +102,22 @@ var Base64 = {
utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128); utftext += String.fromCharCode((c & 63) | 128);
} }
} }
return utftext; return utftext;
}, },
// private method for UTF-8 decoding // private method for UTF-8 decoding
_utf8_decode : function (utftext) { _utf8_decode : function (utftext) {
var string = ""; var string = "";
var i = 0; var i = 0;
var c = c1 = c2 = 0; var c = c1 = c2 = 0;
while ( i < utftext.length ) { while ( i < utftext.length ) {
c = utftext.charCodeAt(i); c = utftext.charCodeAt(i);
if (c < 128) { if (c < 128) {
string += String.fromCharCode(c); string += String.fromCharCode(c);
i++; i++;
...@@ -133,10 +133,10 @@ var Base64 = { ...@@ -133,10 +133,10 @@ var Base64 = {
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3; i += 3;
} }
} }
return string; return string;
} }
}; };
\ No newline at end of file
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/* /*
Chosen, a Select Box Enhancer for jQuery and Protoype Chosen, a Select Box Enhancer for jQuery and Protoype
by Patrick Filler for Harvest, http://getharvest.com by Patrick Filler for Harvest, http://getharvest.com
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
Copyright (c) 2011 by Harvest Copyright (c) 2011 by Harvest
*/ var $, Chosen, SelectParser, get_side_border_padding, root; */ var $, Chosen, SelectParser, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
/* /*
Chosen, a Select Box Enhancer for jQuery and Protoype Chosen, a Select Box Enhancer for jQuery and Protoype
by Patrick Filler for Harvest, http://getharvest.com by Patrick Filler for Harvest, http://getharvest.com
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
Copyright (c) 2011 by Harvest Copyright (c) 2011 by Harvest
*/ var Chosen, SelectParser, get_side_border_padding, root; */ var Chosen, SelectParser, get_side_border_padding, root;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
......
...@@ -21,7 +21,7 @@ class Chosen ...@@ -21,7 +21,7 @@ class Chosen
constructor: (elmn) -> constructor: (elmn) ->
this.set_default_values() this.set_default_values()
@form_field = elmn @form_field = elmn
@form_field_jq = $ @form_field @form_field_jq = $ @form_field
@is_multiple = @form_field.multiple @is_multiple = @form_field.multiple
...@@ -33,7 +33,7 @@ class Chosen ...@@ -33,7 +33,7 @@ class Chosen
@form_field_jq.addClass "chzn-done" @form_field_jq.addClass "chzn-done"
set_default_values: -> set_default_values: ->
@click_test_action = (evt) => this.test_active_click(evt) @click_test_action = (evt) => this.test_active_click(evt)
@active_field = false @active_field = false
@mouse_on_container = false @mouse_on_container = false
...@@ -44,17 +44,17 @@ class Chosen ...@@ -44,17 +44,17 @@ class Chosen
set_up_html: -> set_up_html: ->
@container_id = @form_field.id + "_chzn" @container_id = @form_field.id + "_chzn"
@f_width = @form_field_jq.width() @f_width = @form_field_jq.width()
@default_text = if @form_field_jq.attr 'title' then @form_field_jq.attr 'title' else @default_text_default @default_text = if @form_field_jq.attr 'title' then @form_field_jq.attr 'title' else @default_text_default
container_div = ($ "<div />", { container_div = ($ "<div />", {
id: @container_id id: @container_id
class: 'chzn-container' class: 'chzn-container'
style: 'width: ' + (@f_width) + 'px;' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter style: 'width: ' + (@f_width) + 'px;' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
}) })
if @is_multiple if @is_multiple
container_div.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>' container_div.html '<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + @default_text + '" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>'
else else
...@@ -64,10 +64,10 @@ class Chosen ...@@ -64,10 +64,10 @@ class Chosen
@container = ($ '#' + @container_id) @container = ($ '#' + @container_id)
@container.addClass( "chzn-container-" + (if @is_multiple then "multi" else "single") ) @container.addClass( "chzn-container-" + (if @is_multiple then "multi" else "single") )
@dropdown = @container.find('div.chzn-drop').first() @dropdown = @container.find('div.chzn-drop').first()
dd_top = @container.height() dd_top = @container.height()
dd_width = (@f_width - get_side_border_padding(@dropdown)) dd_width = (@f_width - get_side_border_padding(@dropdown))
@dropdown.css({"width": dd_width + "px", "top": dd_top + "px"}) @dropdown.css({"width": dd_width + "px", "top": dd_top + "px"})
@search_field = @container.find('input').first() @search_field = @container.find('input').first()
...@@ -75,7 +75,7 @@ class Chosen ...@@ -75,7 +75,7 @@ class Chosen
this.search_field_scale() this.search_field_scale()
@search_no_results = @container.find('li.no-results').first() @search_no_results = @container.find('li.no-results').first()
if @is_multiple if @is_multiple
@search_choices = @container.find('ul.chzn-choices').first() @search_choices = @container.find('ul.chzn-choices').first()
@search_container = @container.find('li.search-field').first() @search_container = @container.find('li.search-field').first()
...@@ -84,7 +84,7 @@ class Chosen ...@@ -84,7 +84,7 @@ class Chosen
@selected_item = @container.find('.chzn-single').first() @selected_item = @container.find('.chzn-single').first()
sf_width = dd_width - get_side_border_padding(@search_container) - get_side_border_padding(@search_field) sf_width = dd_width - get_side_border_padding(@search_container) - get_side_border_padding(@search_field)
@search_field.css( {"width" : sf_width + "px"} ) @search_field.css( {"width" : sf_width + "px"} )
this.results_build() this.results_build()
this.set_tab_index() this.set_tab_index()
...@@ -93,7 +93,7 @@ class Chosen ...@@ -93,7 +93,7 @@ class Chosen
@container.click (evt) => this.container_click(evt) @container.click (evt) => this.container_click(evt)
@container.mouseenter (evt) => this.mouse_enter(evt) @container.mouseenter (evt) => this.mouse_enter(evt)
@container.mouseleave (evt) => this.mouse_leave(evt) @container.mouseleave (evt) => this.mouse_leave(evt)
@search_results.click (evt) => this.search_results_click(evt) @search_results.click (evt) => this.search_results_click(evt)
@search_results.mouseover (evt) => this.search_results_mouseover(evt) @search_results.mouseover (evt) => this.search_results_mouseover(evt)
@search_results.mouseout (evt) => this.search_results_mouseout(evt) @search_results.mouseout (evt) => this.search_results_mouseout(evt)
...@@ -131,7 +131,7 @@ class Chosen ...@@ -131,7 +131,7 @@ class Chosen
input_focus: (evt) -> input_focus: (evt) ->
setTimeout (=> this.container_click()), 50 unless @active_field setTimeout (=> this.container_click()), 50 unless @active_field
input_blur: (evt) -> input_blur: (evt) ->
if not @mouse_on_container if not @mouse_on_container
@active_field = false @active_field = false
...@@ -142,11 +142,11 @@ class Chosen ...@@ -142,11 +142,11 @@ class Chosen
close_field: -> close_field: ->
$(document).unbind "click", @click_test_action $(document).unbind "click", @click_test_action
if not @is_multiple if not @is_multiple
@selected_item.attr "tabindex", @search_field.attr("tabindex") @selected_item.attr "tabindex", @search_field.attr("tabindex")
@search_field.attr "tabindex", -1 @search_field.attr "tabindex", -1
@active_field = false @active_field = false
this.results_hide() this.results_hide()
...@@ -174,7 +174,7 @@ class Chosen ...@@ -174,7 +174,7 @@ class Chosen
@active_field = true @active_field = true
else else
this.close_field() this.close_field()
results_build: -> results_build: ->
startTime = new Date() startTime = new Date()
@parsing = true @parsing = true
...@@ -199,7 +199,7 @@ class Chosen ...@@ -199,7 +199,7 @@ class Chosen
this.show_search_field_default() this.show_search_field_default()
this.search_field_scale() this.search_field_scale()
@search_results.html content @search_results.html content
@parsing = false @parsing = false
...@@ -210,15 +210,15 @@ class Chosen ...@@ -210,15 +210,15 @@ class Chosen
'<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>' '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>'
else else
"" ""
result_add_option: (option) -> result_add_option: (option) ->
if not option.disabled if not option.disabled
option.dom_id = @form_field.id + "chzn_o_" + option.array_index option.dom_id = @form_field.id + "chzn_o_" + option.array_index
classes = if option.selected and @is_multiple then [] else ["active-result"] classes = if option.selected and @is_multiple then [] else ["active-result"]
classes.push "result-selected" if option.selected classes.push "result-selected" if option.selected
classes.push "group-option" if option.group_array_index? classes.push "group-option" if option.group_array_index?
'<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + $("<div />").text(option.text).html() + '</li>' '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + $("<div />").text(option.text).html() + '</li>'
else else
"" ""
...@@ -238,7 +238,7 @@ class Chosen ...@@ -238,7 +238,7 @@ class Chosen
maxHeight = parseInt @search_results.css("maxHeight"), 10 maxHeight = parseInt @search_results.css("maxHeight"), 10
visible_top = @search_results.scrollTop() visible_top = @search_results.scrollTop()
visible_bottom = maxHeight + visible_top visible_bottom = maxHeight + visible_top
high_top = @result_highlight.position().top + @search_results.scrollTop() high_top = @result_highlight.position().top + @search_results.scrollTop()
high_bottom = high_top + @result_highlight.outerHeight() high_bottom = high_top + @result_highlight.outerHeight()
...@@ -246,7 +246,7 @@ class Chosen ...@@ -246,7 +246,7 @@ class Chosen
@search_results.scrollTop if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0 @search_results.scrollTop if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0
else if high_top < visible_top else if high_top < visible_top
@search_results.scrollTop high_top @search_results.scrollTop high_top
result_clear_highlight: -> result_clear_highlight: ->
@result_highlight.removeClass "highlighted" if @result_highlight @result_highlight.removeClass "highlighted" if @result_highlight
@result_highlight = null @result_highlight = null
...@@ -342,16 +342,16 @@ class Chosen ...@@ -342,16 +342,16 @@ class Chosen
if @result_highlight if @result_highlight
high = @result_highlight high = @result_highlight
high_id = high.attr "id" high_id = high.attr "id"
this.result_clear_highlight() this.result_clear_highlight()
high.addClass "result-selected" high.addClass "result-selected"
if @is_multiple if @is_multiple
this.result_deactivate high this.result_deactivate high
else else
@result_single_selected = high @result_single_selected = high
position = high_id.substr(high_id.lastIndexOf("_") + 1 ) position = high_id.substr(high_id.lastIndexOf("_") + 1 )
item = @results_data[position] item = @results_data[position]
item.selected = true item.selected = true
...@@ -398,7 +398,7 @@ class Chosen ...@@ -398,7 +398,7 @@ class Chosen
winnow_results: -> winnow_results: ->
startTime = new Date() startTime = new Date()
this.no_results_clear() this.no_results_clear()
results = 0 results = 0
searchText = if @search_field.val() is @default_text then "" else $.trim @search_field.val() searchText = if @search_field.val() is @default_text then "" else $.trim @search_field.val()
...@@ -412,7 +412,7 @@ class Chosen ...@@ -412,7 +412,7 @@ class Chosen
else if not (@is_multiple and option.selected) else if not (@is_multiple and option.selected)
found = false found = false
result_id = option.dom_id result_id = option.dom_id
if regex.test option.text if regex.test option.text
found = true found = true
results += 1 results += 1
...@@ -441,7 +441,7 @@ class Chosen ...@@ -441,7 +441,7 @@ class Chosen
else else
this.result_clear_highlight() if @result_highlight and result_id is @result_highlight.attr 'id' this.result_clear_highlight() if @result_highlight and result_id is @result_highlight.attr 'id'
this.result_deactivate $("#" + result_id) this.result_deactivate $("#" + result_id)
if results < 1 and searchText.length if results < 1 and searchText.length
this.no_results searchText this.no_results searchText
else else
...@@ -463,13 +463,13 @@ class Chosen ...@@ -463,13 +463,13 @@ class Chosen
do_high = @search_results.find(".active-result").first() do_high = @search_results.find(".active-result").first()
if(do_high) if(do_high)
this.result_do_highlight do_high this.result_do_highlight do_high
no_results: (terms) -> no_results: (terms) ->
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>') no_results_html = $('<li class="no-results">No results match "<span></span>"</li>')
no_results_html.find("span").first().text(terms) no_results_html.find("span").first().text(terms)
@search_results.append no_results_html @search_results.append no_results_html
no_results_clear: -> no_results_clear: ->
@search_results.find(".no-results").remove() @search_results.find(".no-results").remove()
...@@ -487,7 +487,7 @@ class Chosen ...@@ -487,7 +487,7 @@ class Chosen
this.results_show() this.results_show()
else if @result_highlight else if @result_highlight
prev_sibs = @result_highlight.prevAll("li.active-result") prev_sibs = @result_highlight.prevAll("li.active-result")
if prev_sibs.length if prev_sibs.length
this.result_do_highlight prev_sibs.first() this.result_do_highlight prev_sibs.first()
else else
...@@ -532,7 +532,7 @@ class Chosen ...@@ -532,7 +532,7 @@ class Chosen
this.search_field_scale() this.search_field_scale()
this.clear_backstroke() if stroke != 8 and this.pending_backstroke this.clear_backstroke() if stroke != 8 and this.pending_backstroke
switch stroke switch stroke
when 8 when 8
@backstroke_length = this.search_field.val().length @backstroke_length = this.search_field.val().length
...@@ -559,10 +559,10 @@ class Chosen ...@@ -559,10 +559,10 @@ class Chosen
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;" style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"
styles = ['font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing'] styles = ['font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing']
for style in styles for style in styles
style_block += style + ":" + @search_field.css(style) + ";" style_block += style + ":" + @search_field.css(style) + ";"
div = $('<div />', { 'style' : style_block }) div = $('<div />', { 'style' : style_block })
div.text @search_field.val() div.text @search_field.val()
$('body').append div $('body').append div
...@@ -584,7 +584,7 @@ get_side_border_padding = (elmt) -> ...@@ -584,7 +584,7 @@ get_side_border_padding = (elmt) ->
root.get_side_border_padding = get_side_border_padding root.get_side_border_padding = get_side_border_padding
class SelectParser class SelectParser
constructor: -> constructor: ->
@options_index = 0 @options_index = 0
@parsed = [] @parsed = []
...@@ -629,5 +629,5 @@ SelectParser.select_to_array = (select) -> ...@@ -629,5 +629,5 @@ SelectParser.select_to_array = (select) ->
parser = new SelectParser() parser = new SelectParser()
parser.add_node( child ) for child in select.childNodes parser.add_node( child ) for child in select.childNodes
parser.parsed parser.parsed
root.SelectParser = SelectParser root.SelectParser = SelectParser
...@@ -13,7 +13,7 @@ class Chosen ...@@ -13,7 +13,7 @@ class Chosen
constructor: (elmn) -> constructor: (elmn) ->
this.set_default_values() this.set_default_values()
@form_field = elmn @form_field = elmn
@is_multiple = @form_field.multiple @is_multiple = @form_field.multiple
...@@ -24,7 +24,7 @@ class Chosen ...@@ -24,7 +24,7 @@ class Chosen
set_default_values: -> set_default_values: ->
@click_test_action = (evt) => this.test_active_click(evt) @click_test_action = (evt) => this.test_active_click(evt)
@active_field = false @active_field = false
@mouse_on_container = false @mouse_on_container = false
...@@ -42,26 +42,26 @@ class Chosen ...@@ -42,26 +42,26 @@ class Chosen
set_up_html: -> set_up_html: ->
@container_id = @form_field.id + "_chzn" @container_id = @form_field.id + "_chzn"
@f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth() @f_width = if @form_field.getStyle("width") then parseInt @form_field.getStyle("width"), 10 else @form_field.getWidth()
container_props = container_props =
'id': @container_id 'id': @container_id
'class': 'chzn-container' 'class': 'chzn-container'
'style': 'width: ' + (@f_width) + 'px' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter 'style': 'width: ' + (@f_width) + 'px' #use parens around @f_width so coffeescript doesn't think + ' px' is a function parameter
@default_text = if @form_field.readAttribute 'title' then @form_field.readAttribute 'title' else @default_text_default @default_text = if @form_field.readAttribute 'title' then @form_field.readAttribute 'title' else @default_text_default
base_template = if @is_multiple then new Element('div', container_props).update( @multi_temp.evaluate({ "default": @default_text}) ) else new Element('div', container_props).update( @single_temp.evaluate({ "default":@default_text }) ) base_template = if @is_multiple then new Element('div', container_props).update( @multi_temp.evaluate({ "default": @default_text}) ) else new Element('div', container_props).update( @single_temp.evaluate({ "default":@default_text }) )
@form_field.hide().insert({ after: base_template }) @form_field.hide().insert({ after: base_template })
@container = $(@container_id) @container = $(@container_id)
@container.addClassName( "chzn-container-" + (if @is_multiple then "multi" else "single") ) @container.addClassName( "chzn-container-" + (if @is_multiple then "multi" else "single") )
@dropdown = @container.down('div.chzn-drop') @dropdown = @container.down('div.chzn-drop')
dd_top = @container.getHeight() dd_top = @container.getHeight()
dd_width = (@f_width - get_side_border_padding(@dropdown)) dd_width = (@f_width - get_side_border_padding(@dropdown))
@dropdown.setStyle({"width": dd_width + "px", "top": dd_top + "px"}) @dropdown.setStyle({"width": dd_width + "px", "top": dd_top + "px"})
@search_field = @container.down('input') @search_field = @container.down('input')
...@@ -69,7 +69,7 @@ class Chosen ...@@ -69,7 +69,7 @@ class Chosen
this.search_field_scale() this.search_field_scale()
@search_no_results = @container.down('li.no-results') @search_no_results = @container.down('li.no-results')
if @is_multiple if @is_multiple
@search_choices = @container.down('ul.chzn-choices') @search_choices = @container.down('ul.chzn-choices')
@search_container = @container.down('li.search-field') @search_container = @container.down('li.search-field')
...@@ -78,7 +78,7 @@ class Chosen ...@@ -78,7 +78,7 @@ class Chosen
@selected_item = @container.down('.chzn-single') @selected_item = @container.down('.chzn-single')
sf_width = dd_width - get_side_border_padding(@search_container) - get_side_border_padding(@search_field) sf_width = dd_width - get_side_border_padding(@search_container) - get_side_border_padding(@search_field)
@search_field.setStyle( {"width" : sf_width + "px"} ) @search_field.setStyle( {"width" : sf_width + "px"} )
this.results_build() this.results_build()
this.set_tab_index() this.set_tab_index()
...@@ -87,11 +87,11 @@ class Chosen ...@@ -87,11 +87,11 @@ class Chosen
@container.observe "click", (evt) => this.container_click(evt) @container.observe "click", (evt) => this.container_click(evt)
@container.observe "mouseenter", (evt) => this.mouse_enter(evt) @container.observe "mouseenter", (evt) => this.mouse_enter(evt)
@container.observe "mouseleave", (evt) => this.mouse_leave(evt) @container.observe "mouseleave", (evt) => this.mouse_leave(evt)
@search_results.observe "click", (evt) => this.search_results_click(evt) @search_results.observe "click", (evt) => this.search_results_click(evt)
@search_results.observe "mouseover", (evt) => this.search_results_mouseover(evt) @search_results.observe "mouseover", (evt) => this.search_results_mouseover(evt)
@search_results.observe "mouseout", (evt) => this.search_results_mouseout(evt) @search_results.observe "mouseout", (evt) => this.search_results_mouseout(evt)
@form_field.observe "liszt:updated", (evt) => this.results_update_field(evt) @form_field.observe "liszt:updated", (evt) => this.results_update_field(evt)
@search_field.observe "blur", (evt) => this.input_blur(evt) @search_field.observe "blur", (evt) => this.input_blur(evt)
...@@ -125,7 +125,7 @@ class Chosen ...@@ -125,7 +125,7 @@ class Chosen
input_focus: (evt) -> input_focus: (evt) ->
setTimeout this.container_click.bind(this), 50 unless @active_field setTimeout this.container_click.bind(this), 50 unless @active_field
input_blur: (evt) -> input_blur: (evt) ->
if not @mouse_on_container if not @mouse_on_container
@active_field = false @active_field = false
...@@ -136,11 +136,11 @@ class Chosen ...@@ -136,11 +136,11 @@ class Chosen
close_field: -> close_field: ->
document.stopObserving "click", @click_test_action document.stopObserving "click", @click_test_action
if not @is_multiple if not @is_multiple
@selected_item.tabIndex = @search_field.tabIndex @selected_item.tabIndex = @search_field.tabIndex
@search_field.tabIndex = -1 @search_field.tabIndex = -1
@active_field = false @active_field = false
this.results_hide() this.results_hide()
...@@ -193,7 +193,7 @@ class Chosen ...@@ -193,7 +193,7 @@ class Chosen
this.show_search_field_default() this.show_search_field_default()
this.search_field_scale() this.search_field_scale()
@search_results.update content @search_results.update content
@parsing = false @parsing = false
...@@ -204,15 +204,15 @@ class Chosen ...@@ -204,15 +204,15 @@ class Chosen
'<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>' '<li id="' + group.dom_id + '" class="group-result">' + group.label.escapeHTML() + '</li>'
else else
"" ""
result_add_option: (option) -> result_add_option: (option) ->
if not option.disabled if not option.disabled
option.dom_id = @form_field.id + "chzn_o_" + option.array_index option.dom_id = @form_field.id + "chzn_o_" + option.array_index
classes = if option.selected and @is_multiple then [] else ["active-result"] classes = if option.selected and @is_multiple then [] else ["active-result"]
classes.push "result-selected" if option.selected classes.push "result-selected" if option.selected
classes.push "group-option" if option.group_array_index? classes.push "group-option" if option.group_array_index?
'<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.text.escapeHTML() + '</li>' '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + option.text.escapeHTML() + '</li>'
else else
"" ""
...@@ -239,7 +239,7 @@ class Chosen ...@@ -239,7 +239,7 @@ class Chosen
@search_results.scrollTop = if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0 @search_results.scrollTop = if (high_bottom - maxHeight) > 0 then (high_bottom - maxHeight) else 0
else if high_top < visible_top else if high_top < visible_top
@search_results.scrollTop = high_top @search_results.scrollTop = high_top
result_clear_highlight: -> result_clear_highlight: ->
@result_highlight.removeClassName('highlighted') if @result_highlight @result_highlight.removeClassName('highlighted') if @result_highlight
@result_highlight = null @result_highlight = null
...@@ -337,12 +337,12 @@ class Chosen ...@@ -337,12 +337,12 @@ class Chosen
this.result_clear_highlight() this.result_clear_highlight()
high.addClassName("result-selected") high.addClassName("result-selected")
if @is_multiple if @is_multiple
this.result_deactivate high this.result_deactivate high
else else
@result_single_selected = high @result_single_selected = high
position = high.id.substr(high.id.lastIndexOf("_") + 1 ) position = high.id.substr(high.id.lastIndexOf("_") + 1 )
item = @results_data[position] item = @results_data[position]
item.selected = true item.selected = true
...@@ -403,7 +403,7 @@ class Chosen ...@@ -403,7 +403,7 @@ class Chosen
else if not (@is_multiple and option.selected) else if not (@is_multiple and option.selected)
found = false found = false
result_id = option.dom_id result_id = option.dom_id
if regex.test option.text if regex.test option.text
found = true found = true
results += 1 results += 1
...@@ -453,10 +453,10 @@ class Chosen ...@@ -453,10 +453,10 @@ class Chosen
do_high = @search_results.down(".active-result") do_high = @search_results.down(".active-result")
if(do_high) if(do_high)
this.result_do_highlight do_high this.result_do_highlight do_high
no_results: (terms) -> no_results: (terms) ->
@search_results.insert @no_results_temp.evaluate({"terms":terms.escapeHTML()}) @search_results.insert @no_results_temp.evaluate({"terms":terms.escapeHTML()})
no_results_clear: -> no_results_clear: ->
nr = null nr = null
nr.remove() while nr = @search_results.down(".no-results") nr.remove() while nr = @search_results.down(".no-results")
...@@ -525,7 +525,7 @@ class Chosen ...@@ -525,7 +525,7 @@ class Chosen
this.search_field_scale() this.search_field_scale()
this.clear_backstroke() if stroke != 8 and this.pending_backstroke this.clear_backstroke() if stroke != 8 and this.pending_backstroke
switch stroke switch stroke
when 8 when 8
@backstroke_length = this.search_field.value.length @backstroke_length = this.search_field.value.length
...@@ -547,10 +547,10 @@ class Chosen ...@@ -547,10 +547,10 @@ class Chosen
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;" style_block = "position:absolute; left: -1000px; top: -1000px; display:none;"
styles = ['font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing'] styles = ['font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing']
for style in styles for style in styles
style_block += style + ":" + @search_field.getStyle(style) + ";" style_block += style + ":" + @search_field.getStyle(style) + ";"
div = new Element('div', { 'style' : style_block }).update(@search_field.value) div = new Element('div', { 'style' : style_block }).update(@search_field.value)
document.body.appendChild(div) document.body.appendChild(div)
...@@ -580,7 +580,7 @@ root.get_side_border_padding = get_side_border_padding ...@@ -580,7 +580,7 @@ root.get_side_border_padding = get_side_border_padding
root = exports ? this root = exports ? this
class SelectParser class SelectParser
constructor: -> constructor: ->
@options_index = 0 @options_index = 0
@parsed = [] @parsed = []
...@@ -625,5 +625,5 @@ SelectParser.select_to_array = (select) -> ...@@ -625,5 +625,5 @@ SelectParser.select_to_array = (select) ->
parser = new SelectParser() parser = new SelectParser()
parser.add_node( child ) for child in select.childNodes parser.add_node( child ) for child in select.childNodes
parser.parsed parser.parsed
root.SelectParser = SelectParser root.SelectParser = SelectParser
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
/* /*
Quirksmode necessity Quirksmode necessity
-------------------- --------------------
If your HTML document renders in quirksmode (i.e. has no doctype declaration) If your HTML document renders in quirksmode (i.e. has no doctype declaration)
then uncomment the following CSS rule or the datePicker will be HUGE... then uncomment the following CSS rule or the datePicker will be HUGE...
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
of Simon Willison (see comments by Simon below). of Simon Willison (see comments by Simon below).
Description: Description:
Uses css selectors to apply javascript behaviours to enable Uses css selectors to apply javascript behaviours to enable
unobtrusive javascript in html documents. unobtrusive javascript in html documents.
Usage: Usage:
var myrules = { var myrules = {
'b.someclass' : function(element){ 'b.someclass' : function(element){
element.onclick = function(){ element.onclick = function(){
...@@ -21,40 +21,40 @@ ...@@ -21,40 +21,40 @@
} }
} }
}; };
Behaviour.register(myrules); Behaviour.register(myrules);
// Call Behaviour.apply() to re-apply the rules (if you // Call Behaviour.apply() to re-apply the rules (if you
// update the dom, etc). // update the dom, etc).
License: License:
This file is entirely BSD licensed. This file is entirely BSD licensed.
More information: More information:
http://ripcord.co.nz/behaviour/ http://ripcord.co.nz/behaviour/
*/ */
var Behaviour = { var Behaviour = {
list : new Array, list : new Array,
register : function(sheet){ register : function(sheet){
Behaviour.list.push(sheet); Behaviour.list.push(sheet);
}, },
start : function(){ start : function(){
Behaviour.addLoadEvent(function(){ Behaviour.addLoadEvent(function(){
Behaviour.apply(); Behaviour.apply();
}); });
}, },
apply : function(){ apply : function(){
for (h=0;sheet=Behaviour.list[h];h++){ for (h=0;sheet=Behaviour.list[h];h++){
for (selector in sheet){ for (selector in sheet){
list = document.getElementsBySelector(selector); list = document.getElementsBySelector(selector);
if (!list){ if (!list){
continue; continue;
} }
...@@ -65,10 +65,10 @@ var Behaviour = { ...@@ -65,10 +65,10 @@ var Behaviour = {
} }
} }
}, },
addLoadEvent : function(func){ addLoadEvent : function(func){
var oldonload = window.onload; var oldonload = window.onload;
if (typeof window.onload != 'function') { if (typeof window.onload != 'function') {
window.onload = func; window.onload = func;
} else { } else {
...@@ -87,13 +87,13 @@ Behaviour.start(); ...@@ -87,13 +87,13 @@ Behaviour.start();
document.getElementsBySelector(selector) document.getElementsBySelector(selector)
- returns an array of element objects from the current document - returns an array of element objects from the current document
matching the CSS selector. Selectors can contain element names, matching the CSS selector. Selectors can contain element names,
class names and ids and can be nested. For example: class names and ids and can be nested. For example:
elements = document.getElementsBySelect('div#main p a.external') elements = document.getElementsBySelect('div#main p a.external')
Will return an array of all 'a' elements with 'external' in their Will return an array of all 'a' elements with 'external' in their
class attribute that are contained inside 'p' elements that are class attribute that are contained inside 'p' elements that are
contained inside the 'div' element which has id="main" contained inside the 'div' element which has id="main"
New in version 0.4: Support for CSS2 and CSS3 attribute selectors: New in version 0.4: Support for CSS2 and CSS3 attribute selectors:
...@@ -101,7 +101,7 @@ Behaviour.start(); ...@@ -101,7 +101,7 @@ Behaviour.start();
Version 0.4 - Simon Willison, March 25th 2003 Version 0.4 - Simon Willison, March 25th 2003
-- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows -- Works in Phoenix 0.5, Mozilla 1.3, Opera 7, Internet Explorer 6, Internet Explorer 5 on Windows
-- Opera 7 fails -- Opera 7 fails
*/ */
function getAllChildren(e) { function getAllChildren(e) {
...@@ -194,7 +194,7 @@ document.getElementsBySelector = function(selector) { ...@@ -194,7 +194,7 @@ document.getElementsBySelector = function(selector) {
case '=': // Equality case '=': // Equality
checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); }; checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); };
break; break;
case '~': // Match one of space separated words case '~': // Match one of space separated words
checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); }; checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); };
break; break;
case '|': // Match start with value followed by optional hyphen case '|': // Match start with value followed by optional hyphen
...@@ -223,11 +223,11 @@ document.getElementsBySelector = function(selector) { ...@@ -223,11 +223,11 @@ document.getElementsBySelector = function(selector) {
// alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue); // alert('Attribute Selector: '+tagName+' '+attrName+' '+attrOperator+' '+attrValue);
continue; // Skip to next token continue; // Skip to next token
} }
if (!currentContext[0]){ if (!currentContext[0]){
return; return;
} }
// If we get here, token is JUST an element (not a class or ID selector) // If we get here, token is JUST an element (not a class or ID selector)
tagName = token; tagName = token;
var found = new Array; var found = new Array;
...@@ -243,12 +243,12 @@ document.getElementsBySelector = function(selector) { ...@@ -243,12 +243,12 @@ document.getElementsBySelector = function(selector) {
return currentContext; return currentContext;
} }
/* That revolting regular expression explained /* That revolting regular expression explained
/^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ /^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
\---/ \---/\-------------/ \-------/ \---/ \---/\-------------/ \-------/
| | | | | | | |
| | | The value | | | The value
| | ~,|,^,$,* or = | | ~,|,^,$,* or =
| Attribute | Attribute
Tag Tag
*/ */
...@@ -133,7 +133,7 @@ function domLib_clone(obj) ...@@ -133,7 +133,7 @@ function domLib_clone(obj)
function domTT_Hash() function domTT_Hash()
{ {
this.length = 0; this.length = 0;
this.numericLength = 0; this.numericLength = 0;
this.elementData = []; this.elementData = [];
for (var i = 0; i < arguments.length; i += 2) for (var i = 0; i < arguments.length; i += 2)
{ {
...@@ -141,7 +141,7 @@ function domTT_Hash() ...@@ -141,7 +141,7 @@ function domTT_Hash()
{ {
this.elementData[arguments[i]] = arguments[i + 1]; this.elementData[arguments[i]] = arguments[i + 1];
this.length++; this.length++;
if (arguments[i] == parseInt(arguments[i])) if (arguments[i] == parseInt(arguments[i]))
{ {
this.numericLength++; this.numericLength++;
} }
...@@ -149,7 +149,7 @@ function domTT_Hash() ...@@ -149,7 +149,7 @@ function domTT_Hash()
} }
} }
// using prototype as opposed to inner functions saves on memory // using prototype as opposed to inner functions saves on memory
domTT_Hash.prototype.get = function(in_key) domTT_Hash.prototype.get = function(in_key)
{ {
if (typeof(this.elementData[in_key]) != 'undefined') { if (typeof(this.elementData[in_key]) != 'undefined') {
...@@ -166,7 +166,7 @@ domTT_Hash.prototype.set = function(in_key, in_value) ...@@ -166,7 +166,7 @@ domTT_Hash.prototype.set = function(in_key, in_value)
if (typeof(this.elementData[in_key]) == 'undefined') if (typeof(this.elementData[in_key]) == 'undefined')
{ {
this.length++; this.length++;
if (in_key == parseInt(in_key)) if (in_key == parseInt(in_key))
{ {
this.numericLength++; this.numericLength++;
} }
...@@ -184,7 +184,7 @@ domTT_Hash.prototype.remove = function(in_key) ...@@ -184,7 +184,7 @@ domTT_Hash.prototype.remove = function(in_key)
if (typeof(this.elementData[in_key]) != 'undefined') if (typeof(this.elementData[in_key]) != 'undefined')
{ {
this.length--; this.length--;
if (in_key == parseInt(in_key)) if (in_key == parseInt(in_key))
{ {
this.numericLength--; this.numericLength--;
} }
...@@ -208,9 +208,9 @@ domTT_Hash.prototype.has = function(in_key) ...@@ -208,9 +208,9 @@ domTT_Hash.prototype.has = function(in_key)
domTT_Hash.prototype.find = function(in_obj) domTT_Hash.prototype.find = function(in_obj)
{ {
for (var tmp_key in this.elementData) for (var tmp_key in this.elementData)
{ {
if (this.elementData[tmp_key] == in_obj) if (this.elementData[tmp_key] == in_obj)
{ {
return tmp_key; return tmp_key;
} }
...@@ -221,12 +221,12 @@ domTT_Hash.prototype.find = function(in_obj) ...@@ -221,12 +221,12 @@ domTT_Hash.prototype.find = function(in_obj)
domTT_Hash.prototype.merge = function(in_hash) domTT_Hash.prototype.merge = function(in_hash)
{ {
for (var tmp_key in in_hash.elementData) for (var tmp_key in in_hash.elementData)
{ {
if (typeof(this.elementData[tmp_key]) == 'undefined') if (typeof(this.elementData[tmp_key]) == 'undefined')
{ {
this.length++; this.length++;
if (tmp_key == parseInt(tmp_key)) if (tmp_key == parseInt(tmp_key))
{ {
this.numericLength++; this.numericLength++;
} }
...@@ -238,19 +238,19 @@ domTT_Hash.prototype.merge = function(in_hash) ...@@ -238,19 +238,19 @@ domTT_Hash.prototype.merge = function(in_hash)
domTT_Hash.prototype.compare = function(in_hash) domTT_Hash.prototype.compare = function(in_hash)
{ {
if (this.length != in_hash.length) if (this.length != in_hash.length)
{ {
return false; return false;
} }
for (var tmp_key in this.elementData) for (var tmp_key in this.elementData)
{ {
if (this.elementData[tmp_key] != in_hash.elementData[tmp_key]) if (this.elementData[tmp_key] != in_hash.elementData[tmp_key])
{ {
return false; return false;
} }
} }
return true; return true;
}; };
...@@ -390,7 +390,7 @@ function domLib_detectCollisions(in_object, in_recover, in_useCache) ...@@ -390,7 +390,7 @@ function domLib_detectCollisions(in_object, in_recover, in_useCache)
thisElement.hideList = new domTT_Hash(); thisElement.hideList = new domTT_Hash();
} }
var selectOffsets = domLib_getOffsets(thisElement); var selectOffsets = domLib_getOffsets(thisElement);
var center2centerDistance = Math.sqrt(Math.pow(selectOffsets.get('leftCenter') - objectOffsets.get('leftCenter'), 2) + Math.pow(selectOffsets.get('topCenter') - objectOffsets.get('topCenter'), 2)); var center2centerDistance = Math.sqrt(Math.pow(selectOffsets.get('leftCenter') - objectOffsets.get('leftCenter'), 2) + Math.pow(selectOffsets.get('topCenter') - objectOffsets.get('topCenter'), 2));
var radiusSum = selectOffsets.get('radius') + objectOffsets.get('radius'); var radiusSum = selectOffsets.get('radius') + objectOffsets.get('radius');
// the encompassing circles are overlapping, get in for a closer look // the encompassing circles are overlapping, get in for a closer look
...@@ -469,7 +469,7 @@ function domLib_getOffsets(in_object, in_preserveScroll) ...@@ -469,7 +469,7 @@ function domLib_getOffsets(in_object, in_preserveScroll)
'bottom', offsetTop + originalHeight, 'bottom', offsetTop + originalHeight,
'leftCenter', offsetLeft + originalWidth/2, 'leftCenter', offsetLeft + originalWidth/2,
'topCenter', offsetTop + originalHeight/2, 'topCenter', offsetTop + originalHeight/2,
'radius', Math.max(originalWidth, originalHeight) 'radius', Math.max(originalWidth, originalHeight)
); );
} }
...@@ -612,8 +612,8 @@ function domLib_getIFrameReference(in_frame) ...@@ -612,8 +612,8 @@ function domLib_getIFrameReference(in_frame)
function domLib_getElementsByClass(in_class) function domLib_getElementsByClass(in_class)
{ {
var elements = domLib_isIE5 ? document.all : document.getElementsByTagName('*'); var elements = domLib_isIE5 ? document.all : document.getElementsByTagName('*');
var matches = []; var matches = [];
var cnt = 0; var cnt = 0;
for (var i = 0; i < elements.length; i++) for (var i = 0; i < elements.length; i++)
{ {
...@@ -658,7 +658,7 @@ function domLib_getElementsByTagNames(in_list, in_excludeHidden) ...@@ -658,7 +658,7 @@ function domLib_getElementsByTagNames(in_list, in_excludeHidden)
continue; continue;
} }
elements[elements.length] = matches[j]; elements[elements.length] = matches[j];
} }
} }
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* Maintainer: Dan Allen <dan.allen@mojavelinux.com> * Maintainer: Dan Allen <dan.allen@mojavelinux.com>
* Contributors: * Contributors:
* Josh Gross <josh@jportalhome.com> * Josh Gross <josh@jportalhome.com>
* Jason Rust <jason@rustyparts.com> * Jason Rust <jason@rustyparts.com>
* *
* License: Apache 2.0 * License: Apache 2.0
...@@ -473,7 +473,7 @@ function domTT_create(in_options) ...@@ -473,7 +473,7 @@ function domTT_create(in_options)
{ {
var left = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-left-width'); var left = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-left-width');
var right = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-right-width'); var right = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-right-width');
left = left.substring(left.indexOf(':') + 2, left.indexOf(';')); left = left.substring(left.indexOf(':') + 2, left.indexOf(';'));
right = right.substring(right.indexOf(':') + 2, right.indexOf(';')); right = right.substring(right.indexOf(':') + 2, right.indexOf(';'));
var correction = 2 * ((left ? parseInt(left) : 0) + (right ? parseInt(right) : 0)); var correction = 2 * ((left ? parseInt(left) : 0) + (right ? parseInt(right) : 0));
...@@ -804,7 +804,7 @@ function domTT_close(in_handle) ...@@ -804,7 +804,7 @@ function domTT_close(in_handle)
while (!obj.id || !domTT_tooltips.get(obj.id)) while (!obj.id || !domTT_tooltips.get(obj.id))
{ {
obj = obj.parentNode; obj = obj.parentNode;
if (obj.nodeType != document.ELEMENT_NODE) { return; } if (obj.nodeType != document.ELEMENT_NODE) { return; }
} }
...@@ -885,7 +885,7 @@ function domTT_deactivate(in_id) ...@@ -885,7 +885,7 @@ function domTT_deactivate(in_id)
if (domTT_detectCollisions) { if (domTT_detectCollisions) {
// unhide all of the selects that are owned by this object // unhide all of the selects that are owned by this object
// utilize original collision element cache // utilize original collision element cache
domLib_detectCollisions(tipObj, true, true); domLib_detectCollisions(tipObj, true, true);
} }
} }
} }
......
...@@ -49,7 +49,7 @@ function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) { ...@@ -49,7 +49,7 @@ function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) {
this._maxOpacity = this._minOpacity; this._maxOpacity = this._minOpacity;
} }
} }
if (typeof initialOpacity != 'undefined') { if (typeof initialOpacity != 'undefined') {
if (initialOpacity > this._maxOpacity) { if (initialOpacity > this._maxOpacity) {
this._opacity = this._maxOpacity; this._opacity = this._maxOpacity;
...@@ -81,7 +81,7 @@ function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) { ...@@ -81,7 +81,7 @@ function Fadomatic (element, rate, initialOpacity, minOpacity, maxOpacity) {
} }
this._updateOpacity = this._updateOpacityMSIE; this._updateOpacity = this._updateOpacityMSIE;
} else { } else {
this._updateOpacity = this._updateVisibility; this._updateOpacity = this._updateVisibility;
...@@ -157,7 +157,7 @@ Fadomatic.prototype._tickFade = function () { ...@@ -157,7 +157,7 @@ Fadomatic.prototype._tickFade = function () {
}; };
Fadomatic.prototype._updateVisibility = function () { Fadomatic.prototype._updateVisibility = function () {
if (this._opacity > 0) { if (this._opacity > 0) {
this._element.style.visibility = 'visible'; this._element.style.visibility = 'visible';
} else { } else {
...@@ -166,13 +166,13 @@ Fadomatic.prototype._updateVisibility = function () { ...@@ -166,13 +166,13 @@ Fadomatic.prototype._updateVisibility = function () {
}; };
Fadomatic.prototype._updateOpacityW3c = function () { Fadomatic.prototype._updateOpacityW3c = function () {
this._element.style.opacity = this._opacity/100; this._element.style.opacity = this._opacity/100;
this._updateVisibility(); this._updateVisibility();
}; };
Fadomatic.prototype._updateOpacityMSIE = function () { Fadomatic.prototype._updateOpacityMSIE = function () {
this._element.filters.alpha.opacity = this._opacity; this._element.filters.alpha.opacity = this._opacity;
this._updateVisibility(); this._updateVisibility();
}; };
......
...@@ -91,7 +91,7 @@ function update_table_rows(data) { ...@@ -91,7 +91,7 @@ function update_table_rows(data) {
if (isIE) { if (isIE) {
showanim = 0; showanim = 0;
} }
var startat = data.length - nentries; var startat = data.length - nentries;
if (startat < 0) { if (startat < 0) {
startat = 0; startat = 0;
......
This diff is collapsed.
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
* @class * @class
* @scope public * @scope public
*/ */
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) { oProvider /*:SuggestionProvider*/) {
/** /**
* The currently selected suggestions. * The currently selected suggestions.
* @scope private * @scope private
*/ */
this.cur /*:int*/ = -1; this.cur /*:int*/ = -1;
/** /**
...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
* @scope private * @scope private
*/ */
this.layer = null; this.layer = null;
/** /**
* Suggestion provider for the autosuggest feature. * Suggestion provider for the autosuggest feature.
* @scope private. * @scope private.
*/ */
this.provider /*:SuggestionProvider*/ = oProvider; this.provider /*:SuggestionProvider*/ = oProvider;
/** /**
* The textbox to capture. * The textbox to capture.
* @scope private * @scope private
*/ */
this.textbox /*:HTMLInputElement*/ = oTextbox; this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control //initialize the control
this.init(); this.init();
} }
/** /**
...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
*/ */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/, AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion //make sure there's at least one suggestion
if (aSuggestions.length > 0) { if (aSuggestions.length > 0) {
if (bTypeAhead) { if (bTypeAhead) {
this.typeAhead(aSuggestions[0]); this.typeAhead(aSuggestions[0]);
} }
this.showSuggestions(aSuggestions); this.showSuggestions(aSuggestions);
} else { } else {
this.hideSuggestions(); this.hideSuggestions();
...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () {
this.layer.className = "suggestions"; this.layer.className = "suggestions";
this.layer.style.visibility = "hidden"; this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth; this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML) //when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox //and place it into a textbox
this.layer.onmousedown = this.layer.onmousedown =
this.layer.onmouseup = this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) { this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event; oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement; oTarget = oEvent.target || oEvent.srcElement;
...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () {
oThis.textbox.focus(); oThis.textbox.focus();
} }
}; };
document.body.appendChild(this.layer); document.body.appendChild(this.layer);
}; };
...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ { ...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iLeft = 0; var iLeft = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft; iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iLeft; return iLeft;
}; };
...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ { ...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iTop = 0; var iTop = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop; iTop += oNode.offsetTop;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iTop; return iTop;
}; };
...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) { ...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
case 38: //up arrow case 38: //up arrow
this.previousSuggestion(); this.previousSuggestion();
break; break;
case 40: //down arrow case 40: //down arrow
this.nextSuggestion(); this.nextSuggestion();
break; break;
case 13: //enter case 13: //enter
...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) { ...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
//for backspace (8) and delete (46), shows suggestions without typeahead //for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) { if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false); this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys //make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) { } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore //ignore
...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () { ...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () {
* @param oSuggestionNode The node representing a suggestion in the dropdown. * @param oSuggestionNode The node representing a suggestion in the dropdown.
*/ */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) { AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) { for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i]; var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) { if (oNode == oSuggestionNode) {
...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () { ...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () {
//save a reference to this object //save a reference to this object
var oThis = this; var oThis = this;
//assign the onkeyup event handler //assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) { this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyUp() method with the event object //call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent); oThis.handleKeyUp(oEvent);
}; };
//assign onkeydown event handler //assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) { this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyDown() method with the event object //call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent); oThis.handleKeyDown(oEvent);
}; };
//assign onblur event handler (hides suggestions) //assign onblur event handler (hides suggestions)
this.textbox.onblur = function () { this.textbox.onblur = function () {
oThis.hideSuggestions(); oThis.hideSuggestions();
}; };
//create the suggestions dropdown //create the suggestions dropdown
this.createDropDown(); this.createDropDown();
}; };
...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () { ...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) { if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur]; var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () { ...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur > 0) { if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur]; var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
//use text ranges for Internet Explorer //use text ranges for Internet Explorer
if (this.textbox.createTextRange) { if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange(); var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart); oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length); oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select(); oRange.select();
//use setSelectionRange() for Mozilla //use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) { } else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength); this.textbox.setSelectionRange(iStart, iLength);
} }
//set focus back to the textbox //set focus back to the textbox
this.textbox.focus(); this.textbox.focus();
}; };
/** /**
* Builds the suggestion layer contents, moves it into position, * Builds the suggestion layer contents, moves it into position,
...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
* @param aSuggestions An array of suggestions for the control. * @param aSuggestions An array of suggestions for the control.
*/ */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) { AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null; var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) { for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div"); oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i])); oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv); this.layer.appendChild(oDiv);
} }
this.layer.style.left = this.getLeft() + "px"; this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px"; this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible"; this.layer.style.visibility = "visible";
...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/ ...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/
}; };
/** /**
* Inserts a suggestion into the textbox, highlighting the * Inserts a suggestion into the textbox, highlighting the
* suggested part of the text. * suggested part of the text.
* @scope private * @scope private
* @param sSuggestion The suggestion for the textbox. * @param sSuggestion The suggestion for the textbox.
...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) { ...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality //check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){ if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length; var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion; this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length); this.selectRange(iLen, sSuggestion.length);
} }
}; };
...@@ -3,4 +3,4 @@ function kH(e) { ...@@ -3,4 +3,4 @@ function kH(e) {
return pK != 13; return pK != 13;
} }
document.onkeypress = kH; document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS); if (document.layers) document.captureEvents(Event.KEYPRESS);
\ No newline at end of file
...@@ -9,7 +9,7 @@ function StateSuggestions(text) { ...@@ -9,7 +9,7 @@ function StateSuggestions(text) {
} }
/** /**
* Request suggestions for the given autosuggest control. * Request suggestions for the given autosuggest control.
* @scope protected * @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for. * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/ */
...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /* ...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
var aSuggestions = []; var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value; var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){ if (sTextboxValue.length > 0){
//search for matching states //search for matching states
for (var i=0; i < this.states.length; i++) { for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) { if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]); aSuggestions.push(this.states[i]);
} }
} }
} }
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
* @class * @class
* @scope public * @scope public
*/ */
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) { oProvider /*:SuggestionProvider*/) {
/** /**
* The currently selected suggestions. * The currently selected suggestions.
* @scope private * @scope private
*/ */
this.cur /*:int*/ = -1; this.cur /*:int*/ = -1;
/** /**
...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
* @scope private * @scope private
*/ */
this.layer = null; this.layer = null;
/** /**
* Suggestion provider for the autosuggest feature. * Suggestion provider for the autosuggest feature.
* @scope private. * @scope private.
*/ */
this.provider /*:SuggestionProvider*/ = oProvider; this.provider /*:SuggestionProvider*/ = oProvider;
/** /**
* The textbox to capture. * The textbox to capture.
* @scope private * @scope private
*/ */
this.textbox /*:HTMLInputElement*/ = oTextbox; this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control //initialize the control
this.init(); this.init();
} }
/** /**
...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
*/ */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/, AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion //make sure there's at least one suggestion
if (aSuggestions.length > 0) { if (aSuggestions.length > 0) {
if (bTypeAhead) { if (bTypeAhead) {
this.typeAhead(aSuggestions[0]); this.typeAhead(aSuggestions[0]);
} }
this.showSuggestions(aSuggestions); this.showSuggestions(aSuggestions);
} else { } else {
this.hideSuggestions(); this.hideSuggestions();
...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () {
this.layer.className = "suggestions"; this.layer.className = "suggestions";
this.layer.style.visibility = "hidden"; this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth; this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML) //when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox //and place it into a textbox
this.layer.onmousedown = this.layer.onmousedown =
this.layer.onmouseup = this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) { this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event; oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement; oTarget = oEvent.target || oEvent.srcElement;
...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () {
oThis.textbox.focus(); oThis.textbox.focus();
} }
}; };
document.body.appendChild(this.layer); document.body.appendChild(this.layer);
}; };
...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ { ...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iLeft = 0; var iLeft = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft; iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iLeft; return iLeft;
}; };
...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ { ...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iTop = 0; var iTop = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop; iTop += oNode.offsetTop;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iTop; return iTop;
}; };
...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) { ...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
case 38: //up arrow case 38: //up arrow
this.previousSuggestion(); this.previousSuggestion();
break; break;
case 40: //down arrow case 40: //down arrow
this.nextSuggestion(); this.nextSuggestion();
break; break;
case 13: //enter case 13: //enter
...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) { ...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
//for backspace (8) and delete (46), shows suggestions without typeahead //for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) { if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false); this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys //make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) { } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore //ignore
...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () { ...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () {
* @param oSuggestionNode The node representing a suggestion in the dropdown. * @param oSuggestionNode The node representing a suggestion in the dropdown.
*/ */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) { AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) { for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i]; var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) { if (oNode == oSuggestionNode) {
...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () { ...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () {
//save a reference to this object //save a reference to this object
var oThis = this; var oThis = this;
//assign the onkeyup event handler //assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) { this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyUp() method with the event object //call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent); oThis.handleKeyUp(oEvent);
}; };
//assign onkeydown event handler //assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) { this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyDown() method with the event object //call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent); oThis.handleKeyDown(oEvent);
}; };
//assign onblur event handler (hides suggestions) //assign onblur event handler (hides suggestions)
this.textbox.onblur = function () { this.textbox.onblur = function () {
oThis.hideSuggestions(); oThis.hideSuggestions();
}; };
//create the suggestions dropdown //create the suggestions dropdown
this.createDropDown(); this.createDropDown();
}; };
...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () { ...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) { if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur]; var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () { ...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur > 0) { if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur]; var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
//use text ranges for Internet Explorer //use text ranges for Internet Explorer
if (this.textbox.createTextRange) { if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange(); var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart); oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length); oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select(); oRange.select();
//use setSelectionRange() for Mozilla //use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) { } else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength); this.textbox.setSelectionRange(iStart, iLength);
} }
//set focus back to the textbox //set focus back to the textbox
this.textbox.focus(); this.textbox.focus();
}; };
/** /**
* Builds the suggestion layer contents, moves it into position, * Builds the suggestion layer contents, moves it into position,
...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
* @param aSuggestions An array of suggestions for the control. * @param aSuggestions An array of suggestions for the control.
*/ */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) { AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null; var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) { for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div"); oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i])); oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv); this.layer.appendChild(oDiv);
} }
this.layer.style.left = this.getLeft() + "px"; this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px"; this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible"; this.layer.style.visibility = "visible";
...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/ ...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/
}; };
/** /**
* Inserts a suggestion into the textbox, highlighting the * Inserts a suggestion into the textbox, highlighting the
* suggested part of the text. * suggested part of the text.
* @scope private * @scope private
* @param sSuggestion The suggestion for the textbox. * @param sSuggestion The suggestion for the textbox.
...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) { ...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality //check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){ if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length; var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion; this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length); this.selectRange(iLen, sSuggestion.length);
} }
}; };
...@@ -3,4 +3,4 @@ function kH(e) { ...@@ -3,4 +3,4 @@ function kH(e) {
return pK != 13; return pK != 13;
} }
document.onkeypress = kH; document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS); if (document.layers) document.captureEvents(Event.KEYPRESS);
\ No newline at end of file
...@@ -150,7 +150,7 @@ function show_dsdiv() { ...@@ -150,7 +150,7 @@ function show_dsdiv() {
function show_advanced_noxmlrpc() { function show_advanced_noxmlrpc() {
document.getElementById("showadvnoxmlrpcsyncbox").innerHTML=''; document.getElementById("showadvnoxmlrpcsyncbox").innerHTML='';
aodiv = document.getElementById('shownoxmlrpcadv'); aodiv = document.getElementById('shownoxmlrpcadv');
aodiv.style.display = "block"; aodiv.style.display = "block";
} }
function show_advanced_vlanprio() { function show_advanced_vlanprio() {
......
...@@ -9,7 +9,7 @@ function StateSuggestions(text) { ...@@ -9,7 +9,7 @@ function StateSuggestions(text) {
} }
/** /**
* Request suggestions for the given autosuggest control. * Request suggestions for the given autosuggest control.
* @scope protected * @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for. * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/ */
...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /* ...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
var aSuggestions = []; var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value; var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){ if (sTextboxValue.length > 0){
//search for matching states //search for matching states
for (var i=0; i < this.states.length; i++) { for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) { if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]); aSuggestions.push(this.states[i]);
} }
} }
} }
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
* @class * @class
* @scope public * @scope public
*/ */
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) { oProvider /*:SuggestionProvider*/) {
/** /**
* The currently selected suggestions. * The currently selected suggestions.
* @scope private * @scope private
*/ */
this.cur /*:int*/ = -1; this.cur /*:int*/ = -1;
/** /**
...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
* @scope private * @scope private
*/ */
this.layer = null; this.layer = null;
/** /**
* Suggestion provider for the autosuggest feature. * Suggestion provider for the autosuggest feature.
* @scope private. * @scope private.
*/ */
this.provider /*:SuggestionProvider*/ = oProvider; this.provider /*:SuggestionProvider*/ = oProvider;
/** /**
* The textbox to capture. * The textbox to capture.
* @scope private * @scope private
*/ */
this.textbox /*:HTMLInputElement*/ = oTextbox; this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control //initialize the control
this.init(); this.init();
} }
/** /**
...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
*/ */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/, AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion //make sure there's at least one suggestion
if (aSuggestions.length > 0) { if (aSuggestions.length > 0) {
if (bTypeAhead) { if (bTypeAhead) {
this.typeAhead(aSuggestions[0]); this.typeAhead(aSuggestions[0]);
} }
this.showSuggestions(aSuggestions); this.showSuggestions(aSuggestions);
} else { } else {
this.hideSuggestions(); this.hideSuggestions();
...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () {
this.layer.className = "suggestions"; this.layer.className = "suggestions";
this.layer.style.visibility = "hidden"; this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth; this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML) //when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox //and place it into a textbox
this.layer.onmousedown = this.layer.onmousedown =
this.layer.onmouseup = this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) { this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event; oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement; oTarget = oEvent.target || oEvent.srcElement;
...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () {
oThis.textbox.focus(); oThis.textbox.focus();
} }
}; };
document.body.appendChild(this.layer); document.body.appendChild(this.layer);
}; };
...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ { ...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iLeft = 0; var iLeft = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft; iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iLeft; return iLeft;
}; };
...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ { ...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iTop = 0; var iTop = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop; iTop += oNode.offsetTop;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iTop; return iTop;
}; };
...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) { ...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
case 38: //up arrow case 38: //up arrow
this.previousSuggestion(); this.previousSuggestion();
break; break;
case 40: //down arrow case 40: //down arrow
this.nextSuggestion(); this.nextSuggestion();
break; break;
case 13: //enter case 13: //enter
...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) { ...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
//for backspace (8) and delete (46), shows suggestions without typeahead //for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) { if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false); this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys //make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) { } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore //ignore
...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () { ...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () {
* @param oSuggestionNode The node representing a suggestion in the dropdown. * @param oSuggestionNode The node representing a suggestion in the dropdown.
*/ */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) { AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) { for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i]; var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) { if (oNode == oSuggestionNode) {
...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () { ...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () {
//save a reference to this object //save a reference to this object
var oThis = this; var oThis = this;
//assign the onkeyup event handler //assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) { this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyUp() method with the event object //call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent); oThis.handleKeyUp(oEvent);
}; };
//assign onkeydown event handler //assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) { this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyDown() method with the event object //call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent); oThis.handleKeyDown(oEvent);
}; };
//assign onblur event handler (hides suggestions) //assign onblur event handler (hides suggestions)
this.textbox.onblur = function () { this.textbox.onblur = function () {
oThis.hideSuggestions(); oThis.hideSuggestions();
}; };
//create the suggestions dropdown //create the suggestions dropdown
this.createDropDown(); this.createDropDown();
}; };
...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () { ...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) { if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur]; var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () { ...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur > 0) { if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur]; var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
//use text ranges for Internet Explorer //use text ranges for Internet Explorer
if (this.textbox.createTextRange) { if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange(); var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart); oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length); oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select(); oRange.select();
//use setSelectionRange() for Mozilla //use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) { } else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength); this.textbox.setSelectionRange(iStart, iLength);
} }
//set focus back to the textbox //set focus back to the textbox
this.textbox.focus(); this.textbox.focus();
}; };
/** /**
* Builds the suggestion layer contents, moves it into position, * Builds the suggestion layer contents, moves it into position,
...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
* @param aSuggestions An array of suggestions for the control. * @param aSuggestions An array of suggestions for the control.
*/ */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) { AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null; var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) { for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div"); oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i])); oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv); this.layer.appendChild(oDiv);
} }
this.layer.style.left = this.getLeft() + "px"; this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px"; this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible"; this.layer.style.visibility = "visible";
...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/ ...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/
}; };
/** /**
* Inserts a suggestion into the textbox, highlighting the * Inserts a suggestion into the textbox, highlighting the
* suggested part of the text. * suggested part of the text.
* @scope private * @scope private
* @param sSuggestion The suggestion for the textbox. * @param sSuggestion The suggestion for the textbox.
...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) { ...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality //check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){ if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length; var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion; this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length); this.selectRange(iLen, sSuggestion.length);
} }
}; };
...@@ -3,4 +3,4 @@ function kH(e) { ...@@ -3,4 +3,4 @@ function kH(e) {
return pK != 13; return pK != 13;
} }
document.onkeypress = kH; document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS); if (document.layers) document.captureEvents(Event.KEYPRESS);
\ No newline at end of file
...@@ -34,4 +34,4 @@ window.onload = function () { ...@@ -34,4 +34,4 @@ window.onload = function () {
var oTextbox3 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray)); var oTextbox3 = new AutoSuggestControl(document.getElementById("dstendport_cust"), new StateSuggestions(customarray));
}; };
//]]> //]]>
\ No newline at end of file
...@@ -9,7 +9,7 @@ function StateSuggestions(text) { ...@@ -9,7 +9,7 @@ function StateSuggestions(text) {
} }
/** /**
* Request suggestions for the given autosuggest control. * Request suggestions for the given autosuggest control.
* @scope protected * @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for. * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/ */
...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /* ...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
var aSuggestions = []; var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value; var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){ if (sTextboxValue.length > 0){
//search for matching states //search for matching states
for (var i=0; i < this.states.length; i++) { for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) { if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]); aSuggestions.push(this.states[i]);
} }
} }
} }
......
...@@ -22,7 +22,7 @@ var AjaxQueue = { ...@@ -22,7 +22,7 @@ var AjaxQueue = {
if(this.currentRequest == null && this.urlQueue.length > 0) // Check if the currently processing request count is less than batch size if(this.currentRequest == null && this.urlQueue.length > 0) // Check if the currently processing request count is less than batch size
{ {
// Call jQuery.ajax on the first item in the queue and remove it from the queue // Call jQuery.ajax on the first item in the queue and remove it from the queue
AjaxQueue.currentRequest = jQuery.ajax(AjaxQueue.urlQueue.shift(), AjaxQueue.optionsQueue.shift()); AjaxQueue.currentRequest = jQuery.ajax(AjaxQueue.urlQueue.shift(), AjaxQueue.optionsQueue.shift());
AjaxQueue.currentRequest.complete( function() { AjaxQueue.currentRequest.complete( function() {
//Call AjaxQueue._processNext on completion ( success / failure) of this AJAX request. //Call AjaxQueue._processNext on completion ( success / failure) of this AJAX request.
AjaxQueue.currentRequest = null; AjaxQueue.currentRequest = null;
...@@ -40,4 +40,3 @@ var AjaxQueue = { ...@@ -40,4 +40,3 @@ var AjaxQueue = {
} }
} }
}; };
...@@ -19,8 +19,8 @@ function updateMeters() { ...@@ -19,8 +19,8 @@ function updateMeters() {
setTimer(); setTimer();
} }
function setTimer() { function setTimer() {
timeout = window.setTimeout('updateMeters()', update_interval); timeout = window.setTimeout('updateMeters()', update_interval);
} }
function stats(x) { function stats(x) {
...@@ -131,7 +131,7 @@ function updateInterfaceStats(x){ ...@@ -131,7 +131,7 @@ function updateInterfaceStats(x){
for (var y=0; y<statistics_split.length-1; y++){ for (var y=0; y<statistics_split.length-1; y++){
if(jQuery('#stat' + counter)) { if(jQuery('#stat' + counter)) {
jQuery('#stat' + counter).html(statistics_split[y]); jQuery('#stat' + counter).html(statistics_split[y]);
counter++; counter++;
} }
} }
} }
...@@ -200,4 +200,3 @@ function widgetActive(x) { ...@@ -200,4 +200,3 @@ function widgetActive(x) {
jQuery(document).ready(function(){ jQuery(document).ready(function(){
setTimer(); setTimer();
}); });
...@@ -66,10 +66,10 @@ function show_hide_linkfields(options){ ...@@ -66,10 +66,10 @@ function show_hide_linkfields(options){
subnet = "#subnet" + count; subnet = "#subnet" + count;
gateway = "#gateway" + count; gateway = "#gateway" + count;
gatewaylabel = "#gatewaylabel" + count; gatewaylabel = "#gatewaylabel" + count;
jQuery(ipfields + ',' + gwfields + ',' + link).hide(); jQuery(ipfields + ',' + gwfields + ',' + link).hide();
jQuery(subnet).prop('disabled',true); jQuery(subnet).prop('disabled',true);
jQuery(bw).attr("name","bandwidth[]"); jQuery(bw).attr("name","bandwidth[]");
jQuery(mtu).attr("name","mtu[]"); jQuery(mtu).attr("name","mtu[]");
jQuery(mru).attr("name","mru[]"); jQuery(mru).attr("name","mru[]");
...@@ -77,7 +77,7 @@ function show_hide_linkfields(options){ ...@@ -77,7 +77,7 @@ function show_hide_linkfields(options){
jQuery(localip).attr("name","localip[]"); jQuery(localip).attr("name","localip[]");
jQuery(subnet).attr("name","subnet[]"); jQuery(subnet).attr("name","subnet[]");
jQuery(gateway).attr("name","gateway[]"); jQuery(gateway).attr("name","gateway[]");
while(i < options.length){ while(i < options.length){
if (options[i].selected ){ if (options[i].selected ){
jQuery(lnklabel).html("Link Parameters (" + options[i].value + ")"); jQuery(lnklabel).html("Link Parameters (" + options[i].value + ")");
...@@ -149,11 +149,11 @@ function updateType(t){ ...@@ -149,11 +149,11 @@ function updateType(t){
} }
function show_reset_settings(reset_type) { function show_reset_settings(reset_type) {
if (reset_type == 'preset') { if (reset_type == 'preset') {
jQuery('#pppoepresetwrap').show(0); jQuery('#pppoepresetwrap').show(0);
jQuery('#pppoecustomwrap').hide(0); jQuery('#pppoecustomwrap').hide(0);
} }
else if (reset_type == 'custom') { else if (reset_type == 'custom') {
jQuery('#pppoecustomwrap').show(0); jQuery('#pppoecustomwrap').show(0);
jQuery('#pppoepresetwrap').hide(0); jQuery('#pppoepresetwrap').hide(0);
} else { } else {
...@@ -167,7 +167,7 @@ function country_list() { ...@@ -167,7 +167,7 @@ function country_list() {
jQuery('#provider option').remove(); jQuery('#provider option').remove();
jQuery('#providerplan option').remove(); jQuery('#providerplan option').remove();
jQuery('#country').append(new Option('', '')); jQuery('#country').append(new Option('', ''));
jQuery.ajax("getserviceproviders.php",{ jQuery.ajax("getserviceproviders.php",{
success: function(responseText) { success: function(responseText) {
var responseTextArr = responseText.split("\n"); var responseTextArr = responseText.split("\n");
...@@ -186,7 +186,7 @@ function country_list() { ...@@ -186,7 +186,7 @@ function country_list() {
} }
}); });
jQuery('#trcountry').css("display","table-row"); jQuery('#trcountry').css("display","table-row");
} }
function providers_list() { function providers_list() {
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
* By: Trent Richardson [http://trentrichardson.com] * By: Trent Richardson [http://trentrichardson.com]
* Version 0.9.9 * Version 0.9.9
* Last Modified: 02/05/2012 * Last Modified: 02/05/2012
* *
* Copyright 2012 Trent Richardson * Copyright 2012 Trent Richardson
* Dual licensed under the MIT and GPL licenses. * Dual licensed under the MIT and GPL licenses.
* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
* *
* HERES THE CSS: * HERES THE CSS:
* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; } * .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
* .ui-timepicker-div dl { text-align: left; } * .ui-timepicker-div dl { text-align: left; }
...@@ -133,7 +133,7 @@ $.extend(Timepicker.prototype, { ...@@ -133,7 +133,7 @@ $.extend(Timepicker.prototype, {
_newInst: function($input, o) { _newInst: function($input, o) {
var tp_inst = new Timepicker(), var tp_inst = new Timepicker(),
inlineSettings = {}; inlineSettings = {};
for (var attrName in this._defaults) { for (var attrName in this._defaults) {
var attrValue = $input.attr('time:' + attrName); var attrValue = $input.attr('time:' + attrName);
if (attrValue) { if (attrValue) {
...@@ -188,7 +188,7 @@ $.extend(Timepicker.prototype, { ...@@ -188,7 +188,7 @@ $.extend(Timepicker.prototype, {
tp_inst.$altInput = $(o.altField) tp_inst.$altInput = $(o.altField)
.css({ cursor: 'pointer' }) .css({ cursor: 'pointer' })
.focus(function(){ $input.trigger("focus"); }); .focus(function(){ $input.trigger("focus"); });
if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0) if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
{ {
tp_inst._defaults.minDate=new Date(); tp_inst._defaults.minDate=new Date();
...@@ -197,7 +197,7 @@ $.extend(Timepicker.prototype, { ...@@ -197,7 +197,7 @@ $.extend(Timepicker.prototype, {
{ {
tp_inst._defaults.maxDate=new Date(); tp_inst._defaults.maxDate=new Date();
} }
// datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime.. // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date) if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime()); tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
...@@ -215,7 +215,7 @@ $.extend(Timepicker.prototype, { ...@@ -215,7 +215,7 @@ $.extend(Timepicker.prototype, {
//######################################################################## //########################################################################
_addTimePicker: function(dp_inst) { _addTimePicker: function(dp_inst) {
var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ? var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
this.$input.val() + ' ' + this.$altInput.val() : this.$input.val() + ' ' + this.$altInput.val() :
this.$input.val(); this.$input.val();
this.timeDefined = this._parseTime(currDT); this.timeDefined = this._parseTime(currDT);
...@@ -249,7 +249,7 @@ $.extend(Timepicker.prototype, { ...@@ -249,7 +249,7 @@ $.extend(Timepicker.prototype, {
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr; regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
} }
treg = timeString.match(new RegExp(regstr, 'i')); treg = timeString.match(new RegExp(regstr, 'i'));
if (treg) { if (treg) {
...@@ -297,7 +297,7 @@ $.extend(Timepicker.prototype, { ...@@ -297,7 +297,7 @@ $.extend(Timepicker.prototype, {
} }
this.timezone = tz; this.timezone = tz;
} }
return true; return true;
} }
...@@ -366,7 +366,7 @@ $.extend(Timepicker.prototype, { ...@@ -366,7 +366,7 @@ $.extend(Timepicker.prototype, {
millisecGridSize = 0, millisecGridSize = 0,
size; size;
// Hours // Hours
html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' + html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
((o.showHour) ? '' : noDisplay) + '></div>'; ((o.showHour) ? '' : noDisplay) + '></div>';
if (o.showHour && o.hourGrid > 0) { if (o.showHour && o.hourGrid > 0) {
...@@ -472,7 +472,7 @@ $.extend(Timepicker.prototype, { ...@@ -472,7 +472,7 @@ $.extend(Timepicker.prototype, {
} }
}); });
// Updated by Peter Medeiros: // Updated by Peter Medeiros:
// - Pass in Event and UI instance into slide function // - Pass in Event and UI instance into slide function
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({ this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
...@@ -634,7 +634,7 @@ $.extend(Timepicker.prototype, { ...@@ -634,7 +634,7 @@ $.extend(Timepicker.prototype, {
this.minute_slider.bind('slidestop',onSelectDelegate); this.minute_slider.bind('slidestop',onSelectDelegate);
this.second_slider.bind('slidestop',onSelectDelegate); this.second_slider.bind('slidestop',onSelectDelegate);
this.millisec_slider.bind('slidestop',onSelectDelegate); this.millisec_slider.bind('slidestop',onSelectDelegate);
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/ // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
if (this._defaults.addSliderAccess){ if (this._defaults.addSliderAccess){
var sliderAccessArgs = this._defaults.sliderAccessArgs; var sliderAccessArgs = this._defaults.sliderAccessArgs;
...@@ -651,7 +651,7 @@ $.extend(Timepicker.prototype, { ...@@ -651,7 +651,7 @@ $.extend(Timepicker.prototype, {
oldMarginLeft = $g.css('marginLeft').toString().replace('%',''), oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
newWidth = oldWidth - sliderAccessWidth, newWidth = oldWidth - sliderAccessWidth,
newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%'; newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
$g.css({ width: newWidth, marginLeft: newMarginLeft }); $g.css({ width: newWidth, marginLeft: newMarginLeft });
}); });
} }
...@@ -659,7 +659,7 @@ $.extend(Timepicker.prototype, { ...@@ -659,7 +659,7 @@ $.extend(Timepicker.prototype, {
},0); },0);
} }
// end slideAccess integration // end slideAccess integration
} }
}, },
...@@ -770,7 +770,7 @@ $.extend(Timepicker.prototype, { ...@@ -770,7 +770,7 @@ $.extend(Timepicker.prototype, {
}, },
//######################################################################## //########################################################################
// when a slider moves, set the internal time... // when a slider moves, set the internal time...
// on time change is also called when the time is updated in the text field // on time change is also called when the time is updated in the text field
...@@ -803,7 +803,7 @@ $.extend(Timepicker.prototype, { ...@@ -803,7 +803,7 @@ $.extend(Timepicker.prototype, {
|| (this.ampm.length > 0 || (this.ampm.length > 0
&& (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
|| timezone != this.timezone); || timezone != this.timezone);
if (hasChanged) { if (hasChanged) {
if (hour !== false)this.hour = hour; if (hour !== false)this.hour = hour;
...@@ -811,22 +811,22 @@ $.extend(Timepicker.prototype, { ...@@ -811,22 +811,22 @@ $.extend(Timepicker.prototype, {
if (second !== false) this.second = second; if (second !== false) this.second = second;
if (millisec !== false) this.millisec = millisec; if (millisec !== false) this.millisec = millisec;
if (timezone !== false) this.timezone = timezone; if (timezone !== false) this.timezone = timezone;
if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]); if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
this._limitMinMaxDateTime(this.inst, true); this._limitMinMaxDateTime(this.inst, true);
} }
if (o.ampm) this.ampm = ampm; if (o.ampm) this.ampm = ampm;
//this._formatTime(); //this._formatTime();
this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults); this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix); if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
this.timeDefined = true; this.timeDefined = true;
if (hasChanged) this._updateDateTime(); if (hasChanged) this._updateDateTime();
}, },
//######################################################################## //########################################################################
// call custom onSelect. // call custom onSelect.
// bind to sliders slidestop, and grid click. // bind to sliders slidestop, and grid click.
//######################################################################## //########################################################################
_onSelectHandler: function() { _onSelectHandler: function() {
...@@ -845,7 +845,7 @@ $.extend(Timepicker.prototype, { ...@@ -845,7 +845,7 @@ $.extend(Timepicker.prototype, {
var tmptime = (format || this._defaults.timeFormat).toString(); var tmptime = (format || this._defaults.timeFormat).toString();
tmptime = $.datepicker.formatTime(tmptime, time, this._defaults); tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
if (arguments.length) return tmptime; if (arguments.length) return tmptime;
else this.formattedTime = tmptime; else this.formattedTime = tmptime;
}, },
...@@ -883,7 +883,7 @@ $.extend(Timepicker.prototype, { ...@@ -883,7 +883,7 @@ $.extend(Timepicker.prototype, {
} else { } else {
this.$input.val(formattedDateTime); this.$input.val(formattedDateTime);
} }
this.$input.trigger("change"); this.$input.trigger("change");
} }
...@@ -913,9 +913,9 @@ $.fn.extend({ ...@@ -913,9 +913,9 @@ $.fn.extend({
tmp_args = arguments; tmp_args = arguments;
if (typeof(o) == 'string'){ if (typeof(o) == 'string'){
if(o == 'getDate') if(o == 'getDate')
return $.fn.datepicker.apply($(this[0]), tmp_args); return $.fn.datepicker.apply($(this[0]), tmp_args);
else else
return this.each(function() { return this.each(function() {
var $t = $(this); var $t = $(this);
$t.datepicker.apply($t, tmp_args); $t.datepicker.apply($t, tmp_args);
...@@ -930,7 +930,7 @@ $.fn.extend({ ...@@ -930,7 +930,7 @@ $.fn.extend({
}); });
//######################################################################## //########################################################################
// format the time all pretty... // format the time all pretty...
// format = string format of the time // format = string format of the time
// time = a {}, not a Date() for timezones // time = a {}, not a Date() for timezones
// options = essentially the regional[].. amNames, pmNames, ampm // options = essentially the regional[].. amNames, pmNames, ampm
...@@ -939,7 +939,7 @@ $.datepicker.formatTime = function(format, time, options) { ...@@ -939,7 +939,7 @@ $.datepicker.formatTime = function(format, time, options) {
options = options || {}; options = options || {};
options = $.extend($.timepicker._defaults, options); options = $.extend($.timepicker._defaults, options);
time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time); time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
var tmptime = format; var tmptime = format;
var ampmName = options['amNames'][0]; var ampmName = options['amNames'][0];
...@@ -1015,9 +1015,9 @@ $.datepicker._updateDatepicker = function(inst) { ...@@ -1015,9 +1015,9 @@ $.datepicker._updateDatepicker = function(inst) {
} }
if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) { if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
this._base_updateDatepicker(inst); this._base_updateDatepicker(inst);
// Reload the time control when changing something in the input text field. // Reload the time control when changing something in the input text field.
var tp_inst = this._get(inst, 'timepicker'); var tp_inst = this._get(inst, 'timepicker');
if(tp_inst) tp_inst._addTimePicker(inst); if(tp_inst) tp_inst._addTimePicker(inst);
...@@ -1055,7 +1055,7 @@ $.datepicker._doKeyPress = function(event) { ...@@ -1055,7 +1055,7 @@ $.datepicker._doKeyPress = function(event) {
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1); return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
} }
} }
return $.datepicker._base_doKeyPress(event); return $.datepicker._base_doKeyPress(event);
}; };
...@@ -1102,7 +1102,7 @@ $.datepicker._gotoToday = function(id) { ...@@ -1102,7 +1102,7 @@ $.datepicker._gotoToday = function(id) {
tp_inst.timezone_select.val(tzoffset); tp_inst.timezone_select.val(tzoffset);
} }
this._setTime(inst, now); this._setTime(inst, now);
$( '.ui-datepicker-today', $dp).click(); $( '.ui-datepicker-today', $dp).click();
}; };
//####################################################################################### //#######################################################################################
...@@ -1252,7 +1252,7 @@ $.datepicker._formatDate = function(inst, day, month, year){ ...@@ -1252,7 +1252,7 @@ $.datepicker._formatDate = function(inst, day, month, year){
{ {
if(day) if(day)
var b = this._base_formatDate(inst, day, month, year); var b = this._base_formatDate(inst, day, month, year);
tp_inst._updateDateTime(inst); tp_inst._updateDateTime(inst);
return tp_inst.$input.val(); return tp_inst.$input.val();
} }
return this._base_formatDate(inst); return this._base_formatDate(inst);
...@@ -1289,7 +1289,7 @@ $.datepicker._optionDatepicker = function(target, name, value) { ...@@ -1289,7 +1289,7 @@ $.datepicker._optionDatepicker = function(target, name, value) {
min=new Date(); min=new Date();
else else
min= new Date(min); min= new Date(min);
tp_inst._defaults.minDate = min; tp_inst._defaults.minDate = min;
tp_inst._defaults.minDateTime = min; tp_inst._defaults.minDateTime = min;
} else if (max){ //if max was set } else if (max){ //if max was set
...@@ -1323,4 +1323,3 @@ $.timepicker = new Timepicker(); // singleton instance ...@@ -1323,4 +1323,3 @@ $.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "0.9.9"; $.timepicker.version = "0.9.9";
})(jQuery); })(jQuery);
...@@ -63,7 +63,7 @@ if (!Array.prototype.some) { ...@@ -63,7 +63,7 @@ if (!Array.prototype.some) {
was_ipv4 = is_ipv4; was_ipv4 = is_ipv4;
is_ipv4 = /\./.test(input1.value) && !/\:/.test(input1.value); is_ipv4 = /\./.test(input1.value) && !/\:/.test(input1.value);
// handle state transitions to gracefully change the // handle state transitions to gracefully change the
// value in the dropdown. // value in the dropdown.
var bits = parseInt($(input2).val(), 10); var bits = parseInt($(input2).val(), 10);
if (was_ipv4 === false && is_ipv4 === true) { if (was_ipv4 === false && is_ipv4 === true) {
restrict_bits_to_ipv4(); restrict_bits_to_ipv4();
...@@ -137,4 +137,3 @@ if (!Array.prototype.some) { ...@@ -137,4 +137,3 @@ if (!Array.prototype.some) {
$(document).ipv4v6ify(); $(document).ipv4v6ify();
}); });
})(jQuery); })(jQuery);
...@@ -71,7 +71,7 @@ function addOption(theSel, theText, theValue) ...@@ -71,7 +71,7 @@ function addOption(theSel, theText, theValue)
} }
function deleteOption(theSel, theIndex) function deleteOption(theSel, theIndex)
{ {
var selLength = theSel.length; var selLength = theSel.length;
if(selLength>0) if(selLength>0)
{ {
......
...@@ -39,7 +39,7 @@ function copyOption(theSrc, theDst) ...@@ -39,7 +39,7 @@ function copyOption(theSrc, theDst)
} }
function deleteOption(theSel) function deleteOption(theSel)
{ {
var theIndex = theSel.selectedIndex; var theIndex = theSel.selectedIndex;
var selLength = theSel.length; var selLength = theSel.length;
if(selLength>0) if(selLength>0)
...@@ -53,4 +53,3 @@ function AllOptions(el, selectAll) { ...@@ -53,4 +53,3 @@ function AllOptions(el, selectAll) {
opt.selected = selectAll; opt.selected = selectAll;
}); });
} }
...@@ -78,7 +78,7 @@ if(!el.passed){ ...@@ -78,7 +78,7 @@ if(!el.passed){
} }
el.passed=true; el.passed=true;
} }
function AddTop(el,bk,color,bc,cn){ function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b"); var i,lim=4,d=CreateEl("b");
...@@ -171,4 +171,4 @@ for(i=0;i<3;i++){ ...@@ -171,4 +171,4 @@ for(i=0;i<3;i++){
r[i]=Math.floor((x*50+y*50)/100); r[i]=Math.floor((x*50+y*50)/100);
} }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16)); return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
} }
\ No newline at end of file
...@@ -284,4 +284,4 @@ incremetalInputController = { ...@@ -284,4 +284,4 @@ incremetalInputController = {
// Close and call anonymous function // Close and call anonymous function
})(); })();
addEvent(window, 'load', incremetalInputController.constructor, true); addEvent(window, 'load', incremetalInputController.constructor, true);
\ No newline at end of file
(function(_scope){ (function(_scope){
/* /*
* pi.js * pi.js
* 1.0 * 1.0
* Azer Koçulu <http://azer.kodfabrik.com> * Azer Koçulu <http://azer.kodfabrik.com>
* http://pi-js.googlecode.com * http://pi-js.googlecode.com
*/ */
_scope.pi = Object(3.14159265358979323846); _scope.pi = Object(3.14159265358979323846);
var pi = _scope.pi; var pi = _scope.pi;
pi.version = 1.0; pi.version = 1.0;
pi.env = { pi.env = {
ie: /MSIE/i.test(navigator.userAgent), ie: /MSIE/i.test(navigator.userAgent),
ie6: /MSIE 6/i.test(navigator.userAgent), ie6: /MSIE 6/i.test(navigator.userAgent),
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
opera: /Opera/i.test(navigator.userAgent), opera: /Opera/i.test(navigator.userAgent),
webkit: /Webkit/i.test(navigator.userAgent) webkit: /Webkit/i.test(navigator.userAgent)
}; };
pi.util = { pi.util = {
IsArray:function(_object){ IsArray:function(_object){
return _object && _object != window && ( _object instanceof Array || ( typeof _object.length == "number" && typeof _object.item =="function" ) ); return _object && _object != window && ( _object instanceof Array || ( typeof _object.length == "number" && typeof _object.item =="function" ) );
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
removeClass:function(_element,_class){ removeClass:function(_element,_class){
if( pi.util.Element.hasClass(_element,_class) ) if( pi.util.Element.hasClass(_element,_class) )
pi.util.Element.setClass( pi.util.Element.setClass(
_element, _element,
pi.util.Element.getClass(_element,_class).split(" ").removeValue(_class).join(" ") pi.util.Element.getClass(_element,_class).split(" ").removeValue(_class).join(" ")
); );
}, },
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
var styleObject = _styleObject; var styleObject = _styleObject;
if(!pi.env.ie) if(!pi.env.ie)
return styleObject["opacity"]; return styleObject["opacity"];
var alpha = styleObject["filter"].match(/opacity\=(\d+)/i); var alpha = styleObject["filter"].match(/opacity\=(\d+)/i);
return alpha?alpha[1]/100:1; return alpha?alpha[1]/100:1;
}, },
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
else else
value = _source[key].clone(); value = _source[key].clone();
} }
else else
if (pi.util.IsHash(_source[key])) { if (pi.util.IsHash(_source[key])) {
if (pi.util.IsHash(_object[key])) { if (pi.util.IsHash(_object[key])) {
value = pi.util.MergeObjects(_object[key], _source[key]); value = pi.util.MergeObjects(_object[key], _source[key]);
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
return _object; return _object;
} }
}; };
pi.get = function(){ pi.get = function(){
return document.getElementById(arguments[0]); return document.getElementById(arguments[0]);
}; };
...@@ -194,23 +194,23 @@ ...@@ -194,23 +194,23 @@
return document.getElementsByTagName(arguments[0]); return document.getElementsByTagName(arguments[0]);
}; };
pi.get.byClass = function(){ return document.getElementsByClassName.apply(document,arguments); }; pi.get.byClass = function(){ return document.getElementsByClassName.apply(document,arguments); };
pi.base = function(){ pi.base = function(){
this.body = {}; this.body = {};
this.constructor = null; this.constructor = null;
this.build = function(_skipClonning){ this.build = function(_skipClonning){
var base = this, skipClonning = _skipClonning||false, _private = {}, var base = this, skipClonning = _skipClonning||false, _private = {},
fn = function(){ fn = function(){
var _p = pi.util.CloneObject(_private); var _p = pi.util.CloneObject(_private);
if(!skipClonning){ if(!skipClonning){
for(var key in this){ for(var key in this){
if(pi.util.IsArray( this[ key ] ) ){ if(pi.util.IsArray( this[ key ] ) ){
this[key] = Array.prototype.clone.apply( this[key] ); this[key] = Array.prototype.clone.apply( this[key] );
} else } else
if( pi.util.IsHash(this[key]) ){ if( pi.util.IsHash(this[key]) ){
this[key] = pi.util.CloneObject( this[key] = pi.util.CloneObject(
this[ key ], this[ key ],
function(_key,_object){ function(_key,_object){
this[ _key ]._parent_ = this; this[ _key ]._parent_ = this;
...@@ -232,35 +232,35 @@ ...@@ -232,35 +232,35 @@
fn.prototype = this.body; fn.prototype = this.body;
return fn; return fn;
}; };
this.createAccessors = function(_p, _branch){ this.createAccessors = function(_p, _branch){
var getter = function(_property){ return this[_property]; }, var getter = function(_property){ return this[_property]; },
setter = function(_property,_value){ this[_property] = _value; return _branch._parent_||_branch; }; setter = function(_property,_value){ this[_property] = _value; return _branch._parent_||_branch; };
for (var name in _p) { for (var name in _p) {
var isPrivate = name.substring(0, 1) == "_", title = name.substring(1, 2).toUpperCase() + name.substring(2); var isPrivate = name.substring(0, 1) == "_", title = name.substring(1, 2).toUpperCase() + name.substring(2);
if (isPrivate) { if (isPrivate) {
_branch["get" + title] = getter.curry(_p,name); _branch["get" + title] = getter.curry(_p,name);
_branch["set" + title] = setter.curry(_p,name); _branch["set" + title] = setter.curry(_p,name);
} }
else else
if (pi.util.IsHash(_p[name])){ if (pi.util.IsHash(_p[name])){
if(!_branch[name]) if(!_branch[name])
_branch[name] = {}; _branch[name] = {};
this.createAccessors(_p[name], _branch[name]); this.createAccessors(_p[name], _branch[name]);
} }
}; };
}; };
this.movePrivateMembers = function(_object, _branch){ this.movePrivateMembers = function(_object, _branch){
for (var name in _object) { for (var name in _object) {
var isPrivate = name.substring(0, 1) == "_"; var isPrivate = name.substring(0, 1) == "_";
if (isPrivate) { if (isPrivate) {
_branch[name] = _object[name]; _branch[name] = _object[name];
delete _object[name]; delete _object[name];
} }
else else
if (pi.util.IsHash(_object[name])){ if (pi.util.IsHash(_object[name])){
_branch[name] = {}; _branch[name] = {};
this.movePrivateMembers(_object[name], _branch[name]); this.movePrivateMembers(_object[name], _branch[name]);
...@@ -268,30 +268,30 @@ ...@@ -268,30 +268,30 @@
}; };
}; };
}; };
Function.prototype.extend = function(_prototype,_skipClonning){ Function.prototype.extend = function(_prototype,_skipClonning){
var object = new pi.base, superClass = this; var object = new pi.base, superClass = this;
if(_prototype["$Constructor"]){ if(_prototype["$Constructor"]){
object.constructor = _prototype["$Constructor"]; object.constructor = _prototype["$Constructor"];
delete _prototype["$Constructor"]; delete _prototype["$Constructor"];
}; };
object.body = superClass==pi.base?_prototype:pi.util.MergeObjects(_prototype,superClass.prototype,2); object.body = superClass==pi.base?_prototype:pi.util.MergeObjects(_prototype,superClass.prototype,2);
object.constructor=object.constructor||function(){ object.constructor=object.constructor||function(){
if(superClass!=pi.base) if(superClass!=pi.base)
superClass.apply(this,arguments); superClass.apply(this,arguments);
}; };
return object.build(_skipClonning); return object.build(_skipClonning);
}; };
Function.prototype.curry = function(_scope){ Function.prototype.curry = function(_scope){
var fn = this, scope = _scope||window, args = Array.prototype.slice.call(arguments,1); var fn = this, scope = _scope||window, args = Array.prototype.slice.call(arguments,1);
return function(){ return function(){
return fn.apply(scope,args.concat( Array.prototype.slice.call(arguments,0) )); return fn.apply(scope,args.concat( Array.prototype.slice.call(arguments,0) ));
}; };
}; };
pi.element = pi.base.extend({ pi.element = pi.base.extend({
"$Constructor":function(_tag){ "$Constructor":function(_tag){
this.environment.setElement(document.createElement(_tag||"DIV")); this.environment.setElement(document.createElement(_tag||"DIV"));
...@@ -460,7 +460,7 @@ ...@@ -460,7 +460,7 @@
} }
} }
}); });
pi.xhr = new pi.base; pi.xhr = new pi.base;
pi.xhr.constructor = function(){ pi.xhr.constructor = function(){
var api; var api;
...@@ -483,16 +483,16 @@ ...@@ -483,16 +483,16 @@
this.environment.getApi().abort(); this.environment.getApi().abort();
}, },
"send":function(){ "send":function(){
var url = this.environment.getUrl(), data = this.environment.getData(),dataUrl = ""; var url = this.environment.getUrl(), data = this.environment.getData(),dataUrl = "";
for (var key in data) for (var key in data)
dataUrl += "{0}={1}&".format(key, data[key]); dataUrl += "{0}={1}&".format(key, data[key]);
if (this.environment.getType()=="GET") if (this.environment.getType()=="GET")
url += (url.search("\\?")==-1?"?":"&")+"{0}".format(dataUrl); url += (url.search("\\?")==-1?"?":"&")+"{0}".format(dataUrl);
this.environment.getApi().open(this.environment.getType(),url,this.environment.getAsync()); this.environment.getApi().open(this.environment.getType(),url,this.environment.getAsync());
for(var key in this.environment.getHeader()) for(var key in this.environment.getHeader())
this.environment.getApi().setRequestHeader(key,this.environment.getHeader()[key]); this.environment.getApi().setRequestHeader(key,this.environment.getHeader()[key]);
...@@ -535,11 +535,11 @@ ...@@ -535,11 +535,11 @@
} }
}; };
pi.xhr = pi.xhr.build(); pi.xhr = pi.xhr.build();
/* /*
* xml.xhr.get * xml.xhr.get
*/ */
pi.xhr.get = function(_url,_returnPiObject){ pi.xhr.get = function(_url,_returnPiObject){
var request = new pi.xhr(); var request = new pi.xhr();
request.environment.setAsync(false); request.environment.setAsync(false);
...@@ -547,26 +547,26 @@ ...@@ -547,26 +547,26 @@
request.send(); request.send();
return _returnPiObject?request:request.environment.getApi(); return _returnPiObject?request:request.environment.getApi();
}; };
/* /*
* pi.xpath * pi.xpath
*/ */
pi.xpath = function(_expression,_resultType,_contextNode,_namespaceResolver,_result){ pi.xpath = function(_expression,_resultType,_contextNode,_namespaceResolver,_result){
var contextNode = _contextNode||document, var contextNode = _contextNode||document,
expression = _expression||"", expression = _expression||"",
namespaceResolver = _namespaceResolver||null, namespaceResolver = _namespaceResolver||null,
result=_result||null, result=_result||null,
resultType=_resultType||"ANY_TYPE"; resultType=_resultType||"ANY_TYPE";
return document.evaluate(expression, contextNode, namespaceResolver, XPathResult[resultType], result); return document.evaluate(expression, contextNode, namespaceResolver, XPathResult[resultType], result);
}; };
Array.prototype.clone = function(){ Array.prototype.clone = function(){
var tmp = []; var tmp = [];
Array.prototype.push.apply(tmp,this); Array.prototype.push.apply(tmp,this);
tmp.forEach(function(item,index,object){ tmp.forEach(function(item,index,object){
if(item instanceof Array) if(item instanceof Array)
object[index] = object[index].clone(); object[index] = object[index].clone();
}); });
return tmp; return tmp;
}; };
...@@ -577,16 +577,16 @@ ...@@ -577,16 +577,16 @@
}); });
return count; return count;
}; };
Array.prototype.forEach = Array.prototype.forEach||function(_function){ Array.prototype.forEach = Array.prototype.forEach||function(_function){
for(var i=0; i<this.length; i++) for(var i=0; i<this.length; i++)
_function.apply(this,[this[i],i,this]); _function.apply(this,[this[i],i,this]);
}; };
Array.prototype.getLastItem = function(){ Array.prototype.getLastItem = function(){
return this[this.length-1]; return this[this.length-1];
}; };
Array.prototype.indexOf = Array.prototype.indexOf||function(_value){ Array.prototype.indexOf = Array.prototype.indexOf||function(_value){
var index = -1; var index = -1;
for(var i=0; i<this.length; i++) for(var i=0; i<this.length; i++)
...@@ -596,13 +596,13 @@ ...@@ -596,13 +596,13 @@
} }
return index; return index;
}; };
Array.prototype.remove = function(_index){ Array.prototype.remove = function(_index){
var array = this.slice(0,_index); var array = this.slice(0,_index);
Array.prototype.push.apply(array,this.slice(_index+1)); Array.prototype.push.apply(array,this.slice(_index+1));
return array; return array;
}; };
Array.prototype.removeValue = function(_value){ Array.prototype.removeValue = function(_value){
return this.remove(this.indexOf(_value)); return this.remove(this.indexOf(_value));
}; };
...@@ -627,9 +627,9 @@ ...@@ -627,9 +627,9 @@
}; };
Number.prototype.range = function(_pattern){ Number.prototype.range = function(_pattern){
for( for(
var value = String(this), isFloat = /\./i.test(value), var value = String(this), isFloat = /\./i.test(value),
i = isFloat.toggle(parseInt(value.split(".")[0]),0), i = isFloat.toggle(parseInt(value.split(".")[0]),0),
end = parseInt(value.split(".")[isFloat.toggle(1,0)]), end = parseInt(value.split(".")[isFloat.toggle(1,0)]),
array = []; i<end; i++ array = []; i<end; i++
){ ){
array.push( array.push(
...@@ -649,7 +649,7 @@ ...@@ -649,7 +649,7 @@
return values[arguments[1]]; return values[arguments[1]];
}); });
}; };
String.prototype.leftpad = function(_len,_ch){ String.prototype.leftpad = function(_len,_ch){
var str=this; var str=this;
var ch = Boolean(_ch)==false?" ":_ch; var ch = Boolean(_ch)==false?" ":_ch;
...@@ -657,18 +657,18 @@ ...@@ -657,18 +657,18 @@
str=ch+str; str=ch+str;
return str; return str;
}; };
String.prototype.toggle = function(_value,_other){ String.prototype.toggle = function(_value,_other){
return this==_value?_value:_other; return this==_value?_value:_other;
}; };
String.prototype.unicode = function(){ String.prototype.unicode = function(){
var str="", obj = this.split(""); var str="", obj = this.split("");
for(var i=obj.length-1; i>=0; i--) for(var i=obj.length-1; i>=0; i--)
str="\\u{0}{1}".format(String(obj[i].charCodeAt(0).base(16)).leftpad(4,"0"),str); str="\\u{0}{1}".format(String(obj[i].charCodeAt(0).base(16)).leftpad(4,"0"),str);
return str; return str;
}; };
pi.util.AddEvent( pi.util.AddEvent(
pi.env.ie?window:document, pi.env.ie?window:document,
pi.env.ie?"load":"DOMContentLoaded", pi.env.ie?"load":"DOMContentLoaded",
...@@ -678,5 +678,5 @@ ...@@ -678,5 +678,5 @@
} }
} }
); );
})(window); })(window);
\ No newline at end of file
// Global Variables // Global Variables
var rowname = new Array(99); var rowname = new Array(99);
var rowtype = new Array(99); var rowtype = new Array(99);
var newrow = new Array(99); var newrow = new Array(99);
var rowsize = new Array(99); var rowsize = new Array(99);
// Global variables. Set to javascript code // Global variables. Set to javascript code
// that will be eval() after change, add & delete. // that will be eval() after change, add & delete.
var rowhelper_onChange = ''; var rowhelper_onChange = '';
var rowhelper_onAdd = ''; var rowhelper_onAdd = '';
var rowhelper_onDelete = ''; var rowhelper_onDelete = '';
...@@ -63,7 +63,7 @@ var addRowTo = (function() { ...@@ -63,7 +63,7 @@ var addRowTo = (function() {
td.innerHTML = '<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/' + theme + '/images/icons/icon_x.gif" /></a>'; td.innerHTML = '<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/' + theme + '/images/icons/icon_x.gif" /></a>';
tr.appendChild(td); tr.appendChild(td);
tbody.appendChild(tr); tbody.appendChild(tr);
if(rowhelper_onAdd != '') if(rowhelper_onAdd != '')
eval(rowhelper_onAdd); eval(rowhelper_onAdd);
if($(tr).ipv4v6ify) if($(tr).ipv4v6ify)
$(tr).ipv4v6ify(); $(tr).ipv4v6ify();
...@@ -79,7 +79,7 @@ function removeRow(el) { ...@@ -79,7 +79,7 @@ function removeRow(el) {
cel = el.getElementsByTagName("td").item(0); cel = el.getElementsByTagName("td").item(0);
el.parentNode.removeChild(el); el.parentNode.removeChild(el);
} }
if(rowhelper_onDelete != '') if(rowhelper_onDelete != '')
eval(rowhelper_onDelete); eval(rowhelper_onDelete);
} }
......
...@@ -36,9 +36,9 @@ function fr_insline(id, on, prefix) { ...@@ -36,9 +36,9 @@ function fr_insline(id, on, prefix) {
prevrow = document.getElementById(prefix + 'header'); prevrow = document.getElementById(prefix + 'header');
} }
var cells = row.getElementsByTagName("td"); var cells = row.getElementsByTagName("td");
var prevcells = prevrow.getElementsByTagName("td"); var prevcells = prevrow.getElementsByTagName("td");
for (i = 0; i <= prevcells.length - 1; i++) { for (i = 0; i <= prevcells.length - 1; i++) {
if (prevcells[i].id == prefix + 'd' + (id-1)) { if (prevcells[i].id == prefix + 'd' + (id-1)) {
if (on) { if (on) {
......
...@@ -133,4 +133,4 @@ var Builder = { ...@@ -133,4 +133,4 @@ var Builder = {
}; };
}); });
} }
}; };
\ No newline at end of file
...@@ -962,4 +962,4 @@ Form.Element.DelayedObserver = Class.create({ ...@@ -962,4 +962,4 @@ Form.Element.DelayedObserver = Class.create({
this.timer = null; this.timer = null;
this.callback(this.element, $F(this.element)); this.callback(this.element, $F(this.element));
} }
}); });
\ No newline at end of file
...@@ -971,4 +971,4 @@ Element.findChildren = function(element, only, recursive, tagName) { ...@@ -971,4 +971,4 @@ Element.findChildren = function(element, only, recursive, tagName) {
Element.offsetSize = function (element, type) { Element.offsetSize = function (element, type) {
return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')];
}; };
\ No newline at end of file
...@@ -150,7 +150,7 @@ var Effect = { ...@@ -150,7 +150,7 @@ var Effect = {
toggle: function(element, effect, options) { toggle: function(element, effect, options) {
element = $(element); element = $(element);
effect = (effect || 'appear').toLowerCase(); effect = (effect || 'appear').toLowerCase();
return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({ return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 } queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, options || {})); }, options || {}));
...@@ -1120,4 +1120,4 @@ $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTex ...@@ -1120,4 +1120,4 @@ $w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTex
function(f) { Effect.Methods[f] = Element[f]; } function(f) { Effect.Methods[f] = Element[f]; }
); );
Element.addMethods(Effect.Methods); Element.addMethods(Effect.Methods);
\ No newline at end of file
...@@ -65,4 +65,4 @@ var Scriptaculous = { ...@@ -65,4 +65,4 @@ var Scriptaculous = {
} }
}; };
Scriptaculous.load(); Scriptaculous.load();
\ No newline at end of file
...@@ -272,4 +272,4 @@ Control.Slider = Class.create({ ...@@ -272,4 +272,4 @@ Control.Slider = Class.create({
this.options.onChange(this.values.length>1 ? this.values : this.value, this); this.options.onChange(this.values.length>1 ? this.values : this.value, this);
this.event = null; this.event = null;
} }
}); });
\ No newline at end of file
...@@ -56,4 +56,4 @@ if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){ ...@@ -56,4 +56,4 @@ if(Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0){
Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'); Sound.template = new Template('<embed type="audio/x-pn-realaudio-plugin" style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>');
else else
Sound.play = function(){}; Sound.play = function(){};
} }
\ No newline at end of file
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
version 2 version 2
7th April 2007 7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
Instructions: Instructions:
Download this file Download this file
Add <script src="sorttable.js"></script> to your HTML Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable Add class="sortable" to any table you'd like to make sortable
Click on the headers to sort Click on the headers to sort
Thanks to many, many people for contributions and suggestions. Thanks to many, many people for contributions and suggestions.
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
This basically means: do what you want with it. This basically means: do what you want with it.
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
2012-11-05 Allow sorting of IP:Port and *:port texts toghether also AAA_23 AAA_123 in 'numeric order' (used in Diagnostics\Sockets column LOCAL) 2012-11-05 Allow sorting of IP:Port and *:port texts toghether also AAA_23 AAA_123 in 'numeric order' (used in Diagnostics\Sockets column LOCAL)
*/ */
var stIsIE = /*@cc_on!@*/false; var stIsIE = /*@cc_on!@*/false;
sorttable = { sorttable = {
...@@ -33,19 +33,19 @@ sorttable = { ...@@ -33,19 +33,19 @@ sorttable = {
arguments.callee.done = true; arguments.callee.done = true;
// kill the timer // kill the timer
if (_timer) clearInterval(_timer); if (_timer) clearInterval(_timer);
if (!document.createElement || !document.getElementsByTagName) return; if (!document.createElement || !document.getElementsByTagName) return;
sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
forEach(document.getElementsByTagName('table'), function(table) { forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) { if (table.className.search(/\bsortable\b/) != -1) {
sorttable.makeSortable(table); sorttable.makeSortable(table);
} }
}); });
}, },
makeSortable: function(table) { makeSortable: function(table) {
if (table.getElementsByTagName('thead').length == 0) { if (table.getElementsByTagName('thead').length == 0) {
// table doesn't have a tHead. Since it should have, create one and // table doesn't have a tHead. Since it should have, create one and
...@@ -56,12 +56,12 @@ sorttable = { ...@@ -56,12 +56,12 @@ sorttable = {
} }
// Safari doesn't support table.tHead, sigh // Safari doesn't support table.tHead, sigh
if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
headrow = undefined; headrow = undefined;
if (table.tHead.rows.length == 1) if (table.tHead.rows.length == 1)
headrow = table.tHead.rows[0].cells; headrow = table.tHead.rows[0].cells;
else else
{ {
//if multiple rows are found one must be marked with class <tr class="sortableHeaderRowIdentifier"> //if multiple rows are found one must be marked with class <tr class="sortableHeaderRowIdentifier">
for (var i=0; i<table.tHead.rows.length; i++) { for (var i=0; i<table.tHead.rows.length; i++) {
if (table.tHead.rows[i].className.search(/\bsortableHeaderRowIdentifier\b/) != -1) if (table.tHead.rows[i].className.search(/\bsortableHeaderRowIdentifier\b/) != -1)
...@@ -73,12 +73,12 @@ sorttable = { ...@@ -73,12 +73,12 @@ sorttable = {
} }
if (headrow == undefined) if (headrow == undefined)
return; return;
if (table.getAttribute("sortableMultirow") != undefined) if (table.getAttribute("sortableMultirow") != undefined)
sortableMultirow = parseInt(table.getAttribute("sortableMultirow")); sortableMultirow = parseInt(table.getAttribute("sortableMultirow"));
else else
sortableMultirow = 1; sortableMultirow = 1;
// Sorttable v1 put rows with a class of "sortbottom" at the bottom (as // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
// "total" rows, for example). This is B&R, since what you're supposed // "total" rows, for example). This is B&R, since what you're supposed
// to do is put them in a tfoot. So, if there are sortbottom rows, // to do is put them in a tfoot. So, if there are sortbottom rows,
...@@ -100,7 +100,7 @@ sorttable = { ...@@ -100,7 +100,7 @@ sorttable = {
} }
delete sortbottomrows; delete sortbottomrows;
} }
// work through each column and calculate its type // work through each column and calculate its type
for (var i=0; i<headrow.length; i++) { for (var i=0; i<headrow.length; i++) {
// manually override the type with a sorttable_type attribute // manually override the type with a sorttable_type attribute
...@@ -118,7 +118,7 @@ sorttable = { ...@@ -118,7 +118,7 @@ sorttable = {
dean_addEvent(headrow[i],"click", function(e) { dean_addEvent(headrow[i],"click", function(e) {
if (this.className.search(/\bsorttable_sorted\b/) != -1) { if (this.className.search(/\bsorttable_sorted\b/) != -1) {
// if we're already sorted by this column, just // if we're already sorted by this column, just
// reverse the table, which is quicker // reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody, sortableMultirow); sorttable.reverse(this.sorttable_tbody, sortableMultirow);
this.className = this.className.replace('sorttable_sorted', this.className = this.className.replace('sorttable_sorted',
...@@ -131,7 +131,7 @@ sorttable = { ...@@ -131,7 +131,7 @@ sorttable = {
return; return;
} }
if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
// if we're already sorted by this column in reverse, just // if we're already sorted by this column in reverse, just
// re-reverse the table, which is quicker // re-reverse the table, which is quicker
sorttable.reverse(this.sorttable_tbody, sortableMultirow); sorttable.reverse(this.sorttable_tbody, sortableMultirow);
this.className = this.className.replace('sorttable_sorted_reverse', this.className = this.className.replace('sorttable_sorted_reverse',
...@@ -143,7 +143,7 @@ sorttable = { ...@@ -143,7 +143,7 @@ sorttable = {
this.appendChild(sortfwdind); this.appendChild(sortfwdind);
return; return;
} }
// remove sorttable_sorted classes // remove sorttable_sorted classes
theadrow = this.parentNode; theadrow = this.parentNode;
forEach(theadrow.childNodes, function(cell) { forEach(theadrow.childNodes, function(cell) {
...@@ -156,7 +156,7 @@ sorttable = { ...@@ -156,7 +156,7 @@ sorttable = {
if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
sortrevind = document.getElementById('sorttable_sortrevind'); sortrevind = document.getElementById('sorttable_sortrevind');
if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
this.className += ' sorttable_sorted'; this.className += ' sorttable_sorted';
sortfwdind = document.createElement('span'); sortfwdind = document.createElement('span');
sortfwdind.id = "sorttable_sortfwdind"; sortfwdind.id = "sorttable_sortfwdind";
...@@ -181,7 +181,7 @@ sorttable = { ...@@ -181,7 +181,7 @@ sorttable = {
//sorttable.shaker_sort(row_array, this.sorttable_sortfunction); //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
/* and comment out this one */ /* and comment out this one */
row_array.sort(this.sorttable_sortfunction); row_array.sort(this.sorttable_sortfunction);
tb = this.sorttable_tbody; tb = this.sorttable_tbody;
for (var j=0; j<row_array.length; j++) { for (var j=0; j<row_array.length; j++) {
for(var k=0; k<sortableMultirow; k++) { for(var k=0; k<sortableMultirow; k++) {
...@@ -194,26 +194,26 @@ sorttable = { ...@@ -194,26 +194,26 @@ sorttable = {
tb.appendChild(row); tb.appendChild(row);
} }
} }
delete row_array; delete row_array;
}); });
} }
} }
}, },
guessType: function(table, column, sortableMultirow) { guessType: function(table, column, sortableMultirow) {
// guess the type of a column based on its first non-blank row // guess the type of a column based on its first non-blank row
sortfn = sorttable.sort_alpha; sortfn = sorttable.sort_alpha;
for (var i=0; i<table.tBodies[0].rows.length; i+=sortableMultirow) { for (var i=0; i<table.tBodies[0].rows.length; i+=sortableMultirow) {
text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]); text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
if (text != '') { if (text != '') {
if (text.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\:[0-9]{1,5})?\b/)) { if (text.match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\:[0-9]{1,5})?\b/)) {
return sorttable.sort_ipaddr; return sorttable.sort_ipaddr;
} }
if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) { if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
return sorttable.sort_numeric; return sorttable.sort_numeric;
} }
// check for a date: dd/mm/yyyy or dd/mm/yy // check for a date: dd/mm/yyyy or dd/mm/yy
// can have / or . or - as separator // can have / or . or - as separator
// can be mm/dd as well // can be mm/dd as well
possdate = text.match(sorttable.DATE_RE); possdate = text.match(sorttable.DATE_RE);
...@@ -236,17 +236,17 @@ sorttable = { ...@@ -236,17 +236,17 @@ sorttable = {
} }
return sortfn; return sortfn;
}, },
getInnerText: function(node) { getInnerText: function(node) {
// gets the text we want to use for sorting for a cell. // gets the text we want to use for sorting for a cell.
// strips leading and trailing whitespace. // strips leading and trailing whitespace.
// this is *not* a generic getInnerText function; it's special to sorttable. // this is *not* a generic getInnerText function; it's special to sorttable.
// for example, you can override the cell text with a customkey attribute. // for example, you can override the cell text with a customkey attribute.
// it also gets .value for <input> fields. // it also gets .value for <input> fields.
hasInputs = (typeof node.getElementsByTagName == 'function') && hasInputs = (typeof node.getElementsByTagName == 'function') &&
node.getElementsByTagName('input').length; node.getElementsByTagName('input').length;
if (node.getAttribute("sorttable_customkey") != null) { if (node.getAttribute("sorttable_customkey") != null) {
return node.getAttribute("sorttable_customkey"); return node.getAttribute("sorttable_customkey");
} }
...@@ -281,7 +281,7 @@ sorttable = { ...@@ -281,7 +281,7 @@ sorttable = {
} }
} }
}, },
reverse: function(tbody, sortableMultirow) { reverse: function(tbody, sortableMultirow) {
// reverse the rows in a tbody // reverse the rows in a tbody
newrows = []; newrows = [];
...@@ -296,14 +296,14 @@ sorttable = { ...@@ -296,14 +296,14 @@ sorttable = {
} }
delete newrows; delete newrows;
}, },
/* sort functions /* sort functions
each sort function takes two parameters, a and b each sort function takes two parameters, a and b
you are comparing a[0] and b[0] */ you are comparing a[0] and b[0] */
sort_numeric: function(a,b) { sort_numeric: function(a,b) {
aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
if (isNaN(aa)) aa = 0; if (isNaN(aa)) aa = 0;
bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
if (isNaN(bb)) bb = 0; if (isNaN(bb)) bb = 0;
return aa-bb; return aa-bb;
}, },
...@@ -344,7 +344,7 @@ sorttable = { ...@@ -344,7 +344,7 @@ sorttable = {
}, },
sortWithNumber: function(a,b) { sortWithNumber: function(a,b) {
amatch = a[0].match(/.*?(?=[0-9])/); amatch = a[0].match(/.*?(?=[0-9])/);
bmatch = b[0].match(/.*?(?=[0-9])/); bmatch = b[0].match(/.*?(?=[0-9])/);
if (amatch && bmatch && amatch[0] == bmatch[0]) if (amatch && bmatch && amatch[0] == bmatch[0])
{ {
anumber = a[0].substring(amatch.length+1); anumber = a[0].substring(amatch.length+1);
...@@ -370,12 +370,12 @@ sorttable = { ...@@ -370,12 +370,12 @@ sorttable = {
if (aip !== false || bip !== false) if (aip !== false || bip !== false)
return aip === false ? -1 : 1; return aip === false ? -1 : 1;
else else
{ {
return sorttable.sortWithNumber(a,b); return sorttable.sortWithNumber(a,b);
} }
} }
}, },
shaker_sort: function(list, comp_func) { shaker_sort: function(list, comp_func) {
// A stable sort function to allow multi-level sorting of data // A stable sort function to allow multi-level sorting of data
// see: http://en.wikipedia.org/wiki/Cocktail_sort // see: http://en.wikipedia.org/wiki/Cocktail_sort
...@@ -405,7 +405,7 @@ sorttable = { ...@@ -405,7 +405,7 @@ sorttable = {
b++; b++;
} // while(swap) } // while(swap)
} }
}; };
/* ****************************************************************** /* ******************************************************************
...@@ -581,4 +581,3 @@ var forEach = function(object, block, context) { ...@@ -581,4 +581,3 @@ var forEach = function(object, block, context) {
resolve.forEach(object, block, context); resolve.forEach(object, block, context);
} }
}; };
...@@ -9,7 +9,7 @@ function StateSuggestions(text) { ...@@ -9,7 +9,7 @@ function StateSuggestions(text) {
} }
/** /**
* Request suggestions for the given autosuggest control. * Request suggestions for the given autosuggest control.
* @scope protected * @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for. * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/ */
...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /* ...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
var aSuggestions = []; var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value; var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){ if (sTextboxValue.length > 0){
//search for matching states //search for matching states
for (var i=0; i < this.states.length; i++) { for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) { if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]); aSuggestions.push(this.states[i]);
} }
} }
} }
......
...@@ -59,4 +59,4 @@ function alias_popup(alias_id,theme,loading) { ...@@ -59,4 +59,4 @@ function alias_popup(alias_id,theme,loading) {
domTT_update('ttalias_'+alias_id,'<div>'+response.match(/<h1>.*<\/table>/i)+'<div>'); domTT_update('ttalias_'+alias_id,'<div>'+response.match(/<h1>.*<\/table>/i)+'<div>');
} }
}); });
} }
\ No newline at end of file
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
* @class * @class
* @scope public * @scope public
*/ */
function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
oProvider /*:SuggestionProvider*/) { oProvider /*:SuggestionProvider*/) {
/** /**
* The currently selected suggestions. * The currently selected suggestions.
* @scope private * @scope private
*/ */
this.cur /*:int*/ = -1; this.cur /*:int*/ = -1;
/** /**
...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -18,22 +18,22 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
* @scope private * @scope private
*/ */
this.layer = null; this.layer = null;
/** /**
* Suggestion provider for the autosuggest feature. * Suggestion provider for the autosuggest feature.
* @scope private. * @scope private.
*/ */
this.provider /*:SuggestionProvider*/ = oProvider; this.provider /*:SuggestionProvider*/ = oProvider;
/** /**
* The textbox to capture. * The textbox to capture.
* @scope private * @scope private
*/ */
this.textbox /*:HTMLInputElement*/ = oTextbox; this.textbox /*:HTMLInputElement*/ = oTextbox;
//initialize the control //initialize the control
this.init(); this.init();
} }
/** /**
...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/, ...@@ -45,13 +45,13 @@ function AutoSuggestControl(oTextbox /*:HTMLInputElement*/,
*/ */
AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/, AutoSuggestControl.prototype.autosuggest = function (aSuggestions /*:Array*/,
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
//make sure there's at least one suggestion //make sure there's at least one suggestion
if (aSuggestions.length > 0) { if (aSuggestions.length > 0) {
if (bTypeAhead) { if (bTypeAhead) {
this.typeAhead(aSuggestions[0]); this.typeAhead(aSuggestions[0]);
} }
this.showSuggestions(aSuggestions); this.showSuggestions(aSuggestions);
} else { } else {
this.hideSuggestions(); this.hideSuggestions();
...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -71,11 +71,11 @@ AutoSuggestControl.prototype.createDropDown = function () {
this.layer.className = "suggestions"; this.layer.className = "suggestions";
this.layer.style.visibility = "hidden"; this.layer.style.visibility = "hidden";
this.layer.style.width = this.textbox.offsetWidth; this.layer.style.width = this.textbox.offsetWidth;
//when the user clicks on the a suggestion, get the text (innerHTML) //when the user clicks on the a suggestion, get the text (innerHTML)
//and place it into a textbox //and place it into a textbox
this.layer.onmousedown = this.layer.onmousedown =
this.layer.onmouseup = this.layer.onmouseup =
this.layer.onmouseover = function (oEvent) { this.layer.onmouseover = function (oEvent) {
oEvent = oEvent || window.event; oEvent = oEvent || window.event;
oTarget = oEvent.target || oEvent.srcElement; oTarget = oEvent.target || oEvent.srcElement;
...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () { ...@@ -89,8 +89,8 @@ AutoSuggestControl.prototype.createDropDown = function () {
oThis.textbox.focus(); oThis.textbox.focus();
} }
}; };
document.body.appendChild(this.layer); document.body.appendChild(this.layer);
}; };
...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ { ...@@ -103,12 +103,12 @@ AutoSuggestControl.prototype.getLeft = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iLeft = 0; var iLeft = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iLeft += oNode.offsetLeft; iLeft += oNode.offsetLeft;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iLeft; return iLeft;
}; };
...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ { ...@@ -121,12 +121,12 @@ AutoSuggestControl.prototype.getTop = function () /*:int*/ {
var oNode = this.textbox; var oNode = this.textbox;
var iTop = 0; var iTop = 0;
while(oNode.tagName != "BODY") { while(oNode.tagName != "BODY") {
iTop += oNode.offsetTop; iTop += oNode.offsetTop;
oNode = oNode.offsetParent; oNode = oNode.offsetParent;
} }
return iTop; return iTop;
}; };
...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) { ...@@ -141,7 +141,7 @@ AutoSuggestControl.prototype.handleKeyDown = function (oEvent /*:Event*/) {
case 38: //up arrow case 38: //up arrow
this.previousSuggestion(); this.previousSuggestion();
break; break;
case 40: //down arrow case 40: //down arrow
this.nextSuggestion(); this.nextSuggestion();
break; break;
case 13: //enter case 13: //enter
...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) { ...@@ -163,7 +163,7 @@ AutoSuggestControl.prototype.handleKeyUp = function (oEvent /*:Event*/) {
//for backspace (8) and delete (46), shows suggestions without typeahead //for backspace (8) and delete (46), shows suggestions without typeahead
if (iKeyCode == 8 || iKeyCode == 46) { if (iKeyCode == 8 || iKeyCode == 46) {
this.provider.requestSuggestions(this, false); this.provider.requestSuggestions(this, false);
//make sure not to interfere with non-character keys //make sure not to interfere with non-character keys
} else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) { } else if (iKeyCode < 32 || (iKeyCode >= 33 && iKeyCode < 46) || (iKeyCode >= 112 && iKeyCode <= 123)) {
//ignore //ignore
...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () { ...@@ -187,7 +187,7 @@ AutoSuggestControl.prototype.hideSuggestions = function () {
* @param oSuggestionNode The node representing a suggestion in the dropdown. * @param oSuggestionNode The node representing a suggestion in the dropdown.
*/ */
AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) { AutoSuggestControl.prototype.highlightSuggestion = function (oSuggestionNode) {
for (var i=0; i < this.layer.childNodes.length; i++) { for (var i=0; i < this.layer.childNodes.length; i++) {
var oNode = this.layer.childNodes[i]; var oNode = this.layer.childNodes[i];
if (oNode == oSuggestionNode) { if (oNode == oSuggestionNode) {
...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () { ...@@ -207,36 +207,36 @@ AutoSuggestControl.prototype.init = function () {
//save a reference to this object //save a reference to this object
var oThis = this; var oThis = this;
//assign the onkeyup event handler //assign the onkeyup event handler
this.textbox.onkeyup = function (oEvent) { this.textbox.onkeyup = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyUp() method with the event object //call the handleKeyUp() method with the event object
oThis.handleKeyUp(oEvent); oThis.handleKeyUp(oEvent);
}; };
//assign onkeydown event handler //assign onkeydown event handler
this.textbox.onkeydown = function (oEvent) { this.textbox.onkeydown = function (oEvent) {
//check for the proper location of the event object //check for the proper location of the event object
if (!oEvent) { if (!oEvent) {
oEvent = window.event; oEvent = window.event;
} }
//call the handleKeyDown() method with the event object //call the handleKeyDown() method with the event object
oThis.handleKeyDown(oEvent); oThis.handleKeyDown(oEvent);
}; };
//assign onblur event handler (hides suggestions) //assign onblur event handler (hides suggestions)
this.textbox.onblur = function () { this.textbox.onblur = function () {
oThis.hideSuggestions(); oThis.hideSuggestions();
}; };
//create the suggestions dropdown //create the suggestions dropdown
this.createDropDown(); this.createDropDown();
}; };
...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () { ...@@ -252,7 +252,7 @@ AutoSuggestControl.prototype.nextSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) { if (cSuggestionNodes.length > 0 && this.cur < cSuggestionNodes.length-1) {
var oNode = cSuggestionNodes[++this.cur]; var oNode = cSuggestionNodes[++this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () { ...@@ -267,7 +267,7 @@ AutoSuggestControl.prototype.previousSuggestion = function () {
if (cSuggestionNodes.length > 0 && this.cur > 0) { if (cSuggestionNodes.length > 0 && this.cur > 0) {
var oNode = cSuggestionNodes[--this.cur]; var oNode = cSuggestionNodes[--this.cur];
this.highlightSuggestion(oNode); this.highlightSuggestion(oNode);
this.textbox.value = oNode.firstChild.nodeValue; this.textbox.value = oNode.firstChild.nodeValue;
} }
}; };
...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -281,19 +281,19 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
//use text ranges for Internet Explorer //use text ranges for Internet Explorer
if (this.textbox.createTextRange) { if (this.textbox.createTextRange) {
var oRange = this.textbox.createTextRange(); var oRange = this.textbox.createTextRange();
oRange.moveStart("character", iStart); oRange.moveStart("character", iStart);
oRange.moveEnd("character", iLength - this.textbox.value.length); oRange.moveEnd("character", iLength - this.textbox.value.length);
oRange.select(); oRange.select();
//use setSelectionRange() for Mozilla //use setSelectionRange() for Mozilla
} else if (this.textbox.setSelectionRange) { } else if (this.textbox.setSelectionRange) {
this.textbox.setSelectionRange(iStart, iLength); this.textbox.setSelectionRange(iStart, iLength);
} }
//set focus back to the textbox //set focus back to the textbox
this.textbox.focus(); this.textbox.focus();
}; };
/** /**
* Builds the suggestion layer contents, moves it into position, * Builds the suggestion layer contents, moves it into position,
...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /* ...@@ -302,16 +302,16 @@ AutoSuggestControl.prototype.selectRange = function (iStart /*:int*/, iLength /*
* @param aSuggestions An array of suggestions for the control. * @param aSuggestions An array of suggestions for the control.
*/ */
AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) { AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/) {
var oDiv = null; var oDiv = null;
this.layer.innerHTML = ""; //clear contents of the layer this.layer.innerHTML = ""; //clear contents of the layer
for (var i=0; i < aSuggestions.length; i++) { for (var i=0; i < aSuggestions.length; i++) {
oDiv = document.createElement("div"); oDiv = document.createElement("div");
oDiv.appendChild(document.createTextNode(aSuggestions[i])); oDiv.appendChild(document.createTextNode(aSuggestions[i]));
this.layer.appendChild(oDiv); this.layer.appendChild(oDiv);
} }
this.layer.style.left = this.getLeft() + "px"; this.layer.style.left = this.getLeft() + "px";
this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px"; this.layer.style.top = (this.getTop()+this.textbox.offsetHeight) + "px";
this.layer.style.visibility = "visible"; this.layer.style.visibility = "visible";
...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/ ...@@ -319,7 +319,7 @@ AutoSuggestControl.prototype.showSuggestions = function (aSuggestions /*:Array*/
}; };
/** /**
* Inserts a suggestion into the textbox, highlighting the * Inserts a suggestion into the textbox, highlighting the
* suggested part of the text. * suggested part of the text.
* @scope private * @scope private
* @param sSuggestion The suggestion for the textbox. * @param sSuggestion The suggestion for the textbox.
...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) { ...@@ -328,9 +328,8 @@ AutoSuggestControl.prototype.typeAhead = function (sSuggestion /*:String*/) {
//check for support of typeahead functionality //check for support of typeahead functionality
if (this.textbox.createTextRange || this.textbox.setSelectionRange){ if (this.textbox.createTextRange || this.textbox.setSelectionRange){
var iLen = this.textbox.value.length; var iLen = this.textbox.value.length;
this.textbox.value = sSuggestion; this.textbox.value = sSuggestion;
this.selectRange(iLen, sSuggestion.length); this.selectRange(iLen, sSuggestion.length);
} }
}; };
...@@ -3,4 +3,4 @@ function kH(e) { ...@@ -3,4 +3,4 @@ function kH(e) {
return pK != 13; return pK != 13;
} }
document.onkeypress = kH; document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS); if (document.layers) document.captureEvents(Event.KEYPRESS);
\ No newline at end of file
...@@ -9,7 +9,7 @@ function StateSuggestions(text) { ...@@ -9,7 +9,7 @@ function StateSuggestions(text) {
} }
/** /**
* Request suggestions for the given autosuggest control. * Request suggestions for the given autosuggest control.
* @scope protected * @scope protected
* @param oAutoSuggestControl The autosuggest control to provide suggestions for. * @param oAutoSuggestControl The autosuggest control to provide suggestions for.
*/ */
...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /* ...@@ -17,14 +17,14 @@ StateSuggestions.prototype.requestSuggestions = function (oAutoSuggestControl /*
bTypeAhead /*:boolean*/) { bTypeAhead /*:boolean*/) {
var aSuggestions = []; var aSuggestions = [];
var sTextboxValue = oAutoSuggestControl.textbox.value; var sTextboxValue = oAutoSuggestControl.textbox.value;
if (sTextboxValue.length > 0){ if (sTextboxValue.length > 0){
//search for matching states //search for matching states
for (var i=0; i < this.states.length; i++) { for (var i=0; i < this.states.length; i++) {
if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) { if (this.states[i].toLowerCase().indexOf(sTextboxValue.toLowerCase()) == 0) {
aSuggestions.push(this.states[i]); aSuggestions.push(this.states[i]);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment