Projet

Général

Profil

Bug #13145 » silverpeas-popup-min.js

David Lesimple, 05/07/2022 11:46

 
(function(e,h){if(e.popup){return}var l=false;var k=new function(){this.isWindowCompatible=function(){return top.spLayout&&!top.spLayout.isWindowTop(h)};this.getLayoutManager=function(){var v=top.spLayout?top.spLayout.getWindowTopFrom(h).window:h;return v.spAdminLayout?v.spAdminLayout:h.spLayout};this.top$=function(){return top.spLayout?top.spLayout.getWindowTopFrom(h).jQuery:e};this.topDocument=function(){return top.spLayout?top.spLayout.getWindowTopFrom(h).document:document}};var m=k.isWindowCompatible();const c=function(v){if(v.keyCode===27){v.preventDefault()}};e.popup={showWaiting:function(){var v=e("#spWaiting");if(v.length===0){v=e("<div>").attr("id","spWaiting").attr("style","display: none; border: 0; padding: 0; text-align: center; overflow: hidden;");e(document.body).append(v);v.popup("waiting");v.dialog("widget").keydown(c)}v.dialog("open")},hideWaiting:function(){var v=e("#spWaiting");if(v.length>0){v.dialog("close");v.dialog("destroy");v.remove()}},confirm:function(x,y){var w=y;var v=e("<div>").append(e("<p>").append(x));if(typeof y==="function"){w={callback:y}}v.popup("confirmation",w)},validate:function(w,x){let options=x;const v=e("<div>").append(e("<p>").append(w));if(typeof x==="function"){options={callback:x}}v.popup("validation",options)},info:function(x,y){var v=y;var w=e("<div>").append(e("<p>").append(x));if(typeof y==="function"){v={callbackOnClose:y}}w.popup("information",v)},error:function(x,y){var w=y;x=x.replaceAll("\n","<br/>");var v=e("<div>").append(e("<p>").append(x));if(typeof y==="function"){w={callback:y}}v.popup("error",w)},load:function(w,x){var y=sp.ajaxRequest(w);if(x){if(x.method==="POST"){y=y.byPostMethod()}if(x.params){y=y.withParams(x.params)}}var v=y.send();return{show:function(z,A){jQuery.popup.showWaiting();return new Promise(function(D,C){var B=A;v.then(function(F){var G=F.responseText;var H=e("#popupHelperContainer");if(H.length!==0){H.remove()}H=e("<div>",{id:"popupHelperContainer",style:"display:none"});H.appendTo(document.body);H.append(G);if(typeof A==="function"){B={callback:A}}var E=B.callbackOnClose;B.callbackOnClose=function(I){if(typeof E==="function"){E.call(I)}H.remove()};H.popup(z,B);D(G);if(sp.promise.isOne(B.openPromise)){B.openPromise.then(jQuery.popup.hideWaiting)}else{jQuery.popup.hideWaiting()}},function(E){notyError(E.responseText);C();jQuery.popup.hideWaiting()})})},close:function(){jQuery("#popupHelperContainer").popup("close")}}}};var s=function(v){return sp.i18n.get(v)};var t={destroy:function(){e(this).dialog("close");e(this).dialog("destroy")},close:function(){e(this).dialog("close")},free:function(v){var w=n(v);w=e.extend(u({buttonDisplayed:false,width:"auto"}),w);q(w,v);return f(e(this),w)},basic:function(v){var w=n(v);e.extend(w,u({buttonDisplayed:false,disabledParentScroll:true,width:"auto"}));q(w,v);return f(e(this),w)},information:function(v){var w=n(v);if(!w.title){w.title=s("GML.information.dialog.title")}e.extend(w,u({buttonTextNo:s("GML.ok"),isMaxWidth:true}));return f(e(this),w)},error:function(v){var w=n(v);if(!w.title){w.title=s("GML.error.dialog.title")}e.extend(w,u({buttonTextNo:s("GML.ok"),isMaxWidth:true}));return f(e(this),w)},help:function(v){var w=n(v);if(!w.title){w.title=s("GML.help.dialog.title")}e.extend(w,u({buttonTextNo:s("GML.ok"),isMaxWidth:true,dialogClass:"help-modal-message"}));return f(e(this),w)},validation:function(v){var w=n(v);w=e.extend(u({buttonTextYes:s("GML.validate"),buttonTextNo:s("GML.cancel"),isMaxWidth:true}),w);return f(e(this),w)},confirmation:function(x){var y=n(x);if(!y.title){y.title=s("GML.confirmation.dialog.title")}var z=e("<div>").attr("style","display: table;");var w=e("<div>").attr("style","display: table-row;");z.append(w);var v=e("<span>").addClass("ui-icon ui-icon-alert");v.attr("style","float:left; margin:0 7px 0 0;");var A=e("<div>").attr("style","display: table-cell;vertical-align: bottom;");A.html(y.title);w.append(e("<div>").attr("style","display: table-cell;vertical-align: middle;").append(v));w.append(A);y.title=e("<div>").append(z).html();e.extend(y,u({buttonTextYes:s("GML.yes"),buttonTextNo:s("GML.no"),isMaxWidth:true}));return f(e(this),y)},preview:function(v){var w=n(v);w.title=s("GML.preview.dialog.title");if(v.title&&v.title.length>0){w.title=w.title+" "+s("GML.preview.dialog.title.of")+" "+v.title}e.extend(w,u({buttonDisplayed:false,width:"auto"}));q(w,v);return f(e(this),w)},view:function(v){var w=n(v);w.title=s("GML.view.dialog.title");if(v.title&&v.title.length>0){w.title=w.title+" "+s("GML.view.dialog.title.of")+" "+v.title}e.extend(w,u({buttonDisplayed:false,width:"auto"}));q(w,v);return f(e(this),w)},waiting:function(){var x=e(this);var w=n({});e.extend(w,u({displayTitle:false,closeOnEscape:false,buttonDisplayed:false,width:"32px",height:39}));var v=popupViewGeneratorIconPath+"/inProgress.gif";x.html(e("<img>").attr("src",v).attr("width","32").attr("height","32"));return f(x,w)}};e.fn.popup=function(v){if(t[v]){return t[v].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof v==="object"||!v){return t.validation.apply(this,arguments)}else{return e.error("Method "+v+" does not exist on jQuery.popup")}}};function n(v){var w={openPromise:undefined,title:"",callback:null,alternativeCallback:null,callbackOnClose:null};if(v){e.extend(w,v)}return w}function u(v){var w={displayTitle:true,closeOnEscape:true,disabledParentScroll:false,buttonDisplayed:true,buttonTextYes:"",buttonTextNo:"",isMaxWidth:false,minWidth:undefined,maxWidth:undefined,width:570,height:"auto",dialogClass:""};if(v){e.extend(w,v)}return w}function i(){return(navigator.appVersion.indexOf("MSIE 7.")!==-1)}function q(w,v){if(i()){if(v.width){w.width=v.width}if(v.height){w.height=Number(v.height)+27}}}function f(w,v){if(!w.length){return w}return w.each(function(){var A=e(this);if(!v.title){v.title=A.attr("title")}A.dialog({closeOnEscape:v.closeOnEscape,title:v.title,autoOpen:false,modal:true,resizable:false,height:v.height,dialogClass:v.dialogClass});if(!v.displayTitle){A.dialog("widget").find(".ui-dialog-titlebar").hide()}if(v.buttonDisplayed){var z=[];if(v.buttonTextYes){z.push({text:v.buttonTextYes,click:function(){var D;if(v.callback){var C=v.callback.call(A);if(sp.promise.isOne(C)){D=C}else{if(typeof C==="undefined"||C){D=sp.promise.resolveDirectlyWith()}else{D=sp.promise.rejectDirectlyWith()}}}else{D=sp.promise.resolveDirectlyWith()}D.then(function(){A.dialog("close")})["catch"](function(){sp.log.debug("dialog not closed as validation failed")})}})}if(v.buttonTextNo){z.push({text:v.buttonTextNo,click:function(){if(v.alternativeCallback){v.alternativeCallback.call(A)}A.dialog("close")}})}if(z.length>0){A.dialog("option","buttons",z)}}A.dialog("option","close",function(C,D){if(v.callbackOnClose){v.callbackOnClose.call(this)}});if(v.disabledParentScroll){A.dialog("option","open",function(C,D){e("html,body").css("overflow","hidden")});A.dialog("option","beforeClose",function(C,D){e("html,body").css("overflow","auto")})}var x=""+v.width;var y=(x!=="auto")?x.replace(/px/,"")+"px":x;if(v.isMaxWidth){A.dialog("option","width","auto")}else{A.dialog("option","width",x)}var B=function(){var E=A.dialog("open");E.data("uiDialog")._title=function(F){F.html(this.options.title)};E.dialog("option","title",v.title);if(v.isMaxWidth){A.dialog("widget").css("max-width",y);A.dialog({position:A.dialog("option","position")})}if(v.minWidth){var C=""+v.minWidth;C=(C!=="auto")?C.replace(/px/,"")+"px":C;A.dialog("widget").css("min-width",C)}if(v.maxWidth){var D=""+v.maxWidth;D=(D!=="auto")?D.replace(/px/,"")+"px":D;A.dialog("widget").css("max-width",D)}};if(sp.promise.isOne(v.openPromise)){v.openPromise.then(B)}else{B()}})}const p=new function(){this.refreshState=function(){const v=k.top$()("div.ui-dialog").filter(":visible").length>0;j.refreshBackgroundState(v);const w=k.getLayoutManager();if(w){if(v){w.getBody().getContent().forceOnBackground()}else{w.getBody().getContent().unforceOnBackground()}}}};function b(){p.refreshState()}function d(){p.refreshState()}const j=new function(){const v=function(x){o("FSContext -",x)};const w=function(x){if(x.length>0){x.each(function(y,z){z.spUIManager.destroy()});v(x.length+" dialogs removed")}};this.refreshBackgroundState=function(x){const y=k.getLayoutManager();if(y){if(!x&&this.getContainers().length>0){y.getBody().getContent().setOnForeground()}else{y.getBody().getContent().setOnBackground()}}};this.clear=function(){v("clearing");w(this.getContainers());this.refreshBackgroundState()};this.removeLast=function(){v("removing last");w(this.getContainers().filter(":last"));this.refreshBackgroundState()};this.getContainers=function(){return k.top$()(".spFullscreenModalBackground",k.topDocument())}};function r(w){j.refreshBackgroundState();const z=k.top$()("<div>").attr("class","spFullscreenModalBackground ui-widget-overlay ui-front").attr("style","display: none; border: 0; padding: 0; overflow: hidden;");k.top$()(k.topDocument().body).append(z);const v=z[0];v.spUIManager=new function(){this.isOpen=function(){return z.css("display")!=="none"};this.open=function(){return z.show()};this.close=function(){return z.hide()};this.destroy=function(){return z.remove()}};v.addEventListener("keydown",c);var B=e("form",w);var A=w[0];var x=A.querySelectorAll("form");var y=A.__lastRegisteredHandler;if(y){B.unbind("submit",y);[].slice.call(x,0).forEach(function(C){C.removeEventListener("submit",y)})}A.__lastRegisteredHandler=function(){try{if(v.spUIManager.isOpen()){v.spUIManager.close()}}catch(C){sp.log.debug(C)}return true};B.bind("submit",A.__lastRegisteredHandler);[].slice.call(x,0).forEach(function(C){C.addEventListener("submit",A.__lastRegisteredHandler)});v.spUIManager.open();j.refreshBackgroundState()}function a(){j.removeLast()}function g(x){var v=x.position;if(v.my==="center"&&v.at==="center"&&v.of===window){var w=k.getLayoutManager();var B=w.getHeader().getContainer().offsetHeight/2;var z=!(k.top$()(w.getBody().getContent().getContainer()).position().left);if(z){var A=w.getBody().getNavigation().getContainer().offsetHeight/2;v.at="center center-"+(B+A)}else{var y=w.getBody().getNavigation().getContainer().offsetWidth/2;v.at="center-"+y+" center-"+B}}return v}e.widget("ui.dialog",e.ui.dialog,{open:function(){if(!!h.opener){return this._super()}const v=m&&!this._isOpen;if(v){g(this.options);r(this.element)}try{return this._super()}finally{if(!v){b()}}},close:function(){if(!!h.opener){return this._super()}const v=m&&this._isOpen;if(v){a()}try{return this._super()}finally{if(!v){d()}}},destroy:function(){if(!!h.opener){return this._super()}const v=m&&this._isOpen;if(v){a()}try{return this._super()}finally{if(!v){d()}}}});if(m){o("cleaning popup from iframe, window "+window.name);j.clear()}function o(){if(l){var v=sp.log.debugActivated;sp.log.debugActivated=true;var w=[];Array.prototype.push.apply(w,arguments);w.splice(0,0,"Popup -");sp.log.debug.apply(this,w);sp.log.debugActivated=v}}})(jQuery,window);
(1-1/3)