1 /**
  2  * @fileOverview render aria and drop arrow for menubutton
  3  * @author  yiminghe@gmail.com
  4  */
  5 KISSY.add("menubutton/baseRender", function (S, Button) {
  6 
  7     var CAPTION_TMPL = '<div class="ks-inline-block ' +
  8             'ks-menu-button-caption"><' + '/div>',
  9 
 10         DROP_TMPL =
 11             '<div class="ks-inline-block ' +
 12                 'ks-menu-button-dropdown">' +
 13                 '<div class=' +
 14                 '"ks-menu-button-dropdown-inner">' +
 15                 '<' + '/div>' +
 16                 '<' + '/div>',
 17         COLLAPSE_CLS = "menu-button-open";
 18 
 19     return Button.Render.extend({
 20 
 21         createDom:function () {
 22             var self = this,
 23                 el = self.get("el");
 24             el.append(DROP_TMPL)
 25                 //带有 menu
 26                 .attr("aria-haspopup", true);
 27         },
 28 
 29         _uiSetCollapsed:function (v) {
 30             var self = this,
 31                 el = self.get("el"),
 32                 cls = self.getCssClassWithPrefix(COLLAPSE_CLS);
 33             el[v ? 'removeClass' : 'addClass'](cls).attr("aria-expanded", !v);
 34         },
 35 
 36         _uiSetActiveItem:function (v) {
 37             this.get("el").attr("aria-activedescendant",
 38                 (v && v.get("el").attr("id")) || "");
 39         }
 40     }, {
 41         ATTRS:{
 42             contentEl:{
 43                 valueFn:function () {
 44                     return S.all(CAPTION_TMPL);
 45                 }
 46             },
 47             contentElCls:{
 48                 value:"ks-menu-button-caption"
 49             },
 50             activeItem:{
 51             },
 52             collapsed:{
 53                 value:true
 54             }
 55         }
 56     });
 57 }, {
 58     requires:['button']
 59 });