AdSense Plugin WP QUADS - Version 1.8.8

Version Description

  • New: Compatible up to WordPress 5.3.0
Download this release

Release Info

Developer ReneHermi
Plugin Icon 128x128 AdSense Plugin WP QUADS
Version 1.8.8
Comparing to
See all releases

Code changes from version 1.8.7 to 1.8.8

Files changed (45) hide show
  1. assets/css/quads-admin-all.css +121 -121
  2. assets/css/quads-admin.css +1204 -1204
  3. assets/js/blocks.js +21 -21
  4. assets/js/chosen.jquery.js +1284 -1284
  5. assets/js/chosen.jquery.min.js +1 -1
  6. assets/js/jscolor.min.js +9 -9
  7. assets/js/quads-admin.js +1799 -1799
  8. includes/Cron/Cron.php +54 -54
  9. includes/DI/InjectionAware.php +38 -38
  10. includes/Forms/Elements.php +299 -299
  11. includes/Forms/Elements/Check.php +65 -65
  12. includes/Forms/Elements/Date.php +27 -27
  13. includes/Forms/Elements/DateTime.php +25 -25
  14. includes/Forms/Elements/Email.php +27 -27
  15. includes/Forms/Elements/File.php +27 -27
  16. includes/Forms/Elements/Hidden.php +28 -28
  17. includes/Forms/Elements/Interfaces/InterfaceElement.php +134 -134
  18. includes/Forms/Elements/Interfaces/InterfaceElementWithOptions.php +33 -33
  19. includes/Forms/Elements/Numerical.php +25 -25
  20. includes/Forms/Elements/Password.php +28 -28
  21. includes/Forms/Elements/Radio.php +43 -43
  22. includes/Forms/Elements/Select.php +58 -58
  23. includes/Forms/Elements/SelectMultiple.php +57 -57
  24. includes/Forms/Elements/Text.php +27 -27
  25. includes/Forms/Elements/TextArea.php +27 -27
  26. includes/Forms/Elements/TextAreaHidden.php +27 -27
  27. includes/Forms/ElementsWithOptions.php +75 -75
  28. includes/Forms/Form.php +59 -59
  29. includes/admin/admin-actions.php +150 -150
  30. includes/admin/admin-notices.php +728 -728
  31. includes/admin/admin-pages.php +83 -83
  32. includes/admin/adsTxt.php +106 -106
  33. includes/admin/settings/display-settings.php +354 -354
  34. includes/admin/settings/register-settings.php +2380 -2380
  35. includes/admin/views/notices.php +18 -18
  36. includes/class-quads-html-elements.php +328 -328
  37. includes/class-template.php +45 -45
  38. includes/conditions.php +255 -255
  39. includes/post_types.php +51 -51
  40. includes/scripts.php +316 -316
  41. includes/shortcodes.php +133 -133
  42. includes/template-functions.php +858 -858
  43. includes/vendor/google/adsense.php +162 -162
  44. includes/vendor/vi/conditions.php +187 -187
  45. includes/vendor/vi/public/js/vi.js +0 -132
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/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
- "<": "&lt;",
94
- ">": "&gt;",
95
- '"': "&quot;",
96
- "'": "&#x27;",
97
- "`": "&#x60;"
98
- };
99
- unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
100
- return text.replace(unsafe_chars, function(chr) {
101
- return map[chr] || "&amp;";
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
+ "<": "&lt;",
94
+ ">": "&gt;",
95
+ '"': "&quot;",
96
+ "'": "&#x27;",
97
+ "`": "&#x60;"
98
+ };
99
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
100
+ return text.replace(unsafe_chars, function(chr) {
101
+ return map[chr] || "&amp;";
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={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):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={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):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);
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/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-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/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>&nbsp;&nbsp;
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>&nbsp;&nbsp;
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 '&nbsp';
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 ) . '/>&nbsp;';
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 ) . '/>&nbsp;';
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 ) . '/>&nbsp;';
704
- echo '<label for="quads_settings[ads][' . $id . '][ad_type_' . $key . ']">' . $option . '</label>&nbsp;';
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 ) . '/>&nbsp;';
735
- echo '<label for="quads_settings[ads][' . $id . '][align_' . $key . ']">Default</label>&nbsp;';
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 ) . '/>&nbsp;';
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>&nbsp;';
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>&nbsp;<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;">&lt;!--more--&gt;</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;"> &lt;div&gt; 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">&lt;!--Ads1--&gt;</span>, <span class="quads-quote-docs">&lt;!--Ads2--&gt;</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">&lt;!--RndAds--&gt;</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="&lt;?php echo do_shortcode('[quads id=<?php echo $args['id']; ?>]'); ?&gt;" 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 '&nbsp';
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 ) . '/>&nbsp;';
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 ) . '/>&nbsp;';
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 ) . '/>&nbsp;';
704
+ echo '<label for="quads_settings[ads][' . $id . '][ad_type_' . $key . ']">' . $option . '</label>&nbsp;';
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 ) . '/>&nbsp;';
735
+ echo '<label for="quads_settings[ads][' . $id . '][align_' . $key . ']">Default</label>&nbsp;';
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 ) . '/>&nbsp;';
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>&nbsp;';
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>&nbsp;<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;">&lt;!--more--&gt;</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;"> &lt;div&gt; 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">&lt;!--Ads1--&gt;</span>, <span class="quads-quote-docs">&lt;!--Ads2--&gt;</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">&lt;!--RndAds--&gt;</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="&lt;?php echo do_shortcode('[quads id=<?php echo $args['id']; ?>]'); ?&gt;" 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/views/notices.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
- /*
3
- * WP QUADS Notices
4
- */
5
- ?>
6
-
7
-
8
-
9
- <div class="quads-banner-wrapper notice <?php echo $type; ?>">
10
- <section class="quads-banner-content">
11
- <div class="quads-banner-columns">
12
- <main class="quads-banner-main"><p><?php echo $message; ?></p></main>
13
- <aside class="quads-banner-sidebar-second" style="margin-right:30px;"></p></aside>
14
- </div>
15
- <aside class="quads-banner-close"><div style="margin-top:5px;"><a href="<?php echo admin_url();?>admin.php?page=quads-settings&quads-action=<?php echo $action; ?>" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
16
- </section>
17
- </div>
18
-
1
+ <?php
2
+ /*
3
+ * WP QUADS Notices
4
+ */
5
+ ?>
6
+
7
+
8
+
9
+ <div class="quads-banner-wrapper notice <?php echo $type; ?>">
10
+ <section class="quads-banner-content">
11
+ <div class="quads-banner-columns">
12
+ <main class="quads-banner-main"><p><?php echo $message; ?></p></main>
13
+ <aside class="quads-banner-sidebar-second" style="margin-right:30px;"></p></aside>
14
+ </div>
15
+ <aside class="quads-banner-close"><div style="margin-top:5px;"><a href="<?php echo admin_url();?>admin.php?page=quads-settings&quads-action=<?php echo $action; ?>" class="quads-notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></a></div></aside>
16
+ </section>
17
+ </div>
18
+
includes/class-quads-html-elements.php CHANGED
@@ -1,328 +1,328 @@
1
- <?php
2
- /**
3
- * HTML elements
4
- *
5
- * A helper class for outputting common HTML elements, such as drop down and checkbox fields
6
- *
7
- * @package QUADS
8
- * @subpackage Classes/HTML
9
- * @copyright Copyright (c) 2015, Pippin Williamson, René Hermenau
10
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
- * @since 0.9.0
12
- */
13
-
14
- // Exit if accessed directly
15
- if ( ! defined( 'ABSPATH' ) ) exit;
16
-
17
- /**
18
- * QUADS_HTML_Elements Class
19
- *
20
- * @since 0.9.0
21
- */
22
- class QUADS_HTML_Elements {
23
-
24
-
25
- /**
26
- * Renders an HTML Dropdown
27
- *
28
- * @since 0.9.0
29
- *
30
- * @param array $args
31
- *
32
- * @return string
33
- */
34
- public function select( $args = array() ) {
35
- $defaults = array(
36
- 'options' => array(),
37
- 'name' => null,
38
- 'class' => '',
39
- 'id' => '',
40
- 'selected' => 0,
41
- 'chosen' => false,
42
- 'placeholder' => null,
43
- 'multiple' => false,
44
- 'show_option_all' => _x( 'All', 'all dropdown items', 'easy-digital-downloads' ),
45
- 'show_option_none' => _x( 'None', 'no dropdown items', 'easy-digital-downloads' )
46
- );
47
-
48
- $args = wp_parse_args( $args, $defaults );
49
-
50
-
51
- if( $args['multiple'] ) {
52
- $multiple = ' MULTIPLE';
53
- } else {
54
- $multiple = '';
55
- }
56
-
57
- if( $args['chosen'] ) {
58
- $args['class'] .= ' quads-select-chosen';
59
- }
60
-
61
- if( $args['placeholder'] ) {
62
- $placeholder = $args['placeholder'];
63
- } else {
64
- $placeholder = '';
65
- }
66
-
67
- $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="quads-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">';
68
-
69
- if ( $args['show_option_all'] ) {
70
- if( $args['multiple'] ) {
71
- $selected = selected( true, in_array( 0, $args['selected'] ), false );
72
- } else {
73
- $selected = selected( $args['selected'], 0, false );
74
- }
75
- $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
76
- }
77
-
78
- if ( ! empty( $args['options'] ) ) {
79
-
80
- if ( $args['show_option_none'] ) {
81
- if( $args['multiple'] ) {
82
- $selected = selected( true, in_array( -1, $args['selected'] ), false );
83
- } else {
84
- $selected = selected( $args['selected'], -1, false );
85
- }
86
- $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
87
- }
88
-
89
- foreach( $args['options'] as $key => $option ) {
90
-
91
- if( $args['multiple'] && is_array( $args['selected'] ) ) {
92
- $selected = selected( true, in_array( $key, $args['selected'] ), false );
93
- } else {
94
- $selected = selected( $args['selected'], $key, false );
95
- }
96
-
97
- $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
98
- }
99
- }
100
-
101
- $output .= '</select>';
102
-
103
- return $output;
104
- }
105
-
106
- /**
107
- * Renders an HTML Checkbox
108
- *
109
- * @since 0.9.0
110
- *
111
- * @param array $args
112
- *
113
- * @return string
114
- */
115
- public function checkbox( $args = array() ) {
116
- $defaults = array(
117
- 'name' => null,
118
- 'current' => null,
119
- 'class' => 'quads-checkbox',
120
- 'value' => "1",
121
- 'options' => array(
122
- 'disabled' => false,
123
- 'readonly' => false
124
- )
125
-
126
- );
127
-
128
- $args = wp_parse_args( $args, $defaults );
129
-
130
- $options = '';
131
- if ( ! empty( $args['options']['disabled'] ) ) {
132
- $options .= ' disabled="disabled"';
133
- } elseif ( ! empty( $args['options']['readonly'] ) ) {
134
- $options .= ' readonly';
135
- }
136
-
137
- $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '"' . checked( $args['value'], $args['current'], false ) .' value="1" />';
138
-
139
- return $output;
140
- }
141
-
142
- /**
143
- * Renders an HTML Text field
144
- *
145
- * @since 0.9.0
146
- *
147
- * @param array $args Arguments for the text field
148
- * @return string Text field
149
- */
150
- public function text( $args = array() ) {
151
- // Backwards compatabliity
152
- if ( func_num_args() > 1 ) {
153
- $args = func_get_args();
154
-
155
- $name = $args[0];
156
- $value = isset( $args[1] ) ? $args[1] : '';
157
- $label = isset( $args[2] ) ? $args[2] : '';
158
- $desc = isset( $args[3] ) ? $args[3] : '';
159
- }
160
-
161
- $defaults = array(
162
- 'id' => '',
163
- 'name' => isset( $name ) ? $name : 'text',
164
- 'value' => isset( $value ) ? $value : null,
165
- 'label' => isset( $label ) ? $label : null,
166
- 'desc' => isset( $desc ) ? $desc : null,
167
- 'placeholder' => '',
168
- 'class' => isset( $args['class'] ) ? 'regular-text ' . $args['class'] : 'regular-text',
169
- 'disabled' => false,
170
- 'autocomplete' => '',
171
- 'data' => false
172
- );
173
-
174
- $args = wp_parse_args( $args, $defaults );
175
-
176
- $disabled = '';
177
- if( $args['disabled'] ) {
178
- $disabled = ' disabled="disabled"';
179
- }
180
-
181
- $data = '';
182
- if ( ! empty( $args['data'] ) ) {
183
- foreach ( $args['data'] as $key => $value ) {
184
- $data .= 'data-' . $key . '="' . $value . '" ';
185
- }
186
- }
187
-
188
- $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
189
-
190
- $output .= '<label class="quads-label" for="' . sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
191
-
192
- if ( ! empty( $args['desc'] ) ) {
193
- $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
194
- }
195
-
196
- $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
197
-
198
- $output .= '</span>';
199
-
200
- return $output;
201
- }
202
- /**
203
- * Renders a date picker
204
- *
205
- * @since 0.9.0
206
- *
207
- * @param array $args Arguments for the text field
208
- * @return string Datepicker field
209
- */
210
- public function date_field( $args = array() ) {
211
-
212
- if( empty( $args['class'] ) ) {
213
- $args['class'] = 'quads_datepicker';
214
- } elseif( ! strpos( $args['class'], 'quads_datepicker' ) ) {
215
- $args['class'] .= ' quads_datepicker';
216
- }
217
-
218
- return $this->text( $args );
219
- }
220
-
221
- /**
222
- * Renders an HTML textarea
223
- *
224
- * @since 0.9.0
225
- *
226
- * @param array $args Arguments for the textarea
227
- * @return string textarea
228
- */
229
- public function textarea( $args = array() ) {
230
- $defaults = array(
231
- 'name' => 'textarea',
232
- 'value' => null,
233
- 'label' => null,
234
- 'desc' => null,
235
- 'class' => 'large-text',
236
- 'disabled' => false,
237
- 'placeholder' => '',
238
-
239
- );
240
-
241
- $args = wp_parse_args( $args, $defaults );
242
-
243
- $disabled = '';
244
- if( $args['disabled'] ) {
245
- $disabled = ' disabled="disabled"';
246
- }
247
-
248
- $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
249
-
250
- $output .= '<label class="quads-label" for="quads-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
251
-
252
- $output .= '<textarea placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
253
-
254
- if ( ! empty( $args['desc'] ) ) {
255
- $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
256
- }
257
-
258
- $output .= '</span>';
259
-
260
- return $output;
261
- }
262
-
263
-
264
- /**
265
- * Renders an HTML Dropdown of years
266
- *
267
- * @access public
268
- * @since 0.9.0
269
- * @param string $name Name attribute of the dropdown
270
- * @param int $selected Year to select automatically
271
- * @param int $years_before Number of years before the current year the dropdown should start with
272
- * @param int $years_after Number of years after the current year the dropdown should finish at
273
- * @return string $output Year dropdown
274
- */
275
- public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
276
- $current = date( 'Y' );
277
- $start_year = $current - absint( $years_before );
278
- $end_year = $current + absint( $years_after );
279
- $selected = empty( $selected ) ? date( 'Y' ) : $selected;
280
- $options = array();
281
-
282
- while ( $start_year <= $end_year ) {
283
- $options[ absint( $start_year ) ] = $start_year;
284
- $start_year++;
285
- }
286
-
287
- $output = $this->select( array(
288
- 'name' => $name,
289
- 'selected' => $selected,
290
- 'options' => $options,
291
- 'show_option_all' => false,
292
- 'show_option_none' => false
293
- ) );
294
-
295
- return $output;
296
- }
297
-
298
- /**
299
- * Renders an HTML Dropdown of months
300
- *
301
- * @access public
302
- * @since 0.9.0
303
- * @param string $name Name attribute of the dropdown
304
- * @param int $selected Month to select automatically
305
- * @return string $output Month dropdown
306
- */
307
- public function month_dropdown( $name = 'month', $selected = 0 ) {
308
- $month = 1;
309
- $options = array();
310
- $selected = empty( $selected ) ? date( 'n' ) : $selected;
311
-
312
- while ( $month <= 12 ) {
313
- $options[ absint( $month ) ] = quads_month_num_to_name( $month );
314
- $month++;
315
- }
316
-
317
- $output = $this->select( array(
318
- 'name' => $name,
319
- 'selected' => $selected,
320
- 'options' => $options,
321
- 'show_option_all' => false,
322
- 'show_option_none' => false
323
- ) );
324
-
325
- return $output;
326
- }
327
-
328
- }
1
+ <?php
2
+ /**
3
+ * HTML elements
4
+ *
5
+ * A helper class for outputting common HTML elements, such as drop down and checkbox fields
6
+ *
7
+ * @package QUADS
8
+ * @subpackage Classes/HTML
9
+ * @copyright Copyright (c) 2015, Pippin Williamson, René Hermenau
10
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+ * @since 0.9.0
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) exit;
16
+
17
+ /**
18
+ * QUADS_HTML_Elements Class
19
+ *
20
+ * @since 0.9.0
21
+ */
22
+ class QUADS_HTML_Elements {
23
+
24
+
25
+ /**
26
+ * Renders an HTML Dropdown
27
+ *
28
+ * @since 0.9.0
29
+ *
30
+ * @param array $args
31
+ *
32
+ * @return string
33
+ */
34
+ public function select( $args = array() ) {
35
+ $defaults = array(
36
+ 'options' => array(),
37
+ 'name' => null,
38
+ 'class' => '',
39
+ 'id' => '',
40
+ 'selected' => 0,
41
+ 'chosen' => false,
42
+ 'placeholder' => null,
43
+ 'multiple' => false,
44
+ 'show_option_all' => _x( 'All', 'all dropdown items', 'easy-digital-downloads' ),
45
+ 'show_option_none' => _x( 'None', 'no dropdown items', 'easy-digital-downloads' )
46
+ );
47
+
48
+ $args = wp_parse_args( $args, $defaults );
49
+
50
+
51
+ if( $args['multiple'] ) {
52
+ $multiple = ' MULTIPLE';
53
+ } else {
54
+ $multiple = '';
55
+ }
56
+
57
+ if( $args['chosen'] ) {
58
+ $args['class'] .= ' quads-select-chosen';
59
+ }
60
+
61
+ if( $args['placeholder'] ) {
62
+ $placeholder = $args['placeholder'];
63
+ } else {
64
+ $placeholder = '';
65
+ }
66
+
67
+ $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="quads-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">';
68
+
69
+ if ( $args['show_option_all'] ) {
70
+ if( $args['multiple'] ) {
71
+ $selected = selected( true, in_array( 0, $args['selected'] ), false );
72
+ } else {
73
+ $selected = selected( $args['selected'], 0, false );
74
+ }
75
+ $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
76
+ }
77
+
78
+ if ( ! empty( $args['options'] ) ) {
79
+
80
+ if ( $args['show_option_none'] ) {
81
+ if( $args['multiple'] ) {
82
+ $selected = selected( true, in_array( -1, $args['selected'] ), false );
83
+ } else {
84
+ $selected = selected( $args['selected'], -1, false );
85
+ }
86
+ $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
87
+ }
88
+
89
+ foreach( $args['options'] as $key => $option ) {
90
+
91
+ if( $args['multiple'] && is_array( $args['selected'] ) ) {
92
+ $selected = selected( true, in_array( $key, $args['selected'] ), false );
93
+ } else {
94
+ $selected = selected( $args['selected'], $key, false );
95
+ }
96
+
97
+ $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
98
+ }
99
+ }
100
+
101
+ $output .= '</select>';
102
+
103
+ return $output;
104
+ }
105
+
106
+ /**
107
+ * Renders an HTML Checkbox
108
+ *
109
+ * @since 0.9.0
110
+ *
111
+ * @param array $args
112
+ *
113
+ * @return string
114
+ */
115
+ public function checkbox( $args = array() ) {
116
+ $defaults = array(
117
+ 'name' => null,
118
+ 'current' => null,
119
+ 'class' => 'quads-checkbox',
120
+ 'value' => "1",
121
+ 'options' => array(
122
+ 'disabled' => false,
123
+ 'readonly' => false
124
+ )
125
+
126
+ );
127
+
128
+ $args = wp_parse_args( $args, $defaults );
129
+
130
+ $options = '';
131
+ if ( ! empty( $args['options']['disabled'] ) ) {
132
+ $options .= ' disabled="disabled"';
133
+ } elseif ( ! empty( $args['options']['readonly'] ) ) {
134
+ $options .= ' readonly';
135
+ }
136
+
137
+ $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '"' . checked( $args['value'], $args['current'], false ) .' value="1" />';
138
+
139
+ return $output;
140
+ }
141
+
142
+ /**
143
+ * Renders an HTML Text field
144
+ *
145
+ * @since 0.9.0
146
+ *
147
+ * @param array $args Arguments for the text field
148
+ * @return string Text field
149
+ */
150
+ public function text( $args = array() ) {
151
+ // Backwards compatabliity
152
+ if ( func_num_args() > 1 ) {
153
+ $args = func_get_args();
154
+
155
+ $name = $args[0];
156
+ $value = isset( $args[1] ) ? $args[1] : '';
157
+ $label = isset( $args[2] ) ? $args[2] : '';
158
+ $desc = isset( $args[3] ) ? $args[3] : '';
159
+ }
160
+
161
+ $defaults = array(
162
+ 'id' => '',
163
+ 'name' => isset( $name ) ? $name : 'text',
164
+ 'value' => isset( $value ) ? $value : null,
165
+ 'label' => isset( $label ) ? $label : null,
166
+ 'desc' => isset( $desc ) ? $desc : null,
167
+ 'placeholder' => '',
168
+ 'class' => isset( $args['class'] ) ? 'regular-text ' . $args['class'] : 'regular-text',
169
+ 'disabled' => false,
170
+ 'autocomplete' => '',
171
+ 'data' => false
172
+ );
173
+
174
+ $args = wp_parse_args( $args, $defaults );
175
+
176
+ $disabled = '';
177
+ if( $args['disabled'] ) {
178
+ $disabled = ' disabled="disabled"';
179
+ }
180
+
181
+ $data = '';
182
+ if ( ! empty( $args['data'] ) ) {
183
+ foreach ( $args['data'] as $key => $value ) {
184
+ $data .= 'data-' . $key . '="' . $value . '" ';
185
+ }
186
+ }
187
+
188
+ $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
189
+
190
+ $output .= '<label class="quads-label" for="' . sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
191
+
192
+ if ( ! empty( $args['desc'] ) ) {
193
+ $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
194
+ }
195
+
196
+ $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
197
+
198
+ $output .= '</span>';
199
+
200
+ return $output;
201
+ }
202
+ /**
203
+ * Renders a date picker
204
+ *
205
+ * @since 0.9.0
206
+ *
207
+ * @param array $args Arguments for the text field
208
+ * @return string Datepicker field
209
+ */
210
+ public function date_field( $args = array() ) {
211
+
212
+ if( empty( $args['class'] ) ) {
213
+ $args['class'] = 'quads_datepicker';
214
+ } elseif( ! strpos( $args['class'], 'quads_datepicker' ) ) {
215
+ $args['class'] .= ' quads_datepicker';
216
+ }
217
+
218
+ return $this->text( $args );
219
+ }
220
+
221
+ /**
222
+ * Renders an HTML textarea
223
+ *
224
+ * @since 0.9.0
225
+ *
226
+ * @param array $args Arguments for the textarea
227
+ * @return string textarea
228
+ */
229
+ public function textarea( $args = array() ) {
230
+ $defaults = array(
231
+ 'name' => 'textarea',
232
+ 'value' => null,
233
+ 'label' => null,
234
+ 'desc' => null,
235
+ 'class' => 'large-text',
236
+ 'disabled' => false,
237
+ 'placeholder' => '',
238
+
239
+ );
240
+
241
+ $args = wp_parse_args( $args, $defaults );
242
+
243
+ $disabled = '';
244
+ if( $args['disabled'] ) {
245
+ $disabled = ' disabled="disabled"';
246
+ }
247
+
248
+ $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
249
+
250
+ $output .= '<label class="quads-label" for="quads-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
251
+
252
+ $output .= '<textarea placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
253
+
254
+ if ( ! empty( $args['desc'] ) ) {
255
+ $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
256
+ }
257
+
258
+ $output .= '</span>';
259
+
260
+ return $output;
261
+ }
262
+
263
+
264
+ /**
265
+ * Renders an HTML Dropdown of years
266
+ *
267
+ * @access public
268
+ * @since 0.9.0
269
+ * @param string $name Name attribute of the dropdown
270
+ * @param int $selected Year to select automatically
271
+ * @param int $years_before Number of years before the current year the dropdown should start with
272
+ * @param int $years_after Number of years after the current year the dropdown should finish at
273
+ * @return string $output Year dropdown
274
+ */
275
+ public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
276
+ $current = date( 'Y' );
277
+ $start_year = $current - absint( $years_before );
278
+ $end_year = $current + absint( $years_after );
279
+ $selected = empty( $selected ) ? date( 'Y' ) : $selected;
280
+ $options = array();
281
+
282
+ while ( $start_year <= $end_year ) {
283
+ $options[ absint( $start_year ) ] = $start_year;
284
+ $start_year++;
285
+ }
286
+
287
+ $output = $this->select( array(
288
+ 'name' => $name,
289
+ 'selected' => $selected,
290
+ 'options' => $options,
291
+ 'show_option_all' => false,
292
+ 'show_option_none' => false
293
+ ) );
294
+
295
+ return $output;
296
+ }
297
+
298
+ /**
299
+ * Renders an HTML Dropdown of months
300
+ *
301
+ * @access public
302
+ * @since 0.9.0
303
+ * @param string $name Name attribute of the dropdown
304
+ * @param int $selected Month to select automatically
305
+ * @return string $output Month dropdown
306
+ */
307
+ public function month_dropdown( $name = 'month', $selected = 0 ) {
308
+ $month = 1;
309
+ $options = array();
310
+ $selected = empty( $selected ) ? date( 'n' ) : $selected;
311
+
312
+ while ( $month <= 12 ) {
313
+ $options[ absint( $month ) ] = quads_month_num_to_name( $month );
314
+ $month++;
315
+ }
316
+
317
+ $output = $this->select( array(
318
+ 'name' => $name,
319
+ 'selected' => $selected,
320
+ 'options' => $options,
321
+ 'show_option_all' => false,
322
+ 'show_option_none' => false
323
+ ) );
324
+
325
+ return $output;
326
+ }
327
+
328
+ }
includes/class-template.php CHANGED
@@ -1,45 +1,45 @@
1
- <?php
2
-
3
- namespace wpquads;
4
-
5
- /*
6
- * Class for rendering templates
7
- */
8
-
9
- class template {
10
- protected $path, $data;
11
-
12
- /**
13
- *
14
- * @param string $path
15
- * @param array $data
16
- */
17
- public function __construct($path, $data = array()) {
18
- $this->path = QUADS_PLUGIN_DIR . DIRECTORY_SEPARATOR . $path . '.php';
19
- $this->data = $data;
20
- }
21
-
22
- /**
23
- *
24
- * @return string HTML
25
- */
26
- public function render() {
27
- if(file_exists($this->path)){
28
- //Extracts vars to current view scope
29
- extract($this->data);
30
-
31
- //Starts output buffering
32
- ob_start();
33
-
34
- //Includes contents
35
- include $this->path;
36
- $buffer = ob_get_contents();
37
- @ob_end_clean();
38
-
39
- //Returns output buffer
40
- return $buffer;
41
- } else {
42
- //Throws exception
43
- }
44
- }
45
- }
1
+ <?php
2
+
3
+ namespace wpquads;
4
+
5
+ /*
6
+ * Class for rendering templates
7
+ */
8
+
9
+ class template {
10
+ protected $path, $data;
11
+
12
+ /**
13
+ *
14
+ * @param string $path
15
+ * @param array $data
16
+ */
17
+ public function __construct($path, $data = array()) {
18
+ $this->path = QUADS_PLUGIN_DIR . DIRECTORY_SEPARATOR . $path . '.php';
19
+ $this->data = $data;
20
+ }
21
+
22
+ /**
23
+ *
24
+ * @return string HTML
25
+ */
26
+ public function render() {
27
+ if(file_exists($this->path)){
28
+ //Extracts vars to current view scope
29
+ extract($this->data);
30
+
31
+ //Starts output buffering
32
+ ob_start();
33
+
34
+ //Includes contents
35
+ include $this->path;
36
+ $buffer = ob_get_contents();
37
+ @ob_end_clean();
38
+
39
+ //Returns output buffer
40
+ return $buffer;
41
+ } else {
42
+ //Throws exception
43
+ }
44
+ }
45
+ }
includes/conditions.php CHANGED
@@ -1,255 +1,255 @@
1
- <?php
2
-
3
- /**
4
- * Conditions
5
- *
6
- * @package QUADS
7
- * @subpackage Functions/conditions
8
- * @copyright Copyright (c) 2016, René Hermenau
9
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
- * @since 1.2.8
11
- */
12
-
13
-
14
-
15
- /**
16
- * Global! Determine if ads are visible
17
- *
18
- * @global arr $quads_options
19
- * @param string $content
20
- * @since 0.9.4
21
- * @return boolean true when ads are shown
22
- */
23
- function quads_ad_is_allowed( $content = null ) {
24
- global $quads_options;
25
-
26
-
27
- // Never show ads in ajax calls
28
- if ( isset($quads_options['is_ajax']) && (defined('DOING_AJAX') && DOING_AJAX) ||
29
- (! empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) == 'xmlhttprequest' )
30
- )
31
- {
32
- /* it's an AJAX call */
33
- return false;
34
- }
35
-
36
- $hide_ads = apply_filters('quads_hide_ads', false);
37
-
38
- // User Roles check
39
- if(!quads_user_roles_permission()){
40
- return false;
41
- }
42
-
43
- // Frontpage check
44
- if (is_front_page() && isset( $quads_options['visibility']['AppHome'] ) ){
45
- return true;
46
- }
47
-
48
- if(
49
- (is_feed()) ||
50
- (is_search()) ||
51
- (is_404() ) ||
52
- (strpos( $content, '<!--NoAds-->' ) !== false) ||
53
- (strpos( $content, '<!--OffAds-->' ) !== false) ||
54
- (is_front_page() && !isset( $quads_options['visibility']['AppHome'] ) ) ||
55
- (is_category() && !(isset( $quads_options['visibility']['AppCate'] ) ) ) ||
56
- (is_archive() && !( isset( $quads_options['visibility']['AppArch'] ) ) ) ||
57
- (is_tag() && !( isset( $quads_options['visibility']['AppTags'] ) ) ) ||
58
- (!quads_post_type_allowed()) ||
59
- (is_user_logged_in() && ( isset( $quads_options['visibility']['AppLogg'] ) ) ) ||
60
- true === $hide_ads
61
- ) {
62
- return false;
63
- }
64
- // else
65
- return true;
66
- }
67
- /**
68
- * Global! Determine if widget ads are visible
69
- *
70
- * @global arr $quads_options
71
- * @param string $content
72
- * @since 0.9.4
73
- * @return boolean true when ads are shown
74
- */
75
- function quads_widget_ad_is_allowed( $content = null ) {
76
- global $quads_options;
77
-
78
-
79
- // Never show ads in ajax calls
80
- if ( isset($quads_options['is_ajax']) && (defined('DOING_AJAX') && DOING_AJAX) ||
81
- (! empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) == 'xmlhttprequest' )
82
- )
83
- {
84
- /* it's an AJAX call */
85
- return false;
86
- }
87
-
88
- $hide_ads = apply_filters('quads_hide_ads', false);
89
-
90
- // User Roles check
91
- if(!quads_user_roles_permission()){
92
- return false;
93
- }
94
-
95
- // Frontpage check
96
- if (is_front_page() && isset( $quads_options['visibility']['AppHome'] ) ){
97
- return true;
98
- }
99
-
100
- if(
101
- (is_feed()) ||
102
- (is_search()) ||
103
- (is_404() ) ||
104
- (strpos( $content, '<!--NoAds-->' ) !== false) ||
105
- (strpos( $content, '<!--OffAds-->' ) !== false) ||
106
- (is_category() && !(isset( $quads_options['visibility']['AppCate'] ) ) ) ||
107
- (is_archive() && !( isset( $quads_options['visibility']['AppArch'] ) ) ) ||
108
- (is_tag() && !( isset( $quads_options['visibility']['AppTags'] ) ) ) ||
109
- (!quads_post_type_allowed()) ||
110
- (is_user_logged_in() && ( isset( $quads_options['visibility']['AppLogg'] ) ) ) ||
111
- true === $hide_ads
112
- ) {
113
- return false;
114
- }
115
- // else
116
- return true;
117
- }
118
-
119
-
120
- /**
121
- * Check if Ad widgets are visible on homepage
122
- *
123
- * @since 0.9.7
124
- * return true when ad widgets are not visible on frontpage else false
125
- */
126
- function quads_hide_ad_widget_on_homepage(){
127
- global $quads_options;
128
-
129
- $is_active = isset($quads_options["visibility"]["AppSide"]) ? true : false;
130
-
131
- if( is_front_page() && $is_active ){
132
- return true;
133
- }
134
-
135
- return false;
136
-
137
- }
138
-
139
-
140
- /**
141
- * Get the total number of active ads
142
- *
143
- * @global int $visibleShortcodeAds
144
- * @global int $visibleContentAdsGlobal
145
- * @global int $ad_count_custom
146
- * @global int $ad_count_widget
147
- * @return int number of active ads
148
- */
149
- function quads_get_total_ad_count(){
150
- global $visibleShortcodeAds, $visibleContentAdsGlobal, $ad_count_custom, $ad_count_widget;
151
-
152
- $shortcode = isset($visibleShortcodeAds) ? (int)$visibleShortcodeAds : 0;
153
- $content = isset($visibleContentAdsGlobal) ? (int)$visibleContentAdsGlobal : 0;
154
- $custom = isset($ad_count_custom) ? (int)$ad_count_custom : 0;
155
- //$widget = isset($ad_count_widget) ? (int)$ad_count_widget : 0;
156
- $widget = quads_get_number_widget_ads();
157
-
158
- //wp_die($widget);
159
- //wp_die( $shortcode + $content + $custom + $widget);
160
- return $shortcode + $content + $custom + $widget;
161
- }
162
-
163
- /**
164
- * Check if the maximum amount of ads are reached
165
- *
166
- * @global arr $quads_options settings
167
- * @var int amount of ads to activate
168
-
169
- * @return bool true if max is reached
170
- */
171
-
172
- function quads_ad_reach_max_count(){
173
- global $quads_options;
174
-
175
- $maxads = isset($quads_options['maxads']) ? $quads_options['maxads'] : 100;
176
- $maxads = $maxads - quads_get_number_widget_ads();
177
-
178
- //echo 'Total ads: '. quads_get_total_ad_count() . ' maxads: '. $maxads . '<br>';
179
- //wp_die('Total ads: '. quads_get_total_ad_count() . ' maxads: '. $maxads . '<br>');
180
- if ( quads_get_total_ad_count() >= $maxads ){
181
- return true;
182
- }
183
- }
184
-
185
- /**
186
- * Increment count of active ads generated in the_content
187
- *
188
- * @global int $ad_count
189
- * @param type $ad_count
190
- * @return int amount of active ads in the_content
191
- */
192
- function quads_set_ad_count_content(){
193
- global $visibleContentAdsGlobal;
194
-
195
- $visibleContentAdsGlobal++;
196
- return $visibleContentAdsGlobal;
197
- }
198
-
199
- /**
200
- * Increment count of active ads generated with shortcodes
201
- *
202
- * @return int amount of active shortcode ads in the_content
203
- */
204
- function quads_set_ad_count_shortcode(){
205
- global $visibleShortcodeAds;
206
-
207
- $visibleShortcodeAds++;
208
- return $visibleShortcodeAds;
209
- }
210
-
211
- /**
212
- * Increment count of custom active ads
213
- *
214
- * @return int amount of active custom ads
215
- */
216
- function quads_set_ad_count_custom(){
217
- global $ad_count_custom;
218
-
219
- $ad_count_custom++;
220
- return $ad_count_custom;
221
- }
222
-
223
- /**
224
- * Increment count of active ads generated on widgets
225
- *
226
- * @return int amount of active widget ads
227
- * @deprecated since 1.4.1
228
- */
229
- function quads_set_ad_count_widget(){
230
- global $ad_count_widget;
231
-
232
- $ad_count_widget++;
233
- return $ad_count_widget;
234
- }
235
-
236
- /**
237
- * Check if AMP ads are disabled on a post via the post meta box settings
238
- *
239
- * @global obj $post
240
- * @return boolean true if its disabled
241
- */
242
- function quads_is_disabled_post_amp() {
243
- global $post;
244
-
245
- if(!is_singular()){
246
- return true;
247
- }
248
-
249
- $ad_settings = get_post_meta( $post->ID, '_quads_config_visibility', true );
250
-
251
- if( !empty( $ad_settings['OffAMP'] ) ) {
252
- return true;
253
- }
254
- return false;
255
- }
1
+ <?php
2
+
3
+ /**
4
+ * Conditions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/conditions
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.8
11
+ */
12
+
13
+
14
+
15
+ /**
16
+ * Global! Determine if ads are visible
17
+ *
18
+ * @global arr $quads_options
19
+ * @param string $content
20
+ * @since 0.9.4
21
+ * @return boolean true when ads are shown
22
+ */
23
+ function quads_ad_is_allowed( $content = null ) {
24
+ global $quads_options;
25
+
26
+
27
+ // Never show ads in ajax calls
28
+ if ( isset($quads_options['is_ajax']) && (defined('DOING_AJAX') && DOING_AJAX) ||
29
+ (! empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) == 'xmlhttprequest' )
30
+ )
31
+ {
32
+ /* it's an AJAX call */
33
+ return false;
34
+ }
35
+
36
+ $hide_ads = apply_filters('quads_hide_ads', false);
37
+
38
+ // User Roles check
39
+ if(!quads_user_roles_permission()){
40
+ return false;
41
+ }
42
+
43
+ // Frontpage check
44
+ if (is_front_page() && isset( $quads_options['visibility']['AppHome'] ) ){
45
+ return true;
46
+ }
47
+
48
+ if(
49
+ (is_feed()) ||
50
+ (is_search()) ||
51
+ (is_404() ) ||
52
+ (strpos( $content, '<!--NoAds-->' ) !== false) ||
53
+ (strpos( $content, '<!--OffAds-->' ) !== false) ||
54
+ (is_front_page() && !isset( $quads_options['visibility']['AppHome'] ) ) ||
55
+ (is_category() && !(isset( $quads_options['visibility']['AppCate'] ) ) ) ||
56
+ (is_archive() && !( isset( $quads_options['visibility']['AppArch'] ) ) ) ||
57
+ (is_tag() && !( isset( $quads_options['visibility']['AppTags'] ) ) ) ||
58
+ (!quads_post_type_allowed()) ||
59
+ (is_user_logged_in() && ( isset( $quads_options['visibility']['AppLogg'] ) ) ) ||
60
+ true === $hide_ads
61
+ ) {
62
+ return false;
63
+ }
64
+ // else
65
+ return true;
66
+ }
67
+ /**
68
+ * Global! Determine if widget ads are visible
69
+ *
70
+ * @global arr $quads_options
71
+ * @param string $content
72
+ * @since 0.9.4
73
+ * @return boolean true when ads are shown
74
+ */
75
+ function quads_widget_ad_is_allowed( $content = null ) {
76
+ global $quads_options;
77
+
78
+
79
+ // Never show ads in ajax calls
80
+ if ( isset($quads_options['is_ajax']) && (defined('DOING_AJAX') && DOING_AJAX) ||
81
+ (! empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) && strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) == 'xmlhttprequest' )
82
+ )
83
+ {
84
+ /* it's an AJAX call */
85
+ return false;
86
+ }
87
+
88
+ $hide_ads = apply_filters('quads_hide_ads', false);
89
+
90
+ // User Roles check
91
+ if(!quads_user_roles_permission()){
92
+ return false;
93
+ }
94
+
95
+ // Frontpage check
96
+ if (is_front_page() && isset( $quads_options['visibility']['AppHome'] ) ){
97
+ return true;
98
+ }
99
+
100
+ if(
101
+ (is_feed()) ||
102
+ (is_search()) ||
103
+ (is_404() ) ||
104
+ (strpos( $content, '<!--NoAds-->' ) !== false) ||
105
+ (strpos( $content, '<!--OffAds-->' ) !== false) ||
106
+ (is_category() && !(isset( $quads_options['visibility']['AppCate'] ) ) ) ||
107
+ (is_archive() && !( isset( $quads_options['visibility']['AppArch'] ) ) ) ||
108
+ (is_tag() && !( isset( $quads_options['visibility']['AppTags'] ) ) ) ||
109
+ (!quads_post_type_allowed()) ||
110
+ (is_user_logged_in() && ( isset( $quads_options['visibility']['AppLogg'] ) ) ) ||
111
+ true === $hide_ads
112
+ ) {
113
+ return false;
114
+ }
115
+ // else
116
+ return true;
117
+ }
118
+
119
+
120
+ /**
121
+ * Check if Ad widgets are visible on homepage
122
+ *
123
+ * @since 0.9.7
124
+ * return true when ad widgets are not visible on frontpage else false
125
+ */
126
+ function quads_hide_ad_widget_on_homepage(){
127
+ global $quads_options;
128
+
129
+ $is_active = isset($quads_options["visibility"]["AppSide"]) ? true : false;
130
+
131
+ if( is_front_page() && $is_active ){
132
+ return true;
133
+ }
134
+
135
+ return false;
136
+
137
+ }
138
+
139
+
140
+ /**
141
+ * Get the total number of active ads
142
+ *
143
+ * @global int $visibleShortcodeAds
144
+ * @global int $visibleContentAdsGlobal
145
+ * @global int $ad_count_custom
146
+ * @global int $ad_count_widget
147
+ * @return int number of active ads
148
+ */
149
+ function quads_get_total_ad_count(){
150
+ global $visibleShortcodeAds, $visibleContentAdsGlobal, $ad_count_custom, $ad_count_widget;
151
+
152
+ $shortcode = isset($visibleShortcodeAds) ? (int)$visibleShortcodeAds : 0;
153
+ $content = isset($visibleContentAdsGlobal) ? (int)$visibleContentAdsGlobal : 0;
154
+ $custom = isset($ad_count_custom) ? (int)$ad_count_custom : 0;
155
+ //$widget = isset($ad_count_widget) ? (int)$ad_count_widget : 0;
156
+ $widget = quads_get_number_widget_ads();
157
+
158
+ //wp_die($widget);
159
+ //wp_die( $shortcode + $content + $custom + $widget);
160
+ return $shortcode + $content + $custom + $widget;
161
+ }
162
+
163
+ /**
164
+ * Check if the maximum amount of ads are reached
165
+ *
166
+ * @global arr $quads_options settings
167
+ * @var int amount of ads to activate
168
+
169
+ * @return bool true if max is reached
170
+ */
171
+
172
+ function quads_ad_reach_max_count(){
173
+ global $quads_options;
174
+
175
+ $maxads = isset($quads_options['maxads']) ? $quads_options['maxads'] : 100;
176
+ $maxads = $maxads - quads_get_number_widget_ads();
177
+
178
+ //echo 'Total ads: '. quads_get_total_ad_count() . ' maxads: '. $maxads . '<br>';
179
+ //wp_die('Total ads: '. quads_get_total_ad_count() . ' maxads: '. $maxads . '<br>');
180
+ if ( quads_get_total_ad_count() >= $maxads ){
181
+ return true;
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Increment count of active ads generated in the_content
187
+ *
188
+ * @global int $ad_count
189
+ * @param type $ad_count
190
+ * @return int amount of active ads in the_content
191
+ */
192
+ function quads_set_ad_count_content(){
193
+ global $visibleContentAdsGlobal;
194
+
195
+ $visibleContentAdsGlobal++;
196
+ return $visibleContentAdsGlobal;
197
+ }
198
+
199
+ /**
200
+ * Increment count of active ads generated with shortcodes
201
+ *
202
+ * @return int amount of active shortcode ads in the_content
203
+ */
204
+ function quads_set_ad_count_shortcode(){
205
+ global $visibleShortcodeAds;
206
+
207
+ $visibleShortcodeAds++;
208
+ return $visibleShortcodeAds;
209
+ }
210
+
211
+ /**
212
+ * Increment count of custom active ads
213
+ *
214
+ * @return int amount of active custom ads
215
+ */
216
+ function quads_set_ad_count_custom(){
217
+ global $ad_count_custom;
218
+
219
+ $ad_count_custom++;
220
+ return $ad_count_custom;
221
+ }
222
+
223
+ /**
224
+ * Increment count of active ads generated on widgets
225
+ *
226
+ * @return int amount of active widget ads
227
+ * @deprecated since 1.4.1
228
+ */
229
+ function quads_set_ad_count_widget(){
230
+ global $ad_count_widget;
231
+
232
+ $ad_count_widget++;
233
+ return $ad_count_widget;
234
+ }
235
+
236
+ /**
237
+ * Check if AMP ads are disabled on a post via the post meta box settings
238
+ *
239
+ * @global obj $post
240
+ * @return boolean true if its disabled
241
+ */
242
+ function quads_is_disabled_post_amp() {
243
+ global $post;
244
+
245
+ if(!is_singular()){
246
+ return true;
247
+ }
248
+
249
+ $ad_settings = get_post_meta( $post->ID, '_quads_config_visibility', true );
250
+
251
+ if( !empty( $ad_settings['OffAMP'] ) ) {
252
+ return true;
253
+ }
254
+ return false;
255
+ }
includes/post_types.php CHANGED
@@ -1,52 +1,52 @@
1
- <?php
2
-
3
- /**
4
- * Post Types
5
- *
6
- * @package QUADS
7
- * @subpackage Functions/post_types
8
- * @copyright Copyright (c) 2016, René Hermenau
9
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
- * @since 1.2.8
11
- */
12
-
13
-
14
-
15
- /**
16
- * Get list of available post_types
17
- *
18
- * @return array list of post_types
19
- */
20
- function quads_get_post_types(){
21
- $post_types = array('post'=>'post', 'page'=>'page');
22
- return apply_filters('quads_post_types',$post_types);
23
- }
24
-
25
- /**
26
- * Check if ad is allowed on specific post_type
27
- *
28
- * @global array $quads_options
29
- * @global array $post
30
- * @return boolean true if post_type is allowed
31
- */
32
- function quads_post_type_allowed(){
33
- global $quads_options, $post;
34
-
35
- $return = false;
36
-
37
- if (!isset($post)){
38
- $return = false;
39
- return apply_filters('quads_post_type_allowed',$return);
40
- }
41
-
42
- if (!isset($quads_options['post_types']) || !is_array($quads_options['post_types']) || empty($quads_options['post_types'])){
43
- $return = false;
44
- return apply_filters('quads_post_type_allowed',$return);
45
- }
46
-
47
- $current_post_type = get_post_type($post->ID);
48
- if ( in_array( $current_post_type, $quads_options['post_types'] )){
49
- $return = true;
50
- }
51
- return apply_filters('quads_post_type_allowed',$return);
52
  }
1
+ <?php
2
+
3
+ /**
4
+ * Post Types
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/post_types
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.8
11
+ */
12
+
13
+
14
+
15
+ /**
16
+ * Get list of available post_types
17
+ *
18
+ * @return array list of post_types
19
+ */
20
+ function quads_get_post_types(){
21
+ $post_types = array('post'=>'post', 'page'=>'page');
22
+ return apply_filters('quads_post_types',$post_types);
23
+ }
24
+
25
+ /**
26
+ * Check if ad is allowed on specific post_type
27
+ *
28
+ * @global array $quads_options
29
+ * @global array $post
30
+ * @return boolean true if post_type is allowed
31
+ */
32
+ function quads_post_type_allowed(){
33
+ global $quads_options, $post;
34
+
35
+ $return = false;
36
+
37
+ if (!isset($post)){
38
+ $return = false;
39
+ return apply_filters('quads_post_type_allowed',$return);
40
+ }
41
+
42
+ if (!isset($quads_options['post_types']) || !is_array($quads_options['post_types']) || empty($quads_options['post_types'])){
43
+ $return = false;
44
+ return apply_filters('quads_post_type_allowed',$return);
45
+ }
46
+
47
+ $current_post_type = get_post_type($post->ID);
48
+ if ( in_array( $current_post_type, $quads_options['post_types'] )){
49
+ $return = true;
50
+ }
51
+ return apply_filters('quads_post_type_allowed',$return);
52
  }
includes/scripts.php CHANGED
@@ -1,316 +1,316 @@
1
- <?php
2
- /**
3
- * Scripts
4
- *
5
- * @package QUADS
6
- * @subpackage Functions
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
- // Exit if accessed directly
12
- if( !defined( 'ABSPATH' ) )
13
- exit;
14
-
15
- //add_action( 'wp_enqueue_scripts', 'quads_register_styles', 10 );
16
- add_action( 'wp_print_styles', 'quads_inline_styles', 9999 );
17
-
18
- add_action( 'admin_enqueue_scripts', 'quads_load_admin_scripts', 100 );
19
- add_action( 'admin_enqueue_scripts', 'quads_load_plugins_admin_scripts', 100 );
20
- add_action( 'admin_enqueue_scripts', 'quads_load_all_admin_scripts', 100 );
21
- add_action( 'admin_print_footer_scripts', 'quads_check_ad_blocker' );
22
-
23
- /**
24
- * Create ad blocker admin script
25
- *
26
- * @return mixed boolean | string
27
- */
28
- function quads_check_ad_blocker() {
29
- if( !quads_is_admin_page() ) {
30
- return false;
31
- }
32
- ?>
33
- <script type="text/javascript">
34
- window.onload = function(){
35
- if (typeof wpquads_adblocker_check === 'undefined' || false === wpquads_adblocker_check) {
36
- if (document.getElementById('wpquads-adblock-notice')){
37
- document.getElementById('wpquads-adblock-notice').style.display = 'block';
38
- console.log('adblocker detected');
39
- }
40
- }
41
- }
42
- </script>
43
- <?php
44
- }
45
-
46
- /**
47
- * Load Admin Scripts
48
- *
49
- * Enqueues the required admin scripts.
50
- *
51
- * @since 1.0
52
- * @global $post
53
- * @param string $hook Page hook
54
- * @return void
55
- */
56
- function quads_load_admin_scripts( $hook ) {
57
- if( !apply_filters( 'quads_load_admin_scripts', quads_is_admin_page(), $hook ) ) {
58
- return;
59
- }
60
- global $wp_version, $quads;
61
-
62
- $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
63
- $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
64
-
65
- // Use minified libraries if SCRIPT_DEBUG is turned off
66
- $suffix = ( quadsIsDebugMode() ) ? '' : '.min';
67
-
68
-
69
- // These have to be global
70
- wp_enqueue_script( 'quads-admin-ads', $js_dir . 'ads.js', array('jquery'), QUADS_VERSION, false );
71
- wp_enqueue_script( 'quads-admin-scripts', $js_dir . 'quads-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
72
- wp_enqueue_script( 'quads-jscolor', $js_dir . 'jscolor' . $suffix . '.js', array(), QUADS_VERSION, false );
73
- wp_enqueue_script( 'jquery-chosen', $js_dir . 'chosen.jquery' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
74
- wp_enqueue_script( 'jquery-form' );
75
-
76
- $vi_dir = QUADS_PLUGIN_URL . 'includes/vendor/vi/public/js/';
77
- wp_enqueue_script( 'quads-vi', $vi_dir . 'vi.js', array(), QUADS_VERSION, false );
78
-
79
-
80
- wp_enqueue_style( 'quads-admin', $css_dir . 'quads-admin' . $suffix . '.css', QUADS_VERSION );
81
- wp_enqueue_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', QUADS_VERSION );
82
-
83
- $signupURL = $quads->vi->getSettings()->data->signupURL;
84
-
85
- wp_localize_script( 'quads-admin-scripts', 'quads', array(
86
- 'nonce' => wp_create_nonce( 'quads_ajax_nonce' ),
87
- 'error' => __( "error", 'quick-adsense-reloaded' ),
88
- 'path' => get_option( 'siteurl' ),
89
- 'vi_revenue' => !empty( $quads->vi->getRevenue()->mtdReport ) ? $quads->vi->getRevenue()->mtdReport : '',
90
- 'vi_login_url' => $quads->vi->getLoginURL(),
91
- 'vi_signup_url' => !empty( $signupURL ) ? $signupURL : '',
92
- 'domain' => $quads->vi->getDomain(),
93
- 'email' => get_option( 'admin_email' ),
94
- 'aid' => 'WP_Quads'
95
- ) );
96
- }
97
-
98
- /**
99
- * Load Admin Scripts available on plugins page
100
- *
101
- * Enqueues the required admin scripts.
102
- *
103
- * @since 1.0
104
- * @global $post
105
- * @param string $hook Page hook
106
- * @return void
107
- */
108
- function quads_load_plugins_admin_scripts( $hook ) {
109
- if( !apply_filters( 'quads_load_plugins_admin_scripts', quads_is_plugins_page(), $hook ) ) {
110
- return;
111
- }
112
-
113
- $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
114
- $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
115
-
116
- // Use minified libraries if SCRIPT_DEBUG is turned off
117
- $suffix = ( quadsIsDebugMode() ) ? '' : '.min';
118
-
119
- wp_enqueue_script( 'quads-plugins-admin-scripts', $js_dir . 'quads-plugins-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
120
- wp_enqueue_style( 'quads-plugins-admin', $css_dir . 'quads-plugins-admin' . $suffix . '.css', QUADS_VERSION );
121
- }
122
-
123
- /**
124
- * Load Admin Scripts available on all admin pages
125
- *
126
- * Enqueues the required admin scripts.
127
- *
128
- * @since 1.6.1
129
- * @global $post
130
- * @param string $hook Page hook
131
- * @return void
132
- */
133
- function quads_load_all_admin_scripts( $hook ) {
134
-
135
-
136
- $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
137
-
138
- wp_enqueue_style( 'quads-admin-all', $css_dir . 'quads-admin-all.css', QUADS_VERSION );
139
- }
140
-
141
- /**
142
- * Create Gutenberg block
143
- */
144
- //function quads_load_blocks() {
145
- // $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
146
- //
147
- // wp_register_script( 'wpquads', $js_dir . 'blocks.js', array('wp-blocks', 'wp-element', 'wp-editor') );
148
- //
149
- // register_block_type( 'wpquads/blocks', array(
150
- // 'editor_script' => 'wpquads',
151
- // ) );
152
- //}
153
- //
154
- //add_action( 'init', 'quads_load_blocks' );
155
-
156
-
157
- /**
158
- * Register CSS Styles
159
- *
160
- * Checks the styles option and hooks the required filter.
161
- *
162
- * @since 1.0
163
- * @global $mashsb_options
164
- * @return void
165
- */
166
- //function quads_register_styles( $hook ) {
167
- // global $quads_options;
168
- //
169
- // // Register empty quads.css to be able to register quads_inline_styles()
170
- // //$url = QUADS_PLUGIN_URL . 'assets/css/quads.css';
171
- //
172
- // //wp_enqueue_style( 'quads-styles', $url, array(), QUADS_VERSION );
173
- // wp_enqueue_style( 'quads-styles', false );
174
- //}
175
-
176
- /**
177
- * Add dynamic CSS to write media queries for removing unwanted ads without the need to use any cache busting method
178
- * (Cache busting could affect performance and lead to lot of support tickets so lets follow the css approach)
179
- *
180
- * @since 1.0
181
- * @global1 array options
182
- * @global2 $quads_css dynamic build css
183
- *
184
- * @return string
185
- */
186
- function quads_inline_styles() {
187
- global $quads_options;
188
-
189
- $css = '';
190
-
191
- if( isset( $quads_options['ads'] ) ) {
192
- foreach ( $quads_options['ads'] as $key => $value ) {
193
- $css .= quads_render_media_query( $key, $value );
194
- }
195
- }
196
- // Register empty style so we do not need an external css file
197
- wp_register_style( 'quads-styles', false );
198
- // Enque empty style
199
- wp_enqueue_style( 'quads-styles' );
200
- // Add inline css to that style
201
- wp_add_inline_style( 'quads-styles', $css );
202
- }
203
-
204
- /**
205
- * Render Media Queries
206
- *
207
- * @param string $key
208
- * @param string $value
209
- * @return string
210
- */
211
- function quads_render_media_query( $key, $value ) {
212
- $lic = get_option( 'quads_wp_quads_pro_license_active' );
213
- if( !$lic || (is_object( $lic ) && $lic->success !== true) ) {
214
- return '';
215
- }
216
-
217
- $html = '';
218
-
219
- if( isset( $value['desktop'] ) ) {
220
- //$html .= '/* Hide on desktop */';
221
- $html .= '@media only screen and (min-width:1140px){#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
222
- }
223
- if( isset( $value['tablet_landscape'] ) ) {
224
- //$html .= '/* Hide on tablet landscape */';
225
- $html .= '@media only screen and (min-width:1024px) and (max-width:1140px) {#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
226
- }
227
- if( isset( $value['tablet_portrait'] ) ) {
228
- //$html .= '/* Hide on tablet portrait */';
229
- $html .= '@media only screen and (min-width:768px) and (max-width:1023px){#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
230
- }
231
- if( isset( $value['phone'] ) ) {
232
- //$html .= '/* Hide on mobile device */';
233
- $html .= '@media only screen and (max-width:767px){#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
234
- }
235
-
236
- return $html;
237
- }
238
-
239
- /*
240
- * Check if debug mode is enabled
241
- *
242
- * @since 0.9.0
243
- * @return bool true if Mashshare debug mode is on
244
- */
245
-
246
- function quadsIsDebugMode() {
247
- global $quads_options;
248
-
249
- $debug_mode = isset( $quads_options['debug_mode'] ) ? true : false;
250
- return $debug_mode;
251
- }
252
-
253
- /**
254
- * Create ad buttons for editor
255
- *
256
- * @author Tedd Garland, René Hermenau
257
- * @since 0.9.0
258
- */
259
- $wpvcomp = ( bool ) (version_compare( get_bloginfo( 'version' ), '3.1', '>=' ));
260
-
261
- function quads_ads_head_script() {
262
- global $quads_options, $wpvcomp;
263
-
264
- if( isset( $quads_options['quicktags']['QckTags'] ) ) {
265
- ?>
266
- <script type="text/javascript">
267
- wpvcomp = <?php echo (($wpvcomp == 1) ? "true " : "false"); ?>;
268
- edaddID = new Array();
269
- edaddNm = new Array();
270
- if (typeof (edButtons) != 'undefined') { edadd = edButtons.length;
271
- var dynads = {"all":[
272
- <?php
273
- for ( $i = 1; $i <= count( quads_get_ads() ) - 1; $i++ ) {
274
- if( isset( $quads_options['ads']['ad' . $i]['code'] ) && $quads_options['ads']['ad' . $i]['code'] != '' ) {
275
- echo('"1",');
276
- } else {
277
- echo('"0",');
278
- };
279
- }
280
- ?>
281
- "0"] };
282
- for (i = 1; i <=<?php echo count( quads_get_ads() ) - 1; ?>; i++) {
283
- if (dynads.all[ i - 1 ] == "1") {
284
- edButtons [edButtons.length] = new edButton("ads" + i.toString(), " Ads" + i.toString(), "\n<!--Ads"+i.toString()+"-->\n", "", "", - 1);
285
- edaddID[edaddID.length] = " ads" + i.toString();
286
- edaddNm[edaddNm.length] = "Ads" + i.toString();
287
- }
288
- }
289
- <?php if( !isset( $quads_options['quicktags']['QckRnds'] ) ) { ?>
290
- edButtons[edButtons.length] = new edButton("random_ads", " RndAds", "\n<!--RndAds-->\n", "", "", - 1);
291
- edaddID[edaddID.length] = "random_ads";
292
- edaddNm[edaddNm.length] = "RndAds";
293
- <?php } ?>
294
- edButtons[edButtons.length] = new edButton("no_ads", "NoAds", "\n<!--NoAds-->\n","","",-1);
295
- edaddID[edaddID.length] = "no_ads";
296
- edaddNm[edaddNm.length] = "NoAds";
297
- };
298
- (function(){
299
- if(typeof(edButtons)!='undefined' && typeof(jQuery)!='undefined' && wpvcomp){
300
- jQuery(document).ready(function(){
301
- for(i=0;i<edaddID.length;i++) {
302
- jQuery("#ed_toolbar").append('<input type="button" value="' + edaddNm[i] +'" id="' + edaddID[i] +'" class="ed_button" onclick="edInsertTag(edCanvas, ' + (edadd+i) + ');" title="' + edaddNm[i] +'" />');
303
- }
304
- });
305
- }
306
- }());
307
- </script>
308
- <?php
309
- }
310
- }
311
-
312
- if( $wpvcomp ) {
313
- add_action( 'admin_print_footer_scripts', 'quads_ads_head_script' );
314
- } else {
315
- add_action( 'admin_head', 'quads_ads_head_javascript_script' );
316
- }
1
+ <?php
2
+ /**
3
+ * Scripts
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Functions
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
+ // Exit if accessed directly
12
+ if( !defined( 'ABSPATH' ) )
13
+ exit;
14
+
15
+ //add_action( 'wp_enqueue_scripts', 'quads_register_styles', 10 );
16
+ add_action( 'wp_print_styles', 'quads_inline_styles', 9999 );
17
+
18
+ add_action( 'admin_enqueue_scripts', 'quads_load_admin_scripts', 100 );
19
+ add_action( 'admin_enqueue_scripts', 'quads_load_plugins_admin_scripts', 100 );
20
+ add_action( 'admin_enqueue_scripts', 'quads_load_all_admin_scripts', 100 );
21
+ add_action( 'admin_print_footer_scripts', 'quads_check_ad_blocker' );
22
+
23
+ /**
24
+ * Create ad blocker admin script
25
+ *
26
+ * @return mixed boolean | string
27
+ */
28
+ function quads_check_ad_blocker() {
29
+ if( !quads_is_admin_page() ) {
30
+ return false;
31
+ }
32
+ ?>
33
+ <script type="text/javascript">
34
+ window.onload = function(){
35
+ if (typeof wpquads_adblocker_check === 'undefined' || false === wpquads_adblocker_check) {
36
+ if (document.getElementById('wpquads-adblock-notice')){
37
+ document.getElementById('wpquads-adblock-notice').style.display = 'block';
38
+ console.log('adblocker detected');
39
+ }
40
+ }
41
+ }
42
+ </script>
43
+ <?php
44
+ }
45
+
46
+ /**
47
+ * Load Admin Scripts
48
+ *
49
+ * Enqueues the required admin scripts.
50
+ *
51
+ * @since 1.0
52
+ * @global $post
53
+ * @param string $hook Page hook
54
+ * @return void
55
+ */
56
+ function quads_load_admin_scripts( $hook ) {
57
+ if( !apply_filters( 'quads_load_admin_scripts', quads_is_admin_page(), $hook ) ) {
58
+ return;
59
+ }
60
+ global $wp_version, $quads;
61
+
62
+ $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
63
+ $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
64
+
65
+ // Use minified libraries if SCRIPT_DEBUG is turned off
66
+ $suffix = ( quadsIsDebugMode() ) ? '' : '.min';
67
+
68
+
69
+ // These have to be global
70
+ wp_enqueue_script( 'quads-admin-ads', $js_dir . 'ads.js', array('jquery'), QUADS_VERSION, false );
71
+ wp_enqueue_script( 'quads-admin-scripts', $js_dir . 'quads-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
72
+ wp_enqueue_script( 'quads-jscolor', $js_dir . 'jscolor' . $suffix . '.js', array(), QUADS_VERSION, false );
73
+ wp_enqueue_script( 'jquery-chosen', $js_dir . 'chosen.jquery' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
74
+ wp_enqueue_script( 'jquery-form' );
75
+
76
+ $vi_dir = QUADS_PLUGIN_URL . 'includes/vendor/vi/public/js/';
77
+ wp_enqueue_script( 'quads-vi', $vi_dir . 'vi.js', array(), QUADS_VERSION, false );
78
+
79
+
80
+ wp_enqueue_style( 'quads-admin', $css_dir . 'quads-admin' . $suffix . '.css', QUADS_VERSION );
81
+ wp_enqueue_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', QUADS_VERSION );
82
+
83
+ $signupURL = $quads->vi->getSettings()->data->signupURL;
84
+
85
+ wp_localize_script( 'quads-admin-scripts', 'quads', array(
86
+ 'nonce' => wp_create_nonce( 'quads_ajax_nonce' ),
87
+ 'error' => __( "error", 'quick-adsense-reloaded' ),
88
+ 'path' => get_option( 'siteurl' ),
89
+ 'vi_revenue' => !empty( $quads->vi->getRevenue()->mtdReport ) ? $quads->vi->getRevenue()->mtdReport : '',
90
+ 'vi_login_url' => $quads->vi->getLoginURL(),
91
+ 'vi_signup_url' => !empty( $signupURL ) ? $signupURL : '',
92
+ 'domain' => $quads->vi->getDomain(),
93
+ 'email' => get_option( 'admin_email' ),
94
+ 'aid' => 'WP_Quads'
95
+ ) );
96
+ }
97
+
98
+ /**
99
+ * Load Admin Scripts available on plugins page
100
+ *
101
+ * Enqueues the required admin scripts.
102
+ *
103
+ * @since 1.0
104
+ * @global $post
105
+ * @param string $hook Page hook
106
+ * @return void
107
+ */
108
+ function quads_load_plugins_admin_scripts( $hook ) {
109
+ if( !apply_filters( 'quads_load_plugins_admin_scripts', quads_is_plugins_page(), $hook ) ) {
110
+ return;
111
+ }
112
+
113
+ $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
114
+ $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
115
+
116
+ // Use minified libraries if SCRIPT_DEBUG is turned off
117
+ $suffix = ( quadsIsDebugMode() ) ? '' : '.min';
118
+
119
+ wp_enqueue_script( 'quads-plugins-admin-scripts', $js_dir . 'quads-plugins-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
120
+ wp_enqueue_style( 'quads-plugins-admin', $css_dir . 'quads-plugins-admin' . $suffix . '.css', QUADS_VERSION );
121
+ }
122
+
123
+ /**
124
+ * Load Admin Scripts available on all admin pages
125
+ *
126
+ * Enqueues the required admin scripts.
127
+ *
128
+ * @since 1.6.1
129
+ * @global $post
130
+ * @param string $hook Page hook
131
+ * @return void
132
+ */
133
+ function quads_load_all_admin_scripts( $hook ) {
134
+
135
+
136
+ $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
137
+
138
+ wp_enqueue_style( 'quads-admin-all', $css_dir . 'quads-admin-all.css', QUADS_VERSION );
139
+ }
140
+
141
+ /**
142
+ * Create Gutenberg block
143
+ */
144
+ //function quads_load_blocks() {
145
+ // $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
146
+ //
147
+ // wp_register_script( 'wpquads', $js_dir . 'blocks.js', array('wp-blocks', 'wp-element', 'wp-editor') );
148
+ //
149
+ // register_block_type( 'wpquads/blocks', array(
150
+ // 'editor_script' => 'wpquads',
151
+ // ) );
152
+ //}
153
+ //
154
+ //add_action( 'init', 'quads_load_blocks' );
155
+
156
+
157
+ /**
158
+ * Register CSS Styles
159
+ *
160
+ * Checks the styles option and hooks the required filter.
161
+ *
162
+ * @since 1.0
163
+ * @global $mashsb_options
164
+ * @return void
165
+ */
166
+ //function quads_register_styles( $hook ) {
167
+ // global $quads_options;
168
+ //
169
+ // // Register empty quads.css to be able to register quads_inline_styles()
170
+ // //$url = QUADS_PLUGIN_URL . 'assets/css/quads.css';
171
+ //
172
+ // //wp_enqueue_style( 'quads-styles', $url, array(), QUADS_VERSION );
173
+ // wp_enqueue_style( 'quads-styles', false );
174
+ //}
175
+
176
+ /**
177
+ * Add dynamic CSS to write media queries for removing unwanted ads without the need to use any cache busting method
178
+ * (Cache busting could affect performance and lead to lot of support tickets so lets follow the css approach)
179
+ *
180
+ * @since 1.0
181
+ * @global1 array options
182
+ * @global2 $quads_css dynamic build css
183
+ *
184
+ * @return string
185
+ */
186
+ function quads_inline_styles() {
187
+ global $quads_options;
188
+
189
+ $css = '';
190
+
191
+ if( isset( $quads_options['ads'] ) ) {
192
+ foreach ( $quads_options['ads'] as $key => $value ) {
193
+ $css .= quads_render_media_query( $key, $value );
194
+ }
195
+ }
196
+ // Register empty style so we do not need an external css file
197
+ wp_register_style( 'quads-styles', false );
198
+ // Enque empty style
199
+ wp_enqueue_style( 'quads-styles' );
200
+ // Add inline css to that style
201
+ wp_add_inline_style( 'quads-styles', $css );
202
+ }
203
+
204
+ /**
205
+ * Render Media Queries
206
+ *
207
+ * @param string $key
208
+ * @param string $value
209
+ * @return string
210
+ */
211
+ function quads_render_media_query( $key, $value ) {
212
+ $lic = get_option( 'quads_wp_quads_pro_license_active' );
213
+ if( !$lic || (is_object( $lic ) && $lic->success !== true) ) {
214
+ return '';
215
+ }
216
+
217
+ $html = '';
218
+
219
+ if( isset( $value['desktop'] ) ) {
220
+ //$html .= '/* Hide on desktop */';
221
+ $html .= '@media only screen and (min-width:1140px){#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
222
+ }
223
+ if( isset( $value['tablet_landscape'] ) ) {
224
+ //$html .= '/* Hide on tablet landscape */';
225
+ $html .= '@media only screen and (min-width:1024px) and (max-width:1140px) {#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
226
+ }
227
+ if( isset( $value['tablet_portrait'] ) ) {
228
+ //$html .= '/* Hide on tablet portrait */';
229
+ $html .= '@media only screen and (min-width:768px) and (max-width:1023px){#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
230
+ }
231
+ if( isset( $value['phone'] ) ) {
232
+ //$html .= '/* Hide on mobile device */';
233
+ $html .= '@media only screen and (max-width:767px){#quads-' . $key . ', .quads-' . $key . ' {display:none;}}' . "\n";
234
+ }
235
+
236
+ return $html;
237
+ }
238
+
239
+ /*
240
+ * Check if debug mode is enabled
241
+ *
242
+ * @since 0.9.0
243
+ * @return bool true if Mashshare debug mode is on
244
+ */
245
+
246
+ function quadsIsDebugMode() {
247
+ global $quads_options;
248
+
249
+ $debug_mode = isset( $quads_options['debug_mode'] ) ? true : false;
250
+ return $debug_mode;
251
+ }
252
+
253
+ /**
254
+ * Create ad buttons for editor
255
+ *
256
+ * @author Tedd Garland, René Hermenau
257
+ * @since 0.9.0
258
+ */
259
+ $wpvcomp = ( bool ) (version_compare( get_bloginfo( 'version' ), '3.1', '>=' ));
260
+
261
+ function quads_ads_head_script() {
262
+ global $quads_options, $wpvcomp;
263
+
264
+ if( isset( $quads_options['quicktags']['QckTags'] ) ) {
265
+ ?>
266
+ <script type="text/javascript">
267
+ wpvcomp = <?php echo (($wpvcomp == 1) ? "true " : "false"); ?>;
268
+ edaddID = new Array();
269
+ edaddNm = new Array();
270
+ if (typeof (edButtons) != 'undefined') { edadd = edButtons.length;
271
+ var dynads = {"all":[
272
+ <?php
273
+ for ( $i = 1; $i <= count( quads_get_ads() ) - 1; $i++ ) {
274
+ if( isset( $quads_options['ads']['ad' . $i]['code'] ) && $quads_options['ads']['ad' . $i]['code'] != '' ) {
275
+ echo('"1",');
276
+ } else {
277
+ echo('"0",');
278
+ };
279
+ }
280
+ ?>
281
+ "0"] };
282
+ for (i = 1; i <=<?php echo count( quads_get_ads() ) - 1; ?>; i++) {
283
+ if (dynads.all[ i - 1 ] == "1") {
284
+ edButtons [edButtons.length] = new edButton("ads" + i.toString(), " Ads" + i.toString(), "\n<!--Ads"+i.toString()+"-->\n", "", "", - 1);
285
+ edaddID[edaddID.length] = " ads" + i.toString();
286
+ edaddNm[edaddNm.length] = "Ads" + i.toString();
287
+ }
288
+ }
289
+ <?php if( !isset( $quads_options['quicktags']['QckRnds'] ) ) { ?>
290
+ edButtons[edButtons.length] = new edButton("random_ads", " RndAds", "\n<!--RndAds-->\n", "", "", - 1);
291
+ edaddID[edaddID.length] = "random_ads";
292
+ edaddNm[edaddNm.length] = "RndAds";
293
+ <?php } ?>
294
+ edButtons[edButtons.length] = new edButton("no_ads", "NoAds", "\n<!--NoAds-->\n","","",-1);
295
+ edaddID[edaddID.length] = "no_ads";
296
+ edaddNm[edaddNm.length] = "NoAds";
297
+ };
298
+ (function(){
299
+ if(typeof(edButtons)!='undefined' && typeof(jQuery)!='undefined' && wpvcomp){
300
+ jQuery(document).ready(function(){
301
+ for(i=0;i<edaddID.length;i++) {
302
+ jQuery("#ed_toolbar").append('<input type="button" value="' + edaddNm[i] +'" id="' + edaddID[i] +'" class="ed_button" onclick="edInsertTag(edCanvas, ' + (edadd+i) + ');" title="' + edaddNm[i] +'" />');
303
+ }
304
+ });
305
+ }
306
+ }());
307
+ </script>
308
+ <?php
309
+ }
310
+ }
311
+
312
+ if( $wpvcomp ) {
313
+ add_action( 'admin_print_footer_scripts', 'quads_ads_head_script' );
314
+ } else {
315
+ add_action( 'admin_head', 'quads_ads_head_javascript_script' );
316
+ }
includes/shortcodes.php CHANGED
@@ -1,133 +1,133 @@
1
- <?php
2
-
3
- /**
4
- * shortcode functions
5
- *
6
- * @package QUADS
7
- * @subpackage Functions/shortcodes
8
- * @copyright Copyright (c) 2015, René Hermenau
9
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
- * @since 0.9.4
11
- */
12
-
13
-
14
- // add short codes
15
- //@deprecated since 0.9.5
16
- add_shortcode( 'quads_ad', 'quads_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
17
- // new shortcode since 0.9.5
18
- add_shortcode( 'quads', 'quads_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
19
-
20
-
21
- /**
22
- * shortcode to include ads in frontend
23
- *
24
- * @since 0.9.4
25
- * @param array $atts
26
- */
27
- function quads_shortcode_display_ad( $atts ) {
28
- global $quads_options;
29
-
30
- // Display Condition is false and ignoreShortcodeCond is empty or not true
31
- if( !quads_ad_is_allowed() && !isset($quads_options['ignoreShortcodeCond']) )
32
- return;
33
-
34
-
35
- //return quads_check_meta_setting('NoAds');
36
- if( quads_check_meta_setting( 'NoAds' ) === '1' ){
37
- return;
38
- }
39
-
40
- // The ad id
41
- $id = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
42
-
43
- $arr = array(
44
- 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
45
- 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
46
- 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
47
- 'float:none;margin:%1$dpx;');
48
-
49
- $adsalign = isset($quads_options['ads']['ad' . $id]['align']) ? $quads_options['ads']['ad' . $id]['align'] : 3; // default
50
- $adsmargin = isset( $quads_options['ads']['ad' . $id]['margin'] ) ? $quads_options['ads']['ad' . $id]['margin'] : '3'; // default
51
- $margin = sprintf( $arr[( int ) $adsalign], $adsmargin );
52
-
53
-
54
- // Do not create any inline style on AMP site
55
- $style = !quads_is_amp_endpoint() ? apply_filters( 'quads_filter_margins', $margin, 'ad' . $id ) : '';
56
-
57
- $code = "\n" . '<!-- WP QUADS v. ' . QUADS_VERSION . ' Shortcode Ad -->' . "\n" .
58
- '<div class="quads-location quads-ad' . $id . '" id="quads-ad' . $id . '" style="' . $style . '">' . "\n";
59
- $code .= do_shortcode( quads_get_ad( $id ) );
60
- $code .= '</div>' . "\n";
61
-
62
- return $code;
63
- }
64
-
65
- /**
66
- * return ad content
67
- *
68
- * @since 0.9.4
69
- * @param int $id id of the ad
70
- * @return string
71
- */
72
- function quads_get_ad($id = 0) {
73
- global $quads_options;
74
-
75
- if ( quads_ad_reach_max_count() ){
76
- return;
77
- }
78
-
79
- if ( isset($quads_options['ads']['ad' . $id]['code']) ){
80
- // Count how often the shortcode is used - Important
81
- quads_set_ad_count_shortcode();
82
- //$code = "\n".'<!-- WP QUADS Shortcode Ad v. ' . QUADS_VERSION .' -->'."\n";
83
- //return $code . $quads_options['ad' . $id]['code'];
84
- return quads_render_ad('ad' . $id, $quads_options['ads']['ad' . $id]['code']);
85
- }
86
- }
87
-
88
-
89
-
90
- /**
91
- * Return value of quads meta box settings
92
- *
93
- * @param type $id id of meta settings
94
- * @return mixed string | bool value if setting is active. False if there is no setting
95
- */
96
- function quads_check_meta_setting($key){
97
- global $post;
98
-
99
- if ( !isset($post->ID ) ){
100
- return false;
101
- }
102
-
103
- $meta_key = '_quads_config_visibility';
104
-
105
- $value_arr = get_post_meta ( $post->ID, $meta_key, true );
106
- $value_key = isset($value_arr[$key]) ? $value_arr[$key] : null;
107
-
108
- if (!empty($value_key))
109
- return (string)$value_key;
110
-
111
- return false;
112
- }
113
-
114
- /*
115
- * Return string through shortcode function and strip out specific shortcode from it to
116
- * prevents infinte loops if shortcode contains same shortcode
117
- *
118
- * @since 1.3.6
119
- * @param1 string shortcode e.g. quads
120
- * @param1 string content to return via shortcode
121
- * @return string / shortcodes parsed
122
- */
123
-
124
- function quadsCleanShortcode( $code, $content ) {
125
- global $shortcode_tags;
126
- $stack = $shortcode_tags;
127
- $shortcode_tags = array($code => 1);
128
- $content = strip_shortcodes( $content );
129
- $shortcode_tags = $stack;
130
-
131
- return do_shortcode( $content );
132
- }
133
-
1
+ <?php
2
+
3
+ /**
4
+ * shortcode functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/shortcodes
8
+ * @copyright Copyright (c) 2015, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 0.9.4
11
+ */
12
+
13
+
14
+ // add short codes
15
+ //@deprecated since 0.9.5
16
+ add_shortcode( 'quads_ad', 'quads_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
17
+ // new shortcode since 0.9.5
18
+ add_shortcode( 'quads', 'quads_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
19
+
20
+
21
+ /**
22
+ * shortcode to include ads in frontend
23
+ *
24
+ * @since 0.9.4
25
+ * @param array $atts
26
+ */
27
+ function quads_shortcode_display_ad( $atts ) {
28
+ global $quads_options;
29
+
30
+ // Display Condition is false and ignoreShortcodeCond is empty or not true
31
+ if( !quads_ad_is_allowed() && !isset($quads_options['ignoreShortcodeCond']) )
32
+ return;
33
+
34
+
35
+ //return quads_check_meta_setting('NoAds');
36
+ if( quads_check_meta_setting( 'NoAds' ) === '1' ){
37
+ return;
38
+ }
39
+
40
+ // The ad id
41
+ $id = isset( $atts['id'] ) ? ( int ) $atts['id'] : 0;
42
+
43
+ $arr = array(
44
+ 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
45
+ 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
46
+ 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
47
+ 'float:none;margin:%1$dpx;');
48
+
49
+ $adsalign = isset($quads_options['ads']['ad' . $id]['align']) ? $quads_options['ads']['ad' . $id]['align'] : 3; // default
50
+ $adsmargin = isset( $quads_options['ads']['ad' . $id]['margin'] ) ? $quads_options['ads']['ad' . $id]['margin'] : '3'; // default
51
+ $margin = sprintf( $arr[( int ) $adsalign], $adsmargin );
52
+
53
+
54
+ // Do not create any inline style on AMP site
55
+ $style = !quads_is_amp_endpoint() ? apply_filters( 'quads_filter_margins', $margin, 'ad' . $id ) : '';
56
+
57
+ $code = "\n" . '<!-- WP QUADS v. ' . QUADS_VERSION . ' Shortcode Ad -->' . "\n" .
58
+ '<div class="quads-location quads-ad' . $id . '" id="quads-ad' . $id . '" style="' . $style . '">' . "\n";
59
+ $code .= do_shortcode( quads_get_ad( $id ) );
60
+ $code .= '</div>' . "\n";
61
+
62
+ return $code;
63
+ }
64
+
65
+ /**
66
+ * return ad content
67
+ *
68
+ * @since 0.9.4
69
+ * @param int $id id of the ad
70
+ * @return string
71
+ */
72
+ function quads_get_ad($id = 0) {
73
+ global $quads_options;
74
+
75
+ if ( quads_ad_reach_max_count() ){
76
+ return;
77
+ }
78
+
79
+ if ( isset($quads_options['ads']['ad' . $id]['code']) ){
80
+ // Count how often the shortcode is used - Important
81
+ quads_set_ad_count_shortcode();
82
+ //$code = "\n".'<!-- WP QUADS Shortcode Ad v. ' . QUADS_VERSION .' -->'."\n";
83
+ //return $code . $quads_options['ad' . $id]['code'];
84
+ return quads_render_ad('ad' . $id, $quads_options['ads']['ad' . $id]['code']);
85
+ }
86
+ }
87
+
88
+
89
+
90
+ /**
91
+ * Return value of quads meta box settings
92
+ *
93
+ * @param type $id id of meta settings
94
+ * @return mixed string | bool value if setting is active. False if there is no setting
95
+ */
96
+ function quads_check_meta_setting($key){
97
+ global $post;
98
+
99
+ if ( !isset($post->ID ) ){
100
+ return false;
101
+ }
102
+
103
+ $meta_key = '_quads_config_visibility';
104
+
105
+ $value_arr = get_post_meta ( $post->ID, $meta_key, true );
106
+ $value_key = isset($value_arr[$key]) ? $value_arr[$key] : null;
107
+
108
+ if (!empty($value_key))
109
+ return (string)$value_key;
110
+
111
+ return false;
112
+ }
113
+
114
+ /*
115
+ * Return string through shortcode function and strip out specific shortcode from it to
116
+ * prevents infinte loops if shortcode contains same shortcode
117
+ *
118
+ * @since 1.3.6
119
+ * @param1 string shortcode e.g. quads
120
+ * @param1 string content to return via shortcode
121
+ * @return string / shortcodes parsed
122
+ */
123
+
124
+ function quadsCleanShortcode( $code, $content ) {
125
+ global $shortcode_tags;
126
+ $stack = $shortcode_tags;
127
+ $shortcode_tags = array($code => 1);
128
+ $content = strip_shortcodes( $content );
129
+ $shortcode_tags = $stack;
130
+
131
+ return do_shortcode( $content );
132
+ }
133
+
includes/template-functions.php CHANGED
@@ -1,859 +1,859 @@
1
- <?php
2
- /**
3
- * Template Functions
4
- *
5
- * @package QUADS
6
- * @subpackage Functions/Templates
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
- // we need to hook into the_content on lower than default priority (that's why we use separate hook)
16
- add_filter('the_content', 'quads_post_settings_to_quicktags', 5);
17
- add_filter('the_content', 'quads_process_content', quads_get_load_priority());
18
-
19
- /**
20
- * Show ads before posts
21
- * @not used at the moment
22
- */
23
- //add_action('loop_start', 'quads_inject_ad');
24
-
25
- //function quads_inject_ad() {
26
- // global $quads_options, $post;
27
- //
28
- // // Ads are deactivated via post meta settings
29
- // if( quads_check_meta_setting( 'NoAds' ) === '1' || quads_check_meta_setting( 'OffBegin' ) === '1'){
30
- // return false;
31
- // }
32
- //
33
- // if( !quads_ad_is_allowed( '' ) || !is_main_query() ) {
34
- // return false;
35
- // }
36
- // // Array of ad codes ids
37
- // $adsArray = quads_get_active_ads();
38
- //
39
- // // Return no ads are defined
40
- // if( count($adsArray) === 0 ) {
41
- // return false;
42
- // }
43
- //
44
- // $id = 1;
45
- //
46
- // $code = !empty($quads_options['ads']['ad' . $id ]['code']) ? $quads_options['ads']['ad' . $id ]['code'] : '';
47
- // echo quads_render_ad(1, $code, false);
48
- //
49
- //}
50
-
51
- /**
52
- * Adds quicktags, defined via post meta options, to content.
53
- *
54
- * @param $content Post content
55
- *
56
- * @return string
57
- */
58
- function quads_post_settings_to_quicktags ( $content ) {
59
-
60
- // Return original content if QUADS is not allowed
61
- if ( !quads_ad_is_allowed($content)){
62
- return $content;
63
- }
64
-
65
- $quicktags_str = quads_get_visibility_quicktags_str();
66
-
67
- return $content . $quicktags_str;
68
- }
69
- /**
70
- * Returns quicktags based on post meta options.
71
- * These quicktags define which ads should be hidden on current page.
72
- *
73
- * @param null $post_id Post id
74
- *
75
- * @return string
76
- */
77
- function quads_get_visibility_quicktags_str( $post_id = null ) {
78
-
79
- if( !$post_id ) {
80
- $post_id = get_the_ID();
81
- }
82
-
83
- $str = '';
84
- if( false === $post_id ) {
85
- return $str;
86
- }
87
-
88
- $config = get_post_meta( $post_id, '_quads_config_visibility', true );
89
-
90
- if( !empty( $config ) && is_array($config) ) {
91
- foreach ( $config as $qtag_id => $qtag_label ) {
92
- $str .= '<!--' . $qtag_id . '-->';
93
- }
94
- }
95
-
96
- return $str;
97
- }
98
-
99
- /**
100
- * Get load priority
101
- *
102
- * @global arr $quads_options
103
- * @return int
104
- */
105
- function quads_get_load_priority(){
106
- global $quads_options;
107
-
108
- if (!empty($quads_options['priority'])){
109
- return intval($quads_options['priority']);
110
- }
111
- return 20;
112
- }
113
-
114
- /**
115
- *
116
- * @global arr $quads_options
117
- * @global type $adsArray
118
- * @param type $content
119
- * @return type
120
- */
121
- function quads_process_content( $content ) {
122
- global $quads_options, $adsArray, $adsArrayCus, $visibleContentAds, $ad_count_widget, $visibleShortcodeAds;
123
-
124
-
125
- // Do not do anything if ads are not allowed or process is not in the main query
126
- if( !quads_ad_is_allowed( $content ) || !is_main_query()) {
127
- $content = quads_clean_tags( $content );
128
- return $content;
129
- }
130
-
131
- // Do nothing if maximum ads are reached in post content
132
- if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
133
- $content = quads_clean_tags( $content );
134
- return $content;
135
- }
136
-
137
- // Array of ad codes ids
138
- $adsArray = quads_get_active_ads();
139
-
140
- // Return is no ads are defined
141
- if ($adsArray === 0){
142
- return $content;
143
- }
144
-
145
- $content = quads_sanitize_content( $content );
146
-
147
- $content = quads_filter_default_ads( $content );
148
-
149
- /*
150
- * Tidy up content
151
- */
152
- //$content = '<!--EmptyClear-->' . $content . "\n" . '<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>';
153
- $content = '<!--EmptyClear-->' . $content . "\n";
154
- $content = quads_clean_tags( $content, true );
155
-
156
- $content = quads_parse_default_ads($content);
157
-
158
- $content = quads_parse_quicktags( $content );
159
-
160
- $content = quads_parse_random_quicktag_ads($content);
161
-
162
- $content = quads_parse_random_ads( $content );
163
-
164
- /* ... That's it. DONE :) ... */
165
- $content = quads_clean_tags( $content );
166
-
167
- return do_shortcode( $content );
168
- }
169
-
170
-
171
- /**
172
- * Return number of active widget ads
173
- * @param string the_content
174
- * @return int amount of widget ads
175
- */
176
- function quads_get_number_widget_ads() {
177
- $number_widgets = 0;
178
- $maxWidgets = 10;
179
- // count active widget ads
180
- for ( $i = 1; $i <= $maxWidgets; $i++ ) {
181
- $AdsWidName = 'AdsWidget%d (Quick Adsense Reloaded)';
182
- $wadsid = sanitize_title( str_replace( array('(', ')'), '', sprintf( $AdsWidName, $i ) ) );
183
- $number_widgets += (is_active_widget( '', '', $wadsid )) ? 1 : 0;
184
- }
185
-
186
- return $number_widgets;
187
- }
188
-
189
- /**
190
- * Get list of valid ad ids's where either the plain text code field or the adsense ad slot and the ad client id is populated.
191
- * @global arr $quads_options
192
- */
193
- function quads_get_active_ads() {
194
- global $quads_options;
195
-
196
-
197
- // Return early
198
- if (empty($quads_options['ads'])){
199
- return 0;
200
- }
201
-
202
- // count valid ads
203
- $i = 0;
204
- foreach ( $quads_options['ads'] as $ads) {
205
- $tmp = isset( $quads_options['ads']['ad' . $i]['code'] ) ? trim( $quads_options['ads']['ad' . $i]['code'] ) : '';
206
- // id is valid if there is either the plain text field populated or the adsense ad slot and the ad client id
207
- if( !empty( $tmp ) || (!empty( $quads_options['ads']['ad' . $i]['g_data_ad_slot'] ) && !empty( $quads_options['ads']['ad' . $i]['g_data_ad_client'] ) ) ) {
208
- $adsArray[] = $i;
209
- }
210
- $i++;
211
- }
212
- return (isset($adsArray) && count($adsArray) > 0) ? $adsArray : 0;
213
- }
214
-
215
-
216
- /**
217
- * Get max allowed numbers of ads
218
- *
219
- * @param string $content
220
- * @return int maximum number of ads
221
- */
222
- function quads_get_max_allowed_post_ads( $content ) {
223
- global $quads_options;
224
-
225
- // Maximum allowed general number of ads
226
- $maxAds = isset( $quads_options['maxads'] ) ? $quads_options['maxads'] : 10;
227
-
228
- $numberWidgets = 10;
229
-
230
- $AdsWidName = 'AdsWidget%d (Quick Adsense Reloaded)';
231
-
232
- // count number of active widgets and subtract them
233
- if( strpos( $content, '<!--OffWidget-->' ) === false && !quads_is_amp_endpoint() ) {
234
- for ( $i = 1; $i <= $numberWidgets; $i++ ) {
235
- $wadsid = sanitize_title( str_replace( array('(', ')'), '', sprintf( $AdsWidName, $i ) ) );
236
- $maxAds -= (is_active_widget( '', '', $wadsid )) ? 1 : 0;
237
- }
238
- }
239
-
240
- return $maxAds;
241
- }
242
-
243
-
244
- /**
245
- * Filter default ads
246
- *
247
- * @global array $quads_options global settings
248
- * @global array $adsArrayCus List of ad id'S
249
- * @param string $content
250
- * @return string content
251
- */
252
- function quads_filter_default_ads( $content ) {
253
- global $quads_options, $adsArrayCus;
254
-
255
- $off_default_ads = (strpos( $content, '<!--OffDef-->' ) !== false);
256
-
257
- if( $off_default_ads ) { // If default ads are disabled
258
- return $content;
259
- }
260
-
261
- // Default Ads
262
- $adsArrayCus = array();
263
-
264
- // placeholder string for random ad
265
- $cusrnd = 'CusRnd';
266
-
267
- // placeholder string for custom ad spots
268
- $cusads = 'CusAds';
269
-
270
- // Beginning of Post
271
- $beginning_position_status = isset( $quads_options['pos1']['BegnAds'] ) ? true : false;
272
- $beginning_position_ad_id = isset( $quads_options['pos1']['BegnRnd'] ) ? $quads_options['pos1']['BegnRnd'] : 0;
273
-
274
- // Middle of Post
275
- $middle_position_status = isset( $quads_options['pos2']['MiddAds'] ) ? true : false;
276
- $middle_position_ad_id = isset( $quads_options['pos2']['MiddRnd'] ) ? $quads_options['pos2']['MiddRnd'] : 0;
277
-
278
- // End of Post
279
- $end_position_status = isset( $quads_options['pos3']['EndiAds'] ) ? true : false;
280
- $end_position_ad_id = isset( $quads_options['pos3']['EndiRnd'] ) ? $quads_options['pos3']['EndiRnd'] : 0;
281
-
282
- // After the more tag
283
- $more_position_status = isset( $quads_options['pos4']['MoreAds'] ) ? true : false;
284
- $more_position_ad_id = isset( $quads_options['pos4']['MoreRnd'] ) ? $quads_options['pos4']['MoreRnd'] : 0;
285
-
286
- // Right before the last paragraph
287
- $last_paragraph_position_status = isset( $quads_options['pos5']['LapaAds'] ) ? true : false;
288
- $last_paragraph_position_ad_id = isset( $quads_options['pos5']['LapaRnd'] ) ? $quads_options['pos5']['LapaRnd'] : 0;
289
-
290
- // After Paragraph option 1 - 3
291
- $number = 3; // number of paragraph ads | default value 3.
292
- $default = 5; // Position. Let's start with id 5
293
- for ( $i = 1; $i <= $number; $i++ ) {
294
- $key = $default + $i; // 6,7,8
295
-
296
- $paragraph['status'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Ads'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Ads'] : 0; // Status - active | inactive
297
- $paragraph['id'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Rnd'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Rnd'] : 0; // Ad id
298
- $paragraph['position'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Nup'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Nup'] : 0; // Paragraph No
299
- $paragraph['end_post'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Con'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Con'] : 0; // End of post - yes | no
300
- }
301
- // After Image ad
302
- $imageActive = isset( $quads_options['pos9']['Img1Ads'] ) ? $quads_options['pos9']['Img1Ads'] : false;
303
- $imageAdNo = isset( $quads_options['pos9']['Img1Rnd'] ) ? $quads_options['pos9']['Img1Rnd'] : false;
304
- $imageNo = isset( $quads_options['pos9']['Img1Nup'] ) ? $quads_options['pos9']['Img1Nup'] : false;
305
- $imageCaption = isset( $quads_options['pos9']['Img1Con'] ) ? $quads_options['pos9']['Img1Con'] : false;
306
-
307
-
308
- if( $beginning_position_ad_id == 0 ) {
309
- $b1 = $cusrnd;
310
- } else {
311
- $b1 = $cusads . $beginning_position_ad_id;
312
- array_push( $adsArrayCus, $beginning_position_ad_id );
313
- };
314
-
315
- if( $more_position_ad_id == 0 ) {
316
- $r1 = $cusrnd;
317
- } else {
318
- $r1 = $cusads . $more_position_ad_id;
319
- array_push( $adsArrayCus, $more_position_ad_id );
320
- };
321
-
322
- if( $middle_position_ad_id == 0 ) {
323
- $m1 = $cusrnd;
324
- } else {
325
- $m1 = $cusads . $middle_position_ad_id;
326
- array_push( $adsArrayCus, $middle_position_ad_id );
327
- };
328
- if( $last_paragraph_position_ad_id == 0 ) {
329
- $g1 = $cusrnd;
330
- } else {
331
- $g1 = $cusads . $last_paragraph_position_ad_id;
332
- array_push( $adsArrayCus, $last_paragraph_position_ad_id );
333
- };
334
- if( $end_position_ad_id == 0 ) {
335
- $b2 = $cusrnd;
336
- } else {
337
- $b2 = $cusads . $end_position_ad_id;
338
- array_push( $adsArrayCus, $end_position_ad_id );
339
- };
340
- for ( $i = 1; $i <= $number; $i++ ) {
341
- if( $paragraph['id'][$i] == 0 ) {
342
- $paragraph[$i] = $cusrnd;
343
- } else {
344
- $paragraph[$i] = $cusads . $paragraph['id'][$i];
345
- array_push( $adsArrayCus, $paragraph['id'][$i] );
346
- };
347
- }
348
- //wp_die(print_r($adsArrayCus));
349
-
350
- // Create the arguments for filter quads_filter_paragraphs
351
- $quads_args = array(
352
- 'paragraph' => $paragraph,
353
- 'cusads' => $cusads,
354
- 'cusrnd' => $cusrnd,
355
- 'AdsIdCus' => $adsArrayCus,
356
- );
357
-
358
- // Execute filter to add more paragraph ad spots
359
- $quads_filtered = apply_filters( 'quads_filter_paragraphs', $quads_args );
360
-
361
- // The filtered arguments
362
- $paragraph = $quads_filtered['paragraph'];
363
-
364
- // filtered list of ad spots
365
- $adsArrayCus = $quads_filtered['AdsIdCus'];
366
-
367
- // Create paragraph ads
368
- $number = 11;
369
-
370
- for ( $i = $number; $i >= 1; $i-- ) {
371
- if( !empty( $paragraph['status'][$i] ) ) {
372
- $sch = "</p>";
373
- $content = str_replace( "</P>", $sch, $content );
374
-
375
-
376
- /**
377
- * Get all blockquote if there are any
378
- */
379
-
380
- preg_match_all("/<blockquote>(.*?)<\/blockquote>/s", $content, $blockquotes);
381
-
382
- /**
383
- * Replace blockquotes with placeholder
384
- */
385
- if(!empty($blockquotes)){
386
- $bId = 0;
387
- foreach($blockquotes[0] as $blockquote){
388
- $replace = "#QUADSBLOCKQUOTE" . $bId . '#';
389
- $content = str_replace(trim($blockquote), $replace, $content);
390
- $bId++;
391
- }
392
- }
393
-
394
- // Get paragraph tags
395
- $paragraphsArray = explode( $sch, $content );
396
-
397
- /**
398
- * Check if last element is empty and remove it
399
- */
400
- if(trim($paragraphsArray[count($paragraphsArray)-1]) == "") array_pop($paragraphsArray);
401
-
402
- if( ( int ) $paragraph['position'][$i] <= count( $paragraphsArray ) ) {
403
- $content = implode( $sch, array_slice( $paragraphsArray, 0, $paragraph['position'][$i] ) ) . $sch . '<!--' . $paragraph[$i] . '-->' . implode( $sch, array_slice( $paragraphsArray, $paragraph['position'][$i] ) );
404
- } elseif( $paragraph['end_post'][$i] ) {
405
- $content = implode( $sch, $paragraphsArray ) . '<!--' . $paragraph[$i] . '-->';
406
- }
407
-
408
- /**
409
- * Put back blockquotes into content
410
- */
411
-
412
- if(!empty($blockquotes)){
413
- $bId = 0;
414
- foreach($blockquotes[0] as $blockquote){
415
- $search = '#QUADSBLOCKQUOTE' . $bId . '#';
416
- $content = str_replace($search, trim($blockquote), $content);
417
- $bId++;
418
- }
419
- }
420
- }
421
- }
422
-
423
- // Check if image ad is random one
424
- if( $imageAdNo == 0 ) {
425
- $imageAd = $cusrnd;
426
- } else {
427
- $imageAd = $cusads . $imageAdNo;
428
- array_push( $adsArrayCus, $imageAdNo );
429
- };
430
-
431
-
432
- // Beginning of post ad
433
- if( $beginning_position_status && strpos( $content, '<!--OffBegin-->' ) === false ) {
434
- $content = '<!--' . $b1 . '-->' . $content;
435
- }
436
-
437
- // Check if ad is middle one
438
- if( $middle_position_status && strpos( $content, '<!--OffMiddle-->' ) === false ) {
439
- if( substr_count( strtolower( $content ), '</p>' ) >= 2 ) {
440
- $closingTagP = "</p>";
441
- $content = str_replace( "</P>", $closingTagP, $content );
442
- $paragraphsArray = explode( $closingTagP, $content );
443
-
444
- /**
445
- * Check if last element is empty and remove it
446
- */
447
- if(trim($paragraphsArray[count($paragraphsArray)-1]) == "") array_pop($paragraphsArray);
448
-
449
- $nn = 0;
450
- $mm = strlen( $content ) / 2;
451
- for ( $i = 0; $i < count( $paragraphsArray ); $i++ ) {
452
- $nn += strlen( $paragraphsArray[$i] ) + 4;
453
- if( $nn > $mm ) {
454
- if( ($mm - ($nn - strlen( $paragraphsArray[$i] ))) > ($nn - $mm) && $i + 1 < count( $paragraphsArray ) ) {
455
- $paragraphsArray[$i + 1] = '<!--' . $m1 . '-->' . $paragraphsArray[$i + 1];
456
- } else {
457
- $paragraphsArray[$i] = '<!--' . $m1 . '-->' . $paragraphsArray[$i];
458
- }
459
- break;
460
- }
461
- }
462
- $content = implode( $closingTagP, $paragraphsArray );
463
- }
464
- }
465
-
466
- // End of Post ad
467
- if( $end_position_status && strpos( $content, '<!--OffEnd-->' ) === false ) {
468
- $content = $content . '<!--' . $b2 . '-->';
469
- }
470
-
471
-
472
-
473
- // Check if ad is after "More Tag"
474
- if( $more_position_status && strpos( $content, '<!--OffAfMore-->' ) === false ) {
475
- $mmr = '<!--' . $r1 . '-->';
476
- $postid = get_the_ID();
477
- $content = str_replace( '<span id="more-' . $postid . '"></span>', $mmr, $content );
478
- }
479
-
480
- // Right before last paragraph ad
481
- if( $last_paragraph_position_status && strpos( $content, '<!--OffBfLastPara-->' ) === false ) {
482
- $closingTagP = "</p>";
483
- $content = str_replace( "</P>", $closingTagP, $content );
484
- $paragraphsArray = explode( $closingTagP, $content );
485
-
486
-
487
- /**
488
- * Check if last element is empty and remove it
489
- */
490
- if(trim($paragraphsArray[count($paragraphsArray)-1]) == "") array_pop($paragraphsArray);
491
-
492
-
493
- //if( count( $paragraphsArray ) > 2 && !strpos($paragraphsArray[count( $paragraphsArray ) - 1], '</blockquote>')) {
494
- if( count( $paragraphsArray ) > 2) {
495
- $content = implode( $closingTagP, array_slice( $paragraphsArray, 0, count( $paragraphsArray ) - 1 ) ) . '<!--' . $g1 . '-->' . $closingTagP . $paragraphsArray[count( $paragraphsArray ) - 1];
496
- }
497
-
498
- }
499
-
500
- // After Image ad
501
- if( $imageActive ) {
502
-
503
- // Sanitation
504
- $imgtag = "<img";
505
- $delimiter = ">";
506
- $caption = "[/caption]";
507
- $atag = "</a>";
508
- $content = str_replace( "<IMG", $imgtag, $content );
509
- $content = str_replace( "</A>", $atag, $content );
510
-
511
- // Get all images in content
512
- $imagesArray = explode( $imgtag, $content );
513
- // Modify Image ad
514
- if( ( int ) $imageNo < count( $imagesArray ) ) {
515
- //Get all tags
516
- $tagsArray = explode( $delimiter, $imagesArray[$imageNo] );
517
- if( count( $tagsArray ) > 1 ) {
518
- $captionArray = explode( $caption, $imagesArray[$imageNo] );
519
- $ccp = ( count( $captionArray ) > 1 ) ? strpos( strtolower( $captionArray[0] ), '[caption ' ) === false : false;
520
- $imagesArrayAtag = explode( $atag, $imagesArray[$imageNo] );
521
- $cdu = ( count( $imagesArrayAtag ) > 1 ) ? strpos( strtolower( $imagesArrayAtag[0] ), '<a href' ) === false : false;
522
- // Show ad after caption
523
- if( $imageCaption && $ccp ) {
524
- $imagesArray[$imageNo] = implode( $caption, array_slice( $captionArray, 0, 1 ) ) . $caption . "\r\n" . '<!--' . $imageAd . '-->' . "\r\n" . implode( $caption, array_slice( $captionArray, 1 ) );
525
- } else if( $cdu ) {
526
- $imagesArray[$imageNo] = implode( $atag, array_slice( $imagesArrayAtag, 0, 1 ) ) . $atag . "\r\n" . '<!--' . $imageAd . '-->' . "\r\n" . implode( $atag, array_slice( $imagesArrayAtag, 1 ) );
527
- } else {
528
- $imagesArray[$imageNo] = implode( $delimiter, array_slice( $tagsArray, 0, 1 ) ) . $delimiter . "\r\n" . '<!--' . $imageAd . '-->' . "\r\n" . implode( $delimiter, array_slice( $tagsArray, 1 ) );
529
- }
530
- }
531
- $content = implode( $imgtag, $imagesArray );
532
- }
533
- }
534
-
535
- return $content;
536
- }
537
- /**
538
- * Sanitize content and return it cleaned
539
- *
540
- * @param string $content
541
- * @return string
542
- */
543
- function quads_sanitize_content($content){
544
-
545
- /* ... Tidy up content ... */
546
- // Replace all <p></p> tags with placeholder ##QA-TP1##
547
- $content = str_replace( "<p></p>", "##QA-TP1##", $content );
548
-
549
- // Replace all <p>&nbsp;</p> tags with placeholder ##QA-TP2##
550
- $content = str_replace( "<p>&nbsp;</p>", "##QA-TP2##", $content );
551
-
552
- return $content;
553
- }
554
-
555
-
556
-
557
- /**
558
- * Parse random ads which are created from quicktag <!--RndAds-->
559
- *
560
- * @global array $adsArray
561
- * @global int $visibleContentAds
562
- * @return content
563
- */
564
- function quads_parse_random_quicktag_ads($content){
565
- global $adsArray, $visibleContentAds, $quads_options;
566
-
567
- $maxAds = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
568
- /*
569
- * Replace RndAds Random Ads
570
- */
571
- if( strpos( $content, '<!--RndAds-->' ) !== false && is_singular() ) {
572
- $adsArrayTmp = array();
573
- shuffle( $adsArray );
574
- for ( $i = 1; $i <= $maxAds - $visibleContentAds; $i++ ) {
575
- if( $i <= count( $adsArray ) ) {
576
- array_push( $adsArrayTmp, $adsArray[$i - 1] );
577
- }
578
- }
579
- $tcx = count( $adsArrayTmp );
580
- $tcy = substr_count( $content, '<!--RndAds-->' );
581
- for ( $i = $tcx; $i <= $tcy - 1; $i++ ) {
582
- array_push( $adsArrayTmp, -1 );
583
- }
584
- shuffle( $adsArrayTmp );
585
- for ( $i = 1; $i <= $tcy; $i++ ) {
586
- $tmp = $adsArrayTmp[0];
587
- $content = quads_replace_ads( $content, 'RndAds', $adsArrayTmp[0] );
588
- $adsArrayTmp = quads_del_element( $adsArrayTmp, 0 );
589
- if( $tmp != -1 ) {
590
- $visibleContentAds += 1;
591
- };
592
- //quads_set_ad_count_content();
593
- //if( quads_ad_reach_max_count() ) {
594
- if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
595
- $content = quads_clean_tags( $content );
596
- return $content;
597
- }
598
- }
599
- }
600
-
601
- return $content;
602
- }
603
-
604
- /**
605
- * Parse random default ads which can be enabled from general settings
606
- *
607
- * @global array $adsArray
608
- * @global int $visibleContentAds
609
- * @return string
610
- */
611
- function quads_parse_random_ads($content) {
612
- global $adsRandom, $visibleContentAds;
613
-
614
- $off_default_ads = (strpos( $content, '<!--OffDef-->' ) !== false);
615
- if( $off_default_ads ) { // disabled default ads
616
- return $content;
617
- }
618
-
619
- if( strpos( $content, '<!--CusRnd-->' ) !== false && is_singular() ) {
620
-
621
- $tcx = count( $adsRandom );
622
- // How often is a random ad appearing in content
623
- $number_rand_ads = substr_count( $content, '<!--CusRnd-->' );
624
-
625
- for ( $i = $tcx; $i <= $number_rand_ads - 1; $i++ ) {
626
- array_push( $adsRandom, -1 );
627
- }
628
- shuffle( $adsRandom );
629
- //wp_die(print_r($adsRandom));
630
- //wp_die($adsRandom[0]);
631
- for ( $i = 1; $i <= $number_rand_ads; $i++ ) {
632
- $content = quads_replace_ads( $content, 'CusRnd', $adsRandom[0] );
633
- $adsRandom = quads_del_element( $adsRandom, 0 );
634
- $visibleContentAds += 1;
635
- //quads_set_ad_count_content();
636
- //if( quads_ad_reach_max_count() ) {
637
- if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
638
- $content = quads_clean_tags( $content );
639
- return $content;
640
- }
641
- }
642
- }
643
-
644
- return $content;
645
- }
646
-
647
- /**
648
- * Parse Quicktags
649
- *
650
- * @global array $adsArray
651
- * @param string $content
652
- * @return string
653
- */
654
- function quads_parse_quicktags($content){
655
- global $adsArray, $visibleContentAds;
656
- //print_r(count($adsArray));
657
-
658
- $idx = 0;
659
- for ( $i = 1; $i <= count( $adsArray ); $i++ ) {
660
- if( strpos( $content, '<!--Ads' . $adsArray[$idx] . '-->' ) !== false ) {
661
- $content = quads_replace_ads( $content, 'Ads' . $adsArray[$idx], $adsArray[$idx] );
662
- //$adsArray = quads_del_element( $adsArray, $idx );
663
- $visibleContentAds += 1;
664
- $idx +=1;
665
- //quads_set_ad_count_content();
666
- if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
667
- $content = quads_clean_tags( $content );
668
- return $content;
669
- }
670
- } else {
671
- $idx += 1;
672
- }
673
- }
674
-
675
- return $content;
676
- }
677
-
678
- /**
679
- * Parse default ads Beginning/Middle/End/Paragraph Ads1-10
680
- *
681
- * @param string $content
682
- * @return string
683
- */
684
- function quads_parse_default_ads( $content ) {
685
- global $adsArrayCus, $adsRandom, $adsArray, $visibleContentAds;
686
-
687
- $off_default_ads = (strpos( $content, '<!--OffDef-->' ) !== false);
688
-
689
- if( $off_default_ads ) { // disabled default ads
690
- return $content;
691
- }
692
- // Create the array which contains the random ads
693
- $adsRandom = $adsArray;
694
-
695
- // echo '<pre>';
696
- // echo 'adsArrayCus: ';
697
- // print_r($adsArrayCus);
698
- // echo 'adsArray: ';
699
- // print_r( $adsArray );
700
- // echo '</pre>';
701
-
702
- for ( $i = 0; $i <= count( $adsArrayCus ); $i++ ) {
703
- if( isset( $adsArrayCus[$i] ) && strpos( $content, '<!--CusAds' . $adsArrayCus[$i] . '-->' ) !== false && in_array( $adsArrayCus[$i], $adsArray ) ) {
704
- $content = quads_replace_ads( $content, 'CusAds' . $adsArrayCus[$i], $adsArrayCus[$i] );
705
- // Create array $adsRandom for quads_parse_random_ads() parsing functions to make sure that the random function
706
- // is never using ads that are already used on static ad spots which are generated with quads_parse_default_ads()
707
- if ($i == 0){
708
- $adsRandom = quads_del_element($adsRandom, array_search($adsArrayCus[$i], $adsRandom));
709
- }else{
710
- $adsRandom = quads_del_element($adsRandom, array_search($adsArrayCus[$i-1], $adsRandom));
711
- }
712
-
713
- $visibleContentAds += 1;
714
- //quads_set_ad_count_content();
715
- //if( quads_ad_reach_max_count() || $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
716
- //wp_die(quads_get_max_allowed_post_ads( $content ));
717
- if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
718
- $content = quads_clean_tags( $content );
719
- }
720
- }
721
- }
722
- return $content;
723
- }
724
-
725
- /**
726
- * Replace ad code in content
727
- *
728
- * @global type $quads_options
729
- * @param string $content
730
- * @param string $quicktag Quicktag
731
- * @param string $id id of the ad
732
- * @return type
733
- */
734
- function quads_replace_ads($content, $quicktag, $id) {
735
- global $quads_options;
736
-
737
-
738
- if( strpos($content,'<!--'.$quicktag.'-->')===false ) {
739
- return $content;
740
- }
741
-
742
-
743
- if ($id != -1) {
744
-
745
- $code = !empty($quads_options['ads']['ad' . $id ]['code']) ? $quads_options['ads']['ad' . $id ]['code'] : '';
746
- $style = quads_get_inline_ad_style($id);
747
- $adscode =
748
- "\n".'<!-- WP QUADS Content Ad Plugin v. ' . QUADS_VERSION .' -->'."\n".
749
- '<div class="quads-location quads-ad' .$id. '" id="quads-ad' .$id. '" style="'.$style.'">'."\n".
750
- quads_render_ad('ad'.$id, $code)."\n".
751
- '</div>'. "\n";
752
-
753
- } else {
754
- $adscode ='';
755
- }
756
- $cont = explode('<!--'.$quicktag.'-->', $content, 2);
757
-
758
- return $cont[0].$adscode.$cont[1];
759
- }
760
-
761
- /**
762
- * Get ad inline style
763
- *
764
- * @global arr $quads_options
765
- * @param int $id id of the ad
766
- * @return string
767
- */
768
- function quads_get_inline_ad_style( $id ) {
769
- global $quads_options;
770
-
771
- if( empty($id) ) {
772
- return '';
773
- }
774
-
775
- // Basic style
776
- $styleArray = array(
777
- 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
778
- 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
779
- 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
780
- 'float:none;margin:%1$dpx;');
781
-
782
- // Alignment
783
- $adsalign = ( int )$quads_options['ads']['ad' . $id]['align'];
784
-
785
- // Margin
786
- $adsmargin = isset( $quads_options['ads']['ad' . $id]['margin'] ) ? $quads_options['ads']['ad' . $id]['margin'] : '3'; // default option = 3
787
- $margin = sprintf( $styleArray[$adsalign], $adsmargin );
788
-
789
- //wp_die($quads_options['ads']['ad' . $id]['margin']);
790
- //wp_die('ad'.$id);
791
-
792
- // Do not create any inline style on AMP site
793
- $style = !quads_is_amp_endpoint() ? apply_filters( 'quads_filter_margins', $margin, 'ad' . $id ) : '';
794
-
795
- return $style;
796
- }
797
-
798
- /**
799
- * Revert content to original content any remove any processing helper strings
800
- *
801
- * @global int $visibleContentAds
802
- * @global array $adsArray
803
- * @global array $quads_options
804
- * @global int $ad_count
805
- * @param string $content
806
- * @param boolean $trimonly
807
- *
808
- * @return string content
809
- */
810
- function quads_clean_tags($content, $trimonly = false) {
811
- global $visibleContentAds;
812
- global $adsArray;
813
- global $quads_options;
814
- global $ad_count;
815
-
816
- $tagnames = array('EmptyClear','RndAds','NoAds','OffDef','OffAds','OffWidget','OffBegin','OffMiddle','OffEnd','OffBfMore','OffAfLastPara','CusRnd');
817
-
818
- for($i=1;$i<=10;$i++) {
819
- array_push($tagnames, 'CusAds'.$i);
820
- array_push($tagnames, 'Ads'.$i);
821
- };
822
-
823
-
824
- foreach ($tagnames as $tags) {
825
- if(strpos($content,'<!--'.$tags.'-->')!==false || $tags=='EmptyClear') {
826
- if($trimonly) {
827
- $content = str_replace('<p><!--'.$tags.'--></p>', '<!--'.$tags.'-->', $content);
828
- }else{
829
- $content = str_replace(array('<p><!--'.$tags.'--></p>','<!--'.$tags.'-->'), '', $content);
830
- $content = str_replace("##QA-TP1##", "<p></p>", $content);
831
- $content = str_replace("##QA-TP2##", "<p>&nbsp;</p>", $content);
832
- }
833
- }
834
- }
835
- if(!$trimonly && (is_single() || is_page()) ) {
836
- $visibleContentAds = 0;
837
- $adsArray = array();
838
- }
839
- return $content;
840
- }
841
-
842
-
843
-
844
- /**
845
- * Remove element from array
846
- *
847
- * @param array $paragraphsArrayay
848
- * @param int $idx key to remove from array
849
- * @return array
850
- */
851
- function quads_del_element($array, $idx) {
852
- $copy = array();
853
- for( $i=0; $i<count($array) ;$i++) {
854
- if ( $idx != $i ) {
855
- array_push($copy, $array[$i]);
856
- }
857
- }
858
- return $copy;
859
  }
1
+ <?php
2
+ /**
3
+ * Template Functions
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Functions/Templates
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
+ // we need to hook into the_content on lower than default priority (that's why we use separate hook)
16
+ add_filter('the_content', 'quads_post_settings_to_quicktags', 5);
17
+ add_filter('the_content', 'quads_process_content', quads_get_load_priority());
18
+
19
+ /**
20
+ * Show ads before posts
21
+ * @not used at the moment
22
+ */
23
+ //add_action('loop_start', 'quads_inject_ad');
24
+
25
+ //function quads_inject_ad() {
26
+ // global $quads_options, $post;
27
+ //
28
+ // // Ads are deactivated via post meta settings
29
+ // if( quads_check_meta_setting( 'NoAds' ) === '1' || quads_check_meta_setting( 'OffBegin' ) === '1'){
30
+ // return false;
31
+ // }
32
+ //
33
+ // if( !quads_ad_is_allowed( '' ) || !is_main_query() ) {
34
+ // return false;
35
+ // }
36
+ // // Array of ad codes ids
37
+ // $adsArray = quads_get_active_ads();
38
+ //
39
+ // // Return no ads are defined
40
+ // if( count($adsArray) === 0 ) {
41
+ // return false;
42
+ // }
43
+ //
44
+ // $id = 1;
45
+ //
46
+ // $code = !empty($quads_options['ads']['ad' . $id ]['code']) ? $quads_options['ads']['ad' . $id ]['code'] : '';
47
+ // echo quads_render_ad(1, $code, false);
48
+ //
49
+ //}
50
+
51
+ /**
52
+ * Adds quicktags, defined via post meta options, to content.
53
+ *
54
+ * @param $content Post content
55
+ *
56
+ * @return string
57
+ */
58
+ function quads_post_settings_to_quicktags ( $content ) {
59
+
60
+ // Return original content if QUADS is not allowed
61
+ if ( !quads_ad_is_allowed($content)){
62
+ return $content;
63
+ }
64
+
65
+ $quicktags_str = quads_get_visibility_quicktags_str();
66
+
67
+ return $content . $quicktags_str;
68
+ }
69
+ /**
70
+ * Returns quicktags based on post meta options.
71
+ * These quicktags define which ads should be hidden on current page.
72
+ *
73
+ * @param null $post_id Post id
74
+ *
75
+ * @return string
76
+ */
77
+ function quads_get_visibility_quicktags_str( $post_id = null ) {
78
+
79
+ if( !$post_id ) {
80
+ $post_id = get_the_ID();
81
+ }
82
+
83
+ $str = '';
84
+ if( false === $post_id ) {
85
+ return $str;
86
+ }
87
+
88
+ $config = get_post_meta( $post_id, '_quads_config_visibility', true );
89
+
90
+ if( !empty( $config ) && is_array($config) ) {
91
+ foreach ( $config as $qtag_id => $qtag_label ) {
92
+ $str .= '<!--' . $qtag_id . '-->';
93
+ }
94
+ }
95
+
96
+ return $str;
97
+ }
98
+
99
+ /**
100
+ * Get load priority
101
+ *
102
+ * @global arr $quads_options
103
+ * @return int
104
+ */
105
+ function quads_get_load_priority(){
106
+ global $quads_options;
107
+
108
+ if (!empty($quads_options['priority'])){
109
+ return intval($quads_options['priority']);
110
+ }
111
+ return 20;
112
+ }
113
+
114
+ /**
115
+ *
116
+ * @global arr $quads_options
117
+ * @global type $adsArray
118
+ * @param type $content
119
+ * @return type
120
+ */
121
+ function quads_process_content( $content ) {
122
+ global $quads_options, $adsArray, $adsArrayCus, $visibleContentAds, $ad_count_widget, $visibleShortcodeAds;
123
+
124
+
125
+ // Do not do anything if ads are not allowed or process is not in the main query
126
+ if( !quads_ad_is_allowed( $content ) || !is_main_query()) {
127
+ $content = quads_clean_tags( $content );
128
+ return $content;
129
+ }
130
+
131
+ // Do nothing if maximum ads are reached in post content
132
+ if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
133
+ $content = quads_clean_tags( $content );
134
+ return $content;
135
+ }
136
+
137
+ // Array of ad codes ids
138
+ $adsArray = quads_get_active_ads();
139
+
140
+ // Return is no ads are defined
141
+ if ($adsArray === 0){
142
+ return $content;
143
+ }
144
+
145
+ $content = quads_sanitize_content( $content );
146
+
147
+ $content = quads_filter_default_ads( $content );
148
+
149
+ /*
150
+ * Tidy up content
151
+ */
152
+ //$content = '<!--EmptyClear-->' . $content . "\n" . '<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>';
153
+ $content = '<!--EmptyClear-->' . $content . "\n";
154
+ $content = quads_clean_tags( $content, true );
155
+
156
+ $content = quads_parse_default_ads($content);
157
+
158
+ $content = quads_parse_quicktags( $content );
159
+
160
+ $content = quads_parse_random_quicktag_ads($content);
161
+
162
+ $content = quads_parse_random_ads( $content );
163
+
164
+ /* ... That's it. DONE :) ... */
165
+ $content = quads_clean_tags( $content );
166
+
167
+ return do_shortcode( $content );
168
+ }
169
+
170
+
171
+ /**
172
+ * Return number of active widget ads
173
+ * @param string the_content
174
+ * @return int amount of widget ads
175
+ */
176
+ function quads_get_number_widget_ads() {
177
+ $number_widgets = 0;
178
+ $maxWidgets = 10;
179
+ // count active widget ads
180
+ for ( $i = 1; $i <= $maxWidgets; $i++ ) {
181
+ $AdsWidName = 'AdsWidget%d (Quick Adsense Reloaded)';
182
+ $wadsid = sanitize_title( str_replace( array('(', ')'), '', sprintf( $AdsWidName, $i ) ) );
183
+ $number_widgets += (is_active_widget( '', '', $wadsid )) ? 1 : 0;
184
+ }
185
+
186
+ return $number_widgets;
187
+ }
188
+
189
+ /**
190
+ * Get list of valid ad ids's where either the plain text code field or the adsense ad slot and the ad client id is populated.
191
+ * @global arr $quads_options
192
+ */
193
+ function quads_get_active_ads() {
194
+ global $quads_options;
195
+
196
+
197
+ // Return early
198
+ if (empty($quads_options['ads'])){
199
+ return 0;
200
+ }
201
+
202
+ // count valid ads
203
+ $i = 0;
204
+ foreach ( $quads_options['ads'] as $ads) {
205
+ $tmp = isset( $quads_options['ads']['ad' . $i]['code'] ) ? trim( $quads_options['ads']['ad' . $i]['code'] ) : '';
206
+ // id is valid if there is either the plain text field populated or the adsense ad slot and the ad client id
207
+ if( !empty( $tmp ) || (!empty( $quads_options['ads']['ad' . $i]['g_data_ad_slot'] ) && !empty( $quads_options['ads']['ad' . $i]['g_data_ad_client'] ) ) ) {
208
+ $adsArray[] = $i;
209
+ }
210
+ $i++;
211
+ }
212
+ return (isset($adsArray) && count($adsArray) > 0) ? $adsArray : 0;
213
+ }
214
+
215
+
216
+ /**
217
+ * Get max allowed numbers of ads
218
+ *
219
+ * @param string $content
220
+ * @return int maximum number of ads
221
+ */
222
+ function quads_get_max_allowed_post_ads( $content ) {
223
+ global $quads_options;
224
+
225
+ // Maximum allowed general number of ads
226
+ $maxAds = isset( $quads_options['maxads'] ) ? $quads_options['maxads'] : 10;
227
+
228
+ $numberWidgets = 10;
229
+
230
+ $AdsWidName = 'AdsWidget%d (Quick Adsense Reloaded)';
231
+
232
+ // count number of active widgets and subtract them
233
+ if( strpos( $content, '<!--OffWidget-->' ) === false && !quads_is_amp_endpoint() ) {
234
+ for ( $i = 1; $i <= $numberWidgets; $i++ ) {
235
+ $wadsid = sanitize_title( str_replace( array('(', ')'), '', sprintf( $AdsWidName, $i ) ) );
236
+ $maxAds -= (is_active_widget( '', '', $wadsid )) ? 1 : 0;
237
+ }
238
+ }
239
+
240
+ return $maxAds;
241
+ }
242
+
243
+
244
+ /**
245
+ * Filter default ads
246
+ *
247
+ * @global array $quads_options global settings
248
+ * @global array $adsArrayCus List of ad id'S
249
+ * @param string $content
250
+ * @return string content
251
+ */
252
+ function quads_filter_default_ads( $content ) {
253
+ global $quads_options, $adsArrayCus;
254
+
255
+ $off_default_ads = (strpos( $content, '<!--OffDef-->' ) !== false);
256
+
257
+ if( $off_default_ads ) { // If default ads are disabled
258
+ return $content;
259
+ }
260
+
261
+ // Default Ads
262
+ $adsArrayCus = array();
263
+
264
+ // placeholder string for random ad
265
+ $cusrnd = 'CusRnd';
266
+
267
+ // placeholder string for custom ad spots
268
+ $cusads = 'CusAds';
269
+
270
+ // Beginning of Post
271
+ $beginning_position_status = isset( $quads_options['pos1']['BegnAds'] ) ? true : false;
272
+ $beginning_position_ad_id = isset( $quads_options['pos1']['BegnRnd'] ) ? $quads_options['pos1']['BegnRnd'] : 0;
273
+
274
+ // Middle of Post
275
+ $middle_position_status = isset( $quads_options['pos2']['MiddAds'] ) ? true : false;
276
+ $middle_position_ad_id = isset( $quads_options['pos2']['MiddRnd'] ) ? $quads_options['pos2']['MiddRnd'] : 0;
277
+
278
+ // End of Post
279
+ $end_position_status = isset( $quads_options['pos3']['EndiAds'] ) ? true : false;
280
+ $end_position_ad_id = isset( $quads_options['pos3']['EndiRnd'] ) ? $quads_options['pos3']['EndiRnd'] : 0;
281
+
282
+ // After the more tag
283
+ $more_position_status = isset( $quads_options['pos4']['MoreAds'] ) ? true : false;
284
+ $more_position_ad_id = isset( $quads_options['pos4']['MoreRnd'] ) ? $quads_options['pos4']['MoreRnd'] : 0;
285
+
286
+ // Right before the last paragraph
287
+ $last_paragraph_position_status = isset( $quads_options['pos5']['LapaAds'] ) ? true : false;
288
+ $last_paragraph_position_ad_id = isset( $quads_options['pos5']['LapaRnd'] ) ? $quads_options['pos5']['LapaRnd'] : 0;
289
+
290
+ // After Paragraph option 1 - 3
291
+ $number = 3; // number of paragraph ads | default value 3.
292
+ $default = 5; // Position. Let's start with id 5
293
+ for ( $i = 1; $i <= $number; $i++ ) {
294
+ $key = $default + $i; // 6,7,8
295
+
296
+ $paragraph['status'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Ads'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Ads'] : 0; // Status - active | inactive
297
+ $paragraph['id'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Rnd'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Rnd'] : 0; // Ad id
298
+ $paragraph['position'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Nup'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Nup'] : 0; // Paragraph No
299
+ $paragraph['end_post'][$i] = isset( $quads_options['pos' . $key]['Par' . $i . 'Con'] ) ? $quads_options['pos' . $key]['Par' . $i . 'Con'] : 0; // End of post - yes | no
300
+ }
301
+ // After Image ad
302
+ $imageActive = isset( $quads_options['pos9']['Img1Ads'] ) ? $quads_options['pos9']['Img1Ads'] : false;
303
+ $imageAdNo = isset( $quads_options['pos9']['Img1Rnd'] ) ? $quads_options['pos9']['Img1Rnd'] : false;
304
+ $imageNo = isset( $quads_options['pos9']['Img1Nup'] ) ? $quads_options['pos9']['Img1Nup'] : false;
305
+ $imageCaption = isset( $quads_options['pos9']['Img1Con'] ) ? $quads_options['pos9']['Img1Con'] : false;
306
+
307
+
308
+ if( $beginning_position_ad_id == 0 ) {
309
+ $b1 = $cusrnd;
310
+ } else {
311
+ $b1 = $cusads . $beginning_position_ad_id;
312
+ array_push( $adsArrayCus, $beginning_position_ad_id );
313
+ };
314
+
315
+ if( $more_position_ad_id == 0 ) {
316
+ $r1 = $cusrnd;
317
+ } else {
318
+ $r1 = $cusads . $more_position_ad_id;
319
+ array_push( $adsArrayCus, $more_position_ad_id );
320
+ };
321
+
322
+ if( $middle_position_ad_id == 0 ) {
323
+ $m1 = $cusrnd;
324
+ } else {
325
+ $m1 = $cusads . $middle_position_ad_id;
326
+ array_push( $adsArrayCus, $middle_position_ad_id );
327
+ };
328
+ if( $last_paragraph_position_ad_id == 0 ) {
329
+ $g1 = $cusrnd;
330
+ } else {
331
+ $g1 = $cusads . $last_paragraph_position_ad_id;
332
+ array_push( $adsArrayCus, $last_paragraph_position_ad_id );
333
+ };
334
+ if( $end_position_ad_id == 0 ) {
335
+ $b2 = $cusrnd;
336
+ } else {
337
+ $b2 = $cusads . $end_position_ad_id;
338
+ array_push( $adsArrayCus, $end_position_ad_id );
339
+ };
340
+ for ( $i = 1; $i <= $number; $i++ ) {
341
+ if( $paragraph['id'][$i] == 0 ) {
342
+ $paragraph[$i] = $cusrnd;
343
+ } else {
344
+ $paragraph[$i] = $cusads . $paragraph['id'][$i];
345
+ array_push( $adsArrayCus, $paragraph['id'][$i] );
346
+ };
347
+ }
348
+ //wp_die(print_r($adsArrayCus));
349
+
350
+ // Create the arguments for filter quads_filter_paragraphs
351
+ $quads_args = array(
352
+ 'paragraph' => $paragraph,
353
+ 'cusads' => $cusads,
354
+ 'cusrnd' => $cusrnd,
355
+ 'AdsIdCus' => $adsArrayCus,
356
+ );
357
+
358
+ // Execute filter to add more paragraph ad spots
359
+ $quads_filtered = apply_filters( 'quads_filter_paragraphs', $quads_args );
360
+
361
+ // The filtered arguments
362
+ $paragraph = $quads_filtered['paragraph'];
363
+
364
+ // filtered list of ad spots
365
+ $adsArrayCus = $quads_filtered['AdsIdCus'];
366
+
367
+ // Create paragraph ads
368
+ $number = 11;
369
+
370
+ for ( $i = $number; $i >= 1; $i-- ) {
371
+ if( !empty( $paragraph['status'][$i] ) ) {
372
+ $sch = "</p>";
373
+ $content = str_replace( "</P>", $sch, $content );
374
+
375
+
376
+ /**
377
+ * Get all blockquote if there are any
378
+ */
379
+
380
+ preg_match_all("/<blockquote>(.*?)<\/blockquote>/s", $content, $blockquotes);
381
+
382
+ /**
383
+ * Replace blockquotes with placeholder
384
+ */
385
+ if(!empty($blockquotes)){
386
+ $bId = 0;
387
+ foreach($blockquotes[0] as $blockquote){
388
+ $replace = "#QUADSBLOCKQUOTE" . $bId . '#';
389
+ $content = str_replace(trim($blockquote), $replace, $content);
390
+ $bId++;
391
+ }
392
+ }
393
+
394
+ // Get paragraph tags
395
+ $paragraphsArray = explode( $sch, $content );
396
+
397
+ /**
398
+ * Check if last element is empty and remove it
399
+ */
400
+ if(trim($paragraphsArray[count($paragraphsArray)-1]) == "") array_pop($paragraphsArray);
401
+
402
+ if( ( int ) $paragraph['position'][$i] <= count( $paragraphsArray ) ) {
403
+ $content = implode( $sch, array_slice( $paragraphsArray, 0, $paragraph['position'][$i] ) ) . $sch . '<!--' . $paragraph[$i] . '-->' . implode( $sch, array_slice( $paragraphsArray, $paragraph['position'][$i] ) );
404
+ } elseif( $paragraph['end_post'][$i] ) {
405
+ $content = implode( $sch, $paragraphsArray ) . '<!--' . $paragraph[$i] . '-->';
406
+ }
407
+
408
+ /**
409
+ * Put back blockquotes into content
410
+ */
411
+
412
+ if(!empty($blockquotes)){
413
+ $bId = 0;
414
+ foreach($blockquotes[0] as $blockquote){
415
+ $search = '#QUADSBLOCKQUOTE' . $bId . '#';
416
+ $content = str_replace($search, trim($blockquote), $content);
417
+ $bId++;
418
+ }
419
+ }
420
+ }
421
+ }
422
+
423
+ // Check if image ad is random one
424
+ if( $imageAdNo == 0 ) {
425
+ $imageAd = $cusrnd;
426
+ } else {
427
+ $imageAd = $cusads . $imageAdNo;
428
+ array_push( $adsArrayCus, $imageAdNo );
429
+ };
430
+
431
+
432
+ // Beginning of post ad
433
+ if( $beginning_position_status && strpos( $content, '<!--OffBegin-->' ) === false ) {
434
+ $content = '<!--' . $b1 . '-->' . $content;
435
+ }
436
+
437
+ // Check if ad is middle one
438
+ if( $middle_position_status && strpos( $content, '<!--OffMiddle-->' ) === false ) {
439
+ if( substr_count( strtolower( $content ), '</p>' ) >= 2 ) {
440
+ $closingTagP = "</p>";
441
+ $content = str_replace( "</P>", $closingTagP, $content );
442
+ $paragraphsArray = explode( $closingTagP, $content );
443
+
444
+ /**
445
+ * Check if last element is empty and remove it
446
+ */
447
+ if(trim($paragraphsArray[count($paragraphsArray)-1]) == "") array_pop($paragraphsArray);
448
+
449
+ $nn = 0;
450
+ $mm = strlen( $content ) / 2;
451
+ for ( $i = 0; $i < count( $paragraphsArray ); $i++ ) {
452
+ $nn += strlen( $paragraphsArray[$i] ) + 4;
453
+ if( $nn > $mm ) {
454
+ if( ($mm - ($nn - strlen( $paragraphsArray[$i] ))) > ($nn - $mm) && $i + 1 < count( $paragraphsArray ) ) {
455
+ $paragraphsArray[$i + 1] = '<!--' . $m1 . '-->' . $paragraphsArray[$i + 1];
456
+ } else {
457
+ $paragraphsArray[$i] = '<!--' . $m1 . '-->' . $paragraphsArray[$i];
458
+ }
459
+ break;
460
+ }
461
+ }
462
+ $content = implode( $closingTagP, $paragraphsArray );
463
+ }
464
+ }
465
+
466
+ // End of Post ad
467
+ if( $end_position_status && strpos( $content, '<!--OffEnd-->' ) === false ) {
468
+ $content = $content . '<!--' . $b2 . '-->';
469
+ }
470
+
471
+
472
+
473
+ // Check if ad is after "More Tag"
474
+ if( $more_position_status && strpos( $content, '<!--OffAfMore-->' ) === false ) {
475
+ $mmr = '<!--' . $r1 . '-->';
476
+ $postid = get_the_ID();
477
+ $content = str_replace( '<span id="more-' . $postid . '"></span>', $mmr, $content );
478
+ }
479
+
480
+ // Right before last paragraph ad
481
+ if( $last_paragraph_position_status && strpos( $content, '<!--OffBfLastPara-->' ) === false ) {
482
+ $closingTagP = "</p>";
483
+ $content = str_replace( "</P>", $closingTagP, $content );
484
+ $paragraphsArray = explode( $closingTagP, $content );
485
+
486
+
487
+ /**
488
+ * Check if last element is empty and remove it
489
+ */
490
+ if(trim($paragraphsArray[count($paragraphsArray)-1]) == "") array_pop($paragraphsArray);
491
+
492
+
493
+ //if( count( $paragraphsArray ) > 2 && !strpos($paragraphsArray[count( $paragraphsArray ) - 1], '</blockquote>')) {
494
+ if( count( $paragraphsArray ) > 2) {
495
+ $content = implode( $closingTagP, array_slice( $paragraphsArray, 0, count( $paragraphsArray ) - 1 ) ) . '<!--' . $g1 . '-->' . $closingTagP . $paragraphsArray[count( $paragraphsArray ) - 1];
496
+ }
497
+
498
+ }
499
+
500
+ // After Image ad
501
+ if( $imageActive ) {
502
+
503
+ // Sanitation
504
+ $imgtag = "<img";
505
+ $delimiter = ">";
506
+ $caption = "[/caption]";
507
+ $atag = "</a>";
508
+ $content = str_replace( "<IMG", $imgtag, $content );
509
+ $content = str_replace( "</A>", $atag, $content );
510
+
511
+ // Get all images in content
512
+ $imagesArray = explode( $imgtag, $content );
513
+ // Modify Image ad
514
+ if( ( int ) $imageNo < count( $imagesArray ) ) {
515
+ //Get all tags
516
+ $tagsArray = explode( $delimiter, $imagesArray[$imageNo] );
517
+ if( count( $tagsArray ) > 1 ) {
518
+ $captionArray = explode( $caption, $imagesArray[$imageNo] );
519
+ $ccp = ( count( $captionArray ) > 1 ) ? strpos( strtolower( $captionArray[0] ), '[caption ' ) === false : false;
520
+ $imagesArrayAtag = explode( $atag, $imagesArray[$imageNo] );
521
+ $cdu = ( count( $imagesArrayAtag ) > 1 ) ? strpos( strtolower( $imagesArrayAtag[0] ), '<a href' ) === false : false;
522
+ // Show ad after caption
523
+ if( $imageCaption && $ccp ) {
524
+ $imagesArray[$imageNo] = implode( $caption, array_slice( $captionArray, 0, 1 ) ) . $caption . "\r\n" . '<!--' . $imageAd . '-->' . "\r\n" . implode( $caption, array_slice( $captionArray, 1 ) );
525
+ } else if( $cdu ) {
526
+ $imagesArray[$imageNo] = implode( $atag, array_slice( $imagesArrayAtag, 0, 1 ) ) . $atag . "\r\n" . '<!--' . $imageAd . '-->' . "\r\n" . implode( $atag, array_slice( $imagesArrayAtag, 1 ) );
527
+ } else {
528
+ $imagesArray[$imageNo] = implode( $delimiter, array_slice( $tagsArray, 0, 1 ) ) . $delimiter . "\r\n" . '<!--' . $imageAd . '-->' . "\r\n" . implode( $delimiter, array_slice( $tagsArray, 1 ) );
529
+ }
530
+ }
531
+ $content = implode( $imgtag, $imagesArray );
532
+ }
533
+ }
534
+
535
+ return $content;
536
+ }
537
+ /**
538
+ * Sanitize content and return it cleaned
539
+ *
540
+ * @param string $content
541
+ * @return string
542
+ */
543
+ function quads_sanitize_content($content){
544
+
545
+ /* ... Tidy up content ... */
546
+ // Replace all <p></p> tags with placeholder ##QA-TP1##
547
+ $content = str_replace( "<p></p>", "##QA-TP1##", $content );
548
+
549
+ // Replace all <p>&nbsp;</p> tags with placeholder ##QA-TP2##
550
+ $content = str_replace( "<p>&nbsp;</p>", "##QA-TP2##", $content );
551
+
552
+ return $content;
553
+ }
554
+
555
+
556
+
557
+ /**
558
+ * Parse random ads which are created from quicktag <!--RndAds-->
559
+ *
560
+ * @global array $adsArray
561
+ * @global int $visibleContentAds
562
+ * @return content
563
+ */
564
+ function quads_parse_random_quicktag_ads($content){
565
+ global $adsArray, $visibleContentAds, $quads_options;
566
+
567
+ $maxAds = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
568
+ /*
569
+ * Replace RndAds Random Ads
570
+ */
571
+ if( strpos( $content, '<!--RndAds-->' ) !== false && is_singular() ) {
572
+ $adsArrayTmp = array();
573
+ shuffle( $adsArray );
574
+ for ( $i = 1; $i <= $maxAds - $visibleContentAds; $i++ ) {
575
+ if( $i <= count( $adsArray ) ) {
576
+ array_push( $adsArrayTmp, $adsArray[$i - 1] );
577
+ }
578
+ }
579
+ $tcx = count( $adsArrayTmp );
580
+ $tcy = substr_count( $content, '<!--RndAds-->' );
581
+ for ( $i = $tcx; $i <= $tcy - 1; $i++ ) {
582
+ array_push( $adsArrayTmp, -1 );
583
+ }
584
+ shuffle( $adsArrayTmp );
585
+ for ( $i = 1; $i <= $tcy; $i++ ) {
586
+ $tmp = $adsArrayTmp[0];
587
+ $content = quads_replace_ads( $content, 'RndAds', $adsArrayTmp[0] );
588
+ $adsArrayTmp = quads_del_element( $adsArrayTmp, 0 );
589
+ if( $tmp != -1 ) {
590
+ $visibleContentAds += 1;
591
+ };
592
+ //quads_set_ad_count_content();
593
+ //if( quads_ad_reach_max_count() ) {
594
+ if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
595
+ $content = quads_clean_tags( $content );
596
+ return $content;
597
+ }
598
+ }
599
+ }
600
+
601
+ return $content;
602
+ }
603
+
604
+ /**
605
+ * Parse random default ads which can be enabled from general settings
606
+ *
607
+ * @global array $adsArray
608
+ * @global int $visibleContentAds
609
+ * @return string
610
+ */
611
+ function quads_parse_random_ads($content) {
612
+ global $adsRandom, $visibleContentAds;
613
+
614
+ $off_default_ads = (strpos( $content, '<!--OffDef-->' ) !== false);
615
+ if( $off_default_ads ) { // disabled default ads
616
+ return $content;
617
+ }
618
+
619
+ if( strpos( $content, '<!--CusRnd-->' ) !== false && is_singular() ) {
620
+
621
+ $tcx = count( $adsRandom );
622
+ // How often is a random ad appearing in content
623
+ $number_rand_ads = substr_count( $content, '<!--CusRnd-->' );
624
+
625
+ for ( $i = $tcx; $i <= $number_rand_ads - 1; $i++ ) {
626
+ array_push( $adsRandom, -1 );
627
+ }
628
+ shuffle( $adsRandom );
629
+ //wp_die(print_r($adsRandom));
630
+ //wp_die($adsRandom[0]);
631
+ for ( $i = 1; $i <= $number_rand_ads; $i++ ) {
632
+ $content = quads_replace_ads( $content, 'CusRnd', $adsRandom[0] );
633
+ $adsRandom = quads_del_element( $adsRandom, 0 );
634
+ $visibleContentAds += 1;
635
+ //quads_set_ad_count_content();
636
+ //if( quads_ad_reach_max_count() ) {
637
+ if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
638
+ $content = quads_clean_tags( $content );
639
+ return $content;
640
+ }
641
+ }
642
+ }
643
+
644
+ return $content;
645
+ }
646
+
647
+ /**
648
+ * Parse Quicktags
649
+ *
650
+ * @global array $adsArray
651
+ * @param string $content
652
+ * @return string
653
+ */
654
+ function quads_parse_quicktags($content){
655
+ global $adsArray, $visibleContentAds;
656
+ //print_r(count($adsArray));
657
+
658
+ $idx = 0;
659
+ for ( $i = 1; $i <= count( $adsArray ); $i++ ) {
660
+ if( strpos( $content, '<!--Ads' . $adsArray[$idx] . '-->' ) !== false ) {
661
+ $content = quads_replace_ads( $content, 'Ads' . $adsArray[$idx], $adsArray[$idx] );
662
+ //$adsArray = quads_del_element( $adsArray, $idx );
663
+ $visibleContentAds += 1;
664
+ $idx +=1;
665
+ //quads_set_ad_count_content();
666
+ if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
667
+ $content = quads_clean_tags( $content );
668
+ return $content;
669
+ }
670
+ } else {
671
+ $idx += 1;
672
+ }
673
+ }
674
+
675
+ return $content;
676
+ }
677
+
678
+ /**
679
+ * Parse default ads Beginning/Middle/End/Paragraph Ads1-10
680
+ *
681
+ * @param string $content
682
+ * @return string
683
+ */
684
+ function quads_parse_default_ads( $content ) {
685
+ global $adsArrayCus, $adsRandom, $adsArray, $visibleContentAds;
686
+
687
+ $off_default_ads = (strpos( $content, '<!--OffDef-->' ) !== false);
688
+
689
+ if( $off_default_ads ) { // disabled default ads
690
+ return $content;
691
+ }
692
+ // Create the array which contains the random ads
693
+ $adsRandom = $adsArray;
694
+
695
+ // echo '<pre>';
696
+ // echo 'adsArrayCus: ';
697
+ // print_r($adsArrayCus);
698
+ // echo 'adsArray: ';
699
+ // print_r( $adsArray );
700
+ // echo '</pre>';
701
+
702
+ for ( $i = 0; $i <= count( $adsArrayCus ); $i++ ) {
703
+ if( isset( $adsArrayCus[$i] ) && strpos( $content, '<!--CusAds' . $adsArrayCus[$i] . '-->' ) !== false && in_array( $adsArrayCus[$i], $adsArray ) ) {
704
+ $content = quads_replace_ads( $content, 'CusAds' . $adsArrayCus[$i], $adsArrayCus[$i] );
705
+ // Create array $adsRandom for quads_parse_random_ads() parsing functions to make sure that the random function
706
+ // is never using ads that are already used on static ad spots which are generated with quads_parse_default_ads()
707
+ if ($i == 0){
708
+ $adsRandom = quads_del_element($adsRandom, array_search($adsArrayCus[$i], $adsRandom));
709
+ }else{
710
+ $adsRandom = quads_del_element($adsRandom, array_search($adsArrayCus[$i-1], $adsRandom));
711
+ }
712
+
713
+ $visibleContentAds += 1;
714
+ //quads_set_ad_count_content();
715
+ //if( quads_ad_reach_max_count() || $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
716
+ //wp_die(quads_get_max_allowed_post_ads( $content ));
717
+ if( $visibleContentAds >= quads_get_max_allowed_post_ads( $content ) ) {
718
+ $content = quads_clean_tags( $content );
719
+ }
720
+ }
721
+ }
722
+ return $content;
723
+ }
724
+
725
+ /**
726
+ * Replace ad code in content
727
+ *
728
+ * @global type $quads_options
729
+ * @param string $content
730
+ * @param string $quicktag Quicktag
731
+ * @param string $id id of the ad
732
+ * @return type
733
+ */
734
+ function quads_replace_ads($content, $quicktag, $id) {
735
+ global $quads_options;
736
+
737
+
738
+ if( strpos($content,'<!--'.$quicktag.'-->')===false ) {
739
+ return $content;
740
+ }
741
+
742
+
743
+ if ($id != -1) {
744
+
745
+ $code = !empty($quads_options['ads']['ad' . $id ]['code']) ? $quads_options['ads']['ad' . $id ]['code'] : '';
746
+ $style = quads_get_inline_ad_style($id);
747
+ $adscode =
748
+ "\n".'<!-- WP QUADS Content Ad Plugin v. ' . QUADS_VERSION .' -->'."\n".
749
+ '<div class="quads-location quads-ad' .$id. '" id="quads-ad' .$id. '" style="'.$style.'">'."\n".
750
+ quads_render_ad('ad'.$id, $code)."\n".
751
+ '</div>'. "\n";
752
+
753
+ } else {
754
+ $adscode ='';
755
+ }
756
+ $cont = explode('<!--'.$quicktag.'-->', $content, 2);
757
+
758
+ return $cont[0].$adscode.$cont[1];
759
+ }
760
+
761
+ /**
762
+ * Get ad inline style
763
+ *
764
+ * @global arr $quads_options
765
+ * @param int $id id of the ad
766
+ * @return string
767
+ */
768
+ function quads_get_inline_ad_style( $id ) {
769
+ global $quads_options;
770
+
771
+ if( empty($id) ) {
772
+ return '';
773
+ }
774
+
775
+ // Basic style
776
+ $styleArray = array(
777
+ 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
778
+ 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
779
+ 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
780
+ 'float:none;margin:%1$dpx;');
781
+
782
+ // Alignment
783
+ $adsalign = ( int )$quads_options['ads']['ad' . $id]['align'];
784
+
785
+ // Margin
786
+ $adsmargin = isset( $quads_options['ads']['ad' . $id]['margin'] ) ? $quads_options['ads']['ad' . $id]['margin'] : '3'; // default option = 3
787
+ $margin = sprintf( $styleArray[$adsalign], $adsmargin );
788
+
789
+ //wp_die($quads_options['ads']['ad' . $id]['margin']);
790
+ //wp_die('ad'.$id);
791
+
792
+ // Do not create any inline style on AMP site
793
+ $style = !quads_is_amp_endpoint() ? apply_filters( 'quads_filter_margins', $margin, 'ad' . $id ) : '';
794
+
795
+ return $style;
796
+ }
797
+
798
+ /**
799
+ * Revert content to original content any remove any processing helper strings
800
+ *
801
+ * @global int $visibleContentAds
802
+ * @global array $adsArray
803
+ * @global array $quads_options
804
+ * @global int $ad_count
805
+ * @param string $content
806
+ * @param boolean $trimonly
807
+ *
808
+ * @return string content
809
+ */
810
+ function quads_clean_tags($content, $trimonly = false) {
811
+ global $visibleContentAds;
812
+ global $adsArray;
813
+ global $quads_options;
814
+ global $ad_count;
815
+
816
+ $tagnames = array('EmptyClear','RndAds','NoAds','OffDef','OffAds','OffWidget','OffBegin','OffMiddle','OffEnd','OffBfMore','OffAfLastPara','CusRnd');
817
+
818
+ for($i=1;$i<=10;$i++) {
819
+ array_push($tagnames, 'CusAds'.$i);
820
+ array_push($tagnames, 'Ads'.$i);
821
+ };
822
+
823
+
824
+ foreach ($tagnames as $tags) {
825
+ if(strpos($content,'<!--'.$tags.'-->')!==false || $tags=='EmptyClear') {
826
+ if($trimonly) {
827
+ $content = str_replace('<p><!--'.$tags.'--></p>', '<!--'.$tags.'-->', $content);
828
+ }else{
829
+ $content = str_replace(array('<p><!--'.$tags.'--></p>','<!--'.$tags.'-->'), '', $content);
830
+ $content = str_replace("##QA-TP1##", "<p></p>", $content);
831
+ $content = str_replace("##QA-TP2##", "<p>&nbsp;</p>", $content);
832
+ }
833
+ }
834
+ }
835
+ if(!$trimonly && (is_single() || is_page()) ) {
836
+ $visibleContentAds = 0;
837
+ $adsArray = array();
838
+ }
839
+ return $content;
840
+ }
841
+
842
+
843
+
844
+ /**
845
+ * Remove element from array
846
+ *
847
+ * @param array $paragraphsArrayay
848
+ * @param int $idx key to remove from array
849
+ * @return array
850
+ */
851
+ function quads_del_element($array, $idx) {
852
+ $copy = array();
853
+ for( $i=0; $i<count($array) ;$i++) {
854
+ if ( $idx != $i ) {
855
+ array_push($copy, $array[$i]);
856
+ }
857
+ }
858
+ return $copy;
859
  }
includes/vendor/google/adsense.php CHANGED
@@ -1,162 +1,162 @@
1
- <?php
2
-
3
- namespace wpquads;
4
-
5
- /*
6
- * Google AdSense integration for WP QUADS
7
- * @author René Hermenau
8
- * @email info@mashshare.net
9
- *
10
- */
11
-
12
- /**
13
- * Main class for wp quads google adsense integration
14
- *
15
- * @author René Hermenau
16
- */
17
- class adsense {
18
-
19
- /**
20
- * Settings
21
- * @var array
22
- */
23
- private $settings;
24
-
25
- public $publisherIds = array();
26
-
27
- public function __construct($settings) {
28
- $this->settings = $settings;
29
- $this->setPublisherID();
30
- }
31
-
32
- /**
33
- * Get AdSense Publisher ID
34
- * @return string
35
- */
36
- public function setPublisherID() {
37
-
38
- if (!isset($this->settings['ads'])){
39
- $this->publisherIds[] = '';
40
- return $this->publisherIds;
41
-
42
- }
43
-
44
- // loop through all adsense g_data_ad_client fields and check if there is any adsense publisher id
45
- foreach ($this->settings['ads'] as $key => $value) {
46
- if (!empty($value['g_data_ad_client'])){
47
- $this->publisherIds[] = $value['g_data_ad_client'];
48
- }
49
- }
50
-
51
- // Loop through all other possible ad codes and check if there is any possible google publisher id
52
- $quads_options = $this->settings;
53
-
54
- foreach ($quads_options as $id => $ads) {
55
- if (!is_array($ads)) {
56
- continue;
57
- }
58
- foreach ($ads as $key => $value) {
59
- if (is_array($value) && array_key_exists('code', $value) && !empty($value['code'])) {
60
-
61
- // Check to see if it is google ad
62
- if (preg_match('/googlesyndication.com/', $value['code'])) {
63
-
64
- // Test if its google asyncron ad
65
- if (preg_match('/data-ad-client=/', $value['code'])) {
66
- //*** GOOGLE ASYNCRON *************
67
- //get g_data_ad_client
68
- $explode_ad_code = explode('data-ad-client', $value['code']);
69
- preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
70
- if(isset($matches_add_client[1])){
71
- $this->publisherIds[] = str_replace(array('"', ' '), array(''), $matches_add_client[1]);
72
- }
73
- } else {
74
- //*** GOOGLE SYNCRON *************
75
- //get g_data_ad_client
76
- $explode_ad_code = explode('google_ad_client', $value['code']);
77
- preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
78
- if(isset($matches_add_client[1])){
79
- $this->publisherIds[] = str_replace(array('"', ' '), array(''), $matches_add_client[1]);
80
- }
81
- }
82
- }
83
- }
84
- }
85
- }
86
-
87
- return $this->publisherIds;
88
- }
89
- // public function setPublisherID() {
90
- // // loop through all adsense g_data_ad_client fields and check if there is any adsense publisher id
91
- // foreach ($this->settings['ads'] as $key => $value) {
92
- // if (!empty($value['g_data_ad_client'])){
93
- // return $value['g_data_ad_client'];
94
- // }
95
- // }
96
- //
97
- // // Loop through all other possible ad codes and check if there is any possible google publisher id
98
- // $quads_options = $this->settings;
99
- //
100
- // foreach ($quads_options as $id => $ads) {
101
- // if (!is_array($ads)) {
102
- // continue;
103
- // }
104
- // foreach ($ads as $key => $value) {
105
- // if (is_array($value) && array_key_exists('code', $value) && !empty($value['code'])) {
106
- //
107
- // // Check to see if it is google ad
108
- // if (preg_match('/googlesyndication.com/', $value['code'])) {
109
- //
110
- // // Test if its google asyncron ad
111
- // if (preg_match('/data-ad-client=/', $value['code'])) {
112
- // //*** GOOGLE ASYNCRON *************
113
- // //get g_data_ad_client
114
- // $explode_ad_code = explode('data-ad-client', $value['code']);
115
- // preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
116
- // return str_replace(array('"', ' '), array(''), $matches_add_client[1]);
117
- // } else {
118
- // //*** GOOGLE SYNCRON *************
119
- // //get g_data_ad_client
120
- // $explode_ad_code = explode('google_ad_client', $value['code']);
121
- // preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
122
- // return str_replace(array('"', ' '), array(''), $matches_add_client[1]);
123
- // }
124
- // }
125
- // }
126
- // }
127
- // }
128
- //
129
- // return '';
130
- // }
131
-
132
-
133
- public function getPublisherIds(){
134
- return array_unique($this->publisherIds);
135
- }
136
-
137
-
138
- /**
139
- * Write ads.txt
140
- * @return boolean
141
- */
142
- public function writeAdsTxt(){
143
-
144
- // if (!isset($this->settings['adsTxtEnabled'])){
145
- // return false;
146
- // }
147
-
148
- $publisherIds = $this->getPublisherIds();
149
-
150
- if (empty($publisherIds)){
151
- return false;
152
- }
153
-
154
- foreach ($publisherIds as $publisherId){
155
- $content = 'google.com, ' . str_replace('ca-', '', $publisherId) . ', DIRECT, f08c47fec0942fa0';
156
- $adsTxt = new adsTxt($content, $content);
157
- $adsTxt->writeAdsTxt();
158
- }
159
- return true;
160
- }
161
-
162
- }
1
+ <?php
2
+
3
+ namespace wpquads;
4
+
5
+ /*
6
+ * Google AdSense integration for WP QUADS
7
+ * @author René Hermenau
8
+ * @email info@mashshare.net
9
+ *
10
+ */
11
+
12
+ /**
13
+ * Main class for wp quads google adsense integration
14
+ *
15
+ * @author René Hermenau
16
+ */
17
+ class adsense {
18
+
19
+ /**
20
+ * Settings
21
+ * @var array
22
+ */
23
+ private $settings;
24
+
25
+ public $publisherIds = array();
26
+
27
+ public function __construct($settings) {
28
+ $this->settings = $settings;
29
+ $this->setPublisherID();
30
+ }
31
+
32
+ /**
33
+ * Get AdSense Publisher ID
34
+ * @return string
35
+ */
36
+ public function setPublisherID() {
37
+
38
+ if (!isset($this->settings['ads'])){
39
+ $this->publisherIds[] = '';
40
+ return $this->publisherIds;
41
+
42
+ }
43
+
44
+ // loop through all adsense g_data_ad_client fields and check if there is any adsense publisher id
45
+ foreach ($this->settings['ads'] as $key => $value) {
46
+ if (!empty($value['g_data_ad_client'])){
47
+ $this->publisherIds[] = $value['g_data_ad_client'];
48
+ }
49
+ }
50
+
51
+ // Loop through all other possible ad codes and check if there is any possible google publisher id
52
+ $quads_options = $this->settings;
53
+
54
+ foreach ($quads_options as $id => $ads) {
55
+ if (!is_array($ads)) {
56
+ continue;
57
+ }
58
+ foreach ($ads as $key => $value) {
59
+ if (is_array($value) && array_key_exists('code', $value) && !empty($value['code'])) {
60
+
61
+ // Check to see if it is google ad
62
+ if (preg_match('/googlesyndication.com/', $value['code'])) {
63
+
64
+ // Test if its google asyncron ad
65
+ if (preg_match('/data-ad-client=/', $value['code'])) {
66
+ //*** GOOGLE ASYNCRON *************
67
+ //get g_data_ad_client
68
+ $explode_ad_code = explode('data-ad-client', $value['code']);
69
+ preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
70
+ if(isset($matches_add_client[1])){
71
+ $this->publisherIds[] = str_replace(array('"', ' '), array(''), $matches_add_client[1]);
72
+ }
73
+ } else {
74
+ //*** GOOGLE SYNCRON *************
75
+ //get g_data_ad_client
76
+ $explode_ad_code = explode('google_ad_client', $value['code']);
77
+ preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
78
+ if(isset($matches_add_client[1])){
79
+ $this->publisherIds[] = str_replace(array('"', ' '), array(''), $matches_add_client[1]);
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+
87
+ return $this->publisherIds;
88
+ }
89
+ // public function setPublisherID() {
90
+ // // loop through all adsense g_data_ad_client fields and check if there is any adsense publisher id
91
+ // foreach ($this->settings['ads'] as $key => $value) {
92
+ // if (!empty($value['g_data_ad_client'])){
93
+ // return $value['g_data_ad_client'];
94
+ // }
95
+ // }
96
+ //
97
+ // // Loop through all other possible ad codes and check if there is any possible google publisher id
98
+ // $quads_options = $this->settings;
99
+ //
100
+ // foreach ($quads_options as $id => $ads) {
101
+ // if (!is_array($ads)) {
102
+ // continue;
103
+ // }
104
+ // foreach ($ads as $key => $value) {
105
+ // if (is_array($value) && array_key_exists('code', $value) && !empty($value['code'])) {
106
+ //
107
+ // // Check to see if it is google ad
108
+ // if (preg_match('/googlesyndication.com/', $value['code'])) {
109
+ //
110
+ // // Test if its google asyncron ad
111
+ // if (preg_match('/data-ad-client=/', $value['code'])) {
112
+ // //*** GOOGLE ASYNCRON *************
113
+ // //get g_data_ad_client
114
+ // $explode_ad_code = explode('data-ad-client', $value['code']);
115
+ // preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
116
+ // return str_replace(array('"', ' '), array(''), $matches_add_client[1]);
117
+ // } else {
118
+ // //*** GOOGLE SYNCRON *************
119
+ // //get g_data_ad_client
120
+ // $explode_ad_code = explode('google_ad_client', $value['code']);
121
+ // preg_match('#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client);
122
+ // return str_replace(array('"', ' '), array(''), $matches_add_client[1]);
123
+ // }
124
+ // }
125
+ // }
126
+ // }
127
+ // }
128
+ //
129
+ // return '';
130
+ // }
131
+
132
+
133
+ public function getPublisherIds(){
134
+ return array_unique($this->publisherIds);
135
+ }
136
+
137
+
138
+ /**
139
+ * Write ads.txt
140
+ * @return boolean
141
+ */
142
+ public function writeAdsTxt(){
143
+
144
+ // if (!isset($this->settings['adsTxtEnabled'])){
145
+ // return false;
146
+ // }
147
+
148
+ $publisherIds = $this->getPublisherIds();
149
+
150
+ if (empty($publisherIds)){
151
+ return false;
152
+ }
153
+
154
+ foreach ($publisherIds as $publisherId){
155
+ $content = 'google.com, ' . str_replace('ca-', '', $publisherId) . ', DIRECT, f08c47fec0942fa0';
156
+ $adsTxt = new adsTxt($content, $content);
157
+ $adsTxt->writeAdsTxt();
158
+ }
159
+ return true;
160
+ }
161
+
162
+ }
includes/vendor/vi/conditions.php CHANGED
@@ -1,187 +1,187 @@
1
- <?php
2
-
3
- namespace wpquads\conditions;
4
-
5
- /*
6
- * vi conditions for WP QUADS
7
- * @author René Hermenau
8
- * @email info@mashshare.net
9
- *
10
- */
11
-
12
- class conditions {
13
-
14
- /**
15
- * global options
16
- * @global array $quads_options
17
- * @return boolean
18
- */
19
- protected function isExcluded() {
20
- global $quads_options;
21
-
22
- /**
23
- * Ad specific options
24
- */
25
-
26
- // User logged in
27
- if (is_user_logged_in() && ( isset($quads_options['visibility']['AppLogg'])))
28
- return true;
29
-
30
- // Is frontpage
31
- if (is_front_page() &&
32
- isset($this->ads['ads'][$this->id]['excludedExtraPages']) &&
33
- in_array('homePage', $this->ads['ads'][$this->id]['excludedExtraPages']))
34
- return true;
35
-
36
-
37
- if (quads_is_amp_endpoint())
38
- return true;
39
-
40
- if ($this->isExcludedUserRole())
41
- return true;
42
-
43
- if ($this->isExcludedPostTypes())
44
- return true;
45
-
46
- if ($this->isExcludedPageId())
47
- return true;
48
-
49
- if ($this->isExcludedByMetaKey())
50
- return true;
51
-
52
- /**
53
- * Global options
54
- */
55
-
56
- // Is feed
57
- if (is_feed()) {
58
- return true;
59
- }
60
-
61
- // Is search
62
- if (is_search()) {
63
- return true;
64
- }
65
-
66
- // Is 404
67
- if (is_404()) {
68
- return true;
69
- }
70
-
71
- // Is category
72
- if (is_category()) {
73
- return true;
74
- }
75
- // Is archive page
76
- if (is_archive()) {
77
- return true;
78
- }
79
-
80
- // Default
81
- return false;
82
- }
83
-
84
- /**
85
- * Excluded user roles
86
- * @return boolean
87
- */
88
- private function isExcludedUserRole() {
89
-
90
- if (!isset($this->ads['ads'][$this->id]['excludedUserRoles']) ||
91
- empty($this->ads['ads'][$this->id]['excludedUserRoles'])
92
- ) {
93
- return false;
94
- }
95
-
96
- if (isset($this->ads['ads'][$this->id]['excludedUserRoles']) &&
97
- count(array_intersect($this->ads['ads'][$this->id]['excludedUserRoles'], wp_get_current_user()->roles)) >= 1) {
98
- return true;
99
- }
100
-
101
- return false;
102
- }
103
-
104
- /**
105
- * Check if post id is excluded
106
- * @global array $post
107
- * @return boolean
108
- */
109
- private function isExcludedPageId() {
110
- global $post;
111
-
112
-
113
- if (!isset($post->ID)) {
114
- return true;
115
- }
116
-
117
- if (!isset($this->ads['ads'][$this->id]['excludedPostIds']) ||
118
- empty($this->ads['ads'][$this->id]['excludedPostIds'])
119
- ) {
120
- return false;
121
- }
122
-
123
- if (strpos($this->ads['ads'][$this->id]['excludedPostIds'], ',') !== false) {
124
- $excluded = explode(',', $this->ads['ads'][$this->id]['excludedPostIds']);
125
- if (in_array($post->ID, $excluded)) {
126
- return true;
127
- }
128
- }
129
- if ($post->ID == $this->ads['ads'][$this->id]['excludedPostIds']) {
130
- return true;
131
- }
132
-
133
- // default condition
134
- return false;
135
- }
136
-
137
- /**
138
- * Check if ad is allowed on specific post_type
139
- *
140
- * @global array $quads_options
141
- * @global array $post
142
- * @return boolean true if post_type is allowed
143
- */
144
- private function isExcludedPostTypes() {
145
- global $post;
146
-
147
- if (!isset($post)) {
148
- return true;
149
- }
150
-
151
- if (!isset($this->ads['ads'][$this->id]['excludedPostTypes']) ||
152
- empty($this->ads['ads'][$this->id]['excludedPostTypes']) ||
153
- !is_array($this->ads['ads'][$this->id]['excludedPostTypes']) ||
154
- $this->ads['ads'][$this->id]['excludedPostTypes'] == 'noPostTypes'
155
- ) {
156
- return false;
157
- }
158
-
159
- $current_post_type = get_post_type($post->ID);
160
- if (in_array($current_post_type, $this->ads['ads'][$this->id]['excludedPostTypes'])) {
161
- return true;
162
- }
163
-
164
- return false;
165
- }
166
-
167
- /**
168
- * Check if ad is deactivated by wp quads meta settings in post editor
169
- * @return boolean
170
- */
171
- private function isExcludedByMetaKey() {
172
- global $post;
173
-
174
- if (!isset($post->ID))
175
- return false;
176
-
177
- $value_arr = get_post_meta($post->ID, '_quads_config_visibility', true);
178
-
179
- $value_key = isset($value_arr['NoAds']) ? $value_arr['NoAds'] : null;
180
-
181
- if (!empty($value_key) && $value_key == 1) {
182
- return true;
183
- }
184
- return false;
185
- }
186
-
187
- }
1
+ <?php
2
+
3
+ namespace wpquads\conditions;
4
+
5
+ /*
6
+ * vi conditions for WP QUADS
7
+ * @author René Hermenau
8
+ * @email info@mashshare.net
9
+ *
10
+ */
11
+
12
+ class conditions {
13
+
14
+ /**
15
+ * global options
16
+ * @global array $quads_options
17
+ * @return boolean
18
+ */
19
+ protected function isExcluded() {
20
+ global $quads_options;
21
+
22
+ /**
23
+ * Ad specific options
24
+ */
25
+
26
+ // User logged in
27
+ if (is_user_logged_in() && ( isset($quads_options['visibility']['AppLogg'])))
28
+ return true;
29
+
30
+ // Is frontpage
31
+ if (is_front_page() &&
32
+ isset($this->ads['ads'][$this->id]['excludedExtraPages']) &&
33
+ in_array('homePage', $this->ads['ads'][$this->id]['excludedExtraPages']))
34
+ return true;
35
+
36
+
37
+ if (quads_is_amp_endpoint())
38
+ return true;
39
+
40
+ if ($this->isExcludedUserRole())
41
+ return true;
42
+
43
+ if ($this->isExcludedPostTypes())
44
+ return true;
45
+
46
+ if ($this->isExcludedPageId())
47
+ return true;
48
+
49
+ if ($this->isExcludedByMetaKey())
50
+ return true;
51
+
52
+ /**
53
+ * Global options
54
+ */
55
+
56
+ // Is feed
57
+ if (is_feed()) {
58
+ return true;
59
+ }
60
+
61
+ // Is search
62
+ if (is_search()) {
63
+ return true;
64
+ }
65
+
66
+ // Is 404
67
+ if (is_404()) {
68
+ return true;
69
+ }
70
+
71
+ // Is category
72
+ if (is_category()) {
73
+ return true;
74
+ }
75
+ // Is archive page
76
+ if (is_archive()) {
77
+ return true;
78
+ }
79
+
80
+ // Default
81
+ return false;
82
+ }
83
+
84
+ /**
85
+ * Excluded user roles
86
+ * @return boolean
87
+ */
88
+ private function isExcludedUserRole() {
89
+
90
+ if (!isset($this->ads['ads'][$this->id]['excludedUserRoles']) ||
91
+ empty($this->ads['ads'][$this->id]['excludedUserRoles'])
92
+ ) {
93
+ return false;
94
+ }
95
+
96
+ if (isset($this->ads['ads'][$this->id]['excludedUserRoles']) &&
97
+ count(array_intersect($this->ads['ads'][$this->id]['excludedUserRoles'], wp_get_current_user()->roles)) >= 1) {
98
+ return true;
99
+ }
100
+
101
+ return false;
102
+ }
103
+
104
+ /**
105
+ * Check if post id is excluded
106
+ * @global array $post
107
+ * @return boolean
108
+ */
109
+ private function isExcludedPageId() {
110
+ global $post;
111
+
112
+
113
+ if (!isset($post->ID)) {
114
+ return true;
115
+ }
116
+
117
+ if (!isset($this->ads['ads'][$this->id]['excludedPostIds']) ||
118
+ empty($this->ads['ads'][$this->id]['excludedPostIds'])
119
+ ) {
120
+ return false;
121
+ }
122
+
123
+ if (strpos($this->ads['ads'][$this->id]['excludedPostIds'], ',') !== false) {
124
+ $excluded = explode(',', $this->ads['ads'][$this->id]['excludedPostIds']);
125
+ if (in_array($post->ID, $excluded)) {
126
+ return true;
127
+ }
128
+ }
129
+ if ($post->ID == $this->ads['ads'][$this->id]['excludedPostIds']) {
130
+ return true;
131
+ }
132
+
133
+ // default condition
134
+ return false;
135
+ }
136
+
137
+ /**
138
+ * Check if ad is allowed on specific post_type
139
+ *
140
+ * @global array $quads_options
141
+ * @global array $post
142
+ * @return boolean true if post_type is allowed
143
+ */
144
+ private function isExcludedPostTypes() {
145
+ global $post;
146
+
147
+ if (!isset($post)) {
148
+ return true;
149
+ }
150
+
151
+ if (!isset($this->ads['ads'][$this->id]['excludedPostTypes']) ||
152
+ empty($this->ads['ads'][$this->id]['excludedPostTypes']) ||
153
+ !is_array($this->ads['ads'][$this->id]['excludedPostTypes']) ||
154
+ $this->ads['ads'][$this->id]['excludedPostTypes'] == 'noPostTypes'
155
+ ) {
156
+ return false;
157
+ }
158
+
159
+ $current_post_type = get_post_type($post->ID);
160
+ if (in_array($current_post_type, $this->ads['ads'][$this->id]['excludedPostTypes'])) {
161
+ return true;
162
+ }
163
+
164
+ return false;
165
+ }
166
+
167
+ /**
168
+ * Check if ad is deactivated by wp quads meta settings in post editor
169
+ * @return boolean
170
+ */
171
+ private function isExcludedByMetaKey() {
172
+ global $post;
173
+
174
+ if (!isset($post->ID))
175
+ return false;
176
+
177
+ $value_arr = get_post_meta($post->ID, '_quads_config_visibility', true);
178
+
179
+ $value_key = isset($value_arr['NoAds']) ? $value_arr['NoAds'] : null;
180
+
181
+ if (!empty($value_key) && $value_key == 1) {
182
+ return true;
183
+ }
184
+ return false;
185
+ }
186
+
187
+ }
includes/vendor/vi/public/js/vi.js CHANGED
@@ -1,204 +1,204 @@
1
- /*!
2
- * Chart.js
3
- * http://chartjs.org/
4
- * Version: 2.4.0
5
- *
6
- * Copyright 2016 Nick Downie
7
- * Released under the MIT license
8
- * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md
9
- */
10
- !function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Chart=t()}}(function(){return function t(e,a,i){function n(r,l){if(!a[r]){if(!e[r]){var s="function"==typeof require&&require;if(!l&&s)return s(r,!0);if(o)return o(r,!0);var d=new Error("Cannot find module '"+r+"'");throw d.code="MODULE_NOT_FOUND",d}var u=a[r]={exports:{}};e[r][0].call(u.exports,function(t){var a=e[r][1][t];return n(a?a:t)},u,u.exports,t,e,a,i)}return a[r].exports}for(var o="function"==typeof require&&require,r=0;r<i.length;r++)n(i[r]);return n}({1:[function(t,e,a){},{}],2:[function(t,e,a){function i(t){if(t){var e=/^#([a-fA-F0-9]{3})$/,a=/^#([a-fA-F0-9]{6})$/,i=/^rgba?\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,n=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*,\s*([+-]?[\d\.]+)\%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)$/,o=/(\w+)/,r=[0,0,0],l=1,s=t.match(e);if(s){s=s[1];for(var d=0;d<r.length;d++)r[d]=parseInt(s[d]+s[d],16)}else if(s=t.match(a)){s=s[1];for(var d=0;d<r.length;d++)r[d]=parseInt(s.slice(2*d,2*d+2),16)}else if(s=t.match(i)){for(var d=0;d<r.length;d++)r[d]=parseInt(s[d+1]);l=parseFloat(s[4])}else if(s=t.match(n)){for(var d=0;d<r.length;d++)r[d]=Math.round(2.55*parseFloat(s[d+1]));l=parseFloat(s[4])}else if(s=t.match(o)){if("transparent"==s[1])return[0,0,0,0];if(r=y[s[1]],!r)return}for(var d=0;d<r.length;d++)r[d]=v(r[d],0,255);return l=l||0==l?v(l,0,1):1,r[3]=l,r}}function n(t){if(t){var e=/^hsla?\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/,a=t.match(e);if(a){var i=parseFloat(a[4]),n=v(parseInt(a[1]),0,360),o=v(parseFloat(a[2]),0,100),r=v(parseFloat(a[3]),0,100),l=v(isNaN(i)?1:i,0,1);return[n,o,r,l]}}}function o(t){if(t){var e=/^hwb\(\s*([+-]?\d+)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?[\d\.]+)\s*)?\)/,a=t.match(e);if(a){var i=parseFloat(a[4]),n=v(parseInt(a[1]),0,360),o=v(parseFloat(a[2]),0,100),r=v(parseFloat(a[3]),0,100),l=v(isNaN(i)?1:i,0,1);return[n,o,r,l]}}}function r(t){var e=i(t);return e&&e.slice(0,3)}function l(t){var e=n(t);return e&&e.slice(0,3)}function s(t){var e=i(t);return e?e[3]:(e=n(t))?e[3]:(e=o(t))?e[3]:void 0}function d(t){return"#"+x(t[0])+x(t[1])+x(t[2])}function u(t,e){return 1>e||t[3]&&t[3]<1?c(t,e):"rgb("+t[0]+", "+t[1]+", "+t[2]+")"}function c(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"rgba("+t[0]+", "+t[1]+", "+t[2]+", "+e+")"}function h(t,e){if(1>e||t[3]&&t[3]<1)return f(t,e);var a=Math.round(t[0]/255*100),i=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgb("+a+"%, "+i+"%, "+n+"%)"}function f(t,e){var a=Math.round(t[0]/255*100),i=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return"rgba("+a+"%, "+i+"%, "+n+"%, "+(e||t[3]||1)+")"}function g(t,e){return 1>e||t[3]&&t[3]<1?p(t,e):"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)"}function p(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+e+")"}function m(t,e){return void 0===e&&(e=void 0!==t[3]?t[3]:1),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+(void 0!==e&&1!==e?", "+e:"")+")"}function b(t){return k[t.slice(0,3)]}function v(t,e,a){return Math.min(Math.max(e,t),a)}function x(t){var e=t.toString(16).toUpperCase();return e.length<2?"0"+e:e}var y=t(6);e.exports={getRgba:i,getHsla:n,getRgb:r,getHsl:l,getHwb:o,getAlpha:s,hexString:d,rgbString:u,rgbaString:c,percentString:h,percentaString:f,hslString:g,hslaString:p,hwbString:m,keyword:b};var k={};for(var S in y)k[y[S]]=S},{6:6}],3:[function(t,e,a){var i=t(5),n=t(2),o=function(t){if(t instanceof o)return t;if(!(this instanceof o))return new o(t);this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1};var e;if("string"==typeof t)if(e=n.getRgba(t))this.setValues("rgb",e);else if(e=n.getHsla(t))this.setValues("hsl",e);else{if(!(e=n.getHwb(t)))throw new Error('Unable to parse color from string "'+t+'"');this.setValues("hwb",e)}else if("object"==typeof t)if(e=t,void 0!==e.r||void 0!==e.red)this.setValues("rgb",e);else if(void 0!==e.l||void 0!==e.lightness)this.setValues("hsl",e);else if(void 0!==e.v||void 0!==e.value)this.setValues("hsv",e);else if(void 0!==e.w||void 0!==e.whiteness)this.setValues("hwb",e);else{if(void 0===e.c&&void 0===e.cyan)throw new Error("Unable to parse color from object "+JSON.stringify(t));this.setValues("cmyk",e)}};o.prototype={rgb:function(){return this.setSpace("rgb",arguments)},hsl:function(){return this.setSpace("hsl",arguments)},hsv:function(){return this.setSpace("hsv",arguments)},hwb:function(){return this.setSpace("hwb",arguments)},cmyk:function(){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){var t=this.values;return 1!==t.alpha?t.hwb.concat([t.alpha]):t.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var t=this.values;return t.rgb.concat([t.alpha])},hslaArray:function(){var t=this.values;return t.hsl.concat([t.alpha])},alpha:function(t){return void 0===t?this.values.alpha:(this.setValues("alpha",t),this)},red:function(t){return this.setChannel("rgb",0,t)},green:function(t){return this.setChannel("rgb",1,t)},blue:function(t){return this.setChannel("rgb",2,t)},hue:function(t){return t&&(t%=360,t=0>t?360+t:t),this.setChannel("hsl",0,t)},saturation:function(t){return this.setChannel("hsl",1,t)},lightness:function(t){return this.setChannel("hsl",2,t)},saturationv:function(t){return this.setChannel("hsv",1,t)},whiteness:function(t){return this.setChannel("hwb",1,t)},blackness:function(t){return this.setChannel("hwb",2,t)},value:function(t){return this.setChannel("hsv",2,t)},cyan:function(t){return this.setChannel("cmyk",0,t)},magenta:function(t){return this.setChannel("cmyk",1,t)},yellow:function(t){return this.setChannel("cmyk",2,t)},black:function(t){return this.setChannel("cmyk",3,t)},hexString:function(){return n.hexString(this.values.rgb)},rgbString:function(){return n.rgbString(this.values.rgb,this.values.alpha)},rgbaString:function(){return n.rgbaString(this.values.rgb,this.values.alpha)},percentString:function(){return n.percentString(this.values.rgb,this.values.alpha)},hslString:function(){return n.hslString(this.values.hsl,this.values.alpha)},hslaString:function(){return n.hslaString(this.values.hsl,this.values.alpha)},hwbString:function(){return n.hwbString(this.values.hwb,this.values.alpha)},keyword:function(){return n.keyword(this.values.rgb,this.values.alpha)},rgbNumber:function(){var t=this.values.rgb;return t[0]<<16|t[1]<<8|t[2]},luminosity:function(){for(var t=this.values.rgb,e=[],a=0;a<t.length;a++){var i=t[a]/255;e[a]=.03928>=i?i/12.92:Math.pow((i+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),a=t.luminosity();return e>a?(e+.05)/(a+.05):(a+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return 128>e},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;3>e;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){var e=this.values.hsl;return e[2]+=e[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=this.values.hsl;return e[2]-=e[2]*t,this.setValues("hsl",e),this},saturate:function(t){var e=this.values.hsl;return e[1]+=e[1]*t,this.setValues("hsl",e),this},desaturate:function(t){var e=this.values.hsl;return e[1]-=e[1]*t,this.setValues("hsl",e),this},whiten:function(t){var e=this.values.hwb;return e[1]+=e[1]*t,this.setValues("hwb",e),this},blacken:function(t){var e=this.values.hwb;return e[2]+=e[2]*t,this.setValues("hwb",e),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=this.values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t){var e=this.values.alpha;return this.setValues("alpha",e+e*t),this},rotate:function(t){var e=this.values.hsl,a=(e[0]+t)%360;return e[0]=0>a?360+a:a,this.setValues("hsl",e),this},mix:function(t,e){var a=this,i=t,n=void 0===e?.5:e,o=2*n-1,r=a.alpha()-i.alpha(),l=((o*r===-1?o:(o+r)/(1+o*r))+1)/2,s=1-l;return this.rgb(l*a.red()+s*i.red(),l*a.green()+s*i.green(),l*a.blue()+s*i.blue()).alpha(a.alpha()*n+i.alpha()*(1-n))},toJSON:function(){return this.rgb()},clone:function(){var t,e,a=new o,i=this.values,n=a.values;for(var r in i)i.hasOwnProperty(r)&&(t=i[r],e={}.toString.call(t),"[object Array]"===e?n[r]=t.slice(0):"[object Number]"===e?n[r]=t:console.error("unexpected color value:",t));return a}},o.prototype.spaces={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},o.prototype.maxes={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},o.prototype.getValues=function(t){for(var e=this.values,a={},i=0;i<t.length;i++)a[t.charAt(i)]=e[t][i];return 1!==e.alpha&&(a.a=e.alpha),a},o.prototype.setValues=function(t,e){var a,n=this.values,o=this.spaces,r=this.maxes,l=1;if("alpha"===t)l=e;else if(e.length)n[t]=e.slice(0,t.length),l=e[t.length];else if(void 0!==e[t.charAt(0)]){for(a=0;a<t.length;a++)n[t][a]=e[t.charAt(a)];l=e.a}else if(void 0!==e[o[t][0]]){var s=o[t];for(a=0;a<t.length;a++)n[t][a]=e[s[a]];l=e.alpha}if(n.alpha=Math.max(0,Math.min(1,void 0===l?n.alpha:l)),"alpha"===t)return!1;var d;for(a=0;a<t.length;a++)d=Math.max(0,Math.min(r[t][a],n[t][a])),n[t][a]=Math.round(d);for(var u in o)u!==t&&(n[u]=i[t][u](n[t]));return!0},o.prototype.setSpace=function(t,e){var a=e[0];return void 0===a?this.getValues(t):("number"==typeof a&&(a=Array.prototype.slice.call(e)),this.setValues(t,a),this)},o.prototype.setChannel=function(t,e,a){var i=this.values[t];return void 0===a?i[e]:a===i[e]?this:(i[e]=a,this.setValues(t,i),this)},"undefined"!=typeof window&&(window.Color=o),e.exports=o},{2:2,5:5}],4:[function(t,e,a){function i(t){var e,a,i,n=t[0]/255,o=t[1]/255,r=t[2]/255,l=Math.min(n,o,r),s=Math.max(n,o,r),d=s-l;return s==l?e=0:n==s?e=(o-r)/d:o==s?e=2+(r-n)/d:r==s&&(e=4+(n-o)/d),e=Math.min(60*e,360),0>e&&(e+=360),i=(l+s)/2,a=s==l?0:.5>=i?d/(s+l):d/(2-s-l),[e,100*a,100*i]}function n(t){var e,a,i,n=t[0],o=t[1],r=t[2],l=Math.min(n,o,r),s=Math.max(n,o,r),d=s-l;return a=0==s?0:d/s*1e3/10,s==l?e=0:n==s?e=(o-r)/d:o==s?e=2+(r-n)/d:r==s&&(e=4+(n-o)/d),e=Math.min(60*e,360),0>e&&(e+=360),i=s/255*1e3/10,[e,a,i]}function o(t){var e=t[0],a=t[1],n=t[2],o=i(t)[0],r=1/255*Math.min(e,Math.min(a,n)),n=1-1/255*Math.max(e,Math.max(a,n));return[o,100*r,100*n]}function l(t){var e,a,i,n,o=t[0]/255,r=t[1]/255,l=t[2]/255;return n=Math.min(1-o,1-r,1-l),e=(1-o-n)/(1-n)||0,a=(1-r-n)/(1-n)||0,i=(1-l-n)/(1-n)||0,[100*e,100*a,100*i,100*n]}function s(t){return G[JSON.stringify(t)]}function d(t){var e=t[0]/255,a=t[1]/255,i=t[2]/255;e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92;var n=.4124*e+.3576*a+.1805*i,o=.2126*e+.7152*a+.0722*i,r=.0193*e+.1192*a+.9505*i;return[100*n,100*o,100*r]}function u(t){var e,a,i,n=d(t),o=n[0],r=n[1],l=n[2];return o/=95.047,r/=100,l/=108.883,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,l=l>.008856?Math.pow(l,1/3):7.787*l+16/116,e=116*r-16,a=500*(o-r),i=200*(r-l),[e,a,i]}function c(t){return W(u(t))}function h(t){var e,a,i,n,o,r=t[0]/360,l=t[1]/100,s=t[2]/100;if(0==l)return o=255*s,[o,o,o];a=.5>s?s*(1+l):s+l-s*l,e=2*s-a,n=[0,0,0];for(var d=0;3>d;d++)i=r+1/3*-(d-1),0>i&&i++,i>1&&i--,o=1>6*i?e+6*(a-e)*i:1>2*i?a:2>3*i?e+(a-e)*(2/3-i)*6:e,n[d]=255*o;return n}function f(t){var e,a,i=t[0],n=t[1]/100,o=t[2]/100;return 0===o?[0,0,0]:(o*=2,n*=1>=o?o:2-o,a=(o+n)/2,e=2*n/(o+n),[i,100*e,100*a])}function p(t){return o(h(t))}function m(t){return l(h(t))}function v(t){return s(h(t))}function x(t){var e=t[0]/60,a=t[1]/100,i=t[2]/100,n=Math.floor(e)%6,o=e-Math.floor(e),r=255*i*(1-a),l=255*i*(1-a*o),s=255*i*(1-a*(1-o)),i=255*i;switch(n){case 0:return[i,s,r];case 1:return[l,i,r];case 2:return[r,i,s];case 3:return[r,l,i];case 4:return[s,r,i];case 5:return[i,r,l]}}function y(t){var e,a,i=t[0],n=t[1]/100,o=t[2]/100;return a=(2-n)*o,e=n*o,e/=1>=a?a:2-a,e=e||0,a/=2,[i,100*e,100*a]}function k(t){return o(x(t))}function S(t){return l(x(t))}function w(t){return s(x(t))}function M(t){var e,a,i,n,o=t[0]/360,l=t[1]/100,s=t[2]/100,d=l+s;switch(d>1&&(l/=d,s/=d),e=Math.floor(6*o),a=1-s,i=6*o-e,0!=(1&e)&&(i=1-i),n=l+i*(a-l),e){default:case 6:case 0:r=a,g=n,b=l;break;case 1:r=n,g=a,b=l;break;case 2:r=l,g=a,b=n;break;case 3:r=l,g=n,b=a;break;case 4:r=n,g=l,b=a;break;case 5:r=a,g=l,b=n}return[255*r,255*g,255*b]}function C(t){return i(M(t))}function D(t){return n(M(t))}function I(t){return l(M(t))}function A(t){return s(M(t))}function T(t){var e,a,i,n=t[0]/100,o=t[1]/100,r=t[2]/100,l=t[3]/100;return e=1-Math.min(1,n*(1-l)+l),a=1-Math.min(1,o*(1-l)+l),i=1-Math.min(1,r*(1-l)+l),[255*e,255*a,255*i]}function P(t){return i(T(t))}function F(t){return n(T(t))}function _(t){return o(T(t))}function R(t){return s(T(t))}function V(t){var e,a,i,n=t[0]/100,o=t[1]/100,r=t[2]/100;return e=3.2406*n+-1.5372*o+r*-.4986,a=n*-.9689+1.8758*o+.0415*r,i=.0557*n+o*-.204+1.057*r,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e=12.92*e,a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a=12.92*a,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i=12.92*i,e=Math.min(Math.max(0,e),1),a=Math.min(Math.max(0,a),1),i=Math.min(Math.max(0,i),1),[255*e,255*a,255*i]}function L(t){var e,a,i,n=t[0],o=t[1],r=t[2];return n/=95.047,o/=100,r/=108.883,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,e=116*o-16,a=500*(n-o),i=200*(o-r),[e,a,i]}function O(t){return W(L(t))}function B(t){var e,a,i,n,o=t[0],r=t[1],l=t[2];return 8>=o?(a=100*o/903.3,n=7.787*(a/100)+16/116):(a=100*Math.pow((o+16)/116,3),n=Math.pow(a/100,1/3)),e=.008856>=e/95.047?e=95.047*(r/500+n-16/116)/7.787:95.047*Math.pow(r/500+n,3),i=.008859>=i/108.883?i=108.883*(n-l/200-16/116)/7.787:108.883*Math.pow(n-l/200,3),[e,a,i]}function W(t){var e,a,i,n=t[0],o=t[1],r=t[2];return e=Math.atan2(r,o),a=360*e/2/Math.PI,0>a&&(a+=360),i=Math.sqrt(o*o+r*r),[n,i,a]}function z(t){return V(B(t))}function N(t){var e,a,i,n=t[0],o=t[1],r=t[2];return i=r/360*2*Math.PI,e=o*Math.cos(i),a=o*Math.sin(i),[n,e,a]}function E(t){return B(N(t))}function H(t){return z(N(t))}function U(t){return Z[t]}function j(t){return i(U(t))}function q(t){return n(U(t))}function Y(t){return o(U(t))}function X(t){return l(U(t))}function K(t){return u(U(t))}function J(t){return d(U(t))}e.exports={rgb2hsl:i,rgb2hsv:n,rgb2hwb:o,rgb2cmyk:l,rgb2keyword:s,rgb2xyz:d,rgb2lab:u,rgb2lch:c,hsl2rgb:h,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:m,hsl2keyword:v,hsv2rgb:x,hsv2hsl:y,hsv2hwb:k,hsv2cmyk:S,hsv2keyword:w,hwb2rgb:M,hwb2hsl:C,hwb2hsv:D,hwb2cmyk:I,hwb2keyword:A,cmyk2rgb:T,cmyk2hsl:P,cmyk2hsv:F,cmyk2hwb:_,cmyk2keyword:R,keyword2rgb:U,keyword2hsl:j,keyword2hsv:q,keyword2hwb:Y,keyword2cmyk:X,keyword2lab:K,keyword2xyz:J,xyz2rgb:V,xyz2lab:L,xyz2lch:O,lab2xyz:B,lab2rgb:z,lab2lch:W,lch2lab:N,lch2xyz:E,lch2rgb:H};var Z={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},G={};for(var Q in Z)G[JSON.stringify(Z[Q])]=Q},{}],5:[function(t,e,a){var i=t(4),n=function(){return new d};for(var o in i){n[o+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(o);var r=/(\w+)2(\w+)/.exec(o),l=r[1],s=r[2];n[l]=n[l]||{},n[l][s]=n[o]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var a=i[t](e);if("string"==typeof a||void 0===a)return a;for(var n=0;n<a.length;n++)a[n]=Math.round(a[n]);return a}}(o)}var d=function(){this.convs={}};d.prototype.routeSpace=function(t,e){var a=e[0];return void 0===a?this.getValues(t):("number"==typeof a&&(a=Array.prototype.slice.call(e)),this.setValues(t,a))},d.prototype.setValues=function(t,e){return this.space=t,this.convs={},this.convs[t]=e,this},d.prototype.getValues=function(t){var e=this.convs[t];if(!e){var a=this.space,i=this.convs[a];e=n[a][t](i),this.convs[t]=e}return e},["rgb","hsl","hsv","cmyk","keyword"].forEach(function(t){d.prototype[t]=function(e){return this.routeSpace(t,arguments)}}),e.exports=n},{4:4}],6:[function(t,e,a){e.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}},{}],7:[function(t,e,a){var i=t(28)();t(26)(i),t(22)(i),t(25)(i),t(21)(i),t(23)(i),t(24)(i),t(29)(i),t(33)(i),t(31)(i),t(34)(i),t(32)(i),t(35)(i),t(30)(i),t(27)(i),t(36)(i),t(37)(i),t(38)(i),t(39)(i),t(40)(i),t(43)(i),t(41)(i),t(42)(i),t(44)(i),t(45)(i),t(46)(i),t(15)(i),t(16)(i),t(17)(i),t(18)(i),t(19)(i),t(20)(i),t(8)(i),t(9)(i),t(10)(i),t(11)(i),t(12)(i),t(13)(i),t(14)(i),window.Chart=e.exports=i},{10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,34:34,35:35,36:36,37:37,38:38,39:39,40:40,41:41,42:42,43:43,44:44,45:45,46:46,8:8,9:9}],8:[function(t,e,a){"use strict";e.exports=function(t){t.Bar=function(e,a){return a.type="bar",new t(e,a)}}},{}],9:[function(t,e,a){"use strict";e.exports=function(t){t.Bubble=function(e,a){return a.type="bubble",new t(e,a)}}},{}],10:[function(t,e,a){"use strict";e.exports=function(t){t.Doughnut=function(e,a){return a.type="doughnut",new t(e,a)}}},{}],11:[function(t,e,a){"use strict";e.exports=function(t){t.Line=function(e,a){return a.type="line",new t(e,a)}}},{}],12:[function(t,e,a){"use strict";e.exports=function(t){t.PolarArea=function(e,a){return a.type="polarArea",new t(e,a)}}},{}],13:[function(t,e,a){"use strict";e.exports=function(t){t.Radar=function(e,a){return a.type="radar",new t(e,a)}}},{}],14:[function(t,e,a){"use strict";e.exports=function(t){var e={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{callbacks:{title:function(){return""},label:function(t){return"("+t.xLabel+", "+t.yLabel+")"}}}};t.defaults.scatter=e,t.controllers.scatter=t.controllers.line,t.Scatter=function(e,a){return a.type="scatter",new t(e,a)}}},{}],15:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categoryPercentage:.8,barPercentage:.9,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},t.controllers.bar=t.DatasetController.extend({dataElementType:t.elements.Rectangle,initialize:function(e,a){t.DatasetController.prototype.initialize.call(this,e,a),this.getMeta().bar=!0},getBarCount:function(){var t=this,a=0;return e.each(t.chart.data.datasets,function(e,i){var n=t.chart.getDatasetMeta(i);n.bar&&t.chart.isDatasetVisible(i)&&++a},t),a},update:function(t){var a=this;e.each(a.getMeta().data,function(e,i){a.updateElement(e,i,t)},a)},updateElement:function(t,a,i){var n=this,o=n.getMeta(),r=n.getScaleForId(o.xAxisID),l=n.getScaleForId(o.yAxisID),s=l.getBasePixel(),d=n.chart.options.elements.rectangle,u=t.custom||{},c=n.getDataset();t._xScale=r,t._yScale=l,t._datasetIndex=n.index,t._index=a;var h=n.getRuler(a);t._model={x:n.calculateBarX(a,n.index,h),y:i?s:n.calculateBarY(a,n.index),label:n.chart.data.labels[a],datasetLabel:c.label,base:i?s:n.calculateBarBase(n.index,a),width:n.calculateBarWidth(h),backgroundColor:u.backgroundColor?u.backgroundColor:e.getValueAtIndexOrDefault(c.backgroundColor,a,d.backgroundColor),borderSkipped:u.borderSkipped?u.borderSkipped:d.borderSkipped,borderColor:u.borderColor?u.borderColor:e.getValueAtIndexOrDefault(c.borderColor,a,d.borderColor),borderWidth:u.borderWidth?u.borderWidth:e.getValueAtIndexOrDefault(c.borderWidth,a,d.borderWidth)},t.pivot()},calculateBarBase:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.yAxisID),o=0;if(n.options.stacked){for(var r=a.chart,l=r.data.datasets,s=Number(l[t].data[e]),d=0;t>d;d++){var u=l[d],c=r.getDatasetMeta(d);if(c.bar&&c.yAxisID===n.id&&r.isDatasetVisible(d)){var h=Number(u.data[e]);o+=0>s?Math.min(h,0):Math.max(h,0)}}return n.getPixelForValue(o)}return n.getBasePixel()},getRuler:function(t){var e,a=this,i=a.getMeta(),n=a.getScaleForId(i.xAxisID),o=a.getBarCount();e="category"===n.options.type?n.getPixelForTick(t+1)-n.getPixelForTick(t):n.width/n.ticks.length;var r=e*n.options.categoryPercentage,l=(e-e*n.options.categoryPercentage)/2,s=r/o;if(n.ticks.length!==a.chart.data.labels.length){var d=n.ticks.length/a.chart.data.labels.length;s*=d}var u=s*n.options.barPercentage,c=s-s*n.options.barPercentage;return{datasetCount:o,tickWidth:e,categoryWidth:r,categorySpacing:l,fullBarWidth:s,barWidth:u,barSpacing:c}},calculateBarWidth:function(t){var e=this.getScaleForId(this.getMeta().xAxisID);return e.options.barThickness?e.options.barThickness:e.options.stacked?t.categoryWidth:t.barWidth},getBarIndex:function(t){var e,a,i=0;for(a=0;t>a;++a)e=this.chart.getDatasetMeta(a),e.bar&&this.chart.isDatasetVisible(a)&&++i;return i},calculateBarX:function(t,e,a){var i=this,n=i.getMeta(),o=i.getScaleForId(n.xAxisID),r=i.getBarIndex(e),l=o.getPixelForValue(null,t,e,i.chart.isCombo);return l-=i.chart.isCombo?a.tickWidth/2:0,o.options.stacked?l+a.categoryWidth/2+a.categorySpacing:l+a.barWidth/2+a.categorySpacing+a.barWidth*r+a.barSpacing/2+a.barSpacing*r},calculateBarY:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.yAxisID),o=Number(a.getDataset().data[t]);if(n.options.stacked){for(var r=0,l=0,s=0;e>s;s++){var d=a.chart.data.datasets[s],u=a.chart.getDatasetMeta(s);if(u.bar&&u.yAxisID===n.id&&a.chart.isDatasetVisible(s)){var c=Number(d.data[t]);0>c?l+=c||0:r+=c||0}}return 0>o?n.getPixelForValue(l+o):n.getPixelForValue(r+o)}return n.getPixelForValue(o)},draw:function(t){var e,a,i=this,n=t||1,o=i.getMeta().data,r=i.getDataset();for(e=0,a=o.length;a>e;++e){var l=r.data[e];null===l||void 0===l||isNaN(l)||o[e].transition(n).draw()}},setHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t._index,n=t.custom||{},o=t._model;o.backgroundColor=n.hoverBackgroundColor?n.hoverBackgroundColor:e.getValueAtIndexOrDefault(a.hoverBackgroundColor,i,e.getHoverColor(o.backgroundColor)),o.borderColor=n.hoverBorderColor?n.hoverBorderColor:e.getValueAtIndexOrDefault(a.hoverBorderColor,i,e.getHoverColor(o.borderColor)),o.borderWidth=n.hoverBorderWidth?n.hoverBorderWidth:e.getValueAtIndexOrDefault(a.hoverBorderWidth,i,o.borderWidth)},removeHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t._index,n=t.custom||{},o=t._model,r=this.chart.options.elements.rectangle;o.backgroundColor=n.backgroundColor?n.backgroundColor:e.getValueAtIndexOrDefault(a.backgroundColor,i,r.backgroundColor),o.borderColor=n.borderColor?n.borderColor:e.getValueAtIndexOrDefault(a.borderColor,i,r.borderColor),o.borderWidth=n.borderWidth?n.borderWidth:e.getValueAtIndexOrDefault(a.borderWidth,i,r.borderWidth)}}),t.defaults.horizontalBar={hover:{mode:"label"},scales:{xAxes:[{type:"linear",position:"bottom"}],yAxes:[{position:"left",type:"category",categoryPercentage:.8,barPercentage:.9,gridLines:{offsetGridLines:!0}}]},elements:{rectangle:{borderSkipped:"left"}},tooltips:{callbacks:{title:function(t,e){var a="";return t.length>0&&(t[0].yLabel?a=t[0].yLabel:e.labels.length>0&&t[0].index<e.labels.length&&(a=e.labels[t[0].index])),a},label:function(t,e){var a=e.datasets[t.datasetIndex].label||"";return a+": "+t.xLabel}}}},t.controllers.horizontalBar=t.controllers.bar.extend({updateElement:function(t,a,i){var n=this,o=n.getMeta(),r=n.getScaleForId(o.xAxisID),l=n.getScaleForId(o.yAxisID),s=r.getBasePixel(),d=t.custom||{},u=n.getDataset(),c=n.chart.options.elements.rectangle;t._xScale=r,t._yScale=l,t._datasetIndex=n.index,t._index=a;var h=n.getRuler(a);t._model={x:i?s:n.calculateBarX(a,n.index),y:n.calculateBarY(a,n.index,h),label:n.chart.data.labels[a],datasetLabel:u.label,base:i?s:n.calculateBarBase(n.index,a),height:n.calculateBarHeight(h),backgroundColor:d.backgroundColor?d.backgroundColor:e.getValueAtIndexOrDefault(u.backgroundColor,a,c.backgroundColor),borderSkipped:d.borderSkipped?d.borderSkipped:c.borderSkipped,borderColor:d.borderColor?d.borderColor:e.getValueAtIndexOrDefault(u.borderColor,a,c.borderColor),borderWidth:d.borderWidth?d.borderWidth:e.getValueAtIndexOrDefault(u.borderWidth,a,c.borderWidth)},t.draw=function(){function t(t){return s[(u+t)%4]}var e=this._chart.ctx,a=this._view,i=a.height/2,n=a.y-i,o=a.y+i,r=a.base-(a.base-a.x),l=a.borderWidth/2;a.borderWidth&&(n+=l,o-=l,r+=l),e.beginPath(),e.fillStyle=a.backgroundColor,e.strokeStyle=a.borderColor,e.lineWidth=a.borderWidth;var s=[[a.base,o],[a.base,n],[r,n],[r,o]],d=["bottom","left","top","right"],u=d.indexOf(a.borderSkipped,0);-1===u&&(u=0),e.moveTo.apply(e,t(0));for(var c=1;4>c;c++)e.lineTo.apply(e,t(c));e.fill(),a.borderWidth&&e.stroke()},t.pivot()},calculateBarBase:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.xAxisID),o=0;if(n.options.stacked){for(var r=a.chart,l=r.data.datasets,s=Number(l[t].data[e]),d=0;t>d;d++){var u=l[d],c=r.getDatasetMeta(d);if(c.bar&&c.xAxisID===n.id&&r.isDatasetVisible(d)){
11
- var h=Number(u.data[e]);o+=0>s?Math.min(h,0):Math.max(h,0)}}return n.getPixelForValue(o)}return n.getBasePixel()},getRuler:function(t){var e,a=this,i=a.getMeta(),n=a.getScaleForId(i.yAxisID),o=a.getBarCount();e="category"===n.options.type?n.getPixelForTick(t+1)-n.getPixelForTick(t):n.width/n.ticks.length;var r=e*n.options.categoryPercentage,l=(e-e*n.options.categoryPercentage)/2,s=r/o;if(n.ticks.length!==a.chart.data.labels.length){var d=n.ticks.length/a.chart.data.labels.length;s*=d}var u=s*n.options.barPercentage,c=s-s*n.options.barPercentage;return{datasetCount:o,tickHeight:e,categoryHeight:r,categorySpacing:l,fullBarHeight:s,barHeight:u,barSpacing:c}},calculateBarHeight:function(t){var e=this,a=e.getScaleForId(e.getMeta().yAxisID);return a.options.barThickness?a.options.barThickness:a.options.stacked?t.categoryHeight:t.barHeight},calculateBarX:function(t,e){var a=this,i=a.getMeta(),n=a.getScaleForId(i.xAxisID),o=Number(a.getDataset().data[t]);if(n.options.stacked){for(var r=0,l=0,s=0;e>s;s++){var d=a.chart.data.datasets[s],u=a.chart.getDatasetMeta(s);if(u.bar&&u.xAxisID===n.id&&a.chart.isDatasetVisible(s)){var c=Number(d.data[t]);0>c?l+=c||0:r+=c||0}}return 0>o?n.getPixelForValue(l+o):n.getPixelForValue(r+o)}return n.getPixelForValue(o)},calculateBarY:function(t,e,a){var i=this,n=i.getMeta(),o=i.getScaleForId(n.yAxisID),r=i.getBarIndex(e),l=o.getPixelForValue(null,t,e,i.chart.isCombo);return l-=i.chart.isCombo?a.tickHeight/2:0,o.options.stacked?l+a.categoryHeight/2+a.categorySpacing:l+a.barHeight/2+a.categorySpacing+a.barHeight*r+a.barSpacing/2+a.barSpacing*r}})}},{}],16:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.bubble={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-0"}],yAxes:[{type:"linear",position:"left",id:"y-axis-0"}]},tooltips:{callbacks:{title:function(){return""},label:function(t,e){var a=e.datasets[t.datasetIndex].label||"",i=e.datasets[t.datasetIndex].data[t.index];return a+": ("+t.xLabel+", "+t.yLabel+", "+i.r+")"}}}},t.controllers.bubble=t.DatasetController.extend({dataElementType:t.elements.Point,update:function(t){var a=this,i=a.getMeta(),n=i.data;e.each(n,function(e,i){a.updateElement(e,i,t)})},updateElement:function(a,i,n){var o=this,r=o.getMeta(),l=o.getScaleForId(r.xAxisID),s=o.getScaleForId(r.yAxisID),d=a.custom||{},u=o.getDataset(),c=u.data[i],h=o.chart.options.elements.point,f=o.index;e.extend(a,{_xScale:l,_yScale:s,_datasetIndex:f,_index:i,_model:{x:n?l.getPixelForDecimal(.5):l.getPixelForValue("object"==typeof c?c:NaN,i,f,o.chart.isCombo),y:n?s.getBasePixel():s.getPixelForValue(c,i,f),radius:n?0:d.radius?d.radius:o.getRadius(c),hitRadius:d.hitRadius?d.hitRadius:e.getValueAtIndexOrDefault(u.hitRadius,i,h.hitRadius)}}),t.DatasetController.prototype.removeHoverStyle.call(o,a,h);var g=a._model;g.skip=d.skip?d.skip:isNaN(g.x)||isNaN(g.y),a.pivot()},getRadius:function(t){return t.r||this.chart.options.elements.point.radius},setHoverStyle:function(a){var i=this;t.DatasetController.prototype.setHoverStyle.call(i,a);var n=i.chart.data.datasets[a._datasetIndex],o=a._index,r=a.custom||{},l=a._model;l.radius=r.hoverRadius?r.hoverRadius:e.getValueAtIndexOrDefault(n.hoverRadius,o,i.chart.options.elements.point.hoverRadius)+i.getRadius(n.data[o])},removeHoverStyle:function(e){var a=this;t.DatasetController.prototype.removeHoverStyle.call(a,e,a.chart.options.elements.point);var i=a.chart.data.datasets[e._datasetIndex].data[e._index],n=e.custom||{},o=e._model;o.radius=n.radius?n.radius:a.getRadius(i)}})}},{}],17:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults;a.doughnut={animation:{animateRotate:!0,animateScale:!1},aspectRatio:1,hover:{mode:"single"},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var a=t.data,i=a.datasets,n=a.labels;if(i.length)for(var o=0;o<i[0].data.length;++o)e.push('<li><span style="background-color:'+i[0].backgroundColor[o]+'"></span>'),n[o]&&e.push(n[o]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var a=t.data;return a.labels.length&&a.datasets.length?a.labels.map(function(i,n){var o=t.getDatasetMeta(0),r=a.datasets[0],l=o.data[n],s=l&&l.custom||{},d=e.getValueAtIndexOrDefault,u=t.options.elements.arc,c=s.backgroundColor?s.backgroundColor:d(r.backgroundColor,n,u.backgroundColor),h=s.borderColor?s.borderColor:d(r.borderColor,n,u.borderColor),f=s.borderWidth?s.borderWidth:d(r.borderWidth,n,u.borderWidth);return{text:i,fillStyle:c,strokeStyle:h,lineWidth:f,hidden:isNaN(r.data[n])||o.data[n].hidden,index:n}}):[]}},onClick:function(t,e){var a,i,n,o=e.index,r=this.chart;for(a=0,i=(r.data.datasets||[]).length;i>a;++a)n=r.getDatasetMeta(a),n.data[o]&&(n.data[o].hidden=!n.data[o].hidden);r.update()}},cutoutPercentage:50,rotation:Math.PI*-.5,circumference:2*Math.PI,tooltips:{callbacks:{title:function(){return""},label:function(t,a){var i=a.labels[t.index],n=": "+a.datasets[t.datasetIndex].data[t.index];return e.isArray(i)?(i=i.slice(),i[0]+=n):i+=n,i}}}},a.pie=e.clone(a.doughnut),e.extend(a.pie,{cutoutPercentage:0}),t.controllers.doughnut=t.controllers.pie=t.DatasetController.extend({dataElementType:t.elements.Arc,linkScales:e.noop,getRingIndex:function(t){for(var e=0,a=0;t>a;++a)this.chart.isDatasetVisible(a)&&++e;return e},update:function(t){var a=this,i=a.chart,n=i.chartArea,o=i.options,r=o.elements.arc,l=n.right-n.left-r.borderWidth,s=n.bottom-n.top-r.borderWidth,d=Math.min(l,s),u={x:0,y:0},c=a.getMeta(),h=o.cutoutPercentage,f=o.circumference;if(f<2*Math.PI){var g=o.rotation%(2*Math.PI);g+=2*Math.PI*(g>=Math.PI?-1:g<-Math.PI?1:0);var p=g+f,m={x:Math.cos(g),y:Math.sin(g)},b={x:Math.cos(p),y:Math.sin(p)},v=0>=g&&p>=0||g<=2*Math.PI&&2*Math.PI<=p,x=g<=.5*Math.PI&&.5*Math.PI<=p||g<=2.5*Math.PI&&2.5*Math.PI<=p,y=g<=-Math.PI&&-Math.PI<=p||g<=Math.PI&&Math.PI<=p,k=g<=.5*-Math.PI&&.5*-Math.PI<=p||g<=1.5*Math.PI&&1.5*Math.PI<=p,S=h/100,w={x:y?-1:Math.min(m.x*(m.x<0?1:S),b.x*(b.x<0?1:S)),y:k?-1:Math.min(m.y*(m.y<0?1:S),b.y*(b.y<0?1:S))},M={x:v?1:Math.max(m.x*(m.x>0?1:S),b.x*(b.x>0?1:S)),y:x?1:Math.max(m.y*(m.y>0?1:S),b.y*(b.y>0?1:S))},C={width:.5*(M.x-w.x),height:.5*(M.y-w.y)};d=Math.min(l/C.width,s/C.height),u={x:(M.x+w.x)*-.5,y:(M.y+w.y)*-.5}}i.borderWidth=a.getMaxBorderWidth(c.data),i.outerRadius=Math.max((d-i.borderWidth)/2,0),i.innerRadius=Math.max(h?i.outerRadius/100*h:1,0),i.radiusLength=(i.outerRadius-i.innerRadius)/i.getVisibleDatasetCount(),i.offsetX=u.x*i.outerRadius,i.offsetY=u.y*i.outerRadius,c.total=a.calculateTotal(),a.outerRadius=i.outerRadius-i.radiusLength*a.getRingIndex(a.index),a.innerRadius=a.outerRadius-i.radiusLength,e.each(c.data,function(e,i){a.updateElement(e,i,t)})},updateElement:function(t,a,i){var n=this,o=n.chart,r=o.chartArea,l=o.options,s=l.animation,d=(r.left+r.right)/2,u=(r.top+r.bottom)/2,c=l.rotation,h=l.rotation,f=n.getDataset(),g=i&&s.animateRotate?0:t.hidden?0:n.calculateCircumference(f.data[a])*(l.circumference/(2*Math.PI)),p=i&&s.animateScale?0:n.innerRadius,m=i&&s.animateScale?0:n.outerRadius,b=e.getValueAtIndexOrDefault;e.extend(t,{_datasetIndex:n.index,_index:a,_model:{x:d+o.offsetX,y:u+o.offsetY,startAngle:c,endAngle:h,circumference:g,outerRadius:m,innerRadius:p,label:b(f.label,a,o.data.labels[a])}});var v=t._model;this.removeHoverStyle(t),i&&s.animateRotate||(0===a?v.startAngle=l.rotation:v.startAngle=n.getMeta().data[a-1]._model.endAngle,v.endAngle=v.startAngle+v.circumference),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},calculateTotal:function(){var t,a=this.getDataset(),i=this.getMeta(),n=0;return e.each(i.data,function(e,i){t=a.data[i],isNaN(t)||e.hidden||(n+=Math.abs(t))}),n},calculateCircumference:function(t){var e=this.getMeta().total;return e>0&&!isNaN(t)?2*Math.PI*(t/e):0},getMaxBorderWidth:function(t){for(var e,a,i=0,n=this.index,o=t.length,r=0;o>r;r++)e=t[r]._model?t[r]._model.borderWidth:0,a=t[r]._chart?t[r]._chart.config.data.datasets[n].hoverBorderWidth:0,i=e>i?e:i,i=a>i?a:i;return i}})}},{}],18:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){return a.getValueOrDefault(t.showLine,e.showLines)}var a=t.helpers;t.defaults.line={showLines:!0,spanGaps:!1,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},t.controllers.line=t.DatasetController.extend({datasetElementType:t.elements.Line,dataElementType:t.elements.Point,update:function(t){var i,n,o,r=this,l=r.getMeta(),s=l.dataset,d=l.data||[],u=r.chart.options,c=u.elements.line,h=r.getScaleForId(l.yAxisID),f=r.getDataset(),g=e(f,u);for(g&&(o=s.custom||{},void 0!==f.tension&&void 0===f.lineTension&&(f.lineTension=f.tension),s._scale=h,s._datasetIndex=r.index,s._children=d,s._model={spanGaps:f.spanGaps?f.spanGaps:u.spanGaps,tension:o.tension?o.tension:a.getValueOrDefault(f.lineTension,c.tension),backgroundColor:o.backgroundColor?o.backgroundColor:f.backgroundColor||c.backgroundColor,borderWidth:o.borderWidth?o.borderWidth:f.borderWidth||c.borderWidth,borderColor:o.borderColor?o.borderColor:f.borderColor||c.borderColor,borderCapStyle:o.borderCapStyle?o.borderCapStyle:f.borderCapStyle||c.borderCapStyle,borderDash:o.borderDash?o.borderDash:f.borderDash||c.borderDash,borderDashOffset:o.borderDashOffset?o.borderDashOffset:f.borderDashOffset||c.borderDashOffset,borderJoinStyle:o.borderJoinStyle?o.borderJoinStyle:f.borderJoinStyle||c.borderJoinStyle,fill:o.fill?o.fill:void 0!==f.fill?f.fill:c.fill,steppedLine:o.steppedLine?o.steppedLine:a.getValueOrDefault(f.steppedLine,c.stepped),cubicInterpolationMode:o.cubicInterpolationMode?o.cubicInterpolationMode:a.getValueOrDefault(f.cubicInterpolationMode,c.cubicInterpolationMode),scaleTop:h.top,scaleBottom:h.bottom,scaleZero:h.getBasePixel()},s.pivot()),i=0,n=d.length;n>i;++i)r.updateElement(d[i],i,t);for(g&&0!==s._model.tension&&r.updateBezierControlPoints(),i=0,n=d.length;n>i;++i)d[i].pivot()},getPointBackgroundColor:function(t,e){var i=this.chart.options.elements.point.backgroundColor,n=this.getDataset(),o=t.custom||{};return o.backgroundColor?i=o.backgroundColor:n.pointBackgroundColor?i=a.getValueAtIndexOrDefault(n.pointBackgroundColor,e,i):n.backgroundColor&&(i=n.backgroundColor),i},getPointBorderColor:function(t,e){var i=this.chart.options.elements.point.borderColor,n=this.getDataset(),o=t.custom||{};return o.borderColor?i=o.borderColor:n.pointBorderColor?i=a.getValueAtIndexOrDefault(n.pointBorderColor,e,i):n.borderColor&&(i=n.borderColor),i},getPointBorderWidth:function(t,e){var i=this.chart.options.elements.point.borderWidth,n=this.getDataset(),o=t.custom||{};return o.borderWidth?i=o.borderWidth:n.pointBorderWidth?i=a.getValueAtIndexOrDefault(n.pointBorderWidth,e,i):n.borderWidth&&(i=n.borderWidth),i},updateElement:function(t,e,i){var n,o,r=this,l=r.getMeta(),s=t.custom||{},d=r.getDataset(),u=r.index,c=d.data[e],h=r.getScaleForId(l.yAxisID),f=r.getScaleForId(l.xAxisID),g=r.chart.options.elements.point,p=r.chart.data.labels||[],m=1===p.length||1===d.data.length||r.chart.isCombo;void 0!==d.radius&&void 0===d.pointRadius&&(d.pointRadius=d.radius),void 0!==d.hitRadius&&void 0===d.pointHitRadius&&(d.pointHitRadius=d.hitRadius),n=f.getPixelForValue("object"==typeof c?c:NaN,e,u,m),o=i?h.getBasePixel():r.calculatePointY(c,e,u),t._xScale=f,t._yScale=h,t._datasetIndex=u,t._index=e,t._model={x:n,y:o,skip:s.skip||isNaN(n)||isNaN(o),radius:s.radius||a.getValueAtIndexOrDefault(d.pointRadius,e,g.radius),pointStyle:s.pointStyle||a.getValueAtIndexOrDefault(d.pointStyle,e,g.pointStyle),backgroundColor:r.getPointBackgroundColor(t,e),borderColor:r.getPointBorderColor(t,e),borderWidth:r.getPointBorderWidth(t,e),tension:l.dataset._model?l.dataset._model.tension:0,steppedLine:l.dataset._model?l.dataset._model.steppedLine:!1,hitRadius:s.hitRadius||a.getValueAtIndexOrDefault(d.pointHitRadius,e,g.hitRadius)}},calculatePointY:function(t,e,a){var i,n,o,r=this,l=r.chart,s=r.getMeta(),d=r.getScaleForId(s.yAxisID),u=0,c=0;if(d.options.stacked){for(i=0;a>i;i++)if(n=l.data.datasets[i],o=l.getDatasetMeta(i),"line"===o.type&&o.yAxisID===d.id&&l.isDatasetVisible(i)){var h=Number(d.getRightValue(n.data[e]));0>h?c+=h||0:u+=h||0}var f=Number(d.getRightValue(t));return 0>f?d.getPixelForValue(c+f):d.getPixelForValue(u+f)}return d.getPixelForValue(t)},updateBezierControlPoints:function(){function t(t,e,a){return Math.max(Math.min(t,a),e)}var e,i,n,o,r,l=this,s=l.getMeta(),d=l.chart.chartArea,u=s.data||[];if(s.dataset._model.spanGaps&&(u=u.filter(function(t){return!t._model.skip})),"monotone"===s.dataset._model.cubicInterpolationMode)a.splineCurveMonotone(u);else for(e=0,i=u.length;i>e;++e)n=u[e],o=n._model,r=a.splineCurve(a.previousItem(u,e)._model,o,a.nextItem(u,e)._model,s.dataset._model.tension),o.controlPointPreviousX=r.previous.x,o.controlPointPreviousY=r.previous.y,o.controlPointNextX=r.next.x,o.controlPointNextY=r.next.y;if(l.chart.options.elements.line.capBezierPoints)for(e=0,i=u.length;i>e;++e)o=u[e]._model,o.controlPointPreviousX=t(o.controlPointPreviousX,d.left,d.right),o.controlPointPreviousY=t(o.controlPointPreviousY,d.top,d.bottom),o.controlPointNextX=t(o.controlPointNextX,d.left,d.right),o.controlPointNextY=t(o.controlPointNextY,d.top,d.bottom)},draw:function(t){var a,i,n=this,o=n.getMeta(),r=o.data||[],l=t||1;for(a=0,i=r.length;i>a;++a)r[a].transition(l);for(e(n.getDataset(),n.chart.options)&&o.dataset.transition(l).draw(),a=0,i=r.length;i>a;++a)r[a].draw()},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],i=t._index,n=t.custom||{},o=t._model;o.radius=n.hoverRadius||a.getValueAtIndexOrDefault(e.pointHoverRadius,i,this.chart.options.elements.point.hoverRadius),o.backgroundColor=n.hoverBackgroundColor||a.getValueAtIndexOrDefault(e.pointHoverBackgroundColor,i,a.getHoverColor(o.backgroundColor)),o.borderColor=n.hoverBorderColor||a.getValueAtIndexOrDefault(e.pointHoverBorderColor,i,a.getHoverColor(o.borderColor)),o.borderWidth=n.hoverBorderWidth||a.getValueAtIndexOrDefault(e.pointHoverBorderWidth,i,o.borderWidth)},removeHoverStyle:function(t){var e=this,i=e.chart.data.datasets[t._datasetIndex],n=t._index,o=t.custom||{},r=t._model;void 0!==i.radius&&void 0===i.pointRadius&&(i.pointRadius=i.radius),r.radius=o.radius||a.getValueAtIndexOrDefault(i.pointRadius,n,e.chart.options.elements.point.radius),r.backgroundColor=e.getPointBackgroundColor(t,n),r.borderColor=e.getPointBorderColor(t,n),r.borderWidth=e.getPointBorderWidth(t,n)}})}},{}],19:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.polarArea={scale:{type:"radialLinear",lineArc:!0,ticks:{beginAtZero:!0}},animation:{animateRotate:!0,animateScale:!0},startAngle:-.5*Math.PI,aspectRatio:1,legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');var a=t.data,i=a.datasets,n=a.labels;if(i.length)for(var o=0;o<i[0].data.length;++o)e.push('<li><span style="background-color:'+i[0].backgroundColor[o]+'"></span>'),n[o]&&e.push(n[o]),e.push("</li>");return e.push("</ul>"),e.join("")},legend:{labels:{generateLabels:function(t){var a=t.data;return a.labels.length&&a.datasets.length?a.labels.map(function(i,n){var o=t.getDatasetMeta(0),r=a.datasets[0],l=o.data[n],s=l.custom||{},d=e.getValueAtIndexOrDefault,u=t.options.elements.arc,c=s.backgroundColor?s.backgroundColor:d(r.backgroundColor,n,u.backgroundColor),h=s.borderColor?s.borderColor:d(r.borderColor,n,u.borderColor),f=s.borderWidth?s.borderWidth:d(r.borderWidth,n,u.borderWidth);return{text:i,fillStyle:c,strokeStyle:h,lineWidth:f,hidden:isNaN(r.data[n])||o.data[n].hidden,index:n}}):[]}},onClick:function(t,e){var a,i,n,o=e.index,r=this.chart;for(a=0,i=(r.data.datasets||[]).length;i>a;++a)n=r.getDatasetMeta(a),n.data[o].hidden=!n.data[o].hidden;r.update()}},tooltips:{callbacks:{title:function(){return""},label:function(t,e){return e.labels[t.index]+": "+t.yLabel}}}},t.controllers.polarArea=t.DatasetController.extend({dataElementType:t.elements.Arc,linkScales:e.noop,update:function(t){var a=this,i=a.chart,n=i.chartArea,o=a.getMeta(),r=i.options,l=r.elements.arc,s=Math.min(n.right-n.left,n.bottom-n.top);i.outerRadius=Math.max((s-l.borderWidth/2)/2,0),i.innerRadius=Math.max(r.cutoutPercentage?i.outerRadius/100*r.cutoutPercentage:1,0),i.radiusLength=(i.outerRadius-i.innerRadius)/i.getVisibleDatasetCount(),a.outerRadius=i.outerRadius-i.radiusLength*a.index,a.innerRadius=a.outerRadius-i.radiusLength,o.count=a.countVisibleElements(),e.each(o.data,function(e,i){a.updateElement(e,i,t)})},updateElement:function(t,a,i){for(var n=this,o=n.chart,r=n.getDataset(),l=o.options,s=l.animation,d=o.scale,u=e.getValueAtIndexOrDefault,c=o.data.labels,h=n.calculateCircumference(r.data[a]),f=d.xCenter,g=d.yCenter,p=0,m=n.getMeta(),b=0;a>b;++b)isNaN(r.data[b])||m.data[b].hidden||++p;var v=l.startAngle,x=t.hidden?0:d.getDistanceFromCenterForValue(r.data[a]),y=v+h*p,k=y+(t.hidden?0:h),S=s.animateScale?0:d.getDistanceFromCenterForValue(r.data[a]);e.extend(t,{_datasetIndex:n.index,_index:a,_scale:d,_model:{x:f,y:g,innerRadius:0,outerRadius:i?S:x,startAngle:i&&s.animateRotate?v:y,endAngle:i&&s.animateRotate?v:k,label:u(c,a,c[a])}}),n.removeHoverStyle(t),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},countVisibleElements:function(){var t=this.getDataset(),a=this.getMeta(),i=0;return e.each(a.data,function(e,a){isNaN(t.data[a])||e.hidden||i++}),i},calculateCircumference:function(t){var e=this.getMeta().count;return e>0&&!isNaN(t)?2*Math.PI/e:0}})}},{}],20:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.radar={aspectRatio:1,scale:{type:"radialLinear"},elements:{line:{tension:0}}},t.controllers.radar=t.DatasetController.extend({datasetElementType:t.elements.Line,dataElementType:t.elements.Point,linkScales:e.noop,update:function(t){var a=this,i=a.getMeta(),n=i.dataset,o=i.data,r=n.custom||{},l=a.getDataset(),s=a.chart.options.elements.line,d=a.chart.scale;void 0!==l.tension&&void 0===l.lineTension&&(l.lineTension=l.tension),e.extend(i.dataset,{_datasetIndex:a.index,_children:o,_loop:!0,_model:{tension:r.tension?r.tension:e.getValueOrDefault(l.lineTension,s.tension),backgroundColor:r.backgroundColor?r.backgroundColor:l.backgroundColor||s.backgroundColor,borderWidth:r.borderWidth?r.borderWidth:l.borderWidth||s.borderWidth,borderColor:r.borderColor?r.borderColor:l.borderColor||s.borderColor,fill:r.fill?r.fill:void 0!==l.fill?l.fill:s.fill,borderCapStyle:r.borderCapStyle?r.borderCapStyle:l.borderCapStyle||s.borderCapStyle,borderDash:r.borderDash?r.borderDash:l.borderDash||s.borderDash,borderDashOffset:r.borderDashOffset?r.borderDashOffset:l.borderDashOffset||s.borderDashOffset,borderJoinStyle:r.borderJoinStyle?r.borderJoinStyle:l.borderJoinStyle||s.borderJoinStyle,scaleTop:d.top,scaleBottom:d.bottom,scaleZero:d.getBasePosition()}}),i.dataset.pivot(),e.each(o,function(e,i){a.updateElement(e,i,t)},a),a.updateBezierControlPoints()},updateElement:function(t,a,i){var n=this,o=t.custom||{},r=n.getDataset(),l=n.chart.scale,s=n.chart.options.elements.point,d=l.getPointPositionForValue(a,r.data[a]);e.extend(t,{_datasetIndex:n.index,_index:a,_scale:l,_model:{x:i?l.xCenter:d.x,y:i?l.yCenter:d.y,tension:o.tension?o.tension:e.getValueOrDefault(r.tension,n.chart.options.elements.line.tension),radius:o.radius?o.radius:e.getValueAtIndexOrDefault(r.pointRadius,a,s.radius),backgroundColor:o.backgroundColor?o.backgroundColor:e.getValueAtIndexOrDefault(r.pointBackgroundColor,a,s.backgroundColor),borderColor:o.borderColor?o.borderColor:e.getValueAtIndexOrDefault(r.pointBorderColor,a,s.borderColor),borderWidth:o.borderWidth?o.borderWidth:e.getValueAtIndexOrDefault(r.pointBorderWidth,a,s.borderWidth),pointStyle:o.pointStyle?o.pointStyle:e.getValueAtIndexOrDefault(r.pointStyle,a,s.pointStyle),hitRadius:o.hitRadius?o.hitRadius:e.getValueAtIndexOrDefault(r.hitRadius,a,s.hitRadius)}}),t._model.skip=o.skip?o.skip:isNaN(t._model.x)||isNaN(t._model.y)},updateBezierControlPoints:function(){var t=this.chart.chartArea,a=this.getMeta();e.each(a.data,function(i,n){var o=i._model,r=e.splineCurve(e.previousItem(a.data,n,!0)._model,o,e.nextItem(a.data,n,!0)._model,o.tension);o.controlPointPreviousX=Math.max(Math.min(r.previous.x,t.right),t.left),o.controlPointPreviousY=Math.max(Math.min(r.previous.y,t.bottom),t.top),o.controlPointNextX=Math.max(Math.min(r.next.x,t.right),t.left),o.controlPointNextY=Math.max(Math.min(r.next.y,t.bottom),t.top),i.pivot()})},draw:function(t){var a=this.getMeta(),i=t||1;e.each(a.data,function(t){t.transition(i)}),a.dataset.transition(i).draw(),e.each(a.data,function(t){t.draw()})},setHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t.custom||{},n=t._index,o=t._model;o.radius=i.hoverRadius?i.hoverRadius:e.getValueAtIndexOrDefault(a.pointHoverRadius,n,this.chart.options.elements.point.hoverRadius),o.backgroundColor=i.hoverBackgroundColor?i.hoverBackgroundColor:e.getValueAtIndexOrDefault(a.pointHoverBackgroundColor,n,e.getHoverColor(o.backgroundColor)),o.borderColor=i.hoverBorderColor?i.hoverBorderColor:e.getValueAtIndexOrDefault(a.pointHoverBorderColor,n,e.getHoverColor(o.borderColor)),o.borderWidth=i.hoverBorderWidth?i.hoverBorderWidth:e.getValueAtIndexOrDefault(a.pointHoverBorderWidth,n,o.borderWidth)},removeHoverStyle:function(t){var a=this.chart.data.datasets[t._datasetIndex],i=t.custom||{},n=t._index,o=t._model,r=this.chart.options.elements.point;o.radius=i.radius?i.radius:e.getValueAtIndexOrDefault(a.radius,n,r.radius),o.backgroundColor=i.backgroundColor?i.backgroundColor:e.getValueAtIndexOrDefault(a.pointBackgroundColor,n,r.backgroundColor),o.borderColor=i.borderColor?i.borderColor:e.getValueAtIndexOrDefault(a.pointBorderColor,n,r.borderColor),o.borderWidth=i.borderWidth?i.borderWidth:e.getValueAtIndexOrDefault(a.pointBorderWidth,n,r.borderWidth)}})}},{}],21:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:e.noop,onComplete:e.noop},t.Animation=t.Element.extend({currentStep:null,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),t.animationService={frameDuration:17,animations:[],dropFrames:0,request:null,addAnimation:function(t,e,a,i){var n=this;i||(t.animating=!0);for(var o=0;o<n.animations.length;++o)if(n.animations[o].chartInstance===t)return void(n.animations[o].animationObject=e);n.animations.push({chartInstance:t,animationObject:e}),1===n.animations.length&&n.requestAnimationFrame()},cancelAnimation:function(t){var a=e.findIndex(this.animations,function(e){return e.chartInstance===t});-1!==a&&(this.animations.splice(a,1),t.animating=!1)},requestAnimationFrame:function(){var t=this;null===t.request&&(t.request=e.requestAnimFrame.call(window,function(){t.request=null,t.startDigest()}))},startDigest:function(){var t=this,e=Date.now(),a=0;t.dropFrames>1&&(a=Math.floor(t.dropFrames),t.dropFrames=t.dropFrames%1);for(var i=0;i<t.animations.length;)null===t.animations[i].animationObject.currentStep&&(t.animations[i].animationObject.currentStep=0),t.animations[i].animationObject.currentStep+=1+a,t.animations[i].animationObject.currentStep>t.animations[i].animationObject.numSteps&&(t.animations[i].animationObject.currentStep=t.animations[i].animationObject.numSteps),t.animations[i].animationObject.render(t.animations[i].chartInstance,t.animations[i].animationObject),t.animations[i].animationObject.onAnimationProgress&&t.animations[i].animationObject.onAnimationProgress.call&&t.animations[i].animationObject.onAnimationProgress.call(t.animations[i].chartInstance,t.animations[i]),t.animations[i].animationObject.currentStep===t.animations[i].animationObject.numSteps?(t.animations[i].animationObject.onAnimationComplete&&t.animations[i].animationObject.onAnimationComplete.call&&t.animations[i].animationObject.onAnimationComplete.call(t.animations[i].chartInstance,t.animations[i]),t.animations[i].chartInstance.animating=!1,t.animations.splice(i,1)):++i;var n=Date.now(),o=(n-e)/t.frameDuration;t.dropFrames+=o,t.animations.length>0&&t.requestAnimationFrame()}}}},{}],22:[function(t,e,a){"use strict";e.exports=function(t){var e=t.canvasHelpers={};e.drawPoint=function(t,e,a,i,n){var o,r,l,s,d,u;if("object"==typeof e&&(o=e.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return void t.drawImage(e,i-e.width/2,n-e.height/2);if(!(isNaN(a)||0>=a)){switch(e){default:t.beginPath(),t.arc(i,n,a,0,2*Math.PI),t.closePath(),t.fill();break;case"triangle":t.beginPath(),r=3*a/Math.sqrt(3),d=r*Math.sqrt(3)/2,t.moveTo(i-r/2,n+d/3),t.lineTo(i+r/2,n+d/3),t.lineTo(i,n-2*d/3),t.closePath(),t.fill();break;case"rect":u=1/Math.SQRT2*a,t.beginPath(),t.fillRect(i-u,n-u,2*u,2*u),t.strokeRect(i-u,n-u,2*u,2*u);break;case"rectRot":u=1/Math.SQRT2*a,t.beginPath(),t.moveTo(i-u,n),t.lineTo(i,n+u),t.lineTo(i+u,n),t.lineTo(i,n-u),t.closePath(),t.fill();break;case"cross":t.beginPath(),t.moveTo(i,n+a),t.lineTo(i,n-a),t.moveTo(i-a,n),t.lineTo(i+a,n),t.closePath();break;case"crossRot":t.beginPath(),l=Math.cos(Math.PI/4)*a,s=Math.sin(Math.PI/4)*a,t.moveTo(i-l,n-s),t.lineTo(i+l,n+s),t.moveTo(i-l,n+s),t.lineTo(i+l,n-s),t.closePath();break;case"star":t.beginPath(),t.moveTo(i,n+a),t.lineTo(i,n-a),t.moveTo(i-a,n),t.lineTo(i+a,n),l=Math.cos(Math.PI/4)*a,s=Math.sin(Math.PI/4)*a,t.moveTo(i-l,n-s),t.lineTo(i+l,n+s),t.moveTo(i-l,n+s),t.lineTo(i+l,n-s),t.closePath();break;case"line":t.beginPath(),t.moveTo(i-a,n),t.lineTo(i+a,n),t.closePath();break;case"dash":t.beginPath(),t.moveTo(i,n),t.lineTo(i+a,n),t.closePath()}t.stroke()}}}},{}],23:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){var a=r.getStyle(t,e),i=a&&a.match(/(\d+)px/);return i?Number(i[1]):void 0}function a(t,a){var i=t.style,n=t.getAttribute("height"),o=t.getAttribute("width");if(t._chartjs={initial:{height:n,width:o,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",null===o||""===o){var r=e(t,"width");void 0!==r&&(t.width=r)}if(null===n||""===n)if(""===t.style.height)t.height=t.width/(a.options.aspectRatio||2);else{var l=e(t,"height");void 0!==r&&(t.height=l)}return t}function i(t){if(t._chartjs){var e=t._chartjs.initial;["height","width"].forEach(function(a){var i=e[a];void 0===i||null===i?t.removeAttribute(a):t.setAttribute(a,i)}),r.each(e.style||{},function(e,a){t.style[a]=e}),t.width=t.width,delete t._chartjs}}function n(t,e){if("string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t instanceof HTMLCanvasElement){var i=t.getContext&&t.getContext("2d");if(i instanceof CanvasRenderingContext2D)return a(t,e),i}return null}function o(e){e=e||{};var a=e.data=e.data||{};return a.datasets=a.datasets||[],a.labels=a.labels||[],e.options=r.configMerge(t.defaults.global,t.defaults[e.type],e.options||{}),e}var r=t.helpers;t.types={},t.instances={},t.controllers={},t.Controller=function(e,a,i){var l=this;a=o(a);var s=n(e,a),d=s&&s.canvas,u=d&&d.height,c=d&&d.width;return i.ctx=s,i.canvas=d,i.config=a,i.width=c,i.height=u,i.aspectRatio=u?c/u:null,l.id=r.uid(),l.chart=i,l.config=a,l.options=a.options,l._bufferedRender=!1,t.instances[l.id]=l,Object.defineProperty(l,"data",{get:function(){return l.config.data}}),s&&d?(r.retinaScale(i),l.options.responsive&&(r.addResizeListener(d.parentNode,function(){l.resize()}),l.resize(!0)),l.initialize(),l):(console.error("Failed to create chart: can't acquire context from the given item"),l)},r.extend(t.Controller.prototype,{initialize:function(){var e=this;return t.plugins.notify("beforeInit",[e]),e.bindEvents(),e.ensureScalesHaveIDs(),e.buildOrUpdateControllers(),e.buildScales(),e.updateLayout(),e.resetElements(),e.initToolTip(),e.update(),t.plugins.notify("afterInit",[e]),e},clear:function(){return r.clear(this.chart),this},stop:function(){return t.animationService.cancelAnimation(this),this},resize:function(e){var a=this,i=a.chart,n=a.options,o=i.canvas,l=n.maintainAspectRatio&&i.aspectRatio||null,s=Math.floor(r.getMaximumWidth(o)),d=Math.floor(l?s/l:r.getMaximumHeight(o));if(i.width!==s||i.height!==d){o.width=i.width=s,o.height=i.height=d,o.style.width=s+"px",o.style.height=d+"px",r.retinaScale(i);var u={width:s,height:d};t.plugins.notify("resize",[a,u]),a.options.onResize&&a.options.onResize(a,u),e||(a.stop(),a.update(a.options.responsiveAnimationDuration))}},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},a=t.scale;r.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),r.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),a&&(a.id=a.id||"scale")},buildScales:function(){var e=this,a=e.options,i=e.scales={},n=[];a.scales&&(n=n.concat((a.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category"}}),(a.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear"}}))),a.scale&&n.push({options:a.scale,dtype:"radialLinear",isDefault:!0}),r.each(n,function(a){var n=a.options,o=r.getValueOrDefault(n.type,a.dtype),l=t.scaleService.getScaleConstructor(o);if(l){var s=new l({id:n.id,options:n,ctx:e.chart.ctx,chart:e});i[s.id]=s,a.isDefault&&(e.scale=s)}}),t.scaleService.addScalesToLayout(this)},updateLayout:function(){t.layoutService.update(this,this.chart.width,this.chart.height)},buildOrUpdateControllers:function(){var e=this,a=[],i=[];if(r.each(e.data.datasets,function(n,o){var r=e.getDatasetMeta(o);r.type||(r.type=n.type||e.config.type),a.push(r.type),r.controller?r.controller.updateIndex(o):(r.controller=new t.controllers[r.type](e,o),i.push(r.controller))},e),a.length>1)for(var n=1;n<a.length;n++)if(a[n]!==a[n-1]){e.isCombo=!0;break}return i},resetElements:function(){var t=this;r.each(t.data.datasets,function(e,a){t.getDatasetMeta(a).controller.reset()},t)},reset:function(){this.resetElements(),this.tooltip.initialize()},update:function(e,a){var i=this;t.plugins.notify("beforeUpdate",[i]),i.tooltip._data=i.data;var n=i.buildOrUpdateControllers();r.each(i.data.datasets,function(t,e){i.getDatasetMeta(e).controller.buildOrUpdateElements()},i),t.layoutService.update(i,i.chart.width,i.chart.height),t.plugins.notify("afterScaleUpdate",[i]),r.each(n,function(t){t.reset()}),i.updateDatasets(),t.plugins.notify("afterUpdate",[i]),i._bufferedRender?i._bufferedRequest={lazy:a,duration:e}:i.render(e,a)},updateDatasets:function(){var e,a,i=this;if(t.plugins.notify("beforeDatasetsUpdate",[i])){for(e=0,a=i.data.datasets.length;a>e;++e)i.getDatasetMeta(e).controller.update();t.plugins.notify("afterDatasetsUpdate",[i])}},render:function(e,a){var i=this;t.plugins.notify("beforeRender",[i]);var n=i.options.animation;if(n&&("undefined"!=typeof e&&0!==e||"undefined"==typeof e&&0!==n.duration)){var o=new t.Animation;o.numSteps=(e||n.duration)/16.66,o.easing=n.easing,o.render=function(t,e){var a=r.easingEffects[e.easing],i=e.currentStep/e.numSteps,n=a(i);t.draw(n,i,e.currentStep)},o.onAnimationProgress=n.onProgress,o.onAnimationComplete=n.onComplete,t.animationService.addAnimation(i,o,e,a)}else i.draw(),n&&n.onComplete&&n.onComplete.call&&n.onComplete.call(i);return i},draw:function(e){var a=this,i=e||1;a.clear(),t.plugins.notify("beforeDraw",[a,i]),r.each(a.boxes,function(t){t.draw(a.chartArea)},a),a.scale&&a.scale.draw(),t.plugins.notify("beforeDatasetsDraw",[a,i]),r.each(a.data.datasets,function(t,i){a.isDatasetVisible(i)&&a.getDatasetMeta(i).controller.draw(e)},a,!0),t.plugins.notify("afterDatasetsDraw",[a,i]),a.tooltip.transition(i).draw(),t.plugins.notify("afterDraw",[a,i])},getElementAtEvent:function(e){return t.Interaction.modes.single(this,e)},getElementsAtEvent:function(e){return t.Interaction.modes.label(this,e,{intersect:!0})},getElementsAtXAxis:function(e){return t.Interaction.modes["x-axis"](this,e,{intersect:!0})},getElementsAtEventForMode:function(e,a,i){var n=t.Interaction.modes[a];return"function"==typeof n?n(this,e,i):[]},getDatasetAtEvent:function(e){return t.Interaction.modes.dataset(this,e)},getDatasetMeta:function(t){var e=this,a=e.data.datasets[t];a._meta||(a._meta={});
12
- var i=a._meta[e.id];return i||(i=a._meta[e.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null}),i},getVisibleDatasetCount:function(){for(var t=0,e=0,a=this.data.datasets.length;a>e;++e)this.isDatasetVisible(e)&&t++;return t},isDatasetVisible:function(t){var e=this.getDatasetMeta(t);return"boolean"==typeof e.hidden?!e.hidden:!this.data.datasets[t].hidden},generateLegend:function(){return this.options.legendCallback(this)},destroy:function(){var e,a,n,o=this,l=o.chart.canvas;for(o.stop(),a=0,n=o.data.datasets.length;n>a;++a)e=o.getDatasetMeta(a),e.controller&&(e.controller.destroy(),e.controller=null);l&&(r.unbindEvents(o,o.events),r.removeResizeListener(l.parentNode),r.clear(o.chart),i(l),o.chart.canvas=null,o.chart.ctx=null),t.plugins.notify("destroy",[o]),delete t.instances[o.id]},toBase64Image:function(){return this.chart.canvas.toDataURL.apply(this.chart.canvas,arguments)},initToolTip:function(){var e=this;e.tooltip=new t.Tooltip({_chart:e.chart,_chartInstance:e,_data:e.data,_options:e.options.tooltips},e),e.tooltip.initialize()},bindEvents:function(){var t=this;r.bindEvents(t,t.options.events,function(e){t.eventHandler(e)})},updateHoverStyle:function(t,e,a){var i,n,o,r=a?"setHoverStyle":"removeHoverStyle";for(n=0,o=t.length;o>n;++n)i=t[n],i&&this.getDatasetMeta(i._datasetIndex).controller[r](i)},eventHandler:function(t){var e=this,a=e.legend,i=e.tooltip,n=e.options.hover;e._bufferedRender=!0,e._bufferedRequest=null;var o=e.handleEvent(t);o|=a&&a.handleEvent(t),o|=i&&i.handleEvent(t);var r=e._bufferedRequest;return r?e.render(r.duration,r.lazy):o&&!e.animating&&(e.stop(),e.render(n.animationDuration,!0)),e._bufferedRender=!1,e._bufferedRequest=null,e},handleEvent:function(t){var e=this,a=e.options||{},i=a.hover,n=!1;return e.lastActive=e.lastActive||[],"mouseout"===t.type?e.active=[]:e.active=e.getElementsAtEventForMode(t,i.mode,i),i.onHover&&i.onHover.call(e,e.active),("mouseup"===t.type||"click"===t.type)&&a.onClick&&a.onClick.call(e,t,e.active),e.lastActive.length&&e.updateHoverStyle(e.lastActive,i.mode,!1),e.active.length&&i.mode&&e.updateHoverStyle(e.active,i.mode,!0),n=!r.arrayEquals(e.active,e.lastActive),e.lastActive=e.active,n}})}},{}],24:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){return t._chartjs?void t._chartjs.listeners.push(e):(Object.defineProperty(t,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[e]}}),void n.forEach(function(e){var a="onData"+e.charAt(0).toUpperCase()+e.slice(1),n=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:function(){var e=Array.prototype.slice.call(arguments),o=n.apply(this,e);return i.each(t._chartjs.listeners,function(t){"function"==typeof t[a]&&t[a].apply(t,e)}),o}})}))}function a(t,e){var a=t._chartjs;if(a){var i=a.listeners,o=i.indexOf(e);-1!==o&&i.splice(o,1),i.length>0||(n.forEach(function(e){delete t[e]}),delete t._chartjs)}}var i=t.helpers,n=["push","pop","shift","splice","unshift"];t.DatasetController=function(t,e){this.initialize(t,e)},i.extend(t.DatasetController.prototype,{datasetElementType:null,dataElementType:null,initialize:function(t,e){var a=this;a.chart=t,a.index=e,a.linkScales(),a.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){var t=this,e=t.getMeta(),a=t.getDataset();null===e.xAxisID&&(e.xAxisID=a.xAxisID||t.chart.options.scales.xAxes[0].id),null===e.yAxisID&&(e.yAxisID=a.yAxisID||t.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getMeta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:function(t){return this.chart.scales[t]},reset:function(){this.update(!0)},destroy:function(){this._data&&a(this._data,this)},createMetaDataset:function(){var t=this,e=t.datasetElementType;return e&&new e({_chart:t.chart.chart,_datasetIndex:t.index})},createMetaData:function(t){var e=this,a=e.dataElementType;return a&&new a({_chart:e.chart.chart,_datasetIndex:e.index,_index:t})},addElements:function(){var t,e,a=this,i=a.getMeta(),n=a.getDataset().data||[],o=i.data;for(t=0,e=n.length;e>t;++t)o[t]=o[t]||a.createMetaData(t);i.dataset=i.dataset||a.createMetaDataset()},addElementAndReset:function(t){var e=this.createMetaData(t);this.getMeta().data.splice(t,0,e),this.updateElement(e,t,!0)},buildOrUpdateElements:function(){var t=this,i=t.getDataset(),n=i.data||(i.data=[]);t._data!==n&&(t._data&&a(t._data,t),e(n,t),t._data=n),t.resyncElements()},update:i.noop,draw:function(t){var e,a,i=t||1,n=this.getMeta().data;for(e=0,a=n.length;a>e;++e)n[e].transition(i).draw()},removeHoverStyle:function(t,e){var a=this.chart.data.datasets[t._datasetIndex],n=t._index,o=t.custom||{},r=i.getValueAtIndexOrDefault,l=t._model;l.backgroundColor=o.backgroundColor?o.backgroundColor:r(a.backgroundColor,n,e.backgroundColor),l.borderColor=o.borderColor?o.borderColor:r(a.borderColor,n,e.borderColor),l.borderWidth=o.borderWidth?o.borderWidth:r(a.borderWidth,n,e.borderWidth)},setHoverStyle:function(t){var e=this.chart.data.datasets[t._datasetIndex],a=t._index,n=t.custom||{},o=i.getValueAtIndexOrDefault,r=i.getHoverColor,l=t._model;l.backgroundColor=n.hoverBackgroundColor?n.hoverBackgroundColor:o(e.hoverBackgroundColor,a,r(l.backgroundColor)),l.borderColor=n.hoverBorderColor?n.hoverBorderColor:o(e.hoverBorderColor,a,r(l.borderColor)),l.borderWidth=n.hoverBorderWidth?n.hoverBorderWidth:o(e.hoverBorderWidth,a,l.borderWidth)},resyncElements:function(){var t=this,e=t.getMeta(),a=t.getDataset().data,i=e.data.length,n=a.length;i>n?e.data.splice(n,i-n):n>i&&t.insertElements(i,n-i)},insertElements:function(t,e){for(var a=0;e>a;++a)this.addElementAndReset(t+a)},onDataPush:function(){this.insertElements(this.getDataset().data.length-1,arguments.length)},onDataPop:function(){this.getMeta().data.pop()},onDataShift:function(){this.getMeta().data.shift()},onDataSplice:function(t,e){this.getMeta().data.splice(t,e),this.insertElements(t,arguments.length-2)},onDataUnshift:function(){this.insertElements(0,arguments.length)}}),t.DatasetController.extend=i.inherits}},{}],25:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.elements={},t.Element=function(t){e.extend(this,t),this.initialize.apply(this,arguments)},e.extend(t.Element.prototype,{initialize:function(){this.hidden=!1},pivot:function(){var t=this;return t._view||(t._view=e.clone(t._model)),t._start=e.clone(t._view),t},transition:function(t){var a=this;return a._view||(a._view=e.clone(a._model)),1===t?(a._view=a._model,a._start=null,a):(a._start||a.pivot(),e.each(a._model,function(i,n){if("_"===n[0]);else if(a._view.hasOwnProperty(n))if(i===a._view[n]);else if("string"==typeof i)try{var o=e.color(a._model[n]).mix(e.color(a._start[n]),t);a._view[n]=o.rgbString()}catch(r){a._view[n]=i}else if("number"==typeof i){var l=void 0!==a._start[n]&&isNaN(a._start[n])===!1?a._start[n]:0;a._view[n]=(a._model[n]-l)*t+l}else a._view[n]=i;else"number"!=typeof i||isNaN(a._view[n])?a._view[n]=i:a._view[n]=i*t},a),a)},tooltipPosition:function(){return{x:this._model.x,y:this._model.y}},hasValue:function(){return e.isNumber(this._model.x)&&e.isNumber(this._model.y)}}),t.Element.extend=e.inherits}},{}],26:[function(t,e,a){"use strict";var i=t(3);e.exports=function(t){function e(t,e,a){var i;return"string"==typeof t?(i=parseInt(t,10),-1!==t.indexOf("%")&&(i=i/100*e.parentNode[a])):i=t,i}function a(t){return void 0!==t&&null!==t&&"none"!==t}function n(t,i,n){var o=document.defaultView,r=t.parentNode,l=o.getComputedStyle(t)[i],s=o.getComputedStyle(r)[i],d=a(l),u=a(s),c=Number.POSITIVE_INFINITY;return d||u?Math.min(d?e(l,t,n):c,u?e(s,r,n):c):"none"}var o=t.helpers={};o.each=function(t,e,a,i){var n,r;if(o.isArray(t))if(r=t.length,i)for(n=r-1;n>=0;n--)e.call(a,t[n],n);else for(n=0;r>n;n++)e.call(a,t[n],n);else if("object"==typeof t){var l=Object.keys(t);for(r=l.length,n=0;r>n;n++)e.call(a,t[l[n]],l[n])}},o.clone=function(t){var e={};return o.each(t,function(t,a){o.isArray(t)?e[a]=t.slice(0):"object"==typeof t&&null!==t?e[a]=o.clone(t):e[a]=t}),e},o.extend=function(t){for(var e=function(e,a){t[a]=e},a=1,i=arguments.length;i>a;a++)o.each(arguments[a],e);return t},o.configMerge=function(e){var a=o.clone(e);return o.each(Array.prototype.slice.call(arguments,1),function(e){o.each(e,function(e,i){var n=a.hasOwnProperty(i),r=n?a[i]:{};"scales"===i?a[i]=o.scaleMerge(r,e):"scale"===i?a[i]=o.configMerge(r,t.scaleService.getScaleDefaults(e.type),e):!n||"object"!=typeof r||o.isArray(r)||null===r||"object"!=typeof e||o.isArray(e)?a[i]=e:a[i]=o.configMerge(r,e)})}),a},o.scaleMerge=function(e,a){var i=o.clone(e);return o.each(a,function(e,a){"xAxes"===a||"yAxes"===a?i.hasOwnProperty(a)?o.each(e,function(e,n){var r=o.getValueOrDefault(e.type,"xAxes"===a?"category":"linear"),l=t.scaleService.getScaleDefaults(r);n>=i[a].length||!i[a][n].type?i[a].push(o.configMerge(l,e)):e.type&&e.type!==i[a][n].type?i[a][n]=o.configMerge(i[a][n],l,e):i[a][n]=o.configMerge(i[a][n],e)}):(i[a]=[],o.each(e,function(e){var n=o.getValueOrDefault(e.type,"xAxes"===a?"category":"linear");i[a].push(o.configMerge(t.scaleService.getScaleDefaults(n),e))})):i.hasOwnProperty(a)&&"object"==typeof i[a]&&null!==i[a]&&"object"==typeof e?i[a]=o.configMerge(i[a],e):i[a]=e}),i},o.getValueAtIndexOrDefault=function(t,e,a){return void 0===t||null===t?a:o.isArray(t)?e<t.length?t[e]:a:t},o.getValueOrDefault=function(t,e){return void 0===t?e:t},o.indexOf=Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var a=0,i=t.length;i>a;++a)if(t[a]===e)return a;return-1},o.where=function(t,e){if(o.isArray(t)&&Array.prototype.filter)return t.filter(e);var a=[];return o.each(t,function(t){e(t)&&a.push(t)}),a},o.findIndex=Array.prototype.findIndex?function(t,e,a){return t.findIndex(e,a)}:function(t,e,a){a=void 0===a?t:a;for(var i=0,n=t.length;n>i;++i)if(e.call(a,t[i],i,t))return i;return-1},o.findNextWhere=function(t,e,a){(void 0===a||null===a)&&(a=-1);for(var i=a+1;i<t.length;i++){var n=t[i];if(e(n))return n}},o.findPreviousWhere=function(t,e,a){(void 0===a||null===a)&&(a=t.length);for(var i=a-1;i>=0;i--){var n=t[i];if(e(n))return n}},o.inherits=function(t){var e=this,a=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},i=function(){this.constructor=a};return i.prototype=e.prototype,a.prototype=new i,a.extend=o.inherits,t&&o.extend(a.prototype,t),a.__super__=e.prototype,a},o.noop=function(){},o.uid=function(){var t=0;return function(){return t++}}(),o.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},o.almostEquals=function(t,e,a){return Math.abs(t-e)<a},o.max=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.max(t,e)},Number.NEGATIVE_INFINITY)},o.min=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.min(t,e)},Number.POSITIVE_INFINITY)},o.sign=Math.sign?function(t){return Math.sign(t)}:function(t){return t=+t,0===t||isNaN(t)?t:t>0?1:-1},o.log10=Math.log10?function(t){return Math.log10(t)}:function(t){return Math.log(t)/Math.LN10},o.toRadians=function(t){return t*(Math.PI/180)},o.toDegrees=function(t){return t*(180/Math.PI)},o.getAngleFromPoint=function(t,e){var a=e.x-t.x,i=e.y-t.y,n=Math.sqrt(a*a+i*i),o=Math.atan2(i,a);return o<-.5*Math.PI&&(o+=2*Math.PI),{angle:o,distance:n}},o.distanceBetweenPoints=function(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},o.aliasPixel=function(t){return t%2===0?0:.5},o.splineCurve=function(t,e,a,i){var n=t.skip?e:t,o=e,r=a.skip?e:a,l=Math.sqrt(Math.pow(o.x-n.x,2)+Math.pow(o.y-n.y,2)),s=Math.sqrt(Math.pow(r.x-o.x,2)+Math.pow(r.y-o.y,2)),d=l/(l+s),u=s/(l+s);d=isNaN(d)?0:d,u=isNaN(u)?0:u;var c=i*d,h=i*u;return{previous:{x:o.x-c*(r.x-n.x),y:o.y-c*(r.y-n.y)},next:{x:o.x+h*(r.x-n.x),y:o.y+h*(r.y-n.y)}}},o.EPSILON=Number.EPSILON||1e-14,o.splineCurveMonotone=function(t){var e,a,i,n,r=(t||[]).map(function(t){return{model:t._model,deltaK:0,mK:0}}),l=r.length;for(e=0;l>e;++e)i=r[e],i.model.skip||(a=e>0?r[e-1]:null,n=l-1>e?r[e+1]:null,n&&!n.model.skip&&(i.deltaK=(n.model.y-i.model.y)/(n.model.x-i.model.x)),!a||a.model.skip?i.mK=i.deltaK:!n||n.model.skip?i.mK=a.deltaK:this.sign(a.deltaK)!==this.sign(i.deltaK)?i.mK=0:i.mK=(a.deltaK+i.deltaK)/2);var s,d,u,c;for(e=0;l-1>e;++e)i=r[e],n=r[e+1],i.model.skip||n.model.skip||(o.almostEquals(i.deltaK,0,this.EPSILON)?i.mK=n.mK=0:(s=i.mK/i.deltaK,d=n.mK/i.deltaK,c=Math.pow(s,2)+Math.pow(d,2),9>=c||(u=3/Math.sqrt(c),i.mK=s*u*i.deltaK,n.mK=d*u*i.deltaK)));var h;for(e=0;l>e;++e)i=r[e],i.model.skip||(a=e>0?r[e-1]:null,n=l-1>e?r[e+1]:null,a&&!a.model.skip&&(h=(i.model.x-a.model.x)/3,i.model.controlPointPreviousX=i.model.x-h,i.model.controlPointPreviousY=i.model.y-h*i.mK),n&&!n.model.skip&&(h=(n.model.x-i.model.x)/3,i.model.controlPointNextX=i.model.x+h,i.model.controlPointNextY=i.model.y+h*i.mK))},o.nextItem=function(t,e,a){return a?e>=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},o.previousItem=function(t,e,a){return a?0>=e?t[t.length-1]:t[e-1]:0>=e?t[0]:t[e-1]},o.niceNum=function(t,e){var a,i=Math.floor(o.log10(t)),n=t/Math.pow(10,i);return a=e?1.5>n?1:3>n?2:7>n?5:10:1>=n?1:2>=n?2:5>=n?5:10,a*Math.pow(10,i)};var r=o.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-0.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-0.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-0.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-0.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,a=0,i=1;return 0===t?0:1===(t/=1)?1:(a||(a=.3),i<Math.abs(1)?(i=1,e=a/4):e=a/(2*Math.PI)*Math.asin(1/i),-(i*Math.pow(2,10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/a)))},easeOutElastic:function(t){var e=1.70158,a=0,i=1;return 0===t?0:1===(t/=1)?1:(a||(a=.3),i<Math.abs(1)?(i=1,e=a/4):e=a/(2*Math.PI)*Math.asin(1/i),i*Math.pow(2,-10*t)*Math.sin((1*t-e)*(2*Math.PI)/a)+1)},easeInOutElastic:function(t){var e=1.70158,a=0,i=1;return 0===t?0:2===(t/=.5)?1:(a||(a=1*(.3*1.5)),i<Math.abs(1)?(i=1,e=a/4):e=a/(2*Math.PI)*Math.asin(1/i),1>t?-.5*(i*Math.pow(2,10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/a)):i*Math.pow(2,-10*(t-=1))*Math.sin((1*t-e)*(2*Math.PI)/a)*.5+1)},easeInBack:function(t){var e=1.70158;return 1*(t/=1)*t*((e+1)*t-e)},easeOutBack:function(t){var e=1.70158;return 1*((t=t/1-1)*t*((e+1)*t+e)+1)},easeInOutBack:function(t){var e=1.70158;return(t/=.5)<1?.5*(t*t*(((e*=1.525)+1)*t-e)):.5*((t-=2)*t*(((e*=1.525)+1)*t+e)+2)},easeInBounce:function(t){return 1-r.easeOutBounce(1-t)},easeOutBounce:function(t){return(t/=1)<1/2.75?1*(7.5625*t*t):2/2.75>t?1*(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1*(7.5625*(t-=2.25/2.75)*t+.9375):1*(7.5625*(t-=2.625/2.75)*t+.984375)},easeInOutBounce:function(t){return.5>t?.5*r.easeInBounce(2*t):.5*r.easeOutBounce(2*t-1)+.5}};o.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)}}(),o.cancelAnimFrame=function(){return window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame||function(t){return window.clearTimeout(t,1e3/60)}}(),o.getRelativePosition=function(t,e){var a,i,n=t.originalEvent||t,r=t.currentTarget||t.srcElement,l=r.getBoundingClientRect(),s=n.touches;s&&s.length>0?(a=s[0].clientX,i=s[0].clientY):(a=n.clientX,i=n.clientY);var d=parseFloat(o.getStyle(r,"padding-left")),u=parseFloat(o.getStyle(r,"padding-top")),c=parseFloat(o.getStyle(r,"padding-right")),h=parseFloat(o.getStyle(r,"padding-bottom")),f=l.right-l.left-d-c,g=l.bottom-l.top-u-h;return a=Math.round((a-l.left-d)/f*r.width/e.currentDevicePixelRatio),i=Math.round((i-l.top-u)/g*r.height/e.currentDevicePixelRatio),{x:a,y:i}},o.addEvent=function(t,e,a){t.addEventListener?t.addEventListener(e,a):t.attachEvent?t.attachEvent("on"+e,a):t["on"+e]=a},o.removeEvent=function(t,e,a){t.removeEventListener?t.removeEventListener(e,a,!1):t.detachEvent?t.detachEvent("on"+e,a):t["on"+e]=o.noop},o.bindEvents=function(t,e,a){var i=t.events=t.events||{};o.each(e,function(e){i[e]=function(){a.apply(t,arguments)},o.addEvent(t.chart.canvas,e,i[e])})},o.unbindEvents=function(t,e){var a=t.chart.canvas;o.each(e,function(t,e){o.removeEvent(a,e,t)})},o.getConstraintWidth=function(t){return n(t,"max-width","clientWidth")},o.getConstraintHeight=function(t){return n(t,"max-height","clientHeight")},o.getMaximumWidth=function(t){var e=t.parentNode,a=parseInt(o.getStyle(e,"padding-left"),10),i=parseInt(o.getStyle(e,"padding-right"),10),n=e.clientWidth-a-i,r=o.getConstraintWidth(t);return isNaN(r)?n:Math.min(n,r)},o.getMaximumHeight=function(t){var e=t.parentNode,a=parseInt(o.getStyle(e,"padding-top"),10),i=parseInt(o.getStyle(e,"padding-bottom"),10),n=e.clientHeight-a-i,r=o.getConstraintHeight(t);return isNaN(r)?n:Math.min(n,r)},o.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},o.retinaScale=function(t){var e=t.currentDevicePixelRatio=window.devicePixelRatio||1;if(1!==e){var a=t.canvas,i=t.height,n=t.width;a.height=i*e,a.width=n*e,t.ctx.scale(e,e),a.style.height=i+"px",a.style.width=n+"px"}},o.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},o.fontString=function(t,e,a){return e+" "+t+"px "+a},o.longestText=function(t,e,a,i){i=i||{};var n=i.data=i.data||{},r=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(n=i.data={},r=i.garbageCollect=[],i.font=e),t.font=e;var l=0;o.each(a,function(e){void 0!==e&&null!==e&&o.isArray(e)!==!0?l=o.measureText(t,n,r,l,e):o.isArray(e)&&o.each(e,function(e){void 0===e||null===e||o.isArray(e)||(l=o.measureText(t,n,r,l,e))})});var s=r.length/2;if(s>a.length){for(var d=0;s>d;d++)delete n[r[d]];r.splice(0,s)}return l},o.measureText=function(t,e,a,i,n){var o=e[n];return o||(o=e[n]=t.measureText(n).width,a.push(n)),o>i&&(i=o),i},o.numberOfLabelLines=function(t){var e=1;return o.each(t,function(t){o.isArray(t)&&t.length>e&&(e=t.length)}),e},o.drawRoundedRectangle=function(t,e,a,i,n,o){t.beginPath(),t.moveTo(e+o,a),t.lineTo(e+i-o,a),t.quadraticCurveTo(e+i,a,e+i,a+o),t.lineTo(e+i,a+n-o),t.quadraticCurveTo(e+i,a+n,e+i-o,a+n),t.lineTo(e+o,a+n),t.quadraticCurveTo(e,a+n,e,a+n-o),t.lineTo(e,a+o),t.quadraticCurveTo(e,a,e+o,a),t.closePath()},o.color=function(e){return i?i(e instanceof CanvasGradient?t.defaults.global.defaultColor:e):(console.error("Color.js not found!"),e)},o.addResizeListener=function(t,e){var a=document.createElement("iframe");a.className="chartjs-hidden-iframe",a.style.cssText="display:block;overflow:hidden;border:0;margin:0;top:0;left:0;bottom:0;right:0;height:100%;width:100%;position:absolute;pointer-events:none;z-index:-1;",a.tabIndex=-1;var i=t._chartjs={resizer:a,ticking:!1},n=function(){i.ticking||(i.ticking=!0,o.requestAnimFrame.call(window,function(){return i.resizer?(i.ticking=!1,e()):void 0}))};o.addEvent(a,"load",function(){o.addEvent(a.contentWindow||a,"resize",n),n()}),t.insertBefore(a,t.firstChild)},o.removeResizeListener=function(t){if(t&&t._chartjs){var e=t._chartjs.resizer;e&&(e.parentNode.removeChild(e),t._chartjs.resizer=null),delete t._chartjs}},o.isArray=Array.isArray?function(t){return Array.isArray(t)}:function(t){return"[object Array]"===Object.prototype.toString.call(t)},o.arrayEquals=function(t,e){var a,i,n,r;if(!t||!e||t.length!==e.length)return!1;for(a=0,i=t.length;i>a;++a)if(n=t[a],r=e[a],n instanceof Array&&r instanceof Array){if(!o.arrayEquals(n,r))return!1}else if(n!==r)return!1;return!0},o.callCallback=function(t,e,a){t&&"function"==typeof t.call&&t.apply(a,e)},o.getHoverColor=function(t){return t instanceof CanvasPattern?t:o.color(t).saturate(.5).darken(.1).rgbString()}}},{3:3}],27:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){var a,i,n,o,r,l=t.data.datasets;for(i=0,o=l.length;o>i;++i)if(t.isDatasetVisible(i))for(a=t.getDatasetMeta(i),n=0,r=a.data.length;r>n;++n){var s=a.data[n];s._view.skip||e(s)}}function a(t,a){var i=[];return e(t,function(t){t.inRange(a.x,a.y)&&i.push(t)}),i}function i(t,a,i,n){var r=Number.POSITIVE_INFINITY,l=[];return n||(n=o.distanceBetweenPoints),e(t,function(t){if(!i||t.inRange(a.x,a.y)){var e=t.getCenterPoint(),o=n(a,e);r>o?(l=[t],r=o):o===r&&l.push(t)}}),l}function n(t,e,n){var r=o.getRelativePosition(e,t.chart),l=function(t,e){return Math.abs(t.x-e.x)},s=n.intersect?a(t,r):i(t,r,!1,l),d=[];return s.length?(t.data.datasets.forEach(function(e,a){if(t.isDatasetVisible(a)){var i=t.getDatasetMeta(a),n=i.data[s[0]._index];n&&!n._view.skip&&d.push(n)}}),d):[]}var o=t.helpers;t.Interaction={modes:{single:function(t,a){var i=o.getRelativePosition(a,t.chart),n=[];return e(t,function(t){return t.inRange(i.x,i.y)?(n.push(t),n):void 0}),n.slice(0,1)},label:n,index:n,dataset:function(t,e,n){var r=o.getRelativePosition(e,t.chart),l=n.intersect?a(t,r):i(t,r,!1);return l.length>0&&(l=t.getDatasetMeta(l[0]._datasetIndex).data),l},"x-axis":function(t,e){return n(t,e,!0)},point:function(t,e){var i=o.getRelativePosition(e,t.chart);return a(t,i)},nearest:function(t,e,a){var n=o.getRelativePosition(e,t.chart),r=i(t,n,a.intersect);return r.length>1&&r.sort(function(t,e){var a=t.getArea(),i=e.getArea(),n=a-i;return 0===n&&(n=t._datasetIndex-e._datasetIndex),n}),r.slice(0,1)},x:function(t,a,i){var n=o.getRelativePosition(a,t.chart),r=[],l=!1;return e(t,function(t){t.inXRange(n.x)&&r.push(t),t.inRange(n.x,n.y)&&(l=!0)}),i.intersect&&!l&&(r=[]),r},y:function(t,a,i){var n=o.getRelativePosition(a,t.chart),r=[],l=!1;return e(t,function(t){t.inYRange(n.y)&&r.push(t),t.inRange(n.x,n.y)&&(l=!0)}),i.intersect&&!l&&(r=[]),r}}}}},{}],28:[function(t,e,a){"use strict";e.exports=function(){var t=function(e,a){return this.controller=new t.Controller(e,a,this),this.controller};return t.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",intersect:!0,animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",defaultFontColor:"#666",defaultFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",defaultFontSize:12,defaultFontStyle:"normal",showLines:!0,elements:{},legendCallback:function(t){var e=[];e.push('<ul class="'+t.id+'-legend">');for(var a=0;a<t.data.datasets.length;a++)e.push('<li><span style="background-color:'+t.data.datasets[a].backgroundColor+'"></span>'),t.data.datasets[a].label&&e.push(t.data.datasets[a].label),e.push("</li>");return e.push("</ul>"),e.join("")}}},t.Chart=t,t}},{}],29:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.layoutService={defaults:{},addBox:function(t,e){t.boxes||(t.boxes=[]),t.boxes.push(e)},removeBox:function(t,e){t.boxes&&t.boxes.splice(t.boxes.indexOf(e),1)},update:function(t,a,i){function n(t){var e,a=t.isHorizontal();a?(e=t.update(t.options.fullWidth?x:C,M),D-=e.height):(e=t.update(w,S),C-=e.width),I.push({horizontal:a,minSize:e,box:t})}function o(t){var a=e.findNextWhere(I,function(e){return e.box===t});if(a)if(t.isHorizontal()){var i={left:A,right:T,top:0,bottom:0};t.update(t.options.fullWidth?x:C,y/2,i)}else t.update(a.minSize.width,D)}function r(t){var a=e.findNextWhere(I,function(e){return e.box===t}),i={left:0,right:0,top:P,bottom:F};a&&t.update(a.minSize.width,D,i)}function l(t){t.isHorizontal()?(t.left=t.options.fullWidth?u:A,t.right=t.options.fullWidth?a-c:A+C,t.top=L,t.bottom=L+t.height,L=t.bottom):(t.left=V,t.right=V+t.width,t.top=P,t.bottom=P+D,V=t.right)}if(t){var s=t.options.layout,d=s?s.padding:null,u=0,c=0,h=0,f=0;isNaN(d)?(u=d.left||0,c=d.right||0,h=d.top||0,f=d.bottom||0):(u=d,c=d,h=d,f=d);var g=e.where(t.boxes,function(t){return"left"===t.options.position}),p=e.where(t.boxes,function(t){return"right"===t.options.position}),m=e.where(t.boxes,function(t){return"top"===t.options.position}),b=e.where(t.boxes,function(t){return"bottom"===t.options.position}),v=e.where(t.boxes,function(t){return"chartArea"===t.options.position});m.sort(function(t,e){return(e.options.fullWidth?1:0)-(t.options.fullWidth?1:0)}),b.sort(function(t,e){return(t.options.fullWidth?1:0)-(e.options.fullWidth?1:0)});var x=a-u-c,y=i-h-f,k=x/2,S=y/2,w=(a-k)/(g.length+p.length),M=(i-S)/(m.length+b.length),C=x,D=y,I=[];e.each(g.concat(p,m,b),n);var A=u,T=c,P=h,F=f;e.each(g.concat(p),o),e.each(g,function(t){A+=t.width}),e.each(p,function(t){T+=t.width}),e.each(m.concat(b),o),e.each(m,function(t){P+=t.height}),e.each(b,function(t){F+=t.height}),e.each(g.concat(p),r),A=u,T=c,P=h,F=f,e.each(g,function(t){A+=t.width}),e.each(p,function(t){T+=t.width}),e.each(m,function(t){P+=t.height}),e.each(b,function(t){F+=t.height});var _=i-P-F,R=a-A-T;(R!==C||_!==D)&&(e.each(g,function(t){t.height=_}),e.each(p,function(t){t.height=_}),e.each(m,function(t){t.options.fullWidth||(t.width=R)}),e.each(b,function(t){t.options.fullWidth||(t.width=R)}),D=_,C=R);var V=u,L=h;e.each(g.concat(m),l),V+=C,L+=D,e.each(p,l),e.each(b,l),t.chartArea={left:A,top:P,right:A+C,bottom:P+D},e.each(v,function(e){e.left=t.chartArea.left,e.top=t.chartArea.top,e.right=t.chartArea.right,e.bottom=t.chartArea.bottom,e.update(C,D)})}}}}},{}],30:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){return t.usePointStyle?e*Math.SQRT2:t.boxWidth}var a=t.helpers,i=a.noop;t.defaults.global.legend={display:!0,position:"top",fullWidth:!0,reverse:!1,onClick:function(t,e){var a=e.datasetIndex,i=this.chart,n=i.getDatasetMeta(a);n.hidden=null===n.hidden?!i.data.datasets[a].hidden:null,i.update()},onHover:null,labels:{boxWidth:40,padding:10,generateLabels:function(t){var e=t.data;return a.isArray(e.datasets)?e.datasets.map(function(e,i){return{text:e.label,fillStyle:a.isArray(e.backgroundColor)?e.backgroundColor[0]:e.backgroundColor,hidden:!t.isDatasetVisible(i),lineCap:e.borderCapStyle,lineDash:e.borderDash,lineDashOffset:e.borderDashOffset,lineJoin:e.borderJoinStyle,lineWidth:e.borderWidth,strokeStyle:e.borderColor,pointStyle:e.pointStyle,datasetIndex:i}},this):[]}}},t.Legend=t.Element.extend({initialize:function(t){a.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:i,update:function(t,e,a){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=a,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:i,beforeSetDimensions:i,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:i,beforeBuildLabels:i,buildLabels:function(){var t=this;t.legendItems=t.options.labels.generateLabels.call(t,t.chart),t.options.reverse&&t.legendItems.reverse()},afterBuildLabels:i,beforeFit:i,fit:function(){var i=this,n=i.options,o=n.labels,r=n.display,l=i.ctx,s=t.defaults.global,d=a.getValueOrDefault,u=d(o.fontSize,s.defaultFontSize),c=d(o.fontStyle,s.defaultFontStyle),h=d(o.fontFamily,s.defaultFontFamily),f=a.fontString(u,c,h),g=i.legendHitBoxes=[],p=i.minSize,m=i.isHorizontal();if(m?(p.width=i.maxWidth,p.height=r?10:0):(p.width=r?10:0,p.height=i.maxHeight),r)if(l.font=f,m){var b=i.lineWidths=[0],v=i.legendItems.length?u+o.padding:0;l.textAlign="left",l.textBaseline="top",a.each(i.legendItems,function(t,a){var n=e(o,u),r=n+u/2+l.measureText(t.text).width;b[b.length-1]+r+o.padding>=i.width&&(v+=u+o.padding,b[b.length]=i.left),g[a]={left:0,top:0,width:r,height:u},b[b.length-1]+=r+o.padding}),p.height+=v}else{var x=o.padding,y=i.columnWidths=[],k=o.padding,S=0,w=0,M=u+x;a.each(i.legendItems,function(t,a){var i=e(o,u),n=i+u/2+l.measureText(t.text).width;w+M>p.height&&(k+=S+o.padding,y.push(S),S=0,w=0),S=Math.max(S,n),w+=M,g[a]={left:0,top:0,width:n,height:u}}),k+=S,y.push(S),p.width+=k}i.width=p.width,i.height=p.height},afterFit:i,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var i=this,n=i.options,o=n.labels,r=t.defaults.global,l=r.elements.line,s=i.width,d=i.lineWidths;if(n.display){var u,c=i.ctx,h=a.getValueOrDefault,f=h(o.fontColor,r.defaultFontColor),g=h(o.fontSize,r.defaultFontSize),p=h(o.fontStyle,r.defaultFontStyle),m=h(o.fontFamily,r.defaultFontFamily),b=a.fontString(g,p,m);c.textAlign="left",c.textBaseline="top",c.lineWidth=.5,c.strokeStyle=f,c.fillStyle=f,c.font=b;var v=e(o,g),x=i.legendHitBoxes,y=function(e,a,i){if(!(isNaN(v)||0>=v)){c.save(),c.fillStyle=h(i.fillStyle,r.defaultColor),c.lineCap=h(i.lineCap,l.borderCapStyle),c.lineDashOffset=h(i.lineDashOffset,l.borderDashOffset),c.lineJoin=h(i.lineJoin,l.borderJoinStyle),c.lineWidth=h(i.lineWidth,l.borderWidth),c.strokeStyle=h(i.strokeStyle,r.defaultColor);var o=0===h(i.lineWidth,l.borderWidth);if(c.setLineDash&&c.setLineDash(h(i.lineDash,l.borderDash)),n.labels&&n.labels.usePointStyle){var s=g*Math.SQRT2/2,d=s/Math.SQRT2,u=e+d,f=a+d;t.canvasHelpers.drawPoint(c,i.pointStyle,s,u,f)}else o||c.strokeRect(e,a,v,g),c.fillRect(e,a,v,g);c.restore()}},k=function(t,e,a,i){c.fillText(a.text,v+g/2+t,e),a.hidden&&(c.beginPath(),c.lineWidth=2,c.moveTo(v+g/2+t,e+g/2),c.lineTo(v+g/2+t+i,e+g/2),c.stroke())},S=i.isHorizontal();u=S?{x:i.left+(s-d[0])/2,y:i.top+o.padding,line:0}:{x:i.left+o.padding,y:i.top+o.padding,line:0};var w=g+o.padding;a.each(i.legendItems,function(t,e){var a=c.measureText(t.text).width,n=v+g/2+a,r=u.x,l=u.y;S?r+n>=s&&(l=u.y+=w,u.line++,r=u.x=i.left+(s-d[u.line])/2):l+w>i.bottom&&(r=u.x=r+i.columnWidths[u.line]+o.padding,l=u.y=i.top,u.line++),y(r,l,t),x[e].left=r,x[e].top=l,k(r,l,t,a),S?u.x+=n+o.padding:u.y+=w})}},handleEvent:function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type,o=!1;if("mousemove"===n){if(!i.onHover)return}else{if("click"!==n)return;if(!i.onClick)return}var r=a.getRelativePosition(t,e.chart.chart),l=r.x,s=r.y;if(l>=e.left&&l<=e.right&&s>=e.top&&s<=e.bottom)for(var d=e.legendHitBoxes,u=0;u<d.length;++u){var c=d[u];if(l>=c.left&&l<=c.left+c.width&&s>=c.top&&s<=c.top+c.height){if("click"===n){i.onClick.call(e,t,e.legendItems[u]),o=!0;break}if("mousemove"===n){i.onHover.call(e,t,e.legendItems[u]),o=!0;break}}}return o}}),t.plugins.register({beforeInit:function(e){var a=e.options,i=a.legend;i&&(e.legend=new t.Legend({ctx:e.chart.ctx,options:i,chart:e}),t.layoutService.addBox(e,e.legend))}})}},{}],31:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers.noop;t.plugins={_plugins:[],register:function(t){var e=this._plugins;[].concat(t).forEach(function(t){-1===e.indexOf(t)&&e.push(t)})},unregister:function(t){var e=this._plugins;[].concat(t).forEach(function(t){var a=e.indexOf(t);-1!==a&&e.splice(a,1)})},clear:function(){this._plugins=[]},count:function(){return this._plugins.length},getAll:function(){return this._plugins},notify:function(t,e){var a,i,n=this._plugins,o=n.length;
13
- for(a=0;o>a;++a)if(i=n[a],"function"==typeof i[t]&&i[t].apply(i,e||[])===!1)return!1;return!0}},t.PluginBase=t.Element.extend({beforeInit:e,afterInit:e,beforeUpdate:e,afterUpdate:e,beforeDraw:e,afterDraw:e,destroy:e}),t.pluginService=t.plugins}},{}],32:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.scale={display:!0,position:"left",gridLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1,drawBorder:!0,drawOnChartArea:!0,drawTicks:!0,tickMarkLength:10,zeroLineWidth:1,zeroLineColor:"rgba(0,0,0,0.25)",offsetGridLines:!1,borderDash:[],borderDashOffset:0},scaleLabel:{labelString:"",display:!1},ticks:{beginAtZero:!1,minRotation:0,maxRotation:50,mirror:!1,padding:10,reverse:!1,display:!0,autoSkip:!0,autoSkipPadding:0,labelOffset:0,callback:t.Ticks.formatters.values}},t.Scale=t.Element.extend({beforeUpdate:function(){e.callCallback(this.options.beforeUpdate,[this])},update:function(t,a,i){var n=this;return n.beforeUpdate(),n.maxWidth=t,n.maxHeight=a,n.margins=e.extend({left:0,right:0,top:0,bottom:0},i),n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeDataLimits(),n.determineDataLimits(),n.afterDataLimits(),n.beforeBuildTicks(),n.buildTicks(),n.afterBuildTicks(),n.beforeTickToLabelConversion(),n.convertTicksToLabels(),n.afterTickToLabelConversion(),n.beforeCalculateTickRotation(),n.calculateTickRotation(),n.afterCalculateTickRotation(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate(),n.minSize},afterUpdate:function(){e.callCallback(this.options.afterUpdate,[this])},beforeSetDimensions:function(){e.callCallback(this.options.beforeSetDimensions,[this])},setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0},afterSetDimensions:function(){e.callCallback(this.options.afterSetDimensions,[this])},beforeDataLimits:function(){e.callCallback(this.options.beforeDataLimits,[this])},determineDataLimits:e.noop,afterDataLimits:function(){e.callCallback(this.options.afterDataLimits,[this])},beforeBuildTicks:function(){e.callCallback(this.options.beforeBuildTicks,[this])},buildTicks:e.noop,afterBuildTicks:function(){e.callCallback(this.options.afterBuildTicks,[this])},beforeTickToLabelConversion:function(){e.callCallback(this.options.beforeTickToLabelConversion,[this])},convertTicksToLabels:function(){var t=this,e=t.options.ticks;t.ticks=t.ticks.map(e.userCallback||e.callback)},afterTickToLabelConversion:function(){e.callCallback(this.options.afterTickToLabelConversion,[this])},beforeCalculateTickRotation:function(){e.callCallback(this.options.beforeCalculateTickRotation,[this])},calculateTickRotation:function(){var a=this,i=a.ctx,n=t.defaults.global,o=a.options.ticks,r=e.getValueOrDefault(o.fontSize,n.defaultFontSize),l=e.getValueOrDefault(o.fontStyle,n.defaultFontStyle),s=e.getValueOrDefault(o.fontFamily,n.defaultFontFamily),d=e.fontString(r,l,s);i.font=d;var u,c=i.measureText(a.ticks[0]).width,h=i.measureText(a.ticks[a.ticks.length-1]).width;if(a.labelRotation=o.minRotation||0,a.paddingRight=0,a.paddingLeft=0,a.options.display&&a.isHorizontal()){a.paddingRight=h/2+3,a.paddingLeft=c/2+3,a.longestTextCache||(a.longestTextCache={});for(var f,g,p=e.longestText(i,d,a.ticks,a.longestTextCache),m=p,b=a.getPixelForTick(1)-a.getPixelForTick(0)-6;m>b&&a.labelRotation<o.maxRotation;){if(f=Math.cos(e.toRadians(a.labelRotation)),g=Math.sin(e.toRadians(a.labelRotation)),u=f*c,u+r/2>a.yLabelWidth&&(a.paddingLeft=u+r/2),a.paddingRight=r/2,g*p>a.maxHeight){a.labelRotation--;break}a.labelRotation++,m=f*p}}a.margins&&(a.paddingLeft=Math.max(a.paddingLeft-a.margins.left,0),a.paddingRight=Math.max(a.paddingRight-a.margins.right,0))},afterCalculateTickRotation:function(){e.callCallback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){e.callCallback(this.options.beforeFit,[this])},fit:function(){var a=this,i=a.minSize={width:0,height:0},n=a.options,o=t.defaults.global,r=n.ticks,l=n.scaleLabel,s=n.gridLines,d=n.display,u=a.isHorizontal(),c=e.getValueOrDefault(r.fontSize,o.defaultFontSize),h=e.getValueOrDefault(r.fontStyle,o.defaultFontStyle),f=e.getValueOrDefault(r.fontFamily,o.defaultFontFamily),g=e.fontString(c,h,f),p=e.getValueOrDefault(l.fontSize,o.defaultFontSize),m=n.gridLines.tickMarkLength;if(u?i.width=a.isFullWidth()?a.maxWidth-a.margins.left-a.margins.right:a.maxWidth:i.width=d&&s.drawTicks?m:0,u?i.height=d&&s.drawTicks?m:0:i.height=a.maxHeight,l.display&&d&&(u?i.height+=1.5*p:i.width+=1.5*p),r.display&&d){a.longestTextCache||(a.longestTextCache={});var b=e.longestText(a.ctx,g,a.ticks,a.longestTextCache),v=e.numberOfLabelLines(a.ticks),x=.5*c;if(u){a.longestLabelWidth=b;var y=Math.sin(e.toRadians(a.labelRotation))*a.longestLabelWidth+c*v+x*v;i.height=Math.min(a.maxHeight,i.height+y),a.ctx.font=g;var k=a.ctx.measureText(a.ticks[0]).width,S=a.ctx.measureText(a.ticks[a.ticks.length-1]).width,w=Math.cos(e.toRadians(a.labelRotation)),M=Math.sin(e.toRadians(a.labelRotation));a.paddingLeft=0!==a.labelRotation?w*k+3:k/2+3,a.paddingRight=0!==a.labelRotation?M*(c/2)+3:S/2+3}else{var C=a.maxWidth-i.width,D=r.mirror;D?b=0:b+=a.options.ticks.padding,C>b?i.width+=b:i.width=a.maxWidth,a.paddingTop=c/2,a.paddingBottom=c/2}}a.margins&&(a.paddingLeft=Math.max(a.paddingLeft-a.margins.left,0),a.paddingTop=Math.max(a.paddingTop-a.margins.top,0),a.paddingRight=Math.max(a.paddingRight-a.margins.right,0),a.paddingBottom=Math.max(a.paddingBottom-a.margins.bottom,0)),a.width=i.width,a.height=i.height},afterFit:function(){e.callCallback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){return null===t||"undefined"==typeof t?NaN:"number"!=typeof t||isFinite(t)?"object"==typeof t?t instanceof Date||t.isValid?t:this.getRightValue(this.isHorizontal()?t.x:t.y):t:NaN},getLabelForIndex:e.noop,getPixelForValue:e.noop,getValueForPixel:e.noop,getPixelForTick:function(t,e){var a=this;if(a.isHorizontal()){var i=a.width-(a.paddingLeft+a.paddingRight),n=i/Math.max(a.ticks.length-(a.options.gridLines.offsetGridLines?0:1),1),o=n*t+a.paddingLeft;e&&(o+=n/2);var r=a.left+Math.round(o);return r+=a.isFullWidth()?a.margins.left:0}var l=a.height-(a.paddingTop+a.paddingBottom);return a.top+t*(l/(a.ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var a=e.width-(e.paddingLeft+e.paddingRight),i=a*t+e.paddingLeft,n=e.left+Math.round(i);return n+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){var t=this,e=t.min,a=t.max;return t.getPixelForValue(t.beginAtZero?0:0>e&&0>a?a:e>0&&a>0?e:0)},draw:function(a){var i=this,n=i.options;if(n.display){var o,r,l=i.ctx,s=t.defaults.global,d=n.ticks,u=n.gridLines,c=n.scaleLabel,h=0!==i.labelRotation,f=d.autoSkip,g=i.isHorizontal();d.maxTicksLimit&&(r=d.maxTicksLimit);var p=e.getValueOrDefault(d.fontColor,s.defaultFontColor),m=e.getValueOrDefault(d.fontSize,s.defaultFontSize),b=e.getValueOrDefault(d.fontStyle,s.defaultFontStyle),v=e.getValueOrDefault(d.fontFamily,s.defaultFontFamily),x=e.fontString(m,b,v),y=u.tickMarkLength,k=e.getValueOrDefault(u.borderDash,s.borderDash),S=e.getValueOrDefault(u.borderDashOffset,s.borderDashOffset),w=e.getValueOrDefault(c.fontColor,s.defaultFontColor),M=e.getValueOrDefault(c.fontSize,s.defaultFontSize),C=e.getValueOrDefault(c.fontStyle,s.defaultFontStyle),D=e.getValueOrDefault(c.fontFamily,s.defaultFontFamily),I=e.fontString(M,C,D),A=e.toRadians(i.labelRotation),T=Math.cos(A),P=i.longestLabelWidth*T;l.fillStyle=p;var F=[];if(g){if(o=!1,h&&(P/=2),(P+d.autoSkipPadding)*i.ticks.length>i.width-(i.paddingLeft+i.paddingRight)&&(o=1+Math.floor((P+d.autoSkipPadding)*i.ticks.length/(i.width-(i.paddingLeft+i.paddingRight)))),r&&i.ticks.length>r)for(;!o||i.ticks.length/(o||1)>r;)o||(o=1),o+=1;f||(o=!1)}var _="right"===n.position?i.left:i.right-y,R="right"===n.position?i.left+y:i.right,V="bottom"===n.position?i.top:i.bottom-y,L="bottom"===n.position?i.top+y:i.bottom;if(e.each(i.ticks,function(t,r){if(void 0!==t&&null!==t){var l=i.ticks.length===r+1,s=o>1&&r%o>0||r%o===0&&r+o>=i.ticks.length;if((!s||l)&&void 0!==t&&null!==t){var c,f;r===("undefined"!=typeof i.zeroLineIndex?i.zeroLineIndex:0)?(c=u.zeroLineWidth,f=u.zeroLineColor):(c=e.getValueAtIndexOrDefault(u.lineWidth,r),f=e.getValueAtIndexOrDefault(u.color,r));var p,m,b,v,x,w,M,C,D,I,T="middle",P="middle";if(g){h||(P="top"===n.position?"bottom":"top"),T=h?"right":"center";var O=i.getPixelForTick(r)+e.aliasPixel(c);D=i.getPixelForTick(r,u.offsetGridLines)+d.labelOffset,I=h?i.top+12:"top"===n.position?i.bottom-y:i.top+y,p=b=x=M=O,m=V,v=L,w=a.top,C=a.bottom}else{"left"===n.position?d.mirror?(D=i.right+d.padding,T="left"):(D=i.right-d.padding,T="right"):d.mirror?(D=i.left-d.padding,T="right"):(D=i.left+d.padding,T="left");var B=i.getPixelForTick(r);B+=e.aliasPixel(c),I=i.getPixelForTick(r,u.offsetGridLines),p=_,b=R,x=a.left,M=a.right,m=v=w=C=B}F.push({tx1:p,ty1:m,tx2:b,ty2:v,x1:x,y1:w,x2:M,y2:C,labelX:D,labelY:I,glWidth:c,glColor:f,glBorderDash:k,glBorderDashOffset:S,rotation:-1*A,label:t,textBaseline:P,textAlign:T})}}}),e.each(F,function(t){if(u.display&&(l.save(),l.lineWidth=t.glWidth,l.strokeStyle=t.glColor,l.setLineDash&&(l.setLineDash(t.glBorderDash),l.lineDashOffset=t.glBorderDashOffset),l.beginPath(),u.drawTicks&&(l.moveTo(t.tx1,t.ty1),l.lineTo(t.tx2,t.ty2)),u.drawOnChartArea&&(l.moveTo(t.x1,t.y1),l.lineTo(t.x2,t.y2)),l.stroke(),l.restore()),d.display){l.save(),l.translate(t.labelX,t.labelY),l.rotate(t.rotation),l.font=x,l.textBaseline=t.textBaseline,l.textAlign=t.textAlign;var a=t.label;if(e.isArray(a))for(var i=0,n=-(a.length-1)*m*.75;i<a.length;++i)l.fillText(""+a[i],0,n),n+=1.5*m;else l.fillText(a,0,0);l.restore()}}),c.display){var O,B,W=0;if(g)O=i.left+(i.right-i.left)/2,B="bottom"===n.position?i.bottom-M/2:i.top+M/2;else{var z="left"===n.position;O=z?i.left+M/2:i.right-M/2,B=i.top+(i.bottom-i.top)/2,W=z?-.5*Math.PI:.5*Math.PI}l.save(),l.translate(O,B),l.rotate(W),l.textAlign="center",l.textBaseline="middle",l.fillStyle=w,l.font=I,l.fillText(c.labelString,0,0),l.restore()}if(u.drawBorder){l.lineWidth=e.getValueAtIndexOrDefault(u.lineWidth,0),l.strokeStyle=e.getValueAtIndexOrDefault(u.color,0);var N=i.left,E=i.right,H=i.top,U=i.bottom,j=e.aliasPixel(l.lineWidth);g?(H=U="top"===n.position?i.bottom:i.top,H+=j,U+=j):(N=E="left"===n.position?i.right:i.left,N+=j,E+=j),l.beginPath(),l.moveTo(N,H),l.lineTo(E,U),l.stroke()}}}})}},{}],33:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.scaleService={constructors:{},defaults:{},registerScaleType:function(t,a,i){this.constructors[t]=a,this.defaults[t]=e.clone(i)},getScaleConstructor:function(t){return this.constructors.hasOwnProperty(t)?this.constructors[t]:void 0},getScaleDefaults:function(a){return this.defaults.hasOwnProperty(a)?e.scaleMerge(t.defaults.scale,this.defaults[a]):{}},updateScaleDefaults:function(t,a){var i=this.defaults;i.hasOwnProperty(t)&&(i[t]=e.extend(i[t],a))},addScalesToLayout:function(a){e.each(a.scales,function(e){t.layoutService.addBox(a,e)})}}}},{}],34:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.Ticks={generators:{linear:function(t,a){var i,n=[];if(t.stepSize&&t.stepSize>0)i=t.stepSize;else{var o=e.niceNum(a.max-a.min,!1);i=e.niceNum(o/(t.maxTicks-1),!0)}var r=Math.floor(a.min/i)*i,l=Math.ceil(a.max/i)*i;if(t.min&&t.max&&t.stepSize){var s=(t.max-t.min)%t.stepSize===0;s&&(r=t.min,l=t.max)}var d=(l-r)/i;d=e.almostEquals(d,Math.round(d),i/1e3)?Math.round(d):Math.ceil(d),n.push(void 0!==t.min?t.min:r);for(var u=1;d>u;++u)n.push(r+u*i);return n.push(void 0!==t.max?t.max:l),n},logarithmic:function(t,a){for(var i=[],n=e.getValueOrDefault,o=n(t.min,Math.pow(10,Math.floor(e.log10(a.min))));o<a.max;){i.push(o);var r,l;0===o?(r=Math.floor(e.log10(a.minNotZero)),l=Math.round(a.minNotZero/Math.pow(10,r))):(r=Math.floor(e.log10(o)),l=Math.floor(o/Math.pow(10,r))+1),10===l&&(l=1,++r),o=l*Math.pow(10,r)}var s=n(t.max,o);return i.push(s),i}},formatters:{values:function(t){return e.isArray(t)?t:""+t},linear:function(t,a,i){var n=i.length>3?i[2]-i[1]:i[1]-i[0];Math.abs(n)>1&&t!==Math.floor(t)&&(n=t-Math.floor(t));var o=e.log10(Math.abs(n)),r="";if(0!==t){var l=-1*Math.floor(o);l=Math.max(Math.min(l,20),0),r=t.toFixed(l)}else r="0";return r},logarithmic:function(t,a,i){var n=t/Math.pow(10,Math.floor(e.log10(t)));return 0===t?"0":1===n||2===n||5===n||0===a||a===i.length-1?t.toExponential():""}}}}},{}],35:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.global.title={display:!1,position:"top",fullWidth:!0,fontStyle:"bold",padding:10,text:""};var a=e.noop;t.Title=t.Element.extend({initialize:function(a){var i=this;e.extend(i,a),i.options=e.configMerge(t.defaults.global.title,a.options),i.legendHitBoxes=[]},beforeUpdate:function(){var a=this.chart.options;a&&a.title&&(this.options=e.configMerge(t.defaults.global.title,a.title))},update:function(t,e,a){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=a,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:a,beforeSetDimensions:a,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:a,beforeBuildLabels:a,buildLabels:a,afterBuildLabels:a,beforeFit:a,fit:function(){var a=this,i=e.getValueOrDefault,n=a.options,o=t.defaults.global,r=n.display,l=i(n.fontSize,o.defaultFontSize),s=a.minSize;a.isHorizontal()?(s.width=a.maxWidth,s.height=r?l+2*n.padding:0):(s.width=r?l+2*n.padding:0,s.height=a.maxHeight),a.width=s.width,a.height=s.height},afterFit:a,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var a=this,i=a.ctx,n=e.getValueOrDefault,o=a.options,r=t.defaults.global;if(o.display){var l,s,d,u=n(o.fontSize,r.defaultFontSize),c=n(o.fontStyle,r.defaultFontStyle),h=n(o.fontFamily,r.defaultFontFamily),f=e.fontString(u,c,h),g=0,p=a.top,m=a.left,b=a.bottom,v=a.right;i.fillStyle=n(o.fontColor,r.defaultFontColor),i.font=f,a.isHorizontal()?(l=m+(v-m)/2,s=p+(b-p)/2,d=v-m):(l="left"===o.position?m+u/2:v-u/2,s=p+(b-p)/2,d=b-p,g=Math.PI*("left"===o.position?-.5:.5)),i.save(),i.translate(l,s),i.rotate(g),i.textAlign="center",i.textBaseline="middle",i.fillText(o.text,0,0,d),i.restore()}}}),t.plugins.register({beforeInit:function(e){var a=e.options,i=a.title;i&&(e.titleBlock=new t.Title({ctx:e.chart.ctx,options:i,chart:e}),t.layoutService.addBox(e,e.titleBlock))}})}},{}],36:[function(t,e,a){"use strict";e.exports=function(t){function e(t,e){var a=s.color(t);return a.alpha(e*a.alpha()).rgbaString()}function a(t,e){return e&&(s.isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function i(t){var e=t._xScale,a=t._yScale||t._scale,i=t._index,n=t._datasetIndex;return{xLabel:e?e.getLabelForIndex(i,n):"",yLabel:a?a.getLabelForIndex(i,n):"",index:i,datasetIndex:n,x:t._model.x,y:t._model.y}}function n(e){var a=t.defaults.global,i=s.getValueOrDefault;return{xPadding:e.xPadding,yPadding:e.yPadding,xAlign:e.xAlign,yAlign:e.yAlign,bodyFontColor:e.bodyFontColor,_bodyFontFamily:i(e.bodyFontFamily,a.defaultFontFamily),_bodyFontStyle:i(e.bodyFontStyle,a.defaultFontStyle),_bodyAlign:e.bodyAlign,bodyFontSize:i(e.bodyFontSize,a.defaultFontSize),bodySpacing:e.bodySpacing,titleFontColor:e.titleFontColor,_titleFontFamily:i(e.titleFontFamily,a.defaultFontFamily),_titleFontStyle:i(e.titleFontStyle,a.defaultFontStyle),titleFontSize:i(e.titleFontSize,a.defaultFontSize),_titleAlign:e.titleAlign,titleSpacing:e.titleSpacing,titleMarginBottom:e.titleMarginBottom,footerFontColor:e.footerFontColor,_footerFontFamily:i(e.footerFontFamily,a.defaultFontFamily),_footerFontStyle:i(e.footerFontStyle,a.defaultFontStyle),footerFontSize:i(e.footerFontSize,a.defaultFontSize),_footerAlign:e.footerAlign,footerSpacing:e.footerSpacing,footerMarginTop:e.footerMarginTop,caretSize:e.caretSize,cornerRadius:e.cornerRadius,backgroundColor:e.backgroundColor,opacity:0,legendColorBackground:e.multiKeyBackground,displayColors:e.displayColors}}function o(t,e){var a=t._chart.ctx,i=2*e.yPadding,n=0,o=e.body,r=o.reduce(function(t,e){return t+e.before.length+e.lines.length+e.after.length},0);r+=e.beforeBody.length+e.afterBody.length;var l=e.title.length,d=e.footer.length,u=e.titleFontSize,c=e.bodyFontSize,h=e.footerFontSize;i+=l*u,i+=l?(l-1)*e.titleSpacing:0,i+=l?e.titleMarginBottom:0,i+=r*c,i+=r?(r-1)*e.bodySpacing:0,i+=d?e.footerMarginTop:0,i+=d*h,i+=d?(d-1)*e.footerSpacing:0;var f=0,g=function(t){n=Math.max(n,a.measureText(t).width+f)};return a.font=s.fontString(u,e._titleFontStyle,e._titleFontFamily),s.each(e.title,g),a.font=s.fontString(c,e._bodyFontStyle,e._bodyFontFamily),s.each(e.beforeBody.concat(e.afterBody),g),f=e.displayColors?c+2:0,s.each(o,function(t){s.each(t.before,g),s.each(t.lines,g),s.each(t.after,g)}),f=0,a.font=s.fontString(h,e._footerFontStyle,e._footerFontFamily),s.each(e.footer,g),n+=2*e.xPadding,{width:n,height:i}}function r(t,e){var a=t._model,i=t._chart,n=t._chartInstance.chartArea,o="center",r="center";a.y<e.height?r="top":a.y>i.height-e.height&&(r="bottom");var l,s,d,u,c,h=(n.left+n.right)/2,f=(n.top+n.bottom)/2;"center"===r?(l=function(t){return h>=t},s=function(t){return t>h}):(l=function(t){return t<=e.width/2},s=function(t){return t>=i.width-e.width/2}),d=function(t){return t+e.width>i.width},u=function(t){return t-e.width<0},c=function(t){return f>=t?"top":"bottom"},l(a.x)?(o="left",d(a.x)&&(o="center",r=c(a.y))):s(a.x)&&(o="right",u(a.x)&&(o="center",r=c(a.y)));var g=t._options;return{xAlign:g.xAlign?g.xAlign:o,yAlign:g.yAlign?g.yAlign:r}}function l(t,e,a){var i=t.x,n=t.y,o=t.caretSize,r=t.caretPadding,l=t.cornerRadius,s=a.xAlign,d=a.yAlign,u=o+r,c=l+r;return"right"===s?i-=e.width:"center"===s&&(i-=e.width/2),"top"===d?n+=u:n-="bottom"===d?e.height+u:e.height/2,"center"===d?"left"===s?i+=u:"right"===s&&(i-=u):"left"===s?i-=c:"right"===s&&(i+=c),{x:i,y:n}}var s=t.helpers;t.defaults.global.tooltips={enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFontStyle:"bold",titleSpacing:2,titleMarginBottom:6,titleFontColor:"#fff",titleAlign:"left",bodySpacing:2,bodyFontColor:"#fff",bodyAlign:"left",footerFontStyle:"bold",footerSpacing:2,footerMarginTop:6,footerFontColor:"#fff",footerAlign:"left",yPadding:6,xPadding:6,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,callbacks:{beforeTitle:s.noop,title:function(t,e){var a="",i=e.labels,n=i?i.length:0;if(t.length>0){var o=t[0];o.xLabel?a=o.xLabel:n>0&&o.index<n&&(a=i[o.index])}return a},afterTitle:s.noop,beforeBody:s.noop,beforeLabel:s.noop,label:function(t,e){var a=e.datasets[t.datasetIndex].label||"";return a+": "+t.yLabel},labelColor:function(t,e){var a=e.getDatasetMeta(t.datasetIndex),i=a.data[t.index],n=i._view;return{borderColor:n.borderColor,backgroundColor:n.backgroundColor}},afterLabel:s.noop,afterBody:s.noop,beforeFooter:s.noop,footer:s.noop,afterFooter:s.noop}},t.Tooltip=t.Element.extend({initialize:function(){this._model=n(this._options)},getTitle:function(){var t=this,e=t._options,i=e.callbacks,n=i.beforeTitle.apply(t,arguments),o=i.title.apply(t,arguments),r=i.afterTitle.apply(t,arguments),l=[];return l=a(l,n),l=a(l,o),l=a(l,r)},getBeforeBody:function(){var t=this._options.callbacks.beforeBody.apply(this,arguments);return s.isArray(t)?t:void 0!==t?[t]:[]},getBody:function(t,e){var i=this,n=i._options.callbacks,o=[];return s.each(t,function(t){var r={before:[],lines:[],after:[]};a(r.before,n.beforeLabel.call(i,t,e)),a(r.lines,n.label.call(i,t,e)),a(r.after,n.afterLabel.call(i,t,e)),o.push(r)}),o},getAfterBody:function(){var t=this._options.callbacks.afterBody.apply(this,arguments);return s.isArray(t)?t:void 0!==t?[t]:[]},getFooter:function(){var t=this,e=t._options.callbacks,i=e.beforeFooter.apply(t,arguments),n=e.footer.apply(t,arguments),o=e.afterFooter.apply(t,arguments),r=[];return r=a(r,i),r=a(r,n),r=a(r,o)},update:function(e){var a,d,u=this,c=u._options,h=u._model,f=u._model=n(c),g=u._active,p=u._data,m=u._chartInstance,b={xAlign:h.xAlign,yAlign:h.yAlign},v={x:h.x,y:h.y},x={width:h.width,height:h.height},y={x:h.caretX,y:h.caretY};if(g.length){f.opacity=1;var k=[];y=t.Tooltip.positioners[c.position](g,u._eventPosition);var S=[];for(a=0,d=g.length;d>a;++a)S.push(i(g[a]));c.filter&&(S=S.filter(function(t){return c.filter(t,p)})),c.itemSort&&(S=S.sort(function(t,e){return c.itemSort(t,e,p)})),s.each(S,function(t){k.push(c.callbacks.labelColor.call(u,t,m))}),f.title=u.getTitle(S,p),f.beforeBody=u.getBeforeBody(S,p),f.body=u.getBody(S,p),f.afterBody=u.getAfterBody(S,p),f.footer=u.getFooter(S,p),f.x=Math.round(y.x),f.y=Math.round(y.y),f.caretPadding=s.getValueOrDefault(y.padding,2),f.labelColors=k,f.dataPoints=S,x=o(this,f),b=r(this,x),v=l(f,x,b)}else f.opacity=0;return f.xAlign=b.xAlign,f.yAlign=b.yAlign,f.x=v.x,f.y=v.y,f.width=x.width,f.height=x.height,f.caretX=y.x,f.caretY=y.y,u._model=f,e&&c.custom&&c.custom.call(u,f),u},drawCaret:function(t,a,i){var n,o,r,l,s,d,u=this._view,c=this._chart.ctx,h=u.caretSize,f=u.cornerRadius,g=u.xAlign,p=u.yAlign,m=t.x,b=t.y,v=a.width,x=a.height;"center"===p?("left"===g?(n=m,o=n-h,r=n):(n=m+v,o=n+h,r=n),s=b+x/2,l=s-h,d=s+h):("left"===g?(n=m+f,o=n+h,r=o+h):"right"===g?(n=m+v-f,o=n-h,r=o-h):(o=m+v/2,n=o-h,r=o+h),"top"===p?(l=b,s=l-h,d=l):(l=b+x,s=l+h,d=l)),c.fillStyle=e(u.backgroundColor,i),c.beginPath(),c.moveTo(n,l),c.lineTo(o,s),c.lineTo(r,d),c.closePath(),c.fill()},drawTitle:function(t,a,i,n){var o=a.title;if(o.length){i.textAlign=a._titleAlign,i.textBaseline="top";var r=a.titleFontSize,l=a.titleSpacing;i.fillStyle=e(a.titleFontColor,n),i.font=s.fontString(r,a._titleFontStyle,a._titleFontFamily);var d,u;for(d=0,u=o.length;u>d;++d)i.fillText(o[d],t.x,t.y),t.y+=r+l,d+1===o.length&&(t.y+=a.titleMarginBottom-l)}},drawBody:function(t,a,i,n){var o=a.bodyFontSize,r=a.bodySpacing,l=a.body;i.textAlign=a._bodyAlign,i.textBaseline="top";var d=e(a.bodyFontColor,n);i.fillStyle=d,i.font=s.fontString(o,a._bodyFontStyle,a._bodyFontFamily);var u=0,c=function(e){i.fillText(e,t.x+u,t.y),t.y+=o+r};s.each(a.beforeBody,c);var h=a.displayColors;u=h?o+2:0,s.each(l,function(r,l){s.each(r.before,c),s.each(r.lines,function(r){h&&(i.fillStyle=e(a.legendColorBackground,n),i.fillRect(t.x,t.y,o,o),i.strokeStyle=e(a.labelColors[l].borderColor,n),i.strokeRect(t.x,t.y,o,o),i.fillStyle=e(a.labelColors[l].backgroundColor,n),i.fillRect(t.x+1,t.y+1,o-2,o-2),i.fillStyle=d),c(r)}),s.each(r.after,c)}),u=0,s.each(a.afterBody,c),t.y-=r},drawFooter:function(t,a,i,n){var o=a.footer;o.length&&(t.y+=a.footerMarginTop,i.textAlign=a._footerAlign,i.textBaseline="top",i.fillStyle=e(a.footerFontColor,n),i.font=s.fontString(a.footerFontSize,a._footerFontStyle,a._footerFontFamily),s.each(o,function(e){i.fillText(e,t.x,t.y),t.y+=a.footerFontSize+a.footerSpacing}))},drawBackground:function(t,a,i,n,o){i.fillStyle=e(a.backgroundColor,o),s.drawRoundedRectangle(i,t.x,t.y,n.width,n.height,a.cornerRadius),i.fill()},draw:function(){var t=this._chart.ctx,e=this._view;if(0!==e.opacity){var a={width:e.width,height:e.height},i={x:e.x,y:e.y},n=Math.abs(e.opacity<.001)?0:e.opacity;this._options.enabled&&(this.drawBackground(i,e,t,a,n),this.drawCaret(i,a,n),i.x+=e.xPadding,i.y+=e.yPadding,this.drawTitle(i,e,t,n),this.drawBody(i,e,t,n),this.drawFooter(i,e,t,n))}},handleEvent:function(t){var e=this,a=e._options,i=!1;if(e._lastActive=e._lastActive||[],"mouseout"===t.type?e._active=[]:e._active=e._chartInstance.getElementsAtEventForMode(t,a.mode,a),i=!s.arrayEquals(e._active,e._lastActive),e._lastActive=e._active,a.enabled||a.custom){e._eventPosition=s.getRelativePosition(t,e._chart);var n=e._model;e.update(!0),e.pivot(),i|=n.x!==e._model.x||n.y!==e._model.y}return i}}),t.Tooltip.positioners={average:function(t){if(!t.length)return!1;var e,a,i=0,n=0,o=0;for(e=0,a=t.length;a>e;++e){var r=t[e];if(r&&r.hasValue()){var l=r.tooltipPosition();i+=l.x,n+=l.y,++o}}return{x:Math.round(i/o),y:Math.round(n/o)}},nearest:function(t,e){var a,i,n,o=e.x,r=e.y,l=Number.POSITIVE_INFINITY;for(i=0,n=t.length;n>i;++i){var d=t[i];if(d&&d.hasValue()){var u=d.getCenterPoint(),c=s.distanceBetweenPoints(e,u);l>c&&(l=c,a=d)}}if(a){var h=a.tooltipPosition();o=h.x,r=h.y}return{x:o,y:r}}}}},{}],37:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults.global;a.elements.arc={backgroundColor:a.defaultColor,borderColor:"#fff",borderWidth:2},t.elements.Arc=t.Element.extend({inLabelRange:function(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hoverRadius,2):!1},inRange:function(t,a){var i=this._view;if(i){for(var n=e.getAngleFromPoint(i,{x:t,y:a}),o=n.angle,r=n.distance,l=i.startAngle,s=i.endAngle;l>s;)s+=2*Math.PI;for(;o>s;)o-=2*Math.PI;for(;l>o;)o+=2*Math.PI;var d=o>=l&&s>=o,u=r>=i.innerRadius&&r<=i.outerRadius;return d&&u}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,a=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*a,y:t.y+Math.sin(e)*a}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,a=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*a,y:t.y+Math.sin(e)*a}},draw:function(){var t=this._chart.ctx,e=this._view,a=e.startAngle,i=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,a,i),t.arc(e.x,e.y,e.innerRadius,i,a,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}},{}],38:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults.global;t.defaults.global.elements.line={tension:.4,backgroundColor:a.defaultColor,borderWidth:3,borderColor:a.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0},t.elements.Line=t.Element.extend({draw:function(){function t(t,e){var a=e._view;e._view.steppedLine===!0?(s.lineTo(a.x,t._view.y),s.lineTo(a.x,a.y)):0===e._view.tension?s.lineTo(a.x,a.y):s.bezierCurveTo(t._view.controlPointNextX,t._view.controlPointNextY,a.controlPointPreviousX,a.controlPointPreviousY,a.x,a.y)}var i=this,n=i._view,o=n.spanGaps,r=n.scaleZero,l=i._loop;l||("top"===n.fill?r=n.scaleTop:"bottom"===n.fill&&(r=n.scaleBottom));var s=i._chart.ctx;s.save();var d=i._children.slice(),u=-1;l&&d.length&&d.push(d[0]);var c,h,f,g;if(d.length&&n.fill){for(s.beginPath(),c=0;c<d.length;++c)h=d[c],f=e.previousItem(d,c),g=h._view,0===c?(l?s.moveTo(r.x,r.y):s.moveTo(g.x,r),g.skip||(u=c,s.lineTo(g.x,g.y))):(f=-1===u?f:d[u],g.skip?o||u!==c-1||(l?s.lineTo(r.x,r.y):s.lineTo(f._view.x,r)):(u!==c-1?o&&-1!==u?t(f,h):l?s.lineTo(g.x,g.y):(s.lineTo(g.x,r),s.lineTo(g.x,g.y)):t(f,h),u=c));l||-1===u||s.lineTo(d[u]._view.x,r),s.fillStyle=n.backgroundColor||a.defaultColor,s.closePath(),s.fill()}var p=a.elements.line;for(s.lineCap=n.borderCapStyle||p.borderCapStyle,s.setLineDash&&s.setLineDash(n.borderDash||p.borderDash),s.lineDashOffset=n.borderDashOffset||p.borderDashOffset,s.lineJoin=n.borderJoinStyle||p.borderJoinStyle,s.lineWidth=n.borderWidth||p.borderWidth,s.strokeStyle=n.borderColor||a.defaultColor,s.beginPath(),u=-1,c=0;c<d.length;++c)h=d[c],f=e.previousItem(d,c),g=h._view,0===c?g.skip||(s.moveTo(g.x,g.y),u=c):(f=-1===u?f:d[u],g.skip||(u!==c-1&&!o||-1===u?s.moveTo(g.x,g.y):t(f,h),u=c));s.stroke(),s.restore()}})}},{}],39:[function(t,e,a){"use strict";e.exports=function(t){function e(t){var e=this._view;return e?Math.pow(t-e.x,2)<Math.pow(e.radius+e.hitRadius,2):!1}function a(t){var e=this._view;return e?Math.pow(t-e.y,2)<Math.pow(e.radius+e.hitRadius,2):!1}var i=t.helpers,n=t.defaults.global,o=n.defaultColor;n.elements.point={radius:3,pointStyle:"circle",backgroundColor:o,borderWidth:1,borderColor:o,hitRadius:1,hoverRadius:4,hoverBorderWidth:1},t.elements.Point=t.Element.extend({inRange:function(t,e){var a=this._view;return a?Math.pow(t-a.x,2)+Math.pow(e-a.y,2)<Math.pow(a.hitRadius+a.radius,2):!1},inLabelRange:e,inXRange:e,inYRange:a,getCenterPoint:function(){var t=this._view;return{x:t.x,y:t.y}},getArea:function(){return Math.PI*Math.pow(this._view.radius,2)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y,padding:t.radius+t.borderWidth}},draw:function(){var e=this._view,a=this._chart.ctx,r=e.pointStyle,l=e.radius,s=e.x,d=e.y;e.skip||(a.strokeStyle=e.borderColor||o,a.lineWidth=i.getValueOrDefault(e.borderWidth,n.elements.point.borderWidth),a.fillStyle=e.backgroundColor||o,t.canvasHelpers.drawPoint(a,r,l,s,d))}})}},{}],40:[function(t,e,a){"use strict";e.exports=function(t){function e(t){return void 0!==t._view.width}function a(t){var a,i,n,o,r=t._view;if(e(t)){var l=r.width/2;a=r.x-l,i=r.x+l,n=Math.min(r.y,r.base),o=Math.max(r.y,r.base)}else{var s=r.height/2;a=Math.min(r.x,r.base),i=Math.max(r.x,r.base),n=r.y-s,o=r.y+s}return{left:a,top:n,right:i,bottom:o}}var i=t.defaults.global;i.elements.rectangle={backgroundColor:i.defaultColor,borderWidth:0,borderColor:i.defaultColor,borderSkipped:"bottom"},t.elements.Rectangle=t.Element.extend({draw:function(){function t(t){return s[(u+t)%4]}var e=this._chart.ctx,a=this._view,i=a.width/2,n=a.x-i,o=a.x+i,r=a.base-(a.base-a.y),l=a.borderWidth/2;a.borderWidth&&(n+=l,o-=l,r+=l),e.beginPath(),e.fillStyle=a.backgroundColor,e.strokeStyle=a.borderColor,e.lineWidth=a.borderWidth;var s=[[n,a.base],[n,r],[o,r],[o,a.base]],d=["bottom","left","top","right"],u=d.indexOf(a.borderSkipped,0);-1===u&&(u=0);var c=t(0);e.moveTo(c[0],c[1]);for(var h=1;4>h;h++)c=t(h),e.lineTo(c[0],c[1]);e.fill(),a.borderWidth&&e.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=!1;if(this._view){var n=a(this);i=t>=n.left&&t<=n.right&&e>=n.top&&e<=n.bottom}return i},inLabelRange:function(t,i){var n=this;if(!n._view)return!1;var o=!1,r=a(n);return o=e(n)?t>=r.left&&t<=r.right:i>=r.top&&i<=r.bottom},inXRange:function(t){var e=a(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=a(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,a,i=this._view;return e(this)?(t=i.x,a=(i.y+i.base)/2):(t=(i.x+i.base)/2,a=i.y),{x:t,y:a}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})}},{}],41:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a={position:"bottom"},i=t.Scale.extend({getLabels:function(){var t=this.chart.data;return(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels},determineDataLimits:function(){var t=this,a=t.getLabels();t.minIndex=0,t.maxIndex=a.length-1;var i;void 0!==t.options.ticks.min&&(i=e.indexOf(a,t.options.ticks.min),t.minIndex=-1!==i?i:t.minIndex),void 0!==t.options.ticks.max&&(i=e.indexOf(a,t.options.ticks.max),t.maxIndex=-1!==i?i:t.maxIndex),t.min=a[t.minIndex],t.max=a[t.maxIndex]},buildTicks:function(){var t=this,e=t.getLabels();t.ticks=0===t.minIndex&&t.maxIndex===e.length-1?e:e.slice(t.minIndex,t.maxIndex+1)},getLabelForIndex:function(t,e){var a=this,i=a.chart.data,n=a.isHorizontal();return i.xLabels&&n||i.yLabels&&!n?a.getRightValue(i.datasets[e].data[t]):a.ticks[t]},getPixelForValue:function(t,e,a,i){var n=this,o=Math.max(n.maxIndex+1-n.minIndex-(n.options.gridLines.offsetGridLines?0:1),1);if(void 0!==t&&isNaN(e)){var r=n.getLabels(),l=r.indexOf(t);e=-1!==l?l:e}if(n.isHorizontal()){var s=n.width-(n.paddingLeft+n.paddingRight),d=s/o,u=d*(e-n.minIndex)+n.paddingLeft;return(n.options.gridLines.offsetGridLines&&i||n.maxIndex===n.minIndex&&i)&&(u+=d/2),
14
- n.left+Math.round(u)}var c=n.height-(n.paddingTop+n.paddingBottom),h=c/o,f=h*(e-n.minIndex)+n.paddingTop;return n.options.gridLines.offsetGridLines&&i&&(f+=h/2),n.top+Math.round(f)},getPixelForTick:function(t,e){return this.getPixelForValue(this.ticks[t],t+this.minIndex,null,e)},getValueForPixel:function(t){var e,a=this,i=Math.max(a.ticks.length-(a.options.gridLines.offsetGridLines?0:1),1),n=a.isHorizontal(),o=n?a.width-(a.paddingLeft+a.paddingRight):a.height-(a.paddingTop+a.paddingBottom),r=o/i;return t-=n?a.left:a.top,a.options.gridLines.offsetGridLines&&(t-=r/2),t-=n?a.paddingLeft:a.paddingTop,e=0>=t?0:Math.round(t/r)},getBasePixel:function(){return this.bottom}});t.scaleService.registerScaleType("category",i,a)}},{}],42:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a={position:"left",ticks:{callback:t.Ticks.formatters.linear}},i=t.LinearScaleBase.extend({determineDataLimits:function(){function t(t){return l?t.xAxisID===a.id:t.yAxisID===a.id}var a=this,i=a.options,n=a.chart,o=n.data,r=o.datasets,l=a.isHorizontal();if(a.min=null,a.max=null,i.stacked){var s={};e.each(r,function(o,r){var l=n.getDatasetMeta(r);void 0===s[l.type]&&(s[l.type]={positiveValues:[],negativeValues:[]});var d=s[l.type].positiveValues,u=s[l.type].negativeValues;n.isDatasetVisible(r)&&t(l)&&e.each(o.data,function(t,e){var n=+a.getRightValue(t);isNaN(n)||l.data[e].hidden||(d[e]=d[e]||0,u[e]=u[e]||0,i.relativePoints?d[e]=100:0>n?u[e]+=n:d[e]+=n)})}),e.each(s,function(t){var i=t.positiveValues.concat(t.negativeValues),n=e.min(i),o=e.max(i);a.min=null===a.min?n:Math.min(a.min,n),a.max=null===a.max?o:Math.max(a.max,o)})}else e.each(r,function(i,o){var r=n.getDatasetMeta(o);n.isDatasetVisible(o)&&t(r)&&e.each(i.data,function(t,e){var i=+a.getRightValue(t);isNaN(i)||r.data[e].hidden||(null===a.min?a.min=i:i<a.min&&(a.min=i),null===a.max?a.max=i:i>a.max&&(a.max=i))})});this.handleTickRangeOptions()},getTickLimit:function(){var a,i=this,n=i.options.ticks;if(i.isHorizontal())a=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(i.width/50));else{var o=e.getValueOrDefault(n.fontSize,t.defaults.global.defaultFontSize);a=Math.min(n.maxTicksLimit?n.maxTicksLimit:11,Math.ceil(i.height/(2*o)))}return a},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,a,i=this,n=i.paddingLeft,o=i.paddingBottom,r=i.start,l=+i.getRightValue(t),s=i.end-r;return i.isHorizontal()?(a=i.width-(n+i.paddingRight),e=i.left+a/s*(l-r),Math.round(e+n)):(a=i.height-(i.paddingTop+o),e=i.bottom-o-a/s*(l-r),Math.round(e))},getValueForPixel:function(t){var e=this,a=e.isHorizontal(),i=e.paddingLeft,n=e.paddingBottom,o=a?e.width-(i+e.paddingRight):e.height-(e.paddingTop+n),r=(a?t-e.left-i:e.bottom-n-t)/o;return e.start+(e.end-e.start)*r},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",i,a)}},{}],43:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=e.noop;t.LinearScaleBase=t.Scale.extend({handleTickRangeOptions:function(){var t=this,a=t.options,i=a.ticks;if(i.beginAtZero){var n=e.sign(t.min),o=e.sign(t.max);0>n&&0>o?t.max=0:n>0&&o>0&&(t.min=0)}void 0!==i.min?t.min=i.min:void 0!==i.suggestedMin&&(t.min=Math.min(t.min,i.suggestedMin)),void 0!==i.max?t.max=i.max:void 0!==i.suggestedMax&&(t.max=Math.max(t.max,i.suggestedMax)),t.min===t.max&&(t.max++,i.beginAtZero||t.min--)},getTickLimit:a,handleDirectionalChanges:a,buildTicks:function(){var a=this,i=a.options,n=i.ticks,o=a.getTickLimit();o=Math.max(2,o);var r={maxTicks:o,min:n.min,max:n.max,stepSize:e.getValueOrDefault(n.fixedStepSize,n.stepSize)},l=a.ticks=t.Ticks.generators.linear(r,a);a.handleDirectionalChanges(),a.max=e.max(l),a.min=e.min(l),n.reverse?(l.reverse(),a.start=a.max,a.end=a.min):(a.start=a.min,a.end=a.max)},convertTicksToLabels:function(){var e=this;e.ticksAsNumbers=e.ticks.slice(),e.zeroLineIndex=e.ticks.indexOf(0),t.Scale.prototype.convertTicksToLabels.call(e)}})}},{}],44:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a={position:"left",ticks:{callback:t.Ticks.formatters.logarithmic}},i=t.Scale.extend({determineDataLimits:function(){function t(t){return d?t.xAxisID===a.id:t.yAxisID===a.id}var a=this,i=a.options,n=i.ticks,o=a.chart,r=o.data,l=r.datasets,s=e.getValueOrDefault,d=a.isHorizontal();if(a.min=null,a.max=null,a.minNotZero=null,i.stacked){var u={};e.each(l,function(n,r){var l=o.getDatasetMeta(r);o.isDatasetVisible(r)&&t(l)&&(void 0===u[l.type]&&(u[l.type]=[]),e.each(n.data,function(t,e){var n=u[l.type],o=+a.getRightValue(t);isNaN(o)||l.data[e].hidden||(n[e]=n[e]||0,i.relativePoints?n[e]=100:n[e]+=o)}))}),e.each(u,function(t){var i=e.min(t),n=e.max(t);a.min=null===a.min?i:Math.min(a.min,i),a.max=null===a.max?n:Math.max(a.max,n)})}else e.each(l,function(i,n){var r=o.getDatasetMeta(n);o.isDatasetVisible(n)&&t(r)&&e.each(i.data,function(t,e){var i=+a.getRightValue(t);isNaN(i)||r.data[e].hidden||(null===a.min?a.min=i:i<a.min&&(a.min=i),null===a.max?a.max=i:i>a.max&&(a.max=i),0!==i&&(null===a.minNotZero||i<a.minNotZero)&&(a.minNotZero=i))})});a.min=s(n.min,a.min),a.max=s(n.max,a.max),a.min===a.max&&(0!==a.min&&null!==a.min?(a.min=Math.pow(10,Math.floor(e.log10(a.min))-1),a.max=Math.pow(10,Math.floor(e.log10(a.max))+1)):(a.min=1,a.max=10))},buildTicks:function(){var a=this,i=a.options,n=i.ticks,o={min:n.min,max:n.max},r=a.ticks=t.Ticks.generators.logarithmic(o,a);a.isHorizontal()||r.reverse(),a.max=e.max(r),a.min=e.min(r),n.reverse?(r.reverse(),a.start=a.max,a.end=a.min):(a.start=a.min,a.end=a.max)},convertTicksToLabels:function(){this.tickValues=this.ticks.slice(),t.Scale.prototype.convertTicksToLabels.call(this)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForTick:function(t){return this.getPixelForValue(this.tickValues[t])},getPixelForValue:function(t){var a,i,n,o=this,r=o.start,l=+o.getRightValue(t),s=o.paddingTop,d=o.paddingBottom,u=o.paddingLeft,c=o.options,h=c.ticks;return o.isHorizontal()?(n=e.log10(o.end)-e.log10(r),0===l?i=o.left+u:(a=o.width-(u+o.paddingRight),i=o.left+a/n*(e.log10(l)-e.log10(r)),i+=u)):(a=o.height-(s+d),0!==r||h.reverse?0===o.end&&h.reverse?(n=e.log10(o.start)-e.log10(o.minNotZero),i=l===o.end?o.top+s:l===o.minNotZero?o.top+s+.02*a:o.top+s+.02*a+.98*a/n*(e.log10(l)-e.log10(o.minNotZero))):(n=e.log10(o.end)-e.log10(r),a=o.height-(s+d),i=o.bottom-d-a/n*(e.log10(l)-e.log10(r))):(n=e.log10(o.end)-e.log10(o.minNotZero),i=l===r?o.bottom-d:l===o.minNotZero?o.bottom-d-.02*a:o.bottom-d-.02*a-.98*a/n*(e.log10(l)-e.log10(o.minNotZero)))),i},getValueForPixel:function(t){var a,i,n=this,o=e.log10(n.end)-e.log10(n.start);return n.isHorizontal()?(i=n.width-(n.paddingLeft+n.paddingRight),a=n.start*Math.pow(10,(t-n.left-n.paddingLeft)*o/i)):(i=n.height-(n.paddingTop+n.paddingBottom),a=Math.pow(10,(n.bottom-n.paddingBottom-t)*o/i)/n.start),a}});t.scaleService.registerScaleType("logarithmic",i,a)}},{}],45:[function(t,e,a){"use strict";e.exports=function(t){var e=t.helpers,a=t.defaults.global,i={display:!0,animate:!0,lineArc:!1,position:"chartArea",angleLines:{display:!0,color:"rgba(0, 0, 0, 0.1)",lineWidth:1},ticks:{showLabelBackdrop:!0,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:t.Ticks.formatters.linear},pointLabels:{fontSize:10,callback:function(t){return t}}},n=t.LinearScaleBase.extend({getValueCount:function(){return this.chart.data.labels.length},setDimensions:function(){var t=this,i=t.options,n=i.ticks;t.width=t.maxWidth,t.height=t.maxHeight,t.xCenter=Math.round(t.width/2),t.yCenter=Math.round(t.height/2);var o=e.min([t.height,t.width]),r=e.getValueOrDefault(n.fontSize,a.defaultFontSize);t.drawingArea=i.display?o/2-(r/2+n.backdropPaddingY):o/2},determineDataLimits:function(){var t=this,a=t.chart;t.min=null,t.max=null,e.each(a.data.datasets,function(i,n){if(a.isDatasetVisible(n)){var o=a.getDatasetMeta(n);e.each(i.data,function(e,a){var i=+t.getRightValue(e);isNaN(i)||o.data[a].hidden||(null===t.min?t.min=i:i<t.min&&(t.min=i),null===t.max?t.max=i:i>t.max&&(t.max=i))})}}),t.handleTickRangeOptions()},getTickLimit:function(){var t=this.options.ticks,i=e.getValueOrDefault(t.fontSize,a.defaultFontSize);return Math.min(t.maxTicksLimit?t.maxTicksLimit:11,Math.ceil(this.drawingArea/(1.5*i)))},convertTicksToLabels:function(){var e=this;t.LinearScaleBase.prototype.convertTicksToLabels.call(e),e.pointLabels=e.chart.data.labels.map(e.options.pointLabels.callback,e)},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},fit:function(){var t,i,n,o,r,l,s,d,u,c,h,f,g=this.options.pointLabels,p=e.getValueOrDefault(g.fontSize,a.defaultFontSize),m=e.getValueOrDefault(g.fontStyle,a.defaultFontStyle),b=e.getValueOrDefault(g.fontFamily,a.defaultFontFamily),v=e.fontString(p,m,b),x=e.min([this.height/2-p-5,this.width/2]),y=this.width,k=0;for(this.ctx.font=v,i=0;i<this.getValueCount();i++){t=this.getPointPosition(i,x),n=this.ctx.measureText(this.pointLabels[i]?this.pointLabels[i]:"").width+5;var S=this.getIndexAngle(i)+Math.PI/2,w=360*S/(2*Math.PI)%360;0===w||180===w?(o=n/2,t.x+o>y&&(y=t.x+o,r=i),t.x-o<k&&(k=t.x-o,s=i)):180>w?t.x+n>y&&(y=t.x+n,r=i):t.x-n<k&&(k=t.x-n,s=i)}u=k,c=Math.ceil(y-this.width),l=this.getIndexAngle(r),d=this.getIndexAngle(s),h=c/Math.sin(l+Math.PI/2),f=u/Math.sin(d+Math.PI/2),h=e.isNumber(h)?h:0,f=e.isNumber(f)?f:0,this.drawingArea=Math.round(x-(f+h)/2),this.setCenterPoint(f,h)},setCenterPoint:function(t,e){var a=this,i=a.width-e-a.drawingArea,n=t+a.drawingArea;a.xCenter=Math.round((n+i)/2+a.left),a.yCenter=Math.round(a.height/2+a.top)},getIndexAngle:function(t){var e=2*Math.PI/this.getValueCount(),a=this.chart.options&&this.chart.options.startAngle?this.chart.options.startAngle:0,i=a*Math.PI*2/360;return t*e-Math.PI/2+i},getDistanceFromCenterForValue:function(t){var e=this;if(null===t)return 0;var a=e.drawingArea/(e.max-e.min);return e.options.reverse?(e.max-t)*a:(t-e.min)*a},getPointPosition:function(t,e){var a=this,i=a.getIndexAngle(t);return{x:Math.round(Math.cos(i)*e)+a.xCenter,y:Math.round(Math.sin(i)*e)+a.yCenter}},getPointPositionForValue:function(t,e){return this.getPointPosition(t,this.getDistanceFromCenterForValue(e))},getBasePosition:function(){var t=this,e=t.min,a=t.max;return t.getPointPositionForValue(0,t.beginAtZero?0:0>e&&0>a?a:e>0&&a>0?e:0)},draw:function(){var t=this,i=t.options,n=i.gridLines,o=i.ticks,r=i.angleLines,l=i.pointLabels,s=e.getValueOrDefault;if(i.display){var d=t.ctx,u=s(o.fontSize,a.defaultFontSize),c=s(o.fontStyle,a.defaultFontStyle),h=s(o.fontFamily,a.defaultFontFamily),f=e.fontString(u,c,h);if(e.each(t.ticks,function(r,l){if(l>0||i.reverse){var c=t.getDistanceFromCenterForValue(t.ticksAsNumbers[l]),h=t.yCenter-c;if(n.display&&0!==l)if(d.strokeStyle=e.getValueAtIndexOrDefault(n.color,l-1),d.lineWidth=e.getValueAtIndexOrDefault(n.lineWidth,l-1),i.lineArc)d.beginPath(),d.arc(t.xCenter,t.yCenter,c,0,2*Math.PI),d.closePath(),d.stroke();else{d.beginPath();for(var g=0;g<t.getValueCount();g++){var p=t.getPointPosition(g,c);0===g?d.moveTo(p.x,p.y):d.lineTo(p.x,p.y)}d.closePath(),d.stroke()}if(o.display){var m=s(o.fontColor,a.defaultFontColor);if(d.font=f,o.showLabelBackdrop){var b=d.measureText(r).width;d.fillStyle=o.backdropColor,d.fillRect(t.xCenter-b/2-o.backdropPaddingX,h-u/2-o.backdropPaddingY,b+2*o.backdropPaddingX,u+2*o.backdropPaddingY)}d.textAlign="center",d.textBaseline="middle",d.fillStyle=m,d.fillText(r,t.xCenter,h)}}}),!i.lineArc){d.lineWidth=r.lineWidth,d.strokeStyle=r.color;for(var g=t.getDistanceFromCenterForValue(i.reverse?t.min:t.max),p=s(l.fontSize,a.defaultFontSize),m=s(l.fontStyle,a.defaultFontStyle),b=s(l.fontFamily,a.defaultFontFamily),v=e.fontString(p,m,b),x=t.getValueCount()-1;x>=0;x--){if(r.display){var y=t.getPointPosition(x,g);d.beginPath(),d.moveTo(t.xCenter,t.yCenter),d.lineTo(y.x,y.y),d.stroke(),d.closePath()}var k=t.getPointPosition(x,g+5),S=s(l.fontColor,a.defaultFontColor);d.font=v,d.fillStyle=S;var w=t.pointLabels,M=this.getIndexAngle(x)+Math.PI/2,C=360*M/(2*Math.PI)%360;0===C||180===C?d.textAlign="center":180>C?d.textAlign="left":d.textAlign="right",90===C||270===C?d.textBaseline="middle":C>270||90>C?d.textBaseline="bottom":d.textBaseline="top",d.fillText(w[x]?w[x]:"",k.x,k.y)}}}}});t.scaleService.registerScaleType("radialLinear",n,i)}},{}],46:[function(t,e,a){"use strict";var i=t(1);i="function"==typeof i?i:window.moment,e.exports=function(t){var e=t.helpers,a={units:[{name:"millisecond",steps:[1,2,5,10,20,50,100,250,500]},{name:"second",steps:[1,2,5,10,30]},{name:"minute",steps:[1,2,5,10,30]},{name:"hour",steps:[1,2,3,6,12]},{name:"day",steps:[1,2,5]},{name:"week",maxStep:4},{name:"month",maxStep:3},{name:"quarter",maxStep:4},{name:"year",maxStep:!1}]},n={position:"bottom",time:{parser:!1,format:!1,unit:!1,round:!1,displayFormat:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm:ss a",hour:"MMM D, hA",day:"ll",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"}},ticks:{autoSkip:!1}},o=t.Scale.extend({initialize:function(){if(!i)throw new Error("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com");t.Scale.prototype.initialize.call(this)},getLabelMoment:function(t,e){return null===t||null===e?null:"undefined"!=typeof this.labelMoments[t]?this.labelMoments[t][e]:null},getLabelDiff:function(t,e){var a=this;return null===t||null===e?null:(void 0===a.labelDiffs&&a.buildLabelDiffs(),"undefined"!=typeof a.labelDiffs[t]?a.labelDiffs[t][e]:null)},getMomentStartOf:function(t){var e=this;return"week"===e.options.time.unit&&e.options.time.isoWeekday!==!1?t.clone().startOf("isoWeek").isoWeekday(e.options.time.isoWeekday):t.clone().startOf(e.tickUnit)},determineDataLimits:function(){var t=this;t.labelMoments=[];var a=[];t.chart.data.labels&&t.chart.data.labels.length>0?(e.each(t.chart.data.labels,function(e){var i=t.parseTime(e);i.isValid()&&(t.options.time.round&&i.startOf(t.options.time.round),a.push(i))},t),t.firstTick=i.min.call(t,a),t.lastTick=i.max.call(t,a)):(t.firstTick=null,t.lastTick=null),e.each(t.chart.data.datasets,function(n,o){var r=[],l=t.chart.isDatasetVisible(o);"object"==typeof n.data[0]&&null!==n.data[0]?e.each(n.data,function(e){var a=t.parseTime(t.getRightValue(e));a.isValid()&&(t.options.time.round&&a.startOf(t.options.time.round),r.push(a),l&&(t.firstTick=null!==t.firstTick?i.min(t.firstTick,a):a,t.lastTick=null!==t.lastTick?i.max(t.lastTick,a):a))},t):r=a,t.labelMoments.push(r)},t),t.options.time.min&&(t.firstTick=t.parseTime(t.options.time.min)),t.options.time.max&&(t.lastTick=t.parseTime(t.options.time.max)),t.firstTick=(t.firstTick||i()).clone(),t.lastTick=(t.lastTick||i()).clone()},buildLabelDiffs:function(){var t=this;t.labelDiffs=[];var a=[];t.chart.data.labels&&t.chart.data.labels.length>0&&e.each(t.chart.data.labels,function(e){var i=t.parseTime(e);i.isValid()&&(t.options.time.round&&i.startOf(t.options.time.round),a.push(i.diff(t.firstTick,t.tickUnit,!0)))},t),e.each(t.chart.data.datasets,function(i){var n=[];"object"==typeof i.data[0]&&null!==i.data[0]?e.each(i.data,function(e){var a=t.parseTime(t.getRightValue(e));a.isValid()&&(t.options.time.round&&a.startOf(t.options.time.round),n.push(a.diff(t.firstTick,t.tickUnit,!0)))},t):n=a,t.labelDiffs.push(n)},t)},buildTicks:function(){var i=this;i.ctx.save();var n=e.getValueOrDefault(i.options.ticks.fontSize,t.defaults.global.defaultFontSize),o=e.getValueOrDefault(i.options.ticks.fontStyle,t.defaults.global.defaultFontStyle),r=e.getValueOrDefault(i.options.ticks.fontFamily,t.defaults.global.defaultFontFamily),l=e.fontString(n,o,r);if(i.ctx.font=l,i.ticks=[],i.unitScale=1,i.scaleSizeInUnits=0,i.options.time.unit)i.tickUnit=i.options.time.unit||"day",i.displayFormat=i.options.time.displayFormats[i.tickUnit],i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0),i.unitScale=e.getValueOrDefault(i.options.time.unitStepSize,1);else{var s=i.isHorizontal()?i.width-(i.paddingLeft+i.paddingRight):i.height-(i.paddingTop+i.paddingBottom),d=i.tickFormatFunction(i.firstTick,0,[]),u=i.ctx.measureText(d).width,c=Math.cos(e.toRadians(i.options.ticks.maxRotation)),h=Math.sin(e.toRadians(i.options.ticks.maxRotation));u=u*c+n*h;var f=s/u;i.tickUnit=i.options.time.minUnit,i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0),i.displayFormat=i.options.time.displayFormats[i.tickUnit];for(var g=0,p=a.units[g];g<a.units.length;){if(i.unitScale=1,e.isArray(p.steps)&&Math.ceil(i.scaleSizeInUnits/f)<e.max(p.steps)){for(var m=0;m<p.steps.length;++m)if(p.steps[m]>=Math.ceil(i.scaleSizeInUnits/f)){i.unitScale=e.getValueOrDefault(i.options.time.unitStepSize,p.steps[m]);break}break}if(p.maxStep===!1||Math.ceil(i.scaleSizeInUnits/f)<p.maxStep){i.unitScale=e.getValueOrDefault(i.options.time.unitStepSize,Math.ceil(i.scaleSizeInUnits/f));break}++g,p=a.units[g],i.tickUnit=p.name;var b=i.firstTick.diff(i.getMomentStartOf(i.firstTick),i.tickUnit,!0),v=i.getMomentStartOf(i.lastTick.clone().add(1,i.tickUnit)).diff(i.lastTick,i.tickUnit,!0);i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0)+b+v,i.displayFormat=i.options.time.displayFormats[p.name]}}var x;if(i.options.time.min?x=i.getMomentStartOf(i.firstTick):(i.firstTick=i.getMomentStartOf(i.firstTick),x=i.firstTick),!i.options.time.max){var y=i.getMomentStartOf(i.lastTick),k=y.diff(i.lastTick,i.tickUnit,!0);0>k?i.lastTick=i.getMomentStartOf(i.lastTick.add(1,i.tickUnit)):k>=0&&(i.lastTick=y),i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0)}i.options.time.displayFormat&&(i.displayFormat=i.options.time.displayFormat),i.ticks.push(i.firstTick.clone());for(var S=1;S<=i.scaleSizeInUnits;++S){var w=x.clone().add(S,i.tickUnit);if(i.options.time.max&&w.diff(i.lastTick,i.tickUnit,!0)>=0)break;S%i.unitScale===0&&i.ticks.push(w)}var M=i.ticks[i.ticks.length-1].diff(i.lastTick,i.tickUnit);(0!==M||0===i.scaleSizeInUnits)&&(i.options.time.max?(i.ticks.push(i.lastTick.clone()),i.scaleSizeInUnits=i.lastTick.diff(i.ticks[0],i.tickUnit,!0)):(i.ticks.push(i.lastTick.clone()),i.scaleSizeInUnits=i.lastTick.diff(i.firstTick,i.tickUnit,!0))),i.ctx.restore(),i.labelDiffs=void 0},getLabelForIndex:function(t,e){var a=this,i=a.chart.data.labels&&t<a.chart.data.labels.length?a.chart.data.labels[t]:"";return"object"==typeof a.chart.data.datasets[e].data[0]&&(i=a.getRightValue(a.chart.data.datasets[e].data[t])),a.options.time.tooltipFormat&&(i=a.parseTime(i).format(a.options.time.tooltipFormat)),i},tickFormatFunction:function(t,a,i){var n=t.format(this.displayFormat),o=this.options.ticks,r=e.getValueOrDefault(o.callback,o.userCallback);return r?r(n,a,i):n},convertTicksToLabels:function(){var t=this;t.tickMoments=t.ticks,t.ticks=t.ticks.map(t.tickFormatFunction,t)},getPixelForValue:function(t,e,a){var i=this,n=null;if(void 0!==e&&void 0!==a&&(n=i.getLabelDiff(a,e)),null===n&&(t&&t.isValid||(t=i.parseTime(i.getRightValue(t))),t&&t.isValid&&t.isValid()&&(n=t.diff(i.firstTick,i.tickUnit,!0))),null!==n){var o=0!==n?n/i.scaleSizeInUnits:n;if(i.isHorizontal()){var r=i.width-(i.paddingLeft+i.paddingRight),l=r*o+i.paddingLeft;return i.left+Math.round(l)}var s=i.height-(i.paddingTop+i.paddingBottom),d=s*o+i.paddingTop;return i.top+Math.round(d)}},getPixelForTick:function(t){return this.getPixelForValue(this.tickMoments[t],null,null)},getValueForPixel:function(t){var e=this,a=e.isHorizontal()?e.width-(e.paddingLeft+e.paddingRight):e.height-(e.paddingTop+e.paddingBottom),n=(t-(e.isHorizontal()?e.left+e.paddingLeft:e.top+e.paddingTop))/a;return n*=e.scaleSizeInUnits,e.firstTick.clone().add(i.duration(n,e.tickUnit).asSeconds(),"seconds")},parseTime:function(t){var e=this;return"string"==typeof e.options.time.parser?i(t,e.options.time.parser):"function"==typeof e.options.time.parser?e.options.time.parser(t):"function"==typeof t.getMonth||"number"==typeof t?i(t):t.isValid&&t.isValid()?t:"string"!=typeof e.options.time.format&&e.options.time.format.call?(console.warn("options.time.format is deprecated and replaced by options.time.parser. See http://nnnick.github.io/Chart.js/docs-v2/#scales-time-scale"),e.options.time.format(t)):i(t,e.options.time.format)}});t.scaleService.registerScaleType("time",o,n)}},{1:1}]},{},[7])(7)});
15
-
16
- jQuery(document).ready(function ($) {
17
-
18
- // Load
19
- $("#quads-vi-signup").click(function () {
20
- console.log(quads.vi_signup_url + '?email='+quads.email + '&domain'+quads.domain + '&aid=WP_Quads')
21
- $("#quads_vi_signup_iframe").attr("src", quads.vi_signup_url + '?email='+quads.email + '&domain='+quads.domain + '&aid=WP_Quads');
22
- quads_verify_vi_signup();
23
- });
24
-
25
-
26
- /**
27
- * Load iAB categories in correct tier 1 and tier 2 hirachy
28
- */
29
- if (document.getElementById('quads_vi_ads[ads][1][iab1]')){
30
-
31
- /**
32
- * Change iab2 tier 2 category by iab tier 1 selection
33
- */
34
-
35
- var iab1Val = jQuery('#quads_vi_ads\\[ads\\]\\[1\\]\\[iab1\\]').val();
36
- replace_iab2_options(iab1Val);
37
-
38
-
39
- jQuery('#quads_vi_ads\\[ads\\]\\[1\\]\\[iab1\\]').load(function(){
40
- var $this = $(this);
41
- //console.log($this.val());
42
- replace_iab2_options($this.val());
43
- })
44
-
45
-
46
- jQuery('#quads_vi_ads\\[ads\\]\\[1\\]\\[iab1\\]').change(function(){
47
- var $this = $(this);
48
- replace_iab2_options($this.val());
49
- })
50
-
51
- function replace_iab2_options(element){
52
- jQuery('#quads_vi_ads\\[ads\\]\\[1\\]\\[iab2\\] option').each(function(i){
53
- var re = new RegExp("\\" + element + '-', "ig");
54
- //console.log(re);
55
- if ($(this).val().match(re) ){
56
- //console.log('match');
57
- $(this).prop('disabled', false).show();
58
- } else {
59
- $(this).prop('disabled', true).hide();
60
- }
61
- if(jQuery('#quads_vi_ads\\[ads\\]\\[1\\]\\[iab2\\] option:selected').prop('disabled') != false) {
62
- jQuery('#quads_vi_ads\\[ads\\]\\[1\\]\\[iab2\\]').val('select');
63
- }
64
- //console.log(element);
65
- });
66
- };
67
-
68
- }
69
-
70
-
71
- /**
72
- * Create vi Revenue Chart
73
- */
74
- var quadsViRevenueInit = function(x, y){
75
- var ctx = document.getElementById('quads-vi-revenue').getContext('2d');
76
- var chart = new Chart(ctx, {
77
- // The type of chart we want to create
78
- type: 'line',
79
- // The data for our dataset
80
- data: {
81
- labels: x,
82
- datasets: [{
83
- label: "VI Revenue",
84
- backgroundColor: 'rgb(236,245,251)',
85
- borderColor: 'rgb(34,149,195)',
86
- data: y,
87
- }]
88
- },
89
- // Configuration options go here
90
- options: {}
91
- });
92
- }
93
-
94
- // Get values for revenue widget
95
- if (document.getElementById('quads-vi-revenue')){
96
- var x = [];
97
- var y = [];
98
- // Get array of x values
99
- jQuery.each(quads.vi_revenue, function(index, value){
100
- x.push(value['date']);
101
- });
102
- // Get array of y values
103
- jQuery.each(quads.vi_revenue, function(index, value){
104
- y.push(value['revenue']);
105
- });
106
- quadsViRevenueInit(x, y);
107
- }
108
-
109
- // Create vi ad and save it via ajax
110
- jQuery('#quads_vi_save_settings_submit').click(function(){
111
-
112
- jQuery("#quads-vi-save-notice").css('display','block');
113
- jQuery("#quads-vi-save-notice").html('Saving settings...');
114
- setTimeout(function(){
115
- jQuery("#quads-vi-save-notice").html('Building ad code ...');
116
- console.log('saved vi ad settings');
117
- save_quads_vi_ad_settings();
118
- },3000);
119
- });
120
-
121
- /**
122
- * Save vi token
123
- */
124
- var save_quads_vi_ad_settings = function (){
125
-
126
-
127
- var data = {
128
- 'action': 'quads_save_vi_ads',
129
- };
130
-
131
- jQuery.ajax({
132
-