forked from glpunzi/nuBuilderPro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nureport_clone.js
185 lines (156 loc) · 7.91 KB
/
nureport_clone.js
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
function nuOBJECTCopy(i,s){
var z = 99;
for(var v = 0; v< REPORT.groups.length; v++) { //-- find highest z-index
for(var x = 0; x< REPORT.groups[v].sections.length;x++) {
for(var y = 0; y< REPORT.groups[v].sections[x].objects.length;y++) {
if(REPORT.groups[v].sections[x].objects[y].zIndex > z) {
z = REPORT.groups[v].sections[x].objects[y].zIndex;
}
}
}
}
z++;
this.id = i;
this.group = s.group; //-- Group it belongs to.
this.section = s.section; //-- Header or Footer.
this.objectType = s.objectType;
this.left = s.left + 3;
this.top = s.top; //-- relative to the Section it belongs to.
this.height = s.height;
this.width = s.width;
this.backgroundColor = s.backgroundColor;
this.borderColor = s.borderColor;
this.borderWidth = s.borderWidth;
this.fieldName = s.fieldName;
this.fontColor = s.fontColor;
this.fontFamily = s.fontFamily;
this.fontSize = s.fontSize;
this.fontWeight = s.fontWeight;
this.format = s.format;
this.textAlign = s.textAlign;
this.phpCall = s.phpCall;
this.zIndex = z;
this.minRows = s.minRows;
this.maxRows = s.maxRows;
this.selected = 0;
this.toselect = 1;
this.name = i;
}
function nuCopyObjects(){
for(var g = 0 ; g < REPORT.groups.length ; g ++){ //-- unselect all Objects
for(var s = 0 ; s < REPORT.groups[g].sections.length ; s ++){
for(var ob = 0 ; ob < REPORT.groups[g].sections[s].objects.length ; ob ++){
if(REPORT.groups[g].sections[s].objects[ob].selected == 1){
REPORT.groups[g].sections[s].objects[ob].tocopy = 1;
} else {
REPORT.groups[g].sections[s].objects[ob].tocopy = 0;
}
}
}
}
}
function nuCloneObjects(paste){
for(var g = 0 ; g < REPORT.groups.length ; g ++){ //-- unselect all Objects
for(var s = 0 ; s < REPORT.groups[g].sections.length ; s ++){
for(var ob = 0 ; ob < REPORT.groups[g].sections[s].objects.length ; ob ++){
if (paste) tocopy = REPORT.groups[g].sections[s].objects[ob].tocopy;
else tocopy = REPORT.groups[g].sections[s].objects[ob].selected;
if(tocopy == 1){
var st = parseInt(REPORT.groups[g].sections[s].top);
var m = parseInt(REPORT.groups[g].sections[s].margins);
var i = nuNextID();
var o = new nuCopyObject(REPORT.groups[g].sections[s].objects[ob]);
o.id = 'object' + i;
o.left = REPORT.groups[g].sections[s].objects[ob].left + 3;
var z = 99;
for(var v = 0; v< REPORT.groups.length; v++) { //-- find highest z-index
for(var x = 0; x< REPORT.groups[v].sections.length;x++) {
for(var y = 0; y< REPORT.groups[v].sections[x].objects.length;y++) {
if(REPORT.groups[v].sections[x].objects[y].zIndex > z) {
z = REPORT.groups[v].sections[x].objects[y].zIndex;
}
}
}
}
z++;
o.zIndex = z;
o.minRows = REPORT.groups[g].sections[s].objects[ob].minRows;
o.maxRows = REPORT.groups[g].sections[s].objects[ob].maxRows;
o.selected = 0;
o.toselect = 1;
o.name = o.id;
window.REPORT.groups[g].sections[s].objects.push(o);
var d = document.createElement('div');
d.setAttribute('id', 'object' + i);
d.setAttribute('ondblclick', 'nuShowObjectProperties(this)');
d.setAttribute('onMousedown', 'nuHighlightObject(this, event)');
d.setAttribute('onmouseup', 'nuMouseUp(this,event)');
d.setAttribute('onmousemove', 'nuMouseMove(event)');
$('#nuSectionIndex20').after(d);
$('#' + d.id).css({
'cursor' : 'cell',
'overflow' : 'hidden',
'position' : 'absolute',
'z-index' : o.zIndex,
'height' : o.height,
'left' : o.left + 30,
'top' : o.top + st + m,
'width' : o.width,
'border-style' : 'solid',
'border-width' : o.borderWidth,
'font-family' : o.fontFamily,
'font-size' : o.fontSize + 'px',
'color' : o.fontColor,
'background-color' : o.backgroundColor,
'text-align' : o.textAlign,
})
.addClass( 'nuReportObject');
switch(o.fontWeight) {
case "I":
$('#' + o.id).css('font-style', 'italic');
break;
case "B":
$('#' + o.id).css('font-weight', 'bold');
break;
default:
$('#' + o.id).css('font-style', 'normal');
break;
}
$('#' + d.id).html( $("#"+REPORT.groups[g].sections[s].objects[ob].id).html());
$('#' + d.id).draggable({
start: function( event, ui ){
nuSetOffset(this.id);
},
drag: function( event, ui ){
nuMoveSelected(this.id);
},
stop: function( event, ui ){
nuReadjustSections(); //-- make Sections Bigger if an Object overlaps it
nuMoveAllObjects();
nuReopenSelectObjects();
nuSaveReport();
}
});
nuReadjustSections(); //-- make Sections Bigger if an Object overlaps it
nuMoveAllObjects();
}
}
}
}
for(var g = 0 ; g < REPORT.groups.length ; g ++){ //-- unselect all Objects
for(var s = 0 ; s < REPORT.groups[g].sections.length ; s ++){
for(var ob = 0 ; ob < REPORT.groups[g].sections[s].objects.length ; ob ++){
if(REPORT.groups[g].sections[s].objects[ob].toselect == 1){
REPORT.groups[g].sections[s].objects[ob].toselect = 0;
REPORT.groups[g].sections[s].objects[ob].selected = 1;
$("#"+REPORT.groups[g].sections[s].objects[ob].id).addClass("nuSelected");
} else {
REPORT.groups[g].sections[s].objects[ob].selected = 0;
$("#"+REPORT.groups[g].sections[s].objects[ob].id).removeClass("nuSelected");
}
}
}
}
nuReopenSelectObjects();
nuSaveReport();
}