//splitbutton 类 ///import button UM.ui.define('splitbutton',{ tpl :'
data-original-title="${title}"<%/if%>>
<%if: ${icon}%>
<%/if%><%if: ${text}%>${text}<%/if%>
'+ '
'+ '
<\/div>'+ '
'+ '
', defaultOpt:{ text:'', title:'', click:function(){} }, init : function(options){ var me = this; me.root( $(UM.utils.render(me.tpl, options))); me.root().find('.edui-btn:first').click(function(evt){ if(!me.disabled()){ $.proxy(options.click,me)(); } }); me.root().find('.edui-dropdown-toggle').click(function(){ if(!me.disabled()){ me.trigger('arrowclick') } }); me.root().hover(function () { if(!me.root().hasClass("edui-disabled")){ me.root().toggleClass('edui-hover') } }); return me; }, wrapclick:function(fn,evt){ if(!this.disabled()){ $.proxy(fn,this,evt)() } return this; }, disabled : function(state){ if(state === undefined){ return this.root().hasClass('edui-disabled') } this.root().toggleClass('edui-disabled',state).find('.edui-btn').toggleClass('edui-disabled',state); return this; }, active:function(state){ if(state === undefined){ return this.root().hasClass('edui-active') } this.root().toggleClass('edui-active',state).find('.edui-btn:first').toggleClass('edui-active',state); return this; }, mergeWith:function($obj){ var me = this; me.data('$mergeObj',$obj); $obj.edui().data('$mergeObj',me.root()); if(!$.contains(document.body,$obj[0])){ $obj.appendTo(me.root()); } me.root().delegate('.edui-dropdown-toggle','click',function(){ me.wrapclick(function(){ $obj.edui().show(); }) }); me.register('click',me.root().find('.edui-dropdown-toggle'),function(evt){ $obj.hide() }); } });