1 /**
  2  * @fileOverview Render aria properties to input element.
  3  * @author yiminghe@gmail.com
  4  */
  5 KISSY.add("combobox/baseRender", function (S, Component) {
  6 
  7     var tpl = '<div class="ks-combobox-input-wrap">' +
  8             '</div>',
  9         triggerTpl = '<div class="ks-combobox-trigger">' +
 10             '<div class="ks-combobox-trigger-inner">▼</div>' +
 11             '</div>',
 12         inputTpl = '<input ' +
 13             'aria-haspopup="true" ' +
 14             'aria-combobox="list" ' +
 15             'aria-haspopup="true" ' +
 16             'role="combobox" ' +
 17             'combobox="off" ' +
 18             'class="ks-combobox-input" />';
 19 
 20     return Component.Render.extend({
 21 
 22         createDom:function () {
 23             var self = this,
 24                 wrap,
 25                 input,
 26                 el = self.get("el"),
 27                 trigger = self.get("trigger");
 28 
 29             if (!self.get("srcNode")) {
 30                 el.append(tpl);
 31                 wrap = el.one(".ks-combobox-input-wrap");
 32                 input = self.get("input") || S.all(inputTpl);
 33                 wrap.append(input);
 34                 self.__set("input", input);
 35             }
 36             if (!trigger) {
 37                 self.__set("trigger", S.all(triggerTpl));
 38             }
 39 
 40             self.get("trigger").unselectable();
 41         },
 42 
 43         getKeyEventTarget:function () {
 44             return this.get("input");
 45         },
 46 
 47         _uiSetCollapsed:function (v) {
 48             this.get("input").attr("aria-expanded", v);
 49         },
 50 
 51         _uiSetHasTrigger:function (t) {
 52             var trigger = this.get("trigger");
 53             if (t) {
 54                 this.get("el").prepend(trigger);
 55             } else {
 56                 trigger.remove();
 57             }
 58         }
 59     }, {
 60         ATTRS:{
 61             collapsed:{},
 62             hasTrigger:{
 63                 value:true
 64             },
 65             input:{},
 66             trigger:{}
 67         },
 68         HTML_PARSER:{
 69             input:function (el) {
 70                 return el.one(".ks-combobox-input");
 71             },
 72             trigger:function (el) {
 73                 return el.one(".ks-combobox-trigger");
 74             }
 75         }
 76     });
 77 }, {
 78     requires:['component']
 79 });