"),this.initialized=!1,this.narrowThreshold=null,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,'
'),this.$element.addClass("oo-ui-toolbar oo-ui-toolbar-position-"+this.position).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");if(!b.length||b[0]===c[0])return!1},a.ui.Toolbar.prototype.onWindowResize=function(){this.$element.toggleClass("oo-ui-toolbar-narrow",this.$bar.width()<=this.getNarrowThreshold())},a.ui.Toolbar.prototype.getNarrowThreshold=function(){return null===this.narrowThreshold&&(this.narrowThreshold=this.$group.width()+this.$actions.width()),this.narrowThreshold},a.ui.Toolbar.prototype.initialize=function(){this.initialized||(this.initialized=!0,$(this.getElementWindow()).on("resize",this.onWindowResizeHandler),this.onWindowResize())},a.ui.Toolbar.prototype.setup=function(b){var c,d,e,f,g=[];for(this.reset(),c=0,d=b.length;c
"),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.setFlags({progressive:!0})):(this.$element.removeClass("oo-ui-tool-active"),this.setFlags({progressive:!1}))},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.static.name=null,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){if(!this.isDisabled()&&(b.which===a.ui.MouseButtons.LEFT||b.which===a.ui.Keys.SPACE||b.which===a.ui.Keys.ENTER))return 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;a"),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){if(!this.isDisabled()&&(b.which===a.ui.MouseButtons.LEFT||b.which===a.ui.Keys.SPACE||b.which===a.ui.Keys.ENTER))return!1},a.ui.PopupToolGroup.prototype.onHandleMouseKeyDown=function(b){if(!this.isDisabled()&&(b.which===a.ui.MouseButtons.LEFT||b.which===a.ui.Keys.SPACE||b.which===a.ui.Keys.ENTER))return 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,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;b