! function() { tinymce.PluginManager.add("bs_alert", function(a, b) { function c(b) { var c; a.dom; c = a.dom.getParent(a.selection.getStart(), ".alert"), window.galau_ui_debug === !0 && console.log("alert => ", c), null === c ? a.undoManager.transact(function() { d(b) }) : a.undoManager.transact(function() { h("alertDanger alertWarning alertInfo alertSuccess".split(" "), function(b) { a.formatter.remove(b) }), a.formatter.apply(b) }) } function d() { function b() { var a = document.createElement("div"); a.setAttribute("id", "bs_alert_preview"), a.setAttribute("class", "text-center"), markup_html = c(h), a.innerHTML = markup_html; var b = document.querySelector("#bs_alert_preview"); b.parentNode.replaceChild(a, b), j.find("#bs_alert_code")[0].value(markup_html) } function c(a) { var b = "", c = ""; a.alert_dismiss === !0 && (b = '', c = " alert-dismissable"); var d = '
' + b + a.alert_text + "
" + (i.ie ? " " : "
"); return window.galau_ui_debug === !0 && console.log("alert => generateAlert : ", d), d } function d(b) { var c = { alert_style: "alert alert-danger", alert_text: "Well done! You successfully read this important alert message.", alert_dismiss: !1 }, d = a.dom.getParent(a.selection.getStart(), ".alert"); if (d) { var f = e(d).clone(); if (e(d).attr("class")) { var g = e(d).attr("class").toString(), h = g.match(/alert-dismissable/i); h ? c.alert_dismiss = !0 : c.alert_dismiss = !1; var i = e(f).find("button").remove(), j = e(f).remove(i); e(f).removeClass("alert-dismissable"), c.alert_style = e(f).attr("class"), c.alert_text = e(j).text() } } return window.galau_ui_debug === !0 && console.log("alert => getAlert: ", c), c } var h = { alert_style: "alert alert-danger", alert_text: "alert" }, h = d(a.selection.getNode()), j = tinymce.activeEditor.windowManager.open({ title: f, bodyType: "tabpanel", body: [{ title: "General", type: "form", columns: 1, items: [{ type: "form", layout: "grid", columns: 1, margin: 0, padding: 0, items: [{ type: "form", id: "bs_alert_option", style: "border: 1px solid #ddd;", margin: 0, padding: 15, border: 1, items: [{ type: "label", text: "Basic", style: "font-weight: bold;" }, { name: "alert_text", type: "textbox", multiline: !0, label: "Text", style: "vertical-align: text-top;", onkeyup: function(a) { 1 == window.galau_ui_debug && console.log("alert => Text : ", a.target.value), h.alert_text = a.target.value, b() }, onchange: b, onclick: b, value: h.alert_text }, { name: "alert_dismiss", type: "checkbox", text: "Dismissable", label: " ", onclick: function(a) { window.galau_ui_debug === !0 && console.log("alert => Dismissable : ", a.control.state.data.checked), a.control.state.data.checked ? h.alert_dismiss = !0 : h.alert_dismiss = !1, b() }, checked: h.alert_dismiss }, { name: "alert_style", type: "listbox", label: "Style", values: [{ text: "Warning", value: "alert alert-warning" }, { text: "Danger", value: "alert alert-danger" }, { text: "Info", value: "alert alert-info" }, { text: "Success", value: "alert alert-success" }], onselect: function(a) { window.galau_ui_debug === !0 && console.log("alert => Style : ", a.control.state.data.value), h.alert_style = a.control.state.data.value, b() }, onchange: b, value: h.alert_style }] }, { type: "form", id: "bs_alert_view", style: " border: 1px solid #ddd;", margin: 0, padding: 15, border: 1, items: [{ type: "label", text: "Preview", style: "font-weight: bold;" }, { type: "container", html: '
' + c(h) + "
", style: "", border: 0, minWidth: 400, minHeight: 80, margin: 0, padding: 0 }] }] }] }, { title: "Code", type: "form", items: [{ type: "label", text: "HTML Code" }, { flex: 1, name: "bs_alert_code", type: "textbox", value: c(h), multiline: !0 }] }], onsubmit: function() { var b = a.dom.getParent(a.selection.getStart(), ".alert"); a.undoManager.transact(function() { var d = c(h); b ? e(b).replaceWith(d) : a.insertContent(d) }) } }) } var e = tinymce.dom.DomQuery, f = "Bootstrap Alert", g = "Visual Editor for bootstrap alerts style.", h = tinymce.util.Tools.each, i = tinymce.Env, j = [b + "/assets/css/plugin.min.css"], k = ""; if ("object" == typeof a.settings.bs_alert) var k = a.settings.bs_alert; var l = !0; if ("object" == typeof k ? ("undefined" != typeof k.css ? k.css.exist ? 1 == window.galau_ui_debug && console.log("alert => css: exist") : k.css.external ? (j.push(k.css.external), 1 == window.galau_ui_debug && console.log("alert => css: external")) : (j.push(b + "/assets/css/bootstrap.min.css"), 1 == window.galau_ui_debug && console.log("alert => css: internal")) : (j.push(b + "/assets/css/bootstrap.min.css"), 1 == window.galau_ui_debug && console.log("alert => css: internal")), l = k.toolbar_text ? !0 : !1) : (j.push(b + "/assets/css/bootstrap.min.css"), 1 == window.galau_ui_debug && console.log("alert => css: internal")), "undefined" != typeof a.settings.content_css) if ("function" == typeof a.settings.content_css.push) for (var m = 0; m < j.length; m++) a.settings.content_css.push(j[m]); else if ("string" == typeof a.settings.content_css) { a.settings.content_css = [a.settings.content_css]; for (var m = 0; m < j.length; m++) a.settings.content_css.push(j[m]) } else a.settings.content_css = j; else a.settings.content_css = j; "undefined" == typeof a.settings.extended_valid_elements && (a.settings.extended_valid_elements = "*[*]"), "undefined" == typeof a.settings.valid_elements && (a.settings.valid_elements = "*[*]"), 1 == window.galau_ui_debug && (console.log("alert => valid: ", a.settings.valid_elements), console.log("alert => extended_valid: ", a.settings.extended_valid_elements)), a.on("init", function() { if (document.createStyleSheet) for (var b = 0; b < j.length; b++) document.createStyleSheet(j[b]); else for (var b = 0; b < j.length; b++) cssLink = a.dom.create("link", { rel: "stylesheet", href: j[b] }), document.getElementsByTagName("head")[0].appendChild(cssLink) }); var n = ""; l && (n = "Alert"), a.addButton("bs_alert", { icon: "guicon-alert guicon guicon-alert", text: n, type: "splitbutton", tooltip: "Insert/edit alert", stateSelector: ".alert", onclick: d, menu: [{ text: "Warning", onclick: function() { c("alertWarning") } }, { text: "Danger", onclick: function() { c("alertDanger") } }, { text: "Info", onclick: function() { c("alertInfo") } }, { text: "Success", onclick: function() { c("alertSuccess") } }] }), a.addButton("bs_alert_remove", { icon: "remove", tooltip: "remove this alert", stateSelector: ".alert", onclick: function() { var b = a.dom.getParent(a.selection.getStart(), ".alert"); b && a.undoManager.transact(function() { e(b).replaceWith("") }) } }), a.on("init", function() { a.addContextToolbar(".alert", "bs_alert | undo redo | bs_alert_remove"), a.formatter.register({ alertDanger: [{ selector: ".alert", classes: "alert-danger" }], alertInfo: [{ selector: ".alert", classes: "alert-info" }], alertSuccess: [{ selector: ".alert", classes: "alert-success" }], alertWarning: [{ selector: ".alert", classes: "alert-warning" }] }) }), a.settings.showGuiBootstrapAlert || (a.settings.showGuiBootstrapAlert = d) }) }();