text: (function($,undefined){$.ui.grid.dropmenu=function(grid){this.grid=grid;this._create()};$.ui.grid.dropmenu.prototype={_create:function(){var self=this,grid=this.grid,headersNode=grid.headersNode;var dropBtn=this.dropBtn=$("<div class='drop-btn'></div>");headersNode.bind("mousedown.grid-dropmenu",function(e){var target=$(e.target);if(!target.hasClass("drop-btn")){return}var dropMenu=self.dropMenu=self.dropMenu||self.createPopMenu();var columnMarkup=grid.getColumnMarkup(target.parent()),left=dropBtn.offset().left-headersNode.offset().left,top=headersNode.height()-1;if(false==columnMarkup.column.sortable){dropMenu.menu("setDisabled","asc",true);dropMenu.menu("setDisabled","desc",true)}else{dropMenu.menu("setDisabled","asc",false);dropMenu.menu("setDisabled","desc",false)}if(columnMarkup.view==grid.normalView){dropMenu.menu("setDisabled","lock",1==grid.normalView.columns.length);dropMenu.menu("setDisabled","unlock",true)}else{dropMenu.menu("setDisabled","lock",true);dropMenu.menu("setDisabled","unlock",false)}dropMenu.css({top:top+"px",left:left+"px",display:"block"});breeze.stopEvent(e)});headersNode.bind("mouseover.grid-dropmenu",function(e){var target=$(e.target);if(null!=target.attr("idx")){var columnMarkup=grid.getColumnMarkup(target);if(false==columnMarkup.column.dropmenu){return}if(self.dropMenu&&"none"!=self.dropMenu.css("display")){return}target.append(dropBtn);dropBtn.show()}});headersNode.bind("mouseout.grid-dropmenu",function(e){if(dropBtn[0]!=e.relatedTarget&&(!self.dropMenu||"none"==self.dropMenu.css("display"))){dropBtn.hide()}})},createPopMenu:function(){var incoPath=breeze.getBreezeContextPath()+"themes/default/images/",self=this,grid=this.grid,headersNode=grid.headersNode;var dropMenu=$("<div class='dropmenu'></div>").appendTo(headersNode);dropMenu.menu({menuBar:false,closableRoot:true,dataProvider:[{id:"asc",title:"升序",iconURL:incoPath+"grid-menu-asc.gif"},{id:"desc",title:"降序",iconURL:incoPath+"grid-menu-desc.gif"},{seperator:true},{id:"lock",title:"锁定",iconURL:incoPath+"grid-menu-lock.gif"},{id:"unlock",title:"解锁",iconURL:incoPath+"grid-menu-unlock.gif"}],onClick:function(data){var columnMarkup=grid.getColumnMarkup(self.dropBtn.parent());switch(data.id){case"asc":self.grid.publish("sort",[columnMarkup,true]);break;case"desc":self.grid.publish("sort",[columnMarkup,false]);break;case"lock":self.lock(columnMarkup.idx);break;case"unlock":self.unlock(columnMarkup.idx)}},onClose:function(e){var target=$(e.target);if($("div.th",headersNode).index(target)>-1){var columnMarkup=grid.getColumnMarkup(target);if(false!=columnMarkup.column.dropmenu){target.append(self.dropBtn);return}}self.dropBtn.hide()}});return dropMenu},lock:function(index){var grid=this.grid,layout=grid.options.layout;if(1==layout.length){layout.unshift([[]])}var columns=layout[1][0];index=this.getRealPosition(index,columns);var column=columns[index];layout[0][0].push(column);columns.splice(index,1);grid.refresh()},unlock:function(index){var grid=this.grid,layout=grid.options.layout,columns=layout[0][0];index=this.getRealPosition(index,columns);var column=columns[index];layout[1][0].unshift(column);columns.splice(index,1);if(0==columns.length){layout.splice(0,1)}grid.refresh()},getRealPosition:function(index,columns){var vIndex=0;for(var i=0,column;column=columns[i];i++){if(column.hidden){continue}if(index==vIndex){return i}vIndex++}return columns.length-1},destroy:function(){var headersNode=this.grid.headersNode;this.dropBtn&&this.dropBtn.remove();this.dropMenu&&this.dropMenu.remove();headersNode.unbind("mousedown.grid-dropmenu");headersNode.unbind("mouseover.grid-dropmenu");headersNode.unbind("mouseout.grid-dropmenu")}};$.ui.grid.plugins.register("dropmenu",$.ui.grid.dropmenu)})(jQuery);