YITH WooCommerce Compare - Version 1.0.2

Version Description

  • Improved: trigger in javascript file for add to compare event
Download this release

Release Info

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

Code changes from version 1.0.1 to 1.0.2

README.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
4
Tags: woocommerce, compare, compare products, product compare, widget
5
Requires at least: 3.5.1
6
Tested up to: 3.5.1
7
- Stable tag: 1.0.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -79,6 +79,10 @@ Yes, you can sort the fields in the compare table. You can do it in Woocommerce
79
80
== Changelog ==
81
82
= 1.0.1 =
83
84
* Added: Link/Button text option in plugin options
4
Tags: woocommerce, compare, compare products, product compare, widget
5
Requires at least: 3.5.1
6
Tested up to: 3.5.1
7
+ Stable tag: 1.0.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
79
80
== Changelog ==
81
82
+ = 1.0.2 =
83
+
84
+ * Improved: trigger in javascript file for add to compare event
85
+
86
= 1.0.1 =
87
88
* Added: Link/Button text option in plugin options
assets/js/woocompare-admin.js CHANGED
@@ -1,2 +1,19 @@
1
-
2
- jQuery(document).ready(function($){$(".attributes .fields").sortable({cursor:"move",scrollSensitivity:10,tolerance:"pointer",axis:"y",stop:function(event,ui){var list=ui.item.parents('.fields'),fields=new Array();$('input[type="checkbox"]',list).each(function(i){fields[i]=$(this).val();});list.next().val(fields.join(','));}});});
1
+ jQuery(document).ready(function($) {
2
+
3
+ $( ".attributes .fields" ).sortable({
4
+ cursor: "move",
5
+ scrollSensitivity: 10,
6
+ tolerance: "pointer",
7
+ axis: "y",
8
+ stop: function(event, ui) {
9
+ var list = ui.item.parents('.fields'),
10
+ fields = new Array();
11
+ $('input[type="checkbox"]', list).each(function(i){
12
+ fields[i] = $(this).val();
13
+ });
14
+
15
+ list.next().val( fields.join(',') );
16
+ }
17
+ });
18
+
19
+ });
assets/js/woocompare.js CHANGED
@@ -1,6 +1,190 @@
1
-
2
- jQuery(document).ready(function($){$(document).on('click','.product .compare',function(e){e.preventDefault();var button=$(this),data={_yitnonce_ajax:yith_woocompare.nonceadd,action:yith_woocompare.actionadd,id:button.data('product_id'),context:'frontend'},widget_list=$('.yith-woocompare-widget ul.products-list');button.block({message:null,overlayCSS:{background:'#fff url('+woocommerce_params.ajax_loader_url+') no-repeat center',backgroundSize:'16px 16px',opacity:0.6}});widget_list.block({message:null,overlayCSS:{background:'#fff url('+woocommerce_params.ajax_loader_url+') no-repeat center',backgroundSize:'16px 16px',opacity:0.6}});$.ajax({type:'post',url:yith_woocompare.ajaxurl,data:data,dataType:'json',success:function(response){button.unblock().addClass('added').text(yith_woocompare.added_label);widget_list.unblock().html(response.widget_table);if(yith_woocompare.auto_open=='yes')$('body').trigger('yith_woocompare_open_popup',{response:response.table_url});}});});$('body').on('yith_woocompare_open_popup',function(e,data){var response=data.response;if($(window).width()>=768){$.colorbox({href:response,iframe:true,width:'90%',height:'90%',onClosed:function(){var widget_list=$('.yith-woocompare-widget ul.products-list'),data={action:yith_woocompare.actionview,context:'frontend'};widget_list.block({message:null,overlayCSS:{background:'#fff url('+woocommerce_params.ajax_loader_url+') no-repeat center',backgroundSize:'16px 16px',opacity:0.6}});$.ajax({type:'post',url:yith_woocompare.ajaxurl,data:data,success:function(response){widget_list.unblock().html(response);}});}});$(window).resize(function(){$.colorbox.resize({width:'90%',height:'90%'});});}else{var urlparts=response.split('?');var parameter='iframe';if(urlparts.length>=2){var prefix=encodeURIComponent(parameter)+'=';var pars=urlparts[1].split(/[&;]/g);for(var i=pars.length;i-->0;)
3
- if(pars[i].lastIndexOf(prefix,0)!==-1)
4
- pars.splice(i,1);response=urlparts[0]+'?'+pars.join('&');}
5
- window.open(response,yith_woocompare.table_title);}});$(document).on('click','.remove a',function(e){e.preventDefault();var button=$(this),data={_yitnonce_ajax:yith_woocompare.nonceremove,action:yith_woocompare.actionremove,id:button.data('product_id'),context:'frontend'},product_cell=$('td.product_'+data.id+', th.product_'+data.id);button.block({message:null,overlayCSS:{background:'#fff url('+woocommerce_params.ajax_loader_url+') no-repeat center',backgroundSize:'16px 16px',opacity:0.6}});$.ajax({type:'post',url:yith_woocompare.ajaxurl,data:data,dataType:'html',success:function(response){button.unblock();var table=$(response).filter('table.compare-list');$('body > table.compare-list').replaceWith(table);$(window).trigger('yith_woocompare_product_removed');}});});$('.yith-woocompare-open a, a.yith-woocompare-open').on('click',function(e){e.preventDefault();$('body').trigger('yith_woocompare_open_popup',{response:yith_add_query_arg('action',yith_woocompare.actionview)+'&iframe=true'});});$('.yith-woocompare-widget').on('click','a.compare',function(e){e.preventDefault();$('body').trigger('yith_woocompare_open_popup',{response:$(this).attr('href')});}).on('click','li a.remove, a.clear-all',function(e){e.preventDefault();var button=$(this),data={_yitnonce_ajax:yith_woocompare.nonceremove,action:yith_woocompare.actionremove,id:button.data('product_id'),context:'frontend',responseType:'product_list'},product_list=button.parents('.yith-woocompare-widget').find('ul.products-list');product_list.block({message:null,overlayCSS:{background:'#fff url('+woocommerce_params.ajax_loader_url+') no-repeat center',backgroundSize:'16px 16px',opacity:0.6}});$.ajax({type:'post',url:yith_woocompare.ajaxurl,data:data,dataType:'html',success:function(response){product_list.html(response);product_list.unblock();}});});function yith_add_query_arg(key,value)
6
- {key=escape(key);value=escape(value);var s=document.location.search;var kvp=key+"="+value;var r=new RegExp("(&|\\?)"+key+"=[^\&]*");s=s.replace(r,"$1"+kvp);if(!RegExp.$1){s+=(s.length>0?'&':'?')+kvp;};return s;}});
1
+ jQuery(document).ready(function($) {
2
+
3
+ // add into table
4
+ $(document).on( 'click', '.product a.compare', function(e){
5
+ e.preventDefault();
6
+
7
+ var button = $(this),
8
+ data = {
9
+ _yitnonce_ajax: yith_woocompare.nonceadd,
10
+ action: yith_woocompare.actionadd,
11
+ id: button.data('product_id'),
12
+ context: 'frontend'
13
+ },
14
+ widget_list = $('.yith-woocompare-widget ul.products-list');
15
+
16
+ // add ajax loader
17
+ button.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
18
+ widget_list.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
19
+
20
+ $.ajax({
21
+ type: 'post',
22
+ url: yith_woocompare.ajaxurl,
23
+ data: data,
24
+ dataType: 'json',
25
+ success: function(response){
26
+ button.unblock().addClass('added').text( yith_woocompare.added_label );
27
+
28
+ // add the product in the widget
29
+ widget_list.unblock().html( response.widget_table );
30
+
31
+ if (yith_woocompare.auto_open == 'yes') $('body').trigger( 'yith_woocompare_open_popup', { response: response.table_url, button: button } );
32
+ }
33
+ });
34
+ });
35
+
36
+ // open popup
37
+ $('body').on( 'yith_woocompare_open_popup', function( e, data ) {
38
+ var response = data.response;
39
+
40
+ if ($(window).width() >= 768) {
41
+ $.colorbox({
42
+ href: response,
43
+ iframe: true,
44
+ width: '90%',
45
+ height: '90%',
46
+ onClosed: function(){
47
+ var widget_list = $('.yith-woocompare-widget ul.products-list'),
48
+ data = {
49
+ action: yith_woocompare.actionview,
50
+ context: 'frontend'
51
+ };
52
+
53
+ widget_list.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
54
+
55
+ $.ajax({
56
+ type: 'post',
57
+ url: yith_woocompare.ajaxurl,
58
+ data: data,
59
+ success: function(response){
60
+ // add the product in the widget
61
+ widget_list.unblock().html( response );
62
+ }
63
+ });
64
+ }
65
+ });
66
+
67
+ $(window).resize(function () {
68
+ $.colorbox.resize({
69
+ width: '90%',
70
+ height: '90%'
71
+ });
72
+ });
73
+
74
+ } else {
75
+ var urlparts = response.split('?');
76
+ var parameter = 'iframe';
77
+ if (urlparts.length >= 2) {
78
+ var prefix = encodeURIComponent(parameter) + '=';
79
+ var pars = urlparts[1].split(/[&;]/g);
80
+ for (var i = pars.length; i-- > 0;)
81
+ if (pars[i].lastIndexOf(prefix, 0) !== -1)
82
+ pars.splice(i, 1);
83
+ response = urlparts[0] + '?' + pars.join('&');
84
+ }
85
+
86
+ window.open(response, yith_woocompare.table_title);
87
+ }
88
+ });
89
+
90
+ // remove from table
91
+ $(document).on( 'click', '.remove a', function(e){
92
+ e.preventDefault();
93
+
94
+ var button = $(this),
95
+ data = {
96
+ _yitnonce_ajax: yith_woocompare.nonceremove,
97
+ action: yith_woocompare.actionremove,
98
+ id: button.data('product_id'),
99
+ context: 'frontend'
100
+ },
101
+ product_cell = $( 'td.product_' + data.id + ', th.product_' + data.id );
102
+
103
+ // add ajax loader
104
+ button.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
105
+
106
+ $.ajax({
107
+ type: 'post',
108
+ url: yith_woocompare.ajaxurl,
109
+ data: data,
110
+ dataType:'html',
111
+ success: function(response){
112
+ button.unblock();
113
+
114
+ // in compare table
115
+ var table = $(response).filter('table.compare-list');
116
+ $('body > table.compare-list').replaceWith( table );
117
+
118
+ // removed trigger
119
+ $(window).trigger('yith_woocompare_product_removed');
120
+ }
121
+ });
122
+ });
123
+
124
+
125
+ // General link to open the compare table
126
+ $('.yith-woocompare-open a, a.yith-woocompare-open').on('click', function(e){
127
+ e.preventDefault();
128
+ $('body').trigger('yith_woocompare_open_popup', { response: yith_add_query_arg('action', yith_woocompare.actionview) + '&iframe=true' });
129
+ });
130
+
131
+
132
+
133
+ // ##### WIDGET ######
134
+
135
+ $('.yith-woocompare-widget')
136
+
137
+ // view table (click on compare
138
+ .on('click', 'a.compare', function (e) {
139
+ e.preventDefault();
140
+ $('body').trigger('yith_woocompare_open_popup', { response: $(this).attr('href') });
141
+ })
142
+
143
+ // remove product & clear all
144
+ .on('click', 'li a.remove, a.clear-all', function (e) {
145
+ e.preventDefault();
146
+
147
+ var button = $(this),
148
+ data = {
149
+ _yitnonce_ajax: yith_woocompare.nonceremove,
150
+ action: yith_woocompare.actionremove,
151
+ id: button.data('product_id'),
152
+ context: 'frontend',
153
+ responseType: 'product_list'
154
+ },
155
+ product_list = button.parents('.yith-woocompare-widget').find('ul.products-list');
156
+
157
+ // add ajax loader
158
+ product_list.block({message: null, overlayCSS: {background: '#fff url(' + woocommerce_params.ajax_loader_url + ') no-repeat center', backgroundSize: '16px 16px', opacity: 0.6}});
159
+
160
+ $.ajax({
161
+ type: 'post',
162
+ url: yith_woocompare.ajaxurl,
163
+ data: data,
164
+ dataType: 'html',
165
+ success: function (response) {
166
+ product_list.html(response);
167
+ product_list.unblock();
168
+ }
169
+ });
170
+ });
171
+
172
+
173
+ function yith_add_query_arg(key, value)
174
+ {
175
+ key = escape(key); value = escape(value);
176
+
177
+ var s = document.location.search;
178
+ var kvp = key+"="+value;
179
+
180
+ var r = new RegExp("(&|\\?)"+key+"=[^\&]*");
181
+
182
+ s = s.replace(r,"$1"+kvp);
183
+
184
+ if(!RegExp.$1) {s += (s.length>0 ? '&' : '?') + kvp;};
185
+
186
+ //again, do what you will here
187
+ return s;
188
+ }
189
+
190
+ });
class.yith-woocompare-admin.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH WooCommerce Magnifier
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH WooCommerce Magnifier
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
class.yith-woocompare-frontend.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
class.yith-woocompare-helper.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH WooCommerce Compare
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH WooCommerce Compare
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
class.yith-woocompare.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
functions.yith-woocompare.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
init.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: YITH Woocommerce Compare
4
* Plugin URI: http://yithemes.com/
5
* Description: YITH Woocommerce Compare allows you to compare more products with woocommerce plugin, through product attributes.
6
- * Version: 1.0.1
7
* Author: Your Inspiration Themes
8
* Author URI: http://yithemes.com/
9
* Text Domain: yit
@@ -11,7 +11,7 @@
11
*
12
* @author Your Inspiration Themes
13
* @package YITH Woocommerce Compare
14
- * @version 1.0.1
15
*/
16
/* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
17
@@ -44,7 +44,7 @@ function yith_woocompare_constructor() {
44
load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
45
46
define( 'YITH_WOOCOMPARE', true );
47
- define( 'YITH_WOOCOMPARE_VERSION', '1.0.1' );
48
define( 'YITH_WOOCOMPARE_URL', plugin_dir_url( __FILE__ ) );
49
define( 'YITH_WOOCOMPARE_DIR', plugin_dir_path( __FILE__ ) );
50
3
* Plugin Name: YITH Woocommerce Compare
4
* Plugin URI: http://yithemes.com/
5
* Description: YITH Woocommerce Compare allows you to compare more products with woocommerce plugin, through product attributes.
6
+ * Version: 1.0.2
7
* Author: Your Inspiration Themes
8
* Author URI: http://yithemes.com/
9
* Text Domain: yit
11
*
12
* @author Your Inspiration Themes
13
* @package YITH Woocommerce Compare
14
+ * @version 1.0.2
15
*/
16
/* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
17
44
load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
45
46
define( 'YITH_WOOCOMPARE', true );
47
+ define( 'YITH_WOOCOMPARE_VERSION', '1.0.2' );
48
define( 'YITH_WOOCOMPARE_URL', plugin_dir_url( __FILE__ ) );
49
define( 'YITH_WOOCOMPARE_DIR', plugin_dir_path( __FILE__ ) );
50
templates/compare.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
- * @version 1.0.1
8
*/
9
10
global $product;
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
+ * @version 1.0.2
8
*/
9
10
global $product;
widgets/class.yith-woocompare-widget.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
yit-common/yit-functions.php CHANGED
@@ -205,4 +205,27 @@ if( !function_exists('yit_typo_option_to_css') ) {
205
206
return implode( "\n", $attrs ) . "\n";
207
}
208
}
205
206
return implode( "\n", $attrs ) . "\n";
207
}
208
+ }
209
+
210
+
211
+ if( !function_exists('yit_curPageURL') ) {
212
+ /**
213
+ * Retrieve the current complete url
214
+ *
215
+ * @since 1.0
216
+ */
217
+ function yit_curPageURL() {
218
+ $pageURL = 'http';
219
+ if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" )
220
+ $pageURL .= "s";
221
+
222
+ $pageURL .= "://";
223
+
224
+ if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" )
225
+ $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
226
+ else
227
+ $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
228
+
229
+ return $pageURL;
230
+ }
231
}
yith-woocompare-options.php CHANGED
@@ -4,7 +4,7 @@
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
- * @version 1.0.1
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly
4
*
5
* @author Your Inspiration Themes
6
* @package YITH Woocommerce Compare
7
+ * @version 1.0.2
8
*/
9
10
if ( !defined( 'YITH_WOOCOMPARE' ) ) { exit; } // Exit if accessed directly