UNPKG

@atlassian/aui

Version:

Atlassian User Interface Framework

20 lines 13.9 kB
/*!! * @atlassian/aui - Atlassian User Interface Framework * @version v8.0.0-alpha.1 * @link https://aui.atlassian.com * @license SEE LICENSE IN LICENSE.md * @author Atlassian Pty Ltd. */ exports.ids=[62],exports.modules={288: /*!******************************!*\ !*** ../src/js/aui/forms.js ***! \******************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.inlineHelp=e.enable=void 0;var n=a(i(/*! ./jquery */0)),o=a(i(/*! ./internal/globalize */1));function a(t){return t&&t.__esModule?t:{default:t}}function s(t,e){var i=(0,n.default)(t);return void 0===e&&(e=!0),i.each(function(){this.disabled=!e})}function h(){(0,n.default)(".icon-inline-help").click(function(){var t=(0,n.default)(this).siblings(".field-help");t.hasClass("hidden")?t.removeClass("hidden"):t.addClass("hidden")})}(0,o.default)("enable",s),(0,o.default)("inlineHelp",h),e.enable=s,e.inlineHelp=h},80: /*!*******************************!*\ !*** ../src/js/aui/dialog.js ***! \*******************************/ /*! no static exports found */ /*! all exports used */ /*! ModuleConcatenation bailout: Module is not an ECMAScript module */function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.popup=e.Dialog=void 0;var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=c(i(/*! ./jquery */0)),a=c(i(/*! ./key-code */8)),s=d(i(/*! ./internal/log */6)),h=d(i(/*! ./internal/deprecation */9)),u=i(/*! ./event */81),l=i(/*! ./blanket */79),p=i(/*! ./forms */288),r=c(i(/*! ./internal/globalize */1));function d(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}function c(t){return t&&t.__esModule?t:{default:t}}function g(t){var e={width:800,height:600,closeOnOutsideClick:!1,keypressListener:function(t){t.keyCode===a.default.ESCAPE&&i.is(":visible")&&d.hide()}};"object"!==(void 0===t?"undefined":n(t))&&(t={width:arguments[0],height:arguments[1],id:arguments[2]},t=o.default.extend({},t,arguments[3])),t=o.default.extend({},e,t);var i=(0,o.default)("<div></div>").addClass("aui-popup");t.id&&i.attr("id",t.id);var s=3e3;(0,o.default)(".aui-dialog").each(function(){var t=(0,o.default)(this);s=t.css("z-index")>s?t.css("z-index"):s});var h=function e(n,o){return t.width=n=n||t.width,t.height=o=o||t.height,i.css({marginTop:-Math.round(o/2)+"px",marginLeft:-Math.round(n/2)+"px",width:n,height:o,"z-index":parseInt(s,10)+2}),e}(t.width,t.height);(0,o.default)("body").append(i),i.hide(),(0,p.enable)(i);var u=(0,o.default)(".aui-blanket"),r=function(t,e){var i=(0,o.default)(t,e);return!!i.length&&(i.focus(),!0)},d={changeSize:function(e,i){(e&&e!=t.width||i&&i!=t.height)&&h(e,i),this.show()},show:function(){var e=function(){(0,o.default)(document).off("keydown",t.keypressListener).on("keydown",t.keypressListener),(0,l.dim)(),0!==(u=(0,o.default)(".aui-blanket")).length&&t.closeOnOutsideClick&&u.click(function(){i.is(":visible")&&d.hide()}),i.show(),g.current=this,function(e){if(0===(0,o.default)(".dialog-page-body",e).find(":focus").length){if(t.focusSelector)return r(t.focusSelector,e);r(":input:visible:enabled:first",(0,o.default)(".dialog-page-body",e))||r(":input:visible:enabled:first",(0,o.default)(".dialog-button-panel",e))||r(":input:visible:enabled:first",(0,o.default)(".dialog-page-menu",e))}}(i),(0,o.default)(document).trigger("showLayer",["popup",this])};e.call(this),this.show=e},hide:function(){(0,o.default)(document).unbind("keydown",t.keypressListener),u.unbind(),this.element.hide(),0===(0,o.default)(".aui-dialog:visible").length&&(0,l.undim)();var e=document.activeElement;this.element.has(e).length&&e.blur(),(0,o.default)(document).trigger("hideLayer",["popup",this]),g.current=null,this.enable()},element:i,remove:function(){i.remove(),this.element=null},disable:function(){this.disabled||(this.popupBlanket=(0,o.default)("<div class='dialog-blanket'> </div>").css({height:i.height(),width:i.width()}),i.append(this.popupBlanket),this.disabled=!0)},enable:function(){this.disabled&&(this.disabled=!1,this.popupBlanket.remove(),this.popupBlanket=null)}};return d}var f=function(){function t(t,e,i,n){t.buttonpanel||t.addButtonPanel(),this.page=t,this.onclick=i,this._onclick=function(e){return!0===i.call(this,t.dialog,t,e)},this.item=(0,o.default)("<button></button>").html(e).addClass("button-panel-button"),n&&this.item.addClass(n),"function"==typeof i&&this.item.click(this._onclick),t.buttonpanel.append(this.item),this.id=t.button.length,t.button[this.id]=this}function e(t,e){var i="left"==t?-1:1;return function(t){var n=this.page[e];if(this.id!=(1==i?n.length-1:0)){i*=t||1,n[this.id+i].item[i<0?"before":"after"](this.item),n.splice(this.id,1),n.splice(this.id+i,0,this);for(var o=0,a=n.length;o<a;o++)"panel"==e&&this.page.curtab==n[o].id&&(this.page.curtab=o),n[o].id=o}return this}}function i(t){return function(){this.page[t].splice(this.id,1);for(var e=0,i=this.page[t].length;e<i;e++)this.page[t][e].id=e;this.item.remove()}}t.prototype.moveUp=t.prototype.moveLeft=e("left","button"),t.prototype.moveDown=t.prototype.moveRight=e("right","button"),t.prototype.remove=i("button"),t.prototype.html=function(t){return this.item.html(t)},t.prototype.onclick=function(t){var e=this;if(void 0===t)return this.onclick;this.item.unbind("click",this._onclick),this._onclick=function(i){return!0===t.call(this,e.page.dialog,e.page,i)},"function"==typeof t&&this.item.click(this._onclick)};var n=function(t,e,i,n,a){i instanceof o.default||(i=(0,o.default)(i)),this.dialog=t.dialog,this.page=t,this.id=t.panel.length,this.button=(0,o.default)("<button></button>").html(e).addClass("item-button"),a&&(this.button[0].id=a),this.item=(0,o.default)("<li></li>").append(this.button).addClass("page-menu-item"),this.body=(0,o.default)("<div></div>").append(i).addClass("dialog-panel-body").css("height",t.dialog.height+"px"),this.padding=20,n&&this.body.addClass(n);var h=t.panel.length,u=this;t.menu.append(this.item),t.body.append(this.body),t.panel[h]=this;var l=function(){var e;t.curtab+1&&((e=t.panel[t.curtab]).body.hide(),e.item.removeClass("selected"),"function"==typeof e.onblur&&e.onblur()),t.curtab=u.id,u.body.show(),u.item.addClass("selected"),"function"==typeof u.onselect&&u.onselect(),"function"==typeof t.ontabchange&&t.ontabchange(u,e)};this.button.click?this.button.click(l):(s.log("atlassian-dialog:Panel:constructor - this.button.click false"),this.button.onclick=l),l(),0==h?t.menu.css("display","none"):t.menu.show()};n.prototype.select=function(){this.button.click()},n.prototype.moveUp=n.prototype.moveLeft=e("left","panel"),n.prototype.moveDown=n.prototype.moveRight=e("right","panel"),n.prototype.remove=i("panel"),n.prototype.html=function(t){return t?(this.body.html(t),this):this.body.html()},n.prototype.setPadding=function(t){return isNaN(+t)||(this.body.css("padding",+t),this.padding=+t,this.page.recalcSize()),this};var a=function(t,e){this.dialog=t,this.id=t.page.length,this.element=(0,o.default)("<div></div>").addClass("dialog-components"),this.body=(0,o.default)("<div></div>").addClass("dialog-page-body"),this.menu=(0,o.default)("<ul></ul>").addClass("dialog-page-menu").css("height",t.height+"px"),this.body.append(this.menu),this.curtab,this.panel=[],this.button=[],e&&this.body.addClass(e),t.popup.element.append(this.element.append(this.menu).append(this.body)),t.page[t.page.length]=this};function h(t,e,i){var n={};+t||(t=(n=Object(t)).width,e=n.height,i=n.id),this.height=e||480,this.width=t||640,this.id=i,n=o.default.extend({},n,{width:this.width,height:this.height,id:this.id}),this.popup=g(n),this.popup.element.addClass("aui-dialog"),this.page=[],this.curpage=0,new a(this)}return a.prototype.recalcSize=function(){for(var t=this.header?62:0,e=this.buttonpanel?52:0,i=this.panel.length;i--;){var n=this.dialog.height-t-e;this.panel[i].body.css("height",n),this.menu.css("height",n)}},a.prototype.addButtonPanel=function(){this.buttonpanel=(0,o.default)("<div></div>").addClass("dialog-button-panel"),this.element.append(this.buttonpanel)},a.prototype.addPanel=function(t,e,i,o){return new n(this,t,e,i,o),this.recalcSize(),this},a.prototype.addHeader=function(t,e){return this.header&&this.header.remove(),this.header=(0,o.default)("<h2></h2>").text(t||"").addClass("dialog-title"),e&&this.header.addClass(e),this.element.prepend(this.header),this.recalcSize(),this},a.prototype.addButton=function(e,i,n){return new t(this,e,i,n),this.recalcSize(),this},a.prototype.addLink=function(t,e,i,n){return new function(t,e,i,n,a){t.buttonpanel||t.addButtonPanel(),a||(a="#"),this.page=t,this.onclick=i,this._onclick=function(e){return!0===i.call(this,t.dialog,t,e)},this.item=(0,o.default)("<a></a>").html(e).attr("href",a).addClass("button-panel-link"),n&&this.item.addClass(n),"function"==typeof i&&this.item.click(this._onclick),t.buttonpanel.append(this.item),this.id=t.button.length,t.button[this.id]=this}(this,t,e,i,n),this.recalcSize(),this},a.prototype.gotoPanel=function(t){this.panel[t.id||t].select()},a.prototype.getCurrentPanel=function(){return this.panel[this.curtab]},a.prototype.hide=function(){this.element.hide()},a.prototype.show=function(){this.element.show()},a.prototype.remove=function(){this.element.remove()},h.prototype.addHeader=function(t,e){return this.page[this.curpage].addHeader(t,e),this},h.prototype.addButton=function(t,e,i){return this.page[this.curpage].addButton(t,e,i),this},h.prototype.addLink=function(t,e,i,n){return this.page[this.curpage].addLink(t,e,i,n),this},h.prototype.addSubmit=function(t,e){return this.page[this.curpage].addButton(t,e,"button-panel-submit-button"),this},h.prototype.addCancel=function(t,e){return this.page[this.curpage].addLink(t,e,"button-panel-cancel-link"),this},h.prototype.addButtonPanel=function(){return this.page[this.curpage].addButtonPanel(),this},h.prototype.addPanel=function(t,e,i,n){return this.page[this.curpage].addPanel(t,e,i,n),this},h.prototype.addPage=function(t){return new a(this,t),this.page[this.curpage].hide(),this.curpage=this.page.length-1,this},h.prototype.nextPage=function(){return this.page[this.curpage++].hide(),this.curpage>=this.page.length&&(this.curpage=0),this.page[this.curpage].show(),this},h.prototype.prevPage=function(){return this.page[this.curpage--].hide(),this.curpage<0&&(this.curpage=this.page.length-1),this.page[this.curpage].show(),this},h.prototype.gotoPage=function(t){return this.page[this.curpage].hide(),this.curpage=t,this.curpage<0?this.curpage=this.page.length-1:this.curpage>=this.page.length&&(this.curpage=0),this.page[this.curpage].show(),this},h.prototype.getPanel=function(t,e){var i=null==e?this.curpage:t;return null==e&&(e=t),this.page[i].panel[e]},h.prototype.getPage=function(t){return this.page[t]},h.prototype.getCurrentPanel=function(){return this.page[this.curpage].getCurrentPanel()},h.prototype.gotoPanel=function(t,e){if(null!=e){var i=t.id||t;this.gotoPage(i)}this.page[this.curpage].gotoPanel(void 0===e?t:e)},h.prototype.show=function(){return this.popup.show(),(0,u.trigger)("show.dialog",{dialog:this}),this},h.prototype.hide=function(){return this.popup.hide(),(0,u.trigger)("hide.dialog",{dialog:this}),this},h.prototype.remove=function(){this.popup.hide(),this.popup.remove(),(0,u.trigger)("remove.dialog",{dialog:this})},h.prototype.disable=function(){return this.popup.disable(),this},h.prototype.enable=function(){return this.popup.enable(),this},h.prototype.get=function(t){var e=[],i=this,n='(?:(page|panel|button|header)(?:#([^"][^ ]*|"[^"]*")|:(\\d+))?|#([^"][^ ]*|"[^"]*"))',o=new RegExp("(?:^|,)\\s*"+n+"(?:\\s+"+n+")?\\s*(?=,|$)","ig");(t+"").replace(o,function(t,n,o,a,s,h,u,l,p){var r=[];if("page"==(n=n&&n.toLowerCase())&&i.page[a]?(r.push(i.page[a]),n=(n=h)&&n.toLowerCase(),o=u,a=l,s=p):r=i.page,o=o&&(o+"").replace(/"/g,""),u=u&&(u+"").replace(/"/g,""),s=s&&(s+"").replace(/"/g,""),p=p&&(p+"").replace(/"/g,""),n||s)for(var d=r.length;d--;){if(s||"panel"==n&&(o||!o&&null==a))for(var c=r[d].panel.length;c--;)(r[d].panel[c].button.html()==s||r[d].panel[c].button.html()==o||"panel"==n&&!o&&null==a)&&e.push(r[d].panel[c]);if(s||"button"==n&&(o||!o&&null==a))for(c=r[d].button.length;c--;)(r[d].button[c].item.html()==s||r[d].button[c].item.html()==o||"button"==n&&!o&&null==a)&&e.push(r[d].button[c]);r[d][n]&&r[d][n][a]&&e.push(r[d][n][a]),"header"==n&&r[d].header&&e.push(r[d].header)}else e=e.concat(r)});for(var a={length:e.length},s=e.length;s--;)for(var h in a[s]=e[s],e[s])h in a||function(t){a[t]=function(){for(var e=this.length;e--;)"function"==typeof this[e][t]&&this[e][t].apply(this[e],arguments)}}(h);return a},h.prototype.updateHeight=function(){for(var t=0,e=(0,o.default)(window).height()-62-52-100,i=0;this.getPanel(i);i++)this.getPanel(i).body.css({height:"auto",display:"block"}).outerHeight()>t&&(t=Math.min(e,this.getPanel(i).body.outerHeight())),i!==this.page[this.curpage].curtab&&this.getPanel(i).body.css({display:"none"});for(i=0;this.getPanel(i);i++)this.getPanel(i).body.css({height:t||this.height});this.page[0].menu.height(t),this.height=t+62+52+1,this.popup.changeSize(void 0,this.height)},h.prototype.isMaximised=function(){return this.popup.element.outerHeight()>=(0,o.default)(window).height()-100},h.prototype.getCurPanel=function(){return this.getPanel(this.page[this.curpage].curtab)},h.prototype.getCurPanelButton=function(){return this.getCurPanel().button},h}();e.Dialog=f=h.construct(f,"Dialog constructor",{alternativeName:"Dialog2"}),e.popup=g=h.construct(g,"Dialog popup constructor",{alternatveName:"Dialog2"}),(0,r.default)("Dialog",f),(0,r.default)("popup",g),e.Dialog=f,e.popup=g}};