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