Type.registerNamespace('AjaxImageButtonNamespace'); AjaxImageButtonNamespace.MyCliImageButton = function(element) { this._hoverImageUrl = ''; this._originalImageUrl = ''; this._mouseOverHandler = null; this._mouseOutHandler = null; this._clickHandler = null; AjaxImageButtonNamespace.MyCliImageButton.initializeBase(this, [element]); } AjaxImageButtonNamespace.MyCliImageButton.prototype = { get_hoverImageUrl : function(){ return this._hoverImageUrl; }, set_hoverImageUrl : function(value) { var e = Function._validateParams(arguments, [{name: 'value', type: String}]); if (e) throw e; if (this._hoverImageUrl != value) { this._hoverImageUrl = value; this.raisePropertyChanged('hoverImageUrl'); } }, initialize : function(){ AjaxImageButtonNamespace.MyCliImageButton.callBaseMethod(this, 'initialize'); var target = this.get_element(); this._originalImageUrl = target.src; this._mouseOverHandler = Function.createDelegate(this, this._onMouseOver); this._mouseOutHandler = Function.createDelegate(this, this._onMouseOut); this._clickHandler = Function.createDelegate(this, this._onClick) $addHandlers(target, {'mouseover':this._mouseOverHandler, 'mouseout':this._mouseOutHandler, 'click': this._clickHandler}, this); }, dispose : function(){ $clearHandlers(this.get_element()); delete this._mouseOverHandler; delete this._mouseOutHandler; delete this._clickHandler; AjaxImageButtonNamespace.MyCliImageButton.callBaseMethod(this, 'dispose'); }, add_click : function(handler) { this.get_events().addHandler('click', handler); }, remove_click : function(handler) { this.get_events().removeHandler('click', handler); }, _onMouseOver : function(e) { e.target.src = this._hoverImageUrl; }, _onMouseOut : function(e) { e.target.src = this._originalImageUrl; }, _onClick : function(e) { e.preventDefault(); var handler = this.get_events().getHandler('click'); if (handler != null) { handler(this, Sys.EventArgs.Empty); } } } AjaxImageButtonNamespace.MyCliImageButton.registerClass ('AjaxImageButtonNamespace.MyCliImageButton', Sys.UI.Control); if (typeof(Sys) != 'undefined') Sys.Application.notifyScriptLoaded(); }
|