YITH WooCommerce Ajax Search - Version 1.7.9

Version Description

  • Released on 20 May 2020 =
  • New: Support for WooCommerce 4.2
  • Update: Plugin framework
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Search
Version 1.7.9
Comparing to
See all releases

Code changes from version 1.7.8 to 1.7.9

Files changed (159) hide show
  1. README.txt +5 -1
  2. assets/css/admin.css +0 -0
  3. assets/css/yith_wcas_ajax_search.css +0 -0
  4. assets/images/01.jpg +0 -0
  5. assets/images/02.png +0 -0
  6. assets/images/03.jpg +0 -0
  7. assets/images/ajax-loader.gif +0 -0
  8. assets/images/ajax-search-premium.jpg +0 -0
  9. assets/images/number-eight.png +0 -0
  10. assets/images/number-five.png +0 -0
  11. assets/images/number-fourth.png +0 -0
  12. assets/images/number-one.png +0 -0
  13. assets/images/number-seven.png +0 -0
  14. assets/images/number-six.png +0 -0
  15. assets/images/number-three.png +0 -0
  16. assets/images/number-two.png +0 -0
  17. assets/images/upgrade.png +0 -0
  18. assets/js/devbridge-jquery-autocomplete.js +0 -0
  19. assets/js/devbridge-jquery-autocomplete.min.js +0 -0
  20. assets/js/frontend.js +0 -0
  21. assets/js/frontend.min.js +0 -0
  22. assets/js/yith-autocomplete.js +0 -0
  23. assets/js/yith-autocomplete.min.js +0 -0
  24. class.yith-wcas-admin.php +204 -0
  25. class.yith-wcas-frontend.php +65 -0
  26. class.yith-wcas.php +227 -0
  27. compatibility/elementor/class.yith-wcas-elementor.php +85 -0
  28. compatibility/elementor/class.yith-wcas-search-form-elementor.php +115 -0
  29. functions.yith-wcas.php +23 -0
  30. init.php +3 -3
  31. languages/yith-woocommerce-ajax-search-it_IT.mo +0 -0
  32. languages/yith-woocommerce-ajax-search-it_IT.po +0 -0
  33. languages/yith-woocommerce-ajax-search-pt_PT.mo +0 -0
  34. languages/yith-woocommerce-ajax-search-pt_PT.po +0 -0
  35. languages/yith-woocommerce-ajax-search.pot +0 -0
  36. plugin-fw/.jshintrc +0 -0
  37. plugin-fw/Gruntfile.js +0 -0
  38. plugin-fw/assets/css/codemirror/codemirror.css +0 -0
  39. plugin-fw/assets/css/colorbox.css +0 -0
  40. plugin-fw/assets/css/metaboxes.css +0 -0
  41. plugin-fw/assets/css/yit-plugin-panel.css +0 -0
  42. plugin-fw/assets/css/yit-upgrade-to-pro.css +0 -0
  43. plugin-fw/assets/css/yit-upgrader.css +0 -0
  44. plugin-fw/assets/fonts/yith-icon.eot +0 -0
  45. plugin-fw/assets/fonts/yith-icon.svg +0 -0
  46. plugin-fw/assets/fonts/yith-icon.ttf +0 -0
  47. plugin-fw/assets/fonts/yith-icon.woff +0 -0
  48. plugin-fw/assets/images/arrow_down.svg +0 -0
  49. plugin-fw/assets/images/banner-premium.png +0 -0
  50. plugin-fw/assets/images/colorbox/border1.png +0 -0
  51. plugin-fw/assets/images/colorbox/border2.png +0 -0
  52. plugin-fw/assets/images/colorbox/loading.gif +0 -0
  53. plugin-fw/assets/images/double-sidebar.png +0 -0
  54. plugin-fw/assets/images/licence-error.png +0 -0
  55. plugin-fw/assets/images/no-sidebar.png +0 -0
  56. plugin-fw/assets/images/sidebar-left.png +0 -0
  57. plugin-fw/assets/images/sidebar-right.png +0 -0
  58. plugin-fw/assets/images/sleep.png +0 -0
  59. plugin-fw/assets/images/spinner.png +0 -0
  60. plugin-fw/assets/images/ui-icons_222222_256x240.png +0 -0
  61. plugin-fw/assets/images/ui-icons_2e83ff_256x240.png +0 -0
  62. plugin-fw/assets/images/ui-icons_454545_256x240.png +0 -0
  63. plugin-fw/assets/images/ui-icons_888888_256x240.png +0 -0
  64. plugin-fw/assets/images/x.png +0 -0
  65. plugin-fw/assets/images/yith-icon.svg +0 -0
  66. plugin-fw/assets/images/yithemes-icon.png +0 -0
  67. plugin-fw/assets/js/codemirror/codemirror.js +0 -0
  68. plugin-fw/assets/js/codemirror/javascript.js +0 -0
  69. plugin-fw/assets/js/how-to.js +0 -0
  70. plugin-fw/assets/js/javascript-md5/md5.min.js +0 -0
  71. plugin-fw/assets/js/jquery.colorbox.js +0 -0
  72. plugin-fw/assets/js/metabox.js +0 -0
  73. plugin-fw/assets/js/metabox.min.js +0 -0
  74. plugin-fw/assets/js/multisite-updater.js +0 -0
  75. plugin-fw/assets/js/multisite-updater.min.js +0 -0
  76. plugin-fw/assets/js/wp-pages.js +0 -0
  77. plugin-fw/assets/js/wp-pages.min.js +0 -0
  78. plugin-fw/assets/js/yit-cpt-unlimited.js +0 -0
  79. plugin-fw/assets/js/yit-cpt-unlimited.min.js +0 -0
  80. plugin-fw/assets/js/yit-plugin-panel.js +16 -4
  81. plugin-fw/assets/js/yit-plugin-panel.min.js +5 -1
  82. plugin-fw/assets/js/yit-wp-pointer.js +0 -0
  83. plugin-fw/assets/js/yit-wp-pointer.min.js +0 -0
  84. plugin-fw/assets/js/yith-colorpicker.min.js +1 -1
  85. plugin-fw/assets/js/yith-dashboard.js +0 -0
  86. plugin-fw/assets/js/yith-dashboard.min.js +0 -0
  87. plugin-fw/assets/js/yith-fields.js +727 -728
  88. plugin-fw/assets/js/yith-fields.min.js +30 -1
  89. plugin-fw/assets/js/yith-gutenberg.js +0 -0
  90. plugin-fw/assets/js/yith-gutenberg.min.js +0 -0
  91. plugin-fw/assets/js/yith-system-info.js +0 -0
  92. plugin-fw/assets/js/yith-system-info.min.js +0 -0
  93. plugin-fw/assets/js/yith-update-plugins.js +0 -0
  94. plugin-fw/assets/js/yith-update-plugins.min.js +0 -0
  95. plugin-fw/init.php +2 -2
  96. plugin-fw/languages/yith-plugin-fw-el.mo +0 -0
  97. plugin-fw/languages/yith-plugin-fw-el.po +0 -0
  98. plugin-fw/languages/yith-plugin-fw-es_ES.mo +0 -0
  99. plugin-fw/languages/yith-plugin-fw-es_ES.po +0 -0
  100. plugin-fw/languages/yith-plugin-fw-it_IT.mo +0 -0
  101. plugin-fw/languages/yith-plugin-fw-it_IT.po +0 -0
  102. plugin-fw/languages/yith-plugin-fw-nl_NL.mo +0 -0
  103. plugin-fw/languages/yith-plugin-fw-nl_NL.po +0 -0
  104. plugin-fw/languages/yith-plugin-fw.pot +0 -0
  105. plugin-fw/lib/promo/black.jpg +0 -0
  106. plugin-fw/lib/promo/cyber.jpg +0 -0
  107. plugin-fw/lib/promo/halloween.jpg +0 -0
  108. plugin-fw/lib/promo/yith-promo.php +0 -0
  109. plugin-fw/lib/promo/yith-promo.xml +0 -0
  110. plugin-fw/lib/yit-ajax.php +0 -0
  111. plugin-fw/lib/yit-cpt-unlimited.php +0 -0
  112. plugin-fw/lib/yit-metabox.php +0 -0
  113. plugin-fw/lib/yit-plugin-common.php +0 -0
  114. plugin-fw/lib/yit-plugin-gradients.php +0 -0
  115. plugin-fw/lib/yit-plugin-licence.php +0 -0
  116. plugin-fw/lib/yit-plugin-panel-wc.php +20 -19
  117. plugin-fw/lib/yit-plugin-panel.php +0 -0
  118. plugin-fw/lib/yit-plugin-subpanel.php +0 -0
  119. plugin-fw/lib/yit-pointers.php +0 -0
  120. plugin-fw/lib/yit-theme-licence.php +0 -0
  121. plugin-fw/lib/yit-upgrade.php +0 -0
  122. plugin-fw/lib/yit-video.php +0 -0
  123. plugin-fw/lib/yith-dashboard.php +0 -0
  124. plugin-fw/lib/yith-gutenberg.php +0 -0
  125. plugin-fw/lib/yith-system-status.php +0 -0
  126. plugin-fw/package.json +0 -0
  127. plugin-fw/templates/fields/ajax-customers.php +0 -0
  128. plugin-fw/templates/fields/checkbox-array.php +0 -0
  129. plugin-fw/templates/fields/country-select.php +0 -0
  130. plugin-fw/templates/fields/custom.php +0 -0
  131. plugin-fw/templates/fields/date-format.php +0 -0
  132. plugin-fw/templates/fields/list-table.php +0 -0
  133. plugin-fw/templates/fields/multi-colorpicker.php +0 -0
  134. plugin-fw/templates/fields/multi-select.php +0 -0
  135. plugin-fw/templates/fields/password.php +0 -0
  136. plugin-fw/templates/fields/select-images.php +3 -3
  137. plugin-fw/templates/fields/toggle-element-fixed.php +0 -0
  138. plugin-fw/templates/fields/toggle-element.php +0 -0
  139. plugin-fw/templates/metaboxes/tab.php +0 -0
  140. plugin-fw/templates/metaboxes/types/icon-list.php +0 -0
  141. plugin-fw/templates/panel/infobox.php +0 -0
  142. plugin-fw/templates/panel/sub-tabs-nav.php +0 -0
  143. plugin-fw/templates/panel/woocommerce/woocommerce-form.php +0 -0
  144. plugin-fw/templates/panel/woocommerce/woocommerce-panel.php +0 -0
  145. plugin-fw/templates/panel/woocommerce/woocommerce-upload.php +0 -0
  146. plugin-fw/templates/sysinfo/system-information-panel.php +0 -0
  147. plugin-fw/yit-deactive-plugin.php +0 -0
  148. plugin-fw/yit-functions.php +0 -0
  149. plugin-fw/yit-plugin-registration-hook.php +0 -0
  150. plugin-fw/yit-plugin.php +0 -0
  151. plugin-fw/yit-woocommerce-compatibility.php +0 -0
  152. plugin-options/gutenberg/blocks.php +0 -0
  153. plugin-options/premium-options.php +0 -0
  154. plugin-options/settings-options.php +0 -0
  155. templates/admin/premium.php +0 -0
  156. templates/yith-woocommerce-ajax-search.php +0 -0
  157. uninstall.php +0 -0
  158. widgets/class.yith-wcas-ajax-search.php +104 -0
  159. wpml-config.xml +0 -0
