Version Description
- Fix: Quicktag buttons are not shown with Gutenberg editor #50
Download this release
Release Info
Developer | ReneHermi |
Plugin | AdSense Plugin WP QUADS |
Version | 1.8.9 |
Comparing to | |
See all releases |
Code changes from version 1.8.8 to 1.8.9
- README.md +36 -36
- assets/css/quads-admin-all.css +121 -121
- assets/css/quads-admin.css +1204 -1204
- assets/css/quads-plugins-admin.min.css +40 -40
- assets/js/blocks.js +21 -21
- assets/js/chosen.jquery.js +1284 -1284
- assets/js/chosen.jquery.min.js +1 -1
- assets/js/jscolor.min.js +9 -9
- assets/js/quads-admin.js +1799 -1799
- assets/js/quads-admin.min.js +1799 -1799
- assets/js/quads-plugins-admin.js +79 -79
- assets/js/quads-plugins-admin.min.js +79 -79
- includes/Autoloader.php +154 -154
- includes/Cron/Cron.php +54 -54
- includes/DI/InjectionAware.php +38 -38
- includes/Forms/Elements.php +299 -299
- includes/Forms/Elements/Check.php +65 -65
- includes/Forms/Elements/Date.php +27 -27
- includes/Forms/Elements/DateTime.php +25 -25
- includes/Forms/Elements/Email.php +27 -27
- includes/Forms/Elements/File.php +27 -27
- includes/Forms/Elements/Hidden.php +28 -28
- includes/Forms/Elements/Interfaces/InterfaceElement.php +134 -134
- includes/Forms/Elements/Interfaces/InterfaceElementWithOptions.php +33 -33
- includes/Forms/Elements/Numerical.php +25 -25
- includes/Forms/Elements/Password.php +28 -28
- includes/Forms/Elements/Radio.php +43 -43
- includes/Forms/Elements/Select.php +58 -58
- includes/Forms/Elements/SelectMultiple.php +57 -57
- includes/Forms/Elements/Text.php +27 -27
- includes/Forms/Elements/TextArea.php +27 -27
- includes/Forms/Elements/TextAreaHidden.php +27 -27
- includes/Forms/ElementsWithOptions.php +75 -75
- includes/Forms/Form.php +59 -59
- includes/QUADS_SL_Plugin_Updater.php +338 -338
- includes/admin/add-ons.php +121 -121
- includes/admin/admin-actions.php +150 -150
- includes/admin/admin-footer.php +34 -34
- includes/admin/admin-notices.php +728 -728
- includes/admin/admin-pages.php +83 -83
- includes/admin/adsTxt.php +106 -106
- includes/admin/plugins.php +61 -61
- includes/admin/settings/contextual-help.php +50 -50
- includes/admin/settings/display-settings.php +354 -354
- includes/admin/settings/register-settings.php +2380 -2380
- includes/admin/tools.php +0 -547
README.md
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
# [WP QUADS (Quick AdSense Reloaded)](https://wordpress.org/support/plugin/quick-adsense-reloaded)
|
2 |
-
|
3 |
-
### Welcome to WP QUADS GitHub Repository
|
4 |
-
|
5 |
-
A further development of Quick Adsense! Insert Google AdSense or any Ads code into your website.
|
6 |
-
|
7 |
-
More information can be found at [wordpress.org](https://wordpress.org/support/plugin/quick-adsense-reloaded).
|
8 |
-
|
9 |
-
## Note ##
|
10 |
-
|
11 |
-
This is the latest developer version of WP QUADS.
|
12 |
-
if you just want to use WP QUADS install the productive version which you get at [wordpress.org](https://wordpress.org/support/plugin/quick-adsense-reloaded)
|
13 |
-
|
14 |
-
## Installation ##
|
15 |
-
|
16 |
-
1. You can clone the GitHub repository: `https://github.com/rene-hermenau/quick-adsense-reloaded.git`
|
17 |
-
2. Or download it directly as a ZIP file: `https://github.com/rene-hermenau/quick-adsense-reloaded/archive/master.zip`
|
18 |
-
|
19 |
-
This will download the latest developer copy of Quick AdSense Reloaded.
|
20 |
-
|
21 |
-
## Bugs ##
|
22 |
-
If you find an issue, let us know [here](https://github.com/rene-hermenau/quick-adsense-reloaded/issues)!
|
23 |
-
|
24 |
-
## Support ##
|
25 |
-
This is a developer's portal for WP QUADS and should _not_ be used for support.
|
26 |
-
Please visit the [support forums](https://wordpress.org/support/plugin/quick-adsense-reloaded/).
|
27 |
-
|
28 |
-
## Contributions ##
|
29 |
-
Anyone is welcome to contribute to WP QUADS. Please read the [guidelines for contributing](https://github.com/rene-hermenau/quick-adsense-reloaded/blob/master/CONTRIBUTING.md) to this repository.
|
30 |
-
|
31 |
-
There are various ways you can contribute:
|
32 |
-
|
33 |
-
1. Raise an [Issue](https://github.com/rene-hermenau/quick-adsense-reloaded/issues) on GitHub
|
34 |
-
2. Send us a Pull Request with your bug fixes and/or new features to the dev branch
|
35 |
-
3. Translate WP QUADS into different languages
|
36 |
-
4. Provide feedback and suggestions on [enhancements](https://github.com/rene-hermenau/quick-adsense-reloaded/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open)
|
1 |
+
# [WP QUADS (Quick AdSense Reloaded)](https://wordpress.org/support/plugin/quick-adsense-reloaded)
|
2 |
+
|
3 |
+
### Welcome to WP QUADS GitHub Repository
|
4 |
+
|
5 |
+
A further development of Quick Adsense! Insert Google AdSense or any Ads code into your website.
|
6 |
+
|
7 |
+
More information can be found at [wordpress.org](https://wordpress.org/support/plugin/quick-adsense-reloaded).
|
8 |
+
|
9 |
+
## Note ##
|
10 |
+
|
11 |
+
This is the latest developer version of WP QUADS.
|
12 |
+
if you just want to use WP QUADS install the productive version which you get at [wordpress.org](https://wordpress.org/support/plugin/quick-adsense-reloaded)
|
13 |
+
|
14 |
+
## Installation ##
|
15 |
+
|
16 |
+
1. You can clone the GitHub repository: `https://github.com/rene-hermenau/quick-adsense-reloaded.git`
|
17 |
+
2. Or download it directly as a ZIP file: `https://github.com/rene-hermenau/quick-adsense-reloaded/archive/master.zip`
|
18 |
+
|
19 |
+
This will download the latest developer copy of Quick AdSense Reloaded.
|
20 |
+
|
21 |
+
## Bugs ##
|
22 |
+
If you find an issue, let us know [here](https://github.com/rene-hermenau/quick-adsense-reloaded/issues)!
|
23 |
+
|
24 |
+
## Support ##
|
25 |
+
This is a developer's portal for WP QUADS and should _not_ be used for support.
|
26 |
+
Please visit the [support forums](https://wordpress.org/support/plugin/quick-adsense-reloaded/).
|
27 |
+
|
28 |
+
## Contributions ##
|
29 |
+
Anyone is welcome to contribute to WP QUADS. Please read the [guidelines for contributing](https://github.com/rene-hermenau/quick-adsense-reloaded/blob/master/CONTRIBUTING.md) to this repository.
|
30 |
+
|
31 |
+
There are various ways you can contribute:
|
32 |
+
|
33 |
+
1. Raise an [Issue](https://github.com/rene-hermenau/quick-adsense-reloaded/issues) on GitHub
|
34 |
+
2. Send us a Pull Request with your bug fixes and/or new features to the dev branch
|
35 |
+
3. Translate WP QUADS into different languages
|
36 |
+
4. Provide feedback and suggestions on [enhancements](https://github.com/rene-hermenau/quick-adsense-reloaded/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open)
|
assets/css/quads-admin-all.css
CHANGED
@@ -1,121 +1,121 @@
|
|
1 |
-
/**
|
2 |
-
* QUADS Admin All CSS
|
3 |
-
*
|
4 |
-
* @package QUADS
|
5 |
-
* @subpackage Admin CSS
|
6 |
-
* @copyright Copyright (c) 2017, René Hermenau
|
7 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
8 |
-
*/
|
9 |
-
|
10 |
-
|
11 |
-
@media (max-width:506px){
|
12 |
-
.quads-banner-columns {
|
13 |
-
display: block !important;
|
14 |
-
}
|
15 |
-
.quads-banner-sidebar-second{
|
16 |
-
width: 100% !important;
|
17 |
-
}
|
18 |
-
}
|
19 |
-
@media (max-width:780px){
|
20 |
-
.quads-banner-wrapper{
|
21 |
-
margin-right:12px !important;
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
.quads-banner-wrapper{
|
26 |
-
display: flex;
|
27 |
-
flex-direction: column;
|
28 |
-
clear:both;
|
29 |
-
background: #fff;
|
30 |
-
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
31 |
-
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
32 |
-
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
33 |
-
margin: 5px 5px 2px;
|
34 |
-
margin-right:20px;
|
35 |
-
padding: 1px 12px;
|
36 |
-
}
|
37 |
-
.quads-banner-content {
|
38 |
-
display: flex;
|
39 |
-
flex: 1;
|
40 |
-
color: #000;
|
41 |
-
}
|
42 |
-
.quads-banner-columns{
|
43 |
-
display: flex;
|
44 |
-
flex:1;
|
45 |
-
-ms-flex-align: center;
|
46 |
-
-webkit-align-items: center;
|
47 |
-
-webkit-box-align: center;
|
48 |
-
|
49 |
-
align-items: center;
|
50 |
-
}
|
51 |
-
.quads-banner-main{
|
52 |
-
flex: 1;
|
53 |
-
order: 2;
|
54 |
-
}
|
55 |
-
.quads-banner-sidebar-first{
|
56 |
-
min-width: 160px;
|
57 |
-
width: 13%;
|
58 |
-
order: 1;
|
59 |
-
}
|
60 |
-
.quads-banner-sidebar-second{
|
61 |
-
width: 19%;
|
62 |
-
order: 3;
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
.quads-button-primary {
|
67 |
-
display: inline-block;
|
68 |
-
text-decoration: none;
|
69 |
-
font-size: 16px;
|
70 |
-
line-height: 32px;
|
71 |
-
height: 36px;
|
72 |
-
margin: 0;
|
73 |
-
padding: 0 13px 1px;
|
74 |
-
cursor: pointer;
|
75 |
-
border-width: 1px;
|
76 |
-
border-style: solid;
|
77 |
-
-webkit-appearance: none;
|
78 |
-
-webkit-border-radius: 3px;
|
79 |
-
border-radius: 3px;
|
80 |
-
white-space: nowrap;
|
81 |
-
-webkit-box-sizing: border-box;
|
82 |
-
-moz-box-sizing: border-box;
|
83 |
-
box-sizing: border-box;
|
84 |
-
font-weight: bold;
|
85 |
-
}
|
86 |
-
|
87 |
-
.quads-button-primary {
|
88 |
-
background: #0085ba;
|
89 |
-
border-color: #0073aa #006799 #006799;
|
90 |
-
-webkit-box-shadow: 0 1px 0 #006799;
|
91 |
-
box-shadow: 0 1px 0 #006799;
|
92 |
-
color: #fff;
|
93 |
-
text-decoration: none;
|
94 |
-
text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
|
95 |
-
}
|
96 |
-
|
97 |
-
.quads-notice-dismiss {
|
98 |
-
display: inline-block;
|
99 |
-
position: relative;
|
100 |
-
top: 0;
|
101 |
-
right: 1px;
|
102 |
-
border: none;
|
103 |
-
margin: 0;
|
104 |
-
padding: 0px;
|
105 |
-
background: 0 0;
|
106 |
-
color: #72777c;
|
107 |
-
cursor: pointer;
|
108 |
-
}
|
109 |
-
|
110 |
-
.quads-notice-dismiss:before{
|
111 |
-
display: inline-block;
|
112 |
-
background: 0 0;
|
113 |
-
color: #72777c;
|
114 |
-
content: "\f153";
|
115 |
-
font: 400 16px/20px dashicons;
|
116 |
-
speak: none;
|
117 |
-
height: 20px;
|
118 |
-
text-align: center;
|
119 |
-
width: 20px;
|
120 |
-
-webkit-font-smoothing: antialiased;
|
121 |
-
}
|
1 |
+
/**
|
2 |
+
* QUADS Admin All CSS
|
3 |
+
*
|
4 |
+
* @package QUADS
|
5 |
+
* @subpackage Admin CSS
|
6 |
+
* @copyright Copyright (c) 2017, René Hermenau
|
7 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
@media (max-width:506px){
|
12 |
+
.quads-banner-columns {
|
13 |
+
display: block !important;
|
14 |
+
}
|
15 |
+
.quads-banner-sidebar-second{
|
16 |
+
width: 100% !important;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
@media (max-width:780px){
|
20 |
+
.quads-banner-wrapper{
|
21 |
+
margin-right:12px !important;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
.quads-banner-wrapper{
|
26 |
+
display: flex;
|
27 |
+
flex-direction: column;
|
28 |
+
clear:both;
|
29 |
+
background: #fff;
|
30 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
31 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
32 |
+
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
33 |
+
margin: 5px 5px 2px;
|
34 |
+
margin-right:20px;
|
35 |
+
padding: 1px 12px;
|
36 |
+
}
|
37 |
+
.quads-banner-content {
|
38 |
+
display: flex;
|
39 |
+
flex: 1;
|
40 |
+
color: #000;
|
41 |
+
}
|
42 |
+
.quads-banner-columns{
|
43 |
+
display: flex;
|
44 |
+
flex:1;
|
45 |
+
-ms-flex-align: center;
|
46 |
+
-webkit-align-items: center;
|
47 |
+
-webkit-box-align: center;
|
48 |
+
|
49 |
+
align-items: center;
|
50 |
+
}
|
51 |
+
.quads-banner-main{
|
52 |
+
flex: 1;
|
53 |
+
order: 2;
|
54 |
+
}
|
55 |
+
.quads-banner-sidebar-first{
|
56 |
+
min-width: 160px;
|
57 |
+
width: 13%;
|
58 |
+
order: 1;
|
59 |
+
}
|
60 |
+
.quads-banner-sidebar-second{
|
61 |
+
width: 19%;
|
62 |
+
order: 3;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
.quads-button-primary {
|
67 |
+
display: inline-block;
|
68 |
+
text-decoration: none;
|
69 |
+
font-size: 16px;
|
70 |
+
line-height: 32px;
|
71 |
+
height: 36px;
|
72 |
+
margin: 0;
|
73 |
+
padding: 0 13px 1px;
|
74 |
+
cursor: pointer;
|
75 |
+
border-width: 1px;
|
76 |
+
border-style: solid;
|
77 |
+
-webkit-appearance: none;
|
78 |
+
-webkit-border-radius: 3px;
|
79 |
+
border-radius: 3px;
|
80 |
+
white-space: nowrap;
|
81 |
+
-webkit-box-sizing: border-box;
|
82 |
+
-moz-box-sizing: border-box;
|
83 |
+
box-sizing: border-box;
|
84 |
+
font-weight: bold;
|
85 |
+
}
|
86 |
+
|
87 |
+
.quads-button-primary {
|
88 |
+
background: #0085ba;
|
89 |
+
border-color: #0073aa #006799 #006799;
|
90 |
+
-webkit-box-shadow: 0 1px 0 #006799;
|
91 |
+
box-shadow: 0 1px 0 #006799;
|
92 |
+
color: #fff;
|
93 |
+
text-decoration: none;
|
94 |
+
text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
|
95 |
+
}
|
96 |
+
|
97 |
+
.quads-notice-dismiss {
|
98 |
+
display: inline-block;
|
99 |
+
position: relative;
|
100 |
+
top: 0;
|
101 |
+
right: 1px;
|
102 |
+
border: none;
|
103 |
+
margin: 0;
|
104 |
+
padding: 0px;
|
105 |
+
background: 0 0;
|
106 |
+
color: #72777c;
|
107 |
+
cursor: pointer;
|
108 |
+
}
|
109 |
+
|
110 |
+
.quads-notice-dismiss:before{
|
111 |
+
display: inline-block;
|
112 |
+
background: 0 0;
|
113 |
+
color: #72777c;
|
114 |
+
content: "\f153";
|
115 |
+
font: 400 16px/20px dashicons;
|
116 |
+
speak: none;
|
117 |
+
height: 20px;
|
118 |
+
text-align: center;
|
119 |
+
width: 20px;
|
120 |
+
-webkit-font-smoothing: antialiased;
|
121 |
+
}
|
assets/css/quads-admin.css
CHANGED
@@ -1,1205 +1,1205 @@
|
|
1 |
-
/**
|
2 |
-
* QUADS Admin CSS
|
3 |
-
*
|
4 |
-
* @package QUADS
|
5 |
-
* @subpackage Admin CSS
|
6 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
7 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
8 |
-
*/
|
9 |
-
|
10 |
-
.quads-share-button-container{
|
11 |
-
margin: 5px 0;
|
12 |
-
}
|
13 |
-
|
14 |
-
.quads-share-button-container p{
|
15 |
-
margin:0px 0 10px 0;
|
16 |
-
}
|
17 |
-
|
18 |
-
.quads-share-button {
|
19 |
-
display: inline-block;
|
20 |
-
}
|
21 |
-
|
22 |
-
.quads-share-button a{
|
23 |
-
text-decoration:none;
|
24 |
-
}
|
25 |
-
|
26 |
-
.quads-share-button .quads-share {
|
27 |
-
font-family:sans-serif;
|
28 |
-
font-weight:bold;
|
29 |
-
text-decoration:none;
|
30 |
-
text-align:center;
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
.quads-share-button .quads-share {
|
35 |
-
-webkit-border-radius:2px;
|
36 |
-
-moz-border-radius:2px;
|
37 |
-
border-radius:2px;
|
38 |
-
color:#FFF;
|
39 |
-
display:inline;
|
40 |
-
font-size:16px;
|
41 |
-
width:40px;
|
42 |
-
padding:4px 8px;
|
43 |
-
}
|
44 |
-
|
45 |
-
.quads-share-button-twitter .quads-share {
|
46 |
-
background-color:#00ABF0;
|
47 |
-
}
|
48 |
-
|
49 |
-
.quads-share-button-facebook .quads-share {
|
50 |
-
background-color:#3b5998;
|
51 |
-
}
|
52 |
-
|
53 |
-
.quads-share-button-googleplus .quads-share {
|
54 |
-
background-color:#F53424;
|
55 |
-
}
|
56 |
-
|
57 |
-
.quads-share-button-twitter .share:active,.quads-share-button-facebook .share:active,.quads-share-button-googleplus .share:active {
|
58 |
-
background-color:#353535;
|
59 |
-
}
|
60 |
-
|
61 |
-
/* Responsive */
|
62 |
-
@media (max-width: 925px) {
|
63 |
-
.quads-share-button .quads-share{
|
64 |
-
font-size:15px;
|
65 |
-
padding: 8px 16px; /* Double the padding */
|
66 |
-
}
|
67 |
-
|
68 |
-
}
|
69 |
-
|
70 |
-
|
71 |
-
/* Input forms */
|
72 |
-
/*.quads-textarea{
|
73 |
-
font-size:11px;
|
74 |
-
}*/
|
75 |
-
.quads-richeditor{
|
76 |
-
font-size:11px;
|
77 |
-
}
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
/* =Add Ons Styles
|
82 |
-
-------------------------------------------------------------- */
|
83 |
-
#quads-add-ons h2 { margin: 0 0 15px; }
|
84 |
-
#quads-add-ons .quadsshare-addons { float: left; margin: 0 15px 15px 0; background: #f0f0f0; border: 1px solid #ccc; width: 320px; padding: 8px; height: 315px; position: relative; }
|
85 |
-
#quads-add-ons .quadsshare-addons h3 { margin: 0 0 8px; font-size: 13px; }
|
86 |
-
#quads-add-ons .quadsshare-addons .button-secondary { position: absolute; bottom: 8px; left: 8px; }
|
87 |
-
/*#quads-add-ons .quadsshare-addons { clear:both; width:100%; }*/
|
88 |
-
#quads-add-ons .quadsshare-addons .third-party { display: none; }
|
89 |
-
|
90 |
-
|
91 |
-
/* System Info page styles
|
92 |
-
-------------------------------------------------------------- */
|
93 |
-
#system-info-textarea { width: 580px; height: 400px; font-family: Menlo, Monaco, monospace; background: none; white-space: pre; overflow: auto; display: block; }
|
94 |
-
|
95 |
-
|
96 |
-
/* General styles
|
97 |
-
-------------------------------------------------------------- */
|
98 |
-
.quads-select-chosen { width: 300px; }
|
99 |
-
|
100 |
-
input.large-text, textarea.large-text {
|
101 |
-
max-width: 600px;
|
102 |
-
}
|
103 |
-
input.medium-text, textarea.medium-text {
|
104 |
-
min-width: 190px;
|
105 |
-
}
|
106 |
-
|
107 |
-
/* CSS for Tabs */
|
108 |
-
|
109 |
-
#quads_tab_container ul {
|
110 |
-
/*height: 200px;*/
|
111 |
-
list-style: none;
|
112 |
-
margin: 0;
|
113 |
-
padding: 0;
|
114 |
-
background: #fff;
|
115 |
-
float: left;
|
116 |
-
padding-top: 0px;
|
117 |
-
/*list-style-type: square;*/
|
118 |
-
}
|
119 |
-
|
120 |
-
#quads_tab_container ul li:first-child.selected-tab {
|
121 |
-
border-top: none;
|
122 |
-
}
|
123 |
-
|
124 |
-
#quads_tab_container ul li a.selected-tab {
|
125 |
-
font-weight: bold;
|
126 |
-
text-decoration: none;
|
127 |
-
}
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
#quads_tab_container .quads-row{
|
132 |
-
padding-top:12px;
|
133 |
-
padding-bottom:12px;
|
134 |
-
}
|
135 |
-
|
136 |
-
|
137 |
-
#quads_tab_container .quads-row label strong, #tab_container .quads-row strong {
|
138 |
-
font-weight: bold;
|
139 |
-
}
|
140 |
-
|
141 |
-
.quads-tabs a {
|
142 |
-
padding:5px;
|
143 |
-
color:#a1a1a1;
|
144 |
-
text-transform: uppercase;
|
145 |
-
}
|
146 |
-
.quads-tabs a strong {
|
147 |
-
font-weight: 700;
|
148 |
-
}
|
149 |
-
|
150 |
-
li.quads-tabs {
|
151 |
-
float:left;
|
152 |
-
margin-left:0px;
|
153 |
-
background-color: #e5e5e5;
|
154 |
-
}
|
155 |
-
|
156 |
-
/*@media only screen and (min-width:400px) {
|
157 |
-
li.quads-tabs {
|
158 |
-
float:left;
|
159 |
-
margin-left:14px;
|
160 |
-
}
|
161 |
-
}*/
|
162 |
-
|
163 |
-
#quads_tab_container > ul > li.quads-tabs.active {
|
164 |
-
background-color:#fff;
|
165 |
-
}
|
166 |
-
#quads_tab_container > ul > li.quads-tabs.active a {
|
167 |
-
color: #83c11f;
|
168 |
-
}
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
/* Layout of admin table and rows
|
173 |
-
*/
|
174 |
-
|
175 |
-
|
176 |
-
#quads_tab_container .quads-panel-container {
|
177 |
-
background: #FFF;
|
178 |
-
padding:20px;
|
179 |
-
overflow:auto;
|
180 |
-
text-align:left;
|
181 |
-
margin-bottom:10px;
|
182 |
-
max-width: 640px;
|
183 |
-
float: left;
|
184 |
-
clear:both;
|
185 |
-
}
|
186 |
-
|
187 |
-
.form-table{
|
188 |
-
margin-top:-20px;
|
189 |
-
}
|
190 |
-
|
191 |
-
#quads_tab_container .form-table th {
|
192 |
-
vertical-align: top;
|
193 |
-
text-align: left;
|
194 |
-
padding: 20px 10px 20px 0;
|
195 |
-
width: 200px;
|
196 |
-
line-height: 1.3;
|
197 |
-
font-weight: bold;
|
198 |
-
font-size: 14px;
|
199 |
-
color:#484848;
|
200 |
-
width: 30%;
|
201 |
-
}
|
202 |
-
|
203 |
-
/*#quads_tab_container .form-table tr{
|
204 |
-
padding:0px;
|
205 |
-
}*/
|
206 |
-
|
207 |
-
#quads_tab_container .form-table tr {
|
208 |
-
border-bottom: 1px solid #E7E7E7;
|
209 |
-
}
|
210 |
-
|
211 |
-
#quads_tab_container span.description{
|
212 |
-
display: block;
|
213 |
-
font-weight: 400;
|
214 |
-
font-style: normal;
|
215 |
-
font-size: 13px;
|
216 |
-
margin-top: 7px;
|
217 |
-
color:#484848;
|
218 |
-
}
|
219 |
-
|
220 |
-
#quads_tab_container .col-title{
|
221 |
-
font-size: 18px;
|
222 |
-
color:#484848;
|
223 |
-
}
|
224 |
-
|
225 |
-
@media only screen and (max-width:680px) {
|
226 |
-
#quads_tab_container ul {
|
227 |
-
float:none;
|
228 |
-
background: #fff;
|
229 |
-
}
|
230 |
-
#quads_tab_container .form-table tr > th {
|
231 |
-
width:100%;
|
232 |
-
}
|
233 |
-
#quads_tab_container span.description{
|
234 |
-
font-size: 14px;
|
235 |
-
}
|
236 |
-
#quads_tab_container .form-table tr > th, #tab_container .form-table tr > td {
|
237 |
-
padding:10px;
|
238 |
-
}
|
239 |
-
#quads_tab_container .quads-tabs a{
|
240 |
-
text-align: left;
|
241 |
-
}
|
242 |
-
#quads_tab_container li.quads-tabs {
|
243 |
-
float:none;
|
244 |
-
margin-left:0px;
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
#quads_tab_container ul li.quads-tabs {
|
249 |
-
margin-bottom:0px;
|
250 |
-
}
|
251 |
-
|
252 |
-
#quads_tab_container ul li.quads-tabs a {
|
253 |
-
display: block;
|
254 |
-
padding:10px 10px 10px 10px;
|
255 |
-
text-decoration: none;
|
256 |
-
font-weight: bold;
|
257 |
-
}
|
258 |
-
#quads_tab_container ul li.quads-tabs a:hover {
|
259 |
-
color:#383838;
|
260 |
-
}
|
261 |
-
#quads_tab_container ul li.quads-tabs a.active {
|
262 |
-
text-decoration: underline;
|
263 |
-
}
|
264 |
-
|
265 |
-
|
266 |
-
#quads_tab_container table tbody tr:nth-child(1) > th > div {
|
267 |
-
font-size: 20px;
|
268 |
-
}
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
/* End layout of admin table and rows
|
273 |
-
*/
|
274 |
-
#quadstabcontainer > .quadstabs {
|
275 |
-
background-color: #ffffff;
|
276 |
-
}
|
277 |
-
|
278 |
-
#quadstabcontainer ul .active {
|
279 |
-
background-color: #00adef;
|
280 |
-
color: white;
|
281 |
-
border-bottom-color: #0098D2;
|
282 |
-
}
|
283 |
-
|
284 |
-
#quadstabcontainer ul .active:hover {
|
285 |
-
background-color: #00A4E2;
|
286 |
-
color: white;
|
287 |
-
border-bottom-color: #0098D2;
|
288 |
-
}
|
289 |
-
|
290 |
-
#quadstabcontainer ul li a {
|
291 |
-
padding: 10px 14px 10px 14px;
|
292 |
-
background-color: #f3f3f3
|
293 |
-
|
294 |
-
}
|
295 |
-
|
296 |
-
#quadstabcontainer .quadstab-container {
|
297 |
-
border: 0px solid #ececec;
|
298 |
-
}
|
299 |
-
|
300 |
-
.quads-quote-docs {
|
301 |
-
font-family:Courier New,Courier,Fixed;
|
302 |
-
color:#050;
|
303 |
-
}
|
304 |
-
|
305 |
-
.quads-desc{
|
306 |
-
display:block;
|
307 |
-
font-style:italic;
|
308 |
-
padding-top:10px;
|
309 |
-
}
|
310 |
-
|
311 |
-
.quads-postbox {
|
312 |
-
padding:10px;
|
313 |
-
position: relative;
|
314 |
-
min-width: 255px;
|
315 |
-
border: 1px solid #e5e5e5;
|
316 |
-
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
317 |
-
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
318 |
-
background: #fff;
|
319 |
-
margin-bottom:20px;
|
320 |
-
}
|
321 |
-
|
322 |
-
.nav-tab-active{
|
323 |
-
background-color: white;
|
324 |
-
border-bottom:0px;
|
325 |
-
}
|
326 |
-
|
327 |
-
/*.wp-admin .quads-align-input{
|
328 |
-
padding: 0px;
|
329 |
-
line-height: 23px;
|
330 |
-
height: 24px;
|
331 |
-
vertical-align: top;
|
332 |
-
}*/
|
333 |
-
|
334 |
-
|
335 |
-
#quads-add-ons {
|
336 |
-
padding: 20px;
|
337 |
-
}
|
338 |
-
.quads-toggle {
|
339 |
-
position: absolute;
|
340 |
-
right: 0px;
|
341 |
-
top: 0px;
|
342 |
-
}
|
343 |
-
|
344 |
-
.quads-box-close .quads-close-open-icon {
|
345 |
-
background-position: 0px -38px;
|
346 |
-
}
|
347 |
-
|
348 |
-
.quads-close-open-icon {
|
349 |
-
width: 38px;
|
350 |
-
height: 38px;
|
351 |
-
background: #f4f4f4 url("../images/arrow-close.png") repeat-y;
|
352 |
-
background-position: 0px 0px;
|
353 |
-
}
|
354 |
-
.quads-ad-toggle-header {
|
355 |
-
position: relative;
|
356 |
-
background-color: #f4f4f4;
|
357 |
-
margin-bottom: 2px;
|
358 |
-
padding: 10px 10px 10px 15px;
|
359 |
-
-moz-user-select: -moz-none;
|
360 |
-
-khtml-user-select: none;
|
361 |
-
-webkit-user-select: none;
|
362 |
-
-o-user-select: none;
|
363 |
-
user-select: none;
|
364 |
-
cursor: pointer !important;
|
365 |
-
min-height: 20px;
|
366 |
-
}
|
367 |
-
|
368 |
-
.quads-ad-toggle-container{
|
369 |
-
padding:20px;
|
370 |
-
background-color: #f4f4f4;
|
371 |
-
}
|
372 |
-
|
373 |
-
.quads-toogle-title{
|
374 |
-
font-size:16px;
|
375 |
-
font-weight: bold;
|
376 |
-
}
|
377 |
-
|
378 |
-
.quads-advanced-description label{
|
379 |
-
float:left;
|
380 |
-
width:215px;
|
381 |
-
font-size: 12px;
|
382 |
-
font-weight: 600;
|
383 |
-
text-transform: uppercase;
|
384 |
-
}
|
385 |
-
|
386 |
-
.quads-advanced-ad-box{
|
387 |
-
clear: both;
|
388 |
-
margin-top:20px;
|
389 |
-
margin-bottom:20px;
|
390 |
-
}
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
.adsense-size-title {
|
395 |
-
margin-right: 0px;
|
396 |
-
float: left;
|
397 |
-
line-height: 32px;
|
398 |
-
margin-left: 14px;
|
399 |
-
min-width: 100px;
|
400 |
-
font-weight: 600;
|
401 |
-
font-size: 12px;
|
402 |
-
text-transform: uppercase;
|
403 |
-
}
|
404 |
-
|
405 |
-
.quads-select-style-overwrite {
|
406 |
-
border: 1px solid #e6e6e6;
|
407 |
-
width: 150px;
|
408 |
-
overflow: hidden;
|
409 |
-
background: #ffffff url("../images/box_arrow.png") repeat-y 120px 0px;
|
410 |
-
margin: 0px 0px 5px 0px;
|
411 |
-
}
|
412 |
-
.quads-select-style-overwrite select {
|
413 |
-
width:150px;
|
414 |
-
}
|
415 |
-
|
416 |
-
/*.quads-select{
|
417 |
-
max-width:100px;
|
418 |
-
}*/
|
419 |
-
|
420 |
-
.quads-size-input {
|
421 |
-
position: relative;
|
422 |
-
top: -1px;
|
423 |
-
width: 110%;
|
424 |
-
border: none;
|
425 |
-
box-shadow: none;
|
426 |
-
background: transparent;
|
427 |
-
background-image: none;
|
428 |
-
-webkit-appearance: none;
|
429 |
-
font-family: 'Open Sans', arial, sans-serif;
|
430 |
-
color: #555555;
|
431 |
-
font-size: 12px;
|
432 |
-
/*margin-left:5px;*/
|
433 |
-
}
|
434 |
-
|
435 |
-
.quads-pro-overlay{
|
436 |
-
height: 200px;
|
437 |
-
}
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
.quads-license-error-notice,
|
442 |
-
.quads-license-expires-soon-notice {
|
443 |
-
background-color: #fff;
|
444 |
-
padding: 10px;
|
445 |
-
border-left: 4px solid #7ad03a;
|
446 |
-
overflow: auto;
|
447 |
-
-webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
448 |
-
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
449 |
-
border: 1px solid #ECECEC;
|
450 |
-
border-radius: 3px;
|
451 |
-
}
|
452 |
-
.quads-license-error-notice a {
|
453 |
-
color: #0097df;
|
454 |
-
text-decoration: underline;
|
455 |
-
}
|
456 |
-
.quads-license-error-notice { border-left: 4px solid #dd3d36; }
|
457 |
-
.quads-license-lifetime-notice,
|
458 |
-
.quads-license-expiration-date-notice,
|
459 |
-
.quads-license-null { padding: 0 0 0 0px; }
|
460 |
-
.quads-license-lifetime-notice .quads-license-data p,
|
461 |
-
.quads-license-expiration-date-notice .quads-license-data p { color: #666; font-size: 14px; font-style: italic; margin: 4px 0 0; }
|
462 |
-
|
463 |
-
#quads_settingslicenses_header-nav{
|
464 |
-
display:none;
|
465 |
-
}
|
466 |
-
|
467 |
-
#quads_settingslicenses_header{
|
468 |
-
max-width:640px;
|
469 |
-
}
|
470 |
-
|
471 |
-
#quads_settingslicenses_header .quads-row.th{
|
472 |
-
min-width:250px;
|
473 |
-
}
|
474 |
-
|
475 |
-
.quads-notice{
|
476 |
-
background: #fff;
|
477 |
-
border-left: 4px solid #46b450;
|
478 |
-
-webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
479 |
-
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
480 |
-
margin: 5px 15px 2px;
|
481 |
-
padding: 1px 12px;
|
482 |
-
}
|
483 |
-
|
484 |
-
.quads_admin h2.nav-tab-wrapper{
|
485 |
-
border:0px;
|
486 |
-
}
|
487 |
-
|
488 |
-
.quads_admin .nav-tab{
|
489 |
-
border:0px;
|
490 |
-
text-transform: uppercase;
|
491 |
-
color: #a1a1a1;
|
492 |
-
font-weight: 700;
|
493 |
-
}
|
494 |
-
|
495 |
-
.quads-h1 {
|
496 |
-
font-size: 2.75em;
|
497 |
-
margin-bottom: 1.35rem;
|
498 |
-
font-size: 2.5em;
|
499 |
-
line-height: 3.68rem;
|
500 |
-
letter-spacing: normal;
|
501 |
-
}
|
502 |
-
|
503 |
-
.quads-h2 {
|
504 |
-
margin-top:0px;
|
505 |
-
margin-bottom: 1.2rem;
|
506 |
-
font-size: 30px;
|
507 |
-
line-height: 2.5rem;
|
508 |
-
}
|
509 |
-
|
510 |
-
.quads-heading-pro{
|
511 |
-
color: #83c11f;
|
512 |
-
font-weight: bold;
|
513 |
-
}
|
514 |
-
|
515 |
-
.quads-button.green {
|
516 |
-
display:inline-block;
|
517 |
-
background-color: #83c11f;
|
518 |
-
padding:10px;
|
519 |
-
min-width: 170px;
|
520 |
-
color: white;
|
521 |
-
font-size: 16px;
|
522 |
-
text-decoration: none;
|
523 |
-
text-align:center;
|
524 |
-
margin-top:20px;
|
525 |
-
}
|
526 |
-
|
527 |
-
#quads-add-ons .quads-footer {
|
528 |
-
clear:both;
|
529 |
-
margin-top:20px;
|
530 |
-
font-style: italic;
|
531 |
-
}
|
532 |
-
|
533 |
-
#quads-footer {
|
534 |
-
clear:both;
|
535 |
-
}
|
536 |
-
|
537 |
-
#quads-add-ons li {
|
538 |
-
font-size:18px;
|
539 |
-
line-height: 29px;
|
540 |
-
position: relative;
|
541 |
-
padding-left: 23px;
|
542 |
-
list-style: none!important;
|
543 |
-
}
|
544 |
-
|
545 |
-
#quads-add-ons li:before {
|
546 |
-
width: 1em;
|
547 |
-
height: 100%;
|
548 |
-
background: url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;
|
549 |
-
background-size: contain;
|
550 |
-
content: "";
|
551 |
-
position: absolute;
|
552 |
-
top: 0;
|
553 |
-
left: 0;
|
554 |
-
color: #77b227;
|
555 |
-
}
|
556 |
-
|
557 |
-
.adsense_admin_header {
|
558 |
-
font-size: 14px;
|
559 |
-
font-weight: 500;
|
560 |
-
}
|
561 |
-
|
562 |
-
#quads-adsense-bg-div{
|
563 |
-
position: fixed;
|
564 |
-
top: 0;
|
565 |
-
left: 0;
|
566 |
-
width: 100%;
|
567 |
-
height: 100%;
|
568 |
-
background-color: rgba(0, 0, 0, 0.65);
|
569 |
-
z-index: 250000;
|
570 |
-
}
|
571 |
-
|
572 |
-
#quads-adsense-container {
|
573 |
-
text-align: center;
|
574 |
-
width: 480px;
|
575 |
-
margin: 85px auto 0 auto;
|
576 |
-
background-color: #fff;
|
577 |
-
padding: 2%;
|
578 |
-
border-radius: 2px;
|
579 |
-
}
|
580 |
-
#quads-adsense-container h3{
|
581 |
-
margin-top:0px;
|
582 |
-
}
|
583 |
-
|
584 |
-
#quads-adsense-container textarea{
|
585 |
-
width: 100%;
|
586 |
-
}
|
587 |
-
|
588 |
-
|
589 |
-
.quads-ad-toggle-container textarea{
|
590 |
-
width: 100%;
|
591 |
-
}
|
592 |
-
|
593 |
-
.quads-ad-toggle-container input{
|
594 |
-
margin-top: 7px;
|
595 |
-
margin-bottom:10px;
|
596 |
-
}
|
597 |
-
|
598 |
-
.quads-adsense-code label, input{
|
599 |
-
margin-right:2px;
|
600 |
-
}
|
601 |
-
|
602 |
-
#quads_settings\5b ad2\5d \5b g_data_ad_client\5d {
|
603 |
-
width:200px;
|
604 |
-
}
|
605 |
-
|
606 |
-
.quads-ad-toggle-container label {
|
607 |
-
display: inline-block;
|
608 |
-
margin-right:2px;
|
609 |
-
margin-top:-3px;
|
610 |
-
}
|
611 |
-
|
612 |
-
/*.quads-adsense-code > label:nth-child(1){
|
613 |
-
min-width: 74px;
|
614 |
-
}*/
|
615 |
-
|
616 |
-
.quads_adsense_code .quads-add-adsense {
|
617 |
-
margin:20px;
|
618 |
-
margin-left:0px;
|
619 |
-
margin-right:5px;
|
620 |
-
}
|
621 |
-
|
622 |
-
.quads-label-left {
|
623 |
-
min-width: 71px;
|
624 |
-
}
|
625 |
-
|
626 |
-
#quads-label-Type {
|
627 |
-
min-width: 67px;
|
628 |
-
}
|
629 |
-
|
630 |
-
.quads-medium-size{
|
631 |
-
width: 110px;
|
632 |
-
}
|
633 |
-
|
634 |
-
#quads-msg{
|
635 |
-
display:none;
|
636 |
-
margin: 5px;
|
637 |
-
background-color: #c55c5c;
|
638 |
-
color: white;
|
639 |
-
}
|
640 |
-
|
641 |
-
.quads-success-modal {
|
642 |
-
display: block;
|
643 |
-
position: fixed;
|
644 |
-
top: 45%;
|
645 |
-
left: 25%;
|
646 |
-
width: 200px;
|
647 |
-
height: auto;
|
648 |
-
padding: 5px 20px;
|
649 |
-
z-index:1002;
|
650 |
-
overflow: auto;
|
651 |
-
}
|
652 |
-
.quads-loader {
|
653 |
-
display: block;
|
654 |
-
position: fixed;
|
655 |
-
top: 45%;
|
656 |
-
left: 25%;
|
657 |
-
width: 200px;
|
658 |
-
height: auto;
|
659 |
-
padding: 5px 20px;
|
660 |
-
z-index:1002;
|
661 |
-
overflow: auto;
|
662 |
-
}
|
663 |
-
|
664 |
-
.quads-form-table{
|
665 |
-
width: 100%;
|
666 |
-
}
|
667 |
-
|
668 |
-
.quads-left-box{
|
669 |
-
width:45%;
|
670 |
-
min-height:100px;
|
671 |
-
float:left;
|
672 |
-
line-height: 35px;
|
673 |
-
min-width: 300px;
|
674 |
-
}
|
675 |
-
|
676 |
-
@media screen and (max-width:700px){
|
677 |
-
.adsense-size-title {
|
678 |
-
margin-left: 0px;
|
679 |
-
}
|
680 |
-
.quads-left-box{
|
681 |
-
width:45%;
|
682 |
-
min-height:100px;
|
683 |
-
float:none;
|
684 |
-
line-height: 35px;
|
685 |
-
min-width: 300px;
|
686 |
-
}
|
687 |
-
|
688 |
-
.quads-style img{
|
689 |
-
max-width: 50px;
|
690 |
-
}
|
691 |
-
|
692 |
-
}
|
693 |
-
|
694 |
-
.adsense_admin_header ul li{
|
695 |
-
margin-top:2px;
|
696 |
-
margin-left:20px;
|
697 |
-
list-style-type: square;
|
698 |
-
}
|
699 |
-
|
700 |
-
.quads-helper {
|
701 |
-
border-radius: 50%;
|
702 |
-
border: 2px solid #fff;
|
703 |
-
background-color: #83c11f;
|
704 |
-
width: 15px;
|
705 |
-
height: 15px;
|
706 |
-
display: inline-block;
|
707 |
-
position: relative;
|
708 |
-
top: 4px;
|
709 |
-
margin-top: -4px;
|
710 |
-
cursor: pointer;
|
711 |
-
margin-left: 2px;
|
712 |
-
}
|
713 |
-
|
714 |
-
.quads-helper:after {
|
715 |
-
height: 20px;
|
716 |
-
font-family: sans-serif;
|
717 |
-
content: "?";
|
718 |
-
color: #fff;
|
719 |
-
font-size: 11px;
|
720 |
-
font-weight: bold;
|
721 |
-
left: 4px;
|
722 |
-
position: absolute;
|
723 |
-
margin-top: -10px;
|
724 |
-
}
|
725 |
-
|
726 |
-
.quads-general-helper:after {
|
727 |
-
height: 20px;
|
728 |
-
font-family: sans-serif;
|
729 |
-
content: "?";
|
730 |
-
color: #fff;
|
731 |
-
font-size: 11px;
|
732 |
-
font-weight: bold;
|
733 |
-
left: 4px;
|
734 |
-
position: absolute;
|
735 |
-
margin-top: -2px;
|
736 |
-
}
|
737 |
-
.quads-general-helper {
|
738 |
-
border-radius: 50%;
|
739 |
-
border: 2px solid #fff;
|
740 |
-
background-color: #83c11f;
|
741 |
-
width: 15px;
|
742 |
-
height: 15px;
|
743 |
-
display: inline-block;
|
744 |
-
position: relative;
|
745 |
-
top: 4px;
|
746 |
-
margin-top: -4px;
|
747 |
-
cursor: pointer;
|
748 |
-
margin-left: 2px;
|
749 |
-
}
|
750 |
-
|
751 |
-
.quads-message{
|
752 |
-
display:block;
|
753 |
-
padding: 10px;
|
754 |
-
border: 1px solid #FBFBFB;
|
755 |
-
border-radius: 2px;
|
756 |
-
background-color: #F8F8F8;
|
757 |
-
position: absolute;
|
758 |
-
max-width: 500px;
|
759 |
-
z-index: 9999;
|
760 |
-
display: none;
|
761 |
-
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
762 |
-
font-weight: normal;
|
763 |
-
line-height: 20px;
|
764 |
-
text-transform: none;
|
765 |
-
font-size: 14px;
|
766 |
-
}
|
767 |
-
|
768 |
-
#quads-pro-hover{
|
769 |
-
background-color: #83c11f;
|
770 |
-
padding:20px;
|
771 |
-
min-width: 150px;
|
772 |
-
color:white;
|
773 |
-
display: block;
|
774 |
-
position: relative;
|
775 |
-
margin-top: -100px;
|
776 |
-
margin-left: 50%;
|
777 |
-
}
|
778 |
-
|
779 |
-
#quads-pro-hover-background{
|
780 |
-
width: 100%; height:100%;background:rgba(0,0,0,0.6);
|
781 |
-
}
|
782 |
-
|
783 |
-
#quads-open-toggle{
|
784 |
-
clear: both;
|
785 |
-
float:left;
|
786 |
-
margin-top:10px;
|
787 |
-
}
|
788 |
-
|
789 |
-
#quads_settingsadsense_header input[type="number"].small-text{
|
790 |
-
width: 55px;
|
791 |
-
}
|
792 |
-
|
793 |
-
.quads_adsense_code input.quads-bggrey {
|
794 |
-
background-color: whitesmoke;
|
795 |
-
color: #939393;
|
796 |
-
}
|
797 |
-
|
798 |
-
.quads-amp-code{
|
799 |
-
color: #939393;
|
800 |
-
height: 130px;
|
801 |
-
}
|
802 |
-
|
803 |
-
.quads-chosen-select .chosen-choices li.search-field input{
|
804 |
-
min-height: 25px;
|
805 |
-
}
|
806 |
-
|
807 |
-
|
808 |
-
#quads-validate{
|
809 |
-
display: block;
|
810 |
-
margin-left: 2px;
|
811 |
-
margin-bottom: 20px;
|
812 |
-
font-weight: bold;
|
813 |
-
clear: both;
|
814 |
-
}
|
815 |
-
|
816 |
-
@font-face {
|
817 |
-
font-family: 'quads';
|
818 |
-
src: url('data:application/octet-stream;base64,d09GRgABAAAAAAxYAA8AAAAAFUQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABWAAAADsAAABUIIslek9TLzIAAAGUAAAAQwAAAFY+IEkBY21hcAAAAdgAAABQAAABfohD7KljdnQgAAACKAAAABMAAAAgBtX/BGZwZ20AAAI8AAAFkAAAC3CKkZBZZ2FzcAAAB8wAAAAIAAAACAAAABBnbHlmAAAH1AAAAdIAAAJWlz85pGhlYWQAAAmoAAAAMwAAADYNxZM1aGhlYQAACdwAAAAfAAAAJAc6A1BobXR4AAAJ/AAAAAwAAAAMClL//WxvY2EAAAoIAAAACAAAAAgAxAErbWF4cAAAChAAAAAgAAAAIAESDApuYW1lAAAKMAAAAXcAAALNzJ0dH3Bvc3QAAAuoAAAAMwAAAESFVFBUcHJlcAAAC9wAAAB6AAAAhuVBK7x4nGNgZGBg4GIwYLBjYHJx8wlh4MtJLMljkGJgYYAAkDwymzEnMz2RgQPGA8qxgGkOIGaDiAIAJjsFSAB4nGNgZC5knMDAysDAVMW0h4GBoQdCMz5gMGRkAooysDIzYAUBaa4pDA4vGF4wMgf9z2KIYg5imAYUZgTJAQDj3AufAHic7ZCxDYAwDATPiaFAjEFBwTBU7F+yRfK2GYOX7qR/uTKwAF1cwsEejMit1XLvbLk7R9547K+NIRNW93STVv7s6fNrLf5U1OcK2gTMuAtdeJxjYEADEhDIHPQ/C4QBEmwD3QB4nK1WaXfTRhQdeUmchCwlCy1qYcTEabBGJmzBgAlBsmMgXZytlaCLFDvpvvGJ3+Bf82Tac+g3flrvGy8kkLTncJqTo3fnzdXM22USWpLYC+uRlJsvxdTWJo3sPAnphk3LUXwoO3shZYrJ3wVREK2W2rcdh0REIlC1rrBEEPseWZpkfOhRRsu2pFdNyi096S5b40G9Vd9+GjrKsTuhpGYzdGg9siVVGFWiSKY9UtKmZaj6K0krvL/CzFfNUMKITiJpvBnG0EjeG2e0ymg1tuMoimyy3ChSJJrhQRR5lNUS5+SKCQzKB82Q8sqnEeXD/Iis2KOcVrBLttP8vi95p3c5P7Ffb1G25EAfyI7s4Ox0JV+EW1th3LST7ShUEXbXd0Js2exU/2aP8ppGA7crMr3QjGCpfIUQKz+hzP4hWS2cT/mSR6NaspETQetlTuxLPoHW44gpcc0YWdDd0QkR1P2SMwz2mD4e/PHeKZYLEwJ4HMt6RyWcCBMpYXM0SdowcmAlZYsqqfWumDjldVrEW8J+7drRl85o41B3YjxbDx1bOVHJ8WhSp5lMndpJzaMpDaKUdCZ4zK8DKD+iSV5tYzWJlUfTOGbGhEQiAi3cS1NBLDuxpCkEzaMZvbkbprl2LVqkyQP13KP39OZWuLnTU9oO9LNGf1anYjrYC9PpaeQv8Wna5SJF6frpGX5M4kHWAjKRLTbDlIMHb/0O0svXlhyF1wbY7u3zK6h91kTwpAH7G9AeT9UpCUyFmFWIVkBirWtZlsnVrBapyNR3Q5pWvqzTBIpyHBfHvoxx/V8zM5aYEr7fidOzIy49c+1LCNMcfJt1PZrXqcVyAXFmeU6nWZbv6zTH8gOd5lme1+kIS1unoyw/1GmB5Uc6HWN5QQuadN/BkIsw5AIOkDCEpQNDWF6CISwVDGG5CENYFmEIyyUYwvJjGMJyGYawvKxl1dRTSePamVgGbEJgYo4eucxF5WoquVRCu2hUakOeEm6VVBTPqn9loF488oY5sBZIl8iaXzHOlY9G5fjWFS1vGjtXwLHqbx+O9jnxUtaLhT8F/9XWVCW9Ys3Dk6vwG4aebCeqNql4dE2Xz1U9uv5fVFRYC/QbSIVYKMqybHBnIoSPOp2GaqCVQ8xszDy063XLmp/D/TcxQhZQ/fg3FBoL3INOWUlZ7eCs1dfbstw7g3I4EyxJMTfz+lb4IiOz0n6RWcqej3wecAWMSmXYagOtFbzZJzEPmd4kzwRxW1E2SNrYzgSJDRzzgHnznQQmYeqqDeRO4YYN+AVhbsF5J1yieqMsh+5F7PMopPxbp+JE9qhojMCz2Rthr+9Cym9xDCQ0+aV+DFQVoakYNRXQNFJuqAZfxtm6bULGDvQjKnbDsqziw8cW95WSbRmEfKSI1aOjn9Zeok6q3H5mFJfvnb4FwSA1MX9733RxkMq7WskyR20DU7calVPXmkPjVYfq5lH1vePsEzlrmm66Jx56X9Oq28HFXCyw9m0O0lImF9T1YYUNosvFpVDqZTRJ77gHGBYY0O9Qio3/q/rYfJ4rVYXRcSTfTtS30edgDPwP2H9H9QPQ92Pocg0uz/eaE59u9OFsma6iF+un6Dcwa625WboG3NB0A+IhR62OuMoNfKcGcXqkuRzpIeBj3RXiAcAmgMXgE921jOZTAKP5jDk+wOfMYdBkDoMt5jDYZs4awA5zGOwyh8Eecxh8wZx1gC+ZwyBkDoOIOQyeMCcAeMocBl8xh8HXzGHwDXPuA3zLHAYxcxgkzGGwr+nWMMwtXtBdoLZBVaADU09Y3MPiUFNlyP6OF4b9vUHM/sEgpv6o6faQ+hMvDPVng5j6i0FM/VXTnSH1N14Y6u8GMfUPg5j6TL8Yy2UGv4x8lwoHlF1sPufvifcP28VAuQABAAH//wAPeJyFkc9r1EAUx9+bTGYmk21i7CSLWHfZZDdBV9aS7A+wuHb9wbawINiCLaW1hS0eSj1IvXjw7sX9M7zoob0IIngp4tE/Q/TQiydhUyf1UC/iY/jw/b73hTfwgAGcHhoXDRtcqMINWIC78ATGizuP7hMmrtYueRYyQDI0DaIFQ9inhABnwPfAAUs41rY7Q0RJEoaCbQG3bb4KnNtrYHN7tDve2dpYX3n4YLQ8HNxWdRUXFV0wrzTRU6yJYdzx2t0FTIPyf/ysV/NUBbNa2kfMkjiJGDf9IqODUS2MEy8K41tYpHt97GVpUEUNrEhRF/IMk3P5WvI/ksulvCQEwa9EiPzVr8vUPGQUf0jRbTfy+UYbO0XubWJdD47K16zknZD4Pv9UNHFQ8B86HxNvelJSUiqyOzARzRW9cXrSunenRWbPPrHpz2FFbUogp1N9h8f6DhHMw2CxP4OAVaQGGRKtDARj30SD6rcHHBA4bgNljK4CpWwNGGUj34/qjaiuhDnXxE475pFGEoWM+xplXwW9TKOcpd1ep4ByMGyRPqYVJG8CZxI4Q1fhxAlQuefm6Nnnb1+eshcff354iTeX9HSiBzqu3L9N9vz44OD4e4HfFf9hawAAeJxjYGRgYADiN4uE5eP5bb4ycDO/AIowXE1YfgpG///7fyPzC2ZuIJeDgQkkCgB97A5TAHicY2BkYGAO+p8FJF/8//v/F/MLBqAICmAGALYGB48AA+gAAAMRAAADWf/9AAAAAADEASsAAQAAAAMAaAAGAAAAAAACACAAMABzAAAAdQtwAAAAAHicdZDdasIwGIbfzJ9tCtvYYKfL0VDG6g8MQRAEh55sJzI8HbXWtlIbSaPgbewedjG7iV3LXts4hrKWNM/35MuXrwFwjW8I5M8TR84CZ4xyPsEpepYL9M+Wi+QXyyVU8Wa5TP9uuYIHBJaruMEHK4jiOaMFPi0LXIlLyye4EHeWC/SPlovknuUSbsWr5TK9Z7mCiUgtV3EvvgZqtdVREBpZG9Rlu9nqyOlWKqoocWPprk2odCr7cq4S48excjy13PPYD9axq/fhfp74Oo1UIltOc69GfuJr1/izXfV0E7SNmcu5Vks5tBlypdXC94wTGrPqNhp/z8MACitsoRHxqkIYSNRo65zbaKKFDmnKDMnMPCtCAhcxjYs1d4TZSsq4zzFnlND6zIjJDjx+l0d+TAq4P2YVfbR6GE9IuzOizEv25bC7w6wRKcky3czOfntPseFpbVrDXbsuddaVxPCghuR97NYWNB69k92Koe2iwfef//sB5m6EUQB4nGNgYoAALgbsgJmRiZGZkYWBu6QosThDNzW3oKSSpyCntFg3ObMoOSc1hYEBAI3CCXgAeJxj8N7BcCIoYiMjY1/kBsadHAwcDMkFGxlYnTYxMDJogRibuZgYOSAsPgYwi81pF9MBoDQnkM3utIvBAcJmZnDZqMLYERixwaEjYiNzistGNRBvF0cDAyOLQ0dySARISSQQbOZhYuTR2sH4v3UDS+9GJgYXAAx2I/QAAA==') format('woff'),
|
819 |
-
url('data:application/octet-stream;base64,AAEAAAAPAIAAAwBwR1NVQiCLJXoAAAD8AAAAVE9TLzI+IEkBAAABUAAAAFZjbWFwiEPsqQAAAagAAAF+Y3Z0IAbV/wQAAAksAAAAIGZwZ22KkZBZAAAJTAAAC3BnYXNwAAAAEAAACSQAAAAIZ2x5Zpc/OaQAAAMoAAACVmhlYWQNxZM1AAAFgAAAADZoaGVhBzoDUAAABbgAAAAkaG10eApS//0AAAXcAAAADGxvY2EAxAErAAAF6AAAAAhtYXhwARIMCgAABfAAAAAgbmFtZcydHR8AAAYQAAACzXBvc3SFVFBUAAAI4AAAAERwcmVw5UErvAAAFLwAAACGAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAEDcQGQAAUAAAJ6ArwAAACMAnoCvAAAAeAAMQECAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAQOgA6AEDUv9qAFoDUgCWAAAAAQAAAAAAAAAAAAUAAAADAAAALAAAAAQAAAFWAAEAAAAAAFAAAwABAAAALAADAAoAAAFWAAQAJAAAAAQABAABAADoAf//AADoAP//AAAAAQAEAAAAAQACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAoAAAAAAAAAAIAAOgAAADoAAAAAAEAAOgBAADoAQAAAAIAAAAGAAD/sQMSAwsADwAfAC8AOwBDAGcAZEBhV0UCBggpIRkRCQEGAAECRwUDAgEGAAYBAG0EAgIABwYAB2sADgAJCA4JYA8NAggMCgIGAQgGXgAHCwsHVAAHBwtYAAsHC0xlZGFeW1lTUk9MSUdBPxQkFCYmJiYmIxAFHSsBERQGKwEiJjURNDY7ATIWFxEUBisBIiY1ETQ2OwEyFhcRFAYrASImNRE0NjsBMhYTESERFB4BMyEyPgEBMycmJyMGBwUVFAYrAREUBiMhIiYnESMiJj0BNDY7ATc+ATczMhYfATMyFgEeCggkCAoKCCQICo8KCCQICgoIJAgKjgoHJAgKCggkBwpI/gwICAIB0AIICP6J+hsEBbEGBAHrCgg2NCX+MCU0ATUICgoIrCcJLBayFyoJJ60ICgG3/r8ICgoIAUEICgoI/r8ICgoIAUEICgoI/r8ICgoIAUEICgr+ZAIR/e8MFAoKFAJlQQUBAQVTJAgK/e8uREIuAhMKCCQICl0VHAEeFF0KAAL//f+xA18DCwAjADAAQUA+DQEAAR8BBAMCRwIBAAEDAQADbQUBAwQBAwRrAAcAAQAHAWAABAYGBFQABAQGWAAGBAZMFRUjJCUjJBQIBRwrATU0JgcjNTQmJyMiBgcVIyIGFxUUFjczFRQWFzMyNjc1MzI2NxQOASIuAj4BMh4BAqcWDo8WDkcPFAGPDhYBFA+PFg5HDxQBjw4WsnLG6MhuBnq89Lp+ATpIDhYBjw8UARYOjxQPSA4WAY8PFAEWDo8UM3XEdHTE6sR0dMQAAAABAAAAAQAA7KITH18PPPUACwPoAAAAANVgp8oAAAAA1WCnyv/9/7ED6AMLAAAACAACAAAAAAAAAAEAAANS/2oAAAPo//3/+gPoAAEAAAAAAAAAAAAAAAAAAAADA+gAAAMRAAADWf/9AAAAAADEASsAAQAAAAMAaAAGAAAAAAACACAAMABzAAAAdQtwAAAAAAAAABIA3gABAAAAAAAAADUAAAABAAAAAAABAAgANQABAAAAAAACAAcAPQABAAAAAAADAAgARAABAAAAAAAEAAgATAABAAAAAAAFAAsAVAABAAAAAAAGAAgAXwABAAAAAAAKACsAZwABAAAAAAALABMAkgADAAEECQAAAGoApQADAAEECQABABABDwADAAEECQACAA4BHwADAAEECQADABABLQADAAEECQAEABABPQADAAEECQAFABYBTQADAAEECQAGABABYwADAAEECQAKAFYBcwADAAEECQALACYByUNvcHlyaWdodCAoQykgMjAxNyBieSBvcmlnaW5hbCBhdXRob3JzIEAgZm9udGVsbG8uY29tZm9udGVsbG9SZWd1bGFyZm9udGVsbG9mb250ZWxsb1ZlcnNpb24gMS4wZm9udGVsbG9HZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAG8AcAB5AHIAaQBnAGgAdAAgACgAQwApACAAMgAwADEANwAgAGIAeQAgAG8AcgBpAGcAaQBuAGEAbAAgAGEAdQB0AGgAbwByAHMAIABAACAAZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AZgBvAG4AdABlAGwAbABvAFIAZQBnAHUAbABhAHIAZgBvAG4AdABlAGwAbABvAGYAbwBuAHQAZQBsAGwAbwBWAGUAcgBzAGkAbwBuACAAMQAuADAAZgBvAG4AdABlAGwAbABvAEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBAgEDAQQAC3RyYXNoLWVtcHR5DHBsdXMtY2lyY2xlZAAAAAEAAf//AA8AAAAAAAAAAAAAAAAAAAAAABgAGAAYABgDUv9qA1L/arAALCCwAFVYRVkgIEu4AA5RS7AGU1pYsDQbsChZYGYgilVYsAIlYbkIAAgAY2MjYhshIbAAWbAAQyNEsgABAENgQi2wASywIGBmLbACLCBkILDAULAEJlqyKAEKQ0VjRVJbWCEjIRuKWCCwUFBYIbBAWRsgsDhQWCGwOFlZILEBCkNFY0VhZLAoUFghsQEKQ0VjRSCwMFBYIbAwWRsgsMBQWCBmIIqKYSCwClBYYBsgsCBQWCGwCmAbILA2UFghsDZgG2BZWVkbsAErWVkjsABQWGVZWS2wAywgRSCwBCVhZCCwBUNQWLAFI0KwBiNCGyEhWbABYC2wBCwjISMhIGSxBWJCILAGI0KxAQpDRWOxAQpDsAFgRWOwAyohILAGQyCKIIqwASuxMAUlsAQmUVhgUBthUllYI1khILBAU1iwASsbIbBAWSOwAFBYZVktsAUssAdDK7IAAgBDYEItsAYssAcjQiMgsAAjQmGwAmJmsAFjsAFgsAUqLbAHLCAgRSCwC0NjuAQAYiCwAFBYsEBgWWawAWNgRLABYC2wCCyyBwsAQ0VCKiGyAAEAQ2BCLbAJLLAAQyNEsgABAENgQi2wCiwgIEUgsAErI7AAQ7AEJWAgRYojYSBkILAgUFghsAAbsDBQWLAgG7BAWVkjsABQWGVZsAMlI2FERLABYC2wCywgIEUgsAErI7AAQ7AEJWAgRYojYSBksCRQWLAAG7BAWSOwAFBYZVmwAyUjYUREsAFgLbAMLCCwACNCsgsKA0VYIRsjIVkqIS2wDSyxAgJFsGRhRC2wDiywAWAgILAMQ0qwAFBYILAMI0JZsA1DSrAAUlggsA0jQlktsA8sILAQYmawAWMguAQAY4ojYbAOQ2AgimAgsA4jQiMtsBAsS1RYsQRkRFkksA1lI3gtsBEsS1FYS1NYsQRkRFkbIVkksBNlI3gtsBIssQAPQ1VYsQ8PQ7ABYUKwDytZsABDsAIlQrEMAiVCsQ0CJUKwARYjILADJVBYsQEAQ2CwBCVCioogiiNhsA4qISOwAWEgiiNhsA4qIRuxAQBDYLACJUKwAiVhsA4qIVmwDENHsA1DR2CwAmIgsABQWLBAYFlmsAFjILALQ2O4BABiILAAUFiwQGBZZrABY2CxAAATI0SwAUOwAD6yAQEBQ2BCLbATLACxAAJFVFiwDyNCIEWwCyNCsAojsAFgQiBgsAFhtRAQAQAOAEJCimCxEgYrsHIrGyJZLbAULLEAEystsBUssQETKy2wFiyxAhMrLbAXLLEDEystsBgssQQTKy2wGSyxBRMrLbAaLLEGEystsBsssQcTKy2wHCyxCBMrLbAdLLEJEystsB4sALANK7EAAkVUWLAPI0IgRbALI0KwCiOwAWBCIGCwAWG1EBABAA4AQkKKYLESBiuwcisbIlktsB8ssQAeKy2wICyxAR4rLbAhLLECHistsCIssQMeKy2wIyyxBB4rLbAkLLEFHistsCUssQYeKy2wJiyxBx4rLbAnLLEIHistsCgssQkeKy2wKSwgPLABYC2wKiwgYLAQYCBDI7ABYEOwAiVhsAFgsCkqIS2wKyywKiuwKiotsCwsICBHICCwC0NjuAQAYiCwAFBYsEBgWWawAWNgI2E4IyCKVVggRyAgsAtDY7gEAGIgsABQWLBAYFlmsAFjYCNhOBshWS2wLSwAsQACRVRYsAEWsCwqsAEVMBsiWS2wLiwAsA0rsQACRVRYsAEWsCwqsAEVMBsiWS2wLywgNbABYC2wMCwAsAFFY7gEAGIgsABQWLBAYFlmsAFjsAErsAtDY7gEAGIgsABQWLBAYFlmsAFjsAErsAAWtAAAAAAARD4jOLEvARUqLbAxLCA8IEcgsAtDY7gEAGIgsABQWLBAYFlmsAFjYLAAQ2E4LbAyLC4XPC2wMywgPCBHILALQ2O4BABiILAAUFiwQGBZZrABY2CwAENhsAFDYzgtsDQssQIAFiUgLiBHsAAjQrACJUmKikcjRyNhIFhiGyFZsAEjQrIzAQEVFCotsDUssAAWsAQlsAQlRyNHI2GwCUMrZYouIyAgPIo4LbA2LLAAFrAEJbAEJSAuRyNHI2EgsAQjQrAJQysgsGBQWCCwQFFYswIgAyAbswImAxpZQkIjILAIQyCKI0cjRyNhI0ZgsARDsAJiILAAUFiwQGBZZrABY2AgsAErIIqKYSCwAkNgZCOwA0NhZFBYsAJDYRuwA0NgWbADJbACYiCwAFBYsEBgWWawAWNhIyAgsAQmI0ZhOBsjsAhDRrACJbAIQ0cjRyNhYCCwBEOwAmIgsABQWLBAYFlmsAFjYCMgsAErI7AEQ2CwASuwBSVhsAUlsAJiILAAUFiwQGBZZrABY7AEJmEgsAQlYGQjsAMlYGRQWCEbIyFZIyAgsAQmI0ZhOFktsDcssAAWICAgsAUmIC5HI0cjYSM8OC2wOCywABYgsAgjQiAgIEYjR7ABKyNhOC2wOSywABawAyWwAiVHI0cjYbAAVFguIDwjIRuwAiWwAiVHI0cjYSCwBSWwBCVHI0cjYbAGJbAFJUmwAiVhuQgACABjYyMgWGIbIVljuAQAYiCwAFBYsEBgWWawAWNgIy4jICA8ijgjIVktsDossAAWILAIQyAuRyNHI2EgYLAgYGawAmIgsABQWLBAYFlmsAFjIyAgPIo4LbA7LCMgLkawAiVGUlggPFkusSsBFCstsDwsIyAuRrACJUZQWCA8WS6xKwEUKy2wPSwjIC5GsAIlRlJYIDxZIyAuRrACJUZQWCA8WS6xKwEUKy2wPiywNSsjIC5GsAIlRlJYIDxZLrErARQrLbA/LLA2K4ogIDywBCNCijgjIC5GsAIlRlJYIDxZLrErARQrsARDLrArKy2wQCywABawBCWwBCYgLkcjRyNhsAlDKyMgPCAuIzixKwEUKy2wQSyxCAQlQrAAFrAEJbAEJSAuRyNHI2EgsAQjQrAJQysgsGBQWCCwQFFYswIgAyAbswImAxpZQkIjIEewBEOwAmIgsABQWLBAYFlmsAFjYCCwASsgiophILACQ2BkI7ADQ2FkUFiwAkNhG7ADQ2BZsAMlsAJiILAAUFiwQGBZZrABY2GwAiVGYTgjIDwjOBshICBGI0ewASsjYTghWbErARQrLbBCLLA1Ky6xKwEUKy2wQyywNishIyAgPLAEI0IjOLErARQrsARDLrArKy2wRCywABUgR7AAI0KyAAEBFRQTLrAxKi2wRSywABUgR7AAI0KyAAEBFRQTLrAxKi2wRiyxAAEUE7AyKi2wRyywNCotsEgssAAWRSMgLiBGiiNhOLErARQrLbBJLLAII0KwSCstsEossgAAQSstsEsssgABQSstsEwssgEAQSstsE0ssgEBQSstsE4ssgAAQistsE8ssgABQistsFAssgEAQistsFEssgEBQistsFIssgAAPistsFMssgABPistsFQssgEAPistsFUssgEBPistsFYssgAAQCstsFcssgABQCstsFgssgEAQCstsFkssgEBQCstsFossgAAQystsFsssgABQystsFwssgEAQystsF0ssgEBQystsF4ssgAAPystsF8ssgABPystsGAssgEAPystsGEssgEBPystsGIssDcrLrErARQrLbBjLLA3K7A7Ky2wZCywNyuwPCstsGUssAAWsDcrsD0rLbBmLLA4Ky6xKwEUKy2wZyywOCuwOystsGgssDgrsDwrLbBpLLA4K7A9Ky2waiywOSsusSsBFCstsGsssDkrsDsrLbBsLLA5K7A8Ky2wbSywOSuwPSstsG4ssDorLrErARQrLbBvLLA6K7A7Ky2wcCywOiuwPCstsHEssDorsD0rLbByLLMJBAIDRVghGyMhWUIrsAhlsAMkUHiwARUwLQBLuADIUlixAQGOWbABuQgACABjcLEABUKyAAEAKrEABUKzCgIBCCqxAAVCsw4AAQgqsQAGQroCwAABAAkqsQAHQroAQAABAAkqsQMARLEkAYhRWLBAiFixA2REsSYBiFFYugiAAAEEQIhjVFixAwBEWVlZWbMMAgEMKrgB/4WwBI2xAgBEAAA=') format('truetype');
|
820 |
-
}
|
821 |
-
#quads-add-new-ad:before {
|
822 |
-
font-family: 'quads';
|
823 |
-
content: '\e801';
|
824 |
-
text-decoration: none;
|
825 |
-
margin-right:5px;
|
826 |
-
color: #383838;
|
827 |
-
}
|
828 |
-
|
829 |
-
#quads-add-new-ad{
|
830 |
-
margin-left: 3px;
|
831 |
-
margin-top: 5px;
|
832 |
-
display: block;
|
833 |
-
margin-bottom: 20px;
|
834 |
-
text-decoration: none;
|
835 |
-
font-size: 14px;
|
836 |
-
font-weight: 600;
|
837 |
-
color: #383838;
|
838 |
-
}
|
839 |
-
|
840 |
-
#quads-submit-button{
|
841 |
-
z-index: 999999;
|
842 |
-
}
|
843 |
-
|
844 |
-
p.submit{
|
845 |
-
float:left;
|
846 |
-
padding-top:0px;
|
847 |
-
padding-bottom:0px;
|
848 |
-
}
|
849 |
-
|
850 |
-
.quads-delete-ad{
|
851 |
-
clear:both;
|
852 |
-
display:block;
|
853 |
-
//background: url('../images/remove-icon.png');
|
854 |
-
//background-size: 20px 20px;
|
855 |
-
//background-repeat: no-repeat;
|
856 |
-
//height: 20px;
|
857 |
-
//padding-left:30px;
|
858 |
-
margin-right:5px;
|
859 |
-
font-size: 14px;
|
860 |
-
font-weight: 600;
|
861 |
-
text-decoration: none;
|
862 |
-
color: #383838;
|
863 |
-
}
|
864 |
-
.quads-delete-ad:before{
|
865 |
-
font-family: 'quads';
|
866 |
-
content: '\e800';
|
867 |
-
margin-right:5px;
|
868 |
-
color: #383838;
|
869 |
-
}
|
870 |
-
|
871 |
-
#backup-settings-textarea{
|
872 |
-
width: 580px;
|
873 |
-
height: 400px;
|
874 |
-
font-family: Menlo, Monaco, monospace;
|
875 |
-
background: none;
|
876 |
-
white-space: normal;
|
877 |
-
overflow: auto;
|
878 |
-
display: block;
|
879 |
-
}
|
880 |
-
|
881 |
-
@media (max-width:506px){
|
882 |
-
.quads-banner-columns {
|
883 |
-
display: block !important;
|
884 |
-
}
|
885 |
-
.quads-banner-sidebar-second{
|
886 |
-
width: 100% !important;
|
887 |
-
}
|
888 |
-
}
|
889 |
-
@media (max-width:780px){
|
890 |
-
.quads-banner-wrapper{
|
891 |
-
margin-right:12px !important;
|
892 |
-
}
|
893 |
-
}
|
894 |
-
|
895 |
-
.quads-banner-wrapper{
|
896 |
-
display: flex;
|
897 |
-
flex-direction: column;
|
898 |
-
clear:both;
|
899 |
-
background: #fff;
|
900 |
-
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
901 |
-
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
902 |
-
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
903 |
-
margin: 5px 5px 2px;
|
904 |
-
margin-right:20px;
|
905 |
-
padding: 1px 12px;
|
906 |
-
}
|
907 |
-
.quads-banner-content {
|
908 |
-
display: flex;
|
909 |
-
flex: 1;
|
910 |
-
color: #000;
|
911 |
-
}
|
912 |
-
.quads-banner-columns{
|
913 |
-
display: flex;
|
914 |
-
flex:1;
|
915 |
-
-ms-flex-align: center;
|
916 |
-
-webkit-align-items: center;
|
917 |
-
-webkit-box-align: center;
|
918 |
-
|
919 |
-
align-items: center;
|
920 |
-
}
|
921 |
-
.quads-banner-main{
|
922 |
-
flex: 1;
|
923 |
-
order: 2;
|
924 |
-
}
|
925 |
-
.quads-banner-sidebar-first{
|
926 |
-
min-width: 160px;
|
927 |
-
width: 13%;
|
928 |
-
order: 1;
|
929 |
-
}
|
930 |
-
.quads-banner-sidebar-second{
|
931 |
-
width: 19%;
|
932 |
-
order: 3;
|
933 |
-
}
|
934 |
-
|
935 |
-
|
936 |
-
.quads-button-primary {
|
937 |
-
display: inline-block;
|
938 |
-
text-decoration: none;
|
939 |
-
font-size: 16px;
|
940 |
-
line-height: 32px;
|
941 |
-
height: 36px;
|
942 |
-
margin: 0;
|
943 |
-
padding: 0 13px 1px;
|
944 |
-
cursor: pointer;
|
945 |
-
border-width: 1px;
|
946 |
-
border-style: solid;
|
947 |
-
-webkit-appearance: none;
|
948 |
-
-webkit-border-radius: 3px;
|
949 |
-
border-radius: 3px;
|
950 |
-
white-space: nowrap;
|
951 |
-
-webkit-box-sizing: border-box;
|
952 |
-
-moz-box-sizing: border-box;
|
953 |
-
box-sizing: border-box;
|
954 |
-
font-weight: bold;
|
955 |
-
}
|
956 |
-
|
957 |
-
.quads-button-primary {
|
958 |
-
background: #0085ba;
|
959 |
-
border-color: #0073aa #006799 #006799;
|
960 |
-
-webkit-box-shadow: 0 1px 0 #006799;
|
961 |
-
box-shadow: 0 1px 0 #006799;
|
962 |
-
color: #fff;
|
963 |
-
text-decoration: none;
|
964 |
-
text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
|
965 |
-
}
|
966 |
-
|
967 |
-
.quads-notice-dismiss {
|
968 |
-
display: inline-block;
|
969 |
-
position: relative;
|
970 |
-
top: 0;
|
971 |
-
right: 1px;
|
972 |
-
border: none;
|
973 |
-
margin: 0;
|
974 |
-
padding: 0px;
|
975 |
-
background: 0 0;
|
976 |
-
color: #72777c;
|
977 |
-
cursor: pointer;
|
978 |
-
}
|
979 |
-
|
980 |
-
.quads-notice-dismiss:before{
|
981 |
-
display: inline-block;
|
982 |
-
background: 0 0;
|
983 |
-
color: #72777c;
|
984 |
-
content: "\f153";
|
985 |
-
font: 400 16px/20px dashicons;
|
986 |
-
speak: none;
|
987 |
-
height: 20px;
|
988 |
-
text-align: center;
|
989 |
-
width: 20px;
|
990 |
-
-webkit-font-smoothing: antialiased;
|
991 |
-
}
|
992 |
-
|
993 |
-
.quads-widget-buttons {
|
994 |
-
float:right;
|
995 |
-
}
|
996 |
-
.quads-widget-buttons a{
|
997 |
-
min-width: 80px;text-align: center;font-weight: 600;
|
998 |
-
}
|
999 |
-
|
1000 |
-
#quads-vi-widget ul {
|
1001 |
-
margin: 0;
|
1002 |
-
margin-left:25px;
|
1003 |
-
padding: 0;
|
1004 |
-
background: #fff;
|
1005 |
-
float: none;
|
1006 |
-
padding-top: 0px;
|
1007 |
-
list-style-type: square;
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
#quads-vi-signup-fullscreen{
|
1011 |
-
display:none;
|
1012 |
-
z-index: 999999;
|
1013 |
-
box-sizing:border-box;
|
1014 |
-
-webkit-box-sizing:border-box;
|
1015 |
-
-moz-box-sizing:border-box;
|
1016 |
-
height: 100%;
|
1017 |
-
width: 100%;
|
1018 |
-
position: absolute;
|
1019 |
-
top: 50%;
|
1020 |
-
left: 50%;
|
1021 |
-
transform: translate(-50%, -50%);
|
1022 |
-
background-color:#f0f0f0;
|
1023 |
-
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
#quads-vi-signup-container {
|
1027 |
-
width:99%;
|
1028 |
-
height:99%;
|
1029 |
-
max-width:868px;
|
1030 |
-
max-height:552px;
|
1031 |
-
}
|
1032 |
-
|
1033 |
-
#quads-vi-close{
|
1034 |
-
cursor:pointer;
|
1035 |
-
position: relative;
|
1036 |
-
display: inline-block;
|
1037 |
-
width: 20px;
|
1038 |
-
height: 20px;
|
1039 |
-
overflow: hidden;
|
1040 |
-
float: right;
|
1041 |
-
margin-right: 20px;
|
1042 |
-
margin-top: 20px;
|
1043 |
-
}
|
1044 |
-
|
1045 |
-
#quads-vi-close::before, #quads-vi-close::after {
|
1046 |
-
content: '';
|
1047 |
-
position: absolute;
|
1048 |
-
height: 2px;
|
1049 |
-
width: 100%;
|
1050 |
-
top: 50%;
|
1051 |
-
left: 0;
|
1052 |
-
margin-top: -1px;
|
1053 |
-
background: #7d7d7d;
|
1054 |
-
}
|
1055 |
-
|
1056 |
-
#quads-vi-close::before {
|
1057 |
-
-webkit-transform: rotate(45deg);
|
1058 |
-
-moz-transform: rotate(45deg);
|
1059 |
-
-ms-transform: rotate(45deg);
|
1060 |
-
-o-transform: rotate(45deg);
|
1061 |
-
transform: rotate(45deg);
|
1062 |
-
}
|
1063 |
-
#quads-vi-close::after {
|
1064 |
-
-webkit-transform: rotate(-45deg);
|
1065 |
-
-moz-transform: rotate(-45deg);
|
1066 |
-
-ms-transform: rotate(-45deg);
|
1067 |
-
-o-transform: rotate(-45deg);
|
1068 |
-
transform: rotate(-45deg);
|
1069 |
-
}
|
1070 |
-
|
1071 |
-
|
1072 |
-
#quads-vi-signup-fullscreen iframe{
|
1073 |
-
width:100%;
|
1074 |
-
height:100%;
|
1075 |
-
z-index: 999999;
|
1076 |
-
display: block;
|
1077 |
-
background:#FFF;
|
1078 |
-
border:none;
|
1079 |
-
}
|
1080 |
-
|
1081 |
-
.quads-spinner {
|
1082 |
-
background: url('/wp-admin/images/spinner.gif') no-repeat;
|
1083 |
-
background-size: 16px 16px;
|
1084 |
-
display: none;
|
1085 |
-
float: left;
|
1086 |
-
opacity: .7;
|
1087 |
-
filter: alpha(opacity=70);
|
1088 |
-
width: 160px;
|
1089 |
-
height: 16px;
|
1090 |
-
margin: 5px 5px 0;
|
1091 |
-
clear:both;
|
1092 |
-
}
|
1093 |
-
|
1094 |
-
#quads-vi-revenue-wrapper{
|
1095 |
-
margin-top: 10px;
|
1096 |
-
min-width: 565px;
|
1097 |
-
min-height: 350px;
|
1098 |
-
}
|
1099 |
-
|
1100 |
-
#quads-vi-revenue-sum {
|
1101 |
-
font-weight: bold;
|
1102 |
-
font-size: 36px;
|
1103 |
-
}
|
1104 |
-
|
1105 |
-
#quads-vi-revenue-sum-wrapper{
|
1106 |
-
margin-top: 20px;
|
1107 |
-
line-height: 26px;
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
#quads-vi-customize-player label {
|
1111 |
-
display:inline-block;
|
1112 |
-
width:170px;
|
1113 |
-
color:black;
|
1114 |
-
font-weight: 500;
|
1115 |
-
}
|
1116 |
-
#quads-vi-shortcodes label {
|
1117 |
-
display:inline-block;
|
1118 |
-
width:170px;
|
1119 |
-
}
|
1120 |
-
#quads-vi-save-settings {
|
1121 |
-
margin-top:20px;
|
1122 |
-
}
|
1123 |
-
|
1124 |
-
#quads-vi-welcome ul {
|
1125 |
-
float:none;
|
1126 |
-
list-style: square;
|
1127 |
-
margin-left:25px;
|
1128 |
-
}
|
1129 |
-
|
1130 |
-
.quads-tooltip {
|
1131 |
-
border-radius: 50%;
|
1132 |
-
border: 2px solid #fff;
|
1133 |
-
background-color: #e7db00;
|
1134 |
-
width: 15px;
|
1135 |
-
height: 15px;
|
1136 |
-
display: inline-block;
|
1137 |
-
position: relative;
|
1138 |
-
top: 4px;
|
1139 |
-
margin-top: -4px;
|
1140 |
-
cursor: pointer;
|
1141 |
-
margin-left: 2px;
|
1142 |
-
}
|
1143 |
-
|
1144 |
-
.quads-tooltip:after {
|
1145 |
-
height: 20px;
|
1146 |
-
font-family: sans-serif;
|
1147 |
-
content: "?";
|
1148 |
-
color: #fff;
|
1149 |
-
font-size: 11px;
|
1150 |
-
font-weight: 700;
|
1151 |
-
left: 4px;
|
1152 |
-
top:-2px;
|
1153 |
-
position: absolute;
|
1154 |
-
}
|
1155 |
-
|
1156 |
-
.quads-tooltip-message {
|
1157 |
-
padding: 10px;
|
1158 |
-
border: 1px solid #FBFBFB;
|
1159 |
-
border-radius: 2px;
|
1160 |
-
background-color: #F8F8F8;
|
1161 |
-
position: absolute;
|
1162 |
-
max-width: 500px;
|
1163 |
-
z-index: 9999;
|
1164 |
-
display: none;
|
1165 |
-
box-shadow: 0 0 5px rgba(0,0,0,.2);
|
1166 |
-
font-weight: 400;
|
1167 |
-
}
|
1168 |
-
|
1169 |
-
#quads-vi-layout label{
|
1170 |
-
width: 100px;
|
1171 |
-
}
|
1172 |
-
|
1173 |
-
#quads_vi_ads-ads-1-align-left-label{
|
1174 |
-
content: url('../images/align_left.png');
|
1175 |
-
}
|
1176 |
-
#quads_vi_ads-ads-1-align-right-label{
|
1177 |
-
content: url('../images/align_right.png');
|
1178 |
-
}
|
1179 |
-
#quads_vi_ads-ads-1-align-middle-label{
|
1180 |
-
content: url('../images/align_middle.png');
|
1181 |
-
}
|
1182 |
-
|
1183 |
-
/*.quads-vi-welcome-white {
|
1184 |
-
text-decoration: underline;
|
1185 |
-
border-bottom:3px solid yellow;
|
1186 |
-
font-weight: bold;
|
1187 |
-
color:black;
|
1188 |
-
}
|
1189 |
-
.quads-vi-welcome-black {
|
1190 |
-
text-decoration: underline;
|
1191 |
-
border-bottom:3px solid yellow;
|
1192 |
-
font-weight: bold;
|
1193 |
-
color:white;
|
1194 |
-
}*/
|
1195 |
-
|
1196 |
-
#quads_vi_automatic_integration select{
|
1197 |
-
min-width: 180px;
|
1198 |
-
}
|
1199 |
-
|
1200 |
-
#quads_vi_ads\[ads\]\[1\]\[marginLeft\],
|
1201 |
-
#quads_vi_ads\[ads\]\[1\]\[marginTop\],
|
1202 |
-
#quads_vi_ads\[ads\]\[1\]\[marginRight\],
|
1203 |
-
#quads_vi_ads\[ads\]\[1\]\[marginBottom\]{
|
1204 |
-
width: 60px;
|
1205 |
}
|
1 |
+
/**
|
2 |
+
* QUADS Admin CSS
|
3 |
+
*
|
4 |
+
* @package QUADS
|
5 |
+
* @subpackage Admin CSS
|
6 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
7 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
8 |
+
*/
|
9 |
+
|
10 |
+
.quads-share-button-container{
|
11 |
+
margin: 5px 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
.quads-share-button-container p{
|
15 |
+
margin:0px 0 10px 0;
|
16 |
+
}
|
17 |
+
|
18 |
+
.quads-share-button {
|
19 |
+
display: inline-block;
|
20 |
+
}
|
21 |
+
|
22 |
+
.quads-share-button a{
|
23 |
+
text-decoration:none;
|
24 |
+
}
|
25 |
+
|
26 |
+
.quads-share-button .quads-share {
|
27 |
+
font-family:sans-serif;
|
28 |
+
font-weight:bold;
|
29 |
+
text-decoration:none;
|
30 |
+
text-align:center;
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
.quads-share-button .quads-share {
|
35 |
+
-webkit-border-radius:2px;
|
36 |
+
-moz-border-radius:2px;
|
37 |
+
border-radius:2px;
|
38 |
+
color:#FFF;
|
39 |
+
display:inline;
|
40 |
+
font-size:16px;
|
41 |
+
width:40px;
|
42 |
+
padding:4px 8px;
|
43 |
+
}
|
44 |
+
|
45 |
+
.quads-share-button-twitter .quads-share {
|
46 |
+
background-color:#00ABF0;
|
47 |
+
}
|
48 |
+
|
49 |
+
.quads-share-button-facebook .quads-share {
|
50 |
+
background-color:#3b5998;
|
51 |
+
}
|
52 |
+
|
53 |
+
.quads-share-button-googleplus .quads-share {
|
54 |
+
background-color:#F53424;
|
55 |
+
}
|
56 |
+
|
57 |
+
.quads-share-button-twitter .share:active,.quads-share-button-facebook .share:active,.quads-share-button-googleplus .share:active {
|
58 |
+
background-color:#353535;
|
59 |
+
}
|
60 |
+
|
61 |
+
/* Responsive */
|
62 |
+
@media (max-width: 925px) {
|
63 |
+
.quads-share-button .quads-share{
|
64 |
+
font-size:15px;
|
65 |
+
padding: 8px 16px; /* Double the padding */
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
69 |
+
|
70 |
+
|
71 |
+
/* Input forms */
|
72 |
+
/*.quads-textarea{
|
73 |
+
font-size:11px;
|
74 |
+
}*/
|
75 |
+
.quads-richeditor{
|
76 |
+
font-size:11px;
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
/* =Add Ons Styles
|
82 |
+
-------------------------------------------------------------- */
|
83 |
+
#quads-add-ons h2 { margin: 0 0 15px; }
|
84 |
+
#quads-add-ons .quadsshare-addons { float: left; margin: 0 15px 15px 0; background: #f0f0f0; border: 1px solid #ccc; width: 320px; padding: 8px; height: 315px; position: relative; }
|
85 |
+
#quads-add-ons .quadsshare-addons h3 { margin: 0 0 8px; font-size: 13px; }
|
86 |
+
#quads-add-ons .quadsshare-addons .button-secondary { position: absolute; bottom: 8px; left: 8px; }
|
87 |
+
/*#quads-add-ons .quadsshare-addons { clear:both; width:100%; }*/
|
88 |
+
#quads-add-ons .quadsshare-addons .third-party { display: none; }
|
89 |
+
|
90 |
+
|
91 |
+
/* System Info page styles
|
92 |
+
-------------------------------------------------------------- */
|
93 |
+
#system-info-textarea { width: 580px; height: 400px; font-family: Menlo, Monaco, monospace; background: none; white-space: pre; overflow: auto; display: block; }
|
94 |
+
|
95 |
+
|
96 |
+
/* General styles
|
97 |
+
-------------------------------------------------------------- */
|
98 |
+
.quads-select-chosen { width: 300px; }
|
99 |
+
|
100 |
+
input.large-text, textarea.large-text {
|
101 |
+
max-width: 600px;
|
102 |
+
}
|
103 |
+
input.medium-text, textarea.medium-text {
|
104 |
+
min-width: 190px;
|
105 |
+
}
|
106 |
+
|
107 |
+
/* CSS for Tabs */
|
108 |
+
|
109 |
+
#quads_tab_container ul {
|
110 |
+
/*height: 200px;*/
|
111 |
+
list-style: none;
|
112 |
+
margin: 0;
|
113 |
+
padding: 0;
|
114 |
+
background: #fff;
|
115 |
+
float: left;
|
116 |
+
padding-top: 0px;
|
117 |
+
/*list-style-type: square;*/
|
118 |
+
}
|
119 |
+
|
120 |
+
#quads_tab_container ul li:first-child.selected-tab {
|
121 |
+
border-top: none;
|
122 |
+
}
|
123 |
+
|
124 |
+
#quads_tab_container ul li a.selected-tab {
|
125 |
+
font-weight: bold;
|
126 |
+
text-decoration: none;
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
+
#quads_tab_container .quads-row{
|
132 |
+
padding-top:12px;
|
133 |
+
padding-bottom:12px;
|
134 |
+
}
|
135 |
+
|
136 |
+
|
137 |
+
#quads_tab_container .quads-row label strong, #tab_container .quads-row strong {
|
138 |
+
font-weight: bold;
|
139 |
+
}
|
140 |
+
|
141 |
+
.quads-tabs a {
|
142 |
+
padding:5px;
|
143 |
+
color:#a1a1a1;
|
144 |
+
text-transform: uppercase;
|
145 |
+
}
|
146 |
+
.quads-tabs a strong {
|
147 |
+
font-weight: 700;
|
148 |
+
}
|
149 |
+
|
150 |
+
li.quads-tabs {
|
151 |
+
float:left;
|
152 |
+
margin-left:0px;
|
153 |
+
background-color: #e5e5e5;
|
154 |
+
}
|
155 |
+
|
156 |
+
/*@media only screen and (min-width:400px) {
|
157 |
+
li.quads-tabs {
|
158 |
+
float:left;
|
159 |
+
margin-left:14px;
|
160 |
+
}
|
161 |
+
}*/
|
162 |
+
|
163 |
+
#quads_tab_container > ul > li.quads-tabs.active {
|
164 |
+
background-color:#fff;
|
165 |
+
}
|
166 |
+
#quads_tab_container > ul > li.quads-tabs.active a {
|
167 |
+
color: #83c11f;
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
|
172 |
+
/* Layout of admin table and rows
|
173 |
+
*/
|
174 |
+
|
175 |
+
|
176 |
+
#quads_tab_container .quads-panel-container {
|
177 |
+
background: #FFF;
|
178 |
+
padding:20px;
|
179 |
+
overflow:auto;
|
180 |
+
text-align:left;
|
181 |
+
margin-bottom:10px;
|
182 |
+
max-width: 640px;
|
183 |
+
float: left;
|
184 |
+
clear:both;
|
185 |
+
}
|
186 |
+
|
187 |
+
.form-table{
|
188 |
+
margin-top:-20px;
|
189 |
+
}
|
190 |
+
|
191 |
+
#quads_tab_container .form-table th {
|
192 |
+
vertical-align: top;
|
193 |
+
text-align: left;
|
194 |
+
padding: 20px 10px 20px 0;
|
195 |
+
width: 200px;
|
196 |
+
line-height: 1.3;
|
197 |
+
font-weight: bold;
|
198 |
+
font-size: 14px;
|
199 |
+
color:#484848;
|
200 |
+
width: 30%;
|
201 |
+
}
|
202 |
+
|
203 |
+
/*#quads_tab_container .form-table tr{
|
204 |
+
padding:0px;
|
205 |
+
}*/
|
206 |
+
|
207 |
+
#quads_tab_container .form-table tr {
|
208 |
+
border-bottom: 1px solid #E7E7E7;
|
209 |
+
}
|
210 |
+
|
211 |
+
#quads_tab_container span.description{
|
212 |
+
display: block;
|
213 |
+
font-weight: 400;
|
214 |
+
font-style: normal;
|
215 |
+
font-size: 13px;
|
216 |
+
margin-top: 7px;
|
217 |
+
color:#484848;
|
218 |
+
}
|
219 |
+
|
220 |
+
#quads_tab_container .col-title{
|
221 |
+
font-size: 18px;
|
222 |
+
color:#484848;
|
223 |
+
}
|
224 |
+
|
225 |
+
@media only screen and (max-width:680px) {
|
226 |
+
#quads_tab_container ul {
|
227 |
+
float:none;
|
228 |
+
background: #fff;
|
229 |
+
}
|
230 |
+
#quads_tab_container .form-table tr > th {
|
231 |
+
width:100%;
|
232 |
+
}
|
233 |
+
#quads_tab_container span.description{
|
234 |
+
font-size: 14px;
|
235 |
+
}
|
236 |
+
#quads_tab_container .form-table tr > th, #tab_container .form-table tr > td {
|
237 |
+
padding:10px;
|
238 |
+
}
|
239 |
+
#quads_tab_container .quads-tabs a{
|
240 |
+
text-align: left;
|
241 |
+
}
|
242 |
+
#quads_tab_container li.quads-tabs {
|
243 |
+
float:none;
|
244 |
+
margin-left:0px;
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
+
#quads_tab_container ul li.quads-tabs {
|
249 |
+
margin-bottom:0px;
|
250 |
+
}
|
251 |
+
|
252 |
+
#quads_tab_container ul li.quads-tabs a {
|
253 |
+
display: block;
|
254 |
+
padding:10px 10px 10px 10px;
|
255 |
+
text-decoration: none;
|
256 |
+
font-weight: bold;
|
257 |
+
}
|
258 |
+
#quads_tab_container ul li.quads-tabs a:hover {
|
259 |
+
color:#383838;
|
260 |
+
}
|
261 |
+
#quads_tab_container ul li.quads-tabs a.active {
|
262 |
+
text-decoration: underline;
|
263 |
+
}
|
264 |
+
|
265 |
+
|
266 |
+
#quads_tab_container table tbody tr:nth-child(1) > th > div {
|
267 |
+
font-size: 20px;
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
|
272 |
+
/* End layout of admin table and rows
|
273 |
+
*/
|
274 |
+
#quadstabcontainer > .quadstabs {
|
275 |
+
background-color: #ffffff;
|
276 |
+
}
|
277 |
+
|
278 |
+
#quadstabcontainer ul .active {
|
279 |
+
background-color: #00adef;
|
280 |
+
color: white;
|
281 |
+
border-bottom-color: #0098D2;
|
282 |
+
}
|
283 |
+
|
284 |
+
#quadstabcontainer ul .active:hover {
|
285 |
+
background-color: #00A4E2;
|
286 |
+
color: white;
|
287 |
+
border-bottom-color: #0098D2;
|
288 |
+
}
|
289 |
+
|
290 |
+
#quadstabcontainer ul li a {
|
291 |
+
padding: 10px 14px 10px 14px;
|
292 |
+
background-color: #f3f3f3
|
293 |
+
|
294 |
+
}
|
295 |
+
|
296 |
+
#quadstabcontainer .quadstab-container {
|
297 |
+
border: 0px solid #ececec;
|
298 |
+
}
|
299 |
+
|
300 |
+
.quads-quote-docs {
|
301 |
+
font-family:Courier New,Courier,Fixed;
|
302 |
+
color:#050;
|
303 |
+
}
|
304 |
+
|
305 |
+
.quads-desc{
|
306 |
+
display:block;
|
307 |
+
font-style:italic;
|
308 |
+
padding-top:10px;
|
309 |
+
}
|
310 |
+
|
311 |
+
.quads-postbox {
|
312 |
+
padding:10px;
|
313 |
+
position: relative;
|
314 |
+
min-width: 255px;
|
315 |
+
border: 1px solid #e5e5e5;
|
316 |
+
-webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
317 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.04);
|
318 |
+
background: #fff;
|
319 |
+
margin-bottom:20px;
|
320 |
+
}
|
321 |
+
|
322 |
+
.nav-tab-active{
|
323 |
+
background-color: white;
|
324 |
+
border-bottom:0px;
|
325 |
+
}
|
326 |
+
|
327 |
+
/*.wp-admin .quads-align-input{
|
328 |
+
padding: 0px;
|
329 |
+
line-height: 23px;
|
330 |
+
height: 24px;
|
331 |
+
vertical-align: top;
|
332 |
+
}*/
|
333 |
+
|
334 |
+
|
335 |
+
#quads-add-ons {
|
336 |
+
padding: 20px;
|
337 |
+
}
|
338 |
+
.quads-toggle {
|
339 |
+
position: absolute;
|
340 |
+
right: 0px;
|
341 |
+
top: 0px;
|
342 |
+
}
|
343 |
+
|
344 |
+
.quads-box-close .quads-close-open-icon {
|
345 |
+
background-position: 0px -38px;
|
346 |
+
}
|
347 |
+
|
348 |
+
.quads-close-open-icon {
|
349 |
+
width: 38px;
|
350 |
+
height: 38px;
|
351 |
+
background: #f4f4f4 url("../images/arrow-close.png") repeat-y;
|
352 |
+
background-position: 0px 0px;
|
353 |
+
}
|
354 |
+
.quads-ad-toggle-header {
|
355 |
+
position: relative;
|
356 |
+
background-color: #f4f4f4;
|
357 |
+
margin-bottom: 2px;
|
358 |
+
padding: 10px 10px 10px 15px;
|
359 |
+
-moz-user-select: -moz-none;
|
360 |
+
-khtml-user-select: none;
|
361 |
+
-webkit-user-select: none;
|
362 |
+
-o-user-select: none;
|
363 |
+
user-select: none;
|
364 |
+
cursor: pointer !important;
|
365 |
+
min-height: 20px;
|
366 |
+
}
|
367 |
+
|
368 |
+
.quads-ad-toggle-container{
|
369 |
+
padding:20px;
|
370 |
+
background-color: #f4f4f4;
|
371 |
+
}
|
372 |
+
|
373 |
+
.quads-toogle-title{
|
374 |
+
font-size:16px;
|
375 |
+
font-weight: bold;
|
376 |
+
}
|
377 |
+
|
378 |
+
.quads-advanced-description label{
|
379 |
+
float:left;
|
380 |
+
width:215px;
|
381 |
+
font-size: 12px;
|
382 |
+
font-weight: 600;
|
383 |
+
text-transform: uppercase;
|
384 |
+
}
|
385 |
+
|
386 |
+
.quads-advanced-ad-box{
|
387 |
+
clear: both;
|
388 |
+
margin-top:20px;
|
389 |
+
margin-bottom:20px;
|
390 |
+
}
|
391 |
+
|
392 |
+
|
393 |
+
|
394 |
+
.adsense-size-title {
|
395 |
+
margin-right: 0px;
|
396 |
+
float: left;
|
397 |
+
line-height: 32px;
|
398 |
+
margin-left: 14px;
|
399 |
+
min-width: 100px;
|
400 |
+
font-weight: 600;
|
401 |
+
font-size: 12px;
|
402 |
+
text-transform: uppercase;
|
403 |
+
}
|
404 |
+
|
405 |
+
.quads-select-style-overwrite {
|
406 |
+
border: 1px solid #e6e6e6;
|
407 |
+
width: 150px;
|
408 |
+
overflow: hidden;
|
409 |
+
background: #ffffff url("../images/box_arrow.png") repeat-y 120px 0px;
|
410 |
+
margin: 0px 0px 5px 0px;
|
411 |
+
}
|
412 |
+
.quads-select-style-overwrite select {
|
413 |
+
width:150px;
|
414 |
+
}
|
415 |
+
|
416 |
+
/*.quads-select{
|
417 |
+
max-width:100px;
|
418 |
+
}*/
|
419 |
+
|
420 |
+
.quads-size-input {
|
421 |
+
position: relative;
|
422 |
+
top: -1px;
|
423 |
+
width: 110%;
|
424 |
+
border: none;
|
425 |
+
box-shadow: none;
|
426 |
+
background: transparent;
|
427 |
+
background-image: none;
|
428 |
+
-webkit-appearance: none;
|
429 |
+
font-family: 'Open Sans', arial, sans-serif;
|
430 |
+
color: #555555;
|
431 |
+
font-size: 12px;
|
432 |
+
/*margin-left:5px;*/
|
433 |
+
}
|
434 |
+
|
435 |
+
.quads-pro-overlay{
|
436 |
+
height: 200px;
|
437 |
+
}
|
438 |
+
|
439 |
+
|
440 |
+
|
441 |
+
.quads-license-error-notice,
|
442 |
+
.quads-license-expires-soon-notice {
|
443 |
+
background-color: #fff;
|
444 |
+
padding: 10px;
|
445 |
+
border-left: 4px solid #7ad03a;
|
446 |
+
overflow: auto;
|
447 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
448 |
+
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
449 |
+
border: 1px solid #ECECEC;
|
450 |
+
border-radius: 3px;
|
451 |
+
}
|
452 |
+
.quads-license-error-notice a {
|
453 |
+
color: #0097df;
|
454 |
+
text-decoration: underline;
|
455 |
+
}
|
456 |
+
.quads-license-error-notice { border-left: 4px solid #dd3d36; }
|
457 |
+
.quads-license-lifetime-notice,
|
458 |
+
.quads-license-expiration-date-notice,
|
459 |
+
.quads-license-null { padding: 0 0 0 0px; }
|
460 |
+
.quads-license-lifetime-notice .quads-license-data p,
|
461 |
+
.quads-license-expiration-date-notice .quads-license-data p { color: #666; font-size: 14px; font-style: italic; margin: 4px 0 0; }
|
462 |
+
|
463 |
+
#quads_settingslicenses_header-nav{
|
464 |
+
display:none;
|
465 |
+
}
|
466 |
+
|
467 |
+
#quads_settingslicenses_header{
|
468 |
+
max-width:640px;
|
469 |
+
}
|
470 |
+
|
471 |
+
#quads_settingslicenses_header .quads-row.th{
|
472 |
+
min-width:250px;
|
473 |
+
}
|
474 |
+
|
475 |
+
.quads-notice{
|
476 |
+
background: #fff;
|
477 |
+
border-left: 4px solid #46b450;
|
478 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
479 |
+
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
|
480 |
+
margin: 5px 15px 2px;
|
481 |
+
padding: 1px 12px;
|
482 |
+
}
|
483 |
+
|
484 |
+
.quads_admin h2.nav-tab-wrapper{
|
485 |
+
border:0px;
|
486 |
+
}
|
487 |
+
|
488 |
+
.quads_admin .nav-tab{
|
489 |
+
border:0px;
|
490 |
+
text-transform: uppercase;
|
491 |
+
color: #a1a1a1;
|
492 |
+
font-weight: 700;
|
493 |
+
}
|
494 |
+
|
495 |
+
.quads-h1 {
|
496 |
+
font-size: 2.75em;
|
497 |
+
margin-bottom: 1.35rem;
|
498 |
+
font-size: 2.5em;
|
499 |
+
line-height: 3.68rem;
|
500 |
+
letter-spacing: normal;
|
501 |
+
}
|
502 |
+
|
503 |
+
.quads-h2 {
|
504 |
+
margin-top:0px;
|
505 |
+
margin-bottom: 1.2rem;
|
506 |
+
font-size: 30px;
|
507 |
+
line-height: 2.5rem;
|
508 |
+
}
|
509 |
+
|
510 |
+
.quads-heading-pro{
|
511 |
+
color: #83c11f;
|
512 |
+
font-weight: bold;
|
513 |
+
}
|
514 |
+
|
515 |
+
.quads-button.green {
|
516 |
+
display:inline-block;
|
517 |
+
background-color: #83c11f;
|
518 |
+
padding:10px;
|
519 |
+
min-width: 170px;
|
520 |
+
color: white;
|
521 |
+
font-size: 16px;
|
522 |
+
text-decoration: none;
|
523 |
+
text-align:center;
|
524 |
+
margin-top:20px;
|
525 |
+
}
|
526 |
+
|
527 |
+
#quads-add-ons .quads-footer {
|
528 |
+
clear:both;
|
529 |
+
margin-top:20px;
|
530 |
+
font-style: italic;
|
531 |
+
}
|
532 |
+
|
533 |
+
#quads-footer {
|
534 |
+
clear:both;
|
535 |
+
}
|
536 |
+
|
537 |
+
#quads-add-ons li {
|
538 |
+
font-size:18px;
|
539 |
+
line-height: 29px;
|
540 |
+
position: relative;
|
541 |
+
padding-left: 23px;
|
542 |
+
list-style: none!important;
|
543 |
+
}
|
544 |
+
|
545 |
+
#quads-add-ons li:before {
|
546 |
+
width: 1em;
|
547 |
+
height: 100%;
|
548 |
+
background: url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;
|
549 |
+
background-size: contain;
|
550 |
+
content: "";
|
551 |
+
position: absolute;
|
552 |
+
top: 0;
|
553 |
+
left: 0;
|
554 |
+
color: #77b227;
|
555 |
+
}
|
556 |
+
|
557 |
+
.adsense_admin_header {
|
558 |
+
font-size: 14px;
|
559 |
+
font-weight: 500;
|
560 |
+
}
|
561 |
+
|
562 |
+
#quads-adsense-bg-div{
|
563 |
+
position: fixed;
|
564 |
+
top: 0;
|
565 |
+
left: 0;
|
566 |
+
width: 100%;
|
567 |
+
height: 100%;
|
568 |
+
background-color: rgba(0, 0, 0, 0.65);
|
569 |
+
z-index: 250000;
|
570 |
+
}
|
571 |
+
|
572 |
+
#quads-adsense-container {
|
573 |
+
text-align: center;
|
574 |
+
width: 480px;
|
575 |
+
margin: 85px auto 0 auto;
|
576 |
+
background-color: #fff;
|
577 |
+
padding: 2%;
|
578 |
+
border-radius: 2px;
|
579 |
+
}
|
580 |
+
#quads-adsense-container h3{
|
581 |
+
margin-top:0px;
|
582 |
+
}
|
583 |
+
|
584 |
+
#quads-adsense-container textarea{
|
585 |
+
width: 100%;
|
586 |
+
}
|
587 |
+
|
588 |
+
|
589 |
+
.quads-ad-toggle-container textarea{
|
590 |
+
width: 100%;
|
591 |
+
}
|
592 |
+
|
593 |
+
.quads-ad-toggle-container input{
|
594 |
+
margin-top: 7px;
|
595 |
+
margin-bottom:10px;
|
596 |
+
}
|
597 |
+
|
598 |
+
.quads-adsense-code label, input{
|
599 |
+
margin-right:2px;
|
600 |
+
}
|
601 |
+
|
602 |
+
#quads_settings\5b ad2\5d \5b g_data_ad_client\5d {
|
603 |
+
width:200px;
|
604 |
+
}
|
605 |
+
|
606 |
+
.quads-ad-toggle-container label {
|
607 |
+
display: inline-block;
|
608 |
+
margin-right:2px;
|
609 |
+
margin-top:-3px;
|
610 |
+
}
|
611 |
+
|
612 |
+
/*.quads-adsense-code > label:nth-child(1){
|
613 |
+
min-width: 74px;
|
614 |
+
}*/
|
615 |
+
|
616 |
+
.quads_adsense_code .quads-add-adsense {
|
617 |
+
margin:20px;
|
618 |
+
margin-left:0px;
|
619 |
+
margin-right:5px;
|
620 |
+
}
|
621 |
+
|
622 |
+
.quads-label-left {
|
623 |
+
min-width: 71px;
|
624 |
+
}
|
625 |
+
|
626 |
+
#quads-label-Type {
|
627 |
+
min-width: 67px;
|
628 |
+
}
|
629 |
+
|
630 |
+
.quads-medium-size{
|
631 |
+
width: 110px;
|
632 |
+
}
|
633 |
+
|
634 |
+
#quads-msg{
|
635 |
+
display:none;
|
636 |
+
margin: 5px;
|
637 |
+
background-color: #c55c5c;
|
638 |
+
color: white;
|
639 |
+
}
|
640 |
+
|
641 |
+
.quads-success-modal {
|
642 |
+
display: block;
|
643 |
+
position: fixed;
|
644 |
+
top: 45%;
|
645 |
+
left: 25%;
|
646 |
+
width: 200px;
|
647 |
+
height: auto;
|
648 |
+
padding: 5px 20px;
|
649 |
+
z-index:1002;
|
650 |
+
overflow: auto;
|
651 |
+
}
|
652 |
+
.quads-loader {
|
653 |
+
display: block;
|
654 |
+
position: fixed;
|
655 |
+
top: 45%;
|
656 |
+
left: 25%;
|
657 |
+
width: 200px;
|
658 |
+
height: auto;
|
659 |
+
padding: 5px 20px;
|
660 |
+
z-index:1002;
|
661 |
+
overflow: auto;
|
662 |
+
}
|
663 |
+
|
664 |
+
.quads-form-table{
|
665 |
+
width: 100%;
|
666 |
+
}
|
667 |
+
|
668 |
+
.quads-left-box{
|
669 |
+
width:45%;
|
670 |
+
min-height:100px;
|
671 |
+
float:left;
|
672 |
+
line-height: 35px;
|
673 |
+
min-width: 300px;
|
674 |
+
}
|
675 |
+
|
676 |
+
@media screen and (max-width:700px){
|
677 |
+
.adsense-size-title {
|
678 |
+
margin-left: 0px;
|
679 |
+
}
|
680 |
+
.quads-left-box{
|
681 |
+
width:45%;
|
682 |
+
min-height:100px;
|
683 |
+
float:none;
|
684 |
+
line-height: 35px;
|
685 |
+
min-width: 300px;
|
686 |
+
}
|
687 |
+
|
688 |
+
.quads-style img{
|
689 |
+
max-width: 50px;
|
690 |
+
}
|
691 |
+
|
692 |
+
}
|
693 |
+
|
694 |
+
.adsense_admin_header ul li{
|
695 |
+
margin-top:2px;
|
696 |
+
margin-left:20px;
|
697 |
+
list-style-type: square;
|
698 |
+
}
|
699 |
+
|
700 |
+
.quads-helper {
|
701 |
+
border-radius: 50%;
|
702 |
+
border: 2px solid #fff;
|
703 |
+
background-color: #83c11f;
|
704 |
+
width: 15px;
|
705 |
+
height: 15px;
|
706 |
+
display: inline-block;
|
707 |
+
position: relative;
|
708 |
+
top: 4px;
|
709 |
+
margin-top: -4px;
|
710 |
+
cursor: pointer;
|
711 |
+
margin-left: 2px;
|
712 |
+
}
|
713 |
+
|
714 |
+
.quads-helper:after {
|
715 |
+
height: 20px;
|
716 |
+
font-family: sans-serif;
|
717 |
+
content: "?";
|
718 |
+
color: #fff;
|
719 |
+
font-size: 11px;
|
720 |
+
font-weight: bold;
|
721 |
+
left: 4px;
|
722 |
+
position: absolute;
|
723 |
+
margin-top: -10px;
|
724 |
+
}
|
725 |
+
|
726 |
+
.quads-general-helper:after {
|
727 |
+
height: 20px;
|
728 |
+
font-family: sans-serif;
|
729 |
+
content: "?";
|
730 |
+
color: #fff;
|
731 |
+
font-size: 11px;
|
732 |
+
font-weight: bold;
|
733 |
+
left: 4px;
|
734 |
+
position: absolute;
|
735 |
+
margin-top: -2px;
|
736 |
+
}
|
737 |
+
.quads-general-helper {
|
738 |
+
border-radius: 50%;
|
739 |
+
border: 2px solid #fff;
|
740 |
+
background-color: #83c11f;
|
741 |
+
width: 15px;
|
742 |
+
height: 15px;
|
743 |
+
display: inline-block;
|
744 |
+
position: relative;
|
745 |
+
top: 4px;
|
746 |
+
margin-top: -4px;
|
747 |
+
cursor: pointer;
|
748 |
+
margin-left: 2px;
|
749 |
+
}
|
750 |
+
|
751 |
+
.quads-message{
|
752 |
+
display:block;
|
753 |
+
padding: 10px;
|
754 |
+
border: 1px solid #FBFBFB;
|
755 |
+
border-radius: 2px;
|
756 |
+
background-color: #F8F8F8;
|
757 |
+
position: absolute;
|
758 |
+
max-width: 500px;
|
759 |
+
z-index: 9999;
|
760 |
+
display: none;
|
761 |
+
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
|
762 |
+
font-weight: normal;
|
763 |
+
line-height: 20px;
|
764 |
+
text-transform: none;
|
765 |
+
font-size: 14px;
|
766 |
+
}
|
767 |
+
|
768 |
+
#quads-pro-hover{
|
769 |
+
background-color: #83c11f;
|
770 |
+
padding:20px;
|
771 |
+
min-width: 150px;
|
772 |
+
color:white;
|
773 |
+
display: block;
|
774 |
+
position: relative;
|
775 |
+
margin-top: -100px;
|
776 |
+
margin-left: 50%;
|
777 |
+
}
|
778 |
+
|
779 |
+
#quads-pro-hover-background{
|
780 |
+
width: 100%; height:100%;background:rgba(0,0,0,0.6);
|
781 |
+
}
|
782 |
+
|
783 |
+
#quads-open-toggle{
|
784 |
+
clear: both;
|
785 |
+
float:left;
|
786 |
+
margin-top:10px;
|
787 |
+
}
|
788 |
+
|
789 |
+
#quads_settingsadsense_header input[type="number"].small-text{
|
790 |
+
width: 55px;
|
791 |
+
}
|
792 |
+
|
793 |
+
.quads_adsense_code input.quads-bggrey {
|
794 |
+
background-color: whitesmoke;
|
795 |
+
color: #939393;
|
796 |
+
}
|
797 |
+
|
798 |
+
.quads-amp-code{
|
799 |
+
color: #939393;
|
800 |
+
height: 130px;
|
801 |
+
}
|
802 |
+
|
803 |
+
.quads-chosen-select .chosen-choices li.search-field input{
|
804 |
+
min-height: 25px;
|
805 |
+
}
|
806 |
+
|
807 |
+
|
808 |
+
#quads-validate{
|
809 |
+
display: block;
|
810 |
+
margin-left: 2px;
|
811 |
+
margin-bottom: 20px;
|
812 |
+
font-weight: bold;
|
813 |
+
clear: both;
|
814 |
+
}
|
815 |
+
|
816 |
+
@font-face {
|
817 |
+
font-family: 'quads';
|
818 |
+
src: url('data:application/octet-stream;base64,d09GRgABAAAAAAxYAA8AAAAAFUQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABWAAAADsAAABUIIslek9TLzIAAAGUAAAAQwAAAFY+IEkBY21hcAAAAdgAAABQAAABfohD7KljdnQgAAACKAAAABMAAAAgBtX/BGZwZ20AAAI8AAAFkAAAC3CKkZBZZ2FzcAAAB8wAAAAIAAAACAAAABBnbHlmAAAH1AAAAdIAAAJWlz85pGhlYWQAAAmoAAAAMwAAADYNxZM1aGhlYQAACdwAAAAfAAAAJAc6A1BobXR4AAAJ/AAAAAwAAAAMClL//WxvY2EAAAoIAAAACAAAAAgAxAErbWF4cAAAChAAAAAgAAAAIAESDApuYW1lAAAKMAAAAXcAAALNzJ0dH3Bvc3QAAAuoAAAAMwAAAESFVFBUcHJlcAAAC9wAAAB6AAAAhuVBK7x4nGNgZGBg4GIwYLBjYHJx8wlh4MtJLMljkGJgYYAAkDwymzEnMz2RgQPGA8qxgGkOIGaDiAIAJjsFSAB4nGNgZC5knMDAysDAVMW0h4GBoQdCMz5gMGRkAooysDIzYAUBaa4pDA4vGF4wMgf9z2KIYg5imAYUZgTJAQDj3AufAHic7ZCxDYAwDATPiaFAjEFBwTBU7F+yRfK2GYOX7qR/uTKwAF1cwsEejMit1XLvbLk7R9547K+NIRNW93STVv7s6fNrLf5U1OcK2gTMuAtdeJxjYEADEhDIHPQ/C4QBEmwD3QB4nK1WaXfTRhQdeUmchCwlCy1qYcTEabBGJmzBgAlBsmMgXZytlaCLFDvpvvGJ3+Bf82Tac+g3flrvGy8kkLTncJqTo3fnzdXM22USWpLYC+uRlJsvxdTWJo3sPAnphk3LUXwoO3shZYrJ3wVREK2W2rcdh0REIlC1rrBEEPseWZpkfOhRRsu2pFdNyi096S5b40G9Vd9+GjrKsTuhpGYzdGg9siVVGFWiSKY9UtKmZaj6K0krvL/CzFfNUMKITiJpvBnG0EjeG2e0ymg1tuMoimyy3ChSJJrhQRR5lNUS5+SKCQzKB82Q8sqnEeXD/Iis2KOcVrBLttP8vi95p3c5P7Ffb1G25EAfyI7s4Ox0JV+EW1th3LST7ShUEXbXd0Js2exU/2aP8ppGA7crMr3QjGCpfIUQKz+hzP4hWS2cT/mSR6NaspETQetlTuxLPoHW44gpcc0YWdDd0QkR1P2SMwz2mD4e/PHeKZYLEwJ4HMt6RyWcCBMpYXM0SdowcmAlZYsqqfWumDjldVrEW8J+7drRl85o41B3YjxbDx1bOVHJ8WhSp5lMndpJzaMpDaKUdCZ4zK8DKD+iSV5tYzWJlUfTOGbGhEQiAi3cS1NBLDuxpCkEzaMZvbkbprl2LVqkyQP13KP39OZWuLnTU9oO9LNGf1anYjrYC9PpaeQv8Wna5SJF6frpGX5M4kHWAjKRLTbDlIMHb/0O0svXlhyF1wbY7u3zK6h91kTwpAH7G9AeT9UpCUyFmFWIVkBirWtZlsnVrBapyNR3Q5pWvqzTBIpyHBfHvoxx/V8zM5aYEr7fidOzIy49c+1LCNMcfJt1PZrXqcVyAXFmeU6nWZbv6zTH8gOd5lme1+kIS1unoyw/1GmB5Uc6HWN5QQuadN/BkIsw5AIOkDCEpQNDWF6CISwVDGG5CENYFmEIyyUYwvJjGMJyGYawvKxl1dRTSePamVgGbEJgYo4eucxF5WoquVRCu2hUakOeEm6VVBTPqn9loF488oY5sBZIl8iaXzHOlY9G5fjWFS1vGjtXwLHqbx+O9jnxUtaLhT8F/9XWVCW9Ys3Dk6vwG4aebCeqNql4dE2Xz1U9uv5fVFRYC/QbSIVYKMqybHBnIoSPOp2GaqCVQ8xszDy063XLmp/D/TcxQhZQ/fg3FBoL3INOWUlZ7eCs1dfbstw7g3I4EyxJMTfz+lb4IiOz0n6RWcqej3wecAWMSmXYagOtFbzZJzEPmd4kzwRxW1E2SNrYzgSJDRzzgHnznQQmYeqqDeRO4YYN+AVhbsF5J1yieqMsh+5F7PMopPxbp+JE9qhojMCz2Rthr+9Cym9xDCQ0+aV+DFQVoakYNRXQNFJuqAZfxtm6bULGDvQjKnbDsqziw8cW95WSbRmEfKSI1aOjn9Zeok6q3H5mFJfvnb4FwSA1MX9733RxkMq7WskyR20DU7calVPXmkPjVYfq5lH1vePsEzlrmm66Jx56X9Oq28HFXCyw9m0O0lImF9T1YYUNosvFpVDqZTRJ77gHGBYY0O9Qio3/q/rYfJ4rVYXRcSTfTtS30edgDPwP2H9H9QPQ92Pocg0uz/eaE59u9OFsma6iF+un6Dcwa625WboG3NB0A+IhR62OuMoNfKcGcXqkuRzpIeBj3RXiAcAmgMXgE921jOZTAKP5jDk+wOfMYdBkDoMt5jDYZs4awA5zGOwyh8Eecxh8wZx1gC+ZwyBkDoOIOQyeMCcAeMocBl8xh8HXzGHwDXPuA3zLHAYxcxgkzGGwr+nWMMwtXtBdoLZBVaADU09Y3MPiUFNlyP6OF4b9vUHM/sEgpv6o6faQ+hMvDPVng5j6i0FM/VXTnSH1N14Y6u8GMfUPg5j6TL8Yy2UGv4x8lwoHlF1sPufvifcP28VAuQABAAH//wAPeJyFkc9r1EAUx9+bTGYmk21i7CSLWHfZZDdBV9aS7A+wuHb9wbawINiCLaW1hS0eSj1IvXjw7sX9M7zoob0IIngp4tE/Q/TQiydhUyf1UC/iY/jw/b73hTfwgAGcHhoXDRtcqMINWIC78ATGizuP7hMmrtYueRYyQDI0DaIFQ9inhABnwPfAAUs41rY7Q0RJEoaCbQG3bb4KnNtrYHN7tDve2dpYX3n4YLQ8HNxWdRUXFV0wrzTRU6yJYdzx2t0FTIPyf/ysV/NUBbNa2kfMkjiJGDf9IqODUS2MEy8K41tYpHt97GVpUEUNrEhRF/IMk3P5WvI/ksulvCQEwa9EiPzVr8vUPGQUf0jRbTfy+UYbO0XubWJdD47K16zknZD4Pv9UNHFQ8B86HxNvelJSUiqyOzARzRW9cXrSunenRWbPPrHpz2FFbUogp1N9h8f6DhHMw2CxP4OAVaQGGRKtDARj30SD6rcHHBA4bgNljK4CpWwNGGUj34/qjaiuhDnXxE475pFGEoWM+xplXwW9TKOcpd1ep4ByMGyRPqYVJG8CZxI4Q1fhxAlQuefm6Nnnb1+eshcff354iTeX9HSiBzqu3L9N9vz44OD4e4HfFf9hawAAeJxjYGRgYADiN4uE5eP5bb4ycDO/AIowXE1YfgpG///7fyPzC2ZuIJeDgQkkCgB97A5TAHicY2BkYGAO+p8FJF/8//v/F/MLBqAICmAGALYGB48AA+gAAAMRAAADWf/9AAAAAADEASsAAQAAAAMAaAAGAAAAAAACACAAMABzAAAAdQtwAAAAAHicdZDdasIwGIbfzJ9tCtvYYKfL0VDG6g8MQRAEh55sJzI8HbXWtlIbSaPgbewedjG7iV3LXts4hrKWNM/35MuXrwFwjW8I5M8TR84CZ4xyPsEpepYL9M+Wi+QXyyVU8Wa5TP9uuYIHBJaruMEHK4jiOaMFPi0LXIlLyye4EHeWC/SPlovknuUSbsWr5TK9Z7mCiUgtV3EvvgZqtdVREBpZG9Rlu9nqyOlWKqoocWPprk2odCr7cq4S48excjy13PPYD9axq/fhfp74Oo1UIltOc69GfuJr1/izXfV0E7SNmcu5Vks5tBlypdXC94wTGrPqNhp/z8MACitsoRHxqkIYSNRo65zbaKKFDmnKDMnMPCtCAhcxjYs1d4TZSsq4zzFnlND6zIjJDjx+l0d+TAq4P2YVfbR6GE9IuzOizEv25bC7w6wRKcky3czOfntPseFpbVrDXbsuddaVxPCghuR97NYWNB69k92Koe2iwfef//sB5m6EUQB4nGNgYoAALgbsgJmRiZGZkYWBu6QosThDNzW3oKSSpyCntFg3ObMoOSc1hYEBAI3CCXgAeJxj8N7BcCIoYiMjY1/kBsadHAwcDMkFGxlYnTYxMDJogRibuZgYOSAsPgYwi81pF9MBoDQnkM3utIvBAcJmZnDZqMLYERixwaEjYiNzistGNRBvF0cDAyOLQ0dySARISSQQbOZhYuTR2sH4v3UDS+9GJgYXAAx2I/QAAA==') format('woff'),
|
819 |
+
url('data:application/octet-stream;base64,AAEAAAAPAIAAAwBwR1NVQiCLJXoAAAD8AAAAVE9TLzI+IEkBAAABUAAAAFZjbWFwiEPsqQAAAagAAAF+Y3Z0IAbV/wQAAAksAAAAIGZwZ22KkZBZAAAJTAAAC3BnYXNwAAAAEAAACSQAAAAIZ2x5Zpc/OaQAAAMoAAACVmhlYWQNxZM1AAAFgAAAADZoaGVhBzoDUAAABbgAAAAkaG10eApS//0AAAXcAAAADGxvY2EAxAErAAAF6AAAAAhtYXhwARIMCgAABfAAAAAgbmFtZcydHR8AAAYQAAACzXBvc3SFVFBUAAAI4AAAAERwcmVw5UErvAAAFLwAAACGAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAEDcQGQAAUAAAJ6ArwAAACMAnoCvAAAAeAAMQECAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAQOgA6AEDUv9qAFoDUgCWAAAAAQAAAAAAAAAAAAUAAAADAAAALAAAAAQAAAFWAAEAAAAAAFAAAwABAAAALAADAAoAAAFWAAQAJAAAAAQABAABAADoAf//AADoAP//AAAAAQAEAAAAAQACAAABBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAoAAAAAAAAAAIAAOgAAADoAAAAAAEAAOgBAADoAQAAAAIAAAAGAAD/sQMSAwsADwAfAC8AOwBDAGcAZEBhV0UCBggpIRkRCQEGAAECRwUDAgEGAAYBAG0EAgIABwYAB2sADgAJCA4JYA8NAggMCgIGAQgGXgAHCwsHVAAHBwtYAAsHC0xlZGFeW1lTUk9MSUdBPxQkFCYmJiYmIxAFHSsBERQGKwEiJjURNDY7ATIWFxEUBisBIiY1ETQ2OwEyFhcRFAYrASImNRE0NjsBMhYTESERFB4BMyEyPgEBMycmJyMGBwUVFAYrAREUBiMhIiYnESMiJj0BNDY7ATc+ATczMhYfATMyFgEeCggkCAoKCCQICo8KCCQICgoIJAgKjgoHJAgKCggkBwpI/gwICAIB0AIICP6J+hsEBbEGBAHrCgg2NCX+MCU0ATUICgoIrCcJLBayFyoJJ60ICgG3/r8ICgoIAUEICgoI/r8ICgoIAUEICgoI/r8ICgoIAUEICgr+ZAIR/e8MFAoKFAJlQQUBAQVTJAgK/e8uREIuAhMKCCQICl0VHAEeFF0KAAL//f+xA18DCwAjADAAQUA+DQEAAR8BBAMCRwIBAAEDAQADbQUBAwQBAwRrAAcAAQAHAWAABAYGBFQABAQGWAAGBAZMFRUjJCUjJBQIBRwrATU0JgcjNTQmJyMiBgcVIyIGFxUUFjczFRQWFzMyNjc1MzI2NxQOASIuAj4BMh4BAqcWDo8WDkcPFAGPDhYBFA+PFg5HDxQBjw4WsnLG6MhuBnq89Lp+ATpIDhYBjw8UARYOjxQPSA4WAY8PFAEWDo8UM3XEdHTE6sR0dMQAAAABAAAAAQAA7KITH18PPPUACwPoAAAAANVgp8oAAAAA1WCnyv/9/7ED6AMLAAAACAACAAAAAAAAAAEAAANS/2oAAAPo//3/+gPoAAEAAAAAAAAAAAAAAAAAAAADA+gAAAMRAAADWf/9AAAAAADEASsAAQAAAAMAaAAGAAAAAAACACAAMABzAAAAdQtwAAAAAAAAABIA3gABAAAAAAAAADUAAAABAAAAAAABAAgANQABAAAAAAACAAcAPQABAAAAAAADAAgARAABAAAAAAAEAAgATAABAAAAAAAFAAsAVAABAAAAAAAGAAgAXwABAAAAAAAKACsAZwABAAAAAAALABMAkgADAAEECQAAAGoApQADAAEECQABABABDwADAAEECQACAA4BHwADAAEECQADABABLQADAAEECQAEABABPQADAAEECQAFABYBTQADAAEECQAGABABYwADAAEECQAKAFYBcwADAAEECQALACYByUNvcHlyaWdodCAoQykgMjAxNyBieSBvcmlnaW5hbCBhdXRob3JzIEAgZm9udGVsbG8uY29tZm9udGVsbG9SZWd1bGFyZm9udGVsbG9mb250ZWxsb1ZlcnNpb24gMS4wZm9udGVsbG9HZW5lcmF0ZWQgYnkgc3ZnMnR0ZiBmcm9tIEZvbnRlbGxvIHByb2plY3QuaHR0cDovL2ZvbnRlbGxvLmNvbQBDAG8AcAB5AHIAaQBnAGgAdAAgACgAQwApACAAMgAwADEANwAgAGIAeQAgAG8AcgBpAGcAaQBuAGEAbAAgAGEAdQB0AGgAbwByAHMAIABAACAAZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AZgBvAG4AdABlAGwAbABvAFIAZQBnAHUAbABhAHIAZgBvAG4AdABlAGwAbABvAGYAbwBuAHQAZQBsAGwAbwBWAGUAcgBzAGkAbwBuACAAMQAuADAAZgBvAG4AdABlAGwAbABvAEcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAAcwB2AGcAMgB0AHQAZgAgAGYAcgBvAG0AIABGAG8AbgB0AGUAbABsAG8AIABwAHIAbwBqAGUAYwB0AC4AaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAAAACAAAAAAAAAAoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMBAgEDAQQAC3RyYXNoLWVtcHR5DHBsdXMtY2lyY2xlZAAAAAEAAf//AA8AAAAAAAAAAAAAAAAAAAAAABgAGAAYABgDUv9qA1L/arAALCCwAFVYRVkgIEu4AA5RS7AGU1pYsDQbsChZYGYgilVYsAIlYbkIAAgAY2MjYhshIbAAWbAAQyNEsgABAENgQi2wASywIGBmLbACLCBkILDAULAEJlqyKAEKQ0VjRVJbWCEjIRuKWCCwUFBYIbBAWRsgsDhQWCGwOFlZILEBCkNFY0VhZLAoUFghsQEKQ0VjRSCwMFBYIbAwWRsgsMBQWCBmIIqKYSCwClBYYBsgsCBQWCGwCmAbILA2UFghsDZgG2BZWVkbsAErWVkjsABQWGVZWS2wAywgRSCwBCVhZCCwBUNQWLAFI0KwBiNCGyEhWbABYC2wBCwjISMhIGSxBWJCILAGI0KxAQpDRWOxAQpDsAFgRWOwAyohILAGQyCKIIqwASuxMAUlsAQmUVhgUBthUllYI1khILBAU1iwASsbIbBAWSOwAFBYZVktsAUssAdDK7IAAgBDYEItsAYssAcjQiMgsAAjQmGwAmJmsAFjsAFgsAUqLbAHLCAgRSCwC0NjuAQAYiCwAFBYsEBgWWawAWNgRLABYC2wCCyyBwsAQ0VCKiGyAAEAQ2BCLbAJLLAAQyNEsgABAENgQi2wCiwgIEUgsAErI7AAQ7AEJWAgRYojYSBkILAgUFghsAAbsDBQWLAgG7BAWVkjsABQWGVZsAMlI2FERLABYC2wCywgIEUgsAErI7AAQ7AEJWAgRYojYSBksCRQWLAAG7BAWSOwAFBYZVmwAyUjYUREsAFgLbAMLCCwACNCsgsKA0VYIRsjIVkqIS2wDSyxAgJFsGRhRC2wDiywAWAgILAMQ0qwAFBYILAMI0JZsA1DSrAAUlggsA0jQlktsA8sILAQYmawAWMguAQAY4ojYbAOQ2AgimAgsA4jQiMtsBAsS1RYsQRkRFkksA1lI3gtsBEsS1FYS1NYsQRkRFkbIVkksBNlI3gtsBIssQAPQ1VYsQ8PQ7ABYUKwDytZsABDsAIlQrEMAiVCsQ0CJUKwARYjILADJVBYsQEAQ2CwBCVCioogiiNhsA4qISOwAWEgiiNhsA4qIRuxAQBDYLACJUKwAiVhsA4qIVmwDENHsA1DR2CwAmIgsABQWLBAYFlmsAFjILALQ2O4BABiILAAUFiwQGBZZrABY2CxAAATI0SwAUOwAD6yAQEBQ2BCLbATLACxAAJFVFiwDyNCIEWwCyNCsAojsAFgQiBgsAFhtRAQAQAOAEJCimCxEgYrsHIrGyJZLbAULLEAEystsBUssQETKy2wFiyxAhMrLbAXLLEDEystsBgssQQTKy2wGSyxBRMrLbAaLLEGEystsBsssQcTKy2wHCyxCBMrLbAdLLEJEystsB4sALANK7EAAkVUWLAPI0IgRbALI0KwCiOwAWBCIGCwAWG1EBABAA4AQkKKYLESBiuwcisbIlktsB8ssQAeKy2wICyxAR4rLbAhLLECHistsCIssQMeKy2wIyyxBB4rLbAkLLEFHistsCUssQYeKy2wJiyxBx4rLbAnLLEIHistsCgssQkeKy2wKSwgPLABYC2wKiwgYLAQYCBDI7ABYEOwAiVhsAFgsCkqIS2wKyywKiuwKiotsCwsICBHICCwC0NjuAQAYiCwAFBYsEBgWWawAWNgI2E4IyCKVVggRyAgsAtDY7gEAGIgsABQWLBAYFlmsAFjYCNhOBshWS2wLSwAsQACRVRYsAEWsCwqsAEVMBsiWS2wLiwAsA0rsQACRVRYsAEWsCwqsAEVMBsiWS2wLywgNbABYC2wMCwAsAFFY7gEAGIgsABQWLBAYFlmsAFjsAErsAtDY7gEAGIgsABQWLBAYFlmsAFjsAErsAAWtAAAAAAARD4jOLEvARUqLbAxLCA8IEcgsAtDY7gEAGIgsABQWLBAYFlmsAFjYLAAQ2E4LbAyLC4XPC2wMywgPCBHILALQ2O4BABiILAAUFiwQGBZZrABY2CwAENhsAFDYzgtsDQssQIAFiUgLiBHsAAjQrACJUmKikcjRyNhIFhiGyFZsAEjQrIzAQEVFCotsDUssAAWsAQlsAQlRyNHI2GwCUMrZYouIyAgPIo4LbA2LLAAFrAEJbAEJSAuRyNHI2EgsAQjQrAJQysgsGBQWCCwQFFYswIgAyAbswImAxpZQkIjILAIQyCKI0cjRyNhI0ZgsARDsAJiILAAUFiwQGBZZrABY2AgsAErIIqKYSCwAkNgZCOwA0NhZFBYsAJDYRuwA0NgWbADJbACYiCwAFBYsEBgWWawAWNhIyAgsAQmI0ZhOBsjsAhDRrACJbAIQ0cjRyNhYCCwBEOwAmIgsABQWLBAYFlmsAFjYCMgsAErI7AEQ2CwASuwBSVhsAUlsAJiILAAUFiwQGBZZrABY7AEJmEgsAQlYGQjsAMlYGRQWCEbIyFZIyAgsAQmI0ZhOFktsDcssAAWICAgsAUmIC5HI0cjYSM8OC2wOCywABYgsAgjQiAgIEYjR7ABKyNhOC2wOSywABawAyWwAiVHI0cjYbAAVFguIDwjIRuwAiWwAiVHI0cjYSCwBSWwBCVHI0cjYbAGJbAFJUmwAiVhuQgACABjYyMgWGIbIVljuAQAYiCwAFBYsEBgWWawAWNgIy4jICA8ijgjIVktsDossAAWILAIQyAuRyNHI2EgYLAgYGawAmIgsABQWLBAYFlmsAFjIyAgPIo4LbA7LCMgLkawAiVGUlggPFkusSsBFCstsDwsIyAuRrACJUZQWCA8WS6xKwEUKy2wPSwjIC5GsAIlRlJYIDxZIyAuRrACJUZQWCA8WS6xKwEUKy2wPiywNSsjIC5GsAIlRlJYIDxZLrErARQrLbA/LLA2K4ogIDywBCNCijgjIC5GsAIlRlJYIDxZLrErARQrsARDLrArKy2wQCywABawBCWwBCYgLkcjRyNhsAlDKyMgPCAuIzixKwEUKy2wQSyxCAQlQrAAFrAEJbAEJSAuRyNHI2EgsAQjQrAJQysgsGBQWCCwQFFYswIgAyAbswImAxpZQkIjIEewBEOwAmIgsABQWLBAYFlmsAFjYCCwASsgiophILACQ2BkI7ADQ2FkUFiwAkNhG7ADQ2BZsAMlsAJiILAAUFiwQGBZZrABY2GwAiVGYTgjIDwjOBshICBGI0ewASsjYTghWbErARQrLbBCLLA1Ky6xKwEUKy2wQyywNishIyAgPLAEI0IjOLErARQrsARDLrArKy2wRCywABUgR7AAI0KyAAEBFRQTLrAxKi2wRSywABUgR7AAI0KyAAEBFRQTLrAxKi2wRiyxAAEUE7AyKi2wRyywNCotsEgssAAWRSMgLiBGiiNhOLErARQrLbBJLLAII0KwSCstsEossgAAQSstsEsssgABQSstsEwssgEAQSstsE0ssgEBQSstsE4ssgAAQistsE8ssgABQistsFAssgEAQistsFEssgEBQistsFIssgAAPistsFMssgABPistsFQssgEAPistsFUssgEBPistsFYssgAAQCstsFcssgABQCstsFgssgEAQCstsFkssgEBQCstsFossgAAQystsFsssgABQystsFwssgEAQystsF0ssgEBQystsF4ssgAAPystsF8ssgABPystsGAssgEAPystsGEssgEBPystsGIssDcrLrErARQrLbBjLLA3K7A7Ky2wZCywNyuwPCstsGUssAAWsDcrsD0rLbBmLLA4Ky6xKwEUKy2wZyywOCuwOystsGgssDgrsDwrLbBpLLA4K7A9Ky2waiywOSsusSsBFCstsGsssDkrsDsrLbBsLLA5K7A8Ky2wbSywOSuwPSstsG4ssDorLrErARQrLbBvLLA6K7A7Ky2wcCywOiuwPCstsHEssDorsD0rLbByLLMJBAIDRVghGyMhWUIrsAhlsAMkUHiwARUwLQBLuADIUlixAQGOWbABuQgACABjcLEABUKyAAEAKrEABUKzCgIBCCqxAAVCsw4AAQgqsQAGQroCwAABAAkqsQAHQroAQAABAAkqsQMARLEkAYhRWLBAiFixA2REsSYBiFFYugiAAAEEQIhjVFixAwBEWVlZWbMMAgEMKrgB/4WwBI2xAgBEAAA=') format('truetype');
|
820 |
+
}
|
821 |
+
#quads-add-new-ad:before {
|
822 |
+
font-family: 'quads';
|
823 |
+
content: '\e801';
|
824 |
+
text-decoration: none;
|
825 |
+
margin-right:5px;
|
826 |
+
color: #383838;
|
827 |
+
}
|
828 |
+
|
829 |
+
#quads-add-new-ad{
|
830 |
+
margin-left: 3px;
|
831 |
+
margin-top: 5px;
|
832 |
+
display: block;
|
833 |
+
margin-bottom: 20px;
|
834 |
+
text-decoration: none;
|
835 |
+
font-size: 14px;
|
836 |
+
font-weight: 600;
|
837 |
+
color: #383838;
|
838 |
+
}
|
839 |
+
|
840 |
+
#quads-submit-button{
|
841 |
+
z-index: 999999;
|
842 |
+
}
|
843 |
+
|
844 |
+
p.submit{
|
845 |
+
float:left;
|
846 |
+
padding-top:0px;
|
847 |
+
padding-bottom:0px;
|
848 |
+
}
|
849 |
+
|
850 |
+
.quads-delete-ad{
|
851 |
+
clear:both;
|
852 |
+
display:block;
|
853 |
+
//background: url('../images/remove-icon.png');
|
854 |
+
//background-size: 20px 20px;
|
855 |
+
//background-repeat: no-repeat;
|
856 |
+
//height: 20px;
|
857 |
+
//padding-left:30px;
|
858 |
+
margin-right:5px;
|
859 |
+
font-size: 14px;
|
860 |
+
font-weight: 600;
|
861 |
+
text-decoration: none;
|
862 |
+
color: #383838;
|
863 |
+
}
|
864 |
+
.quads-delete-ad:before{
|
865 |
+
font-family: 'quads';
|
866 |
+
content: '\e800';
|
867 |
+
margin-right:5px;
|
868 |
+
color: #383838;
|
869 |
+
}
|
870 |
+
|
871 |
+
#backup-settings-textarea{
|
872 |
+
width: 580px;
|
873 |
+
height: 400px;
|
874 |
+
font-family: Menlo, Monaco, monospace;
|
875 |
+
background: none;
|
876 |
+
white-space: normal;
|
877 |
+
overflow: auto;
|
878 |
+
display: block;
|
879 |
+
}
|
880 |
+
|
881 |
+
@media (max-width:506px){
|
882 |
+
.quads-banner-columns {
|
883 |
+
display: block !important;
|
884 |
+
}
|
885 |
+
.quads-banner-sidebar-second{
|
886 |
+
width: 100% !important;
|
887 |
+
}
|
888 |
+
}
|
889 |
+
@media (max-width:780px){
|
890 |
+
.quads-banner-wrapper{
|
891 |
+
margin-right:12px !important;
|
892 |
+
}
|
893 |
+
}
|
894 |
+
|
895 |
+
.quads-banner-wrapper{
|
896 |
+
display: flex;
|
897 |
+
flex-direction: column;
|
898 |
+
clear:both;
|
899 |
+
background: #fff;
|
900 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
901 |
+
-webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
902 |
+
box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
|
903 |
+
margin: 5px 5px 2px;
|
904 |
+
margin-right:20px;
|
905 |
+
padding: 1px 12px;
|
906 |
+
}
|
907 |
+
.quads-banner-content {
|
908 |
+
display: flex;
|
909 |
+
flex: 1;
|
910 |
+
color: #000;
|
911 |
+
}
|
912 |
+
.quads-banner-columns{
|
913 |
+
display: flex;
|
914 |
+
flex:1;
|
915 |
+
-ms-flex-align: center;
|
916 |
+
-webkit-align-items: center;
|
917 |
+
-webkit-box-align: center;
|
918 |
+
|
919 |
+
align-items: center;
|
920 |
+
}
|
921 |
+
.quads-banner-main{
|
922 |
+
flex: 1;
|
923 |
+
order: 2;
|
924 |
+
}
|
925 |
+
.quads-banner-sidebar-first{
|
926 |
+
min-width: 160px;
|
927 |
+
width: 13%;
|
928 |
+
order: 1;
|
929 |
+
}
|
930 |
+
.quads-banner-sidebar-second{
|
931 |
+
width: 19%;
|
932 |
+
order: 3;
|
933 |
+
}
|
934 |
+
|
935 |
+
|
936 |
+
.quads-button-primary {
|
937 |
+
display: inline-block;
|
938 |
+
text-decoration: none;
|
939 |
+
font-size: 16px;
|
940 |
+
line-height: 32px;
|
941 |
+
height: 36px;
|
942 |
+
margin: 0;
|
943 |
+
padding: 0 13px 1px;
|
944 |
+
cursor: pointer;
|
945 |
+
border-width: 1px;
|
946 |
+
border-style: solid;
|
947 |
+
-webkit-appearance: none;
|
948 |
+
-webkit-border-radius: 3px;
|
949 |
+
border-radius: 3px;
|
950 |
+
white-space: nowrap;
|
951 |
+
-webkit-box-sizing: border-box;
|
952 |
+
-moz-box-sizing: border-box;
|
953 |
+
box-sizing: border-box;
|
954 |
+
font-weight: bold;
|
955 |
+
}
|
956 |
+
|
957 |
+
.quads-button-primary {
|
958 |
+
background: #0085ba;
|
959 |
+
border-color: #0073aa #006799 #006799;
|
960 |
+
-webkit-box-shadow: 0 1px 0 #006799;
|
961 |
+
box-shadow: 0 1px 0 #006799;
|
962 |
+
color: #fff;
|
963 |
+
text-decoration: none;
|
964 |
+
text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
|
965 |
+
}
|
966 |
+
|
967 |
+
.quads-notice-dismiss {
|
968 |
+
display: inline-block;
|
969 |
+
position: relative;
|
970 |
+
top: 0;
|
971 |
+
right: 1px;
|
972 |
+
border: none;
|
973 |
+
margin: 0;
|
974 |
+
padding: 0px;
|
975 |
+
background: 0 0;
|
976 |
+
color: #72777c;
|
977 |
+
cursor: pointer;
|
978 |
+
}
|
979 |
+
|
980 |
+
.quads-notice-dismiss:before{
|
981 |
+
display: inline-block;
|
982 |
+
background: 0 0;
|
983 |
+
color: #72777c;
|
984 |
+
content: "\f153";
|
985 |
+
font: 400 16px/20px dashicons;
|
986 |
+
speak: none;
|
987 |
+
height: 20px;
|
988 |
+
text-align: center;
|
989 |
+
width: 20px;
|
990 |
+
-webkit-font-smoothing: antialiased;
|
991 |
+
}
|
992 |
+
|
993 |
+
.quads-widget-buttons {
|
994 |
+
float:right;
|
995 |
+
}
|
996 |
+
.quads-widget-buttons a{
|
997 |
+
min-width: 80px;text-align: center;font-weight: 600;
|
998 |
+
}
|
999 |
+
|
1000 |
+
#quads-vi-widget ul {
|
1001 |
+
margin: 0;
|
1002 |
+
margin-left:25px;
|
1003 |
+
padding: 0;
|
1004 |
+
background: #fff;
|
1005 |
+
float: none;
|
1006 |
+
padding-top: 0px;
|
1007 |
+
list-style-type: square;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
#quads-vi-signup-fullscreen{
|
1011 |
+
display:none;
|
1012 |
+
z-index: 999999;
|
1013 |
+
box-sizing:border-box;
|
1014 |
+
-webkit-box-sizing:border-box;
|
1015 |
+
-moz-box-sizing:border-box;
|
1016 |
+
height: 100%;
|
1017 |
+
width: 100%;
|
1018 |
+
position: absolute;
|
1019 |
+
top: 50%;
|
1020 |
+
left: 50%;
|
1021 |
+
transform: translate(-50%, -50%);
|
1022 |
+
background-color:#f0f0f0;
|
1023 |
+
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
#quads-vi-signup-container {
|
1027 |
+
width:99%;
|
1028 |
+
height:99%;
|
1029 |
+
max-width:868px;
|
1030 |
+
max-height:552px;
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
#quads-vi-close{
|
1034 |
+
cursor:pointer;
|
1035 |
+
position: relative;
|
1036 |
+
display: inline-block;
|
1037 |
+
width: 20px;
|
1038 |
+
height: 20px;
|
1039 |
+
overflow: hidden;
|
1040 |
+
float: right;
|
1041 |
+
margin-right: 20px;
|
1042 |
+
margin-top: 20px;
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
#quads-vi-close::before, #quads-vi-close::after {
|
1046 |
+
content: '';
|
1047 |
+
position: absolute;
|
1048 |
+
height: 2px;
|
1049 |
+
width: 100%;
|
1050 |
+
top: 50%;
|
1051 |
+
left: 0;
|
1052 |
+
margin-top: -1px;
|
1053 |
+
background: #7d7d7d;
|
1054 |
+
}
|
1055 |
+
|
1056 |
+
#quads-vi-close::before {
|
1057 |
+
-webkit-transform: rotate(45deg);
|
1058 |
+
-moz-transform: rotate(45deg);
|
1059 |
+
-ms-transform: rotate(45deg);
|
1060 |
+
-o-transform: rotate(45deg);
|
1061 |
+
transform: rotate(45deg);
|
1062 |
+
}
|
1063 |
+
#quads-vi-close::after {
|
1064 |
+
-webkit-transform: rotate(-45deg);
|
1065 |
+
-moz-transform: rotate(-45deg);
|
1066 |
+
-ms-transform: rotate(-45deg);
|
1067 |
+
-o-transform: rotate(-45deg);
|
1068 |
+
transform: rotate(-45deg);
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
|
1072 |
+
#quads-vi-signup-fullscreen iframe{
|
1073 |
+
width:100%;
|
1074 |
+
height:100%;
|
1075 |
+
z-index: 999999;
|
1076 |
+
display: block;
|
1077 |
+
background:#FFF;
|
1078 |
+
border:none;
|
1079 |
+
}
|
1080 |
+
|
1081 |
+
.quads-spinner {
|
1082 |
+
background: url('/wp-admin/images/spinner.gif') no-repeat;
|
1083 |
+
background-size: 16px 16px;
|
1084 |
+
display: none;
|
1085 |
+
float: left;
|
1086 |
+
opacity: .7;
|
1087 |
+
filter: alpha(opacity=70);
|
1088 |
+
width: 160px;
|
1089 |
+
height: 16px;
|
1090 |
+
margin: 5px 5px 0;
|
1091 |
+
clear:both;
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
#quads-vi-revenue-wrapper{
|
1095 |
+
margin-top: 10px;
|
1096 |
+
min-width: 565px;
|
1097 |
+
min-height: 350px;
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
#quads-vi-revenue-sum {
|
1101 |
+
font-weight: bold;
|
1102 |
+
font-size: 36px;
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
#quads-vi-revenue-sum-wrapper{
|
1106 |
+
margin-top: 20px;
|
1107 |
+
line-height: 26px;
|
1108 |
+
}
|
1109 |
+
|
1110 |
+
#quads-vi-customize-player label {
|
1111 |
+
display:inline-block;
|
1112 |
+
width:170px;
|
1113 |
+
color:black;
|
1114 |
+
font-weight: 500;
|
1115 |
+
}
|
1116 |
+
#quads-vi-shortcodes label {
|
1117 |
+
display:inline-block;
|
1118 |
+
width:170px;
|
1119 |
+
}
|
1120 |
+
#quads-vi-save-settings {
|
1121 |
+
margin-top:20px;
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
#quads-vi-welcome ul {
|
1125 |
+
float:none;
|
1126 |
+
list-style: square;
|
1127 |
+
margin-left:25px;
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
.quads-tooltip {
|
1131 |
+
border-radius: 50%;
|
1132 |
+
border: 2px solid #fff;
|
1133 |
+
background-color: #e7db00;
|
1134 |
+
width: 15px;
|
1135 |
+
height: 15px;
|
1136 |
+
display: inline-block;
|
1137 |
+
position: relative;
|
1138 |
+
top: 4px;
|
1139 |
+
margin-top: -4px;
|
1140 |
+
cursor: pointer;
|
1141 |
+
margin-left: 2px;
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
.quads-tooltip:after {
|
1145 |
+
height: 20px;
|
1146 |
+
font-family: sans-serif;
|
1147 |
+
content: "?";
|
1148 |
+
color: #fff;
|
1149 |
+
font-size: 11px;
|
1150 |
+
font-weight: 700;
|
1151 |
+
left: 4px;
|
1152 |
+
top:-2px;
|
1153 |
+
position: absolute;
|
1154 |
+
}
|
1155 |
+
|
1156 |
+
.quads-tooltip-message {
|
1157 |
+
padding: 10px;
|
1158 |
+
border: 1px solid #FBFBFB;
|
1159 |
+
border-radius: 2px;
|
1160 |
+
background-color: #F8F8F8;
|
1161 |
+
position: absolute;
|
1162 |
+
max-width: 500px;
|
1163 |
+
z-index: 9999;
|
1164 |
+
display: none;
|
1165 |
+
box-shadow: 0 0 5px rgba(0,0,0,.2);
|
1166 |
+
font-weight: 400;
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
#quads-vi-layout label{
|
1170 |
+
width: 100px;
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
#quads_vi_ads-ads-1-align-left-label{
|
1174 |
+
content: url('../images/align_left.png');
|
1175 |
+
}
|
1176 |
+
#quads_vi_ads-ads-1-align-right-label{
|
1177 |
+
content: url('../images/align_right.png');
|
1178 |
+
}
|
1179 |
+
#quads_vi_ads-ads-1-align-middle-label{
|
1180 |
+
content: url('../images/align_middle.png');
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
/*.quads-vi-welcome-white {
|
1184 |
+
text-decoration: underline;
|
1185 |
+
border-bottom:3px solid yellow;
|
1186 |
+
font-weight: bold;
|
1187 |
+
color:black;
|
1188 |
+
}
|
1189 |
+
.quads-vi-welcome-black {
|
1190 |
+
text-decoration: underline;
|
1191 |
+
border-bottom:3px solid yellow;
|
1192 |
+
font-weight: bold;
|
1193 |
+
color:white;
|
1194 |
+
}*/
|
1195 |
+
|
1196 |
+
#quads_vi_automatic_integration select{
|
1197 |
+
min-width: 180px;
|
1198 |
+
}
|
1199 |
+
|
1200 |
+
#quads_vi_ads\[ads\]\[1\]\[marginLeft\],
|
1201 |
+
#quads_vi_ads\[ads\]\[1\]\[marginTop\],
|
1202 |
+
#quads_vi_ads\[ads\]\[1\]\[marginRight\],
|
1203 |
+
#quads_vi_ads\[ads\]\[1\]\[marginBottom\]{
|
1204 |
+
width: 60px;
|
1205 |
}
|
assets/css/quads-plugins-admin.min.css
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
/**
|
2 |
-
PLUGINS ADMIN PAGE
|
3 |
-
*/
|
4 |
-
#quick-adsense-reloaded-feedback-overlay {
|
5 |
-
/* Height & width depends on how you want to reveal the overlay (see JS below) */
|
6 |
-
height: 100%;
|
7 |
-
width: 100%;
|
8 |
-
position: fixed; /* Stay in place */
|
9 |
-
z-index: 10000; /* Sit on top */
|
10 |
-
left: 0;
|
11 |
-
top: 0;
|
12 |
-
background-color: rgb(120,120,120); /* Black fallback color */
|
13 |
-
background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
|
14 |
-
}
|
15 |
-
#quick-adsense-reloaded-feedback-content {
|
16 |
-
position: relative;
|
17 |
-
top: 25%; /* 25% from the top */
|
18 |
-
width: 500px;
|
19 |
-
max-width: 100%;
|
20 |
-
margin: auto;
|
21 |
-
margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
|
22 |
-
max-height: 50%;
|
23 |
-
padding: 20px;
|
24 |
-
background-color: #fff;
|
25 |
-
overflow-y: auto;
|
26 |
-
}
|
27 |
-
#quick-adsense-reloaded-feedback-content textarea,
|
28 |
-
#quick-adsense-reloaded-feedback-content input[type="text"] { display:none;width:100%; }
|
29 |
-
.quick-adsense-reloaded-feedback-not-deactivate { display: block; text-align: right; }
|
30 |
-
|
31 |
-
#quick-adsense-reloaded-feedback-content h3{
|
32 |
-
margin:5px;
|
33 |
-
}
|
34 |
-
|
35 |
-
|
36 |
-
@media screen and (max-width:400px){
|
37 |
-
#quick-adsense-reloaded-feedback-content {
|
38 |
-
padding:0px;
|
39 |
-
padding-bottom:50px;
|
40 |
-
}
|
41 |
}
|
1 |
+
/**
|
2 |
+
PLUGINS ADMIN PAGE
|
3 |
+
*/
|
4 |
+
#quick-adsense-reloaded-feedback-overlay {
|
5 |
+
/* Height & width depends on how you want to reveal the overlay (see JS below) */
|
6 |
+
height: 100%;
|
7 |
+
width: 100%;
|
8 |
+
position: fixed; /* Stay in place */
|
9 |
+
z-index: 10000; /* Sit on top */
|
10 |
+
left: 0;
|
11 |
+
top: 0;
|
12 |
+
background-color: rgb(120,120,120); /* Black fallback color */
|
13 |
+
background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
|
14 |
+
}
|
15 |
+
#quick-adsense-reloaded-feedback-content {
|
16 |
+
position: relative;
|
17 |
+
top: 25%; /* 25% from the top */
|
18 |
+
width: 500px;
|
19 |
+
max-width: 100%;
|
20 |
+
margin: auto;
|
21 |
+
margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
|
22 |
+
max-height: 50%;
|
23 |
+
padding: 20px;
|
24 |
+
background-color: #fff;
|
25 |
+
overflow-y: auto;
|
26 |
+
}
|
27 |
+
#quick-adsense-reloaded-feedback-content textarea,
|
28 |
+
#quick-adsense-reloaded-feedback-content input[type="text"] { display:none;width:100%; }
|
29 |
+
.quick-adsense-reloaded-feedback-not-deactivate { display: block; text-align: right; }
|
30 |
+
|
31 |
+
#quick-adsense-reloaded-feedback-content h3{
|
32 |
+
margin:5px;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
@media screen and (max-width:400px){
|
37 |
+
#quick-adsense-reloaded-feedback-content {
|
38 |
+
padding:0px;
|
39 |
+
padding-bottom:50px;
|
40 |
+
}
|
41 |
}
|
assets/js/blocks.js
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
var el = wp.element.createElement,
|
2 |
-
registerBlockType = wp.blocks.registerBlockType,
|
3 |
-
blockStyle = { backgroundColor: '#900', color: '#fff', padding: '20px' };
|
4 |
-
|
5 |
-
registerBlockType( 'wpquads/blocks', {
|
6 |
-
title: 'Hello World (Step 1)',
|
7 |
-
|
8 |
-
icon: 'universal-access-alt',
|
9 |
-
|
10 |
-
category: 'layout',
|
11 |
-
|
12 |
-
edit: function() {
|
13 |
-
return el( 'p', { style: blockStyle }, 'Hello editor.' );
|
14 |
-
},
|
15 |
-
|
16 |
-
save: function() {
|
17 |
-
return el( 'p', { style: blockStyle }, 'Hello saved content.' );
|
18 |
-
},
|
19 |
-
} );
|
20 |
-
|
21 |
-
|
1 |
+
var el = wp.element.createElement,
|
2 |
+
registerBlockType = wp.blocks.registerBlockType,
|
3 |
+
blockStyle = { backgroundColor: '#900', color: '#fff', padding: '20px' };
|
4 |
+
|
5 |
+
registerBlockType( 'wpquads/blocks', {
|
6 |
+
title: 'Hello World (Step 1)',
|
7 |
+
|
8 |
+
icon: 'universal-access-alt',
|
9 |
+
|
10 |
+
category: 'layout',
|
11 |
+
|
12 |
+
edit: function() {
|
13 |
+
return el( 'p', { style: blockStyle }, 'Hello editor.' );
|
14 |
+
},
|
15 |
+
|
16 |
+
save: function() {
|
17 |
+
return el( 'p', { style: blockStyle }, 'Hello saved content.' );
|
18 |
+
},
|
19 |
+
} );
|
20 |
+
|
21 |
+
|
assets/js/chosen.jquery.js
CHANGED
@@ -1,1284 +1,1284 @@
|
|
1 |
-
/*!
|
2 |
-
Chosen, a Select Box Enhancer for jQuery and Prototype
|
3 |
-
by Patrick Filler for Harvest, http://getharvest.com
|
4 |
-
|
5 |
-
Version 1.5.1
|
6 |
-
Full source at https://github.com/harvesthq/chosen
|
7 |
-
Copyright (c) 2011-2016 Harvest http://getharvest.com
|
8 |
-
|
9 |
-
MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
|
10 |
-
This file is generated by `grunt build`, do not edit it by hand.
|
11 |
-
*/
|
12 |
-
|
13 |
-
(function() {
|
14 |
-
var $, AbstractChosen, Chosen, SelectParser, _ref,
|
15 |
-
__hasProp = {}.hasOwnProperty,
|
16 |
-
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
17 |
-
|
18 |
-
SelectParser = (function() {
|
19 |
-
function SelectParser() {
|
20 |
-
this.options_index = 0;
|
21 |
-
this.parsed = [];
|
22 |
-
}
|
23 |
-
|
24 |
-
SelectParser.prototype.add_node = function(child) {
|
25 |
-
if (child.nodeName.toUpperCase() === "OPTGROUP") {
|
26 |
-
return this.add_group(child);
|
27 |
-
} else {
|
28 |
-
return this.add_option(child);
|
29 |
-
}
|
30 |
-
};
|
31 |
-
|
32 |
-
SelectParser.prototype.add_group = function(group) {
|
33 |
-
var group_position, option, _i, _len, _ref, _results;
|
34 |
-
group_position = this.parsed.length;
|
35 |
-
this.parsed.push({
|
36 |
-
array_index: group_position,
|
37 |
-
group: true,
|
38 |
-
label: this.escapeExpression(group.label),
|
39 |
-
title: group.title ? group.title : void 0,
|
40 |
-
children: 0,
|
41 |
-
disabled: group.disabled,
|
42 |
-
classes: group.className
|
43 |
-
});
|
44 |
-
_ref = group.childNodes;
|
45 |
-
_results = [];
|
46 |
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
47 |
-
option = _ref[_i];
|
48 |
-
_results.push(this.add_option(option, group_position, group.disabled));
|
49 |
-
}
|
50 |
-
return _results;
|
51 |
-
};
|
52 |
-
|
53 |
-
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
|
54 |
-
if (option.nodeName.toUpperCase() === "OPTION") {
|
55 |
-
if (option.text !== "") {
|
56 |
-
if (group_position != null) {
|
57 |
-
this.parsed[group_position].children += 1;
|
58 |
-
}
|
59 |
-
this.parsed.push({
|
60 |
-
array_index: this.parsed.length,
|
61 |
-
options_index: this.options_index,
|
62 |
-
value: option.value,
|
63 |
-
text: option.text,
|
64 |
-
html: option.innerHTML,
|
65 |
-
title: option.title ? option.title : void 0,
|
66 |
-
selected: option.selected,
|
67 |
-
disabled: group_disabled === true ? group_disabled : option.disabled,
|
68 |
-
group_array_index: group_position,
|
69 |
-
group_label: group_position != null ? this.parsed[group_position].label : null,
|
70 |
-
classes: option.className,
|
71 |
-
style: option.style.cssText
|
72 |
-
});
|
73 |
-
} else {
|
74 |
-
this.parsed.push({
|
75 |
-
array_index: this.parsed.length,
|
76 |
-
options_index: this.options_index,
|
77 |
-
empty: true
|
78 |
-
});
|
79 |
-
}
|
80 |
-
return this.options_index += 1;
|
81 |
-
}
|
82 |
-
};
|
83 |
-
|
84 |
-
SelectParser.prototype.escapeExpression = function(text) {
|
85 |
-
var map, unsafe_chars;
|
86 |
-
if ((text == null) || text === false) {
|
87 |
-
return "";
|
88 |
-
}
|
89 |
-
if (!/[\&\<\>\"\'\`]/.test(text)) {
|
90 |
-
return text;
|
91 |
-
}
|
92 |
-
map = {
|
93 |
-
"<": "<",
|
94 |
-
">": ">",
|
95 |
-
'"': """,
|
96 |
-
"'": "'",
|
97 |
-
"`": "`"
|
98 |
-
};
|
99 |
-
unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
|
100 |
-
return text.replace(unsafe_chars, function(chr) {
|
101 |
-
return map[chr] || "&";
|
102 |
-
});
|
103 |
-
};
|
104 |
-
|
105 |
-
return SelectParser;
|
106 |
-
|
107 |
-
})();
|
108 |
-
|
109 |
-
SelectParser.select_to_array = function(select) {
|
110 |
-
var child, parser, _i, _len, _ref;
|
111 |
-
parser = new SelectParser();
|
112 |
-
_ref = select.childNodes;
|
113 |
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
114 |
-
child = _ref[_i];
|
115 |
-
parser.add_node(child);
|
116 |
-
}
|
117 |
-
return parser.parsed;
|
118 |
-
};
|
119 |
-
|
120 |
-
AbstractChosen = (function() {
|
121 |
-
function AbstractChosen(form_field, options) {
|
122 |
-
this.form_field = form_field;
|
123 |
-
this.options = options != null ? options : {};
|
124 |
-
if (!AbstractChosen.browser_is_supported()) {
|
125 |
-
return;
|
126 |
-
}
|
127 |
-
this.is_multiple = this.form_field.multiple;
|
128 |
-
this.set_default_text();
|
129 |
-
this.set_default_values();
|
130 |
-
this.setup();
|
131 |
-
this.set_up_html();
|
132 |
-
this.register_observers();
|
133 |
-
this.on_ready();
|
134 |
-
}
|
135 |
-
|
136 |
-
AbstractChosen.prototype.set_default_values = function() {
|
137 |
-
var _this = this;
|
138 |
-
this.click_test_action = function(evt) {
|
139 |
-
return _this.test_active_click(evt);
|
140 |
-
};
|
141 |
-
this.activate_action = function(evt) {
|
142 |
-
return _this.activate_field(evt);
|
143 |
-
};
|
144 |
-
this.active_field = false;
|
145 |
-
this.mouse_on_container = false;
|
146 |
-
this.results_showing = false;
|
147 |
-
this.result_highlighted = null;
|
148 |
-
this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
|
149 |
-
this.disable_search_threshold = this.options.disable_search_threshold || 0;
|
150 |
-
this.disable_search = this.options.disable_search || false;
|
151 |
-
this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
|
152 |
-
this.group_search = this.options.group_search != null ? this.options.group_search : true;
|
153 |
-
this.search_contains = this.options.search_contains || false;
|
154 |
-
this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
|
155 |
-
this.max_selected_options = this.options.max_selected_options || Infinity;
|
156 |
-
this.inherit_select_classes = this.options.inherit_select_classes || false;
|
157 |
-
this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
|
158 |
-
this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
|
159 |
-
this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
|
160 |
-
return this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
|
161 |
-
};
|
162 |
-
|
163 |
-
AbstractChosen.prototype.set_default_text = function() {
|
164 |
-
if (this.form_field.getAttribute("data-placeholder")) {
|
165 |
-
this.default_text = this.form_field.getAttribute("data-placeholder");
|
166 |
-
} else if (this.is_multiple) {
|
167 |
-
this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
|
168 |
-
} else {
|
169 |
-
this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
|
170 |
-
}
|
171 |
-
return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
|
172 |
-
};
|
173 |
-
|
174 |
-
AbstractChosen.prototype.choice_label = function(item) {
|
175 |
-
if (this.include_group_label_in_selected && (item.group_label != null)) {
|
176 |
-
return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
|
177 |
-
} else {
|
178 |
-
return item.html;
|
179 |
-
}
|
180 |
-
};
|
181 |
-
|
182 |
-
AbstractChosen.prototype.mouse_enter = function() {
|
183 |
-
return this.mouse_on_container = true;
|
184 |
-
};
|
185 |
-
|
186 |
-
AbstractChosen.prototype.mouse_leave = function() {
|
187 |
-
return this.mouse_on_container = false;
|
188 |
-
};
|
189 |
-
|
190 |
-
AbstractChosen.prototype.input_focus = function(evt) {
|
191 |
-
var _this = this;
|
192 |
-
if (this.is_multiple) {
|
193 |
-
if (!this.active_field) {
|
194 |
-
return setTimeout((function() {
|
195 |
-
return _this.container_mousedown();
|
196 |
-
}), 50);
|
197 |
-
}
|
198 |
-
} else {
|
199 |
-
if (!this.active_field) {
|
200 |
-
return this.activate_field();
|
201 |
-
}
|
202 |
-
}
|
203 |
-
};
|
204 |
-
|
205 |
-
AbstractChosen.prototype.input_blur = function(evt) {
|
206 |
-
var _this = this;
|
207 |
-
if (!this.mouse_on_container) {
|
208 |
-
this.active_field = false;
|
209 |
-
return setTimeout((function() {
|
210 |
-
return _this.blur_test();
|
211 |
-
}), 100);
|
212 |
-
}
|
213 |
-
};
|
214 |
-
|
215 |
-
AbstractChosen.prototype.results_option_build = function(options) {
|
216 |
-
var content, data, data_content, shown_results, _i, _len, _ref;
|
217 |
-
content = '';
|
218 |
-
shown_results = 0;
|
219 |
-
_ref = this.results_data;
|
220 |
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
221 |
-
data = _ref[_i];
|
222 |
-
data_content = '';
|
223 |
-
if (data.group) {
|
224 |
-
data_content = this.result_add_group(data);
|
225 |
-
} else {
|
226 |
-
data_content = this.result_add_option(data);
|
227 |
-
}
|
228 |
-
if (data_content !== '') {
|
229 |
-
shown_results++;
|
230 |
-
content += data_content;
|
231 |
-
}
|
232 |
-
if (options != null ? options.first : void 0) {
|
233 |
-
if (data.selected && this.is_multiple) {
|
234 |
-
this.choice_build(data);
|
235 |
-
} else if (data.selected && !this.is_multiple) {
|
236 |
-
this.single_set_selected_text(this.choice_label(data));
|
237 |
-
}
|
238 |
-
}
|
239 |
-
if (shown_results >= this.max_shown_results) {
|
240 |
-
break;
|
241 |
-
}
|
242 |
-
}
|
243 |
-
return content;
|
244 |
-
};
|
245 |
-
|
246 |
-
AbstractChosen.prototype.result_add_option = function(option) {
|
247 |
-
var classes, option_el;
|
248 |
-
if (!option.search_match) {
|
249 |
-
return '';
|
250 |
-
}
|
251 |
-
if (!this.include_option_in_results(option)) {
|
252 |
-
return '';
|
253 |
-
}
|
254 |
-
classes = [];
|
255 |
-
if (!option.disabled && !(option.selected && this.is_multiple)) {
|
256 |
-
classes.push("active-result");
|
257 |
-
}
|
258 |
-
if (option.disabled && !(option.selected && this.is_multiple)) {
|
259 |
-
classes.push("disabled-result");
|
260 |
-
}
|
261 |
-
if (option.selected) {
|
262 |
-
classes.push("result-selected");
|
263 |
-
}
|
264 |
-
if (option.group_array_index != null) {
|
265 |
-
classes.push("group-option");
|
266 |
-
}
|
267 |
-
if (option.classes !== "") {
|
268 |
-
classes.push(option.classes);
|
269 |
-
}
|
270 |
-
option_el = document.createElement("li");
|
271 |
-
option_el.className = classes.join(" ");
|
272 |
-
option_el.style.cssText = option.style;
|
273 |
-
option_el.setAttribute("data-option-array-index", option.array_index);
|
274 |
-
option_el.innerHTML = option.search_text;
|
275 |
-
if (option.title) {
|
276 |
-
option_el.title = option.title;
|
277 |
-
}
|
278 |
-
return this.outerHTML(option_el);
|
279 |
-
};
|
280 |
-
|
281 |
-
AbstractChosen.prototype.result_add_group = function(group) {
|
282 |
-
var classes, group_el;
|
283 |
-
if (!(group.search_match || group.group_match)) {
|
284 |
-
return '';
|
285 |
-
}
|
286 |
-
if (!(group.active_options > 0)) {
|
287 |
-
return '';
|
288 |
-
}
|
289 |
-
classes = [];
|
290 |
-
classes.push("group-result");
|
291 |
-
if (group.classes) {
|
292 |
-
classes.push(group.classes);
|
293 |
-
}
|
294 |
-
group_el = document.createElement("li");
|
295 |
-
group_el.className = classes.join(" ");
|
296 |
-
group_el.innerHTML = group.search_text;
|
297 |
-
if (group.title) {
|
298 |
-
group_el.title = group.title;
|
299 |
-
}
|
300 |
-
return this.outerHTML(group_el);
|
301 |
-
};
|
302 |
-
|
303 |
-
AbstractChosen.prototype.results_update_field = function() {
|
304 |
-
this.set_default_text();
|
305 |
-
if (!this.is_multiple) {
|
306 |
-
this.results_reset_cleanup();
|
307 |
-
}
|
308 |
-
this.result_clear_highlight();
|
309 |
-
this.results_build();
|
310 |
-
if (this.results_showing) {
|
311 |
-
return this.winnow_results();
|
312 |
-
}
|
313 |
-
};
|
314 |
-
|
315 |
-
AbstractChosen.prototype.reset_single_select_options = function() {
|
316 |
-
var result, _i, _len, _ref, _results;
|
317 |
-
_ref = this.results_data;
|
318 |
-
_results = [];
|
319 |
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
320 |
-
result = _ref[_i];
|
321 |
-
if (result.selected) {
|
322 |
-
_results.push(result.selected = false);
|
323 |
-
} else {
|
324 |
-
_results.push(void 0);
|
325 |
-
}
|
326 |
-
}
|
327 |
-
return _results;
|
328 |
-
};
|
329 |
-
|
330 |
-
AbstractChosen.prototype.results_toggle = function() {
|
331 |
-
if (this.results_showing) {
|
332 |
-
return this.results_hide();
|
333 |
-
} else {
|
334 |
-
return this.results_show();
|
335 |
-
}
|
336 |
-
};
|
337 |
-
|
338 |
-
AbstractChosen.prototype.results_search = function(evt) {
|
339 |
-
if (this.results_showing) {
|
340 |
-
return this.winnow_results();
|
341 |
-
} else {
|
342 |
-
return this.results_show();
|
343 |
-
}
|
344 |
-
};
|
345 |
-
|
346 |
-
AbstractChosen.prototype.winnow_results = function() {
|
347 |
-
var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
|
348 |
-
this.no_results_clear();
|
349 |
-
results = 0;
|
350 |
-
searchText = this.get_search_text();
|
351 |
-
escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
352 |
-
zregex = new RegExp(escapedSearchText, 'i');
|
353 |
-
regex = this.get_search_regex(escapedSearchText);
|
354 |
-
_ref = this.results_data;
|
355 |
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
356 |
-
option = _ref[_i];
|
357 |
-
option.search_match = false;
|
358 |
-
results_group = null;
|
359 |
-
if (this.include_option_in_results(option)) {
|
360 |
-
if (option.group) {
|
361 |
-
option.group_match = false;
|
362 |
-
option.active_options = 0;
|
363 |
-
}
|
364 |
-
if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
|
365 |
-
results_group = this.results_data[option.group_array_index];
|
366 |
-
if (results_group.active_options === 0 && results_group.search_match) {
|
367 |
-
results += 1;
|
368 |
-
}
|
369 |
-
results_group.active_options += 1;
|
370 |
-
}
|
371 |
-
option.search_text = option.group ? option.label : option.html;
|
372 |
-
if (!(option.group && !this.group_search)) {
|
373 |
-
option.search_match = this.search_string_match(option.search_text, regex);
|
374 |
-
if (option.search_match && !option.group) {
|
375 |
-
results += 1;
|
376 |
-
}
|
377 |
-
if (option.search_match) {
|
378 |
-
if (searchText.length) {
|
379 |
-
startpos = option.search_text.search(zregex);
|
380 |
-
text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
|
381 |
-
option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
|
382 |
-
}
|
383 |
-
if (results_group != null) {
|
384 |
-
results_group.group_match = true;
|
385 |
-
}
|
386 |
-
} else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
|
387 |
-
option.search_match = true;
|
388 |
-
}
|
389 |
-
}
|
390 |
-
}
|
391 |
-
}
|
392 |
-
this.result_clear_highlight();
|
393 |
-
if (results < 1 && searchText.length) {
|
394 |
-
this.update_results_content("");
|
395 |
-
return this.no_results(searchText);
|
396 |
-
} else {
|
397 |
-
this.update_results_content(this.results_option_build());
|
398 |
-
return this.winnow_results_set_highlight();
|
399 |
-
}
|
400 |
-
};
|
401 |
-
|
402 |
-
AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
|
403 |
-
var regex_anchor;
|
404 |
-
regex_anchor = this.search_contains ? "" : "^";
|
405 |
-
return new RegExp(regex_anchor + escaped_search_string, 'i');
|
406 |
-
};
|
407 |
-
|
408 |
-
AbstractChosen.prototype.search_string_match = function(search_string, regex) {
|
409 |
-
var part, parts, _i, _len;
|
410 |
-
if (regex.test(search_string)) {
|
411 |
-
return true;
|
412 |
-
} else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
|
413 |
-
parts = search_string.replace(/\[|\]/g, "").split(" ");
|
414 |
-
if (parts.length) {
|
415 |
-
for (_i = 0, _len = parts.length; _i < _len; _i++) {
|
416 |
-
part = parts[_i];
|
417 |
-
if (regex.test(part)) {
|
418 |
-
return true;
|
419 |
-
}
|
420 |
-
}
|
421 |
-
}
|
422 |
-
}
|
423 |
-
};
|
424 |
-
|
425 |
-
AbstractChosen.prototype.choices_count = function() {
|
426 |
-
var option, _i, _len, _ref;
|
427 |
-
if (this.selected_option_count != null) {
|
428 |
-
return this.selected_option_count;
|
429 |
-
}
|
430 |
-
this.selected_option_count = 0;
|
431 |
-
_ref = this.form_field.options;
|
432 |
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
433 |
-
option = _ref[_i];
|
434 |
-
if (option.selected) {
|
435 |
-
this.selected_option_count += 1;
|
436 |
-
}
|
437 |
-
}
|
438 |
-
return this.selected_option_count;
|
439 |
-
};
|
440 |
-
|
441 |
-
AbstractChosen.prototype.choices_click = function(evt) {
|
442 |
-
evt.preventDefault();
|
443 |
-
if (!(this.results_showing || this.is_disabled)) {
|
444 |
-
return this.results_show();
|
445 |
-
}
|
446 |
-
};
|
447 |
-
|
448 |
-
AbstractChosen.prototype.keyup_checker = function(evt) {
|
449 |
-
var stroke, _ref;
|
450 |
-
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
451 |
-
this.search_field_scale();
|
452 |
-
switch (stroke) {
|
453 |
-
case 8:
|
454 |
-
if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
|
455 |
-
return this.keydown_backstroke();
|
456 |
-
} else if (!this.pending_backstroke) {
|
457 |
-
this.result_clear_highlight();
|
458 |
-
return this.results_search();
|
459 |
-
}
|
460 |
-
break;
|
461 |
-
case 13:
|
462 |
-
evt.preventDefault();
|
463 |
-
if (this.results_showing) {
|
464 |
-
return this.result_select(evt);
|
465 |
-
}
|
466 |
-
break;
|
467 |
-
case 27:
|
468 |
-
if (this.results_showing) {
|
469 |
-
this.results_hide();
|
470 |
-
}
|
471 |
-
return true;
|
472 |
-
case 9:
|
473 |
-
case 38:
|
474 |
-
case 40:
|
475 |
-
case 16:
|
476 |
-
case 91:
|
477 |
-
case 17:
|
478 |
-
case 18:
|
479 |
-
break;
|
480 |
-
default:
|
481 |
-
return this.results_search();
|
482 |
-
}
|
483 |
-
};
|
484 |
-
|
485 |
-
AbstractChosen.prototype.clipboard_event_checker = function(evt) {
|
486 |
-
var _this = this;
|
487 |
-
return setTimeout((function() {
|
488 |
-
return _this.results_search();
|
489 |
-
}), 50);
|
490 |
-
};
|
491 |
-
|
492 |
-
AbstractChosen.prototype.container_width = function() {
|
493 |
-
if (this.options.width != null) {
|
494 |
-
return this.options.width;
|
495 |
-
} else {
|
496 |
-
return "" + this.form_field.offsetWidth + "px";
|
497 |
-
}
|
498 |
-
};
|
499 |
-
|
500 |
-
AbstractChosen.prototype.include_option_in_results = function(option) {
|
501 |
-
if (this.is_multiple && (!this.display_selected_options && option.selected)) {
|
502 |
-
return false;
|
503 |
-
}
|
504 |
-
if (!this.display_disabled_options && option.disabled) {
|
505 |
-
return false;
|
506 |
-
}
|
507 |
-
if (option.empty) {
|
508 |
-
return false;
|
509 |
-
}
|
510 |
-
return true;
|
511 |
-
};
|
512 |
-
|
513 |
-
AbstractChosen.prototype.search_results_touchstart = function(evt) {
|
514 |
-
this.touch_started = true;
|
515 |
-
return this.search_results_mouseover(evt);
|
516 |
-
};
|
517 |
-
|
518 |
-
AbstractChosen.prototype.search_results_touchmove = function(evt) {
|
519 |
-
this.touch_started = false;
|
520 |
-
return this.search_results_mouseout(evt);
|
521 |
-
};
|
522 |
-
|
523 |
-
AbstractChosen.prototype.search_results_touchend = function(evt) {
|
524 |
-
if (this.touch_started) {
|
525 |
-
return this.search_results_mouseup(evt);
|
526 |
-
}
|
527 |
-
};
|
528 |
-
|
529 |
-
AbstractChosen.prototype.outerHTML = function(element) {
|
530 |
-
var tmp;
|
531 |
-
if (element.outerHTML) {
|
532 |
-
return element.outerHTML;
|
533 |
-
}
|
534 |
-
tmp = document.createElement("div");
|
535 |
-
tmp.appendChild(element);
|
536 |
-
return tmp.innerHTML;
|
537 |
-
};
|
538 |
-
|
539 |
-
AbstractChosen.browser_is_supported = function() {
|
540 |
-
if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
|
541 |
-
return false;
|
542 |
-
}
|
543 |
-
if (/Android/i.test(window.navigator.userAgent)) {
|
544 |
-
if (/Mobile/i.test(window.navigator.userAgent)) {
|
545 |
-
return false;
|
546 |
-
}
|
547 |
-
}
|
548 |
-
if (/IEMobile/i.test(window.navigator.userAgent)) {
|
549 |
-
return false;
|
550 |
-
}
|
551 |
-
if (/Windows Phone/i.test(window.navigator.userAgent)) {
|
552 |
-
return false;
|
553 |
-
}
|
554 |
-
if (/BlackBerry/i.test(window.navigator.userAgent)) {
|
555 |
-
return false;
|
556 |
-
}
|
557 |
-
if (/BB10/i.test(window.navigator.userAgent)) {
|
558 |
-
return false;
|
559 |
-
}
|
560 |
-
if (window.navigator.appName === "Microsoft Internet Explorer") {
|
561 |
-
return document.documentMode >= 8;
|
562 |
-
}
|
563 |
-
return true;
|
564 |
-
};
|
565 |
-
|
566 |
-
AbstractChosen.default_multiple_text = "Select Some Options";
|
567 |
-
|
568 |
-
AbstractChosen.default_single_text = "Select an Option";
|
569 |
-
|
570 |
-
AbstractChosen.default_no_result_text = "No results match";
|
571 |
-
|
572 |
-
return AbstractChosen;
|
573 |
-
|
574 |
-
})();
|
575 |
-
|
576 |
-
$ = jQuery;
|
577 |
-
|
578 |
-
$.fn.extend({
|
579 |
-
chosen: function(options) {
|
580 |
-
if (!AbstractChosen.browser_is_supported()) {
|
581 |
-
return this;
|
582 |
-
}
|
583 |
-
return this.each(function(input_field) {
|
584 |
-
var $this, chosen;
|
585 |
-
$this = $(this);
|
586 |
-
chosen = $this.data('chosen');
|
587 |
-
if (options === 'destroy') {
|
588 |
-
if (chosen instanceof Chosen) {
|
589 |
-
chosen.destroy();
|
590 |
-
}
|
591 |
-
return;
|
592 |
-
}
|
593 |
-
if (!(chosen instanceof Chosen)) {
|
594 |
-
$this.data('chosen', new Chosen(this, options));
|
595 |
-
}
|
596 |
-
});
|
597 |
-
}
|
598 |
-
});
|
599 |
-
|
600 |
-
Chosen = (function(_super) {
|
601 |
-
__extends(Chosen, _super);
|
602 |
-
|
603 |
-
function Chosen() {
|
604 |
-
_ref = Chosen.__super__.constructor.apply(this, arguments);
|
605 |
-
return _ref;
|
606 |
-
}
|
607 |
-
|
608 |
-
Chosen.prototype.setup = function() {
|
609 |
-
this.form_field_jq = $(this.form_field);
|
610 |
-
this.current_selectedIndex = this.form_field.selectedIndex;
|
611 |
-
return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
|
612 |
-
};
|
613 |
-
|
614 |
-
Chosen.prototype.set_up_html = function() {
|
615 |
-
var container_classes, container_props;
|
616 |
-
container_classes = ["chosen-container"];
|
617 |
-
container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
|
618 |
-
if (this.inherit_select_classes && this.form_field.className) {
|
619 |
-
container_classes.push(this.form_field.className);
|
620 |
-
}
|
621 |
-
if (this.is_rtl) {
|
622 |
-
container_classes.push("chosen-rtl");
|
623 |
-
}
|
624 |
-
container_props = {
|
625 |
-
'class': container_classes.join(' '),
|
626 |
-
'style': "width: " + (this.container_width()) + ";",
|
627 |
-
'title': this.form_field.title
|
628 |
-
};
|
629 |
-
if (this.form_field.id.length) {
|
630 |
-
container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
|
631 |
-
}
|
632 |
-
this.container = $("<div />", container_props);
|
633 |
-
if (this.is_multiple) {
|
634 |
-
this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
|
635 |
-
} else {
|
636 |
-
this.container.html('<a class="chosen-single chosen-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
|
637 |
-
}
|
638 |
-
this.form_field_jq.hide().after(this.container);
|
639 |
-
this.dropdown = this.container.find('div.chosen-drop').first();
|
640 |
-
this.search_field = this.container.find('input').first();
|
641 |
-
this.search_results = this.container.find('ul.chosen-results').first();
|
642 |
-
this.search_field_scale();
|
643 |
-
this.search_no_results = this.container.find('li.no-results').first();
|
644 |
-
if (this.is_multiple) {
|
645 |
-
this.search_choices = this.container.find('ul.chosen-choices').first();
|
646 |
-
this.search_container = this.container.find('li.search-field').first();
|
647 |
-
} else {
|
648 |
-
this.search_container = this.container.find('div.chosen-search').first();
|
649 |
-
this.selected_item = this.container.find('.chosen-single').first();
|
650 |
-
}
|
651 |
-
this.results_build();
|
652 |
-
this.set_tab_index();
|
653 |
-
return this.set_label_behavior();
|
654 |
-
};
|
655 |
-
|
656 |
-
Chosen.prototype.on_ready = function() {
|
657 |
-
return this.form_field_jq.trigger("chosen:ready", {
|
658 |
-
chosen: this
|
659 |
-
});
|
660 |
-
};
|
661 |
-
|
662 |
-
Chosen.prototype.register_observers = function() {
|
663 |
-
var _this = this;
|
664 |
-
this.container.bind('touchstart.chosen', function(evt) {
|
665 |
-
_this.container_mousedown(evt);
|
666 |
-
return evt.preventDefault();
|
667 |
-
});
|
668 |
-
this.container.bind('touchend.chosen', function(evt) {
|
669 |
-
_this.container_mouseup(evt);
|
670 |
-
return evt.preventDefault();
|
671 |
-
});
|
672 |
-
this.container.bind('mousedown.chosen', function(evt) {
|
673 |
-
_this.container_mousedown(evt);
|
674 |
-
});
|
675 |
-
this.container.bind('mouseup.chosen', function(evt) {
|
676 |
-
_this.container_mouseup(evt);
|
677 |
-
});
|
678 |
-
this.container.bind('mouseenter.chosen', function(evt) {
|
679 |
-
_this.mouse_enter(evt);
|
680 |
-
});
|
681 |
-
this.container.bind('mouseleave.chosen', function(evt) {
|
682 |
-
_this.mouse_leave(evt);
|
683 |
-
});
|
684 |
-
this.search_results.bind('mouseup.chosen', function(evt) {
|
685 |
-
_this.search_results_mouseup(evt);
|
686 |
-
});
|
687 |
-
this.search_results.bind('mouseover.chosen', function(evt) {
|
688 |
-
_this.search_results_mouseover(evt);
|
689 |
-
});
|
690 |
-
this.search_results.bind('mouseout.chosen', function(evt) {
|
691 |
-
_this.search_results_mouseout(evt);
|
692 |
-
});
|
693 |
-
this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
|
694 |
-
_this.search_results_mousewheel(evt);
|
695 |
-
});
|
696 |
-
this.search_results.bind('touchstart.chosen', function(evt) {
|
697 |
-
_this.search_results_touchstart(evt);
|
698 |
-
});
|
699 |
-
this.search_results.bind('touchmove.chosen', function(evt) {
|
700 |
-
_this.search_results_touchmove(evt);
|
701 |
-
});
|
702 |
-
this.search_results.bind('touchend.chosen', function(evt) {
|
703 |
-
_this.search_results_touchend(evt);
|
704 |
-
});
|
705 |
-
this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
|
706 |
-
_this.results_update_field(evt);
|
707 |
-
});
|
708 |
-
this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
|
709 |
-
_this.activate_field(evt);
|
710 |
-
});
|
711 |
-
this.form_field_jq.bind("chosen:open.chosen", function(evt) {
|
712 |
-
_this.container_mousedown(evt);
|
713 |
-
});
|
714 |
-
this.form_field_jq.bind("chosen:close.chosen", function(evt) {
|
715 |
-
_this.input_blur(evt);
|
716 |
-
});
|
717 |
-
this.search_field.bind('blur.chosen', function(evt) {
|
718 |
-
_this.input_blur(evt);
|
719 |
-
});
|
720 |
-
this.search_field.bind('keyup.chosen', function(evt) {
|
721 |
-
_this.keyup_checker(evt);
|
722 |
-
});
|
723 |
-
this.search_field.bind('keydown.chosen', function(evt) {
|
724 |
-
_this.keydown_checker(evt);
|
725 |
-
});
|
726 |
-
this.search_field.bind('focus.chosen', function(evt) {
|
727 |
-
_this.input_focus(evt);
|
728 |
-
});
|
729 |
-
this.search_field.bind('cut.chosen', function(evt) {
|
730 |
-
_this.clipboard_event_checker(evt);
|
731 |
-
});
|
732 |
-
this.search_field.bind('paste.chosen', function(evt) {
|
733 |
-
_this.clipboard_event_checker(evt);
|
734 |
-
});
|
735 |
-
if (this.is_multiple) {
|
736 |
-
return this.search_choices.bind('click.chosen', function(evt) {
|
737 |
-
_this.choices_click(evt);
|
738 |
-
});
|
739 |
-
} else {
|
740 |
-
return this.container.bind('click.chosen', function(evt) {
|
741 |
-
evt.preventDefault();
|
742 |
-
});
|
743 |
-
}
|
744 |
-
};
|
745 |
-
|
746 |
-
Chosen.prototype.destroy = function() {
|
747 |
-
$(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
|
748 |
-
if (this.search_field[0].tabIndex) {
|
749 |
-
this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
|
750 |
-
}
|
751 |
-
this.container.remove();
|
752 |
-
this.form_field_jq.removeData('chosen');
|
753 |
-
return this.form_field_jq.show();
|
754 |
-
};
|
755 |
-
|
756 |
-
Chosen.prototype.search_field_disabled = function() {
|
757 |
-
this.is_disabled = this.form_field_jq[0].disabled;
|
758 |
-
if (this.is_disabled) {
|
759 |
-
this.container.addClass('chosen-disabled');
|
760 |
-
this.search_field[0].disabled = true;
|
761 |
-
if (!this.is_multiple) {
|
762 |
-
this.selected_item.unbind("focus.chosen", this.activate_action);
|
763 |
-
}
|
764 |
-
return this.close_field();
|
765 |
-
} else {
|
766 |
-
this.container.removeClass('chosen-disabled');
|
767 |
-
this.search_field[0].disabled = false;
|
768 |
-
if (!this.is_multiple) {
|
769 |
-
return this.selected_item.bind("focus.chosen", this.activate_action);
|
770 |
-
}
|
771 |
-
}
|
772 |
-
};
|
773 |
-
|
774 |
-
Chosen.prototype.container_mousedown = function(evt) {
|
775 |
-
if (!this.is_disabled) {
|
776 |
-
if (evt && evt.type === "mousedown" && !this.results_showing) {
|
777 |
-
evt.preventDefault();
|
778 |
-
}
|
779 |
-
if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
|
780 |
-
if (!this.active_field) {
|
781 |
-
if (this.is_multiple) {
|
782 |
-
this.search_field.val("");
|
783 |
-
}
|
784 |
-
$(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
|
785 |
-
this.results_show();
|
786 |
-
} else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
|
787 |
-
evt.preventDefault();
|
788 |
-
this.results_toggle();
|
789 |
-
}
|
790 |
-
return this.activate_field();
|
791 |
-
}
|
792 |
-
}
|
793 |
-
};
|
794 |
-
|
795 |
-
Chosen.prototype.container_mouseup = function(evt) {
|
796 |
-
if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
|
797 |
-
return this.results_reset(evt);
|
798 |
-
}
|
799 |
-
};
|
800 |
-
|
801 |
-
Chosen.prototype.search_results_mousewheel = function(evt) {
|
802 |
-
var delta;
|
803 |
-
if (evt.originalEvent) {
|
804 |
-
delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
|
805 |
-
}
|
806 |
-
if (delta != null) {
|
807 |
-
evt.preventDefault();
|
808 |
-
if (evt.type === 'DOMMouseScroll') {
|
809 |
-
delta = delta * 40;
|
810 |
-
}
|
811 |
-
return this.search_results.scrollTop(delta + this.search_results.scrollTop());
|
812 |
-
}
|
813 |
-
};
|
814 |
-
|
815 |
-
Chosen.prototype.blur_test = function(evt) {
|
816 |
-
if (!this.active_field && this.container.hasClass("chosen-container-active")) {
|
817 |
-
return this.close_field();
|
818 |
-
}
|
819 |
-
};
|
820 |
-
|
821 |
-
Chosen.prototype.close_field = function() {
|
822 |
-
$(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
|
823 |
-
this.active_field = false;
|
824 |
-
this.results_hide();
|
825 |
-
this.container.removeClass("chosen-container-active");
|
826 |
-
this.clear_backstroke();
|
827 |
-
this.show_search_field_default();
|
828 |
-
return this.search_field_scale();
|
829 |
-
};
|
830 |
-
|
831 |
-
Chosen.prototype.activate_field = function() {
|
832 |
-
this.container.addClass("chosen-container-active");
|
833 |
-
this.active_field = true;
|
834 |
-
this.search_field.val(this.search_field.val());
|
835 |
-
return this.search_field.focus();
|
836 |
-
};
|
837 |
-
|
838 |
-
Chosen.prototype.test_active_click = function(evt) {
|
839 |
-
var active_container;
|
840 |
-
active_container = $(evt.target).closest('.chosen-container');
|
841 |
-
if (active_container.length && this.container[0] === active_container[0]) {
|
842 |
-
return this.active_field = true;
|
843 |
-
} else {
|
844 |
-
return this.close_field();
|
845 |
-
}
|
846 |
-
};
|
847 |
-
|
848 |
-
Chosen.prototype.results_build = function() {
|
849 |
-
this.parsing = true;
|
850 |
-
this.selected_option_count = null;
|
851 |
-
this.results_data = SelectParser.select_to_array(this.form_field);
|
852 |
-
if (this.is_multiple) {
|
853 |
-
this.search_choices.find("li.search-choice").remove();
|
854 |
-
} else if (!this.is_multiple) {
|
855 |
-
this.single_set_selected_text();
|
856 |
-
if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
|
857 |
-
this.search_field[0].readOnly = true;
|
858 |
-
this.container.addClass("chosen-container-single-nosearch");
|
859 |
-
} else {
|
860 |
-
this.search_field[0].readOnly = false;
|
861 |
-
this.container.removeClass("chosen-container-single-nosearch");
|
862 |
-
}
|
863 |
-
}
|
864 |
-
this.update_results_content(this.results_option_build({
|
865 |
-
first: true
|
866 |
-
}));
|
867 |
-
this.search_field_disabled();
|
868 |
-
this.show_search_field_default();
|
869 |
-
this.search_field_scale();
|
870 |
-
return this.parsing = false;
|
871 |
-
};
|
872 |
-
|
873 |
-
Chosen.prototype.result_do_highlight = function(el) {
|
874 |
-
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
875 |
-
if (el.length) {
|
876 |
-
this.result_clear_highlight();
|
877 |
-
this.result_highlight = el;
|
878 |
-
this.result_highlight.addClass("highlighted");
|
879 |
-
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
|
880 |
-
visible_top = this.search_results.scrollTop();
|
881 |
-
visible_bottom = maxHeight + visible_top;
|
882 |
-
high_top = this.result_highlight.position().top + this.search_results.scrollTop();
|
883 |
-
high_bottom = high_top + this.result_highlight.outerHeight();
|
884 |
-
if (high_bottom >= visible_bottom) {
|
885 |
-
return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
|
886 |
-
} else if (high_top < visible_top) {
|
887 |
-
return this.search_results.scrollTop(high_top);
|
888 |
-
}
|
889 |
-
}
|
890 |
-
};
|
891 |
-
|
892 |
-
Chosen.prototype.result_clear_highlight = function() {
|
893 |
-
if (this.result_highlight) {
|
894 |
-
this.result_highlight.removeClass("highlighted");
|
895 |
-
}
|
896 |
-
return this.result_highlight = null;
|
897 |
-
};
|
898 |
-
|
899 |
-
Chosen.prototype.results_show = function() {
|
900 |
-
if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
|
901 |
-
this.form_field_jq.trigger("chosen:maxselected", {
|
902 |
-
chosen: this
|
903 |
-
});
|
904 |
-
return false;
|
905 |
-
}
|
906 |
-
this.container.addClass("chosen-with-drop");
|
907 |
-
this.results_showing = true;
|
908 |
-
this.search_field.focus();
|
909 |
-
this.search_field.val(this.search_field.val());
|
910 |
-
this.winnow_results();
|
911 |
-
return this.form_field_jq.trigger("chosen:showing_dropdown", {
|
912 |
-
chosen: this
|
913 |
-
});
|
914 |
-
};
|
915 |
-
|
916 |
-
Chosen.prototype.update_results_content = function(content) {
|
917 |
-
return this.search_results.html(content);
|
918 |
-
};
|
919 |
-
|
920 |
-
Chosen.prototype.results_hide = function() {
|
921 |
-
if (this.results_showing) {
|
922 |
-
this.result_clear_highlight();
|
923 |
-
this.container.removeClass("chosen-with-drop");
|
924 |
-
this.form_field_jq.trigger("chosen:hiding_dropdown", {
|
925 |
-
chosen: this
|
926 |
-
});
|
927 |
-
}
|
928 |
-
return this.results_showing = false;
|
929 |
-
};
|
930 |
-
|
931 |
-
Chosen.prototype.set_tab_index = function(el) {
|
932 |
-
var ti;
|
933 |
-
if (this.form_field.tabIndex) {
|
934 |
-
ti = this.form_field.tabIndex;
|
935 |
-
this.form_field.tabIndex = -1;
|
936 |
-
return this.search_field[0].tabIndex = ti;
|
937 |
-
}
|
938 |
-
};
|
939 |
-
|
940 |
-
Chosen.prototype.set_label_behavior = function() {
|
941 |
-
var _this = this;
|
942 |
-
this.form_field_label = this.form_field_jq.parents("label");
|
943 |
-
if (!this.form_field_label.length && this.form_field.id.length) {
|
944 |
-
this.form_field_label = $("label[for='" + this.form_field.id + "']");
|
945 |
-
}
|
946 |
-
if (this.form_field_label.length > 0) {
|
947 |
-
return this.form_field_label.bind('click.chosen', function(evt) {
|
948 |
-
if (_this.is_multiple) {
|
949 |
-
return _this.container_mousedown(evt);
|
950 |
-
} else {
|
951 |
-
return _this.activate_field();
|
952 |
-
}
|
953 |
-
});
|
954 |
-
}
|
955 |
-
};
|
956 |
-
|
957 |
-
Chosen.prototype.show_search_field_default = function() {
|
958 |
-
if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
|
959 |
-
this.search_field.val(this.default_text);
|
960 |
-
return this.search_field.addClass("default");
|
961 |
-
} else {
|
962 |
-
this.search_field.val("");
|
963 |
-
return this.search_field.removeClass("default");
|
964 |
-
}
|
965 |
-
};
|
966 |
-
|
967 |
-
Chosen.prototype.search_results_mouseup = function(evt) {
|
968 |
-
var target;
|
969 |
-
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
970 |
-
if (target.length) {
|
971 |
-
this.result_highlight = target;
|
972 |
-
this.result_select(evt);
|
973 |
-
return this.search_field.focus();
|
974 |
-
}
|
975 |
-
};
|
976 |
-
|
977 |
-
Chosen.prototype.search_results_mouseover = function(evt) {
|
978 |
-
var target;
|
979 |
-
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
980 |
-
if (target) {
|
981 |
-
return this.result_do_highlight(target);
|
982 |
-
}
|
983 |
-
};
|
984 |
-
|
985 |
-
Chosen.prototype.search_results_mouseout = function(evt) {
|
986 |
-
if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
|
987 |
-
return this.result_clear_highlight();
|
988 |
-
}
|
989 |
-
};
|
990 |
-
|
991 |
-
Chosen.prototype.choice_build = function(item) {
|
992 |
-
var choice, close_link,
|
993 |
-
_this = this;
|
994 |
-
choice = $('<li />', {
|
995 |
-
"class": "search-choice"
|
996 |
-
}).html("<span>" + (this.choice_label(item)) + "</span>");
|
997 |
-
if (item.disabled) {
|
998 |
-
choice.addClass('search-choice-disabled');
|
999 |
-
} else {
|
1000 |
-
close_link = $('<a />', {
|
1001 |
-
"class": 'search-choice-close',
|
1002 |
-
'data-option-array-index': item.array_index
|
1003 |
-
});
|
1004 |
-
close_link.bind('click.chosen', function(evt) {
|
1005 |
-
return _this.choice_destroy_link_click(evt);
|
1006 |
-
});
|
1007 |
-
choice.append(close_link);
|
1008 |
-
}
|
1009 |
-
return this.search_container.before(choice);
|
1010 |
-
};
|
1011 |
-
|
1012 |
-
Chosen.prototype.choice_destroy_link_click = function(evt) {
|
1013 |
-
evt.preventDefault();
|
1014 |
-
evt.stopPropagation();
|
1015 |
-
if (!this.is_disabled) {
|
1016 |
-
return this.choice_destroy($(evt.target));
|
1017 |
-
}
|
1018 |
-
};
|
1019 |
-
|
1020 |
-
Chosen.prototype.choice_destroy = function(link) {
|
1021 |
-
if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
|
1022 |
-
this.show_search_field_default();
|
1023 |
-
if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
|
1024 |
-
this.results_hide();
|
1025 |
-
}
|
1026 |
-
link.parents('li').first().remove();
|
1027 |
-
return this.search_field_scale();
|
1028 |
-
}
|
1029 |
-
};
|
1030 |
-
|
1031 |
-
Chosen.prototype.results_reset = function() {
|
1032 |
-
this.reset_single_select_options();
|
1033 |
-
this.form_field.options[0].selected = true;
|
1034 |
-
this.single_set_selected_text();
|
1035 |
-
this.show_search_field_default();
|
1036 |
-
this.results_reset_cleanup();
|
1037 |
-
this.form_field_jq.trigger("change");
|
1038 |
-
if (this.active_field) {
|
1039 |
-
return this.results_hide();
|
1040 |
-
}
|
1041 |
-
};
|
1042 |
-
|
1043 |
-
Chosen.prototype.results_reset_cleanup = function() {
|
1044 |
-
this.current_selectedIndex = this.form_field.selectedIndex;
|
1045 |
-
return this.selected_item.find("abbr").remove();
|
1046 |
-
};
|
1047 |
-
|
1048 |
-
Chosen.prototype.result_select = function(evt) {
|
1049 |
-
var high, item;
|
1050 |
-
if (this.result_highlight) {
|
1051 |
-
high = this.result_highlight;
|
1052 |
-
this.result_clear_highlight();
|
1053 |
-
if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
|
1054 |
-
this.form_field_jq.trigger("chosen:maxselected", {
|
1055 |
-
chosen: this
|
1056 |
-
});
|
1057 |
-
return false;
|
1058 |
-
}
|
1059 |
-
if (this.is_multiple) {
|
1060 |
-
high.removeClass("active-result");
|
1061 |
-
} else {
|
1062 |
-
this.reset_single_select_options();
|
1063 |
-
}
|
1064 |
-
high.addClass("result-selected");
|
1065 |
-
item = this.results_data[high[0].getAttribute("data-option-array-index")];
|
1066 |
-
item.selected = true;
|
1067 |
-
this.form_field.options[item.options_index].selected = true;
|
1068 |
-
this.selected_option_count = null;
|
1069 |
-
if (this.is_multiple) {
|
1070 |
-
this.choice_build(item);
|
1071 |
-
} else {
|
1072 |
-
this.single_set_selected_text(this.choice_label(item));
|
1073 |
-
}
|
1074 |
-
if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
|
1075 |
-
this.results_hide();
|
1076 |
-
}
|
1077 |
-
this.show_search_field_default();
|
1078 |
-
if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
|
1079 |
-
this.form_field_jq.trigger("change", {
|
1080 |
-
'selected': this.form_field.options[item.options_index].value
|
1081 |
-
});
|
1082 |
-
}
|
1083 |
-
this.current_selectedIndex = this.form_field.selectedIndex;
|
1084 |
-
evt.preventDefault();
|
1085 |
-
return this.search_field_scale();
|
1086 |
-
}
|
1087 |
-
};
|
1088 |
-
|
1089 |
-
Chosen.prototype.single_set_selected_text = function(text) {
|
1090 |
-
if (text == null) {
|
1091 |
-
text = this.default_text;
|
1092 |
-
}
|
1093 |
-
if (text === this.default_text) {
|
1094 |
-
this.selected_item.addClass("chosen-default");
|
1095 |
-
} else {
|
1096 |
-
this.single_deselect_control_build();
|
1097 |
-
this.selected_item.removeClass("chosen-default");
|
1098 |
-
}
|
1099 |
-
return this.selected_item.find("span").html(text);
|
1100 |
-
};
|
1101 |
-
|
1102 |
-
Chosen.prototype.result_deselect = function(pos) {
|
1103 |
-
var result_data;
|
1104 |
-
result_data = this.results_data[pos];
|
1105 |
-
if (!this.form_field.options[result_data.options_index].disabled) {
|
1106 |
-
result_data.selected = false;
|
1107 |
-
this.form_field.options[result_data.options_index].selected = false;
|
1108 |
-
this.selected_option_count = null;
|
1109 |
-
this.result_clear_highlight();
|
1110 |
-
if (this.results_showing) {
|
1111 |
-
this.winnow_results();
|
1112 |
-
}
|
1113 |
-
this.form_field_jq.trigger("change", {
|
1114 |
-
deselected: this.form_field.options[result_data.options_index].value
|
1115 |
-
});
|
1116 |
-
this.search_field_scale();
|
1117 |
-
return true;
|
1118 |
-
} else {
|
1119 |
-
return false;
|
1120 |
-
}
|
1121 |
-
};
|
1122 |
-
|
1123 |
-
Chosen.prototype.single_deselect_control_build = function() {
|
1124 |
-
if (!this.allow_single_deselect) {
|
1125 |
-
return;
|
1126 |
-
}
|
1127 |
-
if (!this.selected_item.find("abbr").length) {
|
1128 |
-
this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
|
1129 |
-
}
|
1130 |
-
return this.selected_item.addClass("chosen-single-with-deselect");
|
1131 |
-
};
|
1132 |
-
|
1133 |
-
Chosen.prototype.get_search_text = function() {
|
1134 |
-
return $('<div/>').text($.trim(this.search_field.val())).html();
|
1135 |
-
};
|
1136 |
-
|
1137 |
-
Chosen.prototype.winnow_results_set_highlight = function() {
|
1138 |
-
var do_high, selected_results;
|
1139 |
-
selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
|
1140 |
-
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
|
1141 |
-
if (do_high != null) {
|
1142 |
-
return this.result_do_highlight(do_high);
|
1143 |
-
}
|
1144 |
-
};
|
1145 |
-
|
1146 |
-
Chosen.prototype.no_results = function(terms) {
|
1147 |
-
var no_results_html;
|
1148 |
-
no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
|
1149 |
-
no_results_html.find("span").first().html(terms);
|
1150 |
-
this.search_results.append(no_results_html);
|
1151 |
-
return this.form_field_jq.trigger("chosen:no_results", {
|
1152 |
-
chosen: this
|
1153 |
-
});
|
1154 |
-
};
|
1155 |
-
|
1156 |
-
Chosen.prototype.no_results_clear = function() {
|
1157 |
-
return this.search_results.find(".no-results").remove();
|
1158 |
-
};
|
1159 |
-
|
1160 |
-
Chosen.prototype.keydown_arrow = function() {
|
1161 |
-
var next_sib;
|
1162 |
-
if (this.results_showing && this.result_highlight) {
|
1163 |
-
next_sib = this.result_highlight.nextAll("li.active-result").first();
|
1164 |
-
if (next_sib) {
|
1165 |
-
return this.result_do_highlight(next_sib);
|
1166 |
-
}
|
1167 |
-
} else {
|
1168 |
-
return this.results_show();
|
1169 |
-
}
|
1170 |
-
};
|
1171 |
-
|
1172 |
-
Chosen.prototype.keyup_arrow = function() {
|
1173 |
-
var prev_sibs;
|
1174 |
-
if (!this.results_showing && !this.is_multiple) {
|
1175 |
-
return this.results_show();
|
1176 |
-
} else if (this.result_highlight) {
|
1177 |
-
prev_sibs = this.result_highlight.prevAll("li.active-result");
|
1178 |
-
if (prev_sibs.length) {
|
1179 |
-
return this.result_do_highlight(prev_sibs.first());
|
1180 |
-
} else {
|
1181 |
-
if (this.choices_count() > 0) {
|
1182 |
-
this.results_hide();
|
1183 |
-
}
|
1184 |
-
return this.result_clear_highlight();
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
};
|
1188 |
-
|
1189 |
-
Chosen.prototype.keydown_backstroke = function() {
|
1190 |
-
var next_available_destroy;
|
1191 |
-
if (this.pending_backstroke) {
|
1192 |
-
this.choice_destroy(this.pending_backstroke.find("a").first());
|
1193 |
-
return this.clear_backstroke();
|
1194 |
-
} else {
|
1195 |
-
next_available_destroy = this.search_container.siblings("li.search-choice").last();
|
1196 |
-
if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
|
1197 |
-
this.pending_backstroke = next_available_destroy;
|
1198 |
-
if (this.single_backstroke_delete) {
|
1199 |
-
return this.keydown_backstroke();
|
1200 |
-
} else {
|
1201 |
-
return this.pending_backstroke.addClass("search-choice-focus");
|
1202 |
-
}
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
};
|
1206 |
-
|
1207 |
-
Chosen.prototype.clear_backstroke = function() {
|
1208 |
-
if (this.pending_backstroke) {
|
1209 |
-
this.pending_backstroke.removeClass("search-choice-focus");
|
1210 |
-
}
|
1211 |
-
return this.pending_backstroke = null;
|
1212 |
-
};
|
1213 |
-
|
1214 |
-
Chosen.prototype.keydown_checker = function(evt) {
|
1215 |
-
var stroke, _ref1;
|
1216 |
-
stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
|
1217 |
-
this.search_field_scale();
|
1218 |
-
if (stroke !== 8 && this.pending_backstroke) {
|
1219 |
-
this.clear_backstroke();
|
1220 |
-
}
|
1221 |
-
switch (stroke) {
|
1222 |
-
case 8:
|
1223 |
-
this.backstroke_length = this.search_field.val().length;
|
1224 |
-
break;
|
1225 |
-
case 9:
|
1226 |
-
if (this.results_showing && !this.is_multiple) {
|
1227 |
-
this.result_select(evt);
|
1228 |
-
}
|
1229 |
-
this.mouse_on_container = false;
|
1230 |
-
break;
|
1231 |
-
case 13:
|
1232 |
-
if (this.results_showing) {
|
1233 |
-
evt.preventDefault();
|
1234 |
-
}
|
1235 |
-
break;
|
1236 |
-
case 32:
|
1237 |
-
if (this.disable_search) {
|
1238 |
-
evt.preventDefault();
|
1239 |
-
}
|
1240 |
-
break;
|
1241 |
-
case 38:
|
1242 |
-
evt.preventDefault();
|
1243 |
-
this.keyup_arrow();
|
1244 |
-
break;
|
1245 |
-
case 40:
|
1246 |
-
evt.preventDefault();
|
1247 |
-
this.keydown_arrow();
|
1248 |
-
break;
|
1249 |
-
}
|
1250 |
-
};
|
1251 |
-
|
1252 |
-
Chosen.prototype.search_field_scale = function() {
|
1253 |
-
var div, f_width, h, style, style_block, styles, w, _i, _len;
|
1254 |
-
if (this.is_multiple) {
|
1255 |
-
h = 0;
|
1256 |
-
w = 0;
|
1257 |
-
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
|
1258 |
-
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
|
1259 |
-
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
1260 |
-
style = styles[_i];
|
1261 |
-
style_block += style + ":" + this.search_field.css(style) + ";";
|
1262 |
-
}
|
1263 |
-
div = $('<div />', {
|
1264 |
-
'style': style_block
|
1265 |
-
});
|
1266 |
-
div.text(this.search_field.val());
|
1267 |
-
$('body').append(div);
|
1268 |
-
w = div.width() + 25;
|
1269 |
-
div.remove();
|
1270 |
-
f_width = this.container.outerWidth();
|
1271 |
-
if (w > f_width - 10) {
|
1272 |
-
w = f_width - 10;
|
1273 |
-
}
|
1274 |
-
return this.search_field.css({
|
1275 |
-
'width': w + 'px'
|
1276 |
-
});
|
1277 |
-
}
|
1278 |
-
};
|
1279 |
-
|
1280 |
-
return Chosen;
|
1281 |
-
|
1282 |
-
})(AbstractChosen);
|
1283 |
-
|
1284 |
-
}).call(this);
|
1 |
+
/*!
|
2 |
+
Chosen, a Select Box Enhancer for jQuery and Prototype
|
3 |
+
by Patrick Filler for Harvest, http://getharvest.com
|
4 |
+
|
5 |
+
Version 1.5.1
|
6 |
+
Full source at https://github.com/harvesthq/chosen
|
7 |
+
Copyright (c) 2011-2016 Harvest http://getharvest.com
|
8 |
+
|
9 |
+
MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
|
10 |
+
This file is generated by `grunt build`, do not edit it by hand.
|
11 |
+
*/
|
12 |
+
|
13 |
+
(function() {
|
14 |
+
var $, AbstractChosen, Chosen, SelectParser, _ref,
|
15 |
+
__hasProp = {}.hasOwnProperty,
|
16 |
+
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
17 |
+
|
18 |
+
SelectParser = (function() {
|
19 |
+
function SelectParser() {
|
20 |
+
this.options_index = 0;
|
21 |
+
this.parsed = [];
|
22 |
+
}
|
23 |
+
|
24 |
+
SelectParser.prototype.add_node = function(child) {
|
25 |
+
if (child.nodeName.toUpperCase() === "OPTGROUP") {
|
26 |
+
return this.add_group(child);
|
27 |
+
} else {
|
28 |
+
return this.add_option(child);
|
29 |
+
}
|
30 |
+
};
|
31 |
+
|
32 |
+
SelectParser.prototype.add_group = function(group) {
|
33 |
+
var group_position, option, _i, _len, _ref, _results;
|
34 |
+
group_position = this.parsed.length;
|
35 |
+
this.parsed.push({
|
36 |
+
array_index: group_position,
|
37 |
+
group: true,
|
38 |
+
label: this.escapeExpression(group.label),
|
39 |
+
title: group.title ? group.title : void 0,
|
40 |
+
children: 0,
|
41 |
+
disabled: group.disabled,
|
42 |
+
classes: group.className
|
43 |
+
});
|
44 |
+
_ref = group.childNodes;
|
45 |
+
_results = [];
|
46 |
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
47 |
+
option = _ref[_i];
|
48 |
+
_results.push(this.add_option(option, group_position, group.disabled));
|
49 |
+
}
|
50 |
+
return _results;
|
51 |
+
};
|
52 |
+
|
53 |
+
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
|
54 |
+
if (option.nodeName.toUpperCase() === "OPTION") {
|
55 |
+
if (option.text !== "") {
|
56 |
+
if (group_position != null) {
|
57 |
+
this.parsed[group_position].children += 1;
|
58 |
+
}
|
59 |
+
this.parsed.push({
|
60 |
+
array_index: this.parsed.length,
|
61 |
+
options_index: this.options_index,
|
62 |
+
value: option.value,
|
63 |
+
text: option.text,
|
64 |
+
html: option.innerHTML,
|
65 |
+
title: option.title ? option.title : void 0,
|
66 |
+
selected: option.selected,
|
67 |
+
disabled: group_disabled === true ? group_disabled : option.disabled,
|
68 |
+
group_array_index: group_position,
|
69 |
+
group_label: group_position != null ? this.parsed[group_position].label : null,
|
70 |
+
classes: option.className,
|
71 |
+
style: option.style.cssText
|
72 |
+
});
|
73 |
+
} else {
|
74 |
+
this.parsed.push({
|
75 |
+
array_index: this.parsed.length,
|
76 |
+
options_index: this.options_index,
|
77 |
+
empty: true
|
78 |
+
});
|
79 |
+
}
|
80 |
+
return this.options_index += 1;
|
81 |
+
}
|
82 |
+
};
|
83 |
+
|
84 |
+
SelectParser.prototype.escapeExpression = function(text) {
|
85 |
+
var map, unsafe_chars;
|
86 |
+
if ((text == null) || text === false) {
|
87 |
+
return "";
|
88 |
+
}
|
89 |
+
if (!/[\&\<\>\"\'\`]/.test(text)) {
|
90 |
+
return text;
|
91 |
+
}
|
92 |
+
map = {
|
93 |
+
"<": "<",
|
94 |
+
">": ">",
|
95 |
+
'"': """,
|
96 |
+
"'": "'",
|
97 |
+
"`": "`"
|
98 |
+
};
|
99 |
+
unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
|
100 |
+
return text.replace(unsafe_chars, function(chr) {
|
101 |
+
return map[chr] || "&";
|
102 |
+
});
|
103 |
+
};
|
104 |
+
|
105 |
+
return SelectParser;
|
106 |
+
|
107 |
+
})();
|
108 |
+
|
109 |
+
SelectParser.select_to_array = function(select) {
|
110 |
+
var child, parser, _i, _len, _ref;
|
111 |
+
parser = new SelectParser();
|
112 |
+
_ref = select.childNodes;
|
113 |
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
114 |
+
child = _ref[_i];
|
115 |
+
parser.add_node(child);
|
116 |
+
}
|
117 |
+
return parser.parsed;
|
118 |
+
};
|
119 |
+
|
120 |
+
AbstractChosen = (function() {
|
121 |
+
function AbstractChosen(form_field, options) {
|
122 |
+
this.form_field = form_field;
|
123 |
+
this.options = options != null ? options : {};
|
124 |
+
if (!AbstractChosen.browser_is_supported()) {
|
125 |
+
return;
|
126 |
+
}
|
127 |
+
this.is_multiple = this.form_field.multiple;
|
128 |
+
this.set_default_text();
|
129 |
+
this.set_default_values();
|
130 |
+
this.setup();
|
131 |
+
this.set_up_html();
|
132 |
+
this.register_observers();
|
133 |
+
this.on_ready();
|
134 |
+
}
|
135 |
+
|
136 |
+
AbstractChosen.prototype.set_default_values = function() {
|
137 |
+
var _this = this;
|
138 |
+
this.click_test_action = function(evt) {
|
139 |
+
return _this.test_active_click(evt);
|
140 |
+
};
|
141 |
+
this.activate_action = function(evt) {
|
142 |
+
return _this.activate_field(evt);
|
143 |
+
};
|
144 |
+
this.active_field = false;
|
145 |
+
this.mouse_on_container = false;
|
146 |
+
this.results_showing = false;
|
147 |
+
this.result_highlighted = null;
|
148 |
+
this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
|
149 |
+
this.disable_search_threshold = this.options.disable_search_threshold || 0;
|
150 |
+
this.disable_search = this.options.disable_search || false;
|
151 |
+
this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
|
152 |
+
this.group_search = this.options.group_search != null ? this.options.group_search : true;
|
153 |
+
this.search_contains = this.options.search_contains || false;
|
154 |
+
this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
|
155 |
+
this.max_selected_options = this.options.max_selected_options || Infinity;
|
156 |
+
this.inherit_select_classes = this.options.inherit_select_classes || false;
|
157 |
+
this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
|
158 |
+
this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
|
159 |
+
this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
|
160 |
+
return this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
|
161 |
+
};
|
162 |
+
|
163 |
+
AbstractChosen.prototype.set_default_text = function() {
|
164 |
+
if (this.form_field.getAttribute("data-placeholder")) {
|
165 |
+
this.default_text = this.form_field.getAttribute("data-placeholder");
|
166 |
+
} else if (this.is_multiple) {
|
167 |
+
this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
|
168 |
+
} else {
|
169 |
+
this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
|
170 |
+
}
|
171 |
+
return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
|
172 |
+
};
|
173 |
+
|
174 |
+
AbstractChosen.prototype.choice_label = function(item) {
|
175 |
+
if (this.include_group_label_in_selected && (item.group_label != null)) {
|
176 |
+
return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
|
177 |
+
} else {
|
178 |
+
return item.html;
|
179 |
+
}
|
180 |
+
};
|
181 |
+
|
182 |
+
AbstractChosen.prototype.mouse_enter = function() {
|
183 |
+
return this.mouse_on_container = true;
|
184 |
+
};
|
185 |
+
|
186 |
+
AbstractChosen.prototype.mouse_leave = function() {
|
187 |
+
return this.mouse_on_container = false;
|
188 |
+
};
|
189 |
+
|
190 |
+
AbstractChosen.prototype.input_focus = function(evt) {
|
191 |
+
var _this = this;
|
192 |
+
if (this.is_multiple) {
|
193 |
+
if (!this.active_field) {
|
194 |
+
return setTimeout((function() {
|
195 |
+
return _this.container_mousedown();
|
196 |
+
}), 50);
|
197 |
+
}
|
198 |
+
} else {
|
199 |
+
if (!this.active_field) {
|
200 |
+
return this.activate_field();
|
201 |
+
}
|
202 |
+
}
|
203 |
+
};
|
204 |
+
|
205 |
+
AbstractChosen.prototype.input_blur = function(evt) {
|
206 |
+
var _this = this;
|
207 |
+
if (!this.mouse_on_container) {
|
208 |
+
this.active_field = false;
|
209 |
+
return setTimeout((function() {
|
210 |
+
return _this.blur_test();
|
211 |
+
}), 100);
|
212 |
+
}
|
213 |
+
};
|
214 |
+
|
215 |
+
AbstractChosen.prototype.results_option_build = function(options) {
|
216 |
+
var content, data, data_content, shown_results, _i, _len, _ref;
|
217 |
+
content = '';
|
218 |
+
shown_results = 0;
|
219 |
+
_ref = this.results_data;
|
220 |
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
221 |
+
data = _ref[_i];
|
222 |
+
data_content = '';
|
223 |
+
if (data.group) {
|
224 |
+
data_content = this.result_add_group(data);
|
225 |
+
} else {
|
226 |
+
data_content = this.result_add_option(data);
|
227 |
+
}
|
228 |
+
if (data_content !== '') {
|
229 |
+
shown_results++;
|
230 |
+
content += data_content;
|
231 |
+
}
|
232 |
+
if (options != null ? options.first : void 0) {
|
233 |
+
if (data.selected && this.is_multiple) {
|
234 |
+
this.choice_build(data);
|
235 |
+
} else if (data.selected && !this.is_multiple) {
|
236 |
+
this.single_set_selected_text(this.choice_label(data));
|
237 |
+
}
|
238 |
+
}
|
239 |
+
if (shown_results >= this.max_shown_results) {
|
240 |
+
break;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
return content;
|
244 |
+
};
|
245 |
+
|
246 |
+
AbstractChosen.prototype.result_add_option = function(option) {
|
247 |
+
var classes, option_el;
|
248 |
+
if (!option.search_match) {
|
249 |
+
return '';
|
250 |
+
}
|
251 |
+
if (!this.include_option_in_results(option)) {
|
252 |
+
return '';
|
253 |
+
}
|
254 |
+
classes = [];
|
255 |
+
if (!option.disabled && !(option.selected && this.is_multiple)) {
|
256 |
+
classes.push("active-result");
|
257 |
+
}
|
258 |
+
if (option.disabled && !(option.selected && this.is_multiple)) {
|
259 |
+
classes.push("disabled-result");
|
260 |
+
}
|
261 |
+
if (option.selected) {
|
262 |
+
classes.push("result-selected");
|
263 |
+
}
|
264 |
+
if (option.group_array_index != null) {
|
265 |
+
classes.push("group-option");
|
266 |
+
}
|
267 |
+
if (option.classes !== "") {
|
268 |
+
classes.push(option.classes);
|
269 |
+
}
|
270 |
+
option_el = document.createElement("li");
|
271 |
+
option_el.className = classes.join(" ");
|
272 |
+
option_el.style.cssText = option.style;
|
273 |
+
option_el.setAttribute("data-option-array-index", option.array_index);
|
274 |
+
option_el.innerHTML = option.search_text;
|
275 |
+
if (option.title) {
|
276 |
+
option_el.title = option.title;
|
277 |
+
}
|
278 |
+
return this.outerHTML(option_el);
|
279 |
+
};
|
280 |
+
|
281 |
+
AbstractChosen.prototype.result_add_group = function(group) {
|
282 |
+
var classes, group_el;
|
283 |
+
if (!(group.search_match || group.group_match)) {
|
284 |
+
return '';
|
285 |
+
}
|
286 |
+
if (!(group.active_options > 0)) {
|
287 |
+
return '';
|
288 |
+
}
|
289 |
+
classes = [];
|
290 |
+
classes.push("group-result");
|
291 |
+
if (group.classes) {
|
292 |
+
classes.push(group.classes);
|
293 |
+
}
|
294 |
+
group_el = document.createElement("li");
|
295 |
+
group_el.className = classes.join(" ");
|
296 |
+
group_el.innerHTML = group.search_text;
|
297 |
+
if (group.title) {
|
298 |
+
group_el.title = group.title;
|
299 |
+
}
|
300 |
+
return this.outerHTML(group_el);
|
301 |
+
};
|
302 |
+
|
303 |
+
AbstractChosen.prototype.results_update_field = function() {
|
304 |
+
this.set_default_text();
|
305 |
+
if (!this.is_multiple) {
|
306 |
+
this.results_reset_cleanup();
|
307 |
+
}
|
308 |
+
this.result_clear_highlight();
|
309 |
+
this.results_build();
|
310 |
+
if (this.results_showing) {
|
311 |
+
return this.winnow_results();
|
312 |
+
}
|
313 |
+
};
|
314 |
+
|
315 |
+
AbstractChosen.prototype.reset_single_select_options = function() {
|
316 |
+
var result, _i, _len, _ref, _results;
|
317 |
+
_ref = this.results_data;
|
318 |
+
_results = [];
|
319 |
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
320 |
+
result = _ref[_i];
|
321 |
+
if (result.selected) {
|
322 |
+
_results.push(result.selected = false);
|
323 |
+
} else {
|
324 |
+
_results.push(void 0);
|
325 |
+
}
|
326 |
+
}
|
327 |
+
return _results;
|
328 |
+
};
|
329 |
+
|
330 |
+
AbstractChosen.prototype.results_toggle = function() {
|
331 |
+
if (this.results_showing) {
|
332 |
+
return this.results_hide();
|
333 |
+
} else {
|
334 |
+
return this.results_show();
|
335 |
+
}
|
336 |
+
};
|
337 |
+
|
338 |
+
AbstractChosen.prototype.results_search = function(evt) {
|
339 |
+
if (this.results_showing) {
|
340 |
+
return this.winnow_results();
|
341 |
+
} else {
|
342 |
+
return this.results_show();
|
343 |
+
}
|
344 |
+
};
|
345 |
+
|
346 |
+
AbstractChosen.prototype.winnow_results = function() {
|
347 |
+
var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
|
348 |
+
this.no_results_clear();
|
349 |
+
results = 0;
|
350 |
+
searchText = this.get_search_text();
|
351 |
+
escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
352 |
+
zregex = new RegExp(escapedSearchText, 'i');
|
353 |
+
regex = this.get_search_regex(escapedSearchText);
|
354 |
+
_ref = this.results_data;
|
355 |
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
356 |
+
option = _ref[_i];
|
357 |
+
option.search_match = false;
|
358 |
+
results_group = null;
|
359 |
+
if (this.include_option_in_results(option)) {
|
360 |
+
if (option.group) {
|
361 |
+
option.group_match = false;
|
362 |
+
option.active_options = 0;
|
363 |
+
}
|
364 |
+
if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
|
365 |
+
results_group = this.results_data[option.group_array_index];
|
366 |
+
if (results_group.active_options === 0 && results_group.search_match) {
|
367 |
+
results += 1;
|
368 |
+
}
|
369 |
+
results_group.active_options += 1;
|
370 |
+
}
|
371 |
+
option.search_text = option.group ? option.label : option.html;
|
372 |
+
if (!(option.group && !this.group_search)) {
|
373 |
+
option.search_match = this.search_string_match(option.search_text, regex);
|
374 |
+
if (option.search_match && !option.group) {
|
375 |
+
results += 1;
|
376 |
+
}
|
377 |
+
if (option.search_match) {
|
378 |
+
if (searchText.length) {
|
379 |
+
startpos = option.search_text.search(zregex);
|
380 |
+
text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
|
381 |
+
option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
|
382 |
+
}
|
383 |
+
if (results_group != null) {
|
384 |
+
results_group.group_match = true;
|
385 |
+
}
|
386 |
+
} else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
|
387 |
+
option.search_match = true;
|
388 |
+
}
|
389 |
+
}
|
390 |
+
}
|
391 |
+
}
|
392 |
+
this.result_clear_highlight();
|
393 |
+
if (results < 1 && searchText.length) {
|
394 |
+
this.update_results_content("");
|
395 |
+
return this.no_results(searchText);
|
396 |
+
} else {
|
397 |
+
this.update_results_content(this.results_option_build());
|
398 |
+
return this.winnow_results_set_highlight();
|
399 |
+
}
|
400 |
+
};
|
401 |
+
|
402 |
+
AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
|
403 |
+
var regex_anchor;
|
404 |
+
regex_anchor = this.search_contains ? "" : "^";
|
405 |
+
return new RegExp(regex_anchor + escaped_search_string, 'i');
|
406 |
+
};
|
407 |
+
|
408 |
+
AbstractChosen.prototype.search_string_match = function(search_string, regex) {
|
409 |
+
var part, parts, _i, _len;
|
410 |
+
if (regex.test(search_string)) {
|
411 |
+
return true;
|
412 |
+
} else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
|
413 |
+
parts = search_string.replace(/\[|\]/g, "").split(" ");
|
414 |
+
if (parts.length) {
|
415 |
+
for (_i = 0, _len = parts.length; _i < _len; _i++) {
|
416 |
+
part = parts[_i];
|
417 |
+
if (regex.test(part)) {
|
418 |
+
return true;
|
419 |
+
}
|
420 |
+
}
|
421 |
+
}
|
422 |
+
}
|
423 |
+
};
|
424 |
+
|
425 |
+
AbstractChosen.prototype.choices_count = function() {
|
426 |
+
var option, _i, _len, _ref;
|
427 |
+
if (this.selected_option_count != null) {
|
428 |
+
return this.selected_option_count;
|
429 |
+
}
|
430 |
+
this.selected_option_count = 0;
|
431 |
+
_ref = this.form_field.options;
|
432 |
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
433 |
+
option = _ref[_i];
|
434 |
+
if (option.selected) {
|
435 |
+
this.selected_option_count += 1;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
return this.selected_option_count;
|
439 |
+
};
|
440 |
+
|
441 |
+
AbstractChosen.prototype.choices_click = function(evt) {
|
442 |
+
evt.preventDefault();
|
443 |
+
if (!(this.results_showing || this.is_disabled)) {
|
444 |
+
return this.results_show();
|
445 |
+
}
|
446 |
+
};
|
447 |
+
|
448 |
+
AbstractChosen.prototype.keyup_checker = function(evt) {
|
449 |
+
var stroke, _ref;
|
450 |
+
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
451 |
+
this.search_field_scale();
|
452 |
+
switch (stroke) {
|
453 |
+
case 8:
|
454 |
+
if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
|
455 |
+
return this.keydown_backstroke();
|
456 |
+
} else if (!this.pending_backstroke) {
|
457 |
+
this.result_clear_highlight();
|
458 |
+
return this.results_search();
|
459 |
+
}
|
460 |
+
break;
|
461 |
+
case 13:
|
462 |
+
evt.preventDefault();
|
463 |
+
if (this.results_showing) {
|
464 |
+
return this.result_select(evt);
|
465 |
+
}
|
466 |
+
break;
|
467 |
+
case 27:
|
468 |
+
if (this.results_showing) {
|
469 |
+
this.results_hide();
|
470 |
+
}
|
471 |
+
return true;
|
472 |
+
case 9:
|
473 |
+
case 38:
|
474 |
+
case 40:
|
475 |
+
case 16:
|
476 |
+
case 91:
|
477 |
+
case 17:
|
478 |
+
case 18:
|
479 |
+
break;
|
480 |
+
default:
|
481 |
+
return this.results_search();
|
482 |
+
}
|
483 |
+
};
|
484 |
+
|
485 |
+
AbstractChosen.prototype.clipboard_event_checker = function(evt) {
|
486 |
+
var _this = this;
|
487 |
+
return setTimeout((function() {
|
488 |
+
return _this.results_search();
|
489 |
+
}), 50);
|
490 |
+
};
|
491 |
+
|
492 |
+
AbstractChosen.prototype.container_width = function() {
|
493 |
+
if (this.options.width != null) {
|
494 |
+
return this.options.width;
|
495 |
+
} else {
|
496 |
+
return "" + this.form_field.offsetWidth + "px";
|
497 |
+
}
|
498 |
+
};
|
499 |
+
|
500 |
+
AbstractChosen.prototype.include_option_in_results = function(option) {
|
501 |
+
if (this.is_multiple && (!this.display_selected_options && option.selected)) {
|
502 |
+
return false;
|
503 |
+
}
|
504 |
+
if (!this.display_disabled_options && option.disabled) {
|
505 |
+
return false;
|
506 |
+
}
|
507 |
+
if (option.empty) {
|
508 |
+
return false;
|
509 |
+
}
|
510 |
+
return true;
|
511 |
+
};
|
512 |
+
|
513 |
+
AbstractChosen.prototype.search_results_touchstart = function(evt) {
|
514 |
+
this.touch_started = true;
|
515 |
+
return this.search_results_mouseover(evt);
|
516 |
+
};
|
517 |
+
|
518 |
+
AbstractChosen.prototype.search_results_touchmove = function(evt) {
|
519 |
+
this.touch_started = false;
|
520 |
+
return this.search_results_mouseout(evt);
|
521 |
+
};
|
522 |
+
|
523 |
+
AbstractChosen.prototype.search_results_touchend = function(evt) {
|
524 |
+
if (this.touch_started) {
|
525 |
+
return this.search_results_mouseup(evt);
|
526 |
+
}
|
527 |
+
};
|
528 |
+
|
529 |
+
AbstractChosen.prototype.outerHTML = function(element) {
|
530 |
+
var tmp;
|
531 |
+
if (element.outerHTML) {
|
532 |
+
return element.outerHTML;
|
533 |
+
}
|
534 |
+
tmp = document.createElement("div");
|
535 |
+
tmp.appendChild(element);
|
536 |
+
return tmp.innerHTML;
|
537 |
+
};
|
538 |
+
|
539 |
+
AbstractChosen.browser_is_supported = function() {
|
540 |
+
if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
|
541 |
+
return false;
|
542 |
+
}
|
543 |
+
if (/Android/i.test(window.navigator.userAgent)) {
|
544 |
+
if (/Mobile/i.test(window.navigator.userAgent)) {
|
545 |
+
return false;
|
546 |
+
}
|
547 |
+
}
|
548 |
+
if (/IEMobile/i.test(window.navigator.userAgent)) {
|
549 |
+
return false;
|
550 |
+
}
|
551 |
+
if (/Windows Phone/i.test(window.navigator.userAgent)) {
|
552 |
+
return false;
|
553 |
+
}
|
554 |
+
if (/BlackBerry/i.test(window.navigator.userAgent)) {
|
555 |
+
return false;
|
556 |
+
}
|
557 |
+
if (/BB10/i.test(window.navigator.userAgent)) {
|
558 |
+
return false;
|
559 |
+
}
|
560 |
+
if (window.navigator.appName === "Microsoft Internet Explorer") {
|
561 |
+
return document.documentMode >= 8;
|
562 |
+
}
|
563 |
+
return true;
|
564 |
+
};
|
565 |
+
|
566 |
+
AbstractChosen.default_multiple_text = "Select Some Options";
|
567 |
+
|
568 |
+
AbstractChosen.default_single_text = "Select an Option";
|
569 |
+
|
570 |
+
AbstractChosen.default_no_result_text = "No results match";
|
571 |
+
|
572 |
+
return AbstractChosen;
|
573 |
+
|
574 |
+
})();
|
575 |
+
|
576 |
+
$ = jQuery;
|
577 |
+
|
578 |
+
$.fn.extend({
|
579 |
+
chosen: function(options) {
|
580 |
+
if (!AbstractChosen.browser_is_supported()) {
|
581 |
+
return this;
|
582 |
+
}
|
583 |
+
return this.each(function(input_field) {
|
584 |
+
var $this, chosen;
|
585 |
+
$this = $(this);
|
586 |
+
chosen = $this.data('chosen');
|
587 |
+
if (options === 'destroy') {
|
588 |
+
if (chosen instanceof Chosen) {
|
589 |
+
chosen.destroy();
|
590 |
+
}
|
591 |
+
return;
|
592 |
+
}
|
593 |
+
if (!(chosen instanceof Chosen)) {
|
594 |
+
$this.data('chosen', new Chosen(this, options));
|
595 |
+
}
|
596 |
+
});
|
597 |
+
}
|
598 |
+
});
|
599 |
+
|
600 |
+
Chosen = (function(_super) {
|
601 |
+
__extends(Chosen, _super);
|
602 |
+
|
603 |
+
function Chosen() {
|
604 |
+
_ref = Chosen.__super__.constructor.apply(this, arguments);
|
605 |
+
return _ref;
|
606 |
+
}
|
607 |
+
|
608 |
+
Chosen.prototype.setup = function() {
|
609 |
+
this.form_field_jq = $(this.form_field);
|
610 |
+
this.current_selectedIndex = this.form_field.selectedIndex;
|
611 |
+
return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
|
612 |
+
};
|
613 |
+
|
614 |
+
Chosen.prototype.set_up_html = function() {
|
615 |
+
var container_classes, container_props;
|
616 |
+
container_classes = ["chosen-container"];
|
617 |
+
container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
|
618 |
+
if (this.inherit_select_classes && this.form_field.className) {
|
619 |
+
container_classes.push(this.form_field.className);
|
620 |
+
}
|
621 |
+
if (this.is_rtl) {
|
622 |
+
container_classes.push("chosen-rtl");
|
623 |
+
}
|
624 |
+
container_props = {
|
625 |
+
'class': container_classes.join(' '),
|
626 |
+
'style': "width: " + (this.container_width()) + ";",
|
627 |
+
'title': this.form_field.title
|
628 |
+
};
|
629 |
+
if (this.form_field.id.length) {
|
630 |
+
container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
|
631 |
+
}
|
632 |
+
this.container = $("<div />", container_props);
|
633 |
+
if (this.is_multiple) {
|
634 |
+
this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
|
635 |
+
} else {
|
636 |
+
this.container.html('<a class="chosen-single chosen-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
|
637 |
+
}
|
638 |
+
this.form_field_jq.hide().after(this.container);
|
639 |
+
this.dropdown = this.container.find('div.chosen-drop').first();
|
640 |
+
this.search_field = this.container.find('input').first();
|
641 |
+
this.search_results = this.container.find('ul.chosen-results').first();
|
642 |
+
this.search_field_scale();
|
643 |
+
this.search_no_results = this.container.find('li.no-results').first();
|
644 |
+
if (this.is_multiple) {
|
645 |
+
this.search_choices = this.container.find('ul.chosen-choices').first();
|
646 |
+
this.search_container = this.container.find('li.search-field').first();
|
647 |
+
} else {
|
648 |
+
this.search_container = this.container.find('div.chosen-search').first();
|
649 |
+
this.selected_item = this.container.find('.chosen-single').first();
|
650 |
+
}
|
651 |
+
this.results_build();
|
652 |
+
this.set_tab_index();
|
653 |
+
return this.set_label_behavior();
|
654 |
+
};
|
655 |
+
|
656 |
+
Chosen.prototype.on_ready = function() {
|
657 |
+
return this.form_field_jq.trigger("chosen:ready", {
|
658 |
+
chosen: this
|
659 |
+
});
|
660 |
+
};
|
661 |
+
|
662 |
+
Chosen.prototype.register_observers = function() {
|
663 |
+
var _this = this;
|
664 |
+
this.container.bind('touchstart.chosen', function(evt) {
|
665 |
+
_this.container_mousedown(evt);
|
666 |
+
return evt.preventDefault();
|
667 |
+
});
|
668 |
+
this.container.bind('touchend.chosen', function(evt) {
|
669 |
+
_this.container_mouseup(evt);
|
670 |
+
return evt.preventDefault();
|
671 |
+
});
|
672 |
+
this.container.bind('mousedown.chosen', function(evt) {
|
673 |
+
_this.container_mousedown(evt);
|
674 |
+
});
|
675 |
+
this.container.bind('mouseup.chosen', function(evt) {
|
676 |
+
_this.container_mouseup(evt);
|
677 |
+
});
|
678 |
+
this.container.bind('mouseenter.chosen', function(evt) {
|
679 |
+
_this.mouse_enter(evt);
|
680 |
+
});
|
681 |
+
this.container.bind('mouseleave.chosen', function(evt) {
|
682 |
+
_this.mouse_leave(evt);
|
683 |
+
});
|
684 |
+
this.search_results.bind('mouseup.chosen', function(evt) {
|
685 |
+
_this.search_results_mouseup(evt);
|
686 |
+
});
|
687 |
+
this.search_results.bind('mouseover.chosen', function(evt) {
|
688 |
+
_this.search_results_mouseover(evt);
|
689 |
+
});
|
690 |
+
this.search_results.bind('mouseout.chosen', function(evt) {
|
691 |
+
_this.search_results_mouseout(evt);
|
692 |
+
});
|
693 |
+
this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
|
694 |
+
_this.search_results_mousewheel(evt);
|
695 |
+
});
|
696 |
+
this.search_results.bind('touchstart.chosen', function(evt) {
|
697 |
+
_this.search_results_touchstart(evt);
|
698 |
+
});
|
699 |
+
this.search_results.bind('touchmove.chosen', function(evt) {
|
700 |
+
_this.search_results_touchmove(evt);
|
701 |
+
});
|
702 |
+
this.search_results.bind('touchend.chosen', function(evt) {
|
703 |
+
_this.search_results_touchend(evt);
|
704 |
+
});
|
705 |
+
this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
|
706 |
+
_this.results_update_field(evt);
|
707 |
+
});
|
708 |
+
this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
|
709 |
+
_this.activate_field(evt);
|
710 |
+
});
|
711 |
+
this.form_field_jq.bind("chosen:open.chosen", function(evt) {
|
712 |
+
_this.container_mousedown(evt);
|
713 |
+
});
|
714 |
+
this.form_field_jq.bind("chosen:close.chosen", function(evt) {
|
715 |
+
_this.input_blur(evt);
|
716 |
+
});
|
717 |
+
this.search_field.bind('blur.chosen', function(evt) {
|
718 |
+
_this.input_blur(evt);
|
719 |
+
});
|
720 |
+
this.search_field.bind('keyup.chosen', function(evt) {
|
721 |
+
_this.keyup_checker(evt);
|
722 |
+
});
|
723 |
+
this.search_field.bind('keydown.chosen', function(evt) {
|
724 |
+
_this.keydown_checker(evt);
|
725 |
+
});
|
726 |
+
this.search_field.bind('focus.chosen', function(evt) {
|
727 |
+
_this.input_focus(evt);
|
728 |
+
});
|
729 |
+
this.search_field.bind('cut.chosen', function(evt) {
|
730 |
+
_this.clipboard_event_checker(evt);
|
731 |
+
});
|
732 |
+
this.search_field.bind('paste.chosen', function(evt) {
|
733 |
+
_this.clipboard_event_checker(evt);
|
734 |
+
});
|
735 |
+
if (this.is_multiple) {
|
736 |
+
return this.search_choices.bind('click.chosen', function(evt) {
|
737 |
+
_this.choices_click(evt);
|
738 |
+
});
|
739 |
+
} else {
|
740 |
+
return this.container.bind('click.chosen', function(evt) {
|
741 |
+
evt.preventDefault();
|
742 |
+
});
|
743 |
+
}
|
744 |
+
};
|
745 |
+
|
746 |
+
Chosen.prototype.destroy = function() {
|
747 |
+
$(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
|
748 |
+
if (this.search_field[0].tabIndex) {
|
749 |
+
this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
|
750 |
+
}
|
751 |
+
this.container.remove();
|
752 |
+
this.form_field_jq.removeData('chosen');
|
753 |
+
return this.form_field_jq.show();
|
754 |
+
};
|
755 |
+
|
756 |
+
Chosen.prototype.search_field_disabled = function() {
|
757 |
+
this.is_disabled = this.form_field_jq[0].disabled;
|
758 |
+
if (this.is_disabled) {
|
759 |
+
this.container.addClass('chosen-disabled');
|
760 |
+
this.search_field[0].disabled = true;
|
761 |
+
if (!this.is_multiple) {
|
762 |
+
this.selected_item.unbind("focus.chosen", this.activate_action);
|
763 |
+
}
|
764 |
+
return this.close_field();
|
765 |
+
} else {
|
766 |
+
this.container.removeClass('chosen-disabled');
|
767 |
+
this.search_field[0].disabled = false;
|
768 |
+
if (!this.is_multiple) {
|
769 |
+
return this.selected_item.bind("focus.chosen", this.activate_action);
|
770 |
+
}
|
771 |
+
}
|
772 |
+
};
|
773 |
+
|
774 |
+
Chosen.prototype.container_mousedown = function(evt) {
|
775 |
+
if (!this.is_disabled) {
|
776 |
+
if (evt && evt.type === "mousedown" && !this.results_showing) {
|
777 |
+
evt.preventDefault();
|
778 |
+
}
|
779 |
+
if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
|
780 |
+
if (!this.active_field) {
|
781 |
+
if (this.is_multiple) {
|
782 |
+
this.search_field.val("");
|
783 |
+
}
|
784 |
+
$(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
|
785 |
+
this.results_show();
|
786 |
+
} else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
|
787 |
+
evt.preventDefault();
|
788 |
+
this.results_toggle();
|
789 |
+
}
|
790 |
+
return this.activate_field();
|
791 |
+
}
|
792 |
+
}
|
793 |
+
};
|
794 |
+
|
795 |
+
Chosen.prototype.container_mouseup = function(evt) {
|
796 |
+
if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
|
797 |
+
return this.results_reset(evt);
|
798 |
+
}
|
799 |
+
};
|
800 |
+
|
801 |
+
Chosen.prototype.search_results_mousewheel = function(evt) {
|
802 |
+
var delta;
|
803 |
+
if (evt.originalEvent) {
|
804 |
+
delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
|
805 |
+
}
|
806 |
+
if (delta != null) {
|
807 |
+
evt.preventDefault();
|
808 |
+
if (evt.type === 'DOMMouseScroll') {
|
809 |
+
delta = delta * 40;
|
810 |
+
}
|
811 |
+
return this.search_results.scrollTop(delta + this.search_results.scrollTop());
|
812 |
+
}
|
813 |
+
};
|
814 |
+
|
815 |
+
Chosen.prototype.blur_test = function(evt) {
|
816 |
+
if (!this.active_field && this.container.hasClass("chosen-container-active")) {
|
817 |
+
return this.close_field();
|
818 |
+
}
|
819 |
+
};
|
820 |
+
|
821 |
+
Chosen.prototype.close_field = function() {
|
822 |
+
$(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
|
823 |
+
this.active_field = false;
|
824 |
+
this.results_hide();
|
825 |
+
this.container.removeClass("chosen-container-active");
|
826 |
+
this.clear_backstroke();
|
827 |
+
this.show_search_field_default();
|
828 |
+
return this.search_field_scale();
|
829 |
+
};
|
830 |
+
|
831 |
+
Chosen.prototype.activate_field = function() {
|
832 |
+
this.container.addClass("chosen-container-active");
|
833 |
+
this.active_field = true;
|
834 |
+
this.search_field.val(this.search_field.val());
|
835 |
+
return this.search_field.focus();
|
836 |
+
};
|
837 |
+
|
838 |
+
Chosen.prototype.test_active_click = function(evt) {
|
839 |
+
var active_container;
|
840 |
+
active_container = $(evt.target).closest('.chosen-container');
|
841 |
+
if (active_container.length && this.container[0] === active_container[0]) {
|
842 |
+
return this.active_field = true;
|
843 |
+
} else {
|
844 |
+
return this.close_field();
|
845 |
+
}
|
846 |
+
};
|
847 |
+
|
848 |
+
Chosen.prototype.results_build = function() {
|
849 |
+
this.parsing = true;
|
850 |
+
this.selected_option_count = null;
|
851 |
+
this.results_data = SelectParser.select_to_array(this.form_field);
|
852 |
+
if (this.is_multiple) {
|
853 |
+
this.search_choices.find("li.search-choice").remove();
|
854 |
+
} else if (!this.is_multiple) {
|
855 |
+
this.single_set_selected_text();
|
856 |
+
if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
|
857 |
+
this.search_field[0].readOnly = true;
|
858 |
+
this.container.addClass("chosen-container-single-nosearch");
|
859 |
+
} else {
|
860 |
+
this.search_field[0].readOnly = false;
|
861 |
+
this.container.removeClass("chosen-container-single-nosearch");
|
862 |
+
}
|
863 |
+
}
|
864 |
+
this.update_results_content(this.results_option_build({
|
865 |
+
first: true
|
866 |
+
}));
|
867 |
+
this.search_field_disabled();
|
868 |
+
this.show_search_field_default();
|
869 |
+
this.search_field_scale();
|
870 |
+
return this.parsing = false;
|
871 |
+
};
|
872 |
+
|
873 |
+
Chosen.prototype.result_do_highlight = function(el) {
|
874 |
+
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
875 |
+
if (el.length) {
|
876 |
+
this.result_clear_highlight();
|
877 |
+
this.result_highlight = el;
|
878 |
+
this.result_highlight.addClass("highlighted");
|
879 |
+
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
|
880 |
+
visible_top = this.search_results.scrollTop();
|
881 |
+
visible_bottom = maxHeight + visible_top;
|
882 |
+
high_top = this.result_highlight.position().top + this.search_results.scrollTop();
|
883 |
+
high_bottom = high_top + this.result_highlight.outerHeight();
|
884 |
+
if (high_bottom >= visible_bottom) {
|
885 |
+
return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
|
886 |
+
} else if (high_top < visible_top) {
|
887 |
+
return this.search_results.scrollTop(high_top);
|
888 |
+
}
|
889 |
+
}
|
890 |
+
};
|
891 |
+
|
892 |
+
Chosen.prototype.result_clear_highlight = function() {
|
893 |
+
if (this.result_highlight) {
|
894 |
+
this.result_highlight.removeClass("highlighted");
|
895 |
+
}
|
896 |
+
return this.result_highlight = null;
|
897 |
+
};
|
898 |
+
|
899 |
+
Chosen.prototype.results_show = function() {
|
900 |
+
if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
|
901 |
+
this.form_field_jq.trigger("chosen:maxselected", {
|
902 |
+
chosen: this
|
903 |
+
});
|
904 |
+
return false;
|
905 |
+
}
|
906 |
+
this.container.addClass("chosen-with-drop");
|
907 |
+
this.results_showing = true;
|
908 |
+
this.search_field.focus();
|
909 |
+
this.search_field.val(this.search_field.val());
|
910 |
+
this.winnow_results();
|
911 |
+
return this.form_field_jq.trigger("chosen:showing_dropdown", {
|
912 |
+
chosen: this
|
913 |
+
});
|
914 |
+
};
|
915 |
+
|
916 |
+
Chosen.prototype.update_results_content = function(content) {
|
917 |
+
return this.search_results.html(content);
|
918 |
+
};
|
919 |
+
|
920 |
+
Chosen.prototype.results_hide = function() {
|
921 |
+
if (this.results_showing) {
|
922 |
+
this.result_clear_highlight();
|
923 |
+
this.container.removeClass("chosen-with-drop");
|
924 |
+
this.form_field_jq.trigger("chosen:hiding_dropdown", {
|
925 |
+
chosen: this
|
926 |
+
});
|
927 |
+
}
|
928 |
+
return this.results_showing = false;
|
929 |
+
};
|
930 |
+
|
931 |
+
Chosen.prototype.set_tab_index = function(el) {
|
932 |
+
var ti;
|
933 |
+
if (this.form_field.tabIndex) {
|
934 |
+
ti = this.form_field.tabIndex;
|
935 |
+
this.form_field.tabIndex = -1;
|
936 |
+
return this.search_field[0].tabIndex = ti;
|
937 |
+
}
|
938 |
+
};
|
939 |
+
|
940 |
+
Chosen.prototype.set_label_behavior = function() {
|
941 |
+
var _this = this;
|
942 |
+
this.form_field_label = this.form_field_jq.parents("label");
|
943 |
+
if (!this.form_field_label.length && this.form_field.id.length) {
|
944 |
+
this.form_field_label = $("label[for='" + this.form_field.id + "']");
|
945 |
+
}
|
946 |
+
if (this.form_field_label.length > 0) {
|
947 |
+
return this.form_field_label.bind('click.chosen', function(evt) {
|
948 |
+
if (_this.is_multiple) {
|
949 |
+
return _this.container_mousedown(evt);
|
950 |
+
} else {
|
951 |
+
return _this.activate_field();
|
952 |
+
}
|
953 |
+
});
|
954 |
+
}
|
955 |
+
};
|
956 |
+
|
957 |
+
Chosen.prototype.show_search_field_default = function() {
|
958 |
+
if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
|
959 |
+
this.search_field.val(this.default_text);
|
960 |
+
return this.search_field.addClass("default");
|
961 |
+
} else {
|
962 |
+
this.search_field.val("");
|
963 |
+
return this.search_field.removeClass("default");
|
964 |
+
}
|
965 |
+
};
|
966 |
+
|
967 |
+
Chosen.prototype.search_results_mouseup = function(evt) {
|
968 |
+
var target;
|
969 |
+
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
970 |
+
if (target.length) {
|
971 |
+
this.result_highlight = target;
|
972 |
+
this.result_select(evt);
|
973 |
+
return this.search_field.focus();
|
974 |
+
}
|
975 |
+
};
|
976 |
+
|
977 |
+
Chosen.prototype.search_results_mouseover = function(evt) {
|
978 |
+
var target;
|
979 |
+
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
980 |
+
if (target) {
|
981 |
+
return this.result_do_highlight(target);
|
982 |
+
}
|
983 |
+
};
|
984 |
+
|
985 |
+
Chosen.prototype.search_results_mouseout = function(evt) {
|
986 |
+
if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
|
987 |
+
return this.result_clear_highlight();
|
988 |
+
}
|
989 |
+
};
|
990 |
+
|
991 |
+
Chosen.prototype.choice_build = function(item) {
|
992 |
+
var choice, close_link,
|
993 |
+
_this = this;
|
994 |
+
choice = $('<li />', {
|
995 |
+
"class": "search-choice"
|
996 |
+
}).html("<span>" + (this.choice_label(item)) + "</span>");
|
997 |
+
if (item.disabled) {
|
998 |
+
choice.addClass('search-choice-disabled');
|
999 |
+
} else {
|
1000 |
+
close_link = $('<a />', {
|
1001 |
+
"class": 'search-choice-close',
|
1002 |
+
'data-option-array-index': item.array_index
|
1003 |
+
});
|
1004 |
+
close_link.bind('click.chosen', function(evt) {
|
1005 |
+
return _this.choice_destroy_link_click(evt);
|
1006 |
+
});
|
1007 |
+
choice.append(close_link);
|
1008 |
+
}
|
1009 |
+
return this.search_container.before(choice);
|
1010 |
+
};
|
1011 |
+
|
1012 |
+
Chosen.prototype.choice_destroy_link_click = function(evt) {
|
1013 |
+
evt.preventDefault();
|
1014 |
+
evt.stopPropagation();
|
1015 |
+
if (!this.is_disabled) {
|
1016 |
+
return this.choice_destroy($(evt.target));
|
1017 |
+
}
|
1018 |
+
};
|
1019 |
+
|
1020 |
+
Chosen.prototype.choice_destroy = function(link) {
|
1021 |
+
if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
|
1022 |
+
this.show_search_field_default();
|
1023 |
+
if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
|
1024 |
+
this.results_hide();
|
1025 |
+
}
|
1026 |
+
link.parents('li').first().remove();
|
1027 |
+
return this.search_field_scale();
|
1028 |
+
}
|
1029 |
+
};
|
1030 |
+
|
1031 |
+
Chosen.prototype.results_reset = function() {
|
1032 |
+
this.reset_single_select_options();
|
1033 |
+
this.form_field.options[0].selected = true;
|
1034 |
+
this.single_set_selected_text();
|
1035 |
+
this.show_search_field_default();
|
1036 |
+
this.results_reset_cleanup();
|
1037 |
+
this.form_field_jq.trigger("change");
|
1038 |
+
if (this.active_field) {
|
1039 |
+
return this.results_hide();
|
1040 |
+
}
|
1041 |
+
};
|
1042 |
+
|
1043 |
+
Chosen.prototype.results_reset_cleanup = function() {
|
1044 |
+
this.current_selectedIndex = this.form_field.selectedIndex;
|
1045 |
+
return this.selected_item.find("abbr").remove();
|
1046 |
+
};
|
1047 |
+
|
1048 |
+
Chosen.prototype.result_select = function(evt) {
|
1049 |
+
var high, item;
|
1050 |
+
if (this.result_highlight) {
|
1051 |
+
high = this.result_highlight;
|
1052 |
+
this.result_clear_highlight();
|
1053 |
+
if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
|
1054 |
+
this.form_field_jq.trigger("chosen:maxselected", {
|
1055 |
+
chosen: this
|
1056 |
+
});
|
1057 |
+
return false;
|
1058 |
+
}
|
1059 |
+
if (this.is_multiple) {
|
1060 |
+
high.removeClass("active-result");
|
1061 |
+
} else {
|
1062 |
+
this.reset_single_select_options();
|
1063 |
+
}
|
1064 |
+
high.addClass("result-selected");
|
1065 |
+
item = this.results_data[high[0].getAttribute("data-option-array-index")];
|
1066 |
+
item.selected = true;
|
1067 |
+
this.form_field.options[item.options_index].selected = true;
|
1068 |
+
this.selected_option_count = null;
|
1069 |
+
if (this.is_multiple) {
|
1070 |
+
this.choice_build(item);
|
1071 |
+
} else {
|
1072 |
+
this.single_set_selected_text(this.choice_label(item));
|
1073 |
+
}
|
1074 |
+
if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
|
1075 |
+
this.results_hide();
|
1076 |
+
}
|
1077 |
+
this.show_search_field_default();
|
1078 |
+
if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
|
1079 |
+
this.form_field_jq.trigger("change", {
|
1080 |
+
'selected': this.form_field.options[item.options_index].value
|
1081 |
+
});
|
1082 |
+
}
|
1083 |
+
this.current_selectedIndex = this.form_field.selectedIndex;
|
1084 |
+
evt.preventDefault();
|
1085 |
+
return this.search_field_scale();
|
1086 |
+
}
|
1087 |
+
};
|
1088 |
+
|
1089 |
+
Chosen.prototype.single_set_selected_text = function(text) {
|
1090 |
+
if (text == null) {
|
1091 |
+
text = this.default_text;
|
1092 |
+
}
|
1093 |
+
if (text === this.default_text) {
|
1094 |
+
this.selected_item.addClass("chosen-default");
|
1095 |
+
} else {
|
1096 |
+
this.single_deselect_control_build();
|
1097 |
+
this.selected_item.removeClass("chosen-default");
|
1098 |
+
}
|
1099 |
+
return this.selected_item.find("span").html(text);
|
1100 |
+
};
|
1101 |
+
|
1102 |
+
Chosen.prototype.result_deselect = function(pos) {
|
1103 |
+
var result_data;
|
1104 |
+
result_data = this.results_data[pos];
|
1105 |
+
if (!this.form_field.options[result_data.options_index].disabled) {
|
1106 |
+
result_data.selected = false;
|
1107 |
+
this.form_field.options[result_data.options_index].selected = false;
|
1108 |
+
this.selected_option_count = null;
|
1109 |
+
this.result_clear_highlight();
|
1110 |
+
if (this.results_showing) {
|
1111 |
+
this.winnow_results();
|
1112 |
+
}
|
1113 |
+
this.form_field_jq.trigger("change", {
|
1114 |
+
deselected: this.form_field.options[result_data.options_index].value
|
1115 |
+
});
|
1116 |
+
this.search_field_scale();
|
1117 |
+
return true;
|
1118 |
+
} else {
|
1119 |
+
return false;
|
1120 |
+
}
|
1121 |
+
};
|
1122 |
+
|
1123 |
+
Chosen.prototype.single_deselect_control_build = function() {
|
1124 |
+
if (!this.allow_single_deselect) {
|
1125 |
+
return;
|
1126 |
+
}
|
1127 |
+
if (!this.selected_item.find("abbr").length) {
|
1128 |
+
this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
|
1129 |
+
}
|
1130 |
+
return this.selected_item.addClass("chosen-single-with-deselect");
|
1131 |
+
};
|
1132 |
+
|
1133 |
+
Chosen.prototype.get_search_text = function() {
|
1134 |
+
return $('<div/>').text($.trim(this.search_field.val())).html();
|
1135 |
+
};
|
1136 |
+
|
1137 |
+
Chosen.prototype.winnow_results_set_highlight = function() {
|
1138 |
+
var do_high, selected_results;
|
1139 |
+
selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
|
1140 |
+
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
|
1141 |
+
if (do_high != null) {
|
1142 |
+
return this.result_do_highlight(do_high);
|
1143 |
+
}
|
1144 |
+
};
|
1145 |
+
|
1146 |
+
Chosen.prototype.no_results = function(terms) {
|
1147 |
+
var no_results_html;
|
1148 |
+
no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
|
1149 |
+
no_results_html.find("span").first().html(terms);
|
1150 |
+
this.search_results.append(no_results_html);
|
1151 |
+
return this.form_field_jq.trigger("chosen:no_results", {
|
1152 |
+
chosen: this
|
1153 |
+
});
|
1154 |
+
};
|
1155 |
+
|
1156 |
+
Chosen.prototype.no_results_clear = function() {
|
1157 |
+
return this.search_results.find(".no-results").remove();
|
1158 |
+
};
|
1159 |
+
|
1160 |
+
Chosen.prototype.keydown_arrow = function() {
|
1161 |
+
var next_sib;
|
1162 |
+
if (this.results_showing && this.result_highlight) {
|
1163 |
+
next_sib = this.result_highlight.nextAll("li.active-result").first();
|
1164 |
+
if (next_sib) {
|
1165 |
+
return this.result_do_highlight(next_sib);
|
1166 |
+
}
|
1167 |
+
} else {
|
1168 |
+
return this.results_show();
|
1169 |
+
}
|
1170 |
+
};
|
1171 |
+
|
1172 |
+
Chosen.prototype.keyup_arrow = function() {
|
1173 |
+
var prev_sibs;
|
1174 |
+
if (!this.results_showing && !this.is_multiple) {
|
1175 |
+
return this.results_show();
|
1176 |
+
} else if (this.result_highlight) {
|
1177 |
+
prev_sibs = this.result_highlight.prevAll("li.active-result");
|
1178 |
+
if (prev_sibs.length) {
|
1179 |
+
return this.result_do_highlight(prev_sibs.first());
|
1180 |
+
} else {
|
1181 |
+
if (this.choices_count() > 0) {
|
1182 |
+
this.results_hide();
|
1183 |
+
}
|
1184 |
+
return this.result_clear_highlight();
|
1185 |
+
}
|
1186 |
+
}
|
1187 |
+
};
|
1188 |
+
|
1189 |
+
Chosen.prototype.keydown_backstroke = function() {
|
1190 |
+
var next_available_destroy;
|
1191 |
+
if (this.pending_backstroke) {
|
1192 |
+
this.choice_destroy(this.pending_backstroke.find("a").first());
|
1193 |
+
return this.clear_backstroke();
|
1194 |
+
} else {
|
1195 |
+
next_available_destroy = this.search_container.siblings("li.search-choice").last();
|
1196 |
+
if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
|
1197 |
+
this.pending_backstroke = next_available_destroy;
|
1198 |
+
if (this.single_backstroke_delete) {
|
1199 |
+
return this.keydown_backstroke();
|
1200 |
+
} else {
|
1201 |
+
return this.pending_backstroke.addClass("search-choice-focus");
|
1202 |
+
}
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
};
|
1206 |
+
|
1207 |
+
Chosen.prototype.clear_backstroke = function() {
|
1208 |
+
if (this.pending_backstroke) {
|
1209 |
+
this.pending_backstroke.removeClass("search-choice-focus");
|
1210 |
+
}
|
1211 |
+
return this.pending_backstroke = null;
|
1212 |
+
};
|
1213 |
+
|
1214 |
+
Chosen.prototype.keydown_checker = function(evt) {
|
1215 |
+
var stroke, _ref1;
|
1216 |
+
stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
|
1217 |
+
this.search_field_scale();
|
1218 |
+
if (stroke !== 8 && this.pending_backstroke) {
|
1219 |
+
this.clear_backstroke();
|
1220 |
+
}
|
1221 |
+
switch (stroke) {
|
1222 |
+
case 8:
|
1223 |
+
this.backstroke_length = this.search_field.val().length;
|
1224 |
+
break;
|
1225 |
+
case 9:
|
1226 |
+
if (this.results_showing && !this.is_multiple) {
|
1227 |
+
this.result_select(evt);
|
1228 |
+
}
|
1229 |
+
this.mouse_on_container = false;
|
1230 |
+
break;
|
1231 |
+
case 13:
|
1232 |
+
if (this.results_showing) {
|
1233 |
+
evt.preventDefault();
|
1234 |
+
}
|
1235 |
+
break;
|
1236 |
+
case 32:
|
1237 |
+
if (this.disable_search) {
|
1238 |
+
evt.preventDefault();
|
1239 |
+
}
|
1240 |
+
break;
|
1241 |
+
case 38:
|
1242 |
+
evt.preventDefault();
|
1243 |
+
this.keyup_arrow();
|
1244 |
+
break;
|
1245 |
+
case 40:
|
1246 |
+
evt.preventDefault();
|
1247 |
+
this.keydown_arrow();
|
1248 |
+
break;
|
1249 |
+
}
|
1250 |
+
};
|
1251 |
+
|
1252 |
+
Chosen.prototype.search_field_scale = function() {
|
1253 |
+
var div, f_width, h, style, style_block, styles, w, _i, _len;
|
1254 |
+
if (this.is_multiple) {
|
1255 |
+
h = 0;
|
1256 |
+
w = 0;
|
1257 |
+
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
|
1258 |
+
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
|
1259 |
+
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
1260 |
+
style = styles[_i];
|
1261 |
+
style_block += style + ":" + this.search_field.css(style) + ";";
|
1262 |
+
}
|
1263 |
+
div = $('<div />', {
|
1264 |
+
'style': style_block
|
1265 |
+
});
|
1266 |
+
div.text(this.search_field.val());
|
1267 |
+
$('body').append(div);
|
1268 |
+
w = div.width() + 25;
|
1269 |
+
div.remove();
|
1270 |
+
f_width = this.container.outerWidth();
|
1271 |
+
if (w > f_width - 10) {
|
1272 |
+
w = f_width - 10;
|
1273 |
+
}
|
1274 |
+
return this.search_field.css({
|
1275 |
+
'width': w + 'px'
|
1276 |
+
});
|
1277 |
+
}
|
1278 |
+
};
|
1279 |
+
|
1280 |
+
return Chosen;
|
1281 |
+
|
1282 |
+
})(AbstractChosen);
|
1283 |
+
|
1284 |
+
}).call(this);
|
assets/js/chosen.jquery.min.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
/* Chosen v1.5.1 | (c) 2011-2016 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
|
2 |
(function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),title:a.title?a.title:void 0,children:0,disabled:a.disabled,classes:a.className}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,title:a.title?a.title:void 0,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,group_label:null!=b?this.parsed[b].label:null,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"<",">":">",'"':""","'":"'","`":"`"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.choice_label=function(a){return this.include_group_label_in_selected&&null!=a.group_label?"<b class='group-name'>"+a.group_label+"</b>"+a.html:a.html},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(a){var b=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return b.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(a){var b=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return b.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f,g,h;for(b="",e=0,h=this.results_data,f=0,g=h.length;g>f&&(c=h[f],d="",d=c.group?this.result_add_group(c):this.result_add_option(c),""!==d&&(e++,b+=d),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(c))),!(e>=this.max_shown_results));f++);return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match&&this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.result_add_group=function(a){var b,c;return(a.search_match||a.group_match)&&a.active_options>0?(b=[],b.push("group-result"),a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),d=0,f=this.get_search_text(),a=f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i=new RegExp(a,"i"),c=this.get_search_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)b=l[j],b.search_match=!1,e=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(e=this.results_data[b.group_array_index],0===e.active_options&&e.search_match&&(d+=1),e.active_options+=1),b.search_text=b.group?b.label:b.html,(!b.group||this.group_search)&&(b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(d+=1),b.search_match?(f.length&&(g=b.search_text.search(i),h=b.search_text.substr(0,g+f.length)+"</em>"+b.search_text.substr(g+f.length),b.search_text=h.substr(0,g)+"<em>"+h.substr(g)),null!=e&&(e.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>d&&f.length?(this.update_results_content(""),this.no_results(f)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.get_search_regex=function(a){var b;return b=this.search_contains?"":"^",new RegExp(b+a,"i")},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:case 18:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(a){var b=this;return setTimeout(function(){return b.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:/IEMobile/i.test(window.navigator.userAgent)?!1:/Windows Phone/i.test(window.navigator.userAgent)?!1:/BlackBerry/i.test(window.navigator.userAgent)?!1:/BB10/i.test(window.navigator.userAgent)?!1:"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(c){var d,e;return d=a(this),e=d.data("chosen"),"destroy"===b?void(e instanceof Chosen&&e.destroy()):void(e instanceof Chosen||d.data("chosen",new Chosen(this,b)))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},Chosen.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("touchstart.chosen",function(b){return a.container_mousedown(b),b.preventDefault()}),this.container.bind("touchend.chosen",function(b){return a.container_mouseup(b),b.preventDefault()}),this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=a.originalEvent.deltaY||-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(a){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(a){var b;return this.form_field.tabIndex?(b=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=b):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+this.choice_label(b)+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),b.addClass("result-selected"),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(this.choice_label(c)),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.show_search_field_default(),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,a.preventDefault(),this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:this.results_showing&&a.preventDefault();break;case 32:this.disable_search&&a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}).call(this);
|
1 |
+
/* Chosen v1.5.1 | (c) 2011-2016 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
|
2 |
(function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),title:a.title?a.title:void 0,children:0,disabled:a.disabled,classes:a.className}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,title:a.title?a.title:void 0,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,group_label:null!=b?this.parsed[b].label:null,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"<",">":">",'"':""","'":"'","`":"`"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.choice_label=function(a){return this.include_group_label_in_selected&&null!=a.group_label?"<b class='group-name'>"+a.group_label+"</b>"+a.html:a.html},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(a){var b=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return b.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(a){var b=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return b.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f,g,h;for(b="",e=0,h=this.results_data,f=0,g=h.length;g>f&&(c=h[f],d="",d=c.group?this.result_add_group(c):this.result_add_option(c),""!==d&&(e++,b+=d),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(c))),!(e>=this.max_shown_results));f++);return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match&&this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.result_add_group=function(a){var b,c;return(a.search_match||a.group_match)&&a.active_options>0?(b=[],b.push("group-result"),a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),d=0,f=this.get_search_text(),a=f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i=new RegExp(a,"i"),c=this.get_search_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)b=l[j],b.search_match=!1,e=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(e=this.results_data[b.group_array_index],0===e.active_options&&e.search_match&&(d+=1),e.active_options+=1),b.search_text=b.group?b.label:b.html,(!b.group||this.group_search)&&(b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(d+=1),b.search_match?(f.length&&(g=b.search_text.search(i),h=b.search_text.substr(0,g+f.length)+"</em>"+b.search_text.substr(g+f.length),b.search_text=h.substr(0,g)+"<em>"+h.substr(g)),null!=e&&(e.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>d&&f.length?(this.update_results_content(""),this.no_results(f)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.get_search_regex=function(a){var b;return b=this.search_contains?"":"^",new RegExp(b+a,"i")},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:case 18:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(a){var b=this;return setTimeout(function(){return b.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:/IEMobile/i.test(window.navigator.userAgent)?!1:/Windows Phone/i.test(window.navigator.userAgent)?!1:/BlackBerry/i.test(window.navigator.userAgent)?!1:/BB10/i.test(window.navigator.userAgent)?!1:"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(c){var d,e;return d=a(this),e=d.data("chosen"),"destroy"===b?void(e instanceof Chosen&&e.destroy()):void(e instanceof Chosen||d.data("chosen",new Chosen(this,b)))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},Chosen.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("touchstart.chosen",function(b){return a.container_mousedown(b),b.preventDefault()}),this.container.bind("touchend.chosen",function(b){return a.container_mouseup(b),b.preventDefault()}),this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=a.originalEvent.deltaY||-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(a){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(a){var b;return this.form_field.tabIndex?(b=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=b):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+this.choice_label(b)+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),b.addClass("result-selected"),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(this.choice_label(c)),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.show_search_field_default(),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,a.preventDefault(),this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:this.results_showing&&a.preventDefault();break;case 32:this.disable_search&&a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}).call(this);
|
assets/js/jscolor.min.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
/**
|
2 |
-
* jscolor - JavaScript Color Picker
|
3 |
-
*
|
4 |
-
* @link http://jscolor.com
|
5 |
-
* @license For open source use: GPLv3
|
6 |
-
* For commercial use: JSColor Commercial License
|
7 |
-
* @author Jan Odvarko
|
8 |
-
*
|
9 |
-
* See usage examples at http://jscolor.com/examples/
|
10 |
*/"use strict";window.jscolor||(window.jscolor=function(){var e={register:function(){e.attachDOMReadyEvent(e.init),e.attachEvent(document,"mousedown",e.onDocumentMouseDown),e.attachEvent(document,"touchstart",e.onDocumentTouchStart),e.attachEvent(window,"resize",e.onWindowResize)},init:function(){e.jscolor.lookupClass&&e.jscolor.installByClassName(e.jscolor.lookupClass)},tryInstallOnElements:function(t,n){var r=new RegExp("(^|\\s)("+n+")(\\s*(\\{[^}]*\\})|\\s|$)","i");for(var i=0;i<t.length;i+=1){if(t[i].type!==undefined&&t[i].type.toLowerCase()=="color"&&e.isColorAttrSupported)continue;var s;if(!t[i].jscolor&&t[i].className&&(s=t[i].className.match(r))){var o=t[i],u=null,a=e.getDataAttr(o,"jscolor");a!==null?u=a:s[4]&&(u=s[4]);var f={};if(u)try{f=(new Function("return ("+u+")"))()}catch(l){e.warn("Error parsing jscolor options: "+l+":\n"+u)}o.jscolor=new e.jscolor(o,f)}}},isColorAttrSupported:function(){var e=document.createElement("input");if(e.setAttribute){e.setAttribute("type","color");if(e.type.toLowerCase()=="color")return!0}return!1}(),isCanvasSupported:function(){var e=document.createElement("canvas");return!!e.getContext&&!!e.getContext("2d")}(),fetchElement:function(e){return typeof e=="string"?document.getElementById(e):e},isElementType:function(e,t){return e.nodeName.toLowerCase()===t.toLowerCase()},getDataAttr:function(e,t){var n="data-"+t,r=e.getAttribute(n);return r!==null?r:null},attachEvent:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},detachEvent:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)},_attachedGroupEvents:{},attachGroupEvent:function(t,n,r,i){e._attachedGroupEvents.hasOwnProperty(t)||(e._attachedGroupEvents[t]=[]),e._attachedGroupEvents[t].push([n,r,i]),e.attachEvent(n,r,i)},detachGroupEvents:function(t){if(e._attachedGroupEvents.hasOwnProperty(t)){for(var n=0;n<e._attachedGroupEvents[t].length;n+=1){var r=e._attachedGroupEvents[t][n];e.detachEvent(r[0],r[1],r[2])}delete e._attachedGroupEvents[t]}},attachDOMReadyEvent:function(e){var t=!1,n=function(){t||(t=!0,e())};if(document.readyState==="complete"){setTimeout(n,1);return}if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",function(){document.readyState==="complete"&&(document.detachEvent("onreadystatechange",arguments.callee),n())}),window.attachEvent("onload",n);if(document.documentElement.doScroll&&window==window.top){var r=function(){if(!document.body)return;try{document.documentElement.doScroll("left"),n()}catch(e){setTimeout(r,1)}};r()}}},warn:function(e){window.console&&window.console.warn&&window.console.warn(e)},preventDefault:function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},captureTarget:function(t){t.setCapture&&(e._capturedTarget=t,e._capturedTarget.setCapture())},releaseTarget:function(){e._capturedTarget&&(e._capturedTarget.releaseCapture(),e._capturedTarget=null)},fireEvent:function(e,t){if(!e)return;if(document.createEvent){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}else if(document.createEventObject){var n=document.createEventObject();e.fireEvent("on"+t,n)}else e["on"+t]&&e["on"+t]()},classNameToList:function(e){return e.replace(/^\s+|\s+$/g,"").split(/\s+/)},hasClass:function(e,t){return t?-1!=(" "+e.className.replace(/\s+/g," ")+" ").indexOf(" "+t+" "):!1},setClass:function(t,n){var r=e.classNameToList(n);for(var i=0;i<r.length;i+=1)e.hasClass(t,r[i])||(t.className+=(t.className?" ":"")+r[i])},unsetClass:function(t,n){var r=e.classNameToList(n);for(var i=0;i<r.length;i+=1){var s=new RegExp("^\\s*"+r[i]+"\\s*|"+"\\s*"+r[i]+"\\s*$|"+"\\s+"+r[i]+"(\\s+)","g");t.className=t.className.replace(s,"$1")}},getStyle:function(e){return window.getComputedStyle?window.getComputedStyle(e):e.currentStyle},setStyle:function(){var e=document.createElement("div"),t=function(t){for(var n=0;n<t.length;n+=1)if(t[n]in e.style)return t[n]},n={borderRadius:t(["borderRadius","MozBorderRadius","webkitBorderRadius"]),boxShadow:t(["boxShadow","MozBoxShadow","webkitBoxShadow"])};return function(e,t,r){switch(t.toLowerCase()){case"opacity":var i=Math.round(parseFloat(r)*100);e.style.opacity=r,e.style.filter="alpha(opacity="+i+")";break;default:e.style[n[t]]=r}}}(),setBorderRadius:function(t,n){e.setStyle(t,"borderRadius",n||"0")},setBoxShadow:function(t,n){e.setStyle(t,"boxShadow",n||"none")},getElementPos:function(t,n){var r=0,i=0,s=t.getBoundingClientRect();r=s.left,i=s.top;if(!n){var o=e.getViewPos();r+=o[0],i+=o[1]}return[r,i]},getElementSize:function(e){return[e.offsetWidth,e.offsetHeight]},getAbsPointerPos:function(e){e||(e=window.event);var t=0,n=0;return typeof e.changedTouches!="undefined"&&e.changedTouches.length?(t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY):typeof e.clientX=="number"&&(t=e.clientX,n=e.clientY),{x:t,y:n}},getRelPointerPos:function(e){e||(e=window.event);var t=e.target||e.srcElement,n=t.getBoundingClientRect(),r=0,i=0,s=0,o=0;return typeof e.changedTouches!="undefined"&&e.changedTouches.length?(s=e.changedTouches[0].clientX,o=e.changedTouches[0].clientY):typeof e.clientX=="number"&&(s=e.clientX,o=e.clientY),r=s-n.left,i=o-n.top,{x:r,y:i}},getViewPos:function(){var e=document.documentElement;return[(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0),(window.pageYOffset||e.scrollTop)-(e.clientTop||0)]},getViewSize:function(){var e=document.documentElement;return[window.innerWidth||e.clientWidth,window.innerHeight||e.clientHeight]},redrawPosition:function(){if(e.picker&&e.picker.owner){var t=e.picker.owner,n,r;t.fixed?(n=e.getElementPos(t.targetElement,!0),r=[0,0]):(n=e.getElementPos(t.targetElement),r=e.getViewPos());var i=e.getElementSize(t.targetElement),s=e.getViewSize(),o=e.getPickerOuterDims(t),u,a,f;switch(t.position.toLowerCase()){case"left":u=1,a=0,f=-1;break;case"right":u=1,a=0,f=1;break;case"top":u=0,a=1,f=-1;break;default:u=0,a=1,f=1}var l=(i[a]+o[a])/2;if(!t.smartPosition)var c=[n[u],n[a]+i[a]-l+l*f];else var c=[-r[u]+n[u]+o[u]>s[u]?-r[u]+n[u]+i[u]/2>s[u]/2&&n[u]+i[u]-o[u]>=0?n[u]+i[u]-o[u]:n[u]:n[u],-r[a]+n[a]+i[a]+o[a]-l+l*f>s[a]?-r[a]+n[a]+i[a]/2>s[a]/2&&n[a]+i[a]-l-l*f>=0?n[a]+i[a]-l-l*f:n[a]+i[a]-l+l*f:n[a]+i[a]-l+l*f>=0?n[a]+i[a]-l+l*f:n[a]+i[a]-l-l*f];var h=c[u],p=c[a],d=t.fixed?"fixed":"absolute",v=(c[0]+o[0]>n[0]||c[0]<n[0]+i[0])&&c[1]+o[1]<n[1]+i[1];e._drawPosition(t,h,p,d,v)}},_drawPosition:function(t,n,r,i,s){var o=s?0:t.shadowBlur;e.picker.wrap.style.position=i,e.picker.wrap.style.left=n+"px",e.picker.wrap.style.top=r+"px",e.setBoxShadow(e.picker.boxS,t.shadow?new e.BoxShadow(0,o,t.shadowBlur,0,t.shadowColor):null)},getPickerDims:function(t){var n=!!e.getSliderComponent(t),r=[2*t.insetWidth+2*t.padding+t.width+(n?2*t.insetWidth+e.getPadToSliderPadding(t)+t.sliderSize:0),2*t.insetWidth+2*t.padding+t.height+(t.closable?2*t.insetWidth+t.padding+t.buttonHeight:0)];return r},getPickerOuterDims:function(t){var n=e.getPickerDims(t);return[n[0]+2*t.borderWidth,n[1]+2*t.borderWidth]},getPadToSliderPadding:function(e){return Math.max(e.padding,1.5*(2*e.pointerBorderWidth+e.pointerThickness))},getPadYComponent:function(e){switch(e.mode.charAt(1).toLowerCase()){case"v":return"v"}return"s"},getSliderComponent:function(e){if(e.mode.length>2)switch(e.mode.charAt(2).toLowerCase()){case"s":return"s";case"v":return"v"}return null},onDocumentMouseDown:function(t){t||(t=window.event);var n=t.target||t.srcElement;n._jscLinkedInstance?n._jscLinkedInstance.showOnClick&&n._jscLinkedInstance.show():n._jscControlName?e.onControlPointerStart(t,n,n._jscControlName,"mouse"):e.picker&&e.picker.owner&&e.picker.owner.hide()},onDocumentTouchStart:function(t){t||(t=window.event);var n=t.target||t.srcElement;n._jscLinkedInstance?n._jscLinkedInstance.showOnClick&&n._jscLinkedInstance.show():n._jscControlName?e.onControlPointerStart(t,n,n._jscControlName,"touch"):e.picker&&e.picker.owner&&e.picker.owner.hide()},onWindowResize:function(t){e.redrawPosition()},onParentScroll:function(t){e.picker&&e.picker.owner&&e.picker.owner.hide()},_pointerMoveEvent:{mouse:"mousemove",touch:"touchmove"},_pointerEndEvent:{mouse:"mouseup",touch:"touchend"},_pointerOrigin:null,_capturedTarget:null,onControlPointerStart:function(t,n,r,i){var s=n._jscInstance;e.preventDefault(t),e.captureTarget(n);var o=function(s,o){e.attachGroupEvent("drag",s,e._pointerMoveEvent[i],e.onDocumentPointerMove(t,n,r,i,o)),e.attachGroupEvent("drag",s,e._pointerEndEvent[i],e.onDocumentPointerEnd(t,n,r,i))};o(document,[0,0]);if(window.parent&&window.frameElement){var u=window.frameElement.getBoundingClientRect(),a=[-u.left,-u.top];o(window.parent.window.document,a)}var f=e.getAbsPointerPos(t),l=e.getRelPointerPos(t);e._pointerOrigin={x:f.x-l.x,y:f.y-l.y};switch(r){case"pad":switch(e.getSliderComponent(s)){case"s":s.hsv[1]===0&&s.fromHSV(null,100,null);break;case"v":s.hsv[2]===0&&s.fromHSV(null,null,100)}e.setPad(s,t,0,0);break;case"sld":e.setSld(s,t,0)}e.dispatchFineChange(s)},onDocumentPointerMove:function(t,n,r,i,s){return function(t){var i=n._jscInstance;switch(r){case"pad":t||(t=window.event),e.setPad(i,t,s[0],s[1]),e.dispatchFineChange(i);break;case"sld":t||(t=window.event),e.setSld(i,t,s[1]),e.dispatchFineChange(i)}}},onDocumentPointerEnd:function(t,n,r,i){return function(t){var r=n._jscInstance;e.detachGroupEvents("drag"),e.releaseTarget(),e.dispatchChange(r)}},dispatchChange:function(t){t.valueElement&&e.isElementType(t.valueElement,"input")&&e.fireEvent(t.valueElement,"change")},dispatchFineChange:function(e){if(e.onFineChange){var t;typeof e.onFineChange=="string"?t=new Function(e.onFineChange):t=e.onFineChange,t.call(e)}},setPad:function(t,n,r,i){var s=e.getAbsPointerPos(n),o=r+s.x-e._pointerOrigin.x-t.padding-t.insetWidth,u=i+s.y-e._pointerOrigin.y-t.padding-t.insetWidth,a=o*(360/(t.width-1)),f=100-u*(100/(t.height-1));switch(e.getPadYComponent(t)){case"s":t.fromHSV(a,f,null,e.leaveSld);break;case"v":t.fromHSV(a,null,f,e.leaveSld)}},setSld:function(t,n,r){var i=e.getAbsPointerPos(n),s=r+i.y-e._pointerOrigin.y-t.padding-t.insetWidth,o=100-s*(100/(t.height-1));switch(e.getSliderComponent(t)){case"s":t.fromHSV(null,o,null,e.leavePad);break;case"v":t.fromHSV(null,null,o,e.leavePad)}},_vmlNS:"jsc_vml_",_vmlCSS:"jsc_vml_css_",_vmlReady:!1,initVML:function(){if(!e._vmlReady){var t=document;t.namespaces[e._vmlNS]||t.namespaces.add(e._vmlNS,"urn:schemas-microsoft-com:vml");if(!t.styleSheets[e._vmlCSS]){var n=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","rect","roundrect","oval","arc","image"],r=t.createStyleSheet();r.owningElement.id=e._vmlCSS;for(var i=0;i<n.length;i+=1)r.addRule(e._vmlNS+"\\:"+n[i],"behavior:url(#default#VML);")}e._vmlReady=!0}},createPalette:function(){var t={elm:null,draw:null};if(e.isCanvasSupported){var n=document.createElement("canvas"),r=n.getContext("2d"),i=function(e,t,i){n.width=e,n.height=t,r.clearRect(0,0,n.width,n.height);var s=r.createLinearGradient(0,0,n.width,0);s.addColorStop(0,"#F00"),s.addColorStop(1/6,"#FF0"),s.addColorStop(2/6,"#0F0"),s.addColorStop(.5,"#0FF"),s.addColorStop(4/6,"#00F"),s.addColorStop(5/6,"#F0F"),s.addColorStop(1,"#F00"),r.fillStyle=s,r.fillRect(0,0,n.width,n.height);var o=r.createLinearGradient(0,0,0,n.height);switch(i.toLowerCase()){case"s":o.addColorStop(0,"rgba(255,255,255,0)"),o.addColorStop(1,"rgba(255,255,255,1)");break;case"v":o.addColorStop(0,"rgba(0,0,0,0)"),o.addColorStop(1,"rgba(0,0,0,1)")}r.fillStyle=o,r.fillRect(0,0,n.width,n.height)};t.elm=n,t.draw=i}else{e.initVML();var s=document.createElement("div");s.style.position="relative",s.style.overflow="hidden";var o=document.createElement(e._vmlNS+":fill");o.type="gradient",o.method="linear",o.angle="90",o.colors="16.67% #F0F, 33.33% #00F, 50% #0FF, 66.67% #0F0, 83.33% #FF0";var u=document.createElement(e._vmlNS+":rect");u.style.position="absolute",u.style.left="-1px",u.style.top="-1px",u.stroked=!1,u.appendChild(o),s.appendChild(u);var a=document.createElement(e._vmlNS+":fill");a.type="gradient",a.method="linear",a.angle="180",a.opacity="0";var f=document.createElement(e._vmlNS+":rect");f.style.position="absolute",f.style.left="-1px",f.style.top="-1px",f.stroked=!1,f.appendChild(a),s.appendChild(f);var i=function(e,t,n){s.style.width=e+"px",s.style.height=t+"px",u.style.width=f.style.width=e+1+"px",u.style.height=f.style.height=t+1+"px",o.color="#F00",o.color2="#F00";switch(n.toLowerCase()){case"s":a.color=a.color2="#FFF";break;case"v":a.color=a.color2="#000"}};t.elm=s,t.draw=i}return t},createSliderGradient:function(){var t={elm:null,draw:null};if(e.isCanvasSupported){var n=document.createElement("canvas"),r=n.getContext("2d"),i=function(e,t,i,s){n.width=e,n.height=t,r.clearRect(0,0,n.width,n.height);var o=r.createLinearGradient(0,0,0,n.height);o.addColorStop(0,i),o.addColorStop(1,s),r.fillStyle=o,r.fillRect(0,0,n.width,n.height)};t.elm=n,t.draw=i}else{e.initVML();var s=document.createElement("div");s.style.position="relative",s.style.overflow="hidden";var o=document.createElement(e._vmlNS+":fill");o.type="gradient",o.method="linear",o.angle="180";var u=document.createElement(e._vmlNS+":rect");u.style.position="absolute",u.style.left="-1px",u.style.top="-1px",u.stroked=!1,u.appendChild(o),s.appendChild(u);var i=function(e,t,n,r){s.style.width=e+"px",s.style.height=t+"px",u.style.width=e+1+"px",u.style.height=t+1+"px",o.color=n,o.color2=r};t.elm=s,t.draw=i}return t},leaveValue:1,leaveStyle:2,leavePad:4,leaveSld:8,BoxShadow:function(){var e=function(e,t,n,r,i,s){this.hShadow=e,this.vShadow=t,this.blur=n,this.spread=r,this.color=i,this.inset=!!s};return e.prototype.toString=function(){var e=[Math.round(this.hShadow)+"px",Math.round(this.vShadow)+"px",Math.round(this.blur)+"px",Math.round(this.spread)+"px",this.color];return this.inset&&e.push("inset"),e.join(" ")},e}(),jscolor:function(t,n){function i(e,t,n){e/=255,t/=255,n/=255;var r=Math.min(Math.min(e,t),n),i=Math.max(Math.max(e,t),n),s=i-r;if(s===0)return[null,0,100*i];var o=e===r?3+(n-t)/s:t===r?5+(e-n)/s:1+(t-e)/s;return[60*(o===6?0:o),100*(s/i),100*i]}function s(e,t,n){var r=255*(n/100);if(e===null)return[r,r,r];e/=60,t/=100;var i=Math.floor(e),s=i%2?e-i:1-(e-i),o=r*(1-t),u=r*(1-t*s);switch(i){case 6:case 0:return[r,u,o];case 1:return[u,r,o];case 2:return[o,r,u];case 3:return[o,u,r];case 4:return[u,o,r];case 5:return[r,o,u]}}function o(){e.unsetClass(d.targetElement,d.activeClass),e.picker.wrap.parentNode.removeChild(e.picker.wrap),delete e.picker.owner}function u(){function l(){var e=d.insetColor.split(/\s+/),n=e.length<2?e[0]:e[1]+" "+e[0]+" "+e[0]+" "+e[1];t.btn.style.borderColor=n}d._processParentElementsInDOM(),e.picker||(e.picker={owner:null,wrap:document.createElement("div"),box:document.createElement("div"),boxS:document.createElement("div"),boxB:document.createElement("div"),pad:document.createElement("div"),padB:document.createElement("div"),padM:document.createElement("div"),padPal:e.createPalette(),cross:document.createElement("div"),crossBY:document.createElement("div"),crossBX:document.createElement("div"),crossLY:document.createElement("div"),crossLX:document.createElement("div"),sld:document.createElement("div"),sldB:document.createElement("div"),sldM:document.createElement("div"),sldGrad:e.createSliderGradient(),sldPtrS:document.createElement("div"),sldPtrIB:document.createElement("div"),sldPtrMB:document.createElement("div"),sldPtrOB:document.createElement("div"),btn:document.createElement("div"),btnT:document.createElement("span")},e.picker.pad.appendChild(e.picker.padPal.elm),e.picker.padB.appendChild(e.picker.pad),e.picker.cross.appendChild(e.picker.crossBY),e.picker.cross.appendChild(e.picker.crossBX),e.picker.cross.appendChild(e.picker.crossLY),e.picker.cross.appendChild(e.picker.crossLX),e.picker.padB.appendChild(e.picker.cross),e.picker.box.appendChild(e.picker.padB),e.picker.box.appendChild(e.picker.padM),e.picker.sld.appendChild(e.picker.sldGrad.elm),e.picker.sldB.appendChild(e.picker.sld),e.picker.sldB.appendChild(e.picker.sldPtrOB),e.picker.sldPtrOB.appendChild(e.picker.sldPtrMB),e.picker.sldPtrMB.appendChild(e.picker.sldPtrIB),e.picker.sldPtrIB.appendChild(e.picker.sldPtrS),e.picker.box.appendChild(e.picker.sldB),e.picker.box.appendChild(e.picker.sldM),e.picker.btn.appendChild(e.picker.btnT),e.picker.box.appendChild(e.picker.btn),e.picker.boxB.appendChild(e.picker.box),e.picker.wrap.appendChild(e.picker.boxS),e.picker.wrap.appendChild(e.picker.boxB));var t=e.picker,n=!!e.getSliderComponent(d),r=e.getPickerDims(d),i=2*d.pointerBorderWidth+d.pointerThickness+2*d.crossSize,s=e.getPadToSliderPadding(d),o=Math.min(d.borderRadius,Math.round(d.padding*Math.PI)),u="crosshair";t.wrap.style.clear="both",t.wrap.style.width=r[0]+2*d.borderWidth+"px",t.wrap.style.height=r[1]+2*d.borderWidth+"px",t.wrap.style.zIndex=d.zIndex,t.box.style.width=r[0]+"px",t.box.style.height=r[1]+"px",t.boxS.style.position="absolute",t.boxS.style.left="0",t.boxS.style.top="0",t.boxS.style.width="100%",t.boxS.style.height="100%",e.setBorderRadius(t.boxS,o+"px"),t.boxB.style.position="relative",t.boxB.style.border=d.borderWidth+"px solid",t.boxB.style.borderColor=d.borderColor,t.boxB.style.background=d.backgroundColor,e.setBorderRadius(t.boxB,o+"px"),t.padM.style.background=t.sldM.style.background="#FFF",e.setStyle(t.padM,"opacity","0"),e.setStyle(t.sldM,"opacity","0"),t.pad.style.position="relative",t.pad.style.width=d.width+"px",t.pad.style.height=d.height+"px",t.padPal.draw(d.width,d.height,e.getPadYComponent(d)),t.padB.style.position="absolute",t.padB.style.left=d.padding+"px",t.padB.style.top=d.padding+"px",t.padB.style.border=d.insetWidth+"px solid",t.padB.style.borderColor=d.insetColor,t.padM._jscInstance=d,t.padM._jscControlName="pad",t.padM.style.position="absolute",t.padM.style.left="0",t.padM.style.top="0",t.padM.style.width=d.padding+2*d.insetWidth+d.width+s/2+"px",t.padM.style.height=r[1]+"px",t.padM.style.cursor=u,t.cross.style.position="absolute",t.cross.style.left=t.cross.style.top="0",t.cross.style.width=t.cross.style.height=i+"px",t.crossBY.style.position=t.crossBX.style.position="absolute",t.crossBY.style.background=t.crossBX.style.background=d.pointerBorderColor,t.crossBY.style.width=t.crossBX.style.height=2*d.pointerBorderWidth+d.pointerThickness+"px",t.crossBY.style.height=t.crossBX.style.width=i+"px",t.crossBY.style.left=t.crossBX.style.top=Math.floor(i/2)-Math.floor(d.pointerThickness/2)-d.pointerBorderWidth+"px",t.crossBY.style.top=t.crossBX.style.left="0",t.crossLY.style.position=t.crossLX.style.position="absolute",t.crossLY.style.background=t.crossLX.style.background=d.pointerColor,t.crossLY.style.height=t.crossLX.style.width=i-2*d.pointerBorderWidth+"px",t.crossLY.style.width=t.crossLX.style.height=d.pointerThickness+"px",t.crossLY.style.left=t.crossLX.style.top=Math.floor(i/2)-Math.floor(d.pointerThickness/2)+"px",t.crossLY.style.top=t.crossLX.style.left=d.pointerBorderWidth+"px",t.sld.style.overflow="hidden",t.sld.style.width=d.sliderSize+"px",t.sld.style.height=d.height+"px",t.sldGrad.draw(d.sliderSize,d.height,"#000","#000"),t.sldB.style.display=n?"block":"none",t.sldB.style.position="absolute",t.sldB.style.right=d.padding+"px",t.sldB.style.top=d.padding+"px",t.sldB.style.border=d.insetWidth+"px solid",t.sldB.style.borderColor=d.insetColor,t.sldM._jscInstance=d,t.sldM._jscControlName="sld",t.sldM.style.display=n?"block":"none",t.sldM.style.position="absolute",t.sldM.style.right="0",t.sldM.style.top="0",t.sldM.style.width=d.sliderSize+s/2+d.padding+2*d.insetWidth+"px",t.sldM.style.height=r[1]+"px",t.sldM.style.cursor="default",t.sldPtrIB.style.border=t.sldPtrOB.style.border=d.pointerBorderWidth+"px solid "+d.pointerBorderColor,t.sldPtrOB.style.position="absolute",t.sldPtrOB.style.left=-(2*d.pointerBorderWidth+d.pointerThickness)+"px",t.sldPtrOB.style.top="0",t.sldPtrMB.style.border=d.pointerThickness+"px solid "+d.pointerColor,t.sldPtrS.style.width=d.sliderSize+"px",t.sldPtrS.style.height=m+"px",t.btn.style.display=d.closable?"block":"none",t.btn.style.position="absolute",t.btn.style.left=d.padding+"px",t.btn.style.bottom=d.padding+"px",t.btn.style.padding="0 15px",t.btn.style.height=d.buttonHeight+"px",t.btn.style.border=d.insetWidth+"px solid",l(),t.btn.style.color=d.buttonColor,t.btn.style.font="12px sans-serif",t.btn.style.textAlign="center";try{t.btn.style.cursor="pointer"}catch(c){t.btn.style.cursor="hand"}t.btn.onmousedown=function(){d.hide()},t.btnT.style.lineHeight=d.buttonHeight+"px",t.btnT.innerHTML="",t.btnT.appendChild(document.createTextNode(d.closeText)),a(),f(),e.picker.owner&&e.picker.owner!==d&&e.unsetClass(e.picker.owner.targetElement,d.activeClass),e.picker.owner=d,e.isElementType(v,"body")?e.redrawPosition():e._drawPosition(d,0,0,"relative",!1),t.wrap.parentNode!=v&&v.appendChild(t.wrap),e.setClass(d.targetElement,d.activeClass)}function a(){switch(e.getPadYComponent(d)){case"s":var t=1;break;case"v":var t=2}var n=Math.round(d.hsv[0]/360*(d.width-1)),r=Math.round((1-d.hsv[t]/100)*(d.height-1)),i=2*d.pointerBorderWidth+d.pointerThickness+2*d.crossSize,o=-Math.floor(i/2);e.picker.cross.style.left=n+o+"px",e.picker.cross.style.top=r+o+"px";switch(e.getSliderComponent(d)){case"s":var u=s(d.hsv[0],100,d.hsv[2]),a=s(d.hsv[0],0,d.hsv[2]),f="rgb("+Math.round(u[0])+","+Math.round(u[1])+","+Math.round(u[2])+")",l="rgb("+Math.round(a[0])+","+Math.round(a[1])+","+Math.round(a[2])+")";e.picker.sldGrad.draw(d.sliderSize,d.height,f,l);break;case"v":var c=s(d.hsv[0],d.hsv[1],100),f="rgb("+Math.round(c[0])+","+Math.round(c[1])+","+Math.round(c[2])+")",l="#000";e.picker.sldGrad.draw(d.sliderSize,d.height,f,l)}}function f(){var t=e.getSliderComponent(d);if(t){switch(t){case"s":var n=1;break;case"v":var n=2}var r=Math.round((1-d.hsv[n]/100)*(d.height-1));e.picker.sldPtrOB.style.top=r-(2*d.pointerBorderWidth+d.pointerThickness)-Math.floor(m/2)+"px"}}function l(){return e.picker&&e.picker.owner===d}function c(){d.importColor()}this.value=null,this.valueElement=t,this.styleElement=t,this.required=!0,this.refine=!0,this.hash=!1,this.uppercase=!0,this.onFineChange=null,this.activeClass="jscolor-active",this.minS=0,this.maxS=100,this.minV=0,this.maxV=100,this.hsv=[0,0,100],this.rgb=[255,255,255],this.width=181,this.height=101,this.showOnClick=!0,this.mode="HSV",this.position="bottom",this.smartPosition=!0,this.sliderSize=16,this.crossSize=8,this.closable=!1,this.closeText="Close",this.buttonColor="#000000",this.buttonHeight=18,this.padding=12,this.backgroundColor="#FFFFFF",this.borderWidth=1,this.borderColor="#BBBBBB",this.borderRadius=8,this.insetWidth=1,this.insetColor="#BBBBBB",this.shadow=!0,this.shadowBlur=15,this.shadowColor="rgba(0,0,0,0.2)",this.pointerColor="#4C4C4C",this.pointerBorderColor="#FFFFFF",this.pointerBorderWidth=1,this.pointerThickness=2,this.zIndex=1e3,this.container=null;for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.hide=function(){l()&&o()},this.show=function(){u()},this.redraw=function(){l()&&u()},this.importColor=function(){this.valueElement?e.isElementType(this.valueElement,"input")?this.refine?!this.required&&/^\s*$/.test(this.valueElement.value)?(this.valueElement.value="",this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(e.leaveValue|e.leaveStyle)):this.fromString(this.valueElement.value)||this.exportColor():this.fromString(this.valueElement.value,e.leaveValue)||(this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(e.leaveValue|e.leaveStyle)):this.exportColor():this.exportColor()},this.exportColor=function(t){if(!(t&e.leaveValue)&&this.valueElement){var n=this.toString();this.uppercase&&(n=n.toUpperCase()),this.hash&&(n="#"+n),e.isElementType(this.valueElement,"input")?this.valueElement.value=n:this.valueElement.innerHTML=n}t&e.leaveStyle||this.styleElement&&(this.styleElement.style.backgroundImage="none",this.styleElement.style.backgroundColor="#"+this.toString(),this.styleElement.style.color=this.isLight()?"#000":"#FFF"),!(t&e.leavePad)&&l()&&a(),!(t&e.leaveSld)&&l()&&f()},this.fromHSV=function(e,t,n,r){if(e!==null){if(isNaN(e))return!1;e=Math.max(0,Math.min(360,e))}if(t!==null){if(isNaN(t))return!1;t=Math.max(0,Math.min(100,this.maxS,t),this.minS)}if(n!==null){if(isNaN(n))return!1;n=Math.max(0,Math.min(100,this.maxV,n),this.minV)}this.rgb=s(e===null?this.hsv[0]:this.hsv[0]=e,t===null?this.hsv[1]:this.hsv[1]=t,n===null?this.hsv[2]:this.hsv[2]=n),this.exportColor(r)},this.fromRGB=function(e,t,n,r){if(e!==null){if(isNaN(e))return!1;e=Math.max(0,Math.min(255,e))}if(t!==null){if(isNaN(t))return!1;t=Math.max(0,Math.min(255,t))}if(n!==null){if(isNaN(n))return!1;n=Math.max(0,Math.min(255,n))}var o=i(e===null?this.rgb[0]:e,t===null?this.rgb[1]:t,n===null?this.rgb[2]:n);o[0]!==null&&(this.hsv[0]=Math.max(0,Math.min(360,o[0]))),o[2]!==0&&(this.hsv[1]=o[1]===null?null:Math.max(0,this.minS,Math.min(100,this.maxS,o[1]))),this.hsv[2]=o[2]===null?null:Math.max(0,this.minV,Math.min(100,this.maxV,o[2]));var u=s(this.hsv[0],this.hsv[1],this.hsv[2]);this.rgb[0]=u[0],this.rgb[1]=u[1],this.rgb[2]=u[2],this.exportColor(r)},this.fromString=function(e,t){var n;if(n=e.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i))return n[1].length===6?this.fromRGB(parseInt(n[1].substr(0,2),16),parseInt(n[1].substr(2,2),16),parseInt(n[1].substr(4,2),16),t):this.fromRGB(parseInt(n[1].charAt(0)+n[1].charAt(0),16),parseInt(n[1].charAt(1)+n[1].charAt(1),16),parseInt(n[1].charAt(2)+n[1].charAt(2),16),t),!0;if(n=e.match(/^\W*rgba?\(([^)]*)\)\W*$/i)){var r=n[1].split(","),i=/^\s*(\d*)(\.\d+)?\s*$/,s,o,u;if(r.length>=3&&(s=r[0].match(i))&&(o=r[1].match(i))&&(u=r[2].match(i))){var a=parseFloat((s[1]||"0")+(s[2]||"")),f=parseFloat((o[1]||"0")+(o[2]||"")),l=parseFloat((u[1]||"0")+(u[2]||""));return this.fromRGB(a,f,l,t),!0}}return!1},this.toString=function(){return(256|Math.round(this.rgb[0])).toString(16).substr(1)+(256|Math.round(this.rgb[1])).toString(16).substr(1)+(256|Math.round(this.rgb[2])).toString(16).substr(1)},this.toHEXString=function(){return"#"+this.toString().toUpperCase()},this.toRGBString=function(){return"rgb("+Math.round(this.rgb[0])+","+Math.round(this.rgb[1])+","+Math.round(this.rgb[2])+")"},this.isLight=function(){return.213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]>127.5},this._processParentElementsInDOM=function(){if(this._linkedElementsProcessed)return;this._linkedElementsProcessed=!0;var t=this.targetElement;do{var n=e.getStyle(t);n&&n.position.toLowerCase()==="fixed"&&(this.fixed=!0),t!==this.targetElement&&(t._jscEventsAttached||(e.attachEvent(t,"scroll",e.onParentScroll),t._jscEventsAttached=!0))}while((t=t.parentNode)&&!e.isElementType(t,"body"))};if(typeof t=="string"){var h=t,p=document.getElementById(h);p?this.targetElement=p:e.warn("Could not find target element with ID '"+h+"'")}else t?this.targetElement=t:e.warn("Invalid target element: '"+t+"'");if(this.targetElement._jscLinkedInstance){e.warn("Cannot link jscolor twice to the same element. Skipping.");return}this.targetElement._jscLinkedInstance=this,this.valueElement=e.fetchElement(this.valueElement),this.styleElement=e.fetchElement(this.styleElement);var d=this,v=this.container?e.fetchElement(this.container):document.getElementsByTagName("body")[0],m=3;if(e.isElementType(this.targetElement,"button"))if(this.targetElement.onclick){var g=this.targetElement.onclick;this.targetElement.onclick=function(e){return g.call(this,e),!1}}else this.targetElement.onclick=function(){return!1};if(this.valueElement&&e.isElementType(this.valueElement,"input")){var y=function(){d.fromString(d.valueElement.value,e.leaveValue),e.dispatchFineChange(d)};e.attachEvent(this.valueElement,"keyup",y),e.attachEvent(this.valueElement,"input",y),e.attachEvent(this.valueElement,"blur",c),this.valueElement.setAttribute("autocomplete","off")}this.styleElement&&(this.styleElement._jscOrigStyle={backgroundImage:this.styleElement.style.backgroundImage,backgroundColor:this.styleElement.style.backgroundColor,color:this.styleElement.style.color}),this.value?this.fromString(this.value)||this.exportColor():this.importColor()}};return e.jscolor.lookupClass="jscolor",e.jscolor.installByClassName=function(t){var n=document.getElementsByTagName("input"),r=document.getElementsByTagName("button");e.tryInstallOnElements(n,t),e.tryInstallOnElements(r,t)},e.register(),e.jscolor}());
|
1 |
+
/**
|
2 |
+
* jscolor - JavaScript Color Picker
|
3 |
+
*
|
4 |
+
* @link http://jscolor.com
|
5 |
+
* @license For open source use: GPLv3
|
6 |
+
* For commercial use: JSColor Commercial License
|
7 |
+
* @author Jan Odvarko
|
8 |
+
*
|
9 |
+
* See usage examples at http://jscolor.com/examples/
|
10 |
*/"use strict";window.jscolor||(window.jscolor=function(){var e={register:function(){e.attachDOMReadyEvent(e.init),e.attachEvent(document,"mousedown",e.onDocumentMouseDown),e.attachEvent(document,"touchstart",e.onDocumentTouchStart),e.attachEvent(window,"resize",e.onWindowResize)},init:function(){e.jscolor.lookupClass&&e.jscolor.installByClassName(e.jscolor.lookupClass)},tryInstallOnElements:function(t,n){var r=new RegExp("(^|\\s)("+n+")(\\s*(\\{[^}]*\\})|\\s|$)","i");for(var i=0;i<t.length;i+=1){if(t[i].type!==undefined&&t[i].type.toLowerCase()=="color"&&e.isColorAttrSupported)continue;var s;if(!t[i].jscolor&&t[i].className&&(s=t[i].className.match(r))){var o=t[i],u=null,a=e.getDataAttr(o,"jscolor");a!==null?u=a:s[4]&&(u=s[4]);var f={};if(u)try{f=(new Function("return ("+u+")"))()}catch(l){e.warn("Error parsing jscolor options: "+l+":\n"+u)}o.jscolor=new e.jscolor(o,f)}}},isColorAttrSupported:function(){var e=document.createElement("input");if(e.setAttribute){e.setAttribute("type","color");if(e.type.toLowerCase()=="color")return!0}return!1}(),isCanvasSupported:function(){var e=document.createElement("canvas");return!!e.getContext&&!!e.getContext("2d")}(),fetchElement:function(e){return typeof e=="string"?document.getElementById(e):e},isElementType:function(e,t){return e.nodeName.toLowerCase()===t.toLowerCase()},getDataAttr:function(e,t){var n="data-"+t,r=e.getAttribute(n);return r!==null?r:null},attachEvent:function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&e.attachEvent("on"+t,n)},detachEvent:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)},_attachedGroupEvents:{},attachGroupEvent:function(t,n,r,i){e._attachedGroupEvents.hasOwnProperty(t)||(e._attachedGroupEvents[t]=[]),e._attachedGroupEvents[t].push([n,r,i]),e.attachEvent(n,r,i)},detachGroupEvents:function(t){if(e._attachedGroupEvents.hasOwnProperty(t)){for(var n=0;n<e._attachedGroupEvents[t].length;n+=1){var r=e._attachedGroupEvents[t][n];e.detachEvent(r[0],r[1],r[2])}delete e._attachedGroupEvents[t]}},attachDOMReadyEvent:function(e){var t=!1,n=function(){t||(t=!0,e())};if(document.readyState==="complete"){setTimeout(n,1);return}if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",function(){document.readyState==="complete"&&(document.detachEvent("onreadystatechange",arguments.callee),n())}),window.attachEvent("onload",n);if(document.documentElement.doScroll&&window==window.top){var r=function(){if(!document.body)return;try{document.documentElement.doScroll("left"),n()}catch(e){setTimeout(r,1)}};r()}}},warn:function(e){window.console&&window.console.warn&&window.console.warn(e)},preventDefault:function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},captureTarget:function(t){t.setCapture&&(e._capturedTarget=t,e._capturedTarget.setCapture())},releaseTarget:function(){e._capturedTarget&&(e._capturedTarget.releaseCapture(),e._capturedTarget=null)},fireEvent:function(e,t){if(!e)return;if(document.createEvent){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}else if(document.createEventObject){var n=document.createEventObject();e.fireEvent("on"+t,n)}else e["on"+t]&&e["on"+t]()},classNameToList:function(e){return e.replace(/^\s+|\s+$/g,"").split(/\s+/)},hasClass:function(e,t){return t?-1!=(" "+e.className.replace(/\s+/g," ")+" ").indexOf(" "+t+" "):!1},setClass:function(t,n){var r=e.classNameToList(n);for(var i=0;i<r.length;i+=1)e.hasClass(t,r[i])||(t.className+=(t.className?" ":"")+r[i])},unsetClass:function(t,n){var r=e.classNameToList(n);for(var i=0;i<r.length;i+=1){var s=new RegExp("^\\s*"+r[i]+"\\s*|"+"\\s*"+r[i]+"\\s*$|"+"\\s+"+r[i]+"(\\s+)","g");t.className=t.className.replace(s,"$1")}},getStyle:function(e){return window.getComputedStyle?window.getComputedStyle(e):e.currentStyle},setStyle:function(){var e=document.createElement("div"),t=function(t){for(var n=0;n<t.length;n+=1)if(t[n]in e.style)return t[n]},n={borderRadius:t(["borderRadius","MozBorderRadius","webkitBorderRadius"]),boxShadow:t(["boxShadow","MozBoxShadow","webkitBoxShadow"])};return function(e,t,r){switch(t.toLowerCase()){case"opacity":var i=Math.round(parseFloat(r)*100);e.style.opacity=r,e.style.filter="alpha(opacity="+i+")";break;default:e.style[n[t]]=r}}}(),setBorderRadius:function(t,n){e.setStyle(t,"borderRadius",n||"0")},setBoxShadow:function(t,n){e.setStyle(t,"boxShadow",n||"none")},getElementPos:function(t,n){var r=0,i=0,s=t.getBoundingClientRect();r=s.left,i=s.top;if(!n){var o=e.getViewPos();r+=o[0],i+=o[1]}return[r,i]},getElementSize:function(e){return[e.offsetWidth,e.offsetHeight]},getAbsPointerPos:function(e){e||(e=window.event);var t=0,n=0;return typeof e.changedTouches!="undefined"&&e.changedTouches.length?(t=e.changedTouches[0].clientX,n=e.changedTouches[0].clientY):typeof e.clientX=="number"&&(t=e.clientX,n=e.clientY),{x:t,y:n}},getRelPointerPos:function(e){e||(e=window.event);var t=e.target||e.srcElement,n=t.getBoundingClientRect(),r=0,i=0,s=0,o=0;return typeof e.changedTouches!="undefined"&&e.changedTouches.length?(s=e.changedTouches[0].clientX,o=e.changedTouches[0].clientY):typeof e.clientX=="number"&&(s=e.clientX,o=e.clientY),r=s-n.left,i=o-n.top,{x:r,y:i}},getViewPos:function(){var e=document.documentElement;return[(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0),(window.pageYOffset||e.scrollTop)-(e.clientTop||0)]},getViewSize:function(){var e=document.documentElement;return[window.innerWidth||e.clientWidth,window.innerHeight||e.clientHeight]},redrawPosition:function(){if(e.picker&&e.picker.owner){var t=e.picker.owner,n,r;t.fixed?(n=e.getElementPos(t.targetElement,!0),r=[0,0]):(n=e.getElementPos(t.targetElement),r=e.getViewPos());var i=e.getElementSize(t.targetElement),s=e.getViewSize(),o=e.getPickerOuterDims(t),u,a,f;switch(t.position.toLowerCase()){case"left":u=1,a=0,f=-1;break;case"right":u=1,a=0,f=1;break;case"top":u=0,a=1,f=-1;break;default:u=0,a=1,f=1}var l=(i[a]+o[a])/2;if(!t.smartPosition)var c=[n[u],n[a]+i[a]-l+l*f];else var c=[-r[u]+n[u]+o[u]>s[u]?-r[u]+n[u]+i[u]/2>s[u]/2&&n[u]+i[u]-o[u]>=0?n[u]+i[u]-o[u]:n[u]:n[u],-r[a]+n[a]+i[a]+o[a]-l+l*f>s[a]?-r[a]+n[a]+i[a]/2>s[a]/2&&n[a]+i[a]-l-l*f>=0?n[a]+i[a]-l-l*f:n[a]+i[a]-l+l*f:n[a]+i[a]-l+l*f>=0?n[a]+i[a]-l+l*f:n[a]+i[a]-l-l*f];var h=c[u],p=c[a],d=t.fixed?"fixed":"absolute",v=(c[0]+o[0]>n[0]||c[0]<n[0]+i[0])&&c[1]+o[1]<n[1]+i[1];e._drawPosition(t,h,p,d,v)}},_drawPosition:function(t,n,r,i,s){var o=s?0:t.shadowBlur;e.picker.wrap.style.position=i,e.picker.wrap.style.left=n+"px",e.picker.wrap.style.top=r+"px",e.setBoxShadow(e.picker.boxS,t.shadow?new e.BoxShadow(0,o,t.shadowBlur,0,t.shadowColor):null)},getPickerDims:function(t){var n=!!e.getSliderComponent(t),r=[2*t.insetWidth+2*t.padding+t.width+(n?2*t.insetWidth+e.getPadToSliderPadding(t)+t.sliderSize:0),2*t.insetWidth+2*t.padding+t.height+(t.closable?2*t.insetWidth+t.padding+t.buttonHeight:0)];return r},getPickerOuterDims:function(t){var n=e.getPickerDims(t);return[n[0]+2*t.borderWidth,n[1]+2*t.borderWidth]},getPadToSliderPadding:function(e){return Math.max(e.padding,1.5*(2*e.pointerBorderWidth+e.pointerThickness))},getPadYComponent:function(e){switch(e.mode.charAt(1).toLowerCase()){case"v":return"v"}return"s"},getSliderComponent:function(e){if(e.mode.length>2)switch(e.mode.charAt(2).toLowerCase()){case"s":return"s";case"v":return"v"}return null},onDocumentMouseDown:function(t){t||(t=window.event);var n=t.target||t.srcElement;n._jscLinkedInstance?n._jscLinkedInstance.showOnClick&&n._jscLinkedInstance.show():n._jscControlName?e.onControlPointerStart(t,n,n._jscControlName,"mouse"):e.picker&&e.picker.owner&&e.picker.owner.hide()},onDocumentTouchStart:function(t){t||(t=window.event);var n=t.target||t.srcElement;n._jscLinkedInstance?n._jscLinkedInstance.showOnClick&&n._jscLinkedInstance.show():n._jscControlName?e.onControlPointerStart(t,n,n._jscControlName,"touch"):e.picker&&e.picker.owner&&e.picker.owner.hide()},onWindowResize:function(t){e.redrawPosition()},onParentScroll:function(t){e.picker&&e.picker.owner&&e.picker.owner.hide()},_pointerMoveEvent:{mouse:"mousemove",touch:"touchmove"},_pointerEndEvent:{mouse:"mouseup",touch:"touchend"},_pointerOrigin:null,_capturedTarget:null,onControlPointerStart:function(t,n,r,i){var s=n._jscInstance;e.preventDefault(t),e.captureTarget(n);var o=function(s,o){e.attachGroupEvent("drag",s,e._pointerMoveEvent[i],e.onDocumentPointerMove(t,n,r,i,o)),e.attachGroupEvent("drag",s,e._pointerEndEvent[i],e.onDocumentPointerEnd(t,n,r,i))};o(document,[0,0]);if(window.parent&&window.frameElement){var u=window.frameElement.getBoundingClientRect(),a=[-u.left,-u.top];o(window.parent.window.document,a)}var f=e.getAbsPointerPos(t),l=e.getRelPointerPos(t);e._pointerOrigin={x:f.x-l.x,y:f.y-l.y};switch(r){case"pad":switch(e.getSliderComponent(s)){case"s":s.hsv[1]===0&&s.fromHSV(null,100,null);break;case"v":s.hsv[2]===0&&s.fromHSV(null,null,100)}e.setPad(s,t,0,0);break;case"sld":e.setSld(s,t,0)}e.dispatchFineChange(s)},onDocumentPointerMove:function(t,n,r,i,s){return function(t){var i=n._jscInstance;switch(r){case"pad":t||(t=window.event),e.setPad(i,t,s[0],s[1]),e.dispatchFineChange(i);break;case"sld":t||(t=window.event),e.setSld(i,t,s[1]),e.dispatchFineChange(i)}}},onDocumentPointerEnd:function(t,n,r,i){return function(t){var r=n._jscInstance;e.detachGroupEvents("drag"),e.releaseTarget(),e.dispatchChange(r)}},dispatchChange:function(t){t.valueElement&&e.isElementType(t.valueElement,"input")&&e.fireEvent(t.valueElement,"change")},dispatchFineChange:function(e){if(e.onFineChange){var t;typeof e.onFineChange=="string"?t=new Function(e.onFineChange):t=e.onFineChange,t.call(e)}},setPad:function(t,n,r,i){var s=e.getAbsPointerPos(n),o=r+s.x-e._pointerOrigin.x-t.padding-t.insetWidth,u=i+s.y-e._pointerOrigin.y-t.padding-t.insetWidth,a=o*(360/(t.width-1)),f=100-u*(100/(t.height-1));switch(e.getPadYComponent(t)){case"s":t.fromHSV(a,f,null,e.leaveSld);break;case"v":t.fromHSV(a,null,f,e.leaveSld)}},setSld:function(t,n,r){var i=e.getAbsPointerPos(n),s=r+i.y-e._pointerOrigin.y-t.padding-t.insetWidth,o=100-s*(100/(t.height-1));switch(e.getSliderComponent(t)){case"s":t.fromHSV(null,o,null,e.leavePad);break;case"v":t.fromHSV(null,null,o,e.leavePad)}},_vmlNS:"jsc_vml_",_vmlCSS:"jsc_vml_css_",_vmlReady:!1,initVML:function(){if(!e._vmlReady){var t=document;t.namespaces[e._vmlNS]||t.namespaces.add(e._vmlNS,"urn:schemas-microsoft-com:vml");if(!t.styleSheets[e._vmlCSS]){var n=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","rect","roundrect","oval","arc","image"],r=t.createStyleSheet();r.owningElement.id=e._vmlCSS;for(var i=0;i<n.length;i+=1)r.addRule(e._vmlNS+"\\:"+n[i],"behavior:url(#default#VML);")}e._vmlReady=!0}},createPalette:function(){var t={elm:null,draw:null};if(e.isCanvasSupported){var n=document.createElement("canvas"),r=n.getContext("2d"),i=function(e,t,i){n.width=e,n.height=t,r.clearRect(0,0,n.width,n.height);var s=r.createLinearGradient(0,0,n.width,0);s.addColorStop(0,"#F00"),s.addColorStop(1/6,"#FF0"),s.addColorStop(2/6,"#0F0"),s.addColorStop(.5,"#0FF"),s.addColorStop(4/6,"#00F"),s.addColorStop(5/6,"#F0F"),s.addColorStop(1,"#F00"),r.fillStyle=s,r.fillRect(0,0,n.width,n.height);var o=r.createLinearGradient(0,0,0,n.height);switch(i.toLowerCase()){case"s":o.addColorStop(0,"rgba(255,255,255,0)"),o.addColorStop(1,"rgba(255,255,255,1)");break;case"v":o.addColorStop(0,"rgba(0,0,0,0)"),o.addColorStop(1,"rgba(0,0,0,1)")}r.fillStyle=o,r.fillRect(0,0,n.width,n.height)};t.elm=n,t.draw=i}else{e.initVML();var s=document.createElement("div");s.style.position="relative",s.style.overflow="hidden";var o=document.createElement(e._vmlNS+":fill");o.type="gradient",o.method="linear",o.angle="90",o.colors="16.67% #F0F, 33.33% #00F, 50% #0FF, 66.67% #0F0, 83.33% #FF0";var u=document.createElement(e._vmlNS+":rect");u.style.position="absolute",u.style.left="-1px",u.style.top="-1px",u.stroked=!1,u.appendChild(o),s.appendChild(u);var a=document.createElement(e._vmlNS+":fill");a.type="gradient",a.method="linear",a.angle="180",a.opacity="0";var f=document.createElement(e._vmlNS+":rect");f.style.position="absolute",f.style.left="-1px",f.style.top="-1px",f.stroked=!1,f.appendChild(a),s.appendChild(f);var i=function(e,t,n){s.style.width=e+"px",s.style.height=t+"px",u.style.width=f.style.width=e+1+"px",u.style.height=f.style.height=t+1+"px",o.color="#F00",o.color2="#F00";switch(n.toLowerCase()){case"s":a.color=a.color2="#FFF";break;case"v":a.color=a.color2="#000"}};t.elm=s,t.draw=i}return t},createSliderGradient:function(){var t={elm:null,draw:null};if(e.isCanvasSupported){var n=document.createElement("canvas"),r=n.getContext("2d"),i=function(e,t,i,s){n.width=e,n.height=t,r.clearRect(0,0,n.width,n.height);var o=r.createLinearGradient(0,0,0,n.height);o.addColorStop(0,i),o.addColorStop(1,s),r.fillStyle=o,r.fillRect(0,0,n.width,n.height)};t.elm=n,t.draw=i}else{e.initVML();var s=document.createElement("div");s.style.position="relative",s.style.overflow="hidden";var o=document.createElement(e._vmlNS+":fill");o.type="gradient",o.method="linear",o.angle="180";var u=document.createElement(e._vmlNS+":rect");u.style.position="absolute",u.style.left="-1px",u.style.top="-1px",u.stroked=!1,u.appendChild(o),s.appendChild(u);var i=function(e,t,n,r){s.style.width=e+"px",s.style.height=t+"px",u.style.width=e+1+"px",u.style.height=t+1+"px",o.color=n,o.color2=r};t.elm=s,t.draw=i}return t},leaveValue:1,leaveStyle:2,leavePad:4,leaveSld:8,BoxShadow:function(){var e=function(e,t,n,r,i,s){this.hShadow=e,this.vShadow=t,this.blur=n,this.spread=r,this.color=i,this.inset=!!s};return e.prototype.toString=function(){var e=[Math.round(this.hShadow)+"px",Math.round(this.vShadow)+"px",Math.round(this.blur)+"px",Math.round(this.spread)+"px",this.color];return this.inset&&e.push("inset"),e.join(" ")},e}(),jscolor:function(t,n){function i(e,t,n){e/=255,t/=255,n/=255;var r=Math.min(Math.min(e,t),n),i=Math.max(Math.max(e,t),n),s=i-r;if(s===0)return[null,0,100*i];var o=e===r?3+(n-t)/s:t===r?5+(e-n)/s:1+(t-e)/s;return[60*(o===6?0:o),100*(s/i),100*i]}function s(e,t,n){var r=255*(n/100);if(e===null)return[r,r,r];e/=60,t/=100;var i=Math.floor(e),s=i%2?e-i:1-(e-i),o=r*(1-t),u=r*(1-t*s);switch(i){case 6:case 0:return[r,u,o];case 1:return[u,r,o];case 2:return[o,r,u];case 3:return[o,u,r];case 4:return[u,o,r];case 5:return[r,o,u]}}function o(){e.unsetClass(d.targetElement,d.activeClass),e.picker.wrap.parentNode.removeChild(e.picker.wrap),delete e.picker.owner}function u(){function l(){var e=d.insetColor.split(/\s+/),n=e.length<2?e[0]:e[1]+" "+e[0]+" "+e[0]+" "+e[1];t.btn.style.borderColor=n}d._processParentElementsInDOM(),e.picker||(e.picker={owner:null,wrap:document.createElement("div"),box:document.createElement("div"),boxS:document.createElement("div"),boxB:document.createElement("div"),pad:document.createElement("div"),padB:document.createElement("div"),padM:document.createElement("div"),padPal:e.createPalette(),cross:document.createElement("div"),crossBY:document.createElement("div"),crossBX:document.createElement("div"),crossLY:document.createElement("div"),crossLX:document.createElement("div"),sld:document.createElement("div"),sldB:document.createElement("div"),sldM:document.createElement("div"),sldGrad:e.createSliderGradient(),sldPtrS:document.createElement("div"),sldPtrIB:document.createElement("div"),sldPtrMB:document.createElement("div"),sldPtrOB:document.createElement("div"),btn:document.createElement("div"),btnT:document.createElement("span")},e.picker.pad.appendChild(e.picker.padPal.elm),e.picker.padB.appendChild(e.picker.pad),e.picker.cross.appendChild(e.picker.crossBY),e.picker.cross.appendChild(e.picker.crossBX),e.picker.cross.appendChild(e.picker.crossLY),e.picker.cross.appendChild(e.picker.crossLX),e.picker.padB.appendChild(e.picker.cross),e.picker.box.appendChild(e.picker.padB),e.picker.box.appendChild(e.picker.padM),e.picker.sld.appendChild(e.picker.sldGrad.elm),e.picker.sldB.appendChild(e.picker.sld),e.picker.sldB.appendChild(e.picker.sldPtrOB),e.picker.sldPtrOB.appendChild(e.picker.sldPtrMB),e.picker.sldPtrMB.appendChild(e.picker.sldPtrIB),e.picker.sldPtrIB.appendChild(e.picker.sldPtrS),e.picker.box.appendChild(e.picker.sldB),e.picker.box.appendChild(e.picker.sldM),e.picker.btn.appendChild(e.picker.btnT),e.picker.box.appendChild(e.picker.btn),e.picker.boxB.appendChild(e.picker.box),e.picker.wrap.appendChild(e.picker.boxS),e.picker.wrap.appendChild(e.picker.boxB));var t=e.picker,n=!!e.getSliderComponent(d),r=e.getPickerDims(d),i=2*d.pointerBorderWidth+d.pointerThickness+2*d.crossSize,s=e.getPadToSliderPadding(d),o=Math.min(d.borderRadius,Math.round(d.padding*Math.PI)),u="crosshair";t.wrap.style.clear="both",t.wrap.style.width=r[0]+2*d.borderWidth+"px",t.wrap.style.height=r[1]+2*d.borderWidth+"px",t.wrap.style.zIndex=d.zIndex,t.box.style.width=r[0]+"px",t.box.style.height=r[1]+"px",t.boxS.style.position="absolute",t.boxS.style.left="0",t.boxS.style.top="0",t.boxS.style.width="100%",t.boxS.style.height="100%",e.setBorderRadius(t.boxS,o+"px"),t.boxB.style.position="relative",t.boxB.style.border=d.borderWidth+"px solid",t.boxB.style.borderColor=d.borderColor,t.boxB.style.background=d.backgroundColor,e.setBorderRadius(t.boxB,o+"px"),t.padM.style.background=t.sldM.style.background="#FFF",e.setStyle(t.padM,"opacity","0"),e.setStyle(t.sldM,"opacity","0"),t.pad.style.position="relative",t.pad.style.width=d.width+"px",t.pad.style.height=d.height+"px",t.padPal.draw(d.width,d.height,e.getPadYComponent(d)),t.padB.style.position="absolute",t.padB.style.left=d.padding+"px",t.padB.style.top=d.padding+"px",t.padB.style.border=d.insetWidth+"px solid",t.padB.style.borderColor=d.insetColor,t.padM._jscInstance=d,t.padM._jscControlName="pad",t.padM.style.position="absolute",t.padM.style.left="0",t.padM.style.top="0",t.padM.style.width=d.padding+2*d.insetWidth+d.width+s/2+"px",t.padM.style.height=r[1]+"px",t.padM.style.cursor=u,t.cross.style.position="absolute",t.cross.style.left=t.cross.style.top="0",t.cross.style.width=t.cross.style.height=i+"px",t.crossBY.style.position=t.crossBX.style.position="absolute",t.crossBY.style.background=t.crossBX.style.background=d.pointerBorderColor,t.crossBY.style.width=t.crossBX.style.height=2*d.pointerBorderWidth+d.pointerThickness+"px",t.crossBY.style.height=t.crossBX.style.width=i+"px",t.crossBY.style.left=t.crossBX.style.top=Math.floor(i/2)-Math.floor(d.pointerThickness/2)-d.pointerBorderWidth+"px",t.crossBY.style.top=t.crossBX.style.left="0",t.crossLY.style.position=t.crossLX.style.position="absolute",t.crossLY.style.background=t.crossLX.style.background=d.pointerColor,t.crossLY.style.height=t.crossLX.style.width=i-2*d.pointerBorderWidth+"px",t.crossLY.style.width=t.crossLX.style.height=d.pointerThickness+"px",t.crossLY.style.left=t.crossLX.style.top=Math.floor(i/2)-Math.floor(d.pointerThickness/2)+"px",t.crossLY.style.top=t.crossLX.style.left=d.pointerBorderWidth+"px",t.sld.style.overflow="hidden",t.sld.style.width=d.sliderSize+"px",t.sld.style.height=d.height+"px",t.sldGrad.draw(d.sliderSize,d.height,"#000","#000"),t.sldB.style.display=n?"block":"none",t.sldB.style.position="absolute",t.sldB.style.right=d.padding+"px",t.sldB.style.top=d.padding+"px",t.sldB.style.border=d.insetWidth+"px solid",t.sldB.style.borderColor=d.insetColor,t.sldM._jscInstance=d,t.sldM._jscControlName="sld",t.sldM.style.display=n?"block":"none",t.sldM.style.position="absolute",t.sldM.style.right="0",t.sldM.style.top="0",t.sldM.style.width=d.sliderSize+s/2+d.padding+2*d.insetWidth+"px",t.sldM.style.height=r[1]+"px",t.sldM.style.cursor="default",t.sldPtrIB.style.border=t.sldPtrOB.style.border=d.pointerBorderWidth+"px solid "+d.pointerBorderColor,t.sldPtrOB.style.position="absolute",t.sldPtrOB.style.left=-(2*d.pointerBorderWidth+d.pointerThickness)+"px",t.sldPtrOB.style.top="0",t.sldPtrMB.style.border=d.pointerThickness+"px solid "+d.pointerColor,t.sldPtrS.style.width=d.sliderSize+"px",t.sldPtrS.style.height=m+"px",t.btn.style.display=d.closable?"block":"none",t.btn.style.position="absolute",t.btn.style.left=d.padding+"px",t.btn.style.bottom=d.padding+"px",t.btn.style.padding="0 15px",t.btn.style.height=d.buttonHeight+"px",t.btn.style.border=d.insetWidth+"px solid",l(),t.btn.style.color=d.buttonColor,t.btn.style.font="12px sans-serif",t.btn.style.textAlign="center";try{t.btn.style.cursor="pointer"}catch(c){t.btn.style.cursor="hand"}t.btn.onmousedown=function(){d.hide()},t.btnT.style.lineHeight=d.buttonHeight+"px",t.btnT.innerHTML="",t.btnT.appendChild(document.createTextNode(d.closeText)),a(),f(),e.picker.owner&&e.picker.owner!==d&&e.unsetClass(e.picker.owner.targetElement,d.activeClass),e.picker.owner=d,e.isElementType(v,"body")?e.redrawPosition():e._drawPosition(d,0,0,"relative",!1),t.wrap.parentNode!=v&&v.appendChild(t.wrap),e.setClass(d.targetElement,d.activeClass)}function a(){switch(e.getPadYComponent(d)){case"s":var t=1;break;case"v":var t=2}var n=Math.round(d.hsv[0]/360*(d.width-1)),r=Math.round((1-d.hsv[t]/100)*(d.height-1)),i=2*d.pointerBorderWidth+d.pointerThickness+2*d.crossSize,o=-Math.floor(i/2);e.picker.cross.style.left=n+o+"px",e.picker.cross.style.top=r+o+"px";switch(e.getSliderComponent(d)){case"s":var u=s(d.hsv[0],100,d.hsv[2]),a=s(d.hsv[0],0,d.hsv[2]),f="rgb("+Math.round(u[0])+","+Math.round(u[1])+","+Math.round(u[2])+")",l="rgb("+Math.round(a[0])+","+Math.round(a[1])+","+Math.round(a[2])+")";e.picker.sldGrad.draw(d.sliderSize,d.height,f,l);break;case"v":var c=s(d.hsv[0],d.hsv[1],100),f="rgb("+Math.round(c[0])+","+Math.round(c[1])+","+Math.round(c[2])+")",l="#000";e.picker.sldGrad.draw(d.sliderSize,d.height,f,l)}}function f(){var t=e.getSliderComponent(d);if(t){switch(t){case"s":var n=1;break;case"v":var n=2}var r=Math.round((1-d.hsv[n]/100)*(d.height-1));e.picker.sldPtrOB.style.top=r-(2*d.pointerBorderWidth+d.pointerThickness)-Math.floor(m/2)+"px"}}function l(){return e.picker&&e.picker.owner===d}function c(){d.importColor()}this.value=null,this.valueElement=t,this.styleElement=t,this.required=!0,this.refine=!0,this.hash=!1,this.uppercase=!0,this.onFineChange=null,this.activeClass="jscolor-active",this.minS=0,this.maxS=100,this.minV=0,this.maxV=100,this.hsv=[0,0,100],this.rgb=[255,255,255],this.width=181,this.height=101,this.showOnClick=!0,this.mode="HSV",this.position="bottom",this.smartPosition=!0,this.sliderSize=16,this.crossSize=8,this.closable=!1,this.closeText="Close",this.buttonColor="#000000",this.buttonHeight=18,this.padding=12,this.backgroundColor="#FFFFFF",this.borderWidth=1,this.borderColor="#BBBBBB",this.borderRadius=8,this.insetWidth=1,this.insetColor="#BBBBBB",this.shadow=!0,this.shadowBlur=15,this.shadowColor="rgba(0,0,0,0.2)",this.pointerColor="#4C4C4C",this.pointerBorderColor="#FFFFFF",this.pointerBorderWidth=1,this.pointerThickness=2,this.zIndex=1e3,this.container=null;for(var r in n)n.hasOwnProperty(r)&&(this[r]=n[r]);this.hide=function(){l()&&o()},this.show=function(){u()},this.redraw=function(){l()&&u()},this.importColor=function(){this.valueElement?e.isElementType(this.valueElement,"input")?this.refine?!this.required&&/^\s*$/.test(this.valueElement.value)?(this.valueElement.value="",this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(e.leaveValue|e.leaveStyle)):this.fromString(this.valueElement.value)||this.exportColor():this.fromString(this.valueElement.value,e.leaveValue)||(this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(e.leaveValue|e.leaveStyle)):this.exportColor():this.exportColor()},this.exportColor=function(t){if(!(t&e.leaveValue)&&this.valueElement){var n=this.toString();this.uppercase&&(n=n.toUpperCase()),this.hash&&(n="#"+n),e.isElementType(this.valueElement,"input")?this.valueElement.value=n:this.valueElement.innerHTML=n}t&e.leaveStyle||this.styleElement&&(this.styleElement.style.backgroundImage="none",this.styleElement.style.backgroundColor="#"+this.toString(),this.styleElement.style.color=this.isLight()?"#000":"#FFF"),!(t&e.leavePad)&&l()&&a(),!(t&e.leaveSld)&&l()&&f()},this.fromHSV=function(e,t,n,r){if(e!==null){if(isNaN(e))return!1;e=Math.max(0,Math.min(360,e))}if(t!==null){if(isNaN(t))return!1;t=Math.max(0,Math.min(100,this.maxS,t),this.minS)}if(n!==null){if(isNaN(n))return!1;n=Math.max(0,Math.min(100,this.maxV,n),this.minV)}this.rgb=s(e===null?this.hsv[0]:this.hsv[0]=e,t===null?this.hsv[1]:this.hsv[1]=t,n===null?this.hsv[2]:this.hsv[2]=n),this.exportColor(r)},this.fromRGB=function(e,t,n,r){if(e!==null){if(isNaN(e))return!1;e=Math.max(0,Math.min(255,e))}if(t!==null){if(isNaN(t))return!1;t=Math.max(0,Math.min(255,t))}if(n!==null){if(isNaN(n))return!1;n=Math.max(0,Math.min(255,n))}var o=i(e===null?this.rgb[0]:e,t===null?this.rgb[1]:t,n===null?this.rgb[2]:n);o[0]!==null&&(this.hsv[0]=Math.max(0,Math.min(360,o[0]))),o[2]!==0&&(this.hsv[1]=o[1]===null?null:Math.max(0,this.minS,Math.min(100,this.maxS,o[1]))),this.hsv[2]=o[2]===null?null:Math.max(0,this.minV,Math.min(100,this.maxV,o[2]));var u=s(this.hsv[0],this.hsv[1],this.hsv[2]);this.rgb[0]=u[0],this.rgb[1]=u[1],this.rgb[2]=u[2],this.exportColor(r)},this.fromString=function(e,t){var n;if(n=e.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i))return n[1].length===6?this.fromRGB(parseInt(n[1].substr(0,2),16),parseInt(n[1].substr(2,2),16),parseInt(n[1].substr(4,2),16),t):this.fromRGB(parseInt(n[1].charAt(0)+n[1].charAt(0),16),parseInt(n[1].charAt(1)+n[1].charAt(1),16),parseInt(n[1].charAt(2)+n[1].charAt(2),16),t),!0;if(n=e.match(/^\W*rgba?\(([^)]*)\)\W*$/i)){var r=n[1].split(","),i=/^\s*(\d*)(\.\d+)?\s*$/,s,o,u;if(r.length>=3&&(s=r[0].match(i))&&(o=r[1].match(i))&&(u=r[2].match(i))){var a=parseFloat((s[1]||"0")+(s[2]||"")),f=parseFloat((o[1]||"0")+(o[2]||"")),l=parseFloat((u[1]||"0")+(u[2]||""));return this.fromRGB(a,f,l,t),!0}}return!1},this.toString=function(){return(256|Math.round(this.rgb[0])).toString(16).substr(1)+(256|Math.round(this.rgb[1])).toString(16).substr(1)+(256|Math.round(this.rgb[2])).toString(16).substr(1)},this.toHEXString=function(){return"#"+this.toString().toUpperCase()},this.toRGBString=function(){return"rgb("+Math.round(this.rgb[0])+","+Math.round(this.rgb[1])+","+Math.round(this.rgb[2])+")"},this.isLight=function(){return.213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]>127.5},this._processParentElementsInDOM=function(){if(this._linkedElementsProcessed)return;this._linkedElementsProcessed=!0;var t=this.targetElement;do{var n=e.getStyle(t);n&&n.position.toLowerCase()==="fixed"&&(this.fixed=!0),t!==this.targetElement&&(t._jscEventsAttached||(e.attachEvent(t,"scroll",e.onParentScroll),t._jscEventsAttached=!0))}while((t=t.parentNode)&&!e.isElementType(t,"body"))};if(typeof t=="string"){var h=t,p=document.getElementById(h);p?this.targetElement=p:e.warn("Could not find target element with ID '"+h+"'")}else t?this.targetElement=t:e.warn("Invalid target element: '"+t+"'");if(this.targetElement._jscLinkedInstance){e.warn("Cannot link jscolor twice to the same element. Skipping.");return}this.targetElement._jscLinkedInstance=this,this.valueElement=e.fetchElement(this.valueElement),this.styleElement=e.fetchElement(this.styleElement);var d=this,v=this.container?e.fetchElement(this.container):document.getElementsByTagName("body")[0],m=3;if(e.isElementType(this.targetElement,"button"))if(this.targetElement.onclick){var g=this.targetElement.onclick;this.targetElement.onclick=function(e){return g.call(this,e),!1}}else this.targetElement.onclick=function(){return!1};if(this.valueElement&&e.isElementType(this.valueElement,"input")){var y=function(){d.fromString(d.valueElement.value,e.leaveValue),e.dispatchFineChange(d)};e.attachEvent(this.valueElement,"keyup",y),e.attachEvent(this.valueElement,"input",y),e.attachEvent(this.valueElement,"blur",c),this.valueElement.setAttribute("autocomplete","off")}this.styleElement&&(this.styleElement._jscOrigStyle={backgroundImage:this.styleElement.style.backgroundImage,backgroundColor:this.styleElement.style.backgroundColor,color:this.styleElement.style.color}),this.value?this.fromString(this.value)||this.exportColor():this.importColor()}};return e.jscolor.lookupClass="jscolor",e.jscolor.installByClassName=function(t){var n=document.getElementsByTagName("input"),r=document.getElementsByTagName("button");e.tryInstallOnElements(n,t),e.tryInstallOnElements(r,t)},e.register(),e.jscolor}());
|
assets/js/quads-admin.js
CHANGED
@@ -1,1800 +1,1800 @@
|
|
1 |
-
var strict;
|
2 |
-
|
3 |
-
|
4 |
-
jQuery(document).ready(function ($) {
|
5 |
-
|
6 |
-
// show / hide helper description
|
7 |
-
$('.quads-tooltip').click(function (e) {
|
8 |
-
e.preventDefault();
|
9 |
-
var icon = $(this),
|
10 |
-
bubble = $(this).next();
|
11 |
-
|
12 |
-
// Close any that are already open
|
13 |
-
$('.quads-tooltip-message').not(bubble).hide();
|
14 |
-
|
15 |
-
var position = icon.position();
|
16 |
-
if (bubble.hasClass('bottom')) {
|
17 |
-
bubble.css({
|
18 |
-
'left': (position.left - bubble.width() / 2) + 'px',
|
19 |
-
'top': (position.top + icon.height() + 9) + 'px'
|
20 |
-
});
|
21 |
-
} else {
|
22 |
-
bubble.css({
|
23 |
-
'left': (position.left + icon.width() + 9) + 'px',
|
24 |
-
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
25 |
-
});
|
26 |
-
}
|
27 |
-
|
28 |
-
bubble.toggle();
|
29 |
-
e.stopPropagation();
|
30 |
-
});
|
31 |
-
|
32 |
-
$('body').click(function () {
|
33 |
-
$('.quads-tooltip-message').hide();
|
34 |
-
});
|
35 |
-
|
36 |
-
$('.quads-tooltip-message').click(function (e) {
|
37 |
-
e.stopPropagation();
|
38 |
-
});
|
39 |
-
|
40 |
-
|
41 |
-
// vi login process
|
42 |
-
$("#quads_vi_login_submit").click(function(e){
|
43 |
-
e.preventDefault();
|
44 |
-
username = $("#quads-vi-email").val();
|
45 |
-
password = $("#quads-vi-password").val();
|
46 |
-
|
47 |
-
var data = '{"email":"' + username + '", "password":"' + password + '"}';
|
48 |
-
|
49 |
-
$.ajax({
|
50 |
-
type: "POST",
|
51 |
-
//url: "https://dashboard-api-test.vidint.net/v1/api/authenticate",
|
52 |
-
url: quads.vi_login_url,
|
53 |
-
contentType: 'application/json',
|
54 |
-
data: data,
|
55 |
-
statusCode: {
|
56 |
-
502: function () {
|
57 |
-
$("#quads_add_err").html("502 Bad Gateway. Contact support[at]vi.ai");
|
58 |
-
console.log('502 Bad Gateway.');
|
59 |
-
return false;
|
60 |
-
},
|
61 |
-
500: function () {
|
62 |
-
$("#quads_add_err").html("500 Bad Gateway. Contact support[at]vi.ai");
|
63 |
-
console.log('500 Bad Gateway.');
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
},
|
67 |
-
success: function(response){
|
68 |
-
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
69 |
-
$("#quads_add_err").hide();
|
70 |
-
if (typeof response.data !== 'undefined') {
|
71 |
-
$("#quads_add_err").html("We are logging you in");
|
72 |
-
console.log('We are logging you in' + response);
|
73 |
-
saveViToken(response.data);
|
74 |
-
}
|
75 |
-
else {
|
76 |
-
$("#quads_add_err").html("No valid API response. Can not log you in. Contact support[at]vi.ai");
|
77 |
-
console.log('no valid api response' + response);
|
78 |
-
}
|
79 |
-
},
|
80 |
-
error: function(response){
|
81 |
-
// check if xhr.status is defined in $.ajax.statusCode
|
82 |
-
// if true, return false to stop this function
|
83 |
-
if (typeof this.statusCode[response.status] != 'undefined') {
|
84 |
-
return false;
|
85 |
-
}
|
86 |
-
|
87 |
-
var result = typeof response.responseText !== 'undefined' ? JSON.parse(response.responseText) : '';
|
88 |
-
$("#quads_add_err").html(result.error.message + ' ' + result.error.description);
|
89 |
-
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
90 |
-
$("#quads_add_err").show();
|
91 |
-
$("#quads_add_err").removeClass('quads-spinner');
|
92 |
-
console.log(result);
|
93 |
-
//exit;
|
94 |
-
},
|
95 |
-
beforeSend:function()
|
96 |
-
{
|
97 |
-
$("#quads_vi_loading").css('display', 'inline', 'important').css('visibility', 'visible');
|
98 |
-
$("#quads_add_err").show();
|
99 |
-
},
|
100 |
-
|
101 |
-
complete:function()
|
102 |
-
{
|
103 |
-
$("#quads_vi_loading").css('display', 'none', 'important').css('visibility', 'hidden');
|
104 |
-
}
|
105 |
-
|
106 |
-
});
|
107 |
-
return false;
|
108 |
-
});
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Save vi token
|
112 |
-
*/
|
113 |
-
function saveViToken(token){
|
114 |
-
var data = {
|
115 |
-
'action': 'quads_save_vi_token',
|
116 |
-
'token': token
|
117 |
-
};
|
118 |
-
$.ajax({
|
119 |
-
type: "POST",
|
120 |
-
url: ajaxurl,
|
121 |
-
dataType: "json",
|
122 |
-
data: data,
|
123 |
-
//contentType: 'application/json;charset=utf-8',
|
124 |
-
success: function(response){
|
125 |
-
//response = JSON.stringify(response);
|
126 |
-
console.log(response.status);
|
127 |
-
|
128 |
-
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
129 |
-
$("#quads_add_err").hide();
|
130 |
-
if (typeof response.status != 'undefined' && response.status == 'success') {
|
131 |
-
console.log('Success, login succesfull, token stored' + response);
|
132 |
-
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
133 |
-
return false;
|
134 |
-
}
|
135 |
-
else {
|
136 |
-
console.log("Can not store token");
|
137 |
-
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
138 |
-
return false;
|
139 |
-
}
|
140 |
-
},
|
141 |
-
beforeSend:function()
|
142 |
-
{
|
143 |
-
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
144 |
-
$("#quads_add_err").show();
|
145 |
-
},
|
146 |
-
complete:function()
|
147 |
-
{
|
148 |
-
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
149 |
-
$("#quads_add_err").hide();
|
150 |
-
}
|
151 |
-
|
152 |
-
});
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
// Remove several unused elements from vi page
|
159 |
-
if (document.location.href.indexOf('vi_header') > - 1) {
|
160 |
-
$('#quads-submit-button').hide();
|
161 |
-
$('#quads-validate').hide();
|
162 |
-
$('#quads-footer').hide();
|
163 |
-
} else {
|
164 |
-
$('#quads-submit-button').show();
|
165 |
-
$('#quads-validate').show();
|
166 |
-
$('#quads-footer').show();
|
167 |
-
}
|
168 |
-
$(window).bind('easytabs:after', function(){
|
169 |
-
if (document.location.href.indexOf('vi_header') > - 1) {
|
170 |
-
$('#quads-submit-button').hide();
|
171 |
-
$('#quads-validate').hide();
|
172 |
-
$('#quads-footer').hide();
|
173 |
-
} else {
|
174 |
-
|
175 |
-
$('#quads-submit-button').show();
|
176 |
-
$('#quads-validate').show();
|
177 |
-
$('#quads-footer').show();
|
178 |
-
}
|
179 |
-
});
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
// VI signup form
|
186 |
-
$('#quads-vi-signup').click(function(e){
|
187 |
-
e.preventDefault();
|
188 |
-
// scroll to top
|
189 |
-
$(window).scrollTop(0);
|
190 |
-
// hide save button
|
191 |
-
$('#quads-submit-button').hide();
|
192 |
-
$('#quads-vi-signup-fullscreen').fadeIn();
|
193 |
-
});
|
194 |
-
$('#quads-vi-close').click(function(e){
|
195 |
-
e.preventDefault();
|
196 |
-
$('#quads-vi-signup-fullscreen').fadeOut();
|
197 |
-
});
|
198 |
-
|
199 |
-
/**
|
200 |
-
* General Tab
|
201 |
-
*/
|
202 |
-
// Inactive select fields are greyed out
|
203 |
-
$('.quads-assign').each(function(e){
|
204 |
-
if (!$(this).prop('checked')){
|
205 |
-
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
206 |
-
}else {
|
207 |
-
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
208 |
-
}
|
209 |
-
});
|
210 |
-
|
211 |
-
$('.quads-assign').click(function(){
|
212 |
-
if (!$(this).prop('checked')){
|
213 |
-
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
214 |
-
} else {
|
215 |
-
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
216 |
-
}
|
217 |
-
});
|
218 |
-
|
219 |
-
/**
|
220 |
-
* AdSense Code Tab
|
221 |
-
*/
|
222 |
-
// Check if submit button is visible than stick it to the bottom of the page
|
223 |
-
$(window).scroll(function() {
|
224 |
-
|
225 |
-
var elem = '#quads_tab_container .submit';
|
226 |
-
|
227 |
-
if ($(elem).length < 1){
|
228 |
-
return;
|
229 |
-
}
|
230 |
-
|
231 |
-
var top_of_element = $(elem).offset().top;
|
232 |
-
var bottom_of_element = $(elem).offset().top + $(elem).outerHeight(false);
|
233 |
-
var bottom_of_screen = $(window).scrollTop() + $(window).height();
|
234 |
-
if (bottom_of_screen > top_of_element){
|
235 |
-
// The element is visible, do something
|
236 |
-
$('#quads-submit-button').css('position', 'relative').css('bottom', '20px');
|
237 |
-
} else {
|
238 |
-
// The element is NOT visible, do something else
|
239 |
-
$('#quads-submit-button').css('position', 'fixed').css('bottom', '20px');
|
240 |
-
}
|
241 |
-
});
|
242 |
-
|
243 |
-
// Activate chosen select boxes
|
244 |
-
// $(".quads-chosen-select").chosen({
|
245 |
-
// inherit_select_classes: true
|
246 |
-
// });
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
// Hid or show AMP code form on click on amp checkbox
|
251 |
-
$('.quads-activate-amp').click(function(){
|
252 |
-
var parent = $(this).parents('.quads-ad-toggle-container').attr('id');
|
253 |
-
if ($(this).attr('checked') === 'checked') {
|
254 |
-
$('#' + parent).find('.quads-amp-code').show();
|
255 |
-
} else {
|
256 |
-
$('#' + parent).find('.quads-amp-code').hide();
|
257 |
-
}
|
258 |
-
});
|
259 |
-
|
260 |
-
|
261 |
-
// Hide or show AMP code form on loading
|
262 |
-
$('.quads-ad-toggle-container').find('.quads-activate-amp').each(function (index, value) {
|
263 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
264 |
-
if ($(this).attr( 'checked') === 'checked' ) {
|
265 |
-
$('#' + parentContainerID).find('.quads-amp-code').show();
|
266 |
-
}else {
|
267 |
-
$('#' + parentContainerID).find('.quads-amp-code').hide();
|
268 |
-
}
|
269 |
-
});
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
/**
|
274 |
-
* Toggle Button | Open All Ads
|
275 |
-
*/
|
276 |
-
$('#quads-open-toggle').click(function(){
|
277 |
-
if ($('#quads-open-toggle').text() === 'Open All Ads' ){
|
278 |
-
$('.quads-ad-toggle-container').show();
|
279 |
-
$('#quads-open-toggle').html('Close Ads');
|
280 |
-
}else{
|
281 |
-
$('.quads-ad-toggle-container').hide();
|
282 |
-
$('#quads-open-toggle').html('Open All Ads');
|
283 |
-
}
|
284 |
-
});
|
285 |
-
|
286 |
-
// show / hide helper description
|
287 |
-
$('.quads-helper').click(function (e) {
|
288 |
-
e.preventDefault();
|
289 |
-
var icon = $(this),
|
290 |
-
bubble = $(this).next();
|
291 |
-
|
292 |
-
// Close any that are already open
|
293 |
-
$('.quads-message').not(bubble).hide();
|
294 |
-
|
295 |
-
var position = icon.position();
|
296 |
-
if (bubble.hasClass('bottom')) {
|
297 |
-
bubble.css({
|
298 |
-
'left': (position.left - bubble.width() / 2) + 'px',
|
299 |
-
'top': (position.top + icon.height() + 9) + 'px'
|
300 |
-
});
|
301 |
-
} else {
|
302 |
-
bubble.css({
|
303 |
-
'left': (position.left + icon.width() + 9) + 'px',
|
304 |
-
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
305 |
-
});
|
306 |
-
}
|
307 |
-
|
308 |
-
bubble.toggle();
|
309 |
-
e.stopPropagation();
|
310 |
-
});
|
311 |
-
$('.quads-general-helper').click(function (e) {
|
312 |
-
e.preventDefault();
|
313 |
-
var icon = $(this),
|
314 |
-
bubble = $(this).next();
|
315 |
-
|
316 |
-
// Close any that are already open
|
317 |
-
$('.quads-message').not(bubble).hide();
|
318 |
-
|
319 |
-
var position = icon.position();
|
320 |
-
if (bubble.hasClass('bottom')) {
|
321 |
-
bubble.css({
|
322 |
-
'left': (position.left - bubble.width() / 2) + 'px',
|
323 |
-
'top': (position.top + icon.height() + 9) + 'px'
|
324 |
-
});
|
325 |
-
} else {
|
326 |
-
bubble.css({
|
327 |
-
'left': (position.left + icon.width() + 9) + 'px',
|
328 |
-
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
329 |
-
});
|
330 |
-
}
|
331 |
-
|
332 |
-
bubble.toggle();
|
333 |
-
e.stopPropagation();
|
334 |
-
});
|
335 |
-
|
336 |
-
$('body').click(function () {
|
337 |
-
$('.quads-message').hide();
|
338 |
-
});
|
339 |
-
|
340 |
-
$('.quads-message').click(function (e) {
|
341 |
-
e.stopPropagation();
|
342 |
-
});
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Save settings via ajax
|
346 |
-
*/
|
347 |
-
|
348 |
-
jQuery('#quads_settings').submit(function() {
|
349 |
-
|
350 |
-
// Check if ad name has been changed and prepare new data for saving
|
351 |
-
$('.quads-toogle-title').each(function(){
|
352 |
-
$(this).children('input').val($(this).text());
|
353 |
-
});
|
354 |
-
|
355 |
-
|
356 |
-
// Check current url / settings page
|
357 |
-
var url = window.location.search;
|
358 |
-
var tab_imexport = url.search("page=quads-settings&tab=imexport");
|
359 |
-
var tab_licenses = url.search("page=quads-settings&tab=licenses");
|
360 |
-
|
361 |
-
jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
|
362 |
-
jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
|
363 |
-
jQuery(this).ajaxSubmit({
|
364 |
-
|
365 |
-
success: function(){
|
366 |
-
jQuery('#quads-save-result').html("<div id='quads-save-message' class='quads-success-modal'></div>");
|
367 |
-
jQuery('#quads-save-message').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/saved.gif"></p>').show();
|
368 |
-
quads_hide_success_message();
|
369 |
-
},
|
370 |
-
//,timeout: 0,
|
371 |
-
|
372 |
-
error: function(){
|
373 |
-
//Do not show alert on import/export tab
|
374 |
-
if ( tab_imexport === -1 && tab_licenses === -1 ){
|
375 |
-
alert ('Error: Can not save settings. Try again');
|
376 |
-
}
|
377 |
-
jQuery('#quads-save-result').hide('fast');
|
378 |
-
}
|
379 |
-
});
|
380 |
-
// Do not use ajax saving on import/export and licenses tab
|
381 |
-
if ( tab_imexport === -1 && tab_licenses ===-1 ){
|
382 |
-
return false;
|
383 |
-
}
|
384 |
-
});
|
385 |
-
|
386 |
-
function quads_hide_success_message(){
|
387 |
-
setTimeout("jQuery('#quads-save-message').hide()", 1000);
|
388 |
-
}
|
389 |
-
|
390 |
-
|
391 |
-
/**
|
392 |
-
* Paste AdSense Code form
|
393 |
-
*/
|
394 |
-
$(document).on('click', '#quads-paste-button', function () {
|
395 |
-
|
396 |
-
var content = $('#quads-adsense-form').val();
|
397 |
-
var parseResult = quadsParseAdSenseCode(content);
|
398 |
-
if (false !== parseResult) {
|
399 |
-
console.log(parseResult);
|
400 |
-
setDetailsFromAdCode(parseResult);
|
401 |
-
}else{
|
402 |
-
$('#quads-msg').html('Can not parse AdSense Code. Is the code valid?');
|
403 |
-
$('#quads-msg').show();
|
404 |
-
}
|
405 |
-
});
|
406 |
-
|
407 |
-
|
408 |
-
/**
|
409 |
-
* Populate AdSense Date Fields
|
410 |
-
*
|
411 |
-
* @param object adsense
|
412 |
-
* @param2 string id of the parent container
|
413 |
-
* @returns false
|
414 |
-
*/
|
415 |
-
function setDetailsFromAdCode(GoogleAd) {
|
416 |
-
|
417 |
-
var containerID = $('#quads-adsense-id').val();
|
418 |
-
|
419 |
-
var id = containerID.replace("quads-toggle", "");
|
420 |
-
|
421 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_slot\\]').val(GoogleAd.slotId);
|
422 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_client\\]').val(GoogleAd.pubId);
|
423 |
-
if ('normal' == GoogleAd.type) {
|
424 |
-
console.log($('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]'));
|
425 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('normal');
|
426 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val(GoogleAd.width);
|
427 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val(GoogleAd.height);
|
428 |
-
}
|
429 |
-
if ('responsive' == GoogleAd.type) {
|
430 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('responsive');
|
431 |
-
//$('#ad-resize-type').val('auto');
|
432 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val('');
|
433 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val('');
|
434 |
-
}
|
435 |
-
// Trigger the ad type select
|
436 |
-
$('.quads-select-Type').trigger('change');
|
437 |
-
// Hide the overlay
|
438 |
-
$('#quads-adsense-bg-div').hide();
|
439 |
-
// Ad code input form must not be empty!
|
440 |
-
if ($('#' + containerID).children('textarea').val().length === 0){
|
441 |
-
$('#' + containerID).children('textarea').val('adsense');
|
442 |
-
}
|
443 |
-
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Parse the adsense ad content
|
449 |
-
* @param {type} content
|
450 |
-
* @returns {quads-admin.min_L3.parseAdContent.GoogleAd|Boolean}
|
451 |
-
*/
|
452 |
-
function quadsParseAdSenseCode(content) {
|
453 |
-
|
454 |
-
var rawContent = ('undefined' != typeof (content)) ? content.trim() : '';
|
455 |
-
var GoogleAd = {};
|
456 |
-
var theContent = $('<div />').html(rawContent);
|
457 |
-
var asyncGoogleAd = theContent.find('ins');
|
458 |
-
//var syncGoogleAd = theContent.search('google_ad_client');
|
459 |
-
|
460 |
-
// Its a async adsense ad
|
461 |
-
if (asyncGoogleAd.length > 0) {
|
462 |
-
console.log('async ad');
|
463 |
-
|
464 |
-
// Ad Slot ID
|
465 |
-
GoogleAd.slotId = asyncGoogleAd.attr('data-ad-slot');
|
466 |
-
|
467 |
-
if ('undefined' != typeof (asyncGoogleAd.attr('data-ad-client'))) {
|
468 |
-
// Ad Publisher ID
|
469 |
-
GoogleAd.pubId = asyncGoogleAd.attr('data-ad-client').substr(3);
|
470 |
-
}
|
471 |
-
|
472 |
-
if (undefined !== GoogleAd.slotId && '' != GoogleAd.pubId) {
|
473 |
-
GoogleAd.display = asyncGoogleAd.css('display');
|
474 |
-
GoogleAd.format = asyncGoogleAd.attr('data-ad-format');
|
475 |
-
GoogleAd.style = asyncGoogleAd.attr('style');
|
476 |
-
|
477 |
-
if ('undefined' == typeof (GoogleAd.format) && -1 != GoogleAd.style.indexOf('width')) {
|
478 |
-
/* normal ad */
|
479 |
-
GoogleAd.type = 'normal';
|
480 |
-
GoogleAd.width = asyncGoogleAd.css('width').replace('px', '');
|
481 |
-
GoogleAd.height = asyncGoogleAd.css('height').replace('px', '');
|
482 |
-
return GoogleAd;
|
483 |
-
}
|
484 |
-
|
485 |
-
if ('undefined' != typeof (GoogleAd.format) && 'auto' == GoogleAd.format) {
|
486 |
-
/* Responsive ad, auto resize */
|
487 |
-
GoogleAd.type = 'responsive';
|
488 |
-
return GoogleAd;
|
489 |
-
}
|
490 |
-
return GoogleAd;
|
491 |
-
}
|
492 |
-
|
493 |
-
return false;
|
494 |
-
}
|
495 |
-
|
496 |
-
// Google syncronous ad
|
497 |
-
if (rawContent.search('google_ad_client') > 0) {
|
498 |
-
console.log('syncronous code');
|
499 |
-
|
500 |
-
// Ad Slot ID
|
501 |
-
GoogleAd.slotId = get_google_ad_slot(content);
|
502 |
-
|
503 |
-
console.log(get_google_ad_slot(content));
|
504 |
-
console.log(get_google_ad_client(content));
|
505 |
-
console.log(get_google_ad_height(content));
|
506 |
-
console.log(get_google_ad_width(content));
|
507 |
-
|
508 |
-
if (!quadsIsEmpty(get_google_ad_client(content))) {
|
509 |
-
// Ad Publisher ID
|
510 |
-
GoogleAd.pubId = 'ca-pub-' + get_google_ad_client(content);
|
511 |
-
}else{
|
512 |
-
return false;
|
513 |
-
}
|
514 |
-
|
515 |
-
if (!quadsIsEmpty(GoogleAd.slotId) && !quadsIsEmpty(GoogleAd.pubId)) {
|
516 |
-
|
517 |
-
if (!quadsIsEmpty(get_google_ad_width(content))) {
|
518 |
-
GoogleAd.type = 'normal';
|
519 |
-
GoogleAd.width = get_google_ad_width(content);
|
520 |
-
GoogleAd.height = get_google_ad_height(content);
|
521 |
-
return GoogleAd;
|
522 |
-
}
|
523 |
-
}
|
524 |
-
return false;
|
525 |
-
}
|
526 |
-
|
527 |
-
return false;
|
528 |
-
}
|
529 |
-
|
530 |
-
function get_google_ad_slot(content) {
|
531 |
-
const regex = /google_ad_slot\s*=\s*"(\d*)";/g;
|
532 |
-
const str = content;
|
533 |
-
var m;
|
534 |
-
var result = {};
|
535 |
-
|
536 |
-
while ((m = regex.exec(str)) !== null) {
|
537 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
538 |
-
if (m.index === regex.lastIndex) {
|
539 |
-
regex.lastIndex++;
|
540 |
-
}
|
541 |
-
|
542 |
-
// The result can be accessed through the `m`-variable.
|
543 |
-
m.forEach(function(match, index){
|
544 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
545 |
-
console.log(match);
|
546 |
-
result = match;
|
547 |
-
});
|
548 |
-
}
|
549 |
-
return result;
|
550 |
-
}
|
551 |
-
function get_google_ad_client(content) {
|
552 |
-
const regex = /google_ad_client\s*=\s*"ca-pub-(\d*)";/g;
|
553 |
-
const str = content;
|
554 |
-
var m;
|
555 |
-
var result = {};
|
556 |
-
|
557 |
-
while ((m = regex.exec(str)) !== null) {
|
558 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
559 |
-
if (m.index === regex.lastIndex) {
|
560 |
-
regex.lastIndex++;
|
561 |
-
}
|
562 |
-
|
563 |
-
// The result can be accessed through the `m`-variable.
|
564 |
-
m.forEach(function(match, index){
|
565 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
566 |
-
console.log(match);
|
567 |
-
result = match;
|
568 |
-
});
|
569 |
-
}
|
570 |
-
return result;
|
571 |
-
}
|
572 |
-
function get_google_ad_width(content) {
|
573 |
-
const regex = /google_ad_width\s*=\s*(\d*);/g;
|
574 |
-
const str = content;
|
575 |
-
var m;
|
576 |
-
var result = {};
|
577 |
-
|
578 |
-
while ((m = regex.exec(str)) !== null) {
|
579 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
580 |
-
if (m.index === regex.lastIndex) {
|
581 |
-
regex.lastIndex++;
|
582 |
-
}
|
583 |
-
|
584 |
-
// The result can be accessed through the `m`-variable.
|
585 |
-
m.forEach(function(match, index){
|
586 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
587 |
-
console.log(match);
|
588 |
-
result = match;
|
589 |
-
});
|
590 |
-
}
|
591 |
-
return result;
|
592 |
-
}
|
593 |
-
function get_google_ad_height(content) {
|
594 |
-
const regex = /google_ad_height\s*=\s*(\d*);/g;
|
595 |
-
const str = content;
|
596 |
-
var m;
|
597 |
-
var result = {};
|
598 |
-
|
599 |
-
while ((m = regex.exec(str)) !== null) {
|
600 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
601 |
-
if (m.index === regex.lastIndex) {
|
602 |
-
regex.lastIndex++;
|
603 |
-
}
|
604 |
-
|
605 |
-
// The result can be accessed through the `m`-variable.
|
606 |
-
m.forEach(function(match, index){
|
607 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
608 |
-
console.log(match);
|
609 |
-
result = match;
|
610 |
-
});
|
611 |
-
}
|
612 |
-
return result;
|
613 |
-
}
|
614 |
-
|
615 |
-
/**
|
616 |
-
* Check if return value is empty or not
|
617 |
-
* @param {type} str
|
618 |
-
* @returns {Boolean}
|
619 |
-
*/
|
620 |
-
function quadsIsEmpty(str) {
|
621 |
-
return (!str || 0 === str.length);
|
622 |
-
}
|
623 |
-
|
624 |
-
// AdSense Code Input Form
|
625 |
-
$(document).on('click', '.quads-add-adsense', function (e) {
|
626 |
-
e.preventDefault();
|
627 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
628 |
-
// Empty the ad plain text form
|
629 |
-
$('#quads-adsense-form').val('');
|
630 |
-
$('#quads-adsense-id').val(parentContainerID);
|
631 |
-
$('#quads-adsense-bg-div').show();
|
632 |
-
});
|
633 |
-
$(document).on('click', '#quads-close-button', function (e) {
|
634 |
-
e.preventDefault();
|
635 |
-
$('#quads-adsense-bg-div').hide();
|
636 |
-
});
|
637 |
-
|
638 |
-
|
639 |
-
// Toggle between AdSense or Plain Text option
|
640 |
-
$(document).on('click', '.quads_adsense_type', function () {
|
641 |
-
|
642 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
643 |
-
|
644 |
-
if ($(this).val() === 'adsense') {
|
645 |
-
$('#' + parentContainerID).children('textarea').hide();
|
646 |
-
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
647 |
-
$('#' + parentContainerID).find('.quads-sizes').show();
|
648 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
649 |
-
|
650 |
-
}
|
651 |
-
if ($(this).val() === 'plain_text') {
|
652 |
-
$('#' + parentContainerID).children('textarea').show();
|
653 |
-
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
654 |
-
$('#' + parentContainerID).find('.quads-sizes').hide();
|
655 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
656 |
-
}
|
657 |
-
});
|
658 |
-
|
659 |
-
|
660 |
-
// Hide or show AdSense elements on loading
|
661 |
-
$('.quads-ad-toggle-container').find('.quads_adsense_type').each(function (index, value) {
|
662 |
-
|
663 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
664 |
-
|
665 |
-
if ($(this).attr('checked') === 'checked' && $(this).val() === 'adsense') {
|
666 |
-
$('#' + parentContainerID).children('textarea').fadeOut();
|
667 |
-
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
668 |
-
}
|
669 |
-
if ($(this).attr('checked') === 'checked' && $(this).val() === 'plain_text') {
|
670 |
-
$('#' + parentContainerID).children('textarea').fadeIn();
|
671 |
-
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
672 |
-
}
|
673 |
-
});
|
674 |
-
|
675 |
-
|
676 |
-
// Hide or show AdSense width and height on loading
|
677 |
-
$('.quads-ad-toggle-container').find('.quads-select-Type').each(function (index, value) {
|
678 |
-
|
679 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
680 |
-
|
681 |
-
if ($(this).val() === 'responsive') {
|
682 |
-
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
683 |
-
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
684 |
-
$('#' + parentContainerID).find('.quads-sizes').show();
|
685 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
686 |
-
}
|
687 |
-
if ($(this).val() === 'normal') {
|
688 |
-
$('#' + parentContainerID).find('.quads-type-normal').show();
|
689 |
-
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
690 |
-
$('#' + parentContainerID).find('.quads-sizes').hide();
|
691 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
692 |
-
}
|
693 |
-
});
|
694 |
-
|
695 |
-
|
696 |
-
// Toggle between Fixed Size or Responsive ad type
|
697 |
-
$(document).on('change', '.quads-select-Type', function () {
|
698 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
699 |
-
|
700 |
-
if ($(this).val() === 'responsive') {
|
701 |
-
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
702 |
-
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
703 |
-
$('#' + parentContainerID).find('.quads-sizes').show();
|
704 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
705 |
-
}
|
706 |
-
if ($(this).val() === 'normal') {
|
707 |
-
$('#' + parentContainerID).find('.quads-type-normal').show();
|
708 |
-
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
709 |
-
$('#' + parentContainerID).find('.quads-sizes').hide();
|
710 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
711 |
-
}
|
712 |
-
});
|
713 |
-
|
714 |
-
//*[@id="quads-togglead1"]/div[2]
|
715 |
-
/**
|
716 |
-
* Toggle the adsense container
|
717 |
-
*/
|
718 |
-
//$('.quads-ad-toggle-header').click(function (e) {
|
719 |
-
$('.quads-form-table').on('click', '.quads-ad-toggle-header', function(e) {
|
720 |
-
e.preventDefault();
|
721 |
-
|
722 |
-
var container = $('#' + $(this).data('box-id'));
|
723 |
-
//console.log(container);
|
724 |
-
container.toggle(0, function () {
|
725 |
-
if (container.parents('.quads-ad-toggle-header').hasClass('quads-box-close')) {
|
726 |
-
// open the box
|
727 |
-
container.parents('.quads-ad-toggle-header').removeClass('quads-box-close');
|
728 |
-
} else {
|
729 |
-
container.parents('.quads-ad-toggle-header').addClass('quads-box-close');
|
730 |
-
}
|
731 |
-
});
|
732 |
-
});
|
733 |
-
|
734 |
-
/*
|
735 |
-
* Quick Adsense import process
|
736 |
-
*/
|
737 |
-
|
738 |
-
jQuery('.quads-import-settings').click(function (e) {
|
739 |
-
e.preventDefault();
|
740 |
-
|
741 |
-
if (!confirm('Importing settings from Quick AdSense will overwrite all your current settings. Are you sure?'))
|
742 |
-
return;
|
743 |
-
|
744 |
-
jQuery('#quads-import-settings').addClass('loading');
|
745 |
-
var data = {
|
746 |
-
action: 'quads_import_quick_adsense',
|
747 |
-
nonce: quads.nonce,
|
748 |
-
};
|
749 |
-
$.post(ajaxurl, data, function (resp, status, xhr) {
|
750 |
-
|
751 |
-
//console.log('success:' + resp + status + xhr);
|
752 |
-
quads_show_message(resp);
|
753 |
-
|
754 |
-
}).fail(function (xhr) { // Will be executed when $.post() fails
|
755 |
-
quads_show_message('Ajax Error: ' + xhr.status + ' ' + xhr.statusText);
|
756 |
-
//console.log('error: ' + xhr.statusText);
|
757 |
-
});
|
758 |
-
});
|
759 |
-
|
760 |
-
jQuery('#quads_insert_ads_action').click(function (e) {
|
761 |
-
e.preventDefault();
|
762 |
-
jQuery('#quads_insert_ads_box').toggle();
|
763 |
-
});
|
764 |
-
|
765 |
-
jQuery('#quads_disable_ads_action').click(function (e) {
|
766 |
-
e.preventDefault();
|
767 |
-
jQuery('#quads_disable_ads_box').toggle();
|
768 |
-
});
|
769 |
-
|
770 |
-
|
771 |
-
/**
|
772 |
-
* Show error message and die()
|
773 |
-
* Writes error message into log file
|
774 |
-
*
|
775 |
-
* @param {string} $error notice
|
776 |
-
* @returns void
|
777 |
-
*/
|
778 |
-
function quads_show_message(error) {
|
779 |
-
$('#quads-error-details').show();
|
780 |
-
$('#quads-error-details').html(error);
|
781 |
-
console.log(error);
|
782 |
-
}
|
783 |
-
|
784 |
-
|
785 |
-
/**
|
786 |
-
* Start easytabs()
|
787 |
-
*/
|
788 |
-
if ($(".quads-tabs").length) {
|
789 |
-
$('#quads_tab_container').easytabs({
|
790 |
-
animate: true,
|
791 |
-
updateHash: true,
|
792 |
-
animationSpeed: 'fast'
|
793 |
-
});
|
794 |
-
}
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
}); // document ready
|
800 |
-
|
801 |
-
/*
|
802 |
-
* jQuery hashchange event - v1.3 - 7/21/2010
|
803 |
-
* http://benalman.com/projects/jquery-hashchange-plugin/
|
804 |
-
*
|
805 |
-
* Copyright (c) 2010 "Cowboy" Ben Alman
|
806 |
-
* Dual licensed under the MIT and GPL licenses.
|
807 |
-
* http://benalman.com/about/license/
|
808 |
-
*/
|
809 |
-
(function ($, e, b) {
|
810 |
-
var c = "hashchange", h = document, f, g = $.event.special, i = h.documentMode, d = "on" + c in e && (i === b || i > 7);
|
811 |
-
function a(j) {
|
812 |
-
j = j || location.href;
|
813 |
-
return"#" + j.replace(/^[^#]*#?(.*)$/, "$1")
|
814 |
-
}
|
815 |
-
$.fn[c] = function (j) {
|
816 |
-
return j ? this.bind(c, j) : this.trigger(c)
|
817 |
-
};
|
818 |
-
$.fn[c].delay = 50;
|
819 |
-
g[c] = $.extend(g[c], {setup: function () {
|
820 |
-
if (d) {
|
821 |
-
return false
|
822 |
-
}
|
823 |
-
$(f.start)
|
824 |
-
}, teardown: function () {
|
825 |
-
if (d) {
|
826 |
-
return false
|
827 |
-
}
|
828 |
-
$(f.stop)
|
829 |
-
}});
|
830 |
-
f = (function () {
|
831 |
-
var j = {}, p, m = a(), k = function (q) {
|
832 |
-
return q
|
833 |
-
}, l = k, o = k;
|
834 |
-
j.start = function () {
|
835 |
-
p || n()
|
836 |
-
};
|
837 |
-
j.stop = function () {
|
838 |
-
p && clearTimeout(p);
|
839 |
-
p = b
|
840 |
-
};
|
841 |
-
function n() {
|
842 |
-
var r = a(), q = o(m);
|
843 |
-
if (r !== m) {
|
844 |
-
l(m = r, q);
|
845 |
-
$(e).trigger(c)
|
846 |
-
} else {
|
847 |
-
if (q !== m) {
|
848 |
-
location.href = location.href.replace(/#.*/, "") + q
|
849 |
-
}
|
850 |
-
}
|
851 |
-
p = setTimeout(n, $.fn[c].delay)
|
852 |
-
}
|
853 |
-
$.browser.msie && !d && (function () {
|
854 |
-
var q, r;
|
855 |
-
j.start = function () {
|
856 |
-
if (!q) {
|
857 |
-
r = $.fn[c].src;
|
858 |
-
r = r && r + a();
|
859 |
-
q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
|
860 |
-
r || l(a());
|
861 |
-
n()
|
862 |
-
}).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
|
863 |
-
h.onpropertychange = function () {
|
864 |
-
try {
|
865 |
-
if (event.propertyName === "title") {
|
866 |
-
q.document.title = h.title
|
867 |
-
}
|
868 |
-
} catch (s) {
|
869 |
-
}
|
870 |
-
}
|
871 |
-
}
|
872 |
-
};
|
873 |
-
j.stop = k;
|
874 |
-
o = function () {
|
875 |
-
return a(q.location.href)
|
876 |
-
};
|
877 |
-
l = function (v, s) {
|
878 |
-
var u = q.document, t = $.fn[c].domain;
|
879 |
-
if (v !== s) {
|
880 |
-
u.title = h.title;
|
881 |
-
u.open();
|
882 |
-
t && u.write('<script>document.domain="' + t + '"<\/script>');
|
883 |
-
u.close();
|
884 |
-
q.location.hash = v
|
885 |
-
}
|
886 |
-
}
|
887 |
-
})();
|
888 |
-
return j
|
889 |
-
})()
|
890 |
-
})(jQuery, this);
|
891 |
-
|
892 |
-
/*
|
893 |
-
* jQuery EasyTabs plugin 3.2.0
|
894 |
-
*
|
895 |
-
* Copyright (c) 2010-2011 Steve Schwartz (JangoSteve)
|
896 |
-
*
|
897 |
-
* Dual licensed under the MIT and GPL licenses:
|
898 |
-
* http://www.opensource.org/licenses/mit-license.php
|
899 |
-
* http://www.gnu.org/licenses/gpl.html
|
900 |
-
*
|
901 |
-
* Date: Thu May 09 17:30:00 2013 -0500
|
902 |
-
*/
|
903 |
-
(function (a) {
|
904 |
-
a.easytabs = function (j, e) {
|
905 |
-
var f = this, q = a(j), i = {animate: true, panelActiveClass: "active", tabActiveClass: "active", defaultTab: "li:first-child", animationSpeed: "fast", tabs: "> ul > li", updateHash: true, cycle: false, collapsible: false, collapsedClass: "collapsed", collapsedByDefault: true, uiTabs: false, transitionIn: "fadeIn", transitionOut: "fadeOut", transitionInEasing: "swing", transitionOutEasing: "swing", transitionCollapse: "slideUp", transitionUncollapse: "slideDown", transitionCollapseEasing: "swing", transitionUncollapseEasing: "swing", containerClass: "", tabsClass: "", tabClass: "", panelClass: "", cache: true, event: "click", panelContext: q}, h, l, v, m, d, t = {fast: 200, normal: 400, slow: 600}, r;
|
906 |
-
f.init = function () {
|
907 |
-
f.settings = r = a.extend({}, i, e);
|
908 |
-
r.bind_str = r.event + ".easytabs";
|
909 |
-
if (r.uiTabs) {
|
910 |
-
r.tabActiveClass = "ui-tabs-selected";
|
911 |
-
r.containerClass = "ui-tabs ui-widget ui-widget-content ui-corner-all";
|
912 |
-
r.tabsClass = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all";
|
913 |
-
r.tabClass = "ui-state-default ui-corner-top";
|
914 |
-
r.panelClass = "ui-tabs-panel ui-widget-content ui-corner-bottom"
|
915 |
-
}
|
916 |
-
if (r.collapsible && e.defaultTab !== undefined && e.collpasedByDefault === undefined) {
|
917 |
-
r.collapsedByDefault = false
|
918 |
-
}
|
919 |
-
if (typeof (r.animationSpeed) === "string") {
|
920 |
-
r.animationSpeed = t[r.animationSpeed]
|
921 |
-
}
|
922 |
-
a("a.anchor").remove().prependTo("body");
|
923 |
-
q.data("easytabs", {});
|
924 |
-
f.setTransitions();
|
925 |
-
f.getTabs();
|
926 |
-
b();
|
927 |
-
g();
|
928 |
-
w();
|
929 |
-
n();
|
930 |
-
c();
|
931 |
-
q.attr("data-easytabs", true)
|
932 |
-
};
|
933 |
-
f.setTransitions = function () {
|
934 |
-
v = (r.animate) ? {show: r.transitionIn, hide: r.transitionOut, speed: r.animationSpeed, collapse: r.transitionCollapse, uncollapse: r.transitionUncollapse, halfSpeed: r.animationSpeed / 2} : {show: "show", hide: "hide", speed: 0, collapse: "hide", uncollapse: "show", halfSpeed: 0}
|
935 |
-
};
|
936 |
-
f.getTabs = function () {
|
937 |
-
var x;
|
938 |
-
f.tabs = q.find(r.tabs), f.panels = a(), f.tabs.each(function () {
|
939 |
-
var A = a(this), z = A.children("a"), y = A.children("a").data("target");
|
940 |
-
A.data("easytabs", {});
|
941 |
-
if (y !== undefined && y !== null) {
|
942 |
-
A.data("easytabs").ajax = z.attr("href")
|
943 |
-
} else {
|
944 |
-
y = z.attr("href")
|
945 |
-
}
|
946 |
-
y = y.match(/#([^\?]+)/)[1];
|
947 |
-
x = r.panelContext.find("#" + y);
|
948 |
-
if (x.length) {
|
949 |
-
x.data("easytabs", {position: x.css("position"), visibility: x.css("visibility")});
|
950 |
-
x.not(r.panelActiveClass).hide();
|
951 |
-
f.panels = f.panels.add(x);
|
952 |
-
A.data("easytabs").panel = x
|
953 |
-
} else {
|
954 |
-
f.tabs = f.tabs.not(A);
|
955 |
-
if ("console" in window) {
|
956 |
-
console.warn("Warning: tab without matching panel for selector '#" + y + "' removed from set")
|
957 |
-
}
|
958 |
-
}
|
959 |
-
})
|
960 |
-
};
|
961 |
-
f.selectTab = function (x, C) {
|
962 |
-
var y = window.location, B = y.hash.match(/^[^\?]*/)[0], z = x.parent().data("easytabs").panel, A = x.parent().data("easytabs").ajax;
|
963 |
-
if (r.collapsible && !d && (x.hasClass(r.tabActiveClass) || x.hasClass(r.collapsedClass))) {
|
964 |
-
f.toggleTabCollapse(x, z, A, C)
|
965 |
-
} else {
|
966 |
-
if (!x.hasClass(r.tabActiveClass) || !z.hasClass(r.panelActiveClass)) {
|
967 |
-
o(x, z, A, C)
|
968 |
-
} else {
|
969 |
-
if (!r.cache) {
|
970 |
-
o(x, z, A, C)
|
971 |
-
}
|
972 |
-
}
|
973 |
-
}
|
974 |
-
};
|
975 |
-
f.toggleTabCollapse = function (x, y, z, A) {
|
976 |
-
f.panels.stop(true, true);
|
977 |
-
if (u(q, "easytabs:before", [x, y, r])) {
|
978 |
-
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
979 |
-
if (x.hasClass(r.collapsedClass)) {
|
980 |
-
if (z && (!r.cache || !x.parent().data("easytabs").cached)) {
|
981 |
-
q.trigger("easytabs:ajax:beforeSend", [x, y]);
|
982 |
-
y.load(z, function (C, B, D) {
|
983 |
-
x.parent().data("easytabs").cached = true;
|
984 |
-
q.trigger("easytabs:ajax:complete", [x, y, C, B, D])
|
985 |
-
})
|
986 |
-
}
|
987 |
-
x.parent().removeClass(r.collapsedClass).addClass(r.tabActiveClass).children().removeClass(r.collapsedClass).addClass(r.tabActiveClass);
|
988 |
-
y.addClass(r.panelActiveClass)[v.uncollapse](v.speed, r.transitionUncollapseEasing, function () {
|
989 |
-
q.trigger("easytabs:midTransition", [x, y, r]);
|
990 |
-
if (typeof A == "function") {
|
991 |
-
A()
|
992 |
-
}
|
993 |
-
})
|
994 |
-
} else {
|
995 |
-
x.addClass(r.collapsedClass).parent().addClass(r.collapsedClass);
|
996 |
-
y.removeClass(r.panelActiveClass)[v.collapse](v.speed, r.transitionCollapseEasing, function () {
|
997 |
-
q.trigger("easytabs:midTransition", [x, y, r]);
|
998 |
-
if (typeof A == "function") {
|
999 |
-
A()
|
1000 |
-
}
|
1001 |
-
})
|
1002 |
-
}
|
1003 |
-
}
|
1004 |
-
};
|
1005 |
-
f.matchTab = function (x) {
|
1006 |
-
return f.tabs.find("[href='" + x + "'],[data-target='" + x + "']").first()
|
1007 |
-
};
|
1008 |
-
f.matchInPanel = function (x) {
|
1009 |
-
return(x && f.validId(x) ? f.panels.filter(":has(" + x + ")").first() : [])
|
1010 |
-
};
|
1011 |
-
f.validId = function (x) {
|
1012 |
-
return x.substr(1).match(/^[A-Za-z]+[A-Za-z0-9\-_:\.].$/)
|
1013 |
-
};
|
1014 |
-
f.selectTabFromHashChange = function () {
|
1015 |
-
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y), z;
|
1016 |
-
if (r.updateHash) {
|
1017 |
-
if (x.length) {
|
1018 |
-
d = true;
|
1019 |
-
f.selectTab(x)
|
1020 |
-
} else {
|
1021 |
-
z = f.matchInPanel(y);
|
1022 |
-
if (z.length) {
|
1023 |
-
y = "#" + z.attr("id");
|
1024 |
-
x = f.matchTab(y);
|
1025 |
-
d = true;
|
1026 |
-
f.selectTab(x)
|
1027 |
-
} else {
|
1028 |
-
if (!h.hasClass(r.tabActiveClass) && !r.cycle) {
|
1029 |
-
if (y === "" || f.matchTab(m).length || q.closest(y).length) {
|
1030 |
-
d = true;
|
1031 |
-
f.selectTab(l)
|
1032 |
-
}
|
1033 |
-
}
|
1034 |
-
}
|
1035 |
-
}
|
1036 |
-
}
|
1037 |
-
};
|
1038 |
-
f.cycleTabs = function (x) {
|
1039 |
-
if (r.cycle) {
|
1040 |
-
x = x % f.tabs.length;
|
1041 |
-
$tab = a(f.tabs[x]).children("a").first();
|
1042 |
-
d = true;
|
1043 |
-
f.selectTab($tab, function () {
|
1044 |
-
setTimeout(function () {
|
1045 |
-
f.cycleTabs(x + 1)
|
1046 |
-
}, r.cycle)
|
1047 |
-
})
|
1048 |
-
}
|
1049 |
-
};
|
1050 |
-
f.publicMethods = {select: function (x) {
|
1051 |
-
var y;
|
1052 |
-
if ((y = f.tabs.filter(x)).length === 0) {
|
1053 |
-
if ((y = f.tabs.find("a[href='" + x + "']")).length === 0) {
|
1054 |
-
if ((y = f.tabs.find("a" + x)).length === 0) {
|
1055 |
-
if ((y = f.tabs.find("[data-target='" + x + "']")).length === 0) {
|
1056 |
-
if ((y = f.tabs.find("a[href$='" + x + "']")).length === 0) {
|
1057 |
-
a.error("Tab '" + x + "' does not exist in tab set")
|
1058 |
-
}
|
1059 |
-
}
|
1060 |
-
}
|
1061 |
-
}
|
1062 |
-
} else {
|
1063 |
-
y = y.children("a").first()
|
1064 |
-
}
|
1065 |
-
f.selectTab(y)
|
1066 |
-
}};
|
1067 |
-
var u = function (A, x, z) {
|
1068 |
-
var y = a.Event(x);
|
1069 |
-
A.trigger(y, z);
|
1070 |
-
return y.result !== false
|
1071 |
-
};
|
1072 |
-
var b = function () {
|
1073 |
-
q.addClass(r.containerClass);
|
1074 |
-
f.tabs.parent().addClass(r.tabsClass);
|
1075 |
-
f.tabs.addClass(r.tabClass);
|
1076 |
-
f.panels.addClass(r.panelClass)
|
1077 |
-
};
|
1078 |
-
var g = function () {
|
1079 |
-
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y).parent(), z;
|
1080 |
-
if (x.length === 1) {
|
1081 |
-
h = x;
|
1082 |
-
r.cycle = false
|
1083 |
-
} else {
|
1084 |
-
z = f.matchInPanel(y);
|
1085 |
-
if (z.length) {
|
1086 |
-
y = "#" + z.attr("id");
|
1087 |
-
h = f.matchTab(y).parent()
|
1088 |
-
} else {
|
1089 |
-
h = f.tabs.parent().find(r.defaultTab);
|
1090 |
-
if (h.length === 0) {
|
1091 |
-
a.error("The specified default tab ('" + r.defaultTab + "') could not be found in the tab set ('" + r.tabs + "') out of " + f.tabs.length + " tabs.")
|
1092 |
-
}
|
1093 |
-
}
|
1094 |
-
}
|
1095 |
-
l = h.children("a").first();
|
1096 |
-
p(x)
|
1097 |
-
};
|
1098 |
-
var p = function (z) {
|
1099 |
-
var y, x;
|
1100 |
-
if (r.collapsible && z.length === 0 && r.collapsedByDefault) {
|
1101 |
-
h.addClass(r.collapsedClass).children().addClass(r.collapsedClass)
|
1102 |
-
} else {
|
1103 |
-
y = a(h.data("easytabs").panel);
|
1104 |
-
x = h.data("easytabs").ajax;
|
1105 |
-
if (x && (!r.cache || !h.data("easytabs").cached)) {
|
1106 |
-
q.trigger("easytabs:ajax:beforeSend", [l, y]);
|
1107 |
-
y.load(x, function (B, A, C) {
|
1108 |
-
h.data("easytabs").cached = true;
|
1109 |
-
q.trigger("easytabs:ajax:complete", [l, y, B, A, C])
|
1110 |
-
})
|
1111 |
-
}
|
1112 |
-
h.data("easytabs").panel.show().addClass(r.panelActiveClass);
|
1113 |
-
h.addClass(r.tabActiveClass).children().addClass(r.tabActiveClass)
|
1114 |
-
}
|
1115 |
-
q.trigger("easytabs:initialised", [l, y])
|
1116 |
-
};
|
1117 |
-
var w = function () {
|
1118 |
-
f.tabs.children("a").bind(r.bind_str, function (x) {
|
1119 |
-
r.cycle = false;
|
1120 |
-
d = false;
|
1121 |
-
f.selectTab(a(this));
|
1122 |
-
x.preventDefault ? x.preventDefault() : x.returnValue = false
|
1123 |
-
})
|
1124 |
-
};
|
1125 |
-
var o = function (z, D, E, H) {
|
1126 |
-
f.panels.stop(true, true);
|
1127 |
-
if (u(q, "easytabs:before", [z, D, r])) {
|
1128 |
-
var A = f.panels.filter(":visible"), y = D.parent(), F, x, C, G, B = window.location.hash.match(/^[^\?]*/)[0];
|
1129 |
-
if (r.animate) {
|
1130 |
-
F = s(D);
|
1131 |
-
x = A.length ? k(A) : 0;
|
1132 |
-
C = F - x
|
1133 |
-
}
|
1134 |
-
m = B;
|
1135 |
-
G = function () {
|
1136 |
-
q.trigger("easytabs:midTransition", [z, D, r]);
|
1137 |
-
if (r.animate && r.transitionIn == "fadeIn") {
|
1138 |
-
if (C < 0) {
|
1139 |
-
y.animate({height: y.height() + C}, v.halfSpeed).css({"min-height": ""})
|
1140 |
-
}
|
1141 |
-
}
|
1142 |
-
if (r.updateHash && !d) {
|
1143 |
-
window.location.hash = "#" + D.attr("id")
|
1144 |
-
} else {
|
1145 |
-
d = false
|
1146 |
-
}
|
1147 |
-
D[v.show](v.speed, r.transitionInEasing, function () {
|
1148 |
-
y.css({height: "", "min-height": ""});
|
1149 |
-
q.trigger("easytabs:after", [z, D, r]);
|
1150 |
-
if (typeof H == "function") {
|
1151 |
-
H()
|
1152 |
-
}
|
1153 |
-
})
|
1154 |
-
};
|
1155 |
-
if (E && (!r.cache || !z.parent().data("easytabs").cached)) {
|
1156 |
-
q.trigger("easytabs:ajax:beforeSend", [z, D]);
|
1157 |
-
D.load(E, function (J, I, K) {
|
1158 |
-
z.parent().data("easytabs").cached = true;
|
1159 |
-
q.trigger("easytabs:ajax:complete", [z, D, J, I, K])
|
1160 |
-
})
|
1161 |
-
}
|
1162 |
-
if (r.animate && r.transitionOut == "fadeOut") {
|
1163 |
-
if (C > 0) {
|
1164 |
-
y.animate({height: (y.height() + C)}, v.halfSpeed)
|
1165 |
-
} else {
|
1166 |
-
y.css({"min-height": y.height()})
|
1167 |
-
}
|
1168 |
-
}
|
1169 |
-
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
1170 |
-
f.tabs.filter("." + r.collapsedClass).removeClass(r.collapsedClass).children().removeClass(r.collapsedClass);
|
1171 |
-
z.parent().addClass(r.tabActiveClass).children().addClass(r.tabActiveClass);
|
1172 |
-
f.panels.filter("." + r.panelActiveClass).removeClass(r.panelActiveClass);
|
1173 |
-
D.addClass(r.panelActiveClass);
|
1174 |
-
if (A.length) {
|
1175 |
-
A[v.hide](v.speed, r.transitionOutEasing, G)
|
1176 |
-
} else {
|
1177 |
-
D[v.uncollapse](v.speed, r.transitionUncollapseEasing, G)
|
1178 |
-
}
|
1179 |
-
}
|
1180 |
-
};
|
1181 |
-
var s = function (z) {
|
1182 |
-
if (z.data("easytabs") && z.data("easytabs").lastHeight) {
|
1183 |
-
return z.data("easytabs").lastHeight
|
1184 |
-
}
|
1185 |
-
var B = z.css("display"), y, x;
|
1186 |
-
try {
|
1187 |
-
y = a("<div></div>", {position: "absolute", visibility: "hidden", overflow: "hidden"})
|
1188 |
-
} catch (A) {
|
1189 |
-
y = a("<div></div>", {visibility: "hidden", overflow: "hidden"})
|
1190 |
-
}
|
1191 |
-
x = z.wrap(y).css({position: "relative", visibility: "hidden", display: "block"}).outerHeight();
|
1192 |
-
z.unwrap();
|
1193 |
-
z.css({position: z.data("easytabs").position, visibility: z.data("easytabs").visibility, display: B});
|
1194 |
-
z.data("easytabs").lastHeight = x;
|
1195 |
-
return x
|
1196 |
-
};
|
1197 |
-
var k = function (y) {
|
1198 |
-
var x = y.outerHeight();
|
1199 |
-
if (y.data("easytabs")) {
|
1200 |
-
y.data("easytabs").lastHeight = x
|
1201 |
-
} else {
|
1202 |
-
y.data("easytabs", {lastHeight: x})
|
1203 |
-
}
|
1204 |
-
return x
|
1205 |
-
};
|
1206 |
-
var n = function () {
|
1207 |
-
if (typeof a(window).hashchange === "function") {
|
1208 |
-
a(window).hashchange(function () {
|
1209 |
-
f.selectTabFromHashChange()
|
1210 |
-
})
|
1211 |
-
} else {
|
1212 |
-
if (a.address && typeof a.address.change === "function") {
|
1213 |
-
a.address.change(function () {
|
1214 |
-
f.selectTabFromHashChange()
|
1215 |
-
})
|
1216 |
-
}
|
1217 |
-
}
|
1218 |
-
};
|
1219 |
-
var c = function () {
|
1220 |
-
var x;
|
1221 |
-
if (r.cycle) {
|
1222 |
-
x = f.tabs.index(h);
|
1223 |
-
setTimeout(function () {
|
1224 |
-
f.cycleTabs(x + 1)
|
1225 |
-
}, r.cycle)
|
1226 |
-
}
|
1227 |
-
};
|
1228 |
-
f.init()
|
1229 |
-
};
|
1230 |
-
a.fn.easytabs = function (c) {
|
1231 |
-
var b = arguments;
|
1232 |
-
return this.each(function () {
|
1233 |
-
var e = a(this), d = e.data("easytabs");
|
1234 |
-
if (undefined === d) {
|
1235 |
-
d = new a.easytabs(this, c);
|
1236 |
-
e.data("easytabs", d)
|
1237 |
-
}
|
1238 |
-
if (d.publicMethods[c]) {
|
1239 |
-
return d.publicMethods[c](Array.prototype.slice.call(b, 1))
|
1240 |
-
}
|
1241 |
-
})
|
1242 |
-
}
|
1243 |
-
})(jQuery);
|
1244 |
-
|
1245 |
-
|
1246 |
-
/*
|
1247 |
-
colpick Color Picker
|
1248 |
-
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
|
1249 |
-
|
1250 |
-
For usage and examples: colpick.com/plugin
|
1251 |
-
*/
|
1252 |
-
|
1253 |
-
(function ($) {
|
1254 |
-
var colpick = function () {
|
1255 |
-
var
|
1256 |
-
tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
|
1257 |
-
defaults = {
|
1258 |
-
showEvent: 'click',
|
1259 |
-
onShow: function () {
|
1260 |
-
},
|
1261 |
-
onBeforeShow: function () {
|
1262 |
-
},
|
1263 |
-
onHide: function () {
|
1264 |
-
},
|
1265 |
-
onChange: function () {
|
1266 |
-
},
|
1267 |
-
onSubmit: function () {
|
1268 |
-
},
|
1269 |
-
colorScheme: 'light',
|
1270 |
-
color: '3289c7',
|
1271 |
-
livePreview: true,
|
1272 |
-
flat: false,
|
1273 |
-
layout: 'full',
|
1274 |
-
submit: 1,
|
1275 |
-
submitText: 'OK',
|
1276 |
-
height: 156
|
1277 |
-
},
|
1278 |
-
//Fill the inputs of the plugin
|
1279 |
-
fillRGBFields = function (hsb, cal) {
|
1280 |
-
var rgb = hsbToRgb(hsb);
|
1281 |
-
$(cal).data('colpick').fields
|
1282 |
-
.eq(1).val(rgb.r).end()
|
1283 |
-
.eq(2).val(rgb.g).end()
|
1284 |
-
.eq(3).val(rgb.b).end();
|
1285 |
-
},
|
1286 |
-
fillHSBFields = function (hsb, cal) {
|
1287 |
-
$(cal).data('colpick').fields
|
1288 |
-
.eq(4).val(Math.round(hsb.h)).end()
|
1289 |
-
.eq(5).val(Math.round(hsb.s)).end()
|
1290 |
-
.eq(6).val(Math.round(hsb.b)).end();
|
1291 |
-
},
|
1292 |
-
fillHexFields = function (hsb, cal) {
|
1293 |
-
$(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
|
1294 |
-
},
|
1295 |
-
//Set the round selector position
|
1296 |
-
setSelector = function (hsb, cal) {
|
1297 |
-
$(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
|
1298 |
-
$(cal).data('colpick').selectorIndic.css({
|
1299 |
-
left: parseInt($(cal).data('colpick').height * hsb.s / 100, 10),
|
1300 |
-
top: parseInt($(cal).data('colpick').height * (100 - hsb.b) / 100, 10)
|
1301 |
-
});
|
1302 |
-
},
|
1303 |
-
//Set the hue selector position
|
1304 |
-
setHue = function (hsb, cal) {
|
1305 |
-
$(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
|
1306 |
-
},
|
1307 |
-
//Set current and new colors
|
1308 |
-
setCurrentColor = function (hsb, cal) {
|
1309 |
-
$(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1310 |
-
},
|
1311 |
-
setNewColor = function (hsb, cal) {
|
1312 |
-
$(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1313 |
-
},
|
1314 |
-
//Called when the new color is changed
|
1315 |
-
change = function (ev) {
|
1316 |
-
var cal = $(this).parent().parent(), col;
|
1317 |
-
if (this.parentNode.className.indexOf('_hex') > 0) {
|
1318 |
-
cal.data('colpick').color = col = hexToHsb(fixHex(this.value));
|
1319 |
-
fillRGBFields(col, cal.get(0));
|
1320 |
-
fillHSBFields(col, cal.get(0));
|
1321 |
-
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
1322 |
-
cal.data('colpick').color = col = fixHSB({
|
1323 |
-
h: parseInt(cal.data('colpick').fields.eq(4).val(), 10),
|
1324 |
-
s: parseInt(cal.data('colpick').fields.eq(5).val(), 10),
|
1325 |
-
b: parseInt(cal.data('colpick').fields.eq(6).val(), 10)
|
1326 |
-
});
|
1327 |
-
fillRGBFields(col, cal.get(0));
|
1328 |
-
fillHexFields(col, cal.get(0));
|
1329 |
-
} else {
|
1330 |
-
cal.data('colpick').color = col = rgbToHsb(fixRGB({
|
1331 |
-
r: parseInt(cal.data('colpick').fields.eq(1).val(), 10),
|
1332 |
-
g: parseInt(cal.data('colpick').fields.eq(2).val(), 10),
|
1333 |
-
b: parseInt(cal.data('colpick').fields.eq(3).val(), 10)
|
1334 |
-
}));
|
1335 |
-
fillHexFields(col, cal.get(0));
|
1336 |
-
fillHSBFields(col, cal.get(0));
|
1337 |
-
}
|
1338 |
-
setSelector(col, cal.get(0));
|
1339 |
-
setHue(col, cal.get(0));
|
1340 |
-
setNewColor(col, cal.get(0));
|
1341 |
-
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
|
1342 |
-
},
|
1343 |
-
//Change style on blur and on focus of inputs
|
1344 |
-
blur = function (ev) {
|
1345 |
-
$(this).parent().removeClass('colpick_focus');
|
1346 |
-
},
|
1347 |
-
focus = function () {
|
1348 |
-
$(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
|
1349 |
-
$(this).parent().addClass('colpick_focus');
|
1350 |
-
},
|
1351 |
-
//Increment/decrement arrows functions
|
1352 |
-
downIncrement = function (ev) {
|
1353 |
-
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1354 |
-
var field = $(this).parent().find('input').focus();
|
1355 |
-
var current = {
|
1356 |
-
el: $(this).parent().addClass('colpick_slider'),
|
1357 |
-
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
1358 |
-
y: ev.pageY,
|
1359 |
-
field: field,
|
1360 |
-
val: parseInt(field.val(), 10),
|
1361 |
-
preview: $(this).parent().parent().data('colpick').livePreview
|
1362 |
-
};
|
1363 |
-
$(document).mouseup(current, upIncrement);
|
1364 |
-
$(document).mousemove(current, moveIncrement);
|
1365 |
-
},
|
1366 |
-
moveIncrement = function (ev) {
|
1367 |
-
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10))));
|
1368 |
-
if (ev.data.preview) {
|
1369 |
-
change.apply(ev.data.field.get(0), [true]);
|
1370 |
-
}
|
1371 |
-
return false;
|
1372 |
-
},
|
1373 |
-
upIncrement = function (ev) {
|
1374 |
-
change.apply(ev.data.field.get(0), [true]);
|
1375 |
-
ev.data.el.removeClass('colpick_slider').find('input').focus();
|
1376 |
-
$(document).off('mouseup', upIncrement);
|
1377 |
-
$(document).off('mousemove', moveIncrement);
|
1378 |
-
return false;
|
1379 |
-
},
|
1380 |
-
//Hue slider functions
|
1381 |
-
downHue = function (ev) {
|
1382 |
-
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1383 |
-
var current = {
|
1384 |
-
cal: $(this).parent(),
|
1385 |
-
y: $(this).offset().top
|
1386 |
-
};
|
1387 |
-
$(document).on('mouseup touchend', current, upHue);
|
1388 |
-
$(document).on('mousemove touchmove', current, moveHue);
|
1389 |
-
|
1390 |
-
var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1391 |
-
change.apply(
|
1392 |
-
current.cal.data('colpick')
|
1393 |
-
.fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height - (pageY - current.y)) / current.cal.data('colpick').height, 10))
|
1394 |
-
.get(0),
|
1395 |
-
[current.cal.data('colpick').livePreview]
|
1396 |
-
);
|
1397 |
-
return false;
|
1398 |
-
},
|
1399 |
-
moveHue = function (ev) {
|
1400 |
-
var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1401 |
-
change.apply(
|
1402 |
-
ev.data.cal.data('colpick')
|
1403 |
-
.fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) / ev.data.cal.data('colpick').height, 10))
|
1404 |
-
.get(0),
|
1405 |
-
[ev.data.preview]
|
1406 |
-
);
|
1407 |
-
return false;
|
1408 |
-
},
|
1409 |
-
upHue = function (ev) {
|
1410 |
-
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1411 |
-
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1412 |
-
$(document).off('mouseup touchend', upHue);
|
1413 |
-
$(document).off('mousemove touchmove', moveHue);
|
1414 |
-
return false;
|
1415 |
-
},
|
1416 |
-
//Color selector functions
|
1417 |
-
downSelector = function (ev) {
|
1418 |
-
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1419 |
-
var current = {
|
1420 |
-
cal: $(this).parent(),
|
1421 |
-
pos: $(this).offset()
|
1422 |
-
};
|
1423 |
-
current.preview = current.cal.data('colpick').livePreview;
|
1424 |
-
|
1425 |
-
$(document).on('mouseup touchend', current, upSelector);
|
1426 |
-
$(document).on('mousemove touchmove', current, moveSelector);
|
1427 |
-
|
1428 |
-
var payeX, pageY;
|
1429 |
-
if (ev.type == 'touchstart') {
|
1430 |
-
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1431 |
-
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1432 |
-
} else {
|
1433 |
-
pageX = ev.pageX;
|
1434 |
-
pageY = ev.pageY;
|
1435 |
-
}
|
1436 |
-
|
1437 |
-
change.apply(
|
1438 |
-
current.cal.data('colpick').fields
|
1439 |
-
.eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) / current.cal.data('colpick').height, 10)).end()
|
1440 |
-
.eq(5).val(parseInt(100 * (pageX - current.pos.left) / current.cal.data('colpick').height, 10))
|
1441 |
-
.get(0),
|
1442 |
-
[current.preview]
|
1443 |
-
);
|
1444 |
-
return false;
|
1445 |
-
},
|
1446 |
-
moveSelector = function (ev) {
|
1447 |
-
var payeX, pageY;
|
1448 |
-
if (ev.type == 'touchmove') {
|
1449 |
-
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1450 |
-
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1451 |
-
} else {
|
1452 |
-
pageX = ev.pageX;
|
1453 |
-
pageY = ev.pageY;
|
1454 |
-
}
|
1455 |
-
|
1456 |
-
change.apply(
|
1457 |
-
ev.data.cal.data('colpick').fields
|
1458 |
-
.eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) / ev.data.cal.data('colpick').height, 10)).end()
|
1459 |
-
.eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
|
1460 |
-
.get(0),
|
1461 |
-
[ev.data.preview]
|
1462 |
-
);
|
1463 |
-
return false;
|
1464 |
-
},
|
1465 |
-
upSelector = function (ev) {
|
1466 |
-
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1467 |
-
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1468 |
-
$(document).off('mouseup touchend', upSelector);
|
1469 |
-
$(document).off('mousemove touchmove', moveSelector);
|
1470 |
-
return false;
|
1471 |
-
},
|
1472 |
-
//Submit button
|
1473 |
-
clickSubmit = function (ev) {
|
1474 |
-
var cal = $(this).parent();
|
1475 |
-
var col = cal.data('colpick').color;
|
1476 |
-
cal.data('colpick').origColor = col;
|
1477 |
-
setCurrentColor(col, cal.get(0));
|
1478 |
-
cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
|
1479 |
-
},
|
1480 |
-
//Show/hide the color picker
|
1481 |
-
show = function (ev) {
|
1482 |
-
// Prevent the trigger of any direct parent
|
1483 |
-
ev.stopPropagation();
|
1484 |
-
var cal = $('#' + $(this).data('colpickId'));
|
1485 |
-
cal.data('colpick').onBeforeShow.apply(this, [cal.get(0)]);
|
1486 |
-
var pos = $(this).offset();
|
1487 |
-
var top = pos.top + this.offsetHeight;
|
1488 |
-
var left = pos.left;
|
1489 |
-
var viewPort = getViewport();
|
1490 |
-
var calW = cal.width();
|
1491 |
-
if (left + calW > viewPort.l + viewPort.w) {
|
1492 |
-
left -= calW;
|
1493 |
-
}
|
1494 |
-
cal.css({left: left + 'px', top: top + 'px'});
|
1495 |
-
if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
|
1496 |
-
cal.show();
|
1497 |
-
}
|
1498 |
-
//Hide when user clicks outside
|
1499 |
-
$('html').mousedown({cal: cal}, hide);
|
1500 |
-
cal.mousedown(function (ev) {
|
1501 |
-
ev.stopPropagation();
|
1502 |
-
})
|
1503 |
-
},
|
1504 |
-
hide = function (ev) {
|
1505 |
-
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
1506 |
-
ev.data.cal.hide();
|
1507 |
-
}
|
1508 |
-
$('html').off('mousedown', hide);
|
1509 |
-
},
|
1510 |
-
getViewport = function () {
|
1511 |
-
var m = document.compatMode == 'CSS1Compat';
|
1512 |
-
return {
|
1513 |
-
l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
1514 |
-
w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
|
1515 |
-
};
|
1516 |
-
},
|
1517 |
-
//Fix the values if the user enters a negative or high value
|
1518 |
-
fixHSB = function (hsb) {
|
1519 |
-
return {
|
1520 |
-
h: Math.min(360, Math.max(0, hsb.h)),
|
1521 |
-
s: Math.min(100, Math.max(0, hsb.s)),
|
1522 |
-
b: Math.min(100, Math.max(0, hsb.b))
|
1523 |
-
};
|
1524 |
-
},
|
1525 |
-
fixRGB = function (rgb) {
|
1526 |
-
return {
|
1527 |
-
r: Math.min(255, Math.max(0, rgb.r)),
|
1528 |
-
g: Math.min(255, Math.max(0, rgb.g)),
|
1529 |
-
b: Math.min(255, Math.max(0, rgb.b))
|
1530 |
-
};
|
1531 |
-
},
|
1532 |
-
fixHex = function (hex) {
|
1533 |
-
var len = 6 - hex.length;
|
1534 |
-
if (len > 0) {
|
1535 |
-
var o = [];
|
1536 |
-
for (var i = 0; i < len; i++) {
|
1537 |
-
o.push('0');
|
1538 |
-
}
|
1539 |
-
o.push(hex);
|
1540 |
-
hex = o.join('');
|
1541 |
-
}
|
1542 |
-
return hex;
|
1543 |
-
},
|
1544 |
-
restoreOriginal = function () {
|
1545 |
-
var cal = $(this).parent();
|
1546 |
-
var col = cal.data('colpick').origColor;
|
1547 |
-
cal.data('colpick').color = col;
|
1548 |
-
fillRGBFields(col, cal.get(0));
|
1549 |
-
fillHexFields(col, cal.get(0));
|
1550 |
-
fillHSBFields(col, cal.get(0));
|
1551 |
-
setSelector(col, cal.get(0));
|
1552 |
-
setHue(col, cal.get(0));
|
1553 |
-
setNewColor(col, cal.get(0));
|
1554 |
-
};
|
1555 |
-
return {
|
1556 |
-
init: function (opt) {
|
1557 |
-
opt = $.extend({}, defaults, opt || {});
|
1558 |
-
//Set color
|
1559 |
-
if (typeof opt.color == 'string') {
|
1560 |
-
opt.color = hexToHsb(opt.color);
|
1561 |
-
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
1562 |
-
opt.color = rgbToHsb(opt.color);
|
1563 |
-
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
1564 |
-
opt.color = fixHSB(opt.color);
|
1565 |
-
} else {
|
1566 |
-
return this;
|
1567 |
-
}
|
1568 |
-
|
1569 |
-
//For each selected DOM element
|
1570 |
-
return this.each(function () {
|
1571 |
-
//If the element does not have an ID
|
1572 |
-
if (!$(this).data('colpickId')) {
|
1573 |
-
var options = $.extend({}, opt);
|
1574 |
-
options.origColor = opt.color;
|
1575 |
-
//Generate and assign a random ID
|
1576 |
-
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
1577 |
-
$(this).data('colpickId', id);
|
1578 |
-
//Set the tpl's ID and get the HTML
|
1579 |
-
var cal = $(tpl).attr('id', id);
|
1580 |
-
//Add class according to layout
|
1581 |
-
cal.addClass('colpick_' + options.layout + (options.submit ? '' : ' colpick_' + options.layout + '_ns'));
|
1582 |
-
//Add class if the color scheme is not default
|
1583 |
-
if (options.colorScheme != 'light') {
|
1584 |
-
cal.addClass('colpick_' + options.colorScheme);
|
1585 |
-
}
|
1586 |
-
//Setup submit button
|
1587 |
-
cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
|
1588 |
-
//Setup input fields
|
1589 |
-
options.fields = cal.find('input').change(change).blur(blur).focus(focus);
|
1590 |
-
cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
|
1591 |
-
//Setup hue selector
|
1592 |
-
options.selector = cal.find('div.colpick_color').on('mousedown touchstart', downSelector);
|
1593 |
-
options.selectorIndic = options.selector.find('div.colpick_selector_outer');
|
1594 |
-
//Store parts of the plugin
|
1595 |
-
options.el = this;
|
1596 |
-
options.hue = cal.find('div.colpick_hue_arrs');
|
1597 |
-
huebar = options.hue.parent();
|
1598 |
-
//Paint the hue bar
|
1599 |
-
var UA = navigator.userAgent.toLowerCase();
|
1600 |
-
var isIE = navigator.appName === 'Microsoft Internet Explorer';
|
1601 |
-
var IEver = isIE ? parseFloat(UA.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0;
|
1602 |
-
var ngIE = (isIE && IEver < 10);
|
1603 |
-
var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80', '#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
|
1604 |
-
if (ngIE) {
|
1605 |
-
var i, div;
|
1606 |
-
for (i = 0; i <= 11; i++) {
|
1607 |
-
div = $('<div></div>').attr('style', 'height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + '); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
|
1608 |
-
huebar.append(div);
|
1609 |
-
}
|
1610 |
-
} else {
|
1611 |
-
stopList = stops.join(',');
|
1612 |
-
huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList + '); background: -o-linear-gradient(top,' + stopList + '); background: -ms-linear-gradient(top,' + stopList + '); background:-moz-linear-gradient(top,' + stopList + '); -webkit-linear-gradient(top,' + stopList + '); background:linear-gradient(to bottom,' + stopList + '); ');
|
1613 |
-
}
|
1614 |
-
cal.find('div.colpick_hue').on('mousedown touchstart', downHue);
|
1615 |
-
options.newColor = cal.find('div.colpick_new_color');
|
1616 |
-
options.currentColor = cal.find('div.colpick_current_color');
|
1617 |
-
//Store options and fill with default color
|
1618 |
-
cal.data('colpick', options);
|
1619 |
-
fillRGBFields(options.color, cal.get(0));
|
1620 |
-
fillHSBFields(options.color, cal.get(0));
|
1621 |
-
fillHexFields(options.color, cal.get(0));
|
1622 |
-
setHue(options.color, cal.get(0));
|
1623 |
-
setSelector(options.color, cal.get(0));
|
1624 |
-
setCurrentColor(options.color, cal.get(0));
|
1625 |
-
setNewColor(options.color, cal.get(0));
|
1626 |
-
//Append to body if flat=false, else show in place
|
1627 |
-
if (options.flat) {
|
1628 |
-
cal.appendTo(this).show();
|
1629 |
-
cal.css({
|
1630 |
-
position: 'relative',
|
1631 |
-
display: 'block'
|
1632 |
-
});
|
1633 |
-
} else {
|
1634 |
-
cal.appendTo(document.body);
|
1635 |
-
$(this).on(options.showEvent, show);
|
1636 |
-
cal.css({
|
1637 |
-
position: 'absolute'
|
1638 |
-
});
|
1639 |
-
}
|
1640 |
-
}
|
1641 |
-
});
|
1642 |
-
},
|
1643 |
-
//Shows the picker
|
1644 |
-
showPicker: function () {
|
1645 |
-
return this.each(function () {
|
1646 |
-
if ($(this).data('colpickId')) {
|
1647 |
-
show.apply(this);
|
1648 |
-
}
|
1649 |
-
});
|
1650 |
-
},
|
1651 |
-
//Hides the picker
|
1652 |
-
hidePicker: function () {
|
1653 |
-
return this.each(function () {
|
1654 |
-
if ($(this).data('colpickId')) {
|
1655 |
-
$('#' + $(this).data('colpickId')).hide();
|
1656 |
-
}
|
1657 |
-
});
|
1658 |
-
},
|
1659 |
-
//Sets a color as new and current (default)
|
1660 |
-
setColor: function (col, setCurrent) {
|
1661 |
-
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
1662 |
-
if (typeof col == 'string') {
|
1663 |
-
col = hexToHsb(col);
|
1664 |
-
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
1665 |
-
col = rgbToHsb(col);
|
1666 |
-
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
1667 |
-
col = fixHSB(col);
|
1668 |
-
} else {
|
1669 |
-
return this;
|
1670 |
-
}
|
1671 |
-
return this.each(function () {
|
1672 |
-
if ($(this).data('colpickId')) {
|
1673 |
-
var cal = $('#' + $(this).data('colpickId'));
|
1674 |
-
cal.data('colpick').color = col;
|
1675 |
-
cal.data('colpick').origColor = col;
|
1676 |
-
fillRGBFields(col, cal.get(0));
|
1677 |
-
fillHSBFields(col, cal.get(0));
|
1678 |
-
fillHexFields(col, cal.get(0));
|
1679 |
-
setHue(col, cal.get(0));
|
1680 |
-
setSelector(col, cal.get(0));
|
1681 |
-
|
1682 |
-
setNewColor(col, cal.get(0));
|
1683 |
-
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
|
1684 |
-
if (setCurrent) {
|
1685 |
-
setCurrentColor(col, cal.get(0));
|
1686 |
-
}
|
1687 |
-
}
|
1688 |
-
});
|
1689 |
-
}
|
1690 |
-
};
|
1691 |
-
}();
|
1692 |
-
//Color space convertions
|
1693 |
-
var hexToRgb = function (hex) {
|
1694 |
-
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
1695 |
-
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
1696 |
-
};
|
1697 |
-
var hexToHsb = function (hex) {
|
1698 |
-
return rgbToHsb(hexToRgb(hex));
|
1699 |
-
};
|
1700 |
-
var rgbToHsb = function (rgb) {
|
1701 |
-
var hsb = {h: 0, s: 0, b: 0};
|
1702 |
-
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
1703 |
-
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
1704 |
-
var delta = max - min;
|
1705 |
-
hsb.b = max;
|
1706 |
-
hsb.s = max != 0 ? 255 * delta / max : 0;
|
1707 |
-
if (hsb.s != 0) {
|
1708 |
-
if (rgb.r == max)
|
1709 |
-
hsb.h = (rgb.g - rgb.b) / delta;
|
1710 |
-
else if (rgb.g == max)
|
1711 |
-
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
1712 |
-
else
|
1713 |
-
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
1714 |
-
} else
|
1715 |
-
hsb.h = -1;
|
1716 |
-
hsb.h *= 60;
|
1717 |
-
if (hsb.h < 0)
|
1718 |
-
hsb.h += 360;
|
1719 |
-
hsb.s *= 100 / 255;
|
1720 |
-
hsb.b *= 100 / 255;
|
1721 |
-
return hsb;
|
1722 |
-
};
|
1723 |
-
var hsbToRgb = function (hsb) {
|
1724 |
-
var rgb = {};
|
1725 |
-
var h = hsb.h;
|
1726 |
-
var s = hsb.s * 255 / 100;
|
1727 |
-
var v = hsb.b * 255 / 100;
|
1728 |
-
if (s == 0) {
|
1729 |
-
rgb.r = rgb.g = rgb.b = v;
|
1730 |
-
} else {
|
1731 |
-
var t1 = v;
|
1732 |
-
var t2 = (255 - s) * v / 255;
|
1733 |
-
var t3 = (t1 - t2) * (h % 60) / 60;
|
1734 |
-
if (h == 360)
|
1735 |
-
h = 0;
|
1736 |
-
if (h < 60) {
|
1737 |
-
rgb.r = t1;
|
1738 |
-
rgb.b = t2;
|
1739 |
-
rgb.g = t2 + t3
|
1740 |
-
} else if (h < 120) {
|
1741 |
-
rgb.g = t1;
|
1742 |
-
rgb.b = t2;
|
1743 |
-
rgb.r = t1 - t3
|
1744 |
-
} else if (h < 180) {
|
1745 |
-
rgb.g = t1;
|
1746 |
-
rgb.r = t2;
|
1747 |
-
rgb.b = t2 + t3
|
1748 |
-
} else if (h < 240) {
|
1749 |
-
rgb.b = t1;
|
1750 |
-
rgb.r = t2;
|
1751 |
-
rgb.g = t1 - t3
|
1752 |
-
} else if (h < 300) {
|
1753 |
-
rgb.b = t1;
|
1754 |
-
rgb.g = t2;
|
1755 |
-
rgb.r = t2 + t3
|
1756 |
-
} else if (h < 360) {
|
1757 |
-
rgb.r = t1;
|
1758 |
-
rgb.g = t2;
|
1759 |
-
rgb.b = t1 - t3
|
1760 |
-
} else {
|
1761 |
-
rgb.r = 0;
|
1762 |
-
rgb.g = 0;
|
1763 |
-
rgb.b = 0
|
1764 |
-
}
|
1765 |
-
}
|
1766 |
-
return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
|
1767 |
-
};
|
1768 |
-
var rgbToHex = function (rgb) {
|
1769 |
-
var hex = [
|
1770 |
-
rgb.r.toString(16),
|
1771 |
-
rgb.g.toString(16),
|
1772 |
-
rgb.b.toString(16)
|
1773 |
-
];
|
1774 |
-
$.each(hex, function (nr, val) {
|
1775 |
-
if (val.length == 1) {
|
1776 |
-
hex[nr] = '0' + val;
|
1777 |
-
}
|
1778 |
-
});
|
1779 |
-
return hex.join('');
|
1780 |
-
};
|
1781 |
-
var hsbToHex = function (hsb) {
|
1782 |
-
return rgbToHex(hsbToRgb(hsb));
|
1783 |
-
};
|
1784 |
-
$.fn.extend({
|
1785 |
-
colpick: colpick.init,
|
1786 |
-
colpickHide: colpick.hidePicker,
|
1787 |
-
colpickShow: colpick.showPicker,
|
1788 |
-
colpickSetColor: colpick.setColor
|
1789 |
-
});
|
1790 |
-
$.extend({
|
1791 |
-
colpick: {
|
1792 |
-
rgbToHex: rgbToHex,
|
1793 |
-
rgbToHsb: rgbToHsb,
|
1794 |
-
hsbToHex: hsbToHex,
|
1795 |
-
hsbToRgb: hsbToRgb,
|
1796 |
-
hexToHsb: hexToHsb,
|
1797 |
-
hexToRgb: hexToRgb
|
1798 |
-
}
|
1799 |
-
});
|
1800 |
})(jQuery);
|
1 |
+
var strict;
|
2 |
+
|
3 |
+
|
4 |
+
jQuery(document).ready(function ($) {
|
5 |
+
|
6 |
+
// show / hide helper description
|
7 |
+
$('.quads-tooltip').click(function (e) {
|
8 |
+
e.preventDefault();
|
9 |
+
var icon = $(this),
|
10 |
+
bubble = $(this).next();
|
11 |
+
|
12 |
+
// Close any that are already open
|
13 |
+
$('.quads-tooltip-message').not(bubble).hide();
|
14 |
+
|
15 |
+
var position = icon.position();
|
16 |
+
if (bubble.hasClass('bottom')) {
|
17 |
+
bubble.css({
|
18 |
+
'left': (position.left - bubble.width() / 2) + 'px',
|
19 |
+
'top': (position.top + icon.height() + 9) + 'px'
|
20 |
+
});
|
21 |
+
} else {
|
22 |
+
bubble.css({
|
23 |
+
'left': (position.left + icon.width() + 9) + 'px',
|
24 |
+
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
25 |
+
});
|
26 |
+
}
|
27 |
+
|
28 |
+
bubble.toggle();
|
29 |
+
e.stopPropagation();
|
30 |
+
});
|
31 |
+
|
32 |
+
$('body').click(function () {
|
33 |
+
$('.quads-tooltip-message').hide();
|
34 |
+
});
|
35 |
+
|
36 |
+
$('.quads-tooltip-message').click(function (e) {
|
37 |
+
e.stopPropagation();
|
38 |
+
});
|
39 |
+
|
40 |
+
|
41 |
+
// vi login process
|
42 |
+
$("#quads_vi_login_submit").click(function(e){
|
43 |
+
e.preventDefault();
|
44 |
+
username = $("#quads-vi-email").val();
|
45 |
+
password = $("#quads-vi-password").val();
|
46 |
+
|
47 |
+
var data = '{"email":"' + username + '", "password":"' + password + '"}';
|
48 |
+
|
49 |
+
$.ajax({
|
50 |
+
type: "POST",
|
51 |
+
//url: "https://dashboard-api-test.vidint.net/v1/api/authenticate",
|
52 |
+
url: quads.vi_login_url,
|
53 |
+
contentType: 'application/json',
|
54 |
+
data: data,
|
55 |
+
statusCode: {
|
56 |
+
502: function () {
|
57 |
+
$("#quads_add_err").html("502 Bad Gateway. Contact support[at]vi.ai");
|
58 |
+
console.log('502 Bad Gateway.');
|
59 |
+
return false;
|
60 |
+
},
|
61 |
+
500: function () {
|
62 |
+
$("#quads_add_err").html("500 Bad Gateway. Contact support[at]vi.ai");
|
63 |
+
console.log('500 Bad Gateway.');
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
},
|
67 |
+
success: function(response){
|
68 |
+
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
69 |
+
$("#quads_add_err").hide();
|
70 |
+
if (typeof response.data !== 'undefined') {
|
71 |
+
$("#quads_add_err").html("We are logging you in");
|
72 |
+
console.log('We are logging you in' + response);
|
73 |
+
saveViToken(response.data);
|
74 |
+
}
|
75 |
+
else {
|
76 |
+
$("#quads_add_err").html("No valid API response. Can not log you in. Contact support[at]vi.ai");
|
77 |
+
console.log('no valid api response' + response);
|
78 |
+
}
|
79 |
+
},
|
80 |
+
error: function(response){
|
81 |
+
// check if xhr.status is defined in $.ajax.statusCode
|
82 |
+
// if true, return false to stop this function
|
83 |
+
if (typeof this.statusCode[response.status] != 'undefined') {
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
var result = typeof response.responseText !== 'undefined' ? JSON.parse(response.responseText) : '';
|
88 |
+
$("#quads_add_err").html(result.error.message + ' ' + result.error.description);
|
89 |
+
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
90 |
+
$("#quads_add_err").show();
|
91 |
+
$("#quads_add_err").removeClass('quads-spinner');
|
92 |
+
console.log(result);
|
93 |
+
//exit;
|
94 |
+
},
|
95 |
+
beforeSend:function()
|
96 |
+
{
|
97 |
+
$("#quads_vi_loading").css('display', 'inline', 'important').css('visibility', 'visible');
|
98 |
+
$("#quads_add_err").show();
|
99 |
+
},
|
100 |
+
|
101 |
+
complete:function()
|
102 |
+
{
|
103 |
+
$("#quads_vi_loading").css('display', 'none', 'important').css('visibility', 'hidden');
|
104 |
+
}
|
105 |
+
|
106 |
+
});
|
107 |
+
return false;
|
108 |
+
});
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Save vi token
|
112 |
+
*/
|
113 |
+
function saveViToken(token){
|
114 |
+
var data = {
|
115 |
+
'action': 'quads_save_vi_token',
|
116 |
+
'token': token
|
117 |
+
};
|
118 |
+
$.ajax({
|
119 |
+
type: "POST",
|
120 |
+
url: ajaxurl,
|
121 |
+
dataType: "json",
|
122 |
+
data: data,
|
123 |
+
//contentType: 'application/json;charset=utf-8',
|
124 |
+
success: function(response){
|
125 |
+
//response = JSON.stringify(response);
|
126 |
+
console.log(response.status);
|
127 |
+
|
128 |
+
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
129 |
+
$("#quads_add_err").hide();
|
130 |
+
if (typeof response.status != 'undefined' && response.status == 'success') {
|
131 |
+
console.log('Success, login succesfull, token stored' + response);
|
132 |
+
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
else {
|
136 |
+
console.log("Can not store token");
|
137 |
+
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
},
|
141 |
+
beforeSend:function()
|
142 |
+
{
|
143 |
+
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
144 |
+
$("#quads_add_err").show();
|
145 |
+
},
|
146 |
+
complete:function()
|
147 |
+
{
|
148 |
+
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
149 |
+
$("#quads_add_err").hide();
|
150 |
+
}
|
151 |
+
|
152 |
+
});
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
// Remove several unused elements from vi page
|
159 |
+
if (document.location.href.indexOf('vi_header') > - 1) {
|
160 |
+
$('#quads-submit-button').hide();
|
161 |
+
$('#quads-validate').hide();
|
162 |
+
$('#quads-footer').hide();
|
163 |
+
} else {
|
164 |
+
$('#quads-submit-button').show();
|
165 |
+
$('#quads-validate').show();
|
166 |
+
$('#quads-footer').show();
|
167 |
+
}
|
168 |
+
$(window).bind('easytabs:after', function(){
|
169 |
+
if (document.location.href.indexOf('vi_header') > - 1) {
|
170 |
+
$('#quads-submit-button').hide();
|
171 |
+
$('#quads-validate').hide();
|
172 |
+
$('#quads-footer').hide();
|
173 |
+
} else {
|
174 |
+
|
175 |
+
$('#quads-submit-button').show();
|
176 |
+
$('#quads-validate').show();
|
177 |
+
$('#quads-footer').show();
|
178 |
+
}
|
179 |
+
});
|
180 |
+
|
181 |
+
|
182 |
+
|
183 |
+
|
184 |
+
|
185 |
+
// VI signup form
|
186 |
+
$('#quads-vi-signup').click(function(e){
|
187 |
+
e.preventDefault();
|
188 |
+
// scroll to top
|
189 |
+
$(window).scrollTop(0);
|
190 |
+
// hide save button
|
191 |
+
$('#quads-submit-button').hide();
|
192 |
+
$('#quads-vi-signup-fullscreen').fadeIn();
|
193 |
+
});
|
194 |
+
$('#quads-vi-close').click(function(e){
|
195 |
+
e.preventDefault();
|
196 |
+
$('#quads-vi-signup-fullscreen').fadeOut();
|
197 |
+
});
|
198 |
+
|
199 |
+
/**
|
200 |
+
* General Tab
|
201 |
+
*/
|
202 |
+
// Inactive select fields are greyed out
|
203 |
+
$('.quads-assign').each(function(e){
|
204 |
+
if (!$(this).prop('checked')){
|
205 |
+
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
206 |
+
}else {
|
207 |
+
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
208 |
+
}
|
209 |
+
});
|
210 |
+
|
211 |
+
$('.quads-assign').click(function(){
|
212 |
+
if (!$(this).prop('checked')){
|
213 |
+
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
214 |
+
} else {
|
215 |
+
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
216 |
+
}
|
217 |
+
});
|
218 |
+
|
219 |
+
/**
|
220 |
+
* AdSense Code Tab
|
221 |
+
*/
|
222 |
+
// Check if submit button is visible than stick it to the bottom of the page
|
223 |
+
$(window).scroll(function() {
|
224 |
+
|
225 |
+
var elem = '#quads_tab_container .submit';
|
226 |
+
|
227 |
+
if ($(elem).length < 1){
|
228 |
+
return;
|
229 |
+
}
|
230 |
+
|
231 |
+
var top_of_element = $(elem).offset().top;
|
232 |
+
var bottom_of_element = $(elem).offset().top + $(elem).outerHeight(false);
|
233 |
+
var bottom_of_screen = $(window).scrollTop() + $(window).height();
|
234 |
+
if (bottom_of_screen > top_of_element){
|
235 |
+
// The element is visible, do something
|
236 |
+
$('#quads-submit-button').css('position', 'relative').css('bottom', '20px');
|
237 |
+
} else {
|
238 |
+
// The element is NOT visible, do something else
|
239 |
+
$('#quads-submit-button').css('position', 'fixed').css('bottom', '20px');
|
240 |
+
}
|
241 |
+
});
|
242 |
+
|
243 |
+
// Activate chosen select boxes
|
244 |
+
// $(".quads-chosen-select").chosen({
|
245 |
+
// inherit_select_classes: true
|
246 |
+
// });
|
247 |
+
|
248 |
+
|
249 |
+
|
250 |
+
// Hid or show AMP code form on click on amp checkbox
|
251 |
+
$('.quads-activate-amp').click(function(){
|
252 |
+
var parent = $(this).parents('.quads-ad-toggle-container').attr('id');
|
253 |
+
if ($(this).attr('checked') === 'checked') {
|
254 |
+
$('#' + parent).find('.quads-amp-code').show();
|
255 |
+
} else {
|
256 |
+
$('#' + parent).find('.quads-amp-code').hide();
|
257 |
+
}
|
258 |
+
});
|
259 |
+
|
260 |
+
|
261 |
+
// Hide or show AMP code form on loading
|
262 |
+
$('.quads-ad-toggle-container').find('.quads-activate-amp').each(function (index, value) {
|
263 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
264 |
+
if ($(this).attr( 'checked') === 'checked' ) {
|
265 |
+
$('#' + parentContainerID).find('.quads-amp-code').show();
|
266 |
+
}else {
|
267 |
+
$('#' + parentContainerID).find('.quads-amp-code').hide();
|
268 |
+
}
|
269 |
+
});
|
270 |
+
|
271 |
+
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Toggle Button | Open All Ads
|
275 |
+
*/
|
276 |
+
$('#quads-open-toggle').click(function(){
|
277 |
+
if ($('#quads-open-toggle').text() === 'Open All Ads' ){
|
278 |
+
$('.quads-ad-toggle-container').show();
|
279 |
+
$('#quads-open-toggle').html('Close Ads');
|
280 |
+
}else{
|
281 |
+
$('.quads-ad-toggle-container').hide();
|
282 |
+
$('#quads-open-toggle').html('Open All Ads');
|
283 |
+
}
|
284 |
+
});
|
285 |
+
|
286 |
+
// show / hide helper description
|
287 |
+
$('.quads-helper').click(function (e) {
|
288 |
+
e.preventDefault();
|
289 |
+
var icon = $(this),
|
290 |
+
bubble = $(this).next();
|
291 |
+
|
292 |
+
// Close any that are already open
|
293 |
+
$('.quads-message').not(bubble).hide();
|
294 |
+
|
295 |
+
var position = icon.position();
|
296 |
+
if (bubble.hasClass('bottom')) {
|
297 |
+
bubble.css({
|
298 |
+
'left': (position.left - bubble.width() / 2) + 'px',
|
299 |
+
'top': (position.top + icon.height() + 9) + 'px'
|
300 |
+
});
|
301 |
+
} else {
|
302 |
+
bubble.css({
|
303 |
+
'left': (position.left + icon.width() + 9) + 'px',
|
304 |
+
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
305 |
+
});
|
306 |
+
}
|
307 |
+
|
308 |
+
bubble.toggle();
|
309 |
+
e.stopPropagation();
|
310 |
+
});
|
311 |
+
$('.quads-general-helper').click(function (e) {
|
312 |
+
e.preventDefault();
|
313 |
+
var icon = $(this),
|
314 |
+
bubble = $(this).next();
|
315 |
+
|
316 |
+
// Close any that are already open
|
317 |
+
$('.quads-message').not(bubble).hide();
|
318 |
+
|
319 |
+
var position = icon.position();
|
320 |
+
if (bubble.hasClass('bottom')) {
|
321 |
+
bubble.css({
|
322 |
+
'left': (position.left - bubble.width() / 2) + 'px',
|
323 |
+
'top': (position.top + icon.height() + 9) + 'px'
|
324 |
+
});
|
325 |
+
} else {
|
326 |
+
bubble.css({
|
327 |
+
'left': (position.left + icon.width() + 9) + 'px',
|
328 |
+
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
329 |
+
});
|
330 |
+
}
|
331 |
+
|
332 |
+
bubble.toggle();
|
333 |
+
e.stopPropagation();
|
334 |
+
});
|
335 |
+
|
336 |
+
$('body').click(function () {
|
337 |
+
$('.quads-message').hide();
|
338 |
+
});
|
339 |
+
|
340 |
+
$('.quads-message').click(function (e) {
|
341 |
+
e.stopPropagation();
|
342 |
+
});
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Save settings via ajax
|
346 |
+
*/
|
347 |
+
|
348 |
+
jQuery('#quads_settings').submit(function() {
|
349 |
+
|
350 |
+
// Check if ad name has been changed and prepare new data for saving
|
351 |
+
$('.quads-toogle-title').each(function(){
|
352 |
+
$(this).children('input').val($(this).text());
|
353 |
+
});
|
354 |
+
|
355 |
+
|
356 |
+
// Check current url / settings page
|
357 |
+
var url = window.location.search;
|
358 |
+
var tab_imexport = url.search("page=quads-settings&tab=imexport");
|
359 |
+
var tab_licenses = url.search("page=quads-settings&tab=licenses");
|
360 |
+
|
361 |
+
jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
|
362 |
+
jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
|
363 |
+
jQuery(this).ajaxSubmit({
|
364 |
+
|
365 |
+
success: function(){
|
366 |
+
jQuery('#quads-save-result').html("<div id='quads-save-message' class='quads-success-modal'></div>");
|
367 |
+
jQuery('#quads-save-message').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/saved.gif"></p>').show();
|
368 |
+
quads_hide_success_message();
|
369 |
+
},
|
370 |
+
//,timeout: 0,
|
371 |
+
|
372 |
+
error: function(){
|
373 |
+
//Do not show alert on import/export tab
|
374 |
+
if ( tab_imexport === -1 && tab_licenses === -1 ){
|
375 |
+
alert ('Error: Can not save settings. Try again');
|
376 |
+
}
|
377 |
+
jQuery('#quads-save-result').hide('fast');
|
378 |
+
}
|
379 |
+
});
|
380 |
+
// Do not use ajax saving on import/export and licenses tab
|
381 |
+
if ( tab_imexport === -1 && tab_licenses ===-1 ){
|
382 |
+
return false;
|
383 |
+
}
|
384 |
+
});
|
385 |
+
|
386 |
+
function quads_hide_success_message(){
|
387 |
+
setTimeout("jQuery('#quads-save-message').hide()", 1000);
|
388 |
+
}
|
389 |
+
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Paste AdSense Code form
|
393 |
+
*/
|
394 |
+
$(document).on('click', '#quads-paste-button', function () {
|
395 |
+
|
396 |
+
var content = $('#quads-adsense-form').val();
|
397 |
+
var parseResult = quadsParseAdSenseCode(content);
|
398 |
+
if (false !== parseResult) {
|
399 |
+
console.log(parseResult);
|
400 |
+
setDetailsFromAdCode(parseResult);
|
401 |
+
}else{
|
402 |
+
$('#quads-msg').html('Can not parse AdSense Code. Is the code valid?');
|
403 |
+
$('#quads-msg').show();
|
404 |
+
}
|
405 |
+
});
|
406 |
+
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Populate AdSense Date Fields
|
410 |
+
*
|
411 |
+
* @param object adsense
|
412 |
+
* @param2 string id of the parent container
|
413 |
+
* @returns false
|
414 |
+
*/
|
415 |
+
function setDetailsFromAdCode(GoogleAd) {
|
416 |
+
|
417 |
+
var containerID = $('#quads-adsense-id').val();
|
418 |
+
|
419 |
+
var id = containerID.replace("quads-toggle", "");
|
420 |
+
|
421 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_slot\\]').val(GoogleAd.slotId);
|
422 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_client\\]').val(GoogleAd.pubId);
|
423 |
+
if ('normal' == GoogleAd.type) {
|
424 |
+
console.log($('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]'));
|
425 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('normal');
|
426 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val(GoogleAd.width);
|
427 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val(GoogleAd.height);
|
428 |
+
}
|
429 |
+
if ('responsive' == GoogleAd.type) {
|
430 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('responsive');
|
431 |
+
//$('#ad-resize-type').val('auto');
|
432 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val('');
|
433 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val('');
|
434 |
+
}
|
435 |
+
// Trigger the ad type select
|
436 |
+
$('.quads-select-Type').trigger('change');
|
437 |
+
// Hide the overlay
|
438 |
+
$('#quads-adsense-bg-div').hide();
|
439 |
+
// Ad code input form must not be empty!
|
440 |
+
if ($('#' + containerID).children('textarea').val().length === 0){
|
441 |
+
$('#' + containerID).children('textarea').val('adsense');
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Parse the adsense ad content
|
449 |
+
* @param {type} content
|
450 |
+
* @returns {quads-admin.min_L3.parseAdContent.GoogleAd|Boolean}
|
451 |
+
*/
|
452 |
+
function quadsParseAdSenseCode(content) {
|
453 |
+
|
454 |
+
var rawContent = ('undefined' != typeof (content)) ? content.trim() : '';
|
455 |
+
var GoogleAd = {};
|
456 |
+
var theContent = $('<div />').html(rawContent);
|
457 |
+
var asyncGoogleAd = theContent.find('ins');
|
458 |
+
//var syncGoogleAd = theContent.search('google_ad_client');
|
459 |
+
|
460 |
+
// Its a async adsense ad
|
461 |
+
if (asyncGoogleAd.length > 0) {
|
462 |
+
console.log('async ad');
|
463 |
+
|
464 |
+
// Ad Slot ID
|
465 |
+
GoogleAd.slotId = asyncGoogleAd.attr('data-ad-slot');
|
466 |
+
|
467 |
+
if ('undefined' != typeof (asyncGoogleAd.attr('data-ad-client'))) {
|
468 |
+
// Ad Publisher ID
|
469 |
+
GoogleAd.pubId = asyncGoogleAd.attr('data-ad-client').substr(3);
|
470 |
+
}
|
471 |
+
|
472 |
+
if (undefined !== GoogleAd.slotId && '' != GoogleAd.pubId) {
|
473 |
+
GoogleAd.display = asyncGoogleAd.css('display');
|
474 |
+
GoogleAd.format = asyncGoogleAd.attr('data-ad-format');
|
475 |
+
GoogleAd.style = asyncGoogleAd.attr('style');
|
476 |
+
|
477 |
+
if ('undefined' == typeof (GoogleAd.format) && -1 != GoogleAd.style.indexOf('width')) {
|
478 |
+
/* normal ad */
|
479 |
+
GoogleAd.type = 'normal';
|
480 |
+
GoogleAd.width = asyncGoogleAd.css('width').replace('px', '');
|
481 |
+
GoogleAd.height = asyncGoogleAd.css('height').replace('px', '');
|
482 |
+
return GoogleAd;
|
483 |
+
}
|
484 |
+
|
485 |
+
if ('undefined' != typeof (GoogleAd.format) && 'auto' == GoogleAd.format) {
|
486 |
+
/* Responsive ad, auto resize */
|
487 |
+
GoogleAd.type = 'responsive';
|
488 |
+
return GoogleAd;
|
489 |
+
}
|
490 |
+
return GoogleAd;
|
491 |
+
}
|
492 |
+
|
493 |
+
return false;
|
494 |
+
}
|
495 |
+
|
496 |
+
// Google syncronous ad
|
497 |
+
if (rawContent.search('google_ad_client') > 0) {
|
498 |
+
console.log('syncronous code');
|
499 |
+
|
500 |
+
// Ad Slot ID
|
501 |
+
GoogleAd.slotId = get_google_ad_slot(content);
|
502 |
+
|
503 |
+
console.log(get_google_ad_slot(content));
|
504 |
+
console.log(get_google_ad_client(content));
|
505 |
+
console.log(get_google_ad_height(content));
|
506 |
+
console.log(get_google_ad_width(content));
|
507 |
+
|
508 |
+
if (!quadsIsEmpty(get_google_ad_client(content))) {
|
509 |
+
// Ad Publisher ID
|
510 |
+
GoogleAd.pubId = 'ca-pub-' + get_google_ad_client(content);
|
511 |
+
}else{
|
512 |
+
return false;
|
513 |
+
}
|
514 |
+
|
515 |
+
if (!quadsIsEmpty(GoogleAd.slotId) && !quadsIsEmpty(GoogleAd.pubId)) {
|
516 |
+
|
517 |
+
if (!quadsIsEmpty(get_google_ad_width(content))) {
|
518 |
+
GoogleAd.type = 'normal';
|
519 |
+
GoogleAd.width = get_google_ad_width(content);
|
520 |
+
GoogleAd.height = get_google_ad_height(content);
|
521 |
+
return GoogleAd;
|
522 |
+
}
|
523 |
+
}
|
524 |
+
return false;
|
525 |
+
}
|
526 |
+
|
527 |
+
return false;
|
528 |
+
}
|
529 |
+
|
530 |
+
function get_google_ad_slot(content) {
|
531 |
+
const regex = /google_ad_slot\s*=\s*"(\d*)";/g;
|
532 |
+
const str = content;
|
533 |
+
var m;
|
534 |
+
var result = {};
|
535 |
+
|
536 |
+
while ((m = regex.exec(str)) !== null) {
|
537 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
538 |
+
if (m.index === regex.lastIndex) {
|
539 |
+
regex.lastIndex++;
|
540 |
+
}
|
541 |
+
|
542 |
+
// The result can be accessed through the `m`-variable.
|
543 |
+
m.forEach(function(match, index){
|
544 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
545 |
+
console.log(match);
|
546 |
+
result = match;
|
547 |
+
});
|
548 |
+
}
|
549 |
+
return result;
|
550 |
+
}
|
551 |
+
function get_google_ad_client(content) {
|
552 |
+
const regex = /google_ad_client\s*=\s*"ca-pub-(\d*)";/g;
|
553 |
+
const str = content;
|
554 |
+
var m;
|
555 |
+
var result = {};
|
556 |
+
|
557 |
+
while ((m = regex.exec(str)) !== null) {
|
558 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
559 |
+
if (m.index === regex.lastIndex) {
|
560 |
+
regex.lastIndex++;
|
561 |
+
}
|
562 |
+
|
563 |
+
// The result can be accessed through the `m`-variable.
|
564 |
+
m.forEach(function(match, index){
|
565 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
566 |
+
console.log(match);
|
567 |
+
result = match;
|
568 |
+
});
|
569 |
+
}
|
570 |
+
return result;
|
571 |
+
}
|
572 |
+
function get_google_ad_width(content) {
|
573 |
+
const regex = /google_ad_width\s*=\s*(\d*);/g;
|
574 |
+
const str = content;
|
575 |
+
var m;
|
576 |
+
var result = {};
|
577 |
+
|
578 |
+
while ((m = regex.exec(str)) !== null) {
|
579 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
580 |
+
if (m.index === regex.lastIndex) {
|
581 |
+
regex.lastIndex++;
|
582 |
+
}
|
583 |
+
|
584 |
+
// The result can be accessed through the `m`-variable.
|
585 |
+
m.forEach(function(match, index){
|
586 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
587 |
+
console.log(match);
|
588 |
+
result = match;
|
589 |
+
});
|
590 |
+
}
|
591 |
+
return result;
|
592 |
+
}
|
593 |
+
function get_google_ad_height(content) {
|
594 |
+
const regex = /google_ad_height\s*=\s*(\d*);/g;
|
595 |
+
const str = content;
|
596 |
+
var m;
|
597 |
+
var result = {};
|
598 |
+
|
599 |
+
while ((m = regex.exec(str)) !== null) {
|
600 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
601 |
+
if (m.index === regex.lastIndex) {
|
602 |
+
regex.lastIndex++;
|
603 |
+
}
|
604 |
+
|
605 |
+
// The result can be accessed through the `m`-variable.
|
606 |
+
m.forEach(function(match, index){
|
607 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
608 |
+
console.log(match);
|
609 |
+
result = match;
|
610 |
+
});
|
611 |
+
}
|
612 |
+
return result;
|
613 |
+
}
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Check if return value is empty or not
|
617 |
+
* @param {type} str
|
618 |
+
* @returns {Boolean}
|
619 |
+
*/
|
620 |
+
function quadsIsEmpty(str) {
|
621 |
+
return (!str || 0 === str.length);
|
622 |
+
}
|
623 |
+
|
624 |
+
// AdSense Code Input Form
|
625 |
+
$(document).on('click', '.quads-add-adsense', function (e) {
|
626 |
+
e.preventDefault();
|
627 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
628 |
+
// Empty the ad plain text form
|
629 |
+
$('#quads-adsense-form').val('');
|
630 |
+
$('#quads-adsense-id').val(parentContainerID);
|
631 |
+
$('#quads-adsense-bg-div').show();
|
632 |
+
});
|
633 |
+
$(document).on('click', '#quads-close-button', function (e) {
|
634 |
+
e.preventDefault();
|
635 |
+
$('#quads-adsense-bg-div').hide();
|
636 |
+
});
|
637 |
+
|
638 |
+
|
639 |
+
// Toggle between AdSense or Plain Text option
|
640 |
+
$(document).on('click', '.quads_adsense_type', function () {
|
641 |
+
|
642 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
643 |
+
|
644 |
+
if ($(this).val() === 'adsense') {
|
645 |
+
$('#' + parentContainerID).children('textarea').hide();
|
646 |
+
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
647 |
+
$('#' + parentContainerID).find('.quads-sizes').show();
|
648 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
649 |
+
|
650 |
+
}
|
651 |
+
if ($(this).val() === 'plain_text') {
|
652 |
+
$('#' + parentContainerID).children('textarea').show();
|
653 |
+
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
654 |
+
$('#' + parentContainerID).find('.quads-sizes').hide();
|
655 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
656 |
+
}
|
657 |
+
});
|
658 |
+
|
659 |
+
|
660 |
+
// Hide or show AdSense elements on loading
|
661 |
+
$('.quads-ad-toggle-container').find('.quads_adsense_type').each(function (index, value) {
|
662 |
+
|
663 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
664 |
+
|
665 |
+
if ($(this).attr('checked') === 'checked' && $(this).val() === 'adsense') {
|
666 |
+
$('#' + parentContainerID).children('textarea').fadeOut();
|
667 |
+
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
668 |
+
}
|
669 |
+
if ($(this).attr('checked') === 'checked' && $(this).val() === 'plain_text') {
|
670 |
+
$('#' + parentContainerID).children('textarea').fadeIn();
|
671 |
+
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
672 |
+
}
|
673 |
+
});
|
674 |
+
|
675 |
+
|
676 |
+
// Hide or show AdSense width and height on loading
|
677 |
+
$('.quads-ad-toggle-container').find('.quads-select-Type').each(function (index, value) {
|
678 |
+
|
679 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
680 |
+
|
681 |
+
if ($(this).val() === 'responsive') {
|
682 |
+
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
683 |
+
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
684 |
+
$('#' + parentContainerID).find('.quads-sizes').show();
|
685 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
686 |
+
}
|
687 |
+
if ($(this).val() === 'normal') {
|
688 |
+
$('#' + parentContainerID).find('.quads-type-normal').show();
|
689 |
+
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
690 |
+
$('#' + parentContainerID).find('.quads-sizes').hide();
|
691 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
692 |
+
}
|
693 |
+
});
|
694 |
+
|
695 |
+
|
696 |
+
// Toggle between Fixed Size or Responsive ad type
|
697 |
+
$(document).on('change', '.quads-select-Type', function () {
|
698 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
699 |
+
|
700 |
+
if ($(this).val() === 'responsive') {
|
701 |
+
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
702 |
+
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
703 |
+
$('#' + parentContainerID).find('.quads-sizes').show();
|
704 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
705 |
+
}
|
706 |
+
if ($(this).val() === 'normal') {
|
707 |
+
$('#' + parentContainerID).find('.quads-type-normal').show();
|
708 |
+
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
709 |
+
$('#' + parentContainerID).find('.quads-sizes').hide();
|
710 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
711 |
+
}
|
712 |
+
});
|
713 |
+
|
714 |
+
//*[@id="quads-togglead1"]/div[2]
|
715 |
+
/**
|
716 |
+
* Toggle the adsense container
|
717 |
+
*/
|
718 |
+
//$('.quads-ad-toggle-header').click(function (e) {
|
719 |
+
$('.quads-form-table').on('click', '.quads-ad-toggle-header', function(e) {
|
720 |
+
e.preventDefault();
|
721 |
+
|
722 |
+
var container = $('#' + $(this).data('box-id'));
|
723 |
+
//console.log(container);
|
724 |
+
container.toggle(0, function () {
|
725 |
+
if (container.parents('.quads-ad-toggle-header').hasClass('quads-box-close')) {
|
726 |
+
// open the box
|
727 |
+
container.parents('.quads-ad-toggle-header').removeClass('quads-box-close');
|
728 |
+
} else {
|
729 |
+
container.parents('.quads-ad-toggle-header').addClass('quads-box-close');
|
730 |
+
}
|
731 |
+
});
|
732 |
+
});
|
733 |
+
|
734 |
+
/*
|
735 |
+
* Quick Adsense import process
|
736 |
+
*/
|
737 |
+
|
738 |
+
jQuery('.quads-import-settings').click(function (e) {
|
739 |
+
e.preventDefault();
|
740 |
+
|
741 |
+
if (!confirm('Importing settings from Quick AdSense will overwrite all your current settings. Are you sure?'))
|
742 |
+
return;
|
743 |
+
|
744 |
+
jQuery('#quads-import-settings').addClass('loading');
|
745 |
+
var data = {
|
746 |
+
action: 'quads_import_quick_adsense',
|
747 |
+
nonce: quads.nonce,
|
748 |
+
};
|
749 |
+
$.post(ajaxurl, data, function (resp, status, xhr) {
|
750 |
+
|
751 |
+
//console.log('success:' + resp + status + xhr);
|
752 |
+
quads_show_message(resp);
|
753 |
+
|
754 |
+
}).fail(function (xhr) { // Will be executed when $.post() fails
|
755 |
+
quads_show_message('Ajax Error: ' + xhr.status + ' ' + xhr.statusText);
|
756 |
+
//console.log('error: ' + xhr.statusText);
|
757 |
+
});
|
758 |
+
});
|
759 |
+
|
760 |
+
jQuery('#quads_insert_ads_action').click(function (e) {
|
761 |
+
e.preventDefault();
|
762 |
+
jQuery('#quads_insert_ads_box').toggle();
|
763 |
+
});
|
764 |
+
|
765 |
+
jQuery('#quads_disable_ads_action').click(function (e) {
|
766 |
+
e.preventDefault();
|
767 |
+
jQuery('#quads_disable_ads_box').toggle();
|
768 |
+
});
|
769 |
+
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Show error message and die()
|
773 |
+
* Writes error message into log file
|
774 |
+
*
|
775 |
+
* @param {string} $error notice
|
776 |
+
* @returns void
|
777 |
+
*/
|
778 |
+
function quads_show_message(error) {
|
779 |
+
$('#quads-error-details').show();
|
780 |
+
$('#quads-error-details').html(error);
|
781 |
+
console.log(error);
|
782 |
+
}
|
783 |
+
|
784 |
+
|
785 |
+
/**
|
786 |
+
* Start easytabs()
|
787 |
+
*/
|
788 |
+
if ($(".quads-tabs").length) {
|
789 |
+
$('#quads_tab_container').easytabs({
|
790 |
+
animate: true,
|
791 |
+
updateHash: true,
|
792 |
+
animationSpeed: 'fast'
|
793 |
+
});
|
794 |
+
}
|
795 |
+
|
796 |
+
|
797 |
+
|
798 |
+
|
799 |
+
}); // document ready
|
800 |
+
|
801 |
+
/*
|
802 |
+
* jQuery hashchange event - v1.3 - 7/21/2010
|
803 |
+
* http://benalman.com/projects/jquery-hashchange-plugin/
|
804 |
+
*
|
805 |
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
806 |
+
* Dual licensed under the MIT and GPL licenses.
|
807 |
+
* http://benalman.com/about/license/
|
808 |
+
*/
|
809 |
+
(function ($, e, b) {
|
810 |
+
var c = "hashchange", h = document, f, g = $.event.special, i = h.documentMode, d = "on" + c in e && (i === b || i > 7);
|
811 |
+
function a(j) {
|
812 |
+
j = j || location.href;
|
813 |
+
return"#" + j.replace(/^[^#]*#?(.*)$/, "$1")
|
814 |
+
}
|
815 |
+
$.fn[c] = function (j) {
|
816 |
+
return j ? this.bind(c, j) : this.trigger(c)
|
817 |
+
};
|
818 |
+
$.fn[c].delay = 50;
|
819 |
+
g[c] = $.extend(g[c], {setup: function () {
|
820 |
+
if (d) {
|
821 |
+
return false
|
822 |
+
}
|
823 |
+
$(f.start)
|
824 |
+
}, teardown: function () {
|
825 |
+
if (d) {
|
826 |
+
return false
|
827 |
+
}
|
828 |
+
$(f.stop)
|
829 |
+
}});
|
830 |
+
f = (function () {
|
831 |
+
var j = {}, p, m = a(), k = function (q) {
|
832 |
+
return q
|
833 |
+
}, l = k, o = k;
|
834 |
+
j.start = function () {
|
835 |
+
p || n()
|
836 |
+
};
|
837 |
+
j.stop = function () {
|
838 |
+
p && clearTimeout(p);
|
839 |
+
p = b
|
840 |
+
};
|
841 |
+
function n() {
|
842 |
+
var r = a(), q = o(m);
|
843 |
+
if (r !== m) {
|
844 |
+
l(m = r, q);
|
845 |
+
$(e).trigger(c)
|
846 |
+
} else {
|
847 |
+
if (q !== m) {
|
848 |
+
location.href = location.href.replace(/#.*/, "") + q
|
849 |
+
}
|
850 |
+
}
|
851 |
+
p = setTimeout(n, $.fn[c].delay)
|
852 |
+
}
|
853 |
+
$.browser.msie && !d && (function () {
|
854 |
+
var q, r;
|
855 |
+
j.start = function () {
|
856 |
+
if (!q) {
|
857 |
+
r = $.fn[c].src;
|
858 |
+
r = r && r + a();
|
859 |
+
q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
|
860 |
+
r || l(a());
|
861 |
+
n()
|
862 |
+
}).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
|
863 |
+
h.onpropertychange = function () {
|
864 |
+
try {
|
865 |
+
if (event.propertyName === "title") {
|
866 |
+
q.document.title = h.title
|
867 |
+
}
|
868 |
+
} catch (s) {
|
869 |
+
}
|
870 |
+
}
|
871 |
+
}
|
872 |
+
};
|
873 |
+
j.stop = k;
|
874 |
+
o = function () {
|
875 |
+
return a(q.location.href)
|
876 |
+
};
|
877 |
+
l = function (v, s) {
|
878 |
+
var u = q.document, t = $.fn[c].domain;
|
879 |
+
if (v !== s) {
|
880 |
+
u.title = h.title;
|
881 |
+
u.open();
|
882 |
+
t && u.write('<script>document.domain="' + t + '"<\/script>');
|
883 |
+
u.close();
|
884 |
+
q.location.hash = v
|
885 |
+
}
|
886 |
+
}
|
887 |
+
})();
|
888 |
+
return j
|
889 |
+
})()
|
890 |
+
})(jQuery, this);
|
891 |
+
|
892 |
+
/*
|
893 |
+
* jQuery EasyTabs plugin 3.2.0
|
894 |
+
*
|
895 |
+
* Copyright (c) 2010-2011 Steve Schwartz (JangoSteve)
|
896 |
+
*
|
897 |
+
* Dual licensed under the MIT and GPL licenses:
|
898 |
+
* http://www.opensource.org/licenses/mit-license.php
|
899 |
+
* http://www.gnu.org/licenses/gpl.html
|
900 |
+
*
|
901 |
+
* Date: Thu May 09 17:30:00 2013 -0500
|
902 |
+
*/
|
903 |
+
(function (a) {
|
904 |
+
a.easytabs = function (j, e) {
|
905 |
+
var f = this, q = a(j), i = {animate: true, panelActiveClass: "active", tabActiveClass: "active", defaultTab: "li:first-child", animationSpeed: "fast", tabs: "> ul > li", updateHash: true, cycle: false, collapsible: false, collapsedClass: "collapsed", collapsedByDefault: true, uiTabs: false, transitionIn: "fadeIn", transitionOut: "fadeOut", transitionInEasing: "swing", transitionOutEasing: "swing", transitionCollapse: "slideUp", transitionUncollapse: "slideDown", transitionCollapseEasing: "swing", transitionUncollapseEasing: "swing", containerClass: "", tabsClass: "", tabClass: "", panelClass: "", cache: true, event: "click", panelContext: q}, h, l, v, m, d, t = {fast: 200, normal: 400, slow: 600}, r;
|
906 |
+
f.init = function () {
|
907 |
+
f.settings = r = a.extend({}, i, e);
|
908 |
+
r.bind_str = r.event + ".easytabs";
|
909 |
+
if (r.uiTabs) {
|
910 |
+
r.tabActiveClass = "ui-tabs-selected";
|
911 |
+
r.containerClass = "ui-tabs ui-widget ui-widget-content ui-corner-all";
|
912 |
+
r.tabsClass = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all";
|
913 |
+
r.tabClass = "ui-state-default ui-corner-top";
|
914 |
+
r.panelClass = "ui-tabs-panel ui-widget-content ui-corner-bottom"
|
915 |
+
}
|
916 |
+
if (r.collapsible && e.defaultTab !== undefined && e.collpasedByDefault === undefined) {
|
917 |
+
r.collapsedByDefault = false
|
918 |
+
}
|
919 |
+
if (typeof (r.animationSpeed) === "string") {
|
920 |
+
r.animationSpeed = t[r.animationSpeed]
|
921 |
+
}
|
922 |
+
a("a.anchor").remove().prependTo("body");
|
923 |
+
q.data("easytabs", {});
|
924 |
+
f.setTransitions();
|
925 |
+
f.getTabs();
|
926 |
+
b();
|
927 |
+
g();
|
928 |
+
w();
|
929 |
+
n();
|
930 |
+
c();
|
931 |
+
q.attr("data-easytabs", true)
|
932 |
+
};
|
933 |
+
f.setTransitions = function () {
|
934 |
+
v = (r.animate) ? {show: r.transitionIn, hide: r.transitionOut, speed: r.animationSpeed, collapse: r.transitionCollapse, uncollapse: r.transitionUncollapse, halfSpeed: r.animationSpeed / 2} : {show: "show", hide: "hide", speed: 0, collapse: "hide", uncollapse: "show", halfSpeed: 0}
|
935 |
+
};
|
936 |
+
f.getTabs = function () {
|
937 |
+
var x;
|
938 |
+
f.tabs = q.find(r.tabs), f.panels = a(), f.tabs.each(function () {
|
939 |
+
var A = a(this), z = A.children("a"), y = A.children("a").data("target");
|
940 |
+
A.data("easytabs", {});
|
941 |
+
if (y !== undefined && y !== null) {
|
942 |
+
A.data("easytabs").ajax = z.attr("href")
|
943 |
+
} else {
|
944 |
+
y = z.attr("href")
|
945 |
+
}
|
946 |
+
y = y.match(/#([^\?]+)/)[1];
|
947 |
+
x = r.panelContext.find("#" + y);
|
948 |
+
if (x.length) {
|
949 |
+
x.data("easytabs", {position: x.css("position"), visibility: x.css("visibility")});
|
950 |
+
x.not(r.panelActiveClass).hide();
|
951 |
+
f.panels = f.panels.add(x);
|
952 |
+
A.data("easytabs").panel = x
|
953 |
+
} else {
|
954 |
+
f.tabs = f.tabs.not(A);
|
955 |
+
if ("console" in window) {
|
956 |
+
console.warn("Warning: tab without matching panel for selector '#" + y + "' removed from set")
|
957 |
+
}
|
958 |
+
}
|
959 |
+
})
|
960 |
+
};
|
961 |
+
f.selectTab = function (x, C) {
|
962 |
+
var y = window.location, B = y.hash.match(/^[^\?]*/)[0], z = x.parent().data("easytabs").panel, A = x.parent().data("easytabs").ajax;
|
963 |
+
if (r.collapsible && !d && (x.hasClass(r.tabActiveClass) || x.hasClass(r.collapsedClass))) {
|
964 |
+
f.toggleTabCollapse(x, z, A, C)
|
965 |
+
} else {
|
966 |
+
if (!x.hasClass(r.tabActiveClass) || !z.hasClass(r.panelActiveClass)) {
|
967 |
+
o(x, z, A, C)
|
968 |
+
} else {
|
969 |
+
if (!r.cache) {
|
970 |
+
o(x, z, A, C)
|
971 |
+
}
|
972 |
+
}
|
973 |
+
}
|
974 |
+
};
|
975 |
+
f.toggleTabCollapse = function (x, y, z, A) {
|
976 |
+
f.panels.stop(true, true);
|
977 |
+
if (u(q, "easytabs:before", [x, y, r])) {
|
978 |
+
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
979 |
+
if (x.hasClass(r.collapsedClass)) {
|
980 |
+
if (z && (!r.cache || !x.parent().data("easytabs").cached)) {
|
981 |
+
q.trigger("easytabs:ajax:beforeSend", [x, y]);
|
982 |
+
y.load(z, function (C, B, D) {
|
983 |
+
x.parent().data("easytabs").cached = true;
|
984 |
+
q.trigger("easytabs:ajax:complete", [x, y, C, B, D])
|
985 |
+
})
|
986 |
+
}
|
987 |
+
x.parent().removeClass(r.collapsedClass).addClass(r.tabActiveClass).children().removeClass(r.collapsedClass).addClass(r.tabActiveClass);
|
988 |
+
y.addClass(r.panelActiveClass)[v.uncollapse](v.speed, r.transitionUncollapseEasing, function () {
|
989 |
+
q.trigger("easytabs:midTransition", [x, y, r]);
|
990 |
+
if (typeof A == "function") {
|
991 |
+
A()
|
992 |
+
}
|
993 |
+
})
|
994 |
+
} else {
|
995 |
+
x.addClass(r.collapsedClass).parent().addClass(r.collapsedClass);
|
996 |
+
y.removeClass(r.panelActiveClass)[v.collapse](v.speed, r.transitionCollapseEasing, function () {
|
997 |
+
q.trigger("easytabs:midTransition", [x, y, r]);
|
998 |
+
if (typeof A == "function") {
|
999 |
+
A()
|
1000 |
+
}
|
1001 |
+
})
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
};
|
1005 |
+
f.matchTab = function (x) {
|
1006 |
+
return f.tabs.find("[href='" + x + "'],[data-target='" + x + "']").first()
|
1007 |
+
};
|
1008 |
+
f.matchInPanel = function (x) {
|
1009 |
+
return(x && f.validId(x) ? f.panels.filter(":has(" + x + ")").first() : [])
|
1010 |
+
};
|
1011 |
+
f.validId = function (x) {
|
1012 |
+
return x.substr(1).match(/^[A-Za-z]+[A-Za-z0-9\-_:\.].$/)
|
1013 |
+
};
|
1014 |
+
f.selectTabFromHashChange = function () {
|
1015 |
+
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y), z;
|
1016 |
+
if (r.updateHash) {
|
1017 |
+
if (x.length) {
|
1018 |
+
d = true;
|
1019 |
+
f.selectTab(x)
|
1020 |
+
} else {
|
1021 |
+
z = f.matchInPanel(y);
|
1022 |
+
if (z.length) {
|
1023 |
+
y = "#" + z.attr("id");
|
1024 |
+
x = f.matchTab(y);
|
1025 |
+
d = true;
|
1026 |
+
f.selectTab(x)
|
1027 |
+
} else {
|
1028 |
+
if (!h.hasClass(r.tabActiveClass) && !r.cycle) {
|
1029 |
+
if (y === "" || f.matchTab(m).length || q.closest(y).length) {
|
1030 |
+
d = true;
|
1031 |
+
f.selectTab(l)
|
1032 |
+
}
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
+
}
|
1036 |
+
}
|
1037 |
+
};
|
1038 |
+
f.cycleTabs = function (x) {
|
1039 |
+
if (r.cycle) {
|
1040 |
+
x = x % f.tabs.length;
|
1041 |
+
$tab = a(f.tabs[x]).children("a").first();
|
1042 |
+
d = true;
|
1043 |
+
f.selectTab($tab, function () {
|
1044 |
+
setTimeout(function () {
|
1045 |
+
f.cycleTabs(x + 1)
|
1046 |
+
}, r.cycle)
|
1047 |
+
})
|
1048 |
+
}
|
1049 |
+
};
|
1050 |
+
f.publicMethods = {select: function (x) {
|
1051 |
+
var y;
|
1052 |
+
if ((y = f.tabs.filter(x)).length === 0) {
|
1053 |
+
if ((y = f.tabs.find("a[href='" + x + "']")).length === 0) {
|
1054 |
+
if ((y = f.tabs.find("a" + x)).length === 0) {
|
1055 |
+
if ((y = f.tabs.find("[data-target='" + x + "']")).length === 0) {
|
1056 |
+
if ((y = f.tabs.find("a[href$='" + x + "']")).length === 0) {
|
1057 |
+
a.error("Tab '" + x + "' does not exist in tab set")
|
1058 |
+
}
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
}
|
1062 |
+
} else {
|
1063 |
+
y = y.children("a").first()
|
1064 |
+
}
|
1065 |
+
f.selectTab(y)
|
1066 |
+
}};
|
1067 |
+
var u = function (A, x, z) {
|
1068 |
+
var y = a.Event(x);
|
1069 |
+
A.trigger(y, z);
|
1070 |
+
return y.result !== false
|
1071 |
+
};
|
1072 |
+
var b = function () {
|
1073 |
+
q.addClass(r.containerClass);
|
1074 |
+
f.tabs.parent().addClass(r.tabsClass);
|
1075 |
+
f.tabs.addClass(r.tabClass);
|
1076 |
+
f.panels.addClass(r.panelClass)
|
1077 |
+
};
|
1078 |
+
var g = function () {
|
1079 |
+
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y).parent(), z;
|
1080 |
+
if (x.length === 1) {
|
1081 |
+
h = x;
|
1082 |
+
r.cycle = false
|
1083 |
+
} else {
|
1084 |
+
z = f.matchInPanel(y);
|
1085 |
+
if (z.length) {
|
1086 |
+
y = "#" + z.attr("id");
|
1087 |
+
h = f.matchTab(y).parent()
|
1088 |
+
} else {
|
1089 |
+
h = f.tabs.parent().find(r.defaultTab);
|
1090 |
+
if (h.length === 0) {
|
1091 |
+
a.error("The specified default tab ('" + r.defaultTab + "') could not be found in the tab set ('" + r.tabs + "') out of " + f.tabs.length + " tabs.")
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
l = h.children("a").first();
|
1096 |
+
p(x)
|
1097 |
+
};
|
1098 |
+
var p = function (z) {
|
1099 |
+
var y, x;
|
1100 |
+
if (r.collapsible && z.length === 0 && r.collapsedByDefault) {
|
1101 |
+
h.addClass(r.collapsedClass).children().addClass(r.collapsedClass)
|
1102 |
+
} else {
|
1103 |
+
y = a(h.data("easytabs").panel);
|
1104 |
+
x = h.data("easytabs").ajax;
|
1105 |
+
if (x && (!r.cache || !h.data("easytabs").cached)) {
|
1106 |
+
q.trigger("easytabs:ajax:beforeSend", [l, y]);
|
1107 |
+
y.load(x, function (B, A, C) {
|
1108 |
+
h.data("easytabs").cached = true;
|
1109 |
+
q.trigger("easytabs:ajax:complete", [l, y, B, A, C])
|
1110 |
+
})
|
1111 |
+
}
|
1112 |
+
h.data("easytabs").panel.show().addClass(r.panelActiveClass);
|
1113 |
+
h.addClass(r.tabActiveClass).children().addClass(r.tabActiveClass)
|
1114 |
+
}
|
1115 |
+
q.trigger("easytabs:initialised", [l, y])
|
1116 |
+
};
|
1117 |
+
var w = function () {
|
1118 |
+
f.tabs.children("a").bind(r.bind_str, function (x) {
|
1119 |
+
r.cycle = false;
|
1120 |
+
d = false;
|
1121 |
+
f.selectTab(a(this));
|
1122 |
+
x.preventDefault ? x.preventDefault() : x.returnValue = false
|
1123 |
+
})
|
1124 |
+
};
|
1125 |
+
var o = function (z, D, E, H) {
|
1126 |
+
f.panels.stop(true, true);
|
1127 |
+
if (u(q, "easytabs:before", [z, D, r])) {
|
1128 |
+
var A = f.panels.filter(":visible"), y = D.parent(), F, x, C, G, B = window.location.hash.match(/^[^\?]*/)[0];
|
1129 |
+
if (r.animate) {
|
1130 |
+
F = s(D);
|
1131 |
+
x = A.length ? k(A) : 0;
|
1132 |
+
C = F - x
|
1133 |
+
}
|
1134 |
+
m = B;
|
1135 |
+
G = function () {
|
1136 |
+
q.trigger("easytabs:midTransition", [z, D, r]);
|
1137 |
+
if (r.animate && r.transitionIn == "fadeIn") {
|
1138 |
+
if (C < 0) {
|
1139 |
+
y.animate({height: y.height() + C}, v.halfSpeed).css({"min-height": ""})
|
1140 |
+
}
|
1141 |
+
}
|
1142 |
+
if (r.updateHash && !d) {
|
1143 |
+
window.location.hash = "#" + D.attr("id")
|
1144 |
+
} else {
|
1145 |
+
d = false
|
1146 |
+
}
|
1147 |
+
D[v.show](v.speed, r.transitionInEasing, function () {
|
1148 |
+
y.css({height: "", "min-height": ""});
|
1149 |
+
q.trigger("easytabs:after", [z, D, r]);
|
1150 |
+
if (typeof H == "function") {
|
1151 |
+
H()
|
1152 |
+
}
|
1153 |
+
})
|
1154 |
+
};
|
1155 |
+
if (E && (!r.cache || !z.parent().data("easytabs").cached)) {
|
1156 |
+
q.trigger("easytabs:ajax:beforeSend", [z, D]);
|
1157 |
+
D.load(E, function (J, I, K) {
|
1158 |
+
z.parent().data("easytabs").cached = true;
|
1159 |
+
q.trigger("easytabs:ajax:complete", [z, D, J, I, K])
|
1160 |
+
})
|
1161 |
+
}
|
1162 |
+
if (r.animate && r.transitionOut == "fadeOut") {
|
1163 |
+
if (C > 0) {
|
1164 |
+
y.animate({height: (y.height() + C)}, v.halfSpeed)
|
1165 |
+
} else {
|
1166 |
+
y.css({"min-height": y.height()})
|
1167 |
+
}
|
1168 |
+
}
|
1169 |
+
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
1170 |
+
f.tabs.filter("." + r.collapsedClass).removeClass(r.collapsedClass).children().removeClass(r.collapsedClass);
|
1171 |
+
z.parent().addClass(r.tabActiveClass).children().addClass(r.tabActiveClass);
|
1172 |
+
f.panels.filter("." + r.panelActiveClass).removeClass(r.panelActiveClass);
|
1173 |
+
D.addClass(r.panelActiveClass);
|
1174 |
+
if (A.length) {
|
1175 |
+
A[v.hide](v.speed, r.transitionOutEasing, G)
|
1176 |
+
} else {
|
1177 |
+
D[v.uncollapse](v.speed, r.transitionUncollapseEasing, G)
|
1178 |
+
}
|
1179 |
+
}
|
1180 |
+
};
|
1181 |
+
var s = function (z) {
|
1182 |
+
if (z.data("easytabs") && z.data("easytabs").lastHeight) {
|
1183 |
+
return z.data("easytabs").lastHeight
|
1184 |
+
}
|
1185 |
+
var B = z.css("display"), y, x;
|
1186 |
+
try {
|
1187 |
+
y = a("<div></div>", {position: "absolute", visibility: "hidden", overflow: "hidden"})
|
1188 |
+
} catch (A) {
|
1189 |
+
y = a("<div></div>", {visibility: "hidden", overflow: "hidden"})
|
1190 |
+
}
|
1191 |
+
x = z.wrap(y).css({position: "relative", visibility: "hidden", display: "block"}).outerHeight();
|
1192 |
+
z.unwrap();
|
1193 |
+
z.css({position: z.data("easytabs").position, visibility: z.data("easytabs").visibility, display: B});
|
1194 |
+
z.data("easytabs").lastHeight = x;
|
1195 |
+
return x
|
1196 |
+
};
|
1197 |
+
var k = function (y) {
|
1198 |
+
var x = y.outerHeight();
|
1199 |
+
if (y.data("easytabs")) {
|
1200 |
+
y.data("easytabs").lastHeight = x
|
1201 |
+
} else {
|
1202 |
+
y.data("easytabs", {lastHeight: x})
|
1203 |
+
}
|
1204 |
+
return x
|
1205 |
+
};
|
1206 |
+
var n = function () {
|
1207 |
+
if (typeof a(window).hashchange === "function") {
|
1208 |
+
a(window).hashchange(function () {
|
1209 |
+
f.selectTabFromHashChange()
|
1210 |
+
})
|
1211 |
+
} else {
|
1212 |
+
if (a.address && typeof a.address.change === "function") {
|
1213 |
+
a.address.change(function () {
|
1214 |
+
f.selectTabFromHashChange()
|
1215 |
+
})
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
};
|
1219 |
+
var c = function () {
|
1220 |
+
var x;
|
1221 |
+
if (r.cycle) {
|
1222 |
+
x = f.tabs.index(h);
|
1223 |
+
setTimeout(function () {
|
1224 |
+
f.cycleTabs(x + 1)
|
1225 |
+
}, r.cycle)
|
1226 |
+
}
|
1227 |
+
};
|
1228 |
+
f.init()
|
1229 |
+
};
|
1230 |
+
a.fn.easytabs = function (c) {
|
1231 |
+
var b = arguments;
|
1232 |
+
return this.each(function () {
|
1233 |
+
var e = a(this), d = e.data("easytabs");
|
1234 |
+
if (undefined === d) {
|
1235 |
+
d = new a.easytabs(this, c);
|
1236 |
+
e.data("easytabs", d)
|
1237 |
+
}
|
1238 |
+
if (d.publicMethods[c]) {
|
1239 |
+
return d.publicMethods[c](Array.prototype.slice.call(b, 1))
|
1240 |
+
}
|
1241 |
+
})
|
1242 |
+
}
|
1243 |
+
})(jQuery);
|
1244 |
+
|
1245 |
+
|
1246 |
+
/*
|
1247 |
+
colpick Color Picker
|
1248 |
+
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
|
1249 |
+
|
1250 |
+
For usage and examples: colpick.com/plugin
|
1251 |
+
*/
|
1252 |
+
|
1253 |
+
(function ($) {
|
1254 |
+
var colpick = function () {
|
1255 |
+
var
|
1256 |
+
tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
|
1257 |
+
defaults = {
|
1258 |
+
showEvent: 'click',
|
1259 |
+
onShow: function () {
|
1260 |
+
},
|
1261 |
+
onBeforeShow: function () {
|
1262 |
+
},
|
1263 |
+
onHide: function () {
|
1264 |
+
},
|
1265 |
+
onChange: function () {
|
1266 |
+
},
|
1267 |
+
onSubmit: function () {
|
1268 |
+
},
|
1269 |
+
colorScheme: 'light',
|
1270 |
+
color: '3289c7',
|
1271 |
+
livePreview: true,
|
1272 |
+
flat: false,
|
1273 |
+
layout: 'full',
|
1274 |
+
submit: 1,
|
1275 |
+
submitText: 'OK',
|
1276 |
+
height: 156
|
1277 |
+
},
|
1278 |
+
//Fill the inputs of the plugin
|
1279 |
+
fillRGBFields = function (hsb, cal) {
|
1280 |
+
var rgb = hsbToRgb(hsb);
|
1281 |
+
$(cal).data('colpick').fields
|
1282 |
+
.eq(1).val(rgb.r).end()
|
1283 |
+
.eq(2).val(rgb.g).end()
|
1284 |
+
.eq(3).val(rgb.b).end();
|
1285 |
+
},
|
1286 |
+
fillHSBFields = function (hsb, cal) {
|
1287 |
+
$(cal).data('colpick').fields
|
1288 |
+
.eq(4).val(Math.round(hsb.h)).end()
|
1289 |
+
.eq(5).val(Math.round(hsb.s)).end()
|
1290 |
+
.eq(6).val(Math.round(hsb.b)).end();
|
1291 |
+
},
|
1292 |
+
fillHexFields = function (hsb, cal) {
|
1293 |
+
$(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
|
1294 |
+
},
|
1295 |
+
//Set the round selector position
|
1296 |
+
setSelector = function (hsb, cal) {
|
1297 |
+
$(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
|
1298 |
+
$(cal).data('colpick').selectorIndic.css({
|
1299 |
+
left: parseInt($(cal).data('colpick').height * hsb.s / 100, 10),
|
1300 |
+
top: parseInt($(cal).data('colpick').height * (100 - hsb.b) / 100, 10)
|
1301 |
+
});
|
1302 |
+
},
|
1303 |
+
//Set the hue selector position
|
1304 |
+
setHue = function (hsb, cal) {
|
1305 |
+
$(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
|
1306 |
+
},
|
1307 |
+
//Set current and new colors
|
1308 |
+
setCurrentColor = function (hsb, cal) {
|
1309 |
+
$(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1310 |
+
},
|
1311 |
+
setNewColor = function (hsb, cal) {
|
1312 |
+
$(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1313 |
+
},
|
1314 |
+
//Called when the new color is changed
|
1315 |
+
change = function (ev) {
|
1316 |
+
var cal = $(this).parent().parent(), col;
|
1317 |
+
if (this.parentNode.className.indexOf('_hex') > 0) {
|
1318 |
+
cal.data('colpick').color = col = hexToHsb(fixHex(this.value));
|
1319 |
+
fillRGBFields(col, cal.get(0));
|
1320 |
+
fillHSBFields(col, cal.get(0));
|
1321 |
+
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
1322 |
+
cal.data('colpick').color = col = fixHSB({
|
1323 |
+
h: parseInt(cal.data('colpick').fields.eq(4).val(), 10),
|
1324 |
+
s: parseInt(cal.data('colpick').fields.eq(5).val(), 10),
|
1325 |
+
b: parseInt(cal.data('colpick').fields.eq(6).val(), 10)
|
1326 |
+
});
|
1327 |
+
fillRGBFields(col, cal.get(0));
|
1328 |
+
fillHexFields(col, cal.get(0));
|
1329 |
+
} else {
|
1330 |
+
cal.data('colpick').color = col = rgbToHsb(fixRGB({
|
1331 |
+
r: parseInt(cal.data('colpick').fields.eq(1).val(), 10),
|
1332 |
+
g: parseInt(cal.data('colpick').fields.eq(2).val(), 10),
|
1333 |
+
b: parseInt(cal.data('colpick').fields.eq(3).val(), 10)
|
1334 |
+
}));
|
1335 |
+
fillHexFields(col, cal.get(0));
|
1336 |
+
fillHSBFields(col, cal.get(0));
|
1337 |
+
}
|
1338 |
+
setSelector(col, cal.get(0));
|
1339 |
+
setHue(col, cal.get(0));
|
1340 |
+
setNewColor(col, cal.get(0));
|
1341 |
+
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
|
1342 |
+
},
|
1343 |
+
//Change style on blur and on focus of inputs
|
1344 |
+
blur = function (ev) {
|
1345 |
+
$(this).parent().removeClass('colpick_focus');
|
1346 |
+
},
|
1347 |
+
focus = function () {
|
1348 |
+
$(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
|
1349 |
+
$(this).parent().addClass('colpick_focus');
|
1350 |
+
},
|
1351 |
+
//Increment/decrement arrows functions
|
1352 |
+
downIncrement = function (ev) {
|
1353 |
+
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1354 |
+
var field = $(this).parent().find('input').focus();
|
1355 |
+
var current = {
|
1356 |
+
el: $(this).parent().addClass('colpick_slider'),
|
1357 |
+
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
1358 |
+
y: ev.pageY,
|
1359 |
+
field: field,
|
1360 |
+
val: parseInt(field.val(), 10),
|
1361 |
+
preview: $(this).parent().parent().data('colpick').livePreview
|
1362 |
+
};
|
1363 |
+
$(document).mouseup(current, upIncrement);
|
1364 |
+
$(document).mousemove(current, moveIncrement);
|
1365 |
+
},
|
1366 |
+
moveIncrement = function (ev) {
|
1367 |
+
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10))));
|
1368 |
+
if (ev.data.preview) {
|
1369 |
+
change.apply(ev.data.field.get(0), [true]);
|
1370 |
+
}
|
1371 |
+
return false;
|
1372 |
+
},
|
1373 |
+
upIncrement = function (ev) {
|
1374 |
+
change.apply(ev.data.field.get(0), [true]);
|
1375 |
+
ev.data.el.removeClass('colpick_slider').find('input').focus();
|
1376 |
+
$(document).off('mouseup', upIncrement);
|
1377 |
+
$(document).off('mousemove', moveIncrement);
|
1378 |
+
return false;
|
1379 |
+
},
|
1380 |
+
//Hue slider functions
|
1381 |
+
downHue = function (ev) {
|
1382 |
+
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1383 |
+
var current = {
|
1384 |
+
cal: $(this).parent(),
|
1385 |
+
y: $(this).offset().top
|
1386 |
+
};
|
1387 |
+
$(document).on('mouseup touchend', current, upHue);
|
1388 |
+
$(document).on('mousemove touchmove', current, moveHue);
|
1389 |
+
|
1390 |
+
var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1391 |
+
change.apply(
|
1392 |
+
current.cal.data('colpick')
|
1393 |
+
.fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height - (pageY - current.y)) / current.cal.data('colpick').height, 10))
|
1394 |
+
.get(0),
|
1395 |
+
[current.cal.data('colpick').livePreview]
|
1396 |
+
);
|
1397 |
+
return false;
|
1398 |
+
},
|
1399 |
+
moveHue = function (ev) {
|
1400 |
+
var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1401 |
+
change.apply(
|
1402 |
+
ev.data.cal.data('colpick')
|
1403 |
+
.fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) / ev.data.cal.data('colpick').height, 10))
|
1404 |
+
.get(0),
|
1405 |
+
[ev.data.preview]
|
1406 |
+
);
|
1407 |
+
return false;
|
1408 |
+
},
|
1409 |
+
upHue = function (ev) {
|
1410 |
+
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1411 |
+
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1412 |
+
$(document).off('mouseup touchend', upHue);
|
1413 |
+
$(document).off('mousemove touchmove', moveHue);
|
1414 |
+
return false;
|
1415 |
+
},
|
1416 |
+
//Color selector functions
|
1417 |
+
downSelector = function (ev) {
|
1418 |
+
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1419 |
+
var current = {
|
1420 |
+
cal: $(this).parent(),
|
1421 |
+
pos: $(this).offset()
|
1422 |
+
};
|
1423 |
+
current.preview = current.cal.data('colpick').livePreview;
|
1424 |
+
|
1425 |
+
$(document).on('mouseup touchend', current, upSelector);
|
1426 |
+
$(document).on('mousemove touchmove', current, moveSelector);
|
1427 |
+
|
1428 |
+
var payeX, pageY;
|
1429 |
+
if (ev.type == 'touchstart') {
|
1430 |
+
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1431 |
+
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1432 |
+
} else {
|
1433 |
+
pageX = ev.pageX;
|
1434 |
+
pageY = ev.pageY;
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
change.apply(
|
1438 |
+
current.cal.data('colpick').fields
|
1439 |
+
.eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) / current.cal.data('colpick').height, 10)).end()
|
1440 |
+
.eq(5).val(parseInt(100 * (pageX - current.pos.left) / current.cal.data('colpick').height, 10))
|
1441 |
+
.get(0),
|
1442 |
+
[current.preview]
|
1443 |
+
);
|
1444 |
+
return false;
|
1445 |
+
},
|
1446 |
+
moveSelector = function (ev) {
|
1447 |
+
var payeX, pageY;
|
1448 |
+
if (ev.type == 'touchmove') {
|
1449 |
+
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1450 |
+
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1451 |
+
} else {
|
1452 |
+
pageX = ev.pageX;
|
1453 |
+
pageY = ev.pageY;
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
change.apply(
|
1457 |
+
ev.data.cal.data('colpick').fields
|
1458 |
+
.eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) / ev.data.cal.data('colpick').height, 10)).end()
|
1459 |
+
.eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
|
1460 |
+
.get(0),
|
1461 |
+
[ev.data.preview]
|
1462 |
+
);
|
1463 |
+
return false;
|
1464 |
+
},
|
1465 |
+
upSelector = function (ev) {
|
1466 |
+
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1467 |
+
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1468 |
+
$(document).off('mouseup touchend', upSelector);
|
1469 |
+
$(document).off('mousemove touchmove', moveSelector);
|
1470 |
+
return false;
|
1471 |
+
},
|
1472 |
+
//Submit button
|
1473 |
+
clickSubmit = function (ev) {
|
1474 |
+
var cal = $(this).parent();
|
1475 |
+
var col = cal.data('colpick').color;
|
1476 |
+
cal.data('colpick').origColor = col;
|
1477 |
+
setCurrentColor(col, cal.get(0));
|
1478 |
+
cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
|
1479 |
+
},
|
1480 |
+
//Show/hide the color picker
|
1481 |
+
show = function (ev) {
|
1482 |
+
// Prevent the trigger of any direct parent
|
1483 |
+
ev.stopPropagation();
|
1484 |
+
var cal = $('#' + $(this).data('colpickId'));
|
1485 |
+
cal.data('colpick').onBeforeShow.apply(this, [cal.get(0)]);
|
1486 |
+
var pos = $(this).offset();
|
1487 |
+
var top = pos.top + this.offsetHeight;
|
1488 |
+
var left = pos.left;
|
1489 |
+
var viewPort = getViewport();
|
1490 |
+
var calW = cal.width();
|
1491 |
+
if (left + calW > viewPort.l + viewPort.w) {
|
1492 |
+
left -= calW;
|
1493 |
+
}
|
1494 |
+
cal.css({left: left + 'px', top: top + 'px'});
|
1495 |
+
if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
|
1496 |
+
cal.show();
|
1497 |
+
}
|
1498 |
+
//Hide when user clicks outside
|
1499 |
+
$('html').mousedown({cal: cal}, hide);
|
1500 |
+
cal.mousedown(function (ev) {
|
1501 |
+
ev.stopPropagation();
|
1502 |
+
})
|
1503 |
+
},
|
1504 |
+
hide = function (ev) {
|
1505 |
+
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
1506 |
+
ev.data.cal.hide();
|
1507 |
+
}
|
1508 |
+
$('html').off('mousedown', hide);
|
1509 |
+
},
|
1510 |
+
getViewport = function () {
|
1511 |
+
var m = document.compatMode == 'CSS1Compat';
|
1512 |
+
return {
|
1513 |
+
l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
1514 |
+
w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
|
1515 |
+
};
|
1516 |
+
},
|
1517 |
+
//Fix the values if the user enters a negative or high value
|
1518 |
+
fixHSB = function (hsb) {
|
1519 |
+
return {
|
1520 |
+
h: Math.min(360, Math.max(0, hsb.h)),
|
1521 |
+
s: Math.min(100, Math.max(0, hsb.s)),
|
1522 |
+
b: Math.min(100, Math.max(0, hsb.b))
|
1523 |
+
};
|
1524 |
+
},
|
1525 |
+
fixRGB = function (rgb) {
|
1526 |
+
return {
|
1527 |
+
r: Math.min(255, Math.max(0, rgb.r)),
|
1528 |
+
g: Math.min(255, Math.max(0, rgb.g)),
|
1529 |
+
b: Math.min(255, Math.max(0, rgb.b))
|
1530 |
+
};
|
1531 |
+
},
|
1532 |
+
fixHex = function (hex) {
|
1533 |
+
var len = 6 - hex.length;
|
1534 |
+
if (len > 0) {
|
1535 |
+
var o = [];
|
1536 |
+
for (var i = 0; i < len; i++) {
|
1537 |
+
o.push('0');
|
1538 |
+
}
|
1539 |
+
o.push(hex);
|
1540 |
+
hex = o.join('');
|
1541 |
+
}
|
1542 |
+
return hex;
|
1543 |
+
},
|
1544 |
+
restoreOriginal = function () {
|
1545 |
+
var cal = $(this).parent();
|
1546 |
+
var col = cal.data('colpick').origColor;
|
1547 |
+
cal.data('colpick').color = col;
|
1548 |
+
fillRGBFields(col, cal.get(0));
|
1549 |
+
fillHexFields(col, cal.get(0));
|
1550 |
+
fillHSBFields(col, cal.get(0));
|
1551 |
+
setSelector(col, cal.get(0));
|
1552 |
+
setHue(col, cal.get(0));
|
1553 |
+
setNewColor(col, cal.get(0));
|
1554 |
+
};
|
1555 |
+
return {
|
1556 |
+
init: function (opt) {
|
1557 |
+
opt = $.extend({}, defaults, opt || {});
|
1558 |
+
//Set color
|
1559 |
+
if (typeof opt.color == 'string') {
|
1560 |
+
opt.color = hexToHsb(opt.color);
|
1561 |
+
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
1562 |
+
opt.color = rgbToHsb(opt.color);
|
1563 |
+
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
1564 |
+
opt.color = fixHSB(opt.color);
|
1565 |
+
} else {
|
1566 |
+
return this;
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
//For each selected DOM element
|
1570 |
+
return this.each(function () {
|
1571 |
+
//If the element does not have an ID
|
1572 |
+
if (!$(this).data('colpickId')) {
|
1573 |
+
var options = $.extend({}, opt);
|
1574 |
+
options.origColor = opt.color;
|
1575 |
+
//Generate and assign a random ID
|
1576 |
+
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
1577 |
+
$(this).data('colpickId', id);
|
1578 |
+
//Set the tpl's ID and get the HTML
|
1579 |
+
var cal = $(tpl).attr('id', id);
|
1580 |
+
//Add class according to layout
|
1581 |
+
cal.addClass('colpick_' + options.layout + (options.submit ? '' : ' colpick_' + options.layout + '_ns'));
|
1582 |
+
//Add class if the color scheme is not default
|
1583 |
+
if (options.colorScheme != 'light') {
|
1584 |
+
cal.addClass('colpick_' + options.colorScheme);
|
1585 |
+
}
|
1586 |
+
//Setup submit button
|
1587 |
+
cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
|
1588 |
+
//Setup input fields
|
1589 |
+
options.fields = cal.find('input').change(change).blur(blur).focus(focus);
|
1590 |
+
cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
|
1591 |
+
//Setup hue selector
|
1592 |
+
options.selector = cal.find('div.colpick_color').on('mousedown touchstart', downSelector);
|
1593 |
+
options.selectorIndic = options.selector.find('div.colpick_selector_outer');
|
1594 |
+
//Store parts of the plugin
|
1595 |
+
options.el = this;
|
1596 |
+
options.hue = cal.find('div.colpick_hue_arrs');
|
1597 |
+
huebar = options.hue.parent();
|
1598 |
+
//Paint the hue bar
|
1599 |
+
var UA = navigator.userAgent.toLowerCase();
|
1600 |
+
var isIE = navigator.appName === 'Microsoft Internet Explorer';
|
1601 |
+
var IEver = isIE ? parseFloat(UA.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0;
|
1602 |
+
var ngIE = (isIE && IEver < 10);
|
1603 |
+
var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80', '#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
|
1604 |
+
if (ngIE) {
|
1605 |
+
var i, div;
|
1606 |
+
for (i = 0; i <= 11; i++) {
|
1607 |
+
div = $('<div></div>').attr('style', 'height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + '); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
|
1608 |
+
huebar.append(div);
|
1609 |
+
}
|
1610 |
+
} else {
|
1611 |
+
stopList = stops.join(',');
|
1612 |
+
huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList + '); background: -o-linear-gradient(top,' + stopList + '); background: -ms-linear-gradient(top,' + stopList + '); background:-moz-linear-gradient(top,' + stopList + '); -webkit-linear-gradient(top,' + stopList + '); background:linear-gradient(to bottom,' + stopList + '); ');
|
1613 |
+
}
|
1614 |
+
cal.find('div.colpick_hue').on('mousedown touchstart', downHue);
|
1615 |
+
options.newColor = cal.find('div.colpick_new_color');
|
1616 |
+
options.currentColor = cal.find('div.colpick_current_color');
|
1617 |
+
//Store options and fill with default color
|
1618 |
+
cal.data('colpick', options);
|
1619 |
+
fillRGBFields(options.color, cal.get(0));
|
1620 |
+
fillHSBFields(options.color, cal.get(0));
|
1621 |
+
fillHexFields(options.color, cal.get(0));
|
1622 |
+
setHue(options.color, cal.get(0));
|
1623 |
+
setSelector(options.color, cal.get(0));
|
1624 |
+
setCurrentColor(options.color, cal.get(0));
|
1625 |
+
setNewColor(options.color, cal.get(0));
|
1626 |
+
//Append to body if flat=false, else show in place
|
1627 |
+
if (options.flat) {
|
1628 |
+
cal.appendTo(this).show();
|
1629 |
+
cal.css({
|
1630 |
+
position: 'relative',
|
1631 |
+
display: 'block'
|
1632 |
+
});
|
1633 |
+
} else {
|
1634 |
+
cal.appendTo(document.body);
|
1635 |
+
$(this).on(options.showEvent, show);
|
1636 |
+
cal.css({
|
1637 |
+
position: 'absolute'
|
1638 |
+
});
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
});
|
1642 |
+
},
|
1643 |
+
//Shows the picker
|
1644 |
+
showPicker: function () {
|
1645 |
+
return this.each(function () {
|
1646 |
+
if ($(this).data('colpickId')) {
|
1647 |
+
show.apply(this);
|
1648 |
+
}
|
1649 |
+
});
|
1650 |
+
},
|
1651 |
+
//Hides the picker
|
1652 |
+
hidePicker: function () {
|
1653 |
+
return this.each(function () {
|
1654 |
+
if ($(this).data('colpickId')) {
|
1655 |
+
$('#' + $(this).data('colpickId')).hide();
|
1656 |
+
}
|
1657 |
+
});
|
1658 |
+
},
|
1659 |
+
//Sets a color as new and current (default)
|
1660 |
+
setColor: function (col, setCurrent) {
|
1661 |
+
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
1662 |
+
if (typeof col == 'string') {
|
1663 |
+
col = hexToHsb(col);
|
1664 |
+
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
1665 |
+
col = rgbToHsb(col);
|
1666 |
+
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
1667 |
+
col = fixHSB(col);
|
1668 |
+
} else {
|
1669 |
+
return this;
|
1670 |
+
}
|
1671 |
+
return this.each(function () {
|
1672 |
+
if ($(this).data('colpickId')) {
|
1673 |
+
var cal = $('#' + $(this).data('colpickId'));
|
1674 |
+
cal.data('colpick').color = col;
|
1675 |
+
cal.data('colpick').origColor = col;
|
1676 |
+
fillRGBFields(col, cal.get(0));
|
1677 |
+
fillHSBFields(col, cal.get(0));
|
1678 |
+
fillHexFields(col, cal.get(0));
|
1679 |
+
setHue(col, cal.get(0));
|
1680 |
+
setSelector(col, cal.get(0));
|
1681 |
+
|
1682 |
+
setNewColor(col, cal.get(0));
|
1683 |
+
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
|
1684 |
+
if (setCurrent) {
|
1685 |
+
setCurrentColor(col, cal.get(0));
|
1686 |
+
}
|
1687 |
+
}
|
1688 |
+
});
|
1689 |
+
}
|
1690 |
+
};
|
1691 |
+
}();
|
1692 |
+
//Color space convertions
|
1693 |
+
var hexToRgb = function (hex) {
|
1694 |
+
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
1695 |
+
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
1696 |
+
};
|
1697 |
+
var hexToHsb = function (hex) {
|
1698 |
+
return rgbToHsb(hexToRgb(hex));
|
1699 |
+
};
|
1700 |
+
var rgbToHsb = function (rgb) {
|
1701 |
+
var hsb = {h: 0, s: 0, b: 0};
|
1702 |
+
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
1703 |
+
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
1704 |
+
var delta = max - min;
|
1705 |
+
hsb.b = max;
|
1706 |
+
hsb.s = max != 0 ? 255 * delta / max : 0;
|
1707 |
+
if (hsb.s != 0) {
|
1708 |
+
if (rgb.r == max)
|
1709 |
+
hsb.h = (rgb.g - rgb.b) / delta;
|
1710 |
+
else if (rgb.g == max)
|
1711 |
+
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
1712 |
+
else
|
1713 |
+
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
1714 |
+
} else
|
1715 |
+
hsb.h = -1;
|
1716 |
+
hsb.h *= 60;
|
1717 |
+
if (hsb.h < 0)
|
1718 |
+
hsb.h += 360;
|
1719 |
+
hsb.s *= 100 / 255;
|
1720 |
+
hsb.b *= 100 / 255;
|
1721 |
+
return hsb;
|
1722 |
+
};
|
1723 |
+
var hsbToRgb = function (hsb) {
|
1724 |
+
var rgb = {};
|
1725 |
+
var h = hsb.h;
|
1726 |
+
var s = hsb.s * 255 / 100;
|
1727 |
+
var v = hsb.b * 255 / 100;
|
1728 |
+
if (s == 0) {
|
1729 |
+
rgb.r = rgb.g = rgb.b = v;
|
1730 |
+
} else {
|
1731 |
+
var t1 = v;
|
1732 |
+
var t2 = (255 - s) * v / 255;
|
1733 |
+
var t3 = (t1 - t2) * (h % 60) / 60;
|
1734 |
+
if (h == 360)
|
1735 |
+
h = 0;
|
1736 |
+
if (h < 60) {
|
1737 |
+
rgb.r = t1;
|
1738 |
+
rgb.b = t2;
|
1739 |
+
rgb.g = t2 + t3
|
1740 |
+
} else if (h < 120) {
|
1741 |
+
rgb.g = t1;
|
1742 |
+
rgb.b = t2;
|
1743 |
+
rgb.r = t1 - t3
|
1744 |
+
} else if (h < 180) {
|
1745 |
+
rgb.g = t1;
|
1746 |
+
rgb.r = t2;
|
1747 |
+
rgb.b = t2 + t3
|
1748 |
+
} else if (h < 240) {
|
1749 |
+
rgb.b = t1;
|
1750 |
+
rgb.r = t2;
|
1751 |
+
rgb.g = t1 - t3
|
1752 |
+
} else if (h < 300) {
|
1753 |
+
rgb.b = t1;
|
1754 |
+
rgb.g = t2;
|
1755 |
+
rgb.r = t2 + t3
|
1756 |
+
} else if (h < 360) {
|
1757 |
+
rgb.r = t1;
|
1758 |
+
rgb.g = t2;
|
1759 |
+
rgb.b = t1 - t3
|
1760 |
+
} else {
|
1761 |
+
rgb.r = 0;
|
1762 |
+
rgb.g = 0;
|
1763 |
+
rgb.b = 0
|
1764 |
+
}
|
1765 |
+
}
|
1766 |
+
return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
|
1767 |
+
};
|
1768 |
+
var rgbToHex = function (rgb) {
|
1769 |
+
var hex = [
|
1770 |
+
rgb.r.toString(16),
|
1771 |
+
rgb.g.toString(16),
|
1772 |
+
rgb.b.toString(16)
|
1773 |
+
];
|
1774 |
+
$.each(hex, function (nr, val) {
|
1775 |
+
if (val.length == 1) {
|
1776 |
+
hex[nr] = '0' + val;
|
1777 |
+
}
|
1778 |
+
});
|
1779 |
+
return hex.join('');
|
1780 |
+
};
|
1781 |
+
var hsbToHex = function (hsb) {
|
1782 |
+
return rgbToHex(hsbToRgb(hsb));
|
1783 |
+
};
|
1784 |
+
$.fn.extend({
|
1785 |
+
colpick: colpick.init,
|
1786 |
+
colpickHide: colpick.hidePicker,
|
1787 |
+
colpickShow: colpick.showPicker,
|
1788 |
+
colpickSetColor: colpick.setColor
|
1789 |
+
});
|
1790 |
+
$.extend({
|
1791 |
+
colpick: {
|
1792 |
+
rgbToHex: rgbToHex,
|
1793 |
+
rgbToHsb: rgbToHsb,
|
1794 |
+
hsbToHex: hsbToHex,
|
1795 |
+
hsbToRgb: hsbToRgb,
|
1796 |
+
hexToHsb: hexToHsb,
|
1797 |
+
hexToRgb: hexToRgb
|
1798 |
+
}
|
1799 |
+
});
|
1800 |
})(jQuery);
|
assets/js/quads-admin.min.js
CHANGED
@@ -1,1800 +1,1800 @@
|
|
1 |
-
var strict;
|
2 |
-
|
3 |
-
|
4 |
-
jQuery(document).ready(function ($) {
|
5 |
-
|
6 |
-
// show / hide helper description
|
7 |
-
$('.quads-tooltip').click(function (e) {
|
8 |
-
e.preventDefault();
|
9 |
-
var icon = $(this),
|
10 |
-
bubble = $(this).next();
|
11 |
-
|
12 |
-
// Close any that are already open
|
13 |
-
$('.quads-tooltip-message').not(bubble).hide();
|
14 |
-
|
15 |
-
var position = icon.position();
|
16 |
-
if (bubble.hasClass('bottom')) {
|
17 |
-
bubble.css({
|
18 |
-
'left': (position.left - bubble.width() / 2) + 'px',
|
19 |
-
'top': (position.top + icon.height() + 9) + 'px'
|
20 |
-
});
|
21 |
-
} else {
|
22 |
-
bubble.css({
|
23 |
-
'left': (position.left + icon.width() + 9) + 'px',
|
24 |
-
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
25 |
-
});
|
26 |
-
}
|
27 |
-
|
28 |
-
bubble.toggle();
|
29 |
-
e.stopPropagation();
|
30 |
-
});
|
31 |
-
|
32 |
-
$('body').click(function () {
|
33 |
-
$('.quads-tooltip-message').hide();
|
34 |
-
});
|
35 |
-
|
36 |
-
$('.quads-tooltip-message').click(function (e) {
|
37 |
-
e.stopPropagation();
|
38 |
-
});
|
39 |
-
|
40 |
-
|
41 |
-
// vi login process
|
42 |
-
$("#quads_vi_login_submit").click(function(e){
|
43 |
-
e.preventDefault();
|
44 |
-
username = $("#quads-vi-email").val();
|
45 |
-
password = $("#quads-vi-password").val();
|
46 |
-
|
47 |
-
var data = '{"email":"' + username + '", "password":"' + password + '"}';
|
48 |
-
|
49 |
-
$.ajax({
|
50 |
-
type: "POST",
|
51 |
-
//url: "https://dashboard-api-test.vidint.net/v1/api/authenticate",
|
52 |
-
url: quads.vi_login_url,
|
53 |
-
contentType: 'application/json',
|
54 |
-
data: data,
|
55 |
-
statusCode: {
|
56 |
-
502: function () {
|
57 |
-
$("#quads_add_err").html("502 Bad Gateway. Contact support[at]vi.ai");
|
58 |
-
console.log('502 Bad Gateway.');
|
59 |
-
return false;
|
60 |
-
},
|
61 |
-
500: function () {
|
62 |
-
$("#quads_add_err").html("500 Bad Gateway. Contact support[at]vi.ai");
|
63 |
-
console.log('500 Bad Gateway.');
|
64 |
-
return false;
|
65 |
-
}
|
66 |
-
},
|
67 |
-
success: function(response){
|
68 |
-
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
69 |
-
$("#quads_add_err").hide();
|
70 |
-
if (typeof response.data !== 'undefined') {
|
71 |
-
$("#quads_add_err").html("We are logging you in");
|
72 |
-
console.log('We are logging you in' + response);
|
73 |
-
saveViToken(response.data);
|
74 |
-
}
|
75 |
-
else {
|
76 |
-
$("#quads_add_err").html("No valid API response. Can not log you in. Contact support[at]vi.ai");
|
77 |
-
console.log('no valid api response' + response);
|
78 |
-
}
|
79 |
-
},
|
80 |
-
error: function(response){
|
81 |
-
// check if xhr.status is defined in $.ajax.statusCode
|
82 |
-
// if true, return false to stop this function
|
83 |
-
if (typeof this.statusCode[response.status] != 'undefined') {
|
84 |
-
return false;
|
85 |
-
}
|
86 |
-
|
87 |
-
var result = typeof response.responseText !== 'undefined' ? JSON.parse(response.responseText) : '';
|
88 |
-
$("#quads_add_err").html(result.error.message + ' ' + result.error.description);
|
89 |
-
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
90 |
-
$("#quads_add_err").show();
|
91 |
-
$("#quads_add_err").removeClass('quads-spinner');
|
92 |
-
console.log(result);
|
93 |
-
//exit;
|
94 |
-
},
|
95 |
-
beforeSend:function()
|
96 |
-
{
|
97 |
-
$("#quads_vi_loading").css('display', 'inline', 'important').css('visibility', 'visible');
|
98 |
-
$("#quads_add_err").show();
|
99 |
-
},
|
100 |
-
|
101 |
-
complete:function()
|
102 |
-
{
|
103 |
-
$("#quads_vi_loading").css('display', 'none', 'important').css('visibility', 'hidden');
|
104 |
-
}
|
105 |
-
|
106 |
-
});
|
107 |
-
return false;
|
108 |
-
});
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Save vi token
|
112 |
-
*/
|
113 |
-
function saveViToken(token){
|
114 |
-
var data = {
|
115 |
-
'action': 'quads_save_vi_token',
|
116 |
-
'token': token
|
117 |
-
};
|
118 |
-
$.ajax({
|
119 |
-
type: "POST",
|
120 |
-
url: ajaxurl,
|
121 |
-
dataType: "json",
|
122 |
-
data: data,
|
123 |
-
//contentType: 'application/json;charset=utf-8',
|
124 |
-
success: function(response){
|
125 |
-
//response = JSON.stringify(response);
|
126 |
-
console.log(response.status);
|
127 |
-
|
128 |
-
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
129 |
-
$("#quads_add_err").hide();
|
130 |
-
if (typeof response.status != 'undefined' && response.status == 'success') {
|
131 |
-
console.log('Success, login succesfull, token stored' + response);
|
132 |
-
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
133 |
-
return false;
|
134 |
-
}
|
135 |
-
else {
|
136 |
-
console.log("Can not store token");
|
137 |
-
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
138 |
-
return false;
|
139 |
-
}
|
140 |
-
},
|
141 |
-
beforeSend:function()
|
142 |
-
{
|
143 |
-
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
144 |
-
$("#quads_add_err").show();
|
145 |
-
},
|
146 |
-
complete:function()
|
147 |
-
{
|
148 |
-
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
149 |
-
$("#quads_add_err").hide();
|
150 |
-
}
|
151 |
-
|
152 |
-
});
|
153 |
-
}
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
// Remove several unused elements from vi page
|
159 |
-
if (document.location.href.indexOf('vi_header') > - 1) {
|
160 |
-
$('#quads-submit-button').hide();
|
161 |
-
$('#quads-validate').hide();
|
162 |
-
$('#quads-footer').hide();
|
163 |
-
} else {
|
164 |
-
$('#quads-submit-button').show();
|
165 |
-
$('#quads-validate').show();
|
166 |
-
$('#quads-footer').show();
|
167 |
-
}
|
168 |
-
$(window).bind('easytabs:after', function(){
|
169 |
-
if (document.location.href.indexOf('vi_header') > - 1) {
|
170 |
-
$('#quads-submit-button').hide();
|
171 |
-
$('#quads-validate').hide();
|
172 |
-
$('#quads-footer').hide();
|
173 |
-
} else {
|
174 |
-
|
175 |
-
$('#quads-submit-button').show();
|
176 |
-
$('#quads-validate').show();
|
177 |
-
$('#quads-footer').show();
|
178 |
-
}
|
179 |
-
});
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
// VI signup form
|
186 |
-
$('#quads-vi-signup').click(function(e){
|
187 |
-
e.preventDefault();
|
188 |
-
// scroll to top
|
189 |
-
$(window).scrollTop(0);
|
190 |
-
// hide save button
|
191 |
-
$('#quads-submit-button').hide();
|
192 |
-
$('#quads-vi-signup-fullscreen').fadeIn();
|
193 |
-
});
|
194 |
-
$('#quads-vi-close').click(function(e){
|
195 |
-
e.preventDefault();
|
196 |
-
$('#quads-vi-signup-fullscreen').fadeOut();
|
197 |
-
});
|
198 |
-
|
199 |
-
/**
|
200 |
-
* General Tab
|
201 |
-
*/
|
202 |
-
// Inactive select fields are greyed out
|
203 |
-
$('.quads-assign').each(function(e){
|
204 |
-
if (!$(this).prop('checked')){
|
205 |
-
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
206 |
-
}else {
|
207 |
-
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
208 |
-
}
|
209 |
-
});
|
210 |
-
|
211 |
-
$('.quads-assign').click(function(){
|
212 |
-
if (!$(this).prop('checked')){
|
213 |
-
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
214 |
-
} else {
|
215 |
-
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
216 |
-
}
|
217 |
-
});
|
218 |
-
|
219 |
-
/**
|
220 |
-
* AdSense Code Tab
|
221 |
-
*/
|
222 |
-
// Check if submit button is visible than stick it to the bottom of the page
|
223 |
-
$(window).scroll(function() {
|
224 |
-
|
225 |
-
var elem = '#quads_tab_container .submit';
|
226 |
-
|
227 |
-
if ($(elem).length < 1){
|
228 |
-
return;
|
229 |
-
}
|
230 |
-
|
231 |
-
var top_of_element = $(elem).offset().top;
|
232 |
-
var bottom_of_element = $(elem).offset().top + $(elem).outerHeight(false);
|
233 |
-
var bottom_of_screen = $(window).scrollTop() + $(window).height();
|
234 |
-
if (bottom_of_screen > top_of_element){
|
235 |
-
// The element is visible, do something
|
236 |
-
$('#quads-submit-button').css('position', 'relative').css('bottom', '20px');
|
237 |
-
} else {
|
238 |
-
// The element is NOT visible, do something else
|
239 |
-
$('#quads-submit-button').css('position', 'fixed').css('bottom', '20px');
|
240 |
-
}
|
241 |
-
});
|
242 |
-
|
243 |
-
// Activate chosen select boxes
|
244 |
-
// $(".quads-chosen-select").chosen({
|
245 |
-
// inherit_select_classes: true
|
246 |
-
// });
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
// Hid or show AMP code form on click on amp checkbox
|
251 |
-
$('.quads-activate-amp').click(function(){
|
252 |
-
var parent = $(this).parents('.quads-ad-toggle-container').attr('id');
|
253 |
-
if ($(this).attr('checked') === 'checked') {
|
254 |
-
$('#' + parent).find('.quads-amp-code').show();
|
255 |
-
} else {
|
256 |
-
$('#' + parent).find('.quads-amp-code').hide();
|
257 |
-
}
|
258 |
-
});
|
259 |
-
|
260 |
-
|
261 |
-
// Hide or show AMP code form on loading
|
262 |
-
$('.quads-ad-toggle-container').find('.quads-activate-amp').each(function (index, value) {
|
263 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
264 |
-
if ($(this).attr( 'checked') === 'checked' ) {
|
265 |
-
$('#' + parentContainerID).find('.quads-amp-code').show();
|
266 |
-
}else {
|
267 |
-
$('#' + parentContainerID).find('.quads-amp-code').hide();
|
268 |
-
}
|
269 |
-
});
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
/**
|
274 |
-
* Toggle Button | Open All Ads
|
275 |
-
*/
|
276 |
-
$('#quads-open-toggle').click(function(){
|
277 |
-
if ($('#quads-open-toggle').text() === 'Open All Ads' ){
|
278 |
-
$('.quads-ad-toggle-container').show();
|
279 |
-
$('#quads-open-toggle').html('Close Ads');
|
280 |
-
}else{
|
281 |
-
$('.quads-ad-toggle-container').hide();
|
282 |
-
$('#quads-open-toggle').html('Open All Ads');
|
283 |
-
}
|
284 |
-
});
|
285 |
-
|
286 |
-
// show / hide helper description
|
287 |
-
$('.quads-helper').click(function (e) {
|
288 |
-
e.preventDefault();
|
289 |
-
var icon = $(this),
|
290 |
-
bubble = $(this).next();
|
291 |
-
|
292 |
-
// Close any that are already open
|
293 |
-
$('.quads-message').not(bubble).hide();
|
294 |
-
|
295 |
-
var position = icon.position();
|
296 |
-
if (bubble.hasClass('bottom')) {
|
297 |
-
bubble.css({
|
298 |
-
'left': (position.left - bubble.width() / 2) + 'px',
|
299 |
-
'top': (position.top + icon.height() + 9) + 'px'
|
300 |
-
});
|
301 |
-
} else {
|
302 |
-
bubble.css({
|
303 |
-
'left': (position.left + icon.width() + 9) + 'px',
|
304 |
-
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
305 |
-
});
|
306 |
-
}
|
307 |
-
|
308 |
-
bubble.toggle();
|
309 |
-
e.stopPropagation();
|
310 |
-
});
|
311 |
-
$('.quads-general-helper').click(function (e) {
|
312 |
-
e.preventDefault();
|
313 |
-
var icon = $(this),
|
314 |
-
bubble = $(this).next();
|
315 |
-
|
316 |
-
// Close any that are already open
|
317 |
-
$('.quads-message').not(bubble).hide();
|
318 |
-
|
319 |
-
var position = icon.position();
|
320 |
-
if (bubble.hasClass('bottom')) {
|
321 |
-
bubble.css({
|
322 |
-
'left': (position.left - bubble.width() / 2) + 'px',
|
323 |
-
'top': (position.top + icon.height() + 9) + 'px'
|
324 |
-
});
|
325 |
-
} else {
|
326 |
-
bubble.css({
|
327 |
-
'left': (position.left + icon.width() + 9) + 'px',
|
328 |
-
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
329 |
-
});
|
330 |
-
}
|
331 |
-
|
332 |
-
bubble.toggle();
|
333 |
-
e.stopPropagation();
|
334 |
-
});
|
335 |
-
|
336 |
-
$('body').click(function () {
|
337 |
-
$('.quads-message').hide();
|
338 |
-
});
|
339 |
-
|
340 |
-
$('.quads-message').click(function (e) {
|
341 |
-
e.stopPropagation();
|
342 |
-
});
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Save settings via ajax
|
346 |
-
*/
|
347 |
-
|
348 |
-
jQuery('#quads_settings').submit(function() {
|
349 |
-
|
350 |
-
// Check if ad name has been changed and prepare new data for saving
|
351 |
-
$('.quads-toogle-title').each(function(){
|
352 |
-
$(this).children('input').val($(this).text());
|
353 |
-
});
|
354 |
-
|
355 |
-
|
356 |
-
// Check current url / settings page
|
357 |
-
var url = window.location.search;
|
358 |
-
var tab_imexport = url.search("page=quads-settings&tab=imexport");
|
359 |
-
var tab_licenses = url.search("page=quads-settings&tab=licenses");
|
360 |
-
|
361 |
-
jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
|
362 |
-
jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
|
363 |
-
jQuery(this).ajaxSubmit({
|
364 |
-
|
365 |
-
success: function(){
|
366 |
-
jQuery('#quads-save-result').html("<div id='quads-save-message' class='quads-success-modal'></div>");
|
367 |
-
jQuery('#quads-save-message').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/saved.gif"></p>').show();
|
368 |
-
quads_hide_success_message();
|
369 |
-
},
|
370 |
-
//,timeout: 0,
|
371 |
-
|
372 |
-
error: function(){
|
373 |
-
//Do not show alert on import/export tab
|
374 |
-
if ( tab_imexport === -1 && tab_licenses === -1 ){
|
375 |
-
alert ('Error: Can not save settings. Try again');
|
376 |
-
}
|
377 |
-
jQuery('#quads-save-result').hide('fast');
|
378 |
-
}
|
379 |
-
});
|
380 |
-
// Do not use ajax saving on import/export and licenses tab
|
381 |
-
if ( tab_imexport === -1 && tab_licenses ===-1 ){
|
382 |
-
return false;
|
383 |
-
}
|
384 |
-
});
|
385 |
-
|
386 |
-
function quads_hide_success_message(){
|
387 |
-
setTimeout("jQuery('#quads-save-message').hide()", 1000);
|
388 |
-
}
|
389 |
-
|
390 |
-
|
391 |
-
/**
|
392 |
-
* Paste AdSense Code form
|
393 |
-
*/
|
394 |
-
$(document).on('click', '#quads-paste-button', function () {
|
395 |
-
|
396 |
-
var content = $('#quads-adsense-form').val();
|
397 |
-
var parseResult = quadsParseAdSenseCode(content);
|
398 |
-
if (false !== parseResult) {
|
399 |
-
console.log(parseResult);
|
400 |
-
setDetailsFromAdCode(parseResult);
|
401 |
-
}else{
|
402 |
-
$('#quads-msg').html('Can not parse AdSense Code. Is the code valid?');
|
403 |
-
$('#quads-msg').show();
|
404 |
-
}
|
405 |
-
});
|
406 |
-
|
407 |
-
|
408 |
-
/**
|
409 |
-
* Populate AdSense Date Fields
|
410 |
-
*
|
411 |
-
* @param object adsense
|
412 |
-
* @param2 string id of the parent container
|
413 |
-
* @returns false
|
414 |
-
*/
|
415 |
-
function setDetailsFromAdCode(GoogleAd) {
|
416 |
-
|
417 |
-
var containerID = $('#quads-adsense-id').val();
|
418 |
-
|
419 |
-
var id = containerID.replace("quads-toggle", "");
|
420 |
-
|
421 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_slot\\]').val(GoogleAd.slotId);
|
422 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_client\\]').val(GoogleAd.pubId);
|
423 |
-
if ('normal' == GoogleAd.type) {
|
424 |
-
console.log($('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]'));
|
425 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('normal');
|
426 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val(GoogleAd.width);
|
427 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val(GoogleAd.height);
|
428 |
-
}
|
429 |
-
if ('responsive' == GoogleAd.type) {
|
430 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('responsive');
|
431 |
-
//$('#ad-resize-type').val('auto');
|
432 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val('');
|
433 |
-
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val('');
|
434 |
-
}
|
435 |
-
// Trigger the ad type select
|
436 |
-
$('.quads-select-Type').trigger('change');
|
437 |
-
// Hide the overlay
|
438 |
-
$('#quads-adsense-bg-div').hide();
|
439 |
-
// Ad code input form must not be empty!
|
440 |
-
if ($('#' + containerID).children('textarea').val().length === 0){
|
441 |
-
$('#' + containerID).children('textarea').val('adsense');
|
442 |
-
}
|
443 |
-
|
444 |
-
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Parse the adsense ad content
|
449 |
-
* @param {type} content
|
450 |
-
* @returns {quads-admin.min_L3.parseAdContent.GoogleAd|Boolean}
|
451 |
-
*/
|
452 |
-
function quadsParseAdSenseCode(content) {
|
453 |
-
|
454 |
-
var rawContent = ('undefined' != typeof (content)) ? content.trim() : '';
|
455 |
-
var GoogleAd = {};
|
456 |
-
var theContent = $('<div />').html(rawContent);
|
457 |
-
var asyncGoogleAd = theContent.find('ins');
|
458 |
-
//var syncGoogleAd = theContent.search('google_ad_client');
|
459 |
-
|
460 |
-
// Its a async adsense ad
|
461 |
-
if (asyncGoogleAd.length > 0) {
|
462 |
-
console.log('async ad');
|
463 |
-
|
464 |
-
// Ad Slot ID
|
465 |
-
GoogleAd.slotId = asyncGoogleAd.attr('data-ad-slot');
|
466 |
-
|
467 |
-
if ('undefined' != typeof (asyncGoogleAd.attr('data-ad-client'))) {
|
468 |
-
// Ad Publisher ID
|
469 |
-
GoogleAd.pubId = asyncGoogleAd.attr('data-ad-client').substr(3);
|
470 |
-
}
|
471 |
-
|
472 |
-
if (undefined !== GoogleAd.slotId && '' != GoogleAd.pubId) {
|
473 |
-
GoogleAd.display = asyncGoogleAd.css('display');
|
474 |
-
GoogleAd.format = asyncGoogleAd.attr('data-ad-format');
|
475 |
-
GoogleAd.style = asyncGoogleAd.attr('style');
|
476 |
-
|
477 |
-
if ('undefined' == typeof (GoogleAd.format) && -1 != GoogleAd.style.indexOf('width')) {
|
478 |
-
/* normal ad */
|
479 |
-
GoogleAd.type = 'normal';
|
480 |
-
GoogleAd.width = asyncGoogleAd.css('width').replace('px', '');
|
481 |
-
GoogleAd.height = asyncGoogleAd.css('height').replace('px', '');
|
482 |
-
return GoogleAd;
|
483 |
-
}
|
484 |
-
|
485 |
-
if ('undefined' != typeof (GoogleAd.format) && 'auto' == GoogleAd.format) {
|
486 |
-
/* Responsive ad, auto resize */
|
487 |
-
GoogleAd.type = 'responsive';
|
488 |
-
return GoogleAd;
|
489 |
-
}
|
490 |
-
return GoogleAd;
|
491 |
-
}
|
492 |
-
|
493 |
-
return false;
|
494 |
-
}
|
495 |
-
|
496 |
-
// Google syncronous ad
|
497 |
-
if (rawContent.search('google_ad_client') > 0) {
|
498 |
-
console.log('syncronous code');
|
499 |
-
|
500 |
-
// Ad Slot ID
|
501 |
-
GoogleAd.slotId = get_google_ad_slot(content);
|
502 |
-
|
503 |
-
console.log(get_google_ad_slot(content));
|
504 |
-
console.log(get_google_ad_client(content));
|
505 |
-
console.log(get_google_ad_height(content));
|
506 |
-
console.log(get_google_ad_width(content));
|
507 |
-
|
508 |
-
if (!quadsIsEmpty(get_google_ad_client(content))) {
|
509 |
-
// Ad Publisher ID
|
510 |
-
GoogleAd.pubId = 'ca-pub-' + get_google_ad_client(content);
|
511 |
-
}else{
|
512 |
-
return false;
|
513 |
-
}
|
514 |
-
|
515 |
-
if (!quadsIsEmpty(GoogleAd.slotId) && !quadsIsEmpty(GoogleAd.pubId)) {
|
516 |
-
|
517 |
-
if (!quadsIsEmpty(get_google_ad_width(content))) {
|
518 |
-
GoogleAd.type = 'normal';
|
519 |
-
GoogleAd.width = get_google_ad_width(content);
|
520 |
-
GoogleAd.height = get_google_ad_height(content);
|
521 |
-
return GoogleAd;
|
522 |
-
}
|
523 |
-
}
|
524 |
-
return false;
|
525 |
-
}
|
526 |
-
|
527 |
-
return false;
|
528 |
-
}
|
529 |
-
|
530 |
-
function get_google_ad_slot(content) {
|
531 |
-
const regex = /google_ad_slot\s*=\s*"(\d*)";/g;
|
532 |
-
const str = content;
|
533 |
-
var m;
|
534 |
-
var result = {};
|
535 |
-
|
536 |
-
while ((m = regex.exec(str)) !== null) {
|
537 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
538 |
-
if (m.index === regex.lastIndex) {
|
539 |
-
regex.lastIndex++;
|
540 |
-
}
|
541 |
-
|
542 |
-
// The result can be accessed through the `m`-variable.
|
543 |
-
m.forEach(function(match, index){
|
544 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
545 |
-
console.log(match);
|
546 |
-
result = match;
|
547 |
-
});
|
548 |
-
}
|
549 |
-
return result;
|
550 |
-
}
|
551 |
-
function get_google_ad_client(content) {
|
552 |
-
const regex = /google_ad_client\s*=\s*"ca-pub-(\d*)";/g;
|
553 |
-
const str = content;
|
554 |
-
var m;
|
555 |
-
var result = {};
|
556 |
-
|
557 |
-
while ((m = regex.exec(str)) !== null) {
|
558 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
559 |
-
if (m.index === regex.lastIndex) {
|
560 |
-
regex.lastIndex++;
|
561 |
-
}
|
562 |
-
|
563 |
-
// The result can be accessed through the `m`-variable.
|
564 |
-
m.forEach(function(match, index){
|
565 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
566 |
-
console.log(match);
|
567 |
-
result = match;
|
568 |
-
});
|
569 |
-
}
|
570 |
-
return result;
|
571 |
-
}
|
572 |
-
function get_google_ad_width(content) {
|
573 |
-
const regex = /google_ad_width\s*=\s*(\d*);/g;
|
574 |
-
const str = content;
|
575 |
-
var m;
|
576 |
-
var result = {};
|
577 |
-
|
578 |
-
while ((m = regex.exec(str)) !== null) {
|
579 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
580 |
-
if (m.index === regex.lastIndex) {
|
581 |
-
regex.lastIndex++;
|
582 |
-
}
|
583 |
-
|
584 |
-
// The result can be accessed through the `m`-variable.
|
585 |
-
m.forEach(function(match, index){
|
586 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
587 |
-
console.log(match);
|
588 |
-
result = match;
|
589 |
-
});
|
590 |
-
}
|
591 |
-
return result;
|
592 |
-
}
|
593 |
-
function get_google_ad_height(content) {
|
594 |
-
const regex = /google_ad_height\s*=\s*(\d*);/g;
|
595 |
-
const str = content;
|
596 |
-
var m;
|
597 |
-
var result = {};
|
598 |
-
|
599 |
-
while ((m = regex.exec(str)) !== null) {
|
600 |
-
// This is necessary to avoid infinite loops with zero-width matches
|
601 |
-
if (m.index === regex.lastIndex) {
|
602 |
-
regex.lastIndex++;
|
603 |
-
}
|
604 |
-
|
605 |
-
// The result can be accessed through the `m`-variable.
|
606 |
-
m.forEach(function(match, index){
|
607 |
-
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
608 |
-
console.log(match);
|
609 |
-
result = match;
|
610 |
-
});
|
611 |
-
}
|
612 |
-
return result;
|
613 |
-
}
|
614 |
-
|
615 |
-
/**
|
616 |
-
* Check if return value is empty or not
|
617 |
-
* @param {type} str
|
618 |
-
* @returns {Boolean}
|
619 |
-
*/
|
620 |
-
function quadsIsEmpty(str) {
|
621 |
-
return (!str || 0 === str.length);
|
622 |
-
}
|
623 |
-
|
624 |
-
// AdSense Code Input Form
|
625 |
-
$(document).on('click', '.quads-add-adsense', function (e) {
|
626 |
-
e.preventDefault();
|
627 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
628 |
-
// Empty the ad plain text form
|
629 |
-
$('#quads-adsense-form').val('');
|
630 |
-
$('#quads-adsense-id').val(parentContainerID);
|
631 |
-
$('#quads-adsense-bg-div').show();
|
632 |
-
});
|
633 |
-
$(document).on('click', '#quads-close-button', function (e) {
|
634 |
-
e.preventDefault();
|
635 |
-
$('#quads-adsense-bg-div').hide();
|
636 |
-
});
|
637 |
-
|
638 |
-
|
639 |
-
// Toggle between AdSense or Plain Text option
|
640 |
-
$(document).on('click', '.quads_adsense_type', function () {
|
641 |
-
|
642 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
643 |
-
|
644 |
-
if ($(this).val() === 'adsense') {
|
645 |
-
$('#' + parentContainerID).children('textarea').hide();
|
646 |
-
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
647 |
-
$('#' + parentContainerID).find('.quads-sizes').show();
|
648 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
649 |
-
|
650 |
-
}
|
651 |
-
if ($(this).val() === 'plain_text') {
|
652 |
-
$('#' + parentContainerID).children('textarea').show();
|
653 |
-
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
654 |
-
$('#' + parentContainerID).find('.quads-sizes').hide();
|
655 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
656 |
-
}
|
657 |
-
});
|
658 |
-
|
659 |
-
|
660 |
-
// Hide or show AdSense elements on loading
|
661 |
-
$('.quads-ad-toggle-container').find('.quads_adsense_type').each(function (index, value) {
|
662 |
-
|
663 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
664 |
-
|
665 |
-
if ($(this).attr('checked') === 'checked' && $(this).val() === 'adsense') {
|
666 |
-
$('#' + parentContainerID).children('textarea').fadeOut();
|
667 |
-
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
668 |
-
}
|
669 |
-
if ($(this).attr('checked') === 'checked' && $(this).val() === 'plain_text') {
|
670 |
-
$('#' + parentContainerID).children('textarea').fadeIn();
|
671 |
-
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
672 |
-
}
|
673 |
-
});
|
674 |
-
|
675 |
-
|
676 |
-
// Hide or show AdSense width and height on loading
|
677 |
-
$('.quads-ad-toggle-container').find('.quads-select-Type').each(function (index, value) {
|
678 |
-
|
679 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
680 |
-
|
681 |
-
if ($(this).val() === 'responsive') {
|
682 |
-
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
683 |
-
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
684 |
-
$('#' + parentContainerID).find('.quads-sizes').show();
|
685 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
686 |
-
}
|
687 |
-
if ($(this).val() === 'normal') {
|
688 |
-
$('#' + parentContainerID).find('.quads-type-normal').show();
|
689 |
-
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
690 |
-
$('#' + parentContainerID).find('.quads-sizes').hide();
|
691 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
692 |
-
}
|
693 |
-
});
|
694 |
-
|
695 |
-
|
696 |
-
// Toggle between Fixed Size or Responsive ad type
|
697 |
-
$(document).on('change', '.quads-select-Type', function () {
|
698 |
-
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
699 |
-
|
700 |
-
if ($(this).val() === 'responsive') {
|
701 |
-
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
702 |
-
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
703 |
-
$('#' + parentContainerID).find('.quads-sizes').show();
|
704 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
705 |
-
}
|
706 |
-
if ($(this).val() === 'normal') {
|
707 |
-
$('#' + parentContainerID).find('.quads-type-normal').show();
|
708 |
-
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
709 |
-
$('#' + parentContainerID).find('.quads-sizes').hide();
|
710 |
-
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
711 |
-
}
|
712 |
-
});
|
713 |
-
|
714 |
-
//*[@id="quads-togglead1"]/div[2]
|
715 |
-
/**
|
716 |
-
* Toggle the adsense container
|
717 |
-
*/
|
718 |
-
//$('.quads-ad-toggle-header').click(function (e) {
|
719 |
-
$('.quads-form-table').on('click', '.quads-ad-toggle-header', function(e) {
|
720 |
-
e.preventDefault();
|
721 |
-
|
722 |
-
var container = $('#' + $(this).data('box-id'));
|
723 |
-
//console.log(container);
|
724 |
-
container.toggle(0, function () {
|
725 |
-
if (container.parents('.quads-ad-toggle-header').hasClass('quads-box-close')) {
|
726 |
-
// open the box
|
727 |
-
container.parents('.quads-ad-toggle-header').removeClass('quads-box-close');
|
728 |
-
} else {
|
729 |
-
container.parents('.quads-ad-toggle-header').addClass('quads-box-close');
|
730 |
-
}
|
731 |
-
});
|
732 |
-
});
|
733 |
-
|
734 |
-
/*
|
735 |
-
* Quick Adsense import process
|
736 |
-
*/
|
737 |
-
|
738 |
-
jQuery('.quads-import-settings').click(function (e) {
|
739 |
-
e.preventDefault();
|
740 |
-
|
741 |
-
if (!confirm('Importing settings from Quick AdSense will overwrite all your current settings. Are you sure?'))
|
742 |
-
return;
|
743 |
-
|
744 |
-
jQuery('#quads-import-settings').addClass('loading');
|
745 |
-
var data = {
|
746 |
-
action: 'quads_import_quick_adsense',
|
747 |
-
nonce: quads.nonce,
|
748 |
-
};
|
749 |
-
$.post(ajaxurl, data, function (resp, status, xhr) {
|
750 |
-
|
751 |
-
//console.log('success:' + resp + status + xhr);
|
752 |
-
quads_show_message(resp);
|
753 |
-
|
754 |
-
}).fail(function (xhr) { // Will be executed when $.post() fails
|
755 |
-
quads_show_message('Ajax Error: ' + xhr.status + ' ' + xhr.statusText);
|
756 |
-
//console.log('error: ' + xhr.statusText);
|
757 |
-
});
|
758 |
-
});
|
759 |
-
|
760 |
-
jQuery('#quads_insert_ads_action').click(function (e) {
|
761 |
-
e.preventDefault();
|
762 |
-
jQuery('#quads_insert_ads_box').toggle();
|
763 |
-
});
|
764 |
-
|
765 |
-
jQuery('#quads_disable_ads_action').click(function (e) {
|
766 |
-
e.preventDefault();
|
767 |
-
jQuery('#quads_disable_ads_box').toggle();
|
768 |
-
});
|
769 |
-
|
770 |
-
|
771 |
-
/**
|
772 |
-
* Show error message and die()
|
773 |
-
* Writes error message into log file
|
774 |
-
*
|
775 |
-
* @param {string} $error notice
|
776 |
-
* @returns void
|
777 |
-
*/
|
778 |
-
function quads_show_message(error) {
|
779 |
-
$('#quads-error-details').show();
|
780 |
-
$('#quads-error-details').html(error);
|
781 |
-
console.log(error);
|
782 |
-
}
|
783 |
-
|
784 |
-
|
785 |
-
/**
|
786 |
-
* Start easytabs()
|
787 |
-
*/
|
788 |
-
if ($(".quads-tabs").length) {
|
789 |
-
$('#quads_tab_container').easytabs({
|
790 |
-
animate: true,
|
791 |
-
updateHash: true,
|
792 |
-
animationSpeed: 'fast'
|
793 |
-
});
|
794 |
-
}
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
}); // document ready
|
800 |
-
|
801 |
-
/*
|
802 |
-
* jQuery hashchange event - v1.3 - 7/21/2010
|
803 |
-
* http://benalman.com/projects/jquery-hashchange-plugin/
|
804 |
-
*
|
805 |
-
* Copyright (c) 2010 "Cowboy" Ben Alman
|
806 |
-
* Dual licensed under the MIT and GPL licenses.
|
807 |
-
* http://benalman.com/about/license/
|
808 |
-
*/
|
809 |
-
(function ($, e, b) {
|
810 |
-
var c = "hashchange", h = document, f, g = $.event.special, i = h.documentMode, d = "on" + c in e && (i === b || i > 7);
|
811 |
-
function a(j) {
|
812 |
-
j = j || location.href;
|
813 |
-
return"#" + j.replace(/^[^#]*#?(.*)$/, "$1")
|
814 |
-
}
|
815 |
-
$.fn[c] = function (j) {
|
816 |
-
return j ? this.bind(c, j) : this.trigger(c)
|
817 |
-
};
|
818 |
-
$.fn[c].delay = 50;
|
819 |
-
g[c] = $.extend(g[c], {setup: function () {
|
820 |
-
if (d) {
|
821 |
-
return false
|
822 |
-
}
|
823 |
-
$(f.start)
|
824 |
-
}, teardown: function () {
|
825 |
-
if (d) {
|
826 |
-
return false
|
827 |
-
}
|
828 |
-
$(f.stop)
|
829 |
-
}});
|
830 |
-
f = (function () {
|
831 |
-
var j = {}, p, m = a(), k = function (q) {
|
832 |
-
return q
|
833 |
-
}, l = k, o = k;
|
834 |
-
j.start = function () {
|
835 |
-
p || n()
|
836 |
-
};
|
837 |
-
j.stop = function () {
|
838 |
-
p && clearTimeout(p);
|
839 |
-
p = b
|
840 |
-
};
|
841 |
-
function n() {
|
842 |
-
var r = a(), q = o(m);
|
843 |
-
if (r !== m) {
|
844 |
-
l(m = r, q);
|
845 |
-
$(e).trigger(c)
|
846 |
-
} else {
|
847 |
-
if (q !== m) {
|
848 |
-
location.href = location.href.replace(/#.*/, "") + q
|
849 |
-
}
|
850 |
-
}
|
851 |
-
p = setTimeout(n, $.fn[c].delay)
|
852 |
-
}
|
853 |
-
$.browser.msie && !d && (function () {
|
854 |
-
var q, r;
|
855 |
-
j.start = function () {
|
856 |
-
if (!q) {
|
857 |
-
r = $.fn[c].src;
|
858 |
-
r = r && r + a();
|
859 |
-
q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
|
860 |
-
r || l(a());
|
861 |
-
n()
|
862 |
-
}).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
|
863 |
-
h.onpropertychange = function () {
|
864 |
-
try {
|
865 |
-
if (event.propertyName === "title") {
|
866 |
-
q.document.title = h.title
|
867 |
-
}
|
868 |
-
} catch (s) {
|
869 |
-
}
|
870 |
-
}
|
871 |
-
}
|
872 |
-
};
|
873 |
-
j.stop = k;
|
874 |
-
o = function () {
|
875 |
-
return a(q.location.href)
|
876 |
-
};
|
877 |
-
l = function (v, s) {
|
878 |
-
var u = q.document, t = $.fn[c].domain;
|
879 |
-
if (v !== s) {
|
880 |
-
u.title = h.title;
|
881 |
-
u.open();
|
882 |
-
t && u.write('<script>document.domain="' + t + '"<\/script>');
|
883 |
-
u.close();
|
884 |
-
q.location.hash = v
|
885 |
-
}
|
886 |
-
}
|
887 |
-
})();
|
888 |
-
return j
|
889 |
-
})()
|
890 |
-
})(jQuery, this);
|
891 |
-
|
892 |
-
/*
|
893 |
-
* jQuery EasyTabs plugin 3.2.0
|
894 |
-
*
|
895 |
-
* Copyright (c) 2010-2011 Steve Schwartz (JangoSteve)
|
896 |
-
*
|
897 |
-
* Dual licensed under the MIT and GPL licenses:
|
898 |
-
* http://www.opensource.org/licenses/mit-license.php
|
899 |
-
* http://www.gnu.org/licenses/gpl.html
|
900 |
-
*
|
901 |
-
* Date: Thu May 09 17:30:00 2013 -0500
|
902 |
-
*/
|
903 |
-
(function (a) {
|
904 |
-
a.easytabs = function (j, e) {
|
905 |
-
var f = this, q = a(j), i = {animate: true, panelActiveClass: "active", tabActiveClass: "active", defaultTab: "li:first-child", animationSpeed: "fast", tabs: "> ul > li", updateHash: true, cycle: false, collapsible: false, collapsedClass: "collapsed", collapsedByDefault: true, uiTabs: false, transitionIn: "fadeIn", transitionOut: "fadeOut", transitionInEasing: "swing", transitionOutEasing: "swing", transitionCollapse: "slideUp", transitionUncollapse: "slideDown", transitionCollapseEasing: "swing", transitionUncollapseEasing: "swing", containerClass: "", tabsClass: "", tabClass: "", panelClass: "", cache: true, event: "click", panelContext: q}, h, l, v, m, d, t = {fast: 200, normal: 400, slow: 600}, r;
|
906 |
-
f.init = function () {
|
907 |
-
f.settings = r = a.extend({}, i, e);
|
908 |
-
r.bind_str = r.event + ".easytabs";
|
909 |
-
if (r.uiTabs) {
|
910 |
-
r.tabActiveClass = "ui-tabs-selected";
|
911 |
-
r.containerClass = "ui-tabs ui-widget ui-widget-content ui-corner-all";
|
912 |
-
r.tabsClass = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all";
|
913 |
-
r.tabClass = "ui-state-default ui-corner-top";
|
914 |
-
r.panelClass = "ui-tabs-panel ui-widget-content ui-corner-bottom"
|
915 |
-
}
|
916 |
-
if (r.collapsible && e.defaultTab !== undefined && e.collpasedByDefault === undefined) {
|
917 |
-
r.collapsedByDefault = false
|
918 |
-
}
|
919 |
-
if (typeof (r.animationSpeed) === "string") {
|
920 |
-
r.animationSpeed = t[r.animationSpeed]
|
921 |
-
}
|
922 |
-
a("a.anchor").remove().prependTo("body");
|
923 |
-
q.data("easytabs", {});
|
924 |
-
f.setTransitions();
|
925 |
-
f.getTabs();
|
926 |
-
b();
|
927 |
-
g();
|
928 |
-
w();
|
929 |
-
n();
|
930 |
-
c();
|
931 |
-
q.attr("data-easytabs", true)
|
932 |
-
};
|
933 |
-
f.setTransitions = function () {
|
934 |
-
v = (r.animate) ? {show: r.transitionIn, hide: r.transitionOut, speed: r.animationSpeed, collapse: r.transitionCollapse, uncollapse: r.transitionUncollapse, halfSpeed: r.animationSpeed / 2} : {show: "show", hide: "hide", speed: 0, collapse: "hide", uncollapse: "show", halfSpeed: 0}
|
935 |
-
};
|
936 |
-
f.getTabs = function () {
|
937 |
-
var x;
|
938 |
-
f.tabs = q.find(r.tabs), f.panels = a(), f.tabs.each(function () {
|
939 |
-
var A = a(this), z = A.children("a"), y = A.children("a").data("target");
|
940 |
-
A.data("easytabs", {});
|
941 |
-
if (y !== undefined && y !== null) {
|
942 |
-
A.data("easytabs").ajax = z.attr("href")
|
943 |
-
} else {
|
944 |
-
y = z.attr("href")
|
945 |
-
}
|
946 |
-
y = y.match(/#([^\?]+)/)[1];
|
947 |
-
x = r.panelContext.find("#" + y);
|
948 |
-
if (x.length) {
|
949 |
-
x.data("easytabs", {position: x.css("position"), visibility: x.css("visibility")});
|
950 |
-
x.not(r.panelActiveClass).hide();
|
951 |
-
f.panels = f.panels.add(x);
|
952 |
-
A.data("easytabs").panel = x
|
953 |
-
} else {
|
954 |
-
f.tabs = f.tabs.not(A);
|
955 |
-
if ("console" in window) {
|
956 |
-
console.warn("Warning: tab without matching panel for selector '#" + y + "' removed from set")
|
957 |
-
}
|
958 |
-
}
|
959 |
-
})
|
960 |
-
};
|
961 |
-
f.selectTab = function (x, C) {
|
962 |
-
var y = window.location, B = y.hash.match(/^[^\?]*/)[0], z = x.parent().data("easytabs").panel, A = x.parent().data("easytabs").ajax;
|
963 |
-
if (r.collapsible && !d && (x.hasClass(r.tabActiveClass) || x.hasClass(r.collapsedClass))) {
|
964 |
-
f.toggleTabCollapse(x, z, A, C)
|
965 |
-
} else {
|
966 |
-
if (!x.hasClass(r.tabActiveClass) || !z.hasClass(r.panelActiveClass)) {
|
967 |
-
o(x, z, A, C)
|
968 |
-
} else {
|
969 |
-
if (!r.cache) {
|
970 |
-
o(x, z, A, C)
|
971 |
-
}
|
972 |
-
}
|
973 |
-
}
|
974 |
-
};
|
975 |
-
f.toggleTabCollapse = function (x, y, z, A) {
|
976 |
-
f.panels.stop(true, true);
|
977 |
-
if (u(q, "easytabs:before", [x, y, r])) {
|
978 |
-
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
979 |
-
if (x.hasClass(r.collapsedClass)) {
|
980 |
-
if (z && (!r.cache || !x.parent().data("easytabs").cached)) {
|
981 |
-
q.trigger("easytabs:ajax:beforeSend", [x, y]);
|
982 |
-
y.load(z, function (C, B, D) {
|
983 |
-
x.parent().data("easytabs").cached = true;
|
984 |
-
q.trigger("easytabs:ajax:complete", [x, y, C, B, D])
|
985 |
-
})
|
986 |
-
}
|
987 |
-
x.parent().removeClass(r.collapsedClass).addClass(r.tabActiveClass).children().removeClass(r.collapsedClass).addClass(r.tabActiveClass);
|
988 |
-
y.addClass(r.panelActiveClass)[v.uncollapse](v.speed, r.transitionUncollapseEasing, function () {
|
989 |
-
q.trigger("easytabs:midTransition", [x, y, r]);
|
990 |
-
if (typeof A == "function") {
|
991 |
-
A()
|
992 |
-
}
|
993 |
-
})
|
994 |
-
} else {
|
995 |
-
x.addClass(r.collapsedClass).parent().addClass(r.collapsedClass);
|
996 |
-
y.removeClass(r.panelActiveClass)[v.collapse](v.speed, r.transitionCollapseEasing, function () {
|
997 |
-
q.trigger("easytabs:midTransition", [x, y, r]);
|
998 |
-
if (typeof A == "function") {
|
999 |
-
A()
|
1000 |
-
}
|
1001 |
-
})
|
1002 |
-
}
|
1003 |
-
}
|
1004 |
-
};
|
1005 |
-
f.matchTab = function (x) {
|
1006 |
-
return f.tabs.find("[href='" + x + "'],[data-target='" + x + "']").first()
|
1007 |
-
};
|
1008 |
-
f.matchInPanel = function (x) {
|
1009 |
-
return(x && f.validId(x) ? f.panels.filter(":has(" + x + ")").first() : [])
|
1010 |
-
};
|
1011 |
-
f.validId = function (x) {
|
1012 |
-
return x.substr(1).match(/^[A-Za-z]+[A-Za-z0-9\-_:\.].$/)
|
1013 |
-
};
|
1014 |
-
f.selectTabFromHashChange = function () {
|
1015 |
-
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y), z;
|
1016 |
-
if (r.updateHash) {
|
1017 |
-
if (x.length) {
|
1018 |
-
d = true;
|
1019 |
-
f.selectTab(x)
|
1020 |
-
} else {
|
1021 |
-
z = f.matchInPanel(y);
|
1022 |
-
if (z.length) {
|
1023 |
-
y = "#" + z.attr("id");
|
1024 |
-
x = f.matchTab(y);
|
1025 |
-
d = true;
|
1026 |
-
f.selectTab(x)
|
1027 |
-
} else {
|
1028 |
-
if (!h.hasClass(r.tabActiveClass) && !r.cycle) {
|
1029 |
-
if (y === "" || f.matchTab(m).length || q.closest(y).length) {
|
1030 |
-
d = true;
|
1031 |
-
f.selectTab(l)
|
1032 |
-
}
|
1033 |
-
}
|
1034 |
-
}
|
1035 |
-
}
|
1036 |
-
}
|
1037 |
-
};
|
1038 |
-
f.cycleTabs = function (x) {
|
1039 |
-
if (r.cycle) {
|
1040 |
-
x = x % f.tabs.length;
|
1041 |
-
$tab = a(f.tabs[x]).children("a").first();
|
1042 |
-
d = true;
|
1043 |
-
f.selectTab($tab, function () {
|
1044 |
-
setTimeout(function () {
|
1045 |
-
f.cycleTabs(x + 1)
|
1046 |
-
}, r.cycle)
|
1047 |
-
})
|
1048 |
-
}
|
1049 |
-
};
|
1050 |
-
f.publicMethods = {select: function (x) {
|
1051 |
-
var y;
|
1052 |
-
if ((y = f.tabs.filter(x)).length === 0) {
|
1053 |
-
if ((y = f.tabs.find("a[href='" + x + "']")).length === 0) {
|
1054 |
-
if ((y = f.tabs.find("a" + x)).length === 0) {
|
1055 |
-
if ((y = f.tabs.find("[data-target='" + x + "']")).length === 0) {
|
1056 |
-
if ((y = f.tabs.find("a[href$='" + x + "']")).length === 0) {
|
1057 |
-
a.error("Tab '" + x + "' does not exist in tab set")
|
1058 |
-
}
|
1059 |
-
}
|
1060 |
-
}
|
1061 |
-
}
|
1062 |
-
} else {
|
1063 |
-
y = y.children("a").first()
|
1064 |
-
}
|
1065 |
-
f.selectTab(y)
|
1066 |
-
}};
|
1067 |
-
var u = function (A, x, z) {
|
1068 |
-
var y = a.Event(x);
|
1069 |
-
A.trigger(y, z);
|
1070 |
-
return y.result !== false
|
1071 |
-
};
|
1072 |
-
var b = function () {
|
1073 |
-
q.addClass(r.containerClass);
|
1074 |
-
f.tabs.parent().addClass(r.tabsClass);
|
1075 |
-
f.tabs.addClass(r.tabClass);
|
1076 |
-
f.panels.addClass(r.panelClass)
|
1077 |
-
};
|
1078 |
-
var g = function () {
|
1079 |
-
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y).parent(), z;
|
1080 |
-
if (x.length === 1) {
|
1081 |
-
h = x;
|
1082 |
-
r.cycle = false
|
1083 |
-
} else {
|
1084 |
-
z = f.matchInPanel(y);
|
1085 |
-
if (z.length) {
|
1086 |
-
y = "#" + z.attr("id");
|
1087 |
-
h = f.matchTab(y).parent()
|
1088 |
-
} else {
|
1089 |
-
h = f.tabs.parent().find(r.defaultTab);
|
1090 |
-
if (h.length === 0) {
|
1091 |
-
a.error("The specified default tab ('" + r.defaultTab + "') could not be found in the tab set ('" + r.tabs + "') out of " + f.tabs.length + " tabs.")
|
1092 |
-
}
|
1093 |
-
}
|
1094 |
-
}
|
1095 |
-
l = h.children("a").first();
|
1096 |
-
p(x)
|
1097 |
-
};
|
1098 |
-
var p = function (z) {
|
1099 |
-
var y, x;
|
1100 |
-
if (r.collapsible && z.length === 0 && r.collapsedByDefault) {
|
1101 |
-
h.addClass(r.collapsedClass).children().addClass(r.collapsedClass)
|
1102 |
-
} else {
|
1103 |
-
y = a(h.data("easytabs").panel);
|
1104 |
-
x = h.data("easytabs").ajax;
|
1105 |
-
if (x && (!r.cache || !h.data("easytabs").cached)) {
|
1106 |
-
q.trigger("easytabs:ajax:beforeSend", [l, y]);
|
1107 |
-
y.load(x, function (B, A, C) {
|
1108 |
-
h.data("easytabs").cached = true;
|
1109 |
-
q.trigger("easytabs:ajax:complete", [l, y, B, A, C])
|
1110 |
-
})
|
1111 |
-
}
|
1112 |
-
h.data("easytabs").panel.show().addClass(r.panelActiveClass);
|
1113 |
-
h.addClass(r.tabActiveClass).children().addClass(r.tabActiveClass)
|
1114 |
-
}
|
1115 |
-
q.trigger("easytabs:initialised", [l, y])
|
1116 |
-
};
|
1117 |
-
var w = function () {
|
1118 |
-
f.tabs.children("a").bind(r.bind_str, function (x) {
|
1119 |
-
r.cycle = false;
|
1120 |
-
d = false;
|
1121 |
-
f.selectTab(a(this));
|
1122 |
-
x.preventDefault ? x.preventDefault() : x.returnValue = false
|
1123 |
-
})
|
1124 |
-
};
|
1125 |
-
var o = function (z, D, E, H) {
|
1126 |
-
f.panels.stop(true, true);
|
1127 |
-
if (u(q, "easytabs:before", [z, D, r])) {
|
1128 |
-
var A = f.panels.filter(":visible"), y = D.parent(), F, x, C, G, B = window.location.hash.match(/^[^\?]*/)[0];
|
1129 |
-
if (r.animate) {
|
1130 |
-
F = s(D);
|
1131 |
-
x = A.length ? k(A) : 0;
|
1132 |
-
C = F - x
|
1133 |
-
}
|
1134 |
-
m = B;
|
1135 |
-
G = function () {
|
1136 |
-
q.trigger("easytabs:midTransition", [z, D, r]);
|
1137 |
-
if (r.animate && r.transitionIn == "fadeIn") {
|
1138 |
-
if (C < 0) {
|
1139 |
-
y.animate({height: y.height() + C}, v.halfSpeed).css({"min-height": ""})
|
1140 |
-
}
|
1141 |
-
}
|
1142 |
-
if (r.updateHash && !d) {
|
1143 |
-
window.location.hash = "#" + D.attr("id")
|
1144 |
-
} else {
|
1145 |
-
d = false
|
1146 |
-
}
|
1147 |
-
D[v.show](v.speed, r.transitionInEasing, function () {
|
1148 |
-
y.css({height: "", "min-height": ""});
|
1149 |
-
q.trigger("easytabs:after", [z, D, r]);
|
1150 |
-
if (typeof H == "function") {
|
1151 |
-
H()
|
1152 |
-
}
|
1153 |
-
})
|
1154 |
-
};
|
1155 |
-
if (E && (!r.cache || !z.parent().data("easytabs").cached)) {
|
1156 |
-
q.trigger("easytabs:ajax:beforeSend", [z, D]);
|
1157 |
-
D.load(E, function (J, I, K) {
|
1158 |
-
z.parent().data("easytabs").cached = true;
|
1159 |
-
q.trigger("easytabs:ajax:complete", [z, D, J, I, K])
|
1160 |
-
})
|
1161 |
-
}
|
1162 |
-
if (r.animate && r.transitionOut == "fadeOut") {
|
1163 |
-
if (C > 0) {
|
1164 |
-
y.animate({height: (y.height() + C)}, v.halfSpeed)
|
1165 |
-
} else {
|
1166 |
-
y.css({"min-height": y.height()})
|
1167 |
-
}
|
1168 |
-
}
|
1169 |
-
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
1170 |
-
f.tabs.filter("." + r.collapsedClass).removeClass(r.collapsedClass).children().removeClass(r.collapsedClass);
|
1171 |
-
z.parent().addClass(r.tabActiveClass).children().addClass(r.tabActiveClass);
|
1172 |
-
f.panels.filter("." + r.panelActiveClass).removeClass(r.panelActiveClass);
|
1173 |
-
D.addClass(r.panelActiveClass);
|
1174 |
-
if (A.length) {
|
1175 |
-
A[v.hide](v.speed, r.transitionOutEasing, G)
|
1176 |
-
} else {
|
1177 |
-
D[v.uncollapse](v.speed, r.transitionUncollapseEasing, G)
|
1178 |
-
}
|
1179 |
-
}
|
1180 |
-
};
|
1181 |
-
var s = function (z) {
|
1182 |
-
if (z.data("easytabs") && z.data("easytabs").lastHeight) {
|
1183 |
-
return z.data("easytabs").lastHeight
|
1184 |
-
}
|
1185 |
-
var B = z.css("display"), y, x;
|
1186 |
-
try {
|
1187 |
-
y = a("<div></div>", {position: "absolute", visibility: "hidden", overflow: "hidden"})
|
1188 |
-
} catch (A) {
|
1189 |
-
y = a("<div></div>", {visibility: "hidden", overflow: "hidden"})
|
1190 |
-
}
|
1191 |
-
x = z.wrap(y).css({position: "relative", visibility: "hidden", display: "block"}).outerHeight();
|
1192 |
-
z.unwrap();
|
1193 |
-
z.css({position: z.data("easytabs").position, visibility: z.data("easytabs").visibility, display: B});
|
1194 |
-
z.data("easytabs").lastHeight = x;
|
1195 |
-
return x
|
1196 |
-
};
|
1197 |
-
var k = function (y) {
|
1198 |
-
var x = y.outerHeight();
|
1199 |
-
if (y.data("easytabs")) {
|
1200 |
-
y.data("easytabs").lastHeight = x
|
1201 |
-
} else {
|
1202 |
-
y.data("easytabs", {lastHeight: x})
|
1203 |
-
}
|
1204 |
-
return x
|
1205 |
-
};
|
1206 |
-
var n = function () {
|
1207 |
-
if (typeof a(window).hashchange === "function") {
|
1208 |
-
a(window).hashchange(function () {
|
1209 |
-
f.selectTabFromHashChange()
|
1210 |
-
})
|
1211 |
-
} else {
|
1212 |
-
if (a.address && typeof a.address.change === "function") {
|
1213 |
-
a.address.change(function () {
|
1214 |
-
f.selectTabFromHashChange()
|
1215 |
-
})
|
1216 |
-
}
|
1217 |
-
}
|
1218 |
-
};
|
1219 |
-
var c = function () {
|
1220 |
-
var x;
|
1221 |
-
if (r.cycle) {
|
1222 |
-
x = f.tabs.index(h);
|
1223 |
-
setTimeout(function () {
|
1224 |
-
f.cycleTabs(x + 1)
|
1225 |
-
}, r.cycle)
|
1226 |
-
}
|
1227 |
-
};
|
1228 |
-
f.init()
|
1229 |
-
};
|
1230 |
-
a.fn.easytabs = function (c) {
|
1231 |
-
var b = arguments;
|
1232 |
-
return this.each(function () {
|
1233 |
-
var e = a(this), d = e.data("easytabs");
|
1234 |
-
if (undefined === d) {
|
1235 |
-
d = new a.easytabs(this, c);
|
1236 |
-
e.data("easytabs", d)
|
1237 |
-
}
|
1238 |
-
if (d.publicMethods[c]) {
|
1239 |
-
return d.publicMethods[c](Array.prototype.slice.call(b, 1))
|
1240 |
-
}
|
1241 |
-
})
|
1242 |
-
}
|
1243 |
-
})(jQuery);
|
1244 |
-
|
1245 |
-
|
1246 |
-
/*
|
1247 |
-
colpick Color Picker
|
1248 |
-
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
|
1249 |
-
|
1250 |
-
For usage and examples: colpick.com/plugin
|
1251 |
-
*/
|
1252 |
-
|
1253 |
-
(function ($) {
|
1254 |
-
var colpick = function () {
|
1255 |
-
var
|
1256 |
-
tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
|
1257 |
-
defaults = {
|
1258 |
-
showEvent: 'click',
|
1259 |
-
onShow: function () {
|
1260 |
-
},
|
1261 |
-
onBeforeShow: function () {
|
1262 |
-
},
|
1263 |
-
onHide: function () {
|
1264 |
-
},
|
1265 |
-
onChange: function () {
|
1266 |
-
},
|
1267 |
-
onSubmit: function () {
|
1268 |
-
},
|
1269 |
-
colorScheme: 'light',
|
1270 |
-
color: '3289c7',
|
1271 |
-
livePreview: true,
|
1272 |
-
flat: false,
|
1273 |
-
layout: 'full',
|
1274 |
-
submit: 1,
|
1275 |
-
submitText: 'OK',
|
1276 |
-
height: 156
|
1277 |
-
},
|
1278 |
-
//Fill the inputs of the plugin
|
1279 |
-
fillRGBFields = function (hsb, cal) {
|
1280 |
-
var rgb = hsbToRgb(hsb);
|
1281 |
-
$(cal).data('colpick').fields
|
1282 |
-
.eq(1).val(rgb.r).end()
|
1283 |
-
.eq(2).val(rgb.g).end()
|
1284 |
-
.eq(3).val(rgb.b).end();
|
1285 |
-
},
|
1286 |
-
fillHSBFields = function (hsb, cal) {
|
1287 |
-
$(cal).data('colpick').fields
|
1288 |
-
.eq(4).val(Math.round(hsb.h)).end()
|
1289 |
-
.eq(5).val(Math.round(hsb.s)).end()
|
1290 |
-
.eq(6).val(Math.round(hsb.b)).end();
|
1291 |
-
},
|
1292 |
-
fillHexFields = function (hsb, cal) {
|
1293 |
-
$(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
|
1294 |
-
},
|
1295 |
-
//Set the round selector position
|
1296 |
-
setSelector = function (hsb, cal) {
|
1297 |
-
$(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
|
1298 |
-
$(cal).data('colpick').selectorIndic.css({
|
1299 |
-
left: parseInt($(cal).data('colpick').height * hsb.s / 100, 10),
|
1300 |
-
top: parseInt($(cal).data('colpick').height * (100 - hsb.b) / 100, 10)
|
1301 |
-
});
|
1302 |
-
},
|
1303 |
-
//Set the hue selector position
|
1304 |
-
setHue = function (hsb, cal) {
|
1305 |
-
$(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
|
1306 |
-
},
|
1307 |
-
//Set current and new colors
|
1308 |
-
setCurrentColor = function (hsb, cal) {
|
1309 |
-
$(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1310 |
-
},
|
1311 |
-
setNewColor = function (hsb, cal) {
|
1312 |
-
$(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1313 |
-
},
|
1314 |
-
//Called when the new color is changed
|
1315 |
-
change = function (ev) {
|
1316 |
-
var cal = $(this).parent().parent(), col;
|
1317 |
-
if (this.parentNode.className.indexOf('_hex') > 0) {
|
1318 |
-
cal.data('colpick').color = col = hexToHsb(fixHex(this.value));
|
1319 |
-
fillRGBFields(col, cal.get(0));
|
1320 |
-
fillHSBFields(col, cal.get(0));
|
1321 |
-
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
1322 |
-
cal.data('colpick').color = col = fixHSB({
|
1323 |
-
h: parseInt(cal.data('colpick').fields.eq(4).val(), 10),
|
1324 |
-
s: parseInt(cal.data('colpick').fields.eq(5).val(), 10),
|
1325 |
-
b: parseInt(cal.data('colpick').fields.eq(6).val(), 10)
|
1326 |
-
});
|
1327 |
-
fillRGBFields(col, cal.get(0));
|
1328 |
-
fillHexFields(col, cal.get(0));
|
1329 |
-
} else {
|
1330 |
-
cal.data('colpick').color = col = rgbToHsb(fixRGB({
|
1331 |
-
r: parseInt(cal.data('colpick').fields.eq(1).val(), 10),
|
1332 |
-
g: parseInt(cal.data('colpick').fields.eq(2).val(), 10),
|
1333 |
-
b: parseInt(cal.data('colpick').fields.eq(3).val(), 10)
|
1334 |
-
}));
|
1335 |
-
fillHexFields(col, cal.get(0));
|
1336 |
-
fillHSBFields(col, cal.get(0));
|
1337 |
-
}
|
1338 |
-
setSelector(col, cal.get(0));
|
1339 |
-
setHue(col, cal.get(0));
|
1340 |
-
setNewColor(col, cal.get(0));
|
1341 |
-
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
|
1342 |
-
},
|
1343 |
-
//Change style on blur and on focus of inputs
|
1344 |
-
blur = function (ev) {
|
1345 |
-
$(this).parent().removeClass('colpick_focus');
|
1346 |
-
},
|
1347 |
-
focus = function () {
|
1348 |
-
$(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
|
1349 |
-
$(this).parent().addClass('colpick_focus');
|
1350 |
-
},
|
1351 |
-
//Increment/decrement arrows functions
|
1352 |
-
downIncrement = function (ev) {
|
1353 |
-
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1354 |
-
var field = $(this).parent().find('input').focus();
|
1355 |
-
var current = {
|
1356 |
-
el: $(this).parent().addClass('colpick_slider'),
|
1357 |
-
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
1358 |
-
y: ev.pageY,
|
1359 |
-
field: field,
|
1360 |
-
val: parseInt(field.val(), 10),
|
1361 |
-
preview: $(this).parent().parent().data('colpick').livePreview
|
1362 |
-
};
|
1363 |
-
$(document).mouseup(current, upIncrement);
|
1364 |
-
$(document).mousemove(current, moveIncrement);
|
1365 |
-
},
|
1366 |
-
moveIncrement = function (ev) {
|
1367 |
-
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10))));
|
1368 |
-
if (ev.data.preview) {
|
1369 |
-
change.apply(ev.data.field.get(0), [true]);
|
1370 |
-
}
|
1371 |
-
return false;
|
1372 |
-
},
|
1373 |
-
upIncrement = function (ev) {
|
1374 |
-
change.apply(ev.data.field.get(0), [true]);
|
1375 |
-
ev.data.el.removeClass('colpick_slider').find('input').focus();
|
1376 |
-
$(document).off('mouseup', upIncrement);
|
1377 |
-
$(document).off('mousemove', moveIncrement);
|
1378 |
-
return false;
|
1379 |
-
},
|
1380 |
-
//Hue slider functions
|
1381 |
-
downHue = function (ev) {
|
1382 |
-
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1383 |
-
var current = {
|
1384 |
-
cal: $(this).parent(),
|
1385 |
-
y: $(this).offset().top
|
1386 |
-
};
|
1387 |
-
$(document).on('mouseup touchend', current, upHue);
|
1388 |
-
$(document).on('mousemove touchmove', current, moveHue);
|
1389 |
-
|
1390 |
-
var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1391 |
-
change.apply(
|
1392 |
-
current.cal.data('colpick')
|
1393 |
-
.fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height - (pageY - current.y)) / current.cal.data('colpick').height, 10))
|
1394 |
-
.get(0),
|
1395 |
-
[current.cal.data('colpick').livePreview]
|
1396 |
-
);
|
1397 |
-
return false;
|
1398 |
-
},
|
1399 |
-
moveHue = function (ev) {
|
1400 |
-
var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1401 |
-
change.apply(
|
1402 |
-
ev.data.cal.data('colpick')
|
1403 |
-
.fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) / ev.data.cal.data('colpick').height, 10))
|
1404 |
-
.get(0),
|
1405 |
-
[ev.data.preview]
|
1406 |
-
);
|
1407 |
-
return false;
|
1408 |
-
},
|
1409 |
-
upHue = function (ev) {
|
1410 |
-
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1411 |
-
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1412 |
-
$(document).off('mouseup touchend', upHue);
|
1413 |
-
$(document).off('mousemove touchmove', moveHue);
|
1414 |
-
return false;
|
1415 |
-
},
|
1416 |
-
//Color selector functions
|
1417 |
-
downSelector = function (ev) {
|
1418 |
-
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1419 |
-
var current = {
|
1420 |
-
cal: $(this).parent(),
|
1421 |
-
pos: $(this).offset()
|
1422 |
-
};
|
1423 |
-
current.preview = current.cal.data('colpick').livePreview;
|
1424 |
-
|
1425 |
-
$(document).on('mouseup touchend', current, upSelector);
|
1426 |
-
$(document).on('mousemove touchmove', current, moveSelector);
|
1427 |
-
|
1428 |
-
var payeX, pageY;
|
1429 |
-
if (ev.type == 'touchstart') {
|
1430 |
-
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1431 |
-
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1432 |
-
} else {
|
1433 |
-
pageX = ev.pageX;
|
1434 |
-
pageY = ev.pageY;
|
1435 |
-
}
|
1436 |
-
|
1437 |
-
change.apply(
|
1438 |
-
current.cal.data('colpick').fields
|
1439 |
-
.eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) / current.cal.data('colpick').height, 10)).end()
|
1440 |
-
.eq(5).val(parseInt(100 * (pageX - current.pos.left) / current.cal.data('colpick').height, 10))
|
1441 |
-
.get(0),
|
1442 |
-
[current.preview]
|
1443 |
-
);
|
1444 |
-
return false;
|
1445 |
-
},
|
1446 |
-
moveSelector = function (ev) {
|
1447 |
-
var payeX, pageY;
|
1448 |
-
if (ev.type == 'touchmove') {
|
1449 |
-
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1450 |
-
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1451 |
-
} else {
|
1452 |
-
pageX = ev.pageX;
|
1453 |
-
pageY = ev.pageY;
|
1454 |
-
}
|
1455 |
-
|
1456 |
-
change.apply(
|
1457 |
-
ev.data.cal.data('colpick').fields
|
1458 |
-
.eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) / ev.data.cal.data('colpick').height, 10)).end()
|
1459 |
-
.eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
|
1460 |
-
.get(0),
|
1461 |
-
[ev.data.preview]
|
1462 |
-
);
|
1463 |
-
return false;
|
1464 |
-
},
|
1465 |
-
upSelector = function (ev) {
|
1466 |
-
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1467 |
-
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1468 |
-
$(document).off('mouseup touchend', upSelector);
|
1469 |
-
$(document).off('mousemove touchmove', moveSelector);
|
1470 |
-
return false;
|
1471 |
-
},
|
1472 |
-
//Submit button
|
1473 |
-
clickSubmit = function (ev) {
|
1474 |
-
var cal = $(this).parent();
|
1475 |
-
var col = cal.data('colpick').color;
|
1476 |
-
cal.data('colpick').origColor = col;
|
1477 |
-
setCurrentColor(col, cal.get(0));
|
1478 |
-
cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
|
1479 |
-
},
|
1480 |
-
//Show/hide the color picker
|
1481 |
-
show = function (ev) {
|
1482 |
-
// Prevent the trigger of any direct parent
|
1483 |
-
ev.stopPropagation();
|
1484 |
-
var cal = $('#' + $(this).data('colpickId'));
|
1485 |
-
cal.data('colpick').onBeforeShow.apply(this, [cal.get(0)]);
|
1486 |
-
var pos = $(this).offset();
|
1487 |
-
var top = pos.top + this.offsetHeight;
|
1488 |
-
var left = pos.left;
|
1489 |
-
var viewPort = getViewport();
|
1490 |
-
var calW = cal.width();
|
1491 |
-
if (left + calW > viewPort.l + viewPort.w) {
|
1492 |
-
left -= calW;
|
1493 |
-
}
|
1494 |
-
cal.css({left: left + 'px', top: top + 'px'});
|
1495 |
-
if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
|
1496 |
-
cal.show();
|
1497 |
-
}
|
1498 |
-
//Hide when user clicks outside
|
1499 |
-
$('html').mousedown({cal: cal}, hide);
|
1500 |
-
cal.mousedown(function (ev) {
|
1501 |
-
ev.stopPropagation();
|
1502 |
-
})
|
1503 |
-
},
|
1504 |
-
hide = function (ev) {
|
1505 |
-
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
1506 |
-
ev.data.cal.hide();
|
1507 |
-
}
|
1508 |
-
$('html').off('mousedown', hide);
|
1509 |
-
},
|
1510 |
-
getViewport = function () {
|
1511 |
-
var m = document.compatMode == 'CSS1Compat';
|
1512 |
-
return {
|
1513 |
-
l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
1514 |
-
w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
|
1515 |
-
};
|
1516 |
-
},
|
1517 |
-
//Fix the values if the user enters a negative or high value
|
1518 |
-
fixHSB = function (hsb) {
|
1519 |
-
return {
|
1520 |
-
h: Math.min(360, Math.max(0, hsb.h)),
|
1521 |
-
s: Math.min(100, Math.max(0, hsb.s)),
|
1522 |
-
b: Math.min(100, Math.max(0, hsb.b))
|
1523 |
-
};
|
1524 |
-
},
|
1525 |
-
fixRGB = function (rgb) {
|
1526 |
-
return {
|
1527 |
-
r: Math.min(255, Math.max(0, rgb.r)),
|
1528 |
-
g: Math.min(255, Math.max(0, rgb.g)),
|
1529 |
-
b: Math.min(255, Math.max(0, rgb.b))
|
1530 |
-
};
|
1531 |
-
},
|
1532 |
-
fixHex = function (hex) {
|
1533 |
-
var len = 6 - hex.length;
|
1534 |
-
if (len > 0) {
|
1535 |
-
var o = [];
|
1536 |
-
for (var i = 0; i < len; i++) {
|
1537 |
-
o.push('0');
|
1538 |
-
}
|
1539 |
-
o.push(hex);
|
1540 |
-
hex = o.join('');
|
1541 |
-
}
|
1542 |
-
return hex;
|
1543 |
-
},
|
1544 |
-
restoreOriginal = function () {
|
1545 |
-
var cal = $(this).parent();
|
1546 |
-
var col = cal.data('colpick').origColor;
|
1547 |
-
cal.data('colpick').color = col;
|
1548 |
-
fillRGBFields(col, cal.get(0));
|
1549 |
-
fillHexFields(col, cal.get(0));
|
1550 |
-
fillHSBFields(col, cal.get(0));
|
1551 |
-
setSelector(col, cal.get(0));
|
1552 |
-
setHue(col, cal.get(0));
|
1553 |
-
setNewColor(col, cal.get(0));
|
1554 |
-
};
|
1555 |
-
return {
|
1556 |
-
init: function (opt) {
|
1557 |
-
opt = $.extend({}, defaults, opt || {});
|
1558 |
-
//Set color
|
1559 |
-
if (typeof opt.color == 'string') {
|
1560 |
-
opt.color = hexToHsb(opt.color);
|
1561 |
-
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
1562 |
-
opt.color = rgbToHsb(opt.color);
|
1563 |
-
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
1564 |
-
opt.color = fixHSB(opt.color);
|
1565 |
-
} else {
|
1566 |
-
return this;
|
1567 |
-
}
|
1568 |
-
|
1569 |
-
//For each selected DOM element
|
1570 |
-
return this.each(function () {
|
1571 |
-
//If the element does not have an ID
|
1572 |
-
if (!$(this).data('colpickId')) {
|
1573 |
-
var options = $.extend({}, opt);
|
1574 |
-
options.origColor = opt.color;
|
1575 |
-
//Generate and assign a random ID
|
1576 |
-
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
1577 |
-
$(this).data('colpickId', id);
|
1578 |
-
//Set the tpl's ID and get the HTML
|
1579 |
-
var cal = $(tpl).attr('id', id);
|
1580 |
-
//Add class according to layout
|
1581 |
-
cal.addClass('colpick_' + options.layout + (options.submit ? '' : ' colpick_' + options.layout + '_ns'));
|
1582 |
-
//Add class if the color scheme is not default
|
1583 |
-
if (options.colorScheme != 'light') {
|
1584 |
-
cal.addClass('colpick_' + options.colorScheme);
|
1585 |
-
}
|
1586 |
-
//Setup submit button
|
1587 |
-
cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
|
1588 |
-
//Setup input fields
|
1589 |
-
options.fields = cal.find('input').change(change).blur(blur).focus(focus);
|
1590 |
-
cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
|
1591 |
-
//Setup hue selector
|
1592 |
-
options.selector = cal.find('div.colpick_color').on('mousedown touchstart', downSelector);
|
1593 |
-
options.selectorIndic = options.selector.find('div.colpick_selector_outer');
|
1594 |
-
//Store parts of the plugin
|
1595 |
-
options.el = this;
|
1596 |
-
options.hue = cal.find('div.colpick_hue_arrs');
|
1597 |
-
huebar = options.hue.parent();
|
1598 |
-
//Paint the hue bar
|
1599 |
-
var UA = navigator.userAgent.toLowerCase();
|
1600 |
-
var isIE = navigator.appName === 'Microsoft Internet Explorer';
|
1601 |
-
var IEver = isIE ? parseFloat(UA.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0;
|
1602 |
-
var ngIE = (isIE && IEver < 10);
|
1603 |
-
var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80', '#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
|
1604 |
-
if (ngIE) {
|
1605 |
-
var i, div;
|
1606 |
-
for (i = 0; i <= 11; i++) {
|
1607 |
-
div = $('<div></div>').attr('style', 'height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + '); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
|
1608 |
-
huebar.append(div);
|
1609 |
-
}
|
1610 |
-
} else {
|
1611 |
-
stopList = stops.join(',');
|
1612 |
-
huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList + '); background: -o-linear-gradient(top,' + stopList + '); background: -ms-linear-gradient(top,' + stopList + '); background:-moz-linear-gradient(top,' + stopList + '); -webkit-linear-gradient(top,' + stopList + '); background:linear-gradient(to bottom,' + stopList + '); ');
|
1613 |
-
}
|
1614 |
-
cal.find('div.colpick_hue').on('mousedown touchstart', downHue);
|
1615 |
-
options.newColor = cal.find('div.colpick_new_color');
|
1616 |
-
options.currentColor = cal.find('div.colpick_current_color');
|
1617 |
-
//Store options and fill with default color
|
1618 |
-
cal.data('colpick', options);
|
1619 |
-
fillRGBFields(options.color, cal.get(0));
|
1620 |
-
fillHSBFields(options.color, cal.get(0));
|
1621 |
-
fillHexFields(options.color, cal.get(0));
|
1622 |
-
setHue(options.color, cal.get(0));
|
1623 |
-
setSelector(options.color, cal.get(0));
|
1624 |
-
setCurrentColor(options.color, cal.get(0));
|
1625 |
-
setNewColor(options.color, cal.get(0));
|
1626 |
-
//Append to body if flat=false, else show in place
|
1627 |
-
if (options.flat) {
|
1628 |
-
cal.appendTo(this).show();
|
1629 |
-
cal.css({
|
1630 |
-
position: 'relative',
|
1631 |
-
display: 'block'
|
1632 |
-
});
|
1633 |
-
} else {
|
1634 |
-
cal.appendTo(document.body);
|
1635 |
-
$(this).on(options.showEvent, show);
|
1636 |
-
cal.css({
|
1637 |
-
position: 'absolute'
|
1638 |
-
});
|
1639 |
-
}
|
1640 |
-
}
|
1641 |
-
});
|
1642 |
-
},
|
1643 |
-
//Shows the picker
|
1644 |
-
showPicker: function () {
|
1645 |
-
return this.each(function () {
|
1646 |
-
if ($(this).data('colpickId')) {
|
1647 |
-
show.apply(this);
|
1648 |
-
}
|
1649 |
-
});
|
1650 |
-
},
|
1651 |
-
//Hides the picker
|
1652 |
-
hidePicker: function () {
|
1653 |
-
return this.each(function () {
|
1654 |
-
if ($(this).data('colpickId')) {
|
1655 |
-
$('#' + $(this).data('colpickId')).hide();
|
1656 |
-
}
|
1657 |
-
});
|
1658 |
-
},
|
1659 |
-
//Sets a color as new and current (default)
|
1660 |
-
setColor: function (col, setCurrent) {
|
1661 |
-
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
1662 |
-
if (typeof col == 'string') {
|
1663 |
-
col = hexToHsb(col);
|
1664 |
-
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
1665 |
-
col = rgbToHsb(col);
|
1666 |
-
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
1667 |
-
col = fixHSB(col);
|
1668 |
-
} else {
|
1669 |
-
return this;
|
1670 |
-
}
|
1671 |
-
return this.each(function () {
|
1672 |
-
if ($(this).data('colpickId')) {
|
1673 |
-
var cal = $('#' + $(this).data('colpickId'));
|
1674 |
-
cal.data('colpick').color = col;
|
1675 |
-
cal.data('colpick').origColor = col;
|
1676 |
-
fillRGBFields(col, cal.get(0));
|
1677 |
-
fillHSBFields(col, cal.get(0));
|
1678 |
-
fillHexFields(col, cal.get(0));
|
1679 |
-
setHue(col, cal.get(0));
|
1680 |
-
setSelector(col, cal.get(0));
|
1681 |
-
|
1682 |
-
setNewColor(col, cal.get(0));
|
1683 |
-
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
|
1684 |
-
if (setCurrent) {
|
1685 |
-
setCurrentColor(col, cal.get(0));
|
1686 |
-
}
|
1687 |
-
}
|
1688 |
-
});
|
1689 |
-
}
|
1690 |
-
};
|
1691 |
-
}();
|
1692 |
-
//Color space convertions
|
1693 |
-
var hexToRgb = function (hex) {
|
1694 |
-
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
1695 |
-
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
1696 |
-
};
|
1697 |
-
var hexToHsb = function (hex) {
|
1698 |
-
return rgbToHsb(hexToRgb(hex));
|
1699 |
-
};
|
1700 |
-
var rgbToHsb = function (rgb) {
|
1701 |
-
var hsb = {h: 0, s: 0, b: 0};
|
1702 |
-
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
1703 |
-
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
1704 |
-
var delta = max - min;
|
1705 |
-
hsb.b = max;
|
1706 |
-
hsb.s = max != 0 ? 255 * delta / max : 0;
|
1707 |
-
if (hsb.s != 0) {
|
1708 |
-
if (rgb.r == max)
|
1709 |
-
hsb.h = (rgb.g - rgb.b) / delta;
|
1710 |
-
else if (rgb.g == max)
|
1711 |
-
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
1712 |
-
else
|
1713 |
-
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
1714 |
-
} else
|
1715 |
-
hsb.h = -1;
|
1716 |
-
hsb.h *= 60;
|
1717 |
-
if (hsb.h < 0)
|
1718 |
-
hsb.h += 360;
|
1719 |
-
hsb.s *= 100 / 255;
|
1720 |
-
hsb.b *= 100 / 255;
|
1721 |
-
return hsb;
|
1722 |
-
};
|
1723 |
-
var hsbToRgb = function (hsb) {
|
1724 |
-
var rgb = {};
|
1725 |
-
var h = hsb.h;
|
1726 |
-
var s = hsb.s * 255 / 100;
|
1727 |
-
var v = hsb.b * 255 / 100;
|
1728 |
-
if (s == 0) {
|
1729 |
-
rgb.r = rgb.g = rgb.b = v;
|
1730 |
-
} else {
|
1731 |
-
var t1 = v;
|
1732 |
-
var t2 = (255 - s) * v / 255;
|
1733 |
-
var t3 = (t1 - t2) * (h % 60) / 60;
|
1734 |
-
if (h == 360)
|
1735 |
-
h = 0;
|
1736 |
-
if (h < 60) {
|
1737 |
-
rgb.r = t1;
|
1738 |
-
rgb.b = t2;
|
1739 |
-
rgb.g = t2 + t3
|
1740 |
-
} else if (h < 120) {
|
1741 |
-
rgb.g = t1;
|
1742 |
-
rgb.b = t2;
|
1743 |
-
rgb.r = t1 - t3
|
1744 |
-
} else if (h < 180) {
|
1745 |
-
rgb.g = t1;
|
1746 |
-
rgb.r = t2;
|
1747 |
-
rgb.b = t2 + t3
|
1748 |
-
} else if (h < 240) {
|
1749 |
-
rgb.b = t1;
|
1750 |
-
rgb.r = t2;
|
1751 |
-
rgb.g = t1 - t3
|
1752 |
-
} else if (h < 300) {
|
1753 |
-
rgb.b = t1;
|
1754 |
-
rgb.g = t2;
|
1755 |
-
rgb.r = t2 + t3
|
1756 |
-
} else if (h < 360) {
|
1757 |
-
rgb.r = t1;
|
1758 |
-
rgb.g = t2;
|
1759 |
-
rgb.b = t1 - t3
|
1760 |
-
} else {
|
1761 |
-
rgb.r = 0;
|
1762 |
-
rgb.g = 0;
|
1763 |
-
rgb.b = 0
|
1764 |
-
}
|
1765 |
-
}
|
1766 |
-
return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
|
1767 |
-
};
|
1768 |
-
var rgbToHex = function (rgb) {
|
1769 |
-
var hex = [
|
1770 |
-
rgb.r.toString(16),
|
1771 |
-
rgb.g.toString(16),
|
1772 |
-
rgb.b.toString(16)
|
1773 |
-
];
|
1774 |
-
$.each(hex, function (nr, val) {
|
1775 |
-
if (val.length == 1) {
|
1776 |
-
hex[nr] = '0' + val;
|
1777 |
-
}
|
1778 |
-
});
|
1779 |
-
return hex.join('');
|
1780 |
-
};
|
1781 |
-
var hsbToHex = function (hsb) {
|
1782 |
-
return rgbToHex(hsbToRgb(hsb));
|
1783 |
-
};
|
1784 |
-
$.fn.extend({
|
1785 |
-
colpick: colpick.init,
|
1786 |
-
colpickHide: colpick.hidePicker,
|
1787 |
-
colpickShow: colpick.showPicker,
|
1788 |
-
colpickSetColor: colpick.setColor
|
1789 |
-
});
|
1790 |
-
$.extend({
|
1791 |
-
colpick: {
|
1792 |
-
rgbToHex: rgbToHex,
|
1793 |
-
rgbToHsb: rgbToHsb,
|
1794 |
-
hsbToHex: hsbToHex,
|
1795 |
-
hsbToRgb: hsbToRgb,
|
1796 |
-
hexToHsb: hexToHsb,
|
1797 |
-
hexToRgb: hexToRgb
|
1798 |
-
}
|
1799 |
-
});
|
1800 |
})(jQuery);
|
1 |
+
var strict;
|
2 |
+
|
3 |
+
|
4 |
+
jQuery(document).ready(function ($) {
|
5 |
+
|
6 |
+
// show / hide helper description
|
7 |
+
$('.quads-tooltip').click(function (e) {
|
8 |
+
e.preventDefault();
|
9 |
+
var icon = $(this),
|
10 |
+
bubble = $(this).next();
|
11 |
+
|
12 |
+
// Close any that are already open
|
13 |
+
$('.quads-tooltip-message').not(bubble).hide();
|
14 |
+
|
15 |
+
var position = icon.position();
|
16 |
+
if (bubble.hasClass('bottom')) {
|
17 |
+
bubble.css({
|
18 |
+
'left': (position.left - bubble.width() / 2) + 'px',
|
19 |
+
'top': (position.top + icon.height() + 9) + 'px'
|
20 |
+
});
|
21 |
+
} else {
|
22 |
+
bubble.css({
|
23 |
+
'left': (position.left + icon.width() + 9) + 'px',
|
24 |
+
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
25 |
+
});
|
26 |
+
}
|
27 |
+
|
28 |
+
bubble.toggle();
|
29 |
+
e.stopPropagation();
|
30 |
+
});
|
31 |
+
|
32 |
+
$('body').click(function () {
|
33 |
+
$('.quads-tooltip-message').hide();
|
34 |
+
});
|
35 |
+
|
36 |
+
$('.quads-tooltip-message').click(function (e) {
|
37 |
+
e.stopPropagation();
|
38 |
+
});
|
39 |
+
|
40 |
+
|
41 |
+
// vi login process
|
42 |
+
$("#quads_vi_login_submit").click(function(e){
|
43 |
+
e.preventDefault();
|
44 |
+
username = $("#quads-vi-email").val();
|
45 |
+
password = $("#quads-vi-password").val();
|
46 |
+
|
47 |
+
var data = '{"email":"' + username + '", "password":"' + password + '"}';
|
48 |
+
|
49 |
+
$.ajax({
|
50 |
+
type: "POST",
|
51 |
+
//url: "https://dashboard-api-test.vidint.net/v1/api/authenticate",
|
52 |
+
url: quads.vi_login_url,
|
53 |
+
contentType: 'application/json',
|
54 |
+
data: data,
|
55 |
+
statusCode: {
|
56 |
+
502: function () {
|
57 |
+
$("#quads_add_err").html("502 Bad Gateway. Contact support[at]vi.ai");
|
58 |
+
console.log('502 Bad Gateway.');
|
59 |
+
return false;
|
60 |
+
},
|
61 |
+
500: function () {
|
62 |
+
$("#quads_add_err").html("500 Bad Gateway. Contact support[at]vi.ai");
|
63 |
+
console.log('500 Bad Gateway.');
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
},
|
67 |
+
success: function(response){
|
68 |
+
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
69 |
+
$("#quads_add_err").hide();
|
70 |
+
if (typeof response.data !== 'undefined') {
|
71 |
+
$("#quads_add_err").html("We are logging you in");
|
72 |
+
console.log('We are logging you in' + response);
|
73 |
+
saveViToken(response.data);
|
74 |
+
}
|
75 |
+
else {
|
76 |
+
$("#quads_add_err").html("No valid API response. Can not log you in. Contact support[at]vi.ai");
|
77 |
+
console.log('no valid api response' + response);
|
78 |
+
}
|
79 |
+
},
|
80 |
+
error: function(response){
|
81 |
+
// check if xhr.status is defined in $.ajax.statusCode
|
82 |
+
// if true, return false to stop this function
|
83 |
+
if (typeof this.statusCode[response.status] != 'undefined') {
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
var result = typeof response.responseText !== 'undefined' ? JSON.parse(response.responseText) : '';
|
88 |
+
$("#quads_add_err").html(result.error.message + ' ' + result.error.description);
|
89 |
+
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
90 |
+
$("#quads_add_err").show();
|
91 |
+
$("#quads_add_err").removeClass('quads-spinner');
|
92 |
+
console.log(result);
|
93 |
+
//exit;
|
94 |
+
},
|
95 |
+
beforeSend:function()
|
96 |
+
{
|
97 |
+
$("#quads_vi_loading").css('display', 'inline', 'important').css('visibility', 'visible');
|
98 |
+
$("#quads_add_err").show();
|
99 |
+
},
|
100 |
+
|
101 |
+
complete:function()
|
102 |
+
{
|
103 |
+
$("#quads_vi_loading").css('display', 'none', 'important').css('visibility', 'hidden');
|
104 |
+
}
|
105 |
+
|
106 |
+
});
|
107 |
+
return false;
|
108 |
+
});
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Save vi token
|
112 |
+
*/
|
113 |
+
function saveViToken(token){
|
114 |
+
var data = {
|
115 |
+
'action': 'quads_save_vi_token',
|
116 |
+
'token': token
|
117 |
+
};
|
118 |
+
$.ajax({
|
119 |
+
type: "POST",
|
120 |
+
url: ajaxurl,
|
121 |
+
dataType: "json",
|
122 |
+
data: data,
|
123 |
+
//contentType: 'application/json;charset=utf-8',
|
124 |
+
success: function(response){
|
125 |
+
//response = JSON.stringify(response);
|
126 |
+
console.log(response.status);
|
127 |
+
|
128 |
+
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
129 |
+
$("#quads_add_err").hide();
|
130 |
+
if (typeof response.status != 'undefined' && response.status == 'success') {
|
131 |
+
console.log('Success, login succesfull, token stored' + response);
|
132 |
+
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
133 |
+
return false;
|
134 |
+
}
|
135 |
+
else {
|
136 |
+
console.log("Can not store token");
|
137 |
+
window.location.href = quads.path + '/wp-admin/?page=quads-settings&tab=general#quads_settingsvi_header';
|
138 |
+
return false;
|
139 |
+
}
|
140 |
+
},
|
141 |
+
beforeSend:function()
|
142 |
+
{
|
143 |
+
$("#quads_add_err").css('display', 'inline', 'important').css('visibility', 'visible');
|
144 |
+
$("#quads_add_err").show();
|
145 |
+
},
|
146 |
+
complete:function()
|
147 |
+
{
|
148 |
+
$("#quads_add_err").css('display', 'none', 'important').css('visibility', 'hidden');
|
149 |
+
$("#quads_add_err").hide();
|
150 |
+
}
|
151 |
+
|
152 |
+
});
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
|
158 |
+
// Remove several unused elements from vi page
|
159 |
+
if (document.location.href.indexOf('vi_header') > - 1) {
|
160 |
+
$('#quads-submit-button').hide();
|
161 |
+
$('#quads-validate').hide();
|
162 |
+
$('#quads-footer').hide();
|
163 |
+
} else {
|
164 |
+
$('#quads-submit-button').show();
|
165 |
+
$('#quads-validate').show();
|
166 |
+
$('#quads-footer').show();
|
167 |
+
}
|
168 |
+
$(window).bind('easytabs:after', function(){
|
169 |
+
if (document.location.href.indexOf('vi_header') > - 1) {
|
170 |
+
$('#quads-submit-button').hide();
|
171 |
+
$('#quads-validate').hide();
|
172 |
+
$('#quads-footer').hide();
|
173 |
+
} else {
|
174 |
+
|
175 |
+
$('#quads-submit-button').show();
|
176 |
+
$('#quads-validate').show();
|
177 |
+
$('#quads-footer').show();
|
178 |
+
}
|
179 |
+
});
|
180 |
+
|
181 |
+
|
182 |
+
|
183 |
+
|
184 |
+
|
185 |
+
// VI signup form
|
186 |
+
$('#quads-vi-signup').click(function(e){
|
187 |
+
e.preventDefault();
|
188 |
+
// scroll to top
|
189 |
+
$(window).scrollTop(0);
|
190 |
+
// hide save button
|
191 |
+
$('#quads-submit-button').hide();
|
192 |
+
$('#quads-vi-signup-fullscreen').fadeIn();
|
193 |
+
});
|
194 |
+
$('#quads-vi-close').click(function(e){
|
195 |
+
e.preventDefault();
|
196 |
+
$('#quads-vi-signup-fullscreen').fadeOut();
|
197 |
+
});
|
198 |
+
|
199 |
+
/**
|
200 |
+
* General Tab
|
201 |
+
*/
|
202 |
+
// Inactive select fields are greyed out
|
203 |
+
$('.quads-assign').each(function(e){
|
204 |
+
if (!$(this).prop('checked')){
|
205 |
+
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
206 |
+
}else {
|
207 |
+
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
208 |
+
}
|
209 |
+
});
|
210 |
+
|
211 |
+
$('.quads-assign').click(function(){
|
212 |
+
if (!$(this).prop('checked')){
|
213 |
+
$(this).next('select').css('background-color', 'whitesmoke').css('color', '#939393');
|
214 |
+
} else {
|
215 |
+
$(this).next('select').css('background-color', 'white').css('color', 'black');
|
216 |
+
}
|
217 |
+
});
|
218 |
+
|
219 |
+
/**
|
220 |
+
* AdSense Code Tab
|
221 |
+
*/
|
222 |
+
// Check if submit button is visible than stick it to the bottom of the page
|
223 |
+
$(window).scroll(function() {
|
224 |
+
|
225 |
+
var elem = '#quads_tab_container .submit';
|
226 |
+
|
227 |
+
if ($(elem).length < 1){
|
228 |
+
return;
|
229 |
+
}
|
230 |
+
|
231 |
+
var top_of_element = $(elem).offset().top;
|
232 |
+
var bottom_of_element = $(elem).offset().top + $(elem).outerHeight(false);
|
233 |
+
var bottom_of_screen = $(window).scrollTop() + $(window).height();
|
234 |
+
if (bottom_of_screen > top_of_element){
|
235 |
+
// The element is visible, do something
|
236 |
+
$('#quads-submit-button').css('position', 'relative').css('bottom', '20px');
|
237 |
+
} else {
|
238 |
+
// The element is NOT visible, do something else
|
239 |
+
$('#quads-submit-button').css('position', 'fixed').css('bottom', '20px');
|
240 |
+
}
|
241 |
+
});
|
242 |
+
|
243 |
+
// Activate chosen select boxes
|
244 |
+
// $(".quads-chosen-select").chosen({
|
245 |
+
// inherit_select_classes: true
|
246 |
+
// });
|
247 |
+
|
248 |
+
|
249 |
+
|
250 |
+
// Hid or show AMP code form on click on amp checkbox
|
251 |
+
$('.quads-activate-amp').click(function(){
|
252 |
+
var parent = $(this).parents('.quads-ad-toggle-container').attr('id');
|
253 |
+
if ($(this).attr('checked') === 'checked') {
|
254 |
+
$('#' + parent).find('.quads-amp-code').show();
|
255 |
+
} else {
|
256 |
+
$('#' + parent).find('.quads-amp-code').hide();
|
257 |
+
}
|
258 |
+
});
|
259 |
+
|
260 |
+
|
261 |
+
// Hide or show AMP code form on loading
|
262 |
+
$('.quads-ad-toggle-container').find('.quads-activate-amp').each(function (index, value) {
|
263 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
264 |
+
if ($(this).attr( 'checked') === 'checked' ) {
|
265 |
+
$('#' + parentContainerID).find('.quads-amp-code').show();
|
266 |
+
}else {
|
267 |
+
$('#' + parentContainerID).find('.quads-amp-code').hide();
|
268 |
+
}
|
269 |
+
});
|
270 |
+
|
271 |
+
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Toggle Button | Open All Ads
|
275 |
+
*/
|
276 |
+
$('#quads-open-toggle').click(function(){
|
277 |
+
if ($('#quads-open-toggle').text() === 'Open All Ads' ){
|
278 |
+
$('.quads-ad-toggle-container').show();
|
279 |
+
$('#quads-open-toggle').html('Close Ads');
|
280 |
+
}else{
|
281 |
+
$('.quads-ad-toggle-container').hide();
|
282 |
+
$('#quads-open-toggle').html('Open All Ads');
|
283 |
+
}
|
284 |
+
});
|
285 |
+
|
286 |
+
// show / hide helper description
|
287 |
+
$('.quads-helper').click(function (e) {
|
288 |
+
e.preventDefault();
|
289 |
+
var icon = $(this),
|
290 |
+
bubble = $(this).next();
|
291 |
+
|
292 |
+
// Close any that are already open
|
293 |
+
$('.quads-message').not(bubble).hide();
|
294 |
+
|
295 |
+
var position = icon.position();
|
296 |
+
if (bubble.hasClass('bottom')) {
|
297 |
+
bubble.css({
|
298 |
+
'left': (position.left - bubble.width() / 2) + 'px',
|
299 |
+
'top': (position.top + icon.height() + 9) + 'px'
|
300 |
+
});
|
301 |
+
} else {
|
302 |
+
bubble.css({
|
303 |
+
'left': (position.left + icon.width() + 9) + 'px',
|
304 |
+
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
305 |
+
});
|
306 |
+
}
|
307 |
+
|
308 |
+
bubble.toggle();
|
309 |
+
e.stopPropagation();
|
310 |
+
});
|
311 |
+
$('.quads-general-helper').click(function (e) {
|
312 |
+
e.preventDefault();
|
313 |
+
var icon = $(this),
|
314 |
+
bubble = $(this).next();
|
315 |
+
|
316 |
+
// Close any that are already open
|
317 |
+
$('.quads-message').not(bubble).hide();
|
318 |
+
|
319 |
+
var position = icon.position();
|
320 |
+
if (bubble.hasClass('bottom')) {
|
321 |
+
bubble.css({
|
322 |
+
'left': (position.left - bubble.width() / 2) + 'px',
|
323 |
+
'top': (position.top + icon.height() + 9) + 'px'
|
324 |
+
});
|
325 |
+
} else {
|
326 |
+
bubble.css({
|
327 |
+
'left': (position.left + icon.width() + 9) + 'px',
|
328 |
+
'top': (position.top + icon.height() / 2 - 18) + 'px'
|
329 |
+
});
|
330 |
+
}
|
331 |
+
|
332 |
+
bubble.toggle();
|
333 |
+
e.stopPropagation();
|
334 |
+
});
|
335 |
+
|
336 |
+
$('body').click(function () {
|
337 |
+
$('.quads-message').hide();
|
338 |
+
});
|
339 |
+
|
340 |
+
$('.quads-message').click(function (e) {
|
341 |
+
e.stopPropagation();
|
342 |
+
});
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Save settings via ajax
|
346 |
+
*/
|
347 |
+
|
348 |
+
jQuery('#quads_settings').submit(function() {
|
349 |
+
|
350 |
+
// Check if ad name has been changed and prepare new data for saving
|
351 |
+
$('.quads-toogle-title').each(function(){
|
352 |
+
$(this).children('input').val($(this).text());
|
353 |
+
});
|
354 |
+
|
355 |
+
|
356 |
+
// Check current url / settings page
|
357 |
+
var url = window.location.search;
|
358 |
+
var tab_imexport = url.search("page=quads-settings&tab=imexport");
|
359 |
+
var tab_licenses = url.search("page=quads-settings&tab=licenses");
|
360 |
+
|
361 |
+
jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
|
362 |
+
jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
|
363 |
+
jQuery(this).ajaxSubmit({
|
364 |
+
|
365 |
+
success: function(){
|
366 |
+
jQuery('#quads-save-result').html("<div id='quads-save-message' class='quads-success-modal'></div>");
|
367 |
+
jQuery('#quads-save-message').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/saved.gif"></p>').show();
|
368 |
+
quads_hide_success_message();
|
369 |
+
},
|
370 |
+
//,timeout: 0,
|
371 |
+
|
372 |
+
error: function(){
|
373 |
+
//Do not show alert on import/export tab
|
374 |
+
if ( tab_imexport === -1 && tab_licenses === -1 ){
|
375 |
+
alert ('Error: Can not save settings. Try again');
|
376 |
+
}
|
377 |
+
jQuery('#quads-save-result').hide('fast');
|
378 |
+
}
|
379 |
+
});
|
380 |
+
// Do not use ajax saving on import/export and licenses tab
|
381 |
+
if ( tab_imexport === -1 && tab_licenses ===-1 ){
|
382 |
+
return false;
|
383 |
+
}
|
384 |
+
});
|
385 |
+
|
386 |
+
function quads_hide_success_message(){
|
387 |
+
setTimeout("jQuery('#quads-save-message').hide()", 1000);
|
388 |
+
}
|
389 |
+
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Paste AdSense Code form
|
393 |
+
*/
|
394 |
+
$(document).on('click', '#quads-paste-button', function () {
|
395 |
+
|
396 |
+
var content = $('#quads-adsense-form').val();
|
397 |
+
var parseResult = quadsParseAdSenseCode(content);
|
398 |
+
if (false !== parseResult) {
|
399 |
+
console.log(parseResult);
|
400 |
+
setDetailsFromAdCode(parseResult);
|
401 |
+
}else{
|
402 |
+
$('#quads-msg').html('Can not parse AdSense Code. Is the code valid?');
|
403 |
+
$('#quads-msg').show();
|
404 |
+
}
|
405 |
+
});
|
406 |
+
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Populate AdSense Date Fields
|
410 |
+
*
|
411 |
+
* @param object adsense
|
412 |
+
* @param2 string id of the parent container
|
413 |
+
* @returns false
|
414 |
+
*/
|
415 |
+
function setDetailsFromAdCode(GoogleAd) {
|
416 |
+
|
417 |
+
var containerID = $('#quads-adsense-id').val();
|
418 |
+
|
419 |
+
var id = containerID.replace("quads-toggle", "");
|
420 |
+
|
421 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_slot\\]').val(GoogleAd.slotId);
|
422 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_client\\]').val(GoogleAd.pubId);
|
423 |
+
if ('normal' == GoogleAd.type) {
|
424 |
+
console.log($('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]'));
|
425 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('normal');
|
426 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val(GoogleAd.width);
|
427 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val(GoogleAd.height);
|
428 |
+
}
|
429 |
+
if ('responsive' == GoogleAd.type) {
|
430 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[adsense_type\\]').val('responsive');
|
431 |
+
//$('#ad-resize-type').val('auto');
|
432 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_width\\]').val('');
|
433 |
+
$('#quads_settings\\[ads\\]\\[' + id + '\\]\\[g_data_ad_height\\]').val('');
|
434 |
+
}
|
435 |
+
// Trigger the ad type select
|
436 |
+
$('.quads-select-Type').trigger('change');
|
437 |
+
// Hide the overlay
|
438 |
+
$('#quads-adsense-bg-div').hide();
|
439 |
+
// Ad code input form must not be empty!
|
440 |
+
if ($('#' + containerID).children('textarea').val().length === 0){
|
441 |
+
$('#' + containerID).children('textarea').val('adsense');
|
442 |
+
}
|
443 |
+
|
444 |
+
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Parse the adsense ad content
|
449 |
+
* @param {type} content
|
450 |
+
* @returns {quads-admin.min_L3.parseAdContent.GoogleAd|Boolean}
|
451 |
+
*/
|
452 |
+
function quadsParseAdSenseCode(content) {
|
453 |
+
|
454 |
+
var rawContent = ('undefined' != typeof (content)) ? content.trim() : '';
|
455 |
+
var GoogleAd = {};
|
456 |
+
var theContent = $('<div />').html(rawContent);
|
457 |
+
var asyncGoogleAd = theContent.find('ins');
|
458 |
+
//var syncGoogleAd = theContent.search('google_ad_client');
|
459 |
+
|
460 |
+
// Its a async adsense ad
|
461 |
+
if (asyncGoogleAd.length > 0) {
|
462 |
+
console.log('async ad');
|
463 |
+
|
464 |
+
// Ad Slot ID
|
465 |
+
GoogleAd.slotId = asyncGoogleAd.attr('data-ad-slot');
|
466 |
+
|
467 |
+
if ('undefined' != typeof (asyncGoogleAd.attr('data-ad-client'))) {
|
468 |
+
// Ad Publisher ID
|
469 |
+
GoogleAd.pubId = asyncGoogleAd.attr('data-ad-client').substr(3);
|
470 |
+
}
|
471 |
+
|
472 |
+
if (undefined !== GoogleAd.slotId && '' != GoogleAd.pubId) {
|
473 |
+
GoogleAd.display = asyncGoogleAd.css('display');
|
474 |
+
GoogleAd.format = asyncGoogleAd.attr('data-ad-format');
|
475 |
+
GoogleAd.style = asyncGoogleAd.attr('style');
|
476 |
+
|
477 |
+
if ('undefined' == typeof (GoogleAd.format) && -1 != GoogleAd.style.indexOf('width')) {
|
478 |
+
/* normal ad */
|
479 |
+
GoogleAd.type = 'normal';
|
480 |
+
GoogleAd.width = asyncGoogleAd.css('width').replace('px', '');
|
481 |
+
GoogleAd.height = asyncGoogleAd.css('height').replace('px', '');
|
482 |
+
return GoogleAd;
|
483 |
+
}
|
484 |
+
|
485 |
+
if ('undefined' != typeof (GoogleAd.format) && 'auto' == GoogleAd.format) {
|
486 |
+
/* Responsive ad, auto resize */
|
487 |
+
GoogleAd.type = 'responsive';
|
488 |
+
return GoogleAd;
|
489 |
+
}
|
490 |
+
return GoogleAd;
|
491 |
+
}
|
492 |
+
|
493 |
+
return false;
|
494 |
+
}
|
495 |
+
|
496 |
+
// Google syncronous ad
|
497 |
+
if (rawContent.search('google_ad_client') > 0) {
|
498 |
+
console.log('syncronous code');
|
499 |
+
|
500 |
+
// Ad Slot ID
|
501 |
+
GoogleAd.slotId = get_google_ad_slot(content);
|
502 |
+
|
503 |
+
console.log(get_google_ad_slot(content));
|
504 |
+
console.log(get_google_ad_client(content));
|
505 |
+
console.log(get_google_ad_height(content));
|
506 |
+
console.log(get_google_ad_width(content));
|
507 |
+
|
508 |
+
if (!quadsIsEmpty(get_google_ad_client(content))) {
|
509 |
+
// Ad Publisher ID
|
510 |
+
GoogleAd.pubId = 'ca-pub-' + get_google_ad_client(content);
|
511 |
+
}else{
|
512 |
+
return false;
|
513 |
+
}
|
514 |
+
|
515 |
+
if (!quadsIsEmpty(GoogleAd.slotId) && !quadsIsEmpty(GoogleAd.pubId)) {
|
516 |
+
|
517 |
+
if (!quadsIsEmpty(get_google_ad_width(content))) {
|
518 |
+
GoogleAd.type = 'normal';
|
519 |
+
GoogleAd.width = get_google_ad_width(content);
|
520 |
+
GoogleAd.height = get_google_ad_height(content);
|
521 |
+
return GoogleAd;
|
522 |
+
}
|
523 |
+
}
|
524 |
+
return false;
|
525 |
+
}
|
526 |
+
|
527 |
+
return false;
|
528 |
+
}
|
529 |
+
|
530 |
+
function get_google_ad_slot(content) {
|
531 |
+
const regex = /google_ad_slot\s*=\s*"(\d*)";/g;
|
532 |
+
const str = content;
|
533 |
+
var m;
|
534 |
+
var result = {};
|
535 |
+
|
536 |
+
while ((m = regex.exec(str)) !== null) {
|
537 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
538 |
+
if (m.index === regex.lastIndex) {
|
539 |
+
regex.lastIndex++;
|
540 |
+
}
|
541 |
+
|
542 |
+
// The result can be accessed through the `m`-variable.
|
543 |
+
m.forEach(function(match, index){
|
544 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
545 |
+
console.log(match);
|
546 |
+
result = match;
|
547 |
+
});
|
548 |
+
}
|
549 |
+
return result;
|
550 |
+
}
|
551 |
+
function get_google_ad_client(content) {
|
552 |
+
const regex = /google_ad_client\s*=\s*"ca-pub-(\d*)";/g;
|
553 |
+
const str = content;
|
554 |
+
var m;
|
555 |
+
var result = {};
|
556 |
+
|
557 |
+
while ((m = regex.exec(str)) !== null) {
|
558 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
559 |
+
if (m.index === regex.lastIndex) {
|
560 |
+
regex.lastIndex++;
|
561 |
+
}
|
562 |
+
|
563 |
+
// The result can be accessed through the `m`-variable.
|
564 |
+
m.forEach(function(match, index){
|
565 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
566 |
+
console.log(match);
|
567 |
+
result = match;
|
568 |
+
});
|
569 |
+
}
|
570 |
+
return result;
|
571 |
+
}
|
572 |
+
function get_google_ad_width(content) {
|
573 |
+
const regex = /google_ad_width\s*=\s*(\d*);/g;
|
574 |
+
const str = content;
|
575 |
+
var m;
|
576 |
+
var result = {};
|
577 |
+
|
578 |
+
while ((m = regex.exec(str)) !== null) {
|
579 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
580 |
+
if (m.index === regex.lastIndex) {
|
581 |
+
regex.lastIndex++;
|
582 |
+
}
|
583 |
+
|
584 |
+
// The result can be accessed through the `m`-variable.
|
585 |
+
m.forEach(function(match, index){
|
586 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
587 |
+
console.log(match);
|
588 |
+
result = match;
|
589 |
+
});
|
590 |
+
}
|
591 |
+
return result;
|
592 |
+
}
|
593 |
+
function get_google_ad_height(content) {
|
594 |
+
const regex = /google_ad_height\s*=\s*(\d*);/g;
|
595 |
+
const str = content;
|
596 |
+
var m;
|
597 |
+
var result = {};
|
598 |
+
|
599 |
+
while ((m = regex.exec(str)) !== null) {
|
600 |
+
// This is necessary to avoid infinite loops with zero-width matches
|
601 |
+
if (m.index === regex.lastIndex) {
|
602 |
+
regex.lastIndex++;
|
603 |
+
}
|
604 |
+
|
605 |
+
// The result can be accessed through the `m`-variable.
|
606 |
+
m.forEach(function(match, index){
|
607 |
+
//console.log(`Found match, group ${groupIndex}: ${match}`);
|
608 |
+
console.log(match);
|
609 |
+
result = match;
|
610 |
+
});
|
611 |
+
}
|
612 |
+
return result;
|
613 |
+
}
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Check if return value is empty or not
|
617 |
+
* @param {type} str
|
618 |
+
* @returns {Boolean}
|
619 |
+
*/
|
620 |
+
function quadsIsEmpty(str) {
|
621 |
+
return (!str || 0 === str.length);
|
622 |
+
}
|
623 |
+
|
624 |
+
// AdSense Code Input Form
|
625 |
+
$(document).on('click', '.quads-add-adsense', function (e) {
|
626 |
+
e.preventDefault();
|
627 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
628 |
+
// Empty the ad plain text form
|
629 |
+
$('#quads-adsense-form').val('');
|
630 |
+
$('#quads-adsense-id').val(parentContainerID);
|
631 |
+
$('#quads-adsense-bg-div').show();
|
632 |
+
});
|
633 |
+
$(document).on('click', '#quads-close-button', function (e) {
|
634 |
+
e.preventDefault();
|
635 |
+
$('#quads-adsense-bg-div').hide();
|
636 |
+
});
|
637 |
+
|
638 |
+
|
639 |
+
// Toggle between AdSense or Plain Text option
|
640 |
+
$(document).on('click', '.quads_adsense_type', function () {
|
641 |
+
|
642 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
643 |
+
|
644 |
+
if ($(this).val() === 'adsense') {
|
645 |
+
$('#' + parentContainerID).children('textarea').hide();
|
646 |
+
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
647 |
+
$('#' + parentContainerID).find('.quads-sizes').show();
|
648 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
649 |
+
|
650 |
+
}
|
651 |
+
if ($(this).val() === 'plain_text') {
|
652 |
+
$('#' + parentContainerID).children('textarea').show();
|
653 |
+
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
654 |
+
$('#' + parentContainerID).find('.quads-sizes').hide();
|
655 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
656 |
+
}
|
657 |
+
});
|
658 |
+
|
659 |
+
|
660 |
+
// Hide or show AdSense elements on loading
|
661 |
+
$('.quads-ad-toggle-container').find('.quads_adsense_type').each(function (index, value) {
|
662 |
+
|
663 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
664 |
+
|
665 |
+
if ($(this).attr('checked') === 'checked' && $(this).val() === 'adsense') {
|
666 |
+
$('#' + parentContainerID).children('textarea').fadeOut();
|
667 |
+
$('#' + parentContainerID).find('div.quads_adsense_code').show();
|
668 |
+
}
|
669 |
+
if ($(this).attr('checked') === 'checked' && $(this).val() === 'plain_text') {
|
670 |
+
$('#' + parentContainerID).children('textarea').fadeIn();
|
671 |
+
$('#' + parentContainerID).children('div.quads_adsense_code').hide();
|
672 |
+
}
|
673 |
+
});
|
674 |
+
|
675 |
+
|
676 |
+
// Hide or show AdSense width and height on loading
|
677 |
+
$('.quads-ad-toggle-container').find('.quads-select-Type').each(function (index, value) {
|
678 |
+
|
679 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
680 |
+
|
681 |
+
if ($(this).val() === 'responsive') {
|
682 |
+
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
683 |
+
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
684 |
+
$('#' + parentContainerID).find('.quads-sizes').show();
|
685 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
686 |
+
}
|
687 |
+
if ($(this).val() === 'normal') {
|
688 |
+
$('#' + parentContainerID).find('.quads-type-normal').show();
|
689 |
+
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
690 |
+
$('#' + parentContainerID).find('.quads-sizes').hide();
|
691 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
692 |
+
}
|
693 |
+
});
|
694 |
+
|
695 |
+
|
696 |
+
// Toggle between Fixed Size or Responsive ad type
|
697 |
+
$(document).on('change', '.quads-select-Type', function () {
|
698 |
+
var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
|
699 |
+
|
700 |
+
if ($(this).val() === 'responsive') {
|
701 |
+
$('#' + parentContainerID).find('.quads-type-normal').hide();
|
702 |
+
$('#' + parentContainerID).find('.quads-pro-notice').show();
|
703 |
+
$('#' + parentContainerID).find('.quads-sizes').show();
|
704 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
|
705 |
+
}
|
706 |
+
if ($(this).val() === 'normal') {
|
707 |
+
$('#' + parentContainerID).find('.quads-type-normal').show();
|
708 |
+
$('#' + parentContainerID).find('.quads-pro-notice').hide();
|
709 |
+
$('#' + parentContainerID).find('.quads-sizes').hide();
|
710 |
+
$('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
|
711 |
+
}
|
712 |
+
});
|
713 |
+
|
714 |
+
//*[@id="quads-togglead1"]/div[2]
|
715 |
+
/**
|
716 |
+
* Toggle the adsense container
|
717 |
+
*/
|
718 |
+
//$('.quads-ad-toggle-header').click(function (e) {
|
719 |
+
$('.quads-form-table').on('click', '.quads-ad-toggle-header', function(e) {
|
720 |
+
e.preventDefault();
|
721 |
+
|
722 |
+
var container = $('#' + $(this).data('box-id'));
|
723 |
+
//console.log(container);
|
724 |
+
container.toggle(0, function () {
|
725 |
+
if (container.parents('.quads-ad-toggle-header').hasClass('quads-box-close')) {
|
726 |
+
// open the box
|
727 |
+
container.parents('.quads-ad-toggle-header').removeClass('quads-box-close');
|
728 |
+
} else {
|
729 |
+
container.parents('.quads-ad-toggle-header').addClass('quads-box-close');
|
730 |
+
}
|
731 |
+
});
|
732 |
+
});
|
733 |
+
|
734 |
+
/*
|
735 |
+
* Quick Adsense import process
|
736 |
+
*/
|
737 |
+
|
738 |
+
jQuery('.quads-import-settings').click(function (e) {
|
739 |
+
e.preventDefault();
|
740 |
+
|
741 |
+
if (!confirm('Importing settings from Quick AdSense will overwrite all your current settings. Are you sure?'))
|
742 |
+
return;
|
743 |
+
|
744 |
+
jQuery('#quads-import-settings').addClass('loading');
|
745 |
+
var data = {
|
746 |
+
action: 'quads_import_quick_adsense',
|
747 |
+
nonce: quads.nonce,
|
748 |
+
};
|
749 |
+
$.post(ajaxurl, data, function (resp, status, xhr) {
|
750 |
+
|
751 |
+
//console.log('success:' + resp + status + xhr);
|
752 |
+
quads_show_message(resp);
|
753 |
+
|
754 |
+
}).fail(function (xhr) { // Will be executed when $.post() fails
|
755 |
+
quads_show_message('Ajax Error: ' + xhr.status + ' ' + xhr.statusText);
|
756 |
+
//console.log('error: ' + xhr.statusText);
|
757 |
+
});
|
758 |
+
});
|
759 |
+
|
760 |
+
jQuery('#quads_insert_ads_action').click(function (e) {
|
761 |
+
e.preventDefault();
|
762 |
+
jQuery('#quads_insert_ads_box').toggle();
|
763 |
+
});
|
764 |
+
|
765 |
+
jQuery('#quads_disable_ads_action').click(function (e) {
|
766 |
+
e.preventDefault();
|
767 |
+
jQuery('#quads_disable_ads_box').toggle();
|
768 |
+
});
|
769 |
+
|
770 |
+
|
771 |
+
/**
|
772 |
+
* Show error message and die()
|
773 |
+
* Writes error message into log file
|
774 |
+
*
|
775 |
+
* @param {string} $error notice
|
776 |
+
* @returns void
|
777 |
+
*/
|
778 |
+
function quads_show_message(error) {
|
779 |
+
$('#quads-error-details').show();
|
780 |
+
$('#quads-error-details').html(error);
|
781 |
+
console.log(error);
|
782 |
+
}
|
783 |
+
|
784 |
+
|
785 |
+
/**
|
786 |
+
* Start easytabs()
|
787 |
+
*/
|
788 |
+
if ($(".quads-tabs").length) {
|
789 |
+
$('#quads_tab_container').easytabs({
|
790 |
+
animate: true,
|
791 |
+
updateHash: true,
|
792 |
+
animationSpeed: 'fast'
|
793 |
+
});
|
794 |
+
}
|
795 |
+
|
796 |
+
|
797 |
+
|
798 |
+
|
799 |
+
}); // document ready
|
800 |
+
|
801 |
+
/*
|
802 |
+
* jQuery hashchange event - v1.3 - 7/21/2010
|
803 |
+
* http://benalman.com/projects/jquery-hashchange-plugin/
|
804 |
+
*
|
805 |
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
806 |
+
* Dual licensed under the MIT and GPL licenses.
|
807 |
+
* http://benalman.com/about/license/
|
808 |
+
*/
|
809 |
+
(function ($, e, b) {
|
810 |
+
var c = "hashchange", h = document, f, g = $.event.special, i = h.documentMode, d = "on" + c in e && (i === b || i > 7);
|
811 |
+
function a(j) {
|
812 |
+
j = j || location.href;
|
813 |
+
return"#" + j.replace(/^[^#]*#?(.*)$/, "$1")
|
814 |
+
}
|
815 |
+
$.fn[c] = function (j) {
|
816 |
+
return j ? this.bind(c, j) : this.trigger(c)
|
817 |
+
};
|
818 |
+
$.fn[c].delay = 50;
|
819 |
+
g[c] = $.extend(g[c], {setup: function () {
|
820 |
+
if (d) {
|
821 |
+
return false
|
822 |
+
}
|
823 |
+
$(f.start)
|
824 |
+
}, teardown: function () {
|
825 |
+
if (d) {
|
826 |
+
return false
|
827 |
+
}
|
828 |
+
$(f.stop)
|
829 |
+
}});
|
830 |
+
f = (function () {
|
831 |
+
var j = {}, p, m = a(), k = function (q) {
|
832 |
+
return q
|
833 |
+
}, l = k, o = k;
|
834 |
+
j.start = function () {
|
835 |
+
p || n()
|
836 |
+
};
|
837 |
+
j.stop = function () {
|
838 |
+
p && clearTimeout(p);
|
839 |
+
p = b
|
840 |
+
};
|
841 |
+
function n() {
|
842 |
+
var r = a(), q = o(m);
|
843 |
+
if (r !== m) {
|
844 |
+
l(m = r, q);
|
845 |
+
$(e).trigger(c)
|
846 |
+
} else {
|
847 |
+
if (q !== m) {
|
848 |
+
location.href = location.href.replace(/#.*/, "") + q
|
849 |
+
}
|
850 |
+
}
|
851 |
+
p = setTimeout(n, $.fn[c].delay)
|
852 |
+
}
|
853 |
+
$.browser.msie && !d && (function () {
|
854 |
+
var q, r;
|
855 |
+
j.start = function () {
|
856 |
+
if (!q) {
|
857 |
+
r = $.fn[c].src;
|
858 |
+
r = r && r + a();
|
859 |
+
q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
|
860 |
+
r || l(a());
|
861 |
+
n()
|
862 |
+
}).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
|
863 |
+
h.onpropertychange = function () {
|
864 |
+
try {
|
865 |
+
if (event.propertyName === "title") {
|
866 |
+
q.document.title = h.title
|
867 |
+
}
|
868 |
+
} catch (s) {
|
869 |
+
}
|
870 |
+
}
|
871 |
+
}
|
872 |
+
};
|
873 |
+
j.stop = k;
|
874 |
+
o = function () {
|
875 |
+
return a(q.location.href)
|
876 |
+
};
|
877 |
+
l = function (v, s) {
|
878 |
+
var u = q.document, t = $.fn[c].domain;
|
879 |
+
if (v !== s) {
|
880 |
+
u.title = h.title;
|
881 |
+
u.open();
|
882 |
+
t && u.write('<script>document.domain="' + t + '"<\/script>');
|
883 |
+
u.close();
|
884 |
+
q.location.hash = v
|
885 |
+
}
|
886 |
+
}
|
887 |
+
})();
|
888 |
+
return j
|
889 |
+
})()
|
890 |
+
})(jQuery, this);
|
891 |
+
|
892 |
+
/*
|
893 |
+
* jQuery EasyTabs plugin 3.2.0
|
894 |
+
*
|
895 |
+
* Copyright (c) 2010-2011 Steve Schwartz (JangoSteve)
|
896 |
+
*
|
897 |
+
* Dual licensed under the MIT and GPL licenses:
|
898 |
+
* http://www.opensource.org/licenses/mit-license.php
|
899 |
+
* http://www.gnu.org/licenses/gpl.html
|
900 |
+
*
|
901 |
+
* Date: Thu May 09 17:30:00 2013 -0500
|
902 |
+
*/
|
903 |
+
(function (a) {
|
904 |
+
a.easytabs = function (j, e) {
|
905 |
+
var f = this, q = a(j), i = {animate: true, panelActiveClass: "active", tabActiveClass: "active", defaultTab: "li:first-child", animationSpeed: "fast", tabs: "> ul > li", updateHash: true, cycle: false, collapsible: false, collapsedClass: "collapsed", collapsedByDefault: true, uiTabs: false, transitionIn: "fadeIn", transitionOut: "fadeOut", transitionInEasing: "swing", transitionOutEasing: "swing", transitionCollapse: "slideUp", transitionUncollapse: "slideDown", transitionCollapseEasing: "swing", transitionUncollapseEasing: "swing", containerClass: "", tabsClass: "", tabClass: "", panelClass: "", cache: true, event: "click", panelContext: q}, h, l, v, m, d, t = {fast: 200, normal: 400, slow: 600}, r;
|
906 |
+
f.init = function () {
|
907 |
+
f.settings = r = a.extend({}, i, e);
|
908 |
+
r.bind_str = r.event + ".easytabs";
|
909 |
+
if (r.uiTabs) {
|
910 |
+
r.tabActiveClass = "ui-tabs-selected";
|
911 |
+
r.containerClass = "ui-tabs ui-widget ui-widget-content ui-corner-all";
|
912 |
+
r.tabsClass = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all";
|
913 |
+
r.tabClass = "ui-state-default ui-corner-top";
|
914 |
+
r.panelClass = "ui-tabs-panel ui-widget-content ui-corner-bottom"
|
915 |
+
}
|
916 |
+
if (r.collapsible && e.defaultTab !== undefined && e.collpasedByDefault === undefined) {
|
917 |
+
r.collapsedByDefault = false
|
918 |
+
}
|
919 |
+
if (typeof (r.animationSpeed) === "string") {
|
920 |
+
r.animationSpeed = t[r.animationSpeed]
|
921 |
+
}
|
922 |
+
a("a.anchor").remove().prependTo("body");
|
923 |
+
q.data("easytabs", {});
|
924 |
+
f.setTransitions();
|
925 |
+
f.getTabs();
|
926 |
+
b();
|
927 |
+
g();
|
928 |
+
w();
|
929 |
+
n();
|
930 |
+
c();
|
931 |
+
q.attr("data-easytabs", true)
|
932 |
+
};
|
933 |
+
f.setTransitions = function () {
|
934 |
+
v = (r.animate) ? {show: r.transitionIn, hide: r.transitionOut, speed: r.animationSpeed, collapse: r.transitionCollapse, uncollapse: r.transitionUncollapse, halfSpeed: r.animationSpeed / 2} : {show: "show", hide: "hide", speed: 0, collapse: "hide", uncollapse: "show", halfSpeed: 0}
|
935 |
+
};
|
936 |
+
f.getTabs = function () {
|
937 |
+
var x;
|
938 |
+
f.tabs = q.find(r.tabs), f.panels = a(), f.tabs.each(function () {
|
939 |
+
var A = a(this), z = A.children("a"), y = A.children("a").data("target");
|
940 |
+
A.data("easytabs", {});
|
941 |
+
if (y !== undefined && y !== null) {
|
942 |
+
A.data("easytabs").ajax = z.attr("href")
|
943 |
+
} else {
|
944 |
+
y = z.attr("href")
|
945 |
+
}
|
946 |
+
y = y.match(/#([^\?]+)/)[1];
|
947 |
+
x = r.panelContext.find("#" + y);
|
948 |
+
if (x.length) {
|
949 |
+
x.data("easytabs", {position: x.css("position"), visibility: x.css("visibility")});
|
950 |
+
x.not(r.panelActiveClass).hide();
|
951 |
+
f.panels = f.panels.add(x);
|
952 |
+
A.data("easytabs").panel = x
|
953 |
+
} else {
|
954 |
+
f.tabs = f.tabs.not(A);
|
955 |
+
if ("console" in window) {
|
956 |
+
console.warn("Warning: tab without matching panel for selector '#" + y + "' removed from set")
|
957 |
+
}
|
958 |
+
}
|
959 |
+
})
|
960 |
+
};
|
961 |
+
f.selectTab = function (x, C) {
|
962 |
+
var y = window.location, B = y.hash.match(/^[^\?]*/)[0], z = x.parent().data("easytabs").panel, A = x.parent().data("easytabs").ajax;
|
963 |
+
if (r.collapsible && !d && (x.hasClass(r.tabActiveClass) || x.hasClass(r.collapsedClass))) {
|
964 |
+
f.toggleTabCollapse(x, z, A, C)
|
965 |
+
} else {
|
966 |
+
if (!x.hasClass(r.tabActiveClass) || !z.hasClass(r.panelActiveClass)) {
|
967 |
+
o(x, z, A, C)
|
968 |
+
} else {
|
969 |
+
if (!r.cache) {
|
970 |
+
o(x, z, A, C)
|
971 |
+
}
|
972 |
+
}
|
973 |
+
}
|
974 |
+
};
|
975 |
+
f.toggleTabCollapse = function (x, y, z, A) {
|
976 |
+
f.panels.stop(true, true);
|
977 |
+
if (u(q, "easytabs:before", [x, y, r])) {
|
978 |
+
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
979 |
+
if (x.hasClass(r.collapsedClass)) {
|
980 |
+
if (z && (!r.cache || !x.parent().data("easytabs").cached)) {
|
981 |
+
q.trigger("easytabs:ajax:beforeSend", [x, y]);
|
982 |
+
y.load(z, function (C, B, D) {
|
983 |
+
x.parent().data("easytabs").cached = true;
|
984 |
+
q.trigger("easytabs:ajax:complete", [x, y, C, B, D])
|
985 |
+
})
|
986 |
+
}
|
987 |
+
x.parent().removeClass(r.collapsedClass).addClass(r.tabActiveClass).children().removeClass(r.collapsedClass).addClass(r.tabActiveClass);
|
988 |
+
y.addClass(r.panelActiveClass)[v.uncollapse](v.speed, r.transitionUncollapseEasing, function () {
|
989 |
+
q.trigger("easytabs:midTransition", [x, y, r]);
|
990 |
+
if (typeof A == "function") {
|
991 |
+
A()
|
992 |
+
}
|
993 |
+
})
|
994 |
+
} else {
|
995 |
+
x.addClass(r.collapsedClass).parent().addClass(r.collapsedClass);
|
996 |
+
y.removeClass(r.panelActiveClass)[v.collapse](v.speed, r.transitionCollapseEasing, function () {
|
997 |
+
q.trigger("easytabs:midTransition", [x, y, r]);
|
998 |
+
if (typeof A == "function") {
|
999 |
+
A()
|
1000 |
+
}
|
1001 |
+
})
|
1002 |
+
}
|
1003 |
+
}
|
1004 |
+
};
|
1005 |
+
f.matchTab = function (x) {
|
1006 |
+
return f.tabs.find("[href='" + x + "'],[data-target='" + x + "']").first()
|
1007 |
+
};
|
1008 |
+
f.matchInPanel = function (x) {
|
1009 |
+
return(x && f.validId(x) ? f.panels.filter(":has(" + x + ")").first() : [])
|
1010 |
+
};
|
1011 |
+
f.validId = function (x) {
|
1012 |
+
return x.substr(1).match(/^[A-Za-z]+[A-Za-z0-9\-_:\.].$/)
|
1013 |
+
};
|
1014 |
+
f.selectTabFromHashChange = function () {
|
1015 |
+
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y), z;
|
1016 |
+
if (r.updateHash) {
|
1017 |
+
if (x.length) {
|
1018 |
+
d = true;
|
1019 |
+
f.selectTab(x)
|
1020 |
+
} else {
|
1021 |
+
z = f.matchInPanel(y);
|
1022 |
+
if (z.length) {
|
1023 |
+
y = "#" + z.attr("id");
|
1024 |
+
x = f.matchTab(y);
|
1025 |
+
d = true;
|
1026 |
+
f.selectTab(x)
|
1027 |
+
} else {
|
1028 |
+
if (!h.hasClass(r.tabActiveClass) && !r.cycle) {
|
1029 |
+
if (y === "" || f.matchTab(m).length || q.closest(y).length) {
|
1030 |
+
d = true;
|
1031 |
+
f.selectTab(l)
|
1032 |
+
}
|
1033 |
+
}
|
1034 |
+
}
|
1035 |
+
}
|
1036 |
+
}
|
1037 |
+
};
|
1038 |
+
f.cycleTabs = function (x) {
|
1039 |
+
if (r.cycle) {
|
1040 |
+
x = x % f.tabs.length;
|
1041 |
+
$tab = a(f.tabs[x]).children("a").first();
|
1042 |
+
d = true;
|
1043 |
+
f.selectTab($tab, function () {
|
1044 |
+
setTimeout(function () {
|
1045 |
+
f.cycleTabs(x + 1)
|
1046 |
+
}, r.cycle)
|
1047 |
+
})
|
1048 |
+
}
|
1049 |
+
};
|
1050 |
+
f.publicMethods = {select: function (x) {
|
1051 |
+
var y;
|
1052 |
+
if ((y = f.tabs.filter(x)).length === 0) {
|
1053 |
+
if ((y = f.tabs.find("a[href='" + x + "']")).length === 0) {
|
1054 |
+
if ((y = f.tabs.find("a" + x)).length === 0) {
|
1055 |
+
if ((y = f.tabs.find("[data-target='" + x + "']")).length === 0) {
|
1056 |
+
if ((y = f.tabs.find("a[href$='" + x + "']")).length === 0) {
|
1057 |
+
a.error("Tab '" + x + "' does not exist in tab set")
|
1058 |
+
}
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
}
|
1062 |
+
} else {
|
1063 |
+
y = y.children("a").first()
|
1064 |
+
}
|
1065 |
+
f.selectTab(y)
|
1066 |
+
}};
|
1067 |
+
var u = function (A, x, z) {
|
1068 |
+
var y = a.Event(x);
|
1069 |
+
A.trigger(y, z);
|
1070 |
+
return y.result !== false
|
1071 |
+
};
|
1072 |
+
var b = function () {
|
1073 |
+
q.addClass(r.containerClass);
|
1074 |
+
f.tabs.parent().addClass(r.tabsClass);
|
1075 |
+
f.tabs.addClass(r.tabClass);
|
1076 |
+
f.panels.addClass(r.panelClass)
|
1077 |
+
};
|
1078 |
+
var g = function () {
|
1079 |
+
var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y).parent(), z;
|
1080 |
+
if (x.length === 1) {
|
1081 |
+
h = x;
|
1082 |
+
r.cycle = false
|
1083 |
+
} else {
|
1084 |
+
z = f.matchInPanel(y);
|
1085 |
+
if (z.length) {
|
1086 |
+
y = "#" + z.attr("id");
|
1087 |
+
h = f.matchTab(y).parent()
|
1088 |
+
} else {
|
1089 |
+
h = f.tabs.parent().find(r.defaultTab);
|
1090 |
+
if (h.length === 0) {
|
1091 |
+
a.error("The specified default tab ('" + r.defaultTab + "') could not be found in the tab set ('" + r.tabs + "') out of " + f.tabs.length + " tabs.")
|
1092 |
+
}
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
l = h.children("a").first();
|
1096 |
+
p(x)
|
1097 |
+
};
|
1098 |
+
var p = function (z) {
|
1099 |
+
var y, x;
|
1100 |
+
if (r.collapsible && z.length === 0 && r.collapsedByDefault) {
|
1101 |
+
h.addClass(r.collapsedClass).children().addClass(r.collapsedClass)
|
1102 |
+
} else {
|
1103 |
+
y = a(h.data("easytabs").panel);
|
1104 |
+
x = h.data("easytabs").ajax;
|
1105 |
+
if (x && (!r.cache || !h.data("easytabs").cached)) {
|
1106 |
+
q.trigger("easytabs:ajax:beforeSend", [l, y]);
|
1107 |
+
y.load(x, function (B, A, C) {
|
1108 |
+
h.data("easytabs").cached = true;
|
1109 |
+
q.trigger("easytabs:ajax:complete", [l, y, B, A, C])
|
1110 |
+
})
|
1111 |
+
}
|
1112 |
+
h.data("easytabs").panel.show().addClass(r.panelActiveClass);
|
1113 |
+
h.addClass(r.tabActiveClass).children().addClass(r.tabActiveClass)
|
1114 |
+
}
|
1115 |
+
q.trigger("easytabs:initialised", [l, y])
|
1116 |
+
};
|
1117 |
+
var w = function () {
|
1118 |
+
f.tabs.children("a").bind(r.bind_str, function (x) {
|
1119 |
+
r.cycle = false;
|
1120 |
+
d = false;
|
1121 |
+
f.selectTab(a(this));
|
1122 |
+
x.preventDefault ? x.preventDefault() : x.returnValue = false
|
1123 |
+
})
|
1124 |
+
};
|
1125 |
+
var o = function (z, D, E, H) {
|
1126 |
+
f.panels.stop(true, true);
|
1127 |
+
if (u(q, "easytabs:before", [z, D, r])) {
|
1128 |
+
var A = f.panels.filter(":visible"), y = D.parent(), F, x, C, G, B = window.location.hash.match(/^[^\?]*/)[0];
|
1129 |
+
if (r.animate) {
|
1130 |
+
F = s(D);
|
1131 |
+
x = A.length ? k(A) : 0;
|
1132 |
+
C = F - x
|
1133 |
+
}
|
1134 |
+
m = B;
|
1135 |
+
G = function () {
|
1136 |
+
q.trigger("easytabs:midTransition", [z, D, r]);
|
1137 |
+
if (r.animate && r.transitionIn == "fadeIn") {
|
1138 |
+
if (C < 0) {
|
1139 |
+
y.animate({height: y.height() + C}, v.halfSpeed).css({"min-height": ""})
|
1140 |
+
}
|
1141 |
+
}
|
1142 |
+
if (r.updateHash && !d) {
|
1143 |
+
window.location.hash = "#" + D.attr("id")
|
1144 |
+
} else {
|
1145 |
+
d = false
|
1146 |
+
}
|
1147 |
+
D[v.show](v.speed, r.transitionInEasing, function () {
|
1148 |
+
y.css({height: "", "min-height": ""});
|
1149 |
+
q.trigger("easytabs:after", [z, D, r]);
|
1150 |
+
if (typeof H == "function") {
|
1151 |
+
H()
|
1152 |
+
}
|
1153 |
+
})
|
1154 |
+
};
|
1155 |
+
if (E && (!r.cache || !z.parent().data("easytabs").cached)) {
|
1156 |
+
q.trigger("easytabs:ajax:beforeSend", [z, D]);
|
1157 |
+
D.load(E, function (J, I, K) {
|
1158 |
+
z.parent().data("easytabs").cached = true;
|
1159 |
+
q.trigger("easytabs:ajax:complete", [z, D, J, I, K])
|
1160 |
+
})
|
1161 |
+
}
|
1162 |
+
if (r.animate && r.transitionOut == "fadeOut") {
|
1163 |
+
if (C > 0) {
|
1164 |
+
y.animate({height: (y.height() + C)}, v.halfSpeed)
|
1165 |
+
} else {
|
1166 |
+
y.css({"min-height": y.height()})
|
1167 |
+
}
|
1168 |
+
}
|
1169 |
+
f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
|
1170 |
+
f.tabs.filter("." + r.collapsedClass).removeClass(r.collapsedClass).children().removeClass(r.collapsedClass);
|
1171 |
+
z.parent().addClass(r.tabActiveClass).children().addClass(r.tabActiveClass);
|
1172 |
+
f.panels.filter("." + r.panelActiveClass).removeClass(r.panelActiveClass);
|
1173 |
+
D.addClass(r.panelActiveClass);
|
1174 |
+
if (A.length) {
|
1175 |
+
A[v.hide](v.speed, r.transitionOutEasing, G)
|
1176 |
+
} else {
|
1177 |
+
D[v.uncollapse](v.speed, r.transitionUncollapseEasing, G)
|
1178 |
+
}
|
1179 |
+
}
|
1180 |
+
};
|
1181 |
+
var s = function (z) {
|
1182 |
+
if (z.data("easytabs") && z.data("easytabs").lastHeight) {
|
1183 |
+
return z.data("easytabs").lastHeight
|
1184 |
+
}
|
1185 |
+
var B = z.css("display"), y, x;
|
1186 |
+
try {
|
1187 |
+
y = a("<div></div>", {position: "absolute", visibility: "hidden", overflow: "hidden"})
|
1188 |
+
} catch (A) {
|
1189 |
+
y = a("<div></div>", {visibility: "hidden", overflow: "hidden"})
|
1190 |
+
}
|
1191 |
+
x = z.wrap(y).css({position: "relative", visibility: "hidden", display: "block"}).outerHeight();
|
1192 |
+
z.unwrap();
|
1193 |
+
z.css({position: z.data("easytabs").position, visibility: z.data("easytabs").visibility, display: B});
|
1194 |
+
z.data("easytabs").lastHeight = x;
|
1195 |
+
return x
|
1196 |
+
};
|
1197 |
+
var k = function (y) {
|
1198 |
+
var x = y.outerHeight();
|
1199 |
+
if (y.data("easytabs")) {
|
1200 |
+
y.data("easytabs").lastHeight = x
|
1201 |
+
} else {
|
1202 |
+
y.data("easytabs", {lastHeight: x})
|
1203 |
+
}
|
1204 |
+
return x
|
1205 |
+
};
|
1206 |
+
var n = function () {
|
1207 |
+
if (typeof a(window).hashchange === "function") {
|
1208 |
+
a(window).hashchange(function () {
|
1209 |
+
f.selectTabFromHashChange()
|
1210 |
+
})
|
1211 |
+
} else {
|
1212 |
+
if (a.address && typeof a.address.change === "function") {
|
1213 |
+
a.address.change(function () {
|
1214 |
+
f.selectTabFromHashChange()
|
1215 |
+
})
|
1216 |
+
}
|
1217 |
+
}
|
1218 |
+
};
|
1219 |
+
var c = function () {
|
1220 |
+
var x;
|
1221 |
+
if (r.cycle) {
|
1222 |
+
x = f.tabs.index(h);
|
1223 |
+
setTimeout(function () {
|
1224 |
+
f.cycleTabs(x + 1)
|
1225 |
+
}, r.cycle)
|
1226 |
+
}
|
1227 |
+
};
|
1228 |
+
f.init()
|
1229 |
+
};
|
1230 |
+
a.fn.easytabs = function (c) {
|
1231 |
+
var b = arguments;
|
1232 |
+
return this.each(function () {
|
1233 |
+
var e = a(this), d = e.data("easytabs");
|
1234 |
+
if (undefined === d) {
|
1235 |
+
d = new a.easytabs(this, c);
|
1236 |
+
e.data("easytabs", d)
|
1237 |
+
}
|
1238 |
+
if (d.publicMethods[c]) {
|
1239 |
+
return d.publicMethods[c](Array.prototype.slice.call(b, 1))
|
1240 |
+
}
|
1241 |
+
})
|
1242 |
+
}
|
1243 |
+
})(jQuery);
|
1244 |
+
|
1245 |
+
|
1246 |
+
/*
|
1247 |
+
colpick Color Picker
|
1248 |
+
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
|
1249 |
+
|
1250 |
+
For usage and examples: colpick.com/plugin
|
1251 |
+
*/
|
1252 |
+
|
1253 |
+
(function ($) {
|
1254 |
+
var colpick = function () {
|
1255 |
+
var
|
1256 |
+
tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
|
1257 |
+
defaults = {
|
1258 |
+
showEvent: 'click',
|
1259 |
+
onShow: function () {
|
1260 |
+
},
|
1261 |
+
onBeforeShow: function () {
|
1262 |
+
},
|
1263 |
+
onHide: function () {
|
1264 |
+
},
|
1265 |
+
onChange: function () {
|
1266 |
+
},
|
1267 |
+
onSubmit: function () {
|
1268 |
+
},
|
1269 |
+
colorScheme: 'light',
|
1270 |
+
color: '3289c7',
|
1271 |
+
livePreview: true,
|
1272 |
+
flat: false,
|
1273 |
+
layout: 'full',
|
1274 |
+
submit: 1,
|
1275 |
+
submitText: 'OK',
|
1276 |
+
height: 156
|
1277 |
+
},
|
1278 |
+
//Fill the inputs of the plugin
|
1279 |
+
fillRGBFields = function (hsb, cal) {
|
1280 |
+
var rgb = hsbToRgb(hsb);
|
1281 |
+
$(cal).data('colpick').fields
|
1282 |
+
.eq(1).val(rgb.r).end()
|
1283 |
+
.eq(2).val(rgb.g).end()
|
1284 |
+
.eq(3).val(rgb.b).end();
|
1285 |
+
},
|
1286 |
+
fillHSBFields = function (hsb, cal) {
|
1287 |
+
$(cal).data('colpick').fields
|
1288 |
+
.eq(4).val(Math.round(hsb.h)).end()
|
1289 |
+
.eq(5).val(Math.round(hsb.s)).end()
|
1290 |
+
.eq(6).val(Math.round(hsb.b)).end();
|
1291 |
+
},
|
1292 |
+
fillHexFields = function (hsb, cal) {
|
1293 |
+
$(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
|
1294 |
+
},
|
1295 |
+
//Set the round selector position
|
1296 |
+
setSelector = function (hsb, cal) {
|
1297 |
+
$(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
|
1298 |
+
$(cal).data('colpick').selectorIndic.css({
|
1299 |
+
left: parseInt($(cal).data('colpick').height * hsb.s / 100, 10),
|
1300 |
+
top: parseInt($(cal).data('colpick').height * (100 - hsb.b) / 100, 10)
|
1301 |
+
});
|
1302 |
+
},
|
1303 |
+
//Set the hue selector position
|
1304 |
+
setHue = function (hsb, cal) {
|
1305 |
+
$(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
|
1306 |
+
},
|
1307 |
+
//Set current and new colors
|
1308 |
+
setCurrentColor = function (hsb, cal) {
|
1309 |
+
$(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1310 |
+
},
|
1311 |
+
setNewColor = function (hsb, cal) {
|
1312 |
+
$(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
1313 |
+
},
|
1314 |
+
//Called when the new color is changed
|
1315 |
+
change = function (ev) {
|
1316 |
+
var cal = $(this).parent().parent(), col;
|
1317 |
+
if (this.parentNode.className.indexOf('_hex') > 0) {
|
1318 |
+
cal.data('colpick').color = col = hexToHsb(fixHex(this.value));
|
1319 |
+
fillRGBFields(col, cal.get(0));
|
1320 |
+
fillHSBFields(col, cal.get(0));
|
1321 |
+
} else if (this.parentNode.className.indexOf('_hsb') > 0) {
|
1322 |
+
cal.data('colpick').color = col = fixHSB({
|
1323 |
+
h: parseInt(cal.data('colpick').fields.eq(4).val(), 10),
|
1324 |
+
s: parseInt(cal.data('colpick').fields.eq(5).val(), 10),
|
1325 |
+
b: parseInt(cal.data('colpick').fields.eq(6).val(), 10)
|
1326 |
+
});
|
1327 |
+
fillRGBFields(col, cal.get(0));
|
1328 |
+
fillHexFields(col, cal.get(0));
|
1329 |
+
} else {
|
1330 |
+
cal.data('colpick').color = col = rgbToHsb(fixRGB({
|
1331 |
+
r: parseInt(cal.data('colpick').fields.eq(1).val(), 10),
|
1332 |
+
g: parseInt(cal.data('colpick').fields.eq(2).val(), 10),
|
1333 |
+
b: parseInt(cal.data('colpick').fields.eq(3).val(), 10)
|
1334 |
+
}));
|
1335 |
+
fillHexFields(col, cal.get(0));
|
1336 |
+
fillHSBFields(col, cal.get(0));
|
1337 |
+
}
|
1338 |
+
setSelector(col, cal.get(0));
|
1339 |
+
setHue(col, cal.get(0));
|
1340 |
+
setNewColor(col, cal.get(0));
|
1341 |
+
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
|
1342 |
+
},
|
1343 |
+
//Change style on blur and on focus of inputs
|
1344 |
+
blur = function (ev) {
|
1345 |
+
$(this).parent().removeClass('colpick_focus');
|
1346 |
+
},
|
1347 |
+
focus = function () {
|
1348 |
+
$(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
|
1349 |
+
$(this).parent().addClass('colpick_focus');
|
1350 |
+
},
|
1351 |
+
//Increment/decrement arrows functions
|
1352 |
+
downIncrement = function (ev) {
|
1353 |
+
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1354 |
+
var field = $(this).parent().find('input').focus();
|
1355 |
+
var current = {
|
1356 |
+
el: $(this).parent().addClass('colpick_slider'),
|
1357 |
+
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
1358 |
+
y: ev.pageY,
|
1359 |
+
field: field,
|
1360 |
+
val: parseInt(field.val(), 10),
|
1361 |
+
preview: $(this).parent().parent().data('colpick').livePreview
|
1362 |
+
};
|
1363 |
+
$(document).mouseup(current, upIncrement);
|
1364 |
+
$(document).mousemove(current, moveIncrement);
|
1365 |
+
},
|
1366 |
+
moveIncrement = function (ev) {
|
1367 |
+
ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10))));
|
1368 |
+
if (ev.data.preview) {
|
1369 |
+
change.apply(ev.data.field.get(0), [true]);
|
1370 |
+
}
|
1371 |
+
return false;
|
1372 |
+
},
|
1373 |
+
upIncrement = function (ev) {
|
1374 |
+
change.apply(ev.data.field.get(0), [true]);
|
1375 |
+
ev.data.el.removeClass('colpick_slider').find('input').focus();
|
1376 |
+
$(document).off('mouseup', upIncrement);
|
1377 |
+
$(document).off('mousemove', moveIncrement);
|
1378 |
+
return false;
|
1379 |
+
},
|
1380 |
+
//Hue slider functions
|
1381 |
+
downHue = function (ev) {
|
1382 |
+
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1383 |
+
var current = {
|
1384 |
+
cal: $(this).parent(),
|
1385 |
+
y: $(this).offset().top
|
1386 |
+
};
|
1387 |
+
$(document).on('mouseup touchend', current, upHue);
|
1388 |
+
$(document).on('mousemove touchmove', current, moveHue);
|
1389 |
+
|
1390 |
+
var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1391 |
+
change.apply(
|
1392 |
+
current.cal.data('colpick')
|
1393 |
+
.fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height - (pageY - current.y)) / current.cal.data('colpick').height, 10))
|
1394 |
+
.get(0),
|
1395 |
+
[current.cal.data('colpick').livePreview]
|
1396 |
+
);
|
1397 |
+
return false;
|
1398 |
+
},
|
1399 |
+
moveHue = function (ev) {
|
1400 |
+
var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
|
1401 |
+
change.apply(
|
1402 |
+
ev.data.cal.data('colpick')
|
1403 |
+
.fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) / ev.data.cal.data('colpick').height, 10))
|
1404 |
+
.get(0),
|
1405 |
+
[ev.data.preview]
|
1406 |
+
);
|
1407 |
+
return false;
|
1408 |
+
},
|
1409 |
+
upHue = function (ev) {
|
1410 |
+
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1411 |
+
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1412 |
+
$(document).off('mouseup touchend', upHue);
|
1413 |
+
$(document).off('mousemove touchmove', moveHue);
|
1414 |
+
return false;
|
1415 |
+
},
|
1416 |
+
//Color selector functions
|
1417 |
+
downSelector = function (ev) {
|
1418 |
+
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
1419 |
+
var current = {
|
1420 |
+
cal: $(this).parent(),
|
1421 |
+
pos: $(this).offset()
|
1422 |
+
};
|
1423 |
+
current.preview = current.cal.data('colpick').livePreview;
|
1424 |
+
|
1425 |
+
$(document).on('mouseup touchend', current, upSelector);
|
1426 |
+
$(document).on('mousemove touchmove', current, moveSelector);
|
1427 |
+
|
1428 |
+
var payeX, pageY;
|
1429 |
+
if (ev.type == 'touchstart') {
|
1430 |
+
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1431 |
+
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1432 |
+
} else {
|
1433 |
+
pageX = ev.pageX;
|
1434 |
+
pageY = ev.pageY;
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
change.apply(
|
1438 |
+
current.cal.data('colpick').fields
|
1439 |
+
.eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) / current.cal.data('colpick').height, 10)).end()
|
1440 |
+
.eq(5).val(parseInt(100 * (pageX - current.pos.left) / current.cal.data('colpick').height, 10))
|
1441 |
+
.get(0),
|
1442 |
+
[current.preview]
|
1443 |
+
);
|
1444 |
+
return false;
|
1445 |
+
},
|
1446 |
+
moveSelector = function (ev) {
|
1447 |
+
var payeX, pageY;
|
1448 |
+
if (ev.type == 'touchmove') {
|
1449 |
+
pageX = ev.originalEvent.changedTouches[0].pageX,
|
1450 |
+
pageY = ev.originalEvent.changedTouches[0].pageY;
|
1451 |
+
} else {
|
1452 |
+
pageX = ev.pageX;
|
1453 |
+
pageY = ev.pageY;
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
change.apply(
|
1457 |
+
ev.data.cal.data('colpick').fields
|
1458 |
+
.eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) / ev.data.cal.data('colpick').height, 10)).end()
|
1459 |
+
.eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
|
1460 |
+
.get(0),
|
1461 |
+
[ev.data.preview]
|
1462 |
+
);
|
1463 |
+
return false;
|
1464 |
+
},
|
1465 |
+
upSelector = function (ev) {
|
1466 |
+
fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1467 |
+
fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
|
1468 |
+
$(document).off('mouseup touchend', upSelector);
|
1469 |
+
$(document).off('mousemove touchmove', moveSelector);
|
1470 |
+
return false;
|
1471 |
+
},
|
1472 |
+
//Submit button
|
1473 |
+
clickSubmit = function (ev) {
|
1474 |
+
var cal = $(this).parent();
|
1475 |
+
var col = cal.data('colpick').color;
|
1476 |
+
cal.data('colpick').origColor = col;
|
1477 |
+
setCurrentColor(col, cal.get(0));
|
1478 |
+
cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
|
1479 |
+
},
|
1480 |
+
//Show/hide the color picker
|
1481 |
+
show = function (ev) {
|
1482 |
+
// Prevent the trigger of any direct parent
|
1483 |
+
ev.stopPropagation();
|
1484 |
+
var cal = $('#' + $(this).data('colpickId'));
|
1485 |
+
cal.data('colpick').onBeforeShow.apply(this, [cal.get(0)]);
|
1486 |
+
var pos = $(this).offset();
|
1487 |
+
var top = pos.top + this.offsetHeight;
|
1488 |
+
var left = pos.left;
|
1489 |
+
var viewPort = getViewport();
|
1490 |
+
var calW = cal.width();
|
1491 |
+
if (left + calW > viewPort.l + viewPort.w) {
|
1492 |
+
left -= calW;
|
1493 |
+
}
|
1494 |
+
cal.css({left: left + 'px', top: top + 'px'});
|
1495 |
+
if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
|
1496 |
+
cal.show();
|
1497 |
+
}
|
1498 |
+
//Hide when user clicks outside
|
1499 |
+
$('html').mousedown({cal: cal}, hide);
|
1500 |
+
cal.mousedown(function (ev) {
|
1501 |
+
ev.stopPropagation();
|
1502 |
+
})
|
1503 |
+
},
|
1504 |
+
hide = function (ev) {
|
1505 |
+
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
1506 |
+
ev.data.cal.hide();
|
1507 |
+
}
|
1508 |
+
$('html').off('mousedown', hide);
|
1509 |
+
},
|
1510 |
+
getViewport = function () {
|
1511 |
+
var m = document.compatMode == 'CSS1Compat';
|
1512 |
+
return {
|
1513 |
+
l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
1514 |
+
w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
|
1515 |
+
};
|
1516 |
+
},
|
1517 |
+
//Fix the values if the user enters a negative or high value
|
1518 |
+
fixHSB = function (hsb) {
|
1519 |
+
return {
|
1520 |
+
h: Math.min(360, Math.max(0, hsb.h)),
|
1521 |
+
s: Math.min(100, Math.max(0, hsb.s)),
|
1522 |
+
b: Math.min(100, Math.max(0, hsb.b))
|
1523 |
+
};
|
1524 |
+
},
|
1525 |
+
fixRGB = function (rgb) {
|
1526 |
+
return {
|
1527 |
+
r: Math.min(255, Math.max(0, rgb.r)),
|
1528 |
+
g: Math.min(255, Math.max(0, rgb.g)),
|
1529 |
+
b: Math.min(255, Math.max(0, rgb.b))
|
1530 |
+
};
|
1531 |
+
},
|
1532 |
+
fixHex = function (hex) {
|
1533 |
+
var len = 6 - hex.length;
|
1534 |
+
if (len > 0) {
|
1535 |
+
var o = [];
|
1536 |
+
for (var i = 0; i < len; i++) {
|
1537 |
+
o.push('0');
|
1538 |
+
}
|
1539 |
+
o.push(hex);
|
1540 |
+
hex = o.join('');
|
1541 |
+
}
|
1542 |
+
return hex;
|
1543 |
+
},
|
1544 |
+
restoreOriginal = function () {
|
1545 |
+
var cal = $(this).parent();
|
1546 |
+
var col = cal.data('colpick').origColor;
|
1547 |
+
cal.data('colpick').color = col;
|
1548 |
+
fillRGBFields(col, cal.get(0));
|
1549 |
+
fillHexFields(col, cal.get(0));
|
1550 |
+
fillHSBFields(col, cal.get(0));
|
1551 |
+
setSelector(col, cal.get(0));
|
1552 |
+
setHue(col, cal.get(0));
|
1553 |
+
setNewColor(col, cal.get(0));
|
1554 |
+
};
|
1555 |
+
return {
|
1556 |
+
init: function (opt) {
|
1557 |
+
opt = $.extend({}, defaults, opt || {});
|
1558 |
+
//Set color
|
1559 |
+
if (typeof opt.color == 'string') {
|
1560 |
+
opt.color = hexToHsb(opt.color);
|
1561 |
+
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
1562 |
+
opt.color = rgbToHsb(opt.color);
|
1563 |
+
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
1564 |
+
opt.color = fixHSB(opt.color);
|
1565 |
+
} else {
|
1566 |
+
return this;
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
//For each selected DOM element
|
1570 |
+
return this.each(function () {
|
1571 |
+
//If the element does not have an ID
|
1572 |
+
if (!$(this).data('colpickId')) {
|
1573 |
+
var options = $.extend({}, opt);
|
1574 |
+
options.origColor = opt.color;
|
1575 |
+
//Generate and assign a random ID
|
1576 |
+
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
1577 |
+
$(this).data('colpickId', id);
|
1578 |
+
//Set the tpl's ID and get the HTML
|
1579 |
+
var cal = $(tpl).attr('id', id);
|
1580 |
+
//Add class according to layout
|
1581 |
+
cal.addClass('colpick_' + options.layout + (options.submit ? '' : ' colpick_' + options.layout + '_ns'));
|
1582 |
+
//Add class if the color scheme is not default
|
1583 |
+
if (options.colorScheme != 'light') {
|
1584 |
+
cal.addClass('colpick_' + options.colorScheme);
|
1585 |
+
}
|
1586 |
+
//Setup submit button
|
1587 |
+
cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
|
1588 |
+
//Setup input fields
|
1589 |
+
options.fields = cal.find('input').change(change).blur(blur).focus(focus);
|
1590 |
+
cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
|
1591 |
+
//Setup hue selector
|
1592 |
+
options.selector = cal.find('div.colpick_color').on('mousedown touchstart', downSelector);
|
1593 |
+
options.selectorIndic = options.selector.find('div.colpick_selector_outer');
|
1594 |
+
//Store parts of the plugin
|
1595 |
+
options.el = this;
|
1596 |
+
options.hue = cal.find('div.colpick_hue_arrs');
|
1597 |
+
huebar = options.hue.parent();
|
1598 |
+
//Paint the hue bar
|
1599 |
+
var UA = navigator.userAgent.toLowerCase();
|
1600 |
+
var isIE = navigator.appName === 'Microsoft Internet Explorer';
|
1601 |
+
var IEver = isIE ? parseFloat(UA.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0;
|
1602 |
+
var ngIE = (isIE && IEver < 10);
|
1603 |
+
var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80', '#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
|
1604 |
+
if (ngIE) {
|
1605 |
+
var i, div;
|
1606 |
+
for (i = 0; i <= 11; i++) {
|
1607 |
+
div = $('<div></div>').attr('style', 'height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + '); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
|
1608 |
+
huebar.append(div);
|
1609 |
+
}
|
1610 |
+
} else {
|
1611 |
+
stopList = stops.join(',');
|
1612 |
+
huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList + '); background: -o-linear-gradient(top,' + stopList + '); background: -ms-linear-gradient(top,' + stopList + '); background:-moz-linear-gradient(top,' + stopList + '); -webkit-linear-gradient(top,' + stopList + '); background:linear-gradient(to bottom,' + stopList + '); ');
|
1613 |
+
}
|
1614 |
+
cal.find('div.colpick_hue').on('mousedown touchstart', downHue);
|
1615 |
+
options.newColor = cal.find('div.colpick_new_color');
|
1616 |
+
options.currentColor = cal.find('div.colpick_current_color');
|
1617 |
+
//Store options and fill with default color
|
1618 |
+
cal.data('colpick', options);
|
1619 |
+
fillRGBFields(options.color, cal.get(0));
|
1620 |
+
fillHSBFields(options.color, cal.get(0));
|
1621 |
+
fillHexFields(options.color, cal.get(0));
|
1622 |
+
setHue(options.color, cal.get(0));
|
1623 |
+
setSelector(options.color, cal.get(0));
|
1624 |
+
setCurrentColor(options.color, cal.get(0));
|
1625 |
+
setNewColor(options.color, cal.get(0));
|
1626 |
+
//Append to body if flat=false, else show in place
|
1627 |
+
if (options.flat) {
|
1628 |
+
cal.appendTo(this).show();
|
1629 |
+
cal.css({
|
1630 |
+
position: 'relative',
|
1631 |
+
display: 'block'
|
1632 |
+
});
|
1633 |
+
} else {
|
1634 |
+
cal.appendTo(document.body);
|
1635 |
+
$(this).on(options.showEvent, show);
|
1636 |
+
cal.css({
|
1637 |
+
position: 'absolute'
|
1638 |
+
});
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
});
|
1642 |
+
},
|
1643 |
+
//Shows the picker
|
1644 |
+
showPicker: function () {
|
1645 |
+
return this.each(function () {
|
1646 |
+
if ($(this).data('colpickId')) {
|
1647 |
+
show.apply(this);
|
1648 |
+
}
|
1649 |
+
});
|
1650 |
+
},
|
1651 |
+
//Hides the picker
|
1652 |
+
hidePicker: function () {
|
1653 |
+
return this.each(function () {
|
1654 |
+
if ($(this).data('colpickId')) {
|
1655 |
+
$('#' + $(this).data('colpickId')).hide();
|
1656 |
+
}
|
1657 |
+
});
|
1658 |
+
},
|
1659 |
+
//Sets a color as new and current (default)
|
1660 |
+
setColor: function (col, setCurrent) {
|
1661 |
+
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
1662 |
+
if (typeof col == 'string') {
|
1663 |
+
col = hexToHsb(col);
|
1664 |
+
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
1665 |
+
col = rgbToHsb(col);
|
1666 |
+
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
1667 |
+
col = fixHSB(col);
|
1668 |
+
} else {
|
1669 |
+
return this;
|
1670 |
+
}
|
1671 |
+
return this.each(function () {
|
1672 |
+
if ($(this).data('colpickId')) {
|
1673 |
+
var cal = $('#' + $(this).data('colpickId'));
|
1674 |
+
cal.data('colpick').color = col;
|
1675 |
+
cal.data('colpick').origColor = col;
|
1676 |
+
fillRGBFields(col, cal.get(0));
|
1677 |
+
fillHSBFields(col, cal.get(0));
|
1678 |
+
fillHexFields(col, cal.get(0));
|
1679 |
+
setHue(col, cal.get(0));
|
1680 |
+
setSelector(col, cal.get(0));
|
1681 |
+
|
1682 |
+
setNewColor(col, cal.get(0));
|
1683 |
+
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
|
1684 |
+
if (setCurrent) {
|
1685 |
+
setCurrentColor(col, cal.get(0));
|
1686 |
+
}
|
1687 |
+
}
|
1688 |
+
});
|
1689 |
+
}
|
1690 |
+
};
|
1691 |
+
}();
|
1692 |
+
//Color space convertions
|
1693 |
+
var hexToRgb = function (hex) {
|
1694 |
+
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
1695 |
+
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
1696 |
+
};
|
1697 |
+
var hexToHsb = function (hex) {
|
1698 |
+
return rgbToHsb(hexToRgb(hex));
|
1699 |
+
};
|
1700 |
+
var rgbToHsb = function (rgb) {
|
1701 |
+
var hsb = {h: 0, s: 0, b: 0};
|
1702 |
+
var min = Math.min(rgb.r, rgb.g, rgb.b);
|
1703 |
+
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
1704 |
+
var delta = max - min;
|
1705 |
+
hsb.b = max;
|
1706 |
+
hsb.s = max != 0 ? 255 * delta / max : 0;
|
1707 |
+
if (hsb.s != 0) {
|
1708 |
+
if (rgb.r == max)
|
1709 |
+
hsb.h = (rgb.g - rgb.b) / delta;
|
1710 |
+
else if (rgb.g == max)
|
1711 |
+
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
1712 |
+
else
|
1713 |
+
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
1714 |
+
} else
|
1715 |
+
hsb.h = -1;
|
1716 |
+
hsb.h *= 60;
|
1717 |
+
if (hsb.h < 0)
|
1718 |
+
hsb.h += 360;
|
1719 |
+
hsb.s *= 100 / 255;
|
1720 |
+
hsb.b *= 100 / 255;
|
1721 |
+
return hsb;
|
1722 |
+
};
|
1723 |
+
var hsbToRgb = function (hsb) {
|
1724 |
+
var rgb = {};
|
1725 |
+
var h = hsb.h;
|
1726 |
+
var s = hsb.s * 255 / 100;
|
1727 |
+
var v = hsb.b * 255 / 100;
|
1728 |
+
if (s == 0) {
|
1729 |
+
rgb.r = rgb.g = rgb.b = v;
|
1730 |
+
} else {
|
1731 |
+
var t1 = v;
|
1732 |
+
var t2 = (255 - s) * v / 255;
|
1733 |
+
var t3 = (t1 - t2) * (h % 60) / 60;
|
1734 |
+
if (h == 360)
|
1735 |
+
h = 0;
|
1736 |
+
if (h < 60) {
|
1737 |
+
rgb.r = t1;
|
1738 |
+
rgb.b = t2;
|
1739 |
+
rgb.g = t2 + t3
|
1740 |
+
} else if (h < 120) {
|
1741 |
+
rgb.g = t1;
|
1742 |
+
rgb.b = t2;
|
1743 |
+
rgb.r = t1 - t3
|
1744 |
+
} else if (h < 180) {
|
1745 |
+
rgb.g = t1;
|
1746 |
+
rgb.r = t2;
|
1747 |
+
rgb.b = t2 + t3
|
1748 |
+
} else if (h < 240) {
|
1749 |
+
rgb.b = t1;
|
1750 |
+
rgb.r = t2;
|
1751 |
+
rgb.g = t1 - t3
|
1752 |
+
} else if (h < 300) {
|
1753 |
+
rgb.b = t1;
|
1754 |
+
rgb.g = t2;
|
1755 |
+
rgb.r = t2 + t3
|
1756 |
+
} else if (h < 360) {
|
1757 |
+
rgb.r = t1;
|
1758 |
+
rgb.g = t2;
|
1759 |
+
rgb.b = t1 - t3
|
1760 |
+
} else {
|
1761 |
+
rgb.r = 0;
|
1762 |
+
rgb.g = 0;
|
1763 |
+
rgb.b = 0
|
1764 |
+
}
|
1765 |
+
}
|
1766 |
+
return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
|
1767 |
+
};
|
1768 |
+
var rgbToHex = function (rgb) {
|
1769 |
+
var hex = [
|
1770 |
+
rgb.r.toString(16),
|
1771 |
+
rgb.g.toString(16),
|
1772 |
+
rgb.b.toString(16)
|
1773 |
+
];
|
1774 |
+
$.each(hex, function (nr, val) {
|
1775 |
+
if (val.length == 1) {
|
1776 |
+
hex[nr] = '0' + val;
|
1777 |
+
}
|
1778 |
+
});
|
1779 |
+
return hex.join('');
|
1780 |
+
};
|
1781 |
+
var hsbToHex = function (hsb) {
|
1782 |
+
return rgbToHex(hsbToRgb(hsb));
|
1783 |
+
};
|
1784 |
+
$.fn.extend({
|
1785 |
+
colpick: colpick.init,
|
1786 |
+
colpickHide: colpick.hidePicker,
|
1787 |
+
colpickShow: colpick.showPicker,
|
1788 |
+
colpickSetColor: colpick.setColor
|
1789 |
+
});
|
1790 |
+
$.extend({
|
1791 |
+
colpick: {
|
1792 |
+
rgbToHex: rgbToHex,
|
1793 |
+
rgbToHsb: rgbToHsb,
|
1794 |
+
hsbToHex: hsbToHex,
|
1795 |
+
hsbToRgb: hsbToRgb,
|
1796 |
+
hexToHsb: hexToHsb,
|
1797 |
+
hexToRgb: hexToRgb
|
1798 |
+
}
|
1799 |
+
});
|
1800 |
})(jQuery);
|
assets/js/quads-plugins-admin.js
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
var strict;
|
2 |
-
|
3 |
-
jQuery(document).ready(function ($) {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* DEACTIVATION FEEDBACK FORM
|
7 |
-
*/
|
8 |
-
// show overlay when clicked on "deactivate"
|
9 |
-
quads_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="quick-adsense-reloaded"] .row-actions .deactivate a');
|
10 |
-
quads_deactivate_link_url = quads_deactivate_link.attr('href');
|
11 |
-
|
12 |
-
quads_deactivate_link.click(function (e) {
|
13 |
-
e.preventDefault();
|
14 |
-
|
15 |
-
// only show feedback form once per 30 days
|
16 |
-
var c_value = quads_admin_get_cookie("quads_hide_deactivate_feedback");
|
17 |
-
|
18 |
-
if (c_value === undefined) {
|
19 |
-
$('#quick-adsense-reloaded-feedback-overlay').show();
|
20 |
-
} else {
|
21 |
-
// click on the link
|
22 |
-
window.location.href = quads_deactivate_link_url;
|
23 |
-
}
|
24 |
-
});
|
25 |
-
// show text fields
|
26 |
-
$('#quick-adsense-reloaded-feedback-content input[type="radio"]').click(function () {
|
27 |
-
// show text field if there is one
|
28 |
-
$(this).parents('li').next('li').children('input[type="text"], textarea').show();
|
29 |
-
});
|
30 |
-
// send form or close it
|
31 |
-
$('#quick-adsense-reloaded-feedback-content .button').click(function (e) {
|
32 |
-
e.preventDefault();
|
33 |
-
// set cookie for 30 days
|
34 |
-
var exdate = new Date();
|
35 |
-
exdate.setSeconds(exdate.getSeconds() + 2592000);
|
36 |
-
document.cookie = "quads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
|
37 |
-
|
38 |
-
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
39 |
-
if ('quick-adsense-reloaded-feedback-submit' === this.id) {
|
40 |
-
// Send form data
|
41 |
-
$.ajax({
|
42 |
-
type: 'POST',
|
43 |
-
url: ajaxurl,
|
44 |
-
dataType: 'json',
|
45 |
-
data: {
|
46 |
-
action: 'quads_send_feedback',
|
47 |
-
data: $('#quick-adsense-reloaded-feedback-content form').serialize()
|
48 |
-
},
|
49 |
-
complete: function (MLHttpRequest, textStatus, errorThrown) {
|
50 |
-
// deactivate the plugin and close the popup
|
51 |
-
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
52 |
-
window.location.href = quads_deactivate_link_url;
|
53 |
-
|
54 |
-
}
|
55 |
-
});
|
56 |
-
} else {
|
57 |
-
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
58 |
-
window.location.href = quads_deactivate_link_url;
|
59 |
-
}
|
60 |
-
});
|
61 |
-
// close form without doing anything
|
62 |
-
$('.quick-adsense-reloaded-feedback-not-deactivate').click(function (e) {
|
63 |
-
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
64 |
-
});
|
65 |
-
|
66 |
-
function quads_admin_get_cookie (name) {
|
67 |
-
var i, x, y, quads_cookies = document.cookie.split( ";" );
|
68 |
-
for (i = 0; i < quads_cookies.length; i++)
|
69 |
-
{
|
70 |
-
x = quads_cookies[i].substr( 0, quads_cookies[i].indexOf( "=" ) );
|
71 |
-
y = quads_cookies[i].substr( quads_cookies[i].indexOf( "=" ) + 1 );
|
72 |
-
x = x.replace( /^\s+|\s+$/g, "" );
|
73 |
-
if (x === name)
|
74 |
-
{
|
75 |
-
return unescape( y );
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
}); // document ready
|
1 |
+
var strict;
|
2 |
+
|
3 |
+
jQuery(document).ready(function ($) {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* DEACTIVATION FEEDBACK FORM
|
7 |
+
*/
|
8 |
+
// show overlay when clicked on "deactivate"
|
9 |
+
quads_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="quick-adsense-reloaded"] .row-actions .deactivate a');
|
10 |
+
quads_deactivate_link_url = quads_deactivate_link.attr('href');
|
11 |
+
|
12 |
+
quads_deactivate_link.click(function (e) {
|
13 |
+
e.preventDefault();
|
14 |
+
|
15 |
+
// only show feedback form once per 30 days
|
16 |
+
var c_value = quads_admin_get_cookie("quads_hide_deactivate_feedback");
|
17 |
+
|
18 |
+
if (c_value === undefined) {
|
19 |
+
$('#quick-adsense-reloaded-feedback-overlay').show();
|
20 |
+
} else {
|
21 |
+
// click on the link
|
22 |
+
window.location.href = quads_deactivate_link_url;
|
23 |
+
}
|
24 |
+
});
|
25 |
+
// show text fields
|
26 |
+
$('#quick-adsense-reloaded-feedback-content input[type="radio"]').click(function () {
|
27 |
+
// show text field if there is one
|
28 |
+
$(this).parents('li').next('li').children('input[type="text"], textarea').show();
|
29 |
+
});
|
30 |
+
// send form or close it
|
31 |
+
$('#quick-adsense-reloaded-feedback-content .button').click(function (e) {
|
32 |
+
e.preventDefault();
|
33 |
+
// set cookie for 30 days
|
34 |
+
var exdate = new Date();
|
35 |
+
exdate.setSeconds(exdate.getSeconds() + 2592000);
|
36 |
+
document.cookie = "quads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
|
37 |
+
|
38 |
+
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
39 |
+
if ('quick-adsense-reloaded-feedback-submit' === this.id) {
|
40 |
+
// Send form data
|
41 |
+
$.ajax({
|
42 |
+
type: 'POST',
|
43 |
+
url: ajaxurl,
|
44 |
+
dataType: 'json',
|
45 |
+
data: {
|
46 |
+
action: 'quads_send_feedback',
|
47 |
+
data: $('#quick-adsense-reloaded-feedback-content form').serialize()
|
48 |
+
},
|
49 |
+
complete: function (MLHttpRequest, textStatus, errorThrown) {
|
50 |
+
// deactivate the plugin and close the popup
|
51 |
+
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
52 |
+
window.location.href = quads_deactivate_link_url;
|
53 |
+
|
54 |
+
}
|
55 |
+
});
|
56 |
+
} else {
|
57 |
+
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
58 |
+
window.location.href = quads_deactivate_link_url;
|
59 |
+
}
|
60 |
+
});
|
61 |
+
// close form without doing anything
|
62 |
+
$('.quick-adsense-reloaded-feedback-not-deactivate').click(function (e) {
|
63 |
+
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
64 |
+
});
|
65 |
+
|
66 |
+
function quads_admin_get_cookie (name) {
|
67 |
+
var i, x, y, quads_cookies = document.cookie.split( ";" );
|
68 |
+
for (i = 0; i < quads_cookies.length; i++)
|
69 |
+
{
|
70 |
+
x = quads_cookies[i].substr( 0, quads_cookies[i].indexOf( "=" ) );
|
71 |
+
y = quads_cookies[i].substr( quads_cookies[i].indexOf( "=" ) + 1 );
|
72 |
+
x = x.replace( /^\s+|\s+$/g, "" );
|
73 |
+
if (x === name)
|
74 |
+
{
|
75 |
+
return unescape( y );
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
}); // document ready
|
assets/js/quads-plugins-admin.min.js
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
var strict;
|
2 |
-
|
3 |
-
jQuery(document).ready(function ($) {
|
4 |
-
|
5 |
-
/**
|
6 |
-
* DEACTIVATION FEEDBACK FORM
|
7 |
-
*/
|
8 |
-
// show overlay when clicked on "deactivate"
|
9 |
-
quads_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="quick-adsense-reloaded"] .row-actions .deactivate a');
|
10 |
-
quads_deactivate_link_url = quads_deactivate_link.attr('href');
|
11 |
-
|
12 |
-
quads_deactivate_link.click(function (e) {
|
13 |
-
e.preventDefault();
|
14 |
-
|
15 |
-
// only show feedback form once per 30 days
|
16 |
-
var c_value = quads_admin_get_cookie("quads_hide_deactivate_feedback");
|
17 |
-
|
18 |
-
if (c_value === undefined) {
|
19 |
-
$('#quick-adsense-reloaded-feedback-overlay').show();
|
20 |
-
} else {
|
21 |
-
// click on the link
|
22 |
-
window.location.href = quads_deactivate_link_url;
|
23 |
-
}
|
24 |
-
});
|
25 |
-
// show text fields
|
26 |
-
$('#quick-adsense-reloaded-feedback-content input[type="radio"]').click(function () {
|
27 |
-
// show text field if there is one
|
28 |
-
$(this).parents('li').next('li').children('input[type="text"], textarea').show();
|
29 |
-
});
|
30 |
-
// send form or close it
|
31 |
-
$('#quick-adsense-reloaded-feedback-content .button').click(function (e) {
|
32 |
-
e.preventDefault();
|
33 |
-
// set cookie for 30 days
|
34 |
-
var exdate = new Date();
|
35 |
-
exdate.setSeconds(exdate.getSeconds() + 2592000);
|
36 |
-
document.cookie = "quads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
|
37 |
-
|
38 |
-
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
39 |
-
if ('quick-adsense-reloaded-feedback-submit' === this.id) {
|
40 |
-
// Send form data
|
41 |
-
$.ajax({
|
42 |
-
type: 'POST',
|
43 |
-
url: ajaxurl,
|
44 |
-
dataType: 'json',
|
45 |
-
data: {
|
46 |
-
action: 'quads_send_feedback',
|
47 |
-
data: $('#quick-adsense-reloaded-feedback-content form').serialize()
|
48 |
-
},
|
49 |
-
complete: function (MLHttpRequest, textStatus, errorThrown) {
|
50 |
-
// deactivate the plugin and close the popup
|
51 |
-
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
52 |
-
window.location.href = quads_deactivate_link_url;
|
53 |
-
|
54 |
-
}
|
55 |
-
});
|
56 |
-
} else {
|
57 |
-
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
58 |
-
window.location.href = quads_deactivate_link_url;
|
59 |
-
}
|
60 |
-
});
|
61 |
-
// close form without doing anything
|
62 |
-
$('.quick-adsense-reloaded-feedback-not-deactivate').click(function (e) {
|
63 |
-
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
64 |
-
});
|
65 |
-
|
66 |
-
function quads_admin_get_cookie (name) {
|
67 |
-
var i, x, y, quads_cookies = document.cookie.split( ";" );
|
68 |
-
for (i = 0; i < quads_cookies.length; i++)
|
69 |
-
{
|
70 |
-
x = quads_cookies[i].substr( 0, quads_cookies[i].indexOf( "=" ) );
|
71 |
-
y = quads_cookies[i].substr( quads_cookies[i].indexOf( "=" ) + 1 );
|
72 |
-
x = x.replace( /^\s+|\s+$/g, "" );
|
73 |
-
if (x === name)
|
74 |
-
{
|
75 |
-
return unescape( y );
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
}); // document ready
|
1 |
+
var strict;
|
2 |
+
|
3 |
+
jQuery(document).ready(function ($) {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* DEACTIVATION FEEDBACK FORM
|
7 |
+
*/
|
8 |
+
// show overlay when clicked on "deactivate"
|
9 |
+
quads_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="quick-adsense-reloaded"] .row-actions .deactivate a');
|
10 |
+
quads_deactivate_link_url = quads_deactivate_link.attr('href');
|
11 |
+
|
12 |
+
quads_deactivate_link.click(function (e) {
|
13 |
+
e.preventDefault();
|
14 |
+
|
15 |
+
// only show feedback form once per 30 days
|
16 |
+
var c_value = quads_admin_get_cookie("quads_hide_deactivate_feedback");
|
17 |
+
|
18 |
+
if (c_value === undefined) {
|
19 |
+
$('#quick-adsense-reloaded-feedback-overlay').show();
|
20 |
+
} else {
|
21 |
+
// click on the link
|
22 |
+
window.location.href = quads_deactivate_link_url;
|
23 |
+
}
|
24 |
+
});
|
25 |
+
// show text fields
|
26 |
+
$('#quick-adsense-reloaded-feedback-content input[type="radio"]').click(function () {
|
27 |
+
// show text field if there is one
|
28 |
+
$(this).parents('li').next('li').children('input[type="text"], textarea').show();
|
29 |
+
});
|
30 |
+
// send form or close it
|
31 |
+
$('#quick-adsense-reloaded-feedback-content .button').click(function (e) {
|
32 |
+
e.preventDefault();
|
33 |
+
// set cookie for 30 days
|
34 |
+
var exdate = new Date();
|
35 |
+
exdate.setSeconds(exdate.getSeconds() + 2592000);
|
36 |
+
document.cookie = "quads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
|
37 |
+
|
38 |
+
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
39 |
+
if ('quick-adsense-reloaded-feedback-submit' === this.id) {
|
40 |
+
// Send form data
|
41 |
+
$.ajax({
|
42 |
+
type: 'POST',
|
43 |
+
url: ajaxurl,
|
44 |
+
dataType: 'json',
|
45 |
+
data: {
|
46 |
+
action: 'quads_send_feedback',
|
47 |
+
data: $('#quick-adsense-reloaded-feedback-content form').serialize()
|
48 |
+
},
|
49 |
+
complete: function (MLHttpRequest, textStatus, errorThrown) {
|
50 |
+
// deactivate the plugin and close the popup
|
51 |
+
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
52 |
+
window.location.href = quads_deactivate_link_url;
|
53 |
+
|
54 |
+
}
|
55 |
+
});
|
56 |
+
} else {
|
57 |
+
$('#quick-adsense-reloaded-feedback-overlay').remove();
|
58 |
+
window.location.href = quads_deactivate_link_url;
|
59 |
+
}
|
60 |
+
});
|
61 |
+
// close form without doing anything
|
62 |
+
$('.quick-adsense-reloaded-feedback-not-deactivate').click(function (e) {
|
63 |
+
$('#quick-adsense-reloaded-feedback-overlay').hide();
|
64 |
+
});
|
65 |
+
|
66 |
+
function quads_admin_get_cookie (name) {
|
67 |
+
var i, x, y, quads_cookies = document.cookie.split( ";" );
|
68 |
+
for (i = 0; i < quads_cookies.length; i++)
|
69 |
+
{
|
70 |
+
x = quads_cookies[i].substr( 0, quads_cookies[i].indexOf( "=" ) );
|
71 |
+
y = quads_cookies[i].substr( quads_cookies[i].indexOf( "=" ) + 1 );
|
72 |
+
x = x.replace( /^\s+|\s+$/g, "" );
|
73 |
+
if (x === name)
|
74 |
+
{
|
75 |
+
return unescape( y );
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
}); // document ready
|
includes/Autoloader.php
CHANGED
@@ -1,154 +1,154 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class Autoloader
|
6 |
-
* @package quads
|
7 |
-
*/
|
8 |
-
class Autoloader
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* An associative array; "namespace" => "directory"
|
12 |
-
* @var array
|
13 |
-
*/
|
14 |
-
private $namespaces;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Register multiple namespaces
|
18 |
-
* @param array $namespaces
|
19 |
-
*/
|
20 |
-
public function registerNamespaces($namespaces)
|
21 |
-
{
|
22 |
-
foreach($namespaces as $namespace => $baseDirectory)
|
23 |
-
{
|
24 |
-
// A string
|
25 |
-
if (is_string($baseDirectory))
|
26 |
-
{
|
27 |
-
$this->registerNamespace($namespace, $baseDirectory);
|
28 |
-
continue;
|
29 |
-
}
|
30 |
-
|
31 |
-
// Multiple directories
|
32 |
-
foreach ($baseDirectory as $directory)
|
33 |
-
{
|
34 |
-
$this->registerNamespace($namespace, $directory);
|
35 |
-
}
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Register a namespace
|
41 |
-
* @param string $namespace
|
42 |
-
* @param string $baseDirectory
|
43 |
-
* @param bool $prepend
|
44 |
-
*/
|
45 |
-
public function registerNamespace($namespace, $baseDirectory, $prepend = false)
|
46 |
-
{
|
47 |
-
// Normalization
|
48 |
-
// Normalize namespace
|
49 |
-
$namespace = trim($namespace, "\\") . "\\";
|
50 |
-
// Normalize base directory
|
51 |
-
$baseDirectory = rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
52 |
-
|
53 |
-
// Namespace is not set
|
54 |
-
if (false === isset($this->namespaces[$namespace]))
|
55 |
-
{
|
56 |
-
$this->namespaces[$namespace] = array();
|
57 |
-
}
|
58 |
-
|
59 |
-
// Prepend or add
|
60 |
-
if ($prepend)
|
61 |
-
{
|
62 |
-
array_unshift($this->namespaces[$namespace], $baseDirectory);
|
63 |
-
}
|
64 |
-
else
|
65 |
-
{
|
66 |
-
array_push($this->namespaces[$namespace], $baseDirectory);
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Loads the class file for given class name
|
72 |
-
* @param string $class
|
73 |
-
* @return bool
|
74 |
-
*/
|
75 |
-
public function load($class)
|
76 |
-
{
|
77 |
-
$namespace = $class;
|
78 |
-
|
79 |
-
// As long as we have a namespace
|
80 |
-
while (false !== ($pos = strrpos($namespace, "\\")))
|
81 |
-
{
|
82 |
-
// Basic variables
|
83 |
-
$namespace = substr($class, 0, $pos +1);
|
84 |
-
$className = substr($class, $pos + 1);
|
85 |
-
|
86 |
-
// Find file for given namespace & class name
|
87 |
-
if ($this->findFile($namespace, $className))
|
88 |
-
{
|
89 |
-
return true;
|
90 |
-
}
|
91 |
-
|
92 |
-
// Trim to search another namespace
|
93 |
-
$namespace = rtrim($namespace, "\\");
|
94 |
-
}
|
95 |
-
|
96 |
-
// Class not found
|
97 |
-
return false;
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Attempts to find file for given namespace and class
|
102 |
-
* @param string $namespace
|
103 |
-
* @param string $class
|
104 |
-
* @return bool
|
105 |
-
*/
|
106 |
-
protected function findFile($namespace, $class)
|
107 |
-
{
|
108 |
-
// No registered base directory for given namespace
|
109 |
-
if (false === isset($this->namespaces[$namespace]))
|
110 |
-
{
|
111 |
-
return false;
|
112 |
-
}
|
113 |
-
|
114 |
-
foreach ($this->namespaces[$namespace] as $baseDirectory)
|
115 |
-
{
|
116 |
-
// Look through base directory for given namespace
|
117 |
-
$file = $baseDirectory . str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
|
118 |
-
|
119 |
-
// File found
|
120 |
-
if ($this->requireFile($file))
|
121 |
-
{
|
122 |
-
return true;
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
// No file found
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Requires file from FS if it exists
|
132 |
-
* @param string $file
|
133 |
-
* @return bool
|
134 |
-
*/
|
135 |
-
protected function requireFile($file)
|
136 |
-
{
|
137 |
-
// File not found
|
138 |
-
if (!file_exists($file))
|
139 |
-
{
|
140 |
-
return false;
|
141 |
-
}
|
142 |
-
|
143 |
-
require_once $file;
|
144 |
-
return true;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Registers autoloader with SPL autoloader stack
|
149 |
-
*/
|
150 |
-
public function register()
|
151 |
-
{
|
152 |
-
spl_autoload_register(array($this, "load"));
|
153 |
-
}
|
154 |
-
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Autoloader
|
6 |
+
* @package quads
|
7 |
+
*/
|
8 |
+
class Autoloader
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* An associative array; "namespace" => "directory"
|
12 |
+
* @var array
|
13 |
+
*/
|
14 |
+
private $namespaces;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Register multiple namespaces
|
18 |
+
* @param array $namespaces
|
19 |
+
*/
|
20 |
+
public function registerNamespaces($namespaces)
|
21 |
+
{
|
22 |
+
foreach($namespaces as $namespace => $baseDirectory)
|
23 |
+
{
|
24 |
+
// A string
|
25 |
+
if (is_string($baseDirectory))
|
26 |
+
{
|
27 |
+
$this->registerNamespace($namespace, $baseDirectory);
|
28 |
+
continue;
|
29 |
+
}
|
30 |
+
|
31 |
+
// Multiple directories
|
32 |
+
foreach ($baseDirectory as $directory)
|
33 |
+
{
|
34 |
+
$this->registerNamespace($namespace, $directory);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Register a namespace
|
41 |
+
* @param string $namespace
|
42 |
+
* @param string $baseDirectory
|
43 |
+
* @param bool $prepend
|
44 |
+
*/
|
45 |
+
public function registerNamespace($namespace, $baseDirectory, $prepend = false)
|
46 |
+
{
|
47 |
+
// Normalization
|
48 |
+
// Normalize namespace
|
49 |
+
$namespace = trim($namespace, "\\") . "\\";
|
50 |
+
// Normalize base directory
|
51 |
+
$baseDirectory = rtrim($baseDirectory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
52 |
+
|
53 |
+
// Namespace is not set
|
54 |
+
if (false === isset($this->namespaces[$namespace]))
|
55 |
+
{
|
56 |
+
$this->namespaces[$namespace] = array();
|
57 |
+
}
|
58 |
+
|
59 |
+
// Prepend or add
|
60 |
+
if ($prepend)
|
61 |
+
{
|
62 |
+
array_unshift($this->namespaces[$namespace], $baseDirectory);
|
63 |
+
}
|
64 |
+
else
|
65 |
+
{
|
66 |
+
array_push($this->namespaces[$namespace], $baseDirectory);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Loads the class file for given class name
|
72 |
+
* @param string $class
|
73 |
+
* @return bool
|
74 |
+
*/
|
75 |
+
public function load($class)
|
76 |
+
{
|
77 |
+
$namespace = $class;
|
78 |
+
|
79 |
+
// As long as we have a namespace
|
80 |
+
while (false !== ($pos = strrpos($namespace, "\\")))
|
81 |
+
{
|
82 |
+
// Basic variables
|
83 |
+
$namespace = substr($class, 0, $pos +1);
|
84 |
+
$className = substr($class, $pos + 1);
|
85 |
+
|
86 |
+
// Find file for given namespace & class name
|
87 |
+
if ($this->findFile($namespace, $className))
|
88 |
+
{
|
89 |
+
return true;
|
90 |
+
}
|
91 |
+
|
92 |
+
// Trim to search another namespace
|
93 |
+
$namespace = rtrim($namespace, "\\");
|
94 |
+
}
|
95 |
+
|
96 |
+
// Class not found
|
97 |
+
return false;
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Attempts to find file for given namespace and class
|
102 |
+
* @param string $namespace
|
103 |
+
* @param string $class
|
104 |
+
* @return bool
|
105 |
+
*/
|
106 |
+
protected function findFile($namespace, $class)
|
107 |
+
{
|
108 |
+
// No registered base directory for given namespace
|
109 |
+
if (false === isset($this->namespaces[$namespace]))
|
110 |
+
{
|
111 |
+
return false;
|
112 |
+
}
|
113 |
+
|
114 |
+
foreach ($this->namespaces[$namespace] as $baseDirectory)
|
115 |
+
{
|
116 |
+
// Look through base directory for given namespace
|
117 |
+
$file = $baseDirectory . str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
|
118 |
+
|
119 |
+
// File found
|
120 |
+
if ($this->requireFile($file))
|
121 |
+
{
|
122 |
+
return true;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
// No file found
|
127 |
+
return false;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Requires file from FS if it exists
|
132 |
+
* @param string $file
|
133 |
+
* @return bool
|
134 |
+
*/
|
135 |
+
protected function requireFile($file)
|
136 |
+
{
|
137 |
+
// File not found
|
138 |
+
if (!file_exists($file))
|
139 |
+
{
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
|
143 |
+
require_once $file;
|
144 |
+
return true;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Registers autoloader with SPL autoloader stack
|
149 |
+
*/
|
150 |
+
public function register()
|
151 |
+
{
|
152 |
+
spl_autoload_register(array($this, "load"));
|
153 |
+
}
|
154 |
+
}
|
includes/Cron/Cron.php
CHANGED
@@ -1,54 +1,54 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Chron relevant stuff
|
5 |
-
*/
|
6 |
-
|
7 |
-
// No Direct Access
|
8 |
-
if( !defined( "WPINC" ) ) {
|
9 |
-
die;
|
10 |
-
}
|
11 |
-
|
12 |
-
class quadsCron {
|
13 |
-
|
14 |
-
public function __construct() {
|
15 |
-
add_filter( 'cron_schedules', array($this, 'add_new_intervals'), 100 );
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Add new intervals for wp cron jobs
|
21 |
-
* @param type $schedules
|
22 |
-
* @return type
|
23 |
-
*/
|
24 |
-
public function add_new_intervals( $schedules ) {
|
25 |
-
// add weekly and monthly intervals
|
26 |
-
$schedules['weekly'] = array(
|
27 |
-
'interval' => 604800,
|
28 |
-
'display' => __( 'Once Weekly' )
|
29 |
-
);
|
30 |
-
|
31 |
-
$schedules['monthly'] = array(
|
32 |
-
'interval' => 2635200,
|
33 |
-
'display' => __( 'Once a month' )
|
34 |
-
);
|
35 |
-
|
36 |
-
return $schedules;
|
37 |
-
}
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
public function schedule_event() {
|
43 |
-
|
44 |
-
if( !wp_next_scheduled( 'quads_weekly_event' ) ) {
|
45 |
-
wp_schedule_event( time(), 'weekly', 'quads_weekly_event' );
|
46 |
-
|
47 |
-
}
|
48 |
-
if( !wp_next_scheduled( 'quads_daily_event' ) ) {
|
49 |
-
wp_schedule_event( time(), 'daily', 'quads_daily_event' );
|
50 |
-
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
$quadsCron = new quadsCron();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Chron relevant stuff
|
5 |
+
*/
|
6 |
+
|
7 |
+
// No Direct Access
|
8 |
+
if( !defined( "WPINC" ) ) {
|
9 |
+
die;
|
10 |
+
}
|
11 |
+
|
12 |
+
class quadsCron {
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
add_filter( 'cron_schedules', array($this, 'add_new_intervals'), 100 );
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Add new intervals for wp cron jobs
|
21 |
+
* @param type $schedules
|
22 |
+
* @return type
|
23 |
+
*/
|
24 |
+
public function add_new_intervals( $schedules ) {
|
25 |
+
// add weekly and monthly intervals
|
26 |
+
$schedules['weekly'] = array(
|
27 |
+
'interval' => 604800,
|
28 |
+
'display' => __( 'Once Weekly' )
|
29 |
+
);
|
30 |
+
|
31 |
+
$schedules['monthly'] = array(
|
32 |
+
'interval' => 2635200,
|
33 |
+
'display' => __( 'Once a month' )
|
34 |
+
);
|
35 |
+
|
36 |
+
return $schedules;
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
+
public function schedule_event() {
|
43 |
+
|
44 |
+
if( !wp_next_scheduled( 'quads_weekly_event' ) ) {
|
45 |
+
wp_schedule_event( time(), 'weekly', 'quads_weekly_event' );
|
46 |
+
|
47 |
+
}
|
48 |
+
if( !wp_next_scheduled( 'quads_daily_event' ) ) {
|
49 |
+
wp_schedule_event( time(), 'daily', 'quads_daily_event' );
|
50 |
+
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
$quadsCron = new quadsCron();
|
includes/DI/InjectionAware.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
namespace WPStaging\DI;
|
3 |
-
|
4 |
-
use WPStaging\WPStaging;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class InjectionAware
|
8 |
-
* @package WPStaging\DI
|
9 |
-
*/
|
10 |
-
abstract class InjectionAware
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @var WPStaging
|
15 |
-
*/
|
16 |
-
protected $di;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* InjectionAware constructor.
|
20 |
-
* @param $di
|
21 |
-
*/
|
22 |
-
public function __construct($di)
|
23 |
-
{
|
24 |
-
$this->di = $di;
|
25 |
-
|
26 |
-
if (method_exists($this, "initialize"))
|
27 |
-
{
|
28 |
-
$this->initialize();
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @return WPStaging
|
34 |
-
*/
|
35 |
-
public function getDI()
|
36 |
-
{
|
37 |
-
return $this->di;
|
38 |
-
}
|
39 |
}
|
1 |
+
<?php
|
2 |
+
namespace WPStaging\DI;
|
3 |
+
|
4 |
+
use WPStaging\WPStaging;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class InjectionAware
|
8 |
+
* @package WPStaging\DI
|
9 |
+
*/
|
10 |
+
abstract class InjectionAware
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var WPStaging
|
15 |
+
*/
|
16 |
+
protected $di;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* InjectionAware constructor.
|
20 |
+
* @param $di
|
21 |
+
*/
|
22 |
+
public function __construct($di)
|
23 |
+
{
|
24 |
+
$this->di = $di;
|
25 |
+
|
26 |
+
if (method_exists($this, "initialize"))
|
27 |
+
{
|
28 |
+
$this->initialize();
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @return WPStaging
|
34 |
+
*/
|
35 |
+
public function getDI()
|
36 |
+
{
|
37 |
+
return $this->di;
|
38 |
+
}
|
39 |
}
|
includes/Forms/Elements.php
CHANGED
@@ -1,300 +1,300 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Class Elements
|
7 |
-
* @package WPStaging\Forms
|
8 |
-
*/
|
9 |
-
abstract class Elements implements InterfaceElement
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @var null|string
|
14 |
-
*/
|
15 |
-
protected $name;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var array
|
19 |
-
*/
|
20 |
-
protected $attributes = array();
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @var null|string
|
24 |
-
*/
|
25 |
-
protected $label;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var null|string|array
|
29 |
-
*/
|
30 |
-
protected $default;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var array
|
34 |
-
*/
|
35 |
-
protected $filters = array();
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
protected $validations = array();
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var string
|
44 |
-
*/
|
45 |
-
protected $renderFile;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Text constructor.
|
49 |
-
* @param string $name
|
50 |
-
* @param array $attributes
|
51 |
-
*/
|
52 |
-
public function __construct($name, $attributes)
|
53 |
-
{
|
54 |
-
$this->setName($name);
|
55 |
-
$this->setAttributes($attributes);
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @param string $name
|
60 |
-
* @return $this
|
61 |
-
*/
|
62 |
-
public function setName($name)
|
63 |
-
{
|
64 |
-
$this->name = $name;
|
65 |
-
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @return null|string
|
71 |
-
*/
|
72 |
-
public function getName()
|
73 |
-
{
|
74 |
-
return $this->name;
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* @param string $name
|
79 |
-
* @param string $value
|
80 |
-
* @return $this
|
81 |
-
*/
|
82 |
-
public function setAttribute($name, $value)
|
83 |
-
{
|
84 |
-
$this->attributes[$name] = $value;
|
85 |
-
|
86 |
-
return $this;
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* @param array $attributes
|
91 |
-
* @return $this
|
92 |
-
*/
|
93 |
-
public function setAttributes($attributes)
|
94 |
-
{
|
95 |
-
foreach ($attributes as $name => $value)
|
96 |
-
{
|
97 |
-
$this->setAttribute($name, $value);
|
98 |
-
}
|
99 |
-
|
100 |
-
return $this;
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* @return string
|
105 |
-
*/
|
106 |
-
public function prepareAttributes()
|
107 |
-
{
|
108 |
-
$attributes = '';
|
109 |
-
foreach ($this->attributes as $name => $value)
|
110 |
-
{
|
111 |
-
$attributes .= "{$name}='{$value}' ";
|
112 |
-
}
|
113 |
-
|
114 |
-
return rtrim($attributes, ' ');
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @return array
|
119 |
-
*/
|
120 |
-
public function getAttributes()
|
121 |
-
{
|
122 |
-
return $this->attributes;
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @param string $label
|
127 |
-
* @return $this
|
128 |
-
*/
|
129 |
-
public function setLabel($label)
|
130 |
-
{
|
131 |
-
$this->label = $label;
|
132 |
-
|
133 |
-
return $this;
|
134 |
-
}
|
135 |
-
|
136 |
-
/**
|
137 |
-
* @return null|string
|
138 |
-
*/
|
139 |
-
public function getLabel()
|
140 |
-
{
|
141 |
-
return $this->label;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* @return string
|
146 |
-
*/
|
147 |
-
public function prepareLabel()
|
148 |
-
{
|
149 |
-
return "<label for='{$this->getId()}'>{$this->label}</label>";
|
150 |
-
}
|
151 |
-
/**
|
152 |
-
* @param string $label
|
153 |
-
* @return $this
|
154 |
-
*/
|
155 |
-
public function setTooltip($tooltip)
|
156 |
-
{
|
157 |
-
$this->tooltip = $tooltip;
|
158 |
-
|
159 |
-
return $this;
|
160 |
-
}
|
161 |
-
|
162 |
-
/**
|
163 |
-
* @return null|string
|
164 |
-
*/
|
165 |
-
public function getTooltip()
|
166 |
-
{
|
167 |
-
return $this->tooltip;
|
168 |
-
}
|
169 |
-
|
170 |
-
/**
|
171 |
-
* @return string
|
172 |
-
*/
|
173 |
-
public function prepareTooltip()
|
174 |
-
{
|
175 |
-
return "<a class='quads-tooltip' href='#'></a><div class='quads-tooltip-message'>{$this->tooltip}</div>";
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* @param array|string $filters
|
180 |
-
* @return $this
|
181 |
-
*/
|
182 |
-
public function setFilters($filters)
|
183 |
-
{
|
184 |
-
if (is_string($filters))
|
185 |
-
{
|
186 |
-
$this->filters[] = $filters;
|
187 |
-
}
|
188 |
-
else
|
189 |
-
{
|
190 |
-
array_merge($this->filters, $filters);
|
191 |
-
}
|
192 |
-
|
193 |
-
return $this;
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* @return array
|
198 |
-
*/
|
199 |
-
public function getFilters()
|
200 |
-
{
|
201 |
-
return $this->filters;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* @param string|array $value
|
206 |
-
* @return $this
|
207 |
-
*/
|
208 |
-
public function setDefault($value)
|
209 |
-
{
|
210 |
-
$this->default = $value;
|
211 |
-
|
212 |
-
return $this;
|
213 |
-
}
|
214 |
-
|
215 |
-
/**
|
216 |
-
* @return null|string|array
|
217 |
-
*/
|
218 |
-
public function getDefault()
|
219 |
-
{
|
220 |
-
return $this->default;
|
221 |
-
}
|
222 |
-
|
223 |
-
/**
|
224 |
-
* @param object $validation
|
225 |
-
* @return $this
|
226 |
-
*/
|
227 |
-
public function addValidation($validation)
|
228 |
-
{
|
229 |
-
$this->validations[] = $validation;
|
230 |
-
|
231 |
-
return $this;
|
232 |
-
}
|
233 |
-
|
234 |
-
/**
|
235 |
-
* @return array
|
236 |
-
*/
|
237 |
-
public function getValidations()
|
238 |
-
{
|
239 |
-
return $this->validations;
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* @param string $file
|
244 |
-
* @return $this
|
245 |
-
*/
|
246 |
-
public function setRenderFile($file)
|
247 |
-
{
|
248 |
-
if (file_exists($file) && is_readable($file))
|
249 |
-
{
|
250 |
-
$this->renderFile = $file;
|
251 |
-
}
|
252 |
-
|
253 |
-
return $this;
|
254 |
-
}
|
255 |
-
|
256 |
-
/**
|
257 |
-
* @return string
|
258 |
-
*/
|
259 |
-
public function getRenderFile()
|
260 |
-
{
|
261 |
-
return $this->renderFile;
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* @return string
|
266 |
-
*/
|
267 |
-
public function __toString()
|
268 |
-
{
|
269 |
-
return $this->render();
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* @param null|string $name
|
274 |
-
* @return string
|
275 |
-
*/
|
276 |
-
public function getId($name = null)
|
277 |
-
{
|
278 |
-
if (null === $name)
|
279 |
-
{
|
280 |
-
$name = $this->name;
|
281 |
-
}
|
282 |
-
|
283 |
-
if (!$name)
|
284 |
-
{
|
285 |
-
return '';
|
286 |
-
}
|
287 |
-
|
288 |
-
return str_replace(' ', '_', $name);
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
* @return string
|
293 |
-
*/
|
294 |
-
abstract protected function prepareOutput();
|
295 |
-
|
296 |
-
/**
|
297 |
-
* @return string
|
298 |
-
*/
|
299 |
-
abstract public function render();
|
300 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class Elements
|
7 |
+
* @package WPStaging\Forms
|
8 |
+
*/
|
9 |
+
abstract class Elements implements InterfaceElement
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @var null|string
|
14 |
+
*/
|
15 |
+
protected $name;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var array
|
19 |
+
*/
|
20 |
+
protected $attributes = array();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @var null|string
|
24 |
+
*/
|
25 |
+
protected $label;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* @var null|string|array
|
29 |
+
*/
|
30 |
+
protected $default;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var array
|
34 |
+
*/
|
35 |
+
protected $filters = array();
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @var array
|
39 |
+
*/
|
40 |
+
protected $validations = array();
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $renderFile;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Text constructor.
|
49 |
+
* @param string $name
|
50 |
+
* @param array $attributes
|
51 |
+
*/
|
52 |
+
public function __construct($name, $attributes)
|
53 |
+
{
|
54 |
+
$this->setName($name);
|
55 |
+
$this->setAttributes($attributes);
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @param string $name
|
60 |
+
* @return $this
|
61 |
+
*/
|
62 |
+
public function setName($name)
|
63 |
+
{
|
64 |
+
$this->name = $name;
|
65 |
+
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return null|string
|
71 |
+
*/
|
72 |
+
public function getName()
|
73 |
+
{
|
74 |
+
return $this->name;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @param string $name
|
79 |
+
* @param string $value
|
80 |
+
* @return $this
|
81 |
+
*/
|
82 |
+
public function setAttribute($name, $value)
|
83 |
+
{
|
84 |
+
$this->attributes[$name] = $value;
|
85 |
+
|
86 |
+
return $this;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @param array $attributes
|
91 |
+
* @return $this
|
92 |
+
*/
|
93 |
+
public function setAttributes($attributes)
|
94 |
+
{
|
95 |
+
foreach ($attributes as $name => $value)
|
96 |
+
{
|
97 |
+
$this->setAttribute($name, $value);
|
98 |
+
}
|
99 |
+
|
100 |
+
return $this;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function prepareAttributes()
|
107 |
+
{
|
108 |
+
$attributes = '';
|
109 |
+
foreach ($this->attributes as $name => $value)
|
110 |
+
{
|
111 |
+
$attributes .= "{$name}='{$value}' ";
|
112 |
+
}
|
113 |
+
|
114 |
+
return rtrim($attributes, ' ');
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @return array
|
119 |
+
*/
|
120 |
+
public function getAttributes()
|
121 |
+
{
|
122 |
+
return $this->attributes;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @param string $label
|
127 |
+
* @return $this
|
128 |
+
*/
|
129 |
+
public function setLabel($label)
|
130 |
+
{
|
131 |
+
$this->label = $label;
|
132 |
+
|
133 |
+
return $this;
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @return null|string
|
138 |
+
*/
|
139 |
+
public function getLabel()
|
140 |
+
{
|
141 |
+
return $this->label;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @return string
|
146 |
+
*/
|
147 |
+
public function prepareLabel()
|
148 |
+
{
|
149 |
+
return "<label for='{$this->getId()}'>{$this->label}</label>";
|
150 |
+
}
|
151 |
+
/**
|
152 |
+
* @param string $label
|
153 |
+
* @return $this
|
154 |
+
*/
|
155 |
+
public function setTooltip($tooltip)
|
156 |
+
{
|
157 |
+
$this->tooltip = $tooltip;
|
158 |
+
|
159 |
+
return $this;
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @return null|string
|
164 |
+
*/
|
165 |
+
public function getTooltip()
|
166 |
+
{
|
167 |
+
return $this->tooltip;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @return string
|
172 |
+
*/
|
173 |
+
public function prepareTooltip()
|
174 |
+
{
|
175 |
+
return "<a class='quads-tooltip' href='#'></a><div class='quads-tooltip-message'>{$this->tooltip}</div>";
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* @param array|string $filters
|
180 |
+
* @return $this
|
181 |
+
*/
|
182 |
+
public function setFilters($filters)
|
183 |
+
{
|
184 |
+
if (is_string($filters))
|
185 |
+
{
|
186 |
+
$this->filters[] = $filters;
|
187 |
+
}
|
188 |
+
else
|
189 |
+
{
|
190 |
+
array_merge($this->filters, $filters);
|
191 |
+
}
|
192 |
+
|
193 |
+
return $this;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* @return array
|
198 |
+
*/
|
199 |
+
public function getFilters()
|
200 |
+
{
|
201 |
+
return $this->filters;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @param string|array $value
|
206 |
+
* @return $this
|
207 |
+
*/
|
208 |
+
public function setDefault($value)
|
209 |
+
{
|
210 |
+
$this->default = $value;
|
211 |
+
|
212 |
+
return $this;
|
213 |
+
}
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @return null|string|array
|
217 |
+
*/
|
218 |
+
public function getDefault()
|
219 |
+
{
|
220 |
+
return $this->default;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* @param object $validation
|
225 |
+
* @return $this
|
226 |
+
*/
|
227 |
+
public function addValidation($validation)
|
228 |
+
{
|
229 |
+
$this->validations[] = $validation;
|
230 |
+
|
231 |
+
return $this;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* @return array
|
236 |
+
*/
|
237 |
+
public function getValidations()
|
238 |
+
{
|
239 |
+
return $this->validations;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* @param string $file
|
244 |
+
* @return $this
|
245 |
+
*/
|
246 |
+
public function setRenderFile($file)
|
247 |
+
{
|
248 |
+
if (file_exists($file) && is_readable($file))
|
249 |
+
{
|
250 |
+
$this->renderFile = $file;
|
251 |
+
}
|
252 |
+
|
253 |
+
return $this;
|
254 |
+
}
|
255 |
+
|
256 |
+
/**
|
257 |
+
* @return string
|
258 |
+
*/
|
259 |
+
public function getRenderFile()
|
260 |
+
{
|
261 |
+
return $this->renderFile;
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @return string
|
266 |
+
*/
|
267 |
+
public function __toString()
|
268 |
+
{
|
269 |
+
return $this->render();
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* @param null|string $name
|
274 |
+
* @return string
|
275 |
+
*/
|
276 |
+
public function getId($name = null)
|
277 |
+
{
|
278 |
+
if (null === $name)
|
279 |
+
{
|
280 |
+
$name = $this->name;
|
281 |
+
}
|
282 |
+
|
283 |
+
if (!$name)
|
284 |
+
{
|
285 |
+
return '';
|
286 |
+
}
|
287 |
+
|
288 |
+
return str_replace(' ', '_', $name);
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
abstract protected function prepareOutput();
|
295 |
+
|
296 |
+
/**
|
297 |
+
* @return string
|
298 |
+
*/
|
299 |
+
abstract public function render();
|
300 |
}
|
includes/Forms/Elements/Check.php
CHANGED
@@ -1,66 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
use wpquads\ElementsWithOptions;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class Check
|
9 |
-
* @package WPStaging\Forms\Elements
|
10 |
-
*/
|
11 |
-
class Check extends ElementsWithOptions
|
12 |
-
{
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @return string
|
16 |
-
*/
|
17 |
-
protected function prepareOutput()
|
18 |
-
{
|
19 |
-
$output = '';
|
20 |
-
|
21 |
-
foreach ($this->options as $id => $value)
|
22 |
-
{
|
23 |
-
$checked = ($this->isChecked($id)) ? " checked=''" : '';
|
24 |
-
|
25 |
-
$attributeId = $this->getId() . '_' . $this->getId($id);
|
26 |
-
|
27 |
-
$output .= "<input type='checkbox' name='{$this->getId()}' id='{$attributeId}' value='{$id}' {$checked}/>";
|
28 |
-
|
29 |
-
if ($value)
|
30 |
-
{
|
31 |
-
$output .= "<label for='{$attributeId}'>{$value}</label>";
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
return $output;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @param string $value
|
40 |
-
* @return bool
|
41 |
-
*/
|
42 |
-
private function isChecked($value)
|
43 |
-
{
|
44 |
-
if (
|
45 |
-
$this->default &&
|
46 |
-
(
|
47 |
-
(is_string($this->default) && $this->default === $value) ||
|
48 |
-
(is_int($value) && (int) $this->default == $value) ||
|
49 |
-
(is_array($this->default) && in_array($value, $this->default))
|
50 |
-
)
|
51 |
-
)
|
52 |
-
{
|
53 |
-
return true;
|
54 |
-
}
|
55 |
-
|
56 |
-
return false;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @return string
|
61 |
-
*/
|
62 |
-
public function render()
|
63 |
-
{
|
64 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
65 |
-
}
|
66 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
use wpquads\ElementsWithOptions;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Check
|
9 |
+
* @package WPStaging\Forms\Elements
|
10 |
+
*/
|
11 |
+
class Check extends ElementsWithOptions
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
protected function prepareOutput()
|
18 |
+
{
|
19 |
+
$output = '';
|
20 |
+
|
21 |
+
foreach ($this->options as $id => $value)
|
22 |
+
{
|
23 |
+
$checked = ($this->isChecked($id)) ? " checked=''" : '';
|
24 |
+
|
25 |
+
$attributeId = $this->getId() . '_' . $this->getId($id);
|
26 |
+
|
27 |
+
$output .= "<input type='checkbox' name='{$this->getId()}' id='{$attributeId}' value='{$id}' {$checked}/>";
|
28 |
+
|
29 |
+
if ($value)
|
30 |
+
{
|
31 |
+
$output .= "<label for='{$attributeId}'>{$value}</label>";
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
return $output;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @param string $value
|
40 |
+
* @return bool
|
41 |
+
*/
|
42 |
+
private function isChecked($value)
|
43 |
+
{
|
44 |
+
if (
|
45 |
+
$this->default &&
|
46 |
+
(
|
47 |
+
(is_string($this->default) && $this->default === $value) ||
|
48 |
+
(is_int($value) && (int) $this->default == $value) ||
|
49 |
+
(is_array($this->default) && in_array($value, $this->default))
|
50 |
+
)
|
51 |
+
)
|
52 |
+
{
|
53 |
+
return true;
|
54 |
+
}
|
55 |
+
|
56 |
+
return false;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function render()
|
63 |
+
{
|
64 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
65 |
+
}
|
66 |
}
|
includes/Forms/Elements/Date.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
use wpquads\Elements;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class Date
|
8 |
-
* @package WPStaging\Forms\Elements
|
9 |
-
*/
|
10 |
-
class Date extends Elements
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
protected function prepareOutput()
|
17 |
-
{
|
18 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='date' {$this->prepareAttributes()} value='{$this->default}' />";
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @return string
|
23 |
-
*/
|
24 |
-
public function render()
|
25 |
-
{
|
26 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
-
}
|
28 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
use wpquads\Elements;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Date
|
8 |
+
* @package WPStaging\Forms\Elements
|
9 |
+
*/
|
10 |
+
class Date extends Elements
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
protected function prepareOutput()
|
17 |
+
{
|
18 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='date' {$this->prepareAttributes()} value='{$this->default}' />";
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
+
}
|
28 |
}
|
includes/Forms/Elements/DateTime.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class Date
|
6 |
-
* @package WPStaging\Forms\Elements
|
7 |
-
*/
|
8 |
-
class DateTime extends Elements
|
9 |
-
{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
protected function prepareOutput()
|
15 |
-
{
|
16 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='datetime' {$this->prepareAttributes()} value='{$this->default}' />";
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
public function render()
|
23 |
-
{
|
24 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
25 |
-
}
|
26 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Date
|
6 |
+
* @package WPStaging\Forms\Elements
|
7 |
+
*/
|
8 |
+
class DateTime extends Elements
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function prepareOutput()
|
15 |
+
{
|
16 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='datetime' {$this->prepareAttributes()} value='{$this->default}' />";
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function render()
|
23 |
+
{
|
24 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
25 |
+
}
|
26 |
}
|
includes/Forms/Elements/Email.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
use wpquads\Elements;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class Email
|
8 |
-
* @package WPStaging\Forms\Elements
|
9 |
-
*/
|
10 |
-
class Email extends Elements
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
protected function prepareOutput()
|
17 |
-
{
|
18 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='email' {$this->prepareAttributes()} value='{$this->default}' />";
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @return string
|
23 |
-
*/
|
24 |
-
public function render()
|
25 |
-
{
|
26 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
-
}
|
28 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
use wpquads\Elements;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Email
|
8 |
+
* @package WPStaging\Forms\Elements
|
9 |
+
*/
|
10 |
+
class Email extends Elements
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
protected function prepareOutput()
|
17 |
+
{
|
18 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='email' {$this->prepareAttributes()} value='{$this->default}' />";
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
+
}
|
28 |
}
|
includes/Forms/Elements/File.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
use wpquads\Elements;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class File
|
8 |
-
* @package WPStaging\Forms\Elements
|
9 |
-
*/
|
10 |
-
class File extends Elements
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
protected function prepareOutput()
|
17 |
-
{
|
18 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='file' {$this->prepareAttributes()} value='{$this->default}' />";
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @return string
|
23 |
-
*/
|
24 |
-
public function render()
|
25 |
-
{
|
26 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
-
}
|
28 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
use wpquads\Elements;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class File
|
8 |
+
* @package WPStaging\Forms\Elements
|
9 |
+
*/
|
10 |
+
class File extends Elements
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
protected function prepareOutput()
|
17 |
+
{
|
18 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='file' {$this->prepareAttributes()} value='{$this->default}' />";
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
+
}
|
28 |
}
|
includes/Forms/Elements/Hidden.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
use wpquads\ElementsWithOptions;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class Hidden
|
9 |
-
* @package WPStaging\Forms\Elements
|
10 |
-
*/
|
11 |
-
class Hidden extends Elements
|
12 |
-
{
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @return string
|
16 |
-
*/
|
17 |
-
protected function prepareOutput()
|
18 |
-
{
|
19 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='hidden' {$this->prepareAttributes()} value='{$this->default}' />";
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @return string
|
24 |
-
*/
|
25 |
-
public function render()
|
26 |
-
{
|
27 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
28 |
-
}
|
29 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
use wpquads\ElementsWithOptions;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Hidden
|
9 |
+
* @package WPStaging\Forms\Elements
|
10 |
+
*/
|
11 |
+
class Hidden extends Elements
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
protected function prepareOutput()
|
18 |
+
{
|
19 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='hidden' {$this->prepareAttributes()} value='{$this->default}' />";
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function render()
|
26 |
+
{
|
27 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
28 |
+
}
|
29 |
}
|
includes/Forms/Elements/Interfaces/InterfaceElement.php
CHANGED
@@ -1,135 +1,135 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Interface InterfaceElement
|
6 |
-
* @package WPStaging\Forms\Elements\Interfaces
|
7 |
-
*/
|
8 |
-
interface InterfaceElement
|
9 |
-
{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @param string $name
|
13 |
-
* return $this
|
14 |
-
*/
|
15 |
-
public function setName($name);
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return null|string
|
19 |
-
*/
|
20 |
-
public function getName();
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @param string $name
|
24 |
-
* @param string $value
|
25 |
-
* return $this
|
26 |
-
*/
|
27 |
-
public function setAttribute($name, $value);
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param array $attributes
|
31 |
-
* return $this
|
32 |
-
*/
|
33 |
-
public function setAttributes($attributes);
|
34 |
-
|
35 |
-
/**
|
36 |
-
* @return string
|
37 |
-
*/
|
38 |
-
public function prepareAttributes();
|
39 |
-
|
40 |
-
/**
|
41 |
-
* @return array
|
42 |
-
*/
|
43 |
-
public function getAttributes();
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @param string $label
|
47 |
-
* return $this
|
48 |
-
*/
|
49 |
-
public function setLabel($label);
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @return null|string
|
53 |
-
*/
|
54 |
-
public function getLabel();
|
55 |
-
/**
|
56 |
-
* @param string $label
|
57 |
-
* return $this
|
58 |
-
*/
|
59 |
-
public function setTooltip($tooltip);
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @return null|string
|
63 |
-
*/
|
64 |
-
public function getTooltip();
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @return string
|
68 |
-
*/
|
69 |
-
public function prepareLabel();
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @return string
|
73 |
-
*/
|
74 |
-
public function prepareTooltip();
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @param array|string $filters
|
78 |
-
* return $this
|
79 |
-
*/
|
80 |
-
public function setFilters($filters);
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @return array
|
84 |
-
*/
|
85 |
-
public function getFilters();
|
86 |
-
|
87 |
-
/**
|
88 |
-
* @param string $value
|
89 |
-
* return $this
|
90 |
-
*/
|
91 |
-
public function setDefault($value);
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @return null|string
|
95 |
-
*/
|
96 |
-
public function getDefault();
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @param object $validation
|
100 |
-
* return $this
|
101 |
-
*/
|
102 |
-
public function addValidation($validation);
|
103 |
-
|
104 |
-
/**
|
105 |
-
* @return array
|
106 |
-
*/
|
107 |
-
public function getValidations();
|
108 |
-
|
109 |
-
/**
|
110 |
-
* @param string $file
|
111 |
-
* return $this
|
112 |
-
*/
|
113 |
-
public function setRenderFile($file);
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @return string
|
117 |
-
*/
|
118 |
-
public function getRenderFile();
|
119 |
-
|
120 |
-
/**
|
121 |
-
* @param null|string $name
|
122 |
-
* @return string
|
123 |
-
*/
|
124 |
-
public function getId($name = null);
|
125 |
-
|
126 |
-
/**
|
127 |
-
* @return string
|
128 |
-
*/
|
129 |
-
public function __toString();
|
130 |
-
|
131 |
-
/**
|
132 |
-
* @return mixed
|
133 |
-
*/
|
134 |
-
public function render();
|
135 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface InterfaceElement
|
6 |
+
* @package WPStaging\Forms\Elements\Interfaces
|
7 |
+
*/
|
8 |
+
interface InterfaceElement
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $name
|
13 |
+
* return $this
|
14 |
+
*/
|
15 |
+
public function setName($name);
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return null|string
|
19 |
+
*/
|
20 |
+
public function getName();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param string $name
|
24 |
+
* @param string $value
|
25 |
+
* return $this
|
26 |
+
*/
|
27 |
+
public function setAttribute($name, $value);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param array $attributes
|
31 |
+
* return $this
|
32 |
+
*/
|
33 |
+
public function setAttributes($attributes);
|
34 |
+
|
35 |
+
/**
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function prepareAttributes();
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @return array
|
42 |
+
*/
|
43 |
+
public function getAttributes();
|
44 |
+
|
45 |
+
/**
|
46 |
+
* @param string $label
|
47 |
+
* return $this
|
48 |
+
*/
|
49 |
+
public function setLabel($label);
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return null|string
|
53 |
+
*/
|
54 |
+
public function getLabel();
|
55 |
+
/**
|
56 |
+
* @param string $label
|
57 |
+
* return $this
|
58 |
+
*/
|
59 |
+
public function setTooltip($tooltip);
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @return null|string
|
63 |
+
*/
|
64 |
+
public function getTooltip();
|
65 |
+
|
66 |
+
/**
|
67 |
+
* @return string
|
68 |
+
*/
|
69 |
+
public function prepareLabel();
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function prepareTooltip();
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @param array|string $filters
|
78 |
+
* return $this
|
79 |
+
*/
|
80 |
+
public function setFilters($filters);
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return array
|
84 |
+
*/
|
85 |
+
public function getFilters();
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @param string $value
|
89 |
+
* return $this
|
90 |
+
*/
|
91 |
+
public function setDefault($value);
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @return null|string
|
95 |
+
*/
|
96 |
+
public function getDefault();
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @param object $validation
|
100 |
+
* return $this
|
101 |
+
*/
|
102 |
+
public function addValidation($validation);
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @return array
|
106 |
+
*/
|
107 |
+
public function getValidations();
|
108 |
+
|
109 |
+
/**
|
110 |
+
* @param string $file
|
111 |
+
* return $this
|
112 |
+
*/
|
113 |
+
public function setRenderFile($file);
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
public function getRenderFile();
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @param null|string $name
|
122 |
+
* @return string
|
123 |
+
*/
|
124 |
+
public function getId($name = null);
|
125 |
+
|
126 |
+
/**
|
127 |
+
* @return string
|
128 |
+
*/
|
129 |
+
public function __toString();
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @return mixed
|
133 |
+
*/
|
134 |
+
public function render();
|
135 |
}
|
includes/Forms/Elements/Interfaces/InterfaceElementWithOptions.php
CHANGED
@@ -1,34 +1,34 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Interface InterfaceElementWithOptions
|
6 |
-
* @package WPStaging\Forms\Elements\Interfaces
|
7 |
-
*/
|
8 |
-
interface InterfaceElementWithOptions
|
9 |
-
{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @param string $id
|
13 |
-
* @param string $name
|
14 |
-
* @return void
|
15 |
-
*/
|
16 |
-
public function addOption($id, $name);
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @param string $id
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
public function removeOption($id);
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @param array $options
|
26 |
-
* @return void
|
27 |
-
*/
|
28 |
-
public function addOptions($options);
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @return array
|
32 |
-
*/
|
33 |
-
public function getOptions();
|
34 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Interface InterfaceElementWithOptions
|
6 |
+
* @package WPStaging\Forms\Elements\Interfaces
|
7 |
+
*/
|
8 |
+
interface InterfaceElementWithOptions
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @param string $id
|
13 |
+
* @param string $name
|
14 |
+
* @return void
|
15 |
+
*/
|
16 |
+
public function addOption($id, $name);
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param string $id
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
public function removeOption($id);
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param array $options
|
26 |
+
* @return void
|
27 |
+
*/
|
28 |
+
public function addOptions($options);
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return array
|
32 |
+
*/
|
33 |
+
public function getOptions();
|
34 |
}
|
includes/Forms/Elements/Numerical.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class Numerical
|
6 |
-
* @package WPStaging\Forms\Elements
|
7 |
-
*/
|
8 |
-
class Numerical extends Elements
|
9 |
-
{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
protected function prepareOutput()
|
15 |
-
{
|
16 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='number' {$this->prepareAttributes()} value='{$this->default}' />";
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
public function render()
|
23 |
-
{
|
24 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
25 |
-
}
|
26 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Numerical
|
6 |
+
* @package WPStaging\Forms\Elements
|
7 |
+
*/
|
8 |
+
class Numerical extends Elements
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function prepareOutput()
|
15 |
+
{
|
16 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='number' {$this->prepareAttributes()} value='{$this->default}' />";
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
public function render()
|
23 |
+
{
|
24 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
25 |
+
}
|
26 |
}
|
includes/Forms/Elements/Password.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
use wpquads\ElementsWithOptions;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class Password
|
9 |
-
* @package WPStaging\Forms\Elements
|
10 |
-
*/
|
11 |
-
class Password extends Elements
|
12 |
-
{
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @return string
|
16 |
-
*/
|
17 |
-
protected function prepareOutput()
|
18 |
-
{
|
19 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='password' {$this->prepareAttributes()} value='{$this->default}' />";
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @return string
|
24 |
-
*/
|
25 |
-
public function render()
|
26 |
-
{
|
27 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
28 |
-
}
|
29 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
use wpquads\ElementsWithOptions;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Password
|
9 |
+
* @package WPStaging\Forms\Elements
|
10 |
+
*/
|
11 |
+
class Password extends Elements
|
12 |
+
{
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
protected function prepareOutput()
|
18 |
+
{
|
19 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='password' {$this->prepareAttributes()} value='{$this->default}' />";
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function render()
|
26 |
+
{
|
27 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
28 |
+
}
|
29 |
}
|
includes/Forms/Elements/Radio.php
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
use wpquads\ElementsWithOptions;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class Radio
|
9 |
-
* @package WPStaging\Forms\Elements
|
10 |
-
*/
|
11 |
-
//class Radio extends Elements
|
12 |
-
class Radio extends ElementsWithOptions
|
13 |
-
{
|
14 |
-
|
15 |
-
/**
|
16 |
-
* @return string
|
17 |
-
*/
|
18 |
-
protected function prepareOutput()
|
19 |
-
{
|
20 |
-
$output = '';
|
21 |
-
|
22 |
-
foreach ($this->options as $id => $value)
|
23 |
-
{
|
24 |
-
$checked = ($this->default && $this->default === $value) ? " checked=''" : '';
|
25 |
-
|
26 |
-
$attributeId = $this->getId($id);
|
27 |
-
|
28 |
-
$sanitize = str_replace (array('][', '[', ']'), '-', $this->getId()) ;
|
29 |
-
|
30 |
-
$output .= "<input type='radio' name='{$this->getId()}' id='{$sanitize}{$attributeId}' value='{$id}' {$checked}/>";
|
31 |
-
$output .= "<label for='{$sanitize}{$attributeId}' id='{$sanitize}{$attributeId}-label'>{$value}</label>";
|
32 |
-
}
|
33 |
-
|
34 |
-
return $output;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @return string
|
39 |
-
*/
|
40 |
-
public function render()
|
41 |
-
{
|
42 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
43 |
-
}
|
44 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
use wpquads\ElementsWithOptions;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Radio
|
9 |
+
* @package WPStaging\Forms\Elements
|
10 |
+
*/
|
11 |
+
//class Radio extends Elements
|
12 |
+
class Radio extends ElementsWithOptions
|
13 |
+
{
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
protected function prepareOutput()
|
19 |
+
{
|
20 |
+
$output = '';
|
21 |
+
|
22 |
+
foreach ($this->options as $id => $value)
|
23 |
+
{
|
24 |
+
$checked = ($this->default && $this->default === $value) ? " checked=''" : '';
|
25 |
+
|
26 |
+
$attributeId = $this->getId($id);
|
27 |
+
|
28 |
+
$sanitize = str_replace (array('][', '[', ']'), '-', $this->getId()) ;
|
29 |
+
|
30 |
+
$output .= "<input type='radio' name='{$this->getId()}' id='{$sanitize}{$attributeId}' value='{$id}' {$checked}/>";
|
31 |
+
$output .= "<label for='{$sanitize}{$attributeId}' id='{$sanitize}{$attributeId}-label'>{$value}</label>";
|
32 |
+
}
|
33 |
+
|
34 |
+
return $output;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return string
|
39 |
+
*/
|
40 |
+
public function render()
|
41 |
+
{
|
42 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
43 |
+
}
|
44 |
}
|
includes/Forms/Elements/Select.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
//use wpquads\includes\Forms\ElementsWithOptions;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class Select
|
8 |
-
* @package WPStaging\Forms\Elements
|
9 |
-
*/
|
10 |
-
class Select extends ElementsWithOptions
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
protected function prepareOutput()
|
17 |
-
{
|
18 |
-
$output = "<select id='{$this->getId()}' name='{$this->name}' {$this->prepareAttributes()}>";
|
19 |
-
|
20 |
-
foreach ($this->options as $id => $value)
|
21 |
-
{
|
22 |
-
$selected = ($this->isSelected($id)) ? " selected=''" : '';
|
23 |
-
|
24 |
-
$output .= "<option value='{$id}'{$selected}>{$value}</option>";
|
25 |
-
}
|
26 |
-
|
27 |
-
$output.= "</select>";
|
28 |
-
|
29 |
-
return $output;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @param string $value
|
34 |
-
* @return bool
|
35 |
-
*/
|
36 |
-
private function isSelected($value)
|
37 |
-
{
|
38 |
-
if (
|
39 |
-
$this->default &&
|
40 |
-
(
|
41 |
-
(is_string($this->default) && $this->default == $value) ||
|
42 |
-
(is_array($this->default) && in_array($value, $this->default))
|
43 |
-
)
|
44 |
-
)
|
45 |
-
{
|
46 |
-
return true;
|
47 |
-
}
|
48 |
-
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* @return string
|
54 |
-
*/
|
55 |
-
public function render()
|
56 |
-
{
|
57 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
58 |
-
}
|
59 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
//use wpquads\includes\Forms\ElementsWithOptions;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class Select
|
8 |
+
* @package WPStaging\Forms\Elements
|
9 |
+
*/
|
10 |
+
class Select extends ElementsWithOptions
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
protected function prepareOutput()
|
17 |
+
{
|
18 |
+
$output = "<select id='{$this->getId()}' name='{$this->name}' {$this->prepareAttributes()}>";
|
19 |
+
|
20 |
+
foreach ($this->options as $id => $value)
|
21 |
+
{
|
22 |
+
$selected = ($this->isSelected($id)) ? " selected=''" : '';
|
23 |
+
|
24 |
+
$output .= "<option value='{$id}'{$selected}>{$value}</option>";
|
25 |
+
}
|
26 |
+
|
27 |
+
$output.= "</select>";
|
28 |
+
|
29 |
+
return $output;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @param string $value
|
34 |
+
* @return bool
|
35 |
+
*/
|
36 |
+
private function isSelected($value)
|
37 |
+
{
|
38 |
+
if (
|
39 |
+
$this->default &&
|
40 |
+
(
|
41 |
+
(is_string($this->default) && $this->default == $value) ||
|
42 |
+
(is_array($this->default) && in_array($value, $this->default))
|
43 |
+
)
|
44 |
+
)
|
45 |
+
{
|
46 |
+
return true;
|
47 |
+
}
|
48 |
+
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function render()
|
56 |
+
{
|
57 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
58 |
+
}
|
59 |
}
|
includes/Forms/Elements/SelectMultiple.php
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Class Select
|
7 |
-
* @package WPStaging\Forms\Elements
|
8 |
-
*/
|
9 |
-
class SelectMultiple extends ElementsWithOptions
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @return string
|
14 |
-
*/
|
15 |
-
protected function prepareOutput()
|
16 |
-
{
|
17 |
-
$output = "<select multiple id='{$this->getId()}' name='{$this->name}[]' {$this->prepareAttributes()}>";
|
18 |
-
|
19 |
-
foreach ($this->options as $id => $value)
|
20 |
-
{
|
21 |
-
$selected = ($this->isSelected($id)) ? " selected=''" : '';
|
22 |
-
|
23 |
-
$output .= "<option value='{$id}'{$selected}>{$value}</option>";
|
24 |
-
}
|
25 |
-
|
26 |
-
$output.= "</select>";
|
27 |
-
|
28 |
-
return $output;
|
29 |
-
}
|
30 |
-
|
31 |
-
/**
|
32 |
-
* @param string $value
|
33 |
-
* @return bool
|
34 |
-
*/
|
35 |
-
private function isSelected($value)
|
36 |
-
{
|
37 |
-
if (
|
38 |
-
$this->default &&
|
39 |
-
(
|
40 |
-
(is_string($this->default) && $this->default === $value) ||
|
41 |
-
(is_array($this->default) && in_array($value, $this->default))
|
42 |
-
)
|
43 |
-
)
|
44 |
-
{
|
45 |
-
return true;
|
46 |
-
}
|
47 |
-
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* @return string
|
53 |
-
*/
|
54 |
-
public function render()
|
55 |
-
{
|
56 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
57 |
-
}
|
58 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class Select
|
7 |
+
* @package WPStaging\Forms\Elements
|
8 |
+
*/
|
9 |
+
class SelectMultiple extends ElementsWithOptions
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
protected function prepareOutput()
|
16 |
+
{
|
17 |
+
$output = "<select multiple id='{$this->getId()}' name='{$this->name}[]' {$this->prepareAttributes()}>";
|
18 |
+
|
19 |
+
foreach ($this->options as $id => $value)
|
20 |
+
{
|
21 |
+
$selected = ($this->isSelected($id)) ? " selected=''" : '';
|
22 |
+
|
23 |
+
$output .= "<option value='{$id}'{$selected}>{$value}</option>";
|
24 |
+
}
|
25 |
+
|
26 |
+
$output.= "</select>";
|
27 |
+
|
28 |
+
return $output;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @param string $value
|
33 |
+
* @return bool
|
34 |
+
*/
|
35 |
+
private function isSelected($value)
|
36 |
+
{
|
37 |
+
if (
|
38 |
+
$this->default &&
|
39 |
+
(
|
40 |
+
(is_string($this->default) && $this->default === $value) ||
|
41 |
+
(is_array($this->default) && in_array($value, $this->default))
|
42 |
+
)
|
43 |
+
)
|
44 |
+
{
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function render()
|
55 |
+
{
|
56 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
57 |
+
}
|
58 |
}
|
includes/Forms/Elements/Text.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Class Text
|
7 |
-
* @package WPStaging\Forms\Elements
|
8 |
-
*/
|
9 |
-
class Text extends Elements
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @return string
|
14 |
-
*/
|
15 |
-
protected function prepareOutput()
|
16 |
-
{
|
17 |
-
return "<input id='{$this->getId()}' name='{$this->getName()}' type='text' {$this->prepareAttributes()} value='{$this->default}' />";
|
18 |
-
}
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @return string
|
23 |
-
*/
|
24 |
-
public function render()
|
25 |
-
{
|
26 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
-
}
|
28 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Class Text
|
7 |
+
* @package WPStaging\Forms\Elements
|
8 |
+
*/
|
9 |
+
class Text extends Elements
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
protected function prepareOutput()
|
16 |
+
{
|
17 |
+
return "<input id='{$this->getId()}' name='{$this->getName()}' type='text' {$this->prepareAttributes()} value='{$this->default}' />";
|
18 |
+
}
|
19 |
+
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
+
}
|
28 |
}
|
includes/Forms/Elements/TextArea.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
use wpquads;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class TextArea
|
8 |
-
* @package WPStaging\Forms\Elements
|
9 |
-
*/
|
10 |
-
class TextArea extends Elements
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
protected function prepareOutput()
|
17 |
-
{
|
18 |
-
return "<textarea id='{$this->getId()}' name='{$this->getName()}' {$this->prepareAttributes()}>{$this->default}</textarea>";
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @return string
|
23 |
-
*/
|
24 |
-
public function render()
|
25 |
-
{
|
26 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
-
}
|
28 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
use wpquads;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class TextArea
|
8 |
+
* @package WPStaging\Forms\Elements
|
9 |
+
*/
|
10 |
+
class TextArea extends Elements
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
protected function prepareOutput()
|
17 |
+
{
|
18 |
+
return "<textarea id='{$this->getId()}' name='{$this->getName()}' {$this->prepareAttributes()}>{$this->default}</textarea>";
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
+
}
|
28 |
}
|
includes/Forms/Elements/TextAreaHidden.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
use wpquads;
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Class TextArea
|
8 |
-
* @package WPStaging\Forms\Elements
|
9 |
-
*/
|
10 |
-
class TextAreaHidden extends Elements
|
11 |
-
{
|
12 |
-
|
13 |
-
/**
|
14 |
-
* @return string
|
15 |
-
*/
|
16 |
-
protected function prepareOutput()
|
17 |
-
{
|
18 |
-
return "<textarea style='display:none;' id='{$this->getId()}' name='{$this->getName()}' {$this->prepareAttributes()}>{$this->default}</textarea>";
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* @return string
|
23 |
-
*/
|
24 |
-
public function render()
|
25 |
-
{
|
26 |
-
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
-
}
|
28 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
use wpquads;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Class TextArea
|
8 |
+
* @package WPStaging\Forms\Elements
|
9 |
+
*/
|
10 |
+
class TextAreaHidden extends Elements
|
11 |
+
{
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
protected function prepareOutput()
|
17 |
+
{
|
18 |
+
return "<textarea style='display:none;' id='{$this->getId()}' name='{$this->getName()}' {$this->prepareAttributes()}>{$this->default}</textarea>";
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
public function render()
|
25 |
+
{
|
26 |
+
return ($this->renderFile) ? @file_get_contents($this->renderFile) : $this->prepareOutput();
|
27 |
+
}
|
28 |
}
|
includes/Forms/ElementsWithOptions.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Class Elements
|
6 |
-
* @package WPStaging\Forms
|
7 |
-
*/
|
8 |
-
abstract class ElementsWithOptions extends Elements implements InterfaceElementWithOptions
|
9 |
-
{
|
10 |
-
|
11 |
-
/**
|
12 |
-
* @var array
|
13 |
-
*/
|
14 |
-
protected $options = array();
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Text constructor.
|
18 |
-
* @param string $name
|
19 |
-
* @param array $options
|
20 |
-
* @param array $attributes
|
21 |
-
*/
|
22 |
-
public function __construct($name, $options = array(), $attributes = array())
|
23 |
-
{
|
24 |
-
$this->setName($name);
|
25 |
-
$this->addOptions($options);
|
26 |
-
$this->setAttributes($attributes);
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @param string $id
|
31 |
-
* @param string $name
|
32 |
-
* @return $this
|
33 |
-
*/
|
34 |
-
public function addOption($id, $name)
|
35 |
-
{
|
36 |
-
$this->options[$id] = $name;
|
37 |
-
|
38 |
-
return $this;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param string $id
|
43 |
-
* @return $this
|
44 |
-
*/
|
45 |
-
public function removeOption($id)
|
46 |
-
{
|
47 |
-
if (isset($this->options[$id]))
|
48 |
-
{
|
49 |
-
unset($this->options[$id]);
|
50 |
-
}
|
51 |
-
|
52 |
-
return $this;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @param array $options
|
57 |
-
* @return $this
|
58 |
-
*/
|
59 |
-
public function addOptions($options)
|
60 |
-
{
|
61 |
-
foreach ($options as $id => $name)
|
62 |
-
{
|
63 |
-
$this->addOption($id, $name);
|
64 |
-
}
|
65 |
-
|
66 |
-
return $this;
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* @return array
|
71 |
-
*/
|
72 |
-
public function getOptions()
|
73 |
-
{
|
74 |
-
return $this->options;
|
75 |
-
}
|
76 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Elements
|
6 |
+
* @package WPStaging\Forms
|
7 |
+
*/
|
8 |
+
abstract class ElementsWithOptions extends Elements implements InterfaceElementWithOptions
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @var array
|
13 |
+
*/
|
14 |
+
protected $options = array();
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Text constructor.
|
18 |
+
* @param string $name
|
19 |
+
* @param array $options
|
20 |
+
* @param array $attributes
|
21 |
+
*/
|
22 |
+
public function __construct($name, $options = array(), $attributes = array())
|
23 |
+
{
|
24 |
+
$this->setName($name);
|
25 |
+
$this->addOptions($options);
|
26 |
+
$this->setAttributes($attributes);
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @param string $id
|
31 |
+
* @param string $name
|
32 |
+
* @return $this
|
33 |
+
*/
|
34 |
+
public function addOption($id, $name)
|
35 |
+
{
|
36 |
+
$this->options[$id] = $name;
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @param string $id
|
43 |
+
* @return $this
|
44 |
+
*/
|
45 |
+
public function removeOption($id)
|
46 |
+
{
|
47 |
+
if (isset($this->options[$id]))
|
48 |
+
{
|
49 |
+
unset($this->options[$id]);
|
50 |
+
}
|
51 |
+
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param array $options
|
57 |
+
* @return $this
|
58 |
+
*/
|
59 |
+
public function addOptions($options)
|
60 |
+
{
|
61 |
+
foreach ($options as $id => $name)
|
62 |
+
{
|
63 |
+
$this->addOption($id, $name);
|
64 |
+
}
|
65 |
+
|
66 |
+
return $this;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return array
|
71 |
+
*/
|
72 |
+
public function getOptions()
|
73 |
+
{
|
74 |
+
return $this->options;
|
75 |
+
}
|
76 |
}
|
includes/Forms/Form.php
CHANGED
@@ -1,60 +1,60 @@
|
|
1 |
-
<?php
|
2 |
-
namespace wpquads;
|
3 |
-
|
4 |
-
//use wpquads\InterfaceElement;
|
5 |
-
//use wpquads\InterfaceElementWithOptions;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class Form
|
9 |
-
* @package WPStaging\Forms
|
10 |
-
*/
|
11 |
-
class Form
|
12 |
-
{
|
13 |
-
|
14 |
-
protected $elements = array();
|
15 |
-
|
16 |
-
public function __construct()
|
17 |
-
{
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
public function add($element)
|
22 |
-
{
|
23 |
-
if (!($element instanceof InterfaceElement) && !($element instanceof InterfaceElementWithOptions))
|
24 |
-
{
|
25 |
-
return;
|
26 |
-
}
|
27 |
-
|
28 |
-
$this->elements[$element->getName()] = $element;
|
29 |
-
}
|
30 |
-
|
31 |
-
public function render($name)
|
32 |
-
{
|
33 |
-
if (!isset($this->elements[$name]))
|
34 |
-
{
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
|
38 |
-
return $this->elements[$name]->render();
|
39 |
-
}
|
40 |
-
|
41 |
-
public function label($name)
|
42 |
-
{
|
43 |
-
if (!isset($this->elements[$name]))
|
44 |
-
{
|
45 |
-
return false;
|
46 |
-
}
|
47 |
-
|
48 |
-
return $this->elements[$name]->prepareLabel();
|
49 |
-
}
|
50 |
-
|
51 |
-
public function tooltip($name)
|
52 |
-
{
|
53 |
-
if (!isset($this->elements[$name]))
|
54 |
-
{
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
|
58 |
-
return $this->elements[$name]->prepareTooltip();
|
59 |
-
}
|
60 |
}
|
1 |
+
<?php
|
2 |
+
namespace wpquads;
|
3 |
+
|
4 |
+
//use wpquads\InterfaceElement;
|
5 |
+
//use wpquads\InterfaceElementWithOptions;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Form
|
9 |
+
* @package WPStaging\Forms
|
10 |
+
*/
|
11 |
+
class Form
|
12 |
+
{
|
13 |
+
|
14 |
+
protected $elements = array();
|
15 |
+
|
16 |
+
public function __construct()
|
17 |
+
{
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
public function add($element)
|
22 |
+
{
|
23 |
+
if (!($element instanceof InterfaceElement) && !($element instanceof InterfaceElementWithOptions))
|
24 |
+
{
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->elements[$element->getName()] = $element;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function render($name)
|
32 |
+
{
|
33 |
+
if (!isset($this->elements[$name]))
|
34 |
+
{
|
35 |
+
return false;
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->elements[$name]->render();
|
39 |
+
}
|
40 |
+
|
41 |
+
public function label($name)
|
42 |
+
{
|
43 |
+
if (!isset($this->elements[$name]))
|
44 |
+
{
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
+
return $this->elements[$name]->prepareLabel();
|
49 |
+
}
|
50 |
+
|
51 |
+
public function tooltip($name)
|
52 |
+
{
|
53 |
+
if (!isset($this->elements[$name]))
|
54 |
+
{
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
return $this->elements[$name]->prepareTooltip();
|
59 |
+
}
|
60 |
}
|
includes/QUADS_SL_Plugin_Updater.php
CHANGED
@@ -1,338 +1,338 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Debug mode - Force plugin update
|
4 |
-
//set_site_transient( 'update_plugins', null );
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Allows plugins to use their own update API.
|
8 |
-
*
|
9 |
-
* @author Pippin Williamson
|
10 |
-
* @version 1.6
|
11 |
-
*/
|
12 |
-
class QUADS_SL_Plugin_Updater {
|
13 |
-
private $api_url = '';
|
14 |
-
private $api_data = array();
|
15 |
-
private $name = '';
|
16 |
-
private $slug = '';
|
17 |
-
private $version = '';
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Class constructor.
|
21 |
-
*
|
22 |
-
* @uses plugin_basename()
|
23 |
-
* @uses hook()
|
24 |
-
*
|
25 |
-
* @param string $_api_url The URL pointing to the custom API endpoint.
|
26 |
-
* @param string $_plugin_file Path to the plugin file.
|
27 |
-
* @param array $_api_data Optional data to send with API calls.
|
28 |
-
* @return void
|
29 |
-
*/
|
30 |
-
function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
31 |
-
$this->api_url = trailingslashit( $_api_url );
|
32 |
-
$this->api_data = $_api_data;
|
33 |
-
$this->name = plugin_basename( $_plugin_file );
|
34 |
-
$this->slug = basename( $_plugin_file, '.php' );
|
35 |
-
$this->version = $_api_data['version'];
|
36 |
-
|
37 |
-
// Set up hooks.
|
38 |
-
$this->init();
|
39 |
-
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Set up WordPress filters to hook into WP's update process.
|
44 |
-
*
|
45 |
-
* @uses add_filter()
|
46 |
-
*
|
47 |
-
* @return void
|
48 |
-
*/
|
49 |
-
public function init() {
|
50 |
-
|
51 |
-
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
52 |
-
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
53 |
-
|
54 |
-
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Check for Updates at the defined API endpoint and modify the update array.
|
59 |
-
*
|
60 |
-
* This function dives into the update API just when WordPress creates its update array,
|
61 |
-
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
62 |
-
* It is reassembled from parts of the native WordPress plugin update code.
|
63 |
-
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
64 |
-
*
|
65 |
-
* @uses api_request()
|
66 |
-
*
|
67 |
-
* @param array $_transient_data Update array build by WordPress.
|
68 |
-
* @return array Modified update array with custom plugin data.
|
69 |
-
*/
|
70 |
-
function check_update( $_transient_data ) {
|
71 |
-
|
72 |
-
global $pagenow;
|
73 |
-
|
74 |
-
if( ! is_object( $_transient_data ) ) {
|
75 |
-
$_transient_data = new stdClass;
|
76 |
-
}
|
77 |
-
|
78 |
-
if( 'plugins.php' == $pagenow && is_multisite() ) {
|
79 |
-
return $_transient_data;
|
80 |
-
}
|
81 |
-
|
82 |
-
if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
|
83 |
-
|
84 |
-
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
|
85 |
-
|
86 |
-
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
87 |
-
|
88 |
-
//$this->did_check = true;
|
89 |
-
|
90 |
-
if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
91 |
-
|
92 |
-
$_transient_data->response[ $this->name ] = $version_info;
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
$_transient_data->last_checked = time();
|
97 |
-
$_transient_data->checked[ $this->name ] = $this->version;
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
return $_transient_data;
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
108 |
-
*
|
109 |
-
* @param string $file
|
110 |
-
* @param array $plugin
|
111 |
-
*/
|
112 |
-
public function show_update_notification( $file, $plugin ) {
|
113 |
-
|
114 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
115 |
-
return;
|
116 |
-
}
|
117 |
-
|
118 |
-
if( ! is_multisite() ) {
|
119 |
-
return;
|
120 |
-
}
|
121 |
-
|
122 |
-
if ( $this->name != $file ) {
|
123 |
-
return;
|
124 |
-
}
|
125 |
-
|
126 |
-
// Remove our filter on the site transient
|
127 |
-
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
128 |
-
|
129 |
-
$update_cache = get_site_transient( 'update_plugins' );
|
130 |
-
|
131 |
-
if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
132 |
-
|
133 |
-
$cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
|
134 |
-
$version_info = get_transient( $cache_key );
|
135 |
-
|
136 |
-
if( false === $version_info ) {
|
137 |
-
|
138 |
-
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
|
139 |
-
|
140 |
-
set_transient( $cache_key, $version_info, 3600 );
|
141 |
-
}
|
142 |
-
|
143 |
-
|
144 |
-
if( ! is_object( $version_info ) ) {
|
145 |
-
return;
|
146 |
-
}
|
147 |
-
|
148 |
-
if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
149 |
-
|
150 |
-
$update_cache->response[ $this->name ] = $version_info;
|
151 |
-
|
152 |
-
}
|
153 |
-
|
154 |
-
$update_cache->last_checked = time();
|
155 |
-
$update_cache->checked[ $this->name ] = $this->version;
|
156 |
-
|
157 |
-
set_site_transient( 'update_plugins', $update_cache );
|
158 |
-
|
159 |
-
} else {
|
160 |
-
|
161 |
-
$version_info = $update_cache->response[ $this->name ];
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
// Restore our filter
|
166 |
-
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
167 |
-
|
168 |
-
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
169 |
-
|
170 |
-
// build a plugin list row, with update notification
|
171 |
-
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
172 |
-
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
173 |
-
|
174 |
-
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
175 |
-
|
176 |
-
if ( empty( $version_info->download_link ) ) {
|
177 |
-
printf(
|
178 |
-
__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
|
179 |
-
esc_html( $version_info->name ),
|
180 |
-
esc_url( $changelog_link ),
|
181 |
-
esc_html( $version_info->new_version )
|
182 |
-
);
|
183 |
-
} else {
|
184 |
-
printf(
|
185 |
-
__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
|
186 |
-
esc_html( $version_info->name ),
|
187 |
-
esc_url( $changelog_link ),
|
188 |
-
esc_html( $version_info->new_version ),
|
189 |
-
esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
|
190 |
-
);
|
191 |
-
}
|
192 |
-
|
193 |
-
echo '</div></td></tr>';
|
194 |
-
}
|
195 |
-
}
|
196 |
-
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Updates information on the "View version x.x details" page with custom data.
|
200 |
-
*
|
201 |
-
* @uses api_request()
|
202 |
-
*
|
203 |
-
* @param mixed $_data
|
204 |
-
* @param string $_action
|
205 |
-
* @param object $_args
|
206 |
-
* @return object $_data
|
207 |
-
*/
|
208 |
-
function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
209 |
-
|
210 |
-
|
211 |
-
if ( $_action != 'plugin_information' ) {
|
212 |
-
|
213 |
-
return $_data;
|
214 |
-
|
215 |
-
}
|
216 |
-
|
217 |
-
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
|
218 |
-
|
219 |
-
return $_data;
|
220 |
-
|
221 |
-
}
|
222 |
-
|
223 |
-
$to_send = array(
|
224 |
-
'slug' => $this->slug,
|
225 |
-
'is_ssl' => is_ssl(),
|
226 |
-
'fields' => array(
|
227 |
-
'banners' => false, // These will be supported soon hopefully
|
228 |
-
'reviews' => false
|
229 |
-
)
|
230 |
-
);
|
231 |
-
|
232 |
-
$api_response = $this->api_request( 'plugin_information', $to_send );
|
233 |
-
|
234 |
-
if ( false !== $api_response ) {
|
235 |
-
$_data = $api_response;
|
236 |
-
}
|
237 |
-
|
238 |
-
return $_data;
|
239 |
-
}
|
240 |
-
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Disable SSL verification in order to prevent download update failures
|
244 |
-
*
|
245 |
-
* @param array $args
|
246 |
-
* @param string $url
|
247 |
-
* @return object $array
|
248 |
-
*/
|
249 |
-
function http_request_args( $args, $url ) {
|
250 |
-
// If it is an https request and we are performing a package download, disable ssl verification
|
251 |
-
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
252 |
-
$args['sslverify'] = false;
|
253 |
-
}
|
254 |
-
return $args;
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* Calls the API and, if successfull, returns the object delivered by the API.
|
259 |
-
*
|
260 |
-
* @uses get_bloginfo()
|
261 |
-
* @uses wp_remote_post()
|
262 |
-
* @uses is_wp_error()
|
263 |
-
*
|
264 |
-
* @param string $_action The requested action.
|
265 |
-
* @param array $_data Parameters for the API action.
|
266 |
-
* @return false||object
|
267 |
-
*/
|
268 |
-
private function api_request( $_action, $_data ) {
|
269 |
-
|
270 |
-
global $wp_version, $edd_options;
|
271 |
-
|
272 |
-
$data = array_merge( $this->api_data, $_data );
|
273 |
-
|
274 |
-
if ( $data['slug'] != $this->slug )
|
275 |
-
return;
|
276 |
-
//if ( empty( $data['license']) && !isset( $edd_options['edd_sl_allow_update_notices'] ) )
|
277 |
-
if ( empty( $data['license']) )
|
278 |
-
return;
|
279 |
-
|
280 |
-
if( $this->api_url == home_url() ) {
|
281 |
-
return false; // Don't allow a plugin to ping itself
|
282 |
-
}
|
283 |
-
|
284 |
-
$api_params = array(
|
285 |
-
'edd_action' => 'get_version',
|
286 |
-
'license' => $data['license'],
|
287 |
-
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
288 |
-
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
289 |
-
'slug' => $data['slug'],
|
290 |
-
'author' => $data['author'],
|
291 |
-
'url' => home_url()
|
292 |
-
);
|
293 |
-
|
294 |
-
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
295 |
-
|
296 |
-
if ( ! is_wp_error( $request ) ) {
|
297 |
-
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
298 |
-
}
|
299 |
-
|
300 |
-
if ( $request && isset( $request->sections ) ) {
|
301 |
-
$request->sections = maybe_unserialize( $request->sections );
|
302 |
-
} else {
|
303 |
-
$request = false;
|
304 |
-
}
|
305 |
-
|
306 |
-
return $request;
|
307 |
-
}
|
308 |
-
|
309 |
-
public function show_changelog() {
|
310 |
-
|
311 |
-
|
312 |
-
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
313 |
-
return;
|
314 |
-
}
|
315 |
-
|
316 |
-
if( empty( $_REQUEST['plugin'] ) ) {
|
317 |
-
return;
|
318 |
-
}
|
319 |
-
|
320 |
-
if( empty( $_REQUEST['slug'] ) ) {
|
321 |
-
return;
|
322 |
-
}
|
323 |
-
|
324 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
325 |
-
wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
|
326 |
-
}
|
327 |
-
|
328 |
-
$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
|
329 |
-
|
330 |
-
if( $response && isset( $response->sections['changelog'] ) ) {
|
331 |
-
echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
|
332 |
-
}
|
333 |
-
|
334 |
-
|
335 |
-
exit;
|
336 |
-
}
|
337 |
-
|
338 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Debug mode - Force plugin update
|
4 |
+
//set_site_transient( 'update_plugins', null );
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Allows plugins to use their own update API.
|
8 |
+
*
|
9 |
+
* @author Pippin Williamson
|
10 |
+
* @version 1.6
|
11 |
+
*/
|
12 |
+
class QUADS_SL_Plugin_Updater {
|
13 |
+
private $api_url = '';
|
14 |
+
private $api_data = array();
|
15 |
+
private $name = '';
|
16 |
+
private $slug = '';
|
17 |
+
private $version = '';
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Class constructor.
|
21 |
+
*
|
22 |
+
* @uses plugin_basename()
|
23 |
+
* @uses hook()
|
24 |
+
*
|
25 |
+
* @param string $_api_url The URL pointing to the custom API endpoint.
|
26 |
+
* @param string $_plugin_file Path to the plugin file.
|
27 |
+
* @param array $_api_data Optional data to send with API calls.
|
28 |
+
* @return void
|
29 |
+
*/
|
30 |
+
function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
31 |
+
$this->api_url = trailingslashit( $_api_url );
|
32 |
+
$this->api_data = $_api_data;
|
33 |
+
$this->name = plugin_basename( $_plugin_file );
|
34 |
+
$this->slug = basename( $_plugin_file, '.php' );
|
35 |
+
$this->version = $_api_data['version'];
|
36 |
+
|
37 |
+
// Set up hooks.
|
38 |
+
$this->init();
|
39 |
+
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Set up WordPress filters to hook into WP's update process.
|
44 |
+
*
|
45 |
+
* @uses add_filter()
|
46 |
+
*
|
47 |
+
* @return void
|
48 |
+
*/
|
49 |
+
public function init() {
|
50 |
+
|
51 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
52 |
+
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
53 |
+
|
54 |
+
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
59 |
+
*
|
60 |
+
* This function dives into the update API just when WordPress creates its update array,
|
61 |
+
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
62 |
+
* It is reassembled from parts of the native WordPress plugin update code.
|
63 |
+
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
64 |
+
*
|
65 |
+
* @uses api_request()
|
66 |
+
*
|
67 |
+
* @param array $_transient_data Update array build by WordPress.
|
68 |
+
* @return array Modified update array with custom plugin data.
|
69 |
+
*/
|
70 |
+
function check_update( $_transient_data ) {
|
71 |
+
|
72 |
+
global $pagenow;
|
73 |
+
|
74 |
+
if( ! is_object( $_transient_data ) ) {
|
75 |
+
$_transient_data = new stdClass;
|
76 |
+
}
|
77 |
+
|
78 |
+
if( 'plugins.php' == $pagenow && is_multisite() ) {
|
79 |
+
return $_transient_data;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
|
83 |
+
|
84 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
|
85 |
+
|
86 |
+
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
87 |
+
|
88 |
+
//$this->did_check = true;
|
89 |
+
|
90 |
+
if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
91 |
+
|
92 |
+
$_transient_data->response[ $this->name ] = $version_info;
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
$_transient_data->last_checked = time();
|
97 |
+
$_transient_data->checked[ $this->name ] = $this->version;
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
return $_transient_data;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
108 |
+
*
|
109 |
+
* @param string $file
|
110 |
+
* @param array $plugin
|
111 |
+
*/
|
112 |
+
public function show_update_notification( $file, $plugin ) {
|
113 |
+
|
114 |
+
if( ! current_user_can( 'update_plugins' ) ) {
|
115 |
+
return;
|
116 |
+
}
|
117 |
+
|
118 |
+
if( ! is_multisite() ) {
|
119 |
+
return;
|
120 |
+
}
|
121 |
+
|
122 |
+
if ( $this->name != $file ) {
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
// Remove our filter on the site transient
|
127 |
+
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
128 |
+
|
129 |
+
$update_cache = get_site_transient( 'update_plugins' );
|
130 |
+
|
131 |
+
if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
132 |
+
|
133 |
+
$cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
|
134 |
+
$version_info = get_transient( $cache_key );
|
135 |
+
|
136 |
+
if( false === $version_info ) {
|
137 |
+
|
138 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
|
139 |
+
|
140 |
+
set_transient( $cache_key, $version_info, 3600 );
|
141 |
+
}
|
142 |
+
|
143 |
+
|
144 |
+
if( ! is_object( $version_info ) ) {
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
149 |
+
|
150 |
+
$update_cache->response[ $this->name ] = $version_info;
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
$update_cache->last_checked = time();
|
155 |
+
$update_cache->checked[ $this->name ] = $this->version;
|
156 |
+
|
157 |
+
set_site_transient( 'update_plugins', $update_cache );
|
158 |
+
|
159 |
+
} else {
|
160 |
+
|
161 |
+
$version_info = $update_cache->response[ $this->name ];
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
// Restore our filter
|
166 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
167 |
+
|
168 |
+
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
169 |
+
|
170 |
+
// build a plugin list row, with update notification
|
171 |
+
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
172 |
+
echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
|
173 |
+
|
174 |
+
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
175 |
+
|
176 |
+
if ( empty( $version_info->download_link ) ) {
|
177 |
+
printf(
|
178 |
+
__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
|
179 |
+
esc_html( $version_info->name ),
|
180 |
+
esc_url( $changelog_link ),
|
181 |
+
esc_html( $version_info->new_version )
|
182 |
+
);
|
183 |
+
} else {
|
184 |
+
printf(
|
185 |
+
__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
|
186 |
+
esc_html( $version_info->name ),
|
187 |
+
esc_url( $changelog_link ),
|
188 |
+
esc_html( $version_info->new_version ),
|
189 |
+
esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
|
190 |
+
);
|
191 |
+
}
|
192 |
+
|
193 |
+
echo '</div></td></tr>';
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Updates information on the "View version x.x details" page with custom data.
|
200 |
+
*
|
201 |
+
* @uses api_request()
|
202 |
+
*
|
203 |
+
* @param mixed $_data
|
204 |
+
* @param string $_action
|
205 |
+
* @param object $_args
|
206 |
+
* @return object $_data
|
207 |
+
*/
|
208 |
+
function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
209 |
+
|
210 |
+
|
211 |
+
if ( $_action != 'plugin_information' ) {
|
212 |
+
|
213 |
+
return $_data;
|
214 |
+
|
215 |
+
}
|
216 |
+
|
217 |
+
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
|
218 |
+
|
219 |
+
return $_data;
|
220 |
+
|
221 |
+
}
|
222 |
+
|
223 |
+
$to_send = array(
|
224 |
+
'slug' => $this->slug,
|
225 |
+
'is_ssl' => is_ssl(),
|
226 |
+
'fields' => array(
|
227 |
+
'banners' => false, // These will be supported soon hopefully
|
228 |
+
'reviews' => false
|
229 |
+
)
|
230 |
+
);
|
231 |
+
|
232 |
+
$api_response = $this->api_request( 'plugin_information', $to_send );
|
233 |
+
|
234 |
+
if ( false !== $api_response ) {
|
235 |
+
$_data = $api_response;
|
236 |
+
}
|
237 |
+
|
238 |
+
return $_data;
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Disable SSL verification in order to prevent download update failures
|
244 |
+
*
|
245 |
+
* @param array $args
|
246 |
+
* @param string $url
|
247 |
+
* @return object $array
|
248 |
+
*/
|
249 |
+
function http_request_args( $args, $url ) {
|
250 |
+
// If it is an https request and we are performing a package download, disable ssl verification
|
251 |
+
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
252 |
+
$args['sslverify'] = false;
|
253 |
+
}
|
254 |
+
return $args;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Calls the API and, if successfull, returns the object delivered by the API.
|
259 |
+
*
|
260 |
+
* @uses get_bloginfo()
|
261 |
+
* @uses wp_remote_post()
|
262 |
+
* @uses is_wp_error()
|
263 |
+
*
|
264 |
+
* @param string $_action The requested action.
|
265 |
+
* @param array $_data Parameters for the API action.
|
266 |
+
* @return false||object
|
267 |
+
*/
|
268 |
+
private function api_request( $_action, $_data ) {
|
269 |
+
|
270 |
+
global $wp_version, $edd_options;
|
271 |
+
|
272 |
+
$data = array_merge( $this->api_data, $_data );
|
273 |
+
|
274 |
+
if ( $data['slug'] != $this->slug )
|
275 |
+
return;
|
276 |
+
//if ( empty( $data['license']) && !isset( $edd_options['edd_sl_allow_update_notices'] ) )
|
277 |
+
if ( empty( $data['license']) )
|
278 |
+
return;
|
279 |
+
|
280 |
+
if( $this->api_url == home_url() ) {
|
281 |
+
return false; // Don't allow a plugin to ping itself
|
282 |
+
}
|
283 |
+
|
284 |
+
$api_params = array(
|
285 |
+
'edd_action' => 'get_version',
|
286 |
+
'license' => $data['license'],
|
287 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
288 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
289 |
+
'slug' => $data['slug'],
|
290 |
+
'author' => $data['author'],
|
291 |
+
'url' => home_url()
|
292 |
+
);
|
293 |
+
|
294 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
|
295 |
+
|
296 |
+
if ( ! is_wp_error( $request ) ) {
|
297 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
298 |
+
}
|
299 |
+
|
300 |
+
if ( $request && isset( $request->sections ) ) {
|
301 |
+
$request->sections = maybe_unserialize( $request->sections );
|
302 |
+
} else {
|
303 |
+
$request = false;
|
304 |
+
}
|
305 |
+
|
306 |
+
return $request;
|
307 |
+
}
|
308 |
+
|
309 |
+
public function show_changelog() {
|
310 |
+
|
311 |
+
|
312 |
+
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
313 |
+
return;
|
314 |
+
}
|
315 |
+
|
316 |
+
if( empty( $_REQUEST['plugin'] ) ) {
|
317 |
+
return;
|
318 |
+
}
|
319 |
+
|
320 |
+
if( empty( $_REQUEST['slug'] ) ) {
|
321 |
+
return;
|
322 |
+
}
|
323 |
+
|
324 |
+
if( ! current_user_can( 'update_plugins' ) ) {
|
325 |
+
wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
|
326 |
+
}
|
327 |
+
|
328 |
+
$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
|
329 |
+
|
330 |
+
if( $response && isset( $response->sections['changelog'] ) ) {
|
331 |
+
echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
|
332 |
+
}
|
333 |
+
|
334 |
+
|
335 |
+
exit;
|
336 |
+
}
|
337 |
+
|
338 |
+
}
|
includes/admin/add-ons.php
CHANGED
@@ -1,122 +1,122 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin Add-ons
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Add-ons
|
7 |
-
* @copyright Copyright (c) 2015, Rene Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 1.1.8
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly
|
13 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
-
|
15 |
-
add_action('admin_head', 'quads_admin_inline_css');
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Create admin inline css to bypass adblock plugin which is blocking wp quads css ressources
|
19 |
-
*/
|
20 |
-
function quads_admin_inline_css() {
|
21 |
-
if (!quads_is_addon_page()){
|
22 |
-
return false;
|
23 |
-
}
|
24 |
-
echo '<style>
|
25 |
-
.quads-button.green {
|
26 |
-
display: inline-block;
|
27 |
-
background-color: #83c11f;
|
28 |
-
padding: 10px;
|
29 |
-
min-width: 170px;
|
30 |
-
color: white;
|
31 |
-
font-size: 16px;
|
32 |
-
text-decoration: none;
|
33 |
-
text-align: center;
|
34 |
-
margin-top: 20px;
|
35 |
-
}
|
36 |
-
#quads-add-ons li {
|
37 |
-
font-size: 18px;
|
38 |
-
line-height: 29px;
|
39 |
-
position: relative;
|
40 |
-
padding-left: 23px;
|
41 |
-
list-style: none!important;
|
42 |
-
}
|
43 |
-
.quads-heading-pro {
|
44 |
-
color: #83c11f;
|
45 |
-
font-weight: bold;
|
46 |
-
}
|
47 |
-
.quads-h2 {
|
48 |
-
margin-top: 0px;
|
49 |
-
margin-bottom: 1.2rem;
|
50 |
-
font-size: 30px;
|
51 |
-
line-height: 2.5rem;
|
52 |
-
}
|
53 |
-
#quads-add-ons li:before {
|
54 |
-
width: 1em;
|
55 |
-
height: 100%;
|
56 |
-
background: url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;
|
57 |
-
background-size: contain;
|
58 |
-
content: "";
|
59 |
-
position: absolute;
|
60 |
-
top: 0;
|
61 |
-
left: 0;
|
62 |
-
color: #77b227;
|
63 |
-
}
|
64 |
-
.quads-h1 {
|
65 |
-
font-size: 2.75em;
|
66 |
-
margin-bottom: 1.35rem;
|
67 |
-
font-size: 2.5em;
|
68 |
-
line-height: 3.68rem;
|
69 |
-
letter-spacing: normal;
|
70 |
-
}
|
71 |
-
#quads-add-ons h2 {
|
72 |
-
margin: 0 0 15px;
|
73 |
-
}
|
74 |
-
#quads-add-ons .quads-footer {
|
75 |
-
clear: both;
|
76 |
-
margin-top: 20px;
|
77 |
-
font-style: italic;
|
78 |
-
}
|
79 |
-
</style>';
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Add-ons
|
84 |
-
*
|
85 |
-
* Renders the add-ons content.
|
86 |
-
*
|
87 |
-
* @since 1.1.8
|
88 |
-
* @return void
|
89 |
-
*/
|
90 |
-
function quads_add_ons_page() {
|
91 |
-
ob_start(); ?>
|
92 |
-
<div class="wrap_" id="quads-add-ons">
|
93 |
-
<h2 class="quads-h1">WP QUADS Premium Integrations: </h2>
|
94 |
-
<div style="border: 2px solid white;padding: 20px;margin-bottom:20px;">
|
95 |
-
<h2 class="quads-h2">
|
96 |
-
<span class="quads-heading-pro"><?php _e( 'WP QUADS PRO', 'quick-adsense-reloaded' ); ?></span><?php _e( ', save time and earn more with next level AdSense integration!', 'quick-adsense-reloaded' ); ?>
|
97 |
-
</h2>
|
98 |
-
<h2 style="display:none;"><?php _e( 'Mobile and Responsive AdSense Support ', 'quick-adsense-reloaded' ); ?></h2>
|
99 |
-
<li><strong>Responsive Ads</strong> - <?php _e('individual AdSense sizes for Desktop, Phone and Tablet devices.','quick-adsense-reloaded' ); ?></li>
|
100 |
-
<li><strong>Visibility Conditions</strong> - <?php _e('decide if AdSense is visible on mobile, tablet or desktop', 'quick-adsense-reloaded' ); ?></li>
|
101 |
-
<li><strong>Automatic Mode</strong> - <?php _e('let the plugin detect optimal ad size on all devices.', 'quick-adsense-reloaded' ); ?></li>
|
102 |
-
<li><strong>High Performance</strong> - <?php _e('this plugin keeps the speed of your site', 'quick-adsense-reloaded' ); ?></li>
|
103 |
-
<a href="http://wpquads.com/?utm_source=wpquads&utm_medium=addon_page&utm_term=click-quads-pro&utm_campaign=wpquads" target="_blank" class="quads-button green">Buy WP QUADS Pro</a>
|
104 |
-
<a href="<?php echo admin_url(); ?>admin.php?page=quads-settings" target="_self" style="margin-left:30px;">Skip - Go to Settings</a>
|
105 |
-
<div class="quads-footer" style="display:none;"> <?php _e('Comes with our 30-day no questions asked money back guarantee','quick-adsense-reloaded'); ?></div>
|
106 |
-
</div>
|
107 |
-
<div style="float:left;width:50%;border: 2px solid white;padding: 20px;display:none;">
|
108 |
-
<h2>
|
109 |
-
<?php _e( 'Clickfraud Monitor Integration', 'quick-adsense-reloaded' ); ?>
|
110 |
-
<!-- — <a href="https://www.quadsshare.net" class="button-primary" title="<?php _e( 'Visit Website', 'quick-adsense-reloaded' ); ?>" target="_blank"><?php _e( 'See Details', 'quick-adsense-reloaded' ); ?></a>-->
|
111 |
-
</h2>
|
112 |
-
<h2><?php _e( 'Protect your AdSense Account ', 'quick-adsense-reloaded' ); ?></h2>
|
113 |
-
<p><?php _e('Monitor and protect all your advertisements on your site.<br> Click protection for Google AdSense and other pay per click vendors.','quick-adsense-reloaded' ); ?></p>
|
114 |
-
<p><?php _e('Fully integrated in WP<strong>QUADS</strong> or completely independant and compatible with <br>any other AdSense Plugin, even with manual inserted ads.', 'quick-adsense-reloaded' ); ?></p>
|
115 |
-
<a href="http://demo.clickfraud-monitoring.com/pricing/?utm_source=wpquads&utm_medium=addon_page&utm_term=click-clickfraud&utm_campaign=wpquads" target="_blank" class="button button-primary">See Demo</a>
|
116 |
-
<a href="<?php echo admin_url(); ?>admin.php?page=quads-settings" target="_blank" class="button">Maybe later - Go to Settings</a>
|
117 |
-
|
118 |
-
</div>
|
119 |
-
</div>
|
120 |
-
<?php
|
121 |
-
echo ob_get_clean();
|
122 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Add-ons
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Add-ons
|
7 |
+
* @copyright Copyright (c) 2015, Rene Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 1.1.8
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
add_action('admin_head', 'quads_admin_inline_css');
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Create admin inline css to bypass adblock plugin which is blocking wp quads css ressources
|
19 |
+
*/
|
20 |
+
function quads_admin_inline_css() {
|
21 |
+
if (!quads_is_addon_page()){
|
22 |
+
return false;
|
23 |
+
}
|
24 |
+
echo '<style>
|
25 |
+
.quads-button.green {
|
26 |
+
display: inline-block;
|
27 |
+
background-color: #83c11f;
|
28 |
+
padding: 10px;
|
29 |
+
min-width: 170px;
|
30 |
+
color: white;
|
31 |
+
font-size: 16px;
|
32 |
+
text-decoration: none;
|
33 |
+
text-align: center;
|
34 |
+
margin-top: 20px;
|
35 |
+
}
|
36 |
+
#quads-add-ons li {
|
37 |
+
font-size: 18px;
|
38 |
+
line-height: 29px;
|
39 |
+
position: relative;
|
40 |
+
padding-left: 23px;
|
41 |
+
list-style: none!important;
|
42 |
+
}
|
43 |
+
.quads-heading-pro {
|
44 |
+
color: #83c11f;
|
45 |
+
font-weight: bold;
|
46 |
+
}
|
47 |
+
.quads-h2 {
|
48 |
+
margin-top: 0px;
|
49 |
+
margin-bottom: 1.2rem;
|
50 |
+
font-size: 30px;
|
51 |
+
line-height: 2.5rem;
|
52 |
+
}
|
53 |
+
#quads-add-ons li:before {
|
54 |
+
width: 1em;
|
55 |
+
height: 100%;
|
56 |
+
background: url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;
|
57 |
+
background-size: contain;
|
58 |
+
content: "";
|
59 |
+
position: absolute;
|
60 |
+
top: 0;
|
61 |
+
left: 0;
|
62 |
+
color: #77b227;
|
63 |
+
}
|
64 |
+
.quads-h1 {
|
65 |
+
font-size: 2.75em;
|
66 |
+
margin-bottom: 1.35rem;
|
67 |
+
font-size: 2.5em;
|
68 |
+
line-height: 3.68rem;
|
69 |
+
letter-spacing: normal;
|
70 |
+
}
|
71 |
+
#quads-add-ons h2 {
|
72 |
+
margin: 0 0 15px;
|
73 |
+
}
|
74 |
+
#quads-add-ons .quads-footer {
|
75 |
+
clear: both;
|
76 |
+
margin-top: 20px;
|
77 |
+
font-style: italic;
|
78 |
+
}
|
79 |
+
</style>';
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Add-ons
|
84 |
+
*
|
85 |
+
* Renders the add-ons content.
|
86 |
+
*
|
87 |
+
* @since 1.1.8
|
88 |
+
* @return void
|
89 |
+
*/
|
90 |
+
function quads_add_ons_page() {
|
91 |
+
ob_start(); ?>
|
92 |
+
<div class="wrap_" id="quads-add-ons">
|
93 |
+
<h2 class="quads-h1">WP QUADS Premium Integrations: </h2>
|
94 |
+
<div style="border: 2px solid white;padding: 20px;margin-bottom:20px;">
|
95 |
+
<h2 class="quads-h2">
|
96 |
+
<span class="quads-heading-pro"><?php _e( 'WP QUADS PRO', 'quick-adsense-reloaded' ); ?></span><?php _e( ', save time and earn more with next level AdSense integration!', 'quick-adsense-reloaded' ); ?>
|
97 |
+
</h2>
|
98 |
+
<h2 style="display:none;"><?php _e( 'Mobile and Responsive AdSense Support ', 'quick-adsense-reloaded' ); ?></h2>
|
99 |
+
<li><strong>Responsive Ads</strong> - <?php _e('individual AdSense sizes for Desktop, Phone and Tablet devices.','quick-adsense-reloaded' ); ?></li>
|
100 |
+
<li><strong>Visibility Conditions</strong> - <?php _e('decide if AdSense is visible on mobile, tablet or desktop', 'quick-adsense-reloaded' ); ?></li>
|
101 |
+
<li><strong>Automatic Mode</strong> - <?php _e('let the plugin detect optimal ad size on all devices.', 'quick-adsense-reloaded' ); ?></li>
|
102 |
+
<li><strong>High Performance</strong> - <?php _e('this plugin keeps the speed of your site', 'quick-adsense-reloaded' ); ?></li>
|
103 |
+
<a href="http://wpquads.com/?utm_source=wpquads&utm_medium=addon_page&utm_term=click-quads-pro&utm_campaign=wpquads" target="_blank" class="quads-button green">Buy WP QUADS Pro</a>
|
104 |
+
<a href="<?php echo admin_url(); ?>admin.php?page=quads-settings" target="_self" style="margin-left:30px;">Skip - Go to Settings</a>
|
105 |
+
<div class="quads-footer" style="display:none;"> <?php _e('Comes with our 30-day no questions asked money back guarantee','quick-adsense-reloaded'); ?></div>
|
106 |
+
</div>
|
107 |
+
<div style="float:left;width:50%;border: 2px solid white;padding: 20px;display:none;">
|
108 |
+
<h2>
|
109 |
+
<?php _e( 'Clickfraud Monitor Integration', 'quick-adsense-reloaded' ); ?>
|
110 |
+
<!-- — <a href="https://www.quadsshare.net" class="button-primary" title="<?php _e( 'Visit Website', 'quick-adsense-reloaded' ); ?>" target="_blank"><?php _e( 'See Details', 'quick-adsense-reloaded' ); ?></a>-->
|
111 |
+
</h2>
|
112 |
+
<h2><?php _e( 'Protect your AdSense Account ', 'quick-adsense-reloaded' ); ?></h2>
|
113 |
+
<p><?php _e('Monitor and protect all your advertisements on your site.<br> Click protection for Google AdSense and other pay per click vendors.','quick-adsense-reloaded' ); ?></p>
|
114 |
+
<p><?php _e('Fully integrated in WP<strong>QUADS</strong> or completely independant and compatible with <br>any other AdSense Plugin, even with manual inserted ads.', 'quick-adsense-reloaded' ); ?></p>
|
115 |
+
<a href="http://demo.clickfraud-monitoring.com/pricing/?utm_source=wpquads&utm_medium=addon_page&utm_term=click-clickfraud&utm_campaign=wpquads" target="_blank" class="button button-primary">See Demo</a>
|
116 |
+
<a href="<?php echo admin_url(); ?>admin.php?page=quads-settings" target="_blank" class="button">Maybe later - Go to Settings</a>
|
117 |
+
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
+
<?php
|
121 |
+
echo ob_get_clean();
|
122 |
}
|
includes/admin/admin-actions.php
CHANGED
@@ -1,150 +1,150 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Admin Actions
|
5 |
-
*
|
6 |
-
* @package QUADS
|
7 |
-
* @subpackage Admin/Actions
|
8 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
9 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
10 |
-
* @since 1.0
|
11 |
-
*/
|
12 |
-
// Exit if accessed directly
|
13 |
-
if (!defined('ABSPATH'))
|
14 |
-
exit;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Processes all QUADS actions sent via POST and GET by looking for the 'quads-action'
|
18 |
-
* request and running do_action() to call the function
|
19 |
-
*
|
20 |
-
* @since 1.0
|
21 |
-
* @return void
|
22 |
-
*/
|
23 |
-
function quads_process_actions() {
|
24 |
-
if (isset($_POST['quads-action'])) {
|
25 |
-
do_action('quads_' . $_POST['quads-action'], $_POST);
|
26 |
-
}
|
27 |
-
|
28 |
-
if (isset($_GET['quads-action'])) {
|
29 |
-
do_action('quads_' . $_GET['quads-action'], $_GET);
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
add_action('admin_init', 'quads_process_actions');
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Update option quads_show_theme_notice
|
37 |
-
* "no" means no further upgrade notices are shown
|
38 |
-
*/
|
39 |
-
function quads_close_upgrade_notice() {
|
40 |
-
update_option('quads_show_theme_notice', 'no');
|
41 |
-
}
|
42 |
-
|
43 |
-
add_action('quads_close_upgrade_notice', 'quads_close_upgrade_notice');
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Close vi welcome notice and do not show again
|
47 |
-
*/
|
48 |
-
function quads_close_vi_welcome_notice() {
|
49 |
-
update_option('quads_close_vi_welcome_notice', 'yes');
|
50 |
-
}
|
51 |
-
|
52 |
-
add_action('quads_close_vi_welcome_notice', 'quads_close_vi_welcome_notice');
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Close vi update notice and show it one week later again
|
56 |
-
*/
|
57 |
-
function quads_show_vi_notice_later() {
|
58 |
-
$nextweek = time() + (7 * 24 * 60 * 60);
|
59 |
-
$human_date = date('Y-m-d h:i:s', $nextweek);
|
60 |
-
update_option('quads_show_vi_notice_later', $human_date);
|
61 |
-
update_option('quads_close_vi_notice', 'yes');
|
62 |
-
}
|
63 |
-
|
64 |
-
add_action('quads_show_vi_notice_later', 'quads_show_vi_notice_later');
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Save vi token
|
68 |
-
*/
|
69 |
-
function quads_save_vi_token() {
|
70 |
-
global $quads_options;
|
71 |
-
|
72 |
-
if (empty($_POST['token'])) {
|
73 |
-
echo json_encode(array("status" => "failed"));
|
74 |
-
wp_die();
|
75 |
-
}
|
76 |
-
|
77 |
-
// Save token before trying to create ads.txt
|
78 |
-
update_option('quads_vi_token', $_POST['token']);
|
79 |
-
|
80 |
-
if (!isset($quads_options['adsTxtEnabled'])) {
|
81 |
-
set_transient('quads_vi_ads_txt_disabled', true, 300);
|
82 |
-
delete_transient('quads_vi_ads_txt_error');
|
83 |
-
delete_transient('quads_vi_ads_txt_notice');
|
84 |
-
echo json_encode(array("status" => "success", "token" => $_POST['token'], "adsTxt" => 'disabled'));
|
85 |
-
wp_die();
|
86 |
-
}
|
87 |
-
|
88 |
-
$vi = new wpquads\vi();
|
89 |
-
|
90 |
-
if ($vi->createAdsTxt()) {
|
91 |
-
set_transient('quads_vi_ads_txt_notice', true, 300);
|
92 |
-
delete_transient('quads_vi_ads_txt_error');
|
93 |
-
} else {
|
94 |
-
set_transient('quads_vi_ads_txt_error', true, 300);
|
95 |
-
delete_transient('quads_vi_ads_txt_notice');
|
96 |
-
}
|
97 |
-
|
98 |
-
|
99 |
-
// Create AdSense ads.txt entries
|
100 |
-
$adsense = new \wpquads\adsense($quads_options);
|
101 |
-
$adsense->writeAdsTxt();
|
102 |
-
|
103 |
-
//sleep(5);
|
104 |
-
echo json_encode(array("status" => "success", "token" => $_POST['token']));
|
105 |
-
wp_die();
|
106 |
-
}
|
107 |
-
|
108 |
-
add_action('wp_ajax_quads_save_vi_token', 'quads_save_vi_token');
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Save vi ad settings and create ad code
|
112 |
-
*/
|
113 |
-
function quads_save_vi_ads() {
|
114 |
-
global $quads;
|
115 |
-
|
116 |
-
$return = $quads->vi->setAdCode();
|
117 |
-
|
118 |
-
if ($return) {
|
119 |
-
wp_die($return);
|
120 |
-
} else {
|
121 |
-
wp_die(array('status' => 'error', 'message' => 'Unknown API Error. Can not get vi ad code'));
|
122 |
-
}
|
123 |
-
}
|
124 |
-
add_action('wp_ajax_quads_save_vi_ads', 'quads_save_vi_ads');
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Logout of vi
|
128 |
-
*/
|
129 |
-
function quads_logout_vi() {
|
130 |
-
delete_option('quads_vi_token');
|
131 |
-
}
|
132 |
-
add_action('quads_logout_vi', 'quads_logout_vi');
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Hide ads txt information notice
|
136 |
-
*/
|
137 |
-
function quads_close_ads_txt_notice() {
|
138 |
-
delete_transient('quads_ads_txt_notice');
|
139 |
-
}
|
140 |
-
add_action('quads_close_ads_txt_notice', 'quads_close_ads_txt_notice');
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Hide ads txt error notice
|
144 |
-
*/
|
145 |
-
function quads_close_ads_txt_error() {
|
146 |
-
delete_transient('quads_ads_txt_error');
|
147 |
-
}
|
148 |
-
add_action('quads_close_ads_txt_error', 'quads_close_ads_txt_error');
|
149 |
-
|
150 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Admin Actions
|
5 |
+
*
|
6 |
+
* @package QUADS
|
7 |
+
* @subpackage Admin/Actions
|
8 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
9 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
10 |
+
* @since 1.0
|
11 |
+
*/
|
12 |
+
// Exit if accessed directly
|
13 |
+
if (!defined('ABSPATH'))
|
14 |
+
exit;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Processes all QUADS actions sent via POST and GET by looking for the 'quads-action'
|
18 |
+
* request and running do_action() to call the function
|
19 |
+
*
|
20 |
+
* @since 1.0
|
21 |
+
* @return void
|
22 |
+
*/
|
23 |
+
function quads_process_actions() {
|
24 |
+
if (isset($_POST['quads-action'])) {
|
25 |
+
do_action('quads_' . $_POST['quads-action'], $_POST);
|
26 |
+
}
|
27 |
+
|
28 |
+
if (isset($_GET['quads-action'])) {
|
29 |
+
do_action('quads_' . $_GET['quads-action'], $_GET);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
add_action('admin_init', 'quads_process_actions');
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Update option quads_show_theme_notice
|
37 |
+
* "no" means no further upgrade notices are shown
|
38 |
+
*/
|
39 |
+
function quads_close_upgrade_notice() {
|
40 |
+
update_option('quads_show_theme_notice', 'no');
|
41 |
+
}
|
42 |
+
|
43 |
+
add_action('quads_close_upgrade_notice', 'quads_close_upgrade_notice');
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Close vi welcome notice and do not show again
|
47 |
+
*/
|
48 |
+
function quads_close_vi_welcome_notice() {
|
49 |
+
update_option('quads_close_vi_welcome_notice', 'yes');
|
50 |
+
}
|
51 |
+
|
52 |
+
add_action('quads_close_vi_welcome_notice', 'quads_close_vi_welcome_notice');
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Close vi update notice and show it one week later again
|
56 |
+
*/
|
57 |
+
function quads_show_vi_notice_later() {
|
58 |
+
$nextweek = time() + (7 * 24 * 60 * 60);
|
59 |
+
$human_date = date('Y-m-d h:i:s', $nextweek);
|
60 |
+
update_option('quads_show_vi_notice_later', $human_date);
|
61 |
+
update_option('quads_close_vi_notice', 'yes');
|
62 |
+
}
|
63 |
+
|
64 |
+
add_action('quads_show_vi_notice_later', 'quads_show_vi_notice_later');
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Save vi token
|
68 |
+
*/
|
69 |
+
function quads_save_vi_token() {
|
70 |
+
global $quads_options;
|
71 |
+
|
72 |
+
if (empty($_POST['token'])) {
|
73 |
+
echo json_encode(array("status" => "failed"));
|
74 |
+
wp_die();
|
75 |
+
}
|
76 |
+
|
77 |
+
// Save token before trying to create ads.txt
|
78 |
+
update_option('quads_vi_token', $_POST['token']);
|
79 |
+
|
80 |
+
if (!isset($quads_options['adsTxtEnabled'])) {
|
81 |
+
set_transient('quads_vi_ads_txt_disabled', true, 300);
|
82 |
+
delete_transient('quads_vi_ads_txt_error');
|
83 |
+
delete_transient('quads_vi_ads_txt_notice');
|
84 |
+
echo json_encode(array("status" => "success", "token" => $_POST['token'], "adsTxt" => 'disabled'));
|
85 |
+
wp_die();
|
86 |
+
}
|
87 |
+
|
88 |
+
$vi = new wpquads\vi();
|
89 |
+
|
90 |
+
if ($vi->createAdsTxt()) {
|
91 |
+
set_transient('quads_vi_ads_txt_notice', true, 300);
|
92 |
+
delete_transient('quads_vi_ads_txt_error');
|
93 |
+
} else {
|
94 |
+
set_transient('quads_vi_ads_txt_error', true, 300);
|
95 |
+
delete_transient('quads_vi_ads_txt_notice');
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
+
// Create AdSense ads.txt entries
|
100 |
+
$adsense = new \wpquads\adsense($quads_options);
|
101 |
+
$adsense->writeAdsTxt();
|
102 |
+
|
103 |
+
//sleep(5);
|
104 |
+
echo json_encode(array("status" => "success", "token" => $_POST['token']));
|
105 |
+
wp_die();
|
106 |
+
}
|
107 |
+
|
108 |
+
add_action('wp_ajax_quads_save_vi_token', 'quads_save_vi_token');
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Save vi ad settings and create ad code
|
112 |
+
*/
|
113 |
+
function quads_save_vi_ads() {
|
114 |
+
global $quads;
|
115 |
+
|
116 |
+
$return = $quads->vi->setAdCode();
|
117 |
+
|
118 |
+
if ($return) {
|
119 |
+
wp_die($return);
|
120 |
+
} else {
|
121 |
+
wp_die(array('status' => 'error', 'message' => 'Unknown API Error. Can not get vi ad code'));
|
122 |
+
}
|
123 |
+
}
|
124 |
+
add_action('wp_ajax_quads_save_vi_ads', 'quads_save_vi_ads');
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Logout of vi
|
128 |
+
*/
|
129 |
+
function quads_logout_vi() {
|
130 |
+
delete_option('quads_vi_token');
|
131 |
+
}
|
132 |
+
add_action('quads_logout_vi', 'quads_logout_vi');
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Hide ads txt information notice
|
136 |
+
*/
|
137 |
+
function quads_close_ads_txt_notice() {
|
138 |
+
delete_transient('quads_ads_txt_notice');
|
139 |
+
}
|
140 |
+
add_action('quads_close_ads_txt_notice', 'quads_close_ads_txt_notice');
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Hide ads txt error notice
|
144 |
+
*/
|
145 |
+
function quads_close_ads_txt_error() {
|
146 |
+
delete_transient('quads_ads_txt_error');
|
147 |
+
}
|
148 |
+
add_action('quads_close_ads_txt_error', 'quads_close_ads_txt_error');
|
149 |
+
|
150 |
+
|
includes/admin/admin-footer.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin Footer
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Footer
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 1.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly
|
13 |
-
if( !defined( 'ABSPATH' ) ) exit;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Add rating links to the admin dashboard
|
17 |
-
*
|
18 |
-
* @since 1.0.0
|
19 |
-
* @global string $typenow
|
20 |
-
* @param string $footer_text The existing footer text
|
21 |
-
* @return string
|
22 |
-
*/
|
23 |
-
function quads_admin_rate_us( $footer_text ) {
|
24 |
-
global $typenow;
|
25 |
-
|
26 |
-
if ( quads_is_admin_page() ) {
|
27 |
-
$rate_text = sprintf( __( '<strong>Please do us a BIG favor and give us a 5 star rating <a href="%1$s" target="_blank">here</a>. If you have issues, open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
|
28 |
-
'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/?filter=5#new-post',
|
29 |
-
'http://wpquads.com/support/'
|
30 |
-
);
|
31 |
-
} else {
|
32 |
-
return $footer_text;
|
33 |
-
}
|
34 |
-
}
|
35 |
add_filter( 'admin_footer_text', 'quads_admin_rate_us' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Footer
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Footer
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 1.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if( !defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Add rating links to the admin dashboard
|
17 |
+
*
|
18 |
+
* @since 1.0.0
|
19 |
+
* @global string $typenow
|
20 |
+
* @param string $footer_text The existing footer text
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
function quads_admin_rate_us( $footer_text ) {
|
24 |
+
global $typenow;
|
25 |
+
|
26 |
+
if ( quads_is_admin_page() ) {
|
27 |
+
$rate_text = sprintf( __( '<strong>Please do us a BIG favor and give us a 5 star rating <a href="%1$s" target="_blank">here</a>. If you have issues, open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
|
28 |
+
'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/?filter=5#new-post',
|
29 |
+
'http://wpquads.com/support/'
|
30 |
+
);
|
31 |
+
} else {
|
32 |
+
return $footer_text;
|
33 |
+
}
|
34 |
+
}
|
35 |
add_filter( 'admin_footer_text', 'quads_admin_rate_us' );
|
includes/admin/admin-notices.php
CHANGED
@@ -1,728 +1,728 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin Notices
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Notices
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 1.0.9
|
10 |
-
*/
|
11 |
-
// Exit if accessed directly
|
12 |
-
if( !defined( 'ABSPATH' ) )
|
13 |
-
exit;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Admin Messages
|
17 |
-
*
|
18 |
-
* @since 2.2.3
|
19 |
-
* @global $mashsb_options Array of all the WP QUADS Options
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
function quads_admin_messages() {
|
23 |
-
global $quads_options;
|
24 |
-
|
25 |
-
if( !current_user_can( 'update_plugins' ) || quads_is_addon_page() ) {
|
26 |
-
return;
|
27 |
-
}
|
28 |
-
|
29 |
-
$screen = get_current_screen();
|
30 |
-
if( $screen->parent_base == 'edit' ) {
|
31 |
-
return;
|
32 |
-
}
|
33 |
-
|
34 |
-
quads_show_update_auto_ads();
|
35 |
-
|
36 |
-
quads_theme_notice();
|
37 |
-
|
38 |
-
quads_update_notice();
|
39 |
-
|
40 |
-
quads_update_notice_v2();
|
41 |
-
|
42 |
-
quads_update_notice_1_5_3();
|
43 |
-
|
44 |
-
quads_show_vi_api_error();
|
45 |
-
|
46 |
-
|
47 |
-
echo quads_get_vi_notice();
|
48 |
-
|
49 |
-
echo quads_show_vi_notices();
|
50 |
-
|
51 |
-
quads_show_ads_txt_notice();
|
52 |
-
|
53 |
-
quads_show_license_expired();
|
54 |
-
|
55 |
-
|
56 |
-
if( quads_is_admin_page() ) {
|
57 |
-
echo '<div class="notice notice-error" style="background-color:#ffebeb;display:none;" id="wpquads-adblock-notice">' . sprintf( __( '<strong><p>Please disable your browser AdBlocker to resolve problems with WP QUADS ad setup</strong></p>', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
|
58 |
-
}
|
59 |
-
|
60 |
-
// if( !quads_is_any_ad_activated() && quads_is_admin_page() ) {
|
61 |
-
// echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads are activated!</strong> You need to assign at least 1 ad to an ad spot. Fix this in <a href="%s">General Settings</a>! Alternatively you need to use a shortcode in your posts or no ads are shown at all.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
|
62 |
-
// }
|
63 |
-
// if( quads_get_active_ads() === 0 && quads_is_admin_page() ) {
|
64 |
-
// echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads defined!</strong> You need to create at least one ad code. Fix this in <a href="%s">ADSENSE CODE</a>.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsadsense_header' ) . '</div>';
|
65 |
-
// }
|
66 |
-
|
67 |
-
if( !quads_is_post_type_activated() && quads_is_admin_page() ) {
|
68 |
-
echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads are shown - No post type chosen!</strong> You need to select at least 1 post type like <i>blog</i> or <i>page</i>. Fix this in <a href="%s">General Settings</a> or no ads are shown at all.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
|
69 |
-
}
|
70 |
-
|
71 |
-
if( isset( $_GET['quads-action'] ) && $_GET['quads-action'] === 'validate' && quads_is_admin_page() && quads_is_any_ad_activated() && quads_is_post_type_activated() && quads_get_active_ads() > 0 ) {
|
72 |
-
echo '<div class="notice notice-success">' . sprintf( __( '<strong>No errors detected in WP QUADS settings.</strong> If ads are still not shown read the <a href="%s" target="_blank">troubleshooting guide</a>' ), 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=toplink' ) . '</div>';
|
73 |
-
}
|
74 |
-
|
75 |
-
|
76 |
-
$install_date = get_option( 'quads_install_date' );
|
77 |
-
$display_date = date( 'Y-m-d h:i:s' );
|
78 |
-
$datetime1 = new DateTime( $install_date );
|
79 |
-
$datetime2 = new DateTime( $display_date );
|
80 |
-
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
|
81 |
-
|
82 |
-
$rate = get_option( 'quads_rating_div', false );
|
83 |
-
if( $diff_intrval >= 7 && ($rate === "no" || false === $rate || quads_rate_again() ) ) {
|
84 |
-
echo '<div class="quads_fivestar updated " style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);background-color:white;">
|
85 |
-
<p>Awesome, you\'ve been using <strong>WP QUADS</strong> for more than 1 week. <br> May i ask you to give it a <strong>5-star rating</strong> on Wordpress? </br>
|
86 |
-
This will help to spread its popularity and to make this plugin a better one.
|
87 |
-
<br><br>Your help is much appreciated. Thank you very much,<br> ~René Hermenau
|
88 |
-
<ul>
|
89 |
-
<li><a href="https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/?filter=5#new-post" class="thankyou" target="_new" title="Ok, you deserved it" style="font-weight:bold;">Ok, you deserved it</a></li>
|
90 |
-
<li><a href="javascript:void(0);" class="quadsHideRating" title="I already did" style="font-weight:bold;">I already did</a></li>
|
91 |
-
<li><a href="javascript:void(0);" class="quadsHideRating" title="No, not good enough" style="font-weight:bold;">No, not good enough</a></li>
|
92 |
-
<br>
|
93 |
-
<li><a href="javascript:void(0);" class="quadsHideRatingWeek" title="No, not good enough" style="font-weight:bold;">I want to rate it later. Ask me again in a week!</a></li>
|
94 |
-
<li class="spinner" style="float:none;display:list-item;margin:0px;"></li>
|
95 |
-
</ul>
|
96 |
-
|
97 |
-
</div>
|
98 |
-
<script>
|
99 |
-
jQuery( document ).ready(function( $ ) {
|
100 |
-
|
101 |
-
jQuery(\'.quadsHideRating\').click(function(){
|
102 |
-
jQuery(".spinner").addClass("is-active");
|
103 |
-
var data={\'action\':\'quads_hide_rating\'}
|
104 |
-
jQuery.ajax({
|
105 |
-
|
106 |
-
url: "' . admin_url( 'admin-ajax.php' ) . '",
|
107 |
-
type: "post",
|
108 |
-
data: data,
|
109 |
-
dataType: "json",
|
110 |
-
async: !0,
|
111 |
-
success: function(e) {
|
112 |
-
if (e=="success") {
|
113 |
-
jQuery(".spinner").removeClass("is-active");
|
114 |
-
jQuery(\'.quads_fivestar\').slideUp(\'fast\');
|
115 |
-
|
116 |
-
}
|
117 |
-
}
|
118 |
-
});
|
119 |
-
})
|
120 |
-
|
121 |
-
jQuery(\'.quadsHideRatingWeek\').click(function(){
|
122 |
-
jQuery(".spinner").addClass("is-active");
|
123 |
-
var data={\'action\':\'quads_hide_rating_week\'}
|
124 |
-
jQuery.ajax({
|
125 |
-
|
126 |
-
url: "' . admin_url( 'admin-ajax.php' ) . '",
|
127 |
-
type: "post",
|
128 |
-
data: data,
|
129 |
-
dataType: "json",
|
130 |
-
async: !0,
|
131 |
-
success: function(e) {
|
132 |
-
if (e=="success") {
|
133 |
-
jQuery(".spinner").removeClass("is-active");
|
134 |
-
jQuery(\'.quads_fivestar\').slideUp(\'fast\');
|
135 |
-
|
136 |
-
}
|
137 |
-
}
|
138 |
-
});
|
139 |
-
})
|
140 |
-
|
141 |
-
});
|
142 |
-
</script>
|
143 |
-
';
|
144 |
-
}
|
145 |
-
}
|
146 |
-
|
147 |
-
add_action( 'admin_notices', 'quads_admin_messages' );
|
148 |
-
|
149 |
-
|
150 |
-
/* Hide the rating div
|
151 |
-
*
|
152 |
-
* @subpackage Admin/Notices
|
153 |
-
* @copyright Copyright (c) 2016, René Hermenau
|
154 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
155 |
-
* @since 1.0.9
|
156 |
-
*
|
157 |
-
* @return json string
|
158 |
-
*
|
159 |
-
*/
|
160 |
-
|
161 |
-
function quads_hide_rating_div() {
|
162 |
-
update_option( 'quads_rating_div', 'yes' );
|
163 |
-
delete_option( 'quads_date_next_notice' );
|
164 |
-
echo json_encode( array("success") );
|
165 |
-
exit;
|
166 |
-
}
|
167 |
-
|
168 |
-
add_action( 'wp_ajax_quads_hide_rating', 'quads_hide_rating_div' );
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Write the timestamp when rating notice will be opened again
|
172 |
-
*/
|
173 |
-
function quads_hide_rating_notice_week() {
|
174 |
-
$nextweek = time() + (7 * 24 * 60 * 60);
|
175 |
-
$human_date = date( 'Y-m-d h:i:s', $nextweek );
|
176 |
-
update_option( 'quads_date_next_notice', $human_date );
|
177 |
-
update_option( 'quads_rating_div', 'yes' );
|
178 |
-
echo json_encode( array("success") );
|
179 |
-
exit;
|
180 |
-
}
|
181 |
-
|
182 |
-
add_action( 'wp_ajax_quads_hide_rating_week', 'quads_hide_rating_notice_week' );
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Check if admin notice will open again after one week of closing
|
186 |
-
* @return boolean
|
187 |
-
*/
|
188 |
-
function quads_rate_again() {
|
189 |
-
|
190 |
-
$rate_again_date = get_option( 'quads_date_next_notice' );
|
191 |
-
|
192 |
-
if( false === $rate_again_date ) {
|
193 |
-
return false;
|
194 |
-
}
|
195 |
-
|
196 |
-
$current_date = date( 'Y-m-d h:i:s' );
|
197 |
-
$datetime1 = new DateTime( $rate_again_date );
|
198 |
-
$datetime2 = new DateTime( $current_date );
|
199 |
-
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
|
200 |
-
|
201 |
-
if( $diff_intrval >= 0 ) {
|
202 |
-
return true;
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Show a message when pro or free plugin gets disabled
|
208 |
-
*
|
209 |
-
* @return void
|
210 |
-
* @not used
|
211 |
-
*/
|
212 |
-
function quads_plugin_deactivated_notice() {
|
213 |
-
if( false !== ( $deactivated_notice_id = get_transient( 'quads_deactivated_notice_id' ) ) ) {
|
214 |
-
if( '1' === $deactivated_notice_id ) {
|
215 |
-
$message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS.", 'wpstg' );
|
216 |
-
} else {
|
217 |
-
$message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS Pro.", 'wpstg' );
|
218 |
-
}
|
219 |
-
?>
|
220 |
-
<div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
|
221 |
-
<p><?php echo esc_html( $message ); ?></p>
|
222 |
-
</div> <?php
|
223 |
-
delete_transient( 'quads_deactivated_notice_id' );
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
/**
|
228 |
-
* This notice is shown for user of the bimber and bunchy theme
|
229 |
-
*
|
230 |
-
* Not used at the moment
|
231 |
-
*/
|
232 |
-
function quads_theme_notice() {
|
233 |
-
|
234 |
-
$show_notice = get_option( 'quads_show_theme_notice' );
|
235 |
-
|
236 |
-
if( false !== $show_notice && 'no' !== $show_notice && quads_is_commercial_theme() ) {
|
237 |
-
$message = __( '<strong>Extend the' . quads_is_commercial_theme() . '</strong> theme with <strong>WP QUADS PRO!</strong><br>Save time and earn more - Bring your AdSense earnings to next level. <a href="http://wpquads.com?utm_campaign=adminnotice&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank"> Purchase Now</a> or <a href="http://wpquads.com?utm_campaign=free_plugin&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank">Get Details</a> <p> <a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_upgrade_notice" class="button">Close Notice</a>', 'quick-adsense-reloaded' );
|
238 |
-
?>
|
239 |
-
<div class="updated notice" style="border-left: 4px solid #ffba00;">
|
240 |
-
<p><?php echo $message; ?></p>
|
241 |
-
</div> <?php
|
242 |
-
//update_option ('quads_show_theme_notice', 'no');
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* This notice is shown after updating to 1.3.9
|
248 |
-
*
|
249 |
-
*/
|
250 |
-
function quads_update_notice() {
|
251 |
-
|
252 |
-
$show_notice = get_option( 'quads_show_update_notice' );
|
253 |
-
|
254 |
-
// do not do anything
|
255 |
-
if( false !== $show_notice ) {
|
256 |
-
return false;
|
257 |
-
}
|
258 |
-
|
259 |
-
if( (version_compare( QUADS_VERSION, '1.3.9', '>=' ) ) && quads_is_pro_active() && (version_compare( QUADS_PRO_VERSION, '1.3.0', '<' ) ) ) {
|
260 |
-
$message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Update WP QUADS PRO to get custom post type support from <a href="%s">General Settings</a>.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings' );
|
261 |
-
$message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
|
262 |
-
?>
|
263 |
-
<div class="updated notice" style="border-left: 4px solid #ffba00;">
|
264 |
-
<p><?php echo $message; ?></p>
|
265 |
-
</div> <?php
|
266 |
-
//update_option ('quads_show_update_notice', 'no');
|
267 |
-
} else
|
268 |
-
if( !quads_is_extra() ) {
|
269 |
-
$message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Install <a href="%1s" target="_blank">WP QUADS PRO</a> to get custom post type support in <a href="%2s">General Settings</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com?utm_campaign=admin_notice&utm_source=admin_notice&utm_medium=admin&utm_content=custom_post_type', admin_url() . 'admin.php?page=quads-settings' );
|
270 |
-
$message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
|
271 |
-
?>
|
272 |
-
<div class="updated notice" style="border-left: 4px solid #ffba00;">
|
273 |
-
<p><?php echo $message; ?></p>
|
274 |
-
</div>
|
275 |
-
<?php
|
276 |
-
}
|
277 |
-
}
|
278 |
-
|
279 |
-
/**
|
280 |
-
* Show upgrade notice if wp quads pro is lower than 1.3.6
|
281 |
-
* @return boolean
|
282 |
-
*/
|
283 |
-
function quads_update_notice_v2() {
|
284 |
-
|
285 |
-
if( quads_is_pro_active() && (version_compare( QUADS_PRO_VERSION, '1.3.6', '<' ) ) && quads_is_admin_page() ) {
|
286 |
-
$message = sprintf( __( 'You need to update <strong>WP QUADS PRO to version 1.3.6</strong> or higher. Your version of <strong>WP QUADS Pro</strong> is ' . QUADS_PRO_VERSION . '.<br>WP QUADS Pro ' . QUADS_PRO_VERSION . ' supports unlimited amount of ads. <br>Updating requires a valid <a href="%s" target="_new">license key</a>.', 'quick-adsense-reloaded' ), 'https://wpquads.com/#buy-wpquads?utm_source=plugin_notice&utm_medium=admin&utm_campaign=activate_license' );
|
287 |
-
?>
|
288 |
-
<div class="notice notice-error">
|
289 |
-
<p><?php echo $message; ?></p>
|
290 |
-
</div> <?php
|
291 |
-
}
|
292 |
-
}
|
293 |
-
|
294 |
-
/**
|
295 |
-
* Show upgrade notice after updating from 1.5.2 to 1.5.3 and higher
|
296 |
-
* @return boolean
|
297 |
-
*/
|
298 |
-
function quads_update_notice_1_5_3() {
|
299 |
-
|
300 |
-
// do not show anything
|
301 |
-
if( false !== get_option( 'quads_hide_update_notice_1_5_3' ) ) {
|
302 |
-
return false;
|
303 |
-
}
|
304 |
-
|
305 |
-
$previous_version = get_option( 'quads_version_upgraded_from' );
|
306 |
-
|
307 |
-
//wp_die(QUADS_VERSION);
|
308 |
-
// Show update message if previous version was lower than 1.7 - This makes sure that the message is shown for future updates without complicated version number conditions
|
309 |
-
if( !empty( $previous_version ) && version_compare( QUADS_VERSION, '1.7.0', '<=' ) ) {
|
310 |
-
|
311 |
-
$message = sprintf( __( 'This is a huge update! The data structure of WP QUADS has been modified and improved for better performance and great new features. <br> For the case you\'d experience issues, we made a <a href="%1s" target="_self">backup of previous WP QUADS data</a>. So you can <a href="%2s" target="_new">switch back to the previous version</a> anytime. <br><br>Please <a href="%3s" target="_new">open first a support ticket</a> if you experience any issue.', 'quick-adsense-reloaded' ), admin_url() . '?page=quads-settings&tab=help', 'https://wpquads.com/docs/install-older-plugin-version/?utm_source=plugin_notice&utm_medium=admin&utm_campaign=install_older_version', 'https://wordpress.org/support/plugin/quick-adsense-reloaded' );
|
312 |
-
?>
|
313 |
-
<div class="notice notice-error">
|
314 |
-
<p><?php echo $message; ?></p>
|
315 |
-
<?php
|
316 |
-
echo '<p><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice_1_5_3" class="button-primary" target="_self" title="Close Notice" style="font-weight:bold;">' . __( 'Close Notice', 'quick-adsense-reloaded' ) . '</a>';
|
317 |
-
?>
|
318 |
-
</div> <?php
|
319 |
-
}
|
320 |
-
}
|
321 |
-
|
322 |
-
/**
|
323 |
-
* Hide Notice and update db option quads_hide_notice
|
324 |
-
*/
|
325 |
-
function quads_hide_notice() {
|
326 |
-
update_option( 'quads_show_update_notice', 'no' );
|
327 |
-
}
|
328 |
-
|
329 |
-
add_action( 'quads_hide_update_notice', 'quads_hide_notice', 10 );
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Set option to hide admin notice 1.5.3
|
333 |
-
* @return boolean
|
334 |
-
*/
|
335 |
-
function quads_hide_notice_1_5_3() {
|
336 |
-
update_option( 'quads_hide_update_notice_1_5_3', '1' );
|
337 |
-
}
|
338 |
-
|
339 |
-
add_action( 'quads_hide_update_notice_1_5_3', 'quads_hide_notice_1_5_3' );
|
340 |
-
|
341 |
-
/**
|
342 |
-
* Check if any ad is activated and assigned in general settings
|
343 |
-
*
|
344 |
-
* @global array $quads_options
|
345 |
-
* @return boolean
|
346 |
-
*/
|
347 |
-
function quads_is_any_ad_activated() {
|
348 |
-
global $quads_options;
|
349 |
-
|
350 |
-
// Check if custom positions location_settings is empty or does not exists
|
351 |
-
$check = array();
|
352 |
-
if( isset( $quads_options['location_settings'] ) ) {
|
353 |
-
foreach ( $quads_options['location_settings'] as $location_array ) {
|
354 |
-
if( isset( $location_array['status'] ) ) {
|
355 |
-
$check[] = $location_array['status'];
|
356 |
-
}
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
// ad activated with api (custom position)
|
361 |
-
if( count( $check ) > 0 ) {
|
362 |
-
return true;
|
363 |
-
}
|
364 |
-
// check if any other ad is assigned and activated
|
365 |
-
if( isset( $quads_options['pos1']['BegnAds'] ) ||
|
366 |
-
isset( $quads_options['pos2']['MiddAds'] ) ||
|
367 |
-
isset( $quads_options['pos3']['EndiAds'] ) ||
|
368 |
-
isset( $quads_options['pos4']['MoreAds'] ) ||
|
369 |
-
isset( $quads_options['pos5']['LapaAds'] ) ||
|
370 |
-
isset( $quads_options['pos6']['Par1Ads'] ) ||
|
371 |
-
isset( $quads_options['pos7']['Par2Ads'] ) ||
|
372 |
-
isset( $quads_options['pos8']['Par3Ads'] ) ||
|
373 |
-
isset( $quads_options['pos9']['Img1Ads'] )
|
374 |
-
) {
|
375 |
-
return true;
|
376 |
-
}
|
377 |
-
// no ad is activated
|
378 |
-
return false;
|
379 |
-
}
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Check if any post type is enabled
|
383 |
-
*
|
384 |
-
* @global array $quads_options
|
385 |
-
* @return boolean
|
386 |
-
*/
|
387 |
-
function quads_is_post_type_activated() {
|
388 |
-
global $quads_options;
|
389 |
-
|
390 |
-
if( empty( $quads_options['post_types'] ) ) {
|
391 |
-
return false;
|
392 |
-
}
|
393 |
-
return true;
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Check if ad codes are populated
|
398 |
-
*
|
399 |
-
* @global array $quads_options
|
400 |
-
* @return booleantrue if ads are empty
|
401 |
-
*/
|
402 |
-
function quads_ads_empty() {
|
403 |
-
global $quads_options;
|
404 |
-
|
405 |
-
$check = array();
|
406 |
-
|
407 |
-
for ( $i = 1; $i <= 10; $i++ ) {
|
408 |
-
if( !empty( $quads_options['ads']['ad' . $i]['code'] ) ) {
|
409 |
-
$check[] = 'true';
|
410 |
-
}
|
411 |
-
}
|
412 |
-
if( count( $check ) === 0 ) {
|
413 |
-
return true;
|
414 |
-
}
|
415 |
-
return false;
|
416 |
-
}
|
417 |
-
|
418 |
-
/**
|
419 |
-
* Return VI admin notice
|
420 |
-
* @return string
|
421 |
-
*/
|
422 |
-
function quads_get_vi_notice() {
|
423 |
-
global $quads;
|
424 |
-
|
425 |
-
if( false !== get_option( 'quads_close_vi_welcome_notice' ) || !quads_is_admin_page() ) {
|
426 |
-
return false;
|
427 |
-
}
|
428 |
-
|
429 |
-
$mail = get_option( 'admin_email' );
|
430 |
-
$domain = $quads->vi->getDomain();
|
431 |
-
|
432 |
-
|
433 |
-
$white = '<div class="quads-banner-wrapper">
|
434 |
-
<section class="quads-banner-content">
|
435 |
-
<div class="quads-banner-columns">
|
436 |
-
<main class="quads-banner-main"><p>' .
|
437 |
-
sprintf(
|
438 |
-
__( 'This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
|
439 |
-
content and video advertising.<br>
|
440 |
-
To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
|
441 |
-
<p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaed' ), 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white', admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white'
|
442 |
-
)
|
443 |
-
. '</p></main>
|
444 |
-
<!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
|
445 |
-
<aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-white.png" width="168" height="72"></a></p></aside>
|
446 |
-
</div>
|
447 |
-
<aside class="quads-banner-close"><div style="margin-top:5px;"><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
|
448 |
-
</section>
|
449 |
-
</div>';
|
450 |
-
|
451 |
-
|
452 |
-
$black = '<div class="quads-banner-wrapper" style="background-color:black;">
|
453 |
-
<section class="quads-banner-content">
|
454 |
-
<div class="quads-banner-columns">
|
455 |
-
<main class="quads-banner-main" style="color:white;"><p>' .
|
456 |
-
sprintf(
|
457 |
-
__( 'This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
|
458 |
-
content and video advertising.<br>
|
459 |
-
To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
|
460 |
-
<p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaded' ), 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black', admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black'
|
461 |
-
)
|
462 |
-
. '</p></main>
|
463 |
-
<!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
|
464 |
-
<aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-black.png" width="168" height="72"></a></p></aside>
|
465 |
-
</div>
|
466 |
-
<aside class="quads-banner-close"><div style="margin-top:5px;"><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
|
467 |
-
</section>
|
468 |
-
</div>';
|
469 |
-
|
470 |
-
$variant = get_option( 'quads_vi_variant' );
|
471 |
-
|
472 |
-
switch ( $variant ) {
|
473 |
-
case 'a':
|
474 |
-
return $white;
|
475 |
-
break;
|
476 |
-
case 'b':
|
477 |
-
return $black;
|
478 |
-
break;
|
479 |
-
default:
|
480 |
-
return $white;
|
481 |
-
break;
|
482 |
-
}
|
483 |
-
}
|
484 |
-
|
485 |
-
/**
|
486 |
-
* Check if vi admin notice should be opened again again one week after closing
|
487 |
-
* @return boolean
|
488 |
-
*/
|
489 |
-
function quads_show_vi_notice_again() {
|
490 |
-
|
491 |
-
$show_again_date = get_option( 'quads_show_vi_notice_later' );
|
492 |
-
|
493 |
-
if( false === $show_again_date ) {
|
494 |
-
return false;
|
495 |
-
}
|
496 |
-
|
497 |
-
$current_date = date( 'Y-m-d h:i:s' );
|
498 |
-
$datetime1 = new DateTime( $show_again_date );
|
499 |
-
$datetime2 = new DateTime( $current_date );
|
500 |
-
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
|
501 |
-
|
502 |
-
if( $diff_intrval >= 0 ) {
|
503 |
-
return true;
|
504 |
-
}
|
505 |
-
}
|
506 |
-
|
507 |
-
/**
|
508 |
-
* Show all vi notices
|
509 |
-
*/
|
510 |
-
function quads_show_vi_notices() {
|
511 |
-
global $quads, $quads_options;
|
512 |
-
|
513 |
-
if( !quads_is_admin_page() ) {
|
514 |
-
return false;
|
515 |
-
}
|
516 |
-
|
517 |
-
|
518 |
-
// adsense ads.txt content
|
519 |
-
$adsense = new wpquads\adsense( $quads_options );
|
520 |
-
$adsensePublisherIds = $adsense->getPublisherIds();
|
521 |
-
|
522 |
-
$adsenseAdsTxtText = '';
|
523 |
-
if( !empty( $adsensePublisherIds ) ) {
|
524 |
-
foreach ( $adsensePublisherIds as $adsensePublisherId ) {
|
525 |
-
$adsenseAdsTxtText .= "google.com, " . str_replace( 'ca-', '', $adsensePublisherId ) . ", DIRECT, f08c47fec0942fa0\r\n";
|
526 |
-
}
|
527 |
-
}
|
528 |
-
|
529 |
-
// vi ads.txt content
|
530 |
-
$viAdsTxtText = '';
|
531 |
-
if( $quads->vi->getPublisherId() ) {
|
532 |
-
$viAdsTxtText = $quads->vi->getAdsTxtContent();
|
533 |
-
}
|
534 |
-
|
535 |
-
// Show ads.txt warning if logged into vi and ads.txt option is disabled
|
536 |
-
if( get_transient( 'quads_vi_ads_txt_disabled' ) && get_option( 'quads_vi_token' ) ) {
|
537 |
-
// ads.txt content
|
538 |
-
$notice['message'] = sprintf( '<p><strong>ADS.TXT couldn\'t be updated automatically.</strong><br><br>You need the ads.txt to display vi video ads. <br>If you want WP QUADS to create an ads.txt automatically you can enable the ads.txt option at <a href="%1$s">General & Position</a>. Alternatively you can also enter the following line manually into <strong>' . get_site_url() . '/ads.txt</strong>:'
|
539 |
-
. "<p>"
|
540 |
-
. "<pre>" . $viAdsTxtText . "<br>"
|
541 |
-
. $adsenseAdsTxtText
|
542 |
-
. "</pre></p>"
|
543 |
-
. 'If the file does not exist you need to create it first. <a href="%2$s" target="_blank">Learn More</a></p>'
|
544 |
-
, admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header'
|
545 |
-
, 'https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
|
546 |
-
);
|
547 |
-
$notice['type'] = 'update-nag';
|
548 |
-
$adsTxtDisabled = new wpquads\template( '/includes/vendor/vi/views/notices', $notice );
|
549 |
-
echo $adsTxtDisabled->render();
|
550 |
-
return false;
|
551 |
-
}
|
552 |
-
|
553 |
-
// show ad.txt update notice
|
554 |
-
if( get_transient( 'quads_vi_ads_txt_notice' ) ) {
|
555 |
-
$notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated your ads.txt '
|
556 |
-
. 'file with lines that declare video inteligence as a legitmate seller of your inventory and enables you to make more money through video inteligence. <a href="https://www.vi.ai/publisher-video-monetization/?utm_source=WordPress&utm_medium=Plugin%20blurb&utm_campaign=wpquads" target="blank" rel="external nofollow">FAQ</a>';
|
557 |
-
$notice['type'] = 'update-nag';
|
558 |
-
$adsUpdated = new wpquads\template( '/includes/vendor/vi/views/notices', $notice );
|
559 |
-
echo $adsUpdated->render();
|
560 |
-
}
|
561 |
-
|
562 |
-
// show ad.txt update notice
|
563 |
-
if( get_transient( 'quads_vi_ads_txt_error' ) ) {
|
564 |
-
|
565 |
-
|
566 |
-
// ads.txt content
|
567 |
-
$notice['message'] = "<p><strong>ADS.TXT couldn't be added</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <br><strong>" . get_home_path() . "ads.txt</strong>:"
|
568 |
-
. "<p>"
|
569 |
-
. "<pre>vi.ai " . $quads->vi->getPublisherId() . " DIRECT # 41b5eef6<br>"
|
570 |
-
. $adsenseAdsTxtText
|
571 |
-
. "</pre></p>"
|
572 |
-
. "Only by doing so you are able to make more money through video inteligence.</p>";
|
573 |
-
$notice['type'] = 'error';
|
574 |
-
|
575 |
-
// render blurb
|
576 |
-
$adsTxtError = new wpquads\template( '/includes/vendor/vi/views/notices', $notice );
|
577 |
-
echo $adsTxtError->render();
|
578 |
-
}
|
579 |
-
}
|
580 |
-
|
581 |
-
/**
|
582 |
-
* Show a ads.txt notices if WP QUADS has permission to update or create an ads.txt
|
583 |
-
*/
|
584 |
-
function quads_show_ads_txt_notice() {
|
585 |
-
global $quads, $quads_options;
|
586 |
-
|
587 |
-
if( !quads_is_admin_page() )
|
588 |
-
return false;
|
589 |
-
|
590 |
-
|
591 |
-
// show ad.txt update notice
|
592 |
-
if( get_transient( 'quads_ads_txt_notice' ) && isset( $quads_options['adsTxtEnabled'] ) ) {
|
593 |
-
$notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated the file ' . ABSPATH . 'ads.txt '
|
594 |
-
. 'file with lines that declare Google.com as a legitmate seller of your inventory and is recommended setting by AdSense.<br><a href="https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/" target="blank" rel="external nofollow">What is ads.txt?</a>';
|
595 |
-
$notice['type'] = 'update-nag';
|
596 |
-
$notice['action'] = 'close_ads_txt_notice';
|
597 |
-
$adsUpdated = new wpquads\template( '/includes/admin/views/notices', $notice );
|
598 |
-
echo $adsUpdated->render();
|
599 |
-
}
|
600 |
-
|
601 |
-
// show ads.txt error notice
|
602 |
-
if( get_transient( 'close_ads_txt_error' ) && isset( $quads_options['adsTxtEnabled'] ) ) {
|
603 |
-
|
604 |
-
// Check if adsense is used and add the adsense publisherId to ads.txt blurb as well
|
605 |
-
$adsense = new wpquads\adsense( $quads_options );
|
606 |
-
$adsensePublisherIds = $adsense->getPublisherIds();
|
607 |
-
|
608 |
-
|
609 |
-
$adsenseAdsTxtText = '';
|
610 |
-
if( !empty( $adsensePublisherIds ) ) {
|
611 |
-
foreach ( $adsensePublisherIds as $adsensePublisherId ) {
|
612 |
-
$adsenseAdsTxtText .= "google.com, " . str_replace( 'ca-', '', $adsensePublisherId ) . ", DIRECT, f08c47fec0942fa0\n\r";
|
613 |
-
}
|
614 |
-
}
|
615 |
-
|
616 |
-
$viAdsTxtText = '';
|
617 |
-
if( $quads->vi->getPublisherId() ) {
|
618 |
-
$viAdsTxtText = $quads->vi->getAdsTxtContent();
|
619 |
-
}
|
620 |
-
|
621 |
-
// ads.txt content
|
622 |
-
$notice['message'] = "<p><strong>ADS.TXT couldn't be updated automatically</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <strong>" . get_home_path() . "ads.txt</strong>:"
|
623 |
-
. "<p>"
|
624 |
-
. "<pre>" . $viAdsTxtText . "<br>"
|
625 |
-
. $adsenseAdsTxtText
|
626 |
-
. "</pre></p>"
|
627 |
-
. "Only by doing so AdSense ads are shown on your site.</p>";
|
628 |
-
$notice['type'] = 'error';
|
629 |
-
$notice['action'] = 'quads_ads_txt_error';
|
630 |
-
|
631 |
-
// render blurb
|
632 |
-
$adsTxtError = new wpquads\template( '/includes/admin/views/notices', $notice );
|
633 |
-
echo $adsTxtError->render();
|
634 |
-
}
|
635 |
-
}
|
636 |
-
|
637 |
-
/**
|
638 |
-
* Show api errors
|
639 |
-
*/
|
640 |
-
function quads_show_vi_api_error() {
|
641 |
-
if( !quads_is_admin_page() ) {
|
642 |
-
return false;
|
643 |
-
}
|
644 |
-
|
645 |
-
if( false !== get_option( 'quads_vi_api_error' ) ) {
|
646 |
-
$notice['message'] = 'WP QUADS - Can not retrive ad settings from vi API. Error: ' . get_option( 'quads_vi_api_error' );
|
647 |
-
$notice['type'] = 'error';
|
648 |
-
$notice['action'] = '';
|
649 |
-
// render blurb
|
650 |
-
$blurb = new wpquads\template( '/includes/admin/views/notices', $notice );
|
651 |
-
echo $blurb->render();
|
652 |
-
}
|
653 |
-
}
|
654 |
-
|
655 |
-
/**
|
656 |
-
* Show global notice WP QUADS Pro license expired
|
657 |
-
* @return mixed boolean | string
|
658 |
-
*/
|
659 |
-
function quads_show_license_expired() {
|
660 |
-
global $quads_options, $wp_version;
|
661 |
-
|
662 |
-
$licKey = isset( $quads_options['quads_wp_quads_pro_license_key'] ) ? $quads_options['quads_wp_quads_pro_license_key'] : '';
|
663 |
-
|
664 |
-
$lic = get_option( 'quads_wp_quads_pro_license_active' );
|
665 |
-
|
666 |
-
// Do not show if no license at all or if there is a valid license key
|
667 |
-
if( !$lic || (isset( $lic->license ) && $lic->license !== 'invalid') ) {
|
668 |
-
return false;
|
669 |
-
}
|
670 |
-
|
671 |
-
// Do not show notice for another 30 days
|
672 |
-
if( get_transient( 'quads_notice_lic_expired' ) ) {
|
673 |
-
return false;
|
674 |
-
}
|
675 |
-
|
676 |
-
|
677 |
-
echo '<div class="notice notice-error">';
|
678 |
-
echo sprintf(
|
679 |
-
__( '<p>Oh No! <strong>WP Quads Pro</strong> license key is not activated or has been expired. It expires on %s. Renew or activate your license key to make sure that your (AdSense) ads are shown properly with your WordPress, version ' . $wp_version . '<br>'
|
680 |
-
. '<a href="%s" target="_blank" title="Renew your license key" class="button"><strong>Renew Your License Key Now</strong></a> | <a href="%s" title="Renew your license key">I am aware of possible issues and want to hide this reminder</a>'
|
681 |
-
, 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $lic->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $licKey . '&utm_campaign=adminnotic123e&utm_source=adminnotice123&utm_medium=admin&utm_content=license-expired', admin_url() . 'admin.php?page=quads-settings&tab=licenses&quads-action=hide_license_expired_notice'
|
682 |
-
);
|
683 |
-
echo '</p></div>';
|
684 |
-
}
|
685 |
-
|
686 |
-
/**
|
687 |
-
* Store the transient for 30 days
|
688 |
-
*/
|
689 |
-
function quads_hide_license_expired_notice() {
|
690 |
-
set_transient( 'quads_notice_lic_expired', 'hide', 60 * 60 * 24 * 30 );
|
691 |
-
}
|
692 |
-
|
693 |
-
add_action( 'quads_hide_license_expired_notice', 'quads_hide_license_expired_notice' );
|
694 |
-
|
695 |
-
/**
|
696 |
-
* Return update notice for Google Auto Ads
|
697 |
-
* @since 3.5.3.0
|
698 |
-
*/
|
699 |
-
function quads_show_update_auto_ads() {
|
700 |
-
|
701 |
-
|
702 |
-
$message = sprintf( __( '<h2 style="color:white;">WP QUADS & Google Auto Ads</h2>'
|
703 |
-
. 'WP QUADS Pro adds support for Google Auto Ads<br><br> Get the Pro plugin from <a href="https://wpquads.com/?utm_source=wp-admin&utm_medium=autoads-notice&utm_campaign=autoads-notice" target="_blank" style="color:#87c131;font-weight:500;">wpquads.com</a>'
|
704 |
-
, 'mashsb' ), admin_url() . 'admin.php?page=quads-settings'
|
705 |
-
);
|
706 |
-
|
707 |
-
if( get_option( 'quads_show_notice_auto_ads' ) === 'no' ) {
|
708 |
-
return false;
|
709 |
-
}
|
710 |
-
|
711 |
-
// admin notice after updating wp quads
|
712 |
-
echo '<div class="quads-notice-gdpr update-nag" style="background-color: black;color: #87c131;padding: 20px;margin-top: 20px;border: 3px solid #87c131;display:block;">' . $message .
|
713 |
-
'<p><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_auto_ads_notice" class="quads_hide_gdpr" title="I got it" style="text-decoration:none;color:white;">- I Understand! Do Not Show This Hint Again -</a></a>' .
|
714 |
-
'</div>';
|
715 |
-
}
|
716 |
-
|
717 |
-
/**
|
718 |
-
* Hide GDPR notice
|
719 |
-
*
|
720 |
-
* @global array $mashsb_options
|
721 |
-
*/
|
722 |
-
function mashsb_hide_auto_ads_notice() {
|
723 |
-
global $quads_options;
|
724 |
-
// Get all settings
|
725 |
-
update_option( 'quads_show_notice_auto_ads', 'no' );
|
726 |
-
}
|
727 |
-
|
728 |
-
add_action( 'quads_hide_auto_ads_notice', 'mashsb_hide_auto_ads_notice' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Notices
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Notices
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 1.0.9
|
10 |
+
*/
|
11 |
+
// Exit if accessed directly
|
12 |
+
if( !defined( 'ABSPATH' ) )
|
13 |
+
exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Admin Messages
|
17 |
+
*
|
18 |
+
* @since 2.2.3
|
19 |
+
* @global $mashsb_options Array of all the WP QUADS Options
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
function quads_admin_messages() {
|
23 |
+
global $quads_options;
|
24 |
+
|
25 |
+
if( !current_user_can( 'update_plugins' ) || quads_is_addon_page() ) {
|
26 |
+
return;
|
27 |
+
}
|
28 |
+
|
29 |
+
$screen = get_current_screen();
|
30 |
+
if( $screen->parent_base == 'edit' ) {
|
31 |
+
return;
|
32 |
+
}
|
33 |
+
|
34 |
+
quads_show_update_auto_ads();
|
35 |
+
|
36 |
+
quads_theme_notice();
|
37 |
+
|
38 |
+
quads_update_notice();
|
39 |
+
|
40 |
+
quads_update_notice_v2();
|
41 |
+
|
42 |
+
quads_update_notice_1_5_3();
|
43 |
+
|
44 |
+
quads_show_vi_api_error();
|
45 |
+
|
46 |
+
|
47 |
+
echo quads_get_vi_notice();
|
48 |
+
|
49 |
+
echo quads_show_vi_notices();
|
50 |
+
|
51 |
+
quads_show_ads_txt_notice();
|
52 |
+
|
53 |
+
quads_show_license_expired();
|
54 |
+
|
55 |
+
|
56 |
+
if( quads_is_admin_page() ) {
|
57 |
+
echo '<div class="notice notice-error" style="background-color:#ffebeb;display:none;" id="wpquads-adblock-notice">' . sprintf( __( '<strong><p>Please disable your browser AdBlocker to resolve problems with WP QUADS ad setup</strong></p>', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
|
58 |
+
}
|
59 |
+
|
60 |
+
// if( !quads_is_any_ad_activated() && quads_is_admin_page() ) {
|
61 |
+
// echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads are activated!</strong> You need to assign at least 1 ad to an ad spot. Fix this in <a href="%s">General Settings</a>! Alternatively you need to use a shortcode in your posts or no ads are shown at all.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
|
62 |
+
// }
|
63 |
+
// if( quads_get_active_ads() === 0 && quads_is_admin_page() ) {
|
64 |
+
// echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads defined!</strong> You need to create at least one ad code. Fix this in <a href="%s">ADSENSE CODE</a>.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsadsense_header' ) . '</div>';
|
65 |
+
// }
|
66 |
+
|
67 |
+
if( !quads_is_post_type_activated() && quads_is_admin_page() ) {
|
68 |
+
echo '<div class="notice notice-warning">' . sprintf( __( '<strong>No ads are shown - No post type chosen!</strong> You need to select at least 1 post type like <i>blog</i> or <i>page</i>. Fix this in <a href="%s">General Settings</a> or no ads are shown at all.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header' ) . '</div>';
|
69 |
+
}
|
70 |
+
|
71 |
+
if( isset( $_GET['quads-action'] ) && $_GET['quads-action'] === 'validate' && quads_is_admin_page() && quads_is_any_ad_activated() && quads_is_post_type_activated() && quads_get_active_ads() > 0 ) {
|
72 |
+
echo '<div class="notice notice-success">' . sprintf( __( '<strong>No errors detected in WP QUADS settings.</strong> If ads are still not shown read the <a href="%s" target="_blank">troubleshooting guide</a>' ), 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=toplink' ) . '</div>';
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
$install_date = get_option( 'quads_install_date' );
|
77 |
+
$display_date = date( 'Y-m-d h:i:s' );
|
78 |
+
$datetime1 = new DateTime( $install_date );
|
79 |
+
$datetime2 = new DateTime( $display_date );
|
80 |
+
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
|
81 |
+
|
82 |
+
$rate = get_option( 'quads_rating_div', false );
|
83 |
+
if( $diff_intrval >= 7 && ($rate === "no" || false === $rate || quads_rate_again() ) ) {
|
84 |
+
echo '<div class="quads_fivestar updated " style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);background-color:white;">
|
85 |
+
<p>Awesome, you\'ve been using <strong>WP QUADS</strong> for more than 1 week. <br> May i ask you to give it a <strong>5-star rating</strong> on Wordpress? </br>
|
86 |
+
This will help to spread its popularity and to make this plugin a better one.
|
87 |
+
<br><br>Your help is much appreciated. Thank you very much,<br> ~René Hermenau
|
88 |
+
<ul>
|
89 |
+
<li><a href="https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/?filter=5#new-post" class="thankyou" target="_new" title="Ok, you deserved it" style="font-weight:bold;">Ok, you deserved it</a></li>
|
90 |
+
<li><a href="javascript:void(0);" class="quadsHideRating" title="I already did" style="font-weight:bold;">I already did</a></li>
|
91 |
+
<li><a href="javascript:void(0);" class="quadsHideRating" title="No, not good enough" style="font-weight:bold;">No, not good enough</a></li>
|
92 |
+
<br>
|
93 |
+
<li><a href="javascript:void(0);" class="quadsHideRatingWeek" title="No, not good enough" style="font-weight:bold;">I want to rate it later. Ask me again in a week!</a></li>
|
94 |
+
<li class="spinner" style="float:none;display:list-item;margin:0px;"></li>
|
95 |
+
</ul>
|
96 |
+
|
97 |
+
</div>
|
98 |
+
<script>
|
99 |
+
jQuery( document ).ready(function( $ ) {
|
100 |
+
|
101 |
+
jQuery(\'.quadsHideRating\').click(function(){
|
102 |
+
jQuery(".spinner").addClass("is-active");
|
103 |
+
var data={\'action\':\'quads_hide_rating\'}
|
104 |
+
jQuery.ajax({
|
105 |
+
|
106 |
+
url: "' . admin_url( 'admin-ajax.php' ) . '",
|
107 |
+
type: "post",
|
108 |
+
data: data,
|
109 |
+
dataType: "json",
|
110 |
+
async: !0,
|
111 |
+
success: function(e) {
|
112 |
+
if (e=="success") {
|
113 |
+
jQuery(".spinner").removeClass("is-active");
|
114 |
+
jQuery(\'.quads_fivestar\').slideUp(\'fast\');
|
115 |
+
|
116 |
+
}
|
117 |
+
}
|
118 |
+
});
|
119 |
+
})
|
120 |
+
|
121 |
+
jQuery(\'.quadsHideRatingWeek\').click(function(){
|
122 |
+
jQuery(".spinner").addClass("is-active");
|
123 |
+
var data={\'action\':\'quads_hide_rating_week\'}
|
124 |
+
jQuery.ajax({
|
125 |
+
|
126 |
+
url: "' . admin_url( 'admin-ajax.php' ) . '",
|
127 |
+
type: "post",
|
128 |
+
data: data,
|
129 |
+
dataType: "json",
|
130 |
+
async: !0,
|
131 |
+
success: function(e) {
|
132 |
+
if (e=="success") {
|
133 |
+
jQuery(".spinner").removeClass("is-active");
|
134 |
+
jQuery(\'.quads_fivestar\').slideUp(\'fast\');
|
135 |
+
|
136 |
+
}
|
137 |
+
}
|
138 |
+
});
|
139 |
+
})
|
140 |
+
|
141 |
+
});
|
142 |
+
</script>
|
143 |
+
';
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
add_action( 'admin_notices', 'quads_admin_messages' );
|
148 |
+
|
149 |
+
|
150 |
+
/* Hide the rating div
|
151 |
+
*
|
152 |
+
* @subpackage Admin/Notices
|
153 |
+
* @copyright Copyright (c) 2016, René Hermenau
|
154 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
155 |
+
* @since 1.0.9
|
156 |
+
*
|
157 |
+
* @return json string
|
158 |
+
*
|
159 |
+
*/
|
160 |
+
|
161 |
+
function quads_hide_rating_div() {
|
162 |
+
update_option( 'quads_rating_div', 'yes' );
|
163 |
+
delete_option( 'quads_date_next_notice' );
|
164 |
+
echo json_encode( array("success") );
|
165 |
+
exit;
|
166 |
+
}
|
167 |
+
|
168 |
+
add_action( 'wp_ajax_quads_hide_rating', 'quads_hide_rating_div' );
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Write the timestamp when rating notice will be opened again
|
172 |
+
*/
|
173 |
+
function quads_hide_rating_notice_week() {
|
174 |
+
$nextweek = time() + (7 * 24 * 60 * 60);
|
175 |
+
$human_date = date( 'Y-m-d h:i:s', $nextweek );
|
176 |
+
update_option( 'quads_date_next_notice', $human_date );
|
177 |
+
update_option( 'quads_rating_div', 'yes' );
|
178 |
+
echo json_encode( array("success") );
|
179 |
+
exit;
|
180 |
+
}
|
181 |
+
|
182 |
+
add_action( 'wp_ajax_quads_hide_rating_week', 'quads_hide_rating_notice_week' );
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Check if admin notice will open again after one week of closing
|
186 |
+
* @return boolean
|
187 |
+
*/
|
188 |
+
function quads_rate_again() {
|
189 |
+
|
190 |
+
$rate_again_date = get_option( 'quads_date_next_notice' );
|
191 |
+
|
192 |
+
if( false === $rate_again_date ) {
|
193 |
+
return false;
|
194 |
+
}
|
195 |
+
|
196 |
+
$current_date = date( 'Y-m-d h:i:s' );
|
197 |
+
$datetime1 = new DateTime( $rate_again_date );
|
198 |
+
$datetime2 = new DateTime( $current_date );
|
199 |
+
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
|
200 |
+
|
201 |
+
if( $diff_intrval >= 0 ) {
|
202 |
+
return true;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Show a message when pro or free plugin gets disabled
|
208 |
+
*
|
209 |
+
* @return void
|
210 |
+
* @not used
|
211 |
+
*/
|
212 |
+
function quads_plugin_deactivated_notice() {
|
213 |
+
if( false !== ( $deactivated_notice_id = get_transient( 'quads_deactivated_notice_id' ) ) ) {
|
214 |
+
if( '1' === $deactivated_notice_id ) {
|
215 |
+
$message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS.", 'wpstg' );
|
216 |
+
} else {
|
217 |
+
$message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS Pro.", 'wpstg' );
|
218 |
+
}
|
219 |
+
?>
|
220 |
+
<div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
|
221 |
+
<p><?php echo esc_html( $message ); ?></p>
|
222 |
+
</div> <?php
|
223 |
+
delete_transient( 'quads_deactivated_notice_id' );
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* This notice is shown for user of the bimber and bunchy theme
|
229 |
+
*
|
230 |
+
* Not used at the moment
|
231 |
+
*/
|
232 |
+
function quads_theme_notice() {
|
233 |
+
|
234 |
+
$show_notice = get_option( 'quads_show_theme_notice' );
|
235 |
+
|
236 |
+
if( false !== $show_notice && 'no' !== $show_notice && quads_is_commercial_theme() ) {
|
237 |
+
$message = __( '<strong>Extend the' . quads_is_commercial_theme() . '</strong> theme with <strong>WP QUADS PRO!</strong><br>Save time and earn more - Bring your AdSense earnings to next level. <a href="http://wpquads.com?utm_campaign=adminnotice&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank"> Purchase Now</a> or <a href="http://wpquads.com?utm_campaign=free_plugin&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank">Get Details</a> <p> <a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_upgrade_notice" class="button">Close Notice</a>', 'quick-adsense-reloaded' );
|
238 |
+
?>
|
239 |
+
<div class="updated notice" style="border-left: 4px solid #ffba00;">
|
240 |
+
<p><?php echo $message; ?></p>
|
241 |
+
</div> <?php
|
242 |
+
//update_option ('quads_show_theme_notice', 'no');
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* This notice is shown after updating to 1.3.9
|
248 |
+
*
|
249 |
+
*/
|
250 |
+
function quads_update_notice() {
|
251 |
+
|
252 |
+
$show_notice = get_option( 'quads_show_update_notice' );
|
253 |
+
|
254 |
+
// do not do anything
|
255 |
+
if( false !== $show_notice ) {
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
|
259 |
+
if( (version_compare( QUADS_VERSION, '1.3.9', '>=' ) ) && quads_is_pro_active() && (version_compare( QUADS_PRO_VERSION, '1.3.0', '<' ) ) ) {
|
260 |
+
$message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Update WP QUADS PRO to get custom post type support from <a href="%s">General Settings</a>.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings' );
|
261 |
+
$message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
|
262 |
+
?>
|
263 |
+
<div class="updated notice" style="border-left: 4px solid #ffba00;">
|
264 |
+
<p><?php echo $message; ?></p>
|
265 |
+
</div> <?php
|
266 |
+
//update_option ('quads_show_update_notice', 'no');
|
267 |
+
} else
|
268 |
+
if( !quads_is_extra() ) {
|
269 |
+
$message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': </strong> Install <a href="%1s" target="_blank">WP QUADS PRO</a> to get custom post type support in <a href="%2s">General Settings</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com?utm_campaign=admin_notice&utm_source=admin_notice&utm_medium=admin&utm_content=custom_post_type', admin_url() . 'admin.php?page=quads-settings' );
|
270 |
+
$message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
|
271 |
+
?>
|
272 |
+
<div class="updated notice" style="border-left: 4px solid #ffba00;">
|
273 |
+
<p><?php echo $message; ?></p>
|
274 |
+
</div>
|
275 |
+
<?php
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Show upgrade notice if wp quads pro is lower than 1.3.6
|
281 |
+
* @return boolean
|
282 |
+
*/
|
283 |
+
function quads_update_notice_v2() {
|
284 |
+
|
285 |
+
if( quads_is_pro_active() && (version_compare( QUADS_PRO_VERSION, '1.3.6', '<' ) ) && quads_is_admin_page() ) {
|
286 |
+
$message = sprintf( __( 'You need to update <strong>WP QUADS PRO to version 1.3.6</strong> or higher. Your version of <strong>WP QUADS Pro</strong> is ' . QUADS_PRO_VERSION . '.<br>WP QUADS Pro ' . QUADS_PRO_VERSION . ' supports unlimited amount of ads. <br>Updating requires a valid <a href="%s" target="_new">license key</a>.', 'quick-adsense-reloaded' ), 'https://wpquads.com/#buy-wpquads?utm_source=plugin_notice&utm_medium=admin&utm_campaign=activate_license' );
|
287 |
+
?>
|
288 |
+
<div class="notice notice-error">
|
289 |
+
<p><?php echo $message; ?></p>
|
290 |
+
</div> <?php
|
291 |
+
}
|
292 |
+
}
|
293 |
+
|
294 |
+
/**
|
295 |
+
* Show upgrade notice after updating from 1.5.2 to 1.5.3 and higher
|
296 |
+
* @return boolean
|
297 |
+
*/
|
298 |
+
function quads_update_notice_1_5_3() {
|
299 |
+
|
300 |
+
// do not show anything
|
301 |
+
if( false !== get_option( 'quads_hide_update_notice_1_5_3' ) ) {
|
302 |
+
return false;
|
303 |
+
}
|
304 |
+
|
305 |
+
$previous_version = get_option( 'quads_version_upgraded_from' );
|
306 |
+
|
307 |
+
//wp_die(QUADS_VERSION);
|
308 |
+
// Show update message if previous version was lower than 1.7 - This makes sure that the message is shown for future updates without complicated version number conditions
|
309 |
+
if( !empty( $previous_version ) && version_compare( QUADS_VERSION, '1.7.0', '<=' ) ) {
|
310 |
+
|
311 |
+
$message = sprintf( __( 'This is a huge update! The data structure of WP QUADS has been modified and improved for better performance and great new features. <br> For the case you\'d experience issues, we made a <a href="%1s" target="_self">backup of previous WP QUADS data</a>. So you can <a href="%2s" target="_new">switch back to the previous version</a> anytime. <br><br>Please <a href="%3s" target="_new">open first a support ticket</a> if you experience any issue.', 'quick-adsense-reloaded' ), admin_url() . '?page=quads-settings&tab=help', 'https://wpquads.com/docs/install-older-plugin-version/?utm_source=plugin_notice&utm_medium=admin&utm_campaign=install_older_version', 'https://wordpress.org/support/plugin/quick-adsense-reloaded' );
|
312 |
+
?>
|
313 |
+
<div class="notice notice-error">
|
314 |
+
<p><?php echo $message; ?></p>
|
315 |
+
<?php
|
316 |
+
echo '<p><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice_1_5_3" class="button-primary" target="_self" title="Close Notice" style="font-weight:bold;">' . __( 'Close Notice', 'quick-adsense-reloaded' ) . '</a>';
|
317 |
+
?>
|
318 |
+
</div> <?php
|
319 |
+
}
|
320 |
+
}
|
321 |
+
|
322 |
+
/**
|
323 |
+
* Hide Notice and update db option quads_hide_notice
|
324 |
+
*/
|
325 |
+
function quads_hide_notice() {
|
326 |
+
update_option( 'quads_show_update_notice', 'no' );
|
327 |
+
}
|
328 |
+
|
329 |
+
add_action( 'quads_hide_update_notice', 'quads_hide_notice', 10 );
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Set option to hide admin notice 1.5.3
|
333 |
+
* @return boolean
|
334 |
+
*/
|
335 |
+
function quads_hide_notice_1_5_3() {
|
336 |
+
update_option( 'quads_hide_update_notice_1_5_3', '1' );
|
337 |
+
}
|
338 |
+
|
339 |
+
add_action( 'quads_hide_update_notice_1_5_3', 'quads_hide_notice_1_5_3' );
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Check if any ad is activated and assigned in general settings
|
343 |
+
*
|
344 |
+
* @global array $quads_options
|
345 |
+
* @return boolean
|
346 |
+
*/
|
347 |
+
function quads_is_any_ad_activated() {
|
348 |
+
global $quads_options;
|
349 |
+
|
350 |
+
// Check if custom positions location_settings is empty or does not exists
|
351 |
+
$check = array();
|
352 |
+
if( isset( $quads_options['location_settings'] ) ) {
|
353 |
+
foreach ( $quads_options['location_settings'] as $location_array ) {
|
354 |
+
if( isset( $location_array['status'] ) ) {
|
355 |
+
$check[] = $location_array['status'];
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
// ad activated with api (custom position)
|
361 |
+
if( count( $check ) > 0 ) {
|
362 |
+
return true;
|
363 |
+
}
|
364 |
+
// check if any other ad is assigned and activated
|
365 |
+
if( isset( $quads_options['pos1']['BegnAds'] ) ||
|
366 |
+
isset( $quads_options['pos2']['MiddAds'] ) ||
|
367 |
+
isset( $quads_options['pos3']['EndiAds'] ) ||
|
368 |
+
isset( $quads_options['pos4']['MoreAds'] ) ||
|
369 |
+
isset( $quads_options['pos5']['LapaAds'] ) ||
|
370 |
+
isset( $quads_options['pos6']['Par1Ads'] ) ||
|
371 |
+
isset( $quads_options['pos7']['Par2Ads'] ) ||
|
372 |
+
isset( $quads_options['pos8']['Par3Ads'] ) ||
|
373 |
+
isset( $quads_options['pos9']['Img1Ads'] )
|
374 |
+
) {
|
375 |
+
return true;
|
376 |
+
}
|
377 |
+
// no ad is activated
|
378 |
+
return false;
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Check if any post type is enabled
|
383 |
+
*
|
384 |
+
* @global array $quads_options
|
385 |
+
* @return boolean
|
386 |
+
*/
|
387 |
+
function quads_is_post_type_activated() {
|
388 |
+
global $quads_options;
|
389 |
+
|
390 |
+
if( empty( $quads_options['post_types'] ) ) {
|
391 |
+
return false;
|
392 |
+
}
|
393 |
+
return true;
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Check if ad codes are populated
|
398 |
+
*
|
399 |
+
* @global array $quads_options
|
400 |
+
* @return booleantrue if ads are empty
|
401 |
+
*/
|
402 |
+
function quads_ads_empty() {
|
403 |
+
global $quads_options;
|
404 |
+
|
405 |
+
$check = array();
|
406 |
+
|
407 |
+
for ( $i = 1; $i <= 10; $i++ ) {
|
408 |
+
if( !empty( $quads_options['ads']['ad' . $i]['code'] ) ) {
|
409 |
+
$check[] = 'true';
|
410 |
+
}
|
411 |
+
}
|
412 |
+
if( count( $check ) === 0 ) {
|
413 |
+
return true;
|
414 |
+
}
|
415 |
+
return false;
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Return VI admin notice
|
420 |
+
* @return string
|
421 |
+
*/
|
422 |
+
function quads_get_vi_notice() {
|
423 |
+
global $quads;
|
424 |
+
|
425 |
+
if( false !== get_option( 'quads_close_vi_welcome_notice' ) || !quads_is_admin_page() ) {
|
426 |
+
return false;
|
427 |
+
}
|
428 |
+
|
429 |
+
$mail = get_option( 'admin_email' );
|
430 |
+
$domain = $quads->vi->getDomain();
|
431 |
+
|
432 |
+
|
433 |
+
$white = '<div class="quads-banner-wrapper">
|
434 |
+
<section class="quads-banner-content">
|
435 |
+
<div class="quads-banner-columns">
|
436 |
+
<main class="quads-banner-main"><p>' .
|
437 |
+
sprintf(
|
438 |
+
__( 'This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
|
439 |
+
content and video advertising.<br>
|
440 |
+
To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-white" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:black;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
|
441 |
+
<p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaed' ), 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white', admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white'
|
442 |
+
)
|
443 |
+
. '</p></main>
|
444 |
+
<!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
|
445 |
+
<aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=white"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-white.png" width="168" height="72"></a></p></aside>
|
446 |
+
</div>
|
447 |
+
<aside class="quads-banner-close"><div style="margin-top:5px;"><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
|
448 |
+
</section>
|
449 |
+
</div>';
|
450 |
+
|
451 |
+
|
452 |
+
$black = '<div class="quads-banner-wrapper" style="background-color:black;">
|
453 |
+
<section class="quads-banner-content">
|
454 |
+
<div class="quads-banner-columns">
|
455 |
+
<main class="quads-banner-main" style="color:white;"><p>' .
|
456 |
+
sprintf(
|
457 |
+
__( 'This update features vi stories from <strong>video intelligence</strong>. This video player will supply you with both video
|
458 |
+
content and video advertising.<br>
|
459 |
+
To begin earning, visit the WP QUADS plugin page, <a href="%1$s" target="_blank" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">sign up</a> to vi stories and <a href="%2$s" class="quads-vi-welcome-black" style="text-decoration: none;border-bottom:3px solid yellow;font-weight: bold;color:white;">place the ad live now!</a> Read the <a href="%3$s" target="_blank">FAQ</a>.
|
460 |
+
<p style="font-size:10px;">By clicking <strong>sign up</strong> you agree to send your current domain, email and affiliate ID to video intelligence & WP QUADS</p>', 'quick-adsense-reloaded' ), 'https://www.vi.ai/publisher-registration/?aid=WP_Quads&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black', admin_url() . 'admin.php?page=quads-settings#quads_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black'
|
461 |
+
)
|
462 |
+
. '</p></main>
|
463 |
+
<!--<aside class="quads-banner-sidebar-first"><p><a href="https://www.vi.ai/?utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi_quads_logo.png" width="168" height="72"></a></p></aside>//-->
|
464 |
+
<aside class="quads-banner-sidebar-second"><p style="text-align:center;"><a href="https://www.vi.ai/?aid=WP_Quads&utm_source=Wordpress&utm_medium=wp%20quads&utm_campaign=black"><img src="' . QUADS_PLUGIN_URL . 'assets/images/vi-logo-black.png" width="168" height="72"></a></p></aside>
|
465 |
+
</div>
|
466 |
+
<aside class="quads-banner-close"><div style="margin-top:5px;"><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=close_vi_welcome_notice" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
|
467 |
+
</section>
|
468 |
+
</div>';
|
469 |
+
|
470 |
+
$variant = get_option( 'quads_vi_variant' );
|
471 |
+
|
472 |
+
switch ( $variant ) {
|
473 |
+
case 'a':
|
474 |
+
return $white;
|
475 |
+
break;
|
476 |
+
case 'b':
|
477 |
+
return $black;
|
478 |
+
break;
|
479 |
+
default:
|
480 |
+
return $white;
|
481 |
+
break;
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
/**
|
486 |
+
* Check if vi admin notice should be opened again again one week after closing
|
487 |
+
* @return boolean
|
488 |
+
*/
|
489 |
+
function quads_show_vi_notice_again() {
|
490 |
+
|
491 |
+
$show_again_date = get_option( 'quads_show_vi_notice_later' );
|
492 |
+
|
493 |
+
if( false === $show_again_date ) {
|
494 |
+
return false;
|
495 |
+
}
|
496 |
+
|
497 |
+
$current_date = date( 'Y-m-d h:i:s' );
|
498 |
+
$datetime1 = new DateTime( $show_again_date );
|
499 |
+
$datetime2 = new DateTime( $current_date );
|
500 |
+
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
|
501 |
+
|
502 |
+
if( $diff_intrval >= 0 ) {
|
503 |
+
return true;
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Show all vi notices
|
509 |
+
*/
|
510 |
+
function quads_show_vi_notices() {
|
511 |
+
global $quads, $quads_options;
|
512 |
+
|
513 |
+
if( !quads_is_admin_page() ) {
|
514 |
+
return false;
|
515 |
+
}
|
516 |
+
|
517 |
+
|
518 |
+
// adsense ads.txt content
|
519 |
+
$adsense = new wpquads\adsense( $quads_options );
|
520 |
+
$adsensePublisherIds = $adsense->getPublisherIds();
|
521 |
+
|
522 |
+
$adsenseAdsTxtText = '';
|
523 |
+
if( !empty( $adsensePublisherIds ) ) {
|
524 |
+
foreach ( $adsensePublisherIds as $adsensePublisherId ) {
|
525 |
+
$adsenseAdsTxtText .= "google.com, " . str_replace( 'ca-', '', $adsensePublisherId ) . ", DIRECT, f08c47fec0942fa0\r\n";
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
// vi ads.txt content
|
530 |
+
$viAdsTxtText = '';
|
531 |
+
if( $quads->vi->getPublisherId() ) {
|
532 |
+
$viAdsTxtText = $quads->vi->getAdsTxtContent();
|
533 |
+
}
|
534 |
+
|
535 |
+
// Show ads.txt warning if logged into vi and ads.txt option is disabled
|
536 |
+
if( get_transient( 'quads_vi_ads_txt_disabled' ) && get_option( 'quads_vi_token' ) ) {
|
537 |
+
// ads.txt content
|
538 |
+
$notice['message'] = sprintf( '<p><strong>ADS.TXT couldn\'t be updated automatically.</strong><br><br>You need the ads.txt to display vi video ads. <br>If you want WP QUADS to create an ads.txt automatically you can enable the ads.txt option at <a href="%1$s">General & Position</a>. Alternatively you can also enter the following line manually into <strong>' . get_site_url() . '/ads.txt</strong>:'
|
539 |
+
. "<p>"
|
540 |
+
. "<pre>" . $viAdsTxtText . "<br>"
|
541 |
+
. $adsenseAdsTxtText
|
542 |
+
. "</pre></p>"
|
543 |
+
. 'If the file does not exist you need to create it first. <a href="%2$s" target="_blank">Learn More</a></p>'
|
544 |
+
, admin_url() . 'admin.php?page=quads-settings#quads_settingsgeneral_header'
|
545 |
+
, 'https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
|
546 |
+
);
|
547 |
+
$notice['type'] = 'update-nag';
|
548 |
+
$adsTxtDisabled = new wpquads\template( '/includes/vendor/vi/views/notices', $notice );
|
549 |
+
echo $adsTxtDisabled->render();
|
550 |
+
return false;
|
551 |
+
}
|
552 |
+
|
553 |
+
// show ad.txt update notice
|
554 |
+
if( get_transient( 'quads_vi_ads_txt_notice' ) ) {
|
555 |
+
$notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated your ads.txt '
|
556 |
+
. 'file with lines that declare video inteligence as a legitmate seller of your inventory and enables you to make more money through video inteligence. <a href="https://www.vi.ai/publisher-video-monetization/?utm_source=WordPress&utm_medium=Plugin%20blurb&utm_campaign=wpquads" target="blank" rel="external nofollow">FAQ</a>';
|
557 |
+
$notice['type'] = 'update-nag';
|
558 |
+
$adsUpdated = new wpquads\template( '/includes/vendor/vi/views/notices', $notice );
|
559 |
+
echo $adsUpdated->render();
|
560 |
+
}
|
561 |
+
|
562 |
+
// show ad.txt update notice
|
563 |
+
if( get_transient( 'quads_vi_ads_txt_error' ) ) {
|
564 |
+
|
565 |
+
|
566 |
+
// ads.txt content
|
567 |
+
$notice['message'] = "<p><strong>ADS.TXT couldn't be added</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <br><strong>" . get_home_path() . "ads.txt</strong>:"
|
568 |
+
. "<p>"
|
569 |
+
. "<pre>vi.ai " . $quads->vi->getPublisherId() . " DIRECT # 41b5eef6<br>"
|
570 |
+
. $adsenseAdsTxtText
|
571 |
+
. "</pre></p>"
|
572 |
+
. "Only by doing so you are able to make more money through video inteligence.</p>";
|
573 |
+
$notice['type'] = 'error';
|
574 |
+
|
575 |
+
// render blurb
|
576 |
+
$adsTxtError = new wpquads\template( '/includes/vendor/vi/views/notices', $notice );
|
577 |
+
echo $adsTxtError->render();
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Show a ads.txt notices if WP QUADS has permission to update or create an ads.txt
|
583 |
+
*/
|
584 |
+
function quads_show_ads_txt_notice() {
|
585 |
+
global $quads, $quads_options;
|
586 |
+
|
587 |
+
if( !quads_is_admin_page() )
|
588 |
+
return false;
|
589 |
+
|
590 |
+
|
591 |
+
// show ad.txt update notice
|
592 |
+
if( get_transient( 'quads_ads_txt_notice' ) && isset( $quads_options['adsTxtEnabled'] ) ) {
|
593 |
+
$notice['message'] = '<strong>ADS.TXT has been added</strong><br><br><strong>WP QUADS</strong> has updated the file ' . ABSPATH . 'ads.txt '
|
594 |
+
. 'file with lines that declare Google.com as a legitmate seller of your inventory and is recommended setting by AdSense.<br><a href="https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/" target="blank" rel="external nofollow">What is ads.txt?</a>';
|
595 |
+
$notice['type'] = 'update-nag';
|
596 |
+
$notice['action'] = 'close_ads_txt_notice';
|
597 |
+
$adsUpdated = new wpquads\template( '/includes/admin/views/notices', $notice );
|
598 |
+
echo $adsUpdated->render();
|
599 |
+
}
|
600 |
+
|
601 |
+
// show ads.txt error notice
|
602 |
+
if( get_transient( 'close_ads_txt_error' ) && isset( $quads_options['adsTxtEnabled'] ) ) {
|
603 |
+
|
604 |
+
// Check if adsense is used and add the adsense publisherId to ads.txt blurb as well
|
605 |
+
$adsense = new wpquads\adsense( $quads_options );
|
606 |
+
$adsensePublisherIds = $adsense->getPublisherIds();
|
607 |
+
|
608 |
+
|
609 |
+
$adsenseAdsTxtText = '';
|
610 |
+
if( !empty( $adsensePublisherIds ) ) {
|
611 |
+
foreach ( $adsensePublisherIds as $adsensePublisherId ) {
|
612 |
+
$adsenseAdsTxtText .= "google.com, " . str_replace( 'ca-', '', $adsensePublisherId ) . ", DIRECT, f08c47fec0942fa0\n\r";
|
613 |
+
}
|
614 |
+
}
|
615 |
+
|
616 |
+
$viAdsTxtText = '';
|
617 |
+
if( $quads->vi->getPublisherId() ) {
|
618 |
+
$viAdsTxtText = $quads->vi->getAdsTxtContent();
|
619 |
+
}
|
620 |
+
|
621 |
+
// ads.txt content
|
622 |
+
$notice['message'] = "<p><strong>ADS.TXT couldn't be updated automatically</strong><br><br>Important note: WP QUADS hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into <strong>" . get_home_path() . "ads.txt</strong>:"
|
623 |
+
. "<p>"
|
624 |
+
. "<pre>" . $viAdsTxtText . "<br>"
|
625 |
+
. $adsenseAdsTxtText
|
626 |
+
. "</pre></p>"
|
627 |
+
. "Only by doing so AdSense ads are shown on your site.</p>";
|
628 |
+
$notice['type'] = 'error';
|
629 |
+
$notice['action'] = 'quads_ads_txt_error';
|
630 |
+
|
631 |
+
// render blurb
|
632 |
+
$adsTxtError = new wpquads\template( '/includes/admin/views/notices', $notice );
|
633 |
+
echo $adsTxtError->render();
|
634 |
+
}
|
635 |
+
}
|
636 |
+
|
637 |
+
/**
|
638 |
+
* Show api errors
|
639 |
+
*/
|
640 |
+
function quads_show_vi_api_error() {
|
641 |
+
if( !quads_is_admin_page() ) {
|
642 |
+
return false;
|
643 |
+
}
|
644 |
+
|
645 |
+
if( false !== get_option( 'quads_vi_api_error' ) ) {
|
646 |
+
$notice['message'] = 'WP QUADS - Can not retrive ad settings from vi API. Error: ' . get_option( 'quads_vi_api_error' );
|
647 |
+
$notice['type'] = 'error';
|
648 |
+
$notice['action'] = '';
|
649 |
+
// render blurb
|
650 |
+
$blurb = new wpquads\template( '/includes/admin/views/notices', $notice );
|
651 |
+
echo $blurb->render();
|
652 |
+
}
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Show global notice WP QUADS Pro license expired
|
657 |
+
* @return mixed boolean | string
|
658 |
+
*/
|
659 |
+
function quads_show_license_expired() {
|
660 |
+
global $quads_options, $wp_version;
|
661 |
+
|
662 |
+
$licKey = isset( $quads_options['quads_wp_quads_pro_license_key'] ) ? $quads_options['quads_wp_quads_pro_license_key'] : '';
|
663 |
+
|
664 |
+
$lic = get_option( 'quads_wp_quads_pro_license_active' );
|
665 |
+
|
666 |
+
// Do not show if no license at all or if there is a valid license key
|
667 |
+
if( !$lic || (isset( $lic->license ) && $lic->license !== 'invalid') ) {
|
668 |
+
return false;
|
669 |
+
}
|
670 |
+
|
671 |
+
// Do not show notice for another 30 days
|
672 |
+
if( get_transient( 'quads_notice_lic_expired' ) ) {
|
673 |
+
return false;
|
674 |
+
}
|
675 |
+
|
676 |
+
|
677 |
+
echo '<div class="notice notice-error">';
|
678 |
+
echo sprintf(
|
679 |
+
__( '<p>Oh No! <strong>WP Quads Pro</strong> license key is not activated or has been expired. It expires on %s. Renew or activate your license key to make sure that your (AdSense) ads are shown properly with your WordPress, version ' . $wp_version . '<br>'
|
680 |
+
. '<a href="%s" target="_blank" title="Renew your license key" class="button"><strong>Renew Your License Key Now</strong></a> | <a href="%s" title="Renew your license key">I am aware of possible issues and want to hide this reminder</a>'
|
681 |
+
, 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $lic->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $licKey . '&utm_campaign=adminnotic123e&utm_source=adminnotice123&utm_medium=admin&utm_content=license-expired', admin_url() . 'admin.php?page=quads-settings&tab=licenses&quads-action=hide_license_expired_notice'
|
682 |
+
);
|
683 |
+
echo '</p></div>';
|
684 |
+
}
|
685 |
+
|
686 |
+
/**
|
687 |
+
* Store the transient for 30 days
|
688 |
+
*/
|
689 |
+
function quads_hide_license_expired_notice() {
|
690 |
+
set_transient( 'quads_notice_lic_expired', 'hide', 60 * 60 * 24 * 30 );
|
691 |
+
}
|
692 |
+
|
693 |
+
add_action( 'quads_hide_license_expired_notice', 'quads_hide_license_expired_notice' );
|
694 |
+
|
695 |
+
/**
|
696 |
+
* Return update notice for Google Auto Ads
|
697 |
+
* @since 3.5.3.0
|
698 |
+
*/
|
699 |
+
function quads_show_update_auto_ads() {
|
700 |
+
|
701 |
+
|
702 |
+
$message = sprintf( __( '<h2 style="color:white;">WP QUADS & Google Auto Ads</h2>'
|
703 |
+
. 'WP QUADS Pro adds support for Google Auto Ads<br><br> Get the Pro plugin from <a href="https://wpquads.com/?utm_source=wp-admin&utm_medium=autoads-notice&utm_campaign=autoads-notice" target="_blank" style="color:#87c131;font-weight:500;">wpquads.com</a>'
|
704 |
+
, 'mashsb' ), admin_url() . 'admin.php?page=quads-settings'
|
705 |
+
);
|
706 |
+
|
707 |
+
if( get_option( 'quads_show_notice_auto_ads' ) === 'no' ) {
|
708 |
+
return false;
|
709 |
+
}
|
710 |
+
|
711 |
+
// admin notice after updating wp quads
|
712 |
+
echo '<div class="quads-notice-gdpr update-nag" style="background-color: black;color: #87c131;padding: 20px;margin-top: 20px;border: 3px solid #87c131;display:block;">' . $message .
|
713 |
+
'<p><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_auto_ads_notice" class="quads_hide_gdpr" title="I got it" style="text-decoration:none;color:white;">- I Understand! Do Not Show This Hint Again -</a></a>' .
|
714 |
+
'</div>';
|
715 |
+
}
|
716 |
+
|
717 |
+
/**
|
718 |
+
* Hide GDPR notice
|
719 |
+
*
|
720 |
+
* @global array $mashsb_options
|
721 |
+
*/
|
722 |
+
function mashsb_hide_auto_ads_notice() {
|
723 |
+
global $quads_options;
|
724 |
+
// Get all settings
|
725 |
+
update_option( 'quads_show_notice_auto_ads', 'no' );
|
726 |
+
}
|
727 |
+
|
728 |
+
add_action( 'quads_hide_auto_ads_notice', 'mashsb_hide_auto_ads_notice' );
|
includes/admin/admin-pages.php
CHANGED
@@ -1,83 +1,83 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin Pages
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Pages
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 2.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly
|
13 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Creates the admin submenu pages under the Quick AdSense Reloaded menu and assigns their
|
17 |
-
* links to global variables
|
18 |
-
*
|
19 |
-
* @since 1.0
|
20 |
-
* @global $quads_settings_page
|
21 |
-
* @global $quads_add_ons_page
|
22 |
-
* @return void
|
23 |
-
*/
|
24 |
-
function quads_add_options_link() {
|
25 |
-
global $quads_options, $quads_parent_page, $quads_add_ons_page, $quads_add_ons_page2, $quads_settings_page;
|
26 |
-
|
27 |
-
$label = quads_is_extra() ? 'WP QUADS PRO' : 'WP QUADS';
|
28 |
-
|
29 |
-
$create_settings = isset($quads_options['create_settings']) ? true : false;
|
30 |
-
if ($create_settings) {
|
31 |
-
$quads_settings_page = add_submenu_page('options-general.php', __('WP QUADS Settings', 'quick-adsense-reloaded'), __('WPQUADS', 'quick-adsense-reloaded'), 'manage_options', 'quads-settings', 'quads_options_page');
|
32 |
-
} else {
|
33 |
-
$wpquads_logo = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgd2lkdGg9IjYxMS42OHB4IiBoZWlnaHQ9IjU0NXB4IiB2aWV3Qm94PSIwIDAgNjExLjY4IDU0NSIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNjExLjY4IDU0NSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQoJIDxzdHlsZT4uc3R5bGUwe2ZpbGw6I2ZmZjt9PC9zdHlsZT4NCjxnIGlkPSJFYmVuZV8wX3hBMF9JbWFnZV8xXyI+DQo8L2c+DQo8ZyBpZD0iV1BRVUFEUyI+DQoJPGc+DQoJCTxwYXRoIGNsYXNzPSJzdHlsZTAiIGQ9Ik0yNS43MDksNTM1LjQyTDMuMzIsNDUxLjA0NGgxMS40NTRsMTIuODM0LDU1LjMxMWMxLjM4MSw1Ljc5NCwyLjU3LDExLjU1LDMuNTY4LDE3LjI2Nw0KCQkJYzIuMTQ4LTkuMDE3LDMuNDE1LTE0LjIxNiwzLjc5OS0xNS41OThsMTYuMDU4LTU2Ljk3OWgxMy40NjhsMTIuMDg2LDQyLjcwNmMzLjAzMSwxMC41OSw1LjIxOCwyMC41NDcsNi41NjIsMjkuODcxDQoJCQljMS4wNzQtNS4zMzMsMi40NzUtMTEuNDUzLDQuMjAyLTE4LjM2bDEzLjIzNy01NC4yMTdoMTEuMjI0TDg4LjY3NSw1MzUuNDJINzcuOTEybC0xNy43ODQtNjQuMjg5DQoJCQljLTEuNDk3LTUuMzcyLTIuMzgtOC42NzEtMi42NDgtOS44OTljLTAuODgzLDMuODc2LTEuNzA4LDcuMTc1LTIuNDc1LDkuODk5bC0xNy45LDY0LjI4OUgyNS43MDl6Ii8+DQoJCTxwYXRoIGNsYXNzPSJzdHlsZTAiIGQ9Ik0xMjIuMjI5LDUzNS40MnYtODQuMzc2aDMxLjgyOGM1LjYwMiwwLDkuODc5LDAuMjY5LDEyLjgzNSwwLjgwNmM0LjE0NCwwLjY5LDcuNjE2LDIuMDA2LDEwLjQxNywzLjk0Mg0KCQkJYzIuOCwxLjkzOCw1LjA1NSw0LjY1Myw2Ljc2Myw4LjE0NWMxLjcwNywzLjQ5MiwyLjU2MSw3LjMyOSwyLjU2MSwxMS41MTFjMCw3LjE3Ni0yLjI4MywxMy4yNDgtNi44NDksMTguMjE3DQoJCQljLTQuNTY2LDQuOTY5LTEyLjgxNiw3LjQ1My0yNC43NDksNy40NTNoLTIxLjY0MXYzNC4zMDNIMTIyLjIyOXogTTEzMy4zOTUsNDkxLjE2aDIxLjgxM2M3LjIxMywwLDEyLjMzNi0xLjM0MywxNS4zNjctNC4wMjkNCgkJCWMzLjAzMS0yLjY4Niw0LjU0Ny02LjQ2NSw0LjU0Ny0xMS4zMzhjMC0zLjUzLTAuODkyLTYuNTUyLTIuNjc2LTkuMDY1Yy0xLjc4NC0yLjUxMy00LjEzNS00LjE3My03LjA1LTQuOTc5DQoJCQljLTEuODgtMC40OTgtNS4zNTMtMC43NDgtMTAuNDE3LTAuNzQ4aC0yMS41ODNWNDkxLjE2eiIvPg0KCQk8cGF0aCBjbGFzcz0ic3R5bGUwIiBkPSJNMjY4LjI0Nyw1MjQuNzE1YzQuMTgyLDIuOTkyLDguNzI5LDUuMzcyLDEzLjY0MSw3LjEzN2wtNi4yNzMsMTIuMDI5DQoJCQljLTIuNTcxLTAuNzY5LTUuMDg0LTEuODIzLTcuNTQtMy4xNjZjLTAuNTM4LTAuMjY5LTQuMzE3LTIuNzYzLTExLjMzOC03LjQ4MmMtNS41MjUsMi40MTgtMTEuNjQ2LDMuNjI2LTE4LjM2LDMuNjI2DQoJCQljLTEyLjk3LDAtMjMuMTI4LTMuODE3LTMwLjQ3Ni0xMS40NTNjLTcuMzQ4LTcuNjM1LTExLjAyMS0xOC4zNi0xMS4wMjEtMzIuMTc0YzAtMTMuNzc0LDMuNjg0LTI0LjQ4OSwxMS4wNS0zMi4xNDUNCgkJCWM3LjM2Ny03LjY1NCwxNy4zNjItMTEuNDgxLDI5Ljk4Ni0xMS40ODFjMTIuNTA4LDAsMjIuNDI3LDMuODI3LDI5Ljc1NiwxMS40ODFjNy4zMjgsNy42NTUsMTAuOTkzLDE4LjM3LDEwLjk5MywzMi4xNDUNCgkJCWMwLDcuMjkxLTEuMDE3LDEzLjY5OC0zLjA1LDE5LjIyNEMyNzQuMDc5LDUxNi42NzcsMjcxLjYyMyw1MjAuNzYzLDI2OC4yNDcsNTI0LjcxNXogTTI1NC41NDksNTE1LjEwMw0KCQkJYzIuMTg3LTIuNTY5LDMuODI3LTUuNjc4LDQuOTIxLTkuMzIzYzEuMDkzLTMuNjQ2LDEuNjQtNy44MjgsMS42NC0xMi41NDhjMC05Ljc0NS0yLjE0OS0xNy4wMjYtNi40NDYtMjEuODQyDQoJCQljLTQuMjk3LTQuODE0LTkuOTE5LTcuMjIzLTE2Ljg2My03LjIyM2MtNi45NDUsMC0xMi41NzYsMi40MTctMTYuODkzLDcuMjUyYy00LjMxNyw0LjgzNC02LjQ3NSwxMi4xMDUtNi40NzUsMjEuODEzDQoJCQljMCw5Ljg2MiwyLjE1OCwxNy4yMzgsNi40NzUsMjIuMTMxYzQuMzE2LDQuODkyLDkuNzc0LDcuMzM4LDE2LjM3NSw3LjMzOGMyLjQ1NSwwLDQuNzc3LTAuNDAzLDYuOTY0LTEuMjA5DQoJCQljLTMuNDUzLTIuMjY0LTYuOTY0LTQuMDI4LTEwLjUzMi01LjI5NWw0Ljc3Ny05LjcyN0MyNDQuMDkyLDUwOC4zODksMjQ5LjQ0NSw1MTEuMjY3LDI1NC41NDksNTE1LjEwM3oiLz4NCgkJPHBhdGggY2xhc3M9InN0eWxlMCIgZD0iTTI5MS45MDIsNDUxLjA0NGgxNy4wMzd2NDUuNjk5YzAsNy4yNTIsMC4yMSwxMS45NTIsMC42MzMsMTQuMTAxYzAuNzI5LDMuNDUzLDIuNDY2LDYuMjI2LDUuMjA5LDguMzE2DQoJCQljMi43NDMsMi4wOTIsNi40OTQsMy4xMzcsMTEuMjUzLDMuMTM3YzQuODM0LDAsOC40NzktMC45ODcsMTAuOTM2LTIuOTY0YzIuNDU1LTEuOTc2LDMuOTMzLTQuNDAyLDQuNDMyLTcuMjgNCgkJCWMwLjQ5OC0yLjg3OCwwLjc0OC03LjY1NSwwLjc0OC0xNC4zMzF2LTQ2LjY3OGgxNy4wMzZ2NDQuMzE3YzAsMTAuMTMtMC40NiwxNy4yODYtMS4zODEsMjEuNDY4DQoJCQljLTAuOTIxLDQuMTg0LTIuNjE5LDcuNzEzLTUuMDk0LDEwLjU5MWMtMi40NzYsMi44NzgtNS43ODQsNS4xNzEtOS45MjksNi44NzhjLTQuMTQ0LDEuNzA3LTkuNTU0LDIuNTYxLTE2LjIzLDIuNTYxDQoJCQljLTguMDU4LDAtMTQuMTY5LTAuOTMxLTE4LjMzMi0yLjc5MWMtNC4xNjQtMS44Ni03LjQ1My00LjI3OC05Ljg3MS03LjI1MmMtMi40MTctMi45NzMtNC4wMS02LjA5MS00Ljc3Ny05LjM1Mw0KCQkJYy0xLjExMy00LjgzNS0xLjY2OS0xMS45NzItMS42NjktMjEuNDExVjQ1MS4wNDR6Ii8+DQoJCTxwYXRoIGNsYXNzPSJzdHlsZTAiIGQ9Ik00NTMuMjMsNTM1LjQyaC0xOC41MzNsLTcuMzY3LTE5LjE2NmgtMzMuNzI4bC02Ljk2NCwxOS4xNjZoLTE4LjA3MmwzMi44NjQtODQuMzc2aDE4LjAxNUw0NTMuMjMsNTM1LjQyeg0KCQkJIE00MjEuODYyLDUwMi4wMzhsLTExLjYyNi0zMS4zMTFsLTExLjM5NiwzMS4zMTFINDIxLjg2MnoiLz4NCgkJPHBhdGggY2xhc3M9InN0eWxlMCIgZD0iTTQ2Mi4yMDksNDUxLjA0NGgzMS4xMzdjNy4wMjIsMCwxMi4zNzUsMC41MzgsMTYuMDU5LDEuNjExYzQuOTQ5LDEuNDU5LDkuMTg4LDQuMDQ5LDEyLjcyLDcuNzcxDQoJCQljMy41MjksMy43MjIsNi4yMTYsOC4yNzgsOC4wNTgsMTMuNjY5YzEuODQyLDUuMzkyLDIuNzYzLDEyLjAzOSwyLjc2MywxOS45NDNjMCw2Ljk0NS0wLjg2MywxMi45MzEtMi41OSwxNy45NTcNCgkJCWMtMi4xMTEsNi4xNC01LjEyMywxMS4xMDgtOS4wMzcsMTQuOTA2Yy0yLjk1NSwyLjg3OC02Ljk0NSw1LjEyMy0xMS45NzEsNi43MzRjLTMuNzYxLDEuMTg5LTguNzg3LDEuNzg0LTE1LjA4LDEuNzg0aC0zMi4wNTgNCgkJCVY0NTEuMDQ0eiBNNDc5LjI0NSw0NjUuMzE3djU1Ljg4N2gxMi43MmM0Ljc1NywwLDguMTkxLTAuMjY5LDEwLjMwMi0wLjgwNmMyLjc2My0wLjY5MSw1LjA1Ni0xLjg2MSw2Ljg3OC0zLjUxMg0KCQkJYzEuODIyLTEuNjQ4LDMuMzEtNC4zNjQsNC40NjEtOC4xNDRzMS43MjctOC45MywxLjcyNy0xNS40NTRjMC02LjUyMi0wLjU3NS0xMS41MjktMS43MjctMTUuMDIxDQoJCQljLTEuMTUxLTMuNDkxLTIuNzYzLTYuMjE2LTQuODM1LTguMTczYy0yLjA3MS0xLjk1Ny00LjctMy4yOC03Ljg4NS0zLjk3MmMtMi4zOC0wLjUzNi03LjA0Mi0wLjgwNi0xMy45ODYtMC44MDZINDc5LjI0NXoiLz4NCgkJPHBhdGggY2xhc3M9InN0eWxlMCIgZD0iTTU0My4wNzMsNTA3Ljk2NmwxNi41NzYtMS42MTFjMC45OTcsNS41NjQsMy4wMjEsOS42NSw2LjA3MiwxMi4yNmMzLjA1LDIuNjA5LDcuMTY1LDMuOTEzLDEyLjM0NiwzLjkxMw0KCQkJYzUuNDg2LDAsOS42Mi0xLjE2LDEyLjQwMy0zLjQ4MWMyLjc4MS0yLjMyMSw0LjE3Mi01LjAzNiw0LjE3Mi04LjE0NWMwLTEuOTk0LTAuNTg1LTMuNjkyLTEuNzU1LTUuMDk0DQoJCQljLTEuMTcxLTEuNC0zLjIxNC0yLjYxOC02LjEzLTMuNjU0Yy0xLjk5NS0wLjY5MS02LjU0Mi0xLjkxOS0xMy42NDEtMy42ODRjLTkuMTMyLTIuMjY0LTE1LjU0LTUuMDQ1LTE5LjIyNC04LjM0Ng0KCQkJYy01LjE4LTQuNjQzLTcuNzctMTAuMzAzLTcuNzctMTYuOTc5YzAtNC4yOTcsMS4yMTgtOC4zMTcsMy42NTQtMTIuMDU5YzIuNDM3LTMuNzQsNS45NDctNi41OSwxMC41MzMtOC41NDcNCgkJCWM0LjU4NC0xLjk1NywxMC4xMi0yLjkzNSwxNi42MDQtMi45MzVjMTAuNTksMCwxOC41NjIsMi4zMjEsMjMuOTE0LDYuOTY0czguMTYzLDEwLjg0LDguNDMyLDE4LjU5bC0xNy4wMzYsMC43NDkNCgkJCWMtMC43MjktNC4zMzYtMi4yOTMtNy40NTQtNC42OS05LjM1NGMtMi4zOTgtMS44OTktNS45OTYtMi44NDktMTAuNzkyLTIuODQ5Yy00Ljk0OSwwLTguODI1LDEuMDE4LTExLjYyNiwzLjA1MQ0KCQkJYy0xLjgwNCwxLjMwNS0yLjcwNSwzLjA1LTIuNzA1LDUuMjM3YzAsMS45OTUsMC44NDQsMy43MDMsMi41MzIsNS4xMjJjMi4xNDgsMS44MDUsNy4zNjcsMy42ODQsMTUuNjU1LDUuNjQxDQoJCQlzMTQuNDE4LDMuOTgxLDE4LjM4OSw2LjA3MmMzLjk3MiwyLjA5Miw3LjA3OSw0Ljk0OSw5LjMyNCw4LjU3NWMyLjI0NCwzLjYyNiwzLjM2Nyw4LjEwNiwzLjM2NywxMy40MzkNCgkJCWMwLDQuODM1LTEuMzQ0LDkuMzYyLTQuMDI5LDEzLjU4M2MtMi42ODcsNC4yMjItNi40ODQsNy4zNTgtMTEuMzk2LDkuNDFjLTQuOTEyLDIuMDUzLTExLjAzMiwzLjA3OS0xOC4zNiwzLjA3OQ0KCQkJYy0xMC42NjgsMC0xOC44NTktMi40NjUtMjQuNTc2LTcuMzk2QzU0Ny42MDEsNTI0LjU5MSw1NDQuMTg2LDUxNy40MDUsNTQzLjA3Myw1MDcuOTY2eiIvPg0KCTwvZz4NCjwvZz4NCjxnIGlkPSJFYmVuZV80X0tvcGllX3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjcyIiBoZWlnaHQ9IjI4IiBpZD0iRWJlbmVfNF9Lb3BpZV94QTBfSW1hZ2UiIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBRWdBQUFBY0NBSUFBQUJOa0c3eEFBQUFDWEJJV1hNQUFBc1NBQUFMRWdIUzNYNzhBQUFBCkdYUkZXSFJUYjJaMGQyRnlaUUJCWkc5aVpTQkpiV0ZuWlZKbFlXUjVjY2xsUEFBQUFEWkpSRUZVZU5yc3p3RU5BQUFJQXlEZlAvVE4Kb1lNR3BPMThGREV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TWJHYlZnQUJCZ0J1WTFQSkhBbElWd0FBQUFCSlJVNUVya0pnZ2c9PSIgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgMSA0IDM5MikiPg0KCTwvaW1hZ2U+DQo8L2c+DQo8ZyBpZD0iRWJlbmVfM19Lb3BpZV82X3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9Ijc2IiBoZWlnaHQ9IjEwOCIgaWQ9IkViZW5lXzNfS29waWVfNl94QTBfSW1hZ2UiIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBRXdBQUFCc0NBSUFBQUJQV2NOS0FBQUFDWEJJV1hNQUFBc1NBQUFMRWdIUzNYNzhBQUFBCkdYUkZXSFJUYjJaMGQyRnlaUUJCWkc5aVpTQkpiV0ZuWlZKbFlXUjVjY2xsUEFBQUFJQkpSRUZVZU5yc3p3RUJBREFJQXlDMWYrZTkKZ0FrOE5LQ1QxSFZUSDVDVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVQpsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlRjUFFFR0FPSGxBOVhxCjVpMFFBQUFBQUVsRlRrU3VRbUNDIiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAxIDIxNSAzMTIpIj4NCgk8L2ltYWdlPg0KPC9nPg0KPGcgaWQ9IkViZW5lXzNfS29waWVfN194QTBfSW1hZ2VfMV8iPg0KCQ0KCQk8aW1hZ2Ugb3ZlcmZsb3c9InZpc2libGUiIHdpZHRoPSI4MCIgaGVpZ2h0PSIxNzIiIGlkPSJFYmVuZV8zX0tvcGllXzdfeEEwX0ltYWdlIiB4bGluazpocmVmPSJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUZBQUFBQ3NDQUlBQUFCakk3eVlBQUFBQ1hCSVdYTUFBQXNTQUFBTEVnSFMzWDc4QUFBQQpHWFJGV0hSVGIyWjBkMkZ5WlFCQlpHOWlaU0JKYldGblpWSmxZV1I1Y2NsbFBBQUFBTDVKUkVGVWVOcnN6d0VCQUFBRUF6RDA3M3c5CjJCcXNrOVFuVTg4SUN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0wKQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTApDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEM5K3lBZ3dBClozMEVWVHVscE5RQUFBQUFTVVZPUks1Q1lJST0iIHRyYW5zZm9ybT0ibWF0cml4KDEgMCAwIDEgMzE5IDI0OCkiPg0KCTwvaW1hZ2U+DQo8L2c+DQo8ZyBpZD0iRWJlbmVfM19Lb3BpZV84X3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjgwIiBoZWlnaHQ9IjcyIiBpZD0iRWJlbmVfM19Lb3BpZV84X3hBMF9JbWFnZSIgeGxpbms6aHJlZj0iZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFGQUFBQUJJQ0FJQUFBRHU5dVVNQUFBQUNYQklXWE1BQUFzU0FBQUxFZ0hTM1g3OEFBQUEKR1hSRldIUlRiMlowZDJGeVpRQkJaRzlpWlNCSmJXRm5aVkpsWVdSNWNjbGxQQUFBQUdGSlJFRlVlTnJzenpFQkFBQUlBeURYUC9Rcwo0U2MwSUczbmt3Z0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMCkN3c0xDd3NMQ3dzTEN3c0xDd3NMQzk5YkFRWUEveWJYY2Qzc1lVOEFBQUFBU1VWT1JLNUNZSUk9IiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAxIDEwNiAzNDgpIj4NCgk8L2ltYWdlPg0KPC9nPg0KPGcgaWQ9IkViZW5lXzNfS29waWVfOV94QTBfSW1hZ2VfMV8iPg0KCQ0KCQk8aW1hZ2Ugb3ZlcmZsb3c9InZpc2libGUiIHdpZHRoPSI3MiIgaGVpZ2h0PSIyODAiIGlkPSJFYmVuZV8zX0tvcGllXzlfeEEwX0ltYWdlIiB4bGluazpocmVmPSJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUVnQUFBRVlDQUlBQUFCd2RpZFRBQUFBQ1hCSVdYTUFBQXNTQUFBTEVnSFMzWDc4QUFBQQpHWFJGV0hSVGIyWjBkMkZ5WlFCQlpHOWlaU0JKYldGblpWSmxZV1I1Y2NsbFBBQUFBUWxKUkVGVWVOcnN6d0VOQUFBSUF5QzFmK2ZiCjQ0TUdiSkpwZEZOS1RFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE0KVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TQpURXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNClRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE0KVEV4TVRFeE1URXhNVEV4TVRLelJDekFBK0YwRkxVdDk2RjhBQUFBQVNVVk9SSzVDWUlJPSIgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgMSA0MzAgMTQwKSI+DQoJPC9pbWFnZT4NCjwvZz4NCjxnIGlkPSJFYmVuZV8zX0tvcGllXzEwX3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjcyIiBoZWlnaHQ9IjQyMCIgaWQ9IkViZW5lXzNfS29waWVfMTBfeEEwX0ltYWdlIiB4bGluazpocmVmPSJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUVnQUFBR2tDQUlBQUFBZGZ2UmRBQUFBQ1hCSVdYTUFBQXNTQUFBTEVnSFMzWDc4QUFBQQpHWFJGV0hSVGIyWjBkMkZ5WlFCQlpHOWlaU0JKYldGblpWSmxZV1I1Y2NsbFBBQUFBWDlKUkVGVWVOcnN6MEVSQUFBSUF5RFhQL1JzCjRjT0RCcVR0ZkJReE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXgKTVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeApNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4Ck1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXgKTVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeApNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4Ck1URXhNVEV4TVRFeE1URXhNVEV4TVRHeE95dkFBRTYvNlBYS29tdGZBQUFBQUVsRlRrU3VRbUNDIiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAxIDUzNiAwKSI+DQoJPC9pbWFnZT4NCjwvZz4NCjwvc3ZnPg0K
|
34 |
-
";
|
35 |
-
$quads_parent_page = add_menu_page('Quick AdSense Reloaded Settings', $label, 'manage_options', 'quads-settings', 'quads_options_page', 'data:image/svg+xml;base64,' . $wpquads_logo);
|
36 |
-
$quads_settings_page = add_submenu_page('quads-settings', __('Ad Settings', 'quick-adsense-reloaded'), 'Ad Settings', 'manage_options', 'quads-settings', 'quads_options_page');
|
37 |
-
|
38 |
-
if (!quads_is_extra()) {
|
39 |
-
$quads_add_ons_page = add_submenu_page('quads-settings', __('Get Add-On', 'quick-adsense-reloaded'), 'Get WP QUADS PRO', 'manage_options', 'quads-addons', 'quads_add_ons_page');
|
40 |
-
}
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
add_action( 'admin_menu', 'quads_add_options_link', 10 );
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Determines whether the current admin page is an QUADS admin page.
|
48 |
-
*
|
49 |
-
* Only works after the `wp_loaded` hook, & most effective
|
50 |
-
* starting on `admin_menu` hook.
|
51 |
-
*
|
52 |
-
* @since 1.9.6
|
53 |
-
* @return bool True if QUADS admin page.
|
54 |
-
*/
|
55 |
-
function quads_is_admin_page() {
|
56 |
-
$currentpage = isset($_GET['page']) ? $_GET['page'] : '';
|
57 |
-
if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
|
58 |
-
return false;
|
59 |
-
}
|
60 |
-
|
61 |
-
if ( 'quads-settings' == $currentpage ) {
|
62 |
-
return true;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
/**
|
66 |
-
* Determines whether the current admin page is an QUADS add-on page.
|
67 |
-
*
|
68 |
-
* Only works after the `wp_loaded` hook, & most effective
|
69 |
-
* starting on `admin_menu` hook.
|
70 |
-
*
|
71 |
-
* @since 1.4.9
|
72 |
-
* @return bool True if QUADS admin page.
|
73 |
-
*/
|
74 |
-
function quads_is_addon_page() {
|
75 |
-
$currentpage = isset($_GET['page']) ? $_GET['page'] : '';
|
76 |
-
if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
|
77 |
-
return false;
|
78 |
-
}
|
79 |
-
|
80 |
-
if ( 'quads-addons' == $currentpage ) {
|
81 |
-
return true;
|
82 |
-
}
|
83 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Pages
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Pages
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 2.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Creates the admin submenu pages under the Quick AdSense Reloaded menu and assigns their
|
17 |
+
* links to global variables
|
18 |
+
*
|
19 |
+
* @since 1.0
|
20 |
+
* @global $quads_settings_page
|
21 |
+
* @global $quads_add_ons_page
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
+
function quads_add_options_link() {
|
25 |
+
global $quads_options, $quads_parent_page, $quads_add_ons_page, $quads_add_ons_page2, $quads_settings_page;
|
26 |
+
|
27 |
+
$label = quads_is_extra() ? 'WP QUADS PRO' : 'WP QUADS';
|
28 |
+
|
29 |
+
$create_settings = isset($quads_options['create_settings']) ? true : false;
|
30 |
+
if ($create_settings) {
|
31 |
+
$quads_settings_page = add_submenu_page('options-general.php', __('WP QUADS Settings', 'quick-adsense-reloaded'), __('WPQUADS', 'quick-adsense-reloaded'), 'manage_options', 'quads-settings', 'quads_options_page');
|
32 |
+
} else {
|
33 |
+
$wpquads_logo = "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCINCgkgd2lkdGg9IjYxMS42OHB4IiBoZWlnaHQ9IjU0NXB4IiB2aWV3Qm94PSIwIDAgNjExLjY4IDU0NSIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgNjExLjY4IDU0NSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQoJIDxzdHlsZT4uc3R5bGUwe2ZpbGw6I2ZmZjt9PC9zdHlsZT4NCjxnIGlkPSJFYmVuZV8wX3hBMF9JbWFnZV8xXyI+DQo8L2c+DQo8ZyBpZD0iV1BRVUFEUyI+DQoJPGc+DQoJCTxwYXRoIGNsYXNzPSJzdHlsZTAiIGQ9Ik0yNS43MDksNTM1LjQyTDMuMzIsNDUxLjA0NGgxMS40NTRsMTIuODM0LDU1LjMxMWMxLjM4MSw1Ljc5NCwyLjU3LDExLjU1LDMuNTY4LDE3LjI2Nw0KCQkJYzIuMTQ4LTkuMDE3LDMuNDE1LTE0LjIxNiwzLjc5OS0xNS41OThsMTYuMDU4LTU2Ljk3OWgxMy40NjhsMTIuMDg2LDQyLjcwNmMzLjAzMSwxMC41OSw1LjIxOCwyMC41NDcsNi41NjIsMjkuODcxDQoJCQljMS4wNzQtNS4zMzMsMi40NzUtMTEuNDUzLDQuMjAyLTE4LjM2bDEzLjIzNy01NC4yMTdoMTEuMjI0TDg4LjY3NSw1MzUuNDJINzcuOTEybC0xNy43ODQtNjQuMjg5DQoJCQljLTEuNDk3LTUuMzcyLTIuMzgtOC42NzEtMi42NDgtOS44OTljLTAuODgzLDMuODc2LTEuNzA4LDcuMTc1LTIuNDc1LDkuODk5bC0xNy45LDY0LjI4OUgyNS43MDl6Ii8+DQoJCTxwYXRoIGNsYXNzPSJzdHlsZTAiIGQ9Ik0xMjIuMjI5LDUzNS40MnYtODQuMzc2aDMxLjgyOGM1LjYwMiwwLDkuODc5LDAuMjY5LDEyLjgzNSwwLjgwNmM0LjE0NCwwLjY5LDcuNjE2LDIuMDA2LDEwLjQxNywzLjk0Mg0KCQkJYzIuOCwxLjkzOCw1LjA1NSw0LjY1Myw2Ljc2Myw4LjE0NWMxLjcwNywzLjQ5MiwyLjU2MSw3LjMyOSwyLjU2MSwxMS41MTFjMCw3LjE3Ni0yLjI4MywxMy4yNDgtNi44NDksMTguMjE3DQoJCQljLTQuNTY2LDQuOTY5LTEyLjgxNiw3LjQ1My0yNC43NDksNy40NTNoLTIxLjY0MXYzNC4zMDNIMTIyLjIyOXogTTEzMy4zOTUsNDkxLjE2aDIxLjgxM2M3LjIxMywwLDEyLjMzNi0xLjM0MywxNS4zNjctNC4wMjkNCgkJCWMzLjAzMS0yLjY4Niw0LjU0Ny02LjQ2NSw0LjU0Ny0xMS4zMzhjMC0zLjUzLTAuODkyLTYuNTUyLTIuNjc2LTkuMDY1Yy0xLjc4NC0yLjUxMy00LjEzNS00LjE3My03LjA1LTQuOTc5DQoJCQljLTEuODgtMC40OTgtNS4zNTMtMC43NDgtMTAuNDE3LTAuNzQ4aC0yMS41ODNWNDkxLjE2eiIvPg0KCQk8cGF0aCBjbGFzcz0ic3R5bGUwIiBkPSJNMjY4LjI0Nyw1MjQuNzE1YzQuMTgyLDIuOTkyLDguNzI5LDUuMzcyLDEzLjY0MSw3LjEzN2wtNi4yNzMsMTIuMDI5DQoJCQljLTIuNTcxLTAuNzY5LTUuMDg0LTEuODIzLTcuNTQtMy4xNjZjLTAuNTM4LTAuMjY5LTQuMzE3LTIuNzYzLTExLjMzOC03LjQ4MmMtNS41MjUsMi40MTgtMTEuNjQ2LDMuNjI2LTE4LjM2LDMuNjI2DQoJCQljLTEyLjk3LDAtMjMuMTI4LTMuODE3LTMwLjQ3Ni0xMS40NTNjLTcuMzQ4LTcuNjM1LTExLjAyMS0xOC4zNi0xMS4wMjEtMzIuMTc0YzAtMTMuNzc0LDMuNjg0LTI0LjQ4OSwxMS4wNS0zMi4xNDUNCgkJCWM3LjM2Ny03LjY1NCwxNy4zNjItMTEuNDgxLDI5Ljk4Ni0xMS40ODFjMTIuNTA4LDAsMjIuNDI3LDMuODI3LDI5Ljc1NiwxMS40ODFjNy4zMjgsNy42NTUsMTAuOTkzLDE4LjM3LDEwLjk5MywzMi4xNDUNCgkJCWMwLDcuMjkxLTEuMDE3LDEzLjY5OC0zLjA1LDE5LjIyNEMyNzQuMDc5LDUxNi42NzcsMjcxLjYyMyw1MjAuNzYzLDI2OC4yNDcsNTI0LjcxNXogTTI1NC41NDksNTE1LjEwMw0KCQkJYzIuMTg3LTIuNTY5LDMuODI3LTUuNjc4LDQuOTIxLTkuMzIzYzEuMDkzLTMuNjQ2LDEuNjQtNy44MjgsMS42NC0xMi41NDhjMC05Ljc0NS0yLjE0OS0xNy4wMjYtNi40NDYtMjEuODQyDQoJCQljLTQuMjk3LTQuODE0LTkuOTE5LTcuMjIzLTE2Ljg2My03LjIyM2MtNi45NDUsMC0xMi41NzYsMi40MTctMTYuODkzLDcuMjUyYy00LjMxNyw0LjgzNC02LjQ3NSwxMi4xMDUtNi40NzUsMjEuODEzDQoJCQljMCw5Ljg2MiwyLjE1OCwxNy4yMzgsNi40NzUsMjIuMTMxYzQuMzE2LDQuODkyLDkuNzc0LDcuMzM4LDE2LjM3NSw3LjMzOGMyLjQ1NSwwLDQuNzc3LTAuNDAzLDYuOTY0LTEuMjA5DQoJCQljLTMuNDUzLTIuMjY0LTYuOTY0LTQuMDI4LTEwLjUzMi01LjI5NWw0Ljc3Ny05LjcyN0MyNDQuMDkyLDUwOC4zODksMjQ5LjQ0NSw1MTEuMjY3LDI1NC41NDksNTE1LjEwM3oiLz4NCgkJPHBhdGggY2xhc3M9InN0eWxlMCIgZD0iTTI5MS45MDIsNDUxLjA0NGgxNy4wMzd2NDUuNjk5YzAsNy4yNTIsMC4yMSwxMS45NTIsMC42MzMsMTQuMTAxYzAuNzI5LDMuNDUzLDIuNDY2LDYuMjI2LDUuMjA5LDguMzE2DQoJCQljMi43NDMsMi4wOTIsNi40OTQsMy4xMzcsMTEuMjUzLDMuMTM3YzQuODM0LDAsOC40NzktMC45ODcsMTAuOTM2LTIuOTY0YzIuNDU1LTEuOTc2LDMuOTMzLTQuNDAyLDQuNDMyLTcuMjgNCgkJCWMwLjQ5OC0yLjg3OCwwLjc0OC03LjY1NSwwLjc0OC0xNC4zMzF2LTQ2LjY3OGgxNy4wMzZ2NDQuMzE3YzAsMTAuMTMtMC40NiwxNy4yODYtMS4zODEsMjEuNDY4DQoJCQljLTAuOTIxLDQuMTg0LTIuNjE5LDcuNzEzLTUuMDk0LDEwLjU5MWMtMi40NzYsMi44NzgtNS43ODQsNS4xNzEtOS45MjksNi44NzhjLTQuMTQ0LDEuNzA3LTkuNTU0LDIuNTYxLTE2LjIzLDIuNTYxDQoJCQljLTguMDU4LDAtMTQuMTY5LTAuOTMxLTE4LjMzMi0yLjc5MWMtNC4xNjQtMS44Ni03LjQ1My00LjI3OC05Ljg3MS03LjI1MmMtMi40MTctMi45NzMtNC4wMS02LjA5MS00Ljc3Ny05LjM1Mw0KCQkJYy0xLjExMy00LjgzNS0xLjY2OS0xMS45NzItMS42NjktMjEuNDExVjQ1MS4wNDR6Ii8+DQoJCTxwYXRoIGNsYXNzPSJzdHlsZTAiIGQ9Ik00NTMuMjMsNTM1LjQyaC0xOC41MzNsLTcuMzY3LTE5LjE2NmgtMzMuNzI4bC02Ljk2NCwxOS4xNjZoLTE4LjA3MmwzMi44NjQtODQuMzc2aDE4LjAxNUw0NTMuMjMsNTM1LjQyeg0KCQkJIE00MjEuODYyLDUwMi4wMzhsLTExLjYyNi0zMS4zMTFsLTExLjM5NiwzMS4zMTFINDIxLjg2MnoiLz4NCgkJPHBhdGggY2xhc3M9InN0eWxlMCIgZD0iTTQ2Mi4yMDksNDUxLjA0NGgzMS4xMzdjNy4wMjIsMCwxMi4zNzUsMC41MzgsMTYuMDU5LDEuNjExYzQuOTQ5LDEuNDU5LDkuMTg4LDQuMDQ5LDEyLjcyLDcuNzcxDQoJCQljMy41MjksMy43MjIsNi4yMTYsOC4yNzgsOC4wNTgsMTMuNjY5YzEuODQyLDUuMzkyLDIuNzYzLDEyLjAzOSwyLjc2MywxOS45NDNjMCw2Ljk0NS0wLjg2MywxMi45MzEtMi41OSwxNy45NTcNCgkJCWMtMi4xMTEsNi4xNC01LjEyMywxMS4xMDgtOS4wMzcsMTQuOTA2Yy0yLjk1NSwyLjg3OC02Ljk0NSw1LjEyMy0xMS45NzEsNi43MzRjLTMuNzYxLDEuMTg5LTguNzg3LDEuNzg0LTE1LjA4LDEuNzg0aC0zMi4wNTgNCgkJCVY0NTEuMDQ0eiBNNDc5LjI0NSw0NjUuMzE3djU1Ljg4N2gxMi43MmM0Ljc1NywwLDguMTkxLTAuMjY5LDEwLjMwMi0wLjgwNmMyLjc2My0wLjY5MSw1LjA1Ni0xLjg2MSw2Ljg3OC0zLjUxMg0KCQkJYzEuODIyLTEuNjQ4LDMuMzEtNC4zNjQsNC40NjEtOC4xNDRzMS43MjctOC45MywxLjcyNy0xNS40NTRjMC02LjUyMi0wLjU3NS0xMS41MjktMS43MjctMTUuMDIxDQoJCQljLTEuMTUxLTMuNDkxLTIuNzYzLTYuMjE2LTQuODM1LTguMTczYy0yLjA3MS0xLjk1Ny00LjctMy4yOC03Ljg4NS0zLjk3MmMtMi4zOC0wLjUzNi03LjA0Mi0wLjgwNi0xMy45ODYtMC44MDZINDc5LjI0NXoiLz4NCgkJPHBhdGggY2xhc3M9InN0eWxlMCIgZD0iTTU0My4wNzMsNTA3Ljk2NmwxNi41NzYtMS42MTFjMC45OTcsNS41NjQsMy4wMjEsOS42NSw2LjA3MiwxMi4yNmMzLjA1LDIuNjA5LDcuMTY1LDMuOTEzLDEyLjM0NiwzLjkxMw0KCQkJYzUuNDg2LDAsOS42Mi0xLjE2LDEyLjQwMy0zLjQ4MWMyLjc4MS0yLjMyMSw0LjE3Mi01LjAzNiw0LjE3Mi04LjE0NWMwLTEuOTk0LTAuNTg1LTMuNjkyLTEuNzU1LTUuMDk0DQoJCQljLTEuMTcxLTEuNC0zLjIxNC0yLjYxOC02LjEzLTMuNjU0Yy0xLjk5NS0wLjY5MS02LjU0Mi0xLjkxOS0xMy42NDEtMy42ODRjLTkuMTMyLTIuMjY0LTE1LjU0LTUuMDQ1LTE5LjIyNC04LjM0Ng0KCQkJYy01LjE4LTQuNjQzLTcuNzctMTAuMzAzLTcuNzctMTYuOTc5YzAtNC4yOTcsMS4yMTgtOC4zMTcsMy42NTQtMTIuMDU5YzIuNDM3LTMuNzQsNS45NDctNi41OSwxMC41MzMtOC41NDcNCgkJCWM0LjU4NC0xLjk1NywxMC4xMi0yLjkzNSwxNi42MDQtMi45MzVjMTAuNTksMCwxOC41NjIsMi4zMjEsMjMuOTE0LDYuOTY0czguMTYzLDEwLjg0LDguNDMyLDE4LjU5bC0xNy4wMzYsMC43NDkNCgkJCWMtMC43MjktNC4zMzYtMi4yOTMtNy40NTQtNC42OS05LjM1NGMtMi4zOTgtMS44OTktNS45OTYtMi44NDktMTAuNzkyLTIuODQ5Yy00Ljk0OSwwLTguODI1LDEuMDE4LTExLjYyNiwzLjA1MQ0KCQkJYy0xLjgwNCwxLjMwNS0yLjcwNSwzLjA1LTIuNzA1LDUuMjM3YzAsMS45OTUsMC44NDQsMy43MDMsMi41MzIsNS4xMjJjMi4xNDgsMS44MDUsNy4zNjcsMy42ODQsMTUuNjU1LDUuNjQxDQoJCQlzMTQuNDE4LDMuOTgxLDE4LjM4OSw2LjA3MmMzLjk3MiwyLjA5Miw3LjA3OSw0Ljk0OSw5LjMyNCw4LjU3NWMyLjI0NCwzLjYyNiwzLjM2Nyw4LjEwNiwzLjM2NywxMy40MzkNCgkJCWMwLDQuODM1LTEuMzQ0LDkuMzYyLTQuMDI5LDEzLjU4M2MtMi42ODcsNC4yMjItNi40ODQsNy4zNTgtMTEuMzk2LDkuNDFjLTQuOTEyLDIuMDUzLTExLjAzMiwzLjA3OS0xOC4zNiwzLjA3OQ0KCQkJYy0xMC42NjgsMC0xOC44NTktMi40NjUtMjQuNTc2LTcuMzk2QzU0Ny42MDEsNTI0LjU5MSw1NDQuMTg2LDUxNy40MDUsNTQzLjA3Myw1MDcuOTY2eiIvPg0KCTwvZz4NCjwvZz4NCjxnIGlkPSJFYmVuZV80X0tvcGllX3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjcyIiBoZWlnaHQ9IjI4IiBpZD0iRWJlbmVfNF9Lb3BpZV94QTBfSW1hZ2UiIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBRWdBQUFBY0NBSUFBQUJOa0c3eEFBQUFDWEJJV1hNQUFBc1NBQUFMRWdIUzNYNzhBQUFBCkdYUkZXSFJUYjJaMGQyRnlaUUJCWkc5aVpTQkpiV0ZuWlZKbFlXUjVjY2xsUEFBQUFEWkpSRUZVZU5yc3p3RU5BQUFJQXlEZlAvVE4Kb1lNR3BPMThGREV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TWJHYlZnQUJCZ0J1WTFQSkhBbElWd0FBQUFCSlJVNUVya0pnZ2c9PSIgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgMSA0IDM5MikiPg0KCTwvaW1hZ2U+DQo8L2c+DQo8ZyBpZD0iRWJlbmVfM19Lb3BpZV82X3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9Ijc2IiBoZWlnaHQ9IjEwOCIgaWQ9IkViZW5lXzNfS29waWVfNl94QTBfSW1hZ2UiIHhsaW5rOmhyZWY9ImRhdGE6aW1hZ2UvcG5nO2Jhc2U2NCxpVkJPUncwS0dnb0FBQUFOU1VoRVVnQUFBRXdBQUFCc0NBSUFBQUJQV2NOS0FBQUFDWEJJV1hNQUFBc1NBQUFMRWdIUzNYNzhBQUFBCkdYUkZXSFJUYjJaMGQyRnlaUUJCWkc5aVpTQkpiV0ZuWlZKbFlXUjVjY2xsUEFBQUFJQkpSRUZVZU5yc3p3RUJBREFJQXlDMWYrZTkKZ0FrOE5LQ1QxSFZUSDVDVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVQpsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlNVbEpTVWxKU1VsSlRjUFFFR0FPSGxBOVhxCjVpMFFBQUFBQUVsRlRrU3VRbUNDIiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAxIDIxNSAzMTIpIj4NCgk8L2ltYWdlPg0KPC9nPg0KPGcgaWQ9IkViZW5lXzNfS29waWVfN194QTBfSW1hZ2VfMV8iPg0KCQ0KCQk8aW1hZ2Ugb3ZlcmZsb3c9InZpc2libGUiIHdpZHRoPSI4MCIgaGVpZ2h0PSIxNzIiIGlkPSJFYmVuZV8zX0tvcGllXzdfeEEwX0ltYWdlIiB4bGluazpocmVmPSJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUZBQUFBQ3NDQUlBQUFCakk3eVlBQUFBQ1hCSVdYTUFBQXNTQUFBTEVnSFMzWDc4QUFBQQpHWFJGV0hSVGIyWjBkMkZ5WlFCQlpHOWlaU0JKYldGblpWSmxZV1I1Y2NsbFBBQUFBTDVKUkVGVWVOcnN6d0VCQUFBRUF6RDA3M3c5CjJCcXNrOVFuVTg4SUN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0wKQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTApDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEM5K3lBZ3dBClozMEVWVHVscE5RQUFBQUFTVVZPUks1Q1lJST0iIHRyYW5zZm9ybT0ibWF0cml4KDEgMCAwIDEgMzE5IDI0OCkiPg0KCTwvaW1hZ2U+DQo8L2c+DQo8ZyBpZD0iRWJlbmVfM19Lb3BpZV84X3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjgwIiBoZWlnaHQ9IjcyIiBpZD0iRWJlbmVfM19Lb3BpZV84X3hBMF9JbWFnZSIgeGxpbms6aHJlZj0iZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFGQUFBQUJJQ0FJQUFBRHU5dVVNQUFBQUNYQklXWE1BQUFzU0FBQUxFZ0hTM1g3OEFBQUEKR1hSRldIUlRiMlowZDJGeVpRQkJaRzlpWlNCSmJXRm5aVkpsWVdSNWNjbGxQQUFBQUdGSlJFRlVlTnJzenpFQkFBQUlBeURYUC9Rcwo0U2MwSUczbmt3Z0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMQ3dzTEN3c0xDd3NMCkN3c0xDd3NMQ3dzTEN3c0xDd3NMQzk5YkFRWUEveWJYY2Qzc1lVOEFBQUFBU1VWT1JLNUNZSUk9IiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAxIDEwNiAzNDgpIj4NCgk8L2ltYWdlPg0KPC9nPg0KPGcgaWQ9IkViZW5lXzNfS29waWVfOV94QTBfSW1hZ2VfMV8iPg0KCQ0KCQk8aW1hZ2Ugb3ZlcmZsb3c9InZpc2libGUiIHdpZHRoPSI3MiIgaGVpZ2h0PSIyODAiIGlkPSJFYmVuZV8zX0tvcGllXzlfeEEwX0ltYWdlIiB4bGluazpocmVmPSJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUVnQUFBRVlDQUlBQUFCd2RpZFRBQUFBQ1hCSVdYTUFBQXNTQUFBTEVnSFMzWDc4QUFBQQpHWFJGV0hSVGIyWjBkMkZ5WlFCQlpHOWlaU0JKYldGblpWSmxZV1I1Y2NsbFBBQUFBUWxKUkVGVWVOcnN6d0VOQUFBSUF5QzFmK2ZiCjQ0TUdiSkpwZEZOS1RFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE0KVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TQpURXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNClRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE0KVEV4TVRFeE1URXhNVEV4TVRLelJDekFBK0YwRkxVdDk2RjhBQUFBQVNVVk9SSzVDWUlJPSIgdHJhbnNmb3JtPSJtYXRyaXgoMSAwIDAgMSA0MzAgMTQwKSI+DQoJPC9pbWFnZT4NCjwvZz4NCjxnIGlkPSJFYmVuZV8zX0tvcGllXzEwX3hBMF9JbWFnZV8xXyI+DQoJDQoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjcyIiBoZWlnaHQ9IjQyMCIgaWQ9IkViZW5lXzNfS29waWVfMTBfeEEwX0ltYWdlIiB4bGluazpocmVmPSJkYXRhOmltYWdlL3BuZztiYXNlNjQsaVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUVnQUFBR2tDQUlBQUFBZGZ2UmRBQUFBQ1hCSVdYTUFBQXNTQUFBTEVnSFMzWDc4QUFBQQpHWFJGV0hSVGIyWjBkMkZ5WlFCQlpHOWlaU0JKYldGblpWSmxZV1I1Y2NsbFBBQUFBWDlKUkVGVWVOcnN6MEVSQUFBSUF5RFhQL1JzCjRjT0RCcVR0ZkJReE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXgKTVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeApNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4Ck1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXgKTVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeApNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4TVRFeE1URXhNVEV4Ck1URXhNVEV4TVRFeE1URXhNVEV4TVRHeE95dkFBRTYvNlBYS29tdGZBQUFBQUVsRlRrU3VRbUNDIiB0cmFuc2Zvcm09Im1hdHJpeCgxIDAgMCAxIDUzNiAwKSI+DQoJPC9pbWFnZT4NCjwvZz4NCjwvc3ZnPg0K
|
34 |
+
";
|
35 |
+
$quads_parent_page = add_menu_page('Quick AdSense Reloaded Settings', $label, 'manage_options', 'quads-settings', 'quads_options_page', 'data:image/svg+xml;base64,' . $wpquads_logo);
|
36 |
+
$quads_settings_page = add_submenu_page('quads-settings', __('Ad Settings', 'quick-adsense-reloaded'), 'Ad Settings', 'manage_options', 'quads-settings', 'quads_options_page');
|
37 |
+
|
38 |
+
if (!quads_is_extra()) {
|
39 |
+
$quads_add_ons_page = add_submenu_page('quads-settings', __('Get Add-On', 'quick-adsense-reloaded'), 'Get WP QUADS PRO', 'manage_options', 'quads-addons', 'quads_add_ons_page');
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
add_action( 'admin_menu', 'quads_add_options_link', 10 );
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Determines whether the current admin page is an QUADS admin page.
|
48 |
+
*
|
49 |
+
* Only works after the `wp_loaded` hook, & most effective
|
50 |
+
* starting on `admin_menu` hook.
|
51 |
+
*
|
52 |
+
* @since 1.9.6
|
53 |
+
* @return bool True if QUADS admin page.
|
54 |
+
*/
|
55 |
+
function quads_is_admin_page() {
|
56 |
+
$currentpage = isset($_GET['page']) ? $_GET['page'] : '';
|
57 |
+
if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
|
58 |
+
return false;
|
59 |
+
}
|
60 |
+
|
61 |
+
if ( 'quads-settings' == $currentpage ) {
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* Determines whether the current admin page is an QUADS add-on page.
|
67 |
+
*
|
68 |
+
* Only works after the `wp_loaded` hook, & most effective
|
69 |
+
* starting on `admin_menu` hook.
|
70 |
+
*
|
71 |
+
* @since 1.4.9
|
72 |
+
* @return bool True if QUADS admin page.
|
73 |
+
*/
|
74 |
+
function quads_is_addon_page() {
|
75 |
+
$currentpage = isset($_GET['page']) ? $_GET['page'] : '';
|
76 |
+
if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
if ( 'quads-addons' == $currentpage ) {
|
81 |
+
return true;
|
82 |
+
}
|
83 |
+
}
|
includes/admin/adsTxt.php
CHANGED
@@ -1,106 +1,106 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace wpquads;
|
4 |
-
|
5 |
-
class adsTxt {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Content to add
|
9 |
-
* @var string
|
10 |
-
*/
|
11 |
-
private $content;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Pattern to search and replace
|
15 |
-
* @var string
|
16 |
-
*/
|
17 |
-
private $pattern;
|
18 |
-
|
19 |
-
/**
|
20 |
-
*
|
21 |
-
* @param array $content to add
|
22 |
-
* @param string $pattern for content to remove
|
23 |
-
*/
|
24 |
-
public function __construct($content = array(), $pattern = '') {
|
25 |
-
$this->content = $content;
|
26 |
-
|
27 |
-
$this->pattern = $pattern;
|
28 |
-
|
29 |
-
$this->filename = ABSPATH . 'ads.txt';
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Check if we need to create an ads.txt
|
34 |
-
* @return boolean
|
35 |
-
*/
|
36 |
-
public function needsAdsTxt(){
|
37 |
-
if (!is_file($this->filename)){
|
38 |
-
return true;
|
39 |
-
}
|
40 |
-
|
41 |
-
// get everything from ads.txt and convert to array
|
42 |
-
$contentText = file_get_contents($this->filename);
|
43 |
-
|
44 |
-
// Pattern not find
|
45 |
-
if (strpos($contentText, $this->pattern) === false) {
|
46 |
-
return true;
|
47 |
-
} else {
|
48 |
-
return false;
|
49 |
-
}
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Write ads.txt
|
55 |
-
* @return bool
|
56 |
-
*/
|
57 |
-
public function writeAdsTxt() {
|
58 |
-
if (false !== file_put_contents($this->filename, $this->getContent())) {
|
59 |
-
// show notice that ads.txt has been created
|
60 |
-
set_transient('quads_vi_ads_txt_notice', true, 300);
|
61 |
-
return true;
|
62 |
-
}
|
63 |
-
// show error admin notice
|
64 |
-
set_transient('quads_vi_ads_txt_error', true, 300);
|
65 |
-
return false;
|
66 |
-
}
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Create and return the content
|
72 |
-
* @return string
|
73 |
-
*/
|
74 |
-
public function getContent() {
|
75 |
-
// ads.txt does not exists
|
76 |
-
if (!is_file($this->filename)) {
|
77 |
-
return $this->content . "\r\n";
|
78 |
-
}
|
79 |
-
|
80 |
-
// get everything from ads.txt and convert to array
|
81 |
-
$contentText = file_get_contents($this->filename);
|
82 |
-
|
83 |
-
// Change all \r\n to \n
|
84 |
-
//$contentText = str_replace(array("\r\n", "\n"), '', $contentText);
|
85 |
-
|
86 |
-
//$content = array_filter(explode("\n", trim($contentText)), 'trim');
|
87 |
-
$content = explode("\n", $contentText);
|
88 |
-
|
89 |
-
// Pattern not find so append new content to ads.txt existing content
|
90 |
-
if (strpos($contentText, $this->pattern) === false) {
|
91 |
-
return $contentText . "\r\n" . $this->content;
|
92 |
-
}
|
93 |
-
|
94 |
-
// Pattern found, so remove everything first and add new stuff from api response
|
95 |
-
$newContent = '';
|
96 |
-
foreach ($content as $entry) {
|
97 |
-
if (strpos($entry, $this->pattern) !== false) {
|
98 |
-
continue;
|
99 |
-
}
|
100 |
-
$newContent .= str_replace(array("\r", "\n"), '', $entry) . "\r\n";
|
101 |
-
|
102 |
-
}
|
103 |
-
return $newContent . $this->content;
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace wpquads;
|
4 |
+
|
5 |
+
class adsTxt {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Content to add
|
9 |
+
* @var string
|
10 |
+
*/
|
11 |
+
private $content;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Pattern to search and replace
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
private $pattern;
|
18 |
+
|
19 |
+
/**
|
20 |
+
*
|
21 |
+
* @param array $content to add
|
22 |
+
* @param string $pattern for content to remove
|
23 |
+
*/
|
24 |
+
public function __construct($content = array(), $pattern = '') {
|
25 |
+
$this->content = $content;
|
26 |
+
|
27 |
+
$this->pattern = $pattern;
|
28 |
+
|
29 |
+
$this->filename = ABSPATH . 'ads.txt';
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Check if we need to create an ads.txt
|
34 |
+
* @return boolean
|
35 |
+
*/
|
36 |
+
public function needsAdsTxt(){
|
37 |
+
if (!is_file($this->filename)){
|
38 |
+
return true;
|
39 |
+
}
|
40 |
+
|
41 |
+
// get everything from ads.txt and convert to array
|
42 |
+
$contentText = file_get_contents($this->filename);
|
43 |
+
|
44 |
+
// Pattern not find
|
45 |
+
if (strpos($contentText, $this->pattern) === false) {
|
46 |
+
return true;
|
47 |
+
} else {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Write ads.txt
|
55 |
+
* @return bool
|
56 |
+
*/
|
57 |
+
public function writeAdsTxt() {
|
58 |
+
if (false !== file_put_contents($this->filename, $this->getContent())) {
|
59 |
+
// show notice that ads.txt has been created
|
60 |
+
set_transient('quads_vi_ads_txt_notice', true, 300);
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
// show error admin notice
|
64 |
+
set_transient('quads_vi_ads_txt_error', true, 300);
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Create and return the content
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function getContent() {
|
75 |
+
// ads.txt does not exists
|
76 |
+
if (!is_file($this->filename)) {
|
77 |
+
return $this->content . "\r\n";
|
78 |
+
}
|
79 |
+
|
80 |
+
// get everything from ads.txt and convert to array
|
81 |
+
$contentText = file_get_contents($this->filename);
|
82 |
+
|
83 |
+
// Change all \r\n to \n
|
84 |
+
//$contentText = str_replace(array("\r\n", "\n"), '', $contentText);
|
85 |
+
|
86 |
+
//$content = array_filter(explode("\n", trim($contentText)), 'trim');
|
87 |
+
$content = explode("\n", $contentText);
|
88 |
+
|
89 |
+
// Pattern not find so append new content to ads.txt existing content
|
90 |
+
if (strpos($contentText, $this->pattern) === false) {
|
91 |
+
return $contentText . "\r\n" . $this->content;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Pattern found, so remove everything first and add new stuff from api response
|
95 |
+
$newContent = '';
|
96 |
+
foreach ($content as $entry) {
|
97 |
+
if (strpos($entry, $this->pattern) !== false) {
|
98 |
+
continue;
|
99 |
+
}
|
100 |
+
$newContent .= str_replace(array("\r", "\n"), '', $entry) . "\r\n";
|
101 |
+
|
102 |
+
}
|
103 |
+
return $newContent . $this->content;
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
includes/admin/plugins.php
CHANGED
@@ -1,62 +1,62 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin Plugins
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Plugins
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 2.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
|
13 |
-
// Exit if accessed directly
|
14 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
-
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Plugins row action links
|
19 |
-
*
|
20 |
-
* @author Michael Cannon <mc@aihr.us>
|
21 |
-
* @since 2.0
|
22 |
-
* @param array $links already defined action links
|
23 |
-
* @param string $file plugin file path and name being processed
|
24 |
-
* @return array $links
|
25 |
-
*/
|
26 |
-
function quads_plugin_action_links( $links, $file ) {
|
27 |
-
$settings_link = '<a href="' . admin_url( 'options-general.php?page=quads-settings' ) . '">' . esc_html__( 'General Settings', 'quick-adsense-reloaded' ) . '</a>';
|
28 |
-
|
29 |
-
if ( $file == 'quick-adsense-reloaded/quick-adsense-reloaded.php' || $file == 'quads-pro/wpquads-pro.php' ){
|
30 |
-
array_unshift( $links, $settings_link );
|
31 |
-
}
|
32 |
-
|
33 |
-
return $links;
|
34 |
-
}
|
35 |
-
add_filter( 'plugin_action_links', 'quads_plugin_action_links', 10, 2 );
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Plugin row meta links
|
41 |
-
*
|
42 |
-
* @author Michael Cannon <mc@aihr.us>
|
43 |
-
* @since 0.0.9
|
44 |
-
* @param array $input already defined meta links
|
45 |
-
* @param string $file plugin file path and name being processed
|
46 |
-
* @return array $input
|
47 |
-
*/
|
48 |
-
//function quads_plugin_row_meta( $input, $file ) {
|
49 |
-
// if ( $file != 'quick-adsense-reloaded/quick-adsense-reloaded.php' && $file != 'quads-pro/wpquads-pro.php' ){
|
50 |
-
// return $input;
|
51 |
-
// }
|
52 |
-
//
|
53 |
-
// $links = array(
|
54 |
-
// '<a href="' . admin_url( 'options-general.php?page=quads-settings' ) . '">' . esc_html__( 'Getting Started', 'quick-adsense-reloaded' ) . '</a>',
|
55 |
-
// );
|
56 |
-
//
|
57 |
-
//
|
58 |
-
// $input = array_merge( $input, $links );
|
59 |
-
//
|
60 |
-
// return $input;
|
61 |
-
//}
|
62 |
//add_filter( 'plugin_row_meta', 'quads_plugin_row_meta', 10, 2 );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Plugins
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Plugins
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 2.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
// Exit if accessed directly
|
14 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
+
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Plugins row action links
|
19 |
+
*
|
20 |
+
* @author Michael Cannon <mc@aihr.us>
|
21 |
+
* @since 2.0
|
22 |
+
* @param array $links already defined action links
|
23 |
+
* @param string $file plugin file path and name being processed
|
24 |
+
* @return array $links
|
25 |
+
*/
|
26 |
+
function quads_plugin_action_links( $links, $file ) {
|
27 |
+
$settings_link = '<a href="' . admin_url( 'options-general.php?page=quads-settings' ) . '">' . esc_html__( 'General Settings', 'quick-adsense-reloaded' ) . '</a>';
|
28 |
+
|
29 |
+
if ( $file == 'quick-adsense-reloaded/quick-adsense-reloaded.php' || $file == 'quads-pro/wpquads-pro.php' ){
|
30 |
+
array_unshift( $links, $settings_link );
|
31 |
+
}
|
32 |
+
|
33 |
+
return $links;
|
34 |
+
}
|
35 |
+
add_filter( 'plugin_action_links', 'quads_plugin_action_links', 10, 2 );
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Plugin row meta links
|
41 |
+
*
|
42 |
+
* @author Michael Cannon <mc@aihr.us>
|
43 |
+
* @since 0.0.9
|
44 |
+
* @param array $input already defined meta links
|
45 |
+
* @param string $file plugin file path and name being processed
|
46 |
+
* @return array $input
|
47 |
+
*/
|
48 |
+
//function quads_plugin_row_meta( $input, $file ) {
|
49 |
+
// if ( $file != 'quick-adsense-reloaded/quick-adsense-reloaded.php' && $file != 'quads-pro/wpquads-pro.php' ){
|
50 |
+
// return $input;
|
51 |
+
// }
|
52 |
+
//
|
53 |
+
// $links = array(
|
54 |
+
// '<a href="' . admin_url( 'options-general.php?page=quads-settings' ) . '">' . esc_html__( 'Getting Started', 'quick-adsense-reloaded' ) . '</a>',
|
55 |
+
// );
|
56 |
+
//
|
57 |
+
//
|
58 |
+
// $input = array_merge( $input, $links );
|
59 |
+
//
|
60 |
+
// return $input;
|
61 |
+
//}
|
62 |
//add_filter( 'plugin_row_meta', 'quads_plugin_row_meta', 10, 2 );
|
includes/admin/settings/contextual-help.php
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Contextual Help
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Settings
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 0.9.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly
|
13 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Settings contextual help.
|
17 |
-
*
|
18 |
-
* @access private
|
19 |
-
* @since 1.0
|
20 |
-
* @return void
|
21 |
-
*/
|
22 |
-
function quads_settings_contextual_help() {
|
23 |
-
$screen = get_current_screen();
|
24 |
-
|
25 |
-
/*if ( $screen->id != 'quads-settings' )
|
26 |
-
return;
|
27 |
-
*/
|
28 |
-
$screen->set_help_sidebar(
|
29 |
-
'<p><strong>' . $screen->id . sprintf( __( 'For more information:', 'quick-adsense-reloaded' ) . '</strong></p>' .
|
30 |
-
'<p>' . sprintf( __( 'Visit the <a href="%s">documentation</a> on the Quick AdSense Reloaded website.', 'quick-adsense-reloaded' ), esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ) ) ) . '</p>' .
|
31 |
-
'<p>' . sprintf(
|
32 |
-
__( '<a href="%s">Post an issue</a> on <a href="%s">Quick AdSense Reloaded</a>. View <a href="%s">extensions</a>.', 'quick-adsense-reloaded' ),
|
33 |
-
esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ),
|
34 |
-
esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ),
|
35 |
-
esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' )
|
36 |
-
) . '</p>'
|
37 |
-
);
|
38 |
-
|
39 |
-
$screen->add_help_tab( array(
|
40 |
-
'id' => 'quads-settings-general',
|
41 |
-
'title' => __( 'General', 'quick-adsense-reloaded' ),
|
42 |
-
'content' => '<p>' . __( 'This screen provides the most basic settings for configuring Quick AdSense Reloaded.', 'quick-adsense-reloaded' ) . '</p>'
|
43 |
-
) );
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
do_action( 'quads_settings_contextual_help', $screen );
|
49 |
-
}
|
50 |
-
add_action( 'load-quads-settings', 'quads_settings_contextual_help' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Contextual Help
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Settings
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 0.9.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Settings contextual help.
|
17 |
+
*
|
18 |
+
* @access private
|
19 |
+
* @since 1.0
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
function quads_settings_contextual_help() {
|
23 |
+
$screen = get_current_screen();
|
24 |
+
|
25 |
+
/*if ( $screen->id != 'quads-settings' )
|
26 |
+
return;
|
27 |
+
*/
|
28 |
+
$screen->set_help_sidebar(
|
29 |
+
'<p><strong>' . $screen->id . sprintf( __( 'For more information:', 'quick-adsense-reloaded' ) . '</strong></p>' .
|
30 |
+
'<p>' . sprintf( __( 'Visit the <a href="%s">documentation</a> on the Quick AdSense Reloaded website.', 'quick-adsense-reloaded' ), esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ) ) ) . '</p>' .
|
31 |
+
'<p>' . sprintf(
|
32 |
+
__( '<a href="%s">Post an issue</a> on <a href="%s">Quick AdSense Reloaded</a>. View <a href="%s">extensions</a>.', 'quick-adsense-reloaded' ),
|
33 |
+
esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ),
|
34 |
+
esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ),
|
35 |
+
esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' )
|
36 |
+
) . '</p>'
|
37 |
+
);
|
38 |
+
|
39 |
+
$screen->add_help_tab( array(
|
40 |
+
'id' => 'quads-settings-general',
|
41 |
+
'title' => __( 'General', 'quick-adsense-reloaded' ),
|
42 |
+
'content' => '<p>' . __( 'This screen provides the most basic settings for configuring Quick AdSense Reloaded.', 'quick-adsense-reloaded' ) . '</p>'
|
43 |
+
) );
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
|
48 |
+
do_action( 'quads_settings_contextual_help', $screen );
|
49 |
+
}
|
50 |
+
add_action( 'load-quads-settings', 'quads_settings_contextual_help' );
|
includes/admin/settings/display-settings.php
CHANGED
@@ -1,354 +1,354 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin Options Page
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Settings
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 1.0
|
10 |
-
*/
|
11 |
-
|
12 |
-
// Exit if accessed directly
|
13 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
-
|
15 |
-
/* Returns list elements for jQuery tab navigation
|
16 |
-
* based on header callback
|
17 |
-
*
|
18 |
-
* @since 2.1.2
|
19 |
-
* @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be much faster?
|
20 |
-
* @return string
|
21 |
-
*/
|
22 |
-
|
23 |
-
function quads_get_tab_header($page, $section){
|
24 |
-
global $quads_options;
|
25 |
-
global $wp_settings_fields;
|
26 |
-
|
27 |
-
if (!isset($wp_settings_fields[$page][$section]))
|
28 |
-
return;
|
29 |
-
|
30 |
-
echo '<ul>';
|
31 |
-
foreach ((array) $wp_settings_fields[$page][$section] as $field) {
|
32 |
-
$sanitizedID = str_replace('[', '', $field['id'] );
|
33 |
-
$sanitizedID = str_replace(']', '', $sanitizedID );
|
34 |
-
if ( strpos($field['callback'],'header') !== false && !quads_is_excluded(array('help', 'licenses') ) ) {
|
35 |
-
echo '<li class="quads-tabs"><a href="#' . $sanitizedID . '">' . $field['title'] .'</a></li>';
|
36 |
-
}
|
37 |
-
}
|
38 |
-
echo '</ul>';
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Check if current page is excluded
|
43 |
-
*
|
44 |
-
* @param array $pages
|
45 |
-
* @return boolean
|
46 |
-
*/
|
47 |
-
function quads_is_excluded($pages){
|
48 |
-
if (isset($_GET['tab'])){
|
49 |
-
$currentpage = $_GET['tab'];
|
50 |
-
if (isset($currentpage) && in_array($currentpage, $pages))
|
51 |
-
return true;
|
52 |
-
}
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Print out the settings fields for a particular settings section
|
57 |
-
*
|
58 |
-
* Part of the Settings API. Use this in a settings page to output
|
59 |
-
* a specific section. Should normally be called by do_settings_sections()
|
60 |
-
* rather than directly.
|
61 |
-
*
|
62 |
-
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
|
63 |
-
* @return string
|
64 |
-
*
|
65 |
-
* @since 2.1.2
|
66 |
-
*
|
67 |
-
* @param string $page Slug title of the admin page who's settings fields you want to show.
|
68 |
-
* @param section $section Slug title of the settings section who's fields you want to show.
|
69 |
-
*
|
70 |
-
* Copied from WP Core 4.0 /wp-admin/includes/template.php do_settings_fields()
|
71 |
-
* We use our own function to be able to create jQuery tabs with easytabs()
|
72 |
-
*
|
73 |
-
* We dont use tables here any longer. Are we stuck in the nineties?
|
74 |
-
* @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be faster?
|
75 |
-
* @todo some media queries for better responisbility
|
76 |
-
*/
|
77 |
-
function quads_do_settings_fields($page, $section) {
|
78 |
-
global $wp_settings_fields;
|
79 |
-
$header = false;
|
80 |
-
$firstHeader = false;
|
81 |
-
|
82 |
-
if (!isset($wp_settings_fields[$page][$section]))
|
83 |
-
return;
|
84 |
-
|
85 |
-
// Check first if any callback header registered
|
86 |
-
foreach ((array) $wp_settings_fields[$page][$section] as $field) {
|
87 |
-
strpos($field['callback'],'header') !== false ? $header = true : $header = false;
|
88 |
-
|
89 |
-
if ($header === true)
|
90 |
-
break;
|
91 |
-
}
|
92 |
-
|
93 |
-
foreach ((array) $wp_settings_fields[$page][$section] as $field) {
|
94 |
-
|
95 |
-
$sanitizedID = str_replace('[', '', $field['id'] );
|
96 |
-
$sanitizedID = str_replace(']', '', $sanitizedID );
|
97 |
-
|
98 |
-
// Check if header has been created previously
|
99 |
-
if (strpos($field['callback'],'header') !== false && $firstHeader === false) {
|
100 |
-
|
101 |
-
echo '<div id="' . $sanitizedID . '">';
|
102 |
-
echo '<table class="quads-form-table"><tbody>';
|
103 |
-
$firstHeader = true;
|
104 |
-
|
105 |
-
} elseif (strpos($field['callback'],'header') !== false && $firstHeader === true) {
|
106 |
-
// Header has been created previously so we have to close the first opened div
|
107 |
-
echo '</table></div><div id="' . $sanitizedID . '">';
|
108 |
-
echo '<table class="quads-form-table"><tbody>';
|
109 |
-
}
|
110 |
-
|
111 |
-
if (!empty($field['args']['label_for']) && !quads_is_excluded_title( $field['args']['id'] )){
|
112 |
-
echo '<tr class="quads-row">';
|
113 |
-
echo '<td class="quads-row th">';
|
114 |
-
echo '<label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label>';
|
115 |
-
echo '</td></tr>';
|
116 |
-
}else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) && !empty($field['args']['helper-desc'])){
|
117 |
-
echo '<tr class="quads-row">';
|
118 |
-
echo '<td class="quads-row th">';
|
119 |
-
echo '<div class="col-title">' . $field['title'] . '<a class="quads-general-helper" href="#"></a><div class="quads-message">' . $field['args']['helper-desc']. '</div></div>';
|
120 |
-
echo '</td></tr>';
|
121 |
-
}else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) ){
|
122 |
-
echo '<tr class="quads-row">';
|
123 |
-
echo '<td class="quads-row th">';
|
124 |
-
echo '<div class="col-title">' . $field['title'] . '</div>';
|
125 |
-
echo '</td></tr>';
|
126 |
-
}
|
127 |
-
|
128 |
-
else {
|
129 |
-
echo '';
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
echo '<tr><td>';
|
134 |
-
call_user_func($field['callback'], $field['args']);
|
135 |
-
echo '</td></tr>';
|
136 |
-
}
|
137 |
-
echo '</tbody></table>';
|
138 |
-
if ($header === true){
|
139 |
-
echo '</div>';
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* If title is one of these entries do not show it
|
145 |
-
*/
|
146 |
-
function quads_is_excluded_title($string){
|
147 |
-
$haystack = array('ad1','ad2','ad3','ad4','ad5','ad6','ad7','ad8','ad9','ad10',
|
148 |
-
'ad1_widget',
|
149 |
-
'ad2_widget',
|
150 |
-
'ad3_widget',
|
151 |
-
'ad4_widget',
|
152 |
-
'ad5_widget',
|
153 |
-
'ad6_widget',
|
154 |
-
'ad7_widget',
|
155 |
-
'ad8_widget',
|
156 |
-
'ad9_widget',
|
157 |
-
'ad10_widget',
|
158 |
-
'vi_header',
|
159 |
-
'vi_signup'
|
160 |
-
);
|
161 |
-
|
162 |
-
if (in_array($string, $haystack)){
|
163 |
-
return true;
|
164 |
-
}
|
165 |
-
return false;
|
166 |
-
}
|
167 |
-
|
168 |
-
/**
|
169 |
-
* Options Page
|
170 |
-
*
|
171 |
-
* Renders the options page contents.
|
172 |
-
*
|
173 |
-
* @since 1.0
|
174 |
-
* @global $quads_options Array of all the QUADS Options
|
175 |
-
* @return void
|
176 |
-
*/
|
177 |
-
function quads_options_page() {
|
178 |
-
global $quads_options;
|
179 |
-
|
180 |
-
$active_tab = isset( $_GET[ 'tab' ] ) && array_key_exists( $_GET['tab'], quads_get_settings_tabs() ) ? $_GET[ 'tab' ] : 'general';
|
181 |
-
|
182 |
-
ob_start();
|
183 |
-
?>
|
184 |
-
<div class="wrap quads_admin">
|
185 |
-
<h1 style="text-align:center;"> <?php echo QUADS_NAME . ' ' . QUADS_VERSION; ?></h1>
|
186 |
-
<div class="about-text" style="font-weight: 400;line-height: 1.6em;text-align:center;">
|
187 |
-
<div class='quads-share-button-container'>
|
188 |
-
<div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
189 |
-
<div clas='box'>
|
190 |
-
<a href="https://twitter.com/share?url=http://wpquads.com&text=WPQUADS+-+The quickest+and+most+easiest+way+to+integrate+AdSense+into+WordPress+websites+@wpquads" target='_blank'>
|
191 |
-
<span class='quads-share'><?php echo __('Shout out a tweet','quick-adsense-reloaded'); ?></span>
|
192 |
-
</a>
|
193 |
-
</div>
|
194 |
-
</div>
|
195 |
-
<div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
196 |
-
<div class="box">
|
197 |
-
<a href="https://www.facebook.com/sharer/sharer.php?u=http://wpquads.com" target="_blank">
|
198 |
-
<span class='quads-share'><?php echo __('Share on Facebook','quick-adsense-reloaded'); ?></span>
|
199 |
-
</a>
|
200 |
-
</div>
|
201 |
-
</div>
|
202 |
-
</div>
|
203 |
-
</div>
|
204 |
-
<h2 class="nav-tab-wrapper">
|
205 |
-
<?php
|
206 |
-
foreach( quads_get_settings_tabs() as $tab_id => $tab_name ) {
|
207 |
-
|
208 |
-
$tab_url = esc_url(add_query_arg( array(
|
209 |
-
'settings-updated' => false,
|
210 |
-
'tab' => $tab_id
|
211 |
-
) ));
|
212 |
-
|
213 |
-
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
|
214 |
-
|
215 |
-
echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
|
216 |
-
echo esc_html( $tab_name );
|
217 |
-
echo '</a>';
|
218 |
-
}
|
219 |
-
?>
|
220 |
-
</h2>
|
221 |
-
<div id="quads_tab_container" class="quads_tab_container">
|
222 |
-
<?php quads_get_tab_header( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab ); ?>
|
223 |
-
<div class="quads-panel-container"> <!-- new //-->
|
224 |
-
<form method="post" action="options.php" id="quads_settings">
|
225 |
-
|
226 |
-
<?php
|
227 |
-
settings_fields( 'quads_settings' );
|
228 |
-
quads_do_settings_fields( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab );
|
229 |
-
?>
|
230 |
-
<?php settings_errors(); ?>
|
231 |
-
<?php
|
232 |
-
// do not show save button on add-on page
|
233 |
-
if ($active_tab !== 'addons' && $active_tab !== 'imexport' && $active_tab !== 'help'){
|
234 |
-
$other_attributes = array( 'id' => 'quads-submit-button' );
|
235 |
-
submit_button(null, 'primary', 'quads-save-settings' , true, $other_attributes );
|
236 |
-
if ($active_tab !== 'licenses'){
|
237 |
-
?>
|
238 |
-
<!--<a href="<?php //echo admin_url() . '/admin.php?page=quads-settings&quads-action=validate'; ?> " id="quads-validate"><?php //_e('Validate Ad Settings','quick-adsense-reloaded')?></a>//-->
|
239 |
-
<?php
|
240 |
-
}
|
241 |
-
|
242 |
-
}
|
243 |
-
?>
|
244 |
-
</form>
|
245 |
-
<div id="quads-footer">
|
246 |
-
<?php
|
247 |
-
|
248 |
-
if ($active_tab !== 'addons' && $active_tab !== 'licenses'){
|
249 |
-
echo sprintf( __( '<strong>If you like this plugin please do us a BIG favor and give us a 5 star rating <a href="%s" target="_blank">here</a> . If you have issues, open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
|
250 |
-
'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/#new-post',
|
251 |
-
'http://wpquads.com/support/'
|
252 |
-
);
|
253 |
-
echo '<br/><br/>' . sprintf( __( '<strong>Ads are not showing? Read the <a href="%s" target="_blank">troubleshooting guide</a> to find out how to resolve it.<p> Looking for a quick way to clone your WordPress? Try the free plugin <a href="%s" target="_blank">WP Staging</a>.', 'quick-adsense-reloaded' ),
|
254 |
-
'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=bottomlink',
|
255 |
-
'https://wp-staging.com/?utm_source=wpquads_plugin&utm_campaign=footer&utm_medium=website&utm_term=bottomlink'
|
256 |
-
);
|
257 |
-
}
|
258 |
-
?>
|
259 |
-
</div>
|
260 |
-
</div> <!-- new //-->
|
261 |
-
<?php quads_get_advertising(); ?>
|
262 |
-
</div><!-- #tab_container-->
|
263 |
-
<div id="quads-save-result"></div>
|
264 |
-
<div class="quads-admin-debug"><?php echo quads_get_debug_messages(); ?></div>
|
265 |
-
<?php echo quads_render_adsense_form(); ?>
|
266 |
-
</div><!-- .wrap -->
|
267 |
-
<?php
|
268 |
-
echo ob_get_clean();
|
269 |
-
}
|
270 |
-
|
271 |
-
function quads_get_debug_messages(){
|
272 |
-
global $quads_options;
|
273 |
-
|
274 |
-
if (isset($quads_options['debug_mode'])){
|
275 |
-
echo '<pre style="clear:both;">';
|
276 |
-
var_dump($quads_options);
|
277 |
-
echo '</pre>';
|
278 |
-
}
|
279 |
-
}
|
280 |
-
|
281 |
-
/**
|
282 |
-
* Render ad and return it when plugin is not pro version
|
283 |
-
* @return string
|
284 |
-
*/
|
285 |
-
function quads_get_advertising() {
|
286 |
-
|
287 |
-
if ( quads_is_extra() ){
|
288 |
-
return '';
|
289 |
-
}
|
290 |
-
ob_start();
|
291 |
-
?>
|
292 |
-
<div class="quads-panel-sidebar" style="float:left;min-width: 301px;margin-left: 1px;margin-top:0px;">
|
293 |
-
<a href="http://wpquads.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-quads&utm_campaign=wpquads" target="_blank">
|
294 |
-
<img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/quads_banner_250x521_buy.png'; ?>">
|
295 |
-
</a>
|
296 |
-
<br>
|
297 |
-
<a style="display:block;" href="http://demo.clickfraud-monitoring.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-cfm&utm_campaign=wpquads" target="_blank">
|
298 |
-
<img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/banner_250x296-cfm.png'; ?>">
|
299 |
-
</a>
|
300 |
-
</div>
|
301 |
-
<?php
|
302 |
-
echo ob_get_clean();
|
303 |
-
}
|
304 |
-
|
305 |
-
/**
|
306 |
-
* Render social buttons
|
307 |
-
*
|
308 |
-
* @return void
|
309 |
-
*/
|
310 |
-
function quads_render_social(){
|
311 |
-
ob_start()?>
|
312 |
-
|
313 |
-
<div class='quads-share-button-container'>
|
314 |
-
<div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
315 |
-
<div clas='box'>
|
316 |
-
<a href="https://twitter.com/share?url=https://wordpress.org/plugins/quick-adsense-reloaded&text=Quick%20AdSense%20reloaded%20-%20a%20brand%20new%20fork%20of%20the%20popular%20AdSense%20Plugin%20Quick%20Adsense!" target='_blank'>
|
317 |
-
<span class='quads-share'><?php echo __('Tweet','quick-adsense-reloaded'); ?></span>
|
318 |
-
</a>
|
319 |
-
</div>
|
320 |
-
</div>
|
321 |
-
|
322 |
-
<div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
323 |
-
<div class="box">
|
324 |
-
<a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/quick-adsense-reloaded" target="_blank">
|
325 |
-
<span class='quads-share'><?php echo __('Share','quick-adsense-reloaded'); ?></span>
|
326 |
-
</a>
|
327 |
-
</div>
|
328 |
-
</div>
|
329 |
-
</div>
|
330 |
-
|
331 |
-
<?php
|
332 |
-
echo ob_get_clean();
|
333 |
-
}
|
334 |
-
|
335 |
-
|
336 |
-
/**
|
337 |
-
* Render AdSense Form
|
338 |
-
*/
|
339 |
-
function quads_render_adsense_form(){
|
340 |
-
|
341 |
-
?>
|
342 |
-
<div id="quads-adsense-bg-div" style="display: none;">
|
343 |
-
<div id="quads-adsense-container">
|
344 |
-
<h3><?php _e( 'Enter <a ahref="https://wpquads.com/docs/how-to-create-and-where-to-get-adsense-code/" target="_blank">AdSense text & display ad code</a> here', 'quick-adsense-reloaded' ); ?></h3>
|
345 |
-
<?php _e('Do not enter <a href="https://wpquads.com/docs/integrate-page-level-ads-wordpress/" target="_blank">AdSense page level ads</a> or <a href="https://wpquads.com/introducing-new-adsense-auto-ads/" target="_blank">Auto ads!</a> <br> <a href="https://wpquads.com/docs/how-to-create-and-where-to-get-adsense-code/" target="_blank">Learn how to create AdSense ad code</a>', 'quick-adsense-reloaded'); ?>
|
346 |
-
<textarea rows="15" cols="55" id="quads-adsense-form"></textarea><hr />
|
347 |
-
<button class="button button-primary" id="quads-paste-button"><?php _e( 'Get Code', 'quick-adsense-reloaded' ); ?></button>
|
348 |
-
<button class="button button-secondary" id="quads-close-button"><?php _e( 'Close', 'quick-adsense-reloaded' ); ?></button>
|
349 |
-
<div id="quads-msg"></div>
|
350 |
-
<input type="hidden" id="quads-adsense-id" value="">
|
351 |
-
</div>
|
352 |
-
</div>
|
353 |
-
<?php
|
354 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin Options Page
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Settings
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 1.0
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
/* Returns list elements for jQuery tab navigation
|
16 |
+
* based on header callback
|
17 |
+
*
|
18 |
+
* @since 2.1.2
|
19 |
+
* @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be much faster?
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
|
23 |
+
function quads_get_tab_header($page, $section){
|
24 |
+
global $quads_options;
|
25 |
+
global $wp_settings_fields;
|
26 |
+
|
27 |
+
if (!isset($wp_settings_fields[$page][$section]))
|
28 |
+
return;
|
29 |
+
|
30 |
+
echo '<ul>';
|
31 |
+
foreach ((array) $wp_settings_fields[$page][$section] as $field) {
|
32 |
+
$sanitizedID = str_replace('[', '', $field['id'] );
|
33 |
+
$sanitizedID = str_replace(']', '', $sanitizedID );
|
34 |
+
if ( strpos($field['callback'],'header') !== false && !quads_is_excluded(array('help', 'licenses') ) ) {
|
35 |
+
echo '<li class="quads-tabs"><a href="#' . $sanitizedID . '">' . $field['title'] .'</a></li>';
|
36 |
+
}
|
37 |
+
}
|
38 |
+
echo '</ul>';
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Check if current page is excluded
|
43 |
+
*
|
44 |
+
* @param array $pages
|
45 |
+
* @return boolean
|
46 |
+
*/
|
47 |
+
function quads_is_excluded($pages){
|
48 |
+
if (isset($_GET['tab'])){
|
49 |
+
$currentpage = $_GET['tab'];
|
50 |
+
if (isset($currentpage) && in_array($currentpage, $pages))
|
51 |
+
return true;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Print out the settings fields for a particular settings section
|
57 |
+
*
|
58 |
+
* Part of the Settings API. Use this in a settings page to output
|
59 |
+
* a specific section. Should normally be called by do_settings_sections()
|
60 |
+
* rather than directly.
|
61 |
+
*
|
62 |
+
* @global $wp_settings_fields Storage array of settings fields and their pages/sections
|
63 |
+
* @return string
|
64 |
+
*
|
65 |
+
* @since 2.1.2
|
66 |
+
*
|
67 |
+
* @param string $page Slug title of the admin page who's settings fields you want to show.
|
68 |
+
* @param section $section Slug title of the settings section who's fields you want to show.
|
69 |
+
*
|
70 |
+
* Copied from WP Core 4.0 /wp-admin/includes/template.php do_settings_fields()
|
71 |
+
* We use our own function to be able to create jQuery tabs with easytabs()
|
72 |
+
*
|
73 |
+
* We dont use tables here any longer. Are we stuck in the nineties?
|
74 |
+
* @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be faster?
|
75 |
+
* @todo some media queries for better responisbility
|
76 |
+
*/
|
77 |
+
function quads_do_settings_fields($page, $section) {
|
78 |
+
global $wp_settings_fields;
|
79 |
+
$header = false;
|
80 |
+
$firstHeader = false;
|
81 |
+
|
82 |
+
if (!isset($wp_settings_fields[$page][$section]))
|
83 |
+
return;
|
84 |
+
|
85 |
+
// Check first if any callback header registered
|
86 |
+
foreach ((array) $wp_settings_fields[$page][$section] as $field) {
|
87 |
+
strpos($field['callback'],'header') !== false ? $header = true : $header = false;
|
88 |
+
|
89 |
+
if ($header === true)
|
90 |
+
break;
|
91 |
+
}
|
92 |
+
|
93 |
+
foreach ((array) $wp_settings_fields[$page][$section] as $field) {
|
94 |
+
|
95 |
+
$sanitizedID = str_replace('[', '', $field['id'] );
|
96 |
+
$sanitizedID = str_replace(']', '', $sanitizedID );
|
97 |
+
|
98 |
+
// Check if header has been created previously
|
99 |
+
if (strpos($field['callback'],'header') !== false && $firstHeader === false) {
|
100 |
+
|
101 |
+
echo '<div id="' . $sanitizedID . '">';
|
102 |
+
echo '<table class="quads-form-table"><tbody>';
|
103 |
+
$firstHeader = true;
|
104 |
+
|
105 |
+
} elseif (strpos($field['callback'],'header') !== false && $firstHeader === true) {
|
106 |
+
// Header has been created previously so we have to close the first opened div
|
107 |
+
echo '</table></div><div id="' . $sanitizedID . '">';
|
108 |
+
echo '<table class="quads-form-table"><tbody>';
|
109 |
+
}
|
110 |
+
|
111 |
+
if (!empty($field['args']['label_for']) && !quads_is_excluded_title( $field['args']['id'] )){
|
112 |
+
echo '<tr class="quads-row">';
|
113 |
+
echo '<td class="quads-row th">';
|
114 |
+
echo '<label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label>';
|
115 |
+
echo '</td></tr>';
|
116 |
+
}else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) && !empty($field['args']['helper-desc'])){
|
117 |
+
echo '<tr class="quads-row">';
|
118 |
+
echo '<td class="quads-row th">';
|
119 |
+
echo '<div class="col-title">' . $field['title'] . '<a class="quads-general-helper" href="#"></a><div class="quads-message">' . $field['args']['helper-desc']. '</div></div>';
|
120 |
+
echo '</td></tr>';
|
121 |
+
}else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) ){
|
122 |
+
echo '<tr class="quads-row">';
|
123 |
+
echo '<td class="quads-row th">';
|
124 |
+
echo '<div class="col-title">' . $field['title'] . '</div>';
|
125 |
+
echo '</td></tr>';
|
126 |
+
}
|
127 |
+
|
128 |
+
else {
|
129 |
+
echo '';
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
echo '<tr><td>';
|
134 |
+
call_user_func($field['callback'], $field['args']);
|
135 |
+
echo '</td></tr>';
|
136 |
+
}
|
137 |
+
echo '</tbody></table>';
|
138 |
+
if ($header === true){
|
139 |
+
echo '</div>';
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* If title is one of these entries do not show it
|
145 |
+
*/
|
146 |
+
function quads_is_excluded_title($string){
|
147 |
+
$haystack = array('ad1','ad2','ad3','ad4','ad5','ad6','ad7','ad8','ad9','ad10',
|
148 |
+
'ad1_widget',
|
149 |
+
'ad2_widget',
|
150 |
+
'ad3_widget',
|
151 |
+
'ad4_widget',
|
152 |
+
'ad5_widget',
|
153 |
+
'ad6_widget',
|
154 |
+
'ad7_widget',
|
155 |
+
'ad8_widget',
|
156 |
+
'ad9_widget',
|
157 |
+
'ad10_widget',
|
158 |
+
'vi_header',
|
159 |
+
'vi_signup'
|
160 |
+
);
|
161 |
+
|
162 |
+
if (in_array($string, $haystack)){
|
163 |
+
return true;
|
164 |
+
}
|
165 |
+
return false;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Options Page
|
170 |
+
*
|
171 |
+
* Renders the options page contents.
|
172 |
+
*
|
173 |
+
* @since 1.0
|
174 |
+
* @global $quads_options Array of all the QUADS Options
|
175 |
+
* @return void
|
176 |
+
*/
|
177 |
+
function quads_options_page() {
|
178 |
+
global $quads_options;
|
179 |
+
|
180 |
+
$active_tab = isset( $_GET[ 'tab' ] ) && array_key_exists( $_GET['tab'], quads_get_settings_tabs() ) ? $_GET[ 'tab' ] : 'general';
|
181 |
+
|
182 |
+
ob_start();
|
183 |
+
?>
|
184 |
+
<div class="wrap quads_admin">
|
185 |
+
<h1 style="text-align:center;"> <?php echo QUADS_NAME . ' ' . QUADS_VERSION; ?></h1>
|
186 |
+
<div class="about-text" style="font-weight: 400;line-height: 1.6em;text-align:center;">
|
187 |
+
<div class='quads-share-button-container'>
|
188 |
+
<div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
189 |
+
<div clas='box'>
|
190 |
+
<a href="https://twitter.com/share?url=http://wpquads.com&text=WPQUADS+-+The quickest+and+most+easiest+way+to+integrate+AdSense+into+WordPress+websites+@wpquads" target='_blank'>
|
191 |
+
<span class='quads-share'><?php echo __('Shout out a tweet','quick-adsense-reloaded'); ?></span>
|
192 |
+
</a>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
<div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
196 |
+
<div class="box">
|
197 |
+
<a href="https://www.facebook.com/sharer/sharer.php?u=http://wpquads.com" target="_blank">
|
198 |
+
<span class='quads-share'><?php echo __('Share on Facebook','quick-adsense-reloaded'); ?></span>
|
199 |
+
</a>
|
200 |
+
</div>
|
201 |
+
</div>
|
202 |
+
</div>
|
203 |
+
</div>
|
204 |
+
<h2 class="nav-tab-wrapper">
|
205 |
+
<?php
|
206 |
+
foreach( quads_get_settings_tabs() as $tab_id => $tab_name ) {
|
207 |
+
|
208 |
+
$tab_url = esc_url(add_query_arg( array(
|
209 |
+
'settings-updated' => false,
|
210 |
+
'tab' => $tab_id
|
211 |
+
) ));
|
212 |
+
|
213 |
+
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
|
214 |
+
|
215 |
+
echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
|
216 |
+
echo esc_html( $tab_name );
|
217 |
+
echo '</a>';
|
218 |
+
}
|
219 |
+
?>
|
220 |
+
</h2>
|
221 |
+
<div id="quads_tab_container" class="quads_tab_container">
|
222 |
+
<?php quads_get_tab_header( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab ); ?>
|
223 |
+
<div class="quads-panel-container"> <!-- new //-->
|
224 |
+
<form method="post" action="options.php" id="quads_settings">
|
225 |
+
|
226 |
+
<?php
|
227 |
+
settings_fields( 'quads_settings' );
|
228 |
+
quads_do_settings_fields( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab );
|
229 |
+
?>
|
230 |
+
<?php settings_errors(); ?>
|
231 |
+
<?php
|
232 |
+
// do not show save button on add-on page
|
233 |
+
if ($active_tab !== 'addons' && $active_tab !== 'imexport' && $active_tab !== 'help'){
|
234 |
+
$other_attributes = array( 'id' => 'quads-submit-button' );
|
235 |
+
submit_button(null, 'primary', 'quads-save-settings' , true, $other_attributes );
|
236 |
+
if ($active_tab !== 'licenses'){
|
237 |
+
?>
|
238 |
+
<!--<a href="<?php //echo admin_url() . '/admin.php?page=quads-settings&quads-action=validate'; ?> " id="quads-validate"><?php //_e('Validate Ad Settings','quick-adsense-reloaded')?></a>//-->
|
239 |
+
<?php
|
240 |
+
}
|
241 |
+
|
242 |
+
}
|
243 |
+
?>
|
244 |
+
</form>
|
245 |
+
<div id="quads-footer">
|
246 |
+
<?php
|
247 |
+
|
248 |
+
if ($active_tab !== 'addons' && $active_tab !== 'licenses'){
|
249 |
+
echo sprintf( __( '<strong>If you like this plugin please do us a BIG favor and give us a 5 star rating <a href="%s" target="_blank">here</a> . If you have issues, open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
|
250 |
+
'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/#new-post',
|
251 |
+
'http://wpquads.com/support/'
|
252 |
+
);
|
253 |
+
echo '<br/><br/>' . sprintf( __( '<strong>Ads are not showing? Read the <a href="%s" target="_blank">troubleshooting guide</a> to find out how to resolve it.<p> Looking for a quick way to clone your WordPress? Try the free plugin <a href="%s" target="_blank">WP Staging</a>.', 'quick-adsense-reloaded' ),
|
254 |
+
'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=bottomlink',
|
255 |
+
'https://wp-staging.com/?utm_source=wpquads_plugin&utm_campaign=footer&utm_medium=website&utm_term=bottomlink'
|
256 |
+
);
|
257 |
+
}
|
258 |
+
?>
|
259 |
+
</div>
|
260 |
+
</div> <!-- new //-->
|
261 |
+
<?php quads_get_advertising(); ?>
|
262 |
+
</div><!-- #tab_container-->
|
263 |
+
<div id="quads-save-result"></div>
|
264 |
+
<div class="quads-admin-debug"><?php echo quads_get_debug_messages(); ?></div>
|
265 |
+
<?php echo quads_render_adsense_form(); ?>
|
266 |
+
</div><!-- .wrap -->
|
267 |
+
<?php
|
268 |
+
echo ob_get_clean();
|
269 |
+
}
|
270 |
+
|
271 |
+
function quads_get_debug_messages(){
|
272 |
+
global $quads_options;
|
273 |
+
|
274 |
+
if (isset($quads_options['debug_mode'])){
|
275 |
+
echo '<pre style="clear:both;">';
|
276 |
+
var_dump($quads_options);
|
277 |
+
echo '</pre>';
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* Render ad and return it when plugin is not pro version
|
283 |
+
* @return string
|
284 |
+
*/
|
285 |
+
function quads_get_advertising() {
|
286 |
+
|
287 |
+
if ( quads_is_extra() ){
|
288 |
+
return '';
|
289 |
+
}
|
290 |
+
ob_start();
|
291 |
+
?>
|
292 |
+
<div class="quads-panel-sidebar" style="float:left;min-width: 301px;margin-left: 1px;margin-top:0px;">
|
293 |
+
<a href="http://wpquads.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-quads&utm_campaign=wpquads" target="_blank">
|
294 |
+
<img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/quads_banner_250x521_buy.png'; ?>">
|
295 |
+
</a>
|
296 |
+
<br>
|
297 |
+
<a style="display:block;" href="http://demo.clickfraud-monitoring.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-cfm&utm_campaign=wpquads" target="_blank">
|
298 |
+
<img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/banner_250x296-cfm.png'; ?>">
|
299 |
+
</a>
|
300 |
+
</div>
|
301 |
+
<?php
|
302 |
+
echo ob_get_clean();
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* Render social buttons
|
307 |
+
*
|
308 |
+
* @return void
|
309 |
+
*/
|
310 |
+
function quads_render_social(){
|
311 |
+
ob_start()?>
|
312 |
+
|
313 |
+
<div class='quads-share-button-container'>
|
314 |
+
<div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
315 |
+
<div clas='box'>
|
316 |
+
<a href="https://twitter.com/share?url=https://wordpress.org/plugins/quick-adsense-reloaded&text=Quick%20AdSense%20reloaded%20-%20a%20brand%20new%20fork%20of%20the%20popular%20AdSense%20Plugin%20Quick%20Adsense!" target='_blank'>
|
317 |
+
<span class='quads-share'><?php echo __('Tweet','quick-adsense-reloaded'); ?></span>
|
318 |
+
</a>
|
319 |
+
</div>
|
320 |
+
</div>
|
321 |
+
|
322 |
+
<div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
|
323 |
+
<div class="box">
|
324 |
+
<a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/quick-adsense-reloaded" target="_blank">
|
325 |
+
<span class='quads-share'><?php echo __('Share','quick-adsense-reloaded'); ?></span>
|
326 |
+
</a>
|
327 |
+
</div>
|
328 |
+
</div>
|
329 |
+
</div>
|
330 |
+
|
331 |
+
<?php
|
332 |
+
echo ob_get_clean();
|
333 |
+
}
|
334 |
+
|
335 |
+
|
336 |
+
/**
|
337 |
+
* Render AdSense Form
|
338 |
+
*/
|
339 |
+
function quads_render_adsense_form(){
|
340 |
+
|
341 |
+
?>
|
342 |
+
<div id="quads-adsense-bg-div" style="display: none;">
|
343 |
+
<div id="quads-adsense-container">
|
344 |
+
<h3><?php _e( 'Enter <a ahref="https://wpquads.com/docs/how-to-create-and-where-to-get-adsense-code/" target="_blank">AdSense text & display ad code</a> here', 'quick-adsense-reloaded' ); ?></h3>
|
345 |
+
<?php _e('Do not enter <a href="https://wpquads.com/docs/integrate-page-level-ads-wordpress/" target="_blank">AdSense page level ads</a> or <a href="https://wpquads.com/introducing-new-adsense-auto-ads/" target="_blank">Auto ads!</a> <br> <a href="https://wpquads.com/docs/how-to-create-and-where-to-get-adsense-code/" target="_blank">Learn how to create AdSense ad code</a>', 'quick-adsense-reloaded'); ?>
|
346 |
+
<textarea rows="15" cols="55" id="quads-adsense-form"></textarea><hr />
|
347 |
+
<button class="button button-primary" id="quads-paste-button"><?php _e( 'Get Code', 'quick-adsense-reloaded' ); ?></button>
|
348 |
+
<button class="button button-secondary" id="quads-close-button"><?php _e( 'Close', 'quick-adsense-reloaded' ); ?></button>
|
349 |
+
<div id="quads-msg"></div>
|
350 |
+
<input type="hidden" id="quads-adsense-id" value="">
|
351 |
+
</div>
|
352 |
+
</div>
|
353 |
+
<?php
|
354 |
+
}
|
includes/admin/settings/register-settings.php
CHANGED
@@ -1,2380 +1,2380 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Register Settings
|
4 |
-
*
|
5 |
-
* @package QUADS
|
6 |
-
* @subpackage Admin/Settings
|
7 |
-
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
-
* @since 1.0
|
10 |
-
*/
|
11 |
-
// Exit if accessed directly
|
12 |
-
if( !defined( 'ABSPATH' ) )
|
13 |
-
exit;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Get an option
|
17 |
-
*
|
18 |
-
* Looks to see if the specified setting exists, returns default if not
|
19 |
-
*
|
20 |
-
* @since 1.0.0
|
21 |
-
* @return mixed
|
22 |
-
*/
|
23 |
-
function quads_get_option( $key = '', $default = false ) {
|
24 |
-
global $quads_options;
|
25 |
-
$value = !empty( $quads_options[$key] ) ? $quads_options[$key] : $default;
|
26 |
-
$value = apply_filters( 'quads_get_option', $value, $key, $default );
|
27 |
-
return apply_filters( 'quads_get_option_' . $key, $value, $key, $default );
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Get Settings
|
32 |
-
*
|
33 |
-
* Retrieves all plugin settings
|
34 |
-
*
|
35 |
-
* @since 1.0
|
36 |
-
* @return array QUADS settings
|
37 |
-
*/
|
38 |
-
function quads_get_settings() {
|
39 |
-
$settings = get_option( 'quads_settings' );
|
40 |
-
|
41 |
-
|
42 |
-
if( empty( $settings ) ) {
|
43 |
-
// Update old settings with new single option
|
44 |
-
$general_settings = is_array( get_option( 'quads_settings_general' ) ) ? get_option( 'quads_settings_general' ) : array();
|
45 |
-
$ext_settings = is_array( get_option( 'quads_settings_extensions' ) ) ? get_option( 'quads_settings_extensions' ) : array();
|
46 |
-
$license_settings = is_array( get_option( 'quads_settings_licenses' ) ) ? get_option( 'quads_settings_licenses' ) : array();
|
47 |
-
$addons_settings = is_array( get_option( 'quads_settings_addons' ) ) ? get_option( 'quads_settings_addons' ) : array();
|
48 |
-
$imexport_settings = is_array( get_option( 'quads_settings_imexport' ) ) ? get_option( 'quads_settings_imexport' ) : array();
|
49 |
-
$help_settings = is_array( get_option( 'quads_settings_help' ) ) ? get_option( 'quads_settings_help' ) : array();
|
50 |
-
|
51 |
-
$settings = array_merge( $general_settings, $ext_settings, $imexport_settings, $help_settings );
|
52 |
-
|
53 |
-
update_option( 'quads_settings', $settings );
|
54 |
-
|
55 |
-
|
56 |
-
}
|
57 |
-
return apply_filters( 'quads_get_settings', $settings );
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Add all settings sections and fields
|
62 |
-
*
|
63 |
-
* @since 1.0
|
64 |
-
* @return void
|
65 |
-
*/
|
66 |
-
function quads_register_settings() {
|
67 |
-
|
68 |
-
if( false == get_option( 'quads_settings' ) ) {
|
69 |
-
add_option( 'quads_settings' );
|
70 |
-
}
|
71 |
-
|
72 |
-
foreach ( quads_get_registered_settings() as $tab => $settings ) {
|
73 |
-
|
74 |
-
add_settings_section(
|
75 |
-
'quads_settings_' . $tab, __return_null(), '__return_false', 'quads_settings_' . $tab
|
76 |
-
);
|
77 |
-
|
78 |
-
foreach ( $settings as $option ) {
|
79 |
-
|
80 |
-
$name = isset( $option['name'] ) ? $option['name'] : '';
|
81 |
-
|
82 |
-
add_settings_field(
|
83 |
-
'quads_settings[' . $option['id'] . ']', $name, function_exists( 'quads_' . $option['type'] . '_callback' ) ? 'quads_' . $option['type'] . '_callback' : 'quads_missing_callback', 'quads_settings_' . $tab, 'quads_settings_' . $tab, array(
|
84 |
-
'id' => isset( $option['id'] ) ? $option['id'] : null,
|
85 |
-
'desc' => !empty( $option['desc'] ) ? $option['desc'] : '',
|
86 |
-
'desc2' => !empty( $option['desc2'] ) ? $option['desc2'] : '',
|
87 |
-
'helper-desc' => !empty( $option['helper-desc'] ) ? $option['helper-desc'] : '',
|
88 |
-
'name' => isset( $option['name'] ) ? $option['name'] : null,
|
89 |
-
'section' => $tab,
|
90 |
-
'size' => isset( $option['size'] ) ? $option['size'] : null,
|
91 |
-
'options' => isset( $option['options'] ) ? $option['options'] : '',
|
92 |
-
'std' => isset( $option['std'] ) ? $option['std'] : '',
|
93 |
-
'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
|
94 |
-
'textarea_rows' => isset( $option['textarea_rows'] ) ? $option['textarea_rows'] : ''
|
95 |
-
)
|
96 |
-
);
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
// Store adsense values
|
101 |
-
quads_store_adsense_args();
|
102 |
-
|
103 |
-
// Store AdSense value
|
104 |
-
//quads_fix_ad_not_shown();
|
105 |
-
// Creates our settings in the options table
|
106 |
-
register_setting( 'quads_settings', 'quads_settings', 'quads_settings_sanitize' );
|
107 |
-
}
|
108 |
-
add_action( 'admin_init', 'quads_register_settings' );
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Retrieve the array of plugin settings
|
112 |
-
*
|
113 |
-
* @since 1.8
|
114 |
-
* @return array
|
115 |
-
*/
|
116 |
-
function quads_get_registered_settings() {
|
117 |
-
|
118 |
-
/**
|
119 |
-
* 'Whitelisted' QUADS settings, filters are provided for each settings
|
120 |
-
* section to allow extensions and other plugins to add their own settings
|
121 |
-
*/
|
122 |
-
$quads_settings = array(
|
123 |
-
/** General Settings */
|
124 |
-
'general' => apply_filters( 'quads_settings_general', array(
|
125 |
-
array(
|
126 |
-
'id' => 'general_header',
|
127 |
-
'name' => '<strong>' . __( 'General & Position', 'quick-adsense-reloaded' ) . '</strong>',
|
128 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
129 |
-
'type' => 'header'
|
130 |
-
),
|
131 |
-
'maxads' => array(
|
132 |
-
'id' => 'maxads',
|
133 |
-
'name' => __( 'Limit Amount of ads:', 'quick-adsense-reloaded' ),
|
134 |
-
'desc' => __( ' ads on a page.', 'quick-adsense-reloaded' ),
|
135 |
-
'desc2' => sprintf( __( '<a href="%s" target="_blank">Read here</a> to learn how many AdSense ads are allowed. If you are unsure set the value to unlimited.', 'quick-adsense-reloaded' ), 'http://wpquads.com/google-adsense-allowed-number-ads/' ),
|
136 |
-
'type' => 'select',
|
137 |
-
'std' => 100,
|
138 |
-
'options' => array(
|
139 |
-
1 => '1',
|
140 |
-
2 => '2',
|
141 |
-
3 => '3',
|
142 |
-
4 => '4',
|
143 |
-
5 => '5',
|
144 |
-
6 => '6',
|
145 |
-
7 => '7',
|
146 |
-
8 => '8',
|
147 |
-
9 => '9',
|
148 |
-
10 => '10',
|
149 |
-
11 => '11',
|
150 |
-
12 => '12',
|
151 |
-
13 => '13',
|
152 |
-
14 => '14',
|
153 |
-
15 => '15',
|
154 |
-
16 => '16',
|
155 |
-
17 => '17',
|
156 |
-
18 => '18',
|
157 |
-
19 => '19',
|
158 |
-
20 => '20',
|
159 |
-
100 => 'Unlimited',
|
160 |
-
),
|
161 |
-
),
|
162 |
-
array(
|
163 |
-
'id' => 'ad_position',
|
164 |
-
'name' => __( 'Position - Default Ads', 'quick-adsense-reloaded' ),
|
165 |
-
'desc' => __( 'Assign and activate ads on specific ad places', 'quick-adsense-reloaded' ),
|
166 |
-
'type' => 'ad_position'
|
167 |
-
),
|
168 |
-
array(
|
169 |
-
'id' => 'visibility',
|
170 |
-
'name' => __( 'Visibility', 'quick-adsense-reloaded' ),
|
171 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
172 |
-
'type' => 'visibility'
|
173 |
-
),
|
174 |
-
array(
|
175 |
-
"id" => "post_types",
|
176 |
-
"name" => __( "Post Types", "quick-adsense-reloaded" ),
|
177 |
-
"desc" => __( "Select post types where ads are visible.", "quick-adsense-reloaded" ),
|
178 |
-
"helper-desc" => __( "Select post types where ads are visible.", "quick-adsense-reloaded" ),
|
179 |
-
"type" => "multiselect",
|
180 |
-
"options" => quads_get_post_types(),
|
181 |
-
"placeholder" => __( "Select Post Type", "quick-adsense-reloaded" )
|
182 |
-
),
|
183 |
-
array(
|
184 |
-
'id' => 'hide_ajax',
|
185 |
-
'name' => __( 'Hide Ads From Ajax Requests', 'quick-adsense-reloaded' ),
|
186 |
-
'desc' => __( 'If your site is using ajax based infinite loading it might happen that ads are loaded without any further post content. Disable this here.', 'quick-adsense-reloaded' ),
|
187 |
-
'type' => 'checkbox'
|
188 |
-
),
|
189 |
-
array(
|
190 |
-
'id' => 'quicktags',
|
191 |
-
'name' => __( 'Quicktags', 'quick-adsense-reloaded' ),
|
192 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
193 |
-
'type' => 'quicktags'
|
194 |
-
),
|
195 |
-
array(
|
196 |
-
'id' => 'adsTxtEnabled',
|
197 |
-
'name' => __( 'ads.txt - Automatic Creation', 'quick-adsense-reloaded' ),
|
198 |
-
'desc' => __( 'Create an ads.txt file', 'quick-adsense-reloaded' ),
|
199 |
-
"helper-desc" => sprintf(__( 'Allow WP QUADS to generate automatically the ads.txt file in root of your website domain. After enabling and saving settings,'
|
200 |
-
. ' check if your ads.txt is correct by opening: <a href="%1$s" target="_blank">%1$s</a> <br><a href="%2$s" target="_blank">Read here</a> to learn more about ads.txt', 'quick-adsense-reloaded' ),
|
201 |
-
get_site_url() . '/ads.txt',
|
202 |
-
'https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
|
203 |
-
),
|
204 |
-
'type' => 'checkbox'
|
205 |
-
),
|
206 |
-
array(
|
207 |
-
'id' => 'quicktags',
|
208 |
-
'name' => __( 'Quicktags', 'quick-adsense-reloaded' ),
|
209 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
210 |
-
'type' => 'quicktags'
|
211 |
-
),
|
212 |
-
array(
|
213 |
-
'id' => 'vi_header',
|
214 |
-
'name' => '<strong>' . __( 'vi ads', 'quick-adsense-reloaded' ) . '</strong>',
|
215 |
-
'desc' => '<strong>Native video ad units powered by video intelligence</strong>',
|
216 |
-
'type' => 'header'
|
217 |
-
),
|
218 |
-
array(
|
219 |
-
'id' => 'vi_signup',
|
220 |
-
'name' =>__( '', 'quick-adsense-reloaded' ) . '</strong>',
|
221 |
-
'type' => 'vi_signup'
|
222 |
-
),
|
223 |
-
/* 'load_scripts_footer' => array(
|
224 |
-
'id' => 'load_scripts_footer',
|
225 |
-
'name' => __( 'JS Load Order', 'quick-adsense-reloaded' ),
|
226 |
-
'desc' => __( 'Enable this to load all *.js files into footer. Make sure your theme uses the wp_footer() template tag in the appropriate place. Default: Disabled', 'quick-adsense-reloaded' ),
|
227 |
-
'type' => 'checkbox'
|
228 |
-
), */
|
229 |
-
'adsense_header' => array(
|
230 |
-
'id' => 'adsense_header',
|
231 |
-
'name' => '<strong>' . __( 'Ads', 'quick-adsense-reloaded' ) . '</strong>',
|
232 |
-
'desc' => '<div class="adsense_admin_header">' . __( 'Enter your ads below:</div>'
|
233 |
-
. '<ul style="margin-top:10px;">'
|
234 |
-
. '<li style="font-weight:600;">- <i>AdSense</i> for using <span style="font-weight:600;">AdSense Text & display Ads</span>!</li>'
|
235 |
-
. '<li style="font-weight:600;">- <i>Plain Text / HTML / JS</i> for all other ads! <br><strong>Caution:</strong> Adding AdSense code into <i>Plain Text</i> option can result in non-displayed ads!</li></ul>', 'quick-adsense-reloaded' )
|
236 |
-
. '</ul>'
|
237 |
-
. '<div style="clear:both;">' . sprintf( __( '<strong>Ads are not showing? Read the <a href="%s" target="_blank">troubleshooting guide</a> to find out how to resolve it.', 'quick-adsense-reloaded' ), 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=toplink' ) . ''
|
238 |
-
. '<br><a href="http://wpquads.com/effective-adsense-banner-size-formats/?utm_campaign=plugin&utm_source=general_tab&utm_medium=admin&utm_content=best_banner_sizes" target="_blank">Read this</a> to find out the most effective AdSense banner sizes. </div>'
|
239 |
-
. '<div id="quads-open-toggle" class="button">' . __( 'Open All Ads', 'quick-adsense-reloaded' ) . '</div>',
|
240 |
-
'type' => 'header'
|
241 |
-
),
|
242 |
-
array(
|
243 |
-
'id' => 'quads_ads',
|
244 |
-
'name' => __( '', 'quick-adsense-reloaded' ),
|
245 |
-
'type' => 'ad_code'
|
246 |
-
),
|
247 |
-
array(
|
248 |
-
'id' => 'new_ad',
|
249 |
-
'name' => __( '', 'quick-adsense-reloaded' ),
|
250 |
-
'type' => 'new_ad',
|
251 |
-
),
|
252 |
-
'widget_header' => array(
|
253 |
-
'id' => 'widget_header',
|
254 |
-
'name' => '<strong>' . __( 'Widget Ads', 'quick-adsense-reloaded' ) . '</strong>',
|
255 |
-
'desc' => sprintf( __( 'After creating your ads here go to <a href="%s" target="_self">Appearance->Widgets</a> and drag the WP QUADS widget into place.', 'quick-adsense-reloaded' ), admin_url() . 'widgets.php' ),
|
256 |
-
'type' => 'header'
|
257 |
-
),
|
258 |
-
'ad1_widget' => array(
|
259 |
-
'id' => 'ad1_widget',
|
260 |
-
'name' => __( 'Ad widget 1', 'quick-adsense-reloaded' ),
|
261 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
262 |
-
'type' => 'adsense_widget',
|
263 |
-
'size' => 4
|
264 |
-
),
|
265 |
-
'ad2_widget' => array(
|
266 |
-
'id' => 'ad2_widget',
|
267 |
-
'name' => __( 'Ad widget 2', 'quick-adsense-reloaded' ),
|
268 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
269 |
-
'type' => 'adsense_widget',
|
270 |
-
'size' => 4
|
271 |
-
),
|
272 |
-
'ad3_widget' => array(
|
273 |
-
'id' => 'ad3_widget',
|
274 |
-
'name' => __( 'Ad widget 3', 'quick-adsense-reloaded' ),
|
275 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
276 |
-
'type' => 'adsense_widget',
|
277 |
-
'size' => 4
|
278 |
-
),
|
279 |
-
'ad4_widget' => array(
|
280 |
-
'id' => 'ad4_widget',
|
281 |
-
'name' => __( 'Ad widget 4', 'quick-adsense-reloaded' ),
|
282 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
283 |
-
'type' => 'adsense_widget',
|
284 |
-
'size' => 4
|
285 |
-
),
|
286 |
-
'ad5_widget' => array(
|
287 |
-
'id' => 'ad5_widget',
|
288 |
-
'name' => __( 'Ad widget 5', 'quick-adsense-reloaded' ),
|
289 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
290 |
-
'type' => 'adsense_widget',
|
291 |
-
'size' => 4
|
292 |
-
),
|
293 |
-
'ad6_widget' => array(
|
294 |
-
'id' => 'ad6_widget',
|
295 |
-
'name' => __( 'Ad widget 6', 'quick-adsense-reloaded' ),
|
296 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
297 |
-
'type' => 'adsense_widget',
|
298 |
-
'size' => 4
|
299 |
-
),
|
300 |
-
'ad7_widget' => array(
|
301 |
-
'id' => 'ad7_widget',
|
302 |
-
'name' => __( 'Ad widget 7', 'quick-adsense-reloaded' ),
|
303 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
304 |
-
'type' => 'adsense_widget',
|
305 |
-
'size' => 4
|
306 |
-
),
|
307 |
-
'ad8_widget' => array(
|
308 |
-
'id' => 'ad8_widget',
|
309 |
-
'name' => __( 'Ad widget 8', 'quick-adsense-reloaded' ),
|
310 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
311 |
-
'type' => 'adsense_widget',
|
312 |
-
'size' => 4
|
313 |
-
),
|
314 |
-
'ad9_widget' => array(
|
315 |
-
'id' => 'ad9_widget',
|
316 |
-
'name' => __( 'Ad widget 9', 'quick-adsense-reloaded' ),
|
317 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
318 |
-
'type' => 'adsense_widget',
|
319 |
-
'size' => 4
|
320 |
-
),
|
321 |
-
'ad10_widget' => array(
|
322 |
-
'id' => 'ad10_widget',
|
323 |
-
'name' => __( 'Ad widget 10', 'quick-adsense-reloaded' ),
|
324 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
325 |
-
'type' => 'adsense_widget',
|
326 |
-
'size' => 4
|
327 |
-
),
|
328 |
-
array(
|
329 |
-
'id' => 'plugin_header',
|
330 |
-
'name' => '<strong>' . __( 'Plugin Settings', 'quick-adsense-reloaded' ) . '</strong>',
|
331 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
332 |
-
'type' => 'header'
|
333 |
-
),
|
334 |
-
'priority' => array(
|
335 |
-
'id' => 'priority',
|
336 |
-
'name' => __( 'Load Priority', 'quick-adsense-reloaded' ),
|
337 |
-
//'desc' => __( 'Do not change this until you know what you are doing. Usually the default value 20 is working fine. Changing this value can lead to unexpected results like ads not showing or loaded on wrong order. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
|
338 |
-
'helper-desc' => __( 'Do not change this until you know what you are doing. Usually the default value 20 is working fine. Changing this value can lead to unexpected results like ads not showing or loaded on wrong order. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
|
339 |
-
'type' => 'number',
|
340 |
-
'size' => 'small',
|
341 |
-
'std' => 10
|
342 |
-
),
|
343 |
-
'create_settings' => array(
|
344 |
-
'id' => 'create_settings',
|
345 |
-
'name' => __( 'Remove menu button', 'quick-adsense-reloaded' ),
|
346 |
-
//'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
|
347 |
-
'desc' => __( 'Remove it' ),
|
348 |
-
'helper-desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
|
349 |
-
'type' => 'checkbox',
|
350 |
-
),
|
351 |
-
'disableAmpScript' => array(
|
352 |
-
'id' => 'disableAmpScript',
|
353 |
-
'name' => __( 'Disable AMP script', 'quick-adsense-reloaded' ),
|
354 |
-
//'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
|
355 |
-
'desc' => __( 'Disable AMP Scripts' ),
|
356 |
-
'helper-desc' => __( 'Disable duplicate AMP ad script integration if your AMP plugin is already loading the script https://cdn.ampproject.org/v0/amp-ad-0.1.js into your site', 'quick-adsense-reloaded' ),
|
357 |
-
'type' => 'checkbox',
|
358 |
-
),
|
359 |
-
'uninstall_on_delete' => array(
|
360 |
-
'id' => 'uninstall_on_delete',
|
361 |
-
'name' => __( 'Delete Data on Uninstall?', 'quick-adsense-reloaded' ),
|
362 |
-
//'desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
|
363 |
-
'helper-desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
|
364 |
-
'desc' => 'Delete data',
|
365 |
-
'type' => 'checkbox'
|
366 |
-
),
|
367 |
-
'debug_mode' => array(
|
368 |
-
'id' => 'debug_mode',
|
369 |
-
'name' => __( 'Debug mode', 'quick-adsense-reloaded' ),
|
370 |
-
'desc' => __( 'Check this to not minify JavaScript and CSS files. This makes debugging much easier and is recommended setting for inspecting issues on your site', 'quick-adsense-reloaded' ),
|
371 |
-
'type' => 'checkbox'
|
372 |
-
)
|
373 |
-
)
|
374 |
-
),
|
375 |
-
'licenses' => apply_filters( 'quads_settings_licenses', array('licenses_header' => array(
|
376 |
-
'id' => 'licenses_header',
|
377 |
-
'name' => __( 'Activate Your License', 'quick-adsense-reloaded' ),
|
378 |
-
'desc' => '',
|
379 |
-
'type' => 'header'
|
380 |
-
),)
|
381 |
-
),
|
382 |
-
'extensions' => apply_filters( 'quads_settings_extension', array()
|
383 |
-
),
|
384 |
-
'addons' => apply_filters( 'quads_settings_addons', array(
|
385 |
-
'addons' => array(
|
386 |
-
'id' => 'addons',
|
387 |
-
'name' => __( '', 'quick-adsense-reloaded' ),
|
388 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
389 |
-
'type' => 'addons'
|
390 |
-
),
|
391 |
-
)
|
392 |
-
),
|
393 |
-
'imexport' => apply_filters( 'quads_settings_imexport', array(
|
394 |
-
'imexport' => array(
|
395 |
-
'id' => 'imexport',
|
396 |
-
'name' => __( '', 'quick-adsense-reloaded' ),
|
397 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
398 |
-
'type' => 'imexport'
|
399 |
-
)
|
400 |
-
)
|
401 |
-
),
|
402 |
-
'help' => apply_filters( 'quads_settings_help', array(
|
403 |
-
'help_header' => array(
|
404 |
-
'id' => 'help_header',
|
405 |
-
'name' => '<strong>' . __( 'Help', 'quick-adsense-reloaded' ) . '</strong>',
|
406 |
-
'desc' => quads_is_extra() ? sprintf( __( 'Something not working as expected? Open a <a href="%1s" target="_blank">support ticket</a>', 'quick-adsense-reloaded' ), 'http://wpquads.com/support/' ) : sprintf( __( 'Something not working as expected? Visit the WP<strong>QUADS</strong> <a href="%1s" target="_blank">Support Forum</a>', 'quick-adsense-reloaded' ), 'https://wordpress.org/support/plugin/quick-adsense-reloaded' ),
|
407 |
-
'type' => 'header'
|
408 |
-
),
|
409 |
-
'systeminfo' => array(
|
410 |
-
'id' => 'systeminfo',
|
411 |
-
'name' => __( 'Systeminfo', 'quick-adsense-reloaded' ),
|
412 |
-
'desc' => __( '', 'quick-adsense-reloaded' ),
|
413 |
-
'type' => 'systeminfo'
|
414 |
-
)
|
415 |
-
)
|
416 |
-
)
|
417 |
-
);
|
418 |
-
|
419 |
-
return $quads_settings;
|
420 |
-
}
|
421 |
-
|
422 |
-
/**
|
423 |
-
* return empty settings
|
424 |
-
* @return string empty one
|
425 |
-
*/
|
426 |
-
function quads_empty_callback() {
|
427 |
-
return '';
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* Settings Sanitization
|
432 |
-
*
|
433 |
-
* Adds a settings error (for the updated message)
|
434 |
-
* At some point this will validate input
|
435 |
-
*
|
436 |
-
* @since 0.9.0
|
437 |
-
*
|
438 |
-
* @param array $input The value input in the field
|
439 |
-
*
|
440 |
-
* @return string $input Sanitized value
|
441 |
-
*/
|
442 |
-
function quads_settings_sanitize( $input = array() ) {
|
443 |
-
|
444 |
-
global $quads_options;
|
445 |
-
|
446 |
-
|
447 |
-
if( empty( $_POST['_wp_http_referer'] ) ) {
|
448 |
-
return $input;
|
449 |
-
}
|
450 |
-
|
451 |
-
parse_str( $_POST['_wp_http_referer'], $referrer );
|
452 |
-
|
453 |
-
$settings = quads_get_registered_settings();
|
454 |
-
$tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
|
455 |
-
|
456 |
-
|
457 |
-
$input = $input ? $input : array();
|
458 |
-
$input = apply_filters( 'quads_settings_' . $tab . '_sanitize', $input );
|
459 |
-
// Loop through each setting being saved and pass it through a sanitization filter
|
460 |
-
foreach ( $input as $key => $value ) {
|
461 |
-
|
462 |
-
// Get the setting type (checkbox, select, etc)
|
463 |
-
$type = isset( $settings[$tab][$key]['type'] ) ? $settings[$tab][$key]['type'] : false;
|
464 |
-
if( $type ) {
|
465 |
-
// Field type specific filter
|
466 |
-
$input[$key] = apply_filters( 'quads_settings_sanitize_' . $type, $value, $key );
|
467 |
-
}
|
468 |
-
|
469 |
-
// General filter
|
470 |
-
$input[$key] = apply_filters( 'quads_settings_sanitize', $value, $key );
|
471 |
-
}
|
472 |
-
//wp_die(var_dump($input));
|
473 |
-
|
474 |
-
|
475 |
-
// Loop through the whitelist and unset any that are empty for the tab being saved
|
476 |
-
if( !empty( $settings[$tab] ) ) {
|
477 |
-
foreach ( $settings[$tab] as $key => $value ) {
|
478 |
-
// settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
|
479 |
-
if( is_numeric( $key ) ) {
|
480 |
-
$key = $value['id'];
|
481 |
-
}
|
482 |
-
|
483 |
-
if( empty( $input[$key] ) ) {
|
484 |
-
unset( $quads_options[$key] );
|
485 |
-
}
|
486 |
-
}
|
487 |
-
}
|
488 |
-
|
489 |
-
|
490 |
-
// Merge our new settings with the existing
|
491 |
-
$output = array_merge( $quads_options, $input );
|
492 |
-
|
493 |
-
|
494 |
-
add_settings_error( 'quads-notices', '', __( 'Settings updated.', 'quick-adsense-reloaded' ), 'updated' );
|
495 |
-
|
496 |
-
return $output;
|
497 |
-
}
|
498 |
-
|
499 |
-
/**
|
500 |
-
* Sanitize all fields and remove whitespaces
|
501 |
-
*
|
502 |
-
* @since 1.5.3
|
503 |
-
* @param array $input The field value
|
504 |
-
* @return string $input Sanitizied value
|
505 |
-
*/
|
506 |
-
function quads_sanitize_general_field( $input ){
|
507 |
-
if (!is_array( $input )){
|
508 |
-
return trim($input);
|
509 |
-
}
|
510 |
-
return array_map('quads_sanitize_general_field', $input);
|
511 |
-
}
|
512 |
-
add_filter( 'quads_settings_sanitize', 'quads_sanitize_general_field' );
|
513 |
-
|
514 |
-
/**
|
515 |
-
* Sanitize text fields
|
516 |
-
*
|
517 |
-
* @since 1.8
|
518 |
-
* @param array $input The field value
|
519 |
-
* @return string $input Sanitizied value
|
520 |
-
*/
|
521 |
-
function quads_sanitize_text_field( $input ) {
|
522 |
-
return trim( $input );
|
523 |
-
}
|
524 |
-
add_filter( 'quads_settings_sanitize_text', 'quads_sanitize_text_field' );
|
525 |
-
|
526 |
-
/**
|
527 |
-
* Retrieve settings tabs
|
528 |
-
*
|
529 |
-
* @since 1.8
|
530 |
-
* @param array $input The field value
|
531 |
-
* @return string $input Sanitizied value
|
532 |
-
*/
|
533 |
-
function quads_get_settings_tabs() {
|
534 |
-
|
535 |
-
$settings = quads_get_registered_settings();
|
536 |
-
|
537 |
-
$tabs = array();
|
538 |
-
$tabs['general'] = __( 'General', 'quick-adsense-reloaded' );
|
539 |
-
|
540 |
-
if( !empty( $settings['visual'] ) ) {
|
541 |
-
$tabs['visual'] = __( 'Visual', 'quick-adsense-reloaded' );
|
542 |
-
}
|
543 |
-
|
544 |
-
if( !empty( $settings['networks'] ) ) {
|
545 |
-
//$tabs['networks'] = __( 'Social Networks', 'quick-adsense-reloaded' );
|
546 |
-
}
|
547 |
-
|
548 |
-
if( !empty( $settings['extensions'] ) ) {
|
549 |
-
$tabs['extensions'] = __( 'Add-On Setting', 'quick-adsense-reloaded' );
|
550 |
-
}
|
551 |
-
|
552 |
-
|
553 |
-
if( !empty( $settings['licenses'] ) && quads_is_extra() || quads_is_advanced() ) {
|
554 |
-
$tabs['licenses'] = __( 'Licenses', 'quick-adsense-reloaded' );
|
555 |
-
}
|
556 |
-
|
557 |
-
//$tabs['addons'] = __( 'Add-Ons', 'quick-adsense-reloaded' );
|
558 |
-
|
559 |
-
$tabs['imexport'] = __( 'Import/Export', 'quick-adsense-reloaded' );
|
560 |
-
|
561 |
-
$tabs['help'] = __( 'Help', 'quick-adsense-reloaded' );
|
562 |
-
|
563 |
-
//$tabs['misc'] = __( 'Misc', 'quick-adsense-reloaded' );
|
564 |
-
|
565 |
-
return apply_filters( 'quads_settings_tabs', $tabs );
|
566 |
-
}
|
567 |
-
|
568 |
-
/**
|
569 |
-
* Header Callback
|
570 |
-
*
|
571 |
-
* Renders the header.
|
572 |
-
*
|
573 |
-
* @since 1.0
|
574 |
-
* @param array $args Arguments passed by the setting
|
575 |
-
* @return void
|
576 |
-
*/
|
577 |
-
function quads_header_callback( $args ) {
|
578 |
-
if( !empty( $args['desc'] ) ) {
|
579 |
-
echo $args['desc'];
|
580 |
-
} else {
|
581 |
-
echo ' ';
|
582 |
-
}
|
583 |
-
}
|
584 |
-
|
585 |
-
/**
|
586 |
-
* Checkbox Callback
|
587 |
-
*
|
588 |
-
* Renders checkboxes.
|
589 |
-
*
|
590 |
-
* @since 1.0
|
591 |
-
* @param array $args Arguments passed by the setting
|
592 |
-
* @global $quads_options Array of all the QUADS Options
|
593 |
-
* @return void
|
594 |
-
*/
|
595 |
-
function quads_checkbox_callback( $args ) {
|
596 |
-
global $quads_options;
|
597 |
-
|
598 |
-
$checked = isset( $quads_options[$args['id']] ) ? checked( 1, $quads_options[$args['id']], false ) : '';
|
599 |
-
$html = '<input type="checkbox" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
600 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
601 |
-
|
602 |
-
echo $html;
|
603 |
-
}
|
604 |
-
|
605 |
-
/**
|
606 |
-
* Checkbox Callback
|
607 |
-
*
|
608 |
-
* Renders checkboxes.
|
609 |
-
*
|
610 |
-
* @since 1.0
|
611 |
-
* @param array $args Arguments passed by the setting
|
612 |
-
* @global $quads_options Array of all the QUADS Options
|
613 |
-
* @return void
|
614 |
-
*/
|
615 |
-
function quads_checkbox_adsense_callback( $args ) {
|
616 |
-
global $quads_options;
|
617 |
-
|
618 |
-
$checked = isset( $quads_options[$args['id']] ) ? checked( 1, $quads_options[$args['id']], false ) : '';
|
619 |
-
$html = '<input type="checkbox" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
620 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
621 |
-
|
622 |
-
return $html;
|
623 |
-
}
|
624 |
-
|
625 |
-
/**
|
626 |
-
* Multicheck Callback
|
627 |
-
*
|
628 |
-
* Renders multiple checkboxes.
|
629 |
-
*
|
630 |
-
* @since 1.0
|
631 |
-
* @param array $args Arguments passed by the setting
|
632 |
-
* @global $quads_options Array of all the QUADS Options
|
633 |
-
* @return void
|
634 |
-
*/
|
635 |
-
function quads_multicheck_callback( $args ) {
|
636 |
-
global $quads_options;
|
637 |
-
|
638 |
-
if( !empty( $args['options'] ) ) {
|
639 |
-
foreach ( $args['options'] as $key => $option ):
|
640 |
-
if( isset( $quads_options[$args['id']][$key] ) ) {
|
641 |
-
$enabled = $option;
|
642 |
-
} else {
|
643 |
-
$enabled = NULL;
|
644 |
-
}
|
645 |
-
echo '<input name="quads_settings[' . $args['id'] . '][' . $key . ']" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . $option . '" ' . checked( $option, $enabled, false ) . '/> ';
|
646 |
-
echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
|
647 |
-
endforeach;
|
648 |
-
echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
|
649 |
-
}
|
650 |
-
}
|
651 |
-
|
652 |
-
/**
|
653 |
-
* Radio Callback
|
654 |
-
*
|
655 |
-
* Renders radio boxes.
|
656 |
-
*
|
657 |
-
* @since 1.3.3
|
658 |
-
* @param array $args Arguments passed by the setting
|
659 |
-
* @global $quads_options Array of all the QUADS Options
|
660 |
-
* @return void
|
661 |
-
*/
|
662 |
-
function quads_radio_callback( $args ) {
|
663 |
-
global $quads_options;
|
664 |
-
|
665 |
-
foreach ( $args['options'] as $key => $option ) :
|
666 |
-
$checked = false;
|
667 |
-
|
668 |
-
if( isset( $quads_options[$args['id']] ) && $quads_options[$args['id']] == $key )
|
669 |
-
$checked = true;
|
670 |
-
elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options[$args['id']] ) )
|
671 |
-
$checked = true;
|
672 |
-
|
673 |
-
echo '<input name="quads_settings[' . $args['id'] . ']"" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
674 |
-
echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
|
675 |
-
endforeach;
|
676 |
-
|
677 |
-
echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
|
678 |
-
}
|
679 |
-
|
680 |
-
/**
|
681 |
-
* Radio Callback for ad types
|
682 |
-
*
|
683 |
-
* Renders radio boxes for specific ads
|
684 |
-
*
|
685 |
-
* @since 1.2.7
|
686 |
-
* @param1 array $args Arguments passed by the setting
|
687 |
-
* @param2 id int ID of the ad
|
688 |
-
*
|
689 |
-
* @global $quads_options Array of all the QUADS Options
|
690 |
-
* @return void
|
691 |
-
*/
|
692 |
-
function quads_adtype_callback( $id, $args ) {
|
693 |
-
global $quads_options;
|
694 |
-
|
695 |
-
foreach ( $args['options'] as $key => $option ) :
|
696 |
-
$checked = false;
|
697 |
-
|
698 |
-
if( isset( $quads_options['ads'][$id]['ad_type'] ) && $quads_options['ads'][$id]['ad_type'] == $key )
|
699 |
-
$checked = true;
|
700 |
-
elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options['ads'][$id]['ad_type'] ) )
|
701 |
-
$checked = true;
|
702 |
-
|
703 |
-
echo '<input name="quads_settings[ads][' . $id . '][ad_type]" class="quads_adsense_type" id="quads_settings[ads][' . $id . '][ad_type_' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
704 |
-
echo '<label for="quads_settings[ads][' . $id . '][ad_type_' . $key . ']">' . $option . '</label> ';
|
705 |
-
endforeach;
|
706 |
-
|
707 |
-
echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
|
708 |
-
}
|
709 |
-
|
710 |
-
/**
|
711 |
-
* Radio Callback for ad positions
|
712 |
-
*
|
713 |
-
* Renders radio boxes for left center right alignment
|
714 |
-
*
|
715 |
-
* @since 1.2.7
|
716 |
-
* @param1 array $args Arguments passed by the setting
|
717 |
-
* @param2 id int ID of the ad
|
718 |
-
*
|
719 |
-
* @global $quads_options Array of all the QUADS Options
|
720 |
-
* @return void
|
721 |
-
*/
|
722 |
-
function quads_adposition_callback( $id, $args ) {
|
723 |
-
global $quads_options;
|
724 |
-
|
725 |
-
foreach ( $args['options'] as $key => $option ) :
|
726 |
-
$checked = false;
|
727 |
-
|
728 |
-
if( isset( $quads_options['ads'][$id]['align'] ) && $quads_options['ads'][$id]['align'] == $key )
|
729 |
-
$checked = true;
|
730 |
-
elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options['ads'][$id]['align'] ) )
|
731 |
-
$checked = true;
|
732 |
-
|
733 |
-
if( $key == '3' ) {
|
734 |
-
echo '<input name="quads_settings[ads][' . $id . '][align]" class="quads_adsense_align" id="quads_settings[ads][' . $id . '][align_' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
735 |
-
echo '<label for="quads_settings[ads][' . $id . '][align_' . $key . ']">Default</label> ';
|
736 |
-
} else {
|
737 |
-
echo '<input name="quads_settings[ads][' . $id . '][align]" class="quads_adsense_positon" id="quads_settings[ads][' . $id . '][align_' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
738 |
-
echo '<label for="quads_settings[ads][' . $id . '][align_' . $key . ']"><img src="' . QUADS_PLUGIN_URL . 'assets/images/align_' . $key . '.png" width="75" height="56"></label> ';
|
739 |
-
}
|
740 |
-
|
741 |
-
endforeach;
|
742 |
-
}
|
743 |
-
|
744 |
-
|
745 |
-
/**
|
746 |
-
* Text Callback
|
747 |
-
*
|
748 |
-
* Renders text fields.
|
749 |
-
*
|
750 |
-
* @since 1.0
|
751 |
-
* @param array $args Arguments passed by the setting
|
752 |
-
* @global $quads_options Array of all the QUADS Options
|
753 |
-
* @return void
|
754 |
-
*/
|
755 |
-
function quads_text_callback( $args ) {
|
756 |
-
global $quads_options;
|
757 |
-
|
758 |
-
if( isset( $quads_options[$args['id']] ) )
|
759 |
-
$value = $quads_options[$args['id']];
|
760 |
-
else
|
761 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
762 |
-
|
763 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
764 |
-
$html = '<input type="text" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
765 |
-
$html .= '<label class="quads_hidden" class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
766 |
-
|
767 |
-
echo $html;
|
768 |
-
}
|
769 |
-
|
770 |
-
/**
|
771 |
-
* Number Callback
|
772 |
-
*
|
773 |
-
* Renders number fields.
|
774 |
-
*
|
775 |
-
* @since 1.9
|
776 |
-
* @param array $args Arguments passed by the setting
|
777 |
-
* @global $quads_options Array of all the QUADS Options
|
778 |
-
* @return void
|
779 |
-
*/
|
780 |
-
function quads_number_callback( $args ) {
|
781 |
-
global $quads_options;
|
782 |
-
|
783 |
-
if( isset( $quads_options[$args['id']] ) )
|
784 |
-
$value = $quads_options[$args['id']];
|
785 |
-
else
|
786 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
787 |
-
|
788 |
-
$max = isset( $args['max'] ) ? $args['max'] : 999999;
|
789 |
-
$min = isset( $args['min'] ) ? $args['min'] : 0;
|
790 |
-
$step = isset( $args['step'] ) ? $args['step'] : 1;
|
791 |
-
|
792 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
793 |
-
$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
794 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
795 |
-
|
796 |
-
echo $html;
|
797 |
-
}
|
798 |
-
|
799 |
-
/**
|
800 |
-
* Textarea Callback
|
801 |
-
*
|
802 |
-
* Renders textarea fields.
|
803 |
-
*
|
804 |
-
* @since 1.0
|
805 |
-
* @param array $args Arguments passed by the setting
|
806 |
-
* @global $quads_options Array of all the QUADS Options
|
807 |
-
* @return void
|
808 |
-
*/
|
809 |
-
function quads_textarea_callback( $args ) {
|
810 |
-
global $quads_options;
|
811 |
-
|
812 |
-
if( isset( $quads_options[$args['id']] ) )
|
813 |
-
$value = $quads_options[$args['id']];
|
814 |
-
else
|
815 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
816 |
-
|
817 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : '40';
|
818 |
-
$html = '<textarea class="large-text quads-textarea" cols="50" rows="' . $size . '" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
819 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
820 |
-
|
821 |
-
echo $html;
|
822 |
-
}
|
823 |
-
|
824 |
-
/**
|
825 |
-
* Password Callback
|
826 |
-
*
|
827 |
-
* Renders password fields.
|
828 |
-
*
|
829 |
-
* @since 1.3
|
830 |
-
* @param array $args Arguments passed by the setting
|
831 |
-
* @global $quads_options Array of all the QUADS Options
|
832 |
-
* @return void
|
833 |
-
*/
|
834 |
-
function quads_password_callback( $args ) {
|
835 |
-
global $quads_options;
|
836 |
-
|
837 |
-
if( isset( $quads_options[$args['id']] ) )
|
838 |
-
$value = $quads_options[$args['id']];
|
839 |
-
else
|
840 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
841 |
-
|
842 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
843 |
-
$html = '<input type="password" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
|
844 |
-
$html .= '<label for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
845 |
-
|
846 |
-
echo $html;
|
847 |
-
}
|
848 |
-
|
849 |
-
/**
|
850 |
-
* Missing Callback
|
851 |
-
*
|
852 |
-
* If a function is missing for settings callbacks alert the user.
|
853 |
-
*
|
854 |
-
* @since 1.3.1
|
855 |
-
* @param array $args Arguments passed by the setting
|
856 |
-
* @return void
|
857 |
-
*/
|
858 |
-
function quads_missing_callback( $args ) {
|
859 |
-
printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'quick-adsense-reloaded' ), $args['id'] );
|
860 |
-
}
|
861 |
-
|
862 |
-
/**
|
863 |
-
* Select Callback
|
864 |
-
*
|
865 |
-
* Renders select fields.
|
866 |
-
*
|
867 |
-
* @since 1.0
|
868 |
-
* @param array $args Arguments passed by the setting
|
869 |
-
* @global $quads_options Array of all the QUADS Options
|
870 |
-
* @return void
|
871 |
-
*/
|
872 |
-
function quads_select_callback( $args ) {
|
873 |
-
global $quads_options;
|
874 |
-
|
875 |
-
if( isset( $quads_options[$args['id']] ) )
|
876 |
-
$value = $quads_options[$args['id']];
|
877 |
-
else
|
878 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
879 |
-
|
880 |
-
$html = '<select id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">';
|
881 |
-
|
882 |
-
foreach ( $args['options'] as $option => $name ) :
|
883 |
-
$selected = selected( $option, $value, false );
|
884 |
-
$html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
885 |
-
endforeach;
|
886 |
-
|
887 |
-
$html .= '</select>';
|
888 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
889 |
-
$html .= '<br>' . $args['desc2'];
|
890 |
-
|
891 |
-
echo $html;
|
892 |
-
}
|
893 |
-
|
894 |
-
/**
|
895 |
-
* AdSense Type Select Callback
|
896 |
-
*
|
897 |
-
* Renders Adsense adsense type fields.
|
898 |
-
*
|
899 |
-
* @since 1.0
|
900 |
-
* @param1 array $args Arguments passed by the setting
|
901 |
-
* @param2 int $id if od the ad
|
902 |
-
* @global $quads_options Array of all the QUADS Options
|
903 |
-
* @return void
|
904 |
-
*/
|
905 |
-
function quads_adense_select_callback( $id, $args ) {
|
906 |
-
global $quads_options;
|
907 |
-
|
908 |
-
if( isset( $quads_options['ads'][$id][$args['id']] ) )
|
909 |
-
$value = $quads_options['ads'][$id][$args['id']];
|
910 |
-
else
|
911 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
912 |
-
|
913 |
-
|
914 |
-
$size = !empty( $args['size'] ) ? $args['size'] : 'quads-medium-size';
|
915 |
-
|
916 |
-
$htmlNew = '<label class="quads_hidden" id="quads-label-' . $args['desc'] . '" for="quads_settings[ads][' . $id . '][' . $args['id'] . ']"> ' . $args['desc'] . ' </label>';
|
917 |
-
$htmlNew .= '<select class="quads-select-' . $args['desc'] . ' ' . $size . '" id="quads_settings[ads][' . $id . '][' . $args['id'] . ']" name="quads_settings[ads][' . $id . '][' . $args['id'] . ']" >';
|
918 |
-
|
919 |
-
foreach ( $args['options'] as $option => $name ) {
|
920 |
-
$selected = selected( $option, $value, false );
|
921 |
-
$htmlNew .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
922 |
-
}
|
923 |
-
|
924 |
-
$htmlNew .= '</select>';
|
925 |
-
echo $htmlNew;
|
926 |
-
}
|
927 |
-
|
928 |
-
/**
|
929 |
-
* Color select Callback
|
930 |
-
*
|
931 |
-
* Renders color select fields.
|
932 |
-
*
|
933 |
-
* @since 2.1.2
|
934 |
-
* @param array $args Arguments passed by the setting
|
935 |
-
* @global $quads_options Array of all the QUADS Options
|
936 |
-
* @return void
|
937 |
-
*/
|
938 |
-
function quads_color_select_callback( $args ) {
|
939 |
-
global $quads_options;
|
940 |
-
|
941 |
-
if( isset( $quads_options[$args['id']] ) )
|
942 |
-
$value = $quads_options[$args['id']];
|
943 |
-
else
|
944 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
945 |
-
|
946 |
-
$html = '<strong>#:</strong><input type="text" style="max-width:80px;border:1px solid #' . esc_attr( stripslashes( $value ) ) . ';border-right:20px solid #' . esc_attr( stripslashes( $value ) ) . ';" id="quads_settings[' . $args['id'] . ']" class="medium-text ' . $args['id'] . '" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
947 |
-
|
948 |
-
$html .= '</select>';
|
949 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
950 |
-
|
951 |
-
echo $html;
|
952 |
-
}
|
953 |
-
|
954 |
-
/**
|
955 |
-
* Rich Editor Callback
|
956 |
-
*
|
957 |
-
* Renders rich editor fields.
|
958 |
-
*
|
959 |
-
* @since 1.0
|
960 |
-
* @param array $args Arguments passed by the setting
|
961 |
-
* @global $quads_options Array of all the QUADS Options
|
962 |
-
* @global $wp_version WordPress Version
|
963 |
-
*/
|
964 |
-
function quads_rich_editor_callback( $args ) {
|
965 |
-
global $quads_options, $wp_version;
|
966 |
-
if( isset( $quads_options[$args['id']] ) )
|
967 |
-
$value = $quads_options[$args['id']];
|
968 |
-
else
|
969 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
970 |
-
|
971 |
-
if( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
|
972 |
-
ob_start();
|
973 |
-
wp_editor( stripslashes( $value ), 'quads_settings_' . $args['id'], array('textarea_name' => 'quads_settings[' . $args['id'] . ']', 'textarea_rows' => $args['textarea_rows']) );
|
974 |
-
$html = ob_get_clean();
|
975 |
-
} else {
|
976 |
-
$html = '<textarea class="large-text quads-richeditor" rows="10" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
977 |
-
}
|
978 |
-
|
979 |
-
$html .= '<br/><label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
980 |
-
|
981 |
-
echo $html;
|
982 |
-
}
|
983 |
-
|
984 |
-
/**
|
985 |
-
* Upload Callback
|
986 |
-
*
|
987 |
-
* Renders upload fields.
|
988 |
-
*
|
989 |
-
* @since 1.0
|
990 |
-
* @param array $args Arguments passed by the setting
|
991 |
-
* @global $quads_options Array of all the QUADS Options
|
992 |
-
* @return void
|
993 |
-
*/
|
994 |
-
function quads_upload_callback( $args ) {
|
995 |
-
global $quads_options;
|
996 |
-
|
997 |
-
if( isset( $quads_options[$args['id']] ) )
|
998 |
-
$value = $quads_options[$args['id']];
|
999 |
-
else
|
1000 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1001 |
-
|
1002 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1003 |
-
$html = '<input type="text" class="' . $size . '-text quads_upload_field" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
1004 |
-
$html .= '<span> <input type="button" class="quads_settings_upload_button button-secondary" value="' . __( 'Upload File', 'quick-adsense-reloaded' ) . '"/></span>';
|
1005 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
1006 |
-
|
1007 |
-
echo $html;
|
1008 |
-
}
|
1009 |
-
|
1010 |
-
|
1011 |
-
/**
|
1012 |
-
* Check if extra settings are available and activated
|
1013 |
-
*
|
1014 |
-
* @return boolean
|
1015 |
-
*/
|
1016 |
-
function quads_is_extra() {
|
1017 |
-
|
1018 |
-
if( !function_exists( 'quads_extra' ) ) {
|
1019 |
-
return false;
|
1020 |
-
}
|
1021 |
-
|
1022 |
-
$lic = get_option( 'quads_wp_quads_pro_license_active' );
|
1023 |
-
|
1024 |
-
if (!$lic){
|
1025 |
-
return false;
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
if (isset($lic->error) && $lic->error === 'expired'){
|
1029 |
-
return true;
|
1030 |
-
}
|
1031 |
-
|
1032 |
-
if (isset($lic->license) && $lic->license === 'valid'){
|
1033 |
-
return true;
|
1034 |
-
}
|
1035 |
-
|
1036 |
-
if (isset($lic->license) && $lic->license === 'inactive'){
|
1037 |
-
return false;
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
|
1041 |
-
// if( !$lic || (is_object( $lic ) && $lic->success !== true) ) {
|
1042 |
-
// return false;
|
1043 |
-
// }
|
1044 |
-
|
1045 |
-
return false;
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
/**
|
1049 |
-
* Color picker Callback
|
1050 |
-
*
|
1051 |
-
* Renders color picker fields.
|
1052 |
-
*
|
1053 |
-
* @since 1.6
|
1054 |
-
* @param array $args Arguments passed by the setting
|
1055 |
-
* @global $quads_options Array of all the QUADS Options
|
1056 |
-
* @return void
|
1057 |
-
*/
|
1058 |
-
function quads_color_callback( $args ) {
|
1059 |
-
global $quads_options;
|
1060 |
-
|
1061 |
-
if( isset( $quads_options[$args['id']] ) )
|
1062 |
-
$value = $quads_options[$args['id']];
|
1063 |
-
else
|
1064 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1065 |
-
|
1066 |
-
$default = isset( $args['std'] ) ? $args['std'] : '';
|
1067 |
-
|
1068 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1069 |
-
$html = '<input type="text" class="quads-color-picker" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
|
1070 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
1071 |
-
|
1072 |
-
echo $html;
|
1073 |
-
}
|
1074 |
-
|
1075 |
-
/**
|
1076 |
-
* Registers the license field callback
|
1077 |
-
*
|
1078 |
-
* @since 3.0.0
|
1079 |
-
* @param array $args Arguments passed by the setting
|
1080 |
-
* @global $quads_options Array of all the QUADS options
|
1081 |
-
* @return void
|
1082 |
-
*/
|
1083 |
-
if( !function_exists( 'quads_license_key_callback' ) ) {
|
1084 |
-
|
1085 |
-
function quads_license_key_callback( $args ) {
|
1086 |
-
global $quads_options;
|
1087 |
-
|
1088 |
-
$class = '';
|
1089 |
-
|
1090 |
-
$messages = array();
|
1091 |
-
$license = get_option( $args['options']['is_valid_license_option'] );
|
1092 |
-
|
1093 |
-
|
1094 |
-
if( isset( $quads_options[$args['id']] ) ) {
|
1095 |
-
$value = $quads_options[$args['id']];
|
1096 |
-
} else {
|
1097 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1098 |
-
}
|
1099 |
-
|
1100 |
-
if( !empty( $license ) && is_object( $license ) ) {
|
1101 |
-
|
1102 |
-
|
1103 |
-
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
1104 |
-
if( false === $license->success ) {
|
1105 |
-
|
1106 |
-
switch ( $license->error ) {
|
1107 |
-
|
1108 |
-
case 'expired' :
|
1109 |
-
|
1110 |
-
$class = 'error';
|
1111 |
-
$messages[] = sprintf(
|
1112 |
-
__( 'Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=license_tab&utm_medium=admin&utm_content=license-expired'
|
1113 |
-
);
|
1114 |
-
|
1115 |
-
$license_status = 'quads-license-' . $class . '-notice';
|
1116 |
-
|
1117 |
-
break;
|
1118 |
-
|
1119 |
-
case 'missing' :
|
1120 |
-
|
1121 |
-
$class = 'error';
|
1122 |
-
$messages[] = sprintf(
|
1123 |
-
__( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'quick-adsense-reloaded' ), 'http://wpquads.com/your-account?utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license&utm_campaign=notice'
|
1124 |
-
);
|
1125 |
-
|
1126 |
-
$license_status = 'quads-license-' . $class . '-notice';
|
1127 |
-
|
1128 |
-
break;
|
1129 |
-
|
1130 |
-
case 'invalid' :
|
1131 |
-
case 'site_inactive' :
|
1132 |
-
|
1133 |
-
$class = 'error';
|
1134 |
-
$messages[] = sprintf(
|
1135 |
-
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'quick-adsense-reloaded' ), $args['name'], 'http://wpquads.com/your-account?utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license'
|
1136 |
-
);
|
1137 |
-
|
1138 |
-
$license_status = 'quads-license-' . $class . '-notice';
|
1139 |
-
|
1140 |
-
break;
|
1141 |
-
|
1142 |
-
case 'item_name_mismatch' :
|
1143 |
-
|
1144 |
-
$class = 'error';
|
1145 |
-
$messages[] = sprintf( __( 'This is not a %s.', 'quick-adsense-reloaded' ), $args['name'] );
|
1146 |
-
|
1147 |
-
$license_status = 'quads-license-' . $class . '-notice';
|
1148 |
-
|
1149 |
-
break;
|
1150 |
-
|
1151 |
-
case 'no_activations_left':
|
1152 |
-
|
1153 |
-
$class = 'error';
|
1154 |
-
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s" target="_blank">View possible upgrades</a> now.', 'quick-adsense-reloaded' ), 'http://wpquads.com/your-account?utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license' );
|
1155 |
-
|
1156 |
-
$license_status = 'quads-license-' . $class . '-notice';
|
1157 |
-
|
1158 |
-
break;
|
1159 |
-
}
|
1160 |
-
|
1161 |
-
} else {
|
1162 |
-
|
1163 |
-
switch ( $license->license ) {
|
1164 |
-
|
1165 |
-
case 'valid' :
|
1166 |
-
default:
|
1167 |
-
|
1168 |
-
$class = 'valid';
|
1169 |
-
|
1170 |
-
$now = current_time( 'timestamp' );
|
1171 |
-
$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
|
1172 |
-
|
1173 |
-
if( 'lifetime' === $license->expires ) {
|
1174 |
-
|
1175 |
-
$messages[] = __( 'License key never expires.', 'quick-adsense-reloaded' );
|
1176 |
-
|
1177 |
-
$license_status = 'quads-license-lifetime-notice';
|
1178 |
-
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
1179 |
-
|
1180 |
-
$messages[] = sprintf(
|
1181 |
-
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
|
1182 |
-
);
|
1183 |
-
|
1184 |
-
$license_status = 'quads-license-expires-soon-notice';
|
1185 |
-
} else {
|
1186 |
-
|
1187 |
-
$messages[] = sprintf(
|
1188 |
-
__( 'Your license key expires on %s.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
1189 |
-
);
|
1190 |
-
|
1191 |
-
$license_status = 'quads-license-expiration-date-notice';
|
1192 |
-
}
|
1193 |
-
break;
|
1194 |
-
|
1195 |
-
case 'inactive' :
|
1196 |
-
$messages[] = sprintf(
|
1197 |
-
__( 'Your license key has been disabled! <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
|
1198 |
-
);
|
1199 |
-
$license_status = 'quads-license-error-notice';
|
1200 |
-
break;
|
1201 |
-
}
|
1202 |
-
}
|
1203 |
-
|
1204 |
-
// switch ( $license->license ) {
|
1205 |
-
// case 'invalid' :
|
1206 |
-
// $messages[] = sprintf(
|
1207 |
-
// __( 'Your license key has been disabled! <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
|
1208 |
-
// );
|
1209 |
-
// break;
|
1210 |
-
// }
|
1211 |
-
|
1212 |
-
} else {
|
1213 |
-
$license_status = null;
|
1214 |
-
|
1215 |
-
}
|
1216 |
-
|
1217 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1218 |
-
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']" name="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
|
1219 |
-
|
1220 |
-
if( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) {
|
1221 |
-
$html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'quick-adsense-reloaded' ) . '"/>';
|
1222 |
-
}
|
1223 |
-
|
1224 |
-
$html .= '<label for="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1225 |
-
|
1226 |
-
if( !empty( $messages ) ) {
|
1227 |
-
foreach ( $messages as $message ) {
|
1228 |
-
|
1229 |
-
$html .= '<div class="quads-license-data quads-license-' . $class . '">';
|
1230 |
-
$html .= '<p>' . $message . '</p>';
|
1231 |
-
$html .= '</div>';
|
1232 |
-
}
|
1233 |
-
}
|
1234 |
-
|
1235 |
-
wp_nonce_field( quads_sanitize_key( $args['id'] ) . '-nonce', quads_sanitize_key( $args['id'] ) . '-nonce' );
|
1236 |
-
|
1237 |
-
if( isset( $license_status ) ) {
|
1238 |
-
echo '<div class="' . $license_status . '">' . $html . '</div>';
|
1239 |
-
} else {
|
1240 |
-
echo '<div class="quads-license-null">' . $html . '</div>';
|
1241 |
-
}
|
1242 |
-
}
|
1243 |
-
|
1244 |
-
}
|
1245 |
-
|
1246 |
-
/**
|
1247 |
-
* Registers the Add-Ons field callback for WPQUADS Add-Ons
|
1248 |
-
*
|
1249 |
-
* @since 2.0.5
|
1250 |
-
* @param array $args Arguments passed by the setting
|
1251 |
-
* @return html
|
1252 |
-
*/
|
1253 |
-
function quads_addons_callback( $args ) {
|
1254 |
-
$html = quads_add_ons_page();
|
1255 |
-
echo $html;
|
1256 |
-
}
|
1257 |
-
|
1258 |
-
/**
|
1259 |
-
* Registers the im/export callback for WPQUADS
|
1260 |
-
*
|
1261 |
-
* @since 0.9.0
|
1262 |
-
* @param array $args Arguments passed by the setting
|
1263 |
-
* @return html
|
1264 |
-
*/
|
1265 |
-
function quads_imexport_callback( $args ) {
|
1266 |
-
$html = quads_tools_import_export_display();
|
1267 |
-
$html .= quads_import_quick_adsense_settings();
|
1268 |
-
echo $html;
|
1269 |
-
}
|
1270 |
-
|
1271 |
-
/**
|
1272 |
-
* Registers the system info for WPQUADS
|
1273 |
-
*
|
1274 |
-
* @since 0.9.0
|
1275 |
-
* @param array $args Arguments passed by the setting
|
1276 |
-
* @return html
|
1277 |
-
*/
|
1278 |
-
function quads_systeminfo_callback( $args ) {
|
1279 |
-
$html = quads_tools_sysinfo_display();
|
1280 |
-
echo $html;
|
1281 |
-
}
|
1282 |
-
|
1283 |
-
/**
|
1284 |
-
* Registers the image upload field
|
1285 |
-
*
|
1286 |
-
* @since 1.0
|
1287 |
-
* @param array $args Arguments passed by the setting
|
1288 |
-
* @global $quads_options Array of all the QUADS Options
|
1289 |
-
* @return void
|
1290 |
-
*/
|
1291 |
-
function quads_upload_image_callback( $args ) {
|
1292 |
-
global $quads_options;
|
1293 |
-
|
1294 |
-
if( isset( $quads_options[$args['id']] ) )
|
1295 |
-
$value = $quads_options[$args['id']];
|
1296 |
-
else
|
1297 |
-
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1298 |
-
|
1299 |
-
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1300 |
-
$html = '<input type="text" class="' . $size . '-text ' . $args['id'] . '" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
|
1301 |
-
|
1302 |
-
$html .= '<input type="submit" class="button-secondary quads_upload_image" name="' . $args['id'] . '_upload" value="' . __( 'Select Image', 'quick-adsense-reloaded' ) . '"/>';
|
1303 |
-
|
1304 |
-
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
1305 |
-
|
1306 |
-
echo $html;
|
1307 |
-
}
|
1308 |
-
|
1309 |
-
/*
|
1310 |
-
* Note Callback
|
1311 |
-
*
|
1312 |
-
* Show a note
|
1313 |
-
*
|
1314 |
-
* @since 2.2.8
|
1315 |
-
* @param array $args Arguments passed by the setting
|
1316 |
-
* @return void
|
1317 |
-
*
|
1318 |
-
*/
|
1319 |
-
|
1320 |
-
function quads_note_callback( $args ) {
|
1321 |
-
global $quads_options;
|
1322 |
-
$html = '';
|
1323 |
-
echo $html;
|
1324 |
-
}
|
1325 |
-
|
1326 |
-
/**
|
1327 |
-
* Additional content Callback
|
1328 |
-
* Adds several content text boxes selectable via jQuery easytabs()
|
1329 |
-
*
|
1330 |
-
* @param array $args
|
1331 |
-
* @return string $html
|
1332 |
-
* @scince 2.3.2
|
1333 |
-
*/
|
1334 |
-
function quads_add_content_callback( $args ) {
|
1335 |
-
global $quads_options;
|
1336 |
-
|
1337 |
-
$html = '<div id="quadstabcontainer" class="tabcontent_container"><ul class="quadstabs" style="width:99%;max-width:500px;">';
|
1338 |
-
foreach ( $args['options'] as $option => $name ) :
|
1339 |
-
$html .= '<li class="quadstab" style="float:left;margin-right:4px;"><a href="#' . $name['id'] . '">' . $name['name'] . '</a></li>';
|
1340 |
-
endforeach;
|
1341 |
-
$html .= '</ul>';
|
1342 |
-
$html .= '<div class="quadstab-container">';
|
1343 |
-
foreach ( $args['options'] as $option => $name ) :
|
1344 |
-
$value = isset( $quads_options[$name['id']] ) ? $quads_options[$name['id']] : '';
|
1345 |
-
$textarea = '<textarea class="large-text quads-textarea" cols="50" rows="15" id="quads_settings[' . $name['id'] . ']" name="quads_settings[' . $name['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
1346 |
-
$html .= '<div id="' . $name['id'] . '" style="max-width:500px;"><span style="padding-top:60px;display:block;">' . $name['desc'] . ':</span><br>' . $textarea . '</div>';
|
1347 |
-
endforeach;
|
1348 |
-
$html .= '</div>';
|
1349 |
-
$html .= '</div>';
|
1350 |
-
echo $html;
|
1351 |
-
}
|
1352 |
-
|
1353 |
-
/**
|
1354 |
-
* Hook Callback
|
1355 |
-
*
|
1356 |
-
* Adds a do_action() hook in place of the field
|
1357 |
-
*
|
1358 |
-
* @since 1.0.8.2
|
1359 |
-
* @param array $args Arguments passed by the setting
|
1360 |
-
* @return void
|
1361 |
-
*/
|
1362 |
-
function quads_hook_callback( $args ) {
|
1363 |
-
do_action( 'quads_' . $args['id'] );
|
1364 |
-
}
|
1365 |
-
|
1366 |
-
/**
|
1367 |
-
* Set manage_options as the cap required to save QUADS settings pages
|
1368 |
-
*
|
1369 |
-
* @since 1.9
|
1370 |
-
* @return string capability required
|
1371 |
-
*/
|
1372 |
-
function quads_set_settings_cap() {
|
1373 |
-
return 'manage_options';
|
1374 |
-
}
|
1375 |
-
|
1376 |
-
add_filter( 'option_page_capability_quads_settings', 'quads_set_settings_cap' );
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
/* returns Cache Status if enabled or disabled
|
1382 |
-
*
|
1383 |
-
* @since 2.0.4
|
1384 |
-
* @return string
|
1385 |
-
*/
|
1386 |
-
|
1387 |
-
function quads_cache_status() {
|
1388 |
-
global $quads_options;
|
1389 |
-
if( isset( $quads_options['disable_cache'] ) ) {
|
1390 |
-
return ' <strong style="color:red;">' . __( 'Transient Cache disabled! Enable it for performance increase.', 'quick-adsense-reloaded' ) . '</strong> ';
|
1391 |
-
}
|
1392 |
-
}
|
1393 |
-
|
1394 |
-
/* Permission check if logfile is writable
|
1395 |
-
*
|
1396 |
-
* @since 2.0.6
|
1397 |
-
* @return string
|
1398 |
-
*/
|
1399 |
-
|
1400 |
-
function quads_log_permissions() {
|
1401 |
-
global $quads_options;
|
1402 |
-
if( !$quads->logger->checkDir() ) {
|
1403 |
-
return '<br><strong style="color:red;">' . __( 'Log file directory not writable! Set FTP permission to 755 or 777 for /wp-content/plugins/quadssharer/logs/', 'quick-adsense-reloaded' ) . '</strong> <br> Read here more about <a href="http://codex.wordpress.org/Changing_File_Permissions" target="_blank">file permissions</a> ';
|
1404 |
-
}
|
1405 |
-
}
|
1406 |
-
|
1407 |
-
/**
|
1408 |
-
* Get number of available ads
|
1409 |
-
*
|
1410 |
-
* @global $quads_options $quads_options
|
1411 |
-
* @return array
|
1412 |
-
*/
|
1413 |
-
function quads_get_ads() {
|
1414 |
-
global $quads_options;
|
1415 |
-
|
1416 |
-
if (!isset($quads_options['ads']) || ( isset($quads_options['ads']) && count( $quads_options['ads'] ) === 0) ) {
|
1417 |
-
$ads = array(
|
1418 |
-
0 => __( 'Random Ads', 'quick-adsense-reloaded' ),
|
1419 |
-
1 => isset( $quads_options['ads']['ad1']['label'] ) ? $quads_options['ads']['ad1']['label'] : 'ad1',
|
1420 |
-
2 => isset( $quads_options['ads']['ad2']['label'] ) ? $quads_options['ads']['ad2']['label'] : 'ad2',
|
1421 |
-
3 => isset( $quads_options['ads']['ad3']['label'] ) ? $quads_options['ads']['ad3']['label'] : 'ad3',
|
1422 |
-
4 => isset( $quads_options['ads']['ad4']['label'] ) ? $quads_options['ads']['ad4']['label'] : 'ad4',
|
1423 |
-
5 => isset( $quads_options['ads']['ad5']['label'] ) ? $quads_options['ads']['ad5']['label'] : 'ad5',
|
1424 |
-
6 => isset( $quads_options['ads']['ad6']['label'] ) ? $quads_options['ads']['ad6']['label'] : 'ad6',
|
1425 |
-
7 => isset( $quads_options['ads']['ad7']['label'] ) ? $quads_options['ads']['ad7']['label'] : 'ad7',
|
1426 |
-
8 => isset( $quads_options['ads']['ad8']['label'] ) ? $quads_options['ads']['ad8']['label'] : 'ad8',
|
1427 |
-
9 => isset( $quads_options['ads']['ad9']['label'] ) ? $quads_options['ads']['ad9']['label'] : 'ad9',
|
1428 |
-
10 => isset( $quads_option['ads']['ad10']['label'] ) ? $quads_options['ads']['ad10']['label'] : 'ad10',
|
1429 |
-
);
|
1430 |
-
return $ads;
|
1431 |
-
}
|
1432 |
-
|
1433 |
-
// Start array with
|
1434 |
-
$arrHeader = array ( 0 => __( 'Random Ads', 'quick-adsense-reloaded' ) );
|
1435 |
-
|
1436 |
-
$ads = array();
|
1437 |
-
|
1438 |
-
foreach ( $quads_options['ads'] as $key => $value ){
|
1439 |
-
// Skip all widget ads
|
1440 |
-
if ( false !== strpos($key, '_widget') ){
|
1441 |
-
continue;
|
1442 |
-
}
|
1443 |
-
// Create array
|
1444 |
-
if (!empty( $value['label'] ) ) {
|
1445 |
-
$ads[] = $value['label'];
|
1446 |
-
} else {
|
1447 |
-
$ads[] = $key;
|
1448 |
-
}
|
1449 |
-
|
1450 |
-
}
|
1451 |
-
|
1452 |
-
return array_merge($arrHeader, $ads);
|
1453 |
-
|
1454 |
-
// $ads = array(
|
1455 |
-
// 0 => __( 'Random Ads', 'quick-adsense-reloaded' ),
|
1456 |
-
// 1 => isset( $quads_options['ads']['ad1']['label'] ) ? $quads_options['ads']['ad1']['label'] : 'ad1',
|
1457 |
-
// 2 => isset( $quads_options['ads']['ad2']['label'] ) ? $quads_options['ads']['ad2']['label'] : 'ad2',
|
1458 |
-
// 3 => isset( $quads_options['ads']['ad3']['label'] ) ? $quads_options['ads']['ad3']['label'] : 'ad3',
|
1459 |
-
// 4 => isset( $quads_options['ads']['ad4']['label'] ) ? $quads_options['ads']['ad4']['label'] : 'ad4',
|
1460 |
-
// 5 => isset( $quads_options['ads']['ad5']['label'] ) ? $quads_options['ads']['ad5']['label'] : 'ad5',
|
1461 |
-
// 6 => isset( $quads_options['ads']['ad6']['label'] ) ? $quads_options['ads']['ad6']['label'] : 'ad6',
|
1462 |
-
// 7 => isset( $quads_options['ads']['ad7']['label'] ) ? $quads_options['ads']['ad7']['label'] : 'ad7',
|
1463 |
-
// 8 => isset( $quads_options['ads']['ad8']['label'] ) ? $quads_options['ads']['ad8']['label'] : 'ad8',
|
1464 |
-
// 9 => isset( $quads_options['ads']['ad9']['label'] ) ? $quads_options['ads']['ad9']['label'] : 'ad9',
|
1465 |
-
// 10 => isset( $quads_option['ads']['ad10']['label'] ) ? $quads_options['ads']['ad10']['label'] : 'ad10',
|
1466 |
-
// );
|
1467 |
-
//return $ads;
|
1468 |
-
}
|
1469 |
-
|
1470 |
-
/**
|
1471 |
-
* Get array of 1 to 50 for image and paragraph dropdown values
|
1472 |
-
*
|
1473 |
-
* @global $quads_options $quads_options
|
1474 |
-
* @return array
|
1475 |
-
*/
|
1476 |
-
function quads_get_values() {
|
1477 |
-
|
1478 |
-
$array = array(1);
|
1479 |
-
for ( $i = 1; $i <= 50; $i++ ) {
|
1480 |
-
$array[] = $i;
|
1481 |
-
}
|
1482 |
-
unset( $array[0] ); // remove the 0 and start the array with 1
|
1483 |
-
return $array;
|
1484 |
-
}
|
1485 |
-
|
1486 |
-
/**
|
1487 |
-
* Visibility Callback
|
1488 |
-
*
|
1489 |
-
* Renders fields for ad visibility
|
1490 |
-
*
|
1491 |
-
* @since 0.9.0
|
1492 |
-
* @param array $args Arguments passed by the setting
|
1493 |
-
* @global $quads_options Array of all the QUADS Options
|
1494 |
-
* @return void
|
1495 |
-
*/
|
1496 |
-
function quads_visibility_callback( $args ) {
|
1497 |
-
global $quads_options, $quads;
|
1498 |
-
|
1499 |
-
$html = $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppHome]', 'current' => !empty( $quads_options['visibility']['AppHome'] ) ? $quads_options['visibility']['AppHome'] : null, 'class' => 'quads-checkbox') ) . __( 'Homepage ', 'quick-adsense-reloaded' );
|
1500 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppCate]', 'current' => !empty( $quads_options['visibility']['AppCate'] ) ? $quads_options['visibility']['AppCate'] : null, 'class' => 'quads-checkbox') ) . __( 'Categories ', 'quick-adsense-reloaded' );
|
1501 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppArch]', 'current' => !empty( $quads_options['visibility']['AppArch'] ) ? $quads_options['visibility']['AppArch'] : null, 'class' => 'quads-checkbox') ) . __( 'Archives ', 'quick-adsense-reloaded' );
|
1502 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppTags]', 'current' => !empty( $quads_options['visibility']['AppTags'] ) ? $quads_options['visibility']['AppTags'] : null, 'class' => 'quads-checkbox') ) . __( 'Tags', 'quick-adsense-reloaded' ) . '<br>';
|
1503 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppSide]', 'current' => !empty( $quads_options['visibility']['AppSide'] ) ? $quads_options['visibility']['AppSide'] : null, 'class' => 'quads-checkbox') ) . __( 'Hide Ad Widgets on Homepage', 'quick-adsense-reloaded' ) . '<br>';
|
1504 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppLogg]', 'current' => !empty( $quads_options['visibility']['AppLogg'] ) ? $quads_options['visibility']['AppLogg'] : null, 'class' => 'quads-checkbox') ) . __( 'Hide Ads when user is logged in.', 'quick-adsense-reloaded' ) . '<br>';
|
1505 |
-
|
1506 |
-
echo $html;
|
1507 |
-
}
|
1508 |
-
|
1509 |
-
/**
|
1510 |
-
* Ad position Callback
|
1511 |
-
*
|
1512 |
-
* Renders multioptions fields for ad position
|
1513 |
-
*
|
1514 |
-
* @since 0.9.0
|
1515 |
-
* @param array $args Arguments passed by the setting
|
1516 |
-
* @global $quads_options Array of all the QUADS Options
|
1517 |
-
* @return void
|
1518 |
-
*/
|
1519 |
-
function quads_ad_position_callback( $args ) {
|
1520 |
-
global $quads_options, $quads;
|
1521 |
-
|
1522 |
-
|
1523 |
-
// Pos 1
|
1524 |
-
$html = $quads->html->checkbox( array('name' => 'quads_settings[pos1][BegnAds]', 'current' => !empty( $quads_options['pos1']['BegnAds'] ) ? $quads_options['pos1']['BegnAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1525 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1526 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos1][BegnRnd]', 'name' => 'quads_settings[pos1][BegnRnd]', 'selected' => !empty( $quads_options['pos1']['BegnRnd'] ) ? $quads_options['pos1']['BegnRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1527 |
-
$html .= ' ' . __( 'to <strong>Beginning of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1528 |
-
|
1529 |
-
// Pos 2
|
1530 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos2][MiddAds]', 'current' => !empty( $quads_options['pos2']['MiddAds'] ) ? $quads_options['pos2']['MiddAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1531 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1532 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos2][MiddRnd]', 'name' => 'quads_settings[pos2][MiddRnd]', 'selected' => !empty( $quads_options['pos2']['MiddRnd'] ) ? $quads_options['pos2']['MiddRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1533 |
-
$html .= ' ' . __( 'to <strong>Middle of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1534 |
-
|
1535 |
-
// Pos 3
|
1536 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos3][EndiAds]', 'current' => !empty( $quads_options['pos3']['EndiAds'] ) ? $quads_options['pos3']['EndiAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1537 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1538 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos3][EndiRnd]', 'name' => 'quads_settings[pos3][EndiRnd]', 'selected' => !empty( $quads_options['pos3']['EndiRnd'] ) ? $quads_options['pos3']['EndiRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1539 |
-
$html .= ' ' . __( 'to <strong>End of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1540 |
-
|
1541 |
-
// Pos 4
|
1542 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos4][MoreAds]', 'current' => !empty( $quads_options['pos4']['MoreAds'] ) ? $quads_options['pos4']['MoreAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1543 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1544 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos4][MoreRnd]', 'name' => 'quads_settings[pos4][MoreRnd]', 'selected' => !empty( $quads_options['pos4']['MoreRnd'] ) ? $quads_options['pos4']['MoreRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1545 |
-
$html .= ' ' . __( 'right after <strong>the <span style="font-family:Courier New,Courier,Fixed;"><!--more--></span> tag</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1546 |
-
|
1547 |
-
// Pos 5
|
1548 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos5][LapaAds]', 'current' => !empty( $quads_options['pos5']['LapaAds'] ) ? $quads_options['pos5']['LapaAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1549 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1550 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos5][LapaRnd]', 'name' => 'quads_settings[pos5][LapaRnd]', 'selected' => !empty( $quads_options['pos5']['LapaRnd'] ) ? $quads_options['pos5']['LapaRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1551 |
-
$html .= ' ' . __( 'right before <strong>the last Paragraph</strong>', 'quick-adsense-reloaded' ) . ' </br>';
|
1552 |
-
|
1553 |
-
// Pos 6
|
1554 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos6][Par1Ads]', 'current' => !empty( $quads_options['pos6']['Par1Ads'] ) ? $quads_options['pos6']['Par1Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1555 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1556 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos6][Par1Rnd]', 'name' => 'quads_settings[pos6][Par1Rnd]', 'selected' => !empty( $quads_options['pos6']['Par1Rnd'] ) ? $quads_options['pos6']['Par1Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1557 |
-
$html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1558 |
-
$html .= $quads->html->select( array('options' => quads_get_values(), 'class' => 'quads-paragraph', 'id' => 'quads_settings[pos6][Par1Nup]', 'name' => 'quads_settings[pos6][Par1Nup]', 'selected' => !empty( $quads_options['pos6']['Par1Nup'] ) ? $quads_options['pos6']['Par1Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1559 |
-
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1560 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos6][Par1Con]', 'current' => !empty( $quads_options['pos6']['Par1Con'] ) ? $quads_options['pos6']['Par1Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1561 |
-
$html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
|
1562 |
-
|
1563 |
-
// Pos 7
|
1564 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos7][Par2Ads]', 'current' => !empty( $quads_options['pos7']['Par2Ads'] ) ? $quads_options['pos7']['Par2Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1565 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1566 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos7][Par2Rnd]', 'name' => 'quads_settings[pos7][Par2Rnd]', 'selected' => !empty( $quads_options['pos7']['Par2Rnd'] ) ? $quads_options['pos7']['Par2Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1567 |
-
$html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1568 |
-
$html .= $quads->html->select( array('options' => quads_get_values(), 'id' => 'quads_settings[pos7][Par2Nup]', 'name' => 'quads_settings[pos7][Par2Nup]', 'selected' => !empty( $quads_options['pos7']['Par2Nup'] ) ? $quads_options['pos7']['Par2Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1569 |
-
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1570 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos7][Par2Con]', 'current' => !empty( $quads_options['pos7']['Par2Con'] ) ? $quads_options['pos7']['Par2Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1571 |
-
$html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
|
1572 |
-
|
1573 |
-
// Pos 8
|
1574 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos8][Par3Ads]', 'current' => !empty( $quads_options['pos8']['Par3Ads'] ) ? $quads_options['pos8']['Par3Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1575 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1576 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos8][Par3Rnd]', 'name' => 'quads_settings[pos8][Par3Rnd]', 'selected' => !empty( $quads_options['pos8']['Par3Rnd'] ) ? $quads_options['pos8']['Par3Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1577 |
-
$html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1578 |
-
$html .= $quads->html->select( array('options' => quads_get_values(), 'id' => 'quads_settings[pos8][Par3Nup]', 'name' => 'quads_settings[pos8][Par3Nup]', 'selected' => !empty( $quads_options['pos8']['Par3Nup'] ) ? $quads_options['pos8']['Par3Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1579 |
-
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1580 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos8][Par3Con]', 'current' => !empty( $quads_options['pos8']['Par3Con'] ) ? $quads_options['pos8']['Par3Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1581 |
-
$html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
|
1582 |
-
|
1583 |
-
$html .= apply_filters( 'quads_extra_paragraph', '' );
|
1584 |
-
|
1585 |
-
// Pos 9
|
1586 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos9][Img1Ads]', 'current' => !empty( $quads_options['pos9']['Img1Ads'] ) ? $quads_options['pos9']['Img1Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1587 |
-
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1588 |
-
$html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos9][Img1Rnd]', 'selected' => !empty( $quads_options['pos9']['Img1Rnd'] ) ? $quads_options['pos9']['Img1Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1589 |
-
$html .= ' ' . __( '<strong>After Image</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1590 |
-
$html .= $quads->html->select( array('options' => quads_get_values(), 'id' => 'quads_settings[pos9][Img1Nup]', 'name' => 'quads_settings[pos9][Img1Nup]', 'selected' => !empty( $quads_options['pos9']['Img1Nup'] ) ? $quads_options['pos9']['Img1Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1591 |
-
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1592 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos9][Img1Con]', 'current' => !empty( $quads_options['pos9']['Img1Con'] ) ? $quads_options['pos9']['Img1Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1593 |
-
$html .= ' ' . __( 'after <b>Image\'s outer</b><b><span style="font-family:Courier New,Courier,Fixed;"> <div> wp-caption</span></b> if any.', 'quick-adsense-reloaded' ) . ' </br>';
|
1594 |
-
|
1595 |
-
echo apply_filters( 'quads_ad_position_callback', $html );
|
1596 |
-
}
|
1597 |
-
|
1598 |
-
/**
|
1599 |
-
* Quicktags Callback
|
1600 |
-
*
|
1601 |
-
* Renders quicktags fields
|
1602 |
-
*
|
1603 |
-
* @since 0.9.0
|
1604 |
-
* @param array $args Arguments passed by the setting
|
1605 |
-
* @global $quads_options Array of all the QUADS Options
|
1606 |
-
* @return void
|
1607 |
-
*/
|
1608 |
-
function quads_quicktags_callback( $args ) {
|
1609 |
-
global $quads_options, $quads;
|
1610 |
-
|
1611 |
-
// Quicktags info
|
1612 |
-
$html = '<div style="margin-bottom:5px;"><strong>Optional: </strong><a href="#" id="quads_insert_ads_action">' . __( ' Insert Ads into a post, on-the-fly', 'quick-adsense-reloaded' ) . '</a></br>' .
|
1613 |
-
'<ol style="margin-top:5px;display:none;" id="quads_insert_ads_box">
|
1614 |
-
<li>' . __( 'Insert <span class="quads-quote-docs"><!--Ads1--></span>, <span class="quads-quote-docs"><!--Ads2--></span>, etc. into a post to show the <b>Particular Ads</b> at specific location.', 'quick-adsense-reloaded' ) . '</li>
|
1615 |
-
<li>' . __( 'Insert <span class="quads-quote-docs"><!--RndAds--></span> into a post to show the <b>Random Ads</b> at specific location', 'quick-adsense-reloaded' ) . '</li>
|
1616 |
-
</ol></div>';
|
1617 |
-
|
1618 |
-
$html .= $quads->html->checkbox( array('name' => 'quads_settings[quicktags][QckTags]', 'current' => !empty( $quads_options['quicktags']['QckTags'] ) ? $quads_options['quicktags']['QckTags'] : null, 'class' => 'quads-checkbox') );
|
1619 |
-
$html .= __( 'Show Quicktag Buttons on the HTML Post Editor', 'quick-adsense-reloaded' ) . '</br>';
|
1620 |
-
$html .= '<span class="quads-desc">' . __( 'Tags can be inserted into a post via the additional Quicktag Buttons at the HTML Edit Post SubPanel.', 'quick-adsense-reloaded' ) . '</span>';
|
1621 |
-
echo $html;
|
1622 |
-
}
|
1623 |
-
|
1624 |
-
/**
|
1625 |
-
* Add new ad
|
1626 |
-
* @global array $quads_options
|
1627 |
-
*/
|
1628 |
-
function quads_ajax_add_ads(){
|
1629 |
-
global $quads_options;
|
1630 |
-
|
1631 |
-
$postCount = !empty($_POST['count']) ? $_POST['count'] : 1;
|
1632 |
-
//wp_die($postCount);
|
1633 |
-
|
1634 |
-
$count = isset($quads_options['ads']) ? count ($quads_options['ads']) + $postCount : 10 + $postCount;
|
1635 |
-
|
1636 |
-
|
1637 |
-
$args = array();
|
1638 |
-
// subtract 10 widget ads
|
1639 |
-
//$args['id'] = $count-10;
|
1640 |
-
$args['id'] = $count-getTotalWidgets();
|
1641 |
-
$args['name'] = 'Ad ' . $args['id'];
|
1642 |
-
|
1643 |
-
ob_start();
|
1644 |
-
// ... get the content ...
|
1645 |
-
quads_adsense_code_callback( $args );
|
1646 |
-
$content = ob_get_contents();
|
1647 |
-
ob_end_clean();
|
1648 |
-
|
1649 |
-
$html = '<tr><td>';
|
1650 |
-
$html.= $content;
|
1651 |
-
$html.= '</td></tr>';
|
1652 |
-
echo $html;
|
1653 |
-
die();
|
1654 |
-
}
|
1655 |
-
add_action( 'wp_ajax_quads_ajax_add_ads', 'quads_ajax_add_ads' );
|
1656 |
-
|
1657 |
-
/**
|
1658 |
-
* Get the total amount of widget ads
|
1659 |
-
* @global $quads_options $quads_options
|
1660 |
-
* @return int
|
1661 |
-
*/
|
1662 |
-
function getTotalWidgets(){
|
1663 |
-
global $quads_options;
|
1664 |
-
|
1665 |
-
$i = 0;
|
1666 |
-
|
1667 |
-
foreach ($quads_options['ads'] as $key => $value){
|
1668 |
-
if (false !== strpos($key, 'widget')){
|
1669 |
-
$i++;
|
1670 |
-
}
|
1671 |
-
}
|
1672 |
-
return $i;
|
1673 |
-
}
|
1674 |
-
|
1675 |
-
/**
|
1676 |
-
* Count normal ads. Do not count widget ads
|
1677 |
-
*
|
1678 |
-
* @global array $quads_options
|
1679 |
-
* @return int
|
1680 |
-
*/
|
1681 |
-
function quads_count_normal_ads() {
|
1682 |
-
global $quads_options;
|
1683 |
-
|
1684 |
-
if(!isset($quads_options['ads'])){
|
1685 |
-
return 0;
|
1686 |
-
}
|
1687 |
-
|
1688 |
-
// Count normal ads - not widget ads
|
1689 |
-
$adsCount = 0;
|
1690 |
-
$id = 1;
|
1691 |
-
foreach ( $quads_options['ads'] as $ads => $value ) {
|
1692 |
-
// Skip if its a widget ad
|
1693 |
-
if( strpos( $ads, 'ad' . $id ) === 0 && false === strpos( $ads, 'ad' . $id . '_widget' ) ) {
|
1694 |
-
$adsCount++;
|
1695 |
-
}
|
1696 |
-
$id++;
|
1697 |
-
}
|
1698 |
-
return $adsCount;
|
1699 |
-
}
|
1700 |
-
|
1701 |
-
function quads_new_ad_callback(){
|
1702 |
-
if (quads_is_extra()) {
|
1703 |
-
echo '<a href="#" id="quads-add-new-ad">' . __('Add New Ad','quick-adsense-reloaded') . '</a>';
|
1704 |
-
}
|
1705 |
-
}
|
1706 |
-
|
1707 |
-
/**
|
1708 |
-
* Render all ad relevant settings (ADSENSE CODE tab)
|
1709 |
-
* No widget ads
|
1710 |
-
* @global $quads_options $quads_options
|
1711 |
-
*/
|
1712 |
-
function quads_ad_code_callback(){
|
1713 |
-
global $quads_options;
|
1714 |
-
|
1715 |
-
// echo '<tr><td>';
|
1716 |
-
// echo 'test2';
|
1717 |
-
// echo '</td></tr>';
|
1718 |
-
|
1719 |
-
$args = array();
|
1720 |
-
|
1721 |
-
$i = 1;
|
1722 |
-
// Render 10 default ads if there are less than 10 ads stored or none at all
|
1723 |
-
if( quads_count_normal_ads() < 10 || !quads_is_extra()) {
|
1724 |
-
//wp_die('t2');
|
1725 |
-
while ( $i <= 10 ) {
|
1726 |
-
|
1727 |
-
$id = $i++;
|
1728 |
-
|
1729 |
-
$args['id'] = $id;
|
1730 |
-
|
1731 |
-
$args['desc'] = '';
|
1732 |
-
|
1733 |
-
$args['name'] = !empty( $quads_options['ads']['ad' . $id]['label'] ) ? $quads_options['ads']['ad' . $id]['label'] : 'Ad ' . $id;
|
1734 |
-
|
1735 |
-
echo '<tr><td>';
|
1736 |
-
echo quads_adsense_code_callback( $args );
|
1737 |
-
echo '</td></tr>';
|
1738 |
-
|
1739 |
-
}
|
1740 |
-
|
1741 |
-
// Stop here early
|
1742 |
-
return true;
|
1743 |
-
}
|
1744 |
-
|
1745 |
-
// Else render 10 + n ads
|
1746 |
-
$i = 1;
|
1747 |
-
foreach ($quads_options['ads'] as $ads => $value ){
|
1748 |
-
|
1749 |
-
$id = $i++;
|
1750 |
-
|
1751 |
-
$args['id'] = $id;
|
1752 |
-
|
1753 |
-
$args['desc'] = '';
|
1754 |
-
|
1755 |
-
$args['name'] = !empty($quads_options['ads']['ad' . $id]['label']) ? $quads_options['ads']['ad' . $id]['label'] : 'Ad ' . $id;
|
1756 |
-
|
1757 |
-
// Skip if its a widget ad
|
1758 |
-
if ( (strpos($ads, 'ad' . $id) === 0) && (false === strpos($ads, 'ad' . $id . '_widget') ) ){
|
1759 |
-
echo '<tr><td>';
|
1760 |
-
echo quads_adsense_code_callback( $args );
|
1761 |
-
echo '</td></tr>';
|
1762 |
-
}
|
1763 |
-
|
1764 |
-
}
|
1765 |
-
}
|
1766 |
-
|
1767 |
-
/**
|
1768 |
-
* AdSense Code Callback
|
1769 |
-
*
|
1770 |
-
* Renders adsense code fields
|
1771 |
-
*
|
1772 |
-
* @since 0.9.0
|
1773 |
-
* @param array $args Arguments passed by the setting
|
1774 |
-
* @global $quads_options Array of all the QUADS Options
|
1775 |
-
* @return void
|
1776 |
-
*/
|
1777 |
-
function quads_adsense_code_callback( $args ) {
|
1778 |
-
global $quads_options;
|
1779 |
-
|
1780 |
-
$new_label = isset( $quads_options['ads']['ad'.$args['id']]['label'] ) ? $quads_options['ads']['ad'.$args['id']]['label'] : '';
|
1781 |
-
|
1782 |
-
$label = !empty( $new_label ) ? $new_label : $args['name'];
|
1783 |
-
|
1784 |
-
$code = isset( $quads_options['ads']['ad'.$args['id']]['code'] ) ? $quads_options['ads']['ad'.$args['id']]['code'] : '';
|
1785 |
-
|
1786 |
-
$margin = isset( $quads_options['ads']['ad'.$args['id']]['margin'] ) ? esc_attr( stripslashes( $quads_options['ads']['ad'.$args['id']]['margin'] ) ) : 0;
|
1787 |
-
|
1788 |
-
$g_data_ad_client = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_client'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_client'] : '';
|
1789 |
-
|
1790 |
-
$g_data_ad_slot = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_slot'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_slot'] : '';
|
1791 |
-
|
1792 |
-
$g_data_ad_width = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_width'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_width'] : '';
|
1793 |
-
|
1794 |
-
$g_data_ad_height = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_height'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_height'] : '';
|
1795 |
-
|
1796 |
-
//$args['desc'] = __( '<strong>Shortcode:</strong> [quads id="'.$args['id'].'"] | <strong>PHP:</strong> echo do_shortcode(\'[quads id="'.$args['id'].'"]\');', 'quick-adsense-reloaded' );
|
1797 |
-
|
1798 |
-
//$label = !empty($new_label) ? $new_label :
|
1799 |
-
// Create a shorter var to make HTML cleaner
|
1800 |
-
$id = 'ad' . $args['id'];
|
1801 |
-
?>
|
1802 |
-
<div class="quads-ad-toggle-header quads-box-close" data-box-id="quads-toggle<?php echo $id; ?>">
|
1803 |
-
<div class="quads-toogle-title"><span contenteditable="true" id="quads-ad-label-<?php echo $id; ?>"><?php echo $label; ?></span><input type="hidden" class="quads-input-label" name="quads_settings[ads][<?php echo $id; ?>][label]" value="<?php echo $new_label; ?>"></div>
|
1804 |
-
<a class="quads-toggle" data-box-id="quads-toggle<?php echo $id; ?>" href="#"><div class="quads-close-open-icon"></div></a>
|
1805 |
-
</div>
|
1806 |
-
<div class="quads-ad-toggle-container" id="quads-toggle<?php echo $id; ?>" style="display:none;">
|
1807 |
-
<div>
|
1808 |
-
<?php
|
1809 |
-
$args_ad_type = array(
|
1810 |
-
'id' => 'ad_type',
|
1811 |
-
'name' => 'Type',
|
1812 |
-
'desc' => '',
|
1813 |
-
'std' => 'plain_text',
|
1814 |
-
'options' => array(
|
1815 |
-
'adsense' => 'AdSense',
|
1816 |
-
'plain_text' => 'Plain Text / HTML / JS'
|
1817 |
-
)
|
1818 |
-
);
|
1819 |
-
echo quads_adtype_callback( $id, $args_ad_type );
|
1820 |
-
?>
|
1821 |
-
</div>
|
1822 |
-
<textarea style="vertical-align:top;margin-right:20px;" class="large-text quads-textarea" cols="50" rows="10" id="quads_settings[ads][<?php echo $id; ?>][code]" name="quads_settings[ads][<?php echo $id; ?>][code]"><?php echo esc_textarea( stripslashes( $code ) ); ?></textarea>
|
1823 |
-
<!--<label for="quads_settings[ads][ <?php //echo $id; ?> ][code]"> <?php //echo $args['desc']; ?></label><br>//-->
|
1824 |
-
<label for="quads_shortcode_<?php echo $args['id'];?>">Post Shortcode:</label><input readonly id="quads_shortcode_<?php echo $args['id'];?>" type="text" onclick="this.focus(); this.select()" value='[quads id=<?php echo $args['id'];?>]' title="Optional: Copy and paste the shortcode into the post editor, click below then press Ctrl + C (PC) or Cmd + C (Mac).">
|
1825 |
-
<label for="quads_php_shortcode_<?php echo $args['id'];?>">PHP:</label><input readonly id="quads_php_shortcode_<?php echo $args['id'];?>" type="text" onclick="this.focus(); this.select()" style="width:290px;" value="<?php echo do_shortcode('[quads id=<?php echo $args['id']; ?>]'); ?>" title="Optional: Copy and paste the PHP code into your theme files, click below then press Ctrl + C (PC) or Cmd + C (Mac).">
|
1826 |
-
<br>
|
1827 |
-
<div class="quads_adsense_code">
|
1828 |
-
<input type="button" style="vertical-align:inherit;" class="button button-primary quads-add-adsense" value="Copy / Paste AdSense Code"> <span>or add Ad Slot ID & Publisher ID manually below:</span>
|
1829 |
-
<br />
|
1830 |
-
<?php //echo __('Generate Ad Slot & Publisher ID automatically from your adsense code', 'quick-adsense-reloaded') ?>
|
1831 |
-
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]">Ad Slot ID </label><input type="text" class="quads-medium-size quads-bggrey" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" value="<?php echo $g_data_ad_slot; ?>">
|
1832 |
-
<label for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]">Publisher ID</label><input type="text" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" class="medium-text quads-bggrey" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" value="<?php echo $g_data_ad_client; ?>">
|
1833 |
-
<br />
|
1834 |
-
<?php
|
1835 |
-
$args = array(
|
1836 |
-
'id' => 'adsense_type',
|
1837 |
-
'name' => 'Type',
|
1838 |
-
'desc' => 'Type',
|
1839 |
-
'options' => array(
|
1840 |
-
'normal' => 'Fixed Size',
|
1841 |
-
'responsive' => 'Responsive'
|
1842 |
-
)
|
1843 |
-
);
|
1844 |
-
echo quads_adense_select_callback( $id, $args );
|
1845 |
-
?>
|
1846 |
-
<?php if( !quads_is_extra() ) { ?>
|
1847 |
-
<span class="quads-pro-notice" style="display:block;margin-top:20px;"><?php echo sprintf( __( 'Install <a href="%s" target="_blank">WP QUADS PRO</a> to fully support AdSense Responsive ads.', 'quick-adsense-reloaded' ), 'http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin' ) ?></span>
|
1848 |
-
<?php } ?>
|
1849 |
-
<br />
|
1850 |
-
<label class="quads-label-left quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]">Width </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_width; ?>">
|
1851 |
-
<label class="quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]">Height </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_height; ?>">
|
1852 |
-
</div>
|
1853 |
-
<div class="quads-style">
|
1854 |
-
<h3>Layout</h3>
|
1855 |
-
<?php
|
1856 |
-
$args_ad_position = array(
|
1857 |
-
'id' => 'align',
|
1858 |
-
'name' => 'align',
|
1859 |
-
'desc' => 'align',
|
1860 |
-
'std' => '3',
|
1861 |
-
'options' => array(
|
1862 |
-
'3' => 'Default',
|
1863 |
-
'0' => 'Left',
|
1864 |
-
'1' => 'Center',
|
1865 |
-
'2' => 'Right'
|
1866 |
-
)
|
1867 |
-
);
|
1868 |
-
echo quads_adposition_callback( $id, $args_ad_position );
|
1869 |
-
// if WP QUADS PRO is installed and version number is higher or equal 1.2.7 show the new margin settings
|
1870 |
-
if( !quads_is_extra() ) {
|
1871 |
-
?>
|
1872 |
-
|
1873 |
-
<br />
|
1874 |
-
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][margin]"><?php _e( 'Margin', 'quick-adsense-reloaded' ); ?></label>
|
1875 |
-
<input type="number" step="1" max="" min="" class="small-text" id="quads_settings[ads][<?php echo $id; ?>][margin]" name="quads_settings[ads][<?php echo $id; ?>][margin]" value="<?php echo esc_attr( stripslashes( $margin ) ); ?>"/>px
|
1876 |
-
<?php } echo apply_filters( 'quads_render_margin', '', $id ); ?>
|
1877 |
-
</div>
|
1878 |
-
<?php
|
1879 |
-
if (quads_is_extra()){
|
1880 |
-
echo apply_filters( 'quads_advanced_settings', '', $id );
|
1881 |
-
}
|
1882 |
-
echo quads_pro_overlay();
|
1883 |
-
?>
|
1884 |
-
</div>
|
1885 |
-
<?php
|
1886 |
-
}
|
1887 |
-
|
1888 |
-
/**
|
1889 |
-
* AdSense Code Widget Callback
|
1890 |
-
*
|
1891 |
-
* Renders adsense code fields
|
1892 |
-
*
|
1893 |
-
* @since 0.9.0
|
1894 |
-
* @param array $args Arguments passed by the setting
|
1895 |
-
* @global $quads_options Array of all the QUADS Options
|
1896 |
-
* @return void
|
1897 |
-
*/
|
1898 |
-
function quads_adsense_widget_callback( $args ) {
|
1899 |
-
global $quads_options;
|
1900 |
-
|
1901 |
-
$label = !empty( $args['name'] ) ? $args['name'] : '';
|
1902 |
-
|
1903 |
-
$code = isset( $quads_options['ads'][$args['id']]['code'] ) ? $quads_options['ads'][$args['id']]['code'] : '';
|
1904 |
-
|
1905 |
-
$margin = isset( $quads_options['ads'][$args['id']]['margin'] ) ? esc_attr( stripslashes( $quads_options['ads'][$args['id']]['margin'] ) ) : 0;
|
1906 |
-
|
1907 |
-
$g_data_ad_client = isset( $quads_options['ads'][$args['id']]['g_data_ad_client'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_client'] : '';
|
1908 |
-
|
1909 |
-
$g_data_ad_slot = isset( $quads_options['ads'][$args['id']]['g_data_ad_slot'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_slot'] : '';
|
1910 |
-
|
1911 |
-
$g_data_ad_width = isset( $quads_options['ads'][$args['id']]['g_data_ad_width'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_width'] : '';
|
1912 |
-
|
1913 |
-
$g_data_ad_height = isset( $quads_options['ads'][$args['id']]['g_data_ad_height'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_height'] : '';
|
1914 |
-
|
1915 |
-
// Create a shorter var to make HTML cleaner
|
1916 |
-
$id = $args['id'];
|
1917 |
-
?>
|
1918 |
-
<div class="quads-ad-toggle-header quads-box-close" data-box-id="quads-toggle<?php echo $id; ?>">
|
1919 |
-
<div class="quads-toogle-title"><?php echo $label; ?></div>
|
1920 |
-
<a class="quads-toggle" data-box-id="quads-toggle<?php echo $id; ?>" href="#"><div class="quads-close-open-icon"></div></a>
|
1921 |
-
</div>
|
1922 |
-
<div class="quads-ad-toggle-container" id="quads-toggle<?php echo $id; ?>" style="display:none;">
|
1923 |
-
<div>
|
1924 |
-
<?php
|
1925 |
-
$args_ad_type = array(
|
1926 |
-
'id' => 'ad_type',
|
1927 |
-
'name' => 'Type',
|
1928 |
-
'desc' => '',
|
1929 |
-
'std' => 'plain_text',
|
1930 |
-
'options' => array(
|
1931 |
-
'adsense' => 'AdSense',
|
1932 |
-
'plain_text' => 'Plain Text / HTML / JS'
|
1933 |
-
)
|
1934 |
-
);
|
1935 |
-
echo quads_adtype_callback( $id, $args_ad_type );
|
1936 |
-
?>
|
1937 |
-
</div>
|
1938 |
-
<textarea style="vertical-align:top;margin-right:20px;" class="large-text quads-textarea" cols="50" rows="10" id="quads_settings[ads][<?php echo $id; ?>][code]" name="quads_settings[ads][<?php echo $id; ?>][code]"><?php echo esc_textarea( stripslashes( $code ) ); ?></textarea><label for="quads_settings[ads][ <?php echo $id; ?> ][code]"> <?php echo $args['desc']; ?></label>
|
1939 |
-
<br>
|
1940 |
-
<div class="quads_adsense_code">
|
1941 |
-
<input type="button" style="vertical-align:inherit;" class="button button-primary quads-add-adsense" value="Copy / Paste AdSense Code"> <span>or add Ad Slot ID & Publisher ID manually below:</span>
|
1942 |
-
<br />
|
1943 |
-
<?php //echo __('Generate Ad Slot & Publisher ID automatically from your adsense code', 'quick-adsense-reloaded') ?>
|
1944 |
-
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]">Ad Slot ID </label><input type="text" class="quads-medium-size quads-bggrey" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" value="<?php echo $g_data_ad_slot; ?>">
|
1945 |
-
<label for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]">Publisher ID</label><input type="text" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" class="medium-text quads-bggrey" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" value="<?php echo $g_data_ad_client; ?>">
|
1946 |
-
<br />
|
1947 |
-
<?php
|
1948 |
-
$args_adsense_type = array(
|
1949 |
-
'id' => 'adsense_type',
|
1950 |
-
'name' => 'Type',
|
1951 |
-
'desc' => 'Type',
|
1952 |
-
'options' => array(
|
1953 |
-
'normal' => 'Fixed Size',
|
1954 |
-
'responsive' => 'Responsive'
|
1955 |
-
)
|
1956 |
-
);
|
1957 |
-
echo quads_adense_select_callback( $id, $args_adsense_type );
|
1958 |
-
?>
|
1959 |
-
<?php if( !quads_is_extra() ) { ?>
|
1960 |
-
<span class="quads-pro-notice" style="display:block;margin-top:20px;"><?php echo sprintf( __( 'Install <a href="%s" target="_blank">WP QUADS PRO</a> to fully support AdSense Responsive ads.', 'quick-adsense-reloaded' ), 'http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin' ) ?></span>
|
1961 |
-
<?php } ?>
|
1962 |
-
<br />
|
1963 |
-
<label class="quads-label-left quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]">Width </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_width; ?>">
|
1964 |
-
<label class="quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]">Height </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_height; ?>">
|
1965 |
-
</div>
|
1966 |
-
<div class="quads-style">
|
1967 |
-
<h3>Layout</h3>
|
1968 |
-
<?php
|
1969 |
-
$args_ad_position = array(
|
1970 |
-
'id' => 'align',
|
1971 |
-
'name' => 'align',
|
1972 |
-
'desc' => 'align',
|
1973 |
-
'std' => '3',
|
1974 |
-
'options' => array(
|
1975 |
-
'3' => 'Default',
|
1976 |
-
'0' => 'Left',
|
1977 |
-
'1' => 'Center',
|
1978 |
-
'2' => 'Right'
|
1979 |
-
)
|
1980 |
-
);
|
1981 |
-
echo quads_adposition_callback( $id, $args_ad_position );
|
1982 |
-
// if WP QUADS PRO is installed and version number is higher or equal 1.2.7 show the new margin settings
|
1983 |
-
if( !quads_is_extra() ) {
|
1984 |
-
?>
|
1985 |
-
<br />
|
1986 |
-
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][margin]"><?php _e( 'Margin', 'quick-adsense-reloaded' ); ?></label>
|
1987 |
-
<input type="number" step="1" max="" min="" class="small-text" id="quads_settings[ads][<?php echo $id; ?>][margin]" name="quads_settings[ads][<?php echo $id; ?>][margin]" value="<?php echo esc_attr( stripslashes( $margin ) ); ?>"/>px
|
1988 |
-
<?php } echo apply_filters( 'quads_render_margin', '', $id ); ?>
|
1989 |
-
</div>
|
1990 |
-
<?php
|
1991 |
-
if (quads_is_extra()){
|
1992 |
-
echo apply_filters( 'quads_advanced_settings', '', $id );
|
1993 |
-
}
|
1994 |
-
echo quads_pro_overlay();
|
1995 |
-
?>
|
1996 |
-
</div>
|
1997 |
-
<?php
|
1998 |
-
}
|
1999 |
-
|
2000 |
-
/**
|
2001 |
-
* If advanced settings are not available load overlay image
|
2002 |
-
* @return string
|
2003 |
-
*/
|
2004 |
-
function quads_pro_overlay() {
|
2005 |
-
if( quads_is_extra() ) {
|
2006 |
-
return '';
|
2007 |
-
}
|
2008 |
-
|
2009 |
-
$html = '<div class="quads-advanced-ad-box quads-pro-overlay"><a href="http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin" target="_blank"><img src="' . QUADS_PLUGIN_URL . '/assets/images/get_pro_overlay.png"></a></div>';
|
2010 |
-
|
2011 |
-
return $html;
|
2012 |
-
}
|
2013 |
-
|
2014 |
-
/**
|
2015 |
-
*
|
2016 |
-
* Return array of alignment options
|
2017 |
-
*
|
2018 |
-
* @return array
|
2019 |
-
*/
|
2020 |
-
function quads_get_alignment() {
|
2021 |
-
// Do not change the key => value order for compatibility reasons
|
2022 |
-
return array(
|
2023 |
-
3 => 'none',
|
2024 |
-
0 => 'left',
|
2025 |
-
1 => 'center',
|
2026 |
-
2 => 'right',
|
2027 |
-
);
|
2028 |
-
}
|
2029 |
-
|
2030 |
-
/**
|
2031 |
-
* Check if plugin Clickfraud Monitoring is installed
|
2032 |
-
*
|
2033 |
-
* @return boolean true when it is installed and active
|
2034 |
-
*/
|
2035 |
-
function quads_is_installed_clickfraud() {
|
2036 |
-
$plugin_file = 'cfmonitor/cfmonitor.php';
|
2037 |
-
$plugin_file2 = 'clickfraud-monitoring/cfmonitor.php';
|
2038 |
-
|
2039 |
-
if( is_plugin_active( $plugin_file ) || is_plugin_active( $plugin_file2 ) ) {
|
2040 |
-
return true;
|
2041 |
-
}
|
2042 |
-
|
2043 |
-
return false;
|
2044 |
-
}
|
2045 |
-
|
2046 |
-
/**
|
2047 |
-
*
|
2048 |
-
* @param array $args array(
|
2049 |
-
* 'id' => 'string),
|
2050 |
-
* 'type' => desktop, tablet_landscape, tablet_portrait, phone
|
2051 |
-
* @return string
|
2052 |
-
|
2053 |
-
*/
|
2054 |
-
function quads_render_size_option( $args ) {
|
2055 |
-
global $quads_options;
|
2056 |
-
|
2057 |
-
if( !isset( $args['id'] ) ) {
|
2058 |
-
return '';
|
2059 |
-
}
|
2060 |
-
|
2061 |
-
$checked = isset( $quads_options['ads'][$args['id']][$args['type']] ) ? $quads_options['ads'][$args['id']][$args['type']] : '';
|
2062 |
-
$html = '<div class="quads-select-style-overwrite">';
|
2063 |
-
$html .= '<select class="quads-size-input" id="quads_settings[ads][' . $args['id'] . '][' . $args['type'] . ']" name="quads_settings[ads][' . $args['id'] . '][' . $args['type'] . ']">';
|
2064 |
-
foreach ( quads_get_adsense_sizes() as $key => $value ) :
|
2065 |
-
$selected = selected( $key, $checked, false );
|
2066 |
-
$html .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
|
2067 |
-
endforeach;
|
2068 |
-
$html .= '</select>';
|
2069 |
-
$html .= '</div>';
|
2070 |
-
|
2071 |
-
return $html;
|
2072 |
-
}
|
2073 |
-
|
2074 |
-
/**
|
2075 |
-
* Get all AdSense Sizes
|
2076 |
-
* @return array
|
2077 |
-
*/
|
2078 |
-
function quads_get_adsense_sizes() {
|
2079 |
-
$sizes = array(
|
2080 |
-
'Auto' => 'Auto',
|
2081 |
-
'120 x 90' => '120 x 90',
|
2082 |
-
'120 x 240' => '120 x 240',
|
2083 |
-
'120 x 600' => '120 x 600',
|
2084 |
-
'125 x 125' => '125 x 125',
|
2085 |
-
'160 x 90' => '160 x 90',
|
2086 |
-
'160 x 600' => '160 x 600',
|
2087 |
-
'180 x 90' => '180 x 90',
|
2088 |
-
'180 x 150' => '180 x 150',
|
2089 |
-
'200 x 90' => '200 x 90',
|
2090 |
-
'200 x 200' => '200 x 200',
|
2091 |
-
'234 x 60' => '234 x 60',
|
2092 |
-
'250 x 250' => '250 x 250',
|
2093 |
-
'320 x 100' => '320 x 100',
|
2094 |
-
'300 x 250' => '300 x 250',
|
2095 |
-
'300 x 600' => '300 x 600',
|
2096 |
-
'300 x 1050' => '300 x 1050',
|
2097 |
-
'320 x 50' => '320 x 50',
|
2098 |
-
'336 x 280' => '336 x 280',
|
2099 |
-
'360 x 300' => '360 x 300',
|
2100 |
-
'435 x 300' => '435 x 300',
|
2101 |
-
'468 x 15' => '468 x 15',
|
2102 |
-
'468 x 60' => '468 x 60',
|
2103 |
-
'640 x 165' => '640 x 165',
|
2104 |
-
'640 x 190' => '640 x 190',
|
2105 |
-
'640 x 300' => '640 x 300',
|
2106 |
-
'728 x 15' => '728 x 15',
|
2107 |
-
'728 x 90' => '728 x 90',
|
2108 |
-
'970 x 90' => '970 x 90',
|
2109 |
-
'970 x 250' => '970 x 250',
|
2110 |
-
'240 x 400' => '240 x 400 - Regional ad sizes',
|
2111 |
-
'250 x 360' => '250 x 360 - Regional ad sizes',
|
2112 |
-
'580 x 400' => '580 x 400 - Regional ad sizes',
|
2113 |
-
'750 x 100' => '750 x 100 - Regional ad sizes',
|
2114 |
-
'750 x 200' => '750 x 200 - Regional ad sizes',
|
2115 |
-
'750 x 300' => '750 x 300 - Regional ad sizes',
|
2116 |
-
'980 x 120' => '980 x 120 - Regional ad sizes',
|
2117 |
-
'930 x 180' => '930 x 180 - Regional ad sizes',
|
2118 |
-
);
|
2119 |
-
|
2120 |
-
return apply_filters( 'quads_adsense_size_formats', $sizes );
|
2121 |
-
}
|
2122 |
-
|
2123 |
-
/**
|
2124 |
-
* Store AdSense parameters
|
2125 |
-
*
|
2126 |
-
* @return boolean
|
2127 |
-
*/
|
2128 |
-
function quads_store_adsense_args() {
|
2129 |
-
global $quads_options;
|
2130 |
-
|
2131 |
-
foreach ( $quads_options as $id => $ads ) {
|
2132 |
-
if (!is_array($ads)){
|
2133 |
-
continue;
|
2134 |
-
}
|
2135 |
-
foreach ($ads as $key => $value) {
|
2136 |
-
if( is_array( $value ) && array_key_exists( 'code', $value ) && !empty( $value['code'] ) ) {
|
2137 |
-
|
2138 |
-
//check to see if it is google ad
|
2139 |
-
if( preg_match( '/googlesyndication.com/', $value['code'] ) ) {
|
2140 |
-
|
2141 |
-
// Test if its google asyncron ad
|
2142 |
-
if( preg_match( '/data-ad-client=/', $value['code'] ) ) {
|
2143 |
-
//*** GOOGLE ASYNCRON *************
|
2144 |
-
$quads_options['ads'][$key]['current_ad_type'] = 'google_async';
|
2145 |
-
//get g_data_ad_client
|
2146 |
-
$explode_ad_code = explode( 'data-ad-client', $value['code'] );
|
2147 |
-
preg_match( '#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client );
|
2148 |
-
$quads_options['ads'][$key]['g_data_ad_client'] = str_replace( array('"', ' '), array(''), $matches_add_client[1] );
|
2149 |
-
|
2150 |
-
//get g_data_ad_slot
|
2151 |
-
$explode_ad_code = explode( 'data-ad-slot', $value['code'] );
|
2152 |
-
preg_match( '#"([a-zA-Z0-9/\s]+)"#', $explode_ad_code[1], $matches_add_slot );
|
2153 |
-
if (isset($matches_add_slot[1])){
|
2154 |
-
$quads_options['ads'][$key]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), $matches_add_slot[1] );
|
2155 |
-
}
|
2156 |
-
} else {
|
2157 |
-
//*** GOOGLE SYNCRON *************
|
2158 |
-
$quads_options['ads'][$key]['current_ad_type'] = 'google_sync';
|
2159 |
-
//get g_data_ad_client
|
2160 |
-
$explode_ad_code = explode( 'google_ad_client', $value['code'] );
|
2161 |
-
preg_match( '#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client );
|
2162 |
-
$quads_options['ads'][$key]['g_data_ad_client'] = str_replace( array('"', ' '), array(''), $matches_add_client[1] );
|
2163 |
-
|
2164 |
-
//get g_data_ad_slot
|
2165 |
-
$explode_ad_code = explode( 'google_ad_slot', $value['code'] );
|
2166 |
-
//preg_match( '#"([a-zA-Z0-9/\s]+)"#', $explode_ad_code[1], $matches_add_slot );
|
2167 |
-
//$quads_options['ads'][$key]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), $matches_add_slot[1] );
|
2168 |
-
preg_match( '#"([a-zA-Z0-9/\s]+)"#', isset($explode_ad_code[1]) ? $explode_ad_code[1] : null, $matches_add_slot );
|
2169 |
-
$quads_options['ads'][$key]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), isset($matches_add_slot[1]) ? $matches_add_slot[1] : null );
|
2170 |
-
}
|
2171 |
-
}
|
2172 |
-
}
|
2173 |
-
}
|
2174 |
-
}
|
2175 |
-
//wp_die( var_dump( $quads_options ) );
|
2176 |
-
update_option( 'quads_settings', $quads_options );
|
2177 |
-
}
|
2178 |
-
|
2179 |
-
/**
|
2180 |
-
* Populate AdSense Code field otherwise ads are not shown on frontpage (Bug).
|
2181 |
-
* @todo
|
2182 |
-
*
|
2183 |
-
* @global $quads_options $quads_options
|
2184 |
-
* @deprecated since 1.3.8
|
2185 |
-
*/
|
2186 |
-
//function quads_fix_ad_not_shown(){
|
2187 |
-
// global $quads_options;
|
2188 |
-
//
|
2189 |
-
// foreach ( $quads_options as $id => $values ) {
|
2190 |
-
// if( is_array( $values ) && array_key_exists( 'code', $values ) && array_key_exists( 'ad_type', $values ) && empty($values['code']) ) {
|
2191 |
-
// $quads_options[$id]['code'] = '...';
|
2192 |
-
// }
|
2193 |
-
// }
|
2194 |
-
//}
|
2195 |
-
|
2196 |
-
/**
|
2197 |
-
* Sanitizes a string key for QUADS Settings
|
2198 |
-
*
|
2199 |
-
* Keys are used as internal identifiers. Alphanumeric characters, dashes, underscores, stops, colons and slashes are allowed
|
2200 |
-
*
|
2201 |
-
* @since 2.0.0
|
2202 |
-
* @param string $key String key
|
2203 |
-
* @return string Sanitized key
|
2204 |
-
*/
|
2205 |
-
function quads_sanitize_key( $key ) {
|
2206 |
-
$raw_key = $key;
|
2207 |
-
$key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
|
2208 |
-
/**
|
2209 |
-
* Filter a sanitized key string.
|
2210 |
-
*
|
2211 |
-
* @since 2.5.8
|
2212 |
-
* @param string $key Sanitized key.
|
2213 |
-
* @param string $raw_key The key prior to sanitization.
|
2214 |
-
*/
|
2215 |
-
return apply_filters( 'quads_sanitize_key', $key, $raw_key );
|
2216 |
-
}
|
2217 |
-
|
2218 |
-
/**
|
2219 |
-
* Multi Select Callback
|
2220 |
-
*
|
2221 |
-
* @since 1.3.8
|
2222 |
-
* @param array $args Arguments passed by the settings
|
2223 |
-
* @global $quads_options Array of all the QUADS Options
|
2224 |
-
* @return string $output dropdown
|
2225 |
-
*/
|
2226 |
-
function quads_multiselect_callback( $args = array() ) {
|
2227 |
-
global $quads_options;
|
2228 |
-
|
2229 |
-
$placeholder = !empty( $args['placeholder'] ) ? $args['placeholder'] : '';
|
2230 |
-
$selected = isset( $quads_options[$args['id']] ) ? $quads_options[$args['id']] : '';
|
2231 |
-
$checked = '';
|
2232 |
-
|
2233 |
-
$html = '<select id="quads_select_'. $args['id'] .'" name="quads_settings[' . $args['id'] . '][]" data-placeholder="' . $placeholder . '" style="width:550px;" multiple tabindex="4" class="quads-select quads-chosen-select">';
|
2234 |
-
$i = 0;
|
2235 |
-
foreach ( $args['options'] as $key => $value ) :
|
2236 |
-
if( is_array( $selected ) ) {
|
2237 |
-
$checked = selected( true, in_array( $key, $selected ), false );
|
2238 |
-
}
|
2239 |
-
$html .= '<option value="' . $key . '" ' . $checked . '>' . $value . '</option>';
|
2240 |
-
endforeach;
|
2241 |
-
$html .= '</select>';
|
2242 |
-
echo $html;
|
2243 |
-
}
|
2244 |
-
/**
|
2245 |
-
* Multi Select Ajax Callback
|
2246 |
-
* This adds only active elements to the array. Useful if there are a lot of elements like tags to increase performance
|
2247 |
-
*
|
2248 |
-
* @since 1.3.8
|
2249 |
-
* @param array $args Arguments passed by the settings
|
2250 |
-
* @global $quads_options Array of all the QUADS Options
|
2251 |
-
* @return string $output dropdown
|
2252 |
-
*/
|
2253 |
-
function quads_multiselect_ajax_callback( $args = array() ) {
|
2254 |
-
global $quads_options;
|
2255 |
-
|
2256 |
-
$placeholder = !empty( $args['placeholder'] ) ? $args['placeholder'] : '';
|
2257 |
-
$selected = isset( $quads_options[$args['id']] ) ? $quads_options[$args['id']] : '';
|
2258 |
-
$checked = '';
|
2259 |
-
|
2260 |
-
$html = '<select id="quads_select_'. $args['id'] .'" name="quads_settings[' . $args['id'] . '][]" data-placeholder="' . $placeholder . '" style="width:550px;" multiple tabindex="4" class="quads-select quads-chosen-select">';
|
2261 |
-
$i = 0;
|
2262 |
-
|
2263 |
-
if (!isset($quads_options[$args['id']]) || !is_array( $quads_options[$args['id']] ) || count($quads_options[$args['id']]) == 0){
|
2264 |
-
$html .= '</select>';
|
2265 |
-
echo $html;
|
2266 |
-
return;
|
2267 |
-
}
|
2268 |
-
|
2269 |
-
foreach ( $quads_options[$args['id']] as $key => $value ) {
|
2270 |
-
$html .= '<option value="' . $key . '" selected="selected">' . $value . '</option>';
|
2271 |
-
};
|
2272 |
-
$html .= '</select>';
|
2273 |
-
echo $html;
|
2274 |
-
}
|
2275 |
-
|
2276 |
-
/**
|
2277 |
-
* VI Integration
|
2278 |
-
* @global type $quads
|
2279 |
-
*
|
2280 |
-
*/
|
2281 |
-
function quads_vi_signup_callback() {
|
2282 |
-
global $quads, $quads_options;
|
2283 |
-
|
2284 |
-
//$adsense = new \wpquads\adsense($quads_options);
|
2285 |
-
//var_dump($adsense->getPublisherIds());
|
2286 |
-
//echo 'test' . $adsense->getPublisherIds() . $adsense->writeAdsTxt();
|
2287 |
-
|
2288 |
-
$header = new \wpquads\template('/includes/vendor/vi/views/partials/header', array());
|
2289 |
-
$footer = new \wpquads\template('/includes/vendor/vi/views/partials/footer', array());
|
2290 |
-
$error = new \wpquads\template('/includes/vendor/vi/views/error', array());
|
2291 |
-
|
2292 |
-
// Try to initially load vi settings
|
2293 |
-
$settings = $quads->vi->getSettings();
|
2294 |
-
if ( false === $settings || empty($settings)){
|
2295 |
-
if (!$quads->vi->setSettings()) {
|
2296 |
-
echo $header->render();
|
2297 |
-
echo $error->render();
|
2298 |
-
echo $footer->render();
|
2299 |
-
return true;
|
2300 |
-
}
|
2301 |
-
}
|
2302 |
-
|
2303 |
-
|
2304 |
-
$data = !empty($quads->vi->getSettings()->data) ? (array) $quads->vi->getSettings()->data : array();
|
2305 |
-
|
2306 |
-
$data['jsTag'] = $quads->vi->getAdCode();
|
2307 |
-
|
2308 |
-
$logged_in = new \wpquads\template('/includes/vendor/vi/views/logged_in', $data);
|
2309 |
-
$not_logged_in = new \wpquads\template('/includes/vendor/vi/views/not_logged_in', $data);
|
2310 |
-
$adform = new \wpquads\template('/includes/vendor/vi/views/ad_settings', $data);
|
2311 |
-
$revenue = new \wpquads\template('/includes/vendor/vi/views/revenue', $data);
|
2312 |
-
|
2313 |
-
// header
|
2314 |
-
echo $header->render();
|
2315 |
-
|
2316 |
-
|
2317 |
-
// Not logged in
|
2318 |
-
if (empty($data) || false === $quads->vi->setRevenue()) {
|
2319 |
-
echo $not_logged_in->render();
|
2320 |
-
} else {
|
2321 |
-
// Is logged in
|
2322 |
-
//if ($quads->vi->setRevenue()) {
|
2323 |
-
echo $revenue->render();
|
2324 |
-
echo $adform->render();
|
2325 |
-
}
|
2326 |
-
|
2327 |
-
// footer
|
2328 |
-
echo $footer->render();
|
2329 |
-
|
2330 |
-
|
2331 |
-
}
|
2332 |
-
|
2333 |
-
/**
|
2334 |
-
* Create ads.txt for Google AdSense when saving settings
|
2335 |
-
* @return boolean
|
2336 |
-
*/
|
2337 |
-
function quads_write_adsense_ads_txt() {
|
2338 |
-
// Get the current recently updated settings
|
2339 |
-
$quads_options = get_option('quads_settings');
|
2340 |
-
|
2341 |
-
// ads.txt is disabled
|
2342 |
-
if (!isset($quads_options['adsTxtEnabled'])) {
|
2343 |
-
set_transient('quads_ads_txt_disabled', true, 100);
|
2344 |
-
delete_transient('quads_ads_txt_error');
|
2345 |
-
delete_transient('quads_ads_txt_notice');
|
2346 |
-
return false;
|
2347 |
-
}
|
2348 |
-
|
2349 |
-
// Create AdSense ads.txt entries
|
2350 |
-
$adsense = new \wpquads\adsense($quads_options);
|
2351 |
-
if ($adsense->writeAdsTxt()){
|
2352 |
-
set_transient('quads_ads_txt_notice', 'true', 3000);
|
2353 |
-
return true;
|
2354 |
-
} else {
|
2355 |
-
// Make sure an error message is shown when ads.txt is available but can not be modified
|
2356 |
-
// Otherwise google adsense ads are not shown
|
2357 |
-
if (is_file(ABSPATH . 'ads.txt')) {
|
2358 |
-
set_transient('quads_ads_txt_error', 'true', 3000);
|
2359 |
-
}
|
2360 |
-
return false;
|
2361 |
-
}
|
2362 |
-
}
|
2363 |
-
add_action('update_option_quads_settings', 'quads_write_adsense_ads_txt');
|
2364 |
-
|
2365 |
-
|
2366 |
-
/**
|
2367 |
-
* Periodically update ads.txt once a day for vi and adsense
|
2368 |
-
* This is to ensure that the file is recreated in case it was deleted
|
2369 |
-
* @return boolean
|
2370 |
-
*/
|
2371 |
-
function updateAdsTxt(){
|
2372 |
-
global $quads, $quads_options;
|
2373 |
-
if(is_file('ads.txt') || !isset($quads_options['adsTxtEnabled'])){
|
2374 |
-
return false;
|
2375 |
-
}
|
2376 |
-
$quads->vi->createAdsTxt();
|
2377 |
-
$adsense = new wpquads\adsense($quads_options);
|
2378 |
-
$adsense->writeAdsTxt();
|
2379 |
-
}
|
2380 |
-
add_action('quads_daily_event', 'updateAdsTxt');
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Register Settings
|
4 |
+
*
|
5 |
+
* @package QUADS
|
6 |
+
* @subpackage Admin/Settings
|
7 |
+
* @copyright Copyright (c) 2015, René Hermenau
|
8 |
+
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
9 |
+
* @since 1.0
|
10 |
+
*/
|
11 |
+
// Exit if accessed directly
|
12 |
+
if( !defined( 'ABSPATH' ) )
|
13 |
+
exit;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Get an option
|
17 |
+
*
|
18 |
+
* Looks to see if the specified setting exists, returns default if not
|
19 |
+
*
|
20 |
+
* @since 1.0.0
|
21 |
+
* @return mixed
|
22 |
+
*/
|
23 |
+
function quads_get_option( $key = '', $default = false ) {
|
24 |
+
global $quads_options;
|
25 |
+
$value = !empty( $quads_options[$key] ) ? $quads_options[$key] : $default;
|
26 |
+
$value = apply_filters( 'quads_get_option', $value, $key, $default );
|
27 |
+
return apply_filters( 'quads_get_option_' . $key, $value, $key, $default );
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Get Settings
|
32 |
+
*
|
33 |
+
* Retrieves all plugin settings
|
34 |
+
*
|
35 |
+
* @since 1.0
|
36 |
+
* @return array QUADS settings
|
37 |
+
*/
|
38 |
+
function quads_get_settings() {
|
39 |
+
$settings = get_option( 'quads_settings' );
|
40 |
+
|
41 |
+
|
42 |
+
if( empty( $settings ) ) {
|
43 |
+
// Update old settings with new single option
|
44 |
+
$general_settings = is_array( get_option( 'quads_settings_general' ) ) ? get_option( 'quads_settings_general' ) : array();
|
45 |
+
$ext_settings = is_array( get_option( 'quads_settings_extensions' ) ) ? get_option( 'quads_settings_extensions' ) : array();
|
46 |
+
$license_settings = is_array( get_option( 'quads_settings_licenses' ) ) ? get_option( 'quads_settings_licenses' ) : array();
|
47 |
+
$addons_settings = is_array( get_option( 'quads_settings_addons' ) ) ? get_option( 'quads_settings_addons' ) : array();
|
48 |
+
$imexport_settings = is_array( get_option( 'quads_settings_imexport' ) ) ? get_option( 'quads_settings_imexport' ) : array();
|
49 |
+
$help_settings = is_array( get_option( 'quads_settings_help' ) ) ? get_option( 'quads_settings_help' ) : array();
|
50 |
+
|
51 |
+
$settings = array_merge( $general_settings, $ext_settings, $imexport_settings, $help_settings );
|
52 |
+
|
53 |
+
update_option( 'quads_settings', $settings );
|
54 |
+
|
55 |
+
|
56 |
+
}
|
57 |
+
return apply_filters( 'quads_get_settings', $settings );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Add all settings sections and fields
|
62 |
+
*
|
63 |
+
* @since 1.0
|
64 |
+
* @return void
|
65 |
+
*/
|
66 |
+
function quads_register_settings() {
|
67 |
+
|
68 |
+
if( false == get_option( 'quads_settings' ) ) {
|
69 |
+
add_option( 'quads_settings' );
|
70 |
+
}
|
71 |
+
|
72 |
+
foreach ( quads_get_registered_settings() as $tab => $settings ) {
|
73 |
+
|
74 |
+
add_settings_section(
|
75 |
+
'quads_settings_' . $tab, __return_null(), '__return_false', 'quads_settings_' . $tab
|
76 |
+
);
|
77 |
+
|
78 |
+
foreach ( $settings as $option ) {
|
79 |
+
|
80 |
+
$name = isset( $option['name'] ) ? $option['name'] : '';
|
81 |
+
|
82 |
+
add_settings_field(
|
83 |
+
'quads_settings[' . $option['id'] . ']', $name, function_exists( 'quads_' . $option['type'] . '_callback' ) ? 'quads_' . $option['type'] . '_callback' : 'quads_missing_callback', 'quads_settings_' . $tab, 'quads_settings_' . $tab, array(
|
84 |
+
'id' => isset( $option['id'] ) ? $option['id'] : null,
|
85 |
+
'desc' => !empty( $option['desc'] ) ? $option['desc'] : '',
|
86 |
+
'desc2' => !empty( $option['desc2'] ) ? $option['desc2'] : '',
|
87 |
+
'helper-desc' => !empty( $option['helper-desc'] ) ? $option['helper-desc'] : '',
|
88 |
+
'name' => isset( $option['name'] ) ? $option['name'] : null,
|
89 |
+
'section' => $tab,
|
90 |
+
'size' => isset( $option['size'] ) ? $option['size'] : null,
|
91 |
+
'options' => isset( $option['options'] ) ? $option['options'] : '',
|
92 |
+
'std' => isset( $option['std'] ) ? $option['std'] : '',
|
93 |
+
'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
|
94 |
+
'textarea_rows' => isset( $option['textarea_rows'] ) ? $option['textarea_rows'] : ''
|
95 |
+
)
|
96 |
+
);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
// Store adsense values
|
101 |
+
quads_store_adsense_args();
|
102 |
+
|
103 |
+
// Store AdSense value
|
104 |
+
//quads_fix_ad_not_shown();
|
105 |
+
// Creates our settings in the options table
|
106 |
+
register_setting( 'quads_settings', 'quads_settings', 'quads_settings_sanitize' );
|
107 |
+
}
|
108 |
+
add_action( 'admin_init', 'quads_register_settings' );
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Retrieve the array of plugin settings
|
112 |
+
*
|
113 |
+
* @since 1.8
|
114 |
+
* @return array
|
115 |
+
*/
|
116 |
+
function quads_get_registered_settings() {
|
117 |
+
|
118 |
+
/**
|
119 |
+
* 'Whitelisted' QUADS settings, filters are provided for each settings
|
120 |
+
* section to allow extensions and other plugins to add their own settings
|
121 |
+
*/
|
122 |
+
$quads_settings = array(
|
123 |
+
/** General Settings */
|
124 |
+
'general' => apply_filters( 'quads_settings_general', array(
|
125 |
+
array(
|
126 |
+
'id' => 'general_header',
|
127 |
+
'name' => '<strong>' . __( 'General & Position', 'quick-adsense-reloaded' ) . '</strong>',
|
128 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
129 |
+
'type' => 'header'
|
130 |
+
),
|
131 |
+
'maxads' => array(
|
132 |
+
'id' => 'maxads',
|
133 |
+
'name' => __( 'Limit Amount of ads:', 'quick-adsense-reloaded' ),
|
134 |
+
'desc' => __( ' ads on a page.', 'quick-adsense-reloaded' ),
|
135 |
+
'desc2' => sprintf( __( '<a href="%s" target="_blank">Read here</a> to learn how many AdSense ads are allowed. If you are unsure set the value to unlimited.', 'quick-adsense-reloaded' ), 'http://wpquads.com/google-adsense-allowed-number-ads/' ),
|
136 |
+
'type' => 'select',
|
137 |
+
'std' => 100,
|
138 |
+
'options' => array(
|
139 |
+
1 => '1',
|
140 |
+
2 => '2',
|
141 |
+
3 => '3',
|
142 |
+
4 => '4',
|
143 |
+
5 => '5',
|
144 |
+
6 => '6',
|
145 |
+
7 => '7',
|
146 |
+
8 => '8',
|
147 |
+
9 => '9',
|
148 |
+
10 => '10',
|
149 |
+
11 => '11',
|
150 |
+
12 => '12',
|
151 |
+
13 => '13',
|
152 |
+
14 => '14',
|
153 |
+
15 => '15',
|
154 |
+
16 => '16',
|
155 |
+
17 => '17',
|
156 |
+
18 => '18',
|
157 |
+
19 => '19',
|
158 |
+
20 => '20',
|
159 |
+
100 => 'Unlimited',
|
160 |
+
),
|
161 |
+
),
|
162 |
+
array(
|
163 |
+
'id' => 'ad_position',
|
164 |
+
'name' => __( 'Position - Default Ads', 'quick-adsense-reloaded' ),
|
165 |
+
'desc' => __( 'Assign and activate ads on specific ad places', 'quick-adsense-reloaded' ),
|
166 |
+
'type' => 'ad_position'
|
167 |
+
),
|
168 |
+
array(
|
169 |
+
'id' => 'visibility',
|
170 |
+
'name' => __( 'Visibility', 'quick-adsense-reloaded' ),
|
171 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
172 |
+
'type' => 'visibility'
|
173 |
+
),
|
174 |
+
array(
|
175 |
+
"id" => "post_types",
|
176 |
+
"name" => __( "Post Types", "quick-adsense-reloaded" ),
|
177 |
+
"desc" => __( "Select post types where ads are visible.", "quick-adsense-reloaded" ),
|
178 |
+
"helper-desc" => __( "Select post types where ads are visible.", "quick-adsense-reloaded" ),
|
179 |
+
"type" => "multiselect",
|
180 |
+
"options" => quads_get_post_types(),
|
181 |
+
"placeholder" => __( "Select Post Type", "quick-adsense-reloaded" )
|
182 |
+
),
|
183 |
+
array(
|
184 |
+
'id' => 'hide_ajax',
|
185 |
+
'name' => __( 'Hide Ads From Ajax Requests', 'quick-adsense-reloaded' ),
|
186 |
+
'desc' => __( 'If your site is using ajax based infinite loading it might happen that ads are loaded without any further post content. Disable this here.', 'quick-adsense-reloaded' ),
|
187 |
+
'type' => 'checkbox'
|
188 |
+
),
|
189 |
+
array(
|
190 |
+
'id' => 'quicktags',
|
191 |
+
'name' => __( 'Quicktags', 'quick-adsense-reloaded' ),
|
192 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
193 |
+
'type' => 'quicktags'
|
194 |
+
),
|
195 |
+
array(
|
196 |
+
'id' => 'adsTxtEnabled',
|
197 |
+
'name' => __( 'ads.txt - Automatic Creation', 'quick-adsense-reloaded' ),
|
198 |
+
'desc' => __( 'Create an ads.txt file', 'quick-adsense-reloaded' ),
|
199 |
+
"helper-desc" => sprintf(__( 'Allow WP QUADS to generate automatically the ads.txt file in root of your website domain. After enabling and saving settings,'
|
200 |
+
. ' check if your ads.txt is correct by opening: <a href="%1$s" target="_blank">%1$s</a> <br><a href="%2$s" target="_blank">Read here</a> to learn more about ads.txt', 'quick-adsense-reloaded' ),
|
201 |
+
get_site_url() . '/ads.txt',
|
202 |
+
'https://wpquads.com/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
|
203 |
+
),
|
204 |
+
'type' => 'checkbox'
|
205 |
+
),
|
206 |
+
array(
|
207 |
+
'id' => 'quicktags',
|
208 |
+
'name' => __( 'Quicktags', 'quick-adsense-reloaded' ),
|
209 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
210 |
+
'type' => 'quicktags'
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'id' => 'vi_header',
|
214 |
+
'name' => '<strong>' . __( 'vi ads', 'quick-adsense-reloaded' ) . '</strong>',
|
215 |
+
'desc' => '<strong>Native video ad units powered by video intelligence</strong>',
|
216 |
+
'type' => 'header'
|
217 |
+
),
|
218 |
+
array(
|
219 |
+
'id' => 'vi_signup',
|
220 |
+
'name' =>__( '', 'quick-adsense-reloaded' ) . '</strong>',
|
221 |
+
'type' => 'vi_signup'
|
222 |
+
),
|
223 |
+
/* 'load_scripts_footer' => array(
|
224 |
+
'id' => 'load_scripts_footer',
|
225 |
+
'name' => __( 'JS Load Order', 'quick-adsense-reloaded' ),
|
226 |
+
'desc' => __( 'Enable this to load all *.js files into footer. Make sure your theme uses the wp_footer() template tag in the appropriate place. Default: Disabled', 'quick-adsense-reloaded' ),
|
227 |
+
'type' => 'checkbox'
|
228 |
+
), */
|
229 |
+
'adsense_header' => array(
|
230 |
+
'id' => 'adsense_header',
|
231 |
+
'name' => '<strong>' . __( 'Ads', 'quick-adsense-reloaded' ) . '</strong>',
|
232 |
+
'desc' => '<div class="adsense_admin_header">' . __( 'Enter your ads below:</div>'
|
233 |
+
. '<ul style="margin-top:10px;">'
|
234 |
+
. '<li style="font-weight:600;">- <i>AdSense</i> for using <span style="font-weight:600;">AdSense Text & display Ads</span>!</li>'
|
235 |
+
. '<li style="font-weight:600;">- <i>Plain Text / HTML / JS</i> for all other ads! <br><strong>Caution:</strong> Adding AdSense code into <i>Plain Text</i> option can result in non-displayed ads!</li></ul>', 'quick-adsense-reloaded' )
|
236 |
+
. '</ul>'
|
237 |
+
. '<div style="clear:both;">' . sprintf( __( '<strong>Ads are not showing? Read the <a href="%s" target="_blank">troubleshooting guide</a> to find out how to resolve it.', 'quick-adsense-reloaded' ), 'http://wpquads.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpquads-settings&utm_medium=website&utm_term=toplink' ) . ''
|
238 |
+
. '<br><a href="http://wpquads.com/effective-adsense-banner-size-formats/?utm_campaign=plugin&utm_source=general_tab&utm_medium=admin&utm_content=best_banner_sizes" target="_blank">Read this</a> to find out the most effective AdSense banner sizes. </div>'
|
239 |
+
. '<div id="quads-open-toggle" class="button">' . __( 'Open All Ads', 'quick-adsense-reloaded' ) . '</div>',
|
240 |
+
'type' => 'header'
|
241 |
+
),
|
242 |
+
array(
|
243 |
+
'id' => 'quads_ads',
|
244 |
+
'name' => __( '', 'quick-adsense-reloaded' ),
|
245 |
+
'type' => 'ad_code'
|
246 |
+
),
|
247 |
+
array(
|
248 |
+
'id' => 'new_ad',
|
249 |
+
'name' => __( '', 'quick-adsense-reloaded' ),
|
250 |
+
'type' => 'new_ad',
|
251 |
+
),
|
252 |
+
'widget_header' => array(
|
253 |
+
'id' => 'widget_header',
|
254 |
+
'name' => '<strong>' . __( 'Widget Ads', 'quick-adsense-reloaded' ) . '</strong>',
|
255 |
+
'desc' => sprintf( __( 'After creating your ads here go to <a href="%s" target="_self">Appearance->Widgets</a> and drag the WP QUADS widget into place.', 'quick-adsense-reloaded' ), admin_url() . 'widgets.php' ),
|
256 |
+
'type' => 'header'
|
257 |
+
),
|
258 |
+
'ad1_widget' => array(
|
259 |
+
'id' => 'ad1_widget',
|
260 |
+
'name' => __( 'Ad widget 1', 'quick-adsense-reloaded' ),
|
261 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
262 |
+
'type' => 'adsense_widget',
|
263 |
+
'size' => 4
|
264 |
+
),
|
265 |
+
'ad2_widget' => array(
|
266 |
+
'id' => 'ad2_widget',
|
267 |
+
'name' => __( 'Ad widget 2', 'quick-adsense-reloaded' ),
|
268 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
269 |
+
'type' => 'adsense_widget',
|
270 |
+
'size' => 4
|
271 |
+
),
|
272 |
+
'ad3_widget' => array(
|
273 |
+
'id' => 'ad3_widget',
|
274 |
+
'name' => __( 'Ad widget 3', 'quick-adsense-reloaded' ),
|
275 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
276 |
+
'type' => 'adsense_widget',
|
277 |
+
'size' => 4
|
278 |
+
),
|
279 |
+
'ad4_widget' => array(
|
280 |
+
'id' => 'ad4_widget',
|
281 |
+
'name' => __( 'Ad widget 4', 'quick-adsense-reloaded' ),
|
282 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
283 |
+
'type' => 'adsense_widget',
|
284 |
+
'size' => 4
|
285 |
+
),
|
286 |
+
'ad5_widget' => array(
|
287 |
+
'id' => 'ad5_widget',
|
288 |
+
'name' => __( 'Ad widget 5', 'quick-adsense-reloaded' ),
|
289 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
290 |
+
'type' => 'adsense_widget',
|
291 |
+
'size' => 4
|
292 |
+
),
|
293 |
+
'ad6_widget' => array(
|
294 |
+
'id' => 'ad6_widget',
|
295 |
+
'name' => __( 'Ad widget 6', 'quick-adsense-reloaded' ),
|
296 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
297 |
+
'type' => 'adsense_widget',
|
298 |
+
'size' => 4
|
299 |
+
),
|
300 |
+
'ad7_widget' => array(
|
301 |
+
'id' => 'ad7_widget',
|
302 |
+
'name' => __( 'Ad widget 7', 'quick-adsense-reloaded' ),
|
303 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
304 |
+
'type' => 'adsense_widget',
|
305 |
+
'size' => 4
|
306 |
+
),
|
307 |
+
'ad8_widget' => array(
|
308 |
+
'id' => 'ad8_widget',
|
309 |
+
'name' => __( 'Ad widget 8', 'quick-adsense-reloaded' ),
|
310 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
311 |
+
'type' => 'adsense_widget',
|
312 |
+
'size' => 4
|
313 |
+
),
|
314 |
+
'ad9_widget' => array(
|
315 |
+
'id' => 'ad9_widget',
|
316 |
+
'name' => __( 'Ad widget 9', 'quick-adsense-reloaded' ),
|
317 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
318 |
+
'type' => 'adsense_widget',
|
319 |
+
'size' => 4
|
320 |
+
),
|
321 |
+
'ad10_widget' => array(
|
322 |
+
'id' => 'ad10_widget',
|
323 |
+
'name' => __( 'Ad widget 10', 'quick-adsense-reloaded' ),
|
324 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
325 |
+
'type' => 'adsense_widget',
|
326 |
+
'size' => 4
|
327 |
+
),
|
328 |
+
array(
|
329 |
+
'id' => 'plugin_header',
|
330 |
+
'name' => '<strong>' . __( 'Plugin Settings', 'quick-adsense-reloaded' ) . '</strong>',
|
331 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
332 |
+
'type' => 'header'
|
333 |
+
),
|
334 |
+
'priority' => array(
|
335 |
+
'id' => 'priority',
|
336 |
+
'name' => __( 'Load Priority', 'quick-adsense-reloaded' ),
|
337 |
+
//'desc' => __( 'Do not change this until you know what you are doing. Usually the default value 20 is working fine. Changing this value can lead to unexpected results like ads not showing or loaded on wrong order. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
|
338 |
+
'helper-desc' => __( 'Do not change this until you know what you are doing. Usually the default value 20 is working fine. Changing this value can lead to unexpected results like ads not showing or loaded on wrong order. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
|
339 |
+
'type' => 'number',
|
340 |
+
'size' => 'small',
|
341 |
+
'std' => 10
|
342 |
+
),
|
343 |
+
'create_settings' => array(
|
344 |
+
'id' => 'create_settings',
|
345 |
+
'name' => __( 'Remove menu button', 'quick-adsense-reloaded' ),
|
346 |
+
//'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
|
347 |
+
'desc' => __( 'Remove it' ),
|
348 |
+
'helper-desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
|
349 |
+
'type' => 'checkbox',
|
350 |
+
),
|
351 |
+
'disableAmpScript' => array(
|
352 |
+
'id' => 'disableAmpScript',
|
353 |
+
'name' => __( 'Disable AMP script', 'quick-adsense-reloaded' ),
|
354 |
+
//'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong>. This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
|
355 |
+
'desc' => __( 'Disable AMP Scripts' ),
|
356 |
+
'helper-desc' => __( 'Disable duplicate AMP ad script integration if your AMP plugin is already loading the script https://cdn.ampproject.org/v0/amp-ad-0.1.js into your site', 'quick-adsense-reloaded' ),
|
357 |
+
'type' => 'checkbox',
|
358 |
+
),
|
359 |
+
'uninstall_on_delete' => array(
|
360 |
+
'id' => 'uninstall_on_delete',
|
361 |
+
'name' => __( 'Delete Data on Uninstall?', 'quick-adsense-reloaded' ),
|
362 |
+
//'desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
|
363 |
+
'helper-desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
|
364 |
+
'desc' => 'Delete data',
|
365 |
+
'type' => 'checkbox'
|
366 |
+
),
|
367 |
+
'debug_mode' => array(
|
368 |
+
'id' => 'debug_mode',
|
369 |
+
'name' => __( 'Debug mode', 'quick-adsense-reloaded' ),
|
370 |
+
'desc' => __( 'Check this to not minify JavaScript and CSS files. This makes debugging much easier and is recommended setting for inspecting issues on your site', 'quick-adsense-reloaded' ),
|
371 |
+
'type' => 'checkbox'
|
372 |
+
)
|
373 |
+
)
|
374 |
+
),
|
375 |
+
'licenses' => apply_filters( 'quads_settings_licenses', array('licenses_header' => array(
|
376 |
+
'id' => 'licenses_header',
|
377 |
+
'name' => __( 'Activate Your License', 'quick-adsense-reloaded' ),
|
378 |
+
'desc' => '',
|
379 |
+
'type' => 'header'
|
380 |
+
),)
|
381 |
+
),
|
382 |
+
'extensions' => apply_filters( 'quads_settings_extension', array()
|
383 |
+
),
|
384 |
+
'addons' => apply_filters( 'quads_settings_addons', array(
|
385 |
+
'addons' => array(
|
386 |
+
'id' => 'addons',
|
387 |
+
'name' => __( '', 'quick-adsense-reloaded' ),
|
388 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
389 |
+
'type' => 'addons'
|
390 |
+
),
|
391 |
+
)
|
392 |
+
),
|
393 |
+
'imexport' => apply_filters( 'quads_settings_imexport', array(
|
394 |
+
'imexport' => array(
|
395 |
+
'id' => 'imexport',
|
396 |
+
'name' => __( '', 'quick-adsense-reloaded' ),
|
397 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
398 |
+
'type' => 'imexport'
|
399 |
+
)
|
400 |
+
)
|
401 |
+
),
|
402 |
+
'help' => apply_filters( 'quads_settings_help', array(
|
403 |
+
'help_header' => array(
|
404 |
+
'id' => 'help_header',
|
405 |
+
'name' => '<strong>' . __( 'Help', 'quick-adsense-reloaded' ) . '</strong>',
|
406 |
+
'desc' => quads_is_extra() ? sprintf( __( 'Something not working as expected? Open a <a href="%1s" target="_blank">support ticket</a>', 'quick-adsense-reloaded' ), 'http://wpquads.com/support/' ) : sprintf( __( 'Something not working as expected? Visit the WP<strong>QUADS</strong> <a href="%1s" target="_blank">Support Forum</a>', 'quick-adsense-reloaded' ), 'https://wordpress.org/support/plugin/quick-adsense-reloaded' ),
|
407 |
+
'type' => 'header'
|
408 |
+
),
|
409 |
+
'systeminfo' => array(
|
410 |
+
'id' => 'systeminfo',
|
411 |
+
'name' => __( 'Systeminfo', 'quick-adsense-reloaded' ),
|
412 |
+
'desc' => __( '', 'quick-adsense-reloaded' ),
|
413 |
+
'type' => 'systeminfo'
|
414 |
+
)
|
415 |
+
)
|
416 |
+
)
|
417 |
+
);
|
418 |
+
|
419 |
+
return $quads_settings;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* return empty settings
|
424 |
+
* @return string empty one
|
425 |
+
*/
|
426 |
+
function quads_empty_callback() {
|
427 |
+
return '';
|
428 |
+
}
|
429 |
+
|
430 |
+
/**
|
431 |
+
* Settings Sanitization
|
432 |
+
*
|
433 |
+
* Adds a settings error (for the updated message)
|
434 |
+
* At some point this will validate input
|
435 |
+
*
|
436 |
+
* @since 0.9.0
|
437 |
+
*
|
438 |
+
* @param array $input The value input in the field
|
439 |
+
*
|
440 |
+
* @return string $input Sanitized value
|
441 |
+
*/
|
442 |
+
function quads_settings_sanitize( $input = array() ) {
|
443 |
+
|
444 |
+
global $quads_options;
|
445 |
+
|
446 |
+
|
447 |
+
if( empty( $_POST['_wp_http_referer'] ) ) {
|
448 |
+
return $input;
|
449 |
+
}
|
450 |
+
|
451 |
+
parse_str( $_POST['_wp_http_referer'], $referrer );
|
452 |
+
|
453 |
+
$settings = quads_get_registered_settings();
|
454 |
+
$tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
|
455 |
+
|
456 |
+
|
457 |
+
$input = $input ? $input : array();
|
458 |
+
$input = apply_filters( 'quads_settings_' . $tab . '_sanitize', $input );
|
459 |
+
// Loop through each setting being saved and pass it through a sanitization filter
|
460 |
+
foreach ( $input as $key => $value ) {
|
461 |
+
|
462 |
+
// Get the setting type (checkbox, select, etc)
|
463 |
+
$type = isset( $settings[$tab][$key]['type'] ) ? $settings[$tab][$key]['type'] : false;
|
464 |
+
if( $type ) {
|
465 |
+
// Field type specific filter
|
466 |
+
$input[$key] = apply_filters( 'quads_settings_sanitize_' . $type, $value, $key );
|
467 |
+
}
|
468 |
+
|
469 |
+
// General filter
|
470 |
+
$input[$key] = apply_filters( 'quads_settings_sanitize', $value, $key );
|
471 |
+
}
|
472 |
+
//wp_die(var_dump($input));
|
473 |
+
|
474 |
+
|
475 |
+
// Loop through the whitelist and unset any that are empty for the tab being saved
|
476 |
+
if( !empty( $settings[$tab] ) ) {
|
477 |
+
foreach ( $settings[$tab] as $key => $value ) {
|
478 |
+
// settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
|
479 |
+
if( is_numeric( $key ) ) {
|
480 |
+
$key = $value['id'];
|
481 |
+
}
|
482 |
+
|
483 |
+
if( empty( $input[$key] ) ) {
|
484 |
+
unset( $quads_options[$key] );
|
485 |
+
}
|
486 |
+
}
|
487 |
+
}
|
488 |
+
|
489 |
+
|
490 |
+
// Merge our new settings with the existing
|
491 |
+
$output = array_merge( $quads_options, $input );
|
492 |
+
|
493 |
+
|
494 |
+
add_settings_error( 'quads-notices', '', __( 'Settings updated.', 'quick-adsense-reloaded' ), 'updated' );
|
495 |
+
|
496 |
+
return $output;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Sanitize all fields and remove whitespaces
|
501 |
+
*
|
502 |
+
* @since 1.5.3
|
503 |
+
* @param array $input The field value
|
504 |
+
* @return string $input Sanitizied value
|
505 |
+
*/
|
506 |
+
function quads_sanitize_general_field( $input ){
|
507 |
+
if (!is_array( $input )){
|
508 |
+
return trim($input);
|
509 |
+
}
|
510 |
+
return array_map('quads_sanitize_general_field', $input);
|
511 |
+
}
|
512 |
+
add_filter( 'quads_settings_sanitize', 'quads_sanitize_general_field' );
|
513 |
+
|
514 |
+
/**
|
515 |
+
* Sanitize text fields
|
516 |
+
*
|
517 |
+
* @since 1.8
|
518 |
+
* @param array $input The field value
|
519 |
+
* @return string $input Sanitizied value
|
520 |
+
*/
|
521 |
+
function quads_sanitize_text_field( $input ) {
|
522 |
+
return trim( $input );
|
523 |
+
}
|
524 |
+
add_filter( 'quads_settings_sanitize_text', 'quads_sanitize_text_field' );
|
525 |
+
|
526 |
+
/**
|
527 |
+
* Retrieve settings tabs
|
528 |
+
*
|
529 |
+
* @since 1.8
|
530 |
+
* @param array $input The field value
|
531 |
+
* @return string $input Sanitizied value
|
532 |
+
*/
|
533 |
+
function quads_get_settings_tabs() {
|
534 |
+
|
535 |
+
$settings = quads_get_registered_settings();
|
536 |
+
|
537 |
+
$tabs = array();
|
538 |
+
$tabs['general'] = __( 'General', 'quick-adsense-reloaded' );
|
539 |
+
|
540 |
+
if( !empty( $settings['visual'] ) ) {
|
541 |
+
$tabs['visual'] = __( 'Visual', 'quick-adsense-reloaded' );
|
542 |
+
}
|
543 |
+
|
544 |
+
if( !empty( $settings['networks'] ) ) {
|
545 |
+
//$tabs['networks'] = __( 'Social Networks', 'quick-adsense-reloaded' );
|
546 |
+
}
|
547 |
+
|
548 |
+
if( !empty( $settings['extensions'] ) ) {
|
549 |
+
$tabs['extensions'] = __( 'Add-On Setting', 'quick-adsense-reloaded' );
|
550 |
+
}
|
551 |
+
|
552 |
+
|
553 |
+
if( !empty( $settings['licenses'] ) && quads_is_extra() || quads_is_advanced() ) {
|
554 |
+
$tabs['licenses'] = __( 'Licenses', 'quick-adsense-reloaded' );
|
555 |
+
}
|
556 |
+
|
557 |
+
//$tabs['addons'] = __( 'Add-Ons', 'quick-adsense-reloaded' );
|
558 |
+
|
559 |
+
$tabs['imexport'] = __( 'Import/Export', 'quick-adsense-reloaded' );
|
560 |
+
|
561 |
+
$tabs['help'] = __( 'Help', 'quick-adsense-reloaded' );
|
562 |
+
|
563 |
+
//$tabs['misc'] = __( 'Misc', 'quick-adsense-reloaded' );
|
564 |
+
|
565 |
+
return apply_filters( 'quads_settings_tabs', $tabs );
|
566 |
+
}
|
567 |
+
|
568 |
+
/**
|
569 |
+
* Header Callback
|
570 |
+
*
|
571 |
+
* Renders the header.
|
572 |
+
*
|
573 |
+
* @since 1.0
|
574 |
+
* @param array $args Arguments passed by the setting
|
575 |
+
* @return void
|
576 |
+
*/
|
577 |
+
function quads_header_callback( $args ) {
|
578 |
+
if( !empty( $args['desc'] ) ) {
|
579 |
+
echo $args['desc'];
|
580 |
+
} else {
|
581 |
+
echo ' ';
|
582 |
+
}
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* Checkbox Callback
|
587 |
+
*
|
588 |
+
* Renders checkboxes.
|
589 |
+
*
|
590 |
+
* @since 1.0
|
591 |
+
* @param array $args Arguments passed by the setting
|
592 |
+
* @global $quads_options Array of all the QUADS Options
|
593 |
+
* @return void
|
594 |
+
*/
|
595 |
+
function quads_checkbox_callback( $args ) {
|
596 |
+
global $quads_options;
|
597 |
+
|
598 |
+
$checked = isset( $quads_options[$args['id']] ) ? checked( 1, $quads_options[$args['id']], false ) : '';
|
599 |
+
$html = '<input type="checkbox" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
600 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
601 |
+
|
602 |
+
echo $html;
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* Checkbox Callback
|
607 |
+
*
|
608 |
+
* Renders checkboxes.
|
609 |
+
*
|
610 |
+
* @since 1.0
|
611 |
+
* @param array $args Arguments passed by the setting
|
612 |
+
* @global $quads_options Array of all the QUADS Options
|
613 |
+
* @return void
|
614 |
+
*/
|
615 |
+
function quads_checkbox_adsense_callback( $args ) {
|
616 |
+
global $quads_options;
|
617 |
+
|
618 |
+
$checked = isset( $quads_options[$args['id']] ) ? checked( 1, $quads_options[$args['id']], false ) : '';
|
619 |
+
$html = '<input type="checkbox" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
|
620 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
621 |
+
|
622 |
+
return $html;
|
623 |
+
}
|
624 |
+
|
625 |
+
/**
|
626 |
+
* Multicheck Callback
|
627 |
+
*
|
628 |
+
* Renders multiple checkboxes.
|
629 |
+
*
|
630 |
+
* @since 1.0
|
631 |
+
* @param array $args Arguments passed by the setting
|
632 |
+
* @global $quads_options Array of all the QUADS Options
|
633 |
+
* @return void
|
634 |
+
*/
|
635 |
+
function quads_multicheck_callback( $args ) {
|
636 |
+
global $quads_options;
|
637 |
+
|
638 |
+
if( !empty( $args['options'] ) ) {
|
639 |
+
foreach ( $args['options'] as $key => $option ):
|
640 |
+
if( isset( $quads_options[$args['id']][$key] ) ) {
|
641 |
+
$enabled = $option;
|
642 |
+
} else {
|
643 |
+
$enabled = NULL;
|
644 |
+
}
|
645 |
+
echo '<input name="quads_settings[' . $args['id'] . '][' . $key . ']" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . $option . '" ' . checked( $option, $enabled, false ) . '/> ';
|
646 |
+
echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
|
647 |
+
endforeach;
|
648 |
+
echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
|
649 |
+
}
|
650 |
+
}
|
651 |
+
|
652 |
+
/**
|
653 |
+
* Radio Callback
|
654 |
+
*
|
655 |
+
* Renders radio boxes.
|
656 |
+
*
|
657 |
+
* @since 1.3.3
|
658 |
+
* @param array $args Arguments passed by the setting
|
659 |
+
* @global $quads_options Array of all the QUADS Options
|
660 |
+
* @return void
|
661 |
+
*/
|
662 |
+
function quads_radio_callback( $args ) {
|
663 |
+
global $quads_options;
|
664 |
+
|
665 |
+
foreach ( $args['options'] as $key => $option ) :
|
666 |
+
$checked = false;
|
667 |
+
|
668 |
+
if( isset( $quads_options[$args['id']] ) && $quads_options[$args['id']] == $key )
|
669 |
+
$checked = true;
|
670 |
+
elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options[$args['id']] ) )
|
671 |
+
$checked = true;
|
672 |
+
|
673 |
+
echo '<input name="quads_settings[' . $args['id'] . ']"" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
674 |
+
echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
|
675 |
+
endforeach;
|
676 |
+
|
677 |
+
echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
|
678 |
+
}
|
679 |
+
|
680 |
+
/**
|
681 |
+
* Radio Callback for ad types
|
682 |
+
*
|
683 |
+
* Renders radio boxes for specific ads
|
684 |
+
*
|
685 |
+
* @since 1.2.7
|
686 |
+
* @param1 array $args Arguments passed by the setting
|
687 |
+
* @param2 id int ID of the ad
|
688 |
+
*
|
689 |
+
* @global $quads_options Array of all the QUADS Options
|
690 |
+
* @return void
|
691 |
+
*/
|
692 |
+
function quads_adtype_callback( $id, $args ) {
|
693 |
+
global $quads_options;
|
694 |
+
|
695 |
+
foreach ( $args['options'] as $key => $option ) :
|
696 |
+
$checked = false;
|
697 |
+
|
698 |
+
if( isset( $quads_options['ads'][$id]['ad_type'] ) && $quads_options['ads'][$id]['ad_type'] == $key )
|
699 |
+
$checked = true;
|
700 |
+
elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options['ads'][$id]['ad_type'] ) )
|
701 |
+
$checked = true;
|
702 |
+
|
703 |
+
echo '<input name="quads_settings[ads][' . $id . '][ad_type]" class="quads_adsense_type" id="quads_settings[ads][' . $id . '][ad_type_' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
704 |
+
echo '<label for="quads_settings[ads][' . $id . '][ad_type_' . $key . ']">' . $option . '</label> ';
|
705 |
+
endforeach;
|
706 |
+
|
707 |
+
echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
|
708 |
+
}
|
709 |
+
|
710 |
+
/**
|
711 |
+
* Radio Callback for ad positions
|
712 |
+
*
|
713 |
+
* Renders radio boxes for left center right alignment
|
714 |
+
*
|
715 |
+
* @since 1.2.7
|
716 |
+
* @param1 array $args Arguments passed by the setting
|
717 |
+
* @param2 id int ID of the ad
|
718 |
+
*
|
719 |
+
* @global $quads_options Array of all the QUADS Options
|
720 |
+
* @return void
|
721 |
+
*/
|
722 |
+
function quads_adposition_callback( $id, $args ) {
|
723 |
+
global $quads_options;
|
724 |
+
|
725 |
+
foreach ( $args['options'] as $key => $option ) :
|
726 |
+
$checked = false;
|
727 |
+
|
728 |
+
if( isset( $quads_options['ads'][$id]['align'] ) && $quads_options['ads'][$id]['align'] == $key )
|
729 |
+
$checked = true;
|
730 |
+
elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options['ads'][$id]['align'] ) )
|
731 |
+
$checked = true;
|
732 |
+
|
733 |
+
if( $key == '3' ) {
|
734 |
+
echo '<input name="quads_settings[ads][' . $id . '][align]" class="quads_adsense_align" id="quads_settings[ads][' . $id . '][align_' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
735 |
+
echo '<label for="quads_settings[ads][' . $id . '][align_' . $key . ']">Default</label> ';
|
736 |
+
} else {
|
737 |
+
echo '<input name="quads_settings[ads][' . $id . '][align]" class="quads_adsense_positon" id="quads_settings[ads][' . $id . '][align_' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/> ';
|
738 |
+
echo '<label for="quads_settings[ads][' . $id . '][align_' . $key . ']"><img src="' . QUADS_PLUGIN_URL . 'assets/images/align_' . $key . '.png" width="75" height="56"></label> ';
|
739 |
+
}
|
740 |
+
|
741 |
+
endforeach;
|
742 |
+
}
|
743 |
+
|
744 |
+
|
745 |
+
/**
|
746 |
+
* Text Callback
|
747 |
+
*
|
748 |
+
* Renders text fields.
|
749 |
+
*
|
750 |
+
* @since 1.0
|
751 |
+
* @param array $args Arguments passed by the setting
|
752 |
+
* @global $quads_options Array of all the QUADS Options
|
753 |
+
* @return void
|
754 |
+
*/
|
755 |
+
function quads_text_callback( $args ) {
|
756 |
+
global $quads_options;
|
757 |
+
|
758 |
+
if( isset( $quads_options[$args['id']] ) )
|
759 |
+
$value = $quads_options[$args['id']];
|
760 |
+
else
|
761 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
762 |
+
|
763 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
764 |
+
$html = '<input type="text" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
765 |
+
$html .= '<label class="quads_hidden" class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
766 |
+
|
767 |
+
echo $html;
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Number Callback
|
772 |
+
*
|
773 |
+
* Renders number fields.
|
774 |
+
*
|
775 |
+
* @since 1.9
|
776 |
+
* @param array $args Arguments passed by the setting
|
777 |
+
* @global $quads_options Array of all the QUADS Options
|
778 |
+
* @return void
|
779 |
+
*/
|
780 |
+
function quads_number_callback( $args ) {
|
781 |
+
global $quads_options;
|
782 |
+
|
783 |
+
if( isset( $quads_options[$args['id']] ) )
|
784 |
+
$value = $quads_options[$args['id']];
|
785 |
+
else
|
786 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
787 |
+
|
788 |
+
$max = isset( $args['max'] ) ? $args['max'] : 999999;
|
789 |
+
$min = isset( $args['min'] ) ? $args['min'] : 0;
|
790 |
+
$step = isset( $args['step'] ) ? $args['step'] : 1;
|
791 |
+
|
792 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
793 |
+
$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
794 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
795 |
+
|
796 |
+
echo $html;
|
797 |
+
}
|
798 |
+
|
799 |
+
/**
|
800 |
+
* Textarea Callback
|
801 |
+
*
|
802 |
+
* Renders textarea fields.
|
803 |
+
*
|
804 |
+
* @since 1.0
|
805 |
+
* @param array $args Arguments passed by the setting
|
806 |
+
* @global $quads_options Array of all the QUADS Options
|
807 |
+
* @return void
|
808 |
+
*/
|
809 |
+
function quads_textarea_callback( $args ) {
|
810 |
+
global $quads_options;
|
811 |
+
|
812 |
+
if( isset( $quads_options[$args['id']] ) )
|
813 |
+
$value = $quads_options[$args['id']];
|
814 |
+
else
|
815 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
816 |
+
|
817 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : '40';
|
818 |
+
$html = '<textarea class="large-text quads-textarea" cols="50" rows="' . $size . '" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
819 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
820 |
+
|
821 |
+
echo $html;
|
822 |
+
}
|
823 |
+
|
824 |
+
/**
|
825 |
+
* Password Callback
|
826 |
+
*
|
827 |
+
* Renders password fields.
|
828 |
+
*
|
829 |
+
* @since 1.3
|
830 |
+
* @param array $args Arguments passed by the setting
|
831 |
+
* @global $quads_options Array of all the QUADS Options
|
832 |
+
* @return void
|
833 |
+
*/
|
834 |
+
function quads_password_callback( $args ) {
|
835 |
+
global $quads_options;
|
836 |
+
|
837 |
+
if( isset( $quads_options[$args['id']] ) )
|
838 |
+
$value = $quads_options[$args['id']];
|
839 |
+
else
|
840 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
841 |
+
|
842 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
843 |
+
$html = '<input type="password" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
|
844 |
+
$html .= '<label for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
845 |
+
|
846 |
+
echo $html;
|
847 |
+
}
|
848 |
+
|
849 |
+
/**
|
850 |
+
* Missing Callback
|
851 |
+
*
|
852 |
+
* If a function is missing for settings callbacks alert the user.
|
853 |
+
*
|
854 |
+
* @since 1.3.1
|
855 |
+
* @param array $args Arguments passed by the setting
|
856 |
+
* @return void
|
857 |
+
*/
|
858 |
+
function quads_missing_callback( $args ) {
|
859 |
+
printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'quick-adsense-reloaded' ), $args['id'] );
|
860 |
+
}
|
861 |
+
|
862 |
+
/**
|
863 |
+
* Select Callback
|
864 |
+
*
|
865 |
+
* Renders select fields.
|
866 |
+
*
|
867 |
+
* @since 1.0
|
868 |
+
* @param array $args Arguments passed by the setting
|
869 |
+
* @global $quads_options Array of all the QUADS Options
|
870 |
+
* @return void
|
871 |
+
*/
|
872 |
+
function quads_select_callback( $args ) {
|
873 |
+
global $quads_options;
|
874 |
+
|
875 |
+
if( isset( $quads_options[$args['id']] ) )
|
876 |
+
$value = $quads_options[$args['id']];
|
877 |
+
else
|
878 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
879 |
+
|
880 |
+
$html = '<select id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">';
|
881 |
+
|
882 |
+
foreach ( $args['options'] as $option => $name ) :
|
883 |
+
$selected = selected( $option, $value, false );
|
884 |
+
$html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
885 |
+
endforeach;
|
886 |
+
|
887 |
+
$html .= '</select>';
|
888 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
889 |
+
$html .= '<br>' . $args['desc2'];
|
890 |
+
|
891 |
+
echo $html;
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
* AdSense Type Select Callback
|
896 |
+
*
|
897 |
+
* Renders Adsense adsense type fields.
|
898 |
+
*
|
899 |
+
* @since 1.0
|
900 |
+
* @param1 array $args Arguments passed by the setting
|
901 |
+
* @param2 int $id if od the ad
|
902 |
+
* @global $quads_options Array of all the QUADS Options
|
903 |
+
* @return void
|
904 |
+
*/
|
905 |
+
function quads_adense_select_callback( $id, $args ) {
|
906 |
+
global $quads_options;
|
907 |
+
|
908 |
+
if( isset( $quads_options['ads'][$id][$args['id']] ) )
|
909 |
+
$value = $quads_options['ads'][$id][$args['id']];
|
910 |
+
else
|
911 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
912 |
+
|
913 |
+
|
914 |
+
$size = !empty( $args['size'] ) ? $args['size'] : 'quads-medium-size';
|
915 |
+
|
916 |
+
$htmlNew = '<label class="quads_hidden" id="quads-label-' . $args['desc'] . '" for="quads_settings[ads][' . $id . '][' . $args['id'] . ']"> ' . $args['desc'] . ' </label>';
|
917 |
+
$htmlNew .= '<select class="quads-select-' . $args['desc'] . ' ' . $size . '" id="quads_settings[ads][' . $id . '][' . $args['id'] . ']" name="quads_settings[ads][' . $id . '][' . $args['id'] . ']" >';
|
918 |
+
|
919 |
+
foreach ( $args['options'] as $option => $name ) {
|
920 |
+
$selected = selected( $option, $value, false );
|
921 |
+
$htmlNew .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
|
922 |
+
}
|
923 |
+
|
924 |
+
$htmlNew .= '</select>';
|
925 |
+
echo $htmlNew;
|
926 |
+
}
|
927 |
+
|
928 |
+
/**
|
929 |
+
* Color select Callback
|
930 |
+
*
|
931 |
+
* Renders color select fields.
|
932 |
+
*
|
933 |
+
* @since 2.1.2
|
934 |
+
* @param array $args Arguments passed by the setting
|
935 |
+
* @global $quads_options Array of all the QUADS Options
|
936 |
+
* @return void
|
937 |
+
*/
|
938 |
+
function quads_color_select_callback( $args ) {
|
939 |
+
global $quads_options;
|
940 |
+
|
941 |
+
if( isset( $quads_options[$args['id']] ) )
|
942 |
+
$value = $quads_options[$args['id']];
|
943 |
+
else
|
944 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
945 |
+
|
946 |
+
$html = '<strong>#:</strong><input type="text" style="max-width:80px;border:1px solid #' . esc_attr( stripslashes( $value ) ) . ';border-right:20px solid #' . esc_attr( stripslashes( $value ) ) . ';" id="quads_settings[' . $args['id'] . ']" class="medium-text ' . $args['id'] . '" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
947 |
+
|
948 |
+
$html .= '</select>';
|
949 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
950 |
+
|
951 |
+
echo $html;
|
952 |
+
}
|
953 |
+
|
954 |
+
/**
|
955 |
+
* Rich Editor Callback
|
956 |
+
*
|
957 |
+
* Renders rich editor fields.
|
958 |
+
*
|
959 |
+
* @since 1.0
|
960 |
+
* @param array $args Arguments passed by the setting
|
961 |
+
* @global $quads_options Array of all the QUADS Options
|
962 |
+
* @global $wp_version WordPress Version
|
963 |
+
*/
|
964 |
+
function quads_rich_editor_callback( $args ) {
|
965 |
+
global $quads_options, $wp_version;
|
966 |
+
if( isset( $quads_options[$args['id']] ) )
|
967 |
+
$value = $quads_options[$args['id']];
|
968 |
+
else
|
969 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
970 |
+
|
971 |
+
if( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
|
972 |
+
ob_start();
|
973 |
+
wp_editor( stripslashes( $value ), 'quads_settings_' . $args['id'], array('textarea_name' => 'quads_settings[' . $args['id'] . ']', 'textarea_rows' => $args['textarea_rows']) );
|
974 |
+
$html = ob_get_clean();
|
975 |
+
} else {
|
976 |
+
$html = '<textarea class="large-text quads-richeditor" rows="10" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
977 |
+
}
|
978 |
+
|
979 |
+
$html .= '<br/><label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
980 |
+
|
981 |
+
echo $html;
|
982 |
+
}
|
983 |
+
|
984 |
+
/**
|
985 |
+
* Upload Callback
|
986 |
+
*
|
987 |
+
* Renders upload fields.
|
988 |
+
*
|
989 |
+
* @since 1.0
|
990 |
+
* @param array $args Arguments passed by the setting
|
991 |
+
* @global $quads_options Array of all the QUADS Options
|
992 |
+
* @return void
|
993 |
+
*/
|
994 |
+
function quads_upload_callback( $args ) {
|
995 |
+
global $quads_options;
|
996 |
+
|
997 |
+
if( isset( $quads_options[$args['id']] ) )
|
998 |
+
$value = $quads_options[$args['id']];
|
999 |
+
else
|
1000 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1001 |
+
|
1002 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1003 |
+
$html = '<input type="text" class="' . $size . '-text quads_upload_field" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
|
1004 |
+
$html .= '<span> <input type="button" class="quads_settings_upload_button button-secondary" value="' . __( 'Upload File', 'quick-adsense-reloaded' ) . '"/></span>';
|
1005 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
1006 |
+
|
1007 |
+
echo $html;
|
1008 |
+
}
|
1009 |
+
|
1010 |
+
|
1011 |
+
/**
|
1012 |
+
* Check if extra settings are available and activated
|
1013 |
+
*
|
1014 |
+
* @return boolean
|
1015 |
+
*/
|
1016 |
+
function quads_is_extra() {
|
1017 |
+
|
1018 |
+
if( !function_exists( 'quads_extra' ) ) {
|
1019 |
+
return false;
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
$lic = get_option( 'quads_wp_quads_pro_license_active' );
|
1023 |
+
|
1024 |
+
if (!$lic){
|
1025 |
+
return false;
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
if (isset($lic->error) && $lic->error === 'expired'){
|
1029 |
+
return true;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
if (isset($lic->license) && $lic->license === 'valid'){
|
1033 |
+
return true;
|
1034 |
+
}
|
1035 |
+
|
1036 |
+
if (isset($lic->license) && $lic->license === 'inactive'){
|
1037 |
+
return false;
|
1038 |
+
}
|
1039 |
+
|
1040 |
+
|
1041 |
+
// if( !$lic || (is_object( $lic ) && $lic->success !== true) ) {
|
1042 |
+
// return false;
|
1043 |
+
// }
|
1044 |
+
|
1045 |
+
return false;
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
/**
|
1049 |
+
* Color picker Callback
|
1050 |
+
*
|
1051 |
+
* Renders color picker fields.
|
1052 |
+
*
|
1053 |
+
* @since 1.6
|
1054 |
+
* @param array $args Arguments passed by the setting
|
1055 |
+
* @global $quads_options Array of all the QUADS Options
|
1056 |
+
* @return void
|
1057 |
+
*/
|
1058 |
+
function quads_color_callback( $args ) {
|
1059 |
+
global $quads_options;
|
1060 |
+
|
1061 |
+
if( isset( $quads_options[$args['id']] ) )
|
1062 |
+
$value = $quads_options[$args['id']];
|
1063 |
+
else
|
1064 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1065 |
+
|
1066 |
+
$default = isset( $args['std'] ) ? $args['std'] : '';
|
1067 |
+
|
1068 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1069 |
+
$html = '<input type="text" class="quads-color-picker" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
|
1070 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
1071 |
+
|
1072 |
+
echo $html;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
/**
|
1076 |
+
* Registers the license field callback
|
1077 |
+
*
|
1078 |
+
* @since 3.0.0
|
1079 |
+
* @param array $args Arguments passed by the setting
|
1080 |
+
* @global $quads_options Array of all the QUADS options
|
1081 |
+
* @return void
|
1082 |
+
*/
|
1083 |
+
if( !function_exists( 'quads_license_key_callback' ) ) {
|
1084 |
+
|
1085 |
+
function quads_license_key_callback( $args ) {
|
1086 |
+
global $quads_options;
|
1087 |
+
|
1088 |
+
$class = '';
|
1089 |
+
|
1090 |
+
$messages = array();
|
1091 |
+
$license = get_option( $args['options']['is_valid_license_option'] );
|
1092 |
+
|
1093 |
+
|
1094 |
+
if( isset( $quads_options[$args['id']] ) ) {
|
1095 |
+
$value = $quads_options[$args['id']];
|
1096 |
+
} else {
|
1097 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
if( !empty( $license ) && is_object( $license ) ) {
|
1101 |
+
|
1102 |
+
|
1103 |
+
// activate_license 'invalid' on anything other than valid, so if there was an error capture it
|
1104 |
+
if( false === $license->success ) {
|
1105 |
+
|
1106 |
+
switch ( $license->error ) {
|
1107 |
+
|
1108 |
+
case 'expired' :
|
1109 |
+
|
1110 |
+
$class = 'error';
|
1111 |
+
$messages[] = sprintf(
|
1112 |
+
__( 'Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=license_tab&utm_medium=admin&utm_content=license-expired'
|
1113 |
+
);
|
1114 |
+
|
1115 |
+
$license_status = 'quads-license-' . $class . '-notice';
|
1116 |
+
|
1117 |
+
break;
|
1118 |
+
|
1119 |
+
case 'missing' :
|
1120 |
+
|
1121 |
+
$class = 'error';
|
1122 |
+
$messages[] = sprintf(
|
1123 |
+
__( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'quick-adsense-reloaded' ), 'http://wpquads.com/your-account?utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license&utm_campaign=notice'
|
1124 |
+
);
|
1125 |
+
|
1126 |
+
$license_status = 'quads-license-' . $class . '-notice';
|
1127 |
+
|
1128 |
+
break;
|
1129 |
+
|
1130 |
+
case 'invalid' :
|
1131 |
+
case 'site_inactive' :
|
1132 |
+
|
1133 |
+
$class = 'error';
|
1134 |
+
$messages[] = sprintf(
|
1135 |
+
__( 'Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'quick-adsense-reloaded' ), $args['name'], 'http://wpquads.com/your-account?utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license'
|
1136 |
+
);
|
1137 |
+
|
1138 |
+
$license_status = 'quads-license-' . $class . '-notice';
|
1139 |
+
|
1140 |
+
break;
|
1141 |
+
|
1142 |
+
case 'item_name_mismatch' :
|
1143 |
+
|
1144 |
+
$class = 'error';
|
1145 |
+
$messages[] = sprintf( __( 'This is not a %s.', 'quick-adsense-reloaded' ), $args['name'] );
|
1146 |
+
|
1147 |
+
$license_status = 'quads-license-' . $class . '-notice';
|
1148 |
+
|
1149 |
+
break;
|
1150 |
+
|
1151 |
+
case 'no_activations_left':
|
1152 |
+
|
1153 |
+
$class = 'error';
|
1154 |
+
$messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s" target="_blank">View possible upgrades</a> now.', 'quick-adsense-reloaded' ), 'http://wpquads.com/your-account?utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license' );
|
1155 |
+
|
1156 |
+
$license_status = 'quads-license-' . $class . '-notice';
|
1157 |
+
|
1158 |
+
break;
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
} else {
|
1162 |
+
|
1163 |
+
switch ( $license->license ) {
|
1164 |
+
|
1165 |
+
case 'valid' :
|
1166 |
+
default:
|
1167 |
+
|
1168 |
+
$class = 'valid';
|
1169 |
+
|
1170 |
+
$now = current_time( 'timestamp' );
|
1171 |
+
$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
|
1172 |
+
|
1173 |
+
if( 'lifetime' === $license->expires ) {
|
1174 |
+
|
1175 |
+
$messages[] = __( 'License key never expires.', 'quick-adsense-reloaded' );
|
1176 |
+
|
1177 |
+
$license_status = 'quads-license-lifetime-notice';
|
1178 |
+
} elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
|
1179 |
+
|
1180 |
+
$messages[] = sprintf(
|
1181 |
+
__( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
|
1182 |
+
);
|
1183 |
+
|
1184 |
+
$license_status = 'quads-license-expires-soon-notice';
|
1185 |
+
} else {
|
1186 |
+
|
1187 |
+
$messages[] = sprintf(
|
1188 |
+
__( 'Your license key expires on %s.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
|
1189 |
+
);
|
1190 |
+
|
1191 |
+
$license_status = 'quads-license-expiration-date-notice';
|
1192 |
+
}
|
1193 |
+
break;
|
1194 |
+
|
1195 |
+
case 'inactive' :
|
1196 |
+
$messages[] = sprintf(
|
1197 |
+
__( 'Your license key has been disabled! <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
|
1198 |
+
);
|
1199 |
+
$license_status = 'quads-license-error-notice';
|
1200 |
+
break;
|
1201 |
+
}
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
// switch ( $license->license ) {
|
1205 |
+
// case 'invalid' :
|
1206 |
+
// $messages[] = sprintf(
|
1207 |
+
// __( 'Your license key has been disabled! <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
|
1208 |
+
// );
|
1209 |
+
// break;
|
1210 |
+
// }
|
1211 |
+
|
1212 |
+
} else {
|
1213 |
+
$license_status = null;
|
1214 |
+
|
1215 |
+
}
|
1216 |
+
|
1217 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1218 |
+
$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']" name="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
|
1219 |
+
|
1220 |
+
if( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) {
|
1221 |
+
$html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'quick-adsense-reloaded' ) . '"/>';
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
$html .= '<label for="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
|
1225 |
+
|
1226 |
+
if( !empty( $messages ) ) {
|
1227 |
+
foreach ( $messages as $message ) {
|
1228 |
+
|
1229 |
+
$html .= '<div class="quads-license-data quads-license-' . $class . '">';
|
1230 |
+
$html .= '<p>' . $message . '</p>';
|
1231 |
+
$html .= '</div>';
|
1232 |
+
}
|
1233 |
+
}
|
1234 |
+
|
1235 |
+
wp_nonce_field( quads_sanitize_key( $args['id'] ) . '-nonce', quads_sanitize_key( $args['id'] ) . '-nonce' );
|
1236 |
+
|
1237 |
+
if( isset( $license_status ) ) {
|
1238 |
+
echo '<div class="' . $license_status . '">' . $html . '</div>';
|
1239 |
+
} else {
|
1240 |
+
echo '<div class="quads-license-null">' . $html . '</div>';
|
1241 |
+
}
|
1242 |
+
}
|
1243 |
+
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
/**
|
1247 |
+
* Registers the Add-Ons field callback for WPQUADS Add-Ons
|
1248 |
+
*
|
1249 |
+
* @since 2.0.5
|
1250 |
+
* @param array $args Arguments passed by the setting
|
1251 |
+
* @return html
|
1252 |
+
*/
|
1253 |
+
function quads_addons_callback( $args ) {
|
1254 |
+
$html = quads_add_ons_page();
|
1255 |
+
echo $html;
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
/**
|
1259 |
+
* Registers the im/export callback for WPQUADS
|
1260 |
+
*
|
1261 |
+
* @since 0.9.0
|
1262 |
+
* @param array $args Arguments passed by the setting
|
1263 |
+
* @return html
|
1264 |
+
*/
|
1265 |
+
function quads_imexport_callback( $args ) {
|
1266 |
+
$html = quads_tools_import_export_display();
|
1267 |
+
$html .= quads_import_quick_adsense_settings();
|
1268 |
+
echo $html;
|
1269 |
+
}
|
1270 |
+
|
1271 |
+
/**
|
1272 |
+
* Registers the system info for WPQUADS
|
1273 |
+
*
|
1274 |
+
* @since 0.9.0
|
1275 |
+
* @param array $args Arguments passed by the setting
|
1276 |
+
* @return html
|
1277 |
+
*/
|
1278 |
+
function quads_systeminfo_callback( $args ) {
|
1279 |
+
$html = quads_tools_sysinfo_display();
|
1280 |
+
echo $html;
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
/**
|
1284 |
+
* Registers the image upload field
|
1285 |
+
*
|
1286 |
+
* @since 1.0
|
1287 |
+
* @param array $args Arguments passed by the setting
|
1288 |
+
* @global $quads_options Array of all the QUADS Options
|
1289 |
+
* @return void
|
1290 |
+
*/
|
1291 |
+
function quads_upload_image_callback( $args ) {
|
1292 |
+
global $quads_options;
|
1293 |
+
|
1294 |
+
if( isset( $quads_options[$args['id']] ) )
|
1295 |
+
$value = $quads_options[$args['id']];
|
1296 |
+
else
|
1297 |
+
$value = isset( $args['std'] ) ? $args['std'] : '';
|
1298 |
+
|
1299 |
+
$size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
|
1300 |
+
$html = '<input type="text" class="' . $size . '-text ' . $args['id'] . '" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
|
1301 |
+
|
1302 |
+
$html .= '<input type="submit" class="button-secondary quads_upload_image" name="' . $args['id'] . '_upload" value="' . __( 'Select Image', 'quick-adsense-reloaded' ) . '"/>';
|
1303 |
+
|
1304 |
+
$html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
|
1305 |
+
|
1306 |
+
echo $html;
|
1307 |
+
}
|
1308 |
+
|
1309 |
+
/*
|
1310 |
+
* Note Callback
|
1311 |
+
*
|
1312 |
+
* Show a note
|
1313 |
+
*
|
1314 |
+
* @since 2.2.8
|
1315 |
+
* @param array $args Arguments passed by the setting
|
1316 |
+
* @return void
|
1317 |
+
*
|
1318 |
+
*/
|
1319 |
+
|
1320 |
+
function quads_note_callback( $args ) {
|
1321 |
+
global $quads_options;
|
1322 |
+
$html = '';
|
1323 |
+
echo $html;
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
/**
|
1327 |
+
* Additional content Callback
|
1328 |
+
* Adds several content text boxes selectable via jQuery easytabs()
|
1329 |
+
*
|
1330 |
+
* @param array $args
|
1331 |
+
* @return string $html
|
1332 |
+
* @scince 2.3.2
|
1333 |
+
*/
|
1334 |
+
function quads_add_content_callback( $args ) {
|
1335 |
+
global $quads_options;
|
1336 |
+
|
1337 |
+
$html = '<div id="quadstabcontainer" class="tabcontent_container"><ul class="quadstabs" style="width:99%;max-width:500px;">';
|
1338 |
+
foreach ( $args['options'] as $option => $name ) :
|
1339 |
+
$html .= '<li class="quadstab" style="float:left;margin-right:4px;"><a href="#' . $name['id'] . '">' . $name['name'] . '</a></li>';
|
1340 |
+
endforeach;
|
1341 |
+
$html .= '</ul>';
|
1342 |
+
$html .= '<div class="quadstab-container">';
|
1343 |
+
foreach ( $args['options'] as $option => $name ) :
|
1344 |
+
$value = isset( $quads_options[$name['id']] ) ? $quads_options[$name['id']] : '';
|
1345 |
+
$textarea = '<textarea class="large-text quads-textarea" cols="50" rows="15" id="quads_settings[' . $name['id'] . ']" name="quads_settings[' . $name['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
|
1346 |
+
$html .= '<div id="' . $name['id'] . '" style="max-width:500px;"><span style="padding-top:60px;display:block;">' . $name['desc'] . ':</span><br>' . $textarea . '</div>';
|
1347 |
+
endforeach;
|
1348 |
+
$html .= '</div>';
|
1349 |
+
$html .= '</div>';
|
1350 |
+
echo $html;
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
/**
|
1354 |
+
* Hook Callback
|
1355 |
+
*
|
1356 |
+
* Adds a do_action() hook in place of the field
|
1357 |
+
*
|
1358 |
+
* @since 1.0.8.2
|
1359 |
+
* @param array $args Arguments passed by the setting
|
1360 |
+
* @return void
|
1361 |
+
*/
|
1362 |
+
function quads_hook_callback( $args ) {
|
1363 |
+
do_action( 'quads_' . $args['id'] );
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
/**
|
1367 |
+
* Set manage_options as the cap required to save QUADS settings pages
|
1368 |
+
*
|
1369 |
+
* @since 1.9
|
1370 |
+
* @return string capability required
|
1371 |
+
*/
|
1372 |
+
function quads_set_settings_cap() {
|
1373 |
+
return 'manage_options';
|
1374 |
+
}
|
1375 |
+
|
1376 |
+
add_filter( 'option_page_capability_quads_settings', 'quads_set_settings_cap' );
|
1377 |
+
|
1378 |
+
|
1379 |
+
|
1380 |
+
|
1381 |
+
/* returns Cache Status if enabled or disabled
|
1382 |
+
*
|
1383 |
+
* @since 2.0.4
|
1384 |
+
* @return string
|
1385 |
+
*/
|
1386 |
+
|
1387 |
+
function quads_cache_status() {
|
1388 |
+
global $quads_options;
|
1389 |
+
if( isset( $quads_options['disable_cache'] ) ) {
|
1390 |
+
return ' <strong style="color:red;">' . __( 'Transient Cache disabled! Enable it for performance increase.', 'quick-adsense-reloaded' ) . '</strong> ';
|
1391 |
+
}
|
1392 |
+
}
|
1393 |
+
|
1394 |
+
/* Permission check if logfile is writable
|
1395 |
+
*
|
1396 |
+
* @since 2.0.6
|
1397 |
+
* @return string
|
1398 |
+
*/
|
1399 |
+
|
1400 |
+
function quads_log_permissions() {
|
1401 |
+
global $quads_options;
|
1402 |
+
if( !$quads->logger->checkDir() ) {
|
1403 |
+
return '<br><strong style="color:red;">' . __( 'Log file directory not writable! Set FTP permission to 755 or 777 for /wp-content/plugins/quadssharer/logs/', 'quick-adsense-reloaded' ) . '</strong> <br> Read here more about <a href="http://codex.wordpress.org/Changing_File_Permissions" target="_blank">file permissions</a> ';
|
1404 |
+
}
|
1405 |
+
}
|
1406 |
+
|
1407 |
+
/**
|
1408 |
+
* Get number of available ads
|
1409 |
+
*
|
1410 |
+
* @global $quads_options $quads_options
|
1411 |
+
* @return array
|
1412 |
+
*/
|
1413 |
+
function quads_get_ads() {
|
1414 |
+
global $quads_options;
|
1415 |
+
|
1416 |
+
if (!isset($quads_options['ads']) || ( isset($quads_options['ads']) && count( $quads_options['ads'] ) === 0) ) {
|
1417 |
+
$ads = array(
|
1418 |
+
0 => __( 'Random Ads', 'quick-adsense-reloaded' ),
|
1419 |
+
1 => isset( $quads_options['ads']['ad1']['label'] ) ? $quads_options['ads']['ad1']['label'] : 'ad1',
|
1420 |
+
2 => isset( $quads_options['ads']['ad2']['label'] ) ? $quads_options['ads']['ad2']['label'] : 'ad2',
|
1421 |
+
3 => isset( $quads_options['ads']['ad3']['label'] ) ? $quads_options['ads']['ad3']['label'] : 'ad3',
|
1422 |
+
4 => isset( $quads_options['ads']['ad4']['label'] ) ? $quads_options['ads']['ad4']['label'] : 'ad4',
|
1423 |
+
5 => isset( $quads_options['ads']['ad5']['label'] ) ? $quads_options['ads']['ad5']['label'] : 'ad5',
|
1424 |
+
6 => isset( $quads_options['ads']['ad6']['label'] ) ? $quads_options['ads']['ad6']['label'] : 'ad6',
|
1425 |
+
7 => isset( $quads_options['ads']['ad7']['label'] ) ? $quads_options['ads']['ad7']['label'] : 'ad7',
|
1426 |
+
8 => isset( $quads_options['ads']['ad8']['label'] ) ? $quads_options['ads']['ad8']['label'] : 'ad8',
|
1427 |
+
9 => isset( $quads_options['ads']['ad9']['label'] ) ? $quads_options['ads']['ad9']['label'] : 'ad9',
|
1428 |
+
10 => isset( $quads_option['ads']['ad10']['label'] ) ? $quads_options['ads']['ad10']['label'] : 'ad10',
|
1429 |
+
);
|
1430 |
+
return $ads;
|
1431 |
+
}
|
1432 |
+
|
1433 |
+
// Start array with
|
1434 |
+
$arrHeader = array ( 0 => __( 'Random Ads', 'quick-adsense-reloaded' ) );
|
1435 |
+
|
1436 |
+
$ads = array();
|
1437 |
+
|
1438 |
+
foreach ( $quads_options['ads'] as $key => $value ){
|
1439 |
+
// Skip all widget ads
|
1440 |
+
if ( false !== strpos($key, '_widget') ){
|
1441 |
+
continue;
|
1442 |
+
}
|
1443 |
+
// Create array
|
1444 |
+
if (!empty( $value['label'] ) ) {
|
1445 |
+
$ads[] = $value['label'];
|
1446 |
+
} else {
|
1447 |
+
$ads[] = $key;
|
1448 |
+
}
|
1449 |
+
|
1450 |
+
}
|
1451 |
+
|
1452 |
+
return array_merge($arrHeader, $ads);
|
1453 |
+
|
1454 |
+
// $ads = array(
|
1455 |
+
// 0 => __( 'Random Ads', 'quick-adsense-reloaded' ),
|
1456 |
+
// 1 => isset( $quads_options['ads']['ad1']['label'] ) ? $quads_options['ads']['ad1']['label'] : 'ad1',
|
1457 |
+
// 2 => isset( $quads_options['ads']['ad2']['label'] ) ? $quads_options['ads']['ad2']['label'] : 'ad2',
|
1458 |
+
// 3 => isset( $quads_options['ads']['ad3']['label'] ) ? $quads_options['ads']['ad3']['label'] : 'ad3',
|
1459 |
+
// 4 => isset( $quads_options['ads']['ad4']['label'] ) ? $quads_options['ads']['ad4']['label'] : 'ad4',
|
1460 |
+
// 5 => isset( $quads_options['ads']['ad5']['label'] ) ? $quads_options['ads']['ad5']['label'] : 'ad5',
|
1461 |
+
// 6 => isset( $quads_options['ads']['ad6']['label'] ) ? $quads_options['ads']['ad6']['label'] : 'ad6',
|
1462 |
+
// 7 => isset( $quads_options['ads']['ad7']['label'] ) ? $quads_options['ads']['ad7']['label'] : 'ad7',
|
1463 |
+
// 8 => isset( $quads_options['ads']['ad8']['label'] ) ? $quads_options['ads']['ad8']['label'] : 'ad8',
|
1464 |
+
// 9 => isset( $quads_options['ads']['ad9']['label'] ) ? $quads_options['ads']['ad9']['label'] : 'ad9',
|
1465 |
+
// 10 => isset( $quads_option['ads']['ad10']['label'] ) ? $quads_options['ads']['ad10']['label'] : 'ad10',
|
1466 |
+
// );
|
1467 |
+
//return $ads;
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
/**
|
1471 |
+
* Get array of 1 to 50 for image and paragraph dropdown values
|
1472 |
+
*
|
1473 |
+
* @global $quads_options $quads_options
|
1474 |
+
* @return array
|
1475 |
+
*/
|
1476 |
+
function quads_get_values() {
|
1477 |
+
|
1478 |
+
$array = array(1);
|
1479 |
+
for ( $i = 1; $i <= 50; $i++ ) {
|
1480 |
+
$array[] = $i;
|
1481 |
+
}
|
1482 |
+
unset( $array[0] ); // remove the 0 and start the array with 1
|
1483 |
+
return $array;
|
1484 |
+
}
|
1485 |
+
|
1486 |
+
/**
|
1487 |
+
* Visibility Callback
|
1488 |
+
*
|
1489 |
+
* Renders fields for ad visibility
|
1490 |
+
*
|
1491 |
+
* @since 0.9.0
|
1492 |
+
* @param array $args Arguments passed by the setting
|
1493 |
+
* @global $quads_options Array of all the QUADS Options
|
1494 |
+
* @return void
|
1495 |
+
*/
|
1496 |
+
function quads_visibility_callback( $args ) {
|
1497 |
+
global $quads_options, $quads;
|
1498 |
+
|
1499 |
+
$html = $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppHome]', 'current' => !empty( $quads_options['visibility']['AppHome'] ) ? $quads_options['visibility']['AppHome'] : null, 'class' => 'quads-checkbox') ) . __( 'Homepage ', 'quick-adsense-reloaded' );
|
1500 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppCate]', 'current' => !empty( $quads_options['visibility']['AppCate'] ) ? $quads_options['visibility']['AppCate'] : null, 'class' => 'quads-checkbox') ) . __( 'Categories ', 'quick-adsense-reloaded' );
|
1501 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppArch]', 'current' => !empty( $quads_options['visibility']['AppArch'] ) ? $quads_options['visibility']['AppArch'] : null, 'class' => 'quads-checkbox') ) . __( 'Archives ', 'quick-adsense-reloaded' );
|
1502 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppTags]', 'current' => !empty( $quads_options['visibility']['AppTags'] ) ? $quads_options['visibility']['AppTags'] : null, 'class' => 'quads-checkbox') ) . __( 'Tags', 'quick-adsense-reloaded' ) . '<br>';
|
1503 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppSide]', 'current' => !empty( $quads_options['visibility']['AppSide'] ) ? $quads_options['visibility']['AppSide'] : null, 'class' => 'quads-checkbox') ) . __( 'Hide Ad Widgets on Homepage', 'quick-adsense-reloaded' ) . '<br>';
|
1504 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppLogg]', 'current' => !empty( $quads_options['visibility']['AppLogg'] ) ? $quads_options['visibility']['AppLogg'] : null, 'class' => 'quads-checkbox') ) . __( 'Hide Ads when user is logged in.', 'quick-adsense-reloaded' ) . '<br>';
|
1505 |
+
|
1506 |
+
echo $html;
|
1507 |
+
}
|
1508 |
+
|
1509 |
+
/**
|
1510 |
+
* Ad position Callback
|
1511 |
+
*
|
1512 |
+
* Renders multioptions fields for ad position
|
1513 |
+
*
|
1514 |
+
* @since 0.9.0
|
1515 |
+
* @param array $args Arguments passed by the setting
|
1516 |
+
* @global $quads_options Array of all the QUADS Options
|
1517 |
+
* @return void
|
1518 |
+
*/
|
1519 |
+
function quads_ad_position_callback( $args ) {
|
1520 |
+
global $quads_options, $quads;
|
1521 |
+
|
1522 |
+
|
1523 |
+
// Pos 1
|
1524 |
+
$html = $quads->html->checkbox( array('name' => 'quads_settings[pos1][BegnAds]', 'current' => !empty( $quads_options['pos1']['BegnAds'] ) ? $quads_options['pos1']['BegnAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1525 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1526 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos1][BegnRnd]', 'name' => 'quads_settings[pos1][BegnRnd]', 'selected' => !empty( $quads_options['pos1']['BegnRnd'] ) ? $quads_options['pos1']['BegnRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1527 |
+
$html .= ' ' . __( 'to <strong>Beginning of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1528 |
+
|
1529 |
+
// Pos 2
|
1530 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos2][MiddAds]', 'current' => !empty( $quads_options['pos2']['MiddAds'] ) ? $quads_options['pos2']['MiddAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1531 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1532 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos2][MiddRnd]', 'name' => 'quads_settings[pos2][MiddRnd]', 'selected' => !empty( $quads_options['pos2']['MiddRnd'] ) ? $quads_options['pos2']['MiddRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1533 |
+
$html .= ' ' . __( 'to <strong>Middle of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1534 |
+
|
1535 |
+
// Pos 3
|
1536 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos3][EndiAds]', 'current' => !empty( $quads_options['pos3']['EndiAds'] ) ? $quads_options['pos3']['EndiAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1537 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1538 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos3][EndiRnd]', 'name' => 'quads_settings[pos3][EndiRnd]', 'selected' => !empty( $quads_options['pos3']['EndiRnd'] ) ? $quads_options['pos3']['EndiRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1539 |
+
$html .= ' ' . __( 'to <strong>End of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1540 |
+
|
1541 |
+
// Pos 4
|
1542 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos4][MoreAds]', 'current' => !empty( $quads_options['pos4']['MoreAds'] ) ? $quads_options['pos4']['MoreAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1543 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1544 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos4][MoreRnd]', 'name' => 'quads_settings[pos4][MoreRnd]', 'selected' => !empty( $quads_options['pos4']['MoreRnd'] ) ? $quads_options['pos4']['MoreRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1545 |
+
$html .= ' ' . __( 'right after <strong>the <span style="font-family:Courier New,Courier,Fixed;"><!--more--></span> tag</strong>', 'quick-adsense-reloaded' ) . '</br>';
|
1546 |
+
|
1547 |
+
// Pos 5
|
1548 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos5][LapaAds]', 'current' => !empty( $quads_options['pos5']['LapaAds'] ) ? $quads_options['pos5']['LapaAds'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1549 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1550 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos5][LapaRnd]', 'name' => 'quads_settings[pos5][LapaRnd]', 'selected' => !empty( $quads_options['pos5']['LapaRnd'] ) ? $quads_options['pos5']['LapaRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1551 |
+
$html .= ' ' . __( 'right before <strong>the last Paragraph</strong>', 'quick-adsense-reloaded' ) . ' </br>';
|
1552 |
+
|
1553 |
+
// Pos 6
|
1554 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos6][Par1Ads]', 'current' => !empty( $quads_options['pos6']['Par1Ads'] ) ? $quads_options['pos6']['Par1Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1555 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1556 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos6][Par1Rnd]', 'name' => 'quads_settings[pos6][Par1Rnd]', 'selected' => !empty( $quads_options['pos6']['Par1Rnd'] ) ? $quads_options['pos6']['Par1Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1557 |
+
$html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1558 |
+
$html .= $quads->html->select( array('options' => quads_get_values(), 'class' => 'quads-paragraph', 'id' => 'quads_settings[pos6][Par1Nup]', 'name' => 'quads_settings[pos6][Par1Nup]', 'selected' => !empty( $quads_options['pos6']['Par1Nup'] ) ? $quads_options['pos6']['Par1Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1559 |
+
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1560 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos6][Par1Con]', 'current' => !empty( $quads_options['pos6']['Par1Con'] ) ? $quads_options['pos6']['Par1Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1561 |
+
$html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
|
1562 |
+
|
1563 |
+
// Pos 7
|
1564 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos7][Par2Ads]', 'current' => !empty( $quads_options['pos7']['Par2Ads'] ) ? $quads_options['pos7']['Par2Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1565 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1566 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos7][Par2Rnd]', 'name' => 'quads_settings[pos7][Par2Rnd]', 'selected' => !empty( $quads_options['pos7']['Par2Rnd'] ) ? $quads_options['pos7']['Par2Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1567 |
+
$html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1568 |
+
$html .= $quads->html->select( array('options' => quads_get_values(), 'id' => 'quads_settings[pos7][Par2Nup]', 'name' => 'quads_settings[pos7][Par2Nup]', 'selected' => !empty( $quads_options['pos7']['Par2Nup'] ) ? $quads_options['pos7']['Par2Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1569 |
+
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1570 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos7][Par2Con]', 'current' => !empty( $quads_options['pos7']['Par2Con'] ) ? $quads_options['pos7']['Par2Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1571 |
+
$html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
|
1572 |
+
|
1573 |
+
// Pos 8
|
1574 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos8][Par3Ads]', 'current' => !empty( $quads_options['pos8']['Par3Ads'] ) ? $quads_options['pos8']['Par3Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1575 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1576 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'id' => 'quads_settings[pos8][Par3Rnd]', 'name' => 'quads_settings[pos8][Par3Rnd]', 'selected' => !empty( $quads_options['pos8']['Par3Rnd'] ) ? $quads_options['pos8']['Par3Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1577 |
+
$html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1578 |
+
$html .= $quads->html->select( array('options' => quads_get_values(), 'id' => 'quads_settings[pos8][Par3Nup]', 'name' => 'quads_settings[pos8][Par3Nup]', 'selected' => !empty( $quads_options['pos8']['Par3Nup'] ) ? $quads_options['pos8']['Par3Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1579 |
+
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1580 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos8][Par3Con]', 'current' => !empty( $quads_options['pos8']['Par3Con'] ) ? $quads_options['pos8']['Par3Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1581 |
+
$html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
|
1582 |
+
|
1583 |
+
$html .= apply_filters( 'quads_extra_paragraph', '' );
|
1584 |
+
|
1585 |
+
// Pos 9
|
1586 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos9][Img1Ads]', 'current' => !empty( $quads_options['pos9']['Img1Ads'] ) ? $quads_options['pos9']['Img1Ads'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1587 |
+
$html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
|
1588 |
+
$html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos9][Img1Rnd]', 'selected' => !empty( $quads_options['pos9']['Img1Rnd'] ) ? $quads_options['pos9']['Img1Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1589 |
+
$html .= ' ' . __( '<strong>After Image</strong>', 'quick-adsense-reloaded' ) . ' ';
|
1590 |
+
$html .= $quads->html->select( array('options' => quads_get_values(), 'id' => 'quads_settings[pos9][Img1Nup]', 'name' => 'quads_settings[pos9][Img1Nup]', 'selected' => !empty( $quads_options['pos9']['Img1Nup'] ) ? $quads_options['pos9']['Img1Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
|
1591 |
+
$html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
|
1592 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[pos9][Img1Con]', 'current' => !empty( $quads_options['pos9']['Img1Con'] ) ? $quads_options['pos9']['Img1Con'] : null, 'class' => 'quads-checkbox quads-assign') );
|
1593 |
+
$html .= ' ' . __( 'after <b>Image\'s outer</b><b><span style="font-family:Courier New,Courier,Fixed;"> <div> wp-caption</span></b> if any.', 'quick-adsense-reloaded' ) . ' </br>';
|
1594 |
+
|
1595 |
+
echo apply_filters( 'quads_ad_position_callback', $html );
|
1596 |
+
}
|
1597 |
+
|
1598 |
+
/**
|
1599 |
+
* Quicktags Callback
|
1600 |
+
*
|
1601 |
+
* Renders quicktags fields
|
1602 |
+
*
|
1603 |
+
* @since 0.9.0
|
1604 |
+
* @param array $args Arguments passed by the setting
|
1605 |
+
* @global $quads_options Array of all the QUADS Options
|
1606 |
+
* @return void
|
1607 |
+
*/
|
1608 |
+
function quads_quicktags_callback( $args ) {
|
1609 |
+
global $quads_options, $quads;
|
1610 |
+
|
1611 |
+
// Quicktags info
|
1612 |
+
$html = '<div style="margin-bottom:5px;"><strong>Optional: </strong><a href="#" id="quads_insert_ads_action">' . __( ' Insert Ads into a post, on-the-fly', 'quick-adsense-reloaded' ) . '</a></br>' .
|
1613 |
+
'<ol style="margin-top:5px;display:none;" id="quads_insert_ads_box">
|
1614 |
+
<li>' . __( 'Insert <span class="quads-quote-docs"><!--Ads1--></span>, <span class="quads-quote-docs"><!--Ads2--></span>, etc. into a post to show the <b>Particular Ads</b> at specific location.', 'quick-adsense-reloaded' ) . '</li>
|
1615 |
+
<li>' . __( 'Insert <span class="quads-quote-docs"><!--RndAds--></span> into a post to show the <b>Random Ads</b> at specific location', 'quick-adsense-reloaded' ) . '</li>
|
1616 |
+
</ol></div>';
|
1617 |
+
|
1618 |
+
$html .= $quads->html->checkbox( array('name' => 'quads_settings[quicktags][QckTags]', 'current' => !empty( $quads_options['quicktags']['QckTags'] ) ? $quads_options['quicktags']['QckTags'] : null, 'class' => 'quads-checkbox') );
|
1619 |
+
$html .= __( 'Show Quicktag Buttons on the HTML Post Editor', 'quick-adsense-reloaded' ) . '</br>';
|
1620 |
+
$html .= '<span class="quads-desc">' . __( 'Tags can be inserted into a post via the additional Quicktag Buttons at the HTML Edit Post SubPanel.', 'quick-adsense-reloaded' ) . '</span>';
|
1621 |
+
echo $html;
|
1622 |
+
}
|
1623 |
+
|
1624 |
+
/**
|
1625 |
+
* Add new ad
|
1626 |
+
* @global array $quads_options
|
1627 |
+
*/
|
1628 |
+
function quads_ajax_add_ads(){
|
1629 |
+
global $quads_options;
|
1630 |
+
|
1631 |
+
$postCount = !empty($_POST['count']) ? $_POST['count'] : 1;
|
1632 |
+
//wp_die($postCount);
|
1633 |
+
|
1634 |
+
$count = isset($quads_options['ads']) ? count ($quads_options['ads']) + $postCount : 10 + $postCount;
|
1635 |
+
|
1636 |
+
|
1637 |
+
$args = array();
|
1638 |
+
// subtract 10 widget ads
|
1639 |
+
//$args['id'] = $count-10;
|
1640 |
+
$args['id'] = $count-getTotalWidgets();
|
1641 |
+
$args['name'] = 'Ad ' . $args['id'];
|
1642 |
+
|
1643 |
+
ob_start();
|
1644 |
+
// ... get the content ...
|
1645 |
+
quads_adsense_code_callback( $args );
|
1646 |
+
$content = ob_get_contents();
|
1647 |
+
ob_end_clean();
|
1648 |
+
|
1649 |
+
$html = '<tr><td>';
|
1650 |
+
$html.= $content;
|
1651 |
+
$html.= '</td></tr>';
|
1652 |
+
echo $html;
|
1653 |
+
die();
|
1654 |
+
}
|
1655 |
+
add_action( 'wp_ajax_quads_ajax_add_ads', 'quads_ajax_add_ads' );
|
1656 |
+
|
1657 |
+
/**
|
1658 |
+
* Get the total amount of widget ads
|
1659 |
+
* @global $quads_options $quads_options
|
1660 |
+
* @return int
|
1661 |
+
*/
|
1662 |
+
function getTotalWidgets(){
|
1663 |
+
global $quads_options;
|
1664 |
+
|
1665 |
+
$i = 0;
|
1666 |
+
|
1667 |
+
foreach ($quads_options['ads'] as $key => $value){
|
1668 |
+
if (false !== strpos($key, 'widget')){
|
1669 |
+
$i++;
|
1670 |
+
}
|
1671 |
+
}
|
1672 |
+
return $i;
|
1673 |
+
}
|
1674 |
+
|
1675 |
+
/**
|
1676 |
+
* Count normal ads. Do not count widget ads
|
1677 |
+
*
|
1678 |
+
* @global array $quads_options
|
1679 |
+
* @return int
|
1680 |
+
*/
|
1681 |
+
function quads_count_normal_ads() {
|
1682 |
+
global $quads_options;
|
1683 |
+
|
1684 |
+
if(!isset($quads_options['ads'])){
|
1685 |
+
return 0;
|
1686 |
+
}
|
1687 |
+
|
1688 |
+
// Count normal ads - not widget ads
|
1689 |
+
$adsCount = 0;
|
1690 |
+
$id = 1;
|
1691 |
+
foreach ( $quads_options['ads'] as $ads => $value ) {
|
1692 |
+
// Skip if its a widget ad
|
1693 |
+
if( strpos( $ads, 'ad' . $id ) === 0 && false === strpos( $ads, 'ad' . $id . '_widget' ) ) {
|
1694 |
+
$adsCount++;
|
1695 |
+
}
|
1696 |
+
$id++;
|
1697 |
+
}
|
1698 |
+
return $adsCount;
|
1699 |
+
}
|
1700 |
+
|
1701 |
+
function quads_new_ad_callback(){
|
1702 |
+
if (quads_is_extra()) {
|
1703 |
+
echo '<a href="#" id="quads-add-new-ad">' . __('Add New Ad','quick-adsense-reloaded') . '</a>';
|
1704 |
+
}
|
1705 |
+
}
|
1706 |
+
|
1707 |
+
/**
|
1708 |
+
* Render all ad relevant settings (ADSENSE CODE tab)
|
1709 |
+
* No widget ads
|
1710 |
+
* @global $quads_options $quads_options
|
1711 |
+
*/
|
1712 |
+
function quads_ad_code_callback(){
|
1713 |
+
global $quads_options;
|
1714 |
+
|
1715 |
+
// echo '<tr><td>';
|
1716 |
+
// echo 'test2';
|
1717 |
+
// echo '</td></tr>';
|
1718 |
+
|
1719 |
+
$args = array();
|
1720 |
+
|
1721 |
+
$i = 1;
|
1722 |
+
// Render 10 default ads if there are less than 10 ads stored or none at all
|
1723 |
+
if( quads_count_normal_ads() < 10 || !quads_is_extra()) {
|
1724 |
+
//wp_die('t2');
|
1725 |
+
while ( $i <= 10 ) {
|
1726 |
+
|
1727 |
+
$id = $i++;
|
1728 |
+
|
1729 |
+
$args['id'] = $id;
|
1730 |
+
|
1731 |
+
$args['desc'] = '';
|
1732 |
+
|
1733 |
+
$args['name'] = !empty( $quads_options['ads']['ad' . $id]['label'] ) ? $quads_options['ads']['ad' . $id]['label'] : 'Ad ' . $id;
|
1734 |
+
|
1735 |
+
echo '<tr><td>';
|
1736 |
+
echo quads_adsense_code_callback( $args );
|
1737 |
+
echo '</td></tr>';
|
1738 |
+
|
1739 |
+
}
|
1740 |
+
|
1741 |
+
// Stop here early
|
1742 |
+
return true;
|
1743 |
+
}
|
1744 |
+
|
1745 |
+
// Else render 10 + n ads
|
1746 |
+
$i = 1;
|
1747 |
+
foreach ($quads_options['ads'] as $ads => $value ){
|
1748 |
+
|
1749 |
+
$id = $i++;
|
1750 |
+
|
1751 |
+
$args['id'] = $id;
|
1752 |
+
|
1753 |
+
$args['desc'] = '';
|
1754 |
+
|
1755 |
+
$args['name'] = !empty($quads_options['ads']['ad' . $id]['label']) ? $quads_options['ads']['ad' . $id]['label'] : 'Ad ' . $id;
|
1756 |
+
|
1757 |
+
// Skip if its a widget ad
|
1758 |
+
if ( (strpos($ads, 'ad' . $id) === 0) && (false === strpos($ads, 'ad' . $id . '_widget') ) ){
|
1759 |
+
echo '<tr><td>';
|
1760 |
+
echo quads_adsense_code_callback( $args );
|
1761 |
+
echo '</td></tr>';
|
1762 |
+
}
|
1763 |
+
|
1764 |
+
}
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
/**
|
1768 |
+
* AdSense Code Callback
|
1769 |
+
*
|
1770 |
+
* Renders adsense code fields
|
1771 |
+
*
|
1772 |
+
* @since 0.9.0
|
1773 |
+
* @param array $args Arguments passed by the setting
|
1774 |
+
* @global $quads_options Array of all the QUADS Options
|
1775 |
+
* @return void
|
1776 |
+
*/
|
1777 |
+
function quads_adsense_code_callback( $args ) {
|
1778 |
+
global $quads_options;
|
1779 |
+
|
1780 |
+
$new_label = isset( $quads_options['ads']['ad'.$args['id']]['label'] ) ? $quads_options['ads']['ad'.$args['id']]['label'] : '';
|
1781 |
+
|
1782 |
+
$label = !empty( $new_label ) ? $new_label : $args['name'];
|
1783 |
+
|
1784 |
+
$code = isset( $quads_options['ads']['ad'.$args['id']]['code'] ) ? $quads_options['ads']['ad'.$args['id']]['code'] : '';
|
1785 |
+
|
1786 |
+
$margin = isset( $quads_options['ads']['ad'.$args['id']]['margin'] ) ? esc_attr( stripslashes( $quads_options['ads']['ad'.$args['id']]['margin'] ) ) : 0;
|
1787 |
+
|
1788 |
+
$g_data_ad_client = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_client'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_client'] : '';
|
1789 |
+
|
1790 |
+
$g_data_ad_slot = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_slot'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_slot'] : '';
|
1791 |
+
|
1792 |
+
$g_data_ad_width = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_width'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_width'] : '';
|
1793 |
+
|
1794 |
+
$g_data_ad_height = isset( $quads_options['ads']['ad'. $args['id']]['g_data_ad_height'] ) ? $quads_options['ads']['ad'. $args['id']]['g_data_ad_height'] : '';
|
1795 |
+
|
1796 |
+
//$args['desc'] = __( '<strong>Shortcode:</strong> [quads id="'.$args['id'].'"] | <strong>PHP:</strong> echo do_shortcode(\'[quads id="'.$args['id'].'"]\');', 'quick-adsense-reloaded' );
|
1797 |
+
|
1798 |
+
//$label = !empty($new_label) ? $new_label :
|
1799 |
+
// Create a shorter var to make HTML cleaner
|
1800 |
+
$id = 'ad' . $args['id'];
|
1801 |
+
?>
|
1802 |
+
<div class="quads-ad-toggle-header quads-box-close" data-box-id="quads-toggle<?php echo $id; ?>">
|
1803 |
+
<div class="quads-toogle-title"><span contenteditable="true" id="quads-ad-label-<?php echo $id; ?>"><?php echo $label; ?></span><input type="hidden" class="quads-input-label" name="quads_settings[ads][<?php echo $id; ?>][label]" value="<?php echo $new_label; ?>"></div>
|
1804 |
+
<a class="quads-toggle" data-box-id="quads-toggle<?php echo $id; ?>" href="#"><div class="quads-close-open-icon"></div></a>
|
1805 |
+
</div>
|
1806 |
+
<div class="quads-ad-toggle-container" id="quads-toggle<?php echo $id; ?>" style="display:none;">
|
1807 |
+
<div>
|
1808 |
+
<?php
|
1809 |
+
$args_ad_type = array(
|
1810 |
+
'id' => 'ad_type',
|
1811 |
+
'name' => 'Type',
|
1812 |
+
'desc' => '',
|
1813 |
+
'std' => 'plain_text',
|
1814 |
+
'options' => array(
|
1815 |
+
'adsense' => 'AdSense',
|
1816 |
+
'plain_text' => 'Plain Text / HTML / JS'
|
1817 |
+
)
|
1818 |
+
);
|
1819 |
+
echo quads_adtype_callback( $id, $args_ad_type );
|
1820 |
+
?>
|
1821 |
+
</div>
|
1822 |
+
<textarea style="vertical-align:top;margin-right:20px;" class="large-text quads-textarea" cols="50" rows="10" id="quads_settings[ads][<?php echo $id; ?>][code]" name="quads_settings[ads][<?php echo $id; ?>][code]"><?php echo esc_textarea( stripslashes( $code ) ); ?></textarea>
|
1823 |
+
<!--<label for="quads_settings[ads][ <?php //echo $id; ?> ][code]"> <?php //echo $args['desc']; ?></label><br>//-->
|
1824 |
+
<label for="quads_shortcode_<?php echo $args['id'];?>">Post Shortcode:</label><input readonly id="quads_shortcode_<?php echo $args['id'];?>" type="text" onclick="this.focus(); this.select()" value='[quads id=<?php echo $args['id'];?>]' title="Optional: Copy and paste the shortcode into the post editor, click below then press Ctrl + C (PC) or Cmd + C (Mac).">
|
1825 |
+
<label for="quads_php_shortcode_<?php echo $args['id'];?>">PHP:</label><input readonly id="quads_php_shortcode_<?php echo $args['id'];?>" type="text" onclick="this.focus(); this.select()" style="width:290px;" value="<?php echo do_shortcode('[quads id=<?php echo $args['id']; ?>]'); ?>" title="Optional: Copy and paste the PHP code into your theme files, click below then press Ctrl + C (PC) or Cmd + C (Mac).">
|
1826 |
+
<br>
|
1827 |
+
<div class="quads_adsense_code">
|
1828 |
+
<input type="button" style="vertical-align:inherit;" class="button button-primary quads-add-adsense" value="Copy / Paste AdSense Code"> <span>or add Ad Slot ID & Publisher ID manually below:</span>
|
1829 |
+
<br />
|
1830 |
+
<?php //echo __('Generate Ad Slot & Publisher ID automatically from your adsense code', 'quick-adsense-reloaded') ?>
|
1831 |
+
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]">Ad Slot ID </label><input type="text" class="quads-medium-size quads-bggrey" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" value="<?php echo $g_data_ad_slot; ?>">
|
1832 |
+
<label for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]">Publisher ID</label><input type="text" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" class="medium-text quads-bggrey" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" value="<?php echo $g_data_ad_client; ?>">
|
1833 |
+
<br />
|
1834 |
+
<?php
|
1835 |
+
$args = array(
|
1836 |
+
'id' => 'adsense_type',
|
1837 |
+
'name' => 'Type',
|
1838 |
+
'desc' => 'Type',
|
1839 |
+
'options' => array(
|
1840 |
+
'normal' => 'Fixed Size',
|
1841 |
+
'responsive' => 'Responsive'
|
1842 |
+
)
|
1843 |
+
);
|
1844 |
+
echo quads_adense_select_callback( $id, $args );
|
1845 |
+
?>
|
1846 |
+
<?php if( !quads_is_extra() ) { ?>
|
1847 |
+
<span class="quads-pro-notice" style="display:block;margin-top:20px;"><?php echo sprintf( __( 'Install <a href="%s" target="_blank">WP QUADS PRO</a> to fully support AdSense Responsive ads.', 'quick-adsense-reloaded' ), 'http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin' ) ?></span>
|
1848 |
+
<?php } ?>
|
1849 |
+
<br />
|
1850 |
+
<label class="quads-label-left quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]">Width </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_width; ?>">
|
1851 |
+
<label class="quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]">Height </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_height; ?>">
|
1852 |
+
</div>
|
1853 |
+
<div class="quads-style">
|
1854 |
+
<h3>Layout</h3>
|
1855 |
+
<?php
|
1856 |
+
$args_ad_position = array(
|
1857 |
+
'id' => 'align',
|
1858 |
+
'name' => 'align',
|
1859 |
+
'desc' => 'align',
|
1860 |
+
'std' => '3',
|
1861 |
+
'options' => array(
|
1862 |
+
'3' => 'Default',
|
1863 |
+
'0' => 'Left',
|
1864 |
+
'1' => 'Center',
|
1865 |
+
'2' => 'Right'
|
1866 |
+
)
|
1867 |
+
);
|
1868 |
+
echo quads_adposition_callback( $id, $args_ad_position );
|
1869 |
+
// if WP QUADS PRO is installed and version number is higher or equal 1.2.7 show the new margin settings
|
1870 |
+
if( !quads_is_extra() ) {
|
1871 |
+
?>
|
1872 |
+
|
1873 |
+
<br />
|
1874 |
+
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][margin]"><?php _e( 'Margin', 'quick-adsense-reloaded' ); ?></label>
|
1875 |
+
<input type="number" step="1" max="" min="" class="small-text" id="quads_settings[ads][<?php echo $id; ?>][margin]" name="quads_settings[ads][<?php echo $id; ?>][margin]" value="<?php echo esc_attr( stripslashes( $margin ) ); ?>"/>px
|
1876 |
+
<?php } echo apply_filters( 'quads_render_margin', '', $id ); ?>
|
1877 |
+
</div>
|
1878 |
+
<?php
|
1879 |
+
if (quads_is_extra()){
|
1880 |
+
echo apply_filters( 'quads_advanced_settings', '', $id );
|
1881 |
+
}
|
1882 |
+
echo quads_pro_overlay();
|
1883 |
+
?>
|
1884 |
+
</div>
|
1885 |
+
<?php
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
/**
|
1889 |
+
* AdSense Code Widget Callback
|
1890 |
+
*
|
1891 |
+
* Renders adsense code fields
|
1892 |
+
*
|
1893 |
+
* @since 0.9.0
|
1894 |
+
* @param array $args Arguments passed by the setting
|
1895 |
+
* @global $quads_options Array of all the QUADS Options
|
1896 |
+
* @return void
|
1897 |
+
*/
|
1898 |
+
function quads_adsense_widget_callback( $args ) {
|
1899 |
+
global $quads_options;
|
1900 |
+
|
1901 |
+
$label = !empty( $args['name'] ) ? $args['name'] : '';
|
1902 |
+
|
1903 |
+
$code = isset( $quads_options['ads'][$args['id']]['code'] ) ? $quads_options['ads'][$args['id']]['code'] : '';
|
1904 |
+
|
1905 |
+
$margin = isset( $quads_options['ads'][$args['id']]['margin'] ) ? esc_attr( stripslashes( $quads_options['ads'][$args['id']]['margin'] ) ) : 0;
|
1906 |
+
|
1907 |
+
$g_data_ad_client = isset( $quads_options['ads'][$args['id']]['g_data_ad_client'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_client'] : '';
|
1908 |
+
|
1909 |
+
$g_data_ad_slot = isset( $quads_options['ads'][$args['id']]['g_data_ad_slot'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_slot'] : '';
|
1910 |
+
|
1911 |
+
$g_data_ad_width = isset( $quads_options['ads'][$args['id']]['g_data_ad_width'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_width'] : '';
|
1912 |
+
|
1913 |
+
$g_data_ad_height = isset( $quads_options['ads'][$args['id']]['g_data_ad_height'] ) ? $quads_options['ads'][$args['id']]['g_data_ad_height'] : '';
|
1914 |
+
|
1915 |
+
// Create a shorter var to make HTML cleaner
|
1916 |
+
$id = $args['id'];
|
1917 |
+
?>
|
1918 |
+
<div class="quads-ad-toggle-header quads-box-close" data-box-id="quads-toggle<?php echo $id; ?>">
|
1919 |
+
<div class="quads-toogle-title"><?php echo $label; ?></div>
|
1920 |
+
<a class="quads-toggle" data-box-id="quads-toggle<?php echo $id; ?>" href="#"><div class="quads-close-open-icon"></div></a>
|
1921 |
+
</div>
|
1922 |
+
<div class="quads-ad-toggle-container" id="quads-toggle<?php echo $id; ?>" style="display:none;">
|
1923 |
+
<div>
|
1924 |
+
<?php
|
1925 |
+
$args_ad_type = array(
|
1926 |
+
'id' => 'ad_type',
|
1927 |
+
'name' => 'Type',
|
1928 |
+
'desc' => '',
|
1929 |
+
'std' => 'plain_text',
|
1930 |
+
'options' => array(
|
1931 |
+
'adsense' => 'AdSense',
|
1932 |
+
'plain_text' => 'Plain Text / HTML / JS'
|
1933 |
+
)
|
1934 |
+
);
|
1935 |
+
echo quads_adtype_callback( $id, $args_ad_type );
|
1936 |
+
?>
|
1937 |
+
</div>
|
1938 |
+
<textarea style="vertical-align:top;margin-right:20px;" class="large-text quads-textarea" cols="50" rows="10" id="quads_settings[ads][<?php echo $id; ?>][code]" name="quads_settings[ads][<?php echo $id; ?>][code]"><?php echo esc_textarea( stripslashes( $code ) ); ?></textarea><label for="quads_settings[ads][ <?php echo $id; ?> ][code]"> <?php echo $args['desc']; ?></label>
|
1939 |
+
<br>
|
1940 |
+
<div class="quads_adsense_code">
|
1941 |
+
<input type="button" style="vertical-align:inherit;" class="button button-primary quads-add-adsense" value="Copy / Paste AdSense Code"> <span>or add Ad Slot ID & Publisher ID manually below:</span>
|
1942 |
+
<br />
|
1943 |
+
<?php //echo __('Generate Ad Slot & Publisher ID automatically from your adsense code', 'quick-adsense-reloaded') ?>
|
1944 |
+
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]">Ad Slot ID </label><input type="text" class="quads-medium-size quads-bggrey" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_slot]" value="<?php echo $g_data_ad_slot; ?>">
|
1945 |
+
<label for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]">Publisher ID</label><input type="text" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" class="medium-text quads-bggrey" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_client]" value="<?php echo $g_data_ad_client; ?>">
|
1946 |
+
<br />
|
1947 |
+
<?php
|
1948 |
+
$args_adsense_type = array(
|
1949 |
+
'id' => 'adsense_type',
|
1950 |
+
'name' => 'Type',
|
1951 |
+
'desc' => 'Type',
|
1952 |
+
'options' => array(
|
1953 |
+
'normal' => 'Fixed Size',
|
1954 |
+
'responsive' => 'Responsive'
|
1955 |
+
)
|
1956 |
+
);
|
1957 |
+
echo quads_adense_select_callback( $id, $args_adsense_type );
|
1958 |
+
?>
|
1959 |
+
<?php if( !quads_is_extra() ) { ?>
|
1960 |
+
<span class="quads-pro-notice" style="display:block;margin-top:20px;"><?php echo sprintf( __( 'Install <a href="%s" target="_blank">WP QUADS PRO</a> to fully support AdSense Responsive ads.', 'quick-adsense-reloaded' ), 'http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin' ) ?></span>
|
1961 |
+
<?php } ?>
|
1962 |
+
<br />
|
1963 |
+
<label class="quads-label-left quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]">Width </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_width]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_width; ?>">
|
1964 |
+
<label class="quads-type-normal" for="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]">Height </label><input type="number" step="1" id="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" name="quads_settings[ads][<?php echo $id; ?>][g_data_ad_height]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_height; ?>">
|
1965 |
+
</div>
|
1966 |
+
<div class="quads-style">
|
1967 |
+
<h3>Layout</h3>
|
1968 |
+
<?php
|
1969 |
+
$args_ad_position = array(
|
1970 |
+
'id' => 'align',
|
1971 |
+
'name' => 'align',
|
1972 |
+
'desc' => 'align',
|
1973 |
+
'std' => '3',
|
1974 |
+
'options' => array(
|
1975 |
+
'3' => 'Default',
|
1976 |
+
'0' => 'Left',
|
1977 |
+
'1' => 'Center',
|
1978 |
+
'2' => 'Right'
|
1979 |
+
)
|
1980 |
+
);
|
1981 |
+
echo quads_adposition_callback( $id, $args_ad_position );
|
1982 |
+
// if WP QUADS PRO is installed and version number is higher or equal 1.2.7 show the new margin settings
|
1983 |
+
if( !quads_is_extra() ) {
|
1984 |
+
?>
|
1985 |
+
<br />
|
1986 |
+
<label class="quads-label-left" for="quads_settings[ads][<?php echo $id; ?>][margin]"><?php _e( 'Margin', 'quick-adsense-reloaded' ); ?></label>
|
1987 |
+
<input type="number" step="1" max="" min="" class="small-text" id="quads_settings[ads][<?php echo $id; ?>][margin]" name="quads_settings[ads][<?php echo $id; ?>][margin]" value="<?php echo esc_attr( stripslashes( $margin ) ); ?>"/>px
|
1988 |
+
<?php } echo apply_filters( 'quads_render_margin', '', $id ); ?>
|
1989 |
+
</div>
|
1990 |
+
<?php
|
1991 |
+
if (quads_is_extra()){
|
1992 |
+
echo apply_filters( 'quads_advanced_settings', '', $id );
|
1993 |
+
}
|
1994 |
+
echo quads_pro_overlay();
|
1995 |
+
?>
|
1996 |
+
</div>
|
1997 |
+
<?php
|
1998 |
+
}
|
1999 |
+
|
2000 |
+
/**
|
2001 |
+
* If advanced settings are not available load overlay image
|
2002 |
+
* @return string
|
2003 |
+
*/
|
2004 |
+
function quads_pro_overlay() {
|
2005 |
+
if( quads_is_extra() ) {
|
2006 |
+
return '';
|
2007 |
+
}
|
2008 |
+
|
2009 |
+
$html = '<div class="quads-advanced-ad-box quads-pro-overlay"><a href="http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin" target="_blank"><img src="' . QUADS_PLUGIN_URL . '/assets/images/get_pro_overlay.png"></a></div>';
|
2010 |
+
|
2011 |
+
return $html;
|
2012 |
+
}
|
2013 |
+
|
2014 |
+
/**
|
2015 |
+
*
|
2016 |
+
* Return array of alignment options
|
2017 |
+
*
|
2018 |
+
* @return array
|
2019 |
+
*/
|
2020 |
+
function quads_get_alignment() {
|
2021 |
+
// Do not change the key => value order for compatibility reasons
|
2022 |
+
return array(
|
2023 |
+
3 => 'none',
|
2024 |
+
0 => 'left',
|
2025 |
+
1 => 'center',
|
2026 |
+
2 => 'right',
|
2027 |
+
);
|
2028 |
+
}
|
2029 |
+
|
2030 |
+
/**
|
2031 |
+
* Check if plugin Clickfraud Monitoring is installed
|
2032 |
+
*
|
2033 |
+
* @return boolean true when it is installed and active
|
2034 |
+
*/
|
2035 |
+
function quads_is_installed_clickfraud() {
|
2036 |
+
$plugin_file = 'cfmonitor/cfmonitor.php';
|
2037 |
+
$plugin_file2 = 'clickfraud-monitoring/cfmonitor.php';
|
2038 |
+
|
2039 |
+
if( is_plugin_active( $plugin_file ) || is_plugin_active( $plugin_file2 ) ) {
|
2040 |
+
return true;
|
2041 |
+
}
|
2042 |
+
|
2043 |
+
return false;
|
2044 |
+
}
|
2045 |
+
|
2046 |
+
/**
|
2047 |
+
*
|
2048 |
+
* @param array $args array(
|
2049 |
+
* 'id' => 'string),
|
2050 |
+
* 'type' => desktop, tablet_landscape, tablet_portrait, phone
|
2051 |
+
* @return string
|
2052 |
+
|
2053 |
+
*/
|
2054 |
+
function quads_render_size_option( $args ) {
|
2055 |
+
global $quads_options;
|
2056 |
+
|
2057 |
+
if( !isset( $args['id'] ) ) {
|
2058 |
+
return '';
|
2059 |
+
}
|
2060 |
+
|
2061 |
+
$checked = isset( $quads_options['ads'][$args['id']][$args['type']] ) ? $quads_options['ads'][$args['id']][$args['type']] : '';
|
2062 |
+
$html = '<div class="quads-select-style-overwrite">';
|
2063 |
+
$html .= '<select class="quads-size-input" id="quads_settings[ads][' . $args['id'] . '][' . $args['type'] . ']" name="quads_settings[ads][' . $args['id'] . '][' . $args['type'] . ']">';
|
2064 |
+
foreach ( quads_get_adsense_sizes() as $key => $value ) :
|
2065 |
+
$selected = selected( $key, $checked, false );
|
2066 |
+
$html .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
|
2067 |
+
endforeach;
|
2068 |
+
$html .= '</select>';
|
2069 |
+
$html .= '</div>';
|
2070 |
+
|
2071 |
+
return $html;
|
2072 |
+
}
|
2073 |
+
|
2074 |
+
/**
|
2075 |
+
* Get all AdSense Sizes
|
2076 |
+
* @return array
|
2077 |
+
*/
|
2078 |
+
function quads_get_adsense_sizes() {
|
2079 |
+
$sizes = array(
|
2080 |
+
'Auto' => 'Auto',
|
2081 |
+
'120 x 90' => '120 x 90',
|
2082 |
+
'120 x 240' => '120 x 240',
|
2083 |
+
'120 x 600' => '120 x 600',
|
2084 |
+
'125 x 125' => '125 x 125',
|
2085 |
+
'160 x 90' => '160 x 90',
|
2086 |
+
'160 x 600' => '160 x 600',
|
2087 |
+
'180 x 90' => '180 x 90',
|
2088 |
+
'180 x 150' => '180 x 150',
|
2089 |
+
'200 x 90' => '200 x 90',
|
2090 |
+
'200 x 200' => '200 x 200',
|
2091 |
+
'234 x 60' => '234 x 60',
|
2092 |
+
'250 x 250' => '250 x 250',
|
2093 |
+
'320 x 100' => '320 x 100',
|
2094 |
+
'300 x 250' => '300 x 250',
|
2095 |
+
'300 x 600' => '300 x 600',
|
2096 |
+
'300 x 1050' => '300 x 1050',
|
2097 |
+
'320 x 50' => '320 x 50',
|
2098 |
+
'336 x 280' => '336 x 280',
|
2099 |
+
'360 x 300' => '360 x 300',
|
2100 |
+
'435 x 300' => '435 x 300',
|
2101 |
+
'468 x 15' => '468 x 15',
|
2102 |
+
'468 x 60' => '468 x 60',
|
2103 |
+
'640 x 165' => '640 x 165',
|
2104 |
+
'640 x 190' => '640 x 190',
|
2105 |
+
'640 x 300' => '640 x 300',
|
2106 |
+
'728 x 15' => '728 x 15',
|
2107 |
+
'728 x 90' => '728 x 90',
|
2108 |
+
'970 x 90' => '970 x 90',
|
2109 |
+
'970 x 250' => '970 x 250',
|
2110 |
+
'240 x 400' => '240 x 400 - Regional ad sizes',
|
2111 |
+
'250 x 360' => '250 x 360 - Regional ad sizes',
|
2112 |
+
'580 x 400' => '580 x 400 - Regional ad sizes',
|
2113 |
+
'750 x 100' => '750 x 100 - Regional ad sizes',
|
2114 |
+
'750 x 200' => '750 x 200 - Regional ad sizes',
|
2115 |
+
'750 x 300' => '750 x 300 - Regional ad sizes',
|
2116 |
+
'980 x 120' => '980 x 120 - Regional ad sizes',
|
2117 |
+
'930 x 180' => '930 x 180 - Regional ad sizes',
|
2118 |
+
);
|
2119 |
+
|
2120 |
+
return apply_filters( 'quads_adsense_size_formats', $sizes );
|
2121 |
+
}
|
2122 |
+
|
2123 |
+
/**
|
2124 |
+
* Store AdSense parameters
|
2125 |
+
*
|
2126 |
+
* @return boolean
|
2127 |
+
*/
|
2128 |
+
function quads_store_adsense_args() {
|
2129 |
+
global $quads_options;
|
2130 |
+
|
2131 |
+
foreach ( $quads_options as $id => $ads ) {
|
2132 |
+
if (!is_array($ads)){
|
2133 |
+
continue;
|
2134 |
+
}
|
2135 |
+
foreach ($ads as $key => $value) {
|
2136 |
+
if( is_array( $value ) && array_key_exists( 'code', $value ) && !empty( $value['code'] ) ) {
|
2137 |
+
|
2138 |
+
//check to see if it is google ad
|
2139 |
+
if( preg_match( '/googlesyndication.com/', $value['code'] ) ) {
|
2140 |
+
|
2141 |
+
// Test if its google asyncron ad
|
2142 |
+
if( preg_match( '/data-ad-client=/', $value['code'] ) ) {
|
2143 |
+
//*** GOOGLE ASYNCRON *************
|
2144 |
+
$quads_options['ads'][$key]['current_ad_type'] = 'google_async';
|
2145 |
+
//get g_data_ad_client
|
2146 |
+
$explode_ad_code = explode( 'data-ad-client', $value['code'] );
|
2147 |
+
preg_match( '#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client );
|
2148 |
+
$quads_options['ads'][$key]['g_data_ad_client'] = str_replace( array('"', ' '), array(''), $matches_add_client[1] );
|
2149 |
+
|
2150 |
+
//get g_data_ad_slot
|
2151 |
+
$explode_ad_code = explode( 'data-ad-slot', $value['code'] );
|
2152 |
+
preg_match( '#"([a-zA-Z0-9/\s]+)"#', $explode_ad_code[1], $matches_add_slot );
|
2153 |
+
if (isset($matches_add_slot[1])){
|
2154 |
+
$quads_options['ads'][$key]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), $matches_add_slot[1] );
|
2155 |
+
}
|
2156 |
+
} else {
|
2157 |
+
//*** GOOGLE SYNCRON *************
|
2158 |
+
$quads_options['ads'][$key]['current_ad_type'] = 'google_sync';
|
2159 |
+
//get g_data_ad_client
|
2160 |
+
$explode_ad_code = explode( 'google_ad_client', $value['code'] );
|
2161 |
+
preg_match( '#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client );
|
2162 |
+
$quads_options['ads'][$key]['g_data_ad_client'] = str_replace( array('"', ' '), array(''), $matches_add_client[1] );
|
2163 |
+
|
2164 |
+
//get g_data_ad_slot
|
2165 |
+
$explode_ad_code = explode( 'google_ad_slot', $value['code'] );
|
2166 |
+
//preg_match( '#"([a-zA-Z0-9/\s]+)"#', $explode_ad_code[1], $matches_add_slot );
|
2167 |
+
//$quads_options['ads'][$key]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), $matches_add_slot[1] );
|
2168 |
+
preg_match( '#"([a-zA-Z0-9/\s]+)"#', isset($explode_ad_code[1]) ? $explode_ad_code[1] : null, $matches_add_slot );
|
2169 |
+
$quads_options['ads'][$key]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), isset($matches_add_slot[1]) ? $matches_add_slot[1] : null );
|
2170 |
+
}
|
2171 |
+
}
|
2172 |
+
}
|
2173 |
+
}
|
2174 |
+
}
|
2175 |
+
//wp_die( var_dump( $quads_options ) );
|
2176 |
+
update_option( 'quads_settings', $quads_options );
|
2177 |
+
}
|
2178 |
+
|
2179 |
+
/**
|
2180 |
+
* Populate AdSense Code field otherwise ads are not shown on frontpage (Bug).
|
2181 |
+
* @todo
|
2182 |
+
*
|
2183 |
+
* @global $quads_options $quads_options
|
2184 |
+
* @deprecated since 1.3.8
|
2185 |
+
*/
|
2186 |
+
//function quads_fix_ad_not_shown(){
|
2187 |
+
// global $quads_options;
|
2188 |
+
//
|
2189 |
+
// foreach ( $quads_options as $id => $values ) {
|
2190 |
+
// if( is_array( $values ) && array_key_exists( 'code', $values ) && array_key_exists( 'ad_type', $values ) && empty($values['code']) ) {
|
2191 |
+
// $quads_options[$id]['code'] = '...';
|
2192 |
+
// }
|
2193 |
+
// }
|
2194 |
+
//}
|
2195 |
+
|
2196 |
+
/**
|
2197 |
+
* Sanitizes a string key for QUADS Settings
|
2198 |
+
*
|
2199 |
+
* Keys are used as internal identifiers. Alphanumeric characters, dashes, underscores, stops, colons and slashes are allowed
|
2200 |
+
*
|
2201 |
+
* @since 2.0.0
|
2202 |
+
* @param string $key String key
|
2203 |
+
* @return string Sanitized key
|
2204 |
+
*/
|
2205 |
+
function quads_sanitize_key( $key ) {
|
2206 |
+
$raw_key = $key;
|
2207 |
+
$key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
|
2208 |
+
/**
|
2209 |
+
* Filter a sanitized key string.
|
2210 |
+
*
|
2211 |
+
* @since 2.5.8
|
2212 |
+
* @param string $key Sanitized key.
|
2213 |
+
* @param string $raw_key The key prior to sanitization.
|
2214 |
+
*/
|
2215 |
+
return apply_filters( 'quads_sanitize_key', $key, $raw_key );
|
2216 |
+
}
|
2217 |
+
|
2218 |
+
/**
|
2219 |
+
* Multi Select Callback
|
2220 |
+
*
|
2221 |
+
* @since 1.3.8
|
2222 |
+
* @param array $args Arguments passed by the settings
|
2223 |
+
* @global $quads_options Array of all the QUADS Options
|
2224 |
+
* @return string $output dropdown
|
2225 |
+
*/
|
2226 |
+
function quads_multiselect_callback( $args = array() ) {
|
2227 |
+
global $quads_options;
|
2228 |
+
|
2229 |
+
$placeholder = !empty( $args['placeholder'] ) ? $args['placeholder'] : '';
|
2230 |
+
$selected = isset( $quads_options[$args['id']] ) ? $quads_options[$args['id']] : '';
|
2231 |
+
$checked = '';
|
2232 |
+
|
2233 |
+
$html = '<select id="quads_select_'. $args['id'] .'" name="quads_settings[' . $args['id'] . '][]" data-placeholder="' . $placeholder . '" style="width:550px;" multiple tabindex="4" class="quads-select quads-chosen-select">';
|
2234 |
+
$i = 0;
|
2235 |
+
foreach ( $args['options'] as $key => $value ) :
|
2236 |
+
if( is_array( $selected ) ) {
|
2237 |
+
$checked = selected( true, in_array( $key, $selected ), false );
|
2238 |
+
}
|
2239 |
+
$html .= '<option value="' . $key . '" ' . $checked . '>' . $value . '</option>';
|
2240 |
+
endforeach;
|
2241 |
+
$html .= '</select>';
|
2242 |
+
echo $html;
|
2243 |
+
}
|
2244 |
+
/**
|
2245 |
+
* Multi Select Ajax Callback
|
2246 |
+
* This adds only active elements to the array. Useful if there are a lot of elements like tags to increase performance
|
2247 |
+
*
|
2248 |
+
* @since 1.3.8
|
2249 |
+
* @param array $args Arguments passed by the settings
|
2250 |
+
* @global $quads_options Array of all the QUADS Options
|
2251 |
+
* @return string $output dropdown
|
2252 |
+
*/
|
2253 |
+
function quads_multiselect_ajax_callback( $args = array() ) {
|
2254 |
+
global $quads_options;
|
2255 |
+
|
2256 |
+
$placeholder = !empty( $args['placeholder'] ) ? $args['placeholder'] : '';
|
2257 |
+
$selected = isset( $quads_options[$args['id']] ) ? $quads_options[$args['id']] : '';
|
2258 |
+
$checked = '';
|
2259 |
+
|
2260 |
+
$html = '<select id="quads_select_'. $args['id'] .'" name="quads_settings[' . $args['id'] . '][]" data-placeholder="' . $placeholder . '" style="width:550px;" multiple tabindex="4" class="quads-select quads-chosen-select">';
|
2261 |
+
$i = 0;
|
2262 |
+
|
2263 |
+
if (!isset($quads_options[$args['id']]) || !is_array( $quads_options[$args['id']] ) || count($quads_options[$args['id']]) == 0){
|
2264 |
+
$html .= '</select>';
|
2265 |
+
echo $html;
|
2266 |
+
return;
|
2267 |
+
}
|
2268 |
+
|
2269 |
+
foreach ( $quads_options[$args['id']] as $key => $value ) {
|
2270 |
+
$html .= '<option value="' . $key . '" selected="selected">' . $value . '</option>';
|
2271 |
+
};
|
2272 |
+
$html .= '</select>';
|
2273 |
+
echo $html;
|
2274 |
+
}
|
2275 |
+
|
2276 |
+
/**
|
2277 |
+
* VI Integration
|
2278 |
+
* @global type $quads
|
2279 |
+
*
|
2280 |
+
*/
|
2281 |
+
function quads_vi_signup_callback() {
|
2282 |
+
global $quads, $quads_options;
|
2283 |
+
|
2284 |
+
//$adsense = new \wpquads\adsense($quads_options);
|
2285 |
+
//var_dump($adsense->getPublisherIds());
|
2286 |
+
//echo 'test' . $adsense->getPublisherIds() . $adsense->writeAdsTxt();
|
2287 |
+
|
2288 |
+
$header = new \wpquads\template('/includes/vendor/vi/views/partials/header', array());
|
2289 |
+
$footer = new \wpquads\template('/includes/vendor/vi/views/partials/footer', array());
|
2290 |
+
$error = new \wpquads\template('/includes/vendor/vi/views/error', array());
|
2291 |
+
|
2292 |
+
// Try to initially load vi settings
|
2293 |
+
$settings = $quads->vi->getSettings();
|
2294 |
+
if ( false === $settings || empty($settings)){
|
2295 |
+
if (!$quads->vi->setSettings()) {
|
2296 |
+
echo $header->render();
|
2297 |
+
echo $error->render();
|
2298 |
+
echo $footer->render();
|
2299 |
+
return true;
|
2300 |
+
}
|
2301 |
+
}
|
2302 |
+
|
2303 |
+
|
2304 |
+
$data = !empty($quads->vi->getSettings()->data) ? (array) $quads->vi->getSettings()->data : array();
|
2305 |
+
|
2306 |
+
$data['jsTag'] = $quads->vi->getAdCode();
|
2307 |
+
|
2308 |
+
$logged_in = new \wpquads\template('/includes/vendor/vi/views/logged_in', $data);
|
2309 |
+
$not_logged_in = new \wpquads\template('/includes/vendor/vi/views/not_logged_in', $data);
|
2310 |
+
$adform = new \wpquads\template('/includes/vendor/vi/views/ad_settings', $data);
|
2311 |
+
$revenue = new \wpquads\template('/includes/vendor/vi/views/revenue', $data);
|
2312 |
+
|
2313 |
+
// header
|
2314 |
+
echo $header->render();
|
2315 |
+
|
2316 |
+
|
2317 |
+
// Not logged in
|
2318 |
+
if (empty($data) || false === $quads->vi->setRevenue()) {
|
2319 |
+
echo $not_logged_in->render();
|
2320 |
+
} else {
|
2321 |
+
// Is logged in
|
2322 |
+
//if ($quads->vi->setRevenue()) {
|
2323 |
+
echo $revenue->render();
|
2324 |
+
echo $adform->render();
|
2325 |
+
}
|
2326 |
+
|
2327 |
+
// footer
|
2328 |
+
echo $footer->render();
|
2329 |
+
|
2330 |
+
|
2331 |
+
}
|
2332 |
+
|
2333 |
+
/**
|
2334 |
+
* Create ads.txt for Google AdSense when saving settings
|
2335 |
+
* @return boolean
|
2336 |
+
*/
|
2337 |
+
function quads_write_adsense_ads_txt() {
|
2338 |
+
// Get the current recently updated settings
|
2339 |
+
$quads_options = get_option('quads_settings');
|
2340 |
+
|
2341 |
+
// ads.txt is disabled
|
2342 |
+
if (!isset($quads_options['adsTxtEnabled'])) {
|
2343 |
+
set_transient('quads_ads_txt_disabled', true, 100);
|
2344 |
+
delete_transient('quads_ads_txt_error');
|
2345 |
+
delete_transient('quads_ads_txt_notice');
|
2346 |
+
return false;
|
2347 |
+
}
|
2348 |
+
|
2349 |
+
// Create AdSense ads.txt entries
|
2350 |
+
$adsense = new \wpquads\adsense($quads_options);
|
2351 |
+
if ($adsense->writeAdsTxt()){
|
2352 |
+
set_transient('quads_ads_txt_notice', 'true', 3000);
|
2353 |
+
return true;
|
2354 |
+
} else {
|
2355 |
+
// Make sure an error message is shown when ads.txt is available but can not be modified
|
2356 |
+
// Otherwise google adsense ads are not shown
|
2357 |
+
if (is_file(ABSPATH . 'ads.txt')) {
|
2358 |
+
set_transient('quads_ads_txt_error', 'true', 3000);
|
2359 |
+
}
|
2360 |
+
return false;
|
2361 |
+
}
|
2362 |
+
}
|
2363 |
+
add_action('update_option_quads_settings', 'quads_write_adsense_ads_txt');
|
2364 |
+
|
2365 |
+
|
2366 |
+
/**
|
2367 |
+
* Periodically update ads.txt once a day for vi and adsense
|
2368 |
+
* This is to ensure that the file is recreated in case it was deleted
|
2369 |
+
* @return boolean
|
2370 |
+
*/
|
2371 |
+
function updateAdsTxt(){
|
2372 |
+
global $quads, $quads_options;
|
2373 |
+
if(is_file('ads.txt') || !isset($quads_options['adsTxtEnabled'])){
|
2374 |
+
return false;
|
2375 |
+
}
|
2376 |
+
$quads->vi->createAdsTxt();
|
2377 |
+
$adsense = new wpquads\adsense($quads_options);
|
2378 |
+
$adsense->writeAdsTxt();
|
2379 |
+
}
|
2380 |
+
add_action('quads_daily_event', 'updateAdsTxt');
|
includes/admin/tools.php
CHANGED
@@ -1,693 +1,693 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Tools
|
4 |
-
*
|
5 |
-
* These are functions used for displaying QUADS tools such as the import/export system.
|
6 |
-
*
|
7 |
-
* @package QUADS
|
8 |
-
* @subpackage Admin/Tools
|
9 |
-
* @copyright Copyright (c) 2015, Pippin Williamson, René Hermenau
|
10 |
-
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
|
11 |
-
*/
|
12 |
-
|
13 |
-
// Exit if accessed directly
|
14 |
-
if ( ! defined( 'ABSPATH' ) ) exit;
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Tools
|
18 |
-
*
|
19 |
-
* Shows the tools panel which contains QUADS-specific tools including the
|
20 |
-
* built-in import/export system.
|
21 |
-
*
|
22 |
-
* @since 0.9.0
|
23 |
-
* @author Daniel J Griffiths, René Hermenau
|
24 |
-
* @return void
|
25 |
-
*/
|
26 |
-
function quads_tools_page() {
|
27 |
-
$active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'import_export';
|
28 |
-
?>
|
29 |
-
<div class="wrap">
|
30 |
-
<?php screen_icon(); ?>
|
31 |
-
<h2 class="nav-tab-wrapper">
|
32 |
-
<?php
|
33 |
-
foreach( quads_get_tools_tabs() as $tab_id => $tab_name ) {
|
34 |
-
|
35 |
-
$tab_url = add_query_arg( array(
|
36 |
-
'tab' => $tab_id
|
37 |
-
) );
|
38 |
-
|
39 |
-
$tab_url = remove_query_arg( array(
|
40 |
-
'quads-message'
|
41 |
-
), $tab_url );
|
42 |
-
|
43 |
-
$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
|
44 |
-
echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">' . esc_html( $tab_name ) . '</a>';
|
45 |
-
|
46 |
-
}
|
47 |
-
?>
|
48 |
-
</h2>
|
49 |
-
<div class="metabox-holder">
|
50 |
-
<?php
|
51 |
-
do_action( 'quads_tools_tab_' . $active_tab );
|
52 |
-
?>
|
53 |
-
</div><!-- .metabox-holder -->
|
54 |
-
</div><!-- .wrap -->
|
55 |
-
<?php
|
56 |
-
}
|
57 |
-
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Retrieve tools tabs
|
61 |
-
*
|
62 |
-
* @since 2.1.6
|
63 |
-
* @return array
|
64 |
-
*/
|
65 |
-
function quads_get_tools_tabs() {
|
66 |
-
|
67 |
-
$tabs = array();
|
68 |
-
$tabs['import_export'] = __( 'Import/Export', 'quick-adsense-reloaded' );
|
69 |
-
$tabs['system_info'] = __( 'System Info', 'quick-adsense-reloaded' );
|
70 |
-
|
71 |
-
return apply_filters( 'quads_tools_tabs', $tabs );
|
72 |
-
}
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Display the tools import/export tab
|
78 |
-
*
|
79 |
-
* @since 2.1.6
|
80 |
-
* @return void
|
81 |
-
*/
|
82 |
-
function quads_tools_import_export_display() {
|
83 |
-
|
84 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
85 |
-
return;
|
86 |
-
}
|
87 |
-
|
88 |
-
do_action( 'quads_tools_import_export_before' );
|
89 |
-
?>
|
90 |
-
<!-- We have to close the old form first//-->
|
91 |
-
|
92 |
-
<div class="quads-postbox">
|
93 |
-
<h3><span><?php _e( 'Export Settings', 'quick-adsense-reloaded' ); ?></span></h3>
|
94 |
-
<div class="inside">
|
95 |
-
<p><?php _e( 'Export the Quick AdSense Reloaded settings for this site as a .json file. This allows you to easily import the configuration into another site.', 'quick-adsense-reloaded' ); ?></p>
|
96 |
-
<form method="post" action="<?php echo admin_url( 'admin.php?page=quads-settings&tab=imexport' ); ?>" id="quads-export-settings">
|
97 |
-
<p><input type="hidden" name="quads-action" value="export_settings" /></p>
|
98 |
-
<p>
|
99 |
-
<?php wp_nonce_field( 'quads_export_nonce', 'quads_export_nonce' ); ?>
|
100 |
-
<?php submit_button( __( 'Export', 'quick-adsense-reloaded' ), 'primary', 'submit', false ); ?>
|
101 |
-
</p>
|
102 |
-
</form>
|
103 |
-
</div><!-- .inside -->
|
104 |
-
</div><!-- .postbox -->
|
105 |
-
|
106 |
-
<div class="quads-postbox">
|
107 |
-
<h3><span><?php _e( 'Import Settings', 'quick-adsense-reloaded' ); ?></span></h3>
|
108 |
-
<div class="inside">
|
109 |
-
<p><?php _e( 'Import the Quick AdSense Reloaded settings from a .json file. This file can be obtained by exporting the settings on another site using the form above.', 'quick-adsense-reloaded' ); ?></p>
|
110 |
-
<form method="post" enctype="multipart/form-data" action="<?php echo admin_url( 'admin.php?page=quads-settings&tab=imexport' ); ?>">
|
111 |
-
<p>
|
112 |
-
<input type="file" name="import_file"/>
|
113 |
-
</p>
|
114 |
-
<p>
|
115 |
-
<input type="hidden" name="quads-action" value="import_settings" />
|
116 |
-
<?php wp_nonce_field( 'quads_import_nonce', 'quads_import_nonce' ); ?>
|
117 |
-
<?php submit_button( __( 'Import', 'quick-adsense-reloaded' ), 'secondary', 'submit', false ); ?>
|
118 |
-
</p>
|
119 |
-
</form>
|
120 |
-
</div><!-- .inside -->
|
121 |
-
</div><!-- .postbox -->
|
122 |
-
<?php
|
123 |
-
do_action( 'quads_tools_import_export_after' );
|
124 |
-
}
|
125 |
-
add_action( 'quads_tools_tab_import_export', 'quads_tools_import_export_display' );
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
/* check if function is disabled or not
|
130 |
-
*
|
131 |
-
* @returns bool
|
132 |
-
* @since 2.1.6
|
133 |
-
*/
|
134 |
-
function quads_is_func_disabled( $function ) {
|
135 |
-
$disabled = explode( ',', ini_get( 'disable_functions' ) );
|
136 |
-
return in_array( $function, $disabled );
|
137 |
-
}
|
138 |
-
|
139 |
-
/**
|
140 |
-
* Process a settings export that generates a .json file of the Quick AdSense Reloaded settings
|
141 |
-
*
|
142 |
-
* @since 2.1.6
|
143 |
-
* @return void
|
144 |
-
*/
|
145 |
-
function quads_tools_import_export_process_export() {
|
146 |
-
if( empty( $_POST['quads_export_nonce'] ) )
|
147 |
-
return;
|
148 |
-
|
149 |
-
if( ! wp_verify_nonce( $_POST['quads_export_nonce'], 'quads_export_nonce' ) )
|
150 |
-
return;
|
151 |
-
|
152 |
-
if( ! current_user_can( 'manage_options' ) )
|
153 |
-
return;
|
154 |
-
|
155 |
-
$settings = array();
|
156 |
-
$settings = get_option( 'quads_settings' );
|
157 |
-
|
158 |
-
ignore_user_abort( true );
|
159 |
-
|
160 |
-
if ( ! quads_is_func_disabled( 'set_time_limit' ) )
|
161 |
-
@set_time_limit( 0 );
|
162 |
-
|
163 |
-
nocache_headers();
|
164 |
-
header( 'Content-Type: application/json; charset=utf-8' );
|
165 |
-
header( 'Content-Disposition: attachment; filename=' . apply_filters( 'quads_settings_export_filename', 'quads-settings-export-' . date( 'm-d-Y' ) ) . '.json' );
|
166 |
-
header( "Expires: 0" );
|
167 |
-
|
168 |
-
echo json_encode( $settings );
|
169 |
-
exit;
|
170 |
-
}
|
171 |
-
add_action( 'quads_export_settings', 'quads_tools_import_export_process_export' );
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Get File Extension
|
175 |
-
*
|
176 |
-
* Returns the file extension of a filename.
|
177 |
-
*
|
178 |
-
* @since 1.0
|
179 |
-
* @param unknown $str File name
|
180 |
-
* @return mixed File extension
|
181 |
-
*/
|
182 |
-
function quads_get_file_extension( $str ) {
|
183 |
-
$parts = explode( '.', $str );
|
184 |
-
return end( $parts );
|
185 |
-
}
|
186 |
-
|
187 |
-
/* Convert an object to an associative array.
|
188 |
-
* Can handle multidimensional arrays
|
189 |
-
*
|
190 |
-
* @returns array
|
191 |
-
* @since 2.1.6
|
192 |
-
*/
|
193 |
-
function quads_object_to_array( $data ) {
|
194 |
-
if ( is_array( $data ) || is_object( $data ) ) {
|
195 |
-
$result = array();
|
196 |
-
foreach ( $data as $key => $value ) {
|
197 |
-
$result[ $key ] = quads_object_to_array( $value );
|
198 |
-
}
|
199 |
-
return $result;
|
200 |
-
}
|
201 |
-
return $data;
|
202 |
-
}
|
203 |
-
|
204 |
-
/**
|
205 |
-
* Process a settings import from a json file
|
206 |
-
*
|
207 |
-
* @since 2.1.6
|
208 |
-
* @return void
|
209 |
-
*/
|
210 |
-
function quads_tools_import_export_process_import() {
|
211 |
-
if( empty( $_POST['quads_import_nonce'] ) )
|
212 |
-
return;
|
213 |
-
|
214 |
-
if( ! wp_verify_nonce( $_POST['quads_import_nonce'], 'quads_import_nonce' ) )
|
215 |
-
return;
|
216 |
-
|
217 |
-
if( ! current_user_can( 'update_plugins' ) )
|
218 |
-
return;
|
219 |
-
|
220 |
-
if( quads_get_file_extension( $_FILES['import_file']['name'] ) != 'json' ) {
|
221 |
-
wp_die( __( 'Please upload a valid .json file', 'quick-adsense-reloaded' ) );
|
222 |
-
}
|
223 |
-
|
224 |
-
$import_file = $_FILES['import_file']['tmp_name'];
|
225 |
-
|
226 |
-
if( empty( $import_file ) ) {
|
227 |
-
wp_die( __( 'Please upload a file to import', 'quick-adsense-reloaded' ) );
|
228 |
-
}
|
229 |
-
|
230 |
-
// Retrieve the settings from the file and convert the json object to an array
|
231 |
-
$settings = quads_object_to_array( json_decode( file_get_contents( $import_file ) ) );
|
232 |
-
|
233 |
-
update_option( 'quads_settings', $settings );
|
234 |
-
|
235 |
-
wp_safe_redirect( admin_url( 'admin.php?page=quads-settings&quads-message=settings-imported&tab=imexport' ) ); exit;
|
236 |
-
|
237 |
-
}
|
238 |
-
add_action( 'quads_import_settings', 'quads_tools_import_export_process_import' );
|
239 |
-
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Display the system info tab
|
243 |
-
*
|
244 |
-
* @since 2.1.6
|
245 |
-
* @return void
|
246 |
-
* @change 2.3.1
|
247 |
-
*/
|
248 |
-
function quads_tools_sysinfo_display() {
|
249 |
-
|
250 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
251 |
-
return;
|
252 |
-
}
|
253 |
-
|
254 |
-
?>
|
255 |
-
<!--<form action="<?php //echo esc_url( admin_url( 'admin.php?page=quads-settings&tab=system_info' ) ); ?>" method="post" dir="ltr">//-->
|
256 |
-
<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="quads-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php echo quads_tools_sysinfo_get(); ?></textarea>
|
257 |
-
<!--
|
258 |
-
<p class="submit">
|
259 |
-
<input type="hidden" name="quads-action" value="download_sysinfo" />-->
|
260 |
-
<?php //submit_button( 'Download System Info File', 'primary', 'quads-download-sysinfo', false ); ?>
|
261 |
-
<!--</p>//-->
|
262 |
-
<!--</form>//-->
|
263 |
-
<?php
|
264 |
-
echo '<br>' . quads_render_backup_settings();
|
265 |
-
|
266 |
-
}
|
267 |
-
add_action( 'quads_tools_tab_system_info', 'quads_tools_sysinfo_display' );
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Render textarea with backup settings from previous version 1.5.2
|
271 |
-
* @return string
|
272 |
-
*/
|
273 |
-
function quads_render_backup_settings(){
|
274 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
275 |
-
return;
|
276 |
-
}
|
277 |
-
|
278 |
-
$settings = json_encode(get_option('quads_settings_1_5_2'));
|
279 |
-
echo '<h3>' . __('Backup data from WP QUADS 1.5.2', 'quick-adsense-reloaded') . '</h3>' . __('Copy and paste this data into an empty text file with extension *.json');
|
280 |
-
?>
|
281 |
-
|
282 |
-
<textarea readonly="readonly" onclick="this.focus(); this.select()" id="backup-settings-textarea" name="quads-backupsettings" title="To copy the backup settings info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php echo $settings; ?></textarea>
|
283 |
-
<?php
|
284 |
-
}
|
285 |
-
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Get system info
|
289 |
-
*
|
290 |
-
* @since 2.1.6
|
291 |
-
* @access public
|
292 |
-
* @global object $wpdb Used to query the database using the WordPress Database API
|
293 |
-
* @global array $quads_options Array of all QUADS options
|
294 |
-
* @return string $return A string containing the info to output
|
295 |
-
*/
|
296 |
-
function quads_tools_sysinfo_get() {
|
297 |
-
global $wpdb, $quads_options;
|
298 |
-
|
299 |
-
if( !class_exists( 'Browser' ) )
|
300 |
-
require_once QUADS_PLUGIN_DIR . 'includes/libraries/browser.php';
|
301 |
-
|
302 |
-
$browser = new Browser();
|
303 |
-
|
304 |
-
// Get theme info
|
305 |
-
if( get_bloginfo( 'version' ) < '3.4' ) {
|
306 |
-
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
|
307 |
-
$theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
|
308 |
-
} else {
|
309 |
-
$theme_data = wp_get_theme();
|
310 |
-
$theme = $theme_data->Name . ' ' . $theme_data->Version;
|
311 |
-
}
|
312 |
-
|
313 |
-
|
314 |
-
$return = '### Begin System Info ###' . "\n\n";
|
315 |
-
|
316 |
-
// Start with the basics...
|
317 |
-
$return .= '-- Site Info' . "\n\n";
|
318 |
-
$return .= 'Site URL: ' . site_url() . "\n";
|
319 |
-
$return .= 'Home URL: ' . home_url() . "\n";
|
320 |
-
$return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
|
321 |
-
|
322 |
-
$return = apply_filters( 'quads_sysinfo_after_site_info', $return );
|
323 |
-
|
324 |
-
|
325 |
-
// The local users' browser information, handled by the Browser class
|
326 |
-
$return .= "\n" . '-- User Browser' . "\n\n";
|
327 |
-
$return .= $browser;
|
328 |
-
|
329 |
-
$return = apply_filters( 'quads_sysinfo_after_user_browser', $return );
|
330 |
-
|
331 |
-
// WordPress configuration
|
332 |
-
$return .= "\n" . '-- WordPress Configuration' . "\n\n";
|
333 |
-
$return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
|
334 |
-
$return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
|
335 |
-
$return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
|
336 |
-
$return .= 'Active Theme: ' . $theme . "\n";
|
337 |
-
$return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
|
338 |
-
|
339 |
-
// Only show page specs if frontpage is set to 'page'
|
340 |
-
if( get_option( 'show_on_front' ) == 'page' ) {
|
341 |
-
$front_page_id = get_option( 'page_on_front' );
|
342 |
-
$blog_page_id = get_option( 'page_for_posts' );
|
343 |
-
|
344 |
-
$return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
|
345 |
-
$return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
|
346 |
-
}
|
347 |
-
|
348 |
-
// Make sure wp_remote_post() is working
|
349 |
-
$request['cmd'] = '_notify-validate';
|
350 |
-
|
351 |
-
$params = array(
|
352 |
-
'sslverify' => false,
|
353 |
-
'timeout' => 60,
|
354 |
-
'user-agent' => 'QUADS/' . QUADS_VERSION,
|
355 |
-
'body' => $request
|
356 |
-
);
|
357 |
-
|
358 |
-
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
|
359 |
-
|
360 |
-
if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
|
361 |
-
$WP_REMOTE_POST = 'wp_remote_post() works';
|
362 |
-
} else {
|
363 |
-
$WP_REMOTE_POST = 'wp_remote_post() does not work';
|
364 |
-
}
|
365 |
-
|
366 |
-
$return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
|
367 |
-
$return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
|
368 |
-
$return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
|
369 |
-
$return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
|
370 |
-
$return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
|
371 |
-
|
372 |
-
$return = apply_filters( 'quads_sysinfo_after_wordpress_config', $return );
|
373 |
-
|
374 |
-
// QUADS configuration
|
375 |
-
$return .= "\n" . '-- QUADS Configuration' . "\n\n";
|
376 |
-
$return .= 'Version: ' . QUADS_VERSION . "\n";
|
377 |
-
$return .= 'Upgraded From: ' . get_option( 'quads_version_upgraded_from', 'None' ) . "\n";
|
378 |
-
|
379 |
-
$return = apply_filters( 'quads_sysinfo_after_quads_config', $return );
|
380 |
-
|
381 |
-
|
382 |
-
// WordPress active plugins
|
383 |
-
$return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
|
384 |
-
|
385 |
-
$plugins = get_plugins();
|
386 |
-
$active_plugins = get_option( 'active_plugins', array() );
|
387 |
-
|
388 |
-
foreach( $plugins as $plugin_path => $plugin ) {
|
389 |
-
if( !in_array( $plugin_path, $active_plugins ) )
|
390 |
-
continue;
|
391 |
-
|
392 |
-
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
|
393 |
-
}
|
394 |
-
|
395 |
-
$return = apply_filters( 'quads_sysinfo_after_wordpress_plugins', $return );
|
396 |
-
|
397 |
-
// WordPress inactive plugins
|
398 |
-
$return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
|
399 |
-
|
400 |
-
foreach( $plugins as $plugin_path => $plugin ) {
|
401 |
-
if( in_array( $plugin_path, $active_plugins ) )
|
402 |
-
continue;
|
403 |
-
|
404 |
-
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
|
405 |
-
}
|
406 |
-
|
407 |
-
$return = apply_filters( 'quads_sysinfo_after_wordpress_plugins_inactive', $return );
|
408 |
-
|
409 |
-
if( is_multisite() ) {
|
410 |
-
// WordPress Multisite active plugins
|
411 |
-
$return .= "\n" . '-- Network Active Plugins' . "\n\n";
|
412 |
-
|
413 |
-
$plugins = wp_get_active_network_plugins();
|
414 |
-
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
|
415 |
-
|
416 |
-
foreach( $plugins as $plugin_path ) {
|
417 |
-
$plugin_base = plugin_basename( $plugin_path );
|
418 |
-
|
419 |
-
if( !array_key_exists( $plugin_base, $active_plugins ) )
|
420 |
-
continue;
|
421 |
-
|
422 |
-
$plugin = get_plugin_data( $plugin_path );
|
423 |
-
$return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
|
424 |
-
}
|
425 |
-
|
426 |
-
$return = apply_filters( 'quads_sysinfo_after_wordpress_ms_plugins', $return );
|
427 |
-
}
|
428 |
-
|
429 |
-
// Server configuration (really just versioning)
|
430 |
-
$return .= "\n" . '-- Webserver Configuration' . "\n\n";
|
431 |
-
$return .= 'PHP Version: ' . PHP_VERSION . "\n";
|
432 |
-
$return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
|
433 |
-
$return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
|
434 |
-
|
435 |
-
$return = apply_filters( 'quads_sysinfo_after_webserver_config', $return );
|
436 |
-
|
437 |
-
// PHP configs... now we're getting to the important stuff
|
438 |
-
$return .= "\n" . '-- PHP Configuration' . "\n\n";
|
439 |
-
$return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
|
440 |
-
$return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
441 |
-
$return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
|
442 |
-
$return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
|
443 |
-
$return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
|
444 |
-
$return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
|
445 |
-
$return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
|
446 |
-
|
447 |
-
$return = apply_filters( 'quads_sysinfo_after_php_config', $return );
|
448 |
-
|
449 |
-
// PHP extensions and such
|
450 |
-
$return .= "\n" . '-- PHP Extensions' . "\n\n";
|
451 |
-
$return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
452 |
-
$return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
|
453 |
-
$return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
454 |
-
$return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
|
455 |
-
|
456 |
-
$return = apply_filters( 'quads_sysinfo_after_php_ext', $return );
|
457 |
-
|
458 |
-
$return .= "\n" . '### End System Info ###';
|
459 |
-
|
460 |
-
return $return;
|
461 |
-
}
|
462 |
-
|
463 |
-
|
464 |
-
/**
|
465 |
-
* Generates a System Info download file
|
466 |
-
*
|
467 |
-
* @since 2.0
|
468 |
-
* @return void
|
469 |
-
*/
|
470 |
-
function quads_tools_sysinfo_download() {
|
471 |
-
|
472 |
-
if( ! current_user_can( 'update_plugins' ) )
|
473 |
-
return;
|
474 |
-
|
475 |
-
nocache_headers();
|
476 |
-
|
477 |
-
header( 'Content-Type: text/plain' );
|
478 |
-
header( 'Content-Disposition: attachment; filename="quads-system-info.txt"' );
|
479 |
-
|
480 |
-
echo wp_strip_all_tags( $_POST['quads-sysinfo'] );
|
481 |
-
wp_die();
|
482 |
-
}
|
483 |
-
add_action( 'quads_download_sysinfo', 'quads_tools_sysinfo_download' );
|
484 |
-
|
485 |
-
/*
|
486 |
-
* Import settings from Quick AdSense reloaded v. 1.9.2
|
487 |
-
*/
|
488 |
-
|
489 |
-
function quads_import_quick_adsense_settings(){
|
490 |
-
// Check first if Quick AdSense is installed and version matches
|
491 |
-
if (!quads_check_quick_adsense_version())
|
492 |
-
return;
|
493 |
-
|
494 |
-
|
495 |
-
if( ! current_user_can( 'update_plugins' ) ) {
|
496 |
-
return;
|
497 |
-
}
|
498 |
-
|
499 |
-
do_action( 'quads_import_quick_adsense_settings_before' );
|
500 |
-
?>
|
501 |
-
<div class="quads-postbox" id="quads-import-settings">
|
502 |
-
<h3><span><?php _e( 'Import from Quick AdSense', 'quick-adsense-reloaded' ); ?></span></h3>
|
503 |
-
<div class="inside">
|
504 |
-
<p><?php _e( 'Import the settings for Quick AdSense Reloaded from Quick AdSense v. 1.9.2.', 'quick-adsense-reloaded' ); ?></p>
|
505 |
-
|
506 |
-
<!--
|
507 |
-
<form id="quads_quick_adsense_input" method="post" action="<?php echo admin_url( 'admin.php?page=quads-settings&tab=imexport' ); ?>" onsubmit="return confirm('Importing the settings from Quick AdSense will overwrite all your current settings. Are you sure?');">
|
508 |
-
-->
|
509 |
-
<p><input type="hidden" name="quads-action" value="import_quick_adsense" /></p>
|
510 |
-
<p>
|
511 |
-
<?php wp_nonce_field( 'quads_quick_adsense_nonce', 'quads_quick_adsense_nonce' ); ?>
|
512 |
-
<?php submit_button( __( 'Start Import process', 'quick-adsense-reloaded' ), 'primary quads-import-settings', 'submit', false ); ?>
|
513 |
-
</p>
|
514 |
-
<!--</form>-->
|
515 |
-
<div id="quads-error-details"></div>
|
516 |
-
</div><!-- .inside -->
|
517 |
-
</div><!-- .postbox -->
|
518 |
-
<?php
|
519 |
-
do_action( 'quads_import_quick_adsense_settings_after' );
|
520 |
-
}
|
521 |
-
add_action( 'quads_import_quick_adsense_settings', 'quads_import_quick_adsense_settings' );
|
522 |
-
|
523 |
-
/**
|
524 |
-
* Ajax process a settings import from Quick AdSense
|
525 |
-
*
|
526 |
-
* @since 0.9.0
|
527 |
-
* @return string json
|
528 |
-
*/
|
529 |
-
function quads_import_quick_adsense_process() {
|
530 |
-
|
531 |
-
check_ajax_referer( 'quads_ajax_nonce', 'nonce' );
|
532 |
-
|
533 |
-
if( ! current_user_can( 'manage_options' ) )
|
534 |
-
return;
|
535 |
-
|
536 |
-
ignore_user_abort( true );
|
537 |
-
|
538 |
-
if ( ! quads_is_func_disabled( 'set_time_limit' ) )
|
539 |
-
set_time_limit( 0 );
|
540 |
-
|
541 |
-
|
542 |
-
$quads_settings = get_quick_adsense_setting();
|
543 |
-
$quads_reloaded_settings = get_option('quads_settings');
|
544 |
-
|
545 |
-
|
546 |
-
if (update_option('quads_settings', $quads_settings ) ){
|
547 |
-
$message = __('Most of the settings have been sucessfully imported from Quick AdSense <br> but due to some inconsistencies there are still some options which needs your a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|