Updated dialog "max-height" CSS property computing
authorThierry Florac <thierry.florac@onf.fr>
Fri, 28 Dec 2018 10:06:15 +0100
changeset 503 a50637baf022
parent 502 403751b04d8e
child 504 fb5a531cddbe
Updated dialog "max-height" CSS property computing
src/pyams_skin/resources/js/myams-dialog.js
src/pyams_skin/resources/js/myams-dialog.min.js
--- a/src/pyams_skin/resources/js/myams-dialog.js	Fri Dec 28 10:05:11 2018 +0100
+++ b/src/pyams_skin/resources/js/myams-dialog.js	Fri Dec 28 10:06:15 2018 +0100
@@ -138,9 +138,12 @@
 																							 overflow: dialogData.amsModalOverflow || '.modal-viewport',
 																							 maxHeight: dialogData.amsModalMaxHeight === undefined ?
 																								 function() {
-																									 return $(window).height() -
+																							 		 var win_height = $(window).height(),
+																										 top_margin = parseInt(dialog.css('margin-top')),
+																									 	 top_padding = Math.round(win_height / 10);
+																									 return win_height -
 																										 $('.modal-header', content).outerHeight(true) -
-																										 $('footer', content).outerHeight(true) - 85;
+																										 $('footer', content).outerHeight(true) - top_margin - top_padding;
 																								 }
 																								 : ams.getFunctionByName(dialogData.amsModalMaxHeight)
 																						 };
