Przeglądaj źródła

【提交内容】:ipu-server同步display-server基础功能

wangyj18 9 lat temu
rodzic
commit
4877560ca3

+ 1 - 2
ipu-server/.gitignore

@ -4,8 +4,7 @@
4 4

5 5
/ipu-server.war
6 6

7
/web
8
/res.version.properties
7
/web/res.version.properties
9 8
10 9
/.DS_Store
11 10

+ 80 - 0
ipu-server/web/res/js/ui/wm-dialog2.js

@ -0,0 +1,80 @@
1
/*引入util对应的js文件*/
2
define(['util'], function(){
3
	var isClose = true;
4
	/*WmNavBar对象定义*/
5
	function WmDialog2(id){
6
		this.listeners = new Array(); //存储监听事件
7
		this.id = id;
8
		/*常用对象*/
9
		this.box = (function(obj){
10
			if(typeof(obj)=="object"){
11
				obj = $(obj);
12
			}else if(typeof(obj)=="string"){
13
				obj = $("#"+obj);
14
			}else{
15
				alert("没有匹配类型");
16
				return null;
17
			}
18
			return obj;
19
		})(id);
20
		this.negativeButton = this.box.find(".s-dialog-cancle");
21
		this.positiveButton = this.box.find(".s-dialog-ok");
22
		this.title = this.box.find('.s-dialog-title');
23
		this.mainView = this.box.find('.s-dialog-mainview');
24
		
25
		var that = this;
26
		this.negativeButton.tap(function(){
27
			that.hide();
28
		});
29
	}
30
	
31
	WmDialog2.prototype.show = function(){
32
		this.box.addClass('s-dialog-show');
33
	}
34
	
35
	WmDialog2.prototype.hide = function(){
36
		this.box.removeClass('s-dialog-show');
37
	}
38
	
39
	WmDialog2.prototype.setPositiveAction = function(action,isHide){
40
		var that = this;
41
		if(this.positiveButton.length != 0){
42
			this.positiveButton.tap(function(){
43
				if(typeof(action) == "function") {
44
					action();
45
				}
46
				if(isHide){
47
					that.hide();
48
				}
49
			});
50
		}
51
	}
52
	
53
	WmDialog2.prototype.setNegativeAction = function(action,isHide){
54
		var that = this;
55
		if(this.negativeButton.length != 0){
56
			this.negativeButton.tap(function(){
57
				if(typeof(action) == "function") {
58
					action();
59
				}
60
				if(isHide){
61
					that.hide();
62
				}
63
			});
64
		}
65
	}
66
	
67
	WmDialog2.prototype.setTitle = function(title){
68
		this.title.text(title);
69
	}
70
	/*设置内容*/
71
	WmDialog2.prototype.setContentView = function(str,setBy) {
72
		if (setBy == "html") {
73
			this.mainView.html($("#" + str).html());
74
		} else {
75
			this.mainView.html("<div>" + str + "</div>");
76
		}
77
	}
78
	
79
	return WmDialog2;
80
});

+ 63 - 0
ipu-server/web/template/lua/tag/WmDialog.lua

@ -0,0 +1,63 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmDialog = Class(Tag)
4

5
function WmDialog:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9
function WmDialog:doStartTag(attr)
10
	if not (attr.id and attr.title) then
11
		monitor:error("WmDialog组件 id、title属性不能为空 ")
12
		return nil
13
	end
14
	self.attr = attr
15
	self.htmlbuff:append('<div class="c_dialog" id="'..attr.id..'">')
16
	self.htmlbuff:append('<div class="wrapper">')
17
	self.htmlbuff:append('<div class="title">')
18
	self.htmlbuff:append('<div class="text">'..attr.title..'</div>')
19
	self.htmlbuff:append('<a href="#nogo" class="close"></a>')
20
	self.htmlbuff:append('</div>')
21
	self.htmlbuff:append('<div class="content">')
22
	if attr.contentText then
23
		self.htmlbuff:append(attr.contentText)
24
	end 
25
end
26

27
function WmDialog:doEndTag()
28
	local attr = self.attr
