aboutsummaryrefslogtreecommitdiff
path: root/simpleSigning/src/main/resources/js/jquery.modalDialog.js
diff options
context:
space:
mode:
Diffstat (limited to 'simpleSigning/src/main/resources/js/jquery.modalDialog.js')
-rw-r--r--simpleSigning/src/main/resources/js/jquery.modalDialog.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/simpleSigning/src/main/resources/js/jquery.modalDialog.js b/simpleSigning/src/main/resources/js/jquery.modalDialog.js
new file mode 100644
index 0000000..fde5f4b
--- /dev/null
+++ b/simpleSigning/src/main/resources/js/jquery.modalDialog.js
@@ -0,0 +1,4 @@
+/*! skinny.js v0.1.0 | Copyright 2013 Vistaprint | vistaprint.github.io/SkinnyJS/LICENSE
+http://vistaprint.github.io/SkinnyJS/download-builder.html?modules=jquery.modalDialog*/
+
+!function(a){a.modalDialog=a.modalDialog||{};var b,c=a.modalDialog._ua=function(){var a=navigator.userAgent;return a.indexOf("MSIE 7.0")>0?{ie:!0,ie7:!0,version:7,compat:a.indexOf("compatible")>0}:a.indexOf("MSIE 8.0")>0?{ie:!0,ie8:!0,version:8,compat:a.indexOf("compatible")>0}:{}}();a.modalDialog.setSmallScreen=function(a){b=a},a.modalDialog.isSmallScreen=function(){if("undefined"!=typeof b)return b;if(c.ie7||c.ie8)return!1;var d=a(window).width();return("number"==typeof window.orientation?Math.min(d,a(window).height()):d)<=480}}(jQuery),function(a){var b="data-dialog-",c=function(a){if(Object.keys)return Object.keys(a);var b=[];for(var c in a)a.hasOwnProperty(c)&&(b[b.length]=c);return b},d=function(a){return""===a?a:a||null},e=function(a){if(a)switch(a=a.toString().toLowerCase()){case"true":case"yes":case"1":return!0}return!1},f=function(a){return a?new Function("event",a):null},g={title:d,onopen:f,onbeforeopen:f,onclose:f,onbeforeclose:f,maxWidth:parseInt,initialHeight:parseInt,ajax:e,onajaxerror:f,destroyOnClose:e,skin:d,enableHistory:e,zIndex:parseInt};a.modalDialog=a.modalDialog||{},a.modalDialog.getSettings=function(d){var e={};return a.each(c(g),function(a,c){var f=d.attr(b+c);if("undefined"!=typeof f){var h=g[c];e[c]=h(f)}}),e}}(jQuery),function(a){if(a.modalDialog&&a.modalDialog._isContent)throw new Error("Attempt to load jquery.modalDialogContent.js in the same window as jquery.modalDialog.js.");var b=10,c="-700px",d=[],e={};a.modalDialog.defaults={zIndex:1e4,title:"",maxWidth:600,initialHeight:100,skin:"primary",ajax:!1,url:null,content:null,destroyOnClose:!1,containerElement:"body",preventEventBubbling:!1,enableHistory:!0,onopen:null,onclose:null,onbeforeopen:null,onbeforeclose:null,onajaxerror:null};var f=a.modalDialog._ua;a.modalDialog.iframeLoadTimeout=0,a.modalDialog.animationDuration=600;var g=function(b){this.settings=b,this.parent=a(this.settings.containerElement||"body"),a.each(["open","beforeopen","close","beforeclose","ajaxerror"],a.proxy(this._setupCustomEvent,this)),a.proxyAll(this,"_drag","_startDrag","_stopDrag","_close","_keydownHandler")};g.prototype.dialogType="node",g.prototype._setupCustomEvent=function(b,c){var d="on"+c,e=a.CustomEvent.create(this,c),f=this.settings[d];return f&&e.add(f),e},g.prototype._initDeferred=function(b,c){return this._deferreds=this._deferreds||{},c=c||new a.Deferred,this._deferreds[b]=c,c},g.prototype._completeDeferred=function(a,b,c){var d=this._deferreds[a];if(d)return d[b+"With"](this,c),d;throw new Error("No deferred initialized for action '"+a+"'")},g.prototype._resolveDeferred=function(a,b){return this._completeDeferred(a,"resolve",b)},g.prototype._rejectDeferred=function(a,b){return this._completeDeferred(a,"reject",b)},g.prototype._clearDeferred=function(a){this._deferreds[a]=null},g.prototype._getDeferred=function(a){return this._deferreds[a]},g.prototype._isDeferredComplete=function(a){var b=this._getDeferred(a);return!b||"pending"!=b.state()},g.prototype.isOpen=function(){return!!this._open},g.prototype.open=function(b){var e=this._initDeferred("open",e);if(this._open)return this._rejectDeferred("open");this.level=d.length;var f=this.onbeforeopen.fire();return f.isDefaultPrevented()?this._rejectDeferred("open"):(f=a.modalDialog.onbeforeopen.fire(null,this),f.isDefaultPrevented()?this._rejectDeferred("open"):(d.push(this),this.level>0&&(this.settings.parentId=d[this.level-1].settings._fullId),this._open=!0,this._build(),this.$container[a.modalDialog.isSmallScreen()?"addClass":"removeClass"]("smallscreen"),this.$container.stop(!0,!0),this.$el.show(),this._showLoadingIndicator(),a(document).on("keydown",this._keydownHandler),this._finishOpenAction=function(){if("rejected"!=e.state()){this.$bg.addClass(a.modalDialog.veilClass);var d=this._getDefaultWidthData();this.$container.css({width:d.width});var f=this._getDefaultPosition(),g=f.top;f.top=c,this.$container.css(f);var h=a.proxy(function(){try{this.$el.addClass("dialog-visible"),a.modalDialog.isSmallScreen()&&(this.triggerWindowResize=!1,this._orientationchange=a.proxy(function(a){return this.triggerWindowResize=!0,this.pos(a)},this),a(window).on("orientationchange resize",this._orientationchange)),this.onopen.fire(),a.modalDialog.onopen.fire(null,this),this._resolveDeferred("open")}catch(b){this._rejectDeferred("open",b)}this._clearDeferred("open")},this);b?(this.$container.css({top:g}),setTimeout(h,0)):this.$container.animate({top:g},a.modalDialog.animationDuration,"swing").promise().then(h,h)}else this._clearDeferred("open");this._hideLoadingIndicator()},this._finishOpen(),e.promise()))},g.prototype._finishOpen=function(){if(this._finishOpenAction){try{this._finishOpenAction()}catch(a){this._rejectDeferred("open",a),this._clearDeferred("open")}this._finishOpenAction=null}},g.prototype._keydownHandler=function(b){27==b.keyCode&&a.modalDialog.getCurrent()===this&&this.cancel()},g.prototype.cancel=function(){this.$container&&this.$container.stop(!0,!1),this.isOpen()&&this.close()},g.prototype._showLoadingIndicator=function(){this.$loadingIndicator||(this.$loadingIndicator=a("<div class='dialog-loading-indicator'><span></span></div>").appendTo(this.$bg))},g.prototype._hideLoadingIndicator=function(){this.$loadingIndicator.remove(),this.$loadingIndicator=null},g.prototype._popDialogStack=function(){a.modalDialog.getCurrent()===this&&d.pop()},g.prototype.close=function(b){var d=this._initDeferred("close",d);if(a.modalDialog.getCurrent()!==this)throw new Error("Can't close a dialog that isn't currently displayed on top.");var e={isDialogCloseButton:!!b};return this.onbeforeclose.fire(e).isDefaultPrevented()?this._rejectDeferred("close"):a.modalDialog.onbeforeclose.fire(e,this).isDefaultPrevented()?this._rejectDeferred("close"):(this._popDialogStack(),a(document).off("keydown",this._keydownHandler),this.$el.removeClass("dialog-visible"),this.$container.animate({top:c},a.modalDialog.animationDuration,"swing").promise().then(a.proxy(function(){try{this._finishClose(e)}catch(a){this._rejectDeferred("close",a),this._clearDeferred("close")}},this),a.proxy(function(a){this._rejectDeferred("close",a),this._clearDeferred("close")},this)),this._orientationchange&&a(window).off("orientationchange resize",this._orientationchange),d.promise())},g.prototype._close=function(a){a.preventDefault(),this.close(!0)},g.prototype._reset=function(){this._open=!1,this.$container.stop(!0,!0),this.$container.css({top:c}),this.$bg.removeClass(a.modalDialog.veilClass),this.$el.hide()},g.prototype._resetFailed=function(){this._reset(),this._popDialogStack()},g.prototype._finishClose=function(b){this._reset(),this.settings.destroyOnClose&&this._destroy(),a.modalDialog.isSmallScreen()&&this.triggerWindowResize&&a(window).trigger("resize"),setTimeout(a.proxy(function(){this.onclose.fire(b),a.modalDialog.onclose.fire(b,this),this._resolveDeferred("close")},this),0)},g.prototype._destroy=function(){this._destroyed||(this.$content.detach().appendTo("body"),this.$el.remove(),delete e[this.settings._fullId],this._destroyed=!0)},g.prototype._updateZIndexes=function(){var a=this.settings.zIndex,b=this.getParent();b&&(a=Math.max(b.settings.zIndex+10,a)),this.$bg.css("z-index",a),a+=2,this.$container.css("z-index",a)},g.prototype._preventClickBubbling=function(a){var b=this;a.on("click mousedown mouseup touchstart touchend",function(a){b.settings.preventEventBubbling&&a.stopPropagation()})},g.prototype._build=function(){if(this._destroyed)throw new Error("This dialog has been destroyed");this.$el?this._alreadyBuilt():(this.$bg=a('<div class="dialog-background"></div>'),this.$container=a('<div class="dialog-container" id="'+this.settings._fullId+'Container"> <div class="dialog-header"> <a href="#" class="dialog-close-button"><span class="dialog-close-button-icon"></span></a> <h1>'+(this.settings.title||"")+'</h1> </div> <div class="dialog-content-container"> </div></div>'),this._preventClickBubbling(this.$bg),this._preventClickBubbling(this.$container),this.$el=a([this.$bg[0],this.$container[0]]).addClass("dialog-skin-"+this.settings.skin),this.parent.append(this.$bg,this.$container),this.parent.is("body")||this.parent.hasClass("ui-page-active")||(this.$bg.css("position","absolute"),"static"==this.parent.css("position")&&this.parent.css("position","relative")),this.$contentContainer=this.$el.find(".dialog-content-container"),this.$header=this.$el.find(".dialog-header"),this.$closeButton=this.$el.find(".dialog-close-button").on("click",this._close),this._buildContent(),this.$contentContainer.on("click",'*[data-action="close"]',this._close),this.$contentContainer.append(this.$content),!this.parent.is("body")&&!this.parent.hasClass("ui-page-active")||f.ie7||this._makeDraggable()),this._updateZIndexes()},g.prototype._alreadyBuilt=function(){this.$content.parent()[0]!==this.$contentContainer[0]&&(this._buildContent(),this.$contentContainer.append(this.$content))},g.prototype._getChromeHeight=function(){return this._chromeHeight||(this._chromeHeight=this.$container.height()-this.$content.height()),this._chromeHeight},g.prototype._getDefaultWidthData=function(){var c=a(window),d=this.parent.is("body")?window.innerWidth||c.width():this.parent.width();return{windowWidth:d,width:Math.min(d-2*b,this.settings.maxWidth)}},g.prototype._getDefaultPosition=function(c){var d=this._getDefaultWidthData(),e=a(document).scrollTop(),g={width:d.width,top:e+b};g.left=(d.windowWidth-g.width)/2;var h=a.modalDialog.isSmallScreen();if((f.ie7||h)&&(g.top=b),!h){c=c||this.$content.height();var i=this._getChromeHeight()+c,j=this.parent.is("body")?a(window).height():this.parent.height(),k=j/2-i/2+e;g.top=Math.max(k,g.top)}return g},g.prototype._makeDraggable=function(){a.modalDialog.isSmallScreen()||this.$header.addClass("draggable").on("pointerdown",this._startDrag)},g.prototype._startDrag=function(b){var c=a(b.target);c.is(this.$closeButton)||c.is(this.$closeButton.children())||(b.stopPropagation(),b.preventDefault(),this._initialMousePos=h(b),this._initialDialogPos=this.$container.offset(),a(document).on("pointermove",this._drag),this.$header.on("pointerup",this._stopDrag),this.$bg.on("pointerup",this._stopDrag),this.$frame&&(this._overlay=a("<div class='dialog-content-overlay'>").appendTo(this.$contentContainer)),this._isDragging=!0)},g.prototype._drag=function(b){if(!this._isDragging)return void a(document).off("pointermove",this._drag);var c=h(b),d=c.top-this._initialMousePos.top,e=c.left-this._initialMousePos.left,f={top:this._initialDialogPos.top+d,left:this._initialDialogPos.left+e};this.$container.css(f)},g.prototype._stopDrag=function(){delete this._initialMousePos,delete this._initialDialogPos,a(document).off("pointermove",this._drag),this.$header.off("pointerup",this._stopDrag),this.$bg.off("pointerup",this._stopDrag),this._overlay&&(this._overlay.remove(),delete this._overlay),this._isDragging=!1};var h=function(b){var c={left:b.pageX,top:b.pageY};if(b.target.ownerDocument!=window.document){var d=a(b.target.ownerDocument).hostIframe();if(d.length>0){var e=d.clientRect();c.top+=e.top,c.left+=e.left}}return c};g.prototype._buildContent=function(){this.$content=a(this.settings.content),this.$content.detach()},g.prototype.getWindow=function(){return window},g.prototype.getParent=function(){return this.settings.parentId?o(this.settings.parentId):null},g.prototype.center=function(){var a=this._getDefaultPosition();this.$container.animate({top:a.top},400)},g.prototype.pos=function(a){this.$container.stop(!0,!0);var b=this._getDefaultPosition();if(a===!0){var c=b.top;delete b.top,this.$container.css(b).animate({top:c},400)}else this.$container.css(b)},g.prototype.setTitle=function(a){this.$container.find(".dialog-header h1").text(a||"")},g.prototype.getTitle=function(){return this.$container.find(".dialog-header h1").text()};var i=function(){g.apply(this,arguments),this.settings.parentId&&(this._parentWindow=window.frames[this.settings.parentId])};a.extend(i.prototype,g.prototype),i.prototype.dialogType="iframe",i.prototype._setupCustomEvent=function(){var a=g.prototype._setupCustomEvent.apply(this,arguments);a.add(j)};var j=function(b){for(var c=0;c<d.length;c++)d[c]._postCommand&&d[c]._postCommand("event"+b.type,a.extend({_eventDialogId:this.settings._fullId},b.data))};i.prototype._finishClose=function(a){g.prototype._finishClose.call(this,a),this.$frame[0].src="about:blank",this.$frame.remove()},i.prototype._destroy=function(){this.$el.remove()},i.prototype._buildContent=function(){this._iframeLoadTimer=null,this.$frame&&this.$frame.length>0&&this.$frame.remove(),this.$frame=a('<iframe src="'+this.settings.url+'" name="'+this.settings._fullId+'" seamless allowtransparency="true" width="100%" style="height:'+(this.height||this.settings.initialHeight)+'px;" class="dialog-frame" scrolling="no" frameborder="0" framespacing="0"></iframe>'),a.modalDialog.iframeLoadTimeout>0&&this.$frame.on("load",a.proxy(function(){this._isDeferredComplete("open")||(this._iframeLoadTimer=setTimeout(a.proxy(function(){this._isDeferredComplete("open")||(this.$frame.remove(),this._resetFailed(),this._rejectDeferred("open",[{message:"iframe load timeout for url: "+this.settings.url}]))},this),a.modalDialog.iframeLoadTimeout))},this)),this.$content=this.$frame},i.prototype._alreadyBuilt=function(){this._buildContent(),this.$contentContainer.append(this.$content)},i.prototype.getWindow=function(){return this.$frame.iframeWindow()[0]},i.prototype._postCommand=function(b,c){var d={dialogCmd:b};c&&a.extend(d,c);var e=a.param(d);this.postMessage(e)},i.prototype.postMessage=function(b){var c=this.getWindow(),d=this.frameHostname;d||(d=0===this.settings.url.indexOf("http")?this.settings.url:document.location.href),a.postMessage?a.postMessage(b,d,c):c.postMessage(b,"*")},i.prototype.setHeight=function(a,b,c){var d=c?function(a,b){a.css(b)}:function(a,b){a.animate(b,{duration:400})};if(d(this.$content,{height:a}),b){var e=this._getDefaultPosition(a);d(this.$content,{top:e.top})}this.height=a},i.prototype.setHeightFromContent=function(a,b){this._postCommand("setHeightFromContent",{center:!!a,skipAnimation:!!b})},i.prototype.setTitleFromContent=function(){this._postCommand("setTitleFromContent")},i.prototype.notifyReady=function(a){this._iframeLoadTimer&&(clearTimeout(this._iframeLoadTimer),this._iframeLoadTimer=null),this.frameHostname=a,g.prototype._finishOpen.apply(this)},i.prototype._finishOpen=function(){};var k=function(){g.apply(this,arguments)};a.extend(k.prototype,g.prototype),k.prototype.dialogType="ajax",k.prototype.open=function(){var b=g.prototype.open.apply(this,arguments);return this._ajaxComplete?g.prototype._finishOpen.call(this):this.$content.partialLoad(this.settings.url,null,a.proxy(function(b,c,d){this._ajaxComplete=!0,d.fail(a.proxy(function(){this._resetFailed();var a={xhr:d,status:c,responseText:b};this.onajaxerror.fire(a),this._rejectDeferred("open",[a])},this));var e=this.$content.find("title");this.settings.title||e.length>=0&&this.setTitle(e.text()),e.remove(),g.prototype._finishOpen.call(this)},this)),b.promise()},k.prototype._finishOpen=function(){},k.prototype._buildContent=function(){this.$content=a("<div class='dialog-content'></div>")},k.prototype._destroy=function(){this.$el.remove()};var l=-1,m="dialog",n=function(a){var b=a.charAt(0);if("#"==b)return!0;if(a.indexOf("/")>=0)return!1;if("."==b){var c=a.charAt(1);return"."==c||"/"==c?!1:!0}return!1};a.modalDialog._ensureSettings=function(b){var c=a.extend({},a.modalDialog.defaults);if(b.contentOrUrl&&(n(b.contentOrUrl)?b.content=a(b.contentOrUrl):b.url=b.contentOrUrl,delete b.contentOrUrl),b.content){var d=a(b.content),e=a.modalDialog.getSettings(d);a.extend(c,e)}a.extend(c,b);var f;if(c._fullId){var g=c._fullId.split("_");f=g.pop(),g.length>0&&(c.parentId=g.join("_"))}else{f=m+(c.id||++l);var h=c.parentId?c.parentId+"_":"";c._fullId=h+f}return c},a.modalDialog._areSettingsEqual=function(a,b){for(var c in a)if("_fullId"!=c){var d=a[c],e=b[c];if(d!==e){if(d.jquery&&e.jquery&&d[0]===e[0])continue;return!1}}return!0};var o=function(a){return e[a]};a.modalDialog=a.modalDialog||{},a.modalDialog._isHost=!0,a.modalDialog.veilClass="dialog-veil",a.modalDialog.create=function(b){b=a.modalDialog._ensureSettings(b);var c=o(b._fullId);if(!c&&b.content){var d=a(b.content).modalDialogInstance();if(d&&b._fullId&&d.settings._fullId!==b._fullId&&d.isOpen())throw new Error("An attempt was made to create a dialog with a content node which is already assigned to another open dialog.")}if(!c){if(b.url){if(b.content)throw new Error("Both url and content cannot be specified.");c=b.ajax?new k(b):new i(b)}else{if(!b.content)throw new Error("No url or content node specified");var f=a(b.content);if(0===f.length)throw new Error("ModalDialog content not found");b.content=f,c=new g(b),b.destroyOnClose||f.modalDialogInstance(c)}e[b._fullId]=c}return c},a.modalDialog.getCurrent=function(){return d.length>0?d[d.length-1]:null},a.modalDialog.getExisting=function(b){var c,d=a(b.content);if(d&&d.length?c=function(b){return b.content&&a(b.content)[0]===d[0]}:b.url&&(c=function(a){return a.url&&a.url===b.url&&!!a.ajax==!!b.ajax}),c)for(var f in e){var g=e[f];if(c(g.settings))return g}return null},a.CustomEvent.create(a.modalDialog,"beforeopen"),a.CustomEvent.create(a.modalDialog,"open"),a.CustomEvent.create(a.modalDialog,"beforeclose"),a.CustomEvent.create(a.modalDialog,"close");var p="modalDialog";a.fn.modalDialogInstance=function(a){return a?this.data(p,a):this.data(p)},a.fn.modalDialog=function(b){var c;if("string"==typeof b){var d=b;c=this.modalDialogInstance(),c&&c[d]&&c[d].apply(c,Array.prototype.slice(arguments,1))}else b=b||{},b.content=this[0],c=a.modalDialog.create(b),c.open();return this};var q={setHeight:function(a,b){a.setHeight(parseInt(b.height,10),"true"===b.center,"true"===b.skipAnimation)},setTitle:function(a,b){a.setTitle(b.title)},open:function(a){a.open()},close:function(a){a.close()},create:function(){},center:function(a){a.center()},notifyReady:function(a,b){a.notifyReady(b.hostname)}},r=function(b){var c;try{c=a.deparam(b.originalEvent?b.originalEvent.data:b.data)}catch(d){}if(c&&c.dialogCmd){var e=q[c.dialogCmd];if(e){var f;return f=c._fullId?a.modalDialog.create(c):a.modalDialog.getCurrent(),e(f,c),!0}}return!1};a.receiveMessage?a.receiveMessage(r,"*"):a(window).on("message",r),window._dialogReceiveMessageManual=function(b,c){if(!r({data:b,origin:c})){var d=new a.Event("message");d.data=b,d.origin=c,a(window).trigger(d,[b,c])}},a(document).ready(function(){a.mobile&&(a.modalDialog.defaults=a.extend(a.modalDialog.defaults,{preventEventBubbling:!1}))})}(jQuery),function(a){var b="[data-dialog-main-panel='true']",c="[data-dialog-hide-onopen='true']",d=function(b,c){"iframe"==b.dialogType&&a([window,document]).enableEvent("touchmove touchstart touchend",!c)},e=function(){return window.innerHeight||a(window).height()},f=function(){var d=a(b);0===d.length&&(d=a(c));var f=0,g=0;a.modalDialog.onbeforeopen.add(function(){0===this.level&&(f=a(document).scrollTop(),g=document.body.style.height,d.each(function(b,c){a(c).data("dialog-parent",c.parentNode)}).detach(),document.body.style.height=e()+50+"px",window.scrollTo(0,1))}),a.modalDialog.onopen.add(function(){if(0===this.level){var b=Math.max(this.$container.height(),e())+20;document.body.style.height=b+"px",a(".dialog-background").css({height:b}),window.scrollTo(0,1)}}),a.modalDialog.onclose.add(function(){0===this.level&&(document.body.style.height=g,d.each(function(b,c){a(a(c).data("dialog-parent")).append(c)}),window.scrollTo(0,f))})};a(function(){if(a.modalDialog.isSmallScreen())if(a.modalDialog.veilClass="dialog-veil-opaque",a.modalDialog&&a.modalDialog._isContent){var b=a.modalDialog.getCurrent();b&&a(window).on("load",function(){d(b,!0)})}else a.modalDialog.onopen.add(function(){d(this,!0)}),a.modalDialog.onbeforeclose.add(function(){d(this,!1)}),f()})}(jQuery),function(a){var b="modalDialogUnobtrusive",c=function(c){c.preventDefault();var d=a(c.currentTarget),e=d.attr("data-dialog-url")||d.attr("href");if(!e)throw new Error("no href specified with data-rel='modalDialog'");var f={contentOrUrl:e},g=a.modalDialog.getSettings(d);a.extend(f,g);var h=new a.Event("dialogsettingscreate");if(h.dialogSettings=f,d.trigger(h),!h.isDefaultPrevented()){var i=d.data(b);if(i){var j=a.modalDialog._ensureSettings(f);a.modalDialog._areSettingsEqual(i.settings,j)||(i._destroy(),i=null)}if(!i){if(i=a.modalDialog.create(f),h=new a.Event("dialogcreate"),h.dialogSettings=f,h.dialog=i,d.trigger(h),h.isDefaultPrevented())return;f.destroyOnClose||d.data(b,i)}i.open()}};a(document).on("click","[data-rel='modalDialog']",c),a(document).on("click",".close-dialog",function(b){b.preventDefault(),setTimeout(function(){var b=a.modalDialog.getCurrent();b&&b.close()},0)})}(jQuery),function(a){var b,c="sdialogid";a.modalDialog.enableHistory=function(d){if(!j){j=!0,b=d||c,e();var f=new a.Deferred;return u(!0).then(function(){try{a.modalDialog.onopen.add(r),a.modalDialog.onclose.add(s),History.Adapter.bind(window,"statechange",t),f.resolve()}catch(b){f.reject(b)}},function(a){f.reject(a)}),f}},a.modalDialog.isHistoryEnabled=function(){return j};var d=function(){if(History.emulated.pushState&&window.location.hash){var b=window.location.hash.indexOf("?");if(b>=0)return a.deparam(window.location.hash.substr(b))}return window.location.search?a.currentQueryString():{}},e=function(){for(var b=a.modalDialog.getCurrent();b;)b&&(b.settings.enableHistory=!1),b=b.getParent()},f=function(a){var b=a;do{if(b&&!b.settings.enableHistory)return!1;b=b.getParent()}while(b);return j},g=!0,h=!1,i=!1,j=!1,k=function(b){var c={dialogType:"node",dialogId:null};if(b.settings.content){var d=a(b.settings.content).prop("id");if(!d)throw new Error("The specified content node has no ID, and cannot be serialized to a URL parameter.");c.dialogId="#"+d}return!c.dialogId&&b.settings.url&&(c.dialogType=b.settings.ajax?"ajax":"iframe",c.dialogId=b.settings.url),c},l=function(b){var c=null;if("iframe"==b.dialogType)c={url:b.dialogId};else if("ajax"==b.dialogType)c={ajax:!0,url:b.dialogId};else{var d;try{d=a(b.dialogId)}catch(e){}d&&d.length>0&&(c=a.modalDialog.getSettings(d),c.content=d)}return c},m=function(a,b){var c=k(b);return c.dialogType==a.dialogType&&c.dialogId==a.dialogId},n=function(a){return a.replace("#","-hash-")},o=function(a){return a.replace("-hash-","#")},p=function(b){if(!b)return[];var c=b.split(" ");return a.map(c,function(a){var b=a.indexOf("_");if(0>b)throw new Error("Invalid dialog parameters: "+a);return{dialogType:a.substr(0,b),dialogId:o(a.substr(b+1))}})},q=function(b){return a.map(b,function(a){return a.dialogType+"_"+n(a.dialogId)}).join(" ")},r=function(){if(!i&&f(this)){var c=k(this),e=d(),j=p(e[b]);if(this.level+1<=j.length)throw new Error("The number of dialogParams in the URL doesn't match the number of open dialogs. Not updating history.");j.push(c),e[b]=q(j);var l=a.appendQueryString(document.location.pathname,e);h=!0,History.pushState(null,document.title,l),g=!1}},s=function(){if(!i&&this.settings.enableHistory!==!1){if(g){var c=d(),e=p(c[b]),f=e.pop();if(!m(f,this))throw new Error("Closed dialog does not match URL parameters: "+f.dialogType+","+f.dialogId+". History not updated.");0===e.length?delete c[b]:c[b]=q(e);var j=a.appendQueryString(document.location.pathname,c);History.pushState(null,document.title,j)}else h=!0,History.back();g=!1}},t=function(){return h?void(h=!1):void u()},u=function(c){var e=new a.Deferred,f=p(d()[b]),g=a.modalDialog.getCurrent(),h=g?g.level+1:0;f.length===h&&e.resolve();var j=function(){if(f.length>h){var b=f[h],d=l(b);if(!d)return i=!1,void e.reject("Unable to create dialog settings from dialogId in URL: "+b.dialogType+","+b.dialogId);var g=a.modalDialog.getExisting(d);g||(g=a.modalDialog.create(d)),i=!0,g.open(c).then(function(){h++;try{j()}catch(a){e.reject(a)}})}else setTimeout(function(){e.resolve(),i=!1},0)};f.length>h&&j();var k=function(){if(f.length<h){var b=a.modalDialog.getCurrent();if(b){if(!b.settings.enableHistory)return e.resolve(),void(i=!1);i=!0,b.close().then(function(){h--;try{k()}catch(a){e.reject(a)}})}else i=!1,e.reject("There was a mismatch between the URL and the current open dialog stack")}else setTimeout(function(){e.resolve(),i=!1})};return f.length<h&&k(),e}}(jQuery);