All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.base.dialog.min.js Maven / Gradle / Ivy

There is a newer version: 5.0.5
Show newest version
'use strict';(function(d){"function"===typeof define&&define.amd?define("jquery ./button ./draggable ./mouse ./resizable ../focusable ../keycode ../position ../safe-active-element ../safe-blur ../tabbable ../unique-id ../version ../widget".split(" "),d):d(jQuery)})(function(d){d.widget("ui.dialog",{version:"1.12.1",options:{appendTo:"body",autoOpen:!0,buttons:[],classes:{"ui-dialog":"ui-corner-all","ui-dialog-titlebar":"ui-corner-all"},closeOnEscape:!0,closeText:"Close",draggable:!0,hide:null,height:"auto",
maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(a){var b=d(this).css(a).offset().top;0>b&&d(this).css("top",a.top-b)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},sizeRelatedOptions:{buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},resizableRelatedOptions:{maxHeight:!0,
maxWidth:!0,minHeight:!0,minWidth:!0},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height};this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)};this.originalTitle=this.element.attr("title");null==this.options.title&&null!=this.originalTitle&&(this.options.title=this.originalTitle);
this.options.disabled&&(this.options.disabled=!1);this._createWrapper();this.element.show().removeAttr("title").appendTo(this.uiDialog);this._addClass("ui-dialog-content","ui-widget-content");this._createTitlebar();this._createButtonPane();this.options.draggable&&d.fn.draggable&&this._makeDraggable();this.options.resizable&&d.fn.resizable&&this._makeResizable();this._isOpen=!1;this._trackFocus()},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var a=this.options.appendTo;
return a&&(a.jquery||a.nodeType)?d(a):this.document.find(a||"body").eq(0)},_destroy:function(){var a,b=this.originalPosition;this._untrackInstance();this._destroyOverlay();this.element.removeUniqueId().css(this.originalCss).detach();this.uiDialog.remove();this.originalTitle&&this.element.attr("title",this.originalTitle);a=b.parent.children().eq(b.index);a.length&&a[0]!==this.element[0]?a.before(this.element):b.parent.append(this.element)},widget:function(){return this.uiDialog},disable:d.noop,enable:d.noop,
close:function(a){var b=this;this._isOpen&&!1!==this._trigger("beforeClose",a)&&(this._isOpen=!1,this._focusedElement=null,this._destroyOverlay(),this._untrackInstance(),this.opener.filter(":focusable").trigger("focus").length||d.ui.safeBlur(d.ui.safeActiveElement(this.document[0])),this._hide(this.uiDialog,this.options.hide,function(){b._trigger("close",a)}))},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(a,b){var e=!1,c=this.uiDialog.siblings(".ui-front:visible").map(function(){return+d(this).css("z-index")}).get(),
c=Math.max.apply(null,c);c>=+this.uiDialog.css("z-index")&&(this.uiDialog.css("z-index",c+1),e=!0);e&&!b&&this._trigger("focus",a);return e},open:function(){var a=this;this._isOpen?this._moveToTop()&&this._focusTabbable():(this._isOpen=!0,this.opener=d(d.ui.safeActiveElement(this.document[0])),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this.overlay&&this.overlay.css("z-index",this.uiDialog.css("z-index")-1),this._show(this.uiDialog,this.options.show,function(){a._focusTabbable();
a._trigger("focus")}),this._makeFocusTarget(),this._trigger("open"))},_focusTabbable:function(){var a=this._focusedElement;a||(a=this.element.find("[autofocus]"));a.length||(a=this.element.find(":tabbable"));a.length||(a=this.uiDialogButtonPane.find(":tabbable"));a.length||(a=this.uiDialogTitlebarClose.filter(":tabbable"));a.length||(a=this.uiDialog);a.eq(0).trigger("focus")},_keepFocus:function(a){function b(){var a=d.ui.safeActiveElement(this.document[0]);this.uiDialog[0]===a||d.contains(this.uiDialog[0],
a)||this._focusTabbable()}a.preventDefault();b.call(this);this._delay(b)},_createWrapper:function(){this.uiDialog=d("\x3cdiv\x3e").hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo());this._addClass(this.uiDialog,"ui-dialog","ui-widget ui-widget-content ui-front");this._on(this.uiDialog,{keydown:function(a){if(this.options.closeOnEscape&&!a.isDefaultPrevented()&&a.keyCode&&a.keyCode===d.ui.keyCode.ESCAPE)a.preventDefault(),this.close(a);else if(a.keyCode===d.ui.keyCode.TAB&&!a.isDefaultPrevented()){var b=
this.uiDialog.find(":tabbable"),e=b.filter(":first"),c=b.filter(":last");a.target!==c[0]&&a.target!==this.uiDialog[0]||a.shiftKey?a.target!==e[0]&&a.target!==this.uiDialog[0]||!a.shiftKey||(this._delay(function(){c.trigger("focus")}),a.preventDefault()):(this._delay(function(){e.trigger("focus")}),a.preventDefault())}},mousedown:function(a){this._moveToTop(a)&&this._focusTabbable()}});this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},
_createTitlebar:function(){var a;this.uiDialogTitlebar=d("\x3cdiv\x3e");this._addClass(this.uiDialogTitlebar,"ui-dialog-titlebar","ui-widget-header ui-helper-clearfix");this._on(this.uiDialogTitlebar,{mousedown:function(a){d(a.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.trigger("focus")}});this.uiDialogTitlebarClose=d("\x3cbutton type\x3d'button'\x3e\x3c/button\x3e").button({label:d("\x3ca\x3e").text(this.options.closeText).html(),icon:"ui-icon-closethick",showLabel:!1}).appendTo(this.uiDialogTitlebar);
this._addClass(this.uiDialogTitlebarClose,"ui-dialog-titlebar-close");this._on(this.uiDialogTitlebarClose,{click:function(a){a.preventDefault();this.close(a)}});a=d("\x3cspan\x3e").uniqueId().prependTo(this.uiDialogTitlebar);this._addClass(a,"ui-dialog-title");this._title(a);this.uiDialogTitlebar.prependTo(this.uiDialog);this.uiDialog.attr({"aria-labelledby":a.attr("id")})},_title:function(a){this.options.title?a.text(this.options.title):a.html("\x26#160;")},_createButtonPane:function(){this.uiDialogButtonPane=
d("\x3cdiv\x3e");this._addClass(this.uiDialogButtonPane,"ui-dialog-buttonpane","ui-widget-content ui-helper-clearfix");this.uiButtonSet=d("\x3cdiv\x3e").appendTo(this.uiDialogButtonPane);this._addClass(this.uiButtonSet,"ui-dialog-buttonset");this._createButtons()},_createButtons:function(){var a=this,b=this.options.buttons;this.uiDialogButtonPane.remove();this.uiButtonSet.empty();d.isEmptyObject(b)||d.isArray(b)&&!b.length?this._removeClass(this.uiDialog,"ui-dialog-buttons"):(d.each(b,function(b,
c){var f,g;c=d.isFunction(c)?{click:c,text:b}:c;c=d.extend({type:"button"},c);f=c.click;g={icon:c.icon,iconPosition:c.iconPosition,showLabel:c.showLabel,icons:c.icons,text:c.text};delete c.click;delete c.icon;delete c.iconPosition;delete c.showLabel;delete c.icons;"boolean"===typeof c.text&&delete c.text;d("\x3cbutton\x3e\x3c/button\x3e",c).button(g).appendTo(a.uiButtonSet).on("click",function(){f.apply(a.element[0],arguments)})}),this._addClass(this.uiDialog,"ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog))},
_makeDraggable:function(){function a(a){return{position:a.position,offset:a.offset}}var b=this,e=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(c,e){b._addClass(d(this),"ui-dialog-dragging");b._blockFrames();b._trigger("dragStart",c,a(e))},drag:function(c,d){b._trigger("drag",c,a(d))},stop:function(c,f){var g=f.offset.left-b.document.scrollLeft(),k=f.offset.top-b.document.scrollTop();e.position=
{my:"left top",at:"left"+(0<=g?"+":"")+g+" top"+(0<=k?"+":"")+k,of:b.window};b._removeClass(d(this),"ui-dialog-dragging");b._unblockFrames();b._trigger("dragStop",c,a(f))}})},_makeResizable:function(){function a(a){return{originalPosition:a.originalPosition,originalSize:a.originalSize,position:a.position,size:a.size}}var b=this,e=this.options,c=e.resizable,f=this.uiDialog.css("position"),c="string"===typeof c?c:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",
alsoResize:this.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:this._minHeight(),handles:c,start:function(c,e){b._addClass(d(this),"ui-dialog-resizing");b._blockFrames();b._trigger("resizeStart",c,a(e))},resize:function(c,d){b._trigger("resize",c,a(d))},stop:function(c,f){var h=b.uiDialog.offset(),l=h.left-b.document.scrollLeft(),h=h.top-b.document.scrollTop();e.height=b.uiDialog.height();e.width=b.uiDialog.width();e.position={my:"left top",at:"left"+(0<=l?"+":"")+
l+" top"+(0<=h?"+":"")+h,of:b.window};b._removeClass(d(this),"ui-dialog-resizing");b._unblockFrames();b._trigger("resizeStop",c,a(f))}}).css("position",f)},_trackFocus:function(){this._on(this.widget(),{focusin:function(a){this._makeFocusTarget();this._focusedElement=d(a.target)}})},_makeFocusTarget:function(){this._untrackInstance();this._trackingInstances().unshift(this)},_untrackInstance:function(){var a=this._trackingInstances(),b=d.inArray(this,a);-1!==b&&a.splice(b,1)},_trackingInstances:function(){var a=
this.document.data("ui-dialog-instances");a||(a=[],this.document.data("ui-dialog-instances",a));return a},_minHeight:function(){var a=this.options;return"auto"===a.height?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(){var a=this.uiDialog.is(":visible");a||this.uiDialog.show();this.uiDialog.position(this.options.position);a||this.uiDialog.hide()},_setOptions:function(a){var b=this,e=!1,c={};d.each(a,function(a,d){b._setOption(a,d);a in b.sizeRelatedOptions&&(e=!0);a in b.resizableRelatedOptions&&
(c[a]=d)});e&&(this._size(),this._position());this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",c)},_setOption:function(a,b){var e,c=this.uiDialog;"disabled"!==a&&(this._super(a,b),"appendTo"===a&&this.uiDialog.appendTo(this._appendTo()),"buttons"===a&&this._createButtons(),"closeText"===a&&this.uiDialogTitlebarClose.button({label:d("\x3ca\x3e").text(""+this.options.closeText).html()}),"draggable"===a&&((e=c.is(":data(ui-draggable)"))&&!b&&c.draggable("destroy"),!e&&b&&this._makeDraggable()),
"position"===a&&this._position(),"resizable"===a&&((e=c.is(":data(ui-resizable)"))&&!b&&c.resizable("destroy"),e&&"string"===typeof b&&c.resizable("option","handles",b),e||!1===b||this._makeResizable()),"title"===a&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var a,b,d,c=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0});c.minWidth>c.width&&(c.width=c.minWidth);a=this.uiDialog.css({height:"auto",width:c.width}).outerHeight();
b=Math.max(0,c.minHeight-a);d="number"===typeof c.maxHeight?Math.max(0,c.maxHeight-a):"none";"auto"===c.height?this.element.css({minHeight:b,maxHeight:d,height:"auto"}):this.element.height(Math.max(0,c.height-a));this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var a=d(this);return d("\x3cdiv\x3e").css({position:"absolute",width:a.outerWidth(),height:a.outerHeight()}).appendTo(a.parent()).offset(a.offset())[0]})},
_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(a){return d(a.target).closest(".ui-dialog").length?!0:!!d(a.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var a=!0;this._delay(function(){a=!1});this.document.data("ui-dialog-overlays")||this._on(this.document,{focusin:function(b){a||this._allowInteraction(b)||(b.preventDefault(),this._trackingInstances()[0]._focusTabbable())}});
this.overlay=d("\x3cdiv\x3e").appendTo(this._appendTo());this._addClass(this.overlay,null,"ui-widget-overlay ui-front");this._on(this.overlay,{mousedown:"_keepFocus"});this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1)}},_destroyOverlay:function(){if(this.options.modal&&this.overlay){var a=this.document.data("ui-dialog-overlays")-1;a?this.document.data("ui-dialog-overlays",a):(this._off(this.document,"focusin"),this.document.removeData("ui-dialog-overlays"));
this.overlay.remove();this.overlay=null}}});!1!==d.uiBackCompat&&d.widget("ui.dialog",d.ui.dialog,{options:{dialogClass:""},_createWrapper:function(){this._super();this.uiDialog.addClass(this.options.dialogClass)},_setOption:function(a,b){"dialogClass"===a&&this.uiDialog.removeClass(this.options.dialogClass).addClass(b);this._superApply(arguments)}});return d.ui.dialog});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy