PageSourceSearch

https://saltycricket.org/_static/--/wp-content/js/jquery/jquery.au…/script-m-1637664782j.js

js saltycricket.org collected 2026-10-04 17:49:59 UTC 58,609 bytes, 1,613 lines download raw bytes

1/*!
2	AutoResize v1.18.4 - 2014-01-11
3	Automatically adjust textarea height based on user input.
4	(c) 2014 Jack Moore - http://www.jacklmoore.com/autosize
5	Originally altered by mdawaffe.
6	Current version altered by pento.
7	license: http://www.opensource.org/licenses/mit-license.php
8*/
9(function ($) {
10	var
11	defaults = {
12		className: 'autosizejs',
13		append: '',
14		callback: false,
15		resizeDelay: 10,
16		placeholder: true,
17		animate: true,
18		animateDuration: 150,
19		animateCallback: function(){},
20		extraSpace: 20
21	},
22
23	// border:0 is unnecessary, but avoids a bug in Firefox on OSX
24	copy = '<textarea aria-hidden="true" tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
25
26	// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
27	typographyStyles = [
28		'fontFamily',
29		'fontSize',
30		'fontWeight',
31		'fontStyle',
32		'letterSpacing',
33		'textTransform',
34		'textDecoration',
35		'wordSpacing',
36		'textIndent'
37	],
38
39	// to keep track which textarea is being mirrored when adjust() is called.
40	mirrored,
41
42	// the mirror element, which is used to calculate what size the mirrored element should be.
43	mirror = $(copy).data('autosize', true)[0];
44
45	// test that line-height can be accurately copied.
46	mirror.style.lineHeight = '99px';
47	if ($(mirror).css('lineHeight') === '99px') {
48		typographyStyles.push('lineHeight');
49	}
50	mirror.style.lineHeight = '';
51
52	$.fn.autoResize = function (options) {
53		if (!this.length) {
54			return this;
55		}
56
57		options = $.extend({}, defaults, options || {});
58
59		if (mirror.parentNode !== this.parentNode) {
60			$(mirror).insertBefore(this);
61		}
62
63		return this.each(function () {
64			var
65			ta = this,
66			$ta = $(ta),
67			maxHeight,
68			minHeight,
69			boxOffset = 0,
70			callback = $.isFunction(options.callback),
71			originalStyles = {
72				height: ta.style.height,
73				overflow: ta.style.overflow,
74				overflowY: ta.style.overflowY,
75				wordWrap: ta.style.wordWrap,
76				resize: ta.style.resize
77			},
78			timeout,
79			width = $ta.width();
80
81			if ($ta.data('autosize')) {
82				// exit if autosize has already been applied, or if the textarea is the mirror element.
83				return;
84			}
85			$ta.data('autosize', true);
86
87			if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
88				boxOffset = $ta.outerHeight() - $ta.height();
89			}
90
91			// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
92			minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
93
94			$ta.css({
95				overflow: 'hidden',
96				overflowY: 'hidden',
97				wordWrap: 'break-word', // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
98				resize: ($ta.css('resize') === 'none' || $ta.css('resize') === 'vertical') ? 'none' : 'horizontal'
99			});
100
101			// The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
102			// window.getComputedStyle, getBoundingClientRect returning a width are unsupported, but also unneeded in IE8 and lower.
103			function setWidth() {
104				var width;
105				var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false;
106				
107				if (style) {
108
109					width = ta.getBoundingClientRect().width;
110
111					if (width === 0) {
112						width = parseInt(style.width,10);
113					}
114
115					$.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
116						width -= parseInt(style[val],10);
117					});
118				} else {
119					width = Math.max($ta.width(), 0);
120				}
121
122				mirror.style.width = width + 'px';
123			}
124
125			function initMirror() {
126				var styles = {};
127
128				mirrored = ta;
129				mirror.className = options.className + " " + ta.className;
130				maxHeight = parseInt($ta.css('maxHeight'), 10);
131
132				// mirror is a duplicate textarea located off-screen that
133				// is automatically updated to contain the same text as the
134				// original textarea.  mirror always has a height of 0.
135				// This gives a cross-browser supported way getting the actual
136				// height of the text, through the scrollTop property.
137				$.each(typographyStyles, function(i,val){
138					styles[val] = $ta.css(val);
139				});
140				$(mirror).css(styles);
141
142				setWidth();
143
144				// Chrome-specific fix:
145				// When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
146				// made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
147				if (window.chrome) {
148					var width = ta.style.width;
149					ta.style.width = '0px';
150					var ignore = ta.offsetWidth;
151					ta.style.width = width;
152				}
153			}
154
155			// Using mainly bare JS in this function because it is going
156			// to fire very often while typing, and needs to very efficie
156nt.
157			function adjust() {
158				var height, original;
159
160				if (mirrored !== ta) {
161					initMirror();
162				} else {
163					setWidth();
164				}
165
166				if (!ta.value && options.placeholder) {
167					// If the textarea is empty, copy the placeholder text into 
168					// the mirror control and use that for sizing so that we 
169					// don't end up with placeholder getting trimmed.
170					mirror.value = ($ta.attr("placeholder") || '') + options.append;
171				} else {
172					mirror.value = ta.value + options.append;
173				}
174
175				mirror.style.overflowY = ta.style.overflowY;
176				original = parseInt(ta.style.height,10);
177
178				// Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
179				mirror.scrollTop = 0;
180
181				mirror.scrollTop = 9e4;
182
183				// Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
184				height = mirror.scrollTop + options.extraSpace;
185
186				if (maxHeight && height > maxHeight) {
187					ta.style.overflowY = 'scroll';
188					height = maxHeight;
189				} else {
190					ta.style.overflowY = 'hidden';
191					if (height < minHeight) {
192						height = minHeight;
193					}
194				}
195
196				height += boxOffset;
197				height = Math.floor( height );
198
199				if (original !== height) {
200					if ( options.animate && $ta.css( 'display' ) === 'block' ) {
201						$ta.stop().animate( {height: height}, options.animateDuration, options.animateCallback );
202					} else {
203						ta.style.height = height + 'px';
204						options.animateCallback.call( this );
205					}
206					if (callback) {
207						options.callback.call(ta,ta);
208					}
209				}
210			}
211
212			function resize () {
213				clearTimeout(timeout);
214				timeout = setTimeout(function(){
215					var newWidth = $ta.width();
216
217					if (newWidth !== width) {
218						width = newWidth;
219						adjust();
220					}
221				}, parseInt(options.resizeDelay,10));
222			}
223
224			if ('onpropertychange' in ta) {
225				if ('oninput' in ta) {
226					// Detects IE9.  IE9 does not fire onpropertychange or oninput for deletions,
227					// so binding to onkeyup to catch most of those occasions.  There is no way that I
228					// know of to detect something like 'cut' in IE9.
229					$ta.on('input.autosize keyup.autosize', adjust);
230				} else {
231					// IE7 / IE8
232					$ta.on('propertychange.autosize', function(){
233						if(event.propertyName === 'value'){
234							adjust();
235						}
236					});
237				}
238			} else {
239				// Modern Browsers
240				$ta.on('input.autosize', adjust);
241			}
242
243			// Set options.resizeDelay to false if using fixed-width textarea elements.
244			// Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
245
246			if (options.resizeDelay !== false) {
247				$(window).on('resize.autosize', resize);
248			}
249
250			// Event for manual triggering if needed.
251			// Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
252			$ta.on('autosize.resize', adjust);
253
254			// Event for manual triggering that also forces the styles to update as well.
255			// Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
256			$ta.on('autosize.resizeIncludeStyle', function() {
257				mirrored = null;
258				adjust();
259			});
260
261			$ta.on('autosize.destroy', function(){
262				mirrored = null;
263				clearTimeout(timeout);
264				$(window).off('resize', resize);
265				$ta
266					.off('autosize')
267					.off('.autosize')
268					.css(originalStyles)
269					.removeData('autosize');
270			});
271
272			// Call adjust in case the textarea already contains text.
273			adjust();
274		});
275	};
276}(window.jQuery || window.$)); // jQuery or jQuery-like library, such as Zepto
277;
278/**
279 The MIT License
280
281 Copyright (c) 2010 Daniel Park (http://metaweb.com, http://postmessage.freebaseapps.com)
282
283 Permission is hereby granted, free of charge, to any person obtaining a copy
284 of this software and associated documentation files (the "Software"), to deal
285 in the Software without restriction, including without limitation the rights
286 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
287 copies of the Software, and to permit persons to whom the Software is
288 furnished to do so, subject to the following conditions:
289
290 The above copyright notice and this permission notice shall be included in
291 all copies or substantial portions of the Software.
292
293 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
294 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
295 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
296 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
297 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
298 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
299 THE SOFTWARE.
300 **/
301var NO_JQUERY = {};
302(function(window, $, undefined) {
303
304     if (!("console" in window)) {
305         var c = window.console = {};
306         c.log = c.warn = c.error = c.debug = function(){};
307     }
308
309     if ($ === NO_JQUERY) {
310         // jQuery is optional
311         $ = {
312             fn: {},
313             extend: function() {
314                 var a = arguments[0];
315                 for (var i=1,len=arguments.length; i<len; i++) {
316                     var b = arguments[i];
317                     for (var prop in b) {
318                         a[prop] = b[prop];
319                     }
320                 }
321                 return a;
322             }
323         };
324     }
325
326     $.fn.pm = function() {
327         console.log("usage: \nto send:    $.pm(options)\nto receive: $.pm.bind(type, fn, [origin])");
328         return this;
329     };
330
331     // send postmessage
332     $.pm = window.pm = function(options) {
333         pm.send(options);
334     };
335
336     // bind postmessage handler
337     $.pm.bind = window.pm.bind = function(type, fn, origin, hash, async_reply) {
vendor: 4,775 bytes, lines 338-487
338         pm.bind(type, fn, origin, hash, async_reply === true);
339     };
340
341     // unbind postmessage handler
342     $.pm.unbind = window.pm.unbind = function(type, fn) {
343         pm.unbind(type, fn);
344     };
345
346     // default postmessage origin on bind
347     $.pm.origin = window.pm.origin = null;
348
349     // default postmessage polling if using location hash to pass postmessages
350     $.pm.poll = window.pm.poll = 200;
351
352     var pm = {
353
354         send: function(options) {
355             var o = $.extend({}, pm.defaults, options),
356             target = o.target;
357             if (!o.target) {
358                 console.warn("postmessage target window required");
359                 return;
360             }
361             if (!o.type) {
362                 console.warn("postmessage type required");
363                 return;
364             }
365             var msg = {data:o.data, type:o.type};
366             if (o.success) {
367                 msg.callback = pm._callback(o.success);
368             }
369             if (o.error) {
370                 msg.errback = pm._callback(o.error);
371             }
372             if (("postMessage" in target) && !o.hash) {
373                 pm._bind();
374                 target.postMessage(JSON.stringify(msg), o.origin || '*');
375             }
376             else {
377                 pm.hash._bind();
378                 pm.hash.send(o, msg);
379             }
380         },
381
382         bind: function(type, fn, origin, hash, async_reply) {
383           pm._replyBind ( type, fn, origin, hash, async_reply );
384         },
385
386         _replyBind: function(type, fn, origin, hash, isCallback) {
387           if (("postMessage" in window) && !hash) {
388               pm._bind();
389           }
390           else {
391               pm.hash._bind();
392           }
393           var l = pm.data("listeners.postmessage");
394           if (!l) {
395               l = {};
396               pm.data("listeners.postmessage", l);
397           }
398           var fns = l[type];
399           if (!fns) {
400               fns = [];
401               l[type] = fns;
402           }
403           fns.push({fn:fn, callback: isCallback, origin:origin || $.pm.origin});
404         },
405
406         unbind: function(type, fn) {
407             var l = pm.data("listeners.postmessage");
408             if (l) {
409                 if (type) {
410                     if (fn) {
411                         // remove specific listener
412                         var fns = l[type];
413                         if (fns) {
414                             var m = [];
415                             for (var i=0,len=fns.length; i<len; i++) {
416                                 var o = fns[i];
417                                 if (o.fn !== fn) {
418                                     m.push(o);
419                                 }
420                             }
421                             l[type] = m;
422                         }
423                     }
424                     else {
425                         // remove all listeners by type
426                         delete l[type];
427                     }
428                 }
429                 else {
430                     // unbind all listeners of all type
431                     for (var i in l) {
432                       delete l[i];
433                     }
434                 }
435             }
436         },
437
438         data: function(k, v) {
439             if (v === undefined) {
440                 return pm._data[k];
441             }
442             pm._data[k] = v;
443             return v;
444         },
445
446         _data: {},
447
448         _CHARS: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''),
449
450         _random: function() {
451             var r = [];
452             for (var i=0; i<32; i++) {
453                 r[i] = pm._CHARS[0 | Math.random() * 32];
454             };
455             return r.join("");
456         },
457
458         _callback: function(fn) {
459             var cbs = pm.data("callbacks.postmessage");
460             if (!cbs) {
461                 cbs = {};
462                 pm.data("callbacks.postmessage", cbs);
463             }
464             var r = pm._random();
465             cbs[r] = fn;
466             return r;
467         },
468
469         _bind: function() {
470             // are we already listening to message events on this w?
471             if (!pm.data("listening.postmessage")) {
472                 if (window.addEventListener) {
473                     window.addEventListener("message", pm._dispatch, false);
474                 }
475                 else if (window.attachEvent) {
476                     window.attachEvent("onmessage", pm._dispatch);
477                 }
478                 pm.data("listening.postmessage", 1);
479             }
480         },
481
482         _dispatch: function(e) {
483             //console.log("$.pm.dispatch", e, this);
484             try {
485                 var msg = JSON.parse(e.data);
486             }
487             catch (ex) {
488                 //console.warn("postmessage data invalid json: ", ex); //message wasn't meant for pm
489                 return;
490             }
491             if (!msg.type) {
492                 //console.warn("postmessage message type required"); //message wasn't meant for pm
493                 return;
494             }
495             var cbs = pm.data("callbacks.postmessage") || {},
496             cb = cbs[msg.type];
497             if (cb) {
498                 cb(msg.data);
499             }
500             else {
501                 var l = pm.data("listeners.postmessage") || {};
502                 var fns = l[msg.type] || [];
503                 for (var i=0,len=fns.length; i<len; i++) {
504                     var o = fns[i];
505                     if (o.origin && o.origin !== '*' && e.origin !== o.origin) {
506                         console.warn("postmessage message origin mismatch", e.origin, o.origin);
507                         if (msg.errback) {
508                             // notify post message errback
509                             var error = {
510                                 message: "postmessage origin mismatch",
511                                 origin: [e.origin, o.origin]
512                             };
513                             pm.send({target:e.source, data:error, type:msg.errback});
514                         }
515                         continue;
516                     }
517
518                     function sendReply ( data ) {
519                       if (msg.callback) {
520                           pm.send({target:e.source, data:data, type:msg.callback});
521                       }
522                     }
523
524                     try {
525                         if ( o.callback ) {
526                           o.fn(msg.data, sendReply, e);
527                         } else {
528                           sendReply ( o.fn(msg.data, e) );
529                         }
530                     }
531                     catch (ex) {
532                         if (msg.errback) {
533                             // notify post message errback
534                             pm.send({target:e.source, data:ex, type:msg.errback});
535                         } else {
536                             throw ex;
537                         }
538                     }
539                 };
540             }
541         }
542     };
543
544     // location hash polling
545     pm.hash = {
546
547         send: function(options, msg) {
548             //console.log("hash.send", target_window, options, msg);
549             var target_window = options.target,
550             target_url = options.url;
551             if (!target_url) {
552                 console.warn("postmessage target window url is required");
553                 return;
554             }
555             target_url = pm.hash._url(target_url);
556             var source_window,
557             source_url = pm.hash._url(window.location.href);
558             if (window == target_window.parent) {
559                 source_window = "parent";
560             }
561             else {
562                 try {
563                     for (var i=0,len=parent.frames.length; i<len; i++) {
564                         var f = parent.frames[i];
565                         if (f == window) {
566                             source_window = i;
567                             break;
568                         }
569                     };
570                 }
571                 catch(ex) {
572                     // Opera: security error trying to access parent.frames x-origin
573                     // juse use window.name
574                     source_window = window.name;
575                 }
576             }
577             if (source_window == null) {
578                 console.warn("postmessage windows must be direct parent/child windows and the child must be available through the parent window.frames list");
579                 return;
580             }
581             var hashmessage = {
582                 "x-requested-with": "postmessage",
583                 source: {
584                     name: source_window,
585                     url: source_url
586                 },
587                 postmessage: msg
588             };
589             var hash_id = "#x-postmessage-id=" + pm._random();
590             target_window.location = target_url + hash_id + encodeURIComponent(JSON.stringify(hashmessage));
591         },
592
593         _regex: /^\#x\-postmessage\-id\=(\w{32})/,
594
595         _regex_len: "#x-postmessage-id=".length + 32,
596
597         _bind: function() {
598             // are we already listening to message events on this w?
599             if (!pm.data("polling.postmessage")) {
600                 setInterval(function() {
601                                 var hash = "" + window.location.hash,
602                                 m = pm.hash._regex.exec(hash);
603                                 if (m) {
604                                     var id = m[1];
605                                     if (pm.hash._last !== id) {
606                                         pm.hash._last = id;
607                                         pm.hash._dispatch(hash.substring(pm.hash._regex_len));
608                                     }
609                                 }
610                             }, $.pm.poll || 200);
611                 pm.data("polling.postmessage", 1);
612             }
613         },
614
615         _dispatch: function(hash) {
616             if (!hash) {
617                 return;
618             }
619             try {
620                 hash = JSON.parse(decodeURIComponent(hash));
621                 if (!(hash['x-requested-with'] === 'postmessage' &&
622                       hash.source && hash.source.name != null && hash.source.url && hash.postmessage)) {
623                     // ignore since hash could've come from somewhere else
624                     return;
625                 }
626             }
627             catch (ex) {
628                 // ignore since hash could've come from somewhere else
629                 return;
630             }
631             var msg = hash.postmessage,
632             cbs = pm.data("callbacks.postmessage") || {},
633             cb = cbs[msg.type];
634             if (cb) {
635                 cb(msg.data);
636             }
637             else {
638                 var source_window;
639                 if (hash.source.name === "parent") {
640                     source_window = window.parent;
641                 }
642                 else {
643                     source_window = window.frames[hash.source.name];
644                 }
645                 var l = pm.data("listeners.postmessage") || {};
646                 var fns = l[msg.type] || [];
647                 for (var i=0,len=fns.length; i<len; i++) {
648                     var o = fns[i];
649                     if (o.origin) {
650                         var origin = /https?\:\/\/[^\/]*/.exec(hash.source.url)[0];
651                         if (o.origin !== '*' && origin !== o.origin) {
652                             console.warn("postmessage message origin mismatch", origin, o.origin);
653                             if (msg.errback) {
654                                 // notify post message errback
655                                 var error = {
656                                     message: "postmessage origin mismatch",
657                                     origin: [origin, o.origin]
658                                 };
659                                 pm.send({target:source_window, data:error, type:msg.errback, hash:true, url:hash.source.url});
660                             }
661                             continue;
662                         }
663                     }
664
665                     function sendReply ( data ) {
666                       if (msg.callback) {
667                         pm.send({target:source_window, data:data, type:msg.callback, hash:true, url:hash.source.url});
668                       }
669                     }
670
671                     try {
672                         if ( o.callback ) {
673                           o.fn(msg.data, sendReply);
674                         } else {
675                           sendReply ( o.fn(msg.data) );
676                         }
677                     }
678                     catch (ex) {
679                         if (msg.errback) {
680                             // notify post message errback
681                             pm.send({target:source_window, data:ex, type:msg.errback, hash:true, url:hash.source.url});
682                         } else {
683                             throw ex;
684                         }
685                     }
686                 };
687             }
688         },
689
690         _url: function(url) {
691             // url minus hash part
692             return (""+url).replace(/#.*$/, "");
693         }
694
695     };
696
697     $.extend(pm, {
698                  defaults: {
699                      target: null,  /* target window (required) */
700                      url: null,     /* target window url (required if no window.postMessage or hash == true) */
701                      type: null,    /* message type (required) */
702                      data: null,    /* message data (required) */
703                      success: null, /* success callback (optional) */
704                      error: null,   /* error callback (optional) */
705                      origin: "*",   /* postmessage origin (optional) */
706                      hash: false    /* use location hash for message passing (optional) */
707                  }
708              });
709
710 })(this, typeof jQuery === "undefined" ? NO_JQUERY : jQuery);
711;
712var HighlanderComments = jQuery.extend( HighlanderComments, {
713	commentList: null,
714
715	initialHeight: 70,
716
717	cookies: { facebook: 'wpc_fbc', twitter: 'wpc_tc', wordpress: 'wpc_wpc', googleplus: 'wpc_gpc' },
718	popups:  { facebook: ',height=400,width=600', twitter: ',height=515,width=600', wordpress: ',height=500,width=500' },
719	temp_cookie_data: '',
720	currentParent: false,
721	currentParentId: false,
722	currentParentMargins: {},
723	keyCodeReturn: 13,
724
725	resizeCallback: function() {},
726
727	init : function() {
728		jQuery( '#respond' ).addClass( 'js' );
729
730		HighlanderComments.commentList = jQuery( '#thecomments, .thecomments, #commentlist, #comment-list, #comments-list, .commentlist, .comment-list, .comments-list, .com-list, #comments' ).last();
731
732		jQuery( '#comment-form-nascar a' ).click( HighlanderComments.clickService );
733		jQuery( '#postas-wordpress' ).click( HighlanderComments.clickExternalTab );
734		jQuery( '#postas-facebook, #labelto-facebook' ).click( HighlanderComments.clickExternalTab );
735		jQuery( '#postas-twitter, #labelto-twitter' ).click( HighlanderComments.clickExternalTab );
736
737		pm.bind( 'googlePlusButtonClick', HighlanderComments.onGooglePlusButtonClick, 'https://public-api.wordpress.com' );
738		pm.bind( 'googlePlusSignIn', HighlanderComments.onGooglePlusSignIn, 'https://public-api.wordpress.com' );
739
740		jQuery( '#labelto-wordpress' ).click( HighlanderComments.checkPostToWordPress );
741		jQuery( '#comment-form-post-to-edit a' ).click( HighlanderComments.editShareText );
742		jQuery( window ).resize( HighlanderComments.toggleShareLabels );
743
744		HighlanderComments.toggleShareLabels();
745
746		jQuery.each( jQuery( '.comment-form-field input, textarea#comment' ), function() {
747			if ( jQuery(this).val() !== '' ) {
748				HighlanderComments.hideLabels( jQuery(this) );
749			}
750		} );
751
752		jQuery( 'div.comment-form-fields input' ).change( function() { HighlanderComments.toggleLabel( jQuery(this) ); } ).focus( function() { HighlanderComments.hideLabels( jQuery(this) ); } ).blur( function() { HighlanderComments.showLabels( jQuery(this) ); } );
753		jQuery( 'div.comment-form-fields label' ).click( function() { HighlanderComments.hideLabels( jQuery(this).parent().children( '.comment-form-input input' ) ); } );
754
755		// Identity auto-fill from Gravatar Profiles
756		jQuery( '#email' ).blur( function() {
757			HighlanderComments.updateAvatarWithGravatar( '#email' );
758
759			if ( !jQuery( '#author' ).val() ) {
760				Gravatar.autofill( jQuery( this ).val(), {
761					'displayName':'author',
762					'url':'url' // Their first available link, or profile URL if none
763				} );
764
765				var afd = Gravatar.autofill_data;
766				Gravatar.autofill_data = function( hash ) {
767					afd.call( Gravatar, hash );
768					jQuery( 'input#url' ).change();
769					jQuery( 'input#author' ).change().click();
770				};
771			}
772		} );
773
774		// Comment area auto-sizing and tab handling
775		jQuery( 'textarea#comment' )
776			.autoResize({
777				animate: false,
778				animateCallback: HighlanderComments.resizeCallback
779			})
780			.css( 'resize', 'none' )
781			.trigger('change.dynSiz')
782			.focus( function() { HighlanderComments.hideLabels( jQuery(this) ); } )
783			.blur( function() { HighlanderComments.showLabels( jQuery(this) ); } )
784			.keydown( function( e ) {
785				if ( 'undefined' != typeof e.keyCode && 9 == e.keyCode ) { // TAB key
786					e.preventDefault();
787					if ( 'guest' == jQuery( '#hc_post_as' ).val() ) {
788						if ( 1 == HighlanderComments.comment_registration ) {
789							jQuery( '#postas-wordpress' ).focus();
790						} else {
791							jQuery( '#email' ).focus();
792						}
793					} else {
794						jQuery( '#comment-submit' ).focus();
795					}
796				}
797				if (
798					HighlanderComments.isCommandOrControlKeyDown( e ) &&
799					HighlanderComments.keyCodeReturn === e.which
800				) {
801					jQuery( "#comment-submit" ).click();
802				}
803			} )
804			.keyup( function() { HighlanderComments.fillShareText( jQuery(this) ); } )
805			.one( 'focus', function() {
806				var googlePlusSignIn = jQuery( '#googleplus-sign-in' );
807				if ( googlePlusSignIn.length < 1 ) {
808					return;
809				}
810
811				pm( {
812					target: googlePlusSignIn[0].contentWindow,
813					type: 'googlePlusLoadJS',
814					data: 0,
815					url: 'https://public-api.wordpress.com'
816				} );
817			});
818
819		// Client-side form validation
820		jQuery( '#commentform' ).submit( function() {
821			var verified = true, email, author;
822			// Comment text required
823			if ( '' === jQuery( 'textarea#comment' ).val() ) {
824				jQuery( 'label[for="comment"]' ).fadeOut( 'fast', function() {
825					jQuery(this).text( HighlanderComments.enterACommentError ).fadeIn( 'fast').addClass('error');
826				} );
827				jQuery( '#comment-form-comment' ).addClass('error');
828				jQuery( 'textarea#comment' ).focus( function() { jQuery(this).parent( '#comment-form-comment' ).removeClass('error'); } );
829				verified = false;
830			}
831
832			// Only exists if email/name are required
833			if ( 'guest' == jQuery( '#hc_post_as' ).val() && ( jQuery( '#comment-form-guest label span[class="required"]' ).size() || jQuery( '#comment-form-guest label[class="error"]' ).size() ) ) {
834				email = jQuery( '#email' ).val();
835				if ( '' === email || !email.match( /^.*@.*\..*$/ ) ) {
836					jQuery( 'label[for="email"]' ).fadeOut( 'fast', function() {
837						var error;
838						if ( '' == email ) {
839							error = HighlanderComments.enterEmailError;
840						} else {
841							error = '<span class="nopublish">' + HighlanderComments.invalidEmailError + '</span>';
842						}
843						jQuery(this).html( error ).css( 'opacity', 1 ).fadeIn( 'fast' ).addClass( 'error' );
844					});
845					jQuery( 'div.comment-form-email .comment-form-input' ).addClass('error');
846					jQuery( 'input#email' ).focus( function() { jQuery(this).parent().removeClass( 'error' ); } );
847
848					verified = false;
849				}
850
851				author = jQuery( '#author' ).val();
852				if ( '' === author ) {
853					jQuery( 'label[for="author"]' ).fadeOut( 'fast', function() {
854						jQuery(this).text( HighlanderComments.enterAuthorError ).fadeIn('fast').addClass( 'error' );
855					} );
856					jQuery( 'div.comment-form-author .comment-form-input' ).addClass('error');
857					jQuery( 'input#author' ).focus( function() { jQuery(this).parent().removeClass( 'error' ); } );
858					verified = false;
859				}
860			}
861
862			// Don't allow "guest" comments if auth is required
863			if ( '1' == HighlanderComments.comment_registration && 'guest' == jQuery( '#hc_post_as' ).val() ) {
864				jQuery( '#comment-form-nascar > p' ).addClass( 'error' ).fadeOut( 'fast', function() {
865					jQuery( this ).fadeIn( 'fast' );
866				} );
867				verified = false;
868			}
869
870			// Set a cookie to remember which was the last used tab
871			HighlanderComments.writeCookie( 'hc_post_as', jQuery( '#hc_post_as' ).val(), 7, '.wordpress.com' );
872
873			if ( !verified ) {
874				return false;
875			}
876
877			HighlanderComments.clickSubmit();
878			return true;
879		} );
880
881		// Set up the identity block based on WP options, logged in state, etc
882		if ( '1' == HighlanderComments.comment_registration ) {
883			// Must be logged in to comment (guest commenting not allowed)
884			jQuery('#comment-form-guest').hide();
885			if ( !HighlanderComments.isJetpack && !HighlanderComments.userIsLoggedIn ) {
886				// Force to guest posting if they're not logged in, which should actually not allow itself
887				HighlanderComments.clickGuestTab();
888				jQuery( '#comment-form-wordpress' ).removeClass( 'selected' );
889				jQuery( '#hc_post_as' ).val( 'guest' );
890			}
891		} else {
892			// Guest commenting is allowed
893			if ( HighlanderComments.userIsLoggedIn && jQuery( '#comment-form-wordpress.selected' ).length ) {
894				// User is logged in and we're looking at the WP UI already, get rid of guest commenting
895				jQuery( '#comment-form-guest' ).slideUp( 'fast' );
896			}
897		}
898		if ( jQuery( '.comment-form-service.selected' ).not( '#comment-form-guest.selected' ).length ) {
899			// Something other than Guest is selected, hide the auth strip
900			jQuery( '#comment-form-nascar' ).hide();
901		}
902
903		if ( 'undefined' !== typeof addComment ) {
904			HighlanderComments._moveForm = addComment.moveForm;
905			addComment.moveForm = HighlanderComments.moveForm;
906		}
907
908		// Hover Tooltips
909		jQuery( '#comment-form-guest .comment-form-avatar' ).hover( function() {
910			pos = jQuery( this ).offset();
911            if (  'rtl' === HighlanderComments.text_direction ) {
912                style = 'top:' + ( pos.top - 10 ) + 'px;left:' + ( pos.left - 130 ) + 'px;';
913            } else {
914                style = 'top:' + ( pos.top - 10 ) + 'px;left:' + ( pos.left + 35 ) + 'px;';
915            }
916
917			jQuery( 'body' ).append( '<div id="hltt-grav" class="highlander-tooltip" style="' + style + '">' + HighlanderComments.gravatarFromEmail  + '</div>' );
918		}, function() {
919			jQuery( '#hltt-grav' ).fadeOut( 'fast', function() {
920				jQuery( this ).remove();
921				jQuery( '.highlander-tooltip' ).remove();
922			} );
923		} );
924		jQuery( '#comment-form-nascar ul' ).hover( function() {
925			pos = jQuery( this ).offset();
926            if (  'rtl' === HighlanderComments.text_direction ) {
927                style = 'top:' + ( pos.top - 12 ) + 'px;left:' + ( pos.left + 125 ) + 'px;';
928            } else {
929                style = 'top:' + ( pos.top - 12 ) + 'px;left:' + ( pos.left - 125 ) + 'px;';
930            }
931			jQuery( 'body' ).append( '<div id="hltt-auth" class="highlander-tooltip" style="' + style + '">' + HighlanderComments.logInToExternalAccount + '</div>' );
932		}, function() {
933			jQuery( '#hltt-auth' ).fadeOut( 'fast', function() {
934				jQuery( this ).remove();
935				jQuery( '.highlander-tooltip' ).remove();
936			} );
937		} );
938	},
939
940    isCommandOrControlKeyDown: function( event ) {
941		// event.metaKey will be true if Command key (⌘) or Windows key is down.
942		return ( event.ctrlKey || event.metaKey );
943	},
944
945	_moveForm: null,
946	moveForm: function( commId, parentId, respondId, postId ) {
947		if ( null === HighlanderComments._moveForm ) {
948			return;
949		}
950
951		var t = this,
952		    r = false,
953		    respond = jQuery( '#' + respondId ).css( { marginLeft: 0, marginRight: 0 } ),
954		    w, wTop, commElement, rHeight, cTop, rTop;
955
956		if ( HighlanderComments.currentParent ) {
957			if ( parentId === HighlanderComments.currentParentId ) {
958				return false;
959			}
960
961			w = jQuery(window);
962			wTop = w.scrollTop();
963			commElement = jQuery( '#' + commId );
964			cTop = commElement.offset().top;
965			rTop = respond.offset().top;
966
967			if ( rTop <= cTop ) {
968				rHeight = respond.outerHeight( true );
969				respond.before( jQuery( '<div id="highlander-placeholder" />' ).css( { margin: 0, padding: 0, border: 0, height: rHeight, visibility: 'hidden', position: respond.css( 'position' ) } ) );
970			}
971
972			r = HighlanderComments._moveForm.call( t, commId, parentId, respondId, postId );
973			if ( false !== r ) {
974				return r;
975			}
976
977			HighlanderComments.currentParent.stop( true, true ).css( HighlanderComments.currentParentMargins );
978
979			jQuery( '#highlander-placeholder' ).remove();
980
981			if ( rTop <= cTop ) {
982				jQuery( window ).scrollTop( wTop - rHeight );
983			}
984
985			HighlanderComments.moveFormNow.call( t, commId, parentId, respondId );
986		} else {
987			r = HighlanderComments._moveForm.call( t, commId, parentId, respondId, postId );
988			if ( false === r ) {
989				HighlanderComments.moveFormNow.call( t, commId, parentId, respondId );
990			}
991		}
992
993		return r;
994	},
995
996	moveFormNow: function( commId, parentId, respondId ) {
997		HighlanderComments.currentParent = jQuery( '#comment-' + parentId ).parents( '.highlander-comment' ).andSelf().filter( '.highlander-comment' ).last();
998		if ( !HighlanderComments.currentParent.size() ) {
999			HighlanderComments.currentParent = jQuery( '#comment-' + parentId ).parents( '.comment' ).andSelf().filter( '.comment' ).last();
1000		}
1001		HighlanderComments.currentParentId = parentId;
1002
1003		var respond = jQuery( '#' + respondId );
1004
1005		if ( !HighlanderComments.currentParent.find( respond ).size() ) {
1006			var betterParent = HighlanderComments.currentParent.parents( '.children:first' );
1007			if ( !betterParent.size() ) {
1008				betterParent = HighlanderComments.currentParent.parents( '.highlander-comment:first' );
1009				if ( !betterParent.size() ) {
1010					betterParent = HighlanderComments.currentParent.parents( '.comment:first' );
1011				}
1012			}
1013
1014			if ( betterParent.size() ) {
1015				HighlanderComments.currentParent = betterParent;
1016			}
1017		}
1018
1019		HighlanderComments.currentParentMargins = {
1020			backgroundColor: HighlanderComments.currentParent.css( 'backgroundColor' ),
1021			marginLeft: HighlanderComments.currentParent.css( 'marginLeft' ),
1022			marginRight: HighlanderComments.currentParent.css( 'marginRight' )
1023		};
1024
1025		var oldOff, newOff, offOrder, autoWidth = false;
1026		if ( 'rtl' === HighlanderComments.text_direction ) {
1027			offOrder = [ 'Left', 'Right' ];
1028		} else {
1029			offOrder = [ 'Right', 'Left' ];
1030		}
1031
1032		jQuery.each( offOrder, function( i, v ) {
1033			if ( '0px' === HighlanderComments.currentParentMargins['margin' + v] ) {
1034				oldOff = HighlanderComments.currentParent.offset().left;
1035				if ( 'Right' === v ) {
1036					oldOff += HighlanderComments.currentParent.outerWidth();
1037				}
1038				HighlanderComments.currentParent.css( 'margin' + v, 0 );
1039				newOff = HighlanderComments.currentParent.offset().left;
1040				if ( 'Right' === v ) {
1041					newOff += HighlanderComments.currentParent.outerWidth();
1042				}
1043				if ( oldOff !== newOff ) {
1044					newOff = 'Right' === v ? newOff - oldOff : oldOff - newOff;
1045					HighlanderComments.currentParent.css( 'margin' + v, newOff );
1046					HighlanderComments.currentParentMargins['margin' + v] = newOff;
1047					autoWidth = true;
1048				}
1049			}
1050		} );
1051
1052		if ( autoWidth ) {
1053			HighlanderComments.currentParent.css( 'width', 'auto' );
1054			HighlanderComments.currentParentMargins.width = 'auto';
1055		}
1056
1057		var rgbaTransparent = /rgba.*,\s*0\s*\)/, cp, bg, bgi;
1058		if ( 'transparent' === HighlanderComments.currentParentMargins.backgroundColor || HighlanderComments.currentParentMargins.backgroundColor.match( rgbaTransparent ) ) {
1059			cp = HighlanderComments.currentParent.get( 0 );
1060			bg = 'transparent';
1061			bgi = HighlanderComments.currentParent.css( 'backgroundImage' );
1062
1063			while ( 'none' === bgi && cp.parentNode && cp.parentNode != document && ( 'transparent' === bg || bg.match( rgbaTransparent ) ) ) {
1064				cp = cp.parentNode;
1065				bg = jQuery( cp );
1066				bgi = bg.css( 'backgroundImage' );
1067				bg = bg.css( 'backgroundColor' );
1068			}
1069
1070			HighlanderComments.currentParent.css( 'backgroundColor', bg );
1071		}
1072
1073		var cancel = document.getElementById( 'cancel-comment-reply-link' ),
1074		    listOffsetSource = HighlanderComments.commentList,
1075		    listOffset,
1076		    parentOffset = HighlanderComments.currentParent.offset(),
1077		    currentParentMargins = HighlanderComments.currentParentMargins,
1078		    redoMargins = false,
1079		    grandWidth;
1080
1081		// Re-initialize the commentList if it was not found during init
1082		if ( ! listOffsetSource.length ) {
1083			HighlanderComments.commentList = jQuery( '#thecomments, .thecomments, #commentlist, #comment-list, #comments-list, .commentlist, .comment-list, .comments-list, .com-list, #comments' ).last();
1084			listOffsetSource = HighlanderComments.commentList;
1085		}
1086
1087		cp = HighlanderComments.currentParent;
1088
1089		while ( !cp.is( HighlanderComments.commentList ) && !cp.is( document ) ) {
1090			if ( 'hidden' === cp.css( 'overflow' ) || 'hidden' === cp.css( 'overflow-x' ) ) {
1091				listOffsetSource = cp;
1092				break;
1093			}
1094
1095			cp = cp.parent();
1096		}
1097
1098		listOffset = listOffsetSource.offset();
1099
1100		HighlanderComments._unmoveForm = cancel.onclick;
1101		cancel.onclick = function() { return HighlanderComments.unmoveForm.call( this ); };
1102
1103		if ( -1 < currentParentMargins.marginLeft.toString().indexOf( '%' ) ) {
1104			grandWidth = HighlanderComments.currentParent.parent().width();
1105			currentParentMargins.marginLeft = parseFloat( currentParentMargins.marginLeft ) / 100 * grandWidth;
1106			redoMargins = true;
1107		}
1108
1109		if ( -1 < currentParentMargins.marginRight.toString().indexOf( '%' ) ) {
1110			grandWidth = HighlanderComments.currentParent.parent().width();
1111			currentParentMargins.marginRight = parseFloat( currentParentMargins.marginRight ) / 100 * grandWidth;
1112			redoMargins = true;
1113		}
1114
1115		if ( redoMargins ) {
1116			HighlanderComments.currentParent.css( currentParentMargins );
1117		}
1118
1119		listOffset.right = listOffset.left + listOffsetSource.outerWidth();
1120		parentOffset.left -= parseInt( HighlanderComments.currentParent.css( 'margin-left' ), 10 );
1121		parentOffset.right = parentOffset.left + HighlanderComments.currentParent.outerWidth( true );
1122
1123		respond.hide();
1124		HighlanderComments.currentParent.animate( {
1125			marginLeft: '-=' + ( parentOffset.left - listOffset.left ).toString(),
1126			marginRight: '-=' + ( listOffset.right - parentOffset.right ).toString()
1127		}, 350, function() {
1128			respond.slideDown( 350, function() {
1129				jQuery( '#' + commId + ' .comment-reply-link:first' ).focus();
1130				jQuery( '#comment' ).focus();
1131				HighlanderComments.resizeCallback();
1132			} );
1133
1134			respond.children('form').after('<div class="clear" id="threaded-clear"></div>');
1135		} );
1136	},
1137
1138	_unmoveForm: null,
1139	unmoveForm: function() {
1140		var r = HighlanderComments._unmoveForm.call( this );
1141		if ( false !== r ) {
1142			return r;
1143		}
1144
1145		HighlanderComments.currentParent.stop( true, true ).animate( HighlanderComments.currentParentMargins, 350, function() {
1146			HighlanderComments.currentParent.css( HighlanderComments.currentParentMargins );
1147			HighlanderComments.currentParent = HighlanderComments.currentParentId = false;
1148		} );
1149		jQuery( '#respond' ).stop( true, true ).show();
1150		jQuery( '#respond div#threaded-clear' ).remove();
1151		HighlanderComments.resizeCallback();
1152
1153		return r;
1154	},
1155
1156	HTMLToText : function( string ) {
1157		return jQuery( '<span />' ).text( string ).html();
1158	},
1159
1160	switchAccount : function() {
1161		jQuery( '.comment-form-service' ).removeClass( 'selected' ).hide();
1162		jQuery( '#hc_post_as' ).val( 'guest' );
1163		jQuery( '#comment-form-nascar > p' ).removeClass( 'error' );
1164		if ( '1' == HighlanderComments.comment_registration ) {
1165			jQuery( '#comment-form-nascar' ).show();
1166			jQuery( '#comment-form-guest' ).hide(); // Guest commenting not allowed
1167			HighlanderComments.resizeCallback();
1168		} else {
1169			jQuery( '#comment-form-nascar' ).show();
1170			jQuery( '#comment-form-guest' ).slideDown( 'fast', HighlanderComments.resizeCallback );
1171			HighlanderComments.clickGuestTab();
1172		}
1173	},
1174
1175	setConnectingToText : function( serviceFriendlyName ) {
1176		jQuery( '#comment-form-load-service p' ).text( HighlanderComments.connectingToText.replace( '%s', serviceFriendlyName ) );
1177	},
1178
1179	updateLoadServiceVisibility : function( tab ) {
1180		jQuery( '.comment-form-service' )
1181			.css( 'visibility', 'hidden' )
1182			.show()
1183			.removeClass( 'selected' )
1184			.filter( tab )
1185				.css( 'visibility', 'visible' )
1186				.fadeIn( 'fast' )
1187			.end()
1188			.not( tab )
1189				.hide()
1190				.css( 'visibility', 'visible' );
1191	},
1192
1193	clickService : function(e) {
1194		e.preventDefault();
1195
1196		var tab = this.href.replace( /^.*#/, '#' ).split( ':' );
1197
1198		if ( '#comment-form-load-service' === tab[0] && tab[1] ) {
1199			HighlanderComments.setConnectingToText( tab[1] );
1200		} else {
1201			jQuery( '#hc_post_as' ).val( tab[0].split( '-' ).pop() );
1202		}
1203
1204		HighlanderComments.updateLoadServiceVisibility( '#comment-form-load-service' );
1205
1206		jQuery( '#comment-form-nascar li.selected' ).removeClass( 'selected' );
1207		jQuery( this ).parent().addClass( 'selected' );
1208		HighlanderComments.resizeCallback();
1209	},
1210
1211	setServiceSelected: function( service ) {
1212		HighlanderComments.updateLoadServiceVisibility( '#comment-form-load-service' );
1213		jQuery( '#comment-form-nascar li.selected' ).removeClass( 'selected' );
1214		jQuery( '#postas-' + service ).parent().addClass( 'selected' );
1215		jQuery( '#comment-form-nascar' ).hide();
1216		HighlanderComments.resizeCallback();
1217	},
1218
1219	clickGuestTab : function(e) {
1220		if ( '1' == HighlanderComments.comment_registration ) {
1221			jQuery( '#comment-form-guest' ).hide();
1222		}
1223
1224		if ( jQuery( '#email' ).length && -1 < jQuery( '#email' ).val().indexOf( '@twitter.example.com' ) ) {
1225			jQuery( '#email' ).val( '' ).blur();
1226		}
1227
1228		HighlanderComments.updateAvatarWithGravatar( '#email' );
1229
1230		// Reenable subscription options
1231		jQuery( '#comment-form-subscribe' ).css( 'opacity', '1'  ).find( 'input' ).removeAttr( 'disabled' );
1232		HighlanderComments.resizeCallback();
1233	},
1234
1235	checkPostToWordPress: function(e) {
1236		HighlanderComments.clickExternalTab( 'wordpress' );
1237		jQuery( '#wordpress-login-first' ).show();
1238	},
1239
1240	updateAvatarWithGravatar: function(e) {
1241		var grav_base = ( 'https:' === location.protocol ? 'https://secure' : 'http://www' ) + '.gravatar.com/avatar/';
1242		// When Avatars are disabled, Gravatar can be undefined, so we check against that first
1243		// and fall back to an unknown gravatar if it isn't
1244		var gravSource = grav_base + 'ad516503a11cd5ca435acc9bb6523536?s=25&forcedefault=1';
1245
1246		if ( 'undefined' !== typeof Gravatar && jQuery( e ).length ) {
1247			gravSource = grav_base + Gravatar.md5( jQuery.trim( jQuery( e ).val().toLowerCase() ) ) + '?s=25';
1248		}
1249
1250		if ( 'gravatar_default' !== HighlanderComments.gravDefault ) {
1251			gravSource += '&d=' + encodeURIComponent( HighlanderComments.gravDefault );
1252		}
1253
1254		jQuery( '#comment-form-guest .comment-form-avatar img' ).attr( 'src', gravSource );
1255	},
1256
1257	getServiceData : function( service ) {
1258		var data = HighlanderComments.readCookie( HighlanderComments.cookies[service] );
1259
1260		if ( null === data || 'undefined' === typeof data.access_token || !data.access_token ) {
1261			return false;
1262		}
1263		return data;
1264	},
1265
1266	ext_win : false,
1267	ext_win_check : false,
1268	pollExternalWindow : function( service, from_tab ) {
1269		if ( !HighlanderComments.ext_win || HighlanderComments.ext_win.closed ) {
1270			// If the cookie is available, then we must have auth'd successfully
1271			if ( HighlanderComments.getServiceData( service ) ) {
1272				HighlanderComments.doExternalLoggedIn( service );
1273				return;
1274			}
1275			HighlanderComments.doExternalCanceled( service, from_tab );
1276			HighlanderComments.ext_win = false;
1277			clearInterval( HighlanderComments.ext_win_check );
1278		}
1279	},
1280
1281	cancelExternalWindow : function() {
1282		if ( HighlanderComments.ext_win ) {
1283			HighlanderComments.ext_win.close();
1284		}
1285		HighlanderComments.doExternalCanceled( jQuery( '#hc_post_as' ).val(), true );
1286	},
1287
1288	clickExternalTab : function( e ) {
1289		if ( 'undefined' == typeof e ) {
1290			return;
1291		}
1292
1293		jQuery( '#comment-form-guest' ).slideUp( 'fast', function() {
1294			jQuery( '#comment-form-nascar' ).hide();
1295
1296			HighlanderComments.resizeCallback();
1297
1298			clearInterval( HighlanderComments.ext_win_check );
1299			jQuery( '.highlander-tooltip' ).remove();
1300
1301			var from_tab = 1;
1302			if ( 'string' == typeof e ) {
1303				var service = e;
1304			} else {
1305				var service = e.currentTarget.id.split( '-' )[1];
1306				if ( e.currentTarget.nodeName != 'A' ) {
1307					from_tab = 0;
1308				}
1309			}
1310
1311			if (
1312				// Found commenting cookies
1313				null != HighlanderComments.readCookie( HighlanderComments.cookies[service] )
1314			&&
1315				(
1316					// WordPress tab, and we're logged in
1317					'wordpress' == service && HighlanderComments.userIsLoggedIn
1318				||
1319					// Not WordPress tab
1320					'wordpress' != service
1321				)
1322			) {
1323				if ( from_tab ) {
1324					HighlanderComments.doExternalLoggedIn( service );
1325				}
1326			} else if ( 'googleplus' == service ) {
1327				// Nothing to do - we're already logged in at this point
1328			} else {
1329				HighlanderComments.ext_win = window.open( HighlanderComments.connectURL + '&service=' + service, 'highconn', 'status=0,toolbar=0,location=1,menubar=0,directories=0,resizable=1,scrollbars=0' + HighlanderComments.popups[service] );
1330				HighlanderComments.ext_win_check = setInterval( "HighlanderComments.pollExternalWindow( '" + service + "', " + from_tab + " )", 100 );
1331			}
1332		} );
1333	},
1334
1335	doExternalLoggedIn : function( service ) {
1336		clearInterval( HighlanderComments.ext_win_check );
1337
1338		var data = HighlanderComments.getServiceData( service );
1339
1340		if ( 'object' !== typeof data ) {
1341			return;
1342		}
1343
1344		if ( 'wordpress' == service ) {
1345			// Allow subscription options
1346			jQuery( '#comment-form-subscribe' ).css( 'opacity', '1'  ).find( 'input' ).removeAttr( 'disabled' );
1347
1348			// Set up Gravatar and flag as logged in. Load a page to trigger cookies etc
1349			jQuery( '#comment-form-' + service + ' .comment-form-avatar img' ).attr( 'src', data.avatar );
1350			HighlanderComments.userIsLoggedIn = true;
1351			if ( !HighlanderComments.isJetpack ) {
1352				jQuery( 'body' ).append( '<iframe class="highlander-auth-init" height="1" width="1" style="display:none;" src="' + HighlanderComments.homeURL + 'highlander.login/" />' );
1353			}
1354		} else if ( 'facebook' == service ) {
1355			jQuery( '#comment-form-' + service + ' .comment-form-avatar img' ).attr( 'src', data.avatar );
1356		} else {
1357			if ( 'twitter' == service ) {
1358				// Disable subscription options for Twitter since we don't have an email
1359				jQuery( '#comment-form-subscribe' ).css( 'opacity', '0.5'  ).find( 'input' ).attr( 'disabled', 'disabled' ).removeAttr( 'checked' );
1360			}
1361
1362			// Run all external avatars through ImgPress to resize them
1363			jQuery( '#comment-form-' + service + ' .comment-form-avatar img' )
1364				.attr( 'src', function() {
1365					var split, host, path, query, url;
1366
1367					try {
1368						if ( data.avatar.match( /^(https?:)?\/\/i[012]\.wp\.com\// ) ) {
1369							return data.avatar.replace( /^https?:/, location.protocol );
1370						}
1371
1372						if ( data.avatar.match( /^(https?:)?\/\/(.*?\.)gravatar\.com\// ) ) {
1373							return data.avatar.replace( /^https?:/, location.protocol );
1374						}
1375
1376						split = data.avatar.split( '#' ); // Ignore fragment
1377						split = split[0].split( '?' );
1378						query = split[1];
1379						split = split[0].split( '//' ); // Ignore scheme
1380						split = split[1].split( '/' );
1381						host  = split[0];
1382						path  = split.slice( 1 ).join( '/' );
1383
1384						url = location.protocol + 'https://i0.wp.com/' + host + '/' + path + '?';
1385
1386						if ( 'graph.facebook.com' === host && query.length ) {
1387							url += 'q=' + encodeURIComponent( query ) + '&';
1388						}
1389
1390						return url + 'resize=25%2C25';
1391					} catch ( error ) {
1392						return data.avatar;
1393					}
1394				} );
1395		}
1396
1397		jQuery( '#email' ).val( data.email ).change();
1398		jQuery( '#author' ).val( data.name ).change();
1399		jQuery( '#url' ).val( data.link ).change().click();
1400		jQuery( '#' + service + '-avatar' ).val( data.avatar );
1401		jQuery( '#' + service + '-user_id' ).val( data.uid );
1402		jQuery( '#' + service + '-access_token' ).val( data.access_token );
1403
1404		jQuery( '#hc_post_as' ).val( service );
1405
1406		// The child of the li.selected can be a <A> (WP, FB, Twitter) or an <IFRAME> (Google)
1407
1408		var selectedLink = jQuery( '#comment-form-nascar li.selected a' );
1409		if ( selectedLink.length && service == selectedLink.attr( 'id' ).replace( 'postas-', '' ) ) {
1410			jQuery( '#comment-form-load-service' ).hide();
1411			jQuery( '#comment-form-' + service ).show();
1412			jQuery( '#comment-form-' + service + ' .comment-form-posting-as strong' ).text( data.name + ':' );
1413			HighlanderComments.resizeCallback();
1414		}
1415
1416		var selectedIFrame = jQuery( '#comment-form-nascar li.selected iframe' );
1417		if ( selectedIFrame.length && service == "googleplus" ) {
1418			jQuery( '#comment-form-load-service' ).hide();
1419			jQuery( '#comment-form-' + service ).show();
1420			jQuery( '#comment-form-' + service + ' .comment-form-posting-as strong' ).text( data.name + ':' );
1421			HighlanderComments.resizeCallback();
1422		}
1423	},
1424
1425	doExternalCanceled : function( service, from_tab ) {
1426		if ( from_tab ) {
1427			var gravSource = ( 'https:' === location.protocol ? 'https://secure' : 'http://www' ) + '.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=25';
1428			if ( 'gravatar_default' !== HighlanderComments.gravDefault ) {
1429				gravSource += '&d=' + encodeURIComponent( HighlanderComments.gravDefault );
1430			}
1431			jQuery( '#comment-form-' + service + ' .comment-form-avatar img' ).attr( 'src', gravSource );
1432			jQuery( '.comment-meta-' + service ).val( '' );
1433			jQuery( '#postas-' + service + ' span' ).html( '&nbsp; &nbsp; &nbsp;' );
1434			jQuery( '#comment-form-' + service ).hide();
1435			HighlanderComments.switchAccount();
1436		}
1437
1438		jQuery( '#postto-' + service ).prop( 'checked', false );
1439	},
1440
1441	doExternalLogout : function( service ) {
1442		var hostname;
1443		if ( -1 !== document.location.hostname.indexOf( '.wordpress.com' ) ) {
1444			hostname = 'wordpress.com';
1445		} else {
1446			hostname = document.location.hostname;
1447		}
1448
1449		HighlanderComments.writeCookie( HighlanderComments.cookies[service], '', -10, hostname );
1450		HighlanderComments.doExternalCanceled( service, true );
1451
1452		if ( 'wordpress' == service ) {
1453			HighlanderComments.userIsLoggedIn = false;
1454			jQuery( 'body' ).append( '<iframe height="1" width="1" style="display:none;" src="' + HighlanderComments.logoutURL + '" />' );
1455		}
1456
1457		if ( 'googleplus' == service ) {
1458			jQuery( 'body' ).append( '<iframe height="1" width="1" style="display:none;" src="https://accounts.google.com/logout" />' );
1459		}
1460	},
1461
1462	clickSubmit : function(e) {
1463		jQuery( '#respond input#comment-submit' ).val( HighlanderComments.HTMLToText( HighlanderComments.submittingText ) ).addClass( 'disabled' ).attr( 'disabled', 'disabled' ).wrap( '<p id="comment-form-submitting" />' );
1464	},
1465
1466	toggleLabel : function( input ) {
1467		if ( jQuery( window ).width() && jQuery( window ).width() <= 450 ) {
1468			return;
1469		}
1470
1471		if ( !input.val().length ) {
1472			input.parents('div.comment-form-field').children('label').css( { opacity: 1 } );
1473		} else {
1474			input.parents('div.comment-form-field').children('label').css( { opacity: 0.05 } );
1475		}
1476	},
1477
1478	hideLabels: function( input ) {
1479		if ( jQuery( window ).width() == 0 || jQuery( window ).width() > 450 && !input.attr( 'placeholder' ) ) {
1480			input.parents('div.comment-form-field').children('label').animate( { opacity: 0 }, 150, function() {
1481				jQuery(this).hide();
1482			} );
1483		}
1484
1485		input.parent().addClass('active');
1486	},
1487
1488	showLabels: function( input ) {
1489		if ( jQuery( window ).width() == 0 || jQuery( window ).width() > 450 && !input.attr( 'placeholder' ) ) {
1490			if ( !input.val().length ) {
1491				input.parents('div.comment-form-field').children('label').show().animate( { opacity: 1 }, 150 );
1492			}
1493		}
1494
1495		input.parent().removeClass('active');
1496	},
1497
1498	editShareText: function(e) {
1499		e.preventDefault();
1500
1501		if ( jQuery( '#comment-form-edit-share-text' ).is( ':hidden' ) ) {
1502			jQuery( '#comment-form-edit-share-text' ).slideDown( 'fast', HighlanderComments.resizeCallback );
1503		} else {
1504			jQuery( '#comment-form-edit-share-text' ).slideUp( 'fast', HighlanderComments.resizeCallback );
1505		}
1506	},
1507
1508	toggleShareLabels: function() {
1509		if ( jQuery( '#respond' ).outerWidth() > 450 ) {
1510			jQuery( '#comment-form-post-to label span' ).show().parent().css( { 'padding-right': 0 } );
1511		} else {
1512			jQuery( '#comment-form-post-to label span' ).hide().parent().css( { 'padding-right': '20px' } );
1513		}
1514		HighlanderComments.resizeCallback();
1515	},
1516
1517	fillShareText: function( textarea ) {
1518		if ( !jQuery( '#comment-form-share-text-textarea' ).length ) { return; }
1519
1520		var current = jQuery( '#comment-form-share-text-textarea' ).val().split( '": ' );
1521		var shareComment = current[0] + '": ' + jQuery(textarea).val();
1522
1523		if ( shareComment.length > 280 ) {
1524			shareComment = shareComment.substr( 0, 276 ) + '...';
1525		}
1526
1527		jQuery( '#comment-form-share-text-textarea' ).val( shareComment );
1528	},
1529
1530	// Google Sign-in is a little different than the other services
1531	// It uses its own JavaScript API loaded in its own iframe
1532	// (public.api/connect/?googleplus-sign-in=1)
1533	// We listen for messages from that iframe here
1534	onGooglePlusSignIn: function( message ) {
1535		var hostname;
1536		if ( -1 !== document.location.hostname.indexOf( '.wordpress.com' ) ) {
1537			hostname = 'wordpress.com';
1538		} else {
1539			hostname = document.location.hostname;
1540		}
1541
1542		if ( 'undefined' == typeof message.error) {
1543			var value = jQuery.param( message ).replace( /\+/g, '%20' );
1544			value.name = encodeURIComponent( value.name );
1545			HighlanderComments.writeCookie( 'wpc_gpc', value, 1, hostname );
1546
1547			jQuery( '#comment-form-nascar li.selected' ).removeClass( 'selected' );
1548			jQuery( "#googleplus-sign-in" ).parent().addClass( 'selected' );
1549
1550			HighlanderComments.doExternalLoggedIn( 'googleplus' );
1551		} else {
1552			HighlanderComments.doExternalLogout( 'googleplus' );
1553		}
1554	},
1555
1556	onGooglePlusButtonClick: function( message ) {
1557		HighlanderComments.setConnectingToText( 'Google' );
1558		HighlanderComments.updateLoadServiceVisibility( '#comment-form-load-service' );
1559		HighlanderComments.clickExternalTab( 'googleplus' );
1560	},
1561
1562	/* Read the contents of a named cookie, assuming they are query-string-style
1563	delimited, and return them as a JS hash. */
1564	readCookie : function(c) {
1565		var nameEQ = c + "=",
1566		    cookieStrings = document.cookie.split( ';' ),
1567		    i, cookieString, num, chunk, pairs, pair, cookie_data;
1568
1569		if( 'wpc_gpc' == c && !document.cookie ) { // Needed for IE because it doesn’t allow setting cookies in iframes from another domain, unless we send P3P headers
1570			cookieStrings = HighlanderComments.temp_cookie_data.split( ';' );
1571		}
1572		for ( i = 0; i < cookieStrings.length; i++ ) {
1573			cookieString = cookieStrings[ i ];
1574			while ( cookieString.charAt( 0 ) === ' ' ) {
1575				cookieString = cookieString.substring( 1, cookieString.length );
1576			}
1577			if ( cookieString.indexOf( nameEQ ) === 0 ) {
1578				chunk = cookieString.substring( nameEQ.length, cookieString.length );
1579				pairs = chunk.split( '&' );
1580				cookie_data = {};
1581				for ( num = pairs.length - 1; num >= 0; num-- ) {
1582					pair = pairs[ num ].split( '=' );
1583					cookie_data[ pair[0] ] = decodeURIComponent( pair[1] );
1584				}
1585				return cookie_data;
1586			}
1587		}
1588		return null;
1589	},
1590
1591	writeCookie : function( name, value, days, domain ) {
1592		var expires;
1593		if ( days ) {
1594			var date = new Date();
1595			date.setTime( date.getTime() + ( days * 24 * 60 * 60 * 1000 ) );
1596			expires = "; expires=" + date.toGMTString();
1597		} else {
1598			expires = "";
1599		}
1600
1601		if ( domain ) {
1602			domain = "; domain=" + domain;
1603		} else {
1604			domain = '';
1605		}
1606
1607		HighlanderComments.temp_cookie_data = document.cookie = name + "=" + value + expires + "; path=/" + domain;
1608
1609	}
1610}
1610 );
1611
1612jQuery( HighlanderComments.init );
1613;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.