PluginProbe
Visual Slider / trunk
Visual Slider vtrunk
visual-slider / admin / assets / js / template.js

template.js in Visual Slider trunk, at admin/assets/js/template.js

691 lines 21.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function($) {
2 'use strict';
3 jQuery(document).ready(function() {
4
5 /*************************************************************************************************************************************************************************
6 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
7 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
8 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
10
11 Error
12
13 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
14 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
15 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
16 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
17 **************************************************************************************************************************************************************************/
18
19 $(document).ajaxError(function( event, jqxhr, setting, thrownError ) {
20 $('body').vs_remove_add_error_loading();
21 });
22 function isset(variable){
23 return variable !== "undefined" && variable !== "0" && variable !== null && variable !== '';
24 }
25
26
27 /*************************************************************************************************************************************************************************
28 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
29
30 to Save
31
32 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
33 **************************************************************************************************************************************************************************/
34 $(document).on('click', '.vs_template_cancel', function(e) {
35 $(this).parents('.vs_template').remove();
36 });
37 //Option Full Save
38 $(document).on('click', '.vs_module_template_save', function(e) {
39 var data_id = $(this).attr('data-id');
40
41 var data_key='';
42
43 if(data_id==='slide'){
44 data_key= $(this).parents('.vs_module_slide_item').first().attr('data-key');
45
46 }else if(data_id=='layer'){
47 data_key= $(this).parents('.vs_module_layer_item').first().attr('data-key');
48 }
49
50 $('body').append('<div class="vs-mouse-wait"></div>');
51
52 $.ajax({
53 url: visualslider.ajaxurl,
54 type: 'POST',
55 data : {
56 action : 'vs_template_save',
57 id :data_id,
58 key:data_key,
59 post_id : visualslider.post_id,
60 _wpnonce : visualslider.nonce,
61 },
62 success:function(data) {
63 $('body').append(data);
64 $('.vs-mouse-wait').remove();
65
66 }
67
68 });
69
70 });
71
72
73
74
75 /*************************************************************************************************************************************************************************
76 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
77
78 Save Pross
79
80 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
81 **************************************************************************************************************************************************************************/
82
83 //Option Full Save
84 $(document).on('click', '.vs_template_global .vs_template_save', function(e) {
85 var data_id = 'global';
86 var data_name = $('[name="vs_template_name"]').val();
87 var data_setting = $('[name="vs_setting_json"]').val();
88 var data_slide = $('[name="vs_slide"]').val();
89 if(isset(data_name)){
90 $('body').append('<div class="vs-mouse-wait"></div>');
91 $.ajax({
92 url: visualslider.ajaxurl,
93 type: 'POST',
94 data : {
95 action : 'vs_template_save_global',
96 setting : data_setting,
97 slide : data_slide,
98 name : data_name,
99 id : data_id,
100 post_id : visualslider.post_id,
101 _wpnonce : visualslider.nonce,
102 },
103 success:function(data) {
104 $('.vs_template').remove();
105 $('.vs-mouse-wait').remove();
106 }
107
108 });
109 }else{
110 $('.vs_template_massage').addClass('vs_template_massage_active');
111
112 }
113
114 });
115
116 //Option Full Save
117 $(document).on('click', '.vs_template_all_slide .vs_template_save', function(e) {
118 var template_key = $(this).parents('.vs_template_slide').attr('data-key');
119
120
121 var data_name = $('[name="vs_template_name"]').val();
122 var data_slide = $('[name="vs_slide"]').val();
123
124 $('body').append('<div class="vs-mouse-wait"></div>');
125 $.ajax({
126 url: visualslider.ajaxurl,
127 type: 'POST',
128 data : {
129 action : 'vs_template_save_slide',
130 slide : data_slide,
131 id : 'slide',
132 name : data_name,
133 post_id : visualslider.post_id,
134 _wpnonce : visualslider.nonce,
135 },
136 success:function(data) {
137
138 $('.vs_template').remove();
139 $('.vs-mouse-wait').remove();
140 }
141
142 });
143
144 });
145
146
147
148
149
150 //Option Full Save
151 $(document).on('click', '.vs_template_slide .vs_template_save', function(e) {
152 var template_key = $(this).parents('.vs_template_slide').attr('data-key');
153
154
155 var slide = {};
156 $('#vs_module_slide_'+template_key).each(function() {
157 var key = $(this).attr('data-key');
158 var value = $(this).attr('data-value');
159 var option = $(this).find('.vs_module_slide_option').html();
160 var layer = $(this).find('.vs_module_slide_layer').html();
161
162 slide[key] = {'value' : value,'option':option ,'layer':layer };
163 });
164
165
166 var data_slide = $().vs_encode(slide,'sl');
167 var data_name = $('[name="vs_template_name"]').val();
168 $('body').append('<div class="vs-mouse-wait"></div>');
169
170 $.ajax({
171 url: visualslider.ajaxurl,
172 type: 'POST',
173 data : {
174 action : 'vs_template_save_slide',
175 slide : data_slide,
176 id : 'slide',
177 name : data_name,
178 post_id : visualslider.post_id,
179 _wpnonce : visualslider.nonce,
180 },
181 success:function(data) {
182
183 $('.vs_template').remove();
184 $('.vs-mouse-wait').remove();
185 }
186
187 });
188
189 });
190
191
192 $(document).on('click', '.vs_template_all_layer .vs_template_save', function(e) {
193 var template_key = $(this).parents('.vs_template_layer').attr('data-key');
194
195
196 var data_layer = '['+JSON.stringify($('body').vs_layer_json())+']';
197 var data_name = $('[name="vs_template_name"]').val();
198 $('body').append('<div class="vs-mouse-wait"></div>');
199 $.ajax({
200 url: visualslider.ajaxurl,
201 type: 'POST',
202 data : {
203 action : 'vs_template_save_layer',
204 layer : data_layer,
205 id : 'layer',
206 name : data_name,
207 post_id : visualslider.post_id,
208 _wpnonce : visualslider.nonce,
209 },
210 success:function(data) {
211
212 $('.vs_template').remove();
213 $('.vs-mouse-wait').remove();
214 }
215
216 });
217
218 });
219
220
221 $(document).on('click', '.vs_template_layer .vs_template_save', function(e) {
222 var template_key = $(this).parents('.vs_template_layer').attr('data-key');
223 var layer_key = {};
224 $('#vs_module_layer_'+template_key).each(function() {
225 var key = $(this).attr('data-key');
226 var id = $(this).attr('data-id');
227 var option = $(this).find('#vs_layer_options').vs_serializeFormToObject();
228
229 layer_key[key] = {'id' : id,'option':option };
230 });
231
232
233
234 var data_layer = $().vs_encode(layer_key,'ly');
235
236 var data_name = $('[name="vs_template_name"]').val();
237 $('body').append('<div class="vs-mouse-wait"></div>');
238 $.ajax({
239 url: visualslider.ajaxurl,
240 type: 'POST',
241 data : {
242 action : 'vs_template_save_layer',
243 layer : data_layer,
244 id : 'layer',
245 name : data_name,
246 post_id : visualslider.post_id,
247 _wpnonce : visualslider.nonce,
248 },
249 success:function(data) {
250
251 $('.vs_template').remove();
252 $('.vs-mouse-wait').remove();
253 }
254
255 });
256
257 });
258
259
260
261
262 /*************************************************************************************************************************************************************************
263 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
264
265 template Options
266
267 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
268 **************************************************************************************************************************************************************************/
269
270
271
272
273
274 $(document).on('click', '.vs_module_global_template_demo', function(e) {
275
276 $('body').append('<div class="vs-mouse-wait"></div>');
277 $.ajax({
278 url: visualslider.ajaxurl,
279 type: 'POST',
280 data : {
281 action : 'vs_template_demo',
282 post_id : visualslider.post_id,
283 _wpnonce : visualslider.nonce,
284 },
285 success:function(data) {
286 $('body').append(data);
287 $('.vs-mouse-wait').remove();
288
289
290 }
291
292 });
293
294 });
295 $(document).on('click', '.vs_module_global_template_add', function(e) {
296
297 $('body').append('<div class="vs-mouse-wait"></div>');
298 $.ajax({
299 url: visualslider.ajaxurl,
300 type: 'POST',
301 data : {
302 action : 'vs_template_options',
303 id : 'global',
304 post_id : visualslider.post_id,
305 _wpnonce : visualslider.nonce,
306 },
307 success:function(data) {
308 $('body').append(data);
309 $('.vs-mouse-wait').remove();
310
311
312 }
313
314 });
315
316 });
317
318 $(document).on('click', '.vs_module_slide_template_add ', function(e) {
319
320 $('body').append('<div class="vs-mouse-wait"></div>');
321
322 $.ajax({
323 url: visualslider.ajaxurl,
324 type: 'POST',
325 data : {
326 action : 'vs_template_options',
327 id : 'slide',
328 post_id : visualslider.post_id,
329 _wpnonce : visualslider.nonce,
330 },
331 success:function(data) {
332 $('body').append(data);
333 $('.vs-mouse-wait').remove();
334
335 }
336
337 });
338
339 });
340
341 $(document).on('click', '.vs_module_layer_template_add ', function(e) {
342
343 $('body').append('<div class="vs-mouse-wait"></div>');
344
345 $.ajax({
346 url: visualslider.ajaxurl,
347 type: 'POST',
348 data : {
349 action : 'vs_template_options',
350 id : 'layer',
351 post_id : visualslider.post_id,
352 _wpnonce : visualslider.nonce,
353 },
354 success:function(data) {
355 $('body').append(data);
356 $('.vs-mouse-wait').remove();
357
358 }
359
360 });
361
362 });
363
364
365
366
367
368 // Full Template ADD Select
369 $(document).on('click', '.vs_template_item', function(e) {
370 $(this).parent().find('.selected').removeClass('selected');
371 $(this).addClass("selected");
372 });
373
374 /*************************************************************************************************************************************************************************
375 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
376
377 Export Pross
378
379 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
380 **************************************************************************************************************************************************************************/
381 /*************************************************************************************************************************************************************************
382 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
383 UrlCode
384 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
385 **************************************************************************************************************************************************************************/
386 function urlencode(inputString='') {
387 if (inputString && typeof inputString !== 'object') {
388 try {
389 return btoa(encodeURIComponent(inputString));
390 } catch (e) {
391 return '';
392 }
393 } else {
394 return '';
395 }
396 }
397 //Option Full Save
398 $(document).on('click', ' .vs_module_global_template_export ', function(e) {
399 var data_setting = $('[name="vs_setting_json"]').val();
400 var data_slide = $('[name="vs_slide"]').val();
401 $('body').append('<div class="vs-mouse-wait"></div>');
402 $.ajax({
403 url: visualslider.ajaxurl,
404 type: 'POST',
405 data : {
406 action : 'vs_template_export',
407 setting : urlencode(data_setting),
408 slide : urlencode(data_slide),
409 post_id : visualslider.post_id,
410 _wpnonce : visualslider.nonce,
411
412 },
413 success:function(data) {
414 $('body').append(data);
415 $('.vs-mouse-wait').remove();
416 }
417
418 });
419
420
421 });
422
423 //Option Full Save
424 $(document).on('click', ' .vs_module_global_template_import ', function(e) {
425
426 $('body').append('<div class="vs-mouse-wait"></div>');
427 $.ajax({
428 url: visualslider.ajaxurl,
429 type: 'POST',
430 data : {
431 action : 'vs_template_import',
432 post_id : visualslider.post_id,
433 _wpnonce : visualslider.nonce,
434 },
435 success:function(data) {
436 $('body').append(data);
437 $('.vs-mouse-wait').remove();
438 }
439
440 });
441
442
443 });
444
445
446 $(document).on('click', '.vs_template_import .vs_template_add', function(e) {
447 var vs_template_import = $('[name="vs_template_import"]').val();
448
449
450 $('body').append('<div class="vs-mouse-wait"></div>');
451
452 $.ajax({
453 type: 'POST',
454
455 url: visualslider.ajaxurl,
456 data : {
457 action : 'vs_module_content',
458 template_import : vs_template_import,
459 post_id : visualslider.post_id,
460 _wpnonce : visualslider.nonce,
461 },
462 success:function(data) {
463
464 if( data.length){
465 $('.vs_module_content').html('');
466 $('.vs_module_content').append( data);
467 $('.vs-mouse-wait').remove();
468 $('.vs_template').remove();
469 $('body').vs_reload_global_slider();
470 $('body').vs_sortable();
471 $('body').vs_coloris();
472 $('body').vs_setting_json();
473 $(".vs_module_setting").on('change keyup mousedown',function() {
474 $('body').vs_setting_json();
475 });
476
477 }else{
478 $('body').vs_remove_add_error_loading();
479 }
480
481 }
482 });
483 });
484 /*************************************************************************************************************************************************************************
485 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
486
487 template add
488
489 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
490 **************************************************************************************************************************************************************************/
491
492 $(document).on('click', '.vs_template_demo .vs_template_add', function(e) {
493 var data_id = $('.vs_template_item.selected').attr('data-id');
494
495
496 $('body').append('<div class="vs-mouse-wait"></div>');
497
498 $.ajax({
499 type: 'POST',
500
501 url: visualslider.ajaxurl,
502 data : {
503 action : 'vs_module_content',
504 global_demo_template_id : data_id,
505 post_id : visualslider.post_id,
506 _wpnonce : visualslider.nonce,
507 },
508 success:function(data) {
509
510 if( data.length){
511 $('.vs_module_content').html('');
512 $('.vs_module_content').append( data);
513 $('.vs-mouse-wait').remove();
514 $('.vs_template').remove();
515 $('body').vs_reload_global_slider();
516 $('body').vs_sortable();
517 $('body').vs_coloris();
518 $('body').vs_setting_json();
519 $(".vs_module_setting").on('change keyup mousedown',function() {
520 $('body').vs_setting_json();
521 });
522
523 }else{
524 $('body').vs_remove_add_error_loading();
525 }
526
527 }
528 });
529 });
530
531
532
533
534 $(document).on('click', '.vs_template_global .vs_template_add', function(e) {
535 var data_id = $('.vs_template_item.selected').attr('data-id');
536
537
538 $('body').append('<div class="vs-mouse-wait"></div>');
539
540 $.ajax({
541 type: 'POST',
542
543 url: visualslider.ajaxurl,
544 data : {
545 action : 'vs_module_content',
546 global_template_id : data_id,
547 post_id : visualslider.post_id,
548 _wpnonce : visualslider.nonce,
549 },
550 success:function(data) {
551
552 if( data.length){
553 $('.vs_module_content').html('');
554 $('.vs_module_content').append( data);
555 $('.vs-mouse-wait').remove();
556 $('.vs_template').remove();
557 $('body').vs_reload_global_slider();
558 $('body').vs_sortable();
559 $('body').vs_coloris();
560 $(".vs_module_setting").on('change keyup mousedown',function() {
561 $('body').vs_setting_json();
562 });
563
564 }else{
565 $('body').vs_remove_add_error_loading();
566 }
567
568 }
569 });
570 });
571
572 $(document).on('click', '.vs_template_slide .vs_template_add', function(e) {
573 var data_id = $('.vs_template_item.selected').attr('data-id');
574
575 $('body').append('<div class="vs-mouse-wait"></div>');
576
577 $.ajax({
578 type: 'POST',
579
580 url: visualslider.ajaxurl,
581 data : {
582 action : 'vs_module_slide_list',
583 slide_template_id : data_id,
584 post_id : visualslider.post_id,
585 _wpnonce : visualslider.nonce,
586
587 },
588 success:function(data) {
589
590 if( data.length){
591 $('.vs_module_slide_list').append( data);
592 $('.vs-mouse-wait').remove();
593 $('.vs_template').remove();
594 $('body').vs_slide_json();
595 $('body').vs_reload_global_slider();
596 $('body').vs_sortable();
597 $('body').vs_coloris();
598 $('body').vs_setting_json();
599
600 }else{
601 $('body').vs_remove_add_error_loading();
602 }
603
604 }
605 });
606 });
607
608
609 function empty(variable){
610 if(variable === "undefined" && variable === null && variable === ''){
611 return '';
612 }else{
613 return variable;
614 }
615 }
616
617 $(document).on('click', '.vs_template_layer .vs_template_add', function(e) {
618 var data_id = $('.vs_template_item.selected').attr('data-id');
619 $('body').append('<div class="vs-mouse-wait"></div>');
620 var data_tablet= $('.vs_live_setting_responsive_tablet').find('input:checked').val();
621 var data_mobile= $('.vs_live_setting_responsive_mobile').find('input:checked').val();
622 $.ajax({
623 type: 'POST',
624
625 url: visualslider.ajaxurl,
626 data : {
627 action : 'vs_module_layer_list',
628 layer_template_id : data_id,
629 vs_tablet : empty(data_tablet),
630 vs_mobile : empty(data_mobile),
631 post_id : visualslider.post_id,
632 _wpnonce : visualslider.nonce,
633 },
634 success:function(data) {
635
636 if( data.length){
637 $('.vs_module_layer_list').append( data);
638 $('.vs-mouse-wait').remove();
639 $('.vs_template').remove();
640 $('body').vs_reload_layer();
641
642 $('body').find('.vs_module_layer_item').each(function() {
643 $(this).vs_layer_options_perview();
644 });
645 $('body').vs_sortable_layer();
646 $('body').vs_draggable();
647
648
649 }else{
650 $('body').vs_remove_add_error_loading();
651 }
652
653 }
654 });
655 });
656
657
658 //Template Remove
659 $(document).on('click', '.vs_template_remove', function(e) {
660 var data_template = $(this).parent();
661 var data_key = data_template.attr('data-id');
662 var data_row = $(this).parents('.vs_template').attr('data-row');
663
664 $('body').append('<div class="vs-mouse-wait"></div>');
665 var txt;
666 var r = confirm('Do you agree to delete this item?');
667 if (r == true) {
668
669 $.ajax({
670 url: visualslider.ajaxurl,
671 type: 'POST',
672 data : {
673 action : 'vs_template_remove',
674 key : data_key,
675 id : data_row,
676 post_id : visualslider.post_id,
677 _wpnonce : visualslider.nonce,
678 },
679 success:function(data) {
680 $(data_template).remove();
681 $('.vs-mouse-wait').remove();
682
683 }
684 });
685
686 }
687 });
688 });
689
690 });
691