var wijmo;define(["./wijmo.wijutil","./wijmo.widget"],function(){var e=this.__extends||function(e,t){function r(){this.constructor=e}for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);r.prototype=t.prototype,e.prototype=new r};$.fn.extend({getBounds:function(){return $.extend({},$(this).offset(),{width:$(this).outerWidth(!0),height:$(this).outerHeight(!0)})},setBounds:function(e){return $(this).css({left:e.left,top:e.top}).width(e.width).height(e.height),this},getMaxZIndex:function(){var e=($(this).css("z-index")=="auto"?0:parseInt($(this).css("z-index")))*1;return $(this).siblings().each(function(t,n){e=Math.max(e,($(n).css("z-index")=="auto"?0:parseInt($(n).css("z-index")))*1)}),Math.max(e,$(this).zIndex())}}),function(t){(function(n){var r=function(t){function n(){t.apply(this,arguments)}return e(n,t),n.prototype._isDisabled=function(){var e=this.options;return e.disabledState===!0||e.disabled===!0},n.prototype._init=function(){this.elementZIndex=this.element.zIndex();if(!!this.options.ensureOutermost){var e=$("form");e.length===0&&(e=$(document.body)),this.element.appendTo(e)}this.element.data("visible.wijpopup",!1),this.element.css("position","absolute"),this.element.position({of:$(document.body)}),this.element.hide(),this._isDisabled()&&this.element.addClass(this.options.wijCSS.stateDisabled)},n.prototype._setOption=function(e,n){var r=this.options.disabled,i;t.prototype._setOption.call(this,e,n);if(e==="autoHide"){var s=this.isVisible();this.hide(),s&&this.show()}else if(e==="disabled"){i=this._isDisabled();if(r===i)return;this.element.toggleClass(this.options.wijCSS.stateDisabled,i)}},n.prototype.destroy=function(){t.prototype.destroy.call(this),this.isVisible()&&this.hide();if($.browser.msie&&parseInt($.browser.version)<7){var e=this.element.data("backframe.wijpopup");e||e.remove()}var n=this;this.element.unbind(".wijpopup"),$.each(["visible","backframe","animating","width"],function(e,t){n.element.removeData(t+".wijpopup")})},n.prototype.isVisible=function(){return!!this.element.data("visible.wijpopup")&&this.element.is(":visible")},n.prototype.isAnimating=function(){return!!this.element.data("animating.wijpopup")},n.prototype.show=function(e){var t=this;this._setPosition(e);if(this.isVisible())return;if(this._trigger("showing")===!1)return;this.options.autoHide&&window.setTimeout(function(){t._bindDocMouseUpEvent()},0);var n=this.options.showEffect||"show",r=this.options.showDuration||300,i=this.options.showOptions||{};this.element.data("animating.wijpopup",!0);if($.effects&&$.effects.effect[n])this.element.show(n,i,r,$.proxy(this._showCompleted,this));else{var s=this.element;s[n](n==="show"?null:r,$.proxy(this._showCompleted,this))}(!n||!r||n==="show"||r<=0)&&this._showCompleted()},n.prototype._showCompleted=function(){this.element.removeData("animating.wijpopup"),this.element.data("visible.wijpopup",!0),this._trigger("shown")},n.prototype.showAt=function(e,t){this.show({my:"left+"+e+" top+"+t,at:"left top",of:document.body})},n.prototype.hide=function(){var e=this;if(!this.isVisible())return;if(this._trigger("hiding")===!1){window.setTimeout(function(){e._bindDocMouseUpEvent()},0);return}var t=this.options.hideEffect||"hide",n=this.options.hideDuration||300,r=this.options.hideOptions||{};this.element.data("animating.wijpopup",!0);if($.effects&&$.effects.effect[t])this.element.hide(t,r,n,$.proxy(this._hideCompleted,this));else{var i=this.element;i[t](t==="hide"?null:n,$.proxy(this._hideCompleted,this))}(!t||!n||t==="hide"||n<=0)&&this._hideCompleted()},n.prototype._hideCompleted=function(){this.element.data("width.wijpopup")!==undefined&&(this.element.width(this.element.data("width.wijpopup")),this.element.removeData("width.wijpopup")),this.element.unbind("move.wijpopup"),this.element.removeData("animating.wijpopup");if($.browser.msie&&parseInt($.browser.version)<7){var e=this.element.data("backframe.wijpopup");e&&e.hide()}this._trigger("hidden")},n.prototype._onDocMouseUp=function(e,t){var n=e.target?e.target:e.srcElement;t.isVisible()&&!!t.options.autoHide&&(n!=t.element.get(0)&&$(n).parents().index(t.element)<0?t.hide():this._bindDocMouseUpEvent())},n.prototype._bindDocMouseUpEvent=function(){var e=this,t="";$.support.isTouchEnabled&&$.support.isTouchEnabled()&&(t="wij"),$(document).one(t+"mouseup.wijpopup",function(t){e._onDocMouseUp(t,e)})},n.prototype._onMove=function(e){var t=this.element.data("backframe.wijpopup");t&&(this.element.before(t),t.css({top:this.element.css("top"),left:this.element.css("left")}))},n.prototype._addBackgroundIFrame=function(){if($.browser.msie&&parseInt($.browser.version)<7){var e=this.element.data("backframe.wijpopup");e||(e=jQuery("<iframe/>").css({position:"absolute",display:"none",filter:"progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)"}).attr({src:"javascript:'<html></html>';",scrolling:"no",frameborder:"0","tabIndex ":-1}),this.element.before(e),this.element.data("backframe.wijpopup",e),this.element.bind("move.wijpopup",$.proxy(this._onMove,this))),e.setBounds(this.element.getBounds()),e.css({display:"block",left:this.element.css("left"),top:this.element.css("top"),"z-index":this.element.css("z-index")-1})}},n.prototype._setZIndex=function(e){this.element.css("z-index",e);var t=this.element.data("backframe.wijpopup");t&&t.css("z-index",this.element.css("z-index")-1)},n.prototype._setPosition=function(e){var t=this.element.is(":visible"),n;this.element.show(),this.element.position($.extend({},this.options.position,e?e:{})),t||this.element.hide(),e&&(n=e.of),n||(n=this.options.position.of),this._addBackgroundIFrame();var r=Math.max(1e3,this.elementZIndex);n&&(r=Math.max(r,$(n).getMaxZIndex())),this._setZIndex(r+10),this._trigger("posChanged")},n}(t.JQueryUIWidget);n.wijpopup=r;var i=function(){function e(){this.ensureOutermost=!1,this.showEffect="show",this.showOptions={},this.showDuration=300,this.hideEffect="hide",this.hideOptions={},this.hideDuration=100,this.autoHide=!1,this.position={at:"left bottom",my:"left top"},this.showing=null,this.shown=null,this.hiding=null,this.hidden=null,this.posChanged=null}return e}();r.prototype.options=$.extend(!0,{},t.wijmoWidget.prototype.options,new i),$.wijmo.registerWidget("wijpopup",r.prototype)})(t.popup||(t.popup={}));var n=t.popup}(wijmo||(wijmo={}))});