--- a/src/pyams_skin/resources/js/myams-dialog.min.js	Fri Dec 28 10:05:11 2018 +0100
+++ b/src/pyams_skin/resources/js/myams-dialog.min.js	Fri Dec 28 10:06:15 2018 +0100
@@ -1,1 +1,1 @@
-!function(a,e){var o=e.MyAMS;o.dialog={_shown_callbacks:[],registerShownCallback:function(a,e){var t;e&&(t=e.objectOrParentWithClass("modal-dialog"));var l;t&&t.exists()?void 0===(l=t.data("shown-callbacks"))&&(l=[],t.data("shown-callbacks",l)):l=o.dialog._shown_callbacks,l.indexOf(a)<0&&l.push(a)},_hide_callbacks:[],registerHideCallback:function(a,e){var t;e&&(t=e.objectOrParentWithClass("modal-dialog"));var l;t&&t.exists()?void 0===(l=t.data("hide-callbacks"))&&(l=[],t.data("hide-callbacks",l)):l=o.dialog._hide_callbacks,l.indexOf(a)<0&&l.push(a)},open:function(e,t,l){o.ajax&&o.ajax.check(a.fn.modalmanager,o.baseURL+"ext/bootstrap-modalmanager"+o.devext+".js",function(){o.ajax.check(a.fn.modal.defaults,o.baseURL+"ext/bootstrap-modal"+o.devext+".js",function(s){s&&(a(document).off("click.modal"),a.fn.modal.defaults.spinner=a.fn.modalmanager.defaults.spinner='<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="progress-bar" style="width: 100%;"></div></div></div>');var d,i;if("string"==typeof e)d={},i=e;else{d=e.data(),i=e.attr("href")||d.amsUrl;var n=o.getFunctionByName(i);"function"==typeof n&&(i=n.call(e))}i&&(a("body").modalmanager("loading"),0===i.indexOf("#")?a(i).modal("show"):a.ajax({url:i,type:"get",cache:void 0!==d.amsAllowCache&&d.amsAllowCache,data:t,success:function(t,s,n){a("body").modalmanager("removeLoading");var c=o.ajax.getResponse(n),r=c.contentType,h=c.data;switch(r){case"json":o.ajax.handleJSON(h,a(a(e).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var m=a(h),g=a(".modal-dialog",m.wrap("<div></div>").parent()),f=g.data()||{},v={backdrop:"static",overflow:f.amsModalOverflow||".modal-viewport",maxHeight:void 0===f.amsModalMaxHeight?function(){return a(window).height()-a(".modal-header",m).outerHeight(!0)-a("footer",m).outerHeight(!0)-85}:o.getFunctionByName(f.amsModalMaxHeight)},p=a.extend({},v,f.amsModalOptions);p=o.executeFunctionByName(f.amsModalInitCallback,g,p)||p,l&&(l.shown&&o.dialog.registerShownCallback(l.shown,m),l.hide&&o.dialog.registerHideCallback(l.hide,m)),a("<div>").addClass("modal fade").append(m).modal(p).on("shown",o.dialog.shown).on("hidden",o.dialog.hidden),o.initContent&&o.initContent(m),!1!==d.amsLogEvent&&o.stats&&o.stats.logPageview(i)}}}))})})},shown:function(e){function t(e){var o=a(".scrollmarker.top",s),t=s.scrollTop();t>0?o.show():o.hide();var l=a(".scrollmarker.bottom",s);d+t>=s.get(0).scrollHeight?l.hide():l.show()}var l=e.target,s=a(".modal-viewport",l);if(s.exists()){var d=parseInt(s.css("max-height")),i=a.scrollbarWidth();"hidden"!==s.css("overflow")&&s.height()===d?(a("<div></div>").addClass("scrollmarker").addClass("top").css("top",0).css("width",s.width()-i).hide().appendTo(s),a("<div></div>").addClass("scrollmarker").addClass("bottom").css("top",d-20).css("width",s.width()-i).appendTo(s),s.scroll(t),s.off("resize").on("resize",t)):a(".scrollmarker",s).remove()}a("[data-ams-shown-callback]",l).each(function(){var e=o.getFunctionByName(a(this).data("ams-shown-callback"));e&&e.call(l,this)});var n,c=a(".modal-dialog",l).data("shown-callbacks");if(c)for(n=0;n<c.length;n++)c[n].call(l);if(c=o.dialog._shown_callbacks)for(n=0;n<c.length;n++)c[n].call(l);o.form&&o.form.setFocus(l)},close:function(e){"string"==typeof e&&(e=a(e));var o=e.parents(".modal").data("modal");if(o){var t=a("body").data("modalmanager");t&&t.getOpenModals().indexOf(o)>=0&&o.hide()}},hidden:function(e){var t=e.target;o.skin&&o.skin.cleanContainer(t),a("[data-ams-hidden-callback]",t).each(function(){var e=o.getFunctionByName(a(this).data("ams-hidden-callback"));e&&e.call(t,this)});var l,s=a(".modal-dialog",t).data("hide-callbacks");if(s)for(l=0;l<s.length;l++)s[l].call(t);if(s=o.dialog._hide_callbacks)for(l=0;l<s.length;l++)s[l].call(t)}}}(jQuery,this);
+!function(a,e){var o=e.MyAMS;o.dialog={_shown_callbacks:[],registerShownCallback:function(a,e){var t;e&&(t=e.objectOrParentWithClass("modal-dialog"));var l;t&&t.exists()?void 0===(l=t.data("shown-callbacks"))&&(l=[],t.data("shown-callbacks",l)):l=o.dialog._shown_callbacks,l.indexOf(a)<0&&l.push(a)},_hide_callbacks:[],registerHideCallback:function(a,e){var t;e&&(t=e.objectOrParentWithClass("modal-dialog"));var l;t&&t.exists()?void 0===(l=t.data("hide-callbacks"))&&(l=[],t.data("hide-callbacks",l)):l=o.dialog._hide_callbacks,l.indexOf(a)<0&&l.push(a)},open:function(e,t,l){o.ajax&&o.ajax.check(a.fn.modalmanager,o.baseURL+"ext/bootstrap-modalmanager"+o.devext+".js",function(){o.ajax.check(a.fn.modal.defaults,o.baseURL+"ext/bootstrap-modal"+o.devext+".js",function(s){s&&(a(document).off("click.modal"),a.fn.modal.defaults.spinner=a.fn.modalmanager.defaults.spinner='<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="progress-bar" style="width: 100%;"></div></div></div>');var d,i;if("string"==typeof e)d={},i=e;else{d=e.data(),i=e.attr("href")||d.amsUrl;var n=o.getFunctionByName(i);"function"==typeof n&&(i=n.call(e))}i&&(a("body").modalmanager("loading"),0===i.indexOf("#")?a(i).modal("show"):a.ajax({url:i,type:"get",cache:void 0!==d.amsAllowCache&&d.amsAllowCache,data:t,success:function(t,s,n){a("body").modalmanager("removeLoading");var c=o.ajax.getResponse(n),r=c.contentType,h=c.data;switch(r){case"json":o.ajax.handleJSON(h,a(a(e).data("ams-json-target")||"#content"));break;case"script":case"xml":break;case"html":case"text":default:var m=a(h),g=a(".modal-dialog",m.wrap("<div></div>").parent()),f=g.data()||{},v={backdrop:"static",overflow:f.amsModalOverflow||".modal-viewport",maxHeight:void 0===f.amsModalMaxHeight?function(){var e=a(window).height(),o=parseInt(g.css("margin-top")),t=Math.round(e/10);return e-a(".modal-header",m).outerHeight(!0)-a("footer",m).outerHeight(!0)-o-t}:o.getFunctionByName(f.amsModalMaxHeight)},p=a.extend({},v,f.amsModalOptions);p=o.executeFunctionByName(f.amsModalInitCallback,g,p)||p,l&&(l.shown&&o.dialog.registerShownCallback(l.shown,m),l.hide&&o.dialog.registerHideCallback(l.hide,m)),a("<div>").addClass("modal fade").append(m).modal(p).on("shown",o.dialog.shown).on("hidden",o.dialog.hidden),o.initContent&&o.initContent(m),!1!==d.amsLogEvent&&o.stats&&o.stats.logPageview(i)}}}))})})},shown:function(e){function t(e){var o=a(".scrollmarker.top",s),t=s.scrollTop();t>0?o.show():o.hide();var l=a(".scrollmarker.bottom",s);d+t>=s.get(0).scrollHeight?l.hide():l.show()}var l=e.target,s=a(".modal-viewport",l);if(s.exists()){var d=parseInt(s.css("max-height")),i=a.scrollbarWidth();"hidden"!==s.css("overflow")&&s.height()===d?(a("<div></div>").addClass("scrollmarker").addClass("top").css("top",0).css("width",s.width()-i).hide().appendTo(s),a("<div></div>").addClass("scrollmarker").addClass("bottom").css("top",d-20).css("width",s.width()-i).appendTo(s),s.scroll(t),s.off("resize").on("resize",t)):a(".scrollmarker",s).remove()}a("[data-ams-shown-callback]",l).each(function(){var e=o.getFunctionByName(a(this).data("ams-shown-callback"));e&&e.call(l,this)});var n,c=a(".modal-dialog",l).data("shown-callbacks");if(c)for(n=0;n<c.length;n++)c[n].call(l);if(c=o.dialog._shown_callbacks)for(n=0;n<c.length;n++)c[n].call(l);o.form&&o.form.setFocus(l)},close:function(e){"string"==typeof e&&(e=a(e));var o=e.parents(".modal").data("modal");if(o){var t=a("body").data("modalmanager");t&&t.getOpenModals().indexOf(o)>=0&&o.hide()}},hidden:function(e){var t=e.target;o.skin&&o.skin.cleanContainer(t),a("[data-ams-hidden-callback]",t).each(function(){var e=o.getFunctionByName(a(this).data("ams-hidden-callback"));e&&e.call(t,this)});var l,s=a(".modal-dialog",t).data("hide-callbacks");if(s)for(l=0;l<s.length;l++)s[l].call(t);if(s=o.dialog._hide_callbacks)for(l=0;l<s.length;l++)s[l].call(t)}}}(jQuery,this);