PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 4.0.1
YITH WooCommerce Wishlist v4.0.1
4.16.0 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.25 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.10.0 3.11.0 3.12.0 3.13.0 3.14.0 3.15.0 3.16.0 3.17.0 3.18.0 3.19.0 3.2.0 3.20.0 3.21.0 3.22.0 3.23.0 3.24.0 3.25.0 3.26.0 3.27.0 3.28.0 3.29.0 3.3.0 3.30.0 3.31.0 3.32.0 3.33.0 3.34.0 3.35.0 3.36.0 3.37.0 3.38.0 3.4.0 3.5.0 3.6.0 3.7.0 3.8.0 3.9.0 4.0.0 4.0.1 4.1.0 4.10.0 4.10.1 4.10.2 4.11.0 4.12.0 4.13.0 4.14.0 4.15.0 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.8.0 4.9.0
yith-woocommerce-wishlist / plugin-fw / assets / js / yit-plugin-panel.js
yith-woocommerce-wishlist / plugin-fw / assets / js Last commit date
codemirror 4 years ago jquery-tiptip 5 years ago select2 5 years ago how-to.js 8 years ago how-to.min.js 6 years ago jquery.colorbox.js 8 years ago jquery.colorbox.min.js 6 years ago metabox.js 4 years ago metabox.min.js 4 years ago multisite-updater.js 2 years ago multisite-updater.min.js 6 years ago welcome-modal.js 3 years ago welcome-modal.min.js 3 years ago wp-pages.js 3 years ago wp-pages.min.js 3 years ago yit-cpt-unlimited.js 6 years ago yit-cpt-unlimited.min.js 6 years ago yit-plugin-panel.js 1 year ago yit-plugin-panel.min.js 1 year ago yit-wp-pointer.js 5 years ago yit-wp-pointer.min.js 5 years ago yith-bh-onboarding.js 3 years ago yith-bh-onboarding.min.js 3 years ago yith-colorpicker.min.js 5 years ago yith-dashboard.js 7 years ago yith-dashboard.min.js 6 years ago yith-date-format.js 5 years ago yith-date-format.min.js 5 years ago yith-enhanced-select-wc-2.6.js 5 years ago yith-enhanced-select-wc-2.6.min.js 5 years ago yith-enhanced-select.js 2 years ago yith-enhanced-select.min.js 2 years ago yith-fields.js 2 years ago yith-fields.min.js 2 years ago yith-promo.js 7 years ago yith-promo.min.js 6 years ago yith-system-info.js 2 years ago yith-system-info.min.js 2 years ago yith-ui.js 1 year ago yith-ui.min.js 1 year ago yith-update-plugins.js 7 years ago yith-update-plugins.min.js 6 years ago
yit-plugin-panel.js
438 lines
1 /* global setUserSetting, yith, yithFwPluginPanel */
2 jQuery( function ( $ ) {
3 // Handle dependencies.
4 function dependencies_handler( id, deps, values, type ) {
5 var result = true;
6 if ( typeof ( deps ) == 'string' ) {
7 if ( deps.substr( 0, 6 ) === ':radio' ) {
8 deps = deps + ':checked';
9 }
10
11 var depsOn = $( deps ),
12 depsOnType = depsOn.attr( 'type' ),
13 val = depsOn.val();
14
15 switch ( depsOnType ) {
16 case 'checkbox':
17 val = depsOn.is( ':checked' ) ? 'yes' : 'no';
18 break;
19 case 'radio':
20 val = depsOn.find( 'input[type="radio"]' ).filter( ':checked' ).val();
21 break;
22 }
23
24 values = values.split( ',' );
25
26 for ( var i = 0; i < values.length; i++ ) {
27 if ( val != values[ i ] ) {
28 result = false;
29 } else {
30 result = true;
31 break;
32 }
33 }
34 }
35
36 var $current_field = $( id ),
37 $current_container = $( id + '-container' ).closest( 'tr' ); // container for YIT Plugin Panel
38
39 if ( $current_container.length < 1 ) {
40 // container for YIT Plugin Panel WooCommerce
41 $current_container = $current_field.closest( '.yith-plugin-fw__panel__option, .yith-plugin-fw-panel-wc-row, .yith-toggle-content-row' );
42 }
43
44 var types = type.split( '-' ), j;
45 for ( j in types ) {
46 var current_type = types[ j ];
47
48 if ( !result ) {
49 switch ( current_type ) {
50 case 'disable':
51 $current_container.addClass( 'yith-disabled' );
52 $current_field.attr( 'disabled', true );
53 break;
54 case 'hide':
55 case 'hideNow':
56 $current_container.hide();
57 break;
58 case 'hideme':
59 $current_field.hide();
60 break;
61 case 'fadeInOut':
62 case 'fadeOut':
63 $current_container.hide( 500 );
64 break;
65 case 'fadeIn':
66 default:
67 $current_container.hide();
68 }
69 } else {
70 switch ( current_type ) {
71 case 'disable':
72 $current_container.removeClass( 'yith-disabled' );
73 $current_field.attr( 'disabled', false );
74 break;
75 case 'hide':
76 case 'hideNow':
77 $current_container.show();
78 break;
79 case 'hideme':
80 $current_field.show();
81 break;
82 case 'fadeOut':
83 $current_container.show();
84 break;
85 case 'fadeInOut':
86 case 'fadeIn':
87 default:
88 $current_container.show( 500 );
89 }
90 }
91 }
92 }
93
94 function init_dependencies() {
95 $( '[data-dep-target]:not( .deps-initialized )' ).each( function () {
96 var t = $( this );
97
98 if ( t.closest( '.metaboxes-tab' ).length ) {
99 // Let meta-boxes handle their own deps.
100 return;
101 }
102
103 // init field deps
104 t.addClass( 'deps-initialized' );
105
106 var field = '#' + t.data( 'dep-target' ),
107 dep = '#' + t.data( 'dep-id' ),
108 value = t.data( 'dep-value' ),
109 type = t.data( 'dep-type' );
110
111 $( dep ).on( 'change', function () {
112 dependencies_handler( field, dep, value.toString(), type );
113 } ).trigger( 'change' );
114 } );
115 }
116
117 init_dependencies();
118
119 $( document ).on( 'yith-plugin-fw-panel-init-deps', init_dependencies );
120
121 // re-init deps after an add toggle action
122 $( document ).on( 'yith-add-box-button-toggle', init_dependencies );
123
124 //connected list
125 $( '.rm_connectedlist' ).each( function () {
126 var ul = $( this ).find( 'ul' );
127 var input = $( this ).find( ':hidden' );
128 var sortable = ul.sortable( {
129 connectWith: ul,
130 update : function ( event, ui ) {
131 var value = {};
132
133 ul.each( function () {
134 var options = {};
135
136 $( this ).children().each( function () {
137 options[ $( this ).data( 'option' ) ] = $( this ).text();
138 } );
139
140 value[ $( this ).data( 'list' ) ] = options;
141 } );
142
143 input.val( ( JSON.stringify( value ) ).replace( /[\\"']/g, '\\$&' ).replace( /\u0000/g, '\\0' ) );
144 }
145 } ).disableSelection();
146 } );
147
148 //google analytics generation
149 $( function () {
150 $( '.google-analytic-generate' ).click( function () {
151 var editor = $( '#' + $( this ).data( 'textarea' ) ).data( 'codemirrorInstance' );
152 var gatc = $( '#' + $( this ).data( 'input' ) ).val();
153 var basename = $( this ).data( 'basename' );
154
155 var text = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n";
156 text += "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\n";
157 text += "m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n";
158 text += "})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n";
159 text += "ga('create', '" + gatc + "', '" + basename + "');\n";
160 text += "ga('send', 'pageview');\n";
161 editor.replaceRange(
162 text,
163 editor.getCursor( 'start' ),
164 editor.getCursor( 'end' )
165 );
166 } );
167 } );
168
169
170 // Prevent the WC message for changes when leaving the panel page
171 $( '.yith-plugin-fw-panel .woo-nav-tab-wrapper' ).removeClass( 'woo-nav-tab-wrapper' ).addClass( 'yith-nav-tab-wrapper' );
172
173 ( function () {
174 var noticesWrapper = $( '#yith-plugin-fw__panel__notices' ),
175 wrap = $( '.wrap.yith-plugin-ui, .yith-plugin-fw-wp-page-wrapper' ).first(), // TODO: remove when all plugins will use the ui-version 2, since notices will be shown in the noticesWrapper.
176 notices = $( 'div.updated, div.error, div.notice, .yith-plugin-fw__notice, .yith-plugin-fw__notice-banner' ).not( '.inline, .yith-plugin-fw--inline' );
177
178 // Prevent moving notices into the wrapper
179 notices.addClass( 'inline' );
180 if ( noticesWrapper.length ) {
181 noticesWrapper.append( notices );
182 } else if ( wrap.length ) {
183 wrap.prepend( notices );
184 }
185 } )();
186
187 // Additional wrapping just in case 'wrap' div is placed within a sub-tab and it's not already wrapped twice.
188 // TODO: Deprecated usage, it'll be removed, since also custom panels should use the automatic-wrapping through 'show_container' param.
189 ( function () {
190 var active_subnav = $( '.yith-nav-sub-tab.nav-tab-active' ),
191 subnav_wrap = $( '.yith-plugin-fw-wp-page__sub-tab-wrap' );
192
193 if ( active_subnav.length && !subnav_wrap.length ) {
194 var mainWrapper = $( '.yith-plugin-fw-wp-page-wrapper' );
195 if ( !mainWrapper.length ) {
196 mainWrapper = $( '#wpbody-content > .yith-plugin-ui' );
197 }
198
199 if ( mainWrapper ) {
200 var defaultWrap = mainWrapper.find( '.yit-admin-panel-content-wrap' ); // at first, search for default wrap.
201 if ( defaultWrap.length ) {
202 defaultWrap.addClass( 'has-subnav' );
203 } else {
204 // try to wrap a generic wrap div in main wrapper
205 mainWrapper.find( '.wrap' ).wrap( '<div class="yith-plugin-fw-wp-page__sub-tab-wrap"></div>' );
206 }
207 }
208 }
209 } )();
210
211 // Float save button.
212 ( function () {
213 var floatSaveButton = $( '#yith-plugin-fw-float-save-button' ),
214 mainForm = $( '#plugin-fw-wc' ),
215 mainFormElement = mainForm.length ? mainForm.get( 0 ) : false,
216 saveButton = document.querySelector( '#main-save-button' );
217
218 function updateValuesForSpecialEditors() {
219 if ( 'tinyMCE' in window && 'triggerSave' in window.tinyMCE ) {
220 // Trigger saving to serialize the correct value for WP Editors.
221 window.tinyMCE.triggerSave();
222 }
223
224 // Trigger saving to serialize the correct value for each Codemirror Editor.
225 $( '.codemirror.codemirror--initialized' ).each( function () {
226 var editor = $( this ).data( 'codemirrorInstance' ) || false;
227 if ( editor && 'codemirror' in editor ) {
228 editor.codemirror.save();
229 }
230 } );
231 }
232
233 function checkButtonPosition() {
234 if ( isInViewport( saveButton ) ) {
235 floatSaveButton.removeClass( 'visible' );
236 } else {
237 floatSaveButton.addClass( 'visible' );
238 }
239 }
240
241 function isInViewport( el ) {
242 var rect = el.getBoundingClientRect(),
243 viewport = {
244 width : window.innerWidth || document.documentElement.clientWidth,
245 height: window.innerHeight || document.documentElement.clientHeight
246 };
247 return (
248 rect.top >= 0 &&
249 rect.left >= 0 &&
250 rect.top <= viewport.height &&
251 rect.left <= viewport.width
252 );
253 }
254
255 if ( floatSaveButton.length > 0 && mainForm.length > 0 ) {
256 checkButtonPosition();
257 document.addEventListener( 'scroll', checkButtonPosition, { passive: true } );
258
259 $( document ).on( 'click', '#yith-plugin-fw-float-save-button', function ( e ) {
260 e.preventDefault();
261
262 updateValuesForSpecialEditors();
263
264 if ( !!mainFormElement && !mainFormElement.checkValidity() ) {
265 mainFormElement.reportValidity();
266 return;
267 }
268
269 floatSaveButton.block(
270 {
271 message : null,
272 overlayCSS: {
273 background: 'transparent',
274 opacity : 0.6
275 }
276 }
277 );
278 $.post( document.location.href, mainForm.serialize() )
279 .done( function ( response ) {
280 floatSaveButton.unblock()
281 .addClass( 'green' )
282 .fadeOut( 300 )
283 .html( floatSaveButton.data( 'saved-label' ) )
284 .fadeIn( 300 )
285 .delay( 2500 )
286 .queue(
287 function ( next ) {
288 floatSaveButton.fadeOut(
289 500,
290 function () {
291 $( this ).removeClass( 'green' );
292 $( this ).html( $( this ).data( 'default-label' ) ).fadeIn( 500 );
293 }
294 );
295 next();
296 } );
297
298 // Prevent WooCommerce warning for changes without saving.
299 window.onbeforeunload = null;
300
301 $( document ).trigger( 'yith-plugin-fw-float-save-button-after-saving', [response] );
302 } );
303 } );
304 }
305 } )();
306
307 // Save - Reset.
308 ( function () {
309 $( document ).on( 'click', '#yith-plugin-fw__panel__content__save', function () {
310 // Prevent WooCommerce warning for changes without saving.
311 window.onbeforeunload = null;
312 var theForm = $( 'form#yith-plugin-fw-panel, form#plugin-fw-wc' );
313 if ( theForm.length ) {
314 var formElement = theForm.get( 0 );
315 if ( formElement.checkValidity() ) {
316 theForm.submit();
317 } else {
318 formElement.reportValidity();
319 }
320 }
321 } );
322
323 $( document ).on( 'click', '#yith-plugin-fw__panel__content__reset', function () {
324 // Prevent WooCommerce warning for changes without saving.
325 window.onbeforeunload = null;
326 $( 'form#yith-plugin-fw-panel-reset, form#plugin-fw-wc-reset' ).submit();
327 } );
328
329 $( document ).on( 'submit', 'form#yith-plugin-fw-panel-reset, form#plugin-fw-wc-reset', function ( e ) {
330 var form = $( this ),
331 confirmed = form.data( 'confirmed' );
332
333 if ( confirmed === 'yes' ) {
334 return;
335 }
336
337 e.preventDefault();
338
339 var modalOptions = {
340 title : yithFwPluginPanel.i18n.resetConfirmTitle,
341 message : yithFwPluginPanel.i18n.resetConfirmMessage,
342 closeAfterConfirm: false,
343 onConfirm : function () {
344 form.data( 'confirmed', 'yes' );
345 form.submit();
346 }
347 };
348
349 yith.ui.confirm( modalOptions );
350
351 } );
352 } )();
353
354 // Panel menu.
355 ( function () {
356 function getSidebar() {
357 if ( !this.__sidebar || !( 'node' in this.__sidebar ) || !( 'hasClass' in this.__sidebar.node ) || !this.__sidebar.node.hasClass( 'yith-plugin-fw__panel__sidebar--initialized' ) ) {
358 var sidebar = {};
359
360 sidebar.node = $( '.yith-plugin-fw__panel__sidebar' );
361 sidebar.node.addClass( 'yith-plugin-fw__panel__sidebar--initialized' );
362
363 sidebar.isCollapsed = function () {
364 return sidebar.node.hasClass( 'yith-plugin-fw__panel__sidebar--collapsed' );
365 };
366
367 sidebar.isFixed = function () {
368 return 'fixed' !== sidebar.node.css( 'position' );
369 };
370
371 sidebar.setCollapsed = function ( collapsed ) {
372 if ( collapsed ) {
373 sidebar.node.addClass( 'yith-plugin-fw__panel__sidebar--collapsed' );
374 setUserSetting( 'yithFwSidebarFold', 'f' );
375 } else {
376 sidebar.node.removeClass( 'yith-plugin-fw__panel__sidebar--collapsed' );
377 setUserSetting( 'yithFwSidebarFold', 'o' );
378 }
379 };
380
381 sidebar.setOpen = function ( open ) {
382 var animationClass = !document.body.classList.contains( 'rtl' ) ? 'yith-plugin-fw-animate__appear-from-left-full' : 'yith-plugin-fw-animate__appear-from-right-full';
383 if ( open ) {
384 sidebar.node.addClass( ['yith-plugin-fw--open', animationClass] );
385 } else {
386 sidebar.node.removeClass( ['yith-plugin-fw--open', animationClass] );
387 }
388 };
389
390 this.__sidebar = sidebar;
391 }
392
393 return this.__sidebar;
394 }
395
396 $( document ).on( 'click', '.yith-plugin-fw__panel__mobile__header__toggle', function () {
397 var sidebar = getSidebar();
398 sidebar.setOpen( true );
399 $( document.body ).append( $( '<div id="yith-plugin-fw__panel__sidebar__mobile-backdrop"></div>' ) );
400 } );
401
402 $( document ).on( 'click', '#yith-plugin-fw__panel__sidebar__mobile-backdrop', function () {
403 var sidebar = getSidebar();
404 sidebar.setOpen( false );
405 $( this ).remove();
406 } );
407
408 $( document ).on( 'click', '.yith-plugin-fw__panel__sidebar__collapse', function () {
409 var sidebar = getSidebar();
410 sidebar.setCollapsed( !sidebar.isCollapsed() );
411 } );
412
413 $( document ).on( 'click', '.yith-plugin-fw__panel__menu-item.yith-plugin-fw--has-submenu a.yith-plugin-fw__panel__menu-item__content', function ( event ) {
414 event.preventDefault();
415 var sidebar = getSidebar();
416
417 if ( sidebar.isCollapsed() && sidebar.isFixed() ) {
418 return;
419 }
420
421 var toggle = $( event.target ),
422 item = toggle.closest( '.yith-plugin-fw__panel__menu-item' ),
423 submenu = item.find( '.yith-plugin-fw__panel__submenu' );
424
425 if ( item.is( '.yith-plugin-fw--open' ) ) {
426 submenu.slideUp( 200 );
427 } else {
428 submenu.slideDown( 200 );
429 }
430
431 item.toggleClass( 'yith-plugin-fw--open' );
432
433 } );
434
435 } )();
436 } )
437 ;
438