-
Notifications
You must be signed in to change notification settings - Fork 106
/
stub.xhtml
1234 lines (1165 loc) · 49.2 KB
/
stub.xhtml
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
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html [
<!ENTITY % pageDTD SYSTEM "chrome://conversations/locale/pages.dtd"> %pageDTD;
]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Conversation Reader</title>
<link rel="stylesheet" type="text/css"
href="chrome://messenger/skin/tagColors.css"/>
<link rel="stylesheet" type="text/css"
href="chrome://conversations/skin/boxflex.css" />
<!-- Keep the order! -->
<link rel="stylesheet" type="text/css"
href="chrome://conversations/skin/conversation.css" />
<link rel="stylesheet" type="text/css"
href="chrome://conversations/skin/quickreply.css" />
<link rel="stylesheet" type="text/css"
href="chrome://conversations/skin/tokeninput.css" />
<link rel="stylesheet" type="text/css" media="print"
href="chrome://conversations/skin/print.css" />
<script type="text/javascript"
src="chrome://messenger/content/jquery.js"></script>
<script type="text/javascript"
src="chrome://conversations/content/js/jquery.text-overflow.js"></script>
<script type="text/javascript"
src="chrome://conversations/content/js/jquery.tmpl.js"></script>
<script type="text/javascript"
src="chrome://conversations/content/js/jquery.tokeninput.js"></script>
<!-- The two scripts below share the same scope, they were split for the sake
of readability. -->
<script type="application/javascript;version=1.8"
src="chrome://conversations/content/quickReply.js"></script>
<script type="application/javascript;version=1.8"
src="chrome://conversations/content/stub.compose-ui.js"></script>
<script type="application/javascript;version=1.8"
src="chrome://conversations/content/stub.compose-ui-bz.js"></script>
<script type="application/javascript;version=1.8"
src="chrome://conversations/content/stub.completion-ui.js"></script>
<script type="application/javascript;version=1.8"><![CDATA[
// Below are mostly UI utility functions.
(function ($) {
$.fn.vAlign = function(container) {
$(document).ready(function () {
if (!container)
container = "div";
this.each(function(i) {
$(this).wrap("<div />");
var el = $(this);
var elh = el.height(); //new element height
var ph = el.parent().height(); //parent height
var nh = (ph - elh) / 2; //new margin to apply
if (!nh) {
$(this).unwrap();
} else {
el.css('margin-top', nh);
// don't align again now we've succeeded
el.removeClass("align");
}
});
}.bind(this));
};
})(jQuery);
function clearMenu() {
let menus = document.getElementsByClassName("menu");
for each (let [, menu] in Iterator(menus))
menu.style.display = "none";
}
function displayMenu(event) {
let target = event.target;
// This is a hack to make it work when we click the downwardArrow.
if (!target.nextElementSibling)
target = target.parentNode;
let menu = target.nextElementSibling;
let menuWasVisible = (menu.style.display == "-moz-box")
|| (menu.style.display == "inline-block")
|| (menu.style.display == "block");
clearMenu();
if (!menuWasVisible) {
menu.style.display = "-moz-box";
event.stopPropagation();
}
}
$(document).ready(function () {
document.addEventListener("click", function (event) {
clearMenu();
}, false);
document.addEventListener("keypress", function (event) {
if (event.keyCode == KeyEvent.DOM_VK_ESCAPE)
clearMenu();
}, false);
});
function alignAttachments(aMsgNode) {
$(aMsgNode._domNode).find(".align").vAlign();
}
// This function only works for our message nodes, use $(...).offset() for
// more complicated computations.
function offsetFromTop (aNode) {
let offset = aNode.offsetTop || 0;
let parent = aNode.parentNode;
while (parent && !(parent instanceof HTMLDocument)) {
let style = window.getComputedStyle(parent, null);
if (style.position == "relative")
offset += parent.offsetTop;
parent = parent.parentNode;
}
return offset;
}
function scrollNodeIntoView (aNode) {
let offset = offsetFromTop(aNode);
// The header is 44px high (yes, this is harcodeadly ugly).
window.scrollTo(0, offset + 5 - 44);
}
function toggleQuote(event, showquotedtext, hidequotedtext) {
let link = event.target;
let div = link.nextSibling;
let cs = window.getComputedStyle(div, null);
if (div.style.display == "none") {
link.textContent = "- "+hidequotedtext+" -";
div.style.display = "";
let h = div.getBoundingClientRect().height +
parseFloat(cs.marginTop) + parseFloat(cs.marginBottom);
return h;
} else {
let h = div.getBoundingClientRect().height;
h += parseFloat(cs.marginTop);
h += parseFloat(cs.marginBottom);
link.textContent = "- "+showquotedtext+" -";
div.style.display = "none";
return -h;
}
}
const kPopupTimeout = 400;
// This only works for contact tooltips. The "more" menu is treated like a
// real menu (it uses displayMenu and falls under clearMenu's operations),
// and the reply menu with various choices is also treated like a menu.
// It turns out the "more" menu reuses the tooltip style for various
// reasons, mostly to keep the same appearance, so we differentiate that
// one with a tooltip-menu extra class.
function enableTooltips(aMsg) {
let $aMsgNode = $(aMsg._domNode);
$aMsgNode.find('.tooltip').each(function (i) {
// "details" is a hypothetical "details" link that, when
// hovered/clicked, starts the interaction with the tooltip
let $tooltip = $(this);
if ($tooltip.hasClass("tooltip-menu"))
return;
let $details = $tooltip.prev();
if ($details.hasClass("contactBr"))
$details = $details.prev();
let timeout;
$details.hover(
function() {
if (aMsg.collapsed)
return;
clearTimeout(timeout);
let self = this;
timeout = setTimeout(function () {
$(self).next(':hidden').fadeIn();
}, kPopupTimeout);
},
function() {
var self = this;
clearTimeout(timeout);
timeout = setTimeout(function () {
$(self).next(/*':visible'*/).fadeOut()
}, kPopupTimeout);
});
$tooltip.hover(
function () {
clearTimeout(timeout);
},
function () {
var self = this;
if ($(this).is(":visible")) {
clearTimeout(timeout);
timeout = setTimeout(function () {
$(self).fadeOut();
}, kPopupTimeout);
}
});
});
}
// Setting the second parameter to false means don't fire a stupid timer
// that lives forever everytime we call this function.
function fakeTextOverflowSubject() {
$(".subject").textOverflow(null, false);
}
function cleanup() {
// These shouldn't be necessary because we're blasting away everything by
// setting .innerHTML BUT jQuery won't remove its persistent event
// listeners if we don't do that which will in turn cause memory leaks!
// Indeed, the listeners are actually closures on Message instances. These
// contain a pointer to their parent Conversation, so that would prevent
// the GC from collecting anything! Argh!
$("#messageList").empty();
}
function openLink(event) {
gMessenger.launchExternalURL(event.originalTarget.getAttribute("href"));
}
document.addEventListener("focus", function (event) {
/* This is a persistent event listener. It can operate multiple
* times. We have the invariant that for a given conversation, there's at
* most one such element (recycling doesn't use tabindex 1). */
let msgNode = document.querySelector(".message[tabindex=\"1\"]");
if (!msgNode)
return;
/* Restore the proper tab order. This event is fired *after* the
* right message has been focused in Gecko 1.9.2, *before* the right
* message has been focused in Gecko 1.9.1 (so it's basically
* useless). */
let msgNodes = document.getElementsByClassName("message");
let index;
for each (let [i, k] in Iterator(msgNodes)) {
if (k == msgNode) {
index = i;
break;
}
}
if (index)
msgNode.setAttribute("tabindex", index+2);
}, true);
function closeTab() {
let browser = window.frameElement;
let tabmail = window.top.document.getElementById("tabmail");
let tabs = tabmail.tabInfo;
let candidates = tabs.filter(function (x) x.browser == browser);
if (candidates.length == 1) {
tabmail.closeTab(candidates[0]);
} else {
Log.error("Couldn't find a tab to close...");
}
}
function capitalize(str)
str.charAt(0).toUpperCase() + str.substring(1);
// Below are event listeners for various actions. There is some logic
// involved, and they may talk to other parts of the code.
// This property is now set from the outside. This allows stub.html to
// be used either in a standalone tab or in the multimessage pane.
// let Conversations = window.top.Conversations;
Components.utils.import("resource:///modules/mailServices.js");
Components.utils.import("resource://conversations/modules/stdlib/misc.js");
Components.utils.import("resource://conversations/modules/stdlib/msgHdrUtils.js");
Components.utils.import("resource://conversations/modules/prefs.js");
Components.utils.import("resource://conversations/modules/log.js");
Components.utils.import("resource://conversations/modules/contact.js");
let Log = setupLogging("Conversations.Stub");
let isOSX = ("nsILocalFileMac" in Components.interfaces);
let isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
let isInTab = false;
$(document).ready(function () {
let stylesheet = [x
for each ([, x] in Iterator(document.styleSheets))
if (String.indexOf(x.href, "/conversation.css") >= 0)][0];
if (stylesheet) {
if (Prefs.tweak_chrome) {
// Set the root size to 10px on Linux, and equivalent font sizes on
// other platforms.
if (isOSX)
stylesheet.insertRule("html { font-size: 66.6%; }", 0);
else if (isWindows)
stylesheet.insertRule("html { font-size: 70%; }", 0);
else
stylesheet.insertRule("html { font-size: 62.5%; }", 0);
} else {
stylesheet.insertRule("html { font-size: 83.3%; }", 0);
}
} else {
Log.error("No stylesheet. This is unexpected.");
}
});
// Mark the current conversation as read/unread. The conversation driver
// takes care of setting the right class on us whenever the state
// changes...
function toggleRead(event) {
let $span = $(event.target).find("span.read");
if ($span.hasClass("unread")) {
Conversations.currentConversation.read = true;
$span.removeClass("unread");
} else {
Conversations.currentConversation.read = false;
$span.addClass("unread");
markReadInView.disable();
}
}
function expandCollapse(event) {
let $span = $(event.target).find("span.expand");
if ($span.hasClass("collapse")) {
[message.collapse()
for each ([, { message }] in Iterator(Conversations.currentConversation.messages))];
$span.removeClass("collapse");
} else {
[message.expand()
for each ([, { message }] in Iterator(Conversations.currentConversation.messages))];
$span.addClass("collapse");
}
}
function archiveToolbar(event) {
if (isInTab || Prefs.operate_on_conversations)
archiveConversation(event);
else
msgHdrsArchive(topMail3Pane(window).gFolderDisplay.selectedMessages);
}
function archiveConversation(event) {
msgHdrsArchive(Conversations.currentConversation.msgHdrs);
}
function deleteToolbar(event) {
if (isInTab || Prefs.operate_on_conversations)
deleteConversation();
else
msgHdrsDelete(topMail3Pane(window).gFolderDisplay.selectedMessages);
}
function deleteConversation(event) {
msgHdrsDelete(Conversations.currentConversation.msgHdrs);
if (isInTab)
closeTab();
}
function forwardConversation(event) {
let conv = Conversations.currentConversation;
let fields = Cc["@mozilla.org/messengercompose/composefields;1"]
.createInstance(Components.interfaces.nsIMsgCompFields);
fields.characterSet = "UTF-8";
fields.bodyIsAsciiOnly = false;
fields.forcePlainText = false;
Conversations.currentConversation.exportAsHtml(function (html) {
fields.body = html;
let params = Cc["@mozilla.org/messengercompose/composeparams;1"]
.createInstance(Ci.nsIMsgComposeParams);
params.format = Ci.nsIMsgCompFormat.HTML;
params.composeFields = fields;
return MailServices.compose.OpenComposeWindowWithParams(null, params);
});
}
let oldPrint = window.print;
function printConversation(event) {
for each (let { message: m } in Conversations.currentConversation.messages) {
m.dumpPlainTextForPrinting();
}
oldPrint();
}
window.print = printConversation;
function junkConversation(event) {
// This callback is only activated when the conversation is not a
// conversation in a tab AND there's only one message in the conversation,
// i.e. the currently selected message
topMail3Pane(window).JunkSelectedMessages(true);
$("#conversationHeader").addClass("not-junkable");
}
const kGalleryUrl = "chrome://conversations/content/gallery/index.html";
function galleryView(uri) {
let tabmail = topMail3Pane(window).document.getElementById("tabmail");
tabmail.openTab("chromeTab", {
chromePage: kGalleryUrl+"?uri="+uri,
});
}
/**
* This function gathers various information, encodes it in a URL query
* string, and then opens a regular chrome tab that contains our
* conversation.
*/
function detachTab(event) {
let tabmail = topMail3Pane(window).document.getElementById("tabmail");
let willExpand = $("textarea").parent().hasClass("expand") && startedEditing();
// Pick _initialSet and not msgHdrs so as to enforce the invariant
// that the messages from _initialSet are in the current view.
let urls = [
msgHdrGetUri(x)
for each (x in Conversations.currentConversation._initialSet)
].join(",");
let queryString = "?urls="+encodeURIComponent(urls)
+"&willExpand="+Number(willExpand);
// First, save the draft, and once it's saved, then move on to opening the
// conversation in a new tab...
onSave(function () {
tabmail.openTab("chromeTab", {
chromePage: kStubUrl+queryString,
});
});
}
/**
* This function finds the right node that holds the attachment information
* and returns its information.
*/
function getCurrentAttInfo() {
let node = topMail3Pane(window).document.popupNode;
while (!node.attInfo)
node = node.parentNode;
return node.attInfo;
}
/**
* That big event handler tries to parse URL query parameters, and then acts
* upon these, by firing a conversation on its own. This is a very
* stripped-down version of the logic that's in monkeypatch.js, and it
* serves the purpose of being able to create a standalone conversation view
* in a new tab.
*/
$(document).ready(function () {
// I just imagined Javascript would have some function for that
// built-in... looks like even jQuery doesn't have it.
let params = decodeUrlParameters(document.location.href);
// Oh, are we expected to build a conversation on our own? Let's do it,
// yay!
if ("urls" in params) {
try {
let scrollMode = ("scrollMode" in params)
? parseInt(params.scrollMode)
: Prefs.kScrollUnreadOrLast;
/* If we start up Thunderbird with a saved conversation tab, then we
* have no selected message. Fallback to the usual mode. */
if (scrollMode == Prefs.kScrollSelected &&
!topMail3Pane(window).gFolderDisplay.selectedMessage)
scrollMode = Prefs.kScrollUnreadOrLast;
isInTab = true;
window.frameElement.setAttribute("tooltip", "aHTMLTooltip");
let mainWindow = topMail3Pane(window);
let willExpand = parseInt(params.willExpand);
let msgHdrs = [msgUriToMsgHdr(x) for each (x in params.urls.split(","))];
msgHdrs = msgHdrs.filter(function (x) x != null);
msgHdrs = msgHdrs.filter(function (x) x.messageId);
// It might happen that there are no messages left...
if (!msgHdrs.length) {
document.getElementById("messageList").textContent =
strings.get("messageMovedOrDeletedConversation");
} else {
window.Conversations = {
currentConversation: null,
counter: 0,
};
let freshConversation = new mainWindow.Conversations.monkeyPatch._Conversation(
window,
msgHdrs,
scrollMode,
++Conversations.counter
);
let browser = window.frameElement;
// Because Thunderbird still hasn't fixed that...
browser.setAttribute("context", "mailContext");
freshConversation.outputInto(browser, function (aConversation) {
// This is a stripped-down version of what's in monkeypatch.js,
// make sure the two are in sync!
Conversations.currentConversation = aConversation;
aConversation.completed = true;
registerQuickReply();
// That's why we saved it before...
newComposeSessionByDraftIf();
if (willExpand)
expandQuickReply();
// Create a new rule that will override the default rule, so that
// the expanded quick reply is twice higher.
document.body.classList.add("inTab");
// We can never junk a conversation in a new tab, because the junk
// command only operates on selected messages, and we're not in a
// 3pane context anymore.
document.getElementById("conversationHeader").classList.add("not-junkable");
// Do this now so as to not defeat the whole expand/collapse
// logic.
if (Prefs.getBool("mailnews.mark_message_read.auto")) {
setTimeout(function () {
msgHdrsMarkAsRead(msgHdrs, true);
}, Prefs.getInt("mailnews.mark_message_read.delay.interval")
* Prefs.getBool("mailnews.mark_message_read.delay") * 1000);
}
});
}
} catch (e) {
Log.debug(e);
dumpCallStack(e);
}
} else if ("quickCompose" in params) {
masqueradeAsQuickCompose();
}
});
var isQuickCompose = false;
function isAccel (event) (isOSX && event.metaKey || event.ctrlKey)
/* This is our new hack: reuse this file to provide a standalone composition
* window. Why? Because it uses gloda autocomplete and provides a
* no-frills composition experience. */
function masqueradeAsQuickCompose() {
isQuickCompose = true;
document.title = strings.get("write");
document.querySelector("#conversationHeader").style.display = "none";
document.querySelector(".bottom-links").style.display = "none";
document.querySelector("#messageList").style.marginTop = "0";
document.querySelector("#messageList").classList.add("quickCompose");
$("#quickReplyTemplate").tmpl().appendTo($("#messageList"));
$(".replyAll, #save, .replyMethod").remove();
showQuickReply.call($(".reply.expand"));
revealCompositionFields();
gComposeSession = createComposeSession(function (x) x.new());
editFields("to");
window.Conversations = {
currentConversation: {
msgHdrs: [],
id: null,
},
};
document.querySelector(".quickReply").addEventListener("keypress", function (event) {
switch (event.keyCode) {
case KeyEvent.DOM_VK_RETURN:
if (isAccel(event)) {
if (event.shiftKey)
gComposeSession.send({ archive: true });
else
gComposeSession.send();
}
break;
}
}, false);
document.querySelector(".popout").addEventListener("click", function (event) {
onUseEditor();
}, false);
let data = [];
// Push a new contact item in the list
let pushNewPopularContacts = function (n) {
let items = data.splice(0, n);
let nodes = $("#popularContactTemplate").tmpl(items);
for each (let [i, data2] in Iterator(items)) {
let data = data2;
let node = nodes.eq(i);
Log.debug("Adding", data.name, data.email);
node.find(".popularRemove").click(function () {
Log.debug("Removing", data.name, data.email);
// Mark it in the prefs
let unwantedRecipients = JSON.parse(Prefs.getString("conversations.unwanted_recipients"));
unwantedRecipients[data.email] = null;
Prefs.setString("conversations.unwanted_recipients",
JSON.stringify(unwantedRecipients));
// Update the UI
$(this).closest(".popularContact").remove();
pushNewPopularContacts(1);
});
node.find(".popularName").click(function () {
// Get all the current parameters
let to = JSON.parse($("#to").val());
let cc = JSON.parse($("#cc").val());
let bcc = JSON.parse($("#bcc").val());
// Append our new value
to.push(MailServices.headerParser.makeFullAddress(data.name, data.email));
// Re-set everything
let format = function (items)
[asToken(null, name, email, null) for each ([{ name, email }] in items.map(parseMimeLine))]
;
setupAutocomplete(format(to), format(cc), format(bcc));
// Remove the node!
node.remove();
pushNewPopularContacts(1);
});
}
nodes.appendTo($(".quickReplyContactsBox"));
};
$(".quickReplyContactsMoreLink").click(function () pushNewPopularContacts(10));
// Fill in the "10 most popular contacts" thing
let contactQuery = Gloda.newQuery(Gloda.NOUN_CONTACT);
contactQuery.orderBy("-popularity").limit(100);
let contactCollection = contactQuery.getCollection({
onItemsAdded: function(aItems, aCollection) {
},
onItemsModified: function(aItems, aCollection) {
},
onItemsRemoved: function(aItems, aCollection) {
},
onQueryCompleted: function(aCollection) {
let items = aCollection.items;
let unwantedRecipients = JSON.parse(Prefs.getString("conversations.unwanted_recipients"));
for each (let contact in items) {
if (contact.identities.length) {
let id = contact.identities[0];
let photoForAbCard = function (card) {
if (!card)
return defaultPhotoURI;
let url = card.getProperty("PhotoURI", "");
if (!url)
return defaultPhotoURI;
return url;
};
if (id.kind == "email" && !(id.value in unwantedRecipients)) {
// Log.debug("Pushing", id.value, contact.name, contact.popularity);
data.push({
email: id.value,
name: contact.name,
photo: photoForAbCard(id.abCard),
});
}
}
}
pushNewPopularContacts(10);
},
}, null);
contactCollection.becomeExplicit();
// Misc
if (!top.opener) {
window.frameElement.setAttribute("tooltip", "aHTMLTooltip");
window.frameElement.setAttribute("context", "mailContext");
}
}
// I'll never understand why JS doesn't have lexical scoping...
let tStrings = new StringBundle("chrome://conversations/locale/template.properties");
let str = function (x) {
try {
return tStrings.get(x);
} catch (e) {
Log.error("No such string", x);
Log.debug(e);
dumpCallStack(e);
}
};
// Mark a message as read if a user scrolls past top and bottom of an
// unread message.
function markReadInView(event) {
if (event.type == "keydown") {
// for scroll by keyboard shortcut
switch (event.which) {
case KeyEvent.DOM_VK_SPACE:
case KeyEvent.DOM_VK_TAB:
case KeyEvent.DOM_VK_PAGE_UP:
case KeyEvent.DOM_VK_PAGE_DOWN:
case KeyEvent.DOM_VK_UP:
case KeyEvent.DOM_VK_DOWN:
case KeyEvent.DOM_VK_F:
case KeyEvent.DOM_VK_B:
break;
default:
return;
}
}
document.removeEventListener("scroll", markReadInView, true);
clearTimeout(markReadInView.timeout);
markReadInView.timeout = setTimeout(function () {
document.addEventListener("scroll", markReadInView, true);
}, 200);
if (!Conversations.currentConversation)
return;
let pageTop = window.pageYOffset;
let pageBottom = pageTop + window.innerHeight;
let messages = Conversations.currentConversation.messages;
for each (let [i, { message }] in Iterator(messages)) {
if (!message.read && message.expanded) {
if (!message._topInView) {
let top = $(message._domNode).offset().top;
if (top > pageTop && top < pageBottom)
message._topInView = true;
}
if (!message._bottomInView) {
let footerClass = (i == messages.length - 1) ? ".quickReply" : ".messageFooter";
let bottom = $(message._domNode.querySelector(footerClass)).offset().top;
if (bottom > pageTop && bottom < pageBottom)
message._bottomInView = true;
}
if (message._topInView && message._bottomInView) {
message._topInView = false;
message._bottomInView = false;
message.read = true;
}
}
}
}
(function () {
let w = window;
markReadInView.enable = function () {
[w.document.addEventListener(x, w.markReadInView, true)
for each ([, x] in Iterator(["mouseover", "focus", "keydown"]))];
};
markReadInView.disable = function () {
w.clearTimeout(w.markReadInView.timeout);
[w.document.removeEventListener(x, w.markReadInView, true)
for each ([, x] in Iterator(["mouseover", "focus", "keydown", "scroll"]))];
};
})();
]]>
</script>
</head>
<body>
<menu id="attachmentMenu" type="context">
<menuitem label="&stub.context.open;" onclick="getCurrentAttInfo().open();"></menuitem>
<menuitem label="&stub.context.save;" onclick="getCurrentAttInfo().save();"></menuitem>
<menuitem label="&stub.context.detach;" onclick="getCurrentAttInfo().detach(true);"></menuitem>
<menuitem label="&stub.context.delete;" onclick="getCurrentAttInfo().detach(false);"></menuitem>
</menu>
<script id="detailsTemplate" type="text/x-jquery-tmpl"><![CDATA[
{{if dataContactsFrom.length}}
<div class="detailsLine fromLine">
<u>${str("fieldFrom")}</u>
{{tmpl(dataContactsFrom) "#contactTemplate"}}
</div>
{{/if}}
{{if dataContactsTo.length}}
<div class="detailsLine toLine">
<u>${str("fieldTo")}</u>
{{tmpl(dataContactsTo) "#contactTemplate"}}
</div>
{{/if}}
{{if dataContactsCc.length}}
<div class="detailsLine ccLine">
<u>${str("fieldCc")}</u>
{{tmpl(dataContactsCc) "#contactTemplate"}}
</div>
{{/if}}
{{if dataContactsBcc.length}}
<div class="detailsLine bccLine">
<u>${str("fieldBcc")}</u>
{{tmpl(dataContactsBcc) "#contactTemplate"}}
</div>
{{/if}}
{{each(i, line) extraLines}}
<div class="detailsLine">
<u>${line.key}:</u>
${line.value}
</div>
{{/each}}
]]>
</script>
<script id="messageTemplate" type="text/x-jquery-tmpl"><![CDATA[
<li class="message collapsed ${extraClasses}">
<div class="messageHeader hbox">
<div class="star"></div>
<div class="author">{{tmpl(dataContactFrom) "#contactTemplate"}}</div>
<div class="involved boxFlex">
<span class="to hide-with-details not-resized-yet"> ${str("to")} {{tmpl(dataContactsTo) "#contactTemplate"}}</span>
<span class="bzTo"> ${str("at")} ${bugzillaUrl}</span>
<span class="snippet"><ul class="tags regular-tags"></ul><ul
class="tags special-tags"
><li
class="tag-signed"
title="${str('messageSignedLong')}"
><img src="chrome://conversations/content/i/sign.png" />
${str("messageSigned")}</li
><li
class="tag-decrypted"
title="${str('messageDecryptedLong')}"
><img src="chrome://conversations/content/i/enc.png" />
${str("messageDecrypted")}</li
><li
class="in-folder"
title="${str('jumpToFolder')}"
>${str("inFolder").replace("#1", shortFolderName)}</li
></ul>${snippet}</span>
</div>
<div class="options">
<span class="date">
<span class="attachmentIcon">
{{tmpl "#attachmentIconTemplate"}}
</span>
<span title="${fullDate}">${date}</span>
</span>
<span class="details hide-with-details">
| <a href="javascript:" class="link">${str("details")}</a>
</span>
<span class="hide-details show-with-details">
| <a href="javascript:" class="link">${str("hideDetails")}</a>
</span>
<span class="replyLinkWrapper">
| <a href="javascript:" class="replyMainActionLink"></a>
</span>
<span class="editDraftLinkWrapper">
| <a href="javascript:" class="edit-draft">${str("editDraft2")}</a>
</span>
<span class="dropDown"> |
<a href="javascript:" onclick="displayMenu(event);" class="top-right-more">${str("more")} <span class="downwardArrow">▼</span></a>
<div class="tooltip tooltip-menu menu">
<ul>
<li class="action-reply">${str("reply")}
<div class="arrow"></div>
<div class="arrow inside"></div>
</li>
<li class="action-replyAll">${str("replyAll")}</li>
<li class="action-replyList">${str("replyList")}</li>
<li class="action-editNew">${str("editNew")}</li>
<li class="action-forward" style="border-bottom: 1px solid #aaa">${str("forward")}</li>
<li class="action-archive">${str("archive")}</li>
<li class="action-delete">${str("delete")}</li>
<li class="action-classic">${str("viewClassic")}</li>
<li class="action-source">${str("viewSource")}</li>
<li class="action-print" style="display: none;">${str("print")}</li>
</ul>
</div>
</span>
</div>
</div>
<div class="detailsPlaceholder show-with-details">
</div>
<div class="detailsLine">
{{tmpl "#attachmentDetailsTemplate"}}
</div>
<div class="lightningImipBar notificationBar" style="display: none">
<img class="lightningImipImage" src="chrome://calendar/skin/cal-icon32.png"/>
<span class="lightningImipText"></span>
<button class="lightningImipButton lightningImipButton1" style="display: none"/>
<button class="lightningImipButton lightningImipButton2" style="display: none"/>
<button class="lightningImipButton lightningImipButton3" style="display: none"/>
</div>
<div class="phishingBar notificationBar" style="display: none">
<img src="chrome://messenger/skin/icons/phishing.png" style="vertical-align: middle;" />
${str("scam")}
<span class="ignore-warning">
<a href="javascript:">${str("ignoreWarning")}</a>
</span>
</div>
<div class="remoteContent notificationBar" style="display: none">
${str("remoteContentBlocked")}
<span class="show-remote-content">
<a href="javascript:">${str("showRemote")}</a> -
</span>
<span class="always-display">
<a href="javascript:">${str("alwaysShowRemote").replace("#1", realFrom)}</a>
</span>
</div>
<div class="junkBar notificationBar" {{if !canUnJunk}}style="display: none"{{/if}}>
<img src="chrome://messenger/skin/icons/junk.png" style="vertical-align: middle;" />
${str("junk")}
<span class="notJunk">
<a href="javascript:">${str("notJunk")}</a>
</span>
</div>
<div class="outboxBar notificationBar" {{if !isOutbox}}style="display: none"{{/if}}>
<img src="chrome://conversations/skin/icons/outbox.png" style="vertical-align: middle;" />
${str("isOutbox")}
<span class="sendUnsent">
<a href="javascript:">${str("sendUnsent")}</a>
</span>
</div>
<div class="messageBody">
<!-- Weird markup to deal with whitespace DOM nodes -->
<ul class="tags special-tags"
><li
class="keep-tag tag-signed"
title="${str('messageSignedLong')}"
><img src="chrome://conversations/content/i/sign.png" />
${str("messageSigned")}</li
><li
class="keep-tag tag-decrypted"
title="${str('messageDecryptedLong')}"
><img src="chrome://conversations/content/i/enc.png" />
${str("messageDecrypted")}</li
><li
class="keep-tag in-folder"
title="${str('jumpToFolder')}"
>${str("inFolder").replace("#1", folderName)}</li
></ul
>
<ul class="tags regular-tags"></ul>
<div class="iframe-container"></div>
<div class="body-container"></div>
<div class="attachments-container">
{{tmpl "#attachmentsTemplate"}}
</div>
<div class="embedsContainer">
</div>
</div>
<div class="messageFooter">
<div class="footerActions">
<button class="edit-draft"><span>${str("editDraft2")}</span><span class="ext"></span></button>
<button class="buttonReply"><span>${str("reply")}</span><span class="ext"></span></button>
<button class="buttonReplyAll"><span>${str("replyAll")}</span><span class="ext"></span></button>
<button class="buttonReplyList"><span>${str("replyList")}</span><span class="ext"></span></button>
<button class="buttonForward">${str("forward")}<span class="ext"></span></button>
</div>
</div>
{{if quickReply}}
{{tmpl "#quickReplyTemplate"}}
{{/if}}
</li>
]]>
</script>
<!-- Weird markup again, otherwise, the comma is separated from the name by a
space because of the #text whitespace-only nodes that end up in the DOM.
-->
<script id="contactTemplate" type="text/x-jquery-tmpl"><![CDATA[<span
>${separator}</span
><span class="tooltipWrapper contact"
><span class="contactName" style="${colorStyle}"
>{{if star}}★ {{/if}}${String.trim(name)}{{if writeBr}}<br />{{/if}}</span
><div class="tooltip">
<div class="arrow"></div>
<div class="arrow inside"></div>
<div class="authorInfo">
<span class="name">${tooltipName}</span>
<span class="authorEmail">
${email}
<button class="copyEmail" title="${str('copyEmail')}">
<img src="chrome://conversations/content/i/clipboard.png" />
</button>
</span>
</div>
<div class="authorPicture">
<img src="${avatar}" />
</div>
<div class="authorInfo authorLinks">
{{if ("facebook" in profiles)}}
<a href="http://www.facebook.com/profile.php?id=${profiles.facebook}" class="profile-link">
<img src="chrome://conversations/content/i/facebook.ico" />
</a>
{{/if}}
{{if ("twitter" in profiles)}}
<a href="http://www.twitter.com/${profiles.twitter}" class="profile-link">
<img src="chrome://conversations/content/i/twitter.ico" />
</a>
{{/if}}
{{if ("google" in profiles)}}
<a href="${profiles.google}" class="profile-link">
<img src="chrome://conversations/content/i/google.ico" />
</a>
{{/if}}
{{if ("flickr" in profiles)}}
<a href="${profiles.flickr}" class="profile-link">
<img src="chrome://conversations/content/i/flickr.ico" />
</a>
{{/if}}
</div>
<div class="tipFooter hiddenFooter" style="display:none;">
{{if (showMonospace)}}
<div style="margin-bottom:5px;">
<input type="checkbox" style="vertical-align: text-top" class="checkbox-monospace" />
<label style="color:#666; font-weight: normal">${str("messagesMonospace")}</label>
</div>
{{/if}}
<button class="createFilter">${str("createFilter")}</button>
<button class="addContact" title="${str('addToAb')}">
<img src="chrome://conversations/content/i/user_add.png" />
</button>
<button class="editContact" title="${str('editCardAb')}">
<img src="chrome://conversations/content/i/user_edit.png" />
</button>
</div>
<div class="tipFooter">
<button class="sendEmail">${str("sendEmail")}</button>
<button class="showInvolving">${str("recentConversations")}</button>
<button class="moreExpander">+</button>
</div>
</div
></span
>]]></script>
<script id="attachmentIconTemplate" type="text/x-jquery-tmpl"><![CDATA[
{{if attachments.length}}
<img src="chrome://conversations/content/i/attachment.png" />
{{/if}}
]]></script>
<script id="attachmentDetailsTemplate" type="text/x-jquery-tmpl"><![CDATA[