append.js
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
$(function(){
region.start();
function actions(){
function _show(obj){
obj.next().show();
}
function _append(obj){
obj.parent().find(".show-more").append(
'<div class="more-cell">'+
obj.parent().find(".title div").html() +
'<span></span></div>'
);
obj.parent().find(".title div").html("");
}
function _remove(obj){
if (obj.parent().parent().find(".more-cell").length<=1){
obj.parent().parent().parent().hide();
}
obj.parent().remove();
}
this.run = function(){
$(".more-cell").live("mouseover",function(){
$(this).find("span").css("visibility","visible");
}).live("mouseout",function(){
$(this).find("span").css("visibility","hidden");
})
$(".add-more").live("click",function(){
if (!$(this).prev().find(".title div").html()){return false};
if (!$(this).parent().find(".title div").html()){return false};
_show($(this));
_append($(this))
return false;
});
$(".more-cell span").live("click",function(){
_remove($(this));
})
}
}
var action = new actions();
action.run();
var varieties = new OperationList({
add : 'add-category',
view : 'category-list',
del : 'category-list span',
fun : function(data){
var ids = '';
var texts = '';
var view = '';
for (var i=0; i < data.length; i++) {
var txt = '';
for (var k=0; k < data[i].length; k++) {
if(k === (data[i].length - 1)){
ids += data[i][k].cid+',';
texts += data[i][k].cname+',';
}else{
texts += data[i][k].cname+'-->';
};
txt += data[i][k].cname+' ';
};
view += '<div page="'+i+'" class="more-cell">'+txt+'<span style="visibility: hidden;"></span></div>';
};
$('.category-list').html('');
$('.category-list').append(view);
$('#categoryId').val(ids);
$('#varietiesId').val(texts);
}
});
var areaData = new OperationList({
add : 'add-area',
view : 'area-list',
del : 'area-list span',
pid : 'regionId',
txt : 'regionName',
fun : function(data){
var adata = '';
var view = '';
for (var i=0; i < data.length; i++) {
var txt = '';
for (var k=0; k < data[i].length; k++) {
if(k == (data[i].length - 1)){
adata += data[i][k].regionId+'/'+data[i][k].regionName+',';
};
txt += data[i][k].regionName+' ';
};
view += '<div page="'+i+'" class="more-cell">'+txt+'<span style="visibility: hidden;"></span></div>';
};
$('.area-list').html('');
$('.area-list').append(view);
$('#specialiseAreaId').val(adata);
}
});
})