Version Description
Download this release
Release Info
Developer | marsian |
Plugin | TemplatesNext ToolKit |
Version | 3.1.1 |
Comparing to | |
See all releases |
Code changes from version 3.1.0 to 3.1.1
- inc/woo-compare-wishlist/assets/css/grid.css +1 -0
- inc/woo-compare-wishlist/assets/css/tablesaw.css +586 -0
- inc/woo-compare-wishlist/assets/css/tm-woocompare.css +199 -0
- inc/woo-compare-wishlist/assets/css/tm-woowishlist.css +178 -0
- inc/woo-compare-wishlist/assets/js/tablesaw-init.js +5 -0
- inc/woo-compare-wishlist/assets/js/tablesaw-init.min.js +1 -0
- inc/woo-compare-wishlist/assets/js/tablesaw.js +1275 -0
- inc/woo-compare-wishlist/assets/js/tablesaw.min.js +1 -0
- inc/woo-compare-wishlist/assets/js/tm-woocompare.js +240 -0
- inc/woo-compare-wishlist/assets/js/tm-woocompare.min.js +1 -0
- inc/woo-compare-wishlist/assets/js/tm-woowishlist.js +146 -0
- inc/woo-compare-wishlist/assets/js/tm-woowishlist.min.js +1 -0
- inc/woo-compare-wishlist/assets/scss/_clearfix.scss +22 -0
- inc/woo-compare-wishlist/assets/scss/_grid-framework.scss +82 -0
- inc/woo-compare-wishlist/assets/scss/_grid.scss +122 -0
- inc/woo-compare-wishlist/assets/scss/_variables.scss +77 -0
- inc/woo-compare-wishlist/assets/scss/grid.scss +74 -0
- inc/woo-compare-wishlist/assets/scss/tm-woocompare.scss +117 -0
- inc/woo-compare-wishlist/assets/scss/tm-woowishlist.scss +93 -0
- inc/woo-compare-wishlist/includes/compare/buttons.php +94 -0
- inc/woo-compare-wishlist/includes/compare/compare.php +615 -0
- inc/woo-compare-wishlist/includes/compare/settings.php +176 -0
- inc/woo-compare-wishlist/includes/compare/shortcode.php +18 -0
- inc/woo-compare-wishlist/includes/compare/widget.php +79 -0
- inc/woo-compare-wishlist/includes/install.php +153 -0
- inc/woo-compare-wishlist/includes/template-callbacks.php +183 -0
- inc/woo-compare-wishlist/includes/templater.php +269 -0
- inc/woo-compare-wishlist/includes/wishlist/buttons.php +99 -0
- inc/woo-compare-wishlist/includes/wishlist/settings.php +185 -0
- inc/woo-compare-wishlist/includes/wishlist/shortcode.php +18 -0
- inc/woo-compare-wishlist/includes/wishlist/widget.php +77 -0
- inc/woo-compare-wishlist/includes/wishlist/wishlist.php +491 -0
- inc/woo-compare-wishlist/templates/shortcodes/tm-woocompare/page.tmpl +5 -0
- inc/woo-compare-wishlist/templates/shortcodes/tm-woocompare/widget.tmpl +2 -0
- inc/woo-compare-wishlist/templates/shortcodes/tm-woowishlist/page.tmpl +5 -0
- inc/woo-compare-wishlist/templates/shortcodes/tm-woowishlist/widget.tmpl +4 -0
- inc/woo-compare-wishlist/uninstall.php +51 -0
- inc/woo-compare-wishlist/woo-compare-wishlist.php +250 -0
- inc/woo-compare-wishlist/wpml-config.xml +15 -0
- js/tx-script.js +1 -1
- readme.txt +1 -1
- tx-functions.php +1 -3
- tx-toolkit.php +16 -3
inc/woo-compare-wishlist/assets/css/grid.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
.container-fluid{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}.container-fluid:before,.container-fluid:after{content:" ";display:table}.container-fluid:after{clear:both}.row{margin-left:-15px;margin-right:-15px}.row:before,.row:after{content:" ";display:table}.row:after{clear:both}.tx_banners_grid_widget_banner{margin-bottom:30px}.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px;box-sizing:border-box}.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{float:left}.col-xs-1{width:8.33333%}.col-xs-2{width:16.66667%}.col-xs-3{width:25%}.col-xs-4{width:33.33333%}.col-xs-5{width:41.66667%}.col-xs-6{width:50%}.col-xs-7{width:58.33333%}.col-xs-8{width:66.66667%}.col-xs-9{width:75%}.col-xs-10{width:83.33333%}.col-xs-11{width:91.66667%}.col-xs-12{width:100%}.col-xs-pull-0{right:auto}.col-xs-pull-1{right:8.33333%}.col-xs-pull-2{right:16.66667%}.col-xs-pull-3{right:25%}.col-xs-pull-4{right:33.33333%}.col-xs-pull-5{right:41.66667%}.col-xs-pull-6{right:50%}.col-xs-pull-7{right:58.33333%}.col-xs-pull-8{right:66.66667%}.col-xs-pull-9{right:75%}.col-xs-pull-10{right:83.33333%}.col-xs-pull-11{right:91.66667%}.col-xs-pull-12{right:100%}.col-xs-push-0{left:auto}.col-xs-push-1{left:8.33333%}.col-xs-push-2{left:16.66667%}.col-xs-push-3{left:25%}.col-xs-push-4{left:33.33333%}.col-xs-push-5{left:41.66667%}.col-xs-push-6{left:50%}.col-xs-push-7{left:58.33333%}.col-xs-push-8{left:66.66667%}.col-xs-push-9{left:75%}.col-xs-push-10{left:83.33333%}.col-xs-push-11{left:91.66667%}.col-xs-push-12{left:100%}.col-xs-offset-0{margin-left:0%}.col-xs-offset-1{margin-left:8.33333%}.col-xs-offset-2{margin-left:16.66667%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-4{margin-left:33.33333%}.col-xs-offset-5{margin-left:41.66667%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-7{margin-left:58.33333%}.col-xs-offset-8{margin-left:66.66667%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-10{margin-left:83.33333%}.col-xs-offset-11{margin-left:91.66667%}.col-xs-offset-12{margin-left:100%}@media (min-width: 768px){.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12{float:left}.col-sm-1{width:8.33333%}.col-sm-2{width:16.66667%}.col-sm-3{width:25%}.col-sm-4{width:33.33333%}.col-sm-5{width:41.66667%}.col-sm-6{width:50%}.col-sm-7{width:58.33333%}.col-sm-8{width:66.66667%}.col-sm-9{width:75%}.col-sm-10{width:83.33333%}.col-sm-11{width:91.66667%}.col-sm-12{width:100%}.col-sm-pull-0{right:auto}.col-sm-pull-1{right:8.33333%}.col-sm-pull-2{right:16.66667%}.col-sm-pull-3{right:25%}.col-sm-pull-4{right:33.33333%}.col-sm-pull-5{right:41.66667%}.col-sm-pull-6{right:50%}.col-sm-pull-7{right:58.33333%}.col-sm-pull-8{right:66.66667%}.col-sm-pull-9{right:75%}.col-sm-pull-10{right:83.33333%}.col-sm-pull-11{right:91.66667%}.col-sm-pull-12{right:100%}.col-sm-push-0{left:auto}.col-sm-push-1{left:8.33333%}.col-sm-push-2{left:16.66667%}.col-sm-push-3{left:25%}.col-sm-push-4{left:33.33333%}.col-sm-push-5{left:41.66667%}.col-sm-push-6{left:50%}.col-sm-push-7{left:58.33333%}.col-sm-push-8{left:66.66667%}.col-sm-push-9{left:75%}.col-sm-push-10{left:83.33333%}.col-sm-push-11{left:91.66667%}.col-sm-push-12{left:100%}.col-sm-offset-0{margin-left:0%}.col-sm-offset-1{margin-left:8.33333%}.col-sm-offset-2{margin-left:16.66667%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-4{margin-left:33.33333%}.col-sm-offset-5{margin-left:41.66667%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-7{margin-left:58.33333%}.col-sm-offset-8{margin-left:66.66667%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-10{margin-left:83.33333%}.col-sm-offset-11{margin-left:91.66667%}.col-sm-offset-12{margin-left:100%}}@media (min-width: 992px){.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12{float:left}.col-md-1{width:8.33333%}.col-md-2{width:16.66667%}.col-md-3{width:25%}.col-md-4{width:33.33333%}.col-md-5{width:41.66667%}.col-md-6{width:50%}.col-md-7{width:58.33333%}.col-md-8{width:66.66667%}.col-md-9{width:75%}.col-md-10{width:83.33333%}.col-md-11{width:91.66667%}.col-md-12{width:100%}.col-md-pull-0{right:auto}.col-md-pull-1{right:8.33333%}.col-md-pull-2{right:16.66667%}.col-md-pull-3{right:25%}.col-md-pull-4{right:33.33333%}.col-md-pull-5{right:41.66667%}.col-md-pull-6{right:50%}.col-md-pull-7{right:58.33333%}.col-md-pull-8{right:66.66667%}.col-md-pull-9{right:75%}.col-md-pull-10{right:83.33333%}.col-md-pull-11{right:91.66667%}.col-md-pull-12{right:100%}.col-md-push-0{left:auto}.col-md-push-1{left:8.33333%}.col-md-push-2{left:16.66667%}.col-md-push-3{left:25%}.col-md-push-4{left:33.33333%}.col-md-push-5{left:41.66667%}.col-md-push-6{left:50%}.col-md-push-7{left:58.33333%}.col-md-push-8{left:66.66667%}.col-md-push-9{left:75%}.col-md-push-10{left:83.33333%}.col-md-push-11{left:91.66667%}.col-md-push-12{left:100%}.col-md-offset-0{margin-left:0%}.col-md-offset-1{margin-left:8.33333%}.col-md-offset-2{margin-left:16.66667%}.col-md-offset-3{margin-left:25%}.col-md-offset-4{margin-left:33.33333%}.col-md-offset-5{margin-left:41.66667%}.col-md-offset-6{margin-left:50%}.col-md-offset-7{margin-left:58.33333%}.col-md-offset-8{margin-left:66.66667%}.col-md-offset-9{margin-left:75%}.col-md-offset-10{margin-left:83.33333%}.col-md-offset-11{margin-left:91.66667%}.col-md-offset-12{margin-left:100%}}@media (min-width: 1200px){.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12{float:left}.col-lg-1{width:8.33333%}.col-lg-2{width:16.66667%}.col-lg-3{width:25%}.col-lg-4{width:33.33333%}.col-lg-5{width:41.66667%}.col-lg-6{width:50%}.col-lg-7{width:58.33333%}.col-lg-8{width:66.66667%}.col-lg-9{width:75%}.col-lg-10{width:83.33333%}.col-lg-11{width:91.66667%}.col-lg-12{width:100%}.col-lg-pull-0{right:auto}.col-lg-pull-1{right:8.33333%}.col-lg-pull-2{right:16.66667%}.col-lg-pull-3{right:25%}.col-lg-pull-4{right:33.33333%}.col-lg-pull-5{right:41.66667%}.col-lg-pull-6{right:50%}.col-lg-pull-7{right:58.33333%}.col-lg-pull-8{right:66.66667%}.col-lg-pull-9{right:75%}.col-lg-pull-10{right:83.33333%}.col-lg-pull-11{right:91.66667%}.col-lg-pull-12{right:100%}.col-lg-push-0{left:auto}.col-lg-push-1{left:8.33333%}.col-lg-push-2{left:16.66667%}.col-lg-push-3{left:25%}.col-lg-push-4{left:33.33333%}.col-lg-push-5{left:41.66667%}.col-lg-push-6{left:50%}.col-lg-push-7{left:58.33333%}.col-lg-push-8{left:66.66667%}.col-lg-push-9{left:75%}.col-lg-push-10{left:83.33333%}.col-lg-push-11{left:91.66667%}.col-lg-push-12{left:100%}.col-lg-offset-0{margin-left:0%}.col-lg-offset-1{margin-left:8.33333%}.col-lg-offset-2{margin-left:16.66667%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-4{margin-left:33.33333%}.col-lg-offset-5{margin-left:41.66667%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-7{margin-left:58.33333%}.col-lg-offset-8{margin-left:66.66667%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-10{margin-left:83.33333%}.col-lg-offset-11{margin-left:91.66667%}.col-lg-offset-12{margin-left:100%}}
|
inc/woo-compare-wishlist/assets/css/tablesaw.css
ADDED
@@ -0,0 +1,586 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! Tablesaw - v2.0.3 - 2016-05-02
|
2 |
+
* https://github.com/filamentgroup/tablesaw
|
3 |
+
* Copyright (c) 2016 Filament Group; Licensed MIT */
|
4 |
+
|
5 |
+
table.tablesaw {
|
6 |
+
empty-cells: show;
|
7 |
+
max-width: 100%;
|
8 |
+
width: 100%;
|
9 |
+
border: none;
|
10 |
+
}
|
11 |
+
|
12 |
+
.tablesaw {
|
13 |
+
border-collapse: collapse;
|
14 |
+
width: 100%;
|
15 |
+
}
|
16 |
+
|
17 |
+
/* Structure */
|
18 |
+
|
19 |
+
.tablesaw {
|
20 |
+
border: 0;
|
21 |
+
padding: 0;
|
22 |
+
}
|
23 |
+
|
24 |
+
.tablesaw th,
|
25 |
+
.tablesaw td {
|
26 |
+
box-sizing: border-box;
|
27 |
+
padding: .5em .7em;
|
28 |
+
border: none !important;
|
29 |
+
text-align: left;
|
30 |
+
vertical-align: middle;
|
31 |
+
}
|
32 |
+
|
33 |
+
.tablesaw thead tr:first-child th {
|
34 |
+
padding-top: .9em;
|
35 |
+
padding-bottom: .7em;
|
36 |
+
}
|
37 |
+
|
38 |
+
.tablesaw-enhanced .tablesaw-bar .btn {
|
39 |
+
border: 1px solid #ccc;
|
40 |
+
background: none;
|
41 |
+
background-color: #fafafa;
|
42 |
+
box-shadow: 0 1px 0 rgba(255,255,255,1);
|
43 |
+
color: #4a4a4a;
|
44 |
+
clear: both;
|
45 |
+
cursor: pointer;
|
46 |
+
display: block;
|
47 |
+
font: bold 20px/1 sans-serif;
|
48 |
+
margin: 0;
|
49 |
+
padding: .5em .85em .4em .85em;
|
50 |
+
position: relative;
|
51 |
+
text-align: center;
|
52 |
+
text-decoration: none;
|
53 |
+
text-transform: capitalize;
|
54 |
+
text-shadow: 0 1px 0 #fff;
|
55 |
+
width: 100%;
|
56 |
+
/* Theming */
|
57 |
+
background-image: -webkit-linear-gradient(top, rgba( 255,255,255,.1 ) 0%, rgba( 255,255,255,.1 ) 50%, rgba( 170,170,170,.1 ) 55%, rgba( 120,120,120,.15 ) 100%);
|
58 |
+
background-image: linear-gradient( top, rgba( 255,255,255,.1 ) 0%, rgba( 255,255,255,.1 ) 50%, rgba( 170,170,170,.1 ) 55%, rgba( 120,120,120,.15 ) 100% );
|
59 |
+
-webkit-appearance: none !important;
|
60 |
+
-moz-appearance: none !important;
|
61 |
+
box-sizing: border-box;
|
62 |
+
-webkit-font-smoothing: antialiased;
|
63 |
+
border-radius: .25em;
|
64 |
+
}
|
65 |
+
|
66 |
+
.tablesaw-enhanced .tablesaw-bar a.btn {
|
67 |
+
color: #1c95d4;
|
68 |
+
}
|
69 |
+
|
70 |
+
.tablesaw-enhanced .tablesaw-bar .btn:hover {
|
71 |
+
text-decoration: none;
|
72 |
+
}
|
73 |
+
|
74 |
+
/* Default radio/checkbox styling horizonal controlgroups. */
|
75 |
+
|
76 |
+
.tablesaw-enhanced .tablesaw-bar .btn:active {
|
77 |
+
background-color: #ddd;
|
78 |
+
background-image: -webkit-linear-gradient(top, rgba( 100,100,100,.35 ) 0%, rgba( 255,255,255,0 ) 70%);
|
79 |
+
background-image: linear-gradient( top, rgba( 100,100,100,.35 ) 0%, rgba( 255,255,255,0 ) 70% );
|
80 |
+
}
|
81 |
+
|
82 |
+
.tablesaw-enhanced .tablesaw-bar .btn:hover,
|
83 |
+
.tablesaw-enhanced .tablesaw-bar .btn:focus {
|
84 |
+
color: #208de3;
|
85 |
+
background-color: #fff;
|
86 |
+
outline: none;
|
87 |
+
}
|
88 |
+
|
89 |
+
.tablesaw-bar .btn:focus {
|
90 |
+
box-shadow: 0 0 .35em #4faeef !important;
|
91 |
+
}
|
92 |
+
|
93 |
+
.tablesaw-bar .btn-select select {
|
94 |
+
background: none;
|
95 |
+
border: none;
|
96 |
+
display: block;
|
97 |
+
position: absolute;
|
98 |
+
font-weight: inherit;
|
99 |
+
left: 0;
|
100 |
+
top: 0;
|
101 |
+
margin: 0;
|
102 |
+
width: 100%;
|
103 |
+
height: 100%;
|
104 |
+
z-index: 2;
|
105 |
+
min-height: 1em;
|
106 |
+
}
|
107 |
+
|
108 |
+
.tablesaw-bar .btn-select select {
|
109 |
+
opacity: 0;
|
110 |
+
filter: alpha(opacity=0);
|
111 |
+
display: inline-block;
|
112 |
+
color: transparent;
|
113 |
+
}
|
114 |
+
|
115 |
+
.tablesaw-bar .btn select option {
|
116 |
+
background: #fff;
|
117 |
+
color: #000;
|
118 |
+
font-family: sans-serif;
|
119 |
+
}
|
120 |
+
|
121 |
+
.tablesaw-enhanced .tablesaw-bar .btn.btn-select {
|
122 |
+
color: #4d4d4d;
|
123 |
+
padding-right: 2.5em;
|
124 |
+
min-width: 7.25em;
|
125 |
+
text-align: left;
|
126 |
+
text-indent: 0;
|
127 |
+
}
|
128 |
+
|
129 |
+
.tablesaw-bar .btn.btn-small,
|
130 |
+
.tablesaw-bar .btn.btn-micro {
|
131 |
+
display: inline-block;
|
132 |
+
width: auto;
|
133 |
+
height: auto;
|
134 |
+
position: relative;
|
135 |
+
top: 0;
|
136 |
+
}
|
137 |
+
|
138 |
+
.tablesaw-bar .btn.btn-small {
|
139 |
+
font-size: 1.0625em;
|
140 |
+
line-height: 19px;
|
141 |
+
padding: .3em 1em .3em 1em;
|
142 |
+
}
|
143 |
+
|
144 |
+
.tablesaw-bar .btn.btn-micro {
|
145 |
+
font-size: .8125em;
|
146 |
+
padding: .4em .7em .25em .7em;
|
147 |
+
}
|
148 |
+
|
149 |
+
.tablesaw-enhanced .tablesaw-bar .btn-select {
|
150 |
+
text-align: left;
|
151 |
+
}
|
152 |
+
|
153 |
+
.tablesaw-bar .btn-select:after {
|
154 |
+
background: #e5e5e5;
|
155 |
+
background: rgba(0,0,0,.1);
|
156 |
+
box-shadow: 0 2px 2px rgba(255,255,255,.25);
|
157 |
+
content: " ";
|
158 |
+
display: block;
|
159 |
+
position: absolute;
|
160 |
+
}
|
161 |
+
|
162 |
+
.tablesaw-bar .btn-select.btn-small,
|
163 |
+
.tablesaw-bar .btn-select.btn-micro {
|
164 |
+
padding-right: 1.5em;
|
165 |
+
}
|
166 |
+
|
167 |
+
.tablesaw-bar .btn-select:after {
|
168 |
+
background: none;
|
169 |
+
background-repeat: no-repeat;
|
170 |
+
background-position: .25em .45em;
|
171 |
+
content: "\25bc";
|
172 |
+
font-size: .55em;
|
173 |
+
padding-top: 1.2em;
|
174 |
+
padding-left: 1em;
|
175 |
+
left: auto;
|
176 |
+
right: 0;
|
177 |
+
margin: 0;
|
178 |
+
top: 0;
|
179 |
+
bottom: 0;
|
180 |
+
width: 1.8em;
|
181 |
+
}
|
182 |
+
|
183 |
+
.tablesaw-bar .btn-select.btn-small:after,
|
184 |
+
.tablesaw-bar .btn-select.btn-micro:after {
|
185 |
+
width: 1.2em;
|
186 |
+
font-size: .5em;
|
187 |
+
padding-top: 1em;
|
188 |
+
padding-right: .5em;
|
189 |
+
line-height: 1.65;
|
190 |
+
background: none;
|
191 |
+
box-shadow: none;
|
192 |
+
border-left-width: 0;
|
193 |
+
}
|
194 |
+
|
195 |
+
/* Column navigation buttons for swipe and columntoggle tables */
|
196 |
+
|
197 |
+
.tablesaw-advance .btn {
|
198 |
+
-webkit-appearance: none;
|
199 |
+
-moz-appearance: none;
|
200 |
+
box-sizing: border-box;
|
201 |
+
text-shadow: 0 1px 0 #fff;
|
202 |
+
border-radius: .25em;
|
203 |
+
}
|
204 |
+
|
205 |
+
.tablesaw-advance .btn.btn-micro {
|
206 |
+
font-size: .8125em;
|
207 |
+
padding: .3em .7em .25em .7em;
|
208 |
+
}
|
209 |
+
|
210 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn {
|
211 |
+
display: inline-block;
|
212 |
+
overflow: hidden;
|
213 |
+
width: 1.8em;
|
214 |
+
height: 1.8em;
|
215 |
+
background-position: 50% 50%;
|
216 |
+
margin-left: .5em;
|
217 |
+
position: relative;
|
218 |
+
}
|
219 |
+
|
220 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.left:before,
|
221 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.right:before,
|
222 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.down:before,
|
223 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.up:before {
|
224 |
+
content: "\0020";
|
225 |
+
overflow: hidden;
|
226 |
+
width: 0;
|
227 |
+
height: 0;
|
228 |
+
position: absolute;
|
229 |
+
}
|
230 |
+
|
231 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.down:before {
|
232 |
+
left: .5em;
|
233 |
+
top: .65em;
|
234 |
+
border-left: 5px solid transparent;
|
235 |
+
border-right: 5px solid transparent;
|
236 |
+
border-top: 5px solid #808080;
|
237 |
+
}
|
238 |
+
|
239 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.up:before {
|
240 |
+
left: .5em;
|
241 |
+
top: .65em;
|
242 |
+
border-left: 5px solid transparent;
|
243 |
+
border-right: 5px solid transparent;
|
244 |
+
border-bottom: 5px solid #808080;
|
245 |
+
}
|
246 |
+
|
247 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.left:before,
|
248 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.right:before {
|
249 |
+
top: .45em;
|
250 |
+
border-top: 5px solid transparent;
|
251 |
+
border-bottom: 5px solid transparent;
|
252 |
+
}
|
253 |
+
|
254 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.left:before {
|
255 |
+
left: .6em;
|
256 |
+
border-right: 5px solid #808080;
|
257 |
+
}
|
258 |
+
|
259 |
+
.tablesaw-bar .tablesaw-advance a.tablesaw-nav-btn.right:before {
|
260 |
+
left: .7em;
|
261 |
+
border-left: 5px solid #808080;
|
262 |
+
}
|
263 |
+
|
264 |
+
.tablesaw-advance a.tablesaw-nav-btn.disabled {
|
265 |
+
opacity: .25;
|
266 |
+
filter: alpha(opacity=25);
|
267 |
+
cursor: default;
|
268 |
+
pointer-events: none;
|
269 |
+
}
|
270 |
+
|
271 |
+
/* Table Toolbar */
|
272 |
+
|
273 |
+
.tablesaw-bar {
|
274 |
+
clear: both;
|
275 |
+
font-family: sans-serif;
|
276 |
+
}
|
277 |
+
|
278 |
+
.tablesaw-toolbar {
|
279 |
+
font-size: .875em;
|
280 |
+
float: left;
|
281 |
+
}
|
282 |
+
|
283 |
+
.tablesaw-toolbar label {
|
284 |
+
padding: .5em 0;
|
285 |
+
clear: both;
|
286 |
+
display: block;
|
287 |
+
color: #888;
|
288 |
+
margin-right: .5em;
|
289 |
+
text-transform: uppercase;
|
290 |
+
}
|
291 |
+
|
292 |
+
.tablesaw-bar .btn,
|
293 |
+
.tablesaw-enhanced .tablesaw-bar .btn {
|
294 |
+
margin-top: .5em;
|
295 |
+
margin-bottom: .5em;
|
296 |
+
}
|
297 |
+
|
298 |
+
.tablesaw-bar .btn-select,
|
299 |
+
.tablesaw-enhanced .tablesaw-bar .btn-select {
|
300 |
+
margin-bottom: 0;
|
301 |
+
}
|
302 |
+
|
303 |
+
.tablesaw-bar .tablesaw-toolbar .btn {
|
304 |
+
margin-left: .4em;
|
305 |
+
margin-top: 0;
|
306 |
+
text-transform: uppercase;
|
307 |
+
border: none;
|
308 |
+
box-shadow: none;
|
309 |
+
background: transparent;
|
310 |
+
font-family: sans-serif;
|
311 |
+
font-size: 1em;
|
312 |
+
padding-left: .3em;
|
313 |
+
}
|
314 |
+
|
315 |
+
.tablesaw-bar .tablesaw-toolbar .btn-select {
|
316 |
+
min-width: 0;
|
317 |
+
}
|
318 |
+
|
319 |
+
.tablesaw-bar .tablesaw-toolbar .btn-select:after {
|
320 |
+
padding-top: .9em;
|
321 |
+
}
|
322 |
+
|
323 |
+
.tablesaw-bar .tablesaw-toolbar select {
|
324 |
+
color: #888;
|
325 |
+
text-transform: none;
|
326 |
+
background: transparent;
|
327 |
+
}
|
328 |
+
|
329 |
+
.tablesaw-toolbar ~ table {
|
330 |
+
clear: both;
|
331 |
+
}
|
332 |
+
|
333 |
+
.tablesaw-toolbar .a11y-sm {
|
334 |
+
clip: rect(0 0 0 0);
|
335 |
+
height: 1px;
|
336 |
+
overflow: hidden;
|
337 |
+
position: absolute;
|
338 |
+
width: 1px;
|
339 |
+
}
|
340 |
+
|
341 |
+
@media (min-width: 24em) {
|
342 |
+
.tablesaw-toolbar .a11y-sm {
|
343 |
+
clip: none;
|
344 |
+
height: auto;
|
345 |
+
width: auto;
|
346 |
+
position: static;
|
347 |
+
overflow: visible;
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
table.tablesaw tbody th {
|
352 |
+
font-weight: bold;
|
353 |
+
}
|
354 |
+
|
355 |
+
.tablesaw td,
|
356 |
+
.tablesaw tbody th {
|
357 |
+
vertical-align: middle;
|
358 |
+
}
|
359 |
+
|
360 |
+
/* Mobile first styles: Begin with the stacked presentation at narrow widths */
|
361 |
+
|
362 |
+
@media only all {
|
363 |
+
|
364 |
+
.tablesaw-cell-label {
|
365 |
+
display: block;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
@media (max-width: 39.9375em) {
|
370 |
+
.tablesaw-cell-label {
|
371 |
+
vertical-align: top;
|
372 |
+
}
|
373 |
+
|
374 |
+
.tablesaw-cell-content {
|
375 |
+
max-width: 67%;
|
376 |
+
display: inline-block;
|
377 |
+
}
|
378 |
+
}
|
379 |
+
|
380 |
+
.tablesaw-fix-persist {
|
381 |
+
table-layout: fixed;
|
382 |
+
}
|
383 |
+
|
384 |
+
@media only all {
|
385 |
+
/* Unchecked manually: Always hide */
|
386 |
+
|
387 |
+
.tablesaw-swipe th.tablesaw-cell-hidden,
|
388 |
+
.tablesaw-swipe td.tablesaw-cell-hidden {
|
389 |
+
display: none;
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
.btn.tablesaw-columntoggle-btn span {
|
394 |
+
text-indent: -9999px;
|
395 |
+
display: inline-block;
|
396 |
+
}
|
397 |
+
|
398 |
+
.tablesaw-columntoggle-btnwrap {
|
399 |
+
position: relative;
|
400 |
+
/* for dialog positioning */
|
401 |
+
}
|
402 |
+
|
403 |
+
.tablesaw-columntoggle-btnwrap .dialog-content {
|
404 |
+
padding: .5em;
|
405 |
+
}
|
406 |
+
|
407 |
+
.tablesaw-columntoggle tbody td {
|
408 |
+
line-height: 1.5;
|
409 |
+
}
|
410 |
+
|
411 |
+
/* Remove top/bottom margins around the fieldcontain on check list */
|
412 |
+
|
413 |
+
.tablesaw-columntoggle-popup {
|
414 |
+
display: none;
|
415 |
+
}
|
416 |
+
|
417 |
+
.tablesaw-columntoggle-btnwrap.visible .tablesaw-columntoggle-popup {
|
418 |
+
display: block;
|
419 |
+
position: absolute;
|
420 |
+
top: 2em;
|
421 |
+
right: 0;
|
422 |
+
background-color: #fff;
|
423 |
+
padding: .5em .8em;
|
424 |
+
border: 1px solid #ccc;
|
425 |
+
box-shadow: 0 1px 2px #ccc;
|
426 |
+
border-radius: .2em;
|
427 |
+
z-index: 1;
|
428 |
+
}
|
429 |
+
|
430 |
+
.tablesaw-columntoggle-popup fieldset {
|
431 |
+
margin: 0;
|
432 |
+
}
|
433 |
+
|
434 |
+
/* Hide all prioritized columns by default */
|
435 |
+
|
436 |
+
@media only all {
|
437 |
+
.tablesaw-columntoggle th.tablesaw-priority-6,
|
438 |
+
.tablesaw-columntoggle td.tablesaw-priority-6,
|
439 |
+
.tablesaw-columntoggle th.tablesaw-priority-5,
|
440 |
+
.tablesaw-columntoggle td.tablesaw-priority-5,
|
441 |
+
.tablesaw-columntoggle th.tablesaw-priority-4,
|
442 |
+
.tablesaw-columntoggle td.tablesaw-priority-4,
|
443 |
+
.tablesaw-columntoggle th.tablesaw-priority-3,
|
444 |
+
.tablesaw-columntoggle td.tablesaw-priority-3,
|
445 |
+
.tablesaw-columntoggle th.tablesaw-priority-2,
|
446 |
+
.tablesaw-columntoggle td.tablesaw-priority-2,
|
447 |
+
.tablesaw-columntoggle th.tablesaw-priority-1,
|
448 |
+
.tablesaw-columntoggle td.tablesaw-priority-1 {
|
449 |
+
display: none;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
.tablesaw-columntoggle-btnwrap .dialog-content {
|
454 |
+
top: 0 !important;
|
455 |
+
right: 1em;
|
456 |
+
left: auto !important;
|
457 |
+
width: 12em;
|
458 |
+
max-width: 18em;
|
459 |
+
margin: -.5em auto 0;
|
460 |
+
}
|
461 |
+
|
462 |
+
.tablesaw-columntoggle-btnwrap .dialog-content:focus {
|
463 |
+
outline-style: none;
|
464 |
+
}
|
465 |
+
|
466 |
+
/* Preset breakpoints if "" class added to table */
|
467 |
+
|
468 |
+
/* Show priority 1 at 320px (20em x 16px) */
|
469 |
+
|
470 |
+
@media (min-width: 20em) {
|
471 |
+
.tablesaw-columntoggle th.tablesaw-priority-1,
|
472 |
+
.tablesaw-columntoggle td.tablesaw-priority-1 {
|
473 |
+
display: table-cell;
|
474 |
+
}
|
475 |
+
}
|
476 |
+
|
477 |
+
/* Show priority 2 at 480px (30em x 16px) */
|
478 |
+
|
479 |
+
@media (min-width: 30em) {
|
480 |
+
.tablesaw-columntoggle th.tablesaw-priority-2,
|
481 |
+
.tablesaw-columntoggle td.tablesaw-priority-2 {
|
482 |
+
display: table-cell;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
|
486 |
+
/* Show priority 3 at 640px (40em x 16px) */
|
487 |
+
|
488 |
+
@media (min-width: 40em) {
|
489 |
+
.tablesaw-columntoggle th.tablesaw-priority-3,
|
490 |
+
.tablesaw-columntoggle td.tablesaw-priority-3 {
|
491 |
+
display: table-cell;
|
492 |
+
}
|
493 |
+
|
494 |
+
.tablesaw-columntoggle tbody td {
|
495 |
+
line-height: 2;
|
496 |
+
}
|
497 |
+
}
|
498 |
+
|
499 |
+
/* Show priority 4 at 800px (50em x 16px) */
|
500 |
+
|
501 |
+
@media (min-width: 50em) {
|
502 |
+
.tablesaw-columntoggle th.tablesaw-priority-4,
|
503 |
+
.tablesaw-columntoggle td.tablesaw-priority-4 {
|
504 |
+
display: table-cell;
|
505 |
+
}
|
506 |
+
}
|
507 |
+
|
508 |
+
/* Show priority 5 at 960px (60em x 16px) */
|
509 |
+
|
510 |
+
@media (min-width: 60em) {
|
511 |
+
.tablesaw-columntoggle th.tablesaw-priority-5,
|
512 |
+
.tablesaw-columntoggle td.tablesaw-priority-5 {
|
513 |
+
display: table-cell;
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
/* Show priority 6 at 1,120px (70em x 16px) */
|
518 |
+
|
519 |
+
@media (min-width: 70em) {
|
520 |
+
.tablesaw-columntoggle th.tablesaw-priority-6,
|
521 |
+
.tablesaw-columntoggle td.tablesaw-priority-6 {
|
522 |
+
display: table-cell;
|
523 |
+
}
|
524 |
+
}
|
525 |
+
|
526 |
+
@media only all {
|
527 |
+
/* Unchecked manually: Always hide */
|
528 |
+
|
529 |
+
.tablesaw-columntoggle th.tablesaw-cell-hidden,
|
530 |
+
.tablesaw-columntoggle td.tablesaw-cell-hidden {
|
531 |
+
display: none;
|
532 |
+
}
|
533 |
+
|
534 |
+
/* Checked manually: Always show */
|
535 |
+
|
536 |
+
.tablesaw-columntoggle th.tablesaw-cell-visible,
|
537 |
+
.tablesaw-columntoggle td.tablesaw-cell-visible {
|
538 |
+
display: table-cell;
|
539 |
+
}
|
540 |
+
}
|
541 |
+
|
542 |
+
.tablesaw-columntoggle-popup .btn-group > label {
|
543 |
+
display: block;
|
544 |
+
padding: .2em 0;
|
545 |
+
white-space: nowrap;
|
546 |
+
}
|
547 |
+
|
548 |
+
.tablesaw-columntoggle-popup .btn-group > label input {
|
549 |
+
margin-right: .8em;
|
550 |
+
}
|
551 |
+
|
552 |
+
.tablesaw-advance {
|
553 |
+
float: right;
|
554 |
+
}
|
555 |
+
|
556 |
+
.tablesaw-advance.minimap {
|
557 |
+
margin-right: .4em;
|
558 |
+
}
|
559 |
+
|
560 |
+
.tablesaw-advance-dots {
|
561 |
+
float: left;
|
562 |
+
margin: 0;
|
563 |
+
padding: 0;
|
564 |
+
list-style: none;
|
565 |
+
}
|
566 |
+
|
567 |
+
.tablesaw-advance-dots li {
|
568 |
+
display: table-cell;
|
569 |
+
margin: 0;
|
570 |
+
padding: .4em .2em;
|
571 |
+
}
|
572 |
+
|
573 |
+
.tablesaw-advance-dots li i {
|
574 |
+
width: .25em;
|
575 |
+
height: .25em;
|
576 |
+
background: #555;
|
577 |
+
border-radius: 100%;
|
578 |
+
display: inline-block;
|
579 |
+
}
|
580 |
+
|
581 |
+
.tablesaw-advance-dots-hide {
|
582 |
+
opacity: .25;
|
583 |
+
filter: alpha(opacity=25);
|
584 |
+
cursor: default;
|
585 |
+
pointer-events: none;
|
586 |
+
}
|
inc/woo-compare-wishlist/assets/css/tm-woocompare.css
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tm-woocompare-list.loading,
|
2 |
+
.tm-woocompare-widget-wrapper.loading {
|
3 |
+
position:relative;
|
4 |
+
}
|
5 |
+
.tm-woocompare-list.loading .tm-wc-compare-wishlist-loader,
|
6 |
+
.tm-woocompare-widget-wrapper.loading .tm-wc-compare-wishlist-loader {
|
7 |
+
display:block;
|
8 |
+
}
|
9 |
+
.tm-woocompare-list .tm-wc-compare-wishlist-loader,
|
10 |
+
.tm-woocompare-widget-wrapper .tm-wc-compare-wishlist-loader {
|
11 |
+
display:none;
|
12 |
+
position:absolute;
|
13 |
+
width:100%;
|
14 |
+
height:100%;
|
15 |
+
background:rgba(255, 255, 255, 0.5);
|
16 |
+
top:0;
|
17 |
+
left:0;
|
18 |
+
}
|
19 |
+
.tm-woocompare-list .tm-wc-compare-wishlist-loader>*,
|
20 |
+
.tm-woocompare-widget-wrapper .tm-wc-compare-wishlist-loader>* {
|
21 |
+
position:absolute;
|
22 |
+
top:50%;
|
23 |
+
left:50%;
|
24 |
+
transform:translate(-50%, -50%);
|
25 |
+
}
|
26 |
+
.tm-woocompare-table {
|
27 |
+
width:100%;
|
28 |
+
min-width:100%;
|
29 |
+
table-layout:fixed;
|
30 |
+
}
|
31 |
+
.tm-woocompare-table.tablesaw {
|
32 |
+
min-width:0;
|
33 |
+
}
|
34 |
+
.tm-woocompare-row {
|
35 |
+
background:rgba(0,0,0,0.02);
|
36 |
+
}
|
37 |
+
thead+.tm-woocompare-row {
|
38 |
+
background:none;
|
39 |
+
}
|
40 |
+
.tm-woocompare-row:nth-child(odd) {
|
41 |
+
background:none;
|
42 |
+
}
|
43 |
+
.tm-woocompare-cell {
|
44 |
+
width:auto;
|
45 |
+
position:relative;
|
46 |
+
background:rgba(0,0,0,0.02);
|
47 |
+
}
|
48 |
+
.tm-woocompare-cell:nth-child(odd){
|
49 |
+
background:none;
|
50 |
+
}
|
51 |
+
.tm-woocompare-cell p {
|
52 |
+
margin:0;
|
53 |
+
padding:0;
|
54 |
+
}
|
55 |
+
.tm-woocompare-remove {
|
56 |
+
position:absolute;
|
57 |
+
right:5px;
|
58 |
+
top:5px;
|
59 |
+
cursor:pointer;
|
60 |
+
color:#d42f2f;
|
61 |
+
text-align:center;
|
62 |
+
line-height:17px;
|
63 |
+
font-size:17px;
|
64 |
+
}
|
65 |
+
.tm-woocompare-remove:hover{
|
66 |
+
color:#a42424;
|
67 |
+
}
|
68 |
+
.tm-woocompare-heading-cell {
|
69 |
+
width:100px;
|
70 |
+
}
|
71 |
+
button.tm-woocompare-button,
|
72 |
+
.woocommerce button.tm-woocompare-button {
|
73 |
+
display:-ms-inline-flexbox;
|
74 |
+
display:-webkit-inline-flex;
|
75 |
+
display:inline-flex;
|
76 |
+
-webkit-flex-direction:row;
|
77 |
+
-ms-flex-direction:row;
|
78 |
+
flex-direction:row;
|
79 |
+
-webkit-flex-wrap:nowrap;
|
80 |
+
-ms-flex-wrap:nowrap;
|
81 |
+
flex-wrap:nowrap;
|
82 |
+
-webkit-justify-content:center;
|
83 |
+
-ms-flex-pack:center;
|
84 |
+
justify-content:center;
|
85 |
+
-webkit-align-content:stretch;
|
86 |
+
-ms-flex-line-pack:stretch;
|
87 |
+
align-content:stretch;
|
88 |
+
-webkit-align-items:center;
|
89 |
+
-ms-flex-align:center;
|
90 |
+
align-items:center;
|
91 |
+
}
|
92 |
+
.tx_woocompare_product_actions_tip,
|
93 |
+
.tx_woocompare_product_actions_tip .text {
|
94 |
+
min-width:0;
|
95 |
+
display:block;
|
96 |
+
}
|
97 |
+
.tx_woocompare_product_actions_tip .text {
|
98 |
+
text-overflow:ellipsis;
|
99 |
+
overflow:hidden;
|
100 |
+
}
|
101 |
+
.tm-woocompare-widget-product {
|
102 |
+
position:relative;
|
103 |
+
margin:0 0 20px;
|
104 |
+
}
|
105 |
+
.compare-count:before {
|
106 |
+
content: ' ';
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
+
|
113 |
+
.woocommerce ul.products li.product button.tm-woocompare-button,
|
114 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woocompare-button {
|
115 |
+
display: block;
|
116 |
+
position: absolute;
|
117 |
+
right: 6px;
|
118 |
+
margin-right: 0px;
|
119 |
+
top: 48px;
|
120 |
+
z-index: 20;
|
121 |
+
|
122 |
+
content: " ";
|
123 |
+
width: 36px;
|
124 |
+
height: 36px;
|
125 |
+
background: transparent;
|
126 |
+
overflow: hidden;
|
127 |
+
text-indent: -200px;
|
128 |
+
border: 1px solid #373737;
|
129 |
+
opacity: 0.48;
|
130 |
+
|
131 |
+
transition-property: all;
|
132 |
+
transition-duration: 0.3s;
|
133 |
+
transition-timing-function: ease-in-out;
|
134 |
+
transition-delay: 0s;
|
135 |
+
white-space: nowrap;
|
136 |
+
}
|
137 |
+
|
138 |
+
.woocommerce ul.products li.product button.tm-woocompare-button:hover,
|
139 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woocompare-button:hover {
|
140 |
+
opacity: 1;
|
141 |
+
color: #373737;
|
142 |
+
background-color: #ffffff!important;
|
143 |
+
}
|
144 |
+
|
145 |
+
.woocommerce ul.products li.product button.tm-woocompare-button:before {
|
146 |
+
position: absolute;
|
147 |
+
display: block;
|
148 |
+
height: 36px;
|
149 |
+
width: 36px;
|
150 |
+
z-index: 1;
|
151 |
+
right: -1px;
|
152 |
+
top: 0px;
|
153 |
+
color: #373737;
|
154 |
+
line-height: 36px;
|
155 |
+
text-align: center;
|
156 |
+
font-family: FontAwesome;
|
157 |
+
text-indent: 0px;
|
158 |
+
content: "\f0ec";
|
159 |
+
}
|
160 |
+
|
161 |
+
.woocommerce ul.products li.product button.tm-woocompare-button:hover::before {
|
162 |
+
background: transparent;
|
163 |
+
}
|
164 |
+
|
165 |
+
.woocommerce ul.products li.product button.tm-woocompare-button,
|
166 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woocompare-button {
|
167 |
+
top: 88px;
|
168 |
+
}
|
169 |
+
|
170 |
+
.woocommerce ul.products li.product button.tm-woocompare-button.added,
|
171 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woocompare-button.added,
|
172 |
+
.woocommerce ul.products li.product button.tm-woocompare-button.in_compare,
|
173 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woocompare-button.in_compare {
|
174 |
+
opacity: 1;
|
175 |
+
color: #F00;
|
176 |
+
border-color: #F00;
|
177 |
+
}
|
178 |
+
|
179 |
+
.woocommerce ul.products li.product button.tm-woocompare-button.added:before,
|
180 |
+
.woocommerce ul.products li.product button.tm-woocompare-button.in_compare:before {
|
181 |
+
color: #F00;
|
182 |
+
}
|
183 |
+
|
184 |
+
.woocommerce .related.products li.product button.tm-woocompare-button,
|
185 |
+
.woocommerce .related.products li.product .woocommerce button.tm-woocompare-button {
|
186 |
+
right: 22px;
|
187 |
+
}
|
188 |
+
|
189 |
+
.woocommerce.single-product button.tm-woocompare-button,
|
190 |
+
.woocommerce.single-product button.tm-woocompare-button:visited {
|
191 |
+
background: transparent;
|
192 |
+
border: 1px solid #373737;
|
193 |
+
color: #373737;
|
194 |
+
}
|
195 |
+
|
196 |
+
.woocommerce.single-product button.tm-woocompare-button:hover {
|
197 |
+
background-color: #373737;
|
198 |
+
color: #FFFFFF;
|
199 |
+
}
|
inc/woo-compare-wishlist/assets/css/tm-woowishlist.css
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tm-woowishlist.loading,
|
2 |
+
.tm-woocomerce-wishlist-widget-wrapper.loading {
|
3 |
+
position:relative;
|
4 |
+
}
|
5 |
+
.tm-woowishlist.loading .tm-wc-compare-wishlist-loader,
|
6 |
+
.tm-woocomerce-wishlist-widget-wrapper.loading .tm-wc-compare-wishlist-loader {
|
7 |
+
display:block;
|
8 |
+
|
9 |
+
}
|
10 |
+
.tm-woowishlist .tm-wc-compare-wishlist-loader,
|
11 |
+
.tm-woocomerce-wishlist-widget-wrapper .tm-wc-compare-wishlist-loader {
|
12 |
+
display:none;
|
13 |
+
position:absolute;
|
14 |
+
width:100%;
|
15 |
+
height:100%;
|
16 |
+
background:rgba(255,255,255,0.5);
|
17 |
+
top:0;
|
18 |
+
left:0;
|
19 |
+
}
|
20 |
+
.tm-woowishlist .tm-wc-compare-wishlist-loader>*,
|
21 |
+
.tm-woocomerce-wishlist-widget-wrapper .tm-wc-compare-wishlist-loader>* {
|
22 |
+
position:absolute;
|
23 |
+
top:50%;
|
24 |
+
left:50%;
|
25 |
+
transform:translate(-50%, -50%);
|
26 |
+
}
|
27 |
+
.tm-woowishlist-remove {
|
28 |
+
position:absolute;
|
29 |
+
right:0px;
|
30 |
+
top:0px;
|
31 |
+
cursor:pointer;
|
32 |
+
color:#d42f2f;
|
33 |
+
text-align:center;
|
34 |
+
line-height:17px;
|
35 |
+
font-size:17px;
|
36 |
+
|
37 |
+
}
|
38 |
+
.tm-woowishlist-remove:hover {
|
39 |
+
color:#a42424;
|
40 |
+
|
41 |
+
}
|
42 |
+
button.tm-woowishlist-button,
|
43 |
+
.woocommerce button.tm-woowishlist-button {
|
44 |
+
display:-ms-inline-flexbox;
|
45 |
+
display:-webkit-inline-flex;
|
46 |
+
display:inline-flex;
|
47 |
+
-webkit-flex-direction:row;
|
48 |
+
-ms-flex-direction:row;
|
49 |
+
flex-direction:row;
|
50 |
+
-webkit-flex-wrap:nowrap;
|
51 |
+
-ms-flex-wrap:nowrap;
|
52 |
+
flex-wrap:nowrap;
|
53 |
+
-webkit-justify-content:center;
|
54 |
+
-ms-flex-pack:center;
|
55 |
+
justify-content:center;
|
56 |
+
-webkit-align-content:stretch;
|
57 |
+
-ms-flex-line-pack:stretch;
|
58 |
+
align-content:stretch;
|
59 |
+
-webkit-align-items:center;
|
60 |
+
-ms-flex-align:center;
|
61 |
+
align-items:center;
|
62 |
+
}
|
63 |
+
.tm-woowishlist-item {
|
64 |
+
position:relative;
|
65 |
+
margin:0 0 20px;
|
66 |
+
}
|
67 |
+
.tm-woowishlist-item:after {
|
68 |
+
content:'';
|
69 |
+
clear:both;
|
70 |
+
display:block;
|
71 |
+
}
|
72 |
+
.tm-woowishlist-item .tm-woocomerce-list__product-title {
|
73 |
+
margin:0 0 10px;
|
74 |
+
}
|
75 |
+
.tm-woowishlist-item .tm-woocomerce-list__product-image {
|
76 |
+
float:left;
|
77 |
+
margin:0 30px 10px 0;
|
78 |
+
}
|
79 |
+
.tm-woowishlist-item .price {
|
80 |
+
display:block;
|
81 |
+
margin:0 0 10px;
|
82 |
+
}
|
83 |
+
.tm-woowishlist-item .stock {
|
84 |
+
color:#77a464;
|
85 |
+
}
|
86 |
+
.tm-woowishlist-item .stock.out-of-stock {
|
87 |
+
color:red;
|
88 |
+
}
|
89 |
+
.tm-woowishlist-widget-product {
|
90 |
+
position:relative;
|
91 |
+
margin:0 0 20px;
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button,
|
97 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woowishlist-button {
|
98 |
+
display: block;
|
99 |
+
position: absolute;
|
100 |
+
right: 6px;
|
101 |
+
margin-right: 0px;
|
102 |
+
top: 48px;
|
103 |
+
z-index: 20;
|
104 |
+
|
105 |
+
content: " ";
|
106 |
+
width: 36px;
|
107 |
+
height: 36px;
|
108 |
+
background: transparent;
|
109 |
+
overflow: hidden;
|
110 |
+
text-indent: -200px;
|
111 |
+
border: 1px solid #373737;
|
112 |
+
opacity: 0.48;
|
113 |
+
|
114 |
+
transition-property: all;
|
115 |
+
transition-duration: 0.3s;
|
116 |
+
transition-timing-function: ease-in-out;
|
117 |
+
transition-delay: 0s;
|
118 |
+
white-space: nowrap;
|
119 |
+
}
|
120 |
+
|
121 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button:hover,
|
122 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woowishlist-button:hover {
|
123 |
+
opacity: 1;
|
124 |
+
color: #373737;
|
125 |
+
background-color: #ffffff!important;
|
126 |
+
}
|
127 |
+
|
128 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button:before {
|
129 |
+
position: absolute;
|
130 |
+
display: block;
|
131 |
+
height: 36px;
|
132 |
+
width: 36px;
|
133 |
+
z-index: 1;
|
134 |
+
right: -1px;
|
135 |
+
top: 0px;
|
136 |
+
color: #333;
|
137 |
+
line-height: 36px;
|
138 |
+
text-align: center;
|
139 |
+
font-family: FontAwesome;
|
140 |
+
text-indent: 0px;
|
141 |
+
content: "\f004";
|
142 |
+
}
|
143 |
+
|
144 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button:hover::before {
|
145 |
+
background: transparent;
|
146 |
+
}
|
147 |
+
|
148 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button.added,
|
149 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woowishlist-button.added,
|
150 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button.in_wishlist,
|
151 |
+
.woocommerce ul.products li.product .woocommerce button.tm-woowishlist-button.in_wishlist {
|
152 |
+
opacity: 1;
|
153 |
+
color: #F00;
|
154 |
+
border-color: #F00;
|
155 |
+
}
|
156 |
+
|
157 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button.added:before,
|
158 |
+
.woocommerce ul.products li.product button.tm-woowishlist-button.in_wishlist:before {
|
159 |
+
color: #F00;
|
160 |
+
}
|
161 |
+
|
162 |
+
.woocommerce .related.products li.product button.tm-woowishlist-button,
|
163 |
+
.woocommerce .related.products li.product .woocommerce button.tm-woowishlist-button {
|
164 |
+
right: 22px;
|
165 |
+
}
|
166 |
+
|
167 |
+
.woocommerce.single-product button.tm-woowishlist-button,
|
168 |
+
.woocommerce.single-product button.tm-woowishlist-button:visited {
|
169 |
+
background: transparent;
|
170 |
+
border: 1px solid #373737;
|
171 |
+
color: #373737;
|
172 |
+
}
|
173 |
+
|
174 |
+
.woocommerce.single-product button.tm-woowishlist-button:hover {
|
175 |
+
background-color: #373737;
|
176 |
+
color: #FFFFFF;
|
177 |
+
}
|
178 |
+
|
inc/woo-compare-wishlist/assets/js/tablesaw-init.js
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
;( function( $ ) {
|
2 |
+
$( function() {
|
3 |
+
$( document ).trigger( 'enhance.tablesaw' );
|
4 |
+
} );
|
5 |
+
} )( jQuery );
|
inc/woo-compare-wishlist/assets/js/tablesaw-init.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(n){n(function(){n(document).trigger("enhance.tablesaw")})}(jQuery);
|
inc/woo-compare-wishlist/assets/js/tablesaw.js
ADDED
@@ -0,0 +1,1275 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*! Tablesaw - v2.0.3 - 2016-05-02
|
2 |
+
* https://github.com/filamentgroup/tablesaw
|
3 |
+
* Copyright (c) 2016 Filament Group; Licensed MIT */
|
4 |
+
/*
|
5 |
+
* tablesaw: A set of plugins for responsive tables
|
6 |
+
* Stack and Column Toggle tables
|
7 |
+
* Copyright (c) 2013 Filament Group, Inc.
|
8 |
+
* MIT License
|
9 |
+
*/
|
10 |
+
|
11 |
+
if( typeof Tablesaw === "undefined" ) {
|
12 |
+
Tablesaw = {
|
13 |
+
i18n: {
|
14 |
+
modes: [ 'Stack', 'Swipe', 'Toggle' ],
|
15 |
+
columns: 'Col<span class=\"a11y-sm\">umn</span>s',
|
16 |
+
columnBtnText: 'Columns',
|
17 |
+
columnsDialogError: 'No eligible columns.',
|
18 |
+
sort: 'Sort'
|
19 |
+
},
|
20 |
+
// cut the mustard
|
21 |
+
mustard: 'querySelector' in document &&
|
22 |
+
( !window.blackberry || window.WebKitPoint ) &&
|
23 |
+
!window.operamini
|
24 |
+
};
|
25 |
+
}
|
26 |
+
if( !Tablesaw.config ) {
|
27 |
+
Tablesaw.config = {};
|
28 |
+
}
|
29 |
+
if( Tablesaw.mustard ) {
|
30 |
+
jQuery( document.documentElement ).addClass( 'tablesaw-enhanced' );
|
31 |
+
}
|
32 |
+
|
33 |
+
;(function( $ ) {
|
34 |
+
var pluginName = "table",
|
35 |
+
classes = {
|
36 |
+
toolbar: "tablesaw-bar"
|
37 |
+
},
|
38 |
+
events = {
|
39 |
+
create: "tablesawcreate",
|
40 |
+
destroy: "tablesawdestroy",
|
41 |
+
refresh: "tablesawrefresh"
|
42 |
+
},
|
43 |
+
defaultMode = "stack",
|
44 |
+
initSelector = "table[data-tablesaw-mode],table[data-tablesaw-sortable]";
|
45 |
+
|
46 |
+
var Table = function( element ) {
|
47 |
+
if( !element ) {
|
48 |
+
throw new Error( "Tablesaw requires an element." );
|
49 |
+
}
|
50 |
+
|
51 |
+
this.table = element;
|
52 |
+
this.$table = $( element );
|
53 |
+
|
54 |
+
this.mode = this.$table.attr( "data-tablesaw-mode" ) || defaultMode;
|
55 |
+
|
56 |
+
this.init();
|
57 |
+
};
|
58 |
+
|
59 |
+
Table.prototype.init = function() {
|
60 |
+
// assign an id if there is none
|
61 |
+
if ( !this.$table.attr( "id" ) ) {
|
62 |
+
this.$table.attr( "id", pluginName + "-" + Math.round( Math.random() * 10000 ) );
|
63 |
+
}
|
64 |
+
|
65 |
+
this.createToolbar();
|
66 |
+
|
67 |
+
var colstart = this._initCells();
|
68 |
+
|
69 |
+
this.$table.trigger( events.create, [ this, colstart ] );
|
70 |
+
};
|
71 |
+
|
72 |
+
Table.prototype._initCells = function() {
|
73 |
+
var colstart,
|
74 |
+
thrs = this.table.querySelectorAll( "thead tr" ),
|
75 |
+
self = this;
|
76 |
+
|
77 |
+
$( thrs ).each( function(){
|
78 |
+
var coltally = 0;
|
79 |
+
|
80 |
+
$( this ).children().each( function(){
|
81 |
+
var span = parseInt( this.getAttribute( "colspan" ), 10 ),
|
82 |
+
sel = ":nth-child(" + ( coltally + 1 ) + ")";
|
83 |
+
|
84 |
+
colstart = coltally + 1;
|
85 |
+
|
86 |
+
if( span ){
|
87 |
+
for( var k = 0; k < span - 1; k++ ){
|
88 |
+
coltally++;
|
89 |
+
sel += ", :nth-child(" + ( coltally + 1 ) + ")";
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
// Store "cells" data on header as a reference to all cells in the same column as this TH
|
94 |
+
this.cells = self.$table.find("tr").not( thrs[0] ).not( this ).children().filter( sel );
|
95 |
+
coltally++;
|
96 |
+
});
|
97 |
+
});
|
98 |
+
|
99 |
+
return colstart;
|
100 |
+
};
|
101 |
+
|
102 |
+
Table.prototype.refresh = function() {
|
103 |
+
this._initCells();
|
104 |
+
|
105 |
+
this.$table.trigger( events.refresh );
|
106 |
+
};
|
107 |
+
|
108 |
+
Table.prototype.createToolbar = function() {
|
109 |
+
// Insert the toolbar
|
110 |
+
// TODO move this into a separate component
|
111 |
+
var $toolbar = this.$table.prev().filter( '.' + classes.toolbar );
|
112 |
+
if( !$toolbar.length ) {
|
113 |
+
$toolbar = $( '<div>' )
|
114 |
+
.addClass( classes.toolbar )
|
115 |
+
.insertBefore( this.$table );
|
116 |
+
}
|
117 |
+
this.$toolbar = $toolbar;
|
118 |
+
|
119 |
+
if( this.mode ) {
|
120 |
+
this.$toolbar.addClass( 'mode-' + this.mode );
|
121 |
+
}
|
122 |
+
};
|
123 |
+
|
124 |
+
Table.prototype.destroy = function() {
|
125 |
+
// Don’t remove the toolbar. Some of the table features are not yet destroy-friendly.
|
126 |
+
this.$table.prev().filter( '.' + classes.toolbar ).each(function() {
|
127 |
+
this.className = this.className.replace( /\bmode\-\w*\b/gi, '' );
|
128 |
+
});
|
129 |
+
|
130 |
+
var tableId = this.$table.attr( 'id' );
|
131 |
+
$( document ).unbind( "." + tableId );
|
132 |
+
$( window ).unbind( "." + tableId );
|
133 |
+
|
134 |
+
// other plugins
|
135 |
+
this.$table.trigger( events.destroy, [ this ] );
|
136 |
+
|
137 |
+
this.$table.removeData( pluginName );
|
138 |
+
};
|
139 |
+
|
140 |
+
// Collection method.
|
141 |
+
$.fn[ pluginName ] = function() {
|
142 |
+
return this.each( function() {
|
143 |
+
var $t = $( this );
|
144 |
+
|
145 |
+
if( $t.data( pluginName ) ){
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
|
149 |
+
var table = new Table( this );
|
150 |
+
$t.data( pluginName, table );
|
151 |
+
});
|
152 |
+
};
|
153 |
+
|
154 |
+
$( document ).on( "enhance.tablesaw", function( e ) {
|
155 |
+
// Cut the mustard
|
156 |
+
if( Tablesaw.mustard ) {
|
157 |
+
$( e.target ).find( initSelector )[ pluginName ]();
|
158 |
+
}
|
159 |
+
});
|
160 |
+
|
161 |
+
}( jQuery ));
|
162 |
+
|
163 |
+
;(function( win, $, undefined ){
|
164 |
+
|
165 |
+
var classes = {
|
166 |
+
stackTable: 'tablesaw-stack',
|
167 |
+
cellLabels: 'tablesaw-cell-label',
|
168 |
+
cellContentLabels: 'tablesaw-cell-content'
|
169 |
+
};
|
170 |
+
|
171 |
+
var data = {
|
172 |
+
obj: 'tablesaw-stack'
|
173 |
+
};
|
174 |
+
|
175 |
+
var attrs = {
|
176 |
+
labelless: 'data-tablesaw-no-labels',
|
177 |
+
hideempty: 'data-tablesaw-hide-empty'
|
178 |
+
};
|
179 |
+
|
180 |
+
var Stack = function( element ) {
|
181 |
+
|
182 |
+
this.$table = $( element );
|
183 |
+
|
184 |
+
this.labelless = this.$table.is( '[' + attrs.labelless + ']' );
|
185 |
+
this.hideempty = this.$table.is( '[' + attrs.hideempty + ']' );
|
186 |
+
|
187 |
+
if( !this.labelless ) {
|
188 |
+
// allHeaders references headers, plus all THs in the thead, which may include several rows, or not
|
189 |
+
this.allHeaders = this.$table.find( "th" );
|
190 |
+
}
|
191 |
+
|
192 |
+
this.$table.data( data.obj, this );
|
193 |
+
};
|
194 |
+
|
195 |
+
Stack.prototype.init = function( colstart ) {
|
196 |
+
this.$table.addClass( classes.stackTable );
|
197 |
+
|
198 |
+
if( this.labelless ) {
|
199 |
+
return;
|
200 |
+
}
|
201 |
+
|
202 |
+
// get headers in reverse order so that top-level headers are appended last
|
203 |
+
var reverseHeaders = $( this.allHeaders );
|
204 |
+
var hideempty = this.hideempty;
|
205 |
+
|
206 |
+
// create the hide/show toggles
|
207 |
+
reverseHeaders.each(function(){
|
208 |
+
var $t = $( this ),
|
209 |
+
$cells = $( this.cells ).filter(function() {
|
210 |
+
return !$( this ).parent().is( "[" + attrs.labelless + "]" ) && ( !hideempty || !$( this ).is( ":empty" ) );
|
211 |
+
}),
|
212 |
+
hierarchyClass = $cells.not( this ).filter( "thead th" ).length && " tablesaw-cell-label-top",
|
213 |
+
// TODO reduce coupling with sortable
|
214 |
+
$sortableButton = $t.find( ".tablesaw-sortable-btn" ),
|
215 |
+
html = $sortableButton.length ? $sortableButton.html() : $t.html();
|
216 |
+
|
217 |
+
if( html !== "" ){
|
218 |
+
if( hierarchyClass ){
|
219 |
+
var iteration = parseInt( $( this ).attr( "colspan" ), 10 ),
|
220 |
+
filter = "";
|
221 |
+
|
222 |
+
if( iteration ){
|
223 |
+
filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")";
|
224 |
+
}
|
225 |
+
$cells.filter( filter ).prepend( "<b class='" + classes.cellLabels + hierarchyClass + "'>" + html + "</b>" );
|
226 |
+
} else {
|
227 |
+
$cells.wrapInner( "<span class='" + classes.cellContentLabels + "'></span>" );
|
228 |
+
$cells.prepend( "<b class='" + classes.cellLabels + "'>" + html + "</b>" );
|
229 |
+
}
|
230 |
+
}
|
231 |
+
});
|
232 |
+
};
|
233 |
+
|
234 |
+
Stack.prototype.destroy = function() {
|
235 |
+
this.$table.removeClass( classes.stackTable );
|
236 |
+
this.$table.find( '.' + classes.cellLabels ).remove();
|
237 |
+
this.$table.find( '.' + classes.cellContentLabels ).each(function() {
|
238 |
+
$( this ).replaceWith( this.childNodes );
|
239 |
+
});
|
240 |
+
};
|
241 |
+
|
242 |
+
// on tablecreate, init
|
243 |
+
$( document ).on( "tablesawcreate", function( e, Tablesaw, colstart ){
|
244 |
+
if( Tablesaw.mode === 'stack' ){
|
245 |
+
var table = new Stack( Tablesaw.table );
|
246 |
+
table.init( colstart );
|
247 |
+
}
|
248 |
+
|
249 |
+
} );
|
250 |
+
|
251 |
+
$( document ).on( "tablesawdestroy", function( e, Tablesaw ){
|
252 |
+
|
253 |
+
if( Tablesaw.mode === 'stack' ){
|
254 |
+
$( Tablesaw.table ).data( data.obj ).destroy();
|
255 |
+
}
|
256 |
+
|
257 |
+
} );
|
258 |
+
|
259 |
+
}( this, jQuery ));
|
260 |
+
;(function( $ ) {
|
261 |
+
var pluginName = "tablesawbtn",
|
262 |
+
methods = {
|
263 |
+
_create: function(){
|
264 |
+
return $( this ).each(function() {
|
265 |
+
$( this )
|
266 |
+
.trigger( "beforecreate." + pluginName )
|
267 |
+
[ pluginName ]( "_init" )
|
268 |
+
.trigger( "create." + pluginName );
|
269 |
+
});
|
270 |
+
},
|
271 |
+
_init: function(){
|
272 |
+
var oEl = $( this ),
|
273 |
+
sel = this.getElementsByTagName( "select" )[ 0 ];
|
274 |
+
|
275 |
+
if( sel ) {
|
276 |
+
$( this )
|
277 |
+
.addClass( "btn-select" )
|
278 |
+
[ pluginName ]( "_select", sel );
|
279 |
+
}
|
280 |
+
return oEl;
|
281 |
+
},
|
282 |
+
_select: function( sel ) {
|
283 |
+
var update = function( oEl, sel ) {
|
284 |
+
var opts = $( sel ).find( "option" ),
|
285 |
+
label, el, children;
|
286 |
+
|
287 |
+
opts.each(function() {
|
288 |
+
var opt = this;
|
289 |
+
if( opt.selected ) {
|
290 |
+
label = document.createTextNode( opt.text );
|
291 |
+
}
|
292 |
+
});
|
293 |
+
|
294 |
+
children = oEl.childNodes;
|
295 |
+
if( opts.length > 0 ){
|
296 |
+
for( var i = 0, l = children.length; i < l; i++ ) {
|
297 |
+
el = children[ i ];
|
298 |
+
|
299 |
+
if( el && el.nodeType === 3 ) {
|
300 |
+
oEl.replaceChild( label, el );
|
301 |
+
}
|
302 |
+
}
|
303 |
+
}
|
304 |
+
};
|
305 |
+
|
306 |
+
update( this, sel );
|
307 |
+
$( this ).bind( "change refresh", function() {
|
308 |
+
update( this, sel );
|
309 |
+
});
|
310 |
+
}
|
311 |
+
};
|
312 |
+
|
313 |
+
// Collection method.
|
314 |
+
$.fn[ pluginName ] = function( arrg, a, b, c ) {
|
315 |
+
return this.each(function() {
|
316 |
+
|
317 |
+
// if it's a method
|
318 |
+
if( arrg && typeof( arrg ) === "string" ){
|
319 |
+
return $.fn[ pluginName ].prototype[ arrg ].call( this, a, b, c );
|
320 |
+
}
|
321 |
+
|
322 |
+
// don't re-init
|
323 |
+
if( $( this ).data( pluginName + "active" ) ){
|
324 |
+
return $( this );
|
325 |
+
}
|
326 |
+
|
327 |
+
// otherwise, init
|
328 |
+
|
329 |
+
$( this ).data( pluginName + "active", true );
|
330 |
+
$.fn[ pluginName ].prototype._create.call( this );
|
331 |
+
});
|
332 |
+
};
|
333 |
+
|
334 |
+
// add methods
|
335 |
+
$.extend( $.fn[ pluginName ].prototype, methods );
|
336 |
+
|
337 |
+
}( jQuery ));
|
338 |
+
;(function( win, $, undefined ){
|
339 |
+
|
340 |
+
var ColumnToggle = function( element ) {
|
341 |
+
|
342 |
+
this.$table = $( element );
|
343 |
+
|
344 |
+
this.classes = {
|
345 |
+
columnToggleTable: 'tablesaw-columntoggle',
|
346 |
+
columnBtnContain: 'tablesaw-columntoggle-btnwrap tablesaw-advance',
|
347 |
+
columnBtn: 'tablesaw-columntoggle-btn tablesaw-nav-btn down',
|
348 |
+
popup: 'tablesaw-columntoggle-popup',
|
349 |
+
priorityPrefix: 'tablesaw-priority-',
|
350 |
+
// TODO duplicate class, also in tables.js
|
351 |
+
toolbar: 'tablesaw-bar'
|
352 |
+
};
|
353 |
+
|
354 |
+
// Expose headers and allHeaders properties on the widget
|
355 |
+
// headers references the THs within the first TR in the table
|
356 |
+
this.headers = this.$table.find( 'tr:first > th' );
|
357 |
+
|
358 |
+
this.$table.data( 'tablesaw-coltoggle', this );
|
359 |
+
};
|
360 |
+
|
361 |
+
ColumnToggle.prototype.init = function() {
|
362 |
+
|
363 |
+
var tableId,
|
364 |
+
id,
|
365 |
+
$menuButton,
|
366 |
+
$popup,
|
367 |
+
$menu,
|
368 |
+
$btnContain,
|
369 |
+
self = this;
|
370 |
+
|
371 |
+
this.$table.addClass( this.classes.columnToggleTable );
|
372 |
+
|
373 |
+
tableId = this.$table.attr( "id" );
|
374 |
+
id = tableId + "-popup";
|
375 |
+
$btnContain = $( "<div class='" + this.classes.columnBtnContain + "'></div>" );
|
376 |
+
$menuButton = $( "<a href='#" + id + "' class='btn btn-micro " + this.classes.columnBtn +"' data-popup-link>" +
|
377 |
+
"<span>" + Tablesaw.i18n.columnBtnText + "</span></a>" );
|
378 |
+
$popup = $( "<div class='dialog-table-coltoggle " + this.classes.popup + "' id='" + id + "'></div>" );
|
379 |
+
$menu = $( "<div class='btn-group'></div>" );
|
380 |
+
|
381 |
+
var hasNonPersistentHeaders = false;
|
382 |
+
$( this.headers ).not( "td" ).each( function() {
|
383 |
+
var $this = $( this ),
|
384 |
+
priority = $this.attr("data-tablesaw-priority"),
|
385 |
+
$cells = self.$getCells( this );
|
386 |
+
|
387 |
+
if( priority && priority !== "persist" ) {
|
388 |
+
$cells.addClass( self.classes.priorityPrefix + priority );
|
389 |
+
|
390 |
+
$("<label><input type='checkbox' checked>" + $this.text() + "</label>" )
|
391 |
+
.appendTo( $menu )
|
392 |
+
.children( 0 )
|
393 |
+
.data( "tablesaw-header", this );
|
394 |
+
|
395 |
+
hasNonPersistentHeaders = true;
|
396 |
+
}
|
397 |
+
});
|
398 |
+
|
399 |
+
if( !hasNonPersistentHeaders ) {
|
400 |
+
$menu.append( '<label>' + Tablesaw.i18n.columnsDialogError + '</label>' );
|
401 |
+
}
|
402 |
+
|
403 |
+
$menu.appendTo( $popup );
|
404 |
+
|
405 |
+
// bind change event listeners to inputs - TODO: move to a private method?
|
406 |
+
$menu.find( 'input[type="checkbox"]' ).on( "change", function(e) {
|
407 |
+
var checked = e.target.checked;
|
408 |
+
|
409 |
+
self.$getCellsFromCheckbox( e.target )
|
410 |
+
.toggleClass( "tablesaw-cell-hidden", !checked )
|
411 |
+
.toggleClass( "tablesaw-cell-visible", checked );
|
412 |
+
|
413 |
+
self.$table.trigger( 'tablesawcolumns' );
|
414 |
+
});
|
415 |
+
|
416 |
+
$menuButton.appendTo( $btnContain );
|
417 |
+
$btnContain.appendTo( this.$table.prev().filter( '.' + this.classes.toolbar ) );
|
418 |
+
|
419 |
+
|
420 |
+
function closePopup( event ) {
|
421 |
+
// Click came from inside the popup, ignore.
|
422 |
+
if( event && $( event.target ).closest( "." + self.classes.popup ).length ) {
|
423 |
+
return;
|
424 |
+
}
|
425 |
+
|
426 |
+
$( document ).unbind( 'click.' + tableId );
|
427 |
+
$menuButton.removeClass( 'up' ).addClass( 'down' );
|
428 |
+
$btnContain.removeClass( 'visible' );
|
429 |
+
}
|
430 |
+
|
431 |
+
var closeTimeout;
|
432 |
+
function openPopup() {
|
433 |
+
$btnContain.addClass( 'visible' );
|
434 |
+
$menuButton.removeClass( 'down' ).addClass( 'up' );
|
435 |
+
|
436 |
+
$( document ).unbind( 'click.' + tableId, closePopup );
|
437 |
+
|
438 |
+
window.clearTimeout( closeTimeout );
|
439 |
+
closeTimeout = window.setTimeout(function() {
|
440 |
+
$( document ).one( 'click.' + tableId, closePopup );
|
441 |
+
}, 15 );
|
442 |
+
}
|
443 |
+
|
444 |
+
$menuButton.on( "click.tablesaw", function( event ) {
|
445 |
+
event.preventDefault();
|
446 |
+
|
447 |
+
if( !$btnContain.is( ".visible" ) ) {
|
448 |
+
openPopup();
|
449 |
+
} else {
|
450 |
+
closePopup();
|
451 |
+
}
|
452 |
+
});
|
453 |
+
|
454 |
+
$popup.appendTo( $btnContain );
|
455 |
+
|
456 |
+
this.$menu = $menu;
|
457 |
+
|
458 |
+
$(window).on( "resize." + tableId, function(){
|
459 |
+
self.refreshToggle();
|
460 |
+
});
|
461 |
+
|
462 |
+
this.refreshToggle();
|
463 |
+
};
|
464 |
+
|
465 |
+
ColumnToggle.prototype.$getCells = function( th ) {
|
466 |
+
return $( th ).add( th.cells );
|
467 |
+
};
|
468 |
+
|
469 |
+
ColumnToggle.prototype.$getCellsFromCheckbox = function( checkbox ) {
|
470 |
+
var th = $( checkbox ).data( "tablesaw-header" );
|
471 |
+
return this.$getCells( th );
|
472 |
+
};
|
473 |
+
|
474 |
+
ColumnToggle.prototype.refreshToggle = function() {
|
475 |
+
var self = this;
|
476 |
+
this.$menu.find( "input" ).each( function() {
|
477 |
+
this.checked = self.$getCellsFromCheckbox( this ).eq( 0 ).css( "display" ) === "table-cell";
|
478 |
+
});
|
479 |
+
};
|
480 |
+
|
481 |
+
ColumnToggle.prototype.refreshPriority = function(){
|
482 |
+
var self = this;
|
483 |
+
$(this.headers).not( "td" ).each( function() {
|
484 |
+
var $this = $( this ),
|
485 |
+
priority = $this.attr("data-tablesaw-priority"),
|
486 |
+
$cells = $this.add( this.cells );
|
487 |
+
|
488 |
+
if( priority && priority !== "persist" ) {
|
489 |
+
$cells.addClass( self.classes.priorityPrefix + priority );
|
490 |
+
}
|
491 |
+
});
|
492 |
+
};
|
493 |
+
|
494 |
+
ColumnToggle.prototype.destroy = function() {
|
495 |
+
// table toolbars, document and window .tableId events
|
496 |
+
// removed in parent tables.js destroy method
|
497 |
+
|
498 |
+
this.$table.removeClass( this.classes.columnToggleTable );
|
499 |
+
this.$table.find( 'th, td' ).each(function() {
|
500 |
+
var $cell = $( this );
|
501 |
+
$cell.removeClass( 'tablesaw-cell-hidden' )
|
502 |
+
.removeClass( 'tablesaw-cell-visible' );
|
503 |
+
|
504 |
+
this.className = this.className.replace( /\bui\-table\-priority\-\d\b/g, '' );
|
505 |
+
});
|
506 |
+
};
|
507 |
+
|
508 |
+
// on tablecreate, init
|
509 |
+
$( document ).on( "tablesawcreate", function( e, Tablesaw ){
|
510 |
+
|
511 |
+
if( Tablesaw.mode === 'columntoggle' ){
|
512 |
+
var table = new ColumnToggle( Tablesaw.table );
|
513 |
+
table.init();
|
514 |
+
}
|
515 |
+
|
516 |
+
} );
|
517 |
+
|
518 |
+
$( document ).on( "tablesawdestroy", function( e, Tablesaw ){
|
519 |
+
if( Tablesaw.mode === 'columntoggle' ){
|
520 |
+
$( Tablesaw.table ).data( 'tablesaw-coltoggle' ).destroy();
|
521 |
+
}
|
522 |
+
} );
|
523 |
+
|
524 |
+
}( this, jQuery ));
|
525 |
+
;(function( win, $, undefined ){
|
526 |
+
|
527 |
+
$.extend( Tablesaw.config, {
|
528 |
+
swipe: {
|
529 |
+
horizontalThreshold: 15,
|
530 |
+
verticalThreshold: 30
|
531 |
+
}
|
532 |
+
});
|
533 |
+
|
534 |
+
function isIE8() {
|
535 |
+
var div = document.createElement('div'),
|
536 |
+
all = div.getElementsByTagName('i');
|
537 |
+
|
538 |
+
div.innerHTML = '<!--[if lte IE 8]><i></i><![endif]-->';
|
539 |
+
|
540 |
+
return !!all.length;
|
541 |
+
}
|
542 |
+
|
543 |
+
var classes = {
|
544 |
+
// TODO duplicate class, also in tables.js
|
545 |
+
toolbar: "tablesaw-bar",
|
546 |
+
hideBtn: "disabled",
|
547 |
+
persistWidths: "tablesaw-fix-persist",
|
548 |
+
allColumnsVisible: 'tablesaw-all-cols-visible'
|
549 |
+
};
|
550 |
+
|
551 |
+
function createSwipeTable( $table ){
|
552 |
+
|
553 |
+
var $btns = $( "<div class='tablesaw-advance'></div>" ),
|
554 |
+
$prevBtn = $( "<a href='#' class='tablesaw-nav-btn btn btn-micro left' title='Previous Column'></a>" ).appendTo( $btns ),
|
555 |
+
$nextBtn = $( "<a href='#' class='tablesaw-nav-btn btn btn-micro right' title='Next Column'></a>" ).appendTo( $btns ),
|
556 |
+
$headerCells = $table.find( "thead th" ),
|
557 |
+
$headerCellsNoPersist = $headerCells.not( '[data-tablesaw-priority="persist"]' ),
|
558 |
+
headerWidths = [],
|
559 |
+
$head = $( document.head || 'head' ),
|
560 |
+
tableId = $table.attr( 'id' ),
|
561 |
+
// TODO switch this to an nth-child feature test
|
562 |
+
supportsNthChild = !isIE8();
|
563 |
+
|
564 |
+
if( !$headerCells.length ) {
|
565 |
+
throw new Error( "tablesaw swipe: no header cells found. Are you using <th> inside of <thead>?" );
|
566 |
+
}
|
567 |
+
|
568 |
+
// Calculate initial widths
|
569 |
+
$table.css('width', 'auto');
|
570 |
+
$headerCells.each(function() {
|
571 |
+
headerWidths.push( $( this ).outerWidth() );
|
572 |
+
});
|
573 |
+
$table.css( 'width', '' );
|
574 |
+
|
575 |
+
$btns.appendTo( $table.prev().filter( '.tablesaw-bar' ) );
|
576 |
+
|
577 |
+
$table.addClass( "tablesaw-swipe" );
|
578 |
+
|
579 |
+
if( !tableId ) {
|
580 |
+
tableId = 'tableswipe-' + Math.round( Math.random() * 10000 );
|
581 |
+
$table.attr( 'id', tableId );
|
582 |
+
}
|
583 |
+
|
584 |
+
function $getCells( headerCell ) {
|
585 |
+
return $( headerCell.cells ).add( headerCell );
|
586 |
+
}
|
587 |
+
|
588 |
+
function showColumn( headerCell ) {
|
589 |
+
$getCells( headerCell ).removeClass( 'tablesaw-cell-hidden' );
|
590 |
+
}
|
591 |
+
|
592 |
+
function hideColumn( headerCell ) {
|
593 |
+
$getCells( headerCell ).addClass( 'tablesaw-cell-hidden' );
|
594 |
+
}
|
595 |
+
|
596 |
+
function persistColumn( headerCell ) {
|
597 |
+
$getCells( headerCell ).addClass( 'tablesaw-cell-persist' );
|
598 |
+
}
|
599 |
+
|
600 |
+
function isPersistent( headerCell ) {
|
601 |
+
return $( headerCell ).is( '[data-tablesaw-priority="persist"]' );
|
602 |
+
}
|
603 |
+
|
604 |
+
function unmaintainWidths() {
|
605 |
+
$table.removeClass( classes.persistWidths );
|
606 |
+
$( '#' + tableId + '-persist' ).remove();
|
607 |
+
}
|
608 |
+
|
609 |
+
function maintainWidths() {
|
610 |
+
var prefix = '#' + tableId + '.tablesaw-swipe ',
|
611 |
+
styles = [],
|
612 |
+
tableWidth = $table.width(),
|
613 |
+
hash = [],
|
614 |
+
newHash;
|
615 |
+
|
616 |
+
$headerCells.each(function( index ) {
|
617 |
+
var width;
|
618 |
+
if( isPersistent( this ) ) {
|
619 |
+
width = $( this ).outerWidth();
|
620 |
+
|
621 |
+
// Only save width on non-greedy columns (take up less than 75% of table width)
|
622 |
+
if( width < tableWidth * 0.75 ) {
|
623 |
+
hash.push( index + '-' + width );
|
624 |
+
styles.push( prefix + ' .tablesaw-cell-persist:nth-child(' + ( index + 1 ) + ') { width: ' + width + 'px; }' );
|
625 |
+
}
|
626 |
+
}
|
627 |
+
});
|
628 |
+
newHash = hash.join( '_' );
|
629 |
+
|
630 |
+
$table.addClass( classes.persistWidths );
|
631 |
+
|
632 |
+
var $style = $( '#' + tableId + '-persist' );
|
633 |
+
// If style element not yet added OR if the widths have changed
|
634 |
+
if( !$style.length || $style.data( 'hash' ) !== newHash ) {
|
635 |
+
// Remove existing
|
636 |
+
$style.remove();
|
637 |
+
|
638 |
+
if( styles.length ) {
|
639 |
+
$( '<style>' + styles.join( "\n" ) + '</style>' )
|
640 |
+
.attr( 'id', tableId + '-persist' )
|
641 |
+
.data( 'hash', newHash )
|
642 |
+
.appendTo( $head );
|
643 |
+
}
|
644 |
+
}
|
645 |
+
}
|
646 |
+
|
647 |
+
function getNext(){
|
648 |
+
var next = [],
|
649 |
+
checkFound;
|
650 |
+
|
651 |
+
$headerCellsNoPersist.each(function( i ) {
|
652 |
+
var $t = $( this ),
|
653 |
+
isHidden = $t.css( "display" ) === "none" || $t.is( ".tablesaw-cell-hidden" );
|
654 |
+
|
655 |
+
if( !isHidden && !checkFound ) {
|
656 |
+
checkFound = true;
|
657 |
+
next[ 0 ] = i;
|
658 |
+
} else if( isHidden && checkFound ) {
|
659 |
+
next[ 1 ] = i;
|
660 |
+
|
661 |
+
return false;
|
662 |
+
}
|
663 |
+
});
|
664 |
+
|
665 |
+
return next;
|
666 |
+
}
|
667 |
+
|
668 |
+
function getPrev(){
|
669 |
+
var next = getNext();
|
670 |
+
return [ next[ 1 ] - 1 , next[ 0 ] - 1 ];
|
671 |
+
}
|
672 |
+
|
673 |
+
function nextpair( fwd ){
|
674 |
+
return fwd ? getNext() : getPrev();
|
675 |
+
}
|
676 |
+
|
677 |
+
function canAdvance( pair ){
|
678 |
+
return pair[ 1 ] > -1 && pair[ 1 ] < $headerCellsNoPersist.length;
|
679 |
+
}
|
680 |
+
|
681 |
+
function matchesMedia() {
|
682 |
+
var matchMedia = $table.attr( "data-tablesaw-swipe-media" );
|
683 |
+
return !matchMedia || ( "matchMedia" in win ) && win.matchMedia( matchMedia ).matches;
|
684 |
+
}
|
685 |
+
|
686 |
+
function fakeBreakpoints() {
|
687 |
+
if( !matchesMedia() ) {
|
688 |
+
return;
|
689 |
+
}
|
690 |
+
|
691 |
+
var extraPaddingPixels = 20,
|
692 |
+
containerWidth = $table.parent().width(),
|
693 |
+
persist = [],
|
694 |
+
sum = 0,
|
695 |
+
sums = [],
|
696 |
+
visibleNonPersistantCount = $headerCells.length;
|
697 |
+
|
698 |
+
$headerCells.each(function( index ) {
|
699 |
+
var $t = $( this ),
|
700 |
+
isPersist = $t.is( '[data-tablesaw-priority="persist"]' );
|
701 |
+
|
702 |
+
persist.push( isPersist );
|
703 |
+
|
704 |
+
sum += headerWidths[ index ] + ( isPersist ? 0 : extraPaddingPixels );
|
705 |
+
sums.push( sum );
|
706 |
+
|
707 |
+
// is persistent or is hidden
|
708 |
+
if( isPersist || sum > containerWidth ) {
|
709 |
+
visibleNonPersistantCount--;
|
710 |
+
}
|
711 |
+
});
|
712 |
+
|
713 |
+
var needsNonPersistentColumn = visibleNonPersistantCount === 0;
|
714 |
+
|
715 |
+
$headerCells.each(function( index ) {
|
716 |
+
if( persist[ index ] ) {
|
717 |
+
|
718 |
+
// for visual box-shadow
|
719 |
+
persistColumn( this );
|
720 |
+
return;
|
721 |
+
}
|
722 |
+
|
723 |
+
if( sums[ index ] <= containerWidth || needsNonPersistentColumn ) {
|
724 |
+
needsNonPersistentColumn = false;
|
725 |
+
showColumn( this );
|
726 |
+
} else {
|
727 |
+
hideColumn( this );
|
728 |
+
}
|
729 |
+
});
|
730 |
+
|
731 |
+
if( supportsNthChild ) {
|
732 |
+
unmaintainWidths();
|
733 |
+
}
|
734 |
+
$table.trigger( 'tablesawcolumns' );
|
735 |
+
}
|
736 |
+
|
737 |
+
function advance( fwd ){
|
738 |
+
var pair = nextpair( fwd );
|
739 |
+
if( canAdvance( pair ) ){
|
740 |
+
if( isNaN( pair[ 0 ] ) ){
|
741 |
+
if( fwd ){
|
742 |
+
pair[0] = 0;
|
743 |
+
}
|
744 |
+
else {
|
745 |
+
pair[0] = $headerCellsNoPersist.length - 1;
|
746 |
+
}
|
747 |
+
}
|
748 |
+
|
749 |
+
if( supportsNthChild ) {
|
750 |
+
maintainWidths();
|
751 |
+
}
|
752 |
+
|
753 |
+
hideColumn( $headerCellsNoPersist.get( pair[ 0 ] ) );
|
754 |
+
showColumn( $headerCellsNoPersist.get( pair[ 1 ] ) );
|
755 |
+
|
756 |
+
$table.trigger( 'tablesawcolumns' );
|
757 |
+
}
|
758 |
+
}
|
759 |
+
|
760 |
+
$prevBtn.add( $nextBtn ).click(function( e ){
|
761 |
+
advance( !!$( e.target ).closest( $nextBtn ).length );
|
762 |
+
e.preventDefault();
|
763 |
+
});
|
764 |
+
|
765 |
+
function getCoord( event, key ) {
|
766 |
+
return ( event.touches || event.originalEvent.touches )[ 0 ][ key ];
|
767 |
+
}
|
768 |
+
|
769 |
+
$table
|
770 |
+
.bind( "touchstart.swipetoggle", function( e ){
|
771 |
+
var originX = getCoord( e, 'pageX' ),
|
772 |
+
originY = getCoord( e, 'pageY' ),
|
773 |
+
x,
|
774 |
+
y;
|
775 |
+
|
776 |
+
$( win ).off( "resize", fakeBreakpoints );
|
777 |
+
|
778 |
+
$( this )
|
779 |
+
.bind( "touchmove", function( e ){
|
780 |
+
x = getCoord( e, 'pageX' );
|
781 |
+
y = getCoord( e, 'pageY' );
|
782 |
+
var cfg = Tablesaw.config.swipe;
|
783 |
+
if( Math.abs( x - originX ) > cfg.horizontalThreshold && Math.abs( y - originY ) < cfg.verticalThreshold ) {
|
784 |
+
e.preventDefault();
|
785 |
+
}
|
786 |
+
})
|
787 |
+
.bind( "touchend.swipetoggle", function(){
|
788 |
+
var cfg = Tablesaw.config.swipe;
|
789 |
+
if( Math.abs( y - originY ) < cfg.verticalThreshold ) {
|
790 |
+
if( x - originX < -1 * cfg.horizontalThreshold ){
|
791 |
+
advance( true );
|
792 |
+
}
|
793 |
+
if( x - originX > cfg.horizontalThreshold ){
|
794 |
+
advance( false );
|
795 |
+
}
|
796 |
+
}
|
797 |
+
|
798 |
+
window.setTimeout(function() {
|
799 |
+
$( win ).on( "resize", fakeBreakpoints );
|
800 |
+
}, 300);
|
801 |
+
$( this ).unbind( "touchmove touchend" );
|
802 |
+
});
|
803 |
+
|
804 |
+
})
|
805 |
+
.bind( "tablesawcolumns.swipetoggle", function(){
|
806 |
+
var canGoPrev = canAdvance( getPrev() );
|
807 |
+
var canGoNext = canAdvance( getNext() );
|
808 |
+
$prevBtn[ canGoPrev ? "removeClass" : "addClass" ]( classes.hideBtn );
|
809 |
+
$nextBtn[ canGoNext ? "removeClass" : "addClass" ]( classes.hideBtn );
|
810 |
+
|
811 |
+
$prevBtn.closest( "." + classes.toolbar )[ !canGoPrev && !canGoNext ? 'addClass' : 'removeClass' ]( classes.allColumnsVisible );
|
812 |
+
})
|
813 |
+
.bind( "tablesawnext.swipetoggle", function(){
|
814 |
+
advance( true );
|
815 |
+
} )
|
816 |
+
.bind( "tablesawprev.swipetoggle", function(){
|
817 |
+
advance( false );
|
818 |
+
} )
|
819 |
+
.bind( "tablesawdestroy.swipetoggle", function(){
|
820 |
+
var $t = $( this );
|
821 |
+
|
822 |
+
$t.removeClass( 'tablesaw-swipe' );
|
823 |
+
$t.prev().filter( '.tablesaw-bar' ).find( '.tablesaw-advance' ).remove();
|
824 |
+
$( win ).off( "resize", fakeBreakpoints );
|
825 |
+
|
826 |
+
$t.unbind( ".swipetoggle" );
|
827 |
+
});
|
828 |
+
|
829 |
+
fakeBreakpoints();
|
830 |
+
$( win ).on( "resize", fakeBreakpoints );
|
831 |
+
}
|
832 |
+
|
833 |
+
|
834 |
+
|
835 |
+
// on tablecreate, init
|
836 |
+
$( document ).on( "tablesawcreate", function( e, Tablesaw ){
|
837 |
+
|
838 |
+
if( Tablesaw.mode === 'swipe' ){
|
839 |
+
createSwipeTable( Tablesaw.$table );
|
840 |
+
}
|
841 |
+
|
842 |
+
} );
|
843 |
+
|
844 |
+
}( this, jQuery ));
|
845 |
+
|
846 |
+
;(function( $ ) {
|
847 |
+
function getSortValue( cell ) {
|
848 |
+
return $.map( cell.childNodes, function( el ) {
|
849 |
+
var $el = $( el );
|
850 |
+
if( $el.is( 'input, select' ) ) {
|
851 |
+
return $el.val();
|
852 |
+
} else if( $el.hasClass( 'tablesaw-cell-label' ) ) {
|
853 |
+
return;
|
854 |
+
}
|
855 |
+
return $.trim( $el.text() );
|
856 |
+
}).join( '' );
|
857 |
+
}
|
858 |
+
|
859 |
+
var pluginName = "tablesaw-sortable",
|
860 |
+
initSelector = "table[data-" + pluginName + "]",
|
861 |
+
sortableSwitchSelector = "[data-" + pluginName + "-switch]",
|
862 |
+
attrs = {
|
863 |
+
defaultCol: "data-tablesaw-sortable-default-col",
|
864 |
+
numericCol: "data-tablesaw-sortable-numeric"
|
865 |
+
},
|
866 |
+
classes = {
|
867 |
+
head: pluginName + "-head",
|
868 |
+
ascend: pluginName + "-ascending",
|
869 |
+
descend: pluginName + "-descending",
|
870 |
+
switcher: pluginName + "-switch",
|
871 |
+
tableToolbar: 'tablesaw-toolbar',
|
872 |
+
sortButton: pluginName + "-btn"
|
873 |
+
},
|
874 |
+
methods = {
|
875 |
+
_create: function( o ){
|
876 |
+
return $( this ).each(function() {
|
877 |
+
var init = $( this ).data( "init" + pluginName );
|
878 |
+
if( init ) {
|
879 |
+
return false;
|
880 |
+
}
|
881 |
+
$( this )
|
882 |
+
.data( "init"+ pluginName, true )
|
883 |
+
.trigger( "beforecreate." + pluginName )
|
884 |
+
[ pluginName ]( "_init" , o )
|
885 |
+
.trigger( "create." + pluginName );
|
886 |
+
});
|
887 |
+
},
|
888 |
+
_init: function(){
|
889 |
+
var el = $( this ),
|
890 |
+
heads,
|
891 |
+
$switcher;
|
892 |
+
|
893 |
+
var addClassToTable = function(){
|
894 |
+
el.addClass( pluginName );
|
895 |
+
},
|
896 |
+
addClassToHeads = function( h ){
|
897 |
+
$.each( h , function( i , v ){
|
898 |
+
$( v ).addClass( classes.head );
|
899 |
+
});
|
900 |
+
},
|
901 |
+
makeHeadsActionable = function( h , fn ){
|
902 |
+
$.each( h , function( i , v ){
|
903 |
+
var b = $( "<button class='" + classes.sortButton + "'/>" );
|
904 |
+
b.bind( "click" , { col: v } , fn );
|
905 |
+
$( v ).wrapInner( b );
|
906 |
+
});
|
907 |
+
},
|
908 |
+
clearOthers = function( sibs ){
|
909 |
+
$.each( sibs , function( i , v ){
|
910 |
+
var col = $( v );
|
911 |
+
col.removeAttr( attrs.defaultCol );
|
912 |
+
col.removeClass( classes.ascend );
|
913 |
+
col.removeClass( classes.descend );
|
914 |
+
});
|
915 |
+
},
|
916 |
+
headsOnAction = function( e ){
|
917 |
+
if( $( e.target ).is( 'a[href]' ) ) {
|
918 |
+
return;
|
919 |
+
}
|
920 |
+
|
921 |
+
e.stopPropagation();
|
922 |
+
var head = $( this ).parent(),
|
923 |
+
v = e.data.col,
|
924 |
+
newSortValue = heads.index( head );
|
925 |
+
|
926 |
+
clearOthers( head.siblings() );
|
927 |
+
if( head.hasClass( classes.descend ) ){
|
928 |
+
el[ pluginName ]( "sortBy" , v , true);
|
929 |
+
newSortValue += '_asc';
|
930 |
+
} else {
|
931 |
+
el[ pluginName ]( "sortBy" , v );
|
932 |
+
newSortValue += '_desc';
|
933 |
+
}
|
934 |
+
if( $switcher ) {
|
935 |
+
$switcher.find( 'select' ).val( newSortValue ).trigger( 'refresh' );
|
936 |
+
}
|
937 |
+
|
938 |
+
e.preventDefault();
|
939 |
+
},
|
940 |
+
handleDefault = function( heads ){
|
941 |
+
$.each( heads , function( idx , el ){
|
942 |
+
var $el = $( el );
|
943 |
+
if( $el.is( "[" + attrs.defaultCol + "]" ) ){
|
944 |
+
if( !$el.hasClass( classes.descend ) ) {
|
945 |
+
$el.addClass( classes.ascend );
|
946 |
+
}
|
947 |
+
}
|
948 |
+
});
|
949 |
+
},
|
950 |
+
addSwitcher = function( heads ){
|
951 |
+
$switcher = $( '<div>' ).addClass( classes.switcher ).addClass( classes.tableToolbar ).html(function() {
|
952 |
+
var html = [ '<label>' + Tablesaw.i18n.sort + ':' ];
|
953 |
+
|
954 |
+
html.push( '<span class="btn btn-small"> <select>' );
|
955 |
+
heads.each(function( j ) {
|
956 |
+
var $t = $( this );
|
957 |
+
var isDefaultCol = $t.is( "[" + attrs.defaultCol + "]" );
|
958 |
+
var isDescending = $t.hasClass( classes.descend );
|
959 |
+
|
960 |
+
var hasNumericAttribute = $t.is( '[data-sortable-numeric]' );
|
961 |
+
var numericCount = 0;
|
962 |
+
// Check only the first four rows to see if the column is numbers.
|
963 |
+
var numericCountMax = 5;
|
964 |
+
|
965 |
+
$( this.cells ).slice( 0, numericCountMax ).each(function() {
|
966 |
+
if( !isNaN( parseInt( getSortValue( this ), 10 ) ) ) {
|
967 |
+
numericCount++;
|
968 |
+
}
|
969 |
+
});
|
970 |
+
var isNumeric = numericCount === numericCountMax;
|
971 |
+
if( !hasNumericAttribute ) {
|
972 |
+
$t.attr( "data-sortable-numeric", isNumeric ? "" : "false" );
|
973 |
+
}
|
974 |
+
|
975 |
+
html.push( '<option' + ( isDefaultCol && !isDescending ? ' selected' : '' ) + ' value="' + j + '_asc">' + $t.text() + ' ' + ( isNumeric ? '↑' : '(A-Z)' ) + '</option>' );
|
976 |
+
html.push( '<option' + ( isDefaultCol && isDescending ? ' selected' : '' ) + ' value="' + j + '_desc">' + $t.text() + ' ' + ( isNumeric ? '↓' : '(Z-A)' ) + '</option>' );
|
977 |
+
});
|
978 |
+
html.push( '</select></span></label>' );
|
979 |
+
|
980 |
+
return html.join('');
|
981 |
+
});
|
982 |
+
|
983 |
+
var $toolbar = el.prev().filter( '.tablesaw-bar' ),
|
984 |
+
$firstChild = $toolbar.children().eq( 0 );
|
985 |
+
|
986 |
+
if( $firstChild.length ) {
|
987 |
+
$switcher.insertBefore( $firstChild );
|
988 |
+
} else {
|
989 |
+
$switcher.appendTo( $toolbar );
|
990 |
+
}
|
991 |
+
$switcher.find( '.btn' ).tablesawbtn();
|
992 |
+
$switcher.find( 'select' ).on( 'change', function() {
|
993 |
+
var val = $( this ).val().split( '_' ),
|
994 |
+
head = heads.eq( val[ 0 ] );
|
995 |
+
|
996 |
+
clearOthers( head.siblings() );
|
997 |
+
el[ pluginName ]( 'sortBy', head.get( 0 ), val[ 1 ] === 'asc' );
|
998 |
+
});
|
999 |
+
};
|
1000 |
+
|
1001 |
+
addClassToTable();
|
1002 |
+
heads = el.find( "thead th[data-" + pluginName + "-col]" );
|
1003 |
+
addClassToHeads( heads );
|
1004 |
+
makeHeadsActionable( heads , headsOnAction );
|
1005 |
+
handleDefault( heads );
|
1006 |
+
|
1007 |
+
if( el.is( sortableSwitchSelector ) ) {
|
1008 |
+
addSwitcher( heads, el.find('tbody tr:nth-child(-n+3)') );
|
1009 |
+
}
|
1010 |
+
},
|
1011 |
+
getColumnNumber: function( col ){
|
1012 |
+
return $( col ).prevAll().length;
|
1013 |
+
},
|
1014 |
+
getTableRows: function(){
|
1015 |
+
return $( this ).find( "tbody tr" );
|
1016 |
+
},
|
1017 |
+
sortRows: function( rows , colNum , ascending, col ){
|
1018 |
+
var cells, fn, sorted;
|
1019 |
+
var getCells = function( rows ){
|
1020 |
+
var cells = [];
|
1021 |
+
$.each( rows , function( i , r ){
|
1022 |
+
var element = $( r ).children().get( colNum );
|
1023 |
+
cells.push({
|
1024 |
+
element: element,
|
1025 |
+
cell: getSortValue( element ),
|
1026 |
+
rowNum: i
|
1027 |
+
});
|
1028 |
+
});
|
1029 |
+
return cells;
|
1030 |
+
},
|
1031 |
+
getSortFxn = function( ascending, forceNumeric ){
|
1032 |
+
var fn,
|
1033 |
+
regex = /[^\-\+\d\.]/g;
|
1034 |
+
if( ascending ){
|
1035 |
+
fn = function( a , b ){
|
1036 |
+
if( forceNumeric ) {
|
1037 |
+
return parseFloat( a.cell.replace( regex, '' ) ) - parseFloat( b.cell.replace( regex, '' ) );
|
1038 |
+
} else {
|
1039 |
+
return a.cell.toLowerCase() > b.cell.toLowerCase() ? 1 : -1;
|
1040 |
+
}
|
1041 |
+
};
|
1042 |
+
} else {
|
1043 |
+
fn = function( a , b ){
|
1044 |
+
if( forceNumeric ) {
|
1045 |
+
return parseFloat( b.cell.replace( regex, '' ) ) - parseFloat( a.cell.replace( regex, '' ) );
|
1046 |
+
} else {
|
1047 |
+
return a.cell.toLowerCase() < b.cell.toLowerCase() ? 1 : -1;
|
1048 |
+
}
|
1049 |
+
};
|
1050 |
+
}
|
1051 |
+
return fn;
|
1052 |
+
},
|
1053 |
+
applyToRows = function( sorted , rows ){
|
1054 |
+
var newRows = [], i, l, cur;
|
1055 |
+
for( i = 0, l = sorted.length ; i < l ; i++ ){
|
1056 |
+
cur = sorted[ i ].rowNum;
|
1057 |
+
newRows.push( rows[cur] );
|
1058 |
+
}
|
1059 |
+
return newRows;
|
1060 |
+
};
|
1061 |
+
|
1062 |
+
cells = getCells( rows );
|
1063 |
+
var customFn = $( col ).data( 'tablesaw-sort' );
|
1064 |
+
fn = ( customFn && typeof customFn === "function" ? customFn( ascending ) : false ) ||
|
1065 |
+
getSortFxn( ascending, $( col ).is( '[data-sortable-numeric]' ) && !$( col ).is( '[data-sortable-numeric="false"]' ) );
|
1066 |
+
sorted = cells.sort( fn );
|
1067 |
+
rows = applyToRows( sorted , rows );
|
1068 |
+
return rows;
|
1069 |
+
},
|
1070 |
+
replaceTableRows: function( rows ){
|
1071 |
+
var el = $( this ),
|
1072 |
+
body = el.find( "tbody" );
|
1073 |
+
body.html( rows );
|
1074 |
+
},
|
1075 |
+
makeColDefault: function( col , a ){
|
1076 |
+
var c = $( col );
|
1077 |
+
c.attr( attrs.defaultCol , "true" );
|
1078 |
+
if( a ){
|
1079 |
+
c.removeClass( classes.descend );
|
1080 |
+
c.addClass( classes.ascend );
|
1081 |
+
} else {
|
1082 |
+
c.removeClass( classes.ascend );
|
1083 |
+
c.addClass( classes.descend );
|
1084 |
+
}
|
1085 |
+
},
|
1086 |
+
sortBy: function( col , ascending ){
|
1087 |
+
var el = $( this ), colNum, rows;
|
1088 |
+
|
1089 |
+
colNum = el[ pluginName ]( "getColumnNumber" , col );
|
1090 |
+
rows = el[ pluginName ]( "getTableRows" );
|
1091 |
+
rows = el[ pluginName ]( "sortRows" , rows , colNum , ascending, col );
|
1092 |
+
el[ pluginName ]( "replaceTableRows" , rows );
|
1093 |
+
el[ pluginName ]( "makeColDefault" , col , ascending );
|
1094 |
+
}
|
1095 |
+
};
|
1096 |
+
|
1097 |
+
// Collection method.
|
1098 |
+
$.fn[ pluginName ] = function( arrg ) {
|
1099 |
+
var args = Array.prototype.slice.call( arguments , 1),
|
1100 |
+
returnVal;
|
1101 |
+
|
1102 |
+
// if it's a method
|
1103 |
+
if( arrg && typeof( arrg ) === "string" ){
|
1104 |
+
returnVal = $.fn[ pluginName ].prototype[ arrg ].apply( this[0], args );
|
1105 |
+
return (typeof returnVal !== "undefined")? returnVal:$(this);
|
1106 |
+
}
|
1107 |
+
// check init
|
1108 |
+
if( !$( this ).data( pluginName + "data" ) ){
|
1109 |
+
$( this ).data( pluginName + "active", true );
|
1110 |
+
$.fn[ pluginName ].prototype._create.call( this , arrg );
|
1111 |
+
}
|
1112 |
+
return $(this);
|
1113 |
+
};
|
1114 |
+
// add methods
|
1115 |
+
$.extend( $.fn[ pluginName ].prototype, methods );
|
1116 |
+
|
1117 |
+
$( document ).on( "tablesawcreate", function( e, Tablesaw ) {
|
1118 |
+
if( Tablesaw.$table.is( initSelector ) ) {
|
1119 |
+
Tablesaw.$table[ pluginName ]();
|
1120 |
+
}
|
1121 |
+
});
|
1122 |
+
|
1123 |
+
}( jQuery ));
|
1124 |
+
|
1125 |
+
;(function( win, $, undefined ){
|
1126 |
+
|
1127 |
+
var MM = {
|
1128 |
+
attr: {
|
1129 |
+
init: 'data-tablesaw-minimap'
|
1130 |
+
}
|
1131 |
+
};
|
1132 |
+
|
1133 |
+
function createMiniMap( $table ){
|
1134 |
+
|
1135 |
+
var $btns = $( '<div class="tablesaw-advance minimap">' ),
|
1136 |
+
$dotNav = $( '<ul class="tablesaw-advance-dots">' ).appendTo( $btns ),
|
1137 |
+
hideDot = 'tablesaw-advance-dots-hide',
|
1138 |
+
$headerCells = $table.find( 'thead th' );
|
1139 |
+
|
1140 |
+
// populate dots
|
1141 |
+
$headerCells.each(function(){
|
1142 |
+
$dotNav.append( '<li><i></i></li>' );
|
1143 |
+
});
|
1144 |
+
|
1145 |
+
$btns.appendTo( $table.prev().filter( '.tablesaw-bar' ) );
|
1146 |
+
|
1147 |
+
function showMinimap( $table ) {
|
1148 |
+
var mq = $table.attr( MM.attr.init );
|
1149 |
+
return !mq || win.matchMedia && win.matchMedia( mq ).matches;
|
1150 |
+
}
|
1151 |
+
|
1152 |
+
function showHideNav(){
|
1153 |
+
if( !showMinimap( $table ) ) {
|
1154 |
+
$btns.hide();
|
1155 |
+
return;
|
1156 |
+
}
|
1157 |
+
$btns.show();
|
1158 |
+
|
1159 |
+
// show/hide dots
|
1160 |
+
var dots = $dotNav.find( "li" ).removeClass( hideDot );
|
1161 |
+
$table.find( "thead th" ).each(function(i){
|
1162 |
+
if( $( this ).css( "display" ) === "none" ){
|
1163 |
+
dots.eq( i ).addClass( hideDot );
|
1164 |
+
}
|
1165 |
+
});
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
// run on init and resize
|
1169 |
+
showHideNav();
|
1170 |
+
$( win ).on( "resize", showHideNav );
|
1171 |
+
|
1172 |
+
|
1173 |
+
$table
|
1174 |
+
.bind( "tablesawcolumns.minimap", function(){
|
1175 |
+
showHideNav();
|
1176 |
+
})
|
1177 |
+
.bind( "tablesawdestroy.minimap", function(){
|
1178 |
+
var $t = $( this );
|
1179 |
+
|
1180 |
+
$t.prev().filter( '.tablesaw-bar' ).find( '.tablesaw-advance' ).remove();
|
1181 |
+
$( win ).off( "resize", showHideNav );
|
1182 |
+
|
1183 |
+
$t.unbind( ".minimap" );
|
1184 |
+
});
|
1185 |
+
}
|
1186 |
+
|
1187 |
+
|
1188 |
+
|
1189 |
+
// on tablecreate, init
|
1190 |
+
$( document ).on( "tablesawcreate", function( e, Tablesaw ){
|
1191 |
+
|
1192 |
+
if( ( Tablesaw.mode === 'swipe' || Tablesaw.mode === 'columntoggle' ) && Tablesaw.$table.is( '[ ' + MM.attr.init + ']' ) ){
|
1193 |
+
createMiniMap( Tablesaw.$table );
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
} );
|
1197 |
+
|
1198 |
+
}( this, jQuery ));
|
1199 |
+
|
1200 |
+
;(function( win, $ ) {
|
1201 |
+
|
1202 |
+
var S = {
|
1203 |
+
selectors: {
|
1204 |
+
init: 'table[data-tablesaw-mode-switch]'
|
1205 |
+
},
|
1206 |
+
attributes: {
|
1207 |
+
excludeMode: 'data-tablesaw-mode-exclude'
|
1208 |
+
},
|
1209 |
+
classes: {
|
1210 |
+
main: 'tablesaw-modeswitch',
|
1211 |
+
toolbar: 'tablesaw-toolbar'
|
1212 |
+
},
|
1213 |
+
modes: [ 'stack', 'swipe', 'columntoggle' ],
|
1214 |
+
init: function( table ) {
|
1215 |
+
var $table = $( table ),
|
1216 |
+
ignoreMode = $table.attr( S.attributes.excludeMode ),
|
1217 |
+
$toolbar = $table.prev().filter( '.tablesaw-bar' ),
|
1218 |
+
modeVal = '',
|
1219 |
+
$switcher = $( '<div>' ).addClass( S.classes.main + ' ' + S.classes.toolbar ).html(function() {
|
1220 |
+
var html = [ '<label>' + Tablesaw.i18n.columns + ':' ],
|
1221 |
+
dataMode = $table.attr( 'data-tablesaw-mode' ),
|
1222 |
+
isSelected;
|
1223 |
+
|
1224 |
+
html.push( '<span class="btn btn-small"> <select>' );
|
1225 |
+
for( var j=0, k = S.modes.length; j<k; j++ ) {
|
1226 |
+
if( ignoreMode && ignoreMode.toLowerCase() === S.modes[ j ] ) {
|
1227 |
+
continue;
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
isSelected = dataMode === S.modes[ j ];
|
1231 |
+
|
1232 |
+
if( isSelected ) {
|
1233 |
+
modeVal = S.modes[ j ];
|
1234 |
+
}
|
1235 |
+
|
1236 |
+
html.push( '<option' +
|
1237 |
+
( isSelected ? ' selected' : '' ) +
|
1238 |
+
' value="' + S.modes[ j ] + '">' + Tablesaw.i18n.modes[ j ] + '</option>' );
|
1239 |
+
}
|
1240 |
+
html.push( '</select></span></label>' );
|
1241 |
+
|
1242 |
+
return html.join('');
|
1243 |
+
});
|
1244 |
+
|
1245 |
+
var $otherToolbarItems = $toolbar.find( '.tablesaw-advance' ).eq( 0 );
|
1246 |
+
if( $otherToolbarItems.length ) {
|
1247 |
+
$switcher.insertBefore( $otherToolbarItems );
|
1248 |
+
} else {
|
1249 |
+
$switcher.appendTo( $toolbar );
|
1250 |
+
}
|
1251 |
+
|
1252 |
+
$switcher.find( '.btn' ).tablesawbtn();
|
1253 |
+
$switcher.find( 'select' ).bind( 'change', S.onModeChange );
|
1254 |
+
},
|
1255 |
+
onModeChange: function() {
|
1256 |
+
var $t = $( this ),
|
1257 |
+
$switcher = $t.closest( '.' + S.classes.main ),
|
1258 |
+
$table = $t.closest( '.tablesaw-bar' ).nextUntil( $table ).eq( 0 ),
|
1259 |
+
val = $t.val();
|
1260 |
+
|
1261 |
+
$switcher.remove();
|
1262 |
+
$table.data( 'table' ).destroy();
|
1263 |
+
|
1264 |
+
$table.attr( 'data-tablesaw-mode', val );
|
1265 |
+
$table.table();
|
1266 |
+
}
|
1267 |
+
};
|
1268 |
+
|
1269 |
+
$( win.document ).on( "tablesawcreate", function( e, Tablesaw ) {
|
1270 |
+
if( Tablesaw.$table.is( S.selectors.init ) ) {
|
1271 |
+
S.init( Tablesaw.table );
|
1272 |
+
}
|
1273 |
+
});
|
1274 |
+
|
1275 |
+
})( this, jQuery );
|
inc/woo-compare-wishlist/assets/js/tablesaw.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
"undefined"==typeof Tablesaw&&(Tablesaw={i18n:{modes:["Stack","Swipe","Toggle"],columns:'Col<span class="a11y-sm">umn</span>s',columnBtnText:"Columns",columnsDialogError:"No eligible columns.",sort:"Sort"},mustard:"querySelector"in document&&(!window.blackberry||window.WebKitPoint)&&!window.operamini}),Tablesaw.config||(Tablesaw.config={}),Tablesaw.mustard&&jQuery(document.documentElement).addClass("tablesaw-enhanced"),function(t){var e="table",a={toolbar:"tablesaw-bar"},s={create:"tablesawcreate",destroy:"tablesawdestroy",refresh:"tablesawrefresh"},n="stack",i="table[data-tablesaw-mode],table[data-tablesaw-sortable]",l=function(e){if(!e)throw new Error("Tablesaw requires an element.");this.table=e,this.$table=t(e),this.mode=this.$table.attr("data-tablesaw-mode")||n,this.init()};l.prototype.init=function(){this.$table.attr("id")||this.$table.attr("id",e+"-"+Math.round(1e4*Math.random())),this.createToolbar();var t=this._initCells();this.$table.trigger(s.create,[this,t])},l.prototype._initCells=function(){var e,a=this.table.querySelectorAll("thead tr"),s=this;return t(a).each(function(){var n=0;t(this).children().each(function(){var t=parseInt(this.getAttribute("colspan"),10),i=":nth-child("+(n+1)+")";if(e=n+1,t)for(var l=0;l<t-1;l++)n++,i+=", :nth-child("+(n+1)+")";this.cells=s.$table.find("tr").not(a[0]).not(this).children().filter(i),n++})}),e},l.prototype.refresh=function(){this._initCells(),this.$table.trigger(s.refresh)},l.prototype.createToolbar=function(){var e=this.$table.prev().filter("."+a.toolbar);e.length||(e=t("<div>").addClass(a.toolbar).insertBefore(this.$table)),this.$toolbar=e,this.mode&&this.$toolbar.addClass("mode-"+this.mode)},l.prototype.destroy=function(){this.$table.prev().filter("."+a.toolbar).each(function(){this.className=this.className.replace(/\bmode\-\w*\b/gi,"")});var n=this.$table.attr("id");t(document).unbind("."+n),t(window).unbind("."+n),this.$table.trigger(s.destroy,[this]),this.$table.removeData(e)},t.fn[e]=function(){return this.each(function(){var a=t(this);if(!a.data(e)){var s=new l(this);a.data(e,s)}})},t(document).on("enhance.tablesaw",function(a){Tablesaw.mustard&&t(a.target).find(i)[e]()})}(jQuery),function(t,e,a){var s={stackTable:"tablesaw-stack",cellLabels:"tablesaw-cell-label",cellContentLabels:"tablesaw-cell-content"},n={obj:"tablesaw-stack"},i={labelless:"data-tablesaw-no-labels",hideempty:"data-tablesaw-hide-empty"},l=function(t){this.$table=e(t),this.labelless=this.$table.is("["+i.labelless+"]"),this.hideempty=this.$table.is("["+i.hideempty+"]"),this.labelless||(this.allHeaders=this.$table.find("th")),this.$table.data(n.obj,this)};l.prototype.init=function(t){if(this.$table.addClass(s.stackTable),!this.labelless){var a=e(this.allHeaders),n=this.hideempty;a.each(function(){var a=e(this),l=e(this.cells).filter(function(){return!(e(this).parent().is("["+i.labelless+"]")||n&&e(this).is(":empty"))}),o=l.not(this).filter("thead th").length&&" tablesaw-cell-label-top",r=a.find(".tablesaw-sortable-btn"),c=r.length?r.html():a.html();if(""!==c)if(o){var d=parseInt(e(this).attr("colspan"),10),h="";d&&(h="td:nth-child("+d+"n + "+t+")"),l.filter(h).prepend("<b class='"+s.cellLabels+o+"'>"+c+"</b>")}else l.wrapInner("<span class='"+s.cellContentLabels+"'></span>"),l.prepend("<b class='"+s.cellLabels+"'>"+c+"</b>")})}},l.prototype.destroy=function(){this.$table.removeClass(s.stackTable),this.$table.find("."+s.cellLabels).remove(),this.$table.find("."+s.cellContentLabels).each(function(){e(this).replaceWith(this.childNodes)})},e(document).on("tablesawcreate",function(t,e,a){if("stack"===e.mode){var s=new l(e.table);s.init(a)}}),e(document).on("tablesawdestroy",function(t,a){"stack"===a.mode&&e(a.table).data(n.obj).destroy()})}(this,jQuery),function(t){var e="tablesawbtn",a={_create:function(){return t(this).each(function(){t(this).trigger("beforecreate."+e)[e]("_init").trigger("create."+e)})},_init:function(){var a=t(this),s=this.getElementsByTagName("select")[0];return s&&t(this).addClass("btn-select")[e]("_select",s),a},_select:function(e){var a=function(e,a){var s,n,i,l=t(a).find("option");if(l.each(function(){var t=this;t.selected&&(s=document.createTextNode(t.text))}),i=e.childNodes,l.length>0)for(var o=0,r=i.length;o<r;o++)n=i[o],n&&3===n.nodeType&&e.replaceChild(s,n)};a(this,e),t(this).bind("change refresh",function(){a(this,e)})}};t.fn[e]=function(a,s,n,i){return this.each(function(){return a&&"string"==typeof a?t.fn[e].prototype[a].call(this,s,n,i):t(this).data(e+"active")?t(this):(t(this).data(e+"active",!0),void t.fn[e].prototype._create.call(this))})},t.extend(t.fn[e].prototype,a)}(jQuery),function(t,e,a){var s=function(t){this.$table=e(t),this.classes={columnToggleTable:"tablesaw-columntoggle",columnBtnContain:"tablesaw-columntoggle-btnwrap tablesaw-advance",columnBtn:"tablesaw-columntoggle-btn tablesaw-nav-btn down",popup:"tablesaw-columntoggle-popup",priorityPrefix:"tablesaw-priority-",toolbar:"tablesaw-bar"},this.headers=this.$table.find("tr:first > th"),this.$table.data("tablesaw-coltoggle",this)};s.prototype.init=function(){function t(t){t&&e(t.target).closest("."+c.classes.popup).length||(e(document).unbind("click."+s),i.removeClass("up").addClass("down"),r.removeClass("visible"))}function a(){r.addClass("visible"),i.removeClass("down").addClass("up"),e(document).unbind("click."+s,t),window.clearTimeout(h),h=window.setTimeout(function(){e(document).one("click."+s,t)},15)}var s,n,i,l,o,r,c=this;this.$table.addClass(this.classes.columnToggleTable),s=this.$table.attr("id"),n=s+"-popup",r=e("<div class='"+this.classes.columnBtnContain+"'></div>"),i=e("<a href='#"+n+"' class='btn btn-micro "+this.classes.columnBtn+"' data-popup-link><span>"+Tablesaw.i18n.columnBtnText+"</span></a>"),l=e("<div class='dialog-table-coltoggle "+this.classes.popup+"' id='"+n+"'></div>"),o=e("<div class='btn-group'></div>");var d=!1;e(this.headers).not("td").each(function(){var t=e(this),a=t.attr("data-tablesaw-priority"),s=c.$getCells(this);a&&"persist"!==a&&(s.addClass(c.classes.priorityPrefix+a),e("<label><input type='checkbox' checked>"+t.text()+"</label>").appendTo(o).children(0).data("tablesaw-header",this),d=!0)}),d||o.append("<label>"+Tablesaw.i18n.columnsDialogError+"</label>"),o.appendTo(l),o.find('input[type="checkbox"]').on("change",function(t){var e=t.target.checked;c.$getCellsFromCheckbox(t.target).toggleClass("tablesaw-cell-hidden",!e).toggleClass("tablesaw-cell-visible",e),c.$table.trigger("tablesawcolumns")}),i.appendTo(r),r.appendTo(this.$table.prev().filter("."+this.classes.toolbar));var h;i.on("click.tablesaw",function(e){e.preventDefault(),r.is(".visible")?t():a()}),l.appendTo(r),this.$menu=o,e(window).on("resize."+s,function(){c.refreshToggle()}),this.refreshToggle()},s.prototype.$getCells=function(t){return e(t).add(t.cells)},s.prototype.$getCellsFromCheckbox=function(t){var a=e(t).data("tablesaw-header");return this.$getCells(a)},s.prototype.refreshToggle=function(){var t=this;this.$menu.find("input").each(function(){this.checked="table-cell"===t.$getCellsFromCheckbox(this).eq(0).css("display")})},s.prototype.refreshPriority=function(){var t=this;e(this.headers).not("td").each(function(){var a=e(this),s=a.attr("data-tablesaw-priority"),n=a.add(this.cells);s&&"persist"!==s&&n.addClass(t.classes.priorityPrefix+s)})},s.prototype.destroy=function(){this.$table.removeClass(this.classes.columnToggleTable),this.$table.find("th, td").each(function(){var t=e(this);t.removeClass("tablesaw-cell-hidden").removeClass("tablesaw-cell-visible"),this.className=this.className.replace(/\bui\-table\-priority\-\d\b/g,"")})},e(document).on("tablesawcreate",function(t,e){if("columntoggle"===e.mode){var a=new s(e.table);a.init()}}),e(document).on("tablesawdestroy",function(t,a){"columntoggle"===a.mode&&e(a.table).data("tablesaw-coltoggle").destroy()})}(this,jQuery),function(t,e,a){function s(){var t=document.createElement("div"),e=t.getElementsByTagName("i");return t.innerHTML="<!--[if lte IE 8]><i></i><![endif]-->",!!e.length}function n(a){function n(t){return e(t.cells).add(t)}function l(t){n(t).removeClass("tablesaw-cell-hidden")}function o(t){n(t).addClass("tablesaw-cell-hidden")}function r(t){n(t).addClass("tablesaw-cell-persist")}function c(t){return e(t).is('[data-tablesaw-priority="persist"]')}function d(){a.removeClass(i.persistWidths),e("#"+N+"-persist").remove()}function h(){var t,s="#"+N+".tablesaw-swipe ",n=[],l=a.width(),o=[];$.each(function(t){var a;c(this)&&(a=e(this).outerWidth(),a<.75*l&&(o.push(t+"-"+a),n.push(s+" .tablesaw-cell-persist:nth-child("+(t+1)+") { width: "+a+"px; }")))}),t=o.join("_"),a.addClass(i.persistWidths);var r=e("#"+N+"-persist");r.length&&r.data("hash")===t||(r.remove(),n.length&&e("<style>"+n.join("\n")+"</style>").attr("id",N+"-persist").data("hash",t).appendTo(B))}function u(){var t,a=[];return x.each(function(s){var n=e(this),i="none"===n.css("display")||n.is(".tablesaw-cell-hidden");if(i||t){if(i&&t)return a[1]=s,!1}else t=!0,a[0]=s}),a}function b(){var t=u();return[t[1]-1,t[0]-1]}function f(t){return t?u():b()}function p(t){return t[1]>-1&&t[1]<x.length}function w(){var e=a.attr("data-tablesaw-swipe-media");return!e||"matchMedia"in t&&t.matchMedia(e).matches}function m(){if(w()){var t=20,s=a.parent().width(),n=[],i=0,c=[],h=$.length;$.each(function(a){var l=e(this),o=l.is('[data-tablesaw-priority="persist"]');n.push(o),i+=k[a]+(o?0:t),c.push(i),(o||i>s)&&h--});var u=0===h;$.each(function(t){return n[t]?void r(this):void(c[t]<=s||u?(u=!1,l(this)):o(this))}),_&&d(),a.trigger("tablesawcolumns")}}function v(t){var e=f(t);p(e)&&(isNaN(e[0])&&(t?e[0]=0:e[0]=x.length-1),_&&h(),o(x.get(e[0])),l(x.get(e[1])),a.trigger("tablesawcolumns"))}function g(t,e){return(t.touches||t.originalEvent.touches)[0][e]}var C=e("<div class='tablesaw-advance'></div>"),y=e("<a href='#' class='tablesaw-nav-btn btn btn-micro left' title='Previous Column'></a>").appendTo(C),T=e("<a href='#' class='tablesaw-nav-btn btn btn-micro right' title='Next Column'></a>").appendTo(C),$=a.find("thead th"),x=$.not('[data-tablesaw-priority="persist"]'),k=[],B=e(document.head||"head"),N=a.attr("id"),_=!s();if(!$.length)throw new Error("tablesaw swipe: no header cells found. Are you using <th> inside of <thead>?");a.css("width","auto"),$.each(function(){k.push(e(this).outerWidth())}),a.css("width",""),C.appendTo(a.prev().filter(".tablesaw-bar")),a.addClass("tablesaw-swipe"),N||(N="tableswipe-"+Math.round(1e4*Math.random()),a.attr("id",N)),y.add(T).click(function(t){v(!!e(t.target).closest(T).length),t.preventDefault()}),a.bind("touchstart.swipetoggle",function(a){var s,n,i=g(a,"pageX"),l=g(a,"pageY");e(t).off("resize",m),e(this).bind("touchmove",function(t){s=g(t,"pageX"),n=g(t,"pageY");var e=Tablesaw.config.swipe;Math.abs(s-i)>e.horizontalThreshold&&Math.abs(n-l)<e.verticalThreshold&&t.preventDefault()}).bind("touchend.swipetoggle",function(){var a=Tablesaw.config.swipe;Math.abs(n-l)<a.verticalThreshold&&(s-i<-1*a.horizontalThreshold&&v(!0),s-i>a.horizontalThreshold&&v(!1)),window.setTimeout(function(){e(t).on("resize",m)},300),e(this).unbind("touchmove touchend")})}).bind("tablesawcolumns.swipetoggle",function(){var t=p(b()),e=p(u());y[t?"removeClass":"addClass"](i.hideBtn),T[e?"removeClass":"addClass"](i.hideBtn),y.closest("."+i.toolbar)[t||e?"removeClass":"addClass"](i.allColumnsVisible)}).bind("tablesawnext.swipetoggle",function(){v(!0)}).bind("tablesawprev.swipetoggle",function(){v(!1)}).bind("tablesawdestroy.swipetoggle",function(){var a=e(this);a.removeClass("tablesaw-swipe"),a.prev().filter(".tablesaw-bar").find(".tablesaw-advance").remove(),e(t).off("resize",m),a.unbind(".swipetoggle")}),m(),e(t).on("resize",m)}e.extend(Tablesaw.config,{swipe:{horizontalThreshold:15,verticalThreshold:30}});var i={toolbar:"tablesaw-bar",hideBtn:"disabled",persistWidths:"tablesaw-fix-persist",allColumnsVisible:"tablesaw-all-cols-visible"};e(document).on("tablesawcreate",function(t,e){"swipe"===e.mode&&n(e.$table)})}(this,jQuery),function(t){function e(e){return t.map(e.childNodes,function(e){var a=t(e);if(a.is("input, select"))return a.val();if(!a.hasClass("tablesaw-cell-label"))return t.trim(a.text())}).join("")}var a="tablesaw-sortable",s="table[data-"+a+"]",n="[data-"+a+"-switch]",i={defaultCol:"data-tablesaw-sortable-default-col",numericCol:"data-tablesaw-sortable-numeric"},l={head:a+"-head",ascend:a+"-ascending",descend:a+"-descending",switcher:a+"-switch",tableToolbar:"tablesaw-toolbar",sortButton:a+"-btn"},o={_create:function(e){return t(this).each(function(){var s=t(this).data("init"+a);return!s&&void t(this).data("init"+a,!0).trigger("beforecreate."+a)[a]("_init",e).trigger("create."+a)})},_init:function(){var s,o,r=t(this),c=function(){r.addClass(a)},d=function(e){t.each(e,function(e,a){t(a).addClass(l.head)})},h=function(e,a){t.each(e,function(e,s){var n=t("<button class='"+l.sortButton+"'/>");n.bind("click",{col:s},a),t(s).wrapInner(n)})},u=function(e){t.each(e,function(e,a){var s=t(a);s.removeAttr(i.defaultCol),s.removeClass(l.ascend),s.removeClass(l.descend)})},b=function(e){if(!t(e.target).is("a[href]")){e.stopPropagation();var n=t(this).parent(),i=e.data.col,c=s.index(n);u(n.siblings()),n.hasClass(l.descend)?(r[a]("sortBy",i,!0),c+="_asc"):(r[a]("sortBy",i),c+="_desc"),o&&o.find("select").val(c).trigger("refresh"),e.preventDefault()}},f=function(e){t.each(e,function(e,a){var s=t(a);s.is("["+i.defaultCol+"]")&&(s.hasClass(l.descend)||s.addClass(l.ascend))})},p=function(s){o=t("<div>").addClass(l.switcher).addClass(l.tableToolbar).html(function(){var a=["<label>"+Tablesaw.i18n.sort+":"];return a.push('<span class="btn btn-small"> <select>'),s.each(function(s){var n=t(this),o=n.is("["+i.defaultCol+"]"),r=n.hasClass(l.descend),c=n.is("[data-sortable-numeric]"),d=0,h=5;t(this.cells).slice(0,h).each(function(){isNaN(parseInt(e(this),10))||d++});var u=d===h;c||n.attr("data-sortable-numeric",u?"":"false"),a.push("<option"+(o&&!r?" selected":"")+' value="'+s+'_asc">'+n.text()+" "+(u?"↑":"(A-Z)")+"</option>"),a.push("<option"+(o&&r?" selected":"")+' value="'+s+'_desc">'+n.text()+" "+(u?"↓":"(Z-A)")+"</option>")}),a.push("</select></span></label>"),a.join("")});var n=r.prev().filter(".tablesaw-bar"),c=n.children().eq(0);c.length?o.insertBefore(c):o.appendTo(n),o.find(".btn").tablesawbtn(),o.find("select").on("change",function(){var e=t(this).val().split("_"),n=s.eq(e[0]);u(n.siblings()),r[a]("sortBy",n.get(0),"asc"===e[1])})};c(),s=r.find("thead th[data-"+a+"-col]"),d(s),h(s,b),f(s),r.is(n)&&p(s,r.find("tbody tr:nth-child(-n+3)"))},getColumnNumber:function(e){return t(e).prevAll().length},getTableRows:function(){return t(this).find("tbody tr")},sortRows:function(a,s,n,i){var l,o,r,c=function(a){var n=[];return t.each(a,function(a,i){var l=t(i).children().get(s);n.push({element:l,cell:e(l),rowNum:a})}),n},d=function(t,e){var a,s=/[^\-\+\d\.]/g;return a=t?function(t,a){return e?parseFloat(t.cell.replace(s,""))-parseFloat(a.cell.replace(s,"")):t.cell.toLowerCase()>a.cell.toLowerCase()?1:-1}:function(t,a){return e?parseFloat(a.cell.replace(s,""))-parseFloat(t.cell.replace(s,"")):t.cell.toLowerCase()<a.cell.toLowerCase()?1:-1}},h=function(t,e){var a,s,n,i=[];for(a=0,s=t.length;a<s;a++)n=t[a].rowNum,i.push(e[n]);return i};l=c(a);var u=t(i).data("tablesaw-sort");return o=!(!u||"function"!=typeof u)&&u(n)||d(n,t(i).is("[data-sortable-numeric]")&&!t(i).is('[data-sortable-numeric="false"]')),r=l.sort(o),a=h(r,a)},replaceTableRows:function(e){var a=t(this),s=a.find("tbody");s.html(e)},makeColDefault:function(e,a){var s=t(e);s.attr(i.defaultCol,"true"),a?(s.removeClass(l.descend),s.addClass(l.ascend)):(s.removeClass(l.ascend),s.addClass(l.descend))},sortBy:function(e,s){var n,i,l=t(this);n=l[a]("getColumnNumber",e),i=l[a]("getTableRows"),i=l[a]("sortRows",i,n,s,e),l[a]("replaceTableRows",i),l[a]("makeColDefault",e,s)}};t.fn[a]=function(e){var s,n=Array.prototype.slice.call(arguments,1);return e&&"string"==typeof e?(s=t.fn[a].prototype[e].apply(this[0],n),"undefined"!=typeof s?s:t(this)):(t(this).data(a+"data")||(t(this).data(a+"active",!0),t.fn[a].prototype._create.call(this,e)),t(this))},t.extend(t.fn[a].prototype,o),t(document).on("tablesawcreate",function(t,e){e.$table.is(s)&&e.$table[a]()})}(jQuery),function(t,e,a){function s(a){function s(e){var a=e.attr(n.attr.init);return!a||t.matchMedia&&t.matchMedia(a).matches}function i(){if(!s(a))return void l.hide();l.show();var t=o.find("li").removeClass(r);a.find("thead th").each(function(a){"none"===e(this).css("display")&&t.eq(a).addClass(r)})}var l=e('<div class="tablesaw-advance minimap">'),o=e('<ul class="tablesaw-advance-dots">').appendTo(l),r="tablesaw-advance-dots-hide",c=a.find("thead th");c.each(function(){o.append("<li><i></i></li>")}),l.appendTo(a.prev().filter(".tablesaw-bar")),i(),e(t).on("resize",i),a.bind("tablesawcolumns.minimap",function(){i()}).bind("tablesawdestroy.minimap",function(){var a=e(this);a.prev().filter(".tablesaw-bar").find(".tablesaw-advance").remove(),e(t).off("resize",i),a.unbind(".minimap")})}var n={attr:{init:"data-tablesaw-minimap"}};e(document).on("tablesawcreate",function(t,e){"swipe"!==e.mode&&"columntoggle"!==e.mode||!e.$table.is("[ "+n.attr.init+"]")||s(e.$table)})}(this,jQuery),function(t,e){var a={selectors:{init:"table[data-tablesaw-mode-switch]"},attributes:{excludeMode:"data-tablesaw-mode-exclude"},classes:{main:"tablesaw-modeswitch",toolbar:"tablesaw-toolbar"},modes:["stack","swipe","columntoggle"],init:function(t){var s=e(t),n=s.attr(a.attributes.excludeMode),i=s.prev().filter(".tablesaw-bar"),l="",o=e("<div>").addClass(a.classes.main+" "+a.classes.toolbar).html(function(){var t,e=["<label>"+Tablesaw.i18n.columns+":"],i=s.attr("data-tablesaw-mode");e.push('<span class="btn btn-small"> <select>');for(var o=0,r=a.modes.length;o<r;o++)n&&n.toLowerCase()===a.modes[o]||(t=i===a.modes[o],t&&(l=a.modes[o]),e.push("<option"+(t?" selected":"")+' value="'+a.modes[o]+'">'+Tablesaw.i18n.modes[o]+"</option>"));return e.push("</select></span></label>"),e.join("")}),r=i.find(".tablesaw-advance").eq(0);r.length?o.insertBefore(r):o.appendTo(i),o.find(".btn").tablesawbtn(),o.find("select").bind("change",a.onModeChange)},onModeChange:function(){var t=e(this),s=t.closest("."+a.classes.main),n=t.closest(".tablesaw-bar").nextUntil(n).eq(0),i=t.val();s.remove(),n.data("table").destroy(),n.attr("data-tablesaw-mode",i),n.table()}};e(t.document).on("tablesawcreate",function(t,e){e.$table.is(a.selectors.init)&&a.init(e.table)})}(this,jQuery);
|
inc/woo-compare-wishlist/assets/js/tm-woocompare.js
ADDED
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
( function( $ ) {
|
2 |
+
|
3 |
+
'use strict';
|
4 |
+
|
5 |
+
$( document ).ready( function() {
|
6 |
+
|
7 |
+
var tmWooLoadingClass = 'loading',
|
8 |
+
tmWooAddedClass = 'added in_compare',
|
9 |
+
btnSelector = 'button.tm-woocompare-button';
|
10 |
+
|
11 |
+
$( document ).on( 'tx_compare_update_fragments', updateFragments );
|
12 |
+
|
13 |
+
function productButtonsInit() {
|
14 |
+
|
15 |
+
$( document ).on( 'click', btnSelector, function ( event ) {
|
16 |
+
|
17 |
+
var button = $( this );
|
18 |
+
|
19 |
+
event.preventDefault();
|
20 |
+
|
21 |
+
var url = tmWoocompare.ajaxurl,
|
22 |
+
data = {
|
23 |
+
action: 'tx_woocompare_add_to_list',
|
24 |
+
pid: button.data( 'id' ),
|
25 |
+
nonce: button.data( 'nonce' ),
|
26 |
+
single: button.hasClass( 'tm-woocompare-button-single' )
|
27 |
+
};
|
28 |
+
|
29 |
+
button
|
30 |
+
.removeClass( tmWooAddedClass )
|
31 |
+
.addClass( tmWooLoadingClass );
|
32 |
+
|
33 |
+
$.post(
|
34 |
+
url,
|
35 |
+
data,
|
36 |
+
function( response ) {
|
37 |
+
|
38 |
+
button.removeClass( tmWooLoadingClass );
|
39 |
+
|
40 |
+
if( response.success ) {
|
41 |
+
|
42 |
+
switch ( response.data.action ) {
|
43 |
+
|
44 |
+
case 'add':
|
45 |
+
|
46 |
+
$( btnSelector + '[data-id=' + data.pid + ']' )
|
47 |
+
.addClass( tmWooAddedClass )
|
48 |
+
.find( '.text' )
|
49 |
+
.text( tmWoocompare.removeText );
|
50 |
+
|
51 |
+
if( response.data.comparePageBtn ) {
|
52 |
+
|
53 |
+
button.after( response.data.comparePageBtn );
|
54 |
+
}
|
55 |
+
break;
|
56 |
+
|
57 |
+
case 'remove':
|
58 |
+
|
59 |
+
$( btnSelector + '[data-id=' + data.pid + ']' )
|
60 |
+
.removeClass( tmWooAddedClass )
|
61 |
+
.find( '.text' )
|
62 |
+
.text( tmWoocompare.compareText );
|
63 |
+
|
64 |
+
$( '.tm-woocompare-page-button' ).remove();
|
65 |
+
|
66 |
+
break;
|
67 |
+
|
68 |
+
default:
|
69 |
+
|
70 |
+
break;
|
71 |
+
}
|
72 |
+
data = {
|
73 |
+
action: 'tx_woocompare_update'
|
74 |
+
};
|
75 |
+
tmWoocompareAjax( null, data );
|
76 |
+
}
|
77 |
+
|
78 |
+
if ( undefined !== response.data.counts ) {
|
79 |
+
$( document ).trigger( 'tx_compare_update_fragments', { response: response.data.counts } );
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
83 |
+
);
|
84 |
+
} );
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
function tmWoocompareAjax( event, data ) {
|
89 |
+
|
90 |
+
if( event ) {
|
91 |
+
|
92 |
+
event.preventDefault();
|
93 |
+
}
|
94 |
+
|
95 |
+
var url = tmWoocompare.ajaxurl,
|
96 |
+
widgetWrapper = $( 'div.tm-woocompare-widget-wrapper' ),
|
97 |
+
compareList = $( 'div.tm-woocompare-list' );
|
98 |
+
|
99 |
+
data.isComparePage = !!compareList.length;
|
100 |
+
data.isWidget = !!widgetWrapper.length;
|
101 |
+
|
102 |
+
if ( 'tx_woocompare_update' === data.action && !data.isComparePage && !data.isWidget ) {
|
103 |
+
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
compareList.addClass( tmWooLoadingClass );
|
107 |
+
widgetWrapper.addClass( tmWooLoadingClass );
|
108 |
+
|
109 |
+
$.post(
|
110 |
+
url,
|
111 |
+
data,
|
112 |
+
function( response ) {
|
113 |
+
|
114 |
+
compareList.removeClass( tmWooLoadingClass );
|
115 |
+
widgetWrapper.removeClass( tmWooLoadingClass );
|
116 |
+
|
117 |
+
if( response.success ) {
|
118 |
+
|
119 |
+
if( data.isComparePage ) {
|
120 |
+
|
121 |
+
$( 'div.tm-woocompare-wrapper' ).html( response.data.compareList );
|
122 |
+
$( document ).trigger( 'enhance.tablesaw' );
|
123 |
+
}
|
124 |
+
if( data.isWidget ) {
|
125 |
+
|
126 |
+
widgetWrapper.html( response.data.widget );
|
127 |
+
}
|
128 |
+
if ( 'tx_woocompare_empty' === data.action ) {
|
129 |
+
|
130 |
+
$( btnSelector )
|
131 |
+
.removeClass( tmWooAddedClass )
|
132 |
+
.find( '.text' )
|
133 |
+
.text( tmWoocompare.compareText );
|
134 |
+
|
135 |
+
$( '.tm-woocompare-page-button' ).remove();
|
136 |
+
}
|
137 |
+
if ( 'tx_woocompare_remove' === data.action ) {
|
138 |
+
|
139 |
+
$( btnSelector + '[data-id=' + data.pid + ']' )
|
140 |
+
.removeClass( tmWooAddedClass )
|
141 |
+
.find( '.text' )
|
142 |
+
.text( tmWoocompare.compareText );
|
143 |
+
|
144 |
+
$( '.tm-woocompare-page-button' ).remove();
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
if ( undefined !== response.data.counts ) {
|
149 |
+
$( document ).trigger( 'tx_compare_update_fragments', { response: response.data.counts } );
|
150 |
+
}
|
151 |
+
|
152 |
+
widgetButtonsInit();
|
153 |
+
}
|
154 |
+
);
|
155 |
+
}
|
156 |
+
|
157 |
+
function tmWoocompareRemove( event ) {
|
158 |
+
|
159 |
+
var button = $( event.currentTarget ),
|
160 |
+
data = {
|
161 |
+
action: 'tx_woocompare_remove',
|
162 |
+
pid: button.data( 'id' ),
|
163 |
+
nonce: button.data( 'nonce' )
|
164 |
+
};
|
165 |
+
|
166 |
+
tmWoocompareAjax( event, data );
|
167 |
+
}
|
168 |
+
|
169 |
+
function tmWoocompareEmpty( event ) {
|
170 |
+
|
171 |
+
var data = {
|
172 |
+
action: 'tx_woocompare_empty'
|
173 |
+
};
|
174 |
+
|
175 |
+
tmWoocompareAjax( event, data );
|
176 |
+
}
|
177 |
+
|
178 |
+
function widgetButtonsInit() {
|
179 |
+
|
180 |
+
$( '.tm-woocompare-remove' )
|
181 |
+
.off( 'click' )
|
182 |
+
.on( 'click', function ( event ) {
|
183 |
+
tmWoocompareRemove( event );
|
184 |
+
} );
|
185 |
+
|
186 |
+
$( '.tm-woocompare-empty' )
|
187 |
+
.off( 'click' )
|
188 |
+
.on( 'click', function( event ) {
|
189 |
+
tmWoocompareEmpty( event );
|
190 |
+
} );
|
191 |
+
}
|
192 |
+
|
193 |
+
function getRefreshedFragments() {
|
194 |
+
|
195 |
+
$.ajax({
|
196 |
+
url: tmWoocompare.ajaxurl,
|
197 |
+
type: 'get',
|
198 |
+
dataType: 'json',
|
199 |
+
data: {
|
200 |
+
action: 'tx_compare_get_fragments'
|
201 |
+
}
|
202 |
+
}).done( function( response ) {
|
203 |
+
|
204 |
+
$( document ).trigger( 'tx_compare_update_fragments', { response: response.data } );
|
205 |
+
|
206 |
+
});
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
function updateFragments( event, data ) {
|
211 |
+
|
212 |
+
if ( ! $.isEmptyObject( data.response.defaultFragments ) ) {
|
213 |
+
$.each( data.response.defaultFragments, function( key, val ) {
|
214 |
+
var $item = $( key ),
|
215 |
+
$count = $( '.compare-count', $item );
|
216 |
+
if ( 0 === $count.length ) {
|
217 |
+
$item.append( tmWoocompare.countFormat.replace( '%count%', val ) );
|
218 |
+
} else {
|
219 |
+
$item.find( '.compare-count' ).html( val );
|
220 |
+
}
|
221 |
+
} );
|
222 |
+
}
|
223 |
+
|
224 |
+
if ( ! $.isEmptyObject( data.response.customFragments ) ) {
|
225 |
+
$.each( data.response.customFragments, function( key, val ) {
|
226 |
+
var $item = $( key );
|
227 |
+
if ( $item.length ) {
|
228 |
+
$item.html( val );
|
229 |
+
}
|
230 |
+
} );
|
231 |
+
}
|
232 |
+
|
233 |
+
}
|
234 |
+
|
235 |
+
widgetButtonsInit();
|
236 |
+
productButtonsInit();
|
237 |
+
getRefreshedFragments();
|
238 |
+
|
239 |
+
} );
|
240 |
+
}( jQuery) );
|
inc/woo-compare-wishlist/assets/js/tm-woocompare.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(t){"use strict";t(document).ready(function(){function e(e,o){e&&e.preventDefault();var a=tmWoocompare.ajaxurl,m=t("div.tm-woocompare-widget-wrapper"),p=t("div.tm-woocompare-list");o.isComparePage=!!p.length,o.isWidget=!!m.length,("tx_woocompare_update"!==o.action||o.isComparePage||o.isWidget)&&(p.addClass(c),m.addClass(c),t.post(a,o,function(e){p.removeClass(c),m.removeClass(c),e.success&&(o.isComparePage&&(t("div.tm-woocompare-wrapper").html(e.data.compareList),t(document).trigger("enhance.tablesaw")),o.isWidget&&m.html(e.data.widget),"tx_woocompare_empty"===o.action&&(t(s).removeClass(r).find(".text").text(tmWoocompare.compareText),t(".tm-woocompare-page-button").remove()),"tx_woocompare_remove"===o.action&&(t(s+"[data-id="+o.pid+"]").removeClass(r).find(".text").text(tmWoocompare.compareText),t(".tm-woocompare-page-button").remove())),void 0!==e.data.counts&&t(document).trigger("tx_compare_update_fragments",{response:e.data.counts}),n()}))}function o(o){var a=t(o.currentTarget);e(o,{action:"tx_woocompare_remove",pid:a.data("id"),nonce:a.data("nonce")})}function a(t){e(t,{action:"tx_woocompare_empty"})}function n(){t(".tm-woocompare-remove").off("click").on("click",function(t){o(t)}),t(".tm-woocompare-empty").off("click").on("click",function(t){a(t)})}function m(e,o){t.isEmptyObject(o.response.defaultFragments)||t.each(o.response.defaultFragments,function(e,o){var a=t(e);0===t(".compare-count",a).length?a.append(tmWoocompare.countFormat.replace("%count%",o)):a.find(".compare-count").html(o)}),t.isEmptyObject(o.response.customFragments)||t.each(o.response.customFragments,function(e,o){var a=t(e);a.length&&a.html(o)})}var c="loading",r="added in_compare",s="button.tm-woocompare-button";t(document).on("tx_compare_update_fragments",m),n(),function(){t(document).on("click",s,function(o){var a=t(this);o.preventDefault();var n=tmWoocompare.ajaxurl,m={action:"tx_woocompare_add_to_list",pid:a.data("id"),nonce:a.data("nonce"),single:a.hasClass("tm-woocompare-button-single")};a.removeClass(r).addClass(c),t.post(n,m,function(o){if(a.removeClass(c),o.success){switch(o.data.action){case"add":t(s+"[data-id="+m.pid+"]").addClass(r).find(".text").text(tmWoocompare.removeText),o.data.comparePageBtn&&a.after(o.data.comparePageBtn);break;case"remove":t(s+"[data-id="+m.pid+"]").removeClass(r).find(".text").text(tmWoocompare.compareText),t(".tm-woocompare-page-button").remove()}e(null,m={action:"tx_woocompare_update"})}void 0!==o.data.counts&&t(document).trigger("tx_compare_update_fragments",{response:o.data.counts})})})}(),function(){t.ajax({url:tmWoocompare.ajaxurl,type:"get",dataType:"json",data:{action:"tx_compare_get_fragments"}}).done(function(e){t(document).trigger("tx_compare_update_fragments",{response:e.data})})}()})}(jQuery);
|
inc/woo-compare-wishlist/assets/js/tm-woowishlist.js
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
( function( $ ) {
|
2 |
+
|
3 |
+
'use strict';
|
4 |
+
|
5 |
+
$( document ).ready( function() {
|
6 |
+
|
7 |
+
var tmWooLoadingClass = 'loading',
|
8 |
+
tmWooAddedClass = 'added in_wishlist',
|
9 |
+
buttonSelector = 'button.tm-woowishlist-button';
|
10 |
+
|
11 |
+
function productButtonsInit() {
|
12 |
+
|
13 |
+
$( document ).on( 'click', buttonSelector, function ( event ) {
|
14 |
+
|
15 |
+
var button = $( this );
|
16 |
+
|
17 |
+
event.preventDefault();
|
18 |
+
|
19 |
+
if( button.hasClass( 'in_wishlist' ) ) {
|
20 |
+
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
|
24 |
+
var url = tmWoowishlist.ajaxurl,
|
25 |
+
data = {
|
26 |
+
action: 'tx_woowishlist_add',
|
27 |
+
pid: button.data( 'id' ),
|
28 |
+
nonce: button.data( 'nonce' ),
|
29 |
+
single: button.hasClass( 'tm-woowishlist-button-single' )
|
30 |
+
};
|
31 |
+
|
32 |
+
button
|
33 |
+
.removeClass( tmWooAddedClass )
|
34 |
+
.addClass( tmWooLoadingClass );
|
35 |
+
|
36 |
+
$.post(
|
37 |
+
url,
|
38 |
+
data,
|
39 |
+
function( response ) {
|
40 |
+
|
41 |
+
button.removeClass( tmWooLoadingClass );
|
42 |
+
|
43 |
+
if( response.success ) {
|
44 |
+
|
45 |
+
button
|
46 |
+
.addClass( tmWooAddedClass )
|
47 |
+
.find( '.text' )
|
48 |
+
.text( tmWoowishlist.addedText );
|
49 |
+
|
50 |
+
if( response.data.wishlistPageBtn ) {
|
51 |
+
|
52 |
+
button.after( response.data.wishlistPageBtn );
|
53 |
+
}
|
54 |
+
var data = {
|
55 |
+
action: 'tx_woowishlist_update'
|
56 |
+
};
|
57 |
+
tmWoowishlistAjax( null, data );
|
58 |
+
}
|
59 |
+
}
|
60 |
+
);
|
61 |
+
} );
|
62 |
+
}
|
63 |
+
|
64 |
+
function tmWoowishlistAjax( event, data ) {
|
65 |
+
|
66 |
+
if( event ) {
|
67 |
+
event.preventDefault();
|
68 |
+
}
|
69 |
+
|
70 |
+
var url = tmWoowishlist.ajaxurl,
|
71 |
+
widgetWrapper = $( 'div.tm-woocomerce-wishlist-widget-wrapper' ),
|
72 |
+
wishList = $( 'div.tm-woowishlist' );
|
73 |
+
|
74 |
+
data.isWishlistPage = !!wishList.length;
|
75 |
+
data.isWidget = !!widgetWrapper.length;
|
76 |
+
|
77 |
+
if ( 'tx_woowishlist_update' === data.action && !data.isWishlistPage && !data.isWidget ) {
|
78 |
+
return;
|
79 |
+
}
|
80 |
+
if( data.isWishlistPage ) {
|
81 |
+
|
82 |
+
data.wishListData = JSON.stringify( wishList.data() );
|
83 |
+
}
|
84 |
+
wishList.addClass( tmWooLoadingClass );
|
85 |
+
|
86 |
+
widgetWrapper.addClass( tmWooLoadingClass );
|
87 |
+
|
88 |
+
$.post(
|
89 |
+
url,
|
90 |
+
data,
|
91 |
+
function( response ) {
|
92 |
+
|
93 |
+
wishList.removeClass( tmWooLoadingClass );
|
94 |
+
|
95 |
+
widgetWrapper.removeClass( tmWooLoadingClass );
|
96 |
+
|
97 |
+
if( response.success ) {
|
98 |
+
|
99 |
+
if( data.isWishlistPage ) {
|
100 |
+
|
101 |
+
$( 'div.tm-woowishlist-wrapper' ).html( response.data.wishList );
|
102 |
+
}
|
103 |
+
if( data.isWidget ) {
|
104 |
+
|
105 |
+
widgetWrapper.html( response.data.widget );
|
106 |
+
}
|
107 |
+
if ( 'tx_woowishlist_remove' === data.action ) {
|
108 |
+
|
109 |
+
$( buttonSelector + '[data-id=' + data.pid + ']' ).removeClass( tmWooAddedClass ).find( '.text' ).text( tmWoowishlist.addText );
|
110 |
+
|
111 |
+
$( buttonSelector + '[data-id=' + data.pid + ']' ).next( '.tm-woowishlist-page-button' ).remove();
|
112 |
+
}
|
113 |
+
}
|
114 |
+
widgetButtonsInit();
|
115 |
+
}
|
116 |
+
);
|
117 |
+
}
|
118 |
+
|
119 |
+
function tmWoowishlistRemove( event ) {
|
120 |
+
|
121 |
+
console.log(event);
|
122 |
+
|
123 |
+
var button = $( event.currentTarget ),
|
124 |
+
data = {
|
125 |
+
action: 'tx_woowishlist_remove',
|
126 |
+
pid: button.data( 'id' ),
|
127 |
+
nonce: button.data( 'nonce' )
|
128 |
+
};
|
129 |
+
|
130 |
+
tmWoowishlistAjax( event, data );
|
131 |
+
}
|
132 |
+
|
133 |
+
function widgetButtonsInit() {
|
134 |
+
|
135 |
+
$( '.tm-woowishlist-remove' )
|
136 |
+
.off( 'click' )
|
137 |
+
.on( 'click', function ( event ) {
|
138 |
+
tmWoowishlistRemove( event );
|
139 |
+
} );
|
140 |
+
}
|
141 |
+
|
142 |
+
widgetButtonsInit();
|
143 |
+
productButtonsInit();
|
144 |
+
|
145 |
+
} );
|
146 |
+
}( jQuery) );
|
inc/woo-compare-wishlist/assets/js/tm-woowishlist.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(t){"use strict";t(document).ready(function(){function i(i,s){i&&i.preventDefault();var d=tmWoowishlist.ajaxurl,l=t("div.tm-woocomerce-wishlist-widget-wrapper"),w=t("div.tm-woowishlist");s.isWishlistPage=!!w.length,s.isWidget=!!l.length,("tx_woowishlist_update"!==s.action||s.isWishlistPage||s.isWidget)&&(s.isWishlistPage&&(s.wishListData=JSON.stringify(w.data())),w.addClass(o),l.addClass(o),t.post(d,s,function(i){w.removeClass(o),l.removeClass(o),i.success&&(s.isWishlistPage&&t("div.tm-woowishlist-wrapper").html(i.data.wishList),s.isWidget&&l.html(i.data.widget),"tx_woowishlist_remove"===s.action&&(t(n+"[data-id="+s.pid+"]").removeClass(e).find(".text").text(tmWoowishlist.addText),t(n+"[data-id="+s.pid+"]").next(".tm-woowishlist-page-button").remove())),a()}))}function s(s){console.log(s);var a=t(s.currentTarget);i(s,{action:"tx_woowishlist_remove",pid:a.data("id"),nonce:a.data("nonce")})}function a(){t(".tm-woowishlist-remove").off("click").on("click",function(t){s(t)})}var o="loading",e="added in_wishlist",n="button.tm-woowishlist-button";a(),function(){t(document).on("click",n,function(s){var a=t(this);if(s.preventDefault(),!a.hasClass("in_wishlist")){var n=tmWoowishlist.ajaxurl,d={action:"tx_woowishlist_add",pid:a.data("id"),nonce:a.data("nonce"),single:a.hasClass("tm-woowishlist-button-single")};a.removeClass(e).addClass(o),t.post(n,d,function(t){a.removeClass(o),t.success&&(a.addClass(e).find(".text").text(tmWoowishlist.addedText),t.data.wishlistPageBtn&&a.after(t.data.wishlistPageBtn),i(null,{action:"tx_woowishlist_update"}))})}})}()})}(jQuery);
|
inc/woo-compare-wishlist/assets/scss/_clearfix.scss
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Clearfix
|
2 |
+
//
|
3 |
+
// For modern browsers
|
4 |
+
// 1. The space content is one way to avoid an Opera bug when the
|
5 |
+
// contenteditable attribute is included anywhere else in the document.
|
6 |
+
// Otherwise it causes space to appear at the top and bottom of elements
|
7 |
+
// that are clearfixed.
|
8 |
+
// 2. The use of `table` rather than `block` is only necessary if using
|
9 |
+
// `:before` to contain the top-margins of child elements.
|
10 |
+
//
|
11 |
+
// Source: http://nicolasgallagher.com/micro-clearfix-hack/
|
12 |
+
|
13 |
+
@mixin clearfix() {
|
14 |
+
&:before,
|
15 |
+
&:after {
|
16 |
+
content: " "; // 1
|
17 |
+
display: table; // 2
|
18 |
+
}
|
19 |
+
&:after {
|
20 |
+
clear: both;
|
21 |
+
}
|
22 |
+
}
|
inc/woo-compare-wishlist/assets/scss/_grid-framework.scss
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Framework grid generation
|
2 |
+
//
|
3 |
+
// Used only by Bootstrap to generate the correct number of grid classes given
|
4 |
+
// any value of `$grid-columns`.
|
5 |
+
|
6 |
+
// [converter] This is defined recursively in LESS, but Sass supports real loops
|
7 |
+
@mixin make-grid-columns($i: 1, $list: ".col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}") {
|
8 |
+
@for $i from (1 + 1) through $grid-columns {
|
9 |
+
$list: "#{$list}, .col-xs-#{$i}, .col-sm-#{$i}, .col-md-#{$i}, .col-lg-#{$i}";
|
10 |
+
}
|
11 |
+
#{$list} {
|
12 |
+
position: relative;
|
13 |
+
// Prevent columns from collapsing when empty
|
14 |
+
min-height: 1px;
|
15 |
+
// Inner gutter via padding
|
16 |
+
padding-left: ceil(($grid-gutter-width / 2));
|
17 |
+
padding-right: floor(($grid-gutter-width / 2));
|
18 |
+
box-sizing: border-box;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
// [converter] This is defined recursively in LESS, but Sass supports real loops
|
24 |
+
@mixin float-grid-columns($class, $i: 1, $list: ".col-#{$class}-#{$i}") {
|
25 |
+
@for $i from (1 + 1) through $grid-columns {
|
26 |
+
$list: "#{$list}, .col-#{$class}-#{$i}";
|
27 |
+
}
|
28 |
+
#{$list} {
|
29 |
+
float: left;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
@mixin calc-grid-column($index, $class, $type) {
|
35 |
+
@if ($type == width) and ($index > 0) {
|
36 |
+
.col-#{$class}-#{$index} {
|
37 |
+
width: percentage(($index / $grid-columns));
|
38 |
+
}
|
39 |
+
}
|
40 |
+
@if ($type == push) and ($index > 0) {
|
41 |
+
.col-#{$class}-push-#{$index} {
|
42 |
+
left: percentage(($index / $grid-columns));
|
43 |
+
}
|
44 |
+
}
|
45 |
+
@if ($type == push) and ($index == 0) {
|
46 |
+
.col-#{$class}-push-0 {
|
47 |
+
left: auto;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
@if ($type == pull) and ($index > 0) {
|
51 |
+
.col-#{$class}-pull-#{$index} {
|
52 |
+
right: percentage(($index / $grid-columns));
|
53 |
+
}
|
54 |
+
}
|
55 |
+
@if ($type == pull) and ($index == 0) {
|
56 |
+
.col-#{$class}-pull-0 {
|
57 |
+
right: auto;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
@if ($type == offset) {
|
61 |
+
.col-#{$class}-offset-#{$index} {
|
62 |
+
margin-left: percentage(($index / $grid-columns));
|
63 |
+
}
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
// [converter] This is defined recursively in LESS, but Sass supports real loops
|
68 |
+
@mixin loop-grid-columns($columns, $class, $type) {
|
69 |
+
@for $i from 0 through $columns {
|
70 |
+
@include calc-grid-column($i, $class, $type);
|
71 |
+
}
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
// Create grid for specific class
|
76 |
+
@mixin make-grid($class) {
|
77 |
+
@include float-grid-columns($class);
|
78 |
+
@include loop-grid-columns($grid-columns, $class, width);
|
79 |
+
@include loop-grid-columns($grid-columns, $class, pull);
|
80 |
+
@include loop-grid-columns($grid-columns, $class, push);
|
81 |
+
@include loop-grid-columns($grid-columns, $class, offset);
|
82 |
+
}
|
inc/woo-compare-wishlist/assets/scss/_grid.scss
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Grid system
|
2 |
+
//
|
3 |
+
// Generate semantic grid columns with these mixins.
|
4 |
+
|
5 |
+
// Centered container element
|
6 |
+
@mixin container-fixed($gutter: $grid-gutter-width) {
|
7 |
+
margin-right: auto;
|
8 |
+
margin-left: auto;
|
9 |
+
padding-left: floor(($gutter / 2));
|
10 |
+
padding-right: ceil(($gutter / 2));
|
11 |
+
@include clearfix;
|
12 |
+
}
|
13 |
+
|
14 |
+
// Creates a wrapper for a series of columns
|
15 |
+
@mixin make-row($gutter: $grid-gutter-width) {
|
16 |
+
margin-left: ceil(($gutter / -2));
|
17 |
+
margin-right: floor(($gutter / -2));
|
18 |
+
@include clearfix;
|
19 |
+
}
|
20 |
+
|
21 |
+
// Generate the extra small columns
|
22 |
+
@mixin make-xs-column($columns, $gutter: $grid-gutter-width) {
|
23 |
+
position: relative;
|
24 |
+
float: left;
|
25 |
+
width: percentage(($columns / $grid-columns));
|
26 |
+
min-height: 1px;
|
27 |
+
padding-left: ($gutter / 2);
|
28 |
+
padding-right: ($gutter / 2);
|
29 |
+
}
|
30 |
+
@mixin make-xs-column-offset($columns) {
|
31 |
+
margin-left: percentage(($columns / $grid-columns));
|
32 |
+
}
|
33 |
+
@mixin make-xs-column-push($columns) {
|
34 |
+
left: percentage(($columns / $grid-columns));
|
35 |
+
}
|
36 |
+
@mixin make-xs-column-pull($columns) {
|
37 |
+
right: percentage(($columns / $grid-columns));
|
38 |
+
}
|
39 |
+
|
40 |
+
// Generate the small columns
|
41 |
+
@mixin make-sm-column($columns, $gutter: $grid-gutter-width) {
|
42 |
+
position: relative;
|
43 |
+
min-height: 1px;
|
44 |
+
padding-left: ($gutter / 2);
|
45 |
+
padding-right: ($gutter / 2);
|
46 |
+
|
47 |
+
@media (min-width: $screen-sm-min) {
|
48 |
+
float: left;
|
49 |
+
width: percentage(($columns / $grid-columns));
|
50 |
+
}
|
51 |
+
}
|
52 |
+
@mixin make-sm-column-offset($columns) {
|
53 |
+
@media (min-width: $screen-sm-min) {
|
54 |
+
margin-left: percentage(($columns / $grid-columns));
|
55 |
+
}
|
56 |
+
}
|
57 |
+
@mixin make-sm-column-push($columns) {
|
58 |
+
@media (min-width: $screen-sm-min) {
|
59 |
+
left: percentage(($columns / $grid-columns));
|
60 |
+
}
|
61 |
+
}
|
62 |
+
@mixin make-sm-column-pull($columns) {
|
63 |
+
@media (min-width: $screen-sm-min) {
|
64 |
+
right: percentage(($columns / $grid-columns));
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
// Generate the medium columns
|
69 |
+
@mixin make-md-column($columns, $gutter: $grid-gutter-width) {
|
70 |
+
position: relative;
|
71 |
+
min-height: 1px;
|
72 |
+
padding-left: ($gutter / 2);
|
73 |
+
padding-right: ($gutter / 2);
|
74 |
+
|
75 |
+
@media (min-width: $screen-md-min) {
|
76 |
+
float: left;
|
77 |
+
width: percentage(($columns / $grid-columns));
|
78 |
+
}
|
79 |
+
}
|
80 |
+
@mixin make-md-column-offset($columns) {
|
81 |
+
@media (min-width: $screen-md-min) {
|
82 |
+
margin-left: percentage(($columns / $grid-columns));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
@mixin make-md-column-push($columns) {
|
86 |
+
@media (min-width: $screen-md-min) {
|
87 |
+
left: percentage(($columns / $grid-columns));
|
88 |
+
}
|
89 |
+
}
|
90 |
+
@mixin make-md-column-pull($columns) {
|
91 |
+
@media (min-width: $screen-md-min) {
|
92 |
+
right: percentage(($columns / $grid-columns));
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
// Generate the large columns
|
97 |
+
@mixin make-lg-column($columns, $gutter: $grid-gutter-width) {
|
98 |
+
position: relative;
|
99 |
+
min-height: 1px;
|
100 |
+
padding-left: ($gutter / 2);
|
101 |
+
padding-right: ($gutter / 2);
|
102 |
+
|
103 |
+
@media (min-width: $screen-lg-min) {
|
104 |
+
float: left;
|
105 |
+
width: percentage(($columns / $grid-columns));
|
106 |
+
}
|
107 |
+
}
|
108 |
+
@mixin make-lg-column-offset($columns) {
|
109 |
+
@media (min-width: $screen-lg-min) {
|
110 |
+
margin-left: percentage(($columns / $grid-columns));
|
111 |
+
}
|
112 |
+
}
|
113 |
+
@mixin make-lg-column-push($columns) {
|
114 |
+
@media (min-width: $screen-lg-min) {
|
115 |
+
left: percentage(($columns / $grid-columns));
|
116 |
+
}
|
117 |
+
}
|
118 |
+
@mixin make-lg-column-pull($columns) {
|
119 |
+
@media (min-width: $screen-lg-min) {
|
120 |
+
right: percentage(($columns / $grid-columns));
|
121 |
+
}
|
122 |
+
}
|
inc/woo-compare-wishlist/assets/scss/_variables.scss
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
$bootstrap-sass-asset-helper: false !default;
|
2 |
+
//
|
3 |
+
// Variables
|
4 |
+
// --------------------------------------------------
|
5 |
+
|
6 |
+
//== Media queries breakpoints
|
7 |
+
//
|
8 |
+
//## Define the breakpoints at which your layout will change, adapting to different screen sizes.
|
9 |
+
|
10 |
+
// Extra small screen / phone
|
11 |
+
//** Deprecated `$screen-xs` as of v3.0.1
|
12 |
+
$screen-xs: 480px !default;
|
13 |
+
//** Deprecated `$screen-xs-min` as of v3.2.0
|
14 |
+
$screen-xs-min: $screen-xs !default;
|
15 |
+
//** Deprecated `$screen-phone` as of v3.0.1
|
16 |
+
$screen-phone: $screen-xs-min !default;
|
17 |
+
|
18 |
+
// Small screen / tablet
|
19 |
+
//** Deprecated `$screen-sm` as of v3.0.1
|
20 |
+
$screen-sm: 768px !default;
|
21 |
+
$screen-sm-min: $screen-sm !default;
|
22 |
+
//** Deprecated `$screen-tablet` as of v3.0.1
|
23 |
+
$screen-tablet: $screen-sm-min !default;
|
24 |
+
|
25 |
+
// Medium screen / desktop
|
26 |
+
//** Deprecated `$screen-md` as of v3.0.1
|
27 |
+
$screen-md: 992px !default;
|
28 |
+
$screen-md-min: $screen-md !default;
|
29 |
+
//** Deprecated `$screen-desktop` as of v3.0.1
|
30 |
+
$screen-desktop: $screen-md-min !default;
|
31 |
+
|
32 |
+
// Large screen / wide desktop
|
33 |
+
//** Deprecated `$screen-lg` as of v3.0.1
|
34 |
+
$screen-lg: 1200px !default;
|
35 |
+
$screen-lg-min: $screen-lg !default;
|
36 |
+
//** Deprecated `$screen-lg-desktop` as of v3.0.1
|
37 |
+
$screen-lg-desktop: $screen-lg-min !default;
|
38 |
+
|
39 |
+
// So media queries don't overlap when required, provide a maximum
|
40 |
+
$screen-xs-max: ($screen-sm-min - 1) !default;
|
41 |
+
$screen-sm-max: ($screen-md-min - 1) !default;
|
42 |
+
$screen-md-max: ($screen-lg-min - 1) !default;
|
43 |
+
|
44 |
+
|
45 |
+
//== Grid system
|
46 |
+
//
|
47 |
+
//## Define your custom responsive grid.
|
48 |
+
|
49 |
+
//** Number of columns in the grid.
|
50 |
+
$grid-columns: 12 !default;
|
51 |
+
//** Padding between columns. Gets divided in half for the left and right.
|
52 |
+
$grid-gutter-width: 30px !default;
|
53 |
+
// Navbar collapse
|
54 |
+
//** Point at which the navbar becomes uncollapsed.
|
55 |
+
$grid-float-breakpoint: $screen-sm-min !default;
|
56 |
+
//** Point at which the navbar begins collapsing.
|
57 |
+
$grid-float-breakpoint-max: ($grid-float-breakpoint - 1) !default;
|
58 |
+
|
59 |
+
|
60 |
+
//== Container sizes
|
61 |
+
//
|
62 |
+
//## Define the maximum width of `.container` for different screen sizes.
|
63 |
+
|
64 |
+
// Small screen / tablet
|
65 |
+
$container-tablet: (720px + $grid-gutter-width) !default;
|
66 |
+
//** For `$screen-sm-min` and up.
|
67 |
+
$container-sm: $container-tablet !default;
|
68 |
+
|
69 |
+
// Medium screen / desktop
|
70 |
+
$container-desktop: (940px + $grid-gutter-width) !default;
|
71 |
+
//** For `$screen-md-min` and up.
|
72 |
+
$container-md: $container-desktop !default;
|
73 |
+
|
74 |
+
// Large screen / wide desktop
|
75 |
+
$container-large-desktop: (1140px + $grid-gutter-width) !default;
|
76 |
+
//** For `$screen-lg-min` and up.
|
77 |
+
$container-lg: $container-large-desktop !default;
|
inc/woo-compare-wishlist/assets/scss/grid.scss
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import "variables";
|
2 |
+
|
3 |
+
@import "clearfix";
|
4 |
+
@import "grid-framework";
|
5 |
+
@import "_grid";
|
6 |
+
|
7 |
+
//
|
8 |
+
// Grid system
|
9 |
+
// --------------------------------------------------
|
10 |
+
|
11 |
+
// Fluid container
|
12 |
+
//
|
13 |
+
// Utilizes the mixin meant for fixed width containers, but without any defined
|
14 |
+
// width for fluid, full width layouts.
|
15 |
+
|
16 |
+
.container-fluid {
|
17 |
+
@include container-fixed;
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
// Row
|
22 |
+
//
|
23 |
+
// Rows contain and clear the floats of your columns.
|
24 |
+
|
25 |
+
.row {
|
26 |
+
@include make-row;
|
27 |
+
}
|
28 |
+
|
29 |
+
.tm_banners_grid_widget_banner {
|
30 |
+
margin-bottom: $grid-gutter-width;
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
// Columns
|
35 |
+
//
|
36 |
+
// Common styles for small and large grid columns
|
37 |
+
|
38 |
+
@include make-grid-columns;
|
39 |
+
|
40 |
+
|
41 |
+
// Extra small grid
|
42 |
+
//
|
43 |
+
// Columns, offsets, pushes, and pulls for extra small devices like
|
44 |
+
// smartphones.
|
45 |
+
|
46 |
+
@include make-grid(xs);
|
47 |
+
|
48 |
+
|
49 |
+
// Small grid
|
50 |
+
//
|
51 |
+
// Columns, offsets, pushes, and pulls for the small device range, from phones
|
52 |
+
// to tablets.
|
53 |
+
|
54 |
+
@media (min-width: $screen-sm-min) {
|
55 |
+
@include make-grid(sm);
|
56 |
+
}
|
57 |
+
|
58 |
+
|
59 |
+
// Medium grid
|
60 |
+
//
|
61 |
+
// Columns, offsets, pushes, and pulls for the desktop device range.
|
62 |
+
|
63 |
+
@media (min-width: $screen-md-min) {
|
64 |
+
@include make-grid(md);
|
65 |
+
}
|
66 |
+
|
67 |
+
|
68 |
+
// Large grid
|
69 |
+
//
|
70 |
+
// Columns, offsets, pushes, and pulls for the large desktop device range.
|
71 |
+
|
72 |
+
@media (min-width: $screen-lg-min) {
|
73 |
+
@include make-grid(lg);
|
74 |
+
}
|
inc/woo-compare-wishlist/assets/scss/tm-woocompare.scss
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tm-woocompare-list,
|
2 |
+
.tm-woocompare-widget-wrapper {
|
3 |
+
&.loading {
|
4 |
+
position: relative;
|
5 |
+
.tm-wc-compare-wishlist-loader {
|
6 |
+
display: block;
|
7 |
+
}
|
8 |
+
}
|
9 |
+
.tm-wc-compare-wishlist-loader {
|
10 |
+
display: none;
|
11 |
+
position: absolute;
|
12 |
+
width: 100%;
|
13 |
+
height: 100%;
|
14 |
+
background: rgba(255,255,255,.5);
|
15 |
+
top: 0;
|
16 |
+
left: 0;
|
17 |
+
>* {
|
18 |
+
position: absolute;
|
19 |
+
top: 50%;
|
20 |
+
left: 50%;
|
21 |
+
transform: translate(-50%, -50%);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
.tm-woocompare-table {
|
27 |
+
width: 100%;
|
28 |
+
min-width: 100%;
|
29 |
+
table-layout: fixed;
|
30 |
+
&.tablesaw {
|
31 |
+
min-width: 0;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
.tm-woocompare-row {
|
36 |
+
background: rgba(0,0,0,.02);
|
37 |
+
thead + & {
|
38 |
+
background: none;
|
39 |
+
}
|
40 |
+
&:nth-child(odd) {
|
41 |
+
background: none;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
.tm-woocompare-cell {
|
46 |
+
width: auto;
|
47 |
+
position: relative;
|
48 |
+
background: rgba(0,0,0,.02);
|
49 |
+
&:nth-child(odd) {
|
50 |
+
background: none;
|
51 |
+
}
|
52 |
+
p{
|
53 |
+
margin: 0;
|
54 |
+
padding: 0;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
.tm-woocompare-remove {
|
58 |
+
position: absolute;
|
59 |
+
right: 5px;
|
60 |
+
top: 5px;
|
61 |
+
cursor: pointer;
|
62 |
+
color: #d42f2f;
|
63 |
+
text-align: center;
|
64 |
+
line-height: 17px;
|
65 |
+
font-size: 17px;
|
66 |
+
&:hover {
|
67 |
+
color: #a42424;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
.tm-woocompare-heading-cell {
|
72 |
+
width: 100px;
|
73 |
+
}
|
74 |
+
|
75 |
+
button.tm-woocompare-button {
|
76 |
+
&,
|
77 |
+
.woocommerce &{
|
78 |
+
display: -ms-inline-flexbox;
|
79 |
+
display: -webkit-inline-flex;
|
80 |
+
display: inline-flex;
|
81 |
+
-webkit-flex-direction: row;
|
82 |
+
-ms-flex-direction: row;
|
83 |
+
flex-direction: row;
|
84 |
+
-webkit-flex-wrap: nowrap;
|
85 |
+
-ms-flex-wrap: nowrap;
|
86 |
+
flex-wrap: nowrap;
|
87 |
+
-webkit-justify-content: center;
|
88 |
+
-ms-flex-pack: center;
|
89 |
+
justify-content: center;
|
90 |
+
-webkit-align-content: stretch;
|
91 |
+
-ms-flex-line-pack: stretch;
|
92 |
+
align-content: stretch;
|
93 |
+
-webkit-align-items: center;
|
94 |
+
-ms-flex-align: center;
|
95 |
+
align-items: center;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
.tm_woocompare_product_actions_tip {
|
99 |
+
&,
|
100 |
+
.text {
|
101 |
+
min-width: 0;
|
102 |
+
display: block;
|
103 |
+
}
|
104 |
+
.text {
|
105 |
+
text-overflow: ellipsis;
|
106 |
+
overflow: hidden;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
.tm-woocompare-widget-product {
|
111 |
+
position: relative;
|
112 |
+
margin: 0 0 20px;
|
113 |
+
}
|
114 |
+
|
115 |
+
.compare-count {
|
116 |
+
text-indent: 5px;
|
117 |
+
}
|
inc/woo-compare-wishlist/assets/scss/tm-woowishlist.scss
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.tm-woowishlist,
|
2 |
+
.tm-woocomerce-wishlist-widget-wrapper {
|
3 |
+
&.loading {
|
4 |
+
position: relative;
|
5 |
+
.tm-wc-compare-wishlist-loader {
|
6 |
+
display: block;
|
7 |
+
}
|
8 |
+
}
|
9 |
+
.tm-wc-compare-wishlist-loader {
|
10 |
+
display: none;
|
11 |
+
position: absolute;
|
12 |
+
width: 100%;
|
13 |
+
height: 100%;
|
14 |
+
background: rgba(255,255,255,.5);
|
15 |
+
top: 0;
|
16 |
+
left: 0;
|
17 |
+
>* {
|
18 |
+
position: absolute;
|
19 |
+
top: 50%;
|
20 |
+
left: 50%;
|
21 |
+
transform: translate(-50%, -50%);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
.tm-woowishlist-remove {
|
27 |
+
position: absolute;
|
28 |
+
right: 0px;
|
29 |
+
top: 0px;
|
30 |
+
cursor: pointer;
|
31 |
+
color: #d42f2f;
|
32 |
+
text-align: center;
|
33 |
+
line-height: 17px;
|
34 |
+
font-size: 17px;
|
35 |
+
&:hover {
|
36 |
+
color: #a42424;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
button.tm-woowishlist-button {
|
41 |
+
&,
|
42 |
+
.woocommerce &{
|
43 |
+
display: -ms-inline-flexbox;
|
44 |
+
display: -webkit-inline-flex;
|
45 |
+
display: inline-flex;
|
46 |
+
-webkit-flex-direction: row;
|
47 |
+
-ms-flex-direction: row;
|
48 |
+
flex-direction: row;
|
49 |
+
-webkit-flex-wrap: nowrap;
|
50 |
+
-ms-flex-wrap: nowrap;
|
51 |
+
flex-wrap: nowrap;
|
52 |
+
-webkit-justify-content: center;
|
53 |
+
-ms-flex-pack: center;
|
54 |
+
justify-content: center;
|
55 |
+
-webkit-align-content: stretch;
|
56 |
+
-ms-flex-line-pack: stretch;
|
57 |
+
align-content: stretch;
|
58 |
+
-webkit-align-items: center;
|
59 |
+
-ms-flex-align: center;
|
60 |
+
align-items: center;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
.tm-woowishlist-item {
|
65 |
+
position: relative;
|
66 |
+
margin: 0 0 20px;
|
67 |
+
&:after{
|
68 |
+
content: '';
|
69 |
+
clear: both;
|
70 |
+
display: block;
|
71 |
+
}
|
72 |
+
.tm-woocomerce-list__product-title {
|
73 |
+
margin: 0 0 10px;
|
74 |
+
}
|
75 |
+
.tm-woocomerce-list__product-image {
|
76 |
+
float: left;margin: 0 30px 10px 0;
|
77 |
+
}
|
78 |
+
.price {
|
79 |
+
display: block;
|
80 |
+
margin: 0 0 10px;
|
81 |
+
}
|
82 |
+
.stock {
|
83 |
+
color: #77a464;
|
84 |
+
&.out-of-stock {
|
85 |
+
color: red;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
.tm-woowishlist-widget-product {
|
91 |
+
position: relative;
|
92 |
+
margin: 0 0 20px;
|
93 |
+
}
|
inc/woo-compare-wishlist/includes/compare/buttons.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// register action hooks
|
4 |
+
|
5 |
+
add_action( 'woocommerce_after_shop_loop_item', 'tx_woocompare_add_button_loop', 12 );
|
6 |
+
|
7 |
+
add_action( 'woocommerce_single_product_summary', 'tx_woocompare_add_button_single', 35 );
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Renders appropriate button for a loop product.
|
11 |
+
*
|
12 |
+
* @since 1.0.0
|
13 |
+
* @action woocommerce_after_shop_loop_item
|
14 |
+
*/
|
15 |
+
function tx_woocompare_add_button_loop( $args ) {
|
16 |
+
|
17 |
+
if ( 'yes' === get_option( 'tx_woocompare_show_in_catalog' ) ) {
|
18 |
+
|
19 |
+
tx_woocompare_add_button( $args );
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Renders appropriate button for a product.
|
25 |
+
*
|
26 |
+
* @since 1.0.0
|
27 |
+
*/
|
28 |
+
function tx_woocompare_add_button( $args ) {
|
29 |
+
|
30 |
+
$id = get_the_ID();
|
31 |
+
$id = tx_wc_compare_wishlist()->get_original_product_id( $id );
|
32 |
+
$classes = array( 'button', 'tm-woocompare-button', 'btn', 'btn-default' );
|
33 |
+
$nonce = wp_create_nonce( 'tx_woocompare' . $id );
|
34 |
+
|
35 |
+
if ( in_array( $id, tx_woocompare_get_list() ) ) {
|
36 |
+
|
37 |
+
$text = get_option( 'tx_woocompare_remove_text', __( 'Remove from Compare', 'tx-tk' ) );
|
38 |
+
$classes[] = ' in_compare';
|
39 |
+
|
40 |
+
} else {
|
41 |
+
|
42 |
+
$text = get_option( 'tx_woocompare_compare_text', __( 'Add to Compare', 'tx-tk' ) );
|
43 |
+
}
|
44 |
+
$text = '<span class="tx_woocompare_product_actions_tip"><span class="text">' . esc_html( $text ) . '</span></span>';
|
45 |
+
$preloader = apply_filters( 'tx_wc_compare_wishlist_button_preloader', '' );
|
46 |
+
|
47 |
+
if( $single = ( is_array( $args ) && isset( $args['single'] ) && $args['single'] ) ) {
|
48 |
+
|
49 |
+
$classes[] = 'tm-woocompare-button-single';
|
50 |
+
}
|
51 |
+
$html = sprintf( '<button type="button" class="%s" data-id="%s" data-nonce="%s" title="' . esc_attr( get_option( 'tx_woocompare_compare_text', __( 'Add to Compare', 'tx-tk' ) ) ) . '">%s</button>', implode( ' ', $classes ), $id, $nonce, $text . $preloader );
|
52 |
+
|
53 |
+
echo apply_filters( 'tx_woocompare_button', $html, $classes, $id, $nonce, $text, $preloader );
|
54 |
+
|
55 |
+
if( in_array( $id, tx_woocompare_get_list() ) && $single ) {
|
56 |
+
|
57 |
+
echo tx_woocompare_page_button();
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Renders appropriate button for a single product.
|
63 |
+
*
|
64 |
+
* @since 1.0.0
|
65 |
+
* @action woocommerce_single_product_summary
|
66 |
+
*/
|
67 |
+
function tx_woocompare_add_button_single( $args ) {
|
68 |
+
|
69 |
+
if ( 'yes' === get_option( 'tx_woocompare_show_in_single' ) ) {
|
70 |
+
|
71 |
+
if( empty( $args ) ) {
|
72 |
+
|
73 |
+
$args = array();
|
74 |
+
}
|
75 |
+
$args['single'] = true;
|
76 |
+
|
77 |
+
tx_woocompare_add_button( $args );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Renders wishlist page button for a product.
|
83 |
+
*
|
84 |
+
* @since 1.0.0
|
85 |
+
*/
|
86 |
+
function tx_woocompare_page_button() {
|
87 |
+
|
88 |
+
$link = tx_woocompare_get_page_link();
|
89 |
+
$classes = array( 'button', 'tm-woocompare-page-button', 'btn', 'btn-primary', 'alt' );
|
90 |
+
$text = __( 'View compare', 'tx-tk' );
|
91 |
+
$html = sprintf( '<a class="%s" href="%s">%s</a>', implode( ' ', $classes ), $link, $text );
|
92 |
+
|
93 |
+
return apply_filters( 'tx_woocompare_page_button', $html, $classes, $link, $text );
|
94 |
+
}
|
inc/woo-compare-wishlist/includes/compare/compare.php
ADDED
@@ -0,0 +1,615 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( is_admin() ) {
|
4 |
+
require_once TX_WC_COMPARE_WISHLIST_PATH . 'includes/compare/settings.php';
|
5 |
+
}
|
6 |
+
if ( 'yes' !== get_option( 'tx_woocompare_enable' ) ) {
|
7 |
+
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
require_once 'buttons.php';
|
11 |
+
|
12 |
+
if ( ! is_admin() ) {
|
13 |
+
|
14 |
+
require_once 'shortcode.php';
|
15 |
+
}
|
16 |
+
require_once 'widget.php';
|
17 |
+
|
18 |
+
if ( ! session_id() ) {
|
19 |
+
|
20 |
+
session_start();
|
21 |
+
}
|
22 |
+
|
23 |
+
// register action hooks
|
24 |
+
add_action( 'wp_enqueue_scripts', 'tx_woocompare_setup_plugin' );
|
25 |
+
|
26 |
+
add_action( 'wp_ajax_tx_woocompare_add_to_list', 'tx_woocompare_process_button_action' );
|
27 |
+
add_action( 'wp_ajax_nopriv_tx_woocompare_add_to_list', 'tx_woocompare_process_button_action' );
|
28 |
+
|
29 |
+
add_action( 'wp_ajax_tx_woocompare_remove', 'tx_woocompare_process_remove_button_action' );
|
30 |
+
add_action( 'wp_ajax_nopriv_tx_woocompare_remove', 'tx_woocompare_process_remove_button_action' );
|
31 |
+
|
32 |
+
add_action( 'wp_ajax_tx_woocompare_empty', 'tx_woocompare_process_empty_button_action' );
|
33 |
+
add_action( 'wp_ajax_nopriv_tx_woocompare_empty', 'tx_woocompare_process_empty_button_action' );
|
34 |
+
|
35 |
+
add_action( 'wp_ajax_tx_woocompare_update', 'tx_woocompare_process_ajax' );
|
36 |
+
add_action( 'wp_ajax_nopriv_tx_woocompare_update', 'tx_woocompare_process_ajax' );
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Registers scripts, styles and page endpoint.
|
40 |
+
*
|
41 |
+
* @since 1.0.0
|
42 |
+
* @action init
|
43 |
+
*/
|
44 |
+
function tx_woocompare_setup_plugin() {
|
45 |
+
|
46 |
+
wp_enqueue_style( 'tm-woocompare' );
|
47 |
+
wp_enqueue_script( 'tm-woocompare' );
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Returns compare list.
|
52 |
+
*
|
53 |
+
* @sicne 1.0.0
|
54 |
+
*
|
55 |
+
* @return array The array of product ids to compare.
|
56 |
+
*/
|
57 |
+
function tx_woocompare_get_list() {
|
58 |
+
|
59 |
+
$list = ! empty( $_SESSION['tm-woocompare-list'] ) ? $_SESSION['tm-woocompare-list'] : array();
|
60 |
+
|
61 |
+
if ( ! empty( $list ) ) {
|
62 |
+
$list = explode( ':', $list );
|
63 |
+
}
|
64 |
+
return $list;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Sets new list of products to compare.
|
69 |
+
*
|
70 |
+
* @since 1.0.0
|
71 |
+
*
|
72 |
+
* @param array $list The new array of products to compare.
|
73 |
+
*/
|
74 |
+
function tx_woocompare_set_list( $list ) {
|
75 |
+
$value = implode( ':', $list );
|
76 |
+
$_SESSION['tm-woocompare-list'] = $value;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Returns compare page link.
|
81 |
+
*
|
82 |
+
* @since 1.0.0
|
83 |
+
*
|
84 |
+
* @return string The compare pare link on success, otherwise FALSE.
|
85 |
+
*/
|
86 |
+
function tx_woocompare_get_page_link() {
|
87 |
+
|
88 |
+
$page_id = intval( get_option( 'tx_woocompare_page' ) );
|
89 |
+
|
90 |
+
if ( ! $page_id ) {
|
91 |
+
|
92 |
+
return false;
|
93 |
+
}
|
94 |
+
$page_link = get_permalink( $page_id );
|
95 |
+
|
96 |
+
if ( ! $page_link ) {
|
97 |
+
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
return trailingslashit( $page_link );
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Processes buttons actions.
|
105 |
+
*
|
106 |
+
* @since 1.0.0
|
107 |
+
*
|
108 |
+
* @action wp_ajax_tx_woocompare_add_to_list
|
109 |
+
*/
|
110 |
+
function tx_woocompare_process_button_action() {
|
111 |
+
|
112 |
+
$id = filter_input( INPUT_POST, 'pid', FILTER_SANITIZE_NUMBER_INT );
|
113 |
+
$list = tx_woocompare_get_list();
|
114 |
+
$key = array_search( $id, $list );
|
115 |
+
$button = false;
|
116 |
+
|
117 |
+
if ( false !== $key ) {
|
118 |
+
|
119 |
+
$action = 'remove';
|
120 |
+
|
121 |
+
tx_woocompare_remove( $id );
|
122 |
+
|
123 |
+
} else {
|
124 |
+
|
125 |
+
$action = 'add';
|
126 |
+
$button = json_decode( filter_input( INPUT_POST, 'single' ) ) ? tx_woocompare_page_button() : false;
|
127 |
+
|
128 |
+
tx_woocompare_add( $id );
|
129 |
+
}
|
130 |
+
|
131 |
+
wp_send_json_success( array(
|
132 |
+
'action' => $action,
|
133 |
+
'comparePageBtn' => $button,
|
134 |
+
'counts' => tx_woocompare_get_counts_data(),
|
135 |
+
) );
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Returns message when is no products in compare.
|
140 |
+
*
|
141 |
+
* @since 1.0.2
|
142 |
+
*
|
143 |
+
* @return string The message
|
144 |
+
*/
|
145 |
+
function tx_woocompare_empty_message() {
|
146 |
+
|
147 |
+
$empty_text = get_option( 'tx_woocompare_empty_text', __( 'No products found to compare.', 'tx-tk' ) );
|
148 |
+
$html = sprintf( '<p class="tm-woocompare-empty">%s</p>', $empty_text );
|
149 |
+
|
150 |
+
return apply_filters( 'tx_woocompare_empty_message', $html, $empty_text );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Processes main ajax handler.
|
155 |
+
*
|
156 |
+
* @since 1.0.0
|
157 |
+
*
|
158 |
+
* @action wp_ajax_tx_woocompare_update
|
159 |
+
*/
|
160 |
+
function tx_woocompare_process_ajax() {
|
161 |
+
|
162 |
+
$is_page = json_decode( filter_input( INPUT_POST, 'isComparePage' ) );
|
163 |
+
$is_widget = json_decode( filter_input( INPUT_POST, 'isWidget' ) );
|
164 |
+
$json = array();
|
165 |
+
|
166 |
+
if ( $is_page ) {
|
167 |
+
|
168 |
+
$json['compareList'] = tx_woocompare_list_render_table();
|
169 |
+
}
|
170 |
+
if ( $is_widget ) {
|
171 |
+
|
172 |
+
$json['widget'] = tx_woocompare_list_render_widget();
|
173 |
+
}
|
174 |
+
|
175 |
+
$json['counts'] = tx_woocompare_get_counts_data();
|
176 |
+
|
177 |
+
wp_send_json_success( $json );
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Processes remove button action.
|
182 |
+
*
|
183 |
+
* @since 1.0.0
|
184 |
+
*
|
185 |
+
* @action wp_ajax_tx_woocompare_remove
|
186 |
+
*/
|
187 |
+
function tx_woocompare_process_remove_button_action() {
|
188 |
+
$product_id = filter_input( INPUT_POST, 'pid', FILTER_SANITIZE_NUMBER_INT );
|
189 |
+
tx_woocompare_remove( $product_id );
|
190 |
+
tx_woocompare_process_ajax();
|
191 |
+
}
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Processes empty button action.
|
195 |
+
*
|
196 |
+
* @since 1.0.0
|
197 |
+
*
|
198 |
+
* @action wp_ajax_tx_woocompare_empty
|
199 |
+
*/
|
200 |
+
function tx_woocompare_process_empty_button_action() {
|
201 |
+
|
202 |
+
tx_woocompare_set_list( array() );
|
203 |
+
|
204 |
+
tx_woocompare_process_ajax();
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Adds product to compare list.
|
209 |
+
*
|
210 |
+
* @since 1.0.0
|
211 |
+
*
|
212 |
+
* @param int $id The product id to add to the compare list.
|
213 |
+
*/
|
214 |
+
function tx_woocompare_add( $id ) {
|
215 |
+
|
216 |
+
$list = tx_woocompare_get_list();
|
217 |
+
$list[] = $id;
|
218 |
+
|
219 |
+
tx_woocompare_set_list( $list );
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Removes product from compare list.
|
224 |
+
*
|
225 |
+
* @since 1.0.0
|
226 |
+
*
|
227 |
+
* @param int $id The product id to remove from compare list.
|
228 |
+
*/
|
229 |
+
function tx_woocompare_remove( $id ) {
|
230 |
+
|
231 |
+
$list = tx_woocompare_get_list();
|
232 |
+
|
233 |
+
foreach ( wp_parse_id_list( $id ) as $id ) {
|
234 |
+
|
235 |
+
$key = array_search( $id, $list );
|
236 |
+
|
237 |
+
if ( false !== $key ) {
|
238 |
+
|
239 |
+
unset( $list[$key] );
|
240 |
+
}
|
241 |
+
}
|
242 |
+
tx_woocompare_set_list( $list );
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Get products added to compare.
|
247 |
+
*
|
248 |
+
* @since 1.0.0
|
249 |
+
*
|
250 |
+
* @param array $list The array of products ids.
|
251 |
+
* @return object The list of products
|
252 |
+
*/
|
253 |
+
function tx_woocompare_get_products( $list ) {
|
254 |
+
|
255 |
+
$args = array(
|
256 |
+
'post_type' => 'product',
|
257 |
+
'post__in' => $list,
|
258 |
+
'orderby' => 'post__in',
|
259 |
+
'posts_per_page' => -1
|
260 |
+
);
|
261 |
+
$products = new WP_Query( $args );
|
262 |
+
|
263 |
+
return $products;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* Renders compare list.
|
268 |
+
*
|
269 |
+
* @since 1.0.0
|
270 |
+
*
|
271 |
+
* @param array $atts The array of attributes to show in the table.
|
272 |
+
* @return string Compare table HTML.
|
273 |
+
*/
|
274 |
+
function tx_woocompare_list_render( $atts = array() ) {
|
275 |
+
|
276 |
+
$tx_wc_compare_wishlist = tx_wc_compare_wishlist();
|
277 |
+
$content = array();
|
278 |
+
$content[] = '<div class="woocommerce tm-woocompare-list">';
|
279 |
+
$content[] = '<div class="woocommerce tm-woocompare-wrapper">';
|
280 |
+
$content[] = tx_woocompare_list_render_table( $atts );
|
281 |
+
$content[] = '</div>';
|
282 |
+
$content[] = $tx_wc_compare_wishlist->get_loader();
|
283 |
+
$content[] = '</div>';
|
284 |
+
|
285 |
+
return implode( "\n", $content );
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Renders compare widget.
|
290 |
+
*
|
291 |
+
* @since 1.0.0
|
292 |
+
*
|
293 |
+
* @return string Wishlist widget HTML.
|
294 |
+
*/
|
295 |
+
function tx_woocompare_list_render_widget() {
|
296 |
+
|
297 |
+
$list = tx_woocompare_get_list();
|
298 |
+
|
299 |
+
if ( empty( $list ) ) {
|
300 |
+
|
301 |
+
return tx_woocompare_empty_message();
|
302 |
+
}
|
303 |
+
$templater = tx_wc_compare_wishlist_templater();
|
304 |
+
$products = tx_woocompare_get_products( $list );
|
305 |
+
$template = get_option( 'tx_woocompare_widget_template' );
|
306 |
+
$template = $templater->get_template_by_name( $template, 'tm-woocompare' );
|
307 |
+
|
308 |
+
if( ! $template ) {
|
309 |
+
|
310 |
+
$template = $templater->get_template_by_name( 'widget.tmpl', 'tm-woocompare' );
|
311 |
+
}
|
312 |
+
$content = array();
|
313 |
+
$tx_wc_compare_wishlist = tx_wc_compare_wishlist();
|
314 |
+
|
315 |
+
if ( $products->have_posts() ) {
|
316 |
+
|
317 |
+
$content[] = '<div class="tm-woocompare-widget-products">' . "\n";
|
318 |
+
|
319 |
+
while ( $products->have_posts() ) {
|
320 |
+
|
321 |
+
$products->the_post();
|
322 |
+
|
323 |
+
global $product;
|
324 |
+
|
325 |
+
if ( empty( $product ) ) {
|
326 |
+
|
327 |
+
continue;
|
328 |
+
}
|
329 |
+
$pid = method_exists( $product, 'get_id' ) ? $product->get_id() : get_the_id();
|
330 |
+
$pid = $tx_wc_compare_wishlist->get_original_product_id( $pid );
|
331 |
+
$dismiss_icon = apply_filters( 'tx_woocompare_dismiss_icon', '<span class="dashicons dashicons-dismiss"></span>' );
|
332 |
+
$content[] = '<div class="tm-woocompare-widget-product">' . "\n";
|
333 |
+
$content[] = '<span class="tm-woocompare-remove" data-id="' . $pid . '">' . $dismiss_icon . '</span>';
|
334 |
+
$content[] = $templater->parse_template( $template );
|
335 |
+
$content[] = '</div>';
|
336 |
+
}
|
337 |
+
$content[] = '</div>';
|
338 |
+
$content[] = '<a href="' . tx_woocompare_get_page_link() . '" class="button btn btn-default compare_link_btn">' . get_option( 'tx_woocompare_page_btn_text', __( 'Compare products' , 'tx-tk' ) ) . '</a>';
|
339 |
+
$content[] = '<button type="button" class="button btn btn-primary btn-danger tm-woocompare-empty">' . get_option( 'tx_woocompare_empty_btn_text', __( 'Empty compare' , 'tx-tk' ) ) . '</button>';
|
340 |
+
$content[] = $tx_wc_compare_wishlist->get_loader();
|
341 |
+
}
|
342 |
+
wp_reset_query();
|
343 |
+
|
344 |
+
return implode( "\n", $content );
|
345 |
+
}
|
346 |
+
|
347 |
+
/**
|
348 |
+
* Renders compare table.
|
349 |
+
*
|
350 |
+
* @since 1.0.0
|
351 |
+
*
|
352 |
+
* @param array $selected_attributes Coming soon.
|
353 |
+
*
|
354 |
+
* @return string Wishlist table HTML.
|
355 |
+
*/
|
356 |
+
function tx_woocompare_list_render_table( $selected_attributes = array() ) {
|
357 |
+
|
358 |
+
$list = tx_woocompare_get_list();
|
359 |
+
|
360 |
+
if ( empty( $list ) ) {
|
361 |
+
|
362 |
+
return tx_woocompare_empty_message();
|
363 |
+
}
|
364 |
+
|
365 |
+
$templater = tx_wc_compare_wishlist_templater();
|
366 |
+
$products = tx_woocompare_get_products( $list );
|
367 |
+
$products_content = array();
|
368 |
+
$template = get_option( 'tx_woocompare_page_template' );
|
369 |
+
$template = $templater->get_template_by_name( $template, 'tm-woocompare' );
|
370 |
+
|
371 |
+
if( ! $template ) {
|
372 |
+
|
373 |
+
$template = $templater->get_template_by_name( 'page.tmpl', 'tm-woocompare' );
|
374 |
+
}
|
375 |
+
|
376 |
+
$replace_data = $templater->get_replace_data();
|
377 |
+
|
378 |
+
while ( $products->have_posts() ) {
|
379 |
+
|
380 |
+
$products->the_post();
|
381 |
+
|
382 |
+
global $product;
|
383 |
+
|
384 |
+
if ( empty( $product ) ) {
|
385 |
+
|
386 |
+
continue;
|
387 |
+
}
|
388 |
+
$pid = method_exists( $product, 'get_id' ) ? $product->get_id() : get_the_id();
|
389 |
+
$pid = tx_wc_compare_wishlist()->get_original_product_id( $pid );
|
390 |
+
preg_match_all( $templater->macros_regex(), $template, $matches );
|
391 |
+
|
392 |
+
if( ! empty( $matches[1] ) ) {
|
393 |
+
|
394 |
+
foreach ( $matches[1] as $match ) {
|
395 |
+
|
396 |
+
$macros = array_filter( explode( ' ', $match, 2 ) );
|
397 |
+
$callback = strtolower( $macros[0] );
|
398 |
+
$attr = isset( $macros[1] ) ? shortcode_parse_atts( $macros[1] ) : array();
|
399 |
+
|
400 |
+
if ( ! isset( $replace_data[ $callback ] ) ) {
|
401 |
+
|
402 |
+
continue;
|
403 |
+
}
|
404 |
+
$callback_func = $replace_data[ $callback ];
|
405 |
+
|
406 |
+
if ( ! is_callable( $callback_func ) ) {
|
407 |
+
|
408 |
+
continue;
|
409 |
+
}
|
410 |
+
$content = call_user_func( $callback_func, $attr );
|
411 |
+
|
412 |
+
if( 'attributes' == $callback ) {
|
413 |
+
|
414 |
+
$products_content[$pid][$callback] = $content;
|
415 |
+
|
416 |
+
} else {
|
417 |
+
|
418 |
+
$products_content[$pid][] = $content;
|
419 |
+
}
|
420 |
+
}
|
421 |
+
}
|
422 |
+
}
|
423 |
+
wp_reset_query();
|
424 |
+
|
425 |
+
$parsed_products = tx_woocompare_parse_products( $products_content );
|
426 |
+
|
427 |
+
return tx_woocompare_compare_list_get_table( $parsed_products, $products );
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Get compare table.
|
432 |
+
*
|
433 |
+
* @since 1.0.1
|
434 |
+
*
|
435 |
+
* @param array $content The parsed products content.
|
436 |
+
* @param object $products The products.
|
437 |
+
*
|
438 |
+
* @return string Wishlist table HTML.
|
439 |
+
*/
|
440 |
+
function tx_woocompare_compare_list_get_table( $content, $products ) {
|
441 |
+
|
442 |
+
$html = array();
|
443 |
+
$i = 0;
|
444 |
+
|
445 |
+
foreach ( $content as $key => $row ) {
|
446 |
+
|
447 |
+
$row = array_filter( $row );
|
448 |
+
|
449 |
+
$i++;
|
450 |
+
|
451 |
+
if( empty( $row ) ) {
|
452 |
+
|
453 |
+
continue;
|
454 |
+
}
|
455 |
+
if ( 1 == $i ) {
|
456 |
+
|
457 |
+
$html[] = '<table class="tm-woocompare-table tablesaw" data-tablesaw-mode="swipe">';
|
458 |
+
$html[] = '<thead>';
|
459 |
+
}
|
460 |
+
if ( 2 == $i ) {
|
461 |
+
|
462 |
+
$html[] = '<tbody>';
|
463 |
+
}
|
464 |
+
$html[] = '<tr class="tm-woocompare-row">';
|
465 |
+
|
466 |
+
if ( 1 == $i ) {
|
467 |
+
|
468 |
+
$tag = 'th';
|
469 |
+
$html[] = '<th class="tm-woocompare-heading-cell title" data-tablesaw-priority="persist" scope="col" data-tablesaw-sortable-col>';
|
470 |
+
|
471 |
+
} else {
|
472 |
+
|
473 |
+
$tag = 'td';
|
474 |
+
$html[] = '<th class="tm-woocompare-heading-cell title">';
|
475 |
+
}
|
476 |
+
if ( 'string' === gettype( $key ) ) {
|
477 |
+
|
478 |
+
$html[] = $key;
|
479 |
+
}
|
480 |
+
$html[] = '</th>';
|
481 |
+
|
482 |
+
while ( $products->have_posts() ) {
|
483 |
+
|
484 |
+
$products->the_post();
|
485 |
+
|
486 |
+
global $product;
|
487 |
+
|
488 |
+
$atts = '';
|
489 |
+
|
490 |
+
if ( 1 == $i ) {
|
491 |
+
$atts = ' scope="col" data-tablesaw-sortable-col';
|
492 |
+
}
|
493 |
+
|
494 |
+
$html[] = '<' . $tag . ' class="tm-woocompare-cell"' . $atts . '>';
|
495 |
+
$pid = method_exists( $product, 'get_id' ) ? $product->get_id() : get_the_id();
|
496 |
+
$pid = tx_wc_compare_wishlist()->get_original_product_id( $pid );
|
497 |
+
|
498 |
+
if ( 1 == $i ) {
|
499 |
+
|
500 |
+
$dismiss_icon = apply_filters( 'tx_woocompare_dismiss_icon', '<span class="dashicons dashicons-dismiss"></span>' );
|
501 |
+
$html[] = '<div class="tm-woocompare-remove" data-id="' . $pid . '">' . $dismiss_icon . '</div>';
|
502 |
+
}
|
503 |
+
$html[] = $row[$pid];
|
504 |
+
$html[] = '</' . $tag . '>';
|
505 |
+
}
|
506 |
+
$html[] = '</tr>';
|
507 |
+
|
508 |
+
if ( 1 == $i ) {
|
509 |
+
|
510 |
+
$html[] = '</thead>';
|
511 |
+
}
|
512 |
+
if ( $i == count( $content ) ) {
|
513 |
+
|
514 |
+
$html[] = '</tbody>';
|
515 |
+
$html[] = '</table>';
|
516 |
+
}
|
517 |
+
}
|
518 |
+
wp_reset_query();
|
519 |
+
|
520 |
+
return implode( "\n", $html );
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Parse products attributes.
|
525 |
+
*
|
526 |
+
* @since 1.0.0
|
527 |
+
*
|
528 |
+
* @param array $attributes The products attributes.
|
529 |
+
*
|
530 |
+
* @return array parsed products attributes.
|
531 |
+
*/
|
532 |
+
function tx_woocompare_parse_products_attributes( $attributes ) {
|
533 |
+
|
534 |
+
$rebuilded_attributes = array();
|
535 |
+
|
536 |
+
foreach ( $attributes as $id => $attribute ) {
|
537 |
+
|
538 |
+
foreach ( $attribute as $attr_name => $attribute_value ) {
|
539 |
+
|
540 |
+
$rebuilded_attributes[$attr_name][$id] = $attribute_value;
|
541 |
+
}
|
542 |
+
}
|
543 |
+
foreach ( $rebuilded_attributes as $attr_name => $attr_products ) {
|
544 |
+
|
545 |
+
foreach ( $attributes as $id => $attribute ) {
|
546 |
+
|
547 |
+
if ( ! array_key_exists( $id, $attr_products ) ) {
|
548 |
+
|
549 |
+
$rebuilded_attributes[$attr_name][$id] = '—';
|
550 |
+
}
|
551 |
+
}
|
552 |
+
}
|
553 |
+
return $rebuilded_attributes;
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* Parse products.
|
558 |
+
*
|
559 |
+
* @since 1.0.0
|
560 |
+
*
|
561 |
+
* @param array $products_content The products content.
|
562 |
+
*
|
563 |
+
* @return array parsed products content.
|
564 |
+
*/
|
565 |
+
function tx_woocompare_parse_products( $products_content ) {
|
566 |
+
|
567 |
+
$parsed_products = array();
|
568 |
+
|
569 |
+
foreach ( $products_content as $product_id => $product_content_arr ) {
|
570 |
+
|
571 |
+
foreach ( $product_content_arr as $key => $product_content ) {
|
572 |
+
|
573 |
+
$parsed_products[$key][$product_id] = $product_content;
|
574 |
+
}
|
575 |
+
}
|
576 |
+
if( array_key_exists( 'attributes', $parsed_products ) && ! empty( $parsed_products['attributes'] ) ) {
|
577 |
+
|
578 |
+
$attributes = tx_woocompare_parse_products_attributes( $parsed_products['attributes'] );
|
579 |
+
$key = array_search( 'attributes', array_keys( $parsed_products ), true );
|
580 |
+
$before = array_slice( $parsed_products, 0, $key, true );
|
581 |
+
$after = array_slice( $parsed_products, ( $key + 1 ), null, true );
|
582 |
+
$parsed_products = array_merge( $before, $attributes, $after );
|
583 |
+
}
|
584 |
+
return $parsed_products;
|
585 |
+
}
|
586 |
+
|
587 |
+
add_action( 'wp_ajax_tx_compare_get_fragments', 'tx_woocompare_update_fragments' );
|
588 |
+
add_action( 'wp_ajax_nopriv_tx_compare_get_fragments', 'tx_woocompare_update_fragments' );
|
589 |
+
|
590 |
+
/**
|
591 |
+
* Update compare counts on page load and products status change
|
592 |
+
*
|
593 |
+
* @since 1.1.0
|
594 |
+
* @return void
|
595 |
+
*/
|
596 |
+
function tx_woocompare_update_fragments() {
|
597 |
+
wp_send_json_success( tx_woocompare_get_counts_data() );
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
* Returns cart counts
|
602 |
+
*
|
603 |
+
* @since 1.1.0
|
604 |
+
* @return array
|
605 |
+
*/
|
606 |
+
function tx_woocompare_get_counts_data() {
|
607 |
+
|
608 |
+
$count = sprintf( '%d', count( tx_woocompare_get_list() ) );
|
609 |
+
$default = apply_filters( 'tx_compare_default_count', array( '.menu-compare > a' => $count ) );
|
610 |
+
|
611 |
+
return array(
|
612 |
+
'defaultFragments' => $default,
|
613 |
+
'customFragments' => apply_filters( 'tx_compare_refreshed_fragments', array() )
|
614 |
+
);
|
615 |
+
}
|
inc/woo-compare-wishlist/includes/compare/settings.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// prevent direct access
|
4 |
+
if ( !defined( 'ABSPATH' ) ) {
|
5 |
+
|
6 |
+
header( 'HTTP/1.0 404 Not Found', true, 404 );
|
7 |
+
|
8 |
+
exit;
|
9 |
+
}
|
10 |
+
|
11 |
+
// register action hooks
|
12 |
+
add_action( 'woocommerce_settings_start', 'tx_woocompare_register_settings' );
|
13 |
+
add_action( 'woocommerce_settings_tx_woocompare_list', 'tx_woocompare_render_settings_page' );
|
14 |
+
add_action( 'woocommerce_update_options_tx_woocompare_list', 'tx_woocompare_update_options' );
|
15 |
+
|
16 |
+
// register filter hooks
|
17 |
+
add_filter( 'woocommerce_settings_tabs_array', 'tx_woocompare_register_settings_tab', PHP_INT_MAX );
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Returns array of the plugin settings, which will be rendered in the
|
21 |
+
* WooCommerce settings tab.
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
*
|
25 |
+
* @return array The array of the plugin settings.
|
26 |
+
*/
|
27 |
+
function tx_woocompare_get_settings() {
|
28 |
+
|
29 |
+
return array(
|
30 |
+
array(
|
31 |
+
'id' => 'general-options',
|
32 |
+
'type' => 'title',
|
33 |
+
'title' => __( 'General Options', 'tx-tk' ),
|
34 |
+
),
|
35 |
+
array(
|
36 |
+
'type' => 'checkbox',
|
37 |
+
'id' => 'tx_woocompare_enable',
|
38 |
+
'title' => __( 'Enable compare', 'tx-tk' ),
|
39 |
+
'desc' => __( 'Enable compare functionality.', 'tx-tk' ),
|
40 |
+
'default' => 'yes',
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'type' => 'single_select_page',
|
44 |
+
'id' => 'tx_woocompare_page',
|
45 |
+
'class' => 'chosen_select_nostd',
|
46 |
+
'title' => __( 'Select compare page', 'tx-tk' ),
|
47 |
+
'desc' => '<br>' . __( 'Select a page which will display compare list.', 'tx-tk' ),
|
48 |
+
),
|
49 |
+
array(
|
50 |
+
'type' => 'checkbox',
|
51 |
+
'id' => 'tx_woocompare_show_in_catalog',
|
52 |
+
'title' => __( 'Show in catalog', 'tx-tk' ),
|
53 |
+
'desc' => __( 'Enable compare functionality for catalog list.', 'tx-tk' ),
|
54 |
+
'default' => 'yes',
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'type' => 'checkbox',
|
58 |
+
'id' => 'tx_woocompare_show_in_single',
|
59 |
+
'title' => __( 'Show in products page', 'tx-tk' ),
|
60 |
+
'desc' => __( 'Enable compare functionality for single product page.', 'tx-tk' ),
|
61 |
+
'default' => 'yes',
|
62 |
+
),
|
63 |
+
array(
|
64 |
+
'type' => 'text',
|
65 |
+
'id' => 'tx_woocompare_compare_text',
|
66 |
+
'title' => __( 'Compare button text', 'tx-tk' ),
|
67 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the add to compare button.', 'tx-tk' ),
|
68 |
+
'default' => __( 'Add to Compare', 'tx-tk' ),
|
69 |
+
),
|
70 |
+
array(
|
71 |
+
'type' => 'text',
|
72 |
+
'id' => 'tx_woocompare_remove_text',
|
73 |
+
'title' => __( 'Remove button text', 'tx-tk' ),
|
74 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the remove from compare button.', 'tx-tk' ),
|
75 |
+
'default' => __( 'Remove from Compare', 'tx-tk' ),
|
76 |
+
),
|
77 |
+
array(
|
78 |
+
'type' => 'text',
|
79 |
+
'id' => 'tx_woocompare_page_btn_text',
|
80 |
+
'title' => __( 'Page button text' , 'tx-tk' ),
|
81 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the compare page button.', 'tx-tk' ),
|
82 |
+
'default' => __( 'Compare products' , 'tx-tk' ),
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'type' => 'text',
|
86 |
+
'id' => 'tx_woocompare_empty_btn_text',
|
87 |
+
'title' => __( 'Empty button text' , 'tx-tk' ),
|
88 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the empty compare button.', 'tx-tk' ),
|
89 |
+
'default' => __( 'Empty compare' , 'tx-tk' ),
|
90 |
+
),
|
91 |
+
array(
|
92 |
+
'type' => 'text',
|
93 |
+
'id' => 'tx_woocompare_empty_text',
|
94 |
+
'title' => __( 'Empty compare list text', 'tx-tk' ),
|
95 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the compare page when is nothing to compare.', 'tx-tk' ),
|
96 |
+
'default' => __( 'No products found to compare.', 'tx-tk' ),
|
97 |
+
),
|
98 |
+
array(
|
99 |
+
'type' => 'text',
|
100 |
+
'id' => 'tx_woocompare_page_template',
|
101 |
+
'title' => __( 'Page template', 'tx-tk' ),
|
102 |
+
'default' => __( 'page.tmpl', 'tx-tk' ),
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'type' => 'text',
|
106 |
+
'id' => 'tx_woocompare_widget_template',
|
107 |
+
'title' => __( 'Widget template', 'tx-tk' ),
|
108 |
+
'default' => __( 'widget.tmpl', 'tx-tk' ),
|
109 |
+
),
|
110 |
+
array( 'type' => 'sectionend', 'id' => 'general-options' ),
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Registers plugin settings in the WooCommerce settings array.
|
116 |
+
*
|
117 |
+
* @since 1.0.0
|
118 |
+
* @action woocommerce_settings_start
|
119 |
+
*
|
120 |
+
* @global array $woocommerce_settings WooCommerce settings array.
|
121 |
+
*/
|
122 |
+
function tx_woocompare_register_settings() {
|
123 |
+
|
124 |
+
global $woocommerce_settings;
|
125 |
+
|
126 |
+
$woocommerce_settings['tx_woocompare_list'] = tx_woocompare_get_settings();
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Registers WooCommerce settings tab which will display the plugin settings.
|
131 |
+
*
|
132 |
+
* @since 1.0.0
|
133 |
+
* @filter woocommerce_settings_tabs_array PHP_INT_MAX
|
134 |
+
*
|
135 |
+
* @param array $tabs The array of already registered tabs.
|
136 |
+
* @return array The extended array with the plugin tab.
|
137 |
+
*/
|
138 |
+
function tx_woocompare_register_settings_tab( $tabs ) {
|
139 |
+
|
140 |
+
$tabs['tx_woocompare_list'] = esc_html__( 'TX Compare List', 'tx-tk' );
|
141 |
+
|
142 |
+
return $tabs;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Renders plugin settings tab.
|
147 |
+
*
|
148 |
+
* @since 1.0.0
|
149 |
+
* @action woocommerce_settings_tx_woocompare_list
|
150 |
+
*
|
151 |
+
* @global array $woocommerce_settings The aggregate array of WooCommerce settings.
|
152 |
+
* @global string $current_tab The current WooCommerce settings tab.
|
153 |
+
*/
|
154 |
+
function tx_woocompare_render_settings_page() {
|
155 |
+
|
156 |
+
global $woocommerce_settings, $current_tab;
|
157 |
+
|
158 |
+
if ( function_exists( 'woocommerce_admin_fields' ) ) {
|
159 |
+
|
160 |
+
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
/**
|
165 |
+
* Updates plugin settings after submission.
|
166 |
+
*
|
167 |
+
* @since 1.0.0
|
168 |
+
* @action woocommerce_update_options_tx_woocompare_list
|
169 |
+
*/
|
170 |
+
function tx_woocompare_update_options() {
|
171 |
+
|
172 |
+
if ( function_exists( 'woocommerce_update_options' ) ) {
|
173 |
+
|
174 |
+
woocommerce_update_options( tx_woocompare_get_settings() );
|
175 |
+
}
|
176 |
+
}
|
inc/woo-compare-wishlist/includes/compare/shortcode.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// add shortcode hooks
|
4 |
+
add_shortcode( 'tx_woo_compare_table', 'tx_woocompare_shortcode' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Renders compare list shortcode.
|
8 |
+
*
|
9 |
+
* @since 1.0.0
|
10 |
+
* @shortcode tx_woo_compare_table
|
11 |
+
*/
|
12 |
+
function tx_woocompare_shortcode( $atts ) {
|
13 |
+
|
14 |
+
wp_enqueue_style( 'tablesaw' );
|
15 |
+
wp_enqueue_script( 'tablesaw-init' );
|
16 |
+
|
17 |
+
return tx_woocompare_list_render();
|
18 |
+
}
|
inc/woo-compare-wishlist/includes/compare/widget.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// add action hooks
|
4 |
+
add_action( 'widgets_init', 'tx_woocompare_widgets_init' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Registers widgets.
|
8 |
+
*
|
9 |
+
* @since 1.0.0
|
10 |
+
* @action widgets_init
|
11 |
+
*/
|
12 |
+
function tx_woocompare_widgets_init() {
|
13 |
+
|
14 |
+
register_widget( 'Tm_Woocommerce_Recent_Compare_Widget' );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Recent compare widget.
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
class Tm_Woocommerce_Recent_Compare_Widget extends WP_Widget {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Constructor.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
|
33 |
+
parent::__construct( 'tx_woocompare_recent_compare_list', esc_html__( 'TX WooCommerce Recent Compare', 'tx-tk' ), array(
|
34 |
+
'description' => esc_html__( 'Shows a recent compare on your site.', 'tx-tk' ),
|
35 |
+
) );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Renders widget settings form.
|
40 |
+
*
|
41 |
+
* @since 1.0.0
|
42 |
+
*
|
43 |
+
* @access public
|
44 |
+
* @param array $instance The array of values, associated with current widget instance.
|
45 |
+
*/
|
46 |
+
public function form( $instance ) {
|
47 |
+
|
48 |
+
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
|
49 |
+
|
50 |
+
?><p><label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php esc_html_e( 'Title:', 'tx-tk' ) ?></label>
|
51 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ) ?>" name="<?php echo $this->get_field_name( 'title' ) ?>" type="text" value="<?php echo $title ?>"></p><?php
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Renders widget.
|
56 |
+
*
|
57 |
+
* @since 1.0.0
|
58 |
+
*
|
59 |
+
* @access public
|
60 |
+
* @param array $args The array of widget settings.
|
61 |
+
* @param array $instance The array of widget instance settings.
|
62 |
+
*/
|
63 |
+
public function widget( $args, $instance ) {
|
64 |
+
|
65 |
+
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Compare', 'tx-tk' ) : $instance['title'], $instance, $this->id_base );
|
66 |
+
|
67 |
+
echo $args['before_widget'], $args['before_title'], $title, $args['after_title'];
|
68 |
+
|
69 |
+
$list = tx_woocompare_get_list();
|
70 |
+
|
71 |
+
echo '<div class="tm-woocompare-widget-wrapper">';
|
72 |
+
|
73 |
+
echo tx_woocompare_list_render_widget( $list );
|
74 |
+
|
75 |
+
echo '</div>';
|
76 |
+
|
77 |
+
echo $args['after_widget'];
|
78 |
+
}
|
79 |
+
}
|
inc/woo-compare-wishlist/includes/install.php
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
4 |
+
|
5 |
+
exit;
|
6 |
+
} // Exit if accessed directly
|
7 |
+
|
8 |
+
if ( !class_exists( 'TX_WC_Compare_Wishlist_Install' ) ) {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Install plugin table and create the wishlist page
|
12 |
+
*
|
13 |
+
* @since 1.0.0
|
14 |
+
*/
|
15 |
+
class TX_WC_Compare_Wishlist_Install {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Single instance of the class
|
19 |
+
*
|
20 |
+
* @var \TX_WC_Compare_Wishlist_Install
|
21 |
+
* @since 2.0.0
|
22 |
+
*/
|
23 |
+
protected static $instance;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Plugin options
|
27 |
+
*
|
28 |
+
* @var array
|
29 |
+
* @since 1.0.0
|
30 |
+
*/
|
31 |
+
public $options;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Returns single instance of the class
|
35 |
+
*
|
36 |
+
* @return \TX_WC_Compare_Wishlist_Install
|
37 |
+
* @since 2.0.0
|
38 |
+
*/
|
39 |
+
public static function get_instance(){
|
40 |
+
|
41 |
+
if( is_null( self::$instance ) ){
|
42 |
+
|
43 |
+
self::$instance = new self();
|
44 |
+
}
|
45 |
+
return self::$instance;
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Initiator. Replace the constructor.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
*/
|
53 |
+
public function init() {
|
54 |
+
|
55 |
+
$this->_add_pages();
|
56 |
+
|
57 |
+
require_once 'compare/settings.php';
|
58 |
+
require_once 'wishlist/settings.php';
|
59 |
+
|
60 |
+
$this->options = tx_woocompare_get_settings();
|
61 |
+
|
62 |
+
$this->default_options( $this->options );
|
63 |
+
|
64 |
+
$this->options = tx_woowishlist_get_settings();
|
65 |
+
|
66 |
+
$this->default_options( $this->options );
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Set options to their default value.
|
71 |
+
*
|
72 |
+
* @param array $options
|
73 |
+
* @return bool
|
74 |
+
* @since 1.0.0
|
75 |
+
*/
|
76 |
+
public function default_options( $options ) {
|
77 |
+
|
78 |
+
foreach( $options as $value ) {
|
79 |
+
|
80 |
+
if ( isset( $value['default'] ) && isset( $value['id'] ) && ! get_option( $value['id'] ) ) {
|
81 |
+
|
82 |
+
add_option( $value['id'], $value['default'] );
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Add a pages.
|
89 |
+
*
|
90 |
+
* @return void
|
91 |
+
* @since 1.0.2
|
92 |
+
*/
|
93 |
+
private function _add_pages() {
|
94 |
+
|
95 |
+
$this->_add_page( 'compare', __( 'Compare', 'tx-tk' ) );
|
96 |
+
$this->_add_page( 'wishlist', __( 'Wishlist', 'tx-tk' ) );
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Add a page.
|
101 |
+
*
|
102 |
+
* @return void
|
103 |
+
* @since 1.0.2
|
104 |
+
*/
|
105 |
+
private function _add_page( $page, $title ) {
|
106 |
+
|
107 |
+
global $wpdb;
|
108 |
+
|
109 |
+
$option = get_option( 'tx_woo' . $page . '_page', '' );
|
110 |
+
$shortcode = '[tx_woo_' . $page . '_table';
|
111 |
+
|
112 |
+
if ( empty ( $option ) ) {
|
113 |
+
|
114 |
+
$option = $wpdb->get_var( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_name` = '{$page}' AND `post_type` = 'page' LIMIT 1;" );
|
115 |
+
}
|
116 |
+
|
117 |
+
if ( ! ( $option && get_post( $option ) ) ) {
|
118 |
+
|
119 |
+
$page_options = array(
|
120 |
+
'post_status' => 'publish',
|
121 |
+
'post_type' => 'page',
|
122 |
+
'post_title' => $title,
|
123 |
+
'post_content' => $shortcode . ']'
|
124 |
+
);
|
125 |
+
$option = wp_insert_post( $page_options );
|
126 |
+
|
127 |
+
} else {
|
128 |
+
|
129 |
+
$post = get_post( $option );
|
130 |
+
|
131 |
+
if( false === strpos( $post->post_content, $shortcode ) ) {
|
132 |
+
|
133 |
+
$update = array(
|
134 |
+
'ID' => $option,
|
135 |
+
'post_content' => $shortcode . "]\n" . $post->post_content,
|
136 |
+
);
|
137 |
+
wp_update_post( $update );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
update_option( 'tx_woo' . $page . '_page', $option );
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Unique access to instance of TX_WC_Compare_Wishlist_Install class
|
147 |
+
*
|
148 |
+
* @return \TX_WC_Compare_Wishlist_Install
|
149 |
+
* @since 2.0.0
|
150 |
+
*/
|
151 |
+
function TX_WC_Compare_Wishlist_Install(){
|
152 |
+
return TX_WC_Compare_Wishlist_Install::get_instance();
|
153 |
+
}
|
inc/woo-compare-wishlist/includes/template-callbacks.php
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Define callback functions for templater
|
4 |
+
*
|
5 |
+
* @package TX WooCommerce Package
|
6 |
+
* @author TemplateMonster
|
7 |
+
* @license GPL-2.0+
|
8 |
+
* @link http://www.templatemonster.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
// If this file is called directly, abort.
|
12 |
+
if ( !defined( 'ABSPATH' ) ) {
|
13 |
+
|
14 |
+
header( 'HTTP/1.0 404 Not Found', true, 404 );
|
15 |
+
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Callbcks for team shortcode templater
|
21 |
+
*
|
22 |
+
* @since 1.0.0
|
23 |
+
*/
|
24 |
+
class TX_WC_Compare_Wishlist_Template_Callbacks {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Get product title.
|
28 |
+
*
|
29 |
+
* @since 1.0.2
|
30 |
+
*/
|
31 |
+
public function get_product_title() {
|
32 |
+
|
33 |
+
global $product;
|
34 |
+
|
35 |
+
if ( empty( $product ) ) {
|
36 |
+
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
$link = $product->get_permalink();
|
40 |
+
$title = $product->get_title();
|
41 |
+
$html = sprintf( '<div class="tm-woocomerce-list__product-title"><a href="%s">%s</a></div>', $link, $title );
|
42 |
+
|
43 |
+
return apply_filters( 'tx_woocommerce_list_product_title', $html, $link, $title, $product );
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get the product image.
|
48 |
+
*
|
49 |
+
* @since 1.0.2
|
50 |
+
* @param array $attr Image attributes.
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
public function get_product_image( $attr = array() ) {
|
54 |
+
|
55 |
+
global $product;
|
56 |
+
|
57 |
+
if ( empty( $product ) ) {
|
58 |
+
|
59 |
+
return;
|
60 |
+
}
|
61 |
+
if ( isset( $attr['placeholder'] ) ) {
|
62 |
+
|
63 |
+
$attr['placeholder'] = json_decode( $attr['placeholder'] );
|
64 |
+
}
|
65 |
+
$default_attr = array(
|
66 |
+
'size' => 'shop_thumbnail',
|
67 |
+
'attr' => array(),
|
68 |
+
'placeholder' => true
|
69 |
+
);
|
70 |
+
$attr = wp_parse_args( $attr, $default_attr );
|
71 |
+
$link = $product->get_permalink();
|
72 |
+
$image = $product->get_image( $attr['size'], $attr['attr'], $attr['placeholder'] );
|
73 |
+
$html = sprintf( '<div class="tm-woocomerce-list__product-image"><a href="%s">%s</a></div>', $link, $image );
|
74 |
+
|
75 |
+
return apply_filters( 'tx_woocommerce_list_product_image', $html, $link, $image );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Get product price.
|
80 |
+
*
|
81 |
+
* @since 1.0.0
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function get_product_price() {
|
85 |
+
|
86 |
+
if ( ! function_exists( 'woocommerce_template_loop_price' ) ) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
ob_start();
|
91 |
+
|
92 |
+
woocommerce_template_loop_price();
|
93 |
+
|
94 |
+
$price = ob_get_contents();
|
95 |
+
|
96 |
+
ob_end_clean();
|
97 |
+
|
98 |
+
return $price;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Get product add to cart button.
|
103 |
+
*
|
104 |
+
* @since 1.0.0
|
105 |
+
* @return string
|
106 |
+
*/
|
107 |
+
public function get_product_add_to_cart_button() {
|
108 |
+
|
109 |
+
if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) {
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
|
113 |
+
ob_start();
|
114 |
+
|
115 |
+
woocommerce_template_loop_add_to_cart();
|
116 |
+
|
117 |
+
$add_to_cart_button = ob_get_contents();
|
118 |
+
|
119 |
+
ob_end_clean();
|
120 |
+
|
121 |
+
return $add_to_cart_button;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Get product attributes.
|
126 |
+
*
|
127 |
+
* @since 1.0.0
|
128 |
+
* @param array $atts Selected attributes.
|
129 |
+
* @return array
|
130 |
+
*/
|
131 |
+
public function get_product_attributes( $atts = array() ) {
|
132 |
+
|
133 |
+
global $product;
|
134 |
+
|
135 |
+
if ( empty( $product ) ) {
|
136 |
+
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
|
140 |
+
$pid = method_exists( $product, 'get_id' ) ? $product->get_id() : get_the_id();
|
141 |
+
|
142 |
+
if ( isset( $atts['atts'] ) ) {
|
143 |
+
|
144 |
+
$selected_attributes = array_filter( array_map( 'trim', explode( ',', strtolower( $atts['atts'] ) ) ) );
|
145 |
+
}
|
146 |
+
$attributes = $product->get_attributes();
|
147 |
+
$product_attributes = array();
|
148 |
+
|
149 |
+
if ( ! empty( $attributes ) ) {
|
150 |
+
|
151 |
+
foreach ( $attributes as $attribute_id => $attribute ) {
|
152 |
+
|
153 |
+
if ( empty( $selected_attributes ) || in_array( strtolower( wc_attribute_label( $attribute['name'] ) ), $selected_attributes ) ) {
|
154 |
+
|
155 |
+
$attr = $attribute['is_taxonomy'] ? wc_get_product_terms( $pid, $attribute['name'], array( 'fields' => 'names' ) )
|
156 |
+
: array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
|
157 |
+
|
158 |
+
$product_attributes[wc_attribute_label( $attribute['name'] )] = apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $attr ) ) ), $attribute, $attr );
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
return $product_attributes;
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Get product stock status.
|
167 |
+
*
|
168 |
+
* @since 1.0.0
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
public function get_product_stock_status() {
|
172 |
+
|
173 |
+
global $product;
|
174 |
+
|
175 |
+
if ( empty( $product ) ) {
|
176 |
+
|
177 |
+
return;
|
178 |
+
}
|
179 |
+
$availability = $product->get_availability();
|
180 |
+
|
181 |
+
return empty( $availability['availability'] ) ? '' : '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . wp_kses_post( $availability['availability'] ) . '</p>';
|
182 |
+
}
|
183 |
+
}
|
inc/woo-compare-wishlist/includes/templater.php
ADDED
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package TX WooCommerce Package
|
4 |
+
* @author TemplateMonster
|
5 |
+
* @license GPL-2.0+
|
6 |
+
* @link http://www.templatemonster.com/
|
7 |
+
*/
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for including page templates.
|
11 |
+
*
|
12 |
+
* @since 1.0.0
|
13 |
+
*/
|
14 |
+
class TX_WC_Compare_Wishlist_Templater {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Templater macros regular expression
|
18 |
+
*
|
19 |
+
* @var string
|
20 |
+
*/
|
21 |
+
private $macros_regex = '/%%(.+?)%%/';
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Templates data to replace
|
25 |
+
*
|
26 |
+
* @var array
|
27 |
+
*/
|
28 |
+
private $replace_data = array();
|
29 |
+
|
30 |
+
/**
|
31 |
+
* A reference to an instance of this class.
|
32 |
+
*
|
33 |
+
* @since 1.0.0
|
34 |
+
* @var object
|
35 |
+
*/
|
36 |
+
private static $instance = null;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Sets up needed actions/filters.
|
40 |
+
*
|
41 |
+
* @since 1.0.0
|
42 |
+
*/
|
43 |
+
public function __construct() {
|
44 |
+
|
45 |
+
// Add a filter to the template include in order to determine if the page has our template assigned and return it's path.
|
46 |
+
add_filter( 'template_include', array( $this, 'view_template' ) );
|
47 |
+
|
48 |
+
require_once tx_wc_compare_wishlist()->plugin_dir( 'includes/template-callbacks.php' );
|
49 |
+
|
50 |
+
$callbacks = new TX_WC_Compare_Wishlist_Template_Callbacks();
|
51 |
+
|
52 |
+
$data = array(
|
53 |
+
'title' => array( $callbacks, 'get_product_title' ),
|
54 |
+
'image' => array( $callbacks, 'get_product_image' ),
|
55 |
+
'permalink' => array( $callbacks, 'get_product_permalink' ),
|
56 |
+
'price' => array( $callbacks, 'get_product_price' ),
|
57 |
+
'addtocart' => array( $callbacks, 'get_product_add_to_cart_button' ),
|
58 |
+
'attributes' => array( $callbacks, 'get_product_attributes' ),
|
59 |
+
'stockstatus' => array( $callbacks, 'get_product_stock_status' ),
|
60 |
+
);
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Filters item data.
|
64 |
+
*
|
65 |
+
* @since 1.0.2
|
66 |
+
* @param array $data Item data.
|
67 |
+
* @param array $atts Attributes.
|
68 |
+
*/
|
69 |
+
$this->replace_data = apply_filters( 'tx_wc_compare_wishlist_templater_callbacks', $data );
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Checks if the template is assigned to the page.
|
75 |
+
*
|
76 |
+
* @since 1.0.0
|
77 |
+
* @param string $template current template name.
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function view_template( $template ) {
|
81 |
+
|
82 |
+
$find = array();
|
83 |
+
$file = '';
|
84 |
+
|
85 |
+
return $template;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Returns macros regular expression.
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function macros_regex() {
|
94 |
+
|
95 |
+
return $this->macros_regex;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function get_replace_data() {
|
99 |
+
|
100 |
+
return $this->replace_data;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Read template (static).
|
105 |
+
*
|
106 |
+
* @since 1.0.0
|
107 |
+
* @return bool|WP_Error|string - false on failure, stored text on success.
|
108 |
+
*/
|
109 |
+
public static function get_contents( $template ) {
|
110 |
+
|
111 |
+
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
112 |
+
|
113 |
+
include_once( ABSPATH . '/wp-admin/includes/file.php' );
|
114 |
+
}
|
115 |
+
WP_Filesystem();
|
116 |
+
|
117 |
+
global $wp_filesystem;
|
118 |
+
|
119 |
+
// Check for existence.
|
120 |
+
if ( ! $wp_filesystem->exists( $template ) ) {
|
121 |
+
|
122 |
+
return false;
|
123 |
+
}
|
124 |
+
// Read the file.
|
125 |
+
$content = $wp_filesystem->get_contents( $template );
|
126 |
+
|
127 |
+
if ( ! $content ) {
|
128 |
+
// Return error object.
|
129 |
+
return new WP_Error( 'reading_error', 'Error when reading file' );
|
130 |
+
}
|
131 |
+
return $content;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Retrieve a *.tmpl file content.
|
136 |
+
*
|
137 |
+
* @since 1.0.0
|
138 |
+
* @param string $template File name.
|
139 |
+
* @param string $shortcode Shortcode name.
|
140 |
+
* @return string
|
141 |
+
*/
|
142 |
+
public function get_template_by_name( $template, $shortcode ) {
|
143 |
+
|
144 |
+
$file = '';
|
145 |
+
$default = tx_wc_compare_wishlist()->plugin_dir( 'templates/shortcodes/' . $shortcode . '/default.tmpl' );
|
146 |
+
$upload_dir = wp_upload_dir();
|
147 |
+
$upload_dir = trailingslashit( $upload_dir['basedir'] );
|
148 |
+
$subdir = 'templates/shortcodes/' . $shortcode . '/' . $template;
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Filters a default fallback-template.
|
152 |
+
*
|
153 |
+
* @since 1.0.0
|
154 |
+
* @param string $content.
|
155 |
+
*/
|
156 |
+
$content = apply_filters( 'tx_wc_compare_wishlist_fallback_template', '' );
|
157 |
+
|
158 |
+
if ( file_exists( $upload_dir . $subdir ) ) {
|
159 |
+
|
160 |
+
$file = $upload_dir . $subdir;
|
161 |
+
|
162 |
+
} elseif ( $theme_template = locate_template( array( 'woocommerce/shortcodes/' . $shortcode . '/' . $template ) ) ) {
|
163 |
+
|
164 |
+
$file = $theme_template;
|
165 |
+
|
166 |
+
} elseif ( file_exists( tx_wc_compare_wishlist()->plugin_dir( $subdir ) ) ) {
|
167 |
+
|
168 |
+
$file = tx_wc_compare_wishlist()->plugin_dir( $subdir );
|
169 |
+
|
170 |
+
} else {
|
171 |
+
|
172 |
+
$file = $default;
|
173 |
+
}
|
174 |
+
if ( ! empty( $file ) ) {
|
175 |
+
|
176 |
+
$content = self::get_contents( $file );
|
177 |
+
}
|
178 |
+
return $content;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Parse template content and replace macros with real data.
|
183 |
+
*
|
184 |
+
* @param string $content Content to parse.
|
185 |
+
* @return string
|
186 |
+
*/
|
187 |
+
public function parse_template( $content, $atts = array() ) {
|
188 |
+
|
189 |
+
$parsed_atts = array();
|
190 |
+
|
191 |
+
if ( ! empty( $atts ) ) {
|
192 |
+
|
193 |
+
foreach ( $atts as $key => $attr ) {
|
194 |
+
|
195 |
+
$key = explode( '_', $key );
|
196 |
+
|
197 |
+
if ( 2 == count( $key ) ) {
|
198 |
+
|
199 |
+
$parsed_atts[$key[0]][$key[1]] = $attr;
|
200 |
+
}
|
201 |
+
}
|
202 |
+
}
|
203 |
+
|
204 |
+
$atts = $parsed_atts;
|
205 |
+
|
206 |
+
$replace_data = $this->replace_data;
|
207 |
+
|
208 |
+
return preg_replace_callback( $this->macros_regex(), function( $matches ) use ( $atts, $replace_data ) {
|
209 |
+
|
210 |
+
if ( ! is_array( $matches ) || empty( $matches ) ) {
|
211 |
+
|
212 |
+
return;
|
213 |
+
}
|
214 |
+
|
215 |
+
$item = trim( $matches[0], '%%' );
|
216 |
+
$arr = explode( ' ', $item, 2 );
|
217 |
+
$macros = strtolower( $arr[0] );
|
218 |
+
|
219 |
+
if ( array_key_exists( $macros, $atts ) ) {
|
220 |
+
|
221 |
+
$atts = isset( $arr[1] ) ? wp_parse_args( $atts[$macros], shortcode_parse_atts( $arr[1] ) ) : $atts[$macros];
|
222 |
+
|
223 |
+
} else {
|
224 |
+
|
225 |
+
$atts = isset( $arr[1] ) ? shortcode_parse_atts( $arr[1] ) : array();
|
226 |
+
}
|
227 |
+
if ( ! isset( $replace_data[ $macros ] ) ) {
|
228 |
+
|
229 |
+
return;
|
230 |
+
}
|
231 |
+
$callback = $replace_data[ $macros ];
|
232 |
+
|
233 |
+
if ( ! is_callable( $callback ) ) {
|
234 |
+
|
235 |
+
return;
|
236 |
+
}
|
237 |
+
return call_user_func( $callback, $atts );
|
238 |
+
|
239 |
+
}, $content );
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Returns the instance.
|
244 |
+
*
|
245 |
+
* @since 1.0.0
|
246 |
+
* @return object
|
247 |
+
*/
|
248 |
+
public static function get_instance() {
|
249 |
+
|
250 |
+
// If the single instance hasn't been set, set it now.
|
251 |
+
if ( null == self::$instance ) {
|
252 |
+
|
253 |
+
self::$instance = new self;
|
254 |
+
}
|
255 |
+
return self::$instance;
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Returns instance of templater class.
|
261 |
+
*
|
262 |
+
* @return TX_WooCommerce_Templater
|
263 |
+
*/
|
264 |
+
function tx_wc_compare_wishlist_templater() {
|
265 |
+
|
266 |
+
return TX_WC_Compare_Wishlist_Templater::get_instance();
|
267 |
+
}
|
268 |
+
|
269 |
+
tx_wc_compare_wishlist_templater();
|
inc/woo-compare-wishlist/includes/wishlist/buttons.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// register action hooks
|
4 |
+
|
5 |
+
add_action( 'woocommerce_after_shop_loop_item', 'tx_woowishlist_add_button_loop', 12 );
|
6 |
+
|
7 |
+
add_action( 'woocommerce_single_product_summary', 'tx_woowishlist_add_button_single', 35 );
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Renders appropriate button for a loop product.
|
11 |
+
*
|
12 |
+
* @since 1.0.0
|
13 |
+
* @action woocommerce_after_shop_loop_item
|
14 |
+
*/
|
15 |
+
function tx_woowishlist_add_button_loop( $args ) {
|
16 |
+
|
17 |
+
if ( 'yes' === get_option( 'tx_woowishlist_show_in_catalog' ) ) {
|
18 |
+
|
19 |
+
tx_woowishlist_add_button( $args );
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Renders appropriate button for a product.
|
25 |
+
*
|
26 |
+
* @since 1.0.0
|
27 |
+
*/
|
28 |
+
function tx_woowishlist_add_button( $args ) {
|
29 |
+
|
30 |
+
$id = get_the_ID();
|
31 |
+
$id = tx_wc_compare_wishlist()->get_original_product_id( $id );
|
32 |
+
$classes = array( 'button', 'tm-woowishlist-button', 'btn', 'btn-default' );
|
33 |
+
$nonce = wp_create_nonce( 'tx_woowishlist' . $id );
|
34 |
+
|
35 |
+
if ( in_array( $id, tx_woowishlist_get_list() ) ) {
|
36 |
+
|
37 |
+
$text = get_option( 'tx_woowishlist_added_text', __( 'Added to Wishlist', 'tx-tk' ) );
|
38 |
+
$classes[] = ' in_wishlist';
|
39 |
+
|
40 |
+
} else {
|
41 |
+
|
42 |
+
$text = get_option( 'tx_woowishlist_add_text', __( 'Add to wishlist', 'tx-tk' ) );
|
43 |
+
}
|
44 |
+
$text = '<span class="tx_woowishlist_product_actions_tip"><span class="text">' . esc_html( $text ) . '</span></span>';
|
45 |
+
$preloader = apply_filters( 'tx_wc_compare_wishlist_button_preloader', '' );
|
46 |
+
|
47 |
+
if( $single = ( is_array( $args ) && isset( $args['single'] ) && $args['single'] ) ) {
|
48 |
+
|
49 |
+
$classes[] = 'tm-woowishlist-button-single';
|
50 |
+
}
|
51 |
+
$html = sprintf( '<button type="button" class="%s" data-id="%s" data-nonce="%s" title="'. esc_attr(get_option( 'tx_woowishlist_add_text', __( 'Add to wishlist', 'tx-tk' ) )) .'">%s</button>', implode( ' ', $classes ), $id, $nonce, $text . $preloader );
|
52 |
+
|
53 |
+
echo apply_filters( 'tx_woowishlist_button', $html, $classes, $id, $nonce, $text, $preloader );
|
54 |
+
|
55 |
+
if ( in_array( $id, tx_woowishlist_get_list() ) && $single ) {
|
56 |
+
|
57 |
+
echo tx_woowishlist_page_button( array( 'btn-primary', 'alt' ) );
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Renders appropriate button for a single product.
|
63 |
+
*
|
64 |
+
* @since 1.0.0
|
65 |
+
* @action woocommerce_single_product_summary
|
66 |
+
*/
|
67 |
+
function tx_woowishlist_add_button_single( $args ) {
|
68 |
+
|
69 |
+
if ( 'yes' === get_option( 'tx_woowishlist_show_in_single' ) ) {
|
70 |
+
|
71 |
+
if( empty( $args ) ) {
|
72 |
+
|
73 |
+
$args = array();
|
74 |
+
}
|
75 |
+
$args['single'] = true;
|
76 |
+
|
77 |
+
tx_woowishlist_add_button( $args );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Renders wishlist page button for a product.
|
83 |
+
*
|
84 |
+
* @since 1.0.0
|
85 |
+
*/
|
86 |
+
function tx_woowishlist_page_button( $classes = array() ) {
|
87 |
+
|
88 |
+
$link = tx_woowishlist_get_page_link();
|
89 |
+
|
90 |
+
if( ! $link ) {
|
91 |
+
|
92 |
+
return;
|
93 |
+
}
|
94 |
+
$classes = array_merge( $classes, array( 'button', 'tm-woowishlist-page-button', 'btn' ) );
|
95 |
+
$text = get_option( 'tx_woowishlist_page_btn_text', __( 'Go to my wishlist', 'tx-tk' ) );
|
96 |
+
$html = sprintf( '<a class="%s" href="%s">%s</a>', implode( ' ', $classes ), $link, $text );
|
97 |
+
|
98 |
+
return apply_filters( 'tx_woowishlist_page_button', $html, $classes, $link, $text );
|
99 |
+
}
|
inc/woo-compare-wishlist/includes/wishlist/settings.php
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// prevent direct access
|
4 |
+
if ( !defined( 'ABSPATH' ) ) {
|
5 |
+
|
6 |
+
header( 'HTTP/1.0 404 Not Found', true, 404 );
|
7 |
+
|
8 |
+
exit;
|
9 |
+
}
|
10 |
+
|
11 |
+
// register action hooks
|
12 |
+
add_action( 'woocommerce_settings_start', 'tx_woowishlist_register_settings' );
|
13 |
+
add_action( 'woocommerce_settings_tx_woowishlist', 'tx_woowishlist_render_settings_page' );
|
14 |
+
add_action( 'woocommerce_update_options_tx_woowishlist', 'tx_woowishlist_update_options' );
|
15 |
+
|
16 |
+
// register filter hooks
|
17 |
+
add_filter( 'woocommerce_settings_tabs_array', 'tx_woowishlist_register_settings_tab', PHP_INT_MAX );
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Returns array of the plugin settings, which will be rendered in the
|
21 |
+
* WooCommerce settings tab.
|
22 |
+
*
|
23 |
+
* @since 1.0.0
|
24 |
+
*
|
25 |
+
* @return array The array of the plugin settings.
|
26 |
+
*/
|
27 |
+
function tx_woowishlist_get_settings() {
|
28 |
+
|
29 |
+
return array(
|
30 |
+
array(
|
31 |
+
'id' => 'general-options',
|
32 |
+
'type' => 'title',
|
33 |
+
'title' => __( 'General Options', 'tx-tk' ),
|
34 |
+
),
|
35 |
+
array(
|
36 |
+
'type' => 'checkbox',
|
37 |
+
'id' => 'tx_woowishlist_enable',
|
38 |
+
'title' => __( 'Enable wishlist', 'tx-tk' ),
|
39 |
+
'desc' => __( 'Enable wishlist functionality.', 'tx-tk' ),
|
40 |
+
'default' => 'yes',
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'type' => 'single_select_page',
|
44 |
+
'id' => 'tx_woowishlist_page',
|
45 |
+
'class' => 'chosen_select_nostd',
|
46 |
+
'title' => __( 'Select wishlist page', 'tx-tk' ),
|
47 |
+
'desc' => '<br>' . __( 'Select a page which will display wishlist.', 'tx-tk' ),
|
48 |
+
),
|
49 |
+
array(
|
50 |
+
'type' => 'checkbox',
|
51 |
+
'id' => 'tx_woowishlist_show_in_catalog',
|
52 |
+
'title' => __( 'Show in catalog', 'tx-tk' ),
|
53 |
+
'desc' => __( 'Enable wishlist button for catalog list.', 'tx-tk' ),
|
54 |
+
'default' => 'yes',
|
55 |
+
),
|
56 |
+
array(
|
57 |
+
'type' => 'checkbox',
|
58 |
+
'id' => 'tx_woowishlist_show_in_single',
|
59 |
+
'title' => __( 'Show in products page', 'tx-tk' ),
|
60 |
+
'desc' => __( 'Enable wishlist button for single product page.', 'tx-tk' ),
|
61 |
+
'default' => 'yes',
|
62 |
+
),
|
63 |
+
array(
|
64 |
+
'type' => 'text',
|
65 |
+
'id' => 'tx_woowishlist_add_text',
|
66 |
+
'title' => __( 'Add to wishlist button text', 'tx-tk' ),
|
67 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the add to wishlist button.', 'tx-tk' ),
|
68 |
+
'default' => __( 'Add to Wishlist', 'tx-tk' ),
|
69 |
+
),
|
70 |
+
array(
|
71 |
+
'type' => 'text',
|
72 |
+
'id' => 'tx_woowishlist_added_text',
|
73 |
+
'title' => __( 'Added to wishlist button text', 'tx-tk' ),
|
74 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the add to wishlist button, when product is added.', 'tx-tk' ),
|
75 |
+
'default' => __( 'Added to Wishlist', 'tx-tk' ),
|
76 |
+
),
|
77 |
+
array(
|
78 |
+
'type' => 'text',
|
79 |
+
'id' => 'tx_woowishlist_page_btn_text',
|
80 |
+
'title' => __( 'Wishlist page button text' , 'tx-tk' ),
|
81 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the wishlist page button.', 'tx-tk' ),
|
82 |
+
'default' => __( 'Go to my wishlist', 'tx-tk' ),
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'type' => 'text',
|
86 |
+
'id' => 'tx_woowishlist_empty_text',
|
87 |
+
'title' => __( 'Empty wishlist text', 'tx-tk' ),
|
88 |
+
'desc' => '<br>' . __( 'Enter text which will be displayed on the wishlist page when is no products.', 'tx-tk' ),
|
89 |
+
'default' => __( 'No products added to wishlist.', 'tx-tk' ),
|
90 |
+
),
|
91 |
+
array(
|
92 |
+
'type' => 'select',
|
93 |
+
'id' => 'tx_woowishlist_cols',
|
94 |
+
'title' => __( 'Wishlist columns', 'tx-tk' ),
|
95 |
+
'desc' => '<br>' . __( 'Choose a number of columns.', 'tx-tk' ),
|
96 |
+
'default' => '1',
|
97 |
+
'options' => array(
|
98 |
+
'1' => '1',
|
99 |
+
'2' => '2',
|
100 |
+
'3' => '3',
|
101 |
+
'4' => '4',
|
102 |
+
)
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'type' => 'text',
|
106 |
+
'id' => 'tx_woowishlist_page_template',
|
107 |
+
'title' => __( 'Page template', 'tx-tk' ),
|
108 |
+
'default' => __( 'page.tmpl', 'tx-tk' ),
|
109 |
+
),
|
110 |
+
array(
|
111 |
+
'type' => 'text',
|
112 |
+
'id' => 'tx_woowishlist_widget_template',
|
113 |
+
'title' => __( 'Widget template', 'tx-tk' ),
|
114 |
+
'default' => __( 'widget.tmpl', 'tx-tk' ),
|
115 |
+
),
|
116 |
+
array(
|
117 |
+
'type' => 'sectionend',
|
118 |
+
'id' => 'general-options'
|
119 |
+
),
|
120 |
+
);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Registers plugin settings in the WooCommerce settings array.
|
125 |
+
*
|
126 |
+
* @since 1.0.0
|
127 |
+
* @action woocommerce_settings_start
|
128 |
+
*
|
129 |
+
* @global array $woocommerce_settings WooCommerce settings array.
|
130 |
+
*/
|
131 |
+
function tx_woowishlist_register_settings() {
|
132 |
+
|
133 |
+
global $woocommerce_settings;
|
134 |
+
|
135 |
+
$woocommerce_settings['tx_woowishlist'] = tx_woowishlist_get_settings();
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Registers WooCommerce settings tab which will display the plugin settings.
|
140 |
+
*
|
141 |
+
* @since 1.0.0
|
142 |
+
* @filter woocommerce_settings_tabs_array PHP_INT_MAX
|
143 |
+
*
|
144 |
+
* @param array $tabs The array of already registered tabs.
|
145 |
+
* @return array The extended array with the plugin tab.
|
146 |
+
*/
|
147 |
+
function tx_woowishlist_register_settings_tab( $tabs ) {
|
148 |
+
|
149 |
+
$tabs['tx_woowishlist'] = esc_html__( 'TX Wishlist', 'tx-tk' );
|
150 |
+
|
151 |
+
return $tabs;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Renders plugin settings tab.
|
156 |
+
*
|
157 |
+
* @since 1.0.0
|
158 |
+
* @action woocommerce_settings_tx_woowishlist
|
159 |
+
*
|
160 |
+
* @global array $woocommerce_settings The aggregate array of WooCommerce settings.
|
161 |
+
* @global string $current_tab The current WooCommerce settings tab.
|
162 |
+
*/
|
163 |
+
function tx_woowishlist_render_settings_page() {
|
164 |
+
|
165 |
+
global $woocommerce_settings, $current_tab;
|
166 |
+
|
167 |
+
if ( function_exists( 'woocommerce_admin_fields' ) ) {
|
168 |
+
|
169 |
+
woocommerce_admin_fields( $woocommerce_settings[$current_tab] );
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* Updates plugin settings after submission.
|
175 |
+
*
|
176 |
+
* @since 1.0.0
|
177 |
+
* @action woocommerce_update_options_tx_woowishlist
|
178 |
+
*/
|
179 |
+
function tx_woowishlist_update_options() {
|
180 |
+
|
181 |
+
if ( function_exists( 'woocommerce_update_options' ) ) {
|
182 |
+
|
183 |
+
woocommerce_update_options( tx_woowishlist_get_settings() );
|
184 |
+
}
|
185 |
+
}
|
inc/woo-compare-wishlist/includes/wishlist/shortcode.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// add shortcode hooks
|
4 |
+
add_shortcode( 'tx_woo_wishlist_table', 'tx_woowishlist_shortcode' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Renders wishlist shortcode.
|
8 |
+
*
|
9 |
+
* @since 1.0.0
|
10 |
+
*
|
11 |
+
* @param array $atts The array of shortcode attributes.
|
12 |
+
*/
|
13 |
+
function tx_woowishlist_shortcode( $atts ) {
|
14 |
+
|
15 |
+
$atts = apply_filters( 'shortcode_atts_tx_woo_wishlist_table', $atts );
|
16 |
+
|
17 |
+
return tx_woowishlist_render( $atts );
|
18 |
+
}
|
inc/woo-compare-wishlist/includes/wishlist/widget.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// add action hooks
|
4 |
+
add_action( 'widgets_init', 'tx_woowishlist_widget_init' );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Registers widgets.
|
8 |
+
*
|
9 |
+
* @since 1.0.0
|
10 |
+
* @action widgets_init
|
11 |
+
*/
|
12 |
+
function tx_woowishlist_widget_init() {
|
13 |
+
|
14 |
+
register_widget( 'Tm_Woocommerce_Wislist_Widget' );
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Wishlist widget.
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
*/
|
22 |
+
class Tm_Woocommerce_Wislist_Widget extends WP_Widget {
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Constructor.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
*
|
29 |
+
* @access public
|
30 |
+
*/
|
31 |
+
public function __construct() {
|
32 |
+
|
33 |
+
parent::__construct( 'tx_woocommerce_wishlist', esc_html__( 'TX WooCommerce Wishlist', 'tx-tk' ), array(
|
34 |
+
'description' => esc_html__( 'Shows a user wishlist on your site.', 'tx-tk' ),
|
35 |
+
) );
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Renders widget settings form.
|
40 |
+
*
|
41 |
+
* @since 1.0.0
|
42 |
+
*
|
43 |
+
* @access public
|
44 |
+
* @param array $instance The array of values, associated with current widget instance.
|
45 |
+
*/
|
46 |
+
public function form( $instance ) {
|
47 |
+
|
48 |
+
$title = isset( $instance['title'] ) ? esc_attr( $instance['title'] ) : '';
|
49 |
+
|
50 |
+
?><p><label for="<?php echo $this->get_field_id( 'title' ) ?>"><?php esc_html_e( 'Title:', 'tx-tk' ) ?></label>
|
51 |
+
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ) ?>" name="<?php echo $this->get_field_name( 'title' ) ?>" type="text" value="<?php echo $title ?>"></p><?php
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Renders widget.
|
56 |
+
*
|
57 |
+
* @since 1.0.0
|
58 |
+
*
|
59 |
+
* @access public
|
60 |
+
* @param array $args The array of widget settings.
|
61 |
+
* @param array $instance The array of widget instance settings.
|
62 |
+
*/
|
63 |
+
public function widget( $args, $instance ) {
|
64 |
+
|
65 |
+
$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? __( 'Recent Compare', 'tx-tk' ) : $instance['title'], $instance, $this->id_base );
|
66 |
+
|
67 |
+
echo $args['before_widget'], $args['before_title'], $title, $args['after_title'];
|
68 |
+
|
69 |
+
echo '<div class="tm-woocomerce-wishlist-widget-wrapper">';
|
70 |
+
|
71 |
+
echo tx_woowishlist_render_widget();
|
72 |
+
|
73 |
+
echo '</div>';
|
74 |
+
|
75 |
+
echo $args['after_widget'];
|
76 |
+
}
|
77 |
+
}
|
inc/woo-compare-wishlist/includes/wishlist/wishlist.php
ADDED
@@ -0,0 +1,491 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( is_admin() ) {
|
4 |
+
require_once TX_WC_COMPARE_WISHLIST_PATH . 'includes/wishlist/settings.php';
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( 'yes' !== get_option( 'tx_woowishlist_enable' ) ) {
|
8 |
+
|
9 |
+
return;
|
10 |
+
}
|
11 |
+
require_once 'buttons.php';
|
12 |
+
|
13 |
+
if ( ! is_admin() ) {
|
14 |
+
|
15 |
+
require_once 'shortcode.php';
|
16 |
+
}
|
17 |
+
require_once 'widget.php';
|
18 |
+
|
19 |
+
// register action hooks
|
20 |
+
add_action( 'wp_enqueue_scripts', 'tx_woowishlist_setup_plugin' );
|
21 |
+
|
22 |
+
add_action( 'wp_ajax_tx_woowishlist_add', 'tx_woowishlist_process_button_action' );
|
23 |
+
add_action( 'wp_ajax_nopriv_tx_woowishlist_add', 'tx_woowishlist_process_button_action' );
|
24 |
+
|
25 |
+
add_action( 'wp_ajax_tx_woowishlist_remove', 'tx_woowishlist_process_remove_button_action' );
|
26 |
+
add_action( 'wp_ajax_nopriv_tx_woowishlist_remove', 'tx_woowishlist_process_remove_button_action' );
|
27 |
+
|
28 |
+
add_action( 'wp_ajax_tx_woowishlist_update', 'tx_woowishlist_process_ajax' );
|
29 |
+
add_action( 'wp_ajax_nopriv_tx_woowishlist_update', 'tx_woowishlist_process_ajax' );
|
30 |
+
|
31 |
+
add_action( 'init', 'tx_woowislist_session_to_db' );
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Enqueue scripts and styles.
|
35 |
+
*
|
36 |
+
* @since 1.0.0
|
37 |
+
*
|
38 |
+
* @action wp_enqueue_scripts
|
39 |
+
*/
|
40 |
+
function tx_woowishlist_setup_plugin() {
|
41 |
+
|
42 |
+
wp_enqueue_style( 'tm-woowishlist' );
|
43 |
+
wp_enqueue_script( 'tm-woowishlist' );
|
44 |
+
|
45 |
+
$include_bootstrap_grid = apply_filters( 'tx_woocommerce_include_bootstrap_grid', true );
|
46 |
+
|
47 |
+
if ( $include_bootstrap_grid ) {
|
48 |
+
|
49 |
+
wp_enqueue_style( 'bootstrap-grid' );
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Returns wishlist list.
|
55 |
+
*
|
56 |
+
* @sicne 1.0.0
|
57 |
+
*
|
58 |
+
* @return array The array of product ids to wishlist.
|
59 |
+
*/
|
60 |
+
function tx_woowishlist_get_list() {
|
61 |
+
|
62 |
+
if( is_user_logged_in() ) {
|
63 |
+
|
64 |
+
$id = get_current_user_id();
|
65 |
+
$list = get_user_meta( $id, 'tx_woo_wishlist_items', true );
|
66 |
+
|
67 |
+
if ( ! empty( $list ) ) {
|
68 |
+
|
69 |
+
$list = unserialize( $list );
|
70 |
+
|
71 |
+
} else {
|
72 |
+
|
73 |
+
$list = array();
|
74 |
+
}
|
75 |
+
} else {
|
76 |
+
|
77 |
+
$list = ! empty( $_SESSION['tm-woowishlist'] ) ? $_SESSION['tm-woowishlist'] : array();
|
78 |
+
|
79 |
+
if ( ! empty( $list ) ) {
|
80 |
+
|
81 |
+
$list = explode( ':', $list );
|
82 |
+
$nonce = array_pop( $list );
|
83 |
+
|
84 |
+
if ( ! wp_verify_nonce( $nonce, implode( $list ) ) ) {
|
85 |
+
|
86 |
+
$list = array();
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
return $list;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Sets new list of products to wishlist.
|
95 |
+
*
|
96 |
+
* @since 1.0.0
|
97 |
+
*
|
98 |
+
* @param array $list The new array of products to wishlist.
|
99 |
+
*/
|
100 |
+
function tx_woowishlist_set_list( $list ) {
|
101 |
+
|
102 |
+
$nonce = wp_create_nonce( implode( $list ) );
|
103 |
+
$value = implode( ':', array_merge( $list, array( $nonce ) ) );
|
104 |
+
if ( ! session_id() ) {
|
105 |
+
|
106 |
+
session_start();
|
107 |
+
}
|
108 |
+
$_SESSION['tm-woowishlist'] = $value;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Returns wishlist page link.
|
113 |
+
*
|
114 |
+
* @since 1.0.0
|
115 |
+
*
|
116 |
+
* @return string The wishlist page link on success, otherwise FALSE.
|
117 |
+
*/
|
118 |
+
function tx_woowishlist_get_page_link() {
|
119 |
+
|
120 |
+
$page_id = intval( get_option( 'tx_woowishlist_page', '' ) );
|
121 |
+
|
122 |
+
if ( ! $page_id ) {
|
123 |
+
|
124 |
+
return false;
|
125 |
+
}
|
126 |
+
$page_link = get_permalink( $page_id );
|
127 |
+
|
128 |
+
if ( ! $page_link ) {
|
129 |
+
|
130 |
+
return false;
|
131 |
+
}
|
132 |
+
return trailingslashit( $page_link );
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Processes buttons actions.
|
137 |
+
*
|
138 |
+
* @since 1.0.0
|
139 |
+
*
|
140 |
+
* @action wp_ajax_tx_woowishlist_add_to_list
|
141 |
+
*/
|
142 |
+
function tx_woowishlist_process_button_action() {
|
143 |
+
|
144 |
+
$id = filter_input( INPUT_POST, 'pid' );
|
145 |
+
|
146 |
+
if ( ! wp_verify_nonce( filter_input( INPUT_POST, 'nonce' ), 'tx_woowishlist' . $id ) ) {
|
147 |
+
|
148 |
+
wp_send_json_error();
|
149 |
+
}
|
150 |
+
$button = json_decode( filter_input( INPUT_POST, 'single' ) ) ? tx_woowishlist_page_button() : false;
|
151 |
+
|
152 |
+
tx_woowishlist_add( $id );
|
153 |
+
|
154 |
+
wp_send_json_success( array(
|
155 |
+
'action' => $action,
|
156 |
+
'wishlistPageBtn' => $button
|
157 |
+
) );
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Returns message when is no products in wishlist.
|
162 |
+
*
|
163 |
+
* @since 1.0.0
|
164 |
+
*
|
165 |
+
* @return string The message
|
166 |
+
*/
|
167 |
+
function tx_woowishlist_empty_message() {
|
168 |
+
|
169 |
+
$empty_text = get_option( 'tx_woowishlist_empty_text', __( 'No products added to wishlist.', 'tx-tk' ) );
|
170 |
+
|
171 |
+
return apply_filters( 'tx_woowishlist_empty_message', sprintf( '<p class="tm-woowishlist-empty">%s</p>', $empty_text ), $empty_text );
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Processes main ajax handler.
|
176 |
+
*
|
177 |
+
* @since 1.0.0
|
178 |
+
*
|
179 |
+
* @action wp_ajax_tx_woowishlist_update
|
180 |
+
*/
|
181 |
+
function tx_woowishlist_process_ajax() {
|
182 |
+
|
183 |
+
$is_page = json_decode( filter_input( INPUT_POST, 'isWishlistPage' ) );
|
184 |
+
$is_widget = json_decode( filter_input( INPUT_POST, 'isWidget' ) );
|
185 |
+
$json = array();
|
186 |
+
$atts = json_decode( filter_input( INPUT_POST, 'wishListData' ), true );
|
187 |
+
|
188 |
+
if ( $is_page ) {
|
189 |
+
|
190 |
+
$json['wishList'] = tx_woowishlist_render_table( $atts );
|
191 |
+
}
|
192 |
+
if ( $is_widget ) {
|
193 |
+
|
194 |
+
$json['widget'] = tx_woowishlist_render_widget();
|
195 |
+
}
|
196 |
+
wp_send_json_success( $json );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Processes remove button action.
|
201 |
+
*
|
202 |
+
* @since 1.0.0
|
203 |
+
*
|
204 |
+
* @action wp_ajax_tx_woowishlist_remove
|
205 |
+
*/
|
206 |
+
function tx_woowishlist_process_remove_button_action() {
|
207 |
+
|
208 |
+
$id = filter_input( INPUT_POST, 'pid' );
|
209 |
+
|
210 |
+
if ( ! wp_verify_nonce( filter_input( INPUT_POST, 'nonce' ), 'tx_woowishlist' . $id ) ) {
|
211 |
+
|
212 |
+
wp_send_json_error();
|
213 |
+
}
|
214 |
+
tx_woowishlist_remove( $id );
|
215 |
+
|
216 |
+
tx_woowishlist_process_ajax();
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Adds product to wishlist.
|
221 |
+
*
|
222 |
+
* @since 1.0.0
|
223 |
+
*
|
224 |
+
* @param int $id The product id to add to the wishlist.
|
225 |
+
*/
|
226 |
+
function tx_woowishlist_add( $id ) {
|
227 |
+
|
228 |
+
$id = intval( $id );
|
229 |
+
|
230 |
+
if( is_user_logged_in() ) {
|
231 |
+
|
232 |
+
$user_id = get_current_user_id();
|
233 |
+
$list = get_user_meta( $user_id, 'tx_woo_wishlist_items', true );
|
234 |
+
|
235 |
+
if ( ! empty( $list ) ) {
|
236 |
+
|
237 |
+
$list = unserialize( $list );
|
238 |
+
|
239 |
+
} else {
|
240 |
+
|
241 |
+
$list = array();
|
242 |
+
}
|
243 |
+
$list[] = $id;
|
244 |
+
$list = array_unique( $list );
|
245 |
+
$list = serialize( $list );
|
246 |
+
|
247 |
+
update_user_meta( $user_id, 'tx_woo_wishlist_items', $list );
|
248 |
+
|
249 |
+
} else {
|
250 |
+
|
251 |
+
$list = tx_woowishlist_get_list();
|
252 |
+
$list[] = $id;
|
253 |
+
$list = array_unique( $list );
|
254 |
+
|
255 |
+
tx_woowishlist_set_list( $list );
|
256 |
+
}
|
257 |
+
}
|
258 |
+
|
259 |
+
/**
|
260 |
+
* Removes product from wishlist list.
|
261 |
+
*
|
262 |
+
* @since 1.0.0
|
263 |
+
*
|
264 |
+
* @param int $id The product id to remove from wishlist.
|
265 |
+
*/
|
266 |
+
function tx_woowishlist_remove( $id ) {
|
267 |
+
|
268 |
+
$id = intval( $id );
|
269 |
+
|
270 |
+
if( is_user_logged_in() ) {
|
271 |
+
|
272 |
+
$user_id = get_current_user_id();
|
273 |
+
$list = get_user_meta( $user_id, 'tx_woo_wishlist_items', true );
|
274 |
+
|
275 |
+
if ( ! empty( $list ) ) {
|
276 |
+
|
277 |
+
$list = unserialize( $list );
|
278 |
+
$key = array_search( $id, $list );
|
279 |
+
|
280 |
+
if ( false !== $key ) {
|
281 |
+
|
282 |
+
unset( $list[$key] );
|
283 |
+
}
|
284 |
+
$list = serialize( $list );
|
285 |
+
|
286 |
+
update_user_meta( $user_id, 'tx_woo_wishlist_items', $list );
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
} else {
|
291 |
+
|
292 |
+
$list = tx_woowishlist_get_list();
|
293 |
+
$key = array_search( $id, $list );
|
294 |
+
|
295 |
+
if ( false !== $key ) {
|
296 |
+
|
297 |
+
unset( $list[$key] );
|
298 |
+
}
|
299 |
+
tx_woowishlist_set_list( $list );
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Get products added to wishlist.
|
305 |
+
*
|
306 |
+
* @since 1.0.0
|
307 |
+
*
|
308 |
+
* @param array $list The array of products ids.
|
309 |
+
* @return object The list of products
|
310 |
+
*/
|
311 |
+
function tx_woowishlist_get_products( $list ) {
|
312 |
+
|
313 |
+
$args = array(
|
314 |
+
'post_type' => 'product',
|
315 |
+
'post__in' => $list,
|
316 |
+
'orderby' => 'post__in',
|
317 |
+
'posts_per_page' => -1
|
318 |
+
);
|
319 |
+
$products = new WP_Query( $args );
|
320 |
+
|
321 |
+
wp_reset_query();
|
322 |
+
|
323 |
+
return $products;
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Renders wishlist.
|
328 |
+
*
|
329 |
+
* @since 1.0.0
|
330 |
+
*
|
331 |
+
* @return string Wishlist HTML.
|
332 |
+
*/
|
333 |
+
function tx_woowishlist_render( $atts = array() ) {
|
334 |
+
|
335 |
+
$content = array();
|
336 |
+
$class = isset( $atts['class'] ) && ! empty( $atts['class'] ) ? $atts['class'] : '';
|
337 |
+
$tx_wc_compare_wishlist = tx_wc_compare_wishlist();
|
338 |
+
$data_atts = $tx_wc_compare_wishlist->build_html_dataattributes( $atts );
|
339 |
+
$content[] = '<div class="woocommerce tm-woowishlist ' . $class . '"' . $data_atts . '>';
|
340 |
+
$content[] = '<div class="woocommerce tm-woowishlist-wrapper">';
|
341 |
+
$content[] = tx_woowishlist_render_table( $atts );
|
342 |
+
$content[] = '</div>';
|
343 |
+
$content[] = $tx_wc_compare_wishlist->get_loader();
|
344 |
+
$content[] = '</div>';
|
345 |
+
|
346 |
+
return implode( "\n", $content );
|
347 |
+
}
|
348 |
+
|
349 |
+
/**
|
350 |
+
* Renders wishlist widget.
|
351 |
+
*
|
352 |
+
* @since 1.0.0
|
353 |
+
*
|
354 |
+
* @return string Wishlist widget HTML.
|
355 |
+
*/
|
356 |
+
function tx_woowishlist_render_widget() {
|
357 |
+
|
358 |
+
$list = tx_woowishlist_get_list();
|
359 |
+
|
360 |
+
if ( empty( $list ) ) {
|
361 |
+
|
362 |
+
return tx_woowishlist_empty_message();
|
363 |
+
}
|
364 |
+
$templater = tx_wc_compare_wishlist_templater();
|
365 |
+
$products = tx_woowishlist_get_products( $list );
|
366 |
+
$template = get_option( 'tx_woowishlist_widget_template', 'widget.tmpl' );
|
367 |
+
$template = $templater->get_template_by_name( $template, 'tm-woowishlist' );
|
368 |
+
|
369 |
+
if( ! $template ) {
|
370 |
+
|
371 |
+
$template = $templater->get_template_by_name( 'widget.tmpl', 'tm-woowishlist' );
|
372 |
+
}
|
373 |
+
$content = array();
|
374 |
+
$tx_wc_compare_wishlist = tx_wc_compare_wishlist();
|
375 |
+
|
376 |
+
if ( $products->have_posts() ) {
|
377 |
+
|
378 |
+
$content[] = '<div class="tm-woowishlist-widget-products">' . "\n";
|
379 |
+
|
380 |
+
while ( $products->have_posts() ) {
|
381 |
+
|
382 |
+
$products->the_post();
|
383 |
+
|
384 |
+
global $product;
|
385 |
+
|
386 |
+
if ( empty( $product ) ) {
|
387 |
+
|
388 |
+
continue;
|
389 |
+
}
|
390 |
+
$pid = method_exists( $product, 'get_id' ) ? $product->get_id() : get_the_id();
|
391 |
+
$pid = $tx_wc_compare_wishlist->get_original_product_id( $pid );
|
392 |
+
$nonce = wp_create_nonce( 'tx_woowishlist' . $pid );
|
393 |
+
$dismiss_icon = apply_filters( 'tx_woowishlist_dismiss_icon', '<span class="dashicons dashicons-dismiss"></span>' );
|
394 |
+
$content[] = '<div class="tm-woowishlist-widget-product">' . "\n";
|
395 |
+
$content[] = '<span class="tm-woowishlist-remove" data-id="' . $pid . '" data-nonce="' . $nonce . '">' . $dismiss_icon . '</span>';
|
396 |
+
$content[] = $templater->parse_template( $template );
|
397 |
+
$content[] = '</div>';
|
398 |
+
}
|
399 |
+
wp_reset_query();
|
400 |
+
|
401 |
+
$content[] = '</div>';
|
402 |
+
$content[] = tx_woowishlist_page_button( array( 'btn-default' ) );
|
403 |
+
$content[] = $tx_wc_compare_wishlist->get_loader();
|
404 |
+
}
|
405 |
+
return implode( "\n", $content );
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Renders wishlist table.
|
410 |
+
*
|
411 |
+
* @since 1.0.0
|
412 |
+
*
|
413 |
+
* @param array $atts The wishlist table attributes.
|
414 |
+
* @return string Wishlist table HTML.
|
415 |
+
*/
|
416 |
+
function tx_woowishlist_render_table( $atts = array() ) {
|
417 |
+
|
418 |
+
$list = tx_woowishlist_get_list();
|
419 |
+
|
420 |
+
if ( empty( $list ) ) {
|
421 |
+
|
422 |
+
return tx_woowishlist_empty_message();
|
423 |
+
}
|
424 |
+
$html = array();
|
425 |
+
$templater = tx_wc_compare_wishlist_templater();
|
426 |
+
$products = tx_woowishlist_get_products( $list );
|
427 |
+
$template = isset( $atts['template'] ) && ! empty( $atts['template'] ) ? $atts['template'] : get_option( 'tx_woowishlist_page_template', 'page.tmpl' );
|
428 |
+
$cols = isset( $atts['cols'] ) && ! empty( $atts['cols'] ) ? $atts['cols'] : get_option( 'tx_woowishlist_cols', '1' );
|
429 |
+
$cols = 4 < $cols ? 4 : $cols;
|
430 |
+
$template = $templater->get_template_by_name( $template, 'tm-woowishlist' );
|
431 |
+
|
432 |
+
if( ! $template ) {
|
433 |
+
|
434 |
+
$template = $templater->get_template_by_name( 'page.tmpl', 'tm-woowishlist' );
|
435 |
+
}
|
436 |
+
$html[] = '<div class="row">';
|
437 |
+
$class = apply_filters( 'tx_woowishlist_column_class', 'col-lg-' . round( 12 / $cols ) . ' col-xs-12', $cols );
|
438 |
+
|
439 |
+
while ( $products->have_posts() ) {
|
440 |
+
|
441 |
+
$products->the_post();
|
442 |
+
|
443 |
+
global $product;
|
444 |
+
|
445 |
+
if ( empty( $product ) ) {
|
446 |
+
|
447 |
+
continue;
|
448 |
+
}
|
449 |
+
$pid = method_exists( $product, 'get_id' ) ? $product->get_id() : get_the_id();
|
450 |
+
$pid = tx_wc_compare_wishlist()->get_original_product_id( $pid );
|
451 |
+
$html[] = '<div class="' . $class . '">';
|
452 |
+
$html[] = '<div class="tm-woowishlist-item">';
|
453 |
+
$nonce = wp_create_nonce( 'tx_woowishlist' . $pid );
|
454 |
+
$dismiss_icon = apply_filters( 'tx_woowishlist_dismiss_icon', '<span class="dashicons dashicons-dismiss"></span>' );
|
455 |
+
$html[] = '<div class="tm-woowishlist-remove" data-id="' . $pid . '" data-nonce="' . $nonce . '">' . $dismiss_icon . '</div>';
|
456 |
+
$html[] = $templater->parse_template( $template, $atts );
|
457 |
+
$html[] = '</div>';
|
458 |
+
$html[] = '</div>';
|
459 |
+
}
|
460 |
+
wp_reset_query();
|
461 |
+
|
462 |
+
$html[] = '</div>';
|
463 |
+
|
464 |
+
return implode( "\n", $html );
|
465 |
+
}
|
466 |
+
|
467 |
+
function tx_woowislist_session_to_db() {
|
468 |
+
|
469 |
+
if ( is_user_logged_in() ) {
|
470 |
+
|
471 |
+
$list = tx_woowishlist_get_list();
|
472 |
+
$session_list = ! empty( $_SESSION['tm-woowishlist'] ) ? $_SESSION['tm-woowishlist'] : array();
|
473 |
+
|
474 |
+
if ( ! empty( $session_list ) ) {
|
475 |
+
|
476 |
+
$session_list = explode( ':', $session_list );
|
477 |
+
$nonce = array_pop( $session_list );
|
478 |
+
}
|
479 |
+
if ( ! empty( $session_list ) ) {
|
480 |
+
|
481 |
+
foreach ( $session_list as $product_id ) {
|
482 |
+
|
483 |
+
if( ! in_array( $product_id, $list ) ) {
|
484 |
+
|
485 |
+
tx_woowishlist_add( $product_id );
|
486 |
+
}
|
487 |
+
}
|
488 |
+
tx_woowishlist_set_list( array() );
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
inc/woo-compare-wishlist/templates/shortcodes/tm-woocompare/page.tmpl
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
%%TITLE%%
|
2 |
+
%%IMAGE%%
|
3 |
+
%%ADDTOCART%%
|
4 |
+
%%PRICE%%
|
5 |
+
%%ATTRIBUTES%%
|
inc/woo-compare-wishlist/templates/shortcodes/tm-woocompare/widget.tmpl
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
<h3>%%TITLE%%</h3>
|
2 |
+
%%IMAGE size="shop_thumbnail"%%
|
inc/woo-compare-wishlist/templates/shortcodes/tm-woowishlist/page.tmpl
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
%%IMAGE size="shop_thumbnail"%%
|
2 |
+
%%TITLE%%
|
3 |
+
%%PRICE%%
|
4 |
+
%%STOCKSTATUS%%
|
5 |
+
%%ADDTOCART%%
|
inc/woo-compare-wishlist/templates/shortcodes/tm-woowishlist/widget.tmpl
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<h3>%%TITLE%%</h3>
|
2 |
+
%%IMAGE size="shop_thumbnail"%%
|
3 |
+
<div>%%PRICE%%</div>
|
4 |
+
%%ADDTOCART%%
|
inc/woo-compare-wishlist/uninstall.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Uninstall plugin
|
4 |
+
*
|
5 |
+
* @author TemplateMonster
|
6 |
+
* @package TX Woocommerce Package
|
7 |
+
* @version 1.0.0
|
8 |
+
*/
|
9 |
+
|
10 |
+
// If uninstall not called from WordPress exit
|
11 |
+
if( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
12 |
+
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
function tx_wc_compare_wishlist_uninstall(){
|
17 |
+
|
18 |
+
global $wpdb;
|
19 |
+
|
20 |
+
//delete pages created for this plugin
|
21 |
+
wp_delete_post( get_option( 'tx_woocompare_page' ), true );
|
22 |
+
|
23 |
+
wp_delete_post( get_option( 'tx_woowishlist_page' ), true );
|
24 |
+
|
25 |
+
// Delete option from options table
|
26 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", 'tx_woocompare%' ) );
|
27 |
+
|
28 |
+
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", 'tx_woowishlist%' ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
if ( ! is_multisite() ) {
|
34 |
+
|
35 |
+
tx_wc_compare_wishlist_uninstall();
|
36 |
+
}
|
37 |
+
else {
|
38 |
+
|
39 |
+
global $wpdb;
|
40 |
+
|
41 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
|
42 |
+
$original_blog_id = get_current_blog_id();
|
43 |
+
|
44 |
+
foreach ( $blog_ids as $blog_id ) {
|
45 |
+
|
46 |
+
switch_to_blog( $blog_id );
|
47 |
+
|
48 |
+
tx_wc_compare_wishlist_uninstall();
|
49 |
+
}
|
50 |
+
switch_to_blog( $original_blog_id );
|
51 |
+
}
|
inc/woo-compare-wishlist/woo-compare-wishlist.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
TX WooCommerce Compare & Wishlist
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
|
8 |
+
header( 'HTTP/1.0 404 Not Found', true, 404 );
|
9 |
+
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
class TX_WC_Compare_Wishlist {
|
14 |
+
|
15 |
+
/**
|
16 |
+
* The single instance of the class.
|
17 |
+
*
|
18 |
+
* @var TX_Woocommerce
|
19 |
+
* @since 1.0.0
|
20 |
+
*/
|
21 |
+
protected static $_instance = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Trigger checks is woocoomerce active or not
|
25 |
+
*
|
26 |
+
* @since 1.0.0
|
27 |
+
* @var bool
|
28 |
+
*/
|
29 |
+
public $has_woocommerce = null;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Holder for plugin folder path
|
33 |
+
*
|
34 |
+
* @since 1.0.0
|
35 |
+
* @var string
|
36 |
+
*/
|
37 |
+
public $plugin_dir = null;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Holder for plugin loader
|
41 |
+
*
|
42 |
+
* @since 1.0.0
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
public $loader;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Holder for plugin scripts suffix
|
49 |
+
*
|
50 |
+
* @since 1.0.0
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
public $suffix;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Main TX_WC_Compare_Wishlist Instance.
|
57 |
+
*
|
58 |
+
* Ensures only one instance of TX_Woocommerce is loaded or can be loaded.
|
59 |
+
*
|
60 |
+
* @since 1.0.0
|
61 |
+
* @static
|
62 |
+
* @see tx_wc_compare_wishlist()
|
63 |
+
* @return TX_WC_Compare_Wishlist - Main instance.
|
64 |
+
*/
|
65 |
+
public static function instance() {
|
66 |
+
|
67 |
+
if ( is_null( self::$_instance ) ) {
|
68 |
+
|
69 |
+
self::$_instance = new self();
|
70 |
+
}
|
71 |
+
return self::$_instance;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Sets up needed actions/filters for the theme to initialize.
|
76 |
+
*
|
77 |
+
* @since 1.0.0
|
78 |
+
*/
|
79 |
+
public function __construct() {
|
80 |
+
|
81 |
+
$page_found = 83;
|
82 |
+
|
83 |
+
define( 'TX_WC_COMPARE_WISHLIST_VERISON', '1.0.1' );
|
84 |
+
define( 'TX_WC_COMPARE_WISHLIST_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
85 |
+
|
86 |
+
// Load public assets.
|
87 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ), 10 );
|
88 |
+
|
89 |
+
// Internationalize the text strings used.
|
90 |
+
// add_action( 'plugins_loaded', array( $this, 'lang' ), 1 );
|
91 |
+
|
92 |
+
add_action( 'plugins_loaded', array( $this, 'init' ), 0 );
|
93 |
+
|
94 |
+
//register_activation_hook( __FILE__, array( $this, 'tx_wc_compare_wishlist_install' ) );
|
95 |
+
|
96 |
+
$this->set_suffix();
|
97 |
+
}
|
98 |
+
|
99 |
+
public function set_suffix() {
|
100 |
+
|
101 |
+
if ( is_null( $this->suffix ) ) {
|
102 |
+
|
103 |
+
$this->suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Loads the translation files.
|
109 |
+
*
|
110 |
+
* @since 1.0.0
|
111 |
+
|
112 |
+
function lang() {
|
113 |
+
|
114 |
+
load_plugin_textdomain( 'tx-tk', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
115 |
+
}
|
116 |
+
*/
|
117 |
+
public function init() {
|
118 |
+
|
119 |
+
include_once 'includes/templater.php';
|
120 |
+
include_once 'includes/compare/compare.php';
|
121 |
+
include_once 'includes/wishlist/wishlist.php';
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Check if WooCommerce is active
|
126 |
+
*
|
127 |
+
* @since 1.0.0
|
128 |
+
* @return bool
|
129 |
+
*/
|
130 |
+
public function has_woocommerce() {
|
131 |
+
|
132 |
+
if ( null == $this->has_woocommerce ) {
|
133 |
+
|
134 |
+
$this->has_woocommerce = in_array(
|
135 |
+
'woocommerce/woocommerce.php',
|
136 |
+
apply_filters( 'active_plugins', get_option( 'active_plugins' ) )
|
137 |
+
);
|
138 |
+
}
|
139 |
+
return $this->has_woocommerce;
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Enqueue assets.
|
144 |
+
*
|
145 |
+
* @since 1.0.0
|
146 |
+
* @return void
|
147 |
+
*/
|
148 |
+
public function register_assets() {
|
149 |
+
|
150 |
+
// TX Bootstrap Grid
|
151 |
+
if( ! wp_style_is( 'bootstrap-grid', 'registered' ) ) {
|
152 |
+
|
153 |
+
wp_register_style( 'bootstrap-grid', tx_wc_compare_wishlist()->plugin_url() . '/assets/css/grid.css', array() );
|
154 |
+
}
|
155 |
+
|
156 |
+
// TX WooCompare
|
157 |
+
wp_register_style( 'tm-woocompare', tx_wc_compare_wishlist()->plugin_url() . '/assets/css/tm-woocompare.css', array( 'dashicons' ) );
|
158 |
+
wp_register_script( 'tm-woocompare', tx_wc_compare_wishlist()->plugin_url() . '/assets/js/tm-woocompare' . $this->suffix . '.js', array( 'jquery' ), TX_WC_COMPARE_WISHLIST_VERISON, true );
|
159 |
+
|
160 |
+
wp_register_style( 'tablesaw', tx_wc_compare_wishlist()->plugin_url() . '/assets/css/tablesaw.css', array() );
|
161 |
+
wp_register_script( 'tablesaw', tx_wc_compare_wishlist()->plugin_url() . '/assets/js/tablesaw' . $this->suffix . '.js', array( 'jquery' ), TX_WC_COMPARE_WISHLIST_VERISON, true );
|
162 |
+
|
163 |
+
wp_register_script( 'tablesaw-init', tx_wc_compare_wishlist()->plugin_url() . '/assets/js/tablesaw-init' . $this->suffix . '.js', array( 'tablesaw' ), TX_WC_COMPARE_WISHLIST_VERISON, true );
|
164 |
+
|
165 |
+
wp_localize_script( 'tm-woocompare', 'tmWoocompare', array(
|
166 |
+
'ajaxurl' => admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' ),
|
167 |
+
'compareText' => get_option( 'tx_woocompare_compare_text', __( 'Add to Compare', 'tx-tk' ) ),
|
168 |
+
'removeText' => get_option( 'tx_woocompare_remove_text', __( 'Remove from Compare List', 'tx-tk' ) ),
|
169 |
+
'countFormat' => apply_filters( 'tx_compare_count_format', '<span class="compare-count">(%count%)</span>' )
|
170 |
+
) );
|
171 |
+
|
172 |
+
// TX WooWishlist
|
173 |
+
wp_register_style( 'tm-woowishlist', tx_wc_compare_wishlist()->plugin_url() . '/assets/css/tm-woowishlist.css', array( 'dashicons' ) );
|
174 |
+
wp_register_script( 'tm-woowishlist', tx_wc_compare_wishlist()->plugin_url() . '/assets/js/tm-woowishlist' . $this->suffix . '.js', array( 'jquery' ), TX_WC_COMPARE_WISHLIST_VERISON, true );
|
175 |
+
|
176 |
+
wp_localize_script( 'tm-woowishlist', 'tmWoowishlist', array(
|
177 |
+
'ajaxurl' => admin_url( 'admin-ajax.php', is_ssl() ? 'https' : 'http' ),
|
178 |
+
'addText' => get_option( 'tx_woowishlist_wishlist_text', __( 'Add to Wishlist', 'tx-tk' ) ),
|
179 |
+
'addedText' => get_option( 'tx_woowishlist_added_text', __( 'Added to Wishlist', 'tx-tk' ) )
|
180 |
+
) );
|
181 |
+
}
|
182 |
+
|
183 |
+
public function plugin_url() {
|
184 |
+
|
185 |
+
return untrailingslashit( plugins_url( '/', __FILE__ ) );
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Get the plugin path.
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
+
public function plugin_dir( $path = null ) {
|
193 |
+
|
194 |
+
if ( ! $this->plugin_dir ) {
|
195 |
+
|
196 |
+
$this->plugin_dir = trailingslashit( plugin_dir_path( __FILE__ ) );
|
197 |
+
}
|
198 |
+
return $this->plugin_dir . $path;
|
199 |
+
}
|
200 |
+
/*
|
201 |
+
public function tx_wc_compare_wishlist_install() {
|
202 |
+
|
203 |
+
require_once 'includes/install.php';
|
204 |
+
|
205 |
+
TX_WC_Compare_Wishlist_Install()->init();
|
206 |
+
}
|
207 |
+
*/
|
208 |
+
public function get_loader() {
|
209 |
+
|
210 |
+
if ( is_null( $this->loader ) ) {
|
211 |
+
|
212 |
+
$loader = '<svg width="60px" height="60px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" class="uil-ring-alt"><rect x="0" y="0" width="100" height="100" fill="none" class="bk"></rect><circle cx="50" cy="50" r="40" stroke="#afafb7" fill="none" stroke-width="10" stroke-linecap="round"></circle><circle cx="50" cy="50" r="40" stroke="#5cffd6" fill="none" stroke-width="6" stroke-linecap="round"><animate attributeName="stroke-dashoffset" dur="2s" repeatCount="indefinite" from="0" to="502"></animate><animate attributeName="stroke-dasharray" dur="2s" repeatCount="indefinite" values="150.6 100.4;1 250;150.6 100.4"></animate></circle></svg>';
|
213 |
+
|
214 |
+
$this->loader = '<div class="tm-wc-compare-wishlist-loader">' . apply_filters( 'tx_wc_compare_wishlist_loader', $loader ) . '</div>';
|
215 |
+
}
|
216 |
+
return $this->loader;
|
217 |
+
}
|
218 |
+
|
219 |
+
public function build_html_dataattributes( $atts ) {
|
220 |
+
|
221 |
+
$data_atts = '';
|
222 |
+
|
223 |
+
if( is_array( $atts ) && ! empty( $atts ) ) {
|
224 |
+
|
225 |
+
foreach ( $atts as $key => $attribute ) {
|
226 |
+
|
227 |
+
$data_atts .= ' data-' . $key . '="' . $attribute . '"';
|
228 |
+
}
|
229 |
+
}
|
230 |
+
return $data_atts;
|
231 |
+
}
|
232 |
+
|
233 |
+
public function get_original_product_id( $id ) {
|
234 |
+
|
235 |
+
global $sitepress;
|
236 |
+
|
237 |
+
if( isset( $sitepress ) ) {
|
238 |
+
|
239 |
+
$id = icl_object_id($id, 'product', true, $sitepress->get_default_language());
|
240 |
+
}
|
241 |
+
return $id;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
function tx_wc_compare_wishlist() {
|
246 |
+
|
247 |
+
return TX_WC_Compare_Wishlist::instance();
|
248 |
+
}
|
249 |
+
|
250 |
+
tx_wc_compare_wishlist();
|
inc/woo-compare-wishlist/wpml-config.xml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<wpml-config>
|
2 |
+
<custom-fields>
|
3 |
+
</custom-fields>
|
4 |
+
<admin-texts>
|
5 |
+
<key name="tx_woocompare_compare_text" />
|
6 |
+
<key name="tx_woocompare_remove_text" />
|
7 |
+
<key name="tx_woocompare_page_btn_text" />
|
8 |
+
<key name="tx_woocompare_empty_btn_text" />
|
9 |
+
<key name="tx_woocompare_empty_text" />
|
10 |
+
<key name="tx_woowishlist_add_text" />
|
11 |
+
<key name="tx_woowishlist_added_text" />
|
12 |
+
<key name="tx_woowishlist_page_btn_text" />
|
13 |
+
<key name="tx_woowishlist_empty_text" />
|
14 |
+
</admin-texts>
|
15 |
+
</wpml-config>
|
js/tx-script.js
CHANGED
@@ -21,7 +21,7 @@ jQuery(document).ready(function ($) {
|
|
21 |
paginationSpeed : 1000,
|
22 |
goToFirstSpeed : 2000,
|
23 |
singleItem : true,
|
24 |
-
autoHeight :
|
25 |
//navigationText: ["<i class=\"fa fa-angle-left\"></i>","<i class=\"fa fa-angle-right\"></i>"],
|
26 |
//theme: "tx-custom-slider",
|
27 |
addClassActive: true
|
21 |
paginationSpeed : 1000,
|
22 |
goToFirstSpeed : 2000,
|
23 |
singleItem : true,
|
24 |
+
autoHeight : false,
|
25 |
//navigationText: ["<i class=\"fa fa-angle-left\"></i>","<i class=\"fa fa-angle-right\"></i>"],
|
26 |
//theme: "tx-custom-slider",
|
27 |
addClassActive: true
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: marsian
|
|
3 |
Tags: shortcode, shortcodes, columns, column, section, sections, portfolio, testimonial, border, borders, button, buttons, masonry, posts, post_type, font awesome, icons, fontawesome
|
4 |
Requires at least: 3.6
|
5 |
Tested up to: 4.9
|
6 |
-
Stable tag: 3.1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
3 |
Tags: shortcode, shortcodes, columns, column, section, sections, portfolio, testimonial, border, borders, button, buttons, masonry, posts, post_type, font awesome, icons, fontawesome
|
4 |
Requires at least: 3.6
|
5 |
Tested up to: 4.9
|
6 |
+
Stable tag: 3.1.1
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
tx-functions.php
CHANGED
@@ -398,9 +398,7 @@ function tx_slider_cat_list ()
|
|
398 |
|
399 |
|
400 |
function tx_load_jqvariables(){
|
401 |
-
|
402 |
-
//wp_enqueue_script('tx-main', plugins_url('/js/tx_main.js', __FILE__));
|
403 |
-
|
404 |
$data = 'xyz';
|
405 |
wp_localize_script( 'tx-main', 'tx_t1', tx_slider_cat_list () );
|
406 |
}
|
398 |
|
399 |
|
400 |
function tx_load_jqvariables(){
|
401 |
+
|
|
|
|
|
402 |
$data = 'xyz';
|
403 |
wp_localize_script( 'tx-main', 'tx_t1', tx_slider_cat_list () );
|
404 |
}
|
tx-toolkit.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
Plugin Name: TemplatesNext ToolKit
|
5 |
Description: Custom Portfolio and Shortcode functionality for TemplatesNext Wordpress Themes
|
6 |
-
Version: 3.1.
|
7 |
Author: TemplatesNext
|
8 |
Author URI: http://templatesnext.org/
|
9 |
License: GPLv2 or later
|
@@ -104,14 +104,13 @@ require_once('inc/widgets/widget-image.php');
|
|
104 |
|
105 |
require_once('inc/tx-meta.php');
|
106 |
|
|
|
107 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
108 |
if ( ! is_plugin_active( 'meta-box/meta-box.php' ) )
|
109 |
{
|
110 |
require_once('inc/meta-box/meta-box.php');
|
111 |
}
|
112 |
|
113 |
-
|
114 |
-
|
115 |
if(!defined('TX_TOOLKIT_PATH')){
|
116 |
define('TX_TOOLKIT_PATH', realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR );
|
117 |
}
|
@@ -132,3 +131,17 @@ if (class_exists( 'SiteOrigin_Panels' ))
|
|
132 |
require_once('inc/pb-widgets/widget-services.php');
|
133 |
require_once('inc/pb-widgets/widget-progressbar.php');
|
134 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
/*
|
4 |
Plugin Name: TemplatesNext ToolKit
|
5 |
Description: Custom Portfolio and Shortcode functionality for TemplatesNext Wordpress Themes
|
6 |
+
Version: 3.1.1
|
7 |
Author: TemplatesNext
|
8 |
Author URI: http://templatesnext.org/
|
9 |
License: GPLv2 or later
|
104 |
|
105 |
require_once('inc/tx-meta.php');
|
106 |
|
107 |
+
|
108 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
109 |
if ( ! is_plugin_active( 'meta-box/meta-box.php' ) )
|
110 |
{
|
111 |
require_once('inc/meta-box/meta-box.php');
|
112 |
}
|
113 |
|
|
|
|
|
114 |
if(!defined('TX_TOOLKIT_PATH')){
|
115 |
define('TX_TOOLKIT_PATH', realpath(plugin_dir_path(__FILE__)) . DIRECTORY_SEPARATOR );
|
116 |
}
|
131 |
require_once('inc/pb-widgets/widget-services.php');
|
132 |
require_once('inc/pb-widgets/widget-progressbar.php');
|
133 |
}
|
134 |
+
|
135 |
+
/* *********************** WishList & Compare ********************/
|
136 |
+
|
137 |
+
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
|
138 |
+
|
139 |
+
require_once('inc/woo-compare-wishlist/woo-compare-wishlist.php');
|
140 |
+
|
141 |
+
register_activation_hook( __FILE__, 'tx_compare_wishlist_install' );
|
142 |
+
|
143 |
+
function tx_compare_wishlist_install() {
|
144 |
+
require_once ('inc/woo-compare-wishlist/includes/install.php');
|
145 |
+
TX_WC_Compare_Wishlist_Install()->init();
|
146 |
+
}
|
147 |
+
}
|