README.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
4
Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
Requires at least: 4.0.0
6
Tested up to: 5.4
7
- Stable tag: 1.7.8
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -138,6 +138,10 @@ If you have created your own language pack for YITH WooCommerce Ajax Search, or
138
2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
139
140
== Changelog ==
141
= 1.7.8 - Released on 23 April 2020 =
142
* Fix: Fixed issue with Elementor plugin
143
4
Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
Requires at least: 4.0.0
6
Tested up to: 5.4
7
+ Stable tag: 1.7.9
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
138
2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
139
140
== Changelog ==
141
+ = 1.7.9 - Released on 20 May 2020 =
142
+ * New: Support for WooCommerce 4.2
143
+ * Update: Plugin framework
144
+
145
= 1.7.8 - Released on 23 April 2020 =
146
* Fix: Fixed issue with Elementor plugin
147
assets/css/admin.css CHANGED
File without changes
assets/css/yith_wcas_ajax_search.css CHANGED
File without changes
assets/images/01.jpg CHANGED
File without changes
assets/images/02.png CHANGED
File without changes
assets/images/03.jpg CHANGED
File without changes
assets/images/ajax-loader.gif CHANGED
File without changes
assets/images/ajax-search-premium.jpg CHANGED
File without changes
assets/images/number-eight.png CHANGED
File without changes
assets/images/number-five.png CHANGED
File without changes
assets/images/number-fourth.png CHANGED
File without changes
assets/images/number-one.png CHANGED
File without changes
assets/images/number-seven.png CHANGED
File without changes
assets/images/number-six.png CHANGED
File without changes
assets/images/number-three.png CHANGED
File without changes
assets/images/number-two.png CHANGED
File without changes
assets/images/upgrade.png CHANGED
File without changes
assets/js/devbridge-jquery-autocomplete.js CHANGED
File without changes
assets/js/devbridge-jquery-autocomplete.min.js CHANGED
File without changes
assets/js/frontend.js CHANGED
File without changes
assets/js/frontend.min.js CHANGED
File without changes
assets/js/yith-autocomplete.js CHANGED
File without changes
assets/js/yith-autocomplete.min.js CHANGED
File without changes
class.yith-wcas-admin.php ADDED
@@ -0,0 +1,204 @@
1
+ <?php
2
+ /**
3
+ * Admin class
4
+ *
5
+ * @author YITH
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.1.1
8
+ */
9
+
10
+ if ( ! defined( 'YITH_WCAS' ) ) {
11
+ exit; } // Exit if accessed directly
12
+
13
+ if ( ! class_exists( 'YITH_WCAS_Admin' ) ) {
14
+ /**
15
+ * Admin class.
16
+ * The class manage all the admin behaviors.
17
+ *
18
+ * @since 1.0.0
19
+ */
20
+ class YITH_WCAS_Admin {
21
+ /**
22
+ * Plugin options
23
+ *
24
+ * @var array
25
+ * @access public
26
+ * @since 1.0.0
27
+ */
28
+ public $options = array();
29
+
30
+ /**
31
+ * Panel object
32
+ *
33
+ * @var Panel Object
34
+ */
35
+ protected $_panel;
36
+
37
+ /**
38
+ * Premium tab template file name.
39
+ *
40
+ * @var string
41
+ */
42
+ protected $_premium = 'premium.php';
43
+
44
+ /**
45
+ * Premium version landing link.
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_premium_landing = 'https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/';
50
+
51
+ /**
52
+ * Ajax Search panel page.
53
+ *
54
+ * @var string
55
+ */
56
+ protected $_panel_page = 'yith_wcas_panel';
57
+
58
+
59
+ /**
60
+ * Constructor
61
+ *
62
+ * @access public
63
+ * @since 1.0.0
64
+ */
65
+ public function __construct() {
66
+
67
+ add_action( 'admin_menu', array( $this, 'register_panel' ), 5 );
68
+ add_action( 'init', array( $this, 'gutenberg_integration' ) );
69
+ // Add action links.
70
+ add_filter( 'plugin_action_links_' . plugin_basename( YITH_WCAS_DIR . '/' . basename( YITH_WCAS_FILE ) ), array( $this, 'action_links' ) );
71
+ add_filter( 'yith_show_plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 5 );
72
+
73
+ add_action( 'yith_ajax_search_premium', array( $this, 'premium_tab' ) );
74
+
75
+ // YITH WCAS Loaded.
76
+ do_action( 'yith_wcas_loaded' );
77
+ }
78
+
79
+
80
+ /**
81
+ * Gutenberg Integration
82
+ */
83
+ public function gutenberg_integration() {
84
+ if ( function_exists( 'yith_plugin_fw_gutenberg_add_blocks' ) ) {
85
+ $blocks = include_once YITH_WCAS_DIR . 'plugin-options/gutenberg/blocks.php';
86
+ yith_plugin_fw_gutenberg_add_blocks( $blocks );
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Action Links
92
+ *
93
+ * Add the action links to plugin admin page
94
+ *
95
+ * @param string $links | links plugin array.
96
+ *
97
+ * @return mixed
98
+ * @since 1.0
99
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
100
+ * @use plugin_action_links_{$plugin_file_name}
101
+ */
102
+ public function action_links( $links ) {
103
+ $links = yith_add_action_links( $links, $this->_panel_page, false );
104
+ return $links;
105
+ }
106
+
107
+ /**
108
+ * Add a panel under YITH Plugins tab
109
+ *
110
+ * @return void
111
+ * @since 1.0
112
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
113
+ * @use /Yit_Plugin_Panel class
114
+ * @see plugin-fw/lib/yit-plugin-panel.php
115
+ */
116
+ public function register_panel() {
117
+
118
+ if ( ! empty( $this->_panel ) ) {
119
+ return;
120
+ }
121
+
122
+ $admin_tabs = array(
123
+ 'settings' => __( 'Settings', 'yith-woocommerce-ajax-search' ),
124
+ 'premium' => __( 'Premium Version', 'yith-woocommerce-ajax-search' ),
125
+ );
126
+
127
+ $args = array(
128
+ 'create_menu_page' => true,
129
+ 'parent_slug' => '',
130
+ 'plugin_slug' => YITH_WCAS_SLUG,
131
+ 'page_title' => __( 'YITH WooCommerce Ajax Search', 'yith-woocommerce-ajax-search' ),
132
+ 'menu_title' => __( 'Ajax Search', 'yith-woocommerce-ajax-search' ),
133
+ 'capability' => 'manage_options',
134
+ 'parent' => '',
135
+ 'parent_page' => 'yith_plugin_panel',
136
+ 'page' => $this->_panel_page,
137
+ 'admin-tabs' => $admin_tabs,
138
+ 'class' => yith_set_wrapper_class(),
139
+ 'options-path' => YITH_WCAS_DIR . '/plugin-options',
140
+ );
141
+
142
+ /* === Fixed: not updated theme === */
143
+ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
144
+ require_once 'plugin-fw/lib/yit-plugin-panel-wc.php';
145
+ }
146
+
147
+ $this->_panel = new YIT_Plugin_Panel_WooCommerce( $args );
148
+ }
149
+
150
+ /**
151
+ * Premium Tab Template
152
+ *
153
+ * Load the premium tab template on admin page
154
+ *
155
+ * @return void
156
+ * @since 1.0
157
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
158
+ */
159
+ public function premium_tab() {
160
+ $premium_tab_template = YITH_WCAS_TEMPLATE_PATH . '/admin/' . $this->_premium;
161
+ if ( file_exists( $premium_tab_template ) ) {
162
+ include_once $premium_tab_template;
163
+ }
164
+
165
+ }
166
+
167
+ /**
168
+ * Add the action links to plugin admin page
169
+ *
170
+ * @param string $new_row_meta_args Plugin Meta New args.
171
+ * @param string $plugin_meta Plugin Meta.
172
+ * @param string $plugin_file Plugin file.
173
+ * @param array $plugin_data Plugin data.
174
+ * @param string $status Status.
175
+ * @param string $init_file Init file.
176
+ *
177
+ * @return array
178
+ * @since 1.0
179
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
180
+ * @use plugin_row_meta
181
+ */
182
+ public function plugin_row_meta( $new_row_meta_args, $plugin_meta, $plugin_file, $plugin_data, $status, $init_file = 'YITH_WCAS_FREE_INIT' ) {
183
+ if ( defined( $init_file ) && constant( $init_file ) === $plugin_file ) {
184
+ $new_row_meta_args['slug'] = YITH_WCAS_SLUG;
185
+ }
186
+
187
+ return $new_row_meta_args;
188
+ }
189
+
190
+
191
+
192
+ /**
193
+ * Get the premium landing uri
194
+ *
195
+ * @since 1.0.0
196
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
197
+ * @return string The premium landing link
198
+ */
199
+ public function get_premium_landing_uri() {
200
+ return $this->_premium_landing;
201
+ }
202
+
203
+ }
204
+ }
class.yith-wcas-frontend.php ADDED
@@ -0,0 +1,65 @@
1
+ <?php
2
+ /**
3
+ * Frontend class
4
+ *
5
+ * @author YITH
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.1.1
8
+ */
9
+
10
+ if ( ! defined( 'YITH_WCAS' ) ) {
11
+ exit; } // Exit if accessed directly
12
+
13
+ if ( ! class_exists( 'YITH_WCAS_Frontend' ) ) {
14
+ /**
15
+ * Admin class.
16
+ * The class manage all the Frontend behaviors.
17
+ *
18
+ * @since 1.0.0
19
+ */
20
+ class YITH_WCAS_Frontend {
21
+
22
+ /**
23
+ * Constructor
24
+ *
25
+ * @access public
26
+ * @since 1.0.0
27
+ */
28
+ public function __construct( ) {
29
+
30
+ // custom styles and javascript.
31
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
32
+ }
33
+
34
+ /**
35
+ * Enqueue styles and scripts
36
+ *
37
+ * @access public
38
+ * @return void
39
+ * @since 1.0.0
40
+ */
41
+ public function enqueue_styles_scripts() {
42
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
43
+ wp_register_script( 'yith_autocomplete', YITH_WCAS_URL . 'assets/js/yith-autocomplete' . $suffix . '.js', array( 'jquery' ), '1.2.7', true );
44
+ wp_register_script( 'yith_wcas_jquery-autocomplete', YITH_WCAS_URL . 'assets/js/devbridge-jquery-autocomplete' . $suffix . '.js', array( 'jquery' ), '1.2.7', true );
45
+
46
+ wp_register_script( 'yith_wcas_frontend', YITH_WCAS_URL . 'assets/js/frontend' . $suffix . '.js', array( 'jquery' ), '1.0', true );
47
+
48
+ $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_ajax_search.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_ajax_search.css' : YITH_WCAS_URL . 'assets/css/yith_wcas_ajax_search.css';
49
+ wp_enqueue_style( 'yith_wcas_frontend', $css, array(), YITH_WCAS_VERSION );
50
+
51
+ wp_localize_script(
52
+ 'yith_wcas_frontend',
53
+ 'yith_wcas_params',
54
+ array(
55
+ 'loading' => YITH_WCAS_ASSETS_IMAGES_URL . 'ajax-loader.gif',
56
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
57
+
58
+ )
59
+ );
60
+
61
+ wp_enqueue_script( 'yith_autocomplete' );
62
+
63
+ }
64
+ }
65
+ }
class.yith-wcas.php ADDED
@@ -0,0 +1,227 @@
1
+ <?php
2
+ /**
3
+ * Main class
4
+ *
5
+ * @author YITH
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.1.1
8
+ */
9
+
10
+ if ( ! defined( 'YITH_WCAS' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+
14
+ if ( ! class_exists( 'YITH_WCAS' ) ) {
15
+ /**
16
+ * YITH WooCommerce Ajax Search
17
+ *
18
+ * @since 1.0.0
19
+ */
20
+ class YITH_WCAS {
21
+
22
+ /**
23
+ * Plugin object
24
+ *
25
+ * @var string
26
+ * @since 1.0.0
27
+ */
28
+ public $obj = null;
29
+
30
+ /**
31
+ * Constructor
32
+ *
33
+ * @return mixed|YITH_WCAS_Admin|YITH_WCAS_Frontend
34
+ * @since 1.0.0
35
+ */
36
+ public function __construct() {
37
+
38
+ $this->obj = false;
39
+
40
+ // Load Plugin Framework.
41
+ if ( ! isset( $_REQUEST['action'] ) || 'yith_ajax_search_products' !== $_REQUEST['action'] ) {
42
+ add_action( 'plugins_loaded', array( $this, 'plugin_fw_loader' ), 15 );
43
+
44
+ if ( is_admin() ) {
45
+ $this->obj = new YITH_WCAS_Admin();
46
+
47
+ } else {
48
+ $this->obj = new YITH_WCAS_Frontend();
49
+ }
50
+ } else {
51
+ if ( class_exists( 'YITH_JetPack' ) ) {
52
+ include_once YJP_DIR . 'plugin-fw/yit-woocommerce-compatibility.php';
53
+ } else {
54
+ include_once YITH_WCAS_DIR . 'plugin-fw/yit-woocommerce-compatibility.php';
55
+ }
56
+ }
57
+
58
+ // actions.
59
+ add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
60
+
61
+ add_action( 'wp_ajax_yith_ajax_search_products', array( $this, 'ajax_search_products' ) );
62
+ add_action( 'wp_ajax_nopriv_yith_ajax_search_products', array( $this, 'ajax_search_products' ) );
63
+
64
+ // register shortcode.
65
+ add_shortcode( 'yith_woocommerce_ajax_search', array( $this, 'add_woo_ajax_search_shortcode' ) );
66
+
67
+ if ( defined('ELEMENTOR_VERSION') ) {
68
+ require_once( YITH_WCAS_DIR . 'compatibility/elementor/class.yith-wcas-elementor.php');
69
+ }
70
+
71
+ return $this->obj;
72
+ }
73
+
74
+
75
+ /**
76
+ * Load Plugin Framework
77
+ *
78
+ * @since 1.0
79
+ * @access public
80
+ * @return void
81
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
82
+ */
83
+ public function plugin_fw_loader() {
84
+ if ( ! defined( 'YIT_CORE_PLUGIN' ) ) {
85
+ global $plugin_fw_data;
86
+ if ( ! empty( $plugin_fw_data ) ) {
87
+ $plugin_fw_file = array_shift( $plugin_fw_data );
88
+ require_once $plugin_fw_file;
89
+ }
90
+ }
91
+ }
92
+
93
+
94
+
95
+ /**
96
+ * Load template for [yith_woocommerce_ajax_search] shortcode
97
+ *
98
+ * @access public
99
+ *
100
+ * @param array $args Array of arguments.
101
+ *
102
+ * @return mixed
103
+ * @since 1.0.0
104
+ */
105
+ public function add_woo_ajax_search_shortcode( $args = array() ) {
106
+ $args = shortcode_atts( array(), $args );
107
+ // for WC 3.6.0.
108
+ unset( $args['template'] );
109
+
110
+ ob_start();
111
+ $wc_get_template = function_exists( 'wc_get_template' ) ? 'wc_get_template' : 'woocommerce_get_template';
112
+ $wc_get_template( 'yith-woocommerce-ajax-search.php', $args, '', YITH_WCAS_DIR . 'templates/' );
113
+ return ob_get_clean();
114
+ }
115
+
116
+ /**
117
+ * Load and register widgets
118
+ *
119
+ * @access public
120
+ * @since 1.0.0
121
+ */
122
+ public function registerWidgets() {
123
+ register_widget( 'YITH_WCAS_Ajax_Search_Widget' );
124
+ }
125
+
126
+
127
+ /**
128
+ * Perform ajax search products
129
+ */
130
+ public function ajax_search_products() {
131
+ global $woocommerce;
132
+ $time_start = getmicrotime();
133
+ $transient_enabled = get_option( 'yith_wcas_enable_transient', 'no' );
134
+ $transient_duration = get_option( 'yith_wcas_transient_duration', 12 );
135
+
136
+ $search_keyword = sanitize_text_field( wp_unslash( $_REQUEST['query'] ) );
137
+
138
+ $ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
139
+ $suggestions = array();
140
+
141
+ $transient_name = 'ywcas_' . $search_keyword;
142
+ $suggestions = get_transient( $transient_name );
143
+ if ( 'no' === $transient_enabled || false === $suggestions ) {
144
+ $args = array(
145
+ 's' => apply_filters( 'yith_wcas_ajax_search_products_search_query', $search_keyword ),
146
+ 'post_type' => 'product',
147
+ 'post_status' => 'publish',
148
+ 'ignore_sticky_posts' => 1,
149
+ 'orderby' => $ordering_args['orderby'],
150
+ 'order' => $ordering_args['order'],
151
+ 'posts_per_page' => apply_filters( 'yith_wcas_ajax_search_products_posts_per_page', get_option( 'yith_wcas_posts_per_page' ) ),
152
+ 'suppress_filters' => false,
153
+ );
154
+
155
+ if ( isset( $_REQUEST['product_cat'] ) ) {
156
+ $args['tax_query'] = array(
157
+ 'relation' => 'AND',
158
+ array(
159
+ 'taxonomy' => 'product_cat',
160
+ 'field' => 'slug',
161
+ 'terms' => sanitize_text_field( wp_unslash( $_REQUEST['product_cat'] ) ),
162
+ ),
163
+ );
164
+ }
165
+
166
+ if ( version_compare( WC()->version, '2.7.0', '<' ) ) {
167
+ $args['meta_query'] = array(
168
+ array(
169
+ 'key' => '_visibility',
170
+ 'value' => array( 'search', 'visible' ),
171
+ 'compare' => 'IN',
172
+ ),
173
+ );
174
+ } else {
175
+ $product_visibility_term_ids = wc_get_product_visibility_term_ids();
176
+ $args['tax_query'][] = array(
177
+ 'taxonomy' => 'product_visibility',
178
+ 'field' => 'term_taxonomy_id',
179
+ 'terms' => $product_visibility_term_ids['exclude-from-search'],
180
+ 'operator' => 'NOT IN',
181
+ );
182
+ }
183
+
184
+ $products = get_posts( $args );
185
+
186
+ if ( ! empty( $products ) ) {
187
+ foreach ( $products as $post ) {
188
+ $product = wc_get_product( $post );
189
+
190
+ $suggestions[] = apply_filters(
191
+ 'yith_wcas_suggestion',
192
+ array(
193
+ 'id' => $product->get_id(),
194
+ 'value' => wp_strip_all_tags( $product->get_title() ),
195
+ 'url' => $product->get_permalink(),
196
+ ),
197
+ $product
198
+ );
199
+ }
200
+ } else {
201
+ $suggestions[] = array(
202
+ 'id' => - 1,
203
+ 'value' => __( 'No results', 'yith-woocommerce-ajax-search' ),
204
+ 'url' => '',
205
+ );
206
+ }
207
+ wp_reset_postdata();
208
+
209
+ if ( 'yes' === $transient_enabled ) {
210
+ set_transient( $transient_name, $suggestions, $transient_duration * HOUR_IN_SECONDS );
211
+ }
212
+ }
213
+
214
+ $time_end = getmicrotime();
215
+ $time = $time_end - $time_start;
216
+ $suggestions = array(
217
+ 'suggestions' => $suggestions,
218
+ 'time' => $time,
219
+ );
220
+ echo wp_json_encode( $suggestions );
221
+ die();
222
+
223
+ }
224
+
225
+
226
+ }
227
+ }
compatibility/elementor/class.yith-wcas-elementor.php ADDED
@@ -0,0 +1,85 @@
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ *
10
+ * @package YITH WooCommerce Ajax Search Premium
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) || ! defined( 'YITH_WCAS_VERSION' ) ) {
14
+ exit; // Exit if accessed directly.
15
+ }
16
+
17
+ /**
18
+ * Implements the YITH_WCAS_Elementor class.
19
+ *
20
+ * @class YITH_WCAS_Elementor
21
+ * @package YITH
22
+ * @since 1.3.6
23
+ * @author YITH
24
+ */
25
+ if ( ! class_exists( 'YITH_WCAS_Elementor' ) ) {
26
+
27
+ /**
28
+ * Class YITH_WCAS_Elementor
29
+ */
30
+ class YITH_WCAS_Elementor {
31
+ /**
32
+ * Single instance of the class
33
+ *
34
+ * @var YITH_WCAS_Elementor
35
+ */
36
+
37
+ protected static $instance;
38
+
39
+ /**
40
+ * Returns single instance of the class
41
+ *
42
+ * @return YITH_WCAS_Elementor
43
+ */
44
+ public static function get_instance() {
45
+ if ( is_null( self::$instance ) ) {
46
+ self::$instance = new self();
47
+ }
48
+ return self::$instance;
49
+ }
50
+
51
+ /**
52
+ * YITH_WCAS_Elementor constructor.
53
+ */
54
+ public function __construct() {
55
+ if ( did_action( 'elementor/loaded' ) ) {
56
+ add_action( 'elementor/widgets/widgets_registered', array( $this, 'elementor_init_widgets' ) );
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Init widget
62
+ *
63
+ * @throws Exception To return Error.
64
+ */
65
+ public function elementor_init_widgets() {
66
+ // Include Widget files.
67
+ require_once YITH_WCAS_DIR . 'compatibility/elementor/class.yith-wcas-search-form-elementor.php';
68
+
69
+ // Register widget.
70
+ \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \YITH_WCAS_Search_Form_Elementor_Widget() );
71
+ }
72
+ }
73
+
74
+ }
75
+
76
+ /**
77
+ * Unique access to instance of YITH_WCAS_Elementor class
78
+ *
79
+ * @return YITH_WCAS_Elementor
80
+ */
81
+ function YITH_WCAS_Elementor() {
82
+ return YITH_WCAS_Elementor::get_instance();
83
+ }
84
+
85
+ YITH_WCAS_Elementor();
compatibility/elementor/class.yith-wcas-search-form-elementor.php ADDED
@@ -0,0 +1,115 @@
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ *
10
+ * @package YITH WooCommerce Ajax Search Premium
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) || ! defined( 'YITH_WCAS_VERSION' ) ) {
14
+ exit; // Exit if accessed directly.
15
+ }
16
+
17
+ use Elementor\Controls_Manager;
18
+
19
+ /**
20
+ * Class YITH_WCAS_Search_Form_Elementor_Widget
21
+ */
22
+ class YITH_WCAS_Search_Form_Elementor_Widget extends \Elementor\Widget_Base {
23
+
24
+
25
+ /**
26
+ * Return the name of widget.
27
+ *
28
+ * @return string
29
+ */
30
+ public function get_name() {
31
+ return 'yith-wcas-search-form';
32
+ }
33
+
34
+ /**
35
+ * Return the title.
36
+ *
37
+ * @return string|void
38
+ */
39
+ public function get_title() {
40
+ return __( 'YITH WooCommerce Ajax Search', 'yith-woocommerce-ajax-search' );
41
+ }
42
+
43
+ /**
44
+ * Return the icon.
45
+ *
46
+ * @return string
47
+ */
48
+ public function get_icon() {
49
+ return 'eicon-search';
50
+ }
51
+
52
+ /**
53
+ * Return the categories.
54
+ *
55
+ * @return array
56
+ */
57
+ public function get_categories() {
58
+ return array( 'yith', 'general' );
59
+ }
60
+
61
+ /**
62
+ * Return the keywords.
63
+ *
64
+ * @return array
65
+ */
66
+ public function get_keywords() {
67
+ return array( 'woocommerce', 'shop', 'store', 'search', 'ajax', 'yith' );
68
+ }
69
+
70
+ /**
71
+ * Register controls
72
+ */
73
+ protected function _register_controls() {
74
+ $this->start_controls_section(
75
+ 'section_button',
76
+ array(
77
+ 'label' => __( 'YITH WooCommerce Ajax Search', 'yith-woocommerce-ajax-search' ),
78
+ )
79
+ );
80
+
81
+ $this->add_control(
82
+ 'wc_style_warning',
83
+ array(
84
+ 'type' => Controls_Manager::RAW_HTML,
85
+ 'raw' => sprintf(
86
+ '%s [<a href="%s">%s</a>].',
87
+ __( 'This widget inherits the style from the settings of YITH WooCommerce Ajax Search plugin that you can edit', 'yith-woocommerce-ajax-search' ),
88
+ get_admin_url( null, 'admin.php?page=yith_wcas_panel&tab=output' ),
89
+ __( 'here', 'yith-woocommerce-ajax-search' )
90
+ ),
91
+ 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
92
+ )
93
+ );
94
+
95
+
96
+
97
+ $this->end_controls_section();
98
+
99
+ }
100
+
101
+ /**
102
+ * Render the form
103
+ */
104
+ protected function render() {
105
+
106
+ $settings = $this->get_settings_for_display();
107
+
108
+ $shortcode = do_shortcode( '[yith_woocommerce_ajax_search]' );
109
+ ?>
110
+ <div class="elementor-shortcode"><?php echo $shortcode; //phpcs:ignore ?></div>
111
+ <?php
112
+
113
+ }
114
+
115
+ }
functions.yith-wcas.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+ /**
3
+ * Functions
4
+ *
5
+ * @author YITH
6
+ * @package YITH WooCommerce Ajax Search
7
+ * @version 1.1.1
8
+ */
9
+
10
+ if ( ! defined( 'YITH_WCAS' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+
14
+ /**
15
+ * Get microtime.
16
+ *
17
+ * @return float
18
+ */
19
+ function getmicrotime() {
20
+ list( $usec, $sec ) = explode( ' ', microtime() );
21
+
22
+ return ( (float) $usec + (float) $sec );
23
+ }
init.php CHANGED
@@ -3,13 +3,13 @@
3
* Plugin Name: YITH WooCommerce Ajax Search
4
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/
5
* Description: <code><strong>YITH WooCommerce Ajax Search</strong></code> is the plugin that allows you to search for a specific product by inserting a few characters. Thanks to <strong>Ajax Search</strong>, users can quickly find the contents they are interested in without wasting time among site pages. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
- * Version: 1.7.8
7
* Author: YITH
8
* Author URI: https://yithemes.com/
9
* Text Domain: yith-woocommerce-ajax-search
10
* Domain Path: /languages/
11
* WC requires at least: 3.0.0
12
- * WC tested up to: 4.1.0
13
*/
14
15
/*
@@ -71,7 +71,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
71
if ( defined( 'YITH_WCAS_VERSION' ) ) {
72
return;
73
} else {
74
- define( 'YITH_WCAS_VERSION', '1.7.8' );
75
}
76
77
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
3
* Plugin Name: YITH WooCommerce Ajax Search
4
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/
5
* Description: <code><strong>YITH WooCommerce Ajax Search</strong></code> is the plugin that allows you to search for a specific product by inserting a few characters. Thanks to <strong>Ajax Search</strong>, users can quickly find the contents they are interested in without wasting time among site pages. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
+ * Version: 1.7.9
7
* Author: YITH
8
* Author URI: https://yithemes.com/
9
* Text Domain: yith-woocommerce-ajax-search
10
* Domain Path: /languages/
11
* WC requires at least: 3.0.0
12
+ * WC tested up to: 4.2.0
13
*/
14
15
/*
71
if ( defined( 'YITH_WCAS_VERSION' ) ) {
72
return;
73
} else {
74
+ define( 'YITH_WCAS_VERSION', '1.7.9' );
75
}
76
77
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
languages/yith-woocommerce-ajax-search-it_IT.mo CHANGED
File without changes
languages/yith-woocommerce-ajax-search-it_IT.po CHANGED
File without changes
languages/yith-woocommerce-ajax-search-pt_PT.mo CHANGED
File without changes
languages/yith-woocommerce-ajax-search-pt_PT.po CHANGED
File without changes
languages/yith-woocommerce-ajax-search.pot CHANGED
File without changes
plugin-fw/.jshintrc CHANGED
File without changes
plugin-fw/Gruntfile.js CHANGED
File without changes
plugin-fw/assets/css/codemirror/codemirror.css CHANGED
File without changes
plugin-fw/assets/css/colorbox.css CHANGED
File without changes
plugin-fw/assets/css/metaboxes.css CHANGED
File without changes
plugin-fw/assets/css/yit-plugin-panel.css CHANGED
File without changes
plugin-fw/assets/css/yit-upgrade-to-pro.css CHANGED
File without changes
plugin-fw/assets/css/yit-upgrader.css CHANGED
File without changes
plugin-fw/assets/fonts/yith-icon.eot CHANGED
File without changes
plugin-fw/assets/fonts/yith-icon.svg CHANGED
File without changes
plugin-fw/assets/fonts/yith-icon.ttf CHANGED
File without changes
plugin-fw/assets/fonts/yith-icon.woff CHANGED
File without changes
plugin-fw/assets/images/arrow_down.svg CHANGED
File without changes
plugin-fw/assets/images/banner-premium.png CHANGED
File without changes
plugin-fw/assets/images/colorbox/border1.png CHANGED
File without changes
plugin-fw/assets/images/colorbox/border2.png CHANGED
File without changes
plugin-fw/assets/images/colorbox/loading.gif CHANGED
File without changes
plugin-fw/assets/images/double-sidebar.png CHANGED
File without changes
plugin-fw/assets/images/licence-error.png CHANGED
File without changes
plugin-fw/assets/images/no-sidebar.png CHANGED
File without changes
plugin-fw/assets/images/sidebar-left.png CHANGED
File without changes
plugin-fw/assets/images/sidebar-right.png CHANGED
File without changes
plugin-fw/assets/images/sleep.png CHANGED
File without changes
plugin-fw/assets/images/spinner.png CHANGED
File without changes
plugin-fw/assets/images/ui-icons_222222_256x240.png CHANGED
File without changes
plugin-fw/assets/images/ui-icons_2e83ff_256x240.png CHANGED
File without changes
plugin-fw/assets/images/ui-icons_454545_256x240.png CHANGED
File without changes
plugin-fw/assets/images/ui-icons_888888_256x240.png CHANGED
File without changes
plugin-fw/assets/images/x.png CHANGED
File without changes
plugin-fw/assets/images/yith-icon.svg CHANGED
File without changes
plugin-fw/assets/images/yithemes-icon.png CHANGED
File without changes
plugin-fw/assets/js/codemirror/codemirror.js CHANGED
File without changes
plugin-fw/assets/js/codemirror/javascript.js CHANGED
File without changes
plugin-fw/assets/js/how-to.js CHANGED
File without changes
plugin-fw/assets/js/javascript-md5/md5.min.js CHANGED
File without changes
plugin-fw/assets/js/jquery.colorbox.js CHANGED
File without changes
plugin-fw/assets/js/metabox.js CHANGED
File without changes
plugin-fw/assets/js/metabox.min.js CHANGED
File without changes
plugin-fw/assets/js/multisite-updater.js CHANGED
File without changes
plugin-fw/assets/js/multisite-updater.min.js CHANGED
File without changes
plugin-fw/assets/js/wp-pages.js CHANGED
File without changes
plugin-fw/assets/js/wp-pages.min.js CHANGED
File without changes
plugin-fw/assets/js/yit-cpt-unlimited.js CHANGED
File without changes
plugin-fw/assets/js/yit-cpt-unlimited.min.js CHANGED
File without changes
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,"\\amp;").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,"\\amp;").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/yit-wp-pointer.js CHANGED
File without changes
plugin-fw/assets/js/yit-wp-pointer.min.js CHANGED
File without changes
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}#x2F;)||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}#x2F;)||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-dashboard.js CHANGED
File without changes
plugin-fw/assets/js/yith-dashboard.min.js CHANGED
File without changes
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#x2F;, '' );
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#x2F;, '' ),
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#x2F;, '' );
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#x2F;, '' ),
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
+