/*! * froala_editor v2.9.0 (https://www.froala.com/wysiwyg-editor) * License https://froala.com/wysiwyg-editor/terms/ * Copyright 2014-2018 Froala Labs */ ! function(n) { "function" == typeof define && define.amd ? define(["jquery"], n) : "object" == typeof module && module.exports ? module.exports = function(e, t) { return t === undefined && (t = "undefined" != typeof window ? require("jquery") : require("jquery")(e)), n(t) } : n(window.jQuery) }(function(be) { var s = function(e, t) { this.id = ++be.FE.ID; var n = {}; t && t.documentReady && (n.toolbarButtons = ["fullscreen", "undo", "redo", "getPDF", "print", "|", "bold", "italic", "underline", "color", "clearFormatting", "|", "alignLeft", "alignCenter", "alignRight", "alignJustify", "|", "formatOL", "formatUL", "indent", "outdent", "-", "paragraphFormat", "|", "fontFamily", "|", "fontSize", "|", "insertLink", "insertImage", "quote"], n.paragraphFormatSelection = !0, n.fontFamilySelection = !0, n.fontSizeSelection = !0, n.placeholderText = "", n.quickInsertEnabled = !1, n.charCounterCount = !1), this.opts = be.extend(!0, {}, be.extend({}, s.DEFAULTS, n, "object" == typeof t && t)); var r = JSON.stringify(this.opts); be.FE.OPTS_MAPPING[r] = be.FE.OPTS_MAPPING[r] || this.id, this.sid = be.FE.OPTS_MAPPING[r], be.FE.SHARED[this.sid] = be.FE.SHARED[this.sid] || {}, this.shared = be.FE.SHARED[this.sid], this.shared.count = (this.shared.count || 0) + 1, this.$oel = be(e), this.$oel.data("froala.editor", this), this.o_doc = e.ownerDocument, this.o_win = "defaultView" in this.o_doc ? this.o_doc.defaultView : this.o_doc.parentWindow; var i = be(this.o_win).scrollTop(); this.$oel.on("froala.doInit", be.proxy(function() { this.$oel.off("froala.doInit"), this.doc = this.$el.get(0).ownerDocument, this.win = "defaultView" in this.doc ? this.doc.defaultView : this.doc.parentWindow, this.$doc = be(this.doc), this.$win = be(this.win), this.opts.pluginsEnabled || (this.opts.pluginsEnabled = Object.keys(be.FE.PLUGINS)), this.opts.initOnClick ? (this.load(be.FE.MODULES), this.$el.on("touchstart.init", function() { be(this).data("touched", !0) }), this.$el.on("touchmove.init", function() { be(this).removeData("touched") }), this.$el.on("mousedown.init touchend.init dragenter.init focus.init", be.proxy(function(e) { if ("touchend" == e.type && !this.$el.data("touched")) return !0; if (1 === e.which || !e.which) { this.$el.off("mousedown.init touchstart.init touchmove.init touchend.init dragenter.init focus.init"), this.load(be.FE.MODULES), this.load(be.FE.PLUGINS); var t = e.originalEvent && e.originalEvent.originalTarget; t && "IMG" == t.tagName && be(t).trigger("mousedown"), "undefined" == typeof this.ul && this.destroy(), "touchend" == e.type && this.image && e.originalEvent && e.originalEvent.target && be(e.originalEvent.target).is("img") && setTimeout(be.proxy(function() { this.image.edit(be(e.originalEvent.target)) }, this), 100), this.ready = !0, this.events.trigger("initialized") } }, this)), this.events.trigger("initializationDelayed")) : (this.load(be.FE.MODULES), this.load(be.FE.PLUGINS), be(this.o_win).scrollTop(i), "undefined" == typeof this.ul && this.destroy(), this.ready = !0, this.events.trigger("initialized")) }, this)), this._init() }; s.DEFAULTS = { initOnClick: !1, pluginsEnabled: null }, s.MODULES = {}, s.PLUGINS = {}, s.VERSION = "2.9.0", s.INSTANCES = [], s.OPTS_MAPPING = {}, s.SHARED = {}, s.ID = 0, s.prototype._init = function() { var e = this.$oel.prop("tagName"); 1 <= this.$oel.closest("label").length && console.warn("Note! It is not recommended to initialize the Froala Editor within a label tag."); var t = be.proxy(function() { "TEXTAREA" != e && (this._original_html = this._original_html || this.$oel.html()), this.$box = this.$box || this.$oel, this.opts.fullPage && (this.opts.iframe = !0), this.opts.iframe ? (this.$iframe = be('', provider: "youtube" }, { test_regex: /^.*(?:vimeo.com)\/(?:channels(\/\w+\/)?|groups\/*\/videos\/\u200b\d+\/|video\/|)(\d+)(?:$|\/|\?)/, url_regex: /(?:https?:\/\/)?(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|video\/|)(\d+)(?:[a-zA-Z0-9_\-]+)?(\/[a-zA-Z0-9_\-]+)?/i, url_text: "https://player.vimeo.com/video/$1", html: '', provider: "vimeo" }, { test_regex: /^.+(dailymotion.com|dai.ly)\/(video|hub)?\/?([^_]+)[^#]*(#video=([^_&]+))?/, url_regex: /(?:https?:\/\/)?(?:www\.)?(?:dailymotion\.com|dai\.ly)\/(?:video|hub)?\/?(.+)/g, url_text: "https://www.dailymotion.com/embed/video/$1", html: '', provider: "dailymotion" }, { test_regex: /^.+(screen.yahoo.com)\/[^_&]+/, url_regex: "", url_text: "", html: '', provider: "yahoo" }, { test_regex: /^.+(rutube.ru)\/[^_&]+/, url_regex: /(?:https?:\/\/)?(?:www\.)?(?:rutube\.ru)\/(?:video)?\/?(.+)/g, url_text: "https://rutube.ru/play/embed/$1", html: '', provider: "rutube" }, { test_regex: /^(?:.+)vidyard.com\/(?:watch)?\/?([^.&/]+)\/?(?:[^_.&]+)?/, url_regex: /^(?:.+)vidyard.com\/(?:watch)?\/?([^.&/]+)\/?(?:[^_.&]+)?/g, url_text: "https://play.vidyard.com/$1", html: '', provider: "vidyard" }], be.FE.VIDEO_EMBED_REGEX = /^\W*((<\/iframe>)|())\W*$/i, be.FE.PLUGINS.video = function(f) { var s, c, p, u, r, n, d = "https://i.froala.com/upload", l = 2, h = 3, g = 4, m = 5, v = 6, i = {}; function E() { var e = f.popups.get("video.insert"); e.find(".fr-video-by-url-layer input").val("").trigger("change"); var t = e.find(".fr-video-embed-layer textarea"); t.val("").trigger("change"), (t = e.find(".fr-video-upload-layer input")).val("").trigger("change") } function a() { var e = f.popups.get("video.edit"); if (e || (e = function() { var e = ""; if (0 < f.opts.videoEditButtons.length) { f.opts.videoResponsive && (f.opts.videoEditButtons.splice(f.opts.videoEditButtons.indexOf("videoSize"), 1), f.opts.videoEditButtons.splice(f.opts.videoEditButtons.indexOf("videoDisplay"), 1), f.opts.videoEditButtons.splice(f.opts.videoEditButtons.indexOf("videoAlign"), 1)), e += '
', e += f.button.buildList(f.opts.videoEditButtons); var t = { buttons: e += "
" }, n = f.popups.create("video.edit", t); return f.events.$on(f.$wp, "scroll.video-edit", function() { u && f.popups.isVisible("video.edit") && (f.events.disableBlur(), y(u)) }), n } return !1 }()), e) { f.popups.setContainer("video.edit", f.$sc), f.popups.refresh("video.edit"); var t = u.find("iframe, embed, video"), n = t.offset().left + t.outerWidth() / 2, r = t.offset().top + t.outerHeight(); f.popups.show("video.edit", n, r, t.outerHeight()) } } function o(e) { if (e) return f.popups.onRefresh("video.insert", E), f.popups.onHide("image.insert", V), !0; var t = ""; f.opts.videoUpload || f.opts.videoInsertButtons.splice(f.opts.videoInsertButtons.indexOf("videoUpload"), 1), 1 < f.opts.videoInsertButtons.length && (t = '
' + f.button.buildList(f.opts.videoInsertButtons) + "
"); var n, r = "", i = f.opts.videoInsertButtons.indexOf("videoUpload"), a = f.opts.videoInsertButtons.indexOf("videoByURL"), o = f.opts.videoInsertButtons.indexOf("videoEmbed"); 0 <= a && (n = " fr-active", (i < a && 0 <= i || o < a && 0 <= o) && (n = ""), r = '
"); var s = ""; 0 <= o && (n = " fr-active", (i < o && 0 <= i || a < o && 0 <= a) && (n = ""), s = '
"); var l = ""; 0 <= i && (n = " fr-active", (o < i && 0 <= o || a < i && 0 <= a) && (n = ""), l = '
' + f.language.translate("Drop video") + "
(" + f.language.translate("or click") + ')
'); var d = { buttons: t, by_url_layer: r, embed_layer: s, upload_layer: l, progress_bar: '

Uploading

' }, c = f.popups.create("video.insert", d); return function(r) { f.events.$on(r, "dragover dragenter", ".fr-video-upload-layer", function() { return be(this).addClass("fr-drop"), !1 }, !0), f.events.$on(r, "dragleave dragend", ".fr-video-upload-layer", function() { return be(this).removeClass("fr-drop"), !1 }, !0), f.events.$on(r, "drop", ".fr-video-upload-layer", function(e) { e.preventDefault(), e.stopPropagation(), be(this).removeClass("fr-drop"); var t = e.originalEvent.dataTransfer; if (t && t.files) { var n = r.data("instance") || f; n.events.disableBlur(), n.video.upload(t.files), n.events.enableBlur() } }, !0), f.helpers.isIOS() && f.events.$on(r, "touchstart", '.fr-video-upload-layer input[type="file"]', function() { be(this).trigger("click") }, !0); f.events.$on(r, "change", '.fr-video-upload-layer input[type="file"]', function() { if (this.files) { var e = r.data("instance") || f; e.events.disableBlur(), r.find("input:focus").blur(), e.events.enableBlur(), e.video.upload(this.files) } be(this).val("") }, !0) }(c), c } function b(e) { f.events.focus(!0), f.selection.restore(); var t = !1; u && (G(), t = !0), f.html.insert('' + e + "", !1, f.opts.videoSplitHTML), f.popups.hide("video.insert"); var n = f.$el.find(".fr-jiv"); n.removeClass("fr-jiv"), n.toggleClass("fr-rv", f.opts.videoResponsive), X(n, f.opts.videoDefaultDisplay, f.opts.videoDefaultAlign), n.toggleClass("fr-draggable", f.opts.videoMove), f.events.trigger(t ? "video.replaced" : "video.inserted", [n]) } function T() { var e = be(this); f.popups.hide("video.insert"), e.removeClass("fr-uploading"), e.parent().next().is("br") && e.parent().next().remove(), y(e.parent()), f.events.trigger("video.loaded", [e.parent()]) } function A(s, e, l, d, c) { f.edit.off(), R("Loading video"), e && (s = f.helpers.sanitizeURL(s)); C("Loading video"), function() { var e, t; if (d) { f.undo.canDo() || d.find("video").hasClass("fr-uploading") || f.undo.saveStep(); var n = d.find("video").data("fr-old-src"), r = d.data("fr-replaced"); d.data("fr-replaced", !1), f.$wp ? ((e = d.clone()).find("video").removeData("fr-old-src").removeClass("fr-uploading"), e.find("video").off("canplay"), n && d.find("video").attr("src", n), d.replaceWith(e)) : e = d; for (var i = e.find("video").get(0).attributes, a = 0; a < i.length; a++) { var o = i[a]; 0 === o.nodeName.indexOf("data-") && e.find("video").removeAttr(o.nodeName) } if (void 0 !== l) for (t in l) l.hasOwnProperty(t) && "link" != t && e.find("video").attr("data-" + t, l[t]); e.find("video").on("canplay", T), e.find("video").attr("src", s), f.edit.on(), k(), f.undo.saveStep(), f.$el.blur(), f.events.trigger(r ? "video.replaced" : "video.inserted", [e, c]) } else e = function(e, t, n) { var r, i = ""; if (t && void 0 !== t) for (r in t) t.hasOwnProperty(r) && "link" != r && (i += " data-" + r + '="' + t[r] + '"'); var a = f.opts.videoDefaultWidth; a && "auto" != a && (a += "px"); var o = be('"); o.toggleClass("fr-draggable", f.opts.videoMove), f.edit.on(), f.events.focus(!0), f.selection.restore(), f.undo.saveStep(), f.opts.videoSplitHTML ? f.markers.split() : f.markers.insert(), f.html.wrap(); var s = f.$el.find(".fr-marker"); return f.node.isLastSibling(s) && s.parent().hasClass("fr-deletable") && s.insertAfter(s.parent()), s.replaceWith(o), f.selection.clear(), o.find("video").get(0).readyState > o.find("video").get(0).HAVE_FUTURE_DATA || f.helpers.isIOS() ? n.call(o.find("video").get(0)) : o.find("video").on("canplaythrough load", n), o }(s, l, T), k(), f.undo.saveStep(), f.events.trigger("video.inserted", [e, c]) }() } function C(e) { var t = f.popups.get("video.insert"); if (t || (t = o()), t.find(".fr-layer.fr-active").removeClass("fr-active").addClass("fr-pactive"), t.find(".fr-video-progress-bar-layer").addClass("fr-active"), t.find(".fr-buttons").hide(), u) { var n = u.find("video"); f.popups.setContainer("video.insert", f.$sc); var r = n.offset().left + n.width() / 2, i = n.offset().top + n.height(); f.popups.show("video.insert", r, i, n.outerHeight()) } void 0 === e && R(f.language.translate("Uploading"), 0) } function S(e) { var t = f.popups.get("video.insert"); if (t && (t.find(".fr-layer.fr-pactive").addClass("fr-active").removeClass("fr-pactive"), t.find(".fr-video-progress-bar-layer").removeClass("fr-active"), t.find(".fr-buttons").show(), e || f.$el.find("video.fr-error").length)) { if (f.events.focus(), f.$el.find("video.fr-error").length && (f.$el.find("video.fr-error").parent().remove(), f.undo.saveStep(), f.undo.run(), f.undo.dropRedo()), !f.$wp && u) { var n = u; $(!0), f.selection.setAfter(n.find("video").get(0)), f.selection.restore() } f.popups.hide("video.insert") } } function R(e, t) { var n = f.popups.get("video.insert"); if (n) { var r = n.find(".fr-video-progress-bar-layer"); r.find("h3").text(e + (t ? " " + t + "%" : "")), r.removeClass("fr-error"), t ? (r.find("div").removeClass("fr-indeterminate"), r.find("div > span").css("width", t + "%")) : r.find("div").addClass("fr-indeterminate") } } function y(e) { M.call(e.get(0)) } function _(e) { R("Loading video"); var t = this.status, n = this.response, r = this.responseXML, i = this.responseText; try { if (f.opts.videoUploadToS3) if (201 == t) { var a = function(e) { try { var t = be(e).find("Location").text(), n = be(e).find("Key").text(); return !1 === f.events.trigger("video.uploadedToS3", [t, n, e], !0) ? (f.edit.on(), !1) : t } catch (r) { return K(g, e), !1 } }(r); a && A(a, !1, [], e, n || r) } else K(g, n || r); else if (200 <= t && t < 300) { var o = function(e) { try { if (!1 === f.events.trigger("video.uploaded", [e], !0)) return f.edit.on(), !1; var t = JSON.parse(e); return t.link ? t : (K(l, e), !1) } catch (n) { return K(g, e), !1 } }(i); o && A(o.link, !1, o, e, n || i) } else K(h, n || i) } catch (s) { K(g, n || i) } } function L() { K(g, this.response || this.responseText || this.responseXML) } function x(e) { if (e.lengthComputable) { var t = e.loaded / e.total * 100 | 0; R(f.language.translate("Uploading"), t) } } function w() { f.edit.on(), S(!0) } function N(e) { if (!f.core.sameInstance(p)) return !0; e.preventDefault(), e.stopPropagation(); var t = e.pageX || (e.originalEvent.touches ? e.originalEvent.touches[0].pageX : null), n = e.pageY || (e.originalEvent.touches ? e.originalEvent.touches[0].pageY : null); if (!t || !n) return !1; if ("mousedown" == e.type) { var r = f.$oel.get(0).ownerDocument, i = r.defaultView || r.parentWindow, a = !1; try { a = i.location != i.parent.location && !(i.$ && i.$.FE) } catch (o) {} a && i.frameElement && (t += f.helpers.getPX(be(i.frameElement).offset().left) + i.frameElement.clientLeft, n = e.clientY + f.helpers.getPX(be(i.frameElement).offset().top) + i.frameElement.clientTop) } f.undo.canDo() || f.undo.saveStep(), (c = be(this)).data("start-x", t), c.data("start-y", n), s.show(), f.popups.hideAll(), B() } function O(e) { if (!f.core.sameInstance(p)) return !0; if (c) { e.preventDefault(); var t = e.pageX || (e.originalEvent.touches ? e.originalEvent.touches[0].pageX : null), n = e.pageY || (e.originalEvent.touches ? e.originalEvent.touches[0].pageY : null); if (!t || !n) return !1; var r = c.data("start-x"), i = c.data("start-y"); c.data("start-x", t), c.data("start-y", n); var a = t - r, o = n - i, s = u.find("iframe, embed, video"), l = s.width(), d = s.height(); (c.hasClass("fr-hnw") || c.hasClass("fr-hsw")) && (a = 0 - a), (c.hasClass("fr-hnw") || c.hasClass("fr-hne")) && (o = 0 - o), s.css("width", l + a), s.css("height", d + o), s.removeAttr("width"), s.removeAttr("height"), F() } } function I(e) { if (!f.core.sameInstance(p)) return !0; c && u && (e && e.stopPropagation(), c = null, s.hide(), F(), a(), f.undo.saveStep()) } function t(e) { return '
' } function D(e, t, n, r) { return e.pageX = t, e.pageY = t, N.call(this, e), e.pageX = e.pageX + n * Math.floor(Math.pow(1.1, r)), e.pageY = e.pageY + n * Math.floor(Math.pow(1.1, r)), O.call(this, e), I.call(this, e), ++r } function k() { var e, t = Array.prototype.slice.call(f.el.querySelectorAll("video, .fr-video > *")), n = []; for (e = 0; e < t.length; e++) n.push(t[e].getAttribute("src")), be(t[e]).toggleClass("fr-draggable", f.opts.videoMove), "" === t[e].getAttribute("class") && t[e].removeAttribute("class"), "" === t[e].getAttribute("style") && t[e].removeAttribute("style"); if (r) for (e = 0; e < r.length; e++) n.indexOf(r[e].getAttribute("src")) < 0 && f.events.trigger("video.removed", [be(r[e])]); r = t } function F() { p || function() { var e; if (f.shared.$video_resizer ? (p = f.shared.$video_resizer, s = f.shared.$vid_overlay, f.events.on("destroy", function() { p.removeClass("fr-active").appendTo(be("body:first")) }, !0)) : (f.shared.$video_resizer = be('
'), p = f.shared.$video_resizer, f.events.$on(p, "mousedown", function(e) { e.stopPropagation() }, !0), f.opts.videoResize && (p.append(t("nw") + t("ne") + t("sw") + t("se")), f.shared.$vid_overlay = be('
'), s = f.shared.$vid_overlay, e = p.get(0).ownerDocument, be(e).find("body:first").append(s))), f.events.on("shared.destroy", function() { p.html("").removeData().remove(), p = null, f.opts.videoResize && (s.remove(), s = null) }, !0), f.helpers.isMobile() || f.events.$on(be(f.o_win), "resize.video", function() { $(!0) }), f.opts.videoResize) { e = p.get(0).ownerDocument, f.events.$on(p, f._mousedown, ".fr-handler", N), f.events.$on(be(e), f._mousemove, O), f.events.$on(be(e.defaultView || e.parentWindow), f._mouseup, I), f.events.$on(s, "mouseleave", I); var r = 1, i = null, a = 0; f.events.on("keydown", function(e) { if (u) { var t = -1 != navigator.userAgent.indexOf("Mac OS X") ? e.metaKey : e.ctrlKey, n = e.which; (n !== i || 200 < e.timeStamp - a) && (r = 1), (n == be.FE.KEYCODE.EQUALS || f.browser.mozilla && n == be.FE.KEYCODE.FF_EQUALS) && t && !e.altKey ? r = D.call(this, e, 1, 1, r) : (n == be.FE.KEYCODE.HYPHEN || f.browser.mozilla && n == be.FE.KEYCODE.FF_HYPHEN) && t && !e.altKey && (r = D.call(this, e, 2, -1, r)), i = n, a = e.timeStamp } }), f.events.on("keyup", function() { r = 1 }) } }(), (f.$wp || f.$sc).append(p), p.data("instance", f); var e = u.find("iframe, embed, video"); p.css("top", (f.opts.iframe ? e.offset().top - 1 : e.offset().top - f.$wp.offset().top - 1) + f.$wp.scrollTop()).css("left", (f.opts.iframe ? e.offset().left - 1 : e.offset().left - f.$wp.offset().left - 1) + f.$wp.scrollLeft()).css("width", e.get(0).getBoundingClientRect().width).css("height", e.get(0).getBoundingClientRect().height).addClass("fr-active") } function M(e) { if (e && "touchend" == e.type && n) return !0; if (e && f.edit.isDisabled()) return e.stopPropagation(), e.preventDefault(), !1; if (f.edit.isDisabled()) return !1; for (var t = 0; t < be.FE.INSTANCES.length; t++) be.FE.INSTANCES[t] != f && be.FE.INSTANCES[t].events.trigger("video.hideResizer"); f.toolbar.disable(), f.helpers.isMobile() && (f.events.disableBlur(), f.$el.blur(), f.events.enableBlur()), f.$el.find(".fr-video.fr-active").removeClass("fr-active"), (u = be(this)).addClass("fr-active"), f.opts.iframe && f.size.syncIframe(), j(), F(), a(), f.selection.clear(), f.button.bulkRefresh(), f.events.trigger("image.hideResizer") } function $(e) { u && (f.shared.vid_exit_flag || !0 === e) && (p.removeClass("fr-active"), f.toolbar.enable(), u.removeClass("fr-active"), u = null, B()) } function e() { f.shared.vid_exit_flag = !0 } function B() { f.shared.vid_exit_flag = !1 } function P(e) { var t = e.originalEvent.dataTransfer; if (t && t.files && t.files.length) { var n = t.files[0]; if (n && n.type && -1 !== n.type.indexOf("video")) { if (!f.opts.videoUpload) return e.preventDefault(), e.stopPropagation(), !1; f.markers.remove(), f.markers.insertAtPoint(e.originalEvent), f.$el.find(".fr-marker").replaceWith(be.FE.MARKERS), f.popups.hideAll(); var r = f.popups.get("video.insert"); return r || (r = o()), f.popups.setContainer("video.insert", f.$sc), f.popups.show("video.insert", e.originalEvent.pageX, e.originalEvent.pageY), C(), 0 <= f.opts.videoAllowedTypes.indexOf(n.type.replace(/video\//g, "")) ? U(t.files) : K(v), e.preventDefault(), e.stopPropagation(), !1 } } } function U(e) { if (void 0 !== e && 0 < e.length) { if (!1 === f.events.trigger("video.beforeUpload", [e])) return !1; var t, n = e[0]; if ((null === f.opts.videoUploadURL || f.opts.videoUploadURL == d) && !f.opts.videoUploadToS3) return s = n, (l = new FileReader).addEventListener("load", function() { l.result; for (var e = atob(l.result.split(",")[1]), t = [], n = 0; n < e.length; n++) t.push(e.charCodeAt(n)); A(window.URL.createObjectURL(new Blob([new Uint8Array(t)], { type: s.type })), !1, null, u) }, !1), C(), l.readAsDataURL(s), !1; if (n.size > f.opts.videoMaxSize) return K(m), !1; if (f.opts.videoAllowedTypes.indexOf(n.type.replace(/video\//g, "")) < 0) return K(v), !1; if (f.drag_support.formdata && (t = f.drag_support.formdata ? new FormData : null), t) { var r; if (!1 !== f.opts.videoUploadToS3) for (r in t.append("key", f.opts.videoUploadToS3.keyStart + (new Date).getTime() + "-" + (n.name || "untitled")), t.append("success_action_status", "201"), t.append("X-Requested-With", "xhr"), t.append("Content-Type", n.type), f.opts.videoUploadToS3.params) f.opts.videoUploadToS3.params.hasOwnProperty(r) && t.append(r, f.opts.videoUploadToS3.params[r]); for (r in f.opts.videoUploadParams) f.opts.videoUploadParams.hasOwnProperty(r) && t.append(r, f.opts.videoUploadParams[r]); t.append(f.opts.videoUploadParam, n); var i = f.opts.videoUploadURL; f.opts.videoUploadToS3 && (i = f.opts.videoUploadToS3.uploadURL ? f.opts.videoUploadToS3.uploadURL : "https://" + f.opts.videoUploadToS3.region + ".amazonaws.com/" + f.opts.videoUploadToS3.bucket); var a = f.core.getXHR(i, f.opts.videoUploadMethod); a.onload = function() { _.call(a, u) }, a.onerror = L, a.upload.onprogress = x, a.onabort = w, C(), f.events.disableBlur(), f.edit.off(), f.events.enableBlur(); var o = f.popups.get("video.insert"); o && o.off("abortUpload").on("abortUpload", function() { 4 != a.readyState && a.abort() }), a.send(t) } } var s, l } function K(e, t) { f.edit.on(), u && u.find("video").addClass("fr-error"), function(e) { C(); var t = f.popups.get("video.insert").find(".fr-video-progress-bar-layer"); t.addClass("fr-error"); var n = t.find("h3"); n.text(e), f.events.disableBlur(), n.focus() }(f.language.translate("Something went wrong. Please try again.")), f.events.trigger("video.error", [{ code: e, message: i[e] }, t]) } function H() { if (u) { var e = f.popups.get("video.size"), t = u.find("iframe, embed, video"); e.find('input[name="width"]').val(t.get(0).style.width || t.attr("width")).trigger("change"), e.find('input[name="height"]').val(t.get(0).style.height || t.attr("height")).trigger("change") } } function W(e) { if (e) return f.popups.onRefresh("video.size", H), !0; var t = { buttons: '
' + f.button.buildList(f.opts.videoSizeButtons) + "
", size_layer: '
" }, n = f.popups.create("video.size", t); return f.events.$on(f.$wp, "scroll", function() { u && f.popups.isVisible("video.size") && (f.events.disableBlur(), y(u)) }), n } function z(e) { if (void 0 === e && (e = u), e) { if (e.hasClass("fr-fvl")) return "left"; if (e.hasClass("fr-fvr")) return "right"; if (e.hasClass("fr-dvb") || e.hasClass("fr-dvi")) return "center"; if ("block" == e.css("display")) { if ("left" == e.css("text-algin")) return "left"; if ("right" == e.css("text-align")) return "right" } else { if ("left" == e.css("float")) return "left"; if ("right" == e.css("float")) return "right" } } return "center" } function Y(e) { void 0 === e && (e = u); var t = e.css("float"); return e.css("float", "none"), "block" == e.css("display") ? (e.css("float", ""), e.css("float") != t && e.css("float", t), "block") : (e.css("float", ""), e.css("float") != t && e.css("float", t), "inline") } function G() { if (u && !1 !== f.events.trigger("video.beforeRemove", [u])) { var e = u; f.popups.hideAll(), $(!0), f.selection.setBefore(e.get(0)) || f.selection.setAfter(e.get(0)), e.remove(), f.selection.restore(), f.html.fillEmptyBlocks(), f.events.trigger("video.removed", [e]) } } function V() { S() } function X(e, t, n) { !f.opts.htmlUntouched && f.opts.useClasses ? (e.removeClass("fr-fvl fr-fvr fr-dvb fr-dvi"), e.addClass("fr-fv" + n[0] + " fr-dv" + t[0])) : "inline" == t ? (e.css({ display: "inline-block" }), "center" == n ? e.css({ "float": "none" }) : "left" == n ? e.css({ "float": "left" }) : e.css({ "float": "right" })) : (e.css({ display: "block", clear: "both" }), "left" == n ? e.css({ textAlign: "left" }) : "right" == n ? e.css({ textAlign: "right" }) : e.css({ textAlign: "center" })) } function q() { f.$el.find("video").filter(function() { return 0 === be(this).parents("span.fr-video").length }).wrap(''), f.$el.find("embed, iframe").filter(function() { if (f.browser.safari && this.getAttribute("src") && this.setAttribute("src", this.src), 0 < be(this).parents("span.fr-video").length) return !1; for (var e = be(this).attr("src"), t = 0; t < be.FE.VIDEO_PROVIDERS.length; t++) { var n = be.FE.VIDEO_PROVIDERS[t]; if (n.test_regex.test(e) && new RegExp(f.opts.videoAllowedProviders.join("|")).test(n.provider)) return !0 } return !1 }).map(function() { return 0 === be(this).parents("object").length ? this : be(this).parents("object").get(0) }).wrap(''); for (var e, t, n = f.$el.find("span.fr-video, video"), r = 0; r < n.length; r++) { var i = be(n[r]); !f.opts.htmlUntouched && f.opts.useClasses ? ((t = i).hasClass("fr-dvi") || t.hasClass("fr-dvb") || (t.addClass("fr-fv" + z(t)[0]), t.addClass("fr-dv" + Y(t)[0])), f.opts.videoTextNear || i.removeClass("fr-dvi").addClass("fr-dvb")) : f.opts.htmlUntouched || f.opts.useClasses || (X(e = i, e.hasClass("fr-dvb") ? "block" : e.hasClass("fr-dvi") ? "inline" : null, e.hasClass("fr-fvl") ? "left" : e.hasClass("fr-fvr") ? "right" : z(e)), e.removeClass("fr-dvb fr-dvi fr-fvr fr-fvl")) } n.toggleClass("fr-draggable", f.opts.videoMove) } function j() { if (u) { f.selection.clear(); var e = f.doc.createRange(); e.selectNode(u.get(0)), f.selection.get().addRange(e) } } return i[1] = "Video cannot be loaded from the passed link.", i[l] = "No link in upload response.", i[h] = "Error during file upload.", i[g] = "Parsing response failed.", i[m] = "File is too large.", i[v] = "Video file type is invalid.", i[7] = "Files can be uploaded only to same domain in IE 8 and IE 9.", f.shared.vid_exit_flag = !1, { _init: function() { f.opts.videoResponsive && (f.opts.videoResize = !1), f.events.on("drop", P, !0), f.events.on("mousedown window.mousedown", e), f.events.on("window.touchmove", B), f.events.on("mouseup window.mouseup", $), f.events.on("commands.mousedown", function(e) { 0 < e.parents(".fr-toolbar").length && $() }), f.events.on("video.hideResizer commands.undo commands.redo element.dropped", function() { $(!0) }), f.helpers.isMobile() && (f.events.$on(f.$el, "touchstart", "span.fr-video", function() { n = !1 }), f.events.$on(f.$el, "touchmove", function() { n = !0 })), f.events.on("html.set", q), q(), f.events.$on(f.$el, "mousedown", "span.fr-video", function(e) { e.stopPropagation(), (f.browser.msie || f.browser.edge) && (e.target.dragDrop(), M.call(this, e)) }), f.events.$on(f.$el, "click touchend", "span.fr-video", function(e) { if ("false" == be(this).parents("[contenteditable]:not(.fr-element):not(.fr-img-caption):not(body):first").attr("contenteditable")) return !0; M.call(this, e) }), f.events.on("keydown", function(e) { var t = e.which; return !u || t != be.FE.KEYCODE.BACKSPACE && t != be.FE.KEYCODE.DELETE ? u && t == be.FE.KEYCODE.ESC ? ($(!0), e.preventDefault(), !1) : u && t != be.FE.KEYCODE.F10 && !f.keys.isBrowserAction(e) ? (e.preventDefault(), !1) : void 0 : (e.preventDefault(), G(), f.undo.saveStep(), !1) }, !0), f.events.on("toolbar.esc", function() { if (u) return f.events.disableBlur(), f.events.focus(), !1 }, !0), f.events.on("toolbar.focusEditor", function() { if (u) return !1 }, !0), f.events.on("keydown", function() { f.$el.find("span.fr-video:empty").remove() }), f.$wp && (k(), f.events.on("contentChanged", k)), o(!0), W(!0) }, showInsertPopup: function() { var e = f.$tb.find('.fr-command[data-cmd="insertVideo"]'), t = f.popups.get("video.insert"); if (t || (t = o()), S(), !t.hasClass("fr-active")) if (f.popups.refresh("video.insert"), f.popups.setContainer("video.insert", f.$tb), e.is(":visible")) { var n = e.offset().left + e.outerWidth() / 2, r = e.offset().top + (f.opts.toolbarBottom ? 10 : e.outerHeight() - 10); f.popups.show("video.insert", n, r, e.outerHeight()) } else f.position.forSelection(t), f.popups.show("video.insert") }, showLayer: function(e) { var t, n, r = f.popups.get("video.insert"); if (!u && !f.opts.toolbarInline) { var i = f.$tb.find('.fr-command[data-cmd="insertVideo"]'); t = i.offset().left + i.outerWidth() / 2, n = i.offset().top + (f.opts.toolbarBottom ? 10 : i.outerHeight() - 10) } f.opts.toolbarInline && (n = r.offset().top - f.helpers.getPX(r.css("margin-top")), r.hasClass("fr-above") && (n += r.outerHeight())), r.find(".fr-layer").removeClass("fr-active"), r.find(".fr-" + e + "-layer").addClass("fr-active"), f.popups.show("video.insert", t, n, 0), f.accessibility.focusPopup(r) }, refreshByURLButton: function(e) { f.popups.get("video.insert").find(".fr-video-by-url-layer").hasClass("fr-active") && e.addClass("fr-active").attr("aria-pressed", !0) }, refreshEmbedButton: function(e) { f.popups.get("video.insert").find(".fr-video-embed-layer").hasClass("fr-active") && e.addClass("fr-active").attr("aria-pressed", !0) }, refreshUploadButton: function(e) { f.popups.get("video.insert").find(".fr-video-upload-layer").hasClass("fr-active") && e.addClass("fr-active").attr("aria-pressed", !0) }, upload: U, insertByURL: function(e) { void 0 === e && (e = (f.popups.get("video.insert").find('.fr-video-by-url-layer input[type="text"]').val() || "").trim()); var t = null; if (/^http/.test(e) || (e = "https://" + e), f.helpers.isURL(e)) for (var n = 0; n < be.FE.VIDEO_PROVIDERS.length; n++) { var r = be.FE.VIDEO_PROVIDERS[n]; if (r.test_regex.test(e) && new RegExp(f.opts.videoAllowedProviders.join("|")).test(r.provider)) { t = e.replace(r.url_regex, r.url_text), t = r.html.replace(/\{url\}/, t); break } } t ? b(t) : f.events.trigger("video.linkError", [e]) }, insertEmbed: function(e) { void 0 === e && (e = f.popups.get("video.insert").find(".fr-video-embed-layer textarea").val() || ""), 0 !== e.length && be.FE.VIDEO_EMBED_REGEX.test(e) ? b(e) : f.events.trigger("video.codeError", [e]) }, insert: b, align: function(e) { u.removeClass("fr-fvr fr-fvl"), !f.opts.htmlUntouched && f.opts.useClasses ? "left" == e ? u.addClass("fr-fvl") : "right" == e && u.addClass("fr-fvr") : X(u, Y(), e), j(), F(), a(), f.selection.clear() }, refreshAlign: function(e) { if (!u) return !1; e.find("> *:first").replaceWith(f.icon.create("video-align-" + z())) }, refreshAlignOnShow: function(e, t) { u && t.find('.fr-command[data-param1="' + z() + '"]').addClass("fr-active").attr("aria-selected", !0) }, display: function(e) { u.removeClass("fr-dvi fr-dvb"), !f.opts.htmlUntouched && f.opts.useClasses ? "inline" == e ? u.addClass("fr-dvi") : "block" == e && u.addClass("fr-dvb") : X(u, e, z()), j(), F(), a(), f.selection.clear() }, refreshDisplayOnShow: function(e, t) { u && t.find('.fr-command[data-param1="' + Y() + '"]').addClass("fr-active").attr("aria-selected", !0) }, remove: G, hideProgressBar: S, showSizePopup: function() { var e = f.popups.get("video.size"); e || (e = W()), S(), f.popups.refresh("video.size"), f.popups.setContainer("video.size", f.$sc); var t = u.find("iframe, embed, video"), n = t.offset().left + t.width() / 2, r = t.offset().top + t.height(); f.popups.show("video.size", n, r, t.height()) }, replace: function() { var e = f.popups.get("video.insert"); e || (e = o()), f.popups.isVisible("video.insert") || (S(), f.popups.refresh("video.insert"), f.popups.setContainer("video.insert", f.$sc)); var t = u.offset().left + u.width() / 2, n = u.offset().top + u.height(); f.popups.show("video.insert", t, n, u.outerHeight()) }, back: function() { u ? (f.events.disableBlur(), u.trigger("click")) : (f.events.disableBlur(), f.selection.restore(), f.events.enableBlur(), f.popups.hide("video.insert"), f.toolbar.showInline()) }, setSize: function(e, t) { if (u) { var n = f.popups.get("video.size"), r = u.find("iframe, embed, video"); r.css("width", e || n.find('input[name="width"]').val()), r.css("height", t || n.find('input[name="height"]').val()), r.get(0).style.width && r.removeAttr("width"), r.get(0).style.height && r.removeAttr("height"), n.find("input:focus").blur(), setTimeout(function() { u.trigger("click") }, f.helpers.isAndroid() ? 50 : 0) } }, get: function() { return u } } }, be.FE.RegisterCommand("insertVideo", { title: "Insert Video", undo: !1, focus: !0, refreshAfterCallback: !1, popup: !0, callback: function() { this.popups.isVisible("video.insert") ? (this.$el.find(".fr-marker").length && (this.events.disableBlur(), this.selection.restore()), this.popups.hide("video.insert")) : this.video.showInsertPopup() }, plugin: "video" }), be.FE.DefineIcon("insertVideo", { NAME: "video-camera", FA5NAME: "camera" }), be.FE.DefineIcon("videoByURL", { NAME: "link" }), be.FE.RegisterCommand("videoByURL", { title: "By URL", undo: !1, focus: !1, toggle: !0, callback: function() { this.video.showLayer("video-by-url") }, refresh: function(e) { this.video.refreshByURLButton(e) } }), be.FE.DefineIcon("videoEmbed", { NAME: "code" }), be.FE.RegisterCommand("videoEmbed", { title: "Embedded Code", undo: !1, focus: !1, toggle: !0, callback: function() { this.video.showLayer("video-embed") }, refresh: function(e) { this.video.refreshEmbedButton(e) } }), be.FE.DefineIcon("videoUpload", { NAME: "upload" }), be.FE.RegisterCommand("videoUpload", { title: "Upload Video", undo: !1, focus: !1, toggle: !0, callback: function() { this.video.showLayer("video-upload") }, refresh: function(e) { this.video.refreshUploadButton(e) } }), be.FE.RegisterCommand("videoInsertByURL", { undo: !0, focus: !0, callback: function() { this.video.insertByURL() } }), be.FE.RegisterCommand("videoInsertEmbed", { undo: !0, focus: !0, callback: function() { this.video.insertEmbed() } }), be.FE.DefineIcon("videoDisplay", { NAME: "star" }), be.FE.RegisterCommand("videoDisplay", { title: "Display", type: "dropdown", options: { inline: "Inline", block: "Break Text" }, callback: function(e, t) { this.video.display(t) }, refresh: function(e) { this.opts.videoTextNear || e.addClass("fr-hidden") }, refreshOnShow: function(e, t) { this.video.refreshDisplayOnShow(e, t) } }), be.FE.DefineIcon("video-align", { NAME: "align-left" }), be.FE.DefineIcon("video-align-left", { NAME: "align-left" }), be.FE.DefineIcon("video-align-right", { NAME: "align-right" }), be.FE.DefineIcon("video-align-center", { NAME: "align-justify" }), be.FE.DefineIcon("videoAlign", { NAME: "align-center" }), be.FE.RegisterCommand("videoAlign", { type: "dropdown", title: "Align", options: { left: "Align Left", center: "None", right: "Align Right" }, html: function() { var e = '" }, callback: function(e, t) { this.video.align(t) }, refresh: function(e) { this.video.refreshAlign(e) }, refreshOnShow: function(e, t) { this.video.refreshAlignOnShow(e, t) } }), be.FE.DefineIcon("videoReplace", { NAME: "exchange", FA5NAME: "exchange-alt" }), be.FE.RegisterCommand("videoReplace", { title: "Replace", undo: !1, focus: !1, popup: !0, refreshAfterCallback: !1, callback: function() { this.video.replace() } }), be.FE.DefineIcon("videoRemove", { NAME: "trash" }), be.FE.RegisterCommand("videoRemove", { title: "Remove", callback: function() { this.video.remove() } }), be.FE.DefineIcon("videoSize", { NAME: "arrows-alt" }), be.FE.RegisterCommand("videoSize", { undo: !1, focus: !1, popup: !0, title: "Change Size", callback: function() { this.video.showSizePopup() } }), be.FE.DefineIcon("videoBack", { NAME: "arrow-left" }), be.FE.RegisterCommand("videoBack", { title: "Back", undo: !1, focus: !1, back: !0, callback: function() { this.video.back() }, refresh: function(e) { this.video.get() || this.opts.toolbarInline ? (e.removeClass("fr-hidden"), e.next(".fr-separator").removeClass("fr-hidden")) : (e.addClass("fr-hidden"), e.next(".fr-separator").addClass("fr-hidden")) } }), be.FE.RegisterCommand("videoDismissError", { title: "OK", undo: !1, callback: function() { this.video.hideProgressBar(!0) } }), be.FE.RegisterCommand("videoSetSize", { undo: !0, focus: !1, title: "Update", refreshAfterCallback: !1, callback: function() { this.video.setSize() } }), be.extend(be.FE.DEFAULTS, { wordDeniedTags: [], wordDeniedAttrs: [], wordAllowedStyleProps: ["font-family", "font-size", "background", "color", "width", "text-align", "vertical-align", "background-color", "padding", "margin", "height", "margin-top", "margin-left", "margin-right", "margin-bottom", "text-decoration", "font-weight", "font-style", "text-indent"], wordPasteModal: !0, wordPasteKeepFormatting: !0 }), be.FE.PLUGINS.wordPaste = function(T) { var a, r, o = "word_paste"; function t(e) { var t = T.opts.wordAllowedStyleProps; e || (T.opts.wordAllowedStyleProps = []), 0 === r.indexOf("") && (r = "" + r + "
"), r = function(e, t) { 0 <= e.indexOf("]*(]*>[.\s\S\w\W<>]*<\/html>)[.\s\S\w\W<>]*/i, "$1")); ! function(e) { for (var t = e.split("v:shape"), n = 1; n < t.length; n++) { var r = t[n], i = r.split(' id="')[1]; if (i && 1 < i.length) { i = i.split('"')[0]; var a = r.split(' o:spid="')[1]; a && 1 < a.length && (a = a.split('"')[0], h[i] = a) } } }(e); var n = (new DOMParser).parseFromString(e, "text/html"), r = n.head, i = n.body, o = function(e) { var t = {}, n = e.getElementsByTagName("style"); if (n.length) { var r = n[0], i = r.innerHTML.match(/[\S ]+\s+{[\s\S]+?}/gi); if (i) for (var a = 0; a < i.length; a++) { var o = i[a], s = o.replace(/([\S ]+\s+){[\s\S]+?}/gi, "$1"), l = o.replace(/[\S ]+\s+{([\s\S]+?)}/gi, "$1"); s = s.replace(/^[\s]|[\s]$/gm, ""), l = l.replace(/^[\s]|[\s]$/gm, ""), s = s.replace(/\n|\r|\n\r/g, ""), l = l.replace(/\n|\r|\n\r/g, ""); for (var d = s.split(", "), c = 0; c < d.length; c++) t[d[c]] = l } } return t }(r); c(i, function(e) { if (e.nodeType == Node.TEXT_NODE && /\n|\u00a0|\r/.test(e.data)) { if (!/\S| /.test(e.data)) return e.data == be.FE.UNICODE_NBSP ? (e.data = "\u200b", !0) : 1 == e.data.length && 10 == e.data.charCodeAt(0) ? (e.data = " ", !0) : (A(e), !1); e.data = e.data.replace(/\n|\r/gi, " ") } return !0 }), c(i, function(e) { return e.nodeType != Node.ELEMENT_NODE || "V:IMAGEDATA" != e.tagName && "IMG" != e.tagName || function(e, t) { if (!t) return; var n; if ("IMG" == e.tagName) { var r = e.getAttribute("src"); if (!r || -1 == r.indexOf("file://")) return; if (0 === r.indexOf("file://") && T.helpers.isURL(e.getAttribute("alt"))) return e.setAttribute("src", e.getAttribute("alt")); (n = h[e.getAttribute("v:shapes")]) || (n = e.getAttribute("v:shapes")) } else n = e.parentNode.getAttribute("o:spid"); if (e.removeAttribute("height"), !n) return; i = t, u = {}, f(i, "i", "\\shppict"), f(i, "s", "\\shp{"); var i; var a = u[n.substring(7)]; if (a) { var o = function(e) { for (var t = e.match(/[0-9a-f]{2}/gi), n = [], r = 0; r < t.length; r++) n.push(String.fromCharCode(parseInt(t[r], 16))); var i = n.join(""); return btoa(i) }(a.image_hex), s = "data:" + a.image_type + ";base64," + o; "IMG" === e.tagName ? (e.src = s, e.setAttribute("data-fr-image-pasted", !0)) : be(e.parentNode).before('').remove() } }(e, t), !0 }); for (var a = i.querySelectorAll("ul > ul, ul > ol, ol > ul, ol > ol"), s = a.length - 1; 0 <= s; s--) a[s].previousElementSibling && "LI" === a[s].previousElementSibling.tagName && a[s].previousElementSibling.appendChild(a[s]); c(i, function(t) { if (t.nodeType == Node.TEXT_NODE) return t.data = t.data.replace(/
(\n|\r)/gi, "
"), !1; if (t.nodeType == Node.ELEMENT_NODE) { if (C(t)) { var n = t.parentNode, r = t.previousSibling, i = function e(t, n) { var r = /[0-9a-zA-Z]./gi; var i = !1; t.firstElementChild && t.firstElementChild.firstElementChild && t.firstElementChild.firstElementChild.firstChild && !(i = i || r.test(t.firstElementChild.firstElementChild.firstChild.data || "")) && t.firstElementChild.firstElementChild.firstElementChild && t.firstElementChild.firstElementChild.firstElementChild.firstChild && (i = i || r.test(t.firstElementChild.firstElementChild.firstElementChild.firstChild.data || "")); var a = i ? "ol" : "ul"; var o = g(t); var s = "<" + a + ">
  • " + m(t, n); var l = t.nextElementSibling; var d = t.parentNode; A(t); t = null; for (; l && C(l);) { var c = l.previousElementSibling, f = g(l); if (o < f) s += e(l, n).outerHTML; else { if (f < o) break; s += "
  • " + m(l, n) } if (o = f, l.previousElementSibling || l.nextElementSibling || l.parentNode) { var p = l; l = l.nextElementSibling, A(p), p = null } else l = c ? c.nextElementSibling : d.firstElementChild } s += "
  • "; var u = document.createElement("div"); u.innerHTML = s; var h = u.firstElementChild; return h }(t, o), a = null; return (a = r ? r.nextSibling : n.firstChild) ? n.insertBefore(i, a) : n.appendChild(i), !1 } return p(t, o) } return t.nodeType != Node.COMMENT_NODE || (A(t), !1) }), c(i, function(e) { if (e.nodeType == Node.ELEMENT_NODE) { var t = e.tagName; if (!e.innerHTML && -1 == ["BR", "IMG"].indexOf(t)) { for (var n = e.parentNode; n && (A(e), !(e = n).innerHTML);) n = e.parentNode; return !1 }! function(e) { var t = e.getAttribute("style"); if (!t) return; (t = R(t)) && ";" != t.slice(-1) && (t += ";"); var n = t.match(/(^|\S+?):.+?;{1,1}/gi); if (!n) return; for (var r = {}, i = 0; i < n.length; i++) { var a = n[i], o = a.split(":"); 2 == o.length && ("text-align" == o[0] && "SPAN" == e.tagName || (r[o[0]] = o[1])) } var s = ""; for (var l in r) if (r.hasOwnProperty(l)) { if ("font-size" == l && "pt;" == r[l].slice(-3)) { var d = null; try { d = parseFloat(r[l].slice(0, -3), 10) } catch (c) {} d && (d = Math.round(1.33 * d), r[l] = d + "px;") } s += l + ":" + r[l] } s && e.setAttribute("style", s) }(e) } return !0 }); var l = i.outerHTML, d = T.opts.htmlAllowedStyleProps; return T.opts.htmlAllowedStyleProps = T.opts.wordAllowedStyleProps, l = T.clean.html(l, T.opts.wordDeniedTags, T.opts.wordDeniedAttrs, !1), T.opts.htmlAllowedStyleProps = d, l }(r = r.replace(/([\r\n\u00a0 ]*)<\/span>/g, function(e, t) { for (var n = "", r = 0; r++ < t.length;) n += " "; return n }), T.paste.getRtfClipboard()); var n = T.doc.createElement("DIV"); n.innerHTML = r, T.html.cleanBlankSpaces(n), r = n.innerHTML, r = (r = T.paste.cleanEmptyTagsAndDivs(r)).replace(/\u200b/g, ""), T.modals.hide(o), T.paste.clean(r, !0, !0), T.opts.wordAllowedStyleProps = t } function A(e) { e.parentNode && e.parentNode.removeChild(e) } function c(e, t) { if (t(e)) for (var n = e.firstChild; n;) { var r = n, i = n.previousSibling; n = n.nextSibling, c(r, t), r.previousSibling || r.nextSibling || r.parentNode || !n || i == n.previousSibling || !n.parentNode ? r.previousSibling || r.nextSibling || r.parentNode || !n || n.previousSibling || n.nextSibling || n.parentNode || (i ? n = i.nextSibling ? i.nextSibling.nextSibling : null : e.firstChild && (n = e.firstChild.nextSibling)) : n = i ? i.nextSibling : e.firstChild } } function C(e) { if (!e.getAttribute("style") || !/mso-list:[\s]*l/gi.test(e.getAttribute("style").replace(/\n/gi, ""))) return !1; try { if (!e.querySelector('[style="mso-list:Ignore"]')) return !1 } catch (t) { return !1 } return !0 } function g(e) { return e.getAttribute("style").replace(/\n/gi, "").replace(/.*level([0-9]+?).*/gi, "$1") } function m(e, t) { var n = e.cloneNode(!0); if (-1 != ["H1", "H2", "H3", "H4", "H5", "H6"].indexOf(e.tagName)) { var r = document.createElement(e.tagName.toLowerCase()); r.setAttribute("style", e.getAttribute("style")), r.innerHTML = n.innerHTML, n.innerHTML = r.outerHTML } c(n, function(e) { return e.nodeType == Node.ELEMENT_NODE && ("mso-list:Ignore" == e.getAttribute("style") && e.parentNode.removeChild(e), p(e, t)), !0 }); var i = n.innerHTML; return i = i.replace(//gi, "") } function v(e, t) { for (var n = document.createElement(t), r = 0; r < e.attributes.length; r++) { var i = e.attributes[r].name; n.setAttribute(i, e.getAttribute(i)) } return n.innerHTML = e.innerHTML, e.parentNode.replaceChild(n, e), n } function S(e) { var t = e.getAttribute("align"); t && (e.style["text-align"] = t, e.removeAttribute("align")) } function R(e) { return e.replace(/\n|\r|\n\r|"/g, "") } function y(e, t, n) { if (t) { var r = e.getAttribute("style"); r && ";" != r.slice(-1) && (r += ";"), t && ";" != t.slice(-1) && (t += ";"), t = t.replace(/\n/gi, ""); var i = null; i = n ? (r || "") + t : t + (r || ""), e.setAttribute("style", i) } } var u = null; function f(e, t, n) { for (var r = e.split(n), i = 1; i < r.length; i++) { var a = r[i]; if (1 < (a = a.split("shplid")).length) { a = a[1]; for (var o = "", s = 0; s < a.length && "\\" != a[s] && "{" != a[s] && " " != a[s] && "\r" != a[s] && "\n" != a[s];) o += a[s], s++; var l = a.split("bliptag"); if (l && l.length < 2) continue; var d = null; if (-1 != l[0].indexOf("pngblip") ? d = "image/png" : -1 != l[0].indexOf("jpegblip") && (d = "image/jpeg"), !d) continue; var c, f = l[1].split("}"); if (f && f.length < 2) continue; if (2 < f.length && -1 != f[0].indexOf("blipuid")) c = f[1].split(" "); else { if ((c = f[0].split(" ")) && c.length < 2) continue; c.shift() } var p = c.join(""); u[t + o] = { image_hex: p, image_type: d } } } } function p(e, t) { var n = e.tagName, r = n.toLowerCase(); e.firstElementChild && ("I" == e.firstElementChild.tagName ? v(e.firstElementChild, "em") : "B" == e.firstElementChild.tagName && v(e.firstElementChild, "strong")); if (-1 != ["SCRIPT", "APPLET", "EMBED", "NOFRAMES", "NOSCRIPT"].indexOf(n)) return A(e), !1; var i = -1, a = ["META", "LINK", "XML", "ST1:", "O:", "W:", "FONT"]; for (i = 0; i < a.length; i++) if (-1 != n.indexOf(a[i])) return e.innerHTML && (e.outerHTML = e.innerHTML), A(e), !1; if ("TD" != n) { var o = e.getAttribute("class"); if (t && o) { var s = (o = R(o)).split(" "); for (i = 0; i < s.length; i++) { var l = [], d = "." + s[i]; l.push(d), d = r + d, l.push(d); for (var c = 0; c < l.length; c++) t[l[c]] && y(e, t[l[c]]) } e.removeAttribute("class") } t && t[r] && y(e, t[r]) } if (-1 != ["P", "H1", "H2", "H3", "H4", "H5", "H6", "PRE"].indexOf(n)) { var f = e.getAttribute("class"); if (f && (t && t[n.toLowerCase() + "." + f] && y(e, t[n.toLowerCase() + "." + f]), -1 != f.toLowerCase().indexOf("mso"))) { var p = R(f); (p = p.replace(/[0-9a-z-_]*mso[0-9a-z-_]*/gi, "")) ? e.setAttribute("class", p): e.removeAttribute("class") } var u = e.getAttribute("style"); if (u) { var h = u.match(/text-align:.+?[; "]{1,1}/gi); h && h[h.length - 1].replace(/(text-align:.+?[; "]{1,1})/gi, "$1") } S(e) } if ("TR" == n && function(e, t) { T.node.clearAttributes(e); for (var n = e.firstElementChild, r = 0, i = !1, a = null; n;) { n.firstElementChild && -1 != n.firstElementChild.tagName.indexOf("W:") && (n.innerHTML = n.firstElementChild.innerHTML), (a = n.getAttribute("width")) || i || (i = !0), r += parseInt(a, 10), (!n.firstChild || n.firstChild && n.firstChild.data == be.FE.UNICODE_NBSP) && (n.firstChild && A(n.firstChild), n.innerHTML = "
    "); for (var o = n.firstElementChild, s = 1 == n.children.length; o;) "P" != o.tagName || C(o) || s && S(o), o = o.nextElementSibling; if (t) { var l = n.getAttribute("class"); if (l) { var d = (l = R(l)).match(/xl[0-9]+/gi); if (d) { var c = "." + d[0]; t[c] && y(n, t[c]) } } t.td && y(n, t.td) } var f = n.getAttribute("style"); f && (f = R(f)) && ";" != f.slice(-1) && (f += ";"); var p = n.getAttribute("valign"); if (!p && f) { var u = f.match(/vertical-align:.+?[; "]{1,1}/gi); u && (p = u[u.length - 1].replace(/vertical-align:(.+?)[; "]{1,1}/gi, "$1")) } var h = null; if (f) { var g = f.match(/text-align:.+?[; "]{1,1}/gi); g && (h = g[g.length - 1].replace(/text-align:(.+?)[; "]{1,1}/gi, "$1")), "general" == h && (h = null) } var m = null; if (f) { var v = f.match(/background:.+?[; "]{1,1}/gi); v && (m = v[v.length - 1].replace(/background:(.+?)[; "]{1,1}/gi, "$1")) } var E = n.getAttribute("colspan"), b = n.getAttribute("rowspan"); E && n.setAttribute("colspan", E), b && n.setAttribute("rowspan", b), p && (n.style["vertical-align"] = p), h && (n.style["text-align"] = h), m && (n.style["background-color"] = m), a && n.setAttribute("width", a), n = n.nextElementSibling } for (n = e.firstElementChild; n;) a = n.getAttribute("width"), i ? n.removeAttribute("width") : n.setAttribute("width", 100 * parseInt(a, 10) / r + "%"), n = n.nextElementSibling }(e, t), "A" != n || e.attributes.getNamedItem("href") || e.attributes.getNamedItem("name") || !e.innerHTML || (e.outerHTML = e.innerHTML), "TD" != n && "TH" != n || e.innerHTML || (e.innerHTML = "
    "), "TABLE" == n && (e.style.width = "100%"), e.getAttribute("lang") && e.removeAttribute("lang"), e.getAttribute("style") && -1 != e.getAttribute("style").toLowerCase().indexOf("mso")) { var g = R(e.getAttribute("style")); (g = g.replace(/[0-9a-z-_]*mso[0-9a-z-_]*:.+?(;{1,1}|$)/gi, "")) ? e.setAttribute("style", g): e.removeAttribute("style") } return !0 } var h = {}; return { _init: function() { T.events.on("paste.wordPaste", function(e) { return r = e, T.opts.wordPasteModal ? function() { if (!a) { var e = '

    ' + T.language.translate("Word Paste Detected") + "

    ", t = (i = '
    ', i += '

    ' + T.language.translate("The pasted content is coming from a Microsoft Word document. Do you want to keep the format or clean it up?") + "

    ", i += '
    ", i += "
    "), n = T.modals.create(o, e, t), r = n.$body; a = n.$modal, n.$modal.addClass("fr-middle"), T.events.bindClick(r, "button.fr-remove-word", function() { var e = a.data("instance") || T; e.wordPaste.clean() }), T.events.bindClick(r, "button.fr-keep-word", function() { var e = a.data("instance") || T; e.wordPaste.clean(!0) }), T.events.$on(be(T.o_win), "resize", function() { T.modals.resize(o) }) } var i; T.modals.show(o), T.modals.resize(o) }() : t(T.opts.wordPasteKeepFormatting), !1 }) }, clean: t } } });