controlhtm.html
15.3 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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<p>图片组合</p>
<!--图片扩展-->
<div class="combination">
<table ng-style="{'border-width':content.border_width+'px'}" style=" width: 240px" class="table table-bordered"
id="layout-table">
<tbody class="controltbody_img" id="controltbody_img{{content.no}}"></tbody>
</table>
</div>
<div>
<!---选择的数组--->
<div class="nav-edit-item parent" ng-repeat="item in content.data track by $index">
<!--默认图片-->
<div class="nav-edit-item-img">
<!--有图片的情况-->
<div class="has-image thumbnail" ng-if="item.src">
<img style="width: 100%; height: 100%" ng-src="{{item.src}}" onclick="setuploadimg('data','src',this)">
<div class="foot-choice" onclick="setuploadimg('data','src',this)">重新选择</div>
</div>
<!--无图片的情况-->
<div class="has-image noimg thumbnail" ng-if="item.src==''"
onclick="setuploadimg1('data','src',this,'layout_createtable')">
<i class="fa fa-plus"></i>添加图片
</div>
</div>
<!--内容和链接-->
<div class="nav-edit-item-info" ng-if="is_mini==0">
<div style="padding:10px;">链接:
<div class="btn-group" onclick="seturl1('data','url','urltitle',this,'layout_createtable')"
onmousemove="setisover(1)" onmouseout="setisover(0)">
<button type="button" class="btn btn-sm btn-default text-over cut">{{item.urltitle}}</button>
<button type="button" class="btn btn-sm btn-default dropdown-toggle" aria-haspopup="true"
aria-expanded="false"><span class="caret"></span></button>
</div>
<div ng-if="item.urltitle=='自定义'">
<div class="p_inputurl line-p">
<input placeholder="http://" class="form-control input-sm " ng-model="item.url"
style="width:270px;margin-top: 10px;">
</div>
</div>
</div>
</div>
<!--内容和链接-->
<div class="nav-edit-item-info" ng-if="is_mini==1">
<div style="padding:10px;">链接:
<div class="btn-group" onclick="seturl2('data','wxapp_url','wxapp_url_title',this,'layout_createtable')"
onmousemove="setisover(1)" onmouseout="setisover(0)">
<button type="button" class="btn btn-sm btn-default text-over cut">{{item.wxapp_url_title}}</button>
<button type="button" class="btn btn-sm btn-default dropdown-toggle" aria-haspopup="true"
aria-expanded="false"><span class="caret"></span></button>
</div>
</div>
</div>
<div class="clear"></div>
<!--小图标-->
<span class="opts">
<span class="opts-icon" onclick="dellayoutitem(this);"><i class="fa fa-trash-o"></i></span>
</span>
</div>
</div>
<ul class="basics_ul" style="padding-bottom: 100px;">
<li ng-if="is_mini==0">
<label class="col-sm-3">显示边框</label>
<div class="col-sm-8">
<label onclick="settbborder(1);"><input type="radio" ng-model="content.border_width" ng-value="1" name="character"/><span>显示</span></label>
<label onclick="settbborder(0);"><input type="radio" ng-model="content.border_width" ng-value="0" name="character"/><span>不显示</span></label>
</div>
<div class="clear"></div>
</li>
<li>
<label class="col-sm-3">颜色选择</label>
<div class="col-sm-8">
<span onclick="setcolor('','bg_color',this)" class="color_Selector"
style="background-color: {{content.bg_color}}"></span>
<input class="btn addNav" type="button" onclick="pic_reset()" value="重置"/>
</div>
<div class="clear"></div>
</li>
</ul>
<!--组合选择弹出框-->
<div id="controltbody_img_selepop" class="modal-dialog modal-sm dn">
<div class="modal-content" modal-transclude="">
<div class="modal-header ng-scope">
<button type="button" class="close" onclick="cancel_controltbody_img_selepop()" data-dismiss="modal">
<span aria-hidden="true">×</span>
<span class="sr-only">关闭</span>
</button>
<h4 class="modal-title">选择布局</h4>
</div>
<div class="modal-body text-center ng-scope">
<div class="layout-table clearfix">
<ul ng-repeat="item in layout_sele_result track by $index" class="layout-cols">
<li ng-repeat="row in item track by $index" onmousemove="setlayoutbackcolor(this)"
onclick="setlayout(this)" x="{{row.x}}" y="{{row.y}}">
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<script>
$(function () {
setTimeout(function () {
layout_createtable();
}, 500);
});
function pic_reset() {
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
$scope.content.bg_color = "#ffffff";
//如果想同步到Angular控制器中,则需要调用$apply()方法即可
$scope.$apply();
}
/*---鼠标移动效果---*/
$(".controltbody_img .empty").hover(
function () {
$(this).addClass('on');
}, function () {
$(this).removeClass('on');
}
);
/*---单击选择---*/
var layout_fir_x = 0;
var layout_fir_y = 0;
function layouteleclick(ob) {
var x = $(ob).attr('x');
var y = $(ob).attr('y');
layout_fir_x = x;
layout_fir_y = y;
$(".layout-cols li").removeClass('on');
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
$scope.layout_sele_result = [];
/*--按行顺序--*/
for (var i = x; i <= 3; i++) {
var ele = [];
for (var j = y; j <= 3; j++) {
var e1 = {'x': i, 'y': j};
/*--当选择了的为空*/
if ($scope.content.data == undefined) {
ele.push(e1);
} else {
if ($scope.content.data.length <= 0) {
ele.push(e1);
} else {
var iscanpush = true;
for (var ii = 0; ii < $scope.content.data.length; ii++) {
var aryd = $scope.content.data[ii].arr;
ismolan = false;
for (var jj = 0; jj < aryd.length; jj++) {
var ismolan = true;
/*----如果初始位置x,y小于选择元素的位置----*/
if (x <= aryd[jj].x && y <= aryd[jj].y) {
/*----如果元素(j,i)大于选中其中的一个元素----*/
if (i >= aryd[jj].x && j >= aryd[jj].y) {
iscanpush = false;
break;
}
}
}
}
if (iscanpush) {
ele.push(e1);
}
}
}
}
if (ele.length > 0) {
$scope.layout_sele_result.push(ele);
ele = [];
}
}
if ($scope.layout_sele_result.length > 0) {
if ($scope.layout_sele_result.length == 1) {
if ($scope.layout_sele_result[0].length == 1) {
var el = {
'fir': {'x': x, 'y': y},
'x_span': 1,
'y_span': 1,
'url': '',
'urltitle': '请选择',
"wxapp_url":"",
"wxapp_url_title":"请选择",
'src': '',
'arr': [{'x': x, 'y': y}]
};
$scope.content.data.push(el);
$scope.$apply();
layout_createtable();
} else {
//同步到Angular控制器中
$scope.$apply();
$("#controltbody_img_selepop").fadeIn(3);
}
} else {
//同步到Angular控制器中
$scope.$apply();
$("#controltbody_img_selepop").fadeIn(3);
}
}
};
/*---鼠标移动上面的效果---*/
function setlayoutbackcolor(ob) {
var x = $(ob).attr('x');
var y = $(ob).attr('y');
$(".layout-cols li").each(function () {
var x1 = $(this).attr('x');
var y1 = $(this).attr('y');
if (y1 > y) {
$(this).removeClass('on');
} else if (x1 > x) {
$(this).removeClass('on');
} else {
$(this).addClass('on');
}
});
$(ob).addClass('on');
}
/*---鼠标点击选择组合---*/
function setlayout(ob) {
var x = $(ob).attr('x');
var y = $(ob).attr('y');
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
var xspan = x - layout_fir_x + 1;
var yspan = y - layout_fir_y + 1;
var e = {
'fir': {'x': layout_fir_x, 'y': layout_fir_y},
'x_span': xspan,
'y_span': yspan,
'url': '',
'urltitle': '请选择',
"wxapp_url":"",
"wxapp_url_title":"请选择",
'src': '',
'arr': []
}
/*--按行添加数据--*/
for (var i = layout_fir_y; i <= y; i++) {
for (var j = layout_fir_x; j <= x; j++) {
var em = {'x': j, 'y': i};
e.arr.push(em);
}
}
$scope.content.data.push(e);
$scope.$apply();
layout_createtable();
cancel_controltbody_img_selepop();
layout_fir_x = 0;
layout_fir_y = 0;
}
/*--关闭弹出框--*/
function cancel_controltbody_img_selepop() {
$("#controltbody_img_selepop").fadeOut(3);
}
/*---删除元素---*/
function dellayoutitem(ob) {
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
var index = $(ob).parent().parent().index();
$scope.content.data.splice(index, 1);
$scope.$apply();
layout_createtable();
}
/*-------------布局创建表格--------*/
function layout_createtable() {
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
$("#showlayouttboay"+$scope.content.no).html('');
$scope.content.layout_htm = "";
var data = $scope.content.data;
var htm = "";
/*--从行开始--*/
for (var i = 0; i <= 3; i++) {
htm += "<tr>";
for (var j = 0; j <= 3; j++) {
var e1 = {'x': j, 'y': i};
var iscanshow = true;
for (var ii = 0; ii < $scope.content.data.length; ii++) {
var aryd = $scope.content.data[ii].arr;
/*--如果元素处于数组内--*/
if (isinlayoutArr(e1, aryd)) {
iscanshow = false;
var ee = $scope.content.data[ii];
/*---如果是组合的第一个元素,要进行合并处理---*/
if (e1.x == ee.fir.x && e1.y == ee.fir.y) {
if (ee.src == "") {
htm += "<td style='border-width:" + $scope.content.border_width + "px' " +
"colspan='" + ee.x_span + "' rowspan='" + ee.y_span + "'>";
if (ee.url != "") {
htm += "<a ul='" + ee.url + "' onclick='tpgrgoto(this)'>" + 160 * ee.x_span + "x" + 160 * ee.y_span + "</a></td>";
} else {
//htm +=""+160*ee.x_span+"x"+160*ee.y_span+"</td>";
htm += "<span class='spanbox'>" + 160 * ee.x_span + "x" + 160 * ee.y_span + "</span>";
}
} else {
htm += "<td style='border-width:" + $scope.content.border_width + "px' " +
"colspan='" + ee.x_span + "' rowspan='" + ee.y_span + "'>";
if (ee.url != "") {
htm += "<a ul='" + ee.url + "' onclick='tpgrgoto(this)'><img src='" + ee.src + "' style='width:100%'></a></td>";
} else {
htm += "<img src='" + ee.src + "' style='width:100%'></td>";
}
}
}
}
}
if (iscanshow) {
htm += "<td style='border-width:" + $scope.content.border_width + "px' " +
" class='empty' x='" + j + "' y='" + i + "'><span class='spanbox'></span></td>";
}
}
htm += "</tr>";
}
//同步到Angular控制器中
$scope.content.layout_htm = htm;
$scope.$apply();
$("#showlayouttboay" + $scope.content.no).html(htm);
$("#controltbody_img" + $scope.content.no).html(htm);
/*--鼠标移动上面的效果--*/
$(".controltbody_img .empty").hover(
function () {
$(this).addClass('on');
}, function () {
$(this).removeClass('on');
});
/*--鼠标点击的效果--*/
$(".controltbody_img .empty").click(function () {
layouteleclick(this);
});
}
/*--判断是否在数组中--*/
function isinlayoutArr(e, arr) {
for (var i = 0; i < arr.length; i++) {
if (e.x == arr[i].x && e.y == arr[i].y) {
return true;
}
}
return false;
}
/*--设置table border--*/
function settbborder(n) {
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=ctrl]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
$scope.content.border_width = n;
//同步到Angular控制器中
$scope.$apply();
layout_createtable();
}
</script>