29
	self.htmlbuff:append('</div>')
30
	self.htmlbuff:append([[
31
		<div class="submit">
32
			<ul>
33
				<li><span class="e_button e_button-cancel">取消</span></li>
34
				<li><span class="e_button e_button-ok" id="btn">确定</span></li>
35
			</ul>
36
		</div>]])
37
	self.htmlbuff:append('</div></div>')
38
	self.htmlbuff:append('')
39

40
	self.htmlbuff:append('<script type="text/javascript">')
41
	self.htmlbuff:append('require(["wmDialog","wmWebUI"],function(WmDialog,WmWebUI) {')
42
	self.htmlbuff:append('var dialog_'..attr.id..' = new WmDialog("'..attr.id..'");')
43
	if attr.contentId then
44
		self.htmlbuff:append(' dialog_'..attr.id..'.setContent("'..attr.contentId..'","html");')
45
	end
46
	if attr.cancelAction then
47
		self.htmlbuff:append(' dialog_'..attr.id..'.cancelAction(function(){ return '..attr.cancelAction..'.apply(window,arguments);});')		
48
	end
49
	if attr.submitAction then
50
		self.htmlbuff:append(' dialog_'..attr.id..'.submitAction(function(){ return '..attr.submitAction..'.apply(window,arguments);});')
51
	end
52
	if attr.hideAction then
53
		self.htmlbuff:append(' dialog_'..attr.id..'.setHideAction(function(){ return '..attr.hideAction..'.apply(window,arguments);});')
54
	end
55
	if attr.showAction then
56
		self.htmlbuff:append(' dialog_'..attr.id..'.setShowAction(function(){ return '..attr.showAction..'.apply(window,arguments);});')
57
	end
58
	self.htmlbuff:append('WmWebUI.store("'..attr.id..'",dialog_'..attr.id..');')
59
	self.htmlbuff:append('})')
60
	self.htmlbuff:append('</script>')
61
end
62

63
return WmDialog

+ 107 - 0
ipu-server/web/template/lua/tag/WmDialog2.lua

@ -0,0 +1,107 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmDialog2 = Class(Tag)
4

5
function WmDialog2:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9
function WmDialog2:doStartTag(attr)
10
	if not (attr.id and attr.title) then
11
		monitor:error("WmDialog2组件 id、title属性不能为空 ")
12
		return nil
13
	end
14
	
15
	self.attr = attr
16
	self.htmlbuff:append('<div class="s-dialog s-dialog-slip" id="'..attr.id..'">')
17
	self.htmlbuff:append('<div class="s-dialog-content">')
18
	self.htmlbuff:append('<h3 class="s-dialog-title">'..attr.title..'</h3>')
19
	self.htmlbuff:append('<div class="s-dialog-mainview">')
20
	--this is the content area
21
	
22
	
23
end
24

25
function WmDialog2:doEndTag()
26
	local attr = self.attr
27
	
28
	self.htmlbuff:append('</div>')
29
	
30
	self.htmlbuff:append('<div class="s-dialog-buttons">')
31
	
32
	local n_action = nil
33
	local p_action = nil
34
	local p_closeDialg = 'true'
35
	if (not attr.negativeAction) and (not attr.positiveAction) then
36
		self.htmlbuff:append('<button class="s-dialog-cancle">确定</button>')
37
	else
38
		if attr.negativeAction then
39
			local negative = string.split(attr.negativeAction,",")
40
			local n_text = negative[1]
41
			n_action = negative[2]
42
			
43
			if n_text then
44
				self.htmlbuff:append('<button class="s-dialog-cancle">'..n_text..'</button>')
45
			end
46
		end
47
		
48
		if attr.positiveAction then
49
			local positive = string.split(attr.positiveAction,",")
50
			local p_text = positive[1]
51
			p_action = positive[2]
52
			
53
			if positive[3] then
54
				p_closeDialg = positive[3]
55
			end
56
			
57
			if p_text then
58
				self.htmlbuff:append('<button class="s-dialog-ok">'..p_text..'</button>')
59
			end
60
		end
61
		
62
		
63
	end
64
	
