YITH WooCommerce Compare - Version 2.3.22

Version Description

Released on 03 June 2020

  • New: Support for WooCommerce 4.2
  • Update: Plugin framework
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Compare
Version 2.3.22
Comparing to
See all releases

Code changes from version 2.3.21 to 2.3.22

README.txt CHANGED
@@ -4,12 +4,12 @@ Contributors: yithemes
4
  Tags: yith, woocommerce compare, compare products, product compare, product comparison
5
  Requires at least: 4.0
6
  Tested up to: 5.4
7
- Stable tag: 2.3.21
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  YITH WooCommerce Compare allows you to compare more products of your shop in one complete table.
12
- WooCommerce Compatible up to 4.1
13
 
14
  == Description ==
15
 
@@ -66,6 +66,11 @@ yith-woocommerce-compare-<WORDPRESS LOCALE >.mo
66
 
67
  == Changelog ==
68
 
 
 
 
 
 
69
  = 2.3.21 = Released on 28 April 2020
70
 
71
  * New: Support for WooCommerce 4.1
@@ -391,7 +396,7 @@ Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woo
391
 
392
  == Upgrade notice ==
393
 
394
- = 2.3.21 = Released on 28 April 2020
395
 
396
- * New: Support for WooCommerce 4.1
397
  * Update: Plugin framework
4
  Tags: yith, woocommerce compare, compare products, product compare, product comparison
5
  Requires at least: 4.0
6
  Tested up to: 5.4
7
+ Stable tag: 2.3.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  YITH WooCommerce Compare allows you to compare more products of your shop in one complete table.
12
+ WooCommerce Compatible up to 4.2
13
 
14
  == Description ==
15
 
66
 
67
  == Changelog ==
68
 
69
+ = 2.3.22 = Released on 03 June 2020
70
+
71
+ * New: Support for WooCommerce 4.2
72
+ * Update: Plugin framework
73
+
74
  = 2.3.21 = Released on 28 April 2020
75
 
76
  * New: Support for WooCommerce 4.1
396
 
397
  == Upgrade notice ==
398
 
399
+ = 2.3.22 = Released on 03 June 2020
400
 
401
+ * New: Support for WooCommerce 4.2
402
  * Update: Plugin framework
init.php CHANGED
@@ -3,17 +3,17 @@
3
  * Plugin Name: YITH WooCommerce Compare
4
  * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-compare/
5
  * Description: The <code><strong>YITH WooCommerce Compare</strong></code> plugin allow you to compare in a simple and efficient way products on sale in your shop and analyze their main features in a single table. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
- * Version: 2.3.21
7
  * Author: YITH
8
  * Author URI: https://yithemes.com/
9
  * Text Domain: yith-woocommerce-compare
10
  * Domain Path: /languages/
11
  * WC requires at least: 3.8
12
- * WC tested up to: 4.1
13
  *
14
  * @author YITH
15
  * @package YITH WooCommerce Compare
16
- * @version 2.3.21
17
  */
18
  /* Copyright 2020 Your Inspiration Themes (email : plugins@yithemes.com)
19
 
@@ -58,7 +58,7 @@ if ( ! function_exists( 'yith_plugin_registration_hook' ) ) {
58
  register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
59
 
60
  if ( ! defined( 'YITH_WOOCOMPARE_VERSION' ) ){
61
- define( 'YITH_WOOCOMPARE_VERSION', '2.3.21' );
62
  }
63
  if ( ! defined( 'YITH_WOOCOMPARE_FREE_INIT' ) ) {
64
  define( 'YITH_WOOCOMPARE_FREE_INIT', plugin_basename( __FILE__ ) );
3
  * Plugin Name: YITH WooCommerce Compare
4
  * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-compare/
5
  * Description: The <code><strong>YITH WooCommerce Compare</strong></code> plugin allow you to compare in a simple and efficient way products on sale in your shop and analyze their main features in a single table. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
+ * Version: 2.3.22
7
  * Author: YITH
8
  * Author URI: https://yithemes.com/
9
  * Text Domain: yith-woocommerce-compare
10
  * Domain Path: /languages/
11
  * WC requires at least: 3.8
12
+ * WC tested up to: 4.2
13
  *
14
  * @author YITH
15
  * @package YITH WooCommerce Compare
16
+ * @version 2.3.22
17
  */
18
  /* Copyright 2020 Your Inspiration Themes (email : plugins@yithemes.com)
19
 
58
  register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
59
 
60
  if ( ! defined( 'YITH_WOOCOMPARE_VERSION' ) ){
61
+ define( 'YITH_WOOCOMPARE_VERSION', '2.3.22' );
62
  }
63
  if ( ! defined( 'YITH_WOOCOMPARE_FREE_INIT' ) ) {
64
  define( 'YITH_WOOCOMPARE_FREE_INIT', plugin_basename( __FILE__ ) );
plugin-fw/assets/css/yith-fields.css CHANGED
@@ -1209,6 +1209,10 @@ span.select2.select2-container.select2-container--default.yith-plugin-fw-select2
1209
  font-size : 13px;
1210
  }
1211
 
 
 
 
 
1212
  .yith-plugin-ui .select2-container--default .select2-selection--single .select2-selection__arrow:before {
1213
  content : "\e900";
1214
  font-family : 'yith-icon' !important;
@@ -1427,8 +1431,9 @@ span.select2.select2-container.select2-container--default.yith-plugin-fw-select2
1427
  .yith-plugin-ui .yith-plugin-fw-onoff-container input + span {
1428
  border : 1px solid #d8d8d8;
1429
  background-color : #fff;
1430
- width : 60px;
1431
  height : 24px;
 
1432
  }
1433
 
1434
  .yith-plugin-ui .yith-plugin-fw-onoff-container input + span:before {
@@ -1465,7 +1470,7 @@ span.select2.select2-container.select2-container--default.yith-plugin-fw-select2
1465
  .yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:before,
1466
  .yith-plugin-ui.yith-plugin-fw-onoff-container input.onoffchecked + span:before {
1467
  background-color : #98aa36;
1468
- left : 41px;
1469
  }
1470
 
1471
  .yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:after,
1209
  font-size : 13px;
1210
  }
1211
 
1212
+ .wc-wp-version-gte-53 .yith-plugin-ui .select2-container .select2-selection--single .select2-selection__arrow{
1213
+ background-image: none;
1214
+ }
1215
+
1216
  .yith-plugin-ui .select2-container--default .select2-selection--single .select2-selection__arrow:before {
1217
  content : "\e900";
1218
  font-family : 'yith-icon' !important;
1431
  .yith-plugin-ui .yith-plugin-fw-onoff-container input + span {
1432
  border : 1px solid #d8d8d8;
1433
  background-color : #fff;
1434
+ width : 58px;
1435
  height : 24px;
1436
+ line-height :14px;
1437
  }
1438
 
1439
  .yith-plugin-ui .yith-plugin-fw-onoff-container input + span:before {
1470
  .yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:before,
1471
  .yith-plugin-ui.yith-plugin-fw-onoff-container input.onoffchecked + span:before {
1472
  background-color : #98aa36;
1473
+ left: 38px;
1474
  }
1475
 
1476
  .yith-plugin-ui .yith-plugin-fw-onoff-container input:checked + span:after,
plugin-fw/assets/js/yit-plugin-panel.js CHANGED
@@ -15,13 +15,21 @@ jQuery( function ( $ ) {
15
  var field = '#' + t.data( 'dep-target' ),
16
  dep = '#' + t.data( 'dep-id' ),
17
  value = t.data( 'dep-value' ),
18
- type = t.data( 'dep-type' );
 
 
 
 
 
 
 
19
 
20
  dependencies_handler( field, dep, value.toString(), type );
21
 
22
- $( dep ).on( 'change', function () {
23
  dependencies_handler( field, dep, value.toString(), type );
24
- } ).change();
 
25
  } );
26
 
27
  //Handle dependencies.
@@ -44,6 +52,10 @@ jQuery( function ( $ ) {
44
  }
45
  }
46
 
 
 
 
 
47
  values = values.split( ',' );
48
 
49
  for ( var i = 0; i < values.length; i++ ) {
@@ -178,4 +190,4 @@ jQuery( function ( $ ) {
178
  wrap.prepend( notices );
179
  }
180
 
181
- } );
15
  var field = '#' + t.data( 'dep-target' ),
16
  dep = '#' + t.data( 'dep-id' ),
17
  value = t.data( 'dep-value' ),
18
+ type = t.data( 'dep-type' ),
19
+ event = 'change',
20
+ wrapper = $( dep + '-wrapper' ),
21
+ field_type = wrapper.data( 'type' );
22
+
23
+ if( field_type === 'select-images' ){
24
+ event = 'yith_select_images_value_changed';
25
+ }
26
 
27
  dependencies_handler( field, dep, value.toString(), type );
28
 
29
+ $( dep ).on( event, function () {
30
  dependencies_handler( field, dep, value.toString(), type );
31
+ } ).trigger( event );
32
+
33
  } );
34
 
35
  //Handle dependencies.
52
  }
53
  }
54
 
55
+ if( $( deps + '-wrapper' ).data( 'type' ) === 'select-images' ){
56
+ val = $( deps + '-wrapper' ).find( 'select' ).first().val();
57
+ }
58
+
59
  values = values.split( ',' );
60
 
61
  for ( var i = 0; i < values.length; i++ ) {
190
  wrap.prepend( notices );
191
  }
192
 
193
+ } );
plugin-fw/assets/js/yit-plugin-panel.min.js CHANGED
@@ -1 +1,5 @@
1
- jQuery(function(a){function e(e,t,i,n){var s=!0;if("string"==typeof t){":radio"==t.substr(0,6)&&(t+=":checked");var r=a(t).val();if("checkbox"==a(t).attr("type"))r=a(t).is(":checked")?"yes":"no";i=i.split(",");for(var d=0;d<i.length;d++){if(r==i[d]){s=!0;break}s=!1}}var c=a(e),o=a(e+"-container").closest("tr");o.length<1&&(o=c.closest(".yith-plugin-fw-panel-wc-row"));var l,h=n.split("-");for(l in h){var f=h[l];if(s)switch(f){case"disable":o.removeClass("yith-disabled"),c.attr("disabled",!1);break;case"hideme":c.show();break;case"fadeInOut":case"fadeIn":o.show(500);break;case"fadeOut":o.show();break;default:o.show(),o.fadeTo("slow",1).addClass("fade-in")}else switch(f){case"disable":o.addClass("yith-disabled"),c.attr("disabled",!0);break;case"hideme":c.hide();break;case"fadeInOut":case"fadeOut":o.hide(500);break;case"fadeIn":o.hide();break;default:o.hasClass("fade-in")?o.fadeTo("slow",0,function(){a(this).hide().removeClass("fade-in")}):(o.hide(),o.css({opacity:"0"}))}}}a("[data-dep-target]").each(function(){var t=a(this),i="#"+t.data("dep-target"),n="#"+t.data("dep-id"),s=t.data("dep-value"),r=t.data("dep-type");e(i,n,s.toString(),r),a(n).on("change",function(){e(i,n,s.toString(),r)}).change()}),a(".rm_connectedlist").each(function(){var e=a(this).find("ul"),t=a(this).find(":hidden");e.sortable({connectWith:e,update:function(i,n){var s={};e.each(function(){var e={};a(this).children().each(function(){e[a(this).data("option")]=a(this).text()}),s[a(this).data("list")]=e}),t.val(JSON.stringify(s).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()}),a(document).ready(function(){a(".google-analytic-generate").click(function(){var e=a("#"+a(this).data("textarea")).data("codemirrorInstance"),t="(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n";t+="(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\n",t+="m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n",t+="})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n",t+="ga('create', '"+a("#"+a(this).data("input")).val()+"', '"+a(this).data("basename")+"');\n",t+="ga('send', 'pageview');\n",e.replaceRange(t,e.getCursor("start"),e.getCursor("end"))})}),a(".yith-plugin-fw-panel .woo-nav-tab-wrapper").removeClass("woo-nav-tab-wrapper").addClass("yith-nav-tab-wrapper");var t=a(".wrap.yith-plugin-ui").first(),i=a("div.updated, div.error, div.notice");i.addClass("inline"),t.length&&t.prepend(i)});
 
 
 
 
1
+ jQuery(function(b){function h(a,c,d,f){var e=!0;if("string"==typeof c){":radio"==c.substr(0,6)&&(c+=":checked");var g=b(c).val();"checkbox"==b(c).attr("type")&&(g=b(c).is(":checked")?"yes":"no");"select-images"===b(c+"-wrapper").data("type")&&(g=b(c+"-wrapper").find("select").first().val());d=d.split(",");for(c=0;c<d.length;c++)if(g!=d[c])e=!1;else{e=!0;break}}d=b(a);a=b(a+"-container").closest("tr");1>a.length&&(a=d.closest(".yith-plugin-fw-panel-wc-row"));f=f.split("-");for(var h in f)if(g=f[h],
2
+ e)switch(g){case "disable":a.removeClass("yith-disabled");d.attr("disabled",!1);break;case "hideme":d.show();break;case "fadeInOut":case "fadeIn":a.show(500);break;case "fadeOut":a.show();break;default:a.show(),a.fadeTo("slow",1).addClass("fade-in")}else switch(g){case "disable":a.addClass("yith-disabled");d.attr("disabled",!0);break;case "hideme":d.hide();break;case "fadeInOut":case "fadeOut":a.hide(500);break;case "fadeIn":a.hide();break;default:a.hasClass("fade-in")?a.fadeTo("slow",0,function(){b(this).hide().removeClass("fade-in")}):
3
+ (a.hide(),a.css({opacity:"0"}))}}b("[data-dep-target]").each(function(){var a=b(this),c="#"+a.data("dep-target"),d="#"+a.data("dep-id"),f=a.data("dep-value"),e=a.data("dep-type");a="change";"select-images"===b(d+"-wrapper").data("type")&&(a="yith_select_images_value_changed");h(c,d,f.toString(),e);b(d).on(a,function(){h(c,d,f.toString(),e)}).trigger(a)});b(".rm_connectedlist").each(function(){var a=b(this).find("ul"),c=b(this).find(":hidden");a.sortable({connectWith:a,update:function(d,f){var e={};
4
+ a.each(function(){var a={};b(this).children().each(function(){a[b(this).data("option")]=b(this).text()});e[b(this).data("list")]=a});c.val(JSON.stringify(e).replace(/[\\"']/g,"\\$&").replace(/\u0000/g,"\\0"))}}).disableSelection()});b(document).ready(function(){b(".google-analytic-generate").click(function(){var a=b("#"+b(this).data("textarea")).data("codemirrorInstance"),c=b("#"+b(this).data("input")).val(),d=b(this).data("basename");a.replaceRange("(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\nm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\nga('create', '"+
5
+ (c+"', '"+d+"');\nga('send', 'pageview');\n"),a.getCursor("start"),a.getCursor("end"))})});b(".yith-plugin-fw-panel .woo-nav-tab-wrapper").removeClass("woo-nav-tab-wrapper").addClass("yith-nav-tab-wrapper");var k=b(".wrap.yith-plugin-ui").first(),l=b("div.updated, div.error, div.notice");l.addClass("inline");k.length&&k.prepend(l)});
plugin-fw/assets/js/yith-colorpicker.min.js CHANGED
@@ -8,4 +8,4 @@
8
  * https://github.com/kallookoo/wp-color-picker-alpha
9
  * Licensed under the GPLv2 license or later.
10
  */
