Guest User

rp

a guest
Jan 14th, 2020
587
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2. * Roundcube webmail functions for the Elastic skin
  3. *
  4. * Copyright (c) The Roundcube Dev Team
  5. *
  6. * The contents are subject to the Creative Commons Attribution-ShareAlike
  7. * License. It is allowed to copy, distribute, transmit and to adapt the work
  8. * by keeping credits to the original autors in the README file.
  9. * See http://creativecommons.org/licenses/by-sa/3.0/ for details.
  10. *
  11. * @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
  12. */
  13. /*
  14. magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
  15. */
  16. function rcube_elastic_ui() {
  17. function n(a, b, c) {
  18. (a = w(a)) && rcmail.register_button(a.command, b, a.data.type, c, a.data.sel)
  19. }
  20. function t(a, b, c, d) {
  21. var e = !0
  22. , g = $("<a>")
  23. , l = a.attr("id") || (new Date).getTime()
  24. , k = l + "-clone";
  25. c = a[0].className + (c ? " " + c : "");
  26. if (!b)
  27. c = $.trim(c.replace("btn-primary", "primary").replace(/(btn[a-z-]*|button|disabled)/g, "")),
  28. c += " button" + (d ? "" : " disabled");
  29. else if (d = a.data("popup"))
  30. g.data({
  31. popup: d,
  32. "toggle-button": a.data("toggle-button")
  33. }),
  34. D(g[0]),
  35. e = !1,
  36. rcmail.register_menu_button(g[0], d);
  37. g.attr({
  38. id: k,
  39. href: "#",
  40. "class": c
  41. }).append($('<span class="inner">').text(a.text()));
  42. if (e)
  43. g.on("click", function(b) {
  44. a.click()
  45. });
  46. p && !b ? (g.data("target", a),
  47. T.push($.extend({
  48. button_id: k
  49. }, w(a[0].id)))) : n(l, k, c.replace(" disabled", ""));
  50. return g
  51. }
  52. function w(a) {
  53. var b, c;
  54. for (c in rcmail.buttons)
  55. for (b = 0; b < rcmail.buttons[c].length; b++) {
  56. var d = rcmail.buttons[c][b];
  57. if (d.id == a)
  58. return {
  59. command: c,
  60. index: b,
  61. data: d
  62. }
  63. }
  64. }
  65. function A() {
  66. $("[data-list]").filter("ul,table").each(function() {
  67. var a, b = $(this), d = b.data("list");
  68. if (rcmail[d] && rcmail[d].multiselect) {
  69. var c = b.parents("layout-sidebar,#layout-list,#layout-content").last();
  70. var e = c.find(".header");
  71. var h = e.find("ul");
  72. if (!h.length)
  73. h = e;
  74. else if (a = h.find("a.select").data("toggle-button"))
  75. a = $("#" + a);
  76. rcmail[d].enable_checkbox_selection();
  77. a || (a = $("<a>").attr({
  78. "class": "button selection disabled",
  79. role: "button",
  80. title: rcmail.gettext("select")
  81. }).on("click", function() {
  82. $(this).is(".active") && b.toggleClass("withselection")
  83. }).append($('<span class="inner">').text(rcmail.gettext("select"))),
  84. h.is(".menu") ? (a.prependTo(h).wrap('<li role="menuitem">'),
  85. f.content && (c = t(a, !0, "hidden-big hidden-large"),
  86. $('<li role="menuitem">').append(c).appendTo("#toolbar-menu"),
  87. a = a.add(c))) : (e = b.data("list-select-replace")) ? $(e).replaceWith(a) : (a.appendTo(h).addClass("icon"),
  88. c.is("#layout-sidebar") || a.addClass("toolbar-button")));
  89. rcmail.addEventListener("listupdate", function(b) {
  90. b.list && b.list == rcmail[d] && (b.rowcount ? a.addClass("active").removeClass("disabled").attr("tabindex", 0) : a.removeClass("active").addClass("disabled").attr("tabindex", -1))
  91. })
  92. }
  93. J && rcmail[d] && ("function" == typeof rcmail[d].draggable ? rcmail[d].draggable("destroy") : "boolean" == typeof rcmail[d].draggable && (rcmail[d].draggable = !1))
  94. });
  95. window.MutationObserver && $("[data-label-msg]").filter("ul,table").each(function() {
  96. var a = $('<div class="listing-info hidden">').insertAfter(this)
  97. , b = $(this);
  98. var d = function() {
  99. var d = b.data("label-msg");
  100. var c = b.is("ul") ? b : b.children("tbody");
  101. if (rcmail.env.search_request || rcmail.env.qsearch || !d || c.children(":visible").length)
  102. a.addClass("hidden");
  103. else {
  104. c = b.data("label-ext");
  105. var g = b.data("create-command");
  106. !c || g && !rcmail.commands[g] || (d += " " + c);
  107. a.text(d).removeClass("hidden")
  108. }
  109. };
  110. var c = function() {
  111. if (rcmail.busy || !b.is(":visible"))
  112. return setTimeout(c, 250);
  113. clearTimeout(h.list_timer);
  114. h.list_timer = setTimeout(d, 50)
  115. };
  116. (new MutationObserver(c)).observe(b[0], {
  117. childList: !0,
  118. subtree: !0,
  119. attributes: !0,
  120. attributeFilter: ["style"]
  121. });
  122. c()
  123. });
  124. "print" != rcmail.env.action && $("#attachment-list > li").each(function() {
  125. U(this)
  126. });
  127. var a = function(a) {
  128. "phone" == q && rcmail.display_message(rcmail.gettext(a), "confirmation")
  129. };
  130. rcmail.addEventListener("fileappended", function(b) {
  131. b.attachment.complete && (U(b.item),
  132. "text/vcard" == b.attachment.mimetype && rcmail.commands["attach-vcard"] && a("vcard_attachments.vcardattached"))
  133. }).addEventListener("managesieve.insertrow", function(a) {
  134. u(a.obj)
  135. }).addEventListener("add-recipient", function() {
  136. a("recipientsadded")
  137. });
  138. rcmail.init_pagejumper(".pagenav > input");
  139. if ("mail" == rcmail.task) {
  140. if ("compose" == rcmail.env.action && (rcmail.addEventListener("compose-encrypted", function(a) {
  141. $("a.mode-html, button.attach").prop("disabled", a.active);
  142. $("a.attach, a.responses:not(.edit)")[a.active ? "addClass" : "removeClass"]("disabled")
  143. }),
  144. $("#layout-sidebar > .footer:not(.pagenav) > a.button").click(function() {
  145. $(this).is(".disabled") && rcmail.display_message(rcmail.gettext("nocontactselected"), "warning")
  146. }),
  147. window.MutationObserver)) {
  148. var b = $("#attachment-list")
  149. , c = function() {
  150. V("attach", 0 < b.children().length)
  151. };
  152. (new MutationObserver(c)).observe(b[0], {
  153. childList: !0
  154. });
  155. c()
  156. }
  157. rcmail.env.extwin || "compose" != rcmail.env.action && "show" != rcmail.env.action || $("a.mail", f.menu).attr("onclick", "return rcmail.command('list','',this,event)");
  158. "preview" != rcmail.env.action && "show" != rcmail.env.action || $("a").filter('[href^="mailto:"]').each(function() {
  159. ia(this)
  160. })
  161. } else
  162. "settings" == rcmail.task && (rcmail.addEventListener("identity-encryption-show", function(a) {
  163. u(a.container)
  164. }),
  165. rcmail.addEventListener("identity-encryption-update", function(a) {
  166. u(a.container)
  167. }));
  168. rcmail.set_env({
  169. thread_padding: "1.5rem",
  170. popup_width_small: 1025,
  171. popup_width: 1200
  172. });
  173. rcmail.env.devel_mode && window.less ? less.pageLoadFinished.then(function() {
  174. E();
  175. rcmail.env.compose_focus_elem && $(rcmail.env.compose_focus_elem).focus()
  176. }) : E();
  177. var d = rcmail.env.date_format_localized;
  178. if (d) {
  179. var e = function(a) {
  180. $(a).filter(".datepicker").attr("placeholder", d);
  181. $(a).parent().find("select").each(function() {
  182. K(this)
  183. })
  184. };
  185. $("input.datepicker").each(function() {
  186. e(this)
  187. });
  188. rcmail.addEventListener("insert-edit-field", e)
  189. }
  190. }
  191. function u(a) {
  192. a || (a = document);
  193. $("input.button,button", a).not(".btn").addClass("btn").not(".btn-primary,.primary,.mainaction").addClass("btn-secondary");
  194. $("input.button.mainaction,button.primary,button.mainaction", a).addClass("btn-primary");
  195. $("button.btn.delete,button.btn.discard", a).addClass("btn-danger");
  196. $.each(["warning", "error", "information", "confirmation"], function() {
  197. var b = this;
  198. $(".box" + b + ":not(.ui.alert)", a).each(function() {
  199. L(this, b, !0)
  200. })
  201. });
  202. if (a != document && 1 == $(".popup", a).children().length) {
  203. var b = $(".popup", a).children().first();
  204. if (b.is("img"))
  205. $(".popup", a).addClass("justified");
  206. else if (b.is("label")) {
  207. var c = b.find("input").detach();
  208. b = b.detach();
  209. var d = c.attr("id");
  210. d || c.attr("id", d = "dialog-input-elastic");
  211. $(".popup", a).addClass("formcontent").append($('<div class="form-group row">').append(b.attr("for", d).addClass("col-sm-2 col-form-label")).append($('<div class="col-sm-10">').append(c)));
  212. c.focus()
  213. }
  214. }
  215. $("input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox]),textarea", $(".propform", a)).addClass("form-control");
  216. $("[type=checkbox]", $(".propform", a)).addClass("form-check-input");
  217. $("select", a).addClass("form-control custom-select");
  218. a != document && $("input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox]),textarea", a).addClass("form-control");
  219. $("table.propform", a).each(function() {
  220. var a = 0
  221. , b = 0
  222. , d = ["sm", 4, 8];
  223. $(this).attr("class").match(/cols-([a-z]+)-(\d)-(\d)/) && (d = [RegExp.$1, RegExp.$2, RegExp.$3]);
  224. $(this).find("> tbody > tr, > tr").each(function() {
  225. var c = $(this)
  226. , g = ["form-group", "row"];
  227. var e = c.children("td");
  228. if (2 == e.length) {
  229. var l = e.first();
  230. e = e.last();
  231. $("label", l).addClass("col-form-label");
  232. l.addClass("col-" + d[0] + "-" + d[1]);
  233. e.addClass("col-" + d[0] + "-" + d[2]);
  234. 1 != e.find("[type=checkbox]").length || e.find(".proplist").length ? e.find("input:not([type=hidden]),textarea,radio,select").length ? b++ : (e.addClass("form-control-plaintext"),
  235. a++) : (g.push("form-check"),
  236. e.find("a").length && g.push("with-link"),
  237. b++);
  238. e.children(".datepicker") && 2 == e.children("input").length && e.addClass("datetime")
  239. } else
  240. 1 == e.length && e.css("width", "100%");
  241. c.addClass(g.join(" "))
  242. });
  243. a > b && $(this).addClass("text-only")
  244. });
  245. $("td.input-group", a).each(function() {
  246. $(this).children().slice(1).addClass("input-group-append")
  247. });
  248. $("fieldset.propform:not(.groupped) div.row", a).each(function() {
  249. var a = 0 < $("input:not([type=hidden]),select,textarea", this).length;
  250. a && $("input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox]),textarea", this).addClass("form-control");
  251. $(this).children().last().addClass("col-sm-8" + (a ? "" : " form-control-plaintext"));
  252. $(this).children().first().addClass("col-sm-4 col-form-label");
  253. $(this).addClass("form-group")
  254. });
  255. $("fieldset.propform.groupped fieldset", a).each(function() {
  256. $(".row", this).each(function() {
  257. var a = 0 < $("input,select,textarea", this).length
  258. , b = $(this).children();
  259. a && $("input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox]),textarea", this).addClass("form-control");
  260. if (!(2 > b.length)) {
  261. var d = b.first();
  262. d.is("select") ? d.addClass("input-group-prepend") : d.wrap('<span class="input-group-prepend">').addClass("input-group-text");
  263. a || b.last().addClass("form-control-plaintext");
  264. $(".content", this).addClass("input-group-prepend input-group-append input-group-text");
  265. $("a.deletebutton", this).addClass("input-group-text icon delete").wrap('<span class="input-group-append">');
  266. $(this).addClass("input-group")
  267. }
  268. })
  269. });
  270. $("fieldset.advanced", a).each(function() {
  271. var a = $(this).children(".propform").first();
  272. a.wrap($("<div>").addClass("collapse"));
  273. $(this).children("legend").first().addClass("closed").on("click", function() {
  274. a.parent().collapse("toggle");
  275. $(this).toggleClass("closed")
  276. })
  277. });
  278. $(".propform > .prop.block:not(.row)", a).each(function() {
  279. $(this).addClass("form-group row").each(function() {
  280. $("label", this).addClass("col-form-label").wrap($('<div class="col-sm-4">'));
  281. $("input,select,textarea", this).wrap($('<div class="col-sm-8">'));
  282. $("input:not(.button,.no-bs,[type=button],[type=radio],[type=checkbox]),textarea", this).addClass("form-control")
  283. })
  284. });
  285. $("td.rowbuttons > a", a).addClass("btn");
  286. $("form.tabbed,div.tabbed", a).each(function(a, b) {
  287. var d = []
  288. , c = $("<ul>").attr({
  289. "class": "nav nav-tabs",
  290. role: "tablist"
  291. });
  292. $(this).addClass("tab-content").children("fieldset").each(function(b, c) {
  293. b = c.id || "tab" + a + "-" + b;
  294. var e = $(c).data("navlink-class");
  295. $(c).addClass("tab-pane").attr({
  296. id: b,
  297. role: "tabpanel"
  298. });
  299. b = $("<li>").addClass("nav-item").append($("<a>").addClass("nav-link" + (e ? " " + e : "")).attr({
  300. role: "tab",
  301. href: "#" + b
  302. }).text($("legend", c).first().text()).click(function(a) {
  303. $(this).tab("show");
  304. x(a);
  305. return !1
  306. }));
  307. $("legend", c).first().hide();
  308. d.push(b)
  309. });
  310. c.append(d).insertBefore(b);
  311. $("a.nav-link", c).first().click()
  312. });
  313. $("input[type=file]:not(.custom-file-input)", a).each(function() {
  314. var a = rcmail.gettext("choosefile" + (this.multiple ? "s" : ""))
  315. , b = $("<label>").attr({
  316. "class": "custom-file-label",
  317. "data-browse": rcmail.gettext("browse")
  318. }).text(a);
  319. $(this).addClass("custom-file-input").wrap('<div class="custom-file">');
  320. $(this).on("change", function() {
  321. var b = a;
  322. this.files.length && (b = this.files[0].name,
  323. 1 < this.files.length && (b += ", ..."));
  324. $(this).next().text(b)
  325. }).parent().append(b)
  326. });
  327. $("table:not(.table,.compact-table,.propform,.listing,.ui-datepicker-calendar)", a).filter(function() {
  328. return !$(this).parent().is(".propform") && !$(this).parents(".message-htmlpart,.message-partheaders,.boxinformation,.raw-tables").length
  329. }).each(function() {
  330. var a = $(this).addClass("table");
  331. a.parent().addClass("table-responsive-sm");
  332. a.find("thead").addClass("thead-default")
  333. });
  334. $("input.pretty-checkbox, .propform input[type=checkbox], .form-check input, .popupmenu.form input[type=checkbox], .menu input[type=checkbox]", a).each(function() {
  335. F(this)
  336. });
  337. $(a).is(".actionrow") && $("input[type=checkbox]", a).each(function() {
  338. F(this)
  339. });
  340. $(".input-group-combo > select", a).first().on("change", function() {
  341. var a = $(this)
  342. , b = function() {
  343. a[a.next().is(":visible") ? "removeClass" : "addClass"]("alone")
  344. };
  345. setTimeout(b, 50);
  346. setTimeout(b, 2E3)
  347. }).trigger("change");
  348. $("#message-objects", a).children(":not(.ui.alert)").add(".part-notice").each(function() {
  349. var a = $(this).removeClass("notice part-notice").attr("class").split(/\s/)[0] || "warning";
  350. L(this, a);
  351. $(this).addClass("box" + a);
  352. $("a", this).addClass("btn btn-primary btn-sm")
  353. });
  354. $(".error", a).addClass("is-invalid");
  355. "login" == rcmail.env.task && a == document && ($("#rcmloginsubmit").addClass("btn-lg text-uppercase w-100"),
  356. $("#login-form table tr").each(function() {
  357. var a = $("input,select", this)
  358. , b = $("label", this)
  359. , d = a.data("icon")
  360. , c = $("<i>").attr("class", "input-group-text icon " + a.attr("name").replace("_", ""));
  361. d && c.addClass(d);
  362. $(this).addClass("form-group row");
  363. b.parent().css("display", "none");
  364. a.addClass(a.is("select") ? "custom-select" : "form-control").attr("placeholder", b.text()).before($('<span class="input-group-prepend">').append(c)).parent().addClass("input-group input-group-lg")
  365. }));
  366. $("select:not([multiple])", a).each(function() {
  367. K(this)
  368. })
  369. }
  370. function ja(a) {
  371. if ($(a).is(".mce-window")) {
  372. var b = $(a).find(".mce-window-body")
  373. , c = $(a).find(".mce-foot > .mce-container-body");
  374. b.length && u(b[0]);
  375. b.find("button").filter(function() {
  376. return 0 < $(this).parent(".mce-btn").length
  377. }).removeClass("btn btn-secondary");
  378. 5 === c.children(".mce-widget").length && c.addClass("mce-search-foot");
  379. $(a).find(".mce-charmap").parent().parent().addClass("mce-charmap-dialog");
  380. $(a).find(".mce-combobox").each(function() {
  381. $(this).children(".mce-btn").length || $(this).addClass("mce-combobox-fake")
  382. });
  383. $(a).find(".mce-form > .mce-container-body").each(function() {
  384. 4 < $(this).children(".mce-formitem").length && $(this).addClass("mce-form-split")
  385. });
  386. $(a).find(".mce-form").next(":not(.mce-formitem)").addClass("mce-form");
  387. if (!r()) {
  388. var d = 0;
  389. c = b.height();
  390. $(a).find(".mce-form").each(function() {
  391. d = Math.max(d, $(this).height())
  392. });
  393. c < d && (d += (b.find(".mce-tabs").height() || 0) + 25,
  394. b.height(d),
  395. $(a).height($(a).height() + (d - c)),
  396. $(a).css("top", ($(window).height() - $(a).height()) / 2 + "px"))
  397. }
  398. } else
  399. $(a).is(".mce-menu") && ($(a).prepend($('<h3 class="popover-header">').append($('<a class="button icon "cancel">').text(rcmail.gettext("close")).on("click", function() {
  400. $(document.body).click()
  401. }))),
  402. window.MutationObserver && (new MutationObserver(function() {
  403. "phone" == q && ($(".mce-menu:visible").length ? $("div.mce-overlay").length || $("<div>").attr("class", "popover-overlay mce-overlay").appendTo("body").click(function() {
  404. $(this).remove()
  405. }) : $("div.mce-overlay").click())
  406. }
  407. )).observe(a, {
  408. attributes: !0
  409. }))
  410. }
  411. function ka(a, b) {
  412. if (a.match(/_action=(create|add)/) || a.match(/_nav=hide/))
  413. $(h.frame_nav).addClass("hide-nav-buttons");
  414. else {
  415. var c, d, e;
  416. if ((a = $("[data-list]", f.list).data("list")) && (e = rcmail[a])) {
  417. $(h.frame_nav).removeClass("hide-nav-buttons hidden");
  418. if (d = e.get_single_selection())
  419. e.rows && e.rows[d] && !e.rows[d].expanded ? e.expand_row(b, d) : e.get_node && (c = e.get_node(d)) && c.collapsed && e.expand(d);
  420. var g, l, k = $("#" + rcmail.env.contentframe);
  421. b = $("a.button.next", h.frame_nav).off("click").addClass("disabled");
  422. c = $("a.button.prev", h.frame_nav).off("click").addClass("disabled");
  423. if ((l = e.get_next()) || rcmail.env.current_page < rcmail.env.pagecount)
  424. b.removeClass("disabled").on("click", function() {
  425. h.content_lock = !0;
  426. G(k);
  427. l ? e.select(l) : (rcmail.env.list_uid = "FIRST",
  428. rcmail.command("nextpage"))
  429. });
  430. if ((g = e.get_prev()) && ("*" != g || "subscription_list" != a) || 1 < rcmail.env.current_page)
  431. c.removeClass("disabled").on("click", function() {
  432. h.content_lock = !0;
  433. G(k);
  434. g ? e.select(g) : (rcmail.env.list_uid = "LAST",
  435. rcmail.command("previouspage"))
  436. })
  437. } else
  438. $(h.frame_nav).is(".hide-nav-buttons") && !$(".buttons", h.frame_nav).children().length && $(h.frame_nav).addClass("hidden")
  439. }
  440. }
  441. function la(a) {
  442. var b = []
  443. , c = $("#" + a.id).is("[data-html-editor]");
  444. a.config.plugins += " autoresize";
  445. H().touch && (a.config.toolbar_items_size = null,
  446. a.config.toolbar = "undo redo | insert | styleselect",
  447. a.config.plugins.match(/emoticons/) && (a.config.toolbar += " emoticons"));
  448. if ("mail" == rcmail.task && "compose" == rcmail.env.action) {
  449. var d = $("#compose-content > form")
  450. , e = function(a) {
  451. "Tab" == a.key && a.shiftKey && $("#compose-content > form").scrollTop(0)
  452. };
  453. b.push(function(a) {
  454. a.on("keypress", e)
  455. });
  456. $("#composebody").on("keypress", e);
  457. d.on("scroll", function() {
  458. var a = $(".mce-container-body", d)
  459. , b = $(".mce-top-part", a)
  460. , c = a.offset()
  461. , e = d.offset().top;
  462. c && 0 > c.top - e ? b.css({
  463. position: "fixed",
  464. top: e + "px",
  465. width: a.width() + "px"
  466. }) : b.css({
  467. position: "relative",
  468. top: 0,
  469. width: "auto"
  470. })
  471. });
  472. $(window).resize(function() {
  473. d.trigger("scroll")
  474. })
  475. }
  476. c && (a.config.toolbar = "plaintext | " + a.config.toolbar,
  477. a.config.setup_callback = function(a) {
  478. a.addButton("plaintext", {
  479. tooltip: rcmail.gettext("plaintoggle"),
  480. icon: "plaintext",
  481. onclick: function(b) {
  482. rcmail.command("toggle-editor", {
  483. id: a.id,
  484. html: !1
  485. }, "", b.originalEvent) && $("#" + a.id).parent().removeClass("ishtml")
  486. }
  487. })
  488. }
  489. );
  490. rcmail.addEventListener("editor-load", function(a) {
  491. $.each(b, function() {
  492. this(a.ref.editor)
  493. })
  494. })
  495. }
  496. function W(a) {
  497. $("ul", a.obj).addClass("menu listing iconized");
  498. $(a.obj).addClass("popupmenu popover");
  499. u(a.obj);
  500. $("input", a.obj).addClass("form-control");
  501. if (r() && $(a.obj).is(".googie_window")) {
  502. var b = rcmail.gettext("close");
  503. b = $("<a>").attr("class", "button icon cancel").text(b).click(function(b) {
  504. b.stopPropagation();
  505. $(".popover-overlay").remove();
  506. $(a.obj).hide()
  507. });
  508. $('<h3 class="popover-header">').append(b).prependTo(a.obj);
  509. $(".popover-overlay").length || $("<div>").attr("class", "popover-overlay").appendTo("body").click(function() {
  510. $(this).remove()
  511. });
  512. $("ul,button", a.obj).click(function(a) {
  513. $(a.target).is("input") || $(".popover-overlay").remove()
  514. })
  515. }
  516. }
  517. function ma(a) {
  518. p && $.each(T, function(b, d) {
  519. if (a.command == d.command)
  520. parent.$("#" + d.button_id)[a.status ? "removeClass" : "addClass"]("disabled")
  521. });
  522. if ("mail" == rcmail.task)
  523. switch (a.command) {
  524. case "reply-list":
  525. if (1 == rcmail.env.reply_all_mode) {
  526. var b = rcmail.gettext(a.status ? "replylist" : "replyall");
  527. $(".toolbar a.reply-all").attr("title", b).find(".inner").text(b)
  528. }
  529. break;
  530. case "compose-encrypted":
  531. a.status && $(".toolbar a.encrypt").parent().show();
  532. break;
  533. case "compose-encrypted-signed":
  534. $("#encryption-menu-button").show()
  535. }
  536. }
  537. function X() {
  538. var a = $(window).width();
  539. J = 1024 >= a;
  540. q = 480 >= a ? "phone" : 1200 < a ? "large" : 768 < a ? "normal" : "small"
  541. }
  542. function E() {
  543. var a;
  544. X();
  545. M();
  546. na();
  547. (a = r()) ? (rcmail.set_env(h.small_screen_config),
  548. rcmail.enable_command("extwin", !1)) : (rcmail.set_env(h.config),
  549. rcmail.enable_command("extwin", !0));
  550. $.each(N, function() {
  551. $(this)[a ? "hide" : "show"]()
  552. })
  553. }
  554. function M() {
  555. if (!p || f.sidebar.length || f.list.length) {
  556. switch (q) {
  557. case "phone":
  558. Y();
  559. y(!1);
  560. break;
  561. case "small":
  562. Y();
  563. y(!0);
  564. break;
  565. case "normal":
  566. oa();
  567. break;
  568. case "large":
  569. pa()
  570. }
  571. "phone" == q && $("#logo").data("src-small") ? $("#logo").attr("src", $("#logo").data("src-small")) : $("#logo").attr("src", $("#logo").data("src-default"));
  572. B();
  573. bw.webkit && bw.ipad && bw.agent.match(/OS 9/) && $(".iframe-wrapper").each(function() {
  574. var a = $(this).height();
  575. a && $(this).children("iframe").height(a)
  576. })
  577. } else
  578. B()
  579. }
  580. function na() {
  581. var a = H()
  582. , b = $(document.documentElement);
  583. b[0].className.match(/layout-([a-z]+)/) ? RegExp.$1 != a.mode && b.removeClass("layout-" + RegExp.$1).addClass("layout-" + a.mode) : b.addClass("layout-" + a.mode);
  584. a.touch && !b.is(".touch") ? b.addClass("touch") : !a.touch && b.is(".touch") && b.removeClass("touch")
  585. }
  586. function B() {
  587. $("#layout > div > .header").each(function() {
  588. var a, b = 0, c = 0, d = {
  589. left: 0,
  590. right: 0
  591. };
  592. $(this).children(":visible:not(.position-absolute)").each(function() {
  593. !a && $(this).is(".header-title") ? a = $(this) : d[a ? "right" : "left"] += this.offsetWidth
  594. });
  595. 0 + d.right >= d.left ? (b = 0,
  596. c = d.right + 0 - d.left) : (c = 0,
  597. b = d.left - (0 + d.right));
  598. $(a).css({
  599. "margin-right": b + "px",
  600. "margin-left": c + "px",
  601. "padding-right": "0px"
  602. })
  603. })
  604. }
  605. function oa() {
  606. if (f.list.length) {
  607. var a = f.list.is(h.last_selected) || !f.sidebar.is(h.last_selected) && !f.sidebar.is(".layout-sticky");
  608. f.list[a ? "removeClass" : "addClass"]("hidden")
  609. }
  610. f.sidebar.length && (a = !f.list.length || f.sidebar.is(h.last_selected) || f.sidebar.is(".layout-sticky"),
  611. f.sidebar[a ? "removeClass" : "addClass"]("hidden"));
  612. f.content.removeClass("hidden");
  613. y(!0);
  614. Z();
  615. f.list.length && $(".header > ul.menu", f.list).addClass("popupmenu")
  616. }
  617. function pa() {
  618. $.each(f, function(a, b) {
  619. b.removeClass("hidden")
  620. });
  621. Z();
  622. f.list && $(".header > ul.menu.popupmenu", f.list).removeClass("popupmenu")
  623. }
  624. function Y() {
  625. var a = !1;
  626. if (f.content.length) {
  627. var b = a = f.content.is(h.last_selected);
  628. f.content[b ? "removeClass" : "addClass"]("hidden");
  629. $(".header > ul.menu", f.content).addClass("popupmenu")
  630. }
  631. f.list.length && (b = !a && f.list.is(h.last_selected),
  632. f.list[b ? "removeClass" : "addClass"]("hidden"),
  633. $(".header > ul.menu", f.list).addClass("popupmenu"));
  634. f.sidebar.length && (b = !a && (f.sidebar.is(h.last_selected) || !f.list.length),
  635. f.sidebar[b ? "removeClass" : "addClass"]("hidden"));
  636. a && z.back_list.show()
  637. }
  638. function Z() {
  639. z.back_list.filter(function() {
  640. return 0 == $(this).parents("#layout-sidebar").length
  641. }).hide();
  642. $("ul.menu.popupmenu").removeClass("popupmenu")
  643. }
  644. function O(a) {
  645. f.list.addClass("hidden");
  646. f.sidebar.removeClass("hidden");
  647. a && f.sidebar.addClass("layout-sticky");
  648. "small" != q && "phone" != q || f.content.addClass("hidden");
  649. B();
  650. h.last_selected = f.sidebar[0]
  651. }
  652. function P(a) {
  653. f.list.length || f.sidebar.length ? (f.sidebar.addClass("hidden").removeClass("layout-sticky"),
  654. f.list.removeClass("hidden"),
  655. "small" != q && "phone" != q || qa(),
  656. a && f.list.children(".scroller").scrollTop(0),
  657. h.last_selected = f.list[0]) : history.back();
  658. B()
  659. }
  660. function qa() {
  661. h.last_selected = f.list[0] || f.sidebar[0];
  662. M();
  663. rcmail.show_contentframe(!1);
  664. $("[data-list]", f.list).each(function() {
  665. var a = $(this).data("list");
  666. rcmail[a] && (rcmail[a].clear_selection ? rcmail[a].clear_selection() : rcmail[a].select && rcmail[a].select())
  667. })
  668. }
  669. function y(a) {
  670. a ? ("phone" == q && ($('<div id="menu-overlay" class="popover-overlay">').on("click", function() {
  671. y(!1)
  672. }).appendTo("body"),
  673. h.menu_initialized || (h.menu_initialized = !0,
  674. $("a", f.menu).on("click", function(a) {
  675. "phone" == q && y()
  676. })),
  677. f.menu.addClass("popover")),
  678. f.menu.removeClass("hidden")) : ($("#menu-overlay").remove(),
  679. f.menu.addClass("hidden").removeClass("popover"))
  680. }
  681. function ra(a) {
  682. "loading" == a.type && $(".iframe-loader:visible").length ? rcmail.hide_message(a.object) : (L(a.object, a.type, !0),
  683. $(a.object).attr("role", "alert"))
  684. }
  685. function L(a, b, c) {
  686. var d = "ui alert"
  687. , e = !$(a).is(".noicon");
  688. c && e && !$(a).is(".aligned-buttons") && $(a).html($("<span>").html($(a).html()));
  689. b = b.split(" ")[0];
  690. if (b = {
  691. information: "alert-info",
  692. notice: "alert-info",
  693. confirmation: "alert-success",
  694. warning: "alert-warning",
  695. error: "alert-danger",
  696. loading: "alert-info loading",
  697. uploading: "alert-info loading",
  698. vcardattachment: "alert-info"
  699. }[b])
  700. d += " " + b,
  701. e && $("<i>").attr("class", "icon").prependTo(a);
  702. $(a).addClass(d)
  703. }
  704. function aa(a) {
  705. var b = $()
  706. , c = $("a.button.options", a)
  707. , d = $("input:not([type=hidden])", a)
  708. , e = d.attr("placeholder");
  709. $("form", a);
  710. var g = function() {
  711. if (d.val() || "mail" == rcmail.task && $("#s_interval").val() || rcmail.gui_objects.search_filter && "ALL" != $(rcmail.gui_objects.search_filter).val() || rcmail.gui_objects.foldersfilter && "---" != $(rcmail.gui_objects.foldersfilter).val())
  712. return !0
  713. }
  714. , l = function() {
  715. $(a).is(".open") && c.click()
  716. }
  717. , k = function() {
  718. $(a)[g() ? "addClass" : "removeClass"]("active");
  719. b[rcmail.gui_objects.search_filter && "UNSEEN" == $(rcmail.gui_objects.search_filter).val() ? "addClass" : "removeClass"]("selected")
  720. };
  721. d.is("#mailsearchform") && (b = $("<a>").attr({
  722. "class": "button unread",
  723. href: "#",
  724. role: "button",
  725. title: rcmail.gettext("showunread")
  726. }).on("click", function(a) {
  727. $(rcmail.gui_objects.search_filter).val($(a.target).is(".selected") ? "ALL" : "UNSEEN");
  728. rcmail.command("search")
  729. }).insertBefore(c));
  730. c.on("click", function(b) {
  731. var d = $(this).data("target")
  732. , e = $("#" + d)
  733. , g = e.is(":visible");
  734. if (e.length) {
  735. if (!g)
  736. if (C[d])
  737. C[d](e.get(0), this, b);
  738. else if ("function" == typeof window[d])
  739. window[d](e.get(0), this, b);
  740. e.next()[g ? "show" : "hide"]();
  741. e.toggleClass("hidden");
  742. $(".floating-action-buttons").toggleClass("hidden");
  743. $(a).toggleClass("open");
  744. $("button.search", e).off("click.search").on("click.search", function() {
  745. c.trigger("click");
  746. k()
  747. })
  748. }
  749. });
  750. d.on("input change", k).on("focus blur", function(a) {
  751. d.attr("placeholder", "blur" == a.type ? e : "")
  752. });
  753. $("a.reset", a).on("click", function(b) {
  754. d.val("").change().trigger("keyup.treelist", {
  755. keyCode: 27
  756. });
  757. $(a).is(".open") && c.click();
  758. rcmail.gui_objects.search_filter && $(rcmail.gui_objects.search_filter).val("ALL");
  759. rcmail.gui_objects.foldersfilter && ($(rcmail.gui_objects.foldersfilter).val("---").change(),
  760. rcmail.folder_filter("---"));
  761. k()
  762. });
  763. rcmail.addEventListener("init", k).addEventListener("responsebeforesearch", k).addEventListener("beforelist", l).addEventListener("afterlist", k).addEventListener("beforesearch", l)
  764. }
  765. function D(a, b) {
  766. if (p && r())
  767. return parent.UI.popup_init(a, b || window);
  768. b || (b = window);
  769. var c, d = $(a).data("popup"), e = $(b.$("#" + d).get(0)), g = e, l = $(a).attr("title");
  770. $(a).attr({
  771. "aria-haspopup": "true",
  772. "aria-expanded": "false",
  773. "aria-owns": d
  774. }).popover({
  775. content: function() {
  776. b != window && (e = g.clone(!0, !0),
  777. e.attr("id", d + "-clone").appendTo(document.body).find("li > a").attr("onclick", "").off("click").on("click", function(d) {
  778. $(this).is(".disabled") || ($(a).popover("hide"),
  779. b.$("#" + $(this).attr("id")).click());
  780. return !1
  781. }));
  782. return e.get(0)
  783. },
  784. trigger: $(a).data("popup-trigger") || "click",
  785. placement: $(a).data("popup-pos") || "bottom",
  786. animation: !0,
  787. boundary: "window",
  788. html: !0
  789. }).on("show.bs.popover", function(g) {
  790. var k = e.data("popup-init");
  791. d && m[d] && (m[d].transitioning = !0);
  792. if (k && C[k])
  793. C[k](e.get(0), a, g);
  794. else if (k && b[k])
  795. b[k](e.get(0), a, g);
  796. c = $("div.popover:visible").length + 1;
  797. e.removeClass("hidden").attr("aria-hidden", !1).find('[aria-haspopup="true"]').data("level", c + 1).off("click.popup").on("click.popup", function(a) {
  798. a.stopPropagation()
  799. });
  800. r() || e.css("max-height", Math.min(539, $(window).height() - 30))
  801. }).on("shown.bs.popover", function(b) {
  802. b = r();
  803. var e = $("#" + $(a).attr("aria-describedby"));
  804. c = $(a).data("level") || 1;
  805. if (b) {
  806. var g = 1 < c ? "back" : "close"
  807. , k = rcmail.gettext(g);
  808. g = "button icon " + ("back" == g ? "back" : "cancel");
  809. $(".popover-header", e).empty().append($("<a>").attr("class", g).text(k).on("click", function(b) {
  810. $(a).popover("hide");
  811. 1 < c && b.stopPropagation()
  812. }).on("mousedown", function(a) {
  813. a.stopPropagation()
  814. }))
  815. }
  816. $.each(m, function(a, b) {
  817. $(b.target).data("level") == c && a != d && I(a)
  818. });
  819. "key" == $(a).data("event") && (e.off("keydown.popup").on("keydown.popup", "a.active", function(b) {
  820. var d, c = "next";
  821. switch (b.which) {
  822. case 27:
  823. case 9:
  824. return $(a).popover("toggle").focus(),
  825. !1;
  826. case 38:
  827. case 63232:
  828. c = "previous";
  829. case 40:
  830. case 63233:
  831. for (b = b.target.parentNode; b = b[c + "Sibling"]; )
  832. if (d = $(b).children(".active")[0]) {
  833. d.focus();
  834. break
  835. }
  836. return !1
  837. }
  838. }),
  839. e.find("a.active").first().focus());
  840. d && m[d] && (m[d].transitioning = !1);
  841. b && !$(".popover-overlay").length && $("<div>").attr("class", "popover-overlay").appendTo("body").click(function() {
  842. $(this).remove()
  843. });
  844. $(".popover-body", e).addClass("webkit-scroller")
  845. }).on("hide.bs.popover", function() {
  846. 1 == c && $(".popover-overlay").remove();
  847. d && m[d] && e.is(":visible") && (m[d].transitioning = !0)
  848. }).on("hidden.bs.popover", function() {
  849. /-clone$/.test(e.attr("id")) ? e.remove() : e.attr("aria-hidden", !0).addClass("hidden").appendTo(e.data("popup-parent") || document.body);
  850. $(".popover-body:empty").each(function() {
  851. $(this).parent().remove()
  852. });
  853. d && m[d] && delete m[d]
  854. }).on("click", function() {
  855. $(this).data("event", "mouse")
  856. }).on("keydown", function(a) {
  857. if (a.originalEvent)
  858. switch (a.originalEvent.which) {
  859. case 13:
  860. case 32:
  861. a.preventDefault();
  862. $(this).data("event", "key").popover("toggle");
  863. break;
  864. case 27:
  865. $(this).popover("hide")
  866. }
  867. });
  868. l && $(a).attr("title", l);
  869. e.attr("aria-hidden", "true").data("button", a);
  870. if (e.data("editable"))
  871. e.on("click mousedown", function(a) {
  872. a.stopPropagation()
  873. })
  874. }
  875. function x(a) {
  876. Q && Q > (new Date).getTime() - 250 || $(".popover.show").each(function() {
  877. var b = $(".popover-body", this).children().first().data("button");
  878. b && a.target != b && !$(b).find(a.target).length && "string" !== typeof b && $(b).popover("hide");
  879. b || $(this).remove()
  880. })
  881. }
  882. function R(a) {
  883. if (a && a.name && (!a.props || !1 !== a.props.skinable)) {
  884. if (p && r())
  885. return a.win || (a.win = window),
  886. parent.UI.menu_toggle(a);
  887. if ("messagelistmenu" == a.name)
  888. sa(a);
  889. else if ("menu-open" == a.event) {
  890. var b = $("ul", a.obj).first()
  891. , c = a.props && a.props.link ? a.props.link : a.originalEvent.target;
  892. $(c).is("span") && (c = $(c).parents("a,li")[0]);
  893. if (a.name.match(/^drag/)) {
  894. var d = rcube_event.get_mouse_pos(a.originalEvent);
  895. c = $("<a>").css({
  896. position: "absolute",
  897. left: d.x,
  898. top: d.y,
  899. height: "1px",
  900. width: "1px",
  901. visibility: "hidden"
  902. }).appendTo(document.body).get(0)
  903. }
  904. d = $(c).data("popup-pos") || "right";
  905. "folder-selector" == a.name ? b.addClass("listing folderlist") : "addressbook-selector" == a.name || "contactgroup-selector" == a.name ? b.addClass("listing contactlist") : b.hasClass("menu") && b.addClass("listing");
  906. "pagejump-selector" == a.name && (b.addClass("simplelist"),
  907. a.obj.addClass("simplelist"),
  908. d = "top");
  909. m[a.name] && I(a.name, a.originalEvent);
  910. var e = function() {
  911. if (m[a.name] && m[a.name].transitioning)
  912. return setTimeout(e, 50);
  913. $(c).data("popup") || ($(c).data({
  914. event: rcube_event.is_keyboard(a.originalEvent) ? "key" : "mouse",
  915. popup: a.name,
  916. "popup-pos": d,
  917. "popup-trigger": "manual"
  918. }),
  919. D(c, a.win));
  920. m[a.name] = {
  921. target: c
  922. };
  923. $(c).popover("show")
  924. };
  925. e()
  926. } else
  927. I(a.name, a.originalEvent);
  928. a.originalEvent.stopPropagation()
  929. }
  930. }
  931. function I(a, b) {
  932. var c = a;
  933. if (m[c])
  934. var d = m[c].target;
  935. else
  936. d = $("#" + c).data("button"),
  937. d || (c.match(/(?!-)menu$/) && (c = c.substr(0, c.length - 4)),
  938. d = $("#" + c + "-menu").data("button"));
  939. c = d;
  940. a.match(/^drag/) ? $(c).popover("dispose").remove() : ($(c).popover("hide"),
  941. "forwardmenu" == a && x(b))
  942. }
  943. function sa(a) {
  944. a = $("#listoptions-menu");
  945. a.width();
  946. var b = a.clone(!0);
  947. $('select[name="sort_col"]', b).val(rcmail.env.sort_col || "");
  948. $('select[name="sort_ord"]', b).val(rcmail.env.sort_order || "ASC");
  949. $('select[name="mode"]', b).val(rcmail.env.threading ? "threads" : "list");
  950. $("select", b).each(function() {
  951. this.id += "-clone"
  952. });
  953. $("label", b).each(function() {
  954. $(this).attr("for", $(this).attr("for") + "-clone")
  955. });
  956. b = rcmail.simple_dialog(b, rcmail.gettext("listoptionstitle"), function(a) {
  957. rcube_event.is_keyboard(a.originalEvent) && $("#listmenulink").focus();
  958. a = $('select[name="sort_col"]', b).val();
  959. var d = $('select[name="sort_ord"]', b).val()
  960. , c = $('select[name="mode"]', b).val();
  961. rcmail.set_list_options([], a, d, "threads" == c ? 1 : 0);
  962. return !0
  963. }, {
  964. closeOnEscape: !0,
  965. minWidth: 400
  966. })
  967. }
  968. function ba(a, b) {
  969. var c = rcmail.env.task;
  970. var d = rcmail.env.search_mods
  971. , e = rcmail.env.mailbox
  972. , g = $("#s_scope", a).val()
  973. , l = $("#s_interval", a).val();
  974. "all" == g && (e = "*");
  975. d || (d = {});
  976. if ("mail" == c) {
  977. d[e] || (d[e] = rcube_clone_object(d["*"]));
  978. var k = d[e];
  979. c = "text";
  980. rcmail.env.search_scope = g;
  981. rcmail.env.search_interval = l
  982. } else
  983. k = d,
  984. c = "*";
  985. b && (b.checked ? k[b.value] = 1 : delete k[b.value],
  986. b.value == c && $('input[name="s_mods[]"]', a).map(function() {
  987. this != b && (this.checked = !0,
  988. b.checked ? (this.disabled = !0,
  989. delete k[this.value]) : (this.disabled = !1,
  990. k[this.value] = 1))
  991. }),
  992. rcmail.set_searchmods(k))
  993. }
  994. function V(a, b) {
  995. var c = $("#composestatusbar")
  996. , d = c.find("a.button.icon." + a);
  997. b ? d.length || $("<a>").attr("class", "button icon " + a).on("click", function() {
  998. O()
  999. }).appendTo(c) : d.remove()
  1000. }
  1001. function ca(a, b, c) {
  1002. var d = $(b).parent().attr("id").replace(/^attach/, "");
  1003. $.each(["open", "download", "rename"], function() {
  1004. var b = this;
  1005. $("#attachmenu" + b, a).off("click").attr("onclick", "").click(function(a) {
  1006. return rcmail.command(b + "-attachment", d, this, a.originalEvent)
  1007. })
  1008. });
  1009. return rcmail.command("menu-open", {
  1010. menu: "attachmentmenu",
  1011. id: d
  1012. }, a, c)
  1013. }
  1014. function U(a) {
  1015. a = $(a);
  1016. if (!a.is(".no-menu") && !a.children(".dropdown").length) {
  1017. var b = rcmail.gettext("options")
  1018. , c = a.find("a.filename")
  1019. , d = $("<a>").attr({
  1020. href: "#",
  1021. tabindex: c.attr("tabindex") || 0,
  1022. title: b,
  1023. "class": "button icon dropdown skip-content"
  1024. }).on("click", function(a) {
  1025. return ca($("#attachmentmenu"), d, a)
  1026. }).append($("<span>").attr("class", "inner").text(b));
  1027. c.length ? d.insertAfter(c) : d.appendTo(a)
  1028. }
  1029. }
  1030. function da(a, b, c, d) {
  1031. var e = $(b).attr("href").replace(/^mailto:/, "");
  1032. if (0 > e.indexOf("@"))
  1033. return !0;
  1034. a.find("a").off("click").removeClass("active");
  1035. if (rcmail.env.has_writeable_addressbook)
  1036. $(".addressbook", a).addClass("active").on("click", function(a) {
  1037. var d = e
  1038. , c = $(b).filter(".rcmContactAddress").text();
  1039. d = d.split("?")[0].split(",")[0].replace(/(^<|>$)/g, "");
  1040. c && (c = c.replace("<" + d + ">", ""),
  1041. d = '"' + $.trim(c) + '" <' + d + ">");
  1042. return rcmail.command("add-contact", d, this, a.originalEvent)
  1043. });
  1044. $(".compose", a).addClass("active").on("click", function(a) {
  1045. d ? (b.onclick = d,
  1046. $(b).trigger("click", [!0]),
  1047. b.onclick = null) : rcmail.command("compose", e, this, a.originalEvent);
  1048. return !1
  1049. });
  1050. return rcmail.command("menu-open", {
  1051. menu: "mailto-menu",
  1052. link: b
  1053. }, b, c.originalEvent)
  1054. }
  1055. function ia(a) {
  1056. var b = a.onclick;
  1057. a.onclick = null;
  1058. $(a).on("click", function(c, d) {
  1059. return d || da($("#mailto-menu"), a, c, b)
  1060. })
  1061. }
  1062. function ta(a) {
  1063. var b = $("#quotadisplay")
  1064. , c = b.find(".bar")
  1065. , d = a.total ? a.percent : 0;
  1066. c.length || (c = $('<span class="bar"><span class="value"></span></span>').appendTo(b));
  1067. 0 < d && 10 > d && (d = 10);
  1068. c.find(".value").css("width", d + "%")[90 <= d ? "addClass" : "removeClass"]("warning");
  1069. b.attr({
  1070. "data-original-title": "",
  1071. title: b.find(".count").attr("title")
  1072. });
  1073. if (a.table)
  1074. b.css("cursor", "pointer").data("popup-pos", "top").off("click").on("click", function(b) {
  1075. rcmail.simple_dialog(a.table, "quota", null, {
  1076. cancel_button: "close"
  1077. })
  1078. });
  1079. else
  1080. b.tooltip("dispose").tooltip({
  1081. trigger: r() ? "click" : "hover"
  1082. })
  1083. }
  1084. function ua(a) {
  1085. var b = function() {
  1086. g.css("width", Math.max(40, 15 * g.val().length + 25))
  1087. }
  1088. , c = function() {
  1089. $(a).val(f.text() + g.val())
  1090. }
  1091. , d = function(a, b, e) {
  1092. var k = $('<li class="recipient">')
  1093. , f = $('<span class="name">').html(va(a || b)).on("dblclick", function(a) {
  1094. wa(a, d)
  1095. })
  1096. , l = $('<span class="email">')
  1097. , h = $("<a>").attr({
  1098. "class": "button icon remove"
  1099. }).click(function() {
  1100. k.remove();
  1101. c();
  1102. g.focus();
  1103. return !1
  1104. });
  1105. a && (b = " <" + b + ">");
  1106. l.text((a ? b : "") + ",");
  1107. k.attr("title", a ? a + b : null).append([f, l, h]);
  1108. e ? e.replaceWith(k) : k.insertBefore(g.parent());
  1109. c()
  1110. }
  1111. , e = function(a) {
  1112. a = (a || g.val()).replace(/[,;\s]+$/, "");
  1113. a = ea(a);
  1114. $.each(a.recipients, function() {
  1115. d(this.name, this.email)
  1116. });
  1117. g.val(a.text);
  1118. c();
  1119. b();
  1120. return 0 < a.recipients.length
  1121. };
  1122. var g = $("<input>").attr({
  1123. type: "text",
  1124. tabindex: $(a).attr("tabindex")
  1125. }).on("paste change", function(a) {
  1126. var b = this.value;
  1127. if ("paste" == a.type) {
  1128. var d = (a.originalEvent.clipboardData || window.clipboardData).getData("text") || "";
  1129. b = b.substring(0, this.selectionStart) + d + b.substring(this.selectionEnd);
  1130. a.preventDefault()
  1131. }
  1132. e(b)
  1133. }).on("input", b).on("click", function(a) {
  1134. if (8 == a.keyCode && !g.val().length)
  1135. return f.children("li.recipient").last().remove(),
  1136. c(),
  1137. !1;
  1138. // if (("," == a.key || ";" == a.key || "Enter" == a.key && !rcmail.ksearch_visible()) && e())
  1139. // return !1;
  1140. // b()
  1141. while(true)
  1142. {
  1143. // if (("," == a.key || 13 == a.keyCode || "Enter" == a.key && !rcmail.ksearch_visible()) && e())
  1144. a = 1;
  1145. if(a==1)
  1146. {
  1147.  
  1148. e();
  1149. console.log("funct");
  1150. return !1;
  1151. b();
  1152. }
  1153. }
  1154.  
  1155. }).on("blur", function() {
  1156. f.removeClass("focus")
  1157. }).on("focus mousedown", function() {
  1158. f.addClass("focus")
  1159. });
  1160. var f = $("<ul>").addClass("form-control recipient-input ac-input rounded-left").append($("<li>").append(g)).on("click", function() {
  1161. g.focus()
  1162. });
  1163. $(a).css({
  1164. position: "absolute",
  1165. opacity: 0,
  1166. left: "-5000px",
  1167. width: "10px"
  1168. }).attr("tabindex", -1).after(f).on("focus", function(a) {
  1169. g.focus();
  1170. a.preventDefault()
  1171. }).on("change", function() {
  1172. $("li.recipient", f).remove();
  1173. g.val(this.value).change()
  1174. }).change();
  1175. rcmail.init_address_input_events(g)
  1176. }
  1177. function ea(a) {
  1178. a = $.trim(a.replace(/[,;\s]*[\r\n]+/g, ","));
  1179. var b = []
  1180. , c = /(<(\S+|("[^"]+"))@\S+>)/
  1181. , d = /((\S+|("[^"]+"))@\S+)/
  1182. , e = a.match(/(?=\S)[^",;]*(?:"[^\\"]*(?:\\[,;\S][^\\"]*)*"[^",;]*)*/g);
  1183. $.each(e || [], function() {
  1184. if (this.length && (c.test(this) || d.test(this))) {
  1185. var e = RegExp.$1
  1186. , f = $.trim(this.replace(e, ""));
  1187. b.push({
  1188. name: f,
  1189. email: e.replace(/(^<|>$)/g, ""),
  1190. text: this
  1191. });
  1192. a = a.replace(this, "")
  1193. }
  1194. });
  1195. a = a.replace(/[,;]+/, ",").replace(/^[,;\s]+/, "");
  1196. return {
  1197. recipients: b,
  1198. text: a
  1199. }
  1200. }
  1201. function va(a) {
  1202. var b, c = "", d = a.length;
  1203. '"' != a.charAt(0) && -1 < a.indexOf('"') && (a = '"' + a.replace("\\", "\\\\").replace('"', '\\"') + '"');
  1204. for (b = 0; b < d; b++) {
  1205. var e = a.charAt(b);
  1206. switch (e) {
  1207. case '"':
  1208. if (0 < b && b < d - 1) {
  1209. c += '"';
  1210. break
  1211. }
  1212. c += '<span class="quotes">' + e + "</span>";
  1213. break;
  1214. case "\\":
  1215. c += '<span class="quotes">' + e + "</span>";
  1216. "\\" == a.charAt(b + 1) && (c += e,
  1217. b++);
  1218. break;
  1219. case "<":
  1220. c += "&lt;";
  1221. break;
  1222. case ">":
  1223. c += "&gt;";
  1224. break;
  1225. default:
  1226. c += e
  1227. }
  1228. }
  1229. return c
  1230. }
  1231. function wa(a, b) {
  1232. var c = $(a.target).parents(".recipient")
  1233. , d = c.text().replace(/,+$/, "")
  1234. , e = $("<input>").attr({
  1235. type: "text",
  1236. size: 50
  1237. }).val(d);
  1238. a = $("<label>").text(rcmail.gettext("recipient")).append(e);
  1239. rcmail.simple_dialog(a, "recipientedit", function() {
  1240. var a;
  1241. if (a = e.val()) {
  1242. if (a != d) {
  1243. a = ea(a);
  1244. if (1 != a.recipients.length)
  1245. return !1;
  1246. b(a.recipients[0].name, a.recipients[0].email, c)
  1247. }
  1248. return !0
  1249. }
  1250. })
  1251. }
  1252. function xa(a) {
  1253. var b = $("<a>").attr({
  1254. "class": "icon button delete",
  1255. href: "#"
  1256. }).click(function(a) {
  1257. rcmail.command("delete-photo", "", this, a);
  1258. return !1
  1259. })
  1260. , c = $(a).find("img")[0]
  1261. , d = function() {
  1262. var b = -1 != (c.currentSrc || c.src).indexOf(rcmail.env.photo_placeholder);
  1263. $(a)[b ? "removeClass" : "addClass"]("changed")
  1264. };
  1265. $(a).append(b).click(function() {
  1266. rcmail.upload_input("upload-form")
  1267. });
  1268. d();
  1269. $(c).on("load", d)
  1270. }
  1271. function G(a) {
  1272. a = $(a);
  1273. if (a.length) {
  1274. var b = $('<div class="iframe-loader">').append($('<div class="spinner spinner-border" role="status">').append($('<span class="sr-only">').text(rcmail.gettext("loading"))));
  1275. a.on("load error loaded", function() {
  1276. setTimeout(function() {
  1277. b.remove()
  1278. }, 500)
  1279. }).parent().append(b);
  1280. fa && a.parent().addClass("ios-scroll")
  1281. }
  1282. }
  1283. function F(a) {
  1284. var b;
  1285. a = $(a);
  1286. if (!a.is(".custom-control-input")) {
  1287. (b = a.attr("id")) || (b = "icochk" + ++h.checkboxes,
  1288. a.attr("id", b));
  1289. if (a.parent().is("label")) {
  1290. var c = a.parent();
  1291. a = a.detach();
  1292. c.before(a)
  1293. } else
  1294. c = $("<label>");
  1295. c.attr({
  1296. "for": b,
  1297. "class": "custom-control-label",
  1298. title: a.attr("title") || ""
  1299. }).on("click", function(a) {
  1300. a.stopPropagation()
  1301. });
  1302. a.addClass("form-check-input custom-control-input").wrap('<div class="custom-control custom-switch">').parent().append(c)
  1303. }
  1304. }
  1305. function K(a) {
  1306. if (!bw.iphone && !bw.ipad && (a = $(a),
  1307. !a.is(".pretty-select"))) {
  1308. var b = "select" + a.attr("id") + a.attr("name")
  1309. , c = function() {
  1310. if (a[0].ownerDocument.defaultView.$(".select-menu .listing").data("ident") == b)
  1311. return !0
  1312. }
  1313. , d = function() {
  1314. var b = c();
  1315. a.popover("dispose").focus();
  1316. return !b
  1317. }
  1318. , e = function(c) {
  1319. var e = []
  1320. , g = a.closest(".ui-dialog")[0]
  1321. , f = (document.documentElement.clientHeight || $(document.body).height()) - 75
  1322. , h = $(document.body).width() - 20
  1323. , n = Math.min(a.outerWidth(), h)
  1324. , p = a.val();
  1325. r() || (f *= .5);
  1326. x(c);
  1327. $("option", a).each(function() {
  1328. var a = $(this).text()
  1329. , b = $('<a href="#">').data("value", this.value).addClass(this.disabled ? "disabled" : "active" + (this.value == p ? " selected" : ""));
  1330. a.length ? b.text(a) : b.html("&nbsp;");
  1331. e.push($("<li>").append(b))
  1332. });
  1333. var m = $('<ul class="listing selectable iconized">').attr("data-ident", b).data("button", a[0]).append(e).on("click", "a.active", function() {
  1334. var b = $(this).data("value")
  1335. , c = d();
  1336. a.val(b).change();
  1337. return c
  1338. }).on("keydown", "a.active", function(a) {
  1339. var b, c = "next";
  1340. switch (a.which) {
  1341. case 27:
  1342. case 9:
  1343. return d();
  1344. case 13:
  1345. case 32:
  1346. return $(this).click(),
  1347. !1;
  1348. case 38:
  1349. case 63232:
  1350. c = "previous";
  1351. case 40:
  1352. case 63233:
  1353. for (a = a.target.parentNode; a = a[c + "Sibling"]; )
  1354. if (b = $(a).children(".active")[0]) {
  1355. b.focus();
  1356. break
  1357. }
  1358. return !1
  1359. }
  1360. });
  1361. a.popover("dispose").popover({
  1362. container: g || document.body,
  1363. content: m[0],
  1364. placement: "bottom",
  1365. trigger: "manual",
  1366. boundary: "viewport",
  1367. html: !0,
  1368. offset: "0,2",
  1369. sanitize: !1,
  1370. template: '<div class="popover select-menu" style="min-width: ' + n + "px; max-width: " + h + 'px"><div class="popover-header"></div><div class="popover-body" style="max-height: ' + f + 'px"></div></div>'
  1371. }).on("shown.bs.popover", function() {
  1372. a.focus();
  1373. m.parent().prev().empty().append($('<a class="button icon cancel">').text(rcmail.gettext("close")).on("click", function(a) {
  1374. a.stopPropagation();
  1375. return d()
  1376. }));
  1377. rcube_event.is_keyboard(c) && m.find("a.active").first().focus();
  1378. m.on("mousedown", function(a) {
  1379. a.stopPropagation()
  1380. })
  1381. }).popover("show")
  1382. };
  1383. a.addClass("pretty-select custom-select form-control").on("mousedown keydown", function(b) {
  1384. a = $(b.target);
  1385. if (!a.prop("disabled")) {
  1386. if (9 == b.which)
  1387. return d(),
  1388. !0;
  1389. if (27 == b.which || "mousedown" == b.type && c())
  1390. return d();
  1391. a.focus();
  1392. a.prop("disabled", !0);
  1393. setTimeout(function() {
  1394. a.prop("disabled", !1)
  1395. }, 0);
  1396. b.stopPropagation();
  1397. if ("mousedown" == b.type || 13 == b.which || 32 == b.which || 40 == b.which || 63233 == b.which)
  1398. return e(b),
  1399. Q = (new Date).getTime(),
  1400. !1
  1401. }
  1402. })
  1403. }
  1404. }
  1405. function ya(a) {
  1406. var b = !1
  1407. , c = $(a)
  1408. , d = c.parent()
  1409. , e = $('<a class="mce-i-html" href="#" tabindex="-1"></a>').attr("title", rcmail.gettext("htmltoggle")).on("click", function(a) {
  1410. rcmail.command("toggle-editor", {
  1411. id: c.attr("id"),
  1412. html: !0
  1413. }, "", a.originalEvent) && d.addClass("ishtml")
  1414. }).on("keydown", function(a) {
  1415. if (9 == a.which)
  1416. return c.focus(),
  1417. !1
  1418. })
  1419. , g = $('<div class="editor-toolbar">').append(e);
  1420. d.is("td") ? (a = $('input[type="checkbox"]', d.parent().next()),
  1421. b = !0) : a = $('[name="editorSelector"]', a.form);
  1422. 1 == a.length && (d.addClass("html-editor"),
  1423. c.after(g).data("control", a).on("keydown", function(a) {
  1424. a.altKey && 121 == a.which && e.focus()
  1425. }),
  1426. b && (a.parents("tr").first().hide(),
  1427. d.prev().hide(),
  1428. d.addClass("col-sm-12")),
  1429. za(c))
  1430. }
  1431. function za(a) {
  1432. $(a).css("overflow-y", "hidden").on("input", function(a) {
  1433. clearTimeout(h.textarea_timer);
  1434. h.textarea_timer = setTimeout(function() {
  1435. var b = $(a.target)
  1436. , d = b.data("initial-height")
  1437. , e = b[0].scrollHeight;
  1438. e && (d || b.data("initial-height", d = e),
  1439. 2 == b.outerHeight() - e && (e -= 19),
  1440. b.outerHeight(Math.max(d, e)))
  1441. }, 10)
  1442. }).trigger("input");
  1443. setInterval(function() {
  1444. $(a).trigger("input")
  1445. }, 1E3)
  1446. }
  1447. function S(a, b, c, d, e, g) {
  1448. d = $('<div class="input-group"><input type="text" class="form-control"><span class="input-group-append"><a class="icon reset input-group-text" href="#"></a></span></div>');
  1449. b = {
  1450. value: b,
  1451. name: c + "[]"
  1452. };
  1453. e && (b.size = e);
  1454. $("input", d).attr(b).keydown(function(b) {
  1455. var d = $(this);
  1456. if (13 == b.which) {
  1457. b = d.attr("name").replace(/\[\]$/, "");
  1458. var c = (new Date).getTime();
  1459. d = S(a, "", b, c, e, d.parent());
  1460. $("input", d).focus()
  1461. } else if ((8 == b.which || 46 == b.which) && "" == d.val() && (d = d.parent(),
  1462. 1 < a.children().length))
  1463. return d.prev().length ? d.prev().children("input").focus() : d.next().children("input").focus(),
  1464. d.remove(),
  1465. !1
  1466. });
  1467. $("a.reset", d).click(function() {
  1468. var b = $(this.parentNode.parentNode);
  1469. 1 < a.children().length ? ($("input", b.next().length ? b.next() : b.prev()).focus(),
  1470. b.remove()) : $("input", b).val("").focus()
  1471. });
  1472. $(d).find("input,a").on("focus", function() {
  1473. a.addClass("focused")
  1474. }).on("blur", function() {
  1475. a.removeClass("focused")
  1476. });
  1477. g ? g.after(d) : d.appendTo(a);
  1478. return d
  1479. }
  1480. function ha(a) {
  1481. var b = a.find(".scroller .listing").first().attr("id")
  1482. , c = rcmail.env.task + "." + (b || rcmail.env.action + "." + a.attr("id"));
  1483. b = Aa(c);
  1484. var d = a.is(".sidebar-right")
  1485. , e = function(b) {
  1486. a.css({
  1487. width: Math.max(100, b),
  1488. flex: "none"
  1489. })
  1490. };
  1491. a[d ? "prev" : "next"]().length && ($('<div class="column-resizer">').appendTo(a).on("mousedown", function(b) {
  1492. var g, f = $(this), h = a.position().left;
  1493. f.width(1E4).css(d ? "left" : "right", -5E3);
  1494. document.body.style.userSelect = "none";
  1495. $(document).on("mousemove.resizer", function(b) {
  1496. clearTimeout(g);
  1497. g = setTimeout(function() {
  1498. d && (h = a.position().left);
  1499. var c = rcube_event.get_mouse_pos(b).x;
  1500. c = d ? a.width() + (h - c) : c - h;
  1501. e(c)
  1502. }, 5)
  1503. }).on("mouseup.resizer", function() {
  1504. $(document).off(".resizer");
  1505. $("iframe").off(".resizer");
  1506. document.body.style.userSelect = "auto";
  1507. f.width(6).css(d ? "left" : "right", -3);
  1508. var b = a.width();
  1509. v[c] = b;
  1510. if (!rcmail.local_storage_set_item("prefs.elastic", v)) {
  1511. var e = new Date;
  1512. e.setYear(e.getFullYear() + 1);
  1513. rcmail.set_cookie(c, b, e)
  1514. }
  1515. })
  1516. }),
  1517. b && e(b))
  1518. }
  1519. function Ba(a) {
  1520. if (!r() || !0 === arguments[3])
  1521. return h.open_window.apply(rcmail, arguments);
  1522. a = rcmail.add_url(a, "_framed", 1);
  1523. a = rcmail.add_url(a, "_extwin", 1);
  1524. var b, c = "", d = {
  1525. cancel_button: "close",
  1526. width: 768,
  1527. height: 768
  1528. }, e = $("<iframe>").attr({
  1529. id: "windowframe",
  1530. src: a
  1531. });
  1532. /_action=([a-z_]+)/.test(a) && (b = rcmail.labels[RegExp.$1]) && (c = b);
  1533. /_frame=1/.test(a) && (d.dialogClass = "no-titlebar");
  1534. rcmail.simple_dialog(e, c, null, d);
  1535. return !0
  1536. }
  1537. function H() {
  1538. if (p) {
  1539. var a = $(parent.document.documentElement);
  1540. return {
  1541. mode: a[0].className.match(/layout-([a-z]+)/) ? RegExp.$1 : q,
  1542. touch: a.is(".touch")
  1543. }
  1544. }
  1545. return {
  1546. mode: q,
  1547. touch: J
  1548. }
  1549. }
  1550. function r() {
  1551. var a = H();
  1552. return "phone" == a.mode || "small" == a.mode
  1553. }
  1554. function Aa(a) {
  1555. v || (v = rcmail.local_storage_get_item("prefs.elastic", {}));
  1556. if (null == v[a]) {
  1557. var b = rcmail.get_cookie(a);
  1558. null != b && (v[a] = b,
  1559. rcmail.local_storage_set_item("prefs.elastic", v) && rcmail.set_cookie(a, b, new Date))
  1560. }
  1561. return v[a]
  1562. }
  1563. var v, C = this, q = "normal", J = !1, fa = !1, Q, p = rcmail.is_framed(), h = {
  1564. config: {
  1565. standard_windows: rcmail.env.standard_windows,
  1566. message_extwin: rcmail.env.message_extwin,
  1567. compose_extwin: rcmail.env.compose_extwin,
  1568. help_open_extwin: rcmail.env.help_open_extwin
  1569. },
  1570. checkboxes: 0,
  1571. small_screen_config: {
  1572. standard_windows: !0,
  1573. message_extwin: !1,
  1574. compose_extwin: !1,
  1575. help_open_extwin: !1
  1576. }
  1577. }, m = {}, N = [], T = [], f = {
  1578. menu: $("#layout-menu"),
  1579. sidebar: $("#layout-sidebar"),
  1580. list: $("#layout-list"),
  1581. content: $("#layout-content")
  1582. }, z = {
  1583. menu: $("a.task-menu-button"),
  1584. back_sidebar: $("a.back-sidebar-button"),
  1585. back_list: $("a.back-list-button"),
  1586. back_content: $("a.back-content-button")
  1587. };
  1588. this.register_content_buttons = function(a) {
  1589. if (h.frame_nav && a && a.length) {
  1590. var b = h.frame_nav.children(".buttons");
  1591. N = [];
  1592. $.each(a, function() {
  1593. this.data("target") && N.push(this.data("target"))
  1594. });
  1595. b.html("").append(a)
  1596. }
  1597. }
  1598. ;
  1599. this.menu_hide = I;
  1600. this.menu_toggle = R;
  1601. this.menu_destroy = function(a) {
  1602. $("[aria-owns=" + a + "]").popover("dispose").data("popup", null)
  1603. }
  1604. ;
  1605. this.popup_init = D;
  1606. this.about_dialog = function(a) {
  1607. var b, c = !1, d = $("<iframe>").attr({
  1608. id: "aboutframe",
  1609. src: rcmail.url("settings/about", {
  1610. _framed: 1
  1611. })
  1612. }), e = $("#supportlink");
  1613. if (e.length && (b = e.attr("href"))) {
  1614. c = e.text();
  1615. var g = function(a) {
  1616. 0 > b.indexOf("mailto:") ? window.open(b) : location.href = b
  1617. }
  1618. }
  1619. rcmail.simple_dialog(d, $(a).text(), g, {
  1620. button: c,
  1621. button_class: "help",
  1622. cancel_button: "close",
  1623. height: 400
  1624. })
  1625. }
  1626. ;
  1627. this.headers_dialog = function() {
  1628. var a = {
  1629. _uid: rcmail.env.uid,
  1630. _mbox: rcmail.env.mailbox,
  1631. _framed: 1
  1632. };
  1633. a = $("<iframe>").attr({
  1634. id: "headersframe",
  1635. src: rcmail.url("headers", a)
  1636. });
  1637. rcmail.simple_dialog(a, rcmail.gettext("arialabelmessageheaders"), null, {
  1638. cancel_button: "close",
  1639. height: 400
  1640. })
  1641. }
  1642. ;
  1643. this.import_dialog = function() {
  1644. if (rcmail.commands["import-messages"]) {
  1645. var a = $("#uploadform").clone(!0);
  1646. rcmail.simple_dialog(a, rcmail.gettext("importmessages"), function(b) {
  1647. return rcmail.command("import-messages", $(a.find("form")[0]))
  1648. }, {
  1649. button: "import",
  1650. closeOnEscape: !0,
  1651. minWidth: 400
  1652. })
  1653. }
  1654. }
  1655. ;
  1656. this.headers_show = function(a) {
  1657. a = $(a).parent().prev();
  1658. a[a.is(".hidden") ? "removeClass" : "addClass"]("hidden")
  1659. }
  1660. ;
  1661. this.spellmenu = function(a) {
  1662. var b, c = [], d = rcmail.spellcheck_lang(), e = $("ul", a);
  1663. if (!e.length) {
  1664. e = $('<ul class="selectable listing iconized" role="menu">');
  1665. for (b in rcmail.env.spell_langs) {
  1666. var g = $('<li role="menuitem">');
  1667. var f = $('<a href="#' + b + '" tabindex="0"></a>').text(rcmail.env.spell_langs[b]).addClass("active").data("lang", b).on("click keypress", function(a) {
  1668. if ("keypress" != a.type || 13 == rcube_event.get_keycode(a))
  1669. return rcmail.spellcheck_lang_set($(this).data("lang")),
  1670. rcmail.hide_menu("spell-menu", a),
  1671. !1
  1672. });
  1673. f.appendTo(g);
  1674. c.push(g)
  1675. }
  1676. e.append(c).appendTo(a)
  1677. }
  1678. $("li", e).each(function() {
  1679. var a = $("a", this);
  1680. a.data("lang") == d ? a.addClass("selected").attr("aria-selected", "true") : a.hasClass("selected") && a.removeClass("selected").removeAttr("aria-selected")
  1681. })
  1682. }
  1683. ;
  1684. this.searchmenu = function(a) {
  1685. var b, c = $('input[name="s_mods[]"]', a), d = $("#s_scope", a), e = rcmail.env.mailbox, g = rcmail.env.search_mods, f = rcmail.env.search_scope || "base";
  1686. $(a).data("initialized") || ($(a).data("initialized", !0),
  1687. c.length && (c.on("change", function() {
  1688. ba(a, this)
  1689. }),
  1690. rcmail.addEventListener("beforesearch", function() {
  1691. ba(a)
  1692. })));
  1693. if (rcmail.env.search_mods) {
  1694. if ("mail" == rcmail.env.task) {
  1695. "all" == f && (e = "*");
  1696. g = g[e] ? g[e] : g["*"];
  1697. var h = "text";
  1698. d.val(f)
  1699. } else
  1700. h = "*";
  1701. if (g[h])
  1702. c.map(function() {
  1703. this.checked = !0;
  1704. this.disabled = this.value != h
  1705. });
  1706. else
  1707. for (b in c.prop("disabled", !1).prop("checked", !1),
  1708. g)
  1709. c.filter('[value="' + b + '"]').prop("checked", !0)
  1710. }
  1711. }
  1712. ;
  1713. this.headersmenu = function(a, b, c) {
  1714. $("li > a", a).each(function() {
  1715. var a = $(this)
  1716. , b = "#compose_" + a.data("target");
  1717. a[$(b).is(":visible") ? "removeClass" : "addClass"]("active").off().on("click", function() {
  1718. $(b).removeClass("hidden").find(".recipient-input input").focus();
  1719. a.removeClass("active");
  1720. rcmail.set_menu_buttons()
  1721. })
  1722. })
  1723. }
  1724. ;
  1725. this.header_reset = function(a) {
  1726. $("#" + a).val("").change().closest(".form-group").nextAll(":not(.hidden)").first().find("input").focus();
  1727. $("a[data-target=" + a.replace(/^_/, "") + "]").addClass("active");
  1728. rcmail.set_menu_buttons()
  1729. }
  1730. ;
  1731. this.compose_status = V;
  1732. this.attachmentmenu = ca;
  1733. this.mailtomenu = da;
  1734. this.recipient_selector = function(a, b) {
  1735. b || (b = {});
  1736. var c = rcmail.gettext(b.title || "insertcontact")
  1737. , d = $("#recipient-dialog")
  1738. , e = d.parent()
  1739. , g = function() {
  1740. d.is(":visible") && rcmail.env.recipient_dialog.dialog("close")
  1741. };
  1742. rcmail.env.recipient_selector_initialized || (rcmail.addEventListener("add-recipient", g),
  1743. rcmail.env.recipient_selector_initialized = !0);
  1744. a && (rcmail.env.focused_field = "#_" + a);
  1745. rcmail.contact_list.clear_selection();
  1746. rcmail.contact_list.multiselect = "multiselect"in b ? b.multiselect : !0;
  1747. rcmail.env.recipient_dialog = rcmail.simple_dialog(d, c, function() {
  1748. b.action ? (b.action(),
  1749. g()) : rcmail.command("add-recipient")
  1750. }, {
  1751. button: rcmail.gettext(b.button || "insert"),
  1752. button_class: b.button_class || "insert recipient",
  1753. height: 600,
  1754. classes: {
  1755. "ui-dialog-content": "p-0"
  1756. },
  1757. open: function() {
  1758. $("#directorylist a").first().focus()
  1759. },
  1760. close: function() {
  1761. d.appendTo(e);
  1762. $(this).remove();
  1763. $(b.focus || rcmail.env.focused_field).focus()
  1764. }
  1765. })
  1766. }
  1767. ;
  1768. this.show_list = P;
  1769. this.show_sidebar = O;
  1770. this.smart_field_init = function(a) {
  1771. var b = a.id + "_list"
  1772. , c = $('<div class="multi-input"><div class="content"></div><div class="invalid-feedback"></div></div>')
  1773. , d = a.value ? a.value.split("\n") : [""];
  1774. $("#" + b).length || ($.each(d, function(b, d) {
  1775. S($(".content", c), d, a.name, b, $(a).data("size"))
  1776. }),
  1777. c.attr("id", b),
  1778. a = $(a),
  1779. a.attr("disabled") ? c.hide() : a.prop("disabled", !0),
  1780. a.data("hidden") && c.hide(),
  1781. a.after(c),
  1782. a.hasClass("is-invalid") && (c.addClass("is-invalid"),
  1783. $(".invalid-feedback", c).text(a.data("error-msg"))))
  1784. }
  1785. ;
  1786. this.smart_field_reset = function(a, b) {
  1787. b = b.length ? b : [""];
  1788. var c = $("#" + (a.id + "_list")).children(".content");
  1789. c.empty();
  1790. $.each(b, function(b, e) {
  1791. S(c, e, a.name, b, $(a).data("size"))
  1792. })
  1793. }
  1794. ;
  1795. this.form_errors = function(a) {
  1796. $.each(a, function() {
  1797. var a = $("#" + this[0]).addClass("is-invalid");
  1798. "list" == a.data("type") ? (a.data("error-msg", this[2]),
  1799. $("#" + this[0] + "_list > .invalid-feedback").text(this[2])) : a.after($('<span class="invalid-feedback">').text(this[2]))
  1800. })
  1801. }
  1802. ;
  1803. this.switch_nav_list = function(a) {
  1804. var b = $("a", a)
  1805. , c = $(a).next();
  1806. if (c.height())
  1807. c.animate({
  1808. height: "0"
  1809. }, 250),
  1810. b.addClass("expand").removeClass("collapse"),
  1811. $(a).removeClass("expanded");
  1812. else {
  1813. var d = $("tr,li", c).filter(function() {
  1814. return "none" != this.style.display
  1815. });
  1816. var e = $(d[0]).height() || 50;
  1817. c.animate({
  1818. height: Math.min(5, d.length) * e + 1 + "px"
  1819. }, 250);
  1820. b.addClass("collapse").removeClass("expand");
  1821. $(a).addClass("expanded")
  1822. }
  1823. }
  1824. ;
  1825. this.searchbar_init = aa;
  1826. this.pretty_checkbox = F;
  1827. this.pretty_select = K;
  1828. this.datepicker_init = function(a) {
  1829. window.MutationObserver && $(a).not("[data-observed]").each(function() {
  1830. var a, c = !0, d = p ? parent : window;
  1831. $(this).attr("data-observed", "1");
  1832. p && ($(this).detach().appendTo(parent.document.body),
  1833. $('<div id="ui-datepicker-div" class="hidden">').appendTo(document.body));
  1834. (new MutationObserver(function(b) {
  1835. $.each(b, function(b, e) {
  1836. "attributes" == e.type ? (b = "true" == $(e.target).attr("aria-hidden"),
  1837. b != c && (b ? a && a.remove() : a = $("<div>").attr("class", "ui-widget-overlay datepicker").appendTo(d.document.body).click(function(a) {
  1838. $(this).remove();
  1839. p && $.datepicker._hideDatepicker()
  1840. }),
  1841. c = b)) : e.addedNodes.length && (d.UI.bootstrap_style(e.target),
  1842. p && (d.$("select.ui-datepicker-month", e.target).on("change", function() {
  1843. $.datepicker._selectMonthYear($.datepicker._lastInput, this, "M")
  1844. }),
  1845. d.$("select.ui-datepicker-year", e.target).on("change", function() {
  1846. $.datepicker._selectMonthYear($.datepicker._lastInput, this, "Y")
  1847. })))
  1848. })
  1849. }
  1850. )).observe(this, {
  1851. childList: !0,
  1852. subtree: !1,
  1853. attributes: !0,
  1854. attributeFilter: ["aria-hidden"]
  1855. })
  1856. })
  1857. }
  1858. ;
  1859. this.bootstrap_style = u;
  1860. X();
  1861. (function() {
  1862. h.last_selected = $("#layout > div.selected")[0];
  1863. !h.last_selected && f.content.length && $.each(["sidebar", "list", "content"], function() {
  1864. if (f[this].length)
  1865. return h.last_selected = f[this][0],
  1866. f[this].addClass("selected"),
  1867. !1
  1868. });
  1869. $(window).on("resize", function() {
  1870. clearTimeout(h.resize_timeout);
  1871. h.resize_timeout = setTimeout(function() {
  1872. E()
  1873. }, 25)
  1874. });
  1875. h.open_window = rcmail.open_window;
  1876. rcmail.open_window = Ba;
  1877. rcmail.addEventListener("message", ra).addEventListener("menu-open", R).addEventListener("menu-close", R).addEventListener("editor-init", la).addEventListener("autocomplete_create", W).addEventListener("googiespell_create", W).addEventListener("setquota", ta).addEventListener("enable-command", ma).addEventListener("init", A);
  1878. window.MutationObserver && window.tinymce && (new MutationObserver(function(a) {
  1879. $.each(a, function() {
  1880. $.each(this.addedNodes, function() {
  1881. ja(this)
  1882. })
  1883. })
  1884. }
  1885. )).observe(document.body, {
  1886. childList: !0
  1887. });
  1888. if ((f.list.length || f.content.length) && r()) {
  1889. var a = [];
  1890. $("[data-fab]").each(function() {
  1891. var b = $(this)
  1892. , c = b.data("fab-task") || "*"
  1893. , d = b.data("fab-action") || "*";
  1894. "*" != c && c != rcmail.env.task || "*" != d && d != rcmail.env.action && ("none" != d || rcmail.env.action) || a.push(t(b, !1, !1, !0))
  1895. });
  1896. a.length && $('<div class="floating-action-buttons">').append(a).appendTo(f.list.length ? f.list : f.content)
  1897. }
  1898. f.sidebar.length && ha(f.sidebar);
  1899. f.list.length && ha(f.list)
  1900. }
  1901. )();
  1902. u();
  1903. (function() {
  1904. if (!h.got_smart_toolbar) {
  1905. h.got_smart_toolbar = !0;
  1906. var a, b = [], c = [], d = H(), e = function(a, b, d) {
  1907. var c = $('<li role="menuitem">');
  1908. a = d ? t($(a), !0, "hidden-big hidden-large") : $(a).detach();
  1909. a.contents().filter(function() {
  1910. 3 != this.nodeType || $.trim(this.nodeValue).length || $(this).remove()
  1911. });
  1912. a.is(".spacer") ? c.addClass("spacer") : c.append(a);
  1913. b.push(c)
  1914. };
  1915. f.content.find(".header > .menu").each(function() {
  1916. var a = $(this);
  1917. a.children().each(function() {
  1918. e(this, b)
  1919. });
  1920. a.remove()
  1921. });
  1922. f.list.find(".header > .menu").each(function() {
  1923. var g = $(this);
  1924. a = g.next();
  1925. g.children().each(function() {
  1926. "large" != d.mode && $(this).data("popup-pos", "right");
  1927. e(this, b, !0);
  1928. e(this, c)
  1929. });
  1930. g.remove()
  1931. });
  1932. $('ul[data-menu="toolbar-small"] > li > a').each(function() {
  1933. var a = $(this).clone();
  1934. a.attr("id", this.id + "_clone");
  1935. b.push($('<li role="menuitem">').addClass("hidden-big").append(a))
  1936. });
  1937. if (c.length) {
  1938. var g = f.list.children(".header")
  1939. , l = {
  1940. "class": "menu toolbar popupmenu listing iconized",
  1941. id: "toolbar-list-menu"
  1942. }
  1943. , k = $('<a class="button icon toolbar-list-button" href="#list-menu">').attr({
  1944. "data-popup": "toolbar-list-menu"
  1945. });
  1946. l = $("<ul>").attr(l).data("popup-parent", g).append(c);
  1947. a.length ? l.insertBefore(a) : g.append(l);
  1948. g.append(k)
  1949. }
  1950. b.length && (g = f.content.children(".header"),
  1951. l = {
  1952. "class": "menu toolbar popupmenu listing iconized",
  1953. id: "toolbar-menu"
  1954. },
  1955. k = $('<a class="button icon toolbar-menu-button" href="#menu">').attr({
  1956. "data-popup": "toolbar-menu"
  1957. }),
  1958. g.append($("<ul>").attr(l).data("popup-parent", g).append(b)).append(k),
  1959. f.list.find("a.toolbar-menu-button").click(function(a) {
  1960. a.stopPropagation();
  1961. k.click()
  1962. }))
  1963. }
  1964. }
  1965. )();
  1966. (function() {
  1967. var a = h.last_selected
  1968. , b = function(a) {
  1969. "string" === typeof a && a.length || (a = $("h1.voice").text() || $("title").text() || "");
  1970. f.content.find(".header > .header-title").text(a)
  1971. }
  1972. , c = function(d, c, e, m) {
  1973. r() && h.frame_nav && ka(c, d);
  1974. e && !f.content.is(":visible") ? h.last_selected = f.content[0] : e || h.last_selected == a || h.content_lock || (h.last_selected = a);
  1975. M();
  1976. b(m && e ? m : null);
  1977. h.content_lock = !1
  1978. }
  1979. , d = function(a) {
  1980. "large" != q && !h.content_lock && a.force && P();
  1981. h.content_lock = !1;
  1982. a.title && $(".header > .header-title", f.list).text(a.title)
  1983. }
  1984. , e = function(a) {
  1985. var b = {};
  1986. if ("addressbook" == rcmail.env.task || "mail" == rcmail.env.task)
  1987. b.force = !0;
  1988. "mail" != rcmail.env.task || rcmail.env.action || (a = "string" == $.type(a) ? a : rcmail.env.mailbox,
  1989. a = rcmail.env.mailboxes[a],
  1990. b.title = a ? a.name : "");
  1991. d(b)
  1992. };
  1993. f.content.find("iframe").on("load", function(a) {
  1994. var d = ""
  1995. , e = !0;
  1996. $(this).parent(".iframe-wrapper").scrollTop(0);
  1997. try {
  1998. d = a.target.contentWindow.location.href,
  1999. e = !d.endsWith(rcmail.env.blankpage),
  2000. $(a.target.contentWindow).on("unload", b)
  2001. } catch (Ca) {}
  2002. c(a, d, e)
  2003. });
  2004. rcmail.addEventListener("afterlist", e).addEventListener("afterlistgroup", e).addEventListener("afterlistsearch", e).addEventListener("show-list", function(a) {
  2005. a.force = !0;
  2006. d(a)
  2007. }).addEventListener("show-content", function(a) {
  2008. a.obj && !$(a.obj).is("iframe") && ($(a.scrollElement || a.obj).scrollTop(0),
  2009. r() && G(a.obj));
  2010. c(a.event || new Event, "_action=" + (a.mode || "edit"), !0, a.title)
  2011. })
  2012. }
  2013. )();
  2014. (function() {
  2015. $("[data-popup]").each(function() {
  2016. D(this)
  2017. });
  2018. $(document).on("click", x);
  2019. rcube_webmail.set_iframe_events({
  2020. mousedown: x,
  2021. touchstart: x
  2022. })
  2023. }
  2024. )();
  2025. (function() {
  2026. var a, b, c = [];
  2027. $.ui && $.widget("ui.dialog", $.ui.dialog, {
  2028. open: function() {
  2029. $(this.element).is(".iframe") && (this.options.width = Math.max(576, this.options.width));
  2030. this._super();
  2031. var a = $(this.uiDialog)
  2032. , b = a.width()
  2033. , c = a.height()
  2034. , f = $(window).width()
  2035. , h = $(window).height();
  2036. 480 >= f ? a.css({
  2037. width: "100%",
  2038. height: "100%"
  2039. }) : (c > h && a.css("height", "100%"),
  2040. b > f && a.css("width", "100%"));
  2041. $(document).click();
  2042. G($("div.popup > iframe", a));
  2043. u(this.uiDialog);
  2044. return this
  2045. },
  2046. close: function() {
  2047. this._super();
  2048. $(".select-menu:visible").remove();
  2049. return this
  2050. }
  2051. });
  2052. z.menu.on("click", function() {
  2053. y(!0);
  2054. return !1
  2055. });
  2056. z.back_sidebar.on("click", function() {
  2057. O();
  2058. return !1
  2059. });
  2060. z.back_list.on("click", function() {
  2061. P();
  2062. return !1
  2063. });
  2064. z.back_content.on("click", function() {
  2065. f.list.addClass("hidden");
  2066. f.sidebar.addClass("hidden");
  2067. f.content.removeClass("hidden");
  2068. f.sidebar.removeClass("layout-sticky");
  2069. B();
  2070. h.last_selected = f.content[0];
  2071. return !1
  2072. });
  2073. $(".searchbar").each(function() {
  2074. aa(this)
  2075. });
  2076. !p || rcmail.env.extwin || parent.$(".ui-dialog:visible").length ? p || ((a = f.content.find(".boxtitle").first().detach().text()) || (a = $("h1.voice").first().text()),
  2077. a && f.content.find(".header > .header-title").text(a)) : (a = $("h1.voice").first().text()) && parent.$("#layout-content > .header > .header-title:not(.constant)").text(a);
  2078. p || !f.content.length || f.content.is(".no-navbar") || f.content.children(".frame-content").length || (h.frame_nav = $('<div class="footer menu toolbar content-frame-navigation hide-nav-buttons">').append($('<a class="button prev">').append($('<span class="inner"></span>').text(rcmail.gettext("previous")))).append($('<span class="buttons">')).append($('<a class="button next">').append($('<span class="inner"></span>').text(rcmail.gettext("next")))).appendTo(f.content));
  2079. $("a[data-content-button]").each(function() {
  2080. c.push(t($(this)))
  2081. });
  2082. $(".formbuttons").filter(function() {
  2083. return !$(this).parent(".searchoptions").length
  2084. }).children().each(function() {
  2085. var a = $(this);
  2086. if (p || a.parents("#layout-content").length)
  2087. a.is(".cancel") ? a.addClass("hidden") : c.push(t(a))
  2088. });
  2089. (p ? parent.UI : C).register_content_buttons(c);
  2090. if (b = rcmail.gui_objects.messageform)
  2091. b = $('form[name="' + b + '"]'),
  2092. $("#_cc, #_bcc, #_replyto, #_followupto", $(".compose-headers")).each(function() {
  2093. $(this).on("change", function() {
  2094. $("#compose" + $(this).attr("id"))[this.value ? "removeClass" : "addClass"]("hidden")
  2095. })
  2096. }),
  2097. $("#compose-options").find("textarea,input,select").each(function() {
  2098. var a = $("<input>").attr({
  2099. type: "hidden",
  2100. name: $(this).attr("name")
  2101. }).appendTo(b);
  2102. $(this).attr("tabindex", 2).on("change", function() {
  2103. a.val("checkbox" != this.type || this.checked ? $(this).val() : "")
  2104. }).change()
  2105. });
  2106. $("[data-recipient-input]").each(function() {
  2107. ua(this)
  2108. });
  2109. $(".image-upload").each(function() {
  2110. xa(this)
  2111. });
  2112. $("textarea[data-html-editor]").each(function() {
  2113. ya(this)
  2114. });
  2115. $("#dragmessage-menu,#dragcontact-menu").each(function() {
  2116. rcmail.gui_object("dragmenu", this.id)
  2117. });
  2118. $("#taskmenu > a").each(function() {
  2119. if (/button-([a-z]+)/.test(this.className)) {
  2120. var a, b = RegExp.$1, c = w(this.id);
  2121. c && (a = c.data) && (a.sel && (a.sel = a.sel.replace("button-selected", "selected") + " " + b),
  2122. a.act && (a.act += " " + b),
  2123. rcmail.buttons[c.command][c.index] = a,
  2124. rcmail.init_button(c.command, a));
  2125. $(this).addClass(b);
  2126. $(".button-inner", this).addClass("inner")
  2127. }
  2128. $(this).on("mouseover", function() {
  2129. rcube_webmail.long_subject_title(this, 0, $("span.inner", this))
  2130. })
  2131. });
  2132. $(".listbutton").each(function() {
  2133. var a = w(this.id);
  2134. $(this).addClass("button").removeClass("listbutton");
  2135. a.data.sel && (a.data.sel = a.data.sel.replace("listbutton", "button"));
  2136. a.data.act && (a.data.act = a.data.act.replace("listbutton", "button"));
  2137. rcmail.buttons[a.command][a.index] = a.data;
  2138. rcmail.init_button(a.command, a.data)
  2139. });
  2140. $("[data-hidden]").each(function() {
  2141. for (var a, b = $(this).data("hidden"), c = $(this).parent("li"), f = /(large|big|small|phone|lbs)/g; a = f.exec(b); )
  2142. $(c.length ? c : this).addClass("hidden-" + a[1])
  2143. });
  2144. $("[data-list]").each(function() {
  2145. $("input[type=checkbox]", this).each(function() {
  2146. F(this)
  2147. })
  2148. });
  2149. p && $(".formcontent").each(function() {
  2150. $(this).next(".formbuttons").length && $(this).parent().addClass("formcontainer")
  2151. });
  2152. $("#attachment-list + a.zipdownload").appendTo(".header-links");
  2153. (fa = $("html").is(".ipad,.iphone")) && $(".iframe-wrapper, .scroller").addClass("ios-scroll");
  2154. $("html").filter(".ipad,.iphone,.webkit.mobile,.webkit.tablet").addClass("webkit-scroller").length && $(f.menu).addClass("webkit-scroller");
  2155. $(".treelist").each(function() {
  2156. var a = this
  2157. , b = function() {
  2158. $(a)[0 < $(".treetoggle", a).length ? "removeClass" : "addClass"]("notree")
  2159. };
  2160. window.MutationObserver && (new MutationObserver(b)).observe(a, {
  2161. childList: !0,
  2162. subtree: !0
  2163. });
  2164. b();
  2165. $("li.mailbox > a").on("mouseover", function() {
  2166. rcube_webmail.long_subject_title_ex(this)
  2167. })
  2168. });
  2169. $("#logo").data("src-default") || $("#logo").data("src-default", $("#logo").attr("src"))
  2170. }
  2171. )();
  2172. E()
  2173. }
  2174. if (window.rcmail)
  2175. rcmail.show_menu = function(n, t, w) {
  2176. var A = "object" == typeof n ? n.menu : n
  2177. , u = $("#" + A);
  2178. "string" == typeof n && (n = {
  2179. menu: A
  2180. });
  2181. return rcmail.triggerEvent(!1 === t ? "menu-close" : "menu-open", {
  2182. name: A,
  2183. obj: u,
  2184. props: n,
  2185. originalEvent: w
  2186. })
  2187. }
  2188. ,
  2189. rcmail.hide_menu = function(n, t) {
  2190. return rcmail.triggerEvent("menu-close", {
  2191. name: n,
  2192. props: {
  2193. menu: n
  2194. },
  2195. originalEvent: t
  2196. })
  2197. }
  2198. ;
  2199. else
  2200. var rcmail = parent.rcmail
  2201. , rcube_webmail = parent.rcube_webmail
  2202. , bw = {};
  2203. var UI = new rcube_elastic_ui;
  2204. if ($ && $.datepicker) {
  2205. var __newInst = $.datepicker._newInst;
  2206. $.extend($.datepicker, {
  2207. _newInst: function(n, t) {
  2208. n = __newInst.call(this, n, t);
  2209. n.inline || UI.datepicker_init(n.dpDiv);
  2210. return n
  2211. }
  2212. })
  2213. }
  2214. ;
RAW Paste Data