65
	self.htmlbuff:append('</div>')	
66
	
67
	self.htmlbuff:append('</div>')
68
	self.htmlbuff:append('</div>')
69
	
70
	
71
	self.htmlbuff:append('<script type="text/javascript">')
72
	self.htmlbuff:append('require(["wmDialog2","wmWebUI"],function(WmDialog2,WmWebUI) {')
73
	self.htmlbuff:append('var dialog_'..attr.id..' = new WmDialog2("'..attr.id..'");')
74
	
75
	if n_action then
76
		self.htmlbuff:append('dialog_'..attr.id..'.setNegativeAction('..n_action..',true);')
77
	end
78
	
79
	if p_action then
80
		self.htmlbuff:append('dialog_'..attr.id..'.setPositiveAction('..p_action..','..p_closeDialg..');')
81
	end
82
	
83
	if attr.contentview then
84
		local contentView = string.split(attr.contentview,",")
85
		local id = contentView[1]
86
		local type = contentView[2]
87
		
88
		self.htmlbuff:append('dialog_'..attr.id..'.setContentView("'..id..'","'..type..'");')
89
	end
90
	
91
	self.htmlbuff:append('WmWebUI.store("'..attr.id..'",dialog_'..attr.id..');')
92
	self.htmlbuff:append('})')
93
	self.htmlbuff:append('</script>')
94
end
95

96
function string.split(str, delimiter)	
97
	if str==nil or str=='' or delimiter==nil then		
98
		return nil	
99
	end	    
100
	local result = {}    
101
	for match in (str..delimiter):gmatch("(.-)"..delimiter) do        
102
		table.insert(result, match)    
103
	end    
104
	return result
105
end
106

107
return WmDialog2

+ 132 - 0
ipu-server/web/template/lua/tag/WmDropmenu.lua

@ -0,0 +1,132 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmDropmenu = Class(Tag)
4

5
--htmlbuff
6
function WmDropmenu:createNew(obj,htmlbuff)
7
  self.htmlbuff = htmlbuff
8
  self.actions = {}
9
end
10

11
--attr所有属性
12
function WmDropmenu:doStartTag(attr)
13
  --属性初始化
14
  attr.closeAction = attr.closeAction
15
  attr.openAction = attr.oppenAction
16
  self.attr = attr
17
  self.htmlbuff:append('<div id="')
18
  self.htmlbuff:append(attr.id)
19
  self.htmlbuff:append('">','\n')
20
  self.htmlbuff:append([[
21
  	<div class="fn">
22
		<span class="e_button"><span>]])
23
  self.htmlbuff:append(attr.label)
24
  self.htmlbuff:append([[</span><span class="e_ico-unfold"></span></span>
25
	</div>
26
	<div class="c_dropmenu">
27
      	<ul>
28
    ]])
29
end
30

31
function WmDropmenu:doEndTag()
32
  self.htmlbuff:append([[
33
     	</ul>
34
      </div>
35
    </div>
36
  ]])
37
    
