1 /**
  2  *
  3  * Process container.js
  4  *
  5  * @fileOverView 流程容器
  6  * @author  <a href="mailto:zhang.gd@foxmail.com">Zhang Guangda</a>
  7  * @date    2012-12-13
  8  */
  9 define(["core"], function() {
 10 
 11 	var _html = [
 12 		'<div class="we_popup $theme$" attr="inner:root" style="display:none;background:none;padding:0px;">',
 13 	        '<div class="we_pop_container">',
 14 	            '<h2 class="we_title" attr="inner:title" style=""></h2>',
 15 	            '<h2 class="we_subtitle" attr="inner:subTitle" style="display: none;"></h2>',
 16 	            '<div class="we_pop_content" attr="inner:content">',
 17 	                '<div class="we_pop_content_box" attr="inner:notice_content"></div>',
 18 	                '<div class="we_cell_submit_box" attr="inner:notice_button"></div>',
 19 	            '</div>',
 20 	            '<div class="we_cell_bottom_tips" attr="inner:bottom" style="display: none;"></div>',
 21 	        '</div>',
 22 	    '</div>'
 23 		].join(""),
 24 		_default_skin_prefix = "we_theme_",
 25 		_default_width = 600;
 26 		theme = "",
 27 		_buttonClass={
 28 	        button:'we_button',
 29 	        cancel:'we_button_gray'
 30 	    };
 31 
 32 	$we.widget.reg("process.container", {
 33 		init: function(el, config) {
 34 			this.el = el || $("body")[0];
 35 			this.config = config || {};
 36 
 37             if($we.conf.THEME) theme=_default_skin_prefix+$we.conf.THEME;
 38 
 39             //渲染
 40             this.append(this.el, _html, {
 41             	theme: theme
 42             });
 43 
 44             this.config.width = $we.utils.setValue(this.config.width, _default_width);
 45             $(this.node.root).css("width", this.config.width);
 46 
 47             if(this.config['title']){
 48                 this.renderTitle(this.config['title']);
 49             }
 50             if(this.config['subTitle']){
 51                 this.renderSubTitle(this.config['subTitle']);
 52             }
 53             if(this.config['bottom']){
 54                 this.renderBottom(this.config['bottom']);
 55             }
 56             //渲染按钮
 57             var buttonConfig=this.config['notice_button_config'];
 58             if(buttonConfig){
 59                 this.renderNoticeButtons(buttonConfig);
 60             }
 61             //渲染Notice内容
 62             var noticeContent = this.config['notice_content'];
 63             if(noticeContent){
 64                 this.renderNoticeContent(noticeContent);
 65             }
 66 		},
 67 		interfaces: {
 68             renderTitle:function(title){
 69                 if(title){
 70                     $(this.node['title']).empty();
 71                     this.append(this.node['title'],title);
 72                     $(this.node['title']).show();
 73                 }
 74             },
 75             renderContent:function(content){
 76                 if(content){
 77                     $(this.node['content']).empty();
 78                     this.append(this.node['content'],content);
 79                 }
 80             },
 81             renderSubTitle:function(subTitle){
 82                 if(subTitle){
 83                     $(this.node['subTitle']).empty();
 84                     this.append(this.node['subTitle'],subTitle);
 85                     $(this.node['subTitle']).show();
 86                 }
 87             },
 88             renderBottom:function(bottom){
 89                 if(bottom){
 90                     $(this.node['bottom']).empty();
 91                     this.append(this.node['bottom'],bottom);
 92                     $(this.node['bottom']).show();
 93                 }else{
 94                     $(this.node['bottom']).hide();
 95                 }
 96             },
 97             renderNoticeButtons:function(buttonConfig){
 98                 var t = this;
 99                 if(buttonConfig){
100                     var buttonArea = $(this.node['notice_button']);
101 
102                     buttonArea.empty();
103 
104                     $.each(buttonConfig,function(i,bConfig){
105                         var buttonType = bConfig['type'] || 'button';
106                         var buttonClass = _buttonClass[buttonType];
107                         var buttonEle=$('<a href="javascript:void(0);" class="'+buttonClass+'" ><span>'+bConfig['name']+'</span></a>');
108                         if(bConfig['click']){
109                             buttonEle.click(function(e){
110                                 bConfig['click'].call(this,e,t);
111                             });
112                         }
113                         buttonArea.append(buttonEle);
114                     });
115                 }
116             },
117             renderNoticeContent:function(noticeContent){
118                 if(noticeContent){
119                     $(this.node['notice_content']).empty();
120                     this.append(this.node['notice_content'],noticeContent);
121                 }
122             },
123             open: function() {
124             	$(this.node.root).show();
125             },
126             position: function() {},
127             esc: function() {},
128             close: function() {},
129             remove: function() {}
130 		}
131 
132 	});
133 
134     return $we.widget.amd("process.container");
135 });