Version Description
(2014.08.11) =
Download this release
Release Info
Developer | AndyGCook |
Plugin | HubSpot – Free Marketing Plugin for WordPress |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 2.0.0
- admin/inc/class-leadin-contact.php +250 -72
- admin/inc/class-leadin-list-table.php +233 -188
- admin/inc/class-leadin-tag-editor.php +184 -0
- admin/inc/class-leadin-tags-list-table.php +249 -0
- admin/inc/class-leadin-viewers.php +16 -16
- admin/inc/class-stats-dashboard.php +14 -14
- admin/leadin-admin.php +26 -13
- assets/css/build/leadin-admin.css +3 -3
- assets/fonts/icomoon.eot +0 -0
- assets/fonts/icomoon.svg +20 -0
- assets/fonts/icomoon.ttf +0 -0
- assets/fonts/icomoon.woff +0 -0
- assets/js/build/leadin-admin.js +101 -5
- assets/js/build/leadin-admin.min.js +4 -4
- assets/js/build/leadin-subscribe.js +2 -2
- assets/js/build/leadin-subscribe.min.js +1 -1
- assets/js/build/leadin-tracking.js +3 -13
- assets/js/build/leadin-tracking.min.js +1 -1
- inc/class-emailer.php +6 -67
- inc/class-leadin.php +296 -0
- inc/leadin-ajax-functions.php +207 -140
- inc/leadin-functions.php +319 -41
- leadin.php +276 -441
- power-ups/beta-program/admin/beta-program-admin.php +0 -2
- power-ups/constant-contact-list-sync.php +63 -19
- power-ups/constant-contact-list-sync/admin/constant-contact-list-sync-admin.php +85 -22
- power-ups/constant-contact-list-sync/inc/li_constant_contact.php +11 -2
- power-ups/contacts/admin/contacts-admin.php +484 -102
- power-ups/mailchimp-list-sync.php +46 -9
- power-ups/mailchimp-list-sync/admin/mailchimp-list-sync-admin.php +82 -11
- power-ups/mailchimp-list-sync/inc/MailChimp-API.php +4 -1
- power-ups/subscribe-widget.php +12 -0
- readme.txt +17 -5
- screenshot-1.png +0 -0
- screenshot-4.png +0 -0
- screenshot-6.png +0 -0
admin/inc/class-leadin-contact.php
CHANGED
@@ -28,7 +28,7 @@ class LI_Contact {
|
|
28 |
{
|
29 |
global $wpdb;
|
30 |
|
31 |
-
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id = %d
|
32 |
$this->hashkey = $wpdb->get_var($q);
|
33 |
|
34 |
return $this->hashkey;
|
@@ -44,52 +44,10 @@ class LI_Contact {
|
|
44 |
{
|
45 |
global $wpdb;
|
46 |
|
47 |
-
|
48 |
-
$
|
49 |
-
|
50 |
-
|
51 |
-
lead_id,
|
52 |
-
lead_ip,
|
53 |
-
lead_email,
|
54 |
-
lead_status
|
55 |
-
FROM
|
56 |
-
li_leads
|
57 |
-
WHERE hashkey LIKE %s " . $wpdb->multisite_query, '%b %D %l:%i%p', $this->hashkey);
|
58 |
-
|
59 |
-
$lead = $wpdb->get_row($q);
|
60 |
-
|
61 |
-
// Get all page views for the contact
|
62 |
-
$q = $wpdb->prepare("
|
63 |
-
SELECT
|
64 |
-
pageview_id,
|
65 |
-
pageview_date AS event_date,
|
66 |
-
DATE_FORMAT(pageview_date, %s) AS pageview_day,
|
67 |
-
DATE_FORMAT(pageview_date, %s) AS pageview_date,
|
68 |
-
lead_hashkey, pageview_title, pageview_url, pageview_source, pageview_session_start
|
69 |
-
FROM
|
70 |
-
li_pageviews
|
71 |
-
WHERE
|
72 |
-
pageview_deleted = 0 AND
|
73 |
-
lead_hashkey LIKE %s " . $wpdb->multisite_query . " ORDER BY event_date DESC", '%b %D', '%b %D %l:%i%p', $this->hashkey);
|
74 |
-
|
75 |
-
$pageviews = $wpdb->get_results($q, ARRAY_A);
|
76 |
-
|
77 |
-
// Get all submissions for the contact
|
78 |
-
$q = $wpdb->prepare("
|
79 |
-
SELECT
|
80 |
-
form_date AS event_date,
|
81 |
-
DATE_FORMAT(form_date, %s) AS form_date,
|
82 |
-
form_page_title,
|
83 |
-
form_page_url,
|
84 |
-
form_fields,
|
85 |
-
form_type
|
86 |
-
FROM
|
87 |
-
li_submissions
|
88 |
-
WHERE
|
89 |
-
form_deleted = 0 AND
|
90 |
-
lead_hashkey = %s " . $wpdb->multisite_query . " ORDER BY event_date DESC", '%b %D %l:%i%p', $this->hashkey);
|
91 |
-
|
92 |
-
$submissions = $wpdb->get_results($q, ARRAY_A);
|
93 |
|
94 |
// Merge the page views array and submissions array and reorder by date
|
95 |
$events_array = array_merge($pageviews, $submissions);
|
@@ -159,7 +117,6 @@ class LI_Contact {
|
|
159 |
|
160 |
// Always overwrite the last_submission date which will end as last submission date
|
161 |
$lead->first_submission = $event['event_date'];
|
162 |
-
$lead->last_submission_type = $event['form_type'];
|
163 |
|
164 |
// Used for $lead->total_submissions
|
165 |
$total_submissions++;
|
@@ -173,50 +130,271 @@ class LI_Contact {
|
|
173 |
$count++;
|
174 |
}
|
175 |
|
176 |
-
$lead->lead_status = $this->frontend_lead_status($lead->lead_status);
|
177 |
$lead->total_visits = $total_visits;
|
178 |
$lead->total_pageviews = $total_pageviews;
|
179 |
$lead->total_submissions = $total_submissions;
|
180 |
|
181 |
-
$this->history
|
182 |
-
$this->history->submission
|
183 |
-
$this->history->sessions
|
184 |
-
$this->history->lead
|
|
|
185 |
|
186 |
return stripslashes_deep($this->history);
|
187 |
}
|
188 |
|
189 |
/**
|
190 |
-
*
|
191 |
*
|
192 |
* @param string
|
193 |
-
* @
|
|
|
194 |
*/
|
195 |
-
function
|
196 |
{
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
}
|
199 |
|
200 |
/**
|
201 |
-
*
|
202 |
*
|
203 |
* @param string
|
204 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
*/
|
206 |
-
function
|
207 |
{
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
}
|
221 |
}
|
222 |
?>
|
28 |
{
|
29 |
global $wpdb;
|
30 |
|
31 |
+
$q = $wpdb->prepare("SELECT hashkey FROM $wpdb->li_leads WHERE lead_id = %d", $lead_id);
|
32 |
$this->hashkey = $wpdb->get_var($q);
|
33 |
|
34 |
return $this->hashkey;
|
44 |
{
|
45 |
global $wpdb;
|
46 |
|
47 |
+
$lead = $this->get_contact_details($this->hashkey);
|
48 |
+
$pageviews = $this->get_contact_pageviews($this->hashkey, 'ARRAY_A');
|
49 |
+
$submissions = $this->get_contact_submissions($this->hashkey, 'ARRAY_A');
|
50 |
+
$tags = $this->get_contact_tags($this->hashkey);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
// Merge the page views array and submissions array and reorder by date
|
53 |
$events_array = array_merge($pageviews, $submissions);
|
117 |
|
118 |
// Always overwrite the last_submission date which will end as last submission date
|
119 |
$lead->first_submission = $event['event_date'];
|
|
|
120 |
|
121 |
// Used for $lead->total_submissions
|
122 |
$total_submissions++;
|
130 |
$count++;
|
131 |
}
|
132 |
|
|
|
133 |
$lead->total_visits = $total_visits;
|
134 |
$lead->total_pageviews = $total_pageviews;
|
135 |
$lead->total_submissions = $total_submissions;
|
136 |
|
137 |
+
$this->history = (object)NULL;
|
138 |
+
$this->history->submission = $submissions[0];
|
139 |
+
$this->history->sessions = $sessions;
|
140 |
+
$this->history->lead = $lead;
|
141 |
+
$this->history->tags = $tags;
|
142 |
|
143 |
return stripslashes_deep($this->history);
|
144 |
}
|
145 |
|
146 |
/**
|
147 |
+
* Gets all the submissions for a contact
|
148 |
*
|
149 |
* @param string
|
150 |
+
* @param string
|
151 |
+
* @return array/object
|
152 |
*/
|
153 |
+
function get_contact_submissions ( $hashkey, $output_type = 'OBJECT' )
|
154 |
{
|
155 |
+
global $wpdb;
|
156 |
+
|
157 |
+
$q = $wpdb->prepare("
|
158 |
+
SELECT
|
159 |
+
form_date AS event_date,
|
160 |
+
DATE_FORMAT(form_date, %s) AS form_date,
|
161 |
+
form_page_title,
|
162 |
+
form_page_url,
|
163 |
+
form_fields
|
164 |
+
FROM
|
165 |
+
$wpdb->li_submissions
|
166 |
+
WHERE
|
167 |
+
form_deleted = 0 AND
|
168 |
+
lead_hashkey = %s ORDER BY event_date DESC", '%b %D %l:%i%p', $hashkey);
|
169 |
+
|
170 |
+
$submissions = $wpdb->get_results($q, $output_type);
|
171 |
+
|
172 |
+
return $submissions;
|
173 |
}
|
174 |
|
175 |
/**
|
176 |
+
* Gets all the pageviews for a contact
|
177 |
*
|
178 |
* @param string
|
179 |
+
* @param string
|
180 |
+
* @return array/object
|
181 |
+
*/
|
182 |
+
function get_contact_pageviews ( $hashkey, $output_type = 'OBJECT' )
|
183 |
+
{
|
184 |
+
global $wpdb;
|
185 |
+
|
186 |
+
$q = $wpdb->prepare("
|
187 |
+
SELECT
|
188 |
+
pageview_id,
|
189 |
+
pageview_date AS event_date,
|
190 |
+
DATE_FORMAT(pageview_date, %s) AS pageview_day,
|
191 |
+
DATE_FORMAT(pageview_date, %s) AS pageview_date,
|
192 |
+
lead_hashkey, pageview_title, pageview_url, pageview_source, pageview_session_start
|
193 |
+
FROM
|
194 |
+
$wpdb->li_pageviews
|
195 |
+
WHERE
|
196 |
+
pageview_deleted = 0 AND
|
197 |
+
lead_hashkey LIKE %s ORDER BY event_date DESC", '%b %D', '%b %D %l:%i%p', $hashkey);
|
198 |
+
|
199 |
+
$pageviews = $wpdb->get_results($q, $output_type);
|
200 |
+
|
201 |
+
return $pageviews;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Gets the details row for a contact
|
206 |
+
*
|
207 |
+
* @param string
|
208 |
+
* @param string
|
209 |
+
* @return array/object
|
210 |
+
*/
|
211 |
+
function get_contact_details ( $hashkey, $output_type = 'OBJECT' )
|
212 |
+
{
|
213 |
+
global $wpdb;
|
214 |
+
|
215 |
+
$q = $wpdb->prepare("
|
216 |
+
SELECT
|
217 |
+
DATE_FORMAT(lead_date, %s) AS lead_date,
|
218 |
+
lead_id,
|
219 |
+
lead_ip,
|
220 |
+
lead_email
|
221 |
+
FROM
|
222 |
+
$wpdb->li_leads
|
223 |
+
WHERE hashkey LIKE %s", '%b %D %l:%i%p', $hashkey);
|
224 |
+
|
225 |
+
$contact_details = $wpdb->get_row($q, $output_type);
|
226 |
+
|
227 |
+
return $contact_details;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Gets all the tags for a contact
|
232 |
+
*
|
233 |
+
* @param string
|
234 |
+
* @param string
|
235 |
+
* @return array/object
|
236 |
+
*/
|
237 |
+
function get_contact_tags ( $hashkey = '', $output_type = 'OBJECT' )
|
238 |
+
{
|
239 |
+
global $wpdb;
|
240 |
+
|
241 |
+
$q = $wpdb->prepare("
|
242 |
+
SELECT
|
243 |
+
lt.tag_text, lt.tag_slug, lt.tag_order, lt.tag_id, ( ltr.tag_id IS NOT NULL AND ltr.tag_relationship_deleted = 0 ) AS tag_set
|
244 |
+
FROM
|
245 |
+
$wpdb->li_tags lt
|
246 |
+
LEFT OUTER JOIN
|
247 |
+
$wpdb->li_tag_relationships ltr ON lt.tag_id = ltr.tag_id AND ltr.contact_hashkey = %s
|
248 |
+
WHERE
|
249 |
+
lt.tag_deleted = 0
|
250 |
+
ORDER BY lt.tag_order ASC", $hashkey);
|
251 |
+
|
252 |
+
$tags = $wpdb->get_results($q, $output_type);
|
253 |
+
|
254 |
+
return $tags;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Set the tags on a contact
|
259 |
+
*
|
260 |
+
* @param int
|
261 |
+
* @param array
|
262 |
+
* @return bool rows deleted or not
|
263 |
*/
|
264 |
+
function update_contact_tags ( $contact_id, $update_tags )
|
265 |
{
|
266 |
+
global $wpdb;
|
267 |
+
|
268 |
+
$esp_power_ups = array(
|
269 |
+
'MailChimp' => 'mailchimp_list_sync',
|
270 |
+
'Constant Contact' => 'constant_contact_list_sync',
|
271 |
+
'AWeber' => 'aweber_list_sync',
|
272 |
+
'GetResponse' => 'getresponse_list_sync',
|
273 |
+
'MailPoet' => 'mailpoet_list_sync',
|
274 |
+
'Campaign Monitor' => 'campaign_monitor_list_sync'
|
275 |
+
);
|
276 |
+
|
277 |
+
$safe_tags = $tags_to_update = '';
|
278 |
+
|
279 |
+
if ( ! isset($this->hashkey) )
|
280 |
+
$this->hashkey = $this->set_hashkey_by_id($contact_id);
|
281 |
+
|
282 |
+
if ( ! isset($this->history) )
|
283 |
+
$this->history = $this->get_contact_history();
|
284 |
+
|
285 |
+
$q = $wpdb->prepare("
|
286 |
+
SELECT
|
287 |
+
lt.tag_text, lt.tag_slug, lt.tag_order, lt.tag_id, lt.tag_synced_lists, ltr.tag_relationship_id, ltr.tag_relationship_deleted, ( ltr.tag_id IS NOT NULL ) AS tag_set
|
288 |
+
FROM
|
289 |
+
$wpdb->li_tags lt
|
290 |
+
LEFT OUTER JOIN
|
291 |
+
$wpdb->li_tag_relationships ltr ON lt.tag_id = ltr.tag_id AND ltr.contact_hashkey = %s
|
292 |
+
WHERE
|
293 |
+
lt.tag_deleted = 0
|
294 |
+
ORDER BY lt.tag_order ASC", $this->hashkey);
|
295 |
+
|
296 |
+
$tags = $wpdb->get_results($q);
|
297 |
+
|
298 |
+
|
299 |
+
// Start looping through all the tags that exist
|
300 |
+
foreach ( $tags as $tag )
|
301 |
+
{
|
302 |
+
// Check if the tag is in the list of tags to update and hit the li_tag_relationships table accordingly
|
303 |
+
$update_tag = in_array($tag->tag_id, $update_tags);
|
304 |
+
if ( $update_tag )
|
305 |
+
{
|
306 |
+
if ( ! $tag->tag_set )
|
307 |
+
{
|
308 |
+
$wpdb->insert(
|
309 |
+
$wpdb->li_tag_relationships,
|
310 |
+
array (
|
311 |
+
'tag_id' => $tag->tag_id,
|
312 |
+
'contact_hashkey' => $this->hashkey
|
313 |
+
),
|
314 |
+
array (
|
315 |
+
'%d', '%s'
|
316 |
+
)
|
317 |
+
);
|
318 |
+
|
319 |
+
$safe_tags .= $wpdb->insert_id . ',';
|
320 |
+
}
|
321 |
+
else
|
322 |
+
{
|
323 |
+
$safe_tags .= $tag->tag_relationship_id . ',';
|
324 |
+
$tags_to_update .= $tag->tag_relationship_id . ',';
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
$synced_lists = array();
|
329 |
+
//$removed_lists = array();
|
330 |
+
|
331 |
+
// Only sync update contacts are deleted or were newly inserted
|
332 |
+
if ( $tag->tag_synced_lists && $update_tag && ( $tag->tag_relationship_deleted || ! $tag->tag_set ) )
|
333 |
+
{
|
334 |
+
foreach ( unserialize($tag->tag_synced_lists) as $list )
|
335 |
+
{
|
336 |
+
// Skip syncing this list because the contact is already synced through another list
|
337 |
+
if ( in_array($list['list_id'], $synced_lists) )
|
338 |
+
continue;
|
339 |
+
|
340 |
+
$power_up_global = 'leadin_' . $list['esp'] . '_list_sync' . '_wp';
|
341 |
+
if ( array_key_exists($power_up_global, $GLOBALS) )
|
342 |
+
{
|
343 |
+
global ${$power_up_global};
|
344 |
+
|
345 |
+
if ( ! ${$power_up_global}->activated )
|
346 |
+
continue;
|
347 |
+
|
348 |
+
${$power_up_global}->push_contact_to_list($list['list_id'], $this->history->lead->lead_email);
|
349 |
+
}
|
350 |
+
|
351 |
+
array_push($synced_lists, $list['list_id']);
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
/*else if ( $tag->tag_synced_lists && ! $update_tag && ! $tag->tag_relationship_deleted )
|
356 |
+
{
|
357 |
+
foreach ( unserialize($tag->tag_synced_lists) as $list )
|
358 |
+
{
|
359 |
+
// Skip removing contact form list if it has already happened or the contact was previoulsy synced
|
360 |
+
if ( in_array($list['list_id'], $removed_lists) || in_array($list['list_id'], $synced_lists) )
|
361 |
+
continue;
|
362 |
+
|
363 |
+
$power_up_global = 'leadin_' . $list['esp'] . '_list_sync' . '_wp';
|
364 |
+
if ( array_key_exists($power_up_global, $GLOBALS) )
|
365 |
+
{
|
366 |
+
global ${$power_up_global};
|
367 |
+
|
368 |
+
if ( ! ${$power_up_global}->activated )
|
369 |
+
continue;
|
370 |
+
|
371 |
+
${$power_up_global}->remove_contact_from_list($list['list_id'], $this->history->lead->lead_email);
|
372 |
+
}
|
373 |
+
|
374 |
+
array_push($synced_lists, $list['list_id']);
|
375 |
+
}
|
376 |
+
}*/
|
377 |
+
}
|
378 |
+
|
379 |
+
if ( $tags_to_update )
|
380 |
+
{
|
381 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_tag_relationships SET tag_relationship_deleted = 0 WHERE contact_hashkey = %s AND tag_relationship_id IN ( " . rtrim($tags_to_update, ',') . " ) ", $this->hashkey);
|
382 |
+
$tag_updated = $wpdb->query($q);
|
383 |
+
}
|
384 |
+
|
385 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_tag_relationships SET tag_relationship_deleted = 1 WHERE contact_hashkey = %s " . ( $safe_tags ? "AND tag_relationship_id NOT IN ( " . rtrim($safe_tags, ',') . " ) " : '' ) . " AND tag_relationship_deleted = 0 ", $this->hashkey);
|
386 |
+
$deleted_tags = $wpdb->query($q);
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* usort helper function to sort array by event date
|
391 |
+
*
|
392 |
+
* @param string
|
393 |
+
* @return array
|
394 |
+
*/
|
395 |
+
function sort_by_event_date ( $a, $b )
|
396 |
+
{
|
397 |
+
return $a['event_date'] < $b['event_date'];
|
398 |
}
|
399 |
}
|
400 |
?>
|
admin/inc/class-leadin-list-table.php
CHANGED
@@ -22,8 +22,9 @@ class LI_List_Table extends WP_List_Table {
|
|
22 |
public $view_label;
|
23 |
private $view_count;
|
24 |
private $views;
|
25 |
-
private $
|
26 |
private $total_filtered;
|
|
|
27 |
|
28 |
/**
|
29 |
* Class constructor
|
@@ -61,8 +62,6 @@ class LI_List_Table extends WP_List_Table {
|
|
61 |
{
|
62 |
case 'email':
|
63 |
|
64 |
-
case 'status':
|
65 |
-
return $item[$column_name];
|
66 |
case 'date':
|
67 |
return $item[$column_name];
|
68 |
case 'last_visit':
|
@@ -129,7 +128,6 @@ class LI_List_Table extends WP_List_Table {
|
|
129 |
'cb' => '<input type="checkbox" />',
|
130 |
'email' => 'Email',
|
131 |
'source' => 'Original source',
|
132 |
-
'status' => 'Status',
|
133 |
'visits' => 'Visits',
|
134 |
'pageviews' => 'Page views',
|
135 |
'submissions' => 'Forms',
|
@@ -149,8 +147,7 @@ class LI_List_Table extends WP_List_Table {
|
|
149 |
function get_sortable_columns ()
|
150 |
{
|
151 |
$sortable_columns = array(
|
152 |
-
'email' => array('email',false),
|
153 |
-
'status' => array('status',false),
|
154 |
'pageviews' => array('pageviews',false),
|
155 |
'visits' => array('visits',false),
|
156 |
'submissions' => array('submissions',false),
|
@@ -168,15 +165,15 @@ class LI_List_Table extends WP_List_Table {
|
|
168 |
*/
|
169 |
function get_bulk_actions ()
|
170 |
{
|
|
|
|
|
171 |
$actions = array(
|
172 |
-
'
|
173 |
-
'
|
174 |
-
'
|
175 |
-
'
|
176 |
-
'
|
177 |
-
'
|
178 |
-
'delete' => 'Delete'
|
179 |
-
|
180 |
);
|
181 |
|
182 |
return $actions;
|
@@ -192,46 +189,114 @@ class LI_List_Table extends WP_List_Table {
|
|
192 |
$ids_for_action = '';
|
193 |
$hashes_for_action = '';
|
194 |
|
195 |
-
|
|
|
196 |
{
|
197 |
-
|
198 |
{
|
199 |
-
|
|
|
|
|
200 |
|
201 |
-
|
202 |
-
|
|
|
203 |
}
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
-
|
|
|
|
|
|
|
206 |
$hashes = $wpdb->get_results($q);
|
207 |
|
208 |
if ( count($hashes) )
|
209 |
{
|
210 |
-
|
211 |
-
|
212 |
-
$hashes_for_action .= "'". $hashes[$i]->hashkey. "'";
|
213 |
|
214 |
-
|
215 |
-
$hashes_for_action .= ",";
|
216 |
-
}
|
217 |
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
|
224 |
-
|
225 |
-
|
226 |
|
227 |
-
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
}
|
230 |
-
|
|
|
|
|
|
|
|
|
231 |
{
|
232 |
-
$
|
|
|
|
|
233 |
|
234 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
$wpdb->query($q);
|
236 |
}
|
237 |
}
|
@@ -247,14 +312,20 @@ class LI_List_Table extends WP_List_Table {
|
|
247 |
{
|
248 |
/***
|
249 |
== FILTER ARGS ==
|
250 |
-
-
|
251 |
-
-
|
252 |
-
-
|
|
|
|
|
|
|
253 |
*/
|
254 |
|
255 |
global $wpdb;
|
256 |
|
257 |
-
$mysql_search_filter
|
|
|
|
|
|
|
258 |
|
259 |
// search filter
|
260 |
if ( isset($_GET['s']) )
|
@@ -262,71 +333,84 @@ class LI_List_Table extends WP_List_Table {
|
|
262 |
$search_query = $_GET['s'];
|
263 |
$mysql_search_filter = $wpdb->prepare(" AND ( l.lead_email LIKE '%%%s%%' OR l.lead_source LIKE '%%%s%%' ) ", like_escape($search_query), like_escape($search_query));
|
264 |
}
|
|
|
|
|
265 |
|
266 |
// contact type filter
|
267 |
if ( isset($_GET['contact_type']) )
|
268 |
{
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
}
|
275 |
|
276 |
-
// filter for visiting a specific page
|
277 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
278 |
{
|
279 |
-
|
280 |
-
$filtered_contacts = $wpdb->get_results($q);
|
281 |
-
|
282 |
-
if ( count($filtered_contacts) )
|
283 |
{
|
284 |
-
$
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
$mysql_search_filter = " AND l.hashkey IN ( " . $filtered_hashkeys . " ) ";
|
289 |
}
|
290 |
}
|
291 |
|
292 |
// filter for a form submitted on a specific page
|
293 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
294 |
{
|
295 |
-
$
|
296 |
-
$
|
297 |
-
|
298 |
-
if ( count($filtered_contacts) )
|
299 |
{
|
300 |
-
$
|
301 |
-
|
302 |
-
$filtered_hashkeys .= "'" . $filtered_contacts[$i]->lead_hashkey . "'" . ( $i != (count($filtered_contacts) - 1) ? ', ' : '' );
|
303 |
-
|
304 |
-
$mysql_search_filter = " AND l.hashkey IN ( " . $filtered_hashkeys . " ) ";
|
305 |
}
|
306 |
-
}
|
307 |
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
{
|
310 |
$q = $wpdb->prepare("
|
311 |
SELECT
|
312 |
l.lead_id AS lead_id,
|
313 |
-
LOWER(DATE_FORMAT(l.lead_date, %s)) AS lead_date, l.lead_ip, l.lead_source, l.lead_email, l.
|
314 |
COUNT(DISTINCT s.form_id) AS lead_form_submissions,
|
315 |
COUNT(DISTINCT p.pageview_id) AS lead_pageviews,
|
316 |
LOWER(DATE_FORMAT(MAX(p.pageview_date), %s)) AS last_visit,
|
317 |
-
( SELECT COUNT(DISTINCT pageview_id) FROM li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0
|
318 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0
|
319 |
FROM
|
320 |
-
li_leads l
|
321 |
-
LEFT JOIN li_submissions s ON l.hashkey = s.lead_hashkey
|
322 |
-
LEFT JOIN li_pageviews p ON l.hashkey = p.lead_hashkey
|
323 |
-
WHERE l.lead_email != '' AND l.lead_deleted = 0 ", '%Y/%m/%d %l:%i%p', '%Y/%m/%d %l:%i%p');
|
324 |
|
325 |
$q .= $mysql_contact_type_filter;
|
326 |
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
327 |
-
$q .=
|
328 |
-
$q .= " GROUP BY l.
|
329 |
-
|
330 |
$leads = $wpdb->get_results($q);
|
331 |
}
|
332 |
else
|
@@ -342,19 +426,6 @@ class LI_List_Table extends WP_List_Table {
|
|
342 |
{
|
343 |
foreach ( $leads as $key => $lead )
|
344 |
{
|
345 |
-
$lead_status = 'Contact';
|
346 |
-
|
347 |
-
if ( $lead->lead_status == 'subscribe' )
|
348 |
-
$lead_status = 'Subscriber';
|
349 |
-
else if ( $lead->lead_status == 'comment' )
|
350 |
-
$lead_status = 'Commenter';
|
351 |
-
else if ( $lead->lead_status == 'lead' )
|
352 |
-
$lead_status = 'Lead';
|
353 |
-
else if ( $lead->lead_status == 'contacted' )
|
354 |
-
$lead_status = 'Contacted';
|
355 |
-
else if ( $lead->lead_status == 'customer' )
|
356 |
-
$lead_status = 'Customer';
|
357 |
-
|
358 |
// filter for number of page views and skipping lead if it doesn't meet the minimum
|
359 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'num_pageviews' )
|
360 |
{
|
@@ -368,7 +439,6 @@ class LI_List_Table extends WP_List_Table {
|
|
368 |
'ID' => $lead->lead_id,
|
369 |
'hashkey' => $lead->hashkey,
|
370 |
'email' => sprintf('<a href="?page=%s&action=%s&lead=%s">' . "<img class='pull-left leadin-contact-avatar leadin-dynamic-avatar_" . substr($lead->lead_id, -1) . "' src='https://app.getsignals.com/avatar/image/?emails=" . $lead->lead_email . "' width='35' height='35'/> " . '</a>', $_REQUEST['page'], 'view', $lead->lead_id) . sprintf('<a href="?page=%s&action=%s&lead=%s"><b>' . $lead->lead_email . '</b></a>', $_REQUEST['page'], 'view', $lead->lead_id),
|
371 |
-
'status' => $lead_status,
|
372 |
'visits' => ( !isset($lead->visits) ? 1 : $lead->visits ),
|
373 |
'submissions' => $lead->lead_form_submissions,
|
374 |
'pageviews' => $lead->lead_pageviews,
|
@@ -391,25 +461,20 @@ class LI_List_Table extends WP_List_Table {
|
|
391 |
/**
|
392 |
* Gets the total number of contacts, comments and subscribers for above the table
|
393 |
*/
|
394 |
-
function
|
395 |
{
|
396 |
global $wpdb;
|
397 |
-
|
398 |
$q = "
|
399 |
SELECT
|
400 |
-
COUNT(DISTINCT
|
401 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'lead' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_leads,
|
402 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'comment' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_comments,
|
403 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'subscribe' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_subscribes,
|
404 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'contacted' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_contacted,
|
405 |
-
( SELECT COUNT(DISTINCT lead_email) FROM li_leads WHERE lead_status = 'customer' AND lead_email != '' AND lead_deleted = 0 " . $wpdb->multisite_query . " ) AS total_customers
|
406 |
FROM
|
407 |
-
li_leads
|
408 |
WHERE
|
409 |
-
lead_email != '' AND lead_deleted = 0
|
410 |
|
411 |
-
$
|
412 |
-
return $
|
413 |
}
|
414 |
|
415 |
/**
|
@@ -440,50 +505,25 @@ class LI_List_Table extends WP_List_Table {
|
|
440 |
}
|
441 |
|
442 |
/**
|
443 |
-
* Get the
|
444 |
*
|
445 |
* @return string
|
446 |
*/
|
447 |
-
function
|
448 |
{
|
449 |
-
$
|
450 |
-
$this->totals = $this->get_contact_type_totals();
|
451 |
-
|
452 |
-
$current = ( !empty($_GET['contact_type']) ? html_entity_decode($_GET['contact_type']) : 'all' );
|
453 |
-
$all_params = array( 'contact_type', 's', 'paged', '_wpnonce', '_wpreferrer', '_wp_http_referer', 'action', 'action2', 'filter_action', 'filter_content', 'contact');
|
454 |
-
$all_url = remove_query_arg($all_params);
|
455 |
-
|
456 |
-
// All link
|
457 |
-
$class = ( $current == 'all' ? ' class="current"' :'' );
|
458 |
-
$views['all'] = "<a href='{$all_url }' {$class} >" . ( $this->totals->total_contacts ) . " total contacts</a>";
|
459 |
-
|
460 |
-
// Commenters link
|
461 |
-
$comments_url = add_query_arg('contact_type','comment', $all_url);
|
462 |
-
$class = ( $current == 'comment' ? ' class="current"' :'' );
|
463 |
-
$views['commenters'] = "<a href='{$comments_url}' {$class} >" . leadin_single_plural_label($this->totals->total_comments, 'commenter', 'commenters') . "</a>";
|
464 |
-
|
465 |
-
// Subscribers link
|
466 |
-
$subscribers_url = add_query_arg('contact_type','subscribe', $all_url);
|
467 |
-
$class = ( $current == 'subscribe' ? ' class="current"' :'' );
|
468 |
-
$views['subscribe'] = "<a href='{$subscribers_url}' {$class} >" . leadin_single_plural_label($this->totals->total_subscribes, 'subscriber', 'subscribers') . "</a>";
|
469 |
-
|
470 |
-
// Leads link
|
471 |
-
$leads_url = add_query_arg('contact_type','lead', $all_url);
|
472 |
-
$class = ( $current == 'lead' ? ' class="current"' :'' );
|
473 |
-
$views['contacts'] = "<a href='{$leads_url}' {$class} >" . leadin_single_plural_label($this->totals->total_leads, 'lead', 'leads') . "</a>";
|
474 |
-
|
475 |
-
// Contacted link
|
476 |
-
$contacted_url = add_query_arg('contact_type','contacted', $all_url);
|
477 |
-
$class = ( $current == 'contacted' ? ' class="current"' :'' );
|
478 |
-
$views['contacted'] = "<a href='{$contacted_url}' {$class} >" . leadin_single_plural_label($this->totals->total_contacted, 'contacted', 'contacted') . "</a>";
|
479 |
-
|
480 |
-
// Customers link
|
481 |
-
$customers_url = add_query_arg('contact_type','customer', $all_url);
|
482 |
-
$class = ( $current == 'customer' ? ' class="current"' :'' );
|
483 |
-
$views['customer'] = "<a href='{$customers_url}' {$class} >" . leadin_single_plural_label($this->totals->total_customers, 'customer', 'customers') . "</a>";
|
484 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
|
486 |
-
return $
|
487 |
}
|
488 |
|
489 |
/**
|
@@ -491,53 +531,44 @@ class LI_List_Table extends WP_List_Table {
|
|
491 |
*/
|
492 |
function views ()
|
493 |
{
|
494 |
-
$this->
|
495 |
-
$
|
496 |
-
$
|
|
|
|
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
$this->view_label = 'Commenters';
|
502 |
-
$this->view_count = number_format($this->totals->total_comments);
|
503 |
-
break;
|
504 |
-
|
505 |
-
case 'subscribe' :
|
506 |
-
$this->view_label = 'Subscribers';
|
507 |
-
$this->view_count = number_format($this->totals->total_subscribes);
|
508 |
-
break;
|
509 |
-
|
510 |
-
case 'lead' :
|
511 |
-
$this->view_label = 'Leads';
|
512 |
-
$this->view_count = number_format($this->totals->total_leads);
|
513 |
-
break;
|
514 |
-
|
515 |
-
case 'contacted' :
|
516 |
-
$this->view_label = 'Contacted';
|
517 |
-
$this->view_count = number_format($this->totals->total_contacted);
|
518 |
-
break;
|
519 |
-
|
520 |
-
case 'customer' :
|
521 |
-
$this->view_label = 'Customers';
|
522 |
-
$this->view_count = number_format($this->totals->total_customers);
|
523 |
-
break;
|
524 |
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
break;
|
529 |
}
|
530 |
|
531 |
-
if ( empty( $this->
|
532 |
-
|
|
|
|
|
|
|
|
|
533 |
|
534 |
-
echo "<ul class='leadin-contacts__type-picker'
|
535 |
-
foreach ( $this->
|
536 |
-
|
537 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
}
|
539 |
-
echo implode( "</li>\n", $this->views ) . "</li>\n";
|
540 |
echo "</ul>";
|
|
|
|
|
541 |
}
|
542 |
|
543 |
|
@@ -550,20 +581,28 @@ class LI_List_Table extends WP_List_Table {
|
|
550 |
|
551 |
?>
|
552 |
<form id="leadin-contacts-filter" class="leadin-contacts__filter" method="GET">
|
|
|
553 |
<h3 class="leadin-contacts__filter-text">
|
554 |
-
|
555 |
-
<
|
556 |
-
|
557 |
-
|
|
|
|
|
558 |
</select>
|
559 |
|
560 |
-
<
|
|
|
|
|
|
|
|
|
561 |
|
562 |
<input type="submit" name="" id="leadin-contacts-filter-button" class="button action" value="Apply">
|
563 |
|
564 |
<?php if ( isset($_GET['filter_action']) || isset($_GET['filter_content']) ) : ?>
|
565 |
<a href="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts' . ( isset($_GET['contact_type']) ? '&contact_type=' . $_GET['contact_type'] : '' ); ?>" id="clear-filter">clear filter</a>
|
566 |
<?php endif; ?>
|
|
|
567 |
</h3>
|
568 |
|
569 |
<?php if ( isset($_GET['contact_type']) ) : ?>
|
@@ -606,6 +645,13 @@ class LI_List_Table extends WP_List_Table {
|
|
606 |
) );
|
607 |
}
|
608 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
609 |
function usort_reorder ( $a, $b )
|
610 |
{
|
611 |
$orderby = ( !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'last_visit' );
|
@@ -620,5 +666,4 @@ class LI_List_Table extends WP_List_Table {
|
|
620 |
|
621 |
return ( $order === 'asc' ? $result : -$result );
|
622 |
}
|
623 |
-
|
624 |
}
|
22 |
public $view_label;
|
23 |
private $view_count;
|
24 |
private $views;
|
25 |
+
private $total_contacts;
|
26 |
private $total_filtered;
|
27 |
+
public $tags;
|
28 |
|
29 |
/**
|
30 |
* Class constructor
|
62 |
{
|
63 |
case 'email':
|
64 |
|
|
|
|
|
65 |
case 'date':
|
66 |
return $item[$column_name];
|
67 |
case 'last_visit':
|
128 |
'cb' => '<input type="checkbox" />',
|
129 |
'email' => 'Email',
|
130 |
'source' => 'Original source',
|
|
|
131 |
'visits' => 'Visits',
|
132 |
'pageviews' => 'Page views',
|
133 |
'submissions' => 'Forms',
|
147 |
function get_sortable_columns ()
|
148 |
{
|
149 |
$sortable_columns = array(
|
150 |
+
'email' => array('email',false), // presorted if true
|
|
|
151 |
'pageviews' => array('pageviews',false),
|
152 |
'visits' => array('visits',false),
|
153 |
'submissions' => array('submissions',false),
|
165 |
*/
|
166 |
function get_bulk_actions ()
|
167 |
{
|
168 |
+
$contact_type = strtolower($this->view_label);
|
169 |
+
$filtered = ( isset($_GET['filter_action']) ? 'filtered ' : '' );
|
170 |
$actions = array(
|
171 |
+
'add_tag_to_all' => 'Add a tag to all ' . $filtered . $contact_type . ' in list',
|
172 |
+
'add_tag_to_selected' => 'Add a tag to selected ' . $contact_type,
|
173 |
+
'remove_tag_from_all' => 'Remove a tag from all ' . $filtered . $contact_type . ' in list',
|
174 |
+
'remove_tag_from_selected' => 'Remove a tag from selected ' . $contact_type,
|
175 |
+
'delete_all' => 'Delete all ' . $contact_type . ' from LeadIn',
|
176 |
+
'delete_selected' => 'Delete selected ' . $contact_type . ' from LeadIn'
|
|
|
|
|
177 |
);
|
178 |
|
179 |
return $actions;
|
189 |
$ids_for_action = '';
|
190 |
$hashes_for_action = '';
|
191 |
|
192 |
+
// @TODO Fix the delete logic
|
193 |
+
if ( strstr($this->current_action(), 'delete') )
|
194 |
{
|
195 |
+
if ( 'delete_selected' === $this->current_action() )
|
196 |
{
|
197 |
+
for ( $i = 0; $i < count($_GET['contact']); $i++ )
|
198 |
+
{
|
199 |
+
$ids_for_action .= $_GET['contact'][$i];;
|
200 |
|
201 |
+
if ( $i != (count($_GET['contact'])-1) )
|
202 |
+
$ids_for_action .= ',';
|
203 |
+
}
|
204 |
}
|
205 |
+
else if ( 'delete_all' === $this->current_action() )
|
206 |
+
{
|
207 |
+
$contacts = $this->get_contacts();
|
208 |
+
foreach ( $contacts as $contact )
|
209 |
+
$ids_for_action .= $contact['ID'] . ',';
|
210 |
|
211 |
+
$ids_for_action = rtrim($ids_for_action, ',');
|
212 |
+
}
|
213 |
+
|
214 |
+
$q = $wpdb->prepare("SELECT hashkey FROM $wpdb->li_leads WHERE lead_id IN ( " . $ids_for_action . " ) ", "");
|
215 |
$hashes = $wpdb->get_results($q);
|
216 |
|
217 |
if ( count($hashes) )
|
218 |
{
|
219 |
+
foreach ( $hashes as $hash )
|
220 |
+
$hashes_for_action .= "'" . $hash->hashkey . "',";
|
|
|
221 |
|
222 |
+
$hashes_for_action = rtrim($hashes_for_action, ',');
|
|
|
|
|
223 |
|
224 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey IN (" . $hashes_for_action . ") ", "");
|
225 |
+
$delete_pageviews = $wpdb->query($q);
|
226 |
+
|
227 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_submissions SET form_deleted = 1 WHERE lead_hashkey IN (" . $hashes_for_action . ") ", "");
|
228 |
+
$delete_submissions = $wpdb->query($q);
|
229 |
+
|
230 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_leads SET lead_deleted = 1 WHERE lead_id IN (" . $ids_for_action . ") ", "");
|
231 |
+
$delete_leads = $wpdb->query($q);
|
232 |
+
|
233 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_tag_relationships SET tag_relationship_deleted = 1 WHERE contact_hashkey IN (" . $hashes_for_action . ") ", "");
|
234 |
+
$delete_tags = $wpdb->query($q);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
if ( isset($_POST['bulk_edit_tags']) )
|
239 |
+
{
|
240 |
+
$q = $wpdb->prepare("SELECT tag_id FROM $wpdb->li_tags WHERE tag_slug = %s ", $_POST['bulk_selected_tag']);
|
241 |
+
$tag_id = $wpdb->get_var($q);
|
242 |
+
|
243 |
+
if ( empty($_POST['leadin_selected_contacts']) )
|
244 |
+
{
|
245 |
+
$contacts = $this->get_contacts();
|
246 |
+
foreach ( $contacts as $contact )
|
247 |
+
$ids_for_action .= $contact['ID'] . ',';
|
248 |
+
|
249 |
+
$ids_for_action = rtrim($ids_for_action, ',');
|
250 |
+
}
|
251 |
+
else
|
252 |
+
$ids_for_action = $_POST['leadin_selected_contacts'];
|
253 |
+
|
254 |
+
$q = $wpdb->prepare("
|
255 |
+
SELECT
|
256 |
+
l.hashkey, l.lead_id,
|
257 |
+
( SELECT ltr.tag_id FROM $wpdb->li_tag_relationships ltr WHERE ltr.tag_id = %d AND ltr.contact_hashkey = l.hashkey GROUP BY ltr.contact_hashkey ) AS tag_set
|
258 |
+
FROM
|
259 |
+
$wpdb->li_leads l
|
260 |
+
WHERE
|
261 |
+
l.lead_id IN ( " . $ids_for_action . " ) AND l.lead_deleted = 0 GROUP BY l.lead_id", $tag_id);
|
262 |
+
|
263 |
+
$hashes = $wpdb->get_results($q);
|
264 |
|
265 |
+
$insert_values = '';
|
266 |
+
$hashes_to_update = '';
|
267 |
|
268 |
+
if ( count($hashes) )
|
269 |
+
{
|
270 |
+
foreach ( $hashes as $hash )
|
271 |
+
{
|
272 |
+
if ( $hash->tag_set === NULL )
|
273 |
+
$insert_values .= '(' . $tag_id . ', "' . $hash->hashkey . '"),';
|
274 |
+
else
|
275 |
+
$hashes_to_update .= "'" . $hash->hashkey . "',";
|
276 |
}
|
277 |
+
}
|
278 |
+
|
279 |
+
if ( $_POST['bulk_edit_tag_action'] == 'add_tag' )
|
280 |
+
{
|
281 |
+
if ( $insert_values )
|
282 |
{
|
283 |
+
$q = "INSERT INTO $wpdb->li_tag_relationships ( tag_id, contact_hashkey ) VALUES " . rtrim($insert_values, ',');
|
284 |
+
$wpdb->query($q);
|
285 |
+
}
|
286 |
|
287 |
+
if ( $hashes_to_update )
|
288 |
+
{
|
289 |
+
// update the relationships for the contacts that exist already
|
290 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_tag_relationships SET tag_relationship_deleted = 0 WHERE tag_id = %d AND contact_hashkey IN ( " . rtrim($hashes_to_update, ',') . ") ", $tag_id);
|
291 |
+
$wpdb->query($q);
|
292 |
+
}
|
293 |
+
}
|
294 |
+
else
|
295 |
+
{
|
296 |
+
if ( $hashes_to_update )
|
297 |
+
{
|
298 |
+
// Update the existing tags only
|
299 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_tag_relationships SET tag_relationship_deleted = 1 WHERE tag_id = %d AND contact_hashkey IN ( " . rtrim($hashes_to_update, ',') . ") ", $tag_id);
|
300 |
$wpdb->query($q);
|
301 |
}
|
302 |
}
|
312 |
{
|
313 |
/***
|
314 |
== FILTER ARGS ==
|
315 |
+
- filter_action (visited) = visited a specific page url (filter_action)
|
316 |
+
- filter_action (submitted) = submitted a form on specific page url (filter_action)
|
317 |
+
- filter_content = content for filter_action
|
318 |
+
- filter_form = selector id/class
|
319 |
+
- num_pageviews = visited at least #n pages
|
320 |
+
- s = search query on lead_email/lead_source
|
321 |
*/
|
322 |
|
323 |
global $wpdb;
|
324 |
|
325 |
+
$mysql_search_filter = '';
|
326 |
+
$mysql_contact_type_filter = '';
|
327 |
+
$mysql_action_filter = '';
|
328 |
+
$filter_action_set = FALSE;
|
329 |
|
330 |
// search filter
|
331 |
if ( isset($_GET['s']) )
|
333 |
$search_query = $_GET['s'];
|
334 |
$mysql_search_filter = $wpdb->prepare(" AND ( l.lead_email LIKE '%%%s%%' OR l.lead_source LIKE '%%%s%%' ) ", like_escape($search_query), like_escape($search_query));
|
335 |
}
|
336 |
+
|
337 |
+
$filtered_contacts = array();
|
338 |
|
339 |
// contact type filter
|
340 |
if ( isset($_GET['contact_type']) )
|
341 |
{
|
342 |
+
// Query for the tag_id, then find all hashkeys with that tag ID tied to them. Use those hashkeys to modify the query
|
343 |
+
$q = $wpdb->prepare("
|
344 |
+
SELECT
|
345 |
+
DISTINCT ltr.contact_hashkey as lead_hashkey
|
346 |
+
FROM
|
347 |
+
$wpdb->li_tag_relationships ltr, $wpdb->li_tags lt
|
348 |
+
WHERE
|
349 |
+
lt.tag_id = ltr.tag_id AND
|
350 |
+
ltr.tag_relationship_deleted = 0 AND
|
351 |
+
lt.tag_slug = %s GROUP BY ltr.contact_hashkey", $_GET['contact_type']);
|
352 |
+
|
353 |
+
$filtered_contacts = $wpdb->get_results($q, 'ARRAY_A');
|
354 |
+
$num_contacts = count($filtered_contacts);
|
355 |
}
|
356 |
|
|
|
357 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
358 |
{
|
359 |
+
if ( isset($_GET['filter_content']) && $_GET['filter_content'] != 'any page' )
|
|
|
|
|
|
|
360 |
{
|
361 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM $wpdb->li_pageviews WHERE pageview_title LIKE '%%%s%%' GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
362 |
+
$filtered_contacts = leadin_merge_filtered_contacts($wpdb->get_results($q, 'ARRAY_A'), $filtered_contacts);
|
363 |
+
$filter_action_set = TRUE;
|
|
|
|
|
364 |
}
|
365 |
}
|
366 |
|
367 |
// filter for a form submitted on a specific page
|
368 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
369 |
{
|
370 |
+
$filter_form = '';
|
371 |
+
if ( isset($_GET['filter_form']) && $_GET['filter_form'] && $_GET['filter_form'] != 'any form' )
|
|
|
|
|
372 |
{
|
373 |
+
$filter_form = str_replace(array('#', '.'), '', htmlspecialchars(urldecode($_GET['filter_form'])));
|
374 |
+
$filter_form_query = $wpdb->prepare(" AND ( form_selector_id LIKE '%%%s%%' OR form_selector_classes LIKE '%%%s%%' )", $filter_form, $filter_form);
|
|
|
|
|
|
|
375 |
}
|
|
|
376 |
|
377 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM $wpdb->li_submissions WHERE form_page_title LIKE '%%%s%%' ", ( $_GET['filter_content'] != 'any page' ? htmlspecialchars(urldecode($_GET['filter_content'])): '' ));
|
378 |
+
$q .= ( $filter_form_query ? $filter_form_query : '' );
|
379 |
+
$q .= " GROUP BY lead_hashkey";
|
380 |
+
$filtered_contacts = leadin_merge_filtered_contacts($wpdb->get_results($q, 'ARRAY_A'), $filtered_contacts);
|
381 |
+
$filter_action_set = TRUE;
|
382 |
+
}
|
383 |
+
|
384 |
+
$filtered_hashkeys = leadin_explode_filtered_contacts($filtered_contacts);
|
385 |
+
|
386 |
+
$mysql_action_filter = '';
|
387 |
+
if ( $filter_action_set ) // If a filter action is set and there are no contacts, do a blank
|
388 |
+
$mysql_action_filter = " AND l.hashkey IN ( " . ( $filtered_hashkeys ? $filtered_hashkeys : "''" ) . " ) ";
|
389 |
+
else
|
390 |
+
$mysql_action_filter = ( $filtered_hashkeys ? " AND l.hashkey IN ( " . $filtered_hashkeys . " ) " : '' ); // If a filter action isn't set, use the filtered hashkeys if they exist, else, don't include the statement
|
391 |
+
|
392 |
+
// There's a filter and leads are in it
|
393 |
+
if ( ( isset($_GET['contact_type']) && $num_contacts ) || ! isset($_GET['contact_type']) )
|
394 |
{
|
395 |
$q = $wpdb->prepare("
|
396 |
SELECT
|
397 |
l.lead_id AS lead_id,
|
398 |
+
LOWER(DATE_FORMAT(l.lead_date, %s)) AS lead_date, l.lead_ip, l.lead_source, l.lead_email, l.hashkey,
|
399 |
COUNT(DISTINCT s.form_id) AS lead_form_submissions,
|
400 |
COUNT(DISTINCT p.pageview_id) AS lead_pageviews,
|
401 |
LOWER(DATE_FORMAT(MAX(p.pageview_date), %s)) AS last_visit,
|
402 |
+
( SELECT COUNT(DISTINCT pageview_id) FROM $wpdb->li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS visits,
|
403 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM $wpdb->li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS pageview_source
|
404 |
FROM
|
405 |
+
$wpdb->li_leads l
|
406 |
+
LEFT JOIN $wpdb->li_submissions s ON l.hashkey = s.lead_hashkey
|
407 |
+
LEFT JOIN $wpdb->li_pageviews p ON l.hashkey = p.lead_hashkey
|
408 |
+
WHERE l.lead_email != '' AND l.lead_deleted = 0 AND l.hashkey != '' ", '%Y/%m/%d %l:%i%p', '%Y/%m/%d %l:%i%p');
|
409 |
|
410 |
$q .= $mysql_contact_type_filter;
|
411 |
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
412 |
+
$q .= ( $mysql_action_filter ? $mysql_action_filter : "" );
|
413 |
+
$q .= " GROUP BY l.hashkey";
|
|
|
414 |
$leads = $wpdb->get_results($q);
|
415 |
}
|
416 |
else
|
426 |
{
|
427 |
foreach ( $leads as $key => $lead )
|
428 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
// filter for number of page views and skipping lead if it doesn't meet the minimum
|
430 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'num_pageviews' )
|
431 |
{
|
439 |
'ID' => $lead->lead_id,
|
440 |
'hashkey' => $lead->hashkey,
|
441 |
'email' => sprintf('<a href="?page=%s&action=%s&lead=%s">' . "<img class='pull-left leadin-contact-avatar leadin-dynamic-avatar_" . substr($lead->lead_id, -1) . "' src='https://app.getsignals.com/avatar/image/?emails=" . $lead->lead_email . "' width='35' height='35'/> " . '</a>', $_REQUEST['page'], 'view', $lead->lead_id) . sprintf('<a href="?page=%s&action=%s&lead=%s"><b>' . $lead->lead_email . '</b></a>', $_REQUEST['page'], 'view', $lead->lead_id),
|
|
|
442 |
'visits' => ( !isset($lead->visits) ? 1 : $lead->visits ),
|
443 |
'submissions' => $lead->lead_form_submissions,
|
444 |
'pageviews' => $lead->lead_pageviews,
|
461 |
/**
|
462 |
* Gets the total number of contacts, comments and subscribers for above the table
|
463 |
*/
|
464 |
+
function get_total_contacts ()
|
465 |
{
|
466 |
global $wpdb;
|
467 |
+
|
468 |
$q = "
|
469 |
SELECT
|
470 |
+
COUNT(DISTINCT hashkey) AS total_contacts
|
|
|
|
|
|
|
|
|
|
|
471 |
FROM
|
472 |
+
$wpdb->li_leads
|
473 |
WHERE
|
474 |
+
lead_email != '' AND lead_deleted = 0 AND hashkey != '' ";
|
475 |
|
476 |
+
$total_contacts = $wpdb->get_var($q);
|
477 |
+
return $total_contacts;
|
478 |
}
|
479 |
|
480 |
/**
|
505 |
}
|
506 |
|
507 |
/**
|
508 |
+
* Get the contact tags
|
509 |
*
|
510 |
* @return string
|
511 |
*/
|
512 |
+
function get_tags ()
|
513 |
{
|
514 |
+
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
|
516 |
+
$q = $wpdb->prepare("
|
517 |
+
SELECT
|
518 |
+
lt.tag_text, lt.tag_slug, lt.tag_synced_lists, lt.tag_form_selectors, lt.tag_order, lt.tag_id,
|
519 |
+
( SELECT COUNT(DISTINCT contact_hashkey) FROM $wpdb->li_tag_relationships, $wpdb->li_leads WHERE tag_id = lt.tag_id AND tag_relationship_deleted = 0 AND contact_hashkey != '' AND $wpdb->li_leads.hashkey = $wpdb->li_tag_relationships.contact_hashkey GROUP BY tag_id ) AS tag_count
|
520 |
+
FROM
|
521 |
+
$wpdb->li_tags lt
|
522 |
+
WHERE
|
523 |
+
lt.tag_deleted = 0
|
524 |
+
ORDER BY lt.tag_order ASC", "");
|
525 |
|
526 |
+
return $wpdb->get_results($q);
|
527 |
}
|
528 |
|
529 |
/**
|
531 |
*/
|
532 |
function views ()
|
533 |
{
|
534 |
+
$this->tags = stripslashes_deep($this->get_tags());
|
535 |
+
$current = ( !empty($_GET['contact_type']) ? html_entity_decode($_GET['contact_type']) : 'all' );
|
536 |
+
$all_params = array( 'contact_type', 's', 'paged', '_wpnonce', '_wpreferrer', '_wp_http_referer', 'action', 'action2', 'filter_form', 'filter_action', 'filter_content', 'contact');
|
537 |
+
$all_url = remove_query_arg($all_params);
|
538 |
+
$this->total_contacts = $this->get_total_contacts();
|
539 |
|
540 |
+
echo "<ul class='leadin-contacts__type-picker'>";
|
541 |
+
echo "<li><a href='$all_url' class='" . ( $current == 'all' ? 'current' :'' ) . "'><span class='icon-user'></span>" . $this->total_contacts . " Total</a></li>";
|
542 |
+
echo "</ul>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
|
544 |
+
if ( $current == "all" ) {
|
545 |
+
$this->view_label = "Contacts";
|
546 |
+
$this->view_count = $this->total_contacts;
|
|
|
547 |
}
|
548 |
|
549 |
+
if ( empty( $this->tags ) ) {
|
550 |
+
echo "<h3 class='leadin-contacts__tags-header'>No Tags</h3>";
|
551 |
+
}
|
552 |
+
else {
|
553 |
+
echo "<h3 class='leadin-contacts__tags-header'>Tags</h3>";
|
554 |
+
}
|
555 |
|
556 |
+
echo "<ul class='leadin-contacts__type-picker'>";
|
557 |
+
foreach ( $this->tags as $tag ) {
|
558 |
+
|
559 |
+
if ( $current == $tag->tag_slug ) {
|
560 |
+
$currentTag = true;
|
561 |
+
$this->view_label = $tag->tag_text;
|
562 |
+
$this->view_count = $tag->tag_count;
|
563 |
+
} else {
|
564 |
+
$currentTag = false;
|
565 |
+
}
|
566 |
+
|
567 |
+
echo "<li><a href='" . $all_url . "&contact_type=" . $tag->tag_slug . "' class='" . ( $currentTag ? 'current' :'' ) . "''><span class='icon-tag'></span>" . ( $tag->tag_count ? $tag->tag_count : '0' ) . " " . $tag->tag_text . "</a></li>";
|
568 |
}
|
|
|
569 |
echo "</ul>";
|
570 |
+
|
571 |
+
echo "<a href='" . get_bloginfo('wpurl') . "/wp-admin/admin.php?page=leadin_contacts&action=manage_tags" . "' class='button'>Manage tags</a>";
|
572 |
}
|
573 |
|
574 |
|
581 |
|
582 |
?>
|
583 |
<form id="leadin-contacts-filter" class="leadin-contacts__filter" method="GET">
|
584 |
+
|
585 |
<h3 class="leadin-contacts__filter-text">
|
586 |
+
|
587 |
+
<span class="leadin-contacts__filter-count"><?php echo ( $this->total_filtered != $this->view_count ? '<span id="contact-count">' . $this->total_filtered . '</span>' . '/' : '' ) . '<span id="contact-count">' . ( $this->view_count ? $this->view_count : '0' ) . '</span>' . ' ' . strtolower($this->view_label); ?></span> who
|
588 |
+
|
589 |
+
<select class="select2" name="filter_action" id="filter_action" style="width:125px">
|
590 |
+
<option value="visited" <?php echo ( $filters['action']=='visited' ? 'selected' : '' ) ?> >viewed</option>
|
591 |
+
<option value="submitted" <?php echo ( $filters['action']=='submitted' ? 'selected' : '' ) ?> >submitted</option>
|
592 |
</select>
|
593 |
|
594 |
+
<span id="form-filter-input" <?php echo ( ! isset($_GET['filter_form']) || ( isset($_GET['filter_action']) && $_GET['filter_action'] != 'submitted' ) ? 'style="display: none;"' : ''); ?>>
|
595 |
+
<input type="hidden" name="filter_form" class="bigdrop" id="filter_form" style="width:250px" value="<?php echo ( isset($_GET['filter_form']) ? stripslashes($_GET['filter_form']) : '' ); ?>"/> on
|
596 |
+
</span>
|
597 |
+
|
598 |
+
<input type="hidden" name="filter_content" class="bigdrop" id="filter_content" style="width:250px" value="<?php echo ( isset($_GET['filter_content']) ? stripslashes($_GET['filter_content']) : '' ); ?>"/>
|
599 |
|
600 |
<input type="submit" name="" id="leadin-contacts-filter-button" class="button action" value="Apply">
|
601 |
|
602 |
<?php if ( isset($_GET['filter_action']) || isset($_GET['filter_content']) ) : ?>
|
603 |
<a href="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts' . ( isset($_GET['contact_type']) ? '&contact_type=' . $_GET['contact_type'] : '' ); ?>" id="clear-filter">clear filter</a>
|
604 |
<?php endif; ?>
|
605 |
+
|
606 |
</h3>
|
607 |
|
608 |
<?php if ( isset($_GET['contact_type']) ) : ?>
|
645 |
) );
|
646 |
}
|
647 |
|
648 |
+
/**
|
649 |
+
* Sorting function for usort
|
650 |
+
*
|
651 |
+
* @param array
|
652 |
+
* @param array
|
653 |
+
* @return array sorted array
|
654 |
+
*/
|
655 |
function usort_reorder ( $a, $b )
|
656 |
{
|
657 |
$orderby = ( !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'last_visit' );
|
666 |
|
667 |
return ( $order === 'asc' ? $result : -$result );
|
668 |
}
|
|
|
669 |
}
|
admin/inc/class-leadin-tag-editor.php
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//=============================================
|
3 |
+
// LI_Contact Class
|
4 |
+
//=============================================
|
5 |
+
class LI_Tag_Editor {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Variables
|
9 |
+
*/
|
10 |
+
var $tag_id;
|
11 |
+
var $details;
|
12 |
+
var $selectors;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Class constructor
|
16 |
+
*/
|
17 |
+
function __construct ( $tag_id )
|
18 |
+
{
|
19 |
+
if ( $tag_id )
|
20 |
+
$this->tag_id = $tag_id;
|
21 |
+
|
22 |
+
$this->selectors = $this->get_form_selectors();
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Get all the details for a tag
|
27 |
+
*
|
28 |
+
* @param int
|
29 |
+
* @return object
|
30 |
+
*/
|
31 |
+
function get_tag_details ( $tag_id )
|
32 |
+
{
|
33 |
+
global $wpdb;
|
34 |
+
|
35 |
+
$q = $wpdb->prepare("SELECT * FROM $wpdb->li_tags WHERE tag_id = %d", $this->tag_id);
|
36 |
+
$this->details = $wpdb->get_row($q);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Get all the existing form selectors sorted by frequency
|
41 |
+
*
|
42 |
+
* @return array
|
43 |
+
*/
|
44 |
+
function get_form_selectors ( )
|
45 |
+
{
|
46 |
+
global $wpdb;
|
47 |
+
$selectors = array();
|
48 |
+
|
49 |
+
$q = "SELECT COUNT(form_selector_classes) AS freq, form_selector_classes FROM $wpdb->li_submissions WHERE form_selector_classes != '' GROUP BY form_selector_classes ORDER BY freq DESC";
|
50 |
+
$classes = $wpdb->get_results($q);
|
51 |
+
|
52 |
+
if ( count($classes) )
|
53 |
+
{
|
54 |
+
foreach ( $classes as $class )
|
55 |
+
{
|
56 |
+
foreach ( explode(',', $class->form_selector_classes) as $class_selector )
|
57 |
+
{
|
58 |
+
if ( ! in_array($class_selector, $selectors) && $class_selector )
|
59 |
+
array_push($selectors, '.' . $class_selector);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
$q = "SELECT COUNT(form_selector_id) AS freq, form_selector_id FROM $wpdb->li_submissions WHERE form_selector_id != '' GROUP BY form_selector_id ORDER BY freq DESC";
|
65 |
+
$ids = $wpdb->get_results($q);
|
66 |
+
|
67 |
+
if ( count($ids) )
|
68 |
+
{
|
69 |
+
foreach ( $ids as $id )
|
70 |
+
{
|
71 |
+
if ( ! in_array($id->form_selector_id, $selectors) && $id->form_selector_id )
|
72 |
+
array_push($selectors, '#' . $id->form_selector_id);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
return $selectors;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Add a new tag in the li_tags table
|
81 |
+
*
|
82 |
+
* @param string
|
83 |
+
* @param string
|
84 |
+
* @param string
|
85 |
+
* @return int tag_id of last inserted tag
|
86 |
+
*/
|
87 |
+
function add_tag ( $tag_text, $tag_form_selectors, $tag_synced_lists )
|
88 |
+
{
|
89 |
+
global $wpdb;
|
90 |
+
|
91 |
+
$q = $wpdb->prepare("SELECT MAX(tag_order) FROM $wpdb->li_tags", "");
|
92 |
+
$tag_order = $wpdb->get_var($q);
|
93 |
+
$tag_order = ( $tag_order ? $tag_order + 1 : 1 );
|
94 |
+
$tag_slug = $this->generate_slug($tag_text);
|
95 |
+
|
96 |
+
$q = $wpdb->prepare("
|
97 |
+
INSERT INTO $wpdb->li_tags ( tag_text, tag_slug, tag_form_selectors, tag_synced_lists, tag_order )
|
98 |
+
VALUES ( %s, %s, %s, %s, %d )", $tag_text, $tag_slug, $tag_form_selectors, $tag_synced_lists, $tag_order);
|
99 |
+
$wpdb->query($q);
|
100 |
+
|
101 |
+
return $wpdb->insert_id;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Update an existing tag in the li_tags table
|
106 |
+
*
|
107 |
+
* @param int
|
108 |
+
* @param string
|
109 |
+
* @param string
|
110 |
+
* @param string serialized array(array('esp' => 'mailchimp', 'list_id' => 'abc123'))
|
111 |
+
* @return bool
|
112 |
+
*/
|
113 |
+
function save_tag ( $tag_id, $tag_text, $tag_form_selectors, $tag_synced_lists )
|
114 |
+
{
|
115 |
+
global $wpdb;
|
116 |
+
|
117 |
+
$tag_slug = $this->generate_slug($tag_text, $tag_id);
|
118 |
+
|
119 |
+
$q = $wpdb->prepare("
|
120 |
+
UPDATE $wpdb->li_tags
|
121 |
+
SET tag_text = %s, tag_slug = %s, tag_form_selectors = %s, tag_synced_lists = %s
|
122 |
+
WHERE tag_id = %d", $tag_text, $tag_slug, $tag_form_selectors, $tag_synced_lists, $tag_id);
|
123 |
+
$result = $wpdb->query($q);
|
124 |
+
|
125 |
+
return $result;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Delete a tag from the li_tags table
|
130 |
+
*
|
131 |
+
* @param int
|
132 |
+
* @param string
|
133 |
+
* @return bool
|
134 |
+
*/
|
135 |
+
function delete_tag ( $tag_id )
|
136 |
+
{
|
137 |
+
global $wpdb;
|
138 |
+
|
139 |
+
$q = $wpdb->prepare("
|
140 |
+
UPDATE $wpdb->li_tags
|
141 |
+
SET tag_deleted = 1
|
142 |
+
WHERE tag_id = %d", $tag_id);
|
143 |
+
|
144 |
+
$result = $wpdb->query($q);
|
145 |
+
|
146 |
+
return $result;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Generates a slug based off a string. If slug exists, then appends -N until the slug is free
|
151 |
+
*
|
152 |
+
* @param string
|
153 |
+
* @return string
|
154 |
+
*/
|
155 |
+
function generate_slug ( $tag_text, $tag_id = FALSE )
|
156 |
+
{
|
157 |
+
global $wpdb;
|
158 |
+
|
159 |
+
$tag_slug = sanitize_title($tag_text);
|
160 |
+
$slug_used = TRUE;
|
161 |
+
$slug_int_check = 0;
|
162 |
+
|
163 |
+
while ( $slug_used )
|
164 |
+
{
|
165 |
+
// slug_int_check is set to 1, but we only want to use it if the slug exists, so kill it in the first iteration
|
166 |
+
|
167 |
+
if ( $slug_int_check )
|
168 |
+
$tag_slug_modified = $tag_slug . '-' . $slug_int_check;
|
169 |
+
else
|
170 |
+
$tag_slug_modified = $tag_slug;
|
171 |
+
|
172 |
+
$q = $wpdb->prepare("SELECT tag_slug FROM $wpdb->li_tags WHERE tag_slug = %s " . ( $tag_id ? $wpdb->prepare(" AND tag_id != %d ", $tag_id) : '' ), $tag_slug_modified);
|
173 |
+
$slug_used = $wpdb->get_var($q);
|
174 |
+
|
175 |
+
if ( $slug_used )
|
176 |
+
$slug_int_check++;
|
177 |
+
else
|
178 |
+
$tag_slug = $tag_slug_modified;
|
179 |
+
}
|
180 |
+
|
181 |
+
return $tag_slug;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
?>
|
admin/inc/class-leadin-tags-list-table.php
ADDED
@@ -0,0 +1,249 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//=============================================
|
4 |
+
// Include Needed Files
|
5 |
+
//=============================================
|
6 |
+
|
7 |
+
if ( !class_exists('WP_List_Table') )
|
8 |
+
require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
|
9 |
+
|
10 |
+
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-functions.php');
|
11 |
+
|
12 |
+
//=============================================
|
13 |
+
// LI_List_Table Class
|
14 |
+
//=============================================
|
15 |
+
class LI_Tags_Table extends WP_List_Table {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Variables
|
19 |
+
*/
|
20 |
+
public $data = array();
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Class constructor
|
24 |
+
*/
|
25 |
+
function __construct ()
|
26 |
+
{
|
27 |
+
global $status, $page;
|
28 |
+
|
29 |
+
//Set parent defaults
|
30 |
+
parent::__construct( array(
|
31 |
+
'singular' => 'tag',
|
32 |
+
'plural' => 'tags',
|
33 |
+
'ajax' => false
|
34 |
+
));
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Prints text for no rows found in table
|
39 |
+
*/
|
40 |
+
function no_items ()
|
41 |
+
{
|
42 |
+
_e('No tags found.');
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Prints values for columns for which no column function has been defined
|
47 |
+
*
|
48 |
+
* @param object
|
49 |
+
* @param string
|
50 |
+
* @return * item value's type
|
51 |
+
*/
|
52 |
+
function column_default ( $item, $column_name )
|
53 |
+
{
|
54 |
+
switch ( $column_name )
|
55 |
+
{
|
56 |
+
//case 'tag_order':
|
57 |
+
//return $item[$column_name];
|
58 |
+
case 'tag_text':
|
59 |
+
return $item[$column_name];
|
60 |
+
case 'tag_count':
|
61 |
+
return $item[$column_name];
|
62 |
+
case 'tag_form_selectors':
|
63 |
+
return $item[$column_name];
|
64 |
+
case 'tag_synced_lists':
|
65 |
+
return $item[$column_name];
|
66 |
+
|
67 |
+
case 'reorder' :
|
68 |
+
return '<span class="icon-mover"></span>';
|
69 |
+
|
70 |
+
default:
|
71 |
+
return print_r($item,true);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Prints text for email column
|
77 |
+
*
|
78 |
+
* @param object
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
function column_tag_text ( $item )
|
82 |
+
{
|
83 |
+
//Build row actions
|
84 |
+
$actions = array(
|
85 |
+
'edit' => sprintf('<div style="clear:both;"></div><a href="?page=%s&action=%s&tag=%s">Edit</a>', $_REQUEST['page'], 'edit_tag',$item['tag_id']),
|
86 |
+
'delete' => sprintf('<a href="?page=%s&action=%s&tag=%s">Delete</a>',$_REQUEST['page'],'delete_tag',$item['tag_id'])
|
87 |
+
);
|
88 |
+
|
89 |
+
//Return the title contents
|
90 |
+
return sprintf('%1$s<br/>%2$s',
|
91 |
+
/*$1%s*/ sprintf('<a class="row-title" href="?page=%s&action=edit_tag&tag=%s">%s</a>', $_REQUEST['page'], $item['tag_id'], $item['tag_text']),
|
92 |
+
/*$2%s*/ $this->row_actions($actions)
|
93 |
+
);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Get all the columns for the list table
|
98 |
+
*
|
99 |
+
* @param object
|
100 |
+
* @param string
|
101 |
+
* @return array associative array of columns
|
102 |
+
*/
|
103 |
+
function get_columns ()
|
104 |
+
{
|
105 |
+
$columns = array(
|
106 |
+
'tag_text' => 'Tag',
|
107 |
+
'tag_count' => 'Contacts',
|
108 |
+
'tag_form_selectors' => 'CSS Selectors',
|
109 |
+
'tag_synced_lists' => 'Synced lists'
|
110 |
+
);
|
111 |
+
return $columns;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Defines sortable columns for table
|
116 |
+
*
|
117 |
+
* @param object
|
118 |
+
* @param string
|
119 |
+
* @return array associative array of columns
|
120 |
+
*/
|
121 |
+
function get_sortable_columns ()
|
122 |
+
{
|
123 |
+
$sortable_columns = array(
|
124 |
+
'tag_text' => array('tag_text',false),
|
125 |
+
'tag_count' => array('tag_count',false),
|
126 |
+
'tag_form_selectors' => array('tag_form_selectors',false),
|
127 |
+
'tag_synced_lists' => array('tag_synced_lists',false)
|
128 |
+
);
|
129 |
+
return $sortable_columns;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Get the bulk actions
|
134 |
+
*
|
135 |
+
* @return array associative array of actions
|
136 |
+
*/
|
137 |
+
function get_bulk_actions ()
|
138 |
+
{
|
139 |
+
return array();
|
140 |
+
}
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Process bulk actions for deleting
|
144 |
+
*/
|
145 |
+
function process_bulk_action ()
|
146 |
+
{
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Get the contact tags
|
152 |
+
*
|
153 |
+
* @return string
|
154 |
+
*/
|
155 |
+
function get_tags ()
|
156 |
+
{
|
157 |
+
global $wpdb;
|
158 |
+
|
159 |
+
$q = $wpdb->prepare("
|
160 |
+
SELECT
|
161 |
+
lt.tag_text, lt.tag_slug, lt.tag_synced_lists, lt.tag_form_selectors, lt.tag_order, lt.tag_id,
|
162 |
+
( SELECT COUNT(DISTINCT contact_hashkey) FROM $wpdb->li_tag_relationships ltr, $wpdb->li_leads ll WHERE tag_id = lt.tag_id AND ltr.tag_relationship_deleted = 0 AND ltr.contact_hashkey != '' AND ll.hashkey = ltr.contact_hashkey AND ll.lead_deleted = 0 GROUP BY tag_id ) AS tag_count
|
163 |
+
FROM
|
164 |
+
$wpdb->li_tags lt
|
165 |
+
WHERE
|
166 |
+
lt.tag_deleted = 0
|
167 |
+
ORDER BY lt.tag_order ASC", "");
|
168 |
+
|
169 |
+
$tags = $wpdb->get_results($q);
|
170 |
+
|
171 |
+
$all_tags = array();
|
172 |
+
if ( count($tags) )
|
173 |
+
{
|
174 |
+
foreach ( $tags as $key => $tag )
|
175 |
+
{
|
176 |
+
$tag_synced_lists = '';
|
177 |
+
if ( $tag->tag_synced_lists )
|
178 |
+
{
|
179 |
+
foreach ( unserialize($tag->tag_synced_lists) as $list )
|
180 |
+
$tag_synced_lists .= $list['list_name'] . '<br/>';
|
181 |
+
}
|
182 |
+
|
183 |
+
$tag_array = array(
|
184 |
+
'tag_id' => $tag->tag_id,
|
185 |
+
'tag_count' => sprintf('<a href="?page=%s&contact_type=%s">%d</a>', $_REQUEST['page'], $tag->tag_slug, ( $tag->tag_count ? $tag->tag_count : 0 )),
|
186 |
+
'tag_text' => $tag->tag_text,
|
187 |
+
'tag_slug' => $tag->tag_slug,
|
188 |
+
'tag_form_selectors' => str_replace(',', '<br/>', $tag->tag_form_selectors),
|
189 |
+
'tag_synced_lists' => $tag_synced_lists,
|
190 |
+
'tag_order' => $tag->tag_order
|
191 |
+
);
|
192 |
+
|
193 |
+
array_push($all_tags, $tag_array);
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
return stripslashes_deep($all_tags);
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Gets + prepares the contacts for the list table
|
202 |
+
*/
|
203 |
+
function prepare_items ()
|
204 |
+
{
|
205 |
+
$per_page = 10;
|
206 |
+
|
207 |
+
$columns = $this->get_columns();
|
208 |
+
|
209 |
+
$hidden = array();
|
210 |
+
$sortable = $this->get_sortable_columns();
|
211 |
+
$this->_column_headers = array($columns, $hidden, $sortable);
|
212 |
+
|
213 |
+
usort($this->data, array($this, 'usort_reorder'));
|
214 |
+
|
215 |
+
$current_page = $this->get_pagenum();
|
216 |
+
$total_items = count($this->data);
|
217 |
+
$this->data = array_slice($this->data, (($current_page-1)*$per_page), $per_page);
|
218 |
+
|
219 |
+
$this->items = $this->data;
|
220 |
+
|
221 |
+
$this->set_pagination_args( array(
|
222 |
+
'total_items' => $total_items,
|
223 |
+
'per_page' => $per_page,
|
224 |
+
'total_pages' => ceil($total_items/$per_page)
|
225 |
+
) );
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Sorting function for usort
|
230 |
+
*
|
231 |
+
* @param array
|
232 |
+
* @param array
|
233 |
+
* @return array sorted array
|
234 |
+
*/
|
235 |
+
function usort_reorder ( $a, $b )
|
236 |
+
{
|
237 |
+
$orderby = ( !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : 'tag_order' );
|
238 |
+
$order = ( !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc' );
|
239 |
+
|
240 |
+
if ( $a[$orderby] == $b[$orderby] )
|
241 |
+
$result = 0;
|
242 |
+
else if ( $a[$orderby] < $b[$orderby] )
|
243 |
+
$result = -1;
|
244 |
+
else
|
245 |
+
$result = 1;
|
246 |
+
|
247 |
+
return ( $order === 'asc' ? $result : -$result );
|
248 |
+
}
|
249 |
+
}
|
admin/inc/class-leadin-viewers.php
CHANGED
@@ -28,16 +28,16 @@ class LI_Viewers {
|
|
28 |
global $wpdb;
|
29 |
$q = $wpdb->prepare(
|
30 |
"SELECT
|
31 |
-
|
32 |
FROM
|
33 |
-
li_leads, li_pageviews
|
34 |
WHERE
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
ORDER BY
|
42 |
pageview_date DESC", $pageview_url);
|
43 |
$this->viewers = $wpdb->get_results($q);
|
@@ -54,16 +54,16 @@ class LI_Viewers {
|
|
54 |
global $wpdb;
|
55 |
$q = $wpdb->prepare(
|
56 |
"SELECT
|
57 |
-
|
58 |
FROM
|
59 |
-
li_leads, li_submissions
|
60 |
WHERE
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
ORDER BY
|
68 |
form_date DESC", $pageview_url);
|
69 |
$this->submissions = $wpdb->get_results($q);
|
28 |
global $wpdb;
|
29 |
$q = $wpdb->prepare(
|
30 |
"SELECT
|
31 |
+
ll.lead_email, ll.lead_id, MAX(lpv.pageview_date) AS pageview_date
|
32 |
FROM
|
33 |
+
$wpdb->li_leads ll, $wpdb->li_pageviews lpv
|
34 |
WHERE
|
35 |
+
lpv.pageview_url = %s AND
|
36 |
+
lpv.lead_hashkey = ll.hashkey AND
|
37 |
+
ll.lead_deleted = 0 AND
|
38 |
+
ll.lead_email != ''
|
39 |
+
GROUP BY
|
40 |
+
ll.lead_id
|
41 |
ORDER BY
|
42 |
pageview_date DESC", $pageview_url);
|
43 |
$this->viewers = $wpdb->get_results($q);
|
54 |
global $wpdb;
|
55 |
$q = $wpdb->prepare(
|
56 |
"SELECT
|
57 |
+
ll.lead_email, ll.lead_id, MAX(ls.form_date) AS form_date
|
58 |
FROM
|
59 |
+
$wpdb->li_leads ll, $wpdb->li_submissions ls
|
60 |
WHERE
|
61 |
+
ls.form_page_url = %s AND
|
62 |
+
ls.lead_hashkey = ll.hashkey AND
|
63 |
+
ll.lead_deleted = 0 AND
|
64 |
+
ls.form_deleted = 0
|
65 |
+
GROUP BY
|
66 |
+
ll.lead_id
|
67 |
ORDER BY
|
68 |
form_date DESC", $pageview_url);
|
69 |
$this->submissions = $wpdb->get_results($q);
|
admin/inc/class-stats-dashboard.php
CHANGED
@@ -65,7 +65,7 @@ class LI_StatsDashboard {
|
|
65 |
function get_data_last_30_days_graph ()
|
66 |
{
|
67 |
global $wpdb;
|
68 |
-
$q = "SELECT DATE(lead_date) as lead_date, COUNT(DISTINCT hashkey) contacts FROM li_leads WHERE lead_email != ''
|
69 |
$contacts = $wpdb->get_results($q);
|
70 |
|
71 |
for ( $i = count($contacts)-1; $i >= 0; $i-- )
|
@@ -120,14 +120,14 @@ class LI_StatsDashboard {
|
|
120 |
DISTINCT lead_hashkey lh,
|
121 |
lead_id,
|
122 |
lead_email,
|
123 |
-
( SELECT COUNT(*) FROM li_pageviews WHERE lead_hashkey = lh
|
124 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0
|
125 |
FROM
|
126 |
-
li_leads, li_pageviews
|
127 |
WHERE
|
128 |
pageview_date >= CURRENT_DATE() AND
|
129 |
-
|
130 |
-
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0 "
|
131 |
|
132 |
return $wpdb->get_results($q);
|
133 |
}
|
@@ -140,14 +140,14 @@ class LI_StatsDashboard {
|
|
140 |
SELECT DISTINCT lead_hashkey lh,
|
141 |
lead_id,
|
142 |
lead_email,
|
143 |
-
( SELECT COUNT(*) FROM li_pageviews WHERE lead_hashkey = lh ) as pageviews,
|
144 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS lead_source
|
145 |
FROM
|
146 |
-
li_leads, li_pageviews
|
147 |
WHERE
|
148 |
lead_date >= CURRENT_DATE() AND
|
149 |
-
|
150 |
-
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0 "
|
151 |
|
152 |
return $wpdb->get_results($q);
|
153 |
}
|
@@ -157,11 +157,11 @@ class LI_StatsDashboard {
|
|
157 |
global $wpdb;
|
158 |
|
159 |
$q = "SELECT hashkey lh,
|
160 |
-
( SELECT MAX(pageview_source) AS pageview_source FROM li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0
|
161 |
FROM
|
162 |
-
li_leads
|
163 |
WHERE
|
164 |
-
lead_date BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE() AND lead_email != ''
|
165 |
|
166 |
$contacts = $wpdb->get_results($q);
|
167 |
|
65 |
function get_data_last_30_days_graph ()
|
66 |
{
|
67 |
global $wpdb;
|
68 |
+
$q = "SELECT DATE(lead_date) as lead_date, COUNT(DISTINCT hashkey) contacts FROM $wpdb->li_leads WHERE lead_email != '' GROUP BY DATE(lead_date)";
|
69 |
$contacts = $wpdb->get_results($q);
|
70 |
|
71 |
for ( $i = count($contacts)-1; $i >= 0; $i-- )
|
120 |
DISTINCT lead_hashkey lh,
|
121 |
lead_id,
|
122 |
lead_email,
|
123 |
+
( SELECT COUNT(*) FROM $wpdb->li_pageviews WHERE lead_hashkey = lh ) as pageviews,
|
124 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM $wpdb->li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS lead_source
|
125 |
FROM
|
126 |
+
$wpdb->li_leads ll, $wpdb->li_pageviews lpv
|
127 |
WHERE
|
128 |
pageview_date >= CURRENT_DATE() AND
|
129 |
+
ll.hashkey = lpv.lead_hashkey AND
|
130 |
+
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0 ";
|
131 |
|
132 |
return $wpdb->get_results($q);
|
133 |
}
|
140 |
SELECT DISTINCT lead_hashkey lh,
|
141 |
lead_id,
|
142 |
lead_email,
|
143 |
+
( SELECT COUNT(*) FROM $wpdb->li_pageviews WHERE lead_hashkey = lh ) as pageviews,
|
144 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM $wpdb->li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS lead_source
|
145 |
FROM
|
146 |
+
$wpdb->li_leads ll, li_pageviews lpv
|
147 |
WHERE
|
148 |
lead_date >= CURRENT_DATE() AND
|
149 |
+
ll.hashkey = lpv.lead_hashkey AND
|
150 |
+
pageview_deleted = 0 AND lead_email != '' AND lead_deleted = 0 ";
|
151 |
|
152 |
return $wpdb->get_results($q);
|
153 |
}
|
157 |
global $wpdb;
|
158 |
|
159 |
$q = "SELECT hashkey lh,
|
160 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM $wpdb->li_pageviews WHERE lead_hashkey = lh AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS lead_source
|
161 |
FROM
|
162 |
+
$wpdb->li_leads
|
163 |
WHERE
|
164 |
+
lead_date BETWEEN CURDATE() - INTERVAL 30 DAY AND CURDATE() AND lead_email != ''";
|
165 |
|
166 |
$contacts = $wpdb->get_results($q);
|
167 |
|
admin/leadin-admin.php
CHANGED
@@ -32,6 +32,12 @@ if ( !class_exists('LI_Viewers') )
|
|
32 |
if ( !class_exists('LI_StatsDashboard') )
|
33 |
require_once LEADIN_PLUGIN_DIR . '/admin/inc/class-stats-dashboard.php';
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
36 |
|
37 |
//=============================================
|
@@ -67,6 +73,8 @@ class WPLeadInAdmin {
|
|
67 |
add_action('admin_footer', array($this, 'build_contacts_chart'));
|
68 |
}
|
69 |
}
|
|
|
|
|
70 |
}
|
71 |
|
72 |
//=============================================
|
@@ -83,7 +91,7 @@ class WPLeadInAdmin {
|
|
83 |
|
84 |
self::check_admin_action();
|
85 |
|
86 |
-
add_menu_page('LeadIn', 'LeadIn', 'manage_categories', 'leadin_stats', array($this, 'leadin_build_stats_page'), LEADIN_PATH . '/images/' . ( $wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? 'leadin-icon-32x32.png' : 'leadin-svg-icon.svg'));
|
87 |
|
88 |
foreach ( $this->admin_power_ups as $power_up )
|
89 |
{
|
@@ -92,7 +100,6 @@ class WPLeadInAdmin {
|
|
92 |
$power_up->admin_init();
|
93 |
|
94 |
// Creates the menu icon for power-up if it's set. Overrides the main LeadIn menu to hit the contacts power-up
|
95 |
-
//if ( $power_up->menu_text == 'Contacts' )
|
96 |
if ( $power_up->menu_text )
|
97 |
add_submenu_page('leadin_stats', $power_up->menu_text, $power_up->menu_text, 'manage_categories', 'leadin_' . $power_up->menu_link, array($power_up, 'power_up_setup_callback'));
|
98 |
}
|
@@ -234,8 +241,6 @@ class WPLeadInAdmin {
|
|
234 |
else
|
235 |
$new_contacts_postbox .= '<i>No new contacts today...</i>';
|
236 |
|
237 |
-
|
238 |
-
|
239 |
return $new_contacts_postbox;
|
240 |
}
|
241 |
|
@@ -593,8 +598,10 @@ class WPLeadInAdmin {
|
|
593 |
<?php if ( $power_up_count == 1 ) : ?>
|
594 |
<!-- static content stats power-up - not a real powerup and this is a hack to put it second in the order -->
|
595 |
<li class="powerup activated">
|
|
|
|
|
|
|
596 |
<h2>Content Stats</h2>
|
597 |
-
<img src="<?php echo LEADIN_PATH; ?>/images/powerup-icon-analytics@2x.png" height="80px" width="80px">
|
598 |
<p>See where all your conversions are coming from.</p>
|
599 |
<p><a href="http://leadin.com/content-analytics-plugin-wordpress/" target="_blank">Learn more</a></p>
|
600 |
<a href="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_stats'; ?>" class="button button-large">View Stats</a>
|
@@ -603,12 +610,14 @@ class WPLeadInAdmin {
|
|
603 |
<?php endif; ?>
|
604 |
|
605 |
<li class="powerup <?php echo ( $power_up->activated ? 'activated' : ''); ?>">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
606 |
<h2><?php echo $power_up->power_up_name; ?></h2>
|
607 |
-
<?php if ( strstr($power_up->icon, 'dashicons') ) : ?>
|
608 |
-
<div class="power-up-icon dashicons <?php echo $power_up->icon; ?>"></div>
|
609 |
-
<?php else : ?>
|
610 |
-
<img src="<?php echo LEADIN_PATH . '/images/' . $power_up->icon . '@2x.png'; ?>" height="80px" width="80px"/>
|
611 |
-
<?php endif; ?>
|
612 |
<p><?php echo $power_up->description; ?></p>
|
613 |
<p><a href="<?php echo $power_up->link_uri; ?>" target="_blank">Learn more</a></p>
|
614 |
<?php if ( $power_up->activated ) : ?>
|
@@ -632,16 +641,20 @@ class WPLeadInAdmin {
|
|
632 |
<?php endforeach; ?>
|
633 |
|
634 |
<li class="powerup">
|
|
|
|
|
|
|
635 |
<h2>Your Idea</h2>
|
636 |
-
<img src="<?php echo LEADIN_PATH; ?>/images/powerup-icon-ideas@2x.png" height="80px" width="80px">
|
637 |
<p>Have an idea for a power-up? We'd love to hear it!</p>
|
638 |
<p> </p>
|
639 |
-
<a href="mailto:
|
640 |
</li>
|
641 |
|
642 |
<li class="powerup">
|
|
|
|
|
|
|
643 |
<h2>LeadIn VIP Program</h2>
|
644 |
-
<img src="<?php echo LEADIN_PATH; ?>/images/powerup-icon-vip@2x.png" height="80px" width="80px">
|
645 |
<p>Get access to exclusive features and offers for consultants and agencies.</p>
|
646 |
<p><a href="http://leadin.com/vip/" target="_blank">Learn more</a></p>
|
647 |
<a href="http://leadin.com/vip" target="_blank" class="button button-primary button-large">Become a VIP</a>
|
32 |
if ( !class_exists('LI_StatsDashboard') )
|
33 |
require_once LEADIN_PLUGIN_DIR . '/admin/inc/class-stats-dashboard.php';
|
34 |
|
35 |
+
if ( !class_exists('LI_Tags_Table') )
|
36 |
+
require_once LEADIN_PLUGIN_DIR . '/admin/inc/class-leadin-tags-list-table.php';
|
37 |
+
|
38 |
+
if ( !class_exists('LI_Tag_Editor') )
|
39 |
+
require_once LEADIN_PLUGIN_DIR . '/admin/inc/class-leadin-tag-editor.php';
|
40 |
+
|
41 |
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
42 |
|
43 |
//=============================================
|
73 |
add_action('admin_footer', array($this, 'build_contacts_chart'));
|
74 |
}
|
75 |
}
|
76 |
+
|
77 |
+
//print_r($_POST);
|
78 |
}
|
79 |
|
80 |
//=============================================
|
91 |
|
92 |
self::check_admin_action();
|
93 |
|
94 |
+
add_menu_page('LeadIn', 'LeadIn', 'manage_categories', 'leadin_stats', array($this, 'leadin_build_stats_page'), LEADIN_PATH . '/images/' . ( $wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? 'leadin-icon-32x32.png' : 'leadin-svg-icon.svg'), '25.100713');
|
95 |
|
96 |
foreach ( $this->admin_power_ups as $power_up )
|
97 |
{
|
100 |
$power_up->admin_init();
|
101 |
|
102 |
// Creates the menu icon for power-up if it's set. Overrides the main LeadIn menu to hit the contacts power-up
|
|
|
103 |
if ( $power_up->menu_text )
|
104 |
add_submenu_page('leadin_stats', $power_up->menu_text, $power_up->menu_text, 'manage_categories', 'leadin_' . $power_up->menu_link, array($power_up, 'power_up_setup_callback'));
|
105 |
}
|
241 |
else
|
242 |
$new_contacts_postbox .= '<i>No new contacts today...</i>';
|
243 |
|
|
|
|
|
244 |
return $new_contacts_postbox;
|
245 |
}
|
246 |
|
598 |
<?php if ( $power_up_count == 1 ) : ?>
|
599 |
<!-- static content stats power-up - not a real powerup and this is a hack to put it second in the order -->
|
600 |
<li class="powerup activated">
|
601 |
+
<div class="img-containter">
|
602 |
+
<img src="<?php echo LEADIN_PATH; ?>/images/powerup-icon-analytics@2x.png" height="80px" width="80px">
|
603 |
+
</div>
|
604 |
<h2>Content Stats</h2>
|
|
|
605 |
<p>See where all your conversions are coming from.</p>
|
606 |
<p><a href="http://leadin.com/content-analytics-plugin-wordpress/" target="_blank">Learn more</a></p>
|
607 |
<a href="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_stats'; ?>" class="button button-large">View Stats</a>
|
610 |
<?php endif; ?>
|
611 |
|
612 |
<li class="powerup <?php echo ( $power_up->activated ? 'activated' : ''); ?>">
|
613 |
+
<div class="img-containter">
|
614 |
+
<?php if ( strstr($power_up->icon, 'dashicon') ) : ?>
|
615 |
+
<span class="<?php echo $power_up->icon; ?>"></span>
|
616 |
+
<?php else : ?>
|
617 |
+
<img src="<?php echo LEADIN_PATH . '/images/' . $power_up->icon . '@2x.png'; ?>" height="80px" width="80px"/>
|
618 |
+
<?php endif; ?>
|
619 |
+
</div>
|
620 |
<h2><?php echo $power_up->power_up_name; ?></h2>
|
|
|
|
|
|
|
|
|
|
|
621 |
<p><?php echo $power_up->description; ?></p>
|
622 |
<p><a href="<?php echo $power_up->link_uri; ?>" target="_blank">Learn more</a></p>
|
623 |
<?php if ( $power_up->activated ) : ?>
|
641 |
<?php endforeach; ?>
|
642 |
|
643 |
<li class="powerup">
|
644 |
+
<div class="img-containter">
|
645 |
+
<img src="<?php echo LEADIN_PATH; ?>/images/powerup-icon-ideas@2x.png" height="80px" width="80px">
|
646 |
+
</div>
|
647 |
<h2>Your Idea</h2>
|
|
|
648 |
<p>Have an idea for a power-up? We'd love to hear it!</p>
|
649 |
<p> </p>
|
650 |
+
<a href="mailto:support@leadin.com" target="_blank" class="button button-primary button-large">Suggest an idea</a>
|
651 |
</li>
|
652 |
|
653 |
<li class="powerup">
|
654 |
+
<div class="img-containter">
|
655 |
+
<img src="<?php echo LEADIN_PATH; ?>/images/powerup-icon-vip@2x.png" height="80px" width="80px">
|
656 |
+
</div>
|
657 |
<h2>LeadIn VIP Program</h2>
|
|
|
658 |
<p>Get access to exclusive features and offers for consultants and agencies.</p>
|
659 |
<p><a href="http://leadin.com/vip/" target="_blank">Learn more</a></p>
|
660 |
<a href="http://leadin.com/vip" target="_blank" class="button button-primary button-large">Become a VIP</a>
|
assets/css/build/leadin-admin.css
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
#leadin label{cursor:default}#leadin .col-wrap{padding:0}#leadin .col-left .col-wrap{padding-right:10px}#leadin .metabox-holder{*zoom:1}#leadin .metabox-holder:after{content:"";display:table;clear:both}#wp-admin-bar-leadin-admin-menu img{height:16px;width:16px;opacity:0.6}@media (min-width: 1200px){#leadin{*zoom:1;max-width:1420px;max-width:88.75rem;padding-left:20px;padding-left:1.25rem;padding-right:20px;padding-right:1.25rem;margin-left:auto;margin-right:auto;margin:10px 20px 0 0;padding:0}#leadin:after{content:"";display:table;clear:both}#leadin *{box-sizing:border-box}}
|
2 |
-
#li_analytics-meta .li-analytics-link{float:left}#li_analytics-meta .li-analytics-link .li-analytics__face{height:35px;width:35px;margin-right:5px;margin-bottom:5px}#li_analytics-meta .hidden_face{display:none}#li_analytics-meta .show-all-faces-container{clear:both}.leadin-postbox{background-color:#fff;border:1px solid #e5e5e5;-moz-box-shadow:0 1px 1px rgba(0,0,0,0.04);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}.leadin-postbox__header{margin:0;padding:8px 12px;font-size:14px;border-bottom:1px solid #eee}.leadin-postbox__content{margin:11px 0;padding:0 12px;*zoom:1}.leadin-postbox__content:after{content:"";display:table;clear:both}.leadin-postbox__table{margin:0;width:100%}.leadin-postbox__table th{padding:6px 0;text-align:left;text-transform:uppercase;letter-spacing:0.05em}.leadin-postbox__table td{padding:6px 0}.leadin-postbox__table tr,.leadin-postbox__table td,.leadin-postbox__table th{vertical-align:middle !important}.leadin-dynamic-avatar_0{background-color:#f88e4b}.leadin-dynamic-avatar_1{background-color:#64aada}.leadin-dynamic-avatar_2{background-color:#64c2b6}.leadin-dynamic-avatar_3{background-color:#cf7baa}.leadin-dynamic-avatar_4{background-color:#e7c24b}.leadin-dynamic-avatar_5{background-color:#9387da}.leadin-dynamic-avatar_6{background-color:#d6dd99}.leadin-dynamic-avatar_7{background-color:#ff4c4c}.leadin-dynamic-avatar_8{background-color:#99583d}.leadin-dynamic-avatar_9{background-color:#54cc14}#leadin-footer{*zoom:1;clear:both;margin-top:48px;color:#999;border-top:1px solid #dedede}#leadin-footer:after{content:"";display:table;clear:both}#leadin-footer .support .sharing{height:18px;text-align:left}@media screen and (min-width: 500px){#leadin-footer .support,#leadin-footer .version,#leadin-footer .sharing{width:50%;float:left}#leadin-footer .sharing{text-align:right}}
|
3 |
-
.li-settings h3{border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;border-top:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5;margin-bottom:0px;background:#fff;padding:8px 12px;font-size:15px}.li-settings .form-table{margin-top:0px;border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5;background-color:#fff;-moz-box-shadow:0 1px 1px rgba(0,0,0,0.04);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}.li-settings .form-table th{padding-left:12px}.li-settings .leadin-section{background-color:#fff;border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;font-size:14px;padding:15px 12px 5px 12px}.li-settings .leadin-section p{margin:0;padding:0}.li-settings.pre-mp6 h3{font-family:Georgia}.li-settings.pre-mp6 select,.li-settings.pre-mp6 input{font-family:sans-serif;font-size:12px}.li-settings.pre-mp6 .form-table,.li-settings.pre-mp6 .leadin-section,.li-settings.pre-mp6 h3{background-color:#f9f9f9 !important}.li-settings.pre-mp6 .form-table{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.li-settings.pre-mp6 h3{background-color:#f9f9f9 !important;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px}.li-settings.pre-mp6 .leadin-section{font-size:12px;padding-left:6px}.li-settings.pre-mp6 h3{padding-left:6px;font-weight:normal;color:#464646;text-shadow:#fff 0px 1px 0px}.li-settings.pre-mp6 label{font-size:12px}.li-settings.pre-mp6 input[type="checkbox"],.li-settings.pre-mp6 input[type="radio"]{margin-right:2px}#icon-leadin{background:url("../../images/leadin-icon-32x32.png") top center no-repeat}.help-notification{background:#d9edf7;border:1px solid #bce8f1;padding:10px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.toplevel_page_leadin_stats .wp-menu-image img{width:16px;height:16px}.leadin-contact-avatar{margin-right:10px;float:left}.power-up-settings-icon{padding-right:10px;float:left;max-height:20px;margin-top:-1px}.dashicons{margin-right:10px;float:left;margin-top:-1px}.steps{margin:48px auto 0;text-align:center;max-width:600px}.steps h3,.steps p{margin:0}.steps .step-names{margin:0;*zoom:1}.steps .step-names:after{content:"";display:table;clear:both}.steps .step-names .step-name{color:#ccc;display:list-item;float:left;width:33%;margin:0;padding-bottom:18px;font-size:16px;list-style:decimal inside none}.steps .step-names .step-name.active{color:#1f7d71;background-image:url(../../images/triangle.png);background-position:bottom center;background-repeat:no-repeat}.steps .step-names .step-name.completed{list-style-image:url(../../images/checkmark.png)}.steps .step-content{margin:0}.steps .step-content .description{margin:10px 0 20px;display:block}.steps .step{display:none;padding:18px;background-color:#d3eeeb;border:2px solid #2a9;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;color:#1f7d71}.steps .step h2{color:#1f7d71;margin-top:0;margin-bottom:18px}.steps .step ol{text-align:left;margin-bottom:18px}.steps .step label{text-align:right}.steps .step.active{display:block}.steps .step .form-table th{display:none}.steps .step .form-table td{text-align:center;width:auto;display:block}.steps .step .form-table input{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block}.leadin-contacts .button{transition:background-color 0.2s}@media (min-width: 1200px){.leadin-contacts__nav{width:15.49296%;float:left;margin-right:1.40845%}.leadin-contacts__content{width:83.09859%;float:right;margin-right:0;margin-bottom:18px}.leadin-contacts__export-form{width:83.09859%;float:left;margin-right:1.40845%;padding-left:16.90141%;margin-bottom:18px}}h2.leadin-contacts__header{
|
4 |
-
.leadin-contacts.pre-mp6 .table_search{float:right;padding:12px 0;padding-bottom:11px}.leadin-contacts.pre-mp6 table{background-color:#fff;border-color:#dedede}.leadin-contacts.pre-mp6 table tr.alternate{background-color:#fff}.leadin-contacts.pre-mp6 table th,.leadin-contacts.pre-mp6 table td{border-top:0;padding:12px 6px 11px}.leadin-contacts.pre-mp6 table th a,.leadin-contacts.pre-mp6 table td a{padding:0}.leadin-contacts.pre-mp6 table th[scope="col"]{background:#eee;font-family:sans-serif;font-size:12px;text-shadow:none}.leadin-contacts.pre-mp6 table td{border-color:#dedede;line-height:18px;font-size:14px}.leadin-contacts.pre-mp6 table td .row-actions{float:left}#leadin .contact-header-wrap{*zoom:1;padding:9px 0 4px}#leadin .contact-header-wrap:after{content:"";display:table;clear:both}#leadin .contact-header-wrap .contact-header-avatar,#leadin .contact-header-wrap .contact-header-info{float:left}#leadin .contact-header-info{padding-left:15px}#leadin .contact-name{line-height:30px;padding:0;margin:0}#leadin .contact-
|
5 |
.big-number--average .leadin-stats__big-number-top-label,.big-number--average .leadin-stats__big-number-content,.big-number--average .leadin-stats__big-number-bottom-label{color:#4ca6cf}.leadin-stats__top-container,.leadin-stats__big-number-top-label,.leadin-stats__big-number-content,.leadin-stats__big-number-bottom-label{color:#666;margin-bottom:12px}.leadin-stats__big-number-top-label{text-transform:uppercase;letter-spacing:0.05em}
|
1 |
#leadin label{cursor:default}#leadin .col-wrap{padding:0}#leadin .col-left .col-wrap{padding-right:10px}#leadin .metabox-holder{*zoom:1}#leadin .metabox-holder:after{content:"";display:table;clear:both}#wp-admin-bar-leadin-admin-menu img{height:16px;width:16px;opacity:0.6}@media (min-width: 1200px){#leadin{*zoom:1;max-width:1420px;max-width:88.75rem;padding-left:20px;padding-left:1.25rem;padding-right:20px;padding-right:1.25rem;margin-left:auto;margin-right:auto;margin:10px 20px 0 0;padding:0}#leadin:after{content:"";display:table;clear:both}#leadin *{box-sizing:border-box}}
|
2 |
+
#li_analytics-meta .li-analytics-link{float:left}#li_analytics-meta .li-analytics-link .li-analytics__face{height:35px;width:35px;margin-right:5px;margin-bottom:5px}#li_analytics-meta .hidden_face{display:none}#li_analytics-meta .show-all-faces-container{clear:both}.leadin-postbox,.powerup-list .powerup{background-color:#fff;border:1px solid #e5e5e5;-moz-box-shadow:0 1px 1px rgba(0,0,0,0.04);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}.leadin-postbox__header{margin:0;padding:8px 12px;font-size:14px;border-bottom:1px solid #eee}.leadin-postbox__content{margin:11px 0;padding:0 12px;*zoom:1}.leadin-postbox__content:after{content:"";display:table;clear:both}.leadin-postbox__table{margin:0;width:100%}.leadin-postbox__table th{padding:6px 0;text-align:left;text-transform:uppercase;letter-spacing:0.05em}.leadin-postbox__table td{padding:6px 0}.leadin-postbox__table tr,.leadin-postbox__table td,.leadin-postbox__table th{vertical-align:middle !important}.leadin-dynamic-avatar_0{background-color:#f88e4b}.leadin-dynamic-avatar_1{background-color:#64aada}.leadin-dynamic-avatar_2{background-color:#64c2b6}.leadin-dynamic-avatar_3{background-color:#cf7baa}.leadin-dynamic-avatar_4{background-color:#e7c24b}.leadin-dynamic-avatar_5{background-color:#9387da}.leadin-dynamic-avatar_6{background-color:#d6dd99}.leadin-dynamic-avatar_7{background-color:#ff4c4c}.leadin-dynamic-avatar_8{background-color:#99583d}.leadin-dynamic-avatar_9{background-color:#54cc14}@font-face{font-family:"icomoon";src:url("../../fonts/icomoon.eot?-lejfm6");src:url("../../fonts/icomoon.eot?#iefix-lejfm6") format("embedded-opentype"),url("../../fonts/icomoon.woff?-lejfm6") format("woff"),url("../../fonts/icomoon.ttf?-lejfm6") format("truetype"),url("../../fonts/icomoon.svg?-lejfm6#icomoon") format("svg");font-weight:normal;font-style:normal}.icon,.icon-profile,.icon-tag,.icon-tags,.icon-envelope,.icon-user,.icon-cog,.icon-bars,.icon-lab,.icon-bulb,.icon-mover{font-family:"icomoon";speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-profile:before{content:"\e600"}.icon-tag:before{content:"\e601"}.icon-tags:before{content:"\e608"}.icon-envelope:before{content:"\e602"}.icon-user:before{content:"\e603"}.icon-cog:before{content:"\e604"}.icon-bars:before{content:"\e605"}.icon-lab:before{content:"\e606"}.icon-bulb:before{content:"\e607"}.icon-mover:before{content:"\e609"}#leadin-footer{*zoom:1;clear:both;margin-top:48px;color:#999;border-top:1px solid #dedede}#leadin-footer:after{content:"";display:table;clear:both}#leadin-footer .support .sharing{height:18px;text-align:left}@media screen and (min-width: 500px){#leadin-footer .support,#leadin-footer .version,#leadin-footer .sharing{width:50%;float:left}#leadin-footer .sharing{text-align:right}}
|
3 |
+
.li-settings h3{border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;border-top:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5;margin-bottom:0px;background:#fff;padding:8px 12px;font-size:15px}.li-settings .form-table{margin-top:0px;border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5;background-color:#fff;-moz-box-shadow:0 1px 1px rgba(0,0,0,0.04);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}.li-settings .form-table th{padding-left:12px}.li-settings .leadin-section{background-color:#fff;border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;font-size:14px;padding:15px 12px 5px 12px}.li-settings .leadin-section p{margin:0;padding:0}.li-settings.pre-mp6 h3{font-family:Georgia}.li-settings.pre-mp6 select,.li-settings.pre-mp6 input{font-family:sans-serif;font-size:12px}.li-settings.pre-mp6 .form-table,.li-settings.pre-mp6 .leadin-section,.li-settings.pre-mp6 h3{background-color:#f9f9f9 !important}.li-settings.pre-mp6 .form-table{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.li-settings.pre-mp6 h3{background-color:#f9f9f9 !important;-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px}.li-settings.pre-mp6 .leadin-section{font-size:12px;padding-left:6px}.li-settings.pre-mp6 h3{padding-left:6px;font-weight:normal;color:#464646;text-shadow:#fff 0px 1px 0px}.li-settings.pre-mp6 label{font-size:12px}.li-settings.pre-mp6 input[type="checkbox"],.li-settings.pre-mp6 input[type="radio"]{margin-right:2px}#icon-leadin{background:url("../../images/leadin-icon-32x32.png") top center no-repeat}.help-notification{background:#d9edf7;border:1px solid #bce8f1;padding:10px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.toplevel_page_leadin_stats .wp-menu-image img{width:16px;height:16px}.leadin-contact-avatar{margin-right:10px;float:left}.power-up-settings-icon{padding-right:10px;float:left;max-height:20px;margin-top:-1px}.dashicons{margin-right:10px;float:left;margin-top:-1px}.steps{margin:48px auto 0;text-align:center;max-width:600px}.steps h3,.steps p{margin:0}.steps .step-names{margin:0;*zoom:1}.steps .step-names:after{content:"";display:table;clear:both}.steps .step-names .step-name{color:#ccc;display:list-item;float:left;width:33%;margin:0;padding-bottom:18px;font-size:16px;list-style:decimal inside none}.steps .step-names .step-name.active{color:#1f7d71;background-image:url(../../images/triangle.png);background-position:bottom center;background-repeat:no-repeat}.steps .step-names .step-name.completed{list-style-image:url(../../images/checkmark.png)}.steps .step-content{margin:0}.steps .step-content .description{margin:10px 0 20px;display:block}.steps .step{display:none;padding:18px;background-color:#d3eeeb;border:2px solid #2a9;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;color:#1f7d71}.steps .step h2{color:#1f7d71;margin-top:0;margin-bottom:18px}.steps .step ol{text-align:left;margin-bottom:18px}.steps .step label{text-align:right}.steps .step.active{display:block}.steps .step .form-table th{display:none}.steps .step .form-table td{text-align:center;width:auto;display:block}.steps .step .form-table input{width:100%;font-size:16px;line-height:1.5;padding:7px 10px;display:block}tr.synced-list-row td.synced-list-cell{padding:3px 0px 10px 0px}tr.synced-list-row td.synced-list-cell .icon-tag{font-size:12px}tr.synced-list-row span.synced-list-arrow{padding:0px 10px}tr.synced-list-row td.synced-list-edit{padding:3px 0px 10px 20px}.leadin-contacts .button{transition:background-color 0.2s}@media (min-width: 1200px){.leadin-contacts__nav{width:15.49296%;float:left;margin-right:1.40845%}.leadin-contacts__content{width:83.09859%;float:right;margin-right:0;margin-bottom:18px}.leadin-contacts__export-form{width:83.09859%;float:left;margin-right:1.40845%;padding-left:16.90141%;margin-bottom:18px}}h2.leadin-contacts__header{margin-bottom:30px}.leadin-contacts__search{float:right;padding:10px 0;padding-bottom:9px}.leadin-contacts__type-picker{margin:0 0 30px;*zoom:1}.leadin-contacts__type-picker:after{content:"";display:table;clear:both}.leadin-contacts__type-picker li{margin:0;padding:0 1em 0 0;float:left}@media (min-width: 1200px){.leadin-contacts__type-picker li{float:none;padding:0}.leadin-contacts__type-picker li+li{padding:18px 0 0}}.leadin-contacts__type-picker li a{display:block;line-height:24px;font-weight:400;font-size:16px;text-decoration:none}.leadin-contacts__type-picker li a.current{font-weight:bold}.leadin-contacts__type-picker li a.current,.leadin-contacts__type-picker li a:hover,.leadin-contacts__type-picker li a:active{color:#f67d42}.leadin-contacts__type-picker li a .icon-tag,.leadin-contacts__type-picker li a .icon-user{padding-right:1em;font-size:0.85em}.leadin-contacts__tags-header{margin:30px 0 18px;font-size:14px;text-transform:uppercase;letter-spacing:0.1em;color:#999}.leadin-contacts__filter-text{margin:0 0 18px}.leadin-contacts__filter-count{color:#f67d42}#clear-filter{font-size:0.8em;margin-left:10px}.leadin-contacts__table table th#source{width:20%}.leadin-contacts__table table th#visits,.leadin-contacts__table table th#submissions{width:8%}.leadin-contacts__table table th#status,.leadin-contacts__table table th#last_visit,.leadin-contacts__table table th#date,.leadin-contacts__table table th#pageviews{width:10%}.leadin-contacts__table table th,.leadin-contacts__table table td{display:none}.leadin-contacts__table table th:nth-child(-n+3),.leadin-contacts__table table td:nth-child(-n+3){display:table-cell}@media (min-width: 1200px){.leadin-contacts__table table th,.leadin-contacts__table table td{display:table-cell}}
|
4 |
+
.leadin-contacts.pre-mp6 .table_search{float:right;padding:12px 0;padding-bottom:11px}.leadin-contacts.pre-mp6 table{background-color:#fff;border-color:#dedede}.leadin-contacts.pre-mp6 table tr.alternate{background-color:#fff}.leadin-contacts.pre-mp6 table th,.leadin-contacts.pre-mp6 table td{border-top:0;padding:12px 6px 11px}.leadin-contacts.pre-mp6 table th a,.leadin-contacts.pre-mp6 table td a{padding:0}.leadin-contacts.pre-mp6 table th[scope="col"]{background:#eee;font-family:sans-serif;font-size:12px;text-shadow:none}.leadin-contacts.pre-mp6 table td{border-color:#dedede;line-height:18px;font-size:14px}.leadin-contacts.pre-mp6 table td .row-actions{float:left}#leadin .contact-header-wrap{*zoom:1;padding:9px 0 4px}#leadin .contact-header-wrap:after{content:"";display:table;clear:both}#leadin .contact-header-wrap .contact-header-avatar,#leadin .contact-header-wrap .contact-header-info{float:left}#leadin .contact-header-info{padding-left:15px}#leadin .contact-name{line-height:30px;padding:0;margin:0}#leadin .contact-tags{margin-top:15px}#leadin .contact-tag{padding:4px 10px;color:#fff;background-color:#f67d42;text-decoration:none;font-weight:600;text-transform:uppercase;letter-spacing:0.1em;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px}#leadin .contact-tag:hover{opacity:0.9}#leadin .contact-tag+.contact-tag,#leadin .contact-tag+.contact-edit-tags{margin-left:10px}#leadin .contact-tag .icon-tag{padding-right:10px}#leadin .contact-info h3{margin:0}#leadin .contact-info label{font-weight:bold;line-height:1;cursor:default}#leadin .contact-history{margin-left:20px}@media (min-width: 1200px){#leadin .contact-history{padding-left:20px;border-left:2px solid #dedede}}#leadin .contact-history .session+.session{margin-top:30px}#leadin .contact-history .session-date{position:relative}@media (min-width: 1200px){#leadin .contact-history .session-date:before{content:"\2022";font-size:32px;line-height:0;height:31px;width:31px;position:absolute;left:-27px;top:9px;color:#dedede}}#leadin .contact-history .session-time-range{color:#999;font-weight:400}#leadin .contact-history .events{background-color:#fff;border:1px solid #dedede;-moz-box-shadow:0 1px 1px rgba(0,0,0,0.04);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.04);box-shadow:0 1px 1px rgba(0,0,0,0.04)}#leadin .contact-history .event{margin:0;padding:10px 20px;border-bottom:1px solid #dedede;border-left:4px solid;*zoom:1}#leadin .contact-history .event:after{content:"";display:table;clear:both}#leadin .contact-history .event:first-child{border-top:0}#leadin .contact-history .event.pageview{border-left-color:#28c;color:#28c}#leadin .contact-history .event.form-submission{border-left-color:#f67d42;color:#f67d42}#leadin .contact-history .event.source{border-left-color:#99aa1f;color:#99aa1f}#leadin .contact-history .event-title{margin:0;font-size:13px;font-weight:600}#leadin .contact-history .event-time{float:left;font-weight:400;width:75px}#leadin .contact-history .event-content{margin-left:75px}#leadin .contact-history .event-detail{margin-top:20px;color:#444}#leadin .contact-history .event-detail li+li{padding-top:6px;border-top:1px solid #eee}#leadin .contact-history .event-detail.pageview-url{color:#ccc}#leadin .contact-history .visit-source p{margin:0;color:#1f6696}#leadin .contact-history .field-label{text-transform:uppercase;letter-spacing:0.05em;color:#999;margin-bottom:6px;font-size:0.9em}#leadin .contact-history .field-value{margin:0}#leadin.pre-mp6 .events{background-color:#f9f9f9}.powerup-list{margin:0}.powerup-list .powerup{width:20%;min-width:250px;float:left;margin:20px;padding:15px}.powerup-list .powerup h2,.powerup-list .powerup p{margin:0;padding:0;color:#666;margin-bottom:15px}.powerup-list .powerup .img-containter{text-align:center;padding:30px 15px;margin-bottom:15px;background-color:#f1f1f1}.powerup-list .powerup.activated h2,.powerup-list .powerup.activated p{color:#1f7d71}.powerup-list .powerup.activated .img-containter{background-color:#d3eeeb}@media (min-width: 1200px){.leadin-stats__top-container,.leadin-stats__chart-container,.leadin-stats__big-numbers-container{width:100%;float:right;margin-right:0}.leadin-stats__postbox_containter{width:49.29577%;float:left;margin-right:1.40845%}.leadin-stats__postbox_containter:nth-child(2n+2){width:49.29577%;float:right;margin-right:0}}h2.leadin-stats__header{margin-bottom:12px}.leadin-stats__postbox_containter .leadin-postbox,.leadin-stats__postbox_containter .powerup-list .powerup,.powerup-list .leadin-stats__postbox_containter .powerup{margin-bottom:12px}.leadin-stats__big-number{text-align:center;width:42%;float:left;padding:4%}@media (min-width: 1200px){.leadin-stats__big-number{width:25%;padding:10px}}
|
5 |
.big-number--average .leadin-stats__big-number-top-label,.big-number--average .leadin-stats__big-number-content,.big-number--average .leadin-stats__big-number-bottom-label{color:#4ca6cf}.leadin-stats__top-container,.leadin-stats__big-number-top-label,.leadin-stats__big-number-content,.leadin-stats__big-number-bottom-label{color:#666;margin-bottom:12px}.leadin-stats__big-number-top-label{text-transform:uppercase;letter-spacing:0.05em}
|
assets/fonts/icomoon.eot
ADDED
Binary file
|
assets/fonts/icomoon.svg
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" standalone="no"?>
|
2 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
3 |
+
<svg xmlns="http://www.w3.org/2000/svg">
|
4 |
+
<metadata>Generated by IcoMoon</metadata>
|
5 |
+
<defs>
|
6 |
+
<font id="icomoon" horiz-adv-x="512">
|
7 |
+
<font-face units-per-em="512" ascent="480" descent="-32" />
|
8 |
+
<missing-glyph horiz-adv-x="512" />
|
9 |
+
<glyph unicode=" " d="" horiz-adv-x="256" />
|
10 |
+
<glyph unicode="" d="M432 480h-384c-26.4 0-48-21.6-48-48v-416c0-26.4 21.6-48 48-48h384c26.4 0 48 21.6 48 48v416c0 26.4-21.6 48-48 48zM416 32h-352v384h352v-384zM128 192h224v-32h-224zM128 128h224v-32h-224zM160 336c0 26.51 21.49 48 48 48s48-21.49 48-48c0-26.51-21.49-48-48-48s-48 21.49-48 48zM240 288h-64c-26.4 0-48-14.4-48-32v-32h160v32c0 17.6-21.6 32-48 32z" />
|
11 |
+
<glyph unicode="" d="M463.906 480h-144.281c-26.453 0-63.398-15.303-82.102-34.007l-223.495-223.495c-18.704-18.704-18.704-49.312 0-68.016l172.455-172.453c18.704-18.705 49.311-18.705 68.015 0l223.495 223.494c18.704 18.705 34.007 55.651 34.007 82.102v144.281c0 26.452-21.643 48.094-48.094 48.094zM400 320c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z" />
|
12 |
+
<glyph unicode="" d="M464 416h-416c-26.4 0-48-21.6-48-48v-320c0-26.4 21.6-48 48-48h416c26.4 0 48 21.6 48 48v320c0 26.4-21.6 48-48 48zM199.37 204.814l-135.37-105.446v250.821l135.37-145.375zM88.19 352h335.62l-167.81-126-167.81 126zM204.644 199.151l51.356-55.151 51.355 55.151 105.277-135.151h-313.264l105.276 135.151zM312.63 204.814l135.37 145.375v-250.821l-135.37 105.446z" />
|
13 |
+
<glyph unicode="" d="M128 320c0 70.692 57.308 128 128 128s128-57.308 128-128c0-70.692-57.308-128-128-128s-128 57.308-128 128zM384 160h-256c-70.692 0-128-57.309-128-128v-32h512v32c0 70.691-57.308 128-128 128z" />
|
14 |
+
<glyph unicode="" d="M512 175.953v96.094l-73.387 12.231c-2.979 9.066-6.611 17.834-10.847 26.25l43.227 60.517-67.948 67.949-60.413-43.152c-8.455 4.277-17.269 7.944-26.384 10.951l-12.201 73.207h-96.094l-12.201-73.208c-9.115-3.007-17.929-6.674-26.383-10.951l-60.414 43.152-67.949-67.949 43.227-60.518c-4.235-8.415-7.867-17.183-10.846-26.249l-73.387-12.23v-96.094l73.559-12.26c2.98-8.984 6.605-17.674 10.821-26.015l-43.374-60.724 67.949-67.948 60.827 43.447c8.301-4.175 16.945-7.764 25.882-10.717l12.289-73.736h96.094l12.289 73.737c8.937 2.953 17.581 6.542 25.883 10.716l60.826-43.446 67.948 67.948-43.372 60.723c4.216 8.341 7.839 17.031 10.82 26.016l73.559 12.259zM256 160c-35.346 0-64 28.653-64 64s28.654 64 64 64c35.347 0 64-28.654 64-64s-28.653-64-64-64z" />
|
15 |
+
<glyph unicode="" d="M0 64h512v-64h-512zM64 192h64v-96h-64zM160 320h64v-224h-64zM256 224h64v-128h-64zM352 416h64v-320h-64z" />
|
16 |
+
<glyph unicode="" d="M478.145 77.759l-158.145 263.512v106.729h16c8.8 0 16 7.2 16 16s-7.2 16-16 16h-160c-8.8 0-16-7.2-16-16s7.2-16 16-16h16v-106.729l-158.144-263.512c-36.221-60.367-8.256-109.759 62.144-109.759h320c70.4 0 98.365 49.392 62.145 109.759zM120.519 160l103.481 172.469v115.531h64v-115.531l103.482-172.469h-270.963z" />
|
17 |
+
<glyph unicode="" d="M256 480c-97.216 0-176-78.784-176-176 0-64.496 59.008-132.848 80.496-192.88 32.048-89.52 28.496-143.12 95.504-143.12 68 0 63.44 53.344 95.504 142.752 21.552 60.16 80.496 129.248 80.496 193.248 0 97.216-78.816 176-176 176zM297.472 45.184l-79.328-9.904c-2.832 8.192-5.872 17.776-9.568 30.288-0.048 0.16-0.112 0.336-0.144 0.496l99.008 12.368c-1.408-4.72-2.912-9.68-4.224-14.128-2.096-7.184-3.968-13.424-5.744-19.12zM203.776 81.472c-2.912 9.632-6.192 19.776-9.84 30.528h124.256c-1.968-5.744-3.936-11.504-5.632-16.944l-108.784-13.584zM256 0c-16.208 0-23.664 1.872-31.952 20l67.808 8.496c-9.824-26.464-16.976-28.496-35.856-28.496zM330.752 144h-149.328c-7.968 17.28-17.536 34.56-26.976 51.472-20.88 37.36-42.448 76-42.448 108.528 0 79.408 64.592 144 144 144s144-64.592 144-144c0-32.288-21.6-71.136-42.496-108.72-9.344-16.848-18.848-34.096-26.752-51.28zM256 400c4.4 0 8-3.584 8-8s-3.584-8-8-8c-44.112 0-80-35.888-80-80 0-4.416-3.584-8-8-8s-8 3.584-8 8c0 52.944 43.056 96 96 96z" />
|
18 |
+
<glyph unicode="" d="M496 448h-112c-26.4 0-63.273-15.273-81.941-33.941l-188.118-188.118c-18.667-18.667-18.667-49.214 0-67.882l140.118-140.117c18.667-18.668 49.214-18.668 67.882 0l188.117 188.117c18.669 18.668 33.942 55.541 33.942 81.941v112c0 26.4-21.6 48-48 48zM432 288c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48zM43.313 180.687l171.189-171.189c-18.132-9.58-41.231-6.769-56.443 8.444l-140.118 140.117c-18.667 18.668-18.667 49.215 0 67.882l188.118 188.118c18.668 18.668 55.541 33.941 81.941 33.941l-244.687-244.686c-6.222-6.223-6.222-16.404 0-22.627z" horiz-adv-x="544" />
|
19 |
+
<glyph unicode="" d="M287.744 385.264v-129.008h128v64l96.256-96.256-96.256-96.24v65.488h-128v-129.008h64.496l-96.24-96.24-96.256 96.24h64v129.008h-128v-64.992l-95.744 95.744 95.744 95.744v-63.488h128v129.008h-62.496l94.752 94.736 94.752-94.736h-63.008z" />
|
20 |
+
</font></defs></svg>
|
assets/fonts/icomoon.ttf
ADDED
Binary file
|
assets/fonts/icomoon.woff
ADDED
Binary file
|
assets/js/build/leadin-admin.js
CHANGED
@@ -305,7 +305,23 @@ b!==!1&&d.redraw();D(c,f)},setTooltipPoints:function(a){var b=[],c,d,e=this.xAxi
|
|
305 |
hasBidiBug:Nb,isTouchDevice:Jb,numberFormat:Ga,seriesTypes:F,setOptions:function(a){E=w(!0,E,a);Cb();return E},addEvent:K,removeEvent:W,createElement:Y,discardElement:Pa,css:G,each:p,extend:q,map:Ua,merge:w,pick:m,splat:qa,extendClass:ka,pInt:z,wrap:Ma,svg:aa,canvas:fa,vml:!aa&&!fa,product:"Highcharts",version:"4.0.1"})})();
|
306 |
jQuery(document).ready( function ( $ ) {
|
307 |
|
308 |
-
$("#filter_action").select2(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
|
310 |
$("#filter_content").select2({
|
311 |
query: function( query ) {
|
@@ -339,7 +355,44 @@ jQuery(document).ready( function ( $ ) {
|
|
339 |
}
|
340 |
else
|
341 |
{
|
342 |
-
$('#filter_content').select2("data", {id: '', text: '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
343 |
}
|
344 |
}
|
345 |
});
|
@@ -349,20 +402,27 @@ jQuery(document).ready( function ( $ ) {
|
|
349 |
});
|
350 |
});
|
351 |
jQuery(document).ready( function ( $ ) {
|
|
|
|
|
|
|
352 |
$('#leadin-contacts input:checkbox').not('thead input:checkbox, tfoot input:checkbox').bind('change', function ( e ){
|
353 |
var cb_count = 0;
|
354 |
var selected_vals = '';
|
355 |
var $btn_selected = $('#leadin-export-selected-leads');
|
356 |
-
|
|
|
357 |
var $cb_selected = $('#leadin-contacts input:checkbox:checked').not('thead input:checkbox, tfoot input:checkbox');
|
358 |
|
359 |
if ( $cb_selected.length > 0 )
|
360 |
{
|
361 |
$btn_selected.attr('disabled', false);
|
|
|
|
|
362 |
}
|
363 |
else
|
364 |
{
|
365 |
$btn_selected.attr('disabled', true);
|
|
|
366 |
}
|
367 |
|
368 |
$cb_selected.each( function ( e ) {
|
@@ -375,6 +435,7 @@ jQuery(document).ready( function ( $ ) {
|
|
375 |
});
|
376 |
|
377 |
$input_selected_vals.val(selected_vals);
|
|
|
378 |
});
|
379 |
|
380 |
$('#cb-select-all-1, #cb-select-all-2').bind('change', function ( e ) {
|
@@ -383,7 +444,7 @@ jQuery(document).ready( function ( $ ) {
|
|
383 |
var $this = $(this);
|
384 |
var $btn_selected = $('#leadin-export-selected-leads');
|
385 |
var $cb_selected = $('#leadin-contacts input:checkbox').not('thead input:checkbox, tfoot input:checkbox');
|
386 |
-
var $input_selected_vals = $('
|
387 |
|
388 |
$cb_selected.each( function ( e ) {
|
389 |
selected_vals += $(this).val();
|
@@ -399,11 +460,18 @@ jQuery(document).ready( function ( $ ) {
|
|
399 |
if ( !$this.is(':checked') )
|
400 |
{
|
401 |
$btn_selected.attr('disabled', true);
|
|
|
|
|
402 |
}
|
403 |
else
|
404 |
{
|
405 |
$btn_selected.attr('disabled', false);
|
|
|
406 |
}
|
|
|
|
|
|
|
|
|
407 |
});
|
408 |
|
409 |
$('.postbox .handlediv').bind('click', function ( e ) {
|
@@ -417,7 +485,35 @@ jQuery(document).ready( function ( $ ) {
|
|
417 |
{
|
418 |
$postbox.addClass('closed');
|
419 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
|
|
|
|
|
|
|
421 |
});
|
422 |
});
|
423 |
/*
|
@@ -3870,7 +3966,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
3870 |
}(jQuery));
|
3871 |
|
3872 |
jQuery(document).ready( function ( $ ) {
|
3873 |
-
$('#filter_action, #filter_content').change(function() {
|
3874 |
$('#leadin-contacts-filter-button').addClass('button-primary');
|
3875 |
});
|
3876 |
});
|
305 |
hasBidiBug:Nb,isTouchDevice:Jb,numberFormat:Ga,seriesTypes:F,setOptions:function(a){E=w(!0,E,a);Cb();return E},addEvent:K,removeEvent:W,createElement:Y,discardElement:Pa,css:G,each:p,extend:q,map:Ua,merge:w,pick:m,splat:qa,extendClass:ka,pInt:z,wrap:Ma,svg:aa,canvas:fa,vml:!aa&&!fa,product:"Highcharts",version:"4.0.1"})})();
|
306 |
jQuery(document).ready( function ( $ ) {
|
307 |
|
308 |
+
$("#filter_action").select2(
|
309 |
+
|
310 |
+
);
|
311 |
+
|
312 |
+
$('#filter_action').change( function ( e ) {
|
313 |
+
var $this = $(this);
|
314 |
+
|
315 |
+
if ( $this.val() == 'submitted' )
|
316 |
+
{
|
317 |
+
$('#form-filter-input').show();
|
318 |
+
}
|
319 |
+
else
|
320 |
+
{
|
321 |
+
$('#form-filter-input').hide();
|
322 |
+
$('#filter_form').select2("val", "any form");
|
323 |
+
}
|
324 |
+
});
|
325 |
|
326 |
$("#filter_content").select2({
|
327 |
query: function( query ) {
|
355 |
}
|
356 |
else
|
357 |
{
|
358 |
+
$('#filter_content').select2("data", {id: '', text: 'any page'});
|
359 |
+
}
|
360 |
+
}
|
361 |
+
});
|
362 |
+
|
363 |
+
$("#filter_form").select2({
|
364 |
+
query: function( query ) {
|
365 |
+
var key = query.term;
|
366 |
+
|
367 |
+
$.ajax({
|
368 |
+
type: 'POST',
|
369 |
+
url: li_admin_ajax.ajax_url,
|
370 |
+
data: {
|
371 |
+
"action": "leadin_get_form_selectors",
|
372 |
+
"search_term": key
|
373 |
+
},
|
374 |
+
success: function(data){
|
375 |
+
// Force override the current tracking with the merged value
|
376 |
+
var json_data = jQuery.parseJSON(data);
|
377 |
+
var data_test = {results: []}, i, j, s;
|
378 |
+
for ( i = 0; i < json_data.length; i++ )
|
379 |
+
{
|
380 |
+
data_test.results.push({id: json_data[i], text: json_data[i]});
|
381 |
+
}
|
382 |
+
|
383 |
+
query.callback(data_test);
|
384 |
+
}
|
385 |
+
})
|
386 |
+
|
387 |
+
},
|
388 |
+
initSelection: function(element, callback) {
|
389 |
+
if ( $('#filter_form').val() )
|
390 |
+
{
|
391 |
+
$('#filter_form').select2("data", {id: $('#filter_form').val(), text: $('#filter_form').val()});
|
392 |
+
}
|
393 |
+
else
|
394 |
+
{
|
395 |
+
$('#filter_form').select2("data", {id: '', text: 'any form'});
|
396 |
}
|
397 |
}
|
398 |
});
|
402 |
});
|
403 |
});
|
404 |
jQuery(document).ready( function ( $ ) {
|
405 |
+
|
406 |
+
var $bulk_opt_selected = $('.bulkactions select option[value="add_tag_to_selected"], .bulkactions select option[value="remove_tag_from_selected"], .bulkactions select option[value="delete_selected"]');
|
407 |
+
|
408 |
$('#leadin-contacts input:checkbox').not('thead input:checkbox, tfoot input:checkbox').bind('change', function ( e ){
|
409 |
var cb_count = 0;
|
410 |
var selected_vals = '';
|
411 |
var $btn_selected = $('#leadin-export-selected-leads');
|
412 |
+
|
413 |
+
var $input_selected_vals = $('.leadin-selected-contacts');
|
414 |
var $cb_selected = $('#leadin-contacts input:checkbox:checked').not('thead input:checkbox, tfoot input:checkbox');
|
415 |
|
416 |
if ( $cb_selected.length > 0 )
|
417 |
{
|
418 |
$btn_selected.attr('disabled', false);
|
419 |
+
$bulk_opt_selected.attr('disabled', false);
|
420 |
+
|
421 |
}
|
422 |
else
|
423 |
{
|
424 |
$btn_selected.attr('disabled', true);
|
425 |
+
$bulk_opt_selected.attr('disabled', true);
|
426 |
}
|
427 |
|
428 |
$cb_selected.each( function ( e ) {
|
435 |
});
|
436 |
|
437 |
$input_selected_vals.val(selected_vals);
|
438 |
+
$('.selected-contacts-count').text(cb_count);
|
439 |
});
|
440 |
|
441 |
$('#cb-select-all-1, #cb-select-all-2').bind('change', function ( e ) {
|
444 |
var $this = $(this);
|
445 |
var $btn_selected = $('#leadin-export-selected-leads');
|
446 |
var $cb_selected = $('#leadin-contacts input:checkbox').not('thead input:checkbox, tfoot input:checkbox');
|
447 |
+
var $input_selected_vals = $('.leadin-selected-contacts');
|
448 |
|
449 |
$cb_selected.each( function ( e ) {
|
450 |
selected_vals += $(this).val();
|
460 |
if ( !$this.is(':checked') )
|
461 |
{
|
462 |
$btn_selected.attr('disabled', true);
|
463 |
+
$bulk_opt_selected.attr('disabled', true);
|
464 |
+
$('.selected-contacts-count').text($('#contact-count').text());
|
465 |
}
|
466 |
else
|
467 |
{
|
468 |
$btn_selected.attr('disabled', false);
|
469 |
+
$bulk_opt_selected.attr('disabled', false);
|
470 |
}
|
471 |
+
|
472 |
+
$('.selected-contacts-count').text(cb_count);
|
473 |
+
|
474 |
+
|
475 |
});
|
476 |
|
477 |
$('.postbox .handlediv').bind('click', function ( e ) {
|
485 |
{
|
486 |
$postbox.addClass('closed');
|
487 |
}
|
488 |
+
});
|
489 |
+
|
490 |
+
$('.selected-contacts-count').text($('#contact-count').text());
|
491 |
+
$bulk_opt_selected.attr('disabled', true);
|
492 |
+
|
493 |
+
$('.bulkactions select').change(function ( e ) {
|
494 |
+
var $this = $(this);
|
495 |
+
var $contact_count = $('#contact-count').text();
|
496 |
+
|
497 |
+
if ( $this.val() == 'add_tag_to_all' || $this.val() == 'add_tag_to_selected' )
|
498 |
+
{
|
499 |
+
$('#bulk-edit-tags h2').html($('#bulk-edit-tags h2').html().replace('remove from', 'add to'));
|
500 |
+
$('#bulk-edit-button').val('Add Tag');
|
501 |
+
$('#bulk-edit-tag-action').val('add_tag');
|
502 |
+
tb_show("", "#TB_inline?width=400&height=175&inlineId=bulk-edit-tags");
|
503 |
+
|
504 |
+
// Reset the bulk actions so if the user closes the box it resets the values and nulls the apply button
|
505 |
+
$('.bulkactions select').val('-1');
|
506 |
+
}
|
507 |
+
else if ( $this.val() == 'remove_tag_from_all' || $this.val() == 'remove_tag_from_selected' )
|
508 |
+
{
|
509 |
+
$('#bulk-edit-tags h2').html($('#bulk-edit-tags h2').html().replace('add to', 'remove from'));
|
510 |
+
$('#bulk-edit-button').val('Remove Tag');
|
511 |
+
$('#bulk-edit-tag-action').val('remove_tag');
|
512 |
+
tb_show("", "#TB_inline?width=400&height=175&inlineId=bulk-edit-tags");
|
513 |
|
514 |
+
// Reset the bulk actions so if the user closes the box it resets the values and nulls the apply button
|
515 |
+
$('.bulkactions select').val('-1');
|
516 |
+
}
|
517 |
});
|
518 |
});
|
519 |
/*
|
3966 |
}(jQuery));
|
3967 |
|
3968 |
jQuery(document).ready( function ( $ ) {
|
3969 |
+
$('#filter_action, #filter_content, #filter_form').change(function() {
|
3970 |
$('#leadin-contacts-filter-button').addClass('button-primary');
|
3971 |
});
|
3972 |
});
|
assets/js/build/leadin-admin.min.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
},n.anchorXSetter=function(a,b){e=a,l(b,a+y-xb)},n.anchorYSetter=function(a,b){f=a,l(b,a-yb)},n.xSetter=function(a){n.x=a,L&&(a-=L*((Va||J.width)+x)),xb=u(a),n.attr("translateX",xb)},n.ySetter=function(a){yb=n.y=u(a),n.attr("translateY",yb)};var A=n.css;return q(n,{css:function(a){if(a){var b={},a=w(a);p("fontSize,fontWeight,fontFamily,color,lineHeight,width,textDecoration,textShadow".split(","),function(c){a[c]!==t&&(b[c]=a[c],delete a[c])}),s.css(b)}return A.call(n,a)},getBBox:function(){return{width:J.width+2*x,height:J.height+2*x,x:J.x-x,y:J.y-x}},shadow:function(a){return m&&m.shadow(a),n},destroy:function(){W(n.element,"mouseenter"),W(n.element,"mouseleave"),s&&(s=s.destroy()),m&&(m=m.destroy()),P.prototype.destroy.call(n),n=o=j=k=l=null}})}},Za=ta,q(P.prototype,{htmlCss:function(a){var b=this.element;return(b=a&&"SPAN"===b.tagName&&a.width)&&(delete a.width,this.textWidth=b,this.updateTransform()),this.styles=q(this.styles,a),G(this.element,a),this},htmlGetBBox:function(){var a=this.element,b=this.bBox;return b||("text"===a.nodeName&&(a.style.position="absolute"),b=this.bBox={x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}),b},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,b=this.element,c=this.translateX||0,d=this.translateY||0,e=this.x||0,f=this.y||0,g=this.textAlign||"left",h={left:0,center:.5,right:1}[g],i=this.shadows;if(G(b,{marginLeft:c,marginTop:d}),i&&p(i,function(a){G(a,{marginLeft:c+1,marginTop:d+1})}),this.inverted&&p(b.childNodes,function(c){a.invertChild(c,b)}),"SPAN"===b.tagName){var k,j=this.rotation,l=z(this.textWidth),o=[j,g,b.innerHTML,this.textWidth].join(",");o!==this.cTT&&(k=a.fontMetrics(b.style.fontSize).b,r(j)&&this.setSpanRotation(j,h,k),i=m(this.elemWidth,b.offsetWidth),i>l&&/[ \-]/.test(b.textContent||b.innerText)&&(G(b,{width:l+"px",display:"block",whiteSpace:"normal"}),i=l),this.getSpanCorrection(i,k,h,j,g)),G(b,{left:e+(this.xCorr||0)+"px",top:f+(this.yCorr||0)+"px"}),ib&&(k=b.offsetHeight),this.cTT=o}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,c){var d={},e=Aa?"-ms-transform":ib?"-webkit-transform":Ta?"MozTransform":Ib?"-o-transform":"";d[e]=d.transform="rotate("+a+"deg)",d[e+(Ta?"Origin":"-origin")]=d.transformOrigin=100*b+"% "+c+"px",G(this.element,d)},getSpanCorrection:function(a,b,c){this.xCorr=-a*c,this.yCorr=-b}}),q(ta.prototype,{html:function(a,b,c){var d=this.createElement("span"),e=d.element,f=d.renderer;return d.textSetter=function(a){a!==e.innerHTML&&delete this.bBox,e.innerHTML=this.textStr=a},d.xSetter=d.ySetter=d.alignSetter=d.rotationSetter=function(a,b){"align"===b&&(b="textAlign"),d[b]=a,d.htmlUpdateTransform()},d.attr({text:a,x:u(b),y:u(c)}).css({position:"absolute",whiteSpace:"nowrap",fontFamily:this.style.fontFamily,fontSize:this.style.fontSize}),d.css=d.htmlCss,f.isSVG&&(d.add=function(a){var b,c=f.box.parentNode,j=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)j.push(a),a=a.parentGroup;p(j.reverse(),function(a){var d;b=a.div=a.div||Y(Ja,{className:H(a.element,"class")},{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px"},b||c),d=b.style,q(a,{translateXSetter:function(b,c){d.left=b+"px",a[c]=b,a.doTransform=!0},translateYSetter:function(b,c){d.top=b+"px",a[c]=b,a.doTransform=!0},visibilitySetter:function(a,b){d[b]=a}})})}}else b=c;return b.appendChild(e),d.added=!0,d.alignOnAdd&&d.htmlUpdateTransform(),d}),d}});var X;if(!aa&&!fa){R.VMLElement=X={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'],d=["position: ","absolute",";"],e=b===Ja;("shape"===b||e)&&d.push("left:0;top:0;width:1px;height:1px;"),d.push("visibility: ",e?"hidden":"visible"),c.push(' style="',d.join(""),'"/>'),b&&(c=e||"span"===b||"img"===b?c.join(""):a.prepVML(c),this.element=Y(c)),this.renderer=a},add:function(a){var b=this.renderer,c=this.element,d=b.box,d=a?a.element||a:d;return a&&a.inverted&&b.invertChild(c,d),d.appendChild(c),this.added=!0,this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform(),this.onAdd&&this.onAdd(),this},updateTransform:P.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Z(a*Ca),c=ea(a*Ca);G(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11=",b,", M12=",-c,", M21=",c,", M22=",b,", sizingMethod='auto expand')"].join(""):Q})},getSpanCorrection:function(a,b,c,d,e){var i,f=d?Z(d*Ca):1,g=d?ea(d*Ca):0,h=m(this.elemHeight,this.element.offsetHeight);this.xCorr=0>f&&-a,this.yCorr=0>g&&-h,i=0>f*g,this.xCorr+=g*b*(i?1-c:c),this.yCorr-=f*b*(d?i?c:1-c:1),e&&"left"!==e&&(this.xCorr-=a*c*(0>f?-1:1),d&&(this.yCorr-=h*c*(0>g?-1:1)),G(this.element,{textAlign:e}))},pathToVML:function(a){for(var b=a.length,c=[];b--;)ha(a[b])?c[b]=u(10*a[b])-5:"Z"===a[b]?c[b]="x":(c[b]=a[b],!a.isArc||"wa"!==a[b]&&"at"!==a[b]||(c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1)));return c.join(" ")||"x"},clip:function(a){var c,b=this;return a?(c=a.members,ja(c,b),c.push(b),b.destroyClip=function(){ja(c,b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:hb?"inherit":"rect(auto)"}),b.css(a)},css:P.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&Pa(a)},destroy:function(){return this.destroyClip&&this.destroyClip(),P.prototype.destroy.apply(this)},on:function(a,b){return this.element["on"+a]=function(){var a=I.event;a.target=a.srcElement,b(a)},this},cutOffPath:function(a,b){var c,a=a.split(/[ ,]/);return c=a.length,(9===c||11===c)&&(a[c-4]=a[c-2]=z(a[c-2])-10*b),a.join(" ")},shadow:function(a,b,c){var e,h,j,l,o,n,s,d=[],f=this.element,g=this.renderer,i=f.style,k=f.path;if(k&&"string"!=typeof k.value&&(k="x"),o=k,a){for(n=m(a.width,3),s=(a.opacity||.15)/n,e=1;3>=e;e++)l=2*n+1-2*e,c&&(o=this.cutOffPath(k.value,l+.5)),j=['<shape isShadow="true" strokeweight="',l,'" filled="false" path="',o,'" coordsize="10 10" style="',f.style.cssText,'" />'],h=Y(g.prepVML(j),null,{left:z(i.left)+m(a.offsetX,1),top:z(i.top)+m(a.offsetY,1)}),c&&(h.cutOff=l+1),j=['<stroke color="',a.color||"black",'" opacity="',s*e,'"/>'],Y(g.prepVML(j),null,null,h),b?b.element.appendChild(h):f.parentNode.insertBefore(h,f),d.push(h);this.shadows=d}return this},updateShadows:sa,setAttr:function(a,b){hb?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){this.element.className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]||Y(this.renderer.prepVML(["<stroke/>"]),null,null,c))[b]=a||"solid",this[b]=a},dSetter:function(a,b,c){var d=this.shadows,a=a||[];if(this.d=a.join(" "),c.path=a=this.pathToVML(a),d)for(c=d.length;c--;)d[c].path=d[c].cutOff?this.cutOffPath(a,d[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var d=c.nodeName;"SPAN"===d?c.style.color=a:"IMG"!==d&&(c.filled=a!==Q,this.setAttr("fillcolor",this.renderer.color(a,c,b,this)))},opacitySetter:sa,rotationSetter:function(a,b,c){c=c.style,this[b]=c[b]=a,c.left=-u(ea(a*Ca)+1)+"px",c.top=u(Z(a*Ca))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a,this[b]=a,ha(a)&&(a+="px"),this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){"inherit"===a&&(a="visible"),this.shadows&&p(this.shadows,function(c){c.style[b]=a}),"DIV"===c.nodeName&&(a="hidden"===a?"-999em":0,hb||(c.style[b]=a?"visible":"hidden"),b="top"),c.style[b]=a},xSetter:function(a,b,c){this[b]=a,"x"===b?b="left":"y"===b&&(b="top"),this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}},X=ka(P,X),X.prototype.ySetter=X.prototype.widthSetter=X.prototype.heightSetter=X.prototype.xSetter;var ga={Element:X,isIE8:wa.indexOf("MSIE 8.0")>-1,init:function(a,b,c,d){var e;if(this.alignedObjects=[],d=this.createElement(Ja).css(q(this.getStyle(d),{position:"relative"})),e=d.element,a.appendChild(d.element),this.isVML=!0,this.box=e,this.boxWrapper=d,this.cache={},this.setSize(b,c,!1),!y.namespaces.hcv){y.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{y.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(f){y.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,c,d){var e=this.createElement(),f=ca(a);return q(e,{members:[],left:(f?a.x:a)+1,top:(f?a.y:b)+1,width:(f?a.width:c)-1,height:(f?a.height:d)-1,getCSS:function(a){var b=a.element,c=b.nodeName,a=a.inverted,d=this.top-("shape"===c?b.offsetTop:0),e=this.left,b=e+this.width,f=d+this.height,d={clip:"rect("+u(a?e:d)+"px,"+u(a?f:b)+"px,"+u(a?b:f)+"px,"+u(a?d:e)+"px)"};return!a&&hb&&"DIV"===c&&q(d,{width:b+"px",height:f+"px"}),d},updateClipping:function(){p(e.members,function(a){a.element&&a.css(e.getCSS(a))})}})},color:function(a,b,c,d){var f,h,i,e=this,g=/^rgba/,j=Q;if(a&&a.linearGradient?i="gradient":a&&a.radialGradient&&(i="pattern"),i){var k,l,n,s,m,J,L,r,o=a.linearGradient||a.radialGradient,x="",a=a.stops,v=[],q=function(){h=['<fill colors="'+v.join(",")+'" opacity="',m,'" o:opacity2="',s,'" type="',i,'" ',x,'focus="100%" method="any" />'],Y(e.prepVML(h),null,null,b)};if(n=a[0],r=a[a.length-1],n[0]>0&&a.unshift([0,n[1]]),r[0]<1&&a.push([1,r[1]]),p(a,function(a,b){g.test(a[1])?(f=ya(a[1]),k=f.get("rgb"),l=f.get("a")):(k=a[1],l=1),v.push(100*a[0]+"% "+k),b?(m=l,J=k):(s=l,L=k)}),"fill"===c)if("gradient"===i)c=o.x1||o[0]||0,a=o.y1||o[1]||0,n=o.x2||o[2]||0,o=o.y2||o[3]||0,x='angle="'+(90-180*U.atan((o-a)/(n-c))/ma)+'"',q();else{var w,j=o.r,t=2*j,u=2*j,y=o.cx,B=o.cy,na=b.radialReference,j=function(){na&&(w=d.getBBox(),y+=(na[0]-w.x)/w.width-.5,B+=(na[1]-w.y)/w.height-.5,t*=na[2]/w.width,u*=na[2]/w.height),x='src="'+E.global.VMLRadialGradientURL+'" size="'+t+","+u+'" origin="0.5,0.5" position="'+y+","+B+'" color2="'+L+'" ',q()};d.added?j():d.onAdd=j,j=J}else j=k}else g.test(a)&&"IMG"!==b.tagName?(f=ya(a),h=["<",c,' opacity="',f.get("a"),'"/>'],Y(this.prepVML(h),null,null,b),j=f.get("rgb")):(j=b.getElementsByTagName(c),j.length&&(j[0].opacity=1,j[0].type="solid"),j=a);return j},prepVML:function(a){var b=this.isIE8,a=a.join("");return b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=-1===a.indexOf('style="')?a.replace("/>",' style="display:inline-block;behavior:url(#default#VML);" />'):a.replace('style="','style="display:inline-block;behavior:url(#default#VML);')):a=a.replace("<","<hcv:"),a},text:ta.prototype.html,path:function(a){var b={coordsize:"10 10"};return La(a)?b.d=a:ca(a)&&q(b,a),this.createElement("shape").attr(b)},circle:function(a,b,c){var d=this.symbol("circle");return ca(a)&&(c=a.r,b=a.y,a=a.x),d.isCircle=!0,d.r=c,d.attr({x:a,y:b})},g:function(a){var b;return a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a}),this.createElement(Ja).attr(b)},image:function(a,b,c,d,e){var f=this.createElement("img").attr({src:a});return arguments.length>1&&f.attr({x:b,y:c,width:d,height:e}),f},createElement:function(a){return"rect"===a?this.symbol(a):ta.prototype.createElement.call(this,a)},invertChild:function(a,b){var c=this,d=b.style,e="IMG"===a.tagName&&a.style;G(a,{flip:"x",left:z(d.width)-(e?z(e.top):1),top:z(d.height)-(e?z(e.left):1),rotation:-90}),p(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,h=e.r||c||d,c=e.innerR,d=Z(f),i=ea(f),j=Z(g),k=ea(g);return g-f===0?["x"]:(f=["wa",a-h,b-h,a+h,b+h,a+h*d,b+h*i,a+h*j,b+h*k],e.open&&!c&&f.push("e","M",a,b),f.push("at",a-c,b-c,a+c,b+c,a+c*j,b+c*k,a+c*d,b+c*i,"x","e"),f.isArc=!0,f)},circle:function(a,b,c,d,e){return e&&(c=d=2*e.r),e&&e.isCircle&&(a-=c/2,b-=d/2),["wa",a,b,a+c,b+d,a+c,b+d/2,a+c,b+d/2,"e"]},rect:function(a,b,c,d,e){return ta.prototype.symbols[r(e)&&e.r?"callout":"square"].call(0,a,b,c,d,e)}}};R.VMLRenderer=X=function(){this.init.apply(this,arguments)},X.prototype=w(ta.prototype,ga),Za=X}ta.prototype.measureSpanWidth=function(a,b){var d,c=y.createElement("span");return d=y.createTextNode(a),c.appendChild(d),G(c,b),this.box.appendChild(c),d=c.offsetWidth,Pa(c),d};var Lb;fa&&(R.CanVGRenderer=X=function(){xa="http://www.w3.org/1999/xhtml"},X.prototype.symbols={},Lb=function(){function a(){var d,a=b.length;for(d=0;a>d;d++)b[d]();b=[]}var b=[];return{push:function(c,d){0===b.length&&Qb(d,a),b.push(c)}}}(),Za=X),Sa.prototype={addLabel:function(){var l,a=this.axis,b=a.options,c=a.chart,d=a.horiz,e=a.categories,f=a.names,g=this.pos,h=b.labels,i=a.tickPositions,d=d&&e&&!h.step&&!h.staggerLines&&!h.rotation&&c.plotWidth/i.length||!d&&(c.margin[3]||.33*c.chartWidth),j=g===i[0],k=g===i[i.length-1],f=e?m(e[g],f[g],g):g,e=this.label,o=i.info;a.isDatetimeAxis&&o&&(l=b.dateTimeLabelFormats[o.higherRanks[g]||o.unitName]),this.isFirst=j,this.isLast=k,b=a.labelFormatter.call({axis:a,chart:c,isFirst:j,isLast:k,dateTimeLabelFormat:l,value:a.isLog?da(ia(f)):f}),g=d&&{width:v(1,u(d-2*(h.padding||10)))+"px"},g=q(g,h.style),r(e)?e&&e.attr({text:b}).css(g):(l={align:a.labelAlign},ha(h.rotation)&&(l.rotation=h.rotation),d&&h.ellipsis&&(l._clipHeight=a.len/i.length),this.label=r(b)&&h.enabled?c.renderer.text(b,0,0,h.useHTML).attr(l).css(g).add(a.labelGroup):null)},getLabelSize:function(){var a=this.label,b=this.axis;return a?a.getBBox()[b.horiz?"height":"width"]:0},getLabelSides:function(){var a=this.label.getBBox(),b=this.axis,c=b.horiz,d=b.options.labels,a=c?a.width:a.height,b=c?d.x-a*{left:0,center:.5,right:1}[b.labelAlign]:0;return[b,c?a+b:a]},handleOverflow:function(a,b){var l,o,n,c=!0,d=this.axis,e=this.isFirst,f=this.isLast,g=d.horiz?b.x:b.y,h=d.reversed,i=d.tickPositions,j=this.getLabelSides(),k=j[0],j=j[1],s=this.label.line||0;if(l=d.labelEdge,o=d.justifyLabels&&(e||f),l[s]===t||g+k>l[s]?l[s]=g+j:o||(c=!1),o){l=(o=d.justifyToPlot)?d.pos:0,o=o?l+d.len:d.chart.chartWidth;do a+=e?1:-1,n=d.ticks[i[a]];while(i[a]&&(!n||n.label.line!==s));d=n&&n.label.xy&&n.label.xy.x+n.getLabelSides()[e?0:1],e&&!h||f&&h?l>g+k&&(g=l-k,n&&g+j>d&&(c=!1)):g+j>o&&(g=o-j,n&&d>g+k&&(c=!1)),b.x=g}return c},getPosition:function(a,b,c,d){var e=this.axis,f=e.chart,g=d&&f.oldChartHeight||f.chartHeight;return{x:a?e.translate(b+c,null,null,d)+e.transB:e.left+e.offset+(e.opposite?(d&&f.oldChartWidth||f.chartWidth)-e.right-e.left:0),y:a?g-e.bottom+e.offset-(e.opposite?e.height:0):g-e.translate(b+c,null,null,d)-e.transB}},getLabelPosition:function(a,b,c,d,e,f,g,h){var i=this.axis,j=i.transA,k=i.reversed,l=i.staggerLines,o=i.chart.renderer.fontMetrics(e.style.fontSize).b,n=e.rotation,a=a+e.x-(f&&d?f*j*(k?-1:1):0),b=b+e.y-(f&&!d?f*j*(k?1:-1):0);return n&&2===i.side&&(b-=o-o*Z(n*Ca)),!r(e.y)&&!n&&(b+=o-c.getBBox().height/2),l&&(c.line=g/(h||1)%l,b+=c.line*(i.labelOffset/l)),{x:a,y:b}},getMarkPath:function(a,b,c,d,e,f){return f.crispLine(["M",a,b,"L",a+(e?0:-c),b+(e?c:0)],d)},render:function(a,b,c){var d=this.axis,e=d.options,f=d.chart.renderer,g=d.horiz,h=this.type,i=this.label,j=this.pos,k=e.labels,l=this.gridLine,o=h?h+"Grid":"grid",n=h?h+"Tick":"tick",s=e[o+"LineWidth"],p=e[o+"LineColor"],J=e[o+"LineDashStyle"],L=e[n+"Length"],o=e[n+"Width"]||0,x=e[n+"Color"],r=e[n+"Position"],n=this.mark,v=k.step,q=!0,u=d.tickmarkOffset,w=this.getPosition(g,j,u,b),y=w.x,w=w.y,B=g&&y===d.pos+d.len||!g&&w===d.pos?-1:1;this.isActive=!0,s&&(j=d.getPlotLinePath(j+u,s*B,b,!0),l===t&&(l={stroke:p,"stroke-width":s},J&&(l.dashstyle=J),h||(l.zIndex=1),b&&(l.opacity=0),this.gridLine=l=s?f.path(j).attr(l).add(d.gridGroup):null),!b&&l&&j&&l[this.isNew?"attr":"animate"]({d:j,opacity:c})),o&&L&&("inside"===r&&(L=-L),d.opposite&&(L=-L),h=this.getMarkPath(y,w,L,o*B,g,f),n?n.animate({d:h,opacity:c}):this.mark=f.path(h).attr({stroke:x,"stroke-width":o,opacity:c}).add(d.axisGroup)),i&&!isNaN(y)&&(i.xy=w=this.getLabelPosition(y,w,i,g,k,u,a,v),this.isFirst&&!this.isLast&&!m(e.showFirstLabel,1)||this.isLast&&!this.isFirst&&!m(e.showLastLabel,1)?q=!1:!d.isRadial&&!k.step&&!k.rotation&&!b&&0!==c&&(q=this.handleOverflow(a,w)),v&&a%v&&(q=!1),q&&!isNaN(w.y)?(w.opacity=c,i[this.isNew?"attr":"animate"](w),this.isNew=!1):i.attr("y",-9999))},destroy:function(){Oa(this,this.axis)}},R.PlotLineOrBand=function(a,b){this.axis=a,b&&(this.options=b,this.id=b.id)},R.PlotLineOrBand.prototype={render:function(){var p,a=this,b=a.axis,c=b.horiz,d=(b.pointRange||0)/2,e=a.options,f=e.label,g=a.label,h=e.width,i=e.to,j=e.from,k=r(j)&&r(i),l=e.value,o=e.dashStyle,n=a.svgElem,s=[],J=e.color,L=e.zIndex,x=e.events,q={},t=b.chart.renderer;if(b.isLog&&(j=za(j),i=za(i),l=za(l)),h)s=b.getPlotLinePath(l,h),q={stroke:J,"stroke-width":h},o&&(q.dashstyle=o);else{if(!k)return;j=v(j,b.min-d),i=C(i,b.max+d),s=b.getPlotBandPath(j,i,e),J&&(q.fill=J),e.borderWidth&&(q.stroke=e.borderColor,q["stroke-width"]=e.borderWidth)}if(r(L)&&(q.zIndex=L),n)s?n.animate({d:s},null,n.onGetPath):(n.hide(),n.onGetPath=function(){n.show()},g&&(a.label=g=g.destroy()));else if(s&&s.length&&(a.svgElem=n=t.path(s).attr(q).add(),x))for(p in d=function(b){n.on(b,function(c){x[b].apply(a,[c])})},x)d(p);return f&&r(f.text)&&s&&s.length&&b.width>0&&b.height>0?(f=w({align:c&&k&&"center",x:c?!k&&4:10,verticalAlign:!c&&k&&"middle",y:c?k?16:10:k?6:-4,rotation:c&&!k&&90},f),g||(q={align:f.textAlign||f.align,rotation:f.rotation},r(L)&&(q.zIndex=L),a.label=g=t.text(f.text,0,0,f.useHTML).attr(q).css(f.style).add()),b=[s[1],s[4],m(s[6],s[1])],s=[s[2],s[5],m(s[7],s[2])],c=Na(b),k=Na(s),g.align(f,!1,{x:c,y:k,width:Ba(b)-c,height:Ba(s)-k}),g.show()):g&&g.hide(),a},destroy:function(){ja(this.axis.plotLinesAndBands,this),delete this.axis,Oa(this)}},la.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,gridLineColor:"#C0C0C0",labels:N,lineColor:"#C0D0E0",lineWidth:1,minPadding:.01,maxPadding:.01,minorGridLineColor:"#E0E0E0",minorGridLineWidth:1,minorTickColor:"#A0A0A0",minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickColor:"#C0D0E0",tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",tickWidth:1,title:{align:"middle",style:{color:"#707070"}},type:"linear"},defaultYAxisOptions:{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8,y:3},lineWidth:0,maxPadding:.05,minPadding:.05,startOnTick:!0,tickWidth:0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return Ga(this.total,-1)},style:N.style}},defaultLeftAxisOptions:{labels:{x:-15,y:null},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15,y:null},title:{rotation:90}},defaultBottomAxisOptions:{labels:{x:0,y:20},title:{rotation:0}},defaultTopAxisOptions:{labels:{x:0,y:-15},title:{rotation:0}},init:function(a,b){var c=b.isX;this.horiz=a.inverted?!c:c,this.coll=(this.isXAxis=c)?"xAxis":"yAxis",this.opposite=b.opposite,this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3),this.setOptions(b);var d=this.options,e=d.type;this.labelFormatter=d.labels.formatter||this.defaultLabelFormatter,this.userOptions=b,this.minPixelPadding=0,this.chart=a,this.reversed=d.reversed,this.zoomEnabled=d.zoomEnabled!==!1,this.categories=d.categories||"category"===e,this.names=[],this.isLog="logarithmic"===e,this.isDatetimeAxis="datetime"===e,this.isLinked=r(d.linkedTo),this.tickmarkOffset=this.categories&&"between"===d.tickmarkPlacement?.5:0,this.ticks={},this.labelEdge=[],this.minorTicks={},this.plotLinesAndBands=[],this.alternateBands={},this.len=0,this.minRange=this.userMinRange=d.minRange||d.maxZoom,this.range=d.range,this.offset=d.offset||0,this.stacks={},this.oldStacks={},this.min=this.max=null,this.crosshair=m(d.crosshair,qa(a.options.tooltip.crosshairs)[c?0:1],!1);var f,d=this.options.events;-1===Da(this,a.axes)&&(c&&!this.isColorAxis?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this)),this.series=this.series||[],a.inverted&&c&&this.reversed===t&&(this.reversed=!0),this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(f in d)K(this,f,d[f]);this.isLog&&(this.val2lin=za,this.lin2val=ia)},setOptions:function(a){this.options=w(this.defaultOptions,this.isXAxis?{}:this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],w(E[this.coll],a))},defaultLabelFormatter:function(){var g,a=this.axis,b=this.value,c=a.categories,d=this.dateTimeLabelFormat,e=E.lang.numericSymbols,f=e&&e.length,h=a.options.labels.format,a=a.isLog?b:a.tickInterval;if(h)g=Ia(h,this);else if(c)g=b;else if(d)g=cb(d,b);else if(f&&a>=1e3)for(;f--&&g===t;)c=Math.pow(1e3,f+1),a>=c&&null!==e[f]&&(g=Ga(b/c,-1)+e[f]);return g===t&&(g=M(b)>=1e4?Ga(b,0):Ga(b,-1,t,"")),g},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1,a.dataMin=a.dataMax=null,a.buildStacks&&a.buildStacks(),p(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries){var d;d=c.options.threshold;var e;a.hasVisibleSeries=!0,a.isLog&&0>=d&&(d=null),a.isXAxis?(d=c.xData,d.length&&(a.dataMin=C(m(a.dataMin,d[0]),Na(d)),a.dataMax=v(m(a.dataMax,d[0]),Ba(d)))):(c.getExtremes(),e=c.dataMax,c=c.dataMin,r(c)&&r(e)&&(a.dataMin=C(m(a.dataMin,c),c),a.dataMax=v(m(a.dataMax,e),e)),r(d)&&(a.dataMin>=d?(a.dataMin=d,a.ignoreMinPadding=!0):a.dataMax<d&&(a.dataMax=d,a.ignoreMaxPadding=!0)))}})},translate:function(a,b,c,d,e,f){var g=1,h=0,i=d?this.oldTransA:this.transA,d=d?this.oldMin:this.min,j=this.minPixelPadding,e=(this.options.ordinal||this.isLog&&e)&&this.lin2val;return i||(i=this.transA),c&&(g*=-1,h=this.len),this.reversed&&(g*=-1,h-=g*(this.sector||this.len)),b?(a=a*g+h,a-=j,a=a/i+d,e&&(a=this.lin2val(a))):(e&&(a=this.val2lin(a)),"between"===f&&(f=.5),a=g*(a-d)*i+h+g*j+(ha(f)?i*f*this.pointRange:0)),a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,d,e){var i,j,o,f=this.chart,g=this.left,h=this.top,k=c&&f.oldChartHeight||f.chartHeight,l=c&&f.oldChartWidth||f.chartWidth;return i=this.transB,e=m(e,this.translate(a,null,null,c)),a=c=u(e+i),i=j=u(k-e-i),isNaN(e)?o=!0:this.horiz?(i=h,j=k-this.bottom,(g>a||a>g+this.width)&&(o=!0)):(a=g,c=l-this.right,(h>i||i>h+this.height)&&(o=!0)),o&&!d?null:f.renderer.crispLine(["M",a,i,"L",c,j],b||1)},getLinearTickPositions:function(a,b,c){var d,e=da(T(b/a)*a),f=da(Ka(c/a)*a),g=[];if(b===c&&ha(b))return[b];for(b=e;f>=b&&(g.push(b),b=da(b+a),b!==d);)d=b;return g},getMinorTickPositions:function(){var e,a=this.options,b=this.tickPositions,c=this.minorTickInterval,d=[];if(this.isLog)for(e=b.length,a=1;e>a;a++)d=d.concat(this.getLogTickPositions(c,b[a-1],b[a],!0));else if(this.isDatetimeAxis&&"auto"===a.minorTickInterval)d=d.concat(this.getTimeTicks(this.normalizeTimeTickInterval(c),this.min,this.max,a.startOfWeek)),d[0]<this.min&&d.shift();else for(b=this.min+(b[0]-this.min)%c;b<=this.max;b+=c)d.push(b);return d},adjustForMinRange:function(){var d,f,g,h,i,j,a=this.options,b=this.min,c=this.max,e=this.dataMax-this.dataMin>=this.minRange;if(this.isXAxis&&this.minRange===t&&!this.isLog&&(r(a.min)||r(a.max)?this.minRange=null:(p(this.series,function(a){for(i=a.xData,g=j=a.xIncrement?1:i.length-1;g>0;g--)h=i[g]-i[g-1],(f===t||f>h)&&(f=h)}),this.minRange=C(5*f,this.dataMax-this.dataMin))),c-b<this.minRange){var k=this.minRange;d=(k-c+b)/2,d=[b-d,m(a.min,b-d)],e&&(d[2]=this.dataMin),b=Ba(d),c=[b+k,m(a.max,b+k)],e&&(c[2]=this.dataMax),c=Na(c),k>c-b&&(d[0]=c-k,d[1]=m(a.min,c-k),b=Ba(d))}this.min=b,this.max=c},setAxisTranslation:function(a){var e,b=this,c=b.max-b.min,d=b.axisPointRange||0,f=0,g=0,h=b.linkedParent,i=!!b.categories,j=b.transA;(b.isXAxis||i||d)&&(h?(f=h.minPointOffset,g=h.pointRangePadding):p(b.series,function(a){var h=i?1:b.isXAxis?a.pointRange:b.axisPointRange||0,j=a.options.pointPlacement,n=a.closestPointRange;h>c&&(h=0),d=v(d,h),f=v(f,Fa(j)?0:h/2),g=v(g,"on"===j?0:h),!a.noSharedTooltip&&r(n)&&(e=r(e)?C(e,n):n)}),h=b.ordinalSlope&&e?b.ordinalSlope/e:1,b.minPointOffset=f*=h,b.pointRangePadding=g*=h,b.pointRange=C(d,c),b.closestPointRange=e),a&&(b.oldTransA=j),b.translationSlope=b.transA=j=b.len/(c+g||1),b.transB=b.horiz?b.left:b.bottom,b.minPixelPadding=j*f},setTickPositions:function(a){var s,b=this,c=b.chart,d=b.options,e=b.isLog,f=b.isDatetimeAxis,g=b.isXAxis,h=b.isLinked,i=b.options.tickPositioner,j=d.maxPadding,k=d.minPadding,l=d.tickInterval,o=d.minTickInterval,n=d.tickPixelInterval,$=b.categories;h?(b.linkedParent=c[b.coll][d.linkedTo],c=b.linkedParent.getExtremes(),b.min=m(c.min,c.dataMin),b.max=m(c.max,c.dataMax),d.type!==b.linkedParent.options.type&&ra(11,1)):(b.min=m(b.userMin,d.min,b.dataMin),b.max=m(b.userMax,d.max,b.dataMax)),e&&(!a&&C(b.min,m(b.dataMin,b.min))<=0&&ra(10,1),b.min=da(za(b.min)),b.max=da(za(b.max))),b.range&&r(b.max)&&(b.userMin=b.min=v(b.min,b.max-b.range),b.userMax=b.max,b.range=null),b.beforePadding&&b.beforePadding(),b.adjustForMinRange(),$||b.axisPointRange||b.usePercentage||h||!r(b.min)||!r(b.max)||!(c=b.max-b.min)||(r(d.min)||r(b.userMin)||!k||!(b.dataMin<0)&&b.ignoreMinPadding||(b.min-=c*k),r(d.max)||r(b.userMax)||!j||!(b.dataMax>0)&&b.ignoreMaxPadding||(b.max+=c*j)),ha(d.floor)&&(b.min=v(b.min,d.floor)),ha(d.ceiling)&&(b.max=C(b.max,d.ceiling)),b.min===b.max||void 0===b.min||void 0===b.max?b.tickInterval=1:h&&!l&&n===b.linkedParent.options.tickPixelInterval?b.tickInterval=b.linkedParent.tickInterval:(b.tickInterval=m(l,$?1:(b.max-b.min)*n/v(b.len,n)),!r(l)&&b.len<n&&!this.isRadial&&!this.isLog&&!$&&d.startOnTick&&d.endOnTick&&(s=!0,b.tickInterval/=4)),g&&!a&&p(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)}),b.setAxisTranslation(!0),b.beforeSetTickPositions&&b.beforeSetTickPositions(),b.postProcessTickInterval&&(b.tickInterval=b.postProcessTickInterval(b.tickInterval)),b.pointRange&&(b.tickInterval=v(b.pointRange,b.tickInterval)),!l&&b.tickInterval<o&&(b.tickInterval=o),f||e||l||(b.tickInterval=nb(b.tickInterval,null,mb(b.tickInterval),d)),b.minorTickInterval="auto"===d.minorTickInterval&&b.tickInterval?b.tickInterval/5:d.minorTickInterval,b.tickPositions=a=d.tickPositions?[].concat(d.tickPositions):i&&i.apply(b,[b.min,b.max]),a||(!b.ordinalPositions&&(b.max-b.min)/b.tickInterval>v(2*b.len,200)&&ra(19,!0),a=f?b.getTimeTicks(b.normalizeTimeTickInterval(b.tickInterval,d.units),b.min,b.max,d.startOfWeek,b.ordinalPositions,b.closestPointRange,!0):e?b.getLogTickPositions(b.tickInterval,b.min,b.max):b.getLinearTickPositions(b.tickInterval,b.min,b.max),s&&a.splice(1,a.length-2),b.tickPositions=a),h||(e=a[0],f=a[a.length-1],h=b.minPointOffset||0,d.startOnTick?b.min=e:b.min-h>e&&a.shift(),d.endOnTick?b.max=f:b.max+h<f&&a.pop(),1===a.length&&(d=M(b.max)>1e13?1:.001,b.min-=d,b.max+=d))},setMaxTicks:function(){var a=this.chart,b=a.maxTicks||{},c=this.tickPositions,d=this._maxTicksKey=[this.coll,this.pos,this.len].join("-");!this.isLinked&&!this.isDatetimeAxis&&c&&c.length>(b[d]||0)&&this.options.alignTicks!==!1&&(b[d]=c.length),a.maxTicks=b},adjustTickAmount:function(){var a=this._maxTicksKey,b=this.tickPositions,c=this.chart.maxTicks;if(c&&c[a]&&!this.isDatetimeAxis&&!this.categories&&!this.isLinked&&this.options.alignTicks!==!1&&this.min!==t){var d=this.tickAmount,e=b.length;if(this.tickAmount=a=c[a],a>e){for(;b.length<a;)b.push(da(b[b.length-1]+this.tickInterval));this.transA*=(e-1)/(a-1),this.max=b[b.length-1]}r(d)&&a!==d&&(this.isDirty=!0)}},setScale:function(){var b,c,d,e,a=this.stacks;if(this.oldMin=this.min,this.oldMax=this.max,this.oldAxisLength=this.len,this.setAxisSize(),e=this.len!==this.oldAxisLength,p(this.series,function(a){(a.isDirtyData||a.isDirty||a.xAxis.isDirty)&&(d=!0)}),e||d||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax){if(!this.isXAxis)for(b in a)for(c in a[b])a[b][c].total=null,a[b][c].cum=0;this.forceRedraw=!1,this.getSeriesExtremes(),this.setTickPositions(),this.oldUserMin=this.userMin,this.oldUserMax=this.userMax,this.isDirty||(this.isDirty=e||this.min!==this.oldMin||this.max!==this.oldMax)}else if(!this.isXAxis){this.oldStacks&&(a=this.stacks=this.oldStacks);for(b in a)for(c in a[b])a[b][c].cum=a[b][c].total}this.setMaxTicks()},setExtremes:function(a,b,c,d,e){var f=this,g=f.chart,c=m(c,!0),e=q(e,{min:a,max:b});D(f,"setExtremes",e,function(){f.userMin=a,f.userMax=b,f.eventArgs=e,f.isDirtyExtremes=!0,c&&g.redraw(d)})},zoom:function(a,b){var c=this.dataMin,d=this.dataMax,e=this.options;return this.allowZoomOutside||(r(c)&&a<=C(c,m(e.min,c))&&(a=t),r(d)&&b>=v(d,m(e.max,d))&&(b=t)),this.displayBtn=a!==t||b!==t,this.setExtremes(a,b,!1,t,{trigger:"zoom"}),!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,d=this.horiz,e=m(b.width,a.plotWidth-c+(b.offsetRight||0)),f=m(b.height,a.plotHeight),g=m(b.top,a.plotTop),b=m(b.left,a.plotLeft+c),c=/%$/;c.test(f)&&(f=parseInt(f,10)/100*a.plotHeight),c.test(g)&&(g=parseInt(g,10)/100*a.plotHeight+a.plotTop),this.left=b,this.top=g,this.width=e,this.height=f,this.bottom=a.chartHeight-f-g,this.right=a.chartWidth-e-b,this.len=v(d?e:f,0),this.pos=d?b:g},getExtremes:function(){var a=this.isLog;return{min:a?da(ia(this.min)):this.min,max:a?da(ia(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,c=b?ia(this.min):this.min,b=b?ia(this.max):this.max;return c>a||null===a?a=c:a>b&&(a=b),this.translate(a,0,1,0,1)},autoLabelAlign:function(a){return a=(m(a,0)-90*this.side+720)%360,a>15&&165>a?"right":a>195&&345>a?"left":"center"},getOffset:function(){var j,l,q,y,z,A,B,a=this,b=a.chart,c=b.renderer,d=a.options,e=a.tickPositions,f=a.ticks,g=a.horiz,h=a.side,i=b.inverted?[1,0,3,2][h]:h,k=0,o=0,n=d.title,s=d.labels,$=0,J=b.axisOffset,L=b.clipOffset,x=[-1,1,1,-1][h],u=1,w=m(s.maxStaggerLines,5),na=2===h?c.fontMetrics(s.style.fontSize).b:0;if(a.hasData=j=a.hasVisibleSeries||r(a.min)&&r(a.max)&&!!e,a.showAxis=b=j||m(d.showEmpty,!0),a.staggerLines=a.horiz&&s.staggerLines,a.axisGroup||(a.gridGroup=c.g("grid").attr({zIndex:d.gridZIndex||1}).add(),a.axisGroup=c.g("axis").attr({zIndex:d.zIndex||2}).add(),a.labelGroup=c.g("axis-labels").attr({zIndex:s.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels").add()),j||a.isLinked){if(a.labelAlign=m(s.align||a.autoLabelAlign(s.rotation)),p(e,function(b){f[b]?f[b].addLabel():f[b]=new Sa(a,b)}),a.horiz&&!a.staggerLines&&w&&!s.rotation){for(q=a.reversed?[].concat(e).reverse():e;w>u;){for(j=[],y=!1,s=0;s<q.length;s++)z=q[s],A=(A=f[z].label&&f[z].label.getBBox())?A.width:0,B=s%u,A&&(z=a.translate(z),j[B]!==t&&z<j[B]&&(y=!0),j[B]=z+A);if(!y)break;u++}u>1&&(a.staggerLines=u)}p(e,function(b){(0===h||2===h||{1:"left",3:"right"}[h]===a.labelAlign)&&($=v(f[b].getLabelSize(),$))}),a.staggerLines&&($*=a.staggerLines,a.labelOffset=$)}else for(q in f)f[q].destroy(),delete f[q];n&&n.text&&n.enabled!==!1&&(a.axisTitle||(a.axisTitle=c.text(n.text,0,0,n.useHTML).attr({zIndex:7,rotation:n.rotation||0,align:n.textAlign||{low:"left",middle:"center",high:"right"}[n.align]}).addClass("highcharts-"+this.coll.toLowerCase()+"-title").css(n.style).add(a.axisGroup),a.axisTitle.isNew=!0),b&&(k=a.axisTitle.getBBox()[g?"height":"width"],o=m(n.margin,g?5:10),l=n.offset),a.axisTitle[b?"show":"hide"]()),a.offset=x*m(d.offset,J[h]),a.axisTitleMargin=m(l,$+o+($&&x*d.labels[g?"y":"x"]-na)),J[h]=v(J[h],a.axisTitleMargin+k+x*a.offset),L[i]=v(L[i],2*T(d.lineWidth/2))},getLinePath:function(a){var b=this.chart,c=this.opposite,d=this.offset,e=this.horiz,f=this.left+(c?this.width:0)+d,d=b.chartHeight-this.bottom-(c?this.height:0)+d;return c&&(a*=-1),b.renderer.crispLine(["M",e?this.left:f,e?d:this.top,"L",e?b.chartWidth-this.right:f,e?d:b.chartHeight-this.bottom],a)},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,d=this.len,e=this.options.title,f=a?b:c,g=this.opposite,h=this.offset,i=z(e.style.fontSize||12),d={low:f+(a?0:d),middle:f+d/2,high:f+(a?d:0)}[e.align],b=(a?c+this.height:b)+(a?1:-1)*(g?-1:1)*this.axisTitleMargin+(2===this.side?i:0);
|
3 |
return{x:a?d:b+(g?this.width:0)+h+(e.x||0),y:a?b-(g?this.height:0)+h:d+(e.y||0)}},render:function(){var j,u,z,a=this,b=a.horiz,c=a.reversed,d=a.chart,e=d.renderer,f=a.options,g=a.isLog,h=a.isLinked,i=a.tickPositions,k=a.axisTitle,l=a.ticks,o=a.minorTicks,n=a.alternateBands,s=f.stackLabels,m=f.alternateGridColor,J=a.tickmarkOffset,L=f.lineWidth,x=d.hasRendered&&r(a.oldMin)&&!isNaN(a.oldMin),q=a.hasData,v=a.showAxis,w=f.labels.overflow,y=a.justifyLabels=b&&w!==!1;a.labelEdge.length=0,a.justifyToPlot="justify"===w,p([l,o,n],function(a){for(var b in a)a[b].isActive=!1}),(q||h)&&(a.minorTickInterval&&!a.categories&&p(a.getMinorTickPositions(),function(b){o[b]||(o[b]=new Sa(a,b,"minor")),x&&o[b].isNew&&o[b].render(null,!0),o[b].render(null,!1,1)}),i.length&&(j=i.slice(),(b&&c||!b&&!c)&&j.reverse(),y&&(j=j.slice(1).concat([j[0]])),p(j,function(b,c){y&&(c=c===j.length-1?0:c+1),(!h||b>=a.min&&b<=a.max)&&(l[b]||(l[b]=new Sa(a,b)),x&&l[b].isNew&&l[b].render(c,!0,.1),l[b].render(c,!1,1))}),J&&0===a.min&&(l[-1]||(l[-1]=new Sa(a,-1,null,!0)),l[-1].render(-1))),m&&p(i,function(b,c){c%2===0&&b<a.max&&(n[b]||(n[b]=new R.PlotLineOrBand(a)),u=b+J,z=i[c+1]!==t?i[c+1]+J:a.max,n[b].options={from:g?ia(u):u,to:g?ia(z):z,color:m},n[b].render(),n[b].isActive=!0)}),a._addedPlotLB||(p((f.plotLines||[]).concat(f.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0)),p([l,o,n],function(a){var b,c,e=[],f=va?va.duration||500:0,g=function(){for(c=e.length;c--;)a[e[c]]&&!a[e[c]].isActive&&(a[e[c]].destroy(),delete a[e[c]])};for(b in a)a[b].isActive||(a[b].render(b,!1,0),a[b].isActive=!1,e.push(b));a!==n&&d.hasRendered&&f?f&&setTimeout(g,f):g()}),L&&(b=a.getLinePath(L),a.axisLine?a.axisLine.animate({d:b}):a.axisLine=e.path(b).attr({stroke:f.lineColor,"stroke-width":L,zIndex:7}).add(a.axisGroup),a.axisLine[v?"show":"hide"]()),k&&v&&(k[k.isNew?"attr":"animate"](a.getTitlePosition()),k.isNew=!1),s&&s.enabled&&a.renderStackTotals(),a.isDirty=!1},redraw:function(){var a=this.chart.pointer;a&&a.reset(!0),this.render(),p(this.plotLinesAndBands,function(a){a.render()}),p(this.series,function(a){a.isDirty=!0})},destroy:function(a){var d,b=this,c=b.stacks,e=b.plotLinesAndBands;a||W(b);for(d in c)Oa(c[d]),c[d]=null;for(p([b.ticks,b.minorTicks,b.alternateBands],function(a){Oa(a)}),a=e.length;a--;)e[a].destroy();p("stackTotalGroup,axisLine,axisTitle,axisGroup,cross,gridGroup,labelGroup".split(","),function(a){b[a]&&(b[a]=b[a].destroy())}),this.cross&&this.cross.destroy()},drawCrosshair:function(a,b){if(this.crosshair)if((r(b)||!m(this.crosshair.snap,!0))===!1)this.hideCrosshair();else{var c,d=this.crosshair,e=d.animation;m(d.snap,!0)?r(b)&&(c=this.chart.inverted!=this.horiz?b.plotX:this.len-b.plotY):c=this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos,c=this.isRadial?this.getPlotLinePath(this.isXAxis?b.x:m(b.stackY,b.y)):this.getPlotLinePath(null,null,null,null,c),null===c?this.hideCrosshair():this.cross?this.cross.attr({visibility:"visible"})[e?"animate":"attr"]({d:c},e):(e={"stroke-width":d.width||1,stroke:d.color||"#C0C0C0",zIndex:d.zIndex||2},d.dashStyle&&(e.dashstyle=d.dashStyle),this.cross=this.chart.renderer.path(c).attr(e).add())}},hideCrosshair:function(){this.cross&&this.cross.hide()}},q(la.prototype,{getPlotBandPath:function(a,b){var c=this.getPlotLinePath(b),d=this.getPlotLinePath(a);return d&&c?d.push(c[4],c[5],c[1],c[2]):d=null,d},addPlotBand:function(a){this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){this.addPlotBandOrLine(a,"plotLines")},addPlotBandOrLine:function(a,b){var c=new R.PlotLineOrBand(this,a).render(),d=this.userOptions;return c&&(b&&(d[b]=d[b]||[],d[b].push(a)),this.plotLinesAndBands.push(c)),c},removePlotBandOrLine:function(a){for(var b=this.plotLinesAndBands,c=this.options,d=this.userOptions,e=b.length;e--;)b[e].id===a&&b[e].destroy();p([c.plotLines||[],d.plotLines||[],c.plotBands||[],d.plotBands||[]],function(b){for(e=b.length;e--;)b[e].id===a&&ja(b,b[e])})}}),la.prototype.getTimeTicks=function(a,b,c,d){var h,e=[],f={},g=E.global.useUTC,i=new Date(b-Ra),j=a.unitRange,k=a.count;if(r(b)){j>=A.second&&(i.setMilliseconds(0),i.setSeconds(j>=A.minute?0:k*T(i.getSeconds()/k))),j>=A.minute&&i[Db](j>=A.hour?0:k*T(i[pb]()/k)),j>=A.hour&&i[Eb](j>=A.day?0:k*T(i[qb]()/k)),j>=A.day&&i[sb](j>=A.month?1:k*T(i[Xa]()/k)),j>=A.month&&(i[Fb](j>=A.year?0:k*T(i[fb]()/k)),h=i[gb]()),j>=A.year&&(h-=h%k,i[Gb](h)),j===A.week&&i[sb](i[Xa]()-i[rb]()+m(d,1)),b=1,Ra&&(i=new Date(i.getTime()+Ra)),h=i[gb]();for(var d=i.getTime(),l=i[fb](),o=i[Xa](),n=g?Ra:(864e5+6e4*i.getTimezoneOffset())%864e5;c>d;)e.push(d),j===A.year?d=eb(h+b*k,0):j===A.month?d=eb(h,l+b*k):g||j!==A.day&&j!==A.week?d+=j*k:d=eb(h,l,o+b*k*(j===A.day?1:7)),b++;e.push(d),p(vb(e,function(a){return j<=A.hour&&a%A.day===n}),function(a){f[a]="day"})}return e.info=q(a,{higherRanks:f,totalRange:j*k}),e},la.prototype.normalizeTimeTickInterval=function(a,b){var g,c=b||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],d=c[c.length-1],e=A[d[0]],f=d[1];for(g=0;g<c.length&&(d=c[g],e=A[d[0]],f=d[1],!(c[g+1]&&a<=(e*f[f.length-1]+A[c[g+1][0]])/2));g++);return e===A.year&&5*e>a&&(f=[1,2,5]),c=nb(a/e,f,"year"===d[0]?v(mb(a/e),1):1),{unitRange:e,count:c,unitName:d[0]}},la.prototype.getLogTickPositions=function(a,b,c,d){var e=this.options,f=this.len,g=[];if(d||(this._minorAutoInterval=null),a>=.5)a=u(a),g=this.getLinearTickPositions(a,b,c);else if(a>=.08)for(var h,i,j,k,l,f=T(b),e=a>.3?[1,2,4]:a>.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];c+1>f&&!l;f++)for(i=e.length,h=0;i>h&&!l;h++)j=za(ia(f)*e[h]),j>b&&(!d||c>=k)&&g.push(k),k>c&&(l=!0),k=j;else b=ia(b),c=ia(c),a=e[d?"minorTickInterval":"tickInterval"],a=m("auto"===a?null:a,this._minorAutoInterval,(c-b)*(e.tickPixelInterval/(d?5:1))/((d?f/this.tickPositions.length:f)||1)),a=nb(a,null,mb(a)),g=Ua(this.getLinearTickPositions(a,b,c),za),d||(this._minorAutoInterval=a/5);return d||(this.tickInterval=a),g};var Mb=R.Tooltip=function(){this.init.apply(this,arguments)};Mb.prototype={init:function(a,b){var c=b.borderWidth,d=b.style,e=z(d.padding);this.chart=a,this.options=b,this.crosshairs=[],this.now={x:0,y:0},this.isHidden=!0,this.label=a.renderer.label("",0,0,b.shape||"callout",null,null,b.useHTML,null,"tooltip").attr({padding:e,fill:b.backgroundColor,"stroke-width":c,r:b.borderRadius,zIndex:8}).css(d).css({padding:0}).add().attr({y:-9999}),fa||this.label.shadow(b.shadow),this.shared=b.shared},destroy:function(){this.label&&(this.label=this.label.destroy()),clearTimeout(this.hideTimer),clearTimeout(this.tooltipTimeout)},move:function(a,b,c,d){var e=this,f=e.now,g=e.options.animation!==!1&&!e.isHidden,h=e.followPointer||e.len>1;q(f,{x:g?(2*f.x+a)/3:a,y:g?(f.y+b)/2:b,anchorX:h?t:g?(2*f.anchorX+c)/3:c,anchorY:h?t:g?(f.anchorY+d)/2:d}),e.label.attr(f),g&&(M(a-f.x)>1||M(b-f.y)>1)&&(clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){e&&e.move(a,b,c,d)},32))},hide:function(){var b,a=this;clearTimeout(this.hideTimer),this.isHidden||(b=this.chart.hoverPoints,this.hideTimer=setTimeout(function(){a.label.fadeOut(),a.isHidden=!0},m(this.options.hideDelay,500)),b&&p(b,function(a){a.setState()}),this.chart.hoverPoints=null)},getAnchor:function(a,b){var c,i,d=this.chart,e=d.inverted,f=d.plotTop,g=0,h=0,a=qa(a);return c=a[0].tooltipPos,this.followPointer&&b&&(b.chartX===t&&(b=d.pointer.normalize(b)),c=[b.chartX-d.plotLeft,b.chartY-f]),c||(p(a,function(a){i=a.series.yAxis,g+=a.plotX,h+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!e&&i?i.top-f:0)}),g/=a.length,h/=a.length,c=[e?d.plotWidth-h:g,this.shared&&!e&&a.length>1&&b?b.chartY-f:e?d.plotHeight-g:h]),Ua(c,u)},getPosition:function(a,b,c){var g,d=this.chart,e=this.distance,f={},h=["y",d.chartHeight,b,c.plotY+d.plotTop],i=["x",d.chartWidth,a,c.plotX+d.plotLeft],j=c.ttBelow||d.inverted&&!c.negative||!d.inverted&&c.negative,k=function(a,b,c,d){var g=d-e>c,b=b>d+e+c,c=d-e-c;if(d+=e,j&&b)f[a]=d;else if(!j&&g)f[a]=c;else if(g)f[a]=c;else{if(!b)return!1;f[a]=d}},l=function(a,b,c,d){return e>d||d>b-e?!1:void(f[a]=c/2>d?1:d>b-c/2?b-c-2:d-c/2)},o=function(a){var b=h;h=i,i=b,g=a},n=function(){k.apply(0,h)!==!1?l.apply(0,i)===!1&&!g&&(o(!0),n()):g?f.x=f.y=0:(o(!0),n())};return(d.inverted||this.len>1)&&o(),n(),f},defaultFormatter:function(a){var d,b=this.points||qa(this),c=b[0].series;return d=[a.tooltipHeaderFormatter(b[0])],p(b,function(a){c=a.series,d.push(c.tooltipFormatter&&c.tooltipFormatter(a)||a.point.tooltipFormatter(c.tooltipOptions.pointFormat))}),d.push(a.options.footerFormat||""),d.join("")},refresh:function(a,b){var f,g,i,c=this.chart,d=this.label,e=this.options,h={},j=[];i=e.formatter||this.defaultFormatter;var k,h=c.hoverPoints,l=this.shared;clearTimeout(this.hideTimer),this.followPointer=qa(a)[0].series.tooltipOptions.followPointer,g=this.getAnchor(a,b),f=g[0],g=g[1],!l||a.series&&a.series.noSharedTooltip?h=a.getLabelConfig():(c.hoverPoints=a,h&&p(h,function(a){a.setState()}),p(a,function(a){a.setState("hover"),j.push(a.getLabelConfig())}),h={x:a[0].category,y:a[0].y},h.points=j,this.len=j.length,a=a[0]),i=i.call(h,this),h=a.series,this.distance=m(h.tooltipOptions.distance,16),i===!1?this.hide():(this.isHidden&&(bb(d),d.attr("opacity",1).show()),d.attr({text:i}),k=e.borderColor||a.color||h.color||"#606060",d.attr({stroke:k}),this.updatePosition({plotX:f,plotY:g,negative:a.negative,ttBelow:a.ttBelow}),this.isHidden=!1),D(c,"tooltipRefresh",{text:i,x:f+c.plotLeft,y:g+c.plotTop,borderColor:k})},updatePosition:function(a){var b=this.chart,c=this.label,c=(this.options.positioner||this.getPosition).call(this,c.width,c.height,a);this.move(u(c.x),u(c.y),a.plotX+b.plotLeft,a.plotY+b.plotTop)},tooltipHeaderFormatter:function(a){var h,b=a.series,c=b.tooltipOptions,d=c.dateTimeLabelFormats,e=c.xDateFormat,f=b.xAxis,g=f&&"datetime"===f.options.type&&ha(a.key),c=c.headerFormat,f=f&&f.closestPointRange;if(g&&!e){if(f){for(h in A)if(A[h]>=f||A[h]<=A.day&&a.key%A[h]>0){e=d[h];break}}else e=d.day;e=e||d.year}return g&&e&&(c=c.replace("{point.key}","{point.key:"+e+"}")),Ia(c,{point:a,series:b})}};var oa;$a=y.documentElement.ontouchstart!==t;var Wa=R.Pointer=function(a,b){this.init(a,b)};if(Wa.prototype={init:function(a,b){var f,c=b.chart,d=c.events,e=fa?"":c.zoomType,c=a.inverted;this.options=b,this.chart=a,this.zoomX=f=/x/.test(e),this.zoomY=e=/y/.test(e),this.zoomHor=f&&!c||e&&c,this.zoomVert=e&&!c||f&&c,this.hasZoom=f||e,this.runChartClick=d&&!!d.click,this.pinchDown=[],this.lastValidTouch={},R.Tooltip&&b.tooltip.enabled&&(a.tooltip=new Mb(a,b.tooltip),this.followTouchMove=b.tooltip.followTouchMove),this.setDOMEvents()},normalize:function(a,b){var c,d,a=a||window.event,a=Sb(a);return a.target||(a.target=a.srcElement),d=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a,b||(this.chartPosition=b=Rb(this.chart.container)),d.pageX===t?(c=v(a.x,a.clientX-b.left),d=a.y):(c=d.pageX-b.left,d=d.pageY-b.top),q(a,{chartX:u(c),chartY:u(d)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};return p(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})}),b},getIndex:function(a){var b=this.chart;return b.inverted?b.plotHeight+b.plotTop-a.chartY:a.chartX-b.plotLeft},runPointActions:function(a){var e,f,i,j,b=this.chart,c=b.series,d=b.tooltip,g=b.hoverPoint,h=b.hoverSeries,k=b.chartWidth,l=this.getIndex(a);if(d&&this.options.tooltip.shared&&(!h||!h.noSharedTooltip)){for(f=[],i=c.length,j=0;i>j;j++)c[j].visible&&c[j].options.enableMouseTracking!==!1&&!c[j].noSharedTooltip&&c[j].singularTooltips!==!0&&c[j].tooltipPoints.length&&(e=c[j].tooltipPoints[l])&&e.series&&(e._dist=M(l-e.clientX),k=C(k,e._dist),f.push(e));for(i=f.length;i--;)f[i]._dist>k&&f.splice(i,1);f.length&&f[0].clientX!==this.hoverX&&(d.refresh(f,a),this.hoverX=f[0].clientX)}c=h&&h.tooltipOptions.followPointer,h&&h.tracker&&!c?(e=h.tooltipPoints[l])&&e!==g&&e.onMouseOver(a):d&&c&&!d.isHidden&&(h=d.getAnchor([{}],a),d.updatePosition({plotX:h[0],plotY:h[1]})),d&&!this._onDocumentMouseMove&&(this._onDocumentMouseMove=function(a){V[oa]&&V[oa].pointer.onDocumentMouseMove(a)},K(y,"mousemove",this._onDocumentMouseMove)),p(b.axes,function(b){b.drawCrosshair(a,m(e,g))})},reset:function(a){var b=this.chart,c=b.hoverSeries,d=b.hoverPoint,e=b.tooltip,f=e&&e.shared?b.hoverPoints:d;(a=a&&e&&f)&&qa(f)[0].plotX===t&&(a=!1),a?(e.refresh(f),d&&d.setState(d.state,!0)):(d&&d.onMouseOut(),c&&c.onMouseOut(),e&&e.hide(),this._onDocumentMouseMove&&(W(y,"mousemove",this._onDocumentMouseMove),this._onDocumentMouseMove=null),p(b.axes,function(a){a.hideCrosshair()}),this.hoverX=null)},scaleGroups:function(a,b){var d,c=this.chart;p(c.series,function(e){d=a||e.getPlotBox(),e.xAxis&&e.xAxis.zoomEnabled&&(e.group.attr(d),e.markerGroup&&(e.markerGroup.attr(d),e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(d))}),c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type,b.cancelClick=!1,b.mouseDownX=this.mouseDownX=a.chartX,b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var l,b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,f=this.zoomHor,g=this.zoomVert,h=b.plotLeft,i=b.plotTop,j=b.plotWidth,k=b.plotHeight,o=this.mouseDownX,n=this.mouseDownY;h>d?d=h:d>h+j&&(d=h+j),i>e?e=i:e>i+k&&(e=i+k),this.hasDragged=Math.sqrt(Math.pow(o-d,2)+Math.pow(n-e,2)),this.hasDragged>10&&(l=b.isInsidePlot(o-h,n-i),b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!this.selectionMarker&&(this.selectionMarker=b.renderer.rect(h,i,f?1:j,g?1:k,0).attr({fill:c.selectionMarkerFill||"rgba(69,114,167,0.25)",zIndex:7}).add()),this.selectionMarker&&f&&(d-=o,this.selectionMarker.attr({width:M(d),x:(d>0?0:d)+o})),this.selectionMarker&&g&&(d=e-n,this.selectionMarker.attr({height:M(d),y:(d>0?0:d)+n})),l&&!this.selectionMarker&&c.panning&&b.pan(a,c.panning))},drop:function(a){var b=this.chart,c=this.hasPinched;if(this.selectionMarker){var i,d={xAxis:[],yAxis:[],originalEvent:a.originalEvent||a},a=this.selectionMarker,e=a.attr?a.attr("x"):a.x,f=a.attr?a.attr("y"):a.y,g=a.attr?a.attr("width"):a.width,h=a.attr?a.attr("height"):a.height;(this.hasDragged||c)&&(p(b.axes,function(a){if(a.zoomEnabled){var b=a.horiz,c=a.toValue(b?e:f),b=a.toValue(b?e+g:f+h);!isNaN(c)&&!isNaN(b)&&(d[a.coll].push({axis:a,min:C(c,b),max:v(c,b)}),i=!0)}}),i&&D(b,"selection",d,function(a){b.zoom(q(a,c?{animation:!1}:null))})),this.selectionMarker=this.selectionMarker.destroy(),c&&this.scaleGroups()}b&&(G(b.container,{cursor:b._cursor}),b.cancelClick=this.hasDragged>10,b.mouseIsDown=this.hasDragged=this.hasPinched=!1,this.pinchDown=[])},onContainerMouseDown:function(a){a=this.normalize(a),a.preventDefault&&a.preventDefault(),this.dragStart(a)},onDocumentMouseUp:function(a){V[oa]&&V[oa].pointer.drop(a)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition,d=b.hoverSeries,a=this.normalize(a,c);c&&d&&!this.inClass(a.target,"highcharts-tracker")&&!b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)&&this.reset()},onContainerMouseLeave:function(){var a=V[oa];a&&(a.pointer.reset(),a.pointer.chartPosition=null)},onContainerMouseMove:function(a){var b=this.chart;oa=b.index,a=this.normalize(a),"mousedown"===b.mouseIsDown&&this.drag(a),(this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop))&&!b.openMenu&&this.runPointActions(a)},inClass:function(a,b){for(var c;a;){if(c=H(a,"class")){if(-1!==c.indexOf(b))return!0;if(-1!==c.indexOf("highcharts-container"))return!1}a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries,c=(a=a.relatedTarget||a.toElement)&&a.point&&a.point.series;!b||b.options.stickyTracking||this.inClass(a,"highcharts-tooltip")||c===b||b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,d=b.plotLeft,e=b.plotTop,a=this.normalize(a);a.cancelBubble=!0,b.cancelClick||(c&&this.inClass(a.target,"highcharts-tracker")?(D(c.series,"click",q(a,{point:c})),b.hoverPoint&&c.firePointEvent("click",a)):(q(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-d,a.chartY-e)&&D(b,"click",a)))},setDOMEvents:function(){var a=this,b=a.chart.container;b.onmousedown=function(b){a.onContainerMouseDown(b)},b.onmousemove=function(b){a.onContainerMouseMove(b)},b.onclick=function(b){a.onContainerClick(b)},K(b,"mouseleave",a.onContainerMouseLeave),1===ab&&K(y,"mouseup",a.onDocumentMouseUp),$a&&(b.ontouchstart=function(b){a.onContainerTouchStart(b)},b.ontouchmove=function(b){a.onContainerTouchMove(b)},1===ab&&K(y,"touchend",a.onDocumentTouchEnd))},destroy:function(){var a;W(this.chart.container,"mouseleave",this.onContainerMouseLeave),ab||(W(y,"mouseup",this.onDocumentMouseUp),W(y,"touchend",this.onDocumentTouchEnd)),clearInterval(this.tooltipTimeout);for(a in this)this[a]=null}},q(R.Pointer.prototype,{pinchTranslate:function(a,b,c,d,e,f){(this.zoomHor||this.pinchHor)&&this.pinchTranslateDirection(!0,a,b,c,d,e,f),(this.zoomVert||this.pinchVert)&&this.pinchTranslateDirection(!1,a,b,c,d,e,f)},pinchTranslateDirection:function(a,b,c,d,e,f,g,h){var s,m,y,i=this.chart,j=a?"x":"y",k=a?"X":"Y",l="chart"+k,o=a?"width":"height",n=i["plot"+(a?"Left":"Top")],p=h||1,q=i.inverted,x=i.bounds[a?"h":"v"],r=1===b.length,v=b[0][l],u=c[0][l],t=!r&&b[1][l],w=!r&&c[1][l],c=function(){!r&&M(v-t)>20&&(p=h||M(u-w)/M(v-t)),m=(n-u)/p+v,s=i["plot"+(a?"Width":"Height")]/p};c(),b=m,b<x.min?(b=x.min,y=!0):b+s>x.max&&(b=x.max-s,y=!0),y?(u-=.8*(u-g[j][0]),r||(w-=.8*(w-g[j][1])),c()):g[j]=[u,w],q||(f[j]=m-n,f[o]=s),f=q?1/p:p,e[o]=s,e[j]=b,d[q?a?"scaleY":"scaleX":"scale"+k]=p,d["translate"+k]=f*n+(u-f*v)},pinch:function(a){var b=this,c=b.chart,d=b.pinchDown,e=b.followTouchMove,f=a.touches,g=f.length,h=b.lastValidTouch,i=b.hasZoom,j=b.selectionMarker,k={},l=1===g&&(b.inClass(a.target,"highcharts-tracker")&&c.runTrackerClick||c.runChartClick),o={};(i||e)&&!l&&a.preventDefault(),Ua(f,function(a){return b.normalize(a)}),"touchstart"===a.type?(p(f,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),h.x=[d[0].chartX,d[1]&&d[1].chartX],h.y=[d[0].chartY,d[1]&&d[1].chartY],p(c.axes,function(a){if(a.zoomEnabled){var b=c.bounds[a.horiz?"h":"v"],d=a.minPixelPadding,e=a.toPixels(a.dataMin),f=a.toPixels(a.dataMax),g=C(e,f),e=v(e,f);b.min=C(a.pos,g-d),b.max=v(a.pos+a.len,e+d)}})):d.length&&(j||(b.selectionMarker=j=q({destroy:sa},c.plotBox)),b.pinchTranslate(d,f,k,j,o,h),b.hasPinched=i,b.scaleGroups(k,o),!i&&e&&1===g&&this.runPointActions(b.normalize(a)))},onContainerTouchStart:function(a){var b=this.chart;oa=b.index,1===a.touches.length?(a=this.normalize(a),b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)?(this.runPointActions(a),this.pinch(a)):this.reset()):2===a.touches.length&&this.pinch(a)},onContainerTouchMove:function(a){(1===a.touches.length||2===a.touches.length)&&this.pinch(a)},onDocumentTouchEnd:function(a){V[oa]&&V[oa].pointer.drop(a)}}),I.PointerEvent||I.MSPointerEvent){var ua={},zb=!!I.PointerEvent,Wb=function(){var a,b=[];b.item=function(a){return this[a]};for(a in ua)ua.hasOwnProperty(a)&&b.push({pageX:ua[a].pageX,pageY:ua[a].pageY,target:ua[a].target});return b},Ab=function(a,b,c,d){a=a.originalEvent||a,"touch"!==a.pointerType&&a.pointerType!==a.MSPOINTER_TYPE_TOUCH||!V[oa]||(d(a),d=V[oa].pointer,d[b]({type:c,target:a.currentTarget,preventDefault:sa,touches:Wb()}))};q(Wa.prototype,{onContainerPointerDown:function(a){Ab(a,"onContainerTouchStart","touchstart",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){Ab(a,"onContainerTouchMove","touchmove",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY},ua[a.pointerId].target||(ua[a.pointerId].target=a.currentTarget)})},onDocumentPointerUp:function(a){Ab(a,"onContainerTouchEnd","touchend",function(a){delete ua[a.pointerId]})},batchMSEvents:function(a){a(this.chart.container,zb?"pointerdown":"MSPointerDown",this.onContainerPointerDown),a(this.chart.container,zb?"pointermove":"MSPointerMove",this.onContainerPointerMove),a(y,zb?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}}),Ma(Wa.prototype,"init",function(a,b,c){a.call(this,b,c),(this.hasZoom||this.followTouchMove)&&G(b.container,{"-ms-touch-action":Q,"touch-action":Q})}),Ma(Wa.prototype,"setDOMEvents",function(a){a.apply(this),(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(K)}),Ma(Wa.prototype,"destroy",function(a){this.batchMSEvents(W),a.call(this)})}var lb=R.Legend=function(a,b){this.init(a,b)};lb.prototype={init:function(a,b){var c=this,d=b.itemStyle,e=m(b.padding,8),f=b.itemMarginTop||0;this.options=b,b.enabled&&(c.baseline=z(d.fontSize)+3+f,c.itemStyle=d,c.itemHiddenStyle=w(d,b.itemHiddenStyle),c.itemMarginTop=f,c.padding=e,c.initialItemX=e,c.initialItemY=e-5,c.maxItemWidth=0,c.chart=a,c.itemHeight=0,c.lastLineHeight=0,c.symbolWidth=m(b.symbolWidth,16),c.pages=[],c.render(),K(c.chart,"endResize",function(){c.positionCheckboxes()}))},colorizeItem:function(a,b){var j,c=this.options,d=a.legendItem,e=a.legendLine,f=a.legendSymbol,g=this.itemHiddenStyle.color,c=b?c.itemStyle.color:g,h=b?a.legendColor||a.color||"#CCC":g,g=a.options&&a.options.marker,i={fill:h};if(d&&d.css({fill:c,color:c}),e&&e.attr({stroke:h}),f){if(g&&f.isMarker)for(j in i.stroke=h,g=a.convertAttribs(g))d=g[j],d!==t&&(i[j]=d);f.attr(i)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,e=d[0],d=d[1],f=a.checkbox;a.legendGroup&&a.legendGroup.translate(b?e:this.legendWidth-e-2*c-4,d),f&&(f.x=e,f.y=d)},destroyItem:function(a){var b=a.checkbox;p(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())}),b&&Pa(a.checkbox)},destroy:function(){var a=this.group,b=this.box;b&&(this.box=b.destroy()),a&&(this.group=a.destroy())},positionCheckboxes:function(a){var c,b=this.group.alignAttr,d=this.clipHeight||this.legendHeight;b&&(c=b.translateY,p(this.allItems,function(e){var g,f=e.checkbox;f&&(g=c+f.y+(a||0)+3,G(f,{left:b.translateX+e.checkboxOffset+f.x-20+"px",top:g+"px",display:g>c-6&&c+d-6>g?"":Q}))}))},renderTitle:function(){var a=this.padding,b=this.options.title,c=0;b.text&&(this.title||(this.title=this.chart.renderer.label(b.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(b.style).add(this.group)),a=this.title.getBBox(),c=a.height,this.offsetWidth=a.width,this.contentGroup.attr({translateY:c})),this.titleHeight=c},renderItem:function(a){var b=this.chart,c=b.renderer,d=this.options,e="horizontal"===d.layout,f=this.symbolWidth,g=d.symbolPadding,h=this.itemStyle,i=this.itemHiddenStyle,j=this.padding,k=e?m(d.itemDistance,20):0,l=!d.rtl,o=d.width,n=d.itemMarginBottom||0,s=this.itemMarginTop,p=this.initialItemX,q=a.legendItem,r=a.series&&a.series.drawLegendSymbol?a.series:a,x=r.options,x=this.createCheckboxForItem&&x&&x.showCheckbox,t=d.useHTML;q||(a.legendGroup=c.g("legend-item").attr({zIndex:1}).add(this.scrollGroup),r.drawLegendSymbol(this,a),a.legendItem=q=c.text(d.labelFormat?Ia(d.labelFormat,a):d.labelFormatter.call(a),l?f+g:-g,this.baseline,t).css(w(a.visible?h:i)).attr({align:l?"left":"right",zIndex:2}).add(a.legendGroup),this.setItemEvents&&this.setItemEvents(a,q,t,h,i),this.colorizeItem(a,a.visible),x&&this.createCheckboxForItem(a)),c=q.getBBox(),f=a.checkboxOffset=d.itemWidth||a.legendItemWidth||f+g+c.width+k+(x?20:0),this.itemHeight=g=u(a.legendItemHeight||c.height),e&&this.itemX-p+f>(o||b.chartWidth-2*j-p-d.x)&&(this.itemX=p,this.itemY+=s+this.lastLineHeight+n,this.lastLineHeight=0),this.maxItemWidth=v(this.maxItemWidth,f),this.lastItemY=s+this.itemY+n,this.lastLineHeight=v(g,this.lastLineHeight),a._legendItemPos=[this.itemX,this.itemY],e?this.itemX+=f:(this.itemY+=s+g+n,this.lastLineHeight=g),this.offsetWidth=o||v((e?this.itemX-p-k:f)+j,this.offsetWidth)},getAllItems:function(){var a=[];return p(this.chart.series,function(b){var c=b.options;m(c.showInLegend,r(c.linkedTo)?!1:t,!0)&&(a=a.concat(b.legendItems||("point"===c.legendType?b.data:b)))}),a},render:function(){var e,f,g,h,a=this,b=a.chart,c=b.renderer,d=a.group,i=a.box,j=a.options,k=a.padding,l=j.borderWidth,o=j.backgroundColor;a.itemX=a.initialItemX,a.itemY=a.initialItemY,a.offsetWidth=0,a.lastItemY=0,d||(a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup)),a.renderTitle(),e=a.getAllItems(),ob(e,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)}),j.reversed&&e.reverse(),a.allItems=e,a.display=f=!!e.length,p(e,function(b){a.renderItem(b)}),g=j.width||a.offsetWidth,h=a.lastItemY+a.lastLineHeight+a.titleHeight,h=a.handleOverflow(h),(l||o)&&(g+=k,h+=k,i?g>0&&h>0&&(i[i.isNew?"attr":"animate"](i.crisp({width:g,height:h})),i.isNew=!1):(a.box=i=c.rect(0,0,g,h,j.borderRadius,l||0).attr({stroke:j.borderColor,"stroke-width":l||0,fill:o||Q}).add(d).shadow(j.shadow),i.isNew=!0),i[f?"show":"hide"]()),a.legendWidth=g,a.legendHeight=h,p(e,function(b){a.positionItem(b)}),f&&d.align(q({width:g,height:h},j),!0,"spacingBox"),b.isResizing||this.positionCheckboxes()},handleOverflow:function(a){var h,s,b=this,c=this.chart,d=c.renderer,e=this.options,f=e.y,f=c.spacingBox.height+("top"===e.verticalAlign?-f:f)-this.padding,g=e.maxHeight,i=this.clipRect,j=e.navigation,k=m(j.animation,!0),l=j.arrowSize||12,o=this.nav,n=this.pages,q=this.allItems;return"horizontal"===e.layout&&(f/=2),g&&(f=C(f,g)),n.length=0,a>f&&!e.useHTML?(this.clipHeight=h=f-20-this.titleHeight-this.padding,this.currentPage=m(this.currentPage,1),this.fullHeight=a,p(q,function(a,b){var c=a._legendItemPos[1],d=u(a.legendItem.getBBox().height),e=n.length;(!e||c-n[e-1]>h&&(s||c)!==n[e-1])&&(n.push(s||c),e++),b===q.length-1&&c+d-n[e-1]>h&&n.push(c),c!==s&&(s=c)}),i||(i=b.clipRect=d.clipRect(0,this.padding,9999,0),b.contentGroup.clip(i)),i.attr({height:h}),o||(this.nav=o=d.g().attr({zIndex:1}).add(this.group),this.up=d.symbol("triangle",0,0,l,l).on("click",function(){b.scroll(-1,k)}).add(o),this.pager=d.text("",15,10).css(j.style).add(o),this.down=d.symbol("triangle-down",0,0,l,l).on("click",function(){b.scroll(1,k)}).add(o)),b.scroll(0),a=f):o&&(i.attr({height:c.chartHeight}),o.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0),a},scroll:function(a,b){var c=this.pages,d=c.length,e=this.currentPage+a,f=this.clipHeight,g=this.options.navigation,h=g.activeColor,g=g.inactiveColor,i=this.pager,j=this.padding;e>d&&(e=d),e>0&&(b!==t&&Qa(b,this.chart),this.nav.attr({translateX:j,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({fill:1===e?g:h}).css({cursor:1===e?"default":"pointer"}),i.attr({text:e+"/"+d}),this.down.attr({x:18+this.pager.getBBox().width,fill:e===d?g:h}).css({cursor:e===d?"default":"pointer"}),c=-c[e-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=e,this.positionCheckboxes(c))}},N=R.LegendSymbolMixin={drawRectangle:function(a,b){var c=a.options.symbolHeight||12;b.legendSymbol=this.chart.renderer.rect(0,a.baseline-5-c/2,a.symbolWidth,c,a.options.symbolRadius||0).attr({zIndex:3}).add(b.legendGroup)},drawLineMarker:function(a){var d,b=this.options,c=b.marker;d=a.symbolWidth;var g,e=this.chart.renderer,f=this.legendGroup,a=a.baseline-u(.3*e.fontMetrics(a.options.itemStyle.fontSize).b);b.lineWidth&&(g={"stroke-width":b.lineWidth},b.dashStyle&&(g.dashstyle=b.dashStyle),this.legendLine=e.path(["M",0,a,"L",d,a]).attr(g).add(f)),c&&c.enabled!==!1&&(b=c.radius,this.legendSymbol=d=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b).add(f),d.isMarker=!0)}},(/Trident\/7\.0/.test(wa)||Ta)&&Ma(lb.prototype,"positionItem",function(a,b){var c=this,d=function(){b._legendItemPos&&a.call(c,b)};d(),setTimeout(d)}),Ya.prototype={init:function(a,b){var c,d=a.series;a.series=null,c=w(E,a),c.series=a.series=d,this.userOptions=a,d=c.chart,this.margin=this.splashArray("margin",d),this.spacing=this.splashArray("spacing",d);var e=d.events;this.bounds={h:{},v:{}},this.callback=b,this.isResizing=0,this.options=c,this.axes=[],this.series=[],this.hasCartesianSeries=d.showAxes;var g,f=this;if(f.index=V.length,V.push(f),ab++,d.reflow!==!1&&K(f,"load",function(){f.initReflow()}),e)for(g in e)K(f,g,e[g]);f.xAxis=[],f.yAxis=[],f.animation=fa?!1:m(d.animation,!0),f.pointCount=0,f.counters=new Bb,f.firstRender()},initSeries:function(a){var b=this.options.chart;return(b=F[a.type||b.type||b.defaultSeriesType])||ra(17,!0),b=new b,b.init(this,a),b},isInsidePlot:function(a,b,c){var d=c?b:a,a=c?a:b;return d>=0&&d<=this.plotWidth&&a>=0&&a<=this.plotHeight},adjustTickAmounts:function(){this.options.chart.alignTicks!==!1&&p(this.axes,function(a){a.adjustTickAmount()}),this.maxTicks=null},redraw:function(a){var g,h,b=this.axes,c=this.series,d=this.pointer,e=this.legend,f=this.isDirtyLegend,i=this.isDirtyBox,j=c.length,k=j,l=this.renderer,o=l.isHidden(),n=[];for(Qa(a,this),o&&this.cloneRenderTo(),this.layOutTitles();k--;)if(a=c[k],a.options.stacking&&(g=!0,a.isDirty)){h=!0;break}if(h)for(k=j;k--;)a=c[k],a.options.stacking&&(a.isDirty=!0);p(c,function(a){a.isDirty&&"point"===a.options.legendType&&(f=!0)}),f&&e.options.enabled&&(e.render(),this.isDirtyLegend=!1),g&&this.getStacks(),this.hasCartesianSeries&&(this.isResizing||(this.maxTicks=null,p(b,function(a){a.setScale()})),this.adjustTickAmounts(),this.getMargins(),p(b,function(a){a.isDirty&&(i=!0)}),p(b,function(a){a.isDirtyExtremes&&(a.isDirtyExtremes=!1,n.push(function(){D(a,"afterSetExtremes",q(a.eventArgs,a.getExtremes())),delete a.eventArgs})),(i||g)&&a.redraw()})),i&&this.drawChartBox(),p(c,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()}),d&&d.reset(!0),l.draw(),D(this,"redraw"),o&&this.cloneRenderTo(!0),p(n,function(a){a.call()})},get:function(a){var d,e,b=this.axes,c=this.series;for(d=0;d<b.length;d++)if(b[d].options.id===a)return b[d];for(d=0;d<c.length;d++)if(c[d].options.id===a)return c[d];for(d=0;d<c.length;d++)for(e=c[d].points||[],b=0;b<e.length;b++)if(e[b].id===a)return e[b];return null},getAxes:function(){var a=this,b=this.options,c=b.xAxis=qa(b.xAxis||{}),b=b.yAxis=qa(b.yAxis||{});p(c,function(a,b){a.index=b,a.isX=!0}),p(b,function(a,b){a.index=b}),c=c.concat(b),p(c,function(b){new la(a,b)}),a.adjustTickAmounts()},getSelectedPoints:function(){var a=[];return p(this.series,function(b){a=a.concat(vb(b.points||[],function(a){return a.selected}))}),a},getSelectedSeries:function(){return vb(this.series,function(a){return a.selected})},getStacks:function(){var a=this;p(a.yAxis,function(a){a.stacks&&a.hasVisibleSeries&&(a.oldStacks=a.stacks)}),p(a.series,function(b){!b.options.stacking||b.visible!==!0&&a.options.chart.ignoreHiddenSeries!==!1||(b.stackKey=b.type+m(b.options.stack,""))})},setTitle:function(a,b,c){var g,f,d=this,e=d.options;f=e.title=w(e.title,a),g=e.subtitle=w(e.subtitle,b),e=g,p([["title",a,f],["subtitle",b,e]],function(a){var b=a[0],c=d[b],e=a[1],a=a[2];c&&e&&(d[b]=c=c.destroy()),a&&a.text&&!c&&(d[b]=d.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+b,zIndex:a.zIndex||4}).css(a.style).add())}),d.layOutTitles(c)},layOutTitles:function(a){var b=0,c=this.title,d=this.subtitle,e=this.options,f=e.title,e=e.subtitle,g=this.spacingBox.width-44;!c||(c.css({width:(f.width||g)+"px"}).align(q({y:15},f),!1,"spacingBox"),f.floating||f.verticalAlign)||(b=c.getBBox().height),d&&(d.css({width:(e.width||g)+"px"}).align(q({y:b+f.margin},e),!1,"spacingBox"),!e.floating&&!e.verticalAlign&&(b=Ka(b+d.getBBox().height))),c=this.titleOffset!==b,this.titleOffset=b,!this.isDirtyBox&&c&&(this.isDirtyBox=c,this.hasRendered&&m(a,!0)&&this.isDirtyBox&&this.redraw())},getChartSize:function(){var a=this.options.chart,b=a.width,a=a.height,c=this.renderToClone||this.renderTo;r(b)||(this.containerWidth=jb(c,"width")),r(a)||(this.containerHeight=jb(c,"height")),this.chartWidth=v(0,b||this.containerWidth||600),this.chartHeight=v(0,m(a,this.containerHeight>19?this.containerHeight:400))},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;a?b&&(this.renderTo.appendChild(c),Pa(b),delete this.renderToClone):(c&&c.parentNode===this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),G(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),y.body.appendChild(b),c&&b.appendChild(c))
|
4 |
},getContainer:function(){var a,c,d,e,b=this.options.chart;this.renderTo=a=b.renderTo,e="highcharts-"+tb++,Fa(a)&&(this.renderTo=a=y.getElementById(a)),a||ra(13,!0),c=z(H(a,"data-highcharts-chart")),!isNaN(c)&&V[c]&&V[c].hasRendered&&V[c].destroy(),H(a,"data-highcharts-chart",this.index),a.innerHTML="",!b.skipClone&&!a.offsetWidth&&this.cloneRenderTo(),this.getChartSize(),c=this.chartWidth,d=this.chartHeight,this.container=a=Y(Ja,{className:"highcharts-container"+(b.className?" "+b.className:""),id:e},q({position:"relative",overflow:"hidden",width:c+"px",height:d+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},b.style),this.renderToClone||a),this._cursor=a.style.cursor,this.renderer=b.forExport?new ta(a,c,d,b.style,!0):new Za(a,c,d,b.style),fa&&this.renderer.create(this,a,c,d)},getMargins:function(){var b,a=this.spacing,c=this.legend,d=this.margin,e=this.options.legend,f=m(e.margin,20),g=e.x,h=e.y,i=e.align,j=e.verticalAlign,k=this.titleOffset;this.resetMargins(),b=this.axisOffset,k&&!r(d[0])&&(this.plotTop=v(this.plotTop,k+this.options.title.margin+a[0])),c.display&&!e.floating&&("right"===i?r(d[1])||(this.marginRight=v(this.marginRight,c.legendWidth-g+f+a[1])):"left"===i?r(d[3])||(this.plotLeft=v(this.plotLeft,c.legendWidth+g+f+a[3])):"top"===j?r(d[0])||(this.plotTop=v(this.plotTop,c.legendHeight+h+f+a[0])):"bottom"!==j||r(d[2])||(this.marginBottom=v(this.marginBottom,c.legendHeight-h+f+a[2]))),this.extraBottomMargin&&(this.marginBottom+=this.extraBottomMargin),this.extraTopMargin&&(this.plotTop+=this.extraTopMargin),this.hasCartesianSeries&&p(this.axes,function(a){a.getOffset()}),r(d[3])||(this.plotLeft+=b[3]),r(d[0])||(this.plotTop+=b[0]),r(d[2])||(this.marginBottom+=b[2]),r(d[1])||(this.marginRight+=b[1]),this.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,d=b.renderTo,e=c.width||jb(d,"width"),f=c.height||jb(d,"height"),c=a?a.target:I,d=function(){b.container&&(b.setSize(e,f,!1),b.hasUserSize=null)};b.hasUserSize||!e||!f||c!==I&&c!==y||((e!==b.containerWidth||f!==b.containerHeight)&&(clearTimeout(b.reflowTimeout),a?b.reflowTimeout=setTimeout(d,100):d()),b.containerWidth=e,b.containerHeight=f)},initReflow:function(){var a=this,b=function(b){a.reflow(b)};K(I,"resize",b),K(a,"destroy",function(){W(I,"resize",b)})},setSize:function(a,b,c){var e,f,g,d=this;d.isResizing+=1,g=function(){d&&D(d,"endResize",null,function(){d.isResizing-=1})},Qa(c,d),d.oldChartHeight=d.chartHeight,d.oldChartWidth=d.chartWidth,r(a)&&(d.chartWidth=e=v(0,u(a)),d.hasUserSize=!!e),r(b)&&(d.chartHeight=f=v(0,u(b))),(va?kb:G)(d.container,{width:e+"px",height:f+"px"},va),d.setChartSize(!0),d.renderer.setSize(e,f,c),d.maxTicks=null,p(d.axes,function(a){a.isDirty=!0,a.setScale()}),p(d.series,function(a){a.isDirty=!0}),d.isDirtyLegend=!0,d.isDirtyBox=!0,d.layOutTitles(),d.getMargins(),d.redraw(c),d.oldChartHeight=null,D(d,"resize"),va===!1?g():setTimeout(g,va&&va.duration||500)},setChartSize:function(a){var i,j,k,l,b=this.inverted,c=this.renderer,d=this.chartWidth,e=this.chartHeight,f=this.options.chart,g=this.spacing,h=this.clipOffset;this.plotLeft=i=u(this.plotLeft),this.plotTop=j=u(this.plotTop),this.plotWidth=k=v(0,u(d-i-this.marginRight)),this.plotHeight=l=v(0,u(e-j-this.marginBottom)),this.plotSizeX=b?l:k,this.plotSizeY=b?k:l,this.plotBorderWidth=f.plotBorderWidth||0,this.spacingBox=c.spacingBox={x:g[3],y:g[0],width:d-g[3]-g[1],height:e-g[0]-g[2]},this.plotBox=c.plotBox={x:i,y:j,width:k,height:l},d=2*T(this.plotBorderWidth/2),b=Ka(v(d,h[3])/2),c=Ka(v(d,h[0])/2),this.clipBox={x:b,y:c,width:T(this.plotSizeX-v(d,h[1])/2-b),height:T(this.plotSizeY-v(d,h[2])/2-c)},a||p(this.axes,function(a){a.setAxisSize(),a.setAxisTranslation()})},resetMargins:function(){var a=this.spacing,b=this.margin;this.plotTop=m(b[0],a[0]),this.marginRight=m(b[1],a[1]),this.marginBottom=m(b[2],a[2]),this.plotLeft=m(b[3],a[3]),this.axisOffset=[0,0,0,0],this.clipOffset=[0,0,0,0]},drawChartBox:function(){var n,a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight,e=this.chartBackground,f=this.plotBackground,g=this.plotBorder,h=this.plotBGImage,i=a.borderWidth||0,j=a.backgroundColor,k=a.plotBackgroundColor,l=a.plotBackgroundImage,o=a.plotBorderWidth||0,s=this.plotLeft,m=this.plotTop,p=this.plotWidth,q=this.plotHeight,r=this.plotBox,v=this.clipRect,u=this.clipBox;n=i+(a.shadow?8:0),(i||j)&&(e?e.animate(e.crisp({width:c-n,height:d-n})):(e={fill:j||Q},i&&(e.stroke=a.borderColor,e["stroke-width"]=i),this.chartBackground=b.rect(n/2,n/2,c-n,d-n,a.borderRadius,i).attr(e).addClass("highcharts-background").add().shadow(a.shadow))),k&&(f?f.animate(r):this.plotBackground=b.rect(s,m,p,q,0).attr({fill:k}).add().shadow(a.plotShadow)),l&&(h?h.animate(r):this.plotBGImage=b.image(l,s,m,p,q).add()),v?v.animate({width:u.width,height:u.height}):this.clipRect=b.clipRect(u),o&&(g?g.animate(g.crisp({x:s,y:m,width:p,height:q})):this.plotBorder=b.rect(s,m,p,q,0,-o).attr({stroke:a.plotBorderColor,"stroke-width":o,fill:Q,zIndex:1}).add()),this.isDirtyBox=!1},propFromSeries:function(){var c,e,f,a=this,b=a.options.chart,d=a.options.series;p(["inverted","angular","polar"],function(g){for(c=F[b.type||b.defaultSeriesType],f=a[g]||b[g]||c&&c.prototype[g],e=d&&d.length;!f&&e--;)(c=F[d[e].type])&&c.prototype[g]&&(f=!0);a[g]=f})},linkSeries:function(){var a=this,b=a.series;p(b,function(a){a.linkedSeries.length=0}),p(b,function(b){var d=b.options.linkedTo;Fa(d)&&(d=":previous"===d?a.series[b.index-1]:a.get(d))&&(d.linkedSeries.push(b),b.linkedParent=d)})},renderSeries:function(){p(this.series,function(a){a.translate(),a.setTooltipPoints&&a.setTooltipPoints(),a.render()})},render:function(){var g,a=this,b=a.axes,c=a.renderer,d=a.options,e=d.labels,f=d.credits;a.setTitle(),a.legend=new lb(a,d.legend),a.getStacks(),p(b,function(a){a.setScale()}),a.getMargins(),a.maxTicks=null,p(b,function(a){a.setTickPositions(!0),a.setMaxTicks()}),a.adjustTickAmounts(),a.getMargins(),a.drawChartBox(),a.hasCartesianSeries&&p(b,function(a){a.render()}),a.seriesGroup||(a.seriesGroup=c.g("series-group").attr({zIndex:3}).add()),a.renderSeries(),e.items&&p(e.items,function(b){var d=q(e.style,b.style),f=z(d.left)+a.plotLeft,g=z(d.top)+a.plotTop+12;delete d.left,delete d.top,c.text(b.html,f,g).attr({zIndex:2}).css(d).add()}),f.enabled&&!a.credits&&(g=f.href,a.credits=c.text(f.text,0,0).on("click",function(){g&&(location.href=g)}).attr({align:f.position.align,zIndex:8}).css(f.style).add().align(f.position)),a.hasRendered=!0},destroy:function(){var e,a=this,b=a.axes,c=a.series,d=a.container,f=d&&d.parentNode;for(D(a,"destroy"),V[a.index]=t,ab--,a.renderTo.removeAttribute("data-highcharts-chart"),W(a),e=b.length;e--;)b[e]=b[e].destroy();for(e=c.length;e--;)c[e]=c[e].destroy();p("title,subtitle,chartBackground,plotBackground,plotBGImage,plotBorder,seriesGroup,clipRect,credits,pointer,scroller,rangeSelector,legend,resetZoomButton,tooltip,renderer".split(","),function(b){var c=a[b];c&&c.destroy&&(a[b]=c.destroy())}),d&&(d.innerHTML="",W(d),f&&Pa(d));for(e in a)delete a[e]},isReadyToRender:function(){var a=this;return!aa&&I==I.top&&"complete"!==y.readyState||fa&&!I.canvg?(fa?Lb.push(function(){a.firstRender()},a.options.global.canvasToolsURL):y.attachEvent("onreadystatechange",function(){y.detachEvent("onreadystatechange",a.firstRender),"complete"===y.readyState&&a.firstRender()}),!1):!0},firstRender:function(){var a=this,b=a.options,c=a.callback;a.isReadyToRender()&&(a.getContainer(),D(a,"init"),a.resetMargins(),a.setChartSize(),a.propFromSeries(),a.getAxes(),p(b.series||[],function(b){a.initSeries(b)}),a.linkSeries(),D(a,"beforeRender"),R.Pointer&&(a.pointer=new Wa(a,b)),a.render(),a.renderer.draw(),c&&c.apply(a,[a]),p(a.callbacks,function(b){b.apply(a,[a])}),a.cloneRenderTo(!0),D(a,"load"))},splashArray:function(a,b){var c=b[a],c=ca(c)?c:[c,c,c,c];return[m(b[a+"Top"],c[0]),m(b[a+"Right"],c[1]),m(b[a+"Bottom"],c[2]),m(b[a+"Left"],c[3])]}},Ya.prototype.callbacks=[],X=R.CenteredSeriesMixin={getCenter:function(){var d,h,a=this.options,b=this.chart,c=2*(a.slicedOffset||0),e=b.plotWidth-2*c,f=b.plotHeight-2*c,b=a.center,a=[m(b[0],"50%"),m(b[1],"50%"),a.size||"100%",a.innerSize||0],g=C(e,f);return Ua(a,function(a,b){return h=/%$/.test(a),d=2>b||2===b&&h,(h?[e,f,g,g][b]*z(a)/100:a)+(d?c:0)})}};var Ea=function(){};Ea.prototype={init:function(a,b,c){return this.series=a,this.applyOptions(b,c),this.pointAttr={},a.options.colorByPoint&&(b=a.options.colors||a.chart.options.colors,this.color=this.color||b[a.colorCounter++],a.colorCounter===b.length)&&(a.colorCounter=0),a.chart.pointCount++,this},applyOptions:function(a,b){var c=this.series,d=c.pointValKey,a=Ea.prototype.optionsToObject.call(this,a);return q(this,a),this.options=this.options?q(this.options,a):a,d&&(this.y=this[d]),this.x===t&&c&&(this.x=b===t?c.autoIncrement():b),this},optionsToObject:function(a){var b={},c=this.series,d=c.pointArrayMap||["y"],e=d.length,f=0,g=0;if("number"==typeof a||null===a)b[d[0]]=a;else if(La(a))for(a.length>e&&(c=typeof a[0],"string"===c?b.name=a[0]:"number"===c&&(b.x=a[0]),f++);e>g;)b[d[g++]]=a[f++];else"object"==typeof a&&(b=a,a.dataLabels&&(c._hasPointLabels=!0),a.marker&&(c._hasPointMarkers=!0));return b},destroy:function(){var c,a=this.series.chart,b=a.hoverPoints;a.pointCount--,b&&(this.setState(),ja(b,this),!b.length)&&(a.hoverPoints=null),this===a.hoverPoint&&this.onMouseOut(),(this.graphic||this.dataLabel)&&(W(this),this.destroyElements()),this.legendItem&&a.legend.destroyItem(this);for(c in this)this[c]=null},destroyElements:function(){for(var b,a="graphic,dataLabel,dataLabelUpper,group,connector,shadowGroup".split(","),c=6;c--;)b=a[c],this[b]&&(this[b]=this[b].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var b=this.series,c=b.tooltipOptions,d=m(c.valueDecimals,""),e=c.valuePrefix||"",f=c.valueSuffix||"";return p(b.pointArrayMap||["y"],function(b){b="{point."+b,(e||f)&&(a=a.replace(b+"}",e+b+"}"+f)),a=a.replace(b+"}",b+":,."+d+"f}")}),Ia(a,{point:this,series:this.series})},firePointEvent:function(a,b,c){var d=this,e=this.series.options;(e.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents(),"click"===a&&e.allowPointSelect&&(c=function(a){d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)}),D(this,a,b,c)}};var O=function(){};O.prototype={isCartesian:!0,type:"line",pointClass:Ea,sorted:!0,requireSorting:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor",r:"radius"},axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],init:function(a,b){var d,e,c=this,f=a.series,g=function(a,b){return m(a.options.index,a._i)-m(b.options.index,b._i)};c.chart=a,c.options=b=c.setOptions(b),c.linkedSeries=[],c.bindAxes(),q(c,{name:b.name,state:"",pointAttr:{},visible:b.visible!==!1,selected:b.selected===!0}),fa&&(b.animation=!1),e=b.events;for(d in e)K(c,d,e[d]);(e&&e.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)&&(a.runTrackerClick=!0),c.getColor(),c.getSymbol(),p(c.parallelArrays,function(a){c[a+"Data"]=[]}),c.setData(b.data,!1),c.isCartesian&&(a.hasCartesianSeries=!0),f.push(c),c._i=f.length-1,ob(f,g),this.yAxis&&ob(this.yAxis.series,g),p(f,function(a,b){a.index=b,a.name=a.name||"Series "+(b+1)})},bindAxes:function(){var d,a=this,b=a.options,c=a.chart;p(a.axisTypes||[],function(e){p(c[e],function(c){d=c.options,(b[e]===d.index||b[e]!==t&&b[e]===d.id||b[e]===t&&0===d.index)&&(c.series.push(a),a[e]=c,c.isDirty=!0)}),!a[e]&&a.optionalAxis!==e&&ra(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,d=arguments;p(c.parallelArrays,"number"==typeof b?function(d){var f="y"===d&&c.toYData?c.toYData(a):a[d];c[d+"Data"][b]=f}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(d,2))})},autoIncrement:function(){var a=this.options,b=this.xIncrement,b=m(b,a.pointStart,0);return this.pointInterval=m(this.pointInterval,a.pointInterval,1),this.xIncrement=b+this.pointInterval,b},getSegments:function(){var c,a=-1,b=[],d=this.points,e=d.length;if(e)if(this.options.connectNulls){for(c=e;c--;)null===d[c].y&&d.splice(c,1);d.length&&(b=[d])}else p(d,function(c,g){null===c.y?(g>a+1&&b.push(d.slice(a+1,g)),a=g):g===e-1&&b.push(d.slice(a+1,g+1))});this.segments=b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},e=c[this.type];return this.userOptions=a,c=w(e,c.series,a),this.tooltipOptions=w(E.tooltip,E.plotOptions[this.type].tooltip,b.tooltip,d.series&&d.series.tooltip,d[this.type]&&d[this.type].tooltip,a.tooltip),null===e.marker&&delete c.marker,c},getColor:function(){var e,a=this.options,b=this.userOptions,c=this.chart.options.colors,d=this.chart.counters;e=a.color||ba[this.type].color,e||a.colorByPoint||(r(b._colorIndex)?a=b._colorIndex:(b._colorIndex=d.color,a=d.color++),e=c[a]),this.color=e,d.wrapColor(c.length)},getSymbol:function(){var a=this.userOptions,b=this.options.marker,c=this.chart,d=c.options.symbols,c=c.counters;this.symbol=b.symbol,this.symbol||(r(a._symbolIndex)?a=a._symbolIndex:(a._symbolIndex=c.symbol,a=c.symbol++),this.symbol=d[a]),/^url/.test(this.symbol)&&(b.radius=0),c.wrapSymbol(d.length)},drawLegendSymbol:N.drawLineMarker,setData:function(a,b,c,d){var h,e=this,f=e.points,g=f&&f.length||0,i=e.options,j=e.chart,k=null,l=e.xAxis,o=l&&!!l.categories,n=e.tooltipPoints,s=i.turboThreshold,q=this.xData,r=this.yData,v=(h=e.pointArrayMap)&&h.length,a=a||[];if(h=a.length,b=m(b,!0),d===!1||!h||g!==h||e.cropped||e.hasGroupedData){if(e.xIncrement=null,e.pointRange=o?1:i.pointRange,e.colorCounter=0,p(this.parallelArrays,function(a){e[a+"Data"].length=0}),s&&h>s){for(c=0;null===k&&h>c;)k=a[c],c++;if(ha(k)){for(o=m(i.pointStart,0),i=m(i.pointInterval,1),c=0;h>c;c++)q[c]=o,r[c]=a[c],o+=i;e.xIncrement=o}else if(La(k))if(v)for(c=0;h>c;c++)i=a[c],q[c]=i[0],r[c]=i.slice(1,v+1);else for(c=0;h>c;c++)i=a[c],q[c]=i[0],r[c]=i[1];else ra(12)}else for(c=0;h>c;c++)a[c]!==t&&(i={series:e},e.pointClass.prototype.applyOptions.apply(i,[a[c]]),e.updateParallelArrays(i,c),o&&i.name)&&(l.names[i.x]=i.name);for(Fa(r[0])&&ra(14,!0),e.data=[],e.options.data=a,c=g;c--;)f[c]&&f[c].destroy&&f[c].destroy();n&&(n.length=0),l&&(l.minRange=l.userMinRange),e.isDirty=e.isDirtyData=j.isDirtyBox=!0,c=!1}else p(a,function(a,b){f[b].update(a,!1)});b&&j.redraw(c)},processData:function(a){var e,b=this.xData,c=this.yData,d=b.length;e=0;var f,g,o,n,h=this.xAxis,i=this.options,j=i.cropThreshold,k=0,l=this.isCartesian;if(l&&!this.isDirty&&!h.isDirty&&!this.yAxis.isDirty&&!a)return!1;for(l&&this.sorted&&(!j||d>j||this.forceCrop)&&(o=h.min,n=h.max,b[d-1]<o||b[0]>n?(b=[],c=[]):(b[0]<o||b[d-1]>n)&&(e=this.cropData(this.xData,this.yData,o,n),b=e.xData,c=e.yData,e=e.start,f=!0,k=b.length)),d=b.length-1;d>=0;d--)a=b[d]-b[d-1],!f&&b[d]>o&&b[d]<n&&k++,a>0&&(g===t||g>a)?g=a:0>a&&this.requireSorting&&ra(15);this.cropped=f,this.cropStart=e,this.processedXData=b,this.processedYData=c,this.activePointCount=k,null===i.pointRange&&(this.pointRange=g||1),this.closestPointRange=g},cropData:function(a,b,c,d){var i,e=a.length,f=0,g=e,h=m(this.cropShoulder,1);for(i=0;e>i;i++)if(a[i]>=c){f=v(0,i-h);break}for(;e>i;i++)if(a[i]>d){g=i+h;break}return{xData:a.slice(f,g),yData:b.slice(f,g),start:f,end:g}},generatePoints:function(){var c,i,k,o,a=this.options.data,b=this.data,d=this.processedXData,e=this.processedYData,f=this.pointClass,g=d.length,h=this.cropStart||0,j=this.hasGroupedData,l=[];for(b||j||(b=[],b.length=a.length,b=this.data=b),o=0;g>o;o++)i=h+o,j?l[o]=(new f).init(this,[d[o]].concat(qa(e[o]))):(b[i]?k=b[i]:a[i]!==t&&(b[i]=k=(new f).init(this,a[i],d[o])),l[o]=k);if(b&&(g!==(c=b.length)||j))for(o=0;c>o;o++)o===h&&!j&&(o+=g),b[o]&&(b[o].destroyElements(),b[o].plotX=t);this.data=b,this.points=l},getExtremes:function(a){var d,b=this.yAxis,c=this.processedXData,e=[],f=0;d=this.xAxis.getExtremes();var i,j,k,l,g=d.min,h=d.max,a=a||this.stackedYData||this.processedYData;for(d=a.length,l=0;d>l;l++)if(j=c[l],k=a[l],i=null!==k&&k!==t&&(!b.isLog||k.length||k>0),j=this.getExtremesFromAll||this.cropped||(c[l+1]||j)>=g&&(c[l-1]||j)<=h,i&&j)if(i=k.length)for(;i--;)null!==k[i]&&(e[f++]=k[i]);else e[f++]=k;this.dataMin=m(void 0,Na(e)),this.dataMax=m(void 0,Ba(e))},translate:function(){this.processedXData||this.processData(),this.generatePoints();for(var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,e=this.yAxis,f=this.points,g=f.length,h=!!this.modifyValue,i=a.pointPlacement,j="between"===i||ha(i),k=a.threshold,a=0;g>a;a++){var l=f[a],o=l.x,n=l.y,s=l.low,p=b&&e.stacks[(this.negStacks&&k>n?"-":"")+this.stackKey];e.isLog&&0>=n&&(l.y=n=null),l.plotX=c.translate(o,0,0,0,1,i,"flags"===this.type),b&&this.visible&&p&&p[o]&&(p=p[o],n=p.points[this.index+","+a],s=n[0],n=n[1],0===s&&(s=m(k,e.min)),e.isLog&&0>=s&&(s=null),l.total=l.stackTotal=p.total,l.percentage=p.total&&l.y/p.total*100,l.stackY=n,p.setOffset(this.pointXOffset||0,this.barW||0)),l.yBottom=r(s)?e.translate(s,0,1,0,1):null,h&&(n=this.modifyValue(n,l)),l.plotY="number"==typeof n&&1/0!==n?e.translate(n,0,1,0,1):t,l.clientX=j?c.translate(o,0,0,0,1):l.plotX,l.negative=l.y<(k||0),l.category=d&&d[l.x]!==t?d[l.x]:l.x}this.getSegments()},animate:function(a){var d,b=this.chart,c=b.renderer;d=this.options.animation;var g,e=this.clipBox||b.clipBox,f=b.inverted;d&&!ca(d)&&(d=ba[this.type].animation),g=["_sharedClip",d.duration,d.easing,e.height].join(","),a?(a=b[g],d=b[g+"m"],a||(b[g]=a=c.clipRect(q(e,{width:0})),b[g+"m"]=d=c.clipRect(-99,f?-b.plotLeft:-b.plotTop,99,f?b.chartWidth:b.chartHeight)),this.group.clip(a),this.markerGroup.clip(d),this.sharedClipKey=g):((a=b[g])&&a.animate({width:b.plotSizeX},d),b[g+"m"]&&b[g+"m"].animate({width:b.plotSizeX+99},d),this.animate=null)},afterAnimate:function(){var a=this.chart,b=this.sharedClipKey,c=this.group,d=this.clipBox;c&&this.options.clip!==!1&&(b&&d||c.clip(d?a.renderer.clipRect(d):a.clipRect),this.markerGroup.clip()),D(this,"afterAnimate"),setTimeout(function(){b&&a[b]&&(d||(a[b]=a[b].destroy()),a[b+"m"]&&(a[b+"m"]=a[b+"m"].destroy()))},100)},drawPoints:function(){var a,d,e,f,g,h,i,j,k,b=this.points,c=this.chart;d=this.options.marker;var o,l=this.pointAttr[""],n=this.markerGroup,s=m(d.enabled,this.activePointCount<.5*this.xAxis.len/d.radius);if(d.enabled!==!1||this._hasPointMarkers)for(f=b.length;f--;)g=b[f],d=T(g.plotX),e=g.plotY,k=g.graphic,i=g.marker||{},a=s&&i.enabled===t||i.enabled,o=c.isInsidePlot(u(d),e,c.inverted),a&&e!==t&&!isNaN(e)&&null!==g.y?(a=g.pointAttr[g.selected?"select":""]||l,h=a.r,i=m(i.symbol,this.symbol),j=0===i.indexOf("url"),k?k[o?"show":"hide"](!0).animate(q({x:d-h,y:e-h},k.symbolName?{width:2*h,height:2*h}:{})):o&&(h>0||j)&&(g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h).attr(a).add(n))):k&&(g.graphic=k.destroy())},convertAttribs:function(a,b,c,d){var f,g,e=this.pointAttrToOptions,h={},a=a||{},b=b||{},c=c||{},d=d||{};for(f in e)g=e[f],h[f]=m(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var f,a=this,b=a.options,c=ba[a.type].marker?b.marker:b,d=c.states,e=d.hover,g=a.color;f={stroke:g,fill:g};var i,k,h=a.points||[],j=[],l=a.pointAttrToOptions;k=a.hasPointSpecificOptions;var o=b.negativeColor,n=c.lineColor,s=c.fillColor;i=b.turboThreshold;var m;if(b.marker?(e.radius=e.radius||c.radius+2,e.lineWidth=e.lineWidth||c.lineWidth+1):e.color=e.color||ya(e.color||g).brighten(e.brightness).get(),j[""]=a.convertAttribs(c,f),p(["hover","select"],function(b){j[b]=a.convertAttribs(d[b],j[""])}),a.pointAttr=j,g=h.length,!i||i>g||k)for(;g--;){if(i=h[g],(c=i.options&&i.options.marker||i.options)&&c.enabled===!1&&(c.radius=0),i.negative&&o&&(i.color=i.fillColor=o),k=b.colorByPoint||i.color,i.options)for(m in l)r(c[l[m]])&&(k=!0);k?(c=c||{},k=[],d=c.states||{},f=d.hover=d.hover||{},b.marker||(f.color=f.color||!i.options.color&&e.color||ya(i.color).brighten(f.brightness||e.brightness).get()),f={color:i.color},s||(f.fillColor=i.color),n||(f.lineColor=i.color),k[""]=a.convertAttribs(q(f,c),j[""]),k.hover=a.convertAttribs(d.hover,j.hover,k[""]),k.select=a.convertAttribs(d.select,j.select,k[""])):k=j,i.pointAttr=k}},destroy:function(){var d,e,g,h,i,a=this,b=a.chart,c=/AppleWebKit\/533/.test(wa),f=a.data||[];for(D(a,"destroy"),W(a),p(a.axisTypes||[],function(b){(i=a[b])&&(ja(i.series,a),i.isDirty=i.forceRedraw=!0)}),a.legendItem&&a.chart.legend.destroyItem(a),e=f.length;e--;)(g=f[e])&&g.destroy&&g.destroy();a.points=null,clearTimeout(a.animationTimeout),p("area,graph,dataLabelsGroup,group,markerGroup,tracker,graphNeg,areaNeg,posClip,negClip".split(","),function(b){a[b]&&(d=c&&"group"===b?"hide":"destroy",a[b][d]())}),b.hoverSeries===a&&(b.hoverSeries=null),ja(b.series,a);for(h in a)delete a[h]},getSegmentPath:function(a){var b=this,c=[],d=b.options.step;return p(a,function(e,f){var i,g=e.plotX,h=e.plotY;b.getPointSpline?c.push.apply(c,b.getPointSpline(a,e,f)):(c.push(f?"L":"M"),d&&f&&(i=a[f-1],"right"===d?c.push(i.plotX,h):"center"===d?c.push((i.plotX+g)/2,i.plotY,(i.plotX+g)/2,h):c.push(g,i.plotY)),c.push(e.plotX,e.plotY))}),c},getGraphPath:function(){var c,a=this,b=[],d=[];return p(a.segments,function(e){c=a.getSegmentPath(e),e.length>1?b=b.concat(c):d.push(e[0])}),a.singlePoints=d,a.graphPath=b},drawGraph:function(){var a=this,b=this.options,c=[["graph",b.lineColor||this.color]],d=b.lineWidth,e=b.dashStyle,f="square"!==b.linecap,g=this.getGraphPath(),h=b.negativeColor;h&&c.push(["graphNeg",h]),p(c,function(c,h){var k=c[0],l=a[k];l?(bb(l),l.animate({d:g})):d&&g.length&&(l={stroke:c[1],"stroke-width":d,fill:Q,zIndex:1},e?l.dashstyle=e:f&&(l["stroke-linecap"]=l["stroke-linejoin"]="round"),a[k]=a.chart.renderer.path(g).attr(l).add(a.group).shadow(!h&&b.shadow))})},clipNeg:function(){var e,a=this.options,b=this.chart,c=b.renderer,d=a.negativeColor||a.negativeFillColor,f=this.graph,g=this.area,h=this.posClip,i=this.negClip;e=b.chartWidth;var j=b.chartHeight,k=v(e,j),l=this.yAxis;d&&(f||g)&&(d=u(l.toPixels(a.threshold||0,!0)),0>d&&(k-=d),a={x:0,y:0,width:k,height:d},k={x:0,y:d,width:k,height:k},b.inverted&&(a.height=k.y=b.plotWidth-d,c.isVML&&(a={x:b.plotWidth-d-b.plotLeft,y:0,width:e,height:j},k={x:d+b.plotLeft-e,y:0,width:b.plotLeft+d,height:e})),l.reversed?(b=k,e=a):(b=a,e=k),h?(h.animate(b),i.animate(e)):(this.posClip=h=c.clipRect(b),this.negClip=i=c.clipRect(e),f&&this.graphNeg&&(f.clip(h),this.graphNeg.clip(i)),g&&(g.clip(h),this.areaNeg.clip(i))))},invertGroups:function(){function a(){var a={width:b.yAxis.len,height:b.xAxis.len};p(["group","markerGroup"],function(c){b[c]&&b[c].attr(a).invert()})}var b=this,c=b.chart;b.xAxis&&(K(c,"resize",a),K(b,"destroy",function(){W(c,"resize",a)}),a(),b.invertGroups=a)},plotGroup:function(a,b,c,d,e){var f=this[a],g=!f;return g&&(this[a]=f=this.chart.renderer.g(b).attr({visibility:c,zIndex:d||.1}).add(e)),f[g?"attr":"animate"](this.getPlotBox()),f},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;return a.inverted&&(b=c,c=this.xAxis),{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var c,a=this,b=a.chart,d=a.options,e=(c=d.animation)&&!!a.animate&&b.renderer.isSVG&&m(c.duration,500)||0,f=a.visible?"visible":"hidden",g=d.zIndex,h=a.hasRendered,i=b.seriesGroup;c=a.plotGroup("group","series",f,g,i),a.markerGroup=a.plotGroup("markerGroup","markers",f,g,i),e&&a.animate(!0),a.getAttribs(),c.inverted=a.isCartesian?b.inverted:!1,a.drawGraph&&(a.drawGraph(),a.clipNeg()),a.drawDataLabels&&a.drawDataLabels(),a.visible&&a.drawPoints(),a.drawTracker&&a.options.enableMouseTracking!==!1&&a.drawTracker(),b.inverted&&a.invertGroups(),d.clip!==!1&&!a.sharedClipKey&&!h&&c.clip(b.clipRect),e&&a.animate(),h||(e?a.animationTimeout=setTimeout(function(){a.afterAnimate()},e):a.afterAnimate()),a.isDirty=a.isDirtyData=!1,a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:m(d&&d.left,a.plotLeft),translateY:m(e&&e.top,a.plotTop)})),this.translate(),this.setTooltipPoints&&this.setTooltipPoints(!0),this.render(),b&&D(this,"updatedData")}},Hb.prototype={destroy:function(){Oa(this,this.axis)},render:function(a){var b=this.options,c=b.format,c=c?Ia(c,this):b.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,null,null,b.useHTML).css(b.style).attr({align:this.textAlign,rotation:b.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,b){var c=this.axis,d=c.chart,e=d.inverted,f=this.isNegative,g=c.translate(c.usePercentage?100:this.total,0,0,0,1),c=c.translate(0),c=M(g-c),h=d.xAxis[0].translate(this.x)+a,i=d.plotHeight,f={x:e?f?g:g-c:h,y:e?i-h-b:f?i-g-c:i-g,width:e?c:b,height:e?b:c};(e=this.label)&&(e.align(this.alignOptions,null,f),f=e.alignAttr,e[this.options.crop===!1||d.isInsidePlot(f.x,f.y)?"show":"hide"](!0))}},la.prototype.buildStacks=function(){var a=this.series,b=m(this.options.reversedStacks,!0),c=a.length;if(!this.isXAxis){for(this.usePercentage=!1;c--;)a[b?c:a.length-c-1].setStackedPoints();if(this.usePercentage)for(c=0;c<a.length;c++)a[c].setPercentStacks()}},la.prototype.renderStackTotals=function(){var d,e,a=this.chart,b=a.renderer,c=this.stacks,f=this.stackTotalGroup;f||(this.stackTotalGroup=f=b.g("stack-labels").attr({visibility:"visible",zIndex:6}).add()),f.translate(a.plotLeft,a.plotTop);for(d in c)for(e in a=c[d])a[e].render(f)},O.prototype.setStackedPoints=function(){if(this.options.stacking&&(this.visible===!0||this.chart.options.chart.ignoreHiddenSeries===!1)){var n,m,p,q,r,u,a=this.processedXData,b=this.processedYData,c=[],d=b.length,e=this.options,f=e.threshold,g=e.stack,e=e.stacking,h=this.stackKey,i="-"+h,j=this.negStacks,k=this.yAxis,l=k.stacks,o=k.oldStacks;for(q=0;d>q;q++)r=a[q],u=b[q],p=this.index+","+q,m=(n=j&&f>u)?i:h,l[m]||(l[m]={}),l[m][r]||(o[m]&&o[m][r]?(l[m][r]=o[m][r],l[m][r].total=null):l[m][r]=new Hb(k,k.options.stackLabels,n,r,g)),m=l[m][r],m.points[p]=[m.cum||0],"percent"===e?(n=n?h:i,j&&l[n]&&l[n][r]?(n=l[n][r],m.total=n.total=v(n.total,m.total)+M(u)||0):m.total=da(m.total+(M(u)||0))):m.total=da(m.total+(u||0)),m.cum=(m.cum||0)+(u||0),m.points[p].push(m.cum),c[q]=m.cum;"percent"===e&&(k.usePercentage=!0),this.stackedYData=c,k.oldStacks={}}},O.prototype.setPercentStacks=function(){var a=this,b=a.stackKey,c=a.yAxis.stacks,d=a.processedXData;p([b,"-"+b],function(b){for(var e,g,h,f=d.length;f--;)g=d[f],e=(h=c[b]&&c[b][g])&&h.points[a.index+","+f],(g=e)&&(h=h.total?100/h.total:0,g[0]=da(g[0]*h),g[1]=da(g[1]*h),a.stackedYData[f]=g[1])})},q(Ya.prototype,{addSeries:function(a,b,c){var d,e=this;return a&&(b=m(b,!0),D(e,"addSeries",{options:a},function(){d=e.initSeries(a),e.isDirtyLegend=!0,e.linkSeries(),b&&e.redraw(c)})),d},addAxis:function(a,b,c,d){var e=b?"xAxis":"yAxis",f=this.options;new la(this,w(a,{index:this[e].length,isX:b})),f[e]=qa(f[e]||{}),f[e].push(a),m(c,!0)&&this.redraw(d)},showLoading:function(a){var b=this.options,c=this.loadingDiv,d=b.loading;c||(this.loadingDiv=c=Y(Ja,{className:"highcharts-loading"},q(d.style,{zIndex:10,display:Q}),this.container),this.loadingSpan=Y("span",null,d.labelStyle,c)),this.loadingSpan.innerHTML=a||b.lang.loading,this.loadingShown||(G(c,{opacity:0,display:"",left:this.plotLeft+"px",top:this.plotTop+"px",width:this.plotWidth+"px",height:this.plotHeight+"px"}),kb(c,{opacity:d.style.opacity},{duration:d.showDuration||0}),this.loadingShown=!0)},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&kb(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){G(b,{display:Q})}}),this.loadingShown=!1}}),q(Ea.prototype,{update:function(a,b,c){var g,d=this,e=d.series,f=d.graphic,h=e.data,i=e.chart,j=e.options,b=m(b,!0);d.firePointEvent("update",{options:a},function(){d.applyOptions(a),ca(a)&&(e.getAttribs(),f&&(a&&a.marker&&a.marker.symbol?d.graphic=f.destroy():f.attr(d.pointAttr[d.state||""])),a&&a.dataLabels&&d.dataLabel&&(d.dataLabel=d.dataLabel.destroy())),g=Da(d,h),e.updateParallelArrays(d,g),j.data[g]=d.options,e.isDirty=e.isDirtyData=!0,!e.fixedBox&&e.hasCartesianSeries&&(i.isDirtyBox=!0),"point"===j.legendType&&i.legend.destroyItem(d),b&&i.redraw(c)})},remove:function(a,b){var g,c=this,d=c.series,e=d.points,f=d.chart,h=d.data;Qa(b,f),a=m(a,!0),c.firePointEvent("remove",null,function(){g=Da(c,h),h.length===e.length&&e.splice(g,1),h.splice(g,1),d.options.data.splice(g,1),d.updateParallelArrays(c,"splice",g,1),c.destroy(),d.isDirty=!0,d.isDirtyData=!0,a&&f.redraw()})}}),q(O.prototype,{addPoint:function(a,b,c,d){var o,e=this.options,f=this.data,g=this.graph,h=this.area,i=this.chart,j=this.xAxis&&this.xAxis.names,k=g&&g.shift||0,l=e.data,n=this.xData;if(Qa(d,i),c&&p([g,h,this.graphNeg,this.areaNeg],function(a){a&&(a.shift=k+1)}),h&&(h.isArea=!0),b=m(b,!0),d={series:this},this.pointClass.prototype.applyOptions.apply(d,[a]),g=d.x,h=n.length,this.requireSorting&&g<n[h-1])for(o=!0;h&&n[h-1]>g;)h--;this.updateParallelArrays(d,"splice",h,0,0),this.updateParallelArrays(d,h),j&&(j[g]=d.name),l.splice(h,0,a),o&&(this.data.splice(h,0,null),this.processData()),"point"===e.legendType&&this.generatePoints(),c&&(f[0]&&f[0].remove?f[0].remove(!1):(f.shift(),this.updateParallelArrays(d,"shift"),l.shift())),this.isDirtyData=this.isDirty=!0,b&&(this.getAttribs(),i.redraw())},remove:function(a,b){var c=this,d=c.chart,a=m(a,!0);c.isRemoving||(c.isRemoving=!0,D(c,"remove",null,function(){c.destroy(),d.isDirtyLegend=d.isDirtyBox=!0,d.linkSeries(),a&&d.redraw(b)})),c.isRemoving=!1},update:function(a,b){var f,c=this.chart,d=this.type,e=F[d].prototype,a=w(this.userOptions,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1);for(f in e)e.hasOwnProperty(f)&&(this[f]=t);q(this,F[a.type||d].prototype),this.init(c,a),m(b,!0)&&c.redraw(!1)}}),q(la.prototype,{update:function(a,b){var c=this.chart,a=c.options[this.coll][this.options.index]=w(this.userOptions,a);this.destroy(!0),this._addedPlotLB=t,this.init(c,q(a,{events:t})),c.isDirtyBox=!0,m(b,!0)&&c.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,d=this.series,e=d.length;e--;)d[e]&&d[e].remove(!1);ja(b.axes,this),ja(b[c],this),b.options[c].splice(this.options.index,1),p(b[c],function(a,b){a.options.index=b}),this.destroy(),b.isDirtyBox=!0,m(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}}),ga=ka(O),F.line=ga,ba.area=w(S,{threshold:0});var pa=ka(O,{type:"area",getSegments:function(){var h,i,l,o,n,a=[],b=[],c=[],d=this.xAxis,e=this.yAxis,f=e.stacks[this.stackKey],g={},j=this.points,k=this.options.connectNulls;if(this.options.stacking&&!this.cropped){for(o=0;o<j.length;o++)g[j[o].x]=j[o];for(n in f)null!==f[n].total&&c.push(+n);c.sort(function(a,b){return a-b}),p(c,function(a){(!k||g[a]&&null!==g[a].y)&&(g[a]?b.push(g[a]):(h=d.translate(a),l=f[a].percent?f[a].total?100*f[a].cum/f[a].total:0:f[a].cum,i=e.toPixels(l,!0),b.push({y:null,plotX:h,clientX:h,plotY:i,yBottom:i,onMouseOver:sa})))}),b.length&&a.push(b)}else O.prototype.getSegments.call(this),a=this.segments;this.segments=a},getSegmentPath:function(a){var d,b=O.prototype.getSegmentPath.call(this,a),c=[].concat(b),e=this.options;d=b.length;var g,f=this.yAxis.getThreshold(e.threshold);if(3===d&&c.push("L",b[1],b[2]),e.stacking&&!this.closedStacks)for(d=a.length-1;d>=0;d--)g=m(a[d].yBottom,f),d<a.length-1&&e.step&&c.push(a[d+1].plotX,g),c.push(a[d].plotX,g);else this.closeSegment(c,a,f);return this.areaPath=this.areaPath.concat(c),b},closeSegment:function(a,b,c){a.push("L",b[b.length-1].plotX,c,"L",b[0].plotX,c)},drawGraph:function(){this.areaPath=[],O.prototype.drawGraph.apply(this);var a=this,b=this.areaPath,c=this.options,d=c.negativeColor,e=c.negativeFillColor,f=[["area",this.color,c.fillColor]];(d||e)&&f.push(["areaNeg",d,e]),p(f,function(d){var e=d[0],f=a[e];f?f.animate({d:b}):a[e]=a.chart.renderer.path(b).attr({fill:m(d[2],ya(d[1]).setOpacity(m(c.fillOpacity,.75)).get()),zIndex:0}).add(a.group)
|
5 |
-
})},drawLegendSymbol:N.drawRectangle});F.area=pa,ba.spline=w(S),ga=ka(O,{type:"spline",getPointSpline:function(a,b,c){var h,i,j,k,d=b.plotX,e=b.plotY,f=a[c-1],g=a[c+1];if(f&&g){a=f.plotY,j=g.plotX;var l,g=g.plotY;h=(1.5*d+f.plotX)/2.5,i=(1.5*e+a)/2.5,j=(1.5*d+j)/2.5,k=(1.5*e+g)/2.5,l=(k-i)*(j-d)/(j-h)+e-k,i+=l,k+=l,i>a&&i>e?(i=v(a,e),k=2*e-i):a>i&&e>i&&(i=C(a,e),k=2*e-i),k>g&&k>e?(k=v(g,e),i=2*e-k):g>k&&e>k&&(k=C(g,e),i=2*e-k),b.rightContX=j,b.rightContY=k}return c?(b=["C",f.rightContX||f.plotX,f.rightContY||f.plotY,h||d,i||e,d,e],f.rightContX=f.rightContY=null):b=["M",d,e],b}}),F.spline=ga,ba.areaspline=w(ba.area),pa=pa.prototype,ga=ka(ga,{type:"areaspline",closedStacks:!0,getSegmentPath:pa.getSegmentPath,closeSegment:pa.closeSegment,drawGraph:pa.drawGraph,drawLegendSymbol:N.drawRectangle}),F.areaspline=ga,ba.column=w(S,{borderColor:"#FFFFFF",borderRadius:0,groupPadding:.2,marker:null,pointPadding:.1,minPointLength:0,cropThreshold:50,pointRange:null,states:{hover:{brightness:.1,shadow:!1,halo:!1},select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}},dataLabels:{align:null,verticalAlign:null,y:null},stickyTracking:!1,tooltip:{distance:6},threshold:0}),ga=ka(O,{type:"column",pointAttrToOptions:{stroke:"borderColor",fill:"color",r:"borderRadius"},cropShoulder:0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){O.prototype.init.apply(this,arguments);var a=this,b=a.chart;b.hasRendered&&p(b.series,function(b){b.type===a.type&&(b.isDirty=!0)})},getColumnMetrics:function(){var f,h,a=this,b=a.options,c=a.xAxis,d=a.yAxis,e=c.reversed,g={},i=0;b.grouping===!1?i=1:p(a.chart.series,function(b){var c=b.options,e=b.yAxis;b.type===a.type&&b.visible&&d.len===e.len&&d.pos===e.pos&&(c.stacking?(f=b.stackKey,g[f]===t&&(g[f]=i++),h=g[f]):c.grouping!==!1&&(h=i++),b.columnIndex=h)});var c=C(M(c.transA)*(c.ordinalSlope||b.pointRange||c.closestPointRange||c.tickInterval||1),c.len),j=c*b.groupPadding,k=(c-2*j)/i,l=b.pointWidth,b=r(l)?(k-l)/2:k*b.pointPadding,l=m(l,k-2*b);return a.columnMetrics={width:l,offset:b+(j+((e?i-(a.columnIndex||0):a.columnIndex)||0)*k-c/2)*(e?-1:1)}},translate:function(){var a=this,b=a.chart,c=a.options,d=a.borderWidth=m(c.borderWidth,a.activePointCount>.5*a.xAxis.len?0:1),e=a.yAxis,f=a.translatedThreshold=e.getThreshold(c.threshold),g=m(c.minPointLength,5),c=a.getColumnMetrics(),h=c.width,i=a.barW=Ka(v(h,1+2*d)),j=a.pointXOffset=c.offset,k=-(d%2?.5:0),l=d%2?.5:1;b.renderer.isVML&&b.inverted&&(l+=1),O.prototype.translate.apply(a),p(a.points,function(c){var x,d=m(c.yBottom,f),p=C(v(-999-d,c.plotY),e.len+999+d),q=c.plotX+j,r=i,t=C(p,d);x=v(p,d)-t,M(x)<g&&g&&(x=g,t=u(M(t-f)>g?d-g:f-(e.translate(c.y,0,1,0,1)<=f?g:0))),c.barX=q,c.pointWidth=h,c.tooltipPos=b.inverted?[e.len-p,a.xAxis.len-q-r/2]:[q+r/2,p],d=M(q)<.5,r=u(q+r)+k,q=u(q)+k,r-=q,p=M(t)<.5,x=u(t+x)+l,t=u(t)+l,x-=t,d&&(q+=1,r-=1),p&&(t-=1,x+=1),c.shapeType="rect",c.shapeArgs={x:q,y:t,width:r,height:x}})},getSymbol:sa,drawLegendSymbol:N.drawRectangle,drawGraph:sa,drawPoints:function(){var f,g,h,a=this,b=this.chart,c=a.options,d=b.renderer,e=c.animationLimit||250;p(a.points,function(i){var j=i.plotY,k=i.graphic;j===t||isNaN(j)||null===i.y?k&&(i.graphic=k.destroy()):(f=i.shapeArgs,h=r(a.borderWidth)?{"stroke-width":a.borderWidth}:{},g=i.pointAttr[i.selected?"select":""]||a.pointAttr[""],k?(bb(k),k.attr(h)[b.pointCount<e?"animate":"attr"](w(f))):i.graphic=d[i.shapeType](f).attr(g).attr(h).add(a.group).shadow(c.shadow,null,c.stacking&&!c.borderRadius))})},animate:function(a){var b=this.yAxis,c=this.options,d=this.chart.inverted,e={};aa&&(a?(e.scaleY=.001,a=C(b.pos+b.len,v(b.pos,b.toPixels(c.threshold))),d?e.translateX=a-b.len:e.translateY=a,this.group.attr(e)):(e.scaleY=1,e[d?"translateX":"translateY"]=b.pos,this.group.animate(e,this.options.animation),this.animate=null))},remove:function(){var a=this,b=a.chart;b.hasRendered&&p(b.series,function(b){b.type===a.type&&(b.isDirty=!0)}),O.prototype.remove.apply(a,arguments)}}),F.column=ga,ba.bar=w(ba.column),pa=ka(ga,{type:"bar",inverted:!0}),F.bar=pa,ba.scatter=w(S,{lineWidth:0,tooltip:{headerFormat:'<span style="color:{series.color}">â—</span> <span style="font-size: 10px;"> {series.name}</span><br/>',pointFormat:"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>"},stickyTracking:!1}),pa=ka(O,{type:"scatter",sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["markerGroup"],takeOrdinalPosition:!1,singularTooltips:!0,drawGraph:function(){this.options.lineWidth&&O.prototype.drawGraph.call(this)}}),F.scatter=pa,ba.pie=w(S,{borderColor:"#FFFFFF",borderWidth:1,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.point.name}},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,states:{hover:{brightness:.1,shadow:!1}},stickyTracking:!1,tooltip:{followPointer:!0}}),S={type:"pie",isCartesian:!1,pointClass:ka(Ea,{init:function(){Ea.prototype.init.apply(this,arguments);var b,a=this;return a.y<0&&(a.y=null),q(a,{visible:a.visible!==!1,name:m(a.name,"Slice")}),b=function(b){a.slice("select"===b.type)},K(a,"select",b),K(a,"unselect",b),a},setVisible:function(a){var b=this,c=b.series,d=c.chart;b.visible=b.options.visible=a=a===t?!b.visible:a,c.options.data[Da(b,c.data)]=b.options,p(["graphic","dataLabel","connector","shadowGroup"],function(c){b[c]&&b[c][a?"show":"hide"](!0)}),b.legendItem&&d.legend.colorizeItem(b,a),!c.isDirty&&c.options.ignoreHiddenPoint&&(c.isDirty=!0,d.redraw())},slice:function(a,b,c){var d=this.series;Qa(c,d.chart),m(b,!0),this.sliced=this.options.sliced=a=r(a)?a:!this.sliced,d.options.data[Da(this,d.data)]=this.options,a=a?this.slicedTranslation:{translateX:0,translateY:0},this.graphic.animate(a),this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var b=this.shapeArgs,c=this.series.chart;return this.series.chart.renderer.symbols.arc(c.plotLeft+b.x,c.plotTop+b.y,b.r+a,b.r+a,{innerR:this.shapeArgs.r,start:b.start,end:b.end})}}),requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},singularTooltips:!0,getColor:sa,animate:function(a){var b=this,c=b.points,d=b.startAngleRad;a||(p(c,function(a){var c=a.graphic,a=a.shapeArgs;c&&(c.attr({r:b.center[3]/2,start:d,end:d}),c.animate({r:a.r,start:a.start,end:a.end},b.options.animation))}),b.animate=null)},setData:function(a,b,c,d){O.prototype.setData.call(this,a,!1,c,d),this.processData(),this.generatePoints(),m(b,!0)&&this.chart.redraw(c)},generatePoints:function(){var a,c,d,e,b=0,f=this.options.ignoreHiddenPoint;for(O.prototype.generatePoints.call(this),c=this.points,d=c.length,a=0;d>a;a++)e=c[a],b+=f&&!e.visible?0:e.y;for(this.total=b,a=0;d>a;a++)e=c[a],e.percentage=b>0?e.y/b*100:0,e.total=b},translate:function(a){this.generatePoints();var f,g,h,o,p,b=0,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,i=c.startAngle||0,j=this.startAngleRad=ma/180*(i-90),i=(this.endAngleRad=ma/180*(m(c.endAngle,i+360)-90))-j,k=this.points,l=c.dataLabels.distance,c=c.ignoreHiddenPoint,n=k.length;for(a||(this.center=a=this.getCenter()),this.getX=function(b,c){return h=U.asin(C((b-a[1])/(a[2]/2+l),1)),a[0]+(c?-1:1)*Z(h)*(a[2]/2+l)},o=0;n>o;o++)p=k[o],f=j+b*i,(!c||p.visible)&&(b+=p.percentage/100),g=j+b*i,p.shapeType="arc",p.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:u(1e3*f)/1e3,end:u(1e3*g)/1e3},h=(g+f)/2,h>1.5*ma?h-=2*ma:-ma/2>h&&(h+=2*ma),p.slicedTranslation={translateX:u(Z(h)*d),translateY:u(ea(h)*d)},f=Z(h)*a[2]/2,g=ea(h)*a[2]/2,p.tooltipPos=[a[0]+.7*f,a[1]+.7*g],p.half=-ma/2>h||h>ma/2?1:0,p.angle=h,e=C(e,l/2),p.labelPos=[a[0]+f+Z(h)*l,a[1]+g+ea(h)*l,a[0]+f+Z(h)*e,a[1]+g+ea(h)*e,a[0]+f,a[1]+g,0>l?"center":p.half?"right":"left",h]},drawGraph:null,drawPoints:function(){var c,d,f,g,a=this,b=a.chart.renderer,e=a.options.shadow;e&&!a.shadowGroup&&(a.shadowGroup=b.g("shadow").add(a.group)),p(a.points,function(h){d=h.graphic,g=h.shapeArgs,f=h.shadowGroup,e&&!f&&(f=h.shadowGroup=b.g("shadow").add(a.shadowGroup)),c=h.sliced?h.slicedTranslation:{translateX:0,translateY:0},f&&f.attr(c),d?d.animate(q(g,c)):h.graphic=d=b[h.shapeType](g).setRadialReference(a.center).attr(h.pointAttr[h.selected?"select":""]).attr({"stroke-linejoin":"round"}).attr(c).add(a.group).shadow(e,f),void 0!==h.visible&&h.setVisible(h.visible)})},sortByAngle:function(a,b){a.sort(function(a,d){return void 0!==a.angle&&(d.angle-a.angle)*b})},drawLegendSymbol:N.drawRectangle,getCenter:X.getCenter,getSymbol:sa},S=ka(O,S),F.pie=S,O.prototype.drawDataLabels=function(){var f,g,h,i,a=this,b=a.options,c=b.cursor,d=b.dataLabels,e=a.points;(d.enabled||a._hasPointLabels)&&(a.dlProcessOptions&&a.dlProcessOptions(d),i=a.plotGroup("dataLabelsGroup","data-labels","hidden",d.zIndex||6),!a.hasRendered&&m(d.defer,!0)&&(i.attr({opacity:0}),K(a,"afterAnimate",function(){a.dataLabelsGroup.show()[b.animation?"animate":"attr"]({opacity:1},{duration:200})})),g=d,p(e,function(b){var e,o,n,l=b.dataLabel,p=b.connector,u=!0;if(f=b.options&&b.options.dataLabels,e=m(f&&f.enabled,g.enabled),l&&!e)b.dataLabel=l.destroy();else if(e){if(d=w(g,f),e=d.rotation,o=b.getLabelConfig(),h=d.format?Ia(d.format,o):d.formatter.call(o,d),d.style.color=m(d.color,d.style.color,a.color,"black"),l)r(h)?(l.attr({text:h}),u=!1):(b.dataLabel=l=l.destroy(),p&&(b.connector=p.destroy()));else if(r(h)){l={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:e,padding:d.padding,zIndex:1};for(n in l)l[n]===t&&delete l[n];l=b.dataLabel=a.chart.renderer[e?"text":"label"](h,0,-999,null,null,null,d.useHTML).attr(l).css(q(d.style,c&&{cursor:c})).add(i).shadow(d.shadow)}l&&a.alignDataLabel(b,l,d,null,u)}}))},O.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=m(a.plotX,-999),i=m(a.plotY,-999),j=b.getBBox();(a=this.visible&&(a.series.forceDL||f.isInsidePlot(h,u(i),g)||d&&f.isInsidePlot(h,g?d.x+1:d.y+d.height-1,g)))&&(d=q({x:g?f.plotWidth-i:h,y:u(g?f.plotHeight-h:i),width:0,height:0},d),q(c,{width:j.width,height:j.height}),c.rotation?(g={align:c.align,x:d.x+c.x+d.width/2,y:d.y+c.y+d.height/2},b[e?"attr":"animate"](g)):(b.align(c,null,d),g=b.alignAttr,"justify"===m(c.overflow,"justify")?this.justifyDataLabel(b,c,g,j,d,e):m(c.crop,!0)&&(a=f.isInsidePlot(g.x,g.y)&&f.isInsidePlot(g.x+j.width,g.y+j.height)))),a||(b.attr({y:-999}),b.placed=!1)},O.prototype.justifyDataLabel=function(a,b,c,d,e,f){var j,k,g=this.chart,h=b.align,i=b.verticalAlign;j=c.x,0>j&&("right"===h?b.align="left":b.x=-j,k=!0),j=c.x+d.width,j>g.plotWidth&&("left"===h?b.align="right":b.x=g.plotWidth-j,k=!0),j=c.y,0>j&&("bottom"===i?b.verticalAlign="top":b.y=-j,k=!0),j=c.y+d.height,j>g.plotHeight&&("top"===i?b.verticalAlign="bottom":b.y=g.plotHeight-j,k=!0),k&&(a.placed=!f,a.align(b,null,e))},F.pie&&(F.pie.prototype.drawDataLabels=function(){var c,i,j,t,w,x,y,A,C,G,D,B,a=this,b=a.data,d=a.chart,e=a.options.dataLabels,f=m(e.connectorPadding,10),g=m(e.connectorWidth,1),h=d.plotWidth,d=d.plotHeight,k=m(e.softConnector,!0),l=e.distance,o=a.center,n=o[2]/2,q=o[1],r=l>0,z=[[],[]],F=[0,0,0,0],N=function(a,b){return b.y-a.y};if(a.visible&&(e.enabled||a._hasPointLabels)){for(O.prototype.drawDataLabels.apply(a),p(b,function(a){a.dataLabel&&a.visible&&z[a.half].push(a)}),D=0;!y&&b[D];)y=b[D]&&b[D].dataLabel&&(b[D].dataLabel.getBBox().height||21),D++;for(D=2;D--;){var E,b=[],K=[],H=z[D],I=H.length;if(a.sortByAngle(H,D-.5),l>0){for(B=q-n-l;q+n+l>=B;B+=y)b.push(B);if(w=b.length,I>w){for(c=[].concat(H),c.sort(N),B=I;B--;)c[B].rank=B;for(B=I;B--;)H[B].rank>=w&&H.splice(B,1);I=H.length}for(B=0;I>B;B++){c=H[B],x=c.labelPos,c=9999;var Q,P;for(P=0;w>P;P++)Q=M(b[P]-x[1]),c>Q&&(c=Q,E=P);if(B>E&&null!==b[B])E=B;else for(I-B+E>w&&null!==b[B]&&(E=w-I+B);null===b[E];)E++;K.push({i:E,y:b[E]}),b[E]=null}K.sort(N)}for(B=0;I>B;B++)c=H[B],x=c.labelPos,t=c.dataLabel,G=c.visible===!1?"hidden":"visible",c=x[1],l>0?(w=K.pop(),E=w.i,C=w.y,(c>C&&null!==b[E+1]||C>c&&null!==b[E-1])&&(C=c)):C=c,A=e.justify?o[0]+(D?-1:1)*(n+l):a.getX(0===E||E===b.length-1?c:C,D),t._attr={visibility:G,align:x[6]},t._pos={x:A+e.x+({left:f,right:-f}[x[6]]||0),y:C+e.y-10},t.connX=A,t.connY=C,null===this.options.size&&(w=t.width,f>A-w?F[3]=v(u(w-A+f),F[3]):A+w>h-f&&(F[1]=v(u(A+w-h+f),F[1])),0>C-y/2?F[0]=v(u(-C+y/2),F[0]):C+y/2>d&&(F[2]=v(u(C+y/2-d),F[2])))}(0===Ba(F)||this.verifyDataLabelOverflow(F))&&(this.placeDataLabels(),r&&g&&p(this.points,function(b){i=b.connector,x=b.labelPos,(t=b.dataLabel)&&t._pos?(G=t._attr.visibility,A=t.connX,C=t.connY,j=k?["M",A+("left"===x[6]?5:-5),C,"C",A,C,2*x[2]-x[4],2*x[3]-x[5],x[2],x[3],"L",x[4],x[5]]:["M",A+("left"===x[6]?5:-5),C,"L",x[2],x[3],"L",x[4],x[5]],i?(i.animate({d:j}),i.attr("visibility",G)):b.connector=i=a.chart.renderer.path(j).attr({"stroke-width":g,stroke:e.connectorColor||b.color||"#606060",visibility:G}).add(a.dataLabelsGroup)):i&&(b.connector=i.destroy())}))}},F.pie.prototype.placeDataLabels=function(){p(this.points,function(a){var b,a=a.dataLabel;a&&((b=a._pos)?(a.attr(a._attr),a[a.moved?"animate":"attr"](b),a.moved=!0):a&&a.attr({y:-999}))})},F.pie.prototype.alignDataLabel=sa,F.pie.prototype.verifyDataLabelOverflow=function(a){var f,b=this.center,c=this.options,d=c.center,e=c=c.minSize||80;return null!==d[0]?e=v(b[2]-v(a[1],a[3]),c):(e=v(b[2]-a[1]-a[3],c),b[0]+=(a[3]-a[1])/2),null!==d[1]?e=v(C(e,b[2]-v(a[0],a[2])),c):(e=v(C(e,b[2]-a[0]-a[2]),c),b[1]+=(a[0]-a[2])/2),e<b[2]?(b[2]=e,this.translate(b),p(this.points,function(a){a.dataLabel&&(a.dataLabel._pos=null)}),this.drawDataLabels&&this.drawDataLabels()):f=!0,f}),F.column&&(F.column.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=a.dlBox||a.shapeArgs,i=a.below||a.plotY>m(this.translatedThreshold,f.plotSizeY),j=m(c.inside,!!this.options.stacking);h&&(d=w(h),g&&(d={x:f.plotWidth-d.y-d.height,y:f.plotHeight-d.x-d.width,width:d.height,height:d.width}),!j)&&(g?(d.x+=i?0:d.width,d.width=0):(d.y+=i?d.height:0,d.height=0)),c.align=m(c.align,!g||j?"center":i?"right":"left"),c.verticalAlign=m(c.verticalAlign,g||j?"middle":i?"top":"bottom"),O.prototype.alignDataLabel.call(this,a,b,c,d,e)}),S=R.TrackerMixin={drawTrackerPoint:function(){var a=this,b=a.chart,c=b.pointer,d=a.options.cursor,e=d&&{cursor:d},f=function(c){var e,d=c.target;for(b.hoverSeries!==a&&a.onMouseOver();d&&!e;)e=d.point,d=d.parentNode;e!==t&&e!==b.hoverPoint&&e.onMouseOver(c)};p(a.points,function(a){a.graphic&&(a.graphic.element.point=a),a.dataLabel&&(a.dataLabel.element.point=a)}),a._hasTracking||(p(a.trackerGroups,function(b){a[b]&&(a[b].addClass("highcharts-tracker").on("mouseover",f).on("mouseout",function(a){c.onTrackerMouseOut(a)}).css(e),$a)&&a[b].on("touchstart",f)}),a._hasTracking=!0)},drawTrackerGraph:function(){var m,a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),e=d.length,f=a.chart,g=f.pointer,h=f.renderer,i=f.options.tooltip.snap,j=a.tracker,k=b.cursor,l=k&&{cursor:k},k=a.singlePoints,n=function(){f.hoverSeries!==a&&a.onMouseOver()},q="rgba(192,192,192,"+(aa?1e-4:.002)+")";if(e&&!c)for(m=e+1;m--;)"M"===d[m]&&d.splice(m+1,0,d[m+1]-i,d[m+2],"L"),(m&&"M"===d[m]||m===e)&&d.splice(m,0,"L",d[m-2]+i,d[m-1]);for(m=0;m<k.length;m++)e=k[m],d.push("M",e.plotX-i,e.plotY,"L",e.plotX+i,e.plotY);j?j.attr({d:d}):(a.tracker=h.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:q,fill:c?q:Q,"stroke-width":b.lineWidth+(c?0:2*i),zIndex:2}).add(a.group),p([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",n).on("mouseout",function(a){g.onTrackerMouseOut(a)}).css(l),$a&&a.on("touchstart",n)}))}},F.column&&(ga.prototype.drawTracker=S.drawTrackerPoint),F.pie&&(F.pie.prototype.drawTracker=S.drawTrackerPoint),F.scatter&&(pa.prototype.drawTracker=S.drawTrackerPoint),q(lb.prototype,{setItemEvents:function(a,b,c,d,e){var f=this;(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover"),b.css(f.options.itemHoverStyle)}).on("mouseout",function(){b.css(a.visible?d:e),a.setState()}).on("click",function(b){var c=function(){a.setVisible()},b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):D(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox=Y("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container),K(a.checkbox,"click",function(b){D(a,"checkboxClick",{checked:b.target.checked},function(){a.select()})})}}),E.legend.itemStyle.cursor="pointer",q(Ya.prototype,{showResetZoom:function(){var a=this,b=E.lang,c=a.options.chart.resetZoomButton,d=c.theme,e=d.states,f="chart"===c.relativeTo?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()},d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).add().align(c.position,!1,f)},zoomOut:function(){var a=this;D(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var b,e,c=this.pointer,d=!1;!a||a.resetSelection?p(this.axes,function(a){b=a.zoom()}):p(a.xAxis.concat(a.yAxis),function(a){var e=a.axis,h=e.isXAxis;(c[h?"zoomX":"zoomY"]||c[h?"pinchX":"pinchY"])&&(b=e.zoom(a.min,a.max),e.displayBtn&&(d=!0))}),e=this.resetZoomButton,d&&!e?this.showResetZoom():!d&&ca(e)&&(this.resetZoomButton=e.destroy()),b&&this.redraw(m(this.options.chart.animation,a&&a.animation,this.pointCount<100))},pan:function(a,b){var e,c=this,d=c.hoverPoints;d&&p(d,function(a){a.setState()}),p("xy"===b?[1,0]:[1],function(b){var d=a[b?"chartX":"chartY"],h=c[b?"xAxis":"yAxis"][0],i=c[b?"mouseDownX":"mouseDownY"],j=(h.pointRange||0)/2,k=h.getExtremes(),l=h.toValue(i-d,!0)+j,i=h.toValue(i+c[b?"plotWidth":"plotHeight"]-d,!0)-j;h.series.length&&l>C(k.dataMin,k.min)&&i<v(k.dataMax,k.max)&&(h.setExtremes(l,i,!1,!1,{trigger:"pan"}),e=!0),c[b?"mouseDownX":"mouseDownY"]=d}),e&&c.redraw(!1),G(c.container,{cursor:"move"})}}),q(Ea.prototype,{select:function(a,b){var c=this,d=c.series,e=d.chart,a=m(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a,d.options.data[Da(c,d.data)]=c.options,c.setState(a&&"select"),b||p(e.getSelectedPoints(),function(a){a.selected&&a!==c&&(a.selected=a.options.selected=!1,d.options.data[Da(a,d.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a){var b=this.series,c=b.chart,d=c.tooltip,e=c.hoverPoint;e&&e!==this&&e.onMouseOut(),this.firePointEvent("mouseOver"),d&&(!d.shared||b.noSharedTooltip)&&d.refresh(this,a),this.setState("hover"),c.hoverPoint=this},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;b&&-1!==Da(this,b)||(this.firePointEvent("mouseOut"),this.setState(),a.hoverPoint=null)},importEvents:function(){if(!this.hasImportedEvents){var b,a=w(this.series.options.point,this.options).events;this.events=a;for(b in a)K(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var p,c=this.plotX,d=this.plotY,e=this.series,f=e.options.states,g=ba[e.type].marker&&e.options.marker,h=g&&!g.enabled,i=g&&g.states[a],j=i&&i.enabled===!1,k=e.stateMarkerGraphic,l=this.marker||{},m=e.chart,n=e.halo,a=a||"";p=this.pointAttr[a]||e.pointAttr[a],a===this.state&&!b||this.selected&&"select"!==a||f[a]&&f[a].enabled===!1||a&&(j||h&&i.enabled===!1)||a&&l.states&&l.states[a]&&l.states[a].enabled===!1||(this.graphic?(g=g&&this.graphic.symbolName&&p.r,this.graphic.attr(w(p,g?{x:c-g,y:d-g,width:2*g,height:2*g}:{})),k&&k.hide()):(a&&i&&(g=i.radius,l=l.symbol||e.symbol,k&&k.currentSymbol!==l&&(k=k.destroy()),k?k[b?"animate":"attr"]({x:c-g,y:d-g}):l&&(e.stateMarkerGraphic=k=m.renderer.symbol(l,c-g,d-g,2*g,2*g).attr(p).add(e.markerGroup),k.currentSymbol=l)),k&&k[a&&m.isInsidePlot(c,d,m.inverted)?"show":"hide"]()),(c=f[a]&&f[a].halo)&&c.size?(n||(e.halo=n=m.renderer.path().add(e.seriesGroup)),n.attr(q({fill:ya(this.color||e.color).setOpacity(c.opacity).get()},c.attributes))[b?"animate":"attr"]({d:this.haloPath(c.size)})):n&&n.attr({d:[]}),this.state=a)},haloPath:function(a){var b=this.series,c=b.chart,d=b.getPlotBox(),e=c.inverted;return c.renderer.symbols.circle(d.translateX+(e?b.yAxis.len-this.plotY:this.plotX)-a,d.translateY+(e?b.xAxis.len-this.plotX:this.plotY)-a,2*a,2*a)}}),q(O.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;b&&b!==this&&b.onMouseOut(),this.options.events.mouseOver&&D(this,"mouseOver"),this.setState("hover"),a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;d&&d.onMouseOut(),this&&a.events.mouseOut&&D(this,"mouseOut"),c&&!a.stickyTracking&&(!c.shared||this.noSharedTooltip)&&c.hide(),this.setState(),b.hoverSeries=null},setState:function(a){var b=this.options,c=this.graph,d=this.graphNeg,e=b.states,b=b.lineWidth,a=a||"";this.state!==a&&(this.state=a,e[a]&&e[a].enabled===!1||(a&&(b=e[a].lineWidth||b+1),c&&!c.dashstyle&&(a={"stroke-width":b},c.attr(a),d&&d.attr(a))))},setVisible:function(a,b){var f,c=this,d=c.chart,e=c.legendItem,g=d.options.chart.ignoreHiddenSeries,h=c.visible;f=(c.visible=a=c.userOptions.visible=a===t?!h:a)?"show":"hide",p(["group","dataLabelsGroup","markerGroup","tracker"],function(a){c[a]&&c[a][f]()}),d.hoverSeries===c&&c.onMouseOut(),e&&d.legend.colorizeItem(c,a),c.isDirty=!0,c.options.stacking&&p(d.series,function(a){a.options.stacking&&a.visible&&(a.isDirty=!0)}),p(c.linkedSeries,function(b){b.setVisible(a,!1)}),g&&(d.isDirtyBox=!0),b!==!1&&d.redraw(),D(c,f)},setTooltipPoints:function(a){var c,d,h,i,b=[],e=this.xAxis,f=e&&e.getExtremes(),g=e?e.tooltipLen||e.len:this.chart.plotSizeX,j=[];if(this.options.enableMouseTracking!==!1&&!this.singularTooltips){for(a&&(this.tooltipPoints=null),p(this.segments||this.points,function(a){b=b.concat(a)}),e&&e.reversed&&(b=b.reverse()),this.orderTooltipPoints&&this.orderTooltipPoints(b),a=b.length,i=0;a>i;i++)if(e=b[i],c=e.x,c>=f.min&&c<=f.max)for(h=b[i+1],c=d===t?0:d+1,d=b[i+1]?C(v(0,T((e.clientX+(h?h.wrappedClientX||h.clientX:g))/2)),g):g;c>=0&&d>=c;)j[c++]=e;this.tooltipPoints=j}},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=a===t?!this.selected:a,this.checkbox&&(this.checkbox.checked=a),D(this,a?"select":"unselect")},drawTracker:S.drawTrackerGraph}),q(R,{Axis:la,Chart:Ya,Color:ya,Point:Ea,Tick:Sa,Renderer:Za,Series:O,SVGElement:P,SVGRenderer:ta,arrayMin:Na,arrayMax:Ba,charts:V,dateFormat:cb,format:Ia,pathAnim:ub,getOptions:function(){return E},hasBidiBug:Nb,isTouchDevice:Jb,numberFormat:Ga,seriesTypes:F,setOptions:function(a){return E=w(!0,E,a),Cb(),E},addEvent:K,removeEvent:W,createElement:Y,discardElement:Pa,css:G,each:p,extend:q,map:Ua,merge:w,pick:m,splat:qa,extendClass:ka,pInt:z,wrap:Ma,svg:aa,canvas:fa,vml:!aa&&!fa,product:"Highcharts",version:"4.0.1"})}(),jQuery(document).ready(function($){$("#filter_action").select2(),$("#filter_content").select2({query:function(query){var key=query.term;$.ajax({type:"POST",url:li_admin_ajax.ajax_url,data:{action:"leadin_get_posts_and_pages",search_term:key},success:function(data){var i,json_data=jQuery.parseJSON(data),data_test={results:[]};for(i=0;i<json_data.length;i++)data_test.results.push({id:json_data[i].post_title,text:json_data[i].post_title});query.callback(data_test)}})},initSelection:function(){$("#filter_content").val()?$("#filter_content").select2("data",{id:$("#filter_content").val(),text:$("#filter_content").val()}):$("#filter_content").select2("data",{id:"",text:"Any Page"})}}),$("#leadin-contact-status").change(function(){$("#leadin-contact-status-button").addClass("button-primary")})}),jQuery(document).ready(function($){$("#leadin-contacts input:checkbox").not("thead input:checkbox, tfoot input:checkbox").bind("change",function(){var cb_count=0,selected_vals="",$btn_selected=$("#leadin-export-selected-leads"),$input_selected_vals=$("#leadin-selected-contacts"),$cb_selected=$("#leadin-contacts input:checkbox:checked").not("thead input:checkbox, tfoot input:checkbox");$cb_selected.length>0?$btn_selected.attr("disabled",!1):$btn_selected.attr("disabled",!0),$cb_selected.each(function(){selected_vals+=$(this).val(),cb_count!=$cb_selected.length-1&&(selected_vals+=","),cb_count++}),$input_selected_vals.val(selected_vals)}),$("#cb-select-all-1, #cb-select-all-2").bind("change",function(){var cb_count=0,selected_vals="",$this=$(this),$btn_selected=$("#leadin-export-selected-leads"),$cb_selected=$("#leadin-contacts input:checkbox").not("thead input:checkbox, tfoot input:checkbox"),$input_selected_vals=$("#leadin-selected-contacts");$cb_selected.each(function(){selected_vals+=$(this).val(),cb_count!=$cb_selected.length-1&&(selected_vals+=","),cb_count++}),$input_selected_vals.val(selected_vals),$this.is(":checked")?$btn_selected.attr("disabled",!1):$btn_selected.attr("disabled",!0)}),$(".postbox .handlediv").bind("click",function(){var $postbox=$(this).parent();$postbox.hasClass("closed")?$postbox.removeClass("closed"):$postbox.addClass("closed")})}),function($){"undefined"==typeof $.fn.each2&&$.extend($.fn,{each2:function(c){for(var j=$([0]),i=-1,l=this.length;++i<l&&(j.context=j[0]=this[i])&&c.call(j[0],i,j)!==!1;);return this}})}(jQuery),function($,undefined){"use strict";function reinsertElement(element){var placeholder=$(document.createTextNode(""));element.before(placeholder),placeholder.before(element),placeholder.remove()}function stripDiacritics(str){function match(a){return DIACRITICS[a]||a}return str.replace(/[^\u0000-\u007E]/g,match)}function indexOf(value,array){for(var i=0,l=array.length;l>i;i+=1)if(equal(value,array[i]))return i;return-1}function measureScrollbar(){var $template=$(MEASURE_SCROLLBAR_TEMPLATE);$template.appendTo("body");var dim={width:$template.width()-$template[0].clientWidth,height:$template.height()-$template[0].clientHeight};return $template.remove(),dim}function equal(a,b){return a===b?!0:a===undefined||b===undefined?!1:null===a||null===b?!1:a.constructor===String?a+""==b+"":b.constructor===String?b+""==a+"":!1}function splitVal(string,separator){var val,i,l;if(null===string||string.length<1)return[];for(val=string.split(separator),i=0,l=val.length;l>i;i+=1)val[i]=$.trim(val[i]);return val}function getSideBorderPadding(element){return element.outerWidth(!1)-element.width()}function installKeyUpChangeEvent(element){var key="keyup-change-value";element.on("keydown",function(){$.data(element,key)===undefined&&$.data(element,key,element.val())}),element.on("keyup",function(){var val=$.data(element,key);val!==undefined&&element.val()!==val&&($.removeData(element,key),element.trigger("keyup-change"))})}function installFilteredMouseMove(element){element.on("mousemove",function(e){var lastpos=lastMousePosition;(lastpos===undefined||lastpos.x!==e.pageX||lastpos.y!==e.pageY)&&$(e.target).trigger("mousemove-filtered",e)})}function debounce(quietMillis,fn,ctx){ctx=ctx||undefined;var timeout;return function(){var args=arguments;window.clearTimeout(timeout),timeout=window.setTimeout(function(){fn.apply(ctx,args)},quietMillis)}}function installDebouncedScroll(threshold,element){var notify=debounce(threshold,function(e){element.trigger("scroll-debounced",e)});element.on("scroll",function(e){indexOf(e.target,element.get())>=0&¬ify(e)})}function focus($el){$el[0]!==document.activeElement&&window.setTimeout(function(){var range,el=$el[0],pos=$el.val().length;$el.focus();var isVisible=el.offsetWidth>0||el.offsetHeight>0;isVisible&&el===document.activeElement&&(el.setSelectionRange?el.setSelectionRange(pos,pos):el.createTextRange&&(range=el.createTextRange(),range.collapse(!1),range.select()))},0)}function getCursorInfo(el){el=$(el)[0];var offset=0,length=0;if("selectionStart"in el)offset=el.selectionStart,length=el.selectionEnd-offset;else if("selection"in document){el.focus();var sel=document.selection.createRange();length=document.selection.createRange().text.length,sel.moveStart("character",-el.value.length),offset=sel.text.length-length}return{offset:offset,length:length}}function killEvent(event){event.preventDefault(),event.stopPropagation()}function killEventImmediately(event){event.preventDefault(),event.stopImmediatePropagation()}function measureTextWidth(e){if(!sizer){var style=e[0].currentStyle||window.getComputedStyle(e[0],null);sizer=$(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:style.fontSize,fontFamily:style.fontFamily,fontStyle:style.fontStyle,fontWeight:style.fontWeight,letterSpacing:style.letterSpacing,textTransform:style.textTransform,whiteSpace:"nowrap"}),sizer.attr("class","select2-sizer"),$("body").append(sizer)}return sizer.text(e.val()),sizer.width()}function syncCssClasses(dest,src,adapter){var classes,adapted,replacements=[];classes=dest.attr("class"),classes&&(classes=""+classes,$(classes.split(" ")).each2(function(){0===this.indexOf("select2-")&&replacements.push(this)})),classes=src.attr("class"),classes&&(classes=""+classes,$(classes.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(adapted=adapter(this),adapted&&replacements.push(adapted))})),dest.attr("class",replacements.join(" "))}function markMatch(text,term,markup,escapeMarkup){var match=stripDiacritics(text.toUpperCase()).indexOf(stripDiacritics(term.toUpperCase())),tl=term.length;return 0>match?void markup.push(escapeMarkup(text)):(markup.push(escapeMarkup(text.substring(0,match))),markup.push("<span class='select2-match'>"),markup.push(escapeMarkup(text.substring(match,match+tl))),markup.push("</span>"),void markup.push(escapeMarkup(text.substring(match+tl,text.length))))}function defaultEscapeMarkup(markup){var replace_map={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(markup).replace(/[&<>"'\/\\]/g,function(match){return replace_map[match]})}function ajax(options){var timeout,handler=null,quietMillis=options.quietMillis||100,ajaxUrl=options.url,self=this;return function(query){window.clearTimeout(timeout),timeout=window.setTimeout(function(){var data=options.data,url=ajaxUrl,transport=options.transport||$.fn.select2.ajaxDefaults.transport,deprecated={type:options.type||"GET",cache:options.cache||!1,jsonpCallback:options.jsonpCallback||undefined,dataType:options.dataType||"json"},params=$.extend({},$.fn.select2.ajaxDefaults.params,deprecated);data=data?data.call(self,query.term,query.page,query.context):null,url="function"==typeof url?url.call(self,query.term,query.page,query.context):url,handler&&"function"==typeof handler.abort&&handler.abort(),options.params&&($.isFunction(options.params)?$.extend(params,options.params.call(self)):$.extend(params,options.params)),$.extend(params,{url:url,dataType:options.dataType,data:data,success:function(data){var results=options.results(data,query.page);query.callback(results)}}),handler=transport.call(self,params)},quietMillis)}}function local(options){var dataText,tmp,data=options,text=function(item){return""+item.text};$.isArray(data)&&(tmp=data,data={results:tmp}),$.isFunction(data)===!1&&(tmp=data,data=function(){return tmp});var dataItem=data();return dataItem.text&&(text=dataItem.text,$.isFunction(text)||(dataText=dataItem.text,text=function(item){return item[dataText]})),function(query){var process,t=query.term,filtered={results:[]};return""===t?void query.callback(data()):(process=function(datum,collection){var group,attr;if(datum=datum[0],datum.children){group={};for(attr in datum)datum.hasOwnProperty(attr)&&(group[attr]=datum[attr]);group.children=[],$(datum.children).each2(function(i,childDatum){process(childDatum,group.children)}),(group.children.length||query.matcher(t,text(group),datum))&&collection.push(group)}else query.matcher(t,text(datum),datum)&&collection.push(datum)},$(data().results).each2(function(i,datum){process(datum,filtered.results)}),void query.callback(filtered))}}function tags(data){var isFunc=$.isFunction(data);return function(query){var t=query.term,filtered={results:[]},result=isFunc?data(query):data;$.isArray(result)&&($(result).each(function(){var isObject=this.text!==undefined,text=isObject?this.text:this;
|
6 |
-
(""===t||query.matcher(t,text))&&filtered.results.push(isObject?this:{id:this,text:this})}),query.callback(filtered))}}function checkFormatter(formatter,formatterName){if($.isFunction(formatter))return!0;if(!formatter)return!1;if("string"==typeof formatter)return!0;throw new Error(formatterName+" must be a string, function, or falsy value")}function evaluate(val){if($.isFunction(val)){var args=Array.prototype.slice.call(arguments,1);return val.apply(null,args)}return val}function countResults(results){var count=0;return $.each(results,function(i,item){item.children?count+=countResults(item.children):count++}),count}function defaultTokenizer(input,selection,selectCallback,opts){var token,index,i,l,separator,original=input,dupe=!1;if(!opts.createSearchChoice||!opts.tokenSeparators||opts.tokenSeparators.length<1)return undefined;for(;;){for(index=-1,i=0,l=opts.tokenSeparators.length;l>i&&(separator=opts.tokenSeparators[i],index=input.indexOf(separator),!(index>=0));i++);if(0>index)break;if(token=input.substring(0,index),input=input.substring(index+separator.length),token.length>0&&(token=opts.createSearchChoice.call(this,token,selection),token!==undefined&&null!==token&&opts.id(token)!==undefined&&null!==opts.id(token))){for(dupe=!1,i=0,l=selection.length;l>i;i++)if(equal(opts.id(token),opts.id(selection[i]))){dupe=!0;break}dupe||selectCallback(token)}}return original!==input?input:void 0}function cleanupJQueryElements(){var self=this;Array.prototype.forEach.call(arguments,function(element){self[element].remove(),self[element]=null})}function clazz(SuperClass,methods){var constructor=function(){};return constructor.prototype=new SuperClass,constructor.prototype.constructor=constructor,constructor.prototype.parent=SuperClass.prototype,constructor.prototype=$.extend(constructor.prototype,methods),constructor}if(window.Select2===undefined){var KEY,AbstractSelect2,SingleSelect2,MultiSelect2,nextUid,sizer,$document,scrollBarDimensions,lastMousePosition={x:0,y:0},KEY={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(k){switch(k=k.which?k.which:k){case KEY.LEFT:case KEY.RIGHT:case KEY.UP:case KEY.DOWN:return!0}return!1},isControl:function(e){var k=e.which;switch(k){case KEY.SHIFT:case KEY.CTRL:case KEY.ALT:return!0}return e.metaKey?!0:!1},isFunctionKey:function(k){return k=k.which?k.which:k,k>=112&&123>=k}},MEASURE_SCROLLBAR_TEMPLATE="<div class='select2-measure-scrollbar'></div>",DIACRITICS={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z"};$document=$(document),nextUid=function(){var counter=1;return function(){return counter++}}(),$document.on("mousemove",function(e){lastMousePosition.x=e.pageX,lastMousePosition.y=e.pageY}),AbstractSelect2=clazz(Object,{bind:function(func){var self=this;return function(){func.apply(self,arguments)}},init:function(opts){var results,search,resultsSelector=".select2-results";this.opts=opts=this.prepareOpts(opts),this.id=opts.id,opts.element.data("select2")!==undefined&&null!==opts.element.data("select2")&&opts.element.data("select2").destroy(),this.container=this.createContainer(),this.liveRegion=$("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body),this.containerId="s2id_"+(opts.element.attr("id")||"autogen"+nextUid()),this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.container.attr("title",opts.element.attr("title")),this.body=$("body"),syncCssClasses(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",opts.element.attr("style")),this.container.css(evaluate(opts.containerCss)),this.container.addClass(evaluate(opts.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",killEvent),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),syncCssClasses(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(evaluate(opts.dropdownCssClass)),this.dropdown.data("select2",this),this.dropdown.on("click",killEvent),this.results=results=this.container.find(resultsSelector),this.search=search=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",killEvent),installFilteredMouseMove(this.results),this.dropdown.on("mousemove-filtered",resultsSelector,this.bind(this.highlightUnderEvent)),this.dropdown.on("touchstart touchmove touchend",resultsSelector,this.bind(function(event){this._touchEvent=!0,this.highlightUnderEvent(event)})),this.dropdown.on("touchmove",resultsSelector,this.bind(this.touchMoved)),this.dropdown.on("touchstart touchend",resultsSelector,this.bind(this.clearTouchMoved)),this.dropdown.on("click",this.bind(function(){this._touchEvent&&(this._touchEvent=!1,this.selectHighlighted())})),installDebouncedScroll(80,this.results),this.dropdown.on("scroll-debounced",resultsSelector,this.bind(this.loadMoreIfNeeded)),$(this.container).on("change",".select2-input",function(e){e.stopPropagation()}),$(this.dropdown).on("change",".select2-input",function(e){e.stopPropagation()}),$.fn.mousewheel&&results.mousewheel(function(e,delta,deltaX,deltaY){var top=results.scrollTop();deltaY>0&&0>=top-deltaY?(results.scrollTop(0),killEvent(e)):0>deltaY&&results.get(0).scrollHeight-results.scrollTop()+deltaY<=results.height()&&(results.scrollTop(results.get(0).scrollHeight-results.height()),killEvent(e))}),installKeyUpChangeEvent(search),search.on("keyup-change input paste",this.bind(this.updateResults)),search.on("focus",function(){search.addClass("select2-focused")}),search.on("blur",function(){search.removeClass("select2-focused")}),this.dropdown.on("mouseup",resultsSelector,this.bind(function(e){$(e.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(e),this.selectHighlighted(e))})),this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(e){e.stopPropagation()}),this.nextSearchTerm=undefined,$.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==opts.maximumInputLength&&this.search.attr("maxlength",opts.maximumInputLength);var disabled=opts.element.prop("disabled");disabled===undefined&&(disabled=!1),this.enable(!disabled);var readonly=opts.element.prop("readonly");readonly===undefined&&(readonly=!1),this.readonly(readonly),scrollBarDimensions=scrollBarDimensions||measureScrollbar(),this.autofocus=opts.element.prop("autofocus"),opts.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.search.attr("placeholder",opts.searchInputPlaceholder)},destroy:function(){var element=this.opts.element,select2=element.data("select2");this.close(),this.propertyObserver&&(this.propertyObserver.disconnect(),this.propertyObserver=null),select2!==undefined&&(select2.container.remove(),select2.liveRegion.remove(),select2.dropdown.remove(),element.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?element.attr({tabindex:this.elementTabIndex}):element.removeAttr("tabindex"),element.show()),cleanupJQueryElements.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(element){return element.is("option")?{id:element.prop("value"),text:element.text(),element:element.get(),css:element.attr("class"),disabled:element.prop("disabled"),locked:equal(element.attr("locked"),"locked")||equal(element.data("locked"),!0)}:element.is("optgroup")?{text:element.attr("label"),children:[],element:element.get(),css:element.attr("class")}:void 0},prepareOpts:function(opts){var element,select,idKey,ajaxUrl,self=this;if(element=opts.element,"select"===element.get(0).tagName.toLowerCase()&&(this.select=select=opts.element),select&&$.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in opts)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),opts=$.extend({},{populateResults:function(container,results,query){var populate,id=this.opts.id,liveRegion=this.liveRegion;(populate=function(results,container,depth){var i,l,result,selectable,disabled,compound,node,label,innerContainer,formatted;for(results=opts.sortResults(results,container,query),i=0,l=results.length;l>i;i+=1)result=results[i],disabled=result.disabled===!0,selectable=!disabled&&id(result)!==undefined,compound=result.children&&result.children.length>0,node=$("<li></li>"),node.addClass("select2-results-dept-"+depth),node.addClass("select2-result"),node.addClass(selectable?"select2-result-selectable":"select2-result-unselectable"),disabled&&node.addClass("select2-disabled"),compound&&node.addClass("select2-result-with-children"),node.addClass(self.opts.formatResultCssClass(result)),node.attr("role","presentation"),label=$(document.createElement("div")),label.addClass("select2-result-label"),label.attr("id","select2-result-label-"+nextUid()),label.attr("role","option"),formatted=opts.formatResult(result,label,query,self.opts.escapeMarkup),formatted!==undefined&&(label.html(formatted),node.append(label)),compound&&(innerContainer=$("<ul></ul>"),innerContainer.addClass("select2-result-sub"),populate(result.children,innerContainer,depth+1),node.append(innerContainer)),node.data("select2-data",result),container.append(node);liveRegion.text(opts.formatMatches(results.length))})(results,container,0)}},$.fn.select2.defaults,opts),"function"!=typeof opts.id&&(idKey=opts.id,opts.id=function(e){return e[idKey]}),$.isArray(opts.element.data("select2Tags"))){if("tags"in opts)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+opts.element.attr("id");opts.tags=opts.element.data("select2Tags")}if(select?(opts.query=this.bind(function(query){var children,placeholderOption,process,data={results:[],more:!1},term=query.term;process=function(element,collection){var group;element.is("option")?query.matcher(term,element.text(),element)&&collection.push(self.optionToData(element)):element.is("optgroup")&&(group=self.optionToData(element),element.children().each2(function(i,elm){process(elm,group.children)}),group.children.length>0&&collection.push(group))},children=element.children(),this.getPlaceholder()!==undefined&&children.length>0&&(placeholderOption=this.getPlaceholderOption(),placeholderOption&&(children=children.not(placeholderOption))),children.each2(function(i,elm){process(elm,data.results)}),query.callback(data)}),opts.id=function(e){return e.id}):"query"in opts||("ajax"in opts?(ajaxUrl=opts.element.data("ajax-url"),ajaxUrl&&ajaxUrl.length>0&&(opts.ajax.url=ajaxUrl),opts.query=ajax.call(opts.element,opts.ajax)):"data"in opts?opts.query=local(opts.data):"tags"in opts&&(opts.query=tags(opts.tags),opts.createSearchChoice===undefined&&(opts.createSearchChoice=function(term){return{id:$.trim(term),text:$.trim(term)}}),opts.initSelection===undefined&&(opts.initSelection=function(element,callback){var data=[];$(splitVal(element.val(),opts.separator)).each(function(){var obj={id:this,text:this},tags=opts.tags;$.isFunction(tags)&&(tags=tags()),$(tags).each(function(){return equal(this.id,obj.id)?(obj=this,!1):void 0}),data.push(obj)}),callback(data)}))),"function"!=typeof opts.query)throw"query function not defined for Select2 "+opts.element.attr("id");if("top"===opts.createSearchChoicePosition)opts.createSearchChoicePosition=function(list,item){list.unshift(item)};else if("bottom"===opts.createSearchChoicePosition)opts.createSearchChoicePosition=function(list,item){list.push(item)};else if("function"!=typeof opts.createSearchChoicePosition)throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";return opts},monitorSource:function(){var sync,observer,el=this.opts.element;el.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),sync=this.bind(function(){var disabled=el.prop("disabled");disabled===undefined&&(disabled=!1),this.enable(!disabled);var readonly=el.prop("readonly");readonly===undefined&&(readonly=!1),this.readonly(readonly),syncCssClasses(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(evaluate(this.opts.containerCssClass)),syncCssClasses(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(evaluate(this.opts.dropdownCssClass))}),el.length&&el[0].attachEvent&&el.each(function(){this.attachEvent("onpropertychange",sync)}),observer=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,observer!==undefined&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new observer(function(mutations){mutations.forEach(sync)}),this.propertyObserver.observe(el.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(data){var evt=$.Event("select2-selecting",{val:this.id(data),object:data});return this.opts.element.trigger(evt),!evt.isDefaultPrevented()},triggerChange:function(details){details=details||{},details=$.extend({},details,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(details),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var enabled=this._enabled&&!this._readonly,disabled=!enabled;return enabled===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",disabled),this.close(),this.enabledInterface=enabled,!0)},enable:function(enabled){enabled===undefined&&(enabled=!0),this._enabled!==enabled&&(this._enabled=enabled,this.opts.element.prop("disabled",!enabled),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(enabled){enabled===undefined&&(enabled=!1),this._readonly!==enabled&&(this._readonly=enabled,this.opts.element.prop("readonly",enabled),this.enableInterface())},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var bodyOffset,above,changeDirection,css,resultsListNode,$dropdown=this.dropdown,offset=this.container.offset(),height=this.container.outerHeight(!1),width=this.container.outerWidth(!1),dropHeight=$dropdown.outerHeight(!1),$window=$(window),windowWidth=$window.width(),windowHeight=$window.height(),viewPortRight=$window.scrollLeft()+windowWidth,viewportBottom=$window.scrollTop()+windowHeight,dropTop=offset.top+height,dropLeft=offset.left,enoughRoomBelow=viewportBottom>=dropTop+dropHeight,enoughRoomAbove=offset.top-dropHeight>=$window.scrollTop(),dropWidth=$dropdown.outerWidth(!1),enoughRoomOnRight=viewPortRight>=dropLeft+dropWidth,aboveNow=$dropdown.hasClass("select2-drop-above");aboveNow?(above=!0,!enoughRoomAbove&&enoughRoomBelow&&(changeDirection=!0,above=!1)):(above=!1,!enoughRoomBelow&&enoughRoomAbove&&(changeDirection=!0,above=!0)),changeDirection&&($dropdown.hide(),offset=this.container.offset(),height=this.container.outerHeight(!1),width=this.container.outerWidth(!1),dropHeight=$dropdown.outerHeight(!1),viewPortRight=$window.scrollLeft()+windowWidth,viewportBottom=$window.scrollTop()+windowHeight,dropTop=offset.top+height,dropLeft=offset.left,dropWidth=$dropdown.outerWidth(!1),enoughRoomOnRight=viewPortRight>=dropLeft+dropWidth,$dropdown.show(),this.focusSearch()),this.opts.dropdownAutoWidth?(resultsListNode=$(".select2-results",$dropdown)[0],$dropdown.addClass("select2-drop-auto-width"),$dropdown.css("width",""),dropWidth=$dropdown.outerWidth(!1)+(resultsListNode.scrollHeight===resultsListNode.clientHeight?0:scrollBarDimensions.width),dropWidth>width?width=dropWidth:dropWidth=width,dropHeight=$dropdown.outerHeight(!1),enoughRoomOnRight=viewPortRight>=dropLeft+dropWidth):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body.css("position")&&(bodyOffset=this.body.offset(),dropTop-=bodyOffset.top,dropLeft-=bodyOffset.left),enoughRoomOnRight||(dropLeft=offset.left+this.container.outerWidth(!1)-dropWidth),css={left:dropLeft,width:width},above?(css.top=offset.top-dropHeight,css.bottom="auto",this.container.addClass("select2-drop-above"),$dropdown.addClass("select2-drop-above")):(css.top=dropTop,css.bottom="auto",this.container.removeClass("select2-drop-above"),$dropdown.removeClass("select2-drop-above")),css=$.extend(css,evaluate(this.opts.dropdownCss)),$dropdown.css(css)},shouldOpen:function(){var event;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(event=$.Event("select2-opening"),this.opts.element.trigger(event),!event.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){var mask,cid=this.containerEventName,scroll="scroll."+cid,resize="resize."+cid,orient="orientationchange."+cid;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body.children().last()[0]&&this.dropdown.detach().appendTo(this.body),mask=$("#select2-drop-mask"),0==mask.length&&(mask=$(document.createElement("div")),mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),mask.hide(),mask.appendTo(this.body),mask.on("mousedown touchstart click",function(e){reinsertElement(mask);var self,dropdown=$("#select2-drop");dropdown.length>0&&(self=dropdown.data("select2"),self.opts.selectOnBlur&&self.selectHighlighted({noFocus:!0}),self.close(),e.preventDefault(),e.stopPropagation())})),this.dropdown.prev()[0]!==mask[0]&&this.dropdown.before(mask),$("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),mask.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var that=this;this.container.parents().add(window).each(function(){$(this).on(resize+" "+scroll+" "+orient,function(){that.opened()&&that.positionDropdown()})})},close:function(){if(this.opened()){var cid=this.containerEventName,scroll="scroll."+cid,resize="resize."+cid,orient="orientationchange."+cid;this.container.parents().add(window).each(function(){$(this).off(scroll).off(resize).off(orient)}),this.clearDropdownAlignmentPreference(),$("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger($.Event("select2-close"))}},externalSearch:function(term){this.open(),this.search.val(term),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return evaluate(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var children,index,child,hb,rb,y,more,results=this.results;if(index=this.highlight(),!(0>index)){if(0==index)return void results.scrollTop(0);children=this.findHighlightableChoices().find(".select2-result-label"),child=$(children[index]),hb=child.offset().top+child.outerHeight(!0),index===children.length-1&&(more=results.find("li.select2-more-results"),more.length>0&&(hb=more.offset().top+more.outerHeight(!0))),rb=results.offset().top+results.outerHeight(!0),hb>rb&&results.scrollTop(results.scrollTop()+(hb-rb)),y=child.offset().top-results.offset().top,0>y&&"none"!=child.css("display")&&results.scrollTop(results.scrollTop()+y)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(delta){for(var choices=this.findHighlightableChoices(),index=this.highlight();index>-1&&index<choices.length;){index+=delta;var choice=$(choices[index]);if(choice.hasClass("select2-result-selectable")&&!choice.hasClass("select2-disabled")&&!choice.hasClass("select2-selected")){this.highlight(index);break}}},highlight:function(index){var choice,data,choices=this.findHighlightableChoices();return 0===arguments.length?indexOf(choices.filter(".select2-highlighted")[0],choices.get()):(index>=choices.length&&(index=choices.length-1),0>index&&(index=0),this.removeHighlight(),choice=$(choices[index]),choice.addClass("select2-highlighted"),this.search.attr("aria-activedescendant",choice.find(".select2-result-label").attr("id")),this.ensureHighlightVisible(),this.liveRegion.text(choice.text()),data=choice.data("select2-data"),void(data&&this.opts.element.trigger({type:"select2-highlight",val:this.id(data),choice:data})))},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=!0},clearTouchMoved:function(){this._touchMoved=!1},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(event){var el=$(event.target).closest(".select2-result-selectable");if(el.length>0&&!el.is(".select2-highlighted")){var choices=this.findHighlightableChoices();this.highlight(choices.index(el))}else 0==el.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var below,results=this.results,more=results.find("li.select2-more-results"),page=this.resultsPage+1,self=this,term=this.search.val(),context=this.context;0!==more.length&&(below=more.offset().top-results.offset().top-results.height(),below<=this.opts.loadMorePadding&&(more.addClass("select2-active"),this.opts.query({element:this.opts.element,term:term,page:page,context:context,matcher:this.opts.matcher,callback:this.bind(function(data){self.opened()&&(self.opts.populateResults.call(this,results,data.results,{term:term,page:page,context:context}),self.postprocessResults(data,!1,!1),data.more===!0?(more.detach().appendTo(results).text(evaluate(self.opts.formatLoadMore,page+1)),window.setTimeout(function(){self.loadMoreIfNeeded()},10)):more.remove(),self.positionDropdown(),self.resultsPage=page,self.context=data.context,this.opts.element.trigger({type:"select2-loaded",items:data}))})})))},tokenize:function(){},updateResults:function(initial){function postRender(){search.removeClass("select2-active"),self.positionDropdown(),self.liveRegion.text(results.find(".select2-no-results,.select2-selection-limit,.select2-searching").length?results.text():self.opts.formatMatches(results.find(".select2-result-selectable").length))}function render(html){results.html(html),postRender()}var data,input,queryNumber,search=this.search,results=this.results,opts=this.opts,self=this,term=search.val(),lastTerm=$.data(this.container,"select2-last-term");if((initial===!0||!lastTerm||!equal(term,lastTerm))&&($.data(this.container,"select2-last-term",term),initial===!0||this.showSearchInput!==!1&&this.opened())){queryNumber=++this.queryCount;var maxSelSize=this.getMaximumSelectionSize();if(maxSelSize>=1&&(data=this.data(),$.isArray(data)&&data.length>=maxSelSize&&checkFormatter(opts.formatSelectionTooBig,"formatSelectionTooBig")))return void render("<li class='select2-selection-limit'>"+evaluate(opts.formatSelectionTooBig,maxSelSize)+"</li>");if(search.val().length<opts.minimumInputLength)return render(checkFormatter(opts.formatInputTooShort,"formatInputTooShort")?"<li class='select2-no-results'>"+evaluate(opts.formatInputTooShort,search.val(),opts.minimumInputLength)+"</li>":""),void(initial&&this.showSearch&&this.showSearch(!0));if(opts.maximumInputLength&&search.val().length>opts.maximumInputLength)return void render(checkFormatter(opts.formatInputTooLong,"formatInputTooLong")?"<li class='select2-no-results'>"+evaluate(opts.formatInputTooLong,search.val(),opts.maximumInputLength)+"</li>":"");opts.formatSearching&&0===this.findHighlightableChoices().length&&render("<li class='select2-searching'>"+evaluate(opts.formatSearching)+"</li>"),search.addClass("select2-active"),this.removeHighlight(),input=this.tokenize(),input!=undefined&&null!=input&&search.val(input),this.resultsPage=1,opts.query({element:opts.element,term:search.val(),page:this.resultsPage,context:null,matcher:opts.matcher,callback:this.bind(function(data){var def;if(queryNumber==this.queryCount){if(!this.opened())return void this.search.removeClass("select2-active");if(this.context=data.context===undefined?null:data.context,this.opts.createSearchChoice&&""!==search.val()&&(def=this.opts.createSearchChoice.call(self,search.val(),data.results),def!==undefined&&null!==def&&self.id(def)!==undefined&&null!==self.id(def)&&0===$(data.results).filter(function(){return equal(self.id(this),self.id(def))}).length&&this.opts.createSearchChoicePosition(data.results,def)),0===data.results.length&&checkFormatter(opts.formatNoMatches,"formatNoMatches"))return void render("<li class='select2-no-results'>"+evaluate(opts.formatNoMatches,search.val())+"</li>");results.empty(),self.opts.populateResults.call(this,results,data.results,{term:search.val(),page:this.resultsPage,context:null}),data.more===!0&&checkFormatter(opts.formatLoadMore,"formatLoadMore")&&(results.append("<li class='select2-more-results'>"+self.opts.escapeMarkup(evaluate(opts.formatLoadMore,this.resultsPage))+"</li>"),window.setTimeout(function(){self.loadMoreIfNeeded()
|
7 |
-
},10)),this.postprocessResults(data,initial),postRender(),this.opts.element.trigger({type:"select2-loaded",items:data})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){focus(this.search)},selectHighlighted:function(options){if(this._touchMoved)return void this.clearTouchMoved();var index=this.highlight(),highlighted=this.results.find(".select2-highlighted"),data=highlighted.closest(".select2-result").data("select2-data");data?(this.highlight(index),this.onSelect(data,options)):options&&options.noFocus&&this.close()},getPlaceholder:function(){var placeholderOption;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((placeholderOption=this.getPlaceholderOption())!==undefined?placeholderOption.text():undefined)},getPlaceholderOption:function(){if(this.select){var firstOption=this.select.children("option").first();if(this.opts.placeholderOption!==undefined)return"first"===this.opts.placeholderOption&&firstOption||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===$.trim(firstOption.text())&&""===firstOption.val())return firstOption}},initContainerWidth:function(){function resolveContainerWidth(){var style,attrs,matches,i,l,attr;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(style=this.opts.element.attr("style"),style!==undefined)for(attrs=style.split(";"),i=0,l=attrs.length;l>i;i+=1)if(attr=attrs[i].replace(/\s/g,""),matches=attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==matches&&matches.length>=1)return matches[1];return"resolve"===this.opts.width?(style=this.opts.element.css("width"),style.indexOf("%")>0?style:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return $.isFunction(this.opts.width)?this.opts.width():this.opts.width}var width=resolveContainerWidth.call(this);null!==width&&this.container.css("width",width)}}),SingleSelect2=clazz(AbstractSelect2,{createContainer:function(){var container=$(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'> </span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'"," aria-autocomplete='list' />"," </div>"," <ul class='select2-results' role='listbox'>"," </ul>","</div>"].join(""));return container},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var el,range,len;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.opts.shouldFocusInput(this)&&(this.search.focus(),el=this.search.get(0),el.createTextRange?(range=el.createTextRange(),range.collapse(!1),range.select()):el.setSelectionRange&&(len=this.search.val().length,el.setSelectionRange(len,len))),""===this.search.val()&&this.nextSearchTerm!=undefined&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger($.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus()},destroy:function(){$("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),cleanupJQueryElements.call(this,"selection","focusser")},initContainer:function(){var selection,elementLabel,container=this.container,dropdown=this.dropdown,idSuffix=nextUid();this.showSearch(this.opts.minimumResultsForSearch<0?!1:!0),this.selection=selection=container.find(".select2-choice"),this.focusser=container.find(".select2-focusser"),selection.find(".select2-chosen").attr("id","select2-chosen-"+idSuffix),this.focusser.attr("aria-labelledby","select2-chosen-"+idSuffix),this.results.attr("id","select2-results-"+idSuffix),this.search.attr("aria-owns","select2-results-"+idSuffix),this.focusser.attr("id","s2id_autogen"+idSuffix),elementLabel=$("label[for='"+this.opts.element.attr("id")+"']"),this.focusser.prev().text(elementLabel.text()).attr("for",this.focusser.attr("id"));var originalTitle=this.opts.element.attr("title");this.opts.element.attr("title",originalTitle||elementLabel.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.attr("id",this.focusser.attr("id")+"_search"),this.search.prev().text($("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){if(e.which===KEY.PAGE_UP||e.which===KEY.PAGE_DOWN)return void killEvent(e);switch(e.which){case KEY.UP:case KEY.DOWN:return this.moveHighlight(e.which===KEY.UP?-1:1),void killEvent(e);case KEY.ENTER:return this.selectHighlighted(),void killEvent(e);case KEY.TAB:return void this.selectHighlighted({noFocus:!0});case KEY.ESC:return this.cancel(e),void killEvent(e)}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body.get(0)&&window.setTimeout(this.bind(function(){this.opened()&&this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()&&e.which!==KEY.TAB&&!KEY.isControl(e)&&!KEY.isFunctionKey(e)&&e.which!==KEY.ESC){if(this.opts.openOnEnter===!1&&e.which===KEY.ENTER)return void killEvent(e);if(e.which==KEY.DOWN||e.which==KEY.UP||e.which==KEY.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;return this.open(),void killEvent(e)}return e.which==KEY.DELETE||e.which==KEY.BACKSPACE?(this.opts.allowClear&&this.clear(),void killEvent(e)):void 0}})),installKeyUpChangeEvent(this.focusser),this.focusser.on("keyup-change input",this.bind(function(e){if(this.opts.minimumResultsForSearch>=0){if(e.stopPropagation(),this.opened())return;this.open()}})),selection.on("mousedown touchstart","abbr",this.bind(function(e){this.isInterfaceEnabled()&&(this.clear(),killEventImmediately(e),this.close(),this.selection.focus())})),selection.on("mousedown touchstart",this.bind(function(e){reinsertElement(selection),this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),killEvent(e)})),dropdown.on("mousedown touchstart",this.bind(function(){this.opts.shouldFocusInput(this)&&this.search.focus()})),selection.on("focus",this.bind(function(e){killEvent(e)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger($.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(triggerChange){var data=this.selection.data("select2-data");if(data){var evt=$.Event("select2-clearing");if(this.opts.element.trigger(evt),evt.isDefaultPrevented())return;var placeholderOption=this.getPlaceholderOption();this.opts.element.val(placeholderOption?placeholderOption.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),triggerChange!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(data),choice:data}),this.triggerChange({removed:data}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var self=this;this.opts.initSelection.call(null,this.opts.element,function(selected){selected!==undefined&&null!==selected&&(self.updateSelection(selected),self.close(),self.setPlaceholder(),self.nextSearchTerm=self.opts.nextSearchTerm(selected,self.search.val()))})}},isPlaceholderOptionSelected:function(){var placeholderOption;return this.getPlaceholder()===undefined?!1:(placeholderOption=this.getPlaceholderOption())!==undefined&&placeholderOption.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===undefined||null===this.opts.element.val()},prepareOpts:function(){var opts=this.parent.prepareOpts.apply(this,arguments),self=this;return"select"===opts.element.get(0).tagName.toLowerCase()?opts.initSelection=function(element,callback){var selected=element.find("option").filter(function(){return this.selected&&!this.disabled});callback(self.optionToData(selected))}:"data"in opts&&(opts.initSelection=opts.initSelection||function(element,callback){var id=element.val(),match=null;opts.query({matcher:function(term,text,el){var is_match=equal(id,opts.id(el));return is_match&&(match=el),is_match},callback:$.isFunction(callback)?function(){callback(match)}:$.noop})}),opts},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===undefined?undefined:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var placeholder=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&placeholder!==undefined){if(this.select&&this.getPlaceholderOption()===undefined)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(data,initial,noHighlightUpdate){var selected=0,self=this;if(this.findHighlightableChoices().each2(function(i,elm){return equal(self.id(elm.data("select2-data")),self.opts.element.val())?(selected=i,!1):void 0}),noHighlightUpdate!==!1&&this.highlight(initial===!0&&selected>=0?selected:0),initial===!0){var min=this.opts.minimumResultsForSearch;min>=0&&this.showSearch(countResults(data.results)>=min)}},showSearch:function(showSearchInput){this.showSearchInput!==showSearchInput&&(this.showSearchInput=showSearchInput,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!showSearchInput),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!showSearchInput),$(this.dropdown,this.container).toggleClass("select2-with-searchbox",showSearchInput))},onSelect:function(data,options){if(this.triggerSelect(data)){var old=this.opts.element.val(),oldData=this.data();this.opts.element.val(this.id(data)),this.updateSelection(data),this.opts.element.trigger({type:"select2-selected",val:this.id(data),choice:data}),this.nextSearchTerm=this.opts.nextSearchTerm(data,this.search.val()),this.close(),options&&options.noFocus||!this.opts.shouldFocusInput(this)||this.focusser.focus(),equal(old,this.id(data))||this.triggerChange({added:data,removed:oldData})}},updateSelection:function(data){var formatted,cssClass,container=this.selection.find(".select2-chosen");this.selection.data("select2-data",data),container.empty(),null!==data&&(formatted=this.opts.formatSelection(data,container,this.opts.escapeMarkup)),formatted!==undefined&&container.append(formatted),cssClass=this.opts.formatSelectionCssClass(data,container),cssClass!==undefined&&container.addClass(cssClass),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==undefined&&this.container.addClass("select2-allowclear")},val:function(){var val,triggerChange=!1,data=null,self=this,oldData=this.data();if(0===arguments.length)return this.opts.element.val();if(val=arguments[0],arguments.length>1&&(triggerChange=arguments[1]),this.select)this.select.val(val).find("option").filter(function(){return this.selected}).each2(function(i,elm){return data=self.optionToData(elm),!1}),this.updateSelection(data),this.setPlaceholder(),triggerChange&&this.triggerChange({added:data,removed:oldData});else{if(!val&&0!==val)return void this.clear(triggerChange);if(this.opts.initSelection===undefined)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(val),this.opts.initSelection(this.opts.element,function(data){self.opts.element.val(data?self.id(data):""),self.updateSelection(data),self.setPlaceholder(),triggerChange&&self.triggerChange({added:data,removed:oldData})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(value){var data,triggerChange=!1;return 0===arguments.length?(data=this.selection.data("select2-data"),data==undefined&&(data=null),data):(arguments.length>1&&(triggerChange=arguments[1]),void(value?(data=this.data(),this.opts.element.val(value?this.id(value):""),this.updateSelection(value),triggerChange&&this.triggerChange({added:value,removed:data})):this.clear(triggerChange)))}}),MultiSelect2=clazz(AbstractSelect2,{createContainer:function(){var container=$(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return container},prepareOpts:function(){var opts=this.parent.prepareOpts.apply(this,arguments),self=this;return"select"===opts.element.get(0).tagName.toLowerCase()?opts.initSelection=function(element,callback){var data=[];element.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(i,elm){data.push(self.optionToData(elm))}),callback(data)}:"data"in opts&&(opts.initSelection=opts.initSelection||function(element,callback){var ids=splitVal(element.val(),opts.separator),matches=[];opts.query({matcher:function(term,text,el){var is_match=$.grep(ids,function(id){return equal(id,opts.id(el))}).length;return is_match&&matches.push(el),is_match},callback:$.isFunction(callback)?function(){for(var ordered=[],i=0;i<ids.length;i++)for(var id=ids[i],j=0;j<matches.length;j++){var match=matches[j];if(equal(id,opts.id(match))){ordered.push(match),matches.splice(j,1);break}}callback(ordered)}:$.noop})}),opts},selectChoice:function(choice){var selected=this.container.find(".select2-search-choice-focus");selected.length&&choice&&choice[0]==selected[0]||(selected.length&&this.opts.element.trigger("choice-deselected",selected),selected.removeClass("select2-search-choice-focus"),choice&&choice.length&&(this.close(),choice.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",choice)))},destroy:function(){$("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),cleanupJQueryElements.call(this,"searchContainer","selection")},initContainer:function(){var selection,selector=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=selection=this.container.find(selector);var _this=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",function(){_this.search[0].focus(),_this.selectChoice($(this))}),this.search.attr("id","s2id_autogen"+nextUid()),this.search.prev().text($("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("input paste",this.bind(function(){this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){++this.keydowns;var selected=selection.find(".select2-search-choice-focus"),prev=selected.prev(".select2-search-choice:not(.select2-locked)"),next=selected.next(".select2-search-choice:not(.select2-locked)"),pos=getCursorInfo(this.search);if(selected.length&&(e.which==KEY.LEFT||e.which==KEY.RIGHT||e.which==KEY.BACKSPACE||e.which==KEY.DELETE||e.which==KEY.ENTER)){var selectedChoice=selected;return e.which==KEY.LEFT&&prev.length?selectedChoice=prev:e.which==KEY.RIGHT?selectedChoice=next.length?next:null:e.which===KEY.BACKSPACE?this.unselect(selected.first())&&(this.search.width(10),selectedChoice=prev.length?prev:next):e.which==KEY.DELETE?this.unselect(selected.first())&&(this.search.width(10),selectedChoice=next.length?next:null):e.which==KEY.ENTER&&(selectedChoice=null),this.selectChoice(selectedChoice),killEvent(e),void(selectedChoice&&selectedChoice.length||this.open())}if((e.which===KEY.BACKSPACE&&1==this.keydowns||e.which==KEY.LEFT)&&0==pos.offset&&!pos.length)return this.selectChoice(selection.find(".select2-search-choice:not(.select2-locked)").last()),void killEvent(e);if(this.selectChoice(null),this.opened())switch(e.which){case KEY.UP:case KEY.DOWN:return this.moveHighlight(e.which===KEY.UP?-1:1),void killEvent(e);case KEY.ENTER:return this.selectHighlighted(),void killEvent(e);case KEY.TAB:return this.selectHighlighted({noFocus:!0}),void this.close();case KEY.ESC:return this.cancel(e),void killEvent(e)}if(e.which!==KEY.TAB&&!KEY.isControl(e)&&!KEY.isFunctionKey(e)&&e.which!==KEY.BACKSPACE&&e.which!==KEY.ESC){if(e.which===KEY.ENTER){if(this.opts.openOnEnter===!1)return;if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return}this.open(),(e.which===KEY.PAGE_UP||e.which===KEY.PAGE_DOWN)&&killEvent(e),e.which===KEY.ENTER&&killEvent(e)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(e){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),e.stopImmediatePropagation(),this.opts.element.trigger($.Event("select2-blur"))})),this.container.on("click",selector,this.bind(function(e){this.isInterfaceEnabled()&&($(e.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.open(),this.focusSearch(),e.preventDefault()))})),this.container.on("focus",selector,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var self=this;this.opts.initSelection.call(null,this.opts.element,function(data){data!==undefined&&null!==data&&(self.updateSelection(data),self.close(),self.clearSearch())})}},clearSearch:function(){var placeholder=this.getPlaceholder(),maxWidth=this.getMaxSearchWidth();placeholder!==undefined&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(placeholder).addClass("select2-default"),this.search.width(maxWidth>0?maxWidth:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),""===this.search.val()&&this.nextSearchTerm!=undefined&&(this.search.val(this.nextSearchTerm),this.search.select()),this.updateResults(!0),this.opts.shouldFocusInput(this)&&this.search.focus(),this.opts.element.trigger($.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(data){var ids=[],filtered=[],self=this;$(data).each(function(){indexOf(self.id(this),ids)<0&&(ids.push(self.id(this)),filtered.push(this))}),data=filtered,this.selection.find(".select2-search-choice").remove(),$(data).each(function(){self.addSelectedChoice(this)}),self.postprocessResults()},tokenize:function(){var input=this.search.val();input=this.opts.tokenizer.call(this,input,this.data(),this.bind(this.onSelect),this.opts),null!=input&&input!=undefined&&(this.search.val(input),input.length>0&&this.open())},onSelect:function(data,options){this.triggerSelect(data)&&(this.addSelectedChoice(data),this.opts.element.trigger({type:"selected",val:this.id(data),choice:data}),this.nextSearchTerm=this.opts.nextSearchTerm(data,this.search.val()),this.clearSearch(),this.updateResults(),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(data,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()?this.updateResults(!0):this.nextSearchTerm!=undefined&&(this.search.val(this.nextSearchTerm),this.updateResults(),this.search.select()),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:data}),options&&options.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(data){var formatted,cssClass,enableChoice=!data.locked,enabledItem=$("<li class='select2-search-choice'> <div></div> <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"),disabledItem=$("<li class='select2-search-choice select2-locked'><div></div></li>"),choice=enableChoice?enabledItem:disabledItem,id=this.id(data),val=this.getVal();formatted=this.opts.formatSelection(data,choice.find("div"),this.opts.escapeMarkup),formatted!=undefined&&choice.find("div").replaceWith("<div>"+formatted+"</div>"),cssClass=this.opts.formatSelectionCssClass(data,choice.find("div")),cssClass!=undefined&&choice.addClass(cssClass),enableChoice&&choice.find(".select2-search-choice-close").on("mousedown",killEvent).on("click dblclick",this.bind(function(e){this.isInterfaceEnabled()&&(this.unselect($(e.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),killEvent(e),this.close(),this.focusSearch())})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),choice.data("select2-data",data),choice.insertBefore(this.searchContainer),val.push(id),this.setVal(val)},unselect:function(selected){var data,index,val=this.getVal();if(selected=selected.closest(".select2-search-choice"),0===selected.length)throw"Invalid argument: "+selected+". Must be .select2-search-choice";if(data=selected.data("select2-data")){var evt=$.Event("select2-removing");if(evt.val=this.id(data),evt.choice=data,this.opts.element.trigger(evt),evt.isDefaultPrevented())return!1;for(;(index=indexOf(this.id(data),val))>=0;)val.splice(index,1),this.setVal(val),this.select&&this.postprocessResults();return selected.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(data),choice:data}),this.triggerChange({removed:data}),!0}},postprocessResults:function(data,initial,noHighlightUpdate){var val=this.getVal(),choices=this.results.find(".select2-result"),compound=this.results.find(".select2-result-with-children"),self=this;choices.each2(function(i,choice){var id=self.id(choice.data("select2-data"));indexOf(id,val)>=0&&(choice.addClass("select2-selected"),choice.find(".select2-result-selectable").addClass("select2-selected"))}),compound.each2(function(i,choice){choice.is(".select2-result-selectable")||0!==choice.find(".select2-result-selectable:not(.select2-selected)").length||choice.addClass("select2-selected")}),-1==this.highlight()&&noHighlightUpdate!==!1&&self.highlight(0),!this.opts.createSearchChoice&&!choices.filter(".select2-result:not(.select2-selected)").length>0&&(!data||data&&!data.more&&0===this.results.find(".select2-no-results").length)&&checkFormatter(self.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+evaluate(self.opts.formatNoMatches,self.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-getSideBorderPadding(this.search)},resizeSearch:function(){var minimumWidth,left,maxWidth,containerLeft,searchWidth,sideBorderPadding=getSideBorderPadding(this.search);minimumWidth=measureTextWidth(this.search)+10,left=this.search.offset().left,maxWidth=this.selection.width(),containerLeft=this.selection.offset().left,searchWidth=maxWidth-(left-containerLeft)-sideBorderPadding,minimumWidth>searchWidth&&(searchWidth=maxWidth-sideBorderPadding),40>searchWidth&&(searchWidth=maxWidth-sideBorderPadding),0>=searchWidth&&(searchWidth=minimumWidth),this.search.width(Math.floor(searchWidth))},getVal:function(){var val;return this.select?(val=this.select.val(),null===val?[]:val):(val=this.opts.element.val(),splitVal(val,this.opts.separator))},setVal:function(val){var unique;this.select?this.select.val(val):(unique=[],$(val).each(function(){indexOf(this,unique)<0&&unique.push(this)}),this.opts.element.val(0===unique.length?"":unique.join(this.opts.separator)))},buildChangeDetails:function(old,current){for(var current=current.slice(0),old=old.slice(0),i=0;i<current.length;i++)for(var j=0;j<old.length;j++)equal(this.opts.id(current[i]),this.opts.id(old[j]))&&(current.splice(i,1),i>0&&i--,old.splice(j,1),j--);return{added:current,removed:old}},val:function(val,triggerChange){var oldData,self=this;if(0===arguments.length)return this.getVal();if(oldData=this.data(),oldData.length||(oldData=[]),!val&&0!==val)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),void(triggerChange&&this.triggerChange({added:this.data(),removed:oldData}));if(this.setVal(val),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),triggerChange&&this.triggerChange(this.buildChangeDetails(oldData,this.data()));else{if(this.opts.initSelection===undefined)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(data){var ids=$.map(data,self.id);self.setVal(ids),self.updateSelection(data),self.clearSearch(),triggerChange&&self.triggerChange(self.buildChangeDetails(oldData,self.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var val=[],self=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){val.push(self.opts.id($(this).data("select2-data")))}),this.setVal(val),this.triggerChange()},data:function(values,triggerChange){var ids,old,self=this;return 0===arguments.length?this.selection.children(".select2-search-choice").map(function(){return $(this).data("select2-data")}).get():(old=this.data(),values||(values=[]),ids=$.map(values,function(e){return self.opts.id(e)}),this.setVal(ids),this.updateSelection(values),this.clearSearch(),triggerChange&&this.triggerChange(this.buildChangeDetails(old,this.data())),void 0)}}),$.fn.select2=function(){var opts,select2,method,value,multiple,args=Array.prototype.slice.call(arguments,0),allowedMethods=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],valueMethods=["opened","isFocused","container","dropdown"],propertyMethods=["val","data"],methodsMap={search:"externalSearch"};return this.each(function(){if(0===args.length||"object"==typeof args[0])opts=0===args.length?{}:$.extend({},args[0]),opts.element=$(this),"select"===opts.element.get(0).tagName.toLowerCase()?multiple=opts.element.prop("multiple"):(multiple=opts.multiple||!1,"tags"in opts&&(opts.multiple=multiple=!0)),select2=multiple?new window.Select2["class"].multi:new window.Select2["class"].single,select2.init(opts);else{if("string"!=typeof args[0])throw"Invalid arguments to select2 plugin: "+args;if(indexOf(args[0],allowedMethods)<0)throw"Unknown method: "+args[0];if(value=undefined,select2=$(this).data("select2"),select2===undefined)return;if(method=args[0],"container"===method?value=select2.container:"dropdown"===method?value=select2.dropdown:(methodsMap[method]&&(method=methodsMap[method]),value=select2[method].apply(select2,args.slice(1))),indexOf(args[0],valueMethods)>=0||indexOf(args[0],propertyMethods)>=0&&1==args.length)return!1}}),value===undefined?this:value},$.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(result,container,query,escapeMarkup){var markup=[];return markMatch(result.text,query.term,markup,escapeMarkup),markup.join("")},formatSelection:function(data,container,escapeMarkup){return data?escapeMarkup(data.text):undefined},sortResults:function(results){return results},formatResultCssClass:function(data){return data.css},formatSelectionCssClass:function(){return undefined},formatMatches:function(matches){return matches+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(input,min){var n=min-input.length;return"Please enter "+n+" or more character"+(1==n?"":"s")},formatInputTooLong:function(input,max){var n=input.length-max;return"Please delete "+n+" character"+(1==n?"":"s")},formatSelectionTooBig:function(limit){return"You can only select "+limit+" item"+(1==limit?"":"s")},formatLoadMore:function(){return"Loading more results…"},formatSearching:function(){return"Searching…"},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e==undefined?null:e.id},matcher:function(term,text){return stripDiacritics(""+text).toUpperCase().indexOf(stripDiacritics(""+term).toUpperCase())>=0
|
8 |
-
},separator:",",tokenSeparators:[],tokenizer:defaultTokenizer,escapeMarkup:defaultEscapeMarkup,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(c){return c},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return undefined},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(instance){var supportsTouchEvents="ontouchstart"in window||navigator.msMaxTouchPoints>0;return supportsTouchEvents&&instance.opts.minimumResultsForSearch<0?!1:!0}},$.fn.select2.ajaxDefaults={transport:$.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:ajax,local:local,tags:tags},util:{debounce:debounce,markMatch:markMatch,escapeMarkup:defaultEscapeMarkup,stripDiacritics:stripDiacritics},"class":{"abstract":AbstractSelect2,single:SingleSelect2,multi:MultiSelect2}}}}(jQuery),jQuery(document).ready(function($){$("#filter_action, #filter_content").change(function(){$("#leadin-contacts-filter-button").addClass("button-primary")})});
|
2 |
},n.anchorXSetter=function(a,b){e=a,l(b,a+y-xb)},n.anchorYSetter=function(a,b){f=a,l(b,a-yb)},n.xSetter=function(a){n.x=a,L&&(a-=L*((Va||J.width)+x)),xb=u(a),n.attr("translateX",xb)},n.ySetter=function(a){yb=n.y=u(a),n.attr("translateY",yb)};var A=n.css;return q(n,{css:function(a){if(a){var b={},a=w(a);p("fontSize,fontWeight,fontFamily,color,lineHeight,width,textDecoration,textShadow".split(","),function(c){a[c]!==t&&(b[c]=a[c],delete a[c])}),s.css(b)}return A.call(n,a)},getBBox:function(){return{width:J.width+2*x,height:J.height+2*x,x:J.x-x,y:J.y-x}},shadow:function(a){return m&&m.shadow(a),n},destroy:function(){W(n.element,"mouseenter"),W(n.element,"mouseleave"),s&&(s=s.destroy()),m&&(m=m.destroy()),P.prototype.destroy.call(n),n=o=j=k=l=null}})}},Za=ta,q(P.prototype,{htmlCss:function(a){var b=this.element;return(b=a&&"SPAN"===b.tagName&&a.width)&&(delete a.width,this.textWidth=b,this.updateTransform()),this.styles=q(this.styles,a),G(this.element,a),this},htmlGetBBox:function(){var a=this.element,b=this.bBox;return b||("text"===a.nodeName&&(a.style.position="absolute"),b=this.bBox={x:a.offsetLeft,y:a.offsetTop,width:a.offsetWidth,height:a.offsetHeight}),b},htmlUpdateTransform:function(){if(this.added){var a=this.renderer,b=this.element,c=this.translateX||0,d=this.translateY||0,e=this.x||0,f=this.y||0,g=this.textAlign||"left",h={left:0,center:.5,right:1}[g],i=this.shadows;if(G(b,{marginLeft:c,marginTop:d}),i&&p(i,function(a){G(a,{marginLeft:c+1,marginTop:d+1})}),this.inverted&&p(b.childNodes,function(c){a.invertChild(c,b)}),"SPAN"===b.tagName){var k,j=this.rotation,l=z(this.textWidth),o=[j,g,b.innerHTML,this.textWidth].join(",");o!==this.cTT&&(k=a.fontMetrics(b.style.fontSize).b,r(j)&&this.setSpanRotation(j,h,k),i=m(this.elemWidth,b.offsetWidth),i>l&&/[ \-]/.test(b.textContent||b.innerText)&&(G(b,{width:l+"px",display:"block",whiteSpace:"normal"}),i=l),this.getSpanCorrection(i,k,h,j,g)),G(b,{left:e+(this.xCorr||0)+"px",top:f+(this.yCorr||0)+"px"}),ib&&(k=b.offsetHeight),this.cTT=o}}else this.alignOnAdd=!0},setSpanRotation:function(a,b,c){var d={},e=Aa?"-ms-transform":ib?"-webkit-transform":Ta?"MozTransform":Ib?"-o-transform":"";d[e]=d.transform="rotate("+a+"deg)",d[e+(Ta?"Origin":"-origin")]=d.transformOrigin=100*b+"% "+c+"px",G(this.element,d)},getSpanCorrection:function(a,b,c){this.xCorr=-a*c,this.yCorr=-b}}),q(ta.prototype,{html:function(a,b,c){var d=this.createElement("span"),e=d.element,f=d.renderer;return d.textSetter=function(a){a!==e.innerHTML&&delete this.bBox,e.innerHTML=this.textStr=a},d.xSetter=d.ySetter=d.alignSetter=d.rotationSetter=function(a,b){"align"===b&&(b="textAlign"),d[b]=a,d.htmlUpdateTransform()},d.attr({text:a,x:u(b),y:u(c)}).css({position:"absolute",whiteSpace:"nowrap",fontFamily:this.style.fontFamily,fontSize:this.style.fontSize}),d.css=d.htmlCss,f.isSVG&&(d.add=function(a){var b,c=f.box.parentNode,j=[];if(this.parentGroup=a){if(b=a.div,!b){for(;a;)j.push(a),a=a.parentGroup;p(j.reverse(),function(a){var d;b=a.div=a.div||Y(Ja,{className:H(a.element,"class")},{position:"absolute",left:(a.translateX||0)+"px",top:(a.translateY||0)+"px"},b||c),d=b.style,q(a,{translateXSetter:function(b,c){d.left=b+"px",a[c]=b,a.doTransform=!0},translateYSetter:function(b,c){d.top=b+"px",a[c]=b,a.doTransform=!0},visibilitySetter:function(a,b){d[b]=a}})})}}else b=c;return b.appendChild(e),d.added=!0,d.alignOnAdd&&d.htmlUpdateTransform(),d}),d}});var X;if(!aa&&!fa){R.VMLElement=X={init:function(a,b){var c=["<",b,' filled="f" stroked="f"'],d=["position: ","absolute",";"],e=b===Ja;("shape"===b||e)&&d.push("left:0;top:0;width:1px;height:1px;"),d.push("visibility: ",e?"hidden":"visible"),c.push(' style="',d.join(""),'"/>'),b&&(c=e||"span"===b||"img"===b?c.join(""):a.prepVML(c),this.element=Y(c)),this.renderer=a},add:function(a){var b=this.renderer,c=this.element,d=b.box,d=a?a.element||a:d;return a&&a.inverted&&b.invertChild(c,d),d.appendChild(c),this.added=!0,this.alignOnAdd&&!this.deferUpdateTransform&&this.updateTransform(),this.onAdd&&this.onAdd(),this},updateTransform:P.prototype.htmlUpdateTransform,setSpanRotation:function(){var a=this.rotation,b=Z(a*Ca),c=ea(a*Ca);G(this.element,{filter:a?["progid:DXImageTransform.Microsoft.Matrix(M11=",b,", M12=",-c,", M21=",c,", M22=",b,", sizingMethod='auto expand')"].join(""):Q})},getSpanCorrection:function(a,b,c,d,e){var i,f=d?Z(d*Ca):1,g=d?ea(d*Ca):0,h=m(this.elemHeight,this.element.offsetHeight);this.xCorr=0>f&&-a,this.yCorr=0>g&&-h,i=0>f*g,this.xCorr+=g*b*(i?1-c:c),this.yCorr-=f*b*(d?i?c:1-c:1),e&&"left"!==e&&(this.xCorr-=a*c*(0>f?-1:1),d&&(this.yCorr-=h*c*(0>g?-1:1)),G(this.element,{textAlign:e}))},pathToVML:function(a){for(var b=a.length,c=[];b--;)ha(a[b])?c[b]=u(10*a[b])-5:"Z"===a[b]?c[b]="x":(c[b]=a[b],!a.isArc||"wa"!==a[b]&&"at"!==a[b]||(c[b+5]===c[b+7]&&(c[b+7]+=a[b+7]>a[b+5]?1:-1),c[b+6]===c[b+8]&&(c[b+8]+=a[b+8]>a[b+6]?1:-1)));return c.join(" ")||"x"},clip:function(a){var c,b=this;return a?(c=a.members,ja(c,b),c.push(b),b.destroyClip=function(){ja(c,b)},a=a.getCSS(b)):(b.destroyClip&&b.destroyClip(),a={clip:hb?"inherit":"rect(auto)"}),b.css(a)},css:P.prototype.htmlCss,safeRemoveChild:function(a){a.parentNode&&Pa(a)},destroy:function(){return this.destroyClip&&this.destroyClip(),P.prototype.destroy.apply(this)},on:function(a,b){return this.element["on"+a]=function(){var a=I.event;a.target=a.srcElement,b(a)},this},cutOffPath:function(a,b){var c,a=a.split(/[ ,]/);return c=a.length,(9===c||11===c)&&(a[c-4]=a[c-2]=z(a[c-2])-10*b),a.join(" ")},shadow:function(a,b,c){var e,h,j,l,o,n,s,d=[],f=this.element,g=this.renderer,i=f.style,k=f.path;if(k&&"string"!=typeof k.value&&(k="x"),o=k,a){for(n=m(a.width,3),s=(a.opacity||.15)/n,e=1;3>=e;e++)l=2*n+1-2*e,c&&(o=this.cutOffPath(k.value,l+.5)),j=['<shape isShadow="true" strokeweight="',l,'" filled="false" path="',o,'" coordsize="10 10" style="',f.style.cssText,'" />'],h=Y(g.prepVML(j),null,{left:z(i.left)+m(a.offsetX,1),top:z(i.top)+m(a.offsetY,1)}),c&&(h.cutOff=l+1),j=['<stroke color="',a.color||"black",'" opacity="',s*e,'"/>'],Y(g.prepVML(j),null,null,h),b?b.element.appendChild(h):f.parentNode.insertBefore(h,f),d.push(h);this.shadows=d}return this},updateShadows:sa,setAttr:function(a,b){hb?this.element[a]=b:this.element.setAttribute(a,b)},classSetter:function(a){this.element.className=a},dashstyleSetter:function(a,b,c){(c.getElementsByTagName("stroke")[0]||Y(this.renderer.prepVML(["<stroke/>"]),null,null,c))[b]=a||"solid",this[b]=a},dSetter:function(a,b,c){var d=this.shadows,a=a||[];if(this.d=a.join(" "),c.path=a=this.pathToVML(a),d)for(c=d.length;c--;)d[c].path=d[c].cutOff?this.cutOffPath(a,d[c].cutOff):a;this.setAttr(b,a)},fillSetter:function(a,b,c){var d=c.nodeName;"SPAN"===d?c.style.color=a:"IMG"!==d&&(c.filled=a!==Q,this.setAttr("fillcolor",this.renderer.color(a,c,b,this)))},opacitySetter:sa,rotationSetter:function(a,b,c){c=c.style,this[b]=c[b]=a,c.left=-u(ea(a*Ca)+1)+"px",c.top=u(Z(a*Ca))+"px"},strokeSetter:function(a,b,c){this.setAttr("strokecolor",this.renderer.color(a,c,b))},"stroke-widthSetter":function(a,b,c){c.stroked=!!a,this[b]=a,ha(a)&&(a+="px"),this.setAttr("strokeweight",a)},titleSetter:function(a,b){this.setAttr(b,a)},visibilitySetter:function(a,b,c){"inherit"===a&&(a="visible"),this.shadows&&p(this.shadows,function(c){c.style[b]=a}),"DIV"===c.nodeName&&(a="hidden"===a?"-999em":0,hb||(c.style[b]=a?"visible":"hidden"),b="top"),c.style[b]=a},xSetter:function(a,b,c){this[b]=a,"x"===b?b="left":"y"===b&&(b="top"),this.updateClipping?(this[b]=a,this.updateClipping()):c.style[b]=a},zIndexSetter:function(a,b,c){c.style[b]=a}},X=ka(P,X),X.prototype.ySetter=X.prototype.widthSetter=X.prototype.heightSetter=X.prototype.xSetter;var ga={Element:X,isIE8:wa.indexOf("MSIE 8.0")>-1,init:function(a,b,c,d){var e;if(this.alignedObjects=[],d=this.createElement(Ja).css(q(this.getStyle(d),{position:"relative"})),e=d.element,a.appendChild(d.element),this.isVML=!0,this.box=e,this.boxWrapper=d,this.cache={},this.setSize(b,c,!1),!y.namespaces.hcv){y.namespaces.add("hcv","urn:schemas-microsoft-com:vml");try{y.createStyleSheet().cssText="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}catch(f){y.styleSheets[0].cssText+="hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke{ behavior:url(#default#VML); display: inline-block; } "}}},isHidden:function(){return!this.box.offsetWidth},clipRect:function(a,b,c,d){var e=this.createElement(),f=ca(a);return q(e,{members:[],left:(f?a.x:a)+1,top:(f?a.y:b)+1,width:(f?a.width:c)-1,height:(f?a.height:d)-1,getCSS:function(a){var b=a.element,c=b.nodeName,a=a.inverted,d=this.top-("shape"===c?b.offsetTop:0),e=this.left,b=e+this.width,f=d+this.height,d={clip:"rect("+u(a?e:d)+"px,"+u(a?f:b)+"px,"+u(a?b:f)+"px,"+u(a?d:e)+"px)"};return!a&&hb&&"DIV"===c&&q(d,{width:b+"px",height:f+"px"}),d},updateClipping:function(){p(e.members,function(a){a.element&&a.css(e.getCSS(a))})}})},color:function(a,b,c,d){var f,h,i,e=this,g=/^rgba/,j=Q;if(a&&a.linearGradient?i="gradient":a&&a.radialGradient&&(i="pattern"),i){var k,l,n,s,m,J,L,r,o=a.linearGradient||a.radialGradient,x="",a=a.stops,v=[],q=function(){h=['<fill colors="'+v.join(",")+'" opacity="',m,'" o:opacity2="',s,'" type="',i,'" ',x,'focus="100%" method="any" />'],Y(e.prepVML(h),null,null,b)};if(n=a[0],r=a[a.length-1],n[0]>0&&a.unshift([0,n[1]]),r[0]<1&&a.push([1,r[1]]),p(a,function(a,b){g.test(a[1])?(f=ya(a[1]),k=f.get("rgb"),l=f.get("a")):(k=a[1],l=1),v.push(100*a[0]+"% "+k),b?(m=l,J=k):(s=l,L=k)}),"fill"===c)if("gradient"===i)c=o.x1||o[0]||0,a=o.y1||o[1]||0,n=o.x2||o[2]||0,o=o.y2||o[3]||0,x='angle="'+(90-180*U.atan((o-a)/(n-c))/ma)+'"',q();else{var w,j=o.r,t=2*j,u=2*j,y=o.cx,B=o.cy,na=b.radialReference,j=function(){na&&(w=d.getBBox(),y+=(na[0]-w.x)/w.width-.5,B+=(na[1]-w.y)/w.height-.5,t*=na[2]/w.width,u*=na[2]/w.height),x='src="'+E.global.VMLRadialGradientURL+'" size="'+t+","+u+'" origin="0.5,0.5" position="'+y+","+B+'" color2="'+L+'" ',q()};d.added?j():d.onAdd=j,j=J}else j=k}else g.test(a)&&"IMG"!==b.tagName?(f=ya(a),h=["<",c,' opacity="',f.get("a"),'"/>'],Y(this.prepVML(h),null,null,b),j=f.get("rgb")):(j=b.getElementsByTagName(c),j.length&&(j[0].opacity=1,j[0].type="solid"),j=a);return j},prepVML:function(a){var b=this.isIE8,a=a.join("");return b?(a=a.replace("/>",' xmlns="urn:schemas-microsoft-com:vml" />'),a=-1===a.indexOf('style="')?a.replace("/>",' style="display:inline-block;behavior:url(#default#VML);" />'):a.replace('style="','style="display:inline-block;behavior:url(#default#VML);')):a=a.replace("<","<hcv:"),a},text:ta.prototype.html,path:function(a){var b={coordsize:"10 10"};return La(a)?b.d=a:ca(a)&&q(b,a),this.createElement("shape").attr(b)},circle:function(a,b,c){var d=this.symbol("circle");return ca(a)&&(c=a.r,b=a.y,a=a.x),d.isCircle=!0,d.r=c,d.attr({x:a,y:b})},g:function(a){var b;return a&&(b={className:"highcharts-"+a,"class":"highcharts-"+a}),this.createElement(Ja).attr(b)},image:function(a,b,c,d,e){var f=this.createElement("img").attr({src:a});return arguments.length>1&&f.attr({x:b,y:c,width:d,height:e}),f},createElement:function(a){return"rect"===a?this.symbol(a):ta.prototype.createElement.call(this,a)},invertChild:function(a,b){var c=this,d=b.style,e="IMG"===a.tagName&&a.style;G(a,{flip:"x",left:z(d.width)-(e?z(e.top):1),top:z(d.height)-(e?z(e.left):1),rotation:-90}),p(a.childNodes,function(b){c.invertChild(b,a)})},symbols:{arc:function(a,b,c,d,e){var f=e.start,g=e.end,h=e.r||c||d,c=e.innerR,d=Z(f),i=ea(f),j=Z(g),k=ea(g);return g-f===0?["x"]:(f=["wa",a-h,b-h,a+h,b+h,a+h*d,b+h*i,a+h*j,b+h*k],e.open&&!c&&f.push("e","M",a,b),f.push("at",a-c,b-c,a+c,b+c,a+c*j,b+c*k,a+c*d,b+c*i,"x","e"),f.isArc=!0,f)},circle:function(a,b,c,d,e){return e&&(c=d=2*e.r),e&&e.isCircle&&(a-=c/2,b-=d/2),["wa",a,b,a+c,b+d,a+c,b+d/2,a+c,b+d/2,"e"]},rect:function(a,b,c,d,e){return ta.prototype.symbols[r(e)&&e.r?"callout":"square"].call(0,a,b,c,d,e)}}};R.VMLRenderer=X=function(){this.init.apply(this,arguments)},X.prototype=w(ta.prototype,ga),Za=X}ta.prototype.measureSpanWidth=function(a,b){var d,c=y.createElement("span");return d=y.createTextNode(a),c.appendChild(d),G(c,b),this.box.appendChild(c),d=c.offsetWidth,Pa(c),d};var Lb;fa&&(R.CanVGRenderer=X=function(){xa="http://www.w3.org/1999/xhtml"},X.prototype.symbols={},Lb=function(){function a(){var d,a=b.length;for(d=0;a>d;d++)b[d]();b=[]}var b=[];return{push:function(c,d){0===b.length&&Qb(d,a),b.push(c)}}}(),Za=X),Sa.prototype={addLabel:function(){var l,a=this.axis,b=a.options,c=a.chart,d=a.horiz,e=a.categories,f=a.names,g=this.pos,h=b.labels,i=a.tickPositions,d=d&&e&&!h.step&&!h.staggerLines&&!h.rotation&&c.plotWidth/i.length||!d&&(c.margin[3]||.33*c.chartWidth),j=g===i[0],k=g===i[i.length-1],f=e?m(e[g],f[g],g):g,e=this.label,o=i.info;a.isDatetimeAxis&&o&&(l=b.dateTimeLabelFormats[o.higherRanks[g]||o.unitName]),this.isFirst=j,this.isLast=k,b=a.labelFormatter.call({axis:a,chart:c,isFirst:j,isLast:k,dateTimeLabelFormat:l,value:a.isLog?da(ia(f)):f}),g=d&&{width:v(1,u(d-2*(h.padding||10)))+"px"},g=q(g,h.style),r(e)?e&&e.attr({text:b}).css(g):(l={align:a.labelAlign},ha(h.rotation)&&(l.rotation=h.rotation),d&&h.ellipsis&&(l._clipHeight=a.len/i.length),this.label=r(b)&&h.enabled?c.renderer.text(b,0,0,h.useHTML).attr(l).css(g).add(a.labelGroup):null)},getLabelSize:function(){var a=this.label,b=this.axis;return a?a.getBBox()[b.horiz?"height":"width"]:0},getLabelSides:function(){var a=this.label.getBBox(),b=this.axis,c=b.horiz,d=b.options.labels,a=c?a.width:a.height,b=c?d.x-a*{left:0,center:.5,right:1}[b.labelAlign]:0;return[b,c?a+b:a]},handleOverflow:function(a,b){var l,o,n,c=!0,d=this.axis,e=this.isFirst,f=this.isLast,g=d.horiz?b.x:b.y,h=d.reversed,i=d.tickPositions,j=this.getLabelSides(),k=j[0],j=j[1],s=this.label.line||0;if(l=d.labelEdge,o=d.justifyLabels&&(e||f),l[s]===t||g+k>l[s]?l[s]=g+j:o||(c=!1),o){l=(o=d.justifyToPlot)?d.pos:0,o=o?l+d.len:d.chart.chartWidth;do a+=e?1:-1,n=d.ticks[i[a]];while(i[a]&&(!n||n.label.line!==s));d=n&&n.label.xy&&n.label.xy.x+n.getLabelSides()[e?0:1],e&&!h||f&&h?l>g+k&&(g=l-k,n&&g+j>d&&(c=!1)):g+j>o&&(g=o-j,n&&d>g+k&&(c=!1)),b.x=g}return c},getPosition:function(a,b,c,d){var e=this.axis,f=e.chart,g=d&&f.oldChartHeight||f.chartHeight;return{x:a?e.translate(b+c,null,null,d)+e.transB:e.left+e.offset+(e.opposite?(d&&f.oldChartWidth||f.chartWidth)-e.right-e.left:0),y:a?g-e.bottom+e.offset-(e.opposite?e.height:0):g-e.translate(b+c,null,null,d)-e.transB}},getLabelPosition:function(a,b,c,d,e,f,g,h){var i=this.axis,j=i.transA,k=i.reversed,l=i.staggerLines,o=i.chart.renderer.fontMetrics(e.style.fontSize).b,n=e.rotation,a=a+e.x-(f&&d?f*j*(k?-1:1):0),b=b+e.y-(f&&!d?f*j*(k?1:-1):0);return n&&2===i.side&&(b-=o-o*Z(n*Ca)),!r(e.y)&&!n&&(b+=o-c.getBBox().height/2),l&&(c.line=g/(h||1)%l,b+=c.line*(i.labelOffset/l)),{x:a,y:b}},getMarkPath:function(a,b,c,d,e,f){return f.crispLine(["M",a,b,"L",a+(e?0:-c),b+(e?c:0)],d)},render:function(a,b,c){var d=this.axis,e=d.options,f=d.chart.renderer,g=d.horiz,h=this.type,i=this.label,j=this.pos,k=e.labels,l=this.gridLine,o=h?h+"Grid":"grid",n=h?h+"Tick":"tick",s=e[o+"LineWidth"],p=e[o+"LineColor"],J=e[o+"LineDashStyle"],L=e[n+"Length"],o=e[n+"Width"]||0,x=e[n+"Color"],r=e[n+"Position"],n=this.mark,v=k.step,q=!0,u=d.tickmarkOffset,w=this.getPosition(g,j,u,b),y=w.x,w=w.y,B=g&&y===d.pos+d.len||!g&&w===d.pos?-1:1;this.isActive=!0,s&&(j=d.getPlotLinePath(j+u,s*B,b,!0),l===t&&(l={stroke:p,"stroke-width":s},J&&(l.dashstyle=J),h||(l.zIndex=1),b&&(l.opacity=0),this.gridLine=l=s?f.path(j).attr(l).add(d.gridGroup):null),!b&&l&&j&&l[this.isNew?"attr":"animate"]({d:j,opacity:c})),o&&L&&("inside"===r&&(L=-L),d.opposite&&(L=-L),h=this.getMarkPath(y,w,L,o*B,g,f),n?n.animate({d:h,opacity:c}):this.mark=f.path(h).attr({stroke:x,"stroke-width":o,opacity:c}).add(d.axisGroup)),i&&!isNaN(y)&&(i.xy=w=this.getLabelPosition(y,w,i,g,k,u,a,v),this.isFirst&&!this.isLast&&!m(e.showFirstLabel,1)||this.isLast&&!this.isFirst&&!m(e.showLastLabel,1)?q=!1:!d.isRadial&&!k.step&&!k.rotation&&!b&&0!==c&&(q=this.handleOverflow(a,w)),v&&a%v&&(q=!1),q&&!isNaN(w.y)?(w.opacity=c,i[this.isNew?"attr":"animate"](w),this.isNew=!1):i.attr("y",-9999))},destroy:function(){Oa(this,this.axis)}},R.PlotLineOrBand=function(a,b){this.axis=a,b&&(this.options=b,this.id=b.id)},R.PlotLineOrBand.prototype={render:function(){var p,a=this,b=a.axis,c=b.horiz,d=(b.pointRange||0)/2,e=a.options,f=e.label,g=a.label,h=e.width,i=e.to,j=e.from,k=r(j)&&r(i),l=e.value,o=e.dashStyle,n=a.svgElem,s=[],J=e.color,L=e.zIndex,x=e.events,q={},t=b.chart.renderer;if(b.isLog&&(j=za(j),i=za(i),l=za(l)),h)s=b.getPlotLinePath(l,h),q={stroke:J,"stroke-width":h},o&&(q.dashstyle=o);else{if(!k)return;j=v(j,b.min-d),i=C(i,b.max+d),s=b.getPlotBandPath(j,i,e),J&&(q.fill=J),e.borderWidth&&(q.stroke=e.borderColor,q["stroke-width"]=e.borderWidth)}if(r(L)&&(q.zIndex=L),n)s?n.animate({d:s},null,n.onGetPath):(n.hide(),n.onGetPath=function(){n.show()},g&&(a.label=g=g.destroy()));else if(s&&s.length&&(a.svgElem=n=t.path(s).attr(q).add(),x))for(p in d=function(b){n.on(b,function(c){x[b].apply(a,[c])})},x)d(p);return f&&r(f.text)&&s&&s.length&&b.width>0&&b.height>0?(f=w({align:c&&k&&"center",x:c?!k&&4:10,verticalAlign:!c&&k&&"middle",y:c?k?16:10:k?6:-4,rotation:c&&!k&&90},f),g||(q={align:f.textAlign||f.align,rotation:f.rotation},r(L)&&(q.zIndex=L),a.label=g=t.text(f.text,0,0,f.useHTML).attr(q).css(f.style).add()),b=[s[1],s[4],m(s[6],s[1])],s=[s[2],s[5],m(s[7],s[2])],c=Na(b),k=Na(s),g.align(f,!1,{x:c,y:k,width:Ba(b)-c,height:Ba(s)-k}),g.show()):g&&g.hide(),a},destroy:function(){ja(this.axis.plotLinesAndBands,this),delete this.axis,Oa(this)}},la.prototype={defaultOptions:{dateTimeLabelFormats:{millisecond:"%H:%M:%S.%L",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%e. %b",week:"%e. %b",month:"%b '%y",year:"%Y"},endOnTick:!1,gridLineColor:"#C0C0C0",labels:N,lineColor:"#C0D0E0",lineWidth:1,minPadding:.01,maxPadding:.01,minorGridLineColor:"#E0E0E0",minorGridLineWidth:1,minorTickColor:"#A0A0A0",minorTickLength:2,minorTickPosition:"outside",startOfWeek:1,startOnTick:!1,tickColor:"#C0D0E0",tickLength:10,tickmarkPlacement:"between",tickPixelInterval:100,tickPosition:"outside",tickWidth:1,title:{align:"middle",style:{color:"#707070"}},type:"linear"},defaultYAxisOptions:{endOnTick:!0,gridLineWidth:1,tickPixelInterval:72,showLastLabel:!0,labels:{x:-8,y:3},lineWidth:0,maxPadding:.05,minPadding:.05,startOnTick:!0,tickWidth:0,title:{rotation:270,text:"Values"},stackLabels:{enabled:!1,formatter:function(){return Ga(this.total,-1)},style:N.style}},defaultLeftAxisOptions:{labels:{x:-15,y:null},title:{rotation:270}},defaultRightAxisOptions:{labels:{x:15,y:null},title:{rotation:90}},defaultBottomAxisOptions:{labels:{x:0,y:20},title:{rotation:0}},defaultTopAxisOptions:{labels:{x:0,y:-15},title:{rotation:0}},init:function(a,b){var c=b.isX;this.horiz=a.inverted?!c:c,this.coll=(this.isXAxis=c)?"xAxis":"yAxis",this.opposite=b.opposite,this.side=b.side||(this.horiz?this.opposite?0:2:this.opposite?1:3),this.setOptions(b);var d=this.options,e=d.type;this.labelFormatter=d.labels.formatter||this.defaultLabelFormatter,this.userOptions=b,this.minPixelPadding=0,this.chart=a,this.reversed=d.reversed,this.zoomEnabled=d.zoomEnabled!==!1,this.categories=d.categories||"category"===e,this.names=[],this.isLog="logarithmic"===e,this.isDatetimeAxis="datetime"===e,this.isLinked=r(d.linkedTo),this.tickmarkOffset=this.categories&&"between"===d.tickmarkPlacement?.5:0,this.ticks={},this.labelEdge=[],this.minorTicks={},this.plotLinesAndBands=[],this.alternateBands={},this.len=0,this.minRange=this.userMinRange=d.minRange||d.maxZoom,this.range=d.range,this.offset=d.offset||0,this.stacks={},this.oldStacks={},this.min=this.max=null,this.crosshair=m(d.crosshair,qa(a.options.tooltip.crosshairs)[c?0:1],!1);var f,d=this.options.events;-1===Da(this,a.axes)&&(c&&!this.isColorAxis?a.axes.splice(a.xAxis.length,0,this):a.axes.push(this),a[this.coll].push(this)),this.series=this.series||[],a.inverted&&c&&this.reversed===t&&(this.reversed=!0),this.removePlotLine=this.removePlotBand=this.removePlotBandOrLine;for(f in d)K(this,f,d[f]);this.isLog&&(this.val2lin=za,this.lin2val=ia)},setOptions:function(a){this.options=w(this.defaultOptions,this.isXAxis?{}:this.defaultYAxisOptions,[this.defaultTopAxisOptions,this.defaultRightAxisOptions,this.defaultBottomAxisOptions,this.defaultLeftAxisOptions][this.side],w(E[this.coll],a))},defaultLabelFormatter:function(){var g,a=this.axis,b=this.value,c=a.categories,d=this.dateTimeLabelFormat,e=E.lang.numericSymbols,f=e&&e.length,h=a.options.labels.format,a=a.isLog?b:a.tickInterval;if(h)g=Ia(h,this);else if(c)g=b;else if(d)g=cb(d,b);else if(f&&a>=1e3)for(;f--&&g===t;)c=Math.pow(1e3,f+1),a>=c&&null!==e[f]&&(g=Ga(b/c,-1)+e[f]);return g===t&&(g=M(b)>=1e4?Ga(b,0):Ga(b,-1,t,"")),g},getSeriesExtremes:function(){var a=this,b=a.chart;a.hasVisibleSeries=!1,a.dataMin=a.dataMax=null,a.buildStacks&&a.buildStacks(),p(a.series,function(c){if(c.visible||!b.options.chart.ignoreHiddenSeries){var d;d=c.options.threshold;var e;a.hasVisibleSeries=!0,a.isLog&&0>=d&&(d=null),a.isXAxis?(d=c.xData,d.length&&(a.dataMin=C(m(a.dataMin,d[0]),Na(d)),a.dataMax=v(m(a.dataMax,d[0]),Ba(d)))):(c.getExtremes(),e=c.dataMax,c=c.dataMin,r(c)&&r(e)&&(a.dataMin=C(m(a.dataMin,c),c),a.dataMax=v(m(a.dataMax,e),e)),r(d)&&(a.dataMin>=d?(a.dataMin=d,a.ignoreMinPadding=!0):a.dataMax<d&&(a.dataMax=d,a.ignoreMaxPadding=!0)))}})},translate:function(a,b,c,d,e,f){var g=1,h=0,i=d?this.oldTransA:this.transA,d=d?this.oldMin:this.min,j=this.minPixelPadding,e=(this.options.ordinal||this.isLog&&e)&&this.lin2val;return i||(i=this.transA),c&&(g*=-1,h=this.len),this.reversed&&(g*=-1,h-=g*(this.sector||this.len)),b?(a=a*g+h,a-=j,a=a/i+d,e&&(a=this.lin2val(a))):(e&&(a=this.val2lin(a)),"between"===f&&(f=.5),a=g*(a-d)*i+h+g*j+(ha(f)?i*f*this.pointRange:0)),a},toPixels:function(a,b){return this.translate(a,!1,!this.horiz,null,!0)+(b?0:this.pos)},toValue:function(a,b){return this.translate(a-(b?0:this.pos),!0,!this.horiz,null,!0)},getPlotLinePath:function(a,b,c,d,e){var i,j,o,f=this.chart,g=this.left,h=this.top,k=c&&f.oldChartHeight||f.chartHeight,l=c&&f.oldChartWidth||f.chartWidth;return i=this.transB,e=m(e,this.translate(a,null,null,c)),a=c=u(e+i),i=j=u(k-e-i),isNaN(e)?o=!0:this.horiz?(i=h,j=k-this.bottom,(g>a||a>g+this.width)&&(o=!0)):(a=g,c=l-this.right,(h>i||i>h+this.height)&&(o=!0)),o&&!d?null:f.renderer.crispLine(["M",a,i,"L",c,j],b||1)},getLinearTickPositions:function(a,b,c){var d,e=da(T(b/a)*a),f=da(Ka(c/a)*a),g=[];if(b===c&&ha(b))return[b];for(b=e;f>=b&&(g.push(b),b=da(b+a),b!==d);)d=b;return g},getMinorTickPositions:function(){var e,a=this.options,b=this.tickPositions,c=this.minorTickInterval,d=[];if(this.isLog)for(e=b.length,a=1;e>a;a++)d=d.concat(this.getLogTickPositions(c,b[a-1],b[a],!0));else if(this.isDatetimeAxis&&"auto"===a.minorTickInterval)d=d.concat(this.getTimeTicks(this.normalizeTimeTickInterval(c),this.min,this.max,a.startOfWeek)),d[0]<this.min&&d.shift();else for(b=this.min+(b[0]-this.min)%c;b<=this.max;b+=c)d.push(b);return d},adjustForMinRange:function(){var d,f,g,h,i,j,a=this.options,b=this.min,c=this.max,e=this.dataMax-this.dataMin>=this.minRange;if(this.isXAxis&&this.minRange===t&&!this.isLog&&(r(a.min)||r(a.max)?this.minRange=null:(p(this.series,function(a){for(i=a.xData,g=j=a.xIncrement?1:i.length-1;g>0;g--)h=i[g]-i[g-1],(f===t||f>h)&&(f=h)}),this.minRange=C(5*f,this.dataMax-this.dataMin))),c-b<this.minRange){var k=this.minRange;d=(k-c+b)/2,d=[b-d,m(a.min,b-d)],e&&(d[2]=this.dataMin),b=Ba(d),c=[b+k,m(a.max,b+k)],e&&(c[2]=this.dataMax),c=Na(c),k>c-b&&(d[0]=c-k,d[1]=m(a.min,c-k),b=Ba(d))}this.min=b,this.max=c},setAxisTranslation:function(a){var e,b=this,c=b.max-b.min,d=b.axisPointRange||0,f=0,g=0,h=b.linkedParent,i=!!b.categories,j=b.transA;(b.isXAxis||i||d)&&(h?(f=h.minPointOffset,g=h.pointRangePadding):p(b.series,function(a){var h=i?1:b.isXAxis?a.pointRange:b.axisPointRange||0,j=a.options.pointPlacement,n=a.closestPointRange;h>c&&(h=0),d=v(d,h),f=v(f,Fa(j)?0:h/2),g=v(g,"on"===j?0:h),!a.noSharedTooltip&&r(n)&&(e=r(e)?C(e,n):n)}),h=b.ordinalSlope&&e?b.ordinalSlope/e:1,b.minPointOffset=f*=h,b.pointRangePadding=g*=h,b.pointRange=C(d,c),b.closestPointRange=e),a&&(b.oldTransA=j),b.translationSlope=b.transA=j=b.len/(c+g||1),b.transB=b.horiz?b.left:b.bottom,b.minPixelPadding=j*f},setTickPositions:function(a){var s,b=this,c=b.chart,d=b.options,e=b.isLog,f=b.isDatetimeAxis,g=b.isXAxis,h=b.isLinked,i=b.options.tickPositioner,j=d.maxPadding,k=d.minPadding,l=d.tickInterval,o=d.minTickInterval,n=d.tickPixelInterval,$=b.categories;h?(b.linkedParent=c[b.coll][d.linkedTo],c=b.linkedParent.getExtremes(),b.min=m(c.min,c.dataMin),b.max=m(c.max,c.dataMax),d.type!==b.linkedParent.options.type&&ra(11,1)):(b.min=m(b.userMin,d.min,b.dataMin),b.max=m(b.userMax,d.max,b.dataMax)),e&&(!a&&C(b.min,m(b.dataMin,b.min))<=0&&ra(10,1),b.min=da(za(b.min)),b.max=da(za(b.max))),b.range&&r(b.max)&&(b.userMin=b.min=v(b.min,b.max-b.range),b.userMax=b.max,b.range=null),b.beforePadding&&b.beforePadding(),b.adjustForMinRange(),$||b.axisPointRange||b.usePercentage||h||!r(b.min)||!r(b.max)||!(c=b.max-b.min)||(r(d.min)||r(b.userMin)||!k||!(b.dataMin<0)&&b.ignoreMinPadding||(b.min-=c*k),r(d.max)||r(b.userMax)||!j||!(b.dataMax>0)&&b.ignoreMaxPadding||(b.max+=c*j)),ha(d.floor)&&(b.min=v(b.min,d.floor)),ha(d.ceiling)&&(b.max=C(b.max,d.ceiling)),b.min===b.max||void 0===b.min||void 0===b.max?b.tickInterval=1:h&&!l&&n===b.linkedParent.options.tickPixelInterval?b.tickInterval=b.linkedParent.tickInterval:(b.tickInterval=m(l,$?1:(b.max-b.min)*n/v(b.len,n)),!r(l)&&b.len<n&&!this.isRadial&&!this.isLog&&!$&&d.startOnTick&&d.endOnTick&&(s=!0,b.tickInterval/=4)),g&&!a&&p(b.series,function(a){a.processData(b.min!==b.oldMin||b.max!==b.oldMax)}),b.setAxisTranslation(!0),b.beforeSetTickPositions&&b.beforeSetTickPositions(),b.postProcessTickInterval&&(b.tickInterval=b.postProcessTickInterval(b.tickInterval)),b.pointRange&&(b.tickInterval=v(b.pointRange,b.tickInterval)),!l&&b.tickInterval<o&&(b.tickInterval=o),f||e||l||(b.tickInterval=nb(b.tickInterval,null,mb(b.tickInterval),d)),b.minorTickInterval="auto"===d.minorTickInterval&&b.tickInterval?b.tickInterval/5:d.minorTickInterval,b.tickPositions=a=d.tickPositions?[].concat(d.tickPositions):i&&i.apply(b,[b.min,b.max]),a||(!b.ordinalPositions&&(b.max-b.min)/b.tickInterval>v(2*b.len,200)&&ra(19,!0),a=f?b.getTimeTicks(b.normalizeTimeTickInterval(b.tickInterval,d.units),b.min,b.max,d.startOfWeek,b.ordinalPositions,b.closestPointRange,!0):e?b.getLogTickPositions(b.tickInterval,b.min,b.max):b.getLinearTickPositions(b.tickInterval,b.min,b.max),s&&a.splice(1,a.length-2),b.tickPositions=a),h||(e=a[0],f=a[a.length-1],h=b.minPointOffset||0,d.startOnTick?b.min=e:b.min-h>e&&a.shift(),d.endOnTick?b.max=f:b.max+h<f&&a.pop(),1===a.length&&(d=M(b.max)>1e13?1:.001,b.min-=d,b.max+=d))},setMaxTicks:function(){var a=this.chart,b=a.maxTicks||{},c=this.tickPositions,d=this._maxTicksKey=[this.coll,this.pos,this.len].join("-");!this.isLinked&&!this.isDatetimeAxis&&c&&c.length>(b[d]||0)&&this.options.alignTicks!==!1&&(b[d]=c.length),a.maxTicks=b},adjustTickAmount:function(){var a=this._maxTicksKey,b=this.tickPositions,c=this.chart.maxTicks;if(c&&c[a]&&!this.isDatetimeAxis&&!this.categories&&!this.isLinked&&this.options.alignTicks!==!1&&this.min!==t){var d=this.tickAmount,e=b.length;if(this.tickAmount=a=c[a],a>e){for(;b.length<a;)b.push(da(b[b.length-1]+this.tickInterval));this.transA*=(e-1)/(a-1),this.max=b[b.length-1]}r(d)&&a!==d&&(this.isDirty=!0)}},setScale:function(){var b,c,d,e,a=this.stacks;if(this.oldMin=this.min,this.oldMax=this.max,this.oldAxisLength=this.len,this.setAxisSize(),e=this.len!==this.oldAxisLength,p(this.series,function(a){(a.isDirtyData||a.isDirty||a.xAxis.isDirty)&&(d=!0)}),e||d||this.isLinked||this.forceRedraw||this.userMin!==this.oldUserMin||this.userMax!==this.oldUserMax){if(!this.isXAxis)for(b in a)for(c in a[b])a[b][c].total=null,a[b][c].cum=0;this.forceRedraw=!1,this.getSeriesExtremes(),this.setTickPositions(),this.oldUserMin=this.userMin,this.oldUserMax=this.userMax,this.isDirty||(this.isDirty=e||this.min!==this.oldMin||this.max!==this.oldMax)}else if(!this.isXAxis){this.oldStacks&&(a=this.stacks=this.oldStacks);for(b in a)for(c in a[b])a[b][c].cum=a[b][c].total}this.setMaxTicks()},setExtremes:function(a,b,c,d,e){var f=this,g=f.chart,c=m(c,!0),e=q(e,{min:a,max:b});D(f,"setExtremes",e,function(){f.userMin=a,f.userMax=b,f.eventArgs=e,f.isDirtyExtremes=!0,c&&g.redraw(d)})},zoom:function(a,b){var c=this.dataMin,d=this.dataMax,e=this.options;return this.allowZoomOutside||(r(c)&&a<=C(c,m(e.min,c))&&(a=t),r(d)&&b>=v(d,m(e.max,d))&&(b=t)),this.displayBtn=a!==t||b!==t,this.setExtremes(a,b,!1,t,{trigger:"zoom"}),!0},setAxisSize:function(){var a=this.chart,b=this.options,c=b.offsetLeft||0,d=this.horiz,e=m(b.width,a.plotWidth-c+(b.offsetRight||0)),f=m(b.height,a.plotHeight),g=m(b.top,a.plotTop),b=m(b.left,a.plotLeft+c),c=/%$/;c.test(f)&&(f=parseInt(f,10)/100*a.plotHeight),c.test(g)&&(g=parseInt(g,10)/100*a.plotHeight+a.plotTop),this.left=b,this.top=g,this.width=e,this.height=f,this.bottom=a.chartHeight-f-g,this.right=a.chartWidth-e-b,this.len=v(d?e:f,0),this.pos=d?b:g},getExtremes:function(){var a=this.isLog;return{min:a?da(ia(this.min)):this.min,max:a?da(ia(this.max)):this.max,dataMin:this.dataMin,dataMax:this.dataMax,userMin:this.userMin,userMax:this.userMax}},getThreshold:function(a){var b=this.isLog,c=b?ia(this.min):this.min,b=b?ia(this.max):this.max;return c>a||null===a?a=c:a>b&&(a=b),this.translate(a,0,1,0,1)},autoLabelAlign:function(a){return a=(m(a,0)-90*this.side+720)%360,a>15&&165>a?"right":a>195&&345>a?"left":"center"},getOffset:function(){var j,l,q,y,z,A,B,a=this,b=a.chart,c=b.renderer,d=a.options,e=a.tickPositions,f=a.ticks,g=a.horiz,h=a.side,i=b.inverted?[1,0,3,2][h]:h,k=0,o=0,n=d.title,s=d.labels,$=0,J=b.axisOffset,L=b.clipOffset,x=[-1,1,1,-1][h],u=1,w=m(s.maxStaggerLines,5),na=2===h?c.fontMetrics(s.style.fontSize).b:0;if(a.hasData=j=a.hasVisibleSeries||r(a.min)&&r(a.max)&&!!e,a.showAxis=b=j||m(d.showEmpty,!0),a.staggerLines=a.horiz&&s.staggerLines,a.axisGroup||(a.gridGroup=c.g("grid").attr({zIndex:d.gridZIndex||1}).add(),a.axisGroup=c.g("axis").attr({zIndex:d.zIndex||2}).add(),a.labelGroup=c.g("axis-labels").attr({zIndex:s.zIndex||7}).addClass("highcharts-"+a.coll.toLowerCase()+"-labels").add()),j||a.isLinked){if(a.labelAlign=m(s.align||a.autoLabelAlign(s.rotation)),p(e,function(b){f[b]?f[b].addLabel():f[b]=new Sa(a,b)}),a.horiz&&!a.staggerLines&&w&&!s.rotation){for(q=a.reversed?[].concat(e).reverse():e;w>u;){for(j=[],y=!1,s=0;s<q.length;s++)z=q[s],A=(A=f[z].label&&f[z].label.getBBox())?A.width:0,B=s%u,A&&(z=a.translate(z),j[B]!==t&&z<j[B]&&(y=!0),j[B]=z+A);if(!y)break;u++}u>1&&(a.staggerLines=u)}p(e,function(b){(0===h||2===h||{1:"left",3:"right"}[h]===a.labelAlign)&&($=v(f[b].getLabelSize(),$))}),a.staggerLines&&($*=a.staggerLines,a.labelOffset=$)}else for(q in f)f[q].destroy(),delete f[q];n&&n.text&&n.enabled!==!1&&(a.axisTitle||(a.axisTitle=c.text(n.text,0,0,n.useHTML).attr({zIndex:7,rotation:n.rotation||0,align:n.textAlign||{low:"left",middle:"center",high:"right"}[n.align]}).addClass("highcharts-"+this.coll.toLowerCase()+"-title").css(n.style).add(a.axisGroup),a.axisTitle.isNew=!0),b&&(k=a.axisTitle.getBBox()[g?"height":"width"],o=m(n.margin,g?5:10),l=n.offset),a.axisTitle[b?"show":"hide"]()),a.offset=x*m(d.offset,J[h]),a.axisTitleMargin=m(l,$+o+($&&x*d.labels[g?"y":"x"]-na)),J[h]=v(J[h],a.axisTitleMargin+k+x*a.offset),L[i]=v(L[i],2*T(d.lineWidth/2))},getLinePath:function(a){var b=this.chart,c=this.opposite,d=this.offset,e=this.horiz,f=this.left+(c?this.width:0)+d,d=b.chartHeight-this.bottom-(c?this.height:0)+d;return c&&(a*=-1),b.renderer.crispLine(["M",e?this.left:f,e?d:this.top,"L",e?b.chartWidth-this.right:f,e?d:b.chartHeight-this.bottom],a)},getTitlePosition:function(){var a=this.horiz,b=this.left,c=this.top,d=this.len,e=this.options.title,f=a?b:c,g=this.opposite,h=this.offset,i=z(e.style.fontSize||12),d={low:f+(a?0:d),middle:f+d/2,high:f+(a?d:0)}[e.align],b=(a?c+this.height:b)+(a?1:-1)*(g?-1:1)*this.axisTitleMargin+(2===this.side?i:0);
|
3 |
return{x:a?d:b+(g?this.width:0)+h+(e.x||0),y:a?b-(g?this.height:0)+h:d+(e.y||0)}},render:function(){var j,u,z,a=this,b=a.horiz,c=a.reversed,d=a.chart,e=d.renderer,f=a.options,g=a.isLog,h=a.isLinked,i=a.tickPositions,k=a.axisTitle,l=a.ticks,o=a.minorTicks,n=a.alternateBands,s=f.stackLabels,m=f.alternateGridColor,J=a.tickmarkOffset,L=f.lineWidth,x=d.hasRendered&&r(a.oldMin)&&!isNaN(a.oldMin),q=a.hasData,v=a.showAxis,w=f.labels.overflow,y=a.justifyLabels=b&&w!==!1;a.labelEdge.length=0,a.justifyToPlot="justify"===w,p([l,o,n],function(a){for(var b in a)a[b].isActive=!1}),(q||h)&&(a.minorTickInterval&&!a.categories&&p(a.getMinorTickPositions(),function(b){o[b]||(o[b]=new Sa(a,b,"minor")),x&&o[b].isNew&&o[b].render(null,!0),o[b].render(null,!1,1)}),i.length&&(j=i.slice(),(b&&c||!b&&!c)&&j.reverse(),y&&(j=j.slice(1).concat([j[0]])),p(j,function(b,c){y&&(c=c===j.length-1?0:c+1),(!h||b>=a.min&&b<=a.max)&&(l[b]||(l[b]=new Sa(a,b)),x&&l[b].isNew&&l[b].render(c,!0,.1),l[b].render(c,!1,1))}),J&&0===a.min&&(l[-1]||(l[-1]=new Sa(a,-1,null,!0)),l[-1].render(-1))),m&&p(i,function(b,c){c%2===0&&b<a.max&&(n[b]||(n[b]=new R.PlotLineOrBand(a)),u=b+J,z=i[c+1]!==t?i[c+1]+J:a.max,n[b].options={from:g?ia(u):u,to:g?ia(z):z,color:m},n[b].render(),n[b].isActive=!0)}),a._addedPlotLB||(p((f.plotLines||[]).concat(f.plotBands||[]),function(b){a.addPlotBandOrLine(b)}),a._addedPlotLB=!0)),p([l,o,n],function(a){var b,c,e=[],f=va?va.duration||500:0,g=function(){for(c=e.length;c--;)a[e[c]]&&!a[e[c]].isActive&&(a[e[c]].destroy(),delete a[e[c]])};for(b in a)a[b].isActive||(a[b].render(b,!1,0),a[b].isActive=!1,e.push(b));a!==n&&d.hasRendered&&f?f&&setTimeout(g,f):g()}),L&&(b=a.getLinePath(L),a.axisLine?a.axisLine.animate({d:b}):a.axisLine=e.path(b).attr({stroke:f.lineColor,"stroke-width":L,zIndex:7}).add(a.axisGroup),a.axisLine[v?"show":"hide"]()),k&&v&&(k[k.isNew?"attr":"animate"](a.getTitlePosition()),k.isNew=!1),s&&s.enabled&&a.renderStackTotals(),a.isDirty=!1},redraw:function(){var a=this.chart.pointer;a&&a.reset(!0),this.render(),p(this.plotLinesAndBands,function(a){a.render()}),p(this.series,function(a){a.isDirty=!0})},destroy:function(a){var d,b=this,c=b.stacks,e=b.plotLinesAndBands;a||W(b);for(d in c)Oa(c[d]),c[d]=null;for(p([b.ticks,b.minorTicks,b.alternateBands],function(a){Oa(a)}),a=e.length;a--;)e[a].destroy();p("stackTotalGroup,axisLine,axisTitle,axisGroup,cross,gridGroup,labelGroup".split(","),function(a){b[a]&&(b[a]=b[a].destroy())}),this.cross&&this.cross.destroy()},drawCrosshair:function(a,b){if(this.crosshair)if((r(b)||!m(this.crosshair.snap,!0))===!1)this.hideCrosshair();else{var c,d=this.crosshair,e=d.animation;m(d.snap,!0)?r(b)&&(c=this.chart.inverted!=this.horiz?b.plotX:this.len-b.plotY):c=this.horiz?a.chartX-this.pos:this.len-a.chartY+this.pos,c=this.isRadial?this.getPlotLinePath(this.isXAxis?b.x:m(b.stackY,b.y)):this.getPlotLinePath(null,null,null,null,c),null===c?this.hideCrosshair():this.cross?this.cross.attr({visibility:"visible"})[e?"animate":"attr"]({d:c},e):(e={"stroke-width":d.width||1,stroke:d.color||"#C0C0C0",zIndex:d.zIndex||2},d.dashStyle&&(e.dashstyle=d.dashStyle),this.cross=this.chart.renderer.path(c).attr(e).add())}},hideCrosshair:function(){this.cross&&this.cross.hide()}},q(la.prototype,{getPlotBandPath:function(a,b){var c=this.getPlotLinePath(b),d=this.getPlotLinePath(a);return d&&c?d.push(c[4],c[5],c[1],c[2]):d=null,d},addPlotBand:function(a){this.addPlotBandOrLine(a,"plotBands")},addPlotLine:function(a){this.addPlotBandOrLine(a,"plotLines")},addPlotBandOrLine:function(a,b){var c=new R.PlotLineOrBand(this,a).render(),d=this.userOptions;return c&&(b&&(d[b]=d[b]||[],d[b].push(a)),this.plotLinesAndBands.push(c)),c},removePlotBandOrLine:function(a){for(var b=this.plotLinesAndBands,c=this.options,d=this.userOptions,e=b.length;e--;)b[e].id===a&&b[e].destroy();p([c.plotLines||[],d.plotLines||[],c.plotBands||[],d.plotBands||[]],function(b){for(e=b.length;e--;)b[e].id===a&&ja(b,b[e])})}}),la.prototype.getTimeTicks=function(a,b,c,d){var h,e=[],f={},g=E.global.useUTC,i=new Date(b-Ra),j=a.unitRange,k=a.count;if(r(b)){j>=A.second&&(i.setMilliseconds(0),i.setSeconds(j>=A.minute?0:k*T(i.getSeconds()/k))),j>=A.minute&&i[Db](j>=A.hour?0:k*T(i[pb]()/k)),j>=A.hour&&i[Eb](j>=A.day?0:k*T(i[qb]()/k)),j>=A.day&&i[sb](j>=A.month?1:k*T(i[Xa]()/k)),j>=A.month&&(i[Fb](j>=A.year?0:k*T(i[fb]()/k)),h=i[gb]()),j>=A.year&&(h-=h%k,i[Gb](h)),j===A.week&&i[sb](i[Xa]()-i[rb]()+m(d,1)),b=1,Ra&&(i=new Date(i.getTime()+Ra)),h=i[gb]();for(var d=i.getTime(),l=i[fb](),o=i[Xa](),n=g?Ra:(864e5+6e4*i.getTimezoneOffset())%864e5;c>d;)e.push(d),j===A.year?d=eb(h+b*k,0):j===A.month?d=eb(h,l+b*k):g||j!==A.day&&j!==A.week?d+=j*k:d=eb(h,l,o+b*k*(j===A.day?1:7)),b++;e.push(d),p(vb(e,function(a){return j<=A.hour&&a%A.day===n}),function(a){f[a]="day"})}return e.info=q(a,{higherRanks:f,totalRange:j*k}),e},la.prototype.normalizeTimeTickInterval=function(a,b){var g,c=b||[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],d=c[c.length-1],e=A[d[0]],f=d[1];for(g=0;g<c.length&&(d=c[g],e=A[d[0]],f=d[1],!(c[g+1]&&a<=(e*f[f.length-1]+A[c[g+1][0]])/2));g++);return e===A.year&&5*e>a&&(f=[1,2,5]),c=nb(a/e,f,"year"===d[0]?v(mb(a/e),1):1),{unitRange:e,count:c,unitName:d[0]}},la.prototype.getLogTickPositions=function(a,b,c,d){var e=this.options,f=this.len,g=[];if(d||(this._minorAutoInterval=null),a>=.5)a=u(a),g=this.getLinearTickPositions(a,b,c);else if(a>=.08)for(var h,i,j,k,l,f=T(b),e=a>.3?[1,2,4]:a>.15?[1,2,4,6,8]:[1,2,3,4,5,6,7,8,9];c+1>f&&!l;f++)for(i=e.length,h=0;i>h&&!l;h++)j=za(ia(f)*e[h]),j>b&&(!d||c>=k)&&g.push(k),k>c&&(l=!0),k=j;else b=ia(b),c=ia(c),a=e[d?"minorTickInterval":"tickInterval"],a=m("auto"===a?null:a,this._minorAutoInterval,(c-b)*(e.tickPixelInterval/(d?5:1))/((d?f/this.tickPositions.length:f)||1)),a=nb(a,null,mb(a)),g=Ua(this.getLinearTickPositions(a,b,c),za),d||(this._minorAutoInterval=a/5);return d||(this.tickInterval=a),g};var Mb=R.Tooltip=function(){this.init.apply(this,arguments)};Mb.prototype={init:function(a,b){var c=b.borderWidth,d=b.style,e=z(d.padding);this.chart=a,this.options=b,this.crosshairs=[],this.now={x:0,y:0},this.isHidden=!0,this.label=a.renderer.label("",0,0,b.shape||"callout",null,null,b.useHTML,null,"tooltip").attr({padding:e,fill:b.backgroundColor,"stroke-width":c,r:b.borderRadius,zIndex:8}).css(d).css({padding:0}).add().attr({y:-9999}),fa||this.label.shadow(b.shadow),this.shared=b.shared},destroy:function(){this.label&&(this.label=this.label.destroy()),clearTimeout(this.hideTimer),clearTimeout(this.tooltipTimeout)},move:function(a,b,c,d){var e=this,f=e.now,g=e.options.animation!==!1&&!e.isHidden,h=e.followPointer||e.len>1;q(f,{x:g?(2*f.x+a)/3:a,y:g?(f.y+b)/2:b,anchorX:h?t:g?(2*f.anchorX+c)/3:c,anchorY:h?t:g?(f.anchorY+d)/2:d}),e.label.attr(f),g&&(M(a-f.x)>1||M(b-f.y)>1)&&(clearTimeout(this.tooltipTimeout),this.tooltipTimeout=setTimeout(function(){e&&e.move(a,b,c,d)},32))},hide:function(){var b,a=this;clearTimeout(this.hideTimer),this.isHidden||(b=this.chart.hoverPoints,this.hideTimer=setTimeout(function(){a.label.fadeOut(),a.isHidden=!0},m(this.options.hideDelay,500)),b&&p(b,function(a){a.setState()}),this.chart.hoverPoints=null)},getAnchor:function(a,b){var c,i,d=this.chart,e=d.inverted,f=d.plotTop,g=0,h=0,a=qa(a);return c=a[0].tooltipPos,this.followPointer&&b&&(b.chartX===t&&(b=d.pointer.normalize(b)),c=[b.chartX-d.plotLeft,b.chartY-f]),c||(p(a,function(a){i=a.series.yAxis,g+=a.plotX,h+=(a.plotLow?(a.plotLow+a.plotHigh)/2:a.plotY)+(!e&&i?i.top-f:0)}),g/=a.length,h/=a.length,c=[e?d.plotWidth-h:g,this.shared&&!e&&a.length>1&&b?b.chartY-f:e?d.plotHeight-g:h]),Ua(c,u)},getPosition:function(a,b,c){var g,d=this.chart,e=this.distance,f={},h=["y",d.chartHeight,b,c.plotY+d.plotTop],i=["x",d.chartWidth,a,c.plotX+d.plotLeft],j=c.ttBelow||d.inverted&&!c.negative||!d.inverted&&c.negative,k=function(a,b,c,d){var g=d-e>c,b=b>d+e+c,c=d-e-c;if(d+=e,j&&b)f[a]=d;else if(!j&&g)f[a]=c;else if(g)f[a]=c;else{if(!b)return!1;f[a]=d}},l=function(a,b,c,d){return e>d||d>b-e?!1:void(f[a]=c/2>d?1:d>b-c/2?b-c-2:d-c/2)},o=function(a){var b=h;h=i,i=b,g=a},n=function(){k.apply(0,h)!==!1?l.apply(0,i)===!1&&!g&&(o(!0),n()):g?f.x=f.y=0:(o(!0),n())};return(d.inverted||this.len>1)&&o(),n(),f},defaultFormatter:function(a){var d,b=this.points||qa(this),c=b[0].series;return d=[a.tooltipHeaderFormatter(b[0])],p(b,function(a){c=a.series,d.push(c.tooltipFormatter&&c.tooltipFormatter(a)||a.point.tooltipFormatter(c.tooltipOptions.pointFormat))}),d.push(a.options.footerFormat||""),d.join("")},refresh:function(a,b){var f,g,i,c=this.chart,d=this.label,e=this.options,h={},j=[];i=e.formatter||this.defaultFormatter;var k,h=c.hoverPoints,l=this.shared;clearTimeout(this.hideTimer),this.followPointer=qa(a)[0].series.tooltipOptions.followPointer,g=this.getAnchor(a,b),f=g[0],g=g[1],!l||a.series&&a.series.noSharedTooltip?h=a.getLabelConfig():(c.hoverPoints=a,h&&p(h,function(a){a.setState()}),p(a,function(a){a.setState("hover"),j.push(a.getLabelConfig())}),h={x:a[0].category,y:a[0].y},h.points=j,this.len=j.length,a=a[0]),i=i.call(h,this),h=a.series,this.distance=m(h.tooltipOptions.distance,16),i===!1?this.hide():(this.isHidden&&(bb(d),d.attr("opacity",1).show()),d.attr({text:i}),k=e.borderColor||a.color||h.color||"#606060",d.attr({stroke:k}),this.updatePosition({plotX:f,plotY:g,negative:a.negative,ttBelow:a.ttBelow}),this.isHidden=!1),D(c,"tooltipRefresh",{text:i,x:f+c.plotLeft,y:g+c.plotTop,borderColor:k})},updatePosition:function(a){var b=this.chart,c=this.label,c=(this.options.positioner||this.getPosition).call(this,c.width,c.height,a);this.move(u(c.x),u(c.y),a.plotX+b.plotLeft,a.plotY+b.plotTop)},tooltipHeaderFormatter:function(a){var h,b=a.series,c=b.tooltipOptions,d=c.dateTimeLabelFormats,e=c.xDateFormat,f=b.xAxis,g=f&&"datetime"===f.options.type&&ha(a.key),c=c.headerFormat,f=f&&f.closestPointRange;if(g&&!e){if(f){for(h in A)if(A[h]>=f||A[h]<=A.day&&a.key%A[h]>0){e=d[h];break}}else e=d.day;e=e||d.year}return g&&e&&(c=c.replace("{point.key}","{point.key:"+e+"}")),Ia(c,{point:a,series:b})}};var oa;$a=y.documentElement.ontouchstart!==t;var Wa=R.Pointer=function(a,b){this.init(a,b)};if(Wa.prototype={init:function(a,b){var f,c=b.chart,d=c.events,e=fa?"":c.zoomType,c=a.inverted;this.options=b,this.chart=a,this.zoomX=f=/x/.test(e),this.zoomY=e=/y/.test(e),this.zoomHor=f&&!c||e&&c,this.zoomVert=e&&!c||f&&c,this.hasZoom=f||e,this.runChartClick=d&&!!d.click,this.pinchDown=[],this.lastValidTouch={},R.Tooltip&&b.tooltip.enabled&&(a.tooltip=new Mb(a,b.tooltip),this.followTouchMove=b.tooltip.followTouchMove),this.setDOMEvents()},normalize:function(a,b){var c,d,a=a||window.event,a=Sb(a);return a.target||(a.target=a.srcElement),d=a.touches?a.touches.length?a.touches.item(0):a.changedTouches[0]:a,b||(this.chartPosition=b=Rb(this.chart.container)),d.pageX===t?(c=v(a.x,a.clientX-b.left),d=a.y):(c=d.pageX-b.left,d=d.pageY-b.top),q(a,{chartX:u(c),chartY:u(d)})},getCoordinates:function(a){var b={xAxis:[],yAxis:[]};return p(this.chart.axes,function(c){b[c.isXAxis?"xAxis":"yAxis"].push({axis:c,value:c.toValue(a[c.horiz?"chartX":"chartY"])})}),b},getIndex:function(a){var b=this.chart;return b.inverted?b.plotHeight+b.plotTop-a.chartY:a.chartX-b.plotLeft},runPointActions:function(a){var e,f,i,j,b=this.chart,c=b.series,d=b.tooltip,g=b.hoverPoint,h=b.hoverSeries,k=b.chartWidth,l=this.getIndex(a);if(d&&this.options.tooltip.shared&&(!h||!h.noSharedTooltip)){for(f=[],i=c.length,j=0;i>j;j++)c[j].visible&&c[j].options.enableMouseTracking!==!1&&!c[j].noSharedTooltip&&c[j].singularTooltips!==!0&&c[j].tooltipPoints.length&&(e=c[j].tooltipPoints[l])&&e.series&&(e._dist=M(l-e.clientX),k=C(k,e._dist),f.push(e));for(i=f.length;i--;)f[i]._dist>k&&f.splice(i,1);f.length&&f[0].clientX!==this.hoverX&&(d.refresh(f,a),this.hoverX=f[0].clientX)}c=h&&h.tooltipOptions.followPointer,h&&h.tracker&&!c?(e=h.tooltipPoints[l])&&e!==g&&e.onMouseOver(a):d&&c&&!d.isHidden&&(h=d.getAnchor([{}],a),d.updatePosition({plotX:h[0],plotY:h[1]})),d&&!this._onDocumentMouseMove&&(this._onDocumentMouseMove=function(a){V[oa]&&V[oa].pointer.onDocumentMouseMove(a)},K(y,"mousemove",this._onDocumentMouseMove)),p(b.axes,function(b){b.drawCrosshair(a,m(e,g))})},reset:function(a){var b=this.chart,c=b.hoverSeries,d=b.hoverPoint,e=b.tooltip,f=e&&e.shared?b.hoverPoints:d;(a=a&&e&&f)&&qa(f)[0].plotX===t&&(a=!1),a?(e.refresh(f),d&&d.setState(d.state,!0)):(d&&d.onMouseOut(),c&&c.onMouseOut(),e&&e.hide(),this._onDocumentMouseMove&&(W(y,"mousemove",this._onDocumentMouseMove),this._onDocumentMouseMove=null),p(b.axes,function(a){a.hideCrosshair()}),this.hoverX=null)},scaleGroups:function(a,b){var d,c=this.chart;p(c.series,function(e){d=a||e.getPlotBox(),e.xAxis&&e.xAxis.zoomEnabled&&(e.group.attr(d),e.markerGroup&&(e.markerGroup.attr(d),e.markerGroup.clip(b?c.clipRect:null)),e.dataLabelsGroup&&e.dataLabelsGroup.attr(d))}),c.clipRect.attr(b||c.clipBox)},dragStart:function(a){var b=this.chart;b.mouseIsDown=a.type,b.cancelClick=!1,b.mouseDownX=this.mouseDownX=a.chartX,b.mouseDownY=this.mouseDownY=a.chartY},drag:function(a){var l,b=this.chart,c=b.options.chart,d=a.chartX,e=a.chartY,f=this.zoomHor,g=this.zoomVert,h=b.plotLeft,i=b.plotTop,j=b.plotWidth,k=b.plotHeight,o=this.mouseDownX,n=this.mouseDownY;h>d?d=h:d>h+j&&(d=h+j),i>e?e=i:e>i+k&&(e=i+k),this.hasDragged=Math.sqrt(Math.pow(o-d,2)+Math.pow(n-e,2)),this.hasDragged>10&&(l=b.isInsidePlot(o-h,n-i),b.hasCartesianSeries&&(this.zoomX||this.zoomY)&&l&&!this.selectionMarker&&(this.selectionMarker=b.renderer.rect(h,i,f?1:j,g?1:k,0).attr({fill:c.selectionMarkerFill||"rgba(69,114,167,0.25)",zIndex:7}).add()),this.selectionMarker&&f&&(d-=o,this.selectionMarker.attr({width:M(d),x:(d>0?0:d)+o})),this.selectionMarker&&g&&(d=e-n,this.selectionMarker.attr({height:M(d),y:(d>0?0:d)+n})),l&&!this.selectionMarker&&c.panning&&b.pan(a,c.panning))},drop:function(a){var b=this.chart,c=this.hasPinched;if(this.selectionMarker){var i,d={xAxis:[],yAxis:[],originalEvent:a.originalEvent||a},a=this.selectionMarker,e=a.attr?a.attr("x"):a.x,f=a.attr?a.attr("y"):a.y,g=a.attr?a.attr("width"):a.width,h=a.attr?a.attr("height"):a.height;(this.hasDragged||c)&&(p(b.axes,function(a){if(a.zoomEnabled){var b=a.horiz,c=a.toValue(b?e:f),b=a.toValue(b?e+g:f+h);!isNaN(c)&&!isNaN(b)&&(d[a.coll].push({axis:a,min:C(c,b),max:v(c,b)}),i=!0)}}),i&&D(b,"selection",d,function(a){b.zoom(q(a,c?{animation:!1}:null))})),this.selectionMarker=this.selectionMarker.destroy(),c&&this.scaleGroups()}b&&(G(b.container,{cursor:b._cursor}),b.cancelClick=this.hasDragged>10,b.mouseIsDown=this.hasDragged=this.hasPinched=!1,this.pinchDown=[])},onContainerMouseDown:function(a){a=this.normalize(a),a.preventDefault&&a.preventDefault(),this.dragStart(a)},onDocumentMouseUp:function(a){V[oa]&&V[oa].pointer.drop(a)},onDocumentMouseMove:function(a){var b=this.chart,c=this.chartPosition,d=b.hoverSeries,a=this.normalize(a,c);c&&d&&!this.inClass(a.target,"highcharts-tracker")&&!b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)&&this.reset()},onContainerMouseLeave:function(){var a=V[oa];a&&(a.pointer.reset(),a.pointer.chartPosition=null)},onContainerMouseMove:function(a){var b=this.chart;oa=b.index,a=this.normalize(a),"mousedown"===b.mouseIsDown&&this.drag(a),(this.inClass(a.target,"highcharts-tracker")||b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop))&&!b.openMenu&&this.runPointActions(a)},inClass:function(a,b){for(var c;a;){if(c=H(a,"class")){if(-1!==c.indexOf(b))return!0;if(-1!==c.indexOf("highcharts-container"))return!1}a=a.parentNode}},onTrackerMouseOut:function(a){var b=this.chart.hoverSeries,c=(a=a.relatedTarget||a.toElement)&&a.point&&a.point.series;!b||b.options.stickyTracking||this.inClass(a,"highcharts-tooltip")||c===b||b.onMouseOut()},onContainerClick:function(a){var b=this.chart,c=b.hoverPoint,d=b.plotLeft,e=b.plotTop,a=this.normalize(a);a.cancelBubble=!0,b.cancelClick||(c&&this.inClass(a.target,"highcharts-tracker")?(D(c.series,"click",q(a,{point:c})),b.hoverPoint&&c.firePointEvent("click",a)):(q(a,this.getCoordinates(a)),b.isInsidePlot(a.chartX-d,a.chartY-e)&&D(b,"click",a)))},setDOMEvents:function(){var a=this,b=a.chart.container;b.onmousedown=function(b){a.onContainerMouseDown(b)},b.onmousemove=function(b){a.onContainerMouseMove(b)},b.onclick=function(b){a.onContainerClick(b)},K(b,"mouseleave",a.onContainerMouseLeave),1===ab&&K(y,"mouseup",a.onDocumentMouseUp),$a&&(b.ontouchstart=function(b){a.onContainerTouchStart(b)},b.ontouchmove=function(b){a.onContainerTouchMove(b)},1===ab&&K(y,"touchend",a.onDocumentTouchEnd))},destroy:function(){var a;W(this.chart.container,"mouseleave",this.onContainerMouseLeave),ab||(W(y,"mouseup",this.onDocumentMouseUp),W(y,"touchend",this.onDocumentTouchEnd)),clearInterval(this.tooltipTimeout);for(a in this)this[a]=null}},q(R.Pointer.prototype,{pinchTranslate:function(a,b,c,d,e,f){(this.zoomHor||this.pinchHor)&&this.pinchTranslateDirection(!0,a,b,c,d,e,f),(this.zoomVert||this.pinchVert)&&this.pinchTranslateDirection(!1,a,b,c,d,e,f)},pinchTranslateDirection:function(a,b,c,d,e,f,g,h){var s,m,y,i=this.chart,j=a?"x":"y",k=a?"X":"Y",l="chart"+k,o=a?"width":"height",n=i["plot"+(a?"Left":"Top")],p=h||1,q=i.inverted,x=i.bounds[a?"h":"v"],r=1===b.length,v=b[0][l],u=c[0][l],t=!r&&b[1][l],w=!r&&c[1][l],c=function(){!r&&M(v-t)>20&&(p=h||M(u-w)/M(v-t)),m=(n-u)/p+v,s=i["plot"+(a?"Width":"Height")]/p};c(),b=m,b<x.min?(b=x.min,y=!0):b+s>x.max&&(b=x.max-s,y=!0),y?(u-=.8*(u-g[j][0]),r||(w-=.8*(w-g[j][1])),c()):g[j]=[u,w],q||(f[j]=m-n,f[o]=s),f=q?1/p:p,e[o]=s,e[j]=b,d[q?a?"scaleY":"scaleX":"scale"+k]=p,d["translate"+k]=f*n+(u-f*v)},pinch:function(a){var b=this,c=b.chart,d=b.pinchDown,e=b.followTouchMove,f=a.touches,g=f.length,h=b.lastValidTouch,i=b.hasZoom,j=b.selectionMarker,k={},l=1===g&&(b.inClass(a.target,"highcharts-tracker")&&c.runTrackerClick||c.runChartClick),o={};(i||e)&&!l&&a.preventDefault(),Ua(f,function(a){return b.normalize(a)}),"touchstart"===a.type?(p(f,function(a,b){d[b]={chartX:a.chartX,chartY:a.chartY}}),h.x=[d[0].chartX,d[1]&&d[1].chartX],h.y=[d[0].chartY,d[1]&&d[1].chartY],p(c.axes,function(a){if(a.zoomEnabled){var b=c.bounds[a.horiz?"h":"v"],d=a.minPixelPadding,e=a.toPixels(a.dataMin),f=a.toPixels(a.dataMax),g=C(e,f),e=v(e,f);b.min=C(a.pos,g-d),b.max=v(a.pos+a.len,e+d)}})):d.length&&(j||(b.selectionMarker=j=q({destroy:sa},c.plotBox)),b.pinchTranslate(d,f,k,j,o,h),b.hasPinched=i,b.scaleGroups(k,o),!i&&e&&1===g&&this.runPointActions(b.normalize(a)))},onContainerTouchStart:function(a){var b=this.chart;oa=b.index,1===a.touches.length?(a=this.normalize(a),b.isInsidePlot(a.chartX-b.plotLeft,a.chartY-b.plotTop)?(this.runPointActions(a),this.pinch(a)):this.reset()):2===a.touches.length&&this.pinch(a)},onContainerTouchMove:function(a){(1===a.touches.length||2===a.touches.length)&&this.pinch(a)},onDocumentTouchEnd:function(a){V[oa]&&V[oa].pointer.drop(a)}}),I.PointerEvent||I.MSPointerEvent){var ua={},zb=!!I.PointerEvent,Wb=function(){var a,b=[];b.item=function(a){return this[a]};for(a in ua)ua.hasOwnProperty(a)&&b.push({pageX:ua[a].pageX,pageY:ua[a].pageY,target:ua[a].target});return b},Ab=function(a,b,c,d){a=a.originalEvent||a,"touch"!==a.pointerType&&a.pointerType!==a.MSPOINTER_TYPE_TOUCH||!V[oa]||(d(a),d=V[oa].pointer,d[b]({type:c,target:a.currentTarget,preventDefault:sa,touches:Wb()}))};q(Wa.prototype,{onContainerPointerDown:function(a){Ab(a,"onContainerTouchStart","touchstart",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY,target:a.currentTarget}})},onContainerPointerMove:function(a){Ab(a,"onContainerTouchMove","touchmove",function(a){ua[a.pointerId]={pageX:a.pageX,pageY:a.pageY},ua[a.pointerId].target||(ua[a.pointerId].target=a.currentTarget)})},onDocumentPointerUp:function(a){Ab(a,"onContainerTouchEnd","touchend",function(a){delete ua[a.pointerId]})},batchMSEvents:function(a){a(this.chart.container,zb?"pointerdown":"MSPointerDown",this.onContainerPointerDown),a(this.chart.container,zb?"pointermove":"MSPointerMove",this.onContainerPointerMove),a(y,zb?"pointerup":"MSPointerUp",this.onDocumentPointerUp)}}),Ma(Wa.prototype,"init",function(a,b,c){a.call(this,b,c),(this.hasZoom||this.followTouchMove)&&G(b.container,{"-ms-touch-action":Q,"touch-action":Q})}),Ma(Wa.prototype,"setDOMEvents",function(a){a.apply(this),(this.hasZoom||this.followTouchMove)&&this.batchMSEvents(K)}),Ma(Wa.prototype,"destroy",function(a){this.batchMSEvents(W),a.call(this)})}var lb=R.Legend=function(a,b){this.init(a,b)};lb.prototype={init:function(a,b){var c=this,d=b.itemStyle,e=m(b.padding,8),f=b.itemMarginTop||0;this.options=b,b.enabled&&(c.baseline=z(d.fontSize)+3+f,c.itemStyle=d,c.itemHiddenStyle=w(d,b.itemHiddenStyle),c.itemMarginTop=f,c.padding=e,c.initialItemX=e,c.initialItemY=e-5,c.maxItemWidth=0,c.chart=a,c.itemHeight=0,c.lastLineHeight=0,c.symbolWidth=m(b.symbolWidth,16),c.pages=[],c.render(),K(c.chart,"endResize",function(){c.positionCheckboxes()}))},colorizeItem:function(a,b){var j,c=this.options,d=a.legendItem,e=a.legendLine,f=a.legendSymbol,g=this.itemHiddenStyle.color,c=b?c.itemStyle.color:g,h=b?a.legendColor||a.color||"#CCC":g,g=a.options&&a.options.marker,i={fill:h};if(d&&d.css({fill:c,color:c}),e&&e.attr({stroke:h}),f){if(g&&f.isMarker)for(j in i.stroke=h,g=a.convertAttribs(g))d=g[j],d!==t&&(i[j]=d);f.attr(i)}},positionItem:function(a){var b=this.options,c=b.symbolPadding,b=!b.rtl,d=a._legendItemPos,e=d[0],d=d[1],f=a.checkbox;a.legendGroup&&a.legendGroup.translate(b?e:this.legendWidth-e-2*c-4,d),f&&(f.x=e,f.y=d)},destroyItem:function(a){var b=a.checkbox;p(["legendItem","legendLine","legendSymbol","legendGroup"],function(b){a[b]&&(a[b]=a[b].destroy())}),b&&Pa(a.checkbox)},destroy:function(){var a=this.group,b=this.box;b&&(this.box=b.destroy()),a&&(this.group=a.destroy())},positionCheckboxes:function(a){var c,b=this.group.alignAttr,d=this.clipHeight||this.legendHeight;b&&(c=b.translateY,p(this.allItems,function(e){var g,f=e.checkbox;f&&(g=c+f.y+(a||0)+3,G(f,{left:b.translateX+e.checkboxOffset+f.x-20+"px",top:g+"px",display:g>c-6&&c+d-6>g?"":Q}))}))},renderTitle:function(){var a=this.padding,b=this.options.title,c=0;b.text&&(this.title||(this.title=this.chart.renderer.label(b.text,a-3,a-4,null,null,null,null,null,"legend-title").attr({zIndex:1}).css(b.style).add(this.group)),a=this.title.getBBox(),c=a.height,this.offsetWidth=a.width,this.contentGroup.attr({translateY:c})),this.titleHeight=c},renderItem:function(a){var b=this.chart,c=b.renderer,d=this.options,e="horizontal"===d.layout,f=this.symbolWidth,g=d.symbolPadding,h=this.itemStyle,i=this.itemHiddenStyle,j=this.padding,k=e?m(d.itemDistance,20):0,l=!d.rtl,o=d.width,n=d.itemMarginBottom||0,s=this.itemMarginTop,p=this.initialItemX,q=a.legendItem,r=a.series&&a.series.drawLegendSymbol?a.series:a,x=r.options,x=this.createCheckboxForItem&&x&&x.showCheckbox,t=d.useHTML;q||(a.legendGroup=c.g("legend-item").attr({zIndex:1}).add(this.scrollGroup),r.drawLegendSymbol(this,a),a.legendItem=q=c.text(d.labelFormat?Ia(d.labelFormat,a):d.labelFormatter.call(a),l?f+g:-g,this.baseline,t).css(w(a.visible?h:i)).attr({align:l?"left":"right",zIndex:2}).add(a.legendGroup),this.setItemEvents&&this.setItemEvents(a,q,t,h,i),this.colorizeItem(a,a.visible),x&&this.createCheckboxForItem(a)),c=q.getBBox(),f=a.checkboxOffset=d.itemWidth||a.legendItemWidth||f+g+c.width+k+(x?20:0),this.itemHeight=g=u(a.legendItemHeight||c.height),e&&this.itemX-p+f>(o||b.chartWidth-2*j-p-d.x)&&(this.itemX=p,this.itemY+=s+this.lastLineHeight+n,this.lastLineHeight=0),this.maxItemWidth=v(this.maxItemWidth,f),this.lastItemY=s+this.itemY+n,this.lastLineHeight=v(g,this.lastLineHeight),a._legendItemPos=[this.itemX,this.itemY],e?this.itemX+=f:(this.itemY+=s+g+n,this.lastLineHeight=g),this.offsetWidth=o||v((e?this.itemX-p-k:f)+j,this.offsetWidth)},getAllItems:function(){var a=[];return p(this.chart.series,function(b){var c=b.options;m(c.showInLegend,r(c.linkedTo)?!1:t,!0)&&(a=a.concat(b.legendItems||("point"===c.legendType?b.data:b)))}),a},render:function(){var e,f,g,h,a=this,b=a.chart,c=b.renderer,d=a.group,i=a.box,j=a.options,k=a.padding,l=j.borderWidth,o=j.backgroundColor;a.itemX=a.initialItemX,a.itemY=a.initialItemY,a.offsetWidth=0,a.lastItemY=0,d||(a.group=d=c.g("legend").attr({zIndex:7}).add(),a.contentGroup=c.g().attr({zIndex:1}).add(d),a.scrollGroup=c.g().add(a.contentGroup)),a.renderTitle(),e=a.getAllItems(),ob(e,function(a,b){return(a.options&&a.options.legendIndex||0)-(b.options&&b.options.legendIndex||0)}),j.reversed&&e.reverse(),a.allItems=e,a.display=f=!!e.length,p(e,function(b){a.renderItem(b)}),g=j.width||a.offsetWidth,h=a.lastItemY+a.lastLineHeight+a.titleHeight,h=a.handleOverflow(h),(l||o)&&(g+=k,h+=k,i?g>0&&h>0&&(i[i.isNew?"attr":"animate"](i.crisp({width:g,height:h})),i.isNew=!1):(a.box=i=c.rect(0,0,g,h,j.borderRadius,l||0).attr({stroke:j.borderColor,"stroke-width":l||0,fill:o||Q}).add(d).shadow(j.shadow),i.isNew=!0),i[f?"show":"hide"]()),a.legendWidth=g,a.legendHeight=h,p(e,function(b){a.positionItem(b)}),f&&d.align(q({width:g,height:h},j),!0,"spacingBox"),b.isResizing||this.positionCheckboxes()},handleOverflow:function(a){var h,s,b=this,c=this.chart,d=c.renderer,e=this.options,f=e.y,f=c.spacingBox.height+("top"===e.verticalAlign?-f:f)-this.padding,g=e.maxHeight,i=this.clipRect,j=e.navigation,k=m(j.animation,!0),l=j.arrowSize||12,o=this.nav,n=this.pages,q=this.allItems;return"horizontal"===e.layout&&(f/=2),g&&(f=C(f,g)),n.length=0,a>f&&!e.useHTML?(this.clipHeight=h=f-20-this.titleHeight-this.padding,this.currentPage=m(this.currentPage,1),this.fullHeight=a,p(q,function(a,b){var c=a._legendItemPos[1],d=u(a.legendItem.getBBox().height),e=n.length;(!e||c-n[e-1]>h&&(s||c)!==n[e-1])&&(n.push(s||c),e++),b===q.length-1&&c+d-n[e-1]>h&&n.push(c),c!==s&&(s=c)}),i||(i=b.clipRect=d.clipRect(0,this.padding,9999,0),b.contentGroup.clip(i)),i.attr({height:h}),o||(this.nav=o=d.g().attr({zIndex:1}).add(this.group),this.up=d.symbol("triangle",0,0,l,l).on("click",function(){b.scroll(-1,k)}).add(o),this.pager=d.text("",15,10).css(j.style).add(o),this.down=d.symbol("triangle-down",0,0,l,l).on("click",function(){b.scroll(1,k)}).add(o)),b.scroll(0),a=f):o&&(i.attr({height:c.chartHeight}),o.hide(),this.scrollGroup.attr({translateY:1}),this.clipHeight=0),a},scroll:function(a,b){var c=this.pages,d=c.length,e=this.currentPage+a,f=this.clipHeight,g=this.options.navigation,h=g.activeColor,g=g.inactiveColor,i=this.pager,j=this.padding;e>d&&(e=d),e>0&&(b!==t&&Qa(b,this.chart),this.nav.attr({translateX:j,translateY:f+this.padding+7+this.titleHeight,visibility:"visible"}),this.up.attr({fill:1===e?g:h}).css({cursor:1===e?"default":"pointer"}),i.attr({text:e+"/"+d}),this.down.attr({x:18+this.pager.getBBox().width,fill:e===d?g:h}).css({cursor:e===d?"default":"pointer"}),c=-c[e-1]+this.initialItemY,this.scrollGroup.animate({translateY:c}),this.currentPage=e,this.positionCheckboxes(c))}},N=R.LegendSymbolMixin={drawRectangle:function(a,b){var c=a.options.symbolHeight||12;b.legendSymbol=this.chart.renderer.rect(0,a.baseline-5-c/2,a.symbolWidth,c,a.options.symbolRadius||0).attr({zIndex:3}).add(b.legendGroup)},drawLineMarker:function(a){var d,b=this.options,c=b.marker;d=a.symbolWidth;var g,e=this.chart.renderer,f=this.legendGroup,a=a.baseline-u(.3*e.fontMetrics(a.options.itemStyle.fontSize).b);b.lineWidth&&(g={"stroke-width":b.lineWidth},b.dashStyle&&(g.dashstyle=b.dashStyle),this.legendLine=e.path(["M",0,a,"L",d,a]).attr(g).add(f)),c&&c.enabled!==!1&&(b=c.radius,this.legendSymbol=d=e.symbol(this.symbol,d/2-b,a-b,2*b,2*b).add(f),d.isMarker=!0)}},(/Trident\/7\.0/.test(wa)||Ta)&&Ma(lb.prototype,"positionItem",function(a,b){var c=this,d=function(){b._legendItemPos&&a.call(c,b)};d(),setTimeout(d)}),Ya.prototype={init:function(a,b){var c,d=a.series;a.series=null,c=w(E,a),c.series=a.series=d,this.userOptions=a,d=c.chart,this.margin=this.splashArray("margin",d),this.spacing=this.splashArray("spacing",d);var e=d.events;this.bounds={h:{},v:{}},this.callback=b,this.isResizing=0,this.options=c,this.axes=[],this.series=[],this.hasCartesianSeries=d.showAxes;var g,f=this;if(f.index=V.length,V.push(f),ab++,d.reflow!==!1&&K(f,"load",function(){f.initReflow()}),e)for(g in e)K(f,g,e[g]);f.xAxis=[],f.yAxis=[],f.animation=fa?!1:m(d.animation,!0),f.pointCount=0,f.counters=new Bb,f.firstRender()},initSeries:function(a){var b=this.options.chart;return(b=F[a.type||b.type||b.defaultSeriesType])||ra(17,!0),b=new b,b.init(this,a),b},isInsidePlot:function(a,b,c){var d=c?b:a,a=c?a:b;return d>=0&&d<=this.plotWidth&&a>=0&&a<=this.plotHeight},adjustTickAmounts:function(){this.options.chart.alignTicks!==!1&&p(this.axes,function(a){a.adjustTickAmount()}),this.maxTicks=null},redraw:function(a){var g,h,b=this.axes,c=this.series,d=this.pointer,e=this.legend,f=this.isDirtyLegend,i=this.isDirtyBox,j=c.length,k=j,l=this.renderer,o=l.isHidden(),n=[];for(Qa(a,this),o&&this.cloneRenderTo(),this.layOutTitles();k--;)if(a=c[k],a.options.stacking&&(g=!0,a.isDirty)){h=!0;break}if(h)for(k=j;k--;)a=c[k],a.options.stacking&&(a.isDirty=!0);p(c,function(a){a.isDirty&&"point"===a.options.legendType&&(f=!0)}),f&&e.options.enabled&&(e.render(),this.isDirtyLegend=!1),g&&this.getStacks(),this.hasCartesianSeries&&(this.isResizing||(this.maxTicks=null,p(b,function(a){a.setScale()})),this.adjustTickAmounts(),this.getMargins(),p(b,function(a){a.isDirty&&(i=!0)}),p(b,function(a){a.isDirtyExtremes&&(a.isDirtyExtremes=!1,n.push(function(){D(a,"afterSetExtremes",q(a.eventArgs,a.getExtremes())),delete a.eventArgs})),(i||g)&&a.redraw()})),i&&this.drawChartBox(),p(c,function(a){a.isDirty&&a.visible&&(!a.isCartesian||a.xAxis)&&a.redraw()}),d&&d.reset(!0),l.draw(),D(this,"redraw"),o&&this.cloneRenderTo(!0),p(n,function(a){a.call()})},get:function(a){var d,e,b=this.axes,c=this.series;for(d=0;d<b.length;d++)if(b[d].options.id===a)return b[d];for(d=0;d<c.length;d++)if(c[d].options.id===a)return c[d];for(d=0;d<c.length;d++)for(e=c[d].points||[],b=0;b<e.length;b++)if(e[b].id===a)return e[b];return null},getAxes:function(){var a=this,b=this.options,c=b.xAxis=qa(b.xAxis||{}),b=b.yAxis=qa(b.yAxis||{});p(c,function(a,b){a.index=b,a.isX=!0}),p(b,function(a,b){a.index=b}),c=c.concat(b),p(c,function(b){new la(a,b)}),a.adjustTickAmounts()},getSelectedPoints:function(){var a=[];return p(this.series,function(b){a=a.concat(vb(b.points||[],function(a){return a.selected}))}),a},getSelectedSeries:function(){return vb(this.series,function(a){return a.selected})},getStacks:function(){var a=this;p(a.yAxis,function(a){a.stacks&&a.hasVisibleSeries&&(a.oldStacks=a.stacks)}),p(a.series,function(b){!b.options.stacking||b.visible!==!0&&a.options.chart.ignoreHiddenSeries!==!1||(b.stackKey=b.type+m(b.options.stack,""))})},setTitle:function(a,b,c){var g,f,d=this,e=d.options;f=e.title=w(e.title,a),g=e.subtitle=w(e.subtitle,b),e=g,p([["title",a,f],["subtitle",b,e]],function(a){var b=a[0],c=d[b],e=a[1],a=a[2];c&&e&&(d[b]=c=c.destroy()),a&&a.text&&!c&&(d[b]=d.renderer.text(a.text,0,0,a.useHTML).attr({align:a.align,"class":"highcharts-"+b,zIndex:a.zIndex||4}).css(a.style).add())}),d.layOutTitles(c)},layOutTitles:function(a){var b=0,c=this.title,d=this.subtitle,e=this.options,f=e.title,e=e.subtitle,g=this.spacingBox.width-44;!c||(c.css({width:(f.width||g)+"px"}).align(q({y:15},f),!1,"spacingBox"),f.floating||f.verticalAlign)||(b=c.getBBox().height),d&&(d.css({width:(e.width||g)+"px"}).align(q({y:b+f.margin},e),!1,"spacingBox"),!e.floating&&!e.verticalAlign&&(b=Ka(b+d.getBBox().height))),c=this.titleOffset!==b,this.titleOffset=b,!this.isDirtyBox&&c&&(this.isDirtyBox=c,this.hasRendered&&m(a,!0)&&this.isDirtyBox&&this.redraw())},getChartSize:function(){var a=this.options.chart,b=a.width,a=a.height,c=this.renderToClone||this.renderTo;r(b)||(this.containerWidth=jb(c,"width")),r(a)||(this.containerHeight=jb(c,"height")),this.chartWidth=v(0,b||this.containerWidth||600),this.chartHeight=v(0,m(a,this.containerHeight>19?this.containerHeight:400))},cloneRenderTo:function(a){var b=this.renderToClone,c=this.container;a?b&&(this.renderTo.appendChild(c),Pa(b),delete this.renderToClone):(c&&c.parentNode===this.renderTo&&this.renderTo.removeChild(c),this.renderToClone=b=this.renderTo.cloneNode(0),G(b,{position:"absolute",top:"-9999px",display:"block"}),b.style.setProperty&&b.style.setProperty("display","block","important"),y.body.appendChild(b),c&&b.appendChild(c))
|
4 |
},getContainer:function(){var a,c,d,e,b=this.options.chart;this.renderTo=a=b.renderTo,e="highcharts-"+tb++,Fa(a)&&(this.renderTo=a=y.getElementById(a)),a||ra(13,!0),c=z(H(a,"data-highcharts-chart")),!isNaN(c)&&V[c]&&V[c].hasRendered&&V[c].destroy(),H(a,"data-highcharts-chart",this.index),a.innerHTML="",!b.skipClone&&!a.offsetWidth&&this.cloneRenderTo(),this.getChartSize(),c=this.chartWidth,d=this.chartHeight,this.container=a=Y(Ja,{className:"highcharts-container"+(b.className?" "+b.className:""),id:e},q({position:"relative",overflow:"hidden",width:c+"px",height:d+"px",textAlign:"left",lineHeight:"normal",zIndex:0,"-webkit-tap-highlight-color":"rgba(0,0,0,0)"},b.style),this.renderToClone||a),this._cursor=a.style.cursor,this.renderer=b.forExport?new ta(a,c,d,b.style,!0):new Za(a,c,d,b.style),fa&&this.renderer.create(this,a,c,d)},getMargins:function(){var b,a=this.spacing,c=this.legend,d=this.margin,e=this.options.legend,f=m(e.margin,20),g=e.x,h=e.y,i=e.align,j=e.verticalAlign,k=this.titleOffset;this.resetMargins(),b=this.axisOffset,k&&!r(d[0])&&(this.plotTop=v(this.plotTop,k+this.options.title.margin+a[0])),c.display&&!e.floating&&("right"===i?r(d[1])||(this.marginRight=v(this.marginRight,c.legendWidth-g+f+a[1])):"left"===i?r(d[3])||(this.plotLeft=v(this.plotLeft,c.legendWidth+g+f+a[3])):"top"===j?r(d[0])||(this.plotTop=v(this.plotTop,c.legendHeight+h+f+a[0])):"bottom"!==j||r(d[2])||(this.marginBottom=v(this.marginBottom,c.legendHeight-h+f+a[2]))),this.extraBottomMargin&&(this.marginBottom+=this.extraBottomMargin),this.extraTopMargin&&(this.plotTop+=this.extraTopMargin),this.hasCartesianSeries&&p(this.axes,function(a){a.getOffset()}),r(d[3])||(this.plotLeft+=b[3]),r(d[0])||(this.plotTop+=b[0]),r(d[2])||(this.marginBottom+=b[2]),r(d[1])||(this.marginRight+=b[1]),this.setChartSize()},reflow:function(a){var b=this,c=b.options.chart,d=b.renderTo,e=c.width||jb(d,"width"),f=c.height||jb(d,"height"),c=a?a.target:I,d=function(){b.container&&(b.setSize(e,f,!1),b.hasUserSize=null)};b.hasUserSize||!e||!f||c!==I&&c!==y||((e!==b.containerWidth||f!==b.containerHeight)&&(clearTimeout(b.reflowTimeout),a?b.reflowTimeout=setTimeout(d,100):d()),b.containerWidth=e,b.containerHeight=f)},initReflow:function(){var a=this,b=function(b){a.reflow(b)};K(I,"resize",b),K(a,"destroy",function(){W(I,"resize",b)})},setSize:function(a,b,c){var e,f,g,d=this;d.isResizing+=1,g=function(){d&&D(d,"endResize",null,function(){d.isResizing-=1})},Qa(c,d),d.oldChartHeight=d.chartHeight,d.oldChartWidth=d.chartWidth,r(a)&&(d.chartWidth=e=v(0,u(a)),d.hasUserSize=!!e),r(b)&&(d.chartHeight=f=v(0,u(b))),(va?kb:G)(d.container,{width:e+"px",height:f+"px"},va),d.setChartSize(!0),d.renderer.setSize(e,f,c),d.maxTicks=null,p(d.axes,function(a){a.isDirty=!0,a.setScale()}),p(d.series,function(a){a.isDirty=!0}),d.isDirtyLegend=!0,d.isDirtyBox=!0,d.layOutTitles(),d.getMargins(),d.redraw(c),d.oldChartHeight=null,D(d,"resize"),va===!1?g():setTimeout(g,va&&va.duration||500)},setChartSize:function(a){var i,j,k,l,b=this.inverted,c=this.renderer,d=this.chartWidth,e=this.chartHeight,f=this.options.chart,g=this.spacing,h=this.clipOffset;this.plotLeft=i=u(this.plotLeft),this.plotTop=j=u(this.plotTop),this.plotWidth=k=v(0,u(d-i-this.marginRight)),this.plotHeight=l=v(0,u(e-j-this.marginBottom)),this.plotSizeX=b?l:k,this.plotSizeY=b?k:l,this.plotBorderWidth=f.plotBorderWidth||0,this.spacingBox=c.spacingBox={x:g[3],y:g[0],width:d-g[3]-g[1],height:e-g[0]-g[2]},this.plotBox=c.plotBox={x:i,y:j,width:k,height:l},d=2*T(this.plotBorderWidth/2),b=Ka(v(d,h[3])/2),c=Ka(v(d,h[0])/2),this.clipBox={x:b,y:c,width:T(this.plotSizeX-v(d,h[1])/2-b),height:T(this.plotSizeY-v(d,h[2])/2-c)},a||p(this.axes,function(a){a.setAxisSize(),a.setAxisTranslation()})},resetMargins:function(){var a=this.spacing,b=this.margin;this.plotTop=m(b[0],a[0]),this.marginRight=m(b[1],a[1]),this.marginBottom=m(b[2],a[2]),this.plotLeft=m(b[3],a[3]),this.axisOffset=[0,0,0,0],this.clipOffset=[0,0,0,0]},drawChartBox:function(){var n,a=this.options.chart,b=this.renderer,c=this.chartWidth,d=this.chartHeight,e=this.chartBackground,f=this.plotBackground,g=this.plotBorder,h=this.plotBGImage,i=a.borderWidth||0,j=a.backgroundColor,k=a.plotBackgroundColor,l=a.plotBackgroundImage,o=a.plotBorderWidth||0,s=this.plotLeft,m=this.plotTop,p=this.plotWidth,q=this.plotHeight,r=this.plotBox,v=this.clipRect,u=this.clipBox;n=i+(a.shadow?8:0),(i||j)&&(e?e.animate(e.crisp({width:c-n,height:d-n})):(e={fill:j||Q},i&&(e.stroke=a.borderColor,e["stroke-width"]=i),this.chartBackground=b.rect(n/2,n/2,c-n,d-n,a.borderRadius,i).attr(e).addClass("highcharts-background").add().shadow(a.shadow))),k&&(f?f.animate(r):this.plotBackground=b.rect(s,m,p,q,0).attr({fill:k}).add().shadow(a.plotShadow)),l&&(h?h.animate(r):this.plotBGImage=b.image(l,s,m,p,q).add()),v?v.animate({width:u.width,height:u.height}):this.clipRect=b.clipRect(u),o&&(g?g.animate(g.crisp({x:s,y:m,width:p,height:q})):this.plotBorder=b.rect(s,m,p,q,0,-o).attr({stroke:a.plotBorderColor,"stroke-width":o,fill:Q,zIndex:1}).add()),this.isDirtyBox=!1},propFromSeries:function(){var c,e,f,a=this,b=a.options.chart,d=a.options.series;p(["inverted","angular","polar"],function(g){for(c=F[b.type||b.defaultSeriesType],f=a[g]||b[g]||c&&c.prototype[g],e=d&&d.length;!f&&e--;)(c=F[d[e].type])&&c.prototype[g]&&(f=!0);a[g]=f})},linkSeries:function(){var a=this,b=a.series;p(b,function(a){a.linkedSeries.length=0}),p(b,function(b){var d=b.options.linkedTo;Fa(d)&&(d=":previous"===d?a.series[b.index-1]:a.get(d))&&(d.linkedSeries.push(b),b.linkedParent=d)})},renderSeries:function(){p(this.series,function(a){a.translate(),a.setTooltipPoints&&a.setTooltipPoints(),a.render()})},render:function(){var g,a=this,b=a.axes,c=a.renderer,d=a.options,e=d.labels,f=d.credits;a.setTitle(),a.legend=new lb(a,d.legend),a.getStacks(),p(b,function(a){a.setScale()}),a.getMargins(),a.maxTicks=null,p(b,function(a){a.setTickPositions(!0),a.setMaxTicks()}),a.adjustTickAmounts(),a.getMargins(),a.drawChartBox(),a.hasCartesianSeries&&p(b,function(a){a.render()}),a.seriesGroup||(a.seriesGroup=c.g("series-group").attr({zIndex:3}).add()),a.renderSeries(),e.items&&p(e.items,function(b){var d=q(e.style,b.style),f=z(d.left)+a.plotLeft,g=z(d.top)+a.plotTop+12;delete d.left,delete d.top,c.text(b.html,f,g).attr({zIndex:2}).css(d).add()}),f.enabled&&!a.credits&&(g=f.href,a.credits=c.text(f.text,0,0).on("click",function(){g&&(location.href=g)}).attr({align:f.position.align,zIndex:8}).css(f.style).add().align(f.position)),a.hasRendered=!0},destroy:function(){var e,a=this,b=a.axes,c=a.series,d=a.container,f=d&&d.parentNode;for(D(a,"destroy"),V[a.index]=t,ab--,a.renderTo.removeAttribute("data-highcharts-chart"),W(a),e=b.length;e--;)b[e]=b[e].destroy();for(e=c.length;e--;)c[e]=c[e].destroy();p("title,subtitle,chartBackground,plotBackground,plotBGImage,plotBorder,seriesGroup,clipRect,credits,pointer,scroller,rangeSelector,legend,resetZoomButton,tooltip,renderer".split(","),function(b){var c=a[b];c&&c.destroy&&(a[b]=c.destroy())}),d&&(d.innerHTML="",W(d),f&&Pa(d));for(e in a)delete a[e]},isReadyToRender:function(){var a=this;return!aa&&I==I.top&&"complete"!==y.readyState||fa&&!I.canvg?(fa?Lb.push(function(){a.firstRender()},a.options.global.canvasToolsURL):y.attachEvent("onreadystatechange",function(){y.detachEvent("onreadystatechange",a.firstRender),"complete"===y.readyState&&a.firstRender()}),!1):!0},firstRender:function(){var a=this,b=a.options,c=a.callback;a.isReadyToRender()&&(a.getContainer(),D(a,"init"),a.resetMargins(),a.setChartSize(),a.propFromSeries(),a.getAxes(),p(b.series||[],function(b){a.initSeries(b)}),a.linkSeries(),D(a,"beforeRender"),R.Pointer&&(a.pointer=new Wa(a,b)),a.render(),a.renderer.draw(),c&&c.apply(a,[a]),p(a.callbacks,function(b){b.apply(a,[a])}),a.cloneRenderTo(!0),D(a,"load"))},splashArray:function(a,b){var c=b[a],c=ca(c)?c:[c,c,c,c];return[m(b[a+"Top"],c[0]),m(b[a+"Right"],c[1]),m(b[a+"Bottom"],c[2]),m(b[a+"Left"],c[3])]}},Ya.prototype.callbacks=[],X=R.CenteredSeriesMixin={getCenter:function(){var d,h,a=this.options,b=this.chart,c=2*(a.slicedOffset||0),e=b.plotWidth-2*c,f=b.plotHeight-2*c,b=a.center,a=[m(b[0],"50%"),m(b[1],"50%"),a.size||"100%",a.innerSize||0],g=C(e,f);return Ua(a,function(a,b){return h=/%$/.test(a),d=2>b||2===b&&h,(h?[e,f,g,g][b]*z(a)/100:a)+(d?c:0)})}};var Ea=function(){};Ea.prototype={init:function(a,b,c){return this.series=a,this.applyOptions(b,c),this.pointAttr={},a.options.colorByPoint&&(b=a.options.colors||a.chart.options.colors,this.color=this.color||b[a.colorCounter++],a.colorCounter===b.length)&&(a.colorCounter=0),a.chart.pointCount++,this},applyOptions:function(a,b){var c=this.series,d=c.pointValKey,a=Ea.prototype.optionsToObject.call(this,a);return q(this,a),this.options=this.options?q(this.options,a):a,d&&(this.y=this[d]),this.x===t&&c&&(this.x=b===t?c.autoIncrement():b),this},optionsToObject:function(a){var b={},c=this.series,d=c.pointArrayMap||["y"],e=d.length,f=0,g=0;if("number"==typeof a||null===a)b[d[0]]=a;else if(La(a))for(a.length>e&&(c=typeof a[0],"string"===c?b.name=a[0]:"number"===c&&(b.x=a[0]),f++);e>g;)b[d[g++]]=a[f++];else"object"==typeof a&&(b=a,a.dataLabels&&(c._hasPointLabels=!0),a.marker&&(c._hasPointMarkers=!0));return b},destroy:function(){var c,a=this.series.chart,b=a.hoverPoints;a.pointCount--,b&&(this.setState(),ja(b,this),!b.length)&&(a.hoverPoints=null),this===a.hoverPoint&&this.onMouseOut(),(this.graphic||this.dataLabel)&&(W(this),this.destroyElements()),this.legendItem&&a.legend.destroyItem(this);for(c in this)this[c]=null},destroyElements:function(){for(var b,a="graphic,dataLabel,dataLabelUpper,group,connector,shadowGroup".split(","),c=6;c--;)b=a[c],this[b]&&(this[b]=this[b].destroy())},getLabelConfig:function(){return{x:this.category,y:this.y,key:this.name||this.category,series:this.series,point:this,percentage:this.percentage,total:this.total||this.stackTotal}},tooltipFormatter:function(a){var b=this.series,c=b.tooltipOptions,d=m(c.valueDecimals,""),e=c.valuePrefix||"",f=c.valueSuffix||"";return p(b.pointArrayMap||["y"],function(b){b="{point."+b,(e||f)&&(a=a.replace(b+"}",e+b+"}"+f)),a=a.replace(b+"}",b+":,."+d+"f}")}),Ia(a,{point:this,series:this.series})},firePointEvent:function(a,b,c){var d=this,e=this.series.options;(e.point.events[a]||d.options&&d.options.events&&d.options.events[a])&&this.importEvents(),"click"===a&&e.allowPointSelect&&(c=function(a){d.select(null,a.ctrlKey||a.metaKey||a.shiftKey)}),D(this,a,b,c)}};var O=function(){};O.prototype={isCartesian:!0,type:"line",pointClass:Ea,sorted:!0,requireSorting:!0,pointAttrToOptions:{stroke:"lineColor","stroke-width":"lineWidth",fill:"fillColor",r:"radius"},axisTypes:["xAxis","yAxis"],colorCounter:0,parallelArrays:["x","y"],init:function(a,b){var d,e,c=this,f=a.series,g=function(a,b){return m(a.options.index,a._i)-m(b.options.index,b._i)};c.chart=a,c.options=b=c.setOptions(b),c.linkedSeries=[],c.bindAxes(),q(c,{name:b.name,state:"",pointAttr:{},visible:b.visible!==!1,selected:b.selected===!0}),fa&&(b.animation=!1),e=b.events;for(d in e)K(c,d,e[d]);(e&&e.click||b.point&&b.point.events&&b.point.events.click||b.allowPointSelect)&&(a.runTrackerClick=!0),c.getColor(),c.getSymbol(),p(c.parallelArrays,function(a){c[a+"Data"]=[]}),c.setData(b.data,!1),c.isCartesian&&(a.hasCartesianSeries=!0),f.push(c),c._i=f.length-1,ob(f,g),this.yAxis&&ob(this.yAxis.series,g),p(f,function(a,b){a.index=b,a.name=a.name||"Series "+(b+1)})},bindAxes:function(){var d,a=this,b=a.options,c=a.chart;p(a.axisTypes||[],function(e){p(c[e],function(c){d=c.options,(b[e]===d.index||b[e]!==t&&b[e]===d.id||b[e]===t&&0===d.index)&&(c.series.push(a),a[e]=c,c.isDirty=!0)}),!a[e]&&a.optionalAxis!==e&&ra(18,!0)})},updateParallelArrays:function(a,b){var c=a.series,d=arguments;p(c.parallelArrays,"number"==typeof b?function(d){var f="y"===d&&c.toYData?c.toYData(a):a[d];c[d+"Data"][b]=f}:function(a){Array.prototype[b].apply(c[a+"Data"],Array.prototype.slice.call(d,2))})},autoIncrement:function(){var a=this.options,b=this.xIncrement,b=m(b,a.pointStart,0);return this.pointInterval=m(this.pointInterval,a.pointInterval,1),this.xIncrement=b+this.pointInterval,b},getSegments:function(){var c,a=-1,b=[],d=this.points,e=d.length;if(e)if(this.options.connectNulls){for(c=e;c--;)null===d[c].y&&d.splice(c,1);d.length&&(b=[d])}else p(d,function(c,g){null===c.y?(g>a+1&&b.push(d.slice(a+1,g)),a=g):g===e-1&&b.push(d.slice(a+1,g+1))});this.segments=b},setOptions:function(a){var b=this.chart,c=b.options.plotOptions,b=b.userOptions||{},d=b.plotOptions||{},e=c[this.type];return this.userOptions=a,c=w(e,c.series,a),this.tooltipOptions=w(E.tooltip,E.plotOptions[this.type].tooltip,b.tooltip,d.series&&d.series.tooltip,d[this.type]&&d[this.type].tooltip,a.tooltip),null===e.marker&&delete c.marker,c},getColor:function(){var e,a=this.options,b=this.userOptions,c=this.chart.options.colors,d=this.chart.counters;e=a.color||ba[this.type].color,e||a.colorByPoint||(r(b._colorIndex)?a=b._colorIndex:(b._colorIndex=d.color,a=d.color++),e=c[a]),this.color=e,d.wrapColor(c.length)},getSymbol:function(){var a=this.userOptions,b=this.options.marker,c=this.chart,d=c.options.symbols,c=c.counters;this.symbol=b.symbol,this.symbol||(r(a._symbolIndex)?a=a._symbolIndex:(a._symbolIndex=c.symbol,a=c.symbol++),this.symbol=d[a]),/^url/.test(this.symbol)&&(b.radius=0),c.wrapSymbol(d.length)},drawLegendSymbol:N.drawLineMarker,setData:function(a,b,c,d){var h,e=this,f=e.points,g=f&&f.length||0,i=e.options,j=e.chart,k=null,l=e.xAxis,o=l&&!!l.categories,n=e.tooltipPoints,s=i.turboThreshold,q=this.xData,r=this.yData,v=(h=e.pointArrayMap)&&h.length,a=a||[];if(h=a.length,b=m(b,!0),d===!1||!h||g!==h||e.cropped||e.hasGroupedData){if(e.xIncrement=null,e.pointRange=o?1:i.pointRange,e.colorCounter=0,p(this.parallelArrays,function(a){e[a+"Data"].length=0}),s&&h>s){for(c=0;null===k&&h>c;)k=a[c],c++;if(ha(k)){for(o=m(i.pointStart,0),i=m(i.pointInterval,1),c=0;h>c;c++)q[c]=o,r[c]=a[c],o+=i;e.xIncrement=o}else if(La(k))if(v)for(c=0;h>c;c++)i=a[c],q[c]=i[0],r[c]=i.slice(1,v+1);else for(c=0;h>c;c++)i=a[c],q[c]=i[0],r[c]=i[1];else ra(12)}else for(c=0;h>c;c++)a[c]!==t&&(i={series:e},e.pointClass.prototype.applyOptions.apply(i,[a[c]]),e.updateParallelArrays(i,c),o&&i.name)&&(l.names[i.x]=i.name);for(Fa(r[0])&&ra(14,!0),e.data=[],e.options.data=a,c=g;c--;)f[c]&&f[c].destroy&&f[c].destroy();n&&(n.length=0),l&&(l.minRange=l.userMinRange),e.isDirty=e.isDirtyData=j.isDirtyBox=!0,c=!1}else p(a,function(a,b){f[b].update(a,!1)});b&&j.redraw(c)},processData:function(a){var e,b=this.xData,c=this.yData,d=b.length;e=0;var f,g,o,n,h=this.xAxis,i=this.options,j=i.cropThreshold,k=0,l=this.isCartesian;if(l&&!this.isDirty&&!h.isDirty&&!this.yAxis.isDirty&&!a)return!1;for(l&&this.sorted&&(!j||d>j||this.forceCrop)&&(o=h.min,n=h.max,b[d-1]<o||b[0]>n?(b=[],c=[]):(b[0]<o||b[d-1]>n)&&(e=this.cropData(this.xData,this.yData,o,n),b=e.xData,c=e.yData,e=e.start,f=!0,k=b.length)),d=b.length-1;d>=0;d--)a=b[d]-b[d-1],!f&&b[d]>o&&b[d]<n&&k++,a>0&&(g===t||g>a)?g=a:0>a&&this.requireSorting&&ra(15);this.cropped=f,this.cropStart=e,this.processedXData=b,this.processedYData=c,this.activePointCount=k,null===i.pointRange&&(this.pointRange=g||1),this.closestPointRange=g},cropData:function(a,b,c,d){var i,e=a.length,f=0,g=e,h=m(this.cropShoulder,1);for(i=0;e>i;i++)if(a[i]>=c){f=v(0,i-h);break}for(;e>i;i++)if(a[i]>d){g=i+h;break}return{xData:a.slice(f,g),yData:b.slice(f,g),start:f,end:g}},generatePoints:function(){var c,i,k,o,a=this.options.data,b=this.data,d=this.processedXData,e=this.processedYData,f=this.pointClass,g=d.length,h=this.cropStart||0,j=this.hasGroupedData,l=[];for(b||j||(b=[],b.length=a.length,b=this.data=b),o=0;g>o;o++)i=h+o,j?l[o]=(new f).init(this,[d[o]].concat(qa(e[o]))):(b[i]?k=b[i]:a[i]!==t&&(b[i]=k=(new f).init(this,a[i],d[o])),l[o]=k);if(b&&(g!==(c=b.length)||j))for(o=0;c>o;o++)o===h&&!j&&(o+=g),b[o]&&(b[o].destroyElements(),b[o].plotX=t);this.data=b,this.points=l},getExtremes:function(a){var d,b=this.yAxis,c=this.processedXData,e=[],f=0;d=this.xAxis.getExtremes();var i,j,k,l,g=d.min,h=d.max,a=a||this.stackedYData||this.processedYData;for(d=a.length,l=0;d>l;l++)if(j=c[l],k=a[l],i=null!==k&&k!==t&&(!b.isLog||k.length||k>0),j=this.getExtremesFromAll||this.cropped||(c[l+1]||j)>=g&&(c[l-1]||j)<=h,i&&j)if(i=k.length)for(;i--;)null!==k[i]&&(e[f++]=k[i]);else e[f++]=k;this.dataMin=m(void 0,Na(e)),this.dataMax=m(void 0,Ba(e))},translate:function(){this.processedXData||this.processData(),this.generatePoints();for(var a=this.options,b=a.stacking,c=this.xAxis,d=c.categories,e=this.yAxis,f=this.points,g=f.length,h=!!this.modifyValue,i=a.pointPlacement,j="between"===i||ha(i),k=a.threshold,a=0;g>a;a++){var l=f[a],o=l.x,n=l.y,s=l.low,p=b&&e.stacks[(this.negStacks&&k>n?"-":"")+this.stackKey];e.isLog&&0>=n&&(l.y=n=null),l.plotX=c.translate(o,0,0,0,1,i,"flags"===this.type),b&&this.visible&&p&&p[o]&&(p=p[o],n=p.points[this.index+","+a],s=n[0],n=n[1],0===s&&(s=m(k,e.min)),e.isLog&&0>=s&&(s=null),l.total=l.stackTotal=p.total,l.percentage=p.total&&l.y/p.total*100,l.stackY=n,p.setOffset(this.pointXOffset||0,this.barW||0)),l.yBottom=r(s)?e.translate(s,0,1,0,1):null,h&&(n=this.modifyValue(n,l)),l.plotY="number"==typeof n&&1/0!==n?e.translate(n,0,1,0,1):t,l.clientX=j?c.translate(o,0,0,0,1):l.plotX,l.negative=l.y<(k||0),l.category=d&&d[l.x]!==t?d[l.x]:l.x}this.getSegments()},animate:function(a){var d,b=this.chart,c=b.renderer;d=this.options.animation;var g,e=this.clipBox||b.clipBox,f=b.inverted;d&&!ca(d)&&(d=ba[this.type].animation),g=["_sharedClip",d.duration,d.easing,e.height].join(","),a?(a=b[g],d=b[g+"m"],a||(b[g]=a=c.clipRect(q(e,{width:0})),b[g+"m"]=d=c.clipRect(-99,f?-b.plotLeft:-b.plotTop,99,f?b.chartWidth:b.chartHeight)),this.group.clip(a),this.markerGroup.clip(d),this.sharedClipKey=g):((a=b[g])&&a.animate({width:b.plotSizeX},d),b[g+"m"]&&b[g+"m"].animate({width:b.plotSizeX+99},d),this.animate=null)},afterAnimate:function(){var a=this.chart,b=this.sharedClipKey,c=this.group,d=this.clipBox;c&&this.options.clip!==!1&&(b&&d||c.clip(d?a.renderer.clipRect(d):a.clipRect),this.markerGroup.clip()),D(this,"afterAnimate"),setTimeout(function(){b&&a[b]&&(d||(a[b]=a[b].destroy()),a[b+"m"]&&(a[b+"m"]=a[b+"m"].destroy()))},100)},drawPoints:function(){var a,d,e,f,g,h,i,j,k,b=this.points,c=this.chart;d=this.options.marker;var o,l=this.pointAttr[""],n=this.markerGroup,s=m(d.enabled,this.activePointCount<.5*this.xAxis.len/d.radius);if(d.enabled!==!1||this._hasPointMarkers)for(f=b.length;f--;)g=b[f],d=T(g.plotX),e=g.plotY,k=g.graphic,i=g.marker||{},a=s&&i.enabled===t||i.enabled,o=c.isInsidePlot(u(d),e,c.inverted),a&&e!==t&&!isNaN(e)&&null!==g.y?(a=g.pointAttr[g.selected?"select":""]||l,h=a.r,i=m(i.symbol,this.symbol),j=0===i.indexOf("url"),k?k[o?"show":"hide"](!0).animate(q({x:d-h,y:e-h},k.symbolName?{width:2*h,height:2*h}:{})):o&&(h>0||j)&&(g.graphic=c.renderer.symbol(i,d-h,e-h,2*h,2*h).attr(a).add(n))):k&&(g.graphic=k.destroy())},convertAttribs:function(a,b,c,d){var f,g,e=this.pointAttrToOptions,h={},a=a||{},b=b||{},c=c||{},d=d||{};for(f in e)g=e[f],h[f]=m(a[g],b[f],c[f],d[f]);return h},getAttribs:function(){var f,a=this,b=a.options,c=ba[a.type].marker?b.marker:b,d=c.states,e=d.hover,g=a.color;f={stroke:g,fill:g};var i,k,h=a.points||[],j=[],l=a.pointAttrToOptions;k=a.hasPointSpecificOptions;var o=b.negativeColor,n=c.lineColor,s=c.fillColor;i=b.turboThreshold;var m;if(b.marker?(e.radius=e.radius||c.radius+2,e.lineWidth=e.lineWidth||c.lineWidth+1):e.color=e.color||ya(e.color||g).brighten(e.brightness).get(),j[""]=a.convertAttribs(c,f),p(["hover","select"],function(b){j[b]=a.convertAttribs(d[b],j[""])}),a.pointAttr=j,g=h.length,!i||i>g||k)for(;g--;){if(i=h[g],(c=i.options&&i.options.marker||i.options)&&c.enabled===!1&&(c.radius=0),i.negative&&o&&(i.color=i.fillColor=o),k=b.colorByPoint||i.color,i.options)for(m in l)r(c[l[m]])&&(k=!0);k?(c=c||{},k=[],d=c.states||{},f=d.hover=d.hover||{},b.marker||(f.color=f.color||!i.options.color&&e.color||ya(i.color).brighten(f.brightness||e.brightness).get()),f={color:i.color},s||(f.fillColor=i.color),n||(f.lineColor=i.color),k[""]=a.convertAttribs(q(f,c),j[""]),k.hover=a.convertAttribs(d.hover,j.hover,k[""]),k.select=a.convertAttribs(d.select,j.select,k[""])):k=j,i.pointAttr=k}},destroy:function(){var d,e,g,h,i,a=this,b=a.chart,c=/AppleWebKit\/533/.test(wa),f=a.data||[];for(D(a,"destroy"),W(a),p(a.axisTypes||[],function(b){(i=a[b])&&(ja(i.series,a),i.isDirty=i.forceRedraw=!0)}),a.legendItem&&a.chart.legend.destroyItem(a),e=f.length;e--;)(g=f[e])&&g.destroy&&g.destroy();a.points=null,clearTimeout(a.animationTimeout),p("area,graph,dataLabelsGroup,group,markerGroup,tracker,graphNeg,areaNeg,posClip,negClip".split(","),function(b){a[b]&&(d=c&&"group"===b?"hide":"destroy",a[b][d]())}),b.hoverSeries===a&&(b.hoverSeries=null),ja(b.series,a);for(h in a)delete a[h]},getSegmentPath:function(a){var b=this,c=[],d=b.options.step;return p(a,function(e,f){var i,g=e.plotX,h=e.plotY;b.getPointSpline?c.push.apply(c,b.getPointSpline(a,e,f)):(c.push(f?"L":"M"),d&&f&&(i=a[f-1],"right"===d?c.push(i.plotX,h):"center"===d?c.push((i.plotX+g)/2,i.plotY,(i.plotX+g)/2,h):c.push(g,i.plotY)),c.push(e.plotX,e.plotY))}),c},getGraphPath:function(){var c,a=this,b=[],d=[];return p(a.segments,function(e){c=a.getSegmentPath(e),e.length>1?b=b.concat(c):d.push(e[0])}),a.singlePoints=d,a.graphPath=b},drawGraph:function(){var a=this,b=this.options,c=[["graph",b.lineColor||this.color]],d=b.lineWidth,e=b.dashStyle,f="square"!==b.linecap,g=this.getGraphPath(),h=b.negativeColor;h&&c.push(["graphNeg",h]),p(c,function(c,h){var k=c[0],l=a[k];l?(bb(l),l.animate({d:g})):d&&g.length&&(l={stroke:c[1],"stroke-width":d,fill:Q,zIndex:1},e?l.dashstyle=e:f&&(l["stroke-linecap"]=l["stroke-linejoin"]="round"),a[k]=a.chart.renderer.path(g).attr(l).add(a.group).shadow(!h&&b.shadow))})},clipNeg:function(){var e,a=this.options,b=this.chart,c=b.renderer,d=a.negativeColor||a.negativeFillColor,f=this.graph,g=this.area,h=this.posClip,i=this.negClip;e=b.chartWidth;var j=b.chartHeight,k=v(e,j),l=this.yAxis;d&&(f||g)&&(d=u(l.toPixels(a.threshold||0,!0)),0>d&&(k-=d),a={x:0,y:0,width:k,height:d},k={x:0,y:d,width:k,height:k},b.inverted&&(a.height=k.y=b.plotWidth-d,c.isVML&&(a={x:b.plotWidth-d-b.plotLeft,y:0,width:e,height:j},k={x:d+b.plotLeft-e,y:0,width:b.plotLeft+d,height:e})),l.reversed?(b=k,e=a):(b=a,e=k),h?(h.animate(b),i.animate(e)):(this.posClip=h=c.clipRect(b),this.negClip=i=c.clipRect(e),f&&this.graphNeg&&(f.clip(h),this.graphNeg.clip(i)),g&&(g.clip(h),this.areaNeg.clip(i))))},invertGroups:function(){function a(){var a={width:b.yAxis.len,height:b.xAxis.len};p(["group","markerGroup"],function(c){b[c]&&b[c].attr(a).invert()})}var b=this,c=b.chart;b.xAxis&&(K(c,"resize",a),K(b,"destroy",function(){W(c,"resize",a)}),a(),b.invertGroups=a)},plotGroup:function(a,b,c,d,e){var f=this[a],g=!f;return g&&(this[a]=f=this.chart.renderer.g(b).attr({visibility:c,zIndex:d||.1}).add(e)),f[g?"attr":"animate"](this.getPlotBox()),f},getPlotBox:function(){var a=this.chart,b=this.xAxis,c=this.yAxis;return a.inverted&&(b=c,c=this.xAxis),{translateX:b?b.left:a.plotLeft,translateY:c?c.top:a.plotTop,scaleX:1,scaleY:1}},render:function(){var c,a=this,b=a.chart,d=a.options,e=(c=d.animation)&&!!a.animate&&b.renderer.isSVG&&m(c.duration,500)||0,f=a.visible?"visible":"hidden",g=d.zIndex,h=a.hasRendered,i=b.seriesGroup;c=a.plotGroup("group","series",f,g,i),a.markerGroup=a.plotGroup("markerGroup","markers",f,g,i),e&&a.animate(!0),a.getAttribs(),c.inverted=a.isCartesian?b.inverted:!1,a.drawGraph&&(a.drawGraph(),a.clipNeg()),a.drawDataLabels&&a.drawDataLabels(),a.visible&&a.drawPoints(),a.drawTracker&&a.options.enableMouseTracking!==!1&&a.drawTracker(),b.inverted&&a.invertGroups(),d.clip!==!1&&!a.sharedClipKey&&!h&&c.clip(b.clipRect),e&&a.animate(),h||(e?a.animationTimeout=setTimeout(function(){a.afterAnimate()},e):a.afterAnimate()),a.isDirty=a.isDirtyData=!1,a.hasRendered=!0},redraw:function(){var a=this.chart,b=this.isDirtyData,c=this.group,d=this.xAxis,e=this.yAxis;c&&(a.inverted&&c.attr({width:a.plotWidth,height:a.plotHeight}),c.animate({translateX:m(d&&d.left,a.plotLeft),translateY:m(e&&e.top,a.plotTop)})),this.translate(),this.setTooltipPoints&&this.setTooltipPoints(!0),this.render(),b&&D(this,"updatedData")}},Hb.prototype={destroy:function(){Oa(this,this.axis)},render:function(a){var b=this.options,c=b.format,c=c?Ia(c,this):b.formatter.call(this);this.label?this.label.attr({text:c,visibility:"hidden"}):this.label=this.axis.chart.renderer.text(c,null,null,b.useHTML).css(b.style).attr({align:this.textAlign,rotation:b.rotation,visibility:"hidden"}).add(a)},setOffset:function(a,b){var c=this.axis,d=c.chart,e=d.inverted,f=this.isNegative,g=c.translate(c.usePercentage?100:this.total,0,0,0,1),c=c.translate(0),c=M(g-c),h=d.xAxis[0].translate(this.x)+a,i=d.plotHeight,f={x:e?f?g:g-c:h,y:e?i-h-b:f?i-g-c:i-g,width:e?c:b,height:e?b:c};(e=this.label)&&(e.align(this.alignOptions,null,f),f=e.alignAttr,e[this.options.crop===!1||d.isInsidePlot(f.x,f.y)?"show":"hide"](!0))}},la.prototype.buildStacks=function(){var a=this.series,b=m(this.options.reversedStacks,!0),c=a.length;if(!this.isXAxis){for(this.usePercentage=!1;c--;)a[b?c:a.length-c-1].setStackedPoints();if(this.usePercentage)for(c=0;c<a.length;c++)a[c].setPercentStacks()}},la.prototype.renderStackTotals=function(){var d,e,a=this.chart,b=a.renderer,c=this.stacks,f=this.stackTotalGroup;f||(this.stackTotalGroup=f=b.g("stack-labels").attr({visibility:"visible",zIndex:6}).add()),f.translate(a.plotLeft,a.plotTop);for(d in c)for(e in a=c[d])a[e].render(f)},O.prototype.setStackedPoints=function(){if(this.options.stacking&&(this.visible===!0||this.chart.options.chart.ignoreHiddenSeries===!1)){var n,m,p,q,r,u,a=this.processedXData,b=this.processedYData,c=[],d=b.length,e=this.options,f=e.threshold,g=e.stack,e=e.stacking,h=this.stackKey,i="-"+h,j=this.negStacks,k=this.yAxis,l=k.stacks,o=k.oldStacks;for(q=0;d>q;q++)r=a[q],u=b[q],p=this.index+","+q,m=(n=j&&f>u)?i:h,l[m]||(l[m]={}),l[m][r]||(o[m]&&o[m][r]?(l[m][r]=o[m][r],l[m][r].total=null):l[m][r]=new Hb(k,k.options.stackLabels,n,r,g)),m=l[m][r],m.points[p]=[m.cum||0],"percent"===e?(n=n?h:i,j&&l[n]&&l[n][r]?(n=l[n][r],m.total=n.total=v(n.total,m.total)+M(u)||0):m.total=da(m.total+(M(u)||0))):m.total=da(m.total+(u||0)),m.cum=(m.cum||0)+(u||0),m.points[p].push(m.cum),c[q]=m.cum;"percent"===e&&(k.usePercentage=!0),this.stackedYData=c,k.oldStacks={}}},O.prototype.setPercentStacks=function(){var a=this,b=a.stackKey,c=a.yAxis.stacks,d=a.processedXData;p([b,"-"+b],function(b){for(var e,g,h,f=d.length;f--;)g=d[f],e=(h=c[b]&&c[b][g])&&h.points[a.index+","+f],(g=e)&&(h=h.total?100/h.total:0,g[0]=da(g[0]*h),g[1]=da(g[1]*h),a.stackedYData[f]=g[1])})},q(Ya.prototype,{addSeries:function(a,b,c){var d,e=this;return a&&(b=m(b,!0),D(e,"addSeries",{options:a},function(){d=e.initSeries(a),e.isDirtyLegend=!0,e.linkSeries(),b&&e.redraw(c)})),d},addAxis:function(a,b,c,d){var e=b?"xAxis":"yAxis",f=this.options;new la(this,w(a,{index:this[e].length,isX:b})),f[e]=qa(f[e]||{}),f[e].push(a),m(c,!0)&&this.redraw(d)},showLoading:function(a){var b=this.options,c=this.loadingDiv,d=b.loading;c||(this.loadingDiv=c=Y(Ja,{className:"highcharts-loading"},q(d.style,{zIndex:10,display:Q}),this.container),this.loadingSpan=Y("span",null,d.labelStyle,c)),this.loadingSpan.innerHTML=a||b.lang.loading,this.loadingShown||(G(c,{opacity:0,display:"",left:this.plotLeft+"px",top:this.plotTop+"px",width:this.plotWidth+"px",height:this.plotHeight+"px"}),kb(c,{opacity:d.style.opacity},{duration:d.showDuration||0}),this.loadingShown=!0)},hideLoading:function(){var a=this.options,b=this.loadingDiv;b&&kb(b,{opacity:0},{duration:a.loading.hideDuration||100,complete:function(){G(b,{display:Q})}}),this.loadingShown=!1}}),q(Ea.prototype,{update:function(a,b,c){var g,d=this,e=d.series,f=d.graphic,h=e.data,i=e.chart,j=e.options,b=m(b,!0);d.firePointEvent("update",{options:a},function(){d.applyOptions(a),ca(a)&&(e.getAttribs(),f&&(a&&a.marker&&a.marker.symbol?d.graphic=f.destroy():f.attr(d.pointAttr[d.state||""])),a&&a.dataLabels&&d.dataLabel&&(d.dataLabel=d.dataLabel.destroy())),g=Da(d,h),e.updateParallelArrays(d,g),j.data[g]=d.options,e.isDirty=e.isDirtyData=!0,!e.fixedBox&&e.hasCartesianSeries&&(i.isDirtyBox=!0),"point"===j.legendType&&i.legend.destroyItem(d),b&&i.redraw(c)})},remove:function(a,b){var g,c=this,d=c.series,e=d.points,f=d.chart,h=d.data;Qa(b,f),a=m(a,!0),c.firePointEvent("remove",null,function(){g=Da(c,h),h.length===e.length&&e.splice(g,1),h.splice(g,1),d.options.data.splice(g,1),d.updateParallelArrays(c,"splice",g,1),c.destroy(),d.isDirty=!0,d.isDirtyData=!0,a&&f.redraw()})}}),q(O.prototype,{addPoint:function(a,b,c,d){var o,e=this.options,f=this.data,g=this.graph,h=this.area,i=this.chart,j=this.xAxis&&this.xAxis.names,k=g&&g.shift||0,l=e.data,n=this.xData;if(Qa(d,i),c&&p([g,h,this.graphNeg,this.areaNeg],function(a){a&&(a.shift=k+1)}),h&&(h.isArea=!0),b=m(b,!0),d={series:this},this.pointClass.prototype.applyOptions.apply(d,[a]),g=d.x,h=n.length,this.requireSorting&&g<n[h-1])for(o=!0;h&&n[h-1]>g;)h--;this.updateParallelArrays(d,"splice",h,0,0),this.updateParallelArrays(d,h),j&&(j[g]=d.name),l.splice(h,0,a),o&&(this.data.splice(h,0,null),this.processData()),"point"===e.legendType&&this.generatePoints(),c&&(f[0]&&f[0].remove?f[0].remove(!1):(f.shift(),this.updateParallelArrays(d,"shift"),l.shift())),this.isDirtyData=this.isDirty=!0,b&&(this.getAttribs(),i.redraw())},remove:function(a,b){var c=this,d=c.chart,a=m(a,!0);c.isRemoving||(c.isRemoving=!0,D(c,"remove",null,function(){c.destroy(),d.isDirtyLegend=d.isDirtyBox=!0,d.linkSeries(),a&&d.redraw(b)})),c.isRemoving=!1},update:function(a,b){var f,c=this.chart,d=this.type,e=F[d].prototype,a=w(this.userOptions,{animation:!1,index:this.index,pointStart:this.xData[0]},{data:this.options.data},a);this.remove(!1);for(f in e)e.hasOwnProperty(f)&&(this[f]=t);q(this,F[a.type||d].prototype),this.init(c,a),m(b,!0)&&c.redraw(!1)}}),q(la.prototype,{update:function(a,b){var c=this.chart,a=c.options[this.coll][this.options.index]=w(this.userOptions,a);this.destroy(!0),this._addedPlotLB=t,this.init(c,q(a,{events:t})),c.isDirtyBox=!0,m(b,!0)&&c.redraw()},remove:function(a){for(var b=this.chart,c=this.coll,d=this.series,e=d.length;e--;)d[e]&&d[e].remove(!1);ja(b.axes,this),ja(b[c],this),b.options[c].splice(this.options.index,1),p(b[c],function(a,b){a.options.index=b}),this.destroy(),b.isDirtyBox=!0,m(a,!0)&&b.redraw()},setTitle:function(a,b){this.update({title:a},b)},setCategories:function(a,b){this.update({categories:a},b)}}),ga=ka(O),F.line=ga,ba.area=w(S,{threshold:0});var pa=ka(O,{type:"area",getSegments:function(){var h,i,l,o,n,a=[],b=[],c=[],d=this.xAxis,e=this.yAxis,f=e.stacks[this.stackKey],g={},j=this.points,k=this.options.connectNulls;if(this.options.stacking&&!this.cropped){for(o=0;o<j.length;o++)g[j[o].x]=j[o];for(n in f)null!==f[n].total&&c.push(+n);c.sort(function(a,b){return a-b}),p(c,function(a){(!k||g[a]&&null!==g[a].y)&&(g[a]?b.push(g[a]):(h=d.translate(a),l=f[a].percent?f[a].total?100*f[a].cum/f[a].total:0:f[a].cum,i=e.toPixels(l,!0),b.push({y:null,plotX:h,clientX:h,plotY:i,yBottom:i,onMouseOver:sa})))}),b.length&&a.push(b)}else O.prototype.getSegments.call(this),a=this.segments;this.segments=a},getSegmentPath:function(a){var d,b=O.prototype.getSegmentPath.call(this,a),c=[].concat(b),e=this.options;d=b.length;var g,f=this.yAxis.getThreshold(e.threshold);if(3===d&&c.push("L",b[1],b[2]),e.stacking&&!this.closedStacks)for(d=a.length-1;d>=0;d--)g=m(a[d].yBottom,f),d<a.length-1&&e.step&&c.push(a[d+1].plotX,g),c.push(a[d].plotX,g);else this.closeSegment(c,a,f);return this.areaPath=this.areaPath.concat(c),b},closeSegment:function(a,b,c){a.push("L",b[b.length-1].plotX,c,"L",b[0].plotX,c)},drawGraph:function(){this.areaPath=[],O.prototype.drawGraph.apply(this);var a=this,b=this.areaPath,c=this.options,d=c.negativeColor,e=c.negativeFillColor,f=[["area",this.color,c.fillColor]];(d||e)&&f.push(["areaNeg",d,e]),p(f,function(d){var e=d[0],f=a[e];f?f.animate({d:b}):a[e]=a.chart.renderer.path(b).attr({fill:m(d[2],ya(d[1]).setOpacity(m(c.fillOpacity,.75)).get()),zIndex:0}).add(a.group)
|
5 |
+
})},drawLegendSymbol:N.drawRectangle});F.area=pa,ba.spline=w(S),ga=ka(O,{type:"spline",getPointSpline:function(a,b,c){var h,i,j,k,d=b.plotX,e=b.plotY,f=a[c-1],g=a[c+1];if(f&&g){a=f.plotY,j=g.plotX;var l,g=g.plotY;h=(1.5*d+f.plotX)/2.5,i=(1.5*e+a)/2.5,j=(1.5*d+j)/2.5,k=(1.5*e+g)/2.5,l=(k-i)*(j-d)/(j-h)+e-k,i+=l,k+=l,i>a&&i>e?(i=v(a,e),k=2*e-i):a>i&&e>i&&(i=C(a,e),k=2*e-i),k>g&&k>e?(k=v(g,e),i=2*e-k):g>k&&e>k&&(k=C(g,e),i=2*e-k),b.rightContX=j,b.rightContY=k}return c?(b=["C",f.rightContX||f.plotX,f.rightContY||f.plotY,h||d,i||e,d,e],f.rightContX=f.rightContY=null):b=["M",d,e],b}}),F.spline=ga,ba.areaspline=w(ba.area),pa=pa.prototype,ga=ka(ga,{type:"areaspline",closedStacks:!0,getSegmentPath:pa.getSegmentPath,closeSegment:pa.closeSegment,drawGraph:pa.drawGraph,drawLegendSymbol:N.drawRectangle}),F.areaspline=ga,ba.column=w(S,{borderColor:"#FFFFFF",borderRadius:0,groupPadding:.2,marker:null,pointPadding:.1,minPointLength:0,cropThreshold:50,pointRange:null,states:{hover:{brightness:.1,shadow:!1,halo:!1},select:{color:"#C0C0C0",borderColor:"#000000",shadow:!1}},dataLabels:{align:null,verticalAlign:null,y:null},stickyTracking:!1,tooltip:{distance:6},threshold:0}),ga=ka(O,{type:"column",pointAttrToOptions:{stroke:"borderColor",fill:"color",r:"borderRadius"},cropShoulder:0,trackerGroups:["group","dataLabelsGroup"],negStacks:!0,init:function(){O.prototype.init.apply(this,arguments);var a=this,b=a.chart;b.hasRendered&&p(b.series,function(b){b.type===a.type&&(b.isDirty=!0)})},getColumnMetrics:function(){var f,h,a=this,b=a.options,c=a.xAxis,d=a.yAxis,e=c.reversed,g={},i=0;b.grouping===!1?i=1:p(a.chart.series,function(b){var c=b.options,e=b.yAxis;b.type===a.type&&b.visible&&d.len===e.len&&d.pos===e.pos&&(c.stacking?(f=b.stackKey,g[f]===t&&(g[f]=i++),h=g[f]):c.grouping!==!1&&(h=i++),b.columnIndex=h)});var c=C(M(c.transA)*(c.ordinalSlope||b.pointRange||c.closestPointRange||c.tickInterval||1),c.len),j=c*b.groupPadding,k=(c-2*j)/i,l=b.pointWidth,b=r(l)?(k-l)/2:k*b.pointPadding,l=m(l,k-2*b);return a.columnMetrics={width:l,offset:b+(j+((e?i-(a.columnIndex||0):a.columnIndex)||0)*k-c/2)*(e?-1:1)}},translate:function(){var a=this,b=a.chart,c=a.options,d=a.borderWidth=m(c.borderWidth,a.activePointCount>.5*a.xAxis.len?0:1),e=a.yAxis,f=a.translatedThreshold=e.getThreshold(c.threshold),g=m(c.minPointLength,5),c=a.getColumnMetrics(),h=c.width,i=a.barW=Ka(v(h,1+2*d)),j=a.pointXOffset=c.offset,k=-(d%2?.5:0),l=d%2?.5:1;b.renderer.isVML&&b.inverted&&(l+=1),O.prototype.translate.apply(a),p(a.points,function(c){var x,d=m(c.yBottom,f),p=C(v(-999-d,c.plotY),e.len+999+d),q=c.plotX+j,r=i,t=C(p,d);x=v(p,d)-t,M(x)<g&&g&&(x=g,t=u(M(t-f)>g?d-g:f-(e.translate(c.y,0,1,0,1)<=f?g:0))),c.barX=q,c.pointWidth=h,c.tooltipPos=b.inverted?[e.len-p,a.xAxis.len-q-r/2]:[q+r/2,p],d=M(q)<.5,r=u(q+r)+k,q=u(q)+k,r-=q,p=M(t)<.5,x=u(t+x)+l,t=u(t)+l,x-=t,d&&(q+=1,r-=1),p&&(t-=1,x+=1),c.shapeType="rect",c.shapeArgs={x:q,y:t,width:r,height:x}})},getSymbol:sa,drawLegendSymbol:N.drawRectangle,drawGraph:sa,drawPoints:function(){var f,g,h,a=this,b=this.chart,c=a.options,d=b.renderer,e=c.animationLimit||250;p(a.points,function(i){var j=i.plotY,k=i.graphic;j===t||isNaN(j)||null===i.y?k&&(i.graphic=k.destroy()):(f=i.shapeArgs,h=r(a.borderWidth)?{"stroke-width":a.borderWidth}:{},g=i.pointAttr[i.selected?"select":""]||a.pointAttr[""],k?(bb(k),k.attr(h)[b.pointCount<e?"animate":"attr"](w(f))):i.graphic=d[i.shapeType](f).attr(g).attr(h).add(a.group).shadow(c.shadow,null,c.stacking&&!c.borderRadius))})},animate:function(a){var b=this.yAxis,c=this.options,d=this.chart.inverted,e={};aa&&(a?(e.scaleY=.001,a=C(b.pos+b.len,v(b.pos,b.toPixels(c.threshold))),d?e.translateX=a-b.len:e.translateY=a,this.group.attr(e)):(e.scaleY=1,e[d?"translateX":"translateY"]=b.pos,this.group.animate(e,this.options.animation),this.animate=null))},remove:function(){var a=this,b=a.chart;b.hasRendered&&p(b.series,function(b){b.type===a.type&&(b.isDirty=!0)}),O.prototype.remove.apply(a,arguments)}}),F.column=ga,ba.bar=w(ba.column),pa=ka(ga,{type:"bar",inverted:!0}),F.bar=pa,ba.scatter=w(S,{lineWidth:0,tooltip:{headerFormat:'<span style="color:{series.color}">â—</span> <span style="font-size: 10px;"> {series.name}</span><br/>',pointFormat:"x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>"},stickyTracking:!1}),pa=ka(O,{type:"scatter",sorted:!1,requireSorting:!1,noSharedTooltip:!0,trackerGroups:["markerGroup"],takeOrdinalPosition:!1,singularTooltips:!0,drawGraph:function(){this.options.lineWidth&&O.prototype.drawGraph.call(this)}}),F.scatter=pa,ba.pie=w(S,{borderColor:"#FFFFFF",borderWidth:1,center:[null,null],clip:!1,colorByPoint:!0,dataLabels:{distance:30,enabled:!0,formatter:function(){return this.point.name}},ignoreHiddenPoint:!0,legendType:"point",marker:null,size:null,showInLegend:!1,slicedOffset:10,states:{hover:{brightness:.1,shadow:!1}},stickyTracking:!1,tooltip:{followPointer:!0}}),S={type:"pie",isCartesian:!1,pointClass:ka(Ea,{init:function(){Ea.prototype.init.apply(this,arguments);var b,a=this;return a.y<0&&(a.y=null),q(a,{visible:a.visible!==!1,name:m(a.name,"Slice")}),b=function(b){a.slice("select"===b.type)},K(a,"select",b),K(a,"unselect",b),a},setVisible:function(a){var b=this,c=b.series,d=c.chart;b.visible=b.options.visible=a=a===t?!b.visible:a,c.options.data[Da(b,c.data)]=b.options,p(["graphic","dataLabel","connector","shadowGroup"],function(c){b[c]&&b[c][a?"show":"hide"](!0)}),b.legendItem&&d.legend.colorizeItem(b,a),!c.isDirty&&c.options.ignoreHiddenPoint&&(c.isDirty=!0,d.redraw())},slice:function(a,b,c){var d=this.series;Qa(c,d.chart),m(b,!0),this.sliced=this.options.sliced=a=r(a)?a:!this.sliced,d.options.data[Da(this,d.data)]=this.options,a=a?this.slicedTranslation:{translateX:0,translateY:0},this.graphic.animate(a),this.shadowGroup&&this.shadowGroup.animate(a)},haloPath:function(a){var b=this.shapeArgs,c=this.series.chart;return this.series.chart.renderer.symbols.arc(c.plotLeft+b.x,c.plotTop+b.y,b.r+a,b.r+a,{innerR:this.shapeArgs.r,start:b.start,end:b.end})}}),requireSorting:!1,noSharedTooltip:!0,trackerGroups:["group","dataLabelsGroup"],axisTypes:[],pointAttrToOptions:{stroke:"borderColor","stroke-width":"borderWidth",fill:"color"},singularTooltips:!0,getColor:sa,animate:function(a){var b=this,c=b.points,d=b.startAngleRad;a||(p(c,function(a){var c=a.graphic,a=a.shapeArgs;c&&(c.attr({r:b.center[3]/2,start:d,end:d}),c.animate({r:a.r,start:a.start,end:a.end},b.options.animation))}),b.animate=null)},setData:function(a,b,c,d){O.prototype.setData.call(this,a,!1,c,d),this.processData(),this.generatePoints(),m(b,!0)&&this.chart.redraw(c)},generatePoints:function(){var a,c,d,e,b=0,f=this.options.ignoreHiddenPoint;for(O.prototype.generatePoints.call(this),c=this.points,d=c.length,a=0;d>a;a++)e=c[a],b+=f&&!e.visible?0:e.y;for(this.total=b,a=0;d>a;a++)e=c[a],e.percentage=b>0?e.y/b*100:0,e.total=b},translate:function(a){this.generatePoints();var f,g,h,o,p,b=0,c=this.options,d=c.slicedOffset,e=d+c.borderWidth,i=c.startAngle||0,j=this.startAngleRad=ma/180*(i-90),i=(this.endAngleRad=ma/180*(m(c.endAngle,i+360)-90))-j,k=this.points,l=c.dataLabels.distance,c=c.ignoreHiddenPoint,n=k.length;for(a||(this.center=a=this.getCenter()),this.getX=function(b,c){return h=U.asin(C((b-a[1])/(a[2]/2+l),1)),a[0]+(c?-1:1)*Z(h)*(a[2]/2+l)},o=0;n>o;o++)p=k[o],f=j+b*i,(!c||p.visible)&&(b+=p.percentage/100),g=j+b*i,p.shapeType="arc",p.shapeArgs={x:a[0],y:a[1],r:a[2]/2,innerR:a[3]/2,start:u(1e3*f)/1e3,end:u(1e3*g)/1e3},h=(g+f)/2,h>1.5*ma?h-=2*ma:-ma/2>h&&(h+=2*ma),p.slicedTranslation={translateX:u(Z(h)*d),translateY:u(ea(h)*d)},f=Z(h)*a[2]/2,g=ea(h)*a[2]/2,p.tooltipPos=[a[0]+.7*f,a[1]+.7*g],p.half=-ma/2>h||h>ma/2?1:0,p.angle=h,e=C(e,l/2),p.labelPos=[a[0]+f+Z(h)*l,a[1]+g+ea(h)*l,a[0]+f+Z(h)*e,a[1]+g+ea(h)*e,a[0]+f,a[1]+g,0>l?"center":p.half?"right":"left",h]},drawGraph:null,drawPoints:function(){var c,d,f,g,a=this,b=a.chart.renderer,e=a.options.shadow;e&&!a.shadowGroup&&(a.shadowGroup=b.g("shadow").add(a.group)),p(a.points,function(h){d=h.graphic,g=h.shapeArgs,f=h.shadowGroup,e&&!f&&(f=h.shadowGroup=b.g("shadow").add(a.shadowGroup)),c=h.sliced?h.slicedTranslation:{translateX:0,translateY:0},f&&f.attr(c),d?d.animate(q(g,c)):h.graphic=d=b[h.shapeType](g).setRadialReference(a.center).attr(h.pointAttr[h.selected?"select":""]).attr({"stroke-linejoin":"round"}).attr(c).add(a.group).shadow(e,f),void 0!==h.visible&&h.setVisible(h.visible)})},sortByAngle:function(a,b){a.sort(function(a,d){return void 0!==a.angle&&(d.angle-a.angle)*b})},drawLegendSymbol:N.drawRectangle,getCenter:X.getCenter,getSymbol:sa},S=ka(O,S),F.pie=S,O.prototype.drawDataLabels=function(){var f,g,h,i,a=this,b=a.options,c=b.cursor,d=b.dataLabels,e=a.points;(d.enabled||a._hasPointLabels)&&(a.dlProcessOptions&&a.dlProcessOptions(d),i=a.plotGroup("dataLabelsGroup","data-labels","hidden",d.zIndex||6),!a.hasRendered&&m(d.defer,!0)&&(i.attr({opacity:0}),K(a,"afterAnimate",function(){a.dataLabelsGroup.show()[b.animation?"animate":"attr"]({opacity:1},{duration:200})})),g=d,p(e,function(b){var e,o,n,l=b.dataLabel,p=b.connector,u=!0;if(f=b.options&&b.options.dataLabels,e=m(f&&f.enabled,g.enabled),l&&!e)b.dataLabel=l.destroy();else if(e){if(d=w(g,f),e=d.rotation,o=b.getLabelConfig(),h=d.format?Ia(d.format,o):d.formatter.call(o,d),d.style.color=m(d.color,d.style.color,a.color,"black"),l)r(h)?(l.attr({text:h}),u=!1):(b.dataLabel=l=l.destroy(),p&&(b.connector=p.destroy()));else if(r(h)){l={fill:d.backgroundColor,stroke:d.borderColor,"stroke-width":d.borderWidth,r:d.borderRadius||0,rotation:e,padding:d.padding,zIndex:1};for(n in l)l[n]===t&&delete l[n];l=b.dataLabel=a.chart.renderer[e?"text":"label"](h,0,-999,null,null,null,d.useHTML).attr(l).css(q(d.style,c&&{cursor:c})).add(i).shadow(d.shadow)}l&&a.alignDataLabel(b,l,d,null,u)}}))},O.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=m(a.plotX,-999),i=m(a.plotY,-999),j=b.getBBox();(a=this.visible&&(a.series.forceDL||f.isInsidePlot(h,u(i),g)||d&&f.isInsidePlot(h,g?d.x+1:d.y+d.height-1,g)))&&(d=q({x:g?f.plotWidth-i:h,y:u(g?f.plotHeight-h:i),width:0,height:0},d),q(c,{width:j.width,height:j.height}),c.rotation?(g={align:c.align,x:d.x+c.x+d.width/2,y:d.y+c.y+d.height/2},b[e?"attr":"animate"](g)):(b.align(c,null,d),g=b.alignAttr,"justify"===m(c.overflow,"justify")?this.justifyDataLabel(b,c,g,j,d,e):m(c.crop,!0)&&(a=f.isInsidePlot(g.x,g.y)&&f.isInsidePlot(g.x+j.width,g.y+j.height)))),a||(b.attr({y:-999}),b.placed=!1)},O.prototype.justifyDataLabel=function(a,b,c,d,e,f){var j,k,g=this.chart,h=b.align,i=b.verticalAlign;j=c.x,0>j&&("right"===h?b.align="left":b.x=-j,k=!0),j=c.x+d.width,j>g.plotWidth&&("left"===h?b.align="right":b.x=g.plotWidth-j,k=!0),j=c.y,0>j&&("bottom"===i?b.verticalAlign="top":b.y=-j,k=!0),j=c.y+d.height,j>g.plotHeight&&("top"===i?b.verticalAlign="bottom":b.y=g.plotHeight-j,k=!0),k&&(a.placed=!f,a.align(b,null,e))},F.pie&&(F.pie.prototype.drawDataLabels=function(){var c,i,j,t,w,x,y,A,C,G,D,B,a=this,b=a.data,d=a.chart,e=a.options.dataLabels,f=m(e.connectorPadding,10),g=m(e.connectorWidth,1),h=d.plotWidth,d=d.plotHeight,k=m(e.softConnector,!0),l=e.distance,o=a.center,n=o[2]/2,q=o[1],r=l>0,z=[[],[]],F=[0,0,0,0],N=function(a,b){return b.y-a.y};if(a.visible&&(e.enabled||a._hasPointLabels)){for(O.prototype.drawDataLabels.apply(a),p(b,function(a){a.dataLabel&&a.visible&&z[a.half].push(a)}),D=0;!y&&b[D];)y=b[D]&&b[D].dataLabel&&(b[D].dataLabel.getBBox().height||21),D++;for(D=2;D--;){var E,b=[],K=[],H=z[D],I=H.length;if(a.sortByAngle(H,D-.5),l>0){for(B=q-n-l;q+n+l>=B;B+=y)b.push(B);if(w=b.length,I>w){for(c=[].concat(H),c.sort(N),B=I;B--;)c[B].rank=B;for(B=I;B--;)H[B].rank>=w&&H.splice(B,1);I=H.length}for(B=0;I>B;B++){c=H[B],x=c.labelPos,c=9999;var Q,P;for(P=0;w>P;P++)Q=M(b[P]-x[1]),c>Q&&(c=Q,E=P);if(B>E&&null!==b[B])E=B;else for(I-B+E>w&&null!==b[B]&&(E=w-I+B);null===b[E];)E++;K.push({i:E,y:b[E]}),b[E]=null}K.sort(N)}for(B=0;I>B;B++)c=H[B],x=c.labelPos,t=c.dataLabel,G=c.visible===!1?"hidden":"visible",c=x[1],l>0?(w=K.pop(),E=w.i,C=w.y,(c>C&&null!==b[E+1]||C>c&&null!==b[E-1])&&(C=c)):C=c,A=e.justify?o[0]+(D?-1:1)*(n+l):a.getX(0===E||E===b.length-1?c:C,D),t._attr={visibility:G,align:x[6]},t._pos={x:A+e.x+({left:f,right:-f}[x[6]]||0),y:C+e.y-10},t.connX=A,t.connY=C,null===this.options.size&&(w=t.width,f>A-w?F[3]=v(u(w-A+f),F[3]):A+w>h-f&&(F[1]=v(u(A+w-h+f),F[1])),0>C-y/2?F[0]=v(u(-C+y/2),F[0]):C+y/2>d&&(F[2]=v(u(C+y/2-d),F[2])))}(0===Ba(F)||this.verifyDataLabelOverflow(F))&&(this.placeDataLabels(),r&&g&&p(this.points,function(b){i=b.connector,x=b.labelPos,(t=b.dataLabel)&&t._pos?(G=t._attr.visibility,A=t.connX,C=t.connY,j=k?["M",A+("left"===x[6]?5:-5),C,"C",A,C,2*x[2]-x[4],2*x[3]-x[5],x[2],x[3],"L",x[4],x[5]]:["M",A+("left"===x[6]?5:-5),C,"L",x[2],x[3],"L",x[4],x[5]],i?(i.animate({d:j}),i.attr("visibility",G)):b.connector=i=a.chart.renderer.path(j).attr({"stroke-width":g,stroke:e.connectorColor||b.color||"#606060",visibility:G}).add(a.dataLabelsGroup)):i&&(b.connector=i.destroy())}))}},F.pie.prototype.placeDataLabels=function(){p(this.points,function(a){var b,a=a.dataLabel;a&&((b=a._pos)?(a.attr(a._attr),a[a.moved?"animate":"attr"](b),a.moved=!0):a&&a.attr({y:-999}))})},F.pie.prototype.alignDataLabel=sa,F.pie.prototype.verifyDataLabelOverflow=function(a){var f,b=this.center,c=this.options,d=c.center,e=c=c.minSize||80;return null!==d[0]?e=v(b[2]-v(a[1],a[3]),c):(e=v(b[2]-a[1]-a[3],c),b[0]+=(a[3]-a[1])/2),null!==d[1]?e=v(C(e,b[2]-v(a[0],a[2])),c):(e=v(C(e,b[2]-a[0]-a[2]),c),b[1]+=(a[0]-a[2])/2),e<b[2]?(b[2]=e,this.translate(b),p(this.points,function(a){a.dataLabel&&(a.dataLabel._pos=null)}),this.drawDataLabels&&this.drawDataLabels()):f=!0,f}),F.column&&(F.column.prototype.alignDataLabel=function(a,b,c,d,e){var f=this.chart,g=f.inverted,h=a.dlBox||a.shapeArgs,i=a.below||a.plotY>m(this.translatedThreshold,f.plotSizeY),j=m(c.inside,!!this.options.stacking);h&&(d=w(h),g&&(d={x:f.plotWidth-d.y-d.height,y:f.plotHeight-d.x-d.width,width:d.height,height:d.width}),!j)&&(g?(d.x+=i?0:d.width,d.width=0):(d.y+=i?d.height:0,d.height=0)),c.align=m(c.align,!g||j?"center":i?"right":"left"),c.verticalAlign=m(c.verticalAlign,g||j?"middle":i?"top":"bottom"),O.prototype.alignDataLabel.call(this,a,b,c,d,e)}),S=R.TrackerMixin={drawTrackerPoint:function(){var a=this,b=a.chart,c=b.pointer,d=a.options.cursor,e=d&&{cursor:d},f=function(c){var e,d=c.target;for(b.hoverSeries!==a&&a.onMouseOver();d&&!e;)e=d.point,d=d.parentNode;e!==t&&e!==b.hoverPoint&&e.onMouseOver(c)};p(a.points,function(a){a.graphic&&(a.graphic.element.point=a),a.dataLabel&&(a.dataLabel.element.point=a)}),a._hasTracking||(p(a.trackerGroups,function(b){a[b]&&(a[b].addClass("highcharts-tracker").on("mouseover",f).on("mouseout",function(a){c.onTrackerMouseOut(a)}).css(e),$a)&&a[b].on("touchstart",f)}),a._hasTracking=!0)},drawTrackerGraph:function(){var m,a=this,b=a.options,c=b.trackByArea,d=[].concat(c?a.areaPath:a.graphPath),e=d.length,f=a.chart,g=f.pointer,h=f.renderer,i=f.options.tooltip.snap,j=a.tracker,k=b.cursor,l=k&&{cursor:k},k=a.singlePoints,n=function(){f.hoverSeries!==a&&a.onMouseOver()},q="rgba(192,192,192,"+(aa?1e-4:.002)+")";if(e&&!c)for(m=e+1;m--;)"M"===d[m]&&d.splice(m+1,0,d[m+1]-i,d[m+2],"L"),(m&&"M"===d[m]||m===e)&&d.splice(m,0,"L",d[m-2]+i,d[m-1]);for(m=0;m<k.length;m++)e=k[m],d.push("M",e.plotX-i,e.plotY,"L",e.plotX+i,e.plotY);j?j.attr({d:d}):(a.tracker=h.path(d).attr({"stroke-linejoin":"round",visibility:a.visible?"visible":"hidden",stroke:q,fill:c?q:Q,"stroke-width":b.lineWidth+(c?0:2*i),zIndex:2}).add(a.group),p([a.tracker,a.markerGroup],function(a){a.addClass("highcharts-tracker").on("mouseover",n).on("mouseout",function(a){g.onTrackerMouseOut(a)}).css(l),$a&&a.on("touchstart",n)}))}},F.column&&(ga.prototype.drawTracker=S.drawTrackerPoint),F.pie&&(F.pie.prototype.drawTracker=S.drawTrackerPoint),F.scatter&&(pa.prototype.drawTracker=S.drawTrackerPoint),q(lb.prototype,{setItemEvents:function(a,b,c,d,e){var f=this;(c?b:a.legendGroup).on("mouseover",function(){a.setState("hover"),b.css(f.options.itemHoverStyle)}).on("mouseout",function(){b.css(a.visible?d:e),a.setState()}).on("click",function(b){var c=function(){a.setVisible()},b={browserEvent:b};a.firePointEvent?a.firePointEvent("legendItemClick",b,c):D(a,"legendItemClick",b,c)})},createCheckboxForItem:function(a){a.checkbox=Y("input",{type:"checkbox",checked:a.selected,defaultChecked:a.selected},this.options.itemCheckboxStyle,this.chart.container),K(a.checkbox,"click",function(b){D(a,"checkboxClick",{checked:b.target.checked},function(){a.select()})})}}),E.legend.itemStyle.cursor="pointer",q(Ya.prototype,{showResetZoom:function(){var a=this,b=E.lang,c=a.options.chart.resetZoomButton,d=c.theme,e=d.states,f="chart"===c.relativeTo?null:"plotBox";this.resetZoomButton=a.renderer.button(b.resetZoom,null,null,function(){a.zoomOut()},d,e&&e.hover).attr({align:c.position.align,title:b.resetZoomTitle}).add().align(c.position,!1,f)},zoomOut:function(){var a=this;D(a,"selection",{resetSelection:!0},function(){a.zoom()})},zoom:function(a){var b,e,c=this.pointer,d=!1;!a||a.resetSelection?p(this.axes,function(a){b=a.zoom()}):p(a.xAxis.concat(a.yAxis),function(a){var e=a.axis,h=e.isXAxis;(c[h?"zoomX":"zoomY"]||c[h?"pinchX":"pinchY"])&&(b=e.zoom(a.min,a.max),e.displayBtn&&(d=!0))}),e=this.resetZoomButton,d&&!e?this.showResetZoom():!d&&ca(e)&&(this.resetZoomButton=e.destroy()),b&&this.redraw(m(this.options.chart.animation,a&&a.animation,this.pointCount<100))},pan:function(a,b){var e,c=this,d=c.hoverPoints;d&&p(d,function(a){a.setState()}),p("xy"===b?[1,0]:[1],function(b){var d=a[b?"chartX":"chartY"],h=c[b?"xAxis":"yAxis"][0],i=c[b?"mouseDownX":"mouseDownY"],j=(h.pointRange||0)/2,k=h.getExtremes(),l=h.toValue(i-d,!0)+j,i=h.toValue(i+c[b?"plotWidth":"plotHeight"]-d,!0)-j;h.series.length&&l>C(k.dataMin,k.min)&&i<v(k.dataMax,k.max)&&(h.setExtremes(l,i,!1,!1,{trigger:"pan"}),e=!0),c[b?"mouseDownX":"mouseDownY"]=d}),e&&c.redraw(!1),G(c.container,{cursor:"move"})}}),q(Ea.prototype,{select:function(a,b){var c=this,d=c.series,e=d.chart,a=m(a,!c.selected);c.firePointEvent(a?"select":"unselect",{accumulate:b},function(){c.selected=c.options.selected=a,d.options.data[Da(c,d.data)]=c.options,c.setState(a&&"select"),b||p(e.getSelectedPoints(),function(a){a.selected&&a!==c&&(a.selected=a.options.selected=!1,d.options.data[Da(a,d.data)]=a.options,a.setState(""),a.firePointEvent("unselect"))})})},onMouseOver:function(a){var b=this.series,c=b.chart,d=c.tooltip,e=c.hoverPoint;e&&e!==this&&e.onMouseOut(),this.firePointEvent("mouseOver"),d&&(!d.shared||b.noSharedTooltip)&&d.refresh(this,a),this.setState("hover"),c.hoverPoint=this},onMouseOut:function(){var a=this.series.chart,b=a.hoverPoints;b&&-1!==Da(this,b)||(this.firePointEvent("mouseOut"),this.setState(),a.hoverPoint=null)},importEvents:function(){if(!this.hasImportedEvents){var b,a=w(this.series.options.point,this.options).events;this.events=a;for(b in a)K(this,b,a[b]);this.hasImportedEvents=!0}},setState:function(a,b){var p,c=this.plotX,d=this.plotY,e=this.series,f=e.options.states,g=ba[e.type].marker&&e.options.marker,h=g&&!g.enabled,i=g&&g.states[a],j=i&&i.enabled===!1,k=e.stateMarkerGraphic,l=this.marker||{},m=e.chart,n=e.halo,a=a||"";p=this.pointAttr[a]||e.pointAttr[a],a===this.state&&!b||this.selected&&"select"!==a||f[a]&&f[a].enabled===!1||a&&(j||h&&i.enabled===!1)||a&&l.states&&l.states[a]&&l.states[a].enabled===!1||(this.graphic?(g=g&&this.graphic.symbolName&&p.r,this.graphic.attr(w(p,g?{x:c-g,y:d-g,width:2*g,height:2*g}:{})),k&&k.hide()):(a&&i&&(g=i.radius,l=l.symbol||e.symbol,k&&k.currentSymbol!==l&&(k=k.destroy()),k?k[b?"animate":"attr"]({x:c-g,y:d-g}):l&&(e.stateMarkerGraphic=k=m.renderer.symbol(l,c-g,d-g,2*g,2*g).attr(p).add(e.markerGroup),k.currentSymbol=l)),k&&k[a&&m.isInsidePlot(c,d,m.inverted)?"show":"hide"]()),(c=f[a]&&f[a].halo)&&c.size?(n||(e.halo=n=m.renderer.path().add(e.seriesGroup)),n.attr(q({fill:ya(this.color||e.color).setOpacity(c.opacity).get()},c.attributes))[b?"animate":"attr"]({d:this.haloPath(c.size)})):n&&n.attr({d:[]}),this.state=a)},haloPath:function(a){var b=this.series,c=b.chart,d=b.getPlotBox(),e=c.inverted;return c.renderer.symbols.circle(d.translateX+(e?b.yAxis.len-this.plotY:this.plotX)-a,d.translateY+(e?b.xAxis.len-this.plotX:this.plotY)-a,2*a,2*a)}}),q(O.prototype,{onMouseOver:function(){var a=this.chart,b=a.hoverSeries;b&&b!==this&&b.onMouseOut(),this.options.events.mouseOver&&D(this,"mouseOver"),this.setState("hover"),a.hoverSeries=this},onMouseOut:function(){var a=this.options,b=this.chart,c=b.tooltip,d=b.hoverPoint;d&&d.onMouseOut(),this&&a.events.mouseOut&&D(this,"mouseOut"),c&&!a.stickyTracking&&(!c.shared||this.noSharedTooltip)&&c.hide(),this.setState(),b.hoverSeries=null},setState:function(a){var b=this.options,c=this.graph,d=this.graphNeg,e=b.states,b=b.lineWidth,a=a||"";this.state!==a&&(this.state=a,e[a]&&e[a].enabled===!1||(a&&(b=e[a].lineWidth||b+1),c&&!c.dashstyle&&(a={"stroke-width":b},c.attr(a),d&&d.attr(a))))},setVisible:function(a,b){var f,c=this,d=c.chart,e=c.legendItem,g=d.options.chart.ignoreHiddenSeries,h=c.visible;f=(c.visible=a=c.userOptions.visible=a===t?!h:a)?"show":"hide",p(["group","dataLabelsGroup","markerGroup","tracker"],function(a){c[a]&&c[a][f]()}),d.hoverSeries===c&&c.onMouseOut(),e&&d.legend.colorizeItem(c,a),c.isDirty=!0,c.options.stacking&&p(d.series,function(a){a.options.stacking&&a.visible&&(a.isDirty=!0)}),p(c.linkedSeries,function(b){b.setVisible(a,!1)}),g&&(d.isDirtyBox=!0),b!==!1&&d.redraw(),D(c,f)},setTooltipPoints:function(a){var c,d,h,i,b=[],e=this.xAxis,f=e&&e.getExtremes(),g=e?e.tooltipLen||e.len:this.chart.plotSizeX,j=[];if(this.options.enableMouseTracking!==!1&&!this.singularTooltips){for(a&&(this.tooltipPoints=null),p(this.segments||this.points,function(a){b=b.concat(a)}),e&&e.reversed&&(b=b.reverse()),this.orderTooltipPoints&&this.orderTooltipPoints(b),a=b.length,i=0;a>i;i++)if(e=b[i],c=e.x,c>=f.min&&c<=f.max)for(h=b[i+1],c=d===t?0:d+1,d=b[i+1]?C(v(0,T((e.clientX+(h?h.wrappedClientX||h.clientX:g))/2)),g):g;c>=0&&d>=c;)j[c++]=e;this.tooltipPoints=j}},show:function(){this.setVisible(!0)},hide:function(){this.setVisible(!1)},select:function(a){this.selected=a=a===t?!this.selected:a,this.checkbox&&(this.checkbox.checked=a),D(this,a?"select":"unselect")},drawTracker:S.drawTrackerGraph}),q(R,{Axis:la,Chart:Ya,Color:ya,Point:Ea,Tick:Sa,Renderer:Za,Series:O,SVGElement:P,SVGRenderer:ta,arrayMin:Na,arrayMax:Ba,charts:V,dateFormat:cb,format:Ia,pathAnim:ub,getOptions:function(){return E},hasBidiBug:Nb,isTouchDevice:Jb,numberFormat:Ga,seriesTypes:F,setOptions:function(a){return E=w(!0,E,a),Cb(),E},addEvent:K,removeEvent:W,createElement:Y,discardElement:Pa,css:G,each:p,extend:q,map:Ua,merge:w,pick:m,splat:qa,extendClass:ka,pInt:z,wrap:Ma,svg:aa,canvas:fa,vml:!aa&&!fa,product:"Highcharts",version:"4.0.1"})}(),jQuery(document).ready(function($){$("#filter_action").select2(),$("#filter_action").change(function(){var $this=$(this);"submitted"==$this.val()?$("#form-filter-input").show():($("#form-filter-input").hide(),$("#filter_form").select2("val","any form"))}),$("#filter_content").select2({query:function(query){var key=query.term;$.ajax({type:"POST",url:li_admin_ajax.ajax_url,data:{action:"leadin_get_posts_and_pages",search_term:key},success:function(data){var i,json_data=jQuery.parseJSON(data),data_test={results:[]};for(i=0;i<json_data.length;i++)data_test.results.push({id:json_data[i].post_title,text:json_data[i].post_title});query.callback(data_test)}})},initSelection:function(){$("#filter_content").val()?$("#filter_content").select2("data",{id:$("#filter_content").val(),text:$("#filter_content").val()}):$("#filter_content").select2("data",{id:"",text:"any page"})}}),$("#filter_form").select2({query:function(query){var key=query.term;$.ajax({type:"POST",url:li_admin_ajax.ajax_url,data:{action:"leadin_get_form_selectors",search_term:key},success:function(data){var i,json_data=jQuery.parseJSON(data),data_test={results:[]};for(i=0;i<json_data.length;i++)data_test.results.push({id:json_data[i],text:json_data[i]});query.callback(data_test)}})},initSelection:function(){$("#filter_form").val()?$("#filter_form").select2("data",{id:$("#filter_form").val(),text:$("#filter_form").val()}):$("#filter_form").select2("data",{id:"",text:"any form"})}}),$("#leadin-contact-status").change(function(){$("#leadin-contact-status-button").addClass("button-primary")})}),jQuery(document).ready(function($){var $bulk_opt_selected=$('.bulkactions select option[value="add_tag_to_selected"], .bulkactions select option[value="remove_tag_from_selected"], .bulkactions select option[value="delete_selected"]');$("#leadin-contacts input:checkbox").not("thead input:checkbox, tfoot input:checkbox").bind("change",function(){var cb_count=0,selected_vals="",$btn_selected=$("#leadin-export-selected-leads"),$input_selected_vals=$(".leadin-selected-contacts"),$cb_selected=$("#leadin-contacts input:checkbox:checked").not("thead input:checkbox, tfoot input:checkbox");$cb_selected.length>0?($btn_selected.attr("disabled",!1),$bulk_opt_selected.attr("disabled",!1)):($btn_selected.attr("disabled",!0),$bulk_opt_selected.attr("disabled",!0)),$cb_selected.each(function(){selected_vals+=$(this).val(),cb_count!=$cb_selected.length-1&&(selected_vals+=","),cb_count++}),$input_selected_vals.val(selected_vals),$(".selected-contacts-count").text(cb_count)}),$("#cb-select-all-1, #cb-select-all-2").bind("change",function(){var cb_count=0,selected_vals="",$this=$(this),$btn_selected=$("#leadin-export-selected-leads"),$cb_selected=$("#leadin-contacts input:checkbox").not("thead input:checkbox, tfoot input:checkbox"),$input_selected_vals=$(".leadin-selected-contacts");$cb_selected.each(function(){selected_vals+=$(this).val(),cb_count!=$cb_selected.length-1&&(selected_vals+=","),cb_count++}),$input_selected_vals.val(selected_vals),$this.is(":checked")?($btn_selected.attr("disabled",!1),$bulk_opt_selected.attr("disabled",!1)):($btn_selected.attr("disabled",!0),$bulk_opt_selected.attr("disabled",!0),$(".selected-contacts-count").text($("#contact-count").text())),$(".selected-contacts-count").text(cb_count)}),$(".postbox .handlediv").bind("click",function(){var $postbox=$(this).parent();$postbox.hasClass("closed")?$postbox.removeClass("closed"):$postbox.addClass("closed")}),$(".selected-contacts-count").text($("#contact-count").text()),$bulk_opt_selected.attr("disabled",!0),$(".bulkactions select").change(function(){{var $this=$(this);$("#contact-count").text()}"add_tag_to_all"==$this.val()||"add_tag_to_selected"==$this.val()?($("#bulk-edit-tags h2").html($("#bulk-edit-tags h2").html().replace("remove from","add to")),$("#bulk-edit-button").val("Add Tag"),$("#bulk-edit-tag-action").val("add_tag"),tb_show("","#TB_inline?width=400&height=175&inlineId=bulk-edit-tags"),$(".bulkactions select").val("-1")):("remove_tag_from_all"==$this.val()||"remove_tag_from_selected"==$this.val())&&($("#bulk-edit-tags h2").html($("#bulk-edit-tags h2").html().replace("add to","remove from")),$("#bulk-edit-button").val("Remove Tag"),$("#bulk-edit-tag-action").val("remove_tag"),tb_show("","#TB_inline?width=400&height=175&inlineId=bulk-edit-tags"),$(".bulkactions select").val("-1"))})}),function($){"undefined"==typeof $.fn.each2&&$.extend($.fn,{each2:function(c){for(var j=$([0]),i=-1,l=this.length;++i<l&&(j.context=j[0]=this[i])&&c.call(j[0],i,j)!==!1;);return this}})}(jQuery),function($,undefined){"use strict";function reinsertElement(element){var placeholder=$(document.createTextNode(""));element.before(placeholder),placeholder.before(element),placeholder.remove()}function stripDiacritics(str){function match(a){return DIACRITICS[a]||a}return str.replace(/[^\u0000-\u007E]/g,match)}function indexOf(value,array){for(var i=0,l=array.length;l>i;i+=1)if(equal(value,array[i]))return i;return-1}function measureScrollbar(){var $template=$(MEASURE_SCROLLBAR_TEMPLATE);$template.appendTo("body");var dim={width:$template.width()-$template[0].clientWidth,height:$template.height()-$template[0].clientHeight};return $template.remove(),dim}function equal(a,b){return a===b?!0:a===undefined||b===undefined?!1:null===a||null===b?!1:a.constructor===String?a+""==b+"":b.constructor===String?b+""==a+"":!1}function splitVal(string,separator){var val,i,l;if(null===string||string.length<1)return[];for(val=string.split(separator),i=0,l=val.length;l>i;i+=1)val[i]=$.trim(val[i]);return val}function getSideBorderPadding(element){return element.outerWidth(!1)-element.width()}function installKeyUpChangeEvent(element){var key="keyup-change-value";element.on("keydown",function(){$.data(element,key)===undefined&&$.data(element,key,element.val())}),element.on("keyup",function(){var val=$.data(element,key);val!==undefined&&element.val()!==val&&($.removeData(element,key),element.trigger("keyup-change"))})}function installFilteredMouseMove(element){element.on("mousemove",function(e){var lastpos=lastMousePosition;(lastpos===undefined||lastpos.x!==e.pageX||lastpos.y!==e.pageY)&&$(e.target).trigger("mousemove-filtered",e)})}function debounce(quietMillis,fn,ctx){ctx=ctx||undefined;var timeout;return function(){var args=arguments;window.clearTimeout(timeout),timeout=window.setTimeout(function(){fn.apply(ctx,args)},quietMillis)}}function installDebouncedScroll(threshold,element){var notify=debounce(threshold,function(e){element.trigger("scroll-debounced",e)});element.on("scroll",function(e){indexOf(e.target,element.get())>=0&¬ify(e)})}function focus($el){$el[0]!==document.activeElement&&window.setTimeout(function(){var range,el=$el[0],pos=$el.val().length;$el.focus();var isVisible=el.offsetWidth>0||el.offsetHeight>0;isVisible&&el===document.activeElement&&(el.setSelectionRange?el.setSelectionRange(pos,pos):el.createTextRange&&(range=el.createTextRange(),range.collapse(!1),range.select()))},0)}function getCursorInfo(el){el=$(el)[0];var offset=0,length=0;if("selectionStart"in el)offset=el.selectionStart,length=el.selectionEnd-offset;else if("selection"in document){el.focus();var sel=document.selection.createRange();length=document.selection.createRange().text.length,sel.moveStart("character",-el.value.length),offset=sel.text.length-length}return{offset:offset,length:length}}function killEvent(event){event.preventDefault(),event.stopPropagation()}function killEventImmediately(event){event.preventDefault(),event.stopImmediatePropagation()}function measureTextWidth(e){if(!sizer){var style=e[0].currentStyle||window.getComputedStyle(e[0],null);sizer=$(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:style.fontSize,fontFamily:style.fontFamily,fontStyle:style.fontStyle,fontWeight:style.fontWeight,letterSpacing:style.letterSpacing,textTransform:style.textTransform,whiteSpace:"nowrap"}),sizer.attr("class","select2-sizer"),$("body").append(sizer)}return sizer.text(e.val()),sizer.width()}function syncCssClasses(dest,src,adapter){var classes,adapted,replacements=[];classes=dest.attr("class"),classes&&(classes=""+classes,$(classes.split(" ")).each2(function(){0===this.indexOf("select2-")&&replacements.push(this)})),classes=src.attr("class"),classes&&(classes=""+classes,$(classes.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(adapted=adapter(this),adapted&&replacements.push(adapted))})),dest.attr("class",replacements.join(" "))}function markMatch(text,term,markup,escapeMarkup){var match=stripDiacritics(text.toUpperCase()).indexOf(stripDiacritics(term.toUpperCase())),tl=term.length;return 0>match?void markup.push(escapeMarkup(text)):(markup.push(escapeMarkup(text.substring(0,match))),markup.push("<span class='select2-match'>"),markup.push(escapeMarkup(text.substring(match,match+tl))),markup.push("</span>"),void markup.push(escapeMarkup(text.substring(match+tl,text.length))))}function defaultEscapeMarkup(markup){var replace_map={"\\":"\","&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return String(markup).replace(/[&<>"'\/\\]/g,function(match){return replace_map[match]})}function ajax(options){var timeout,handler=null,quietMillis=options.quietMillis||100,ajaxUrl=options.url,self=this;
|
6 |
+
return function(query){window.clearTimeout(timeout),timeout=window.setTimeout(function(){var data=options.data,url=ajaxUrl,transport=options.transport||$.fn.select2.ajaxDefaults.transport,deprecated={type:options.type||"GET",cache:options.cache||!1,jsonpCallback:options.jsonpCallback||undefined,dataType:options.dataType||"json"},params=$.extend({},$.fn.select2.ajaxDefaults.params,deprecated);data=data?data.call(self,query.term,query.page,query.context):null,url="function"==typeof url?url.call(self,query.term,query.page,query.context):url,handler&&"function"==typeof handler.abort&&handler.abort(),options.params&&($.isFunction(options.params)?$.extend(params,options.params.call(self)):$.extend(params,options.params)),$.extend(params,{url:url,dataType:options.dataType,data:data,success:function(data){var results=options.results(data,query.page);query.callback(results)}}),handler=transport.call(self,params)},quietMillis)}}function local(options){var dataText,tmp,data=options,text=function(item){return""+item.text};$.isArray(data)&&(tmp=data,data={results:tmp}),$.isFunction(data)===!1&&(tmp=data,data=function(){return tmp});var dataItem=data();return dataItem.text&&(text=dataItem.text,$.isFunction(text)||(dataText=dataItem.text,text=function(item){return item[dataText]})),function(query){var process,t=query.term,filtered={results:[]};return""===t?void query.callback(data()):(process=function(datum,collection){var group,attr;if(datum=datum[0],datum.children){group={};for(attr in datum)datum.hasOwnProperty(attr)&&(group[attr]=datum[attr]);group.children=[],$(datum.children).each2(function(i,childDatum){process(childDatum,group.children)}),(group.children.length||query.matcher(t,text(group),datum))&&collection.push(group)}else query.matcher(t,text(datum),datum)&&collection.push(datum)},$(data().results).each2(function(i,datum){process(datum,filtered.results)}),void query.callback(filtered))}}function tags(data){var isFunc=$.isFunction(data);return function(query){var t=query.term,filtered={results:[]},result=isFunc?data(query):data;$.isArray(result)&&($(result).each(function(){var isObject=this.text!==undefined,text=isObject?this.text:this;(""===t||query.matcher(t,text))&&filtered.results.push(isObject?this:{id:this,text:this})}),query.callback(filtered))}}function checkFormatter(formatter,formatterName){if($.isFunction(formatter))return!0;if(!formatter)return!1;if("string"==typeof formatter)return!0;throw new Error(formatterName+" must be a string, function, or falsy value")}function evaluate(val){if($.isFunction(val)){var args=Array.prototype.slice.call(arguments,1);return val.apply(null,args)}return val}function countResults(results){var count=0;return $.each(results,function(i,item){item.children?count+=countResults(item.children):count++}),count}function defaultTokenizer(input,selection,selectCallback,opts){var token,index,i,l,separator,original=input,dupe=!1;if(!opts.createSearchChoice||!opts.tokenSeparators||opts.tokenSeparators.length<1)return undefined;for(;;){for(index=-1,i=0,l=opts.tokenSeparators.length;l>i&&(separator=opts.tokenSeparators[i],index=input.indexOf(separator),!(index>=0));i++);if(0>index)break;if(token=input.substring(0,index),input=input.substring(index+separator.length),token.length>0&&(token=opts.createSearchChoice.call(this,token,selection),token!==undefined&&null!==token&&opts.id(token)!==undefined&&null!==opts.id(token))){for(dupe=!1,i=0,l=selection.length;l>i;i++)if(equal(opts.id(token),opts.id(selection[i]))){dupe=!0;break}dupe||selectCallback(token)}}return original!==input?input:void 0}function cleanupJQueryElements(){var self=this;Array.prototype.forEach.call(arguments,function(element){self[element].remove(),self[element]=null})}function clazz(SuperClass,methods){var constructor=function(){};return constructor.prototype=new SuperClass,constructor.prototype.constructor=constructor,constructor.prototype.parent=SuperClass.prototype,constructor.prototype=$.extend(constructor.prototype,methods),constructor}if(window.Select2===undefined){var KEY,AbstractSelect2,SingleSelect2,MultiSelect2,nextUid,sizer,$document,scrollBarDimensions,lastMousePosition={x:0,y:0},KEY={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(k){switch(k=k.which?k.which:k){case KEY.LEFT:case KEY.RIGHT:case KEY.UP:case KEY.DOWN:return!0}return!1},isControl:function(e){var k=e.which;switch(k){case KEY.SHIFT:case KEY.CTRL:case KEY.ALT:return!0}return e.metaKey?!0:!1},isFunctionKey:function(k){return k=k.which?k.which:k,k>=112&&123>=k}},MEASURE_SCROLLBAR_TEMPLATE="<div class='select2-measure-scrollbar'></div>",DIACRITICS={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z"};$document=$(document),nextUid=function(){var counter=1;return function(){return counter++}}(),$document.on("mousemove",function(e){lastMousePosition.x=e.pageX,lastMousePosition.y=e.pageY}),AbstractSelect2=clazz(Object,{bind:function(func){var self=this;return function(){func.apply(self,arguments)}},init:function(opts){var results,search,resultsSelector=".select2-results";this.opts=opts=this.prepareOpts(opts),this.id=opts.id,opts.element.data("select2")!==undefined&&null!==opts.element.data("select2")&&opts.element.data("select2").destroy(),this.container=this.createContainer(),this.liveRegion=$("<span>",{role:"status","aria-live":"polite"}).addClass("select2-hidden-accessible").appendTo(document.body),this.containerId="s2id_"+(opts.element.attr("id")||"autogen"+nextUid()),this.containerEventName=this.containerId.replace(/([.])/g,"_").replace(/([;&,\-\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.container.attr("title",opts.element.attr("title")),this.body=$("body"),syncCssClasses(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",opts.element.attr("style")),this.container.css(evaluate(opts.containerCss)),this.container.addClass(evaluate(opts.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",killEvent),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),syncCssClasses(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(evaluate(opts.dropdownCssClass)),this.dropdown.data("select2",this),this.dropdown.on("click",killEvent),this.results=results=this.container.find(resultsSelector),this.search=search=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",killEvent),installFilteredMouseMove(this.results),this.dropdown.on("mousemove-filtered",resultsSelector,this.bind(this.highlightUnderEvent)),this.dropdown.on("touchstart touchmove touchend",resultsSelector,this.bind(function(event){this._touchEvent=!0,this.highlightUnderEvent(event)})),this.dropdown.on("touchmove",resultsSelector,this.bind(this.touchMoved)),this.dropdown.on("touchstart touchend",resultsSelector,this.bind(this.clearTouchMoved)),this.dropdown.on("click",this.bind(function(){this._touchEvent&&(this._touchEvent=!1,this.selectHighlighted())})),installDebouncedScroll(80,this.results),this.dropdown.on("scroll-debounced",resultsSelector,this.bind(this.loadMoreIfNeeded)),$(this.container).on("change",".select2-input",function(e){e.stopPropagation()}),$(this.dropdown).on("change",".select2-input",function(e){e.stopPropagation()}),$.fn.mousewheel&&results.mousewheel(function(e,delta,deltaX,deltaY){var top=results.scrollTop();deltaY>0&&0>=top-deltaY?(results.scrollTop(0),killEvent(e)):0>deltaY&&results.get(0).scrollHeight-results.scrollTop()+deltaY<=results.height()&&(results.scrollTop(results.get(0).scrollHeight-results.height()),killEvent(e))}),installKeyUpChangeEvent(search),search.on("keyup-change input paste",this.bind(this.updateResults)),search.on("focus",function(){search.addClass("select2-focused")}),search.on("blur",function(){search.removeClass("select2-focused")}),this.dropdown.on("mouseup",resultsSelector,this.bind(function(e){$(e.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(e),this.selectHighlighted(e))})),this.dropdown.on("click mouseup mousedown touchstart touchend focusin",function(e){e.stopPropagation()}),this.nextSearchTerm=undefined,$.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==opts.maximumInputLength&&this.search.attr("maxlength",opts.maximumInputLength);var disabled=opts.element.prop("disabled");disabled===undefined&&(disabled=!1),this.enable(!disabled);var readonly=opts.element.prop("readonly");readonly===undefined&&(readonly=!1),this.readonly(readonly),scrollBarDimensions=scrollBarDimensions||measureScrollbar(),this.autofocus=opts.element.prop("autofocus"),opts.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.search.attr("placeholder",opts.searchInputPlaceholder)},destroy:function(){var element=this.opts.element,select2=element.data("select2");this.close(),this.propertyObserver&&(this.propertyObserver.disconnect(),this.propertyObserver=null),select2!==undefined&&(select2.container.remove(),select2.liveRegion.remove(),select2.dropdown.remove(),element.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?element.attr({tabindex:this.elementTabIndex}):element.removeAttr("tabindex"),element.show()),cleanupJQueryElements.call(this,"container","liveRegion","dropdown","results","search")},optionToData:function(element){return element.is("option")?{id:element.prop("value"),text:element.text(),element:element.get(),css:element.attr("class"),disabled:element.prop("disabled"),locked:equal(element.attr("locked"),"locked")||equal(element.data("locked"),!0)}:element.is("optgroup")?{text:element.attr("label"),children:[],element:element.get(),css:element.attr("class")}:void 0},prepareOpts:function(opts){var element,select,idKey,ajaxUrl,self=this;if(element=opts.element,"select"===element.get(0).tagName.toLowerCase()&&(this.select=select=opts.element),select&&$.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in opts)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),opts=$.extend({},{populateResults:function(container,results,query){var populate,id=this.opts.id,liveRegion=this.liveRegion;(populate=function(results,container,depth){var i,l,result,selectable,disabled,compound,node,label,innerContainer,formatted;for(results=opts.sortResults(results,container,query),i=0,l=results.length;l>i;i+=1)result=results[i],disabled=result.disabled===!0,selectable=!disabled&&id(result)!==undefined,compound=result.children&&result.children.length>0,node=$("<li></li>"),node.addClass("select2-results-dept-"+depth),node.addClass("select2-result"),node.addClass(selectable?"select2-result-selectable":"select2-result-unselectable"),disabled&&node.addClass("select2-disabled"),compound&&node.addClass("select2-result-with-children"),node.addClass(self.opts.formatResultCssClass(result)),node.attr("role","presentation"),label=$(document.createElement("div")),label.addClass("select2-result-label"),label.attr("id","select2-result-label-"+nextUid()),label.attr("role","option"),formatted=opts.formatResult(result,label,query,self.opts.escapeMarkup),formatted!==undefined&&(label.html(formatted),node.append(label)),compound&&(innerContainer=$("<ul></ul>"),innerContainer.addClass("select2-result-sub"),populate(result.children,innerContainer,depth+1),node.append(innerContainer)),node.data("select2-data",result),container.append(node);liveRegion.text(opts.formatMatches(results.length))})(results,container,0)}},$.fn.select2.defaults,opts),"function"!=typeof opts.id&&(idKey=opts.id,opts.id=function(e){return e[idKey]}),$.isArray(opts.element.data("select2Tags"))){if("tags"in opts)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+opts.element.attr("id");opts.tags=opts.element.data("select2Tags")}if(select?(opts.query=this.bind(function(query){var children,placeholderOption,process,data={results:[],more:!1},term=query.term;process=function(element,collection){var group;element.is("option")?query.matcher(term,element.text(),element)&&collection.push(self.optionToData(element)):element.is("optgroup")&&(group=self.optionToData(element),element.children().each2(function(i,elm){process(elm,group.children)}),group.children.length>0&&collection.push(group))},children=element.children(),this.getPlaceholder()!==undefined&&children.length>0&&(placeholderOption=this.getPlaceholderOption(),placeholderOption&&(children=children.not(placeholderOption))),children.each2(function(i,elm){process(elm,data.results)}),query.callback(data)}),opts.id=function(e){return e.id}):"query"in opts||("ajax"in opts?(ajaxUrl=opts.element.data("ajax-url"),ajaxUrl&&ajaxUrl.length>0&&(opts.ajax.url=ajaxUrl),opts.query=ajax.call(opts.element,opts.ajax)):"data"in opts?opts.query=local(opts.data):"tags"in opts&&(opts.query=tags(opts.tags),opts.createSearchChoice===undefined&&(opts.createSearchChoice=function(term){return{id:$.trim(term),text:$.trim(term)}}),opts.initSelection===undefined&&(opts.initSelection=function(element,callback){var data=[];$(splitVal(element.val(),opts.separator)).each(function(){var obj={id:this,text:this},tags=opts.tags;$.isFunction(tags)&&(tags=tags()),$(tags).each(function(){return equal(this.id,obj.id)?(obj=this,!1):void 0}),data.push(obj)}),callback(data)}))),"function"!=typeof opts.query)throw"query function not defined for Select2 "+opts.element.attr("id");if("top"===opts.createSearchChoicePosition)opts.createSearchChoicePosition=function(list,item){list.unshift(item)};else if("bottom"===opts.createSearchChoicePosition)opts.createSearchChoicePosition=function(list,item){list.push(item)};else if("function"!=typeof opts.createSearchChoicePosition)throw"invalid createSearchChoicePosition option must be 'top', 'bottom' or a custom function";return opts},monitorSource:function(){var sync,observer,el=this.opts.element;el.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),sync=this.bind(function(){var disabled=el.prop("disabled");disabled===undefined&&(disabled=!1),this.enable(!disabled);var readonly=el.prop("readonly");readonly===undefined&&(readonly=!1),this.readonly(readonly),syncCssClasses(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(evaluate(this.opts.containerCssClass)),syncCssClasses(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(evaluate(this.opts.dropdownCssClass))}),el.length&&el[0].attachEvent&&el.each(function(){this.attachEvent("onpropertychange",sync)}),observer=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,observer!==undefined&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new observer(function(mutations){mutations.forEach(sync)}),this.propertyObserver.observe(el.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(data){var evt=$.Event("select2-selecting",{val:this.id(data),object:data});return this.opts.element.trigger(evt),!evt.isDefaultPrevented()},triggerChange:function(details){details=details||{},details=$.extend({},details,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(details),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var enabled=this._enabled&&!this._readonly,disabled=!enabled;return enabled===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",disabled),this.close(),this.enabledInterface=enabled,!0)},enable:function(enabled){enabled===undefined&&(enabled=!0),this._enabled!==enabled&&(this._enabled=enabled,this.opts.element.prop("disabled",!enabled),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(enabled){enabled===undefined&&(enabled=!1),this._readonly!==enabled&&(this._readonly=enabled,this.opts.element.prop("readonly",enabled),this.enableInterface())},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var bodyOffset,above,changeDirection,css,resultsListNode,$dropdown=this.dropdown,offset=this.container.offset(),height=this.container.outerHeight(!1),width=this.container.outerWidth(!1),dropHeight=$dropdown.outerHeight(!1),$window=$(window),windowWidth=$window.width(),windowHeight=$window.height(),viewPortRight=$window.scrollLeft()+windowWidth,viewportBottom=$window.scrollTop()+windowHeight,dropTop=offset.top+height,dropLeft=offset.left,enoughRoomBelow=viewportBottom>=dropTop+dropHeight,enoughRoomAbove=offset.top-dropHeight>=$window.scrollTop(),dropWidth=$dropdown.outerWidth(!1),enoughRoomOnRight=viewPortRight>=dropLeft+dropWidth,aboveNow=$dropdown.hasClass("select2-drop-above");aboveNow?(above=!0,!enoughRoomAbove&&enoughRoomBelow&&(changeDirection=!0,above=!1)):(above=!1,!enoughRoomBelow&&enoughRoomAbove&&(changeDirection=!0,above=!0)),changeDirection&&($dropdown.hide(),offset=this.container.offset(),height=this.container.outerHeight(!1),width=this.container.outerWidth(!1),dropHeight=$dropdown.outerHeight(!1),viewPortRight=$window.scrollLeft()+windowWidth,viewportBottom=$window.scrollTop()+windowHeight,dropTop=offset.top+height,dropLeft=offset.left,dropWidth=$dropdown.outerWidth(!1),enoughRoomOnRight=viewPortRight>=dropLeft+dropWidth,$dropdown.show(),this.focusSearch()),this.opts.dropdownAutoWidth?(resultsListNode=$(".select2-results",$dropdown)[0],$dropdown.addClass("select2-drop-auto-width"),$dropdown.css("width",""),dropWidth=$dropdown.outerWidth(!1)+(resultsListNode.scrollHeight===resultsListNode.clientHeight?0:scrollBarDimensions.width),dropWidth>width?width=dropWidth:dropWidth=width,dropHeight=$dropdown.outerHeight(!1),enoughRoomOnRight=viewPortRight>=dropLeft+dropWidth):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body.css("position")&&(bodyOffset=this.body.offset(),dropTop-=bodyOffset.top,dropLeft-=bodyOffset.left),enoughRoomOnRight||(dropLeft=offset.left+this.container.outerWidth(!1)-dropWidth),css={left:dropLeft,width:width},above?(css.top=offset.top-dropHeight,css.bottom="auto",this.container.addClass("select2-drop-above"),$dropdown.addClass("select2-drop-above")):(css.top=dropTop,css.bottom="auto",this.container.removeClass("select2-drop-above"),$dropdown.removeClass("select2-drop-above")),css=$.extend(css,evaluate(this.opts.dropdownCss)),$dropdown.css(css)},shouldOpen:function(){var event;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(event=$.Event("select2-opening"),this.opts.element.trigger(event),!event.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){var mask,cid=this.containerEventName,scroll="scroll."+cid,resize="resize."+cid,orient="orientationchange."+cid;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body.children().last()[0]&&this.dropdown.detach().appendTo(this.body),mask=$("#select2-drop-mask"),0==mask.length&&(mask=$(document.createElement("div")),mask.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),mask.hide(),mask.appendTo(this.body),mask.on("mousedown touchstart click",function(e){reinsertElement(mask);var self,dropdown=$("#select2-drop");dropdown.length>0&&(self=dropdown.data("select2"),self.opts.selectOnBlur&&self.selectHighlighted({noFocus:!0}),self.close(),e.preventDefault(),e.stopPropagation())})),this.dropdown.prev()[0]!==mask[0]&&this.dropdown.before(mask),$("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),mask.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var that=this;this.container.parents().add(window).each(function(){$(this).on(resize+" "+scroll+" "+orient,function(){that.opened()&&that.positionDropdown()})})},close:function(){if(this.opened()){var cid=this.containerEventName,scroll="scroll."+cid,resize="resize."+cid,orient="orientationchange."+cid;this.container.parents().add(window).each(function(){$(this).off(scroll).off(resize).off(orient)}),this.clearDropdownAlignmentPreference(),$("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger($.Event("select2-close"))}},externalSearch:function(term){this.open(),this.search.val(term),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return evaluate(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var children,index,child,hb,rb,y,more,results=this.results;if(index=this.highlight(),!(0>index)){if(0==index)return void results.scrollTop(0);children=this.findHighlightableChoices().find(".select2-result-label"),child=$(children[index]),hb=child.offset().top+child.outerHeight(!0),index===children.length-1&&(more=results.find("li.select2-more-results"),more.length>0&&(hb=more.offset().top+more.outerHeight(!0))),rb=results.offset().top+results.outerHeight(!0),hb>rb&&results.scrollTop(results.scrollTop()+(hb-rb)),y=child.offset().top-results.offset().top,0>y&&"none"!=child.css("display")&&results.scrollTop(results.scrollTop()+y)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled):not(.select2-selected)")},moveHighlight:function(delta){for(var choices=this.findHighlightableChoices(),index=this.highlight();index>-1&&index<choices.length;){index+=delta;var choice=$(choices[index]);if(choice.hasClass("select2-result-selectable")&&!choice.hasClass("select2-disabled")&&!choice.hasClass("select2-selected")){this.highlight(index);break}}},highlight:function(index){var choice,data,choices=this.findHighlightableChoices();return 0===arguments.length?indexOf(choices.filter(".select2-highlighted")[0],choices.get()):(index>=choices.length&&(index=choices.length-1),0>index&&(index=0),this.removeHighlight(),choice=$(choices[index]),choice.addClass("select2-highlighted"),this.search.attr("aria-activedescendant",choice.find(".select2-result-label").attr("id")),this.ensureHighlightVisible(),this.liveRegion.text(choice.text()),data=choice.data("select2-data"),void(data&&this.opts.element.trigger({type:"select2-highlight",val:this.id(data),choice:data})))},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},touchMoved:function(){this._touchMoved=!0},clearTouchMoved:function(){this._touchMoved=!1},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(event){var el=$(event.target).closest(".select2-result-selectable");if(el.length>0&&!el.is(".select2-highlighted")){var choices=this.findHighlightableChoices();this.highlight(choices.index(el))}else 0==el.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var below,results=this.results,more=results.find("li.select2-more-results"),page=this.resultsPage+1,self=this,term=this.search.val(),context=this.context;0!==more.length&&(below=more.offset().top-results.offset().top-results.height(),below<=this.opts.loadMorePadding&&(more.addClass("select2-active"),this.opts.query({element:this.opts.element,term:term,page:page,context:context,matcher:this.opts.matcher,callback:this.bind(function(data){self.opened()&&(self.opts.populateResults.call(this,results,data.results,{term:term,page:page,context:context}),self.postprocessResults(data,!1,!1),data.more===!0?(more.detach().appendTo(results).text(evaluate(self.opts.formatLoadMore,page+1)),window.setTimeout(function(){self.loadMoreIfNeeded()},10)):more.remove(),self.positionDropdown(),self.resultsPage=page,self.context=data.context,this.opts.element.trigger({type:"select2-loaded",items:data}))})})))},tokenize:function(){},updateResults:function(initial){function postRender(){search.removeClass("select2-active"),self.positionDropdown(),self.liveRegion.text(results.find(".select2-no-results,.select2-selection-limit,.select2-searching").length?results.text():self.opts.formatMatches(results.find(".select2-result-selectable").length))}function render(html){results.html(html),postRender()}var data,input,queryNumber,search=this.search,results=this.results,opts=this.opts,self=this,term=search.val(),lastTerm=$.data(this.container,"select2-last-term");if((initial===!0||!lastTerm||!equal(term,lastTerm))&&($.data(this.container,"select2-last-term",term),initial===!0||this.showSearchInput!==!1&&this.opened())){queryNumber=++this.queryCount;var maxSelSize=this.getMaximumSelectionSize();if(maxSelSize>=1&&(data=this.data(),$.isArray(data)&&data.length>=maxSelSize&&checkFormatter(opts.formatSelectionTooBig,"formatSelectionTooBig")))return void render("<li class='select2-selection-limit'>"+evaluate(opts.formatSelectionTooBig,maxSelSize)+"</li>");
|
7 |
+
if(search.val().length<opts.minimumInputLength)return render(checkFormatter(opts.formatInputTooShort,"formatInputTooShort")?"<li class='select2-no-results'>"+evaluate(opts.formatInputTooShort,search.val(),opts.minimumInputLength)+"</li>":""),void(initial&&this.showSearch&&this.showSearch(!0));if(opts.maximumInputLength&&search.val().length>opts.maximumInputLength)return void render(checkFormatter(opts.formatInputTooLong,"formatInputTooLong")?"<li class='select2-no-results'>"+evaluate(opts.formatInputTooLong,search.val(),opts.maximumInputLength)+"</li>":"");opts.formatSearching&&0===this.findHighlightableChoices().length&&render("<li class='select2-searching'>"+evaluate(opts.formatSearching)+"</li>"),search.addClass("select2-active"),this.removeHighlight(),input=this.tokenize(),input!=undefined&&null!=input&&search.val(input),this.resultsPage=1,opts.query({element:opts.element,term:search.val(),page:this.resultsPage,context:null,matcher:opts.matcher,callback:this.bind(function(data){var def;if(queryNumber==this.queryCount){if(!this.opened())return void this.search.removeClass("select2-active");if(this.context=data.context===undefined?null:data.context,this.opts.createSearchChoice&&""!==search.val()&&(def=this.opts.createSearchChoice.call(self,search.val(),data.results),def!==undefined&&null!==def&&self.id(def)!==undefined&&null!==self.id(def)&&0===$(data.results).filter(function(){return equal(self.id(this),self.id(def))}).length&&this.opts.createSearchChoicePosition(data.results,def)),0===data.results.length&&checkFormatter(opts.formatNoMatches,"formatNoMatches"))return void render("<li class='select2-no-results'>"+evaluate(opts.formatNoMatches,search.val())+"</li>");results.empty(),self.opts.populateResults.call(this,results,data.results,{term:search.val(),page:this.resultsPage,context:null}),data.more===!0&&checkFormatter(opts.formatLoadMore,"formatLoadMore")&&(results.append("<li class='select2-more-results'>"+self.opts.escapeMarkup(evaluate(opts.formatLoadMore,this.resultsPage))+"</li>"),window.setTimeout(function(){self.loadMoreIfNeeded()},10)),this.postprocessResults(data,initial),postRender(),this.opts.element.trigger({type:"select2-loaded",items:data})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){focus(this.search)},selectHighlighted:function(options){if(this._touchMoved)return void this.clearTouchMoved();var index=this.highlight(),highlighted=this.results.find(".select2-highlighted"),data=highlighted.closest(".select2-result").data("select2-data");data?(this.highlight(index),this.onSelect(data,options)):options&&options.noFocus&&this.close()},getPlaceholder:function(){var placeholderOption;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((placeholderOption=this.getPlaceholderOption())!==undefined?placeholderOption.text():undefined)},getPlaceholderOption:function(){if(this.select){var firstOption=this.select.children("option").first();if(this.opts.placeholderOption!==undefined)return"first"===this.opts.placeholderOption&&firstOption||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===$.trim(firstOption.text())&&""===firstOption.val())return firstOption}},initContainerWidth:function(){function resolveContainerWidth(){var style,attrs,matches,i,l,attr;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(style=this.opts.element.attr("style"),style!==undefined)for(attrs=style.split(";"),i=0,l=attrs.length;l>i;i+=1)if(attr=attrs[i].replace(/\s/g,""),matches=attr.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==matches&&matches.length>=1)return matches[1];return"resolve"===this.opts.width?(style=this.opts.element.css("width"),style.indexOf("%")>0?style:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return $.isFunction(this.opts.width)?this.opts.width():this.opts.width}var width=resolveContainerWidth.call(this);null!==width&&this.container.css("width",width)}}),SingleSelect2=clazz(AbstractSelect2,{createContainer:function(){var container=$(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'> </span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow' role='presentation'><b role='presentation'></b></span>","</a>","<label for='' class='select2-offscreen'></label>","<input class='select2-focusser select2-offscreen' type='text' aria-haspopup='true' role='button' />","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input' role='combobox' aria-expanded='true'"," aria-autocomplete='list' />"," </div>"," <ul class='select2-results' role='listbox'>"," </ul>","</div>"].join(""));return container},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var el,range,len;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.opts.shouldFocusInput(this)&&(this.search.focus(),el=this.search.get(0),el.createTextRange?(range=el.createTextRange(),range.collapse(!1),range.select()):el.setSelectionRange&&(len=this.search.val().length,el.setSelectionRange(len,len))),""===this.search.val()&&this.nextSearchTerm!=undefined&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger($.Event("select2-open"))},close:function(){this.opened()&&(this.parent.close.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.prop("disabled",!1),this.opts.shouldFocusInput(this)&&this.focusser.focus()},destroy:function(){$("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),cleanupJQueryElements.call(this,"selection","focusser")},initContainer:function(){var selection,elementLabel,container=this.container,dropdown=this.dropdown,idSuffix=nextUid();this.showSearch(this.opts.minimumResultsForSearch<0?!1:!0),this.selection=selection=container.find(".select2-choice"),this.focusser=container.find(".select2-focusser"),selection.find(".select2-chosen").attr("id","select2-chosen-"+idSuffix),this.focusser.attr("aria-labelledby","select2-chosen-"+idSuffix),this.results.attr("id","select2-results-"+idSuffix),this.search.attr("aria-owns","select2-results-"+idSuffix),this.focusser.attr("id","s2id_autogen"+idSuffix),elementLabel=$("label[for='"+this.opts.element.attr("id")+"']"),this.focusser.prev().text(elementLabel.text()).attr("for",this.focusser.attr("id"));var originalTitle=this.opts.element.attr("title");this.opts.element.attr("title",originalTitle||elementLabel.text()),this.focusser.attr("tabindex",this.elementTabIndex),this.search.attr("id",this.focusser.attr("id")+"_search"),this.search.prev().text($("label[for='"+this.focusser.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){if(e.which===KEY.PAGE_UP||e.which===KEY.PAGE_DOWN)return void killEvent(e);switch(e.which){case KEY.UP:case KEY.DOWN:return this.moveHighlight(e.which===KEY.UP?-1:1),void killEvent(e);case KEY.ENTER:return this.selectHighlighted(),void killEvent(e);case KEY.TAB:return void this.selectHighlighted({noFocus:!0});case KEY.ESC:return this.cancel(e),void killEvent(e)}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body.get(0)&&window.setTimeout(this.bind(function(){this.opened()&&this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()&&e.which!==KEY.TAB&&!KEY.isControl(e)&&!KEY.isFunctionKey(e)&&e.which!==KEY.ESC){if(this.opts.openOnEnter===!1&&e.which===KEY.ENTER)return void killEvent(e);if(e.which==KEY.DOWN||e.which==KEY.UP||e.which==KEY.ENTER&&this.opts.openOnEnter){if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return;return this.open(),void killEvent(e)}return e.which==KEY.DELETE||e.which==KEY.BACKSPACE?(this.opts.allowClear&&this.clear(),void killEvent(e)):void 0}})),installKeyUpChangeEvent(this.focusser),this.focusser.on("keyup-change input",this.bind(function(e){if(this.opts.minimumResultsForSearch>=0){if(e.stopPropagation(),this.opened())return;this.open()}})),selection.on("mousedown touchstart","abbr",this.bind(function(e){this.isInterfaceEnabled()&&(this.clear(),killEventImmediately(e),this.close(),this.selection.focus())})),selection.on("mousedown touchstart",this.bind(function(e){reinsertElement(selection),this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),killEvent(e)})),dropdown.on("mousedown touchstart",this.bind(function(){this.opts.shouldFocusInput(this)&&this.search.focus()})),selection.on("focus",this.bind(function(e){killEvent(e)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger($.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(triggerChange){var data=this.selection.data("select2-data");if(data){var evt=$.Event("select2-clearing");if(this.opts.element.trigger(evt),evt.isDefaultPrevented())return;var placeholderOption=this.getPlaceholderOption();this.opts.element.val(placeholderOption?placeholderOption.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),triggerChange!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(data),choice:data}),this.triggerChange({removed:data}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var self=this;this.opts.initSelection.call(null,this.opts.element,function(selected){selected!==undefined&&null!==selected&&(self.updateSelection(selected),self.close(),self.setPlaceholder(),self.nextSearchTerm=self.opts.nextSearchTerm(selected,self.search.val()))})}},isPlaceholderOptionSelected:function(){var placeholderOption;return this.getPlaceholder()===undefined?!1:(placeholderOption=this.getPlaceholderOption())!==undefined&&placeholderOption.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===undefined||null===this.opts.element.val()},prepareOpts:function(){var opts=this.parent.prepareOpts.apply(this,arguments),self=this;return"select"===opts.element.get(0).tagName.toLowerCase()?opts.initSelection=function(element,callback){var selected=element.find("option").filter(function(){return this.selected&&!this.disabled});callback(self.optionToData(selected))}:"data"in opts&&(opts.initSelection=opts.initSelection||function(element,callback){var id=element.val(),match=null;opts.query({matcher:function(term,text,el){var is_match=equal(id,opts.id(el));return is_match&&(match=el),is_match},callback:$.isFunction(callback)?function(){callback(match)}:$.noop})}),opts},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===undefined?undefined:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var placeholder=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&placeholder!==undefined){if(this.select&&this.getPlaceholderOption()===undefined)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(placeholder)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(data,initial,noHighlightUpdate){var selected=0,self=this;if(this.findHighlightableChoices().each2(function(i,elm){return equal(self.id(elm.data("select2-data")),self.opts.element.val())?(selected=i,!1):void 0}),noHighlightUpdate!==!1&&this.highlight(initial===!0&&selected>=0?selected:0),initial===!0){var min=this.opts.minimumResultsForSearch;min>=0&&this.showSearch(countResults(data.results)>=min)}},showSearch:function(showSearchInput){this.showSearchInput!==showSearchInput&&(this.showSearchInput=showSearchInput,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!showSearchInput),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!showSearchInput),$(this.dropdown,this.container).toggleClass("select2-with-searchbox",showSearchInput))},onSelect:function(data,options){if(this.triggerSelect(data)){var old=this.opts.element.val(),oldData=this.data();this.opts.element.val(this.id(data)),this.updateSelection(data),this.opts.element.trigger({type:"select2-selected",val:this.id(data),choice:data}),this.nextSearchTerm=this.opts.nextSearchTerm(data,this.search.val()),this.close(),options&&options.noFocus||!this.opts.shouldFocusInput(this)||this.focusser.focus(),equal(old,this.id(data))||this.triggerChange({added:data,removed:oldData})}},updateSelection:function(data){var formatted,cssClass,container=this.selection.find(".select2-chosen");this.selection.data("select2-data",data),container.empty(),null!==data&&(formatted=this.opts.formatSelection(data,container,this.opts.escapeMarkup)),formatted!==undefined&&container.append(formatted),cssClass=this.opts.formatSelectionCssClass(data,container),cssClass!==undefined&&container.addClass(cssClass),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==undefined&&this.container.addClass("select2-allowclear")},val:function(){var val,triggerChange=!1,data=null,self=this,oldData=this.data();if(0===arguments.length)return this.opts.element.val();if(val=arguments[0],arguments.length>1&&(triggerChange=arguments[1]),this.select)this.select.val(val).find("option").filter(function(){return this.selected}).each2(function(i,elm){return data=self.optionToData(elm),!1}),this.updateSelection(data),this.setPlaceholder(),triggerChange&&this.triggerChange({added:data,removed:oldData});else{if(!val&&0!==val)return void this.clear(triggerChange);if(this.opts.initSelection===undefined)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(val),this.opts.initSelection(this.opts.element,function(data){self.opts.element.val(data?self.id(data):""),self.updateSelection(data),self.setPlaceholder(),triggerChange&&self.triggerChange({added:data,removed:oldData})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(value){var data,triggerChange=!1;return 0===arguments.length?(data=this.selection.data("select2-data"),data==undefined&&(data=null),data):(arguments.length>1&&(triggerChange=arguments[1]),void(value?(data=this.data(),this.opts.element.val(value?this.id(value):""),this.updateSelection(value),triggerChange&&this.triggerChange({added:value,removed:data})):this.clear(triggerChange)))}}),MultiSelect2=clazz(AbstractSelect2,{createContainer:function(){var container=$(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <label for='' class='select2-offscreen'></label>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return container},prepareOpts:function(){var opts=this.parent.prepareOpts.apply(this,arguments),self=this;return"select"===opts.element.get(0).tagName.toLowerCase()?opts.initSelection=function(element,callback){var data=[];element.find("option").filter(function(){return this.selected&&!this.disabled}).each2(function(i,elm){data.push(self.optionToData(elm))}),callback(data)}:"data"in opts&&(opts.initSelection=opts.initSelection||function(element,callback){var ids=splitVal(element.val(),opts.separator),matches=[];opts.query({matcher:function(term,text,el){var is_match=$.grep(ids,function(id){return equal(id,opts.id(el))}).length;return is_match&&matches.push(el),is_match},callback:$.isFunction(callback)?function(){for(var ordered=[],i=0;i<ids.length;i++)for(var id=ids[i],j=0;j<matches.length;j++){var match=matches[j];if(equal(id,opts.id(match))){ordered.push(match),matches.splice(j,1);break}}callback(ordered)}:$.noop})}),opts},selectChoice:function(choice){var selected=this.container.find(".select2-search-choice-focus");selected.length&&choice&&choice[0]==selected[0]||(selected.length&&this.opts.element.trigger("choice-deselected",selected),selected.removeClass("select2-search-choice-focus"),choice&&choice.length&&(this.close(),choice.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",choice)))},destroy:function(){$("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments),cleanupJQueryElements.call(this,"searchContainer","selection")},initContainer:function(){var selection,selector=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=selection=this.container.find(selector);var _this=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",function(){_this.search[0].focus(),_this.selectChoice($(this))}),this.search.attr("id","s2id_autogen"+nextUid()),this.search.prev().text($("label[for='"+this.opts.element.attr("id")+"']").text()).attr("for",this.search.attr("id")),this.search.on("input paste",this.bind(function(){this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(e){if(this.isInterfaceEnabled()){++this.keydowns;var selected=selection.find(".select2-search-choice-focus"),prev=selected.prev(".select2-search-choice:not(.select2-locked)"),next=selected.next(".select2-search-choice:not(.select2-locked)"),pos=getCursorInfo(this.search);if(selected.length&&(e.which==KEY.LEFT||e.which==KEY.RIGHT||e.which==KEY.BACKSPACE||e.which==KEY.DELETE||e.which==KEY.ENTER)){var selectedChoice=selected;return e.which==KEY.LEFT&&prev.length?selectedChoice=prev:e.which==KEY.RIGHT?selectedChoice=next.length?next:null:e.which===KEY.BACKSPACE?this.unselect(selected.first())&&(this.search.width(10),selectedChoice=prev.length?prev:next):e.which==KEY.DELETE?this.unselect(selected.first())&&(this.search.width(10),selectedChoice=next.length?next:null):e.which==KEY.ENTER&&(selectedChoice=null),this.selectChoice(selectedChoice),killEvent(e),void(selectedChoice&&selectedChoice.length||this.open())}if((e.which===KEY.BACKSPACE&&1==this.keydowns||e.which==KEY.LEFT)&&0==pos.offset&&!pos.length)return this.selectChoice(selection.find(".select2-search-choice:not(.select2-locked)").last()),void killEvent(e);if(this.selectChoice(null),this.opened())switch(e.which){case KEY.UP:case KEY.DOWN:return this.moveHighlight(e.which===KEY.UP?-1:1),void killEvent(e);case KEY.ENTER:return this.selectHighlighted(),void killEvent(e);case KEY.TAB:return this.selectHighlighted({noFocus:!0}),void this.close();case KEY.ESC:return this.cancel(e),void killEvent(e)}if(e.which!==KEY.TAB&&!KEY.isControl(e)&&!KEY.isFunctionKey(e)&&e.which!==KEY.BACKSPACE&&e.which!==KEY.ESC){if(e.which===KEY.ENTER){if(this.opts.openOnEnter===!1)return;if(e.altKey||e.ctrlKey||e.shiftKey||e.metaKey)return}this.open(),(e.which===KEY.PAGE_UP||e.which===KEY.PAGE_DOWN)&&killEvent(e),e.which===KEY.ENTER&&killEvent(e)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(e){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),e.stopImmediatePropagation(),this.opts.element.trigger($.Event("select2-blur"))})),this.container.on("click",selector,this.bind(function(e){this.isInterfaceEnabled()&&($(e.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.open(),this.focusSearch(),e.preventDefault()))})),this.container.on("focus",selector,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger($.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var self=this;this.opts.initSelection.call(null,this.opts.element,function(data){data!==undefined&&null!==data&&(self.updateSelection(data),self.close(),self.clearSearch())})}},clearSearch:function(){var placeholder=this.getPlaceholder(),maxWidth=this.getMaxSearchWidth();placeholder!==undefined&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(placeholder).addClass("select2-default"),this.search.width(maxWidth>0?maxWidth:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),""===this.search.val()&&this.nextSearchTerm!=undefined&&(this.search.val(this.nextSearchTerm),this.search.select()),this.updateResults(!0),this.opts.shouldFocusInput(this)&&this.search.focus(),this.opts.element.trigger($.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(data){var ids=[],filtered=[],self=this;$(data).each(function(){indexOf(self.id(this),ids)<0&&(ids.push(self.id(this)),filtered.push(this))}),data=filtered,this.selection.find(".select2-search-choice").remove(),$(data).each(function(){self.addSelectedChoice(this)}),self.postprocessResults()},tokenize:function(){var input=this.search.val();input=this.opts.tokenizer.call(this,input,this.data(),this.bind(this.onSelect),this.opts),null!=input&&input!=undefined&&(this.search.val(input),input.length>0&&this.open())},onSelect:function(data,options){this.triggerSelect(data)&&(this.addSelectedChoice(data),this.opts.element.trigger({type:"selected",val:this.id(data),choice:data}),this.nextSearchTerm=this.opts.nextSearchTerm(data,this.search.val()),this.clearSearch(),this.updateResults(),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(data,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()?this.updateResults(!0):this.nextSearchTerm!=undefined&&(this.search.val(this.nextSearchTerm),this.updateResults(),this.search.select()),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:data}),options&&options.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(data){var formatted,cssClass,enableChoice=!data.locked,enabledItem=$("<li class='select2-search-choice'> <div></div> <a href='#' class='select2-search-choice-close' tabindex='-1'></a></li>"),disabledItem=$("<li class='select2-search-choice select2-locked'><div></div></li>"),choice=enableChoice?enabledItem:disabledItem,id=this.id(data),val=this.getVal();formatted=this.opts.formatSelection(data,choice.find("div"),this.opts.escapeMarkup),formatted!=undefined&&choice.find("div").replaceWith("<div>"+formatted+"</div>"),cssClass=this.opts.formatSelectionCssClass(data,choice.find("div")),cssClass!=undefined&&choice.addClass(cssClass),enableChoice&&choice.find(".select2-search-choice-close").on("mousedown",killEvent).on("click dblclick",this.bind(function(e){this.isInterfaceEnabled()&&(this.unselect($(e.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),killEvent(e),this.close(),this.focusSearch())})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),choice.data("select2-data",data),choice.insertBefore(this.searchContainer),val.push(id),this.setVal(val)},unselect:function(selected){var data,index,val=this.getVal();if(selected=selected.closest(".select2-search-choice"),0===selected.length)throw"Invalid argument: "+selected+". Must be .select2-search-choice";if(data=selected.data("select2-data")){var evt=$.Event("select2-removing");if(evt.val=this.id(data),evt.choice=data,this.opts.element.trigger(evt),evt.isDefaultPrevented())return!1;for(;(index=indexOf(this.id(data),val))>=0;)val.splice(index,1),this.setVal(val),this.select&&this.postprocessResults();return selected.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(data),choice:data}),this.triggerChange({removed:data}),!0}},postprocessResults:function(data,initial,noHighlightUpdate){var val=this.getVal(),choices=this.results.find(".select2-result"),compound=this.results.find(".select2-result-with-children"),self=this;choices.each2(function(i,choice){var id=self.id(choice.data("select2-data"));indexOf(id,val)>=0&&(choice.addClass("select2-selected"),choice.find(".select2-result-selectable").addClass("select2-selected"))}),compound.each2(function(i,choice){choice.is(".select2-result-selectable")||0!==choice.find(".select2-result-selectable:not(.select2-selected)").length||choice.addClass("select2-selected")}),-1==this.highlight()&&noHighlightUpdate!==!1&&self.highlight(0),!this.opts.createSearchChoice&&!choices.filter(".select2-result:not(.select2-selected)").length>0&&(!data||data&&!data.more&&0===this.results.find(".select2-no-results").length)&&checkFormatter(self.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+evaluate(self.opts.formatNoMatches,self.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-getSideBorderPadding(this.search)},resizeSearch:function(){var minimumWidth,left,maxWidth,containerLeft,searchWidth,sideBorderPadding=getSideBorderPadding(this.search);minimumWidth=measureTextWidth(this.search)+10,left=this.search.offset().left,maxWidth=this.selection.width(),containerLeft=this.selection.offset().left,searchWidth=maxWidth-(left-containerLeft)-sideBorderPadding,minimumWidth>searchWidth&&(searchWidth=maxWidth-sideBorderPadding),40>searchWidth&&(searchWidth=maxWidth-sideBorderPadding),0>=searchWidth&&(searchWidth=minimumWidth),this.search.width(Math.floor(searchWidth))},getVal:function(){var val;return this.select?(val=this.select.val(),null===val?[]:val):(val=this.opts.element.val(),splitVal(val,this.opts.separator))},setVal:function(val){var unique;this.select?this.select.val(val):(unique=[],$(val).each(function(){indexOf(this,unique)<0&&unique.push(this)}),this.opts.element.val(0===unique.length?"":unique.join(this.opts.separator)))},buildChangeDetails:function(old,current){for(var current=current.slice(0),old=old.slice(0),i=0;i<current.length;i++)for(var j=0;j<old.length;j++)equal(this.opts.id(current[i]),this.opts.id(old[j]))&&(current.splice(i,1),i>0&&i--,old.splice(j,1),j--);return{added:current,removed:old}},val:function(val,triggerChange){var oldData,self=this;if(0===arguments.length)return this.getVal();if(oldData=this.data(),oldData.length||(oldData=[]),!val&&0!==val)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),void(triggerChange&&this.triggerChange({added:this.data(),removed:oldData}));if(this.setVal(val),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),triggerChange&&this.triggerChange(this.buildChangeDetails(oldData,this.data()));else{if(this.opts.initSelection===undefined)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(data){var ids=$.map(data,self.id);self.setVal(ids),self.updateSelection(data),self.clearSearch(),triggerChange&&self.triggerChange(self.buildChangeDetails(oldData,self.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var val=[],self=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){val.push(self.opts.id($(this).data("select2-data")))}),this.setVal(val),this.triggerChange()},data:function(values,triggerChange){var ids,old,self=this;return 0===arguments.length?this.selection.children(".select2-search-choice").map(function(){return $(this).data("select2-data")}).get():(old=this.data(),values||(values=[]),ids=$.map(values,function(e){return self.opts.id(e)}),this.setVal(ids),this.updateSelection(values),this.clearSearch(),triggerChange&&this.triggerChange(this.buildChangeDetails(old,this.data())),void 0)}}),$.fn.select2=function(){var opts,select2,method,value,multiple,args=Array.prototype.slice.call(arguments,0),allowedMethods=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],valueMethods=["opened","isFocused","container","dropdown"],propertyMethods=["val","data"],methodsMap={search:"externalSearch"};return this.each(function(){if(0===args.length||"object"==typeof args[0])opts=0===args.length?{}:$.extend({},args[0]),opts.element=$(this),"select"===opts.element.get(0).tagName.toLowerCase()?multiple=opts.element.prop("multiple"):(multiple=opts.multiple||!1,"tags"in opts&&(opts.multiple=multiple=!0)),select2=multiple?new window.Select2["class"].multi:new window.Select2["class"].single,select2.init(opts);
|
8 |
+
else{if("string"!=typeof args[0])throw"Invalid arguments to select2 plugin: "+args;if(indexOf(args[0],allowedMethods)<0)throw"Unknown method: "+args[0];if(value=undefined,select2=$(this).data("select2"),select2===undefined)return;if(method=args[0],"container"===method?value=select2.container:"dropdown"===method?value=select2.dropdown:(methodsMap[method]&&(method=methodsMap[method]),value=select2[method].apply(select2,args.slice(1))),indexOf(args[0],valueMethods)>=0||indexOf(args[0],propertyMethods)>=0&&1==args.length)return!1}}),value===undefined?this:value},$.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(result,container,query,escapeMarkup){var markup=[];return markMatch(result.text,query.term,markup,escapeMarkup),markup.join("")},formatSelection:function(data,container,escapeMarkup){return data?escapeMarkup(data.text):undefined},sortResults:function(results){return results},formatResultCssClass:function(data){return data.css},formatSelectionCssClass:function(){return undefined},formatMatches:function(matches){return matches+" results are available, use up and down arrow keys to navigate."},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(input,min){var n=min-input.length;return"Please enter "+n+" or more character"+(1==n?"":"s")},formatInputTooLong:function(input,max){var n=input.length-max;return"Please delete "+n+" character"+(1==n?"":"s")},formatSelectionTooBig:function(limit){return"You can only select "+limit+" item"+(1==limit?"":"s")},formatLoadMore:function(){return"Loading more results…"},formatSearching:function(){return"Searching…"},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(e){return e==undefined?null:e.id},matcher:function(term,text){return stripDiacritics(""+text).toUpperCase().indexOf(stripDiacritics(""+term).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:defaultTokenizer,escapeMarkup:defaultEscapeMarkup,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(c){return c},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return undefined},searchInputPlaceholder:"",createSearchChoicePosition:"top",shouldFocusInput:function(instance){var supportsTouchEvents="ontouchstart"in window||navigator.msMaxTouchPoints>0;return supportsTouchEvents&&instance.opts.minimumResultsForSearch<0?!1:!0}},$.fn.select2.ajaxDefaults={transport:$.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:ajax,local:local,tags:tags},util:{debounce:debounce,markMatch:markMatch,escapeMarkup:defaultEscapeMarkup,stripDiacritics:stripDiacritics},"class":{"abstract":AbstractSelect2,single:SingleSelect2,multi:MultiSelect2}}}}(jQuery),jQuery(document).ready(function($){$("#filter_action, #filter_content, #filter_form").change(function(){$("#leadin-contacts-filter-button").addClass("button-primary")})});
|
assets/js/build/leadin-subscribe.js
CHANGED
@@ -349,7 +349,7 @@ jQuery(document).ready( function ( $ ) {
|
|
349 |
if ( !li_subscribe_flag )
|
350 |
{
|
351 |
leadin_check_visitor_status($.cookie("li_hash"), function ( data ) {
|
352 |
-
if ( data != '
|
353 |
{
|
354 |
$.cookie("li_subscribe", 'show', {path: "/", domain: ""});
|
355 |
bind_leadin_subscribe_widget();
|
@@ -428,7 +428,7 @@ function bind_leadin_subscribe_widget ()
|
|
428 |
).css('text-align', 'center').fadeIn(250);
|
429 |
});
|
430 |
|
431 |
-
leadin_submit_form($('.leadin-subscribe form'),
|
432 |
$.cookie("li_subscribe", 'ignore', {path: "/", domain: "", expires: ignore_date});
|
433 |
return false;
|
434 |
},
|
349 |
if ( !li_subscribe_flag )
|
350 |
{
|
351 |
leadin_check_visitor_status($.cookie("li_hash"), function ( data ) {
|
352 |
+
if ( data != 'vex_set' )
|
353 |
{
|
354 |
$.cookie("li_subscribe", 'show', {path: "/", domain: ""});
|
355 |
bind_leadin_subscribe_widget();
|
428 |
).css('text-align', 'center').fadeIn(250);
|
429 |
});
|
430 |
|
431 |
+
leadin_submit_form($('.leadin-subscribe form'), $);
|
432 |
$.cookie("li_subscribe", 'ignore', {path: "/", domain: "", expires: ignore_date});
|
433 |
return false;
|
434 |
},
|
assets/js/build/leadin-subscribe.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function bind_leadin_subscribe_widget(){!function(){var $=jQuery,subscribe={};subscribe.vex=void 0,subscribe.init=function(){$(window).scroll(function(){$(window).scrollTop()+$(window).height()>$(document).height()/2&&subscribe.open()})},subscribe.open=function(){return subscribe.vex?subscribe._open():(subscribe.vex=vex.dialog.open({showCloseButton:!0,className:"leadin-subscribe "+$("#leadin-subscribe-vex-class").val(),message:$("#leadin-subscribe-heading").val(),input:'<input id="leadin-subscribe-email" name="email" type="email" placeholder="Email address" />'+(0==$("#leadin-subscribe-name-fields").val()?"":'<input id="leadin-subscribe-fname" name="fname" type="text" placeholder="First Name" /><input id="leadin-subscribe-lname" name="lname" type="text" placeholder="Last Name" />')+(0==$("#leadin-subscribe-phone-field").val()?"":'<input id="leadin-subscribe-phone" name="phone" type="tel" placeholder="Phone" />'),buttons:[$.extend({},vex.dialog.buttons.YES,{text:$("#leadin-subscribe-btn-label").val()?$("#leadin-subscribe-btn-label").val():"SUBSCRIBE"})],onSubmit:function(){$subscribe_form=$(this),$subscribe_form.find("input.error").removeClass("error");var form_validated=!0;return $subscribe_form.find("input").each(function(){var $input=$(this);$input.val()||($input.addClass("error"),form_validated=!1)}),form_validated?($(".vex-dialog-form").fadeOut(300,function(){$(".vex-dialog-form").html('<div class="vex-close"></div><h3>Thanks!<br>You should receive a confirmation email in your inbox shortly.</h3><div><span class="powered-by">Powered by LeadIn</span><a href="http://leadin.com/wordpress-subscribe-widget/?utm_campaign=subscribe_widget&utm_medium=email&utm_source='+window.location.host+'"><img alt="LeadIn" height="20px" width="99px" src="http://leadin.com/wp-content/themes/LeadIn-WP-Theme/library/images/logos/Leadin_logo@2x.png" alt="leadin.com"/></a></div>').css("text-align","center").fadeIn(250)}),leadin_submit_form($(".leadin-subscribe form"),$,"subscribe"),$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date}),!1):!1},callback:function(data){data===!1&&$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date}),$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date})}}),void $(".leadin-subscribe form.vex-dialog-form").append('<a href="http://leadin.com/pop-subscribe-form-plugin-wordpress/?utm_campaign=subscribe_widget&utm_medium=widget&utm_source='+document.URL+'" id="leadin-subscribe-powered-by" class="leadin-subscribe-powered-by">Powered by LeadIn</a>'))},subscribe._open=function(){subscribe.vex.parent().removeClass("vex-closing")},subscribe.close=function(){subscribe.vex&&subscribe.vex.parent().addClass("vex-closing")},subscribe.init(),window.subscribe=subscribe}()}function leadin_subscribe_check_mobile($){var is_mobile=!1;return"none"==$("#leadin-subscribe-mobile-check").css("display")&&(is_mobile=!0),is_mobile}function leadin_subscribe_show(){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_subscribe_show"},success:function(){},error:function(){}})}(function(){var vexFactory;vexFactory=function($){var animationEndSupport,vex;return animationEndSupport=!1,$(function(){var s;return s=(document.body||document.documentElement).style,animationEndSupport=void 0!==s.animation||void 0!==s.WebkitAnimation||void 0!==s.MozAnimation||void 0!==s.MsAnimation||void 0!==s.OAnimation,$(window).bind("keyup.vex",function(event){return 27===event.keyCode?vex.closeByEscape():void 0})}),vex={globalID:1,animationEndEvent:"animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",baseClassNames:{vex:"vex",content:"vex-content",overlay:"vex-overlay",close:"vex-close",closing:"vex-closing",open:"vex-open"},defaultOptions:{content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",css:{},overlayClassName:"",overlayCSS:{},contentClassName:"",contentCSS:{},closeClassName:"",closeCSS:{}},open:function(options){return options=$.extend({},vex.defaultOptions,options),options.id=vex.globalID,vex.globalID+=1,options.$vex=$("<div>").addClass(vex.baseClassNames.vex).addClass(options.className).css(options.css).data({vex:options}),options.$vexOverlay=$("<div>").addClass(vex.baseClassNames.overlay).addClass(options.overlayClassName).css(options.overlayCSS).data({vex:options}),options.overlayClosesOnClick&&options.$vexOverlay.bind("click.vex",function(e){return e.target===this?vex.close($(this).data().vex.id):void 0}),options.$vex.append(options.$vexOverlay),options.$vexContent=$("<div>").addClass(vex.baseClassNames.content).addClass(options.contentClassName).css(options.contentCSS).append(options.content).data({vex:options}),options.$vex.append(options.$vexContent),options.showCloseButton&&(options.$closeButton=$("<div>").addClass(vex.baseClassNames.close).addClass(options.closeClassName).css(options.closeCSS).data({vex:options}).bind("click.vex",function(){return vex.close($(this).data().vex.id)}),options.$vexContent.append(options.$closeButton)),$(options.appendLocation).append(options.$vex),vex.setupBodyClassName(options.$vex),options.afterOpen&&options.afterOpen(options.$vexContent,options),setTimeout(function(){return options.$vexContent.trigger("vexOpen",options)},0),options.$vexContent},getAllVexes:function(){return $("."+vex.baseClassNames.vex+':not(".'+vex.baseClassNames.closing+'") .'+vex.baseClassNames.content)},getVexByID:function(id){return vex.getAllVexes().filter(function(){return $(this).data().vex.id===id})},close:function(id){var $lastVex;if(!id){if($lastVex=vex.getAllVexes().last(),!$lastVex.length)return!1;id=$lastVex.data().vex.id}return vex.closeByID(id)},closeAll:function(){var ids;return ids=vex.getAllVexes().map(function(){return $(this).data().vex.id}).toArray(),(null!=ids?ids.length:void 0)?($.each(ids.reverse(),function(index,id){return vex.closeByID(id)}),!0):!1},closeByID:function(id){var $vex,$vexContent,beforeClose,close,options;return $vexContent=vex.getVexByID(id),$vexContent.length?($vex=$vexContent.data().vex.$vex,options=$.extend({},$vexContent.data().vex),beforeClose=function(){return options.beforeClose?options.beforeClose($vexContent,options):void 0},close=function(){return $vexContent.trigger("vexClose",options),$vex.remove(),options.afterClose?options.afterClose($vexContent,options):void 0},animationEndSupport?(beforeClose(),$vex.unbind(vex.animationEndEvent).bind(vex.animationEndEvent,function(){return close()}).addClass(vex.baseClassNames.closing)):(beforeClose(),close()),!0):void 0},closeByEscape:function(){var $lastVex,id,ids;return ids=vex.getAllVexes().map(function(){return $(this).data().vex.id}).toArray(),(null!=ids?ids.length:void 0)?(id=Math.max.apply(Math,ids),$lastVex=vex.getVexByID(id),$lastVex.data().vex.escapeButtonCloses!==!0?!1:vex.closeByID(id)):!1},setupBodyClassName:function($vex){return $vex.bind("vexOpen.vex",function(){return $("body").addClass(vex.baseClassNames.open)}).bind("vexClose.vex",function(){return vex.getAllVexes().length?void 0:$("body").removeClass(vex.baseClassNames.open)})},hideLoading:function(){return $(".vex-loading-spinner").remove()},showLoading:function(){return vex.hideLoading(),$("body").append('<div class="vex-loading-spinner '+vex.defaultOptions.className+'"></div>')}}},"function"==typeof define&&define.amd?define(["jquery"],vexFactory):"object"==typeof exports?module.exports=vexFactory(require("jquery")):window.vex=vexFactory(jQuery)}).call(this),function(){var vexDialogFactory;vexDialogFactory=function($,vex){var $formToObject,dialog;return null==vex?$.error("Vex is required to use vex.dialog"):($formToObject=function($form){var object;return object={},$.each($form.serializeArray(),function(){return object[this.name]?(object[this.name].push||(object[this.name]=[object[this.name]]),object[this.name].push(this.value||"")):object[this.name]=this.value||""}),object},dialog={},dialog.buttons={YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary"},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function($vexContent){return $vexContent.data().vex.value=!1,vex.close($vexContent.data().vex.id)}}},dialog.defaultOptions={callback:function(){},afterOpen:function(){},message:"Message",input:'<input name="vex" type="hidden" value="_vex-empty-value" />',value:!1,buttons:[dialog.buttons.YES,dialog.buttons.NO],showCloseButton:!1,onSubmit:function(event){var $form,$vexContent;return $form=$(this),$vexContent=$form.parent(),event.preventDefault(),event.stopPropagation(),$vexContent.data().vex.value=dialog.getFormValueOnSubmit($formToObject($form)),vex.close($vexContent.data().vex.id)},focusFirstInput:!0},dialog.defaultAlertOptions={message:"Alert",buttons:[dialog.buttons.YES]},dialog.defaultConfirmOptions={message:"Confirm"},dialog.open=function(options){var $vexContent;return options=$.extend({},vex.defaultOptions,dialog.defaultOptions,options),options.content=dialog.buildDialogForm(options),options.beforeClose=function($vexContent){return options.callback($vexContent.data().vex.value)},$vexContent=vex.open(options),options.focusFirstInput&&$vexContent.find('input[type="submit"], textarea, input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="time"], input[type="url"], input[type="week"]').first().focus(),$vexContent},dialog.alert=function(options){return"string"==typeof options&&(options={message:options}),options=$.extend({},dialog.defaultAlertOptions,options),dialog.open(options)},dialog.confirm=function(options){return"string"==typeof options?$.error("dialog.confirm(options) requires options.callback."):(options=$.extend({},dialog.defaultConfirmOptions,options),dialog.open(options))},dialog.prompt=function(options){var defaultPromptOptions;return"string"==typeof options?$.error("dialog.prompt(options) requires options.callback."):(defaultPromptOptions={message:'<label for="vex">'+(options.label||"Prompt:")+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+(options.placeholder||"")+'" value="'+(options.value||"")+'" />'},options=$.extend({},defaultPromptOptions,options),dialog.open(options))},dialog.buildDialogForm=function(options){var $form,$input,$message;return $form=$('<form class="vex-dialog-form" />'),$message=$('<div class="vex-dialog-message" />'),$input=$('<div class="vex-dialog-input" />'),$form.append($message.append(options.message)).append($input.append(options.input)).append(dialog.buttonsToDOM(options.buttons)).bind("submit.vex",options.onSubmit),$form},dialog.getFormValueOnSubmit=function(formData){return formData.vex||""===formData.vex?"_vex-empty-value"===formData.vex?!0:formData.vex:formData},dialog.buttonsToDOM=function(buttons){var $buttons;return $buttons=$('<div class="vex-dialog-buttons" />'),$.each(buttons,function(index,button){return $buttons.append($('<input type="'+button.type+'" />').val(button.text).addClass(button.className+" vex-dialog-button "+(0===index?"vex-first ":"")+(index===buttons.length-1?"vex-last ":"")).bind("click.vex",function(e){return button.click?button.click($(this).parents("."+vex.baseClassNames.content),e):void 0}))}),$buttons},dialog)},"function"==typeof define&&define.amd?define(["jquery","vex"],vexDialogFactory):"object"==typeof exports?module.exports=vexDialogFactory(require("jquery"),require("vex")):window.vex.dialog=vexDialogFactory(window.jQuery,window.vex)}.call(this);var ignore_date=new Date;ignore_date.setTime(ignore_date.getTime()+12096e5),jQuery(document).ready(function($){var li_subscribe_flag=$.cookie("li_subscribe");leadin_subscribe_check_mobile($)||(li_subscribe_flag?"show"==li_subscribe_flag&&bind_leadin_subscribe_widget():leadin_check_visitor_status($.cookie("li_hash"),function(data){"subscribe"!=data?($.cookie("li_subscribe","show",{path:"/",domain:""}),bind_leadin_subscribe_widget()):$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date})}))});
|
1 |
+
function bind_leadin_subscribe_widget(){!function(){var $=jQuery,subscribe={};subscribe.vex=void 0,subscribe.init=function(){$(window).scroll(function(){$(window).scrollTop()+$(window).height()>$(document).height()/2&&subscribe.open()})},subscribe.open=function(){return subscribe.vex?subscribe._open():(subscribe.vex=vex.dialog.open({showCloseButton:!0,className:"leadin-subscribe "+$("#leadin-subscribe-vex-class").val(),message:$("#leadin-subscribe-heading").val(),input:'<input id="leadin-subscribe-email" name="email" type="email" placeholder="Email address" />'+(0==$("#leadin-subscribe-name-fields").val()?"":'<input id="leadin-subscribe-fname" name="fname" type="text" placeholder="First Name" /><input id="leadin-subscribe-lname" name="lname" type="text" placeholder="Last Name" />')+(0==$("#leadin-subscribe-phone-field").val()?"":'<input id="leadin-subscribe-phone" name="phone" type="tel" placeholder="Phone" />'),buttons:[$.extend({},vex.dialog.buttons.YES,{text:$("#leadin-subscribe-btn-label").val()?$("#leadin-subscribe-btn-label").val():"SUBSCRIBE"})],onSubmit:function(){$subscribe_form=$(this),$subscribe_form.find("input.error").removeClass("error");var form_validated=!0;return $subscribe_form.find("input").each(function(){var $input=$(this);$input.val()||($input.addClass("error"),form_validated=!1)}),form_validated?($(".vex-dialog-form").fadeOut(300,function(){$(".vex-dialog-form").html('<div class="vex-close"></div><h3>Thanks!<br>You should receive a confirmation email in your inbox shortly.</h3><div><span class="powered-by">Powered by LeadIn</span><a href="http://leadin.com/wordpress-subscribe-widget/?utm_campaign=subscribe_widget&utm_medium=email&utm_source='+window.location.host+'"><img alt="LeadIn" height="20px" width="99px" src="http://leadin.com/wp-content/themes/LeadIn-WP-Theme/library/images/logos/Leadin_logo@2x.png" alt="leadin.com"/></a></div>').css("text-align","center").fadeIn(250)}),leadin_submit_form($(".leadin-subscribe form"),$),$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date}),!1):!1},callback:function(data){data===!1&&$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date}),$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date})}}),void $(".leadin-subscribe form.vex-dialog-form").append('<a href="http://leadin.com/pop-subscribe-form-plugin-wordpress/?utm_campaign=subscribe_widget&utm_medium=widget&utm_source='+document.URL+'" id="leadin-subscribe-powered-by" class="leadin-subscribe-powered-by">Powered by LeadIn</a>'))},subscribe._open=function(){subscribe.vex.parent().removeClass("vex-closing")},subscribe.close=function(){subscribe.vex&&subscribe.vex.parent().addClass("vex-closing")},subscribe.init(),window.subscribe=subscribe}()}function leadin_subscribe_check_mobile($){var is_mobile=!1;return"none"==$("#leadin-subscribe-mobile-check").css("display")&&(is_mobile=!0),is_mobile}function leadin_subscribe_show(){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_subscribe_show"},success:function(){},error:function(){}})}(function(){var vexFactory;vexFactory=function($){var animationEndSupport,vex;return animationEndSupport=!1,$(function(){var s;return s=(document.body||document.documentElement).style,animationEndSupport=void 0!==s.animation||void 0!==s.WebkitAnimation||void 0!==s.MozAnimation||void 0!==s.MsAnimation||void 0!==s.OAnimation,$(window).bind("keyup.vex",function(event){return 27===event.keyCode?vex.closeByEscape():void 0})}),vex={globalID:1,animationEndEvent:"animationend webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend",baseClassNames:{vex:"vex",content:"vex-content",overlay:"vex-overlay",close:"vex-close",closing:"vex-closing",open:"vex-open"},defaultOptions:{content:"",showCloseButton:!0,escapeButtonCloses:!0,overlayClosesOnClick:!0,appendLocation:"body",className:"",css:{},overlayClassName:"",overlayCSS:{},contentClassName:"",contentCSS:{},closeClassName:"",closeCSS:{}},open:function(options){return options=$.extend({},vex.defaultOptions,options),options.id=vex.globalID,vex.globalID+=1,options.$vex=$("<div>").addClass(vex.baseClassNames.vex).addClass(options.className).css(options.css).data({vex:options}),options.$vexOverlay=$("<div>").addClass(vex.baseClassNames.overlay).addClass(options.overlayClassName).css(options.overlayCSS).data({vex:options}),options.overlayClosesOnClick&&options.$vexOverlay.bind("click.vex",function(e){return e.target===this?vex.close($(this).data().vex.id):void 0}),options.$vex.append(options.$vexOverlay),options.$vexContent=$("<div>").addClass(vex.baseClassNames.content).addClass(options.contentClassName).css(options.contentCSS).append(options.content).data({vex:options}),options.$vex.append(options.$vexContent),options.showCloseButton&&(options.$closeButton=$("<div>").addClass(vex.baseClassNames.close).addClass(options.closeClassName).css(options.closeCSS).data({vex:options}).bind("click.vex",function(){return vex.close($(this).data().vex.id)}),options.$vexContent.append(options.$closeButton)),$(options.appendLocation).append(options.$vex),vex.setupBodyClassName(options.$vex),options.afterOpen&&options.afterOpen(options.$vexContent,options),setTimeout(function(){return options.$vexContent.trigger("vexOpen",options)},0),options.$vexContent},getAllVexes:function(){return $("."+vex.baseClassNames.vex+':not(".'+vex.baseClassNames.closing+'") .'+vex.baseClassNames.content)},getVexByID:function(id){return vex.getAllVexes().filter(function(){return $(this).data().vex.id===id})},close:function(id){var $lastVex;if(!id){if($lastVex=vex.getAllVexes().last(),!$lastVex.length)return!1;id=$lastVex.data().vex.id}return vex.closeByID(id)},closeAll:function(){var ids;return ids=vex.getAllVexes().map(function(){return $(this).data().vex.id}).toArray(),(null!=ids?ids.length:void 0)?($.each(ids.reverse(),function(index,id){return vex.closeByID(id)}),!0):!1},closeByID:function(id){var $vex,$vexContent,beforeClose,close,options;return $vexContent=vex.getVexByID(id),$vexContent.length?($vex=$vexContent.data().vex.$vex,options=$.extend({},$vexContent.data().vex),beforeClose=function(){return options.beforeClose?options.beforeClose($vexContent,options):void 0},close=function(){return $vexContent.trigger("vexClose",options),$vex.remove(),options.afterClose?options.afterClose($vexContent,options):void 0},animationEndSupport?(beforeClose(),$vex.unbind(vex.animationEndEvent).bind(vex.animationEndEvent,function(){return close()}).addClass(vex.baseClassNames.closing)):(beforeClose(),close()),!0):void 0},closeByEscape:function(){var $lastVex,id,ids;return ids=vex.getAllVexes().map(function(){return $(this).data().vex.id}).toArray(),(null!=ids?ids.length:void 0)?(id=Math.max.apply(Math,ids),$lastVex=vex.getVexByID(id),$lastVex.data().vex.escapeButtonCloses!==!0?!1:vex.closeByID(id)):!1},setupBodyClassName:function($vex){return $vex.bind("vexOpen.vex",function(){return $("body").addClass(vex.baseClassNames.open)}).bind("vexClose.vex",function(){return vex.getAllVexes().length?void 0:$("body").removeClass(vex.baseClassNames.open)})},hideLoading:function(){return $(".vex-loading-spinner").remove()},showLoading:function(){return vex.hideLoading(),$("body").append('<div class="vex-loading-spinner '+vex.defaultOptions.className+'"></div>')}}},"function"==typeof define&&define.amd?define(["jquery"],vexFactory):"object"==typeof exports?module.exports=vexFactory(require("jquery")):window.vex=vexFactory(jQuery)}).call(this),function(){var vexDialogFactory;vexDialogFactory=function($,vex){var $formToObject,dialog;return null==vex?$.error("Vex is required to use vex.dialog"):($formToObject=function($form){var object;return object={},$.each($form.serializeArray(),function(){return object[this.name]?(object[this.name].push||(object[this.name]=[object[this.name]]),object[this.name].push(this.value||"")):object[this.name]=this.value||""}),object},dialog={},dialog.buttons={YES:{text:"OK",type:"submit",className:"vex-dialog-button-primary"},NO:{text:"Cancel",type:"button",className:"vex-dialog-button-secondary",click:function($vexContent){return $vexContent.data().vex.value=!1,vex.close($vexContent.data().vex.id)}}},dialog.defaultOptions={callback:function(){},afterOpen:function(){},message:"Message",input:'<input name="vex" type="hidden" value="_vex-empty-value" />',value:!1,buttons:[dialog.buttons.YES,dialog.buttons.NO],showCloseButton:!1,onSubmit:function(event){var $form,$vexContent;return $form=$(this),$vexContent=$form.parent(),event.preventDefault(),event.stopPropagation(),$vexContent.data().vex.value=dialog.getFormValueOnSubmit($formToObject($form)),vex.close($vexContent.data().vex.id)},focusFirstInput:!0},dialog.defaultAlertOptions={message:"Alert",buttons:[dialog.buttons.YES]},dialog.defaultConfirmOptions={message:"Confirm"},dialog.open=function(options){var $vexContent;return options=$.extend({},vex.defaultOptions,dialog.defaultOptions,options),options.content=dialog.buildDialogForm(options),options.beforeClose=function($vexContent){return options.callback($vexContent.data().vex.value)},$vexContent=vex.open(options),options.focusFirstInput&&$vexContent.find('input[type="submit"], textarea, input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="time"], input[type="url"], input[type="week"]').first().focus(),$vexContent},dialog.alert=function(options){return"string"==typeof options&&(options={message:options}),options=$.extend({},dialog.defaultAlertOptions,options),dialog.open(options)},dialog.confirm=function(options){return"string"==typeof options?$.error("dialog.confirm(options) requires options.callback."):(options=$.extend({},dialog.defaultConfirmOptions,options),dialog.open(options))},dialog.prompt=function(options){var defaultPromptOptions;return"string"==typeof options?$.error("dialog.prompt(options) requires options.callback."):(defaultPromptOptions={message:'<label for="vex">'+(options.label||"Prompt:")+"</label>",input:'<input name="vex" type="text" class="vex-dialog-prompt-input" placeholder="'+(options.placeholder||"")+'" value="'+(options.value||"")+'" />'},options=$.extend({},defaultPromptOptions,options),dialog.open(options))},dialog.buildDialogForm=function(options){var $form,$input,$message;return $form=$('<form class="vex-dialog-form" />'),$message=$('<div class="vex-dialog-message" />'),$input=$('<div class="vex-dialog-input" />'),$form.append($message.append(options.message)).append($input.append(options.input)).append(dialog.buttonsToDOM(options.buttons)).bind("submit.vex",options.onSubmit),$form},dialog.getFormValueOnSubmit=function(formData){return formData.vex||""===formData.vex?"_vex-empty-value"===formData.vex?!0:formData.vex:formData},dialog.buttonsToDOM=function(buttons){var $buttons;return $buttons=$('<div class="vex-dialog-buttons" />'),$.each(buttons,function(index,button){return $buttons.append($('<input type="'+button.type+'" />').val(button.text).addClass(button.className+" vex-dialog-button "+(0===index?"vex-first ":"")+(index===buttons.length-1?"vex-last ":"")).bind("click.vex",function(e){return button.click?button.click($(this).parents("."+vex.baseClassNames.content),e):void 0}))}),$buttons},dialog)},"function"==typeof define&&define.amd?define(["jquery","vex"],vexDialogFactory):"object"==typeof exports?module.exports=vexDialogFactory(require("jquery"),require("vex")):window.vex.dialog=vexDialogFactory(window.jQuery,window.vex)}.call(this);var ignore_date=new Date;ignore_date.setTime(ignore_date.getTime()+12096e5),jQuery(document).ready(function($){var li_subscribe_flag=$.cookie("li_subscribe");leadin_subscribe_check_mobile($)||(li_subscribe_flag?"show"==li_subscribe_flag&&bind_leadin_subscribe_widget():leadin_check_visitor_status($.cookie("li_hash"),function(data){"vex_set"!=data?($.cookie("li_subscribe","show",{path:"/",domain:""}),bind_leadin_subscribe_widget()):$.cookie("li_subscribe","ignore",{path:"/",domain:"",expires:ignore_date})}))});
|
assets/js/build/leadin-tracking.js
CHANGED
@@ -135,7 +135,6 @@ jQuery(document).ready( function ( $ ) {
|
|
135 |
submission_data.lead_first_name,
|
136 |
submission_data.lead_last_name,
|
137 |
submission_data.lead_phone,
|
138 |
-
submission_data.form_submission_type,
|
139 |
submission_data.form_selector_id,
|
140 |
submission_data.form_selector_classes,
|
141 |
function ( data ) {
|
@@ -186,7 +185,7 @@ jQuery(function($){
|
|
186 |
}
|
187 |
});
|
188 |
|
189 |
-
function leadin_submit_form ( $form,
|
190 |
{
|
191 |
var $this = $form;
|
192 |
|
@@ -195,7 +194,6 @@ function leadin_submit_form ( $form, $, form_type )
|
|
195 |
var lead_first_name = '';
|
196 |
var lead_last_name = '';
|
197 |
var lead_phone = '';
|
198 |
-
var form_submission_type = ( form_type ? form_type : 'contact' );
|
199 |
var ignore_form = false;
|
200 |
var form_selector_id = ( $form.attr('id') ? $form.attr('id') : '' );
|
201 |
var form_selector_classes = ( $form.classes() ? $form.classes().join(',') : '' );
|
@@ -397,11 +395,6 @@ function leadin_submit_form ( $form, $, form_type )
|
|
397 |
|
398 |
$this.find('.li_used').removeClass('li_used'); // Clean up added classes
|
399 |
|
400 |
-
if ( $this.find('#comment_post_ID').length )
|
401 |
-
{
|
402 |
-
form_submission_type = 'comment';
|
403 |
-
}
|
404 |
-
|
405 |
// Save submission into database if email is present and form is not ignore, send LeadIn email, and submit form as usual
|
406 |
if ( lead_email && ! ignore_form )
|
407 |
{
|
@@ -421,7 +414,6 @@ function leadin_submit_form ( $form, $, form_type )
|
|
421 |
"page_title": page_title,
|
422 |
"page_url": page_url,
|
423 |
"json_form_fields": json_form_fields,
|
424 |
-
"form_submission_type": form_submission_type,
|
425 |
"form_selector_id": form_selector_id,
|
426 |
"form_selector_classes": form_selector_classes
|
427 |
};
|
@@ -437,8 +429,7 @@ function leadin_submit_form ( $form, $, form_type )
|
|
437 |
lead_email,
|
438 |
lead_first_name,
|
439 |
lead_last_name,
|
440 |
-
lead_phone,
|
441 |
-
form_submission_type,
|
442 |
form_selector_id,
|
443 |
form_selector_classes,
|
444 |
function ( data ) {
|
@@ -534,7 +525,7 @@ function leadin_insert_lead ( hashkey, page_referrer ) {
|
|
534 |
});
|
535 |
}
|
536 |
|
537 |
-
function leadin_insert_form_submission ( submission_haskey, hashkey, page_title, page_url, json_fields, lead_email, lead_first_name, lead_last_name, lead_phone,
|
538 |
{
|
539 |
jQuery.ajax({
|
540 |
type: 'POST',
|
@@ -550,7 +541,6 @@ function leadin_insert_form_submission ( submission_haskey, hashkey, page_title,
|
|
550 |
"li_first_name": lead_first_name,
|
551 |
"li_last_name": lead_last_name,
|
552 |
"li_phone": lead_phone,
|
553 |
-
"li_submission_type": form_submission_type,
|
554 |
"li_form_selector_id": form_selector_id,
|
555 |
"li_form_selector_classes": form_selector_classes
|
556 |
},
|
135 |
submission_data.lead_first_name,
|
136 |
submission_data.lead_last_name,
|
137 |
submission_data.lead_phone,
|
|
|
138 |
submission_data.form_selector_id,
|
139 |
submission_data.form_selector_classes,
|
140 |
function ( data ) {
|
185 |
}
|
186 |
});
|
187 |
|
188 |
+
function leadin_submit_form ( $form, $ )
|
189 |
{
|
190 |
var $this = $form;
|
191 |
|
194 |
var lead_first_name = '';
|
195 |
var lead_last_name = '';
|
196 |
var lead_phone = '';
|
|
|
197 |
var ignore_form = false;
|
198 |
var form_selector_id = ( $form.attr('id') ? $form.attr('id') : '' );
|
199 |
var form_selector_classes = ( $form.classes() ? $form.classes().join(',') : '' );
|
395 |
|
396 |
$this.find('.li_used').removeClass('li_used'); // Clean up added classes
|
397 |
|
|
|
|
|
|
|
|
|
|
|
398 |
// Save submission into database if email is present and form is not ignore, send LeadIn email, and submit form as usual
|
399 |
if ( lead_email && ! ignore_form )
|
400 |
{
|
414 |
"page_title": page_title,
|
415 |
"page_url": page_url,
|
416 |
"json_form_fields": json_form_fields,
|
|
|
417 |
"form_selector_id": form_selector_id,
|
418 |
"form_selector_classes": form_selector_classes
|
419 |
};
|
429 |
lead_email,
|
430 |
lead_first_name,
|
431 |
lead_last_name,
|
432 |
+
lead_phone,
|
|
|
433 |
form_selector_id,
|
434 |
form_selector_classes,
|
435 |
function ( data ) {
|
525 |
});
|
526 |
}
|
527 |
|
528 |
+
function leadin_insert_form_submission ( submission_haskey, hashkey, page_title, page_url, json_fields, lead_email, lead_first_name, lead_last_name, lead_phone, form_selector_id, form_selector_classes, Callback )
|
529 |
{
|
530 |
jQuery.ajax({
|
531 |
type: 'POST',
|
541 |
"li_first_name": lead_first_name,
|
542 |
"li_last_name": lead_last_name,
|
543 |
"li_phone": lead_phone,
|
|
|
544 |
"li_form_selector_id": form_selector_id,
|
545 |
"li_form_selector_classes": form_selector_classes
|
546 |
},
|
assets/js/build/leadin-tracking.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function leadin_submit_form($form,$,form_type){var $this=$form,form_fields=[],lead_email="",lead_first_name="",lead_last_name="",lead_phone="",form_submission_type=form_type?form_type:"contact",ignore_form=!1,form_selector_id=$form.attr("id")?$form.attr("id"):"",form_selector_classes=$form.classes()?$form.classes().join(","):"";$this.find('input[type!="submit"], textarea').not('input[type="hidden"], input[type="radio"], input[type="password"]').each(function(){var $element=$(this),$value=$element.val();if(!$element.is(":visible"))return!0;var $label=$("label[for='"+$element.attr("id")+"']").text();0==$label.length&&($label=$element.prev("label").not(".li_used").addClass("li_used").first().text(),$label.length||($label=$element.prevAll("b, strong, span").text())),0==$label.length&&($label=$element.next("label").not(".li_used").addClass("li_used").first().text(),$label.length||($label=$element.nextAll("b, strong, span").text())),0==$label.length&&($label=$element.parent().find("label, b, strong").not(".li_used").first().text()),0==$label.length&&$.contains($this,$element.parent().parent())&&($label=$element.parent().parent().find("label, b, strong").first().text()),0==$label.length&&($p=$element.closest("p").not(".li_used").addClass("li_used"),$p.length&&($label=$p.text(),$label=$.trim($label.replace($value,"")))),0==$label.length&&void 0!==$element.attr("placeholder")&&($label=$element.attr("placeholder").toString()),0==$label.length&&void 0!==$element.attr("name")&&($label=$element.attr("name").toString()),$element.is(":checkbox")&&($value=$element.is(":checked")?"Checked":"Not checked"),$value=$value.replace("C:\\fakepath\\","");var $label_text=$.trim($label.replaceArray(["(",")","required","Required","*",":"],[""]));(-1!=$label_text.toLowerCase().indexOf("credit card")||-1!=$label_text.toLowerCase().indexOf("card number"))&&(ignore_form=!0),push_form_field($label_text,$value,form_fields),-1==$value.indexOf("@")||-1==$value.indexOf(".")||lead_email||(lead_email=$value),"leadin-subscribe-fname"==$element.attr("id")&&(lead_first_name=$value),"leadin-subscribe-lname"==$element.attr("id")&&(lead_last_name=$value),"leadin-subscribe-phone"==$element.attr("id")&&(lead_phone=$value)});var radio_groups=[],rbg_label_values=[];$this.find(":radio").each(function(){-1==$.inArray(this.name,radio_groups)&&radio_groups.push(this.name),rbg_label_values.push($(this).val())});for(var i=0;i<radio_groups.length;i++){{var $rbg=$("input:radio[name='"+radio_groups[i]+"']");$("input:radio[name='"+radio_groups[i]+"']:checked").val()}$p=$this.find(".gfield").length?$rbg.closest(".gfield").not(".li_used").addClass("li_used"):$this.find(".frm_form_field").length?$rbg.closest(".frm_form_field").not(".li_used").addClass("li_used"):$rbg.closest("div, p").not(".li_used").addClass("li_used"),$p.length&&($rbg_label=$p.text(),$rbg_label=$.trim($rbg_label.replaceArray(rbg_label_values,[""]).replace($p.find(".gfield_description").text(),"")));var rgb_selected=$("input:radio[name='"+radio_groups[i]+"']:checked").val()?$("input:radio[name='"+radio_groups[i]+"']:checked").val():"not selected";push_form_field($rbg_label,rgb_selected,form_fields)}if($this.find("select").each(function(){var $select=$(this),$select_label=$("label[for='"+$select.attr("id")+"']").text();if(!$select_label.length){var select_values=[];$select.find("option").each(function(){-1==$.inArray($(this).val(),select_values)&&select_values.push($(this).val())}),$p=$select.closest("div, p").not(".li_used").addClass("li_used"),$p=$this.find(".gfield").length?$select.closest(".gfield").not(".li_used").addClass("li_used"):$select.closest("div, p").addClass("li_used"),$p.length&&($select_label=$p.text(),$select_label=$.trim($select_label.replaceArray(select_values,[""]).replace($p.find(".gfield_description").text(),"")))}var select_value="";if($select.val()instanceof Array){var select_vals=$select.val();for(i=0;i<select_vals.length;i++)select_value+=select_vals[i],i!=select_vals.length-1&&(select_value+=", ")}else select_value=$select.val();push_form_field($select_label,select_value,form_fields)}),$this.find(".li_used").removeClass("li_used"),$this.find("#comment_post_ID").length&&(form_submission_type="comment"),lead_email&&!ignore_form){var submission_hash=Math.random().toString(36).slice(2),hashkey=$.cookie("li_hash"),json_form_fields=JSON.stringify(form_fields),form_submission={};form_submission={submission_hash:submission_hash,hashkey:hashkey,lead_email:lead_email,lead_first_name:lead_first_name,lead_last_name:lead_last_name,lead_phone:lead_phone,page_title:page_title,page_url:page_url,json_form_fields:json_form_fields,form_submission_type:form_submission_type,form_selector_id:form_selector_id,form_selector_classes:form_selector_classes},$.cookie("li_submission",JSON.stringify(form_submission),{path:"/",domain:""}),leadin_insert_form_submission(submission_hash,hashkey,page_title,page_url,json_form_fields,lead_email,lead_first_name,lead_last_name,lead_phone,form_submission_type,form_selector_id,form_selector_classes,function(){$.removeCookie("li_submission",{path:"/",domain:""})})}else form_saved=!0}function leadin_check_merged_contact(hashkey){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_check_merged_contact",li_id:hashkey},success:function(data){var json_data=jQuery.parseJSON(data);json_data&&jQuery.cookie("li_hash",json_data,{path:"/",domain:""})},error:function(){}})}function leadin_check_visitor_status(hashkey,callback){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_check_visitor_status",li_id:hashkey},success:function(data){var json_data=jQuery.parseJSON(data);callback&&callback(json_data)},error:function(){}})}function leadin_log_pageview(hashkey,page_title,page_url,page_referrer,last_visit){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_log_pageview",li_id:hashkey,li_title:page_title,li_url:page_url,li_referrer:page_referrer,li_last_visit:last_visit},success:function(){},error:function(){}})}function leadin_insert_lead(hashkey,page_referrer){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_insert_lead",li_id:hashkey,li_referrer:page_referrer},success:function(){},error:function(){}})}function leadin_insert_form_submission(submission_haskey,hashkey,page_title,page_url,json_fields,lead_email,lead_first_name,lead_last_name,lead_phone,form_submission_type,form_selector_id,form_selector_classes,Callback){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_insert_form_submission",li_submission_id:submission_haskey,li_id:hashkey,li_title:page_title,li_url:page_url,li_fields:json_fields,li_email:lead_email,li_first_name:lead_first_name,li_last_name:lead_last_name,li_phone:lead_phone,li_submission_type:form_submission_type,li_form_selector_id:form_selector_id,li_form_selector_classes:form_selector_classes},success:function(data){Callback&&Callback(data)},error:function(){}})}function push_form_field(label,value,form_fields){var field={label:label,value:value};form_fields.push(field)}!function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):factory(jQuery)}(function($){function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){0===s.indexOf('"')&&(s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return s=decodeURIComponent(s.replace(pluses," ")),config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var pluses=/\+/g,config=$.cookie=function(key,value,options){if(void 0!==value&&!$.isFunction(value)){if(options=$.extend({},config.defaults,options),"number"==typeof options.expires){var days=options.expires,t=options.expires=new Date;t.setDate(t.getDate()+days)}return document.cookie=[encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}for(var result=key?void 0:{},cookies=document.cookie?document.cookie.split("; "):[],i=0,l=cookies.length;l>i;i++){var parts=cookies[i].split("="),name=decode(parts.shift()),cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}key||void 0===(cookie=read(cookie))||(result[name]=cookie)}return result};config.defaults={},$.removeCookie=function(key,options){return void 0===$.cookie(key)?!1:($.cookie(key,"",$.extend({},options,{expires:-1})),!$.cookie(key))}});var page_title=jQuery(document).find("title").text(),page_url=window.location.href,page_referrer=document.referrer,form_saved=!1;jQuery(document).ready(function($){var hashkey=$.cookie("li_hash"),li_submission_cookie=$.cookie("li_submission");if(li_submission_cookie){var submission_data=JSON.parse(li_submission_cookie);leadin_insert_form_submission(submission_data.submission_hash,submission_data.hashkey,submission_data.page_title,submission_data.page_url,submission_data.json_form_fields,submission_data.lead_email,submission_data.lead_first_name,submission_data.lead_last_name,submission_data.lead_phone,submission_data.form_submission_type,submission_data.form_selector_id,submission_data.form_selector_classes,function(){$.removeCookie("li_submission",{path:"/",domain:""})})}hashkey||(hashkey=Math.random().toString(36).slice(2),$.cookie("li_hash",hashkey,{path:"/",domain:""}),leadin_insert_lead(hashkey,page_referrer)),leadin_log_pageview(hashkey,page_title,page_url,page_referrer,$.cookie("li_last_visit"));var date=new Date,current_time=date.getTime();date.setTime(date.getTime()+36e5),$.cookie("li_last_visit")||leadin_check_merged_contact(hashkey),$.cookie("li_last_visit",current_time,{path:"/",domain:"",expires:date})}),jQuery(function($){-1!=$.versioncompare($.fn.jquery,"1.7.0")?$(document).on("submit","form",function(){var $form=$(this).closest("form");leadin_submit_form($form,$)}):$(document).bind("submit","form",function(){var $form=$(this).closest("form");leadin_submit_form($form,$)})}),String.prototype.replaceArray=function(find,replace){for(var replaceString=this,i=0;i<find.length;i++)replaceString=1!=replace.length?replaceString.replace(find[i],replace[i]):replaceString.replace(find[i],replace[0]);return replaceString},function($){function normalize(version){return $.map(version.split("."),function(value){return parseInt(value,10)})}$.versioncompare=function(version1,version2){if("undefined"==typeof version1)throw new Error("$.versioncompare needs at least one parameter.");if(version2=version2||$.fn.jquery,version1==version2)return 0;for(var v1=normalize(version1),v2=normalize(version2),len=Math.max(v1.length,v2.length),i=0;len>i;i++)if(v1[i]=v1[i]||0,v2[i]=v2[i]||0,v1[i]!=v2[i])return v1[i]>v2[i]?1:-1;return 0}}(jQuery),function($){$.fn.classes=function(callback){var classes=[];if($.each(this,function(i,v){var splitClassName=v.className.split(/\s+/);for(var j in splitClassName){var className=splitClassName[j];-1===classes.indexOf(className)&&classes.push(className)}}),"function"==typeof callback)for(var i in classes)callback(classes[i]);return classes}}(jQuery);
|
1 |
+
function leadin_submit_form($form,$){var $this=$form,form_fields=[],lead_email="",lead_first_name="",lead_last_name="",lead_phone="",ignore_form=!1,form_selector_id=$form.attr("id")?$form.attr("id"):"",form_selector_classes=$form.classes()?$form.classes().join(","):"";$this.find('input[type!="submit"], textarea').not('input[type="hidden"], input[type="radio"], input[type="password"]').each(function(){var $element=$(this),$value=$element.val();if(!$element.is(":visible"))return!0;var $label=$("label[for='"+$element.attr("id")+"']").text();0==$label.length&&($label=$element.prev("label").not(".li_used").addClass("li_used").first().text(),$label.length||($label=$element.prevAll("b, strong, span").text())),0==$label.length&&($label=$element.next("label").not(".li_used").addClass("li_used").first().text(),$label.length||($label=$element.nextAll("b, strong, span").text())),0==$label.length&&($label=$element.parent().find("label, b, strong").not(".li_used").first().text()),0==$label.length&&$.contains($this,$element.parent().parent())&&($label=$element.parent().parent().find("label, b, strong").first().text()),0==$label.length&&($p=$element.closest("p").not(".li_used").addClass("li_used"),$p.length&&($label=$p.text(),$label=$.trim($label.replace($value,"")))),0==$label.length&&void 0!==$element.attr("placeholder")&&($label=$element.attr("placeholder").toString()),0==$label.length&&void 0!==$element.attr("name")&&($label=$element.attr("name").toString()),$element.is(":checkbox")&&($value=$element.is(":checked")?"Checked":"Not checked"),$value=$value.replace("C:\\fakepath\\","");var $label_text=$.trim($label.replaceArray(["(",")","required","Required","*",":"],[""]));(-1!=$label_text.toLowerCase().indexOf("credit card")||-1!=$label_text.toLowerCase().indexOf("card number"))&&(ignore_form=!0),push_form_field($label_text,$value,form_fields),-1==$value.indexOf("@")||-1==$value.indexOf(".")||lead_email||(lead_email=$value),"leadin-subscribe-fname"==$element.attr("id")&&(lead_first_name=$value),"leadin-subscribe-lname"==$element.attr("id")&&(lead_last_name=$value),"leadin-subscribe-phone"==$element.attr("id")&&(lead_phone=$value)});var radio_groups=[],rbg_label_values=[];$this.find(":radio").each(function(){-1==$.inArray(this.name,radio_groups)&&radio_groups.push(this.name),rbg_label_values.push($(this).val())});for(var i=0;i<radio_groups.length;i++){{var $rbg=$("input:radio[name='"+radio_groups[i]+"']");$("input:radio[name='"+radio_groups[i]+"']:checked").val()}$p=$this.find(".gfield").length?$rbg.closest(".gfield").not(".li_used").addClass("li_used"):$this.find(".frm_form_field").length?$rbg.closest(".frm_form_field").not(".li_used").addClass("li_used"):$rbg.closest("div, p").not(".li_used").addClass("li_used"),$p.length&&($rbg_label=$p.text(),$rbg_label=$.trim($rbg_label.replaceArray(rbg_label_values,[""]).replace($p.find(".gfield_description").text(),"")));var rgb_selected=$("input:radio[name='"+radio_groups[i]+"']:checked").val()?$("input:radio[name='"+radio_groups[i]+"']:checked").val():"not selected";push_form_field($rbg_label,rgb_selected,form_fields)}if($this.find("select").each(function(){var $select=$(this),$select_label=$("label[for='"+$select.attr("id")+"']").text();if(!$select_label.length){var select_values=[];$select.find("option").each(function(){-1==$.inArray($(this).val(),select_values)&&select_values.push($(this).val())}),$p=$select.closest("div, p").not(".li_used").addClass("li_used"),$p=$this.find(".gfield").length?$select.closest(".gfield").not(".li_used").addClass("li_used"):$select.closest("div, p").addClass("li_used"),$p.length&&($select_label=$p.text(),$select_label=$.trim($select_label.replaceArray(select_values,[""]).replace($p.find(".gfield_description").text(),"")))}var select_value="";if($select.val()instanceof Array){var select_vals=$select.val();for(i=0;i<select_vals.length;i++)select_value+=select_vals[i],i!=select_vals.length-1&&(select_value+=", ")}else select_value=$select.val();push_form_field($select_label,select_value,form_fields)}),$this.find(".li_used").removeClass("li_used"),lead_email&&!ignore_form){var submission_hash=Math.random().toString(36).slice(2),hashkey=$.cookie("li_hash"),json_form_fields=JSON.stringify(form_fields),form_submission={};form_submission={submission_hash:submission_hash,hashkey:hashkey,lead_email:lead_email,lead_first_name:lead_first_name,lead_last_name:lead_last_name,lead_phone:lead_phone,page_title:page_title,page_url:page_url,json_form_fields:json_form_fields,form_selector_id:form_selector_id,form_selector_classes:form_selector_classes},$.cookie("li_submission",JSON.stringify(form_submission),{path:"/",domain:""}),leadin_insert_form_submission(submission_hash,hashkey,page_title,page_url,json_form_fields,lead_email,lead_first_name,lead_last_name,lead_phone,form_selector_id,form_selector_classes,function(){$.removeCookie("li_submission",{path:"/",domain:""})})}else form_saved=!0}function leadin_check_merged_contact(hashkey){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_check_merged_contact",li_id:hashkey},success:function(data){var json_data=jQuery.parseJSON(data);json_data&&jQuery.cookie("li_hash",json_data,{path:"/",domain:""})},error:function(){}})}function leadin_check_visitor_status(hashkey,callback){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_check_visitor_status",li_id:hashkey},success:function(data){var json_data=jQuery.parseJSON(data);callback&&callback(json_data)},error:function(){}})}function leadin_log_pageview(hashkey,page_title,page_url,page_referrer,last_visit){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_log_pageview",li_id:hashkey,li_title:page_title,li_url:page_url,li_referrer:page_referrer,li_last_visit:last_visit},success:function(){},error:function(){}})}function leadin_insert_lead(hashkey,page_referrer){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_insert_lead",li_id:hashkey,li_referrer:page_referrer},success:function(){},error:function(){}})}function leadin_insert_form_submission(submission_haskey,hashkey,page_title,page_url,json_fields,lead_email,lead_first_name,lead_last_name,lead_phone,form_selector_id,form_selector_classes,Callback){jQuery.ajax({type:"POST",url:li_ajax.ajax_url,data:{action:"leadin_insert_form_submission",li_submission_id:submission_haskey,li_id:hashkey,li_title:page_title,li_url:page_url,li_fields:json_fields,li_email:lead_email,li_first_name:lead_first_name,li_last_name:lead_last_name,li_phone:lead_phone,li_form_selector_id:form_selector_id,li_form_selector_classes:form_selector_classes},success:function(data){Callback&&Callback(data)},error:function(){}})}function push_form_field(label,value,form_fields){var field={label:label,value:value};form_fields.push(field)}!function(factory){"function"==typeof define&&define.amd?define(["jquery"],factory):factory(jQuery)}(function($){function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){0===s.indexOf('"')&&(s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\"));try{return s=decodeURIComponent(s.replace(pluses," ")),config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var pluses=/\+/g,config=$.cookie=function(key,value,options){if(void 0!==value&&!$.isFunction(value)){if(options=$.extend({},config.defaults,options),"number"==typeof options.expires){var days=options.expires,t=options.expires=new Date;t.setDate(t.getDate()+days)}return document.cookie=[encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}for(var result=key?void 0:{},cookies=document.cookie?document.cookie.split("; "):[],i=0,l=cookies.length;l>i;i++){var parts=cookies[i].split("="),name=decode(parts.shift()),cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}key||void 0===(cookie=read(cookie))||(result[name]=cookie)}return result};config.defaults={},$.removeCookie=function(key,options){return void 0===$.cookie(key)?!1:($.cookie(key,"",$.extend({},options,{expires:-1})),!$.cookie(key))}});var page_title=jQuery(document).find("title").text(),page_url=window.location.href,page_referrer=document.referrer,form_saved=!1;jQuery(document).ready(function($){var hashkey=$.cookie("li_hash"),li_submission_cookie=$.cookie("li_submission");if(li_submission_cookie){var submission_data=JSON.parse(li_submission_cookie);leadin_insert_form_submission(submission_data.submission_hash,submission_data.hashkey,submission_data.page_title,submission_data.page_url,submission_data.json_form_fields,submission_data.lead_email,submission_data.lead_first_name,submission_data.lead_last_name,submission_data.lead_phone,submission_data.form_selector_id,submission_data.form_selector_classes,function(){$.removeCookie("li_submission",{path:"/",domain:""})})}hashkey||(hashkey=Math.random().toString(36).slice(2),$.cookie("li_hash",hashkey,{path:"/",domain:""}),leadin_insert_lead(hashkey,page_referrer)),leadin_log_pageview(hashkey,page_title,page_url,page_referrer,$.cookie("li_last_visit"));var date=new Date,current_time=date.getTime();date.setTime(date.getTime()+36e5),$.cookie("li_last_visit")||leadin_check_merged_contact(hashkey),$.cookie("li_last_visit",current_time,{path:"/",domain:"",expires:date})}),jQuery(function($){-1!=$.versioncompare($.fn.jquery,"1.7.0")?$(document).on("submit","form",function(){var $form=$(this).closest("form");leadin_submit_form($form,$)}):$(document).bind("submit","form",function(){var $form=$(this).closest("form");leadin_submit_form($form,$)})}),String.prototype.replaceArray=function(find,replace){for(var replaceString=this,i=0;i<find.length;i++)replaceString=1!=replace.length?replaceString.replace(find[i],replace[i]):replaceString.replace(find[i],replace[0]);return replaceString},function($){function normalize(version){return $.map(version.split("."),function(value){return parseInt(value,10)})}$.versioncompare=function(version1,version2){if("undefined"==typeof version1)throw new Error("$.versioncompare needs at least one parameter.");if(version2=version2||$.fn.jquery,version1==version2)return 0;for(var v1=normalize(version1),v2=normalize(version2),len=Math.max(v1.length,v2.length),i=0;len>i;i++)if(v1[i]=v1[i]||0,v2[i]=v2[i]||0,v1[i]!=v2[i])return v1[i]>v2[i]?1:-1;return 0}}(jQuery),function($){$.fn.classes=function(callback){var classes=[];if($.each(this,function(i,v){var splitClassName=v.className.split(/\s+/);for(var j in splitClassName){var className=splitClassName[j];-1===classes.indexOf(className)&&classes.push(className)}}),"function"==typeof callback)for(var i in classes)callback(classes[i]);return classes}}(jQuery);
|
inc/class-emailer.php
CHANGED
@@ -43,18 +43,7 @@ class LI_Emailer {
|
|
43 |
$options = get_option('leadin_options');
|
44 |
$to = ( $options['li_email'] ? $options['li_email'] : get_bloginfo('admin_email') ); // Get email from plugin settings, if none set, use admin email
|
45 |
|
46 |
-
|
47 |
-
$subject = "Comment posted on " . $history->submission->form_page_title;
|
48 |
-
$subject .= " by " . $history->lead->lead_email;
|
49 |
-
}
|
50 |
-
elseif ( $history->lead->last_submission_type == "subscribe" ) {
|
51 |
-
$subject = "LeadIn Subscribe submission on " . $history->submission->form_page_title;
|
52 |
-
$subject .= " by " . $history->lead->lead_email;
|
53 |
-
}
|
54 |
-
else {
|
55 |
-
$subject = "Form submission on " . get_bloginfo('name') . " - " . $history->lead->lead_email;
|
56 |
-
}
|
57 |
-
|
58 |
$email_sent = wp_mail($to, $subject, $body, $headers);
|
59 |
|
60 |
return $email_sent;
|
@@ -149,7 +138,7 @@ class LI_Emailer {
|
|
149 |
$submission_Time = date('g:ia', strtotime($submission['event_date']));
|
150 |
$submission_url = $submission['form_page_url'];
|
151 |
$submission_page_title = $submission['form_page_title'];
|
152 |
-
$submission_form_fields = json_decode(
|
153 |
|
154 |
$format = '<table class="row lead-timeline__event submission" style="border-spacing: 0;border-collapse: collapse;padding: 0px;vertical-align: top;text-align: left;width: 100%%;position: relative;display: block;background-color: #fff;border-top: 1px solid #dedede;border-right: 1px solid #dedede;border-left: 4px solid #f6601d;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="wrapper" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="two columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 80px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-time" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">%s</p></td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td><td class="wrapper last" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;padding-right: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="ten columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 480px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-title" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">Filled out form on page <a href="%s" style="color: #2ba6cb;text-decoration: none;">%s</a></p> %s </td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td></tr></table>';
|
155 |
$built_sessions .= sprintf($format, $submission_Time, $submission_url, $submission_page_title, $this->build_form_fields($submission_form_fields));
|
@@ -173,8 +162,10 @@ class LI_Emailer {
|
|
173 |
{
|
174 |
foreach ( $form_fields as $field )
|
175 |
{
|
|
|
|
|
176 |
$format = '<p class="lead-timeline__submission-field" style="margin: 0;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;"><label class="lead-timeline__submission-label" style="text-transform: uppercase;font-size: 12px;color: #999;letter-spacing: 0.05em;">%s</label><br/>%s </p>';
|
177 |
-
$built_form_fields .= sprintf($format, $field->label, $field->value);
|
178 |
}
|
179 |
}
|
180 |
|
@@ -248,29 +239,18 @@ class LI_Emailer {
|
|
248 |
|
249 |
// Form Submission section open
|
250 |
$body .= "<table class='row section form-submission' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;position: relative;display: block;background: #deedf8;padding: 0px;' bgcolor='#deedf8'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;position: relative;padding: 0 0px 0 0;' align='left' valign='top'>";
|
251 |
-
|
252 |
-
// Form Submission section header
|
253 |
-
//$body .= $this->build_submission_header($history->submission, TRUE);
|
254 |
|
255 |
$submission = $history->submission;
|
256 |
$submission_Time = date('g:ia', strtotime($submission['event_date']));
|
257 |
$submission_url = $submission['form_page_url'];
|
258 |
$submission_page_title = $submission['form_page_title'];
|
259 |
-
$submission_form_fields = json_decode(
|
260 |
|
261 |
$format = '<table class="row lead-timeline__event submission" style="border-spacing: 0;border-collapse: collapse;padding: 0px;vertical-align: top;text-align: left;width: 100%%;position: relative;display: block;background-color: #fff;border-top: 1px solid #dedede;border-right: 1px solid #dedede;border-left: 4px solid #f6601d;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="wrapper" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="two columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 80px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-time" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">%s</p></td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td><td class="wrapper last" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;padding-right: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="ten columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 480px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-title" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">Filled out form on page <a href="%s" style="color: #2ba6cb;text-decoration: none;">%s</a></p> %s </td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td></tr></table>';
|
262 |
$built_sessions = sprintf($format, $submission_Time, $submission_url, $submission_page_title, $this->build_form_fields($submission_form_fields));
|
263 |
|
264 |
$body .= $built_sessions;
|
265 |
|
266 |
-
/*// Form Submission Rows
|
267 |
-
$fields = json_decode(stripslashes($history->submission->form_fields), true);
|
268 |
-
|
269 |
-
foreach ( $fields as $field )
|
270 |
-
{
|
271 |
-
$body .= $this->build_submission_row($field);
|
272 |
-
}*/
|
273 |
-
|
274 |
// Form Submission Section Close
|
275 |
$body .= "</td></tr></table>";
|
276 |
|
@@ -304,45 +284,4 @@ class LI_Emailer {
|
|
304 |
$email_sent = wp_mail($history->lead->lead_email, $subject, $body, $headers);
|
305 |
return $email_sent;
|
306 |
}
|
307 |
-
|
308 |
-
/**
|
309 |
-
* Builds the blue form submission header for the lead email
|
310 |
-
*
|
311 |
-
* @param object $submission
|
312 |
-
* @param bool confirmation_email should be sent or not
|
313 |
-
* @return string
|
314 |
-
*/
|
315 |
-
function build_submission_header ( $submission, $confirmation_email = FALSE )
|
316 |
-
{
|
317 |
-
// @EMAIL Use these variables to construct the heading for the form section
|
318 |
-
$form_page_title = "<a href='" . $submission->form_page_url . "'>" . $submission->form_page_title . "</a>";
|
319 |
-
$form_submission_day = date('M j' , strtotime($submission->form_date));
|
320 |
-
$form_submission_time = date('g:i a', strtotime($submission->form_date));
|
321 |
-
$form_submission_type = $submission->form_type;
|
322 |
-
|
323 |
-
$submissionHeader = "";
|
324 |
-
|
325 |
-
// Form Submission header open
|
326 |
-
$submissionHeader .= "<table class='twelve columns' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 580px;margin: 0 auto;padding: 0;'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='section-header' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;border-bottom-width: 1px;border-bottom-color: #c9e1f3;border-bottom-style: solid;background: #c9e1f3;padding: 15px 20px;' align='left' bgcolor='#c9e1f3' valign='top'>";
|
327 |
-
|
328 |
-
// Form Submission header content
|
329 |
-
$submissionHeader .= "<h3 style='color: #153d60;display: block;font-family: Helvetica, Arial, sans-serif;font-weight: bold;text-align: left;line-height: 1.3;word-break: normal;font-size: 16px;margin: 0;padding: 0;' align='left'>";
|
330 |
-
|
331 |
-
if ( $form_submission_type == "comment" )
|
332 |
-
{
|
333 |
-
$submissionHeader .= "Commented on " . $form_page_title . " on " . $form_submission_day . ' at ' . $form_submission_time;
|
334 |
-
}
|
335 |
-
else
|
336 |
-
{
|
337 |
-
$submissionHeader .= ( $confirmation_email ? "You filled out the subscription form on " : "Filled out a form on " ) . $form_page_title . " on " . $form_submission_day . ' at ' . $form_submission_time;
|
338 |
-
}
|
339 |
-
|
340 |
-
$submissionHeader .= "</h3>";
|
341 |
-
|
342 |
-
// Form Submission header close
|
343 |
-
$submissionHeader .= "</td><td class='expander' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;visibility: hidden;width: 0px;border-bottom-color: #c9e1f3;border-bottom-style: solid;padding: 0;border-width: 0 0 1px;' align='left' valign='top'></td></tr></table>";
|
344 |
-
|
345 |
-
return $submissionHeader;
|
346 |
-
}
|
347 |
-
|
348 |
}
|
43 |
$options = get_option('leadin_options');
|
44 |
$to = ( $options['li_email'] ? $options['li_email'] : get_bloginfo('admin_email') ); // Get email from plugin settings, if none set, use admin email
|
45 |
|
46 |
+
$subject = "Form submission on " . get_bloginfo('name') . " - " . $history->lead->lead_email;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
$email_sent = wp_mail($to, $subject, $body, $headers);
|
48 |
|
49 |
return $email_sent;
|
138 |
$submission_Time = date('g:ia', strtotime($submission['event_date']));
|
139 |
$submission_url = $submission['form_page_url'];
|
140 |
$submission_page_title = $submission['form_page_title'];
|
141 |
+
$submission_form_fields = json_decode($submission['form_fields']);
|
142 |
|
143 |
$format = '<table class="row lead-timeline__event submission" style="border-spacing: 0;border-collapse: collapse;padding: 0px;vertical-align: top;text-align: left;width: 100%%;position: relative;display: block;background-color: #fff;border-top: 1px solid #dedede;border-right: 1px solid #dedede;border-left: 4px solid #f6601d;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="wrapper" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="two columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 80px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-time" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">%s</p></td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td><td class="wrapper last" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;padding-right: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="ten columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 480px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-title" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">Filled out form on page <a href="%s" style="color: #2ba6cb;text-decoration: none;">%s</a></p> %s </td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td></tr></table>';
|
144 |
$built_sessions .= sprintf($format, $submission_Time, $submission_url, $submission_page_title, $this->build_form_fields($submission_form_fields));
|
162 |
{
|
163 |
foreach ( $form_fields as $field )
|
164 |
{
|
165 |
+
$field->value = str_replace("\n", "\\n", str_replace(array("\r\n"), "\n", $field->value));
|
166 |
+
|
167 |
$format = '<p class="lead-timeline__submission-field" style="margin: 0;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;"><label class="lead-timeline__submission-label" style="text-transform: uppercase;font-size: 12px;color: #999;letter-spacing: 0.05em;">%s</label><br/>%s </p>';
|
168 |
+
$built_form_fields .= sprintf($format, $field->label, leadin_html_line_breaks($field->value));
|
169 |
}
|
170 |
}
|
171 |
|
239 |
|
240 |
// Form Submission section open
|
241 |
$body .= "<table class='row section form-submission' style='border-spacing: 0;border-collapse: collapse;vertical-align: top;text-align: left;width: 100%;position: relative;display: block;background: #deedf8;padding: 0px;' bgcolor='#deedf8'><tr style='vertical-align: top;text-align: left;padding: 0;' align='left'><td class='wrapper last' style='word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse !important;vertical-align: top;text-align: left;position: relative;padding: 0 0px 0 0;' align='left' valign='top'>";
|
|
|
|
|
|
|
242 |
|
243 |
$submission = $history->submission;
|
244 |
$submission_Time = date('g:ia', strtotime($submission['event_date']));
|
245 |
$submission_url = $submission['form_page_url'];
|
246 |
$submission_page_title = $submission['form_page_title'];
|
247 |
+
$submission_form_fields = json_decode($submission['form_fields']);
|
248 |
|
249 |
$format = '<table class="row lead-timeline__event submission" style="border-spacing: 0;border-collapse: collapse;padding: 0px;vertical-align: top;text-align: left;width: 100%%;position: relative;display: block;background-color: #fff;border-top: 1px solid #dedede;border-right: 1px solid #dedede;border-left: 4px solid #f6601d;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="wrapper" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="two columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 80px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-time" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">%s</p></td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td><td class="wrapper last" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 10px 20px 0px 0px;vertical-align: top;text-align: left;position: relative;padding-right: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><table class="ten columns" style="border-spacing: 0;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;margin: 0 auto;width: 480px;"><tr style="padding: 0;vertical-align: top;text-align: left;"><td class="text-pad" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0px 0px 10px;vertical-align: top;text-align: left;padding-left: 10px;padding-right: 10px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"><p class="lead-timeline__event-title" style="margin: 0;color: #b34a12;font-family: Helvetica, Arial, sans-serif;font-weight: normal;padding: 0;text-align: left;line-height: 19px;font-size: 14px;margin-bottom: 10px;">Filled out form on page <a href="%s" style="color: #2ba6cb;text-decoration: none;">%s</a></p> %s </td><td class="expander" style="word-break: break-word;-webkit-hyphens: auto;-moz-hyphens: auto;hyphens: auto;border-collapse: collapse;padding: 0;vertical-align: top;text-align: left;visibility: hidden;width: 0px;color: #222222;font-family: Helvetica, Arial, sans-serif;font-weight: normal;margin: 0;line-height: 19px;font-size: 14px;"></td></tr></table></td></tr></table>';
|
250 |
$built_sessions = sprintf($format, $submission_Time, $submission_url, $submission_page_title, $this->build_form_fields($submission_form_fields));
|
251 |
|
252 |
$body .= $built_sessions;
|
253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
// Form Submission Section Close
|
255 |
$body .= "</td></tr></table>";
|
256 |
|
284 |
$email_sent = wp_mail($history->lead->lead_email, $subject, $body, $headers);
|
285 |
return $email_sent;
|
286 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
inc/class-leadin.php
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//=============================================
|
4 |
+
// WPLeadIn Class
|
5 |
+
//=============================================
|
6 |
+
class WPLeadIn {
|
7 |
+
|
8 |
+
var $power_ups;
|
9 |
+
var $options;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Class constructor
|
13 |
+
*/
|
14 |
+
function __construct ()
|
15 |
+
{
|
16 |
+
global $wpdb;
|
17 |
+
|
18 |
+
leadin_set_wpdb_tables();
|
19 |
+
|
20 |
+
//=============================================
|
21 |
+
// Hooks & Filters
|
22 |
+
//=============================================
|
23 |
+
|
24 |
+
$this->power_ups = $this->get_available_power_ups();
|
25 |
+
$this->options = get_option('leadin_options');
|
26 |
+
$this->add_leadin_frontend_scripts();
|
27 |
+
|
28 |
+
add_action('admin_bar_menu', array($this, 'add_leadin_link_to_admin_bar'), 999);
|
29 |
+
|
30 |
+
$li_wp_admin = new WPLeadInAdmin($this->power_ups);
|
31 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(&$li_wp_admin, 'leadin_plugin_settings_link'));
|
32 |
+
|
33 |
+
if ( isset($this->options['beta_tester']) && $this->options['beta_tester'] )
|
34 |
+
$li_wp_updater = new WPLeadInUpdater();
|
35 |
+
}
|
36 |
+
|
37 |
+
//=============================================
|
38 |
+
// Scripts & Styles
|
39 |
+
//=============================================
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Adds front end javascript + initializes ajax object
|
43 |
+
*/
|
44 |
+
function add_leadin_frontend_scripts ()
|
45 |
+
{
|
46 |
+
if ( !is_admin() )
|
47 |
+
{
|
48 |
+
wp_register_script('leadin-tracking', LEADIN_PATH . '/assets/js/build/leadin-tracking.min.js', array ('jquery'), FALSE, TRUE);
|
49 |
+
wp_enqueue_script('leadin-tracking');
|
50 |
+
|
51 |
+
// replace https with http for admin-ajax calls for SSLed backends
|
52 |
+
wp_localize_script('leadin-tracking', 'li_ajax', array('ajax_url' => str_replace('https:', 'http:', admin_url('admin-ajax.php'))));
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Adds LeadIn link to top-level admin bar
|
58 |
+
*/
|
59 |
+
function add_leadin_link_to_admin_bar( $wp_admin_bar ) {
|
60 |
+
global $wp_version;
|
61 |
+
|
62 |
+
$args = array(
|
63 |
+
'id' => 'leadin-admin-menu',
|
64 |
+
'title' => '<span class="ab-icon" '. ( $wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? ' style="margin-top: 3px;"' : ''). '><img src="/wp-content/plugins/leadin/images/leadin-svg-icon.svg" style="height:16px; width:16px;"></span><span class="ab-label">LeadIn</span>', // alter the title of existing node
|
65 |
+
'parent' => FALSE, // set parent to false to make it a top level (parent) node
|
66 |
+
'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_stats',
|
67 |
+
'meta' => array('title' => 'LeadIn')
|
68 |
+
);
|
69 |
+
|
70 |
+
$wp_admin_bar->add_node( $args );
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* List available power-ups
|
75 |
+
*/
|
76 |
+
public static function get_available_power_ups( $min_version = FALSE, $max_version = FALSE ) {
|
77 |
+
static $power_ups = null;
|
78 |
+
|
79 |
+
if ( ! isset( $power_ups ) ) {
|
80 |
+
$files = WPLeadIn::glob_php( LEADIN_PLUGIN_DIR . '/power-ups' );
|
81 |
+
|
82 |
+
$power_ups = array();
|
83 |
+
|
84 |
+
foreach ( $files as $file ) {
|
85 |
+
|
86 |
+
if ( ! $headers = WPLeadIn::get_power_up($file) ) {
|
87 |
+
continue;
|
88 |
+
}
|
89 |
+
|
90 |
+
$power_up = new $headers['class']($headers['activated']);
|
91 |
+
$power_up->power_up_name = $headers['name'];
|
92 |
+
$power_up->menu_text = $headers['menu_text'];
|
93 |
+
$power_up->menu_link = $headers['menu_link'];
|
94 |
+
$power_up->slug = $headers['slug'];
|
95 |
+
$power_up->link_uri = $headers['uri'];
|
96 |
+
$power_up->description = $headers['description'];
|
97 |
+
$power_up->icon = $headers['icon'];
|
98 |
+
$power_up->permanent = ( $headers['permanent'] == 'Yes' ? 1 : 0 );
|
99 |
+
$power_up->auto_activate = ( $headers['auto_activate'] == 'Yes' ? 1 : 0 );
|
100 |
+
$power_up->hidden = ( $headers['hidden'] == 'Yes' ? 1 : 0 );
|
101 |
+
$power_up->activated = $headers['activated'];
|
102 |
+
|
103 |
+
// Set the small icons HTML for the settings page
|
104 |
+
if ( strstr($headers['icon_small'], 'dashicons') )
|
105 |
+
$power_up->icon_small = '<span class="dashicons ' . $headers['icon_small'] . '"></span>';
|
106 |
+
else
|
107 |
+
$power_up->icon_small = '<img src="' . LEADIN_PATH . '/images/' . $headers['icon_small'] . '.png" class="power-up-settings-icon"/>';
|
108 |
+
|
109 |
+
array_push($power_ups, $power_up);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
return $power_ups;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Extract a power-up's slug from its full path.
|
118 |
+
*/
|
119 |
+
public static function get_power_up_slug ( $file ) {
|
120 |
+
return str_replace( '.php', '', basename( $file ) );
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Generate a power-up's path from its slug.
|
125 |
+
*/
|
126 |
+
public static function get_power_up_path ( $slug ) {
|
127 |
+
return LEADIN_PLUGIN_DIR . "/power-ups/$slug.php";
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Load power-up data from power-up file. Headers differ from WordPress
|
132 |
+
* plugin headers to avoid them being identified as standalone
|
133 |
+
* plugins on the WordPress plugins page.
|
134 |
+
*
|
135 |
+
* @param $power_up The file path for the power-up
|
136 |
+
* @return $pu array of power-up attributes
|
137 |
+
*/
|
138 |
+
public static function get_power_up ( $power_up )
|
139 |
+
{
|
140 |
+
$headers = array(
|
141 |
+
'name' => 'Power-up Name',
|
142 |
+
'class' => 'Power-up Class',
|
143 |
+
'menu_text' => 'Power-up Menu Text',
|
144 |
+
'menu_link' => 'Power-up Menu Link',
|
145 |
+
'slug' => 'Power-up Slug',
|
146 |
+
'uri' => 'Power-up URI',
|
147 |
+
'description' => 'Power-up Description',
|
148 |
+
'icon' => 'Power-up Icon',
|
149 |
+
'icon_small' => 'Power-up Icon Small',
|
150 |
+
'introduced' => 'First Introduced',
|
151 |
+
'auto_activate' => 'Auto Activate',
|
152 |
+
'permanent' => 'Permanently Enabled',
|
153 |
+
'power_up_tags' => 'Power-up Tags',
|
154 |
+
'hidden' => 'Hidden'
|
155 |
+
);
|
156 |
+
|
157 |
+
$file = WPLeadIn::get_power_up_path( WPLeadIn::get_power_up_slug( $power_up ) );
|
158 |
+
if ( ! file_exists( $file ) )
|
159 |
+
return FALSE;
|
160 |
+
|
161 |
+
$pu = get_file_data( $file, $headers );
|
162 |
+
|
163 |
+
if ( empty( $pu['name'] ) )
|
164 |
+
return FALSE;
|
165 |
+
|
166 |
+
$pu['activated'] = self::is_power_up_active($pu['slug']);
|
167 |
+
|
168 |
+
return $pu;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Returns an array of all PHP files in the specified absolute path.
|
173 |
+
* Equivalent to glob( "$absolute_path/*.php" ).
|
174 |
+
*
|
175 |
+
* @param string $absolute_path The absolute path of the directory to search.
|
176 |
+
* @return array Array of absolute paths to the PHP files.
|
177 |
+
*/
|
178 |
+
public static function glob_php( $absolute_path ) {
|
179 |
+
$absolute_path = untrailingslashit( $absolute_path );
|
180 |
+
$files = array();
|
181 |
+
if ( ! $dir = @opendir( $absolute_path ) ) {
|
182 |
+
return $files;
|
183 |
+
}
|
184 |
+
|
185 |
+
while ( FALSE !== $file = readdir( $dir ) ) {
|
186 |
+
if ( '.' == substr( $file, 0, 1 ) || '.php' != substr( $file, -4 ) ) {
|
187 |
+
continue;
|
188 |
+
}
|
189 |
+
|
190 |
+
$file = "$absolute_path/$file";
|
191 |
+
|
192 |
+
if ( ! is_file( $file ) ) {
|
193 |
+
continue;
|
194 |
+
}
|
195 |
+
|
196 |
+
$files[] = $file;
|
197 |
+
}
|
198 |
+
|
199 |
+
$files = leadin_sort_power_ups($files, array(
|
200 |
+
LEADIN_PLUGIN_DIR . '/power-ups/contacts.php',
|
201 |
+
LEADIN_PLUGIN_DIR . '/power-ups/subscribe-widget.php',
|
202 |
+
LEADIN_PLUGIN_DIR . '/power-ups/mailchimp-list-sync.php',
|
203 |
+
LEADIN_PLUGIN_DIR . '/power-ups/constant-contact-list-sync.php',
|
204 |
+
LEADIN_PLUGIN_DIR . '/power-ups/beta-program.php'
|
205 |
+
));
|
206 |
+
|
207 |
+
closedir( $dir );
|
208 |
+
|
209 |
+
return $files;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Check whether or not a LeadIn power-up is active.
|
214 |
+
*
|
215 |
+
* @param string $power_up The slug of a power-up
|
216 |
+
* @return bool
|
217 |
+
*
|
218 |
+
* @static
|
219 |
+
*/
|
220 |
+
public static function is_power_up_active( $power_up_slug )
|
221 |
+
{
|
222 |
+
return in_array($power_up_slug, self::get_active_power_ups());
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Get a list of activated modules as an array of module slugs.
|
227 |
+
*/
|
228 |
+
public static function get_active_power_ups ()
|
229 |
+
{
|
230 |
+
$activated_power_ups = get_option('leadin_active_power_ups');
|
231 |
+
if ( $activated_power_ups )
|
232 |
+
return array_unique(unserialize($activated_power_ups));
|
233 |
+
else
|
234 |
+
return array();
|
235 |
+
}
|
236 |
+
|
237 |
+
public static function activate_power_up( $power_up_slug, $exit = TRUE )
|
238 |
+
{
|
239 |
+
if ( ! strlen( $power_up_slug ) )
|
240 |
+
return FALSE;
|
241 |
+
|
242 |
+
// If it's already active, then don't do it again
|
243 |
+
$active = self::is_power_up_active($power_up_slug);
|
244 |
+
if ( $active )
|
245 |
+
return TRUE;
|
246 |
+
|
247 |
+
$activated_power_ups = get_option('leadin_active_power_ups');
|
248 |
+
|
249 |
+
if ( $activated_power_ups )
|
250 |
+
{
|
251 |
+
$activated_power_ups = unserialize($activated_power_ups);
|
252 |
+
$activated_power_ups[] = $power_up_slug;
|
253 |
+
}
|
254 |
+
else
|
255 |
+
{
|
256 |
+
$activated_power_ups = array($power_up_slug);
|
257 |
+
}
|
258 |
+
|
259 |
+
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
260 |
+
|
261 |
+
|
262 |
+
if ( $exit )
|
263 |
+
{
|
264 |
+
exit;
|
265 |
+
}
|
266 |
+
|
267 |
+
}
|
268 |
+
|
269 |
+
public static function deactivate_power_up( $power_up_slug, $exit = TRUE )
|
270 |
+
{
|
271 |
+
if ( ! strlen( $power_up_slug ) )
|
272 |
+
return FALSE;
|
273 |
+
|
274 |
+
// If it's already active, then don't do it again
|
275 |
+
$active = self::is_power_up_active($power_up_slug);
|
276 |
+
if ( ! $active )
|
277 |
+
return TRUE;
|
278 |
+
|
279 |
+
$activated_power_ups = get_option('leadin_active_power_ups');
|
280 |
+
|
281 |
+
$power_ups_left = leadin_array_delete(unserialize($activated_power_ups), $power_up_slug);
|
282 |
+
update_option('leadin_active_power_ups', serialize($power_ups_left));
|
283 |
+
|
284 |
+
if ( $exit )
|
285 |
+
{
|
286 |
+
exit;
|
287 |
+
}
|
288 |
+
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
//=============================================
|
293 |
+
// LeadIn Init
|
294 |
+
//=============================================
|
295 |
+
|
296 |
+
global $li_wp_admin;
|
inc/leadin-ajax-functions.php
CHANGED
@@ -18,17 +18,17 @@ function leadin_check_merged_contact ()
|
|
18 |
$stale_hash = $_POST['li_id'];
|
19 |
|
20 |
// Check if hashkey is in a merged contact
|
21 |
-
$q = $wpdb->prepare("SELECT hashkey, merged_hashkeys FROM li_leads WHERE merged_hashkeys LIKE '%%%s%%'
|
22 |
$row = $wpdb->get_row($q);
|
23 |
|
24 |
if ( isset($row->hashkey) && $stale_hash )
|
25 |
{
|
26 |
// One final update to set all the previous pageviews to the new hashkey
|
27 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey = %s
|
28 |
$wpdb->query($q);
|
29 |
|
30 |
// One final update to set all the previous submissions to the new hashkey
|
31 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey = %s
|
32 |
$wpdb->query($q);
|
33 |
|
34 |
// Remove the passed hash from the merged hashkeys for the row
|
@@ -37,7 +37,7 @@ function leadin_check_merged_contact ()
|
|
37 |
// Delete the stale hash from the merged hashkeys array
|
38 |
$merged_hashkeys = leadin_array_delete($merged_hashkeys, "'" . $stale_hash . "'");
|
39 |
|
40 |
-
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = %s WHERE hashkey = %s
|
41 |
$wpdb->query($q);
|
42 |
|
43 |
echo json_encode($row->hashkey);
|
@@ -69,17 +69,16 @@ function leadin_log_pageview ()
|
|
69 |
$last_visit = ( isset($_POST['li_last_visit']) ? $_POST['li_last_visit'] : 0 );
|
70 |
|
71 |
$result = $wpdb->insert(
|
72 |
-
|
73 |
array(
|
74 |
'lead_hashkey' => $hash,
|
75 |
'pageview_title' => $title,
|
76 |
'pageview_url' => $url,
|
77 |
'pageview_source' => $source,
|
78 |
-
'pageview_session_start' => ( !$last_visit ? 1 : 0 )
|
79 |
-
'blog_id' => $wpdb->blogid
|
80 |
),
|
81 |
array(
|
82 |
-
'%s', '%s', '%s', '%s', '%s'
|
83 |
)
|
84 |
);
|
85 |
|
@@ -103,15 +102,14 @@ function leadin_insert_lead ()
|
|
103 |
$source = ( isset($_POST['li_referrer']) ? $_POST['li_referrer'] : '' );
|
104 |
|
105 |
$result = $wpdb->insert(
|
106 |
-
|
107 |
array(
|
108 |
'hashkey' => $hashkey,
|
109 |
'lead_ip' => $ipaddress,
|
110 |
-
'lead_source' => $source
|
111 |
-
'blog_id' => $wpdb->blogid
|
112 |
),
|
113 |
array(
|
114 |
-
'%s', '%s', '%s'
|
115 |
)
|
116 |
);
|
117 |
|
@@ -139,14 +137,14 @@ function leadin_insert_form_submission ()
|
|
139 |
$first_name = $_POST['li_first_name'];
|
140 |
$last_name = $_POST['li_last_name'];
|
141 |
$phone = $_POST['li_phone'];
|
142 |
-
$submission_type = $_POST['li_submission_type'];
|
143 |
$form_selector_id = $_POST['li_form_selector_id'];
|
144 |
$form_selector_classes = $_POST['li_form_selector_classes'];
|
145 |
$options = get_option('leadin_options');
|
146 |
$li_admin_email = ( isset($options['li_email']) ) ? $options['li_email'] : '';
|
|
|
147 |
|
148 |
// Check to see if the form_hashkey exists, and if it does, don't run the insert or send the email
|
149 |
-
$q = $wpdb->prepare("SELECT form_hashkey FROM li_submissions WHERE form_hashkey = %s AND form_deleted = 0
|
150 |
$submission_hash_exists = $wpdb->get_var($q);
|
151 |
|
152 |
if ( $submission_hash_exists )
|
@@ -156,154 +154,164 @@ function leadin_insert_form_submission ()
|
|
156 |
exit;
|
157 |
}
|
158 |
|
159 |
-
//
|
160 |
-
|
161 |
-
|
162 |
-
// Get the contact row tied to hashkey
|
163 |
-
$q = $wpdb->prepare("SELECT * FROM li_leads WHERE hashkey = %s AND lead_deleted = 0 " . $wpdb->multisite_query, $hashkey);
|
164 |
-
$contact = $wpdb->get_row($q);
|
165 |
-
|
166 |
-
// Check for existing contacts based on whether the email is present in the contacts table
|
167 |
-
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys, lead_status FROM li_leads WHERE lead_email = %s AND hashkey != %s AND lead_deleted = 0 " . $wpdb->multisite_query, $email, $hashkey);
|
168 |
-
$existing_contacts = $wpdb->get_results($q);
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
177 |
|
178 |
-
|
179 |
-
|
|
|
|
|
180 |
{
|
181 |
-
|
182 |
-
|
183 |
-
// Start with the existing contact's hashkeys and create a string containg comma-deliminated hashes
|
184 |
-
$existing_contact_hashkeys .= "'" . $existing_contacts[$i]->hashkey . "'";
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
|
|
193 |
|
194 |
-
|
195 |
-
|
196 |
-
$existing_contact_status = 'comment';
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
$existing_contact_status = 'subscribe';
|
201 |
-
}
|
202 |
|
203 |
-
|
204 |
-
|
|
|
205 |
|
206 |
-
|
207 |
-
|
|
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
array(
|
229 |
-
'form_hashkey' => $submission_hash,
|
230 |
-
'lead_hashkey' => $hashkey,
|
231 |
-
'form_page_title' => $page_title,
|
232 |
-
'form_page_url' => $page_url,
|
233 |
-
'form_fields' => $form_json,
|
234 |
-
'form_type' => $submission_type,
|
235 |
-
'form_selector_id' => $form_selector_id,
|
236 |
-
'form_selector_classes' => $form_selector_classes,
|
237 |
-
'blog_id' => $wpdb->blogid
|
238 |
-
),
|
239 |
-
array(
|
240 |
-
'%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'
|
241 |
-
)
|
242 |
-
);
|
243 |
-
|
244 |
-
$contact_status = $submission_type;
|
245 |
-
|
246 |
-
// If a contact was manually set to a stage in the funnel, don't change it with smart rules
|
247 |
-
if ( $contact->lead_status != 'lead' && $contact->lead_status != 'contacted' && $contact->lead_status != 'customer' )
|
248 |
-
{
|
249 |
-
// Override the status because comment is further down the funnel than contact
|
250 |
-
if ( $contact->lead_status == 'comment' && $submission_type == 'general' )
|
251 |
-
$contact_status = 'comment';
|
252 |
-
// Override the status because subscribe is further down the funnel than contact and comment
|
253 |
-
else if ( $contact->lead_status == 'subscribe' && ($submission_type == 'general' || $submission_type == 'comment') )
|
254 |
-
$contact_status = 'subscribe';
|
255 |
-
|
256 |
-
// Override the status with the merged contacts status if the children have a status further down the funnel
|
257 |
-
if ( $existing_contact_status == 'comment' && $submission_type == 'general' )
|
258 |
-
$contact_status = 'comment';
|
259 |
-
else if ( $existing_contact_status == 'subscribe' && ($submission_type == 'general' || $submission_type == 'comment') )
|
260 |
-
$contact_status = 'subscribe';
|
261 |
-
}
|
262 |
-
else
|
263 |
-
$contact_status = $contact->lead_status;
|
264 |
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
|
|
268 |
|
269 |
-
|
270 |
-
if ( $contact_status == 'subscribe' )
|
271 |
{
|
272 |
-
$
|
273 |
-
|
274 |
-
if ( in_array('mailchimp_list_sync', $active_power_ups) )
|
275 |
{
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
285 |
}
|
|
|
286 |
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
-
if ( $
|
290 |
{
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
}
|
|
|
294 |
|
295 |
-
|
296 |
-
{
|
297 |
-
// Send the subscription confirmation kickback email
|
298 |
-
$leadin_subscribe_settings = get_option('leadin_subscribe_options');
|
299 |
-
if ( !isset($leadin_subscribe_settings['li_subscribe_confirmation']) || $leadin_subscribe_settings['li_subscribe_confirmation'] )
|
300 |
-
$li_emailer->send_subscriber_confirmation_email($hashkey);
|
301 |
-
}
|
302 |
|
303 |
-
|
|
|
304 |
|
305 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
}
|
308 |
|
309 |
add_action('wp_ajax_leadin_insert_form_submission', 'leadin_insert_form_submission'); // Call when user logged in
|
@@ -320,12 +328,13 @@ function leadin_check_visitor_status ()
|
|
320 |
|
321 |
$hash = $_POST['li_id'];
|
322 |
|
323 |
-
|
324 |
-
$
|
|
|
325 |
|
326 |
-
if (
|
327 |
{
|
328 |
-
echo json_encode(
|
329 |
die();
|
330 |
}
|
331 |
else
|
@@ -355,7 +364,6 @@ add_action('wp_ajax_nopriv_leadin_subscribe_show', 'leadin_subscribe_show'); //
|
|
355 |
/**
|
356 |
* Gets post and pages (name + title) for contacts filtering
|
357 |
*
|
358 |
-
* @param int
|
359 |
* @return json object
|
360 |
*/
|
361 |
function leadin_get_posts_and_pages ( )
|
@@ -364,9 +372,16 @@ function leadin_get_posts_and_pages ( )
|
|
364 |
|
365 |
$search_term = $_POST['search_term'];
|
366 |
|
367 |
-
$q = $wpdb->prepare("SELECT post_title, post_name
|
368 |
$wp_posts = $wpdb->get_results($q);
|
369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
echo json_encode($wp_posts);
|
371 |
die();
|
372 |
}
|
@@ -374,4 +389,56 @@ function leadin_get_posts_and_pages ( )
|
|
374 |
add_action('wp_ajax_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user logged in
|
375 |
add_action('wp_ajax_nopriv_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user is not logged in
|
376 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
?>
|
18 |
$stale_hash = $_POST['li_id'];
|
19 |
|
20 |
// Check if hashkey is in a merged contact
|
21 |
+
$q = $wpdb->prepare("SELECT hashkey, merged_hashkeys FROM $wpdb->li_leads WHERE merged_hashkeys LIKE '%%%s%%'", like_escape($stale_hash));
|
22 |
$row = $wpdb->get_row($q);
|
23 |
|
24 |
if ( isset($row->hashkey) && $stale_hash )
|
25 |
{
|
26 |
// One final update to set all the previous pageviews to the new hashkey
|
27 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_pageviews SET lead_hashkey = %s WHERE lead_hashkey = %s", $row->hashkey, $stale_hash);
|
28 |
$wpdb->query($q);
|
29 |
|
30 |
// One final update to set all the previous submissions to the new hashkey
|
31 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_submissions SET lead_hashkey = %s WHERE lead_hashkey = %s", $row->hashkey, $stale_hash);
|
32 |
$wpdb->query($q);
|
33 |
|
34 |
// Remove the passed hash from the merged hashkeys for the row
|
37 |
// Delete the stale hash from the merged hashkeys array
|
38 |
$merged_hashkeys = leadin_array_delete($merged_hashkeys, "'" . $stale_hash . "'");
|
39 |
|
40 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_leads SET merged_hashkeys = %s WHERE hashkey = %s", rtrim(implode(',', $merged_hashkeys), ','), $row->hashkey);
|
41 |
$wpdb->query($q);
|
42 |
|
43 |
echo json_encode($row->hashkey);
|
69 |
$last_visit = ( isset($_POST['li_last_visit']) ? $_POST['li_last_visit'] : 0 );
|
70 |
|
71 |
$result = $wpdb->insert(
|
72 |
+
$wpdb->li_pageviews,
|
73 |
array(
|
74 |
'lead_hashkey' => $hash,
|
75 |
'pageview_title' => $title,
|
76 |
'pageview_url' => $url,
|
77 |
'pageview_source' => $source,
|
78 |
+
'pageview_session_start' => ( !$last_visit ? 1 : 0 )
|
|
|
79 |
),
|
80 |
array(
|
81 |
+
'%s', '%s', '%s', '%s', '%s'
|
82 |
)
|
83 |
);
|
84 |
|
102 |
$source = ( isset($_POST['li_referrer']) ? $_POST['li_referrer'] : '' );
|
103 |
|
104 |
$result = $wpdb->insert(
|
105 |
+
$wpdb->li_leads,
|
106 |
array(
|
107 |
'hashkey' => $hashkey,
|
108 |
'lead_ip' => $ipaddress,
|
109 |
+
'lead_source' => $source
|
|
|
110 |
),
|
111 |
array(
|
112 |
+
'%s', '%s', '%s'
|
113 |
)
|
114 |
);
|
115 |
|
137 |
$first_name = $_POST['li_first_name'];
|
138 |
$last_name = $_POST['li_last_name'];
|
139 |
$phone = $_POST['li_phone'];
|
|
|
140 |
$form_selector_id = $_POST['li_form_selector_id'];
|
141 |
$form_selector_classes = $_POST['li_form_selector_classes'];
|
142 |
$options = get_option('leadin_options');
|
143 |
$li_admin_email = ( isset($options['li_email']) ) ? $options['li_email'] : '';
|
144 |
+
$contact_type = 'contact'; // used at bottom of function
|
145 |
|
146 |
// Check to see if the form_hashkey exists, and if it does, don't run the insert or send the email
|
147 |
+
$q = $wpdb->prepare("SELECT form_hashkey FROM $wpdb->li_submissions WHERE form_hashkey = %s AND form_deleted = 0", $submission_hash);
|
148 |
$submission_hash_exists = $wpdb->get_var($q);
|
149 |
|
150 |
if ( $submission_hash_exists )
|
154 |
exit;
|
155 |
}
|
156 |
|
157 |
+
// Get the contact row tied to hashkey
|
158 |
+
$q = $wpdb->prepare("SELECT * FROM $wpdb->li_leads WHERE hashkey = %s AND lead_deleted = 0", $hashkey);
|
159 |
+
$contact = $wpdb->get_row($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
+
// Check for existing contacts based on whether the email is present in the contacts table
|
162 |
+
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys FROM $wpdb->li_leads WHERE lead_email = %s AND hashkey != %s AND lead_deleted = 0", $email, $hashkey);
|
163 |
+
$existing_contacts = $wpdb->get_results($q);
|
164 |
+
|
165 |
+
// Setup the string for the existing hashkeys
|
166 |
+
$existing_contact_hashkeys = $contact->merged_hashkeys;
|
167 |
+
if ( $contact->merged_hashkeys && count($existing_contacts) )
|
168 |
+
$existing_contact_hashkeys .= ',';
|
169 |
|
170 |
+
// Do some merging if the email exists already in the contact table
|
171 |
+
if ( count($existing_contacts) )
|
172 |
+
{
|
173 |
+
for ( $i = 0; $i < count($existing_contacts); $i++ )
|
174 |
{
|
175 |
+
// Start with the existing contact's hashkeys and create a string containg comma-deliminated hashes
|
176 |
+
$existing_contact_hashkeys .= "'" . $existing_contacts[$i]->hashkey . "'";
|
|
|
|
|
177 |
|
178 |
+
// Add any of those existing contact row's merged hashkeys
|
179 |
+
if ( $existing_contacts[$i]->merged_hashkeys )
|
180 |
+
$existing_contact_hashkeys .= "," . $existing_contacts[$i]->merged_hashkeys;
|
181 |
|
182 |
+
// Add a comma delimiter
|
183 |
+
if ( $i != count($existing_contacts)-1 )
|
184 |
+
$existing_contact_hashkeys .= ",";
|
185 |
+
}
|
186 |
|
187 |
+
// Remove duplicates from the array
|
188 |
+
$existing_contact_hashkeys = implode(',', array_unique(explode(',', $existing_contact_hashkeys)));
|
|
|
189 |
|
190 |
+
// Safety precaution - trim any trailing commas
|
191 |
+
$existing_contact_hashkeys = rtrim($existing_contact_hashkeys, ',');
|
|
|
|
|
192 |
|
193 |
+
// Update all the previous pageviews to the new hashkey
|
194 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkeys )", $hashkey);
|
195 |
+
$wpdb->query($q);
|
196 |
|
197 |
+
// Update all the previous submissions to the new hashkey
|
198 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkeys )", $hashkey);
|
199 |
+
$wpdb->query($q);
|
200 |
|
201 |
+
// Update all the previous submissions to the new hashkey
|
202 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_tag_relationships SET contact_hashkey = %s WHERE contact_hashkey IN ( $existing_contact_hashkeys )", $hashkey);
|
203 |
+
$wpdb->query($q);
|
204 |
|
205 |
+
// "Delete" all the old leads from the leads table
|
206 |
+
$wpdb->query("UPDATE $wpdb->li_leads SET lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkeys )");
|
207 |
+
}
|
208 |
|
209 |
+
// Prevent duplicate form submission entries by deleting existing submissions if it didn't finish the process before the web page refreshed
|
210 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_submissions SET form_deleted = 1 WHERE form_hashkey = %s", $submission_hash);
|
211 |
+
$wpdb->query($q);
|
212 |
|
213 |
+
// Insert the form fields and hash into the submissions table
|
214 |
+
$result = $wpdb->insert(
|
215 |
+
$wpdb->li_submissions,
|
216 |
+
array(
|
217 |
+
'form_hashkey' => $submission_hash,
|
218 |
+
'lead_hashkey' => $hashkey,
|
219 |
+
'form_page_title' => $page_title,
|
220 |
+
'form_page_url' => $page_url,
|
221 |
+
'form_fields' => $form_json,
|
222 |
+
'form_selector_id' => $form_selector_id,
|
223 |
+
'form_selector_classes' => $form_selector_classes
|
224 |
+
),
|
225 |
+
array(
|
226 |
+
'%s', '%s', '%s', '%s', '%s', '%s', '%s'
|
227 |
+
)
|
228 |
+
);
|
229 |
|
230 |
+
// Update the contact with the new email, status and merged hashkeys
|
231 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_leads SET lead_email = %s, merged_hashkeys = %s WHERE hashkey = %s", $email, $existing_contact_hashkeys, $hashkey);
|
232 |
+
$rows_updated = $wpdb->query($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
+
// Apply the tag relationship to contacts for form id rules
|
235 |
+
if ( $form_selector_id )
|
236 |
+
{
|
237 |
+
$q = $wpdb->prepare("SELECT tag_id, tag_synced_lists FROM $wpdb->li_tags WHERE tag_form_selectors LIKE '%%%s%%' AND tag_deleted = 0", '#' . $form_selector_id);
|
238 |
+
$tagged_lists = $wpdb->get_results($q);
|
239 |
|
240 |
+
if ( count($tagged_lists) )
|
|
|
241 |
{
|
242 |
+
foreach ( $tagged_lists as $list )
|
|
|
|
|
243 |
{
|
244 |
+
$tag_added = leadin_apply_tag_to_contact($list->tag_id, $contact->hashkey);
|
245 |
+
|
246 |
+
$contact_type = 'tagged contact';
|
247 |
+
|
248 |
+
if ( $tag_added && $list->tag_synced_lists )
|
249 |
+
{
|
250 |
+
foreach ( unserialize($list->tag_synced_lists) as $synced_list )
|
251 |
+
{
|
252 |
+
// e.g. leadin_constant_contact_list_sync_wp
|
253 |
+
$leadin_esp_wp = 'leadin_' . $synced_list['esp'] . '_list_sync_wp';
|
254 |
+
global ${$leadin_esp_wp};
|
255 |
+
|
256 |
+
if ( ${$leadin_esp_wp}->activated )
|
257 |
+
${$leadin_esp_wp}->push_contact_to_list($synced_list['list_id'], $email, $first_name, $last_name, $phone);
|
258 |
+
}
|
259 |
+
}
|
260 |
}
|
261 |
}
|
262 |
+
}
|
263 |
|
264 |
+
// Apply the tag relationship to contacts for class rules
|
265 |
+
$form_classes = explode(',', $form_selector_classes);
|
266 |
+
foreach ( $form_classes as $class )
|
267 |
+
{
|
268 |
+
$q = $wpdb->prepare("SELECT tag_id, tag_synced_lists FROM $wpdb->li_tags WHERE tag_form_selectors LIKE '%%%s%%' AND tag_deleted = 0", '.' . $class);
|
269 |
+
$tagged_lists = $wpdb->get_results($q);
|
270 |
|
271 |
+
if ( count($tagged_lists) )
|
272 |
{
|
273 |
+
foreach ( $tagged_lists as $list )
|
274 |
+
{
|
275 |
+
$tag_added = leadin_apply_tag_to_contact($list->tag_id, $contact->hashkey);
|
276 |
+
|
277 |
+
$contact_type = 'tagged contact';
|
278 |
+
|
279 |
+
if ( $tag_added && $list->tag_synced_lists )
|
280 |
+
{
|
281 |
+
foreach ( unserialize($list->tag_synced_lists) as $synced_list )
|
282 |
+
{
|
283 |
+
// e.g. leadin_constant_contact_list_sync_wp
|
284 |
+
$leadin_esp_wp = 'leadin_' . $synced_list['esp'] . '_list_sync_wp';
|
285 |
+
global ${$leadin_esp_wp};
|
286 |
+
|
287 |
+
if ( ${$leadin_esp_wp}->activated )
|
288 |
+
${$leadin_esp_wp}->push_contact_to_list($synced_list['list_id'], $email, $first_name, $last_name, $phone);
|
289 |
+
}
|
290 |
+
}
|
291 |
+
}
|
292 |
}
|
293 |
+
}
|
294 |
|
295 |
+
$li_emailer = new LI_Emailer();
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
+
if ( $li_admin_email )
|
298 |
+
$li_emailer->send_new_lead_email($hashkey); // Send the contact notification email
|
299 |
|
300 |
+
if ( strstr($form_selector_classes, 'vex-dialog-form') )
|
301 |
+
{
|
302 |
+
// Send the subscription confirmation kickback email
|
303 |
+
$leadin_subscribe_settings = get_option('leadin_subscribe_options');
|
304 |
+
if ( !isset($leadin_subscribe_settings['li_subscribe_confirmation']) || $leadin_subscribe_settings['li_subscribe_confirmation'] )
|
305 |
+
$li_emailer->send_subscriber_confirmation_email($hashkey);
|
306 |
+
|
307 |
+
$contact_type = 'subscriber';
|
308 |
}
|
309 |
+
else if ( strstr($form_selector_id, 'commentform') )
|
310 |
+
$contact_type = 'comment';
|
311 |
+
|
312 |
+
leadin_track_plugin_activity("New lead", array("contact_type" => $contact_type));
|
313 |
+
|
314 |
+
return $rows_updated;
|
315 |
}
|
316 |
|
317 |
add_action('wp_ajax_leadin_insert_form_submission', 'leadin_insert_form_submission'); // Call when user logged in
|
328 |
|
329 |
$hash = $_POST['li_id'];
|
330 |
|
331 |
+
// SELECT whether the hashkey is tied to the li_tags list that is for the subscriber
|
332 |
+
$q = $wpdb->prepare("SELECT contact_hashkey FROM $wpdb->li_tag_relationships ltr, $wpdb->li_tags lt WHERE lt.tag_form_selectors LIKE '%vex-dialog-form%' AND lt.tag_id = ltr.tag_id AND ltr.contact_hashkey = %s AND lt.tag_deleted = 0", $hash);
|
333 |
+
$vex_set = $wpdb->get_var($q);
|
334 |
|
335 |
+
if ( $vex_set )
|
336 |
{
|
337 |
+
echo json_encode('vex_set');
|
338 |
die();
|
339 |
}
|
340 |
else
|
364 |
/**
|
365 |
* Gets post and pages (name + title) for contacts filtering
|
366 |
*
|
|
|
367 |
* @return json object
|
368 |
*/
|
369 |
function leadin_get_posts_and_pages ( )
|
372 |
|
373 |
$search_term = $_POST['search_term'];
|
374 |
|
375 |
+
$q = $wpdb->prepare("SELECT post_title, post_name FROM " . $wpdb->prefix . "posts WHERE post_status = 'publish' AND ( post_name LIKE '%%%s%%' OR post_title LIKE '%%%s%%' ) GROUP BY post_name ORDER BY post_date DESC LIMIT 25", $search_term, $search_term);
|
376 |
$wp_posts = $wpdb->get_results($q);
|
377 |
|
378 |
+
if ( ! $_POST['search_term'] )
|
379 |
+
{
|
380 |
+
$obj_any_page = (Object)Null;
|
381 |
+
$obj_any_page->post_title = $obj_any_page->post_name = 'any page';
|
382 |
+
array_unshift($wp_posts, $obj_any_page);
|
383 |
+
}
|
384 |
+
|
385 |
echo json_encode($wp_posts);
|
386 |
die();
|
387 |
}
|
389 |
add_action('wp_ajax_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user logged in
|
390 |
add_action('wp_ajax_nopriv_leadin_get_posts_and_pages', 'leadin_get_posts_and_pages'); // Call when user is not logged in
|
391 |
|
392 |
+
/**
|
393 |
+
* Gets form selectors
|
394 |
+
*
|
395 |
+
* @return json object
|
396 |
+
*/
|
397 |
+
function leadin_get_form_selectors ( )
|
398 |
+
{
|
399 |
+
global $wpdb;
|
400 |
+
|
401 |
+
$search_term = $_POST['search_term'];
|
402 |
+
$tagger = new LI_Tag_Editor();
|
403 |
+
|
404 |
+
// Add in the custom form fields
|
405 |
+
$q = $wpdb->prepare("SELECT tag_form_selectors FROM $wpdb->li_tags WHERE tag_form_selectors != ''", "");
|
406 |
+
$tags = $wpdb->get_results($q);
|
407 |
+
|
408 |
+
// Get all the form selectors synced with a list
|
409 |
+
if ( count($tags) )
|
410 |
+
{
|
411 |
+
foreach ( $tags as $tag )
|
412 |
+
{
|
413 |
+
foreach ( explode(',', $tag->tag_form_selectors) as $selector )
|
414 |
+
{
|
415 |
+
if ( ! in_array($selector, $tagger->selectors) && $selector )
|
416 |
+
array_push($tagger->selectors, $selector);
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
$fuzzy_selectors = array();
|
422 |
+
foreach ( $tagger->selectors as $key => $selector )
|
423 |
+
{
|
424 |
+
if ( strstr($selector, $_POST['search_term']) )
|
425 |
+
{
|
426 |
+
if ( ! in_array($selector, $fuzzy_selectors) && $selector )
|
427 |
+
array_push($fuzzy_selectors, $selector);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
|
431 |
+
array_unshift($tagger->selectors, 'any form');
|
432 |
+
|
433 |
+
if ( count($fuzzy_selectors) )
|
434 |
+
echo json_encode($fuzzy_selectors);
|
435 |
+
else
|
436 |
+
echo json_encode($tagger->selectors);
|
437 |
+
|
438 |
+
die();
|
439 |
+
}
|
440 |
+
|
441 |
+
add_action('wp_ajax_leadin_get_form_selectors', 'leadin_get_form_selectors'); // Call when user logged in
|
442 |
+
add_action('wp_ajax_nopriv_leadin_get_form_selectors', 'leadin_get_form_selectors'); // Call when user is not logged in
|
443 |
+
|
444 |
?>
|
inc/leadin-functions.php
CHANGED
@@ -281,7 +281,7 @@ function leadin_recover_contact_data ()
|
|
281 |
{
|
282 |
global $wpdb;
|
283 |
|
284 |
-
$q = $wpdb->prepare("SELECT * FROM li_submissions AS s LEFT JOIN li_leads AS l ON s.lead_hashkey = l.hashkey WHERE l.hashkey IS NULL AND s.form_fields LIKE '%%%s%%' AND s.form_fields LIKE '%%%s%%' AND form_deleted = 0
|
285 |
$submissions = $wpdb->get_results($q);
|
286 |
|
287 |
if ( count($submissions) )
|
@@ -297,24 +297,22 @@ function leadin_recover_contact_data ()
|
|
297 |
if ( strstr($object['value'], '@') && strstr($object['value'], '@') && strlen($object['value']) <= 254 )
|
298 |
{
|
299 |
// check to see if the contact exists and if it does, skip the data recovery
|
300 |
-
$q = $wpdb->prepare("SELECT lead_email FROM li_leads WHERE lead_email = %s AND lead_deleted = 0
|
301 |
$exists = $wpdb->get_var($q);
|
302 |
|
303 |
if ( $exists )
|
304 |
continue;
|
305 |
|
306 |
// get the original data
|
307 |
-
$q = $wpdb->prepare("SELECT pageview_date, pageview_source FROM li_pageviews WHERE lead_hashkey = %s AND pageview_deleted = 0
|
308 |
$first_pageview = $wpdb->get_row($q);
|
309 |
|
310 |
// recreate the contact
|
311 |
-
$q = $wpdb->prepare("INSERT INTO li_leads ( lead_date, hashkey, lead_source, lead_email
|
312 |
( $first_pageview->pageview_date ? $first_pageview->pageview_date : $submission->form_date),
|
313 |
$submission->lead_hashkey,
|
314 |
( $first_pageview->pageview_source ? $first_pageview->pageview_source : ''),
|
315 |
-
$object['value']
|
316 |
-
$submission->form_type,
|
317 |
-
$wpdb->blogid
|
318 |
);
|
319 |
|
320 |
$wpdb->query($q);
|
@@ -335,16 +333,14 @@ function leadin_delete_flag_fix ()
|
|
335 |
{
|
336 |
global $wpdb;
|
337 |
|
338 |
-
$q = $wpdb->prepare("SELECT lead_email, COUNT(hashkey) c FROM li_leads WHERE lead_email != '' AND lead_deleted = 0
|
339 |
$duplicates = $wpdb->get_results($q);
|
340 |
|
341 |
if ( count($duplicates) )
|
342 |
{
|
343 |
foreach ( $duplicates as $duplicate )
|
344 |
{
|
345 |
-
$
|
346 |
-
|
347 |
-
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys, lead_status FROM li_leads WHERE lead_email = %s AND lead_deleted = 0 " . $wpdb->multisite_query . " ORDER BY lead_date DESC", $duplicate->lead_email);
|
348 |
$existing_contacts = $wpdb->get_results($q);
|
349 |
|
350 |
$newest = $existing_contacts[0];
|
@@ -369,14 +365,6 @@ function leadin_delete_flag_fix ()
|
|
369 |
// Add a comma delimiter
|
370 |
if ( $i != count($existing_contacts)-1 )
|
371 |
$existing_contact_hashkeys .= ",";
|
372 |
-
|
373 |
-
// Check on each existing lead if the lead_status is comment. If it is, save the status to override the new lead's status
|
374 |
-
if ( $existing_contacts[$i]->lead_status == 'comment' && $existing_contact_status == 'lead' )
|
375 |
-
$existing_contact_status = 'comment';
|
376 |
-
|
377 |
-
// Check on each existing lead if the lead_status is subscribe. If it is, save the status to override the new lead's status
|
378 |
-
if ( $existing_contacts[$i]->lead_status == 'subscribe' && ($existing_contact_status == 'lead' || $existing_contact_status == 'comment') )
|
379 |
-
$existing_contact_status = 'subscribe';
|
380 |
}
|
381 |
}
|
382 |
|
@@ -389,19 +377,19 @@ function leadin_delete_flag_fix ()
|
|
389 |
if ( $existing_contact_hashkey_string )
|
390 |
{
|
391 |
// Set the merged hashkeys with the fixed merged hashkey values
|
392 |
-
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = %s
|
393 |
$wpdb->query($q);
|
394 |
|
395 |
// "Delete" all the old contacts
|
396 |
-
$q = $wpdb->prepare("UPDATE li_leads SET merged_hashkeys = '', lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkey_string )
|
397 |
$wpdb->query($q);
|
398 |
|
399 |
// Set all the pageviews and submissions to the new hashkey just in case
|
400 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string )
|
401 |
$wpdb->query($q);
|
402 |
|
403 |
// Update all the previous submissions to the new hashkey just in case
|
404 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string )
|
405 |
$wpdb->query($q);
|
406 |
}
|
407 |
}
|
@@ -410,6 +398,189 @@ function leadin_delete_flag_fix ()
|
|
410 |
leadin_update_option('leadin_options', 'delete_flags_fixed', 1);
|
411 |
}
|
412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
413 |
/**
|
414 |
* Sorts the powerups into a predefined order in leadin.php line 416
|
415 |
*
|
@@ -445,6 +616,17 @@ function leadin_encode_quotes ( $string )
|
|
445 |
return $string;
|
446 |
}
|
447 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
/**
|
449 |
* Strip url get parameters off a url and return the base url
|
450 |
*
|
@@ -453,18 +635,12 @@ function leadin_encode_quotes ( $string )
|
|
453 |
*/
|
454 |
function leadin_strip_params_from_url ( $url )
|
455 |
{
|
456 |
-
/*$url_parts = parse_url($url);
|
457 |
-
$base_url .= ( isset($url_parts['host']) ? : rtrim($url_parts['host'] . '/' . ltrim($url_parts['path'], '/'), '/'));
|
458 |
-
$base_url = urldecode($base_url);*/
|
459 |
-
|
460 |
$url_parts = parse_url($url);
|
461 |
$base_url = ( isset($url_parts['host']) ? 'http://' . rtrim($url_parts['host'], '/') : '' );
|
462 |
$base_url .= ( isset($url_parts['path']) ? '/' . ltrim($url_parts['path'], '/') : '' );
|
463 |
-
|
464 |
-
ltrim($url_parts['path'], '/');
|
465 |
$base_url = urldecode(ltrim($base_url, '/'));
|
466 |
|
467 |
-
|
468 |
return $base_url;
|
469 |
}
|
470 |
|
@@ -499,25 +675,127 @@ function leadin_is_weekend ( $date )
|
|
499 |
}
|
500 |
|
501 |
/**
|
502 |
-
*
|
503 |
*
|
504 |
-
* @
|
|
|
|
|
|
|
505 |
*/
|
506 |
-
function
|
507 |
{
|
508 |
global $wpdb;
|
509 |
|
510 |
-
$q = $wpdb->prepare("SELECT
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
|
515 |
-
$
|
516 |
-
|
517 |
-
|
|
|
|
|
518 |
|
519 |
-
return
|
520 |
}
|
521 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
522 |
|
523 |
?>
|
281 |
{
|
282 |
global $wpdb;
|
283 |
|
284 |
+
$q = $wpdb->prepare("SELECT * FROM $wpdb->li_submissions AS s LEFT JOIN $wpdb->li_leads AS l ON s.lead_hashkey = l.hashkey WHERE l.hashkey IS NULL AND s.form_fields LIKE '%%%s%%' AND s.form_fields LIKE '%%%s%%' AND form_deleted = 0", '@', '.');
|
285 |
$submissions = $wpdb->get_results($q);
|
286 |
|
287 |
if ( count($submissions) )
|
297 |
if ( strstr($object['value'], '@') && strstr($object['value'], '@') && strlen($object['value']) <= 254 )
|
298 |
{
|
299 |
// check to see if the contact exists and if it does, skip the data recovery
|
300 |
+
$q = $wpdb->prepare("SELECT lead_email FROM $wpdb->li_leads WHERE lead_email = %s AND lead_deleted = 0", $object['value']); // @HERE
|
301 |
$exists = $wpdb->get_var($q);
|
302 |
|
303 |
if ( $exists )
|
304 |
continue;
|
305 |
|
306 |
// get the original data
|
307 |
+
$q = $wpdb->prepare("SELECT pageview_date, pageview_source FROM $wpdb->li_pageviews WHERE lead_hashkey = %s AND pageview_deleted = 0 ORDER BY pageview_date ASC LIMIT 1", $submission->lead_hashkey);
|
308 |
$first_pageview = $wpdb->get_row($q);
|
309 |
|
310 |
// recreate the contact
|
311 |
+
$q = $wpdb->prepare("INSERT INTO $wpdb->li_leads ( lead_date, hashkey, lead_source, lead_email ) VALUES ( %s, %s, %s, %s )",
|
312 |
( $first_pageview->pageview_date ? $first_pageview->pageview_date : $submission->form_date),
|
313 |
$submission->lead_hashkey,
|
314 |
( $first_pageview->pageview_source ? $first_pageview->pageview_source : ''),
|
315 |
+
$object['value']
|
|
|
|
|
316 |
);
|
317 |
|
318 |
$wpdb->query($q);
|
333 |
{
|
334 |
global $wpdb;
|
335 |
|
336 |
+
$q = $wpdb->prepare("SELECT lead_email, COUNT(hashkey) c FROM $wpdb->li_leads WHERE lead_email != '' AND lead_deleted = 0 GROUP BY lead_email HAVING c > 1", '');
|
337 |
$duplicates = $wpdb->get_results($q);
|
338 |
|
339 |
if ( count($duplicates) )
|
340 |
{
|
341 |
foreach ( $duplicates as $duplicate )
|
342 |
{
|
343 |
+
$q = $wpdb->prepare("SELECT lead_email, hashkey, merged_hashkeys FROM $wpdb->li_leads WHERE lead_email = %s AND lead_deleted = 0 ORDER BY lead_date DESC", $duplicate->lead_email);
|
|
|
|
|
344 |
$existing_contacts = $wpdb->get_results($q);
|
345 |
|
346 |
$newest = $existing_contacts[0];
|
365 |
// Add a comma delimiter
|
366 |
if ( $i != count($existing_contacts)-1 )
|
367 |
$existing_contact_hashkeys .= ",";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
369 |
}
|
370 |
|
377 |
if ( $existing_contact_hashkey_string )
|
378 |
{
|
379 |
// Set the merged hashkeys with the fixed merged hashkey values
|
380 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_leads SET merged_hashkeys = %s WHERE hashkey = %s", $existing_contact_hashkey_string, $newest->hashkey);
|
381 |
$wpdb->query($q);
|
382 |
|
383 |
// "Delete" all the old contacts
|
384 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_leads SET merged_hashkeys = '', lead_deleted = 1 WHERE hashkey IN ( $existing_contact_hashkey_string )", '');
|
385 |
$wpdb->query($q);
|
386 |
|
387 |
// Set all the pageviews and submissions to the new hashkey just in case
|
388 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_pageviews SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string )", $newest->hashkey);
|
389 |
$wpdb->query($q);
|
390 |
|
391 |
// Update all the previous submissions to the new hashkey just in case
|
392 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_submissions SET lead_hashkey = %s WHERE lead_hashkey IN ( $existing_contact_hashkey_string )", $newest->hashkey);
|
393 |
$wpdb->query($q);
|
394 |
}
|
395 |
}
|
398 |
leadin_update_option('leadin_options', 'delete_flags_fixed', 1);
|
399 |
}
|
400 |
|
401 |
+
/**
|
402 |
+
* Sets the default lists for V2.0.0 and converts all existing statuses to tag format
|
403 |
+
*
|
404 |
+
*/
|
405 |
+
function leadin_convert_statuses_to_tags ( )
|
406 |
+
{
|
407 |
+
global $wpdb;
|
408 |
+
|
409 |
+
$blog_ids = array();
|
410 |
+
if ( is_multisite() )
|
411 |
+
{
|
412 |
+
$blog_id = (Object)Null;
|
413 |
+
$blog_id->blog_id = $wpdb->blogid;
|
414 |
+
array_push($blog_ids, $blog_id);
|
415 |
+
}
|
416 |
+
else
|
417 |
+
{
|
418 |
+
$blog_id = (Object)Null;
|
419 |
+
$blog_id->blog_id = 0;
|
420 |
+
array_push($blog_ids, $blog_id);
|
421 |
+
}
|
422 |
+
|
423 |
+
foreach ( $blog_ids as $blog )
|
424 |
+
{
|
425 |
+
if ( is_multisite() )
|
426 |
+
{
|
427 |
+
$q = $wpdb->prepare("SELECT COUNT(TABLE_NAME) FROM information_schema.tables WHERE TABLE_NAME = $wpdb->li_leads LIMIT 1");
|
428 |
+
$leadin_tables_exist = $wpdb->get_var($q);
|
429 |
+
|
430 |
+
if ( ! $leadin_tables_exist )
|
431 |
+
{
|
432 |
+
leadin_db_install();
|
433 |
+
}
|
434 |
+
}
|
435 |
+
|
436 |
+
// Get all the contacts from li_leads
|
437 |
+
$q = $wpdb->prepare("SELECT lead_id, lead_status, hashkey FROM li_leads WHERE lead_status != 'contact' AND lead_email != '' AND lead_deleted = 0 AND blog_id = %d", $blog->blog_id);
|
438 |
+
$contacts = $wpdb->get_results($q);
|
439 |
+
|
440 |
+
// Check if there are any subscribers in the li_leads table and build the list if any exist
|
441 |
+
$subscriber_exists = FALSE;
|
442 |
+
foreach ( $contacts as $contact )
|
443 |
+
{
|
444 |
+
if ( $contact->lead_status == 'subscribe' )
|
445 |
+
{
|
446 |
+
$subscriber_exists = TRUE;
|
447 |
+
break;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
// Check if LeadIn Subscribe is activated
|
452 |
+
if ( ! $subscriber_exists )
|
453 |
+
{
|
454 |
+
if ( WPLeadIn::is_power_up_active('subscribe_widget') )
|
455 |
+
$subscriber_exists = TRUE;
|
456 |
+
}
|
457 |
+
|
458 |
+
$existing_synced_lists = array();
|
459 |
+
|
460 |
+
// Check to see if the mailchimp power-up is active and add the existing synced list for serialization
|
461 |
+
$mailchimp_options = get_option('leadin_mls_options');
|
462 |
+
if ( $mailchimp_options['li_mls_subscribers_to_list'] )
|
463 |
+
{
|
464 |
+
$leadin_mailchimp = new WPMailChimpListSync(TRUE);
|
465 |
+
$leadin_mailchimp->admin_init();
|
466 |
+
$lists = $leadin_mailchimp->admin->li_get_lists();
|
467 |
+
|
468 |
+
if ( count($lists) )
|
469 |
+
{
|
470 |
+
foreach ( $lists as $list )
|
471 |
+
{
|
472 |
+
if ( $list->id == $mailchimp_options['li_mls_subscribers_to_list'] )
|
473 |
+
{
|
474 |
+
array_push($existing_synced_lists,
|
475 |
+
array(
|
476 |
+
'esp' => 'mailchimp',
|
477 |
+
'list_id' => $list->id,
|
478 |
+
'list_name' => $list->name
|
479 |
+
)
|
480 |
+
);
|
481 |
+
|
482 |
+
break;
|
483 |
+
}
|
484 |
+
}
|
485 |
+
}
|
486 |
+
}
|
487 |
+
|
488 |
+
// Check to see if the constant contact power-up is active and add the existing synced list for serialization
|
489 |
+
$constant_contact_options = get_option('leadin_cc_options');
|
490 |
+
if ( $constant_contact_options['li_cc_subscribers_to_list'] )
|
491 |
+
{
|
492 |
+
$leadin_constant_contact = new WPConstantContactListSync(TRUE);
|
493 |
+
$leadin_constant_contact->admin_init();
|
494 |
+
$lists = $leadin_constant_contact->admin->li_get_lists();
|
495 |
+
|
496 |
+
if ( count($lists) )
|
497 |
+
{
|
498 |
+
foreach ( $lists as $list )
|
499 |
+
{
|
500 |
+
if ( $list->id == str_replace('@', '%40', $constant_contact_options['li_cc_subscribers_to_list']) )
|
501 |
+
{
|
502 |
+
array_push($existing_synced_lists,
|
503 |
+
array(
|
504 |
+
'esp' => 'constant_contact',
|
505 |
+
'list_id' => end(explode('/', $list->id)), // Changed the list_id for constant contact to just store the list integer in 2.0
|
506 |
+
'list_name' => $list->name
|
507 |
+
)
|
508 |
+
);
|
509 |
+
|
510 |
+
break;
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
}
|
515 |
+
|
516 |
+
unset($leadin_constant_contact);
|
517 |
+
unset($leadin_mailchimp);
|
518 |
+
|
519 |
+
// Create all the default comment lists (Commenters, Leads, Contacted, Customers). Figures out if it should add the subscriber list and puts the lists in the correct order
|
520 |
+
$q = "
|
521 |
+
INSERT INTO $wpdb->li_tags
|
522 |
+
( tag_text, tag_slug, tag_form_selectors, tag_synced_lists, tag_order )
|
523 |
+
VALUES " .
|
524 |
+
( $subscriber_exists ? "('Subscribers', 'subscribers', '.vex-dialog-form', " . ( count($existing_synced_lists) ? $wpdb->prepare('%s', serialize($existing_synced_lists)) : "''" ) . ", 1 ), " : "" ) .
|
525 |
+
" ('Commenters', 'commenters', '#commentform', '', " . ( $subscriber_exists ? "2" : "1" ) . "),
|
526 |
+
('Leads', 'leads', '', '', " . ( $subscriber_exists ? "3" : "2" ) . "),
|
527 |
+
('Contacted', 'contacted', '', '', " . ( $subscriber_exists ? "4" : "3" ) . "),
|
528 |
+
('Customers', 'customers', '', '', " . ( $subscriber_exists ? "5" : "4" ) . ")";
|
529 |
+
|
530 |
+
$wpdb->query($q);
|
531 |
+
|
532 |
+
$tags = $wpdb->get_results("SELECT tag_id, tag_slug FROM $wpdb->li_tags WHERE tag_slug IN ( 'commenters', 'leads', 'contacted', 'customers', 'subscribers' )");
|
533 |
+
foreach ( $tags as $tag )
|
534 |
+
${$tag->tag_slug . '_tag_id'} = $tag->tag_id;
|
535 |
+
|
536 |
+
$insert_values = '';
|
537 |
+
foreach ( $contacts as $contact )
|
538 |
+
{
|
539 |
+
switch ( $contact->lead_status )
|
540 |
+
{
|
541 |
+
case 'comment' :
|
542 |
+
$tag_id = $commenters_tag_id;
|
543 |
+
break;
|
544 |
+
|
545 |
+
case 'lead' :
|
546 |
+
$tag_id = $leads_tag_id;
|
547 |
+
break;
|
548 |
+
|
549 |
+
case 'contacted' :
|
550 |
+
$tag_id = $contacted_tag_id;
|
551 |
+
break;
|
552 |
+
|
553 |
+
case 'customer' :
|
554 |
+
$tag_id = $customers_tag_id;
|
555 |
+
break;
|
556 |
+
|
557 |
+
case 'subscribe' :
|
558 |
+
$tag_id = $subscribers_tag_id;
|
559 |
+
break;
|
560 |
+
}
|
561 |
+
|
562 |
+
$insert_values .= '(' . $tag_id . ', "' . $contact->hashkey . '" ),';
|
563 |
+
}
|
564 |
+
|
565 |
+
$q = "INSERT INTO $wpdb->li_tag_relationships ( tag_id, contact_hashkey ) VALUES " . rtrim($insert_values, ',');
|
566 |
+
$wpdb->query($q);
|
567 |
+
|
568 |
+
if ( is_multisite() )
|
569 |
+
{
|
570 |
+
$q = $wpdb->prepare("INSERT $wpdb->li_leads SELECT * FROM li_leads WHERE li_leads.blog_id = %d", $blog->blog_id);
|
571 |
+
$wpdb->query($q);
|
572 |
+
|
573 |
+
$q = $wpdb->prepare("INSERT $wpdb->li_pageviews SELECT * FROM li_pageviews WHERE li_pageviews.blog_id = %d", $blog->blog_id);
|
574 |
+
$wpdb->query($q);
|
575 |
+
|
576 |
+
$q = $wpdb->prepare("INSERT $wpdb->li_submissions SELECT * FROM li_submissions WHERE li_submissions.blog_id = %d", $blog->blog_id);
|
577 |
+
$wpdb->query($q);
|
578 |
+
}
|
579 |
+
}
|
580 |
+
|
581 |
+
leadin_update_option('leadin_options', 'converted_to_tags', '1');
|
582 |
+
}
|
583 |
+
|
584 |
/**
|
585 |
* Sorts the powerups into a predefined order in leadin.php line 416
|
586 |
*
|
616 |
return $string;
|
617 |
}
|
618 |
|
619 |
+
/**
|
620 |
+
* Converts all carriage returns into HTML line breaks
|
621 |
+
*
|
622 |
+
* @param string
|
623 |
+
* @return string
|
624 |
+
*/
|
625 |
+
function leadin_html_line_breaks ( $string )
|
626 |
+
{
|
627 |
+
return stripslashes(str_replace('\n', '<br>', $string));
|
628 |
+
}
|
629 |
+
|
630 |
/**
|
631 |
* Strip url get parameters off a url and return the base url
|
632 |
*
|
635 |
*/
|
636 |
function leadin_strip_params_from_url ( $url )
|
637 |
{
|
|
|
|
|
|
|
|
|
638 |
$url_parts = parse_url($url);
|
639 |
$base_url = ( isset($url_parts['host']) ? 'http://' . rtrim($url_parts['host'], '/') : '' );
|
640 |
$base_url .= ( isset($url_parts['path']) ? '/' . ltrim($url_parts['path'], '/') : '' );
|
641 |
+
ltrim($url_parts['path'], '/');
|
|
|
642 |
$base_url = urldecode(ltrim($base_url, '/'));
|
643 |
|
|
|
644 |
return $base_url;
|
645 |
}
|
646 |
|
675 |
}
|
676 |
|
677 |
/**
|
678 |
+
* Tie a tag to a contact in li_tag_relationships
|
679 |
*
|
680 |
+
* @param int
|
681 |
+
* @param int
|
682 |
+
* @param int
|
683 |
+
* @return bool successful insert
|
684 |
*/
|
685 |
+
function leadin_apply_tag_to_contact ( $tag_id, $contact_hashkey )
|
686 |
{
|
687 |
global $wpdb;
|
688 |
|
689 |
+
$q = $wpdb->prepare("SELECT tag_id FROM $wpdb->li_tag_relationships WHERE tag_id = %d AND contact_hashkey = %s", $tag_id, $contact_hashkey);
|
690 |
+
$exists = $wpdb->get_var($q);
|
691 |
+
|
692 |
+
if ( ! $exists )
|
693 |
+
{
|
694 |
+
$q = $wpdb->prepare("INSERT INTO $wpdb->li_tag_relationships ( tag_id, contact_hashkey ) VALUES ( %d, %s )", $tag_id, $contact_hashkey);
|
695 |
+
return $wpdb->query($q);
|
696 |
+
}
|
697 |
+
}
|
698 |
+
|
699 |
+
|
700 |
+
/**
|
701 |
+
* Check multidimensional arrray for an existing value
|
702 |
+
*
|
703 |
+
* @param string
|
704 |
+
* @param array
|
705 |
+
* @return bool
|
706 |
+
*/
|
707 |
+
function leadin_in_array_deep ( $needle, $haystack )
|
708 |
+
{
|
709 |
+
if ( in_array($needle, $haystack) )
|
710 |
+
return TRUE;
|
711 |
|
712 |
+
foreach ( $haystack as $element )
|
713 |
+
{
|
714 |
+
if ( is_array($element) && leadin_in_array_deep($needle, $element) )
|
715 |
+
return TRUE;
|
716 |
+
}
|
717 |
|
718 |
+
return FALSE;
|
719 |
}
|
720 |
|
721 |
+
/**
|
722 |
+
* Check multidimensional arrray for an existing value
|
723 |
+
*
|
724 |
+
* @param string needle
|
725 |
+
* @param array haystack
|
726 |
+
* @return string key if found, null if not
|
727 |
+
*/
|
728 |
+
function leadin_array_search_deep ( $needle, $array, $index )
|
729 |
+
{
|
730 |
+
foreach ( $array as $key => $val )
|
731 |
+
{
|
732 |
+
if ( $val[$index] === $needle )
|
733 |
+
return $key;
|
734 |
+
}
|
735 |
+
|
736 |
+
return NULL;
|
737 |
+
}
|
738 |
+
|
739 |
+
/**
|
740 |
+
* Creates a list of filtered contacts into a comma separated string of hashkeys
|
741 |
+
*
|
742 |
+
* @param object
|
743 |
+
* @return string sorted array
|
744 |
+
*/
|
745 |
+
function leadin_merge_filtered_contacts ( $filtered_contacts, $all_contacts = array() )
|
746 |
+
{
|
747 |
+
if ( ! count($all_contacts) )
|
748 |
+
return $filtered_contacts;
|
749 |
+
|
750 |
+
if ( count($filtered_contacts) )
|
751 |
+
{
|
752 |
+
foreach ( $all_contacts as $key => $contact )
|
753 |
+
{
|
754 |
+
if ( ! leadin_in_array_deep($contact['lead_hashkey'], $filtered_contacts) )
|
755 |
+
unset($all_contacts[$key]);
|
756 |
+
}
|
757 |
+
|
758 |
+
return $all_contacts;
|
759 |
+
}
|
760 |
+
else
|
761 |
+
return FALSE;
|
762 |
+
}
|
763 |
+
|
764 |
+
/**
|
765 |
+
* Creates a list of filtered contacts into a comma separated string of hashkeys
|
766 |
+
*
|
767 |
+
* @param object
|
768 |
+
* @return string sorted array
|
769 |
+
*/
|
770 |
+
function leadin_explode_filtered_contacts ( $contacts )
|
771 |
+
{
|
772 |
+
if ( count($contacts) )
|
773 |
+
{
|
774 |
+
$contacts = array_values($contacts);
|
775 |
+
|
776 |
+
$hashkeys = '';
|
777 |
+
for ( $i = 0; $i < count($contacts); $i++ )
|
778 |
+
$hashkeys .= "'" . $contacts[$i]['lead_hashkey'] . "'" . ( $i != (count($contacts) - 1) ? ', ' : '' );
|
779 |
+
|
780 |
+
return $hashkeys;
|
781 |
+
}
|
782 |
+
else
|
783 |
+
return FALSE;
|
784 |
+
}
|
785 |
+
|
786 |
+
/**
|
787 |
+
* Sets the wpdb tables to the current blog
|
788 |
+
*
|
789 |
+
*/
|
790 |
+
function leadin_set_wpdb_tables ()
|
791 |
+
{
|
792 |
+
global $wpdb;
|
793 |
+
|
794 |
+
$wpdb->li_submissions = ( is_multisite() ? $wpdb->prefix . 'li_submissions' : 'li_submissions' );
|
795 |
+
$wpdb->li_pageviews = ( is_multisite() ? $wpdb->prefix . 'li_pageviews' : 'li_pageviews' );
|
796 |
+
$wpdb->li_leads = ( is_multisite() ? $wpdb->prefix . 'li_leads' : 'li_leads' );
|
797 |
+
$wpdb->li_tags = ( is_multisite() ? $wpdb->prefix . 'li_tags' : 'li_tags' );
|
798 |
+
$wpdb->li_tag_relationships = ( is_multisite() ? $wpdb->prefix . 'li_tag_relationships' : 'li_tag_relationships' );
|
799 |
+
}
|
800 |
|
801 |
?>
|
leadin.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: LeadIn
|
4 |
Plugin URI: http://leadin.com
|
5 |
Description: LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
6 |
-
Version:
|
7 |
Author: Andy Cook, Nelson Joyce
|
8 |
Author URI: http://leadin.com
|
9 |
License: GPL2
|
@@ -23,10 +23,10 @@ if ( !defined('LEADIN_PLUGIN_SLUG') )
|
|
23 |
define('LEADIN_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
24 |
|
25 |
if ( !defined('LEADIN_DB_VERSION') )
|
26 |
-
define('LEADIN_DB_VERSION', '
|
27 |
|
28 |
if ( !defined('LEADIN_PLUGIN_VERSION') )
|
29 |
-
define('LEADIN_PLUGIN_VERSION', '
|
30 |
|
31 |
if ( !defined('MIXPANEL_PROJECT_TOKEN') )
|
32 |
define('MIXPANEL_PROJECT_TOKEN', 'a9615503ec58a6bce2c646a58390eac1');
|
@@ -35,514 +35,349 @@ if ( !defined('MIXPANEL_PROJECT_TOKEN') )
|
|
35 |
// Include Needed Files
|
36 |
//=============================================
|
37 |
|
38 |
-
require_once(LEADIN_PLUGIN_DIR . '/admin/leadin-admin.php');
|
39 |
-
require_once(LEADIN_PLUGIN_DIR . '/inc/class-emailer.php');
|
40 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-ajax-functions.php');
|
41 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-functions.php');
|
|
|
42 |
require_once(LEADIN_PLUGIN_DIR . '/inc/class-leadin-updater.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/subscribe-widget.php');
|
44 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/contacts.php');
|
45 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/mailchimp-list-sync.php');
|
46 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/constant-contact-list-sync.php');
|
47 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/beta-program.php');
|
48 |
-
require_once(LEADIN_PLUGIN_DIR . '/lib/mixpanel/LI_Mixpanel.php');
|
49 |
|
50 |
//=============================================
|
51 |
-
//
|
52 |
//=============================================
|
53 |
-
class WPLeadIn {
|
54 |
-
|
55 |
-
var $power_ups;
|
56 |
-
var $options;
|
57 |
-
|
58 |
-
/**
|
59 |
-
* Class constructor
|
60 |
-
*/
|
61 |
-
function __construct ()
|
62 |
-
{
|
63 |
-
//=============================================
|
64 |
-
// Hooks & Filters
|
65 |
-
//=============================================
|
66 |
-
|
67 |
-
// Activate + install LeadIn
|
68 |
-
register_activation_hook( __FILE__, array(&$this, 'add_leadin_defaults'));
|
69 |
|
70 |
-
// Deactivate LeadIn
|
71 |
-
register_deactivation_hook( __FILE__, array(&$this, 'deactivate_leadin'));
|
72 |
|
73 |
-
$this->power_ups = $this->get_available_power_ups();
|
74 |
-
$this->options = get_option('leadin_options');
|
75 |
|
76 |
-
add_action('plugins_loaded', array($this, 'leadin_update_check'));
|
77 |
-
add_filter('init', array($this, 'add_leadin_frontend_scripts'));
|
78 |
|
79 |
-
|
80 |
-
add_action( 'admin_bar_menu', array($this, 'add_leadin_link_to_admin_bar'), 999 );
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
global $wpdb;
|
88 |
-
$wpdb->multisite_query = ( is_multisite() ? $wpdb->prepare(" AND blog_id = %d ", $wpdb->blogid) : "" );
|
89 |
}
|
|
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
*/
|
94 |
-
function add_leadin_defaults ()
|
95 |
-
{
|
96 |
-
$options = $this->options;
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
$opt = array(
|
101 |
-
'li_installed' => 1,
|
102 |
-
'li_db_version' => LEADIN_DB_VERSION,
|
103 |
-
'li_email' => get_bloginfo('admin_email'),
|
104 |
-
'onboarding_complete' => 0,
|
105 |
-
'ignore_settings_popup' => 0,
|
106 |
-
'data_recovered' => 1,
|
107 |
-
'delete_flags_fixed' => 1,
|
108 |
-
'beta_tester' => 0
|
109 |
-
);
|
110 |
-
|
111 |
-
update_option('leadin_options', $opt);
|
112 |
-
$this->leadin_db_install();
|
113 |
-
}
|
114 |
|
115 |
-
|
|
|
116 |
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
{
|
119 |
-
$
|
120 |
-
|
121 |
-
|
122 |
-
);
|
123 |
-
|
124 |
-
update_option('leadin_active_power_ups', serialize($auto_activate));
|
125 |
}
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
128 |
}
|
|
|
|
|
|
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
}
|
137 |
|
138 |
-
|
139 |
-
// Database update
|
140 |
-
//=============================================
|
141 |
|
142 |
-
|
143 |
-
* Creates or updates the LeadIn tables
|
144 |
-
*/
|
145 |
-
function leadin_db_install ()
|
146 |
{
|
147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
-
$
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
PRIMARY KEY (`lead_id`),
|
162 |
-
KEY `hashkey` (`hashkey`)
|
163 |
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
|
164 |
-
|
165 |
-
CREATE TABLE `li_pageviews` (
|
166 |
-
`pageview_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
167 |
-
`pageview_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
168 |
-
`lead_hashkey` varchar(16) NOT NULL,
|
169 |
-
`pageview_title` varchar(255) NOT NULL,
|
170 |
-
`pageview_url` text NOT NULL,
|
171 |
-
`pageview_source` text NOT NULL,
|
172 |
-
`pageview_session_start` int(1) NOT NULL,
|
173 |
-
`pageview_deleted` int(1) NOT NULL DEFAULT '0',
|
174 |
-
`blog_id` int(11) unsigned NOT NULL,
|
175 |
-
PRIMARY KEY (`pageview_id`),
|
176 |
-
KEY `lead_hashkey` (`lead_hashkey`)
|
177 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
178 |
-
|
179 |
-
CREATE TABLE `li_submissions` (
|
180 |
-
`form_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
181 |
-
`form_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
182 |
-
`lead_hashkey` varchar(16) NOT NULL,
|
183 |
-
`form_page_title` varchar(255) NOT NULL,
|
184 |
-
`form_page_url` text NOT NULL,
|
185 |
-
`form_fields` text NOT NULL,
|
186 |
-
`form_type` set('contact','comment','subscribe') NOT NULL DEFAULT 'contact',
|
187 |
-
`form_selector_id` mediumtext NOT NULL,
|
188 |
-
`form_selector_classes` mediumtext NOT NULL,
|
189 |
-
`form_hashkey` varchar(16) NOT NULL,
|
190 |
-
`form_deleted` int(1) NOT NULL DEFAULT '0',
|
191 |
-
`blog_id` int(11) unsigned NOT NULL,
|
192 |
-
PRIMARY KEY (`form_id`),
|
193 |
-
KEY `lead_hashkey` (`lead_hashkey`)
|
194 |
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;";
|
195 |
-
|
196 |
-
dbDelta($sql);
|
197 |
-
|
198 |
-
leadin_update_option('leadin_options', 'li_db_version', LEADIN_DB_VERSION);
|
199 |
-
}
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Checks the stored database version against the current data version + updates if needed
|
203 |
-
*/
|
204 |
-
function leadin_update_check ()
|
205 |
-
{
|
206 |
-
global $wpdb;
|
207 |
-
$options = $this->options;
|
208 |
-
|
209 |
-
// If the plugin version matches the latest version escape the update function
|
210 |
-
if ( isset ($options['leadin_version']) && $options['leadin_version'] == LEADIN_PLUGIN_VERSION )
|
211 |
-
return FALSE;
|
212 |
-
|
213 |
-
// 0.5.1 upgrade - Create active power-ups option if it doesn't exist
|
214 |
-
$leadin_active_power_ups = get_option('leadin_active_power_ups');
|
215 |
-
|
216 |
-
if ( !$leadin_active_power_ups )
|
217 |
-
{
|
218 |
-
$auto_activate = array(
|
219 |
-
'contacts',
|
220 |
-
'beta_program'
|
221 |
-
);
|
222 |
-
|
223 |
-
update_option('leadin_active_power_ups', serialize($auto_activate));
|
224 |
-
}
|
225 |
-
else
|
226 |
-
{
|
227 |
-
// 0.9.2 upgrade - set beta program power-up to auto-activate
|
228 |
-
$activated_power_ups = unserialize($leadin_active_power_ups);
|
229 |
-
|
230 |
-
// 0.9.3 bug fix for dupliate beta_program values being stored in the active power-ups array
|
231 |
-
if ( !in_array('beta_program', $activated_power_ups) )
|
232 |
-
{
|
233 |
-
$activated_power_ups[] = 'beta_program';
|
234 |
-
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
235 |
-
}
|
236 |
-
else
|
237 |
-
{
|
238 |
-
$tmp = array_count_values($activated_power_ups);
|
239 |
-
$count = $tmp['beta_program'];
|
240 |
-
|
241 |
-
if ( $count > 1 )
|
242 |
-
{
|
243 |
-
$activated_power_ups = array_unique($activated_power_ups);
|
244 |
-
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
245 |
-
}
|
246 |
-
}
|
247 |
-
|
248 |
-
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
249 |
-
}
|
250 |
-
|
251 |
-
// 0.7.2 bug fix - data recovery algorithm for deleted contacts
|
252 |
-
if ( ! isset($options['data_recovered']) )
|
253 |
-
{
|
254 |
-
leadin_recover_contact_data();
|
255 |
-
}
|
256 |
-
|
257 |
-
// Set the database version if it doesn't exist
|
258 |
-
if ( isset($options['li_db_version']) )
|
259 |
-
{
|
260 |
-
if ( $options['li_db_version'] != LEADIN_DB_VERSION )
|
261 |
-
{
|
262 |
-
$this->leadin_db_install();
|
263 |
-
|
264 |
-
// 1.1.0 upgrade - After the DB installation converts the set structure from contact to lead, update all the blank form_type = leads
|
265 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET form_type = 'contact' WHERE form_type = 'lead' OR form_type = ''" . $wpdb->multisite_query, "");
|
266 |
-
$wpdb->query($q);
|
267 |
-
}
|
268 |
-
}
|
269 |
-
else
|
270 |
-
{
|
271 |
-
$this->leadin_db_install();
|
272 |
-
}
|
273 |
-
|
274 |
-
// 0.8.3 bug fix - bug fix for duplicated contacts that should be merged
|
275 |
-
if ( ! isset($options['delete_flags_fixed']) )
|
276 |
-
{
|
277 |
-
leadin_delete_flag_fix();
|
278 |
-
}
|
279 |
-
|
280 |
-
// Set the plugin version
|
281 |
-
leadin_update_option('leadin_options', 'leadin_version', LEADIN_PLUGIN_VERSION);
|
282 |
}
|
283 |
|
284 |
-
|
285 |
-
// Scripts & Styles
|
286 |
-
//=============================================
|
287 |
|
288 |
-
|
289 |
-
* Adds front end javascript + initializes ajax object
|
290 |
-
*/
|
291 |
-
function add_leadin_frontend_scripts ()
|
292 |
{
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
wp_enqueue_script('leadin-tracking');
|
297 |
-
|
298 |
-
// replace https with http for admin-ajax calls for SSLed backends
|
299 |
-
wp_localize_script('leadin-tracking', 'li_ajax', array('ajax_url' => str_replace('https:', 'http:', admin_url('admin-ajax.php'))));
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* Adds LeadIn link to top-level admin bar
|
305 |
-
*/
|
306 |
-
function add_leadin_link_to_admin_bar( $wp_admin_bar ) {
|
307 |
-
global $wp_version;
|
308 |
-
|
309 |
-
$args = array(
|
310 |
-
'id' => 'leadin-admin-menu', // id of the existing child node (New > Post)
|
311 |
-
'title' => '<span class="ab-icon" '. ( $wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? ' style="margin-top: 3px;"' : ''). '><img src="/wp-content/plugins/leadin/images/leadin-svg-icon.svg" style="height:16px; width:16px;"></span><span class="ab-label">LeadIn</span>', // alter the title of existing node
|
312 |
-
'parent' => FALSE, // set parent to false to make it a top level (parent) node
|
313 |
-
'href' => get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts',
|
314 |
-
'meta' => array('title' => 'LeadIn')
|
315 |
);
|
316 |
|
317 |
-
|
318 |
}
|
319 |
|
320 |
-
|
321 |
-
|
322 |
-
*/
|
323 |
-
public static function get_available_power_ups( $min_version = FALSE, $max_version = FALSE ) {
|
324 |
-
static $power_ups = null;
|
325 |
-
|
326 |
-
if ( ! isset( $power_ups ) ) {
|
327 |
-
$files = WPLeadIn::glob_php( LEADIN_PLUGIN_DIR . '/power-ups' );
|
328 |
-
|
329 |
-
$power_ups = array();
|
330 |
-
|
331 |
-
foreach ( $files as $file ) {
|
332 |
-
|
333 |
-
if ( ! $headers = WPLeadIn::get_power_up($file) ) {
|
334 |
-
continue;
|
335 |
-
}
|
336 |
-
|
337 |
-
$power_up = new $headers['class']($headers['activated']);
|
338 |
-
$power_up->power_up_name = $headers['name'];
|
339 |
-
$power_up->menu_text = $headers['menu_text'];
|
340 |
-
$power_up->menu_link = $headers['menu_link'];
|
341 |
-
$power_up->slug = $headers['slug'];
|
342 |
-
$power_up->link_uri = $headers['uri'];
|
343 |
-
$power_up->description = $headers['description'];
|
344 |
-
$power_up->icon = $headers['icon'];
|
345 |
-
$power_up->permanent = ( $headers['permanent'] == 'Yes' ? 1 : 0 );
|
346 |
-
$power_up->auto_activate = ( $headers['auto_activate'] == 'Yes' ? 1 : 0 );
|
347 |
-
$power_up->hidden = ( $headers['hidden'] == 'Yes' ? 1 : 0 );
|
348 |
-
$power_up->activated = $headers['activated'];
|
349 |
-
|
350 |
-
// Set the small icons HTML for the settings page
|
351 |
-
if ( strstr($headers['icon_small'], 'dashicons') )
|
352 |
-
$power_up->icon_small = '<span class="dashicons ' . $headers['icon_small'] . '"></span>';
|
353 |
-
else
|
354 |
-
$power_up->icon_small = '<img src="' . LEADIN_PATH . '/images/' . $headers['icon_small'] . '.png" class="power-up-settings-icon"/>';
|
355 |
-
|
356 |
-
array_push($power_ups, $power_up);
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
return $power_ups;
|
361 |
-
}
|
362 |
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
368 |
}
|
|
|
|
|
|
|
369 |
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
public static function get_power_up_path ( $slug ) {
|
374 |
-
return LEADIN_PLUGIN_DIR . "/power-ups/$slug.php";
|
375 |
-
}
|
376 |
|
377 |
-
|
378 |
-
* Load power-up data from power-up file. Headers differ from WordPress
|
379 |
-
* plugin headers to avoid them being identified as standalone
|
380 |
-
* plugins on the WordPress plugins page.
|
381 |
-
*
|
382 |
-
* @param $power_up The file path for the power-up
|
383 |
-
* @return $pu array of power-up attributes
|
384 |
-
*/
|
385 |
-
public static function get_power_up ( $power_up )
|
386 |
{
|
387 |
-
$
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
'uri' => 'Power-up URI',
|
394 |
-
'description' => 'Power-up Description',
|
395 |
-
'icon' => 'Power-up Icon',
|
396 |
-
'icon_small' => 'Power-up Icon Small',
|
397 |
-
'introduced' => 'First Introduced',
|
398 |
-
'auto_activate' => 'Auto Activate',
|
399 |
-
'permanent' => 'Permanently Enabled',
|
400 |
-
'power_up_tags' => 'Power-up Tags',
|
401 |
-
'hidden' => 'Hidden'
|
402 |
-
);
|
403 |
|
404 |
-
|
405 |
-
|
406 |
-
|
|
|
|
|
|
|
407 |
|
408 |
-
|
409 |
|
410 |
-
|
411 |
-
|
412 |
|
413 |
-
|
414 |
|
415 |
-
|
416 |
-
|
|
|
417 |
|
418 |
-
|
419 |
-
|
420 |
-
* Equivalent to glob( "$absolute_path/*.php" ).
|
421 |
-
*
|
422 |
-
* @param string $absolute_path The absolute path of the directory to search.
|
423 |
-
* @return array Array of absolute paths to the PHP files.
|
424 |
-
*/
|
425 |
-
public static function glob_php( $absolute_path ) {
|
426 |
-
$absolute_path = untrailingslashit( $absolute_path );
|
427 |
-
$files = array();
|
428 |
-
if ( ! $dir = @opendir( $absolute_path ) ) {
|
429 |
-
return $files;
|
430 |
-
}
|
431 |
-
|
432 |
-
while ( FALSE !== $file = readdir( $dir ) ) {
|
433 |
-
if ( '.' == substr( $file, 0, 1 ) || '.php' != substr( $file, -4 ) ) {
|
434 |
-
continue;
|
435 |
-
}
|
436 |
-
|
437 |
-
$file = "$absolute_path/$file";
|
438 |
-
|
439 |
-
if ( ! is_file( $file ) ) {
|
440 |
-
continue;
|
441 |
-
}
|
442 |
-
|
443 |
-
$files[] = $file;
|
444 |
-
}
|
445 |
-
|
446 |
-
$files = leadin_sort_power_ups($files, array(
|
447 |
-
LEADIN_PLUGIN_DIR . '/power-ups/contacts.php',
|
448 |
-
LEADIN_PLUGIN_DIR . '/power-ups/subscribe-widget.php',
|
449 |
-
LEADIN_PLUGIN_DIR . '/power-ups/mailchimp-list-sync.php',
|
450 |
-
LEADIN_PLUGIN_DIR . '/power-ups/constant-contact-list-sync.php',
|
451 |
-
LEADIN_PLUGIN_DIR . '/power-ups/beta-program.php'
|
452 |
-
));
|
453 |
-
|
454 |
-
closedir( $dir );
|
455 |
-
|
456 |
-
return $files;
|
457 |
-
}
|
458 |
|
459 |
-
|
460 |
-
* Check whether or not a LeadIn power-up is active.
|
461 |
-
*
|
462 |
-
* @param string $power_up The slug of a power-up
|
463 |
-
* @return bool
|
464 |
-
*
|
465 |
-
* @static
|
466 |
-
*/
|
467 |
-
public static function is_power_up_active( $power_up_slug )
|
468 |
{
|
469 |
-
|
470 |
-
|
|
|
|
|
471 |
|
472 |
-
|
473 |
-
* Get a list of activated modules as an array of module slugs.
|
474 |
-
*/
|
475 |
-
public static function get_active_power_ups ()
|
476 |
-
{
|
477 |
-
$activated_power_ups = get_option('leadin_active_power_ups');
|
478 |
-
if ( $activated_power_ups )
|
479 |
-
return array_unique(unserialize($activated_power_ups));
|
480 |
-
else
|
481 |
-
return array();
|
482 |
}
|
483 |
-
|
484 |
-
public static function activate_power_up( $power_up_slug, $exit = TRUE )
|
485 |
{
|
486 |
-
|
487 |
-
|
488 |
|
489 |
-
//
|
490 |
-
|
491 |
-
if ( $active )
|
492 |
-
return TRUE;
|
493 |
-
|
494 |
-
$activated_power_ups = get_option('leadin_active_power_ups');
|
495 |
-
|
496 |
-
if ( $activated_power_ups )
|
497 |
{
|
498 |
-
$activated_power_ups =
|
499 |
-
$activated_power_ups
|
500 |
}
|
501 |
-
else
|
502 |
{
|
503 |
-
$
|
504 |
-
|
505 |
-
|
506 |
-
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
507 |
-
|
508 |
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
512 |
}
|
513 |
|
|
|
514 |
}
|
515 |
|
516 |
-
|
|
|
517 |
{
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
// If it's already active, then don't do it again
|
522 |
-
$active = self::is_power_up_active($power_up_slug);
|
523 |
-
if ( ! $active )
|
524 |
-
return TRUE;
|
525 |
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
|
|
|
|
|
|
|
|
|
536 |
}
|
|
|
|
|
|
|
537 |
}
|
538 |
|
539 |
//=============================================
|
540 |
-
//
|
541 |
//=============================================
|
542 |
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
547 |
|
548 |
?>
|
3 |
Plugin Name: LeadIn
|
4 |
Plugin URI: http://leadin.com
|
5 |
Description: LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
6 |
+
Version: 2.0.0
|
7 |
Author: Andy Cook, Nelson Joyce
|
8 |
Author URI: http://leadin.com
|
9 |
License: GPL2
|
23 |
define('LEADIN_PLUGIN_SLUG', basename(dirname(__FILE__)));
|
24 |
|
25 |
if ( !defined('LEADIN_DB_VERSION') )
|
26 |
+
define('LEADIN_DB_VERSION', '2.0.0');
|
27 |
|
28 |
if ( !defined('LEADIN_PLUGIN_VERSION') )
|
29 |
+
define('LEADIN_PLUGIN_VERSION', '2.0.0');
|
30 |
|
31 |
if ( !defined('MIXPANEL_PROJECT_TOKEN') )
|
32 |
define('MIXPANEL_PROJECT_TOKEN', 'a9615503ec58a6bce2c646a58390eac1');
|
35 |
// Include Needed Files
|
36 |
//=============================================
|
37 |
|
|
|
|
|
38 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-ajax-functions.php');
|
39 |
require_once(LEADIN_PLUGIN_DIR . '/inc/leadin-functions.php');
|
40 |
+
require_once(LEADIN_PLUGIN_DIR . '/inc/class-emailer.php');
|
41 |
require_once(LEADIN_PLUGIN_DIR . '/inc/class-leadin-updater.php');
|
42 |
+
require_once(LEADIN_PLUGIN_DIR . '/admin/leadin-admin.php');
|
43 |
+
|
44 |
+
|
45 |
+
require_once(LEADIN_PLUGIN_DIR . '/lib/mixpanel/LI_Mixpanel.php');
|
46 |
+
require_once(LEADIN_PLUGIN_DIR . '/inc/class-leadin.php');
|
47 |
+
|
48 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/subscribe-widget.php');
|
49 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/contacts.php');
|
50 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/mailchimp-list-sync.php');
|
51 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/constant-contact-list-sync.php');
|
52 |
require_once(LEADIN_PLUGIN_DIR . '/power-ups/beta-program.php');
|
|
|
53 |
|
54 |
//=============================================
|
55 |
+
// Hooks & Filters
|
56 |
//=============================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
|
|
|
|
58 |
|
|
|
|
|
59 |
|
|
|
|
|
60 |
|
61 |
+
// Pretty sure this hook is being run
|
|
|
62 |
|
63 |
+
if ( ! defined( 'WP_INSTALLING' ) || WP_INSTALLING === false )
|
64 |
+
{
|
65 |
+
if ( ! has_action('init', 'leadin_update_check') )
|
66 |
+
{
|
67 |
+
add_action('init', 'leadin_update_check', 9);
|
|
|
|
|
68 |
}
|
69 |
+
}
|
70 |
|
71 |
+
// Activate + install LeadIn
|
72 |
+
register_activation_hook( __FILE__, 'activate_leadin');
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
// Deactivate LeadIn
|
75 |
+
register_deactivation_hook( __FILE__, 'deactivate_leadin');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
+
// Activate on newly created wpmu blog
|
78 |
+
add_action('wpmu_new_blog', 'activate_leadin_on_new_blog', 10, 6);
|
79 |
|
80 |
+
/**
|
81 |
+
* Activate the plugin
|
82 |
+
*/
|
83 |
+
function activate_leadin ( $network_wide )
|
84 |
+
{
|
85 |
+
// Check activation on entire network or one blog
|
86 |
+
if ( is_multisite() && $network_wide )
|
87 |
+
{
|
88 |
+
global $wpdb;
|
89 |
+
|
90 |
+
// Get this so we can switch back to it later
|
91 |
+
$current_blog = $wpdb->blogid;
|
92 |
+
// For storing the list of activated blogs
|
93 |
+
$activated = array();
|
94 |
+
|
95 |
+
// Get all blogs in the network and activate plugin on each one
|
96 |
+
$q = "SELECT blog_id FROM $wpdb->blogs";
|
97 |
+
$blog_ids = $wpdb->get_col($q);
|
98 |
+
foreach ( $blog_ids as $blog_id )
|
99 |
{
|
100 |
+
switch_to_blog($blog_id);
|
101 |
+
add_leadin_defaults();
|
102 |
+
$activated[] = $blog_id;
|
|
|
|
|
|
|
103 |
}
|
104 |
+
|
105 |
+
// Switch back to the current blog
|
106 |
+
switch_to_blog($current_blog);
|
107 |
+
|
108 |
+
// Store the array for a later function
|
109 |
+
update_site_option('leadin_activated', $activated);
|
110 |
}
|
111 |
+
else
|
112 |
+
add_leadin_defaults();
|
113 |
+
}
|
114 |
|
115 |
+
/**
|
116 |
+
* Check LeadIn installation and set options
|
117 |
+
*/
|
118 |
+
function add_leadin_defaults ( )
|
119 |
+
{
|
120 |
+
global $wpdb;
|
|
|
121 |
|
122 |
+
$options = get_option('leadin_options');
|
|
|
|
|
123 |
|
124 |
+
if ( ($options['li_installed'] != 1) || (!is_array($options)) )
|
|
|
|
|
|
|
125 |
{
|
126 |
+
$opt = array(
|
127 |
+
'li_installed' => 1,
|
128 |
+
'li_db_version' => LEADIN_DB_VERSION,
|
129 |
+
'li_email' => get_bloginfo('admin_email'),
|
130 |
+
'onboarding_complete' => 0,
|
131 |
+
'ignore_settings_popup' => 0,
|
132 |
+
'data_recovered' => 1,
|
133 |
+
'delete_flags_fixed' => 1,
|
134 |
+
'beta_tester' => 0
|
135 |
+
);
|
136 |
|
137 |
+
update_option('leadin_options', $opt);
|
138 |
+
leadin_db_install();
|
139 |
+
|
140 |
+
$multisite_prefix = ( is_multisite() ? $wpdb->prefix : '' );
|
141 |
+
$q = $wpdb->prepare("
|
142 |
+
INSERT INTO " . $multisite_prefix . "li_tags
|
143 |
+
( tag_text, tag_slug, tag_form_selectors, tag_synced_lists, tag_order )
|
144 |
+
VALUES ('Commenters', 'commenters', '#commentform', '', 1),
|
145 |
+
('Leads', 'leads', '', '', 2),
|
146 |
+
('Contacted', 'contacted', '', '', 3),
|
147 |
+
('Customers', 'customers', '', '', 4)", "");
|
148 |
+
$wpdb->query($q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
+
$leadin_active_power_ups = get_option('leadin_active_power_ups');
|
|
|
|
|
152 |
|
153 |
+
if ( !$leadin_active_power_ups )
|
|
|
|
|
|
|
154 |
{
|
155 |
+
$auto_activate = array(
|
156 |
+
'contacts',
|
157 |
+
'beta_program'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
);
|
159 |
|
160 |
+
update_option('leadin_active_power_ups', serialize($auto_activate));
|
161 |
}
|
162 |
|
163 |
+
leadin_track_plugin_registration_hook(TRUE);
|
164 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
+
/**
|
167 |
+
* Deactivate LeadIn plugin hook
|
168 |
+
*/
|
169 |
+
function deactivate_leadin ( $network_wide )
|
170 |
+
{
|
171 |
+
if ( is_multisite() && $network_wide )
|
172 |
+
{
|
173 |
+
global $wpdb;
|
174 |
+
|
175 |
+
// Get this so we can switch back to it later
|
176 |
+
$current_blog = $wpdb->blogid;
|
177 |
+
|
178 |
+
// Get all blogs in the network and activate plugin on each one
|
179 |
+
$q = "SELECT blog_id FROM $wpdb->blogs";
|
180 |
+
$blog_ids = $wpdb->get_col($q);
|
181 |
+
foreach ( $blog_ids as $blog_id )
|
182 |
+
{
|
183 |
+
switch_to_blog($blog_id);
|
184 |
+
leadin_track_plugin_registration_hook(FALSE);
|
185 |
+
}
|
186 |
+
|
187 |
+
// Switch back to the current blog
|
188 |
+
switch_to_blog($current_blog);
|
189 |
}
|
190 |
+
else
|
191 |
+
leadin_track_plugin_registration_hook(FALSE);
|
192 |
+
}
|
193 |
|
194 |
+
function activate_leadin_on_new_blog ( $blog_id, $user_id, $domain, $path, $site_id, $meta )
|
195 |
+
{
|
196 |
+
global $wpdb;
|
|
|
|
|
|
|
197 |
|
198 |
+
if ( is_plugin_active_for_network('leadin/leadin.php') )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
{
|
200 |
+
$current_blog = $wpdb->blogid;
|
201 |
+
switch_to_blog($blog_id);
|
202 |
+
add_leadin_defaults();
|
203 |
+
switch_to_blog($current_blog);
|
204 |
+
}
|
205 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
+
/**
|
208 |
+
* Checks the stored database version against the current data version + updates if needed
|
209 |
+
*/
|
210 |
+
function leadin_update_check ()
|
211 |
+
{
|
212 |
+
global $wpdb;
|
213 |
|
214 |
+
$leadin_wp = new WPLeadIn();
|
215 |
|
216 |
+
if ( defined('DOING_AJAX') && DOING_AJAX )
|
217 |
+
return;
|
218 |
|
219 |
+
$options = get_option('leadin_options');
|
220 |
|
221 |
+
// If the plugin version matches the latest version escape the update function
|
222 |
+
if ( isset ($options['leadin_version']) && $options['leadin_version'] == LEADIN_PLUGIN_VERSION )
|
223 |
+
return FALSE;
|
224 |
|
225 |
+
// 0.5.1 upgrade - Create active power-ups option if it doesn't exist
|
226 |
+
$leadin_active_power_ups = get_option('leadin_active_power_ups');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
+
if ( !$leadin_active_power_ups )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
{
|
230 |
+
$auto_activate = array(
|
231 |
+
'contacts',
|
232 |
+
'beta_program'
|
233 |
+
);
|
234 |
|
235 |
+
update_option('leadin_active_power_ups', serialize($auto_activate));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
}
|
237 |
+
else
|
|
|
238 |
{
|
239 |
+
// 0.9.2 upgrade - set beta program power-up to auto-activate
|
240 |
+
$activated_power_ups = unserialize($leadin_active_power_ups);
|
241 |
|
242 |
+
// 0.9.3 bug fix for dupliate beta_program values being stored in the active power-ups array
|
243 |
+
if ( !in_array('beta_program', $activated_power_ups) )
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
{
|
245 |
+
$activated_power_ups[] = 'beta_program';
|
246 |
+
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
247 |
}
|
248 |
+
else
|
249 |
{
|
250 |
+
$tmp = array_count_values($activated_power_ups);
|
251 |
+
$count = $tmp['beta_program'];
|
|
|
|
|
|
|
252 |
|
253 |
+
if ( $count > 1 )
|
254 |
+
{
|
255 |
+
$activated_power_ups = array_unique($activated_power_ups);
|
256 |
+
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
257 |
+
}
|
258 |
}
|
259 |
|
260 |
+
update_option('leadin_active_power_ups', serialize($activated_power_ups));
|
261 |
}
|
262 |
|
263 |
+
// 0.7.2 bug fix - data recovery algorithm for deleted contacts
|
264 |
+
if ( ! isset($options['data_recovered']) )
|
265 |
{
|
266 |
+
leadin_recover_contact_data();
|
267 |
+
}
|
|
|
|
|
|
|
|
|
|
|
268 |
|
269 |
+
// Set the database version if it doesn't exist
|
270 |
+
if ( isset($options['li_db_version']) )
|
271 |
+
{
|
272 |
+
if ( $options['li_db_version'] != LEADIN_DB_VERSION )
|
273 |
+
{
|
274 |
+
leadin_db_install();
|
275 |
+
|
276 |
+
// 2.0.0 upgrade
|
277 |
+
if ( ! isset($options['converted_to_tags']) )
|
278 |
+
leadin_convert_statuses_to_tags();
|
279 |
+
}
|
280 |
+
}
|
281 |
+
else
|
282 |
+
{
|
283 |
+
leadin_db_install();
|
284 |
+
}
|
285 |
|
286 |
+
// 0.8.3 bug fix - bug fix for duplicated contacts that should be merged
|
287 |
+
if ( ! isset($options['delete_flags_fixed']) )
|
288 |
+
{
|
289 |
+
leadin_delete_flag_fix();
|
290 |
}
|
291 |
+
|
292 |
+
// Set the plugin version
|
293 |
+
leadin_update_option('leadin_options', 'leadin_version', LEADIN_PLUGIN_VERSION);
|
294 |
}
|
295 |
|
296 |
//=============================================
|
297 |
+
// Database update
|
298 |
//=============================================
|
299 |
|
300 |
+
/**
|
301 |
+
* Creates or updates the LeadIn tables
|
302 |
+
*/
|
303 |
+
function leadin_db_install ()
|
304 |
+
{
|
305 |
+
global $wpdb;
|
306 |
+
|
307 |
+
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
308 |
+
|
309 |
+
$multisite_prefix = ( is_multisite() ? $wpdb->prefix : '' );
|
310 |
+
|
311 |
+
$sql = "
|
312 |
+
CREATE TABLE " . $multisite_prefix . "li_leads (
|
313 |
+
`lead_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
314 |
+
`lead_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
315 |
+
`hashkey` varchar(16) DEFAULT NULL,
|
316 |
+
`lead_ip` varchar(40) DEFAULT NULL,
|
317 |
+
`lead_source` text,
|
318 |
+
`lead_email` varchar(255) DEFAULT NULL,
|
319 |
+
`lead_status` set('contact','lead','comment','subscribe','contacted','customer') NOT NULL DEFAULT 'contact',
|
320 |
+
`merged_hashkeys` text,
|
321 |
+
`lead_deleted` int(1) NOT NULL DEFAULT '0',
|
322 |
+
`blog_id` int(11) unsigned NOT NULL,
|
323 |
+
PRIMARY KEY (`lead_id`),
|
324 |
+
KEY `hashkey` (`hashkey`)
|
325 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
|
326 |
+
|
327 |
+
CREATE TABLE " . $multisite_prefix . "li_pageviews (
|
328 |
+
`pageview_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
329 |
+
`pageview_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
330 |
+
`lead_hashkey` varchar(16) NOT NULL,
|
331 |
+
`pageview_title` varchar(255) NOT NULL,
|
332 |
+
`pageview_url` text NOT NULL,
|
333 |
+
`pageview_source` text NOT NULL,
|
334 |
+
`pageview_session_start` int(1) NOT NULL,
|
335 |
+
`pageview_deleted` int(1) NOT NULL DEFAULT '0',
|
336 |
+
`blog_id` int(11) unsigned NOT NULL,
|
337 |
+
PRIMARY KEY (`pageview_id`),
|
338 |
+
KEY `lead_hashkey` (`lead_hashkey`)
|
339 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
340 |
+
|
341 |
+
CREATE TABLE " . $multisite_prefix . "li_submissions (
|
342 |
+
`form_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
343 |
+
`form_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
344 |
+
`lead_hashkey` varchar(16) NOT NULL,
|
345 |
+
`form_page_title` varchar(255) NOT NULL,
|
346 |
+
`form_page_url` text NOT NULL,
|
347 |
+
`form_fields` text NOT NULL,
|
348 |
+
`form_selector_id` mediumtext NOT NULL,
|
349 |
+
`form_selector_classes` mediumtext NOT NULL,
|
350 |
+
`form_hashkey` varchar(16) NOT NULL,
|
351 |
+
`form_deleted` int(1) NOT NULL DEFAULT '0',
|
352 |
+
`blog_id` int(11) unsigned NOT NULL,
|
353 |
+
PRIMARY KEY (`form_id`),
|
354 |
+
KEY `lead_hashkey` (`lead_hashkey`)
|
355 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
|
356 |
+
|
357 |
+
CREATE TABLE " . $multisite_prefix . "li_tags (
|
358 |
+
`tag_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
359 |
+
`tag_text` varchar(255) NOT NULL,
|
360 |
+
`tag_slug` varchar(255) NOT NULL,
|
361 |
+
`tag_form_selectors` mediumtext NOT NULL,
|
362 |
+
`tag_synced_lists` mediumtext NOT NULL,
|
363 |
+
`tag_order` int(11) unsigned NOT NULL,
|
364 |
+
`blog_id` int(11) unsigned NOT NULL,
|
365 |
+
`tag_deleted` int(1) NOT NULL,
|
366 |
+
PRIMARY KEY (`tag_id`)
|
367 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
|
368 |
+
|
369 |
+
CREATE TABLE " . $multisite_prefix . "li_tag_relationships (
|
370 |
+
`tag_relationship_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
371 |
+
`tag_id` int(11) unsigned NOT NULL,
|
372 |
+
`contact_hashkey` varchar(16) NOT NULL,
|
373 |
+
`tag_relationship_deleted` int(1) unsigned NOT NULL,
|
374 |
+
`blog_id` int(11) unsigned NOT NULL,
|
375 |
+
PRIMARY KEY (`tag_relationship_id`)
|
376 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;";
|
377 |
+
|
378 |
+
dbDelta($sql);
|
379 |
+
|
380 |
+
leadin_update_option('leadin_options', 'li_db_version', LEADIN_DB_VERSION);
|
381 |
+
}
|
382 |
|
383 |
?>
|
power-ups/beta-program/admin/beta-program-admin.php
CHANGED
@@ -42,8 +42,6 @@ class WPLeadInBetaAdmin extends WPLeadInAdmin {
|
|
42 |
function leadin_beta_program_build_settings_page ()
|
43 |
{
|
44 |
// Need to use the santize function from the main admin class because that is where leadin_options is set
|
45 |
-
global $li_wp_admin;
|
46 |
-
|
47 |
add_settings_section(
|
48 |
$this->power_up_settings_section,
|
49 |
$this->power_up_icon . 'LeadIn Beta Program',
|
42 |
function leadin_beta_program_build_settings_page ()
|
43 |
{
|
44 |
// Need to use the santize function from the main admin class because that is where leadin_options is set
|
|
|
|
|
45 |
add_settings_section(
|
46 |
$this->power_up_settings_section,
|
47 |
$this->power_up_icon . 'LeadIn Beta Program',
|
power-ups/constant-contact-list-sync.php
CHANGED
@@ -47,6 +47,8 @@ class WPConstantContactListSync extends WPLeadIn {
|
|
47 |
|
48 |
var $admin;
|
49 |
var $options;
|
|
|
|
|
50 |
|
51 |
/**
|
52 |
* Class constructor
|
@@ -84,34 +86,76 @@ class WPConstantContactListSync extends WPLeadIn {
|
|
84 |
|
85 |
}
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
{
|
89 |
-
$options
|
90 |
-
|
91 |
-
$li_cc_subscribers_to_list = ( isset($options['li_cc_subscribers_to_list']) ? $options['li_cc_subscribers_to_list'] : '' );
|
92 |
-
|
93 |
-
if ( isset($options['li_cc_email']) && isset($options['li_cc_password']) && $options['li_cc_email'] && $options['li_cc_password'] && $li_cc_subscribers_to_list )
|
94 |
{
|
95 |
-
|
|
|
|
|
|
|
96 |
|
97 |
-
|
|
|
|
|
|
|
98 |
|
99 |
-
if ( $
|
100 |
-
$
|
|
|
|
|
|
|
|
|
|
|
101 |
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
|
106 |
-
|
107 |
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
|
111 |
-
|
112 |
-
|
113 |
|
114 |
-
|
|
|
|
|
|
|
115 |
}
|
116 |
}
|
117 |
}
|
47 |
|
48 |
var $admin;
|
49 |
var $options;
|
50 |
+
var $constant_contact;
|
51 |
+
var $cc_id;
|
52 |
|
53 |
/**
|
54 |
* Class constructor
|
86 |
|
87 |
}
|
88 |
|
89 |
+
/**
|
90 |
+
* Adds a subcsriber to a specific list
|
91 |
+
*
|
92 |
+
* @param string
|
93 |
+
* @param string
|
94 |
+
* @param string
|
95 |
+
* @param string
|
96 |
+
* @param string
|
97 |
+
* @return int ContactID for the new entry
|
98 |
+
*/
|
99 |
+
function push_contact_to_list ( $list_id = '', $email = '', $first_name = '', $last_name = '', $phone = '' )
|
100 |
{
|
101 |
+
if ( isset($this->options['li_cc_email']) && isset($this->options['li_cc_password']) && $this->options['li_cc_email'] && $this->options['li_cc_password'] )
|
|
|
|
|
|
|
|
|
102 |
{
|
103 |
+
// Convert the stored list id integer into the accepted constant contact list id format
|
104 |
+
$list_id = 'http://api.constantcontact.com/ws/customers/' . str_replace('@', '%40', $this->options['li_cc_email']) . '/lists/' . $list_id;
|
105 |
+
|
106 |
+
$this->constant_contact = new LI_ConstantContact($this->options['li_cc_email'], $this->options['li_cc_password'], LEADIN_CONSTANT_CONTACT_API_KEY, FALSE);
|
107 |
|
108 |
+
if ( ! isset($this->cc_id) )
|
109 |
+
{
|
110 |
+
$this->cc_id = $this->constant_contact->search_contact_by_email($email);
|
111 |
+
}
|
112 |
|
113 |
+
if ( $this->cc_id )
|
114 |
+
return $this->constant_contact->add_subscription($this->cc_id, $list_id, 'ACTION_BY_CLIENT');
|
115 |
+
else
|
116 |
+
{
|
117 |
+
$contact = array();
|
118 |
+
if ( $email )
|
119 |
+
$contact['EmailAddress'] = $email;
|
120 |
|
121 |
+
if ( $first_name )
|
122 |
+
$contact['FirstName'] = $first_name;
|
123 |
|
124 |
+
if ( $last_name )
|
125 |
+
$contact['LastName'] = $last_name;
|
126 |
|
127 |
+
if ( $phone )
|
128 |
+
$contact['HomePhone'] = $phone;
|
129 |
+
|
130 |
+
if ( $phone )
|
131 |
+
$contact['WorkPhone'] = $phone;
|
132 |
+
|
133 |
+
return $this->constant_contact->add_contact($contact, array($list_id));
|
134 |
+
}
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Removes an email address from a specific list
|
140 |
+
*
|
141 |
+
* @param string
|
142 |
+
* @param string
|
143 |
+
* @return bool
|
144 |
+
*/
|
145 |
+
function remove_contact_from_list ( $list_id = '', $email = '' )
|
146 |
+
{
|
147 |
+
if ( isset($this->options['li_cc_email']) && isset($this->options['li_cc_password']) && $this->options['li_cc_email'] && $this->options['li_cc_password'] )
|
148 |
+
{
|
149 |
+
// Convert the stored list id integer into the accepted constant contact list id format
|
150 |
+
$list_id = 'http://api.constantcontact.com/ws/customers/' . str_replace('@', '%40', $this->options['li_cc_email']) . '/lists/' . $list_id;
|
151 |
|
152 |
+
$this->constant_contact = new LI_ConstantContact($this->options['li_cc_email'], $this->options['li_cc_password'], LEADIN_CONSTANT_CONTACT_API_KEY, FALSE);
|
153 |
+
$cc_id = $this->constant_contact->search_contact_by_email($email);
|
154 |
|
155 |
+
if ( $cc_id )
|
156 |
+
return $this->constant_contact->remove_subscription($cc_id, $list_id);
|
157 |
+
else
|
158 |
+
return FALSE;
|
159 |
}
|
160 |
}
|
161 |
}
|
power-ups/constant-contact-list-sync/admin/constant-contact-list-sync-admin.php
CHANGED
@@ -6,24 +6,30 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
6 |
|
7 |
var $power_up_settings_section = 'leadin_cc_options_section';
|
8 |
var $power_up_icon;
|
9 |
-
var $auth_set;
|
10 |
var $bad_api_call;
|
11 |
var $constant_contact;
|
12 |
var $lists;
|
|
|
|
|
13 |
|
14 |
/**
|
15 |
* Class constructor
|
16 |
*/
|
17 |
function __construct ( $power_up_icon_small )
|
18 |
{
|
|
|
|
|
19 |
//=============================================
|
20 |
// Hooks & Filters
|
21 |
//=============================================
|
22 |
-
|
23 |
if ( is_admin() )
|
24 |
{
|
25 |
$this->power_up_icon = $power_up_icon_small;
|
26 |
add_action('admin_init', array($this, 'leadin_cc_build_settings_page'));
|
|
|
|
|
|
|
27 |
}
|
28 |
}
|
29 |
|
@@ -38,17 +44,13 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
38 |
{
|
39 |
global $leadin_constant_contact_list_sync_wp;
|
40 |
|
41 |
-
$options = get_option('leadin_cc_options');
|
42 |
-
|
43 |
register_setting('leadin_settings_options', 'leadin_cc_options', array($this, 'sanitize'));
|
44 |
|
45 |
// If the creds are set, check if they are any good by hitting the API
|
46 |
-
if (
|
47 |
{
|
48 |
-
$this->auth_set = TRUE;
|
49 |
-
|
50 |
// Try to make a request using the authentication credentials
|
51 |
-
$this->lists = $this->li_cc_get_email_lists(LEADIN_CONSTANT_CONTACT_API_KEY, $options['li_cc_email'], $options['li_cc_password']);
|
52 |
|
53 |
if ( $this->constant_contact->cc_exception )
|
54 |
{
|
@@ -58,10 +60,8 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
58 |
|
59 |
add_settings_section($this->power_up_settings_section, $this->power_up_icon . "Constant Contact", array($this, 'cc_section_callback'), LEADIN_ADMIN_PATH);
|
60 |
|
61 |
-
if ( $this->
|
62 |
-
|
63 |
-
add_settings_field('li_cc_subscribers_to_list', 'Add subscribers to list', array($this, 'li_cc_subscribers_to_list_callback'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
64 |
-
}
|
65 |
else
|
66 |
{
|
67 |
add_settings_field('li_cc_email', 'Email', array($this, 'li_cc_email_callback'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
@@ -71,7 +71,7 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
71 |
|
72 |
function cc_section_callback ( )
|
73 |
{
|
74 |
-
if ( ! $this->
|
75 |
echo '<div class="leadin-section">Sign into your Constant Contact account below to setup Contact Sync</div>';
|
76 |
else if ( $this->bad_api_call )
|
77 |
echo '<div class="leadin-section"><p style="color: #f33f33; font-weight: bold;">' . $this->constant_contact->cc_exception . '</p></div>';
|
@@ -82,9 +82,8 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
82 |
function print_hidden_settings_fields ()
|
83 |
{
|
84 |
// Hacky solution to solve the Settings API overwriting the default values
|
85 |
-
$
|
86 |
-
$
|
87 |
-
$li_cc_password = ( $options['li_cc_password'] ? $options['li_cc_password'] : '' );
|
88 |
|
89 |
if ( $li_cc_email )
|
90 |
{
|
@@ -129,8 +128,7 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
129 |
*/
|
130 |
function li_cc_email_callback ()
|
131 |
{
|
132 |
-
$
|
133 |
-
$li_cc_email = ( $options['li_cc_email'] ? $options['li_cc_email'] : '' ); // Get header from options, or show default
|
134 |
|
135 |
printf(
|
136 |
'<input id="li_cc_email" type="text" id="title" name="leadin_cc_options[li_cc_email]" value="%s" size="50"/>',
|
@@ -143,8 +141,7 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
143 |
*/
|
144 |
function li_cc_password_callback ()
|
145 |
{
|
146 |
-
$
|
147 |
-
$li_cc_password = ( $options['li_cc_password'] ? $options['li_cc_password'] : '' ); // Get header from options, or show default
|
148 |
|
149 |
printf(
|
150 |
'<input id="li_cc_password" type="password" id="title" name="leadin_cc_options[li_cc_password]" value="%s" size="50"/>',
|
@@ -157,8 +154,7 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
157 |
*/
|
158 |
function li_cc_subscribers_to_list_callback ()
|
159 |
{
|
160 |
-
$
|
161 |
-
$li_cc_subscribers_to_list = ( isset($options['li_cc_subscribers_to_list']) ? $options['li_cc_subscribers_to_list'] : '' ); // Get header from options, or show default
|
162 |
|
163 |
echo '<select id="li_cc_subscribers_to_list" name="leadin_cc_options[li_cc_subscribers_to_list]" ' . ( ! count($this->lists) ? 'disabled' : '' ) . '>';
|
164 |
|
@@ -200,6 +196,73 @@ class WPConstantContactListSyncAdmin extends WPLeadInAdmin {
|
|
200 |
else
|
201 |
return FALSE;
|
202 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
?>
|
6 |
|
7 |
var $power_up_settings_section = 'leadin_cc_options_section';
|
8 |
var $power_up_icon;
|
|
|
9 |
var $bad_api_call;
|
10 |
var $constant_contact;
|
11 |
var $lists;
|
12 |
+
var $options;
|
13 |
+
var $authed = FALSE;
|
14 |
|
15 |
/**
|
16 |
* Class constructor
|
17 |
*/
|
18 |
function __construct ( $power_up_icon_small )
|
19 |
{
|
20 |
+
global $pagenow;
|
21 |
+
|
22 |
//=============================================
|
23 |
// Hooks & Filters
|
24 |
//=============================================
|
25 |
+
|
26 |
if ( is_admin() )
|
27 |
{
|
28 |
$this->power_up_icon = $power_up_icon_small;
|
29 |
add_action('admin_init', array($this, 'leadin_cc_build_settings_page'));
|
30 |
+
$this->options = get_option('leadin_cc_options');
|
31 |
+
if ( isset($this->options['li_cc_email']) && isset($this->options['li_cc_password']) && $this->options['li_cc_email'] && $this->options['li_cc_password'] )
|
32 |
+
$this->authed = TRUE;
|
33 |
}
|
34 |
}
|
35 |
|
44 |
{
|
45 |
global $leadin_constant_contact_list_sync_wp;
|
46 |
|
|
|
|
|
47 |
register_setting('leadin_settings_options', 'leadin_cc_options', array($this, 'sanitize'));
|
48 |
|
49 |
// If the creds are set, check if they are any good by hitting the API
|
50 |
+
if ( $this->authed )
|
51 |
{
|
|
|
|
|
52 |
// Try to make a request using the authentication credentials
|
53 |
+
$this->lists = $this->li_cc_get_email_lists(LEADIN_CONSTANT_CONTACT_API_KEY, $this->options['li_cc_email'], $this->options['li_cc_password']);
|
54 |
|
55 |
if ( $this->constant_contact->cc_exception )
|
56 |
{
|
60 |
|
61 |
add_settings_section($this->power_up_settings_section, $this->power_up_icon . "Constant Contact", array($this, 'cc_section_callback'), LEADIN_ADMIN_PATH);
|
62 |
|
63 |
+
if ( $this->authed && ! $this->bad_api_call )
|
64 |
+
add_settings_field('li_print_synced_lists', 'Synced tags', array($this, 'li_print_synced_lists'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
|
|
|
|
65 |
else
|
66 |
{
|
67 |
add_settings_field('li_cc_email', 'Email', array($this, 'li_cc_email_callback'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
71 |
|
72 |
function cc_section_callback ( )
|
73 |
{
|
74 |
+
if ( ! $this->authed )
|
75 |
echo '<div class="leadin-section">Sign into your Constant Contact account below to setup Contact Sync</div>';
|
76 |
else if ( $this->bad_api_call )
|
77 |
echo '<div class="leadin-section"><p style="color: #f33f33; font-weight: bold;">' . $this->constant_contact->cc_exception . '</p></div>';
|
82 |
function print_hidden_settings_fields ()
|
83 |
{
|
84 |
// Hacky solution to solve the Settings API overwriting the default values
|
85 |
+
$li_cc_email = ( $this->options['li_cc_email'] ? $this->options['li_cc_email'] : '' );
|
86 |
+
$li_cc_password = ( $this->options['li_cc_password'] ? $this->options['li_cc_password'] : '' );
|
|
|
87 |
|
88 |
if ( $li_cc_email )
|
89 |
{
|
128 |
*/
|
129 |
function li_cc_email_callback ()
|
130 |
{
|
131 |
+
$li_cc_email = ( $this->options['li_cc_email'] ? $this->options['li_cc_email'] : '' ); // Get header from options, or show default
|
|
|
132 |
|
133 |
printf(
|
134 |
'<input id="li_cc_email" type="text" id="title" name="leadin_cc_options[li_cc_email]" value="%s" size="50"/>',
|
141 |
*/
|
142 |
function li_cc_password_callback ()
|
143 |
{
|
144 |
+
$li_cc_password = ( $this->options['li_cc_password'] ? $this->options['li_cc_password'] : '' ); // Get header from options, or show default
|
|
|
145 |
|
146 |
printf(
|
147 |
'<input id="li_cc_password" type="password" id="title" name="leadin_cc_options[li_cc_password]" value="%s" size="50"/>',
|
154 |
*/
|
155 |
function li_cc_subscribers_to_list_callback ()
|
156 |
{
|
157 |
+
$li_cc_subscribers_to_list = ( isset($this->options['li_cc_subscribers_to_list']) ? $this->options['li_cc_subscribers_to_list'] : '' ); // Get header from options, or show default
|
|
|
158 |
|
159 |
echo '<select id="li_cc_subscribers_to_list" name="leadin_cc_options[li_cc_subscribers_to_list]" ' . ( ! count($this->lists) ? 'disabled' : '' ) . '>';
|
160 |
|
196 |
else
|
197 |
return FALSE;
|
198 |
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Prints synced lists with tag name
|
202 |
+
*/
|
203 |
+
function li_print_synced_lists ()
|
204 |
+
{
|
205 |
+
$synced_lists = $this->li_get_synced_list_for_esp('constant_contact');
|
206 |
+
$list_value_pairs = array();
|
207 |
+
$synced_list_count = 0;
|
208 |
+
|
209 |
+
echo '<table>';
|
210 |
+
foreach ( $synced_lists as $synced_list )
|
211 |
+
{
|
212 |
+
foreach ( stripslashes_deep(unserialize($synced_list->tag_synced_lists)) as $tag_synced_list )
|
213 |
+
{
|
214 |
+
if ( $tag_synced_list['esp'] == 'constant_contact' )
|
215 |
+
{
|
216 |
+
echo '<tr class="synced-list-row">';
|
217 |
+
echo '<td class="synced-list-cell"><span class="icon-tag"></span> ' . $synced_list->tag_text . '</td>';
|
218 |
+
echo '<td class="synced-list-cell"><span class="synced-list-arrow">→</span></td>';
|
219 |
+
echo '<td class="synced-list-cell"><span class="icon-envelope"></span> ' . $tag_synced_list['list_name'] . '</td>';
|
220 |
+
echo '<td class="synced-list-edit"><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=edit_tag&tag=' . $synced_list->tag_id . '">edit</a></td>';
|
221 |
+
echo '</tr>';
|
222 |
+
|
223 |
+
$synced_list_count++;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
echo '</table>';
|
228 |
+
|
229 |
+
if ( ! $synced_list_count )
|
230 |
+
echo "<p>You don't have any Constant Contact lists synced with LeadIn yet...</p>";
|
231 |
+
|
232 |
+
echo '<p><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=manage_tags' . '">Manage tags</a></p>';
|
233 |
+
|
234 |
+
echo '<p style="padding-top: 10px;"><a href="https://login.constantcontact.com/login/login.sdo?goto=https://ui.constantcontact.com/rnavmap/distui/contacts" target="_blank">Create a new list on ConstantContact.com</a></p>';
|
235 |
+
}
|
236 |
+
|
237 |
+
function li_get_synced_list_for_esp ( $esp_name, $output_type = 'OBJECT' )
|
238 |
+
{
|
239 |
+
global $wpdb;
|
240 |
+
|
241 |
+
$q = $wpdb->prepare("SELECT * FROM $wpdb->li_tags WHERE tag_synced_lists LIKE '%%%s%%' AND tag_deleted = 0", $esp_name);
|
242 |
+
$synced_lists = $wpdb->get_results($q, $output_type);
|
243 |
+
|
244 |
+
return $synced_lists;
|
245 |
+
}
|
246 |
+
|
247 |
+
function li_get_lists ( )
|
248 |
+
{
|
249 |
+
$lists = $this->li_cc_get_email_lists(LEADIN_CONSTANT_CONTACT_API_KEY, $this->options['li_cc_email'], $this->options['li_cc_password']);
|
250 |
+
|
251 |
+
$sanitized_lists = array();
|
252 |
+
if ( count($lists) )
|
253 |
+
{
|
254 |
+
foreach ( $lists as $list )
|
255 |
+
{
|
256 |
+
$list_obj = (Object)NULL;
|
257 |
+
$list_obj->id = $list['ListID'];
|
258 |
+
$list_obj->name = $list['Name'];
|
259 |
+
|
260 |
+
array_push($sanitized_lists, $list_obj);;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
return $sanitized_lists;
|
265 |
+
}
|
266 |
}
|
267 |
|
268 |
?>
|
power-ups/constant-contact-list-sync/inc/li_constant_contact.php
CHANGED
@@ -19,7 +19,7 @@ class LI_ConstantContact
|
|
19 |
* @param String $debug_style - Options are "cli" or "html". All it does is print "\n" or "<br>" for debugging output.
|
20 |
*/
|
21 |
|
22 |
-
public function __construct ( $username = '', $password = '', $api_key = '', $debug_enabled = FALSE, $debug_style = '
|
23 |
{
|
24 |
$this->debug['enabled'] = $debug_enabled;
|
25 |
$this->debug['style'] = $debug_style;
|
@@ -76,6 +76,7 @@ class LI_ConstantContact
|
|
76 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
|
77 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
78 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
79 |
if(strlen(trim($post))>0)
|
80 |
{
|
81 |
if ($this->debug['style'] == 'cli')
|
@@ -103,6 +104,8 @@ class LI_ConstantContact
|
|
103 |
}
|
104 |
|
105 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
|
|
106 |
|
107 |
$response = curl_exec($ch);
|
108 |
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
@@ -126,8 +129,9 @@ class LI_ConstantContact
|
|
126 |
$this->debug_print("Received:\n\n---START---\n".$response."\n---END---\n\n");
|
127 |
elseif ($this->debug['style'] == 'html')
|
128 |
$this->debug_print("Received:<pre>\n\n---START---\n".htmlspecialchars($response)."\n---END---\n\n</pre>");
|
129 |
-
|
130 |
curl_close($ch);
|
|
|
131 |
if ($fetch_as == 'array')
|
132 |
return $this->xml_to_array($response);
|
133 |
else
|
@@ -476,15 +480,20 @@ class LI_ConstantContact
|
|
476 |
{
|
477 |
//Get the old xml from get_contact() and then post after replacing values that need replacing
|
478 |
$url = $this->api['url'].'contacts?email='.urlencode(strtolower($email));
|
|
|
479 |
$response = Array();
|
480 |
$response = $this->fetch($url,$post);
|
481 |
|
482 |
if ($this->debug['last_response'] <= 204)
|
483 |
{
|
484 |
if ($id_only)
|
|
|
485 |
return $this->id_from_url($response['feed']['entry']['id']['value']);
|
|
|
486 |
else
|
|
|
487 |
return $this->get_contact($this->id_from_url($response['feed']['entry']['id']['value']));
|
|
|
488 |
}
|
489 |
else
|
490 |
return false;
|
19 |
* @param String $debug_style - Options are "cli" or "html". All it does is print "\n" or "<br>" for debugging output.
|
20 |
*/
|
21 |
|
22 |
+
public function __construct ( $username = '', $password = '', $api_key = '', $debug_enabled = FALSE, $debug_style = 'html' )
|
23 |
{
|
24 |
$this->debug['enabled'] = $debug_enabled;
|
25 |
$this->debug['style'] = $debug_style;
|
76 |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
|
77 |
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
78 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
79 |
+
|
80 |
if(strlen(trim($post))>0)
|
81 |
{
|
82 |
if ($this->debug['style'] == 'cli')
|
104 |
}
|
105 |
|
106 |
curl_setopt($ch, CURLOPT_HEADER, 0);
|
107 |
+
|
108 |
+
|
109 |
|
110 |
$response = curl_exec($ch);
|
111 |
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
129 |
$this->debug_print("Received:\n\n---START---\n".$response."\n---END---\n\n");
|
130 |
elseif ($this->debug['style'] == 'html')
|
131 |
$this->debug_print("Received:<pre>\n\n---START---\n".htmlspecialchars($response)."\n---END---\n\n</pre>");
|
132 |
+
|
133 |
curl_close($ch);
|
134 |
+
|
135 |
if ($fetch_as == 'array')
|
136 |
return $this->xml_to_array($response);
|
137 |
else
|
480 |
{
|
481 |
//Get the old xml from get_contact() and then post after replacing values that need replacing
|
482 |
$url = $this->api['url'].'contacts?email='.urlencode(strtolower($email));
|
483 |
+
$post = '';
|
484 |
$response = Array();
|
485 |
$response = $this->fetch($url,$post);
|
486 |
|
487 |
if ($this->debug['last_response'] <= 204)
|
488 |
{
|
489 |
if ($id_only)
|
490 |
+
{
|
491 |
return $this->id_from_url($response['feed']['entry']['id']['value']);
|
492 |
+
}
|
493 |
else
|
494 |
+
{
|
495 |
return $this->get_contact($this->id_from_url($response['feed']['entry']['id']['value']));
|
496 |
+
}
|
497 |
}
|
498 |
else
|
499 |
return false;
|
power-ups/contacts/admin/contacts-admin.php
CHANGED
@@ -12,6 +12,8 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
12 |
/**
|
13 |
* Class constructor
|
14 |
*/
|
|
|
|
|
15 |
function __construct ()
|
16 |
{
|
17 |
//=============================================
|
@@ -48,16 +50,100 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
48 |
{
|
49 |
global $wp_version;
|
50 |
|
51 |
-
$action = $this->leadin_current_action();
|
52 |
-
if ( $action == 'delete' )
|
53 |
{
|
54 |
$lead_id = ( isset($_GET['lead']) ? absint($_GET['lead']) : FALSE );
|
55 |
$this->delete_lead($lead_id);
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
echo '<div id="leadin" class="wrap '. ( $wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? 'pre-mp6' : ''). '">';
|
59 |
|
60 |
-
if ( $action
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
leadin_track_plugin_activity("Loaded Contact List Page");
|
62 |
$this->leadin_render_list_page();
|
63 |
}
|
@@ -66,6 +152,7 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
66 |
$this->leadin_render_contact_detail($_GET['lead']);
|
67 |
}
|
68 |
|
|
|
69 |
$this->leadin_footer();
|
70 |
|
71 |
echo '</div>';
|
@@ -93,45 +180,75 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
93 |
*/
|
94 |
function leadin_render_contact_detail ( $lead_id )
|
95 |
{
|
96 |
-
if ( isset($_GET['contact_status']) )
|
97 |
-
{
|
98 |
-
$this->update_contact_status($lead_id, $_GET['contact_status']);
|
99 |
-
}
|
100 |
-
|
101 |
$li_contact = new LI_Contact();
|
102 |
$li_contact->set_hashkey_by_id($lead_id);
|
103 |
$li_contact->get_contact_history();
|
104 |
-
|
105 |
$lead_email = $li_contact->history->lead->lead_email;
|
106 |
-
|
107 |
$lead_source = leadin_strip_params_from_url($li_contact->history->lead->lead_source);
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
if ( isset($_GET['post_id']) )
|
110 |
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?post=' . $_GET['post_id'] . '&action=edit#li_analytics-meta">← All Viewers</a>';
|
111 |
else if ( isset($_GET['stats_dashboard']) )
|
112 |
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_stats">← Stat Dashboard</a>';
|
113 |
else
|
114 |
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts">← All Contacts</a>';
|
115 |
-
|
116 |
echo '<div class="contact-header-wrap">';
|
117 |
echo '<img class="contact-header-avatar leadin-dynamic-avatar_' . substr($lead_id, -1) . '" height="76px" width="76px" src="https://app.getsignals.com/avatar/image/?emails=' . $lead_email . '"/>';
|
118 |
echo '<div class="contact-header-info">';
|
119 |
echo '<h1 class="contact-name">' . $lead_email . '</h1>';
|
120 |
-
echo '<
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
echo '</div>';
|
136 |
echo '</div>';
|
137 |
|
@@ -185,10 +302,9 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
185 |
else if ( $event['event_type'] == 'form' )
|
186 |
{
|
187 |
$submission = $event['activities'][0];
|
188 |
-
|
189 |
-
$form_fields = json_decode(stripslashes($submission['form_fields']));
|
190 |
$num_form_fieds = count($form_fields);
|
191 |
-
|
192 |
echo '<li class="event form-submission">';
|
193 |
echo '<div class="event-time">' . date('g:ia', strtotime($submission['event_date'])) . '</div>';
|
194 |
echo '<div class="event-content">';
|
@@ -200,7 +316,7 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
200 |
{
|
201 |
echo '<li class="field">';
|
202 |
echo '<label class="field-label">' . $field->label . ':</label>';
|
203 |
-
echo '<p class="field-value">' . $field->value . '</p>';
|
204 |
echo '</li>';
|
205 |
}
|
206 |
}
|
@@ -221,7 +337,6 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
221 |
echo '<div class="contact-info leadin-postbox">';
|
222 |
echo '<div class="leadin-postbox__content">';
|
223 |
echo '<p><b>Email:</b> <a href="mailto:' . $lead_email . '">' . $lead_email . '</a></p>';
|
224 |
-
echo '<p><b>Status:</b> ' . $li_contact->history->lead->lead_status . '</p>';
|
225 |
echo '<p><b>Original referrer:</b> ' . ( $li_contact->history->lead->lead_source ? '<a href="' . $li_contact->history->lead->lead_source . '">' . $lead_source . '</a></p>' : 'Direct' );
|
226 |
echo '<p><b>First visit:</b> ' . self::date_format_contact_stat($li_contact->history->lead->first_visit) . '</p>';
|
227 |
echo '<p><b>Last Visit:</b> ' . self::date_format_contact_stat($li_contact->history->lead->last_visit) . '</p>';
|
@@ -238,16 +353,248 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
238 |
echo '</div>';
|
239 |
}
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
/**
|
243 |
* Creates list table for Contacts page
|
244 |
*
|
245 |
*/
|
246 |
-
function
|
247 |
{
|
248 |
global $wp_version;
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
//Create an instance of our package class...
|
253 |
$leadinListTable = new LI_List_table();
|
@@ -310,6 +657,30 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
310 |
|
311 |
</div>
|
312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
<?php
|
314 |
$export_button_labels = $leadinListTable->view_label;
|
315 |
|
@@ -320,7 +691,7 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
320 |
<form id="export-form" class="leadin-contacts__export-form" name="export-form" method="POST">
|
321 |
<input type="submit" value="<?php esc_attr_e('Export All ' . $export_button_labels ); ?>" name="export-all" id="leadin-export-leads" class="button" <?php echo ( ! count($leadinListTable->data) ? 'disabled' : '' ); ?>>
|
322 |
<input type="submit" value="<?php esc_attr_e('Export Selected ' . $export_button_labels ); ?>" name="export-selected" id="leadin-export-selected-leads" class="button" disabled>
|
323 |
-
<input type="hidden"
|
324 |
</form>
|
325 |
|
326 |
</div>
|
@@ -338,39 +709,21 @@ class WPLeadInContactsAdmin extends WPLeadInAdmin {
|
|
338 |
{
|
339 |
global $wpdb;
|
340 |
|
341 |
-
$q = $wpdb->prepare("SELECT hashkey FROM li_leads WHERE lead_id = %d
|
342 |
$lead_hash = $wpdb->get_var($q);
|
343 |
|
344 |
-
$q = $wpdb->prepare("UPDATE li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey = %s AND pageview_deleted = 0
|
345 |
$delete_pageviews = $wpdb->query($q);
|
346 |
|
347 |
-
$q = $wpdb->prepare("UPDATE li_submissions SET form_deleted = 1 WHERE lead_hashkey = %s AND form_deleted = 0
|
348 |
$delete_submissions = $wpdb->query($q);
|
349 |
|
350 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_deleted = 1 WHERE lead_id = %d AND lead_deleted = 0
|
351 |
$delete_lead = $wpdb->query($q);
|
352 |
|
353 |
return $delete_lead;
|
354 |
}
|
355 |
|
356 |
-
/**
|
357 |
-
* Updates the contact status
|
358 |
-
*
|
359 |
-
* @param int
|
360 |
-
* @param string
|
361 |
-
* @return bool
|
362 |
-
*/
|
363 |
-
function update_contact_status ( $lead_id, $contact_status )
|
364 |
-
{
|
365 |
-
global $wpdb;
|
366 |
-
|
367 |
-
$q = $wpdb->prepare("UPDATE li_leads SET lead_status = %s WHERE lead_id = %d " . $wpdb->multisite_query, $contact_status, $lead_id);
|
368 |
-
$result = $wpdb->query($q);
|
369 |
-
|
370 |
-
return $result;
|
371 |
-
}
|
372 |
-
|
373 |
-
|
374 |
//=============================================
|
375 |
// Admin Styles & Scripts
|
376 |
//=============================================
|
@@ -429,7 +782,7 @@ if ( isset($_POST['export-all']) || isset($_POST['export-selected']) )
|
|
429 |
);
|
430 |
|
431 |
$fields = array(
|
432 |
-
'lead_email', 'lead_source', '
|
433 |
);
|
434 |
|
435 |
$headers = array();
|
@@ -439,7 +792,10 @@ if ( isset($_POST['export-all']) || isset($_POST['export-selected']) )
|
|
439 |
}
|
440 |
echo implode(',', $headers) . "\n";
|
441 |
|
442 |
-
$mysql_search_filter
|
|
|
|
|
|
|
443 |
|
444 |
// search filter
|
445 |
if ( isset($_GET['s']) )
|
@@ -448,67 +804,93 @@ if ( isset($_POST['export-all']) || isset($_POST['export-selected']) )
|
|
448 |
$mysql_search_filter = $wpdb->prepare(" AND ( l.lead_email LIKE '%%%s%%' OR l.lead_source LIKE '%%%s%%' ) ", like_escape($search_query), like_escape($search_query));
|
449 |
}
|
450 |
|
|
|
|
|
|
|
|
|
451 |
// contact type filter
|
452 |
if ( isset($_GET['contact_type']) )
|
453 |
{
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
}
|
460 |
|
461 |
-
// filter for visiting a specific page
|
462 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
463 |
{
|
464 |
-
|
465 |
-
$filtered_contacts = $wpdb->get_results($q);
|
466 |
-
|
467 |
-
if ( count($filtered_contacts) )
|
468 |
{
|
469 |
-
$
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
$mysql_search_filter = " AND l.hashkey IN ( " . $filtered_hashkeys . " ) ";
|
474 |
}
|
475 |
}
|
476 |
|
477 |
// filter for a form submitted on a specific page
|
478 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
479 |
{
|
480 |
-
$
|
481 |
-
$
|
|
|
|
|
|
|
|
|
482 |
|
483 |
-
$
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
$
|
488 |
-
}
|
|
|
|
|
489 |
|
490 |
-
$
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
|
513 |
foreach ( $leads as $contacts )
|
514 |
{
|
12 |
/**
|
13 |
* Class constructor
|
14 |
*/
|
15 |
+
var $action;
|
16 |
+
|
17 |
function __construct ()
|
18 |
{
|
19 |
//=============================================
|
50 |
{
|
51 |
global $wp_version;
|
52 |
|
53 |
+
$this->action = $this->leadin_current_action();
|
54 |
+
if ( $this->action == 'delete' )
|
55 |
{
|
56 |
$lead_id = ( isset($_GET['lead']) ? absint($_GET['lead']) : FALSE );
|
57 |
$this->delete_lead($lead_id);
|
58 |
}
|
59 |
|
60 |
+
if ( isset($_POST['tag_name']) )
|
61 |
+
{
|
62 |
+
$tag_id = ( isset($_POST['tag_id']) ? $_POST['tag_id'] : FALSE );
|
63 |
+
$tagger = new LI_Tag_Editor($tag_id);
|
64 |
+
|
65 |
+
$tag_name = $_POST['tag_name'];
|
66 |
+
$tag_form_selectors = '';
|
67 |
+
$tag_synced_lists = array();
|
68 |
+
|
69 |
+
foreach ( $_POST as $name => $value )
|
70 |
+
{
|
71 |
+
if ( strstr($name, 'email_form_tags_') )
|
72 |
+
{
|
73 |
+
$tag_selector = '';
|
74 |
+
if ( strstr($name, '_class') )
|
75 |
+
$tag_selector = str_replace('email_form_tags_class_', '.', $name);
|
76 |
+
else if ( strstr($name, '_id') )
|
77 |
+
$tag_selector = str_replace('email_form_tags_id_', '#', $name);
|
78 |
+
|
79 |
+
if ( $tag_selector )
|
80 |
+
{
|
81 |
+
if ( ! strstr($tag_form_selectors, $tag_selector) )
|
82 |
+
$tag_form_selectors .= $tag_selector . ',';
|
83 |
+
}
|
84 |
+
}
|
85 |
+
else if ( strstr($name, 'email_list_sync_') )
|
86 |
+
{
|
87 |
+
$synced_list = '';
|
88 |
+
if ( strstr($name, '_mailchimp') )
|
89 |
+
$synced_list = array('esp' => 'mailchimp', 'list_id' => str_replace('email_list_sync_mailchimp_', '', $name), 'list_name' => $value);
|
90 |
+
else if ( strstr($name, '_constant_contact') )
|
91 |
+
$synced_list = array('esp' => 'constant_contact', 'list_id' => str_replace('email_list_sync_constant_contact_', '', $name), 'list_name' => $value);
|
92 |
+
|
93 |
+
array_push($tag_synced_lists, $synced_list);
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
if ( $_POST['email_form_tags_custom'] )
|
98 |
+
{
|
99 |
+
if ( strstr($_POST['email_form_tags_custom'], ',') )
|
100 |
+
{
|
101 |
+
foreach ( explode(',', $_POST['email_form_tags_custom']) as $tag )
|
102 |
+
{
|
103 |
+
if ( ! strstr($tag_form_selectors, $tag) )
|
104 |
+
$tag_form_selectors .= $tag . ',';
|
105 |
+
}
|
106 |
+
}
|
107 |
+
else
|
108 |
+
{
|
109 |
+
if ( ! strstr($tag_form_selectors, $_POST['email_form_tags_custom']) )
|
110 |
+
$tag_form_selectors .= $_POST['email_form_tags_custom'] . ',';
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
// Sanitize the selectors by removing any spaces and any trailing commas
|
115 |
+
$tag_form_selectors = rtrim(str_replace(' ', '', $tag_form_selectors), ',');
|
116 |
+
|
117 |
+
if ( $tag_id )
|
118 |
+
{
|
119 |
+
$tagger->save_tag(
|
120 |
+
$tag_id,
|
121 |
+
$tag_name,
|
122 |
+
$tag_form_selectors,
|
123 |
+
serialize($tag_synced_lists)
|
124 |
+
);
|
125 |
+
}
|
126 |
+
else
|
127 |
+
{
|
128 |
+
$tagger->tag_id = $tagger->add_tag(
|
129 |
+
$tag_name,
|
130 |
+
$tag_form_selectors,
|
131 |
+
serialize($tag_synced_lists)
|
132 |
+
);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
echo '<div id="leadin" class="wrap '. ( $wp_version < 3.8 && !is_plugin_active('mp6/mp6.php') ? 'pre-mp6' : ''). '">';
|
137 |
|
138 |
+
if ( $this->action == 'manage_tags' || $this->action == 'delete_tag' ) {
|
139 |
+
leadin_track_plugin_activity("Loaded Tag List");
|
140 |
+
$this->leadin_render_tag_list_page();
|
141 |
+
}
|
142 |
+
else if ( $this->action == 'edit_tag' || $this->action == 'add_tag' ) {
|
143 |
+
leadin_track_plugin_activity("Loaded Tag Editor");
|
144 |
+
$this->leadin_render_tag_editor();
|
145 |
+
}
|
146 |
+
else if ( $this->action != 'view' ) {
|
147 |
leadin_track_plugin_activity("Loaded Contact List Page");
|
148 |
$this->leadin_render_list_page();
|
149 |
}
|
152 |
$this->leadin_render_contact_detail($_GET['lead']);
|
153 |
}
|
154 |
|
155 |
+
|
156 |
$this->leadin_footer();
|
157 |
|
158 |
echo '</div>';
|
180 |
*/
|
181 |
function leadin_render_contact_detail ( $lead_id )
|
182 |
{
|
|
|
|
|
|
|
|
|
|
|
183 |
$li_contact = new LI_Contact();
|
184 |
$li_contact->set_hashkey_by_id($lead_id);
|
185 |
$li_contact->get_contact_history();
|
|
|
186 |
$lead_email = $li_contact->history->lead->lead_email;
|
|
|
187 |
$lead_source = leadin_strip_params_from_url($li_contact->history->lead->lead_source);
|
188 |
|
189 |
+
if ( isset($_POST['edit_tags']) )
|
190 |
+
{
|
191 |
+
$updated_tags = array();
|
192 |
+
|
193 |
+
foreach ( $_POST as $name => $value )
|
194 |
+
{
|
195 |
+
if ( strstr($name, 'tag_slug_') )
|
196 |
+
{
|
197 |
+
array_push($updated_tags, $value);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
$li_contact->update_contact_tags($lead_id, $updated_tags);
|
202 |
+
$li_contact->history->tags = $li_contact->get_contact_tags($li_contact->hashkey);
|
203 |
+
}
|
204 |
+
|
205 |
if ( isset($_GET['post_id']) )
|
206 |
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?post=' . $_GET['post_id'] . '&action=edit#li_analytics-meta">← All Viewers</a>';
|
207 |
else if ( isset($_GET['stats_dashboard']) )
|
208 |
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_stats">← Stat Dashboard</a>';
|
209 |
else
|
210 |
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts">← All Contacts</a>';
|
211 |
+
|
212 |
echo '<div class="contact-header-wrap">';
|
213 |
echo '<img class="contact-header-avatar leadin-dynamic-avatar_' . substr($lead_id, -1) . '" height="76px" width="76px" src="https://app.getsignals.com/avatar/image/?emails=' . $lead_email . '"/>';
|
214 |
echo '<div class="contact-header-info">';
|
215 |
echo '<h1 class="contact-name">' . $lead_email . '</h1>';
|
216 |
+
echo '<div class="contact-tags">';
|
217 |
+
foreach( $li_contact->history->tags as $tag ) {
|
218 |
+
if ($tag->tag_set)
|
219 |
+
echo '<a class="contact-tag" href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&contact_type=' . $tag->tag_slug . '"><span class="icon-tag"></span>' . $tag->tag_text . '</a>';
|
220 |
+
}
|
221 |
+
?>
|
222 |
+
|
223 |
+
<?php add_thickbox(); ?>
|
224 |
+
<div id="edit-contact-tags" style="display:none;">
|
225 |
+
<h2>Edit Tags - <?php echo $li_contact->history->lead->lead_email; ?></h2>
|
226 |
+
<form id="edit_tags" action="" method="POST">
|
227 |
+
|
228 |
+
<?php
|
229 |
+
|
230 |
+
foreach( $li_contact->history->tags as $tag )
|
231 |
+
{
|
232 |
+
echo '<p>';
|
233 |
+
echo '<label for="tag_slug_' . $tag->tag_slug . '">';
|
234 |
+
echo '<input name="tag_slug_' . $tag->tag_slug . '" type="checkbox" id="tag_slug_' . $tag->tag_slug . '" value="' . $tag->tag_id . '" ' . ( $tag->tag_set ? ' checked' : '' ) . '>' . $tag->tag_text . '</label>';
|
235 |
+
echo '</p>';
|
236 |
+
}
|
237 |
+
|
238 |
+
?>
|
239 |
+
|
240 |
+
<input type="hidden" name="edit_tags" value="1"/>
|
241 |
+
<p class="submit">
|
242 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Tags">
|
243 |
+
</p>
|
244 |
+
</form>
|
245 |
+
</div>
|
246 |
+
|
247 |
+
<a class="thickbox contact-edit-tags" href="#TB_inline?width=400&height=400&inlineId=edit-contact-tags">edit tags</a>
|
248 |
+
|
249 |
+
<?php
|
250 |
+
|
251 |
+
echo '</div>';
|
252 |
echo '</div>';
|
253 |
echo '</div>';
|
254 |
|
302 |
else if ( $event['event_type'] == 'form' )
|
303 |
{
|
304 |
$submission = $event['activities'][0];
|
305 |
+
$form_fields = json_decode($submission['form_fields']);
|
|
|
306 |
$num_form_fieds = count($form_fields);
|
307 |
+
|
308 |
echo '<li class="event form-submission">';
|
309 |
echo '<div class="event-time">' . date('g:ia', strtotime($submission['event_date'])) . '</div>';
|
310 |
echo '<div class="event-content">';
|
316 |
{
|
317 |
echo '<li class="field">';
|
318 |
echo '<label class="field-label">' . $field->label . ':</label>';
|
319 |
+
echo '<p class="field-value">' . nl2br($field->value) . '</p>';
|
320 |
echo '</li>';
|
321 |
}
|
322 |
}
|
337 |
echo '<div class="contact-info leadin-postbox">';
|
338 |
echo '<div class="leadin-postbox__content">';
|
339 |
echo '<p><b>Email:</b> <a href="mailto:' . $lead_email . '">' . $lead_email . '</a></p>';
|
|
|
340 |
echo '<p><b>Original referrer:</b> ' . ( $li_contact->history->lead->lead_source ? '<a href="' . $li_contact->history->lead->lead_source . '">' . $lead_source . '</a></p>' : 'Direct' );
|
341 |
echo '<p><b>First visit:</b> ' . self::date_format_contact_stat($li_contact->history->lead->first_visit) . '</p>';
|
342 |
echo '<p><b>Last Visit:</b> ' . self::date_format_contact_stat($li_contact->history->lead->last_visit) . '</p>';
|
353 |
echo '</div>';
|
354 |
}
|
355 |
|
356 |
+
/**
|
357 |
+
* Creates list table for Contacts page
|
358 |
+
*
|
359 |
+
*/
|
360 |
+
function leadin_render_tag_editor ()
|
361 |
+
{
|
362 |
+
?>
|
363 |
+
<div class="leadin-contacts">
|
364 |
+
<?php
|
365 |
+
|
366 |
+
if ( $this->action == 'edit_tag' || $this->action == 'add_tag' )
|
367 |
+
{
|
368 |
+
$tag_id = ( isset($_GET['tag']) ? $_GET['tag'] : FALSE);
|
369 |
+
$tagger = new LI_Tag_Editor($tag_id);
|
370 |
+
}
|
371 |
+
|
372 |
+
if ( $tagger->tag_id )
|
373 |
+
$tagger->get_tag_details($tagger->tag_id);
|
374 |
+
|
375 |
+
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=manage_tags">← Manage tags</a>';
|
376 |
+
$this->leadin_header(( $this->action == 'edit_tag' ? 'Edit a tag' : 'Add a tag' ), 'leadin-contacts__header');
|
377 |
+
?>
|
378 |
+
|
379 |
+
<div class="">
|
380 |
+
<form id="leadin-tag-settings" action="<?php echo get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=manage_tags'; ?>" method="POST">
|
381 |
+
|
382 |
+
<table class="form-table"><tbody>
|
383 |
+
<tr>
|
384 |
+
<th scope="row"><label for="tag_name">Tag name</label></th>
|
385 |
+
<td><input name="tag_name" type="text" id="tag_name" value="<?php echo ( isset($tagger->details->tag_text) ? $tagger->details->tag_text : '' ); ?>" class="regular-text" placeholder="Tag Name"></td>
|
386 |
+
</tr>
|
387 |
+
|
388 |
+
<tr>
|
389 |
+
<th scope="row">Automatically tag contacts who fill out any of these forms</th>
|
390 |
+
<td>
|
391 |
+
<fieldset>
|
392 |
+
<legend class="screen-reader-text"><span>Automatically tag contacts who fill out any of these forms</span></legend>
|
393 |
+
<?php
|
394 |
+
$tag_form_selectors = ( isset($tagger->details->tag_form_selectors) ? explode(',', str_replace(' ', '', $tagger->details->tag_form_selectors)) : '');
|
395 |
+
|
396 |
+
foreach ( $tagger->selectors as $selector )
|
397 |
+
{
|
398 |
+
$html_id = 'email_form_tags_' . str_replace(array('#', '.'), array('id_', 'class_'), $selector);
|
399 |
+
$selector_set = FALSE;
|
400 |
+
|
401 |
+
if ( isset($tagger->details->tag_form_selectors) && strstr($tagger->details->tag_form_selectors, $selector) )
|
402 |
+
{
|
403 |
+
$selector_set = TRUE;
|
404 |
+
$key = array_search($selector, $tag_form_selectors);
|
405 |
+
if ( $key !== FALSE )
|
406 |
+
unset($tag_form_selectors[$key]);
|
407 |
+
}
|
408 |
+
|
409 |
+
echo '<label for="' . $html_id . '">';
|
410 |
+
echo '<input name="' . $html_id . '" type="checkbox" id="' . $html_id . '" value="" ' . ( $selector_set ? 'checked' : '' ) . '>';
|
411 |
+
echo $selector;
|
412 |
+
echo '</label><br>';
|
413 |
+
}
|
414 |
+
?>
|
415 |
+
</fieldset>
|
416 |
+
<br>
|
417 |
+
<input name="email_form_tags_custom" type="text" value="<?php echo ( $tag_form_selectors ? implode(', ', $tag_form_selectors) : ''); ?>" class="regular-text" placeholder="#form-id, .form-class">
|
418 |
+
<p class="description">Include additional form's css selectors.</p>
|
419 |
+
</td>
|
420 |
+
</tr>
|
421 |
+
|
422 |
+
|
423 |
+
<?php
|
424 |
+
$esp_power_ups = array(
|
425 |
+
'MailChimp' => 'mailchimp_list_sync',
|
426 |
+
'Constant Contact' => 'constant_contact_list_sync',
|
427 |
+
'AWeber' => 'aweber_list_sync',
|
428 |
+
'GetResponse' => 'getresponse_list_sync',
|
429 |
+
'MailPoet' => 'mailpoet_list_sync',
|
430 |
+
'Campaign Monitor' => 'campaign_monitor_list_sync'
|
431 |
+
);
|
432 |
+
|
433 |
+
foreach ( $esp_power_ups as $power_up_name => $power_up_slug )
|
434 |
+
{
|
435 |
+
if ( WPLeadIn::is_power_up_active($power_up_slug) )
|
436 |
+
{
|
437 |
+
global ${'leadin_' . $power_up_slug . '_wp'}; // e.g leadin_mailchimp_list_sync_wp
|
438 |
+
$esp_name = strtolower(str_replace('_list_sync', '', $power_up_slug)); // e.g. mailchimp
|
439 |
+
$lists = ${'leadin_' . $power_up_slug . '_wp'}->admin->li_get_lists();
|
440 |
+
$synced_lists = ( isset($tagger->details->tag_synced_lists) ? unserialize($tagger->details->tag_synced_lists) : '' );
|
441 |
+
|
442 |
+
echo '<tr>';
|
443 |
+
echo '<th scope="row">Sync tagged contacts with these ' . $power_up_name . ' lists</th>';
|
444 |
+
echo '<td>';
|
445 |
+
echo '<fieldset>';
|
446 |
+
echo '<legend class="screen-reader-text"><span>Sync tagged contacts to with these ' . $power_up_name . ' email lists</span></legend>';
|
447 |
+
//
|
448 |
+
$esp_name_readable = ucwords(str_replace('_', ' ', $esp_name));
|
449 |
+
$esp_url = str_replace('_', '', $esp_name) . '.com';
|
450 |
+
|
451 |
+
switch ( $esp_name )
|
452 |
+
{
|
453 |
+
case 'mailchimp' :
|
454 |
+
$esp_list_url = 'http://admin.mailchimp.com/lists/new-list/';
|
455 |
+
$settings_page_anchor_id = '#li_mls_api_key';
|
456 |
+
break;
|
457 |
+
|
458 |
+
case 'constant_contact' :
|
459 |
+
$esp_list_url = 'https://login.constantcontact.com/login/login.sdo?goto=https://ui.constantcontact.com/rnavmap/distui/contacts';
|
460 |
+
$settings_page_anchor_id = '#li_cc_email';
|
461 |
+
break;
|
462 |
+
|
463 |
+
default:
|
464 |
+
$esp_list_url = '';
|
465 |
+
$settings_page_anchor_id = '';
|
466 |
+
break;
|
467 |
+
}
|
468 |
+
|
469 |
+
if ( ! ${'leadin_' . $power_up_slug . '_wp'}->admin->authed )
|
470 |
+
{
|
471 |
+
echo 'It looks like you haven\'t setup your ' . $esp_name_readable . ' integration yet...<br/><br/>';
|
472 |
+
echo '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_settings' . $settings_page_anchor_id . '">Setup your ' . $esp_name_readable . ' integration</a>';
|
473 |
+
}
|
474 |
+
else if ( count($lists) )
|
475 |
+
{
|
476 |
+
foreach ( $lists as $list )
|
477 |
+
{
|
478 |
+
$list_id = $list->id;
|
479 |
+
|
480 |
+
// Hack for constant contact's list id string (e.g. http://api.constantcontact.com/ws/customers/name%40website.com/lists/1234567890)
|
481 |
+
if ( $power_up_name == 'Constant Contact' )
|
482 |
+
$list_id = end(explode('/', $list_id));
|
483 |
+
|
484 |
+
$html_id = 'email_list_sync_' . $esp_name . '_' . $list_id;
|
485 |
+
$synced = FALSE;
|
486 |
+
|
487 |
+
if ( $synced_lists )
|
488 |
+
{
|
489 |
+
$key = leadin_array_search_deep($list_id, $synced_lists, 'list_id');
|
490 |
+
|
491 |
+
if ( isset($key) )
|
492 |
+
{
|
493 |
+
if ( $synced_lists[$key]['esp'] == $esp_name )
|
494 |
+
$synced = TRUE;
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
echo '<label for="' . $html_id . '">';
|
499 |
+
echo '<input name="' . $html_id . '" type="checkbox" id="' . $html_id . '" value="' . $list->name . '" ' . ( $synced ? 'checked' : '' ) . '>';
|
500 |
+
echo $list->name;
|
501 |
+
echo '</label><br>';
|
502 |
+
}
|
503 |
+
}
|
504 |
+
else
|
505 |
+
{
|
506 |
+
echo 'It looks like you don\'t have any ' . $esp_name_readable . 'lists yet...<br/><br/>';
|
507 |
+
echo '<a href="' . $esp_list_url . '" target="_blank">Create a list on ' . $esp_url . '.com</a>';
|
508 |
+
}
|
509 |
+
echo '</fieldset>';
|
510 |
+
echo '</td>';
|
511 |
+
echo '</tr>';
|
512 |
+
}
|
513 |
+
}
|
514 |
+
?>
|
515 |
+
|
516 |
+
</tbody></table>
|
517 |
+
<input type="hidden" name="tag_id" value="<?php echo $tag_id; ?>"/>
|
518 |
+
<p class="submit">
|
519 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes">
|
520 |
+
</p>
|
521 |
+
</form>
|
522 |
+
</div>
|
523 |
+
|
524 |
+
</div>
|
525 |
+
|
526 |
+
<?php
|
527 |
+
}
|
528 |
|
529 |
/**
|
530 |
* Creates list table for Contacts page
|
531 |
*
|
532 |
*/
|
533 |
+
function leadin_render_tag_list_page ()
|
534 |
{
|
535 |
global $wp_version;
|
536 |
|
537 |
+
if ( $this->action == 'delete_tag')
|
538 |
+
{
|
539 |
+
$tag_id = ( isset($_GET['tag']) ? $_GET['tag'] : FALSE);
|
540 |
+
$tagger = new LI_Tag_Editor($tag_id);
|
541 |
+
$tagger->delete_tag($tag_id);
|
542 |
+
}
|
543 |
+
|
544 |
+
//Create an instance of our package class...
|
545 |
+
$leadinTagsTable = new LI_Tags_Table();
|
546 |
+
|
547 |
+
// Process any bulk actions before the contacts are grabbed from the database
|
548 |
+
$leadinTagsTable->process_bulk_action();
|
549 |
+
|
550 |
+
//Fetch, prepare, sort, and filter our data...
|
551 |
+
$leadinTagsTable->data = $leadinTagsTable->get_tags();
|
552 |
+
$leadinTagsTable->prepare_items();
|
553 |
+
|
554 |
+
?>
|
555 |
+
<div class="leadin-contacts">
|
556 |
+
|
557 |
+
<?php
|
558 |
+
$this->leadin_header('Manage LeadIn Tags <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=add_tag" class="add-new-h2">Add New</a>', 'leadin-contacts__header');
|
559 |
+
?>
|
560 |
+
|
561 |
+
<div class="">
|
562 |
|
563 |
+
<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
|
564 |
+
<form id="" method="GET">
|
565 |
+
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
566 |
+
|
567 |
+
<div class="leadin-contacts__table">
|
568 |
+
<?php $leadinTagsTable->display(); ?>
|
569 |
+
</div>
|
570 |
+
|
571 |
+
<input type="hidden" name="contact_type" value="<?php echo ( isset($_GET['contact_type']) ? $_GET['contact_type'] : '' ); ?>"/>
|
572 |
+
|
573 |
+
<?php if ( isset($_GET['filter_content']) ) : ?>
|
574 |
+
<input type="hidden" name="filter_content" value="<?php echo ( isset($_GET['filter_content']) ? stripslashes($_GET['filter_content']) : '' ); ?>"/>
|
575 |
+
<?php endif; ?>
|
576 |
+
|
577 |
+
<?php if ( isset($_GET['filter_action']) ) : ?>
|
578 |
+
<input type="hidden" name="filter_action" value="<?php echo ( isset($_GET['filter_action']) ? $_GET['filter_action'] : '' ); ?>"/>
|
579 |
+
<?php endif; ?>
|
580 |
+
|
581 |
+
</form>
|
582 |
+
|
583 |
+
</div>
|
584 |
+
|
585 |
+
</div>
|
586 |
+
|
587 |
+
<?php
|
588 |
+
}
|
589 |
+
|
590 |
+
|
591 |
+
/**
|
592 |
+
* Creates list table for Contacts page
|
593 |
+
*
|
594 |
+
*/
|
595 |
+
function leadin_render_list_page ()
|
596 |
+
{
|
597 |
+
global $wp_version;
|
598 |
|
599 |
//Create an instance of our package class...
|
600 |
$leadinListTable = new LI_List_table();
|
657 |
|
658 |
</div>
|
659 |
|
660 |
+
<?php add_thickbox(); ?>
|
661 |
+
<div id="bulk-edit-tags" style="display:none;">
|
662 |
+
<h2>Select a tag to add to <span class="selected-contacts-count"></span> <?php echo strtolower($leadinListTable->view_label); ?></h2>
|
663 |
+
<form id="bulk-edit-tags-form" action="" method="POST">
|
664 |
+
<?php
|
665 |
+
if ( count($leadinListTable->tags) )
|
666 |
+
{
|
667 |
+
echo '<select name="bulk_selected_tag">';
|
668 |
+
foreach( $leadinListTable->tags as $tag )
|
669 |
+
echo '<option value="' . $tag->tag_slug . '">' . $tag->tag_text . '</option>';
|
670 |
+
echo '</select>';
|
671 |
+
}
|
672 |
+
?>
|
673 |
+
|
674 |
+
<input type="hidden" name="bulk_edit_tags" value="1"/>
|
675 |
+
<input type="hidden" id="bulk-edit-tag-action" name="bulk_edit_tag_action" value=""/>
|
676 |
+
<input type="hidden" class="leadin-selected-contacts" name="leadin_selected_contacts" value=""/>
|
677 |
+
|
678 |
+
<p class="submit">
|
679 |
+
<input id="bulk-edit-button" type="submit" name="submit" id="submit" class="button button-primary" value="Add Tag">
|
680 |
+
</p>
|
681 |
+
</form>
|
682 |
+
</div>
|
683 |
+
|
684 |
<?php
|
685 |
$export_button_labels = $leadinListTable->view_label;
|
686 |
|
691 |
<form id="export-form" class="leadin-contacts__export-form" name="export-form" method="POST">
|
692 |
<input type="submit" value="<?php esc_attr_e('Export All ' . $export_button_labels ); ?>" name="export-all" id="leadin-export-leads" class="button" <?php echo ( ! count($leadinListTable->data) ? 'disabled' : '' ); ?>>
|
693 |
<input type="submit" value="<?php esc_attr_e('Export Selected ' . $export_button_labels ); ?>" name="export-selected" id="leadin-export-selected-leads" class="button" disabled>
|
694 |
+
<input type="hidden" class="leadin-selected-contacts" name="leadin_selected_contacts" value=""/>
|
695 |
</form>
|
696 |
|
697 |
</div>
|
709 |
{
|
710 |
global $wpdb;
|
711 |
|
712 |
+
$q = $wpdb->prepare("SELECT hashkey FROM $wpdb->li_leads WHERE lead_id = %d", $lead_id);
|
713 |
$lead_hash = $wpdb->get_var($q);
|
714 |
|
715 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_pageviews SET pageview_deleted = 1 WHERE lead_hashkey = %s AND pageview_deleted = 0", $lead_hash);
|
716 |
$delete_pageviews = $wpdb->query($q);
|
717 |
|
718 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_submissions SET form_deleted = 1 WHERE lead_hashkey = %s AND form_deleted = 0", $lead_hash);
|
719 |
$delete_submissions = $wpdb->query($q);
|
720 |
|
721 |
+
$q = $wpdb->prepare("UPDATE $wpdb->li_leads SET lead_deleted = 1 WHERE lead_id = %d AND lead_deleted = 0", $lead_id);
|
722 |
$delete_lead = $wpdb->query($q);
|
723 |
|
724 |
return $delete_lead;
|
725 |
}
|
726 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
727 |
//=============================================
|
728 |
// Admin Styles & Scripts
|
729 |
//=============================================
|
782 |
);
|
783 |
|
784 |
$fields = array(
|
785 |
+
'lead_email', 'lead_source', 'visits', 'lead_pageviews', 'lead_form_submissions', 'last_visit', 'lead_date'
|
786 |
);
|
787 |
|
788 |
$headers = array();
|
792 |
}
|
793 |
echo implode(',', $headers) . "\n";
|
794 |
|
795 |
+
$mysql_search_filter = '';
|
796 |
+
$mysql_contact_type_filter = '';
|
797 |
+
$mysql_action_filter = '';
|
798 |
+
$filter_action_set = FALSE;
|
799 |
|
800 |
// search filter
|
801 |
if ( isset($_GET['s']) )
|
804 |
$mysql_search_filter = $wpdb->prepare(" AND ( l.lead_email LIKE '%%%s%%' OR l.lead_source LIKE '%%%s%%' ) ", like_escape($search_query), like_escape($search_query));
|
805 |
}
|
806 |
|
807 |
+
// @TODO - need to modify the filters to pull down the form ID types
|
808 |
+
|
809 |
+
$filtered_contacts = array();
|
810 |
+
|
811 |
// contact type filter
|
812 |
if ( isset($_GET['contact_type']) )
|
813 |
{
|
814 |
+
// Query for the tag_id, then find all hashkeys with that tag ID tied to them. Use those hashkeys to modify the query
|
815 |
+
$q = $wpdb->prepare("
|
816 |
+
SELECT
|
817 |
+
DISTINCT ltr.contact_hashkey as lead_hashkey
|
818 |
+
FROM
|
819 |
+
$wpdb->li_tag_relationships ltr, $wpdb->li_tags lt
|
820 |
+
WHERE
|
821 |
+
lt.tag_id = ltr.tag_id AND
|
822 |
+
ltr.tag_relationship_deleted = 0 AND
|
823 |
+
lt.tag_slug = %s GROUP BY ltr.contact_hashkey", $_GET['contact_type']);
|
824 |
+
|
825 |
+
$filtered_contacts = $wpdb->get_results($q, 'ARRAY_A');
|
826 |
+
$num_contacts = count($filtered_contacts);
|
827 |
}
|
828 |
|
|
|
829 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'visited' )
|
830 |
{
|
831 |
+
if ( isset($_GET['filter_content']) && $_GET['filter_content'] != 'any page' )
|
|
|
|
|
|
|
832 |
{
|
833 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM $wpdb->li_pageviews WHERE pageview_title LIKE '%%%s%%' GROUP BY lead_hashkey", htmlspecialchars(urldecode($_GET['filter_content'])));
|
834 |
+
$filtered_contacts = leadin_merge_filtered_contacts($wpdb->get_results($q, 'ARRAY_A'), $filtered_contacts);
|
835 |
+
$filter_action_set = TRUE;
|
|
|
|
|
836 |
}
|
837 |
}
|
838 |
|
839 |
// filter for a form submitted on a specific page
|
840 |
if ( isset($_GET['filter_action']) && $_GET['filter_action'] == 'submitted' )
|
841 |
{
|
842 |
+
$filter_form = '';
|
843 |
+
if ( isset($_GET['filter_form']) && $_GET['filter_form'] && $_GET['filter_form'] != 'any form' )
|
844 |
+
{
|
845 |
+
$filter_form = str_replace(array('#', '.'), '', htmlspecialchars(urldecode($_GET['filter_form'])));
|
846 |
+
$filter_form_query = $wpdb->prepare(" AND ( form_selector_id LIKE '%%%s%%' OR form_selector_classes LIKE '%%%s%%' )", $filter_form, $filter_form);
|
847 |
+
}
|
848 |
|
849 |
+
$q = $wpdb->prepare("SELECT lead_hashkey FROM $wpdb->li_submissions WHERE form_page_title LIKE '%%%s%%' ", ( $_GET['filter_content'] != 'any page' ? htmlspecialchars(urldecode($_GET['filter_content'])): '' ));
|
850 |
+
$q .= ( $filter_form_query ? $filter_form_query : '' );
|
851 |
+
$q .= " GROUP BY lead_hashkey";
|
852 |
+
$filtered_contacts = leadin_merge_filtered_contacts($wpdb->get_results($q, 'ARRAY_A'), $filtered_contacts);
|
853 |
+
$filter_action_set = TRUE;
|
854 |
+
}
|
855 |
+
|
856 |
+
$filtered_hashkeys = leadin_explode_filtered_contacts($filtered_contacts);
|
857 |
|
858 |
+
$mysql_action_filter = '';
|
859 |
+
if ( $filter_action_set ) // If a filter action is set and there are no contacts, do a blank
|
860 |
+
$mysql_action_filter = " AND l.hashkey IN ( " . ( $filtered_hashkeys ? $filtered_hashkeys : "''" ) . " ) ";
|
861 |
+
else
|
862 |
+
$mysql_action_filter = ( $filtered_hashkeys ? " AND l.hashkey IN ( " . $filtered_hashkeys . " ) " : '' ); // If a filter action isn't set, use the filtered hashkeys if they exist, else, don't include the statement
|
863 |
+
|
864 |
+
// There's a filter and leads are in it
|
865 |
+
if ( ( isset($_GET['contact_type']) && $num_contacts ) || ! isset($_GET['contact_type']) )
|
866 |
+
{
|
867 |
+
$q = $wpdb->prepare("
|
868 |
+
SELECT
|
869 |
+
l.lead_id AS lead_id,
|
870 |
+
LOWER(DATE_FORMAT(l.lead_date, %s)) AS lead_date, l.lead_ip, l.lead_source, l.lead_email, l.hashkey,
|
871 |
+
COUNT(DISTINCT s.form_id) AS lead_form_submissions,
|
872 |
+
COUNT(DISTINCT p.pageview_id) AS lead_pageviews,
|
873 |
+
LOWER(DATE_FORMAT(MAX(p.pageview_date), %s)) AS last_visit,
|
874 |
+
( SELECT COUNT(DISTINCT pageview_id) FROM $wpdb->li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS visits,
|
875 |
+
( SELECT MAX(pageview_source) AS pageview_source FROM $wpdb->li_pageviews WHERE lead_hashkey = l.hashkey AND pageview_session_start = 1 AND pageview_deleted = 0 ) AS pageview_source
|
876 |
+
FROM
|
877 |
+
$wpdb->li_leads l
|
878 |
+
LEFT JOIN $wpdb->li_submissions s ON l.hashkey = s.lead_hashkey
|
879 |
+
LEFT JOIN $wpdb->li_pageviews p ON l.hashkey = p.lead_hashkey
|
880 |
+
WHERE l.lead_email != '' AND l.lead_deleted = 0 " .
|
881 |
+
( isset ($_POST['export-selected']) ? " AND l.lead_id IN ( " . $_POST['leadin_selected_contacts'] . " ) " : "" ) .
|
882 |
+
" AND l.hashkey != '' ", '%Y/%m/%d %l:%i%p', '%Y/%m/%d %l:%i%p');
|
883 |
+
|
884 |
+
$q .= $mysql_contact_type_filter;
|
885 |
+
$q .= ( $mysql_search_filter ? $mysql_search_filter : "" );
|
886 |
+
$q .= ( $mysql_action_filter ? $mysql_action_filter : "" );
|
887 |
+
$q .= " GROUP BY l.hashkey";
|
888 |
+
$leads = $wpdb->get_results($q);
|
889 |
+
}
|
890 |
+
else
|
891 |
+
{
|
892 |
+
$leads = array();
|
893 |
+
}
|
894 |
|
895 |
foreach ( $leads as $contacts )
|
896 |
{
|
power-ups/mailchimp-list-sync.php
CHANGED
@@ -79,17 +79,24 @@ class WPMailChimpListSync extends WPLeadIn {
|
|
79 |
|
80 |
}
|
81 |
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
{
|
84 |
-
$options
|
85 |
-
|
86 |
-
if ( isset($options['li_mls_api_key']) && $options['li_mls_api_key'] && isset($options['li_mls_subscribers_to_list']) && $options['li_mls_subscribers_to_list'] )
|
87 |
{
|
88 |
-
$MailChimp = new LI_MailChimp($options['li_mls_api_key']);
|
89 |
-
|
90 |
-
|
91 |
-
"
|
92 |
-
"email" => array( 'email' => $email),
|
93 |
"send_welcome" => FALSE,
|
94 |
"email_type" => 'html',
|
95 |
"update_existing" => TRUE,
|
@@ -102,7 +109,37 @@ class WPMailChimpListSync extends WPLeadIn {
|
|
102 |
'PHONE' => $phone
|
103 |
)
|
104 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
|
|
|
|
106 |
}
|
107 |
}
|
108 |
|
79 |
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Adds a subcsriber to a specific list
|
84 |
+
*
|
85 |
+
* @param string
|
86 |
+
* @param string
|
87 |
+
* @param string
|
88 |
+
* @param string
|
89 |
+
* @param string
|
90 |
+
* @return int/bool API status code OR false if api key not set
|
91 |
+
*/
|
92 |
+
function push_contact_to_list ( $list_id = '', $email = '', $first_name = '', $last_name = '', $phone = '' )
|
93 |
{
|
94 |
+
if ( isset($this->options['li_mls_api_key']) && $this->options['li_mls_api_key'] && $list_id )
|
|
|
|
|
95 |
{
|
96 |
+
$MailChimp = new LI_MailChimp($this->options['li_mls_api_key']);
|
97 |
+
$contact_synced = $MailChimp->call("lists/subscribe", array(
|
98 |
+
"id" => $list_id,
|
99 |
+
"email" => array('email' => $email),
|
|
|
100 |
"send_welcome" => FALSE,
|
101 |
"email_type" => 'html',
|
102 |
"update_existing" => TRUE,
|
109 |
'PHONE' => $phone
|
110 |
)
|
111 |
));
|
112 |
+
|
113 |
+
return $contact_synced;
|
114 |
+
}
|
115 |
+
|
116 |
+
return FALSE;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Removes an email address from a specific list
|
121 |
+
*
|
122 |
+
* @param string
|
123 |
+
* @param string
|
124 |
+
* @return int/bool API status code OR false if api key not set
|
125 |
+
*/
|
126 |
+
function remove_contact_from_list ( $list_id = '', $email = '' )
|
127 |
+
{
|
128 |
+
if ( isset($this->options['li_mls_api_key']) && $this->options['li_mls_api_key'] && $list_id )
|
129 |
+
{
|
130 |
+
$MailChimp = new LI_MailChimp($this->options['li_mls_api_key']);
|
131 |
+
$contact_removed = $MailChimp->call("lists/unsubscribe ", array(
|
132 |
+
"id" => $list_id,
|
133 |
+
"email" => array('email' => $email),
|
134 |
+
"delete_member" => TRUE,
|
135 |
+
"send_goodbye" => FALSE,
|
136 |
+
"send_notify" => FALSE
|
137 |
+
));
|
138 |
+
|
139 |
+
return $contact_removed;
|
140 |
}
|
141 |
+
|
142 |
+
return FALSE;
|
143 |
}
|
144 |
}
|
145 |
|
power-ups/mailchimp-list-sync/admin/mailchimp-list-sync-admin.php
CHANGED
@@ -6,6 +6,8 @@ class WPMailChimpListSyncAdmin extends WPLeadInAdmin {
|
|
6 |
|
7 |
var $power_up_settings_section = 'leadin_mls_options_section';
|
8 |
var $power_up_icon;
|
|
|
|
|
9 |
|
10 |
/**
|
11 |
* Class constructor
|
@@ -20,6 +22,8 @@ class WPMailChimpListSyncAdmin extends WPLeadInAdmin {
|
|
20 |
{
|
21 |
$this->power_up_icon = $power_up_icon_small;
|
22 |
add_action('admin_init', array($this, 'leadin_mls_build_settings_page'));
|
|
|
|
|
23 |
}
|
24 |
}
|
25 |
|
@@ -32,14 +36,12 @@ class WPMailChimpListSyncAdmin extends WPLeadInAdmin {
|
|
32 |
*/
|
33 |
function leadin_mls_build_settings_page ()
|
34 |
{
|
35 |
-
$options = get_option('leadin_mls_options');
|
36 |
-
|
37 |
register_setting('leadin_settings_options', 'leadin_mls_options', array($this, 'sanitize'));
|
38 |
add_settings_section($this->power_up_settings_section, $this->power_up_icon . "MailChimp", '', LEADIN_ADMIN_PATH);
|
39 |
add_settings_field('li_mls_api_key', 'API key', array($this, 'li_mls_api_key_callback'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
40 |
-
|
41 |
-
if ( isset($options['li_mls_api_key'])
|
42 |
-
add_settings_field('
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -65,15 +67,68 @@ class WPMailChimpListSyncAdmin extends WPLeadInAdmin {
|
|
65 |
*/
|
66 |
function li_mls_api_key_callback ()
|
67 |
{
|
68 |
-
$
|
69 |
-
$li_mls_api_key = ( $options['li_mls_api_key'] ? $options['li_mls_api_key'] : '' ); // Get header from options, or show default
|
70 |
|
71 |
printf(
|
72 |
'<input id="li_mls_api_key" type="text" id="title" name="leadin_mls_options[li_mls_api_key]" value="%s" size="50"/>',
|
73 |
$li_mls_api_key
|
74 |
);
|
75 |
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
|
79 |
/**
|
@@ -81,10 +136,9 @@ class WPMailChimpListSyncAdmin extends WPLeadInAdmin {
|
|
81 |
*/
|
82 |
function li_mls_subscribers_to_list_callback ()
|
83 |
{
|
84 |
-
$
|
85 |
-
$li_mls_subscribers_to_list = ( isset($options['li_mls_subscribers_to_list']) ? $options['li_mls_subscribers_to_list'] : '' );
|
86 |
|
87 |
-
$lists = $this->li_mls_get_mailchimp_lists($options['li_mls_api_key']);
|
88 |
|
89 |
echo '<select id="li_mls_subscribers_to_list" name="leadin_mls_options[li_mls_subscribers_to_list]" ' . ( ! count($lists['data']) ? 'disabled' : '' ) . '>';
|
90 |
|
@@ -113,6 +167,23 @@ class WPMailChimpListSyncAdmin extends WPLeadInAdmin {
|
|
113 |
echo '<p><a href="http://admin.mailchimp.com/lists/new-list/" target="_blank">Create a new list on MailChimp.com</a></p>';
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
function li_mls_get_mailchimp_lists ( $api_key )
|
117 |
{
|
118 |
$MailChimp = new LI_MailChimp($api_key);
|
6 |
|
7 |
var $power_up_settings_section = 'leadin_mls_options_section';
|
8 |
var $power_up_icon;
|
9 |
+
var $options;
|
10 |
+
var $authed = FALSE;
|
11 |
|
12 |
/**
|
13 |
* Class constructor
|
22 |
{
|
23 |
$this->power_up_icon = $power_up_icon_small;
|
24 |
add_action('admin_init', array($this, 'leadin_mls_build_settings_page'));
|
25 |
+
$this->options = get_option('leadin_mls_options');
|
26 |
+
$this->authed = ( $this->options['li_mls_api_key'] ? TRUE : FALSE );
|
27 |
}
|
28 |
}
|
29 |
|
36 |
*/
|
37 |
function leadin_mls_build_settings_page ()
|
38 |
{
|
|
|
|
|
39 |
register_setting('leadin_settings_options', 'leadin_mls_options', array($this, 'sanitize'));
|
40 |
add_settings_section($this->power_up_settings_section, $this->power_up_icon . "MailChimp", '', LEADIN_ADMIN_PATH);
|
41 |
add_settings_field('li_mls_api_key', 'API key', array($this, 'li_mls_api_key_callback'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
42 |
+
|
43 |
+
if ( isset($this->options['li_mls_api_key']) )
|
44 |
+
add_settings_field('li_print_synced_lists', 'Synced tags', array($this, 'li_print_synced_lists'), LEADIN_ADMIN_PATH, $this->power_up_settings_section);
|
45 |
}
|
46 |
|
47 |
/**
|
67 |
*/
|
68 |
function li_mls_api_key_callback ()
|
69 |
{
|
70 |
+
$li_mls_api_key = ( $this->options['li_mls_api_key'] ? $this->options['li_mls_api_key'] : '' ); // Get header from options, or show default
|
|
|
71 |
|
72 |
printf(
|
73 |
'<input id="li_mls_api_key" type="text" id="title" name="leadin_mls_options[li_mls_api_key]" value="%s" size="50"/>',
|
74 |
$li_mls_api_key
|
75 |
);
|
76 |
|
77 |
+
if ( ! isset($li_mls_api_key) )
|
78 |
+
echo '<p><a href="http://admin.mailchimp.com/account/api/" target="_blank">Get an API key from MailChimp.com</a></p>';
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Prints email input for settings page
|
83 |
+
*/
|
84 |
+
function li_print_synced_lists ()
|
85 |
+
{
|
86 |
+
$li_mls_api_key = ( $this->options['li_mls_api_key'] ? $this->options['li_mls_api_key'] : '' ); // Get header from options, or show default
|
87 |
+
|
88 |
+
if ( isset($li_mls_api_key ) )
|
89 |
+
{
|
90 |
+
$synced_lists = $this->li_get_synced_list_for_esp('mailchimp');
|
91 |
+
$list_value_pairs = array();
|
92 |
+
$synced_list_count = 0;
|
93 |
+
|
94 |
+
echo '<table>';
|
95 |
+
foreach ( $synced_lists as $synced_list )
|
96 |
+
{
|
97 |
+
foreach ( stripslashes_deep(unserialize($synced_list->tag_synced_lists)) as $tag_synced_list )
|
98 |
+
{
|
99 |
+
if ( $tag_synced_list['esp'] == 'mailchimp' )
|
100 |
+
{
|
101 |
+
echo '<tr class="synced-list-row">';
|
102 |
+
echo '<td class="synced-list-cell"><span class="icon-tag"></span> ' . $synced_list->tag_text . '</td>';
|
103 |
+
echo '<td class="synced-list-cell"><span class="synced-list-arrow">→</span></td>';
|
104 |
+
echo '<td class="synced-list-cell"><span class="icon-envelope"></span> ' . $tag_synced_list['list_name'] . '</td>';
|
105 |
+
echo '<td class="synced-list-edit"><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=edit_tag&tag=' . $synced_list->tag_id . '">edit</a></td>';
|
106 |
+
echo '</tr>';
|
107 |
+
|
108 |
+
$synced_list_count++;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
+
echo '</table>';
|
113 |
+
|
114 |
+
if ( ! $synced_list_count )
|
115 |
+
echo "<p>You don't have any MailChimp lists synced with LeadIn yet...</p>";
|
116 |
+
|
117 |
+
echo '<p><a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=leadin_contacts&action=manage_tags' . '">Manage tags</a></p>';
|
118 |
+
}
|
119 |
+
|
120 |
+
if ( $li_mls_api_key )
|
121 |
+
echo '<p style="padding-top: 10px;"><a href="http://admin.mailchimp.com/lists/new-list/" target="_blank">Create a new list on MailChimp.com</a></p>';
|
122 |
+
}
|
123 |
+
|
124 |
+
function li_get_synced_list_for_esp ( $esp_name, $output_type = 'OBJECT' )
|
125 |
+
{
|
126 |
+
global $wpdb;
|
127 |
+
|
128 |
+
$q = $wpdb->prepare("SELECT * FROM $wpdb->li_tags WHERE tag_synced_lists LIKE '%%%s%%' AND tag_deleted = 0", $esp_name);
|
129 |
+
$synced_lists = $wpdb->get_results($q, $output_type);
|
130 |
+
|
131 |
+
return $synced_lists;
|
132 |
}
|
133 |
|
134 |
/**
|
136 |
*/
|
137 |
function li_mls_subscribers_to_list_callback ()
|
138 |
{
|
139 |
+
$li_mls_subscribers_to_list = ( isset($this->options['li_mls_subscribers_to_list']) ? $this->options['li_mls_subscribers_to_list'] : '' );
|
|
|
140 |
|
141 |
+
$lists = $this->li_mls_get_mailchimp_lists($this->options['li_mls_api_key']);
|
142 |
|
143 |
echo '<select id="li_mls_subscribers_to_list" name="leadin_mls_options[li_mls_subscribers_to_list]" ' . ( ! count($lists['data']) ? 'disabled' : '' ) . '>';
|
144 |
|
167 |
echo '<p><a href="http://admin.mailchimp.com/lists/new-list/" target="_blank">Create a new list on MailChimp.com</a></p>';
|
168 |
}
|
169 |
|
170 |
+
function li_get_lists ( )
|
171 |
+
{
|
172 |
+
$lists = $this->li_mls_get_mailchimp_lists($this->options['li_mls_api_key']);
|
173 |
+
|
174 |
+
$sanitized_lists = array();
|
175 |
+
foreach ( $lists['data'] as $list )
|
176 |
+
{
|
177 |
+
$list_obj = (Object)NULL;
|
178 |
+
$list_obj->id = $list['id'];
|
179 |
+
$list_obj->name = $list['name'];
|
180 |
+
|
181 |
+
array_push($sanitized_lists, $list_obj);;
|
182 |
+
}
|
183 |
+
|
184 |
+
return $sanitized_lists;
|
185 |
+
}
|
186 |
+
|
187 |
function li_mls_get_mailchimp_lists ( $api_key )
|
188 |
{
|
189 |
$MailChimp = new LI_MailChimp($api_key);
|
power-ups/mailchimp-list-sync/inc/MailChimp-API.php
CHANGED
@@ -52,7 +52,7 @@ class LI_MailChimp
|
|
52 |
* @return array Assoc array of decoded result
|
53 |
*/
|
54 |
private function makeRequest($method, $args=array())
|
55 |
-
{
|
56 |
$args['apikey'] = $this->api_key;
|
57 |
|
58 |
$url = $this->api_endpoint.'/'.$method.'.json';
|
@@ -67,8 +67,11 @@ class LI_MailChimp
|
|
67 |
curl_setopt($ch, CURLOPT_POST, true);
|
68 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
|
69 |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
|
|
|
70 |
$result = curl_exec($ch);
|
71 |
curl_close($ch);
|
|
|
|
|
72 |
} else {
|
73 |
$json_data = json_encode($args);
|
74 |
$result = file_get_contents($url, null, stream_context_create(array(
|
52 |
* @return array Assoc array of decoded result
|
53 |
*/
|
54 |
private function makeRequest($method, $args=array())
|
55 |
+
{
|
56 |
$args['apikey'] = $this->api_key;
|
57 |
|
58 |
$url = $this->api_endpoint.'/'.$method.'.json';
|
67 |
curl_setopt($ch, CURLOPT_POST, true);
|
68 |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
|
69 |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
|
70 |
+
curl_setopt($ch, CURLOPT_HEADER, false);
|
71 |
$result = curl_exec($ch);
|
72 |
curl_close($ch);
|
73 |
+
|
74 |
+
|
75 |
} else {
|
76 |
$json_data = json_encode($args);
|
77 |
$result = file_get_contents($url, null, stream_context_create(array(
|
power-ups/subscribe-widget.php
CHANGED
@@ -79,6 +79,8 @@ class WPLeadInSubscribe extends WPLeadIn {
|
|
79 |
*/
|
80 |
function add_defaults ()
|
81 |
{
|
|
|
|
|
82 |
$options = $this->options;
|
83 |
|
84 |
if ( ($options['li_susbscibe_installed'] != 1) || (!is_array($options)) )
|
@@ -99,6 +101,16 @@ class WPLeadInSubscribe extends WPLeadIn {
|
|
99 |
);
|
100 |
|
101 |
update_option('leadin_subscribe_options', $opt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
}
|
104 |
|
79 |
*/
|
80 |
function add_defaults ()
|
81 |
{
|
82 |
+
global $wpdb;
|
83 |
+
|
84 |
$options = $this->options;
|
85 |
|
86 |
if ( ($options['li_susbscibe_installed'] != 1) || (!is_array($options)) )
|
101 |
);
|
102 |
|
103 |
update_option('leadin_subscribe_options', $opt);
|
104 |
+
|
105 |
+
// Create smart list for subscribe pop-up
|
106 |
+
$q = $wpdb->prepare("SELECT tag_id FROM $wpdb->li_tags WHERE tag_synced_lists LIKE '%%%s%'", ".vex-dialog-form");
|
107 |
+
$subscriber_list_exists = $wpdb->get_var($q);
|
108 |
+
|
109 |
+
if ( ! $subscriber_list_exists )
|
110 |
+
{
|
111 |
+
$tagger = new LI_Tag_Editor();
|
112 |
+
$tagger->add_tag('Subscribers', '.vex-dialog-form', '');
|
113 |
+
}
|
114 |
}
|
115 |
}
|
116 |
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== LeadIn ===
|
2 |
Contributors: andygcook, nelsonjoyce
|
3 |
-
Tags: lead tracking, visitor tracking, analytics,
|
4 |
Requires at least: 3.7
|
5 |
-
Tested up to: 3.9.
|
6 |
-
Stable tag:
|
7 |
|
8 |
LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
9 |
|
@@ -87,11 +87,23 @@ To ensure quality we've tested the most popular WordPress form builder plugins.
|
|
87 |
3. LeadIn stats show you where your leads are coming from.
|
88 |
4. Segment your contact list based on page views and submissinos.
|
89 |
5. Collect more contacts with the pop-up subscribe widget.
|
|
|
90 |
|
91 |
== Changelog ==
|
92 |
|
93 |
-
- Current version:
|
94 |
-
- Current version release: 2014-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
= 1.3.0 (2014.07.14) =
|
97 |
= Enhancements =
|
1 |
=== LeadIn ===
|
2 |
Contributors: andygcook, nelsonjoyce
|
3 |
+
Tags: crm, contacts, lead tracking, click tracking, visitor tracking, analytics, marketing automation, inbound marketing, subscription, marketing, lead generation, mailchimp, constant contact, newsletter, popup, popover, email list, email, contacts database, contact form, forms, form widget, popup form
|
4 |
Requires at least: 3.7
|
5 |
+
Tested up to: 3.9.2
|
6 |
+
Stable tag: 2.0.0
|
7 |
|
8 |
LeadIn is an easy-to-use marketing automation and lead tracking plugin for WordPress that helps you better understand your web site visitors.
|
9 |
|
87 |
3. LeadIn stats show you where your leads are coming from.
|
88 |
4. Segment your contact list based on page views and submissinos.
|
89 |
5. Collect more contacts with the pop-up subscribe widget.
|
90 |
+
6. Create custom tagged lists, choose the form triggers to add contacts and sync your contacts to third-party email services
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
- Current version: 2.0.0
|
95 |
+
- Current version release: 2014-08-14
|
96 |
+
|
97 |
+
= 2.0.0 (2014.08.11) =
|
98 |
+
= Enhancements =
|
99 |
+
- Create a custom tagged list based on form submission rules
|
100 |
+
- Ability to sync tagged contacts to a specific ESP list
|
101 |
+
- Filter lists by form selectors
|
102 |
+
|
103 |
+
- Bug fixes
|
104 |
+
- Fix contact export for selected contacts
|
105 |
+
- Text area line breaks in the contact notifications now show properly
|
106 |
+
- Contact numbers at top of list did not always match number in sidebar - fixed
|
107 |
|
108 |
= 1.3.0 (2014.07.14) =
|
109 |
= Enhancements =
|
screenshot-1.png
CHANGED
Binary file
|
screenshot-4.png
CHANGED
Binary file
|
screenshot-6.png
ADDED
Binary file
|