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

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

305 lines 15.4 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 function isset(variable){
4 return variable !== "undefined" && variable !== "0" && variable !== null && variable !== '';
5 }
6
7 function empty(variable){
8 if(variable === "undefined" && variable === null && variable === ''){
9 return '';
10 }else{
11 return variable;
12 }
13 }
14
15 /*************************************************************************************************************************************************************************
16 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
17
18 Fold Hide
19
20 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21 **************************************************************************************************************************************************************************/
22 $.fn.vs_remove_add_error_loading = function() {
23 var output ='';
24 output ='<div class="vs-errored">Error</div>';
25
26 $('.vs-mouse-wait').append(output);
27 setTimeout(function(){ $('.vs-mouse-wait').remove() }, 2500);
28 };
29
30
31 /*************************************************************************************************************************************************************************
32 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
33
34 Hover
35
36 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
37 **************************************************************************************************************************************************************************/
38 $.fn.vs_item_hover = function() {
39
40 $('.vs-slide-item .vs-slide-inner').each( function(i) {
41 var count = i + 1;
42 $(this).append('<div class="vs_module_slide_top " data-count="'+count+'"><a class="vs_module_slide_options"></a><a class="vs_module_slide_duplicate"></a><a class="vs_module_slide_template_save vs_module_template_save" data-id="slide"></a><a class="vs_module_slide_remove"></a></div>');
43 });
44
45
46 };
47
48
49 /*************************************************************************************************************************************************************************
50 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
51
52 Global Slider
53
54 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
55 **************************************************************************************************************************************************************************/
56 function settingEmptyAndZero(obj) {
57 for (var key in obj) {
58 if (obj[key] === null || obj[key] === undefined || obj[key] === '') {
59 delete obj[key];
60 } else if ($.type(obj[key]) === 'object') {
61 settingEmptyAndZero(obj[key]);
62 var sum = Object.values(obj[key]).reduce(function(acc, val) {
63 return acc + val;
64 }, 0);
65 if (sum === 0) {
66 delete obj[key];
67 }
68 }
69 }
70 return obj;
71 }
72
73 $.fn.vs_setting_json = function() {
74 var data_option = $('#post').vs_serializeFormToObject();
75 var setting= $().vs_encode($().vs_settingEmptyAndZero(data_option['vs_setting']),'st');
76 $('#vs_setting_json').val(setting);
77 };
78
79
80 $.fn.vs_reload_global_slider = function() {
81 var data_key = Math.floor(Math.random() * 9999999999);
82 var height = $(this).height();
83 $(this).height(height);
84 $('.vs_perview_global').addClass('vs-active-loading').removeClass('vs-perview-show');
85 $('.vs_perview_global_content').attr('data-key',data_key).addClass('vs-loading');
86
87 setTimeout(function(){
88 var data_setting_json = $('#vs_setting_json').val();
89 var data_slide_json = $('#vs_slide').val();
90 $.ajax({
91 type: 'POST',
92 url: visualslider.ajaxurl,
93 data : {
94 action : 'vs_perview_global',
95 vs_setting_json : data_setting_json,
96 vs_slide : data_slide_json,
97 post_id : visualslider.post_id,
98 _wpnonce : visualslider.nonce,
99 },
100 success:function(data) {
101 if(data.length){
102 $('.vs_perview_global_content[data-key="'+data_key+'"]').children().remove();
103 $('.vs_perview_global_content[data-key="'+data_key+'"]').removeClass('vs-loading').append(data);
104 setTimeout(function(){
105 $('body').vs_custom_slider();
106 $('body').vs_perview_size();
107 $('body').vs_item_hover();
108 $('.vs_perview_global_content[data-key="'+data_key+'"]').height('auto');
109 }, 50);
110 } else{
111 vs_remove_add_error_loading();
112 }
113 }
114 });
115 }, 500);
116
117 };
118
119 jQuery(document).ready(function() {
120
121
122
123
124
125
126
127
128
129 /*************************************************************************************************************************************************************************
130 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
131
132 Iseet
133
134 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
135 **************************************************************************************************************************************************************************/
136
137 /*************************************************************************************************************************************************************************
138 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
139
140 Slug
141
142 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
143 **************************************************************************************************************************************************************************/
144 $(document).on("click",'#edit-slug-buttons .save',function() {
145 setTimeout(function(){
146 var slug = $('#editable-post-name').text();
147 $('#vs_shortcode').text('[visualslider id="'+slug+'"][/visualslider]');
148 },2000);
149 });
150
151 /*************************************************************************************************************************************************************************
152 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
153
154 Scroll Center
155
156 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
157 **************************************************************************************************************************************************************************/
158 function scrollMeTo($Parent, $Child) {
159 let parentHalf = $Parent.width() / 2; // half of parent width
160 let childHalf = $Child.width() / 2; //half of child width
161 let childPos = $Child.position().left; // X pos of child (relative to screen)
162 //We increase X with the center of the child (childHalf) - scrolling here we see the right half of the child;
163 //We decrease X with the parentHalf to obtain perfect center;
164 let scroll = childPos + childHalf - parentHalf; //how much we need to scroll to the element
165 //We now add the needed scroll to the current scroll.
166 let nextScroll = $Parent.scrollLeft() + scroll;
167 $Parent.scrollLeft(nextScroll);
168
169 }
170 if($('.vs_perview_global_scroll').hasClass('vs_perview_global_scroll')){
171 scrollMeTo($('.vs_perview_global_scroll'),$('.vs_perview_global_content '));
172 }
173
174
175
176
177 /*************************************************************************************************************************************************************************
178 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
179
180 Json
181
182 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
183 **************************************************************************************************************************************************************************/
184 $(".vs_module_setting").on('change keyup mousedown',function() {
185 $('body').vs_setting_json();
186 });
187
188
189
190
191
192
193
194 /*************************************************************************************************************************************************************************
195 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
196 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
197 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
198 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
199
200 Slide Options
201
202 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
203 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
204 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
205 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
206 **************************************************************************************************************************************************************************/
207
208 $(document).on('click', ".vs_animte_play", function(e) {
209
210
211
212 $('.vs_perview_slide').addClass('vs_perview_animte_active');
213
214 var duplicate = $(".vs-perview-slide").clone();
215 $(".vs_perview_slide_content .vs-slide-list").append(duplicate);
216 $(".vs_perview_slide_content div.vs-slide:last-child").addClass('vs-slide-item active').removeClass('vs-perview-slide');
217
218 $('.vs_module_layer_item').each( function(index, element) {
219 $(this).vs_layer_effectss();
220 });
221
222
223 setTimeout(function(){
224 $(".vs_perview_slide_content div.vs-slide:last-child").addClass('vs-animte-active');
225 }, 100);
226
227
228
229 });
230
231 $(document).on('click', ".vs_perview_animte_active .vs_animte_stop", function(e) {
232
233 $('.vs_perview_slide ').removeClass('vs_perview_animte_active');
234 $('.vs_perview_slide_content .vs-slide-item').remove();
235
236
237 });
238
239
240 /*************************************************************************************************************************************************************************
241 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
242 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
243 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
244 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
245
246 Perview Content All ELEMENT
247
248 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
249 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
250 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
251 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
252 **************************************************************************************************************************************************************************/
253
254
255 $(document).on("click", ".vs_perview_global .vs_module_slide_top .vs_module_slide_options", function(){
256 e.preventDefault();
257 var data= $(this).parent().attr('data-count');
258 $('.vs_module_slide_item[data-count="'+data+'"] .vs_module_slide_options').trigger("click");
259 });
260 $(document).on("click", ".vs_perview_global .vs_module_slide_top .vs_module_slide_duplicate", function(){
261 e.preventDefault();
262 var data= $(this).parent().attr('data-count');
263 $('.vs_module_slide_item[data-count="'+data+'"] .vs_module_slide_duplicate').trigger("click");
264 });
265 $(document).on("click", ".vs_perview_global .vs_module_slide_top .vs_module_slide_template_save", function(){
266 e.preventDefault();
267 var data= $(this).parent().attr('data-count');
268 $('.vs_module_slide_item[data-count="'+data+'"] .vs_module_slide_template_save').trigger("click");
269 });
270 $(document).on("click", ".vs_perview_global .vs_module_slide_top .vs_module_slide_remove", function(){
271 e.preventDefault();
272 var data= $(this).parent().attr('data-count');
273 $('.vs_module_slide_item[data-count="'+data+'"] .vs_module_slide_remove').trigger("click");
274 });
275
276
277
278
279 $(document).on('change keyup mousedown input','.vs_module_side_options_active',function() {
280 $(this).vs_layer_options_perview();
281
282 });
283 $(document).on('change keyup mousedown input','#vs_module_slide_options',function() {
284 $('body').vs_perview_slide();
285
286 });
287
288
289
290 $(document).on('change keyup mousedown mousemove','#clr-picker',function() {
291 $('.vs_module_side_options_active').vs_layer_options_perview();
292 $('#vs_module_slide_options').vs_perview_slide();
293
294 });
295
296 $(document).on('click','.vs_perview_heading_change,.vs_module_setting input',function() {
297 $('body').vs_reload_global_slider();
298 });
299
300 $('body').vs_setting_json();
301 $('body').vs_reload_global_slider();
302 });
303
304 });
305