Type.registerNamespace("Microsoft.UpdateServices.Catalog.UI");
Microsoft.UpdateServices.Catalog.UI.MasterPageContext = function(basketForm)
{
this._basketForm = basketForm;
this.initialize = function()
{
}
this.get_basketForm = function()
{
return this._basketForm;
}
}
Microsoft.UpdateServices.Catalog.UI.MasterPageContext.registerClass("Microsoft.UpdateServices.Catalog.UI.MasterPageContext");
Microsoft.UpdateServices.Catalog.UI.SearchTextBox = function(searchElement, defaultText, initialText, searchLink, defaultTextClass, normalTextClass)
{
var _defaultText = defaultText;
var _initialText = initialText;
var _defaultTextClass = defaultTextClass;
var _normalTextClass = normalTextClass;
var _baseTextClass;
var _blurDelegate;
var _focusDelegate;
var _keyDownDelegate;
var _searchLink = searchLink;
var _instance = this;
if(typeof(searchElement) == 'undefined' || searchElement == null)
{
throw new Microsoft.UpdateServices.Catalog.Exception(
'Microsoft.UpdateServices.Catalog.UI.SearchTextBox requires that a valid element be supplied for the searchElement argument',
Microsoft.UpdateServices.Catalog.Constants.ErrorArgumentInvalid);
}
Microsoft.UpdateServices.Catalog.UI.SearchTextBox.initializeBase(this, [searchElement]);
this.get_defaultText = function()
{
return _defaultText;
}
this.set_defaultText = function(value)
{
if(value != _defaultText)
{
_defaultText = value;
this.raisePropertyChanged('defaultText');
}
}
this.get_initialText = function()
{
return _initialText;
}
this.set_initialText = function(value)
{
if(value != _initialText)
{
_initialText = value;
this.raisePropertyChanged('initialText');
}
}
this.set_text = function(value) {
if (this.get_element().value != value) {
this.get_element().value = value;
this.raisePropertyChanged('text');
}
}
this.get_text = function() {
return this.get_element().value;
}
this.get_defaultTextClass = function()
{
return _defaultTextClass;
}
this.set_defaultTextClass = function(value)
{
if(value != _defaultTextClass)
{
_defaultTextClass = value;
this.raisePropertyChanged('defaultTextClass');
}
}
this.get_normalTextClass = function()
{
return _normalTextClass;
}
this.set_normalTextClass = function(value)
{
if(value != _normalTextClass)
{
_normalTextClass = value;
this.raisePropertyChanged('_normalTextClass');
}
}
this.get_searchText = function()
{
var defaultText = this.get_defaultText();
var currentText = this.get_text();
var searchText = '';
if(currentText != defaultText)
{
searchText = currentText;
}
return searchText;
}
this.initialize = function()
{
Microsoft.UpdateServices.Catalog.UI.SearchTextBox.callBaseMethod(this, 'initialize');
var searchTextBox = this.get_element();
_blurDelegate = Function.createDelegate(this, this.showDefaultText);
searchTextBox.attachEvent('onblur', _blurDelegate);
_focusDelegate = Function.createDelegate(this, this.hideDefaultText);
searchTextBox.attachEvent('onfocus', _focusDelegate);
_keyDownDelegate = Function.createDelegate(this, this.enterKeyCapture);
searchTextBox.attachEvent('onkeydown', _keyDownDelegate);
_baseTextClass = (this.get_element()).className;
this.set_text(_initialText);
this.showDefaultText();
}
this.dispose = function()
{
var searchTextBox = this.get_element();
searchTextBox.detachEvent('onblur', _blurDelegate);
searchTextBox.detachEvent('onfocus', _focusDelegate);
searchTextBox.detachEvent('onkeydown', _keyDownDelegate);
Microsoft.UpdateServices.Catalog.UI.SearchTextBox.callBaseMethod(this, 'dispose');
}
this.getDescriptor = function() {
var td = Microsoft.UpdateServices.Catalog.UI.SearchTextBox.callBaseMethod(this, 'getDescriptor');
td.addProperty('defaultText', String);
td.addProperty('initialText', String);
td.addProperty('defaultTextClass', String);
td.addProperty('normalTextClass', String);
td.addProperty('searchText', String);
return td;
}
this.hideDefaultText = function()
{
var defaultText = this.get_defaultText();
if(typeof(defaultText) != 'undefined'
&& defaultText != null)
{
if(this.get_text() == defaultText)
{
this.set_text('');
this.get_element().className=_baseTextClass + ' ' + this.get_normalTextClass();
}
}
}
this.enterKeyCapture = function()
{
if(event.keyCode == Microsoft.UpdateServices.Catalog.Constants.EnterButtonKeyCode)
{
_searchLink.click();
}
}
this.showDefaultText = function()
{
var defaultText = this.get_defaultText();
if(typeof(defaultText) != 'undefined'
&& defaultText != null)
{
var currentText = _instance.get_text();
if(currentText == '' || currentText == defaultText)
{
this.get_element().className=_baseTextClass + ' ' + this.get_defaultTextClass();
this.set_text(defaultText);
}
}
}
}
Microsoft.UpdateServices.Catalog.UI.SearchTextBox.registerClass("Microsoft.UpdateServices.Catalog.UI.SearchTextBox", Sys.UI.Control);
