forked from jdm/asknot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tabzilla.js
796 lines (731 loc) · 31.7 KB
/
tabzilla.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
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
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
/**
* Tabzilla global navigation for Mozilla projects
*
* This code is licensed under the Mozilla Public License 1.1.
*
* Portions adapted from the jQuery Easing plugin written by Robert Penner and
* used under the following license:
*
* Copyright 2001 Robert Penner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the author nor the names of contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Media query matchMedia polyfill implementation from Paul Irish
* (https://github.com/paulirish/matchMedia.js/) used under the following
* license (MIT):
*
* Copyright (c) 2012 Scott Jehl
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*
* @copyright 2012-2013 silverorange Inc.
* @license http://www.mozilla.org/MPL/MPL-1.1.html Mozilla Public License 1.1
* @author Michael Gauthier <[email protected]>
* @author Steven Garrity <[email protected]>
* @author Isac Lagerblad <[email protected]>
* @author Kohei Yoshino <[email protected]>
*/
// Load mwc 2014 strings from mwc2014_promos.lang only for the locales we target
var Tabzilla = (function (Tabzilla) {
'use strict';
var minimumJQuery = '1.7.1';
var panel;
var nav;
var headlines;
var tab;
var opened = false;
var hasMediaQueries = ('matchMedia' in window);
var isIE9 = (document.documentMode === 9);
var mode = 'wide';
var negativeTabIndex = '-1';
var $ = null; // non-version-conflicting jQuery alias for tabzilla
var jQuery;
var checkMode = function () {
var currentMode = getMode();
if (mode !== currentMode) {
mode = currentMode;
setMode();
}
};
var getMode = function() {
if (hasMediaQueries && matchMedia('(max-width: 719px)').matches) {
return 'compact';
}
return 'wide';
};
var setMode = function () {
if (mode === 'wide') {
leaveCompactMode();
} else {
enterCompactMode();
}
};
var leaveCompactMode = function () {
removeCompactModeAttributes();
removeCompactModeEvents();
panel.focus();
};
var enterCompactMode = function () {
addCompactModeAttributes();
addCompactModeEvents();
};
var addCompactModeAttributes = function () {
nav.find('>ul').attr('role', 'presentation');
headlines.each(function (i) {
$(this).attr({
'id': 'tab-' + i,
'aria-controls': 'panel-' + i,
'tabindex': negativeTabIndex,
'role': 'tab',
'aria-expanded': false
});
});
if (!nav.find('h2[tabindex=0]').length) {
nav.find('h2:first').attr('tabindex', 0);
}
nav.find('div').each(function (i) {
$(this).attr({
'id': 'panel-' + i,
'aria-labeledby': 'tab-' + i,
'role': 'tabpanel'
}).css('display','none');
});
};
var removeCompactModeAttributes = function () {
nav.find('>ul').removeAttr('role');
headlines.removeAttr('id aria-controls tabindex role aria-expanded');
nav.find('div').removeAttr('id aria-labeledby role style');
};
var addCompactModeEvents = function () {
nav.on('click.submenu', 'h2', function (event) {
event.preventDefault();
var div = $(event.target).next('div');
$(event.target).attr('aria-expanded', div.is(':hidden'));
div.toggle();
});
nav.on('keydown.submenu', function (event) {
var which = event.which;
var target = $(event.target);
// search
if (target.is('input')) {
return true;
}
// enter or space
if (which === 13 || which === 32) {
event.preventDefault();
target.trigger('click');
}
// up or left
if (which === 37 || which === 38) {
event.preventDefault();
headlines.each(function (i) {
if (i > 0 && $(this).attr('tabindex') === 0) {
$(this).attr('tabindex', negativeTabIndex);
$(headlines[i - 1]).attr('tabindex', 0).focus();
return false;
}
});
}
// down or right
if (which === 40 || which === 39) {
event.preventDefault();
headlines.each(function (i) {
if (i < (headlines.length - 1) && $(this).attr('tabindex') === 0) {
$(this).attr('tabindex', negativeTabIndex);
$(headlines[i + 1]).attr('tabindex', 0).focus();
return false;
}
});
}
// esc
if (which === 27 && target.is('a')) {
event.preventDefault();
event.stopPropagation();
target.parents('div').prev('h2').trigger('click').focus();
}
});
};
var removeCompactModeEvents = function () {
nav.off('.submenu');
};
Tabzilla.open = function () {
opened = true;
panel.toggleClass('open');
var height = $('#tabzilla-contents').height();
panel.animate({'height': height}, 200, function () {
panel.css('height', 'auto');
});
tab
.attr({'aria-expanded' : 'true'})
.addClass('tabzilla-opened')
.removeClass('tabzilla-closed');
panel.focus();
if (typeof(_gaq) == 'object') {
window._gaq.push(['_trackEvent', 'Tabzilla', 'click', 'Open Tabzilla']);
}
return panel;
};
Tabzilla.close = function () {
opened = false;
panel.animate({height: 0}, 200, function () {
panel.toggleClass('open');
});
tab
.attr({'aria-expanded' : 'false'})
.addClass('tabzilla-closed')
.removeClass('tabzilla-opened');
if (typeof(_gaq) == 'object') {
window._gaq.push(['_trackEvent', 'Tabzilla', 'click', 'Close Tabzilla']);
}
return tab;
};
Tabzilla.compareVersion = function (a, b) {
var num1, num2;
a = ('' + a).split('.');
b = ('' + b).split('.');
while (a.length < b.length) { a.push('0'); }
while (b.length < a.length) { b.push('0'); }
for (var i = 0; i < a.length; i++) {
num1 = parseInt(a[i], 10);
num2 = parseInt(b[i], 10);
if (num1 > num2) { return 1; }
if (num1 < num2) { return -1; }
}
return 0;
};
// Changing this pref name causes the easter egg to reappear, requires a
// fresh disable. Might be handy if or when the message is changed.
Tabzilla.EASTER_EGG_PREF_NAME = 'tabzilla.showEasterEgg.careersTeaser';
Tabzilla.disableEasterEgg = function () {
try {
localStorage.setItem(this.EASTER_EGG_PREF_NAME, 'false');
} catch (ex) {}
};
Tabzilla.enableEasterEgg = function () {
try {
localStorage.setItem(this.EASTER_EGG_PREF_NAME, 'true');
} catch (ex) {}
};
Tabzilla.shouldShowEasterEgg = function () {
try {
return (localStorage.getItem(this.EASTER_EGG_PREF_NAME) !== 'false');
} catch (ex) {
// HACK: If there's an exception in getting a localStorage item,
// then the support is probably not there. Err on the side of not
// showing the easter egg, since it can't be turned off.
return false;
}
};
var Infobar = function (id, name) {
this.id = id;
this.name = name;
this.disabled = false;
this.prefName = 'tabzilla.infobar.' + id + '.disabled';
// Read the preference
try {
if (sessionStorage.getItem(this.prefName) === 'true') {
this.disabled = true;
}
} catch (ex) {}
// If there is already another infobar, don't show this
if ($('#tabzilla-infobar').length) {
this.disabled = true;
}
};
Infobar.prototype.show = function (str) {
// A infobar can be disabled by pref.
// And check the existence of another infobar again
if (this.disabled || $('#tabzilla-infobar').length) {
return;
}
var self = this;
var bar = self.element = $(
'<div id="tabzilla-infobar" class="' + self.id + '" role="dialog"><div>'
+ '<p>' + str.message + '</p><ul>'
+ '<li><button class="btn-accept" type="button">' + str.accept + '</button></li>'
+ '<li><button class="btn-cancel" type="button">' + str.cancel + '</button></li>'
+ '</ul></div></div>').prependTo(panel);
bar.find('.btn-accept').click(function (event) {
event.preventDefault();
self.trackEvent(self.onaccept.trackAction || 'accept',
self.onaccept.trackLabel,
0, false, // A user interaction event
self.onaccept.callback);
self.hide();
});
bar.find('.btn-cancel').click(function (event) {
event.preventDefault();
self.trackEvent(self.oncancel.trackAction || 'cancel',
self.oncancel.trackLabel,
0, false, // A user interaction event
self.oncancel.callback);
self.hide();
try {
sessionStorage.setItem(self.prefName, 'true');
} catch (ex) {}
});
panel.trigger('infobar-showing');
self.trackEvent(self.onshow.trackAction || 'show',
self.onshow.trackLabel,
0, true, // An auto-triggered, non-interaction event
self.onshow.callback);
if (opened) {
bar.css('height', 0)
.animate({'height': bar.find('div').outerHeight()}, 200,
function () { panel.trigger('infobar-shown'); });
} else {
panel.animate({'height': bar.height()}, 200,
function () { panel.trigger('infobar-shown'); });
}
return bar;
};
Infobar.prototype.hide = function () {
var self = this;
var target = (opened) ? self.element : panel;
panel.trigger('infobar-hiding');
target.animate({'height': 0}, 200, function () {
self.element.remove();
panel.trigger('infobar-hidden');
});
};
Infobar.prototype.trackEvent = function (action, label, value,
nonInteraction, callback) {
if (typeof(_gaq) !== 'object') {
return;
}
// The 5th value and 6th nonInteraction parameters are optional.
// See the Google Analytics Developer Guide for details:
// https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
window._gaq.push(['_trackEvent', 'Tabzilla - ' + this.name, action,
label, value || 0, nonInteraction || false]);
if (callback) {
var timer = null;
var _callback = function () {
clearTimeout(timer);
callback();
};
timer = setTimeout(_callback, 500);
window._gaq.push(_callback);
}
};
Infobar.prototype.onshow = {};
Infobar.prototype.onaccept = {};
Infobar.prototype.oncancel = {};
Infobar.translation = function (userLangs, pageLang) {
var transbar = new Infobar('transbar', 'Translation Bar');
// Note that navigator.language doesn't always work because it's just
// the application's locale on some browsers. navigator.languages has
// not been widely implemented yet, but the new property provides an
// array of the user's accept languages that we'd like to see.
userLangs = userLangs || navigator.languages;
pageLang = pageLang || document.documentElement.lang;
if (transbar.disabled || !userLangs || !pageLang) {
return false;
}
// Normalize the user language in the form of ab or ab-CD
var normalize = function (lang) {
return lang.replace(/^(\w+)(?:-(\w+))?$/, function (m, p1, p2) {
return p1.toLowerCase() + ((p2) ? '-' + p2.toUpperCase() : '');
});
};
// Normalize every language for easier comparison
userLangs = $.map(userLangs, function (lang) { return normalize(lang); });
pageLang = normalize(pageLang);
// If the page language is the user's primary language, there is nothing
// to do here
if (pageLang === userLangs[0]) {
return false;
}
var offeredLang;
var availableLangs = {};
var $links = $('link[hreflang]');
var $options = $('#language option');
// Make a dictionary from alternate URLs or a language selector. The key
// is a language, the value is the relevant <link> or <option> element.
// If those lists cannot be found, there is nothing to do
if ($links.length) {
$links.each(function () {
availableLangs[normalize(this.hreflang)] = this;
});
} else if ($options.length) {
$options.each(function () {
availableLangs[normalize(this.value.match(/^\/?([\w\-]+)/)[1])] = this;
});
} else {
return false;
}
// Compare the user's accept languages against the page's current
// language and other available languages to find the best language
$.each(userLangs, function(index, userLang) {
if (pageLang === userLang || pageLang === userLang.split('-')[0]) {
offeredLang = 'self';
return false; // Break the loop
}
if (userLang in availableLangs) {
offeredLang = userLang;
return false; // Break the loop
}
});
// If the page language is one of the user's secondary languages and no
// other higher-priority language cannot be found in the translations,
// there is nothing to do
if (offeredLang === 'self') {
return false;
}
// If an offered language cannot be detected, try again with shorter
// language names, like en-US -> en, fr-FR -> fr
if (!offeredLang) {
$.each(userLangs, function(index, userLang) {
userLang = userLang.split('-')[0];
if (userLang in availableLangs) {
offeredLang = userLang;
return false; // Break the loop
}
});
}
// If there is no offered language yet, there is nothing to do
if (!offeredLang) {
return false;
}
// Do not show Chrome's built-in Translation Bar
$('head').append('<meta name="google" value="notranslate">');
// Log the language of the current page
transbar.onshow.trackLabel = transbar.oncancel.trackLabel = offeredLang;
transbar.oncancel.trackAction = 'hide';
// If the user selects Yes, show the translated page
transbar.onaccept = {
trackAction: 'change',
trackLabel: offeredLang,
callback: function () {
var element = availableLangs[offeredLang];
if (element.form) { // <option>
element.selected = true;
element.form.submit();
} else { // <link>
location.href = element.href.replace(/^https?\:\/\/[^/]+/, '');
}
}
};
// Fetch the localized strings and show the Translation Bar
$.ajax({ url: '//mozorg.cdn.mozilla.net/' + offeredLang + '/tabzilla/transbar.jsonp',
cache: true, crossDomain: true, dataType: 'jsonp',
jsonpCallback: "_", success: function (str) {
transbar.show(str).attr({
'lang': offeredLang,
'dir': ($.inArray(offeredLang, ['he', 'ar', 'fa', 'ur']) > -1) ? 'rtl' : 'ltr'
});
}});
return offeredLang;
};
Infobar.update = function (latestVersion, ua, buildID) {
latestVersion = parseInt(latestVersion || '36.0.1', 10);
ua = ua || navigator.userAgent;
buildID = buildID || navigator.buildID;
var updatebar = new Infobar('updatebar', 'Update Bar');
var isFirefox = ((/\sFirefox\/\d+/).test(ua) &&
!(/like\ Firefox|Iceweasel|SeaMonkey/i).test(ua)); // Exclude Camino and others
var isMobile = (/Mobile|Tablet|Fennec/i).test(ua);
var userVersion = (isFirefox) ? parseInt(ua.match(/Firefox\/(\d+)/)[1], 10) : 0;
var isFirefox31ESR = !isMobile && userVersion === 31 && buildID && buildID !== '20140716183446';
var showInfobar = function () {
if ($('body').data('defaultSlug') === 'update-firefox-latest-version') {
// Don't show the info bar on the page that the info bar sends the user to.
return;
}
// If the user accepts, show the SUMO article
updatebar.onaccept.callback = function () {
location.href = 'https://support.mozilla.org/en-US/kb/update-firefox-latest-version';
};
// Log the used Firefox version
updatebar.onshow.trackLabel = updatebar.onaccept.trackLabel
= updatebar.oncancel.trackLabel
= String(userVersion);
// The message and accept strings are the same as /firefox/new/
updatebar.show({
message: 'Looks like you\u2019re using an older version of Firefox.',
accept: 'Update to stay fast and safe.',
cancel: 'Later'
});
};
if (updatebar.disabled || !isFirefox || isMobile || isFirefox31ESR ||
userVersion > latestVersion) {
return false;
}
// Show the Update Bar if the user's major version is older than 3 major
// versions. Once the Mozilla.UITour API starts providing the channel
// info (Bug 1065525, Firefox 35+), we can show the Bar only to Release
// channel users. 31 ESR can be detected only with the navigator.buildID
// property. 20140716183446 is the non-ESR build ID that can be found at
// https://wiki.mozilla.org/Releases/Firefox_31/Test_Plan
if (userVersion < latestVersion - 2) {
showInfobar();
return true;
}
return false;
};
// Expose the object for the tests
Tabzilla.infobar = Infobar;
var setupGATracking = function () {
// track tabzilla links in GA
$('#tabzilla-contents').on('click', 'a', function (e) {
var newTab = (this.target === '_blank' || e.metaKey || e.ctrlKey);
var href = this.href;
var timer = null;
var callback = function () {
clearTimeout(timer);
window.location = href;
};
if (typeof(_gaq) == 'object') {
if (newTab) {
window._gaq.push(['_trackEvent', 'Tabzilla', 'click', href]);
} else {
e.preventDefault();
timer = setTimeout(callback, 500);
window._gaq.push(['_trackEvent', 'Tabzilla', 'click', href], callback);
}
}
});
// track search keywords in GA
$('#tabzilla-search form').on('submit', function (e) {
e.preventDefault();
var $form = $(this);
var keyword = $form.find('#q').val();
var timer = null;
var callback = function () {
clearTimeout(timer);
$form.submit();
};
$form.unbind('submit');
if (typeof(_gaq) == 'object' && keyword !== '') {
timer = setTimeout(callback, 500);
window._gaq.push(['_trackEvent', 'Tabzilla', 'search', keyword], callback);
} else {
$form.submit();
}
});
};
var addEaseInOut = function () {
$.extend($.easing, {
'easeInOut': function (x, t, b, c, d) {
if (( t /= d / 2) < 1) {
return c / 2 * t * t + b;
}
return -c / 2 * ((--t) * (t - 2) - 1) + b;
}
});
};
var addMatchMediaPolyfill = function () {
window.matchMedia = window.matchMedia || (function( doc, undefined ) {
var bool;
var docElem = doc.documentElement;
var refNode = docElem.firstElementChild || docElem.firstChild;
// fakeBody required for <FF4 when executed in <head>
var fakeBody = doc.createElement( "body" );
var div = doc.createElement( "div" );
div.id = "mq-test-1";
div.style.cssText = "position:absolute;top:-100em";
fakeBody.style.background = "none";
fakeBody.appendChild(div);
return function(q){
div.innerHTML = "­<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
docElem.insertBefore( fakeBody, refNode );
bool = div.offsetWidth === 42;
docElem.removeChild( fakeBody );
return {
matches: bool,
media: q
};
};
}( document ));
};
var init = function () {
$('body').prepend(content);
tab = $('#tabzilla');
panel = $('#tabzilla-panel');
nav = $('#tabzilla-nav');
headlines = nav.find('h2');
if (isIE9 && !hasMediaQueries) {
addMatchMediaPolyfill();
hasMediaQueries = true;
}
addEaseInOut();
checkMode();
$(window).on('resize', function () {
checkMode();
});
panel.on('keydown', function (event) {
if (event.which === 27) {
event.preventDefault();
Tabzilla.close();
tab.focus();
}
});
tab.attr('aria-label', 'Mozilla links');
tab.on('click', function (event) {
event.preventDefault();
if (opened) {
Tabzilla.close();
} else {
Tabzilla.open();
}
});
$.each((tab.data('infobar') || '').split(' '), function (index, value) {
var setup = Infobar[value];
if (setup) {
setup.call();
}
});
setupGATracking();
// Careers teaser in error console.
$(window).load(function() {
try {
// Try to only show on stage and production environments.
if (Tabzilla.shouldShowEasterEgg()) {
console.log(" _.-~-.\n 7'' Q..\\\n _7 (_\n _7 _/ _q. /\n _7 . ___ /VVvv-'_ .\n 7/ / /~- \\_\\\\ '-._ .-' / //\n ./ ( /-~-/||'=.__ '::. '-~'' { ___ / // ./{\n V V-~-~| || __''_ ':::. ''~-~.___.-'' _/ // / {_ / { /\n VV/-~-~-|/ \\ .'__'. '. ':: _ _ _ ''.\n / /~~~~||VVV/ / \\ ) \\ _ __ ___ ___ ___(_) | | __ _ .::'\n / (~-~-~\\\\.-' / \\' \\::::. | '_ ` _ \\ / _ \\_ / | | |/ _` | :::'\n/..\\ /..\\__/ ' '::: | | | | | | (_) / /| | | | (_| | ::'\nvVVv vVVv ': |_| |_| |_|\\___/___|_|_|_|\\__,_| ''\n\nHi there, nice to meet you!\n\nInterested in having a direct impact on hundreds of millions of users? Join\nMozilla, and become part of a global community that\u2019s helping to build a\nbrighter future for the Web.\n\nVisit https://careers.mozilla.org to learn about our current job openings.\nVisit https://www.mozilla.org/contribute for more ways to get involved and\nhelp support Mozilla.\n\n---\n\nIf you don't want to see this message next time, run this JS statement:\n\n Tabzilla.disableEasterEgg()\n");
}
} catch(e) {}
});
};
var loadJQuery = function (callback) {
var noConflictCallback = function() {
// set non-conflicting version local aliases
jQuery = window.jQuery.noConflict(true);
$ = jQuery;
callback.call();
};
var script = document.createElement("script");
if (script.readyState) {
script.onreadystatechange = function () {
if (script.readyState === "loaded" || script.readyState === "complete") {
script.onreadystatechange = null;
noConflictCallback.call();
}
};
} else {
script.onload = noConflictCallback;
}
script.src = '//mozorg.cdn.mozilla.net/media/js/libs/jquery-' + minimumJQuery + '.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
};
// icn=tabz appended to links for Google Analytics purposes
var content =
'<div id="tabzilla-panel" class="tabzilla-closed" tabindex="-1">'
+ ' <div id="tabzilla-contents">'
+ ' <div id="tabzilla-promo">'
+ ' <div class="snippet" id="tabzilla-promo-gear">'
+ ' <a href="https://gear.mozilla.org/?ref=OMG_launch&utm_campaign=OMG_launch&utm_source=gear.mozilla.org&utm_medium=referral&utm_content=tabzilla">'
+ ' <h4>Official Mozilla gear is here</h4>'
+ ' </a>'
+ ' </div>'
+ ' </div>'
+ ' <div id="tabzilla-nav">'
+ ' <ul>'
+ ' <li><h2>Mozilla</h2>'
+ ' <div>'
+ ' <ul>'
+ ' <li><a href="https://www.mozilla.org/mission/?icn=tabz">Mission</a></li>'
+ ' <li><a href="https://www.mozilla.org/about/?icn=tabz">About</a></li>'
+ ' <li><a href="https://www.mozilla.org/projects/?icn=tabz">Projects</a></li>'
+ ' <li><a href="https://support.mozilla.org/?icn=tabz">Support</a></li>'
+ ' <li><a href="https://developer.mozilla.org/?icn=tabz">Developer Network</a></li>'
+ ' </ul>'
+ ' </div>'
+ ' </li>'
+ ' <li><h2>Products</h2>'
+ ' <div>'
+ ' <ul>'
+ ' <li><a href="https://www.mozilla.org/firefox/?icn=tabz">Firefox</a></li>'
+ ' <li><a href="https://www.mozilla.org/thunderbird/?icn=tabz">Thunderbird</a></li>'
+ ' <li><a href="https://www.mozilla.org/firefox/os/?icn=tabz">Firefox OS</a></li>'
+ ' </ul>'
+ ' </div>'
+ ' </li>'
+ ' <li><h2>Innovations</h2>'
+ ' <div>'
+ ' <ul>'
+ ' <li><a href="https://webmaker.org/?icn=tabz">Webmaker</a></li>'
+ ' <li><a href="https://www.mozilla.org/research/?icn=tabz">Research</a></li>'
+ ' </ul>'
+ ' </div>'
+ ' </li>'
+ ' <li><h2>Get Involved</h2>'
+ ' <div>'
+ ' <ul>'
+ ' <li><a href="https://www.mozilla.org/contribute/?icn=tabz">Volunteer</a></li>'
+ ' <li><a href="https://careers.mozilla.org/?icn=tabz">Careers</a></li>'
+ ' <li><a href="https://www.mozilla.org/en-US/about/mozilla-spaces/?icn=tabz">Find us</a></li>'
+ ' <li><a href="https://sendto.mozilla.org/page/contribute/givenow-seq?preset=2&source=mozillaorg_tabzillaTXT&ref=EOYFR2014&utm_campaign=EOYFR2014&utm_source=mozilla.org&utm_medium=referral&utm_content=mozillaorg_tabzillaTXT&icn=tabz" class="donate">Donate</a></li>'
+ ' <li><a href="https://www.mozilla.org/about/partnerships/?icn=tabz">Partner</a></li>'
+ ' </ul>'
+ ' </div>'
+ ' </li>'
+ ' <li id="tabzilla-search">'
+ ' <a href="https://wiki.mozilla.org/Websites/Directory?icn=tabz">Website Directory</a>'
+ ' <form title="Search Mozilla sites" role="search" action="https://www.google.com/cse">'
+ ' <input type="hidden" value="002443141534113389537:ysdmevkkknw" name="cx">'
+ ' <input type="hidden" value="FORID:0" name="cof">'
+ ' <label for="q">Search</label>'
+ ' <input type="search" placeholder="Search" id="q" name="q">'
+ ' </form>'
+ ' </li>'
+ ' </ul>'
+ ' </div>'
+ ' </div>';
+ '</div>';
// Self-executing function must be after all vars have been initialized
(function () {
if (window.jQuery !== undefined &&
Tabzilla.compareVersion(window.jQuery.fn.jquery, minimumJQuery) !== -1
) {
// set up local jQuery aliases
jQuery = window.jQuery;
$ = jQuery;
$(document).ready(init);
} else {
// no jQuery or older than minimum required jQuery
loadJQuery(init);
}
})();
return Tabzilla;
})(Tabzilla || {});