"),this.initialized=!1,this.onWindowResizeHandler=this.onWindowResize.bind(this),this.$element.add(this.$bar).add(this.$group).add(this.$actions).on("mousedown keydown",this.onPointerDown.bind(this)),this.$group.addClass("oo-ui-toolbar-tools"),d.actions&&this.$bar.append(this.$actions.addClass("oo-ui-toolbar-actions")),this.$bar.addClass("oo-ui-toolbar-bar").append(this.$group,'
'),d.shadow&&this.$bar.append('
'),this.$element.addClass("oo-ui-toolbar").append(this.$bar)},a.inheritClass(a.ui.Toolbar,a.ui.Element),a.mixinClass(a.ui.Toolbar,a.EventEmitter),a.mixinClass(a.ui.Toolbar,a.ui.mixin.GroupElement),a.ui.Toolbar.prototype.getToolFactory=function(){return this.toolFactory},a.ui.Toolbar.prototype.getToolGroupFactory=function(){return this.toolGroupFactory},a.ui.Toolbar.prototype.onPointerDown=function(a){var b=$(a.target).closest(".oo-ui-widget"),c=this.$element.closest(".oo-ui-widget");return b.length&&b[0]!==c[0]?void 0:!1},a.ui.Toolbar.prototype.onWindowResize=function(){this.$element.toggleClass("oo-ui-toolbar-narrow",this.$bar.width()<=this.narrowThreshold)},a.ui.Toolbar.prototype.initialize=function(){this.initialized||(this.initialized=!0,this.narrowThreshold=this.$group.width()+this.$actions.width(),$(this.getElementWindow()).on("resize",this.onWindowResizeHandler),this.onWindowResize())},a.ui.Toolbar.prototype.setup=function(b){var c,d,e,f,g=[],h="bar";for(this.reset(),c=0,d=b.length;d>c;c++)f=b[c],"*"===f.include&&(void 0===f.type&&(f.type="list"),void 0===f.label&&(f.label=a.ui.msg("ooui-toolbar-more"))),e=this.getToolGroupFactory().lookup(f.type)?f.type:h,g.push(this.getToolGroupFactory().create(e,this,f));this.addItems(g)},a.ui.Toolbar.prototype.reset=function(){var a,b;for(this.groups=[],this.tools={},a=0,b=this.items.length;b>a;a++)this.items[a].destroy();this.clearItems()},a.ui.Toolbar.prototype.destroy=function(){$(this.getElementWindow()).off("resize",this.onWindowResizeHandler),this.reset(),this.$element.remove()},a.ui.Toolbar.prototype.isToolAvailable=function(a){return!this.tools[a]},a.ui.Toolbar.prototype.reserveTool=function(a){this.tools[a.getName()]=a},a.ui.Toolbar.prototype.releaseTool=function(a){delete this.tools[a.getName()]},a.ui.Toolbar.prototype.getToolAccelerator=function(){},a.ui.Tool=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolGroup),c=c||{},a.ui.Tool.parent.call(this,c),this.toolGroup=b,this.toolbar=this.toolGroup.getToolbar(),this.active=!1,this.$title=$("
"),this.$accel=$(""),this.$link=$(""),this.title=null,a.ui.mixin.IconElement.call(this,c),a.ui.mixin.FlaggedElement.call(this,c),a.ui.mixin.TabIndexedElement.call(this,$.extend({},c,{$tabIndexed:this.$link})),this.toolbar.connect(this,{updateState:"onUpdateState"}),this.$title.addClass("oo-ui-tool-title"),this.$accel.addClass("oo-ui-tool-accel").prop({dir:"ltr",lang:"en"}),this.$link.addClass("oo-ui-tool-link").append(this.$icon,this.$title,this.$accel).attr("role","button"),this.$element.data("oo-ui-tool",this).addClass("oo-ui-tool oo-ui-tool-name-"+this.constructor["static"].name.replace(/^([^\/]+)\/([^\/]+).*$/,"$1-$2")).toggleClass("oo-ui-tool-with-label",this.constructor["static"].displayBothIconAndLabel).append(this.$link),this.setTitle(c.title||this.constructor["static"].title)},a.inheritClass(a.ui.Tool,a.ui.Widget),a.mixinClass(a.ui.Tool,a.ui.mixin.IconElement),a.mixinClass(a.ui.Tool,a.ui.mixin.FlaggedElement),a.mixinClass(a.ui.Tool,a.ui.mixin.TabIndexedElement),a.ui.Tool["static"].tagName="span",a.ui.Tool["static"].name="",a.ui.Tool["static"].group="",a.ui.Tool["static"].title="",a.ui.Tool["static"].displayBothIconAndLabel=!1,a.ui.Tool["static"].autoAddToCatchall=!0,a.ui.Tool["static"].autoAddToGroup=!0,a.ui.Tool["static"].isCompatibleWith=function(){return!1},a.ui.Tool.prototype.onUpdateState=null,a.ui.Tool.prototype.onSelect=null,a.ui.Tool.prototype.isActive=function(){return this.active},a.ui.Tool.prototype.setActive=function(a){this.active=!!a,this.active?this.$element.addClass("oo-ui-tool-active"):this.$element.removeClass("oo-ui-tool-active")},a.ui.Tool.prototype.setTitle=function(b){return this.title=a.ui.resolveMsg(b),this.updateTitle(),this},a.ui.Tool.prototype.getTitle=function(){return this.title},a.ui.Tool.prototype.getName=function(){return this.constructor["static"].name},a.ui.Tool.prototype.updateTitle=function(){var a=this.toolGroup.constructor["static"].titleTooltips,b=this.toolGroup.constructor["static"].accelTooltips,c=this.toolbar.getToolAccelerator(this.constructor["static"].name),d=[];this.$title.text(this.title),this.$accel.text(c),a&&"string"==typeof this.title&&this.title.length&&d.push(this.title),b&&"string"==typeof c&&c.length&&d.push(c),d.length?this.$link.attr("title",d.join(" ")):this.$link.removeAttr("title")},a.ui.Tool.prototype.destroy=function(){this.toolbar.disconnect(this),this.$element.remove()},a.ui.ToolGroup=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolbar),c=c||{},a.ui.ToolGroup.parent.call(this,c),a.ui.mixin.GroupElement.call(this,c),this.toolbar=b,this.tools={},this.pressed=null,this.autoDisabled=!1,this.include=c.include||[],this.exclude=c.exclude||[],this.promote=c.promote||[],this.demote=c.demote||[],this.onCapturedMouseKeyUpHandler=this.onCapturedMouseKeyUp.bind(this),this.$element.on({mousedown:this.onMouseKeyDown.bind(this),mouseup:this.onMouseKeyUp.bind(this),keydown:this.onMouseKeyDown.bind(this),keyup:this.onMouseKeyUp.bind(this),focus:this.onMouseOverFocus.bind(this),blur:this.onMouseOutBlur.bind(this),mouseover:this.onMouseOverFocus.bind(this),mouseout:this.onMouseOutBlur.bind(this)}),this.toolbar.getToolFactory().connect(this,{register:"onToolFactoryRegister"}),this.aggregate({disable:"itemDisable"}),this.connect(this,{itemDisable:"updateDisabled"}),this.$group.addClass("oo-ui-toolGroup-tools"),this.$element.addClass("oo-ui-toolGroup").append(this.$group),this.populate()},a.inheritClass(a.ui.ToolGroup,a.ui.Widget),a.mixinClass(a.ui.ToolGroup,a.ui.mixin.GroupElement),a.ui.ToolGroup["static"].titleTooltips=!1,a.ui.ToolGroup["static"].accelTooltips=!1,a.ui.ToolGroup["static"].autoDisable=!0,a.ui.ToolGroup.prototype.isDisabled=function(){return this.autoDisabled||a.ui.ToolGroup.parent.prototype.isDisabled.apply(this,arguments)},a.ui.ToolGroup.prototype.updateDisabled=function(){var b,c,d=!0;if(this.constructor["static"].autoDisable){for(b=this.items.length-1;b>=0;b--)if(c=this.items[b],!c.isDisabled()){d=!1;break}this.autoDisabled=d}a.ui.ToolGroup.parent.prototype.updateDisabled.apply(this,arguments)},a.ui.ToolGroup.prototype.onMouseKeyDown=function(b){return this.isDisabled()||b.which!==a.ui.MouseButtons.LEFT&&b.which!==a.ui.Keys.SPACE&&b.which!==a.ui.Keys.ENTER?void 0:(this.pressed=this.getTargetTool(b),this.pressed&&(this.pressed.setActive(!0),this.getElementDocument().addEventListener("mouseup",this.onCapturedMouseKeyUpHandler,!0),this.getElementDocument().addEventListener("keyup",this.onCapturedMouseKeyUpHandler,!0)),!1)},a.ui.ToolGroup.prototype.onCapturedMouseKeyUp=function(a){this.getElementDocument().removeEventListener("mouseup",this.onCapturedMouseKeyUpHandler,!0),this.getElementDocument().removeEventListener("keyup",this.onCapturedMouseKeyUpHandler,!0),this.onMouseKeyUp(a)},a.ui.ToolGroup.prototype.onMouseKeyUp=function(b){var c=this.getTargetTool(b);this.isDisabled()||!this.pressed||this.pressed!==c||b.which!==a.ui.MouseButtons.LEFT&&b.which!==a.ui.Keys.SPACE&&b.which!==a.ui.Keys.ENTER||(this.pressed.onSelect(),this.pressed=null,b.preventDefault(),b.stopPropagation()),this.pressed=null},a.ui.ToolGroup.prototype.onMouseOverFocus=function(a){var b=this.getTargetTool(a);this.pressed&&this.pressed===b&&this.pressed.setActive(!0)},a.ui.ToolGroup.prototype.onMouseOutBlur=function(a){var b=this.getTargetTool(a);this.pressed&&this.pressed===b&&this.pressed.setActive(!1)},a.ui.ToolGroup.prototype.getTargetTool=function(a){var b,c=$(a.target).closest(".oo-ui-tool-link");return c.length&&(b=c.parent().data("oo-ui-tool")),b&&!b.isDisabled()?b:null},a.ui.ToolGroup.prototype.onToolFactoryRegister=function(){this.populate()},a.ui.ToolGroup.prototype.getToolbar=function(){return this.toolbar},a.ui.ToolGroup.prototype.populate=function(){var a,b,c,d,e=this.toolbar.getToolFactory(),f={},g=[],h=[],i=this.toolbar.getToolFactory().getTools(this.include,this.exclude,this.promote,this.demote);for(a=0,b=i.length;b>a;a++)c=i[a],e.lookup(c)&&(this.toolbar.isToolAvailable(c)||this.tools[c])&&(this.toolbar.tools[c]=!0,d=this.tools[c],d||(this.tools[c]=d=e.create(c,this),d.updateTitle()),this.toolbar.reserveTool(d),g.push(d),f[c]=!0);for(c in this.tools)f[c]||(this.tools[c].destroy(),this.toolbar.releaseTool(this.tools[c]),h.push(this.tools[c]),delete this.tools[c]);h.length&&this.removeItems(h),g.length?this.$element.removeClass("oo-ui-toolGroup-empty"):this.$element.addClass("oo-ui-toolGroup-empty"),this.addItems(g),this.updateDisabled()},a.ui.ToolGroup.prototype.destroy=function(){var a;this.clearItems(),this.toolbar.getToolFactory().disconnect(this);for(a in this.tools)this.toolbar.releaseTool(this.tools[a]),this.tools[a].disconnect(this).destroy(),delete this.tools[a];this.$element.remove()},a.ui.ToolFactory=function(){a.ui.ToolFactory.parent.call(this)},a.inheritClass(a.ui.ToolFactory,a.Factory),a.ui.ToolFactory.prototype.getTools=function(b,c,d,e){var f,g,h,i,j,k=[],l={};for(h=a.simpleArrayDifference(this.extract(b),this.extract(c)),i=this.extract(d,l),j=this.extract(e,l),f=0,g=h.length;g>f;f++)l[h[f]]||k.push(h[f]);return i.concat(k).concat(j)},a.ui.ToolFactory.prototype.extract=function(b,c){var d,e,f,g,h,i=[];if("*"===b)for(g in this.registry)h=this.registry[g],!h["static"].autoAddToCatchall||c&&c[g]||(i.push(g),c&&(c[g]=!0));else if(Array.isArray(b))for(d=0,e=b.length;e>d;d++)if(f=b[d],"string"==typeof f&&(f={name:f}),a.isPlainObject(f))if(f.group)for(g in this.registry)h=this.registry[g],h["static"].group!==f.group||!h["static"].autoAddToGroup||c&&c[g]||(i.push(g),c&&(c[g]=!0));else!f.name||c&&c[f.name]||(i.push(f.name),c&&(c[f.name]=!0));return i},a.ui.ToolGroupFactory=function(){var b,c,d;for(a.Factory.call(this),d=this.constructor["static"].getDefaultClasses(),b=0,c=d.length;c>b;b++)this.register(d[b])},a.inheritClass(a.ui.ToolGroupFactory,a.Factory),a.ui.ToolGroupFactory["static"].getDefaultClasses=function(){return[a.ui.BarToolGroup,a.ui.ListToolGroup,a.ui.MenuToolGroup]},a.ui.PopupTool=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolGroup),a.ui.PopupTool.parent.call(this,b,c),a.ui.mixin.PopupElement.call(this,c),this.$element.addClass("oo-ui-popupTool").append(this.popup.$element)},a.inheritClass(a.ui.PopupTool,a.ui.Tool),a.mixinClass(a.ui.PopupTool,a.ui.mixin.PopupElement),a.ui.PopupTool.prototype.onSelect=function(){return this.isDisabled()||this.popup.toggle(),this.setActive(!1),!1},a.ui.PopupTool.prototype.onUpdateState=function(){this.setActive(!1)},a.ui.ToolGroupTool=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolGroup),a.ui.ToolGroupTool.parent.call(this,b,c),this.innerToolGroup=this.createGroup(this.constructor["static"].groupConfig),this.innerToolGroup.connect(this,{disable:"onToolGroupDisable"}),this.$link.remove(),this.$element.addClass("oo-ui-toolGroupTool").append(this.innerToolGroup.$element)},a.inheritClass(a.ui.ToolGroupTool,a.ui.Tool),a.ui.ToolGroupTool["static"].groupConfig={},a.ui.ToolGroupTool.prototype.onSelect=function(){return this.innerToolGroup.setActive(!this.innerToolGroup.active),!1},a.ui.ToolGroupTool.prototype.onToolGroupDisable=function(a){this.setDisabled(a)},a.ui.ToolGroupTool.prototype.onUpdateState=function(){this.setActive(!1)},a.ui.ToolGroupTool.prototype.createGroup=function(b){return"*"===b.include&&void 0===b.label&&(b.label=a.ui.msg("ooui-toolbar-more")),this.toolbar.getToolGroupFactory().create("list",this.toolbar,b)},a.ui.BarToolGroup=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolbar),a.ui.BarToolGroup.parent.call(this,b,c),this.$element.addClass("oo-ui-barToolGroup")},a.inheritClass(a.ui.BarToolGroup,a.ui.ToolGroup),a.ui.BarToolGroup["static"].titleTooltips=!0,a.ui.BarToolGroup["static"].accelTooltips=!0,a.ui.BarToolGroup["static"].name="bar",a.ui.PopupToolGroup=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolbar),c=c||{},a.ui.PopupToolGroup.parent.call(this,b,c),this.active=!1,this.dragging=!1,this.onBlurHandler=this.onBlur.bind(this),this.$handle=$(""),a.ui.mixin.IconElement.call(this,c),a.ui.mixin.IndicatorElement.call(this,c),a.ui.mixin.LabelElement.call(this,c),a.ui.mixin.TitledElement.call(this,c),a.ui.mixin.ClippableElement.call(this,$.extend({},c,{$clippable:this.$group})),a.ui.mixin.TabIndexedElement.call(this,$.extend({},c,{$tabIndexed:this.$handle})),this.$handle.on({keydown:this.onHandleMouseKeyDown.bind(this),keyup:this.onHandleMouseKeyUp.bind(this),mousedown:this.onHandleMouseKeyDown.bind(this),mouseup:this.onHandleMouseKeyUp.bind(this)}),this.$handle.addClass("oo-ui-popupToolGroup-handle").append(this.$icon,this.$label,this.$indicator),void 0!==c.header&&this.$group.prepend($("").addClass("oo-ui-popupToolGroup-header").text(c.header)),this.$element.addClass("oo-ui-popupToolGroup").prepend(this.$handle)},a.inheritClass(a.ui.PopupToolGroup,a.ui.ToolGroup),a.mixinClass(a.ui.PopupToolGroup,a.ui.mixin.IconElement),a.mixinClass(a.ui.PopupToolGroup,a.ui.mixin.IndicatorElement),a.mixinClass(a.ui.PopupToolGroup,a.ui.mixin.LabelElement),a.mixinClass(a.ui.PopupToolGroup,a.ui.mixin.TitledElement),a.mixinClass(a.ui.PopupToolGroup,a.ui.mixin.ClippableElement),a.mixinClass(a.ui.PopupToolGroup,a.ui.mixin.TabIndexedElement),a.ui.PopupToolGroup.prototype.setDisabled=function(){a.ui.PopupToolGroup.parent.prototype.setDisabled.apply(this,arguments),this.isDisabled()&&this.isElementAttached()&&this.setActive(!1)},a.ui.PopupToolGroup.prototype.onBlur=function(a){$(a.target).closest(".oo-ui-popupToolGroup")[0]!==this.$element[0]&&this.setActive(!1)},a.ui.PopupToolGroup.prototype.onMouseKeyUp=function(b){return this.isDisabled()||!this.pressed||this.pressed!==this.getTargetTool(b)||b.which!==a.ui.MouseButtons.LEFT&&b.which!==a.ui.Keys.SPACE&&b.which!==a.ui.Keys.ENTER||this.setActive(!1),a.ui.PopupToolGroup.parent.prototype.onMouseKeyUp.call(this,b)},a.ui.PopupToolGroup.prototype.onHandleMouseKeyUp=function(b){return this.isDisabled()||b.which!==a.ui.MouseButtons.LEFT&&b.which!==a.ui.Keys.SPACE&&b.which!==a.ui.Keys.ENTER?void 0:!1},a.ui.PopupToolGroup.prototype.onHandleMouseKeyDown=function(b){return this.isDisabled()||b.which!==a.ui.MouseButtons.LEFT&&b.which!==a.ui.Keys.SPACE&&b.which!==a.ui.Keys.ENTER?void 0:(this.setActive(!this.active),!1)},a.ui.PopupToolGroup.prototype.setActive=function(a){var b,c;a=!!a,this.active!==a&&(this.active=a,a?(this.getElementDocument().addEventListener("mouseup",this.onBlurHandler,!0),this.getElementDocument().addEventListener("keyup",this.onBlurHandler,!0),this.$clippable.css("left",""),this.$element.addClass("oo-ui-popupToolGroup-active oo-ui-popupToolGroup-left"),this.toggleClipping(!0),this.isClippedHorizontally()&&(this.toggleClipping(!1),this.$element.removeClass("oo-ui-popupToolGroup-left").addClass("oo-ui-popupToolGroup-right"),this.toggleClipping(!0)),this.isClippedHorizontally()&&(b=this.$clippableScrollableContainer.width(),c=this.$clippableScrollableContainer.offset().left,this.toggleClipping(!1),this.$element.removeClass("oo-ui-popupToolGroup-right"),this.$clippable.css({left:-(this.$element.offset().left-c),width:b}))):(this.getElementDocument().removeEventListener("mouseup",this.onBlurHandler,!0),this.getElementDocument().removeEventListener("keyup",this.onBlurHandler,!0),this.$element.removeClass("oo-ui-popupToolGroup-active oo-ui-popupToolGroup-left oo-ui-popupToolGroup-right"),this.toggleClipping(!1)))},a.ui.ListToolGroup=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolbar),c=c||{},this.allowCollapse=c.allowCollapse,this.forceExpand=c.forceExpand,this.expanded=void 0!==c.expanded?c.expanded:!1,this.collapsibleTools=[],a.ui.ListToolGroup.parent.call(this,b,c),this.$element.addClass("oo-ui-listToolGroup")},a.inheritClass(a.ui.ListToolGroup,a.ui.PopupToolGroup),a.ui.ListToolGroup["static"].name="list",a.ui.ListToolGroup.prototype.populate=function(){var b,c,d=[];for(a.ui.ListToolGroup.parent.prototype.populate.call(this),void 0!==this.allowCollapse?d=this.allowCollapse:void 0!==this.forceExpand&&(d=a.simpleArrayDifference(Object.keys(this.tools),this.forceExpand)),this.collapsibleTools=[],b=0,c=d.length;c>b;b++)void 0!==this.tools[d[b]]&&this.collapsibleTools.push(this.tools[d[b]]);this.$group.append(this.getExpandCollapseTool().$element),this.getExpandCollapseTool().toggle(0!==this.collapsibleTools.length),this.updateCollapsibleState()},a.ui.ListToolGroup.prototype.getExpandCollapseTool=function(){var b;return void 0===this.expandCollapseTool&&(b=function(){b.parent.apply(this,arguments)},a.inheritClass(b,a.ui.Tool),b.prototype.onSelect=function(){this.toolGroup.expanded=!this.toolGroup.expanded,this.toolGroup.updateCollapsibleState(),this.setActive(!1)},b.prototype.onUpdateState=function(){},b["static"].name="more-fewer",this.expandCollapseTool=new b(this)),this.expandCollapseTool},a.ui.ListToolGroup.prototype.onMouseKeyUp=function(b){return!$(b.target).closest(".oo-ui-tool-name-more-fewer").length||b.which!==a.ui.MouseButtons.LEFT&&b.which!==a.ui.Keys.SPACE&&b.which!==a.ui.Keys.ENTER?a.ui.ListToolGroup.parent.prototype.onMouseKeyUp.call(this,b):a.ui.ListToolGroup.parent.parent.prototype.onMouseKeyUp.call(this,b)},a.ui.ListToolGroup.prototype.updateCollapsibleState=function(){var b,c;for(this.getExpandCollapseTool().setIcon(this.expanded?"collapse":"expand").setTitle(a.ui.msg(this.expanded?"ooui-toolgroup-collapse":"ooui-toolgroup-expand")),b=0,c=this.collapsibleTools.length;c>b;b++)this.collapsibleTools[b].toggle(this.expanded)},a.ui.MenuToolGroup=function(b,c){a.isPlainObject(b)&&void 0===c&&(c=b,b=c.toolbar),c=c||{},a.ui.MenuToolGroup.parent.call(this,b,c),this.toolbar.connect(this,{updateState:"onUpdateState"}),this.$element.addClass("oo-ui-menuToolGroup")},a.inheritClass(a.ui.MenuToolGroup,a.ui.PopupToolGroup),a.ui.MenuToolGroup["static"].name="menu",a.ui.MenuToolGroup.prototype.onUpdateState=function(){var a,b=[];for(a in this.tools)this.tools[a].isActive()&&b.push(this.tools[a].getTitle());this.setLabel(b.join(", ")||" ")}}(OO);
//# sourceMappingURL=oojs-ui-toolbars.min.js.map