ThirstyAffiliates Affiliate Link Manager - Version 3.0.1

Version Description

  • Bug Fix: Link Fixer overrides existing CSS classes on the link
  • Bug Fix: Delete all stats data of a link when its permanently deleted
  • Bug Fix: Minor code fixes on data migration ( from V2 to V3 )
  • Bug Fix: Properly escape destination urls
Download this release

Release Info

Developer jkohlbach
Plugin Icon 128x128 ThirstyAffiliates Affiliate Link Manager
Version 3.0.1
Comparing to
See all releases

Code changes from version 2.7.0 to 3.0.1

Files changed (79) hide show
  1. Abstracts/Abstract_Main_Plugin_Class.php +112 -0
  2. Abstracts/index.php +1 -0
  3. Helpers/Helper_Functions.php +474 -0
  4. Helpers/Plugin_Constants.php +157 -0
  5. Helpers/index.php +1 -0
  6. Interfaces/Activatable_Interface.php +22 -0
  7. Interfaces/Initiable_Interface.php +22 -0
  8. Interfaces/Model_Interface.php +22 -0
  9. Interfaces/index.php +1 -0
  10. Models/Affiliate_Link.php +597 -0
  11. Models/Affiliate_Link_Attachment.php +323 -0
  12. Models/Affiliate_Links_CPT.php +626 -0
  13. Models/Bootstrap.php +424 -0
  14. Models/Guided_Tour.php +386 -0
  15. Models/Link_Fixer.php +233 -0
  16. Models/Link_Picker.php +483 -0
  17. Models/Marketing.php +403 -0
  18. Models/Migration.php +853 -0
  19. Models/Rewrites_Redirection.php +291 -0
  20. Models/Script_Loader.php +288 -0
  21. Models/Settings.php +1821 -0
  22. Models/Shortcodes.php +262 -0
  23. Models/Stats_Reporting.php +775 -0
  24. Models/index.php +1 -0
  25. ThirstyAddonPage.php +0 -147
  26. ThirstyAdminPage.php +0 -558
  27. ThirstyShortcode.php +0 -111
  28. css/admin/index.php +1 -0
  29. css/admin/ta-guided-tour.css +11 -0
  30. css/admin/ta-reports.css +241 -0
  31. css/admin/ta-settings.css +29 -0
  32. css/admin/tinymce/editor.css +38 -0
  33. css/index.php +1 -0
  34. css/lib/jquery-tiptip/jquery-tiptip.css +109 -0
  35. css/lib/select2/select2.css +484 -0
  36. css/lib/select2/select2.min.css +1 -0
  37. css/thirstystyle.css +0 -276
  38. images/admin-review-notice-logo.png +0 -0
  39. images/deleteImg.png +0 -0
  40. images/detailsbg.jpg +0 -0
  41. images/icon-aff.png +0 -0
  42. images/icon-images-disabled.png +0 -0
  43. images/icon-images.png +0 -0
  44. images/icon-link.png +0 -0
  45. images/icon-shortcode.png +0 -0
  46. images/index.php +1 -0
  47. images/license +0 -18
  48. images/lightgreytransparent.png +0 -0
  49. images/lightgreytransparentalt.png +0 -0
  50. images/linkpickerlogo.png +0 -0
  51. images/media-button.png +0 -0
  52. images/search-load-more.png +0 -0
  53. images/spinner-2x.gif +0 -0
  54. images/spinner.gif +0 -0
  55. images/thirsty-loader.gif +0 -0
  56. images/thirstylogo.png +0 -0
  57. images/white-grad.png +0 -0
  58. index.php +1 -0
  59. js/ThirstyLinkPicker.js +0 -168
  60. js/ThirstyQuickAddLinkPicker.js +0 -263
  61. js/app/advance_link_picker/dist/advance-link-picker.css +1 -0
  62. js/app/advance_link_picker/dist/advance-link-picker.js +24 -0
  63. js/app/affiliate_link_page/dist/affiliate-link-page.css +1 -0
  64. js/app/affiliate_link_page/dist/affiliate-link-page.js +24 -0
  65. js/app/import_export/dist/import-export.css +1 -0
  66. js/app/import_export/dist/import-export.js +25 -0
  67. js/app/migration/dist/migration.css +1 -0
  68. js/app/migration/dist/migration.js +25 -0
  69. js/app/quick_add_affiliate_link/dist/quick-add-affiliate-link.css +1 -0
  70. js/app/quick_add_affiliate_link/dist/quick-add-affiliate-link.js +24 -0
  71. js/app/ta-editor.js +129 -0
  72. js/app/ta-guided-tour.js +210 -0
  73. js/app/ta-reports.js +329 -0
  74. js/app/ta-review-request.js +38 -0
  75. js/app/ta-settings.js +65 -0
  76. js/app/ta.js +117 -0
  77. js/index.php +1 -0
  78. js/lib/chosen/chosen.jquery.js +1321 -0
  79. js/lib/chosen/chosen.jquery.min.js +2 -2
Abstracts/Abstract_Main_Plugin_Class.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Abstracts;
3
+
4
+ use ThirstyAffiliates\Interfaces\Model_Interface;
5
+
6
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7
+
8
+ /**
9
+ * Abstract class that the main plugin class needs to extend.
10
+ *
11
+ * @since 3.0.0
12
+ */
13
+ abstract class Abstract_Main_Plugin_Class {
14
+
15
+ /*
16
+ |--------------------------------------------------------------------------
17
+ | Class Properties
18
+ |--------------------------------------------------------------------------
19
+ */
20
+
21
+ /**
22
+ * Property that houses an array of all the "regular models" of the plugin.
23
+ *
24
+ * @since 3.0.0
25
+ * @access protected
26
+ * @var array
27
+ */
28
+ protected $__all_models = array();
29
+
30
+ /**
31
+ * Property that houses an array of all "public regular models" of the plugin.
32
+ * Public models can be accessed and utilized by external entities via the main plugin class.
33
+ *
34
+ * @since 3.0.0
35
+ * @access public
36
+ * @var array
37
+ */
38
+ public $models = array();
39
+
40
+ /**
41
+ * Property that houses an array of all "public helper classes" of the plugin.
42
+ *
43
+ * @since 3.0.0
44
+ * @access public
45
+ * @var array
46
+ */
47
+ public $helpers = array();
48
+
49
+
50
+
51
+
52
+ /*
53
+ |--------------------------------------------------------------------------
54
+ | Class Methods
55
+ |--------------------------------------------------------------------------
56
+ */
57
+
58
+ /**
59
+ * Add a "regular model" to the main plugin class "all models" array.
60
+ *
61
+ * @since 3.0.0
62
+ * @access public
63
+ *
64
+ * @param Model_Interface $model Regular model.
65
+ */
66
+ public function add_to_all_plugin_models( Model_Interface $model ) {
67
+
68
+ $class_reflection = new \ReflectionClass( $model );
69
+ $class_name = $class_reflection->getShortName();
70
+
71
+ if ( !array_key_exists( $class_name , $this->__all_models ) )
72
+ $this->__all_models[ $class_name ] = $model;
73
+
74
+ }
75
+
76
+ /**
77
+ * Add a "regular model" to the main plugin class "public models" array.
78
+ *
79
+ * @since 3.0.0
80
+ * @access public
81
+ *
82
+ * @param Model_Interface $model Regular model.
83
+ */
84
+ public function add_to_public_models( Model_Interface $model ) {
85
+
86
+ $class_reflection = new \ReflectionClass( $model );
87
+ $class_name = $class_reflection->getShortName();
88
+
89
+ if ( !array_key_exists( $class_name , $this->models ) )
90
+ $this->models[ $class_name ] = $model;
91
+
92
+ }
93
+
94
+ /**
95
+ * Add a "helper class instance" to the main plugin class "public helpers" array.
96
+ *
97
+ * @since 3.0.0
98
+ * @access public
99
+ *
100
+ * @param object $helper Helper class instance.
101
+ */
102
+ public function add_to_public_helpers( $helper ) {
103
+
104
+ $class_reflection = new \ReflectionClass( $helper );
105
+ $class_name = $class_reflection->getShortName();
106
+
107
+ if ( !array_key_exists( $class_name , $this->helpers ) )
108
+ $this->helpers[ $class_name ] = $helper;
109
+
110
+ }
111
+
112
+ }
Abstracts/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
Helpers/Helper_Functions.php ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Helpers;
3
+
4
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
5
+
6
+ use ThirstyAffiliates\Models\Affiliate_Link;
7
+
8
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
+
10
+ /**
11
+ * Model that houses all the helper functions of the plugin.
12
+ *
13
+ * 3.0.0
14
+ */
15
+ class Helper_Functions {
16
+
17
+ /*
18
+ |--------------------------------------------------------------------------
19
+ | Class Properties
20
+ |--------------------------------------------------------------------------
21
+ */
22
+
23
+ /**
24
+ * Property that holds the single main instance of Helper_Functions.
25
+ *
26
+ * @since 3.0.0
27
+ * @access private
28
+ * @var Helper_Functions
29
+ */
30
+ private static $_instance;
31
+
32
+ /**
33
+ * Model that houses all the plugin constants.
34
+ *
35
+ * @since 3.0.0
36
+ * @access private
37
+ * @var Plugin_Constants
38
+ */
39
+ private $_constants;
40
+
41
+ /**
42
+ * Property that houses all the saved settings.
43
+ *
44
+ * @since 3.0.0
45
+ * @access private
46
+ */
47
+ private $_settings = array();
48
+
49
+
50
+
51
+
52
+ /*
53
+ |--------------------------------------------------------------------------
54
+ | Class Methods
55
+ |--------------------------------------------------------------------------
56
+ */
57
+
58
+ /**
59
+ * Class constructor.
60
+ *
61
+ * @since 3.0.0
62
+ * @access public
63
+ *
64
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
65
+ * @param Plugin_Constants $constants Plugin constants object.
66
+ */
67
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants ) {
68
+
69
+ $this->_constants = $constants;
70
+
71
+ $main_plugin->add_to_public_helpers( $this );
72
+
73
+ }
74
+
75
+ /**
76
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
77
+ *
78
+ * @since 3.0.0
79
+ * @access public
80
+ *
81
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
82
+ * @param Plugin_Constants $constants Plugin constants object.
83
+ * @return Helper_Functions
84
+ */
85
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants ) {
86
+
87
+ if ( !self::$_instance instanceof self )
88
+ self::$_instance = new self( $main_plugin , $constants );
89
+
90
+ return self::$_instance;
91
+
92
+ }
93
+
94
+
95
+
96
+
97
+ /*
98
+ |--------------------------------------------------------------------------
99
+ | Helper Functions
100
+ |--------------------------------------------------------------------------
101
+ */
102
+
103
+ /**
104
+ * Write data to plugin log file.
105
+ *
106
+ * @since 3.0.0
107
+ * @access public
108
+ *
109
+ * @param mixed Data to log.
110
+ */
111
+ public function write_debug_log( $log ) {
112
+
113
+ error_log( "\n[" . current_time( 'mysql' ) . "]\n" . $log . "\n--------------------------------------------------\n" , 3 , $this->_constants->LOGS_ROOT_PATH() . 'debug.log' );
114
+
115
+ }
116
+
117
+ /**
118
+ * Check if current user is authorized to manage the plugin on the backend.
119
+ *
120
+ * @since 3.0.0
121
+ * @access public
122
+ *
123
+ * @param WP_User $user WP_User object.
124
+ * @return boolean True if authorized, False otherwise.
125
+ */
126
+ public function current_user_authorized( $user = null ) {
127
+
128
+ // Array of roles allowed to access/utilize the plugin
129
+ $admin_roles = apply_filters( 'ucfw_admin_roles' , array( 'administrator' ) );
130
+
131
+ if ( is_null( $user ) )
132
+ $user = wp_get_current_user();
133
+
134
+ if ( $user->ID )
135
+ return count( array_intersect( ( array ) $user->roles , $admin_roles ) ) ? true : false;
136
+ else
137
+ return false;
138
+
139
+ }
140
+
141
+ /**
142
+ * Returns the timezone string for a site, even if it's set to a UTC offset
143
+ *
144
+ * Adapted from http://www.php.net/manual/en/function.timezone-name-from-abbr.php#89155
145
+ *
146
+ * Reference:
147
+ * http://www.skyverge.com/blog/down-the-rabbit-hole-wordpress-and-timezones/
148
+ *
149
+ * @since 3.0.0
150
+ * @access public
151
+ *
152
+ * @return string Valid PHP timezone string
153
+ */
154
+ public function get_site_current_timezone() {
155
+
156
+ // if site timezone string exists, return it
157
+ if ( $timezone = get_option( 'timezone_string' ) )
158
+ return $timezone;
159
+
160
+ // get UTC offset, if it isn't set then return UTC
161
+ if ( 0 === ( $utc_offset = get_option( 'gmt_offset', 0 ) ) )
162
+ return 'UTC';
163
+
164
+ return $this->convert_utc_offset_to_timezone( $utc_offset );
165
+
166
+ }
167
+
168
+ /**
169
+ * Conver UTC offset to timezone.
170
+ *
171
+ * @since 1.2.0
172
+ * @access public
173
+ *
174
+ * @param float|int|string $utc_offset UTC offset.
175
+ * @return string valid PHP timezone string
176
+ */
177
+ public function convert_utc_offset_to_timezone( $utc_offset ) {
178
+
179
+ // adjust UTC offset from hours to seconds
180
+ $utc_offset *= 3600;
181
+
182
+ // attempt to guess the timezone string from the UTC offset
183
+ if ( $timezone = timezone_name_from_abbr( '' , $utc_offset , 0 ) )
184
+ return $timezone;
185
+
186
+ // last try, guess timezone string manually
187
+ $is_dst = date( 'I' );
188
+
189
+ foreach ( timezone_abbreviations_list() as $abbr )
190
+ foreach ( $abbr as $city )
191
+ if ( $city[ 'dst' ] == $is_dst && $city[ 'offset' ] == $utc_offset )
192
+ return $city[ 'timezone_id' ];
193
+
194
+ // fallback to UTC
195
+ return 'UTC';
196
+
197
+ }
198
+
199
+ /**
200
+ * Get all user roles.
201
+ *
202
+ * @since 3.0.0
203
+ * @access public
204
+ *
205
+ * @global WP_Roles $wp_roles Core class used to implement a user roles API.
206
+ *
207
+ * @return array Array of all site registered user roles. User role key as the key and value is user role text.
208
+ */
209
+ public function get_all_user_roles() {
210
+
211
+ global $wp_roles;
212
+ return $wp_roles->get_names();
213
+
214
+ }
215
+
216
+ /**
217
+ * Check validity of a save post action.
218
+ *
219
+ * @since 3.0.0
220
+ * @access private
221
+ *
222
+ * @param int $post_id Id of the coupon post.
223
+ * @param string $post_type Post type to check.
224
+ * @return bool True if valid save post action, False otherwise.
225
+ */
226
+ public function check_if_valid_save_post_action( $post_id , $post_type ) {
227
+
228
+ if ( wp_is_post_autosave( $post_id ) || wp_is_post_revision( $post_id ) || !current_user_can( 'edit_page' , $post_id ) || get_post_type() != $post_type || empty( $_POST ) )
229
+ return false;
230
+ else
231
+ return true;
232
+
233
+ }
234
+
235
+ /**
236
+ * Get user IP address.
237
+ *
238
+ * @since 3.0.0
239
+ * @access public
240
+ *
241
+ * @return string User's IP address.
242
+ */
243
+ public function get_user_ip_address() {
244
+
245
+ if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) )
246
+ $ip = $_SERVER['HTTP_CLIENT_IP'];
247
+ elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
248
+ $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
249
+ else
250
+ $ip = $_SERVER['REMOTE_ADDR'];
251
+
252
+ return apply_filters( 'ta_get_user_ip_address', $ip );
253
+ }
254
+
255
+ /**
256
+ * Get the thirstylink slug set on the settings.
257
+ *
258
+ * @since 3.0.0
259
+ * @access public
260
+ *
261
+ * @return string $link_prefix Thirstyling link prefix.
262
+ */
263
+ public function get_thirstylink_link_prefix() {
264
+
265
+ $link_prefix = get_option( 'ta_link_prefix' , 'recommends' );
266
+
267
+ if ( $link_prefix === 'custom' )
268
+ $link_prefix = get_option( 'ta_link_prefix_custom' , 'recommends' );
269
+
270
+ return $link_prefix;
271
+ }
272
+
273
+ /**
274
+ * Get the affiliate link post default category slug.
275
+ *
276
+ * @since 3.0.0
277
+ * @access public
278
+ *
279
+ * @param int $link_id Affiliate Link ID.
280
+ * @return string Affiliate link default category slug.
281
+ */
282
+ public function get_default_category_slug( $link_id ) {
283
+
284
+ $terms = get_the_terms( $link_id , Plugin_Constants::AFFILIATE_LINKS_TAX );
285
+
286
+ if ( is_wp_error( $terms ) || empty( $terms ) )
287
+ return;
288
+
289
+ $link_cat_obj = array_shift( $terms );
290
+
291
+ return $link_cat_obj->slug;
292
+ }
293
+
294
+ /**
295
+ * Search affiliate links query
296
+ *
297
+ * @since 3.0.0
298
+ * @access public
299
+ *
300
+ * @param string $keyword Search keyword.
301
+ * @param int $paged WP_Query paged value.
302
+ * @param string $category Affiliate link category to search.
303
+ * @param array $exclude List of posts to be excluded.
304
+ * @return array List of affiliate link IDs.
305
+ */
306
+ public function search_affiliate_links_query( $keyword = '' , $paged = 1 , $category = '' , $exclude = array() ) {
307
+
308
+ $args = array(
309
+ 'post_type' => Plugin_Constants::AFFILIATE_LINKS_CPT,
310
+ 'post_status' => 'publish',
311
+ 's' => $keyword,
312
+ 'fields' => 'ids',
313
+ 'paged' => $paged,
314
+ 'post__not_in' => $exclude
315
+ );
316
+
317
+ if ( $category ) {
318
+
319
+ $args[ 'tax_query' ] = array(
320
+ array(
321
+ 'taxonomy' => Plugin_Constants::AFFILIATE_LINKS_TAX,
322
+ 'field' => 'slug',
323
+ 'terms' => $category
324
+ )
325
+ );
326
+ }
327
+
328
+ $query = new \WP_Query( $args );
329
+
330
+ return $query->posts;
331
+ }
332
+
333
+ /**
334
+ * Check if affiliate link needs to be uncloaked.
335
+ *
336
+ * @since 3.0.0
337
+ * @access public
338
+ *
339
+ * @param Affiliate_Link $thirstylink Thirsty affiliate link object.
340
+ * @return boolean Sets to true when affiliate link needs to be uncloaked.
341
+ */
342
+ public function is_uncloak_link( $thirstylink ) {
343
+
344
+ // check if global setting for uncloak link is enabled.
345
+ if ( get_option( 'ta_uncloak_link_per_link' ) !== 'yes' )
346
+ return;
347
+
348
+ // return (true) when uncloak link is enabled on a per post basis.
349
+ if ( $thirstylink->get_prop( 'uncloak_link' ) == 'yes' )
350
+ return true;
351
+ elseif ( $thirstylink->get_prop( 'uncloak_link' ) == 'no' )
352
+ return;
353
+
354
+ $uncloak_categories = maybe_unserialize( get_option( 'ta_category_to_uncloak' ) );
355
+ $link_categories = $thirstylink->get_prop( 'categories' );
356
+
357
+ // skip when there are no categories to uncloak (false)
358
+ if ( empty( $uncloak_categories ) || empty( $link_categories ) )
359
+ return;
360
+
361
+ foreach ( $link_categories as $category ) {
362
+
363
+ if ( in_array( $category->term_id , $uncloak_categories ) )
364
+ return true;
365
+ }
366
+
367
+ return;
368
+ }
369
+
370
+ /**
371
+ * Error log with a trace.
372
+ *
373
+ * @since 3.0.0
374
+ * @access public
375
+ */
376
+ public function ta_error_log( $msg ) {
377
+
378
+ $trace = debug_backtrace();
379
+ $caller = array_shift( $trace );
380
+
381
+ error_log( $msg . ' | Trace: ' . $caller[ 'file' ] . ' on line ' . $caller[ 'line' ] );
382
+
383
+ }
384
+
385
+ /**
386
+ * Utility function that determines if a plugin is active or not.
387
+ *
388
+ * @since 3.0.0
389
+ * @access public
390
+ *
391
+ * @param string $plugin_basename Plugin base name. Ex. woocommerce/woocommerce.php
392
+ * @return boolean True if active, false otherwise.
393
+ */
394
+ public function is_plugin_active( $plugin_basename ) {
395
+
396
+ // Makes sure the plugin is defined before trying to use it
397
+ if ( !function_exists( 'is_plugin_active' ) )
398
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
399
+
400
+ return is_plugin_active( $plugin_basename );
401
+
402
+ }
403
+
404
+ /**
405
+ * Send email.
406
+ *
407
+ * @since 3.0.0
408
+ * @access public
409
+ *
410
+ * @param array $recipients Array of recipients emails.
411
+ * @param string $subject Email subject.
412
+ * @param string $message Email message.
413
+ * @param array $headers Array of email headers.
414
+ * @param array $attachments Array of email attachments.
415
+ * @return boolean True if email sending is triggered, note it does not mean that the email was received, it just denotes that the email sending is triggered. False if email sending is not triggered.
416
+ */
417
+ public function send_email( $recipients , $subject , $message , $headers = array() , $attachments = array() ) {
418
+
419
+ $from_name = apply_filters( 'ta_email_from_name' , get_bloginfo( 'name' ) );
420
+ $from_email = apply_filters( 'ta_email_from_email' , get_option( 'admin_email' ) );
421
+
422
+ $headers[] = 'From: ' . $from_name . ' <' . $from_email . '>';
423
+ $headers[] = 'Content-Type: text/html; charset=' . get_option( 'blog_charset' );
424
+
425
+ return wp_mail( $recipients , $subject , $message , $headers , $attachments );
426
+
427
+ }
428
+
429
+ /**
430
+ * Get Affiliate_Link data object.
431
+ *
432
+ * @since 3.0.0
433
+ * @access public
434
+ *
435
+ * @param int $id Affiliate_Link post ID.
436
+ * @return Affiliate_Link Affiliate Link object.
437
+ */
438
+ public function get_affiliate_link( $id = 0 ) {
439
+
440
+ return new Affiliate_Link( $id );
441
+ }
442
+
443
+ /**
444
+ * Retrieve all categories as an option array list.
445
+ *
446
+ * @since 3.0.0
447
+ * @access public
448
+ *
449
+ * @return array List of category options.
450
+ */
451
+ public function get_all_category_as_options() {
452
+
453
+ $options = array();
454
+
455
+ $categories = get_terms( array(
456
+ 'taxonomy' => Plugin_Constants::AFFILIATE_LINKS_TAX,
457
+ 'hide_empty' => false,
458
+ ) );
459
+
460
+ if ( ! is_wp_error( $categories ) ) {
461
+
462
+ foreach( $categories as $category )
463
+ $options[ $category->term_id ] = $category->name;
464
+
465
+ } else {
466
+
467
+ // TODO: Handle error
468
+
469
+ }
470
+
471
+ return $options;
472
+ }
473
+
474
+ }
Helpers/Plugin_Constants.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Helpers;
3
+
4
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
5
+
6
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
7
+
8
+ /**
9
+ * Model that houses all the plugin constants.
10
+ * Note as much as possible, we need to make this class succinct as the only purpose of this is to house all the constants that is utilized by the plugin.
11
+ * Therefore we omit class member comments and minimize comments as much as possible.
12
+ * In fact the only verbouse comment here is this comment you are reading right now.
13
+ * And guess what, it just got worse coz now this comment takes 5 lines instead of 3.
14
+ *
15
+ * @since 3.0.0
16
+ */
17
+ class Plugin_Constants {
18
+
19
+ /*
20
+ |--------------------------------------------------------------------------
21
+ | Class Properties
22
+ |--------------------------------------------------------------------------
23
+ */
24
+
25
+ private static $_instance;
26
+
27
+ // Plugin configuration constants
28
+ const TOKEN = 'ta';
29
+ const INSTALLED_VERSION = 'ta_installed_version';
30
+ const VERSION = '3.0.1';
31
+ const TEXT_DOMAIN = 'thirstyaffiliates';
32
+ const THEME_TEMPLATE_PATH = 'thirstyaffiliates';
33
+ const META_DATA_PREFIX = '_ta_';
34
+
35
+ // CPT Taxonomy constants
36
+ const AFFILIATE_LINKS_CPT = 'thirstylink';
37
+ const AFFILIATE_LINKS_TAX = 'thirstylink-category';
38
+ const DEFAULT_LINK_CATEGORY = 'Uncategorized';
39
+
40
+ // CRON
41
+ const CRON_REQUEST_REVIEW = 'ta_cron_request_review';
42
+ const CRON_MIGRATE_OLD_PLUGIN_DATA = 'ta_cron_migrate_old_plugin_data';
43
+ const CRON_TAPRO_NOTICE = 'ta_cron_tapro_notice';
44
+
45
+ // Options
46
+ const SHOW_REQUEST_REVIEW = 'ta_show_request_review';
47
+ const REVIEW_REQUEST_RESPONSE = 'ta_request_review_response';
48
+ const MIGRATION_COMPLETE_FLAG = 'ta_migration_complete_flag';
49
+ const SHOW_TAPRO_NOTICE = 'ta_show_tapro_notice';
50
+
51
+ // Settings Constants
52
+
53
+ // DB Tables
54
+ const LINK_CLICK_DB = 'ta_link_clicks';
55
+ const LINK_CLICK_META_DB = 'ta_link_clicks_meta';
56
+
57
+ // Help Section
58
+ const CLEAN_UP_PLUGIN_OPTIONS = 'ta_clean_up_plugin_options';
59
+
60
+
61
+
62
+
63
+ /*
64
+ |--------------------------------------------------------------------------
65
+ | Class Methods
66
+ |--------------------------------------------------------------------------
67
+ */
68
+
69
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin ) {
70
+
71
+ // Path constants
72
+ $this->_MAIN_PLUGIN_FILE_PATH = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'thirstyaffiliates' . DIRECTORY_SEPARATOR . 'thirstyaffiliates.php';
73
+ $this->_PLUGIN_DIR_PATH = plugin_dir_path( $this->_MAIN_PLUGIN_FILE_PATH );
74
+ $this->_PLUGIN_DIR_URL = plugin_dir_url( $this->_MAIN_PLUGIN_FILE_PATH );
75
+ $this->_PLUGIN_DIRNAME = plugin_basename( dirname( $this->_MAIN_PLUGIN_FILE_PATH ) );
76
+ $this->_PLUGIN_BASENAME = plugin_basename( $this->_MAIN_PLUGIN_FILE_PATH );
77
+
78
+ $this->_CSS_ROOT_URL = $this->_PLUGIN_DIR_URL . 'css/';
79
+ $this->_IMAGES_ROOT_URL = $this->_PLUGIN_DIR_URL . 'images/';
80
+ $this->_JS_ROOT_URL = $this->_PLUGIN_DIR_URL . 'js/';
81
+
82
+ $this->_VIEWS_ROOT_PATH = $this->_PLUGIN_DIR_PATH . 'views/';
83
+ $this->_TEMPLATES_ROOT_PATH = $this->_PLUGIN_DIR_PATH . 'templates/';
84
+ $this->_LOGS_ROOT_PATH = $this->_PLUGIN_DIR_PATH . 'logs/';
85
+
86
+ $this->_REDIRECT_TYPES = apply_filters( 'ta_redirect_types' , array(
87
+ '301' => __( '301 Permanent' , 'thirstyaffiliates' ),
88
+ '302' => __( '302 Temporary' , 'thirstyaffiliates' ),
89
+ '307' => __( '307 Temporary (alternative)' , 'thirstyaffiliates' )
90
+ ) );
91
+
92
+ $main_plugin->add_to_public_helpers( $this );
93
+
94
+ }
95
+
96
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin ) {
97
+
98
+ if ( !self::$_instance instanceof self )
99
+ self::$_instance = new self( $main_plugin );
100
+
101
+ return self::$_instance;
102
+
103
+ }
104
+
105
+ public function VERSION() {
106
+ return self::VERSION;
107
+ }
108
+
109
+ public function MAIN_PLUGIN_FILE_PATH() {
110
+ return $this->_MAIN_PLUGIN_FILE_PATH;
111
+ }
112
+
113
+ public function PLUGIN_DIR_PATH() {
114
+ return $this->_PLUGIN_DIR_PATH;
115
+ }
116
+
117
+ public function PLUGIN_DIR_URL() {
118
+ return $this->_PLUGIN_DIR_URL;
119
+ }
120
+
121
+ public function PLUGIN_DIRNAME() {
122
+ return $this->_PLUGIN_DIRNAME;
123
+ }
124
+
125
+ public function PLUGIN_BASENAME() {
126
+ return $this->_PLUGIN_BASENAME;
127
+ }
128
+
129
+ public function CSS_ROOT_URL() {
130
+ return $this->_CSS_ROOT_URL;
131
+ }
132
+
133
+ public function IMAGES_ROOT_URL() {
134
+ return $this->_IMAGES_ROOT_URL;
135
+ }
136
+
137
+ public function JS_ROOT_URL() {
138
+ return $this->_JS_ROOT_URL;
139
+ }
140
+
141
+ public function VIEWS_ROOT_PATH() {
142
+ return $this->_VIEWS_ROOT_PATH;
143
+ }
144
+
145
+ public function TEMPLATES_ROOT_PATH() {
146
+ return $this->_TEMPLATES_ROOT_PATH;
147
+ }
148
+
149
+ public function LOGS_ROOT_PATH() {
150
+ return $this->_LOGS_ROOT_PATH;
151
+ }
152
+
153
+ public function REDIRECT_TYPES() {
154
+ return $this->_REDIRECT_TYPES;
155
+ }
156
+
157
+ }
Helpers/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
Interfaces/Activatable_Interface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Interfaces;
3
+
4
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
+
6
+ /**
7
+ * Abstraction that provides contract relating to activation.
8
+ * Any model that needs some sort of activation must implement this interface.
9
+ *
10
+ * @since 3.0.0
11
+ */
12
+ interface Activatable_Interface {
13
+
14
+ /**
15
+ * Contruct for activation.
16
+ *
17
+ * @since 3.0.0
18
+ * @access public
19
+ */
20
+ public function activate();
21
+
22
+ }
Interfaces/Initiable_Interface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Interfaces;
3
+
4
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
+
6
+ /**
7
+ * Abstraction that provides contract relating to initialization.
8
+ * Any model that needs some sort of initialization must implement this interface.
9
+ *
10
+ * @since 3.0.0
11
+ */
12
+ interface Initiable_Interface {
13
+
14
+ /**
15
+ * Contruct for initialization.
16
+ *
17
+ * @since 3.0.0
18
+ * @access public
19
+ */
20
+ public function initialize();
21
+
22
+ }
Interfaces/Model_Interface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Interfaces;
3
+
4
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
+
6
+ /**
7
+ * Abstraction that provides contract relating to plugin models.
8
+ * All "regular models" should implement this interface.
9
+ *
10
+ * @since 3.0.0
11
+ */
12
+ interface Model_Interface {
13
+
14
+ /**
15
+ * Contract for running the model.
16
+ *
17
+ * @since 3.0.0
18
+ * @access public
19
+ */
20
+ public function run();
21
+
22
+ }
Interfaces/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
Models/Affiliate_Link.php ADDED
@@ -0,0 +1,597 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+
9
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
10
+ use ThirstyAffiliates\Helpers\Helper_Functions;
11
+
12
+ /**
13
+ * Model that houses the data model of an affiliate link.
14
+ *
15
+ * @since 3.0.0
16
+ */
17
+ class Affiliate_Link {
18
+
19
+
20
+ /*
21
+ |--------------------------------------------------------------------------
22
+ | Class Properties
23
+ |--------------------------------------------------------------------------
24
+ */
25
+
26
+ /**
27
+ * Model that houses the main plugin object.
28
+ *
29
+ * @since 3.0.0
30
+ * @access private
31
+ * @var Abstract_Main_Plugin_Class
32
+ */
33
+ private $_main_plugin;
34
+
35
+ /**
36
+ * Model that houses all the plugin constants.
37
+ *
38
+ * @since 3.0.0
39
+ * @access private
40
+ * @var Plugin_Constants
41
+ */
42
+ private $_constants;
43
+
44
+ /**
45
+ * Property that houses all the helper functions of the plugin.
46
+ *
47
+ * @since 3.0.0
48
+ * @access private
49
+ * @var Helper_Functions
50
+ */
51
+ private $_helper_functions;
52
+
53
+ /**
54
+ * Stores affiliate link ID.
55
+ *
56
+ * @since 3.0.0
57
+ * @access private
58
+ * @var array
59
+ */
60
+ protected $id;
61
+
62
+ /**
63
+ * Stores affiliate link data.
64
+ *
65
+ * @since 3.0.0
66
+ * @access private
67
+ * @var array
68
+ */
69
+ protected $data = array();
70
+
71
+ /**
72
+ * Stores affiliate link default data.
73
+ *
74
+ * @since 3.0.0
75
+ * @access private
76
+ * @var array
77
+ */
78
+ protected $default_data = array(
79
+ 'name' => '',
80
+ 'slug' => '',
81
+ 'date_created' => '',
82
+ 'date_modified' => '',
83
+ 'status' => '',
84
+ 'permalink' => '',
85
+ 'destination_url' => '',
86
+ 'rel_tags' => '',
87
+ 'redirect_type' => '',
88
+ 'no_follow' => 'global',
89
+ 'new_window' => 'global',
90
+ 'uncloak_link' => 'global',
91
+ 'pass_query_str' => 'global',
92
+ 'image_ids' => array(),
93
+ 'categories' => array(),
94
+ 'category_slug' => '',
95
+ 'category_slug_id' => 0,
96
+ );
97
+
98
+ /**
99
+ * Stores affiliate link default data.
100
+ *
101
+ * @since 3.0.0
102
+ * @access private
103
+ * @var array
104
+ */
105
+ protected $extend_data = array();
106
+
107
+ /**
108
+ * Stores affiliate link post data.
109
+ *
110
+ * @since 3.0.0
111
+ * @access private
112
+ * @var object
113
+ */
114
+ protected $post_data;
115
+
116
+ /**
117
+ * This is where changes to the $data will be saved.
118
+ *
119
+ * @since 3.0.0
120
+ * @access private
121
+ * @var object
122
+ */
123
+ protected $changes = array();
124
+
125
+ /**
126
+ * Stores boolean if the data has been read from the database or not.
127
+ *
128
+ * @since 3.0.0
129
+ * @access private
130
+ * @var object
131
+ */
132
+ protected $object_is_read = false;
133
+
134
+
135
+
136
+
137
+ /*
138
+ |--------------------------------------------------------------------------
139
+ | Class Methods
140
+ |--------------------------------------------------------------------------
141
+ */
142
+
143
+ /**
144
+ * Class constructor.
145
+ *
146
+ * @since 3.0.0
147
+ * @access public
148
+ *
149
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
150
+ * @param Plugin_Constants $constants Plugin constants object.
151
+ * @param Helper_Functions $helper_functions Helper functions object.
152
+ */
153
+ public function __construct( $id = null ) {
154
+
155
+ $this->_constants = ThirstyAffiliates()->helpers[ 'Plugin_Constants' ];
156
+ $this->_helper_functions = ThirstyAffiliates()->helpers[ 'Helper_Functions' ];
157
+
158
+ if ( filter_var( $id , FILTER_VALIDATE_INT ) && $id ) {
159
+
160
+ $this->extend_data = apply_filters( 'ta_affiliate_link_extended_data' , $this->extend_data , $this->default_data );
161
+ $this->data = $this->get_merged_default_extended_data();
162
+ $this->id = absint( $id );
163
+
164
+ $this->read();
165
+
166
+ }
167
+
168
+ }
169
+
170
+ /**
171
+ * Read data from DB and save on instance.
172
+ *
173
+ * @since 3.0.0
174
+ * @access public
175
+ */
176
+ private function read() {
177
+
178
+ $this->post_data = get_post( $this->id );
179
+
180
+ if ( ! is_a( $this->post_data , 'WP_Post' ) || $this->object_is_read )
181
+ return;
182
+
183
+ // set the affiliate link ID
184
+ $this->id = $this->post_data->ID;
185
+
186
+ foreach ( $this->get_merged_default_extended_data() as $prop => $value ) {
187
+
188
+ switch ( $prop ) {
189
+
190
+ case 'name' :
191
+ case 'slug' :
192
+ case 'status' :
193
+ case 'date_created' :
194
+ case 'permalink' :
195
+ $this->data[ $prop ] = $this->get_post_data_equivalent( $prop );
196
+ break;
197
+
198
+ case 'rel_tags' :
199
+ case 'no_follow' :
200
+ case 'new_window' :
201
+ case 'uncloak_link' :
202
+ case 'redirect_type' :
203
+ case 'pass_query_str' :
204
+ $raw_data = get_post_meta( $this->id , Plugin_Constants::META_DATA_PREFIX . $prop , true );
205
+ $this->data[ $prop ] = ! empty( $raw_data ) ? $raw_data : $this->get_prop_global_option_value( $prop );
206
+ break;
207
+
208
+ case 'image_ids' :
209
+ $raw_data = get_post_meta( $this->id , Plugin_Constants::META_DATA_PREFIX . $prop , true );
210
+ $this->data[ $prop ] = ( is_array( $raw_data ) && ! empty( $raw_data ) ) ? $raw_data : $this->default_data[ $prop ];
211
+ break;
212
+
213
+ case 'categories' :
214
+ $categories = wp_get_post_terms( $this->id , Plugin_Constants::AFFILIATE_LINKS_TAX );
215
+ $this->data[ $prop ] = ! empty( $categories ) ? $categories : $this->default_data[ $prop ];
216
+ break;
217
+
218
+ default :
219
+ $value = get_post_meta( $this->id , Plugin_Constants::META_DATA_PREFIX . $prop , true );
220
+ $this->data[ $prop ] = apply_filters( 'ta_read_thirstylink_property' , $value , $prop , $this->default_data );
221
+ break;
222
+
223
+ }
224
+
225
+ }
226
+
227
+ $this->object_is_read = true;
228
+
229
+ }
230
+
231
+
232
+
233
+
234
+ /*
235
+ |--------------------------------------------------------------------------
236
+ | Data getters
237
+ |--------------------------------------------------------------------------
238
+ */
239
+
240
+ /**
241
+ * Get merged $default_data and $extended_data class properties.
242
+ *
243
+ * @since 3.0.0
244
+ * @access public
245
+ *
246
+ * @return array Data properties.
247
+ */
248
+ private function get_merged_default_extended_data() {
249
+
250
+ return array_merge( $this->default_data , $this->extend_data );
251
+
252
+ }
253
+
254
+ /**
255
+ * Return's the post data equivalent of a certain affiliate link data property.
256
+ *
257
+ * @since 3.0.0
258
+ * @access private
259
+ *
260
+ * @param string $prop Affiliate link property name.
261
+ * @return string WP Post property equivalent.
262
+ */
263
+ private function get_post_data_equivalent( $prop ) {
264
+
265
+ $equivalents = apply_filters( 'ta_affiliate_link_post_data_equivalent' , array(
266
+ 'name' => $this->post_data->post_title,
267
+ 'slug' => $this->post_data->post_name,
268
+ 'permalink' => get_permalink( $this->post_data->ID ),
269
+ 'status' => $this->post_data->post_status,
270
+ 'date_created' => $this->post_data->post_date,
271
+ 'date_modified' => $this->post_data->post_modified,
272
+ ) , $this->post_data );
273
+
274
+ if ( array_key_exists( $prop , $equivalents ) )
275
+ return $equivalents[ $prop ];
276
+ else
277
+ return;
278
+
279
+ }
280
+
281
+ /**
282
+ * Return data property.
283
+ *
284
+ * @since 3.0.0
285
+ * @access public
286
+ *
287
+ * @param string $prop Data property slug.
288
+ * @param mixed $default Set property default value (optional).
289
+ * @return mixed Property data.
290
+ */
291
+ public function get_prop( $prop , $default = '' ) {
292
+
293
+ $default_data = $this->get_merged_default_extended_data();
294
+
295
+ if ( array_key_exists( $prop , $this->data ) && $this->data[ $prop ] )
296
+ $return_value = $this->data[ $prop ];
297
+ else
298
+ $return_value = ( $default ) ? $default : $default_data[ $prop ];
299
+
300
+ return $prop === 'destination_url' ? esc_url( $return_value ) : $return_value;
301
+
302
+ }
303
+
304
+ /**
305
+ * Return Affiliate_Link ID.
306
+ *
307
+ * @since 3.0.0
308
+ * @access public
309
+ *
310
+ * @return int Affiliate_Link ID.
311
+ */
312
+ public function get_id() {
313
+
314
+ return absint( $this->id );
315
+
316
+ }
317
+
318
+ /**
319
+ * Return changed data property.
320
+ *
321
+ * @since 3.0.0
322
+ * @access public
323
+ *
324
+ * @param string $prop Data property slug.
325
+ * @param mixed $default Set property default value (optional).
326
+ * @return mixed Property data.
327
+ */
328
+ public function get_changed_prop( $prop , $default = '' ) {
329
+
330
+ return isset( $this->changes[ $prop ] ) ? $this->changes[ $prop ] : $this->get_prop( $prop , $default );
331
+
332
+ }
333
+
334
+ /**
335
+ * Return affiliate link's WP_Post data.
336
+ *
337
+ * @since 3.0.0
338
+ * @access public
339
+ *
340
+ * @return object Post data object.
341
+ */
342
+ public function get_post_data() {
343
+
344
+ return $this->post_data;
345
+
346
+ }
347
+
348
+ /**
349
+ * Get the properties global option value.
350
+ *
351
+ * @since 3.0.0
352
+ * @access public
353
+ *
354
+ * @param string $prop Name of property.
355
+ * @return string Global option value.
356
+ */
357
+ public function get_prop_global_option_value( $prop ) {
358
+
359
+ $default = '';
360
+
361
+ switch( $prop ) {
362
+
363
+ case 'rel_tags' :
364
+ $option = 'ta_additional_rel_tags';
365
+ break;
366
+
367
+ case 'no_follow' :
368
+ $option = 'ta_no_follow';
369
+ break;
370
+
371
+ case 'new_window' :
372
+ $option = 'ta_new_window';
373
+ break;
374
+
375
+ case 'redirect_type' :
376
+ $option = 'ta_link_redirect_type';
377
+ $default = '301';
378
+ break;
379
+
380
+ case 'pass_query_str' :
381
+ $option = 'ta_pass_query_str';
382
+ break;
383
+
384
+ case 'uncloak_link' :
385
+ return;
386
+ break;
387
+ }
388
+
389
+ return get_option( $option , $default );
390
+ }
391
+
392
+ /**
393
+ * Get the global value for the uncloak property.
394
+ *
395
+ * @since 3.0.0
396
+ * @access public
397
+ *
398
+ * @return string Global option value.
399
+ */
400
+ public function get_global_uncloak_value() {
401
+
402
+ $uncloak_cats = maybe_unserialize( get_option( 'ta_category_to_uncloak' , array() ) );
403
+
404
+ if ( ! is_array( $uncloak_cats ) || empty( $uncloak_cats ) )
405
+ return 'no';
406
+
407
+ foreach ( $uncloak_cats as $cat_id ) {
408
+
409
+ if ( has_term( intval( $cat_id ) , Plugin_Constants::AFFILIATE_LINKS_TAX , $this->id ) )
410
+ return 'yes';
411
+ }
412
+
413
+ return 'no';
414
+ }
415
+
416
+
417
+
418
+
419
+ /*
420
+ |--------------------------------------------------------------------------
421
+ | Data setters
422
+ |--------------------------------------------------------------------------
423
+ */
424
+
425
+ /**
426
+ * Set new value to properties and save it to $changes property.
427
+ * This stores changes in a special array so we can track what needs to be saved on the DB later.
428
+ *
429
+ * @since 3.0.0
430
+ * @access public
431
+ *
432
+ * @param string $prop Data property slug.
433
+ * @param string $value New property value.
434
+ */
435
+ public function set_prop( $prop , $value ) {
436
+
437
+ $default_data = $this->get_merged_default_extended_data();
438
+
439
+ if ( array_key_exists( $prop , $this->data ) ) {
440
+
441
+ // permalink property must not be changed
442
+ if ( $prop == 'permalink' )
443
+ return;
444
+
445
+ if ( gettype( $value ) == gettype( $default_data[ $prop ] ) )
446
+ $this->changes[ $prop ] = $value;
447
+ else {
448
+
449
+ // TODO: handle error here.
450
+
451
+ }
452
+
453
+ } else {
454
+
455
+ $this->data[ $prop ] = $value;
456
+ $this->changes[ $prop ] = $value;
457
+
458
+ }
459
+
460
+ }
461
+
462
+
463
+
464
+
465
+ /*
466
+ |--------------------------------------------------------------------------
467
+ | Save (Create / Update) data to DB
468
+ |--------------------------------------------------------------------------
469
+ */
470
+
471
+ /**
472
+ * Save data in $changes to the database.
473
+ *
474
+ * @since 3.0.0
475
+ * @access public
476
+ *
477
+ * @return WP_Error | int On success will return the post ID, otherwise it will return a WP_Error object.
478
+ */
479
+ public function save() {
480
+
481
+ if ( ! empty( $this->changes ) ) {
482
+
483
+ $post_metas = array();
484
+ $post_data = array(
485
+ 'post_title' => $this->get_changed_prop( 'name' ),
486
+ 'post_name' => $this->get_changed_prop( 'slug' ),
487
+ 'post_status' => $this->get_changed_prop( 'status' , 'publish' ),
488
+ 'post_date' => $this->get_changed_prop( 'date_created' , current_time( 'mysql' ) ),
489
+ 'post_modified' => $this->get_changed_prop( 'date_modified' , current_time( 'mysql' ) )
490
+ );
491
+
492
+ foreach ( $this->changes as $prop => $value ) {
493
+
494
+ // make sure that property is registered in default data
495
+ if ( ! array_key_exists( $prop , $this->get_merged_default_extended_data() ) )
496
+ continue;
497
+
498
+ if ( in_array( $prop , array( 'permalink' , 'name' , 'slug' , 'status' , 'date_created' , 'date_modified' ) ) )
499
+ continue;
500
+
501
+ $post_metas[ $prop ] = $value;
502
+ }
503
+
504
+ // create or update post
505
+ if ( $this->id )
506
+ $post_id = $this->update( $post_data );
507
+ else
508
+ $post_id = $this->create( $post_data );
509
+
510
+ if ( ! is_wp_error( $post_id ) )
511
+ $this->update_metas( $post_id , $post_metas );
512
+ else
513
+ return $post_id; // Return WP_Error object on error
514
+
515
+ do_action( 'ta_save_affiliate_link' , $this->changes , $this );
516
+
517
+ // update instance with new changes.
518
+ $this->object_is_read = false;
519
+ $this->read();
520
+
521
+ } else
522
+ return new \WP_Error( 'ta_affiliate_link_no_changes' , __( 'Unable to save affiliate link as there are no changes registered on the object yet.' , 'thirstyaffiliates' ) , array( 'changes' => $this->changes , 'affiliate_link' => $this ) );
523
+
524
+ return $post_id;
525
+ }
526
+
527
+ /**
528
+ * Create the affiliate link post.
529
+ *
530
+ * @since 3.0.0
531
+ * @access private
532
+ *
533
+ * @param array $post_data Affiliate link post data.
534
+ * @param WP_Error|int WP_Error on error, ID of newly created post otherwise.
535
+ */
536
+ private function create( $post_data ) {
537
+
538
+ $post_data = array_merge( array( 'post_type' => Plugin_Constants::AFFILIATE_LINKS_CPT ) , $post_data );
539
+ $this->id = wp_insert_post( $post_data );
540
+
541
+ return $this->id;
542
+
543
+ }
544
+
545
+ /**
546
+ * Update the affiliate link post.
547
+ *
548
+ * @since 3.0.0
549
+ * @access private
550
+ *
551
+ * @param array $post_data Affiliate link post data.
552
+ * @return int ID of the updated post upon success. 0 on failure.
553
+ */
554
+ private function update( $post_data ) {
555
+
556
+ $post_data = array_merge( array( 'ID' => $this->id ) , $post_data );
557
+ return wp_update_post( $post_data , true );
558
+
559
+ }
560
+
561
+ /**
562
+ * Update/add the affiliate link meta data.
563
+ *
564
+ * @since 3.0.0
565
+ * @access private
566
+ *
567
+ * @param int $post_id Affiliate link post ID.
568
+ * @param array $post_metas Affiliate link meta data.
569
+ */
570
+ private function update_metas( $post_id , $post_metas ) {
571
+
572
+ foreach ( $post_metas as $key => $value )
573
+ update_post_meta( $post_id , Plugin_Constants::META_DATA_PREFIX . $key , $value );
574
+
575
+ }
576
+
577
+ /**
578
+ * Count affiliate link clicks.
579
+ *
580
+ * @since 3.0.0
581
+ * @access public
582
+ *
583
+ * @return int Total number of clicks.
584
+ */
585
+ public function count_clicks() {
586
+
587
+ global $wpdb;
588
+
589
+ $table_name = $wpdb->prefix . Plugin_Constants::LINK_CLICK_DB;
590
+ $link_id = $this->get_id();
591
+ $query = "SELECT count(*) from $table_name WHERE link_id = $link_id";
592
+ $clicks = $wpdb->get_var( $query );
593
+
594
+ return (int) $clicks;
595
+ }
596
+
597
+ }
Models/Affiliate_Link_Attachment.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+
10
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
11
+ use ThirstyAffiliates\Helpers\Helper_Functions;
12
+
13
+ /**
14
+ * Model that houses the logic of media attachments of an affiliate link.
15
+ *
16
+ * @since 3.0.0
17
+ */
18
+ class Affiliate_Link_Attachment implements Model_Interface , Initiable_Interface {
19
+
20
+ /*
21
+ |--------------------------------------------------------------------------
22
+ | Class Properties
23
+ |--------------------------------------------------------------------------
24
+ */
25
+
26
+ /**
27
+ * Property that holds the single main instance of Bootstrap.
28
+ *
29
+ * @since 3.0.0
30
+ * @access private
31
+ * @var Affiliate_Link_Attachment
32
+ */
33
+ private static $_instance;
34
+
35
+ /**
36
+ * Model that houses the main plugin object.
37
+ *
38
+ * @since 3.0.0
39
+ * @access private
40
+ * @var Affiliate_Link_Attachment
41
+ */
42
+ private $_main_plugin;
43
+
44
+ /**
45
+ * Model that houses all the plugin constants.
46
+ *
47
+ * @since 3.0.0
48
+ * @access private
49
+ * @var Plugin_Constants
50
+ */
51
+ private $_constants;
52
+
53
+ /**
54
+ * Property that houses all the helper functions of the plugin.
55
+ *
56
+ * @since 3.0.0
57
+ * @access private
58
+ * @var Helper_Functions
59
+ */
60
+ private $_helper_functions;
61
+
62
+
63
+
64
+
65
+ /*
66
+ |--------------------------------------------------------------------------
67
+ | Class Methods
68
+ |--------------------------------------------------------------------------
69
+ */
70
+
71
+ /**
72
+ * Class constructor.
73
+ *
74
+ * @since 3.0.0
75
+ * @access public
76
+ *
77
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
78
+ * @param Plugin_Constants $constants Plugin constants object.
79
+ * @param Helper_Functions $helper_functions Helper functions object.
80
+ */
81
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
82
+
83
+ $this->_constants = $constants;
84
+ $this->_helper_functions = $helper_functions;
85
+
86
+ $main_plugin->add_to_all_plugin_models( $this );
87
+ $main_plugin->add_to_public_models( $this );
88
+
89
+ }
90
+
91
+ /**
92
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
93
+ *
94
+ * @since 3.0.0
95
+ * @access public
96
+ *
97
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
98
+ * @param Plugin_Constants $constants Plugin constants object.
99
+ * @param Helper_Functions $helper_functions Helper functions object.
100
+ * @return Affiliate_Link_Attachment
101
+ */
102
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
103
+
104
+ if ( !self::$_instance instanceof self )
105
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
106
+
107
+ return self::$_instance;
108
+
109
+ }
110
+
111
+
112
+
113
+
114
+
115
+ /*
116
+ |--------------------------------------------------------------------------
117
+ | Attachments
118
+ |--------------------------------------------------------------------------
119
+ */
120
+
121
+ /**
122
+ * Add attachments to affiliate link via ajax.
123
+ *
124
+ * @since 3.0.0
125
+ * @access public
126
+ */
127
+ public function ajax_add_attachments_to_affiliate_link() {
128
+
129
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
130
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
131
+ elseif ( ! isset( $_POST[ 'attachment_ids' ] ) || ! isset( $_POST[ 'affiliate_link_id' ] ) )
132
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
133
+ else {
134
+
135
+ $result = $this->add_attachments_to_affiliate_link( $_POST[ 'attachment_ids' ] , $_POST[ 'affiliate_link_id' ] );
136
+
137
+ if ( is_wp_error( $result ) )
138
+ $response = array( 'status' => 'fail' , 'error_msg' => $result->get_error_message() );
139
+ else {
140
+
141
+ ob_start();
142
+
143
+ foreach ( $result as $attachment_id ) {
144
+
145
+ $img = wp_get_attachment_image_src( $attachment_id , 'full' );
146
+ include( $this->_constants->VIEWS_ROOT_PATH() . 'cpt/view-attach-images-metabox-single-image.php' );
147
+
148
+ }
149
+
150
+ $added_attachments_markup = ob_get_clean();
151
+
152
+ $response = array( 'status' => 'success' , 'success_msg' => __( 'Attachments successfully added to the affiliate link' , 'thirstyaffiliates' ) , 'added_attachments_markup' => $added_attachments_markup );
153
+
154
+ }
155
+
156
+ }
157
+
158
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
159
+ echo wp_json_encode( $response );
160
+ wp_die();
161
+
162
+ }
163
+
164
+ /**
165
+ * Add attachments to affiliate link.
166
+ *
167
+ * @since 3.0.0
168
+ * @access public
169
+ *
170
+ * @param array $attachment_ids Array of attachment ids.
171
+ * @param int $affiliate_link_id Id of the current affiliate link.
172
+ * @return WP_Error | boolean WP_Error instance on failure, boolean true otherwise.
173
+ */
174
+ public function add_attachments_to_affiliate_link( $attachment_ids , $affiliate_link_id ) {
175
+
176
+ if ( !is_array( $attachment_ids ) )
177
+ return new \WP_Error( 'ta_invalid_attachment_ids' , __( 'Invalid attachment ids to attach to an affiliate link' , 'thirstyaffiliates' ) , array( 'attachment_ids' => $attachment_ids , 'affiliate_link_id' => $affiliate_link_id ) );
178
+
179
+ $attachments = get_post_meta( $affiliate_link_id , Plugin_Constants::META_DATA_PREFIX . 'image_ids' , true );
180
+ if ( !is_array( $attachments ) )
181
+ $attachments = array();
182
+
183
+ $new_attachment_ids = array_diff( $attachment_ids , $attachments );
184
+
185
+ update_post_meta( $affiliate_link_id , Plugin_Constants::META_DATA_PREFIX . 'image_ids' , array_unique( array_merge( $attachments , $attachment_ids ) ) );
186
+
187
+ return $new_attachment_ids;
188
+
189
+ }
190
+
191
+ /**
192
+ * Add attachments to affiliate link via ajax.
193
+ *
194
+ * @since 3.0.0
195
+ * @access public
196
+ */
197
+ public function ajax_remove_attachment_to_affiliate_link() {
198
+
199
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
200
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
201
+ elseif ( ! isset( $_POST[ 'attachment_id' ] ) || ! isset( $_POST[ 'affiliate_link_id' ] ) )
202
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
203
+ else {
204
+
205
+ if ( is_wp_error( $this->remove_attachment_to_affiliate_link( $_POST[ 'attachment_id' ] , $_POST[ 'affiliate_link_id' ] ) ) )
206
+ $response = array( 'status' => 'fail' , 'error_msg' => $result->get_error_message() );
207
+ else
208
+ $response = array( 'status' => 'success' , 'success_msg' => __( 'Attachment successfully removed from attachment' , 'thirstyaffiliates' ) );
209
+
210
+ }
211
+
212
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
213
+ echo wp_json_encode( $response );
214
+ wp_die();
215
+
216
+ }
217
+
218
+ /**
219
+ * Remove an attachment from an affiliate link.
220
+ *
221
+ * @since 3.0.0
222
+ * @access public
223
+ *
224
+ * @param int $attachment_id Attachment id.
225
+ * @param int $affiliate_link_id Affiliate link id.
226
+ * @return WP_Error | boolean WP_Error instance on failure, boolean true otherwise.
227
+ */
228
+ public function remove_attachment_to_affiliate_link( $attachment_id , $affiliate_link_id ) {
229
+
230
+ $attachments = get_post_meta( $affiliate_link_id , Plugin_Constants::META_DATA_PREFIX . 'image_ids' , true );
231
+ if ( !is_array( $attachments ) )
232
+ $attachments = array();
233
+
234
+ if ( !in_array( $attachment_id , $attachments ) )
235
+ return new \WP_Error( 'ta_invalid_attachment_id' , __( 'Invalid attachment id to remove from an affiliate link' , 'thirstyaffiliates' ) , array( 'attachment_id' => $attachment_id , 'affiliate_link_id' => 'affiliate_link_id' ) );
236
+
237
+ $key = array_search( $attachment_id , $attachments );
238
+ unset( $attachments[ $key ] );
239
+
240
+ update_post_meta( $affiliate_link_id , Plugin_Constants::META_DATA_PREFIX . 'image_ids' , $attachments );
241
+
242
+ return true;
243
+
244
+ }
245
+
246
+ /**
247
+ * This is the place where we decide whether if it is an affiliate link page and if it is, well apply custom action modifications that is exclusive only to the affiliate link page.
248
+ *
249
+ * @since 3.0.0
250
+ * @access public
251
+ */
252
+ public function current_screen_filter() {
253
+
254
+ $current_screen = get_current_screen();
255
+
256
+ if ( $current_screen->base === 'post' && $current_screen->post_type === 'thirstylink' ) {
257
+
258
+ add_filter( 'upload_mimes' , array( $this , 'restrict_file_upload_to_images_only' ) , 10 , 1 );
259
+
260
+ }
261
+
262
+ }
263
+
264
+ /**
265
+ * Restrict the media library uploader to accept image files only.
266
+ * The effects of this filter is global, thats why we only apply the filter when we are inside an affiliate link edit page.
267
+ *
268
+ * @since 3.0.0
269
+ * @access public
270
+ *
271
+ * @param array $mime_types Array of accepted mime types.
272
+ * @return array Filtered array of accepted mime types.
273
+ */
274
+ public function restrict_file_upload_to_images_only( $mime_types ) {
275
+
276
+ return array(
277
+ 'jpg|jpeg|jpe' => 'image/jpeg',
278
+ 'gif' => 'image/gif',
279
+ 'png' => 'image/png',
280
+ 'bmp' => 'image/bmp',
281
+ 'tiff|tif' => 'image/tiff',
282
+ 'ico' => 'image/x-icon'
283
+ );
284
+
285
+ }
286
+
287
+
288
+
289
+
290
+ /*
291
+ |--------------------------------------------------------------------------
292
+ | Implemented Interface Methods
293
+ |--------------------------------------------------------------------------
294
+ */
295
+
296
+ /**
297
+ * Execute codes that needs to run on plugin initialization.
298
+ *
299
+ * @since 3.0.0
300
+ * @access public
301
+ * @implements ThirstyAffiliates\Interfaces\Initiable_Interface
302
+ */
303
+ public function initialize() {
304
+
305
+ add_action( 'wp_ajax_ta_add_attachments_to_affiliate_link' , array( $this , 'ajax_add_attachments_to_affiliate_link' ) );
306
+ add_action( 'wp_ajax_ta_remove_attachment_to_affiliate_link' , array( $this , 'ajax_remove_attachment_to_affiliate_link' ) );
307
+
308
+ }
309
+
310
+ /**
311
+ * Execute model core logic.
312
+ *
313
+ * @since 3.0.0
314
+ * @access public
315
+ * @implements ThirstyAffiliates\Interfaces\Model_Interface
316
+ */
317
+ public function run() {
318
+
319
+ add_action( 'current_screen' , array( $this , 'current_screen_filter' ) );
320
+
321
+ }
322
+
323
+ }
Models/Affiliate_Links_CPT.php ADDED
@@ -0,0 +1,626 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+
10
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
11
+ use ThirstyAffiliates\Helpers\Helper_Functions;
12
+
13
+ // Data Models
14
+ use ThirstyAffiliates\Models\Affiliate_Link;
15
+
16
+ /**
17
+ * Model that houses the logic of registering the 'thirstylink' custom post type.
18
+ *
19
+ * @since 3.0.0
20
+ */
21
+ class Affiliate_Links_CPT implements Model_Interface , Initiable_Interface {
22
+
23
+ /*
24
+ |--------------------------------------------------------------------------
25
+ | Class Properties
26
+ |--------------------------------------------------------------------------
27
+ */
28
+
29
+ /**
30
+ * Property that holds the single main instance of Bootstrap.
31
+ *
32
+ * @since 3.0.0
33
+ * @access private
34
+ * @var Affiliate_Links_CPT
35
+ */
36
+ private static $_instance;
37
+
38
+ /**
39
+ * Model that houses the main plugin object.
40
+ *
41
+ * @since 3.0.0
42
+ * @access private
43
+ * @var Abstract_Main_Plugin_Class
44
+ */
45
+ private $_main_plugin;
46
+
47
+ /**
48
+ * Model that houses all the plugin constants.
49
+ *
50
+ * @since 3.0.0
51
+ * @access private
52
+ * @var Plugin_Constants
53
+ */
54
+ private $_constants;
55
+
56
+ /**
57
+ * Property that houses all the helper functions of the plugin.
58
+ *
59
+ * @since 3.0.0
60
+ * @access private
61
+ * @var Helper_Functions
62
+ */
63
+ private $_helper_functions;
64
+
65
+ /**
66
+ * Property that holds the currently loaded thirstylink post.
67
+ *
68
+ * @since 3.0.0
69
+ * @access private
70
+ */
71
+ private $_thirstylink;
72
+
73
+
74
+
75
+
76
+ /*
77
+ |--------------------------------------------------------------------------
78
+ | Class Methods
79
+ |--------------------------------------------------------------------------
80
+ */
81
+
82
+ /**
83
+ * Class constructor.
84
+ *
85
+ * @since 3.0.0
86
+ * @access public
87
+ *
88
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
89
+ * @param Plugin_Constants $constants Plugin constants object.
90
+ * @param Helper_Functions $helper_functions Helper functions object.
91
+ */
92
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
93
+
94
+ $this->_constants = $constants;
95
+ $this->_helper_functions = $helper_functions;
96
+
97
+ $main_plugin->add_to_all_plugin_models( $this );
98
+
99
+ }
100
+
101
+ /**
102
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
103
+ *
104
+ * @since 3.0.0
105
+ * @access public
106
+ *
107
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
108
+ * @param Plugin_Constants $constants Plugin constants object.
109
+ * @param Helper_Functions $helper_functions Helper functions object.
110
+ * @return Affiliate_Links_CPT
111
+ */
112
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
113
+
114
+ if ( !self::$_instance instanceof self )
115
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
116
+
117
+ return self::$_instance;
118
+
119
+ }
120
+
121
+ /**
122
+ * Get thirstylink Affiliate_Link object.
123
+ *
124
+ * @since 3.0.0
125
+ * @access private
126
+ *
127
+ * @param int $post_id Thirstylink post id.
128
+ * @return Affiliate_Link object.
129
+ */
130
+ private function get_thirstylink_post( $post_id ) {
131
+
132
+ if ( is_object( $this->_thirstylink ) && $this->_thirstylink->get_id() == $post_id )
133
+ return $this->_thirstylink;
134
+
135
+ return $this->_thirstylink = new Affiliate_Link( $post_id );
136
+
137
+ }
138
+
139
+ /**
140
+ * Register the 'thirstylink' custom post type.
141
+ *
142
+ * @since 3.0.0
143
+ * @access private
144
+ */
145
+ private function register_thirstylink_custom_post_type() {
146
+
147
+ $link_prefix = $this->_helper_functions->get_thirstylink_link_prefix();
148
+
149
+ $labels = array(
150
+ 'name' => __( 'Affiliate Links' , 'thirstyaffiliates' ),
151
+ 'singular_name' => __( 'Affiliate Link' , 'thirstyaffiliates' ),
152
+ 'menu_name' => __( 'ThirstyAffiliates' , 'thirstyaffiliates' ),
153
+ 'parent_item_colon' => __( 'Parent Affiliate Link' , 'thirstyaffiliates' ),
154
+ 'all_items' => __( 'Affiliate Links' , 'thirstyaffiliates' ),
155
+ 'view_item' => __( 'View Affiliate Link' , 'thirstyaffiliates' ),
156
+ 'add_new_item' => __( 'Add Affiliate Link' , 'thirstyaffiliates' ),
157
+ 'add_new' => __( 'New Affiliate Link' , 'thirstyaffiliates' ),
158
+ 'edit_item' => __( 'Edit Affiliate Link' , 'thirstyaffiliates' ),
159
+ 'update_item' => __( 'Update Affiliate Link' , 'thirstyaffiliates' ),
160
+ 'search_items' => __( 'Search Affiliate Links' , 'thirstyaffiliates' ),
161
+ 'not_found' => __( 'No Affiliate Link found' , 'thirstyaffiliates' ),
162
+ 'not_found_in_trash' => __( 'No Affiliate Links found in Trash' , 'thirstyaffiliates' )
163
+ );
164
+
165
+ $args = array(
166
+ 'label' => __( 'Affiliate Links' , 'thirstyaffiliates' ),
167
+ 'description' => __( 'ThirstyAffiliates affiliate links' , 'thirstyaffiliates' ),
168
+ 'labels' => $labels,
169
+ 'supports' => array( 'title' ),
170
+ 'taxonomies' => array(),
171
+ 'hierarchical' => true,
172
+ 'public' => true,
173
+ 'show_ui' => true,
174
+ 'show_in_menu' => true,
175
+ 'show_in_json' => false,
176
+ 'query_var' => true,
177
+ 'rewrite' => array(
178
+ 'slug' => $link_prefix,
179
+ 'with_front' => false,
180
+ 'pages' => false
181
+ ),
182
+ 'show_in_nav_menus' => true,
183
+ 'show_in_admin_bar' => true,
184
+ 'menu_position' => 26,
185
+ 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" width="16.688" height="9.875" viewBox="0 0 16.688 9.875">
186
+ <path id="TA.svg" fill="black" class="cls-1" d="M2.115,15.12H4.847L6.836,7.7H9.777l0.63-2.381H1.821L1.177,7.7H4.118Zm4.758,0H9.829l1.177-1.751h3.782l0.238,1.751h2.858L16.357,5.245H13.7Zm5.5-3.866,1.835-2.816,0.35,2.816H12.378Z" transform="translate(-1.188 -5.25)"/>
187
+ </svg>
188
+ '),
189
+ 'can_export' => true,
190
+ 'has_archive' => false,
191
+ 'exclude_from_search' => true,
192
+ 'publicly_queryable' => true,
193
+ 'capability_type' => 'post'
194
+ );
195
+
196
+ register_post_type( Plugin_Constants::AFFILIATE_LINKS_CPT , apply_filters( 'ta_affiliate_links_cpt_args' , $args , $labels ) );
197
+
198
+ do_action( 'ta_after_register_thirstylink_post_type' , $link_prefix );
199
+ }
200
+
201
+ /**
202
+ * Register the 'thirstylink-category' custom taxonomy.
203
+ *
204
+ * @since 3.0.0
205
+ * @access private
206
+ */
207
+ private function register_thirstylink_category_custom_taxonomy() {
208
+
209
+ $labels = array(
210
+ 'name' => __( 'Link Categories', 'thirstyaffiliates' ),
211
+ 'singular_name' => __( 'Link Category', 'thirstyaffiliates' ),
212
+ 'menu_name' => __( 'Link Categories', 'thirstyaffiliates' ),
213
+ 'all_items' => __( 'All Categories', 'thirstyaffiliates' ),
214
+ 'parent_item' => __( 'Parent Category', 'thirstyaffiliates' ),
215
+ 'parent_item_colon' => __( 'Parent Category:', 'thirstyaffiliates' ),
216
+ 'new_item_name' => __( 'New Category Name', 'thirstyaffiliates' ),
217
+ 'add_new_item' => __( 'Add New Category', 'thirstyaffiliates' ),
218
+ 'edit_item' => __( 'Edit Category', 'thirstyaffiliates' ),
219
+ 'update_item' => __( 'Update Category', 'thirstyaffiliates' ),
220
+ 'view_item' => __( 'View Category', 'thirstyaffiliates' ),
221
+ 'separate_items_with_commas' => __( 'Separate items with commas', 'thirstyaffiliates' ),
222
+ 'add_or_remove_items' => __( 'Add or remove items', 'thirstyaffiliates' ),
223
+ 'choose_from_most_used' => __( 'Choose from the most used', 'thirstyaffiliates' ),
224
+ 'popular_items' => __( 'Popular Categories', 'thirstyaffiliates' ),
225
+ 'search_items' => __( 'Search Categories', 'thirstyaffiliates' ),
226
+ 'not_found' => __( 'Not Found', 'thirstyaffiliates' ),
227
+ 'no_terms' => __( 'No items', 'thirstyaffiliates' ),
228
+ 'items_list' => __( 'Category list', 'thirstyaffiliates' ),
229
+ 'items_list_navigation' => __( 'Category list navigation', 'thirstyaffiliates' )
230
+ );
231
+
232
+ $args = array(
233
+ 'labels' => $labels,
234
+ 'hierarchical' => true,
235
+ 'public' => true,
236
+ 'show_ui' => true,
237
+ 'show_admin_column' => true,
238
+ 'show_in_nav_menus' => true,
239
+ 'show_tagcloud' => false,
240
+ 'rewrite' => false
241
+ );
242
+
243
+ register_taxonomy( Plugin_Constants::AFFILIATE_LINKS_TAX , Plugin_Constants::AFFILIATE_LINKS_CPT , apply_filters( 'ta_affiliate_link_taxonomy_args' , $args , $labels ) );
244
+
245
+ }
246
+
247
+ /**
248
+ * Replace default post type permalink html with affiliate link ID.
249
+ *
250
+ * @since 3.0.0
251
+ * @access public
252
+ *
253
+ * @param string $html Permalink html.
254
+ * @param int $post_id Affiliate Link post id.
255
+ * @return string Link ID html.
256
+ */
257
+ public function replace_permalink_with_id( $html , $post_id ) {
258
+
259
+ if ( get_post_type( $post_id ) == Plugin_Constants::AFFILIATE_LINKS_CPT )
260
+ return '<span id="link_id">' . __( 'Link ID:' , 'thirstyaffiliates' ) . ' <strong>' . $post_id . '</strong></span>';
261
+
262
+ return $html;
263
+ }
264
+
265
+ /**
266
+ * Register metaboxes
267
+ *
268
+ * @since 3.0.0
269
+ * @access public
270
+ */
271
+ public function register_metaboxes() {
272
+
273
+ // normal
274
+ add_meta_box( 'ta-urls-metabox', __( 'URLs', 'thirstyaffiliates' ), array( $this , 'urls_metabox' ) , Plugin_Constants::AFFILIATE_LINKS_CPT , 'normal' );
275
+ add_meta_box( 'ta-attach-images-metabox', __( 'Attach Images', 'thirstyaffiliates' ), array( $this , 'attach_images_metabox' ) , Plugin_Constants::AFFILIATE_LINKS_CPT , 'normal' );
276
+
277
+ // side
278
+ add_meta_box( 'ta-save-affiliate-link-metabox-side', __( 'Save Affiliate Link', 'thirstyaffiliates' ), array( $this , 'save_affiliate_link_metabox' ) , Plugin_Constants::AFFILIATE_LINKS_CPT , 'side' , 'high' );
279
+ add_meta_box( 'ta-link-options-metabox', __( 'Link Options', 'thirstyaffiliates' ), array( $this , 'link_options_metabox' ) , Plugin_Constants::AFFILIATE_LINKS_CPT , 'side' );
280
+
281
+ // remove
282
+ remove_meta_box( 'submitdiv', Plugin_Constants::AFFILIATE_LINKS_CPT, 'side' );
283
+
284
+ }
285
+
286
+ /**
287
+ * Display "URls" metabox
288
+ *
289
+ * @since 3.0.0
290
+ * @access public
291
+ *
292
+ * @param WP_Post $post Affiliate link WP_Post object.
293
+ */
294
+ public function urls_metabox( $post ) {
295
+
296
+ $screen = get_current_screen();
297
+ $thirstylink = $this->get_thirstylink_post( $post->ID );
298
+ $home_link_prefix = home_url( user_trailingslashit( $this->_helper_functions->get_thirstylink_link_prefix() ) );
299
+ $default_cat_slug = $this->_helper_functions->get_default_category_slug( $post->ID );
300
+
301
+ include_once( $this->_constants->VIEWS_ROOT_PATH() . 'cpt/view-urls-metabox.php' );
302
+
303
+ }
304
+
305
+ /**
306
+ * Display "Attach Images" metabox
307
+ *
308
+ * @since 3.0.0
309
+ * @access public
310
+ *
311
+ * @param WP_Post $post Affiliate link WP_Post object.
312
+ */
313
+ public function attach_images_metabox( $post ) {
314
+
315
+ $thirstylink = $this->get_thirstylink_post( $post->ID );
316
+ $legacy_uploader = get_option( 'ta_legacy_uploader', 'no' );
317
+ $attachments = $thirstylink->get_prop( 'image_ids' );
318
+
319
+ include_once( $this->_constants->VIEWS_ROOT_PATH() . 'cpt/view-attach-images-metabox.php' );
320
+
321
+ }
322
+
323
+ /**
324
+ * Display "Redirect Type" metabox
325
+ *
326
+ * @since 3.0.0
327
+ * @access public
328
+ *
329
+ * @param WP_Post $post Affiliate link WP_Post object.
330
+ */
331
+ public function link_options_metabox( $post ) {
332
+
333
+ $thirstylink = $this->get_thirstylink_post( $post->ID );
334
+ $default_redirect_type = get_option( 'ta_link_redirect_type' , '301' );
335
+ $post_redirect_type = $thirstylink->get_prop( 'redirect_type' , $default_redirect_type );
336
+ $redirect_types = $this->_constants->REDIRECT_TYPES();
337
+ $global_no_follow = get_option( 'ta_no_follow' ) == 'yes' ? 'yes' : 'no';
338
+ $global_new_window = get_option( 'ta_new_window' ) == 'yes' ? 'yes' : 'no';
339
+ $global_pass_query_str = get_option( 'ta_pass_query_str' ) == 'yes' ? 'yes' : 'no';
340
+ $global_uncloak = $thirstylink->get_global_uncloak_value();
341
+ $rel_tags = get_post_meta( $post->ID , Plugin_Constants::META_DATA_PREFIX . 'rel_tags' , true );
342
+ $global_rel_tags = get_option( 'ta_additional_rel_tags' );
343
+
344
+ include_once( $this->_constants->VIEWS_ROOT_PATH() . 'cpt/view-link-options-metabox.php' );
345
+
346
+ }
347
+
348
+ /**
349
+ * Display "Save Affiliate Link" metabox
350
+ *
351
+ * @since 3.0.0
352
+ * @access public
353
+ *
354
+ * @param WP_Post $post Affiliate link WP_Post object.
355
+ */
356
+ public function save_affiliate_link_metabox( $post ) {
357
+
358
+ include( $this->_constants->VIEWS_ROOT_PATH() . 'cpt/view-save-affiliate-link-metabox.php' );
359
+
360
+ }
361
+
362
+ /**
363
+ * Save thirstylink post.
364
+ *
365
+ * @since 3.0.0
366
+ * @access public
367
+ *
368
+ * @param int $post_id Affiliate link post ID.
369
+ */
370
+ public function save_post( $post_id ) {
371
+
372
+ if ( ! isset( $_POST[ '_thirstyaffiliates_nonce' ] ) || ! wp_verify_nonce( $_POST['_thirstyaffiliates_nonce'], 'thirsty_affiliates_cpt_nonce' ) )
373
+ return;
374
+
375
+ // remove save_post hooked action to prevent infinite loop
376
+ remove_action( 'save_post' , array( $this , 'save_post' ) );
377
+
378
+ $thirstylink = $this->get_thirstylink_post( $post_id );
379
+
380
+ // set Properties
381
+ $thirstylink->set_prop( 'destination_url' , esc_url_raw( $_POST[ 'ta_destination_url' ] ) );
382
+ $thirstylink->set_prop( 'no_follow' , sanitize_text_field( $_POST[ 'ta_no_follow' ] ) );
383
+ $thirstylink->set_prop( 'new_window' , sanitize_text_field( $_POST[ 'ta_new_window' ] ) );
384
+ $thirstylink->set_prop( 'pass_query_str' , sanitize_text_field( $_POST[ 'ta_pass_query_str' ] ) );
385
+ $thirstylink->set_prop( 'redirect_type' , sanitize_text_field( $_POST[ 'ta_redirect_type' ] ) );
386
+ $thirstylink->set_prop( 'rel_tags' , sanitize_text_field( $_POST[ 'ta_rel_tags' ] ) );
387
+
388
+ if ( isset( $_POST[ 'ta_uncloak_link' ] ) )
389
+ $thirstylink->set_prop( 'uncloak_link' , sanitize_text_field( $_POST[ 'ta_uncloak_link' ] ) );
390
+
391
+ if ( isset( $_POST[ 'ta_category_slug' ] ) && $_POST[ 'ta_category_slug' ] ) {
392
+
393
+ $category_slug_id = (int) sanitize_text_field( $_POST[ 'ta_category_slug' ] );
394
+ $category_slug = get_term( $category_slug_id , Plugin_Constants::AFFILIATE_LINKS_TAX );
395
+ $thirstylink->set_prop( 'category_slug_id' , $category_slug_id );
396
+ $thirstylink->set_prop( 'category_slug' , $category_slug->slug );
397
+
398
+ } else {
399
+
400
+ $thirstylink->set_prop( 'category_slug_id' , 0 );
401
+ $thirstylink->set_prop( 'category_slug' , '' );
402
+ }
403
+
404
+ do_action( 'ta_save_affiliate_link_post' , $thirstylink , $post_id );
405
+
406
+ // save affiliate link
407
+ $thirstylink->save();
408
+
409
+ // set default term
410
+ $this->save_default_affiliate_link_category( $post_id );
411
+
412
+ // add back save_post hooked action after saving
413
+ add_action( 'save_post' , array( $this , 'save_post' ) );
414
+
415
+ do_action( 'ta_after_save_affiliate_link_post' , $post_id , $thirstylink );
416
+ }
417
+
418
+ /**
419
+ * Set default term when affiliate link is saved.
420
+ *
421
+ * @since 3.0.0
422
+ * @access public
423
+ *
424
+ * @param int $post_id Affiliate link post ID.
425
+ */
426
+ public function save_default_affiliate_link_category( $post_id ) {
427
+
428
+ $default_category = Plugin_Constants::DEFAULT_LINK_CATEGORY;
429
+ $taxonomy_slug = Plugin_Constants::AFFILIATE_LINKS_TAX;
430
+
431
+ if ( get_option( 'ta_disable_cat_auto_select' ) == 'yes' || get_the_terms( $post_id , $taxonomy_slug ) )
432
+ return;
433
+
434
+ // create the default term if it doesn't exist
435
+ if ( ! term_exists( $default_category , $taxonomy_slug ) )
436
+ wp_insert_term( $default_category , $taxonomy_slug );
437
+
438
+ $default_term = get_term_by( 'name' , $default_category , $taxonomy_slug );
439
+
440
+ wp_set_post_terms( $post_id , $default_term->term_id , $taxonomy_slug );
441
+ }
442
+
443
+ /**
444
+ * Add custom column to thirsty link listings (Link ID).
445
+ *
446
+ * @since 3.0.0
447
+ * @access public
448
+ *
449
+ * @param array $columns Post type listing columns.
450
+ * @return array
451
+ */
452
+ public function custom_post_listing_column( $columns ) {
453
+
454
+ $updated_columns = array();
455
+
456
+ foreach ( $columns as $key => $column ) {
457
+
458
+ // add link_id and link_destination column before link categories column
459
+ if ( $key == 'taxonomy-thirstylink-category' ) {
460
+
461
+ $updated_columns[ 'link_id' ] = __( 'Link ID' , 'thirstyaffiliates' );
462
+ $updated_columns[ 'redirect_type' ] = __( 'Redirect Type' , 'thirstyaffiliates' );
463
+ $updated_columns[ 'cloaked_url' ] = __( 'Cloaked URL' , 'thirstyaffiliates' );
464
+ $updated_columns[ 'link_destination' ] = __( 'Link Destination' , 'thirstyaffiliates' );
465
+ }
466
+
467
+
468
+ $updated_columns[ $key ] = $column;
469
+ }
470
+
471
+ return apply_filters( 'ta_post_listing_custom_columns' , $updated_columns );
472
+
473
+ }
474
+
475
+ /**
476
+ * Add custom column to thirsty link listings (Link ID).
477
+ *
478
+ * @since 3.0.0
479
+ * @access public
480
+ *
481
+ * @param string $column Current column name.
482
+ * @param int $post_id Thirstylink ID.
483
+ * @return array
484
+ */
485
+ public function custom_post_listing_column_value( $column , $post_id ) {
486
+
487
+ $thirstylink = $this->get_thirstylink_post( $post_id );
488
+
489
+ switch ( $column ) {
490
+
491
+ case 'link_id' :
492
+ echo '<span>' . $post_id . '</span>';
493
+ break;
494
+
495
+ case 'redirect_type' :
496
+ echo $thirstylink->get_prop( 'redirect_type' );
497
+ break;
498
+
499
+ case 'cloaked_url' :
500
+ echo '<input style="width:100%;" type="text" value="' . $thirstylink->get_prop( 'permalink' ) . '" readonly>';
501
+ break;
502
+
503
+ case 'link_destination' :
504
+ echo '<input style="width:100%;" type="text" value="' . $thirstylink->get_prop( 'destination_url' ) . '" readonly>';
505
+
506
+ break;
507
+
508
+ }
509
+
510
+ do_action( 'ta_post_listing_custom_columns_value' , $column , $thirstylink );
511
+
512
+ }
513
+
514
+ /**
515
+ * Add category slug to the permalink.
516
+ *
517
+ * @since 3.0.0
518
+ * @access public
519
+ *
520
+ * @param string $post_link Thirstylink permalink.
521
+ * @param WP_Post $post Thirstylink WP_Post object.
522
+ * @return string Thirstylink permalink.
523
+ */
524
+ public function add_category_slug_to_permalink( $post_link , $post ) {
525
+
526
+ $link_prefix = $this->_helper_functions->get_thirstylink_link_prefix();
527
+
528
+ if ( get_option( 'ta_show_cat_in_slug' ) !== 'yes' || is_wp_error( $post ) || $post->post_type != 'thirstylink' )
529
+ return $post_link;
530
+
531
+ $link_cat_id = get_post_meta( $post->ID , '_ta_category_slug_id' , true );
532
+ $link_cat = get_post_meta( $post->ID , '_ta_category_slug' , true );
533
+
534
+ if ( ! $link_cat && $link_cat_id ) {
535
+
536
+ $link_cat_obj = get_term( $link_cat_id , Plugin_Constants::AFFILIATE_LINKS_TAX );
537
+ $link_cat = $link_cat_obj->slug;
538
+
539
+ } elseif ( ! $link_cat && ! $link_cat_id ) {
540
+
541
+ $link_cat = $this->_helper_functions->get_default_category_slug( $post->ID );
542
+ }
543
+
544
+ if ( ! $link_cat )
545
+ return $post_link;
546
+
547
+ return home_url( user_trailingslashit( $link_prefix . '/' . $link_cat . '/' . $post->post_name ) );
548
+ }
549
+
550
+ /**
551
+ * Ajax get category slug.
552
+ *
553
+ * @since 3.0.0
554
+ * @access public
555
+ */
556
+ public function ajax_get_category_slug() {
557
+
558
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
559
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
560
+ elseif ( ! isset( $_POST[ 'term_id' ] ) )
561
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
562
+ else {
563
+
564
+ $link_cat_id = (int) sanitize_text_field( $_POST[ 'term_id' ] );
565
+ $category = get_term( $link_cat_id , Plugin_Constants::AFFILIATE_LINKS_TAX );
566
+
567
+ $response = array( 'status' => 'success' , 'category_slug' => $category->slug );
568
+ }
569
+
570
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
571
+ echo wp_json_encode( $response );
572
+ wp_die();
573
+ }
574
+
575
+
576
+
577
+
578
+ /*
579
+ |--------------------------------------------------------------------------
580
+ | Fulfill implemented interface contracts
581
+ |--------------------------------------------------------------------------
582
+ */
583
+
584
+ /**
585
+ * Method that houses codes to be executed on init hook.
586
+ *
587
+ * @since 3.0.0
588
+ * @access public
589
+ * @inherit ThirstyAffiliates\Interfaces\Initiable_Interface
590
+ */
591
+ public function initialize() {
592
+
593
+ // cpt and taxonomy
594
+ $this->register_thirstylink_custom_post_type();
595
+ $this->register_thirstylink_category_custom_taxonomy();
596
+
597
+ add_action( 'wp_ajax_ta_get_category_slug' , array( $this , 'ajax_get_category_slug' ) );
598
+
599
+ }
600
+
601
+ /**
602
+ * Execute 'thirstylink' custom post type code.
603
+ *
604
+ * @since 3.0.0
605
+ * @access public
606
+ * @inherit ThirstyAffiliates\Interfaces\Model_Interface
607
+ */
608
+ public function run() {
609
+
610
+ // replace permalink with link ID
611
+ add_filter( 'get_sample_permalink_html', array( $this , 'replace_permalink_with_id' ), 10 , 2 );
612
+
613
+ // metaboxes
614
+ add_action( 'add_meta_boxes' , array( $this , 'register_metaboxes' ) );
615
+ add_action( 'save_post' , array( $this , 'save_post' ) );
616
+
617
+ // custom column
618
+ add_filter( 'manage_edit-thirstylink_columns' , array( $this , 'custom_post_listing_column' ) );
619
+ add_action( 'manage_thirstylink_posts_custom_column', array( $this , 'custom_post_listing_column_value' ) , 10 , 2 );
620
+
621
+ // filter to add category on permalink
622
+ add_filter( 'post_type_link' , array( $this , 'add_category_slug_to_permalink' ) , 10 , 2 );
623
+
624
+ }
625
+
626
+ }
Models/Bootstrap.php ADDED
@@ -0,0 +1,424 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Models;
3
+
4
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
5
+
6
+ use ThirstyAffiliates\Interfaces\Model_Interface;
7
+ use ThirstyAffiliates\Interfaces\Activatable_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+
10
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
11
+ use ThirstyAffiliates\Helpers\Helper_Functions;
12
+
13
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
+ /**
16
+ * Model that houses the logic of 'Bootstraping' the plugin.
17
+ *
18
+ * @since 3.0.0
19
+ */
20
+ class Bootstrap implements Model_Interface {
21
+
22
+ /*
23
+ |--------------------------------------------------------------------------
24
+ | Class Properties
25
+ |--------------------------------------------------------------------------
26
+ */
27
+
28
+ /**
29
+ * Property that holds the single main instance of Bootstrap.
30
+ *
31
+ * @since 3.0.0
32
+ * @access private
33
+ * @var Bootstrap
34
+ */
35
+ private static $_instance;
36
+
37
+ /**
38
+ * Model that houses all the plugin constants.
39
+ *
40
+ * @since 3.0.0
41
+ * @access private
42
+ * @var Plugin_Constants
43
+ */
44
+ private $_constants;
45
+
46
+ /**
47
+ * Property that houses all the helper functions of the plugin.
48
+ *
49
+ * @since 3.0.0
50
+ * @access private
51
+ * @var Helper_Functions
52
+ */
53
+ private $_helper_functions;
54
+
55
+ /**
56
+ * Array of models implementing the ThirstyAffiliates\Interfaces\Activatable_Interface.
57
+ *
58
+ * @since 3.0.0
59
+ * @access private
60
+ * @var array
61
+ */
62
+ private $_activatables;
63
+
64
+ /**
65
+ * Array of models implementing the ThirstyAffiliates\Interfaces\Initiable_Interface.
66
+ *
67
+ * @since 3.0.0
68
+ * @access private
69
+ * @var array
70
+ */
71
+ private $_initiables;
72
+
73
+
74
+
75
+
76
+ /*
77
+ |--------------------------------------------------------------------------
78
+ | Class Methods
79
+ |--------------------------------------------------------------------------
80
+ */
81
+
82
+ /**
83
+ * Class constructor.
84
+ *
85
+ * @since 3.0.0
86
+ * @access public
87
+ *
88
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
89
+ * @param Plugin_Constants $constants Plugin constants object.
90
+ * @param Helper_Functions $helper_functions Helper functions object.
91
+ * @param array $activatables Array of models implementing ThirstyAffiliates\Interfaces\Activatable_Interface.
92
+ * @param array $initiables Array of models implementing ThirstyAffiliates\Interfaces\Initiable_Interface.
93
+ */
94
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions , array $activatables = array() , array $initiables = array() ) {
95
+
96
+ $this->_constants = $constants;
97
+ $this->_helper_functions = $helper_functions;
98
+ $this->_activatables = $activatables;
99
+ $this->_initiables = $initiables;
100
+
101
+ $main_plugin->add_to_all_plugin_models( $this );
102
+
103
+ }
104
+
105
+ /**
106
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
107
+ *
108
+ * @since 3.0.0
109
+ * @access public
110
+ *
111
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
112
+ * @param Plugin_Constants $constants Plugin constants object.
113
+ * @param Helper_Functions $helper_functions Helper functions object.
114
+ * @param array $activatables Array of models implementing ThirstyAffiliates\Interfaces\Activatable_Interface.
115
+ * @param array $initiables Array of models implementing ThirstyAffiliates\Interfaces\Initiable_Interface.
116
+ * @return Bootstrap
117
+ */
118
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions , array $activatables = array() , array $initiables = array() ) {
119
+
120
+ if ( !self::$_instance instanceof self )
121
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions , $activatables , $initiables );
122
+
123
+ return self::$_instance;
124
+
125
+ }
126
+
127
+ /**
128
+ * Load plugin text domain.
129
+ *
130
+ * @since 3.0.0
131
+ * @access public
132
+ */
133
+ public function load_plugin_textdomain() {
134
+
135
+ load_plugin_textdomain( Plugin_Constants::TEXT_DOMAIN , false , $this->_constants->PLUGIN_DIRNAME() . '/languages' );
136
+
137
+ }
138
+
139
+ /**
140
+ * Method that houses the logic relating to activating the plugin.
141
+ *
142
+ * @since 3.0.0
143
+ * @access public
144
+ *
145
+ * @global wpdb $wpdb Object that contains a set of functions used to interact with a database.
146
+ *
147
+ * @param boolean $network_wide Flag that determines whether the plugin has been activated network wid ( on multi site environment ) or not.
148
+ */
149
+ public function activate_plugin( $network_wide ) {
150
+
151
+ // Suppress any errors
152
+ @deactivate_plugins( array(
153
+ 'thirstyaffiliates-stats/thirstyaffiliates-stats.php',
154
+ 'thirstyaffiliates-htaccess-redirect/thirstyaffiliates-htaccess-refactor.bootstrap.php',
155
+ 'thirstyaffiliates-google-click-tracking/thirstyaffiliates-google-click-tracking.php',
156
+ 'thirstyaffiliates-geolocations/thirstyaffiliates-geolocations.php',
157
+ 'thirstyaffiliates-csv-importer/thirstyaffiliates-csv-importer.php',
158
+ 'thirstyaffiliates-autolinker/thirstyaffiliates-autolinker.php',
159
+ 'thirstyaffiliates-azon-add-on/azon-bootstrap.php',
160
+ 'thirstyaffiliates-itunes/thirstyaffiliates-itunes.bootstrap.php'
161
+ ) , true , null ); // Deactivate on all sites in the network and do not fire deactivation hooks
162
+
163
+ global $wpdb;
164
+
165
+ if ( is_multisite() ) {
166
+
167
+ if ( $network_wide ) {
168
+
169
+ // get ids of all sites
170
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
171
+
172
+ foreach ( $blog_ids as $blog_id ) {
173
+
174
+ switch_to_blog( $blog_id );
175
+ $this->_activate_plugin( $blog_id );
176
+
177
+ }
178
+
179
+ restore_current_blog();
180
+
181
+ } else
182
+ $this->_activate_plugin( $wpdb->blogid ); // activated on a single site, in a multi-site
183
+
184
+ } else
185
+ $this->_activate_plugin( $wpdb->blogid ); // activated on a single site
186
+
187
+ }
188
+
189
+ /**
190
+ * Method to initialize a newly created site in a multi site set up.
191
+ *
192
+ * @since 3.0.0
193
+ * @access public
194
+ *
195
+ * @param int $blogid Blog ID of the created blog.
196
+ * @param int $user_id User ID of the user creating the blog.
197
+ * @param string $domain Domain used for the new blog.
198
+ * @param string $path Path to the new blog.
199
+ * @param int $site_id Site ID. Only relevant on multi-network installs.
200
+ * @param array $meta Meta data. Used to set initial site options.
201
+ */
202
+ public function new_mu_site_init( $blog_id , $user_id , $domain , $path , $site_id , $meta ) {
203
+
204
+ if ( is_plugin_active_for_network( 'thirstyaffiliates/thirstyaffiliates.php' ) ) {
205
+
206
+ switch_to_blog( $blog_id );
207
+ $this->_activate_plugin( $blog_id );
208
+ restore_current_blog();
209
+
210
+ }
211
+
212
+ }
213
+
214
+ /**
215
+ * Initialize plugin settings options.
216
+ * This is a compromise to my idea of 'Modularity'. Ideally, bootstrap should not take care of plugin settings stuff.
217
+ * However due to how WooCommerce do its thing, we need to do it this way. We can't separate settings on its own.
218
+ *
219
+ * @since 3.0.0
220
+ * @access private
221
+ */
222
+ private function _initialize_plugin_settings_options() {
223
+
224
+ // Help settings section options
225
+
226
+ // Set initial value of 'no' for the option that sets the option that specify whether to delete the options on plugin uninstall. Optionception.
227
+ if ( !get_option( Plugin_Constants::CLEAN_UP_PLUGIN_OPTIONS , false ) )
228
+ update_option( Plugin_Constants::CLEAN_UP_PLUGIN_OPTIONS , 'no' );
229
+
230
+ }
231
+
232
+ /**
233
+ * Actual function that houses the code to execute on plugin activation.
234
+ *
235
+ * @since 3.0.0
236
+ * @since 3.0.0 Added the ta_activation_date option
237
+ * @access private
238
+ *
239
+ * @param int $blogid Blog ID of the created blog.
240
+ */
241
+ private function _activate_plugin( $blogid ) {
242
+
243
+ // Initialize settings options
244
+ $this->_initialize_plugin_settings_options();
245
+
246
+ // Create database tables
247
+ $this->_create_database_tables();
248
+
249
+ // set flush rewrite rules transient so it can be flushed after the CPT and rewrite rules have been registered.
250
+ set_transient( 'ta_flush_rewrite_rules' , 'true' , 5 * 60 );
251
+
252
+ // Execute 'activate' contract of models implementing ThirstyAffiliates\Interfaces\Activatable_Interface
253
+ foreach ( $this->_activatables as $activatable )
254
+ if ( $activatable instanceof Activatable_Interface )
255
+ $activatable->activate();
256
+
257
+ update_option( Plugin_Constants::INSTALLED_VERSION , Plugin_Constants::VERSION ); // Update current installed plugin version
258
+ update_option( 'ta_activation_code_triggered' , 'yes' ); // Mark activation code triggered
259
+
260
+ }
261
+
262
+ /**
263
+ * Method that houses the logic relating to deactivating the plugin.
264
+ *
265
+ * @since 3.0.0
266
+ * @access public
267
+ *
268
+ * @global wpdb $wpdb Object that contains a set of functions used to interact with a database.
269
+ *
270
+ * @param boolean $network_wide Flag that determines whether the plugin has been activated network wid ( on multi site environment ) or not.
271
+ */
272
+ public function deactivate_plugin( $network_wide ) {
273
+
274
+ global $wpdb;
275
+
276
+ // check if it is a multisite network
277
+ if ( is_multisite() ) {
278
+
279
+ // check if the plugin has been activated on the network or on a single site
280
+ if ( $network_wide ) {
281
+
282
+ // get ids of all sites
283
+ $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
284
+
285
+ foreach ( $blog_ids as $blog_id ) {
286
+
287
+ switch_to_blog( $blog_id );
288
+ $this->_deactivate_plugin( $wpdb->blogid );
289
+
290
+ }
291
+
292
+ restore_current_blog();
293
+
294
+ } else
295
+ $this->_deactivate_plugin( $wpdb->blogid ); // activated on a single site, in a multi-site
296
+
297
+ } else
298
+ $this->_deactivate_plugin( $wpdb->blogid ); // activated on a single site
299
+
300
+ }
301
+
302
+ /**
303
+ * Actual method that houses the code to execute on plugin deactivation.
304
+ *
305
+ * @since 3.0.0
306
+ * @access private
307
+ *
308
+ * @param int $blogid Blog ID of the created blog.
309
+ */
310
+ private function _deactivate_plugin( $blogid ) {
311
+
312
+ flush_rewrite_rules();
313
+
314
+ }
315
+
316
+ /**
317
+ * Create database tables.
318
+ *
319
+ * @since 3.0.0
320
+ * @access private
321
+ */
322
+ private function _create_database_tables() {
323
+
324
+ global $wpdb;
325
+
326
+ if ( get_option( 'ta_database_tables_created' ) === 'yes' )
327
+ return;
328
+
329
+ $link_click_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_DB;
330
+ $link_click_meta_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_META_DB;
331
+ $charset_collate = $wpdb->get_charset_collate();
332
+
333
+ // link clicks db sql command
334
+ $sql = "CREATE TABLE $link_click_db (
335
+ id bigint(20) NOT NULL AUTO_INCREMENT,
336
+ link_id bigint(20) NOT NULL,
337
+ date_clicked datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
338
+ PRIMARY KEY (id)
339
+ ) $charset_collate;\n";
340
+
341
+ // link clicks meta db sql command
342
+ $sql .= "CREATE TABLE $link_click_meta_db (
343
+ id bigint(20) NOT NULL AUTO_INCREMENT,
344
+ click_id bigint(20) NOT NULL,
345
+ meta_key varchar(255) NULL,
346
+ meta_value longtext NULL,
347
+ PRIMARY KEY (id)
348
+ ) $charset_collate;";
349
+
350
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
351
+ dbDelta( $sql );
352
+
353
+ update_option( 'ta_database_tables_created' , 'yes' );
354
+ }
355
+
356
+ /**
357
+ * Add custom links to the plugin's action links.
358
+ *
359
+ * @since 3.0.0
360
+ * @access public
361
+ */
362
+ public function plugin_action_links( $links ) {
363
+
364
+ $settings_link = admin_url( 'edit.php?post_type=' . Plugin_Constants::AFFILIATE_LINKS_CPT . '&page=thirsty-settings' );
365
+
366
+ $new_links = array(
367
+ '<a href="' . $settings_link . '">' . __( 'Settings' , 'thirstyaffiliates' ) . '</a>'
368
+ );
369
+
370
+ return array_merge( $new_links , $links );
371
+ }
372
+
373
+ /**
374
+ * Method that houses codes to be executed on init hook.
375
+ *
376
+ * @since 3.0.0
377
+ * @access public
378
+ */
379
+ public function initialize() {
380
+
381
+ // Execute activation codebase if not yet executed on plugin activation ( Mostly due to plugin dependencies )
382
+ if ( get_option( 'ta_activation_code_triggered' , false ) !== 'yes' ) {
383
+
384
+ if ( ! function_exists( 'is_plugin_active_for_network' ) )
385
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
386
+
387
+ $network_wide = is_plugin_active_for_network( 'thirstyaffiliates/thirstyaffiliates.php' );
388
+ $this->activate_plugin( $network_wide );
389
+
390
+ }
391
+
392
+ // Execute 'initialize' contract of models implementing ThirstyAffiliates\Interfaces\Initiable_Interface
393
+ foreach ( $this->_initiables as $initiable )
394
+ if ( $initiable instanceof Initiable_Interface )
395
+ $initiable->initialize();
396
+
397
+ }
398
+
399
+ /**
400
+ * Execute plugin bootstrap code.
401
+ *
402
+ * @since 3.0.0
403
+ * @access public
404
+ */
405
+ public function run() {
406
+
407
+ // Internationalization
408
+ add_action( 'plugins_loaded' , array( $this , 'load_plugin_textdomain' ) );
409
+
410
+ // Execute plugin activation/deactivation
411
+ register_activation_hook( $this->_constants->MAIN_PLUGIN_FILE_PATH() , array( $this , 'activate_plugin' ) );
412
+ register_deactivation_hook( $this->_constants->MAIN_PLUGIN_FILE_PATH() , array( $this , 'deactivate_plugin' ) );
413
+
414
+ // Execute plugin initialization ( plugin activation ) on every newly created site in a multi site set up
415
+ add_action( 'wpmu_new_blog' , array( $this , 'new_mu_site_init' ) , 10 , 6 );
416
+
417
+ add_filter( 'plugin_action_links_' . $this->_constants->PLUGIN_BASENAME() , array( $this , 'plugin_action_links' ) );
418
+
419
+ // Execute codes that need to run on 'init' hook
420
+ add_action( 'init' , array( $this , 'initialize' ) );
421
+
422
+ }
423
+
424
+ }
Models/Guided_Tour.php ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Activatable_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+ use ThirstyAffiliates\Interfaces\Model_Interface;
10
+
11
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
12
+ use ThirstyAffiliates\Helpers\Helper_Functions;
13
+
14
+ /**
15
+ * Model that houses the logic for permalink rewrites and affiliate link redirections.
16
+ *
17
+ * @since 3.0.0
18
+ */
19
+ class Guided_Tour implements Model_Interface , Activatable_Interface , Initiable_Interface {
20
+
21
+ /*
22
+ |--------------------------------------------------------------------------
23
+ | Class Properties
24
+ |--------------------------------------------------------------------------
25
+ */
26
+
27
+ /**
28
+ * Property that holds the single main instance of Shortcodes.
29
+ *
30
+ * @since 3.0.0
31
+ * @access private
32
+ * @var Redirection
33
+ */
34
+ private static $_instance;
35
+
36
+ /**
37
+ * Model that houses the main plugin object.
38
+ *
39
+ * @since 3.0.0
40
+ * @access private
41
+ * @var Redirection
42
+ */
43
+ private $_main_plugin;
44
+
45
+ /**
46
+ * Model that houses all the plugin constants.
47
+ *
48
+ * @since 3.0.0
49
+ * @access private
50
+ * @var Plugin_Constants
51
+ */
52
+ private $_constants;
53
+
54
+ /**
55
+ * Property that houses all the helper functions of the plugin.
56
+ *
57
+ * @since 3.0.0
58
+ * @access private
59
+ * @var Helper_Functions
60
+ */
61
+ private $_helper_functions;
62
+
63
+ /**
64
+ * Property that urls of the guided tour screens.
65
+ *
66
+ * @since 3.0.0
67
+ * @access private
68
+ * @var array
69
+ */
70
+ private $_urls = array();
71
+
72
+ /**
73
+ * Property that houses the screens of the guided tour.
74
+ *
75
+ * @since 3.0.0
76
+ * @access private
77
+ * @var array
78
+ */
79
+ private $_screens = array();
80
+
81
+
82
+
83
+
84
+ /*
85
+ |--------------------------------------------------------------------------
86
+ | Class Methods
87
+ |--------------------------------------------------------------------------
88
+ */
89
+
90
+ /**
91
+ * Class constructor.
92
+ *
93
+ * @since 3.0.0
94
+ * @access public
95
+ *
96
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
97
+ * @param Plugin_Constants $constants Plugin constants object.
98
+ * @param Helper_Functions $helper_functions Helper functions object.
99
+ */
100
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
101
+
102
+ $this->_constants = $constants;
103
+ $this->_helper_functions = $helper_functions;
104
+
105
+ $main_plugin->add_to_all_plugin_models( $this );
106
+ }
107
+
108
+ /**
109
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
110
+ *
111
+ * @since 3.0.0
112
+ * @access public
113
+ *
114
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
115
+ * @param Plugin_Constants $constants Plugin constants object.
116
+ * @param Helper_Functions $helper_functions Helper functions object.
117
+ * @return Redirection
118
+ */
119
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
120
+
121
+ if ( !self::$_instance instanceof self )
122
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
123
+
124
+ return self::$_instance;
125
+
126
+ }
127
+
128
+ /**
129
+ * Define guided tour pages.
130
+ *
131
+ * @since 3.0.0
132
+ * @access private
133
+ */
134
+ private function define_guided_tour_pages() {
135
+
136
+ $this->_urls = apply_filters( 'ta_guided_tour_pages' , array(
137
+ 'plugin-listing' => admin_url( 'plugins.php' ),
138
+ 'affiliate-links-listing' => admin_url( 'edit.php?post_type=thirstylink' ),
139
+ 'new-wp-post' => admin_url( 'post-new.php' ),
140
+ 'general-settings' => admin_url( 'edit.php?post_type=thirstylink&page=thirsty-settings' ),
141
+ 'link-apperance-settings' => admin_url( 'edit.php?post_type=thirstylink&page=thirsty-settings&tab=ta_links_settings' ),
142
+ 'modules-settings' => admin_url( 'edit.php?post_type=thirstylink&page=thirsty-settings&tab=ta_modules_settings' ),
143
+ 'import-export-settings' => admin_url( 'edit.php?post_type=thirstylink&page=thirsty-settings&tab=ta_import_export_settings' ),
144
+ 'help-settings' => admin_url( 'edit.php?post_type=thirstylink&page=thirsty-settings&tab=ta_help_settings' ),
145
+ 'new-affiliate-link' => admin_url( 'post-new.php?post_type=thirstylink' ),
146
+ ) );
147
+
148
+ $this->_screens = apply_filters( 'ta_guided_tours' , array(
149
+ 'plugins' => array(
150
+ 'elem' => '#menu-posts-thirstylink .menu-top',
151
+ 'html' => __( '<h3>Congratulations, you just activated ThirstyAffiliates!</h3>
152
+ <p>Would you like to take a tour of the plugin features? It takes less than a minute and you\'ll then know exactly how to use the plugin.</p>', 'thirstyaffiliates' ),
153
+ 'prev' => null,
154
+ 'next' => $this->_urls[ 'affiliate-links-listing' ],
155
+ 'edge' => 'left',
156
+ 'align' => 'left',
157
+ ),
158
+ 'edit-thirstylink' => array(
159
+ 'elem' => '#wpbody-content > .wrap > .wp-heading-inline',
160
+ 'html' => __( '<h3>ThirstyAffiliates helps you manage affiliate links that you are given from the various affiliate programs you are a member of.</h3>
161
+ <p>It lets you hide long, and often confusing looking, affiliate link URLs behind another URL called a redirect. When your visitors click on that new URL they are automatically redirected to your affiliate link.</p>
162
+ <p>This is helpful for five reasons:</p>
163
+ <ol><li>AESTHETICS: Affiliate links are often long and ugly as mentioned and this can look off putting to visitors. ThirstyAffiliates redirects make them shorter and more attractive to click on like "http://example.com/recommends/some-product-name"</li>
164
+ <li>PROTECTION: It hides the affiliate code, so malicious software (malware) cannot sniff out the affiliate code for common affiliate programs and replace it with their own code instead. In this way, it protects your commissions.</li>
165
+ <li>CONVENIENCE: If the affiliate program ever changes the link code you’ll only have ONE place to change it on your blog, rather than going through all your content and changing every instance of the link.</li>
166
+ <li>CATEGORIZATION: You categorize your affiliate links into logical groups which can make managing them much simpler.</li>
167
+ <li>STATISTICS: Finally, because your visitors are travelling via a ThirstyAffiliates redirect, the plugin can provide you with statistics on what is being clicked.</li></ol>
168
+ <p>You can now create an “Affiliate Link” in this new section in your dashboard. This view shows you all the affiliate links you are managing with ThirstyAffiliates.</p>', 'thirstyaffiliates' ),
169
+ 'prev' => $this->_urls[ 'plugin-listing' ],
170
+ 'next' => $this->_urls[ 'new-wp-post' ],
171
+ 'edge' => 'top',
172
+ 'align' => 'left',
173
+ 'width' => 600
174
+ ),
175
+ 'post' => array(
176
+ 'elem' => '#wpbody #insert-media-button',
177
+ 'html' => __( '<h3>Affiliate links can be added to your posts easily by clicking on the “TA” button on your editor.</h3>
178
+ <p>This works identically to the WordPress link tool, but only searches for affiliate links.</p>
179
+ <p>Give it a try by typing in some text, highlighting it, then clicking the “TA” button.</p>
180
+ <p>If you need to you can click the cog icon for an advanced search view which is handy for doing more advanced searches and for inserting images pre-wrapped with your affiliate link or via a shortcode instead.</p>', 'thirstyaffiliates' ),
181
+ 'prev' => $this->_urls[ 'affiliate-links-listing' ],
182
+ 'next' => $this->_urls[ 'general-settings' ],
183
+ 'edge' => 'top',
184
+ 'align' => 'left',
185
+ 'width' => 400
186
+ ),
187
+ 'thirstylink_page_thirsty-settings' => array(
188
+ 'ta_general_settings' => array(
189
+ 'elem' => '.nav-tab-wrapper .ta_general_settings',
190
+ 'html' => __( '<h3>ThirstyAffiliates has a number of settings that change the way it works, behaves and how your links appear.</h3>
191
+ <p>Here are the General settings which are for changing the way you work with ThirstyAffiliates in the backend.</p>', 'thirstyaffiliates' ),
192
+ 'prev' => $this->_urls[ 'new-wp-post' ],
193
+ 'next' => $this->_urls[ 'link-apperance-settings' ],
194
+ 'edge' => 'top',
195
+ 'align' => 'left',
196
+ ),
197
+ 'ta_links_settings' => array(
198
+ 'elem' => '.nav-tab-wrapper .ta_links_settings',
199
+ 'html' => __( '<h3>One of the most important parts of the settings area is Link Appearance which changes the way your links look to your visitors.</h3>
200
+ <p>This includes the Link Prefix setting which is important to decide on before you start using ThirstyAffiliates.</p>
201
+ <p>By default, this is set to “recommends” so your links will look like “http://example.com/recommends/some-product-name”.</p>
202
+ <p>You can also choose to include the category slug in the URL, change the way ThirstyAffiliates redirects links, add no follow, make links open in a new window and more.</p>', 'thirstyaffiliates' ),
203
+ 'prev' => $this->_urls[ 'general-settings' ],
204
+ 'next' => $this->_urls[ 'modules-settings' ],
205
+ 'edge' => 'top',
206
+ 'align' => 'left',
207
+ 'width' => 450
208
+ ),
209
+ 'ta_modules_settings' => array(
210
+ 'elem' => '.nav-tab-wrapper .ta_modules_settings',
211
+ 'html' => __( '<h3>We built ThirstyAffiliates to be flexible and as such, you can shut down the parts of ThirstyAffiliates that aren’t being used. This can make the plugin faster.</h3>
212
+ <p>If you have the Pro add-on each Pro module will show in here as well.</p>', 'thirstyaffiliates' ),
213
+ 'prev' => $this->_urls[ 'link-apperance-settings' ],
214
+ 'next' => $this->_urls[ 'import-export-settings' ],
215
+ 'edge' => 'top',
216
+ 'align' => 'left',
217
+ ),
218
+ 'ta_import_export_settings' => array(
219
+ 'elem' => '.nav-tab-wrapper .ta_import_export_settings',
220
+ 'html' => __( '<h3>Setting up multiple sites with all running ThirstyAffiliates?</h3>
221
+ <p>We’ve made it super simple to configure your additional sites by being able to import and export ThirstyAffiliate settings.</p>
222
+ <p>Just copy the Export section and paste it into the Import section on your other site and ThirstyAffiliates will be automatically configured the same way.</p>', 'thirstyaffiliates' ),
223
+ 'prev' => $this->_urls[ 'modules-settings' ],
224
+ 'next' => $this->_urls[ 'help-settings' ],
225
+ 'edge' => 'top',
226
+ 'align' => 'right',
227
+ ),
228
+ 'ta_help_settings' => array(
229
+ 'elem' => '.nav-tab-wrapper .ta_help_settings',
230
+ 'html' => __( '<h3>Need some help with ThirstyAffiliates?</h3>
231
+ <p>We have a growing knowledge base filled with guides, troubleshooting and FAQ.</p>
232
+ <p>Our blog is also very active with lots of interesting affiliate marketing topics to help you grow your affiliate marketing empire.</p>', 'thirstyaffiliates' ),
233
+ 'prev' => $this->_urls[ 'import-export-settings' ],
234
+ 'next' => $this->_urls[ 'new-affiliate-link' ],
235
+ 'edge' => 'top',
236
+ 'align' => 'right',
237
+ )
238
+ ),
239
+ 'thirstylink' => array(
240
+ 'elem' => '#menu-posts-thirstylink',
241
+ 'html' => __( '<h3>
This concludes the guide. You are now ready to setup your first affiliate link!</h3>
242
+ <p>We also have a Pro add-on for ThirstyAffiliates which contains lots of interesting features for affiliates like:</p>
243
+ <ul><li>Automatically link up your affiliate links to keywords in your blog</li>
244
+ <li>Get more detailed and advanced reports</li>
245
+ <li>Geolocated affiliate links</li>
246
+ <li>Google Analytics integration</li>
247
+ <li>CSV importing/exporting, Amazon importing, and more</li>
248
+ <li>Link event notification admin emails</li>
249
+ <li>Automatic link health checker</li></ul>
250
+ <p>Want to unlock all of the extra features you see here? The Pro add-on is for you. And we’re adding new features all the time!</p>', 'thirstyaffiliates' ),
251
+ 'prev' => $this->_urls[ 'help-settings' ],
252
+ 'next' => null,
253
+ 'edge' => 'left',
254
+ 'align' => 'left',
255
+ 'width' => 620,
256
+ 'btn_tour_done' => __( 'Check out the current Pro add-on features' , 'thirstyaffiliates' ),
257
+ 'btn_tour_done_url' => 'https://thirstyaffiliates.com/pricing?utm_source=Free%20Plugin&utm_medium=Tour&utm_campaign=Pro%20Link'
258
+ ),
259
+ ) );
260
+ }
261
+
262
+ /**
263
+ * Get current screen.
264
+ *
265
+ * @since 3.0.0
266
+ * @access public
267
+ *
268
+ * @return array Current guide tour screen.
269
+ */
270
+ public function get_current_screen() {
271
+
272
+ $screen = get_current_screen();
273
+ $tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field( $_GET[ 'tab' ] ) : '';
274
+
275
+ if ( ! isset( $this->_screens[ $screen->id ] ) || empty( $this->_screens[ $screen->id ] ) )
276
+ return;
277
+
278
+ if ( $screen->id == 'thirstylink_page_thirsty-settings' ) {
279
+
280
+ if( $tab && isset( $this->_screens[ $screen->id ][ $tab ] ) )
281
+ return $this->_screens[ $screen->id ][ $tab ];
282
+ elseif ( ! isset( $_GET[ 'tab' ] ) )
283
+ return $this->_screens[ $screen->id ][ 'ta_general_settings' ];
284
+ else
285
+ return array();
286
+ }
287
+
288
+ return $this->_screens[ $screen->id ];
289
+ }
290
+
291
+ /**
292
+ * Get all guide tour screens.
293
+ *
294
+ * @since 3.0.0
295
+ * @access public
296
+ *
297
+ * @return array List of all guide tour screens.
298
+ */
299
+ public function get_screens() {
300
+
301
+ return $this->_screens;
302
+ }
303
+
304
+ /**
305
+ * AJAX close guided tour.
306
+ *
307
+ * @since 3.0.0
308
+ * @access public
309
+ */
310
+ public function ajax_close_guided_tour() {
311
+
312
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
313
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
314
+ elseif ( ! check_ajax_referer( 'ta-close-guided-tour' , 'nonce' , false ) )
315
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Security Check Failed' , 'thirstyaffiliates' ) );
316
+ else {
317
+
318
+ update_option( 'ta_guided_tour_status' , 'close' );
319
+ $response = array( 'status' => 'success' );
320
+ }
321
+
322
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
323
+ echo wp_json_encode( $response );
324
+ wp_die();
325
+ }
326
+
327
+ /**
328
+ * Set the guided tour status option as 'open' on activation.
329
+ *
330
+ * @since 3.0.0
331
+ * @access private
332
+ */
333
+ private function set_guided_tour_status_open() {
334
+
335
+ update_option( 'ta_guided_tour_status' , 'open' );
336
+ }
337
+
338
+
339
+
340
+
341
+ /*
342
+ |--------------------------------------------------------------------------
343
+ | Implemented Interface Methods
344
+ |--------------------------------------------------------------------------
345
+ */
346
+
347
+ /**
348
+ * Execute codes that needs to run plugin activation.
349
+ *
350
+ * @since 3.0.0
351
+ * @access public
352
+ * @implements ThirstyAffiliates\Interfaces\Activatable_Interface
353
+ */
354
+ public function activate() {
355
+
356
+ $this->set_guided_tour_status_open();
357
+ }
358
+
359
+ /**
360
+ * Method that houses codes to be executed on init hook.
361
+ *
362
+ * @since 3.0.0
363
+ * @access public
364
+ * @inherit ThirstyAffiliates\Interfaces\Initiable_Interface
365
+ */
366
+ public function initialize() {
367
+
368
+ add_action( 'wp_ajax_ta_close_guided_tour' , array( $this , 'ajax_close_guided_tour' ) );
369
+ }
370
+
371
+ /**
372
+ * Execute model.
373
+ *
374
+ * @implements ThirstyAffiliates\Interfaces\Model_Interface
375
+ *
376
+ * @since 3.0.0
377
+ * @access public
378
+ */
379
+ public function run() {
380
+
381
+ if ( get_option( 'ta_guided_tour_status' ) !== 'open' )
382
+ return;
383
+
384
+ $this->define_guided_tour_pages();
385
+ }
386
+ }
Models/Link_Fixer.php ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+
10
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
11
+ use ThirstyAffiliates\Helpers\Helper_Functions;
12
+
13
+ use ThirstyAffiliates\Models\Affiliate_Link;
14
+
15
+ /**
16
+ * Model that houses the link fixer logic.
17
+ *
18
+ * @since 3.0.0
19
+ */
20
+ class Link_Fixer implements Model_Interface , Initiable_Interface {
21
+
22
+ /*
23
+ |--------------------------------------------------------------------------
24
+ | Class Properties
25
+ |--------------------------------------------------------------------------
26
+ */
27
+
28
+ /**
29
+ * Property that holds the single main instance of Bootstrap.
30
+ *
31
+ * @since 3.0.0
32
+ * @access private
33
+ * @var Link_Fixer
34
+ */
35
+ private static $_instance;
36
+
37
+ /**
38
+ * Model that houses the main plugin object.
39
+ *
40
+ * @since 3.0.0
41
+ * @access private
42
+ * @var Abstract_Main_Plugin_Class
43
+ */
44
+ private $_main_plugin;
45
+
46
+ /**
47
+ * Model that houses all the plugin constants.
48
+ *
49
+ * @since 3.0.0
50
+ * @access private
51
+ * @var Plugin_Constants
52
+ */
53
+ private $_constants;
54
+
55
+ /**
56
+ * Property that houses all the helper functions of the plugin.
57
+ *
58
+ * @since 3.0.0
59
+ * @access private
60
+ * @var Helper_Functions
61
+ */
62
+ private $_helper_functions;
63
+
64
+
65
+
66
+
67
+ /*
68
+ |--------------------------------------------------------------------------
69
+ | Class Methods
70
+ |--------------------------------------------------------------------------
71
+ */
72
+
73
+ /**
74
+ * Class constructor.
75
+ *
76
+ * @since 3.0.0
77
+ * @access public
78
+ *
79
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
80
+ * @param Plugin_Constants $constants Plugin constants object.
81
+ * @param Helper_Functions $helper_functions Helper functions object.
82
+ */
83
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
84
+
85
+ $this->_constants = $constants;
86
+ $this->_helper_functions = $helper_functions;
87
+
88
+ $main_plugin->add_to_all_plugin_models( $this );
89
+ $main_plugin->add_to_public_models( $this );
90
+
91
+ }
92
+
93
+ /**
94
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
95
+ *
96
+ * @since 3.0.0
97
+ * @access public
98
+ *
99
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
100
+ * @param Plugin_Constants $constants Plugin constants object.
101
+ * @param Helper_Functions $helper_functions Helper functions object.
102
+ * @return Link_Fixer
103
+ */
104
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
105
+
106
+ if ( !self::$_instance instanceof self )
107
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
108
+
109
+ return self::$_instance;
110
+
111
+ }
112
+
113
+ /**
114
+ * Get data of links to be fixed.
115
+ *
116
+ * @since 3.0.0
117
+ * @access public
118
+ *
119
+ * @param array $links List of affiliate links to fix.
120
+ * @param int $post_id ID of the post currently being viewed.
121
+ * @param array $data Affiliate Links data.
122
+ * @return array Affiliate Links data.
123
+ */
124
+ public function get_link_fixer_data( $links , $post_id = 0 , $data = array() ) {
125
+
126
+ if ( empty( $links ) )
127
+ return $data;
128
+
129
+ foreach( $links as $link ) {
130
+
131
+ $href = esc_url_raw( $link[ 'href' ] );
132
+ $class = sanitize_text_field( $link[ 'class' ] );
133
+ $key = (int) sanitize_text_field( $link[ 'key' ] );
134
+ $content = intval( $link[ 'is_image' ] ) ? '{image_placeholder}' : $link[ 'content' ];
135
+ $link_id = url_to_postid( $href );
136
+
137
+ $thirstylink = new Affiliate_Link( $link_id );
138
+
139
+ // if ( $thirstylink->get_prop( 'status' ) != 'publish' )
140
+ // continue;
141
+
142
+ $class .= ( get_option( 'ta_disable_thirsty_link_class' ) !== "yes" && strpos( $class , 'thirstylink' ) === false ) ? ' thirstylink' : '';
143
+ $nofollow = $thirstylink->get_prop( 'no_follow' ) == 'global' ? get_option( 'ta_no_follow' ) : $thirstylink->get_prop( 'no_follow' );
144
+ $new_window = $thirstylink->get_prop( 'new_window' ) == 'global' ? get_option( 'ta_new_window' ) : $thirstylink->get_prop( 'new_window' );
145
+ $href = ( $this->_helper_functions->is_uncloak_link( $thirstylink ) ) ? $thirstylink->get_prop( 'destination_url' ) : $thirstylink->get_prop( 'permalink' );
146
+ $rel = $nofollow == "yes" ? 'nofollow' : '';
147
+ $rel .= ' ' . $thirstylink->get_prop( 'rel_tags' );
148
+ $target = $new_window == "yes" ? '_blank' : '';
149
+ $title = ( get_option( 'ta_disable_title_attribute' ) != 'yes' ) ? 'title="' . esc_attr( str_replace( '"' , '' , $thirstylink->get_prop( 'name' ) ) ) . '" ' : '';
150
+ $other_atts = apply_filters( 'ta_link_insert_extend_data_attributes' , array() , $thirstylink , $post_id );
151
+ $other_atts_string = '';
152
+
153
+ if ( is_array( $other_atts ) && ! empty( $other_atts ) ) {
154
+
155
+ foreach ( $other_atts as $att => $att_value )
156
+ $other_atts_string .= $att . '="' . esc_attr( $att_value ) . '" ';
157
+ }
158
+
159
+ $html = '<a class="' . esc_attr( $class ) . '" ' . $title .
160
+ 'href="' . esc_url( $href ) . '" ' .
161
+ 'rel="' . esc_attr( trim( $rel ) ) . '" ' .
162
+ 'target="' . esc_attr( $target ) . '" ' .
163
+ 'data-linkid="' . esc_attr( $link_id ) . '" ' . $other_atts_string . '>' . $content . '</a>';
164
+
165
+ $data[] = array(
166
+ 'key' => $key,
167
+ 'html' => $html,
168
+ 'link_id' => $link_id,
169
+ 'is_image' => intval( $link[ 'is_image' ] )
170
+ );
171
+ }
172
+
173
+ return $data;
174
+ }
175
+
176
+ /**
177
+ * Ajax link fixer.
178
+ *
179
+ * @since 3.0.0
180
+ * @access public
181
+ */
182
+ public function ajax_link_fixer() {
183
+
184
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
185
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
186
+ elseif ( ! isset( $_POST[ 'hrefs' ] ) || empty( $_POST[ 'hrefs' ] ) )
187
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
188
+ else {
189
+
190
+ $links = $_POST[ 'hrefs' ];
191
+ $post_id = isset( $_POST[ 'post_id' ] ) ? intval( $_POST[ 'post_id' ] ) : 0;
192
+ $response = array(
193
+ 'status' => 'success',
194
+ 'data' => $this->get_link_fixer_data( $links , $post_id )
195
+ );
196
+ }
197
+
198
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
199
+ echo wp_json_encode( $response );
200
+ wp_die();
201
+ }
202
+
203
+
204
+
205
+
206
+ /*
207
+ |--------------------------------------------------------------------------
208
+ | Fulfill implemented interface contracts
209
+ |--------------------------------------------------------------------------
210
+ */
211
+
212
+ /**
213
+ * Execute codes that needs to run on plugin initialization.
214
+ *
215
+ * @since 3.0.0
216
+ * @access public
217
+ * @implements ThirstyAffiliates\Interfaces\Initiable_Interface
218
+ */
219
+ public function initialize() {
220
+
221
+ add_action( 'wp_ajax_ta_link_fixer' , array( $this , 'ajax_link_fixer' ) );
222
+ add_action( 'wp_ajax_nopriv_ta_link_fixer' , array( $this , 'ajax_link_fixer' ) );
223
+ }
224
+
225
+ /**
226
+ * Execute link picker.
227
+ *
228
+ * @since 3.0.0
229
+ * @access public
230
+ */
231
+ public function run() {
232
+ }
233
+ }
Models/Link_Picker.php ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+
9
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
10
+ use ThirstyAffiliates\Helpers\Helper_Functions;
11
+
12
+ use ThirstyAffiliates\Models\Affiliate_Link;
13
+
14
+ /**
15
+ * Model that houses the link picker logic.
16
+ *
17
+ * @since 3.0.0
18
+ */
19
+ class Link_Picker implements Model_Interface {
20
+
21
+ /*
22
+ |--------------------------------------------------------------------------
23
+ | Class Properties
24
+ |--------------------------------------------------------------------------
25
+ */
26
+
27
+ /**
28
+ * Property that holds the single main instance of Bootstrap.
29
+ *
30
+ * @since 3.0.0
31
+ * @access private
32
+ * @var Link_Picker
33
+ */
34
+ private static $_instance;
35
+
36
+ /**
37
+ * Model that houses the main plugin object.
38
+ *
39
+ * @since 3.0.0
40
+ * @access private
41
+ * @var Abstract_Main_Plugin_Class
42
+ */
43
+ private $_main_plugin;
44
+
45
+ /**
46
+ * Model that houses all the plugin constants.
47
+ *
48
+ * @since 3.0.0
49
+ * @access private
50
+ * @var Plugin_Constants
51
+ */
52
+ private $_constants;
53
+
54
+ /**
55
+ * Property that houses all the helper functions of the plugin.
56
+ *
57
+ * @since 3.0.0
58
+ * @access private
59
+ * @var Helper_Functions
60
+ */
61
+ private $_helper_functions;
62
+
63
+
64
+
65
+
66
+ /*
67
+ |--------------------------------------------------------------------------
68
+ | Class Methods
69
+ |--------------------------------------------------------------------------
70
+ */
71
+
72
+ /**
73
+ * Class constructor.
74
+ *
75
+ * @since 3.0.0
76
+ * @access public
77
+ *
78
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
79
+ * @param Plugin_Constants $constants Plugin constants object.
80
+ * @param Helper_Functions $helper_functions Helper functions object.
81
+ */
82
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
83
+
84
+ $this->_constants = $constants;
85
+ $this->_helper_functions = $helper_functions;
86
+
87
+ $main_plugin->add_to_all_plugin_models( $this );
88
+
89
+ }
90
+
91
+ /**
92
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
93
+ *
94
+ * @since 3.0.0
95
+ * @access public
96
+ *
97
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
98
+ * @param Plugin_Constants $constants Plugin constants object.
99
+ * @param Helper_Functions $helper_functions Helper functions object.
100
+ * @return Link_Picker
101
+ */
102
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
103
+
104
+ if ( !self::$_instance instanceof self )
105
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
106
+
107
+ return self::$_instance;
108
+
109
+ }
110
+
111
+
112
+
113
+ /*
114
+ |--------------------------------------------------------------------------
115
+ | Register tinymce buttons and scripts
116
+ |--------------------------------------------------------------------------
117
+ */
118
+
119
+ /**
120
+ * Initialize thirsty editor buttons.
121
+ *
122
+ * @since 3.0.0
123
+ * @access public
124
+ */
125
+ public function init_thirsty_editor_buttons() {
126
+
127
+ if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( 'edit_pages' ) )
128
+ return;
129
+
130
+ if ( get_option( 'ta_disable_visual_editor_buttons' ) == 'yes' || get_user_option( 'rich_editing' ) != 'true' )
131
+ return;
132
+
133
+ add_filter( 'mce_external_plugins' , array( $this , 'load_thirsty_mce_plugin' ) );
134
+ add_filter( 'mce_buttons' , array( $this , 'register_mce_buttons' ) , 5 );
135
+
136
+ }
137
+
138
+ /**
139
+ * Load Thirsty Affiliate MCE plugin to TinyMCE.
140
+ *
141
+ * @since 3.0.0
142
+ * @access public
143
+ *
144
+ * @param array $mce_plugins Array of all MCE plugins.
145
+ * @return array
146
+ */
147
+ public function load_thirsty_mce_plugin( $mce_plugins ) {
148
+
149
+ $mce_plugins[ 'thirstyaffiliates' ] = $this->_constants->JS_ROOT_URL() . 'lib/thirstymce/editor-plugin.js';
150
+
151
+ return $mce_plugins;
152
+ }
153
+
154
+ /**
155
+ * Register Thirsty Affiliate MCE buttons.
156
+ *
157
+ * @since 3.0.0
158
+ * @access public
159
+ *
160
+ * @param array $buttons Array of all MCE buttons.
161
+ * @return array
162
+ */
163
+ public function register_mce_buttons( $buttons ) {
164
+
165
+ array_push( $buttons , 'separator' , 'thirstyaffiliates_button' );
166
+ array_push( $buttons , 'separator' , 'thirstyaffiliates_quickaddlink_button' );
167
+
168
+ return $buttons;
169
+ }
170
+
171
+
172
+
173
+
174
+ /*
175
+ |--------------------------------------------------------------------------
176
+ | Link Picker methods
177
+ |--------------------------------------------------------------------------
178
+ */
179
+
180
+ /**
181
+ * Return
182
+ *
183
+ * @since 3.0.0
184
+ * @access public
185
+ *
186
+ * @param array $affiliate_links List of affiliate link IDs.
187
+ * @param bool $advanced Boolean check if its advanced or not.
188
+ * @param int $post_id ID of the post currently being edited.
189
+ * @param string $result_markup Search Affiliate Links result markup.
190
+ * @return Search Affiliate Links result markup
191
+ */
192
+ public function search_affiliate_links_result_markup( $affiliate_links , $advance = false , $post_id = 0 , $result_markup = '' ) {
193
+
194
+ if ( is_array( $affiliate_links ) && ! empty( $affiliate_links ) ) {
195
+
196
+ foreach( $affiliate_links as $link_id ) {
197
+
198
+ $thirstylink = new Affiliate_Link( $link_id );
199
+ $nofollow = $thirstylink->get_prop( 'no_follow' ) == 'global' ? get_option( 'ta_no_follow' ) : $thirstylink->get_prop( 'no_follow' );
200
+ $new_window = $thirstylink->get_prop( 'new_window' ) == 'global' ? get_option( 'ta_new_window' ) : $thirstylink->get_prop( 'new_window' );
201
+ $rel = $nofollow == 'yes' ? 'nofollow' : '';
202
+ $rel .= ' ' . $thirstylink->get_prop( 'rel_tags' );
203
+ $target = $new_window == 'yes' ? '_blank' : '';
204
+ $class = ( get_option( 'ta_disable_thirsty_link_class' ) !== "yes" ) ? 'thirstylink' : '';
205
+ $title = ( get_option( 'ta_disable_title_attribute' ) !== "yes" ) ? $thirstylink->get_prop( 'name' ) : '';
206
+ $other_atts = esc_attr( json_encode( apply_filters( 'ta_link_insert_extend_data_attributes' , array() , $thirstylink , $post_id ) ) );
207
+
208
+
209
+ if ( $advance ) {
210
+
211
+ $images = $thirstylink->get_prop( 'image_ids' );
212
+ $images_markup = '<span class="images-block">';
213
+
214
+ if ( is_array( $images ) && ! empty( $images ) ) {
215
+
216
+ $images_markup .= '<span class="label">' . __( 'Select image:' , 'thirstyaffiliates' ) . '</span>';
217
+ $images_markup .= '<span class="images">';
218
+
219
+ foreach( $images as $image )
220
+ $images_markup .= wp_get_attachment_image( $image , array( 75 , 75 ) , false , array( 'data-imgid' => $image , 'data-type' => 'image' ) );
221
+
222
+ $images_markup .= '</span>';
223
+ } else {
224
+
225
+ $images_markup .= '<span class="no-images">' . __( 'No images found' , 'thirstyaffiliates' ) . '</span>';
226
+ }
227
+
228
+ $images_markup .= '</span>';
229
+
230
+ $result_markup .= '<li class="thirstylink"
231
+ data-linkid="' . $thirstylink->get_id() . '"
232
+ data-class="' . esc_attr( $class ) . '"
233
+ data-title="' . esc_attr( str_replace( '"' , '' , $title ) ) . '"
234
+ data-href="' . esc_url( $thirstylink->get_prop( 'permalink' ) ) . '"
235
+ data-rel="' . trim( esc_attr( $rel ) ) . '"
236
+ data-target="' . esc_attr( $target ) . '"
237
+ data-other-atts="' . esc_attr( $other_atts ) . '">
238
+ <span class="name">' . $thirstylink->get_prop( 'name' ) . '</span>
239
+ <span class="slug">[' . $thirstylink->get_prop( 'slug' ) . ']</span>
240
+ <span class="actions">
241
+ <button type="button" data-type="normal" class="button insert-link-button dashicons dashicons-admin-links" data-tip="' . __( 'Insert link' , 'thirstyaffiliates' ) . '"></button>
242
+ <button type="button" data-type="shortcode" class="button insert-shortcode-button dashicons dashicons-editor-code" data-tip="' . __( 'Insert shortcode' , 'thirstyaffiliates' ) . '"></button>
243
+ <button type="button" data-type="image" class="button insert-image-button dashicons dashicons-format-image" data-tip="' . __( 'Insert image' , 'thirstyaffiliates' ) . '"></button>
244
+ </span>
245
+ ' . $images_markup . '
246
+ </li>';
247
+ } else {
248
+
249
+ $result_markup .= '<li data-class="' . esc_attr( $class ) . '"
250
+ data-title="' . esc_attr( str_replace( '"' , '' , $title ) ) . '"
251
+ data-href="' . esc_attr( $thirstylink->get_prop( 'permalink' ) ) . '"
252
+ data-rel="' . esc_attr( $rel ) . '"
253
+ data-target="' . esc_attr( $target ) . '"
254
+ data-link-id="' . esc_attr( $thirstylink->get_id() ) . '"
255
+ data-link-insertion-type="' . esc_attr( get_option( 'ta_link_insertion_type' , 'link' ) ) . '"
256
+ data-other-atts="' . $other_atts . '">';
257
+ $result_markup .= '<strong>' . $link_id . '</strong> : <span>' . $thirstylink->get_prop( 'name' ) . '</span></li>';
258
+
259
+ }
260
+
261
+ }
262
+
263
+ } else
264
+ $result_markup .= '<li class="no-links-found">' . __( 'No affiliate links found' , 'thirstyaffiliates' ) . '</li>';
265
+
266
+ return $result_markup;
267
+ }
268
+
269
+ /**
270
+ * Search Affiliate Links Query AJAX function
271
+ *
272
+ * @since 3.0.0
273
+ * @access public
274
+ */
275
+ public function ajax_search_affiliate_links_query() {
276
+
277
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
278
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
279
+ elseif ( ! isset( $_POST[ 'keyword' ] ) )
280
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
281
+ else {
282
+
283
+ $paged = ( isset( $_POST[ 'paged' ] ) && $_POST[ 'paged' ] ) ? $_POST[ 'paged' ] : 1;
284
+ $exclude = ( isset( $_POST[ 'exclude' ] ) && is_array( $_POST[ 'exclude' ] ) && ! empty( $_POST[ 'exclude' ] ) ) ? $_POST[ 'exclude' ] : array();
285
+ $affiliate_links = $this->_helper_functions->search_affiliate_links_query( $_POST[ 'keyword' ] , $paged , '' , $exclude );
286
+ $advance = ( isset( $_POST[ 'advance' ] ) && $_POST[ 'advance' ] ) ? true : false;
287
+ $post_id = isset( $_POST[ 'post_id' ] ) ? intval( $_POST[ 'post_id' ] ) : 0;
288
+ $result_markup = $this->search_affiliate_links_result_markup( $affiliate_links , $advance , $post_id );
289
+
290
+ $response = array( 'status' => 'success' , 'search_query_markup' => $result_markup , 'count' => count( $affiliate_links ) );
291
+ }
292
+
293
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
294
+ echo wp_json_encode( $response );
295
+ wp_die();
296
+ }
297
+
298
+ /**
299
+ * AJAX function to display the advance add affiliate link thickbox content.
300
+ *
301
+ * @since 3.0.0
302
+ * @access public
303
+ */
304
+ public function ajax_display_advanced_add_affiliate_link() {
305
+
306
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || ! current_user_can( apply_filters( 'ta_ajax_access_capability' , 'edit_posts' ) ) )
307
+ wp_die();
308
+
309
+ $post_id = isset( $_REQUEST[ 'post_id' ] ) ? intval( $_REQUEST[ 'post_id' ] ) : 0;
310
+ $affiliate_links = $this->_helper_functions->search_affiliate_links_query();
311
+ $result_markup = $this->search_affiliate_links_result_markup( $affiliate_links , true , $post_id );
312
+ $html_editor = isset( $_REQUEST[ 'html_editor' ] ) ? sanitize_text_field( $_REQUEST[ 'html_editor' ] ) : false;
313
+
314
+ wp_enqueue_script('editor');
315
+ wp_dequeue_script('jquery-ui-sortable');
316
+ wp_dequeue_script('admin-scripts');
317
+ wp_enqueue_style( 'jquery_tiptip' , $this->_constants->CSS_ROOT_URL() . 'lib/jquery-tiptip/jquery-tiptip.css' , array() , $this->_constants->VERSION() , 'all' );
318
+ wp_enqueue_style( 'ta_advance_link_picker_css' , $this->_constants->JS_ROOT_URL() . 'app/advance_link_picker/dist/advance-link-picker.css' , array( 'dashicons' ) , $this->_constants->VERSION() , 'all' );
319
+ wp_enqueue_script( 'jquery_tiptip' , $this->_constants->JS_ROOT_URL() . 'lib/jquery-tiptip/jquery.tipTip.min.js' , array() , $this->_constants->VERSION() , true );
320
+ wp_enqueue_script( 'ta_advance_link_picker_js' , $this->_constants->JS_ROOT_URL() . 'app/advance_link_picker/dist/advance-link-picker.js' , array( 'jquery_tiptip' ) , $this->_constants->VERSION() , true );
321
+
322
+ include( $this->_constants->VIEWS_ROOT_PATH() . 'linkpicker/advance-link-picker.php' );
323
+
324
+ wp_die();
325
+ }
326
+
327
+ /**
328
+ * Get image markup by ID.
329
+ *
330
+ * @since 3.0.0
331
+ * @access public
332
+ */
333
+ public function ajax_get_image_markup_by_id() {
334
+
335
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
336
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
337
+ elseif ( ! isset( $_REQUEST[ 'imgid' ] ) )
338
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
339
+ else {
340
+
341
+ $image_id = (int) sanitize_text_field( $_REQUEST[ 'imgid' ] );
342
+ $image_markup = wp_get_attachment_image( $image_id , 'full' );
343
+
344
+ $response = array( 'status' => 'success' , 'image_markup' => $image_markup );
345
+ }
346
+
347
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
348
+ echo wp_json_encode( $response );
349
+ wp_die();
350
+ }
351
+
352
+
353
+
354
+
355
+
356
+ /*
357
+ |--------------------------------------------------------------------------
358
+ | Quick Add Affiliate Link methods
359
+ |--------------------------------------------------------------------------
360
+ */
361
+
362
+ /**
363
+ * Display the quick add affiliate link content on the thickbox popup.
364
+ *
365
+ * @since 3.0.0
366
+ * @access public
367
+ */
368
+ public function ajax_display_quick_add_affiliate_link_thickbox() {
369
+
370
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX || ! current_user_can( apply_filters( 'ta_ajax_access_capability' , 'edit_posts' ) ) )
371
+ wp_die();
372
+
373
+ $post_id = isset( $_REQUEST[ 'post_id' ] ) ? intval( $_REQUEST[ 'post_id' ] ) : 0;
374
+ $redirect_types = $this->_constants->REDIRECT_TYPES();
375
+ $selection = sanitize_text_field( $_REQUEST[ 'selection' ] );
376
+ $default_redirect_type = get_option( 'ta_link_redirect_type' , '301' );
377
+ $global_no_follow = get_option( 'ta_no_follow' ) == 'yes' ? 'yes' : 'no';
378
+ $global_new_window = get_option( 'ta_new_window' ) == 'yes' ? 'yes' : 'no';
379
+ $html_editor = isset( $_REQUEST[ 'html_editor' ] ) ? sanitize_text_field( $_REQUEST[ 'html_editor' ] ) : false;
380
+
381
+ wp_enqueue_script('editor');
382
+ wp_dequeue_script('jquery-ui-sortable');
383
+ wp_dequeue_script('admin-scripts');
384
+ wp_enqueue_script( 'ta_quick_add_affiliate_link_js' , $this->_constants->JS_ROOT_URL() . 'app/quick_add_affiliate_link/dist/quick-add-affiliate-link.js' , array() , $this->_constants->VERSION() , true );
385
+ wp_enqueue_style( 'ta_quick_add_affiliate_link_css' , $this->_constants->JS_ROOT_URL() . 'app/quick_add_affiliate_link/dist/quick-add-affiliate-link.css' , array( 'dashicons' ) , $this->_constants->VERSION() , 'all' );
386
+
387
+ include( $this->_constants->VIEWS_ROOT_PATH() . 'linkpicker/quick-add-affiliate-link.php' );
388
+
389
+ wp_die();
390
+
391
+ }
392
+
393
+ /**
394
+ * Process quick add affiliate link. Create Affiliate link post.
395
+ *
396
+ * @since 3.0.0
397
+ * @access public
398
+ */
399
+ public function process_quick_add_affiliate_link() {
400
+
401
+ $thirstylink = new Affiliate_Link();
402
+
403
+ // set Properties
404
+ $thirstylink->set_prop( 'name' , sanitize_text_field( $_POST[ 'ta_link_name' ] ) );
405
+ $thirstylink->set_prop( 'destination_url' , esc_url_raw( $_POST[ 'ta_destination_url' ] ) );
406
+ $thirstylink->set_prop( 'no_follow' , sanitize_text_field( $_POST[ 'ta_no_follow' ] ) );
407
+ $thirstylink->set_prop( 'new_window' , sanitize_text_field( $_POST[ 'ta_new_window' ] ) );
408
+ $thirstylink->set_prop( 'redirect_type' , sanitize_text_field( $_POST[ 'ta_redirect_type' ] ) );
409
+
410
+ add_action( 'ta_save_quick_add_affiliate_link' , $thirstylink );
411
+
412
+ // save affiliate link
413
+ $thirstylink->save();
414
+
415
+ return $thirstylink;
416
+ }
417
+
418
+ /**
419
+ * AJAX function to process quick add affiliate link.
420
+ *
421
+ * @since 3.0.0
422
+ * @access public
423
+ */
424
+ public function ajax_process_quick_add_affiliate_link() {
425
+
426
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
427
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
428
+ elseif ( ! isset( $_REQUEST[ 'ta_link_name' ] ) || ! isset( $_REQUEST[ 'ta_destination_url' ] ) || ! isset( $_REQUEST[ 'ta_redirect_type' ] ) )
429
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
430
+ else {
431
+
432
+ $thirstylink = $this->process_quick_add_affiliate_link();
433
+ $post_id = isset( $_POST[ 'post_id' ] ) ? intval( sanitize_text_field( $_POST[ 'post_id' ] ) ) : 0;
434
+ $nofollow = $thirstylink->get_prop( 'no_follow' ) == 'global' ? get_option( 'ta_no_follow' ) : $thirstylink->get_prop( 'no_follow' );
435
+ $new_window = $thirstylink->get_prop( 'new_window' ) == 'global' ? get_option( 'ta_new_window' ) : $thirstylink->get_prop( 'new_window' );
436
+ $rel = $nofollow == 'yes' ? 'nofollow' : '';
437
+ $rel .= ' ' . $thirstylink->get_prop( 'rel_tags' );
438
+ $target = $new_window == 'yes' ? '_blank' : '';
439
+ $class = ( get_option( 'ta_disable_thirsty_link_class' ) !== "yes" ) ? 'thirstylink' : '';
440
+ $title = ( get_option( 'ta_disable_title_attribute' ) !== "yes" ) ? $thirstylink->get_prop( 'name' ) : '';
441
+
442
+ $response = array(
443
+ 'status' => 'success',
444
+ 'link_id' => $thirstylink->get_id(),
445
+ 'content' => $thirstylink->get_prop( 'name' ),
446
+ 'href' => $thirstylink->get_prop( 'permalink' ),
447
+ 'class' => $class,
448
+ 'title' => str_replace( '"' , '' , $title ),
449
+ 'rel' => $rel,
450
+ 'target' => $target,
451
+ 'link_insertion_type' => get_option( 'ta_link_insertion_type' , 'link' ),
452
+ 'other_atts' => apply_filters( 'ta_link_insert_extend_data_attributes' , array() , $thirstylink , $post_id )
453
+ );
454
+
455
+ }
456
+
457
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
458
+ echo wp_json_encode( $response );
459
+ wp_die();
460
+ }
461
+
462
+ /**
463
+ * Execute link picker.
464
+ *
465
+ * @since 3.0.0
466
+ * @access public
467
+ */
468
+ public function run() {
469
+
470
+ // TinyMCE buttons
471
+ add_action( 'init' , array( $this , 'init_thirsty_editor_buttons' ) );
472
+
473
+ // Advanced Link Picker hooks
474
+ add_action( 'wp_ajax_search_affiliate_links_query' , array( $this , 'ajax_search_affiliate_links_query' ) );
475
+ add_action( 'wp_ajax_ta_advanced_add_affiliate_link' , array( $this , 'ajax_display_advanced_add_affiliate_link' ) );
476
+ add_action( 'wp_ajax_ta_get_image_markup_by_id' , array( $this , 'ajax_get_image_markup_by_id' ) );
477
+
478
+ // Quick Add Affiliate Link hooks
479
+ add_action( 'wp_ajax_ta_quick_add_affiliate_link_thickbox' , array( $this , 'ajax_display_quick_add_affiliate_link_thickbox' ) );
480
+ add_action( 'wp_ajax_ta_process_quick_add_affiliate_link' , array( $this , 'ajax_process_quick_add_affiliate_link' ) );
481
+
482
+ }
483
+ }
Models/Marketing.php ADDED
@@ -0,0 +1,403 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+ use ThirstyAffiliates\Interfaces\Activatable_Interface;
9
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
10
+
11
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
12
+ use ThirstyAffiliates\Helpers\Helper_Functions;
13
+
14
+ /**
15
+ * Model that houses the logic of Marketing of old versions of TA to version 3.0.0
16
+ *
17
+ * @since 3.0.0
18
+ */
19
+ class Marketing implements Model_Interface , Activatable_Interface , Initiable_Interface {
20
+
21
+ /*
22
+ |--------------------------------------------------------------------------
23
+ | Class Properties
24
+ |--------------------------------------------------------------------------
25
+ */
26
+
27
+ /**
28
+ * Property that holds the single main instance of Marketing.
29
+ *
30
+ * @since 3.0.0
31
+ * @access private
32
+ * @var Redirection
33
+ */
34
+ private static $_instance;
35
+
36
+ /**
37
+ * Model that houses the main plugin object.
38
+ *
39
+ * @since 3.0.0
40
+ * @access private
41
+ * @var Redirection
42
+ */
43
+ private $_main_plugin;
44
+
45
+ /**
46
+ * Model that houses all the plugin constants.
47
+ *
48
+ * @since 3.0.0
49
+ * @access private
50
+ * @var Plugin_Constants
51
+ */
52
+ private $_constants;
53
+
54
+ /**
55
+ * Property that houses all the helper functions of the plugin.
56
+ *
57
+ * @since 3.0.0
58
+ * @access private
59
+ * @var Helper_Functions
60
+ */
61
+ private $_helper_functions;
62
+
63
+ /**
64
+ * Property that holds the list of all affiliate links.
65
+ *
66
+ * @since 3.0.0
67
+ * @access private
68
+ * @var array
69
+ */
70
+ private $_all_affiliate_links;
71
+
72
+ /**
73
+ * Variable that holds the mapping between options from old version of the plugin to the new version of the plugin.
74
+ *
75
+ * @since 3.0.0
76
+ * @access public
77
+ * @var array
78
+ */
79
+ private $_old_new_options_mapping;
80
+
81
+ /**
82
+ * Variable that holds the mapping between post meta from old version of the plugin to the new version of the plugin.
83
+ *
84
+ * @since 3.0.0
85
+ * @access public
86
+ * @var array
87
+ */
88
+ private $_old_new_meta_mapping;
89
+
90
+
91
+
92
+
93
+ /*
94
+ |--------------------------------------------------------------------------
95
+ | Class Methods
96
+ |--------------------------------------------------------------------------
97
+ */
98
+
99
+ /**
100
+ * Class constructor.
101
+ *
102
+ * @since 3.0.0
103
+ * @access public
104
+ *
105
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
106
+ * @param Plugin_Constants $constants Plugin constants object.
107
+ * @param Helper_Functions $helper_functions Helper functions object.
108
+ */
109
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
110
+
111
+ $this->_constants = $constants;
112
+ $this->_helper_functions = $helper_functions;
113
+
114
+ $main_plugin->add_to_all_plugin_models( $this );
115
+
116
+ }
117
+
118
+ /**
119
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
120
+ *
121
+ * @since 3.0.0
122
+ * @access public
123
+ *
124
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
125
+ * @param Plugin_Constants $constants Plugin constants object.
126
+ * @param Helper_Functions $helper_functions Helper functions object.
127
+ * @return Redirection
128
+ */
129
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
130
+
131
+ if ( !self::$_instance instanceof self )
132
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
133
+
134
+ return self::$_instance;
135
+
136
+ }
137
+
138
+ /**
139
+ * Flag to show review request.
140
+ *
141
+ * @since 3.0.0
142
+ * @access public
143
+ */
144
+ public function flag_show_review_request() {
145
+
146
+ update_option( Plugin_Constants::SHOW_REQUEST_REVIEW , 'yes' );
147
+
148
+ }
149
+
150
+ /**
151
+ * Flag to show TA Pro notice.
152
+ *
153
+ * @since 3.0.0
154
+ * @access public
155
+ */
156
+ public function flag_show_tapro_notice() {
157
+
158
+ // prevent the notice showing up again when the plugin is deactivated/activated.
159
+ if ( get_option( Plugin_Constants::SHOW_TAPRO_NOTICE ) )
160
+ return;
161
+
162
+ update_option( Plugin_Constants::SHOW_TAPRO_NOTICE , 'yes' );
163
+
164
+ }
165
+
166
+ /**
167
+ * Record the user's review request response.
168
+ *
169
+ * @since 3.0.0
170
+ * @access public
171
+ */
172
+ public function ajax_request_review_response() {
173
+
174
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
175
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'rwcdplm' ) );
176
+ elseif ( !isset( $_POST[ 'review_request_response' ] ) )
177
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Required parameter not passed' , 'rwcdplm' ) );
178
+ else {
179
+
180
+ update_option( Plugin_Constants::REVIEW_REQUEST_RESPONSE , $_POST[ 'review_request_response' ] );
181
+
182
+ if ( $_POST[ 'review_request_response' ] === 'review-later' )
183
+ wp_schedule_single_event( time() + 1209600 , Plugin_Constants::CRON_REQUEST_REVIEW );
184
+
185
+ delete_option( Plugin_Constants::SHOW_REQUEST_REVIEW );
186
+
187
+ $response = array( 'status' => 'success' , 'success_msg' => __( 'Review request response saved' , 'rwcdplm' ) );
188
+
189
+ }
190
+
191
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
192
+ echo wp_json_encode( $response );
193
+ wp_die();
194
+
195
+ }
196
+
197
+ /**
198
+ * Display the review request admin notice.
199
+ *
200
+ * @since 3.0.0
201
+ * @access public
202
+ */
203
+ public function show_review_request_notice() {
204
+
205
+ $screen = get_current_screen();
206
+
207
+ $post_type = get_post_type();
208
+ if ( !$post_type && isset( $_GET[ 'post_type' ] ) )
209
+ $post_type = $_GET[ 'post_type' ];
210
+
211
+ $review_request_response = get_option( Plugin_Constants::REVIEW_REQUEST_RESPONSE );
212
+
213
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) || $post_type !== Plugin_Constants::AFFILIATE_LINKS_CPT || get_option( Plugin_Constants::SHOW_REQUEST_REVIEW ) !== 'yes' || ( $review_request_response !== 'review-later' && ! empty( $review_request_response ) ) )
214
+ return;
215
+
216
+ if ( $this->_helper_functions->is_plugin_active( 'thirstyaffiliates-pro/thirstyaffiliates-pro.php' ) ) {
217
+
218
+ $msg = sprintf( __( '<p>We see you have been using ThirstyAffiliates for a couple of weeks now – thank you once again for your purchase and we hope you are enjoying it so far!</p>
219
+ <p>We\'d really appreciate it if you could take a few minutes to write a 5-star review of our free plugin on WordPress.org!</p>
220
+ <p>Your comment will go a long way to helping us grow and giving new users the confidence to give us a try.</p>
221
+ <p>Thanks in advance, we are looking forward to reading it!</p>
222
+ <p>PS. If you ever need support, please just <a href="%1$s" target="_blank">get in touch here.</a></p>' , "thirstyaffiliates" ) , 'https://goo.gl/SsDbYD' );
223
+
224
+ } else {
225
+
226
+ $msg = __( "<p>Thanks for using our free ThirstyAffiliates plugin – we hope you are enjoying it so far.</p>
227
+ <p>We’d really appreciate it if you could take a few minutes to write a 5-star review of our plugin on WordPress.org!</p>
228
+ <p>Your comment will go a long way to helping us grow and giving new users the confidence to give us a try.</p>
229
+ <p>Thanks in advance, we are looking forward to reading it!</p>" , "thirstyaffiliates" );
230
+
231
+ } ?>
232
+ <div class="ta-review-request notice notice-info">
233
+
234
+ <div style="padding: 4px 0;">
235
+ <a href="https://thirstyaffiliates.com/" target="_blank"><img src="<?php echo $this->_constants->IMAGES_ROOT_URL() . 'admin-review-notice-logo.png'; ?>"></a>
236
+ </div>
237
+
238
+ <?php echo $msg; ?>
239
+
240
+ <p class="actions">
241
+ <a href="#" class="button" data-response="never-show"><?php _e( 'Don\'t show again' , 'thirstyaffiliates' ); ?></a>
242
+ <a href="#" class="button" data-response="review-later"><?php _e( 'Review later' , 'thirstyaffiliates' ); ?></a>
243
+ <a href="https://goo.gl/RAsxVu" class="button button-primary" data-response="review"><?php _e( 'Review' , 'thirstyaffiliates' ); ?></a>
244
+ </p>
245
+ </div>
246
+ <?php
247
+ }
248
+
249
+ /**
250
+ * Display the TA Pro promotional admin notice.
251
+ *
252
+ * @since 3.0.0
253
+ * @access public
254
+ */
255
+ public function show_tapro_admin_notice() {
256
+
257
+ $post_type = get_post_type();
258
+ if ( !$post_type && isset( $_GET[ 'post_type' ] ) )
259
+ $post_type = $_GET[ 'post_type' ];
260
+
261
+ if ( ! is_admin() || ! current_user_can( 'manage_options' ) || $post_type !== Plugin_Constants::AFFILIATE_LINKS_CPT || get_option( Plugin_Constants::SHOW_TAPRO_NOTICE ) !== 'yes' || $this->_helper_functions->is_plugin_active( 'thirstyaffiliates-pro/thirstyaffiliates-pro.php' ) )
262
+ return;
263
+
264
+ $tapro_url = esc_url( 'https://thirstyaffiliates.com/pricing/?utm_source=Free%20Plugin&utm_medium=Pro&utm_campaign=Admin%20Notice' ); ?>
265
+ <div class="notice notice-error is-dismissible ta_tapro_admin_notice">
266
+ <?php
267
+ echo sprintf( __( '<h4>Hi there, we hope you\'re enjoying ThirstyAffiliates!</h4>
268
+ <p>Did you know we also have a Pro addon that can help you:</p>
269
+ <ul><li>Automatically link up affiliate links to keywords throughout your site (monetize your site faster!)</li>
270
+ <li>Give you more amazing advanced reports (see what is working and what is not!)</li>
271
+ <li>Let you link to different places depending on the visitor\'s country (geolocation links)</li>
272
+ <li>Let you import Amazon products as links (+ CSV import/export and more premium importing options)</li>
273
+ <li>... plus a whole lot more!</li></ul>
274
+ <p><a href="%s" target="_blank">Check out the ThristyAffiliates Pro features here →</a></p>' , 'thirstyaffiliates' ) , $tapro_url );
275
+ ?>
276
+ </div>
277
+
278
+ <script>
279
+ ( function( $ ) {
280
+ $( '.ta_tapro_admin_notice' ).on( 'click' , '.notice-dismiss' , function() {
281
+ $.ajax( ajaxurl , {
282
+ type: 'POST',
283
+ data: { action: 'ta_dismiss_tapro_admin_notice' }
284
+ } );
285
+ } );
286
+ } )( jQuery );
287
+ </script>
288
+ <?php
289
+ }
290
+
291
+ /**
292
+ * Set SHOW_TAPRO_NOTICE option to "no" when the TA Pro admin notice is dismissed.
293
+ *
294
+ * @since 3.0.0
295
+ * @access public
296
+ */
297
+ public function ajax_dismiss_tapro_admin_notice() {
298
+
299
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
300
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'rwcdplm' ) );
301
+ else {
302
+
303
+ update_option( Plugin_Constants::SHOW_TAPRO_NOTICE , 'no' );
304
+ $response = array( 'status' => 'success' );
305
+ }
306
+
307
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
308
+ echo wp_json_encode( $response );
309
+ wp_die();
310
+ }
311
+
312
+ /**
313
+ * Add the Pro Features menu link
314
+ *
315
+ * @since 3.0.0
316
+ * @access public
317
+ */
318
+ public function add_pro_features_menu_link() {
319
+
320
+ if ( !is_plugin_active( 'thirstyaffiliates-pro/thirstyaffiliates-pro.php' ) ) {
321
+
322
+ global $submenu;
323
+
324
+ array_push( $submenu['edit.php?post_type=thirstylink'] , array( '<div id="spfmlt">Pro Features →</div>' , 'manage_options', 'https://thirstyaffiliates.com/pricing/?utm_source=Free%20Plugin&utm_medium=Pro&utm_campaign=Admin%20Menu' ) );
325
+
326
+ }
327
+
328
+ }
329
+
330
+ /**
331
+ * Add the Pro Features menu link target
332
+ *
333
+ * @since 3.0.0
334
+ * @access public
335
+ */
336
+ public function add_pro_features_menu_link_target() {
337
+
338
+ ?>
339
+ <script type="text/javascript">
340
+ jQuery(document).ready( function($) {
341
+ $( '#spfmlt' ).parent().attr( 'target' , '_blank' );
342
+ });
343
+ </script>
344
+ <?php
345
+
346
+ }
347
+
348
+
349
+
350
+
351
+ /*
352
+ |--------------------------------------------------------------------------
353
+ | Fulfill Implemented Interface Contracts
354
+ |--------------------------------------------------------------------------
355
+ */
356
+
357
+ /**
358
+ * Execute codes that needs to run plugin activation.
359
+ *
360
+ * @since 3.0.0
361
+ * @access public
362
+ * @implements ThirstyAffiliates\Interfaces\Activatable_Interface
363
+ */
364
+ public function activate() {
365
+
366
+ wp_schedule_single_event( time() + 1209600 , Plugin_Constants::CRON_REQUEST_REVIEW );
367
+ wp_schedule_single_event( time() + 172800 , Plugin_Constants::CRON_TAPRO_NOTICE );
368
+
369
+ }
370
+
371
+ /**
372
+ * Execute codes that needs to run on plugin initialization.
373
+ *
374
+ * @since 3.0.0
375
+ * @access public
376
+ * @implements ThirstyAffiliates\Interfaces\Initiable_Interface
377
+ */
378
+ public function initialize() {
379
+
380
+ add_action( 'wp_ajax_ta_request_review_response' , array( $this , 'ajax_request_review_response' ) );
381
+ add_action( 'wp_ajax_ta_dismiss_tapro_admin_notice' , array( $this , 'ajax_dismiss_tapro_admin_notice' ) );
382
+
383
+ }
384
+
385
+ /**
386
+ * Execute Marketing class.
387
+ *
388
+ * @since 3.0.0
389
+ * @access public
390
+ * @implements ThirstyAffiliates\Interfaces\Model_Interface
391
+ */
392
+ public function run() {
393
+
394
+ add_action( Plugin_Constants::CRON_REQUEST_REVIEW , array( $this , 'flag_show_review_request' ) );
395
+ add_action( Plugin_Constants::CRON_TAPRO_NOTICE , array( $this , 'flag_show_tapro_notice' ) );
396
+ add_action( 'admin_notices' , array( $this , 'show_review_request_notice' ) );
397
+ add_action( 'admin_notices' , array( $this , 'show_tapro_admin_notice' ) );
398
+ add_action( 'admin_menu' , array( $this , 'add_pro_features_menu_link' ) , 20 );
399
+ add_action( 'admin_head', array( $this , 'add_pro_features_menu_link_target' ) );
400
+
401
+ }
402
+
403
+ }
Models/Migration.php ADDED
@@ -0,0 +1,853 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+ use ThirstyAffiliates\Interfaces\Activatable_Interface;
9
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
10
+
11
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
12
+ use ThirstyAffiliates\Helpers\Helper_Functions;
13
+
14
+ /**
15
+ * Model that houses the logic of migration of old versions of TA to version 3.0.0
16
+ *
17
+ * @since 3.0.0
18
+ */
19
+ class Migration implements Model_Interface , Activatable_Interface , Initiable_Interface {
20
+
21
+ /*
22
+ |--------------------------------------------------------------------------
23
+ | Class Properties
24
+ |--------------------------------------------------------------------------
25
+ */
26
+
27
+ /**
28
+ * Property that holds the single main instance of Migration.
29
+ *
30
+ * @since 3.0.0
31
+ * @access private
32
+ * @var Redirection
33
+ */
34
+ private static $_instance;
35
+
36
+ /**
37
+ * Model that houses the main plugin object.
38
+ *
39
+ * @since 3.0.0
40
+ * @access private
41
+ * @var Redirection
42
+ */
43
+ private $_main_plugin;
44
+
45
+ /**
46
+ * Model that houses all the plugin constants.
47
+ *
48
+ * @since 3.0.0
49
+ * @access private
50
+ * @var Plugin_Constants
51
+ */
52
+ private $_constants;
53
+
54
+ /**
55
+ * Property that houses all the helper functions of the plugin.
56
+ *
57
+ * @since 3.0.0
58
+ * @access private
59
+ * @var Helper_Functions
60
+ */
61
+ private $_helper_functions;
62
+
63
+ /**
64
+ * Property that holds the list of all affiliate links.
65
+ *
66
+ * @since 3.0.0
67
+ * @access private
68
+ * @var array
69
+ */
70
+ private $_all_affiliate_links;
71
+
72
+ /**
73
+ * Variable that holds the mapping between options from old version of the plugin to the new version of the plugin.
74
+ *
75
+ * @since 3.0.0
76
+ * @access public
77
+ * @var array
78
+ */
79
+ private $_old_new_options_mapping;
80
+
81
+ /**
82
+ * Variable that holds the mapping between post meta from old version of the plugin to the new version of the plugin.
83
+ *
84
+ * @since 3.0.0
85
+ * @access public
86
+ * @var array
87
+ */
88
+ private $_old_new_meta_mapping;
89
+
90
+
91
+
92
+
93
+ /*
94
+ |--------------------------------------------------------------------------
95
+ | Class Methods
96
+ |--------------------------------------------------------------------------
97
+ */
98
+
99
+ /**
100
+ * Class constructor.
101
+ *
102
+ * @since 3.0.0
103
+ * @access public
104
+ *
105
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
106
+ * @param Plugin_Constants $constants Plugin constants object.
107
+ * @param Helper_Functions $helper_functions Helper functions object.
108
+ */
109
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
110
+
111
+ $this->_constants = $constants;
112
+ $this->_helper_functions = $helper_functions;
113
+
114
+ $main_plugin->add_to_all_plugin_models( $this );
115
+ $main_plugin->add_to_public_models( $this );
116
+
117
+ }
118
+
119
+ /**
120
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
121
+ *
122
+ * @since 3.0.0
123
+ * @access public
124
+ *
125
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
126
+ * @param Plugin_Constants $constants Plugin constants object.
127
+ * @param Helper_Functions $helper_functions Helper functions object.
128
+ * @return Redirection
129
+ */
130
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
131
+
132
+ if ( !self::$_instance instanceof self )
133
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
134
+
135
+ return self::$_instance;
136
+
137
+ }
138
+
139
+ /**
140
+ * Initialize data key mappings.
141
+ *
142
+ * @since 3.0.0
143
+ * @access public
144
+ */
145
+ public function initialize_data_key_mappings() {
146
+
147
+ // Get all affiliate links
148
+ $this->_all_affiliate_links = $this->get_all_affiliate_links();
149
+
150
+ $this->_old_new_options_mapping = apply_filters( 'ta_old_new_options_mapping' , array(
151
+
152
+ // Core Data
153
+ 'linkprefix' => 'ta_link_prefix',
154
+ 'linkprefixcustom' => 'ta_link_prefix_custom',
155
+ 'showcatinslug' => 'ta_show_cat_in_slug',
156
+ 'disablecatautoselect' => 'ta_disable_cat_auto_select',
157
+ 'linkredirecttype' => 'ta_link_redirect_type',
158
+ 'nofollow' => 'ta_no_follow',
159
+ 'newwindow' => 'ta_new_window',
160
+ // 'legacyuploader' => '', // Obsolete option, not supported anymore on 3.0.0
161
+ 'disabletitleattribute' => 'ta_disable_title_attribute',
162
+ 'disablethirstylinkclass' => 'ta_disable_thirsty_link_class',
163
+ 'disablevisualeditorbuttons' => 'ta_disable_visual_editor_buttons',
164
+ 'disabletexteditorbuttons' => 'ta_disable_text_editor_buttons',
165
+ 'additionalreltags' => 'ta_additional_rel_tags',
166
+
167
+ /* autolinker options */
168
+ 'autolinkbbpress' => 'tap_autolink_bbpress',
169
+ 'randomplacement' => 'tap_autolink_random_placement',
170
+ 'autolinkheadings' => 'tap_autolink_inside_heading',
171
+ 'disablearchives' => 'tap_autolink_disable_archives',
172
+ 'disablehome' => 'tap_autolink_disable_homepage',
173
+ 'enablefeedreplacement' => 'tap_autolink_enable_feeds',
174
+ 'enabledPostTypes' => 'tap_autolink_post_types',
175
+
176
+ /* geolocations options */
177
+ // 'geolicencekey' => '', // Obsolete option, not supported anymore on 3.0.0
178
+ // 'geolicenceemail' => '', // Obsolete option, not supported anymore on 3.0.0
179
+ 'disableforwardingproxytest' => 'tap_geolocations_disable_proxy_test',
180
+ // 'enableip2locationdb' => '', // Obsolete option, not supported anymore on 3.0.0
181
+ // 'ip2locationdbfile' => '', // Obsolete option, not supported anymore on 3.0.0
182
+ // 'disableip2locationdbcache' => '', // Obsolete option, not supported anymore on 3.0.0
183
+ // 'enableip2locationwebservice' => '', // Obsolete option, not supported anymore on 3.0.0
184
+ // 'ip2locationwebservicekey' => '', // Obsolete option, not supported anymore on 3.0.0
185
+ // 'enablemaxminddb' => '', // Obsolete option, not supported anymore on 3.0.0
186
+ // 'enablemaxmindwebservice' => '', // Obsolete option, not supported anymore on 3.0.0
187
+ 'maxminddbfile' => 'tap_geolocations_maxmind_mmdb_file',
188
+ 'maxmindwebserviceuserid' => 'tap_geolocations_maxmind_api_userid',
189
+ 'maxmindwebservicekey' => 'tap_geolocations_maxmind_api_key',
190
+
191
+ // Azon
192
+ /*
193
+ * Options below are not imported.
194
+ *
195
+ * include_item_stock_on_search_result
196
+ * include_item_rating_on_search_result
197
+ * include_sales_rank_on_search_result
198
+ */
199
+ 'azon_aws_access_key_id' => 'tap_amazon_access_key_id',
200
+ 'azon_aws_secret_key' => 'tap_amazon_secret_key',
201
+ 'defaultSearchCountry' => 'tap_last_used_search_endpoint',
202
+ 'azon_geolocation_support' => 'tap_azon_geolocation_integration',
203
+ 'defaultCategories' => 'tap_azon_imported_link_categories',
204
+ 'exclude_zero_priced_products' => 'tap_hide_products_with_empty_price',
205
+
206
+ // Google Click Tracking
207
+ 'gctactionname' => 'tap_google_click_tracking_action_name',
208
+ 'gctusepost' => 'tap_google_click_tracking_use_post',
209
+ 'gctuselegacyga' => 'tap_google_click_tracking_use_legacy_ga',
210
+ // 'gctfilterlegacyga' => '', // Obsolete option, not supported anymore on 3.0.0
211
+
212
+ // Stats
213
+ 'statsmanualexclusions' => 'tap_stats_manual_exclusions'
214
+
215
+
216
+ ) );
217
+
218
+ $this->_old_new_meta_mapping = apply_filters( 'ta_old_new_meta_mapping' , array(
219
+
220
+ // Core Data
221
+ 'linkredirecttype' => 'redirect_type',
222
+ 'linkurl' => 'destination_url',
223
+ 'nofollow' => 'no_follow',
224
+ 'newwindow' => 'new_window',
225
+ // 'enablewildcard' => '', // Tentative
226
+ // 'wildcards' => '', // Tentative
227
+ 'linkname' => 'name',
228
+
229
+ // autolinker meta
230
+ 'keywordlist' => 'autolink_keyword_list',
231
+ 'autolinklimit' => 'autolink_keyword_limit',
232
+ 'autolinkheadings' => 'autolink_inside_heading',
233
+ 'randomplacement' => 'autolink_random_placement',
234
+
235
+ // geolocations meta
236
+ 'geolink' => 'geolocation_links',
237
+
238
+ // Azon
239
+ // 'asin' => '_tap_asin' // asin bugged out, it does not contain asin anymore
240
+
241
+ // Stats
242
+ 'statsmanualexclusions' => 'tap_stats_manual_exclusions',
243
+
244
+
245
+ ) );
246
+
247
+ }
248
+
249
+ /**
250
+ * Migrate old plugin data.
251
+ * Note: Plugin_Constants::MIGRATION_COMPLETE_FLAG is not used to determine if we should migrate or not
252
+ * The only purpose of this option is to determine if there is a current migration running.
253
+ * If it says 'no' then there is a migration running, but its not yet finished.
254
+ * If it says 'yes' then it says, the current migration is done.
255
+ * We need to allow re-running migration coz there might be some data that have not migrated on first pass ( though this is for worst case scenarios ).
256
+ *
257
+ * @since 3.0.0
258
+ * @access public
259
+ */
260
+ public function migrate_old_plugin_data() {
261
+
262
+ update_option( Plugin_Constants::MIGRATION_COMPLETE_FLAG , 'no' );
263
+
264
+ $this->initialize_data_key_mappings();
265
+ $this->migrate_plugin_options();
266
+ $this->migrate_link_meta();
267
+ $this->migrate_image_attachments();
268
+
269
+ do_action( 'ta_migrate_old_plugin_data' );
270
+
271
+ update_option( Plugin_Constants::MIGRATION_COMPLETE_FLAG , 'yes' );
272
+
273
+ }
274
+
275
+ /**
276
+ * Migrate old plugin data to new data model via ajax.
277
+ *
278
+ * @since 3.0.0
279
+ * @access public
280
+ */
281
+ public function ajax_migrate_old_plugin_data() {
282
+
283
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
284
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX Call.' , 'thirstyaffiliates' ) );
285
+ elseif ( !$this->_helper_functions->current_user_authorized() )
286
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Unauthorized operation. Only authorized accounts can do data migration.' , 'thirstyaffiliates' ) );
287
+ else {
288
+
289
+ $this->migrate_old_plugin_data();
290
+ $response = array( 'status' => 'success' , 'success_msg' => __( 'Data Migration Complete!' , 'thirstyaffiliates' ) );
291
+
292
+ }
293
+
294
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
295
+ echo wp_json_encode( $response );
296
+ wp_die();
297
+
298
+ }
299
+
300
+
301
+
302
+
303
+ /*
304
+ |--------------------------------------------------------------------------
305
+ | Migrating Settings Options
306
+ |--------------------------------------------------------------------------
307
+ */
308
+
309
+ /**
310
+ * Migrate old plugin options to the new plugin options.
311
+ *
312
+ * @since 3.0.0
313
+ * @access public
314
+ */
315
+ public function migrate_plugin_options() {
316
+
317
+ $old_options = get_option( 'thirstyOptions' , array() );
318
+ if ( !is_array( $old_options ) )
319
+ $old_options = array();
320
+
321
+ $old_options_cache = $old_options;
322
+
323
+ $old_options = apply_filters( 'ta_migration_process_old_options' , $old_options );
324
+
325
+ foreach ( $old_options as $key => $val ) {
326
+
327
+ if ( array_key_exists( $key , $this->_old_new_options_mapping ) ) {
328
+
329
+ if ( $val === 'on' )
330
+ $val = 'yes';
331
+
332
+ update_option( $this->_old_new_options_mapping[ $key ] , $val );
333
+ unset( $old_options_cache[ $key ] );
334
+
335
+ }
336
+
337
+ }
338
+
339
+ update_option( 'thirstyOptions' , $old_options_cache );
340
+
341
+ do_action( 'ta_migrate_complex_options' ); // Hook for migrating complex options
342
+
343
+ }
344
+
345
+ /**
346
+ * Migrate complex options.
347
+ *
348
+ * @since 3.0.0
349
+ * @access public
350
+ */
351
+ public function complex_options_migration() {
352
+
353
+ $old_options = get_option( 'thirstyOptions' , array() );
354
+ if ( !is_array( $old_options ) )
355
+ $old_options = array();
356
+
357
+ // Amazon Associate Tags
358
+ $country_codes = array( 'us' , 'ca' , 'cn' , 'de' , 'es' , 'fr' , 'in' , 'it' , 'jp' , 'uk' ); // The only supported countries on old azon
359
+ $new_associate_tags = array();
360
+ $update_associate_tag = false;
361
+
362
+ foreach ( $country_codes as $cc ) {
363
+
364
+ if ( isset( $old_options[ $cc . "_azon_aws_associate_tag" ] ) && !empty( $old_options[ $cc . "_azon_aws_associate_tag" ] ) ) {
365
+
366
+ $update_associate_tag = true;
367
+ $new_associate_tags[ strtoupper( $cc ) ] = $old_options[ $cc . "_azon_aws_associate_tag" ];
368
+ unset( $old_options[ $cc . "_azon_aws_associate_tag" ] );
369
+
370
+ }
371
+
372
+ }
373
+
374
+ if ( $update_associate_tag )
375
+ update_option( 'tap_amazon_associate_tags' , $new_associate_tags );
376
+
377
+ // Amazon Import Images
378
+ $imported_images = array();
379
+ $update_images = false;
380
+
381
+ if ( isset( $old_options[ 'importImages' ] ) && !empty( $old_options[ 'importImages' ] ) && is_array( $old_options[ 'importImages' ] ) ) {
382
+
383
+ foreach ( $old_options[ 'importImages' ] as $key => $val )
384
+ if ( in_array( $key , array( 'small' , 'medium' , 'large' ) ) && $val === 'on' ) {
385
+
386
+ $update_images = true;
387
+ $imported_images[] = $key;
388
+
389
+ }
390
+
391
+ unset( $old_options[ 'importImages' ] );
392
+
393
+ }
394
+
395
+ if ( $update_images )
396
+ update_option( 'tap_azon_import_images' , $imported_images );
397
+
398
+ // Update the old option so no repeating of imports
399
+ update_option( 'thirstyOptions' , $old_options );
400
+
401
+ }
402
+
403
+
404
+
405
+
406
+ /*
407
+ |--------------------------------------------------------------------------
408
+ | Migrating Link Meta
409
+ |--------------------------------------------------------------------------
410
+ */
411
+
412
+ /**
413
+ * Get all affiliate links.
414
+ *
415
+ * @since 3.0.0
416
+ * @access public
417
+ *
418
+ * @return array Array of all affiliate links as objects.
419
+ */
420
+ public function get_all_affiliate_links() {
421
+
422
+ global $wpdb;
423
+
424
+ $query = "SELECT *
425
+ FROM $wpdb->posts
426
+ WHERE post_type = 'thirstylink'";
427
+
428
+ return $wpdb->get_results( $query );
429
+
430
+ }
431
+
432
+ /**
433
+ * Generate link meta insert sql.
434
+ *
435
+ * @since 3.0.0
436
+ * @access public
437
+ *
438
+ * @global WPDB $wpdb Global $wpdb object.
439
+ * @param int $link_id Affiliate link id.
440
+ * @param array $old_link_meta Old thirsty affiliate link meta.
441
+ * @param array $old_link_meta_cache Old thirsty affiliate link meta. Passed by reference. Used to track down the new old meta data.
442
+ * @return string SQL query.
443
+ */
444
+ private function _generate_link_meta_insert_sql( $link_id , $old_link_meta , &$old_link_meta_cache ) {
445
+
446
+ global $wpdb;
447
+
448
+ $query = "INSERT INTO $wpdb->postmeta ( post_id , meta_key , meta_value ) VALUES";
449
+ $first_pass = false;
450
+
451
+ foreach ( $this->_old_new_meta_mapping as $old_key => $new_key ) {
452
+
453
+ if ( isset( $old_link_meta[ $old_key ] ) ) {
454
+
455
+ if ( $first_pass )
456
+ $query .= ",";
457
+
458
+ $value = $old_link_meta[ $old_key ] === 'on' ? 'yes' : $old_link_meta[ $old_key ];
459
+
460
+ if ( $new_key === "destination_url" ) {
461
+
462
+ // Do not esc the destination_url as its already escaped there on meta
463
+ // There are cases on TA V2 that & are stored as double amps ( '&amp;amp;' ) we should replace them with single &amp;
464
+ $value = str_replace( '&amp;amp;' , '&amp;' , $value );
465
+
466
+ } else
467
+ $value = esc_sql( $value );
468
+
469
+ $query .= " ( " . $link_id . " , '" . Plugin_Constants::META_DATA_PREFIX . $new_key . "' , '" . $value . "' )";
470
+
471
+ /*
472
+ * We handle asin in a special way, i found out that old azon bugged out, it was not storing asin meta on azon imported links anymore.
473
+ * That is important for azon to identify which links came from amazon ( hence identifying on search if the product item on search result is already imported or not ).
474
+ * Because of that, we need to import the asin data when we reached to importing linkurl, linkurl contains asin data, so will extract that from link url and import it.
475
+ * We only do this tho for azon imported links.
476
+ */
477
+ if ( array_key_exists( 'asin' , $old_link_meta ) && $old_key === 'linkurl' && isset( $old_link_meta[ $old_key ] ) ) {
478
+
479
+ $parsed_url = parse_url( $old_link_meta[ $old_key ] );
480
+
481
+ if ( isset( $parsed_url[ 'query' ] ) ) {
482
+
483
+ // Yes intentionally doubled coz i see links like this &amp;amp;
484
+ $parsed_url[ 'query' ] = str_replace( "&amp;" , "&" , $parsed_url[ 'query' ] );
485
+ $parsed_url[ 'query' ] = str_replace( "&amp;" , "&" , $parsed_url[ 'query' ] );
486
+ parse_str( $parsed_url[ 'query' ] , $parsed_query_string );
487
+
488
+ if ( isset( $parsed_query_string[ 'creativeASIN' ] ) ) {
489
+
490
+ $asin = $parsed_query_string[ 'creativeASIN' ];
491
+ $query .= ", ( " . $link_id . " , '_tap_asin' , '" . $asin . "' )";
492
+
493
+ }
494
+
495
+ }
496
+
497
+ }
498
+
499
+ unset( $old_link_meta_cache[ $old_key ] );
500
+
501
+ if ( !$first_pass )
502
+ $first_pass = true;
503
+
504
+ }
505
+
506
+ }
507
+
508
+ return $first_pass ? $query : false;
509
+
510
+ }
511
+
512
+ /**
513
+ * Generate link meta delete sql.
514
+ * This sql query deletes old post meta from links after old data is migrated to the new post meta.
515
+ * This is designed to be reusable, the only dynamic part here is the link id.
516
+ * Therefore users of this function must str_replace the <link_id> with the proper link id.
517
+ * Currently not used, but we might used this later so lets just keep it.
518
+ *
519
+ * @since 3.0.0
520
+ * @access public
521
+ *
522
+ * @global WPDB $wpdb Global $wpdb object.
523
+ */
524
+ private function _generate_link_meta_delete_sql() {
525
+
526
+ global $wpdb;
527
+
528
+ return "DELETE FROM $wpdb->postmeta
529
+ WHERE post_id = <link_id>
530
+ AND meta_key IN ( " . implode( "," , array_keys( $this->_old_new_meta_mapping ) ) . " )";
531
+
532
+ }
533
+
534
+ /**
535
+ * Migrate old link metadata to new link metadata model.
536
+ * Old data comes from 'thirstyData' post meta which contains a serialized array of link meta data.
537
+ *
538
+ * @since 3.0.0
539
+ * @access public
540
+ *
541
+ * @global WPDB $wpdb Global $wpdb object.
542
+ */
543
+ public function migrate_link_meta() {
544
+
545
+ global $wpdb;
546
+
547
+ foreach ( $this->_all_affiliate_links as $affiliate_link ) {
548
+
549
+ $old_link_meta = maybe_unserialize( get_post_meta( $affiliate_link->ID , 'thirstyData' , true ) );
550
+ if ( !is_array( $old_link_meta ) )
551
+ $old_link_meta = array();
552
+
553
+ $old_link_meta_cache = $old_link_meta;
554
+
555
+ if ( empty( $old_link_meta ) )
556
+ continue;
557
+
558
+ $old_link_meta = apply_filters( 'ta_migration_process_old_link_meta' , $old_link_meta , $affiliate_link );
559
+
560
+ $query = $this->_generate_link_meta_insert_sql( $affiliate_link->ID , $old_link_meta , $old_link_meta_cache );
561
+ if ( $query && $wpdb->query( $query ) )
562
+ update_post_meta( $affiliate_link->ID , 'thirstyData' , serialize( $old_link_meta_cache ) );
563
+
564
+ }
565
+
566
+ }
567
+
568
+ /**
569
+ * Migrate autolinker enabled post types field
570
+ *
571
+ * @since 3.0.0
572
+ * @access public
573
+ *
574
+ * @param array $old_options TA2 settings.
575
+ * @return array Filtered TA2 settings.
576
+ */
577
+ public function migrate_autolinker_enabled_post_types_field( $old_options ) {
578
+
579
+ if ( isset( $old_options[ 'enabledPostTypes' ] ) && ! empty( $old_options[ 'enabledPostTypes' ] ) ) {
580
+
581
+ $support_post_types = array();
582
+
583
+ foreach ( $old_options[ 'enabledPostTypes' ] as $post_type => $val )
584
+ $support_post_types[] = $post_type;
585
+
586
+ $old_options[ 'enabledPostTypes' ] = $support_post_types;
587
+ }
588
+
589
+ return $old_options;
590
+ }
591
+
592
+ /**
593
+ * Migrate stats manual exclusion but removing the default value added by the Stats addon.
594
+ *
595
+ * @since 3.0.0
596
+ * @access public
597
+ *
598
+ * @param array $old_options TA2 settings.
599
+ * @return array Filtered TA2 settings.
600
+ */
601
+ public function migrate_stats_manual_exclusion( $old_options ) {
602
+
603
+ if ( ! isset( $old_options[ 'statsmanualexclusions' ] ) )
604
+ return $old_options;
605
+
606
+ $default_exclusions = "64.233.160.0-64.233.191.255\r\n66.102.0.0-66.102.15.255\r\n66.249.64.0-66.249.95.255\r\n72.14.192.0-72.14.255.255\r\n74.125.0.0-74.125.255.255\r\n209.85.128.0-209.85.255.255\r\n216.239.32.0-216.239.63.255\r\n64.4.0.0-64.4.63.255\r\n65.52.0.0-65.55.255.255\r\n131.253.21.0-131.253.47.255\r\n157.54.0.0-157.60.255.255\r\n207.46.0.0-207.46.255.255\r\n207.68.128.0-207.68.207.255\r\n8.12.144.0-8.12.144.255\r\n66.196.64.0-66.196.127.255\r\n66.228.160.0-66.228.191.255\r\n67.195.0.0-67.195.255.255\r\n68.142.192.0-68.142.255.255\r\n72.30.0.0-72.30.255.255\r\n74.6.0.0-74.6.255.255\r\n98.136.0.0-98.139.255.255\r\n202.160.176.0-202.160.191.255\r\n209.191.64.0-209.191.127.255";
607
+ $old_options[ 'statsmanualexclusions' ] = trim( str_replace( $default_exclusions , '' , $old_options[ 'statsmanualexclusions' ] ) );
608
+
609
+ return $old_options;
610
+ }
611
+
612
+
613
+
614
+
615
+ /*
616
+ |--------------------------------------------------------------------------
617
+ | Migrating Image Attachments To An Affiliate Link
618
+ |--------------------------------------------------------------------------
619
+ */
620
+
621
+ /**
622
+ * Migrate old image attachments data to new image attachment meta data.
623
+ * The code on how we used to attach image to a link can be found here in this functon "thirstyAttachImageToLink".
624
+ * We are using the post parent of the attachment as the place to hold the affiliate link id that the current attachment is attached to.
625
+ *
626
+ * @since 3.0.0
627
+ * @access public
628
+ *
629
+ * @global WPDB $wpdb Global $wpdb object.
630
+ */
631
+ public function migrate_image_attachments() {
632
+
633
+ global $wpdb;
634
+
635
+ foreach ( $this->_all_affiliate_links as $affiliate_link ) {
636
+
637
+ $old_link_attachments = get_posts( array(
638
+ 'post_type' => 'attachment',
639
+ 'posts_per_page' => -1,
640
+ 'post_status' => null,
641
+ 'post_parent' => $affiliate_link->ID,
642
+ 'orderby' => 'menu_order',
643
+ 'order' => 'ASC'
644
+ ) );
645
+
646
+ if ( is_array( $old_link_attachments ) ) {
647
+
648
+ $new_attachment_data = array();
649
+ foreach ( $old_link_attachments as $attachment )
650
+ $new_attachment_data[] = $attachment->ID;
651
+
652
+ if ( !empty( $new_attachment_data ) ) {
653
+
654
+ update_post_meta( $affiliate_link->ID , Plugin_Constants::META_DATA_PREFIX . 'image_ids' , $new_attachment_data );
655
+
656
+ $wpdb->query( "UPDATE $wpdb->posts
657
+ SET post_parent = ''
658
+ WHERE ID IN ( " . implode( "," , array_map( 'intval' , $new_attachment_data ) ) . " )
659
+ AND post_type = 'attachment'" );
660
+
661
+ }
662
+
663
+ }
664
+
665
+ }
666
+
667
+ }
668
+
669
+
670
+
671
+
672
+ /*
673
+ |--------------------------------------------------------------------------
674
+ | Migrating Geolocations Data
675
+ |--------------------------------------------------------------------------
676
+ */
677
+
678
+ /**
679
+ * Migrate geolocations metadata
680
+ *
681
+ * @since 3.0.0
682
+ * @access public
683
+ *
684
+ * @param array $old_link_data Affiliate link old post meta data.
685
+ * @param object $affiliate_link Affiliate link object $wpdb->posts single row result.
686
+ * @return array Filtered affiliate link old post meta data.
687
+ */
688
+ public function migrate_geolocations_meta_data( $old_link_meta , $affiliate_link ) {
689
+
690
+ if ( empty( $old_link_meta ) || ! isset( $old_link_meta[ 'geolink' ] ) || ! is_array( $old_link_meta[ 'geolink' ] ) || empty( $old_link_meta[ 'geolink' ] ) ) {
691
+
692
+ unset( $old_link_meta[ 'geolink' ] ); // NOTE: We need to unset this so no empty array will be processed in the SQL query.
693
+ return $old_link_meta;
694
+ }
695
+
696
+ $temp_geolinks = array();
697
+ $geolinks = array();
698
+ $country_clones = array();
699
+ $keys = array();
700
+
701
+ // seperate the geolinks with actual urls from the clone ones.
702
+ foreach ( $old_link_meta[ 'geolink' ] as $country => $destination ) {
703
+
704
+ if ( filter_var( $destination , FILTER_VALIDATE_URL ) === FALSE )
705
+ $country_clones[ $country ] = $destination;
706
+ else {
707
+
708
+ $temp_geolinks[ $country ] = array(
709
+ 'countries' => array( $country ),
710
+ 'destination_url' => $destination
711
+ );
712
+ }
713
+
714
+ }
715
+
716
+ // assign cloned countries to $temp_geolinks country data
717
+ foreach ( $country_clones as $country => $cloned_country )
718
+ $temp_geolinks[ $cloned_country ][ 'countries' ][] = $country;
719
+
720
+ // generate key for each geolink and add to $geolinks array list
721
+ foreach ( $temp_geolinks as $country => $data ) {
722
+
723
+ $key = trim( implode( ',' , $data[ 'countries' ] ) );
724
+ $geolinks[ $key ] = $data[ 'destination_url' ];
725
+ }
726
+
727
+ // Return combined keys with geolinks data
728
+ $old_link_meta[ 'geolink' ] = serialize( $geolinks );
729
+
730
+ return $old_link_meta;
731
+ }
732
+
733
+
734
+
735
+
736
+ /*
737
+ |--------------------------------------------------------------------------
738
+ | Migration Admin Notice
739
+ |--------------------------------------------------------------------------
740
+ */
741
+
742
+ /**
743
+ * Show admin notice that migration process is currently running.
744
+ *
745
+ * @since 3.0.0
746
+ * @access public
747
+ */
748
+ public function migration_running_admin_notice() {
749
+
750
+ if ( get_option( Plugin_Constants::MIGRATION_COMPLETE_FLAG ) === 'no' ) { ?>
751
+
752
+ <div class="notice notice-warning">
753
+ <p><?php _e( '<b>ThirstyAffiliates is currently migrating your old affiliate link data to the new data model.<br>Please hold off making changes to your affiliate links. Please refresh the page and if this message has disappeared, the migration is complete.</b>' , 'thirstyaffiliates' ); ?></p>
754
+ </div>
755
+
756
+ <?php }
757
+
758
+ }
759
+
760
+
761
+
762
+
763
+ /*
764
+ |--------------------------------------------------------------------------
765
+ | After migration
766
+ |--------------------------------------------------------------------------
767
+ */
768
+
769
+ /**
770
+ * After migration, urls will have double amps, change this to single amps.
771
+ * This is a behavior on TA v2 where it saves & on db as double amps.
772
+ *
773
+ * @since 3.0.1
774
+ * @access public
775
+ */
776
+ public function fix_double_amps_on_destination_url() {
777
+
778
+ global $wpdb;
779
+
780
+ $affiliate_link_ids = array();
781
+ foreach ( $this->_all_affiliate_links as $affiliate_link )
782
+ $affiliate_link_ids[] = $affiliate_link->ID;
783
+
784
+ $affiliate_link_ids_str = implode( "," , array_map( 'intval' , $affiliate_link_ids ) );
785
+
786
+ $query = "UPDATE $wpdb->postmeta
787
+ SET meta_value = REPLACE( meta_value , '&amp;amp;' , '&amp;' )
788
+ WHERE meta_key = '_ta_destination_url'
789
+ AND post_id IN ( $affiliate_link_ids_str )";
790
+
791
+ $wpdb->query( $query );
792
+
793
+ }
794
+
795
+
796
+
797
+
798
+ /*
799
+ |--------------------------------------------------------------------------
800
+ | Fulfill Implemented Interface Contracts
801
+ |--------------------------------------------------------------------------
802
+ */
803
+
804
+ /**
805
+ * Execute codes that needs to run plugin activation.
806
+ *
807
+ * @since 3.0.0
808
+ * @access public
809
+ * @implements ThirstyAffiliates\Interfaces\Activatable_Interface
810
+ */
811
+ public function activate() {
812
+
813
+ // Execute one time cron on plugin activation to migrate old data to new data
814
+ wp_schedule_single_event( time() + 5 , Plugin_Constants::CRON_MIGRATE_OLD_PLUGIN_DATA ); // Delay the migration for 5 sec to be sure everything is set up
815
+
816
+ }
817
+
818
+ /**
819
+ * Execute codes that needs to run on plugin initialization.
820
+ *
821
+ * @since 3.0.0
822
+ * @access public
823
+ * @implements ThirstyAffiliates\Interfaces\Initiable_Interface
824
+ */
825
+ public function initialize() {
826
+
827
+ add_action( 'wp_ajax_ta_migrate_old_plugin_data' , array( $this , 'ajax_migrate_old_plugin_data' ) );
828
+
829
+ }
830
+
831
+ /**
832
+ * Execute Migration class.
833
+ *
834
+ * @since 3.0.0
835
+ * @access public
836
+ * @implements ThirstyAffiliates\Interfaces\Model_Interface
837
+ */
838
+ public function run() {
839
+
840
+ add_action( Plugin_Constants::CRON_MIGRATE_OLD_PLUGIN_DATA , array( $this , 'migrate_old_plugin_data' ) );
841
+
842
+ add_action( 'admin_notices' , array( $this , 'migration_running_admin_notice' ) );
843
+
844
+ add_filter( 'ta_migration_process_old_options' , array( $this , 'migrate_autolinker_enabled_post_types_field' ) , 10 , 1 );
845
+ add_filter( 'ta_migration_process_old_options' , array( $this , 'migrate_stats_manual_exclusion' ) , 10 , 1 );
846
+ add_action( 'ta_migrate_complex_options' , array( $this , 'complex_options_migration' ) );
847
+ add_filter( 'ta_migration_process_old_link_meta' , array( $this , 'migrate_geolocations_meta_data' ) , 10 , 2 );
848
+
849
+ add_action( 'ta_migrate_old_plugin_data' , array( $this , 'fix_double_amps_on_destination_url' ) );
850
+
851
+ }
852
+
853
+ }
Models/Rewrites_Redirection.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+
9
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
10
+ use ThirstyAffiliates\Helpers\Helper_Functions;
11
+
12
+ /**
13
+ * Model that houses the logic for permalink rewrites and affiliate link redirections.
14
+ *
15
+ * @since 3.0.0
16
+ */
17
+ class Rewrites_Redirection implements Model_Interface {
18
+
19
+ /*
20
+ |--------------------------------------------------------------------------
21
+ | Class Properties
22
+ |--------------------------------------------------------------------------
23
+ */
24
+
25
+ /**
26
+ * Property that holds the single main instance of Rewrites_Redirection.
27
+ *
28
+ * @since 3.0.0
29
+ * @access private
30
+ * @var Redirection
31
+ */
32
+ private static $_instance;
33
+
34
+ /**
35
+ * Model that houses the main plugin object.
36
+ *
37
+ * @since 3.0.0
38
+ * @access private
39
+ * @var Redirection
40
+ */
41
+ private $_main_plugin;
42
+
43
+ /**
44
+ * Model that houses all the plugin constants.
45
+ *
46
+ * @since 3.0.0
47
+ * @access private
48
+ * @var Plugin_Constants
49
+ */
50
+ private $_constants;
51
+
52
+ /**
53
+ * Property that houses all the helper functions of the plugin.
54
+ *
55
+ * @since 3.0.0
56
+ * @access private
57
+ * @var Helper_Functions
58
+ */
59
+ private $_helper_functions;
60
+
61
+ /**
62
+ * Property that holds the currently loaded thirstylink post.
63
+ *
64
+ * @since 3.0.0
65
+ * @access private
66
+ */
67
+ private $_thirstylink;
68
+
69
+
70
+
71
+
72
+ /*
73
+ |--------------------------------------------------------------------------
74
+ | Class Methods
75
+ |--------------------------------------------------------------------------
76
+ */
77
+
78
+ /**
79
+ * Class constructor.
80
+ *
81
+ * @since 3.0.0
82
+ * @access public
83
+ *
84
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
85
+ * @param Plugin_Constants $constants Plugin constants object.
86
+ * @param Helper_Functions $helper_functions Helper functions object.
87
+ */
88
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
89
+
90
+ $this->_constants = $constants;
91
+ $this->_helper_functions = $helper_functions;
92
+
93
+ $main_plugin->add_to_all_plugin_models( $this );
94
+ $main_plugin->add_to_public_models( $this );
95
+
96
+ }
97
+
98
+ /**
99
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
100
+ *
101
+ * @since 3.0.0
102
+ * @access public
103
+ *
104
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
105
+ * @param Plugin_Constants $constants Plugin constants object.
106
+ * @param Helper_Functions $helper_functions Helper functions object.
107
+ * @return Redirection
108
+ */
109
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
110
+
111
+ if ( !self::$_instance instanceof self )
112
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
113
+
114
+ return self::$_instance;
115
+
116
+ }
117
+
118
+
119
+
120
+
121
+ /*
122
+ |--------------------------------------------------------------------------
123
+ | Flush Rewrite Rules
124
+ |--------------------------------------------------------------------------
125
+ */
126
+
127
+ /**
128
+ * Get thirstylink Affiliate_Link object.
129
+ *
130
+ * @since 3.0.0
131
+ * @access private
132
+ *
133
+ * @param int $post_id Thirstylink post id.
134
+ * @return Affiliate_Link object.
135
+ */
136
+ private function get_thirstylink_post( $post_id ) {
137
+
138
+ if ( is_object( $this->_thirstylink ) && $this->_thirstylink->get_id() == $post_id )
139
+ return $this->_thirstylink;
140
+
141
+ return $this->_thirstylink = new Affiliate_Link( $post_id );
142
+
143
+ }
144
+
145
+ /**
146
+ * Set ta_flush_rewrite_rules transient value to true if the link prefix value has changed.
147
+ *
148
+ * @since 3.0.0
149
+ * @access public
150
+ *
151
+ * @param string $new_value Option new value.
152
+ * @param string $old_value Option old value.
153
+ */
154
+ public function set_flush_rewrite_rules_transient( $new_value , $old_value ) {
155
+
156
+ if ( $new_value != $old_value )
157
+ set_transient( 'ta_flush_rewrite_rules' , 'true' , 5 * 60 );
158
+
159
+ return $new_value;
160
+
161
+ }
162
+
163
+ /**
164
+ * Set rewrite tags and rules.
165
+ *
166
+ * @since 3.0.0
167
+ * @access private
168
+ *
169
+ * @param string $link_prefix Thirstylink post type slug.
170
+ */
171
+ public function set_rewrites( $link_prefix ) {
172
+
173
+ add_rewrite_tag( '%' . $link_prefix . '%' , '([^&]+)' );
174
+ add_rewrite_rule( "$link_prefix/([^/]+)?/?$" , 'index.php?thirstylink=$matches[1]' , 'top' );
175
+
176
+ if ( get_option( 'ta_show_cat_in_slug' ) === 'yes' ) {
177
+
178
+ add_rewrite_tag( '%thirstylink-category%' , '([^&]+)');
179
+ add_rewrite_rule( "$link_prefix/([^/]+)?/?([^/]+)?/?" , 'index.php?thirstylink=$matches[2]&thirstylink-category=$matches[1]' , 'top' );
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Flush rewrite rules (soft) when the ta_flush_rewrite_rules transient is set to 'true'.
185
+ *
186
+ * @since 3.0.0
187
+ * @access public
188
+ */
189
+ public function flush_rewrite_rules() {
190
+
191
+ if ( 'true' !== get_transient( 'ta_flush_rewrite_rules' ) )
192
+ return;
193
+
194
+ flush_rewrite_rules( false );
195
+ delete_transient( 'ta_flush_rewrite_rules' );
196
+ }
197
+
198
+
199
+
200
+
201
+ /*
202
+ |--------------------------------------------------------------------------
203
+ | Redirection Handler
204
+ |--------------------------------------------------------------------------
205
+ */
206
+
207
+ /**
208
+ * Handles redirect for thirstylink link urls.
209
+ *
210
+ * @since 3.0.0
211
+ * @access public
212
+ */
213
+ public function redirect_url() {
214
+
215
+ global $post;
216
+
217
+ if ( ! is_object( $post ) || $post->post_type != Plugin_Constants::AFFILIATE_LINKS_CPT )
218
+ return;
219
+
220
+ $thirstylink = $this->get_thirstylink_post( $post->ID );
221
+ $redirect_url = html_entity_decode( $thirstylink->get_prop( 'destination_url' ) );
222
+ $redirect_type = $thirstylink->get_prop( 'redirect_type' , get_option( 'ta_link_redirect_type' ) );
223
+
224
+ // Apply any filters to the url and redirect type before redirecting
225
+ $redirect_url = apply_filters( 'ta_filter_redirect_url' , $redirect_url , $thirstylink );
226
+ $redirect_type = apply_filters( 'ta_filter_redirect_type' , $redirect_type , $thirstylink );
227
+
228
+ // perform actions before redirecting
229
+ do_action( 'ta_before_link_redirect' , $thirstylink , $redirect_url , $redirect_type );
230
+
231
+ if ( $redirect_url && $redirect_type ) {
232
+
233
+ wp_redirect( $redirect_url , intval( $redirect_type ) );
234
+ exit;
235
+ }
236
+
237
+ }
238
+
239
+ /**
240
+ * Pass query strings to destination url when option is enabled on settings.
241
+ *
242
+ * @since 3.0.0
243
+ * @access public
244
+ *
245
+ * @param string $redirect_url Affiliate link destination url.
246
+ */
247
+ public function pass_query_string_to_destination_url( $redirect_url , $thirstylink ) {
248
+
249
+ $query_string = isset( $_SERVER[ 'QUERY_STRING' ] ) ? $_SERVER[ 'QUERY_STRING' ] : '';
250
+ $pass_query_str = $thirstylink->get_prop( 'pass_query_str' ) == 'global' ? get_option( 'ta_pass_query_str' ) : $thirstylink->get_prop( 'pass_query_str' );
251
+
252
+ if ( ! $query_string || $pass_query_str !== 'yes' )
253
+ return $redirect_url;
254
+
255
+ $connector = ( strpos( $redirect_url , '?' ) === false ) ? '?' : '&';
256
+
257
+ return $redirect_url . $connector . $query_string;
258
+ }
259
+
260
+
261
+
262
+
263
+ /*
264
+ |--------------------------------------------------------------------------
265
+ | Fulfill implemented interface contracts
266
+ |--------------------------------------------------------------------------
267
+ */
268
+
269
+ /**
270
+ * Execute ajax handler.
271
+ *
272
+ * @since 3.0.0
273
+ * @access public
274
+ * @inherit ThirstyAffiliates\Interfaces\Model_Interface
275
+ */
276
+ public function run() {
277
+
278
+ // flush rewrite rules
279
+ add_filter( 'pre_update_option_ta_link_prefix' , array( $this , 'set_flush_rewrite_rules_transient' ) , 10 , 2 );
280
+ add_filter( 'pre_update_option_ta_link_prefix_custom' , array( $this , 'set_flush_rewrite_rules_transient' ) , 10 , 2 );
281
+ add_filter( 'pre_update_option_ta_show_cat_in_slug' , array( $this , 'set_flush_rewrite_rules_transient' ) , 10 , 2 );
282
+ add_action( 'ta_after_register_thirstylink_post_type' , array( $this , 'set_rewrites' ) , 1 , 1 );
283
+ add_action( 'ta_after_register_thirstylink_post_type' , array( $this , 'flush_rewrite_rules' ) );
284
+
285
+ // redirection handler
286
+ add_action( 'template_redirect' , array( $this , 'redirect_url' ) , 1 );
287
+
288
+ // filter redirect url before redirecting
289
+ add_filter( 'ta_filter_redirect_url' , array( $this , 'pass_query_string_to_destination_url' ) , 10 , 2 );
290
+ }
291
+ }
Models/Script_Loader.php ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Models;
3
+
4
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
5
+
6
+ use ThirstyAffiliates\Interfaces\Model_Interface;
7
+
8
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
9
+ use ThirstyAffiliates\Helpers\Helper_Functions;
10
+
11
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
+
13
+ class Script_Loader implements Model_Interface {
14
+
15
+ /*
16
+ |--------------------------------------------------------------------------
17
+ | Class Properties
18
+ |--------------------------------------------------------------------------
19
+ */
20
+
21
+ /**
22
+ * Property that holds the single main instance of Bootstrap.
23
+ *
24
+ * @since 3.0.0
25
+ * @access private
26
+ * @var Bootstrap
27
+ */
28
+ private static $_instance;
29
+
30
+ /**
31
+ * Model that houses all the plugin constants.
32
+ *
33
+ * @since 3.0.0
34
+ * @access private
35
+ * @var Plugin_Constants
36
+ */
37
+ private $_constants;
38
+
39
+ /**
40
+ * Property that houses all the helper functions of the plugin.
41
+ *
42
+ * @since 3.0.0
43
+ * @access private
44
+ * @var Helper_Functions
45
+ */
46
+ private $_helper_functions;
47
+
48
+ /**
49
+ * Property that houses the Guided_Tour model.
50
+ *
51
+ * @since 3.0.0
52
+ * @access private
53
+ * @var Guided_Tour
54
+ */
55
+ private $_guided_tour;
56
+
57
+
58
+
59
+
60
+ /*
61
+ |--------------------------------------------------------------------------
62
+ | Class Methods
63
+ |--------------------------------------------------------------------------
64
+ */
65
+
66
+ /**
67
+ * Class constructor.
68
+ *
69
+ * @since 3.0.0
70
+ * @access public
71
+ *
72
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
73
+ * @param Plugin_Constants $constants Plugin constants object.
74
+ * @param Helper_Functions $helper_functions Helper functions object.
75
+ */
76
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions , Guided_Tour $guided_tour ) {
77
+
78
+ $this->_constants = $constants;
79
+ $this->_helper_functions = $helper_functions;
80
+ $this->_guided_tour = $guided_tour;
81
+
82
+ $main_plugin->add_to_all_plugin_models( $this );
83
+
84
+ }
85
+
86
+ /**
87
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
88
+ *
89
+ * @since 3.0.0
90
+ * @access public
91
+ *
92
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
93
+ * @param Plugin_Constants $constants Plugin constants object.
94
+ * @param Helper_Functions $helper_functions Helper functions object.
95
+ * @return Bootstrap
96
+ */
97
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions , Guided_Tour $guided_tour ) {
98
+
99
+ if ( !self::$_instance instanceof self )
100
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions , $guided_tour );
101
+
102
+ return self::$_instance;
103
+
104
+ }
105
+
106
+ /**
107
+ * Load backend js and css scripts.
108
+ *
109
+ * @since 3.0.0
110
+ * @access public
111
+ *
112
+ * @global WP_Post $post WP_Post object of the current screen.
113
+ *
114
+ * @param string $handle Unique identifier of the current backend page.
115
+ */
116
+ public function load_backend_scripts( $handle ) {
117
+
118
+ global $post;
119
+
120
+ $screen = get_current_screen();
121
+
122
+ $post_type = get_post_type();
123
+ if ( !$post_type && isset( $_GET[ 'post_type' ] ) )
124
+ $post_type = $_GET[ 'post_type' ];
125
+
126
+ $review_request_response = get_option( Plugin_Constants::REVIEW_REQUEST_RESPONSE );
127
+
128
+ // Show review request popup
129
+ if ( is_admin() && current_user_can( 'manage_options' ) && $post_type === Plugin_Constants::AFFILIATE_LINKS_CPT && get_option( Plugin_Constants::SHOW_REQUEST_REVIEW ) === 'yes' && ( $review_request_response === 'review-later' || empty( $review_request_response ) ) ) {
130
+
131
+ wp_enqueue_script( 'review-request' , $this->_constants->JS_ROOT_URL() . 'app/ta-review-request.js' , array( 'jquery' ) , Plugin_Constants::VERSION , true );
132
+ }
133
+
134
+ if ( $screen->base === 'thirstylink_page_thirsty-settings' ) {
135
+
136
+ // Settings
137
+
138
+ // wp_enqueue_style( 'select2' , $this->_constants->CSS_ROOT_URL() . 'lib/select2/select2.min.css' , array() , Plugin_Constants::VERSION , 'all' );
139
+ wp_enqueue_style( 'chosen' , $this->_constants->JS_ROOT_URL() . 'lib/chosen/chosen.min.css' , array() , Plugin_Constants::VERSION , 'all' );
140
+ wp_enqueue_style( 'selectize' , $this->_constants->JS_ROOT_URL() . 'lib/selectize/selectize.default.css' , array() , Plugin_Constants::VERSION , 'all' );
141
+ wp_enqueue_style( 'ta_settings_css' , $this->_constants->CSS_ROOT_URL() . 'admin/ta-settings.css' , array() , Plugin_Constants::VERSION , 'all' );
142
+
143
+ // wp_enqueue_script( 'select2', $this->_constants->JS_ROOT_URL() . 'lib/select2/select2.min.js', array( 'jquery' ), Plugin_Constants::VERSION , true );
144
+ wp_enqueue_script( 'chosen' , $this->_constants->JS_ROOT_URL() . 'lib/chosen/chosen.jquery.min.js' , array( 'jquery' ) , Plugin_Constants::VERSION , true );
145
+ wp_enqueue_script( 'selectize', $this->_constants->JS_ROOT_URL() . 'lib/selectize/selectize.min.js' , array( 'jquery' , 'jquery-ui-core' , 'jquery-ui-sortable' ) , Plugin_Constants::VERSION , true );
146
+ wp_enqueue_script( 'ta_settings_js', $this->_constants->JS_ROOT_URL() . 'app/ta-settings.js', array( 'jquery' ), Plugin_Constants::VERSION , true );
147
+ wp_localize_script( 'ta_settings_js' , 'ta_settings_var' , array(
148
+ 'i18n_custom_link_prefix_valid_val' => __( 'Please provide a value for "Custom Link Prefix" option' , 'thirstyaffiliates' )
149
+ ) );
150
+
151
+ if ( isset( $_GET[ 'tab' ] ) && $_GET[ 'tab' ] === 'ta_import_export_settings' ) {
152
+
153
+ // Import/Export
154
+
155
+ wp_enqueue_style( 'ta_import_export_css' , $this->_constants->JS_ROOT_URL() . 'app/import_export/dist/import-export.css' , array() , 'all' );
156
+
157
+ wp_enqueue_script( 'ta_import_export_js' , $this->_constants->JS_ROOT_URL() . 'app/import_export/dist/import-export.js' , array() , true );
158
+ wp_localize_script( 'ta_import_export_js' , 'import_export_var' , array(
159
+ 'please_input_settings_string' => __( 'Please input settings string' , 'thirstyaffiliates' ),
160
+ 'settings_string_copied' => __( 'Settings string copied' , 'thirstyaffiliates' ),
161
+ 'failed_copy_settings_string' => __( 'Failed to copy settings string' , 'thirstyaffiliates' )
162
+ ) );
163
+
164
+ } elseif ( isset( $_GET[ 'tab' ] ) && $_GET[ 'tab' ] === 'ta_help_settings' ) {
165
+
166
+ // Migration
167
+
168
+ wp_enqueue_style( 'ta_migration_css' , $this->_constants->JS_ROOT_URL() . 'app/migration/dist/migration.css' , array() , 'all' );
169
+
170
+ wp_enqueue_script( 'ta_migration_js' , $this->_constants->JS_ROOT_URL() . 'app/migration/dist/migration.js' , array() , true );
171
+ wp_localize_script( 'ta_migration_js' , 'migration_var' , array(
172
+ 'i18n_migration_failed' => __( 'Failed to do data migration' , 'thirstyaffiliates' ),
173
+ 'i18n_confirm_migration' => __( 'Are you sure you want to migrate your ThirstyAffiliates data to version 3 format?' , 'thirstyaffiliates' )
174
+ ) );
175
+
176
+ }
177
+
178
+ } elseif ( $screen->base == 'post' && $post_type == Plugin_Constants::AFFILIATE_LINKS_CPT ) {
179
+
180
+ // Single Affiliate Link Edit Page
181
+
182
+ wp_enqueue_style( 'thickbox' );
183
+ wp_enqueue_style( 'jquery_tiptip' , $this->_constants->CSS_ROOT_URL() . 'lib/jquery-tiptip/jquery-tiptip.css' , array() , Plugin_Constants::VERSION , 'all' );
184
+ wp_enqueue_style( 'ta_affiliate-link-page_css' , $this->_constants->JS_ROOT_URL() . 'app/affiliate_link_page/dist/affiliate-link-page.css' , array() , Plugin_Constants::VERSION , 'all' );
185
+
186
+ wp_enqueue_media();
187
+ wp_dequeue_script( 'autosave' ); // Disable autosave
188
+ wp_enqueue_script( 'thickbox' , true );
189
+ wp_enqueue_script( 'jquery_tiptip' , $this->_constants->JS_ROOT_URL() . 'lib/jquery-tiptip/jquery.tipTip.min.js' , array() , Plugin_Constants::VERSION , true );
190
+ wp_enqueue_script( 'ta_affiliate-link-page_js' , $this->_constants->JS_ROOT_URL() . 'app/affiliate_link_page/dist/affiliate-link-page.js' , array() , Plugin_Constants::VERSION , true );
191
+
192
+ } elseif ( $screen->base == 'post' && $post_type != Plugin_Constants::AFFILIATE_LINKS_CPT ) {
193
+
194
+ wp_enqueue_style( 'thickbox' );
195
+ wp_enqueue_style( 'thirstyaffiliates-tinymce' , $this->_constants->CSS_ROOT_URL() . 'admin/tinymce/editor.css' , Plugin_Constants::VERSION , 'screen' );
196
+
197
+ wp_enqueue_script( 'thickbox' , true );
198
+ wp_enqueue_script( 'ta_editor_js', $this->_constants->JS_ROOT_URL() . 'app/ta-editor.js', array( 'jquery' ), Plugin_Constants::VERSION , true );
199
+ wp_localize_script( 'ta_editor_js' , 'ta_editor_var' , array(
200
+ 'insertion_type' => get_option( 'ta_link_insertion_type' , 'link' ),
201
+ 'disable_qtag_buttons' => get_option( 'ta_disable_text_editor_buttons' , 'no' ),
202
+ 'html_editor_affiliate_link_title' => __( 'Open the ThirstyAffiliates link picker' , 'thirstyaffiliates' ),
203
+ 'html_editor_quick_add_title' => __( 'Open quick add affiliate link dialog' , 'thirstyaffiliates' ),
204
+ 'simple_search_placeholder' => __( 'Type to seach affiliate link' , 'thirstyaffiliates' )
205
+ ) );
206
+
207
+ } elseif ( $screen->id == 'thirstylink_page_thirsty-reports' ) {
208
+
209
+ wp_enqueue_style( 'jquery-ui-styles' , '//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css' , array() , '1.11.4', 'all' );
210
+ wp_enqueue_style( 'ta_reports_css' , $this->_constants->CSS_ROOT_URL() . 'admin/ta-reports.css' , array( 'jquery-ui-styles' ) , Plugin_Constants::VERSION , 'all' );
211
+
212
+ wp_enqueue_script( 'jquery-ui-core' );
213
+ wp_enqueue_script( 'jquery-ui-datepicker' );
214
+ wp_enqueue_script( 'ta_reports_js', $this->_constants->JS_ROOT_URL() . 'app/ta-reports.js', array( 'jquery' , 'jquery-ui-core' , 'jquery-ui-datepicker' ), Plugin_Constants::VERSION , true );
215
+
216
+ if ( ! isset( $_GET[ 'tab' ] ) || $_GET[ 'tab' ] == 'link_performance' ) {
217
+
218
+ wp_enqueue_script( 'jquery-flot', $this->_constants->JS_ROOT_URL() . 'lib/flot/jquery.flot.min.js', array( 'jquery' ), Plugin_Constants::VERSION , true );
219
+ wp_enqueue_script( 'jquery-flot-time', $this->_constants->JS_ROOT_URL() . 'lib/flot/jquery.flot.time.min.js', array( 'jquery' , 'jquery-flot' ), Plugin_Constants::VERSION , true );
220
+
221
+ }
222
+
223
+ }
224
+
225
+ if ( get_option( 'ta_guided_tour_status' ) == 'open' && array_key_exists( $screen->id , $this->_guided_tour->get_screens() ) ) {
226
+
227
+ wp_enqueue_style( 'ta-guided-tour_css' , $this->_constants->CSS_ROOT_URL() . 'admin/ta-guided-tour.css' , array( 'wp-pointer' ) , Plugin_Constants::VERSION , 'all' );
228
+ wp_enqueue_script( 'ta-guided-tour_js' , $this->_constants->JS_ROOT_URL() . 'app/ta-guided-tour.js' , array( 'wp-pointer' , 'thickbox' ) , Plugin_Constants::VERSION , true );
229
+
230
+ wp_localize_script( 'ta-guided-tour_js',
231
+ 'ta_guided_tour_params',
232
+ array(
233
+ 'actions' => array( 'close_tour' => 'ta_close_guided_tour' ),
234
+ 'nonces' => array( 'close_tour' => wp_create_nonce( 'ta-close-guided-tour' ) ),
235
+ 'screen' => $this->_guided_tour->get_current_screen(),
236
+ 'screenid' => $screen->id,
237
+ 'height' => 640,
238
+ 'width' => 640,
239
+ 'texts' => array(
240
+ 'btn_prev_tour' => __( 'Previous', 'thirstyaffiliates' ),
241
+ 'btn_next_tour' => __( 'Next', 'thirstyaffiliates' ),
242
+ 'btn_close_tour' => __( 'Close', 'thirstyaffiliates' ),
243
+ 'btn_start_tour' => __( 'Start Tour', 'thirstyaffiliates' )
244
+ ),
245
+ 'urls' => array( 'ajax' => admin_url( 'admin-ajax.php' ) ),
246
+ 'post' => isset( $post ) && isset( $post->ID ) ? $post->ID : 0
247
+ )
248
+ );
249
+ }
250
+
251
+ }
252
+
253
+ /**
254
+ * Load frontend js and css scripts.
255
+ *
256
+ * @since 3.0.0
257
+ * @access public
258
+ */
259
+ public function load_frontend_scripts() {
260
+
261
+ global $post, $wp;
262
+
263
+ // load main frontend script that holds the link fixer and stat record JS code
264
+ wp_enqueue_script( 'ta_main_js' , $this->_constants->JS_ROOT_URL() . 'app/ta.js' , array() , Plugin_Constants::VERSION , true );
265
+ wp_localize_script( 'ta_main_js' , 'thirsty_global_vars' , array(
266
+ 'home_url' => home_url('/'),
267
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
268
+ 'link_fixer_enabled' => get_option( 'ta_enable_link_fixer' , 'yes' ),
269
+ 'link_prefix' => $this->_helper_functions->get_thirstylink_link_prefix(),
270
+ 'link_prefixes' => maybe_unserialize( get_option( 'ta_used_link_prefixes' ) ),
271
+ 'post_id' => isset( $post->ID ) ? $post->ID : 0,
272
+ ) );
273
+ }
274
+
275
+ /**
276
+ * Execute plugin script loader.
277
+ *
278
+ * @since 3.0.0
279
+ * @access public
280
+ */
281
+ public function run () {
282
+
283
+ add_action( 'admin_enqueue_scripts' , array( $this , 'load_backend_scripts' ) , 10 , 1 );
284
+ add_action( 'wp_enqueue_scripts' , array( $this , 'load_frontend_scripts' ) );
285
+
286
+ }
287
+
288
+ }
Models/Settings.php ADDED
@@ -0,0 +1,1821 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace ThirstyAffiliates\Models;
3
+
4
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
5
+
6
+ use ThirstyAffiliates\Interfaces\Model_Interface;
7
+ use ThirstyAffiliates\Interfaces\Activatable_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+
10
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
11
+ use ThirstyAffiliates\Helpers\Helper_Functions;
12
+
13
+ if ( !defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
+ /**
16
+ * Model that houses the logic of plugin Settings.
17
+ * General Information:
18
+ * The Ultimate Settings API ( Of course there will always be room for improvements ).
19
+ * Basically we are using parts of the WordPress Settings API ( Only the backend processes )
20
+ * But we are using our own custom render codebase.
21
+ * The issue with WordPress Settings API is that we need to supply callbacks for each option field we add, so its not really extensible.
22
+ * The data supplied on those callbacks are not ideal or not complete too to make a very extensible Settings API.
23
+ * So what we did is, Register the settings and settings options in a way that we can utilize WordPress Settings API to handle them on the backend.
24
+ * But use our own render codebase so we can make the Settings API very easy to extend.
25
+ *
26
+ * Important Note:
27
+ * Be careful with default values. Default values only take effect if you haven't set the option yet. Meaning the option is not yet registered yet to the options db. ( get_option ).
28
+ * Now if you hit save on a settings section with a field that have a default value, and you haven't changed that default value, Alas! it will still not register that option to the options db.
29
+ * The reason is the default value and the current value of the options is the same.
30
+ * Bug if you modify the value of the option, and hit save, this time, that option will be registered to the options db.
31
+ * Then if you set back the value of that option, same as its default, it will still updated that option that is registered to the options db with that value.
32
+ * Again remember, default value only kicks in if the option you are trying to get via get_option function is not yet registered to the options db.
33
+ *
34
+ * Important Note:
35
+ * If the option can contain multiple values ( in array form , ex. checkbox and multiselect option types ), the default value must be in array form even if it only contains one value.
36
+ *
37
+ * Private Model.
38
+ *
39
+ * @since 3.0.0
40
+ */
41
+ class Settings implements Model_Interface , Activatable_Interface , Initiable_Interface {
42
+
43
+ /*
44
+ |--------------------------------------------------------------------------
45
+ | Class Properties
46
+ |--------------------------------------------------------------------------
47
+ */
48
+
49
+ /**
50
+ * Property that holds the single main instance of Settings.
51
+ *
52
+ * @since 3.0.0
53
+ * @access private
54
+ * @var Settings
55
+ */
56
+ private static $_instance;
57
+
58
+ /**
59
+ * Model that houses all the plugin constants.
60
+ *
61
+ * @since 3.0.0
62
+ * @access private
63
+ * @var Plugin_Constants
64
+ */
65
+ private $_constants;
66
+
67
+ /**
68
+ * Property that houses all the helper functions of the plugin.
69
+ *
70
+ * @since 3.0.0
71
+ * @access private
72
+ * @var Helper_Functions
73
+ */
74
+ private $_helper_functions;
75
+
76
+ /**
77
+ * Property that houses all the supported option field types.
78
+ *
79
+ * @since 3.0.0
80
+ * @access private
81
+ * @var array
82
+ */
83
+ private $_supported_field_types;
84
+
85
+ /**
86
+ * Property that houses all the supported option field types that do not needed to be registered to the WP Settings API.
87
+ * Ex. of this are field types that are for decorative purposes only and has no underlying option data to save.
88
+ * Another is type of option fields that perform specialized task and does not need any underlying data to be saved.
89
+ *
90
+ * @since 3.0.0
91
+ * @access public
92
+ */
93
+ private $_skip_wp_settings_registration;
94
+
95
+ /**
96
+ * Property that houses all the registered settings sections.
97
+ *
98
+ *
99
+ * @since 3.0.0
100
+ * @access private
101
+ * @var array
102
+ */
103
+ private $_settings_sections;
104
+
105
+ /**
106
+ * Property that houses all the registered options of the registered settings sections.
107
+ *
108
+ * @since 3.0.0
109
+ * @access private
110
+ * @var array
111
+ */
112
+ private $_settings_section_options;
113
+
114
+ /**
115
+ * Property that holds all plugin options that can be exported.
116
+ *
117
+ * @since 3.0.0
118
+ * @access private
119
+ * @var array
120
+ */
121
+ private $_exportable_options;
122
+
123
+ /**
124
+ * Property that holds list of post update function callbacks per option if there are any.
125
+ *
126
+ * @since 3.0.0
127
+ * @access private
128
+ * @var array
129
+ */
130
+ private $_post_update_option_cbs = array();
131
+
132
+
133
+
134
+
135
+ /*
136
+ |--------------------------------------------------------------------------
137
+ | Class Methods
138
+ |--------------------------------------------------------------------------
139
+ */
140
+
141
+ /**
142
+ * Class constructor.
143
+ *
144
+ * @since 3.0.0
145
+ * @access public
146
+ *
147
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
148
+ * @param Plugin_Constants $constants Plugin constants object.
149
+ * @param Helper_Functions $helper_functions Helper functions object.
150
+ */
151
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
152
+
153
+ $this->_constants = $constants;
154
+ $this->_helper_functions = $helper_functions;
155
+
156
+ $main_plugin->add_to_all_plugin_models( $this );
157
+
158
+ }
159
+
160
+ /**
161
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
162
+ *
163
+ * @since 3.0.0
164
+ * @access public
165
+ *
166
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
167
+ * @param Plugin_Constants $constants Plugin constants object.
168
+ * @param Helper_Functions $helper_functions Helper functions object.
169
+ * @return Settings
170
+ */
171
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
172
+
173
+ if ( !self::$_instance instanceof self )
174
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
175
+
176
+ return self::$_instance;
177
+
178
+ }
179
+
180
+
181
+
182
+
183
+ /*
184
+ |--------------------------------------------------------------------------
185
+ | Initialize Settings
186
+ |--------------------------------------------------------------------------
187
+ */
188
+
189
+ /**
190
+ * Initialize the list of plugin built-in settings sections and its corresponding options.
191
+ *
192
+ * @since 3.0.0
193
+ * @access public
194
+ */
195
+ public function init_settings_sections_and_options() {
196
+
197
+ $this->_supported_field_types = apply_filters( 'ta_supported_field_types' , array(
198
+ 'text' => array( $this , 'render_text_option_field' ),
199
+ 'number' => array( $this , 'render_number_option_field' ),
200
+ 'textarea' => array( $this , 'render_textarea_option_field' ),
201
+ 'checkbox' => array( $this , 'render_checkbox_option_field' ),
202
+ 'radio' => array( $this , 'render_radio_option_field' ),
203
+ 'select' => array( $this , 'render_select_option_field' ),
204
+ 'multiselect' => array( $this , 'render_multiselect_option_field' ),
205
+ 'toggle' => array( $this , 'render_toggle_option_field' ),
206
+ 'editor' => array( $this , 'render_editor_option_field' ),
207
+ 'csv' => array( $this , 'render_csv_option_field' ),
208
+ 'key_value' => array( $this , 'render_key_value_option_field' ),
209
+ 'link' => array( $this , 'render_link_option_field' ),
210
+ 'option_divider' => array( $this , 'render_option_divider_option_field' ),
211
+ 'migration_controls' => array( $this , 'render_migration_controls_option_field' ),
212
+ 'export_global_settings' => array( $this , 'render_export_global_settings_option_field' ),
213
+ 'import_global_settings' => array( $this , 'render_import_global_settings_option_field' )
214
+ ) );
215
+
216
+ $this->_skip_wp_settings_registration = apply_filters( 'ta_skip_wp_settings_registration' , array(
217
+ 'link',
218
+ 'option_divider',
219
+ 'migration_controls',
220
+ 'export_global_settings',
221
+ 'import_global_settings'
222
+ ) );
223
+
224
+ $this->_settings_sections = apply_filters( 'ta_settings_option_sections' , array(
225
+ 'ta_general_settings' => array(
226
+ 'title' => __( 'General' , 'thirstyaffiliates' ) ,
227
+ 'desc' => __( 'Settings that change the general behaviour of ThirstyAffiliates.' , 'thirstyaffiliates' )
228
+ ),
229
+ 'ta_links_settings' => array(
230
+ 'title' => __( 'Link Appearance' , 'thirstyaffiliates' ) ,
231
+ 'desc' => __( 'Settings that specifically affect the behaviour & appearance of your affiliate links.' , 'thirstyaffiliates' )
232
+ ),
233
+ 'ta_modules_settings' => array(
234
+ 'title' => __( 'Modules' , 'thirstyaffiliates' ),
235
+ 'desc' => __( 'This section allows you to turn certain parts of ThirstyAffiliates on or off. Below are the individual modules and features of the plugin that can be controlled.' , 'thirstyaffiliates' )
236
+ ),
237
+ 'ta_import_export_settings' => array(
238
+ 'title' => __( 'Import/Export' , 'thirstyaffiliates' ),
239
+ 'desc' => __( 'Import and Export global ThirstyAffiliates plugin settings from one site to another.' , 'thirstyaffiliates' )
240
+ ),
241
+ 'ta_help_settings' => array(
242
+ 'title' => __( 'Help' , 'thirstyaffiliates' ),
243
+ 'desc' => __( 'Links to knowledge base and other utilities.' , 'thirstyaffiliates' )
244
+ )
245
+ ) );
246
+
247
+ $this->_settings_section_options = apply_filters( 'ta_settings_section_options' , array(
248
+ 'ta_general_settings' => apply_filters( 'ta_general_settings_options' , array(
249
+
250
+ array(
251
+ 'id' => 'ta_link_insertion_type',
252
+ 'title' => __( 'Default Link Insertion Type' , 'thirstyaffiliates' ),
253
+ 'desc' => __( "Determines the default link type when inserting a link using the quick search." , 'thirstyaffiliates' ),
254
+ 'type' => 'select',
255
+ 'default' => 'link',
256
+ 'options' => array(
257
+ 'link' => __( 'Link' , 'thirstyaffiliates' ),
258
+ 'shortcode' => __( 'Shortcode' , 'thirstyaffiliates' ),
259
+ )
260
+ ),
261
+
262
+ array(
263
+ 'id' => 'ta_disable_cat_auto_select',
264
+ 'title' => __( 'Disable "uncategorized" category on save?' , 'thirstyaffiliates' ),
265
+ 'desc' => __( 'If links are including categories in the URL then by default ThirstyAffiliates will add an "uncategorized" category to apply to non-categorised links during save. If you disable this, it allows you to have some links with categories in the URL and some without.' , 'thirstyaffiliates' ),
266
+ 'type' => 'toggle'
267
+ ),
268
+
269
+ array(
270
+ 'id' => 'ta_disable_visual_editor_buttons',
271
+ 'title' => __( 'Disable buttons on the Visual editor?' , 'thirstyaffiliates' ),
272
+ 'desc' => __( "Hide the ThirstyAffiliates buttons on the Visual editor." , 'thirstyaffiliates' ),
273
+ 'type' => 'toggle'
274
+ ),
275
+
276
+ array(
277
+ 'id' => 'ta_disable_text_editor_buttons',
278
+ 'title' => __( 'Disable buttons on the Text/Quicktags editor?' , 'thirstyaffiliates' ),
279
+ 'desc' => __( "Hide the ThirstyAffiliates buttons on the Text editor." , 'thirstyaffiliates' ),
280
+ 'type' => 'toggle'
281
+ )
282
+
283
+ ) ),
284
+ 'ta_links_settings' => apply_filters( 'ta_links_settings_options' , array(
285
+
286
+ array(
287
+ 'id' => 'ta_link_prefix',
288
+ 'title' => __( 'Link Prefix' , 'thirstyaffiliates' ),
289
+ 'desc' => sprintf( __( "The prefix that comes before your cloaked link's slug. <br>eg. %s/<strong>recommends</strong>/your-affiliate-link-name.<br><br><b>Warning :</b> Changing this setting after you've used links in a post could break those links. Be careful!" , 'thirstyaffiliates' ) , home_url() ),
290
+ 'type' => 'select',
291
+ 'default' => 'recommends',
292
+ 'options' => array(
293
+ 'custom' => '-- custom --',
294
+ 'recommends' => 'recommends',
295
+ 'link' => 'link',
296
+ 'go' => 'go',
297
+ 'review' => 'review',
298
+ 'product' => 'product',
299
+ 'suggests' => 'suggests',
300
+ 'follow' => 'follow',
301
+ 'endorses' => 'endorses',
302
+ 'proceed' => 'proceed',
303
+ 'fly' => 'fly',
304
+ 'goto' => 'goto',
305
+ 'get' => 'get',
306
+ 'find' => 'find',
307
+ 'act' => 'act',
308
+ 'click' => 'click',
309
+ 'move' => 'move',
310
+ 'offer' => 'offer',
311
+ 'run' => 'run'
312
+ )
313
+ ),
314
+
315
+ array(
316
+ 'id' => 'ta_link_prefix_custom',
317
+ 'title' => __( 'Custom Link Prefix' , 'thirstyaffiliates' ),
318
+ 'desc' => __( 'Enter your preferred link prefix.' , 'thirstyaffiliates' ),
319
+ 'type' => 'text'
320
+ ),
321
+
322
+ array(
323
+ 'id' => 'ta_show_cat_in_slug',
324
+ 'title' => __( 'Link Category in URL?' , 'thirstyaffiliates' ),
325
+ 'desc' => sprintf( __( "Shows the primary selected category in the url. eg. %s/recommends/<strong>link-category</strong>/your-affiliate-link-name.<br><br><b>Warning :</b> Changing this setting after you've used links in a post could break those links. Be careful!" , 'thirstyaffiliates' ) , home_url() ),
326
+ 'type' => 'toggle'
327
+ ),
328
+
329
+ array(
330
+ 'id' => 'ta_link_redirect_type',
331
+ 'title' => __( 'Link Redirect Type' , 'thirstyaffiliates' ),
332
+ 'desc' => __( "This is the type of redirect ThirstyAffiliates will use to redirect the user to your affiliate link." , 'thirstyaffiliates' ),
333
+ 'type' => 'radio',
334
+ 'options' => $this->_constants->REDIRECT_TYPES(),
335
+ ),
336
+
337
+ array(
338
+ 'id' => 'ta_no_follow',
339
+ 'title' => __( 'Use no follow on links?' , 'thirstyaffiliates' ),
340
+ 'desc' => __( "Add the nofollow attribute to links so search engines don't index them." , 'thirstyaffiliates' ),
341
+ 'type' => 'toggle',
342
+ 'default' => 'no'
343
+ ),
344
+
345
+ array(
346
+ 'id' => 'ta_new_window',
347
+ 'title' => __( 'Open links in new window?' , 'thirstyaffiliates' ),
348
+ 'desc' => __( "Make links open in a new browser tab by default." , 'thirstyaffiliates' ),
349
+ 'type' => 'toggle',
350
+ 'default' => 'no'
351
+ ),
352
+
353
+ array(
354
+ 'id' => 'ta_pass_query_str',
355
+ 'title' => __( 'Pass query strings to destination url?' , 'thirstyaffiliates' ),
356
+ 'desc' => __( "Enabling this option will pass all of the query strings present after the cloaked url to the destination url automatically when redirecting." , 'thirstyaffiliates' ),
357
+ 'type' => 'toggle',
358
+ 'default' => 'no'
359
+ ),
360
+
361
+ array(
362
+ 'id' => 'ta_additional_rel_tags',
363
+ 'title' => __( 'Additional rel attribute tags' , 'thirstyaffiliates' ),
364
+ 'desc' => __( "Allows you to add extra tags into the rel= attribute when links are inserted." , 'thirstyaffiliates' ),
365
+ 'type' => 'text'
366
+ ),
367
+
368
+ array(
369
+ 'id' => 'ta_disable_thirsty_link_class',
370
+ 'title' => __( 'Disable ThirstyAffiliates CSS classes?' , 'thirstyaffiliates' ),
371
+ 'desc' => __( 'To help with styling a CSS class called "thirstylink" is added links on insertion.<br>Likewise the "thirstylinkimg" class is added to images when using the image insertion type. This option disables the addition these CSS classes.' , 'thirstyaffiliates' ),
372
+ 'type' => 'toggle'
373
+ ),
374
+
375
+ array(
376
+ 'id' => 'ta_disable_title_attribute',
377
+ 'title' => __( 'Disable title attribute on link insertion?' , 'thirstyaffiliates' ),
378
+ 'desc' => __( "Links are automatically output with a title html attribute (by default this shows the title of the affiliate link).<br>This option disables the output of the title attribute on your links." , 'thirstyaffiliates' ),
379
+ 'type' => 'toggle'
380
+ ),
381
+
382
+ array(
383
+ 'id' => 'ta_category_to_uncloak',
384
+ 'title' => __( 'Select Category to Uncloak' , 'thirstyaffiliates' ),
385
+ 'desc' => __( "The links assigned to the selected category will be uncloaked." , 'thirstyaffiliates' ),
386
+ 'type' => 'multiselect',
387
+ 'options' => $this->_helper_functions->get_all_category_as_options(),
388
+ 'default' => array(),
389
+ 'condition_cb' => function() { return get_option( 'ta_uncloak_link_per_link' ) === 'yes'; },
390
+ 'placeholder' => __( 'Select category...' , 'thirstyaffiliates' )
391
+ )
392
+
393
+ ) ),
394
+
395
+ 'ta_modules_settings' => apply_filters( 'ta_modules_settings_options' , array(
396
+
397
+ array(
398
+ 'id' => 'ta_enable_stats_reporting_module',
399
+ 'title' => __( 'Statistics' , 'thirstyaffiliates' ),
400
+ 'desc' => __( "When enabled, ThirstyAffiliates will collect click statistics information about visitors that click on your affiliate links. Also adds a new Reports section." , 'thirstyaffiliates' ),
401
+ 'type' => 'toggle',
402
+ 'default' => 'yes'
403
+ ),
404
+
405
+ array(
406
+ 'id' => 'ta_enable_link_fixer',
407
+ 'title' => __( 'Link Fixer' , 'thirstyaffiliates' ),
408
+ 'desc' => __( "Link Fixer is a tiny piece of javascript code that runs on the frontend of your site to fix any outdated/broken affiliate links it detects. It's cache-friendly and runs after page load so it doesn't affect the rendering of content. Changed the settings on your site recently? Enabling Link Fixer means you don't need to update all your previously inserted affiliate links one by one – your visitors will never see an out of date affiliate link again." , 'thirstyaffiliates' ),
409
+ 'type' => 'toggle',
410
+ 'default' => 'yes',
411
+ ),
412
+
413
+ array(
414
+ 'id' => 'ta_uncloak_link_per_link',
415
+ 'title' => __( 'Uncloak Links' , 'thirstyaffiliates' ),
416
+ 'desc' => __( "Uncloak Links is a feature to allow uncloaking of specific links on your site. It replaces the cloaked url with the actual destination url which is important for compatibility with some affiliate program with stricter terms (such as Amazon Associates). Once enabled, you will see a new Uncloak Link checkbox on the affiliate link edit screen. It also introduces a new setting under the Links tab for uncloaking whole categories.<br><br><b>Warning : </b>For this feature to work, the <strong>Link Fixer</strong> module needs to be turned on." , 'thirstyaffiliates' ),
417
+ 'type' => 'toggle',
418
+ 'default' => 'no',
419
+ )
420
+
421
+ ) ),
422
+ 'ta_import_export_settings' => apply_filters( 'ta_import_export_settings_options' , array(
423
+
424
+ array(
425
+ 'id' => 'ta_import_settings',
426
+ 'title' => __( 'Import Global Settings' , 'thirstyaffiliates' ),
427
+ 'type' => 'import_global_settings',
428
+ 'placeholder' => __( 'Paste settings string here...' , 'thirstyaffiliates' )
429
+ ),
430
+
431
+ array(
432
+ 'id' => 'ta_export_settings',
433
+ 'title' => __( 'Export Global Settings' , 'thirstyaffiliates' ),
434
+ 'type' => 'export_global_settings'
435
+ )
436
+
437
+ ) ),
438
+ 'ta_help_settings' => apply_filters( 'ta_help_settings_options' , array(
439
+
440
+ array(
441
+ 'id' => 'ta_knowledge_base_divider', // Even though no option is really saved, we still add id, for the purpose of later when extending this section options, they can search for this specific section divider during array loop
442
+ 'title' => __( 'Knowledge Base' , 'thirstyaffiliates' ),
443
+ 'type' => 'option_divider'
444
+ ),
445
+
446
+ array(
447
+ 'title' => __( 'Documentation' , 'thirstyaffiliates' ),
448
+ 'type' => 'link',
449
+ 'link_url' => 'https://thirstyaffiliates.com/knowledge-base/?utm_source=Free%20Plugin&utm_medium=Help&utm_campaign=Knowledge%20Base%20Link',
450
+ 'link_text' => __( 'Knowledge Base' , 'thirstyaffiliates' ),
451
+ 'desc' => __( 'Guides, troubleshooting, FAQ and more.' , 'thirstyaffiliates' ),
452
+ 'id' => 'ta_kb_link',
453
+ ),
454
+
455
+ array(
456
+ 'title' => __( 'Our Blog' , 'thirstyaffiliates' ),
457
+ 'type' => 'link',
458
+ 'link_url' => 'https://thirstyaffiliates.com/blog?utm_source=Free%20Plugin&utm_medium=Help&utm_campaign=Blog%20Link',
459
+ 'link_text' => __( 'ThirstyAffiliates Blog' , 'thirstyaffiliates' ),
460
+ 'desc' => __( 'Learn & grow your affiliate marketing – covering increasing sales, generating traffic, optimising your affiliate marketing, interviews & case studies.' , 'thirstyaffiliates' ),
461
+ 'id' => 'ta_blog_link',
462
+ ),
463
+
464
+ array(
465
+ 'id' => 'ta_other_utilities_divider', // Even though no option is really saved, we still add id, for the purpose of later when extending this section options, they can search for this specific section divider during array loop
466
+ 'title' => __( 'Other Utilities' , 'thirstyaffiliates' ),
467
+ 'type' => 'option_divider'
468
+ ),
469
+
470
+ array(
471
+ 'title' => __( 'Migrate Old Data' , 'thirstyaffiliates' ),
472
+ 'type' => 'migration_controls',
473
+ 'desc' => __( 'Migrate old ThirstyAffiliates version 2 data to new version 3 data model.' , 'thirstyaffiliates' ),
474
+ 'id' => 'ta_migrate_old_data'
475
+ )
476
+
477
+ ) )
478
+
479
+ ) );
480
+
481
+ // Get all the exportable options
482
+ foreach ( $this->_settings_section_options as $section_id => $section_options ) {
483
+
484
+ foreach ( $section_options as $option ) {
485
+
486
+ if ( in_array( $option[ 'type' ] , $this->_skip_wp_settings_registration ) )
487
+ continue;
488
+
489
+ $this->_exportable_options[ $option[ 'id' ] ] = isset( $option[ 'default' ] ) ? $option[ 'default' ] : '';
490
+
491
+ if ( isset( $option[ 'post_update_cb' ] ) && is_callable( $option[ 'post_update_cb' ] ) )
492
+ add_action( 'update_option_' . $option[ 'id' ] , $option[ 'post_update_cb' ] , 10 , 3 );
493
+
494
+ }
495
+
496
+ }
497
+
498
+ }
499
+
500
+ /**
501
+ * Register Settings Section and Options Group to WordPress Settings API.
502
+ *
503
+ * @since 3.0.0
504
+ * @access public
505
+ */
506
+ public function register_settings_section_and_options_group() {
507
+
508
+ foreach ( $this->_settings_sections as $section_id => $section_data ) {
509
+
510
+ add_settings_section(
511
+ $section_id, // Settings Section ID
512
+ $section_data[ 'title' ], // Settings Section Title
513
+ function() {}, // Callback. Intentionally Left Empty. We Will Handle UI Rendering.
514
+ $section_id . '_options_group' // Options Group
515
+ );
516
+
517
+ }
518
+
519
+ }
520
+
521
+ /**
522
+ * Register Settings Section Options to WordPress Settings API.
523
+ *
524
+ * @since 3.0.0
525
+ * @access public
526
+ */
527
+ public function register_settings_section_options() {
528
+
529
+ foreach ( $this->_settings_section_options as $section_id => $section_options ) {
530
+
531
+ foreach ( $section_options as $option ) {
532
+
533
+ if ( !array_key_exists( $option[ 'type' ] , $this->_supported_field_types ) || in_array( $option[ 'type' ] , $this->_skip_wp_settings_registration ) )
534
+ continue;
535
+
536
+ // Register The Option To The Options Group It Is Scoped With
537
+ add_settings_field(
538
+ $option[ 'id' ], // Option ID
539
+ $option[ 'title' ], // Option Title
540
+ function() {}, // Render Callback. Intentionally Left Empty. We Will Handle UI Rendering.
541
+ $section_id . '_options_group', // Options Group
542
+ $section_id // Settings Section ID
543
+ );
544
+
545
+ // Register The Actual Settings Option
546
+ $args = array();
547
+
548
+ if ( isset( $option[ 'data_type' ] ) )
549
+ $args[ 'type' ] = $option[ 'data_type' ];
550
+
551
+ if ( isset( $option[ 'desc' ] ) )
552
+ $args[ 'description' ] = $option[ 'desc' ];
553
+
554
+ if ( isset( $option[ 'sanitation_cb' ] ) && is_callable( $option[ 'sanitation_cb' ] ) )
555
+ $args[ 'sanitize_callback' ] = $option[ 'sanitation_cb' ];
556
+
557
+ if ( isset( $option[ 'show_in_rest' ] ) )
558
+ $args[ 'show_in_rest' ] = $option[ 'show_in_rest' ];
559
+
560
+ if ( isset( $option[ 'default' ] ) )
561
+ $args[ 'default' ] = $option[ 'default' ]; // Important Note: This will be used on "get_option" function automatically if the current option is not registered yet to the options db.
562
+
563
+ register_setting( $section_id . '_options_group' , $option[ 'id' ] , $args );
564
+
565
+ }
566
+
567
+ }
568
+
569
+ }
570
+
571
+ /**
572
+ * Initialize Plugin Settings API.
573
+ * We register the plugin settings section and settings section options to WordPress Settings API.
574
+ * We let WordPress Settings API handle the backend stuff.
575
+ * We will handle the UI rendering.
576
+ *
577
+ * @since 3.0.0
578
+ * @access public
579
+ */
580
+ public function init_plugin_settings() {
581
+
582
+ $this->init_settings_sections_and_options();
583
+ $this->register_settings_section_and_options_group();
584
+ $this->register_settings_section_options();
585
+
586
+ }
587
+
588
+ /**
589
+ * Add settings page.
590
+ *
591
+ * @since 3.0.0
592
+ * @access public
593
+ */
594
+ public function add_settings_page() {
595
+
596
+ add_submenu_page(
597
+ 'edit.php?post_type=thirstylink',
598
+ __( 'ThirstyAffiliates Settings' , 'thirstyaffiliates' ),
599
+ __( 'Settings' , 'thirstyaffiliates' ),
600
+ 'manage_options',
601
+ 'thirsty-settings',
602
+ array( $this, 'view_settings_page' )
603
+ );
604
+
605
+ }
606
+
607
+ /**
608
+ * Settings page view.
609
+ *
610
+ * @since 3.0.0
611
+ * @access public
612
+ */
613
+ public function view_settings_page() {
614
+ ?>
615
+
616
+ <div class="wrap ta-settings">
617
+
618
+ <h2><?php _e( 'ThirstyAffiliates Settings' , 'thirstyaffiliates' ); ?></h2>
619
+
620
+ <?php
621
+ settings_errors(); // Show notices based on the outcome of the settings save action
622
+ $active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'ta_general_settings';
623
+ ?>
624
+
625
+ <h2 class="nav-tab-wrapper">
626
+ <?php foreach ( $this->_settings_sections as $section_key => $section_data ) { ?>
627
+ <a href="?post_type=thirstylink&page=thirsty-settings&tab=<?php echo $section_key; ?>" class="nav-tab <?php echo $active_tab == $section_key ? 'nav-tab-active' : ''; ?> <?php echo $section_key; ?>"><?php echo $section_data[ 'title' ]; ?></a>
628
+ <?php } ?>
629
+ </h2>
630
+
631
+ <?php do_action( 'ta_before_settings_form' ); ?>
632
+
633
+ <form method="post" action="options.php" enctype="multipart/form-data">
634
+
635
+ <?php
636
+ $this->render_settings_section_nonces( $active_tab );
637
+ $this->render_settings_section_header( $active_tab );
638
+ $this->render_settings_section_fields( $active_tab );
639
+ ?>
640
+
641
+ </form>
642
+
643
+ </div><!--wrap-->
644
+
645
+ <?php
646
+ }
647
+
648
+ /**
649
+ * Render all necessary nonces for the current settings section.
650
+ *
651
+ * @since 3.0.0
652
+ * @access public
653
+ *
654
+ * @param string $active_tab Currently active settings section.
655
+ */
656
+ public function render_settings_section_nonces( $active_tab ) {
657
+
658
+ settings_fields( $active_tab . '_options_group' );
659
+
660
+ }
661
+
662
+ /**
663
+ * Render the current settings section header markup.
664
+ *
665
+ * @since 3.0.0
666
+ * @access public
667
+ *
668
+ * @param string $active_tab Currently active settings section.
669
+ */
670
+ public function render_settings_section_header( $active_tab ) {
671
+
672
+ if ( ! isset( $this->_settings_sections[ $active_tab ] ) )
673
+ return;
674
+
675
+ ?>
676
+
677
+ <h2><?php echo $this->_settings_sections[ $active_tab ][ 'title' ]; ?></h2>
678
+ <p class="desc"><?php echo $this->_settings_sections[ $active_tab ][ 'desc' ]; ?></p>
679
+
680
+ <?php
681
+
682
+ }
683
+
684
+ /**
685
+ * Render an option as a hidden field.
686
+ * We do this if that option's condition callback failed.
687
+ * We don't show it for the end user, but we still need to pass on the form the current data so we don't lost it.
688
+ *
689
+ * @since 3.0.0
690
+ * @access public
691
+ *
692
+ * @param array $option Array of options data. May vary depending on option type.
693
+ */
694
+ public function render_option_as_hidden_field( $option ) {
695
+
696
+ if ( in_array( $option[ 'type' ] , $this->_skip_wp_settings_registration ) )
697
+ return; // This is a decorative option type, no need to render this as a hidden field
698
+
699
+ ?>
700
+
701
+ <input type="hidden" name="<?php echo esc_attr( $option[ 'id' ] ); ?>" value="<?php echo get_option( $option[ 'id' ] , '' ); ?>">
702
+
703
+ <?php
704
+
705
+ }
706
+
707
+ /**
708
+ * Render settings section option fields.
709
+ *
710
+ * @since 3.0.0
711
+ * @access public
712
+ *
713
+ * @param string $active_tab Currently active settings section.
714
+ */
715
+ public function render_settings_section_fields( $active_tab ) {
716
+
717
+ ?>
718
+
719
+ <table class="form-table">
720
+ <tbody>
721
+ <?php
722
+ foreach ( $this->_settings_section_options as $section_id => $section_options ) {
723
+
724
+ if ( $section_id !== $active_tab )
725
+ continue;
726
+
727
+ foreach ( $section_options as $option ) {
728
+
729
+ if ( isset( $option[ 'condition_cb' ] ) && is_callable( $option[ 'condition_cb' ] ) && !$option[ 'condition_cb' ]() )
730
+ $this->render_option_as_hidden_field( $option ); // Option condition failed. Render it as a hidden field so its value is preserved
731
+ else
732
+ $this->_supported_field_types[ $option[ 'type' ] ]( $option );
733
+
734
+ // if ( $option[ 'type' ] === 'editor' )
735
+ // add_filter( );
736
+
737
+ }
738
+
739
+ }
740
+ ?>
741
+ </tbody>
742
+ </table>
743
+
744
+ <p class="submit">
745
+ <input name="submit" id="submit" class="button button-primary" value="<?php _e( 'Save Changes' , 'thirstyaffiliates' ); ?>" type="submit">
746
+ </p>
747
+
748
+ <?php
749
+
750
+ }
751
+
752
+
753
+
754
+
755
+ /*
756
+ |--------------------------------------------------------------------------
757
+ | Option Field Views
758
+ |--------------------------------------------------------------------------
759
+ */
760
+
761
+ /**
762
+ * Render 'text' type option field.
763
+ *
764
+ * @since 3.0.0
765
+ * @access public
766
+ *
767
+ * @param array $option Array of options data. May vary depending on option type.
768
+ */
769
+ public function render_text_option_field( $option ) {
770
+
771
+ ?>
772
+
773
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
774
+
775
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
776
+
777
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
778
+ <input
779
+ type = "text"
780
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
781
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
782
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
783
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : 'width: 360px;'; ?>"
784
+ value = "<?php echo get_option( $option[ 'id' ] ); ?>" >
785
+ <br>
786
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
787
+ </td>
788
+
789
+ </tr>
790
+
791
+ <?php
792
+
793
+ }
794
+
795
+ /**
796
+ * Render 'text' type option field.
797
+ *
798
+ * @since 3.0.0
799
+ * @access public
800
+ *
801
+ * @param array $option Array of options data. May vary depending on option type.
802
+ */
803
+ public function render_number_option_field( $option ) {
804
+
805
+ ?>
806
+
807
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
808
+
809
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
810
+
811
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
812
+ <input
813
+ type = "number"
814
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
815
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
816
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
817
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : 'width: 100px;'; ?>"
818
+ value = "<?php echo get_option( $option[ 'id' ] ); ?>"
819
+ min = "<?php echo isset( $option[ 'min' ] ) ? $option[ 'min' ] : 0; ?>"
820
+ max = "<?php echo isset( $option[ 'max' ] ) ? $option[ 'max' ] : ''; ?>" >
821
+ <span><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></span>
822
+ </td>
823
+
824
+ </tr>
825
+
826
+ <?php
827
+
828
+ }
829
+
830
+ /**
831
+ * Render 'textarea' type option field.
832
+ *
833
+ * @since 3.0.0
834
+ * @access public
835
+ *
836
+ * @param array $option Array of options data. May vary depending on option type.
837
+ */
838
+ public function render_textarea_option_field( $option ) {
839
+
840
+ ?>
841
+
842
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
843
+
844
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
845
+
846
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
847
+ <textarea
848
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
849
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
850
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
851
+ cols = "60"
852
+ rows = "8"
853
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : 'width: 360px;'; ?>"><?php echo get_option( $option[ 'id' ] ); ?></textarea>
854
+ <br />
855
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
856
+ </td>
857
+
858
+ </tr>
859
+
860
+ <?php
861
+
862
+ }
863
+
864
+ /**
865
+ * Render 'checkbox' type option field.
866
+ *
867
+ * @since 3.0.0
868
+ * @access public
869
+ *
870
+ * @param array $option Array of options data. May vary depending on option type.
871
+ */
872
+ public function render_checkbox_option_field( $option ) {
873
+
874
+ $option_val = get_option( $option[ 'id' ] );
875
+ if ( !is_array( $option_val ) )
876
+ $option_val = array(); ?>
877
+
878
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
879
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
880
+
881
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
882
+ <?php foreach ( $option[ 'options' ] as $opt_key => $opt_text ) {
883
+
884
+ $opt_key_class = str_replace( " " , "-" , $opt_key ); ?>
885
+
886
+ <input
887
+ type = "checkbox"
888
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>[]"
889
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
890
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
891
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : ''; ?>"
892
+ value = "<?php echo $opt_key; ?>"
893
+ <?php echo in_array( $opt_key , $option_val ) ? 'checked' : ''; ?>>
894
+
895
+ <label class="<?php echo esc_attr( $option[ 'id' ] ); ?>"><?php echo $opt_text; ?></label>
896
+ <br>
897
+
898
+ <?php } ?>
899
+
900
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
901
+ </td>
902
+
903
+ <script>
904
+ jQuery( document ).ready( function( $ ) {
905
+
906
+ $( "label.<?php echo esc_attr( $option[ 'id' ] ); ?>" ).on( "click" , function() {
907
+
908
+ $( this ).prev( "input[type='checkbox']" ).trigger( "click" );
909
+
910
+ } );
911
+
912
+ } );
913
+ </script>
914
+ </tr>
915
+
916
+ <?php
917
+
918
+ }
919
+
920
+ /**
921
+ * Render 'radio' type option field.
922
+ *
923
+ * @since 3.0.0
924
+ * @access public
925
+ *
926
+ * @param array $option Array of options data. May vary depending on option type.
927
+ */
928
+ public function render_radio_option_field( $option ) {
929
+
930
+ $option_val = get_option( $option[ 'id' ] ); ?>
931
+
932
+
933
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
934
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
935
+
936
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
937
+ <?php foreach ( $option[ 'options' ] as $opt_key => $opt_text ) { ?>
938
+
939
+ <input
940
+ type = "radio"
941
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
942
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
943
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
944
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : ''; ?>"
945
+ value = "<?php echo $opt_key; ?>"
946
+ <?php echo $opt_key == $option_val ? 'checked' : ''; ?>>
947
+
948
+ <label class="<?php echo esc_attr( $option[ 'id' ] ); ?>"><?php echo $opt_text; ?></label>
949
+ <br>
950
+
951
+ <?php } ?>
952
+
953
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
954
+ </td>
955
+
956
+ <script>
957
+ jQuery( document ).ready( function( $ ) {
958
+
959
+ $( "label.<?php echo esc_attr( $option[ 'id' ] ); ?>" ).on( "click" , function() {
960
+
961
+ $( this ).prev( "input[type='radio']" ).trigger( "click" );
962
+
963
+ } );
964
+
965
+ } );
966
+ </script>
967
+ </tr>
968
+
969
+ <?php
970
+
971
+ }
972
+
973
+ /**
974
+ * Render 'select' type option field.
975
+ *
976
+ * @since 3.0.0
977
+ * @access public
978
+ *
979
+ * @param array $option Array of options data. May vary depending on option type.
980
+ */
981
+ public function render_select_option_field( $option ) {
982
+
983
+ $allow_deselect = isset( $option[ 'allow_deselect' ] ) && $option[ 'allow_deselect' ]; ?>
984
+
985
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
986
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
987
+
988
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
989
+ <select
990
+ data-placeholder = "<?php echo isset( $option[ 'placeholder' ] ) ? $option[ 'placeholder' ] : 'Choose an option...' ; ?>"
991
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
992
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
993
+ class = "option-field chosen-select <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
994
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : 'width:360px;'; ?>">
995
+
996
+ <?php if ( $allow_deselect ) { ?>
997
+ <option value=""></option>
998
+ <?php } ?>
999
+
1000
+ <?php foreach ( $option[ 'options' ] as $opt_key => $opt_text ) { ?>
1001
+
1002
+ <option value="<?php echo $opt_key; ?>" <?php echo get_option( $option[ 'id' ] ) === $opt_key ? 'selected' : ''; ?>><?php echo $opt_text; ?></option>
1003
+
1004
+ <?php } ?>
1005
+ </select>
1006
+ <br>
1007
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1008
+ </td>
1009
+
1010
+ <script>
1011
+ jQuery( document ).ready( function( $ ) {
1012
+
1013
+ <?php echo $allow_deselect ? 'var allow_deselect = true;' : 'var allow_deselect = false;'; ?>
1014
+
1015
+ $( '#<?php echo esc_attr( $option[ 'id' ] ); ?>' ).chosen( { allow_single_deselect : allow_deselect } );
1016
+
1017
+ } );
1018
+ </script>
1019
+ </tr>
1020
+
1021
+ <?php
1022
+
1023
+ }
1024
+
1025
+ /**
1026
+ * Render 'multiselect' type option field.
1027
+ *
1028
+ * @since 3.0.0
1029
+ * @access public
1030
+ *
1031
+ * @param array $option Array of options data. May vary depending on option type.
1032
+ */
1033
+ public function render_multiselect_option_field( $option ) {
1034
+
1035
+ $option_val = get_option( $option[ 'id' ] );
1036
+ if ( !is_array( $option_val ) )
1037
+ $option_val = array(); ?>
1038
+
1039
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1040
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
1041
+
1042
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1043
+ <select
1044
+ multiple
1045
+ data-placeholder = "<?php echo isset( $option[ 'placeholder' ] ) ? $option[ 'placeholder' ] : 'Choose an option...' ; ?>"
1046
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>[]"
1047
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
1048
+ class = "option-field chosen-select <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
1049
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : 'width:360px;'; ?>">
1050
+
1051
+ <?php foreach ( $option[ 'options' ] as $opt_key => $opt_text ) { ?>
1052
+
1053
+ <option value="<?php echo $opt_key; ?>" <?php echo in_array( $opt_key , $option_val ) ? 'selected="selected"' : ''; ?>><?php echo $opt_text; ?></option>
1054
+
1055
+ <?php } ?>
1056
+ </select>
1057
+ <br>
1058
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1059
+ </td>
1060
+
1061
+ <script>
1062
+ jQuery( document ).ready( function( $ ) {
1063
+
1064
+ $( '#<?php echo esc_attr( $option[ 'id' ] ); ?>' ).chosen();
1065
+
1066
+ } );
1067
+ </script>
1068
+ </tr>
1069
+
1070
+ <?php
1071
+
1072
+ }
1073
+
1074
+ /**
1075
+ * Render 'toggle' type option field.
1076
+ * Basically a single check box style option field.
1077
+ *
1078
+ * @since 3.0.0
1079
+ * @access public
1080
+ *
1081
+ * @param array $option Array of options data. May vary depending on option type.
1082
+ */
1083
+ public function render_toggle_option_field( $option ) {
1084
+
1085
+ ?>
1086
+
1087
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1088
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
1089
+
1090
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1091
+ <input
1092
+ type = "checkbox"
1093
+ name = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
1094
+ id = "<?php echo esc_attr( $option[ 'id' ] ); ?>"
1095
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
1096
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : ''; ?>"
1097
+ value = "yes"
1098
+ <?php echo get_option( $option[ 'id' ] ) === "yes" ? 'checked' : ''; ?>>
1099
+ <label class="<?php echo esc_attr( $option[ 'id' ] ); ?>"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></label>
1100
+ </td>
1101
+
1102
+ <script>
1103
+ jQuery( document ).ready( function( $ ) {
1104
+
1105
+ $( "label.<?php echo esc_attr( $option[ 'id' ] ); ?>" ).on( "click" , function() {
1106
+
1107
+ $( this ).prev( "input[type='checkbox']" ).trigger( "click" );
1108
+
1109
+ } );
1110
+
1111
+ } );
1112
+ </script>
1113
+ </tr>
1114
+
1115
+ <?php
1116
+
1117
+ }
1118
+
1119
+ /**
1120
+ * Render 'editor' type option field.
1121
+ *
1122
+ * @since 3.0.0
1123
+ * @access public
1124
+ *
1125
+ * @param array $option Array of options data. May vary depending on option type.
1126
+ */
1127
+ public function render_editor_option_field( $option ) {
1128
+
1129
+ $editor_value = html_entity_decode( get_option( $option[ 'id' ] ) ); ?>
1130
+
1131
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1132
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
1133
+
1134
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1135
+ <style type="text/css"><?php echo "div#wp-" . $option[ 'id' ] . "-wrap{ width: 70% !important; }"; ?></style>
1136
+
1137
+ <?php wp_editor( $editor_value , $option[ 'id' ] , array(
1138
+ 'wpautop' => true,
1139
+ 'textarea_name' => $option[ 'id' ],
1140
+ 'editor_height' => '300'
1141
+ ) ); ?>
1142
+ <br>
1143
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1144
+ </td>
1145
+ </tr>
1146
+
1147
+ <?php
1148
+
1149
+ }
1150
+
1151
+ /**
1152
+ * Render 'csv' type option field.
1153
+ *
1154
+ * @since 3.0.0
1155
+ * @access public
1156
+ *
1157
+ * @param array $option Array of options data. May vary depending on option type.
1158
+ */
1159
+ public function render_csv_option_field( $option ) {
1160
+
1161
+ ?>
1162
+
1163
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1164
+ <th scope="row"><?php echo $option[ 'title' ]; ?></th>
1165
+
1166
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1167
+ <input
1168
+ type = "text"
1169
+ name = "<?php echo $option[ 'id' ]; ?>"
1170
+ id = "<?php echo $option[ 'id' ]; ?>"
1171
+ class = "option-field <?php echo isset( $option[ 'class' ] ) ? $option[ 'class' ] : ''; ?>"
1172
+ style = "<?php echo isset( $option[ 'style' ] ) ? $option[ 'style' ] : 'width: 360px;'; ?>"
1173
+ value = "<?php echo get_option( $option[ 'id' ] ); ?>" >
1174
+ <br>
1175
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1176
+ </td>
1177
+
1178
+ <script>
1179
+ jQuery( document ).ready( function( $ ) {
1180
+
1181
+ $( '#<?php echo $option[ 'id' ]; ?>' ).selectize( {
1182
+ plugins : [ 'restore_on_backspace' , 'remove_button' , 'drag_drop' ],
1183
+ delimiter : ',',
1184
+ persist : false,
1185
+ create : function( input ) {
1186
+ return {
1187
+ value: input,
1188
+ text: input
1189
+ }
1190
+ }
1191
+ } );
1192
+
1193
+ } );
1194
+ </script>
1195
+ </tr>
1196
+
1197
+ <?php
1198
+
1199
+ }
1200
+
1201
+ /**
1202
+ * Render 'key_value' type option field. Do not need to be registered to WP Settings API.
1203
+ *
1204
+ * @since 3.0.0
1205
+ * @access public
1206
+ *
1207
+ * @param array $option Array of options data. May vary depending on option type.
1208
+ */
1209
+ public function render_key_value_option_field( $option ) {
1210
+
1211
+ $option_value = get_option( $option[ 'id' ] );
1212
+ if ( !is_array( $option_value ) )
1213
+ $option_value = array(); ?>
1214
+
1215
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1216
+ <th scope="row"><?php echo $option[ 'title' ]; ?></th>
1217
+
1218
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1219
+
1220
+ <div class="key-value-fields-container" data-field-id="<?php echo $option[ 'id' ]; ?>">
1221
+
1222
+ <header>
1223
+ <span class="key"><?php _e( 'Key' , 'thirstyaffiliates' ); ?></span>
1224
+ <span class="value"><?php _e( 'Value' , 'thirstyaffiliates' ); ?></span>
1225
+ </header>
1226
+
1227
+ <div class="fields">
1228
+
1229
+ <?php if ( empty( $option_value ) ) { ?>
1230
+
1231
+ <div class="data-set">
1232
+ <input type="text" class="field key-field">
1233
+ <input type="text" class="field value-field">
1234
+ <div class="controls">
1235
+ <span class="control add dashicons dashicons-plus-alt" autocomplete="off"></span>
1236
+ <span class="control delete dashicons dashicons-dismiss" autocomplete="off"></span>
1237
+ </div>
1238
+ </div>
1239
+
1240
+ <?php } else {
1241
+
1242
+ foreach ( $option_value as $key => $val ) { ?>
1243
+
1244
+ <div class="data-set">
1245
+ <input type="text" class="field key-field" value="<?php echo $key; ?>">
1246
+ <input type="text" class="field value-field" value="<?php echo $val; ?>">
1247
+ <div class="controls">
1248
+ <span class="control add dashicons dashicons-plus-alt" autocomplete="off"></span>
1249
+ <span class="control delete dashicons dashicons-dismiss" autocomplete="off"></span>
1250
+ </div>
1251
+ </div>
1252
+
1253
+ <?php }
1254
+
1255
+ } ?>
1256
+
1257
+ </div>
1258
+
1259
+ </div>
1260
+
1261
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1262
+
1263
+ </td>
1264
+ </tr>
1265
+
1266
+ <?php
1267
+
1268
+ }
1269
+
1270
+ /**
1271
+ * Render 'link' type option field. Do not need to be registered to WP Settings API.
1272
+ *
1273
+ * @since 3.0.0
1274
+ * @access public
1275
+ *
1276
+ * @param array $option Array of options data. May vary depending on option type.
1277
+ */
1278
+ public function render_link_option_field( $option ) {
1279
+
1280
+ ?>
1281
+
1282
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1283
+ <th scope="row"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
1284
+ <td>
1285
+ <a id="<?php echo esc_attr( $option[ 'id' ] ); ?>" href="<?php echo $option[ 'link_url' ]; ?>" target="_blank"><?php echo $option[ 'link_text' ]; ?></a>
1286
+ <br>
1287
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1288
+ </td>
1289
+ </tr>
1290
+
1291
+ <?php
1292
+
1293
+ }
1294
+
1295
+ /**
1296
+ * Render option divider. Decorative field. Do not need to be registered to WP Settings API.
1297
+ *
1298
+ * @since 3.0.0
1299
+ * @access public
1300
+ *
1301
+ * @param array $option Array of options data. May vary depending on option type.
1302
+ */
1303
+ public function render_option_divider_option_field( $option ) {
1304
+
1305
+ ?>
1306
+
1307
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1308
+ <th scope="row" colspan="2">
1309
+ <h3><?php echo sanitize_text_field( $option[ 'title' ] ); ?></h3>
1310
+ <?php echo isset( $option[ 'markup' ] ) ? $option[ 'markup' ] : ''; ?>
1311
+ </th>
1312
+ </tr>
1313
+
1314
+ <?php
1315
+
1316
+ }
1317
+
1318
+ /**
1319
+ * Render custom "migration_controls" field. Do not need to be registered to WP Settings API.
1320
+ *
1321
+ * @since 3.0.0
1322
+ * @access public
1323
+ *
1324
+ * @param array $option Array of options data. May vary depending on option type.
1325
+ */
1326
+ public function render_migration_controls_option_field( $option ) {
1327
+
1328
+ $database_processing = apply_filters( 'ta_database_processing' , true ); // Flag to determine if another application is processing the db. ex. data downgrade.
1329
+ $processing = "";
1330
+ $disabled = false;
1331
+
1332
+ if ( get_option( Plugin_Constants::MIGRATION_COMPLETE_FLAG ) === 'no' ) {
1333
+
1334
+ $processing = "-processing";
1335
+ $disabled = true;
1336
+
1337
+ } ?>
1338
+
1339
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1340
+
1341
+ <th scope="row" class="title_desc"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
1342
+
1343
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?> <?php echo $processing; ?>">
1344
+
1345
+ <?php if ( !$database_processing ) { ?>
1346
+
1347
+ <p><?php _e( 'Another application is currently processing the database. Please wait for this to complete.' , 'thirstyaffiliates' ); ?></p>
1348
+
1349
+ <?php } else { ?>
1350
+
1351
+ <input
1352
+ <?php echo $disabled ? "disabled" : ""; ?>
1353
+ type="button"
1354
+ id="<?php echo esc_attr( $option[ 'id' ] ); ?>"
1355
+ class="button button-primary"
1356
+ style="<?php echo isset( $option[ 'style' ] ) ? esc_attr( $option[ 'style' ] ) : ''; ?>"
1357
+ value="<?php _e( 'Migrate' , 'thirstyaffiliates' ); ?>">
1358
+
1359
+ <span class="spinner"></span>
1360
+ <p class="status"><?php _e( 'Migrating data. Please wait...' , 'thirstyaffiliates' ); ?></p>
1361
+
1362
+ <?php } ?>
1363
+
1364
+ <br /><br />
1365
+ <p class="desc"><?php echo isset( $option[ 'desc' ] ) ? $option[ 'desc' ] : ''; ?></p>
1366
+
1367
+ </td>
1368
+
1369
+ </tr>
1370
+
1371
+ <?php
1372
+
1373
+ }
1374
+
1375
+ /**
1376
+ * Render custom "export_global_settings" field. Do not need to be registered to WP Settings API.
1377
+ *
1378
+ * @since 3.0.0
1379
+ * @access public
1380
+ *
1381
+ * @param array $option Array of options data. May vary depending on option type.
1382
+ */
1383
+ public function render_export_global_settings_option_field( $option ) {
1384
+
1385
+ $global_settings_string = $this->get_global_settings_string(); ?>
1386
+
1387
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1388
+ <th scope="row" class="title_desc"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></th>
1389
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1390
+ <textarea
1391
+ name="<?php echo esc_attr( $option[ 'id' ] ); ?>"
1392
+ id="<?php echo esc_attr( $option[ 'id' ] ); ?>"
1393
+ style="<?php echo isset( $option[ 'style' ] ) ? esc_attr( $option[ 'style' ] ) : ''; ?>"
1394
+ class="<?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
1395
+ placeholder="<?php echo isset( $option[ 'placeholder' ] ) ? esc_attr( $option[ 'placeholder' ] ) : ''; ?>"
1396
+ autocomplete="off"
1397
+ readonly
1398
+ rows="10"><?php echo $global_settings_string; ?></textarea>
1399
+ <div class="controls">
1400
+ <a id="copy-settings-string" data-clipboard-target="#<?php echo esc_attr( $option[ 'id' ] ); ?>"><?php _e( 'Copy' , 'thirstyaffiliates' ); ?></a>
1401
+ </div>
1402
+ </td>
1403
+ </tr>
1404
+
1405
+ <?php
1406
+
1407
+ }
1408
+
1409
+ /**
1410
+ * Render custom "import_global_settings" field. Do not need to be registered to WP Settings API.
1411
+ *
1412
+ * @since 3.0.0
1413
+ * @access public
1414
+ *
1415
+ * @param array $option Array of options data. May vary depending on option type.
1416
+ */
1417
+ public function render_import_global_settings_option_field( $option ) {
1418
+
1419
+ ?>
1420
+
1421
+ <tr valign="top" class="<?php echo esc_attr( $option[ 'id' ] ) . '-row'; ?>">
1422
+ <th scope="row" class="title_desc">
1423
+ <label for="<?php echo esc_attr( $option[ 'id' ] ); ?>"><?php echo sanitize_text_field( $option[ 'title' ] ); ?></label>
1424
+ </th>
1425
+ <td class="forminp forminp-<?php echo sanitize_title( $option[ 'type' ] ) ?>">
1426
+ <textarea
1427
+ name="<?php echo esc_attr( $option[ 'id' ] ); ?>"
1428
+ id="<?php echo esc_attr( $option[ 'id' ] ); ?>"
1429
+ style="<?php echo isset( $option[ 'style' ] ) ? esc_attr( $option[ 'style' ] ) : ''; ?>"
1430
+ class="<?php echo isset( $option[ 'class' ] ) ? esc_attr( $option[ 'class' ] ) : ''; ?>"
1431
+ placeholder="<?php echo esc_attr( $option[ 'placeholder' ] ); ?>"
1432
+ autocomplete="off"
1433
+ rows="10"></textarea>
1434
+ <p class="desc"><?php echo isset( $option[ 'description' ] ) ? $option[ 'description' ] : ''; ?></p>
1435
+ <div class="controls">
1436
+ <span class="spinner"></span>
1437
+ <input type="button" id="import-setting-button" class="button button-primary" value="<?php _e( 'Import Settings' , 'thirstyaffiliates' ); ?>">
1438
+ </di>
1439
+ </td>
1440
+ </tr>
1441
+
1442
+ <?php
1443
+
1444
+ }
1445
+
1446
+
1447
+
1448
+
1449
+ /*
1450
+ |--------------------------------------------------------------------------
1451
+ | "key_value" option field type helpers
1452
+ |--------------------------------------------------------------------------
1453
+ */
1454
+
1455
+ /**
1456
+ * Load styling relating to 'key_value' field type.
1457
+ *
1458
+ * @since 3.0.0
1459
+ * @access public
1460
+ */
1461
+ public function load_key_value_option_field_type_styling() {
1462
+
1463
+ ?>
1464
+
1465
+ <style>
1466
+ .key-value-fields-container header span {
1467
+ display: inline-block;
1468
+ font-weight: 600;
1469
+ margin-bottom: 8px;
1470
+ }
1471
+ .key-value-fields-container header .key {
1472
+ width: 144px;
1473
+ }
1474
+ .key-value-fields-container header .value {
1475
+ width: 214px;
1476
+ }
1477
+ .key-value-fields-container .fields .data-set {
1478
+ margin-bottom: 8px;
1479
+ }
1480
+ .key-value-fields-container .fields .data-set:last-child {
1481
+ margin-bottom: 0;
1482
+ }
1483
+ .key-value-fields-container .fields .data-set .key-field {
1484
+ width: 140px;
1485
+ margin-left: 0;
1486
+ }
1487
+ .key-value-fields-container .fields .data-set .value-field {
1488
+ width: 215px;
1489
+ }
1490
+ .key-value-fields-container .fields .data-set .controls {
1491
+ display: none;
1492
+ }
1493
+ .key-value-fields-container .fields .data-set:hover .controls {
1494
+ display: inline-block;
1495
+ }
1496
+ .key-value-fields-container .fields .data-set .controls .control {
1497
+ cursor: pointer;
1498
+ }
1499
+ .key-value-fields-container .fields .data-set .controls .add {
1500
+ color: green;
1501
+ }
1502
+ .key-value-fields-container .fields .data-set .controls .delete {
1503
+ color: red;
1504
+ }
1505
+ </style>
1506
+
1507
+ <?php
1508
+
1509
+ }
1510
+
1511
+ /**
1512
+ * Load scripts relating to 'key_value' field type.
1513
+ *
1514
+ * @since 3.0.0
1515
+ * @access public
1516
+ */
1517
+ public function load_key_value_option_field_type_script() {
1518
+
1519
+ ?>
1520
+
1521
+ <script>
1522
+
1523
+ jQuery( document ).ready( function( $ ) {
1524
+
1525
+ // Hide the delete button if only 1 data set is available
1526
+ function init_data_set_controls() {
1527
+
1528
+ $( ".key-value-fields-container" ).each( function() {
1529
+
1530
+ if ( $( this ).find( ".data-set" ).length === 1 )
1531
+ $( this ).find( ".data-set .controls .delete" ).css( "display" , "none" );
1532
+ else
1533
+ $( this ).find( ".data-set .controls .delete" ).removeAttr( "style" );
1534
+
1535
+ } );
1536
+
1537
+ }
1538
+
1539
+ init_data_set_controls();
1540
+
1541
+
1542
+ // Attach "add" and "delete" events
1543
+ $( ".key-value-fields-container" ).on( "click" , ".controls .add" , function() {
1544
+
1545
+ let $data_set = $( this ).closest( '.data-set' );
1546
+
1547
+ $data_set.after( "<div class='data-set'>" +
1548
+ "<input type='text' class='field key-field' autocomplete='off'> " +
1549
+ "<input type='text' class='field value-field' autocomplete='off'>" +
1550
+ "<div class='controls'>" +
1551
+ "<span class='control add dashicons dashicons-plus-alt'></span>" +
1552
+ "<span class='control delete dashicons dashicons-dismiss'></span>" +
1553
+ "</div>" +
1554
+ "</div>" );
1555
+
1556
+ init_data_set_controls();
1557
+
1558
+ } );
1559
+
1560
+ $( ".key-value-fields-container" ).on( "click" , ".controls .delete" , function() {
1561
+
1562
+ let $data_set = $( this ).closest( '.data-set' );
1563
+
1564
+ $data_set.remove();
1565
+
1566
+ init_data_set_controls();
1567
+
1568
+ } );
1569
+
1570
+
1571
+ // Construct hidden fields for each of "key_value" option field types upon form submission
1572
+ $( "form" ).submit( function() {
1573
+
1574
+ $( ".key-value-fields-container" ).each( function() {
1575
+
1576
+ var $this = $( this ),
1577
+ field_id = $this.attr( "data-field-id" ),
1578
+ field_inputs = "";
1579
+
1580
+ $this.find( ".data-set" ).each( function() {
1581
+
1582
+ var $this = $( this ),
1583
+ key_field = $.trim( $this.find( ".key-field" ).val() ),
1584
+ value_field = $.trim( $this.find( ".value-field" ).val() );
1585
+
1586
+ if ( key_field !== "" && value_field !== "" )
1587
+ field_inputs += "<input type='hidden' name='" + field_id + "[" + key_field + "]' value='" + value_field + "'>";
1588
+
1589
+ } );
1590
+
1591
+ $this.append( field_inputs );
1592
+
1593
+ } );
1594
+
1595
+ } );
1596
+
1597
+ } );
1598
+
1599
+ </script>
1600
+
1601
+ <?php
1602
+
1603
+ }
1604
+
1605
+
1606
+
1607
+
1608
+ /*
1609
+ |--------------------------------------------------------------------------
1610
+ | Settings helper
1611
+ |--------------------------------------------------------------------------
1612
+ */
1613
+
1614
+ /**
1615
+ * Get global settings string via ajax.
1616
+ *
1617
+ * @since 3.0.0
1618
+ * @access public
1619
+ */
1620
+ public function ajax_get_global_settings_string() {
1621
+
1622
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
1623
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
1624
+ else {
1625
+
1626
+ $global_settings_string = $this->get_global_settings_string();
1627
+
1628
+ if ( is_wp_error( $global_settings_string ) )
1629
+ $response = array( 'status' => 'fail' , 'error_msg' => $global_settings_string->get_error_message() );
1630
+ else
1631
+ $response = array( 'status' => 'success' , 'global_settings_string' => $global_settings_string );
1632
+
1633
+ }
1634
+
1635
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1636
+ echo wp_json_encode( $response );
1637
+ wp_die();
1638
+
1639
+ }
1640
+
1641
+ /**
1642
+ * Get global settings string.
1643
+ *
1644
+ * @since 3.0.0
1645
+ * @access public
1646
+ *
1647
+ * @return WP_Error|string WP_Error on error, Base 64 encoded serialized global plugin settings otherwise.
1648
+ */
1649
+ public function get_global_settings_string() {
1650
+
1651
+ if ( !$this->_helper_functions->current_user_authorized() )
1652
+ return new \WP_Error( 'ta_unauthorized_operation_export_settings' , __( 'Unauthorized operation. Only authorized accounts can access global plugin settings string' , 'thirstyaffiliates' ) );
1653
+
1654
+ $global_settings_arr = array();
1655
+ foreach ( $this->_exportable_options as $key => $default )
1656
+ $global_settings_arr[ $key ] = get_option( $key , $default );
1657
+
1658
+ return base64_encode( serialize( $global_settings_arr ) );
1659
+
1660
+ }
1661
+
1662
+ /**
1663
+ * Import settings via ajax.
1664
+ *
1665
+ * @access public
1666
+ * @since 3.0.0
1667
+ */
1668
+ public function ajax_import_settings() {
1669
+
1670
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
1671
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
1672
+ elseif ( !isset( $_POST[ 'ta_settings_string' ] ) )
1673
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Required parameter not passed' , 'thirstyaffiliates' ) );
1674
+ else {
1675
+
1676
+ $result = $this->import_settings( filter_var( $_POST[ 'ta_settings_string' ] , FILTER_SANITIZE_STRING ) );
1677
+
1678
+ if ( is_wp_error( $result ) )
1679
+ $response = array( 'status' => 'fail' , 'error_msg' => $result->get_error_message() );
1680
+ else
1681
+ $response = array( 'status' => 'success' , 'success_msg' => __( 'Settings successfully imported' , 'thirstyaffiliates' ) );
1682
+
1683
+ }
1684
+
1685
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
1686
+ echo wp_json_encode( $response );
1687
+ wp_die();
1688
+
1689
+ }
1690
+
1691
+ /**
1692
+ * Import settings from external global settings string.
1693
+ *
1694
+ * @since 3.0.0
1695
+ * @access public
1696
+ *
1697
+ * @param string $global_settings_string Settings string.
1698
+ * @return WP_Error | boolean WP_Error instance on failure, boolean true otherwise.
1699
+ */
1700
+ public function import_settings( $global_settings_string ) {
1701
+
1702
+ if ( !$this->_helper_functions->current_user_authorized() )
1703
+ return new \WP_Error( 'ta_unauthorized_operation_import_settings' , __( 'Unauthorized operation. Only authorized accounts can import settings' , 'thirstyaffiliates' ) );
1704
+
1705
+ $settings_arr = @unserialize( base64_decode( $global_settings_string ) );
1706
+
1707
+ if ( !is_array( $settings_arr ) )
1708
+ return new \WP_Error( 'ta_invalid_global_settings_string' , __( 'Invalid global settings string' , 'thirstyaffiliates' ) , array( 'global_settings_string' => $global_settings_string ) );
1709
+ else {
1710
+
1711
+ foreach ( $settings_arr as $key => $val ) {
1712
+
1713
+ if ( !array_key_exists( $key , $this->_exportable_options ) )
1714
+ continue;
1715
+
1716
+ update_option( $key , $val );
1717
+
1718
+ }
1719
+
1720
+ return true;
1721
+
1722
+ }
1723
+
1724
+ }
1725
+
1726
+ /**
1727
+ * Post update option callback for link prefix options.
1728
+ *
1729
+ * @since 3.0.0
1730
+ * @access public
1731
+ *
1732
+ * @param string $old_value Old option value before the update.
1733
+ * @param string $value New value saved.
1734
+ * @param string $option Option id.
1735
+ */
1736
+ public function link_prefix_post_update_callback( $value , $old_value , $option ) {
1737
+
1738
+ if ( $option === 'ta_link_prefix' && $value === 'custom' )
1739
+ return $value;
1740
+
1741
+ if ( $option === 'ta_link_prefix_custom' && get_option( 'ta_link_prefix' ) !== 'custom' )
1742
+ return $value;
1743
+
1744
+ $used_link_prefixes = maybe_unserialize( get_option( 'ta_used_link_prefixes' , array() ) );
1745
+ $check_duplicate = array_search( $value , $used_link_prefixes );
1746
+
1747
+ if ( $check_duplicate !== false )
1748
+ unset( $used_link_prefixes[ $check_duplicate ] );
1749
+
1750
+ $used_link_prefixes[] = sanitize_text_field( $value );
1751
+ $count = count( $used_link_prefixes );
1752
+
1753
+ if ( $count > 10 )
1754
+ $used_link_prefixes = array_slice( $used_link_prefixes , $count - 10 , 10 , false );
1755
+
1756
+ update_option( 'ta_used_link_prefixes' , array_unique( $used_link_prefixes ) );
1757
+
1758
+ return $value;
1759
+ }
1760
+
1761
+
1762
+
1763
+
1764
+ /*
1765
+ |--------------------------------------------------------------------------
1766
+ | Implemented Interface Methods
1767
+ |--------------------------------------------------------------------------
1768
+ */
1769
+
1770
+ /**
1771
+ * Execute codes that needs to run plugin activation.
1772
+ *
1773
+ * @since 3.0.0
1774
+ * @access public
1775
+ * @implements ThirstyAffiliates\Interfaces\Activatable_Interface
1776
+ */
1777
+ public function activate() {
1778
+
1779
+ if ( get_option( 'ta_settings_initialized' ) !== 'yes' ) {
1780
+
1781
+ update_option( 'ta_link_prefix' , 'recommends' );
1782
+ update_option( 'ta_link_prefix_custom' , '' );
1783
+ update_option( 'ta_used_link_prefixes' , array( 'recommends' ) );
1784
+ update_option( 'ta_settings_initialized' , 'yes' );
1785
+ }
1786
+ }
1787
+
1788
+ /**
1789
+ * Execute codes that needs to run on plugin initialization.
1790
+ *
1791
+ * @since 3.0.0
1792
+ * @access public
1793
+ * @implements ThirstyAffiliates\Interfaces\Initiable_Interface
1794
+ */
1795
+ public function initialize() {
1796
+
1797
+ add_action( 'wp_ajax_ta_get_global_settings_string' , array( $this , 'ajax_get_global_settings_string' ) );
1798
+ add_action( 'wp_ajax_ta_import_settings' , array( $this , 'ajax_import_settings' ) );
1799
+
1800
+ }
1801
+
1802
+ /**
1803
+ * Execute model.
1804
+ *
1805
+ * @implements WordPress_Plugin_Boilerplate\Interfaces\Model_Interface
1806
+ *
1807
+ * @since 3.0.0
1808
+ * @access public
1809
+ */
1810
+ public function run() {
1811
+
1812
+ add_action( 'admin_init' , array( $this , 'init_plugin_settings' ) );
1813
+ add_action( 'admin_menu' , array( $this , 'add_settings_page' ) );
1814
+
1815
+ add_action( 'ta_before_settings_form' , array( $this , 'load_key_value_option_field_type_styling' ) );
1816
+ add_action( 'ta_before_settings_form' , array( $this , 'load_key_value_option_field_type_script' ) );
1817
+ add_action( 'pre_update_option_ta_link_prefix' , array( $this , 'link_prefix_post_update_callback' ) , 10 , 3 );
1818
+ add_action( 'pre_update_option_ta_link_prefix_custom' , array( $this , 'link_prefix_post_update_callback' ) , 10 , 3 );
1819
+ }
1820
+
1821
+ }
Models/Shortcodes.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+
9
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
10
+ use ThirstyAffiliates\Helpers\Helper_Functions;
11
+
12
+ /**
13
+ * Model that houses the logic for permalink rewrites and affiliate link redirections.
14
+ *
15
+ * @since 3.0.0
16
+ */
17
+ class Shortcodes implements Model_Interface {
18
+
19
+ /*
20
+ |--------------------------------------------------------------------------
21
+ | Class Properties
22
+ |--------------------------------------------------------------------------
23
+ */
24
+
25
+ /**
26
+ * Property that holds the single main instance of Shortcodes.
27
+ *
28
+ * @since 3.0.0
29
+ * @access private
30
+ * @var Redirection
31
+ */
32
+ private static $_instance;
33
+
34
+ /**
35
+ * Model that houses the main plugin object.
36
+ *
37
+ * @since 3.0.0
38
+ * @access private
39
+ * @var Redirection
40
+ */
41
+ private $_main_plugin;
42
+
43
+ /**
44
+ * Model that houses all the plugin constants.
45
+ *
46
+ * @since 3.0.0
47
+ * @access private
48
+ * @var Plugin_Constants
49
+ */
50
+ private $_constants;
51
+
52
+ /**
53
+ * Property that houses all the helper functions of the plugin.
54
+ *
55
+ * @since 3.0.0
56
+ * @access private
57
+ * @var Helper_Functions
58
+ */
59
+ private $_helper_functions;
60
+
61
+
62
+
63
+
64
+ /*
65
+ |--------------------------------------------------------------------------
66
+ | Class Methods
67
+ |--------------------------------------------------------------------------
68
+ */
69
+
70
+ /**
71
+ * Class constructor.
72
+ *
73
+ * @since 3.0.0
74
+ * @access public
75
+ *
76
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
77
+ * @param Plugin_Constants $constants Plugin constants object.
78
+ * @param Helper_Functions $helper_functions Helper functions object.
79
+ */
80
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
81
+
82
+ $this->_constants = $constants;
83
+ $this->_helper_functions = $helper_functions;
84
+
85
+ $main_plugin->add_to_all_plugin_models( $this );
86
+
87
+ }
88
+
89
+ /**
90
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
91
+ *
92
+ * @since 3.0.0
93
+ * @access public
94
+ *
95
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
96
+ * @param Plugin_Constants $constants Plugin constants object.
97
+ * @param Helper_Functions $helper_functions Helper functions object.
98
+ * @return Redirection
99
+ */
100
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
101
+
102
+ if ( !self::$_instance instanceof self )
103
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
104
+
105
+ return self::$_instance;
106
+
107
+ }
108
+
109
+ /**
110
+ * Checks if the given ID needs to be uncloaked
111
+ *
112
+ * @since 3.0.0
113
+ * @access public
114
+ *
115
+ * @param int $link_id Affiliate Link post ID.
116
+ * @return boolean.
117
+ */
118
+ public function is_link_to_be_uncloaked( $link_id ) {
119
+
120
+ if ( get_option( 'ta_uncloak_link_per_link' ) == 'yes' ) {
121
+
122
+ $links_to_uncloak = maybe_unserialize( get_option( 'ta_links_to_uncloak' , array() ) );
123
+
124
+ if ( in_array( $link_id , $links_to_uncloak ) )
125
+ return true;
126
+
127
+ }
128
+
129
+ if ( get_option( 'ta_uncloak_link_per_category' ) == 'yes' && $category_to_uncloak = get_option( 'ta_category_to_uncloak' ) ) {
130
+
131
+ if ( has_term( $category_to_uncloak , Plugin_Constants::AFFILIATE_LINKS_TAX , $link_id ) )
132
+ return true;
133
+ }
134
+
135
+ return false;
136
+ }
137
+
138
+ /**
139
+ * thirstylink shortcode.
140
+ * example: [thirstylink ids="10,15,18,20"]Affiliate Link[/thirstylink]
141
+ *
142
+ * @since 3.0.0
143
+ * @access public
144
+ *
145
+ * @param array $atts Shortcode attributes.
146
+ * @param string $content Shortcode content.
147
+ * @return string Processed shortcode output.
148
+ */
149
+ public function thirstylink_shortcode( $atts , $content = '' ) {
150
+
151
+ global $post;
152
+
153
+ $atts = shortcode_atts( array(
154
+ 'ids' => '',
155
+ 'linkid' => '',
156
+ 'linktext' => '',
157
+ 'class' => '',
158
+ 'rel' => '',
159
+ 'target' => '',
160
+ 'title' => ''
161
+ ), $atts , 'thirstylink' );
162
+
163
+ // get all link attributes from $atts
164
+ $link_attributes = array_diff_assoc(
165
+ $atts,
166
+ array(
167
+ 'ids' => $atts[ 'ids' ],
168
+ 'linkid' => $atts[ 'linkid' ],
169
+ 'linktext' => $atts[ 'linktext' ],
170
+ )
171
+ );
172
+
173
+ // get the link ID
174
+ if ( ! $atts[ 'linkid' ] ) {
175
+
176
+ $ids = isset( $atts[ 'ids' ] ) ? array_map( 'intval' , explode( ',' , $atts[ 'ids' ] ) ) : array();
177
+ $key = rand( 0 , count( $ids ) - 1 );
178
+ $link_id = $ids[ $key ];
179
+ } else
180
+ $link_id = (int) $atts[ 'linkid' ];
181
+
182
+ $output = '';
183
+
184
+ if ( $link_id && get_post_type( $link_id ) == Plugin_Constants::AFFILIATE_LINKS_CPT ) {
185
+
186
+ // load thirstylink
187
+ $thirstylink = new Affiliate_Link( $link_id );
188
+ $uncloak_link = $this->_helper_functions->is_uncloak_link( $thirstylink );
189
+
190
+ // get the link URL
191
+ $link_attributes[ 'href' ] = ( $uncloak_link ) ? $thirstylink->get_prop( 'destination_url' ) : $thirstylink->get_prop( 'permalink' );
192
+
193
+ // get link text content default if no value is set
194
+ if ( empty( $content ) && $atts[ 'linktext' ] )
195
+ $content = $atts[ 'linktext' ]; // backward compatibility to get the link text content.
196
+ else if ( empty( $content ) )
197
+ $content = $thirstylink->get_prop( 'name' );
198
+
199
+ // check for nofollow defaults if no value is set
200
+ if ( empty( $link_attributes[ 'rel' ] ) ) {
201
+
202
+ $nofollow = $thirstylink->get_prop( 'no_follow' ) == 'global' ? get_option( 'ta_no_follow' ) : $thirstylink->get_prop( 'no_follow' );
203
+ $link_attributes[ 'rel' ] = $nofollow == 'yes' ? 'nofollow' : '';
204
+ $link_attributes[ 'rel' ] .= ' ' . $thirstylink->get_prop( 'rel_tags' );
205
+ }
206
+
207
+ // check for new window defaults if no value is set
208
+ if ( empty( $link_attributes[ 'target' ] ) ) {
209
+
210
+ $new_window = $thirstylink->get_prop( 'new_window' ) == 'global' ? get_option( 'ta_new_window' ) : $thirstylink->get_prop( 'new_window' );
211
+ $link_attributes[ 'target' ] = $new_window == 'yes' ? '_blank' : '';
212
+ }
213
+
214
+ // provide default class value if it is not set
215
+ if ( empty( $link_attributes[ 'class' ] ) && get_option( 'ta_disable_thirsty_link_class' ) !== 'yes' )
216
+ $link_attributes[ 'class' ] = 'thirstylink';
217
+
218
+ // provide default class value if it is not set
219
+ if ( empty( $link_attributes[ 'title' ] ) && get_option( 'ta_disable_title_attribute' ) !== 'yes' )
220
+ $link_attributes[ 'title' ] = $thirstylink->get_prop( 'name' );
221
+
222
+ // remove double quote character on title attribute.
223
+ $link_attributes[ 'title' ] = esc_attr( str_replace( '"' , '' , $link_attributes[ 'title' ] ) );
224
+
225
+ // add data-link_id attribute if affiliate link is uncloaked.
226
+ if ( $uncloak_link )
227
+ $link_attributes[ 'data-linkid' ] = $link_id;
228
+
229
+ // allow the ability to add custom link attributes
230
+ $link_attributes = apply_filters( 'ta_link_insert_extend_data_attributes' , $link_attributes , $thirstylink , $post->ID );
231
+
232
+ // Build the link ready for output
233
+ $output .= '<a';
234
+
235
+ foreach ( $link_attributes as $name => $value ) {
236
+ // Handle square bracket escaping (used for some addons, eg. Google Analytics click tracking)
237
+ $value = html_entity_decode( $value );
238
+ $value = preg_replace( '/&#91;/' , '[' , $value );
239
+ $value = preg_replace( '/&#93;/' , ']' , $value );
240
+ $output .= ! empty($value) ? ' ' . $name . '="' . trim( esc_attr( $value ) ) . '"' : '';
241
+ }
242
+
243
+ $output .= 'data-shortcode="true">' . do_shortcode( $content ) . '</a>';
244
+
245
+
246
+ } else
247
+ $output .= '<span style="color: #0000ff;">' . __( 'SHORTCODE ERROR: ThirstyAffiliates did not detect a valid link id, please check your short code!' , 'thirstyaffiliates' ) . '</span>';
248
+
249
+ return $output;
250
+ }
251
+
252
+ /**
253
+ * Execute shortcodes class.
254
+ *
255
+ * @since 3.0.0
256
+ * @access public
257
+ */
258
+ public function run() {
259
+
260
+ add_shortcode( 'thirstylink' , array( $this , 'thirstylink_shortcode' ) );
261
+ }
262
+ }
Models/Stats_Reporting.php ADDED
@@ -0,0 +1,775 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace ThirstyAffiliates\Models;
4
+
5
+ use ThirstyAffiliates\Abstracts\Abstract_Main_Plugin_Class;
6
+
7
+ use ThirstyAffiliates\Interfaces\Model_Interface;
8
+ use ThirstyAffiliates\Interfaces\Initiable_Interface;
9
+
10
+ use ThirstyAffiliates\Helpers\Plugin_Constants;
11
+ use ThirstyAffiliates\Helpers\Helper_Functions;
12
+
13
+ use ThirstyAffiliates\Models\Affiliate_Link;
14
+
15
+ /**
16
+ * Model that houses the logic for permalink rewrites and affiliate link redirections.
17
+ *
18
+ * @since 3.0.0
19
+ */
20
+ class Stats_Reporting implements Model_Interface , Initiable_Interface {
21
+
22
+ /*
23
+ |--------------------------------------------------------------------------
24
+ | Class Properties
25
+ |--------------------------------------------------------------------------
26
+ */
27
+
28
+ /**
29
+ * Property that holds the single main instance of Stats_Reporting.
30
+ *
31
+ * @since 3.0.0
32
+ * @access private
33
+ * @var Redirection
34
+ */
35
+ private static $_instance;
36
+
37
+ /**
38
+ * Model that houses the main plugin object.
39
+ *
40
+ * @since 3.0.0
41
+ * @access private
42
+ * @var Redirection
43
+ */
44
+ private $_main_plugin;
45
+
46
+ /**
47
+ * Model that houses all the plugin constants.
48
+ *
49
+ * @since 3.0.0
50
+ * @access private
51
+ * @var Plugin_Constants
52
+ */
53
+ private $_constants;
54
+
55
+ /**
56
+ * Property that houses all the helper functions of the plugin.
57
+ *
58
+ * @since 3.0.0
59
+ * @access private
60
+ * @var Helper_Functions
61
+ */
62
+ private $_helper_functions;
63
+
64
+
65
+
66
+
67
+ /*
68
+ |--------------------------------------------------------------------------
69
+ | Class Methods
70
+ |--------------------------------------------------------------------------
71
+ */
72
+
73
+ /**
74
+ * Class constructor.
75
+ *
76
+ * @since 3.0.0
77
+ * @access public
78
+ *
79
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
80
+ * @param Plugin_Constants $constants Plugin constants object.
81
+ * @param Helper_Functions $helper_functions Helper functions object.
82
+ */
83
+ public function __construct( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
84
+
85
+ $this->_constants = $constants;
86
+ $this->_helper_functions = $helper_functions;
87
+
88
+ $main_plugin->add_to_all_plugin_models( $this );
89
+ $main_plugin->add_to_public_models( $this );
90
+
91
+ }
92
+
93
+ /**
94
+ * Ensure that only one instance of this class is loaded or can be loaded ( Singleton Pattern ).
95
+ *
96
+ * @since 3.0.0
97
+ * @access public
98
+ *
99
+ * @param Abstract_Main_Plugin_Class $main_plugin Main plugin object.
100
+ * @param Plugin_Constants $constants Plugin constants object.
101
+ * @param Helper_Functions $helper_functions Helper functions object.
102
+ * @return Redirection
103
+ */
104
+ public static function get_instance( Abstract_Main_Plugin_Class $main_plugin , Plugin_Constants $constants , Helper_Functions $helper_functions ) {
105
+
106
+ if ( !self::$_instance instanceof self )
107
+ self::$_instance = new self( $main_plugin , $constants , $helper_functions );
108
+
109
+ return self::$_instance;
110
+
111
+ }
112
+
113
+
114
+
115
+
116
+ /*
117
+ |--------------------------------------------------------------------------
118
+ | Data saving
119
+ |--------------------------------------------------------------------------
120
+ */
121
+
122
+ /**
123
+ * Save link click data to the database.
124
+ *
125
+ * @since 3.0.0
126
+ * @access private
127
+ *
128
+ * @param int $link_id Affiliate link ID.
129
+ * @param string $http_referer HTTP Referrer value.
130
+ */
131
+ private function save_click_data( $link_id , $http_referer = '' ) {
132
+
133
+ global $wpdb;
134
+
135
+ $link_click_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_DB;
136
+ $link_click_meta_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_META_DB;
137
+
138
+ // insert click entry
139
+ $wpdb->insert(
140
+ $link_click_db,
141
+ array(
142
+ 'link_id' => $link_id,
143
+ 'date_clicked' => current_time( 'mysql' , true )
144
+ )
145
+ );
146
+
147
+ // save click meta data
148
+ if ( $click_id = $wpdb->insert_id ) {
149
+
150
+ $meta_data = apply_filters( 'ta_save_click_data' , array(
151
+ 'user_ip_address' => $this->_helper_functions->get_user_ip_address(),
152
+ 'http_referer' => $http_referer
153
+ ) );
154
+
155
+ foreach ( $meta_data as $key => $value ) {
156
+
157
+ $wpdb->insert(
158
+ $link_click_meta_db,
159
+ array(
160
+ 'click_id' => $click_id,
161
+ 'meta_key' => $key,
162
+ 'meta_value' => $value
163
+ )
164
+ );
165
+ }
166
+
167
+ }
168
+ }
169
+
170
+ /**
171
+ * Save click data on redirect
172
+ *
173
+ * @since 3.0.0
174
+ * @access public
175
+ *
176
+ * @param Affiliate_Link $thirstylink Affiliate link object.
177
+ */
178
+ public function save_click_data_on_redirect( $thirstylink ) {
179
+
180
+ $link_id = $thirstylink->get_id();
181
+ $http_referer = isset( $_SERVER[ 'HTTP_REFERER' ] ) ? $_SERVER[ 'HTTP_REFERER' ] : '';
182
+
183
+ // if the refferer is from an external site, then record stat.
184
+ if ( ! $http_referer || ! strrpos( 'x' . $http_referer , home_url() ) )
185
+ $this->save_click_data( $link_id , $http_referer );
186
+ }
187
+
188
+ /**
189
+ * AJAX save click data on redirect
190
+ *
191
+ * @since 3.0.0
192
+ * @access public
193
+ */
194
+ public function ajax_save_click_data_on_redirect() {
195
+
196
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
197
+ wp_die();
198
+
199
+ $link_id = isset( $_REQUEST[ 'link_id' ] ) ? (int) sanitize_text_field( $_REQUEST[ 'link_id' ] ) : 0;
200
+ $http_referer = isset( $_REQUEST[ 'page' ] ) ? sanitize_text_field( $_REQUEST[ 'page' ] ) : '';
201
+
202
+ if ( ! $link_id ) {
203
+
204
+ $link_href = sanitize_text_field( $_REQUEST[ 'href' ] );
205
+ $link_id = url_to_postid( $link_href );
206
+ }
207
+
208
+ if ( $link_id )
209
+ $this->save_click_data( $link_id , $http_referer );
210
+
211
+ wp_die();
212
+ }
213
+
214
+
215
+
216
+
217
+ /*
218
+ |--------------------------------------------------------------------------
219
+ | Fetch Report Data
220
+ |--------------------------------------------------------------------------
221
+ */
222
+
223
+ /**
224
+ * Fetch link performance data by date range.
225
+ *
226
+ * @since 3.0.0
227
+ * @access public
228
+ *
229
+ * @global wpdb $wpdb Object that contains a set of functions used to interact with a database.
230
+ *
231
+ * @param string $start_date Report start date. Format: YYYY-MM-DD hh:mm:ss
232
+ * @param string $end_date Report end date. Format: YYYY-MM-DD hh:mm:ss
233
+ * @param array $link_ids Affiliate Link post ID
234
+ * @return string/array Link click meta data value.
235
+ */
236
+ public function get_link_performance_data( $start_date , $end_date , $link_ids ) {
237
+
238
+ global $wpdb;
239
+
240
+ if ( ! is_array( $link_ids ) || empty( $link_ids ) )
241
+ return array();
242
+
243
+ $link_clicks_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_DB;
244
+ $link_ids_str = implode( ', ' , $link_ids );
245
+ $query = "SELECT * FROM $link_clicks_db WHERE date_clicked between '$start_date' and '$end_date' and link_id IN ( $link_ids_str )";
246
+
247
+ return $wpdb->get_results( $query );
248
+ }
249
+
250
+ /**
251
+ * Get link click meta by id and key.
252
+ *
253
+ * @since 3.0.0
254
+ * @access public
255
+ *
256
+ * @param int $click_id Link click ID.
257
+ * @param string $meta_key Meta key column value.
258
+ * @param boolean $single Return single result or array.
259
+ * @return array Link performance data.
260
+ */
261
+ private function get_click_meta( $click_id , $meta_key , $single = false ) {
262
+
263
+ global $wpdb;
264
+
265
+ $links_click_meta_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_META_DB;
266
+
267
+ if ( $single ){
268
+
269
+ $meta = $wpdb->get_row( "SELECT meta_value FROM $links_click_meta_db WHERE click_id = '$click_id' and meta_key = '$meta_key'" , ARRAY_A );
270
+ return array_shift( $meta );
271
+
272
+ } else {
273
+
274
+ $meta = array();
275
+ $raw_data = $wpdb->get_results( "SELECT meta_value FROM $links_click_meta_db WHERE click_id = '$click_id' and meta_key = '$meta_key'" , ARRAY_N );
276
+
277
+ foreach ( $raw_data as $data )
278
+ $meta[] = array_shift( $data );
279
+
280
+ return $meta;
281
+ }
282
+ }
283
+
284
+ /**
285
+ * AJAX fetch report by linkid.
286
+ *
287
+ * @since 3.0.0
288
+ * @access public
289
+ */
290
+ public function ajax_fetch_report_by_linkid() {
291
+
292
+ if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX )
293
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Invalid AJAX call' , 'thirstyaffiliates' ) );
294
+ elseif ( ! isset( $_POST[ 'link_id' ] ) )
295
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Missing required post data' , 'thirstyaffiliates' ) );
296
+ else {
297
+
298
+ $link_id = (int) sanitize_text_field( $_POST[ 'link_id' ] );
299
+ $thirstylink = new Affiliate_Link( $link_id );
300
+ $range_txt = sanitize_text_field( $_POST[ 'range' ] );
301
+ $start_date = sanitize_text_field( $_POST[ 'start_date' ] );
302
+ $end_date = sanitize_text_field( $_POST[ 'end_date' ] );
303
+
304
+ if ( ! $thirstylink->get_id() )
305
+ $response = array( 'status' => 'fail' , 'error_msg' => __( 'Selected affiliate link is invalid' , 'thirstyaffiliates' ) );
306
+ else {
307
+
308
+ $range = $this->get_report_range_details( $range_txt , $start_date , $end_date );
309
+ $data = $this->prepare_data_for_flot( $range , array( $link_id ) );
310
+
311
+ $response = array(
312
+ 'status' => 'success',
313
+ 'label' => $thirstylink->get_prop( 'name' ),
314
+ 'slug' => $thirstylink->get_prop( 'slug' ),
315
+ 'report_data' => $data
316
+ );
317
+ }
318
+ }
319
+
320
+ @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
321
+ echo wp_json_encode( $response );
322
+ wp_die();
323
+ }
324
+
325
+
326
+
327
+
328
+ /*
329
+ |--------------------------------------------------------------------------
330
+ | Reports Structure
331
+ |--------------------------------------------------------------------------
332
+ */
333
+
334
+ /**
335
+ * Get all registered reports.
336
+ *
337
+ * @since 3.0.0
338
+ * @access public
339
+ *
340
+ * @return array Settings sections.
341
+ */
342
+ public function get_all_reports() {
343
+
344
+ return apply_filters( 'ta_register_reports' , array() );
345
+ }
346
+
347
+ /**
348
+ * Get current loaded report.
349
+ *
350
+ * @since 3.0.0
351
+ * @access public
352
+ *
353
+ * @param string $tab Current report tab.
354
+ * @return array Current loaded report.
355
+ */
356
+ public function get_current_report( $tab = '' ) {
357
+
358
+ if ( ! $tab )
359
+ $tab = isset( $_GET[ 'tab' ] ) ? esc_attr( $_GET[ 'tab' ] ) : 'link_performance';
360
+
361
+ // get all registered sections and fields
362
+ $reports = $this->get_all_reports();
363
+
364
+ return isset( $reports[ $tab ] ) ? $reports[ $tab ] : array();
365
+ }
366
+
367
+ /**
368
+ * Register link performance report.
369
+ *
370
+ * @since 3.0.0
371
+ * @access public
372
+ *
373
+ * @param array $reports Array list of all registered reports.
374
+ * @return array Array list of all registered reports.
375
+ */
376
+ public function register_link_performance_report( $reports ) {
377
+
378
+ $reports[ 'link_performance' ] = array(
379
+ 'id' => 'ta_link_performance_report',
380
+ 'tab' => 'link_performance',
381
+ 'name' => __( 'Link Performance' , 'thirstyaffiliates' ),
382
+ 'title' => __( 'Link Performance Report' , 'thirstyaffiliates' ),
383
+ 'desc' => __( 'Total clicks on affiliate links over a given period.' , 'thirstyaffiliates' ),
384
+ 'content' => $this->get_link_performance_report_content()
385
+ );
386
+
387
+ return $reports;
388
+ }
389
+
390
+
391
+
392
+
393
+ /*
394
+ |--------------------------------------------------------------------------
395
+ | Display Report
396
+ |--------------------------------------------------------------------------
397
+ */
398
+
399
+ /**
400
+ * Register reports menu page.
401
+ *
402
+ * @since 3.0.0
403
+ * @access public
404
+ */
405
+ public function add_reports_submenu() {
406
+
407
+ add_submenu_page(
408
+ 'edit.php?post_type=thirstylink',
409
+ __( 'ThirstyAffiliates Reports' , 'thirstyaffiliates' ),
410
+ __( 'Reports' , 'thirstyaffiliates' ),
411
+ 'manage_options',
412
+ 'thirsty-reports',
413
+ array( $this, 'render_reports' )
414
+ );
415
+ }
416
+
417
+ /**
418
+ * Render reports page.
419
+ *
420
+ * @since 3.0.0
421
+ * @access public
422
+ */
423
+ public function render_reports() {
424
+
425
+ // fetch current section
426
+ $current_report = $this->get_current_report();
427
+
428
+ // skip if section data is empty
429
+ if ( empty( $current_report ) ) return; ?>
430
+
431
+ <div class="ta-settings ta-settings-<?php echo $current_report[ 'tab' ]; ?> wrap">
432
+
433
+ <?php $this->render_reports_nav(); ?>
434
+
435
+ <h1><?php echo $current_report[ 'title' ]; ?></h1>
436
+ <p class="desc"><?php echo $current_report[ 'desc' ]; ?></p>
437
+
438
+ <?php echo $current_report[ 'content' ]; ?>
439
+ </div>
440
+ <?php
441
+ }
442
+
443
+ /**
444
+ * Render the settings navigation.
445
+ *
446
+ * @since 3.0.0
447
+ * @access public
448
+ */
449
+ public function render_reports_nav() {
450
+
451
+ $reports = $this->get_all_reports();
452
+ $current = $this->get_current_report();
453
+ $base_url = admin_url( 'edit.php?post_type=thirstylink&page=thirsty-reports' );
454
+
455
+ if ( empty( $reports ) ) return; ?>
456
+
457
+ <nav class="thirsty-nav-tab">
458
+ <?php foreach ( $reports as $report ) : ?>
459
+
460
+ <a href="<?php echo $base_url . '&tab=' . $report[ 'tab' ]; ?>" class="tab <?php echo ( $current[ 'tab' ] === $report[ 'tab' ] ) ? 'tab-active' : ''; ?>">
461
+ <?php echo $report[ 'name' ]; ?>
462
+ </a>
463
+
464
+ <?php endforeach; ?>
465
+ </nav>
466
+
467
+ <?php
468
+ }
469
+
470
+ /**
471
+ * Get Link performance report content.
472
+ *
473
+ * @since 3.0.0
474
+ * @access public
475
+ *
476
+ * @return string Link performance report content.
477
+ */
478
+ public function get_link_performance_report_content() {
479
+
480
+ $cpt_slug = Plugin_Constants::AFFILIATE_LINKS_CPT;
481
+ $current_range = isset( $_GET[ 'range' ] ) ? sanitize_text_field( $_GET[ 'range' ] ) : '7day';
482
+ $start_date = isset( $_GET[ 'start_date' ] ) ? sanitize_text_field( $_GET[ 'start_date' ] ) : '';
483
+ $end_date = isset( $_GET[ 'end_date' ] ) ? sanitize_text_field( $_GET[ 'end_date' ] ) : '';
484
+ $link_id = isset( $_GET[ 'link_id' ] ) ? sanitize_text_field( $_GET[ 'link_id' ] ) : '';
485
+ $range = $this->get_report_range_details( $current_range , $start_date , $end_date );
486
+ $range_nav = apply_filters( 'ta_link_performances_report_nav' , array(
487
+ 'year' => __( 'Year' , 'thirstyaffiliates' ),
488
+ 'last_month' => __( 'Last Month' , 'thirstyaffiliates' ),
489
+ 'month' => __( 'This Month' , 'thirstyaffiliates' ),
490
+ '7day' => __( 'Last 7 Days' , 'thirstyaffiliates' )
491
+ ) );
492
+
493
+ // make sure link_id is an affiliate link (published).
494
+ // NOTE: when false, this needs to return an empty string as it is used for display.
495
+ if ( $link_id ) $link_id = ( get_post_type( $link_id ) == $cpt_slug && get_post_status( $link_id ) == 'publish' ) ? $link_id : '';
496
+
497
+ // get all published affiliate link ids
498
+ $query = new \WP_Query( array(
499
+ 'post_type' => $cpt_slug,
500
+ 'post_status' => 'publish',
501
+ 'fields' => 'ids',
502
+ 'posts_per_page' => -1
503
+ ) );
504
+
505
+ $data = $this->prepare_data_for_flot( $range , $query->posts );
506
+
507
+ ob_start();
508
+ include( $this->_constants->VIEWS_ROOT_PATH() . 'reports/link-performance-report.php' );
509
+
510
+ return ob_get_clean();
511
+ }
512
+
513
+
514
+
515
+
516
+ /*
517
+ |--------------------------------------------------------------------------
518
+ | Helper methods
519
+ |--------------------------------------------------------------------------
520
+ */
521
+
522
+ /**
523
+ * Get report range details.
524
+ *
525
+ * @since 3.0.0
526
+ * @access public
527
+ *
528
+ * @param string $range Report range type.
529
+ * @param string $start_date Starting date of range.
530
+ * @param string $end_date Ending date of range.
531
+ * @return array Report range details.
532
+ */
533
+ public function get_report_range_details( $range = '7day' , $start_date = 'now -6 days' , $end_date = 'now' ) {
534
+
535
+ $data = array();
536
+ $zone_str = $this->_helper_functions->get_site_current_timezone();
537
+ $timezone = new \DateTimeZone( $zone_str );
538
+ $now = new \DateTime( 'now' , $timezone );
539
+
540
+ switch ( $range ) {
541
+
542
+ case 'year' :
543
+ $data[ 'type' ] = 'year';
544
+ $data[ 'start_date' ] = new \DateTime( 'first day of January' . date( 'Y' ) , $timezone );
545
+ $data[ 'end_date' ] = $now;
546
+ break;
547
+
548
+ case 'last_month' :
549
+ $data[ 'type' ] = 'last_month';
550
+ $data[ 'start_date' ] = new \DateTime( 'first day of last month' , $timezone );
551
+ $data[ 'end_date' ] = new \DateTime( 'last day of last month' , $timezone );
552
+ break;
553
+
554
+ case 'month' :
555
+ $data[ 'type' ] = 'month';
556
+ $data[ 'start_date' ] = new \DateTime( 'first day of this month' , $timezone );
557
+ $data[ 'end_date' ] = $now;
558
+ break;
559
+
560
+ case 'custom' :
561
+ $data[ 'type' ] = 'custom';
562
+ $data[ 'start_date' ] = new \DateTime( $start_date , $timezone );
563
+ $data[ 'end_date' ] = new \DateTime( $end_date . ' 23:59:59' , $timezone );
564
+ break;
565
+
566
+ case '7day' :
567
+ default :
568
+ $data[ 'type' ] = '7day';
569
+ $data[ 'start_date' ] = new \DateTime( 'now -6 days' , $timezone );
570
+ $data[ 'end_date' ] = $now;
571
+ break;
572
+ }
573
+
574
+ return apply_filters( 'ta_report_range_data' , $data , $range );
575
+ }
576
+
577
+ /**
578
+ * Prepare data to feed for jQuery flot.
579
+ *
580
+ * @since 3.0.0
581
+ * @access public
582
+ *
583
+ * @param array $range Report range details
584
+ * @param array $link_ids Affiliate Link post ID
585
+ * @return array Processed data for jQuery flot.
586
+ */
587
+ public function prepare_data_for_flot( $range , $link_ids ) {
588
+
589
+ $start_date = $range[ 'start_date' ];
590
+ $end_date = $range[ 'end_date' ];
591
+ $zone_str = $this->_helper_functions->get_site_current_timezone();
592
+ $timezone = new \DateTimeZone( $zone_str );
593
+ $flot_data = array();
594
+
595
+ if ( apply_filters( 'ta_report_set_start_date_time_to_zero' , true , $range ) )
596
+ $start_date->setTime( 0 , 0 );
597
+
598
+ $raw_data = $this->get_link_performance_data( $start_date->format( 'Y-m-d H:i:s' ) , $end_date->format( 'Y-m-d H:i:s' ) , $link_ids );
599
+
600
+ // get number of days difference between start and end
601
+ $incrementor = apply_filters( 'ta_report_flot_data_incrementor' , ( 60 * 60 * 24 ) , $range );
602
+ $timestamp_diff = ( $start_date->getTimestamp() - $end_date->getTimestamp() );
603
+ $days_diff = abs( floor( $timestamp_diff / $incrementor ) );
604
+
605
+ // save the timestamp for first day
606
+ $timestamp = $start_date->format( 'U' );
607
+ $month_time = $this->get_month_first_day_datetime_obj( 'February' );
608
+ $next_timestamp = ( $range[ 'type' ] == 'year' ) ? $month_time->format( 'U' ) : $timestamp + $incrementor;
609
+ $flot_data[] = array(
610
+ 'timestamp' => (int) $timestamp,
611
+ 'count' => 0,
612
+ 'next_timestamp' => $next_timestamp
613
+ );
614
+
615
+ if ( $range[ 'type' ] == 'year' ) {
616
+
617
+ $months = array( 'February' , 'March' , 'April' , 'May' , 'June' , 'July' , 'August' , 'September' , 'October' , 'November' , 'December' );
618
+
619
+ foreach ( $months as $key => $month ) {
620
+
621
+ $month_time = $this->get_month_first_day_datetime_obj( $month );
622
+ $next_month = $this->get_month_first_day_datetime_obj( $months[ $key + 1 ] );
623
+
624
+ $flot_data[] = array(
625
+ 'timestamp' => $month_time->format( 'U' ),
626
+ 'count' => 0,
627
+ 'next_timestamp' => $next_month->format( 'U' )
628
+ );
629
+
630
+ if ( $end_date->format( 'F' ) == $month )
631
+ break;
632
+ }
633
+
634
+ } else {
635
+
636
+ // determine timestamps for succeeding days
637
+ for ( $x = 1; $x < $days_diff; $x++ ) {
638
+
639
+ $timestamp = $next_timestamp;
640
+ $next_timestamp = $timestamp + $incrementor;
641
+
642
+ $flot_data[] = array(
643
+ 'timestamp' => (int) $timestamp,
644
+ 'count' => 0,
645
+ 'next_timestamp' => $next_timestamp
646
+ );
647
+
648
+ }
649
+ }
650
+
651
+ // count each click data and assign to appropriate day.
652
+ foreach ( $raw_data as $click_entry ) {
653
+
654
+ $click_date = new \DateTime( $click_entry->date_clicked , new \DateTimeZone( 'UTC' ) );
655
+ $click_date->setTimezone( $timezone );
656
+
657
+ $click_timestamp = (int) $click_date->format( 'U' );
658
+
659
+ foreach ( $flot_data as $key => $day_data ) {
660
+
661
+ if ( $click_timestamp >= $day_data[ 'timestamp' ] && $click_timestamp < $day_data[ 'next_timestamp' ] ) {
662
+ $flot_data[ $key ][ 'count' ] += 1;
663
+ continue;
664
+ }
665
+ }
666
+ }
667
+
668
+ // convert $flot_data array into non-associative array
669
+ foreach ( $flot_data as $key => $day_data ) {
670
+
671
+ unset( $day_data[ 'next_timestamp' ] );
672
+
673
+ $day_data[ 'timestamp' ] = $day_data[ 'timestamp' ] * 1000;
674
+ $flot_data[ $key ] = array_values( $day_data );
675
+ }
676
+
677
+ return $flot_data;
678
+ }
679
+
680
+ /**
681
+ * Get the DateTime object of the first day of a given month.
682
+ *
683
+ * @since 3.0.0
684
+ * @access public
685
+ *
686
+ * @param string $month Month full textual representation.
687
+ * @return DateTime First day of the given month DateTime object.
688
+ */
689
+ public function get_month_first_day_datetime_obj( $month ) {
690
+
691
+ $zone_str = $this->_helper_functions->get_site_current_timezone();
692
+ $timezone = new \DateTimeZone( $zone_str );
693
+
694
+ return new \DateTime( 'First day of ' . $month . ' ' . date( 'Y' ) , $timezone );
695
+ }
696
+
697
+ /**
698
+ * Delete stats data when an affiliate link is deleted permanently.
699
+ *
700
+ * @since 3.0.1
701
+ * @access public
702
+ *
703
+ * @global wpdb $wpdb Object that contains a set of functions used to interact with a database.
704
+ *
705
+ * @param int $link_id Affiliate link ID.
706
+ */
707
+ public function delete_stats_data_on_affiliate_link_deletion( $link_id ) {
708
+
709
+ global $wpdb;
710
+
711
+ if ( Plugin_Constants::AFFILIATE_LINKS_CPT !== get_post_type( $link_id ) )
712
+ return;
713
+
714
+ $link_click_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_DB;
715
+ $link_click_meta_db = $wpdb->prefix . Plugin_Constants::LINK_CLICK_META_DB;
716
+ $click_ids = $wpdb->get_col( "SELECT id FROM $link_click_db WHERE link_id = $link_id" );
717
+
718
+ if ( ! is_array( $click_ids ) || empty( $click_ids ) )
719
+ return;
720
+
721
+ $click_ids_str = implode( ',' , $click_ids );
722
+
723
+ // delete click meta records.
724
+ $wpdb->query( "DELETE FROM $link_click_meta_db WHERE click_id IN ( $click_ids_str )" );
725
+
726
+ // delete click records.
727
+ $wpdb->query( "DELETE FROM $link_click_db WHERE id IN ( $click_ids_str )" );
728
+ }
729
+
730
+
731
+
732
+
733
+ /*
734
+ |--------------------------------------------------------------------------
735
+ | Fulfill implemented interface contracts
736
+ |--------------------------------------------------------------------------
737
+ */
738
+
739
+ /**
740
+ * Method that houses codes to be executed on init hook.
741
+ *
742
+ * @since 3.0.0
743
+ * @access public
744
+ * @inherit ThirstyAffiliates\Interfaces\Initiable_Interface
745
+ */
746
+ public function initialize() {
747
+
748
+ // When module is disabled in the settings, then it shouldn't run the whole class.
749
+ if ( get_option( 'ta_enable_stats_reporting_module' , 'yes' ) !== 'yes' )
750
+ return;
751
+
752
+ add_action( 'wp_ajax_ta_click_data_redirect' , array( $this , 'ajax_save_click_data_on_redirect' ) , 10 );
753
+ add_action( 'wp_ajax_ta_fetch_report_by_linkid' , array( $this , 'ajax_fetch_report_by_linkid' ) , 10 );
754
+ add_action( 'wp_ajax_nopriv_ta_click_data_redirect' , array( $this , 'ajax_save_click_data_on_redirect' ) , 10 );
755
+ }
756
+
757
+ /**
758
+ * Execute ajax handler.
759
+ *
760
+ * @since 3.0.0
761
+ * @access public
762
+ * @inherit ThirstyAffiliates\Interfaces\Model_Interface
763
+ */
764
+ public function run() {
765
+
766
+ // When module is disabled in the settings, then it shouldn't run the whole class.
767
+ if ( get_option( 'ta_enable_stats_reporting_module' , 'yes' ) !== 'yes' )
768
+ return;
769
+
770
+ add_action( 'ta_before_link_redirect' , array( $this , 'save_click_data_on_redirect' ) , 10 , 1 );
771
+ add_action( 'admin_menu' , array( $this , 'add_reports_submenu' ) , 10 );
772
+ add_action( 'ta_register_reports' , array( $this , 'register_link_performance_report' ) , 10 );
773
+ add_action( 'before_delete_post' , array( $this , 'delete_stats_data_on_affiliate_link_deletion' ) , 10 );
774
+ }
775
+ }
Models/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
ThirstyAddonPage.php DELETED
@@ -1,147 +0,0 @@
1
- <?php
2
-
3
- /*******************************************************************************
4
- ** thirstySetupAddonsMenu()
5
- ** Setup the plugin options menu
6
- ** @since 2.0
7
- *******************************************************************************/
8
- function thirstySetupAddonsMenu() {
9
- if (is_admin()) {
10
- add_submenu_page('edit.php?post_type=thirstylink', __('Add-ons', 'thirstyaffiliates'), __('Add-ons', 'thirstyaffiliates'), 'manage_options', 'thirsty-addons', 'thirstyAddonsPage');
11
- }
12
- }
13
-
14
- /*******************************************************************************
15
- ** thirstyAddonsPage()
16
- ** Create the add-ons page
17
- ** @since 2.0
18
- *******************************************************************************/
19
- function thirstyAddonsPage() {
20
-
21
- if (!current_user_can('manage_options')) {
22
- wp_die( __('You do not have suffifient permissions to access this page.', 'thirstyaffiliates') );
23
- }
24
-
25
- echo '<div class="wrap">';
26
- echo '<img id="thirstylogo" src="' . plugins_url('thirstyaffiliates/images/thirstylogo.png') . '" alt="ThirstyAffiliates" />';
27
-
28
- echo '<h2>'.__('Turbo Charge ThirstyAffiliates With These Add-ons', 'thirstyaffiliates').'</h2>';
29
-
30
- // get the products list from the RSS feed on thirstyaffiliates.com and
31
- // print them into the page nicely
32
- $products = thirstyAddonsPageGetProducts();
33
-
34
- if (!empty($products)) {
35
- echo '<ul id="thirstyaddonscontainer" class="columns-2">';
36
-
37
- foreach ($products as $product) {
38
- $productUrl = str_replace('utm_source=rss' , 'utm_source=plugin', $product['url']);
39
- $productUrl = str_replace('utm_medium=rss' , 'utm_medium=addonpage', $productUrl);
40
- $productTitle = str_replace('ThirstyAffiliates ', '', $product['title']);
41
- $productTitle = str_replace(' Add-on', '', $productTitle);
42
-
43
- echo '<li class="thirstyaddon">';
44
- echo '<h3>' . $productTitle . '</h3>';
45
- echo '<div class="thirstyaddondescription">' . $product['description'] . '</div>';
46
- echo '<a class="button-primary" href="' . $productUrl . '" target="_blank">'.__('Visit Add-on Page &rarr;', 'thirstyaffiliates').'</a>';
47
- echo '</li>';
48
- }
49
-
50
- echo '</ul>';
51
-
52
- echo '<script type="text/javascript">
53
- jQuery(document).ready(function() {
54
- var addonBoxHeight = 0;
55
- jQuery(".thirstyaddon").each(function() {
56
- if (jQuery(this).height() > addonBoxHeight) {
57
- addonBoxHeight = jQuery(this).height();
58
- }
59
- });
60
- jQuery(".thirstyaddon").height(addonBoxHeight);
61
- });
62
- </script>';
63
- }
64
-
65
- echo '</div>';
66
- }
67
-
68
- /*******************************************************************************
69
- ** thirstyAddonsPageGetProducts()
70
- ** Get the add-ons feed
71
- ** @since 2.0
72
- *******************************************************************************/
73
- function thirstyAddonsPageGetProducts($forceNew = false) {
74
- $thirstyAddonsRSS = get_option('thirstyAddonsRSS');
75
- $expired = false;
76
-
77
- /* If the timestamp hasn't been set or if it is expired or if we're forcing
78
- ** make sure we fetch a new feed */
79
- if (isset($thirstyAddonsRSS) && !empty($thirstyAddonsRSS) && !$forceNew) {
80
-
81
- $oneDayAgo = current_time('timestamp', 0) - (24 * 60 * 60); // current time minus 1 day
82
-
83
- if (!isset($thirstyAddonsRSS['timestamp']) ||
84
- empty($thirstyAddonsRSS['timestamp']) ||
85
- $oneDayAgo > $thirstyAddonsRSS['timestamp']) {
86
-
87
- $expired = true;
88
- }
89
-
90
- } else {
91
- $expired = true;
92
- }
93
-
94
- // Check if we need to get a new RSS feed
95
- if (!isset($thirstyAddonsRSS['products']) || empty($thirstyAddonsRSS['products']) || $expired) {
96
-
97
- $rssXMLString = '';
98
- $rssUrl = 'http://thirstyaffiliates.com/feed?post_type=product';
99
-
100
- if (function_exists('curl_init')) { // cURL is installed on the server so use this preferably
101
- $ch = curl_init();
102
- curl_setopt($ch, CURLOPT_HEADER, false);
103
- curl_setopt($ch, CURLOPT_URL, $rssUrl);
104
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); // provide a http header to please some curl setups
105
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
106
- curl_setopt($ch, CURLOPT_AUTOREFERER, true);
107
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
108
- $rssXMLString = curl_exec($ch);
109
- curl_close($ch);
110
- } else { // try using file_get_contents, though this causes some issues on some servers
111
- $rssXMLString = file_get_contents($rssUrl, true);
112
- }
113
-
114
- // DEFAULT BEHAVIOUR: if we can't get the country XML file return false
115
- if (empty($rssXMLString))
116
- return false;
117
-
118
- // Create XML object for transversing
119
- $rssXML = new SimpleXMLElement($rssXMLString);
120
-
121
- // Check against each bot we have on record
122
- if (!empty($rssXML)) {
123
-
124
- $products = array();
125
- foreach ($rssXML->channel->item as $product) {
126
- $title = (string)$product->title;
127
- $description = (string)$product->description;
128
- $url = (string)$product->link;
129
-
130
- $products[] = array(
131
- 'title' => $title,
132
- 'description' => $description,
133
- 'url' => $url
134
- );
135
- }
136
-
137
- $timestamp = current_time('timestamp', 0);
138
- update_option('thirstyAddonsRSS', array('products' => $products, 'timestamp' => $timestamp));
139
- }
140
-
141
- }
142
-
143
- // Return products array
144
- return $thirstyAddonsRSS['products'];
145
- }
146
-
147
- add_action('admin_menu', 'thirstySetupAddonsMenu', 90);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ThirstyAdminPage.php DELETED
@@ -1,558 +0,0 @@
1
- <?php
2
-
3
- /*******************************************************************************
4
- ** thirstySetupMenu()
5
- ** Setup the plugin options menu
6
- ** @since 1.0
7
- *******************************************************************************/
8
- function thirstySetupMenu() {
9
- if (is_admin()) {
10
- register_setting('thirstyOptions', 'thirstyOptions');
11
- add_submenu_page('edit.php?post_type=thirstylink', __('Settings', 'thirstyaffiliates'), __('Settings', 'thirstyaffiliates'), 'manage_options', 'thirsty-settings', 'thirstyAdminOptions');
12
- }
13
- }
14
-
15
- /*******************************************************************************
16
- ** thirstyAdminOptions
17
- ** Present the options page
18
- ** @since 1.0
19
- *******************************************************************************/
20
- function thirstyAdminOptions() {
21
- if (!current_user_can('manage_options')) {
22
- wp_die( __('You do not have suffifient permissions to access this page.', 'thirstyaffiliates') );
23
- }
24
-
25
- $thirstyOptions = get_option('thirstyOptions');
26
-
27
- $linksRebuilt = false;
28
- if (isset($thirstyOptions['rebuildlinks']) && $thirstyOptions['rebuildlinks'] == 'true') {
29
- $thirstyOptions['rebuildlinks'] = 'false';
30
- update_option('thirstyOptions', $thirstyOptions);
31
- $thirstyOptions = get_option('thirstyOptions');
32
- thirstyResaveAllLinks();
33
- flush_rewrite_rules();
34
- $linksRebuilt = true;
35
- }
36
-
37
- // Sanity check on link prefix
38
- if (empty($thirstyOptions['linkprefix'])) {
39
- $thirstyOptions['linkprefix'] = 'recommends';
40
- update_option('thirstyOptions', $thirstyOptions);
41
- }
42
-
43
- $redirectTypes = thirstyGetRedirectTypes();
44
-
45
- // Sanity check on link redirect type
46
- if (empty($thirstyOptions['linkredirecttype'])) {
47
- $thirstyOptions['linkredirecttype'] = '301';
48
- update_option('thirstyOptions', $thirstyOptions);
49
- }
50
-
51
- $thirstyOptions['nofollow'] = isset($thirstyOptions['nofollow']) ? 'checked="checked"' : '';
52
- $thirstyOptions['newwindow'] = isset($thirstyOptions['newwindow']) ? 'checked="checked"' : '';
53
- $thirstyOptions['showcatinslug'] = isset($thirstyOptions['showcatinslug']) ? 'checked="checked"' : '';
54
- $thirstyOptions['disablecatautoselect'] = isset($thirstyOptions['disablecatautoselect']) ? 'checked="checked"' : '';
55
- $thirstyOptions['legacyuploader'] = isset($thirstyOptions['legacyuploader']) ? 'checked="checked"' : '';
56
- $thirstyOptions['disabletitleattribute'] = isset($thirstyOptions['disabletitleattribute']) ? 'checked="checked"' : '';
57
- $thirstyOptions['disablethirstylinkclass'] = isset($thirstyOptions['disablethirstylinkclass']) ? 'checked="checked"' : '';
58
- $thirstyOptions['disableslugshortening'] = isset($thirstyOptions['disableslugshortening']) ? 'checked="checked"' : '';
59
- $thirstyOptions['disablevisualeditorbuttons'] = isset($thirstyOptions['disablevisualeditorbuttons']) ? 'checked="checked"' : '';
60
- $thirstyOptions['disabletexteditorbuttons'] = isset($thirstyOptions['disabletexteditorbuttons']) ? 'checked="checked"' : '';
61
-
62
- echo '<script type="text/javascript">var thirstyPluginDir = "' .
63
- plugins_url('thirstyaffiliates/') . '";
64
- var thirstyJSEnable = true;
65
- </script>';
66
-
67
- echo '<div class="wrap">';
68
-
69
- echo '<img id="thirstylogo" src="' . plugins_url('thirstyaffiliates/images/thirstylogo.png') . '" alt="ThirstyAffiliates" />';
70
-
71
- echo '<form id="thirstySettingsForm" method="post" action="options.php">';
72
-
73
- wp_nonce_field('update-options');
74
- settings_fields('thirstyOptions');
75
-
76
- if (!empty($_GET['settings-updated'])) {
77
- echo '<div id="message" class="updated below-h2"><p>'.__('Settings updated.', 'thirstyaffiliates').'</p>' .
78
- ($linksRebuilt ? '<p>'.__('Links rebuilt.', 'thirstyaffiliates').'</p>' : '') . '</div>';
79
- }
80
-
81
- echo '
82
- <table class="thirstyTable form-table" cellspacing="0" cellpadding="0">
83
-
84
- <tr><td><h3 style="margin-top: 0;">'.__('General Settings', 'thirstyaffiliates').'</h3></td></tr>
85
-
86
- <tr>
87
- <th>
88
- <label for="thirstyOptions[linkprefix]">'.__('Link Prefix:', 'thirstyaffiliates').'</label>
89
- </th>
90
- <td>
91
- <select id="thirstyOptionsLinkPrefix" name="thirstyOptions[linkprefix]">
92
- <option value="custom"' . (!empty($thirstyOptions['linkprefix']) && $thirstyOptions['linkprefix'] == 'custom' ? ' selected' : '') . '>-- ' . __('Custom', 'thirstyaffiliates') . ' --</option>';
93
-
94
- thirstyGenerateSelectOptions(array("recommends", "link", "go", "review",
95
- "product", "suggests", "follow", "endorses", "proceed", "fly", "goto",
96
- "get", "find", "act", "click", "move", "offer", "run"), true);
97
-
98
- echo '</select><br />
99
- <input type="text" id="thirstyCustomLinkPrefix" value="' . (isset($thirstyOptions['linkprefixcustom']) ? $thirstyOptions['linkprefixcustom'] : '') . '" name="thirstyOptions[linkprefixcustom]" />';
100
-
101
- if (isset($thirstyOptions['linkprefix']) && $thirstyOptions['linkprefix'] == 'custom') {
102
- echo '<script type="text/javascript">
103
- jQuery("#thirstyCustomLinkPrefix").css("display", "block");
104
- jQuery("#thirstyCustomLinkPrefix").show();
105
- </script>';
106
- }
107
-
108
- echo '</td>
109
- <td>
110
- <span class="description">'.__('The prefix that comes before your cloaked link\'s slug.<br />eg. ', 'thirstyaffiliates') .
111
- trailingslashit(get_bloginfo('url')) . '<span style="font-weight: bold;">' . thirstyGetCurrentSlug() . '</span>/your-affiliate-link-name</span>
112
- <br /><span class="description"><b>'.__('Warning:', 'thirstyaffiliates').'</b> '.__('Changing this setting after you\'ve used links in a post could break those links. Be careful!', 'thirstyaffiliates').'</span>
113
- </td>
114
- </tr>
115
-
116
- <tr>
117
- <th>
118
- <label for="thirstyOptions[showcatinslug]">'.__('Show Link Category in URL?', 'thirstyaffiliates').'</label>
119
- <td>
120
- <input type="checkbox" name="thirstyOptions[showcatinslug]" id="thirstyOptionsShowCatInSlug" ' .
121
- $thirstyOptions['showcatinslug'] . ' />
122
- </td>
123
- <td>
124
- <span class="description">'.__('Show the selected category in the url. eg. ', 'thirstyaffiliates') .
125
- trailingslashit(get_bloginfo('url')) . '' . thirstyGetCurrentSlug() . '/<span style="font-weight: bold;">link-category</span>/your-affiliate-link-name</span></span>
126
- <br /><span class="description"><b>'.__('Warning:', 'thirstyaffiliates').'</b> '.__('Changing this setting after you\'ve used links in a post could break those links. Be careful!', 'thirstyaffiliates').'</span>
127
- </td>
128
- </tr>
129
-
130
- <tr>
131
- <th>
132
- <label for="thirstyOptions[disablecatautoselect]">'.__('Disable "uncategorized" category on save?', 'thirstyaffiliates').'</label>
133
- <td>
134
- <input type="checkbox" name="thirstyOptions[disablecatautoselect]" id="thirstyOptionsDisableCatAutoSelect" ' .
135
- $thirstyOptions['disablecatautoselect'] . ' />
136
- </td>
137
- <td>
138
- <span class="description">'.__('If the "Show the selected category in the url" option above is selected, by default ThirstyAffiliates will add an "uncategorized" category to apply to non-categorised links during save. If you disable this, it allows you to have some links with categories in the URL and some without.', 'thirstyaffiliates').'</span>
139
- </td>
140
- </tr>
141
-
142
- <tr>
143
- <th>
144
- <label for="thirstyOptions[linkredirecttype]">'.__('Link Redirect Type:', 'thirstyaffiliates').'</label>
145
- <td>';
146
-
147
- foreach ($redirectTypes as $redirectTypeCode => $redirectTypeDesc) {
148
-
149
- $linkTypeSelected = false;
150
- if (strcasecmp($thirstyOptions['linkredirecttype'], $redirectTypeCode) == 0)
151
- $linkTypeSelected = true;
152
-
153
- echo '<input type="radio" name="thirstyOptions[linkredirecttype]" id="thirstyOptionsLinkRedirectType' . $redirectTypeCode .'" ' .
154
- ($linkTypeSelected ? 'checked="checked" ' : '') . 'value="' . $redirectTypeCode . '" /> <label for="thirstyOptionsLinkRedirectType' . $redirectTypeCode .'">' . $redirectTypeDesc . '</label><br />';
155
-
156
- }
157
-
158
- $additionalreltags = isset($thirstyOptions['additionalreltags']) ? $thirstyOptions['additionalreltags'] : "";
159
-
160
- echo '
161
- </td>
162
- <td>
163
- <span class="description">'.__('This is the type of redirect ThirstyAffiliates will use to redirect the user to your affiliate link.', 'thirstyaffiliates').'</span>
164
- </td>
165
- </tr>
166
-
167
- <tr>
168
- <th>
169
- <label for="thirstyOptions[nofollow]">'.__('Use no follow on links?', 'thirstyaffiliates').'</label>
170
- <td>
171
- <input type="checkbox" name="thirstyOptions[nofollow]" id="thirstyOptionsNofollow" ' .
172
- $thirstyOptions['nofollow'] . ' />
173
- </td>
174
- <td>
175
- <span class="description">'.__('Add the nofollow attribute to links so search engines don\'t index them', 'thirstyaffiliates').'</span>
176
- </td>
177
- </tr>
178
-
179
- <tr>
180
- <th>
181
- <label for="thirstyOptions[newwindow]">'.__('Open links in new window?', 'thirstyaffiliates').'</label>
182
- <td>
183
- <input type="checkbox" name="thirstyOptions[newwindow]" id="thirstyOptionsNewwindow" ' .
184
- $thirstyOptions['newwindow'] . ' />
185
- </td>
186
- <td>
187
- <span class="description">'.__('Force the user to open links in a new window or tab', 'thirstyaffiliates').'</span>
188
- </td>
189
- </tr>
190
-
191
- <tr>
192
- <th>
193
- <label for="thirstyOptions[legacyuploader]">'.__('Revert to legacy image uploader?', 'thirstyaffiliates').'</label>
194
- <td>
195
- <input type="checkbox" name="thirstyOptions[legacyuploader]" id="thirstyOptionsLegacyUploader" ' .
196
- $thirstyOptions['legacyuploader'] . ' />
197
- </td>
198
- <td>
199
- <span class="description">'.__('Disable the new media uploader in favour of the old style uploader', 'thirstyaffiliates').'</span>
200
- </td>
201
- </tr>
202
-
203
- <tr>
204
- <th>
205
- <label for="thirstyOptions[disabletitleattribute]">'.__('Disable title attribute output on link insertion?', 'thirstyaffiliates').'</label>
206
- <td>
207
- <input type="checkbox" name="thirstyOptions[disabletitleattribute]" id="thirstyOptionsDisableTitleAttribute" ' .
208
- $thirstyOptions['disabletitleattribute'] . ' />
209
- </td>
210
- <td>
211
- <span class="description">'.__('Links are automatically output with a title html attribute (by default this shows the text
212
- that you have linked), this option lets you disable the output of the title attribute on your links.', 'thirstyaffiliates').'</span>
213
- </td>
214
- </tr>
215
-
216
- <tr>
217
- <th>
218
- <label for="thirstyOptions[disablethirstylinkclass]">'.__('Disable automatic output of ThirstyAffiliates CSS classes?', 'thirstyaffiliates').'</label>
219
- <td>
220
- <input type="checkbox" name="thirstyOptions[disablethirstylinkclass]" id="thirstyOptionsDisableThirstylinkClass" ' .
221
- $thirstyOptions['disablethirstylinkclass'] . ' />
222
- </td>
223
- <td>
224
- <span class="description">'.__('To help with styling your affiliate links a CSS class called "thirstylink" is added
225
- to the link and a CSS class called "thirstylinkimg" is added to images (when inserting image affiliate links),
226
- this option disables the addition of both of these CSS classes.', 'thirstyaffiliates').'</span>
227
- </td>
228
- </tr>
229
-
230
- <tr>
231
- <th>
232
- <label for="thirstyOptions[disableslugshortening]">'.__('Disable slug shortening?', 'thirstyaffiliates').'</label>
233
- <td>
234
- <input type="checkbox" name="thirstyOptions[disableslugshortening]" id="thirstyOptionsDisableSlugShortening" ' .
235
- $thirstyOptions['disableslugshortening'] . ' />
236
- </td>
237
- <td>
238
- <span class="description">'.__('By default, ThirstyAffiliates removes superfluous words from your cloaked link URLs, this option turns that feature off.', 'thirstyaffiliates').'</span>
239
- </td>
240
- </tr>
241
-
242
- <tr>
243
- <th>
244
- <label for="thirstyOptions[disablevisualeditorbuttons]">'.__('Disable buttons on the Visual editor?', 'thirstyaffiliates').'</label>
245
- <td>
246
- <input type="checkbox" name="thirstyOptions[disablevisualeditorbuttons]" id="thirstyOptionsDisableVisualEditorButtons" ' .
247
- $thirstyOptions['disablevisualeditorbuttons'] . ' />
248
- </td>
249
- <td>
250
- <span class="description">'.__('Hide the ThirstyAffiliates buttons on the Visual editor.', 'thirstyaffiliates').'</span>
251
- </td>
252
- </tr>
253
-
254
- <tr>
255
- <th>
256
- <label for="thirstyOptions[disabletexteditorbuttons]">'.__('Disable buttons on the Text/Quicktags editor?', 'thirstyaffiliates').'</label>
257
- <td>
258
- <input type="checkbox" name="thirstyOptions[disabletexteditorbuttons]" id="thirstyOptionsDisableTextEditorButtons" ' .
259
- $thirstyOptions['disabletexteditorbuttons'] . ' />
260
- </td>
261
- <td>
262
- <span class="description">'.__('Hide the ThirstyAffiliates buttons on the Text editor.', 'thirstyaffiliates').'</span>
263
- </td>
264
- </tr>
265
-
266
- <tr>
267
- <th>
268
- <label for="thirstyOptions[additionalreltags]">'.__('Additional rel attribute tags to add during link insertion: ', 'thirstyaffiliates').'</label>
269
- <td>
270
- <input type="text" name="thirstyOptions[additionalreltags]" id="thirstyOptionsAdditionalRelTags" value="' .
271
- $additionalreltags . '" />
272
- </td>
273
- <td>
274
- <span class="description">'.__('Allows you to add extra tags into the rel= attribute when links are inserted.', 'thirstyaffiliates').'</span>
275
- </td>
276
- </tr>';
277
-
278
- do_action('thirstyAffiliatesAfterMainSettings');
279
-
280
- echo '
281
- </table>
282
-
283
- <input type="hidden" name="thirstyOptions[rebuildlinks]" id="thirstyHiddenRebuildFlag" value="false" />
284
-
285
- <input type="hidden" name="page_options" value="thirstyOptions" />
286
-
287
- <p class="submit">
288
- <input type="submit" class="button-primary" value="'.__('Save All Changes', 'thirstyaffiliates').'" />
289
- <input type="submit" id="thirstyForceLinkRebuild" class="button-secondary" value="'.__('Save & Force Link Rebuild').'" />
290
- </p>
291
-
292
- </form>
293
-
294
- <div class="thirstyWhiteBox">
295
-
296
- <h3>'.__('Plugin Information', 'thirstyaffiliates').'</h3>'.
297
-
298
- 'ThirstyAffiliates Version: '. THIRSTY_VERSION .'<br />';
299
-
300
- do_action('thirstyAffiliatesPluginInformation');
301
-
302
- echo '</div><!-- /.thirstyWhiteBox -->';
303
-
304
- do_action('thirstyAffiliatesAfterPluginInformation');
305
-
306
- echo '
307
- <div class="thirstyWhiteBox">
308
- <h3>Join The Community</h3>
309
- <ul id="thirstyCommunityLinks"><li><a href="http://thirstyaffiliates.com">'.__('Visit Our Website', 'thirstyaffiliates').'</a></li>
310
- <li><a href="' . admin_url('edit.php?post_type=thirstylink&page=thirsty-addons') . '">'.__('Browse ThirstyAffiliates Add-ons', 'thirstyaffiliates').'</a></li>
311
- <li><a href="http://thirstyaffiliates.com/affiliates">'.__('Join Our Affiliate Program', 'thirstyaffiliates').'</a> '.__('(up to 50% commissions)' ,'thirstyaffiliates').'</li>
312
- <li><a href="http://facebook.com/thirstyaffiliates" style="margin-right: 10px;">'.__('Like us on Facebook', 'thirstyaffiliates').'</a><iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fthirstyaffiliates&amp;send=false&amp;layout=button_count&amp;width=450&amp;show_faces=false&amp;font=arial&amp;colorscheme=light&amp;action=like&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px; vertical-align: bottom;" allowTransparency="true"></iframe></li>
313
- <li><a href="http://twitter.com/thirstyaff" style="margin-right: 10px;">'.__('Follow us on Twitter', 'thirstyaffiliates').'</a> <a href="https://twitter.com/thirstyaff" class="twitter-follow-button" data-show-count="true" style="vertical-align: bottom;">Follow @thirstyaff</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li>
314
- </ul>
315
- </div><!-- /.thirstyWhiteBox -->
316
-
317
- </div><!-- /.wrap -->';
318
-
319
- // Provide debug output for diagnostics and support use
320
- if(isset($_GET['debug'])){
321
- if ($_GET['debug'] == 'true') {
322
- $thirstyOptions = get_option('thirstyOptions'); // re-retrieve options in case any of the filters/actions messed with it
323
- echo '<pre>'.__('DEBUG: ','thirstyaffiliates') . print_r($thirstyOptions, true) . '</pre>';
324
- }
325
- }
326
- }
327
-
328
- /*******************************************************************************
329
- ** thirstyResaveAllLinks
330
- ** Resave all ThirstyAffiliates links in the system. Allows us to regenerate the
331
- ** slug and permalink after big settings changes.
332
- ** @since 2.1
333
- *******************************************************************************/
334
- function thirstyResaveAllLinks() {
335
-
336
- $thirstyLinkQuery = new WP_Query(array(
337
- 'post_type' => 'thirstylink',
338
- 'post_status' => 'publish',
339
- 'posts_per_page' => -1,
340
- 'ignore_sticky_posts'=> 1
341
- ));
342
-
343
- if($thirstyLinkQuery->have_posts()) {
344
- while ($thirstyLinkQuery->have_posts()) {
345
- $thirstyLinkQuery->the_post();
346
-
347
- $thirstyLink['ID'] = get_the_ID();
348
- wp_update_post($thirstyLink);
349
- }
350
- }
351
- }
352
-
353
- /*******************************************************************************
354
- ** thirstyGenerateSelectOptions
355
- ** Helper function to generate selection boxes for admin page
356
- ** @since 1.0
357
- *******************************************************************************/
358
- function thirstyGenerateSelectOptions($selectNames, $echo = false) {
359
- $thirstyOptions = get_option('thirstyOptions');
360
- $html = '';
361
-
362
- foreach ($selectNames as $selectName) {
363
- $html .= '<option value="' . $selectName . '"' . ($thirstyOptions['linkprefix'] == $selectName ? ' selected' : '') . '>' . $selectName . '</option>';
364
- }
365
-
366
- if ($echo)
367
- echo $html;
368
- else
369
- return $html;
370
- }
371
-
372
- add_action('admin_menu', 'thirstySetupMenu', 99);
373
-
374
- /*******************************************************************************
375
- ** thirstyGlobalAdminNotices
376
- ** This should only be added to for really critical configuration problems that
377
- ** the admin should know about. In most cases this shows a notice to the admin
378
- ** explaining about the config problem and what they have to do to fix it.
379
- ** @since 2.4.6
380
- *******************************************************************************/
381
- function thirstyGlobalAdminNotices() {
382
- // Check for pretty permalinks
383
- global $wp_rewrite;
384
- if (empty($wp_rewrite->permalink_structure)) {
385
- echo '<div class="error">
386
- <p>'.__('ThirstyAffiliates requires pretty permalinks, please change
387
- your', 'thirstyaffiliates').' <a href="' . admin_url('options-permalink.php') . '">'.__('Permalink settings', 'thirstyaffiliates').'</a> '.__('to something other than default.', 'thirstyaffiliates').'<a href="#" style="float: right;" id="thirstyDismissPermalinksMessage">'.__('Dismiss', 'thirstyaffiliates').'</a></p>
388
- </div>';
389
- }
390
- }
391
-
392
- add_action('admin_notices', 'thirstyGlobalAdminNotices');
393
-
394
- /**
395
- * Render export/import controls.
396
- *
397
- * @contributor J++
398
- * @since 2.5
399
- */
400
- function renderExportImportControls(){
401
- ?>
402
- <style>
403
- .export_import_settings_instruction {
404
- margin-bottom: 30px;
405
- }
406
- .export_import_settings_instruction dt {
407
- font-weight: bold;
408
- margin-bottom: 10px;
409
- }
410
- .export_import_settings_instruction dd {
411
- margin-bottom: 20px;
412
- }
413
- .export_import_settings_instruction dd ul {
414
- list-style-type: disc;
415
- }
416
- </style>
417
- <div id="export_import_controls_container" class="thirstyWhiteBox">
418
- <h3><?php _e('Export/Import Global Settings', 'thirstyaffiliates'); ?></h3>
419
-
420
- <dl class="export_import_settings_instruction">
421
- <dt><?php _e('Exporting Settings', 'thirstyaffiliates'); ?></dt>
422
- <dd>
423
- <ul>
424
- <li><?php _e('Click export settings button', 'thirstyaffiliates'); ?></li>
425
- <li><?php _e('Copy the settings text code', 'thirstyaffiliates'); ?></li>
426
- <li><?php _e('Paste in the settings code to the destination site', 'thirstyaffiliates'); ?></li>
427
- </ul>
428
- </dd>
429
-
430
- <dt><?php _e('Importing Settings', 'thirstyaffiliates'); ?></dt>
431
- <dd>
432
- <ul>
433
- <li><?php _e('Click import settings button', 'thirstyaffiliates'); ?></li>
434
- <li><?php _e('Paste the settings text code ( From other site )', 'thirstyaffiliates'); ?></li>
435
- <li><?php _e('Click import global settings button', 'thirstyaffiliates'); ?></li>
436
- </ul>
437
- </dd>
438
- </dl>
439
-
440
- <input type="button" class="button button-primary" id="export_global_settings" value="<?php _e('Export Settings', 'thirstyaffiliates'); ?>" />
441
- <input type="button" class="button button-primary" id="import_global_settings" value="<?php _e('Import Settings', 'thirstyaffiliates'); ?>" />
442
-
443
- <div id="textarea_container">
444
- <textarea id="global_settings_string" cols="40" rows="10"></textarea>
445
- </div>
446
- <input type="button" class="button button-primary" id="import_global_settings_action" value="<?php _e('Import Global Settings', 'thirstyaffiliates'); ?>"/>
447
- </div>
448
- <?php
449
- }
450
-
451
- add_action( 'thirstyAffiliatesAfterPluginInformation' , 'renderExportImportControls' );
452
-
453
- /**
454
- * Export global settings.
455
- *
456
- * @param null $dummyArg
457
- * @param bool $ajaxCall
458
- *
459
- * @contributor J++
460
- * @return bool
461
- * @since 2.5
462
- */
463
- function thirstyExportGlobalSettings( $dummyArg = null , $ajaxCall = true ){
464
- if (!current_user_can(apply_filters('thirstyAjaxOptionsCapability', 'manage_options')))
465
- die('Cheatin\', Huh?');
466
-
467
- $thirstyOption = base64_encode( serialize( get_option('thirstyOptions') ) );
468
-
469
- if($ajaxCall === true){
470
-
471
- header('Content-Type: application/json'); // specify we return json
472
- echo json_encode(array(
473
- 'status' => 'success',
474
- 'thirstyOption' => $thirstyOption
475
- ));
476
- die();
477
-
478
- }else{
479
-
480
- return true;
481
-
482
- }
483
-
484
- }
485
-
486
- add_action( "wp_ajax_thirstyExportGlobalSettings" , 'thirstyExportGlobalSettings' );
487
-
488
- /**
489
- * Import global settings.
490
- *
491
- * @param null $thirstyOptions
492
- * @param bool $ajaxCall
493
- *
494
- * @contributor J++
495
- * @return bool
496
- * @since 2.5
497
- */
498
- function thirstyImportGlobalSettings( $thirstyOptions = null , $ajaxCall = true ){
499
- if (!current_user_can(apply_filters('thirstyAjaxOptionsCapability', 'manage_options')))
500
- die('Cheatin\', Huh?');
501
-
502
- // We do this coz unserialize issues E_NOTICE on failure.
503
- error_reporting( E_ERROR | E_PARSE );
504
-
505
- if ( $ajaxCall === true )
506
- $thirstyOptions = $_POST[ 'thirstyOptions' ];
507
-
508
- $err = null;
509
- $thirstyOptions = base64_decode( $thirstyOptions );
510
-
511
- if ( !$thirstyOptions )
512
- $err = __("Failed to decode settings string", "thirstyaffiliates");
513
-
514
- if ( is_null( $err ) ) {
515
-
516
- $thirstyOptions = maybe_unserialize( $thirstyOptions );
517
-
518
- if ( !$thirstyOptions )
519
- $err = __("Failed to unserialize settings string", "thirstyaffiliates");
520
-
521
- }
522
-
523
- if ( is_null( $err ) )
524
- update_option( 'thirstyOptions' , $thirstyOptions );
525
-
526
- if($ajaxCall === true){
527
-
528
- if ( is_null( $err ) ) {
529
-
530
- header('Content-Type: application/json'); // specify we return json
531
- echo json_encode(array(
532
- 'status' => 'success'
533
- ));
534
- die();
535
-
536
- } else {
537
-
538
- header('Content-Type: application/json'); // specify we return json
539
- echo json_encode(array(
540
- 'status' => 'fail',
541
- 'error_message' => $err
542
- ));
543
- die();
544
-
545
- }
546
-
547
- }else{
548
-
549
- if ( is_null( $err ) )
550
- return true;
551
- else
552
- return false;
553
-
554
- }
555
-
556
- }
557
-
558
- add_action( "wp_ajax_thirstyImportGlobalSettings" , 'thirstyImportGlobalSettings' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ThirstyShortcode.php DELETED
@@ -1,111 +0,0 @@
1
- <?php
2
- /*******************************************************************************
3
- ** thirstyLinkByShortcode
4
- ** Allows user to specify a shortcode in the page/post to include a thirstylink
5
- *******************************************************************************/
6
- function thirstyLinkByShortcode($atts) {
7
- extract($atts);
8
-
9
- $output = '';
10
-
11
- // Sanity check, if the linkid attribute is empty we can't retrieve the link
12
- if (!empty($linkid)) {
13
- // Remove linkid, linktext and linkclass to get final link attributes
14
- $linkAttributes = array_diff_assoc(
15
- $atts,
16
- array(
17
- 'linkid' => (isset($linkid) ? $linkid : ''),
18
- 'linktext' => (isset($linktext) ? $linktext : ''),
19
- 'linkclass' => (isset($linkclass) ? $linkclass : '')
20
- )
21
- );
22
-
23
- // Backwards compatibility for linkclass shortcode attribute, should add this to the "class" link attribute
24
- if (isset($linkclass))
25
- $linkAttributes['class'] = $linkAttributes['class'] . ' ' . (isset($linkclass) ? $linkclass : '');
26
-
27
- // Retrieving via the link ID
28
- if (is_numeric($linkid)) {
29
-
30
- // Get the link and global options
31
- $thirstyOptions = get_option('thirstyOptions');
32
- $link = get_post($linkid);
33
- // Check if the link is set
34
- if (!isset($link))
35
- return;
36
-
37
- $linkData = unserialize(get_post_meta($link->ID, 'thirstyData', true));
38
-
39
- // Check if the link data is set
40
- if (!isset($linkData))
41
- return;
42
-
43
- // Get the link URL
44
- $linkAttributes['href'] = get_post_permalink($linkid);
45
-
46
- // If the link text is empty, use the link name instead
47
- if (empty($linktext)) {
48
- $linktext = $link->post_title;
49
- }
50
-
51
- // Check for no follow defaults if not specified in the shortcode attributes
52
- if (empty($linkAttributes['rel'])) {
53
- $linkAttributes['rel'] = (!empty($thirstyOptions['nofollow']) ? 'nofollow' : '');
54
-
55
- // Set the link's nofollow if global setting is not set
56
- if (empty($linkAttributes['rel']))
57
- $linkAttributes['rel'] = (isset($linkData['nofollow']) && $linkData['nofollow'] == 'on' ? 'nofollow' : '');
58
- }
59
-
60
- // Check for no follow defaults if not specified in the shortcode attributes
61
- if (empty($linkAttributes['target'])) {
62
- $linkAttributes['target'] = (!empty($thirstyOptions['newwindow']) ? '_blank' : '');
63
-
64
- // Set the link's target value if global setting is not set
65
- if (empty($linkAttributes['target']))
66
- $linkAttributes['target'] = (isset($linkData['newwindow']) && $linkData['newwindow'] == 'on' ? '_blank' : '');
67
- }
68
-
69
- // Provide a default value for link class when attribute is not given in shortcode
70
- if (empty($linkAttributes['class'])) {
71
- $linkAttributes['class'] = 'thirstylink';
72
- }
73
-
74
- // Disable class output if global option set
75
- if (!empty($thirstyOptions['disablethirstylinkclass']))
76
- unset($linkAttributes['class']);
77
-
78
- // Provide a default value for the title attribute when attribute is not given in shortcode
79
- if (empty($linkAttributes['title'])) {
80
- $linkAttributes['title'] = $link->post_title;
81
- }
82
-
83
- // Disable title attribute if global option set
84
- if (!empty($thirstyOptions['disabletitleattribute']))
85
- unset($linkAttributes['title']);
86
-
87
- // Build the link ready for output
88
- $output .= '<a';
89
-
90
- foreach ($linkAttributes as $name => $value) {
91
- // Handle square bracket escaping (used for some addons, eg. Google Analytics click tracking)
92
- $value = html_entity_decode($value);
93
- $value = preg_replace('/&#91;/', '[', $value);
94
- $value = preg_replace('/&#93;/', ']', $value);
95
- $output .= (!empty($value) ? ' ' . $name . '="' . $value . '"' : '');
96
- }
97
-
98
- $output .= '>' . $linktext . '</a>';
99
-
100
- } else {
101
- $output .= '<span style="color: #0000ff;">'.__('SHORTCODE ERROR: ThirstyAffiliates did not detect a valid link id, please check your short code!').'</span>';
102
- }
103
-
104
- }
105
-
106
- return $output;
107
- }
108
-
109
- // Add a shortcode for thirsty affiliate links
110
- add_shortcode('thirstylink', 'thirstyLinkByShortcode', 1);
111
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/admin/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
css/admin/ta-guided-tour.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ .ta-tour-buttons {
2
+ display: block;
3
+ text-align: right;
4
+ }
5
+ .ta-tour-buttons > .button {
6
+ margin-left: 10px;
7
+ }
8
+ .wp-pointer ul {
9
+ padding: 0 15px 0 40px;
10
+ list-style: disc;
11
+ }
css/admin/ta-reports.css ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Top Navigation */
2
+ .thirsty-nav-tab {
3
+ margin: 20px 0 15px;
4
+ position: relative;
5
+ }
6
+ .thirsty-nav-tab:after {
7
+ content: '';
8
+ display: block;
9
+ position: absolute;
10
+ z-index: 1;
11
+ bottom: -1px;
12
+ width: 100%;
13
+ height:1px;
14
+ border-top: 1px solid #ccc;
15
+ }
16
+ .thirsty-nav-tab a.tab {
17
+ display: inline-block;
18
+ position: relative;
19
+ z-index: 2;
20
+ padding: 8px 10px;
21
+ margin-right: 2px;
22
+ background: #e5e5e5;
23
+ border: 1px solid #ccc;
24
+ text-decoration: none;
25
+ font-weight: bold;
26
+ color: #111;
27
+ font-size: 14px;
28
+ }
29
+ .thirsty-nav-tab a.tab:hover {
30
+ background: #fff;
31
+ }
32
+ .thirsty-nav-tab a.tab-active {
33
+ background: #f1f1f1 !important;
34
+ border-bottom-color: #f1f1f1;
35
+ }
36
+ .thirsty-nav-tab a.tab:first-child {
37
+ margin-left: 8px;
38
+ }
39
+
40
+ /* Range navigation */
41
+ .link-performance-report {
42
+ position: relative;
43
+ background:#fff;
44
+ min-height: 300px;
45
+ border: 1px solid #dedede;
46
+ }
47
+ .link-performance-report .stats-range {
48
+ position: relative;
49
+ background: #f7f7f7;
50
+ }
51
+ .link-performance-report .stats-range:after {
52
+ content: '';
53
+ display: table;
54
+ position: absolute;
55
+ z-index: 1;
56
+ bottom: -1px;
57
+ border-top: 1px solid #ccc;
58
+ width: 100%;
59
+ height: 1px;
60
+ }
61
+ .link-performance-report .stats-range ul {
62
+ margin: 0;
63
+ padding: 0;
64
+ }
65
+ .link-performance-report .stats-range ul:after {
66
+ content: '';
67
+ display: block;
68
+ clear: both;
69
+ }
70
+ .link-performance-report .stats-range ul li {
71
+ float: left;
72
+ position: relative;
73
+ margin: 0;
74
+ }
75
+ .link-performance-report .stats-range ul li a,
76
+ .link-performance-report .stats-range ul li > span {
77
+ position:relative;
78
+ z-index: 2;
79
+ display: block;
80
+ padding: 15px 10px;
81
+ font-weight: bold;
82
+ font-size: 14px;
83
+ text-decoration: none;
84
+ border-right: 1px solid #dedede;
85
+ border-bottom: 1px solid transparent;
86
+ }
87
+ .link-performance-report .stats-range ul li.current a {
88
+ background:#fff;
89
+ border-bottom-color: #fff;
90
+ color: #555 !important;
91
+ }
92
+ .link-performance-report .stats-range ul li.custom-range {
93
+ width: 400px;
94
+ }
95
+ .link-performance-report .stats-range ul li.custom-range span {
96
+ display: inline-block;
97
+ float: left;
98
+ color: #555;
99
+ border-right: 0;
100
+ }
101
+ .link-performance-report .stats-range ul li.custom-range:after {
102
+ content: '';
103
+ display: table;
104
+ clear: both;
105
+ }
106
+
107
+ /* Custom range form */
108
+ #custom-date-range {
109
+ margin-top: 10px;
110
+ }
111
+ #custom-date-range .range_datepicker {
112
+ float: left;
113
+ width: 100px;
114
+ text-align: center;
115
+ background: transparent;
116
+ border: 0;
117
+ box-shadow: none;
118
+ -moz-box-shadow: none;
119
+ -webkit-box-shadow: none;
120
+ }
121
+ #custom-date-range span {
122
+ display: inline-block;
123
+ float: left;
124
+ margin-top: 3px;
125
+ }
126
+
127
+ /* Chart layout */
128
+ .chart-sidebar {
129
+ display: block;
130
+ width: 225px;
131
+ float: left;
132
+ }
133
+ .report-chart-wrap {
134
+ margin: 10px;
135
+ }
136
+
137
+ /* Chart legend */
138
+ ul.chart-legend {
139
+ margin: 15px 0 0 0;
140
+ border: 1px solid #dadada;
141
+ border-right: 0;
142
+ }
143
+ ul.chart-legend li {
144
+ padding: 10px 15px;
145
+ margin: 0;
146
+ border-right: 5px solid #ccc;
147
+ border-bottom: 1px solid #dadada !important;
148
+ }
149
+ ul.chart-legend li span {
150
+ display: block;
151
+ color: #aaa;
152
+ font-size: 11px;
153
+ }
154
+ ul.chart-legend li:hover {
155
+ background: #efefef;
156
+ }
157
+ ul.chart-legend li:last-child {
158
+ border-bottom: 0 !important;
159
+ }
160
+ .add-legend {
161
+ padding: 7px 12px;
162
+ border: 1px solid #dadada;
163
+ border-top: 0;
164
+ }
165
+ .add-legend:after {
166
+ content: '';
167
+ display: table;
168
+ clear: both;
169
+ }
170
+ .add-legend label {
171
+ display: block;
172
+ margin-bottom: 5px;
173
+ }
174
+ .add-legend input {
175
+ width: 100%;
176
+ padding: 5px;
177
+ box-sizing: border-box;
178
+ }
179
+ .add-legend button {
180
+ float: right;
181
+ }
182
+ .add-legend .input-wrap {
183
+ position: relative;
184
+ margin-bottom: 5px;
185
+ }
186
+ .add-legend ul.link-search-result {
187
+ position: absolute;
188
+ z-index: 2;
189
+ top: 100%;
190
+ left: 0;
191
+ width: 99%;
192
+ margin: -2px 0 0 1px;
193
+ background: #fff;
194
+ border: 1px solid #dadada;
195
+ }
196
+ .add-legend ul.link-search-result li {
197
+ margin: 0;
198
+ padding: 3px 5px;
199
+ border-bottom: 1px solid #dadada;
200
+ white-space: nowrap;
201
+ overflow: hidden;
202
+ }
203
+ .add-legend ul.link-search-result li:hover {
204
+ background: #efefef;
205
+ cursor: pointer;
206
+ }
207
+
208
+
209
+ /* Chart placeholder */
210
+ .report-chart-placeholder {
211
+ height: 600px;
212
+ margin-left: 235px;
213
+ }
214
+ .report-chart-placeholder:after {
215
+ content: '';
216
+ display: table;
217
+ clear: both;
218
+ }
219
+ body .chart-tooltip {
220
+ position: absolute;
221
+ padding: 3px 5px;
222
+ background: rgba( 0, 0, 0, 0.8 );
223
+ color: #fff;
224
+ font-size: 11px;
225
+ border-radius: 5px;
226
+ }
227
+
228
+ /* overlay */
229
+ .link-performance-report .overlay {
230
+ display: none;
231
+ position: absolute;
232
+ top: 0;
233
+ left:0;
234
+ background-image: url( '../../images/spinner-2x.gif' );
235
+ background-repeat: no-repeat;
236
+ background-position: center center;
237
+ background-color: rgba(255, 255, 255, 0.64);
238
+ width: 100%;
239
+ height: 1000px;
240
+ z-index: 10;
241
+ }
css/admin/ta-settings.css ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ta-settings .form-table td,
2
+ .ta-settings .form-table th {
3
+ vertical-align: top;
4
+ padding: 20px 10px 20px 0;
5
+ }
6
+ .ta-settings .form-table .submit-wrapper {
7
+ padding: 0;
8
+ }
9
+ .ta-settings .form-table .forminp-radio label {
10
+ margin-top: 0 !important;
11
+ line-height: 1em;
12
+ }
13
+ .ta-settings .form-table .forminp-radio ul {
14
+ margin: 5px 0 0;
15
+ }
16
+ .ta-settings .form-table .forminp-checkbox label {
17
+ margin-top: 5px !important;
18
+ line-height: 1em;
19
+ }
20
+ .ta-settings .form-table td .description {
21
+ margin-top: 0;
22
+ }
23
+ tr.ta_link_prefix_custom-row {
24
+ display: none;
25
+ }
26
+ .ta-settings .uncloak-links-select2 , .ta-settings .select2 {
27
+ width: 100%;
28
+ }
29
+ .ta_category_to_uncloak-row span.select2-selection__clear { display: none; }
css/admin/tinymce/editor.css ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mce-container div.wp-thirstylink-input {
2
+ float: left;
3
+ margin: 2px;
4
+ max-width: 694px;
5
+ position: relative;
6
+ }
7
+
8
+ .mce-container div.wp-thirstylink-input input {
9
+ width: 300px;
10
+ padding: 5px;
11
+ -webkit-box-sizing: border-box;
12
+ -moz-box-sizing: border-box;
13
+ box-sizing: border-box
14
+ }
15
+ .mce-container div.wp-thirstylink-input .affiliate-link-list {
16
+ position: absolute;
17
+ top: 100%;
18
+ left: 0;
19
+ width: 100%;
20
+ max-height: 150px;
21
+ overflow: auto;
22
+ border: 1px solid #eee;
23
+ background: #fff;
24
+ }
25
+ .mce-container div.wp-thirstylink-input .affiliate-link-list li {
26
+ padding: 5px;
27
+ border-bottom: 1px solid #eee;
28
+ cursor: pointer;
29
+ }
30
+ .mce-container div.wp-thirstylink-input .affiliate-link-list li:hover {
31
+ background: #eee;
32
+ }
33
+ .mce-container div.wp-thirstylink-input .affiliate-link-list li * {
34
+ font-size: 13px;
35
+ }
36
+ .mce-container div.wp-thirstylink-input .affiliate-link-list li:last-child {
37
+ border-bottom: 0;
38
+ }
css/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
css/lib/jquery-tiptip/jquery-tiptip.css ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* TipTip CSS - Version 1.2 */
2
+
3
+ #tiptip_holder {
4
+ display: none;
5
+ position: absolute;
6
+ top: 0;
7
+ left: 0;
8
+ z-index: 99999;
9
+ }
10
+
11
+ #tiptip_holder.tip_top {
12
+ padding-bottom: 5px;
13
+ }
14
+
15
+ #tiptip_holder.tip_bottom {
16
+ padding-top: 5px;
17
+ }
18
+
19
+ #tiptip_holder.tip_right {
20
+ padding-left: 5px;
21
+ }
22
+
23
+ #tiptip_holder.tip_left {
24
+ padding-right: 5px;
25
+ }
26
+
27
+ #tiptip_content {
28
+ font-size: 11px;
29
+ color: #fff;
30
+ text-shadow: 0 0 2px #000;
31
+ padding: 4px 8px;
32
+ border: 1px solid rgba(255,255,255,0.25);
33
+ background-color: rgb(25,25,25);
34
+ background-color: rgba(25,25,25,0.92);
35
+ border-radius: 3px;
36
+ -webkit-border-radius: 3px;
37
+ -moz-border-radius: 3px;
38
+ }
39
+
40
+ #tiptip_arrow, #tiptip_arrow_inner {
41
+ position: absolute;
42
+ border-color: transparent;
43
+ border-style: solid;
44
+ border-width: 6px;
45
+ height: 0;
46
+ width: 0;
47
+ }
48
+
49
+ #tiptip_holder.tip_top #tiptip_arrow {
50
+ border-top-color: #fff;
51
+ border-top-color: rgba(255,255,255,0.35);
52
+ }
53
+
54
+ #tiptip_holder.tip_bottom #tiptip_arrow {
55
+ border-bottom-color: #fff;
56
+ border-bottom-color: rgba(255,255,255,0.35);
57
+ }
58
+
59
+ #tiptip_holder.tip_right #tiptip_arrow {
60
+ border-right-color: #fff;
61
+ border-right-color: rgba(255,255,255,0.35);
62
+ }
63
+
64
+ #tiptip_holder.tip_left #tiptip_arrow {
65
+ border-left-color: #fff;
66
+ border-left-color: rgba(255,255,255,0.35);
67
+ }
68
+
69
+ #tiptip_holder.tip_top #tiptip_arrow_inner {
70
+ margin-top: -7px;
71
+ margin-left: -6px;
72
+ border-top-color: rgb(25,25,25);
73
+ border-top-color: rgba(25,25,25,0.92);
74
+ }
75
+
76
+ #tiptip_holder.tip_bottom #tiptip_arrow_inner {
77
+ margin-top: -5px;
78
+ margin-left: -6px;
79
+ border-bottom-color: rgb(25,25,25);
80
+ border-bottom-color: rgba(25,25,25,0.92);
81
+ }
82
+
83
+ #tiptip_holder.tip_right #tiptip_arrow_inner {
84
+ margin-top: -6px;
85
+ margin-left: -5px;
86
+ border-right-color: rgb(25,25,25);
87
+ border-right-color: rgba(25,25,25,0.92);
88
+ }
89
+
90
+ #tiptip_holder.tip_left #tiptip_arrow_inner {
91
+ margin-top: -6px;
92
+ margin-left: -7px;
93
+ border-left-color: rgb(25,25,25);
94
+ border-left-color: rgba(25,25,25,0.92);
95
+ }
96
+
97
+ /* Webkit Hacks */
98
+ @media screen and (-webkit-min-device-pixel-ratio:0) {
99
+ #tiptip_content {
100
+ padding: 4px 8px 5px 8px;
101
+ background-color: rgba(45,45,45,0.88);
102
+ }
103
+ #tiptip_holder.tip_bottom #tiptip_arrow_inner {
104
+ border-bottom-color: rgba(45,45,45,0.88);
105
+ }
106
+ #tiptip_holder.tip_top #tiptip_arrow_inner {
107
+ border-top-color: rgba(20,20,20,0.92);
108
+ }
109
+ }
css/lib/select2/select2.css ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .select2-container {
2
+ box-sizing: border-box;
3
+ display: inline-block;
4
+ margin: 0;
5
+ position: relative;
6
+ vertical-align: middle; }
7
+ .select2-container .select2-selection--single {
8
+ box-sizing: border-box;
9
+ cursor: pointer;
10
+ display: block;
11
+ height: 28px;
12
+ user-select: none;
13
+ -webkit-user-select: none; }
14
+ .select2-container .select2-selection--single .select2-selection__rendered {
15
+ display: block;
16
+ padding-left: 8px;
17
+ padding-right: 20px;
18
+ overflow: hidden;
19
+ text-overflow: ellipsis;
20
+ white-space: nowrap; }
21
+ .select2-container .select2-selection--single .select2-selection__clear {
22
+ position: relative; }
23
+ .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
24
+ padding-right: 8px;
25
+ padding-left: 20px; }
26
+ .select2-container .select2-selection--multiple {
27
+ box-sizing: border-box;
28
+ cursor: pointer;
29
+ display: block;
30
+ min-height: 32px;
31
+ user-select: none;
32
+ -webkit-user-select: none; }
33
+ .select2-container .select2-selection--multiple .select2-selection__rendered {
34
+ display: inline-block;
35
+ overflow: hidden;
36
+ padding-left: 8px;
37
+ text-overflow: ellipsis;
38
+ white-space: nowrap; }
39
+ .select2-container .select2-search--inline {
40
+ float: left; }
41
+ .select2-container .select2-search--inline .select2-search__field {
42
+ box-sizing: border-box;
43
+ border: none;
44
+ font-size: 100%;
45
+ margin-top: 5px;
46
+ padding: 0; }
47
+ .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
48
+ -webkit-appearance: none; }
49
+
50
+ .select2-dropdown {
51
+ background-color: white;
52
+ border: 1px solid #aaa;
53
+ border-radius: 4px;
54
+ box-sizing: border-box;
55
+ display: block;
56
+ position: absolute;
57
+ left: -100000px;
58
+ width: 100%;
59
+ z-index: 1051; }
60
+
61
+ .select2-results {
62
+ display: block; }
63
+
64
+ .select2-results__options {
65
+ list-style: none;
66
+ margin: 0;
67
+ padding: 0; }
68
+
69
+ .select2-results__option {
70
+ padding: 6px;
71
+ user-select: none;
72
+ -webkit-user-select: none; }
73
+ .select2-results__option[aria-selected] {
74
+ cursor: pointer; }
75
+
76
+ .select2-container--open .select2-dropdown {
77
+ left: 0; }
78
+
79
+ .select2-container--open .select2-dropdown--above {
80
+ border-bottom: none;
81
+ border-bottom-left-radius: 0;
82
+ border-bottom-right-radius: 0; }
83
+
84
+ .select2-container--open .select2-dropdown--below {
85
+ border-top: none;
86
+ border-top-left-radius: 0;
87
+ border-top-right-radius: 0; }
88
+
89
+ .select2-search--dropdown {
90
+ display: block;
91
+ padding: 4px; }
92
+ .select2-search--dropdown .select2-search__field {
93
+ padding: 4px;
94
+ width: 100%;
95
+ box-sizing: border-box; }
96
+ .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
97
+ -webkit-appearance: none; }
98
+ .select2-search--dropdown.select2-search--hide {
99
+ display: none; }
100
+
101
+ .select2-close-mask {
102
+ border: 0;
103
+ margin: 0;
104
+ padding: 0;
105
+ display: block;
106
+ position: fixed;
107
+ left: 0;
108
+ top: 0;
109
+ min-height: 100%;
110
+ min-width: 100%;
111
+ height: auto;
112
+ width: auto;
113
+ opacity: 0;
114
+ z-index: 99;
115
+ background-color: #fff;
116
+ filter: alpha(opacity=0); }
117
+
118
+ .select2-hidden-accessible {
119
+ border: 0 !important;
120
+ clip: rect(0 0 0 0) !important;
121
+ height: 1px !important;
122
+ margin: -1px !important;
123
+ overflow: hidden !important;
124
+ padding: 0 !important;
125
+ position: absolute !important;
126
+ width: 1px !important; }
127
+
128
+ .select2-container--default .select2-selection--single {
129
+ background-color: #fff;
130
+ border: 1px solid #aaa;
131
+ border-radius: 4px; }
132
+ .select2-container--default .select2-selection--single .select2-selection__rendered {
133
+ color: #444;
134
+ line-height: 28px; }
135
+ .select2-container--default .select2-selection--single .select2-selection__clear {
136
+ cursor: pointer;
137
+ float: right;
138
+ font-weight: bold; }
139
+ .select2-container--default .select2-selection--single .select2-selection__placeholder {
140
+ color: #999; }
141
+ .select2-container--default .select2-selection--single .select2-selection__arrow {
142
+ height: 26px;
143
+ position: absolute;
144
+ top: 1px;
145
+ right: 1px;
146
+ width: 20px; }
147
+ .select2-container--default .select2-selection--single .select2-selection__arrow b {
148
+ border-color: #888 transparent transparent transparent;
149
+ border-style: solid;
150
+ border-width: 5px 4px 0 4px;
151
+ height: 0;
152
+ left: 50%;
153
+ margin-left: -4px;
154
+ margin-top: -2px;
155
+ position: absolute;
156
+ top: 50%;
157
+ width: 0; }
158
+
159
+ .select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear {
160
+ float: left; }
161
+
162
+ .select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow {
163
+ left: 1px;
164
+ right: auto; }
165
+
166
+ .select2-container--default.select2-container--disabled .select2-selection--single {
167
+ background-color: #eee;
168
+ cursor: default; }
169
+ .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear {
170
+ display: none; }
171
+
172
+ .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
173
+ border-color: transparent transparent #888 transparent;
174
+ border-width: 0 4px 5px 4px; }
175
+
176
+ .select2-container--default .select2-selection--multiple {
177
+ background-color: white;
178
+ border: 1px solid #aaa;
179
+ border-radius: 4px;
180
+ cursor: text; }
181
+ .select2-container--default .select2-selection--multiple .select2-selection__rendered {
182
+ box-sizing: border-box;
183
+ list-style: none;
184
+ margin: 0;
185
+ padding: 0 5px;
186
+ width: 100%; }
187
+ .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
188
+ list-style: none; }
189
+ .select2-container--default .select2-selection--multiple .select2-selection__placeholder {
190
+ color: #999;
191
+ margin-top: 5px;
192
+ float: left; }
193
+ .select2-container--default .select2-selection--multiple .select2-selection__clear {
194
+ cursor: pointer;
195
+ float: right;
196
+ font-weight: bold;
197
+ margin-top: 5px;
198
+ margin-right: 10px; }
199
+ .select2-container--default .select2-selection--multiple .select2-selection__choice {
200
+ background-color: #e4e4e4;
201
+ border: 1px solid #aaa;
202
+ border-radius: 4px;
203
+ cursor: default;
204
+ float: left;
205
+ margin-right: 5px;
206
+ margin-top: 5px;
207
+ padding: 0 5px; }
208
+ .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
209
+ color: #999;
210
+ cursor: pointer;
211
+ display: inline-block;
212
+ font-weight: bold;
213
+ margin-right: 2px; }
214
+ .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
215
+ color: #333; }
216
+
217
+ .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
218
+ float: right; }
219
+
220
+ .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
221
+ margin-left: 5px;
222
+ margin-right: auto; }
223
+
224
+ .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
225
+ margin-left: 2px;
226
+ margin-right: auto; }
227
+
228
+ .select2-container--default.select2-container--focus .select2-selection--multiple {
229
+ border: solid black 1px;
230
+ outline: 0; }
231
+
232
+ .select2-container--default.select2-container--disabled .select2-selection--multiple {
233
+ background-color: #eee;
234
+ cursor: default; }
235
+
236
+ .select2-container--default.select2-container--disabled .select2-selection__choice__remove {
237
+ display: none; }
238
+
239
+ .select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple {
240
+ border-top-left-radius: 0;
241
+ border-top-right-radius: 0; }
242
+
243
+ .select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
244
+ border-bottom-left-radius: 0;
245
+ border-bottom-right-radius: 0; }
246
+
247
+ .select2-container--default .select2-search--dropdown .select2-search__field {
248
+ border: 1px solid #aaa; }
249
+
250
+ .select2-container--default .select2-search--inline .select2-search__field {
251
+ background: transparent;
252
+ border: none;
253
+ outline: 0;
254
+ box-shadow: none;
255
+ -webkit-appearance: textfield; }
256
+
257
+ .select2-container--default .select2-results > .select2-results__options {
258
+ max-height: 200px;
259
+ overflow-y: auto; }
260
+
261
+ .select2-container--default .select2-results__option[role=group] {
262
+ padding: 0; }
263
+
264
+ .select2-container--default .select2-results__option[aria-disabled=true] {
265
+ color: #999; }
266
+
267
+ .select2-container--default .select2-results__option[aria-selected=true] {
268
+ background-color: #ddd; }
269
+
270
+ .select2-container--default .select2-results__option .select2-results__option {
271
+ padding-left: 1em; }
272
+ .select2-container--default .select2-results__option .select2-results__option .select2-results__group {
273
+ padding-left: 0; }
274
+ .select2-container--default .select2-results__option .select2-results__option .select2-results__option {
275
+ margin-left: -1em;
276
+ padding-left: 2em; }
277
+ .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
278
+ margin-left: -2em;
279
+ padding-left: 3em; }
280
+ .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
281
+ margin-left: -3em;
282
+ padding-left: 4em; }
283
+ .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
284
+ margin-left: -4em;
285
+ padding-left: 5em; }
286
+ .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
287
+ margin-left: -5em;
288
+ padding-left: 6em; }
289
+
290
+ .select2-container--default .select2-results__option--highlighted[aria-selected] {
291
+ background-color: #5897fb;
292
+ color: white; }
293
+
294
+ .select2-container--default .select2-results__group {
295
+ cursor: default;
296
+ display: block;
297
+ padding: 6px; }
298
+
299
+ .select2-container--classic .select2-selection--single {
300
+ background-color: #f7f7f7;
301
+ border: 1px solid #aaa;
302
+ border-radius: 4px;
303
+ outline: 0;
304
+ background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%);
305
+ background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%);
306
+ background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%);
307
+ background-repeat: repeat-x;
308
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
309
+ .select2-container--classic .select2-selection--single:focus {
310
+ border: 1px solid #5897fb; }
311
+ .select2-container--classic .select2-selection--single .select2-selection__rendered {
312
+ color: #444;
313
+ line-height: 28px; }
314
+ .select2-container--classic .select2-selection--single .select2-selection__clear {
315
+ cursor: pointer;
316
+ float: right;
317
+ font-weight: bold;
318
+ margin-right: 10px; }
319
+ .select2-container--classic .select2-selection--single .select2-selection__placeholder {
320
+ color: #999; }
321
+ .select2-container--classic .select2-selection--single .select2-selection__arrow {
322
+ background-color: #ddd;
323
+ border: none;
324
+ border-left: 1px solid #aaa;
325
+ border-top-right-radius: 4px;
326
+ border-bottom-right-radius: 4px;
327
+ height: 26px;
328
+ position: absolute;
329
+ top: 1px;
330
+ right: 1px;
331
+ width: 20px;
332
+ background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
333
+ background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
334
+ background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);
335
+ background-repeat: repeat-x;
336
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); }
337
+ .select2-container--classic .select2-selection--single .select2-selection__arrow b {
338
+ border-color: #888 transparent transparent transparent;
339
+ border-style: solid;
340
+ border-width: 5px 4px 0 4px;
341
+ height: 0;
342
+ left: 50%;
343
+ margin-left: -4px;
344
+ margin-top: -2px;
345
+ position: absolute;
346
+ top: 50%;
347
+ width: 0; }
348
+
349
+ .select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear {
350
+ float: left; }
351
+
352
+ .select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow {
353
+ border: none;
354
+ border-right: 1px solid #aaa;
355
+ border-radius: 0;
356
+ border-top-left-radius: 4px;
357
+ border-bottom-left-radius: 4px;
358
+ left: 1px;
359
+ right: auto; }
360
+
361
+ .select2-container--classic.select2-container--open .select2-selection--single {
362
+ border: 1px solid #5897fb; }
363
+ .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
364
+ background: transparent;
365
+ border: none; }
366
+ .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b {
367
+ border-color: transparent transparent #888 transparent;
368
+ border-width: 0 4px 5px 4px; }
369
+
370
+ .select2-container--classic.select2-container--open.select2-container--above .select2-selection--single {
371
+ border-top: none;
372
+ border-top-left-radius: 0;
373
+ border-top-right-radius: 0;
374
+ background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%);
375
+ background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
376
+ background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%);
377
+ background-repeat: repeat-x;
378
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
379
+
380
+ .select2-container--classic.select2-container--open.select2-container--below .select2-selection--single {
381
+ border-bottom: none;
382
+ border-bottom-left-radius: 0;
383
+ border-bottom-right-radius: 0;
384
+ background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%);
385
+ background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%);
386
+ background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%);
387
+ background-repeat: repeat-x;
388
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); }
389
+
390
+ .select2-container--classic .select2-selection--multiple {
391
+ background-color: white;
392
+ border: 1px solid #aaa;
393
+ border-radius: 4px;
394
+ cursor: text;
395
+ outline: 0; }
396
+ .select2-container--classic .select2-selection--multiple:focus {
397
+ border: 1px solid #5897fb; }
398
+ .select2-container--classic .select2-selection--multiple .select2-selection__rendered {
399
+ list-style: none;
400
+ margin: 0;
401
+ padding: 0 5px; }
402
+ .select2-container--classic .select2-selection--multiple .select2-selection__clear {
403
+ display: none; }
404
+ .select2-container--classic .select2-selection--multiple .select2-selection__choice {
405
+ background-color: #e4e4e4;
406
+ border: 1px solid #aaa;
407
+ border-radius: 4px;
408
+ cursor: default;
409
+ float: left;
410
+ margin-right: 5px;
411
+ margin-top: 5px;
412
+ padding: 0 5px; }
413
+ .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove {
414
+ color: #888;
415
+ cursor: pointer;
416
+ display: inline-block;
417
+ font-weight: bold;
418
+ margin-right: 2px; }
419
+ .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
420
+ color: #555; }
421
+
422
+ .select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
423
+ float: right; }
424
+
425
+ .select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
426
+ margin-left: 5px;
427
+ margin-right: auto; }
428
+
429
+ .select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
430
+ margin-left: 2px;
431
+ margin-right: auto; }
432
+
433
+ .select2-container--classic.select2-container--open .select2-selection--multiple {
434
+ border: 1px solid #5897fb; }
435
+
436
+ .select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple {
437
+ border-top: none;
438
+ border-top-left-radius: 0;
439
+ border-top-right-radius: 0; }
440
+
441
+ .select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple {
442
+ border-bottom: none;
443
+ border-bottom-left-radius: 0;
444
+ border-bottom-right-radius: 0; }
445
+
446
+ .select2-container--classic .select2-search--dropdown .select2-search__field {
447
+ border: 1px solid #aaa;
448
+ outline: 0; }
449
+
450
+ .select2-container--classic .select2-search--inline .select2-search__field {
451
+ outline: 0;
452
+ box-shadow: none; }
453
+
454
+ .select2-container--classic .select2-dropdown {
455
+ background-color: white;
456
+ border: 1px solid transparent; }
457
+
458
+ .select2-container--classic .select2-dropdown--above {
459
+ border-bottom: none; }
460
+
461
+ .select2-container--classic .select2-dropdown--below {
462
+ border-top: none; }
463
+
464
+ .select2-container--classic .select2-results > .select2-results__options {
465
+ max-height: 200px;
466
+ overflow-y: auto; }
467
+
468
+ .select2-container--classic .select2-results__option[role=group] {
469
+ padding: 0; }
470
+
471
+ .select2-container--classic .select2-results__option[aria-disabled=true] {
472
+ color: grey; }
473
+
474
+ .select2-container--classic .select2-results__option--highlighted[aria-selected] {
475
+ background-color: #3875d7;
476
+ color: white; }
477
+
478
+ .select2-container--classic .select2-results__group {
479
+ cursor: default;
480
+ display: block;
481
+ padding: 6px; }
482
+
483
+ .select2-container--classic.select2-container--open .select2-dropdown {
484
+ border-color: #5897fb; }
css/lib/select2/select2.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
css/thirstystyle.css DELETED
@@ -1,276 +0,0 @@
1
- /*******************************************************************************
2
- ** File: thirstystyle.css
3
- ** Description: Admin styles for ThirstyAffiliates plugin
4
- *******************************************************************************/
5
-
6
- .infolabel {
7
- padding-bottom: 5px;
8
- }
9
-
10
- #thirsty_linkname, #thirsty_linkurl, #thirsty_linkslug, .infotext, #thirsty_cloakedurl {
11
- height: 31px;
12
- font-size: 14px;
13
- border: 1px solid #DFDFDF;
14
- width: 100%;
15
- margin: 0;
16
- padding: 5px;
17
- }
18
-
19
- .infotext {
20
- height: 16px;
21
- }
22
-
23
- #thirsty_linkslug, #thirstySaveSlug {
24
- display: none;
25
- }
26
-
27
-
28
- #thirstyEditSlug, #thirstyVisitLink {
29
- display: inline-block;
30
- margin-top: 5px;
31
- }
32
-
33
- #thirstySaveSlug {
34
- margin-top: 5px;
35
- }
36
-
37
- #thirstyEditSlug:hover, #thirstyVisitLink:hover {
38
- border: 1px solid #666666;
39
- }
40
-
41
- .thirstySaveMe {
42
- display: none;
43
- color: #0000ff;
44
- }
45
-
46
- #thirstylink-main-meta div.inside {
47
- background: #ffffff;
48
- margin: 0;
49
- padding: 0 0 30px 0;
50
- }
51
-
52
- #thirsty_upload_insert_img {
53
- font-size: 12px;
54
- font-family: Arial, sans serif;
55
- }
56
-
57
- .thirsty_description {
58
- color: #909090;
59
- padding-left: 2px;
60
- font-style: italic;
61
- font-size: 10px !important;
62
- }
63
-
64
- #thirsty_logo {
65
- margin: 25px 0 15px 30px;
66
- float: left;
67
- width: 100%;
68
- }
69
-
70
- #thirsty_add_images {
71
- cursor: pointer;
72
- vertical-align: middle;
73
- }
74
-
75
- #thirsty_upload_insert_img {
76
- margin-top: 15px;
77
- }
78
-
79
- #thirsty_image_holder {
80
- background: white;
81
- overflow: hidden;
82
- padding: 0px 0px 20px 0px;
83
- margin: 0;
84
- border: 1px solid #DFDFDF;
85
- text-align: center;
86
- }
87
-
88
- .thirstyImg img {
89
- }
90
-
91
- #thirsty_cloakedurl {
92
- display: inline;
93
- }
94
-
95
- #publish {
96
- margin-top: 8px;
97
- margin-bottom: 5px;
98
- }
99
-
100
- .submitdelete {
101
- color: #ff0000;
102
- font-weight: normal;
103
- text-decoration: underline;
104
- }
105
-
106
- .thirstyImgHolder {
107
- border: 1px solid #eee;
108
- border-radius: 5px;
109
- -webkit-border-radius: 5px;
110
- -moz-border-radius: 5px;
111
- padding: 5px;
112
- margin-left: 20px;
113
- margin-top: 20px;
114
- float: left;
115
- }
116
-
117
- .thirstyRemoveImg {
118
- float: right;
119
- background: transparent url('../images/deleteImg.png') no-repeat left top;
120
- height: 17px;
121
- width: 17px;
122
- margin-top: -14px;
123
- margin-right: -24px;
124
- padding: 5px;
125
- cursor: pointer;
126
- }
127
-
128
- #thirstyaddonscontainer {
129
- margin-top: 20px;
130
- }
131
-
132
- .thirstyaddon {
133
- display: inline-block;
134
- margin: 0 1% 1% 0;
135
- position: relative;
136
- width: 28.5%;
137
- padding: 0 20px 20px 20px;
138
- vertical-align: top;
139
- border: 1px solid #CCC;
140
- border-radius: 5px;
141
- -webkit-border-radius: 5px;
142
- -moz-border-radius: 5px;
143
- background: #ffffff;
144
- }
145
-
146
- .thirstyaddonlinkpage {
147
- margin: 0 1% 1% 0;
148
- position: relative;
149
- width: auto;
150
- padding: 0 10px 10px 10px;
151
- vertical-align: top;
152
- border: 1px solid #CCC;
153
- border-radius: 5px;
154
- -webkit-border-radius: 5px;
155
- -moz-border-radius: 5px;
156
- background: #ffffff;
157
- }
158
-
159
- .thirstyaddon:nth-child(3n) {
160
- margin-right: 0;
161
- }
162
-
163
- .thirstyaddon h3, .thirstyaddonlinkpage h3 {
164
- font-size: 12pt;
165
- margin-top: 0px;
166
- margin-left: -20px;
167
- margin-right: -20px;
168
- background: #EEE;
169
- padding: 1em;
170
- border-bottom: 1px solid #CCC;
171
- border-top-left-radius: 5px;
172
- border-top-right-radius: 5px;
173
- }
174
-
175
- .thirstyaddonlinkpage h3 {
176
- margin-top: 0px !important;
177
- margin-left: -10px !important;
178
- margin-right: -10px !important;
179
- margin-bottom: 10px !important;
180
- }
181
-
182
- .thirstyaddondescription {
183
- margin-bottom: 15px;
184
- }
185
-
186
- #thirstyCustomLinkPrefix {
187
- display: none;
188
- width: 130px;
189
- }
190
-
191
- #thirstySettingsForm {
192
- padding: 2%;
193
- background: #ffffff;
194
- margin-top: 1em;
195
- margin-bottom: 1em;
196
- }
197
-
198
- #thirstySettingsForm .description {
199
- color: #808080;
200
- }
201
-
202
- #thirstySettingsForm td {
203
- vertical-align: top;
204
- }
205
-
206
- #thirstyCustomLinkPrefix, #thirstyOptionsLinkPrefix {
207
- width: 120px;
208
- }
209
-
210
- #thirstyCommunityLinks li {
211
- height: 28px;
212
- }
213
-
214
- .thirstyWhiteBox {
215
- padding: 2%;
216
- background: #ffffff;
217
- margin-bottom: 1em;
218
- }
219
-
220
- @media handheld, only screen and (max-width: 959px) {
221
- .thirstyaddon {
222
- width: 45.5%;
223
- }
224
-
225
- .thirstyaddon:nth-child(3n) {
226
- margin-right: 1%;
227
- }
228
-
229
- .thirstyaddon:nth-child(2n) {
230
- margin-right: 0;
231
- }
232
- }
233
-
234
- @media handheld, only screen and (max-width: 599px) {
235
- .thirstyaddon {
236
- width: 97%;
237
- }
238
-
239
- .thirstyaddon:nth-child(3n) {
240
- margin-right: 1%;
241
- }
242
-
243
- .thirstyaddon:nth-child(2n) {
244
- margin-right: 1%;
245
- }
246
- }
247
-
248
-
249
- /*
250
- Export/Import Settings Styling
251
- */
252
- #export_import_controls_container textarea {
253
- margin-top: 20px;
254
- display: none;
255
- }
256
-
257
- #import_global_settings_action {
258
- display: none;
259
- margin-top: 20px;
260
- }
261
-
262
- /*
263
- */
264
- }
265
- float: none;
266
- padding: 10px 15px;
267
- word-break: break-word;
268
- }
269
- body.post-type-thirstylink #TB_secondLine {
270
- display: block;
271
- margin-top: 10px;
272
- font-size: 12px;
273
- }
274
- body.post-type-thirstylink #TB_window img#TB_Image {
275
- margin: 15px auto 0;
276
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
images/admin-review-notice-logo.png ADDED
Binary file
images/deleteImg.png DELETED
Binary file
images/detailsbg.jpg DELETED
Binary file
images/icon-aff.png DELETED
Binary file
images/icon-images-disabled.png DELETED
Binary file
images/icon-images.png DELETED
Binary file
images/icon-link.png DELETED
Binary file
images/icon-shortcode.png DELETED
Binary file
images/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
images/license DELETED
@@ -1,18 +0,0 @@
1
- icon-images.png, icon-shortcode.png and icon-link.png are all licensed under GPL,
2
- they are free software: you can redistribute it and/or modify
3
- it under the terms of the GNU General Public License as published by
4
- the Free Software Foundation, either version 3 of the License, or
5
- (at your option) any later version.
6
-
7
- These images are distributed in the hope that it will be useful,
8
- but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- GNU General Public License for more details.
11
-
12
- You should have received a copy of the GNU General Public License
13
- along with Foobar. If not, see <http://www.gnu.org/licenses/>.
14
-
15
- Images were obtained from the oxygen icon set and WooCons #1 icon set, both
16
- licensed under GPL, see below links for more info:
17
- http://www.oxygen-icons.org/
18
- http://www.woothemes.com/2010/08/woocons1/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
images/lightgreytransparent.png DELETED
Binary file
images/lightgreytransparentalt.png DELETED
Binary file
images/linkpickerlogo.png DELETED
Binary file
images/media-button.png DELETED
Binary file
images/search-load-more.png DELETED
Binary file
images/spinner-2x.gif ADDED
Binary file
images/spinner.gif ADDED
Binary file
images/thirsty-loader.gif DELETED
Binary file
images/thirstylogo.png DELETED
Binary file
images/white-grad.png DELETED
Binary file
index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
js/ThirstyLinkPicker.js DELETED
@@ -1,168 +0,0 @@
1
- var search_offset = 0;
2
-
3
- function thirstyPerformSearch(searchQueryText) {
4
- var catsQueryIDs = '';
5
-
6
- if (searchQueryText && searchQueryText.length > 0) {
7
- jQuery('#show_more').fadeOut(200);
8
- } else {
9
- jQuery('#show_more').delay(500).fadeIn(400);
10
- search_offset = 0;
11
- }
12
-
13
- jQuery.post(
14
- thirstyAjaxLink,
15
- {
16
- action: 'thirstyLinkPickerSearch',
17
- search_query: searchQueryText
18
- },
19
- replaceSearchResults
20
- );
21
- }
22
-
23
- function showImages() {
24
- jQuery(this).next('.img_choices').slideDown();
25
- jQuery(this).unbind();
26
- jQuery(this).click(hideImages);
27
- jQuery(this).html('Insert Image &laquo;');
28
- }
29
-
30
- function hideImages() {
31
- jQuery(this).next('.img_choices').slideUp();
32
- jQuery(this).unbind();
33
- jQuery(this).click(showImages);
34
- jQuery(this).html('Insert Image &raquo;');
35
- }
36
-
37
- thirstyPerformSearch();
38
-
39
- jQuery('input#search_input').keyup(function() {
40
- thirstyPerformSearch(jQuery(this).val());
41
- });
42
-
43
- jQuery(document).ready(function() {
44
- jQuery('input#search_input').focus();
45
-
46
- jQuery('#show_more').click(function() {
47
- search_offset = search_offset + 10;
48
- jQuery('#show_more_loader').show();
49
- jQuery.post(
50
- thirstyAjaxLink,
51
- {
52
- action: 'thirstyLinkPickerSearch',
53
- search_offset: search_offset
54
- },
55
- appendSearchResults
56
- );
57
- });
58
- });
59
-
60
- function appendSearchResults(html) { jQuery('#show_more_loader').hide(); printSearchResults(html, false); }
61
- function replaceSearchResults(html) { printSearchResults(html, true); }
62
-
63
- function printSearchResults(html, replace) {
64
- if (replace == true)
65
- jQuery('#picker_content').html(html);
66
- else
67
- jQuery('#picker_content').append(html);
68
-
69
- jQuery('.insert_shortcode_link').unbind();
70
- jQuery('.insert_link').unbind();
71
-
72
- jQuery('.insert_link').click(function() {
73
-
74
- var linkID = jQuery(this).attr('linkID');
75
- var copiedText = thirstyGetCopiedText();
76
-
77
- // Check if there are anything selected on the editor
78
- // If none, use the linkname
79
- if((copiedText == "") || (jQuery.trim(copiedText) == "")){
80
-
81
- // Select the image control with appropriate linkid
82
- // Go up to the closest table row
83
- // Go down to that particular row's span with a class of linkname
84
- // Get the text
85
- var linkname = jQuery("img[linkid='"+linkID+"']").closest("tr").find(".linkname").text();
86
- copiedText = linkname;
87
- }
88
-
89
- // Make ajax call to get the link code
90
- jQuery.post(
91
- thirstyAjaxLink,
92
- {
93
- action: 'thirstyGetLinkCode',
94
- linkType: 'link',
95
- linkID: linkID,
96
- copiedText: copiedText
97
- },
98
- function(linkCode) {
99
- parent.thirstyInsertLink(linkCode);
100
- parent.thirstyDismissLinkPicker();
101
- }
102
- );
103
-
104
- });
105
-
106
- jQuery('.insert_shortcode_link').click(function() {
107
- var linkID = jQuery(this).attr('linkID');
108
- var copiedText = thirstyGetCopiedText();
109
-
110
- // Make ajax call to get the link code
111
- jQuery.post(
112
- thirstyAjaxLink,
113
- {
114
- action: 'thirstyGetLinkCode',
115
- linkType: 'shortcode',
116
- linkID: linkID,
117
- copiedText: copiedText
118
- },
119
- function(linkCode) {
120
- parent.thirstyInsertLink(linkCode);
121
- parent.thirstyDismissLinkPicker();
122
- }
123
- );
124
- });
125
-
126
- jQuery('.thirstyImg').click(function() {
127
- var linkID = jQuery(this).attr('linkID');
128
- var imageID = jQuery(this).attr('imageID');
129
- var copiedText = thirstyGetCopiedText();
130
-
131
- // Make ajax call to get the link code
132
- jQuery.post(
133
- thirstyAjaxLink,
134
- {
135
- action: 'thirstyGetLinkCode',
136
- linkType: 'image',
137
- linkID: linkID,
138
- copiedText: copiedText,
139
- imageID: imageID
140
- },
141
- function(linkCode) {
142
- parent.thirstyInsertLink(linkCode);
143
- parent.thirstyDismissLinkPicker();
144
- }
145
- );
146
-
147
- });
148
-
149
- jQuery('.insert_img_link').click(showImages);
150
- }
151
-
152
- function thirstyGetCopiedText() {
153
- var copiedText = '';
154
-
155
- var richEditorActive = false;
156
- if (parent.thirstyMCE != null && !parent.thirstyMCE.isHidden()) {
157
- richEditorActive = true;
158
- }
159
-
160
- if (!richEditorActive) {
161
- var selectedText = parent.thirstyGetHTMLEditorSelection();
162
- copiedText = selectedText.text;
163
- } else {
164
- copiedText = parent.thirstyMCE.selection.getContent();
165
- }
166
-
167
- return copiedText;
168
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/ThirstyQuickAddLinkPicker.js DELETED
@@ -1,263 +0,0 @@
1
- jQuery(document).ready(function($) {
2
-
3
- /*========================================
4
- = Global Variables =
5
- ========================================*/
6
- var quick_add_link_container = $("#quick-add-link-container"),
7
- allClear = true,
8
- errList = {};
9
-
10
-
11
- /*=========================================
12
- = Utility Functions =
13
- =========================================*/
14
-
15
- // Initialize form
16
- function initializeForm(){
17
-
18
- // Clear all error related stuff
19
- quick_add_link_container
20
- .find("input[type='text']")
21
- .removeClass('err')
22
- .siblings('.errmsg')
23
- .css("display","none")
24
- .text('')
25
- .closest("#quick-add-link-container")
26
- .find("#error-bulletin")
27
- .css("display","none")
28
- .text('');
29
-
30
- // Re initialize checkpoint flag
31
- allClear = true;
32
-
33
- // Re initialize error list object
34
- errList = {};
35
- }
36
-
37
- // Validate Link Name
38
- function validateLinkName(linkname) {
39
- if(linkname == ""){
40
- allClear = false;
41
- errList["#qal_link_name"] = "Required Field, Can't be empty";
42
- }
43
- }
44
-
45
- // Validate Destination URL
46
- function validateDestinationURL(linkurl){
47
- if(linkurl == ""){
48
- allClear = false;
49
- errList["#qal_destination_url"] = "Required Field, Can't be empty";
50
- }else{
51
- var urlRegex = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
52
- if(!urlRegex.test(linkurl)){
53
- allClear = false;
54
- errList["#qal_destination_url"] = "Invalid URL Supplied";
55
- }
56
- }
57
- }
58
-
59
- // Prompt Error Message
60
- function promptErrorMessage(){
61
- $.each(errList, function( id, errmsg ) {
62
- quick_add_link_container
63
- .find(id)
64
- .addClass('err')
65
- .siblings('.errmsg')
66
- .css("display","block")
67
- .text(errmsg);
68
- });
69
- }
70
-
71
-
72
- /*=======================================================================
73
- = Add New Affiliate Link and Insert to Post Editor =
74
- =======================================================================*/
75
- $('#quick-add-link').click(function() {
76
-
77
- /*========== Init ==========*/
78
- initializeForm();
79
-
80
- /*========== Data Sanitation ==========*/
81
- // Note: JS Validation should not be relied on
82
- // Just for user convenience purposes
83
- var linkname = $.trim(quick_add_link_container.find("#qal_link_name").val()),
84
- nonce = quick_add_link_container.find("#quick_add_aff_link_nonce").val(),
85
- linkurl = $.trim(quick_add_link_container.find("#qal_destination_url").val()),
86
- nofollow = $.trim(quick_add_link_container.find("#qal_no_follow_link:checked").val()),
87
- newwindow = $.trim(quick_add_link_container.find("#qal_new_window:checked").val()),
88
- linkredirecttype = $.trim(quick_add_link_container.find("input[name='qal_redirect_type']:checked").val()),
89
- linkCategory = $.trim(quick_add_link_container.find("#qal_link_categories").val());
90
-
91
- // Link Name
92
- validateLinkName(linkname);
93
-
94
- // Link URL
95
- validateDestinationURL(linkurl);
96
-
97
- // Checkpoint
98
- if(allClear){
99
-
100
- /*========== Ajax Call ==========*/
101
- // TODO: Refactor this ajax call to another function
102
- $.post(
103
- thirstyAjaxLink,
104
- {
105
- action : 'quickCreateAffiliateLink',
106
- nonce : nonce,
107
- linkname : linkname,
108
- linkurl : linkurl,
109
- nofollow : nofollow,
110
- newwindow : newwindow,
111
- linkredirecttype : linkredirecttype,
112
- linkCategory : linkCategory
113
- },
114
- function(data){
115
-
116
- if(!isNaN(data)){
117
-
118
- // Success
119
- var linkID = data;
120
- var copiedText = thirstyGetCopiedText();
121
-
122
- // Check if there are anything selected on the editor
123
- // If none, use the linkname
124
- if((copiedText == "") || ($.trim(copiedText) == "")){
125
- copiedText = linkname;
126
- }
127
-
128
- // Make ajax call to get the link code
129
- jQuery.post(
130
- thirstyAjaxLink,
131
- {
132
- action: 'thirstyGetLinkCode',
133
- linkType: 'link',
134
- linkID: linkID,
135
- copiedText: copiedText
136
- },
137
- function(linkCode) {
138
- parent.thirstyInsertLink(linkCode);
139
- parent.thirstyDismissLinkPicker();
140
- }
141
- );
142
-
143
- }else{
144
-
145
- // Failure
146
- quick_add_link_container
147
- .find("#error-bulletin")
148
- .text(data)
149
- .css("display","block");
150
-
151
- }
152
-
153
- }
154
- );
155
-
156
- }else{
157
-
158
- // Prompt Message
159
- promptErrorMessage();
160
-
161
- }
162
-
163
- // Prevent evernt bubbling
164
- return false;
165
-
166
- });//$('#quick-add-link').click
167
-
168
-
169
- /*==============================================
170
- = Add New Affiliate Link =
171
- ==============================================*/
172
- $("#add-link").click(function(){
173
-
174
- /*========== Init ==========*/
175
- initializeForm();
176
-
177
- /*========== Data Sanitation ==========*/
178
- // Note: JS Validation should not be relied on
179
- // Just for user convenience purposes
180
- var linkname = $.trim(quick_add_link_container.find("#qal_link_name").val()),
181
- nonce = quick_add_link_container.find("#quick_add_aff_link_nonce").val(),
182
- linkurl = $.trim(quick_add_link_container.find("#qal_destination_url").val()),
183
- nofollow = $.trim(quick_add_link_container.find("#qal_no_follow_link:checked").val()),
184
- newwindow = $.trim(quick_add_link_container.find("#qal_new_window:checked").val()),
185
- linkredirecttype = $.trim(quick_add_link_container.find("input[name='qal_redirect_type']:checked").val()),
186
- linkCategory = $.trim(quick_add_link_container.find("#qal_link_categories").val());
187
-
188
- // Link Name
189
- validateLinkName(linkname);
190
-
191
- // Link URL
192
- validateDestinationURL(linkurl);
193
-
194
- // Checkpoint
195
- if(allClear){
196
-
197
- /*========== Ajax Call ==========*/
198
- // TODO: Refactor this ajax call to another function
199
- $.post(
200
- thirstyAjaxLink,
201
- {
202
- action : 'quickCreateAffiliateLink',
203
- nonce : nonce,
204
- linkname : linkname,
205
- linkurl : linkurl,
206
- nofollow : nofollow,
207
- newwindow : newwindow,
208
- linkredirecttype : linkredirecttype,
209
- linkCategory : linkCategory
210
- },
211
- function(data){
212
-
213
- if(!isNaN(data)){
214
-
215
- // Success
216
- parent.thirstyDismissLinkPicker();
217
-
218
- }else{
219
-
220
- // Failure
221
- quick_add_link_container
222
- .find("#error-bulletin")
223
- .text(data)
224
- .css("display","block");
225
-
226
- }
227
-
228
- }
229
- );
230
-
231
- }else{
232
-
233
- // Prompt Message
234
- promptErrorMessage();
235
-
236
- }
237
-
238
- // Prevent evernt bubbling
239
- return false;
240
-
241
- });//$('#quick-add-link').click
242
-
243
- });//document ready
244
-
245
-
246
-
247
- // TODO: Suggest to move this function from ThirstyLinkPicker.js To thistyPickerHelper.js
248
- function thirstyGetCopiedText() {
249
- var copiedText = '';
250
-
251
- var richEditorActive = false;
252
- if (parent.thirstyMCE != null && !parent.thirstyMCE.isHidden()) {
253
- richEditorActive = true;
254
- }
255
- if (!richEditorActive) {
256
- var selectedText = parent.thirstyGetHTMLEditorSelection();
257
- copiedText = selectedText.text;
258
- } else {
259
- copiedText = parent.thirstyMCE.selection.getContent();
260
- }
261
-
262
- return copiedText;
263
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/app/advance_link_picker/dist/advance-link-picker.css ADDED
@@ -0,0 +1 @@
 
1
+ body{background:#f1f1f1;color:#444;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:14px;line-height:1.4em}#advanced_add_affiliate_link{margin:20px 34px}.search-panel{margin:auto}.search-panel .search-label{font-size:14px}.search-panel .thirstylink-search-field{border-radius:0;font-size:14px;padding:5px;width:400px}.results-panel{border:1px solid #ded9d9;background:#fff;margin-top:10px}.results-panel ul.results-list{margin:0;padding:0;list-style:none}.results-panel ul.results-list li{padding:8px 12px;border-bottom:1px solid #ded9d9}.results-panel ul.results-list li.spinner{text-align:center;padding-top:4px}.results-panel ul.results-list li.spinner i{display:inline-block;width:20px;height:20px;position:relative;top:4px;margin-right:5px}.results-panel ul.results-list li.spinner span{display:inline-block}.results-panel ul.results-list li:after{content:"";display:table;clear:both}.results-panel ul.results-list li:hover{background:#f3f3f3}.results-panel ul.results-list li.no-links-found{text-align:center;display:block}.results-panel ul.results-list li .slug{font-size:13px;color:#aaa}.results-panel ul.results-list li .actions{float:right}.results-panel ul.results-list li .actions .button{background:#fafafa;border:1px solid #ccc;border-radius:3px;font-size:13px;width:26px;cursor:pointer;color:#333;padding:3px 5px;height:auto;margin-left:5px}.results-panel ul.results-list li .actions .button:focus{background:#eee}.results-panel ul.results-list li .images-block{display:none;margin-top:8px;padding-top:5px;border-top:1px dashed #e8e8e8;overflow-y:hidden;transition-property:all;transition-duration:.5s;transition-timing-function:cubic-bezier(0,1,.5,1)}.results-panel ul.results-list li .images-block.show{display:block!important}.results-panel ul.results-list li .images-block:after{content:"";display:table;clear:both}.results-panel ul.results-list li .images-block .label{display:block;float:left;position:relative;top:25px;margin-right:10px}.results-panel ul.results-list li .images-block .images{display:block;float:left}.results-panel ul.results-list li .images-block .images img{margin-right:7px;border:1px solid #ececec;cursor:pointer}.results-panel ul.results-list li .images-block .images img:hover{border-color:#c1c1c1}.results-panel ul.results-list li .images-block .no-images{display:block;text-align:center}.results-panel a.load-more-results{display:block;color:#444;padding:8px;text-align:center;text-decoration:none}.results-panel a.load-more-results:hover{background:#006799;color:#fff}.results-panel a.load-more-results.fetching{cursor:default}.results-panel a.load-more-results.fetching:hover{background:inherit;color:inherit}.results-panel a.load-more-results .spinner{display:none}.results-panel a.load-more-results .spinner i{display:inline-block;width:20px;height:20px;position:relative;top:4px}.results-panel a.load-more-results .button-text,.results-panel a.load-more-results .button-text i{display:inline-block}
js/app/advance_link_picker/dist/advance-link-picker.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t,n){"use strict";(function(e){var n,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!
2
+ * jQuery JavaScript Library v3.2.1
3
+ * https://jquery.com/
4
+ *
5
+ * Includes Sizzle.js
6
+ * https://sizzlejs.com/
7
+ *
8
+ * Copyright JS Foundation and other contributors
9
+ * Released under the MIT license
10
+ * https://jquery.org/license
11
+ *
12
+ * Date: 2017-03-20T18:59Z
13
+ */
14
+ !function(t,n){"object"===i(e)&&"object"===i(e.exports)?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:void 0,function(o,a){function s(e,t){t=t||se;var n=t.createElement("script");n.text=e,t.head.appendChild(n).parentNode.removeChild(n)}function u(e){var t=!!e&&"length"in e&&e.length,n=xe.type(e);return"function"!==n&&!xe.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function l(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function c(e,t,n){return xe.isFunction(t)?xe.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?xe.grep(e,function(e){return e===t!==n}):"string"!=typeof t?xe.grep(e,function(e){return de.call(t,e)>-1!==n}):Ee.test(t)?xe.filter(t,e,n):(t=xe.filter(t,e),xe.grep(e,function(e){return de.call(t,e)>-1!==n&&1===e.nodeType}))}function f(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function d(e){var t={};return xe.each(e.match(Le)||[],function(e,n){t[n]=!0}),t}function p(e){return e}function h(e){throw e}function g(e,t,n,r){var i;try{e&&xe.isFunction(i=e.promise)?i.call(e).done(t).fail(n):e&&xe.isFunction(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}function v(){se.removeEventListener("DOMContentLoaded",v),o.removeEventListener("load",v),xe.ready()}function m(){this.expando=xe.expando+m.uid++}function y(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Me.test(e)?JSON.parse(e):e)}function x(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(Re,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=y(n)}catch(e){}Fe.set(e,t,n)}else n=void 0;return n}function b(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return xe.css(e,t,"")},u=s(),l=n&&n[3]||(xe.cssNumber[t]?"":"px"),c=(xe.cssNumber[t]||"px"!==l&&+u)&&We.exec(xe.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do{o=o||".5",c/=o,xe.style(e,t,c+l)}while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function w(e){var t,n=e.ownerDocument,r=e.nodeName,i=Xe[r];return i||(t=n.body.appendChild(n.createElement(r)),i=xe.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),Xe[r]=i,i)}function T(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)r=e[o],r.style&&(n=r.style.display,t?("none"===n&&(i[o]=_e.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&Be(r)&&(i[o]=w(r))):"none"!==n&&(i[o]="none",_e.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}function k(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&l(e,t)?xe.merge([e],n):n}function C(e,t){for(var n=0,r=e.length;n<r;n++)_e.set(e[n],"globalEval",!t||_e.get(t[n],"globalEval"))}function S(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),d=[],p=0,h=e.length;p<h;p++)if((o=e[p])||0===o)if("object"===xe.type(o))xe.merge(d,o.nodeType?[o]:o);else if(Qe.test(o)){for(a=a||f.appendChild(t.createElement("div")),s=(Ve.exec(o)||["",""])[1].toLowerCase(),u=Ye[s]||Ye._default,a.innerHTML=u[1]+xe.htmlPrefilter(o)+u[2],c=u[0];c--;)a=a.lastChild;xe.merge(d,a.childNodes),a=f.firstChild,a.textContent=""}else d.push(t.createTextNode(o));for(f.textContent="",p=0;o=d[p++];)if(r&&xe.inArray(o,r)>-1)i&&i.push(o);else if(l=xe.contains(o.ownerDocument,o),a=k(f.appendChild(o),"script"),l&&C(a),n)for(c=0;o=a[c++];)Ge.test(o.type||"")&&n.push(o);return f}function E(){return!0}function j(){return!1}function N(){try{return se.activeElement}catch(e){}}function D(e,t,n,r,o,a){var s,u;if("object"===(void 0===t?"undefined":i(t))){"string"!=typeof n&&(r=r||n,n=void 0);for(u in t)D(e,u,n,r,t[u],a);return e}if(null==r&&null==o?(o=n,r=n=void 0):null==o&&("string"==typeof n?(o=r,r=void 0):(o=r,r=n,n=void 0)),!1===o)o=j;else if(!o)return e;return 1===a&&(s=o,o=function(e){return xe().off(e),s.apply(this,arguments)},o.guid=s.guid||(s.guid=xe.guid++)),e.each(function(){xe.event.add(this,t,o,r,n)})}function A(e,t){return l(e,"table")&&l(11!==t.nodeType?t:t.firstChild,"tr")?xe(">tbody",e)[0]||e:e}function L(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function q(e){var t=rt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function P(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(_e.hasData(e)&&(o=_e.access(e),a=_e.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)xe.event.add(t,i,l[i][n])}Fe.hasData(e)&&(s=Fe.access(e),u=xe.extend({},s),Fe.set(t,u))}}function H(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Ue.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function O(e,t,n,r){t=ce.apply([],t);var i,o,a,u,l,c,f=0,d=e.length,p=d-1,h=t[0],g=xe.isFunction(h);if(g||d>1&&"string"==typeof h&&!ye.checkClone&&nt.test(h))return e.each(function(i){var o=e.eq(i);g&&(t[0]=h.call(this,i,o.html())),O(o,t,n,r)});if(d&&(i=S(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(a=xe.map(k(i,"script"),L),u=a.length;f<d;f++)l=i,f!==p&&(l=xe.clone(l,!0,!0),u&&xe.merge(a,k(l,"script"))),n.call(e[f],l,f);if(u)for(c=a[a.length-1].ownerDocument,xe.map(a,q),f=0;f<u;f++)l=a[f],Ge.test(l.type||"")&&!_e.access(l,"globalEval")&&xe.contains(c,l)&&(l.src?xe._evalUrl&&xe._evalUrl(l.src):s(l.textContent.replace(it,""),c))}return e}function _(e,t,n){for(var r,i=t?xe.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||xe.cleanData(k(r)),r.parentNode&&(n&&xe.contains(r.ownerDocument,r)&&C(k(r,"script")),r.parentNode.removeChild(r));return e}function F(e,t,n){var r,i,o,a,s=e.style;return n=n||st(e),n&&(a=n.getPropertyValue(t)||n[t],""!==a||xe.contains(e.ownerDocument,e)||(a=xe.style(e,t)),!ye.pixelMarginRight()&&at.test(a)&&ot.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function M(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function R(e){if(e in pt)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=dt.length;n--;)if((e=dt[n]+t)in pt)return e}function I(e){var t=xe.cssProps[e];return t||(t=xe.cssProps[e]=R(e)||e),t}function W(e,t,n){var r=We.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function $(e,t,n,r,i){var o,a=0;for(o=n===(r?"border":"content")?4:"width"===t?1:0;o<4;o+=2)"margin"===n&&(a+=xe.css(e,n+$e[o],!0,i)),r?("content"===n&&(a-=xe.css(e,"padding"+$e[o],!0,i)),"margin"!==n&&(a-=xe.css(e,"border"+$e[o]+"Width",!0,i))):(a+=xe.css(e,"padding"+$e[o],!0,i),"padding"!==n&&(a+=xe.css(e,"border"+$e[o]+"Width",!0,i)));return a}function B(e,t,n){var r,i=st(e),o=F(e,t,i),a="border-box"===xe.css(e,"boxSizing",!1,i);return at.test(o)?o:(r=a&&(ye.boxSizingReliable()||o===e.style[t]),"auto"===o&&(o=e["offset"+t[0].toUpperCase()+t.slice(1)]),(o=parseFloat(o)||0)+$(e,t,n||(a?"border":"content"),r,i)+"px")}function z(e,t,n,r,i){return new z.prototype.init(e,t,n,r,i)}function X(){gt&&(!1===se.hidden&&o.requestAnimationFrame?o.requestAnimationFrame(X):o.setTimeout(X,xe.fx.interval),xe.fx.tick())}function U(){return o.setTimeout(function(){ht=void 0}),ht=xe.now()}function V(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)n=$e[r],i["margin"+n]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function G(e,t,n){for(var r,i=(J.tweeners[t]||[]).concat(J.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function Y(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,d=this,p={},h=e.style,g=e.nodeType&&Be(e),v=_e.get(e,"fxshow");n.queue||(a=xe._queueHooks(e,"fx"),null==a.unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,d.always(function(){d.always(function(){a.unqueued--,xe.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],vt.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}p[r]=v&&v[r]||xe.style(e,r)}if((u=!xe.isEmptyObject(t))||!xe.isEmptyObject(p)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],l=v&&v.display,null==l&&(l=_e.get(e,"display")),c=xe.css(e,"display"),"none"===c&&(l?c=l:(T([e],!0),l=e.style.display||l,c=xe.css(e,"display"),T([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===xe.css(e,"float")&&(u||(d.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",d.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in p)u||(v?"hidden"in v&&(g=v.hidden):v=_e.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&T([e],!0),d.done(function(){g||T([e]),_e.remove(e,"fxshow");for(r in p)xe.style(e,r,p[r])})),u=G(g?v[r]:0,r,d),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}}function Q(e,t){var n,r,i,o,a;for(n in e)if(r=xe.camelCase(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=xe.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function J(e,t,n){var r,i,o=0,a=J.prefilters.length,s=xe.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=ht||U(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;a<u;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),o<1&&u?n:(u||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:xe.extend({},t),opts:xe.extend(!0,{specialEasing:{},easing:xe.easing._default},n),originalProperties:t,originalOptions:n,startTime:ht||U(),duration:n.duration,tweens:[],createTween:function(t,n){var r=xe.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(Q(c,l.opts.specialEasing);o<a;o++)if(r=J.prefilters[o].call(l,e,c,l.opts))return xe.isFunction(r.stop)&&(xe._queueHooks(l.elem,l.opts.queue).stop=xe.proxy(r.stop,r)),r;return xe.map(c,G,l),xe.isFunction(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),xe.fx.timer(xe.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}function K(e){return(e.match(Le)||[]).join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ee(e,t,n,r){var o;if(Array.isArray(t))xe.each(t,function(t,o){n||Et.test(e)?r(e,o):ee(e+"["+("object"===(void 0===o?"undefined":i(o))&&null!=o?t:"")+"]",o,n,r)});else if(n||"object"!==xe.type(t))r(e,t);else for(o in t)ee(e+"["+o+"]",t[o],n,r)}function te(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(Le)||[];if(xe.isFunction(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ne(e,t,n,r){function i(s){var u;return o[s]=!0,xe.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||a||o[l]?a?!(u=l):void 0:(t.dataTypes.unshift(l),i(l),!1)}),u}var o={},a=e===Pt;return i(t.dataTypes[0])||!o["*"]&&i("*")}function re(e,t){var n,r,i=xe.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&xe.extend(!0,e,r),e}function ie(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;"*"===u[0];)u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function oe(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if(s=i.split(" "),s[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}var ae=[],se=o.document,ue=Object.getPrototypeOf,le=ae.slice,ce=ae.concat,fe=ae.push,de=ae.indexOf,pe={},he=pe.toString,ge=pe.hasOwnProperty,ve=ge.toString,me=ve.call(Object),ye={},xe=function e(t,n){return new e.fn.init(t,n)},be=function(e,t){return t.toUpperCase()};xe.fn=xe.prototype={jquery:"3.2.1",constructor:xe,length:0,toArray:function(){return le.call(this)},get:function(e){return null==e?le.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=xe.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return xe.each(this,e)},map:function(e){return this.pushStack(xe.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(le.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:fe,sort:ae.sort,splice:ae.splice},xe.extend=xe.fn.extend=function(){var e,t,n,r,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[u]||{},u++),"object"===(void 0===s?"undefined":i(s))||xe.isFunction(s)||(s={}),u===l&&(s=this,u--);u<l;u++)if(null!=(e=arguments[u]))for(t in e)n=s[t],r=e[t],s!==r&&(c&&r&&(xe.isPlainObject(r)||(o=Array.isArray(r)))?(o?(o=!1,a=n&&Array.isArray(n)?n:[]):a=n&&xe.isPlainObject(n)?n:{},s[t]=xe.extend(c,a,r)):void 0!==r&&(s[t]=r));return s},xe.extend({expando:"jQuery"+("3.2.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return"function"===xe.type(e)},isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){var t=xe.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==he.call(e))&&(!(t=ue(e))||"function"==typeof(n=ge.call(t,"constructor")&&t.constructor)&&ve.call(n)===me)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},type:function(e){return null==e?e+"":"object"===(void 0===e?"undefined":i(e))||"function"==typeof e?pe[he.call(e)]||"object":void 0===e?"undefined":i(e)},globalEval:function(e){s(e)},camelCase:function(e){return e.replace(/^-ms-/,"ms-").replace(/-([a-z])/g,be)},each:function(e,t){var n,r=0;if(u(e))for(n=e.length;r<n&&!1!==t.call(e[r],r,e[r]);r++);else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(u(Object(e))?xe.merge(n,"string"==typeof e?[e]:e):fe.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:de.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(u(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return ce.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),xe.isFunction(e))return r=le.call(arguments,2),i=function(){return e.apply(t||this,r.concat(le.call(arguments)))},i.guid=e.guid=e.guid||xe.guid++,i},now:Date.now,support:ye}),"function"==typeof Symbol&&(xe.fn[Symbol.iterator]=ae[Symbol.iterator]),xe.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){pe["[object "+t+"]"]=t.toLowerCase()});var we=/*!
15
+ * Sizzle CSS Selector Engine v2.3.3
16
+ * https://sizzlejs.com/
17
+ *
18
+ * Copyright jQuery Foundation and other contributors
19
+ * Released under the MIT license
20
+ * http://jquery.org/license
21
+ *
22
+ * Date: 2016-08-08
23
+ */
24
+ function(e){function t(e,t,n,r){var i,o,a,s,u,c,d,p=t&&t.ownerDocument,h=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==h&&9!==h&&11!==h)return n;if(!r&&((t?t.ownerDocument||t:R)!==L&&A(t),t=t||L,P)){if(11!==h&&(u=ge.exec(e)))if(i=u[1]){if(9===h){if(!(a=t.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(p&&(a=p.getElementById(i))&&F(t,a)&&a.id===i)return n.push(a),n}else{if(u[2])return Q.apply(n,t.getElementsByTagName(e)),n;if((i=u[3])&&b.getElementsByClassName&&t.getElementsByClassName)return Q.apply(n,t.getElementsByClassName(i)),n}if(b.qsa&&!z[e+" "]&&(!H||!H.test(e))){if(1!==h)p=t,d=e;else if("object"!==t.nodeName.toLowerCase()){for((s=t.getAttribute("id"))?s=s.replace(xe,be):t.setAttribute("id",s=M),c=C(e),o=c.length;o--;)c[o]="#"+s+" "+f(c[o]);d=c.join(","),p=ve.test(e)&&l(t.parentNode)||t}if(d)try{return Q.apply(n,p.querySelectorAll(d)),n}catch(e){}finally{s===M&&t.removeAttribute("id")}}}return E(e.replace(oe,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[M]=!0,e}function i(e){var t=L.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&Te(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function u(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function l(e){return e&&void 0!==e.getElementsByTagName&&e}function c(){}function f(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function d(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=W++;return t.first?function(t,n,i){for(;t=t[r];)if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,d=[I,s];if(u){for(;t=t[r];)if((1===t.nodeType||a)&&e(t,n,u))return!0}else for(;t=t[r];)if(1===t.nodeType||a)if(f=t[M]||(t[M]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===I&&l[1]===s)return d[2]=l[2];if(c[o]=d,d[2]=e(t,n,u))return!0}return!1}}function p(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function h(e,n,r){for(var i=0,o=n.length;i<o;i++)t(e,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function v(e,t,n,i,o,a){return i&&!i[M]&&(i=v(i)),o&&!o[M]&&(o=v(o,a)),r(function(r,a,s,u){var l,c,f,d=[],p=[],v=a.length,m=r||h(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?m:g(m,d,e,s,u),x=n?o||(r?e:v||i)?[]:a:y;if(n&&n(y,x,s,u),i)for(l=g(x,p),i(l,[],s,u),c=l.length;c--;)(f=l[c])&&(x[p[c]]=!(y[p[c]]=f));if(r){if(o||e){if(o){for(l=[],c=x.length;c--;)(f=x[c])&&l.push(y[c]=f);o(null,x=[],l,u)}for(c=x.length;c--;)(f=x[c])&&(l=o?K(r,f):d[c])>-1&&(r[l]=!(a[l]=f))}}else x=g(x===a?x.splice(v,x.length):x),o?o(null,a,x,u):Q.apply(a,x)})}function m(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,u=d(function(e){return e===t},a,!0),l=d(function(e){return K(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==j)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s<i;s++)if(n=w.relative[e[s].type])c=[d(p(c),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[M]){for(r=++s;r<i&&!w.relative[e[r].type];r++);return v(s>1&&p(c),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(oe,"$1"),n,s<r&&m(e.slice(s,r)),r<i&&m(e=e.slice(r)),r<i&&f(e))}c.push(n)}return p(c)}function y(e,n){var i=n.length>0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",v=r&&[],m=[],y=j,x=r||o&&w.find.TAG("*",l),b=I+=null==y?1:Math.random()||.1,T=x.length;for(l&&(j=a===L||a||l);h!==T&&null!=(c=x[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===L||(A(c),s=!P);d=e[f++];)if(d(c,a||L,s)){u.push(c);break}l&&(I=b)}i&&((c=!d&&c)&&p--,r&&v.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(v,m,a,s);if(r){if(p>0)for(;h--;)v[h]||m[h]||(m[h]=G.call(u));m=g(m)}Q.apply(u,m),l&&!r&&m.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(I=b,j=y),v};return i?r(a):a}var x,b,w,T,k,C,S,E,j,N,D,A,L,q,P,H,O,_,F,M="sizzle"+1*new Date,R=e.document,I=0,W=0,$=n(),B=n(),z=n(),X=function(e,t){return e===t&&(D=!0),0},U={}.hasOwnProperty,V=[],G=V.pop,Y=V.push,Q=V.push,J=V.slice,K=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},Z="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ee="[\\x20\\t\\r\\n\\f]",te="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",ne="\\["+ee+"*("+te+")(?:"+ee+"*([*^$|!~]?=)"+ee+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+te+"))|)"+ee+"*\\]",re=":("+te+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ne+")*)|.*)\\)|)",ie=new RegExp(ee+"+","g"),oe=new RegExp("^"+ee+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ee+"+$","g"),ae=new RegExp("^"+ee+"*,"+ee+"*"),se=new RegExp("^"+ee+"*([>+~]|"+ee+")"+ee+"*"),ue=new RegExp("="+ee+"*([^\\]'\"]*?)"+ee+"*\\]","g"),le=new RegExp(re),ce=new RegExp("^"+te+"$"),fe={ID:new RegExp("^#("+te+")"),CLASS:new RegExp("^\\.("+te+")"),TAG:new RegExp("^("+te+"|[*])"),ATTR:new RegExp("^"+ne),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ee+"*(even|odd|(([+-]|)(\\d*)n|)"+ee+"*(?:([+-]|)"+ee+"*(\\d+)|))"+ee+"*\\)|)","i"),bool:new RegExp("^(?:"+Z+")$","i"),needsContext:new RegExp("^"+ee+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ee+"*((?:-\\d)?\\d*)"+ee+"*\\)|)(?=[^-]|$)","i")},de=/^(?:input|select|textarea|button)$/i,pe=/^h\d$/i,he=/^[^{]+\{\s*\[native \w/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ve=/[+~]/,me=new RegExp("\\\\([\\da-f]{1,6}"+ee+"?|("+ee+")|.)","ig"),ye=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},xe=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,be=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},we=function(){A()},Te=d(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{Q.apply(V=J.call(R.childNodes),R.childNodes),V[R.childNodes.length].nodeType}catch(e){Q={apply:V.length?function(e,t){Y.apply(e,J.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}b=t.support={},k=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},A=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:R;return r!==L&&9===r.nodeType&&r.documentElement?(L=r,q=L.documentElement,P=!k(L),R!==L&&(n=L.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",we,!1):n.attachEvent&&n.attachEvent("onunload",we)),b.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),b.getElementsByTagName=i(function(e){return e.appendChild(L.createComment("")),!e.getElementsByTagName("*").length}),b.getElementsByClassName=he.test(L.getElementsByClassName),b.getById=i(function(e){return q.appendChild(e).id=M,!L.getElementsByName||!L.getElementsByName(M).length}),b.getById?(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){return e.getAttribute("id")===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&P){var n=t.getElementById(e);return n?[n]:[]}}):(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&P){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),w.find.TAG=b.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):b.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=b.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&P)return t.getElementsByClassName(e)},O=[],H=[],(b.qsa=he.test(L.querySelectorAll))&&(i(function(e){q.appendChild(e).innerHTML="<a id='"+M+"'></a><select id='"+M+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&H.push("[*^$]="+ee+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||H.push("\\["+ee+"*(?:value|"+Z+")"),e.querySelectorAll("[id~="+M+"-]").length||H.push("~="),e.querySelectorAll(":checked").length||H.push(":checked"),e.querySelectorAll("a#"+M+"+*").length||H.push(".#.+[+~]")}),i(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=L.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&H.push("name"+ee+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&H.push(":enabled",":disabled"),q.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&H.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),H.push(",.*:")})),(b.matchesSelector=he.test(_=q.matches||q.webkitMatchesSelector||q.mozMatchesSelector||q.oMatchesSelector||q.msMatchesSelector))&&i(function(e){b.disconnectedMatch=_.call(e,"*"),_.call(e,"[s!='']:x"),O.push("!=",re)}),H=H.length&&new RegExp(H.join("|")),O=O.length&&new RegExp(O.join("|")),t=he.test(q.compareDocumentPosition),F=t||he.test(q.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},X=t?function(e,t){if(e===t)return D=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!b.sortDetached&&t.compareDocumentPosition(e)===n?e===L||e.ownerDocument===R&&F(R,e)?-1:t===L||t.ownerDocument===R&&F(R,t)?1:N?K(N,e)-K(N,t):0:4&n?-1:1)}:function(e,t){if(e===t)return D=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===L?-1:t===L?1:i?-1:o?1:N?K(N,e)-K(N,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===R?-1:u[r]===R?1:0},L):L},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==L&&A(e),n=n.replace(ue,"='$1']"),b.matchesSelector&&P&&!z[n+" "]&&(!O||!O.test(n))&&(!H||!H.test(n)))try{var r=_.call(e,n);if(r||b.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return t(n,L,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==L&&A(e),F(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==L&&A(e);var n=w.attrHandle[t.toLowerCase()],r=n&&U.call(w.attrHandle,t.toLowerCase())?n(e,t,!P):void 0;return void 0!==r?r:b.attributes||!P?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.escape=function(e){return(e+"").replace(xe,be)},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(D=!b.detectDuplicates,N=!b.sortStable&&e.slice(0),e.sort(X),D){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return N=null,e},T=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=T(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=T(t);return n},w=t.selectors={cacheLength:50,createPseudo:r,match:fe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(me,ye),e[3]=(e[3]||e[4]||e[5]||"").replace(me,ye),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return fe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&le.test(n)&&(t=C(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(me,ye).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ee+")"+e+"("+ee+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ie," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,g=o!==a?"nextSibling":"previousSibling",v=t.parentNode,m=s&&t.nodeName.toLowerCase(),y=!u&&!s,x=!1;if(v){if(o){for(;g;){for(d=t;d=d[g];)if(s?d.nodeName.toLowerCase()===m:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?v.firstChild:v.lastChild],a&&y){for(d=v,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],x=p&&l[2],d=p&&v.childNodes[p];d=++p&&d&&d[g]||(x=p=0)||h.pop();)if(1===d.nodeType&&++x&&d===t){c[e]=[I,p,x];break}}else if(y&&(d=t,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],x=p),!1===x)for(;(d=++p&&d&&d[g]||(x=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==m:1!==d.nodeType)||!++x||(y&&(f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[I,x]),d!==t)););return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,n){var i,o=w.pseudos[e]||w.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[M]?o(n):o.length>1?(i=[e,e,"",n],w.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=K(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=S(e.replace(oe,"$1"));return i[M]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(me,ye),function(t){return(t.textContent||t.innerText||T(t)).indexOf(e)>-1}}),lang:r(function(e){return ce.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(me,ye).toLowerCase(),function(t){var n;do{if(n=P?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===q},focus:function(e){return e===L.activeElement&&(!L.hasFocus||L.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:s(!1),disabled:s(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return pe.test(e.nodeName)},input:function(e){return de.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:u(function(){return[0]}),last:u(function(e,t){return[t-1]}),eq:u(function(e,t,n){return[n<0?n+t:n]}),even:u(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:u(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:u(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:u(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},w.pseudos.nth=w.pseudos.eq;for(x in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})w.pseudos[x]=function(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}(x);for(x in{submit:!0,reset:!0})w.pseudos[x]=function(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}(x);return c.prototype=w.filters=w.pseudos,w.setFilters=new c,C=t.tokenize=function(e,n){var r,i,o,a,s,u,l,c=B[e+" "];if(c)return n?0:c.slice(0);for(s=e,u=[],l=w.preFilter;s;){r&&!(i=ae.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),r=!1,(i=se.exec(s))&&(r=i.shift(),o.push({value:r,type:i[0].replace(oe," ")}),s=s.slice(r.length));for(a in w.filter)!(i=fe[a].exec(s))||l[a]&&!(i=l[a](i))||(r=i.shift(),o.push({value:r,type:a,matches:i}),s=s.slice(r.length));if(!r)break}return n?s.length:s?t.error(e):B(e,u).slice(0)},S=t.compile=function(e,t){var n,r=[],i=[],o=z[e+" "];if(!o){for(t||(t=C(e)),n=t.length;n--;)o=m(t[n]),o[M]?r.push(o):i.push(o);o=z(e,y(i,r)),o.selector=e}return o},E=t.select=function(e,t,n,r){var i,o,a,s,u,c="function"==typeof e&&e,d=!r&&C(e=c.selector||e);if(n=n||[],1===d.length){if(o=d[0]=d[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&9===t.nodeType&&P&&w.relative[o[1].type]){if(!(t=(w.find.ID(a.matches[0].replace(me,ye),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=fe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((u=w.find[s])&&(r=u(a.matches[0].replace(me,ye),ve.test(o[0].type)&&l(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&f(o)))return Q.apply(n,r),n;break}}return(c||S(e,d))(r,t,!P,n,!t||ve.test(e)&&l(t.parentNode)||t),n},b.sortStable=M.split("").sort(X).join("")===M,b.detectDuplicates=!!D,A(),b.sortDetached=i(function(e){return 1&e.compareDocumentPosition(L.createElement("fieldset"))}),i(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),b.attributes&&i(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(Z,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(o);xe.find=we,xe.expr=we.selectors,xe.expr[":"]=xe.expr.pseudos,xe.uniqueSort=xe.unique=we.uniqueSort,xe.text=we.getText,xe.isXMLDoc=we.isXML,xe.contains=we.contains,xe.escapeSelector=we.escape;var Te=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&xe(e).is(n))break;r.push(e)}return r},ke=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},Ce=xe.expr.match.needsContext,Se=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,Ee=/^.[^:#\[\.,]*$/;xe.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?xe.find.matchesSelector(r,e)?[r]:[]:xe.find.matches(e,xe.grep(t,function(e){return 1===e.nodeType}))},xe.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(xe(e).filter(function(){for(t=0;t<r;t++)if(xe.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)xe.find(e,i[t],n);return r>1?xe.uniqueSort(n):n},filter:function(e){return this.pushStack(c(this,e||[],!1))},not:function(e){return this.pushStack(c(this,e||[],!0))},is:function(e){return!!c(this,"string"==typeof e&&Ce.test(e)?xe(e):e||[],!1).length}});var je,Ne=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(xe.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||je,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Ne.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof xe?t[0]:t,xe.merge(this,xe.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:se,!0)),Se.test(r[1])&&xe.isPlainObject(t))for(r in t)xe.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=se.getElementById(r[2]),i&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):xe.isFunction(e)?void 0!==n.ready?n.ready(e):e(xe):xe.makeArray(e,this)}).prototype=xe.fn,je=xe(se);var De=/^(?:parents|prev(?:Until|All))/,Ae={children:!0,contents:!0,next:!0,prev:!0};xe.fn.extend({has:function(e){var t=xe(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(xe.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&xe(e);if(!Ce.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&xe.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?xe.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?de.call(xe(e),this[0]):de.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(xe.uniqueSort(xe.merge(this.get(),xe(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),xe.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return Te(e,"parentNode")},parentsUntil:function(e,t,n){return Te(e,"parentNode",n)},next:function(e){return f(e,"nextSibling")},prev:function(e){return f(e,"previousSibling")},nextAll:function(e){return Te(e,"nextSibling")},prevAll:function(e){return Te(e,"previousSibling")},nextUntil:function(e,t,n){return Te(e,"nextSibling",n)},prevUntil:function(e,t,n){return Te(e,"previousSibling",n)},siblings:function(e){return ke((e.parentNode||{}).firstChild,e)},children:function(e){return ke(e.firstChild)},contents:function(e){return l(e,"iframe")?e.contentDocument:(l(e,"template")&&(e=e.content||e),xe.merge([],e.childNodes))}},function(e,t){xe.fn[e]=function(n,r){var i=xe.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=xe.filter(r,i)),this.length>1&&(Ae[e]||xe.uniqueSort(i),De.test(e)&&i.reverse()),this.pushStack(i)}});var Le=/[^\x20\t\r\n\f]+/g;xe.Callbacks=function(e){e="string"==typeof e?d(e):xe.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1)for(n=a.shift();++s<o.length;)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1);e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){xe.each(n,function(n,r){xe.isFunction(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==xe.type(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return xe.each(arguments,function(e,t){for(var n;(n=xe.inArray(t,o,n))>-1;)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?xe.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},xe.extend({Deferred:function(e){var t=[["notify","progress",xe.Callbacks("memory"),xe.Callbacks("memory"),2],["resolve","done",xe.Callbacks("once memory"),xe.Callbacks("once memory"),0,"resolved"],["reject","fail",xe.Callbacks("once memory"),xe.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return xe.Deferred(function(n){xe.each(t,function(t,r){var i=xe.isFunction(e[r[4]])&&e[r[4]];a[r[1]](function(){var e=i&&i.apply(this,arguments);e&&xe.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(e,n,r){function a(e,t,n,r){return function(){var u=this,l=arguments,c=function(){var o,c;if(!(e<s)){if((o=n.apply(u,l))===t.promise())throw new TypeError("Thenable self-resolution");c=o&&("object"===(void 0===o?"undefined":i(o))||"function"==typeof o)&&o.then,xe.isFunction(c)?r?c.call(o,a(s,t,p,r),a(s,t,h,r)):(s++,c.call(o,a(s,t,p,r),a(s,t,h,r),a(s,t,p,t.notifyWith))):(n!==p&&(u=void 0,l=[o]),(r||t.resolveWith)(u,l))}},f=r?c:function(){try{c()}catch(r){xe.Deferred.exceptionHook&&xe.Deferred.exceptionHook(r,f.stackTrace),e+1>=s&&(n!==h&&(u=void 0,l=[r]),t.rejectWith(u,l))}};e?f():(xe.Deferred.getStackHook&&(f.stackTrace=xe.Deferred.getStackHook()),o.setTimeout(f))}}var s=0;return xe.Deferred(function(i){t[0][3].add(a(0,i,xe.isFunction(r)?r:p,i.notifyWith)),t[1][3].add(a(0,i,xe.isFunction(e)?e:p)),t[2][3].add(a(0,i,xe.isFunction(n)?n:h))}).promise()},promise:function(e){return null!=e?xe.extend(e,r):r}},a={};return xe.each(t,function(e,i){var o=i[2],s=i[5];r[i[1]]=o.add,s&&o.add(function(){n=s},t[3-e][2].disable,t[0][2].lock),o.add(i[3].fire),a[i[0]]=function(){return a[i[0]+"With"](this===a?void 0:this,arguments),this},a[i[0]+"With"]=o.fireWith}),r.promise(a),e&&e.call(a,a),a},when:function(e){var t=arguments.length,n=t,r=Array(n),i=le.call(arguments),o=xe.Deferred(),a=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?le.call(arguments):n,--t||o.resolveWith(r,i)}};if(t<=1&&(g(e,o.done(a(n)).resolve,o.reject,!t),"pending"===o.state()||xe.isFunction(i[n]&&i[n].then)))return o.then();for(;n--;)g(i[n],a(n),o.reject);return o.promise()}});var qe=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;xe.Deferred.exceptionHook=function(e,t){o.console&&o.console.warn&&e&&qe.test(e.name)&&o.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},xe.readyException=function(e){o.setTimeout(function(){throw e})};var Pe=xe.Deferred();xe.fn.ready=function(e){return Pe.then(e).catch(function(e){xe.readyException(e)}),this},xe.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--xe.readyWait:xe.isReady)||(xe.isReady=!0,!0!==e&&--xe.readyWait>0||Pe.resolveWith(se,[xe]))}}),xe.ready.then=Pe.then,"complete"===se.readyState||"loading"!==se.readyState&&!se.documentElement.doScroll?o.setTimeout(xe.ready):(se.addEventListener("DOMContentLoaded",v),o.addEventListener("load",v));var He=function e(t,n,r,i,o,a,s){var u=0,l=t.length,c=null==r;if("object"===xe.type(r)){o=!0;for(u in r)e(t,n,u,r[u],!0,a,s)}else if(void 0!==i&&(o=!0,xe.isFunction(i)||(s=!0),c&&(s?(n.call(t,i),n=null):(c=n,n=function(e,t,n){return c.call(xe(e),n)})),n))for(;u<l;u++)n(t[u],r,s?i:i.call(t[u],u,n(t[u],r)));return o?t:c?n.call(t):l?n(t[0],r):a},Oe=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};m.uid=1,m.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Oe(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[xe.camelCase(t)]=n;else for(r in t)i[xe.camelCase(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][xe.camelCase(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){Array.isArray(t)?t=t.map(xe.camelCase):(t=xe.camelCase(t),t=t in r?[t]:t.match(Le)||[]),n=t.length;for(;n--;)delete r[t[n]]}(void 0===t||xe.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!xe.isEmptyObject(t)}};var _e=new m,Fe=new m,Me=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Re=/[A-Z]/g;xe.extend({hasData:function(e){return Fe.hasData(e)||_e.hasData(e)},data:function(e,t,n){return Fe.access(e,t,n)},removeData:function(e,t){Fe.remove(e,t)},_data:function(e,t,n){return _e.access(e,t,n)},_removeData:function(e,t){_e.remove(e,t)}}),xe.fn.extend({data:function(e,t){var n,r,o,a=this[0],s=a&&a.attributes;if(void 0===e){if(this.length&&(o=Fe.get(a),1===a.nodeType&&!_e.get(a,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&(r=s[n].name,0===r.indexOf("data-")&&(r=xe.camelCase(r.slice(5)),x(a,r,o[r])));_e.set(a,"hasDataAttrs",!0)}return o}return"object"===(void 0===e?"undefined":i(e))?this.each(function(){Fe.set(this,e)}):He(this,function(t){var n;if(a&&void 0===t){if(void 0!==(n=Fe.get(a,e)))return n;if(void 0!==(n=x(a,e)))return n}else this.each(function(){Fe.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Fe.remove(this,e)})}}),xe.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=_e.get(e,t),n&&(!r||Array.isArray(n)?r=_e.access(e,t,xe.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=xe.queue(e,t),r=n.length,i=n.shift(),o=xe._queueHooks(e,t),a=function(){xe.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return _e.get(e,n)||_e.access(e,n,{empty:xe.Callbacks("once memory").add(function(){_e.remove(e,[t+"queue",n])})})}}),xe.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?xe.queue(this[0],e):void 0===t?this:this.each(function(){var n=xe.queue(this,e,t);xe._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&xe.dequeue(this,e)})},dequeue:function(e){return this.each(function(){xe.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=xe.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";a--;)(n=_e.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var Ie=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,We=new RegExp("^(?:([+-])=|)("+Ie+")([a-z%]*)$","i"),$e=["Top","Right","Bottom","Left"],Be=function(e,t){return e=t||e,"none"===e.style.display||""===e.style.display&&xe.contains(e.ownerDocument,e)&&"none"===xe.css(e,"display")},ze=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i},Xe={};xe.fn.extend({show:function(){return T(this,!0)},hide:function(){return T(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Be(this)?xe(this).show():xe(this).hide()})}});var Ue=/^(?:checkbox|radio)$/i,Ve=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,Ge=/^$|\/(?:java|ecma)script/i,Ye={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ye.optgroup=Ye.option,Ye.tbody=Ye.tfoot=Ye.colgroup=Ye.caption=Ye.thead,Ye.th=Ye.td;var Qe=/<|&#?\w+;/;!function(){var e=se.createDocumentFragment(),t=e.appendChild(se.createElement("div")),n=se.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),ye.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",ye.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var Je=se.documentElement,Ke=/^key/,Ze=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,et=/^([^.]*)(?:\.(.+)|)/;xe.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=_e.get(e);if(v)for(n.handler&&(o=n,n=o.handler,i=o.selector),i&&xe.find.matchesSelector(Je,i),n.guid||(n.guid=xe.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(t){return void 0!==xe&&xe.event.triggered!==t.type?xe.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(Le)||[""],l=t.length;l--;)s=et.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p&&(f=xe.event.special[p]||{},p=(i?f.delegateType:f.bindType)||p,f=xe.event.special[p]||{},c=xe.extend({type:p,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&xe.expr.match.needsContext.test(i),namespace:h.join(".")},o),(d=u[p])||(d=u[p]=[],d.delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(p,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),xe.event.global[p]=!0)},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=_e.hasData(e)&&_e.get(e);if(v&&(u=v.events)){for(t=(t||"").match(Le)||[""],l=t.length;l--;)if(s=et.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p){for(f=xe.event.special[p]||{},p=(r?f.delegateType:f.bindType)||p,d=u[p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=d.length;o--;)c=d[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,f.remove&&f.remove.call(e,c));a&&!d.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||xe.removeEvent(e,p,v.handle),delete u[p])}else for(p in u)xe.event.remove(e,p+t[l],n,r,!0);xe.isEmptyObject(u)&&_e.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=xe.event.fix(e),u=new Array(arguments.length),l=(_e.get(this,"events")||{})[s.type]||[],c=xe.event.special[s.type]||{};for(u[0]=s,t=1;t<arguments.length;t++)u[t]=arguments[t];if(s.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,s)){for(a=xe.event.handlers.call(this,s,l),t=0;(i=a[t++])&&!s.isPropagationStopped();)for(s.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!s.isImmediatePropagationStopped();)s.rnamespace&&!s.rnamespace.test(o.namespace)||(s.handleObj=o,s.data=o.data,void 0!==(r=((xe.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,u))&&!1===(s.result=r)&&(s.preventDefault(),s.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,s),s.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)r=t[n],i=r.selector+" ",void 0===a[i]&&(a[i]=r.needsContext?xe(i,this).index(l)>-1:xe.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(xe.Event.prototype,e,{enumerable:!0,configurable:!0,get:xe.isFunction(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[xe.expando]?e:new xe.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==N()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===N()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&l(this,"input"))return this.click(),!1},_default:function(e){return l(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},xe.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},xe.Event=function(e,t){if(!(this instanceof xe.Event))return new xe.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?E:j,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&xe.extend(this,t),this.timeStamp=e&&e.timeStamp||xe.now(),this[xe.expando]=!0},xe.Event.prototype={constructor:xe.Event,isDefaultPrevented:j,isPropagationStopped:j,isImmediatePropagationStopped:j,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=E,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=E,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=E,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},xe.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&Ke.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&Ze.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},xe.event.addProp),xe.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){xe.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||xe.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),xe.fn.extend({on:function(e,t,n,r){return D(this,e,t,n,r)},one:function(e,t,n,r){return D(this,e,t,n,r,1)},off:function(e,t,n){var r,o;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,xe(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"===(void 0===e?"undefined":i(e))){for(o in e)this.off(o,t,e[o]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=j),this.each(function(){xe.event.remove(this,e,n,t)})}});var tt=/<script|<style|<link/i,nt=/checked\s*(?:[^=]|=\s*.checked.)/i,rt=/^true\/(.*)/,it=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;xe.extend({htmlPrefilter:function(e){return e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=xe.contains(e.ownerDocument,e);if(!(ye.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||xe.isXMLDoc(e)))for(a=k(s),o=k(e),r=0,i=o.length;r<i;r++)H(o[r],a[r]);if(t)if(n)for(o=o||k(e),a=a||k(s),r=0,i=o.length;r<i;r++)P(o[r],a[r]);else P(e,s);return a=k(s,"script"),a.length>0&&C(a,!u&&k(e,"script")),s},cleanData:function(e){for(var t,n,r,i=xe.event.special,o=0;void 0!==(n=e[o]);o++)if(Oe(n)){if(t=n[_e.expando]){if(t.events)for(r in t.events)i[r]?xe.event.remove(n,r):xe.removeEvent(n,r,t.handle);n[_e.expando]=void 0}n[Fe.expando]&&(n[Fe.expando]=void 0)}}}),xe.fn.extend({detach:function(e){return _(this,e,!0)},remove:function(e){return _(this,e)},text:function(e){return He(this,function(e){return void 0===e?xe.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return O(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){A(this,e).appendChild(e)}})},prepend:function(){return O(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=A(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return O(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return O(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(xe.cleanData(k(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return xe.clone(this,e,t)})},html:function(e){return He(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!tt.test(e)&&!Ye[(Ve.exec(e)||["",""])[1].toLowerCase()]){e=xe.htmlPrefilter(e);try{for(;n<r;n++)t=this[n]||{},1===t.nodeType&&(xe.cleanData(k(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return O(this,arguments,function(t){var n=this.parentNode;xe.inArray(this,e)<0&&(xe.cleanData(k(this)),n&&n.replaceChild(t,this))},e)}}),xe.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){xe.fn[e]=function(e){for(var n,r=[],i=xe(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),xe(i[a])[t](n),fe.apply(r,n.get());return this.pushStack(r)}});var ot=/^margin/,at=new RegExp("^("+Ie+")(?!px)[a-z%]+$","i"),st=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=o),t.getComputedStyle(e)};!function(){function e(){if(s){s.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",s.innerHTML="",Je.appendChild(a);var e=o.getComputedStyle(s);t="1%"!==e.top,i="2px"===e.marginLeft,n="4px"===e.width,s.style.marginRight="50%",r="4px"===e.marginRight,Je.removeChild(a),s=null}}var t,n,r,i,a=se.createElement("div"),s=se.createElement("div");s.style&&(s.style.backgroundClip="content-box",s.cloneNode(!0).style.backgroundClip="",ye.clearCloneStyle="content-box"===s.style.backgroundClip,a.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",a.appendChild(s),xe.extend(ye,{pixelPosition:function(){return e(),t},boxSizingReliable:function(){return e(),n},pixelMarginRight:function(){return e(),r},reliableMarginLeft:function(){return e(),i}}))}();var ut=/^(none|table(?!-c[ea]).+)/,lt=/^--/,ct={position:"absolute",visibility:"hidden",display:"block"},ft={letterSpacing:"0",fontWeight:"400"},dt=["Webkit","Moz","ms"],pt=se.createElement("div").style;xe.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=F(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=xe.camelCase(t),l=lt.test(t),c=e.style;if(l||(t=I(u)),s=xe.cssHooks[t]||xe.cssHooks[u],void 0===n)return s&&"get"in s&&void 0!==(o=s.get(e,!1,r))?o:c[t];a=void 0===n?"undefined":i(n),"string"===a&&(o=We.exec(n))&&o[1]&&(n=b(e,t,o),a="number"),null!=n&&n===n&&("number"===a&&(n+=o&&o[3]||(xe.cssNumber[u]?"":"px")),ye.clearCloneStyle||""!==n||0!==t.indexOf("background")||(c[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,r))||(l?c.setProperty(t,n):c[t]=n))}},css:function(e,t,n,r){var i,o,a,s=xe.camelCase(t);return lt.test(t)||(t=I(s)),a=xe.cssHooks[t]||xe.cssHooks[s],a&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=F(e,t,r)),"normal"===i&&t in ft&&(i=ft[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),xe.each(["height","width"],function(e,t){xe.cssHooks[t]={get:function(e,n,r){if(n)return!ut.test(xe.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?B(e,t,r):ze(e,ct,function(){return B(e,t,r)})},set:function(e,n,r){var i,o=r&&st(e),a=r&&$(e,t,r,"border-box"===xe.css(e,"boxSizing",!1,o),o);return a&&(i=We.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=xe.css(e,t)),W(e,n,a)}}}),xe.cssHooks.marginLeft=M(ye.reliableMarginLeft,function(e,t){if(t)return(parseFloat(F(e,"marginLeft"))||e.getBoundingClientRect().left-ze(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),xe.each({margin:"",padding:"",border:"Width"},function(e,t){xe.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+$e[r]+t]=o[r]||o[r-2]||o[0];return i}},ot.test(e)||(xe.cssHooks[e+t].set=W)}),xe.fn.extend({css:function(e,t){return He(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=st(e),i=t.length;a<i;a++)o[t[a]]=xe.css(e,t[a],!1,r);return o}return void 0!==n?xe.style(e,t,n):xe.css(e,t)},e,t,arguments.length>1)}}),xe.Tween=z,z.prototype={constructor:z,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||xe.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(xe.cssNumber[n]?"":"px")},cur:function(){var e=z.propHooks[this.prop];return e&&e.get?e.get(this):z.propHooks._default.get(this)},run:function(e){var t,n=z.propHooks[this.prop];return this.options.duration?this.pos=t=xe.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):z.propHooks._default.set(this),this}},z.prototype.init.prototype=z.prototype,z.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=xe.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){xe.fx.step[e.prop]?xe.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[xe.cssProps[e.prop]]&&!xe.cssHooks[e.prop]?e.elem[e.prop]=e.now:xe.style(e.elem,e.prop,e.now+e.unit)}}},z.propHooks.scrollTop=z.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},xe.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},xe.fx=z.prototype.init,xe.fx.step={};var ht,gt,vt=/^(?:toggle|show|hide)$/,mt=/queueHooks$/;xe.Animation=xe.extend(J,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return b(n.elem,e,We.exec(t),n),n}]},tweener:function(e,t){xe.isFunction(e)?(t=e,e=["*"]):e=e.match(Le);for(var n,r=0,i=e.length;r<i;r++)n=e[r],J.tweeners[n]=J.tweeners[n]||[],J.tweeners[n].unshift(t)},prefilters:[Y],prefilter:function(e,t){t?J.prefilters.unshift(e):J.prefilters.push(e)}}),xe.speed=function(e,t,n){var r=e&&"object"===(void 0===e?"undefined":i(e))?xe.extend({},e):{complete:n||!n&&t||xe.isFunction(e)&&e,duration:e,easing:n&&t||t&&!xe.isFunction(t)&&t};return xe.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in xe.fx.speeds?r.duration=xe.fx.speeds[r.duration]:r.duration=xe.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){xe.isFunction(r.old)&&r.old.call(this),r.queue&&xe.dequeue(this,r.queue)},r},xe.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Be).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=xe.isEmptyObject(e),o=xe.speed(t,n,r),a=function(){var t=J(this,xe.extend({},e),o);(i||_e.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=xe.timers,a=_e.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&mt.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||xe.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=_e.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=xe.timers,a=r?r.length:0;for(n.finish=!0,xe.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),xe.each(["toggle","show","hide"],function(e,t){var n=xe.fn[t];xe.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(V(t,!0),e,r,i)}}),xe.each({slideDown:V("show"),slideUp:V("hide"),slideToggle:V("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){xe.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),xe.timers=[],xe.fx.tick=function(){var e,t=0,n=xe.timers;for(ht=xe.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||xe.fx.stop(),ht=void 0},xe.fx.timer=function(e){xe.timers.push(e),xe.fx.start()},xe.fx.interval=13,xe.fx.start=function(){gt||(gt=!0,X())},xe.fx.stop=function(){gt=null},xe.fx.speeds={slow:600,fast:200,_default:400},xe.fn.delay=function(e,t){return e=xe.fx?xe.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=o.setTimeout(t,e);n.stop=function(){o.clearTimeout(r)}})},function(){var e=se.createElement("input"),t=se.createElement("select"),n=t.appendChild(se.createElement("option"));e.type="checkbox",ye.checkOn=""!==e.value,ye.optSelected=n.selected,e=se.createElement("input"),e.value="t",e.type="radio",ye.radioValue="t"===e.value}();var yt,xt=xe.expr.attrHandle;xe.fn.extend({attr:function(e,t){return He(this,xe.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){xe.removeAttr(this,e)})}}),xe.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?xe.prop(e,t,n):(1===o&&xe.isXMLDoc(e)||(i=xe.attrHooks[t.toLowerCase()]||(xe.expr.match.bool.test(t)?yt:void 0)),void 0!==n?null===n?void xe.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=xe.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!ye.radioValue&&"radio"===t&&l(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(Le);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),yt={set:function(e,t,n){return!1===t?xe.removeAttr(e,n):e.setAttribute(n,n),n}},xe.each(xe.expr.match.bool.source.match(/\w+/g),function(e,t){var n=xt[t]||xe.find.attr;xt[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=xt[a],xt[a]=i,i=null!=n(e,t,r)?a:null,xt[a]=o),i}});var bt=/^(?:input|select|textarea|button)$/i,wt=/^(?:a|area)$/i;xe.fn.extend({prop:function(e,t){return He(this,xe.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[xe.propFix[e]||e]})}}),xe.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&xe.isXMLDoc(e)||(t=xe.propFix[t]||t,i=xe.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=xe.find.attr(e,"tabindex");return t?parseInt(t,10):bt.test(e.nodeName)||wt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),ye.optSelected||(xe.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),xe.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){xe.propFix[this.toLowerCase()]=this}),xe.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(xe.isFunction(e))return this.each(function(t){xe(this).addClass(e.call(this,t,Z(this)))});if("string"==typeof e&&e)for(t=e.match(Le)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(xe.isFunction(e))return this.each(function(t){xe(this).removeClass(e.call(this,t,Z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(Le)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=void 0===e?"undefined":i(e);return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):xe.isFunction(e)?this.each(function(n){xe(this).toggleClass(e.call(this,n,Z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=xe(this),o=e.match(Le)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=Z(this),t&&_e.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":_e.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+K(Z(n))+" ").indexOf(t)>-1)return!0;return!1}});xe.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=xe.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,xe(this).val()):e,null==i?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=xe.map(i,function(e){return null==e?"":e+""})),(t=xe.valHooks[this.type]||xe.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=xe.valHooks[i.type]||xe.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(/\r/g,""):null==n?"":n)}}}),xe.extend({valHooks:{option:{get:function(e){var t=xe.find.attr(e,"value");return null!=t?t:K(xe.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(n=i[r],(n.selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!l(n.parentNode,"optgroup"))){if(t=xe(n).val(),a)return t;s.push(t)}return s},set:function(e,t){for(var n,r,i=e.options,o=xe.makeArray(t),a=i.length;a--;)r=i[a],(r.selected=xe.inArray(xe.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),xe.each(["radio","checkbox"],function(){xe.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=xe.inArray(xe(e).val(),t)>-1}},ye.checkOn||(xe.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Tt=/^(?:focusinfocus|focusoutblur)$/;xe.extend(xe.event,{trigger:function(e,t,n,r){var a,s,u,l,c,f,d,p=[n||se],h=ge.call(e,"type")?e.type:e,g=ge.call(e,"namespace")?e.namespace.split("."):[];if(s=u=n=n||se,3!==n.nodeType&&8!==n.nodeType&&!Tt.test(h+xe.event.triggered)&&(h.indexOf(".")>-1&&(g=h.split("."),h=g.shift(),g.sort()),c=h.indexOf(":")<0&&"on"+h,e=e[xe.expando]?e:new xe.Event(h,"object"===(void 0===e?"undefined":i(e))&&e),e.isTrigger=r?2:3,e.namespace=g.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:xe.makeArray(t,[e]),d=xe.event.special[h]||{},r||!d.trigger||!1!==d.trigger.apply(n,t))){if(!r&&!d.noBubble&&!xe.isWindow(n)){for(l=d.delegateType||h,Tt.test(l+h)||(s=s.parentNode);s;s=s.parentNode)p.push(s),u=s;u===(n.ownerDocument||se)&&p.push(u.defaultView||u.parentWindow||o)}for(a=0;(s=p[a++])&&!e.isPropagationStopped();)e.type=a>1?l:d.bindType||h,f=(_e.get(s,"events")||{})[e.type]&&_e.get(s,"handle"),f&&f.apply(s,t),(f=c&&s[c])&&f.apply&&Oe(s)&&(e.result=f.apply(s,t),!1===e.result&&e.preventDefault());return e.type=h,r||e.isDefaultPrevented()||d._default&&!1!==d._default.apply(p.pop(),t)||!Oe(n)||c&&xe.isFunction(n[h])&&!xe.isWindow(n)&&(u=n[c],u&&(n[c]=null),xe.event.triggered=h,n[h](),xe.event.triggered=void 0,u&&(n[c]=u)),e.result}},simulate:function(e,t,n){var r=xe.extend(new xe.Event,n,{type:e,isSimulated:!0});xe.event.trigger(r,null,t)}}),xe.fn.extend({trigger:function(e,t){return this.each(function(){xe.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return xe.event.trigger(e,t,n,!0)}}),xe.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){xe.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),xe.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),ye.focusin="onfocusin"in o,ye.focusin||xe.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){xe.event.simulate(t,e.target,xe.event.fix(e))};xe.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=_e.access(r,t);i||r.addEventListener(e,n,!0),_e.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=_e.access(r,t)-1;i?_e.access(r,t,i):(r.removeEventListener(e,n,!0),_e.remove(r,t))}}});var kt=o.location,Ct=xe.now(),St=/\?/;xe.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new o.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||xe.error("Invalid XML: "+e),t};var Et=/\[\]$/,jt=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;xe.param=function(e,t){var n,r=[],i=function(e,t){var n=xe.isFunction(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!xe.isPlainObject(e))xe.each(e,function(){i(this.name,this.value)});else for(n in e)ee(n,e[n],t,i);return r.join("&")},xe.fn.extend({serialize:function(){return xe.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=xe.prop(this,"elements");return e?xe.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!xe(this).is(":disabled")&&Nt.test(this.nodeName)&&!jt.test(e)&&(this.checked||!Ue.test(e))}).map(function(e,t){var n=xe(this).val();return null==n?null:Array.isArray(n)?xe.map(n,function(e){return{name:t.name,value:e.replace(/\r?\n/g,"\r\n")}}):{name:t.name,value:n.replace(/\r?\n/g,"\r\n")}}).get()}});var Dt=/^(.*?):[ \t]*([^\r\n]*)$/gm,At=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Lt=/^(?:GET|HEAD)$/,qt={},Pt={},Ht="*/".concat("*"),Ot=se.createElement("a");Ot.href=kt.href,xe.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:kt.href,type:"GET",isLocal:At.test(kt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ht,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":xe.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?re(re(e,xe.ajaxSettings),t):re(xe.ajaxSettings,e)},ajaxPrefilter:te(qt),ajaxTransport:te(Pt),ajax:function(e,t){function n(e,t,n,i){var u,c,p,h,w,T=t;f||(f=!0,l&&o.clearTimeout(l),r=void 0,s=i||"",C.readyState=e>0?4:0,u=e>=200&&e<300||304===e,n&&(h=ie(g,C,n)),h=oe(g,h,C,u),u?(g.ifModified&&(w=C.getResponseHeader("Last-Modified"),w&&(xe.lastModified[a]=w),(w=C.getResponseHeader("etag"))&&(xe.etag[a]=w)),204===e||"HEAD"===g.type?T="nocontent":304===e?T="notmodified":(T=h.state,c=h.data,p=h.error,u=!p)):(p=T,!e&&T||(T="error",e<0&&(e=0))),C.status=e,C.statusText=(t||T)+"",u?y.resolveWith(v,[c,T,C]):y.rejectWith(v,[C,T,p]),C.statusCode(b),b=void 0,d&&m.trigger(u?"ajaxSuccess":"ajaxError",[C,g,u?c:p]),x.fireWith(v,[C,T]),d&&(m.trigger("ajaxComplete",[C,g]),--xe.active||xe.event.trigger("ajaxStop")))}"object"===(void 0===e?"undefined":i(e))&&(t=e,e=void 0),t=t||{};var r,a,s,u,l,c,f,d,p,h,g=xe.ajaxSetup({},t),v=g.context||g,m=g.context&&(v.nodeType||v.jquery)?xe(v):xe.event,y=xe.Deferred(),x=xe.Callbacks("once memory"),b=g.statusCode||{},w={},T={},k="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(f){if(!u)for(u={};t=Dt.exec(s);)u[t[1].toLowerCase()]=t[2];t=u[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return f?s:null},setRequestHeader:function(e,t){return null==f&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,w[e]=t),this},overrideMimeType:function(e){return null==f&&(g.mimeType=e),this},statusCode:function(e){var t;if(e)if(f)C.always(e[C.status]);else for(t in e)b[t]=[b[t],e[t]];return this},abort:function(e){var t=e||k;return r&&r.abort(t),n(0,t),this}};if(y.promise(C),g.url=((e||g.url||kt.href)+"").replace(/^\/\//,kt.protocol+"//"),g.type=t.method||t.type||g.method||g.type,g.dataTypes=(g.dataType||"*").toLowerCase().match(Le)||[""],null==g.crossDomain){c=se.createElement("a");try{c.href=g.url,c.href=c.href,g.crossDomain=Ot.protocol+"//"+Ot.host!=c.protocol+"//"+c.host}catch(e){g.crossDomain=!0}}if(g.data&&g.processData&&"string"!=typeof g.data&&(g.data=xe.param(g.data,g.traditional)),ne(qt,g,t,C),f)return C;d=xe.event&&g.global,d&&0==xe.active++&&xe.event.trigger("ajaxStart"),g.type=g.type.toUpperCase(),g.hasContent=!Lt.test(g.type),a=g.url.replace(/#.*$/,""),g.hasContent?g.data&&g.processData&&0===(g.contentType||"").indexOf("application/x-www-form-urlencoded")&&(g.data=g.data.replace(/%20/g,"+")):(h=g.url.slice(a.length),g.data&&(a+=(St.test(a)?"&":"?")+g.data,delete g.data),!1===g.cache&&(a=a.replace(/([?&])_=[^&]*/,"$1"),h=(St.test(a)?"&":"?")+"_="+Ct+++h),g.url=a+h),g.ifModified&&(xe.lastModified[a]&&C.setRequestHeader("If-Modified-Since",xe.lastModified[a]),xe.etag[a]&&C.setRequestHeader("If-None-Match",xe.etag[a])),(g.data&&g.hasContent&&!1!==g.contentType||t.contentType)&&C.setRequestHeader("Content-Type",g.contentType),C.setRequestHeader("Accept",g.dataTypes[0]&&g.accepts[g.dataTypes[0]]?g.accepts[g.dataTypes[0]]+("*"!==g.dataTypes[0]?", "+Ht+"; q=0.01":""):g.accepts["*"]);for(p in g.headers)C.setRequestHeader(p,g.headers[p]);if(g.beforeSend&&(!1===g.beforeSend.call(v,C,g)||f))return C.abort();if(k="abort",x.add(g.complete),C.done(g.success),C.fail(g.error),r=ne(Pt,g,t,C)){if(C.readyState=1,d&&m.trigger("ajaxSend",[C,g]),f)return C;g.async&&g.timeout>0&&(l=o.setTimeout(function(){C.abort("timeout")},g.timeout));try{f=!1,r.send(w,n)}catch(e){if(f)throw e;n(-1,e)}}else n(-1,"No Transport");return C},getJSON:function(e,t,n){return xe.get(e,t,n,"json")},getScript:function(e,t){return xe.get(e,void 0,t,"script")}}),xe.each(["get","post"],function(e,t){xe[t]=function(e,n,r,i){return xe.isFunction(n)&&(i=i||r,r=n,n=void 0),xe.ajax(xe.extend({url:e,type:t,dataType:i,data:n,success:r},xe.isPlainObject(e)&&e))}}),xe._evalUrl=function(e){return xe.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},xe.fn.extend({wrapAll:function(e){var t;return this[0]&&(xe.isFunction(e)&&(e=e.call(this[0])),t=xe(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return xe.isFunction(e)?this.each(function(t){xe(this).wrapInner(e.call(this,t))}):this.each(function(){var t=xe(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=xe.isFunction(e);return this.each(function(n){xe(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){xe(this).replaceWith(this.childNodes)}),this}}),xe.expr.pseudos.hidden=function(e){return!xe.expr.pseudos.visible(e)},xe.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},xe.ajaxSettings.xhr=function(){try{return new o.XMLHttpRequest}catch(e){}};var _t={0:200,1223:204},Ft=xe.ajaxSettings.xhr();ye.cors=!!Ft&&"withCredentials"in Ft,ye.ajax=Ft=!!Ft,xe.ajaxTransport(function(e){var t,n;if(ye.cors||Ft&&!e.crossDomain)return{send:function(r,i){var a,s=e.xhr();if(s.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(a in e.xhrFields)s[a]=e.xhrFields[a];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),e.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(a in r)s.setRequestHeader(a,r[a]);t=function(e){return function(){t&&(t=n=s.onload=s.onerror=s.onabort=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?i(0,"error"):i(s.status,s.statusText):i(_t[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=t(),n=s.onerror=t("error"),void 0!==s.onabort?s.onabort=n:s.onreadystatechange=function(){4===s.readyState&&o.setTimeout(function(){t&&n()})},t=t("abort");try{s.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),xe.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),xe.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return xe.globalEval(e),e}}}),xe.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),xe.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=xe("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),se.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Mt=[],Rt=/(=)\?(?=&|$)|\?\?/;xe.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mt.pop()||xe.expando+"_"+Ct++;return this[e]=!0,e}}),xe.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,a,s=!1!==e.jsonp&&(Rt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Rt.test(e.data)&&"data");if(s||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=xe.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,s?e[s]=e[s].replace(Rt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return a||xe.error(r+" was not called"),a[0]},e.dataTypes[0]="json",i=o[r],o[r]=function(){a=arguments},n.always(function(){void 0===i?xe(o).removeProp(r):o[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Mt.push(r)),a&&xe.isFunction(i)&&i(a[0]),a=i=void 0}),"script"}),ye.createHTMLDocument=function(){var e=se.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),xe.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var r,i,o;return t||(ye.createHTMLDocument?(t=se.implementation.createHTMLDocument(""),r=t.createElement("base"),r.href=se.location.href,t.head.appendChild(r)):t=se),i=Se.exec(e),o=!n&&[],i?[t.createElement(i[1])]:(i=S([e],t,o),o&&o.length&&xe(o).remove(),xe.merge([],i.childNodes))},xe.fn.load=function(e,t,n){var r,o,a,s=this,u=e.indexOf(" ");return u>-1&&(r=K(e.slice(u)),e=e.slice(0,u)),xe.isFunction(t)?(n=t,t=void 0):t&&"object"===(void 0===t?"undefined":i(t))&&(o="POST"),s.length>0&&xe.ajax({url:e,type:o||"GET",dataType:"html",data:t}).done(function(e){a=arguments,s.html(r?xe("<div>").append(xe.parseHTML(e)).find(r):e)}).always(n&&function(e,t){s.each(function(){n.apply(this,a||[e.responseText,t,e])})}),this},xe.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){xe.fn[t]=function(e){return this.on(t,e)}}),xe.expr.pseudos.animated=function(e){return xe.grep(xe.timers,function(t){return e===t.elem}).length},xe.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=xe.css(e,"position"),f=xe(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=xe.css(e,"top"),u=xe.css(e,"left"),l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),xe.isFunction(t)&&(t=t.call(e,n,xe.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},xe.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){xe.offset.setOffset(this,e,t)});var t,n,r,i,o=this[0];if(o)return o.getClientRects().length?(r=o.getBoundingClientRect(),t=o.ownerDocument,n=t.documentElement,i=t.defaultView,{top:r.top+i.pageYOffset-n.clientTop,left:r.left+i.pageXOffset-n.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n=this[0],r={top:0,left:0};return"fixed"===xe.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),l(e[0],"html")||(r=e.offset()),r={top:r.top+xe.css(e[0],"borderTopWidth",!0),left:r.left+xe.css(e[0],"borderLeftWidth",!0)}),{top:t.top-r.top-xe.css(n,"marginTop",!0),left:t.left-r.left-xe.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===xe.css(e,"position");)e=e.offsetParent;return e||Je})}}),xe.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;xe.fn[e]=function(r){return He(this,function(e,r,i){var o;if(xe.isWindow(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),xe.each(["top","left"],function(e,t){xe.cssHooks[t]=M(ye.pixelPosition,function(e,n){if(n)return n=F(e,t),at.test(n)?xe(e).position()[t]+"px":n})}),xe.each({Height:"height",Width:"width"},function(e,t){xe.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){xe.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return He(this,function(t,n,i){var o;return xe.isWindow(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?xe.css(t,n,s):xe.style(t,n,i,s)},t,a?i:void 0,a)}})}),xe.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),xe.holdReady=function(e){e?xe.readyWait++:xe.ready(!0)},xe.isArray=Array.isArray,xe.parseJSON=JSON.parse,xe.nodeName=l,n=[],void 0!==(r=function(){return xe}.apply(t,n))&&(e.exports=r);var It=o.jQuery,Wt=o.$;return xe.noConflict=function(e){return o.$===xe&&(o.$=Wt),e&&o.jQuery===xe&&(o.jQuery=It),xe},a||(o.jQuery=o.$=xe),xe})}).call(t,n(4)(e))},function(e,t,n){"use strict";function r(){var e,t,n,r=(0,o.default)("#advanced_add_affiliate_link"),i=r.find(".search-panel"),a=r.find(".results-panel"),s=a.find("ul.results-list"),u=2,l=!0,c=void 0;i.on("keyup","#thirstylink-search",function(){var r=(0,o.default)(this),i=a.find(".load-more-results");return c&&n!==r.val()&&(c.abort(),c=null),e||(e=s.html()),s.html("<li class='spinner'><i style='background-image: url("+Options.spinner_image+");'></i><span>"+Options.searching_text+"</span></li>"),(""==r.val()||r.val().length<3)&&!l?(u=2,s.html(e).show(),void i.show()):n===r.val()?(u=2,s.html(t).show(),void i.show()):(u=1,i.hide(),void(c=o.default.post(parent.ajaxurl,{action:"search_affiliate_links_query",keyword:r.val(),paged:u,advance:!0,post_id:Options.post_id},function(e){n=r.val(),l=!1,"success"==e.status&&(t=e.search_query_markup,s.html(e.search_query_markup).show(),u++,e.count<1?i.hide():i.show())},"json")))}),a.on("click",".load-more-results",function(){var e=(0,o.default)(this),t=i.find("#thirstylink-search");e.hasClass("fetching")||(e.addClass("fetching").css("padding-top","4px").find(".spinner").show(),e.find(".button-text").hide(),c=o.default.post(parent.ajaxurl,{action:"search_affiliate_links_query",keyword:t.val(),paged:u,advance:!0},function(t){if(e.removeClass("fetching").find(".spinner").hide(),e.find(".button-text").show(),"success"==t.status){if(u++,t.count<1)return void e.hide();s.append(t.search_query_markup)}},"json"))})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(i)},function(e,t,n){"use strict";function r(){function e(){var e,t,r,o,s,u,l,c,f,d,p,h,g,v,m,y=(0,a.default)(this).closest("li.thirstylink"),x=(0,a.default)(this).data("type"),b=n.data("htmleditor"),w="";if(parent.ThirstyLinkPicker.linkNode||b){if(e=b?parent.ThirstyLinkPicker.get_html_editor_selection().text:parent.ThirstyLinkPicker.editor.selection.getContent(),t=y.data("linkid"),r=y.data("class"),o=r?' class="'+r+'"':"",s=y.data("href"),u=y.data("title"),l=u?' title="'+u+'"':"",c=y.find("span.name").text(),f=y.data("rel"),d=y.data("target"),v=y.data("other-atts"),!/^(?:[a-z]+:|#|\?|\.|\/)/.test(s))return;if("object"==(void 0===v?"undefined":i(v))&&Object.keys(v).length>0)for(var T in v)w+=T+'="'+v[T]+'" ';if("shortcode"==x)c=e.trim()?e:c,p='[thirstylink ids="'+t+'"]'+c+"[/thirstylink]",b?parent.ThirstyLinkPicker.replace_html_editor_selected_text(p):(parent.ThirstyLinkPicker.editor.execCommand("Unlink",!1,!1),parent.ThirstyLinkPicker.editor.selection.setContent(p),parent.ThirstyLinkPicker.inputInstance.reset());else if("image"==x)""!=r&&(o=' class="thirstylinkimg"'),g=(0,a.default)(this).data("imgid"),a.default.post(parent.ajaxurl,{action:"ta_get_image_markup_by_id",imgid:g},function(e){"success"==e.status&&(h="<a"+o+l+' href="'+s+'" rel="'+f+'" target="'+d+'" '+w+">"+e.image_markup+"</a>",b?parent.ThirstyLinkPicker.replace_html_editor_selected_text(h):(parent.ThirstyLinkPicker.editor.selection.setContent(h),parent.ThirstyLinkPicker.inputInstance.reset())),parent.ThirstyLinkPicker.close_thickbox()},"json");else if(c=e.trim()?e:c,b)h="<a"+o+l+' href="'+s+'" rel="'+f+'" target="'+d+'" '+w+">"+e+"</a>",parent.ThirstyLinkPicker.replace_html_editor_selected_text(h);else{if(m={class:r,title:u,href:s,rel:f,target:d,"data-wplink-edit":null,"data-thirstylink-edit":null},"object"==(void 0===v?"undefined":i(v))&&Object.keys(v).length>0)for(T in v)m[T]=v[T];parent.ThirstyLinkPicker.editor.execCommand("Unlink",!1,!1),parent.ThirstyLinkPicker.editor.execCommand("mceInsertLink",!1,m),e.trim()||parent.ThirstyLinkPicker.editor.selection.setContent(c),parent.ThirstyLinkPicker.inputInstance.reset()}g||parent.ThirstyLinkPicker.close_thickbox()}}var t=(0,a.default)("#advanced_add_affiliate_link"),n=t.find(".results-panel ul.results-list");n.on("click",".actions .insert-link-button",e),n.on("click",".actions .insert-shortcode-button",e),n.on("click",".images-block .images img",e),n.on("click",".actions .insert-image-button",function(){var e=(0,a.default)(this).closest(".thirstylink"),t=e.find(".images-block"),n=e.hasClass("show");(0,a.default)(".results-panel").find(".images-block").removeClass("show").hide(),n||t.slideDown("fast").addClass("show")})}Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=r;var o=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(o)},function(e,t){},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i=n(0),o=r(i),a=n(1),s=r(a),u=n(2),l=r(u);n(3),(0,o.default)(document).ready(function(){(0,s.default)(),(0,l.default)()})}]);
js/app/affiliate_link_page/dist/affiliate-link-page.css ADDED
@@ -0,0 +1 @@
 
1
+ label.info-label{margin:0 10px 5px 0;display:inline-block}label.info-label .tooltip{display:inline-block;width:12px;height:12px;position:relative;top:1px;text-align:center;font-size:9px;font-family:Verdana;background-size:12px 12px;background-image:url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTguMS4xLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDkyIDkyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA5MiA5MjsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHdpZHRoPSIxNnB4IiBoZWlnaHQ9IjE2cHgiPgo8Zz4KCTxwYXRoIGQ9Ik00NS4zODYsMC4wMDRDMTkuOTgzLDAuMzQ0LTAuMzMzLDIxLjIxNSwwLjAwNSw0Ni42MTljMC4zNCwyNS4zOTMsMjEuMjA5LDQ1LjcxNSw0Ni42MTEsNDUuMzc3ICAgYzI1LjM5OC0wLjM0Miw0NS43MTgtMjEuMjEzLDQ1LjM4LTQ2LjYxNUM5MS42NTYsMTkuOTg2LDcwLjc4Ni0wLjMzNSw0NS4zODYsMC4wMDR6IE00NS4yNSw3NGwtMC4yNTQtMC4wMDQgICBjLTMuOTEyLTAuMTE2LTYuNjctMi45OTgtNi41NTktNi44NTJjMC4xMDktMy43ODgsMi45MzQtNi41MzgsNi43MTctNi41MzhsMC4yMjcsMC4wMDRjNC4wMjEsMC4xMTksNi43NDgsMi45NzIsNi42MzUsNi45MzcgICBDNTEuOTA0LDcxLjM0Niw0OS4xMjMsNzQsNDUuMjUsNzR6IE02MS43MDUsNDEuMzQxYy0wLjkyLDEuMzA3LTIuOTQzLDIuOTMtNS40OTIsNC45MTZsLTIuODA3LDEuOTM4ICAgYy0xLjU0MSwxLjE5OC0yLjQ3MSwyLjMyNS0yLjgyLDMuNDM0Yy0wLjI3NSwwLjg3My0wLjQxLDEuMTA0LTAuNDM0LDIuODhsLTAuMDA0LDAuNDUxSDM5LjQzbDAuMDMxLTAuOTA3ICAgYzAuMTMxLTMuNzI4LDAuMjIzLTUuOTIxLDEuNzY4LTcuNzMzYzIuNDI0LTIuODQ2LDcuNzcxLTYuMjg5LDcuOTk4LTYuNDM1YzAuNzY2LTAuNTc3LDEuNDEyLTEuMjM0LDEuODkzLTEuOTM2ICAgYzEuMTI1LTEuNTUxLDEuNjIzLTIuNzcyLDEuNjIzLTMuOTcyYzAtMS42NjUtMC40OTQtMy4yMDUtMS40NzEtNC41NzZjLTAuOTM5LTEuMzIzLTIuNzIzLTEuOTkzLTUuMzAzLTEuOTkzICAgYy0yLjU1OSwwLTQuMzExLDAuODEyLTUuMzU5LDIuNDc4Yy0xLjA3OCwxLjcxMy0xLjYyMywzLjUxMi0xLjYyMyw1LjM1djAuNDU3SDI3LjkzNmwwLjAyLTAuNDc3ICAgYzAuMjg1LTYuNzY5LDIuNzAxLTExLjY0Myw3LjE3OC0xNC40ODdDMzcuOTQ3LDE4LjkxOCw0MS40NDcsMTgsNDUuNTMxLDE4YzUuMzQ2LDAsOS44NTksMS4yOTksMTMuNDEyLDMuODYxICAgYzMuNiwyLjU5Niw1LjQyNiw2LjQ4NCw1LjQyNiwxMS41NTZDNjQuMzY5LDM2LjI1NCw2My40NzMsMzguOTE5LDYxLjcwNSw0MS4zNDF6IiBmaWxsPSIjNzU3NTc1Ii8+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==)}label.info-label.block{display:block}.ta-form-input{height:31px;font-size:14px;border:1px solid #dfdfdf;width:100%;margin:0 0 5px;padding:5px}.clearfix:after{content:"";clear:both;display:table}.ta-input-description{color:#909090;padding-left:2px;font-style:italic;font-size:10px}div#edit-slug-box{padding-left:0}.submitdelete{color:red;font-weight:400;text-decoration:underline;margin-left:5px}#thirsty_image_holder{background:#fff;overflow:hidden;padding:0 0 20px;margin:10px 0 0;border:1px solid #dfdfdf;text-align:center}#thirsty_image_holder .thirsty-attached-image{position:relative;border:1px solid #eee;padding:5px;margin-left:20px;margin-top:20px;float:left}#thirsty_image_holder .thirsty-remove-img{position:absolute;top:-8px;right:-8px;background:#c00;color:#fff;font-size:16px;font-weight:700;line-height:.7em;padding:2px 3px 4px;border-radius:50px;cursor:pointer}#ta_upload_insert_img,#ta_upload_media_manager{margin-top:5px}#ta_upload_insert_img a{text-decoration:none}.wp-media-buttons-icon:before{content:"\F104";font-family:dashicons;font-size:12px}.attachments-browser .media-toolbar-secondary{width:300px;max-width:300px}.attachments-browser .media-toolbar-primary{width:200px;max-width:200px}
js/app/affiliate_link_page/dist/affiliate-link-page.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){"use strict";(function(e){var n,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!
2
+ * jQuery JavaScript Library v3.2.1
3
+ * https://jquery.com/
4
+ *
5
+ * Includes Sizzle.js
6
+ * https://sizzlejs.com/
7
+ *
8
+ * Copyright JS Foundation and other contributors
9
+ * Released under the MIT license
10
+ * https://jquery.org/license
11
+ *
12
+ * Date: 2017-03-20T18:59Z
13
+ */
14
+ !function(t,n){"object"===i(e)&&"object"===i(e.exports)?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:void 0,function(o,a){function s(e,t){t=t||se;var n=t.createElement("script");n.text=e,t.head.appendChild(n).parentNode.removeChild(n)}function u(e){var t=!!e&&"length"in e&&e.length,n=xe.type(e);return"function"!==n&&!xe.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function l(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function c(e,t,n){return xe.isFunction(t)?xe.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?xe.grep(e,function(e){return e===t!==n}):"string"!=typeof t?xe.grep(e,function(e){return de.call(t,e)>-1!==n}):Se.test(t)?xe.filter(t,e,n):(t=xe.filter(t,e),xe.grep(e,function(e){return de.call(t,e)>-1!==n&&1===e.nodeType}))}function f(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function d(e){var t={};return xe.each(e.match(qe)||[],function(e,n){t[n]=!0}),t}function p(e){return e}function h(e){throw e}function g(e,t,n,r){var i;try{e&&xe.isFunction(i=e.promise)?i.call(e).done(t).fail(n):e&&xe.isFunction(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}function v(){se.removeEventListener("DOMContentLoaded",v),o.removeEventListener("load",v),xe.ready()}function m(){this.expando=xe.expando+m.uid++}function y(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Me.test(e)?JSON.parse(e):e)}function x(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(Re,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=y(n)}catch(e){}Pe.set(e,t,n)}else n=void 0;return n}function b(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return xe.css(e,t,"")},u=s(),l=n&&n[3]||(xe.cssNumber[t]?"":"px"),c=(xe.cssNumber[t]||"px"!==l&&+u)&&We.exec(xe.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do{o=o||".5",c/=o,xe.style(e,t,c+l)}while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function w(e){var t,n=e.ownerDocument,r=e.nodeName,i=Xe[r];return i||(t=n.body.appendChild(n.createElement(r)),i=xe.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),Xe[r]=i,i)}function T(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)r=e[o],r.style&&(n=r.style.display,t?("none"===n&&(i[o]=Fe.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&Be(r)&&(i[o]=w(r))):"none"!==n&&(i[o]="none",Fe.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}function C(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&l(e,t)?xe.merge([e],n):n}function k(e,t){for(var n=0,r=e.length;n<r;n++)Fe.set(e[n],"globalEval",!t||Fe.get(t[n],"globalEval"))}function E(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),d=[],p=0,h=e.length;p<h;p++)if((o=e[p])||0===o)if("object"===xe.type(o))xe.merge(d,o.nodeType?[o]:o);else if(Qe.test(o)){for(a=a||f.appendChild(t.createElement("div")),s=(Ve.exec(o)||["",""])[1].toLowerCase(),u=Ye[s]||Ye._default,a.innerHTML=u[1]+xe.htmlPrefilter(o)+u[2],c=u[0];c--;)a=a.lastChild;xe.merge(d,a.childNodes),a=f.firstChild,a.textContent=""}else d.push(t.createTextNode(o));for(f.textContent="",p=0;o=d[p++];)if(r&&xe.inArray(o,r)>-1)i&&i.push(o);else if(l=xe.contains(o.ownerDocument,o),a=C(f.appendChild(o),"script"),l&&k(a),n)for(c=0;o=a[c++];)Ge.test(o.type||"")&&n.push(o);return f}function S(){return!0}function j(){return!1}function N(){try{return se.activeElement}catch(e){}}function D(e,t,n,r,o,a){var s,u;if("object"===(void 0===t?"undefined":i(t))){"string"!=typeof n&&(r=r||n,n=void 0);for(u in t)D(e,u,n,r,t[u],a);return e}if(null==r&&null==o?(o=n,r=n=void 0):null==o&&("string"==typeof n?(o=r,r=void 0):(o=r,r=n,n=void 0)),!1===o)o=j;else if(!o)return e;return 1===a&&(s=o,o=function(e){return xe().off(e),s.apply(this,arguments)},o.guid=s.guid||(s.guid=xe.guid++)),e.each(function(){xe.event.add(this,t,o,r,n)})}function A(e,t){return l(e,"table")&&l(11!==t.nodeType?t:t.firstChild,"tr")?xe(">tbody",e)[0]||e:e}function q(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function L(e){var t=rt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Fe.hasData(e)&&(o=Fe.access(e),a=Fe.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)xe.event.add(t,i,l[i][n])}Pe.hasData(e)&&(s=Pe.access(e),u=xe.extend({},s),Pe.set(t,u))}}function O(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Ue.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function H(e,t,n,r){t=ce.apply([],t);var i,o,a,u,l,c,f=0,d=e.length,p=d-1,h=t[0],g=xe.isFunction(h);if(g||d>1&&"string"==typeof h&&!ye.checkClone&&nt.test(h))return e.each(function(i){var o=e.eq(i);g&&(t[0]=h.call(this,i,o.html())),H(o,t,n,r)});if(d&&(i=E(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(a=xe.map(C(i,"script"),q),u=a.length;f<d;f++)l=i,f!==p&&(l=xe.clone(l,!0,!0),u&&xe.merge(a,C(l,"script"))),n.call(e[f],l,f);if(u)for(c=a[a.length-1].ownerDocument,xe.map(a,L),f=0;f<u;f++)l=a[f],Ge.test(l.type||"")&&!Fe.access(l,"globalEval")&&xe.contains(c,l)&&(l.src?xe._evalUrl&&xe._evalUrl(l.src):s(l.textContent.replace(it,""),c))}return e}function F(e,t,n){for(var r,i=t?xe.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||xe.cleanData(C(r)),r.parentNode&&(n&&xe.contains(r.ownerDocument,r)&&k(C(r,"script")),r.parentNode.removeChild(r));return e}function P(e,t,n){var r,i,o,a,s=e.style;return n=n||st(e),n&&(a=n.getPropertyValue(t)||n[t],""!==a||xe.contains(e.ownerDocument,e)||(a=xe.style(e,t)),!ye.pixelMarginRight()&&at.test(a)&&ot.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function M(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function R(e){if(e in pt)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=dt.length;n--;)if((e=dt[n]+t)in pt)return e}function I(e){var t=xe.cssProps[e];return t||(t=xe.cssProps[e]=R(e)||e),t}function W(e,t,n){var r=We.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function $(e,t,n,r,i){var o,a=0;for(o=n===(r?"border":"content")?4:"width"===t?1:0;o<4;o+=2)"margin"===n&&(a+=xe.css(e,n+$e[o],!0,i)),r?("content"===n&&(a-=xe.css(e,"padding"+$e[o],!0,i)),"margin"!==n&&(a-=xe.css(e,"border"+$e[o]+"Width",!0,i))):(a+=xe.css(e,"padding"+$e[o],!0,i),"padding"!==n&&(a+=xe.css(e,"border"+$e[o]+"Width",!0,i)));return a}function B(e,t,n){var r,i=st(e),o=P(e,t,i),a="border-box"===xe.css(e,"boxSizing",!1,i);return at.test(o)?o:(r=a&&(ye.boxSizingReliable()||o===e.style[t]),"auto"===o&&(o=e["offset"+t[0].toUpperCase()+t.slice(1)]),(o=parseFloat(o)||0)+$(e,t,n||(a?"border":"content"),r,i)+"px")}function z(e,t,n,r,i){return new z.prototype.init(e,t,n,r,i)}function X(){gt&&(!1===se.hidden&&o.requestAnimationFrame?o.requestAnimationFrame(X):o.setTimeout(X,xe.fx.interval),xe.fx.tick())}function U(){return o.setTimeout(function(){ht=void 0}),ht=xe.now()}function V(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)n=$e[r],i["margin"+n]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function G(e,t,n){for(var r,i=(J.tweeners[t]||[]).concat(J.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function Y(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,d=this,p={},h=e.style,g=e.nodeType&&Be(e),v=Fe.get(e,"fxshow");n.queue||(a=xe._queueHooks(e,"fx"),null==a.unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,d.always(function(){d.always(function(){a.unqueued--,xe.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],vt.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}p[r]=v&&v[r]||xe.style(e,r)}if((u=!xe.isEmptyObject(t))||!xe.isEmptyObject(p)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],l=v&&v.display,null==l&&(l=Fe.get(e,"display")),c=xe.css(e,"display"),"none"===c&&(l?c=l:(T([e],!0),l=e.style.display||l,c=xe.css(e,"display"),T([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===xe.css(e,"float")&&(u||(d.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",d.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in p)u||(v?"hidden"in v&&(g=v.hidden):v=Fe.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&T([e],!0),d.done(function(){g||T([e]),Fe.remove(e,"fxshow");for(r in p)xe.style(e,r,p[r])})),u=G(g?v[r]:0,r,d),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}}function Q(e,t){var n,r,i,o,a;for(n in e)if(r=xe.camelCase(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=xe.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function J(e,t,n){var r,i,o=0,a=J.prefilters.length,s=xe.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=ht||U(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;a<u;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),o<1&&u?n:(u||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:xe.extend({},t),opts:xe.extend(!0,{specialEasing:{},easing:xe.easing._default},n),originalProperties:t,originalOptions:n,startTime:ht||U(),duration:n.duration,tweens:[],createTween:function(t,n){var r=xe.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(Q(c,l.opts.specialEasing);o<a;o++)if(r=J.prefilters[o].call(l,e,c,l.opts))return xe.isFunction(r.stop)&&(xe._queueHooks(l.elem,l.opts.queue).stop=xe.proxy(r.stop,r)),r;return xe.map(c,G,l),xe.isFunction(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),xe.fx.timer(xe.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}function K(e){return(e.match(qe)||[]).join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ee(e,t,n,r){var o;if(Array.isArray(t))xe.each(t,function(t,o){n||St.test(e)?r(e,o):ee(e+"["+("object"===(void 0===o?"undefined":i(o))&&null!=o?t:"")+"]",o,n,r)});else if(n||"object"!==xe.type(t))r(e,t);else for(o in t)ee(e+"["+o+"]",t[o],n,r)}function te(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(qe)||[];if(xe.isFunction(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ne(e,t,n,r){function i(s){var u;return o[s]=!0,xe.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||a||o[l]?a?!(u=l):void 0:(t.dataTypes.unshift(l),i(l),!1)}),u}var o={},a=e===_t;return i(t.dataTypes[0])||!o["*"]&&i("*")}function re(e,t){var n,r,i=xe.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&xe.extend(!0,e,r),e}function ie(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;"*"===u[0];)u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function oe(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if(s=i.split(" "),s[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}var ae=[],se=o.document,ue=Object.getPrototypeOf,le=ae.slice,ce=ae.concat,fe=ae.push,de=ae.indexOf,pe={},he=pe.toString,ge=pe.hasOwnProperty,ve=ge.toString,me=ve.call(Object),ye={},xe=function e(t,n){return new e.fn.init(t,n)},be=function(e,t){return t.toUpperCase()};xe.fn=xe.prototype={jquery:"3.2.1",constructor:xe,length:0,toArray:function(){return le.call(this)},get:function(e){return null==e?le.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=xe.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return xe.each(this,e)},map:function(e){return this.pushStack(xe.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(le.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:fe,sort:ae.sort,splice:ae.splice},xe.extend=xe.fn.extend=function(){var e,t,n,r,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[u]||{},u++),"object"===(void 0===s?"undefined":i(s))||xe.isFunction(s)||(s={}),u===l&&(s=this,u--);u<l;u++)if(null!=(e=arguments[u]))for(t in e)n=s[t],r=e[t],s!==r&&(c&&r&&(xe.isPlainObject(r)||(o=Array.isArray(r)))?(o?(o=!1,a=n&&Array.isArray(n)?n:[]):a=n&&xe.isPlainObject(n)?n:{},s[t]=xe.extend(c,a,r)):void 0!==r&&(s[t]=r));return s},xe.extend({expando:"jQuery"+("3.2.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return"function"===xe.type(e)},isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){var t=xe.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==he.call(e))&&(!(t=ue(e))||"function"==typeof(n=ge.call(t,"constructor")&&t.constructor)&&ve.call(n)===me)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},type:function(e){return null==e?e+"":"object"===(void 0===e?"undefined":i(e))||"function"==typeof e?pe[he.call(e)]||"object":void 0===e?"undefined":i(e)},globalEval:function(e){s(e)},camelCase:function(e){return e.replace(/^-ms-/,"ms-").replace(/-([a-z])/g,be)},each:function(e,t){var n,r=0;if(u(e))for(n=e.length;r<n&&!1!==t.call(e[r],r,e[r]);r++);else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(u(Object(e))?xe.merge(n,"string"==typeof e?[e]:e):fe.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:de.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(u(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return ce.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),xe.isFunction(e))return r=le.call(arguments,2),i=function(){return e.apply(t||this,r.concat(le.call(arguments)))},i.guid=e.guid=e.guid||xe.guid++,i},now:Date.now,support:ye}),"function"==typeof Symbol&&(xe.fn[Symbol.iterator]=ae[Symbol.iterator]),xe.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){pe["[object "+t+"]"]=t.toLowerCase()});var we=/*!
15
+ * Sizzle CSS Selector Engine v2.3.3
16
+ * https://sizzlejs.com/
17
+ *
18
+ * Copyright jQuery Foundation and other contributors
19
+ * Released under the MIT license
20
+ * http://jquery.org/license
21
+ *
22
+ * Date: 2016-08-08
23
+ */
24
+ function(e){function t(e,t,n,r){var i,o,a,s,u,c,d,p=t&&t.ownerDocument,h=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==h&&9!==h&&11!==h)return n;if(!r&&((t?t.ownerDocument||t:R)!==q&&A(t),t=t||q,_)){if(11!==h&&(u=ge.exec(e)))if(i=u[1]){if(9===h){if(!(a=t.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(p&&(a=p.getElementById(i))&&P(t,a)&&a.id===i)return n.push(a),n}else{if(u[2])return Q.apply(n,t.getElementsByTagName(e)),n;if((i=u[3])&&b.getElementsByClassName&&t.getElementsByClassName)return Q.apply(n,t.getElementsByClassName(i)),n}if(b.qsa&&!z[e+" "]&&(!O||!O.test(e))){if(1!==h)p=t,d=e;else if("object"!==t.nodeName.toLowerCase()){for((s=t.getAttribute("id"))?s=s.replace(xe,be):t.setAttribute("id",s=M),c=k(e),o=c.length;o--;)c[o]="#"+s+" "+f(c[o]);d=c.join(","),p=ve.test(e)&&l(t.parentNode)||t}if(d)try{return Q.apply(n,p.querySelectorAll(d)),n}catch(e){}finally{s===M&&t.removeAttribute("id")}}}return S(e.replace(oe,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[M]=!0,e}function i(e){var t=q.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&Te(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function u(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function l(e){return e&&void 0!==e.getElementsByTagName&&e}function c(){}function f(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function d(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=W++;return t.first?function(t,n,i){for(;t=t[r];)if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,d=[I,s];if(u){for(;t=t[r];)if((1===t.nodeType||a)&&e(t,n,u))return!0}else for(;t=t[r];)if(1===t.nodeType||a)if(f=t[M]||(t[M]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===I&&l[1]===s)return d[2]=l[2];if(c[o]=d,d[2]=e(t,n,u))return!0}return!1}}function p(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function h(e,n,r){for(var i=0,o=n.length;i<o;i++)t(e,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function v(e,t,n,i,o,a){return i&&!i[M]&&(i=v(i)),o&&!o[M]&&(o=v(o,a)),r(function(r,a,s,u){var l,c,f,d=[],p=[],v=a.length,m=r||h(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?m:g(m,d,e,s,u),x=n?o||(r?e:v||i)?[]:a:y;if(n&&n(y,x,s,u),i)for(l=g(x,p),i(l,[],s,u),c=l.length;c--;)(f=l[c])&&(x[p[c]]=!(y[p[c]]=f));if(r){if(o||e){if(o){for(l=[],c=x.length;c--;)(f=x[c])&&l.push(y[c]=f);o(null,x=[],l,u)}for(c=x.length;c--;)(f=x[c])&&(l=o?K(r,f):d[c])>-1&&(r[l]=!(a[l]=f))}}else x=g(x===a?x.splice(v,x.length):x),o?o(null,a,x,u):Q.apply(a,x)})}function m(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,u=d(function(e){return e===t},a,!0),l=d(function(e){return K(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==j)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s<i;s++)if(n=w.relative[e[s].type])c=[d(p(c),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[M]){for(r=++s;r<i&&!w.relative[e[r].type];r++);return v(s>1&&p(c),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(oe,"$1"),n,s<r&&m(e.slice(s,r)),r<i&&m(e=e.slice(r)),r<i&&f(e))}c.push(n)}return p(c)}function y(e,n){var i=n.length>0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",v=r&&[],m=[],y=j,x=r||o&&w.find.TAG("*",l),b=I+=null==y?1:Math.random()||.1,T=x.length;for(l&&(j=a===q||a||l);h!==T&&null!=(c=x[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===q||(A(c),s=!_);d=e[f++];)if(d(c,a||q,s)){u.push(c);break}l&&(I=b)}i&&((c=!d&&c)&&p--,r&&v.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(v,m,a,s);if(r){if(p>0)for(;h--;)v[h]||m[h]||(m[h]=G.call(u));m=g(m)}Q.apply(u,m),l&&!r&&m.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(I=b,j=y),v};return i?r(a):a}var x,b,w,T,C,k,E,S,j,N,D,A,q,L,_,O,H,F,P,M="sizzle"+1*new Date,R=e.document,I=0,W=0,$=n(),B=n(),z=n(),X=function(e,t){return e===t&&(D=!0),0},U={}.hasOwnProperty,V=[],G=V.pop,Y=V.push,Q=V.push,J=V.slice,K=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},Z="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ee="[\\x20\\t\\r\\n\\f]",te="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",ne="\\["+ee+"*("+te+")(?:"+ee+"*([*^$|!~]?=)"+ee+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+te+"))|)"+ee+"*\\]",re=":("+te+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ne+")*)|.*)\\)|)",ie=new RegExp(ee+"+","g"),oe=new RegExp("^"+ee+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ee+"+$","g"),ae=new RegExp("^"+ee+"*,"+ee+"*"),se=new RegExp("^"+ee+"*([>+~]|"+ee+")"+ee+"*"),ue=new RegExp("="+ee+"*([^\\]'\"]*?)"+ee+"*\\]","g"),le=new RegExp(re),ce=new RegExp("^"+te+"$"),fe={ID:new RegExp("^#("+te+")"),CLASS:new RegExp("^\\.("+te+")"),TAG:new RegExp("^("+te+"|[*])"),ATTR:new RegExp("^"+ne),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ee+"*(even|odd|(([+-]|)(\\d*)n|)"+ee+"*(?:([+-]|)"+ee+"*(\\d+)|))"+ee+"*\\)|)","i"),bool:new RegExp("^(?:"+Z+")$","i"),needsContext:new RegExp("^"+ee+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ee+"*((?:-\\d)?\\d*)"+ee+"*\\)|)(?=[^-]|$)","i")},de=/^(?:input|select|textarea|button)$/i,pe=/^h\d$/i,he=/^[^{]+\{\s*\[native \w/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ve=/[+~]/,me=new RegExp("\\\\([\\da-f]{1,6}"+ee+"?|("+ee+")|.)","ig"),ye=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},xe=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,be=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},we=function(){A()},Te=d(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{Q.apply(V=J.call(R.childNodes),R.childNodes),V[R.childNodes.length].nodeType}catch(e){Q={apply:V.length?function(e,t){Y.apply(e,J.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}b=t.support={},C=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},A=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:R;return r!==q&&9===r.nodeType&&r.documentElement?(q=r,L=q.documentElement,_=!C(q),R!==q&&(n=q.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",we,!1):n.attachEvent&&n.attachEvent("onunload",we)),b.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),b.getElementsByTagName=i(function(e){return e.appendChild(q.createComment("")),!e.getElementsByTagName("*").length}),b.getElementsByClassName=he.test(q.getElementsByClassName),b.getById=i(function(e){return L.appendChild(e).id=M,!q.getElementsByName||!q.getElementsByName(M).length}),b.getById?(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){return e.getAttribute("id")===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&_){var n=t.getElementById(e);return n?[n]:[]}}):(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&_){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),w.find.TAG=b.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):b.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=b.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&_)return t.getElementsByClassName(e)},H=[],O=[],(b.qsa=he.test(q.querySelectorAll))&&(i(function(e){L.appendChild(e).innerHTML="<a id='"+M+"'></a><select id='"+M+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&O.push("[*^$]="+ee+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||O.push("\\["+ee+"*(?:value|"+Z+")"),e.querySelectorAll("[id~="+M+"-]").length||O.push("~="),e.querySelectorAll(":checked").length||O.push(":checked"),e.querySelectorAll("a#"+M+"+*").length||O.push(".#.+[+~]")}),i(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=q.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&O.push("name"+ee+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&O.push(":enabled",":disabled"),L.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&O.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),O.push(",.*:")})),(b.matchesSelector=he.test(F=L.matches||L.webkitMatchesSelector||L.mozMatchesSelector||L.oMatchesSelector||L.msMatchesSelector))&&i(function(e){b.disconnectedMatch=F.call(e,"*"),F.call(e,"[s!='']:x"),H.push("!=",re)}),O=O.length&&new RegExp(O.join("|")),H=H.length&&new RegExp(H.join("|")),t=he.test(L.compareDocumentPosition),P=t||he.test(L.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},X=t?function(e,t){if(e===t)return D=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!b.sortDetached&&t.compareDocumentPosition(e)===n?e===q||e.ownerDocument===R&&P(R,e)?-1:t===q||t.ownerDocument===R&&P(R,t)?1:N?K(N,e)-K(N,t):0:4&n?-1:1)}:function(e,t){if(e===t)return D=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===q?-1:t===q?1:i?-1:o?1:N?K(N,e)-K(N,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===R?-1:u[r]===R?1:0},q):q},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==q&&A(e),n=n.replace(ue,"='$1']"),b.matchesSelector&&_&&!z[n+" "]&&(!H||!H.test(n))&&(!O||!O.test(n)))try{var r=F.call(e,n);if(r||b.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return t(n,q,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==q&&A(e),P(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==q&&A(e);var n=w.attrHandle[t.toLowerCase()],r=n&&U.call(w.attrHandle,t.toLowerCase())?n(e,t,!_):void 0;return void 0!==r?r:b.attributes||!_?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.escape=function(e){return(e+"").replace(xe,be)},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(D=!b.detectDuplicates,N=!b.sortStable&&e.slice(0),e.sort(X),D){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return N=null,e},T=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=T(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=T(t);return n},w=t.selectors={cacheLength:50,createPseudo:r,match:fe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(me,ye),e[3]=(e[3]||e[4]||e[5]||"").replace(me,ye),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return fe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&le.test(n)&&(t=k(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(me,ye).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ee+")"+e+"("+ee+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ie," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,g=o!==a?"nextSibling":"previousSibling",v=t.parentNode,m=s&&t.nodeName.toLowerCase(),y=!u&&!s,x=!1;if(v){if(o){for(;g;){for(d=t;d=d[g];)if(s?d.nodeName.toLowerCase()===m:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?v.firstChild:v.lastChild],a&&y){for(d=v,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],x=p&&l[2],d=p&&v.childNodes[p];d=++p&&d&&d[g]||(x=p=0)||h.pop();)if(1===d.nodeType&&++x&&d===t){c[e]=[I,p,x];break}}else if(y&&(d=t,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],x=p),!1===x)for(;(d=++p&&d&&d[g]||(x=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==m:1!==d.nodeType)||!++x||(y&&(f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[I,x]),d!==t)););return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,n){var i,o=w.pseudos[e]||w.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[M]?o(n):o.length>1?(i=[e,e,"",n],w.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=K(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=E(e.replace(oe,"$1"));return i[M]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(me,ye),function(t){return(t.textContent||t.innerText||T(t)).indexOf(e)>-1}}),lang:r(function(e){return ce.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(me,ye).toLowerCase(),function(t){var n;do{if(n=_?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===L},focus:function(e){return e===q.activeElement&&(!q.hasFocus||q.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:s(!1),disabled:s(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return pe.test(e.nodeName)},input:function(e){return de.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:u(function(){return[0]}),last:u(function(e,t){return[t-1]}),eq:u(function(e,t,n){return[n<0?n+t:n]}),even:u(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:u(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:u(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:u(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},w.pseudos.nth=w.pseudos.eq;for(x in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})w.pseudos[x]=function(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}(x);for(x in{submit:!0,reset:!0})w.pseudos[x]=function(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}(x);return c.prototype=w.filters=w.pseudos,w.setFilters=new c,k=t.tokenize=function(e,n){var r,i,o,a,s,u,l,c=B[e+" "];if(c)return n?0:c.slice(0);for(s=e,u=[],l=w.preFilter;s;){r&&!(i=ae.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),r=!1,(i=se.exec(s))&&(r=i.shift(),o.push({value:r,type:i[0].replace(oe," ")}),s=s.slice(r.length));for(a in w.filter)!(i=fe[a].exec(s))||l[a]&&!(i=l[a](i))||(r=i.shift(),o.push({value:r,type:a,matches:i}),s=s.slice(r.length));if(!r)break}return n?s.length:s?t.error(e):B(e,u).slice(0)},E=t.compile=function(e,t){var n,r=[],i=[],o=z[e+" "];if(!o){for(t||(t=k(e)),n=t.length;n--;)o=m(t[n]),o[M]?r.push(o):i.push(o);o=z(e,y(i,r)),o.selector=e}return o},S=t.select=function(e,t,n,r){var i,o,a,s,u,c="function"==typeof e&&e,d=!r&&k(e=c.selector||e);if(n=n||[],1===d.length){if(o=d[0]=d[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&9===t.nodeType&&_&&w.relative[o[1].type]){if(!(t=(w.find.ID(a.matches[0].replace(me,ye),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=fe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((u=w.find[s])&&(r=u(a.matches[0].replace(me,ye),ve.test(o[0].type)&&l(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&f(o)))return Q.apply(n,r),n;break}}return(c||E(e,d))(r,t,!_,n,!t||ve.test(e)&&l(t.parentNode)||t),n},b.sortStable=M.split("").sort(X).join("")===M,b.detectDuplicates=!!D,A(),b.sortDetached=i(function(e){return 1&e.compareDocumentPosition(q.createElement("fieldset"))}),i(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),b.attributes&&i(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(Z,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(o);xe.find=we,xe.expr=we.selectors,xe.expr[":"]=xe.expr.pseudos,xe.uniqueSort=xe.unique=we.uniqueSort,xe.text=we.getText,xe.isXMLDoc=we.isXML,xe.contains=we.contains,xe.escapeSelector=we.escape;var Te=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&xe(e).is(n))break;r.push(e)}return r},Ce=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},ke=xe.expr.match.needsContext,Ee=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,Se=/^.[^:#\[\.,]*$/;xe.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?xe.find.matchesSelector(r,e)?[r]:[]:xe.find.matches(e,xe.grep(t,function(e){return 1===e.nodeType}))},xe.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(xe(e).filter(function(){for(t=0;t<r;t++)if(xe.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)xe.find(e,i[t],n);return r>1?xe.uniqueSort(n):n},filter:function(e){return this.pushStack(c(this,e||[],!1))},not:function(e){return this.pushStack(c(this,e||[],!0))},is:function(e){return!!c(this,"string"==typeof e&&ke.test(e)?xe(e):e||[],!1).length}});var je,Ne=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(xe.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||je,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Ne.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof xe?t[0]:t,xe.merge(this,xe.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:se,!0)),Ee.test(r[1])&&xe.isPlainObject(t))for(r in t)xe.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=se.getElementById(r[2]),i&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):xe.isFunction(e)?void 0!==n.ready?n.ready(e):e(xe):xe.makeArray(e,this)}).prototype=xe.fn,je=xe(se);var De=/^(?:parents|prev(?:Until|All))/,Ae={children:!0,contents:!0,next:!0,prev:!0};xe.fn.extend({has:function(e){var t=xe(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(xe.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&xe(e);if(!ke.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&xe.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?xe.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?de.call(xe(e),this[0]):de.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(xe.uniqueSort(xe.merge(this.get(),xe(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),xe.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return Te(e,"parentNode")},parentsUntil:function(e,t,n){return Te(e,"parentNode",n)},next:function(e){return f(e,"nextSibling")},prev:function(e){return f(e,"previousSibling")},nextAll:function(e){return Te(e,"nextSibling")},prevAll:function(e){return Te(e,"previousSibling")},nextUntil:function(e,t,n){return Te(e,"nextSibling",n)},prevUntil:function(e,t,n){return Te(e,"previousSibling",n)},siblings:function(e){return Ce((e.parentNode||{}).firstChild,e)},children:function(e){return Ce(e.firstChild)},contents:function(e){return l(e,"iframe")?e.contentDocument:(l(e,"template")&&(e=e.content||e),xe.merge([],e.childNodes))}},function(e,t){xe.fn[e]=function(n,r){var i=xe.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=xe.filter(r,i)),this.length>1&&(Ae[e]||xe.uniqueSort(i),De.test(e)&&i.reverse()),this.pushStack(i)}});var qe=/[^\x20\t\r\n\f]+/g;xe.Callbacks=function(e){e="string"==typeof e?d(e):xe.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1)for(n=a.shift();++s<o.length;)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1);e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){xe.each(n,function(n,r){xe.isFunction(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==xe.type(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return xe.each(arguments,function(e,t){for(var n;(n=xe.inArray(t,o,n))>-1;)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?xe.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},xe.extend({Deferred:function(e){var t=[["notify","progress",xe.Callbacks("memory"),xe.Callbacks("memory"),2],["resolve","done",xe.Callbacks("once memory"),xe.Callbacks("once memory"),0,"resolved"],["reject","fail",xe.Callbacks("once memory"),xe.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return xe.Deferred(function(n){xe.each(t,function(t,r){var i=xe.isFunction(e[r[4]])&&e[r[4]];a[r[1]](function(){var e=i&&i.apply(this,arguments);e&&xe.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(e,n,r){function a(e,t,n,r){return function(){var u=this,l=arguments,c=function(){var o,c;if(!(e<s)){if((o=n.apply(u,l))===t.promise())throw new TypeError("Thenable self-resolution");c=o&&("object"===(void 0===o?"undefined":i(o))||"function"==typeof o)&&o.then,xe.isFunction(c)?r?c.call(o,a(s,t,p,r),a(s,t,h,r)):(s++,c.call(o,a(s,t,p,r),a(s,t,h,r),a(s,t,p,t.notifyWith))):(n!==p&&(u=void 0,l=[o]),(r||t.resolveWith)(u,l))}},f=r?c:function(){try{c()}catch(r){xe.Deferred.exceptionHook&&xe.Deferred.exceptionHook(r,f.stackTrace),e+1>=s&&(n!==h&&(u=void 0,l=[r]),t.rejectWith(u,l))}};e?f():(xe.Deferred.getStackHook&&(f.stackTrace=xe.Deferred.getStackHook()),o.setTimeout(f))}}var s=0;return xe.Deferred(function(i){t[0][3].add(a(0,i,xe.isFunction(r)?r:p,i.notifyWith)),t[1][3].add(a(0,i,xe.isFunction(e)?e:p)),t[2][3].add(a(0,i,xe.isFunction(n)?n:h))}).promise()},promise:function(e){return null!=e?xe.extend(e,r):r}},a={};return xe.each(t,function(e,i){var o=i[2],s=i[5];r[i[1]]=o.add,s&&o.add(function(){n=s},t[3-e][2].disable,t[0][2].lock),o.add(i[3].fire),a[i[0]]=function(){return a[i[0]+"With"](this===a?void 0:this,arguments),this},a[i[0]+"With"]=o.fireWith}),r.promise(a),e&&e.call(a,a),a},when:function(e){var t=arguments.length,n=t,r=Array(n),i=le.call(arguments),o=xe.Deferred(),a=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?le.call(arguments):n,--t||o.resolveWith(r,i)}};if(t<=1&&(g(e,o.done(a(n)).resolve,o.reject,!t),"pending"===o.state()||xe.isFunction(i[n]&&i[n].then)))return o.then();for(;n--;)g(i[n],a(n),o.reject);return o.promise()}});var Le=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;xe.Deferred.exceptionHook=function(e,t){o.console&&o.console.warn&&e&&Le.test(e.name)&&o.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},xe.readyException=function(e){o.setTimeout(function(){throw e})};var _e=xe.Deferred();xe.fn.ready=function(e){return _e.then(e).catch(function(e){xe.readyException(e)}),this},xe.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--xe.readyWait:xe.isReady)||(xe.isReady=!0,!0!==e&&--xe.readyWait>0||_e.resolveWith(se,[xe]))}}),xe.ready.then=_e.then,"complete"===se.readyState||"loading"!==se.readyState&&!se.documentElement.doScroll?o.setTimeout(xe.ready):(se.addEventListener("DOMContentLoaded",v),o.addEventListener("load",v));var Oe=function e(t,n,r,i,o,a,s){var u=0,l=t.length,c=null==r;if("object"===xe.type(r)){o=!0;for(u in r)e(t,n,u,r[u],!0,a,s)}else if(void 0!==i&&(o=!0,xe.isFunction(i)||(s=!0),c&&(s?(n.call(t,i),n=null):(c=n,n=function(e,t,n){return c.call(xe(e),n)})),n))for(;u<l;u++)n(t[u],r,s?i:i.call(t[u],u,n(t[u],r)));return o?t:c?n.call(t):l?n(t[0],r):a},He=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};m.uid=1,m.prototype={cache:function(e){var t=e[this.expando];return t||(t={},He(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[xe.camelCase(t)]=n;else for(r in t)i[xe.camelCase(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][xe.camelCase(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){Array.isArray(t)?t=t.map(xe.camelCase):(t=xe.camelCase(t),t=t in r?[t]:t.match(qe)||[]),n=t.length;for(;n--;)delete r[t[n]]}(void 0===t||xe.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!xe.isEmptyObject(t)}};var Fe=new m,Pe=new m,Me=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,Re=/[A-Z]/g;xe.extend({hasData:function(e){return Pe.hasData(e)||Fe.hasData(e)},data:function(e,t,n){return Pe.access(e,t,n)},removeData:function(e,t){Pe.remove(e,t)},_data:function(e,t,n){return Fe.access(e,t,n)},_removeData:function(e,t){Fe.remove(e,t)}}),xe.fn.extend({data:function(e,t){var n,r,o,a=this[0],s=a&&a.attributes;if(void 0===e){if(this.length&&(o=Pe.get(a),1===a.nodeType&&!Fe.get(a,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&(r=s[n].name,0===r.indexOf("data-")&&(r=xe.camelCase(r.slice(5)),x(a,r,o[r])));Fe.set(a,"hasDataAttrs",!0)}return o}return"object"===(void 0===e?"undefined":i(e))?this.each(function(){Pe.set(this,e)}):Oe(this,function(t){var n;if(a&&void 0===t){if(void 0!==(n=Pe.get(a,e)))return n;if(void 0!==(n=x(a,e)))return n}else this.each(function(){Pe.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Pe.remove(this,e)})}}),xe.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Fe.get(e,t),n&&(!r||Array.isArray(n)?r=Fe.access(e,t,xe.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=xe.queue(e,t),r=n.length,i=n.shift(),o=xe._queueHooks(e,t),a=function(){xe.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Fe.get(e,n)||Fe.access(e,n,{empty:xe.Callbacks("once memory").add(function(){Fe.remove(e,[t+"queue",n])})})}}),xe.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?xe.queue(this[0],e):void 0===t?this:this.each(function(){var n=xe.queue(this,e,t);xe._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&xe.dequeue(this,e)})},dequeue:function(e){return this.each(function(){xe.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=xe.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";a--;)(n=Fe.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var Ie=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,We=new RegExp("^(?:([+-])=|)("+Ie+")([a-z%]*)$","i"),$e=["Top","Right","Bottom","Left"],Be=function(e,t){return e=t||e,"none"===e.style.display||""===e.style.display&&xe.contains(e.ownerDocument,e)&&"none"===xe.css(e,"display")},ze=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i},Xe={};xe.fn.extend({show:function(){return T(this,!0)},hide:function(){return T(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Be(this)?xe(this).show():xe(this).hide()})}});var Ue=/^(?:checkbox|radio)$/i,Ve=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,Ge=/^$|\/(?:java|ecma)script/i,Ye={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ye.optgroup=Ye.option,Ye.tbody=Ye.tfoot=Ye.colgroup=Ye.caption=Ye.thead,Ye.th=Ye.td;var Qe=/<|&#?\w+;/;!function(){var e=se.createDocumentFragment(),t=e.appendChild(se.createElement("div")),n=se.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),ye.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",ye.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var Je=se.documentElement,Ke=/^key/,Ze=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,et=/^([^.]*)(?:\.(.+)|)/;xe.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=Fe.get(e);if(v)for(n.handler&&(o=n,n=o.handler,i=o.selector),i&&xe.find.matchesSelector(Je,i),n.guid||(n.guid=xe.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(t){return void 0!==xe&&xe.event.triggered!==t.type?xe.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(qe)||[""],l=t.length;l--;)s=et.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p&&(f=xe.event.special[p]||{},p=(i?f.delegateType:f.bindType)||p,f=xe.event.special[p]||{},c=xe.extend({type:p,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&xe.expr.match.needsContext.test(i),namespace:h.join(".")},o),(d=u[p])||(d=u[p]=[],d.delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(p,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),xe.event.global[p]=!0)},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=Fe.hasData(e)&&Fe.get(e);if(v&&(u=v.events)){for(t=(t||"").match(qe)||[""],l=t.length;l--;)if(s=et.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p){for(f=xe.event.special[p]||{},p=(r?f.delegateType:f.bindType)||p,d=u[p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=d.length;o--;)c=d[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,f.remove&&f.remove.call(e,c));a&&!d.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||xe.removeEvent(e,p,v.handle),delete u[p])}else for(p in u)xe.event.remove(e,p+t[l],n,r,!0);xe.isEmptyObject(u)&&Fe.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=xe.event.fix(e),u=new Array(arguments.length),l=(Fe.get(this,"events")||{})[s.type]||[],c=xe.event.special[s.type]||{};for(u[0]=s,t=1;t<arguments.length;t++)u[t]=arguments[t];if(s.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,s)){for(a=xe.event.handlers.call(this,s,l),t=0;(i=a[t++])&&!s.isPropagationStopped();)for(s.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!s.isImmediatePropagationStopped();)s.rnamespace&&!s.rnamespace.test(o.namespace)||(s.handleObj=o,s.data=o.data,void 0!==(r=((xe.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,u))&&!1===(s.result=r)&&(s.preventDefault(),s.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,s),s.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)r=t[n],i=r.selector+" ",void 0===a[i]&&(a[i]=r.needsContext?xe(i,this).index(l)>-1:xe.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(xe.Event.prototype,e,{enumerable:!0,configurable:!0,get:xe.isFunction(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[xe.expando]?e:new xe.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==N()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===N()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&l(this,"input"))return this.click(),!1},_default:function(e){return l(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},xe.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},xe.Event=function(e,t){if(!(this instanceof xe.Event))return new xe.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?S:j,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&xe.extend(this,t),this.timeStamp=e&&e.timeStamp||xe.now(),this[xe.expando]=!0},xe.Event.prototype={constructor:xe.Event,isDefaultPrevented:j,isPropagationStopped:j,isImmediatePropagationStopped:j,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=S,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=S,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=S,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},xe.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&Ke.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&Ze.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},xe.event.addProp),xe.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){xe.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||xe.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),xe.fn.extend({on:function(e,t,n,r){return D(this,e,t,n,r)},one:function(e,t,n,r){return D(this,e,t,n,r,1)},off:function(e,t,n){var r,o;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,xe(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"===(void 0===e?"undefined":i(e))){for(o in e)this.off(o,t,e[o]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=j),this.each(function(){xe.event.remove(this,e,n,t)})}});var tt=/<script|<style|<link/i,nt=/checked\s*(?:[^=]|=\s*.checked.)/i,rt=/^true\/(.*)/,it=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;xe.extend({htmlPrefilter:function(e){return e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=xe.contains(e.ownerDocument,e);if(!(ye.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||xe.isXMLDoc(e)))for(a=C(s),o=C(e),r=0,i=o.length;r<i;r++)O(o[r],a[r]);if(t)if(n)for(o=o||C(e),a=a||C(s),r=0,i=o.length;r<i;r++)_(o[r],a[r]);else _(e,s);return a=C(s,"script"),a.length>0&&k(a,!u&&C(e,"script")),s},cleanData:function(e){for(var t,n,r,i=xe.event.special,o=0;void 0!==(n=e[o]);o++)if(He(n)){if(t=n[Fe.expando]){if(t.events)for(r in t.events)i[r]?xe.event.remove(n,r):xe.removeEvent(n,r,t.handle);n[Fe.expando]=void 0}n[Pe.expando]&&(n[Pe.expando]=void 0)}}}),xe.fn.extend({detach:function(e){return F(this,e,!0)},remove:function(e){return F(this,e)},text:function(e){return Oe(this,function(e){return void 0===e?xe.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return H(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){A(this,e).appendChild(e)}})},prepend:function(){return H(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=A(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return H(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return H(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(xe.cleanData(C(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return xe.clone(this,e,t)})},html:function(e){return Oe(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!tt.test(e)&&!Ye[(Ve.exec(e)||["",""])[1].toLowerCase()]){e=xe.htmlPrefilter(e);try{for(;n<r;n++)t=this[n]||{},1===t.nodeType&&(xe.cleanData(C(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return H(this,arguments,function(t){var n=this.parentNode;xe.inArray(this,e)<0&&(xe.cleanData(C(this)),n&&n.replaceChild(t,this))},e)}}),xe.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){xe.fn[e]=function(e){for(var n,r=[],i=xe(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),xe(i[a])[t](n),fe.apply(r,n.get());return this.pushStack(r)}});var ot=/^margin/,at=new RegExp("^("+Ie+")(?!px)[a-z%]+$","i"),st=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=o),t.getComputedStyle(e)};!function(){function e(){if(s){s.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",s.innerHTML="",Je.appendChild(a);var e=o.getComputedStyle(s);t="1%"!==e.top,i="2px"===e.marginLeft,n="4px"===e.width,s.style.marginRight="50%",r="4px"===e.marginRight,Je.removeChild(a),s=null}}var t,n,r,i,a=se.createElement("div"),s=se.createElement("div");s.style&&(s.style.backgroundClip="content-box",s.cloneNode(!0).style.backgroundClip="",ye.clearCloneStyle="content-box"===s.style.backgroundClip,a.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",a.appendChild(s),xe.extend(ye,{pixelPosition:function(){return e(),t},boxSizingReliable:function(){return e(),n},pixelMarginRight:function(){return e(),r},reliableMarginLeft:function(){return e(),i}}))}();var ut=/^(none|table(?!-c[ea]).+)/,lt=/^--/,ct={position:"absolute",visibility:"hidden",display:"block"},ft={letterSpacing:"0",fontWeight:"400"},dt=["Webkit","Moz","ms"],pt=se.createElement("div").style;xe.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=P(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=xe.camelCase(t),l=lt.test(t),c=e.style;if(l||(t=I(u)),s=xe.cssHooks[t]||xe.cssHooks[u],void 0===n)return s&&"get"in s&&void 0!==(o=s.get(e,!1,r))?o:c[t];a=void 0===n?"undefined":i(n),"string"===a&&(o=We.exec(n))&&o[1]&&(n=b(e,t,o),a="number"),null!=n&&n===n&&("number"===a&&(n+=o&&o[3]||(xe.cssNumber[u]?"":"px")),ye.clearCloneStyle||""!==n||0!==t.indexOf("background")||(c[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,r))||(l?c.setProperty(t,n):c[t]=n))}},css:function(e,t,n,r){var i,o,a,s=xe.camelCase(t);return lt.test(t)||(t=I(s)),a=xe.cssHooks[t]||xe.cssHooks[s],a&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=P(e,t,r)),"normal"===i&&t in ft&&(i=ft[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),xe.each(["height","width"],function(e,t){xe.cssHooks[t]={get:function(e,n,r){if(n)return!ut.test(xe.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?B(e,t,r):ze(e,ct,function(){return B(e,t,r)})},set:function(e,n,r){var i,o=r&&st(e),a=r&&$(e,t,r,"border-box"===xe.css(e,"boxSizing",!1,o),o);return a&&(i=We.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=xe.css(e,t)),W(e,n,a)}}}),xe.cssHooks.marginLeft=M(ye.reliableMarginLeft,function(e,t){if(t)return(parseFloat(P(e,"marginLeft"))||e.getBoundingClientRect().left-ze(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),xe.each({margin:"",padding:"",border:"Width"},function(e,t){xe.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+$e[r]+t]=o[r]||o[r-2]||o[0];return i}},ot.test(e)||(xe.cssHooks[e+t].set=W)}),xe.fn.extend({css:function(e,t){return Oe(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=st(e),i=t.length;a<i;a++)o[t[a]]=xe.css(e,t[a],!1,r);return o}return void 0!==n?xe.style(e,t,n):xe.css(e,t)},e,t,arguments.length>1)}}),xe.Tween=z,z.prototype={constructor:z,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||xe.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(xe.cssNumber[n]?"":"px")},cur:function(){var e=z.propHooks[this.prop];return e&&e.get?e.get(this):z.propHooks._default.get(this)},run:function(e){var t,n=z.propHooks[this.prop];return this.options.duration?this.pos=t=xe.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):z.propHooks._default.set(this),this}},z.prototype.init.prototype=z.prototype,z.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=xe.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){xe.fx.step[e.prop]?xe.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[xe.cssProps[e.prop]]&&!xe.cssHooks[e.prop]?e.elem[e.prop]=e.now:xe.style(e.elem,e.prop,e.now+e.unit)}}},z.propHooks.scrollTop=z.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},xe.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},xe.fx=z.prototype.init,xe.fx.step={};var ht,gt,vt=/^(?:toggle|show|hide)$/,mt=/queueHooks$/;xe.Animation=xe.extend(J,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return b(n.elem,e,We.exec(t),n),n}]},tweener:function(e,t){xe.isFunction(e)?(t=e,e=["*"]):e=e.match(qe);for(var n,r=0,i=e.length;r<i;r++)n=e[r],J.tweeners[n]=J.tweeners[n]||[],J.tweeners[n].unshift(t)},prefilters:[Y],prefilter:function(e,t){t?J.prefilters.unshift(e):J.prefilters.push(e)}}),xe.speed=function(e,t,n){var r=e&&"object"===(void 0===e?"undefined":i(e))?xe.extend({},e):{complete:n||!n&&t||xe.isFunction(e)&&e,duration:e,easing:n&&t||t&&!xe.isFunction(t)&&t};return xe.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in xe.fx.speeds?r.duration=xe.fx.speeds[r.duration]:r.duration=xe.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){xe.isFunction(r.old)&&r.old.call(this),r.queue&&xe.dequeue(this,r.queue)},r},xe.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Be).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=xe.isEmptyObject(e),o=xe.speed(t,n,r),a=function(){var t=J(this,xe.extend({},e),o);(i||Fe.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=xe.timers,a=Fe.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&mt.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||xe.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=Fe.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=xe.timers,a=r?r.length:0;for(n.finish=!0,xe.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),xe.each(["toggle","show","hide"],function(e,t){var n=xe.fn[t];xe.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(V(t,!0),e,r,i)}}),xe.each({slideDown:V("show"),slideUp:V("hide"),slideToggle:V("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){xe.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),xe.timers=[],xe.fx.tick=function(){var e,t=0,n=xe.timers;for(ht=xe.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||xe.fx.stop(),ht=void 0},xe.fx.timer=function(e){xe.timers.push(e),xe.fx.start()},xe.fx.interval=13,xe.fx.start=function(){gt||(gt=!0,X())},xe.fx.stop=function(){gt=null},xe.fx.speeds={slow:600,fast:200,_default:400},xe.fn.delay=function(e,t){return e=xe.fx?xe.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=o.setTimeout(t,e);n.stop=function(){o.clearTimeout(r)}})},function(){var e=se.createElement("input"),t=se.createElement("select"),n=t.appendChild(se.createElement("option"));e.type="checkbox",ye.checkOn=""!==e.value,ye.optSelected=n.selected,e=se.createElement("input"),e.value="t",e.type="radio",ye.radioValue="t"===e.value}();var yt,xt=xe.expr.attrHandle;xe.fn.extend({attr:function(e,t){return Oe(this,xe.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){xe.removeAttr(this,e)})}}),xe.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?xe.prop(e,t,n):(1===o&&xe.isXMLDoc(e)||(i=xe.attrHooks[t.toLowerCase()]||(xe.expr.match.bool.test(t)?yt:void 0)),void 0!==n?null===n?void xe.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=xe.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!ye.radioValue&&"radio"===t&&l(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(qe);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),yt={set:function(e,t,n){return!1===t?xe.removeAttr(e,n):e.setAttribute(n,n),n}},xe.each(xe.expr.match.bool.source.match(/\w+/g),function(e,t){var n=xt[t]||xe.find.attr;xt[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=xt[a],xt[a]=i,i=null!=n(e,t,r)?a:null,xt[a]=o),i}});var bt=/^(?:input|select|textarea|button)$/i,wt=/^(?:a|area)$/i;xe.fn.extend({prop:function(e,t){return Oe(this,xe.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[xe.propFix[e]||e]})}}),xe.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&xe.isXMLDoc(e)||(t=xe.propFix[t]||t,i=xe.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=xe.find.attr(e,"tabindex");return t?parseInt(t,10):bt.test(e.nodeName)||wt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),ye.optSelected||(xe.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),xe.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){xe.propFix[this.toLowerCase()]=this}),xe.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(xe.isFunction(e))return this.each(function(t){xe(this).addClass(e.call(this,t,Z(this)))});if("string"==typeof e&&e)for(t=e.match(qe)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(xe.isFunction(e))return this.each(function(t){xe(this).removeClass(e.call(this,t,Z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(qe)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=void 0===e?"undefined":i(e);return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):xe.isFunction(e)?this.each(function(n){xe(this).toggleClass(e.call(this,n,Z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=xe(this),o=e.match(qe)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=Z(this),t&&Fe.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":Fe.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+K(Z(n))+" ").indexOf(t)>-1)return!0;return!1}});xe.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=xe.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,xe(this).val()):e,null==i?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=xe.map(i,function(e){return null==e?"":e+""})),(t=xe.valHooks[this.type]||xe.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=xe.valHooks[i.type]||xe.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(/\r/g,""):null==n?"":n)}}}),xe.extend({valHooks:{option:{get:function(e){var t=xe.find.attr(e,"value");return null!=t?t:K(xe.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(n=i[r],(n.selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!l(n.parentNode,"optgroup"))){if(t=xe(n).val(),a)return t;s.push(t)}return s},set:function(e,t){for(var n,r,i=e.options,o=xe.makeArray(t),a=i.length;a--;)r=i[a],(r.selected=xe.inArray(xe.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),xe.each(["radio","checkbox"],function(){xe.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=xe.inArray(xe(e).val(),t)>-1}},ye.checkOn||(xe.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Tt=/^(?:focusinfocus|focusoutblur)$/;xe.extend(xe.event,{trigger:function(e,t,n,r){var a,s,u,l,c,f,d,p=[n||se],h=ge.call(e,"type")?e.type:e,g=ge.call(e,"namespace")?e.namespace.split("."):[];if(s=u=n=n||se,3!==n.nodeType&&8!==n.nodeType&&!Tt.test(h+xe.event.triggered)&&(h.indexOf(".")>-1&&(g=h.split("."),h=g.shift(),g.sort()),c=h.indexOf(":")<0&&"on"+h,e=e[xe.expando]?e:new xe.Event(h,"object"===(void 0===e?"undefined":i(e))&&e),e.isTrigger=r?2:3,e.namespace=g.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:xe.makeArray(t,[e]),d=xe.event.special[h]||{},r||!d.trigger||!1!==d.trigger.apply(n,t))){if(!r&&!d.noBubble&&!xe.isWindow(n)){for(l=d.delegateType||h,Tt.test(l+h)||(s=s.parentNode);s;s=s.parentNode)p.push(s),u=s;u===(n.ownerDocument||se)&&p.push(u.defaultView||u.parentWindow||o)}for(a=0;(s=p[a++])&&!e.isPropagationStopped();)e.type=a>1?l:d.bindType||h,f=(Fe.get(s,"events")||{})[e.type]&&Fe.get(s,"handle"),f&&f.apply(s,t),(f=c&&s[c])&&f.apply&&He(s)&&(e.result=f.apply(s,t),!1===e.result&&e.preventDefault());return e.type=h,r||e.isDefaultPrevented()||d._default&&!1!==d._default.apply(p.pop(),t)||!He(n)||c&&xe.isFunction(n[h])&&!xe.isWindow(n)&&(u=n[c],u&&(n[c]=null),xe.event.triggered=h,n[h](),xe.event.triggered=void 0,u&&(n[c]=u)),e.result}},simulate:function(e,t,n){var r=xe.extend(new xe.Event,n,{type:e,isSimulated:!0});xe.event.trigger(r,null,t)}}),xe.fn.extend({trigger:function(e,t){return this.each(function(){xe.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return xe.event.trigger(e,t,n,!0)}}),xe.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){xe.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),xe.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),ye.focusin="onfocusin"in o,ye.focusin||xe.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){xe.event.simulate(t,e.target,xe.event.fix(e))};xe.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=Fe.access(r,t);i||r.addEventListener(e,n,!0),Fe.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=Fe.access(r,t)-1;i?Fe.access(r,t,i):(r.removeEventListener(e,n,!0),Fe.remove(r,t))}}});var Ct=o.location,kt=xe.now(),Et=/\?/;xe.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new o.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||xe.error("Invalid XML: "+e),t};var St=/\[\]$/,jt=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;xe.param=function(e,t){var n,r=[],i=function(e,t){var n=xe.isFunction(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!xe.isPlainObject(e))xe.each(e,function(){i(this.name,this.value)});else for(n in e)ee(n,e[n],t,i);return r.join("&")},xe.fn.extend({serialize:function(){return xe.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=xe.prop(this,"elements");return e?xe.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!xe(this).is(":disabled")&&Nt.test(this.nodeName)&&!jt.test(e)&&(this.checked||!Ue.test(e))}).map(function(e,t){var n=xe(this).val();return null==n?null:Array.isArray(n)?xe.map(n,function(e){return{name:t.name,value:e.replace(/\r?\n/g,"\r\n")}}):{name:t.name,value:n.replace(/\r?\n/g,"\r\n")}}).get()}});var Dt=/^(.*?):[ \t]*([^\r\n]*)$/gm,At=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,qt=/^(?:GET|HEAD)$/,Lt={},_t={},Ot="*/".concat("*"),Ht=se.createElement("a");Ht.href=Ct.href,xe.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:At.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ot,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":xe.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?re(re(e,xe.ajaxSettings),t):re(xe.ajaxSettings,e)},ajaxPrefilter:te(Lt),ajaxTransport:te(_t),ajax:function(e,t){function n(e,t,n,i){var u,c,p,h,w,T=t;f||(f=!0,l&&o.clearTimeout(l),r=void 0,s=i||"",k.readyState=e>0?4:0,u=e>=200&&e<300||304===e,n&&(h=ie(g,k,n)),h=oe(g,h,k,u),u?(g.ifModified&&(w=k.getResponseHeader("Last-Modified"),w&&(xe.lastModified[a]=w),(w=k.getResponseHeader("etag"))&&(xe.etag[a]=w)),204===e||"HEAD"===g.type?T="nocontent":304===e?T="notmodified":(T=h.state,c=h.data,p=h.error,u=!p)):(p=T,!e&&T||(T="error",e<0&&(e=0))),k.status=e,k.statusText=(t||T)+"",u?y.resolveWith(v,[c,T,k]):y.rejectWith(v,[k,T,p]),k.statusCode(b),b=void 0,d&&m.trigger(u?"ajaxSuccess":"ajaxError",[k,g,u?c:p]),x.fireWith(v,[k,T]),d&&(m.trigger("ajaxComplete",[k,g]),--xe.active||xe.event.trigger("ajaxStop")))}"object"===(void 0===e?"undefined":i(e))&&(t=e,e=void 0),t=t||{};var r,a,s,u,l,c,f,d,p,h,g=xe.ajaxSetup({},t),v=g.context||g,m=g.context&&(v.nodeType||v.jquery)?xe(v):xe.event,y=xe.Deferred(),x=xe.Callbacks("once memory"),b=g.statusCode||{},w={},T={},C="canceled",k={readyState:0,getResponseHeader:function(e){var t;if(f){if(!u)for(u={};t=Dt.exec(s);)u[t[1].toLowerCase()]=t[2];t=u[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return f?s:null},setRequestHeader:function(e,t){return null==f&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,w[e]=t),this},overrideMimeType:function(e){return null==f&&(g.mimeType=e),this},statusCode:function(e){var t;if(e)if(f)k.always(e[k.status]);else for(t in e)b[t]=[b[t],e[t]];return this},abort:function(e){var t=e||C;return r&&r.abort(t),n(0,t),this}};if(y.promise(k),g.url=((e||g.url||Ct.href)+"").replace(/^\/\//,Ct.protocol+"//"),g.type=t.method||t.type||g.method||g.type,g.dataTypes=(g.dataType||"*").toLowerCase().match(qe)||[""],null==g.crossDomain){c=se.createElement("a");try{c.href=g.url,c.href=c.href,g.crossDomain=Ht.protocol+"//"+Ht.host!=c.protocol+"//"+c.host}catch(e){g.crossDomain=!0}}if(g.data&&g.processData&&"string"!=typeof g.data&&(g.data=xe.param(g.data,g.traditional)),ne(Lt,g,t,k),f)return k;d=xe.event&&g.global,d&&0==xe.active++&&xe.event.trigger("ajaxStart"),g.type=g.type.toUpperCase(),g.hasContent=!qt.test(g.type),a=g.url.replace(/#.*$/,""),g.hasContent?g.data&&g.processData&&0===(g.contentType||"").indexOf("application/x-www-form-urlencoded")&&(g.data=g.data.replace(/%20/g,"+")):(h=g.url.slice(a.length),g.data&&(a+=(Et.test(a)?"&":"?")+g.data,delete g.data),!1===g.cache&&(a=a.replace(/([?&])_=[^&]*/,"$1"),h=(Et.test(a)?"&":"?")+"_="+kt+++h),g.url=a+h),g.ifModified&&(xe.lastModified[a]&&k.setRequestHeader("If-Modified-Since",xe.lastModified[a]),xe.etag[a]&&k.setRequestHeader("If-None-Match",xe.etag[a])),(g.data&&g.hasContent&&!1!==g.contentType||t.contentType)&&k.setRequestHeader("Content-Type",g.contentType),k.setRequestHeader("Accept",g.dataTypes[0]&&g.accepts[g.dataTypes[0]]?g.accepts[g.dataTypes[0]]+("*"!==g.dataTypes[0]?", "+Ot+"; q=0.01":""):g.accepts["*"]);for(p in g.headers)k.setRequestHeader(p,g.headers[p]);if(g.beforeSend&&(!1===g.beforeSend.call(v,k,g)||f))return k.abort();if(C="abort",x.add(g.complete),k.done(g.success),k.fail(g.error),r=ne(_t,g,t,k)){if(k.readyState=1,d&&m.trigger("ajaxSend",[k,g]),f)return k;g.async&&g.timeout>0&&(l=o.setTimeout(function(){k.abort("timeout")},g.timeout));try{f=!1,r.send(w,n)}catch(e){if(f)throw e;n(-1,e)}}else n(-1,"No Transport");return k},getJSON:function(e,t,n){return xe.get(e,t,n,"json")},getScript:function(e,t){return xe.get(e,void 0,t,"script")}}),xe.each(["get","post"],function(e,t){xe[t]=function(e,n,r,i){return xe.isFunction(n)&&(i=i||r,r=n,n=void 0),xe.ajax(xe.extend({url:e,type:t,dataType:i,data:n,success:r},xe.isPlainObject(e)&&e))}}),xe._evalUrl=function(e){return xe.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},xe.fn.extend({wrapAll:function(e){var t;return this[0]&&(xe.isFunction(e)&&(e=e.call(this[0])),t=xe(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return xe.isFunction(e)?this.each(function(t){xe(this).wrapInner(e.call(this,t))}):this.each(function(){var t=xe(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=xe.isFunction(e);return this.each(function(n){xe(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){xe(this).replaceWith(this.childNodes)}),this}}),xe.expr.pseudos.hidden=function(e){return!xe.expr.pseudos.visible(e)},xe.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},xe.ajaxSettings.xhr=function(){try{return new o.XMLHttpRequest}catch(e){}};var Ft={0:200,1223:204},Pt=xe.ajaxSettings.xhr();ye.cors=!!Pt&&"withCredentials"in Pt,ye.ajax=Pt=!!Pt,xe.ajaxTransport(function(e){var t,n;if(ye.cors||Pt&&!e.crossDomain)return{send:function(r,i){var a,s=e.xhr();if(s.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(a in e.xhrFields)s[a]=e.xhrFields[a];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),e.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(a in r)s.setRequestHeader(a,r[a]);t=function(e){return function(){t&&(t=n=s.onload=s.onerror=s.onabort=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?i(0,"error"):i(s.status,s.statusText):i(Ft[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=t(),n=s.onerror=t("error"),void 0!==s.onabort?s.onabort=n:s.onreadystatechange=function(){4===s.readyState&&o.setTimeout(function(){t&&n()})},t=t("abort");try{s.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),xe.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),xe.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return xe.globalEval(e),e}}}),xe.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),xe.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=xe("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),se.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Mt=[],Rt=/(=)\?(?=&|$)|\?\?/;xe.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mt.pop()||xe.expando+"_"+kt++;return this[e]=!0,e}}),xe.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,a,s=!1!==e.jsonp&&(Rt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Rt.test(e.data)&&"data");if(s||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=xe.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,s?e[s]=e[s].replace(Rt,"$1"+r):!1!==e.jsonp&&(e.url+=(Et.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return a||xe.error(r+" was not called"),a[0]},e.dataTypes[0]="json",i=o[r],o[r]=function(){a=arguments},n.always(function(){void 0===i?xe(o).removeProp(r):o[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Mt.push(r)),a&&xe.isFunction(i)&&i(a[0]),a=i=void 0}),"script"}),ye.createHTMLDocument=function(){var e=se.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),xe.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var r,i,o;return t||(ye.createHTMLDocument?(t=se.implementation.createHTMLDocument(""),r=t.createElement("base"),r.href=se.location.href,t.head.appendChild(r)):t=se),i=Ee.exec(e),o=!n&&[],i?[t.createElement(i[1])]:(i=E([e],t,o),o&&o.length&&xe(o).remove(),xe.merge([],i.childNodes))},xe.fn.load=function(e,t,n){var r,o,a,s=this,u=e.indexOf(" ");return u>-1&&(r=K(e.slice(u)),e=e.slice(0,u)),xe.isFunction(t)?(n=t,t=void 0):t&&"object"===(void 0===t?"undefined":i(t))&&(o="POST"),s.length>0&&xe.ajax({url:e,type:o||"GET",dataType:"html",data:t}).done(function(e){a=arguments,s.html(r?xe("<div>").append(xe.parseHTML(e)).find(r):e)}).always(n&&function(e,t){s.each(function(){n.apply(this,a||[e.responseText,t,e])})}),this},xe.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){xe.fn[t]=function(e){return this.on(t,e)}}),xe.expr.pseudos.animated=function(e){return xe.grep(xe.timers,function(t){return e===t.elem}).length},xe.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=xe.css(e,"position"),f=xe(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=xe.css(e,"top"),u=xe.css(e,"left"),l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),xe.isFunction(t)&&(t=t.call(e,n,xe.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},xe.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){xe.offset.setOffset(this,e,t)});var t,n,r,i,o=this[0];if(o)return o.getClientRects().length?(r=o.getBoundingClientRect(),t=o.ownerDocument,n=t.documentElement,i=t.defaultView,{top:r.top+i.pageYOffset-n.clientTop,left:r.left+i.pageXOffset-n.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n=this[0],r={top:0,left:0};return"fixed"===xe.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),l(e[0],"html")||(r=e.offset()),r={top:r.top+xe.css(e[0],"borderTopWidth",!0),left:r.left+xe.css(e[0],"borderLeftWidth",!0)}),{top:t.top-r.top-xe.css(n,"marginTop",!0),left:t.left-r.left-xe.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===xe.css(e,"position");)e=e.offsetParent;return e||Je})}}),xe.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;xe.fn[e]=function(r){return Oe(this,function(e,r,i){var o;if(xe.isWindow(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),xe.each(["top","left"],function(e,t){xe.cssHooks[t]=M(ye.pixelPosition,function(e,n){if(n)return n=P(e,t),at.test(n)?xe(e).position()[t]+"px":n})}),xe.each({Height:"height",Width:"width"},function(e,t){xe.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){xe.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return Oe(this,function(t,n,i){var o;return xe.isWindow(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?xe.css(t,n,s):xe.style(t,n,i,s)},t,a?i:void 0,a)}})}),xe.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),xe.holdReady=function(e){e?xe.readyWait++:xe.ready(!0)},xe.isArray=Array.isArray,xe.parseJSON=JSON.parse,xe.nodeName=l,n=[],void 0!==(r=function(){return xe}.apply(t,n))&&(e.exports=r);var It=o.jQuery,Wt=o.$;return xe.noConflict=function(e){return o.$===xe&&(o.$=Wt),e&&o.jQuery===xe&&(o.jQuery=It),xe},a||(o.jQuery=o.$=xe),xe})}).call(t,n(5)(e))},function(e,t,n){"use strict";function r(){var e=(0,o.default)("#ta-attach-images-metabox");e.on("click","#ta_upload_media_manager",function(t){if(t.preventDefault(),n)return void n.open();var n=wp.media({title:(0,o.default)(this).data("uploader-title"),library:{type:"image"},button:{text:(0,o.default)(this).data("uploader-button-text"),close:!0},multiple:!0});n.on("select",function(){var t=n.state().get("selection"),r=(0,o.default)("input[name=post_ID]").val(),i=[],a=(0,o.default)("#thirsty_image_holder");e.find("#thirsty_image_holder").length<=0&&e.find(".inside").append("<div id='thirsty_image_holder'></div>"),t.map(function(e){e=e.toJSON(),i.push(e.id)}),i.length>0&&o.default.ajax({url:ajaxurl,type:"POST",data:{action:"ta_add_attachments_to_affiliate_link",attachment_ids:i,affiliate_link_id:r},dataType:"json"}).done(function(t){"success"===t.status?e.find("#thirsty_image_holder").append(t.added_attachments_markup):(alert(t.error_msg),console.log(t))}).fail(function(e){alert(e),console.log("Failed to add attachments to affiliate link")}).always(function(){a.find(".thirsty-attached-image").length>0&&a.show(),tb_remove()})}),n.open()}),e.on("click",".thirsty-remove-img",function(){var e=(0,o.default)(this);if(e.hasClass("removing"))return!1;e.addClass("removing");var t=e.attr("id"),n=(0,o.default)("input[name=post_ID]").val(),r=e.closest(".thirsty-attached-image"),i=(0,o.default)("#thirsty_image_holder");o.default.ajax({url:ajaxurl,type:"POST",data:{action:"ta_remove_attachment_to_affiliate_link",attachment_id:t,affiliate_link_id:n},dataType:"json"}).done(function(e){"success"===e.status?(r.fadeOut(300).delay(300).remove(),i.find(".thirsty-attached-image").length<=0&&i.hide()):(alert(e.error_msg),console.log(e))}).fail(function(e){alert("Failed to remove attachment from affiliate link"),console.log(e)})})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(i)},function(e,t,n){"use strict";function r(){var e=(0,o.default)("#ta-urls-metabox");e.on("click","button.edit-ta-slug",function(){e.find(".cloaked-fields").hide(),e.find(".slug-fields").fadeIn(200)}),e.on("click","button.save-ta-slug",function(){var t=e.find("input#ta_slug").val(),n=e.find("input#ta_cloaked_url").val(),r=n.replace(/[^\/]+\/?$/g,"");t=""==t?n.match(/[^\/]+$/):t,e.find("input#ta_cloaked_url").val(r+t),e.find(".slug-fields").hide(),e.find(".cloaked-fields").fadeIn(200)})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(i)},function(e,t,n){"use strict";function r(){function e(e,t){o.default.post(ajaxurl,{action:"ta_get_category_slug",term_id:e},function(n){"success"==n.status?r.append("<option value='"+e+"' data-slug='"+n.category_slug+"'>"+t+"</option>").trigger("change"):(alert(n.error_msg),console.log(n))},"json")}function t(){var e=n.find("input[type='checkbox']:checked"),t=[],i=[],a=void 0,s=void 0,u=void 0,l=void 0;if(!(e.length<1)){for(l=0;l<e.length;l++)u=(0,o.default)(e[l]).parent().text().trim(),t.push(u),i[u]=l;t=t.sort(function(e,t){return e=e.toLowerCase(),t=t.toLowerCase(),e>t?1:e<t?-1:0}),s=i[t[0]],a=(0,o.default)(e[s]),o.default.post(ajaxurl,{action:"ta_get_category_slug",term_id:a.val()},function(e){"success"==e.status?(r.find("option:first-child").data("slug",e.category_slug).attr("data-slug",e.category_slug),r.trigger("change")):(alert(e.error_msg),console.log(e))},"json")}}var n=(0,o.default)("#thirstylink-categorychecklist"),r=(0,o.default)("select[name='ta_category_slug']");n.on("change","input[type='checkbox']",function(){var n=(0,o.default)(this).val(),i=(0,o.default)(this).parent().text(),a=(0,o.default)(this).prop("checked");t(),a?e(n,i):(r.find("option[value='"+n+"']").remove(),r.trigger("change"))}),(0,o.default)(document).on("DOMNodeInserted","#thirstylink-categorychecklist",function(){var n=(0,o.default)("#thirstylink-categorychecklist li").first(),i=n.find("input[type='checkbox']").val(),a=n.find("label").text(),s=n.find("input[type='checkbox']").prop("checked");t(),s?e(i,a):r.find("option[value='"+i+"']").remove()}),(0,o.default)(document).on("change","select[name='ta_category_slug']",function(){var e=(0,o.default)(this),t=e.find("option:selected").data("slug"),n=e.data("home-link-prefix"),r=(0,o.default)("#ta_slug").val(),i=(0,o.default)("#ta_cloaked_url");(0,o.default)(this).find("option").length<=1?i.val(n+r+"/"):i.val(n+t+"/"+r+"/")})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var i=n(0),o=function(e){return e&&e.__esModule?e:{default:e}}(i)},function(e,t){},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i=n(0),o=r(i),a=n(1),s=r(a),u=n(2),l=r(u),c=n(3),f=r(c);n(4),(0,o.default)(document).ready(function(){(0,s.default)(),(0,l.default)(),(0,f.default)()})}]);
js/app/import_export/dist/import-export.css ADDED
@@ -0,0 +1 @@
 
1
+ @keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-webkit-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-moz-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-ms-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-o-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-webkit-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-moz-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-ms-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-o-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-webkit-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-moz-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-ms-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-o-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}.vex,.vex *,.vex :after,.vex :before{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.vex{position:fixed;overflow:auto;-webkit-overflow-scrolling:touch;z-index:1111;top:0;right:0;bottom:0;left:0}.vex-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.vex-overlay{background:#000;filter:alpha(opacity=40);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";animation:vex-fadein .5s;-webkit-animation:vex-fadein .5s;-moz-animation:vex-fadein .5s;-ms-animation:vex-fadein .5s;-o-animation:vex-fadein .5s;-webkit-backface-visibility:hidden;position:fixed;background:rgba(0,0,0,.4);top:0;right:0;bottom:0;left:0}.vex.vex-closing .vex-overlay{animation:vex-fadeout .5s;-webkit-animation:vex-fadeout .5s;-moz-animation:vex-fadeout .5s;-ms-animation:vex-fadeout .5s;-o-animation:vex-fadeout .5s;-webkit-backface-visibility:hidden}.vex-content{animation:vex-fadein .5s;-webkit-animation:vex-fadein .5s;-moz-animation:vex-fadein .5s;-ms-animation:vex-fadein .5s;-o-animation:vex-fadein .5s;-webkit-backface-visibility:hidden;background:#fff}.vex.vex-closing .vex-content{animation:vex-fadeout .5s;-webkit-animation:vex-fadeout .5s;-moz-animation:vex-fadeout .5s;-ms-animation:vex-fadeout .5s;-o-animation:vex-fadeout .5s;-webkit-backface-visibility:hidden}.vex-close:before{font-family:Arial,sans-serif;content:"\D7"}.vex-dialog-form{margin:0}.vex-dialog-button{text-rendering:optimizeLegibility;-moz-appearance:none;-webkit-appearance:none;cursor:pointer;-webkit-tap-highlight-color:transparent}.vex-loading-spinner{animation:vex-rotation .7s linear infinite;-webkit-animation:vex-rotation .7s linear infinite;-moz-animation:vex-rotation .7s linear infinite;-ms-animation:vex-rotation .7s linear infinite;-o-animation:vex-rotation .7s linear infinite;-webkit-backface-visibility:hidden;-moz-box-shadow:0 0 1em rgba(0,0,0,.1);-webkit-box-shadow:0 0 1em rgba(0,0,0,.1);box-shadow:0 0 1em rgba(0,0,0,.1);position:fixed;z-index:1112;margin:auto;top:0;right:0;bottom:0;left:0;height:2em;width:2em;background:#fff}body.vex-open{overflow:hidden}@keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-webkit-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-moz-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-ms-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-o-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}.vex.vex-theme-plain{padding-top:160px;padding-bottom:160px}.vex.vex-theme-plain .vex-content{font-family:Helvetica Neue,sans-serif;background:#fff;color:#444;padding:1em;position:relative;margin:0 auto;max-width:100%;width:450px;font-size:1.1em;line-height:1.5em}.vex.vex-theme-plain .vex-content h1,.vex.vex-theme-plain .vex-content h2,.vex.vex-theme-plain .vex-content h3,.vex.vex-theme-plain .vex-content h4,.vex.vex-theme-plain .vex-content h5,.vex.vex-theme-plain .vex-content h6,.vex.vex-theme-plain .vex-content li,.vex.vex-theme-plain .vex-content p,.vex.vex-theme-plain .vex-content ul{color:inherit}.vex.vex-theme-plain .vex-close{position:absolute;top:0;right:0;cursor:pointer}.vex.vex-theme-plain .vex-close:before{position:absolute;content:"\D7";font-size:26px;font-weight:400;line-height:31px;height:30px;width:30px;text-align:center;top:3px;right:3px;color:#bbb;background:transparent}.vex.vex-theme-plain .vex-close:active:before,.vex.vex-theme-plain .vex-close:hover:before{color:#777;background:#e0e0e0}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-message{margin-bottom:.5em}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input{margin-bottom:1em}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=date],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime-local],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=email],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=month],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=number],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=password],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=search],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=tel],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=text],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=time],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=url],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=week],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input select,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input textarea{background:#f0f0f0;width:100%;padding:.25em .67em;border:0;font-family:inherit;font-weight:inherit;font-size:inherit;min-height:2.5em;margin:0 0 .25em}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=date]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime-local]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=email]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=month]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=number]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=password]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=search]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=tel]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=text]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=time]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=url]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=week]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input select:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input textarea:focus{-moz-box-shadow:inset 0 0 0 2px rgba(0,0,0,.2);-webkit-box-shadow:inset 0 0 0 2px rgba(0,0,0,.2);box-shadow:inset 0 0 0 2px rgba(0,0,0,.2);outline:none}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-buttons{*zoom:1}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-buttons:after{content:"";display:table;clear:both}.vex.vex-theme-plain .vex-dialog-button{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border:0;float:right;margin:0 0 0 .5em;font-family:inherit;text-transform:uppercase;letter-spacing:.1em;font-size:.8em;line-height:1em;padding:.75em 2em}.vex.vex-theme-plain .vex-dialog-button.vex-last{margin-left:0}.vex.vex-theme-plain .vex-dialog-button:focus{animation:vex-pulse 1.1s infinite;-webkit-animation:vex-pulse 1.1s infinite;-moz-animation:vex-pulse 1.1s infinite;-ms-animation:vex-pulse 1.1s infinite;-o-animation:vex-pulse 1.1s infinite;-webkit-backface-visibility:hidden;outline:none}@media (max-width:568px){.vex.vex-theme-plain .vex-dialog-button:focus{animation:none;-webkit-animation:none;-moz-animation:none;-ms-animation:none;-o-animation:none;-webkit-backface-visibility:hidden}}.vex.vex-theme-plain .vex-dialog-button.vex-dialog-button-primary{background:#3288e6;color:#fff}.vex.vex-theme-plain .vex-dialog-button.vex-dialog-button-secondary{background:#e0e0e0;color:#777}.vex-loading-spinner.vex-theme-plain{height:2.5em;width:2.5em}.forminp-import_global_settings #ta_import_settings{width:530px}.forminp-import_global_settings .controls{text-align:right;width:530px;padding-top:6px}.forminp-import_global_settings .controls .spinner{display:inline-block;float:none;visibility:hidden}.forminp-export_global_settings #ta_export_settings{width:530px}.forminp-export_global_settings .controls{text-align:right;width:530px;padding-top:6px}.forminp-export_global_settings .controls #copy-settings-string{outline:none;cursor:pointer}
js/app/import_export/dist/import-export.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=15)}([function(e,t,n){"use strict";(function(e){var n,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!
2
+ * jQuery JavaScript Library v3.2.1
3
+ * https://jquery.com/
4
+ *
5
+ * Includes Sizzle.js
6
+ * https://sizzlejs.com/
7
+ *
8
+ * Copyright JS Foundation and other contributors
9
+ * Released under the MIT license
10
+ * https://jquery.org/license
11
+ *
12
+ * Date: 2017-03-20T18:59Z
13
+ */
14
+ !function(t,n){"object"===i(e)&&"object"===i(e.exports)?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:void 0,function(o,a){function s(e,t){t=t||se;var n=t.createElement("script");n.text=e,t.head.appendChild(n).parentNode.removeChild(n)}function u(e){var t=!!e&&"length"in e&&e.length,n=be.type(e);return"function"!==n&&!be.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function l(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function c(e,t,n){return be.isFunction(t)?be.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?be.grep(e,function(e){return e===t!==n}):"string"!=typeof t?be.grep(e,function(e){return de.call(t,e)>-1!==n}):Ae.test(t)?be.filter(t,e,n):(t=be.filter(t,e),be.grep(e,function(e){return de.call(t,e)>-1!==n&&1===e.nodeType}))}function f(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function d(e){var t={};return be.each(e.match(_e)||[],function(e,n){t[n]=!0}),t}function p(e){return e}function h(e){throw e}function v(e,t,n,r){var i;try{e&&be.isFunction(i=e.promise)?i.call(e).done(t).fail(n):e&&be.isFunction(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}function g(){se.removeEventListener("DOMContentLoaded",g),o.removeEventListener("load",g),be.ready()}function m(){this.expando=be.expando+m.uid++}function y(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:We.test(e)?JSON.parse(e):e)}function b(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace($e,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=y(n)}catch(e){}Ie.set(e,t,n)}else n=void 0;return n}function x(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return be.css(e,t,"")},u=s(),l=n&&n[3]||(be.cssNumber[t]?"":"px"),c=(be.cssNumber[t]||"px"!==l&&+u)&&ze.exec(be.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do{o=o||".5",c/=o,be.style(e,t,c+l)}while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function w(e){var t,n=e.ownerDocument,r=e.nodeName,i=Ye[r];return i||(t=n.body.appendChild(n.createElement(r)),i=be.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),Ye[r]=i,i)}function C(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)r=e[o],r.style&&(n=r.style.display,t?("none"===n&&(i[o]=Re.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&Xe(r)&&(i[o]=w(r))):"none"!==n&&(i[o]="none",Re.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}function T(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&l(e,t)?be.merge([e],n):n}function E(e,t){for(var n=0,r=e.length;n<r;n++)Re.set(e[n],"globalEval",!t||Re.get(t[n],"globalEval"))}function k(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),d=[],p=0,h=e.length;p<h;p++)if((o=e[p])||0===o)if("object"===be.type(o))be.merge(d,o.nodeType?[o]:o);else if(Ze.test(o)){for(a=a||f.appendChild(t.createElement("div")),s=(Qe.exec(o)||["",""])[1].toLowerCase(),u=Ke[s]||Ke._default,a.innerHTML=u[1]+be.htmlPrefilter(o)+u[2],c=u[0];c--;)a=a.lastChild;be.merge(d,a.childNodes),a=f.firstChild,a.textContent=""}else d.push(t.createTextNode(o));for(f.textContent="",p=0;o=d[p++];)if(r&&be.inArray(o,r)>-1)i&&i.push(o);else if(l=be.contains(o.ownerDocument,o),a=T(f.appendChild(o),"script"),l&&E(a),n)for(c=0;o=a[c++];)Je.test(o.type||"")&&n.push(o);return f}function S(){return!0}function N(){return!1}function j(){try{return se.activeElement}catch(e){}}function A(e,t,n,r,o,a){var s,u;if("object"===(void 0===t?"undefined":i(t))){"string"!=typeof n&&(r=r||n,n=void 0);for(u in t)A(e,u,n,r,t[u],a);return e}if(null==r&&null==o?(o=n,r=n=void 0):null==o&&("string"==typeof n?(o=r,r=void 0):(o=r,r=n,n=void 0)),!1===o)o=N;else if(!o)return e;return 1===a&&(s=o,o=function(e){return be().off(e),s.apply(this,arguments)},o.guid=s.guid||(s.guid=be.guid++)),e.each(function(){be.event.add(this,t,o,r,n)})}function L(e,t){return l(e,"table")&&l(11!==t.nodeType?t:t.firstChild,"tr")?be(">tbody",e)[0]||e:e}function O(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function D(e){var t=st.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function q(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Re.hasData(e)&&(o=Re.access(e),a=Re.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)be.event.add(t,i,l[i][n])}Ie.hasData(e)&&(s=Ie.access(e),u=be.extend({},s),Ie.set(t,u))}}function _(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Ge.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function H(e,t,n,r){t=ce.apply([],t);var i,o,a,u,l,c,f=0,d=e.length,p=d-1,h=t[0],v=be.isFunction(h);if(v||d>1&&"string"==typeof h&&!ye.checkClone&&at.test(h))return e.each(function(i){var o=e.eq(i);v&&(t[0]=h.call(this,i,o.html())),H(o,t,n,r)});if(d&&(i=k(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(a=be.map(T(i,"script"),O),u=a.length;f<d;f++)l=i,f!==p&&(l=be.clone(l,!0,!0),u&&be.merge(a,T(l,"script"))),n.call(e[f],l,f);if(u)for(c=a[a.length-1].ownerDocument,be.map(a,D),f=0;f<u;f++)l=a[f],Je.test(l.type||"")&&!Re.access(l,"globalEval")&&be.contains(c,l)&&(l.src?be._evalUrl&&be._evalUrl(l.src):s(l.textContent.replace(ut,""),c))}return e}function P(e,t,n){for(var r,i=t?be.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||be.cleanData(T(r)),r.parentNode&&(n&&be.contains(r.ownerDocument,r)&&E(T(r,"script")),r.parentNode.removeChild(r));return e}function F(e,t,n){var r,i,o,a,s=e.style;return n=n||ft(e),n&&(a=n.getPropertyValue(t)||n[t],""!==a||be.contains(e.ownerDocument,e)||(a=be.style(e,t)),!ye.pixelMarginRight()&&ct.test(a)&&lt.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function M(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function R(e){if(e in mt)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=gt.length;n--;)if((e=gt[n]+t)in mt)return e}function I(e){var t=be.cssProps[e];return t||(t=be.cssProps[e]=R(e)||e),t}function W(e,t,n){var r=ze.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function $(e,t,n,r,i){var o,a=0;for(o=n===(r?"border":"content")?4:"width"===t?1:0;o<4;o+=2)"margin"===n&&(a+=be.css(e,n+Ue[o],!0,i)),r?("content"===n&&(a-=be.css(e,"padding"+Ue[o],!0,i)),"margin"!==n&&(a-=be.css(e,"border"+Ue[o]+"Width",!0,i))):(a+=be.css(e,"padding"+Ue[o],!0,i),"padding"!==n&&(a+=be.css(e,"border"+Ue[o]+"Width",!0,i)));return a}function B(e,t,n){var r,i=ft(e),o=F(e,t,i),a="border-box"===be.css(e,"boxSizing",!1,i);return ct.test(o)?o:(r=a&&(ye.boxSizingReliable()||o===e.style[t]),"auto"===o&&(o=e["offset"+t[0].toUpperCase()+t.slice(1)]),(o=parseFloat(o)||0)+$(e,t,n||(a?"border":"content"),r,i)+"px")}function z(e,t,n,r,i){return new z.prototype.init(e,t,n,r,i)}function U(){bt&&(!1===se.hidden&&o.requestAnimationFrame?o.requestAnimationFrame(U):o.setTimeout(U,be.fx.interval),be.fx.tick())}function X(){return o.setTimeout(function(){yt=void 0}),yt=be.now()}function V(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)n=Ue[r],i["margin"+n]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function Y(e,t,n){for(var r,i=(J.tweeners[t]||[]).concat(J.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function G(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,d=this,p={},h=e.style,v=e.nodeType&&Xe(e),g=Re.get(e,"fxshow");n.queue||(a=be._queueHooks(e,"fx"),null==a.unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,d.always(function(){d.always(function(){a.unqueued--,be.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],xt.test(i)){if(delete t[r],o=o||"toggle"===i,i===(v?"hide":"show")){if("show"!==i||!g||void 0===g[r])continue;v=!0}p[r]=g&&g[r]||be.style(e,r)}if((u=!be.isEmptyObject(t))||!be.isEmptyObject(p)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],l=g&&g.display,null==l&&(l=Re.get(e,"display")),c=be.css(e,"display"),"none"===c&&(l?c=l:(C([e],!0),l=e.style.display||l,c=be.css(e,"display"),C([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===be.css(e,"float")&&(u||(d.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",d.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in p)u||(g?"hidden"in g&&(v=g.hidden):g=Re.access(e,"fxshow",{display:l}),o&&(g.hidden=!v),v&&C([e],!0),d.done(function(){v||C([e]),Re.remove(e,"fxshow");for(r in p)be.style(e,r,p[r])})),u=Y(v?g[r]:0,r,d),r in g||(g[r]=u.start,v&&(u.end=u.start,u.start=0))}}function Q(e,t){var n,r,i,o,a;for(n in e)if(r=be.camelCase(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=be.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function J(e,t,n){var r,i,o=0,a=J.prefilters.length,s=be.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=yt||X(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;a<u;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),o<1&&u?n:(u||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:be.extend({},t),opts:be.extend(!0,{specialEasing:{},easing:be.easing._default},n),originalProperties:t,originalOptions:n,startTime:yt||X(),duration:n.duration,tweens:[],createTween:function(t,n){var r=be.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(Q(c,l.opts.specialEasing);o<a;o++)if(r=J.prefilters[o].call(l,e,c,l.opts))return be.isFunction(r.stop)&&(be._queueHooks(l.elem,l.opts.queue).stop=be.proxy(r.stop,r)),r;return be.map(c,Y,l),be.isFunction(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),be.fx.timer(be.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}function K(e){return(e.match(_e)||[]).join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ee(e,t,n,r){var o;if(Array.isArray(t))be.each(t,function(t,o){n||Ot.test(e)?r(e,o):ee(e+"["+("object"===(void 0===o?"undefined":i(o))&&null!=o?t:"")+"]",o,n,r)});else if(n||"object"!==be.type(t))r(e,t);else for(o in t)ee(e+"["+o+"]",t[o],n,r)}function te(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(_e)||[];if(be.isFunction(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ne(e,t,n,r){function i(s){var u;return o[s]=!0,be.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||a||o[l]?a?!(u=l):void 0:(t.dataTypes.unshift(l),i(l),!1)}),u}var o={},a=e===Bt;return i(t.dataTypes[0])||!o["*"]&&i("*")}function re(e,t){var n,r,i=be.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&be.extend(!0,e,r),e}function ie(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;"*"===u[0];)u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function oe(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if(s=i.split(" "),s[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}var ae=[],se=o.document,ue=Object.getPrototypeOf,le=ae.slice,ce=ae.concat,fe=ae.push,de=ae.indexOf,pe={},he=pe.toString,ve=pe.hasOwnProperty,ge=ve.toString,me=ge.call(Object),ye={},be=function e(t,n){return new e.fn.init(t,n)},xe=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,we=/^-ms-/,Ce=/-([a-z])/g,Te=function(e,t){return t.toUpperCase()};be.fn=be.prototype={jquery:"3.2.1",constructor:be,length:0,toArray:function(){return le.call(this)},get:function(e){return null==e?le.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=be.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return be.each(this,e)},map:function(e){return this.pushStack(be.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(le.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:fe,sort:ae.sort,splice:ae.splice},be.extend=be.fn.extend=function(){var e,t,n,r,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[u]||{},u++),"object"===(void 0===s?"undefined":i(s))||be.isFunction(s)||(s={}),u===l&&(s=this,u--);u<l;u++)if(null!=(e=arguments[u]))for(t in e)n=s[t],r=e[t],s!==r&&(c&&r&&(be.isPlainObject(r)||(o=Array.isArray(r)))?(o?(o=!1,a=n&&Array.isArray(n)?n:[]):a=n&&be.isPlainObject(n)?n:{},s[t]=be.extend(c,a,r)):void 0!==r&&(s[t]=r));return s},be.extend({expando:"jQuery"+("3.2.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return"function"===be.type(e)},isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){var t=be.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==he.call(e))&&(!(t=ue(e))||"function"==typeof(n=ve.call(t,"constructor")&&t.constructor)&&ge.call(n)===me)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},type:function(e){return null==e?e+"":"object"===(void 0===e?"undefined":i(e))||"function"==typeof e?pe[he.call(e)]||"object":void 0===e?"undefined":i(e)},globalEval:function(e){s(e)},camelCase:function(e){return e.replace(we,"ms-").replace(Ce,Te)},each:function(e,t){var n,r=0;if(u(e))for(n=e.length;r<n&&!1!==t.call(e[r],r,e[r]);r++);else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(xe,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(u(Object(e))?be.merge(n,"string"==typeof e?[e]:e):fe.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:de.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(u(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return ce.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),be.isFunction(e))return r=le.call(arguments,2),i=function(){return e.apply(t||this,r.concat(le.call(arguments)))},i.guid=e.guid=e.guid||be.guid++,i},now:Date.now,support:ye}),"function"==typeof Symbol&&(be.fn[Symbol.iterator]=ae[Symbol.iterator]),be.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){pe["[object "+t+"]"]=t.toLowerCase()});var Ee=/*!
15
+ * Sizzle CSS Selector Engine v2.3.3
16
+ * https://sizzlejs.com/
17
+ *
18
+ * Copyright jQuery Foundation and other contributors
19
+ * Released under the MIT license
20
+ * http://jquery.org/license
21
+ *
22
+ * Date: 2016-08-08
23
+ */
24
+ function(e){function t(e,t,n,r){var i,o,a,s,u,c,d,p=t&&t.ownerDocument,h=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==h&&9!==h&&11!==h)return n;if(!r&&((t?t.ownerDocument||t:R)!==O&&L(t),t=t||O,q)){if(11!==h&&(u=ve.exec(e)))if(i=u[1]){if(9===h){if(!(a=t.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(p&&(a=p.getElementById(i))&&F(t,a)&&a.id===i)return n.push(a),n}else{if(u[2])return Q.apply(n,t.getElementsByTagName(e)),n;if((i=u[3])&&x.getElementsByClassName&&t.getElementsByClassName)return Q.apply(n,t.getElementsByClassName(i)),n}if(x.qsa&&!z[e+" "]&&(!_||!_.test(e))){if(1!==h)p=t,d=e;else if("object"!==t.nodeName.toLowerCase()){for((s=t.getAttribute("id"))?s=s.replace(be,xe):t.setAttribute("id",s=M),c=E(e),o=c.length;o--;)c[o]="#"+s+" "+f(c[o]);d=c.join(","),p=ge.test(e)&&l(t.parentNode)||t}if(d)try{return Q.apply(n,p.querySelectorAll(d)),n}catch(e){}finally{s===M&&t.removeAttribute("id")}}}return S(e.replace(oe,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[M]=!0,e}function i(e){var t=O.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&Ce(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function u(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function l(e){return e&&void 0!==e.getElementsByTagName&&e}function c(){}function f(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function d(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=W++;return t.first?function(t,n,i){for(;t=t[r];)if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,d=[I,s];if(u){for(;t=t[r];)if((1===t.nodeType||a)&&e(t,n,u))return!0}else for(;t=t[r];)if(1===t.nodeType||a)if(f=t[M]||(t[M]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===I&&l[1]===s)return d[2]=l[2];if(c[o]=d,d[2]=e(t,n,u))return!0}return!1}}function p(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function h(e,n,r){for(var i=0,o=n.length;i<o;i++)t(e,n[i],r);return r}function v(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function g(e,t,n,i,o,a){return i&&!i[M]&&(i=g(i)),o&&!o[M]&&(o=g(o,a)),r(function(r,a,s,u){var l,c,f,d=[],p=[],g=a.length,m=r||h(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?m:v(m,d,e,s,u),b=n?o||(r?e:g||i)?[]:a:y;if(n&&n(y,b,s,u),i)for(l=v(b,p),i(l,[],s,u),c=l.length;c--;)(f=l[c])&&(b[p[c]]=!(y[p[c]]=f));if(r){if(o||e){if(o){for(l=[],c=b.length;c--;)(f=b[c])&&l.push(y[c]=f);o(null,b=[],l,u)}for(c=b.length;c--;)(f=b[c])&&(l=o?K(r,f):d[c])>-1&&(r[l]=!(a[l]=f))}}else b=v(b===a?b.splice(g,b.length):b),o?o(null,a,b,u):Q.apply(a,b)})}function m(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,u=d(function(e){return e===t},a,!0),l=d(function(e){return K(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==N)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s<i;s++)if(n=w.relative[e[s].type])c=[d(p(c),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[M]){for(r=++s;r<i&&!w.relative[e[r].type];r++);return g(s>1&&p(c),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(oe,"$1"),n,s<r&&m(e.slice(s,r)),r<i&&m(e=e.slice(r)),r<i&&f(e))}c.push(n)}return p(c)}function y(e,n){var i=n.length>0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",g=r&&[],m=[],y=N,b=r||o&&w.find.TAG("*",l),x=I+=null==y?1:Math.random()||.1,C=b.length;for(l&&(N=a===O||a||l);h!==C&&null!=(c=b[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===O||(L(c),s=!q);d=e[f++];)if(d(c,a||O,s)){u.push(c);break}l&&(I=x)}i&&((c=!d&&c)&&p--,r&&g.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(g,m,a,s);if(r){if(p>0)for(;h--;)g[h]||m[h]||(m[h]=Y.call(u));m=v(m)}Q.apply(u,m),l&&!r&&m.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(I=x,N=y),g};return i?r(a):a}var b,x,w,C,T,E,k,S,N,j,A,L,O,D,q,_,H,P,F,M="sizzle"+1*new Date,R=e.document,I=0,W=0,$=n(),B=n(),z=n(),U=function(e,t){return e===t&&(A=!0),0},X={}.hasOwnProperty,V=[],Y=V.pop,G=V.push,Q=V.push,J=V.slice,K=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},Z="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ee="[\\x20\\t\\r\\n\\f]",te="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",ne="\\["+ee+"*("+te+")(?:"+ee+"*([*^$|!~]?=)"+ee+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+te+"))|)"+ee+"*\\]",re=":("+te+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ne+")*)|.*)\\)|)",ie=new RegExp(ee+"+","g"),oe=new RegExp("^"+ee+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ee+"+$","g"),ae=new RegExp("^"+ee+"*,"+ee+"*"),se=new RegExp("^"+ee+"*([>+~]|"+ee+")"+ee+"*"),ue=new RegExp("="+ee+"*([^\\]'\"]*?)"+ee+"*\\]","g"),le=new RegExp(re),ce=new RegExp("^"+te+"$"),fe={ID:new RegExp("^#("+te+")"),CLASS:new RegExp("^\\.("+te+")"),TAG:new RegExp("^("+te+"|[*])"),ATTR:new RegExp("^"+ne),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ee+"*(even|odd|(([+-]|)(\\d*)n|)"+ee+"*(?:([+-]|)"+ee+"*(\\d+)|))"+ee+"*\\)|)","i"),bool:new RegExp("^(?:"+Z+")$","i"),needsContext:new RegExp("^"+ee+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ee+"*((?:-\\d)?\\d*)"+ee+"*\\)|)(?=[^-]|$)","i")},de=/^(?:input|select|textarea|button)$/i,pe=/^h\d$/i,he=/^[^{]+\{\s*\[native \w/,ve=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ge=/[+~]/,me=new RegExp("\\\\([\\da-f]{1,6}"+ee+"?|("+ee+")|.)","ig"),ye=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},be=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,xe=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},we=function(){L()},Ce=d(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{Q.apply(V=J.call(R.childNodes),R.childNodes),V[R.childNodes.length].nodeType}catch(e){Q={apply:V.length?function(e,t){G.apply(e,J.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}x=t.support={},T=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},L=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:R;return r!==O&&9===r.nodeType&&r.documentElement?(O=r,D=O.documentElement,q=!T(O),R!==O&&(n=O.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",we,!1):n.attachEvent&&n.attachEvent("onunload",we)),x.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),x.getElementsByTagName=i(function(e){return e.appendChild(O.createComment("")),!e.getElementsByTagName("*").length}),x.getElementsByClassName=he.test(O.getElementsByClassName),x.getById=i(function(e){return D.appendChild(e).id=M,!O.getElementsByName||!O.getElementsByName(M).length}),x.getById?(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){return e.getAttribute("id")===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&q){var n=t.getElementById(e);return n?[n]:[]}}):(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&q){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),w.find.TAG=x.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):x.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=x.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&q)return t.getElementsByClassName(e)},H=[],_=[],(x.qsa=he.test(O.querySelectorAll))&&(i(function(e){D.appendChild(e).innerHTML="<a id='"+M+"'></a><select id='"+M+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&_.push("[*^$]="+ee+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||_.push("\\["+ee+"*(?:value|"+Z+")"),e.querySelectorAll("[id~="+M+"-]").length||_.push("~="),e.querySelectorAll(":checked").length||_.push(":checked"),e.querySelectorAll("a#"+M+"+*").length||_.push(".#.+[+~]")}),i(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=O.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&_.push("name"+ee+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&_.push(":enabled",":disabled"),D.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&_.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),_.push(",.*:")})),(x.matchesSelector=he.test(P=D.matches||D.webkitMatchesSelector||D.mozMatchesSelector||D.oMatchesSelector||D.msMatchesSelector))&&i(function(e){x.disconnectedMatch=P.call(e,"*"),P.call(e,"[s!='']:x"),H.push("!=",re)}),_=_.length&&new RegExp(_.join("|")),H=H.length&&new RegExp(H.join("|")),t=he.test(D.compareDocumentPosition),F=t||he.test(D.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},U=t?function(e,t){if(e===t)return A=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!x.sortDetached&&t.compareDocumentPosition(e)===n?e===O||e.ownerDocument===R&&F(R,e)?-1:t===O||t.ownerDocument===R&&F(R,t)?1:j?K(j,e)-K(j,t):0:4&n?-1:1)}:function(e,t){if(e===t)return A=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===O?-1:t===O?1:i?-1:o?1:j?K(j,e)-K(j,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===R?-1:u[r]===R?1:0},O):O},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==O&&L(e),n=n.replace(ue,"='$1']"),x.matchesSelector&&q&&!z[n+" "]&&(!H||!H.test(n))&&(!_||!_.test(n)))try{var r=P.call(e,n);if(r||x.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return t(n,O,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==O&&L(e),F(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==O&&L(e);var n=w.attrHandle[t.toLowerCase()],r=n&&X.call(w.attrHandle,t.toLowerCase())?n(e,t,!q):void 0;return void 0!==r?r:x.attributes||!q?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.escape=function(e){return(e+"").replace(be,xe)},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(A=!x.detectDuplicates,j=!x.sortStable&&e.slice(0),e.sort(U),A){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return j=null,e},C=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=C(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=C(t);return n},w=t.selectors={cacheLength:50,createPseudo:r,match:fe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(me,ye),e[3]=(e[3]||e[4]||e[5]||"").replace(me,ye),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return fe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&le.test(n)&&(t=E(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(me,ye).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ee+")"+e+"("+ee+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ie," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,v=o!==a?"nextSibling":"previousSibling",g=t.parentNode,m=s&&t.nodeName.toLowerCase(),y=!u&&!s,b=!1;if(g){if(o){for(;v;){for(d=t;d=d[v];)if(s?d.nodeName.toLowerCase()===m:1===d.nodeType)return!1;h=v="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?g.firstChild:g.lastChild],a&&y){for(d=g,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],b=p&&l[2],d=p&&g.childNodes[p];d=++p&&d&&d[v]||(b=p=0)||h.pop();)if(1===d.nodeType&&++b&&d===t){c[e]=[I,p,b];break}}else if(y&&(d=t,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],b=p),!1===b)for(;(d=++p&&d&&d[v]||(b=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==m:1!==d.nodeType)||!++b||(y&&(f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[I,b]),d!==t)););return(b-=i)===r||b%r==0&&b/r>=0}}},PSEUDO:function(e,n){var i,o=w.pseudos[e]||w.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[M]?o(n):o.length>1?(i=[e,e,"",n],w.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=K(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(oe,"$1"));return i[M]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(me,ye),function(t){return(t.textContent||t.innerText||C(t)).indexOf(e)>-1}}),lang:r(function(e){return ce.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(me,ye).toLowerCase(),function(t){var n;do{if(n=q?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===D},focus:function(e){return e===O.activeElement&&(!O.hasFocus||O.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:s(!1),disabled:s(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return pe.test(e.nodeName)},input:function(e){return de.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:u(function(){return[0]}),last:u(function(e,t){return[t-1]}),eq:u(function(e,t,n){return[n<0?n+t:n]}),even:u(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:u(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:u(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:u(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},w.pseudos.nth=w.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})w.pseudos[b]=function(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}(b);for(b in{submit:!0,reset:!0})w.pseudos[b]=function(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}(b);return c.prototype=w.filters=w.pseudos,w.setFilters=new c,E=t.tokenize=function(e,n){var r,i,o,a,s,u,l,c=B[e+" "];if(c)return n?0:c.slice(0);for(s=e,u=[],l=w.preFilter;s;){r&&!(i=ae.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),r=!1,(i=se.exec(s))&&(r=i.shift(),o.push({value:r,type:i[0].replace(oe," ")}),s=s.slice(r.length));for(a in w.filter)!(i=fe[a].exec(s))||l[a]&&!(i=l[a](i))||(r=i.shift(),o.push({value:r,type:a,matches:i}),s=s.slice(r.length));if(!r)break}return n?s.length:s?t.error(e):B(e,u).slice(0)},k=t.compile=function(e,t){var n,r=[],i=[],o=z[e+" "];if(!o){for(t||(t=E(e)),n=t.length;n--;)o=m(t[n]),o[M]?r.push(o):i.push(o);o=z(e,y(i,r)),o.selector=e}return o},S=t.select=function(e,t,n,r){var i,o,a,s,u,c="function"==typeof e&&e,d=!r&&E(e=c.selector||e);if(n=n||[],1===d.length){if(o=d[0]=d[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&9===t.nodeType&&q&&w.relative[o[1].type]){if(!(t=(w.find.ID(a.matches[0].replace(me,ye),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=fe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((u=w.find[s])&&(r=u(a.matches[0].replace(me,ye),ge.test(o[0].type)&&l(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&f(o)))return Q.apply(n,r),n;break}}return(c||k(e,d))(r,t,!q,n,!t||ge.test(e)&&l(t.parentNode)||t),n},x.sortStable=M.split("").sort(U).join("")===M,x.detectDuplicates=!!A,L(),x.sortDetached=i(function(e){return 1&e.compareDocumentPosition(O.createElement("fieldset"))}),i(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),x.attributes&&i(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(Z,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(o);be.find=Ee,be.expr=Ee.selectors,be.expr[":"]=be.expr.pseudos,be.uniqueSort=be.unique=Ee.uniqueSort,be.text=Ee.getText,be.isXMLDoc=Ee.isXML,be.contains=Ee.contains,be.escapeSelector=Ee.escape;var ke=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&be(e).is(n))break;r.push(e)}return r},Se=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},Ne=be.expr.match.needsContext,je=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,Ae=/^.[^:#\[\.,]*$/;be.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?be.find.matchesSelector(r,e)?[r]:[]:be.find.matches(e,be.grep(t,function(e){return 1===e.nodeType}))},be.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(be(e).filter(function(){for(t=0;t<r;t++)if(be.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)be.find(e,i[t],n);return r>1?be.uniqueSort(n):n},filter:function(e){return this.pushStack(c(this,e||[],!1))},not:function(e){return this.pushStack(c(this,e||[],!0))},is:function(e){return!!c(this,"string"==typeof e&&Ne.test(e)?be(e):e||[],!1).length}});var Le,Oe=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(be.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||Le,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Oe.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof be?t[0]:t,be.merge(this,be.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:se,!0)),je.test(r[1])&&be.isPlainObject(t))for(r in t)be.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=se.getElementById(r[2]),i&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):be.isFunction(e)?void 0!==n.ready?n.ready(e):e(be):be.makeArray(e,this)}).prototype=be.fn,Le=be(se);var De=/^(?:parents|prev(?:Until|All))/,qe={children:!0,contents:!0,next:!0,prev:!0};be.fn.extend({has:function(e){var t=be(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(be.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&be(e);if(!Ne.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&be.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?be.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?de.call(be(e),this[0]):de.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(be.uniqueSort(be.merge(this.get(),be(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),be.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return ke(e,"parentNode")},parentsUntil:function(e,t,n){return ke(e,"parentNode",n)},next:function(e){return f(e,"nextSibling")},prev:function(e){return f(e,"previousSibling")},nextAll:function(e){return ke(e,"nextSibling")},prevAll:function(e){return ke(e,"previousSibling")},nextUntil:function(e,t,n){return ke(e,"nextSibling",n)},prevUntil:function(e,t,n){return ke(e,"previousSibling",n)},siblings:function(e){return Se((e.parentNode||{}).firstChild,e)},children:function(e){return Se(e.firstChild)},contents:function(e){return l(e,"iframe")?e.contentDocument:(l(e,"template")&&(e=e.content||e),be.merge([],e.childNodes))}},function(e,t){be.fn[e]=function(n,r){var i=be.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=be.filter(r,i)),this.length>1&&(qe[e]||be.uniqueSort(i),De.test(e)&&i.reverse()),this.pushStack(i)}});var _e=/[^\x20\t\r\n\f]+/g;be.Callbacks=function(e){e="string"==typeof e?d(e):be.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1)for(n=a.shift();++s<o.length;)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1);e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){be.each(n,function(n,r){be.isFunction(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==be.type(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return be.each(arguments,function(e,t){for(var n;(n=be.inArray(t,o,n))>-1;)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?be.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},be.extend({Deferred:function(e){var t=[["notify","progress",be.Callbacks("memory"),be.Callbacks("memory"),2],["resolve","done",be.Callbacks("once memory"),be.Callbacks("once memory"),0,"resolved"],["reject","fail",be.Callbacks("once memory"),be.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return be.Deferred(function(n){be.each(t,function(t,r){var i=be.isFunction(e[r[4]])&&e[r[4]];a[r[1]](function(){var e=i&&i.apply(this,arguments);e&&be.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(e,n,r){function a(e,t,n,r){return function(){var u=this,l=arguments,c=function(){var o,c;if(!(e<s)){if((o=n.apply(u,l))===t.promise())throw new TypeError("Thenable self-resolution");c=o&&("object"===(void 0===o?"undefined":i(o))||"function"==typeof o)&&o.then,be.isFunction(c)?r?c.call(o,a(s,t,p,r),a(s,t,h,r)):(s++,c.call(o,a(s,t,p,r),a(s,t,h,r),a(s,t,p,t.notifyWith))):(n!==p&&(u=void 0,l=[o]),(r||t.resolveWith)(u,l))}},f=r?c:function(){try{c()}catch(r){be.Deferred.exceptionHook&&be.Deferred.exceptionHook(r,f.stackTrace),e+1>=s&&(n!==h&&(u=void 0,l=[r]),t.rejectWith(u,l))}};e?f():(be.Deferred.getStackHook&&(f.stackTrace=be.Deferred.getStackHook()),o.setTimeout(f))}}var s=0;return be.Deferred(function(i){t[0][3].add(a(0,i,be.isFunction(r)?r:p,i.notifyWith)),t[1][3].add(a(0,i,be.isFunction(e)?e:p)),t[2][3].add(a(0,i,be.isFunction(n)?n:h))}).promise()},promise:function(e){return null!=e?be.extend(e,r):r}},a={};return be.each(t,function(e,i){var o=i[2],s=i[5];r[i[1]]=o.add,s&&o.add(function(){n=s},t[3-e][2].disable,t[0][2].lock),o.add(i[3].fire),a[i[0]]=function(){return a[i[0]+"With"](this===a?void 0:this,arguments),this},a[i[0]+"With"]=o.fireWith}),r.promise(a),e&&e.call(a,a),a},when:function(e){var t=arguments.length,n=t,r=Array(n),i=le.call(arguments),o=be.Deferred(),a=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?le.call(arguments):n,--t||o.resolveWith(r,i)}};if(t<=1&&(v(e,o.done(a(n)).resolve,o.reject,!t),"pending"===o.state()||be.isFunction(i[n]&&i[n].then)))return o.then();for(;n--;)v(i[n],a(n),o.reject);return o.promise()}});var He=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;be.Deferred.exceptionHook=function(e,t){o.console&&o.console.warn&&e&&He.test(e.name)&&o.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},be.readyException=function(e){o.setTimeout(function(){throw e})};var Pe=be.Deferred();be.fn.ready=function(e){return Pe.then(e).catch(function(e){be.readyException(e)}),this},be.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--be.readyWait:be.isReady)||(be.isReady=!0,!0!==e&&--be.readyWait>0||Pe.resolveWith(se,[be]))}}),be.ready.then=Pe.then,"complete"===se.readyState||"loading"!==se.readyState&&!se.documentElement.doScroll?o.setTimeout(be.ready):(se.addEventListener("DOMContentLoaded",g),o.addEventListener("load",g));var Fe=function e(t,n,r,i,o,a,s){var u=0,l=t.length,c=null==r;if("object"===be.type(r)){o=!0;for(u in r)e(t,n,u,r[u],!0,a,s)}else if(void 0!==i&&(o=!0,be.isFunction(i)||(s=!0),c&&(s?(n.call(t,i),n=null):(c=n,n=function(e,t,n){return c.call(be(e),n)})),n))for(;u<l;u++)n(t[u],r,s?i:i.call(t[u],u,n(t[u],r)));return o?t:c?n.call(t):l?n(t[0],r):a},Me=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};m.uid=1,m.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Me(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[be.camelCase(t)]=n;else for(r in t)i[be.camelCase(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][be.camelCase(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){Array.isArray(t)?t=t.map(be.camelCase):(t=be.camelCase(t),t=t in r?[t]:t.match(_e)||[]),n=t.length;for(;n--;)delete r[t[n]]}(void 0===t||be.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!be.isEmptyObject(t)}};var Re=new m,Ie=new m,We=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,$e=/[A-Z]/g;be.extend({hasData:function(e){return Ie.hasData(e)||Re.hasData(e)},data:function(e,t,n){return Ie.access(e,t,n)},removeData:function(e,t){Ie.remove(e,t)},_data:function(e,t,n){return Re.access(e,t,n)},_removeData:function(e,t){Re.remove(e,t)}}),be.fn.extend({data:function(e,t){var n,r,o,a=this[0],s=a&&a.attributes;if(void 0===e){if(this.length&&(o=Ie.get(a),1===a.nodeType&&!Re.get(a,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&(r=s[n].name,0===r.indexOf("data-")&&(r=be.camelCase(r.slice(5)),b(a,r,o[r])));Re.set(a,"hasDataAttrs",!0)}return o}return"object"===(void 0===e?"undefined":i(e))?this.each(function(){Ie.set(this,e)}):Fe(this,function(t){var n;if(a&&void 0===t){if(void 0!==(n=Ie.get(a,e)))return n;if(void 0!==(n=b(a,e)))return n}else this.each(function(){Ie.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Ie.remove(this,e)})}}),be.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Re.get(e,t),n&&(!r||Array.isArray(n)?r=Re.access(e,t,be.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=be.queue(e,t),r=n.length,i=n.shift(),o=be._queueHooks(e,t),a=function(){be.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Re.get(e,n)||Re.access(e,n,{empty:be.Callbacks("once memory").add(function(){Re.remove(e,[t+"queue",n])})})}}),be.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?be.queue(this[0],e):void 0===t?this:this.each(function(){var n=be.queue(this,e,t);be._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&be.dequeue(this,e)})},dequeue:function(e){return this.each(function(){be.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=be.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";a--;)(n=Re.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var Be=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ze=new RegExp("^(?:([+-])=|)("+Be+")([a-z%]*)$","i"),Ue=["Top","Right","Bottom","Left"],Xe=function(e,t){return e=t||e,"none"===e.style.display||""===e.style.display&&be.contains(e.ownerDocument,e)&&"none"===be.css(e,"display")},Ve=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i},Ye={};be.fn.extend({show:function(){return C(this,!0)},hide:function(){return C(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Xe(this)?be(this).show():be(this).hide()})}});var Ge=/^(?:checkbox|radio)$/i,Qe=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,Je=/^$|\/(?:java|ecma)script/i,Ke={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ke.optgroup=Ke.option,Ke.tbody=Ke.tfoot=Ke.colgroup=Ke.caption=Ke.thead,Ke.th=Ke.td;var Ze=/<|&#?\w+;/;!function(){var e=se.createDocumentFragment(),t=e.appendChild(se.createElement("div")),n=se.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),ye.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",ye.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var et=se.documentElement,tt=/^key/,nt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,rt=/^([^.]*)(?:\.(.+)|)/;be.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,v,g=Re.get(e);if(g)for(n.handler&&(o=n,n=o.handler,i=o.selector),i&&be.find.matchesSelector(et,i),n.guid||(n.guid=be.guid++),(u=g.events)||(u=g.events={}),(a=g.handle)||(a=g.handle=function(t){return void 0!==be&&be.event.triggered!==t.type?be.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(_e)||[""],l=t.length;l--;)s=rt.exec(t[l])||[],p=v=s[1],h=(s[2]||"").split(".").sort(),p&&(f=be.event.special[p]||{},p=(i?f.delegateType:f.bindType)||p,f=be.event.special[p]||{},c=be.extend({type:p,origType:v,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&be.expr.match.needsContext.test(i),namespace:h.join(".")},o),(d=u[p])||(d=u[p]=[],d.delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(p,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),be.event.global[p]=!0)},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,v,g=Re.hasData(e)&&Re.get(e);if(g&&(u=g.events)){for(t=(t||"").match(_e)||[""],l=t.length;l--;)if(s=rt.exec(t[l])||[],p=v=s[1],h=(s[2]||"").split(".").sort(),p){for(f=be.event.special[p]||{},p=(r?f.delegateType:f.bindType)||p,d=u[p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=d.length;o--;)c=d[o],!i&&v!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,f.remove&&f.remove.call(e,c));a&&!d.length&&(f.teardown&&!1!==f.teardown.call(e,h,g.handle)||be.removeEvent(e,p,g.handle),delete u[p])}else for(p in u)be.event.remove(e,p+t[l],n,r,!0);be.isEmptyObject(u)&&Re.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=be.event.fix(e),u=new Array(arguments.length),l=(Re.get(this,"events")||{})[s.type]||[],c=be.event.special[s.type]||{};for(u[0]=s,t=1;t<arguments.length;t++)u[t]=arguments[t];if(s.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,s)){for(a=be.event.handlers.call(this,s,l),t=0;(i=a[t++])&&!s.isPropagationStopped();)for(s.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!s.isImmediatePropagationStopped();)s.rnamespace&&!s.rnamespace.test(o.namespace)||(s.handleObj=o,s.data=o.data,void 0!==(r=((be.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,u))&&!1===(s.result=r)&&(s.preventDefault(),s.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,s),s.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)r=t[n],i=r.selector+" ",void 0===a[i]&&(a[i]=r.needsContext?be(i,this).index(l)>-1:be.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(be.Event.prototype,e,{enumerable:!0,configurable:!0,get:be.isFunction(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[be.expando]?e:new be.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==j()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===j()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&l(this,"input"))return this.click(),!1},_default:function(e){return l(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},be.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},be.Event=function(e,t){if(!(this instanceof be.Event))return new be.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?S:N,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&be.extend(this,t),this.timeStamp=e&&e.timeStamp||be.now(),this[be.expando]=!0},be.Event.prototype={constructor:be.Event,isDefaultPrevented:N,isPropagationStopped:N,isImmediatePropagationStopped:N,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=S,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=S,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=S,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},be.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&tt.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&nt.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},be.event.addProp),be.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){be.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||be.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),be.fn.extend({on:function(e,t,n,r){return A(this,e,t,n,r)},one:function(e,t,n,r){return A(this,e,t,n,r,1)},off:function(e,t,n){var r,o;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,be(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"===(void 0===e?"undefined":i(e))){for(o in e)this.off(o,t,e[o]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=N),this.each(function(){be.event.remove(this,e,n,t)})}});var it=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,ot=/<script|<style|<link/i,at=/checked\s*(?:[^=]|=\s*.checked.)/i,st=/^true\/(.*)/,ut=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;be.extend({htmlPrefilter:function(e){return e.replace(it,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=be.contains(e.ownerDocument,e);if(!(ye.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||be.isXMLDoc(e)))for(a=T(s),o=T(e),r=0,i=o.length;r<i;r++)_(o[r],a[r]);if(t)if(n)for(o=o||T(e),a=a||T(s),r=0,i=o.length;r<i;r++)q(o[r],a[r]);else q(e,s);return a=T(s,"script"),a.length>0&&E(a,!u&&T(e,"script")),s},cleanData:function(e){for(var t,n,r,i=be.event.special,o=0;void 0!==(n=e[o]);o++)if(Me(n)){if(t=n[Re.expando]){if(t.events)for(r in t.events)i[r]?be.event.remove(n,r):be.removeEvent(n,r,t.handle);n[Re.expando]=void 0}n[Ie.expando]&&(n[Ie.expando]=void 0)}}}),be.fn.extend({detach:function(e){return P(this,e,!0)},remove:function(e){return P(this,e)},text:function(e){return Fe(this,function(e){return void 0===e?be.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return H(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){L(this,e).appendChild(e)}})},prepend:function(){return H(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=L(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return H(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return H(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(be.cleanData(T(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return be.clone(this,e,t)})},html:function(e){return Fe(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!ot.test(e)&&!Ke[(Qe.exec(e)||["",""])[1].toLowerCase()]){e=be.htmlPrefilter(e);try{for(;n<r;n++)t=this[n]||{},1===t.nodeType&&(be.cleanData(T(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return H(this,arguments,function(t){var n=this.parentNode;be.inArray(this,e)<0&&(be.cleanData(T(this)),n&&n.replaceChild(t,this))},e)}}),be.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){be.fn[e]=function(e){for(var n,r=[],i=be(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),be(i[a])[t](n),fe.apply(r,n.get());return this.pushStack(r)}});var lt=/^margin/,ct=new RegExp("^("+Be+")(?!px)[a-z%]+$","i"),ft=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=o),t.getComputedStyle(e)};!function(){function e(){if(s){s.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",s.innerHTML="",et.appendChild(a);var e=o.getComputedStyle(s);t="1%"!==e.top,i="2px"===e.marginLeft,n="4px"===e.width,s.style.marginRight="50%",r="4px"===e.marginRight,et.removeChild(a),s=null}}var t,n,r,i,a=se.createElement("div"),s=se.createElement("div");s.style&&(s.style.backgroundClip="content-box",s.cloneNode(!0).style.backgroundClip="",ye.clearCloneStyle="content-box"===s.style.backgroundClip,a.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",a.appendChild(s),be.extend(ye,{pixelPosition:function(){return e(),t},boxSizingReliable:function(){return e(),n},pixelMarginRight:function(){return e(),r},reliableMarginLeft:function(){return e(),i}}))}();var dt=/^(none|table(?!-c[ea]).+)/,pt=/^--/,ht={position:"absolute",visibility:"hidden",display:"block"},vt={letterSpacing:"0",fontWeight:"400"},gt=["Webkit","Moz","ms"],mt=se.createElement("div").style;be.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=F(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=be.camelCase(t),l=pt.test(t),c=e.style;if(l||(t=I(u)),s=be.cssHooks[t]||be.cssHooks[u],void 0===n)return s&&"get"in s&&void 0!==(o=s.get(e,!1,r))?o:c[t];a=void 0===n?"undefined":i(n),"string"===a&&(o=ze.exec(n))&&o[1]&&(n=x(e,t,o),a="number"),null!=n&&n===n&&("number"===a&&(n+=o&&o[3]||(be.cssNumber[u]?"":"px")),ye.clearCloneStyle||""!==n||0!==t.indexOf("background")||(c[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,r))||(l?c.setProperty(t,n):c[t]=n))}},css:function(e,t,n,r){var i,o,a,s=be.camelCase(t);return pt.test(t)||(t=I(s)),a=be.cssHooks[t]||be.cssHooks[s],a&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=F(e,t,r)),"normal"===i&&t in vt&&(i=vt[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),be.each(["height","width"],function(e,t){be.cssHooks[t]={get:function(e,n,r){if(n)return!dt.test(be.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?B(e,t,r):Ve(e,ht,function(){return B(e,t,r)})},set:function(e,n,r){var i,o=r&&ft(e),a=r&&$(e,t,r,"border-box"===be.css(e,"boxSizing",!1,o),o);return a&&(i=ze.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=be.css(e,t)),W(e,n,a)}}}),be.cssHooks.marginLeft=M(ye.reliableMarginLeft,function(e,t){if(t)return(parseFloat(F(e,"marginLeft"))||e.getBoundingClientRect().left-Ve(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),be.each({margin:"",padding:"",border:"Width"},function(e,t){be.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+Ue[r]+t]=o[r]||o[r-2]||o[0];return i}},lt.test(e)||(be.cssHooks[e+t].set=W)}),be.fn.extend({css:function(e,t){return Fe(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=ft(e),i=t.length;a<i;a++)o[t[a]]=be.css(e,t[a],!1,r);return o}return void 0!==n?be.style(e,t,n):be.css(e,t)},e,t,arguments.length>1)}}),be.Tween=z,z.prototype={constructor:z,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||be.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(be.cssNumber[n]?"":"px")},cur:function(){var e=z.propHooks[this.prop];return e&&e.get?e.get(this):z.propHooks._default.get(this)},run:function(e){var t,n=z.propHooks[this.prop];return this.options.duration?this.pos=t=be.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):z.propHooks._default.set(this),this}},z.prototype.init.prototype=z.prototype,z.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=be.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){be.fx.step[e.prop]?be.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[be.cssProps[e.prop]]&&!be.cssHooks[e.prop]?e.elem[e.prop]=e.now:be.style(e.elem,e.prop,e.now+e.unit)}}},z.propHooks.scrollTop=z.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},be.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},be.fx=z.prototype.init,be.fx.step={};var yt,bt,xt=/^(?:toggle|show|hide)$/,wt=/queueHooks$/;be.Animation=be.extend(J,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return x(n.elem,e,ze.exec(t),n),n}]},tweener:function(e,t){be.isFunction(e)?(t=e,e=["*"]):e=e.match(_e);for(var n,r=0,i=e.length;r<i;r++)n=e[r],J.tweeners[n]=J.tweeners[n]||[],J.tweeners[n].unshift(t)},prefilters:[G],prefilter:function(e,t){t?J.prefilters.unshift(e):J.prefilters.push(e)}}),be.speed=function(e,t,n){var r=e&&"object"===(void 0===e?"undefined":i(e))?be.extend({},e):{complete:n||!n&&t||be.isFunction(e)&&e,duration:e,easing:n&&t||t&&!be.isFunction(t)&&t};return be.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in be.fx.speeds?r.duration=be.fx.speeds[r.duration]:r.duration=be.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){be.isFunction(r.old)&&r.old.call(this),r.queue&&be.dequeue(this,r.queue)},r},be.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Xe).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=be.isEmptyObject(e),o=be.speed(t,n,r),a=function(){var t=J(this,be.extend({},e),o);(i||Re.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=be.timers,a=Re.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&wt.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||be.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=Re.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=be.timers,a=r?r.length:0;for(n.finish=!0,be.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),be.each(["toggle","show","hide"],function(e,t){var n=be.fn[t];be.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(V(t,!0),e,r,i)}}),be.each({slideDown:V("show"),slideUp:V("hide"),slideToggle:V("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){be.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),be.timers=[],be.fx.tick=function(){var e,t=0,n=be.timers;for(yt=be.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||be.fx.stop(),yt=void 0},be.fx.timer=function(e){be.timers.push(e),be.fx.start()},be.fx.interval=13,be.fx.start=function(){bt||(bt=!0,U())},be.fx.stop=function(){bt=null},be.fx.speeds={slow:600,fast:200,_default:400},be.fn.delay=function(e,t){return e=be.fx?be.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=o.setTimeout(t,e);n.stop=function(){o.clearTimeout(r)}})},function(){var e=se.createElement("input"),t=se.createElement("select"),n=t.appendChild(se.createElement("option"));e.type="checkbox",ye.checkOn=""!==e.value,ye.optSelected=n.selected,e=se.createElement("input"),e.value="t",e.type="radio",ye.radioValue="t"===e.value}();var Ct,Tt=be.expr.attrHandle;be.fn.extend({attr:function(e,t){return Fe(this,be.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){be.removeAttr(this,e)})}}),be.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?be.prop(e,t,n):(1===o&&be.isXMLDoc(e)||(i=be.attrHooks[t.toLowerCase()]||(be.expr.match.bool.test(t)?Ct:void 0)),void 0!==n?null===n?void be.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=be.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!ye.radioValue&&"radio"===t&&l(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(_e);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),Ct={set:function(e,t,n){return!1===t?be.removeAttr(e,n):e.setAttribute(n,n),n}},be.each(be.expr.match.bool.source.match(/\w+/g),function(e,t){var n=Tt[t]||be.find.attr;Tt[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=Tt[a],Tt[a]=i,i=null!=n(e,t,r)?a:null,Tt[a]=o),i}});var Et=/^(?:input|select|textarea|button)$/i,kt=/^(?:a|area)$/i;be.fn.extend({prop:function(e,t){return Fe(this,be.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[be.propFix[e]||e]})}}),be.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&be.isXMLDoc(e)||(t=be.propFix[t]||t,i=be.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=be.find.attr(e,"tabindex");return t?parseInt(t,10):Et.test(e.nodeName)||kt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),ye.optSelected||(be.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),be.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){be.propFix[this.toLowerCase()]=this}),be.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(be.isFunction(e))return this.each(function(t){be(this).addClass(e.call(this,t,Z(this)))});if("string"==typeof e&&e)for(t=e.match(_e)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(be.isFunction(e))return this.each(function(t){be(this).removeClass(e.call(this,t,Z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(_e)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=void 0===e?"undefined":i(e);return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):be.isFunction(e)?this.each(function(n){be(this).toggleClass(e.call(this,n,Z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=be(this),o=e.match(_e)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=Z(this),t&&Re.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":Re.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+K(Z(n))+" ").indexOf(t)>-1)return!0;return!1}});var St=/\r/g;be.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=be.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,be(this).val()):e,null==i?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=be.map(i,function(e){return null==e?"":e+""})),(t=be.valHooks[this.type]||be.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=be.valHooks[i.type]||be.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(St,""):null==n?"":n)}}}),be.extend({valHooks:{option:{get:function(e){var t=be.find.attr(e,"value");return null!=t?t:K(be.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(n=i[r],(n.selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!l(n.parentNode,"optgroup"))){if(t=be(n).val(),a)return t;s.push(t)}return s},set:function(e,t){for(var n,r,i=e.options,o=be.makeArray(t),a=i.length;a--;)r=i[a],(r.selected=be.inArray(be.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),be.each(["radio","checkbox"],function(){be.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=be.inArray(be(e).val(),t)>-1}},ye.checkOn||(be.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Nt=/^(?:focusinfocus|focusoutblur)$/;be.extend(be.event,{trigger:function(e,t,n,r){var a,s,u,l,c,f,d,p=[n||se],h=ve.call(e,"type")?e.type:e,v=ve.call(e,"namespace")?e.namespace.split("."):[];if(s=u=n=n||se,3!==n.nodeType&&8!==n.nodeType&&!Nt.test(h+be.event.triggered)&&(h.indexOf(".")>-1&&(v=h.split("."),h=v.shift(),v.sort()),c=h.indexOf(":")<0&&"on"+h,e=e[be.expando]?e:new be.Event(h,"object"===(void 0===e?"undefined":i(e))&&e),e.isTrigger=r?2:3,e.namespace=v.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+v.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:be.makeArray(t,[e]),d=be.event.special[h]||{},r||!d.trigger||!1!==d.trigger.apply(n,t))){if(!r&&!d.noBubble&&!be.isWindow(n)){for(l=d.delegateType||h,Nt.test(l+h)||(s=s.parentNode);s;s=s.parentNode)p.push(s),u=s;u===(n.ownerDocument||se)&&p.push(u.defaultView||u.parentWindow||o)}for(a=0;(s=p[a++])&&!e.isPropagationStopped();)e.type=a>1?l:d.bindType||h,f=(Re.get(s,"events")||{})[e.type]&&Re.get(s,"handle"),f&&f.apply(s,t),(f=c&&s[c])&&f.apply&&Me(s)&&(e.result=f.apply(s,t),!1===e.result&&e.preventDefault());return e.type=h,r||e.isDefaultPrevented()||d._default&&!1!==d._default.apply(p.pop(),t)||!Me(n)||c&&be.isFunction(n[h])&&!be.isWindow(n)&&(u=n[c],u&&(n[c]=null),be.event.triggered=h,n[h](),be.event.triggered=void 0,u&&(n[c]=u)),e.result}},simulate:function(e,t,n){var r=be.extend(new be.Event,n,{type:e,isSimulated:!0});be.event.trigger(r,null,t)}}),be.fn.extend({trigger:function(e,t){return this.each(function(){be.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return be.event.trigger(e,t,n,!0)}}),be.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){be.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),be.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),ye.focusin="onfocusin"in o,ye.focusin||be.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){be.event.simulate(t,e.target,be.event.fix(e))};be.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=Re.access(r,t);i||r.addEventListener(e,n,!0),Re.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=Re.access(r,t)-1;i?Re.access(r,t,i):(r.removeEventListener(e,n,!0),Re.remove(r,t))}}});var jt=o.location,At=be.now(),Lt=/\?/;be.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new o.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||be.error("Invalid XML: "+e),t};var Ot=/\[\]$/,Dt=/\r?\n/g,qt=/^(?:submit|button|image|reset|file)$/i,_t=/^(?:input|select|textarea|keygen)/i;be.param=function(e,t){var n,r=[],i=function(e,t){var n=be.isFunction(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!be.isPlainObject(e))be.each(e,function(){i(this.name,this.value)});else for(n in e)ee(n,e[n],t,i);return r.join("&")},be.fn.extend({serialize:function(){return be.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=be.prop(this,"elements");return e?be.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!be(this).is(":disabled")&&_t.test(this.nodeName)&&!qt.test(e)&&(this.checked||!Ge.test(e))}).map(function(e,t){var n=be(this).val();return null==n?null:Array.isArray(n)?be.map(n,function(e){return{name:t.name,value:e.replace(Dt,"\r\n")}}):{name:t.name,value:n.replace(Dt,"\r\n")}}).get()}});var Ht=/%20/g,Pt=/#.*$/,Ft=/([?&])_=[^&]*/,Mt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Rt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,It=/^(?:GET|HEAD)$/,Wt=/^\/\//,$t={},Bt={},zt="*/".concat("*"),Ut=se.createElement("a");Ut.href=jt.href,be.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:jt.href,type:"GET",isLocal:Rt.test(jt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":zt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":be.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?re(re(e,be.ajaxSettings),t):re(be.ajaxSettings,e)},ajaxPrefilter:te($t),ajaxTransport:te(Bt),ajax:function(e,t){function n(e,t,n,i){var u,c,p,h,w,C=t;f||(f=!0,l&&o.clearTimeout(l),r=void 0,s=i||"",E.readyState=e>0?4:0,u=e>=200&&e<300||304===e,n&&(h=ie(v,E,n)),h=oe(v,h,E,u),u?(v.ifModified&&(w=E.getResponseHeader("Last-Modified"),w&&(be.lastModified[a]=w),(w=E.getResponseHeader("etag"))&&(be.etag[a]=w)),204===e||"HEAD"===v.type?C="nocontent":304===e?C="notmodified":(C=h.state,c=h.data,p=h.error,u=!p)):(p=C,!e&&C||(C="error",e<0&&(e=0))),E.status=e,E.statusText=(t||C)+"",u?y.resolveWith(g,[c,C,E]):y.rejectWith(g,[E,C,p]),E.statusCode(x),x=void 0,d&&m.trigger(u?"ajaxSuccess":"ajaxError",[E,v,u?c:p]),b.fireWith(g,[E,C]),d&&(m.trigger("ajaxComplete",[E,v]),--be.active||be.event.trigger("ajaxStop")))}"object"===(void 0===e?"undefined":i(e))&&(t=e,e=void 0),t=t||{};var r,a,s,u,l,c,f,d,p,h,v=be.ajaxSetup({},t),g=v.context||v,m=v.context&&(g.nodeType||g.jquery)?be(g):be.event,y=be.Deferred(),b=be.Callbacks("once memory"),x=v.statusCode||{},w={},C={},T="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(f){if(!u)for(u={};t=Mt.exec(s);)u[t[1].toLowerCase()]=t[2];t=u[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return f?s:null},setRequestHeader:function(e,t){return null==f&&(e=C[e.toLowerCase()]=C[e.toLowerCase()]||e,w[e]=t),this},overrideMimeType:function(e){return null==f&&(v.mimeType=e),this},statusCode:function(e){var t;if(e)if(f)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||T;return r&&r.abort(t),n(0,t),this}};if(y.promise(E),v.url=((e||v.url||jt.href)+"").replace(Wt,jt.protocol+"//"),v.type=t.method||t.type||v.method||v.type,v.dataTypes=(v.dataType||"*").toLowerCase().match(_e)||[""],null==v.crossDomain){c=se.createElement("a");try{c.href=v.url,c.href=c.href,v.crossDomain=Ut.protocol+"//"+Ut.host!=c.protocol+"//"+c.host}catch(e){v.crossDomain=!0}}if(v.data&&v.processData&&"string"!=typeof v.data&&(v.data=be.param(v.data,v.traditional)),ne($t,v,t,E),f)return E;d=be.event&&v.global,d&&0==be.active++&&be.event.trigger("ajaxStart"),v.type=v.type.toUpperCase(),v.hasContent=!It.test(v.type),a=v.url.replace(Pt,""),v.hasContent?v.data&&v.processData&&0===(v.contentType||"").indexOf("application/x-www-form-urlencoded")&&(v.data=v.data.replace(Ht,"+")):(h=v.url.slice(a.length),v.data&&(a+=(Lt.test(a)?"&":"?")+v.data,delete v.data),!1===v.cache&&(a=a.replace(Ft,"$1"),h=(Lt.test(a)?"&":"?")+"_="+At+++h),v.url=a+h),v.ifModified&&(be.lastModified[a]&&E.setRequestHeader("If-Modified-Since",be.lastModified[a]),be.etag[a]&&E.setRequestHeader("If-None-Match",be.etag[a])),(v.data&&v.hasContent&&!1!==v.contentType||t.contentType)&&E.setRequestHeader("Content-Type",v.contentType),E.setRequestHeader("Accept",v.dataTypes[0]&&v.accepts[v.dataTypes[0]]?v.accepts[v.dataTypes[0]]+("*"!==v.dataTypes[0]?", "+zt+"; q=0.01":""):v.accepts["*"]);for(p in v.headers)E.setRequestHeader(p,v.headers[p]);if(v.beforeSend&&(!1===v.beforeSend.call(g,E,v)||f))return E.abort();if(T="abort",b.add(v.complete),E.done(v.success),E.fail(v.error),r=ne(Bt,v,t,E)){if(E.readyState=1,d&&m.trigger("ajaxSend",[E,v]),f)return E;v.async&&v.timeout>0&&(l=o.setTimeout(function(){E.abort("timeout")},v.timeout));try{f=!1,r.send(w,n)}catch(e){if(f)throw e;n(-1,e)}}else n(-1,"No Transport");return E},getJSON:function(e,t,n){return be.get(e,t,n,"json")},getScript:function(e,t){return be.get(e,void 0,t,"script")}}),be.each(["get","post"],function(e,t){be[t]=function(e,n,r,i){return be.isFunction(n)&&(i=i||r,r=n,n=void 0),be.ajax(be.extend({url:e,type:t,dataType:i,data:n,success:r},be.isPlainObject(e)&&e))}}),be._evalUrl=function(e){return be.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},be.fn.extend({wrapAll:function(e){var t;return this[0]&&(be.isFunction(e)&&(e=e.call(this[0])),t=be(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return be.isFunction(e)?this.each(function(t){be(this).wrapInner(e.call(this,t))}):this.each(function(){var t=be(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=be.isFunction(e);return this.each(function(n){be(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){be(this).replaceWith(this.childNodes)}),this}}),be.expr.pseudos.hidden=function(e){return!be.expr.pseudos.visible(e)},be.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},be.ajaxSettings.xhr=function(){try{return new o.XMLHttpRequest}catch(e){}};var Xt={0:200,1223:204},Vt=be.ajaxSettings.xhr();ye.cors=!!Vt&&"withCredentials"in Vt,ye.ajax=Vt=!!Vt,be.ajaxTransport(function(e){var t,n;if(ye.cors||Vt&&!e.crossDomain)return{send:function(r,i){var a,s=e.xhr();if(s.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(a in e.xhrFields)s[a]=e.xhrFields[a];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),e.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(a in r)s.setRequestHeader(a,r[a]);t=function(e){return function(){t&&(t=n=s.onload=s.onerror=s.onabort=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?i(0,"error"):i(s.status,s.statusText):i(Xt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=t(),n=s.onerror=t("error"),void 0!==s.onabort?s.onabort=n:s.onreadystatechange=function(){4===s.readyState&&o.setTimeout(function(){t&&n()})},t=t("abort");try{s.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),be.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),be.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return be.globalEval(e),e}}}),be.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),be.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=be("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),se.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Yt=[],Gt=/(=)\?(?=&|$)|\?\?/;be.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Yt.pop()||be.expando+"_"+At++;return this[e]=!0,e}}),be.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,a,s=!1!==e.jsonp&&(Gt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Gt.test(e.data)&&"data");if(s||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=be.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,s?e[s]=e[s].replace(Gt,"$1"+r):!1!==e.jsonp&&(e.url+=(Lt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return a||be.error(r+" was not called"),a[0]},e.dataTypes[0]="json",i=o[r],o[r]=function(){a=arguments},n.always(function(){void 0===i?be(o).removeProp(r):o[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Yt.push(r)),a&&be.isFunction(i)&&i(a[0]),a=i=void 0}),"script"}),ye.createHTMLDocument=function(){var e=se.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),be.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var r,i,o;return t||(ye.createHTMLDocument?(t=se.implementation.createHTMLDocument(""),r=t.createElement("base"),r.href=se.location.href,t.head.appendChild(r)):t=se),i=je.exec(e),o=!n&&[],i?[t.createElement(i[1])]:(i=k([e],t,o),o&&o.length&&be(o).remove(),be.merge([],i.childNodes))},be.fn.load=function(e,t,n){var r,o,a,s=this,u=e.indexOf(" ");return u>-1&&(r=K(e.slice(u)),e=e.slice(0,u)),be.isFunction(t)?(n=t,t=void 0):t&&"object"===(void 0===t?"undefined":i(t))&&(o="POST"),s.length>0&&be.ajax({url:e,type:o||"GET",dataType:"html",data:t}).done(function(e){a=arguments,s.html(r?be("<div>").append(be.parseHTML(e)).find(r):e)}).always(n&&function(e,t){s.each(function(){n.apply(this,a||[e.responseText,t,e])})}),this},be.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){be.fn[t]=function(e){return this.on(t,e)}}),be.expr.pseudos.animated=function(e){return be.grep(be.timers,function(t){return e===t.elem}).length},be.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=be.css(e,"position"),f=be(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=be.css(e,"top"),u=be.css(e,"left"),l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),be.isFunction(t)&&(t=t.call(e,n,be.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},be.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){be.offset.setOffset(this,e,t)});var t,n,r,i,o=this[0];if(o)return o.getClientRects().length?(r=o.getBoundingClientRect(),t=o.ownerDocument,n=t.documentElement,i=t.defaultView,{top:r.top+i.pageYOffset-n.clientTop,left:r.left+i.pageXOffset-n.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n=this[0],r={top:0,left:0};return"fixed"===be.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),l(e[0],"html")||(r=e.offset()),r={top:r.top+be.css(e[0],"borderTopWidth",!0),left:r.left+be.css(e[0],"borderLeftWidth",!0)}),{top:t.top-r.top-be.css(n,"marginTop",!0),left:t.left-r.left-be.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===be.css(e,"position");)e=e.offsetParent;return e||et})}}),be.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;be.fn[e]=function(r){return Fe(this,function(e,r,i){var o;if(be.isWindow(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),be.each(["top","left"],function(e,t){be.cssHooks[t]=M(ye.pixelPosition,function(e,n){if(n)return n=F(e,t),ct.test(n)?be(e).position()[t]+"px":n})}),be.each({Height:"height",Width:"width"},function(e,t){be.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){be.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return Fe(this,function(t,n,i){var o;return be.isWindow(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?be.css(t,n,s):be.style(t,n,i,s)},t,a?i:void 0,a)}})}),be.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),be.holdReady=function(e){e?be.readyWait++:be.ready(!0)},be.isArray=Array.isArray,be.parseJSON=JSON.parse,be.nodeName=l,n=[],void 0!==(r=function(){return be}.apply(t,n))&&(e.exports=r);var Qt=o.jQuery,Jt=o.$;return be.noConflict=function(e){return o.$===be&&(o.$=Jt),e&&o.jQuery===be&&(o.jQuery=Qt),be},a||(o.jQuery=o.$=be),be})}).call(t,n(14)(e))},function(e,t,n){"use strict";var r,i,o,a,a,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(n){if("object"===s(t)&&void 0!==e)e.exports=n();else{i=[],r=n,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}}(function(){return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var l="function"==typeof a&&a;if(!u&&l)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof a&&a,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
25
+ "document"in window.self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))?function(){var e=document.createElement("_");if(e.classList.add("c1","c2"),!e.classList.contains("c2")){var t=function(e){var t=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(e){var n,r=arguments.length;for(n=0;n<r;n++)e=arguments[n],t.call(this,e)}};t("add"),t("remove")}if(e.classList.toggle("c3",!1),e.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:n.call(this,e)}}e=null}():function(e){if("Element"in e){var t=e.Element.prototype,n=Object,r=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},i=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1},o=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},a=function(e,t){if(""===t)throw new o("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(t))throw new o("INVALID_CHARACTER_ERR","String contains an invalid character");return i.call(e,t)},s=function(e){for(var t=r.call(e.getAttribute("class")||""),n=t?t.split(/\s+/):[],i=0,o=n.length;i<o;i++)this.push(n[i]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},u=s.prototype=[],l=function(){return new s(this)};if(o.prototype=Error.prototype,u.item=function(e){return this[e]||null},u.contains=function(e){return e+="",-1!==a(this,e)},u.add=function(){var e,t=arguments,n=0,r=t.length,i=!1;do{e=t[n]+"",-1===a(this,e)&&(this.push(e),i=!0)}while(++n<r);i&&this._updateClassName()},u.remove=function(){var e,t,n=arguments,r=0,i=n.length,o=!1;do{for(e=n[r]+"",t=a(this,e);-1!==t;)this.splice(t,1),o=!0,t=a(this,e)}while(++r<i);o&&this._updateClassName()},u.toggle=function(e,t){e+="";var n=this.contains(e),r=n?!0!==t&&"remove":!1!==t&&"add";return r&&this[r](e),!0===t||!1===t?t:!n},u.toString=function(){return this.join(" ")},n.defineProperty){var c={get:l,enumerable:!0,configurable:!0};try{n.defineProperty(t,"classList",c)}catch(e){-2146823252===e.number&&(c.enumerable=!1,n.defineProperty(t,"classList",c))}}else n.prototype.__defineGetter__&&t.__defineGetter__("classList",l)}}(window.self))},{}],2:[function(e,t,n){function r(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){var i=t.createElement("html");return i.innerHTML=e,i.removeChild(i.lastChild)}var o=a[r]||a._default,s=o[0],u=o[1],l=o[2],i=t.createElement("div");for(i.innerHTML=u+e+l;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var c=t.createDocumentFragment();i.firstChild;)c.appendChild(i.removeChild(i.firstChild));return c}t.exports=r;var i,o=!1;"undefined"!=typeof document&&(i=document.createElement("div"),i.innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',o=!i.getElementsByTagName("link").length,i=void 0);var a={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:o?[1,"X<div>","</div>"]:[0,"",""]};a.td=a.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],a.option=a.optgroup=[1,'<select multiple="multiple">',"</select>"],a.thead=a.tbody=a.colgroup=a.caption=a.tfoot=[1,"<table>","</table>"],a.polyline=a.ellipse=a.polygon=a.circle=a.text=a.line=a.path=a.rect=a.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],3:[function(e,t,n){function r(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),r=1;r<arguments.length;r++){var i=arguments[r];if(void 0!==i&&null!==i)for(var o=Object.keys(Object(i)),a=0,s=o.length;a<s;a++){var u=o[a],l=Object.getOwnPropertyDescriptor(i,u);void 0!==l&&l.enumerable&&(n[u]=i[u])}}return n}function i(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:r})}t.exports={assign:r,polyfill:i}},{}],4:[function(e,t,n){e("classlist-polyfill"),e("es6-object-assign").polyfill();var r=e("domify"),i=function(e){if(void 0!==e){var t=document.createElement("div");return t.appendChild(document.createTextNode(e)),t.innerHTML}return""},o=function(e,t){if("string"==typeof t&&0!==t.length)for(var n=t.split(" "),r=0;r<n.length;r++){var i=n[r];i.length&&e.classList.add(i)}},a=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(void 0!==e.style[n])return t[n];return!1}(),s={vex:"vex",content:"vex-content",overlay:"vex-overlay",close:"vex-close",closing:"vex-closing",open:"vex-open"},u={},l=1,c=!1,f={open:function(e){var t=function(e){console.warn('The "'+e+'" property is deprecated in vex 3. Use CSS classes and the appropriate "ClassName" options, instead.'),console.warn("See http://github.hubspot.com/vex/api/advanced/#options")};e.css&&t("css"),e.overlayCSS&&t("overlayCSS"),e.contentCSS&&t("contentCSS"),e.closeCSS&&t("closeCSS");var n={};n.id=l++,u[n.id]=n,n.isOpen=!0,n.close=function(){function e(e){return"none"!==n.getPropertyValue(e+"animation-name")&&"0s"!==n.getPropertyValue(e+"animation-duration")}if(!this.isOpen)return!0;var t=this.options;if(c&&!t.escapeButtonCloses)return!1;if(!1===function(){return!t.beforeClose||t.beforeClose.call(this)}.bind(this)())return!1;this.isOpen=!1;var n=window.getComputedStyle(this.contentEl),r=e("")||e("-webkit-")||e("-moz-")||e("-o-"),i=function e(){this.rootEl.parentNode&&(this.rootEl.removeEventListener(a,e),delete u[this.id],this.rootEl.parentNode.removeChild(this.rootEl),t.afterClose&&t.afterClose.call(this),0===Object.keys(u).length&&document.body.classList.remove(s.open))}.bind(this);return a&&r?(this.rootEl.addEventListener(a,i),this.rootEl.classList.add(s.closing)):i(),!0},"string"==typeof e&&(e={content:e}),e.unsafeContent&&!e.content?e.content=e.unsafeContent:e.content&&(e.content=i(e.content));var d=n.options=Object.assign({},f.defaultOptions,e),p=n.rootEl=document.createElement("div");p.classList.add(s.vex),o(p,d.className);var h=n.overlayEl=document.createElement("div");h.classList.add(s.overlay),o(h,d.overlayClassName),d.overlayClosesOnClick&&h.addEventListener("click",function(e){e.target===h&&n.close()}),p.appendChild(h);var v=n.contentEl=document.createElement("div");if(v.classList.add(s.content),o(v,d.contentClassName),v.appendChild(d.content instanceof window.Node?d.content:r(d.content)),p.appendChild(v),d.showCloseButton){var g=n.closeEl=document.createElement("div");g.classList.add(s.close),o(g,d.closeClassName),g.addEventListener("click",n.close.bind(n)),v.appendChild(g)}return document.querySelector(d.appendLocation).appendChild(p),d.afterOpen&&d.afterOpen.call(n),document.body.classList.add(s.open),n},close:function(e){var t;if(e.id)t=e.id;else{if("string"!=typeof e)throw new TypeError("close requires a vex object or id string");t=e}return!!u[t]&&u[t].close()},closeTop:function(){var e=Object.keys(u);return!!e.length&&u[e[e.length-1]].close()},closeAll:function(){for(var e in u)this.close(e);return!0},getAll:function(){return u},getById:function(e){return u[e]}};window.addEventListener("keyup",function(e){27===e.keyCode&&(c=!0,f.closeTop(),c=!1)}),window.addEventListener("popstate",function(){f.defaultOptions.closeAllOnPopState&&f.closeAll()}),f.defaultOptions={content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",overlayClassName:"",contentClassName:"",closeClassName:"",closeAllOnPopState:!0},Object.defineProperty(f,"_escapeHtml",{configurable:!1,enumerable:!1,writable:!1,value:i}),f.registerPlugin=function(e,t){var n=e(f),r=t||n.name;if(f[r])throw new Error("Plugin "+t+" is already registered.");f[r]=n},t.exports=f},{"classlist-polyfill":1,domify:2,"es6-object-assign":3}]},{},[4])(4)})},function(e,t,n){"use strict";var r,i,o,a,a,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(n){if("object"===s(t)&&void 0!==e)e.exports=n();else{i=[],r=n,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}}(function(){return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var l="function"==typeof a&&a;if(!u&&l)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof a&&a,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){function r(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){var i=t.createElement("html");return i.innerHTML=e,i.removeChild(i.lastChild)}var o=a[r]||a._default,s=o[0],u=o[1],l=o[2],i=t.createElement("div");for(i.innerHTML=u+e+l;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var c=t.createDocumentFragment();i.firstChild;)c.appendChild(i.removeChild(i.firstChild));return c}t.exports=r;var i,o=!1;"undefined"!=typeof document&&(i=document.createElement("div"),i.innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',o=!i.getElementsByTagName("link").length,i=void 0);var a={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:o?[1,"X<div>","</div>"]:[0,"",""]};a.td=a.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],a.option=a.optgroup=[1,'<select multiple="multiple">',"</select>"],a.thead=a.tbody=a.colgroup=a.caption=a.tfoot=[1,"<table>","</table>"],a.polyline=a.ellipse=a.polygon=a.circle=a.text=a.line=a.path=a.rect=a.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],2:[function(e,t,n){function r(e,t){"object"!=(void 0===t?"undefined":s(t))?t={hash:!!t}:void 0===t.hash&&(t.hash=!0);for(var n=t.hash?{}:"",r=t.serializer||(t.hash?a:u),i=e&&e.elements?e.elements:[],o=Object.create(null),f=0;f<i.length;++f){var d=i[f];if((t.disabled||!d.disabled)&&d.name&&(c.test(d.nodeName)&&!l.test(d.type))){var p=d.name,h=d.value;if("checkbox"!==d.type&&"radio"!==d.type||d.checked||(h=void 0),t.empty){if("checkbox"!==d.type||d.checked||(h=""),"radio"===d.type&&(o[d.name]||d.checked?d.checked&&(o[d.name]=!0):o[d.name]=!1),!h&&"radio"==d.type)continue}else if(!h)continue;if("select-multiple"!==d.type)n=r(n,p,h);else{h=[];for(var v=d.options,g=!1,m=0;m<v.length;++m){var y=v[m],b=t.empty&&!y.value,x=y.value||b;y.selected&&x&&(g=!0,n=t.hash&&"[]"!==p.slice(p.length-2)?r(n,p+"[]",y.value):r(n,p,y.value))}!g&&t.empty&&(n=r(n,p,""))}}}if(t.empty)for(var p in o)o[p]||(n=r(n,p,""));return n}function i(e){var t=[],n=/^([^\[\]]*)/,r=new RegExp(f),i=n.exec(e);for(i[1]&&t.push(i[1]);null!==(i=r.exec(e));)t.push(i[1]);return t}function o(e,t,n){if(0===t.length)return e=n;var r=t.shift(),i=r.match(/^\[(.+?)\]$/);if("[]"===r)return e=e||[],Array.isArray(e)?e.push(o(null,t,n)):(e._values=e._values||[],e._values.push(o(null,t,n))),e;if(i){var a=i[1],s=+a;isNaN(s)?(e=e||{},e[a]=o(e[a],t,n)):(e=e||[],e[s]=o(e[s],t,n))}else e[r]=o(e[r],t,n);return e}function a(e,t,n){if(t.match(f))o(e,i(t),n);else{var r=e[t];r?(Array.isArray(r)||(e[t]=[r]),e[t].push(n)):e[t]=n}return e}function u(e,t,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=encodeURIComponent(n),n=n.replace(/%20/g,"+"),e+(e?"&":"")+encodeURIComponent(t)+"="+n}var l=/^(?:submit|button|image|reset|file)$/i,c=/^(?:input|select|textarea|keygen)/i,f=/(\[[^\[\]]*\])/g;t.exports=r},{}],3:[function(e,t,n){var r=e("domify"),i=e("form-serialize"),o=function(e){var t=document.createElement("form");t.classList.add("vex-dialog-form");var n=document.createElement("div");n.classList.add("vex-dialog-message"),n.appendChild(e.message instanceof window.Node?e.message:r(e.message));var i=document.createElement("div");return i.classList.add("vex-dialog-input"),i.appendChild(e.input instanceof window.Node?e.input:r(e.input)),t.appendChild(n),t.appendChild(i),t},a=function(e){var t=document.createElement("div");t.classList.add("vex-dialog-buttons");for(var n=0;n<e.length;n++){var r=e[n],i=document.createElement("button");i.type=r.type,i.textContent=r.text,i.className=r.className,i.classList.add("vex-dialog-button"),0===n?i.classList.add("vex-first"):n===e.length-1&&i.classList.add("vex-last"),function(e){i.addEventListener("click",function(t){e.click&&e.click.call(this,t)}.bind(this))}.bind(this)(r),t.appendChild(i)}return t},u=function(e){var t={name:"dialog",open:function(t){var n=Object.assign({},this.defaultOptions,t);n.unsafeMessage&&!n.message?n.message=n.unsafeMessage:n.message&&(n.message=e._escapeHtml(n.message));var r=n.unsafeContent=o(n),i=e.open(n),s=n.beforeClose&&n.beforeClose.bind(i);if(i.options.beforeClose=function(){var e=!s||s();return e&&n.callback(this.value||!1),e}.bind(i),r.appendChild(a.call(i,n.buttons)),i.form=r,r.addEventListener("submit",n.onSubmit.bind(i)),n.focusFirstInput){var u=i.contentEl.querySelector("button, input, select, textarea");u&&u.focus()}return i},alert:function(e){return"string"==typeof e&&(e={message:e}),e=Object.assign({},this.defaultOptions,this.defaultAlertOptions,e),this.open(e)},confirm:function(e){if("object"!==(void 0===e?"undefined":s(e))||"function"!=typeof e.callback)throw new Error("dialog.confirm(options) requires options.callback.");return e=Object.assign({},this.defaultOptions,this.defaultConfirmOptions,e),this.open(e)},prompt:function(t){if("object"!==(void 0===t?"undefined":s(t))||"function"!=typeof t.callback)throw new Error("dialog.prompt(options) requires options.callback.");var n=Object.assign({},this.defaultOptions,this.defaultPromptOptions),r={unsafeMessage:'<label for="vex">'+e._escapeHtml(t.label||n.label)+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+e._escapeHtml(t.placeholder||n.placeholder)+'" value="'+e._escapeHtml(t.value||n.value)+'" />'};t=Object.assign(n,r,t);var i=t.callback;return t.callback=function(e){if("object"===(void 0===e?"undefined":s(e))){var t=Object.keys(e);e=t.length?e[t[0]]:""}i(e)},this.open(t)}};return t.buttons={YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary",click:function(){this.value=!0}},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function(){this.value=!1,this.close()}}},t.defaultOptions={callback:function(){},afterOpen:function(){},message:"",input:"",buttons:[t.buttons.YES,t.buttons.NO],showCloseButton:!1,onSubmit:function(e){return e.preventDefault(),this.options.input&&(this.value=i(this.form,{hash:!0})),this.close()},focusFirstInput:!0},t.defaultAlertOptions={buttons:[t.buttons.YES]},t.defaultPromptOptions={label:"Prompt:",placeholder:"",value:""},t.defaultConfirmOptions={},t};t.exports=u},{domify:1,"form-serialize":2}]},{},[3])(3)})},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(){var e=new s.default("#copy-settings-string");e.on("success",function(e){l.default.dialog.alert(import_export_var.settings_string_copied)}),e.on("error",function(e){l.default.dialog.alert(import_export_var.failed_copy_settings_string)})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var o=n(0),a=(r(o),n(7)),s=r(a),u=n(1),l=r(u)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(){var e=(0,a.default)("#import-setting-button"),t=(0,a.default)("#ta_import_settings"),n=e.siblings(".spinner");e.on("click",function(){e.attr("disabled","disabled"),n.css("visibility","visible");var r=a.default.trim(t.val());""===r?(u.default.dialog.alert(import_export_var.please_input_settings_string),e.removeAttr("disabled"),n.css("visibility","hidden")):a.default.ajax({url:ajaxurl,type:"POST",data:{action:"ta_import_settings",ta_settings_string:r},dataType:"json"}).done(function(e,n,r){"success"===e.status?(u.default.dialog.alert(e.success_msg),t.val("")):(u.default.dialog.alert(e.error_msg),console.log(e))}).fail(function(e,t,n){u.default.dialog.alert(e),console.log(e)}).always(function(){e.removeAttr("disabled"),n.css("visibility","hidden")})})}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var o=n(0),a=r(o),s=n(1),u=r(s)},function(e,t){},function(e,t,n){"use strict";var r,i,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(a,s){i=[e,n(12)],r=s,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}(0,function(e,t){function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(e){return e&&e.__esModule?e:{default:e}}(t),i="function"==typeof Symbol&&"symbol"===a(Symbol.iterator)?function(e){return void 0===e?"undefined":a(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":void 0===e?"undefined":a(e)},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=function(){function e(t){n(this,e),this.resolveOptions(t),this.initSelection()}return o(e,[{key:"resolveOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var e=this,t="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,r.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,r.default)(this.target),this.copyText()}},{key:"copyText",value:function(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":i(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function(){return this._target}}]),e}();e.exports=s})},function(e,t,n){"use strict";var r,i,o,a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(a,s){i=[e,n(6),n(13),n(11)],r=s,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}(0,function(e,t,n,r){function i(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==(void 0===t?"undefined":a(t))&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+(void 0===t?"undefined":a(t)));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function l(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}var c=i(t),f=i(n),d=i(r),p=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),h=function(e){function t(e,n){o(this,t);var r=s(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return r.resolveOptions(n),r.listenClick(e),r}return u(t,e),p(t,[{key:"resolveOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText}},{key:"listenClick",value:function(e){var t=this;this.listener=(0,d.default)(e,"click",function(e){return t.onClick(e)})}},{key:"onClick",value:function(e){var t=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new c.default({action:this.action(t),target:this.target(t),text:this.text(t),trigger:t,emitter:this})}},{key:"defaultAction",value:function(e){return l("action",e)}},{key:"defaultTarget",value:function(e){var t=l("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return l("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof e?[e]:e,n=!!document.queryCommandSupported;return t.forEach(function(e){n=n&&!!document.queryCommandSupported(e)}),n}}]),t}(f.default);e.exports=h})},function(e,t,n){"use strict";function r(e,t){for(;e&&e.nodeType!==i;){if(e.matches(t))return e;e=e.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var o=Element.prototype;o.matches=o.matchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector||o.webkitMatchesSelector}e.exports=r},function(e,t,n){"use strict";function r(e,t,n,r,o){var a=i.apply(this,arguments);return e.addEventListener(n,a,o),{destroy:function(){e.removeEventListener(n,a,o)}}}function i(e,t,n,r){return function(n){n.delegateTarget=o(n.target,t),n.delegateTarget&&r.call(e,n)}}var o=n(8);e.exports=r},function(e,t,n){"use strict";t.node=function(e){return void 0!==e&&e instanceof HTMLElement&&1===e.nodeType},t.nodeList=function(e){var n=Object.prototype.toString.call(e);return void 0!==e&&("[object NodeList]"===n||"[object HTMLCollection]"===n)&&"length"in e&&(0===e.length||t.node(e[0]))},t.string=function(e){return"string"==typeof e||e instanceof String},t.fn=function(e){return"[object Function]"===Object.prototype.toString.call(e)}},function(e,t,n){"use strict";function r(e,t,n){if(!e&&!t&&!n)throw new Error("Missing required arguments");if(!s.string(t))throw new TypeError("Second argument must be a String");if(!s.fn(n))throw new TypeError("Third argument must be a Function");if(s.node(e))return i(e,t,n);if(s.nodeList(e))return o(e,t,n);if(s.string(e))return a(e,t,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(e,t,n){return e.addEventListener(t,n),{destroy:function(){e.removeEventListener(t,n)}}}function o(e,t,n){return Array.prototype.forEach.call(e,function(e){e.addEventListener(t,n)}),{destroy:function(){Array.prototype.forEach.call(e,function(e){e.removeEventListener(t,n)})}}}function a(e,t,n){return u(document.body,e,t,n)}var s=n(10),u=n(9);e.exports=r},function(e,t,n){"use strict";function r(e){var t;if("SELECT"===e.nodeName)e.focus(),t=e.value;else if("INPUT"===e.nodeName||"TEXTAREA"===e.nodeName){var n=e.hasAttribute("readonly");n||e.setAttribute("readonly",""),e.select(),e.setSelectionRange(0,e.value.length),n||e.removeAttribute("readonly"),t=e.value}else{e.hasAttribute("contenteditable")&&e.focus();var r=window.getSelection(),i=document.createRange();i.selectNodeContents(e),r.removeAllRanges(),r.addRange(i),t=r.toString()}return t}e.exports=r},function(e,t,n){"use strict";function r(){}r.prototype={on:function(e,t,n){var r=this.e||(this.e={});return(r[e]||(r[e]=[])).push({fn:t,ctx:n}),this},once:function(e,t,n){function r(){i.off(e,r),t.apply(n,arguments)}var i=this;return r._=t,this.on(e,r,n)},emit:function(e){var t=[].slice.call(arguments,1),n=((this.e||(this.e={}))[e]||[]).slice(),r=0,i=n.length;for(r;r<i;r++)n[r].fn.apply(n[r].ctx,t);return this},off:function(e,t){var n=this.e||(this.e={}),r=n[e],i=[];if(r&&t)for(var o=0,a=r.length;o<a;o++)r[o].fn!==t&&r[o].fn._!==t&&i.push(r[o]);return i.length?n[e]=i:delete n[e],this}},e.exports=r},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i=n(0),o=r(i),a=n(1),s=r(a),u=n(4),l=r(u),c=n(3),f=r(c);n(5),s.default.registerPlugin(n(2)),s.default.defaultOptions.className="vex-theme-plain",(0,o.default)(document).ready(function(){(0,l.default)(),(0,f.default)()})}]);
js/app/migration/dist/migration.css ADDED
@@ -0,0 +1 @@
 
1
+ @keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-webkit-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-moz-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-ms-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@-o-keyframes vex-fadein{0%{opacity:0}to{opacity:1}}@keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-webkit-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-moz-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-ms-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@-o-keyframes vex-fadeout{0%{opacity:1}to{opacity:0}}@keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-webkit-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-moz-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-ms-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}@-o-keyframes vex-rotation{0%{transform:rotate(0deg);-webkit-transform:rotate(0deg);-moz-transform:rotate(0deg);-ms-transform:rotate(0deg);-o-transform:rotate(0deg)}to{transform:rotate(359deg);-webkit-transform:rotate(359deg);-moz-transform:rotate(359deg);-ms-transform:rotate(359deg);-o-transform:rotate(359deg)}}.vex,.vex *,.vex :after,.vex :before{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.vex{position:fixed;overflow:auto;-webkit-overflow-scrolling:touch;z-index:1111;top:0;right:0;bottom:0;left:0}.vex-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.vex-overlay{background:#000;filter:alpha(opacity=40);-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=40)";animation:vex-fadein .5s;-webkit-animation:vex-fadein .5s;-moz-animation:vex-fadein .5s;-ms-animation:vex-fadein .5s;-o-animation:vex-fadein .5s;-webkit-backface-visibility:hidden;position:fixed;background:rgba(0,0,0,.4);top:0;right:0;bottom:0;left:0}.vex.vex-closing .vex-overlay{animation:vex-fadeout .5s;-webkit-animation:vex-fadeout .5s;-moz-animation:vex-fadeout .5s;-ms-animation:vex-fadeout .5s;-o-animation:vex-fadeout .5s;-webkit-backface-visibility:hidden}.vex-content{animation:vex-fadein .5s;-webkit-animation:vex-fadein .5s;-moz-animation:vex-fadein .5s;-ms-animation:vex-fadein .5s;-o-animation:vex-fadein .5s;-webkit-backface-visibility:hidden;background:#fff}.vex.vex-closing .vex-content{animation:vex-fadeout .5s;-webkit-animation:vex-fadeout .5s;-moz-animation:vex-fadeout .5s;-ms-animation:vex-fadeout .5s;-o-animation:vex-fadeout .5s;-webkit-backface-visibility:hidden}.vex-close:before{font-family:Arial,sans-serif;content:"\D7"}.vex-dialog-form{margin:0}.vex-dialog-button{text-rendering:optimizeLegibility;-moz-appearance:none;-webkit-appearance:none;cursor:pointer;-webkit-tap-highlight-color:transparent}.vex-loading-spinner{animation:vex-rotation .7s linear infinite;-webkit-animation:vex-rotation .7s linear infinite;-moz-animation:vex-rotation .7s linear infinite;-ms-animation:vex-rotation .7s linear infinite;-o-animation:vex-rotation .7s linear infinite;-webkit-backface-visibility:hidden;-moz-box-shadow:0 0 1em rgba(0,0,0,.1);-webkit-box-shadow:0 0 1em rgba(0,0,0,.1);box-shadow:0 0 1em rgba(0,0,0,.1);position:fixed;z-index:1112;margin:auto;top:0;right:0;bottom:0;left:0;height:2em;width:2em;background:#fff}body.vex-open{overflow:hidden}@keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-webkit-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-moz-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-ms-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}@-o-keyframes vex-pulse{0%{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}70%{-moz-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);-webkit-box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25);box-shadow:inset 0 0 0 300px hsla(0,0%,100%,.25)}to{-moz-box-shadow:inset 0 0 0 300px transparent;-webkit-box-shadow:inset 0 0 0 300px transparent;box-shadow:inset 0 0 0 300px transparent}}.vex.vex-theme-plain{padding-top:160px;padding-bottom:160px}.vex.vex-theme-plain .vex-content{font-family:Helvetica Neue,sans-serif;background:#fff;color:#444;padding:1em;position:relative;margin:0 auto;max-width:100%;width:450px;font-size:1.1em;line-height:1.5em}.vex.vex-theme-plain .vex-content h1,.vex.vex-theme-plain .vex-content h2,.vex.vex-theme-plain .vex-content h3,.vex.vex-theme-plain .vex-content h4,.vex.vex-theme-plain .vex-content h5,.vex.vex-theme-plain .vex-content h6,.vex.vex-theme-plain .vex-content li,.vex.vex-theme-plain .vex-content p,.vex.vex-theme-plain .vex-content ul{color:inherit}.vex.vex-theme-plain .vex-close{position:absolute;top:0;right:0;cursor:pointer}.vex.vex-theme-plain .vex-close:before{position:absolute;content:"\D7";font-size:26px;font-weight:400;line-height:31px;height:30px;width:30px;text-align:center;top:3px;right:3px;color:#bbb;background:transparent}.vex.vex-theme-plain .vex-close:active:before,.vex.vex-theme-plain .vex-close:hover:before{color:#777;background:#e0e0e0}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-message{margin-bottom:.5em}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input{margin-bottom:1em}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=date],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime-local],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=email],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=month],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=number],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=password],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=search],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=tel],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=text],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=time],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=url],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=week],.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input select,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input textarea{background:#f0f0f0;width:100%;padding:.25em .67em;border:0;font-family:inherit;font-weight:inherit;font-size:inherit;min-height:2.5em;margin:0 0 .25em}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=date]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime-local]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=datetime]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=email]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=month]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=number]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=password]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=search]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=tel]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=text]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=time]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=url]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input input[type=week]:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input select:focus,.vex.vex-theme-plain .vex-dialog-form .vex-dialog-input textarea:focus{-moz-box-shadow:inset 0 0 0 2px rgba(0,0,0,.2);-webkit-box-shadow:inset 0 0 0 2px rgba(0,0,0,.2);box-shadow:inset 0 0 0 2px rgba(0,0,0,.2);outline:none}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-buttons{*zoom:1}.vex.vex-theme-plain .vex-dialog-form .vex-dialog-buttons:after{content:"";display:table;clear:both}.vex.vex-theme-plain .vex-dialog-button{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border:0;float:right;margin:0 0 0 .5em;font-family:inherit;text-transform:uppercase;letter-spacing:.1em;font-size:.8em;line-height:1em;padding:.75em 2em}.vex.vex-theme-plain .vex-dialog-button.vex-last{margin-left:0}.vex.vex-theme-plain .vex-dialog-button:focus{animation:vex-pulse 1.1s infinite;-webkit-animation:vex-pulse 1.1s infinite;-moz-animation:vex-pulse 1.1s infinite;-ms-animation:vex-pulse 1.1s infinite;-o-animation:vex-pulse 1.1s infinite;-webkit-backface-visibility:hidden;outline:none}@media (max-width:568px){.vex.vex-theme-plain .vex-dialog-button:focus{animation:none;-webkit-animation:none;-moz-animation:none;-ms-animation:none;-o-animation:none;-webkit-backface-visibility:hidden}}.vex.vex-theme-plain .vex-dialog-button.vex-dialog-button-primary{background:#3288e6;color:#fff}.vex.vex-theme-plain .vex-dialog-button.vex-dialog-button-secondary{background:#e0e0e0;color:#777}.vex-loading-spinner.vex-theme-plain{height:2.5em;width:2.5em}.ta_migrate_old_data-row .forminp-migration_controls #ta_migrate_old_data{float:left;cursor:pointer;text-decoration:none;outline:none}.ta_migrate_old_data-row .forminp-migration_controls .spinner,.ta_migrate_old_data-row .forminp-migration_controls .status{float:left;display:inline-block;visibility:hidden}.ta_migrate_old_data-row .forminp-migration_controls.-processing .spinner,.ta_migrate_old_data-row .forminp-migration_controls.-processing .status{visibility:visible}
js/app/migration/dist/migration.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=5)}([function(e,t,n){"use strict";(function(e){var n,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!
2
+ * jQuery JavaScript Library v3.2.1
3
+ * https://jquery.com/
4
+ *
5
+ * Includes Sizzle.js
6
+ * https://sizzlejs.com/
7
+ *
8
+ * Copyright JS Foundation and other contributors
9
+ * Released under the MIT license
10
+ * https://jquery.org/license
11
+ *
12
+ * Date: 2017-03-20T18:59Z
13
+ */
14
+ !function(t,n){"object"===i(e)&&"object"===i(e.exports)?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:void 0,function(o,a){function s(e,t){t=t||se;var n=t.createElement("script");n.text=e,t.head.appendChild(n).parentNode.removeChild(n)}function u(e){var t=!!e&&"length"in e&&e.length,n=be.type(e);return"function"!==n&&!be.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function l(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function c(e,t,n){return be.isFunction(t)?be.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?be.grep(e,function(e){return e===t!==n}):"string"!=typeof t?be.grep(e,function(e){return de.call(t,e)>-1!==n}):Ae.test(t)?be.filter(t,e,n):(t=be.filter(t,e),be.grep(e,function(e){return de.call(t,e)>-1!==n&&1===e.nodeType}))}function f(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function d(e){var t={};return be.each(e.match(He)||[],function(e,n){t[n]=!0}),t}function p(e){return e}function h(e){throw e}function g(e,t,n,r){var i;try{e&&be.isFunction(i=e.promise)?i.call(e).done(t).fail(n):e&&be.isFunction(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}function v(){se.removeEventListener("DOMContentLoaded",v),o.removeEventListener("load",v),be.ready()}function m(){this.expando=be.expando+m.uid++}function y(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:We.test(e)?JSON.parse(e):e)}function b(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace($e,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=y(n)}catch(e){}Ie.set(e,t,n)}else n=void 0;return n}function x(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return be.css(e,t,"")},u=s(),l=n&&n[3]||(be.cssNumber[t]?"":"px"),c=(be.cssNumber[t]||"px"!==l&&+u)&&ze.exec(be.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do{o=o||".5",c/=o,be.style(e,t,c+l)}while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function w(e){var t,n=e.ownerDocument,r=e.nodeName,i=Ye[r];return i||(t=n.body.appendChild(n.createElement(r)),i=be.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),Ye[r]=i,i)}function C(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)r=e[o],r.style&&(n=r.style.display,t?("none"===n&&(i[o]=Re.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&Xe(r)&&(i[o]=w(r))):"none"!==n&&(i[o]="none",Re.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}function T(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&l(e,t)?be.merge([e],n):n}function E(e,t){for(var n=0,r=e.length;n<r;n++)Re.set(e[n],"globalEval",!t||Re.get(t[n],"globalEval"))}function k(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),d=[],p=0,h=e.length;p<h;p++)if((o=e[p])||0===o)if("object"===be.type(o))be.merge(d,o.nodeType?[o]:o);else if(Ze.test(o)){for(a=a||f.appendChild(t.createElement("div")),s=(Qe.exec(o)||["",""])[1].toLowerCase(),u=Ke[s]||Ke._default,a.innerHTML=u[1]+be.htmlPrefilter(o)+u[2],c=u[0];c--;)a=a.lastChild;be.merge(d,a.childNodes),a=f.firstChild,a.textContent=""}else d.push(t.createTextNode(o));for(f.textContent="",p=0;o=d[p++];)if(r&&be.inArray(o,r)>-1)i&&i.push(o);else if(l=be.contains(o.ownerDocument,o),a=T(f.appendChild(o),"script"),l&&E(a),n)for(c=0;o=a[c++];)Je.test(o.type||"")&&n.push(o);return f}function S(){return!0}function N(){return!1}function j(){try{return se.activeElement}catch(e){}}function A(e,t,n,r,o,a){var s,u;if("object"===(void 0===t?"undefined":i(t))){"string"!=typeof n&&(r=r||n,n=void 0);for(u in t)A(e,u,n,r,t[u],a);return e}if(null==r&&null==o?(o=n,r=n=void 0):null==o&&("string"==typeof n?(o=r,r=void 0):(o=r,r=n,n=void 0)),!1===o)o=N;else if(!o)return e;return 1===a&&(s=o,o=function(e){return be().off(e),s.apply(this,arguments)},o.guid=s.guid||(s.guid=be.guid++)),e.each(function(){be.event.add(this,t,o,r,n)})}function L(e,t){return l(e,"table")&&l(11!==t.nodeType?t:t.firstChild,"tr")?be(">tbody",e)[0]||e:e}function D(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function O(e){var t=st.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function q(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Re.hasData(e)&&(o=Re.access(e),a=Re.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)be.event.add(t,i,l[i][n])}Ie.hasData(e)&&(s=Ie.access(e),u=be.extend({},s),Ie.set(t,u))}}function H(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Ge.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function P(e,t,n,r){t=ce.apply([],t);var i,o,a,u,l,c,f=0,d=e.length,p=d-1,h=t[0],g=be.isFunction(h);if(g||d>1&&"string"==typeof h&&!ye.checkClone&&at.test(h))return e.each(function(i){var o=e.eq(i);g&&(t[0]=h.call(this,i,o.html())),P(o,t,n,r)});if(d&&(i=k(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(a=be.map(T(i,"script"),D),u=a.length;f<d;f++)l=i,f!==p&&(l=be.clone(l,!0,!0),u&&be.merge(a,T(l,"script"))),n.call(e[f],l,f);if(u)for(c=a[a.length-1].ownerDocument,be.map(a,O),f=0;f<u;f++)l=a[f],Je.test(l.type||"")&&!Re.access(l,"globalEval")&&be.contains(c,l)&&(l.src?be._evalUrl&&be._evalUrl(l.src):s(l.textContent.replace(ut,""),c))}return e}function F(e,t,n){for(var r,i=t?be.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||be.cleanData(T(r)),r.parentNode&&(n&&be.contains(r.ownerDocument,r)&&E(T(r,"script")),r.parentNode.removeChild(r));return e}function _(e,t,n){var r,i,o,a,s=e.style;return n=n||ft(e),n&&(a=n.getPropertyValue(t)||n[t],""!==a||be.contains(e.ownerDocument,e)||(a=be.style(e,t)),!ye.pixelMarginRight()&&ct.test(a)&&lt.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function M(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function R(e){if(e in mt)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=vt.length;n--;)if((e=vt[n]+t)in mt)return e}function I(e){var t=be.cssProps[e];return t||(t=be.cssProps[e]=R(e)||e),t}function W(e,t,n){var r=ze.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function $(e,t,n,r,i){var o,a=0;for(o=n===(r?"border":"content")?4:"width"===t?1:0;o<4;o+=2)"margin"===n&&(a+=be.css(e,n+Ue[o],!0,i)),r?("content"===n&&(a-=be.css(e,"padding"+Ue[o],!0,i)),"margin"!==n&&(a-=be.css(e,"border"+Ue[o]+"Width",!0,i))):(a+=be.css(e,"padding"+Ue[o],!0,i),"padding"!==n&&(a+=be.css(e,"border"+Ue[o]+"Width",!0,i)));return a}function B(e,t,n){var r,i=ft(e),o=_(e,t,i),a="border-box"===be.css(e,"boxSizing",!1,i);return ct.test(o)?o:(r=a&&(ye.boxSizingReliable()||o===e.style[t]),"auto"===o&&(o=e["offset"+t[0].toUpperCase()+t.slice(1)]),(o=parseFloat(o)||0)+$(e,t,n||(a?"border":"content"),r,i)+"px")}function z(e,t,n,r,i){return new z.prototype.init(e,t,n,r,i)}function U(){bt&&(!1===se.hidden&&o.requestAnimationFrame?o.requestAnimationFrame(U):o.setTimeout(U,be.fx.interval),be.fx.tick())}function X(){return o.setTimeout(function(){yt=void 0}),yt=be.now()}function V(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)n=Ue[r],i["margin"+n]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function Y(e,t,n){for(var r,i=(J.tweeners[t]||[]).concat(J.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function G(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,d=this,p={},h=e.style,g=e.nodeType&&Xe(e),v=Re.get(e,"fxshow");n.queue||(a=be._queueHooks(e,"fx"),null==a.unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,d.always(function(){d.always(function(){a.unqueued--,be.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],xt.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}p[r]=v&&v[r]||be.style(e,r)}if((u=!be.isEmptyObject(t))||!be.isEmptyObject(p)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],l=v&&v.display,null==l&&(l=Re.get(e,"display")),c=be.css(e,"display"),"none"===c&&(l?c=l:(C([e],!0),l=e.style.display||l,c=be.css(e,"display"),C([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===be.css(e,"float")&&(u||(d.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",d.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in p)u||(v?"hidden"in v&&(g=v.hidden):v=Re.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&C([e],!0),d.done(function(){g||C([e]),Re.remove(e,"fxshow");for(r in p)be.style(e,r,p[r])})),u=Y(g?v[r]:0,r,d),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}}function Q(e,t){var n,r,i,o,a;for(n in e)if(r=be.camelCase(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=be.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function J(e,t,n){var r,i,o=0,a=J.prefilters.length,s=be.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=yt||X(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;a<u;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),o<1&&u?n:(u||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:be.extend({},t),opts:be.extend(!0,{specialEasing:{},easing:be.easing._default},n),originalProperties:t,originalOptions:n,startTime:yt||X(),duration:n.duration,tweens:[],createTween:function(t,n){var r=be.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(Q(c,l.opts.specialEasing);o<a;o++)if(r=J.prefilters[o].call(l,e,c,l.opts))return be.isFunction(r.stop)&&(be._queueHooks(l.elem,l.opts.queue).stop=be.proxy(r.stop,r)),r;return be.map(c,Y,l),be.isFunction(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),be.fx.timer(be.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}function K(e){return(e.match(He)||[]).join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ee(e,t,n,r){var o;if(Array.isArray(t))be.each(t,function(t,o){n||Dt.test(e)?r(e,o):ee(e+"["+("object"===(void 0===o?"undefined":i(o))&&null!=o?t:"")+"]",o,n,r)});else if(n||"object"!==be.type(t))r(e,t);else for(o in t)ee(e+"["+o+"]",t[o],n,r)}function te(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(He)||[];if(be.isFunction(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ne(e,t,n,r){function i(s){var u;return o[s]=!0,be.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||a||o[l]?a?!(u=l):void 0:(t.dataTypes.unshift(l),i(l),!1)}),u}var o={},a=e===Bt;return i(t.dataTypes[0])||!o["*"]&&i("*")}function re(e,t){var n,r,i=be.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&be.extend(!0,e,r),e}function ie(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;"*"===u[0];)u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function oe(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if(s=i.split(" "),s[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}var ae=[],se=o.document,ue=Object.getPrototypeOf,le=ae.slice,ce=ae.concat,fe=ae.push,de=ae.indexOf,pe={},he=pe.toString,ge=pe.hasOwnProperty,ve=ge.toString,me=ve.call(Object),ye={},be=function e(t,n){return new e.fn.init(t,n)},xe=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,we=/^-ms-/,Ce=/-([a-z])/g,Te=function(e,t){return t.toUpperCase()};be.fn=be.prototype={jquery:"3.2.1",constructor:be,length:0,toArray:function(){return le.call(this)},get:function(e){return null==e?le.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=be.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return be.each(this,e)},map:function(e){return this.pushStack(be.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(le.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:fe,sort:ae.sort,splice:ae.splice},be.extend=be.fn.extend=function(){var e,t,n,r,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[u]||{},u++),"object"===(void 0===s?"undefined":i(s))||be.isFunction(s)||(s={}),u===l&&(s=this,u--);u<l;u++)if(null!=(e=arguments[u]))for(t in e)n=s[t],r=e[t],s!==r&&(c&&r&&(be.isPlainObject(r)||(o=Array.isArray(r)))?(o?(o=!1,a=n&&Array.isArray(n)?n:[]):a=n&&be.isPlainObject(n)?n:{},s[t]=be.extend(c,a,r)):void 0!==r&&(s[t]=r));return s},be.extend({expando:"jQuery"+("3.2.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return"function"===be.type(e)},isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){var t=be.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==he.call(e))&&(!(t=ue(e))||"function"==typeof(n=ge.call(t,"constructor")&&t.constructor)&&ve.call(n)===me)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},type:function(e){return null==e?e+"":"object"===(void 0===e?"undefined":i(e))||"function"==typeof e?pe[he.call(e)]||"object":void 0===e?"undefined":i(e)},globalEval:function(e){s(e)},camelCase:function(e){return e.replace(we,"ms-").replace(Ce,Te)},each:function(e,t){var n,r=0;if(u(e))for(n=e.length;r<n&&!1!==t.call(e[r],r,e[r]);r++);else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(xe,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(u(Object(e))?be.merge(n,"string"==typeof e?[e]:e):fe.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:de.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(u(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return ce.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),be.isFunction(e))return r=le.call(arguments,2),i=function(){return e.apply(t||this,r.concat(le.call(arguments)))},i.guid=e.guid=e.guid||be.guid++,i},now:Date.now,support:ye}),"function"==typeof Symbol&&(be.fn[Symbol.iterator]=ae[Symbol.iterator]),be.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){pe["[object "+t+"]"]=t.toLowerCase()});var Ee=/*!
15
+ * Sizzle CSS Selector Engine v2.3.3
16
+ * https://sizzlejs.com/
17
+ *
18
+ * Copyright jQuery Foundation and other contributors
19
+ * Released under the MIT license
20
+ * http://jquery.org/license
21
+ *
22
+ * Date: 2016-08-08
23
+ */
24
+ function(e){function t(e,t,n,r){var i,o,a,s,u,c,d,p=t&&t.ownerDocument,h=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==h&&9!==h&&11!==h)return n;if(!r&&((t?t.ownerDocument||t:R)!==D&&L(t),t=t||D,q)){if(11!==h&&(u=ge.exec(e)))if(i=u[1]){if(9===h){if(!(a=t.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(p&&(a=p.getElementById(i))&&_(t,a)&&a.id===i)return n.push(a),n}else{if(u[2])return Q.apply(n,t.getElementsByTagName(e)),n;if((i=u[3])&&x.getElementsByClassName&&t.getElementsByClassName)return Q.apply(n,t.getElementsByClassName(i)),n}if(x.qsa&&!z[e+" "]&&(!H||!H.test(e))){if(1!==h)p=t,d=e;else if("object"!==t.nodeName.toLowerCase()){for((s=t.getAttribute("id"))?s=s.replace(be,xe):t.setAttribute("id",s=M),c=E(e),o=c.length;o--;)c[o]="#"+s+" "+f(c[o]);d=c.join(","),p=ve.test(e)&&l(t.parentNode)||t}if(d)try{return Q.apply(n,p.querySelectorAll(d)),n}catch(e){}finally{s===M&&t.removeAttribute("id")}}}return S(e.replace(oe,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[M]=!0,e}function i(e){var t=D.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&Ce(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function u(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function l(e){return e&&void 0!==e.getElementsByTagName&&e}function c(){}function f(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function d(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=W++;return t.first?function(t,n,i){for(;t=t[r];)if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,d=[I,s];if(u){for(;t=t[r];)if((1===t.nodeType||a)&&e(t,n,u))return!0}else for(;t=t[r];)if(1===t.nodeType||a)if(f=t[M]||(t[M]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===I&&l[1]===s)return d[2]=l[2];if(c[o]=d,d[2]=e(t,n,u))return!0}return!1}}function p(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function h(e,n,r){for(var i=0,o=n.length;i<o;i++)t(e,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function v(e,t,n,i,o,a){return i&&!i[M]&&(i=v(i)),o&&!o[M]&&(o=v(o,a)),r(function(r,a,s,u){var l,c,f,d=[],p=[],v=a.length,m=r||h(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?m:g(m,d,e,s,u),b=n?o||(r?e:v||i)?[]:a:y;if(n&&n(y,b,s,u),i)for(l=g(b,p),i(l,[],s,u),c=l.length;c--;)(f=l[c])&&(b[p[c]]=!(y[p[c]]=f));if(r){if(o||e){if(o){for(l=[],c=b.length;c--;)(f=b[c])&&l.push(y[c]=f);o(null,b=[],l,u)}for(c=b.length;c--;)(f=b[c])&&(l=o?K(r,f):d[c])>-1&&(r[l]=!(a[l]=f))}}else b=g(b===a?b.splice(v,b.length):b),o?o(null,a,b,u):Q.apply(a,b)})}function m(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,u=d(function(e){return e===t},a,!0),l=d(function(e){return K(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==N)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s<i;s++)if(n=w.relative[e[s].type])c=[d(p(c),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[M]){for(r=++s;r<i&&!w.relative[e[r].type];r++);return v(s>1&&p(c),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(oe,"$1"),n,s<r&&m(e.slice(s,r)),r<i&&m(e=e.slice(r)),r<i&&f(e))}c.push(n)}return p(c)}function y(e,n){var i=n.length>0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",v=r&&[],m=[],y=N,b=r||o&&w.find.TAG("*",l),x=I+=null==y?1:Math.random()||.1,C=b.length;for(l&&(N=a===D||a||l);h!==C&&null!=(c=b[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===D||(L(c),s=!q);d=e[f++];)if(d(c,a||D,s)){u.push(c);break}l&&(I=x)}i&&((c=!d&&c)&&p--,r&&v.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(v,m,a,s);if(r){if(p>0)for(;h--;)v[h]||m[h]||(m[h]=Y.call(u));m=g(m)}Q.apply(u,m),l&&!r&&m.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(I=x,N=y),v};return i?r(a):a}var b,x,w,C,T,E,k,S,N,j,A,L,D,O,q,H,P,F,_,M="sizzle"+1*new Date,R=e.document,I=0,W=0,$=n(),B=n(),z=n(),U=function(e,t){return e===t&&(A=!0),0},X={}.hasOwnProperty,V=[],Y=V.pop,G=V.push,Q=V.push,J=V.slice,K=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},Z="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ee="[\\x20\\t\\r\\n\\f]",te="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",ne="\\["+ee+"*("+te+")(?:"+ee+"*([*^$|!~]?=)"+ee+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+te+"))|)"+ee+"*\\]",re=":("+te+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ne+")*)|.*)\\)|)",ie=new RegExp(ee+"+","g"),oe=new RegExp("^"+ee+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ee+"+$","g"),ae=new RegExp("^"+ee+"*,"+ee+"*"),se=new RegExp("^"+ee+"*([>+~]|"+ee+")"+ee+"*"),ue=new RegExp("="+ee+"*([^\\]'\"]*?)"+ee+"*\\]","g"),le=new RegExp(re),ce=new RegExp("^"+te+"$"),fe={ID:new RegExp("^#("+te+")"),CLASS:new RegExp("^\\.("+te+")"),TAG:new RegExp("^("+te+"|[*])"),ATTR:new RegExp("^"+ne),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ee+"*(even|odd|(([+-]|)(\\d*)n|)"+ee+"*(?:([+-]|)"+ee+"*(\\d+)|))"+ee+"*\\)|)","i"),bool:new RegExp("^(?:"+Z+")$","i"),needsContext:new RegExp("^"+ee+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ee+"*((?:-\\d)?\\d*)"+ee+"*\\)|)(?=[^-]|$)","i")},de=/^(?:input|select|textarea|button)$/i,pe=/^h\d$/i,he=/^[^{]+\{\s*\[native \w/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ve=/[+~]/,me=new RegExp("\\\\([\\da-f]{1,6}"+ee+"?|("+ee+")|.)","ig"),ye=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},be=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,xe=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},we=function(){L()},Ce=d(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{Q.apply(V=J.call(R.childNodes),R.childNodes),V[R.childNodes.length].nodeType}catch(e){Q={apply:V.length?function(e,t){G.apply(e,J.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}x=t.support={},T=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},L=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:R;return r!==D&&9===r.nodeType&&r.documentElement?(D=r,O=D.documentElement,q=!T(D),R!==D&&(n=D.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",we,!1):n.attachEvent&&n.attachEvent("onunload",we)),x.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),x.getElementsByTagName=i(function(e){return e.appendChild(D.createComment("")),!e.getElementsByTagName("*").length}),x.getElementsByClassName=he.test(D.getElementsByClassName),x.getById=i(function(e){return O.appendChild(e).id=M,!D.getElementsByName||!D.getElementsByName(M).length}),x.getById?(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){return e.getAttribute("id")===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&q){var n=t.getElementById(e);return n?[n]:[]}}):(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&q){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),w.find.TAG=x.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):x.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=x.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&q)return t.getElementsByClassName(e)},P=[],H=[],(x.qsa=he.test(D.querySelectorAll))&&(i(function(e){O.appendChild(e).innerHTML="<a id='"+M+"'></a><select id='"+M+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&H.push("[*^$]="+ee+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||H.push("\\["+ee+"*(?:value|"+Z+")"),e.querySelectorAll("[id~="+M+"-]").length||H.push("~="),e.querySelectorAll(":checked").length||H.push(":checked"),e.querySelectorAll("a#"+M+"+*").length||H.push(".#.+[+~]")}),i(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=D.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&H.push("name"+ee+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&H.push(":enabled",":disabled"),O.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&H.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),H.push(",.*:")})),(x.matchesSelector=he.test(F=O.matches||O.webkitMatchesSelector||O.mozMatchesSelector||O.oMatchesSelector||O.msMatchesSelector))&&i(function(e){x.disconnectedMatch=F.call(e,"*"),F.call(e,"[s!='']:x"),P.push("!=",re)}),H=H.length&&new RegExp(H.join("|")),P=P.length&&new RegExp(P.join("|")),t=he.test(O.compareDocumentPosition),_=t||he.test(O.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},U=t?function(e,t){if(e===t)return A=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!x.sortDetached&&t.compareDocumentPosition(e)===n?e===D||e.ownerDocument===R&&_(R,e)?-1:t===D||t.ownerDocument===R&&_(R,t)?1:j?K(j,e)-K(j,t):0:4&n?-1:1)}:function(e,t){if(e===t)return A=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===D?-1:t===D?1:i?-1:o?1:j?K(j,e)-K(j,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===R?-1:u[r]===R?1:0},D):D},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==D&&L(e),n=n.replace(ue,"='$1']"),x.matchesSelector&&q&&!z[n+" "]&&(!P||!P.test(n))&&(!H||!H.test(n)))try{var r=F.call(e,n);if(r||x.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return t(n,D,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==D&&L(e),_(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==D&&L(e);var n=w.attrHandle[t.toLowerCase()],r=n&&X.call(w.attrHandle,t.toLowerCase())?n(e,t,!q):void 0;return void 0!==r?r:x.attributes||!q?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.escape=function(e){return(e+"").replace(be,xe)},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(A=!x.detectDuplicates,j=!x.sortStable&&e.slice(0),e.sort(U),A){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return j=null,e},C=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=C(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=C(t);return n},w=t.selectors={cacheLength:50,createPseudo:r,match:fe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(me,ye),e[3]=(e[3]||e[4]||e[5]||"").replace(me,ye),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return fe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&le.test(n)&&(t=E(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(me,ye).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ee+")"+e+"("+ee+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ie," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,g=o!==a?"nextSibling":"previousSibling",v=t.parentNode,m=s&&t.nodeName.toLowerCase(),y=!u&&!s,b=!1;if(v){if(o){for(;g;){for(d=t;d=d[g];)if(s?d.nodeName.toLowerCase()===m:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?v.firstChild:v.lastChild],a&&y){for(d=v,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],b=p&&l[2],d=p&&v.childNodes[p];d=++p&&d&&d[g]||(b=p=0)||h.pop();)if(1===d.nodeType&&++b&&d===t){c[e]=[I,p,b];break}}else if(y&&(d=t,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],b=p),!1===b)for(;(d=++p&&d&&d[g]||(b=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==m:1!==d.nodeType)||!++b||(y&&(f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[I,b]),d!==t)););return(b-=i)===r||b%r==0&&b/r>=0}}},PSEUDO:function(e,n){var i,o=w.pseudos[e]||w.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[M]?o(n):o.length>1?(i=[e,e,"",n],w.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=K(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(oe,"$1"));return i[M]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(me,ye),function(t){return(t.textContent||t.innerText||C(t)).indexOf(e)>-1}}),lang:r(function(e){return ce.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(me,ye).toLowerCase(),function(t){var n;do{if(n=q?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===O},focus:function(e){return e===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:s(!1),disabled:s(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return pe.test(e.nodeName)},input:function(e){return de.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:u(function(){return[0]}),last:u(function(e,t){return[t-1]}),eq:u(function(e,t,n){return[n<0?n+t:n]}),even:u(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:u(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:u(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:u(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},w.pseudos.nth=w.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})w.pseudos[b]=function(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}(b);for(b in{submit:!0,reset:!0})w.pseudos[b]=function(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}(b);return c.prototype=w.filters=w.pseudos,w.setFilters=new c,E=t.tokenize=function(e,n){var r,i,o,a,s,u,l,c=B[e+" "];if(c)return n?0:c.slice(0);for(s=e,u=[],l=w.preFilter;s;){r&&!(i=ae.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),r=!1,(i=se.exec(s))&&(r=i.shift(),o.push({value:r,type:i[0].replace(oe," ")}),s=s.slice(r.length));for(a in w.filter)!(i=fe[a].exec(s))||l[a]&&!(i=l[a](i))||(r=i.shift(),o.push({value:r,type:a,matches:i}),s=s.slice(r.length));if(!r)break}return n?s.length:s?t.error(e):B(e,u).slice(0)},k=t.compile=function(e,t){var n,r=[],i=[],o=z[e+" "];if(!o){for(t||(t=E(e)),n=t.length;n--;)o=m(t[n]),o[M]?r.push(o):i.push(o);o=z(e,y(i,r)),o.selector=e}return o},S=t.select=function(e,t,n,r){var i,o,a,s,u,c="function"==typeof e&&e,d=!r&&E(e=c.selector||e);if(n=n||[],1===d.length){if(o=d[0]=d[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&9===t.nodeType&&q&&w.relative[o[1].type]){if(!(t=(w.find.ID(a.matches[0].replace(me,ye),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=fe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((u=w.find[s])&&(r=u(a.matches[0].replace(me,ye),ve.test(o[0].type)&&l(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&f(o)))return Q.apply(n,r),n;break}}return(c||k(e,d))(r,t,!q,n,!t||ve.test(e)&&l(t.parentNode)||t),n},x.sortStable=M.split("").sort(U).join("")===M,x.detectDuplicates=!!A,L(),x.sortDetached=i(function(e){return 1&e.compareDocumentPosition(D.createElement("fieldset"))}),i(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),x.attributes&&i(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(Z,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(o);be.find=Ee,be.expr=Ee.selectors,be.expr[":"]=be.expr.pseudos,be.uniqueSort=be.unique=Ee.uniqueSort,be.text=Ee.getText,be.isXMLDoc=Ee.isXML,be.contains=Ee.contains,be.escapeSelector=Ee.escape;var ke=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&be(e).is(n))break;r.push(e)}return r},Se=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},Ne=be.expr.match.needsContext,je=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,Ae=/^.[^:#\[\.,]*$/;be.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?be.find.matchesSelector(r,e)?[r]:[]:be.find.matches(e,be.grep(t,function(e){return 1===e.nodeType}))},be.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(be(e).filter(function(){for(t=0;t<r;t++)if(be.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)be.find(e,i[t],n);return r>1?be.uniqueSort(n):n},filter:function(e){return this.pushStack(c(this,e||[],!1))},not:function(e){return this.pushStack(c(this,e||[],!0))},is:function(e){return!!c(this,"string"==typeof e&&Ne.test(e)?be(e):e||[],!1).length}});var Le,De=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(be.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||Le,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:De.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof be?t[0]:t,be.merge(this,be.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:se,!0)),je.test(r[1])&&be.isPlainObject(t))for(r in t)be.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=se.getElementById(r[2]),i&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):be.isFunction(e)?void 0!==n.ready?n.ready(e):e(be):be.makeArray(e,this)}).prototype=be.fn,Le=be(se);var Oe=/^(?:parents|prev(?:Until|All))/,qe={children:!0,contents:!0,next:!0,prev:!0};be.fn.extend({has:function(e){var t=be(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(be.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&be(e);if(!Ne.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&be.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?be.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?de.call(be(e),this[0]):de.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(be.uniqueSort(be.merge(this.get(),be(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),be.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return ke(e,"parentNode")},parentsUntil:function(e,t,n){return ke(e,"parentNode",n)},next:function(e){return f(e,"nextSibling")},prev:function(e){return f(e,"previousSibling")},nextAll:function(e){return ke(e,"nextSibling")},prevAll:function(e){return ke(e,"previousSibling")},nextUntil:function(e,t,n){return ke(e,"nextSibling",n)},prevUntil:function(e,t,n){return ke(e,"previousSibling",n)},siblings:function(e){return Se((e.parentNode||{}).firstChild,e)},children:function(e){return Se(e.firstChild)},contents:function(e){return l(e,"iframe")?e.contentDocument:(l(e,"template")&&(e=e.content||e),be.merge([],e.childNodes))}},function(e,t){be.fn[e]=function(n,r){var i=be.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=be.filter(r,i)),this.length>1&&(qe[e]||be.uniqueSort(i),Oe.test(e)&&i.reverse()),this.pushStack(i)}});var He=/[^\x20\t\r\n\f]+/g;be.Callbacks=function(e){e="string"==typeof e?d(e):be.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1)for(n=a.shift();++s<o.length;)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1);e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){be.each(n,function(n,r){be.isFunction(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==be.type(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return be.each(arguments,function(e,t){for(var n;(n=be.inArray(t,o,n))>-1;)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?be.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},be.extend({Deferred:function(e){var t=[["notify","progress",be.Callbacks("memory"),be.Callbacks("memory"),2],["resolve","done",be.Callbacks("once memory"),be.Callbacks("once memory"),0,"resolved"],["reject","fail",be.Callbacks("once memory"),be.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return be.Deferred(function(n){be.each(t,function(t,r){var i=be.isFunction(e[r[4]])&&e[r[4]];a[r[1]](function(){var e=i&&i.apply(this,arguments);e&&be.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(e,n,r){function a(e,t,n,r){return function(){var u=this,l=arguments,c=function(){var o,c;if(!(e<s)){if((o=n.apply(u,l))===t.promise())throw new TypeError("Thenable self-resolution");c=o&&("object"===(void 0===o?"undefined":i(o))||"function"==typeof o)&&o.then,be.isFunction(c)?r?c.call(o,a(s,t,p,r),a(s,t,h,r)):(s++,c.call(o,a(s,t,p,r),a(s,t,h,r),a(s,t,p,t.notifyWith))):(n!==p&&(u=void 0,l=[o]),(r||t.resolveWith)(u,l))}},f=r?c:function(){try{c()}catch(r){be.Deferred.exceptionHook&&be.Deferred.exceptionHook(r,f.stackTrace),e+1>=s&&(n!==h&&(u=void 0,l=[r]),t.rejectWith(u,l))}};e?f():(be.Deferred.getStackHook&&(f.stackTrace=be.Deferred.getStackHook()),o.setTimeout(f))}}var s=0;return be.Deferred(function(i){t[0][3].add(a(0,i,be.isFunction(r)?r:p,i.notifyWith)),t[1][3].add(a(0,i,be.isFunction(e)?e:p)),t[2][3].add(a(0,i,be.isFunction(n)?n:h))}).promise()},promise:function(e){return null!=e?be.extend(e,r):r}},a={};return be.each(t,function(e,i){var o=i[2],s=i[5];r[i[1]]=o.add,s&&o.add(function(){n=s},t[3-e][2].disable,t[0][2].lock),o.add(i[3].fire),a[i[0]]=function(){return a[i[0]+"With"](this===a?void 0:this,arguments),this},a[i[0]+"With"]=o.fireWith}),r.promise(a),e&&e.call(a,a),a},when:function(e){var t=arguments.length,n=t,r=Array(n),i=le.call(arguments),o=be.Deferred(),a=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?le.call(arguments):n,--t||o.resolveWith(r,i)}};if(t<=1&&(g(e,o.done(a(n)).resolve,o.reject,!t),"pending"===o.state()||be.isFunction(i[n]&&i[n].then)))return o.then();for(;n--;)g(i[n],a(n),o.reject);return o.promise()}});var Pe=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;be.Deferred.exceptionHook=function(e,t){o.console&&o.console.warn&&e&&Pe.test(e.name)&&o.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},be.readyException=function(e){o.setTimeout(function(){throw e})};var Fe=be.Deferred();be.fn.ready=function(e){return Fe.then(e).catch(function(e){be.readyException(e)}),this},be.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--be.readyWait:be.isReady)||(be.isReady=!0,!0!==e&&--be.readyWait>0||Fe.resolveWith(se,[be]))}}),be.ready.then=Fe.then,"complete"===se.readyState||"loading"!==se.readyState&&!se.documentElement.doScroll?o.setTimeout(be.ready):(se.addEventListener("DOMContentLoaded",v),o.addEventListener("load",v));var _e=function e(t,n,r,i,o,a,s){var u=0,l=t.length,c=null==r;if("object"===be.type(r)){o=!0;for(u in r)e(t,n,u,r[u],!0,a,s)}else if(void 0!==i&&(o=!0,be.isFunction(i)||(s=!0),c&&(s?(n.call(t,i),n=null):(c=n,n=function(e,t,n){return c.call(be(e),n)})),n))for(;u<l;u++)n(t[u],r,s?i:i.call(t[u],u,n(t[u],r)));return o?t:c?n.call(t):l?n(t[0],r):a},Me=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};m.uid=1,m.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Me(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[be.camelCase(t)]=n;else for(r in t)i[be.camelCase(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][be.camelCase(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){Array.isArray(t)?t=t.map(be.camelCase):(t=be.camelCase(t),t=t in r?[t]:t.match(He)||[]),n=t.length;for(;n--;)delete r[t[n]]}(void 0===t||be.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!be.isEmptyObject(t)}};var Re=new m,Ie=new m,We=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,$e=/[A-Z]/g;be.extend({hasData:function(e){return Ie.hasData(e)||Re.hasData(e)},data:function(e,t,n){return Ie.access(e,t,n)},removeData:function(e,t){Ie.remove(e,t)},_data:function(e,t,n){return Re.access(e,t,n)},_removeData:function(e,t){Re.remove(e,t)}}),be.fn.extend({data:function(e,t){var n,r,o,a=this[0],s=a&&a.attributes;if(void 0===e){if(this.length&&(o=Ie.get(a),1===a.nodeType&&!Re.get(a,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&(r=s[n].name,0===r.indexOf("data-")&&(r=be.camelCase(r.slice(5)),b(a,r,o[r])));Re.set(a,"hasDataAttrs",!0)}return o}return"object"===(void 0===e?"undefined":i(e))?this.each(function(){Ie.set(this,e)}):_e(this,function(t){var n;if(a&&void 0===t){if(void 0!==(n=Ie.get(a,e)))return n;if(void 0!==(n=b(a,e)))return n}else this.each(function(){Ie.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Ie.remove(this,e)})}}),be.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Re.get(e,t),n&&(!r||Array.isArray(n)?r=Re.access(e,t,be.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=be.queue(e,t),r=n.length,i=n.shift(),o=be._queueHooks(e,t),a=function(){be.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Re.get(e,n)||Re.access(e,n,{empty:be.Callbacks("once memory").add(function(){Re.remove(e,[t+"queue",n])})})}}),be.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?be.queue(this[0],e):void 0===t?this:this.each(function(){var n=be.queue(this,e,t);be._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&be.dequeue(this,e)})},dequeue:function(e){return this.each(function(){be.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=be.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";a--;)(n=Re.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var Be=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,ze=new RegExp("^(?:([+-])=|)("+Be+")([a-z%]*)$","i"),Ue=["Top","Right","Bottom","Left"],Xe=function(e,t){return e=t||e,"none"===e.style.display||""===e.style.display&&be.contains(e.ownerDocument,e)&&"none"===be.css(e,"display")},Ve=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i},Ye={};be.fn.extend({show:function(){return C(this,!0)},hide:function(){return C(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Xe(this)?be(this).show():be(this).hide()})}});var Ge=/^(?:checkbox|radio)$/i,Qe=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,Je=/^$|\/(?:java|ecma)script/i,Ke={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ke.optgroup=Ke.option,Ke.tbody=Ke.tfoot=Ke.colgroup=Ke.caption=Ke.thead,Ke.th=Ke.td;var Ze=/<|&#?\w+;/;!function(){var e=se.createDocumentFragment(),t=e.appendChild(se.createElement("div")),n=se.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),ye.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",ye.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var et=se.documentElement,tt=/^key/,nt=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,rt=/^([^.]*)(?:\.(.+)|)/;be.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=Re.get(e);if(v)for(n.handler&&(o=n,n=o.handler,i=o.selector),i&&be.find.matchesSelector(et,i),n.guid||(n.guid=be.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(t){return void 0!==be&&be.event.triggered!==t.type?be.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(He)||[""],l=t.length;l--;)s=rt.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p&&(f=be.event.special[p]||{},p=(i?f.delegateType:f.bindType)||p,f=be.event.special[p]||{},c=be.extend({type:p,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&be.expr.match.needsContext.test(i),namespace:h.join(".")},o),(d=u[p])||(d=u[p]=[],d.delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(p,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),be.event.global[p]=!0)},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=Re.hasData(e)&&Re.get(e);if(v&&(u=v.events)){for(t=(t||"").match(He)||[""],l=t.length;l--;)if(s=rt.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p){for(f=be.event.special[p]||{},p=(r?f.delegateType:f.bindType)||p,d=u[p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=d.length;o--;)c=d[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,f.remove&&f.remove.call(e,c));a&&!d.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||be.removeEvent(e,p,v.handle),delete u[p])}else for(p in u)be.event.remove(e,p+t[l],n,r,!0);be.isEmptyObject(u)&&Re.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=be.event.fix(e),u=new Array(arguments.length),l=(Re.get(this,"events")||{})[s.type]||[],c=be.event.special[s.type]||{};for(u[0]=s,t=1;t<arguments.length;t++)u[t]=arguments[t];if(s.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,s)){for(a=be.event.handlers.call(this,s,l),t=0;(i=a[t++])&&!s.isPropagationStopped();)for(s.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!s.isImmediatePropagationStopped();)s.rnamespace&&!s.rnamespace.test(o.namespace)||(s.handleObj=o,s.data=o.data,void 0!==(r=((be.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,u))&&!1===(s.result=r)&&(s.preventDefault(),s.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,s),s.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)r=t[n],i=r.selector+" ",void 0===a[i]&&(a[i]=r.needsContext?be(i,this).index(l)>-1:be.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(be.Event.prototype,e,{enumerable:!0,configurable:!0,get:be.isFunction(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[be.expando]?e:new be.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==j()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===j()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&l(this,"input"))return this.click(),!1},_default:function(e){return l(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},be.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},be.Event=function(e,t){if(!(this instanceof be.Event))return new be.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?S:N,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&be.extend(this,t),this.timeStamp=e&&e.timeStamp||be.now(),this[be.expando]=!0},be.Event.prototype={constructor:be.Event,isDefaultPrevented:N,isPropagationStopped:N,isImmediatePropagationStopped:N,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=S,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=S,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=S,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},be.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&tt.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&nt.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},be.event.addProp),be.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){be.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||be.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),be.fn.extend({on:function(e,t,n,r){return A(this,e,t,n,r)},one:function(e,t,n,r){return A(this,e,t,n,r,1)},off:function(e,t,n){var r,o;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,be(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"===(void 0===e?"undefined":i(e))){for(o in e)this.off(o,t,e[o]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=N),this.each(function(){be.event.remove(this,e,n,t)})}});var it=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,ot=/<script|<style|<link/i,at=/checked\s*(?:[^=]|=\s*.checked.)/i,st=/^true\/(.*)/,ut=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;be.extend({htmlPrefilter:function(e){return e.replace(it,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=be.contains(e.ownerDocument,e);if(!(ye.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||be.isXMLDoc(e)))for(a=T(s),o=T(e),r=0,i=o.length;r<i;r++)H(o[r],a[r]);if(t)if(n)for(o=o||T(e),a=a||T(s),r=0,i=o.length;r<i;r++)q(o[r],a[r]);else q(e,s);return a=T(s,"script"),a.length>0&&E(a,!u&&T(e,"script")),s},cleanData:function(e){for(var t,n,r,i=be.event.special,o=0;void 0!==(n=e[o]);o++)if(Me(n)){if(t=n[Re.expando]){if(t.events)for(r in t.events)i[r]?be.event.remove(n,r):be.removeEvent(n,r,t.handle);n[Re.expando]=void 0}n[Ie.expando]&&(n[Ie.expando]=void 0)}}}),be.fn.extend({detach:function(e){return F(this,e,!0)},remove:function(e){return F(this,e)},text:function(e){return _e(this,function(e){return void 0===e?be.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return P(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){L(this,e).appendChild(e)}})},prepend:function(){return P(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=L(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return P(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return P(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(be.cleanData(T(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return be.clone(this,e,t)})},html:function(e){return _e(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!ot.test(e)&&!Ke[(Qe.exec(e)||["",""])[1].toLowerCase()]){e=be.htmlPrefilter(e);try{for(;n<r;n++)t=this[n]||{},1===t.nodeType&&(be.cleanData(T(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return P(this,arguments,function(t){var n=this.parentNode;be.inArray(this,e)<0&&(be.cleanData(T(this)),n&&n.replaceChild(t,this))},e)}}),be.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){be.fn[e]=function(e){for(var n,r=[],i=be(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),be(i[a])[t](n),fe.apply(r,n.get());return this.pushStack(r)}});var lt=/^margin/,ct=new RegExp("^("+Be+")(?!px)[a-z%]+$","i"),ft=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=o),t.getComputedStyle(e)};!function(){function e(){if(s){s.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",s.innerHTML="",et.appendChild(a);var e=o.getComputedStyle(s);t="1%"!==e.top,i="2px"===e.marginLeft,n="4px"===e.width,s.style.marginRight="50%",r="4px"===e.marginRight,et.removeChild(a),s=null}}var t,n,r,i,a=se.createElement("div"),s=se.createElement("div");s.style&&(s.style.backgroundClip="content-box",s.cloneNode(!0).style.backgroundClip="",ye.clearCloneStyle="content-box"===s.style.backgroundClip,a.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",a.appendChild(s),be.extend(ye,{pixelPosition:function(){return e(),t},boxSizingReliable:function(){return e(),n},pixelMarginRight:function(){return e(),r},reliableMarginLeft:function(){return e(),i}}))}();var dt=/^(none|table(?!-c[ea]).+)/,pt=/^--/,ht={position:"absolute",visibility:"hidden",display:"block"},gt={letterSpacing:"0",fontWeight:"400"},vt=["Webkit","Moz","ms"],mt=se.createElement("div").style;be.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=_(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=be.camelCase(t),l=pt.test(t),c=e.style;if(l||(t=I(u)),s=be.cssHooks[t]||be.cssHooks[u],void 0===n)return s&&"get"in s&&void 0!==(o=s.get(e,!1,r))?o:c[t];a=void 0===n?"undefined":i(n),"string"===a&&(o=ze.exec(n))&&o[1]&&(n=x(e,t,o),a="number"),null!=n&&n===n&&("number"===a&&(n+=o&&o[3]||(be.cssNumber[u]?"":"px")),ye.clearCloneStyle||""!==n||0!==t.indexOf("background")||(c[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,r))||(l?c.setProperty(t,n):c[t]=n))}},css:function(e,t,n,r){var i,o,a,s=be.camelCase(t);return pt.test(t)||(t=I(s)),a=be.cssHooks[t]||be.cssHooks[s],a&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=_(e,t,r)),"normal"===i&&t in gt&&(i=gt[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),be.each(["height","width"],function(e,t){be.cssHooks[t]={get:function(e,n,r){if(n)return!dt.test(be.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?B(e,t,r):Ve(e,ht,function(){return B(e,t,r)})},set:function(e,n,r){var i,o=r&&ft(e),a=r&&$(e,t,r,"border-box"===be.css(e,"boxSizing",!1,o),o);return a&&(i=ze.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=be.css(e,t)),W(e,n,a)}}}),be.cssHooks.marginLeft=M(ye.reliableMarginLeft,function(e,t){if(t)return(parseFloat(_(e,"marginLeft"))||e.getBoundingClientRect().left-Ve(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),be.each({margin:"",padding:"",border:"Width"},function(e,t){be.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+Ue[r]+t]=o[r]||o[r-2]||o[0];return i}},lt.test(e)||(be.cssHooks[e+t].set=W)}),be.fn.extend({css:function(e,t){return _e(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=ft(e),i=t.length;a<i;a++)o[t[a]]=be.css(e,t[a],!1,r);return o}return void 0!==n?be.style(e,t,n):be.css(e,t)},e,t,arguments.length>1)}}),be.Tween=z,z.prototype={constructor:z,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||be.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(be.cssNumber[n]?"":"px")},cur:function(){var e=z.propHooks[this.prop];return e&&e.get?e.get(this):z.propHooks._default.get(this)},run:function(e){var t,n=z.propHooks[this.prop];return this.options.duration?this.pos=t=be.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):z.propHooks._default.set(this),this}},z.prototype.init.prototype=z.prototype,z.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=be.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){be.fx.step[e.prop]?be.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[be.cssProps[e.prop]]&&!be.cssHooks[e.prop]?e.elem[e.prop]=e.now:be.style(e.elem,e.prop,e.now+e.unit)}}},z.propHooks.scrollTop=z.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},be.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},be.fx=z.prototype.init,be.fx.step={};var yt,bt,xt=/^(?:toggle|show|hide)$/,wt=/queueHooks$/;be.Animation=be.extend(J,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return x(n.elem,e,ze.exec(t),n),n}]},tweener:function(e,t){be.isFunction(e)?(t=e,e=["*"]):e=e.match(He);for(var n,r=0,i=e.length;r<i;r++)n=e[r],J.tweeners[n]=J.tweeners[n]||[],J.tweeners[n].unshift(t)},prefilters:[G],prefilter:function(e,t){t?J.prefilters.unshift(e):J.prefilters.push(e)}}),be.speed=function(e,t,n){var r=e&&"object"===(void 0===e?"undefined":i(e))?be.extend({},e):{complete:n||!n&&t||be.isFunction(e)&&e,duration:e,easing:n&&t||t&&!be.isFunction(t)&&t};return be.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in be.fx.speeds?r.duration=be.fx.speeds[r.duration]:r.duration=be.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){be.isFunction(r.old)&&r.old.call(this),r.queue&&be.dequeue(this,r.queue)},r},be.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Xe).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=be.isEmptyObject(e),o=be.speed(t,n,r),a=function(){var t=J(this,be.extend({},e),o);(i||Re.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=be.timers,a=Re.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&wt.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||be.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=Re.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=be.timers,a=r?r.length:0;for(n.finish=!0,be.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),be.each(["toggle","show","hide"],function(e,t){var n=be.fn[t];be.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(V(t,!0),e,r,i)}}),be.each({slideDown:V("show"),slideUp:V("hide"),slideToggle:V("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){be.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),be.timers=[],be.fx.tick=function(){var e,t=0,n=be.timers;for(yt=be.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||be.fx.stop(),yt=void 0},be.fx.timer=function(e){be.timers.push(e),be.fx.start()},be.fx.interval=13,be.fx.start=function(){bt||(bt=!0,U())},be.fx.stop=function(){bt=null},be.fx.speeds={slow:600,fast:200,_default:400},be.fn.delay=function(e,t){return e=be.fx?be.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=o.setTimeout(t,e);n.stop=function(){o.clearTimeout(r)}})},function(){var e=se.createElement("input"),t=se.createElement("select"),n=t.appendChild(se.createElement("option"));e.type="checkbox",ye.checkOn=""!==e.value,ye.optSelected=n.selected,e=se.createElement("input"),e.value="t",e.type="radio",ye.radioValue="t"===e.value}();var Ct,Tt=be.expr.attrHandle;be.fn.extend({attr:function(e,t){return _e(this,be.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){be.removeAttr(this,e)})}}),be.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?be.prop(e,t,n):(1===o&&be.isXMLDoc(e)||(i=be.attrHooks[t.toLowerCase()]||(be.expr.match.bool.test(t)?Ct:void 0)),void 0!==n?null===n?void be.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=be.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!ye.radioValue&&"radio"===t&&l(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(He);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),Ct={set:function(e,t,n){return!1===t?be.removeAttr(e,n):e.setAttribute(n,n),n}},be.each(be.expr.match.bool.source.match(/\w+/g),function(e,t){var n=Tt[t]||be.find.attr;Tt[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=Tt[a],Tt[a]=i,i=null!=n(e,t,r)?a:null,Tt[a]=o),i}});var Et=/^(?:input|select|textarea|button)$/i,kt=/^(?:a|area)$/i;be.fn.extend({prop:function(e,t){return _e(this,be.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[be.propFix[e]||e]})}}),be.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&be.isXMLDoc(e)||(t=be.propFix[t]||t,i=be.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=be.find.attr(e,"tabindex");return t?parseInt(t,10):Et.test(e.nodeName)||kt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),ye.optSelected||(be.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),be.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){be.propFix[this.toLowerCase()]=this}),be.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(be.isFunction(e))return this.each(function(t){be(this).addClass(e.call(this,t,Z(this)))});if("string"==typeof e&&e)for(t=e.match(He)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(be.isFunction(e))return this.each(function(t){be(this).removeClass(e.call(this,t,Z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(He)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=void 0===e?"undefined":i(e);return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):be.isFunction(e)?this.each(function(n){be(this).toggleClass(e.call(this,n,Z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=be(this),o=e.match(He)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=Z(this),t&&Re.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":Re.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+K(Z(n))+" ").indexOf(t)>-1)return!0;return!1}});var St=/\r/g;be.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=be.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,be(this).val()):e,null==i?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=be.map(i,function(e){return null==e?"":e+""})),(t=be.valHooks[this.type]||be.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=be.valHooks[i.type]||be.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(St,""):null==n?"":n)}}}),be.extend({valHooks:{option:{get:function(e){var t=be.find.attr(e,"value");return null!=t?t:K(be.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(n=i[r],(n.selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!l(n.parentNode,"optgroup"))){if(t=be(n).val(),a)return t;s.push(t)}return s},set:function(e,t){for(var n,r,i=e.options,o=be.makeArray(t),a=i.length;a--;)r=i[a],(r.selected=be.inArray(be.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),be.each(["radio","checkbox"],function(){be.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=be.inArray(be(e).val(),t)>-1}},ye.checkOn||(be.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Nt=/^(?:focusinfocus|focusoutblur)$/;be.extend(be.event,{trigger:function(e,t,n,r){var a,s,u,l,c,f,d,p=[n||se],h=ge.call(e,"type")?e.type:e,g=ge.call(e,"namespace")?e.namespace.split("."):[];if(s=u=n=n||se,3!==n.nodeType&&8!==n.nodeType&&!Nt.test(h+be.event.triggered)&&(h.indexOf(".")>-1&&(g=h.split("."),h=g.shift(),g.sort()),c=h.indexOf(":")<0&&"on"+h,e=e[be.expando]?e:new be.Event(h,"object"===(void 0===e?"undefined":i(e))&&e),e.isTrigger=r?2:3,e.namespace=g.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:be.makeArray(t,[e]),d=be.event.special[h]||{},r||!d.trigger||!1!==d.trigger.apply(n,t))){if(!r&&!d.noBubble&&!be.isWindow(n)){for(l=d.delegateType||h,Nt.test(l+h)||(s=s.parentNode);s;s=s.parentNode)p.push(s),u=s;u===(n.ownerDocument||se)&&p.push(u.defaultView||u.parentWindow||o)}for(a=0;(s=p[a++])&&!e.isPropagationStopped();)e.type=a>1?l:d.bindType||h,f=(Re.get(s,"events")||{})[e.type]&&Re.get(s,"handle"),f&&f.apply(s,t),(f=c&&s[c])&&f.apply&&Me(s)&&(e.result=f.apply(s,t),!1===e.result&&e.preventDefault());return e.type=h,r||e.isDefaultPrevented()||d._default&&!1!==d._default.apply(p.pop(),t)||!Me(n)||c&&be.isFunction(n[h])&&!be.isWindow(n)&&(u=n[c],u&&(n[c]=null),be.event.triggered=h,n[h](),be.event.triggered=void 0,u&&(n[c]=u)),e.result}},simulate:function(e,t,n){var r=be.extend(new be.Event,n,{type:e,isSimulated:!0});be.event.trigger(r,null,t)}}),be.fn.extend({trigger:function(e,t){return this.each(function(){be.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return be.event.trigger(e,t,n,!0)}}),be.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){be.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),be.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),ye.focusin="onfocusin"in o,ye.focusin||be.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){be.event.simulate(t,e.target,be.event.fix(e))};be.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=Re.access(r,t);i||r.addEventListener(e,n,!0),Re.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=Re.access(r,t)-1;i?Re.access(r,t,i):(r.removeEventListener(e,n,!0),Re.remove(r,t))}}});var jt=o.location,At=be.now(),Lt=/\?/;be.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new o.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||be.error("Invalid XML: "+e),t};var Dt=/\[\]$/,Ot=/\r?\n/g,qt=/^(?:submit|button|image|reset|file)$/i,Ht=/^(?:input|select|textarea|keygen)/i;be.param=function(e,t){var n,r=[],i=function(e,t){var n=be.isFunction(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!be.isPlainObject(e))be.each(e,function(){i(this.name,this.value)});else for(n in e)ee(n,e[n],t,i);return r.join("&")},be.fn.extend({serialize:function(){return be.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=be.prop(this,"elements");return e?be.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!be(this).is(":disabled")&&Ht.test(this.nodeName)&&!qt.test(e)&&(this.checked||!Ge.test(e))}).map(function(e,t){var n=be(this).val();return null==n?null:Array.isArray(n)?be.map(n,function(e){return{name:t.name,value:e.replace(Ot,"\r\n")}}):{name:t.name,value:n.replace(Ot,"\r\n")}}).get()}});var Pt=/%20/g,Ft=/#.*$/,_t=/([?&])_=[^&]*/,Mt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Rt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,It=/^(?:GET|HEAD)$/,Wt=/^\/\//,$t={},Bt={},zt="*/".concat("*"),Ut=se.createElement("a");Ut.href=jt.href,be.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:jt.href,type:"GET",isLocal:Rt.test(jt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":zt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":be.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?re(re(e,be.ajaxSettings),t):re(be.ajaxSettings,e)},ajaxPrefilter:te($t),ajaxTransport:te(Bt),ajax:function(e,t){function n(e,t,n,i){var u,c,p,h,w,C=t;f||(f=!0,l&&o.clearTimeout(l),r=void 0,s=i||"",E.readyState=e>0?4:0,u=e>=200&&e<300||304===e,n&&(h=ie(g,E,n)),h=oe(g,h,E,u),u?(g.ifModified&&(w=E.getResponseHeader("Last-Modified"),w&&(be.lastModified[a]=w),(w=E.getResponseHeader("etag"))&&(be.etag[a]=w)),204===e||"HEAD"===g.type?C="nocontent":304===e?C="notmodified":(C=h.state,c=h.data,p=h.error,u=!p)):(p=C,!e&&C||(C="error",e<0&&(e=0))),E.status=e,E.statusText=(t||C)+"",u?y.resolveWith(v,[c,C,E]):y.rejectWith(v,[E,C,p]),E.statusCode(x),x=void 0,d&&m.trigger(u?"ajaxSuccess":"ajaxError",[E,g,u?c:p]),b.fireWith(v,[E,C]),d&&(m.trigger("ajaxComplete",[E,g]),--be.active||be.event.trigger("ajaxStop")))}"object"===(void 0===e?"undefined":i(e))&&(t=e,e=void 0),t=t||{};var r,a,s,u,l,c,f,d,p,h,g=be.ajaxSetup({},t),v=g.context||g,m=g.context&&(v.nodeType||v.jquery)?be(v):be.event,y=be.Deferred(),b=be.Callbacks("once memory"),x=g.statusCode||{},w={},C={},T="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(f){if(!u)for(u={};t=Mt.exec(s);)u[t[1].toLowerCase()]=t[2];t=u[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return f?s:null},setRequestHeader:function(e,t){return null==f&&(e=C[e.toLowerCase()]=C[e.toLowerCase()]||e,w[e]=t),this},overrideMimeType:function(e){return null==f&&(g.mimeType=e),this},statusCode:function(e){var t;if(e)if(f)E.always(e[E.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||T;return r&&r.abort(t),n(0,t),this}};if(y.promise(E),g.url=((e||g.url||jt.href)+"").replace(Wt,jt.protocol+"//"),g.type=t.method||t.type||g.method||g.type,g.dataTypes=(g.dataType||"*").toLowerCase().match(He)||[""],null==g.crossDomain){c=se.createElement("a");try{c.href=g.url,c.href=c.href,g.crossDomain=Ut.protocol+"//"+Ut.host!=c.protocol+"//"+c.host}catch(e){g.crossDomain=!0}}if(g.data&&g.processData&&"string"!=typeof g.data&&(g.data=be.param(g.data,g.traditional)),ne($t,g,t,E),f)return E;d=be.event&&g.global,d&&0==be.active++&&be.event.trigger("ajaxStart"),g.type=g.type.toUpperCase(),g.hasContent=!It.test(g.type),a=g.url.replace(Ft,""),g.hasContent?g.data&&g.processData&&0===(g.contentType||"").indexOf("application/x-www-form-urlencoded")&&(g.data=g.data.replace(Pt,"+")):(h=g.url.slice(a.length),g.data&&(a+=(Lt.test(a)?"&":"?")+g.data,delete g.data),!1===g.cache&&(a=a.replace(_t,"$1"),h=(Lt.test(a)?"&":"?")+"_="+At+++h),g.url=a+h),g.ifModified&&(be.lastModified[a]&&E.setRequestHeader("If-Modified-Since",be.lastModified[a]),be.etag[a]&&E.setRequestHeader("If-None-Match",be.etag[a])),(g.data&&g.hasContent&&!1!==g.contentType||t.contentType)&&E.setRequestHeader("Content-Type",g.contentType),E.setRequestHeader("Accept",g.dataTypes[0]&&g.accepts[g.dataTypes[0]]?g.accepts[g.dataTypes[0]]+("*"!==g.dataTypes[0]?", "+zt+"; q=0.01":""):g.accepts["*"]);for(p in g.headers)E.setRequestHeader(p,g.headers[p]);if(g.beforeSend&&(!1===g.beforeSend.call(v,E,g)||f))return E.abort();if(T="abort",b.add(g.complete),E.done(g.success),E.fail(g.error),r=ne(Bt,g,t,E)){if(E.readyState=1,d&&m.trigger("ajaxSend",[E,g]),f)return E;g.async&&g.timeout>0&&(l=o.setTimeout(function(){E.abort("timeout")},g.timeout));try{f=!1,r.send(w,n)}catch(e){if(f)throw e;n(-1,e)}}else n(-1,"No Transport");return E},getJSON:function(e,t,n){return be.get(e,t,n,"json")},getScript:function(e,t){return be.get(e,void 0,t,"script")}}),be.each(["get","post"],function(e,t){be[t]=function(e,n,r,i){return be.isFunction(n)&&(i=i||r,r=n,n=void 0),be.ajax(be.extend({url:e,type:t,dataType:i,data:n,success:r},be.isPlainObject(e)&&e))}}),be._evalUrl=function(e){return be.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},be.fn.extend({wrapAll:function(e){var t;return this[0]&&(be.isFunction(e)&&(e=e.call(this[0])),t=be(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return be.isFunction(e)?this.each(function(t){be(this).wrapInner(e.call(this,t))}):this.each(function(){var t=be(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=be.isFunction(e);return this.each(function(n){be(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){be(this).replaceWith(this.childNodes)}),this}}),be.expr.pseudos.hidden=function(e){return!be.expr.pseudos.visible(e)},be.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},be.ajaxSettings.xhr=function(){try{return new o.XMLHttpRequest}catch(e){}};var Xt={0:200,1223:204},Vt=be.ajaxSettings.xhr();ye.cors=!!Vt&&"withCredentials"in Vt,ye.ajax=Vt=!!Vt,be.ajaxTransport(function(e){var t,n;if(ye.cors||Vt&&!e.crossDomain)return{send:function(r,i){var a,s=e.xhr();if(s.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(a in e.xhrFields)s[a]=e.xhrFields[a];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),e.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(a in r)s.setRequestHeader(a,r[a]);t=function(e){return function(){t&&(t=n=s.onload=s.onerror=s.onabort=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?i(0,"error"):i(s.status,s.statusText):i(Xt[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=t(),n=s.onerror=t("error"),void 0!==s.onabort?s.onabort=n:s.onreadystatechange=function(){4===s.readyState&&o.setTimeout(function(){t&&n()})},t=t("abort");try{s.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),be.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),be.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return be.globalEval(e),e}}}),be.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),be.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=be("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),se.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Yt=[],Gt=/(=)\?(?=&|$)|\?\?/;be.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Yt.pop()||be.expando+"_"+At++;return this[e]=!0,e}}),be.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,a,s=!1!==e.jsonp&&(Gt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Gt.test(e.data)&&"data");if(s||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=be.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,s?e[s]=e[s].replace(Gt,"$1"+r):!1!==e.jsonp&&(e.url+=(Lt.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return a||be.error(r+" was not called"),a[0]},e.dataTypes[0]="json",i=o[r],o[r]=function(){a=arguments},n.always(function(){void 0===i?be(o).removeProp(r):o[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Yt.push(r)),a&&be.isFunction(i)&&i(a[0]),a=i=void 0}),"script"}),ye.createHTMLDocument=function(){var e=se.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),be.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var r,i,o;return t||(ye.createHTMLDocument?(t=se.implementation.createHTMLDocument(""),r=t.createElement("base"),r.href=se.location.href,t.head.appendChild(r)):t=se),i=je.exec(e),o=!n&&[],i?[t.createElement(i[1])]:(i=k([e],t,o),o&&o.length&&be(o).remove(),be.merge([],i.childNodes))},be.fn.load=function(e,t,n){var r,o,a,s=this,u=e.indexOf(" ");return u>-1&&(r=K(e.slice(u)),e=e.slice(0,u)),be.isFunction(t)?(n=t,t=void 0):t&&"object"===(void 0===t?"undefined":i(t))&&(o="POST"),s.length>0&&be.ajax({url:e,type:o||"GET",dataType:"html",data:t}).done(function(e){a=arguments,s.html(r?be("<div>").append(be.parseHTML(e)).find(r):e)}).always(n&&function(e,t){s.each(function(){n.apply(this,a||[e.responseText,t,e])})}),this},be.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){be.fn[t]=function(e){return this.on(t,e)}}),be.expr.pseudos.animated=function(e){return be.grep(be.timers,function(t){return e===t.elem}).length},be.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=be.css(e,"position"),f=be(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=be.css(e,"top"),u=be.css(e,"left"),l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),be.isFunction(t)&&(t=t.call(e,n,be.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},be.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){be.offset.setOffset(this,e,t)});var t,n,r,i,o=this[0];if(o)return o.getClientRects().length?(r=o.getBoundingClientRect(),t=o.ownerDocument,n=t.documentElement,i=t.defaultView,{top:r.top+i.pageYOffset-n.clientTop,left:r.left+i.pageXOffset-n.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n=this[0],r={top:0,left:0};return"fixed"===be.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),l(e[0],"html")||(r=e.offset()),r={top:r.top+be.css(e[0],"borderTopWidth",!0),left:r.left+be.css(e[0],"borderLeftWidth",!0)}),{top:t.top-r.top-be.css(n,"marginTop",!0),left:t.left-r.left-be.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===be.css(e,"position");)e=e.offsetParent;return e||et})}}),be.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;be.fn[e]=function(r){return _e(this,function(e,r,i){var o;if(be.isWindow(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),be.each(["top","left"],function(e,t){be.cssHooks[t]=M(ye.pixelPosition,function(e,n){if(n)return n=_(e,t),ct.test(n)?be(e).position()[t]+"px":n})}),be.each({Height:"height",Width:"width"},function(e,t){be.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){be.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return _e(this,function(t,n,i){var o;return be.isWindow(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?be.css(t,n,s):be.style(t,n,i,s)},t,a?i:void 0,a)}})}),be.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),be.holdReady=function(e){e?be.readyWait++:be.ready(!0)},be.isArray=Array.isArray,be.parseJSON=JSON.parse,be.nodeName=l,n=[],void 0!==(r=function(){return be}.apply(t,n))&&(e.exports=r);var Qt=o.jQuery,Jt=o.$;return be.noConflict=function(e){return o.$===be&&(o.$=Jt),e&&o.jQuery===be&&(o.jQuery=Qt),be},a||(o.jQuery=o.$=be),be})}).call(t,n(4)(e))},function(e,t,n){"use strict";var r,i,o,a,a,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(n){if("object"===s(t)&&void 0!==e)e.exports=n();else{i=[],r=n,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}}(function(){return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var l="function"==typeof a&&a;if(!u&&l)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof a&&a,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){function r(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){var i=t.createElement("html");return i.innerHTML=e,i.removeChild(i.lastChild)}var o=a[r]||a._default,s=o[0],u=o[1],l=o[2],i=t.createElement("div");for(i.innerHTML=u+e+l;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var c=t.createDocumentFragment();i.firstChild;)c.appendChild(i.removeChild(i.firstChild));return c}t.exports=r;var i,o=!1;"undefined"!=typeof document&&(i=document.createElement("div"),i.innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',o=!i.getElementsByTagName("link").length,i=void 0);var a={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:o?[1,"X<div>","</div>"]:[0,"",""]};a.td=a.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],a.option=a.optgroup=[1,'<select multiple="multiple">',"</select>"],a.thead=a.tbody=a.colgroup=a.caption=a.tfoot=[1,"<table>","</table>"],a.polyline=a.ellipse=a.polygon=a.circle=a.text=a.line=a.path=a.rect=a.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],2:[function(e,t,n){function r(e,t){"object"!=(void 0===t?"undefined":s(t))?t={hash:!!t}:void 0===t.hash&&(t.hash=!0);for(var n=t.hash?{}:"",r=t.serializer||(t.hash?a:u),i=e&&e.elements?e.elements:[],o=Object.create(null),f=0;f<i.length;++f){var d=i[f];if((t.disabled||!d.disabled)&&d.name&&(c.test(d.nodeName)&&!l.test(d.type))){var p=d.name,h=d.value;if("checkbox"!==d.type&&"radio"!==d.type||d.checked||(h=void 0),t.empty){if("checkbox"!==d.type||d.checked||(h=""),"radio"===d.type&&(o[d.name]||d.checked?d.checked&&(o[d.name]=!0):o[d.name]=!1),!h&&"radio"==d.type)continue}else if(!h)continue;if("select-multiple"!==d.type)n=r(n,p,h);else{h=[];for(var g=d.options,v=!1,m=0;m<g.length;++m){var y=g[m],b=t.empty&&!y.value,x=y.value||b;y.selected&&x&&(v=!0,n=t.hash&&"[]"!==p.slice(p.length-2)?r(n,p+"[]",y.value):r(n,p,y.value))}!v&&t.empty&&(n=r(n,p,""))}}}if(t.empty)for(var p in o)o[p]||(n=r(n,p,""));return n}function i(e){var t=[],n=/^([^\[\]]*)/,r=new RegExp(f),i=n.exec(e);for(i[1]&&t.push(i[1]);null!==(i=r.exec(e));)t.push(i[1]);return t}function o(e,t,n){if(0===t.length)return e=n;var r=t.shift(),i=r.match(/^\[(.+?)\]$/);if("[]"===r)return e=e||[],Array.isArray(e)?e.push(o(null,t,n)):(e._values=e._values||[],e._values.push(o(null,t,n))),e;if(i){var a=i[1],s=+a;isNaN(s)?(e=e||{},e[a]=o(e[a],t,n)):(e=e||[],e[s]=o(e[s],t,n))}else e[r]=o(e[r],t,n);return e}function a(e,t,n){if(t.match(f))o(e,i(t),n);else{var r=e[t];r?(Array.isArray(r)||(e[t]=[r]),e[t].push(n)):e[t]=n}return e}function u(e,t,n){return n=n.replace(/(\r)?\n/g,"\r\n"),n=encodeURIComponent(n),n=n.replace(/%20/g,"+"),e+(e?"&":"")+encodeURIComponent(t)+"="+n}var l=/^(?:submit|button|image|reset|file)$/i,c=/^(?:input|select|textarea|keygen)/i,f=/(\[[^\[\]]*\])/g;t.exports=r},{}],3:[function(e,t,n){var r=e("domify"),i=e("form-serialize"),o=function(e){var t=document.createElement("form");t.classList.add("vex-dialog-form");var n=document.createElement("div");n.classList.add("vex-dialog-message"),n.appendChild(e.message instanceof window.Node?e.message:r(e.message));var i=document.createElement("div");return i.classList.add("vex-dialog-input"),i.appendChild(e.input instanceof window.Node?e.input:r(e.input)),t.appendChild(n),t.appendChild(i),t},a=function(e){var t=document.createElement("div");t.classList.add("vex-dialog-buttons");for(var n=0;n<e.length;n++){var r=e[n],i=document.createElement("button");i.type=r.type,i.textContent=r.text,i.className=r.className,i.classList.add("vex-dialog-button"),0===n?i.classList.add("vex-first"):n===e.length-1&&i.classList.add("vex-last"),function(e){i.addEventListener("click",function(t){e.click&&e.click.call(this,t)}.bind(this))}.bind(this)(r),t.appendChild(i)}return t},u=function(e){var t={name:"dialog",open:function(t){var n=Object.assign({},this.defaultOptions,t);n.unsafeMessage&&!n.message?n.message=n.unsafeMessage:n.message&&(n.message=e._escapeHtml(n.message));var r=n.unsafeContent=o(n),i=e.open(n),s=n.beforeClose&&n.beforeClose.bind(i);if(i.options.beforeClose=function(){var e=!s||s();return e&&n.callback(this.value||!1),e}.bind(i),r.appendChild(a.call(i,n.buttons)),i.form=r,r.addEventListener("submit",n.onSubmit.bind(i)),n.focusFirstInput){var u=i.contentEl.querySelector("button, input, select, textarea");u&&u.focus()}return i},alert:function(e){return"string"==typeof e&&(e={message:e}),e=Object.assign({},this.defaultOptions,this.defaultAlertOptions,e),this.open(e)},confirm:function(e){if("object"!==(void 0===e?"undefined":s(e))||"function"!=typeof e.callback)throw new Error("dialog.confirm(options) requires options.callback.");return e=Object.assign({},this.defaultOptions,this.defaultConfirmOptions,e),this.open(e)},prompt:function(t){if("object"!==(void 0===t?"undefined":s(t))||"function"!=typeof t.callback)throw new Error("dialog.prompt(options) requires options.callback.");var n=Object.assign({},this.defaultOptions,this.defaultPromptOptions),r={unsafeMessage:'<label for="vex">'+e._escapeHtml(t.label||n.label)+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+e._escapeHtml(t.placeholder||n.placeholder)+'" value="'+e._escapeHtml(t.value||n.value)+'" />'};t=Object.assign(n,r,t);var i=t.callback;return t.callback=function(e){if("object"===(void 0===e?"undefined":s(e))){var t=Object.keys(e);e=t.length?e[t[0]]:""}i(e)},this.open(t)}};return t.buttons={YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary",click:function(){this.value=!0}},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function(){this.value=!1,this.close()}}},t.defaultOptions={callback:function(){},afterOpen:function(){},message:"",input:"",buttons:[t.buttons.YES,t.buttons.NO],showCloseButton:!1,onSubmit:function(e){return e.preventDefault(),this.options.input&&(this.value=i(this.form,{hash:!0})),this.close()},focusFirstInput:!0},t.defaultAlertOptions={buttons:[t.buttons.YES]},t.defaultPromptOptions={label:"Prompt:",placeholder:"",value:""},t.defaultConfirmOptions={},t};t.exports=u},{domify:1,"form-serialize":2}]},{},[3])(3)})},function(e,t,n){"use strict";var r,i,o,a,a,s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(n){if("object"===s(t)&&void 0!==e)e.exports=n();else{i=[],r=n,void 0!==(o="function"==typeof r?r.apply(t,i):r)&&(e.exports=o)}}(function(){return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var l="function"==typeof a&&a;if(!u&&l)return a(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof a&&a,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
25
+ "document"in window.self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))?function(){var e=document.createElement("_");if(e.classList.add("c1","c2"),!e.classList.contains("c2")){var t=function(e){var t=DOMTokenList.prototype[e];DOMTokenList.prototype[e]=function(e){var n,r=arguments.length;for(n=0;n<r;n++)e=arguments[n],t.call(this,e)}};t("add"),t("remove")}if(e.classList.toggle("c3",!1),e.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:n.call(this,e)}}e=null}():function(e){if("Element"in e){var t=e.Element.prototype,n=Object,r=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},i=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1},o=function(e,t){this.name=e,this.code=DOMException[e],this.message=t},a=function(e,t){if(""===t)throw new o("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(t))throw new o("INVALID_CHARACTER_ERR","String contains an invalid character");return i.call(e,t)},s=function(e){for(var t=r.call(e.getAttribute("class")||""),n=t?t.split(/\s+/):[],i=0,o=n.length;i<o;i++)this.push(n[i]);this._updateClassName=function(){e.setAttribute("class",this.toString())}},u=s.prototype=[],l=function(){return new s(this)};if(o.prototype=Error.prototype,u.item=function(e){return this[e]||null},u.contains=function(e){return e+="",-1!==a(this,e)},u.add=function(){var e,t=arguments,n=0,r=t.length,i=!1;do{e=t[n]+"",-1===a(this,e)&&(this.push(e),i=!0)}while(++n<r);i&&this._updateClassName()},u.remove=function(){var e,t,n=arguments,r=0,i=n.length,o=!1;do{for(e=n[r]+"",t=a(this,e);-1!==t;)this.splice(t,1),o=!0,t=a(this,e)}while(++r<i);o&&this._updateClassName()},u.toggle=function(e,t){e+="";var n=this.contains(e),r=n?!0!==t&&"remove":!1!==t&&"add";return r&&this[r](e),!0===t||!1===t?t:!n},u.toString=function(){return this.join(" ")},n.defineProperty){var c={get:l,enumerable:!0,configurable:!0};try{n.defineProperty(t,"classList",c)}catch(e){-2146823252===e.number&&(c.enumerable=!1,n.defineProperty(t,"classList",c))}}else n.prototype.__defineGetter__&&t.__defineGetter__("classList",l)}}(window.self))},{}],2:[function(e,t,n){function r(e,t){if("string"!=typeof e)throw new TypeError("String expected");t||(t=document);var n=/<([\w:]+)/.exec(e);if(!n)return t.createTextNode(e);e=e.replace(/^\s+|\s+$/g,"");var r=n[1];if("body"==r){var i=t.createElement("html");return i.innerHTML=e,i.removeChild(i.lastChild)}var o=a[r]||a._default,s=o[0],u=o[1],l=o[2],i=t.createElement("div");for(i.innerHTML=u+e+l;s--;)i=i.lastChild;if(i.firstChild==i.lastChild)return i.removeChild(i.firstChild);for(var c=t.createDocumentFragment();i.firstChild;)c.appendChild(i.removeChild(i.firstChild));return c}t.exports=r;var i,o=!1;"undefined"!=typeof document&&(i=document.createElement("div"),i.innerHTML=' <link/><table></table><a href="/a">a</a><input type="checkbox"/>',o=!i.getElementsByTagName("link").length,i=void 0);var a={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:o?[1,"X<div>","</div>"]:[0,"",""]};a.td=a.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],a.option=a.optgroup=[1,'<select multiple="multiple">',"</select>"],a.thead=a.tbody=a.colgroup=a.caption=a.tfoot=[1,"<table>","</table>"],a.polyline=a.ellipse=a.polygon=a.circle=a.text=a.line=a.path=a.rect=a.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"]},{}],3:[function(e,t,n){function r(e,t){if(void 0===e||null===e)throw new TypeError("Cannot convert first argument to object");for(var n=Object(e),r=1;r<arguments.length;r++){var i=arguments[r];if(void 0!==i&&null!==i)for(var o=Object.keys(Object(i)),a=0,s=o.length;a<s;a++){var u=o[a],l=Object.getOwnPropertyDescriptor(i,u);void 0!==l&&l.enumerable&&(n[u]=i[u])}}return n}function i(){Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:r})}t.exports={assign:r,polyfill:i}},{}],4:[function(e,t,n){e("classlist-polyfill"),e("es6-object-assign").polyfill();var r=e("domify"),i=function(e){if(void 0!==e){var t=document.createElement("div");return t.appendChild(document.createTextNode(e)),t.innerHTML}return""},o=function(e,t){if("string"==typeof t&&0!==t.length)for(var n=t.split(" "),r=0;r<n.length;r++){var i=n[r];i.length&&e.classList.add(i)}},a=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",MozAnimation:"animationend",OAnimation:"oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(void 0!==e.style[n])return t[n];return!1}(),s={vex:"vex",content:"vex-content",overlay:"vex-overlay",close:"vex-close",closing:"vex-closing",open:"vex-open"},u={},l=1,c=!1,f={open:function(e){var t=function(e){console.warn('The "'+e+'" property is deprecated in vex 3. Use CSS classes and the appropriate "ClassName" options, instead.'),console.warn("See http://github.hubspot.com/vex/api/advanced/#options")};e.css&&t("css"),e.overlayCSS&&t("overlayCSS"),e.contentCSS&&t("contentCSS"),e.closeCSS&&t("closeCSS");var n={};n.id=l++,u[n.id]=n,n.isOpen=!0,n.close=function(){function e(e){return"none"!==n.getPropertyValue(e+"animation-name")&&"0s"!==n.getPropertyValue(e+"animation-duration")}if(!this.isOpen)return!0;var t=this.options;if(c&&!t.escapeButtonCloses)return!1;if(!1===function(){return!t.beforeClose||t.beforeClose.call(this)}.bind(this)())return!1;this.isOpen=!1;var n=window.getComputedStyle(this.contentEl),r=e("")||e("-webkit-")||e("-moz-")||e("-o-"),i=function e(){this.rootEl.parentNode&&(this.rootEl.removeEventListener(a,e),delete u[this.id],this.rootEl.parentNode.removeChild(this.rootEl),t.afterClose&&t.afterClose.call(this),0===Object.keys(u).length&&document.body.classList.remove(s.open))}.bind(this);return a&&r?(this.rootEl.addEventListener(a,i),this.rootEl.classList.add(s.closing)):i(),!0},"string"==typeof e&&(e={content:e}),e.unsafeContent&&!e.content?e.content=e.unsafeContent:e.content&&(e.content=i(e.content));var d=n.options=Object.assign({},f.defaultOptions,e),p=n.rootEl=document.createElement("div");p.classList.add(s.vex),o(p,d.className);var h=n.overlayEl=document.createElement("div");h.classList.add(s.overlay),o(h,d.overlayClassName),d.overlayClosesOnClick&&h.addEventListener("click",function(e){e.target===h&&n.close()}),p.appendChild(h);var g=n.contentEl=document.createElement("div");if(g.classList.add(s.content),o(g,d.contentClassName),g.appendChild(d.content instanceof window.Node?d.content:r(d.content)),p.appendChild(g),d.showCloseButton){var v=n.closeEl=document.createElement("div");v.classList.add(s.close),o(v,d.closeClassName),v.addEventListener("click",n.close.bind(n)),g.appendChild(v)}return document.querySelector(d.appendLocation).appendChild(p),d.afterOpen&&d.afterOpen.call(n),document.body.classList.add(s.open),n},close:function(e){var t;if(e.id)t=e.id;else{if("string"!=typeof e)throw new TypeError("close requires a vex object or id string");t=e}return!!u[t]&&u[t].close()},closeTop:function(){var e=Object.keys(u);return!!e.length&&u[e[e.length-1]].close()},closeAll:function(){for(var e in u)this.close(e);return!0},getAll:function(){return u},getById:function(e){return u[e]}};window.addEventListener("keyup",function(e){27===e.keyCode&&(c=!0,f.closeTop(),c=!1)}),window.addEventListener("popstate",function(){f.defaultOptions.closeAllOnPopState&&f.closeAll()}),f.defaultOptions={content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",overlayClassName:"",contentClassName:"",closeClassName:"",closeAllOnPopState:!0},Object.defineProperty(f,"_escapeHtml",{configurable:!1,enumerable:!1,writable:!1,value:i}),f.registerPlugin=function(e,t){var n=e(f),r=t||n.name;if(f[r])throw new Error("Plugin "+t+" is already registered.");f[r]=n},t.exports=f},{"classlist-polyfill":1,domify:2,"es6-object-assign":3}]},{},[4])(4)})},function(e,t){},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i=n(0),o=r(i),a=n(2),s=r(a);n(3),s.default.registerPlugin(n(1)),s.default.defaultOptions.className="vex-theme-plain",(0,o.default)(document).ready(function(){(0,o.default)("#ta_migrate_old_data").on("click",function(){var e=(0,o.default)(this);s.default.dialog.confirm({message:migration_var.i18n_confirm_migration,callback:function(t){t&&(e.attr("disabled","disabled"),e.closest(".forminp-migration_controls").addClass("-processing"),o.default.ajax({url:ajaxurl,type:"POST",data:{action:"ta_migrate_old_plugin_data"},dataType:"json"}).done(function(e,t,n){"success"===e.status?s.default.dialog.alert(e.success_msg):(s.default.dialog.alert(e.error_msg),console.log(e))}).fail(function(e,t,n){s.default.dialog.alert(migration_var.i18n_migration_failed),console.log(e)}).always(function(){e.removeAttr("disabled"),e.closest(".forminp-migration_controls").removeClass("-processing")}))}})})})}]);
js/app/quick_add_affiliate_link/dist/quick-add-affiliate-link.css ADDED
@@ -0,0 +1 @@
 
1
+ body{background:#f1f1f1;color:#444;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:14px;line-height:1.4em}#quick_add_affiliate_link{margin:20px}ul{list-style:none;margin:0;padding:0}ul li{margin-bottom:5px}.field-row{margin-bottom:15px}.field-row label{display:block}.field-row .guide{font-size:12px;font-style:italic}.field-row input.form-control{width:100%;box-sizing:border-box;font-size:14px;padding:8px 10px;border:1px solid #ccc}.field-row select{padding:2px;line-height:28px;height:28px;font-size:14px;-webkit-border-radius:0;border-radius:0;border:1px solid #ddd;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.07);box-shadow:inset 0 1px 2px rgba(0,0,0,.07);background-color:#fff;color:#32373c;outline:0;-webkit-transition:border-color 50ms ease-in-out;transition:border-color 50ms ease-in-out}.field-row .button{color:#555;border:1px solid #ccc;background:#f7f7f7;-webkit-box-shadow:0 1px 0 #ccc;box-shadow:0 1px 0 #ccc;display:inline-block;line-height:26px;height:28px;margin:0;padding:0 10px 1px;cursor:pointer;-webkit-border-radius:3px;-webkit-appearance:none;border-radius:3px;white-space:nowrap;box-sizing:border-box;margin-left:5px;font-size:14px;font-family:Arial,sans-serif}.field-row .button.button-primary{margin-top:8px;margin-bottom:5px;background:#2ea2cc;border-color:#0074a2;-webkit-box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(120,200,230,.5),0 1px 0 rgba(0,0,0,.15);color:#fff;text-decoration:none}.field-row.link-option{width:33.333%;float:left}.field-row.link-option label{margin-bottom:5px}.submit-row{clear:both;text-align:right}.submit-row *{margin-left:10px}.submit-row span.ta_spinner{display:none;background-repeat:no-repeat;position:relative;top:5px;width:20px;height:20px}
js/app/quick_add_affiliate_link/dist/quick-add-affiliate-link.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,n){"use strict";(function(e){var n,r,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};/*!
2
+ * jQuery JavaScript Library v3.2.1
3
+ * https://jquery.com/
4
+ *
5
+ * Includes Sizzle.js
6
+ * https://sizzlejs.com/
7
+ *
8
+ * Copyright JS Foundation and other contributors
9
+ * Released under the MIT license
10
+ * https://jquery.org/license
11
+ *
12
+ * Date: 2017-03-20T18:59Z
13
+ */
14
+ !function(t,n){"object"===i(e)&&"object"===i(e.exports)?e.exports=t.document?n(t,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return n(e)}:n(t)}("undefined"!=typeof window?window:void 0,function(o,a){function s(e,t){t=t||se;var n=t.createElement("script");n.text=e,t.head.appendChild(n).parentNode.removeChild(n)}function u(e){var t=!!e&&"length"in e&&e.length,n=xe.type(e);return"function"!==n&&!xe.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function l(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}function c(e,t,n){return xe.isFunction(t)?xe.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?xe.grep(e,function(e){return e===t!==n}):"string"!=typeof t?xe.grep(e,function(e){return de.call(t,e)>-1!==n}):Ee.test(t)?xe.filter(t,e,n):(t=xe.filter(t,e),xe.grep(e,function(e){return de.call(t,e)>-1!==n&&1===e.nodeType}))}function f(e,t){for(;(e=e[t])&&1!==e.nodeType;);return e}function d(e){var t={};return xe.each(e.match(Le)||[],function(e,n){t[n]=!0}),t}function p(e){return e}function h(e){throw e}function g(e,t,n,r){var i;try{e&&xe.isFunction(i=e.promise)?i.call(e).done(t).fail(n):e&&xe.isFunction(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n.apply(void 0,[e])}}function v(){se.removeEventListener("DOMContentLoaded",v),o.removeEventListener("load",v),xe.ready()}function m(){this.expando=xe.expando+m.uid++}function y(e){return"true"===e||"false"!==e&&("null"===e?null:e===+e+""?+e:Me.test(e)?JSON.parse(e):e)}function x(e,t,n){var r;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(_e,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{n=y(n)}catch(e){}Re.set(e,t,n)}else n=void 0;return n}function b(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return xe.css(e,t,"")},u=s(),l=n&&n[3]||(xe.cssNumber[t]?"":"px"),c=(xe.cssNumber[t]||"px"!==l&&+u)&&We.exec(xe.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do{o=o||".5",c/=o,xe.style(e,t,c+l)}while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function w(e){var t,n=e.ownerDocument,r=e.nodeName,i=Xe[r];return i||(t=n.body.appendChild(n.createElement(r)),i=xe.css(t,"display"),t.parentNode.removeChild(t),"none"===i&&(i="block"),Xe[r]=i,i)}function T(e,t){for(var n,r,i=[],o=0,a=e.length;o<a;o++)r=e[o],r.style&&(n=r.style.display,t?("none"===n&&(i[o]=Fe.get(r,"display")||null,i[o]||(r.style.display="")),""===r.style.display&&Be(r)&&(i[o]=w(r))):"none"!==n&&(i[o]="none",Fe.set(r,"display",n)));for(o=0;o<a;o++)null!=i[o]&&(e[o].style.display=i[o]);return e}function C(e,t){var n;return n=void 0!==e.getElementsByTagName?e.getElementsByTagName(t||"*"):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&l(e,t)?xe.merge([e],n):n}function k(e,t){for(var n=0,r=e.length;n<r;n++)Fe.set(e[n],"globalEval",!t||Fe.get(t[n],"globalEval"))}function S(e,t,n,r,i){for(var o,a,s,u,l,c,f=t.createDocumentFragment(),d=[],p=0,h=e.length;p<h;p++)if((o=e[p])||0===o)if("object"===xe.type(o))xe.merge(d,o.nodeType?[o]:o);else if(Qe.test(o)){for(a=a||f.appendChild(t.createElement("div")),s=(Ve.exec(o)||["",""])[1].toLowerCase(),u=Ye[s]||Ye._default,a.innerHTML=u[1]+xe.htmlPrefilter(o)+u[2],c=u[0];c--;)a=a.lastChild;xe.merge(d,a.childNodes),a=f.firstChild,a.textContent=""}else d.push(t.createTextNode(o));for(f.textContent="",p=0;o=d[p++];)if(r&&xe.inArray(o,r)>-1)i&&i.push(o);else if(l=xe.contains(o.ownerDocument,o),a=C(f.appendChild(o),"script"),l&&k(a),n)for(c=0;o=a[c++];)Ge.test(o.type||"")&&n.push(o);return f}function E(){return!0}function j(){return!1}function N(){try{return se.activeElement}catch(e){}}function D(e,t,n,r,o,a){var s,u;if("object"===(void 0===t?"undefined":i(t))){"string"!=typeof n&&(r=r||n,n=void 0);for(u in t)D(e,u,n,r,t[u],a);return e}if(null==r&&null==o?(o=n,r=n=void 0):null==o&&("string"==typeof n?(o=r,r=void 0):(o=r,r=n,n=void 0)),!1===o)o=j;else if(!o)return e;return 1===a&&(s=o,o=function(e){return xe().off(e),s.apply(this,arguments)},o.guid=s.guid||(s.guid=xe.guid++)),e.each(function(){xe.event.add(this,t,o,r,n)})}function A(e,t){return l(e,"table")&&l(11!==t.nodeType?t:t.firstChild,"tr")?xe(">tbody",e)[0]||e:e}function L(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function q(e){var t=rt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function H(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Fe.hasData(e)&&(o=Fe.access(e),a=Fe.set(t,o),l=o.events)){delete a.handle,a.events={};for(i in l)for(n=0,r=l[i].length;n<r;n++)xe.event.add(t,i,l[i][n])}Re.hasData(e)&&(s=Re.access(e),u=xe.extend({},s),Re.set(t,u))}}function P(e,t){var n=t.nodeName.toLowerCase();"input"===n&&Ue.test(e.type)?t.checked=e.checked:"input"!==n&&"textarea"!==n||(t.defaultValue=e.defaultValue)}function O(e,t,n,r){t=ce.apply([],t);var i,o,a,u,l,c,f=0,d=e.length,p=d-1,h=t[0],g=xe.isFunction(h);if(g||d>1&&"string"==typeof h&&!ye.checkClone&&nt.test(h))return e.each(function(i){var o=e.eq(i);g&&(t[0]=h.call(this,i,o.html())),O(o,t,n,r)});if(d&&(i=S(t,e[0].ownerDocument,!1,e,r),o=i.firstChild,1===i.childNodes.length&&(i=o),o||r)){for(a=xe.map(C(i,"script"),L),u=a.length;f<d;f++)l=i,f!==p&&(l=xe.clone(l,!0,!0),u&&xe.merge(a,C(l,"script"))),n.call(e[f],l,f);if(u)for(c=a[a.length-1].ownerDocument,xe.map(a,q),f=0;f<u;f++)l=a[f],Ge.test(l.type||"")&&!Fe.access(l,"globalEval")&&xe.contains(c,l)&&(l.src?xe._evalUrl&&xe._evalUrl(l.src):s(l.textContent.replace(it,""),c))}return e}function F(e,t,n){for(var r,i=t?xe.filter(t,e):e,o=0;null!=(r=i[o]);o++)n||1!==r.nodeType||xe.cleanData(C(r)),r.parentNode&&(n&&xe.contains(r.ownerDocument,r)&&k(C(r,"script")),r.parentNode.removeChild(r));return e}function R(e,t,n){var r,i,o,a,s=e.style;return n=n||st(e),n&&(a=n.getPropertyValue(t)||n[t],""!==a||xe.contains(e.ownerDocument,e)||(a=xe.style(e,t)),!ye.pixelMarginRight()&&at.test(a)&&ot.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o)),void 0!==a?a+"":a}function M(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function _(e){if(e in pt)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=dt.length;n--;)if((e=dt[n]+t)in pt)return e}function I(e){var t=xe.cssProps[e];return t||(t=xe.cssProps[e]=_(e)||e),t}function W(e,t,n){var r=We.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function $(e,t,n,r,i){var o,a=0;for(o=n===(r?"border":"content")?4:"width"===t?1:0;o<4;o+=2)"margin"===n&&(a+=xe.css(e,n+$e[o],!0,i)),r?("content"===n&&(a-=xe.css(e,"padding"+$e[o],!0,i)),"margin"!==n&&(a-=xe.css(e,"border"+$e[o]+"Width",!0,i))):(a+=xe.css(e,"padding"+$e[o],!0,i),"padding"!==n&&(a+=xe.css(e,"border"+$e[o]+"Width",!0,i)));return a}function B(e,t,n){var r,i=st(e),o=R(e,t,i),a="border-box"===xe.css(e,"boxSizing",!1,i);return at.test(o)?o:(r=a&&(ye.boxSizingReliable()||o===e.style[t]),"auto"===o&&(o=e["offset"+t[0].toUpperCase()+t.slice(1)]),(o=parseFloat(o)||0)+$(e,t,n||(a?"border":"content"),r,i)+"px")}function z(e,t,n,r,i){return new z.prototype.init(e,t,n,r,i)}function X(){gt&&(!1===se.hidden&&o.requestAnimationFrame?o.requestAnimationFrame(X):o.setTimeout(X,xe.fx.interval),xe.fx.tick())}function U(){return o.setTimeout(function(){ht=void 0}),ht=xe.now()}function V(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)n=$e[r],i["margin"+n]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function G(e,t,n){for(var r,i=(J.tweeners[t]||[]).concat(J.tweeners["*"]),o=0,a=i.length;o<a;o++)if(r=i[o].call(n,t,e))return r}function Y(e,t,n){var r,i,o,a,s,u,l,c,f="width"in t||"height"in t,d=this,p={},h=e.style,g=e.nodeType&&Be(e),v=Fe.get(e,"fxshow");n.queue||(a=xe._queueHooks(e,"fx"),null==a.unqueued&&(a.unqueued=0,s=a.empty.fire,a.empty.fire=function(){a.unqueued||s()}),a.unqueued++,d.always(function(){d.always(function(){a.unqueued--,xe.queue(e,"fx").length||a.empty.fire()})}));for(r in t)if(i=t[r],vt.test(i)){if(delete t[r],o=o||"toggle"===i,i===(g?"hide":"show")){if("show"!==i||!v||void 0===v[r])continue;g=!0}p[r]=v&&v[r]||xe.style(e,r)}if((u=!xe.isEmptyObject(t))||!xe.isEmptyObject(p)){f&&1===e.nodeType&&(n.overflow=[h.overflow,h.overflowX,h.overflowY],l=v&&v.display,null==l&&(l=Fe.get(e,"display")),c=xe.css(e,"display"),"none"===c&&(l?c=l:(T([e],!0),l=e.style.display||l,c=xe.css(e,"display"),T([e]))),("inline"===c||"inline-block"===c&&null!=l)&&"none"===xe.css(e,"float")&&(u||(d.done(function(){h.display=l}),null==l&&(c=h.display,l="none"===c?"":c)),h.display="inline-block")),n.overflow&&(h.overflow="hidden",d.always(function(){h.overflow=n.overflow[0],h.overflowX=n.overflow[1],h.overflowY=n.overflow[2]})),u=!1;for(r in p)u||(v?"hidden"in v&&(g=v.hidden):v=Fe.access(e,"fxshow",{display:l}),o&&(v.hidden=!g),g&&T([e],!0),d.done(function(){g||T([e]),Fe.remove(e,"fxshow");for(r in p)xe.style(e,r,p[r])})),u=G(g?v[r]:0,r,d),r in v||(v[r]=u.start,g&&(u.end=u.start,u.start=0))}}function Q(e,t){var n,r,i,o,a;for(n in e)if(r=xe.camelCase(n),i=t[r],o=e[n],Array.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),(a=xe.cssHooks[r])&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function J(e,t,n){var r,i,o=0,a=J.prefilters.length,s=xe.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=ht||U(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;a<u;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),o<1&&u?n:(u||s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:xe.extend({},t),opts:xe.extend(!0,{specialEasing:{},easing:xe.easing._default},n),originalProperties:t,originalOptions:n,startTime:ht||U(),duration:n.duration,tweens:[],createTween:function(t,n){var r=xe.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;n<r;n++)l.tweens[n].run(1);return t?(s.notifyWith(e,[l,1,0]),s.resolveWith(e,[l,t])):s.rejectWith(e,[l,t]),this}}),c=l.props;for(Q(c,l.opts.specialEasing);o<a;o++)if(r=J.prefilters[o].call(l,e,c,l.opts))return xe.isFunction(r.stop)&&(xe._queueHooks(l.elem,l.opts.queue).stop=xe.proxy(r.stop,r)),r;return xe.map(c,G,l),xe.isFunction(l.opts.start)&&l.opts.start.call(e,l),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always),xe.fx.timer(xe.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l}function K(e){return(e.match(Le)||[]).join(" ")}function Z(e){return e.getAttribute&&e.getAttribute("class")||""}function ee(e,t,n,r){var o;if(Array.isArray(t))xe.each(t,function(t,o){n||Et.test(e)?r(e,o):ee(e+"["+("object"===(void 0===o?"undefined":i(o))&&null!=o?t:"")+"]",o,n,r)});else if(n||"object"!==xe.type(t))r(e,t);else for(o in t)ee(e+"["+o+"]",t[o],n,r)}function te(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(Le)||[];if(xe.isFunction(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function ne(e,t,n,r){function i(s){var u;return o[s]=!0,xe.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||a||o[l]?a?!(u=l):void 0:(t.dataTypes.unshift(l),i(l),!1)}),u}var o={},a=e===Ht;return i(t.dataTypes[0])||!o["*"]&&i("*")}function re(e,t){var n,r,i=xe.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&xe.extend(!0,e,r),e}function ie(e,t,n){for(var r,i,o,a,s=e.contents,u=e.dataTypes;"*"===u[0];)u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}function oe(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift())if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o]))for(i in l)if(s=i.split(" "),s[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}return{state:"success",data:t}}var ae=[],se=o.document,ue=Object.getPrototypeOf,le=ae.slice,ce=ae.concat,fe=ae.push,de=ae.indexOf,pe={},he=pe.toString,ge=pe.hasOwnProperty,ve=ge.toString,me=ve.call(Object),ye={},xe=function e(t,n){return new e.fn.init(t,n)},be=function(e,t){return t.toUpperCase()};xe.fn=xe.prototype={jquery:"3.2.1",constructor:xe,length:0,toArray:function(){return le.call(this)},get:function(e){return null==e?le.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=xe.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return xe.each(this,e)},map:function(e){return this.pushStack(xe.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(le.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n<t?[this[n]]:[])},end:function(){return this.prevObject||this.constructor()},push:fe,sort:ae.sort,splice:ae.splice},xe.extend=xe.fn.extend=function(){var e,t,n,r,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[u]||{},u++),"object"===(void 0===s?"undefined":i(s))||xe.isFunction(s)||(s={}),u===l&&(s=this,u--);u<l;u++)if(null!=(e=arguments[u]))for(t in e)n=s[t],r=e[t],s!==r&&(c&&r&&(xe.isPlainObject(r)||(o=Array.isArray(r)))?(o?(o=!1,a=n&&Array.isArray(n)?n:[]):a=n&&xe.isPlainObject(n)?n:{},s[t]=xe.extend(c,a,r)):void 0!==r&&(s[t]=r));return s},xe.extend({expando:"jQuery"+("3.2.1"+Math.random()).replace(/\D/g,""),isReady:!0,error:function(e){throw new Error(e)},noop:function(){},isFunction:function(e){return"function"===xe.type(e)},isWindow:function(e){return null!=e&&e===e.window},isNumeric:function(e){var t=xe.type(e);return("number"===t||"string"===t)&&!isNaN(e-parseFloat(e))},isPlainObject:function(e){var t,n;return!(!e||"[object Object]"!==he.call(e))&&(!(t=ue(e))||"function"==typeof(n=ge.call(t,"constructor")&&t.constructor)&&ve.call(n)===me)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},type:function(e){return null==e?e+"":"object"===(void 0===e?"undefined":i(e))||"function"==typeof e?pe[he.call(e)]||"object":void 0===e?"undefined":i(e)},globalEval:function(e){s(e)},camelCase:function(e){return e.replace(/^-ms-/,"ms-").replace(/-([a-z])/g,be)},each:function(e,t){var n,r=0;if(u(e))for(n=e.length;r<n&&!1!==t.call(e[r],r,e[r]);r++);else for(r in e)if(!1===t.call(e[r],r,e[r]))break;return e},trim:function(e){return null==e?"":(e+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(u(Object(e))?xe.merge(n,"string"==typeof e?[e]:e):fe.call(n,e)),n},inArray:function(e,t,n){return null==t?-1:de.call(t,e,n)},merge:function(e,t){for(var n=+t.length,r=0,i=e.length;r<n;r++)e[i++]=t[r];return e.length=i,e},grep:function(e,t,n){for(var r=[],i=0,o=e.length,a=!n;i<o;i++)!t(e[i],i)!==a&&r.push(e[i]);return r},map:function(e,t,n){var r,i,o=0,a=[];if(u(e))for(r=e.length;o<r;o++)null!=(i=t(e[o],o,n))&&a.push(i);else for(o in e)null!=(i=t(e[o],o,n))&&a.push(i);return ce.apply([],a)},guid:1,proxy:function(e,t){var n,r,i;if("string"==typeof t&&(n=e[t],t=e,e=n),xe.isFunction(e))return r=le.call(arguments,2),i=function(){return e.apply(t||this,r.concat(le.call(arguments)))},i.guid=e.guid=e.guid||xe.guid++,i},now:Date.now,support:ye}),"function"==typeof Symbol&&(xe.fn[Symbol.iterator]=ae[Symbol.iterator]),xe.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){pe["[object "+t+"]"]=t.toLowerCase()});var we=/*!
15
+ * Sizzle CSS Selector Engine v2.3.3
16
+ * https://sizzlejs.com/
17
+ *
18
+ * Copyright jQuery Foundation and other contributors
19
+ * Released under the MIT license
20
+ * http://jquery.org/license
21
+ *
22
+ * Date: 2016-08-08
23
+ */
24
+ function(e){function t(e,t,n,r){var i,o,a,s,u,c,d,p=t&&t.ownerDocument,h=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==h&&9!==h&&11!==h)return n;if(!r&&((t?t.ownerDocument||t:_)!==L&&A(t),t=t||L,H)){if(11!==h&&(u=ge.exec(e)))if(i=u[1]){if(9===h){if(!(a=t.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(p&&(a=p.getElementById(i))&&R(t,a)&&a.id===i)return n.push(a),n}else{if(u[2])return Q.apply(n,t.getElementsByTagName(e)),n;if((i=u[3])&&b.getElementsByClassName&&t.getElementsByClassName)return Q.apply(n,t.getElementsByClassName(i)),n}if(b.qsa&&!z[e+" "]&&(!P||!P.test(e))){if(1!==h)p=t,d=e;else if("object"!==t.nodeName.toLowerCase()){for((s=t.getAttribute("id"))?s=s.replace(xe,be):t.setAttribute("id",s=M),c=k(e),o=c.length;o--;)c[o]="#"+s+" "+f(c[o]);d=c.join(","),p=ve.test(e)&&l(t.parentNode)||t}if(d)try{return Q.apply(n,p.querySelectorAll(d)),n}catch(e){}finally{s===M&&t.removeAttribute("id")}}}return E(e.replace(oe,"$1"),t,n,r)}function n(){function e(n,r){return t.push(n+" ")>w.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[M]=!0,e}function i(e){var t=L.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)w.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){return"form"in t?t.parentNode&&!1===t.disabled?"label"in t?"label"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&Te(t)===e:t.disabled===e:"label"in t&&t.disabled===e}}function u(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function l(e){return e&&void 0!==e.getElementsByTagName&&e}function c(){}function f(e){for(var t=0,n=e.length,r="";t<n;t++)r+=e[t].value;return r}function d(e,t,n){var r=t.dir,i=t.next,o=i||r,a=n&&"parentNode"===o,s=W++;return t.first?function(t,n,i){for(;t=t[r];)if(1===t.nodeType||a)return e(t,n,i);return!1}:function(t,n,u){var l,c,f,d=[I,s];if(u){for(;t=t[r];)if((1===t.nodeType||a)&&e(t,n,u))return!0}else for(;t=t[r];)if(1===t.nodeType||a)if(f=t[M]||(t[M]={}),c=f[t.uniqueID]||(f[t.uniqueID]={}),i&&i===t.nodeName.toLowerCase())t=t[r]||t;else{if((l=c[o])&&l[0]===I&&l[1]===s)return d[2]=l[2];if(c[o]=d,d[2]=e(t,n,u))return!0}return!1}}function p(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function h(e,n,r){for(var i=0,o=n.length;i<o;i++)t(e,n[i],r);return r}function g(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s<u;s++)(o=e[s])&&(n&&!n(o,r,i)||(a.push(o),l&&t.push(s)));return a}function v(e,t,n,i,o,a){return i&&!i[M]&&(i=v(i)),o&&!o[M]&&(o=v(o,a)),r(function(r,a,s,u){var l,c,f,d=[],p=[],v=a.length,m=r||h(t||"*",s.nodeType?[s]:s,[]),y=!e||!r&&t?m:g(m,d,e,s,u),x=n?o||(r?e:v||i)?[]:a:y;if(n&&n(y,x,s,u),i)for(l=g(x,p),i(l,[],s,u),c=l.length;c--;)(f=l[c])&&(x[p[c]]=!(y[p[c]]=f));if(r){if(o||e){if(o){for(l=[],c=x.length;c--;)(f=x[c])&&l.push(y[c]=f);o(null,x=[],l,u)}for(c=x.length;c--;)(f=x[c])&&(l=o?K(r,f):d[c])>-1&&(r[l]=!(a[l]=f))}}else x=g(x===a?x.splice(v,x.length):x),o?o(null,a,x,u):Q.apply(a,x)})}function m(e){for(var t,n,r,i=e.length,o=w.relative[e[0].type],a=o||w.relative[" "],s=o?1:0,u=d(function(e){return e===t},a,!0),l=d(function(e){return K(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==j)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s<i;s++)if(n=w.relative[e[s].type])c=[d(p(c),n)];else{if(n=w.filter[e[s].type].apply(null,e[s].matches),n[M]){for(r=++s;r<i&&!w.relative[e[r].type];r++);return v(s>1&&p(c),s>1&&f(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(oe,"$1"),n,s<r&&m(e.slice(s,r)),r<i&&m(e=e.slice(r)),r<i&&f(e))}c.push(n)}return p(c)}function y(e,n){var i=n.length>0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",v=r&&[],m=[],y=j,x=r||o&&w.find.TAG("*",l),b=I+=null==y?1:Math.random()||.1,T=x.length;for(l&&(j=a===L||a||l);h!==T&&null!=(c=x[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===L||(A(c),s=!H);d=e[f++];)if(d(c,a||L,s)){u.push(c);break}l&&(I=b)}i&&((c=!d&&c)&&p--,r&&v.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(v,m,a,s);if(r){if(p>0)for(;h--;)v[h]||m[h]||(m[h]=G.call(u));m=g(m)}Q.apply(u,m),l&&!r&&m.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(I=b,j=y),v};return i?r(a):a}var x,b,w,T,C,k,S,E,j,N,D,A,L,q,H,P,O,F,R,M="sizzle"+1*new Date,_=e.document,I=0,W=0,$=n(),B=n(),z=n(),X=function(e,t){return e===t&&(D=!0),0},U={}.hasOwnProperty,V=[],G=V.pop,Y=V.push,Q=V.push,J=V.slice,K=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1},Z="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ee="[\\x20\\t\\r\\n\\f]",te="(?:\\\\.|[\\w-]|[^\0-\\xa0])+",ne="\\["+ee+"*("+te+")(?:"+ee+"*([*^$|!~]?=)"+ee+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+te+"))|)"+ee+"*\\]",re=":("+te+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+ne+")*)|.*)\\)|)",ie=new RegExp(ee+"+","g"),oe=new RegExp("^"+ee+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ee+"+$","g"),ae=new RegExp("^"+ee+"*,"+ee+"*"),se=new RegExp("^"+ee+"*([>+~]|"+ee+")"+ee+"*"),ue=new RegExp("="+ee+"*([^\\]'\"]*?)"+ee+"*\\]","g"),le=new RegExp(re),ce=new RegExp("^"+te+"$"),fe={ID:new RegExp("^#("+te+")"),CLASS:new RegExp("^\\.("+te+")"),TAG:new RegExp("^("+te+"|[*])"),ATTR:new RegExp("^"+ne),PSEUDO:new RegExp("^"+re),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ee+"*(even|odd|(([+-]|)(\\d*)n|)"+ee+"*(?:([+-]|)"+ee+"*(\\d+)|))"+ee+"*\\)|)","i"),bool:new RegExp("^(?:"+Z+")$","i"),needsContext:new RegExp("^"+ee+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ee+"*((?:-\\d)?\\d*)"+ee+"*\\)|)(?=[^-]|$)","i")},de=/^(?:input|select|textarea|button)$/i,pe=/^h\d$/i,he=/^[^{]+\{\s*\[native \w/,ge=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ve=/[+~]/,me=new RegExp("\\\\([\\da-f]{1,6}"+ee+"?|("+ee+")|.)","ig"),ye=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},xe=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,be=function(e,t){return t?"\0"===e?"�":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},we=function(){A()},Te=d(function(e){return!0===e.disabled&&("form"in e||"label"in e)},{dir:"parentNode",next:"legend"});try{Q.apply(V=J.call(_.childNodes),_.childNodes),V[_.childNodes.length].nodeType}catch(e){Q={apply:V.length?function(e,t){Y.apply(e,J.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}b=t.support={},C=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},A=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:_;return r!==L&&9===r.nodeType&&r.documentElement?(L=r,q=L.documentElement,H=!C(L),_!==L&&(n=L.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",we,!1):n.attachEvent&&n.attachEvent("onunload",we)),b.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),b.getElementsByTagName=i(function(e){return e.appendChild(L.createComment("")),!e.getElementsByTagName("*").length}),b.getElementsByClassName=he.test(L.getElementsByClassName),b.getById=i(function(e){return q.appendChild(e).id=M,!L.getElementsByName||!L.getElementsByName(M).length}),b.getById?(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){return e.getAttribute("id")===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&H){var n=t.getElementById(e);return n?[n]:[]}}):(w.filter.ID=function(e){var t=e.replace(me,ye);return function(e){var n=void 0!==e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}},w.find.ID=function(e,t){if(void 0!==t.getElementById&&H){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];for(i=t.getElementsByName(e),r=0;o=i[r++];)if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),w.find.TAG=b.getElementsByTagName?function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):b.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},w.find.CLASS=b.getElementsByClassName&&function(e,t){if(void 0!==t.getElementsByClassName&&H)return t.getElementsByClassName(e)},O=[],P=[],(b.qsa=he.test(L.querySelectorAll))&&(i(function(e){q.appendChild(e).innerHTML="<a id='"+M+"'></a><select id='"+M+"-\r\\' msallowcapture=''><option selected=''></option></select>",e.querySelectorAll("[msallowcapture^='']").length&&P.push("[*^$]="+ee+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||P.push("\\["+ee+"*(?:value|"+Z+")"),e.querySelectorAll("[id~="+M+"-]").length||P.push("~="),e.querySelectorAll(":checked").length||P.push(":checked"),e.querySelectorAll("a#"+M+"+*").length||P.push(".#.+[+~]")}),i(function(e){e.innerHTML="<a href='' disabled='disabled'></a><select disabled='disabled'><option/></select>";var t=L.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&P.push("name"+ee+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&P.push(":enabled",":disabled"),q.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&P.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),P.push(",.*:")})),(b.matchesSelector=he.test(F=q.matches||q.webkitMatchesSelector||q.mozMatchesSelector||q.oMatchesSelector||q.msMatchesSelector))&&i(function(e){b.disconnectedMatch=F.call(e,"*"),F.call(e,"[s!='']:x"),O.push("!=",re)}),P=P.length&&new RegExp(P.join("|")),O=O.length&&new RegExp(O.join("|")),t=he.test(q.compareDocumentPosition),R=t||he.test(q.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},X=t?function(e,t){if(e===t)return D=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!b.sortDetached&&t.compareDocumentPosition(e)===n?e===L||e.ownerDocument===_&&R(_,e)?-1:t===L||t.ownerDocument===_&&R(_,t)?1:N?K(N,e)-K(N,t):0:4&n?-1:1)}:function(e,t){if(e===t)return D=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===L?-1:t===L?1:i?-1:o?1:N?K(N,e)-K(N,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===_?-1:u[r]===_?1:0},L):L},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==L&&A(e),n=n.replace(ue,"='$1']"),b.matchesSelector&&H&&!z[n+" "]&&(!O||!O.test(n))&&(!P||!P.test(n)))try{var r=F.call(e,n);if(r||b.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(e){}return t(n,L,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==L&&A(e),R(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==L&&A(e);var n=w.attrHandle[t.toLowerCase()],r=n&&U.call(w.attrHandle,t.toLowerCase())?n(e,t,!H):void 0;return void 0!==r?r:b.attributes||!H?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.escape=function(e){return(e+"").replace(xe,be)},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(D=!b.detectDuplicates,N=!b.sortStable&&e.slice(0),e.sort(X),D){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return N=null,e},T=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=T(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=T(t);return n},w=t.selectors={cacheLength:50,createPseudo:r,match:fe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(me,ye),e[3]=(e[3]||e[4]||e[5]||"").replace(me,ye),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return fe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&le.test(n)&&(t=k(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(me,ye).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ee+")"+e+"("+ee+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ie," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,g=o!==a?"nextSibling":"previousSibling",v=t.parentNode,m=s&&t.nodeName.toLowerCase(),y=!u&&!s,x=!1;if(v){if(o){for(;g;){for(d=t;d=d[g];)if(s?d.nodeName.toLowerCase()===m:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?v.firstChild:v.lastChild],a&&y){for(d=v,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],x=p&&l[2],d=p&&v.childNodes[p];d=++p&&d&&d[g]||(x=p=0)||h.pop();)if(1===d.nodeType&&++x&&d===t){c[e]=[I,p,x];break}}else if(y&&(d=t,f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===I&&l[1],x=p),!1===x)for(;(d=++p&&d&&d[g]||(x=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==m:1!==d.nodeType)||!++x||(y&&(f=d[M]||(d[M]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[I,x]),d!==t)););return(x-=i)===r||x%r==0&&x/r>=0}}},PSEUDO:function(e,n){var i,o=w.pseudos[e]||w.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[M]?o(n):o.length>1?(i=[e,e,"",n],w.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=K(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=S(e.replace(oe,"$1"));return i[M]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(me,ye),function(t){return(t.textContent||t.innerText||T(t)).indexOf(e)>-1}}),lang:r(function(e){return ce.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(me,ye).toLowerCase(),function(t){var n;do{if(n=H?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-")}while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===q},focus:function(e){return e===L.activeElement&&(!L.hasFocus||L.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:s(!1),disabled:s(!0),checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!w.pseudos.empty(e)},header:function(e){return pe.test(e.nodeName)},input:function(e){return de.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:u(function(){return[0]}),last:u(function(e,t){return[t-1]}),eq:u(function(e,t,n){return[n<0?n+t:n]}),even:u(function(e,t){for(var n=0;n<t;n+=2)e.push(n);return e}),odd:u(function(e,t){for(var n=1;n<t;n+=2)e.push(n);return e}),lt:u(function(e,t,n){for(var r=n<0?n+t:n;--r>=0;)e.push(r);return e}),gt:u(function(e,t,n){for(var r=n<0?n+t:n;++r<t;)e.push(r);return e})}},w.pseudos.nth=w.pseudos.eq;for(x in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})w.pseudos[x]=function(e){return function(t){return"input"===t.nodeName.toLowerCase()&&t.type===e}}(x);for(x in{submit:!0,reset:!0})w.pseudos[x]=function(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}(x);return c.prototype=w.filters=w.pseudos,w.setFilters=new c,k=t.tokenize=function(e,n){var r,i,o,a,s,u,l,c=B[e+" "];if(c)return n?0:c.slice(0);for(s=e,u=[],l=w.preFilter;s;){r&&!(i=ae.exec(s))||(i&&(s=s.slice(i[0].length)||s),u.push(o=[])),r=!1,(i=se.exec(s))&&(r=i.shift(),o.push({value:r,type:i[0].replace(oe," ")}),s=s.slice(r.length));for(a in w.filter)!(i=fe[a].exec(s))||l[a]&&!(i=l[a](i))||(r=i.shift(),o.push({value:r,type:a,matches:i}),s=s.slice(r.length));if(!r)break}return n?s.length:s?t.error(e):B(e,u).slice(0)},S=t.compile=function(e,t){var n,r=[],i=[],o=z[e+" "];if(!o){for(t||(t=k(e)),n=t.length;n--;)o=m(t[n]),o[M]?r.push(o):i.push(o);o=z(e,y(i,r)),o.selector=e}return o},E=t.select=function(e,t,n,r){var i,o,a,s,u,c="function"==typeof e&&e,d=!r&&k(e=c.selector||e);if(n=n||[],1===d.length){if(o=d[0]=d[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&9===t.nodeType&&H&&w.relative[o[1].type]){if(!(t=(w.find.ID(a.matches[0].replace(me,ye),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=fe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!w.relative[s=a.type]);)if((u=w.find[s])&&(r=u(a.matches[0].replace(me,ye),ve.test(o[0].type)&&l(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&f(o)))return Q.apply(n,r),n;break}}return(c||S(e,d))(r,t,!H,n,!t||ve.test(e)&&l(t.parentNode)||t),n},b.sortStable=M.split("").sort(X).join("")===M,b.detectDuplicates=!!D,A(),b.sortDetached=i(function(e){return 1&e.compareDocumentPosition(L.createElement("fieldset"))}),i(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),b.attributes&&i(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(Z,function(e,t,n){var r;if(!n)return!0===e[t]?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(o);xe.find=we,xe.expr=we.selectors,xe.expr[":"]=xe.expr.pseudos,xe.uniqueSort=xe.unique=we.uniqueSort,xe.text=we.getText,xe.isXMLDoc=we.isXML,xe.contains=we.contains,xe.escapeSelector=we.escape;var Te=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&xe(e).is(n))break;r.push(e)}return r},Ce=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},ke=xe.expr.match.needsContext,Se=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i,Ee=/^.[^:#\[\.,]*$/;xe.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?xe.find.matchesSelector(r,e)?[r]:[]:xe.find.matches(e,xe.grep(t,function(e){return 1===e.nodeType}))},xe.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(xe(e).filter(function(){for(t=0;t<r;t++)if(xe.contains(i[t],this))return!0}));for(n=this.pushStack([]),t=0;t<r;t++)xe.find(e,i[t],n);return r>1?xe.uniqueSort(n):n},filter:function(e){return this.pushStack(c(this,e||[],!1))},not:function(e){return this.pushStack(c(this,e||[],!0))},is:function(e){return!!c(this,"string"==typeof e&&ke.test(e)?xe(e):e||[],!1).length}});var je,Ne=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(xe.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||je,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&e.length>=3?[null,e,null]:Ne.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof xe?t[0]:t,xe.merge(this,xe.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:se,!0)),Se.test(r[1])&&xe.isPlainObject(t))for(r in t)xe.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return i=se.getElementById(r[2]),i&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):xe.isFunction(e)?void 0!==n.ready?n.ready(e):e(xe):xe.makeArray(e,this)}).prototype=xe.fn,je=xe(se);var De=/^(?:parents|prev(?:Until|All))/,Ae={children:!0,contents:!0,next:!0,prev:!0};xe.fn.extend({has:function(e){var t=xe(e,this),n=t.length;return this.filter(function(){for(var e=0;e<n;e++)if(xe.contains(this,t[e]))return!0})},closest:function(e,t){var n,r=0,i=this.length,o=[],a="string"!=typeof e&&xe(e);if(!ke.test(e))for(;r<i;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(n.nodeType<11&&(a?a.index(n)>-1:1===n.nodeType&&xe.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?xe.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?de.call(xe(e),this[0]):de.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(xe.uniqueSort(xe.merge(this.get(),xe(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),xe.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return Te(e,"parentNode")},parentsUntil:function(e,t,n){return Te(e,"parentNode",n)},next:function(e){return f(e,"nextSibling")},prev:function(e){return f(e,"previousSibling")},nextAll:function(e){return Te(e,"nextSibling")},prevAll:function(e){return Te(e,"previousSibling")},nextUntil:function(e,t,n){return Te(e,"nextSibling",n)},prevUntil:function(e,t,n){return Te(e,"previousSibling",n)},siblings:function(e){return Ce((e.parentNode||{}).firstChild,e)},children:function(e){return Ce(e.firstChild)},contents:function(e){return l(e,"iframe")?e.contentDocument:(l(e,"template")&&(e=e.content||e),xe.merge([],e.childNodes))}},function(e,t){xe.fn[e]=function(n,r){var i=xe.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=xe.filter(r,i)),this.length>1&&(Ae[e]||xe.uniqueSort(i),De.test(e)&&i.reverse()),this.pushStack(i)}});var Le=/[^\x20\t\r\n\f]+/g;xe.Callbacks=function(e){e="string"==typeof e?d(e):xe.extend({},e);var t,n,r,i,o=[],a=[],s=-1,u=function(){for(i=i||e.once,r=t=!0;a.length;s=-1)for(n=a.shift();++s<o.length;)!1===o[s].apply(n[0],n[1])&&e.stopOnFalse&&(s=o.length,n=!1);e.memory||(n=!1),t=!1,i&&(o=n?[]:"")},l={add:function(){return o&&(n&&!t&&(s=o.length-1,a.push(n)),function t(n){xe.each(n,function(n,r){xe.isFunction(r)?e.unique&&l.has(r)||o.push(r):r&&r.length&&"string"!==xe.type(r)&&t(r)})}(arguments),n&&!t&&u()),this},remove:function(){return xe.each(arguments,function(e,t){for(var n;(n=xe.inArray(t,o,n))>-1;)o.splice(n,1),n<=s&&s--}),this},has:function(e){return e?xe.inArray(e,o)>-1:o.length>0},empty:function(){return o&&(o=[]),this},disable:function(){return i=a=[],o=n="",this},disabled:function(){return!o},lock:function(){return i=a=[],n||t||(o=n=""),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],a.push(n),t||u()),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!r}};return l},xe.extend({Deferred:function(e){var t=[["notify","progress",xe.Callbacks("memory"),xe.Callbacks("memory"),2],["resolve","done",xe.Callbacks("once memory"),xe.Callbacks("once memory"),0,"resolved"],["reject","fail",xe.Callbacks("once memory"),xe.Callbacks("once memory"),1,"rejected"]],n="pending",r={state:function(){return n},always:function(){return a.done(arguments).fail(arguments),this},catch:function(e){return r.then(null,e)},pipe:function(){var e=arguments;return xe.Deferred(function(n){xe.each(t,function(t,r){var i=xe.isFunction(e[r[4]])&&e[r[4]];a[r[1]](function(){var e=i&&i.apply(this,arguments);e&&xe.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(e,n,r){function a(e,t,n,r){return function(){var u=this,l=arguments,c=function(){var o,c;if(!(e<s)){if((o=n.apply(u,l))===t.promise())throw new TypeError("Thenable self-resolution");c=o&&("object"===(void 0===o?"undefined":i(o))||"function"==typeof o)&&o.then,xe.isFunction(c)?r?c.call(o,a(s,t,p,r),a(s,t,h,r)):(s++,c.call(o,a(s,t,p,r),a(s,t,h,r),a(s,t,p,t.notifyWith))):(n!==p&&(u=void 0,l=[o]),(r||t.resolveWith)(u,l))}},f=r?c:function(){try{c()}catch(r){xe.Deferred.exceptionHook&&xe.Deferred.exceptionHook(r,f.stackTrace),e+1>=s&&(n!==h&&(u=void 0,l=[r]),t.rejectWith(u,l))}};e?f():(xe.Deferred.getStackHook&&(f.stackTrace=xe.Deferred.getStackHook()),o.setTimeout(f))}}var s=0;return xe.Deferred(function(i){t[0][3].add(a(0,i,xe.isFunction(r)?r:p,i.notifyWith)),t[1][3].add(a(0,i,xe.isFunction(e)?e:p)),t[2][3].add(a(0,i,xe.isFunction(n)?n:h))}).promise()},promise:function(e){return null!=e?xe.extend(e,r):r}},a={};return xe.each(t,function(e,i){var o=i[2],s=i[5];r[i[1]]=o.add,s&&o.add(function(){n=s},t[3-e][2].disable,t[0][2].lock),o.add(i[3].fire),a[i[0]]=function(){return a[i[0]+"With"](this===a?void 0:this,arguments),this},a[i[0]+"With"]=o.fireWith}),r.promise(a),e&&e.call(a,a),a},when:function(e){var t=arguments.length,n=t,r=Array(n),i=le.call(arguments),o=xe.Deferred(),a=function(e){return function(n){r[e]=this,i[e]=arguments.length>1?le.call(arguments):n,--t||o.resolveWith(r,i)}};if(t<=1&&(g(e,o.done(a(n)).resolve,o.reject,!t),"pending"===o.state()||xe.isFunction(i[n]&&i[n].then)))return o.then();for(;n--;)g(i[n],a(n),o.reject);return o.promise()}});var qe=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;xe.Deferred.exceptionHook=function(e,t){o.console&&o.console.warn&&e&&qe.test(e.name)&&o.console.warn("jQuery.Deferred exception: "+e.message,e.stack,t)},xe.readyException=function(e){o.setTimeout(function(){throw e})};var He=xe.Deferred();xe.fn.ready=function(e){return He.then(e).catch(function(e){xe.readyException(e)}),this},xe.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--xe.readyWait:xe.isReady)||(xe.isReady=!0,!0!==e&&--xe.readyWait>0||He.resolveWith(se,[xe]))}}),xe.ready.then=He.then,"complete"===se.readyState||"loading"!==se.readyState&&!se.documentElement.doScroll?o.setTimeout(xe.ready):(se.addEventListener("DOMContentLoaded",v),o.addEventListener("load",v));var Pe=function e(t,n,r,i,o,a,s){var u=0,l=t.length,c=null==r;if("object"===xe.type(r)){o=!0;for(u in r)e(t,n,u,r[u],!0,a,s)}else if(void 0!==i&&(o=!0,xe.isFunction(i)||(s=!0),c&&(s?(n.call(t,i),n=null):(c=n,n=function(e,t,n){return c.call(xe(e),n)})),n))for(;u<l;u++)n(t[u],r,s?i:i.call(t[u],u,n(t[u],r)));return o?t:c?n.call(t):l?n(t[0],r):a},Oe=function(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType};m.uid=1,m.prototype={cache:function(e){var t=e[this.expando];return t||(t={},Oe(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[xe.camelCase(t)]=n;else for(r in t)i[xe.camelCase(r)]=t[r];return i},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][xe.camelCase(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){Array.isArray(t)?t=t.map(xe.camelCase):(t=xe.camelCase(t),t=t in r?[t]:t.match(Le)||[]),n=t.length;for(;n--;)delete r[t[n]]}(void 0===t||xe.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!xe.isEmptyObject(t)}};var Fe=new m,Re=new m,Me=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,_e=/[A-Z]/g;xe.extend({hasData:function(e){return Re.hasData(e)||Fe.hasData(e)},data:function(e,t,n){return Re.access(e,t,n)},removeData:function(e,t){Re.remove(e,t)},_data:function(e,t,n){return Fe.access(e,t,n)},_removeData:function(e,t){Fe.remove(e,t)}}),xe.fn.extend({data:function(e,t){var n,r,o,a=this[0],s=a&&a.attributes;if(void 0===e){if(this.length&&(o=Re.get(a),1===a.nodeType&&!Fe.get(a,"hasDataAttrs"))){for(n=s.length;n--;)s[n]&&(r=s[n].name,0===r.indexOf("data-")&&(r=xe.camelCase(r.slice(5)),x(a,r,o[r])));Fe.set(a,"hasDataAttrs",!0)}return o}return"object"===(void 0===e?"undefined":i(e))?this.each(function(){Re.set(this,e)}):Pe(this,function(t){var n;if(a&&void 0===t){if(void 0!==(n=Re.get(a,e)))return n;if(void 0!==(n=x(a,e)))return n}else this.each(function(){Re.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){Re.remove(this,e)})}}),xe.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=Fe.get(e,t),n&&(!r||Array.isArray(n)?r=Fe.access(e,t,xe.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=xe.queue(e,t),r=n.length,i=n.shift(),o=xe._queueHooks(e,t),a=function(){xe.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return Fe.get(e,n)||Fe.access(e,n,{empty:xe.Callbacks("once memory").add(function(){Fe.remove(e,[t+"queue",n])})})}}),xe.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length<n?xe.queue(this[0],e):void 0===t?this:this.each(function(){var n=xe.queue(this,e,t);xe._queueHooks(this,e),"fx"===e&&"inprogress"!==n[0]&&xe.dequeue(this,e)})},dequeue:function(e){return this.each(function(){xe.dequeue(this,e)})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,t){var n,r=1,i=xe.Deferred(),o=this,a=this.length,s=function(){--r||i.resolveWith(o,[o])};for("string"!=typeof e&&(t=e,e=void 0),e=e||"fx";a--;)(n=Fe.get(o[a],e+"queueHooks"))&&n.empty&&(r++,n.empty.add(s));return s(),i.promise(t)}});var Ie=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,We=new RegExp("^(?:([+-])=|)("+Ie+")([a-z%]*)$","i"),$e=["Top","Right","Bottom","Left"],Be=function(e,t){return e=t||e,"none"===e.style.display||""===e.style.display&&xe.contains(e.ownerDocument,e)&&"none"===xe.css(e,"display")},ze=function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i},Xe={};xe.fn.extend({show:function(){return T(this,!0)},hide:function(){return T(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Be(this)?xe(this).show():xe(this).hide()})}});var Ue=/^(?:checkbox|radio)$/i,Ve=/<([a-z][^\/\0>\x20\t\r\n\f]+)/i,Ge=/^$|\/(?:java|ecma)script/i,Ye={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};Ye.optgroup=Ye.option,Ye.tbody=Ye.tfoot=Ye.colgroup=Ye.caption=Ye.thead,Ye.th=Ye.td;var Qe=/<|&#?\w+;/;!function(){var e=se.createDocumentFragment(),t=e.appendChild(se.createElement("div")),n=se.createElement("input");n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),t.appendChild(n),ye.checkClone=t.cloneNode(!0).cloneNode(!0).lastChild.checked,t.innerHTML="<textarea>x</textarea>",ye.noCloneChecked=!!t.cloneNode(!0).lastChild.defaultValue}();var Je=se.documentElement,Ke=/^key/,Ze=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,et=/^([^.]*)(?:\.(.+)|)/;xe.event={global:{},add:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=Fe.get(e);if(v)for(n.handler&&(o=n,n=o.handler,i=o.selector),i&&xe.find.matchesSelector(Je,i),n.guid||(n.guid=xe.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(t){return void 0!==xe&&xe.event.triggered!==t.type?xe.event.dispatch.apply(e,arguments):void 0}),t=(t||"").match(Le)||[""],l=t.length;l--;)s=et.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p&&(f=xe.event.special[p]||{},p=(i?f.delegateType:f.bindType)||p,f=xe.event.special[p]||{},c=xe.extend({type:p,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&xe.expr.match.needsContext.test(i),namespace:h.join(".")},o),(d=u[p])||(d=u[p]=[],d.delegateCount=0,f.setup&&!1!==f.setup.call(e,r,h,a)||e.addEventListener&&e.addEventListener(p,a)),f.add&&(f.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),xe.event.global[p]=!0)},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,d,p,h,g,v=Fe.hasData(e)&&Fe.get(e);if(v&&(u=v.events)){for(t=(t||"").match(Le)||[""],l=t.length;l--;)if(s=et.exec(t[l])||[],p=g=s[1],h=(s[2]||"").split(".").sort(),p){for(f=xe.event.special[p]||{},p=(r?f.delegateType:f.bindType)||p,d=u[p]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=d.length;o--;)c=d[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,f.remove&&f.remove.call(e,c));a&&!d.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||xe.removeEvent(e,p,v.handle),delete u[p])}else for(p in u)xe.event.remove(e,p+t[l],n,r,!0);xe.isEmptyObject(u)&&Fe.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=xe.event.fix(e),u=new Array(arguments.length),l=(Fe.get(this,"events")||{})[s.type]||[],c=xe.event.special[s.type]||{};for(u[0]=s,t=1;t<arguments.length;t++)u[t]=arguments[t];if(s.delegateTarget=this,!c.preDispatch||!1!==c.preDispatch.call(this,s)){for(a=xe.event.handlers.call(this,s,l),t=0;(i=a[t++])&&!s.isPropagationStopped();)for(s.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!s.isImmediatePropagationStopped();)s.rnamespace&&!s.rnamespace.test(o.namespace)||(s.handleObj=o,s.data=o.data,void 0!==(r=((xe.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,u))&&!1===(s.result=r)&&(s.preventDefault(),s.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,s),s.result}},handlers:function(e,t){var n,r,i,o,a,s=[],u=t.delegateCount,l=e.target;if(u&&l.nodeType&&!("click"===e.type&&e.button>=1))for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(o=[],a={},n=0;n<u;n++)r=t[n],i=r.selector+" ",void 0===a[i]&&(a[i]=r.needsContext?xe(i,this).index(l)>-1:xe.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}return l=this,u<t.length&&s.push({elem:l,handlers:t.slice(u)}),s},addProp:function(e,t){Object.defineProperty(xe.Event.prototype,e,{enumerable:!0,configurable:!0,get:xe.isFunction(t)?function(){if(this.originalEvent)return t(this.originalEvent)}:function(){if(this.originalEvent)return this.originalEvent[e]},set:function(t){Object.defineProperty(this,e,{enumerable:!0,configurable:!0,writable:!0,value:t})}})},fix:function(e){return e[xe.expando]?e:new xe.Event(e)},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==N()&&this.focus)return this.focus(),!1},delegateType:"focusin"},blur:{trigger:function(){if(this===N()&&this.blur)return this.blur(),!1},delegateType:"focusout"},click:{trigger:function(){if("checkbox"===this.type&&this.click&&l(this,"input"))return this.click(),!1},_default:function(e){return l(e.target,"a")}},beforeunload:{postDispatch:function(e){void 0!==e.result&&e.originalEvent&&(e.originalEvent.returnValue=e.result)}}}},xe.removeEvent=function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n)},xe.Event=function(e,t){if(!(this instanceof xe.Event))return new xe.Event(e,t);e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||void 0===e.defaultPrevented&&!1===e.returnValue?E:j,this.target=e.target&&3===e.target.nodeType?e.target.parentNode:e.target,this.currentTarget=e.currentTarget,this.relatedTarget=e.relatedTarget):this.type=e,t&&xe.extend(this,t),this.timeStamp=e&&e.timeStamp||xe.now(),this[xe.expando]=!0},xe.Event.prototype={constructor:xe.Event,isDefaultPrevented:j,isPropagationStopped:j,isImmediatePropagationStopped:j,isSimulated:!1,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=E,e&&!this.isSimulated&&e.preventDefault()},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=E,e&&!this.isSimulated&&e.stopPropagation()},stopImmediatePropagation:function(){var e=this.originalEvent;this.isImmediatePropagationStopped=E,e&&!this.isSimulated&&e.stopImmediatePropagation(),this.stopPropagation()}},xe.each({altKey:!0,bubbles:!0,cancelable:!0,changedTouches:!0,ctrlKey:!0,detail:!0,eventPhase:!0,metaKey:!0,pageX:!0,pageY:!0,shiftKey:!0,view:!0,char:!0,charCode:!0,key:!0,keyCode:!0,button:!0,buttons:!0,clientX:!0,clientY:!0,offsetX:!0,offsetY:!0,pointerId:!0,pointerType:!0,screenX:!0,screenY:!0,targetTouches:!0,toElement:!0,touches:!0,which:function(e){var t=e.button;return null==e.which&&Ke.test(e.type)?null!=e.charCode?e.charCode:e.keyCode:!e.which&&void 0!==t&&Ze.test(e.type)?1&t?1:2&t?3:4&t?2:0:e.which}},xe.event.addProp),xe.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(e,t){xe.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return i&&(i===r||xe.contains(r,i))||(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),xe.fn.extend({on:function(e,t,n,r){return D(this,e,t,n,r)},one:function(e,t,n,r){return D(this,e,t,n,r,1)},off:function(e,t,n){var r,o;if(e&&e.preventDefault&&e.handleObj)return r=e.handleObj,xe(e.delegateTarget).off(r.namespace?r.origType+"."+r.namespace:r.origType,r.selector,r.handler),this;if("object"===(void 0===e?"undefined":i(e))){for(o in e)this.off(o,t,e[o]);return this}return!1!==t&&"function"!=typeof t||(n=t,t=void 0),!1===n&&(n=j),this.each(function(){xe.event.remove(this,e,n,t)})}});var tt=/<script|<style|<link/i,nt=/checked\s*(?:[^=]|=\s*.checked.)/i,rt=/^true\/(.*)/,it=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;xe.extend({htmlPrefilter:function(e){return e.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,"<$1></$2>")},clone:function(e,t,n){var r,i,o,a,s=e.cloneNode(!0),u=xe.contains(e.ownerDocument,e);if(!(ye.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||xe.isXMLDoc(e)))for(a=C(s),o=C(e),r=0,i=o.length;r<i;r++)P(o[r],a[r]);if(t)if(n)for(o=o||C(e),a=a||C(s),r=0,i=o.length;r<i;r++)H(o[r],a[r]);else H(e,s);return a=C(s,"script"),a.length>0&&k(a,!u&&C(e,"script")),s},cleanData:function(e){for(var t,n,r,i=xe.event.special,o=0;void 0!==(n=e[o]);o++)if(Oe(n)){if(t=n[Fe.expando]){if(t.events)for(r in t.events)i[r]?xe.event.remove(n,r):xe.removeEvent(n,r,t.handle);n[Fe.expando]=void 0}n[Re.expando]&&(n[Re.expando]=void 0)}}}),xe.fn.extend({detach:function(e){return F(this,e,!0)},remove:function(e){return F(this,e)},text:function(e){return Pe(this,function(e){return void 0===e?xe.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return O(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){A(this,e).appendChild(e)}})},prepend:function(){return O(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=A(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return O(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return O(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(xe.cleanData(C(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return xe.clone(this,e,t)})},html:function(e){return Pe(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!tt.test(e)&&!Ye[(Ve.exec(e)||["",""])[1].toLowerCase()]){e=xe.htmlPrefilter(e);try{for(;n<r;n++)t=this[n]||{},1===t.nodeType&&(xe.cleanData(C(t,!1)),t.innerHTML=e);t=0}catch(e){}}t&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=[];return O(this,arguments,function(t){var n=this.parentNode;xe.inArray(this,e)<0&&(xe.cleanData(C(this)),n&&n.replaceChild(t,this))},e)}}),xe.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){xe.fn[e]=function(e){for(var n,r=[],i=xe(e),o=i.length-1,a=0;a<=o;a++)n=a===o?this:this.clone(!0),xe(i[a])[t](n),fe.apply(r,n.get());return this.pushStack(r)}});var ot=/^margin/,at=new RegExp("^("+Ie+")(?!px)[a-z%]+$","i"),st=function(e){var t=e.ownerDocument.defaultView;return t&&t.opener||(t=o),t.getComputedStyle(e)};!function(){function e(){if(s){s.style.cssText="box-sizing:border-box;position:relative;display:block;margin:auto;border:1px;padding:1px;top:1%;width:50%",s.innerHTML="",Je.appendChild(a);var e=o.getComputedStyle(s);t="1%"!==e.top,i="2px"===e.marginLeft,n="4px"===e.width,s.style.marginRight="50%",r="4px"===e.marginRight,Je.removeChild(a),s=null}}var t,n,r,i,a=se.createElement("div"),s=se.createElement("div");s.style&&(s.style.backgroundClip="content-box",s.cloneNode(!0).style.backgroundClip="",ye.clearCloneStyle="content-box"===s.style.backgroundClip,a.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",a.appendChild(s),xe.extend(ye,{pixelPosition:function(){return e(),t},boxSizingReliable:function(){return e(),n},pixelMarginRight:function(){return e(),r},reliableMarginLeft:function(){return e(),i}}))}();var ut=/^(none|table(?!-c[ea]).+)/,lt=/^--/,ct={position:"absolute",visibility:"hidden",display:"block"},ft={letterSpacing:"0",fontWeight:"400"},dt=["Webkit","Moz","ms"],pt=se.createElement("div").style;xe.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=R(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{float:"cssFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=xe.camelCase(t),l=lt.test(t),c=e.style;if(l||(t=I(u)),s=xe.cssHooks[t]||xe.cssHooks[u],void 0===n)return s&&"get"in s&&void 0!==(o=s.get(e,!1,r))?o:c[t];a=void 0===n?"undefined":i(n),"string"===a&&(o=We.exec(n))&&o[1]&&(n=b(e,t,o),a="number"),null!=n&&n===n&&("number"===a&&(n+=o&&o[3]||(xe.cssNumber[u]?"":"px")),ye.clearCloneStyle||""!==n||0!==t.indexOf("background")||(c[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,r))||(l?c.setProperty(t,n):c[t]=n))}},css:function(e,t,n,r){var i,o,a,s=xe.camelCase(t);return lt.test(t)||(t=I(s)),a=xe.cssHooks[t]||xe.cssHooks[s],a&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=R(e,t,r)),"normal"===i&&t in ft&&(i=ft[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),xe.each(["height","width"],function(e,t){xe.cssHooks[t]={get:function(e,n,r){if(n)return!ut.test(xe.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?B(e,t,r):ze(e,ct,function(){return B(e,t,r)})},set:function(e,n,r){var i,o=r&&st(e),a=r&&$(e,t,r,"border-box"===xe.css(e,"boxSizing",!1,o),o);return a&&(i=We.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=xe.css(e,t)),W(e,n,a)}}}),xe.cssHooks.marginLeft=M(ye.reliableMarginLeft,function(e,t){if(t)return(parseFloat(R(e,"marginLeft"))||e.getBoundingClientRect().left-ze(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),xe.each({margin:"",padding:"",border:"Width"},function(e,t){xe.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+$e[r]+t]=o[r]||o[r-2]||o[0];return i}},ot.test(e)||(xe.cssHooks[e+t].set=W)}),xe.fn.extend({css:function(e,t){return Pe(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=st(e),i=t.length;a<i;a++)o[t[a]]=xe.css(e,t[a],!1,r);return o}return void 0!==n?xe.style(e,t,n):xe.css(e,t)},e,t,arguments.length>1)}}),xe.Tween=z,z.prototype={constructor:z,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||xe.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(xe.cssNumber[n]?"":"px")},cur:function(){var e=z.propHooks[this.prop];return e&&e.get?e.get(this):z.propHooks._default.get(this)},run:function(e){var t,n=z.propHooks[this.prop];return this.options.duration?this.pos=t=xe.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):z.propHooks._default.set(this),this}},z.prototype.init.prototype=z.prototype,z.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=xe.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){xe.fx.step[e.prop]?xe.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[xe.cssProps[e.prop]]&&!xe.cssHooks[e.prop]?e.elem[e.prop]=e.now:xe.style(e.elem,e.prop,e.now+e.unit)}}},z.propHooks.scrollTop=z.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},xe.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},xe.fx=z.prototype.init,xe.fx.step={};var ht,gt,vt=/^(?:toggle|show|hide)$/,mt=/queueHooks$/;xe.Animation=xe.extend(J,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return b(n.elem,e,We.exec(t),n),n}]},tweener:function(e,t){xe.isFunction(e)?(t=e,e=["*"]):e=e.match(Le);for(var n,r=0,i=e.length;r<i;r++)n=e[r],J.tweeners[n]=J.tweeners[n]||[],J.tweeners[n].unshift(t)},prefilters:[Y],prefilter:function(e,t){t?J.prefilters.unshift(e):J.prefilters.push(e)}}),xe.speed=function(e,t,n){var r=e&&"object"===(void 0===e?"undefined":i(e))?xe.extend({},e):{complete:n||!n&&t||xe.isFunction(e)&&e,duration:e,easing:n&&t||t&&!xe.isFunction(t)&&t};return xe.fx.off?r.duration=0:"number"!=typeof r.duration&&(r.duration in xe.fx.speeds?r.duration=xe.fx.speeds[r.duration]:r.duration=xe.fx.speeds._default),null!=r.queue&&!0!==r.queue||(r.queue="fx"),r.old=r.complete,r.complete=function(){xe.isFunction(r.old)&&r.old.call(this),r.queue&&xe.dequeue(this,r.queue)},r},xe.fn.extend({fadeTo:function(e,t,n,r){return this.filter(Be).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=xe.isEmptyObject(e),o=xe.speed(t,n,r),a=function(){var t=J(this,xe.extend({},e),o);(i||Fe.get(this,"finish"))&&t.stop(!0)};return a.finish=a,i||!1===o.queue?this.each(a):this.queue(o.queue,a)},stop:function(e,t,n){var r=function(e){var t=e.stop;delete e.stop,t(n)};return"string"!=typeof e&&(n=t,t=e,e=void 0),t&&!1!==e&&this.queue(e||"fx",[]),this.each(function(){var t=!0,i=null!=e&&e+"queueHooks",o=xe.timers,a=Fe.get(this);if(i)a[i]&&a[i].stop&&r(a[i]);else for(i in a)a[i]&&a[i].stop&&mt.test(i)&&r(a[i]);for(i=o.length;i--;)o[i].elem!==this||null!=e&&o[i].queue!==e||(o[i].anim.stop(n),t=!1,o.splice(i,1));!t&&n||xe.dequeue(this,e)})},finish:function(e){return!1!==e&&(e=e||"fx"),this.each(function(){var t,n=Fe.get(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=xe.timers,a=r?r.length:0;for(n.finish=!0,xe.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;t<a;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),xe.each(["toggle","show","hide"],function(e,t){var n=xe.fn[t];xe.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(V(t,!0),e,r,i)}}),xe.each({slideDown:V("show"),slideUp:V("hide"),slideToggle:V("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){xe.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),xe.timers=[],xe.fx.tick=function(){var e,t=0,n=xe.timers;for(ht=xe.now();t<n.length;t++)(e=n[t])()||n[t]!==e||n.splice(t--,1);n.length||xe.fx.stop(),ht=void 0},xe.fx.timer=function(e){xe.timers.push(e),xe.fx.start()},xe.fx.interval=13,xe.fx.start=function(){gt||(gt=!0,X())},xe.fx.stop=function(){gt=null},xe.fx.speeds={slow:600,fast:200,_default:400},xe.fn.delay=function(e,t){return e=xe.fx?xe.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=o.setTimeout(t,e);n.stop=function(){o.clearTimeout(r)}})},function(){var e=se.createElement("input"),t=se.createElement("select"),n=t.appendChild(se.createElement("option"));e.type="checkbox",ye.checkOn=""!==e.value,ye.optSelected=n.selected,e=se.createElement("input"),e.value="t",e.type="radio",ye.radioValue="t"===e.value}();var yt,xt=xe.expr.attrHandle;xe.fn.extend({attr:function(e,t){return Pe(this,xe.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){xe.removeAttr(this,e)})}}),xe.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?xe.prop(e,t,n):(1===o&&xe.isXMLDoc(e)||(i=xe.attrHooks[t.toLowerCase()]||(xe.expr.match.bool.test(t)?yt:void 0)),void 0!==n?null===n?void xe.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=xe.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!ye.radioValue&&"radio"===t&&l(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(Le);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),yt={set:function(e,t,n){return!1===t?xe.removeAttr(e,n):e.setAttribute(n,n),n}},xe.each(xe.expr.match.bool.source.match(/\w+/g),function(e,t){var n=xt[t]||xe.find.attr;xt[t]=function(e,t,r){var i,o,a=t.toLowerCase();return r||(o=xt[a],xt[a]=i,i=null!=n(e,t,r)?a:null,xt[a]=o),i}});var bt=/^(?:input|select|textarea|button)$/i,wt=/^(?:a|area)$/i;xe.fn.extend({prop:function(e,t){return Pe(this,xe.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[xe.propFix[e]||e]})}}),xe.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&xe.isXMLDoc(e)||(t=xe.propFix[t]||t,i=xe.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=xe.find.attr(e,"tabindex");return t?parseInt(t,10):bt.test(e.nodeName)||wt.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),ye.optSelected||(xe.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),xe.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){xe.propFix[this.toLowerCase()]=this}),xe.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(xe.isFunction(e))return this.each(function(t){xe(this).addClass(e.call(this,t,Z(this)))});if("string"==typeof e&&e)for(t=e.match(Le)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(xe.isFunction(e))return this.each(function(t){xe(this).removeClass(e.call(this,t,Z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(Le)||[];n=this[u++];)if(i=Z(n),r=1===n.nodeType&&" "+K(i)+" "){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=K(r),i!==s&&n.setAttribute("class",s)}return this},toggleClass:function(e,t){var n=void 0===e?"undefined":i(e);return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):xe.isFunction(e)?this.each(function(n){xe(this).toggleClass(e.call(this,n,Z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=xe(this),o=e.match(Le)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=Z(this),t&&Fe.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":Fe.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+K(Z(n))+" ").indexOf(t)>-1)return!0;return!1}});xe.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=xe.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,xe(this).val()):e,null==i?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=xe.map(i,function(e){return null==e?"":e+""})),(t=xe.valHooks[this.type]||xe.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=xe.valHooks[i.type]||xe.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(/\r/g,""):null==n?"":n)}}}),xe.extend({valHooks:{option:{get:function(e){var t=xe.find.attr(e,"value");return null!=t?t:K(xe.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r<u;r++)if(n=i[r],(n.selected||r===o)&&!n.disabled&&(!n.parentNode.disabled||!l(n.parentNode,"optgroup"))){if(t=xe(n).val(),a)return t;s.push(t)}return s},set:function(e,t){for(var n,r,i=e.options,o=xe.makeArray(t),a=i.length;a--;)r=i[a],(r.selected=xe.inArray(xe.valHooks.option.get(r),o)>-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),xe.each(["radio","checkbox"],function(){xe.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=xe.inArray(xe(e).val(),t)>-1}},ye.checkOn||(xe.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Tt=/^(?:focusinfocus|focusoutblur)$/;xe.extend(xe.event,{trigger:function(e,t,n,r){var a,s,u,l,c,f,d,p=[n||se],h=ge.call(e,"type")?e.type:e,g=ge.call(e,"namespace")?e.namespace.split("."):[];if(s=u=n=n||se,3!==n.nodeType&&8!==n.nodeType&&!Tt.test(h+xe.event.triggered)&&(h.indexOf(".")>-1&&(g=h.split("."),h=g.shift(),g.sort()),c=h.indexOf(":")<0&&"on"+h,e=e[xe.expando]?e:new xe.Event(h,"object"===(void 0===e?"undefined":i(e))&&e),e.isTrigger=r?2:3,e.namespace=g.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=n),t=null==t?[e]:xe.makeArray(t,[e]),d=xe.event.special[h]||{},r||!d.trigger||!1!==d.trigger.apply(n,t))){if(!r&&!d.noBubble&&!xe.isWindow(n)){for(l=d.delegateType||h,Tt.test(l+h)||(s=s.parentNode);s;s=s.parentNode)p.push(s),u=s;u===(n.ownerDocument||se)&&p.push(u.defaultView||u.parentWindow||o)}for(a=0;(s=p[a++])&&!e.isPropagationStopped();)e.type=a>1?l:d.bindType||h,f=(Fe.get(s,"events")||{})[e.type]&&Fe.get(s,"handle"),f&&f.apply(s,t),(f=c&&s[c])&&f.apply&&Oe(s)&&(e.result=f.apply(s,t),!1===e.result&&e.preventDefault());return e.type=h,r||e.isDefaultPrevented()||d._default&&!1!==d._default.apply(p.pop(),t)||!Oe(n)||c&&xe.isFunction(n[h])&&!xe.isWindow(n)&&(u=n[c],u&&(n[c]=null),xe.event.triggered=h,n[h](),xe.event.triggered=void 0,u&&(n[c]=u)),e.result}},simulate:function(e,t,n){var r=xe.extend(new xe.Event,n,{type:e,isSimulated:!0});xe.event.trigger(r,null,t)}}),xe.fn.extend({trigger:function(e,t){return this.each(function(){xe.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return xe.event.trigger(e,t,n,!0)}}),xe.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,t){xe.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),xe.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),ye.focusin="onfocusin"in o,ye.focusin||xe.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){xe.event.simulate(t,e.target,xe.event.fix(e))};xe.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=Fe.access(r,t);i||r.addEventListener(e,n,!0),Fe.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=Fe.access(r,t)-1;i?Fe.access(r,t,i):(r.removeEventListener(e,n,!0),Fe.remove(r,t))}}});var Ct=o.location,kt=xe.now(),St=/\?/;xe.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new o.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||xe.error("Invalid XML: "+e),t};var Et=/\[\]$/,jt=/^(?:submit|button|image|reset|file)$/i,Nt=/^(?:input|select|textarea|keygen)/i;xe.param=function(e,t){var n,r=[],i=function(e,t){var n=xe.isFunction(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!xe.isPlainObject(e))xe.each(e,function(){i(this.name,this.value)});else for(n in e)ee(n,e[n],t,i);return r.join("&")},xe.fn.extend({serialize:function(){return xe.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=xe.prop(this,"elements");return e?xe.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!xe(this).is(":disabled")&&Nt.test(this.nodeName)&&!jt.test(e)&&(this.checked||!Ue.test(e))}).map(function(e,t){var n=xe(this).val();return null==n?null:Array.isArray(n)?xe.map(n,function(e){return{name:t.name,value:e.replace(/\r?\n/g,"\r\n")}}):{name:t.name,value:n.replace(/\r?\n/g,"\r\n")}}).get()}});var Dt=/^(.*?):[ \t]*([^\r\n]*)$/gm,At=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Lt=/^(?:GET|HEAD)$/,qt={},Ht={},Pt="*/".concat("*"),Ot=se.createElement("a");Ot.href=Ct.href,xe.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Ct.href,type:"GET",isLocal:At.test(Ct.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Pt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":xe.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?re(re(e,xe.ajaxSettings),t):re(xe.ajaxSettings,e)},ajaxPrefilter:te(qt),ajaxTransport:te(Ht),ajax:function(e,t){function n(e,t,n,i){var u,c,p,h,w,T=t;f||(f=!0,l&&o.clearTimeout(l),r=void 0,s=i||"",k.readyState=e>0?4:0,u=e>=200&&e<300||304===e,n&&(h=ie(g,k,n)),h=oe(g,h,k,u),u?(g.ifModified&&(w=k.getResponseHeader("Last-Modified"),w&&(xe.lastModified[a]=w),(w=k.getResponseHeader("etag"))&&(xe.etag[a]=w)),204===e||"HEAD"===g.type?T="nocontent":304===e?T="notmodified":(T=h.state,c=h.data,p=h.error,u=!p)):(p=T,!e&&T||(T="error",e<0&&(e=0))),k.status=e,k.statusText=(t||T)+"",u?y.resolveWith(v,[c,T,k]):y.rejectWith(v,[k,T,p]),k.statusCode(b),b=void 0,d&&m.trigger(u?"ajaxSuccess":"ajaxError",[k,g,u?c:p]),x.fireWith(v,[k,T]),d&&(m.trigger("ajaxComplete",[k,g]),--xe.active||xe.event.trigger("ajaxStop")))}"object"===(void 0===e?"undefined":i(e))&&(t=e,e=void 0),t=t||{};var r,a,s,u,l,c,f,d,p,h,g=xe.ajaxSetup({},t),v=g.context||g,m=g.context&&(v.nodeType||v.jquery)?xe(v):xe.event,y=xe.Deferred(),x=xe.Callbacks("once memory"),b=g.statusCode||{},w={},T={},C="canceled",k={readyState:0,getResponseHeader:function(e){var t;if(f){if(!u)for(u={};t=Dt.exec(s);)u[t[1].toLowerCase()]=t[2];t=u[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return f?s:null},setRequestHeader:function(e,t){return null==f&&(e=T[e.toLowerCase()]=T[e.toLowerCase()]||e,w[e]=t),this},overrideMimeType:function(e){return null==f&&(g.mimeType=e),this},statusCode:function(e){var t;if(e)if(f)k.always(e[k.status]);else for(t in e)b[t]=[b[t],e[t]];return this},abort:function(e){var t=e||C;return r&&r.abort(t),n(0,t),this}};if(y.promise(k),g.url=((e||g.url||Ct.href)+"").replace(/^\/\//,Ct.protocol+"//"),g.type=t.method||t.type||g.method||g.type,g.dataTypes=(g.dataType||"*").toLowerCase().match(Le)||[""],null==g.crossDomain){c=se.createElement("a");try{c.href=g.url,c.href=c.href,g.crossDomain=Ot.protocol+"//"+Ot.host!=c.protocol+"//"+c.host}catch(e){g.crossDomain=!0}}if(g.data&&g.processData&&"string"!=typeof g.data&&(g.data=xe.param(g.data,g.traditional)),ne(qt,g,t,k),f)return k;d=xe.event&&g.global,d&&0==xe.active++&&xe.event.trigger("ajaxStart"),g.type=g.type.toUpperCase(),g.hasContent=!Lt.test(g.type),a=g.url.replace(/#.*$/,""),g.hasContent?g.data&&g.processData&&0===(g.contentType||"").indexOf("application/x-www-form-urlencoded")&&(g.data=g.data.replace(/%20/g,"+")):(h=g.url.slice(a.length),g.data&&(a+=(St.test(a)?"&":"?")+g.data,delete g.data),!1===g.cache&&(a=a.replace(/([?&])_=[^&]*/,"$1"),h=(St.test(a)?"&":"?")+"_="+kt+++h),g.url=a+h),g.ifModified&&(xe.lastModified[a]&&k.setRequestHeader("If-Modified-Since",xe.lastModified[a]),xe.etag[a]&&k.setRequestHeader("If-None-Match",xe.etag[a])),(g.data&&g.hasContent&&!1!==g.contentType||t.contentType)&&k.setRequestHeader("Content-Type",g.contentType),k.setRequestHeader("Accept",g.dataTypes[0]&&g.accepts[g.dataTypes[0]]?g.accepts[g.dataTypes[0]]+("*"!==g.dataTypes[0]?", "+Pt+"; q=0.01":""):g.accepts["*"]);for(p in g.headers)k.setRequestHeader(p,g.headers[p]);if(g.beforeSend&&(!1===g.beforeSend.call(v,k,g)||f))return k.abort();if(C="abort",x.add(g.complete),k.done(g.success),k.fail(g.error),r=ne(Ht,g,t,k)){if(k.readyState=1,d&&m.trigger("ajaxSend",[k,g]),f)return k;g.async&&g.timeout>0&&(l=o.setTimeout(function(){k.abort("timeout")},g.timeout));try{f=!1,r.send(w,n)}catch(e){if(f)throw e;n(-1,e)}}else n(-1,"No Transport");return k},getJSON:function(e,t,n){return xe.get(e,t,n,"json")},getScript:function(e,t){return xe.get(e,void 0,t,"script")}}),xe.each(["get","post"],function(e,t){xe[t]=function(e,n,r,i){return xe.isFunction(n)&&(i=i||r,r=n,n=void 0),xe.ajax(xe.extend({url:e,type:t,dataType:i,data:n,success:r},xe.isPlainObject(e)&&e))}}),xe._evalUrl=function(e){return xe.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},xe.fn.extend({wrapAll:function(e){var t;return this[0]&&(xe.isFunction(e)&&(e=e.call(this[0])),t=xe(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return xe.isFunction(e)?this.each(function(t){xe(this).wrapInner(e.call(this,t))}):this.each(function(){var t=xe(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=xe.isFunction(e);return this.each(function(n){xe(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){xe(this).replaceWith(this.childNodes)}),this}}),xe.expr.pseudos.hidden=function(e){return!xe.expr.pseudos.visible(e)},xe.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},xe.ajaxSettings.xhr=function(){try{return new o.XMLHttpRequest}catch(e){}};var Ft={0:200,1223:204},Rt=xe.ajaxSettings.xhr();ye.cors=!!Rt&&"withCredentials"in Rt,ye.ajax=Rt=!!Rt,xe.ajaxTransport(function(e){var t,n;if(ye.cors||Rt&&!e.crossDomain)return{send:function(r,i){var a,s=e.xhr();if(s.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(a in e.xhrFields)s[a]=e.xhrFields[a];e.mimeType&&s.overrideMimeType&&s.overrideMimeType(e.mimeType),e.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(a in r)s.setRequestHeader(a,r[a]);t=function(e){return function(){t&&(t=n=s.onload=s.onerror=s.onabort=s.onreadystatechange=null,"abort"===e?s.abort():"error"===e?"number"!=typeof s.status?i(0,"error"):i(s.status,s.statusText):i(Ft[s.status]||s.status,s.statusText,"text"!==(s.responseType||"text")||"string"!=typeof s.responseText?{binary:s.response}:{text:s.responseText},s.getAllResponseHeaders()))}},s.onload=t(),n=s.onerror=t("error"),void 0!==s.onabort?s.onabort=n:s.onreadystatechange=function(){4===s.readyState&&o.setTimeout(function(){t&&n()})},t=t("abort");try{s.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),xe.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),xe.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return xe.globalEval(e),e}}}),xe.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),xe.ajaxTransport("script",function(e){if(e.crossDomain){var t,n;return{send:function(r,i){t=xe("<script>").prop({charset:e.scriptCharset,src:e.url}).on("load error",n=function(e){t.remove(),n=null,e&&i("error"===e.type?404:200,e.type)}),se.head.appendChild(t[0])},abort:function(){n&&n()}}}});var Mt=[],_t=/(=)\?(?=&|$)|\?\?/;xe.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Mt.pop()||xe.expando+"_"+kt++;return this[e]=!0,e}}),xe.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,a,s=!1!==e.jsonp&&(_t.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&_t.test(e.data)&&"data");if(s||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=xe.isFunction(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,s?e[s]=e[s].replace(_t,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return a||xe.error(r+" was not called"),a[0]},e.dataTypes[0]="json",i=o[r],o[r]=function(){a=arguments},n.always(function(){void 0===i?xe(o).removeProp(r):o[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Mt.push(r)),a&&xe.isFunction(i)&&i(a[0]),a=i=void 0}),"script"}),ye.createHTMLDocument=function(){var e=se.implementation.createHTMLDocument("").body;return e.innerHTML="<form></form><form></form>",2===e.childNodes.length}(),xe.parseHTML=function(e,t,n){if("string"!=typeof e)return[];"boolean"==typeof t&&(n=t,t=!1);var r,i,o;return t||(ye.createHTMLDocument?(t=se.implementation.createHTMLDocument(""),r=t.createElement("base"),r.href=se.location.href,t.head.appendChild(r)):t=se),i=Se.exec(e),o=!n&&[],i?[t.createElement(i[1])]:(i=S([e],t,o),o&&o.length&&xe(o).remove(),xe.merge([],i.childNodes))},xe.fn.load=function(e,t,n){var r,o,a,s=this,u=e.indexOf(" ");return u>-1&&(r=K(e.slice(u)),e=e.slice(0,u)),xe.isFunction(t)?(n=t,t=void 0):t&&"object"===(void 0===t?"undefined":i(t))&&(o="POST"),s.length>0&&xe.ajax({url:e,type:o||"GET",dataType:"html",data:t}).done(function(e){a=arguments,s.html(r?xe("<div>").append(xe.parseHTML(e)).find(r):e)}).always(n&&function(e,t){s.each(function(){n.apply(this,a||[e.responseText,t,e])})}),this},xe.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){xe.fn[t]=function(e){return this.on(t,e)}}),xe.expr.pseudos.animated=function(e){return xe.grep(xe.timers,function(t){return e===t.elem}).length},xe.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=xe.css(e,"position"),f=xe(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=xe.css(e,"top"),u=xe.css(e,"left"),l=("absolute"===c||"fixed"===c)&&(o+u).indexOf("auto")>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),xe.isFunction(t)&&(t=t.call(e,n,xe.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},xe.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){xe.offset.setOffset(this,e,t)});var t,n,r,i,o=this[0];if(o)return o.getClientRects().length?(r=o.getBoundingClientRect(),t=o.ownerDocument,n=t.documentElement,i=t.defaultView,{top:r.top+i.pageYOffset-n.clientTop,left:r.left+i.pageXOffset-n.clientLeft}):{top:0,left:0}},position:function(){if(this[0]){var e,t,n=this[0],r={top:0,left:0};return"fixed"===xe.css(n,"position")?t=n.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),l(e[0],"html")||(r=e.offset()),r={top:r.top+xe.css(e[0],"borderTopWidth",!0),left:r.left+xe.css(e[0],"borderLeftWidth",!0)}),{top:t.top-r.top-xe.css(n,"marginTop",!0),left:t.left-r.left-xe.css(n,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent;e&&"static"===xe.css(e,"position");)e=e.offsetParent;return e||Je})}}),xe.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n="pageYOffset"===t;xe.fn[e]=function(r){return Pe(this,function(e,r,i){var o;if(xe.isWindow(e)?o=e:9===e.nodeType&&(o=e.defaultView),void 0===i)return o?o[t]:e[r];o?o.scrollTo(n?o.pageXOffset:i,n?i:o.pageYOffset):e[r]=i},e,r,arguments.length)}}),xe.each(["top","left"],function(e,t){xe.cssHooks[t]=M(ye.pixelPosition,function(e,n){if(n)return n=R(e,t),at.test(n)?xe(e).position()[t]+"px":n})}),xe.each({Height:"height",Width:"width"},function(e,t){xe.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){xe.fn[r]=function(i,o){var a=arguments.length&&(n||"boolean"!=typeof i),s=n||(!0===i||!0===o?"margin":"border");return Pe(this,function(t,n,i){var o;return xe.isWindow(t)?0===r.indexOf("outer")?t["inner"+e]:t.document.documentElement["client"+e]:9===t.nodeType?(o=t.documentElement,Math.max(t.body["scroll"+e],o["scroll"+e],t.body["offset"+e],o["offset"+e],o["client"+e])):void 0===i?xe.css(t,n,s):xe.style(t,n,i,s)},t,a?i:void 0,a)}})}),xe.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),xe.holdReady=function(e){e?xe.readyWait++:xe.ready(!0)},xe.isArray=Array.isArray,xe.parseJSON=JSON.parse,xe.nodeName=l,n=[],void 0!==(r=function(){return xe}.apply(t,n))&&(e.exports=r);var It=o.jQuery,Wt=o.$;return xe.noConflict=function(e){return o.$===xe&&(o.$=Wt),e&&o.jQuery===xe&&(o.jQuery=It),xe},a||(o.jQuery=o.$=xe),xe})}).call(t,n(3)(e))},function(e,t,n){"use strict";function r(){var e=(0,a.default)("#quick_add_affiliate_link"),t=e.find("form");e.on("click","button[type='submit']",function(){if(t[0].checkValidity()){var n=(0,a.default)(this).prop("name"),r=t.serializeArray(),o=e.data("htmleditor"),s=o?parent.ThirstyLinkPicker.get_html_editor_selection().text:parent.ThirstyLinkPicker.editor.selection.getContent(),u=void 0,l=void 0,c=void 0;t.find(".submit-row .ta_spinner").css("display","inline-block"),a.default.post(parent.ajaxurl,r,function(e){if("success"==e.status)if(t[0].reset(),t.find(".submit-row .ta_spinner").hide(),"add_link_and_insert"==n){if("shortcode"===e.link_insertion_type){var r=s||e.content,a='[thirstylink ids="'+e.link_id+'"]'+r+"[/thirstylink]";o?parent.ThirstyLinkPicker.replace_html_editor_selected_text(a):(parent.ThirstyLinkPicker.editor.execCommand("Unlink",!1,!1),parent.ThirstyLinkPicker.editor.selection.setContent(a))}else{var f=e.other_atts,d=" ",p=void 0,h=void 0;if(o){for(h in f)d+=h+'="'+f[h]+'" ';l=e.class?' class="'+e.class+'"':"",c=e.title?' title="'+e.title+'"':"",s=s.trim()?s:e.name,u="<a"+l+c+' href="'+e.href+'" rel="'+e.rel+'" target="'+e.target+'" '+d+">"+s+"</a>",parent.ThirstyLinkPicker.replace_html_editor_selected_text(u)}else{if(p={class:e.class,title:e.title,href:e.href,rel:e.rel,target:e.target,"data-wplink-edit":null,"data-thirstylink-edit":null},"object"==(void 0===f?"undefined":i(f))&&Object.keys(f).length>0)for(h in f)p[h]=f[h];parent.ThirstyLinkPicker.editor.execCommand("Unlink",!1,!1),parent.ThirstyLinkPicker.editor.execCommand("mceInsertLink",!1,p),s.trim()||parent.ThirstyLinkPicker.editor.selection.setContent(e.content)}}parent.ThirstyLinkPicker.close_thickbox()}else parent.ThirstyLinkPicker.close_thickbox()},"json")}})}Object.defineProperty(t,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=r;var o=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(o)},function(e,t){},function(e,t,n){"use strict";e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}var i=n(0),o=r(i),a=n(1),s=r(a);n(2),(0,o.default)(document).ready(function(){(0,s.default)()})}]);
js/app/ta-editor.js ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var ThirstyLinkPicker;
2
+
3
+ jQuery( document ).ready( function($) {
4
+
5
+ ThirstyLinkPicker = {
6
+ editor : null,
7
+ editorinit : false,
8
+ linkNode : null,
9
+ inputInstance : null,
10
+ close_thickbox : function() {
11
+ tb_remove();
12
+ },
13
+
14
+ /**
15
+ * Get selected text on the HTML editor
16
+ *
17
+ * @since 3.0.0
18
+ */
19
+ get_html_editor_selection : function() {
20
+
21
+ var text_component,
22
+ selected_text = {},
23
+ sel, startPos, endPos;
24
+
25
+ text_component = document.getElementById( "replycontent" );
26
+ if (typeof text_component == "undefined" || ! jQuery(text_component).is( ":visible" ) ) // is not a comment reply
27
+ text_component = document.getElementById( "content" );
28
+
29
+ // IE version
30
+ if (parent.document.selection != undefined) {
31
+ text_component.focus();
32
+ sel = parent.document.selection.createRange();
33
+ selected_text.text = sel.text;
34
+ selected_text.start = sel.start;
35
+ selected_text.end = sel.end;
36
+ }
37
+
38
+ // Mozilla version
39
+ else if (text_component.selectionStart != undefined) {
40
+ startPos = text_component.selectionStart;
41
+ endPos = text_component.selectionEnd;
42
+ selected_text.text = text_component.value.substring(startPos, endPos)
43
+ selected_text.start = startPos;
44
+ selected_text.end = endPos;
45
+ }
46
+
47
+ return selected_text;
48
+ },
49
+
50
+ /**
51
+ * Replace selected text on the HTML editor.
52
+ *
53
+ * @since 3.0.0
54
+ */
55
+ replace_html_editor_selected_text : function( text , append = false ) {
56
+
57
+ var el = parent.document.getElementById("replycontent"),
58
+ sel = ThirstyLinkPicker.get_html_editor_selection(),
59
+ val;
60
+
61
+ if ( typeof el == "undefined" || ! $( el ).is( ":visible" ) ) // is not a comment reply
62
+ el = parent.document.getElementById( "content" );
63
+
64
+ val = el.value;
65
+ content = append ? sel.text + text : text;
66
+ el.value = val.slice( 0 , sel.start ) + content + val.slice( sel.end );
67
+
68
+ jQuery( el ).trigger('change'); // some addons require notice that something has changed
69
+ }
70
+ };
71
+
72
+ /**
73
+ * Event: Simple insert link search results selection.
74
+ * This event runs when a result selection is clicked. The purpose of this is to transfer the required data
75
+ * from the selection to the text input (inputInstance) so it can be processed in the thirstylink_apply custom tinymce command.
76
+ *
77
+ * @since 3.0.0
78
+ */
79
+ $( 'body' ).on( 'click' , '.affiliate-link-list li' , function( event ) {
80
+
81
+ event.preventDefault();
82
+
83
+ var $link = $(this),
84
+ $input = $link.closest( '.wp-thirstylink-input' ).find( 'input' );
85
+
86
+ $input.val( $link.data( 'href' ) )
87
+ .attr( 'data-aff-content' , $link.find( 'span' ).text() )
88
+ .attr( 'data-aff-class' , $link.data( 'class' ) )
89
+ .attr( 'data-aff-title' , $link.data( 'title' ) )
90
+ .attr( 'data-aff-rel' , $link.data( 'rel' ) )
91
+ .attr( 'data-aff-target' , $link.data( 'target' ) )
92
+ .attr( 'data-aff-link-insertion-type' , $link.data( 'link-insertion-type' ) )
93
+ .attr( 'data-aff-link-id' , $link.data( 'link-id' ) )
94
+ .attr( 'data-aff-other-atts' , $link.attr( 'data-other-atts' ) );
95
+ });
96
+
97
+ /**
98
+ * Register Text/Quicktags editor buttons.
99
+ *
100
+ * @since 3.0.0
101
+ */
102
+ if ( typeof QTags != 'undefined' && ta_editor_var.disable_qtag_buttons !== 'yes' ) {
103
+
104
+ QTags.addButton( "thirstyaffiliates_aff_link", "affiliate link", ta_display_affiliate_link_thickbox , "" , "" , ta_editor_var.html_editor_affiliate_link_title , 30 );
105
+ QTags.addButton( "thirstyaffiliates_quick_add_aff_Link", "quick add affiliate link", ta_display_quick_add_affiliate_thickbox , "" , "" , ta_editor_var.html_editor_quick_add_title , 31 );
106
+ }
107
+
108
+ /**
109
+ * Function to display the affiliate link thickbox for the HTML editor.
110
+ *
111
+ * @since 3.0.0
112
+ */
113
+ function ta_display_affiliate_link_thickbox() {
114
+
115
+ var post_id = $( '#post_ID' ).val();
116
+ tb_show( 'Add Affiliate Link' , window.ajaxurl + '?action=ta_advanced_add_affiliate_link&post_id=' + post_id + '&height=640&width=640&html_editor=true&TB_iframe=false' );
117
+ }
118
+
119
+ /**
120
+ * Function to display the quick add affiliate link thickbox for the HTML editor.
121
+ */
122
+ function ta_display_quick_add_affiliate_thickbox() {
123
+
124
+ var selection = ThirstyLinkPicker.get_html_editor_selection().text,
125
+ post_id = $( '#post_ID' ).val();
126
+
127
+ tb_show( 'Quick Add Affiliate Link' , window.ajaxurl + '?action=ta_quick_add_affiliate_link_thickbox&post_id=' + post_id + '&height=500&width=500&selection=' + selection + '&html_editor=true&TB_iframe=false' );
128
+ }
129
+ });
js/app/ta-guided-tour.js ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(){
2
+ window.TA = window.TA ||{ Admin: {} };
3
+ }());
4
+
5
+ (function($){
6
+
7
+ function Tour() {
8
+
9
+ if ( !ta_guided_tour_params.screen.elem )
10
+ return;
11
+ this.initPointer();
12
+
13
+ }
14
+
15
+ Tour.prototype.initPointer = function(){
16
+
17
+ var self = this;
18
+ self.$elem = $( ta_guided_tour_params.screen.elem ).pointer({
19
+ content: ta_guided_tour_params.screen.html,
20
+ width: 1000,
21
+ position: {
22
+ align: ta_guided_tour_params.screen.align,
23
+ edge: ta_guided_tour_params.screen.edge,
24
+ },
25
+ buttons: function( event, t ){
26
+ return self.createButtons( t );
27
+ },
28
+ }).pointer( 'open' );
29
+
30
+ var pointer_width = ( typeof ta_guided_tour_params.screen.width !== 'undefined' ) ? ta_guided_tour_params.screen.width : 320,
31
+ $wp_pointer = $( '.wp-pointer' );
32
+
33
+ $wp_pointer.css( 'width' , pointer_width );
34
+
35
+ // adjust the arrow pointer on the settings screen
36
+ if ( ta_guided_tour_params.screenid == 'thirstylink_page_thirsty-settings' ) {
37
+
38
+ var tab_width = self.$elem.width() + 20,
39
+ panel_width = $wp_pointer.width(),
40
+ arrow_offset;
41
+
42
+ if ( ta_guided_tour_params.screen.align == 'left' && ta_guided_tour_params.screen.edge == 'top' )
43
+ arrow_offset = ( tab_width / 2 ) - 13;
44
+ else if ( ta_guided_tour_params.screen.align == 'right' && ta_guided_tour_params.screen.edge == 'top' )
45
+ arrow_offset = panel_width - ( tab_width / 2 ) - 13;
46
+
47
+ if ( arrow_offset )
48
+ $wp_pointer.find( '.wp-pointer-arrow' ).css( 'left' , arrow_offset );
49
+
50
+ } else if ( ta_guided_tour_params.screenid === 'post' )
51
+ $wp_pointer.css( 'display' , 'none' );
52
+ };
53
+
54
+ Tour.prototype.createButtons = function( t ) {
55
+
56
+ this.$buttons = $( '<div></div>', {
57
+ 'class': 'ta-tour-buttons'
58
+ });
59
+
60
+ if ( ta_guided_tour_params.screen.btn_tour_done )
61
+ this.createTourCompleteButton( t );
62
+
63
+ this.createCloseButton( t );
64
+ this.createPrevButton( t );
65
+ this.createNextButton( t );
66
+
67
+ return this.$buttons;
68
+
69
+ };
70
+
71
+ Tour.prototype.createCloseButton = function( t ) {
72
+
73
+ var $btnClose = $( '<button></button>', {
74
+ 'class': 'button button-large',
75
+ 'type': 'button'
76
+ }).html( ta_guided_tour_params.texts.btn_close_tour );
77
+
78
+ $btnClose.click(function() {
79
+
80
+ var data = {
81
+ action : ta_guided_tour_params.actions.close_tour,
82
+ nonce : ta_guided_tour_params.nonces.close_tour,
83
+ };
84
+
85
+ $.post( ta_guided_tour_params.urls.ajax, data, function( response ) {
86
+
87
+ if ( response.status == 'success' )
88
+ t.element.pointer( 'close' );
89
+
90
+ } , 'json' );
91
+
92
+ });
93
+
94
+ this.$buttons.append($btnClose);
95
+
96
+ };
97
+
98
+ Tour.prototype.createPrevButton = function( t ) {
99
+
100
+ if ( !ta_guided_tour_params.screen.prev )
101
+ return;
102
+
103
+ var $btnPrev = $( '<button></button>' , {
104
+ 'class': 'button button-large',
105
+ 'type': 'button'
106
+ } ).html( ta_guided_tour_params.texts.btn_prev_tour );
107
+
108
+ $btnPrev.click( function(){
109
+ window.location.href = ta_guided_tour_params.screen.prev;
110
+ });
111
+
112
+ this.$buttons.append($btnPrev);
113
+
114
+ };
115
+
116
+ Tour.prototype.createNextButton = function( t ) {
117
+
118
+ if ( !ta_guided_tour_params.screen.next )
119
+ return;
120
+
121
+ // Check if this is the first screen of the tour.
122
+ var text = ( !ta_guided_tour_params.screen.prev ) ? ta_guided_tour_params.texts.btn_start_tour : ta_guided_tour_params.texts.btn_next_tour;
123
+
124
+ // Check if this is the last screen of the tour.
125
+ text = ( ta_guided_tour_params.screen.btn_tour_done ) ? ta_guided_tour_params.screen.btn_tour_done : text;
126
+
127
+ var $btnStart = $( '<button></button>', {
128
+ 'class' : 'button button-large button-primary',
129
+ 'type' : 'button'
130
+ }).html( text );
131
+
132
+ $btnStart.click( function() {
133
+ window.location.href = ta_guided_tour_params.screen.next;
134
+ } );
135
+
136
+ this.$buttons.append( $btnStart );
137
+
138
+ };
139
+
140
+ Tour.prototype.createTourCompleteButton = function( t ) {
141
+
142
+ var $btnTourComplete = $( '<button></button>', {
143
+ 'class': 'button button-large button-primary',
144
+ 'type': 'button'
145
+ }).html( ta_guided_tour_params.screen.btn_tour_done );
146
+
147
+ $btnTourComplete.click(function() {
148
+
149
+ var data = {
150
+ action : ta_guided_tour_params.actions.close_tour,
151
+ nonce : ta_guided_tour_params.nonces.close_tour,
152
+ };
153
+
154
+ // open link to TA Pro on new tab
155
+ window.open( ta_guided_tour_params.screen.btn_tour_done_url );
156
+
157
+ $.post( ta_guided_tour_params.urls.ajax, data, function( response ) {
158
+
159
+ if ( response.status == 'success' )
160
+ t.element.pointer( 'close' );
161
+
162
+ } , 'json' );
163
+
164
+ });
165
+
166
+ this.$buttons.append( $btnTourComplete );
167
+
168
+ };
169
+
170
+ TA.Admin.Tour = Tour;
171
+
172
+ // DOM ready
173
+ $( function() {
174
+ new TA.Admin.Tour();
175
+ });
176
+
177
+ if ( ta_guided_tour_params.screenid === 'post' ) {
178
+
179
+ $( 'body' ).on( 'ta_reinit_tour_pointer' , function() {
180
+
181
+ Tour.prototype.initPointer();
182
+
183
+ setTimeout(function(){
184
+
185
+ var $ta_button = ThirstyLinkPicker.editorinit ? $( '.ta-add-link-button' ) : $( '#qt_content_thirstyaffiliates_aff_link' ),
186
+ offset_top = $ta_button.offset().top + 28,
187
+ offset_left = ThirstyLinkPicker.editorinit ? $ta_button.offset().left - 48 : $ta_button.offset().left - 23;
188
+
189
+ $( '.wp-pointer' ).css( {
190
+ top : offset_top,
191
+ left : offset_left,
192
+ display : 'block'
193
+ } );
194
+
195
+ }, 500 );
196
+ } );
197
+
198
+ $( '.wp-editor-tabs' ).on( 'click' , 'button' , function() {
199
+
200
+ ThirstyLinkPicker.editorinit = $(this).hasClass( 'switch-tmce' ) ? true : false;
201
+ setTimeout(function(){ $( 'body' ).trigger( 'ta_reinit_tour_pointer' ); } , 500 );
202
+ } );
203
+
204
+ setTimeout( function() {
205
+ if ( $( '#wp-content-wrap' ).hasClass( 'html-active' ) )
206
+ $( '.wp-editor-tabs .switch-html' ).trigger( 'click' );
207
+ } , 500 );
208
+ }
209
+
210
+ }(jQuery));
js/app/ta-reports.js ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var thirstyReports;
2
+
3
+ jQuery( document ).ready( function($){
4
+
5
+ // Functions
6
+ thirstyReports = {
7
+
8
+ /**
9
+ * Main chart series variable
10
+ *
11
+ * @since 3.0.0
12
+ */
13
+ series : [],
14
+
15
+ /**
16
+ * First chart series variable (General all links)
17
+ *
18
+ * @since 3.0.0
19
+ */
20
+ firstSeries : {
21
+ label : report_details.label,
22
+ data : report_data.click_counts,
23
+ yaxis : 1,
24
+ color : '#3498db',
25
+ points : { show: true , radius: 6 , lineWidth: 4 , fillColor: '#fff' , fill: true },
26
+ lines : { show: true , lineWidth: 5, fill: false },
27
+ shadowSize : 0,
28
+ prepend_tooltip : "&#36;"
29
+ },
30
+
31
+ /**
32
+ * Initialize date picker function
33
+ *
34
+ * @since 3.0.0
35
+ */
36
+ rangeDatepicker : function() {
37
+
38
+ var from = $custom_date_form.find( '.range_datepicker.from' ),
39
+ to = $custom_date_form.find( '.range_datepicker.to' );
40
+
41
+ from.datepicker({
42
+ maxDate : 0,
43
+ dateFormat : 'yy-mm-dd'
44
+ }).on( "change" , function() {
45
+ to.datepicker( "option" , "minDate" , thirstyReports.getDate( this ) );
46
+ } );
47
+
48
+ to.datepicker({
49
+ maxDate : 0,
50
+ dateFormat : 'yy-mm-dd'
51
+ }).on( "change" , function() {
52
+ from.datepicker( "option", "maxDate", thirstyReports.getDate( this ) );
53
+ } );
54
+ },
55
+
56
+ /**
57
+ * Get the date value of the datepicker element.
58
+ *
59
+ * @since 3.0.0
60
+ */
61
+ getDate : function( element ) {
62
+
63
+ var date;
64
+
65
+ try {
66
+ date = $.datepicker.parseDate( date_format, element.value );
67
+ } catch( error ) {
68
+ date = null;
69
+ }
70
+
71
+ return date;
72
+ },
73
+
74
+ /**
75
+ * Initialize / display the report graph.
76
+ *
77
+ * @since 3.0.0
78
+ */
79
+ drawGraph : function() {
80
+
81
+ if ( thirstyReports.series.length < 1 )
82
+ thirstyReports.series.push( thirstyReports.firstSeries );
83
+
84
+ main_chart = $.plot(
85
+ $chart_placeholder,
86
+ thirstyReports.series,
87
+ {
88
+ legend : {
89
+ show : false,
90
+ },
91
+ grid : {
92
+ color : '#aaa',
93
+ borderColor : 'transparent',
94
+ borderWidth : 0,
95
+ hoverable : true,
96
+ markings: [ { xaxis: { from: 1.25, to: 1.25 }, color: "black" } ]
97
+ },
98
+ xaxis: {
99
+ show : true,
100
+ color : '#aaa',
101
+ position : 'bottom',
102
+ tickColor : 'transparent',
103
+ mode : "time",
104
+ timeformat : report_details.timeformat,
105
+ monthNames : [ "Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ],
106
+ tickLength : 1,
107
+ minTickSize : report_details.minTickSize,
108
+ font : { color: '#000' }
109
+ },
110
+ yaxis: {
111
+ show : true,
112
+ min : 0,
113
+ minTickSize : 1,
114
+ tickDecimals : 0,
115
+ color : '#d4d9dc',
116
+ font : { color: '#000' }
117
+ }
118
+ }
119
+ );
120
+
121
+ $chart_placeholder.resize();
122
+ },
123
+
124
+ /**
125
+ * Event function to display tooltip when datapoint is hovered.
126
+ *
127
+ * @since 3.0.0
128
+ */
129
+ plotTooltip : function() {
130
+
131
+ var prev_data_point = null;
132
+
133
+ $chart_placeholder.bind( 'plothover', function ( event, pos, item ) {
134
+
135
+ if ( item ) {
136
+
137
+ if ( prev_data_point !== item.datapoint ) {
138
+
139
+ prev_data_point = item.datapoint;
140
+ $( '.chart-tooltip' ).remove();
141
+
142
+ var tooltip = report_details.clicksLabel + item.datapoint[1];
143
+
144
+ thirstyReports.showTooltip( item.pageX , item.pageY , tooltip );
145
+
146
+ }
147
+
148
+ } else {
149
+ prev_data_point = null;
150
+ $( '.chart-tooltip' ).remove();
151
+ }
152
+ } );
153
+ },
154
+
155
+ /**
156
+ * Append tooltip content.
157
+ *
158
+ * @since 3.0.0
159
+ */
160
+ showTooltip : function( x , y , contents ) {
161
+
162
+ var xoffset = ( ( x + 100 ) > $( window ).width() ) ? x - 20 : x + 20,
163
+ yoffset = ( ( x + 100 ) > $( window ).width() ) ? y - 35 : y - 16;
164
+
165
+ $( '<div class="chart-tooltip">' + contents + '</div>' ).css( {
166
+ top: yoffset,
167
+ left: xoffset
168
+ }).appendTo( 'body' ).fadeIn( 200 );
169
+ },
170
+
171
+ /**
172
+ * Search affiliate link to display in the report
173
+ *
174
+ * @since 3.0.0
175
+ */
176
+ searchAffiliateLink : function() {
177
+
178
+ // ajax search affiliate links on keyup event.
179
+ $chart_sidebar.on( 'keyup' , '#add-report-data' , function() {
180
+
181
+ var $input = $(this);
182
+
183
+ // clear results list
184
+ $results_list.html('').hide();
185
+ $input.data( 'linkid' , '' ).attr( 'data-linkid' , '' );
186
+
187
+ if ( $input.val().length < 3 )
188
+ return;
189
+
190
+ if ( last_searched === $input.val() ) {
191
+
192
+ $results_list.html( search_cache ).show();
193
+ return;
194
+ }
195
+
196
+ last_searched = $input.val();
197
+
198
+ $.post( window.ajaxurl, {
199
+ action : 'search_affiliate_links_query',
200
+ keyword : $input.val()
201
+ }, function( response ) {
202
+
203
+ if ( response.status == 'success' ) {
204
+
205
+ search_cache = response.search_query_markup;
206
+ $results_list.html( response.search_query_markup ).show();
207
+
208
+ } else {
209
+ // TODO: Handle error here
210
+ }
211
+
212
+ } , 'json' );
213
+
214
+ } );
215
+
216
+ // apply link data to search input on click of single search result
217
+ $results_list.on( 'click' , 'li' , function() {
218
+
219
+ event.preventDefault();
220
+
221
+ var $link = $(this),
222
+ $input = $link.closest( '.input-wrap' ).find( 'input' );
223
+
224
+ $input.val( $link.text() )
225
+ .attr( 'data-linkid' , $link.data( 'link-id' ) )
226
+ .data( 'linkid' , $link.data( 'link-id' ) );
227
+
228
+ $results_list.hide();
229
+ } );
230
+ },
231
+
232
+ /**
233
+ * Fetch link report data and redraw the graph
234
+ *
235
+ * @since 3.0.0
236
+ */
237
+ fetchLinkReport : function() {
238
+
239
+ $chart_sidebar.on( 'click' , 'button#fetch-link-report' , function() {
240
+
241
+ var $input = $(this).closest( '.add-legend' ).find( '#add-report-data' ),
242
+ series;
243
+
244
+ if ( ! $input.data( 'linkid' ) ) {
245
+
246
+ // TODO: change to vex dialog
247
+ alert( 'Invalid affiliate link selected.' );
248
+ return;
249
+ }
250
+
251
+ // show overlay
252
+ $report_block.find( '.overlay' ).css( 'height' , $report_block.height() ).show();
253
+
254
+ $.post( window.ajaxurl, {
255
+ action : 'ta_fetch_report_by_linkid',
256
+ link_id : $input.data( 'linkid' ),
257
+ range : $input.data( 'range' ),
258
+ start_date : $input.data( 'start-date' ),
259
+ end_date : $input.data( 'end-date' )
260
+ }, function( response ) {
261
+
262
+ if ( response.status == 'success' ) {
263
+
264
+ series = {
265
+ label : response.label,
266
+ data : response.report_data,
267
+ yaxis : 1,
268
+ color : '#e74c3c',
269
+ points : { show: true , radius: 6 , lineWidth: 4 , fillColor: '#fff' , fill: true },
270
+ lines : { show: true , lineWidth: 5, fill: false },
271
+ shadowSize : 0,
272
+ prepend_tooltip : "&#36;"
273
+ };
274
+
275
+ // add new legend
276
+ $chart_sidebar.find( 'ul li.single-link' ).remove();
277
+ $chart_sidebar.find( 'ul.chart-legend' )
278
+ .append( '<li class="single-link" style="border-color:#e74c3c;">' + response.label + '<span>' + response.slug + '</span></li>' );
279
+
280
+ // redraw the graph
281
+ thirstyReports.series = [];
282
+ thirstyReports.series.push( thirstyReports.firstSeries );
283
+ thirstyReports.series.push( series );
284
+ thirstyReports.drawGraph();
285
+
286
+ // clear form
287
+ $chart_sidebar.find( 'input#add-report-data' ).val( '' ).data( 'link_id' , '' );
288
+
289
+ // hide overlay
290
+ $report_block.find( '.overlay' ).hide();
291
+
292
+ } else {
293
+
294
+ // TODO: change to vex dialog
295
+ alert( response.error_msg );
296
+ }
297
+
298
+ } , 'json' );
299
+ } );
300
+
301
+ if ( $chart_sidebar.find( '#add-report-data' ).data( 'linkid' ) )
302
+ $chart_sidebar.find( 'button#fetch-link-report' ).trigger( 'click' );
303
+ }
304
+
305
+ };
306
+
307
+ var $custom_date_form = $( 'form#custom-date-range' ),
308
+ $report_block = $( '.link-performance-report' ),
309
+ $chart_placeholder = $( '.report-chart-placeholder' ),
310
+ $chart_sidebar = $( '.chart-sidebar' ),
311
+ $results_list = $( '.report-chart-wrap .add-legend .link-search-result' ),
312
+ date_format = 'yy-mm-dd',
313
+ last_searched, search_cache;
314
+
315
+ // init range date picker
316
+ thirstyReports.rangeDatepicker();
317
+
318
+ // init jQuery flot graph
319
+ thirstyReports.drawGraph();
320
+
321
+ // init plot tooltip events
322
+ thirstyReports.plotTooltip();
323
+
324
+ // init search affiliate link event
325
+ thirstyReports.searchAffiliateLink();
326
+
327
+ // init fetch link report event
328
+ thirstyReports.fetchLinkReport();
329
+ } );
js/app/ta-review-request.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function($) {
2
+
3
+ var review_request_functions = {
4
+
5
+ ajax_init : function() {
6
+
7
+ $review_request_notice.on( 'click' , '.button' , function(e) {
8
+
9
+ e.preventDefault();
10
+
11
+ var $button = $(this),
12
+ response = $button.data( 'response' )
13
+ ajax_args = {
14
+ url : ajaxurl,
15
+ type : "POST",
16
+ data : {
17
+ action : "ta_request_review_response",
18
+ review_request_response : response
19
+ },
20
+ dataType : "json"
21
+ };
22
+
23
+ $.ajax( ajax_args );
24
+
25
+ if ( response === 'review' )
26
+ window.open( $button.prop( 'href' ) );
27
+
28
+ $review_request_notice.fadeOut( 'fast' );
29
+ } );
30
+
31
+ }
32
+
33
+ };
34
+
35
+ var $review_request_notice = $( '.ta-review-request.notice' );
36
+
37
+ review_request_functions.ajax_init();
38
+ });
js/app/ta-settings.js ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready( function($){
2
+
3
+ // Functions
4
+ thirstySettings = {
5
+ customLinkPrefix : function() {
6
+
7
+ $settingsBlock.on( 'change' , '#ta_link_prefix' , function() {
8
+
9
+ var linkPrefix = $(this).val(),
10
+ $customLinkPrefixRow = $settingsBlock.find( '.ta_link_prefix_custom-row' );
11
+
12
+ if ( linkPrefix == 'custom' ) {
13
+
14
+ $customLinkPrefixRow.show();
15
+ $customLinkPrefixRow.find( '#ta_link_prefix_custom' ).prop( 'disabled' , false );
16
+
17
+ } else {
18
+
19
+ $customLinkPrefixRow.hide();
20
+ $customLinkPrefixRow.find( '#ta_link_prefix_custom' ).prop( 'disabled' , true );
21
+
22
+ }
23
+
24
+ } );
25
+
26
+ $settingsBlock.find( '#ta_link_prefix' ).trigger( 'change' );
27
+
28
+ },
29
+ validLinkPrefix : function() {
30
+
31
+ if ( $settingsBlock.find( '#ta_link_prefix' ).length > 0 ) {
32
+
33
+ $settingsBlock.on( 'click' , '#submit' , function() {
34
+
35
+ var linkPrefix = $settingsBlock.find( '#ta_link_prefix' ).val(),
36
+ $customLinkPrefixRow = $settingsBlock.find( '.ta_link_prefix_custom-row' );
37
+
38
+ if ( linkPrefix == 'custom' && $.trim( $customLinkPrefixRow.find( '#ta_link_prefix_custom' ).val() ) === '' ) {
39
+
40
+ alert( ta_settings_var.i18n_custom_link_prefix_valid_val );
41
+
42
+ $( 'html, body' ).animate( {
43
+ scrollTop : $customLinkPrefixRow.find( '#ta_link_prefix_custom' ).offset().top - 50
44
+ } , 500 );
45
+
46
+ $customLinkPrefixRow.find( '#ta_link_prefix_custom' ).focus();
47
+
48
+ return false;
49
+
50
+ }
51
+
52
+ } );
53
+
54
+ }
55
+
56
+ }
57
+ };
58
+
59
+ var $settingsBlock = $( '.ta-settings.wrap' );
60
+
61
+ // initialize custom link prefix settings display
62
+ thirstySettings.customLinkPrefix();
63
+ thirstySettings.validLinkPrefix();
64
+
65
+ });
js/app/ta.js ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var thirstyFunctions;
2
+
3
+ jQuery( document ).ready( function($) {
4
+
5
+ thirstyFunctions = {
6
+
7
+ /**
8
+ * Record link clicks AJAX event trigger.
9
+ *
10
+ * @since 3.0.0
11
+ */
12
+ recordLinkStat : function() {
13
+
14
+ $( 'body' ).delegate( 'a' , 'click' , function(e) {
15
+
16
+ var $link = $(this),
17
+ href = $link.attr( 'href' ),
18
+ linkID = $(this).data( 'linkid' ),
19
+ href = thirstyFunctions.isThirstyLink( href );
20
+
21
+ if ( href || linkID ) {
22
+
23
+ $.post( thirsty_global_vars.ajax_url , {
24
+ action : 'ta_click_data_redirect',
25
+ href : href,
26
+ page : window.location.href,
27
+ link_id : linkID
28
+ } );
29
+ }
30
+
31
+ });
32
+ },
33
+
34
+ /**
35
+ * Function to check if the loaded link is a ThirstyAffiliates link or not.
36
+ *
37
+ * @since 3.0.0
38
+ */
39
+ isThirstyLink : function( href ) {
40
+
41
+ if ( ! href )
42
+ return;
43
+
44
+ var link_uri = href.replace( thirsty_global_vars.home_url , '' ),
45
+ link_prefix = link_uri.substr( 0 , link_uri.indexOf( '/' ) ),
46
+ new_href = href.replace( '/' + link_prefix + '/' , '/' + thirsty_global_vars.link_prefix + '/' );
47
+
48
+ return ( link_prefix && $.inArray( link_prefix , link_prefixes ) > -1 ) ? new_href : false;
49
+ },
50
+
51
+ /**
52
+ * Function to check if the loaded link is a ThirstyAffiliates link or not.
53
+ *
54
+ * @since 3.0.0
55
+ */
56
+ linkFixer : function() {
57
+
58
+ if ( thirsty_global_vars.link_fixer_enabled !== 'yes' )
59
+ return;
60
+
61
+ var $allLinks = $( 'body a' ),
62
+ hrefs = [],
63
+ href, linkClass, isShortcode, isImage, content;
64
+
65
+ // fetch all links that are thirstylinks
66
+ for ( key = 0; key < $allLinks.length; key++ ) {
67
+
68
+ href = $( $allLinks[ key ] ).attr( 'href' );
69
+ linkClass = $( $allLinks[ key ] ).attr( 'class' );
70
+ isShortcode = $( $allLinks[ key ] ).data( 'shortcode' );
71
+ isImage = $( $allLinks[ key ] ).has( 'img' ).length;
72
+ content = $( $allLinks[ key ] ).text();
73
+ href = thirstyFunctions.isThirstyLink( href );
74
+
75
+ if ( href && ! isShortcode )
76
+ hrefs.push({ key : key , class : linkClass , href : href , content : content , is_image : isImage });
77
+
78
+ $( $allLinks[ key ] ).removeAttr( 'data-shortcode' );
79
+ }
80
+
81
+ // skip if there are no affiliate links
82
+ if ( hrefs.length < 1 )
83
+ return;
84
+
85
+ $.post( thirsty_global_vars.ajax_url , {
86
+ action : 'ta_link_fixer',
87
+ hrefs : hrefs,
88
+ post_id : thirsty_global_vars.post_id
89
+ }, function( response ) {
90
+
91
+ if ( response.status == 'success' ) {
92
+
93
+ for ( x in response.data ) {
94
+
95
+ key = response.data[ x ][ 'key' ];
96
+ html = response.data[ x ][ 'html' ];
97
+
98
+ if ( parseInt( response.data[ x ][ 'is_image' ] ) )
99
+ html = html.replace( '{image_placeholder}' , $( $allLinks[ key ] ).html() );
100
+
101
+ $( $allLinks[ key ] ).replaceWith( html );
102
+ }
103
+ }
104
+ }, 'json' );
105
+ }
106
+ }
107
+
108
+ var link_prefixes = $.map( thirsty_global_vars.link_prefixes , function(value , index) {
109
+ return [value];
110
+ });
111
+
112
+ // Initiate record link click stat function
113
+ thirstyFunctions.recordLinkStat();
114
+
115
+ // Initialize uncloak links function
116
+ thirstyFunctions.linkFixer();
117
+ });
js/index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php /* Silence is Golden */ ?>
js/lib/chosen/chosen.jquery.js ADDED
@@ -0,0 +1,1321 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Chosen, a Select Box Enhancer for jQuery and Prototype
3
+ by Patrick Filler for Harvest, http://getharvest.com
4
+
5
+ Version 1.7.0
6
+ Full source at https://github.com/harvesthq/chosen
7
+ Copyright (c) 2011-2017 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
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
16
+ __hasProp = {}.hasOwnProperty,
17
+ __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; };
18
+
19
+ SelectParser = (function() {
20
+ function SelectParser() {
21
+ this.options_index = 0;
22
+ this.parsed = [];
23
+ }
24
+
25
+ SelectParser.prototype.add_node = function(child) {
26
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
27
+ return this.add_group(child);
28
+ } else {
29
+ return this.add_option(child);
30
+ }
31
+ };
32
+
33
+ SelectParser.prototype.add_group = function(group) {
34
+ var group_position, option, _i, _len, _ref, _results;
35
+ group_position = this.parsed.length;
36
+ this.parsed.push({
37
+ array_index: group_position,
38
+ group: true,
39
+ label: this.escapeExpression(group.label),
40
+ title: group.title ? group.title : void 0,
41
+ children: 0,
42
+ disabled: group.disabled,
43
+ classes: group.className
44
+ });
45
+ _ref = group.childNodes;
46
+ _results = [];
47
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
48
+ option = _ref[_i];
49
+ _results.push(this.add_option(option, group_position, group.disabled));
50
+ }
51
+ return _results;
52
+ };
53
+
54
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
55
+ if (option.nodeName.toUpperCase() === "OPTION") {
56
+ if (option.text !== "") {
57
+ if (group_position != null) {
58
+ this.parsed[group_position].children += 1;
59
+ }
60
+ this.parsed.push({
61
+ array_index: this.parsed.length,
62
+ options_index: this.options_index,
63
+ value: option.value,
64
+ text: option.text,
65
+ html: option.innerHTML,
66
+ title: option.title ? option.title : void 0,
67
+ selected: option.selected,
68
+ disabled: group_disabled === true ? group_disabled : option.disabled,
69
+ group_array_index: group_position,
70
+ group_label: group_position != null ? this.parsed[group_position].label : null,
71
+ classes: option.className,
72
+ style: option.style.cssText
73
+ });
74
+ } else {
75
+ this.parsed.push({
76
+ array_index: this.parsed.length,
77
+ options_index: this.options_index,
78
+ empty: true
79
+ });
80
+ }
81
+ return this.options_index += 1;
82
+ }
83
+ };
84
+
85
+ SelectParser.prototype.escapeExpression = function(text) {
86
+ var map, unsafe_chars;
87
+ if ((text == null) || text === false) {
88
+ return "";
89
+ }
90
+ if (!/[\&\<\>\"\'\`]/.test(text)) {
91
+ return text;
92
+ }
93
+ map = {
94
+ "<": "&lt;",
95
+ ">": "&gt;",
96
+ '"': "&quot;",
97
+ "'": "&#x27;",
98
+ "`": "&#x60;"
99
+ };
100
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
101
+ return text.replace(unsafe_chars, function(chr) {
102
+ return map[chr] || "&amp;";
103
+ });
104
+ };
105
+
106
+ return SelectParser;
107
+
108
+ })();
109
+
110
+ SelectParser.select_to_array = function(select) {
111
+ var child, parser, _i, _len, _ref;
112
+ parser = new SelectParser();
113
+ _ref = select.childNodes;
114
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
115
+ child = _ref[_i];
116
+ parser.add_node(child);
117
+ }
118
+ return parser.parsed;
119
+ };
120
+
121
+ AbstractChosen = (function() {
122
+ function AbstractChosen(form_field, options) {
123
+ this.form_field = form_field;
124
+ this.options = options != null ? options : {};
125
+ this.label_click_handler = __bind(this.label_click_handler, this);
126
+ if (!AbstractChosen.browser_is_supported()) {
127
+ return;
128
+ }
129
+ this.is_multiple = this.form_field.multiple;
130
+ this.set_default_text();
131
+ this.set_default_values();
132
+ this.setup();
133
+ this.set_up_html();
134
+ this.register_observers();
135
+ this.on_ready();
136
+ }
137
+
138
+ AbstractChosen.prototype.set_default_values = function() {
139
+ var _this = this;
140
+ this.click_test_action = function(evt) {
141
+ return _this.test_active_click(evt);
142
+ };
143
+ this.activate_action = function(evt) {
144
+ return _this.activate_field(evt);
145
+ };
146
+ this.active_field = false;
147
+ this.mouse_on_container = false;
148
+ this.results_showing = false;
149
+ this.result_highlighted = null;
150
+ this.is_rtl = this.options.rtl || /\bchosen-rtl\b/.test(this.form_field.className);
151
+ 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;
152
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
153
+ this.disable_search = this.options.disable_search || false;
154
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
155
+ this.group_search = this.options.group_search != null ? this.options.group_search : true;
156
+ this.search_contains = this.options.search_contains || false;
157
+ this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
158
+ this.max_selected_options = this.options.max_selected_options || Infinity;
159
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
160
+ this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
161
+ this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
162
+ this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
163
+ this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
164
+ this.case_sensitive_search = this.options.case_sensitive_search || false;
165
+ return this.hide_results_on_select = this.options.hide_results_on_select != null ? this.options.hide_results_on_select : true;
166
+ };
167
+
168
+ AbstractChosen.prototype.set_default_text = function() {
169
+ if (this.form_field.getAttribute("data-placeholder")) {
170
+ this.default_text = this.form_field.getAttribute("data-placeholder");
171
+ } else if (this.is_multiple) {
172
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
173
+ } else {
174
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
175
+ }
176
+ this.default_text = this.escape_html(this.default_text);
177
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
178
+ };
179
+
180
+ AbstractChosen.prototype.choice_label = function(item) {
181
+ if (this.include_group_label_in_selected && (item.group_label != null)) {
182
+ return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
183
+ } else {
184
+ return item.html;
185
+ }
186
+ };
187
+
188
+ AbstractChosen.prototype.mouse_enter = function() {
189
+ return this.mouse_on_container = true;
190
+ };
191
+
192
+ AbstractChosen.prototype.mouse_leave = function() {
193
+ return this.mouse_on_container = false;
194
+ };
195
+
196
+ AbstractChosen.prototype.input_focus = function(evt) {
197
+ var _this = this;
198
+ if (this.is_multiple) {
199
+ if (!this.active_field) {
200
+ return setTimeout((function() {
201
+ return _this.container_mousedown();
202
+ }), 50);
203
+ }
204
+ } else {
205
+ if (!this.active_field) {
206
+ return this.activate_field();
207
+ }
208
+ }
209
+ };
210
+
211
+ AbstractChosen.prototype.input_blur = function(evt) {
212
+ var _this = this;
213
+ if (!this.mouse_on_container) {
214
+ this.active_field = false;
215
+ return setTimeout((function() {
216
+ return _this.blur_test();
217
+ }), 100);
218
+ }
219
+ };
220
+
221
+ AbstractChosen.prototype.label_click_handler = function(evt) {
222
+ if (this.is_multiple) {
223
+ return this.container_mousedown(evt);
224
+ } else {
225
+ return this.activate_field();
226
+ }
227
+ };
228
+
229
+ AbstractChosen.prototype.results_option_build = function(options) {
230
+ var content, data, data_content, shown_results, _i, _len, _ref;
231
+ content = '';
232
+ shown_results = 0;
233
+ _ref = this.results_data;
234
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
235
+ data = _ref[_i];
236
+ data_content = '';
237
+ if (data.group) {
238
+ data_content = this.result_add_group(data);
239
+ } else {
240
+ data_content = this.result_add_option(data);
241
+ }
242
+ if (data_content !== '') {
243
+ shown_results++;
244
+ content += data_content;
245
+ }
246
+ if (options != null ? options.first : void 0) {
247
+ if (data.selected && this.is_multiple) {
248
+ this.choice_build(data);
249
+ } else if (data.selected && !this.is_multiple) {
250
+ this.single_set_selected_text(this.choice_label(data));
251
+ }
252
+ }
253
+ if (shown_results >= this.max_shown_results) {
254
+ break;
255
+ }
256
+ }
257
+ return content;
258
+ };
259
+
260
+ AbstractChosen.prototype.result_add_option = function(option) {
261
+ var classes, option_el;
262
+ if (!option.search_match) {
263
+ return '';
264
+ }
265
+ if (!this.include_option_in_results(option)) {
266
+ return '';
267
+ }
268
+ classes = [];
269
+ if (!option.disabled && !(option.selected && this.is_multiple)) {
270
+ classes.push("active-result");
271
+ }
272
+ if (option.disabled && !(option.selected && this.is_multiple)) {
273
+ classes.push("disabled-result");
274
+ }
275
+ if (option.selected) {
276
+ classes.push("result-selected");
277
+ }
278
+ if (option.group_array_index != null) {
279
+ classes.push("group-option");
280
+ }
281
+ if (option.classes !== "") {
282
+ classes.push(option.classes);
283
+ }
284
+ option_el = document.createElement("li");
285
+ option_el.className = classes.join(" ");
286
+ option_el.style.cssText = option.style;
287
+ option_el.setAttribute("data-option-array-index", option.array_index);
288
+ option_el.innerHTML = option.search_text;
289
+ if (option.title) {
290
+ option_el.title = option.title;
291
+ }
292
+ return this.outerHTML(option_el);
293
+ };
294
+
295
+ AbstractChosen.prototype.result_add_group = function(group) {
296
+ var classes, group_el;
297
+ if (!(group.search_match || group.group_match)) {
298
+ return '';
299
+ }
300
+ if (!(group.active_options > 0)) {
301
+ return '';
302
+ }
303
+ classes = [];
304
+ classes.push("group-result");
305
+ if (group.classes) {
306
+ classes.push(group.classes);
307
+ }
308
+ group_el = document.createElement("li");
309
+ group_el.className = classes.join(" ");
310
+ group_el.innerHTML = group.search_text;
311
+ if (group.title) {
312
+ group_el.title = group.title;
313
+ }
314
+ return this.outerHTML(group_el);
315
+ };
316
+
317
+ AbstractChosen.prototype.results_update_field = function() {
318
+ this.set_default_text();
319
+ if (!this.is_multiple) {
320
+ this.results_reset_cleanup();
321
+ }
322
+ this.result_clear_highlight();
323
+ this.results_build();
324
+ if (this.results_showing) {
325
+ return this.winnow_results();
326
+ }
327
+ };
328
+
329
+ AbstractChosen.prototype.reset_single_select_options = function() {
330
+ var result, _i, _len, _ref, _results;
331
+ _ref = this.results_data;
332
+ _results = [];
333
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
334
+ result = _ref[_i];
335
+ if (result.selected) {
336
+ _results.push(result.selected = false);
337
+ } else {
338
+ _results.push(void 0);
339
+ }
340
+ }
341
+ return _results;
342
+ };
343
+
344
+ AbstractChosen.prototype.results_toggle = function() {
345
+ if (this.results_showing) {
346
+ return this.results_hide();
347
+ } else {
348
+ return this.results_show();
349
+ }
350
+ };
351
+
352
+ AbstractChosen.prototype.results_search = function(evt) {
353
+ if (this.results_showing) {
354
+ return this.winnow_results();
355
+ } else {
356
+ return this.results_show();
357
+ }
358
+ };
359
+
360
+ AbstractChosen.prototype.winnow_results = function() {
361
+ var escapedSearchText, highlightRegex, option, regex, results, results_group, searchText, startpos, text, _i, _len, _ref;
362
+ this.no_results_clear();
363
+ results = 0;
364
+ searchText = this.get_search_text();
365
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
366
+ regex = this.get_search_regex(escapedSearchText);
367
+ highlightRegex = this.get_highlight_regex(escapedSearchText);
368
+ _ref = this.results_data;
369
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
370
+ option = _ref[_i];
371
+ option.search_match = false;
372
+ results_group = null;
373
+ if (this.include_option_in_results(option)) {
374
+ if (option.group) {
375
+ option.group_match = false;
376
+ option.active_options = 0;
377
+ }
378
+ if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
379
+ results_group = this.results_data[option.group_array_index];
380
+ if (results_group.active_options === 0 && results_group.search_match) {
381
+ results += 1;
382
+ }
383
+ results_group.active_options += 1;
384
+ }
385
+ option.search_text = option.group ? option.label : option.html;
386
+ if (!(option.group && !this.group_search)) {
387
+ option.search_match = this.search_string_match(option.search_text, regex);
388
+ if (option.search_match && !option.group) {
389
+ results += 1;
390
+ }
391
+ if (option.search_match) {
392
+ if (searchText.length) {
393
+ startpos = option.search_text.search(highlightRegex);
394
+ text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
395
+ option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
396
+ }
397
+ if (results_group != null) {
398
+ results_group.group_match = true;
399
+ }
400
+ } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
401
+ option.search_match = true;
402
+ }
403
+ }
404
+ }
405
+ }
406
+ this.result_clear_highlight();
407
+ if (results < 1 && searchText.length) {
408
+ this.update_results_content("");
409
+ return this.no_results(searchText);
410
+ } else {
411
+ this.update_results_content(this.results_option_build());
412
+ return this.winnow_results_set_highlight();
413
+ }
414
+ };
415
+
416
+ AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
417
+ var regex_anchor, regex_flag;
418
+ regex_anchor = this.search_contains ? "" : "^";
419
+ regex_flag = this.case_sensitive_search ? "" : "i";
420
+ return new RegExp(regex_anchor + escaped_search_string, regex_flag);
421
+ };
422
+
423
+ AbstractChosen.prototype.get_highlight_regex = function(escaped_search_string) {
424
+ var regex_anchor, regex_flag;
425
+ regex_anchor = this.search_contains ? "" : "\\b";
426
+ regex_flag = this.case_sensitive_search ? "" : "i";
427
+ return new RegExp(regex_anchor + escaped_search_string, regex_flag);
428
+ };
429
+
430
+ AbstractChosen.prototype.search_string_match = function(search_string, regex) {
431
+ var part, parts, _i, _len;
432
+ if (regex.test(search_string)) {
433
+ return true;
434
+ } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
435
+ parts = search_string.replace(/\[|\]/g, "").split(" ");
436
+ if (parts.length) {
437
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
438
+ part = parts[_i];
439
+ if (regex.test(part)) {
440
+ return true;
441
+ }
442
+ }
443
+ }
444
+ }
445
+ };
446
+
447
+ AbstractChosen.prototype.choices_count = function() {
448
+ var option, _i, _len, _ref;
449
+ if (this.selected_option_count != null) {
450
+ return this.selected_option_count;
451
+ }
452
+ this.selected_option_count = 0;
453
+ _ref = this.form_field.options;
454
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
455
+ option = _ref[_i];
456
+ if (option.selected) {
457
+ this.selected_option_count += 1;
458
+ }
459
+ }
460
+ return this.selected_option_count;
461
+ };
462
+
463
+ AbstractChosen.prototype.choices_click = function(evt) {
464
+ evt.preventDefault();
465
+ this.activate_field();
466
+ if (!(this.results_showing || this.is_disabled)) {
467
+ return this.results_show();
468
+ }
469
+ };
470
+
471
+ AbstractChosen.prototype.keydown_checker = function(evt) {
472
+ var stroke, _ref;
473
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
474
+ this.search_field_scale();
475
+ if (stroke !== 8 && this.pending_backstroke) {
476
+ this.clear_backstroke();
477
+ }
478
+ switch (stroke) {
479
+ case 8:
480
+ this.backstroke_length = this.get_search_field_value().length;
481
+ break;
482
+ case 9:
483
+ if (this.results_showing && !this.is_multiple) {
484
+ this.result_select(evt);
485
+ }
486
+ this.mouse_on_container = false;
487
+ break;
488
+ case 13:
489
+ if (this.results_showing) {
490
+ evt.preventDefault();
491
+ }
492
+ break;
493
+ case 27:
494
+ if (this.results_showing) {
495
+ evt.preventDefault();
496
+ }
497
+ break;
498
+ case 32:
499
+ if (this.disable_search) {
500
+ evt.preventDefault();
501
+ }
502
+ break;
503
+ case 38:
504
+ evt.preventDefault();
505
+ this.keyup_arrow();
506
+ break;
507
+ case 40:
508
+ evt.preventDefault();
509
+ this.keydown_arrow();
510
+ break;
511
+ }
512
+ };
513
+
514
+ AbstractChosen.prototype.keyup_checker = function(evt) {
515
+ var stroke, _ref;
516
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
517
+ this.search_field_scale();
518
+ switch (stroke) {
519
+ case 8:
520
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
521
+ this.keydown_backstroke();
522
+ } else if (!this.pending_backstroke) {
523
+ this.result_clear_highlight();
524
+ this.results_search();
525
+ }
526
+ break;
527
+ case 13:
528
+ evt.preventDefault();
529
+ if (this.results_showing) {
530
+ this.result_select(evt);
531
+ }
532
+ break;
533
+ case 27:
534
+ if (this.results_showing) {
535
+ this.results_hide();
536
+ }
537
+ break;
538
+ case 9:
539
+ case 16:
540
+ case 17:
541
+ case 18:
542
+ case 38:
543
+ case 40:
544
+ case 91:
545
+ break;
546
+ default:
547
+ this.results_search();
548
+ break;
549
+ }
550
+ };
551
+
552
+ AbstractChosen.prototype.clipboard_event_checker = function(evt) {
553
+ var _this = this;
554
+ if (this.is_disabled) {
555
+ return;
556
+ }
557
+ return setTimeout((function() {
558
+ return _this.results_search();
559
+ }), 50);
560
+ };
561
+
562
+ AbstractChosen.prototype.container_width = function() {
563
+ if (this.options.width != null) {
564
+ return this.options.width;
565
+ } else {
566
+ return "" + this.form_field.offsetWidth + "px";
567
+ }
568
+ };
569
+
570
+ AbstractChosen.prototype.include_option_in_results = function(option) {
571
+ if (this.is_multiple && (!this.display_selected_options && option.selected)) {
572
+ return false;
573
+ }
574
+ if (!this.display_disabled_options && option.disabled) {
575
+ return false;
576
+ }
577
+ if (option.empty) {
578
+ return false;
579
+ }
580
+ return true;
581
+ };
582
+
583
+ AbstractChosen.prototype.search_results_touchstart = function(evt) {
584
+ this.touch_started = true;
585
+ return this.search_results_mouseover(evt);
586
+ };
587
+
588
+ AbstractChosen.prototype.search_results_touchmove = function(evt) {
589
+ this.touch_started = false;
590
+ return this.search_results_mouseout(evt);
591
+ };
592
+
593
+ AbstractChosen.prototype.search_results_touchend = function(evt) {
594
+ if (this.touch_started) {
595
+ return this.search_results_mouseup(evt);
596
+ }
597
+ };
598
+
599
+ AbstractChosen.prototype.outerHTML = function(element) {
600
+ var tmp;
601
+ if (element.outerHTML) {
602
+ return element.outerHTML;
603
+ }
604
+ tmp = document.createElement("div");
605
+ tmp.appendChild(element);
606
+ return tmp.innerHTML;
607
+ };
608
+
609
+ AbstractChosen.prototype.get_single_html = function() {
610
+ return "<a class=\"chosen-single chosen-default\">\n <span>" + this.default_text + "</span>\n <div><b></b></div>\n</a>\n<div class=\"chosen-drop\">\n <div class=\"chosen-search\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" />\n </div>\n <ul class=\"chosen-results\"></ul>\n</div>";
611
+ };
612
+
613
+ AbstractChosen.prototype.get_multi_html = function() {
614
+ return "<ul class=\"chosen-choices\">\n <li class=\"search-field\">\n <input class=\"chosen-search-input\" type=\"text\" autocomplete=\"off\" value=\"" + this.default_text + "\" />\n </li>\n</ul>\n<div class=\"chosen-drop\">\n <ul class=\"chosen-results\"></ul>\n</div>";
615
+ };
616
+
617
+ AbstractChosen.prototype.get_no_results_html = function(terms) {
618
+ return "<li class=\"no-results\">\n " + this.results_none_found + " <span>" + terms + "</span>\n</li>";
619
+ };
620
+
621
+ AbstractChosen.browser_is_supported = function() {
622
+ if ("Microsoft Internet Explorer" === window.navigator.appName) {
623
+ return document.documentMode >= 8;
624
+ }
625
+ if (/iP(od|hone)/i.test(window.navigator.userAgent) || /IEMobile/i.test(window.navigator.userAgent) || /Windows Phone/i.test(window.navigator.userAgent) || /BlackBerry/i.test(window.navigator.userAgent) || /BB10/i.test(window.navigator.userAgent) || /Android.*Mobile/i.test(window.navigator.userAgent)) {
626
+ return false;
627
+ }
628
+ return true;
629
+ };
630
+
631
+ AbstractChosen.default_multiple_text = "Select Some Options";
632
+
633
+ AbstractChosen.default_single_text = "Select an Option";
634
+
635
+ AbstractChosen.default_no_result_text = "No results match";
636
+
637
+ return AbstractChosen;
638
+
639
+ })();
640
+
641
+ $ = jQuery;
642
+
643
+ $.fn.extend({
644
+ chosen: function(options) {
645
+ if (!AbstractChosen.browser_is_supported()) {
646
+ return this;
647
+ }
648
+ return this.each(function(input_field) {
649
+ var $this, chosen;
650
+ $this = $(this);
651
+ chosen = $this.data('chosen');
652
+ if (options === 'destroy') {
653
+ if (chosen instanceof Chosen) {
654
+ chosen.destroy();
655
+ }
656
+ return;
657
+ }
658
+ if (!(chosen instanceof Chosen)) {
659
+ $this.data('chosen', new Chosen(this, options));
660
+ }
661
+ });
662
+ }
663
+ });
664
+
665
+ Chosen = (function(_super) {
666
+ __extends(Chosen, _super);
667
+
668
+ function Chosen() {
669
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
670
+ return _ref;
671
+ }
672
+
673
+ Chosen.prototype.setup = function() {
674
+ this.form_field_jq = $(this.form_field);
675
+ return this.current_selectedIndex = this.form_field.selectedIndex;
676
+ };
677
+
678
+ Chosen.prototype.set_up_html = function() {
679
+ var container_classes, container_props;
680
+ container_classes = ["chosen-container"];
681
+ container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
682
+ if (this.inherit_select_classes && this.form_field.className) {
683
+ container_classes.push(this.form_field.className);
684
+ }
685
+ if (this.is_rtl) {
686
+ container_classes.push("chosen-rtl");
687
+ }
688
+ container_props = {
689
+ 'class': container_classes.join(' '),
690
+ 'title': this.form_field.title
691
+ };
692
+ if (this.form_field.id.length) {
693
+ container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
694
+ }
695
+ this.container = $("<div />", container_props);
696
+ this.container.width(this.container_width());
697
+ if (this.is_multiple) {
698
+ this.container.html(this.get_multi_html());
699
+ } else {
700
+ this.container.html(this.get_single_html());
701
+ }
702
+ this.form_field_jq.hide().after(this.container);
703
+ this.dropdown = this.container.find('div.chosen-drop').first();
704
+ this.search_field = this.container.find('input').first();
705
+ this.search_results = this.container.find('ul.chosen-results').first();
706
+ this.search_field_scale();
707
+ this.search_no_results = this.container.find('li.no-results').first();
708
+ if (this.is_multiple) {
709
+ this.search_choices = this.container.find('ul.chosen-choices').first();
710
+ this.search_container = this.container.find('li.search-field').first();
711
+ } else {
712
+ this.search_container = this.container.find('div.chosen-search').first();
713
+ this.selected_item = this.container.find('.chosen-single').first();
714
+ }
715
+ this.results_build();
716
+ this.set_tab_index();
717
+ return this.set_label_behavior();
718
+ };
719
+
720
+ Chosen.prototype.on_ready = function() {
721
+ return this.form_field_jq.trigger("chosen:ready", {
722
+ chosen: this
723
+ });
724
+ };
725
+
726
+ Chosen.prototype.register_observers = function() {
727
+ var _this = this;
728
+ this.container.bind('touchstart.chosen', function(evt) {
729
+ _this.container_mousedown(evt);
730
+ });
731
+ this.container.bind('touchend.chosen', function(evt) {
732
+ _this.container_mouseup(evt);
733
+ });
734
+ this.container.bind('mousedown.chosen', function(evt) {
735
+ _this.container_mousedown(evt);
736
+ });
737
+ this.container.bind('mouseup.chosen', function(evt) {
738
+ _this.container_mouseup(evt);
739
+ });
740
+ this.container.bind('mouseenter.chosen', function(evt) {
741
+ _this.mouse_enter(evt);
742
+ });
743
+ this.container.bind('mouseleave.chosen', function(evt) {
744
+ _this.mouse_leave(evt);
745
+ });
746
+ this.search_results.bind('mouseup.chosen', function(evt) {
747
+ _this.search_results_mouseup(evt);
748
+ });
749
+ this.search_results.bind('mouseover.chosen', function(evt) {
750
+ _this.search_results_mouseover(evt);
751
+ });
752
+ this.search_results.bind('mouseout.chosen', function(evt) {
753
+ _this.search_results_mouseout(evt);
754
+ });
755
+ this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
756
+ _this.search_results_mousewheel(evt);
757
+ });
758
+ this.search_results.bind('touchstart.chosen', function(evt) {
759
+ _this.search_results_touchstart(evt);
760
+ });
761
+ this.search_results.bind('touchmove.chosen', function(evt) {
762
+ _this.search_results_touchmove(evt);
763
+ });
764
+ this.search_results.bind('touchend.chosen', function(evt) {
765
+ _this.search_results_touchend(evt);
766
+ });
767
+ this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
768
+ _this.results_update_field(evt);
769
+ });
770
+ this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
771
+ _this.activate_field(evt);
772
+ });
773
+ this.form_field_jq.bind("chosen:open.chosen", function(evt) {
774
+ _this.container_mousedown(evt);
775
+ });
776
+ this.form_field_jq.bind("chosen:close.chosen", function(evt) {
777
+ _this.close_field(evt);
778
+ });
779
+ this.search_field.bind('blur.chosen', function(evt) {
780
+ _this.input_blur(evt);
781
+ });
782
+ this.search_field.bind('keyup.chosen', function(evt) {
783
+ _this.keyup_checker(evt);
784
+ });
785
+ this.search_field.bind('keydown.chosen', function(evt) {
786
+ _this.keydown_checker(evt);
787
+ });
788
+ this.search_field.bind('focus.chosen', function(evt) {
789
+ _this.input_focus(evt);
790
+ });
791
+ this.search_field.bind('cut.chosen', function(evt) {
792
+ _this.clipboard_event_checker(evt);
793
+ });
794
+ this.search_field.bind('paste.chosen', function(evt) {
795
+ _this.clipboard_event_checker(evt);
796
+ });
797
+ if (this.is_multiple) {
798
+ return this.search_choices.bind('click.chosen', function(evt) {
799
+ _this.choices_click(evt);
800
+ });
801
+ } else {
802
+ return this.container.bind('click.chosen', function(evt) {
803
+ evt.preventDefault();
804
+ });
805
+ }
806
+ };
807
+
808
+ Chosen.prototype.destroy = function() {
809
+ $(this.container[0].ownerDocument).unbind('click.chosen', this.click_test_action);
810
+ if (this.form_field_label.length > 0) {
811
+ this.form_field_label.unbind('click.chosen');
812
+ }
813
+ if (this.search_field[0].tabIndex) {
814
+ this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
815
+ }
816
+ this.container.remove();
817
+ this.form_field_jq.removeData('chosen');
818
+ return this.form_field_jq.show();
819
+ };
820
+
821
+ Chosen.prototype.search_field_disabled = function() {
822
+ this.is_disabled = this.form_field.disabled || this.form_field_jq.parents('fieldset').is(':disabled');
823
+ this.container.toggleClass('chosen-disabled', this.is_disabled);
824
+ this.search_field[0].disabled = this.is_disabled;
825
+ if (!this.is_multiple) {
826
+ this.selected_item.unbind('focus.chosen', this.activate_field);
827
+ }
828
+ if (this.is_disabled) {
829
+ return this.close_field();
830
+ } else if (!this.is_multiple) {
831
+ return this.selected_item.bind('focus.chosen', this.activate_field);
832
+ }
833
+ };
834
+
835
+ Chosen.prototype.container_mousedown = function(evt) {
836
+ var _ref1;
837
+ if (this.is_disabled) {
838
+ return;
839
+ }
840
+ if (evt && ((_ref1 = evt.type) === 'mousedown' || _ref1 === 'touchstart') && !this.results_showing) {
841
+ evt.preventDefault();
842
+ }
843
+ if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
844
+ if (!this.active_field) {
845
+ if (this.is_multiple) {
846
+ this.search_field.val("");
847
+ }
848
+ $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
849
+ this.results_show();
850
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
851
+ evt.preventDefault();
852
+ this.results_toggle();
853
+ }
854
+ return this.activate_field();
855
+ }
856
+ };
857
+
858
+ Chosen.prototype.container_mouseup = function(evt) {
859
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
860
+ return this.results_reset(evt);
861
+ }
862
+ };
863
+
864
+ Chosen.prototype.search_results_mousewheel = function(evt) {
865
+ var delta;
866
+ if (evt.originalEvent) {
867
+ delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
868
+ }
869
+ if (delta != null) {
870
+ evt.preventDefault();
871
+ if (evt.type === 'DOMMouseScroll') {
872
+ delta = delta * 40;
873
+ }
874
+ return this.search_results.scrollTop(delta + this.search_results.scrollTop());
875
+ }
876
+ };
877
+
878
+ Chosen.prototype.blur_test = function(evt) {
879
+ if (!this.active_field && this.container.hasClass("chosen-container-active")) {
880
+ return this.close_field();
881
+ }
882
+ };
883
+
884
+ Chosen.prototype.close_field = function() {
885
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
886
+ this.active_field = false;
887
+ this.results_hide();
888
+ this.container.removeClass("chosen-container-active");
889
+ this.clear_backstroke();
890
+ this.show_search_field_default();
891
+ this.search_field_scale();
892
+ return this.search_field.blur();
893
+ };
894
+
895
+ Chosen.prototype.activate_field = function() {
896
+ if (this.is_disabled) {
897
+ return;
898
+ }
899
+ this.container.addClass("chosen-container-active");
900
+ this.active_field = true;
901
+ this.search_field.val(this.search_field.val());
902
+ return this.search_field.focus();
903
+ };
904
+
905
+ Chosen.prototype.test_active_click = function(evt) {
906
+ var active_container;
907
+ active_container = $(evt.target).closest('.chosen-container');
908
+ if (active_container.length && this.container[0] === active_container[0]) {
909
+ return this.active_field = true;
910
+ } else {
911
+ return this.close_field();
912
+ }
913
+ };
914
+
915
+ Chosen.prototype.results_build = function() {
916
+ this.parsing = true;
917
+ this.selected_option_count = null;
918
+ this.results_data = SelectParser.select_to_array(this.form_field);
919
+ if (this.is_multiple) {
920
+ this.search_choices.find("li.search-choice").remove();
921
+ } else if (!this.is_multiple) {
922
+ this.single_set_selected_text();
923
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
924
+ this.search_field[0].readOnly = true;
925
+ this.container.addClass("chosen-container-single-nosearch");
926
+ } else {
927
+ this.search_field[0].readOnly = false;
928
+ this.container.removeClass("chosen-container-single-nosearch");
929
+ }
930
+ }
931
+ this.update_results_content(this.results_option_build({
932
+ first: true
933
+ }));
934
+ this.search_field_disabled();
935
+ this.show_search_field_default();
936
+ this.search_field_scale();
937
+ return this.parsing = false;
938
+ };
939
+
940
+ Chosen.prototype.result_do_highlight = function(el) {
941
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
942
+ if (el.length) {
943
+ this.result_clear_highlight();
944
+ this.result_highlight = el;
945
+ this.result_highlight.addClass("highlighted");
946
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
947
+ visible_top = this.search_results.scrollTop();
948
+ visible_bottom = maxHeight + visible_top;
949
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
950
+ high_bottom = high_top + this.result_highlight.outerHeight();
951
+ if (high_bottom >= visible_bottom) {
952
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
953
+ } else if (high_top < visible_top) {
954
+ return this.search_results.scrollTop(high_top);
955
+ }
956
+ }
957
+ };
958
+
959
+ Chosen.prototype.result_clear_highlight = function() {
960
+ if (this.result_highlight) {
961
+ this.result_highlight.removeClass("highlighted");
962
+ }
963
+ return this.result_highlight = null;
964
+ };
965
+
966
+ Chosen.prototype.results_show = function() {
967
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
968
+ this.form_field_jq.trigger("chosen:maxselected", {
969
+ chosen: this
970
+ });
971
+ return false;
972
+ }
973
+ this.container.addClass("chosen-with-drop");
974
+ this.results_showing = true;
975
+ this.search_field.focus();
976
+ this.search_field.val(this.get_search_field_value());
977
+ this.winnow_results();
978
+ return this.form_field_jq.trigger("chosen:showing_dropdown", {
979
+ chosen: this
980
+ });
981
+ };
982
+
983
+ Chosen.prototype.update_results_content = function(content) {
984
+ return this.search_results.html(content);
985
+ };
986
+
987
+ Chosen.prototype.results_hide = function() {
988
+ if (this.results_showing) {
989
+ this.result_clear_highlight();
990
+ this.container.removeClass("chosen-with-drop");
991
+ this.form_field_jq.trigger("chosen:hiding_dropdown", {
992
+ chosen: this
993
+ });
994
+ }
995
+ return this.results_showing = false;
996
+ };
997
+
998
+ Chosen.prototype.set_tab_index = function(el) {
999
+ var ti;
1000
+ if (this.form_field.tabIndex) {
1001
+ ti = this.form_field.tabIndex;
1002
+ this.form_field.tabIndex = -1;
1003
+ return this.search_field[0].tabIndex = ti;
1004
+ }
1005
+ };
1006
+
1007
+ Chosen.prototype.set_label_behavior = function() {
1008
+ this.form_field_label = this.form_field_jq.parents("label");
1009
+ if (!this.form_field_label.length && this.form_field.id.length) {
1010
+ this.form_field_label = $("label[for='" + this.form_field.id + "']");
1011
+ }
1012
+ if (this.form_field_label.length > 0) {
1013
+ return this.form_field_label.bind('click.chosen', this.label_click_handler);
1014
+ }
1015
+ };
1016
+
1017
+ Chosen.prototype.show_search_field_default = function() {
1018
+ if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
1019
+ this.search_field.val(this.default_text);
1020
+ return this.search_field.addClass("default");
1021
+ } else {
1022
+ this.search_field.val("");
1023
+ return this.search_field.removeClass("default");
1024
+ }
1025
+ };
1026
+
1027
+ Chosen.prototype.search_results_mouseup = function(evt) {
1028
+ var target;
1029
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
1030
+ if (target.length) {
1031
+ this.result_highlight = target;
1032
+ this.result_select(evt);
1033
+ return this.search_field.focus();
1034
+ }
1035
+ };
1036
+
1037
+ Chosen.prototype.search_results_mouseover = function(evt) {
1038
+ var target;
1039
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
1040
+ if (target) {
1041
+ return this.result_do_highlight(target);
1042
+ }
1043
+ };
1044
+
1045
+ Chosen.prototype.search_results_mouseout = function(evt) {
1046
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
1047
+ return this.result_clear_highlight();
1048
+ }
1049
+ };
1050
+
1051
+ Chosen.prototype.choice_build = function(item) {
1052
+ var choice, close_link,
1053
+ _this = this;
1054
+ choice = $('<li />', {
1055
+ "class": "search-choice"
1056
+ }).html("<span>" + (this.choice_label(item)) + "</span>");
1057
+ if (item.disabled) {
1058
+ choice.addClass('search-choice-disabled');
1059
+ } else {
1060
+ close_link = $('<a />', {
1061
+ "class": 'search-choice-close',
1062
+ 'data-option-array-index': item.array_index
1063
+ });
1064
+ close_link.bind('click.chosen', function(evt) {
1065
+ return _this.choice_destroy_link_click(evt);
1066
+ });
1067
+ choice.append(close_link);
1068
+ }
1069
+ return this.search_container.before(choice);
1070
+ };
1071
+
1072
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
1073
+ evt.preventDefault();
1074
+ evt.stopPropagation();
1075
+ if (!this.is_disabled) {
1076
+ return this.choice_destroy($(evt.target));
1077
+ }
1078
+ };
1079
+
1080
+ Chosen.prototype.choice_destroy = function(link) {
1081
+ if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
1082
+ if (this.active_field) {
1083
+ this.search_field.focus();
1084
+ } else {
1085
+ this.show_search_field_default();
1086
+ }
1087
+ if (this.is_multiple && this.choices_count() > 0 && this.get_search_field_value().length < 1) {
1088
+ this.results_hide();
1089
+ }
1090
+ link.parents('li').first().remove();
1091
+ return this.search_field_scale();
1092
+ }
1093
+ };
1094
+
1095
+ Chosen.prototype.results_reset = function() {
1096
+ this.reset_single_select_options();
1097
+ this.form_field.options[0].selected = true;
1098
+ this.single_set_selected_text();
1099
+ this.show_search_field_default();
1100
+ this.results_reset_cleanup();
1101
+ this.trigger_form_field_change();
1102
+ if (this.active_field) {
1103
+ return this.results_hide();
1104
+ }
1105
+ };
1106
+
1107
+ Chosen.prototype.results_reset_cleanup = function() {
1108
+ this.current_selectedIndex = this.form_field.selectedIndex;
1109
+ return this.selected_item.find("abbr").remove();
1110
+ };
1111
+
1112
+ Chosen.prototype.result_select = function(evt) {
1113
+ var high, item;
1114
+ if (this.result_highlight) {
1115
+ high = this.result_highlight;
1116
+ this.result_clear_highlight();
1117
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
1118
+ this.form_field_jq.trigger("chosen:maxselected", {
1119
+ chosen: this
1120
+ });
1121
+ return false;
1122
+ }
1123
+ if (this.is_multiple) {
1124
+ high.removeClass("active-result");
1125
+ } else {
1126
+ this.reset_single_select_options();
1127
+ }
1128
+ high.addClass("result-selected");
1129
+ item = this.results_data[high[0].getAttribute("data-option-array-index")];
1130
+ item.selected = true;
1131
+ this.form_field.options[item.options_index].selected = true;
1132
+ this.selected_option_count = null;
1133
+ if (this.is_multiple) {
1134
+ this.choice_build(item);
1135
+ } else {
1136
+ this.single_set_selected_text(this.choice_label(item));
1137
+ }
1138
+ if (!(this.is_multiple && (!this.hide_results_on_select || (evt.metaKey || evt.ctrlKey)))) {
1139
+ this.results_hide();
1140
+ this.show_search_field_default();
1141
+ }
1142
+ if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1143
+ this.trigger_form_field_change({
1144
+ selected: this.form_field.options[item.options_index].value
1145
+ });
1146
+ }
1147
+ this.current_selectedIndex = this.form_field.selectedIndex;
1148
+ evt.preventDefault();
1149
+ return this.search_field_scale();
1150
+ }
1151
+ };
1152
+
1153
+ Chosen.prototype.single_set_selected_text = function(text) {
1154
+ if (text == null) {
1155
+ text = this.default_text;
1156
+ }
1157
+ if (text === this.default_text) {
1158
+ this.selected_item.addClass("chosen-default");
1159
+ } else {
1160
+ this.single_deselect_control_build();
1161
+ this.selected_item.removeClass("chosen-default");
1162
+ }
1163
+ return this.selected_item.find("span").html(text);
1164
+ };
1165
+
1166
+ Chosen.prototype.result_deselect = function(pos) {
1167
+ var result_data;
1168
+ result_data = this.results_data[pos];
1169
+ if (!this.form_field.options[result_data.options_index].disabled) {
1170
+ result_data.selected = false;
1171
+ this.form_field.options[result_data.options_index].selected = false;
1172
+ this.selected_option_count = null;
1173
+ this.result_clear_highlight();
1174
+ if (this.results_showing) {
1175
+ this.winnow_results();
1176
+ }
1177
+ this.trigger_form_field_change({
1178
+ deselected: this.form_field.options[result_data.options_index].value
1179
+ });
1180
+ this.search_field_scale();
1181
+ return true;
1182
+ } else {
1183
+ return false;
1184
+ }
1185
+ };
1186
+
1187
+ Chosen.prototype.single_deselect_control_build = function() {
1188
+ if (!this.allow_single_deselect) {
1189
+ return;
1190
+ }
1191
+ if (!this.selected_item.find("abbr").length) {
1192
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1193
+ }
1194
+ return this.selected_item.addClass("chosen-single-with-deselect");
1195
+ };
1196
+
1197
+ Chosen.prototype.get_search_field_value = function() {
1198
+ return this.search_field.val();
1199
+ };
1200
+
1201
+ Chosen.prototype.get_search_text = function() {
1202
+ return this.escape_html($.trim(this.get_search_field_value()));
1203
+ };
1204
+
1205
+ Chosen.prototype.escape_html = function(text) {
1206
+ return $('<div/>').text(text).html();
1207
+ };
1208
+
1209
+ Chosen.prototype.winnow_results_set_highlight = function() {
1210
+ var do_high, selected_results;
1211
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1212
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1213
+ if (do_high != null) {
1214
+ return this.result_do_highlight(do_high);
1215
+ }
1216
+ };
1217
+
1218
+ Chosen.prototype.no_results = function(terms) {
1219
+ var no_results_html;
1220
+ no_results_html = this.get_no_results_html(terms);
1221
+ this.search_results.append(no_results_html);
1222
+ return this.form_field_jq.trigger("chosen:no_results", {
1223
+ chosen: this
1224
+ });
1225
+ };
1226
+
1227
+ Chosen.prototype.no_results_clear = function() {
1228
+ return this.search_results.find(".no-results").remove();
1229
+ };
1230
+
1231
+ Chosen.prototype.keydown_arrow = function() {
1232
+ var next_sib;
1233
+ if (this.results_showing && this.result_highlight) {
1234
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
1235
+ if (next_sib) {
1236
+ return this.result_do_highlight(next_sib);
1237
+ }
1238
+ } else {
1239
+ return this.results_show();
1240
+ }
1241
+ };
1242
+
1243
+ Chosen.prototype.keyup_arrow = function() {
1244
+ var prev_sibs;
1245
+ if (!this.results_showing && !this.is_multiple) {
1246
+ return this.results_show();
1247
+ } else if (this.result_highlight) {
1248
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
1249
+ if (prev_sibs.length) {
1250
+ return this.result_do_highlight(prev_sibs.first());
1251
+ } else {
1252
+ if (this.choices_count() > 0) {
1253
+ this.results_hide();
1254
+ }
1255
+ return this.result_clear_highlight();
1256
+ }
1257
+ }
1258
+ };
1259
+
1260
+ Chosen.prototype.keydown_backstroke = function() {
1261
+ var next_available_destroy;
1262
+ if (this.pending_backstroke) {
1263
+ this.choice_destroy(this.pending_backstroke.find("a").first());
1264
+ return this.clear_backstroke();
1265
+ } else {
1266
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
1267
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
1268
+ this.pending_backstroke = next_available_destroy;
1269
+ if (this.single_backstroke_delete) {
1270
+ return this.keydown_backstroke();
1271
+ } else {
1272
+ return this.pending_backstroke.addClass("search-choice-focus");
1273
+ }
1274
+ }
1275
+ }
1276
+ };
1277
+
1278
+ Chosen.prototype.clear_backstroke = function() {
1279
+ if (this.pending_backstroke) {
1280
+ this.pending_backstroke.removeClass("search-choice-focus");
1281
+ }
1282
+ return this.pending_backstroke = null;
1283
+ };
1284
+
1285
+ Chosen.prototype.search_field_scale = function() {
1286
+ var container_width, div, style, style_block, styles, width, _i, _len;
1287
+ if (!this.is_multiple) {
1288
+ return;
1289
+ }
1290
+ style_block = {
1291
+ position: 'absolute',
1292
+ left: '-1000px',
1293
+ top: '-1000px',
1294
+ display: 'none',
1295
+ whiteSpace: 'pre'
1296
+ };
1297
+ styles = ['fontSize', 'fontStyle', 'fontWeight', 'fontFamily', 'lineHeight', 'textTransform', 'letterSpacing'];
1298
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1299
+ style = styles[_i];
1300
+ style_block[style] = this.search_field.css(style);
1301
+ }
1302
+ div = $('<div />').css(style_block);
1303
+ div.text(this.get_search_field_value());
1304
+ $('body').append(div);
1305
+ width = div.width() + 25;
1306
+ div.remove();
1307
+ container_width = this.container.outerWidth();
1308
+ width = Math.min(container_width - 10, width);
1309
+ return this.search_field.width(width);
1310
+ };
1311
+
1312
+ Chosen.prototype.trigger_form_field_change = function(extra) {
1313
+ this.form_field_jq.trigger("input", extra);
1314
+ return this.form_field_jq.trigger("change", extra);
1315
+ };
1316
+
1317
+ return Chosen;
1318
+
1319
+ })(AbstractChosen);
1320
+
1321
+ }).call(this);
js/lib/chosen/chosen.jquery.min.js CHANGED
@@ -1,2 +1,2 @@
1
- /* Chosen v1.3.0 | (c) 2011-2014 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),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,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,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},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_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.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(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(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(c.text));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,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,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(){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.group||this.group_search)&&(b.search_text=b.group?b.label:b.text,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:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(){var a=this;return setTimeout(function(){return a.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"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!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(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d instanceof Chosen?d.destroy():d instanceof Chosen||c.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" tabindex="-1"><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){a.container_mousedown(b)}),this.container.bind("touchend.chosen",function(b){a.container_mouseup(b)}),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(){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(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):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>"+b.html+"</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(),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(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(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,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").text(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 this.search_field.val()===this.default_text?"":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.7.0 | (c) 2011-2017 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+ (function(){var a,b,c,d,e,f=function(a,b){return function(){return a.apply(b,arguments)}},g={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)g.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};d=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},a.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},a.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},a.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},a}(),d.select_to_array=function(a){var b,c,e,f,g;for(c=new d,g=a.childNodes,e=0,f=g.length;f>e;e++)b=g[e],c.add_node(b);return c.parsed},b=function(){function a(b,c){this.form_field=b,this.options=null!=c?c:{},this.label_click_handler=f(this.label_click_handler,this),a.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 a.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.is_rtl=this.options.rtl||/\bchosen-rtl\b/.test(this.form_field.className),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,this.case_sensitive_search=this.options.case_sensitive_search||!1,this.hide_results_on_select=null!=this.options.hide_results_on_select?this.options.hide_results_on_select:!0},a.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||a.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||a.default_single_text,this.default_text=this.escape_html(this.default_text),this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||a.default_no_result_text},a.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},a.prototype.mouse_enter=function(){return this.mouse_on_container=!0},a.prototype.mouse_leave=function(){return this.mouse_on_container=!1},a.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()},a.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))},a.prototype.label_click_handler=function(a){return this.is_multiple?this.container_mousedown(a):this.activate_field()},a.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},a.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)):""},a.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)):""},a.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},a.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},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),e=0,g=this.get_search_text(),a=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),d=this.get_search_regex(a),b=this.get_highlight_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)c=l[j],c.search_match=!1,f=null,this.include_option_in_results(c)&&(c.group&&(c.group_match=!1,c.active_options=0),null!=c.group_array_index&&this.results_data[c.group_array_index]&&(f=this.results_data[c.group_array_index],0===f.active_options&&f.search_match&&(e+=1),f.active_options+=1),c.search_text=c.group?c.label:c.html,(!c.group||this.group_search)&&(c.search_match=this.search_string_match(c.search_text,d),c.search_match&&!c.group&&(e+=1),c.search_match?(g.length&&(h=c.search_text.search(b),i=c.search_text.substr(0,h+g.length)+"</em>"+c.search_text.substr(h+g.length),c.search_text=i.substr(0,h)+"<em>"+i.substr(h)),null!=f&&(f.group_match=!0)):null!=c.group_array_index&&this.results_data[c.group_array_index].search_match&&(c.search_match=!0)));return this.result_clear_highlight(),1>e&&g.length?(this.update_results_content(""),this.no_results(g)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},a.prototype.get_search_regex=function(a){var b,c;return b=this.search_contains?"":"^",c=this.case_sensitive_search?"":"i",new RegExp(b+a,c)},a.prototype.get_highlight_regex=function(a){var b,c;return b=this.search_contains?"":"\\b",c=this.case_sensitive_search?"":"i",new RegExp(b+a,c)},a.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},a.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},a.prototype.choices_click=function(a){return a.preventDefault(),this.activate_field(),this.results_showing||this.is_disabled?void 0:this.results_show()},a.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.get_search_field_value().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 27: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()}},a.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0?this.keydown_backstroke():this.pending_backstroke||(this.result_clear_highlight(),this.results_search());break;case 13:a.preventDefault(),this.results_showing&&this.result_select(a);break;case 27:this.results_showing&&this.results_hide();break;case 9:case 16:case 17:case 18:case 38:case 40:case 91:break;default:this.results_search()}},a.prototype.clipboard_event_checker=function(a){var b=this;if(!this.is_disabled)return setTimeout(function(){return b.results_search()},50)},a.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},a.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},a.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},a.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},a.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},a.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},a.prototype.get_single_html=function(){return'<a class="chosen-single chosen-default">\n <span>'+this.default_text+'</span>\n <div><b></b></div>\n</a>\n<div class="chosen-drop">\n <div class="chosen-search">\n <input class="chosen-search-input" type="text" autocomplete="off" />\n </div>\n <ul class="chosen-results"></ul>\n</div>'},a.prototype.get_multi_html=function(){return'<ul class="chosen-choices">\n <li class="search-field">\n <input class="chosen-search-input" type="text" autocomplete="off" value="'+this.default_text+'" />\n </li>\n</ul>\n<div class="chosen-drop">\n <ul class="chosen-results"></ul>\n</div>'},a.prototype.get_no_results_html=function(a){return'<li class="no-results">\n '+this.results_none_found+" <span>"+a+"</span>\n</li>"},a.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)||/IEMobile/i.test(window.navigator.userAgent)||/Windows Phone/i.test(window.navigator.userAgent)||/BlackBerry/i.test(window.navigator.userAgent)||/BB10/i.test(window.navigator.userAgent)||/Android.*Mobile/i.test(window.navigator.userAgent)?!1:!0},a.default_multiple_text="Select Some Options",a.default_single_text="Select an Option",a.default_no_result_text="No results match",a}(),a=jQuery,a.fn.extend({chosen:function(d){return b.browser_is_supported()?this.each(function(b){var e,f;return e=a(this),f=e.data("chosen"),"destroy"===d?void(f instanceof c&&f.destroy()):void(f instanceof c||e.data("chosen",new c(this,d)))}):this}}),c=function(b){function c(){return e=c.__super__.constructor.apply(this,arguments)}return h(c,b),c.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex},c.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(" "),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.container.width(this.container_width()),this.is_multiple?this.container.html(this.get_multi_html()):this.container.html(this.get_single_html()),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()},c.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},c.prototype.register_observers=function(){var a=this;return this.container.bind("touchstart.chosen",function(b){a.container_mousedown(b)}),this.container.bind("touchend.chosen",function(b){a.container_mouseup(b)}),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.close_field(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()})},c.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.form_field_label.length>0&&this.form_field_label.unbind("click.chosen"),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()},c.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field.disabled||this.form_field_jq.parents("fieldset").is(":disabled"),this.container.toggleClass("chosen-disabled",this.is_disabled),this.search_field[0].disabled=this.is_disabled,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_field),this.is_disabled?this.close_field():this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_field)},c.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return!b||"mousedown"!==(c=b.type)&&"touchstart"!==c||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())},c.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},c.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},c.prototype.blur_test=function(a){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},c.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(),this.search_field.blur()},c.prototype.activate_field=function(){return this.is_disabled?void 0:(this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus())},c.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()},c.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=d.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},c.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)}},c.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},c.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.get_search_field_value()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},c.prototype.update_results_content=function(a){return this.search_results.html(a)},c.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},c.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},c.prototype.set_label_behavior=function(){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",this.label_click_handler):void 0},c.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"))},c.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},c.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},c.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},c.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)},c.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},c.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.active_field?this.search_field.focus():this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.get_search_field_value().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},c.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.trigger_form_field_change(),this.active_field?this.results_hide():void 0},c.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},c.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)),(!this.is_multiple||this.hide_results_on_select&&!a.metaKey&&!a.ctrlKey)&&(this.results_hide(),this.show_search_field_default()),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.trigger_form_field_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},c.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)},c.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.trigger_form_field_change({deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},c.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},c.prototype.get_search_field_value=function(){return this.search_field.val()},c.prototype.get_search_text=function(){return this.escape_html(a.trim(this