(function(){var t=u8.device.touch?"tap":"click";u8.Base.Widgets.ActionsMixIn=new function(){};$.extend(u8.Base.Widgets.ActionsMixIn,{"Actions.show":function(t){if(typeof t=="undefined"){t=true}else if(typeof t!="boolean"){t=!!t}this.disabled=!t;this["Actions.update"]("layout")},"Actions.getElement":function(t){var i=this.$(this.element).find("."+this.theme.css.actions);if(arguments.length<1||t<0){return i[0]}var e=i.children("span."+this.theme.css.action+":eq("+t+")");return e[0]},"Actions.createView":function(){if(!this.actions){return undefined}var i=this.$;var e=i("<div />").addClass("u8-actions").addClass(this.theme.css.actions);var n,s,a=this.actions?this.actions.length:0;for(var o=0;o<a;o++){var c=this.actions[o];n=i("<span/>").data("u8_action",c).addClass("u8-action").addClass(this.theme.css.action);if(!this.designer){n.on(t,this._onActionClick.bind(this))}s=i("<img />").sprite(c.image).appendTo(n);if(!c.noFocus&&!this.designer){n.attr("tabIndex",this.tabIndex||0).on("keypress",this._onActionKeyPress.bind(this))}var r=c.title;if(r){s.attr("title",r.format())}n.appendTo(e)}return e},"Actions.update":function(t){if(this._isDisposed){return}if(typeof t=="string"){t={reason:t}}if(!t){t={}}var i=this.$(this["Actions.getElement"]());if(!i.length){return}if("index"in t){var e=t&&t.index;var n=this.actions&&this.actions[e];if(!n){return}var s=i.children("span."+this.theme.css.action+":eq("+e+")");var a=s.children(".img");if(n.title){a.attr("title",n.title)}else{a.removeAttr("title")}a.sprite(n.image)}else if(t.reason=="layout"){var o=false;if(this.autoDisableActions!==false){if(this.disabled){for(var c=0;c<this.actions.length;c++){if(this.actions[c].forceShow){i.children("span."+this.theme.css.action).show()}else{i.children("span."+this.theme.css.action+":eq("+c+")").hide();o=true}}}else{i.children("span."+this.theme.css.action).show();i.show()}}if(this["Actions.layout"]===false){return}if(!o&&!i.is(":visible")&&!i.is(":empty")){i.one("appear",this["Actions.update"].bind(this,t));return}i.css("width","");var r=i.width(),h={top:0,bottom:0,right:0,width:r+1};if(this["Actions.onPreLayout"]){this["Actions.onPreLayout"](this,h)}i.css(h)}else if(t.reason=="create"){if(t.actions){this.actions=t.actions}i.replaceWith(this["Actions.createView"]());this["Actions.update"]("layout")}},_onActionClick:function(t){var i=this.$(t.currentTarget).data("u8_action");var e={action:i,cancelEvent:false,element:t.currentTarget,elEvent:t};this._onAction(e);if(e.cancelEvent){return false}},_onActionKeyPress:function(t){var i=t.keyCode||t.charCode;if(i!=32){return undefined}var e=this.$(t.currentTarget).closest("span."+this.theme.css.action).data("u8_action");var n={action:e,cancelEvent:false,elEvent:t};this._onAction(n);if(n.cancelEvent){return false}},_onAction:function(t){if(t.action.command){t.command=t.action.command;if(t.action.commandArguments){t.commandArguments=$.extend({},t.action.commandArguments)}else{t.commandArguments=t}}var i=this["Actions.onPreExecute"];if(i){i.call(this,t)}this.raise("Action",t);if(t.cancel){return}if(t.command){$w(this.element).$command(this,t.command,t.commandArguments)}}})})();