1 /**
  2  *
  3  * autocomplete.js
  4  *
  5  * @fileOverView 自动完成组件
  6  * @author  <a href="mailto:chenzheng.carl@snda.com">CarlChen</a>
  7  * @date    2012-10-31
  8  */
  9 define(["core"], function() {
 10 
 11     var _ContainerHtml = [
 12         '<div class="we_option_box" style="display: none;" attr="inner:root"></div>'
 13     ].join('');
 14 
 15     var _Html = [
 16         '<div class="we_option_list" style="height: 150px;overflow-y: auto;">',
 17         '<p class="we_option_txt">$title$</p>',
 18         '<ul class="we_list" attr="inner:datasource"></ul>',
 19         '</div>'
 20     ].join('');
 21 
 22     /**
 23      * 自动完成组件
 24      *
 25      * @lends $we.widget.Autocomplete
 26      */
 27     $we.widget.reg("Autocomplete", {
 28         /**
 29          * 自动完成组件接口
 30          *
 31          * @memberOf $we.widget.Autocomplete-
 32          */
 33         interfaces:{
 34             /**
 35              * 渲染数据
 36              */
 37             renderData:function ()
 38             {
 39             },
 40 
 41             /**
 42              * 显示
 43              */
 44             show:function ()
 45             {
 46                 $(this.node['root']).show();
 47                 this.renderData();
 48             },
 49 
 50             /**
 51              * 隐藏
 52              */
 53             hide:function (event)
 54             {
 55                 $(this.node['root']).hide();
 56             }
 57         },
 58 
 59         /**
 60          * 事件
 61          *
 62          * @memberOf $we.widget.Autocomplete-
 63          */
 64         events:{
 65         },
 66 
 67         /**
 68          *  Config配置说明 <br/>
 69          *  title:标题
 70          *  ds:数据源
 71          *  search_parse: 搜索解析器
 72          *  commit:回车提交函数
 73          *
 74          * @param config
 75          * @constructs
 76          */
 77         init:function (target, config)
 78         {
 79             config = config || {};
 80             this.config = config;
 81             this.target = target;
 82 
 83             // target.attr('autocomplete','off');
 84             // this.after(target, _ContainerHtml);
 85             // this.append(this.node['root'], _Html, {title:config['title']});
 86 
 87             var t = this;
 88         }
 89     });
 90 
 91     return $we.widget.amd("Autocomplete");
 92 });