38
  self.htmlbuff:append([[
39
<script type="text/javascript">
40
  require(["wmDropmenu"],function(WmDropmenu) {
41
      var wmDropmenu=new WmDropmenu("]])
42
  self.htmlbuff:append(self.attr.id)
43
  self.htmlbuff:append('");','\n')
44
  self.htmlbuff:append([[
45
  	wmDropmenu.create();
46
  ]])
47
  
48
  if self.attr.openAction then
49
  	self.htmlbuff:append([[
50
      wmDropmenu.setOpenAction(function(){
51
    ]])
52
	self.htmlbuff:append(self.attr.openAction,'\n')
53
	self.htmlbuff:append('});','\n')
54
  end
55
  if self.attr.closeAction then
56
  	self.htmlbuff:append([[
57
	  wmDropmenu.setCloseAction(function(){
58
    ]])
59
 	self.htmlbuff:append(self.attr.closeAction,'\n')
60
	self.htmlbuff:append('});','\n')
61
  end
62
 
63
 self.htmlbuff:append('		var items = wmDropmenu.getDropmenuItems();','\n')
64
 for k,v in pairs(self.actions) do
65
    if v~=-1 then
66
      self.htmlbuff:append('items[')
67
      self.htmlbuff:append(k-1)
68
      self.htmlbuff:append('].setAction(function(){')
69
      self.htmlbuff:append(v)
70
      self.htmlbuff:append('});','\n')
71
    end
72
  end
73
  self.htmlbuff:append([[
74
	});
75
	</script>
76
  ]])
77
end
78

79
function WmDropmenu:addActions(action)
80
  table.insert(self.actions, action)
81
end
82

83
return WmDropmenu
84

85
--[[
86
require(["wmDropmenu","util"],function(WmDropmenu) {
87
  var wmDropmenu=new WmDropmenu(dropmenu01);
88
  wmDropmenu.create();
89
  wmDropmenu.setLabel("下拉菜单01");
90
  wmDropmenu.setCloseAction(function(){
91
    console.log("closeAction");
92
  });
93
  wmDropmenu.setOpenAction(function(){
94
    console.log("openAction");
95
    console.log(wmDropmenu.getLabel());
96
  });
97
  var items=wmDropmenu.getItems();
98
  for(var i=0;i<items.length;i++){
99
    console.log("index:"+items[i].getIndex());
100
    console.log("parent:"+items[i].getParent());
101
    items[i].setAction(function(obj){
102
      alert(obj.html());
103
    });
104
  }
105
  console.log("length:"+items.length);
106
  items[2].remove();
107
  console.log("length:"+items.length);
108
  for(var i=0;i<items.length;i++){
109
    //alert(items[i].html());
110
  }
111
  //wmDropmenu.removeAll();
112
  var item1=wmDropmenu.push("111");
113
  item1.setAction(function(obj){
114
    alert("我是新来的1");
115
  });
116
  var item2=wmDropmenu.push("22222");
117
  item2.setAction(function(obj){
118
    alert("我是新来的2");
119
  });
120
  item1.remove();
121
  //wmDropmenu.getItems()[0].remove();
122
  $("#testbtn").setAction(function(){
123
    if(wmDropmenu.Invisible()){
124
      wmDropmenu.show();
125
    }else{
126
      wmDropmenu.hidden();
127
    }
128
  });
129
});
130

131
]]
132


+ 19 - 0
ipu-server/web/template/lua/tag/WmDropmenuItem.lua

@ -0,0 +1,19 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmDropmenuItem = Class(Tag)
4

5
function WmDropmenuItem:createNew(obj,htmlbuff)
6
  self.htmlbuff = htmlbuff
7
end
8

9
function WmDropmenuItem:doStartTag(attr)
10
  self.parent:addActions(attr.action or -1);
11
  self.htmlbuff:append('<li ontap>')
12
 
13
end
14

15
function WmDropmenuItem:doEndTag()
16
 self.htmlbuff:append('</li>');
17
end
18

19
return WmDropmenuItem

+ 96 - 0
ipu-server/web/template/lua/tag/WmNavBar.lua

@ -0,0 +1,96 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmNavBar = Class(Tag)
4

5
function WmNavBar:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
  monitor:debug("------------------------")
8
 -- monitor:debug("htmlbuff length:"..#self.htmlbuff)
9
  self.bottoms = {}
10
end
11

12
function WmNavBar:doStartTag(attr)
13
	self.id = attr.id
14
	self.bottoms = {}
15
	self.htmlbuff:append('<div class="c_navBar" id="'.. self.id ..'">')
16
end
17

18
function WmNavBar:doEndTag()
19
	self.htmlbuff:append('</div>')
20
	self.htmlbuff:append('<script type="text/javascript">')
21
	self.htmlbuff:append('require(["wmNavBar"],function(WmNavBar) {')
22
	self.htmlbuff:append('var navbar_'..self.id..' = new WmNavBar("'..self.id..'");')
23
	local groupCount = 0
24
	for i=1,#self.bottoms do
25
		local attr = self.bottoms[i]
26
		if attr.action and attr.action~="" then
27
			if attr.type == "icon" then
28
				local icons = self.Split(attr.icons, ",");
29
				local actions = self.Split(attr.action, ",");
30
				for i=1,#icons do
31
					if icons[i]~="" then
32
						self:setAction(icons[i],actions[i])
33
					end
34
				end 
35
			elseif attr.type == "tab" then
36
				local actions = self.Split(attr.action, ",");
37
				for i=1,#actions do
38
					self.htmlbuff:append('navbar_'..self.id..'.setTabItemAction('..(i-1)..',function(){ return '..actions[i]..'.apply(window,arguments);});')
39
				end
40
			elseif attr.type == "tabgroup" then
41
				if groupCount==0 then
42
					self.htmlbuff:append('navbar_'..self.id..'.initTabGroup();')
43
				end
44
				local actions = self.Split(attr.action, ",");
45
				for i=1,#actions do
46
					self.htmlbuff:append('navbar_'..self.id..'.setTabGroupItemAction('..groupCount..','..(i-1)..',function(){ return '..actions[i]..'.apply(window,arguments);});')
47
				end
48
				groupCount = groupCount+1
49
			else
50
				self:setAction(attr.type,attr.action)
51
			end
52
		end 
53
	end 
54
	self.htmlbuff:append('WmWebUI.store("'..self.id..'",navbar_'..self.id..');')
55
	self.htmlbuff:append('});')
56
	self.htmlbuff:append('</script>')
57
end
58

59
function WmNavBar:setAction(type,action)
60
	if action and action~="" then
61
		action = 'function(){ return '..action..'.apply(window,arguments);}'
62
		if type == "back" then
63
			self.htmlbuff:append('navbar_'..self.id..'.setBackAction('..action..');')
64
		elseif type == "add"  then
65
			self.htmlbuff:append('navbar_'..self.id..'.setAddAction('..action..');')
66
		elseif type == "delete" then
67
			self.htmlbuff:append('navbar_'..self.id..'.setDelAction('..action..');')
68
		elseif type == "date" then
69
			self.htmlbuff:append('navbar_'..self.id..'.setDateAction('..action..');')
70
		elseif type == "search" then
71
			self.htmlbuff:append('navbar_'..self.id..'.setSearchAction('..action..');')
72
		end
73
	end
74
end
75
function WmNavBar:addBottom(bottom)
76
  table.insert(self.bottoms, bottom)
77
end
78

79
function WmNavBar.Split(szFullString, szSeparator)
80
	local nFindStartIndex = 1
81
	local nSplitIndex = 1
82
	local nSplitArray = {}
83
	while true do
84
		local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)
85
		if not nFindLastIndex then
86
			nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
87
			break
88
		end
89
		nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
90
		nFindStartIndex = nFindLastIndex + string.len(szSeparator)
91
		nSplitIndex = nSplitIndex + 1
92
	end
93
	return nSplitArray
94
end
95

96
return WmNavBar

+ 84 - 0
ipu-server/web/template/lua/tag/WmNavBarItem.lua

@ -0,0 +1,84 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmNavBarItem = Class(Tag)
4

5
function WmNavBarItem:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9
function WmNavBarItem:doStartTag(attr)
10
	if attr.type == "back" then
11
		self.htmlbuff:append('<div class="left"><div class="back"><span class="e_ico-back"></span>')
12
		if attr.title then
13
			self.htmlbuff:append('<span class="text">'..attr.title..'</span>')
14
		end
15
		self.htmlbuff:append('</div></div>')
16
	elseif attr.type == "add" or attr.type == "delete" or attr.type == "date" then
17
		if attr.position then
18
			self.htmlbuff:append('<div class="'..attr.position..'">')
19
		else
20
			self.htmlbuff:append('<div class="right">')
21
		end 
22
		self.htmlbuff:append('<button><span class="e_ico-'..attr.type..'"></span>')
23
		if attr.text then
24
			self.htmlbuff:append(attr.text)
25
		end 
26
		self.htmlbuff:append('</button></div>')
27
	elseif attr.type == "title" then
28
		self.htmlbuff:append('<div class="center"><div class="title">'..attr.text..'</div></div>')
29
	elseif attr.type == "icon" then
30
		if attr.position then
31
			self.htmlbuff:append('<div class="'..attr.position..'">')
32
		else
33
			self.htmlbuff:append('<div class="right">')
34
		end
35
		self.htmlbuff:append('<div class="icon">')
36
		local icons = self.parent.Split(attr.icons, ",");
37
		for i=1,#icons do
38
			if icons[i]~="" then
39
				self.htmlbuff:append('<span class="e_ico-'..icons[i]..'"></span>')
40
			end
41
		end 
42
		self.htmlbuff:append('</div></div>')
43
	elseif attr.type == "tab" then
44
		if attr.position then
45
			self.htmlbuff:append('<div class="'..attr.position..'">')
46
		end 
47
		self.htmlbuff:append('<div class="tab"><ul>')
48
		local items = self.parent.Split(attr.items, ",");
49
		for i=1,#items do
50
			if i==1 then
51
				self.htmlbuff:append('<li class="on">'..items[i]..'</li>')
52
			else
53
				if items[i]~="" then
54
					self.htmlbuff:append('<li>'..items[i]..'</li>')
55
				end
56
			end
57
		end 
58
		self.htmlbuff:append('</ul></div>')
59
		if attr.position then
60
			self.htmlbuff:append('</div>')
61
		end 
62
	elseif attr.type == "tabgroup" then
63
		self.htmlbuff:append('<div class="'..attr.position..'">')
64
		self.htmlbuff:append('<div class="buttonList">')
65
		self.htmlbuff:append('<div class="tip">'..attr.text..'<span class="e_ico-unfold"></span></div>')
66
		self.htmlbuff:append('<div class="option" style="display:none;"><ul>')
67
		local items = self.parent.Split(attr.items, ",");
68
		for i=1,#items do
69
			if items[i]~="" then
70
				self.htmlbuff:append('<li>'..items[i]..'</li>')
71
			end
72
		end 
73
		self.htmlbuff:append('</ul></div></div></div>')
74
	end
75
	
76
	self.parent:addBottom(attr)
77
	
78
end
79

80
function WmNavBarItem:doEndTag()
81

82
end
83

84
return WmNavBarItem

+ 55 - 0
ipu-server/web/template/lua/tag/WmProgress.lua

@ -0,0 +1,55 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmProgress = Class(Tag)
4

5
function WmProgress:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9
function WmProgress:doStartTag(attr)
10

11
	if not (attr.id and attr.progress) then
12
		monitor:error("WmProgress组件 id、progress属性不能为空 ")
13
		return nil
14
	end
15
		
16
	self.htmlbuff:append('<div class="e_progress" id="'..attr.id..'">')
17
	if attr.pastTip then
18
		self.htmlbuff:append([[
19
			<div class="e_progressUse">
20
				<div class="e_progressUseValue"></div>
21
				<div class="e_progressUseTip">]]..attr.pastTip..[[</div>
22
			</div>
23
		]])
24
	end
25
	self.htmlbuff:append('<div class="e_progressBar"><span></span></div>')
26
	if attr.totalTip then
27
		self.htmlbuff:append('<div class="e_progressTotal">'..attr.totalTip..'</div>')
28
	end
29
	if attr.spaceTip then
30
		self.htmlbuff:append([[
31
			<div class="e_progressSurplus">
32
				<div class="e_progressSurplusTip">]]..attr.spaceTip..[[</div>
33
				<div class="e_progressSurplusValue"></div>
34
			</div>
35
		]])
36
	end
37
	self.htmlbuff:append('</div>\n')
38

39
	self.htmlbuff:append('<script type="text/javascript">')
40
	self.htmlbuff:append('require(["wmProgress"],function(WmProgress) {')
41
	self.htmlbuff:append('var progress_'..attr.id..' = new WmProgress("'..attr.id..'");')
42
	self.htmlbuff:append('progress_'..attr.id..'.setProgress("'..attr.progress..'");')
43
	if attr.level then
44
		self.htmlbuff:append('progress_'..attr.id..'.setLevel("'..attr.level..'");')
45
	end
46
	self.htmlbuff:append('WmWebUI.store("'..attr.id..'",progress_'..attr.id..');')
47
	self.htmlbuff:append('})')
48
	self.htmlbuff:append('</script>')
49
end
50

51
function WmProgress:doEndTag()
52

53
end
54

55
return WmProgress

+ 65 - 0
ipu-server/web/template/lua/tag/WmRefresh.lua

@ -0,0 +1,65 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmRefresh = Class(Tag)
4

5
function WmRefresh:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9
function WmRefresh:doStartTag(attr)
10
	if not (attr.id) then
11
		monitor:error("WmRefresh组件 id属性不能为空 ")
12
		return nil
13
	end
14
	
15
	self.attr = attr
16
	self.htmlbuff:append('<div class="c-refresh-container" id="'..attr.id..'">')
17
	self.htmlbuff:append('<div id="c-refresh-wrapper" style="height:200px;">')
18
	self.htmlbuff:append('<div id="c-refresh-scroller">')
19
	self.htmlbuff:append('<div id="pullDown">')
20
	self.htmlbuff:append('<span class="pullDownIcon"></span><span class="pullDownLabel">下拉刷新...</span>')
21
	self.htmlbuff:append('</div>')
22
	self.htmlbuff:append('<div class="c_list">')
23
	--this is the content area
24
	
25
	
26
end
27

28
function WmRefresh:doEndTag()
29
	local attr = self.attr
30
	
31
	self.htmlbuff:append('</div>')
32
	
33
	self.htmlbuff:append('<div id="pullUp">')
34
	self.htmlbuff:append('<span class="pullUpIcon"></span><span class="pullUpLabel">上拉加载更多...</span>')
35
	self.htmlbuff:append('</div> </div> </div> </div>')
36
	
37
	self.htmlbuff:append('<script type="text/javascript">')
38
	self.htmlbuff:append('require([ "wmRefresh","wmWebUI" ], function(WmRefresh,WmWebUI) {')
39
	self.htmlbuff:append('var refresh_'..attr.id..' = new WmRefresh("'..attr.id..'");')
40
	
41
	if attr.pullDownAction then
42
		self.htmlbuff:append('refresh_'..attr.id..'.setPullDownAction('..attr.pullDownAction..');')
43
	end
44
	
45
	if attr.pullUpAction then
46
		self.htmlbuff:append('refresh_'..attr.id..'.setPullUpAction('..attr.pullUpAction..');')
47
	end
48
	
49
	self.htmlbuff:append('WmWebUI.store("'..attr.id..'",refresh_'..attr.id..');')
50
	self.htmlbuff:append('})')
51
	self.htmlbuff:append('</script>')
52
end
53

54
function string.split(str, delimiter)	
55
	if str==nil or str=='' or delimiter==nil then		
56
		return nil	
57
	end	    
58
	local result = {}    
59
	for match in (str..delimiter):gmatch("(.-)"..delimiter) do        
60
		table.insert(result, match)    
61
	end    
62
	return result
63
end
64

65
return WmRefresh

+ 59 - 0
ipu-server/web/template/lua/tag/WmSegment.lua

@ -0,0 +1,59 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmSegment = Class(Tag)
4

5
function WmSegment:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9
function WmSegment:doStartTag(attr)
10
	local texts = self.Split(attr.texts, ",")
11
	local values = self.Split(attr.values, ",")
12
	self.htmlbuff:append('<span class="e_segment" id="'..attr.id..'"><span class="e_segmentWrapper">')
13
	for i=1,#texts do
14
		self.htmlbuff:append('<span class="e_segmentLi" segValue="'..values[i]..'">'..texts[i]..'</span>')
15
	end 
16
	self.htmlbuff:append('</span></span>\n')
17
	self.htmlbuff:append('<input type="hidden" id="'..attr.name..'" name="'..attr.name..'" value="" />')
18
	
19
	
20
	self.htmlbuff:append('<script type="text/javascript">\n')
21
	self.htmlbuff:append('require(["wmSegment"],function(WmSegment) {\n')
22
	self.htmlbuff:append('var segment_'..attr.id..' = new WmSegment("'..attr.id..'","'..attr.name..'",false);\n')
23
	if attr.selected then
24
		self.htmlbuff:append('segment_'..attr.id..'.activeItem("'..attr.selected..'");\n')
25
	else
26
		self.htmlbuff:append('segment_'..attr.id..'.activeItemIndex(0);\n')
27
	end 
28
	if attr.action then
29
		self.htmlbuff:append('segment_'..attr.id..'.setAction(function(){ return '..attr.action..'.apply(window,arguments);})\n')
30
	else
31
		self.htmlbuff:append('segment_'..attr.id..'.setAction();\n')
32
	end 
33
	self.htmlbuff:append('WmWebUI.store("'..attr.id..'",segment_'..attr.id..');\n')
34
	self.htmlbuff:append('})\n')
35
	self.htmlbuff:append('</script>')
36
end
37

38
function WmSegment:doEndTag()
39

40
end
41

42
function WmSegment.Split(szFullString, szSeparator)
43
	local nFindStartIndex = 1
44
	local nSplitIndex = 1
45
	local nSplitArray = {}
46
	while true do
47
		local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)
48
		if not nFindLastIndex then
49
			nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
50
			break
51
		end
52
		nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
53
		nFindStartIndex = nFindLastIndex + string.len(szSeparator)
54
		nSplitIndex = nSplitIndex + 1
55
	end
56
	return nSplitArray
57
end
58

59
return WmSegment

+ 54 - 0
ipu-server/web/template/lua/tag/WmToolTip.lua

@ -0,0 +1,54 @@
1
local Class = require("util.Class")
2
local Tag = require("engine.Tag")
3
local WmToolTip = Class(Tag)
4

5
function WmToolTip:createNew(obj,htmlbuff)
6
  self.htmlbuff=htmlbuff
7
end
8

9

10
function WmToolTip:doStartTag(attr)
11
	self.id = attr.id
12
	local align = ""
13
	if attr.align=="right" then
14
		align = "c_toolTip-arrowRight"
15
	elseif attr.align=="left" then
16
		align = "c_toolTip-arrowLeft"
17
	end
18
	local position = ""
19
	if attr.position=="up" then
20
		position = "c_toolTip-positionBottom"
21
	end
22
	self.htmlbuff:append('<div class="c_toolTip '..align..' '..position..'" id="'.. self.id ..'" >')
23
	self.htmlbuff:append('<div class="pointer"></div>')
24
	self.htmlbuff:append('<div class="content" >')
25
	self.htmlbuff:append('<div class="ico"><span class="e_ico-swipe"></span></div>')
26
	local textAlign = ""
27
	if attr.textAlign == "center" then
28
		textAlign = "e_center"
29
	end
30
	self.htmlbuff:append('<div class="detail '..textAlign..'">'..attr.text..'</div>')
31
	if attr.buttonText then
32
		self.htmlbuff:append('<div class="submit"><span class="e_button">'..attr.buttonText..'</span></div>')
33
	end
34
	self.htmlbuff:append('</div></div>')
35
	self.htmlbuff:append('<script type="text/javascript">')
36
	self.htmlbuff:append('require(["wmToolTip","wmWebUI"],function(WmToolTip,WmWebUI) {')
37
	self.htmlbuff:append('var tooltip_'..self.id..' = new WmToolTip("'..self.id..'");')
38
	if attr.action then
39
		self.htmlbuff:append('tooltip_'..self.id..'.setCloseAction(function(){ return '..attr.action..'.apply(window,arguments);});')
40
	else
41
		self.htmlbuff:append('tooltip_'..self.id..'.setCloseAction();')
42
	end
43
	self.htmlbuff:append('tooltip_'..self.id..'.setBaseElement("'..attr.baseId..'");')
44
	self.htmlbuff:append('tooltip_'..self.id..'.show();')
45
	self.htmlbuff:append('WmWebUI.store("'..attr.id..'",tooltip_'..attr.id..');')
46
	self.htmlbuff:append('})')
47
	self.htmlbuff:append('</script>')
48
end
49

50
function WmToolTip:doEndTag()
51

52
end
53

54
return WmToolTip