11
- !function(t){if(!t.wp.wpColorPicker.prototype._hasAlpha){var o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",r='<div class="wp-picker-holder" />',e='<div class="wp-picker-container" />',a='<input type="button" class="button button-small" />',i=void 0!==wpColorPickerL10n.current;if(i)var n='<a tabindex="0" class="wp-color-result" />';else{n='<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>';var l="<label></label>",s='<span class="screen-reader-text"></span>'}Color.fn.toString=function(){if(this._alpha<1)return this.toCSS("rgba",this._alpha).replace(/\s+/g,"");var t=parseInt(this._color,10).toString(16);return this.error?"":(t.length<6&&(t=("00000"+t).substr(-6)),"#"+t)},t.widget("wp.wpColorPicker",t.wp.wpColorPicker,{_hasAlpha:!0,_create:function(){if(t.support.iris){var p=this,c=p.element;if(t.extend(p.options,c.data()),"hue"===p.options.type)return p._createHueOnly();p.close=t.proxy(p.close,p),p.initialValue=c.val(),c.addClass("wp-color-picker"),i?(c.hide().wrap(e),p.wrap=c.parent(),p.toggler=t(n).insertBefore(c).css({backgroundColor:p.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current),p.pickerContainer=t(r).insertAfter(c),p.button=t(a).addClass("hidden")):(c.parent("label").length||(c.wrap(l),p.wrappingLabelText=t(s).insertBefore(c).text(wpColorPickerL10n.defaultLabel)),p.wrappingLabel=c.parent(),p.wrappingLabel.wrap(e),p.wrap=p.wrappingLabel.parent(),p.toggler=t(n).insertBefore(p.wrappingLabel).css({backgroundColor:p.initialValue}),p.toggler.find(".wp-color-result-text").text(wpColorPickerL10n.pick),p.pickerContainer=t(r).insertAfter(p.wrappingLabel),p.button=t(a)),p.options.defaultColor?(p.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString),i||p.button.attr("aria-label",wpColorPickerL10n.defaultAriaLabel)):(p.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear),i||p.button.attr("aria-label",wpColorPickerL10n.clearAriaLabel)),i?c.wrap('<span class="wp-picker-input-wrap" />').after(p.button):(p.wrappingLabel.wrap('<span class="wp-picker-input-wrap hidden" />').after(p.button),p.inputWrapper=c.closest(".wp-picker-input-wrap")),c.iris({target:p.pickerContainer,hide:p.options.hide,width:p.options.width,mode:p.options.mode,palettes:p.options.palettes,change:function(r,e){p.options.alpha?(p.toggler.css({"background-image":"url("+o+")"}),i?p.toggler.html('<span class="color-alpha" />'):(p.toggler.css({position:"relative"}),0==p.toggler.find("span.color-alpha").length&&p.toggler.append('<span class="color-alpha" />')),p.toggler.find("span.color-alpha").css({width:"30px",height:"24px",position:"absolute",top:0,left:0,"border-top-left-radius":"2px","border-bottom-left-radius":"2px",background:e.color.toString()})):p.toggler.css({backgroundColor:e.color.toString()}),t.isFunction(p.options.change)&&p.options.change.call(this,r,e)}}),c.val(p.initialValue),p._addListeners(),p.options.hide||p.toggler.click()}},_addListeners:function(){var o=this;o.wrap.on("click.wpcolorpicker",function(t){t.stopPropagation()}),o.toggler.click(function(){o.toggler.hasClass("wp-picker-open")?o.close():o.open()}),o.element.on("change",function(r){(""===t(this).val()||o.element.hasClass("iris-error"))&&(o.options.alpha?(i&&o.toggler.removeAttr("style"),o.toggler.find("span.color-alpha").css("backgroundColor","")):o.toggler.css("backgroundColor",""),t.isFunction(o.options.clear)&&o.options.clear.call(this,r))}),o.button.on("click",function(r){t(this).hasClass("wp-picker-clear")?(o.element.val(""),o.options.alpha?(i&&o.toggler.removeAttr("style"),o.toggler.find("span.color-alpha").css("backgroundColor","")):o.toggler.css("backgroundColor",""),t.isFunction(o.options.clear)&&o.options.clear.call(this,r),o.element.trigger("change")):t(this).hasClass("wp-picker-default")&&o.element.val(o.options.defaultColor).change()})}}),t.widget("a8c.iris",t.a8c.iris,{_create:function(){if(this._super(),this.options.alpha=this.element.data("alpha")||!1,this.element.is(":input")||(this.options.alpha=!1),void 0!==this.options.alpha&&this.options.alpha){var o=this,r=o.element,e=t('<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>').appendTo(o.picker.find(".iris-picker-inner")),a={aContainer:e,aSlider:e.find(".iris-slider-offset-alpha")};void 0!==r.data("custom-width")?o.options.customWidth=parseInt(r.data("custom-width"))||0:o.options.customWidth=100,o.options.defaultWidth=r.width(),(o._color._alpha<1||-1!=o._color.toString().indexOf("rgb"))&&r.width(parseInt(o.options.defaultWidth+o.options.customWidth)),t.each(a,function(t,r){o.controls[t]=r}),o.controls.square.css({"margin-right":"0"});var i=o.picker.width()-o.controls.square.width()-20,n=i/6,l=i/2-n;t.each(["aContainer","strip"],function(t,r){o.controls[r].width(l).css({"margin-left":n+"px"})}),o._initControls(),o._change()}},_initControls:function(){if(this._super(),this.options.alpha){var t=this;t.controls.aSlider.slider({orientation:"vertical",min:0,max:100,step:1,value:parseInt(100*t._color._alpha),slide:function(o,r){t._color._alpha=parseFloat(r.value/100),t._change.apply(t,arguments)}})}},_change:function(){this._super();var t=this,r=t.element;if(this.options.alpha){var e=t.controls,a=parseInt(100*t._color._alpha),i=t._color.toRgb(),n=["rgb("+i.r+","+i.g+","+i.b+") 0%","rgba("+i.r+","+i.g+","+i.b+", 0) 100%"],l=t.options.defaultWidth,s=t.options.customWidth,p=t.picker.closest(".wp-picker-container").find(".wp-color-result");e.aContainer.css({background:"linear-gradient(to bottom, "+n.join(", ")+"), url("+o+")"}),p.hasClass("wp-picker-open")&&(e.aSlider.slider("value",a),t._color._alpha<1?(e.strip.attr("style",e.strip.attr("style").replace(/rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g,"rgb($1$3$5)")),r.width(parseInt(l+s))):r.width(l))}(r.data("reset-alpha")||!1)&&t.picker.find(".iris-palette-container").on("click.palette",".iris-palette",function(){t._color._alpha=1,t.active="external",t._change()}),r.trigger("change")},_addInputListeners:function(t){var o=this,r=function(r){var e=new Color(t.val()),a=t.val();t.removeClass("iris-error"),e.error?""!==a&&t.addClass("iris-error"):e.toString()!==o._color.toString()&&("keyup"===r.type&&a.match(/^[0-9a-fA-F]{3}$/)||o._setOption("color",e.toString()))};t.on("change",r).on("keyup",o._debounce(r,100)),o.options.hide&&t.on("focus",function(){o.show()})}})}}(jQuery),jQuery(document).ready(function(t){t(".color-picker").wpColorPicker()});
8
  * https://github.com/kallookoo/wp-color-picker-alpha
9
  * Licensed under the GPLv2 license or later.
10
  */
11
+ !function(t){if(!t.wp.wpColorPicker.prototype._hasAlpha){var o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==",i='<div class="wp-picker-holder" />',a='<div class="wp-picker-container" />',e='<input type="button" class="button button-small" />',r='<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>';Color.fn.toString=function(){if(this._alpha<1)return this.toCSS("rgba",this._alpha).replace(/\s+/g,"");var t=parseInt(this._color,10).toString(16);return this.error?"":(t.length<6&&(t=("00000"+t).substr(-6)),"#"+t)},t.widget("wp.wpColorPicker",t.wp.wpColorPicker,{_hasAlpha:!0,_create:function(){if(t.support.iris){var n=this,l=n.element;if(t.extend(n.options,l.data()),"hue"===n.options.type)return n._createHueOnly();n.close=t.proxy(n.close,n),n.initialValue=l.val(),l.addClass("wp-color-picker"),l.parent("label").length||(l.wrap("<label></label>"),n.wrappingLabelText=t('<span class="screen-reader-text"></span>').insertBefore(l).text(wpColorPickerL10n.defaultLabel)),n.wrappingLabel=l.parent(),n.wrappingLabel.wrap(a),n.wrap=n.wrappingLabel.parent(),n.toggler=t(r).insertBefore(n.wrappingLabel).css({backgroundColor:n.initialValue}),n.toggler.find(".wp-color-result-text").text(wpColorPickerL10n.pick),n.pickerContainer=t(i).insertAfter(n.wrappingLabel),n.button=t(e),n.options.defaultColor?(n.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString),n.button.attr("aria-label",wpColorPickerL10n.defaultAriaLabel)):(n.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear),n.button.attr("aria-label",wpColorPickerL10n.clearAriaLabel)),n.wrappingLabel.wrap('<span class="wp-picker-input-wrap hidden" />').after(n.button),n.inputWrapper=l.closest(".wp-picker-input-wrap"),l.iris({target:n.pickerContainer,hide:n.options.hide,width:n.options.width,mode:n.options.mode,palettes:n.options.palettes,change:function(i,a){n.options.alpha?(n.toggler.css({"background-image":"url("+o+")"}),n.toggler.css({position:"relative"}),0==n.toggler.find("span.color-alpha").length&&n.toggler.append('<span class="color-alpha" />'),n.toggler.find("span.color-alpha").css({width:"30px",height:"24px",position:"absolute",top:0,left:0,"border-top-left-radius":"2px","border-bottom-left-radius":"2px",background:a.color.toString()})):n.toggler.css({backgroundColor:a.color.toString()}),t.isFunction(n.options.change)&&n.options.change.call(this,i,a)}}),l.val(n.initialValue),n._addListeners(),n.options.hide||n.toggler.click()}},_addListeners:function(){var o=this;o.wrap.on("click.wpcolorpicker",function(t){t.stopPropagation()}),o.toggler.click(function(){o.toggler.hasClass("wp-picker-open")?o.close():o.open()}),o.element.on("change",function(i){(""===t(this).val()||o.element.hasClass("iris-error"))&&(o.options.alpha?o.toggler.find("span.color-alpha").css("backgroundColor",""):o.toggler.css("backgroundColor",""),t.isFunction(o.options.clear)&&o.options.clear.call(this,i))}),o.button.on("click",function(i){t(this).hasClass("wp-picker-clear")?(o.element.val(""),o.options.alpha?o.toggler.find("span.color-alpha").css("backgroundColor",""):o.toggler.css("backgroundColor",""),t.isFunction(o.options.clear)&&o.options.clear.call(this,i),o.element.trigger("change")):t(this).hasClass("wp-picker-default")&&o.element.val(o.options.defaultColor).change()})}}),t.widget("a8c.iris",t.a8c.iris,{_create:function(){if(this._super(),this.options.alpha=this.element.data("alpha")||!1,this.element.is(":input")||(this.options.alpha=!1),void 0!==this.options.alpha&&this.options.alpha){var o=this,i=o.element,a=t('<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>').appendTo(o.picker.find(".iris-picker-inner")),e={aContainer:a,aSlider:a.find(".iris-slider-offset-alpha")};void 0!==i.data("custom-width")?o.options.customWidth=parseInt(i.data("custom-width"))||0:o.options.customWidth=100,o.options.defaultWidth=i.width(),(o._color._alpha<1||-1!=o._color.toString().indexOf("rgb"))&&i.width(parseInt(o.options.defaultWidth+o.options.customWidth)),t.each(e,function(t,i){o.controls[t]=i}),o.controls.square.css({"margin-right":"0"});var r=o.picker.width()-o.controls.square.width()-20,n=r/6,l=r/2-n;t.each(["aContainer","strip"],function(t,i){o.controls[i].width(l).css({"margin-left":n+"px"})}),o._initControls(),o._change()}},_initControls:function(){if(this._super(),this.options.alpha){var t=this;t.controls.aSlider.slider({orientation:"vertical",min:0,max:100,step:1,value:parseInt(100*t._color._alpha),slide:function(o,i){t._color._alpha=parseFloat(i.value/100),t._change.apply(t,arguments)}})}},_change:function(){this._super();var t=this,i=t.element;if(this.options.alpha){var a=t.controls,e=parseInt(100*t._color._alpha),r=t._color.toRgb(),n=["rgb("+r.r+","+r.g+","+r.b+") 0%","rgba("+r.r+","+r.g+","+r.b+", 0) 100%"],l=t.options.defaultWidth,s=t.options.customWidth,p=t.picker.closest(".wp-picker-container").find(".wp-color-result");a.aContainer.css({background:"linear-gradient(to bottom, "+n.join(", ")+"), url("+o+")"}),p.hasClass("wp-picker-open")&&(a.aSlider.slider("value",e),t._color._alpha<1?(a.strip.attr("style",a.strip.attr("style").replace(/rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g,"rgb($1$3$5)")),i.width(parseInt(l+s))):i.width(l))}!!i.data("reset-alpha")&&t.picker.find(".iris-palette-container").on("click.palette",".iris-palette",function(){t._color._alpha=1,t.active="external",t._change()}),i.trigger("change")},_addInputListeners:function(t){var o=this,i=function(i){var a=new Color(t.val()),e=t.val();t.removeClass("iris-error"),a.error?""!==e&&t.addClass("iris-error"):a.toString()!==o._color.toString()&&("keyup"===i.type&&e.match(/^[0-9a-fA-F]{3}$/)||o._setOption("color",a.toString()))};t.on("change",i).on("keyup",o._debounce(i,100)),o.options.hide&&t.on("focus",function(){o.show()})}})}}(jQuery),jQuery(document).ready(function(t){t(".color-picker").wpColorPicker()});
plugin-fw/assets/js/yith-fields.js CHANGED
@@ -1,734 +1,733 @@
1
  ( function ( $ ) {
2
 
3
- /* global yith_framework_fw_fields*/
4
-
5
- var yith_fields_init = function () {
6
- var $datepicker = $( '.yith-plugin-fw-datepicker' ),
7
- $colorpicker = $( '.yith-plugin-fw-colorpicker' ),
8
- $upload = {
9
- imgPreviewHandler : '.yith-plugin-fw-upload-img-preview',
10
- uploadButtonHandler: '.yith-plugin-fw-upload-button',
11
- imgUrlHandler : '.yith-plugin-fw-upload-img-url',
12
- resetButtonHandler : '.yith-plugin-fw-upload-button-reset',
13
- imgUrl : $( '.yith-plugin-fw-upload-img-url' )
14
- },
15
- $wpAddMedia = $( '.add_media' ),
16
- $imageGallery = {
17
- sliderWrapper: $( '.yith-plugin-fw .image-gallery ul.slides-wrapper' ),
18
- buttonHandler: '.yith-plugin-fw .image-gallery-button'
19
- },
20
- $sidebars = $( '.yith-plugin-fw-sidebar-layout' ),
21
- $slider = $( '.yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal' ),
22
- $codemirror = $( '.codemirror' ),
23
- $icons = $( '.yit-icons-manager-wrapper' ),
24
- $checkgroup = $( ".yith-plugin-ui td.forminp-checkbox" );
25
-
26
- /* Datepicker */
27
- $datepicker.each( function () {
28
- var args = $( this ).data();
29
-
30
- // set animation to false to prevent style 'glitches' when removing class on closing
31
- args.showAnim = false;
32
- args.beforeShow = function ( input, instance ) {
33
- instance.dpDiv.addClass( 'yith-plugin-fw-datepicker-div' );
34
- };
35
- args.onClose = function ( selectedDate, instance ) {
36
- instance.dpDiv.removeClass( 'yith-plugin-fw-datepicker-div' );
37
- };
38
-
39
- $( this ).datepicker( args );
40
- } );
41
-
42
- /* Colorpicker */
43
- $colorpicker.wpColorPicker( {
44
- palettes: false,
45
- width : 200,
46
- mode : 'hsl',
47
- clear : function () {
48
- var input = $( this );
49
- input.val( input.data( 'default-color' ) );
50
- input.change();
51
- }
52
- } );
53
-
54
-
55
- $colorpicker.each( function () {
56
- var select_label = $( this ).data( 'variations-label' ),
57
- wrap_main1 = $( this ).closest( '.yith-plugin-fw-colorpicker-field-wrapper' ),
58
- wrap_main2 = $( this ).closest( '.yith-single-colorpicker' ),
59
- wrap1 = wrap_main1.find( '.wp-picker-input-wrap' ),
60
- wrap2 = wrap_main2.find( '.wp-picker-input-wrap' );
61
-
62
- wrap1.length && wrap_main1.find( 'a.wp-color-result' ).attr( 'title', select_label );
63
- wrap_main2.length && wrap_main2.find( 'a.wp-color-result' ).attr( 'title', select_label );
64
-
65
- if ( !wrap1.find( '.wp-picker-clear-custom' ).length ) {
66
- var button = $( '<span/>' ).attr( {
67
- class: "wp-picker-default-custom"
68
- } );
69
- wrap1.find( '.wp-picker-default' ).wrap( button );
70
- }
71
-
72
- if ( !wrap2.find( '.wp-picker-clear-custom' ).length ) {
73
- var button = $( '<span/>' ).attr( {
74
- class: "wp-picker-default-custom"
75
- } );
76
- wrap2.find( '.wp-picker-default' ).wrap( button );
77
- }
78
- } );
79
-
80
-
81
- /* Upload */
82
- if ( typeof wp !== 'undefined' && typeof wp.media !== 'undefined' ) {
83
- var _custom_media = true;
84
- // preview
85
- $upload.imgUrl.change( function () {
86
- var url = $( this ).val(),
87
  re = new RegExp( "(http|ftp|https)://[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico|svg)" ),
88
- preview = $( this ).parent().find( $upload.imgPreviewHandler ).first();
89
-
90
- if ( preview.length < 1 ) {
91
- preview = $( this ).parent().parent().find( $upload.imgPreviewHandler ).first();
92
- }
93
-
94
- if ( re.test( url ) ) {
95
- preview.html( '<img src="' + url + '" style="max-width:100px; max-height:100px;" />' );
96
- } else {
97
- preview.html( '' );
98
- }
99
- } ).trigger( 'change' );
100
-
101
- $( document ).on( 'click', $upload.uploadButtonHandler, function ( e ) {
102
- e.preventDefault();
103
-
104
- var t = $( this ),
105
- custom_uploader,
106
- id = t.attr( 'id' ).replace( /-button$/, '' );
107
-
108
- //If the uploader object has already been created, reopen the dialog
109
- if ( custom_uploader ) {
110
- custom_uploader.open();
111
- return;
112
- }
113
-
114
- var custom_uploader_states = [
115
- // Main states.
116
- new wp.media.controller.Library( {
117
- library : wp.media.query(),
118
- multiple : false,
119
- title : 'Choose Image',
120
- priority : 20,
121
- filterable: 'uploaded'
122
- } )
123
- ];
124
-
125
- // Create the media frame.
126
- custom_uploader = wp.media.frames.downloadable_file = wp.media( {
127
- // Set the title of the modal.
128
- title : 'Choose Image',
129
- library : {
130
- type: ''
131
- },
132
- button : {
133
- text: 'Choose Image'
134
- },
135
- multiple: false,
136
- states : custom_uploader_states
137
- } );
138
-
139
- //When a file is selected, grab the URL and set it as the text field's value
140
- custom_uploader.on( 'select', function () {
141
- var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
142
-
143
- $( "#" + id ).val( attachment.url );
144
- // Save the id of the selected element to an element which name is the same with a suffix "-yith-attachment-id"
145
- if ( $( "#" + id + "-yith-attachment-id" ) ) {
146
- $( "#" + id + "-yith-attachment-id" ).val( attachment.id );
147
- }
148
- $upload.imgUrl.trigger( 'change' );
149
- } );
150
-
151
- //Open the uploader dialog
152
- custom_uploader.open();
153
- } );
154
-
155
- $( document ).on( 'click', $upload.resetButtonHandler, function ( e ) {
156
- var t = $( this ),
157
- id = t.attr( 'id' ),
158
- input_id = t.attr( 'id' ).replace( /-button-reset$/, '' ),
159
- default_value = $( '#' + id ).data( 'default' );
160
-
161
- $( "#" + input_id ).val( default_value );
162
- $upload.imgUrl.trigger( 'change' );
163
- } );
164
- }
165
-
166
- $wpAddMedia.on( 'click', function () {
167
- _custom_media = false;
168
- } );
169
-
170
- /* Image Gallery */
171
- if ( typeof wp !== 'undefined' && typeof wp.media !== 'undefined' ) {
172
- $( document ).on( 'click', $imageGallery.buttonHandler, function ( e ) {
173
- var $t = $( this ),
174
- $container = $t.closest( '.image-gallery' ),
175
- $image_gallery_ids = $container.find( '.image_gallery_ids' ),
176
- attachment_ids = $image_gallery_ids.val(),
177
- $gallery_images_wrapper = $container.find( 'ul.slides-wrapper' );
178
-
179
- // Create the media frame.
180
- var image_gallery_frame = wp.media.frames.image_gallery = wp.media( {
181
- // Set the title of the modal.
182
- title : $t.data( 'choose' ),
183
- button: {
184
- text: $t.data( 'update' )
185
- },
186
- states: [
187
- new wp.media.controller.Library( {
188
- title : $t.data( 'choose' ),
189
- filterable: 'all',
190
- multiple : true
191
- } )
192
- ]
193
- } );
194
-
195
- // When an image is selected, run a callback.
196
- image_gallery_frame.on( 'select', function () {
197
- var selection = image_gallery_frame.state().get( 'selection' );
198
- selection.map( function ( attachment ) {
199
- attachment = attachment.toJSON();
200
-
201
- if ( attachment.id ) {
202
- attachment_ids = attachment_ids ? attachment_ids + "," + attachment.id : attachment.id;
203
- $gallery_images_wrapper.append( '<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment.sizes.thumbnail.url + '"/><ul class="actions"><li><a href="#" class="delete" title="' + $t.data( 'delete' ) + '">x</a></li></ul></li>' );
204
- }
205
- } );
206
-
207
- $image_gallery_ids.val( attachment_ids );
208
- } );
209
-
210
- image_gallery_frame.open();
211
-
212
- } );
213
-
214
- // Image ordering
215
- $imageGallery.sliderWrapper.each( function () {
216
- var $t = $( this );
217
- $t.sortable( {
218
- items : 'li.image',
219
- cursor : 'move',
220
- scrollSensitivity : 40,
221
- forcePlaceholderSize: true,
222
- forceHelperSize : false,
223
- helper : 'clone',
224
- opacity : 0.65,
225
- start : function ( event, ui ) {
226
- ui.item.css( 'background-color', '#f6f6f6' );
227
- },
228
- stop : function ( event, ui ) {
229
- ui.item.removeAttr( 'style' );
230
- },
231
- update : function ( event, ui ) {
232
- var attachment_ids = '';
233
-
234
- $t.find( 'li.image' ).css( 'cursor', 'default' ).each( function () {
235
- var attachment_id = $( this ).attr( 'data-attachment_id' );
236
- attachment_ids = attachment_ids + attachment_id + ',';
237
- } );
238
-
239
- $t.closest( '.image-gallery' ).find( '.image_gallery_ids' ).val( attachment_ids );
240
- }
241
- } );
242
- } );
243
-
244
- // Remove images
245
- $imageGallery.sliderWrapper.on( 'click', 'a.delete', function () {
246
- var $wrapper = $( this ).closest( '.image-gallery' ),
247
- $gallery = $( this ).closest( '.image-gallery ul.slides-wrapper' ),
248
- $image_gallery_ids = $wrapper.find( '.image_gallery_ids' ),
249
- attachment_ids = '';
250
-
251
- $( this ).closest( 'li.image' ).remove();
252
-
253
- $gallery.find( 'li.image' ).css( 'cursor', 'default' ).each( function () {
254
- var attachment_id = $( this ).attr( 'data-attachment_id' );
255
- attachment_ids = attachment_ids + attachment_id + ',';
256
- } );
257
-
258
- $image_gallery_ids.val( attachment_ids );
259
- } );
260
- }
261
-
262
-
263
- /* Sidebars */
264
- $sidebars.each( function () {
265
- var $images = $( this ).find( 'img' );
266
- $images.on( 'click', function () {
267
- var $container = $( this ).closest( '.yith-plugin-fw-sidebar-layout' ),
268
- $left = $container.find( '.yith-plugin-fw-sidebar-layout-sidebar-left-container' ),
269
- $right = $container.find( '.yith-plugin-fw-sidebar-layout-sidebar-right-container' ),
270
- type = $( this ).data( 'type' );
271
-
272
- $( this ).parent().children( ':radio' ).attr( 'checked', false );
273
- $( this ).prev( ':radio' ).attr( 'checked', true );
274
-
275
- if ( typeof type != 'undefined' ) {
276
- switch ( type ) {
277
- case 'left':
278
- $left.show();
279
- $right.hide();
280
- break;
281
- case 'right':
282
- $right.show();
283
- $left.hide();
284
- break;
285
- case 'double':
286
- $left.show();
287
- $right.show();
288
- break;
289
- default:
290
- $left.hide();
291
- $right.hide();
292
- break;
293
- }
294
- }
295
- } );
296
- } );
297
-
298
- /* Slider */
299
- $slider.each( function () {
300
- var val = $( this ).data( 'val' ),
301
- minValue = $( this ).data( 'min' ),
302
- maxValue = $( this ).data( 'max' ),
303
- step = $( this ).data( 'step' ),
304
- labels = $( this ).data( 'labels' );
305
-
306
- $( this ).slider( {
307
- value: val,
308
- min : minValue,
309
- max : maxValue,
310
- range: 'min',
311
- step : step,
312
-
313
- create: function () {
314
- $( this ).find( '.ui-slider-handle' ).text( $( this ).slider( "value" ) );
315
- },
316
-
317
-
318
- slide: function ( event, ui ) {
319
- $( this ).find( 'input' ).val( ui.value );
320
- $( this ).find( '.ui-slider-handle' ).text( ui.value );
321
- $( this ).siblings( '.feedback' ).find( 'strong' ).text( ui.value + labels );
322
- }
323
- } );
324
- } );
325
-
326
- /* codemirror */
327
- $codemirror.each( function ( i, v ) {
328
- var editor = CodeMirror.fromTextArea( v, {
329
- lineNumbers : 1,
330
- mode : 'javascript',
331
- showCursorWhenSelecting: true
332
- } );
333
-
334
- $( v ).data( 'codemirrorInstance', editor );
335
- } );
336
-
337
- /* Select All - Deselect All */
338
- $( document ).on( 'click', '.yith-plugin-fw-select-all', function () {
339
- var $targetSelect = $( '#' + $( this ).data( 'select-id' ) );
340
- $targetSelect.find( 'option' ).prop( 'selected', true ).trigger( 'change' );
341
- } );
342
-
343
- $( document ).on( 'click', '.yith-plugin-fw-deselect-all', function () {
344
- var $targetSelect = $( '#' + $( this ).data( 'select-id' ) );
345
- $targetSelect.find( 'option' ).prop( 'selected', false ).trigger( 'change' );
346
- } );
347
-
348
-
349
- $icons.each( function () {
350
- var $container = $( this ),
351
- $preview = $container.find( '.yit-icons-manager-icon-preview' ).first(),
352
- $text = $container.find( '.yit-icons-manager-icon-text' );
353
-
354
- $container.on( 'click', '.yit-icons-manager-list li', function ( event ) {
355
- var $target = $( event.target ).closest( 'li' ),
356
- font = $target.data( 'font' ),
357
- icon = $target.data( 'icon' ),
358
- key = $target.data( 'key' ),
359
- name = $target.data( 'name' );
360
-
361
- $preview.attr( 'data-font', font );
362
- $preview.attr( 'data-icon', icon );
363
- $preview.attr( 'data-key', key );
364
- $preview.attr( 'data-name', name );
365
-
366
- $text.val( font + ':' + name );
367
-
368
- $container.find( '.yit-icons-manager-list li' ).removeClass( 'active' );
369
- $target.addClass( 'active' );
370
- } );
371
-
372
- $container.on( 'click', '.yit-icons-manager-action-set-default', function () {
373
- $container.find( '.yit-icons-manager-list li.default' ).trigger( 'click' );
374
- } );
375
- } );
376
-
377
- /** Select Images */
378
- $( document ).on( 'click', '.yith-plugin-fw-select-images__item', function () {
379
- var item = $( this ),
380
- key = item.data( 'key' ),
381
- wrapper = item.closest( '.yith-plugin-fw-select-images__wrapper' ),
382
- items = wrapper.find( '.yith-plugin-fw-select-images__item' ),
383
- select = wrapper.find( 'select' ).first();
384
-
385
- if ( select.length ) {
386
- select.val( key );
387
- items.removeClass( 'yith-plugin-fw-select-images__item--selected' );
388
- item.addClass( 'yith-plugin-fw-select-images__item--selected' );
389
- }
390
- } );
391
-
392
- $( document.body ).trigger( 'wc-enhanced-select-init' );
393
-
394
- $( document ).find( '.ui-sortable .yith-toggle-elements' ).sortable(
395
- {
396
- cursor : 'move',
397
- axis : 'y',
398
- scrollSensitivity : 40,
399
- forcePlaceholderSize: true,
400
- helper : 'clone',
401
-
402
- stop: function ( event, ui ) {
403
- var keys = jQuery( '.ui-sortable-handle' ),
404
- i = 0,
405
- array_keys = new Array();
406
- for ( i = 0; i < keys.length; i++ ) {
407
- array_keys[ i ] = $( keys[ i ] ).data( 'item_key' );
408
- }
409
- if ( array_keys.length > 0 ) {
410
- var toggle = $( this ).closest( '.toggle-element' );
411
- toggle.saveToggleElement( null, array_keys );
412
- }
413
- }
414
- }
415
- );
416
-
417
- $( document.body ).trigger( 'yith-framework-enhanced-select-init' );
418
- };
419
-
420
- $( document ).on( 'yith_fields_init', yith_fields_init ).trigger( 'yith_fields_init' );
421
-
422
- /* on-off */
423
- $( document ).on( 'click', '.yith-plugin-fw-onoff-container span', function () {
424
- var input = $( this ).prev( 'input' ),
425
- checked = input.prop( 'checked' );
426
-
427
- if ( checked ) {
428
- input.prop( 'checked', false ).attr( 'value', 'no' ).removeClass( 'onoffchecked' );
429
- } else {
430
- input.prop( 'checked', true ).attr( 'value', 'yes' ).addClass( 'onoffchecked' );
431
- }
432
-
433
- input.change();
434
- } );
435
-
436
-
437
- /** Toggle **/
438
-
439
-
440
-
441
- //TOGGLE ELEMENT
442
- $.fn.saveToggleElement = function ( spinner, array_keys ) {
443
- var toggle = $( this ),
444
- action = 'yith_plugin_fw_save_toggle_element',
445
- formdata = toggle.serializeToggleElement(),
446
- wrapper = toggle.find( '.yith-toggle_wrapper' ),
447
- id = wrapper.attr( 'id' ),
448
- current_tab = $.urlParam( 'tab' );
449
-
450
- formdata.append( 'security', wrapper.data( 'nonce' ) );
451
-
452
- if ( typeof array_keys != 'undefined' && array_keys.length > 0 ) {
453
- formdata.append( 'yith_toggle_elements_order_keys', array_keys );
454
- }
455
-
456
- if ( toggle.closest( '.metaboxes-tab.yith-plugin-ui' ).length ) {
457
- action = 'yith_plugin_fw_save_toggle_element_metabox';
458
- post_id = $( this ).closest( 'form#post' ).find( '#post_ID' ).val();
459
- yit_metaboxes_nonce = $( this ).closest( 'form#post' ).find( '#yit_metaboxes_nonce' ).val();
460
- metabox_tab = $( this ).closest( '.tabs-panel' ).attr( 'id' );
461
- url = yith_framework_fw_fields.ajax_url +
462
- '?action=' + action +
463
- "&post_ID=" + post_id +
464
- '&yit_metaboxes_nonce=' + yit_metaboxes_nonce +
465
- "&toggle_id=" + id +
466
- "&metabox_tab=" + metabox_tab;
467
- } else {
468
- url = yith_framework_fw_fields.admin_url + '?action=' + action + '&tab=' + current_tab + "&toggle_id=" + id;
469
- }
470
-
471
- $.ajax( {
472
- type : "POST",
473
- url : url,
474
- data : formdata,
475
- contentType: false,
476
- processData: false,
477
- success : function ( result ) {
478
- if ( spinner ) {
479
- spinner.removeClass( 'show' );
480
- }
481
-
482
- $( document ).trigger( 'yith_save_toggle_element_done', [result, toggle] );
483
- }
484
- } );
485
- };
486
-
487
- $.fn.serializeToggleElement = function () {
488
- var obj = $( this );
489
- /* ADD FILE TO PARAM AJAX */
490
- var formData = new FormData();
491
- var params = $( obj ).find( ":input" ).serializeArray();
492
-
493
- $.each( params, function ( i, val ) {
494
- el_name = val.name;
495
- formData.append( val.name, val.value );
496
- } );
497
-
498
- return formData;
499
- };
500
-
501
- $.fn.formatToggleTitle = function () {
502
- var toggle_el = $( this ),
503
- fields = toggle_el.find( ':input' ),
504
- title = toggle_el.find( 'span.title' ).data( 'title_format' ),
505
- subtitle = toggle_el.find( '.subtitle' ).data( 'subtitle_format' ),
506
- regExp = new RegExp( "[^%%]+(?=[%%])", 'g' );
507
-
508
- if ( typeof title != 'undefined' ) {
509
- var res = title.match( regExp );
510
- }
511
-
512
- if ( typeof subtitle != 'undefined' ) {
513
- var ressub = subtitle.match( regExp );
514
- }
515
-
516
- $.each( fields, function ( i, field ) {
517
- if ( typeof $( field ).attr( 'id' ) != 'undefined' ) {
518
- $field_id = $( field ).attr( 'id' );
519
- $field_array = $field_id.split( '_' );
520
- $field_array.pop();
521
- $field_id = $field_array.join( '_' );
522
- $field_val = $( field ).val();
523
-
524
- if ( res != null && typeof res != 'undefined' && res.indexOf( $field_id ) !== -1 ) {
525
- title = title.replace( '%%' + $field_id + '%%', $field_val );
526
- }
527
- if ( ressub != null && typeof ressub != 'undefined' && ressub.indexOf( $field_id ) !== -1 ) {
528
- subtitle = subtitle.replace( '%%' + $field_id + '%%', $field_val );
529
- }
530
- }
531
- } );
532
-
533
- if ( '' !== title ) {
534
- toggle_el.find( 'span.title' ).html( title );
535
- }
536
-
537
- if ( '' !== subtitle ) {
538
- toggle_el.find( '.subtitle' ).html( subtitle );
539
- }
540
-
541
- $( document ).trigger( 'yith-toggle-element-item-title', [toggle_el] );
542
- };
543
-
544
- $.urlParam = function ( name ) {
545
- var results = new RegExp( '[\?&]' + name + '=([^&#]*)' )
546
- .exec( window.location.search );
547
-
548
- return ( results !== null ) ? results[ 1 ] || 0 : false;
549
- };
550
-
551
- $( document ).on( 'click', '.yith-toggle-title', function ( event ) {
552
- var _toggle = $( event.target ),
553
- _section = _toggle.closest( '.yith-toggle-row' ),
554
- _content = _section.find( '.yith-toggle-content' );
555
-
556
- if ( _toggle.hasClass( 'yith-plugin-fw-onoff' ) || _toggle.hasClass( 'yith-icon-drag' ) ) {
557
- return false;
558
- }
559
-
560
- if ( _section.is( '.yith-toggle-row-opened' ) ) {
561
- _content.slideUp( 400 );
562
- } else {
563
- _content.slideDown( 400 );
564
- }
565
- _section.toggleClass( 'yith-toggle-row-opened' );
566
- } );
567
-
568
- /**Add new box toggle**/
569
- $( document ).on( 'click', '.yith-add-box-button', function ( event ) {
570
- event.preventDefault();
571
- var $this = $( this ),
572
- target_id = $this.data( 'box_id' ),
573
- closed_label = $this.data( 'closed_label' ),
574
- label = $this.data( 'opened_label' ),
575
- id = $this.closest( '.yith-toggle_wrapper' ).attr( 'id' );
576
- template = wp.template( 'yith-toggle-element-add-box-content-' + id );
577
-
578
- if ( '' !== target_id ) {
579
- $( '#' + target_id ).html( template( { index: 'box_id' } ) ).slideToggle();
580
- if ( closed_label !== '' ) {
581
- if ( $this.html() === closed_label ) {
582
- $this.html( label ).removeClass( 'closed' );
583
- } else {
584
- $this.html( closed_label ).addClass( 'closed' );
585
- }
586
- }
587
-
588
- $( document ).trigger( 'yith_fields_init' );
589
- $( document ).trigger( 'yith-add-box-button-toggle', [$this] );
590
- }
591
- } );
592
-
593
- $( document ).on( 'click', '.yith-add-box-buttons .yith-save-button', function ( event ) {
594
-
595
- event.preventDefault();
596
- var add_box = $( this ).parents( '.yith-add-box' ),
597
- id = $( this ).closest( '.yith-toggle_wrapper' ).attr( 'id' ),
598
- spinner = add_box.find( '.spinner' ),
599
- toggle_element = $( this ).parents( '.toggle-element' ),
600
- fields = add_box.find( ':input' ),
601
- counter = toggle_element.find( '.yith-toggle-row' ).length,
602
- hidden_obj = $( '<input type="hidden">' );
603
-
604
- hidden_obj.val( counter );
605
-
606
- $( document ).trigger( 'yith-toggle-change-counter', [hidden_obj, add_box] );
607
-
608
- counter = hidden_obj.val();
609
- var template = wp.template( 'yith-toggle-element-item-' + id ),
610
- toggle_el = $( template( { index: counter } ) );
611
-
612
- spinner.addClass( 'show' );
613
-
614
- $.each( fields, function ( i, field ) {
615
- if ( typeof $( field ).attr( 'id' ) != 'undefined' ) {
616
-
617
- $field_id = $( field ).attr( 'id' );
618
- $field_val = $( field ).val();
619
-
620
- if ( 'radio' == $( field ).attr( 'type' ) ) {
621
- $field_id = $field_id.replace( 'new_', '' );
622
- $field_id = $field_id.replace( '-' + $field_val, '' );
623
- $field_id = $field_id + '_dataindex-' + $field_val;
624
- } else {
625
- $field_id = $field_id.replace( 'new_', '' ) + '_' + counter;
626
- }
627
-
628
- if ( $( field ).is( ':checked' ) ) {
629
- $( toggle_el ).find( '#' + $field_id ).prop( 'checked', true );
630
- }
631
-
632
- if ( $( field ).hasClass( 'yith-post-search' ) || $( field ).hasClass( 'yith-term-search' ) ) {
633
- $( toggle_el ).find( '#' + $field_id ).html( $( '#' + $( field ).attr( 'id' ) ).html() );
634
- }
635
-
636
- $( toggle_el ).find( '#' + $field_id ).val( $field_val );
637
-
638
- }
639
-
640
- } );
641
-
642
- $( toggle_el ).formatToggleTitle();
643
- var form_is_valid = $( '<input type="hidden">' ).val( 'yes' );
644
- $( document ).trigger( 'yith-toggle-element-item-before-add', [add_box, toggle_el, form_is_valid] );
645
-
646
- var delayInMilliseconds = 1000; //1 second
647
- setTimeout( function () {
648
- if ( form_is_valid.val() === 'yes' ) {
649
- $( toggle_element ).find( '.yith-toggle-elements' ).append( toggle_el );
650
- $( add_box ).find( '.yith-plugin-fw-datepicker' ).datepicker( 'destroy' );
651
- $( add_box ).html( '' );
652
- $( add_box ).prev( '.yith-add-box-button' ).trigger( 'click' );
653
- toggle_element.saveToggleElement();
654
-
655
- var delayInMilliseconds = 2000; //1 second
656
- setTimeout( function () {
657
- $( toggle_element ).find( '.highlight' ).removeClass( 'highlight' );
658
- }, delayInMilliseconds );
659
-
660
-
661
- $( document ).trigger( 'yith_fields_init' );
662
- }
663
- }, delayInMilliseconds );
664
-
665
-
666
- } );
667
-
668
- $( document ).on( 'click', '.yith-toggle-row .yith-save-button', function ( event ) {
669
- event.preventDefault();
670
- var toggle = $( this ).closest( '.toggle-element' ),
671
- toggle_row = $( this ).closest( '.yith-toggle-row' ),
672
- spinner = toggle_row.find( '.spinner' );
673
- toggle_row.formatToggleTitle();
674
-
675
- var form_is_valid = $( '<input type="hidden">' ).val( 'yes' );
676
- $( document ).trigger( 'yith-toggle-element-item-before-update', [toggle, toggle_row, form_is_valid] );
677
- if ( form_is_valid.val() === 'yes' ) {
678
- spinner.addClass( 'show' );
679
- toggle.saveToggleElement( spinner );
680
- }
681
- } );
682
-
683
- //register remove the dome and save the toggle
684
- $( document ).on( 'click', '.yith-toggle-row .yith-delete-button', function ( event ) {
685
- event.preventDefault();
686
- var toggle = $( this ).closest( '.toggle-element' ),
687
- toggle_row = $( this ).closest( '.yith-toggle-row' );
688
- toggle_row.remove();
689
- toggle.saveToggleElement();
690
- } );
691
-
692
- //register onoff status
693
- $( document ).on( 'click', '.yith-toggle-onoff', function ( event ) {
694
- event.preventDefault();
695
- var toggle = $( this ).closest( '.toggle-element' );
696
- toggle.saveToggleElement();
697
- } );
698
-
699
- // Radio
700
- $( document ).on( 'click', '.yith-plugin-fw-radio input[type=radio]', function () {
701
- $( this ).closest( '.yith-plugin-fw-radio' ).val( $( this ).val() ).trigger( 'change' );
702
- } );
703
-
704
- $( document ).on( 'click', '.yith-password-eye', function () {
705
- var $this = $( this ),
706
- inp = $( this ).closest( '.yith-password-wrapper' ).find( 'input' );
707
- if ( inp.attr( 'type' ) === "password" ) {
708
- inp.attr( 'type', 'text' );
709
- $this.addClass( 'yith-password-eye-closed' );
710
- } else {
711
- inp.attr( 'type', 'password' );
712
- $this.removeClass( 'yith-password-eye-closed' );
713
- }
714
- } );
715
-
716
- $( document.body ).on( 'yith-plugin-fw-init-radio', function () {
717
- $( '.yith-plugin-fw-radio:not(.yith-plugin-fw-radio--initialized)' ).each( function () {
718
- $( this ).val( $( this ).attr( 'value' ) );
719
- $( this ).addClass( 'yith-plugin-fw-radio--initialized' );
720
- } );
721
- } ).trigger( 'yith-plugin-fw-init-radio' );
722
-
723
- /**
724
- * Select2 - add class to stylize it with the new plugin-fw style
725
- */
726
- $( document ).on( 'select2:open', function ( e ) {
727
- if ( $( e.target ).closest( '.yith-plugin-ui' ).length ) {
728
- $( '.select2-results' ).closest( '.select2-container' ).addClass( 'yith-plugin-fw-select2-container' );
729
- }
730
- } );
731
-
732
  /**
733
  * Dimensions
734
  */
1
  ( function ( $ ) {
2
 
3
+ /* global yith_framework_fw_fields*/
4
+
5
+ var yith_fields_init = function () {
6
+ var $datepicker = $( '.yith-plugin-fw-datepicker' ),
7
+ $colorpicker = $( '.yith-plugin-fw-colorpicker' ),
8
+ $upload = {
9
+ imgPreviewHandler : '.yith-plugin-fw-upload-img-preview',
10
+ uploadButtonHandler: '.yith-plugin-fw-upload-button',
11
+ imgUrlHandler : '.yith-plugin-fw-upload-img-url',
12
+ resetButtonHandler : '.yith-plugin-fw-upload-button-reset',
13
+ imgUrl : $( '.yith-plugin-fw-upload-img-url' )
14
+ },
15
+ $wpAddMedia = $( '.add_media' ),
16
+ $imageGallery = {
17
+ sliderWrapper: $( '.yith-plugin-fw .image-gallery ul.slides-wrapper' ),
18
+ buttonHandler: '.yith-plugin-fw .image-gallery-button'
19
+ },
20
+ $sidebars = $( '.yith-plugin-fw-sidebar-layout' ),
21
+ $slider = $( '.yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal' ),
22
+ $codemirror = $( '.codemirror' ),
23
+ $icons = $( '.yit-icons-manager-wrapper' ),
24
+ $checkgroup = $( ".yith-plugin-ui td.forminp-checkbox" );
25
+
26
+ /* Datepicker */
27
+ $datepicker.each( function () {
28
+ var args = $( this ).data();
29
+
30
+ // set animation to false to prevent style 'glitches' when removing class on closing
31
+ args.showAnim = false;
32
+ args.beforeShow = function ( input, instance ) {
33
+ instance.dpDiv.addClass( 'yith-plugin-fw-datepicker-div' );
34
+ };
35
+ args.onClose = function ( selectedDate, instance ) {
36
+ instance.dpDiv.removeClass( 'yith-plugin-fw-datepicker-div' );
37
+ };
38
+
39
+ $( this ).datepicker( args );
40
+ } );
41
+
42
+ /* Colorpicker */
43
+ $colorpicker.wpColorPicker( {
44
+ palettes: false,
45
+ width : 200,
46
+ mode : 'hsl',
47
+ clear : function () {
48
+ var input = $( this );
49
+ input.val( input.data( 'default-color' ) );
50
+ input.change();
51
+ }
52
+ } );
53
+
54
+
55
+ $colorpicker.each( function () {
56
+ var select_label = $( this ).data( 'variations-label' ),
57
+ wrap_main1 = $( this ).closest( '.yith-plugin-fw-colorpicker-field-wrapper' ),
58
+ wrap_main2 = $( this ).closest( '.yith-single-colorpicker' ),
59
+ wrap1 = wrap_main1.find( '.wp-picker-input-wrap' ),
60
+ wrap2 = wrap_main2.find( '.wp-picker-input-wrap' );
61
+
62
+ wrap1.length && wrap_main1.find( 'a.wp-color-result' ).attr( 'title', select_label );
63
+ wrap_main2.length && wrap_main2.find( 'a.wp-color-result' ).attr( 'title', select_label );
64
+
65
+ if ( !wrap1.find( '.wp-picker-clear-custom' ).length ) {
66
+ var button = $( '<span/>' ).attr( {
67
+ class: "wp-picker-default-custom"
68
+ } );
69
+ wrap1.find( '.wp-picker-default' ).wrap( button );
70
+ }
71
+
72
+ if ( !wrap2.find( '.wp-picker-clear-custom' ).length ) {
73
+ var button = $( '<span/>' ).attr( {
74
+ class: "wp-picker-default-custom"
75
+ } );
76
+ wrap2.find( '.wp-picker-default' ).wrap( button );
77
+ }
78
+ } );
79
+
80
+
81
+ /* Upload */
82
+ if ( typeof wp !== 'undefined' && typeof wp.media !== 'undefined' ) {
83
+ var _custom_media = true;
84
+ // preview
85
+ $upload.imgUrl.change( function () {
86
+ var url = $( this ).val(),
87
  re = new RegExp( "(http|ftp|https)://[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico|svg)" ),
88
+ preview = $( this ).parent().find( $upload.imgPreviewHandler ).first();
89
+
90
+ if ( preview.length < 1 ) {
91
+ preview = $( this ).parent().parent().find( $upload.imgPreviewHandler ).first();
92
+ }
93
+
94
+ if ( re.test( url ) ) {
95
+ preview.html( '<img src="' + url + '" style="max-width:100px; max-height:100px;" />' );
96
+ } else {
97
+ preview.html( '' );
98
+ }
99
+ } ).trigger( 'change' );
100
+
101
+ $( document ).on( 'click', $upload.uploadButtonHandler, function ( e ) {
102
+ e.preventDefault();
103
+
104
+ var t = $( this ),
105
+ custom_uploader,
106
+ id = t.attr( 'id' ).replace( /-button$/, '' );
107
+
108
+ //If the uploader object has already been created, reopen the dialog
109
+ if ( custom_uploader ) {
110
+ custom_uploader.open();
111
+ return;
112
+ }
113
+
114
+ var custom_uploader_states = [
115
+ // Main states.
116
+ new wp.media.controller.Library( {
117
+ library : wp.media.query(),
118
+ multiple : false,
119
+ title : 'Choose Image',
120
+ priority : 20,
121
+ filterable: 'uploaded'
122
+ } )
123
+ ];
124
+
125
+ // Create the media frame.
126
+ custom_uploader = wp.media.frames.downloadable_file = wp.media( {
127
+ // Set the title of the modal.
128
+ title : 'Choose Image',
129
+ library : {
130
+ type: ''
131
+ },
132
+ button : {
133
+ text: 'Choose Image'
134
+ },
135
+ multiple: false,
136
+ states : custom_uploader_states
137
+ } );
138
+
139
+ //When a file is selected, grab the URL and set it as the text field's value
140
+ custom_uploader.on( 'select', function () {
141
+ var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
142
+
143
+ $( "#" + id ).val( attachment.url );
144
+ // Save the id of the selected element to an element which name is the same with a suffix "-yith-attachment-id"
145
+ if ( $( "#" + id + "-yith-attachment-id" ) ) {
146
+ $( "#" + id + "-yith-attachment-id" ).val( attachment.id );
147
+ }
148
+ $upload.imgUrl.trigger( 'change' );
149
+ } );
150
+
151
+ //Open the uploader dialog
152
+ custom_uploader.open();
153
+ } );
154
+
155
+ $( document ).on( 'click', $upload.resetButtonHandler, function ( e ) {
156
+ var t = $( this ),
157
+ id = t.attr( 'id' ),
158
+ input_id = t.attr( 'id' ).replace( /-button-reset$/, '' ),
159
+ default_value = $( '#' + id ).data( 'default' );
160
+
161
+ $( "#" + input_id ).val( default_value );
162
+ $upload.imgUrl.trigger( 'change' );
163
+ } );
164
+ }
165
+
166
+ $wpAddMedia.on( 'click', function () {
167
+ _custom_media = false;
168
+ } );
169
+
170
+ /* Image Gallery */
171
+ if ( typeof wp !== 'undefined' && typeof wp.media !== 'undefined' ) {
172
+ $( document ).on( 'click', $imageGallery.buttonHandler, function ( e ) {
173
+ var $t = $( this ),
174
+ $container = $t.closest( '.image-gallery' ),
175
+ $image_gallery_ids = $container.find( '.image_gallery_ids' ),
176
+ attachment_ids = $image_gallery_ids.val(),
177
+ $gallery_images_wrapper = $container.find( 'ul.slides-wrapper' );
178
+
179
+ // Create the media frame.
180
+ var image_gallery_frame = wp.media.frames.image_gallery = wp.media( {
181
+ // Set the title of the modal.
182
+ title : $t.data( 'choose' ),
183
+ button: {
184
+ text: $t.data( 'update' )
185
+ },
186
+ states: [
187
+ new wp.media.controller.Library( {
188
+ title : $t.data( 'choose' ),
189
+ filterable: 'all',
190
+ multiple : true
191
+ } )
192
+ ]
193
+ } );
194
+
195
+ // When an image is selected, run a callback.
196
+ image_gallery_frame.on( 'select', function () {
197
+ var selection = image_gallery_frame.state().get( 'selection' );
198
+ selection.map( function ( attachment ) {
199
+ attachment = attachment.toJSON();
200
+
201
+ if ( attachment.id ) {
202
+ attachment_ids = attachment_ids ? attachment_ids + "," + attachment.id : attachment.id;
203
+ $gallery_images_wrapper.append( '<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment.sizes.thumbnail.url + '"/><ul class="actions"><li><a href="#" class="delete" title="' + $t.data( 'delete' ) + '">x</a></li></ul></li>' );
204
+ }
205
+ } );
206
+
207
+ $image_gallery_ids.val( attachment_ids );
208
+ } );
209
+
210
+ image_gallery_frame.open();
211
+
212
+ } );
213
+
214
+ // Image ordering
215
+ $imageGallery.sliderWrapper.each( function () {
216
+ var $t = $( this );
217
+ $t.sortable( {
218
+ items : 'li.image',
219
+ cursor : 'move',
220
+ scrollSensitivity : 40,
221
+ forcePlaceholderSize: true,
222
+ forceHelperSize : false,
223
+ helper : 'clone',
224
+ opacity : 0.65,
225
+ start : function ( event, ui ) {
226
+ ui.item.css( 'background-color', '#f6f6f6' );
227
+ },
228
+ stop : function ( event, ui ) {
229
+ ui.item.removeAttr( 'style' );
230
+ },
231
+ update : function ( event, ui ) {
232
+ var attachment_ids = '';
233
+
234
+ $t.find( 'li.image' ).css( 'cursor', 'default' ).each( function () {
235
+ var attachment_id = $( this ).attr( 'data-attachment_id' );
236
+ attachment_ids = attachment_ids + attachment_id + ',';
237
+ } );
238
+
239
+ $t.closest( '.image-gallery' ).find( '.image_gallery_ids' ).val( attachment_ids );
240
+ }
241
+ } );
242
+ } );
243
+
244
+ // Remove images
245
+ $imageGallery.sliderWrapper.on( 'click', 'a.delete', function () {
246
+ var $wrapper = $( this ).closest( '.image-gallery' ),
247
+ $gallery = $( this ).closest( '.image-gallery ul.slides-wrapper' ),
248
+ $image_gallery_ids = $wrapper.find( '.image_gallery_ids' ),
249
+ attachment_ids = '';
250
+
251
+ $( this ).closest( 'li.image' ).remove();
252
+
253
+ $gallery.find( 'li.image' ).css( 'cursor', 'default' ).each( function () {
254
+ var attachment_id = $( this ).attr( 'data-attachment_id' );
255
+ attachment_ids = attachment_ids + attachment_id + ',';
256
+ } );
257
+
258
+ $image_gallery_ids.val( attachment_ids );
259
+ } );
260
+ }
261
+
262
+
263
+ /* Sidebars */
264
+ $sidebars.each( function () {
265
+ var $images = $( this ).find( 'img' );
266
+ $images.on( 'click', function () {
267
+ var $container = $( this ).closest( '.yith-plugin-fw-sidebar-layout' ),
268
+ $left = $container.find( '.yith-plugin-fw-sidebar-layout-sidebar-left-container' ),
269
+ $right = $container.find( '.yith-plugin-fw-sidebar-layout-sidebar-right-container' ),
270
+ type = $( this ).data( 'type' );
271
+
272
+ $( this ).parent().children( ':radio' ).attr( 'checked', false );
273
+ $( this ).prev( ':radio' ).attr( 'checked', true );
274
+
275
+ if ( typeof type != 'undefined' ) {
276
+ switch ( type ) {
277
+ case 'left':
278
+ $left.show();
279
+ $right.hide();
280
+ break;
281
+ case 'right':
282
+ $right.show();
283
+ $left.hide();
284
+ break;
285
+ case 'double':
286
+ $left.show();
287
+ $right.show();
288
+ break;
289
+ default:
290
+ $left.hide();
291
+ $right.hide();
292
+ break;
293
+ }
294
+ }
295
+ } );
296
+ } );
297
+
298
+ /* Slider */
299
+ $slider.each( function () {
300
+ var val = $( this ).data( 'val' ),
301
+ minValue = $( this ).data( 'min' ),
302
+ maxValue = $( this ).data( 'max' ),
303
+ step = $( this ).data( 'step' ),
304
+ labels = $( this ).data( 'labels' );
305
+
306
+ $( this ).slider( {
307
+ value: val,
308
+ min : minValue,
309
+ max : maxValue,
310
+ range: 'min',
311
+ step : step,
312
+
313
+ create: function () {
314
+ $( this ).find( '.ui-slider-handle' ).text( $( this ).slider( "value" ) );
315
+ },
316
+
317
+
318
+ slide: function ( event, ui ) {
319
+ $( this ).find( 'input' ).val( ui.value );
320
+ $( this ).find( '.ui-slider-handle' ).text( ui.value );
321
+ $( this ).siblings( '.feedback' ).find( 'strong' ).text( ui.value + labels );
322
+ }
323
+ } );
324
+ } );
325
+
326
+ /* codemirror */
327
+ $codemirror.each( function ( i, v ) {
328
+ var editor = CodeMirror.fromTextArea( v, {
329
+ lineNumbers : 1,
330
+ mode : 'javascript',
331
+ showCursorWhenSelecting: true
332
+ } );
333
+
334
+ $( v ).data( 'codemirrorInstance', editor );
335
+ } );
336
+
337
+ /* Select All - Deselect All */
338
+ $( document ).on( 'click', '.yith-plugin-fw-select-all', function () {
339
+ var $targetSelect = $( '#' + $( this ).data( 'select-id' ) );
340
+ $targetSelect.find( 'option' ).prop( 'selected', true ).trigger( 'change' );
341
+ } );
342
+
343
+ $( document ).on( 'click', '.yith-plugin-fw-deselect-all', function () {
344
+ var $targetSelect = $( '#' + $( this ).data( 'select-id' ) );
345
+ $targetSelect.find( 'option' ).prop( 'selected', false ).trigger( 'change' );
346
+ } );
347
+
348
+
349
+ $icons.each( function () {
350
+ var $container = $( this ),
351
+ $preview = $container.find( '.yit-icons-manager-icon-preview' ).first(),
352
+ $text = $container.find( '.yit-icons-manager-icon-text' );
353
+
354
+ $container.on( 'click', '.yit-icons-manager-list li', function ( event ) {
355
+ var $target = $( event.target ).closest( 'li' ),
356
+ font = $target.data( 'font' ),
357
+ icon = $target.data( 'icon' ),
358
+ key = $target.data( 'key' ),
359
+ name = $target.data( 'name' );
360
+
361
+ $preview.attr( 'data-font', font );
362
+ $preview.attr( 'data-icon', icon );
363
+ $preview.attr( 'data-key', key );
364
+ $preview.attr( 'data-name', name );
365
+
366
+ $text.val( font + ':' + name );
367
+
368
+ $container.find( '.yit-icons-manager-list li' ).removeClass( 'active' );
369
+ $target.addClass( 'active' );
370
+ } );
371
+
372
+ $container.on( 'click', '.yit-icons-manager-action-set-default', function () {
373
+ $container.find( '.yit-icons-manager-list li.default' ).trigger( 'click' );
374
+ } );
375
+ } );
376
+
377
+ /** Select Images */
378
+ $( document ).on( 'click', '.yith-plugin-fw-select-images__item', function () {
379
+ var item = $( this ),
380
+ key = item.data( 'key' ),
381
+ wrapper = item.closest( '.yith-plugin-fw-select-images__wrapper' ),
382
+ items = wrapper.find( '.yith-plugin-fw-select-images__item' ),
383
+ select = wrapper.find( 'select' ).first();
384
+
385
+ if ( select.length ) {
386
+ select.val( key ).trigger('yith_select_images_value_changed');
387
+ items.removeClass( 'yith-plugin-fw-select-images__item--selected' );
388
+ item.addClass( 'yith-plugin-fw-select-images__item--selected' );
389
+ }
390
+ } );
391
+
392
+ $( document.body ).trigger( 'wc-enhanced-select-init' );
393
+
394
+ $( document ).find( '.ui-sortable .yith-toggle-elements' ).sortable(
395
+ {
396
+ cursor : 'move',
397
+ axis : 'y',
398
+ scrollSensitivity : 40,
399
+ forcePlaceholderSize: true,
400
+ helper : 'clone',
401
+
402
+ stop: function ( event, ui ) {
403
+ var keys = jQuery( '.ui-sortable-handle' ),
404
+ i = 0,
405
+ array_keys = new Array();
406
+ for ( i = 0; i < keys.length; i++ ) {
407
+ array_keys[ i ] = $( keys[ i ] ).data( 'item_key' );
408
+ }
409
+ if ( array_keys.length > 0 ) {
410
+ var toggle = $( this ).closest( '.toggle-element' );
411
+ toggle.saveToggleElement( null, array_keys );
412
+ }
413
+ }
414
+ }
415
+ );
416
+
417
+ $( document.body ).trigger( 'yith-framework-enhanced-select-init' );
418
+ };
419
+
420
+ $( document ).on( 'yith_fields_init', yith_fields_init ).trigger( 'yith_fields_init' );
421
+
422
+ /* on-off */
423
+ $( document ).on( 'click', '.yith-plugin-fw-onoff-container span', function () {
424
+ var input = $( this ).prev( 'input' ),
425
+ checked = input.prop( 'checked' );
426
+
427
+ if ( checked ) {
428
+ input.prop( 'checked', false ).attr( 'value', 'no' ).removeClass( 'onoffchecked' );
429
+ } else {
430
+ input.prop( 'checked', true ).attr( 'value', 'yes' ).addClass( 'onoffchecked' );
431
+ }
432
+
433
+ input.change();
434
+ } );
435
+
436
+
437
+ /** Toggle **/
438
+
439
+
440
+
441
+ //TOGGLE ELEMENT
442
+ $.fn.saveToggleElement = function ( spinner, array_keys ) {
443
+ var toggle = $( this ),
444
+ action = 'yith_plugin_fw_save_toggle_element',
445
+ formdata = toggle.serializeToggleElement(),
446
+ wrapper = toggle.find( '.yith-toggle_wrapper' ),
447
+ id = wrapper.attr( 'id' ),
448
+ current_tab = $.urlParam( 'tab' );
449
+
450
+ formdata.append( 'security', wrapper.data( 'nonce' ) );
451
+
452
+ if ( typeof array_keys != 'undefined' && array_keys.length > 0 ) {
453
+ formdata.append( 'yith_toggle_elements_order_keys', array_keys );
454
+ }
455
+
456
+ if ( toggle.closest( '.metaboxes-tab.yith-plugin-ui' ).length ) {
457
+ action = 'yith_plugin_fw_save_toggle_element_metabox';
458
+ post_id = $( this ).closest( 'form#post' ).find( '#post_ID' ).val();
459
+ yit_metaboxes_nonce = $( this ).closest( 'form#post' ).find( '#yit_metaboxes_nonce' ).val();
460
+ metabox_tab = $( this ).closest( '.tabs-panel' ).attr( 'id' );
461
+ url = yith_framework_fw_fields.ajax_url +
462
+ '?action=' + action +
463
+ "&post_ID=" + post_id +
464
+ '&yit_metaboxes_nonce=' + yit_metaboxes_nonce +
465
+ "&toggle_id=" + id +
466
+ "&metabox_tab=" + metabox_tab;
467
+ } else {
468
+ url = yith_framework_fw_fields.admin_url + '?action=' + action + '&tab=' + current_tab + "&toggle_id=" + id;
469
+ }
470
+
471
+ $.ajax( {
472
+ type : "POST",
473
+ url : url,
474
+ data : formdata,
475
+ contentType: false,
476
+ processData: false,
477
+ success : function ( result ) {
478
+ if ( spinner ) {
479
+ spinner.removeClass( 'show' );
480
+ }
481
+
482
+ $( document ).trigger( 'yith_save_toggle_element_done', [result, toggle] );
483
+ }
484
+ } );
485
+ };
486
+
487
+ $.fn.serializeToggleElement = function () {
488
+ var obj = $( this );
489
+ /* ADD FILE TO PARAM AJAX */
490
+ var formData = new FormData();
491
+ var params = $( obj ).find( ":input" ).serializeArray();
492
+
493
+ $.each( params, function ( i, val ) {
494
+ el_name = val.name;
495
+ formData.append( val.name, val.value );
496
+ } );
497
+
498
+ return formData;
499
+ };
500
+
501
+ $.fn.formatToggleTitle = function () {
502
+ var toggle_el = $( this ),
503
+ fields = toggle_el.find( ':input' ),
504
+ title = toggle_el.find( 'span.title' ).data( 'title_format' ),
505
+ subtitle = toggle_el.find( '.subtitle' ).data( 'subtitle_format' ),
506
+ regExp = new RegExp( "[^%%]+(?=[%%])", 'g' );
507
+
508
+ if ( typeof title != 'undefined' ) {
509
+ var res = title.match( regExp );
510
+ }
511
+
512
+ if ( typeof subtitle != 'undefined' ) {
513
+ var ressub = subtitle.match( regExp );
514
+ }
515
+
516
+ $.each( fields, function ( i, field ) {
517
+ if ( typeof $( field ).attr( 'id' ) != 'undefined' ) {
518
+ $field_id = $( field ).attr( 'id' );
519
+ $field_array = $field_id.split( '_' );
520
+ $field_array.pop();
521
+ $field_id = $field_array.join( '_' );
522
+ $field_val = $( field ).val();
523
+
524
+ if ( res != null && typeof res != 'undefined' && res.indexOf( $field_id ) !== -1 ) {
525
+ title = title.replace( '%%' + $field_id + '%%', $field_val );
526
+ }
527
+ if ( ressub != null && typeof ressub != 'undefined' && ressub.indexOf( $field_id ) !== -1 ) {
528
+ subtitle = subtitle.replace( '%%' + $field_id + '%%', $field_val );
529
+ }
530
+ }
531
+ } );
532
+
533
+ if ( '' !== title ) {
534
+ toggle_el.find( 'span.title' ).html( title );
535
+ }
536
+
537
+ if ( '' !== subtitle ) {
538
+ toggle_el.find( '.subtitle' ).html( subtitle );
539
+ }
540
+
541
+ $( document ).trigger( 'yith-toggle-element-item-title', [toggle_el] );
542
+ };
543
+
544
+ $.urlParam = function ( name ) {
545
+ var results = new RegExp( '[\?&]' + name + '=([^&#]*)' )
546
+ .exec( window.location.search );
547
+
548
+ return ( results !== null ) ? results[ 1 ] || 0 : false;
549
+ };
550
+
551
+ $( document ).on( 'click', '.yith-toggle-title', function ( event ) {
552
+ var _toggle = $( event.target ),
553
+ _section = _toggle.closest( '.yith-toggle-row' ),
554
+ _content = _section.find( '.yith-toggle-content' );
555
+
556
+ if ( _toggle.hasClass( 'yith-plugin-fw-onoff' ) || _toggle.hasClass( 'yith-icon-drag' ) ) {
557
+ return false;
558
+ }
559
+
560
+ if ( _section.is( '.yith-toggle-row-opened' ) ) {
561
+ _content.slideUp( 400 );
562
+ } else {
563
+ _content.slideDown( 400 );
564
+ }
565
+ _section.toggleClass( 'yith-toggle-row-opened' );
566
+ } );
567
+
568
+ /**Add new box toggle**/
569
+ $( document ).on( 'click', '.yith-add-box-button', function ( event ) {
570
+ event.preventDefault();
571
+ var $this = $( this ),
572
+ target_id = $this.data( 'box_id' ),
573
+ closed_label = $this.data( 'closed_label' ),
574
+ label = $this.data( 'opened_label' ),
575
+ id = $this.closest( '.yith-toggle_wrapper' ).attr( 'id' );
576
+ template = wp.template( 'yith-toggle-element-add-box-content-' + id );
577
+
578
+ if ( '' !== target_id ) {
579
+ $( '#' + target_id ).html( template( { index: 'box_id' } ) ).slideToggle();
580
+ if ( closed_label !== '' ) {
581
+ if ( $this.html() === closed_label ) {
582
+ $this.html( label ).removeClass( 'closed' );
583
+ } else {
584
+ $this.html( closed_label ).addClass( 'closed' );
585
+ }
586
+ }
587
+
588
+ $( document ).trigger( 'yith_fields_init' );
589
+ $( document ).trigger( 'yith-add-box-button-toggle', [$this] );
590
+ }
591
+ } );
592
+
593
+ $( document ).on( 'click', '.yith-add-box-buttons .yith-save-button', function ( event ) {
594
+
595
+ event.preventDefault();
596
+ var add_box = $( this ).parents( '.yith-add-box' ),
597
+ id = $( this ).closest( '.yith-toggle_wrapper' ).attr( 'id' ),
598
+ spinner = add_box.find( '.spinner' ),
599
+ toggle_element = $( this ).parents( '.toggle-element' ),
600
+ fields = add_box.find( ':input' ),
601
+ counter = toggle_element.find( '.yith-toggle-row' ).length,
602
+ hidden_obj = $( '<input type="hidden">' );
603
+
604
+ hidden_obj.val( counter );
605
+
606
+ $( document ).trigger( 'yith-toggle-change-counter', [hidden_obj, add_box] );
607
+
608
+ counter = hidden_obj.val();
609
+ var template = wp.template( 'yith-toggle-element-item-' + id ),
610
+ toggle_el = $( template( { index: counter } ) );
611
+
612
+ spinner.addClass( 'show' );
613
+
614
+ $.each( fields, function ( i, field ) {
615
+ if ( typeof $( field ).attr( 'id' ) != 'undefined' ) {
616
+
617
+ $field_id = $( field ).attr( 'id' );
618
+ $field_val = $( field ).val();
619
+
620
+ if ( 'radio' == $( field ).attr( 'type' ) ) {
621
+ $field_id = $field_id.replace( 'new_', '' );
622
+ $field_id = $field_id.replace( '-' + $field_val, '' );
623
+ $field_id = $field_id + '_dataindex-' + $field_val;
624
+ } else {
625
+ $field_id = $field_id.replace( 'new_', '' ) + '_' + counter;
626
+ }
627
+
628
+ if ( $( field ).is( ':checked' ) ) {
629
+ $( toggle_el ).find( '#' + $field_id ).prop( 'checked', true );
630
+ }
631
+
632
+ if ( $( field ).hasClass( 'yith-post-search' ) || $( field ).hasClass( 'yith-term-search' ) ) {
633
+ $( toggle_el ).find( '#' + $field_id ).html( $( '#' + $( field ).attr( 'id' ) ).html() );
634
+ }
635
+
636
+ $( toggle_el ).find( '#' + $field_id ).val( $field_val );
637
+
638
+ }
639
+
640
+ } );
641
+
642
+ $( toggle_el ).formatToggleTitle();
643
+ var form_is_valid = $( '<input type="hidden">' ).val( 'yes' );
644
+ $( document ).trigger( 'yith-toggle-element-item-before-add', [add_box, toggle_el, form_is_valid] );
645
+
646
+ var delayInMilliseconds = 1000; //1 second
647
+ setTimeout( function () {
648
+ if ( form_is_valid.val() === 'yes' ) {
649
+ $( toggle_element ).find( '.yith-toggle-elements' ).append( toggle_el );
650
+ $( add_box ).find( '.yith-plugin-fw-datepicker' ).datepicker( 'destroy' );
651
+ $( add_box ).html( '' );
652
+ $( add_box ).prev( '.yith-add-box-button' ).trigger( 'click' );
653
+ toggle_element.saveToggleElement();
654
+
655
+ var delayInMilliseconds = 2000; //1 second
656
+ setTimeout( function () {
657
+ $( toggle_element ).find( '.highlight' ).removeClass( 'highlight' );
658
+ }, delayInMilliseconds );
659
+
660
+
661
+ $( document ).trigger( 'yith_fields_init' );
662
+ }
663
+ }, delayInMilliseconds );
664
+
665
+
666
+ } );
667
+
668
+ $( document ).on( 'click', '.yith-toggle-row .yith-save-button', function ( event ) {
669
+ event.preventDefault();
670
+ var toggle = $( this ).closest( '.toggle-element' ),
671
+ toggle_row = $( this ).closest( '.yith-toggle-row' ),
672
+ spinner = toggle_row.find( '.spinner' );
673
+ toggle_row.formatToggleTitle();
674
+
675
+ var form_is_valid = $( '<input type="hidden">' ).val( 'yes' );
676
+ $( document ).trigger( 'yith-toggle-element-item-before-update', [toggle, toggle_row, form_is_valid] );
677
+ if ( form_is_valid.val() === 'yes' ) {
678
+ spinner.addClass( 'show' );
679
+ toggle.saveToggleElement( spinner );
680
+ }
681
+ } );
682
+
683
+ //register remove the dome and save the toggle
684
+ $( document ).on( 'click', '.yith-toggle-row .yith-delete-button', function ( event ) {
685
+ event.preventDefault();
686
+ var toggle = $( this ).closest( '.toggle-element' ),
687
+ toggle_row = $( this ).closest( '.yith-toggle-row' );
688
+ toggle_row.remove();
689
+ toggle.saveToggleElement();
690
+ } );
691
+
692
+ //register onoff status
693
+ $( document ).on( 'click', '.yith-toggle-onoff', function ( event ) {
694
+ event.preventDefault();
695
+ var toggle = $( this ).closest( '.toggle-element' );
696
+ toggle.saveToggleElement();
697
+ } );
698
+
699
+ // Radio
700
+ $( document ).on( 'click', '.yith-plugin-fw-radio input[type=radio]', function () {
701
+ $( this ).closest( '.yith-plugin-fw-radio' ).val( $( this ).val() ).trigger( 'change' );
702
+ } );
703
+
704
+ $( document ).on( 'click', '.yith-password-eye', function () {
705
+ var $this = $( this ),
706
+ inp = $( this ).closest( '.yith-password-wrapper' ).find( 'input' );
707
+ if ( inp.attr( 'type' ) === "password" ) {
708
+ inp.attr( 'type', 'text' );
709
+ $this.addClass( 'yith-password-eye-closed' );
710
+ } else {
711
+ inp.attr( 'type', 'password' );
712
+ $this.removeClass( 'yith-password-eye-closed' );
713
+ }
714
+ } );
715
+
716
+ $( document.body ).on( 'yith-plugin-fw-init-radio', function () {
717
+ $( '.yith-plugin-fw-radio:not(.yith-plugin-fw-radio--initialized)' ).each( function () {
718
+ $( this ).val( $( this ).attr( 'value' ) );
719
+ $( this ).addClass( 'yith-plugin-fw-radio--initialized' );
720
+ } );
721
+ } ).trigger( 'yith-plugin-fw-init-radio' );
722
+
723
+ /**
724
+ * Select2 - add class to stylize it with the new plugin-fw style
725
+ */
726
+ $( document ).on( 'select2:open', function ( e ) {
727
+ if ( $( e.target ).closest( '.yith-plugin-ui' ).length ) {
728
+ $( '.select2-results' ).closest( '.select2-container' ).addClass( 'yith-plugin-fw-select2-container' );
729
+ }
730
+ } );
 
731
  /**
732
  * Dimensions
733
  */
plugin-fw/assets/js/yith-fields.min.js CHANGED
@@ -1 +1,30 @@
1
- !function(e){e(document).on("yith_fields_init",function(){var t=e(".yith-plugin-fw-datepicker"),i=e(".yith-plugin-fw-colorpicker"),a={imgPreviewHandler:".yith-plugin-fw-upload-img-preview",uploadButtonHandler:".yith-plugin-fw-upload-button",imgUrlHandler:".yith-plugin-fw-upload-img-url",resetButtonHandler:".yith-plugin-fw-upload-button-reset",imgUrl:e(".yith-plugin-fw-upload-img-url")},n=e(".add_media"),l={sliderWrapper:e(".yith-plugin-fw .image-gallery ul.slides-wrapper"),buttonHandler:".yith-plugin-fw .image-gallery-button"},s=e(".yith-plugin-fw-sidebar-layout"),o=e(".yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal"),r=e(".codemirror"),d=e(".yit-icons-manager-wrapper");e(".yith-plugin-ui td.forminp-checkbox");t.each(function(){var t=e(this).data();t.showAnim=!1,t.beforeShow=function(e,t){t.dpDiv.addClass("yith-plugin-fw-datepicker-div")},t.onClose=function(e,t){t.dpDiv.removeClass("yith-plugin-fw-datepicker-div")},e(this).datepicker(t)}),i.wpColorPicker({palettes:!1,width:200,mode:"hsl",clear:function(){var t=e(this);t.val(t.data("default-color")),t.change()}}),i.each(function(){var t=e(this).data("variations-label"),i=e(this).closest(".yith-plugin-fw-colorpicker-field-wrapper"),a=e(this).closest(".yith-single-colorpicker"),n=i.find(".wp-picker-input-wrap"),l=a.find(".wp-picker-input-wrap");if(n.length&&i.find("a.wp-color-result").attr("title",t),a.length&&a.find("a.wp-color-result").attr("title",t),!n.find(".wp-picker-clear-custom").length){var s=e("<span/>").attr({"class":"wp-picker-default-custom"});n.find(".wp-picker-default").wrap(s)}l.find(".wp-picker-clear-custom").length||(s=e("<span/>").attr({"class":"wp-picker-default-custom"}),l.find(".wp-picker-default").wrap(s))}),"undefined"!=typeof wp&&"undefined"!=typeof wp.media&&(a.imgUrl.change(function(){var t=e(this).val(),i=new RegExp("(http|ftp|https)://[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico|svg)"),n=e(this).parent().find(a.imgPreviewHandler).first();n.length<1&&(n=e(this).parent().parent().find(a.imgPreviewHandler).first()),i.test(t)?n.html('<img src="'+t+'" style="max-width:100px; max-height:100px;" />'):n.html("")}).trigger("change"),e(document).on("click",a.uploadButtonHandler,function(t){t.preventDefault();var i,n=e(this).attr("id").replace(/-button$/,"");if(i)i.open();else{var l=[new wp.media.controller.Library({library:wp.media.query(),multiple:!1,title:"Choose Image",priority:20,filterable:"uploaded"})];(i=wp.media.frames.downloadable_file=wp.media({title:"Choose Image",library:{type:""},button:{text:"Choose Image"},multiple:!1,states:l})).on("select",function(){var t=i.state().get("selection").first().toJSON();e("#"+n).val(t.url),e("#"+n+"-yith-attachment-id")&&e("#"+n+"-yith-attachment-id").val(t.id),a.imgUrl.trigger("change")}),i.open()}}),e(document).on("click",a.resetButtonHandler,function(t){var i=e(this),n=i.attr("id"),l=i.attr("id").replace(/-button-reset$/,""),s=e("#"+n).data("default");e("#"+l).val(s),a.imgUrl.trigger("change")}));n.on("click",function(){}),"undefined"!=typeof wp&&"undefined"!=typeof wp.media&&(e(document).on("click",l.buttonHandler,function(t){var i=e(this),a=i.closest(".image-gallery"),n=a.find(".image_gallery_ids"),l=n.val(),s=a.find("ul.slides-wrapper"),o=wp.media.frames.image_gallery=wp.media({title:i.data("choose"),button:{text:i.data("update")},states:[new wp.media.controller.Library({title:i.data("choose"),filterable:"all",multiple:!0})]});o.on("select",function(){o.state().get("selection").map(function(e){(e=e.toJSON()).id&&(l=l?l+","+e.id:e.id,s.append('<li class="image" data-attachment_id="'+e.id+'"><img src="'+e.sizes.thumbnail.url+'"/><ul class="actions"><li><a href="#" class="delete" title="'+i.data("delete")+'">x</a></li></ul></li>'))}),n.val(l)}),o.open()}),l.sliderWrapper.each(function(){var t=e(this);t.sortable({items:"li.image",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,start:function(e,t){t.item.css("background-color","#f6f6f6")},stop:function(e,t){t.item.removeAttr("style")},update:function(i,a){var n="";t.find("li.image").css("cursor","default").each(function(){var t=e(this).attr("data-attachment_id");n=n+t+","}),t.closest(".image-gallery").find(".image_gallery_ids").val(n)}})}),l.sliderWrapper.on("click","a.delete",function(){var t=e(this).closest(".image-gallery"),i=e(this).closest(".image-gallery ul.slides-wrapper"),a=t.find(".image_gallery_ids"),n="";e(this).closest("li.image").remove(),i.find("li.image").css("cursor","default").each(function(){var t=e(this).attr("data-attachment_id");n=n+t+","}),a.val(n)})),s.each(function(){e(this).find("img").on("click",function(){var t=e(this).closest(".yith-plugin-fw-sidebar-layout"),i=t.find(".yith-plugin-fw-sidebar-layout-sidebar-left-container"),a=t.find(".yith-plugin-fw-sidebar-layout-sidebar-right-container"),n=e(this).data("type");if(e(this).parent().children(":radio").attr("checked",!1),e(this).prev(":radio").attr("checked",!0),void 0!==n)switch(n){case"left":i.show(),a.hide();break;case"right":a.show(),i.hide();break;case"double":i.show(),a.show();break;default:i.hide(),a.hide()}})}),o.each(function(){var t=e(this).data("val"),i=e(this).data("min"),a=e(this).data("max"),n=e(this).data("step"),l=e(this).data("labels");e(this).slider({value:t,min:i,max:a,range:"min",step:n,create:function(){e(this).find(".ui-slider-handle").text(e(this).slider("value"))},slide:function(t,i){e(this).find("input").val(i.value),e(this).find(".ui-slider-handle").text(i.value),e(this).siblings(".feedback").find("strong").text(i.value+l)}})}),r.each(function(t,i){var a=CodeMirror.fromTextArea(i,{lineNumbers:1,mode:"javascript",showCursorWhenSelecting:!0});e(i).data("codemirrorInstance",a)}),e(document).on("click",".yith-plugin-fw-select-all",function(){e("#"+e(this).data("select-id")).find("option").prop("selected",!0).trigger("change")}),e(document).on("click",".yith-plugin-fw-deselect-all",function(){e("#"+e(this).data("select-id")).find("option").prop("selected",!1).trigger("change")}),d.each(function(){var t=e(this),i=t.find(".yit-icons-manager-icon-preview").first(),a=t.find(".yit-icons-manager-icon-text");t.on("click",".yit-icons-manager-list li",function(n){var l=e(n.target).closest("li"),s=l.data("font"),o=l.data("icon"),r=l.data("key"),d=l.data("name");i.attr("data-font",s),i.attr("data-icon",o),i.attr("data-key",r),i.attr("data-name",d),a.val(s+":"+d),t.find(".yit-icons-manager-list li").removeClass("active"),l.addClass("active")}),t.on("click",".yit-icons-manager-action-set-default",function(){t.find(".yit-icons-manager-list li.default").trigger("click")})}),e(document).on("click",".yith-plugin-fw-select-images__item",function(){var t=e(this),i=t.data("key"),a=t.closest(".yith-plugin-fw-select-images__wrapper"),n=a.find(".yith-plugin-fw-select-images__item"),l=a.find("select").first();l.length&&(l.val(i),n.removeClass("yith-plugin-fw-select-images__item--selected"),t.addClass("yith-plugin-fw-select-images__item--selected"))}),e(document.body).trigger("wc-enhanced-select-init"),e(document).find(".ui-sortable .yith-toggle-elements").sortable({cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",stop:function(t,i){var a=jQuery(".ui-sortable-handle"),n=0,l=new Array;for(n=0;n<a.length;n++)l[n]=e(a[n]).data("item_key");l.length>0&&e(this).closest(".toggle-element").saveToggleElement(null,l)}}),e(document.body).trigger("yith-framework-enhanced-select-init")}).trigger("yith_fields_init"),e(document).on("click",".yith-plugin-fw-onoff-container span",function(){var t=e(this).prev("input");t.prop("checked")?t.prop("checked",!1).attr("value","no").removeClass("onoffchecked"):t.prop("checked",!0).attr("value","yes").addClass("onoffchecked"),t.change()}),e.fn.saveToggleElement=function(t,i){var a=e(this),n="yith_plugin_fw_save_toggle_element",l=a.serializeToggleElement(),s=a.find(".yith-toggle_wrapper"),o=s.attr("id"),r=e.urlParam("tab");l.append("security",s.data("nonce")),void 0!==i&&i.length>0&&l.append("yith_toggle_elements_order_keys",i),a.closest(".metaboxes-tab.yith-plugin-ui").length?(n="yith_plugin_fw_save_toggle_element_metabox",post_id=e(this).closest("form#post").find("#post_ID").val(),yit_metaboxes_nonce=e(this).closest("form#post").find("#yit_metaboxes_nonce").val(),metabox_tab=e(this).closest(".tabs-panel").attr("id"),url=yith_framework_fw_fields.ajax_url+"?action="+n+"&post_ID="+post_id+"&yit_metaboxes_nonce="+yit_metaboxes_nonce+"&toggle_id="+o+"&metabox_tab="+metabox_tab):url=yith_framework_fw_fields.admin_url+"?action="+n+"&tab="+r+"&toggle_id="+o,e.ajax({type:"POST",url:url,data:l,contentType:!1,processData:!1,success:function(i){t&&t.removeClass("show"),e(document).trigger("yith_save_toggle_element_done",[i,a])}})},e.fn.serializeToggleElement=function(){var t=e(this),i=new FormData,a=e(t).find(":input").serializeArray();return e.each(a,function(e,t){el_name=t.name,i.append(t.name,t.value)}),i},e.fn.formatToggleTitle=function(){var t=e(this),i=t.find(":input"),a=t.find("span.title").data("title_format"),n=t.find(".subtitle").data("subtitle_format"),l=new RegExp("[^%%]+(?=[%%])","g");if(void 0!==a)var s=a.match(l);if(void 0!==n)var o=n.match(l);e.each(i,function(t,i){void 0!==e(i).attr("id")&&($field_id=e(i).attr("id"),$field_array=$field_id.split("_"),$field_array.pop(),$field_id=$field_array.join("_"),$field_val=e(i).val(),null!=s&&void 0!==s&&-1!==s.indexOf($field_id)&&(a=a.replace("%%"+$field_id+"%%",$field_val)),null!=o&&void 0!==o&&-1!==o.indexOf($field_id)&&(n=n.replace("%%"+$field_id+"%%",$field_val)))}),""!==a&&t.find("span.title").html(a),""!==n&&t.find(".subtitle").html(n),e(document).trigger("yith-toggle-element-item-title",[t])},e.urlParam=function(e){var t=new RegExp("[?&]"+e+"=([^&#]*)").exec(window.location.search);return null!==t&&(t[1]||0)},e(document).on("click",".yith-toggle-title",function(t){var i=e(t.target),a=i.closest(".yith-toggle-row"),n=a.find(".yith-toggle-content");if(i.hasClass("yith-plugin-fw-onoff")||i.hasClass("yith-icon-drag"))return!1;a.is(".yith-toggle-row-opened")?n.slideUp(400):n.slideDown(400),a.toggleClass("yith-toggle-row-opened")}),e(document).on("click",".yith-add-box-button",function(t){t.preventDefault();var i=e(this),a=i.data("box_id"),n=i.data("closed_label"),l=i.data("opened_label"),s=i.closest(".yith-toggle_wrapper").attr("id");template=wp.template("yith-toggle-element-add-box-content-"+s),""!==a&&(e("#"+a).html(template({index:"box_id"})).slideToggle(),""!==n&&(i.html()===n?i.html(l).removeClass("closed"):i.html(n).addClass("closed")),e(document).trigger("yith_fields_init"),e(document).trigger("yith-add-box-button-toggle",[i]))}),e(document).on("click",".yith-add-box-buttons .yith-save-button",function(t){t.preventDefault();var i=e(this).parents(".yith-add-box"),a=e(this).closest(".yith-toggle_wrapper").attr("id"),n=i.find(".spinner"),l=e(this).parents(".toggle-element"),s=i.find(":input"),o=l.find(".yith-toggle-row").length,r=e('<input type="hidden">');r.val(o),e(document).trigger("yith-toggle-change-counter",[r,i]),o=r.val();var d=wp.template("yith-toggle-element-item-"+a),c=e(d({index:o}));n.addClass("show"),e.each(s,function(t,i){void 0!==e(i).attr("id")&&($field_id=e(i).attr("id"),$field_val=e(i).val(),"radio"==e(i).attr("type")?($field_id=$field_id.replace("new_",""),$field_id=$field_id.replace("-"+$field_val,""),$field_id=$field_id+"_dataindex-"+$field_val):$field_id=$field_id.replace("new_","")+"_"+o,e(i).is(":checked")&&e(c).find("#"+$field_id).prop("checked",!0),(e(i).hasClass("yith-post-search")||e(i).hasClass("yith-term-search"))&&e(c).find("#"+$field_id).html(e("#"+e(i).attr("id")).html()),e(c).find("#"+$field_id).val($field_val))}),e(c).formatToggleTitle();var u=e('<input type="hidden">').val("yes");e(document).trigger("yith-toggle-element-item-before-add",[i,c,u]);setTimeout(function(){if("yes"===u.val()){e(l).find(".yith-toggle-elements").append(c),e(i).find(".yith-plugin-fw-datepicker").datepicker("destroy"),e(i).html(""),e(i).prev(".yith-add-box-button").trigger("click"),l.saveToggleElement();setTimeout(function(){e(l).find(".highlight").removeClass("highlight")},2e3),e(document).trigger("yith_fields_init")}},1e3)}),e(document).on("click",".yith-toggle-row .yith-save-button",function(t){t.preventDefault();var i=e(this).closest(".toggle-element"),a=e(this).closest(".yith-toggle-row"),n=a.find(".spinner");a.formatToggleTitle();var l=e('<input type="hidden">').val("yes");e(document).trigger("yith-toggle-element-item-before-update",[i,a,l]),"yes"===l.val()&&(n.addClass("show"),i.saveToggleElement(n))}),e(document).on("click",".yith-toggle-row .yith-delete-button",function(t){t.preventDefault();var i=e(this).closest(".toggle-element");e(this).closest(".yith-toggle-row").remove(),i.saveToggleElement()}),e(document).on("click",".yith-toggle-onoff",function(t){t.preventDefault(),e(this).closest(".toggle-element").saveToggleElement()}),e(document).on("click",".yith-plugin-fw-radio input[type=radio]",function(){e(this).closest(".yith-plugin-fw-radio").val(e(this).val()).trigger("change")}),e(document).on("click",".yith-password-eye",function(){var t=e(this),i=e(this).closest(".yith-password-wrapper").find("input");"password"===i.attr("type")?(i.attr("type","text"),t.addClass("yith-password-eye-closed")):(i.attr("type","password"),t.removeClass("yith-password-eye-closed"))}),e(document.body).on("yith-plugin-fw-init-radio",function(){e(".yith-plugin-fw-radio:not(.yith-plugin-fw-radio--initialized)").each(function(){e(this).val(e(this).attr("value")),e(this).addClass("yith-plugin-fw-radio--initialized")})}).trigger("yith-plugin-fw-init-radio"),e(document).on("select2:open",function(t){e(t.target).closest(".yith-plugin-ui").length&&e(".select2-results").closest(".select2-container").addClass("yith-plugin-fw-select2-container")});var t={selectors:{wrapper:".yith-plugin-fw-dimensions",units:{wrapper:".yith-plugin-fw-dimensions__units",single:".yith-plugin-fw-dimensions__unit",value:".yith-plugin-fw-dimensions__unit__value",selectedClass:"yith-plugin-fw-dimensions__unit--selected"},linked:{button:".yith-plugin-fw-dimensions__linked",value:".yith-plugin-fw-dimensions__linked__value",wrapperActiveClass:"yith-plugin-fw-dimensions--linked-active"},dimensions:{number:".yith-plugin-fw-dimensions__dimension__number"}},init:function(){var i=t;e(document).on("click",i.selectors.units.single,i.unitChange),e(document).on("click",i.selectors.linked.button,i.linkedChange),e(document).on("change keyup",i.selectors.dimensions.number,i.numberChange)},unitChange:function(i){var a=e(this).closest(t.selectors.units.single),n=a.closest(t.selectors.units.wrapper),l=n.find(t.selectors.units.single),s=n.find(t.selectors.units.value).first(),o=a.data("value");l.removeClass(t.selectors.units.selectedClass),a.addClass(t.selectors.units.selectedClass),s.val(o)},linkedChange:function(){var i=e(this).closest(t.selectors.linked.button),a=i.closest(t.selectors.wrapper),n=i.find(t.selectors.linked.value);"yes"===n.val()?(a.removeClass(t.selectors.linked.wrapperActiveClass),n.val("no")):(a.addClass(t.selectors.linked.wrapperActiveClass),n.val("yes"),a.find(t.selectors.dimensions.number).first().trigger("change"))},numberChange:function(i){var a=e(this).closest(t.selectors.dimensions.number),n=a.closest(t.selectors.wrapper);n.hasClass(t.selectors.linked.wrapperActiveClass)&&n.find(t.selectors.dimensions.number).val(a.val())}};t.init()}(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(a){a(document).on("yith_fields_init",function(){var b=a(".yith-plugin-fw-datepicker"),c=a(".yith-plugin-fw-colorpicker"),d=a(".yith-plugin-fw-upload-img-url"),e=a(".add_media"),f=a(".yith-plugin-fw .image-gallery ul.slides-wrapper"),h=a(".yith-plugin-fw-sidebar-layout"),k=a(".yith-plugin-fw .yith-plugin-fw-slider-container .ui-slider-horizontal"),l=a(".codemirror"),n=a(".yit-icons-manager-wrapper");a(".yith-plugin-ui td.forminp-checkbox");b.each(function(){var b=a(this).data();b.showAnim=
2
+ !1;b.beforeShow=function(a,b){b.dpDiv.addClass("yith-plugin-fw-datepicker-div")};b.onClose=function(a,b){b.dpDiv.removeClass("yith-plugin-fw-datepicker-div")};a(this).datepicker(b)});c.wpColorPicker({palettes:!1,width:200,mode:"hsl",clear:function(){var b=a(this);b.val(b.data("default-color"));b.change()}});c.each(function(){var b=a(this).data("variations-label"),g=a(this).closest(".yith-plugin-fw-colorpicker-field-wrapper"),c=a(this).closest(".yith-single-colorpicker"),m=g.find(".wp-picker-input-wrap"),
3
+ d=c.find(".wp-picker-input-wrap");m.length&&g.find("a.wp-color-result").attr("title",b);c.length&&c.find("a.wp-color-result").attr("title",b);m.find(".wp-picker-clear-custom").length||(b=a("<span/>").attr({"class":"wp-picker-default-custom"}),m.find(".wp-picker-default").wrap(b));d.find(".wp-picker-clear-custom").length||(b=a("<span/>").attr({"class":"wp-picker-default-custom"}),d.find(".wp-picker-default").wrap(b))});"undefined"!==typeof wp&&"undefined"!==typeof wp.media&&(d.change(function(){var b=
4
+ a(this).val(),g=a(this).parent().find(".yith-plugin-fw-upload-img-preview").first();1>g.length&&(g=a(this).parent().parent().find(".yith-plugin-fw-upload-img-preview").first());/(http|ftp|https):\/\/[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico|svg)/.test(b)?g.html('<img src="'+b+'" style="max-width:100px; max-height:100px;" />'):g.html("")}).trigger("change"),a(document).on("click",".yith-plugin-fw-upload-button",function(b){b.preventDefault();var g=a(this).attr("id").replace(/-button$/,"");
5
+ if(!c){b=[new wp.media.controller.Library({library:wp.media.query(),multiple:!1,title:"Choose Image",priority:20,filterable:"uploaded"})];var c=wp.media.frames.downloadable_file=wp.media({title:"Choose Image",library:{type:""},button:{text:"Choose Image"},multiple:!1,states:b});c.on("select",function(){var b=c.state().get("selection").first().toJSON();a("#"+g).val(b.url);a("#"+g+"-yith-attachment-id")&&a("#"+g+"-yith-attachment-id").val(b.id);d.trigger("change")})}c.open()}),a(document).on("click",
6
+ ".yith-plugin-fw-upload-button-reset",function(b){var c=a(this);b=c.attr("id");c=c.attr("id").replace(/-button-reset$/,"");b=a("#"+b).data("default");a("#"+c).val(b);d.trigger("change")}));e.on("click",function(){});"undefined"!==typeof wp&&"undefined"!==typeof wp.media&&(a(document).on("click",".yith-plugin-fw .image-gallery-button",function(b){var c=a(this);b=c.closest(".image-gallery");var d=b.find(".image_gallery_ids"),m=d.val(),p=b.find("ul.slides-wrapper"),e=wp.media.frames.image_gallery=wp.media({title:c.data("choose"),
7
+ button:{text:c.data("update")},states:[new wp.media.controller.Library({title:c.data("choose"),filterable:"all",multiple:!0})]});e.on("select",function(){e.state().get("selection").map(function(a){a=a.toJSON();a.id&&(m=m?m+","+a.id:a.id,p.append('<li class="image" data-attachment_id="'+a.id+'"><img src="'+a.sizes.thumbnail.url+'"/><ul class="actions"><li><a href="#" class="delete" title="'+c.data("delete")+'">x</a></li></ul></li>'))});d.val(m)});e.open()}),f.each(function(){var b=a(this);b.sortable({items:"li.image",
8
+ cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")},update:function(c,d){var g="";b.find("li.image").css("cursor","default").each(function(){var b=a(this).attr("data-attachment_id");g=g+b+","});b.closest(".image-gallery").find(".image_gallery_ids").val(g)}})}),f.on("click","a.delete",function(){var b=a(this).closest(".image-gallery"),c=a(this).closest(".image-gallery ul.slides-wrapper");
9
+ b=b.find(".image_gallery_ids");var d="";a(this).closest("li.image").remove();c.find("li.image").css("cursor","default").each(function(){var b=a(this).attr("data-attachment_id");d=d+b+","});b.val(d)}));h.each(function(){a(this).find("img").on("click",function(){var b=a(this).closest(".yith-plugin-fw-sidebar-layout"),c=b.find(".yith-plugin-fw-sidebar-layout-sidebar-left-container");b=b.find(".yith-plugin-fw-sidebar-layout-sidebar-right-container");var d=a(this).data("type");a(this).parent().children(":radio").attr("checked",
10
+ !1);a(this).prev(":radio").attr("checked",!0);if("undefined"!=typeof d)switch(d){case "left":c.show();b.hide();break;case "right":b.show();c.hide();break;case "double":c.show();b.show();break;default:c.hide(),b.hide()}})});k.each(function(){var b=a(this).data("val"),c=a(this).data("min"),d=a(this).data("max"),e=a(this).data("step"),f=a(this).data("labels");a(this).slider({value:b,min:c,max:d,range:"min",step:e,create:function(){a(this).find(".ui-slider-handle").text(a(this).slider("value"))},slide:function(b,
11
+ c){a(this).find("input").val(c.value);a(this).find(".ui-slider-handle").text(c.value);a(this).siblings(".feedback").find("strong").text(c.value+f)}})});l.each(function(b,c){var d=CodeMirror.fromTextArea(c,{lineNumbers:1,mode:"javascript",showCursorWhenSelecting:!0});a(c).data("codemirrorInstance",d)});a(document).on("click",".yith-plugin-fw-select-all",function(){a("#"+a(this).data("select-id")).find("option").prop("selected",!0).trigger("change")});a(document).on("click",".yith-plugin-fw-deselect-all",
12
+ function(){a("#"+a(this).data("select-id")).find("option").prop("selected",!1).trigger("change")});n.each(function(){var b=a(this),c=b.find(".yit-icons-manager-icon-preview").first(),d=b.find(".yit-icons-manager-icon-text");b.on("click",".yit-icons-manager-list li",function(e){e=a(e.target).closest("li");var g=e.data("font"),f=e.data("icon"),m=e.data("key"),h=e.data("name");c.attr("data-font",g);c.attr("data-icon",f);c.attr("data-key",m);c.attr("data-name",h);d.val(g+":"+h);b.find(".yit-icons-manager-list li").removeClass("active");
13
+ e.addClass("active")});b.on("click",".yit-icons-manager-action-set-default",function(){b.find(".yit-icons-manager-list li.default").trigger("click")})});a(document).on("click",".yith-plugin-fw-select-images__item",function(){var b=a(this),c=b.data("key"),d=b.closest(".yith-plugin-fw-select-images__wrapper"),e=d.find(".yith-plugin-fw-select-images__item");d=d.find("select").first();d.length&&(d.val(c).trigger("yith_select_images_value_changed"),e.removeClass("yith-plugin-fw-select-images__item--selected"),
14
+ b.addClass("yith-plugin-fw-select-images__item--selected"))});a(document.body).trigger("wc-enhanced-select-init");a(document).find(".ui-sortable .yith-toggle-elements").sortable({cursor:"move",axis:"y",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",stop:function(b,c){var d=jQuery(".ui-sortable-handle"),e,g=[];for(e=0;e<d.length;e++)g[e]=a(d[e]).data("item_key");0<g.length&&a(this).closest(".toggle-element").saveToggleElement(null,g)}});a(document.body).trigger("yith-framework-enhanced-select-init")}).trigger("yith_fields_init");
15
+ a(document).on("click",".yith-plugin-fw-onoff-container span",function(){var b=a(this).prev("input");b.prop("checked")?b.prop("checked",!1).attr("value","no").removeClass("onoffchecked"):b.prop("checked",!0).attr("value","yes").addClass("onoffchecked");b.change()});a.fn.saveToggleElement=function(b,c){var d=a(this),e="yith_plugin_fw_save_toggle_element",f=d.serializeToggleElement(),h=d.find(".yith-toggle_wrapper"),k=h.attr("id"),l=a.urlParam("tab");f.append("security",h.data("nonce"));"undefined"!=
16
+ typeof c&&0<c.length&&f.append("yith_toggle_elements_order_keys",c);d.closest(".metaboxes-tab.yith-plugin-ui").length?(e="yith_plugin_fw_save_toggle_element_metabox",post_id=a(this).closest("form#post").find("#post_ID").val(),yit_metaboxes_nonce=a(this).closest("form#post").find("#yit_metaboxes_nonce").val(),metabox_tab=a(this).closest(".tabs-panel").attr("id"),url=yith_framework_fw_fields.ajax_url+"?action="+e+"&post_ID="+post_id+"&yit_metaboxes_nonce="+yit_metaboxes_nonce+"&toggle_id="+k+"&metabox_tab="+
17
+ metabox_tab):url=yith_framework_fw_fields.admin_url+"?action="+e+"&tab="+l+"&toggle_id="+k;a.ajax({type:"POST",url:url,data:f,contentType:!1,processData:!1,success:function(c){b&&b.removeClass("show");a(document).trigger("yith_save_toggle_element_done",[c,d])}})};a.fn.serializeToggleElement=function(){var b=a(this),c=new FormData;b=a(b).find(":input").serializeArray();a.each(b,function(a,b){el_name=b.name;c.append(b.name,b.value)});return c};a.fn.formatToggleTitle=function(){var b=a(this),c=b.find(":input"),
18
+ d=b.find("span.title").data("title_format"),e=b.find(".subtitle").data("subtitle_format"),f=RegExp("[^%%]+(?=[%%])","g");if("undefined"!=typeof d)var h=d.match(f);if("undefined"!=typeof e)var k=e.match(f);a.each(c,function(b,c){"undefined"!=typeof a(c).attr("id")&&($field_id=a(c).attr("id"),$field_array=$field_id.split("_"),$field_array.pop(),$field_id=$field_array.join("_"),$field_val=a(c).val(),null!=h&&"undefined"!=typeof h&&-1!==h.indexOf($field_id)&&(d=d.replace("%%"+$field_id+"%%",$field_val)),
19
+ null!=k&&"undefined"!=typeof k&&-1!==k.indexOf($field_id)&&(e=e.replace("%%"+$field_id+"%%",$field_val)))});""!==d&&b.find("span.title").html(d);""!==e&&b.find(".subtitle").html(e);a(document).trigger("yith-toggle-element-item-title",[b])};a.urlParam=function(a){a=(new RegExp("[?&]"+a+"=([^&#]*)")).exec(window.location.search);return null!==a?a[1]||0:!1};a(document).on("click",".yith-toggle-title",function(b){b=a(b.target);var c=b.closest(".yith-toggle-row"),d=c.find(".yith-toggle-content");if(b.hasClass("yith-plugin-fw-onoff")||
20
+ b.hasClass("yith-icon-drag"))return!1;c.is(".yith-toggle-row-opened")?d.slideUp(400):d.slideDown(400);c.toggleClass("yith-toggle-row-opened")});a(document).on("click",".yith-add-box-button",function(b){b.preventDefault();b=a(this);var c=b.data("box_id"),d=b.data("closed_label"),e=b.data("opened_label"),f=b.closest(".yith-toggle_wrapper").attr("id");template=wp.template("yith-toggle-element-add-box-content-"+f);""!==c&&(a("#"+c).html(template({index:"box_id"})).slideToggle(),""!==d&&(b.html()===d?
21
+ b.html(e).removeClass("closed"):b.html(d).addClass("closed")),a(document).trigger("yith_fields_init"),a(document).trigger("yith-add-box-button-toggle",[b]))});a(document).on("click",".yith-add-box-buttons .yith-save-button",function(b){b.preventDefault();var c=a(this).parents(".yith-add-box"),d=a(this).closest(".yith-toggle_wrapper").attr("id");b=c.find(".spinner");var e=a(this).parents(".toggle-element"),f=c.find(":input"),h=e.find(".yith-toggle-row").length,k=a('<input type="hidden">');k.val(h);
22
+ a(document).trigger("yith-toggle-change-counter",[k,c]);h=k.val();d=wp.template("yith-toggle-element-item-"+d);var l=a(d({index:h}));b.addClass("show");a.each(f,function(b,c){"undefined"!=typeof a(c).attr("id")&&($field_id=a(c).attr("id"),$field_val=a(c).val(),"radio"==a(c).attr("type")?($field_id=$field_id.replace("new_",""),$field_id=$field_id.replace("-"+$field_val,""),$field_id=$field_id+"_dataindex-"+$field_val):$field_id=$field_id.replace("new_","")+"_"+h,a(c).is(":checked")&&a(l).find("#"+
23
+ $field_id).prop("checked",!0),(a(c).hasClass("yith-post-search")||a(c).hasClass("yith-term-search"))&&a(l).find("#"+$field_id).html(a("#"+a(c).attr("id")).html()),a(l).find("#"+$field_id).val($field_val))});a(l).formatToggleTitle();var n=a('<input type="hidden">').val("yes");a(document).trigger("yith-toggle-element-item-before-add",[c,l,n]);setTimeout(function(){"yes"===n.val()&&(a(e).find(".yith-toggle-elements").append(l),a(c).find(".yith-plugin-fw-datepicker").datepicker("destroy"),a(c).html(""),
24
+ a(c).prev(".yith-add-box-button").trigger("click"),e.saveToggleElement(),setTimeout(function(){a(e).find(".highlight").removeClass("highlight")},2E3),a(document).trigger("yith_fields_init"))},1E3)});a(document).on("click",".yith-toggle-row .yith-save-button",function(b){b.preventDefault();b=a(this).closest(".toggle-element");var c=a(this).closest(".yith-toggle-row"),d=c.find(".spinner");c.formatToggleTitle();var e=a('<input type="hidden">').val("yes");a(document).trigger("yith-toggle-element-item-before-update",
25
+ [b,c,e]);"yes"===e.val()&&(d.addClass("show"),b.saveToggleElement(d))});a(document).on("click",".yith-toggle-row .yith-delete-button",function(b){b.preventDefault();b=a(this).closest(".toggle-element");a(this).closest(".yith-toggle-row").remove();b.saveToggleElement()});a(document).on("click",".yith-toggle-onoff",function(b){b.preventDefault();a(this).closest(".toggle-element").saveToggleElement()});a(document).on("click",".yith-plugin-fw-radio input[type=radio]",function(){a(this).closest(".yith-plugin-fw-radio").val(a(this).val()).trigger("change")});
26
+ a(document).on("click",".yith-password-eye",function(){var b=a(this),c=a(this).closest(".yith-password-wrapper").find("input");"password"===c.attr("type")?(c.attr("type","text"),b.addClass("yith-password-eye-closed")):(c.attr("type","password"),b.removeClass("yith-password-eye-closed"))});a(document.body).on("yith-plugin-fw-init-radio",function(){a(".yith-plugin-fw-radio:not(.yith-plugin-fw-radio--initialized)").each(function(){a(this).val(a(this).attr("value"));a(this).addClass("yith-plugin-fw-radio--initialized")})}).trigger("yith-plugin-fw-init-radio");
27
+ a(document).on("select2:open",function(b){a(b.target).closest(".yith-plugin-ui").length&&a(".select2-results").closest(".select2-container").addClass("yith-plugin-fw-select2-container")});var f={selectors:{wrapper:".yith-plugin-fw-dimensions",units:{wrapper:".yith-plugin-fw-dimensions__units",single:".yith-plugin-fw-dimensions__unit",value:".yith-plugin-fw-dimensions__unit__value",selectedClass:"yith-plugin-fw-dimensions__unit--selected"},linked:{button:".yith-plugin-fw-dimensions__linked",value:".yith-plugin-fw-dimensions__linked__value",
28
+ wrapperActiveClass:"yith-plugin-fw-dimensions--linked-active"},dimensions:{number:".yith-plugin-fw-dimensions__dimension__number"}},init:function(){var b=f;a(document).on("click",b.selectors.units.single,b.unitChange);a(document).on("click",b.selectors.linked.button,b.linkedChange);a(document).on("change keyup",b.selectors.dimensions.number,b.numberChange)},unitChange:function(b){b=a(this).closest(f.selectors.units.single);var c=b.closest(f.selectors.units.wrapper),d=c.find(f.selectors.units.single);
29
+ c=c.find(f.selectors.units.value).first();var e=b.data("value");d.removeClass(f.selectors.units.selectedClass);b.addClass(f.selectors.units.selectedClass);c.val(e)},linkedChange:function(){var b=a(this).closest(f.selectors.linked.button),c=b.closest(f.selectors.wrapper);b=b.find(f.selectors.linked.value);"yes"===b.val()?(c.removeClass(f.selectors.linked.wrapperActiveClass),b.val("no")):(c.addClass(f.selectors.linked.wrapperActiveClass),b.val("yes"),c.find(f.selectors.dimensions.number).first().trigger("change"))},
30
+ numberChange:function(b){b=a(this).closest(f.selectors.dimensions.number);var c=b.closest(f.selectors.wrapper);c.hasClass(f.selectors.linked.wrapperActiveClass)&&c.find(f.selectors.dimensions.number).val(b.val())}};f.init()})(jQuery);
plugin-fw/init.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /**
3
  * Framework Name: YIT Plugin Framework
4
- * Version: 3.4.19
5
  * Author: YITH
6
  * Text Domain: yith-plugin-fw
7
  * Domain Path: /languages/
8
  *
9
  * @author Your Inspiration Themes
10
- * @version 3.4.19
11
  */
12
  /**
13
  * This file belongs to the YIT Plugin Framework.
1
  <?php
2
  /**
3
  * Framework Name: YIT Plugin Framework
4
+ * Version: 3.4.22
5
  * Author: YITH
6
  * Text Domain: yith-plugin-fw
7
  * Domain Path: /languages/
8
  *
9
  * @author Your Inspiration Themes
10
+ * @version 3.4.20
11
  */
12
  /**
13
  * This file belongs to the YIT Plugin Framework.
plugin-fw/languages/yith-plugin-fw-it_IT.mo CHANGED
Binary file
plugin-fw/languages/yith-plugin-fw-it_IT.po CHANGED
@@ -5,14 +5,14 @@ msgstr ""
5
  "Project-Id-Version: YITH Plugin Starter 1.0.0 Plugin FW\n"
6
  "Report-Msgid-Bugs-To: YITH <plugins@yithemes.com>\n"
7
  "POT-Creation-Date: 2020-04-23 06:38:32+00:00\n"
8
- "PO-Revision-Date: 2020-04-06 10:46+0200\n"
9
  "Last-Translator: \n"
10
  "Language-Team: YIThemes <plugins@yithemes.com>\n"
11
  "Language: it_IT\n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
- "X-Generator: Poedit 2.2.1\n"
16
  "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
17
  "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
18
  "esc_html_x:1,2c\n"
@@ -779,7 +779,7 @@ msgstr ""
779
  #: templates/fields/onoff.php:24
780
  msgctxt "YES/NO button: use MAX 3 characters!"
781
  msgid "YES"
782
- msgstr "SI"
783
 
784
  #: templates/fields/onoff.php:25
785
  msgctxt "YES/NO button: use MAX 3 characters!"
5
  "Project-Id-Version: YITH Plugin Starter 1.0.0 Plugin FW\n"
6
  "Report-Msgid-Bugs-To: YITH <plugins@yithemes.com>\n"
7
  "POT-Creation-Date: 2020-04-23 06:38:32+00:00\n"
8
+ "PO-Revision-Date: 2020-06-01 13:46+0200\n"
9
  "Last-Translator: \n"
10
  "Language-Team: YIThemes <plugins@yithemes.com>\n"
11
  "Language: it_IT\n"
12
  "MIME-Version: 1.0\n"
13
  "Content-Type: text/plain; charset=UTF-8\n"
14
  "Content-Transfer-Encoding: 8bit\n"
15
+ "X-Generator: Poedit 2.3.1\n"
16
  "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
17
  "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
18
  "esc_html_x:1,2c\n"
779
  #: templates/fields/onoff.php:24
780
  msgctxt "YES/NO button: use MAX 3 characters!"
781
  msgid "YES"
782
+ msgstr ""
783
 
784
  #: templates/fields/onoff.php:25
785
  msgctxt "YES/NO button: use MAX 3 characters!"
plugin-fw/lib/yit-plugin-panel-wc.php CHANGED
@@ -303,6 +303,14 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
303
  $yit_options = $this->get_main_array_options();
304
  $option_key = $this->get_current_option_key();
305
 
 
 
 
 
 
 
 
 
306
  if ( version_compare( WC()->version, '2.4.0', '>=' ) ) {
307
  if ( !empty( $yit_options[ $option_key ] ) ) {
308
  foreach ( $yit_options[ $option_key ] as $option ) {
@@ -327,7 +335,7 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
327
  }
328
  }
329
 
330
- woocommerce_update_options( $yit_options[ $option_key ] );
331
 
332
  do_action( 'yit_panel_wc_after_update' );
333
 
@@ -460,25 +468,26 @@ if ( !class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
460
  delete_option( 'yit_plugin_fw_panel_wc_default_options_set' );
461
  }
462
 
463
- /**
464
- * Add the WooCommerce body class in plugin panel page
465
- *
466
- * @param array $admin_body_classes The body classes
467
- * @return array Filtered body classes
468
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
469
- * @since 2.0
470
- */
471
- public static function admin_body_class( $admin_body_classes ) {
472
- global $pagenow;
473
-
474
- $assets_screen_ids = (array) apply_filters( 'yith_plugin_fw_wc_panel_screen_ids_for_assets', array() );
475
-
476
-
477
- if ( ( 'admin.php' == $pagenow && ( strpos( get_current_screen()->id, 'yith-plugins_page' ) !== false || in_array( get_current_screen()->id, $assets_screen_ids ) ) ) )
478
- $admin_body_classes = substr_count( $admin_body_classes, self::$body_class ) == 0 ? $admin_body_classes . self::$body_class : $admin_body_classes;
479
-
480
- return 'admin.php' == $pagenow && substr_count( $admin_body_classes, 'woocommerce' ) == 0 ? $admin_body_classes .= ' woocommerce ' : $admin_body_classes;
481
- }
 
482
 
483
  /**
484
  * Maybe unserialize panel data
303
  $yit_options = $this->get_main_array_options();
304
  $option_key = $this->get_current_option_key();
305
 
306
+ foreach ( $yit_options as $key => $options_list ){
307
+ foreach ( $options_list as $value ){
308
+ if( ! empty( $value['yith-type'] ) && 'toggle-element-fixed' == $value['yith-type'] && isset( $value['save_single_options'] ) && true === $value['save_single_options'] ){
309
+ $yit_options[ $key ] = array_merge( $yit_options[ $key ] , $value['elements'] );
310
+ }
311
+ }
312
+ }
313
+
314
  if ( version_compare( WC()->version, '2.4.0', '>=' ) ) {
315
  if ( !empty( $yit_options[ $option_key ] ) ) {
316
  foreach ( $yit_options[ $option_key ] as $option ) {
335
  }
336
  }
337
 
338
+ woocommerce_update_options( $yit_options[ $option_key ] );
339
 
340
  do_action( 'yit_panel_wc_after_update' );
341
 
468
  delete_option( 'yit_plugin_fw_panel_wc_default_options_set' );
469
  }
470
 
471
+ /**
472
+ * Add the WooCommerce body class in plugin panel page
473
+ *
474
+ * @param string $admin_body_classes The body classes.
475
+ * @return string Filtered body classes
476
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
477
+ * @since 2.0
478
+ */
479
+ public static function admin_body_class( $admin_body_classes ) {
480
+ global $pagenow;
481
+
482
+ $assets_screen_ids = (array) apply_filters( 'yith_plugin_fw_wc_panel_screen_ids_for_assets', array() );
483
+
484
+ if ( ( 'admin.php' == $pagenow && ( strpos( get_current_screen()->id, 'yith-plugins_page' ) !== false || in_array( get_current_screen()->id, $assets_screen_ids ) ) ) ) {
485
+ $admin_body_classes = substr_count( $admin_body_classes, self::$body_class ) == 0 ? $admin_body_classes . self::$body_class : $admin_body_classes;
486
+ $admin_body_classes = substr_count( $admin_body_classes, 'woocommerce' ) == 0 ? $admin_body_classes . ' woocommerce ' : $admin_body_classes;
487
+ }
488
+
489
+ return $admin_body_classes;
490
+ }
491
 
492
  /**
493
  * Maybe unserialize panel data
plugin-fw/templates/fields/select-images.php CHANGED
@@ -17,7 +17,7 @@ extract( $field );
17
  $class = isset( $class ) ? $class : 'yith-plugin-fw-select-images';
18
  $wrapper_id = $id . '-wrapper';
19
  ?>
20
- <div id="<?php echo $wrapper_id ?>" class="yith-plugin-fw-select-images__wrapper">
21
 
22
  <select id="<?php echo $id ?>"
23
  name="<?php echo $name ?>"
@@ -41,7 +41,7 @@ $wrapper_id = $id . '-wrapper';
41
  $selected_class = 'yith-plugin-fw-select-images__item--selected';
42
  $current_class = $key === $value ? $selected_class : '';
43
  ?>
44
- <li class="yith-plugin-fw-select-images__item <?php echo $current_class ?>" data-key="<?php echo $key ?>" <?php echo $img_data; ?>>
45
  <?php if ( $label ) : ?>
46
  <div class="yith-plugin-fw-select-images__item__label"><?php echo $label ?></div>
47
  <?php endif; ?>
@@ -50,4 +50,4 @@ $wrapper_id = $id . '-wrapper';
50
  <?php endif; ?>
51
  <?php endforeach; ?>
52
  </ul>
53
- </div>
17
  $class = isset( $class ) ? $class : 'yith-plugin-fw-select-images';
18
  $wrapper_id = $id . '-wrapper';
19
  ?>
20
+ <div id="<?php echo $wrapper_id ?>" class="yith-plugin-fw-select-images__wrapper" data-type="select-images">
21
 
22
  <select id="<?php echo $id ?>"
23
  name="<?php echo $name ?>"
41
  $selected_class = 'yith-plugin-fw-select-images__item--selected';
42
  $current_class = $key === $value ? $selected_class : '';
43
  ?>
44
+ <li class="yith-plugin-fw-select-images__item <?php echo $current_class ?>" data-type="select-images-item" data-key="<?php echo $key ?>" <?php echo $img_data; ?>>
45
  <?php if ( $label ) : ?>
46
  <div class="yith-plugin-fw-select-images__item__label"><?php echo $label ?></div>
47
  <?php endif; ?>
50
  <?php endif; ?>
51
  <?php endforeach; ?>
52
  </ul>
53
+ </div>
plugin-fw/templates/fields/toggle-element-fixed.php CHANGED
@@ -10,6 +10,7 @@ $defaults = array(
10
  'custom_attributes' => '',
11
  'elements' => [],
12
  'onoff_field' => true,
 
13
 
14
  );
15
  $field = wp_parse_args( $field, $defaults );
@@ -48,10 +49,17 @@ $value = get_option( $name, [] );
48
  <?php foreach ( $elements as $element ):
49
  // build correct name and id
50
  $field_id = $element['id'];
51
- $element['name'] = "{$name}[{$field_id}]";
52
  $element['id'] = "{$id}_{$field_id}";
53
  // get value
54
- $element['value'] = isset( $value[ $field_id ] ) ? $value[ $field_id ] : ( isset( $element['default'] ) ? $element['default'] : '' );
 
 
 
 
 
 
 
55
  ?>
56
  <div class="yith-toggle-content-row <?php echo $element['type'] ?>">
57
  <label for="<?php echo $element['id']; ?>"><?php echo $element['title']; ?></label>
@@ -65,4 +73,4 @@ $value = get_option( $name, [] );
65
  </div>
66
  </div>
67
  </div>
68
- </div>
10
  'custom_attributes' => '',
11
  'elements' => [],
12
  'onoff_field' => true,
13
+ 'save_single_options' => false,
14
 
15
  );
16
  $field = wp_parse_args( $field, $defaults );
49
  <?php foreach ( $elements as $element ):
50
  // build correct name and id
51
  $field_id = $element['id'];
52
+ $element['name'] = false === $save_single_options ? "{$name}[{$field_id}]" : $field_id;
53
  $element['id'] = "{$id}_{$field_id}";
54
  // get value
55
+ $element['value'] = '';
56
+ if( false === $save_single_options ){
57
+ $element['value'] = isset( $value[ $field_id ] ) ? $value[ $field_id ] : ( isset( $element['default'] ) ? $element['default'] : '' );
58
+ }
59
+
60
+ else {
61
+ $element['value'] = get_option( $field_id, $element['default'] );
62
+ }
63
  ?>
64
  <div class="yith-toggle-content-row <?php echo $element['type'] ?>">
65
  <label for="<?php echo $element['id']; ?>"><?php echo $element['title']; ?></label>
73
  </div>
74
  </div>
75
  </div>
76
+ </div>