if (! ("ace" in window)) { window.ace = {} } jQuery(function() { window.ace.click_event = $.fn.tap ? "tap": "click" }); (function(e, c) { var d = "multiple" in document.createElement("INPUT"); var j = "FileList" in window; var b = "FileReader" in window; var f = function(l, m) { var k = this; this.settings = e.extend({}, e.fn.ace_file_input.defaults, m); this.$element = e(l); this.element = l; this.disabled = false; this.can_reset = true; this.$element.on("change.ace_inner_call", function(o, n) { if (n === true) { return } return a.call(k) }); this.$element.wrap('
'); this.apply_settings() }; f.error = { FILE_LOAD_FAILED: 1, IMAGE_LOAD_FAILED: 2, THUMBNAIL_FAILED: 3 }; f.prototype.apply_settings = function() { var l = this; var k = !!this.settings.icon_remove; this.multi = this.$element.attr("multiple") && d; this.well_style = this.settings.style == "well"; if (this.well_style) { this.$element.parent().addClass("ace-file-multiple") } else { this.$element.parent().removeClass("ace-file-multiple") } this.$element.parent().find(":not(input[type=file])").remove(); this.$element.after('" + (k ? '': "")); this.$label = this.$element.next(); this.$label.on("click", function() { if (!this.disabled && !l.element.disabled && !l.$element.attr("readonly")) { l.$element.click() } }); if (k) { this.$label.next("a").on(ace.click_event, function() { if (!l.can_reset) { return false } var m = true; if (l.settings.before_remove) { m = l.settings.before_remove.call(l.element) } if (!m) { return false } return l.reset_input() }) } if (this.settings.droppable && j) { g.call(this) } }; f.prototype.show_file_list = function(k) { var n = typeof k === "undefined" ? this.$element.data("ace_input_files") : k; if (!n || n.length == 0) { return } if (this.well_style) { this.$label.find(".file-name").remove(); if (!this.settings.btn_change) { this.$label.addClass("hide-placeholder") } } this.$label.attr("data-title", this.settings.btn_change).addClass("selected"); for (var p = 0; p < n.length; p++) { var l = typeof n[p] === "string" ? n[p] : e.trim(n[p].name); var q = l.lastIndexOf("\\") + 1; if (q == 0) { q = l.lastIndexOf("/") + 1 } l = l.substr(q); var m = "icon-file"; if ((/\.(jpe?g|png|gif|svg|bmp|tiff?)$/i).test(l)) { m = "icon-picture" } else { if ((/\.(mpe?g|flv|mov|avi|swf|mp4|mkv|webm|wmv|3gp)$/i).test(l)) { m = "icon-film" } else { if ((/\.(mp3|ogg|wav|wma|amr|aac)$/i).test(l)) { m = "icon-music" } } } if (!this.well_style) { this.$label.find(".file-name").attr({ "data-title": l }).find('[class*="icon-"]').attr("class", m) } else { this.$label.append(''); var r = e.trim(n[p].type); var o = b && this.settings.thumbnail && ((r.length > 0 && r.match("image")) || (r.length == 0 && m == "icon-picture")); if (o) { var s = this; e.when(i.call(this, n[p])).fail(function(t) { if (s.settings.preview_error) { s.settings.preview_error.call(s, l, t.code) } }) } } } return true }; f.prototype.reset_input = function() { this.$label.attr({ "data-title": this.settings.btn_choose, "class": "file-label" }).find(".file-name:first").attr({ "data-title": this.settings.no_file, "class": "file-name" }).find('[class*="icon-"]').attr("class", this.settings.no_icon).prev("img").remove(); if (!this.settings.no_icon) { this.$label.find('[class*="icon-"]').remove() } this.$label.find(".file-name").not(":first").remove(); if (this.$element.data("ace_input_files")) { this.$element.removeData("ace_input_files"); this.$element.removeData("ace_input_method") } this.reset_input_field(); return false }; f.prototype.reset_input_field = function() { this.$element.wrap("
").closest("form").get(0).reset(); this.$element.unwrap() }; f.prototype.enable_reset = function(k) { this.can_reset = k }; f.prototype.disable = function() { this.disabled = true; this.$element.attr("disabled", "disabled").addClass("disabled") }; f.prototype.enable = function() { this.disabled = false; this.$element.removeAttr("disabled").removeClass("disabled") }; f.prototype.files = function() { return e(this).data("ace_input_files") || null }; f.prototype.method = function() { return e(this).data("ace_input_method") || "" }; f.prototype.update_settings = function(k) { this.settings = e.extend({}, this.settings, k); this.apply_settings() }; var g = function() { var l = this; var k = this.element.parentNode; e(k).on("dragenter", function(m) { m.preventDefault(); m.stopPropagation() }).on("dragover", function(m) { m.preventDefault(); m.stopPropagation() }).on("drop", function(q) { q.preventDefault(); q.stopPropagation(); var p = q.originalEvent.dataTransfer; var o = p.files; if (!l.multi && o.length > 1) { var n = []; n.push(o[0]); o = n } var m = true; if (l.settings.before_change) { m = l.settings.before_change.call(l.element, o, true) } if (!m || m.length == 0) { return false } if (m instanceof Array || (j && m instanceof FileList)) { o = m } l.$element.data("ace_input_files", o); l.$element.data("ace_input_method", "drop"); l.show_file_list(o); l.$element.triggerHandler("change", [true]); return true }) }; var a = function() { var l = true; if (this.settings.before_change) { l = this.settings.before_change.call(this.element, this.element.files || [this.element.value], false) } if (!l || l.length == 0) { if (!this.$element.data("ace_input_files")) { this.reset_input_field() } return false } var m = !j ? null: ((l instanceof Array || l instanceof FileList) ? l: this.element.files); this.$element.data("ace_input_method", "select"); if (m && m.length > 0) { this.$element.data("ace_input_files", m) } else { var k = e.trim(this.element.value); if (k && k.length > 0) { m = []; m.push(k); this.$element.data("ace_input_files", m) } } if (!m || m.length == 0) { return false } this.show_file_list(m); return true }; var i = function(o) { var n = this; var l = n.$label.find(".file-name:last"); var m = new e.Deferred; var k = new FileReader(); k.onload = function(q) { l.prepend(""); var p = l.find("img:last").get(0); e(p).one("load", function() { var t = 50; if (n.settings.thumbnail == "large") { t = 150 } else { if (n.settings.thumbnail == "fit") { t = l.width() } } l.addClass(t > 50 ? "large": ""); var s = h(p, t, o.type); if (s == null) { e(this).remove(); m.reject({ code: f.error.THUMBNAIL_FAILED }); return } var r = s.w, u = s.h; if (n.settings.thumbnail == "small") { r = u = t } e(p).css({ "background-image": "url(" + s.src + ")", width: r, height: u }).data("thumb", s.src).attr({ src: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGBgAAAABQABh6FO1AAAAABJRU5ErkJggg==" }).show(); m.resolve() }).one("error", function() { l.find("img").remove(); m.reject({ code: f.error.IMAGE_LOAD_FAILED }) }); p.src = q.target.result }; k.onerror = function(p) { m.reject({ code: f.error.FILE_LOAD_FAILED }) }; k.readAsDataURL(o); return m.promise() }; var h = function(n, s, q) { var r = n.width, o = n.height; if (r > s || o > s) { if (r > o) { o = parseInt(s / r * o); r = s } else { r = parseInt(s / o * r); o = s } } var m; try { var l = document.createElement("canvas"); l.width = r; l.height = o; var k = l.getContext("2d"); k.drawImage(n, 0, 0, n.width, n.height, 0, 0, r, o); m = l.toDataURL() } catch(p) { m = null } if (! (/^data\:image\/(png|jpe?g|gif);base64,[0-9A-Za-z\+\/\=]+$/.test(m))) { m = null } if (!m) { return null } return { src: m, w: r, h: o } }; e.fn.ace_file_input = function(m, n) { var l; var k = this.each(function() { var q = e(this); var p = q.data("ace_file_input"); var o = typeof m === "object" && m; if (!p) { q.data("ace_file_input", (p = new f(this, o))) } if (typeof m === "string") { l = p[m](n) } }); return (l === c) ? k: l }; e.fn.ace_file_input.defaults = { style: false, no_file: "No File ...", no_icon: "icon-upload-alt", btn_choose: "Choose", btn_change: "Change", icon_remove: "icon-remove", droppable: false, thumbnail: false, before_change: null, before_remove: null, preview_error: null } })(window.jQuery); (function(a, b) { a.fn.ace_spinner = function(c) { this.each(function() { var f = c.icon_up || "icon-chevron-up"; var j = c.icon_down || "icon-chevron-down"; var h = c.on_sides || false; var e = c.btn_up_class || ""; var g = c.btn_down_class || ""; var d = c.max || 999; d = ("" + d).length; a(this).addClass("spinner-input form-control").wrap('
'); var k = a(this).closest(".ace-spinner").spinner(c).wrapInner("
"); if (h) { a(this).before('
').after('
'); k.addClass("touch-spinner"); k.css("width", (d * 20 + 40) + "px") } else { a(this).after('
'); if ("ontouchend" in document || c.touch_spinner) { k.addClass("touch-spinner"); k.css("width", (d * 20 + 40) + "px") } else { a(this).next().addClass("btn-group-vertical"); k.css("width", (d * 20 + 10) + "px") } } a(this).on("mousewheel DOMMouseScroll", function(l) { var m = l.originalEvent.detail < 0 || l.originalEvent.wheelDelta > 0 ? 1 : -1; k.spinner("step", m > 0); k.spinner("triggerChangedEvent"); return false }); var i = a(this); k.on("changed", function() { i.trigger("change") }) }); return this } })(window.jQuery); (function(a, b) { a.fn.ace_wizard = function(c) { this.each(function() { var e = a(this); e.wizard(); var d = e.siblings(".wizard-actions").eq(0); var f = e.data("wizard"); f.$prevBtn.remove(); f.$nextBtn.remove(); f.$prevBtn = d.find(".btn-prev").eq(0).on(ace.click_event, function() { e.wizard("previous") }).attr("disabled", "disabled"); f.$nextBtn = d.find(".btn-next").eq(0).on(ace.click_event, function() { e.wizard("next") }).removeAttr("disabled"); f.nextText = f.$nextBtn.text() }); return this } })(window.jQuery); (function(a, b) { a.fn.ace_colorpicker = function(c) { var d = a.extend({ pull_right: false, caret: true }, c); this.each(function() { var g = a(this); var e = ""; var f = ""; a(this).hide().find("option").each(function() { var h = "colorpick-btn"; if (this.selected) { h += " selected"; f = this.value } e += '
  • ' }).end().on("change.ace_inner_call", function() { a(this).next().find(".btn-colorpicker").css("background-color", this.value) }).after('").next().find(".dropdown-menu").on(ace.click_event, function(j) { var h = a(j.target); if (!h.is(".colorpick-btn")) { return false } h.closest("ul").find(".selected").removeClass("selected"); h.addClass("selected"); var i = h.data("color"); g.val(i).change(); j.preventDefault(); return true }) }); return this } })(window.jQuery); (function(a, b) { a.fn.ace_tree = function(d) { var c = { "open-icon": "icon-folder-open", "close-icon": "icon-folder-close", selectable: true, "selected-icon": "tree-dot", "unselected-icon": "tree-dot" }; c = a.extend({}, c, d); this.each(function() { var e = a(this); e.html(' '); e.addClass(c.selectable == true ? "tree-selectable": "tree-unselectable"); e.tree(c) }); return this } })(window.jQuery); (function(a, b) { a.fn.ace_wysiwyg = function(c, h) { var d = a.extend({ speech_button: true, wysiwyg: {} }, c); var e = ["#ac725e", "#d06b64", "#f83a22", "#fa573c", "#ff7537", "#ffad46", "#42d692", "#16a765", "#7bd148", "#b3dc6c", "#fbe983", "#fad165", "#92e1c0", "#9fe1e7", "#9fc6e7", "#4986e7", "#9a9cff", "#b99aff", "#c2c2c2", "#cabdbf", "#cca6ac", "#f691b2", "#cd74e6", "#a47ae2", "#444444"]; var g = { font: { values: ["Arial", "Courier", "Comic Sans MS", "Helvetica", "Open Sans", "Tahoma", "Verdana"], icon: "icon-font", title: "Font" }, fontSize: { values: { 5 : "Huge", 3 : "Normal", 1 : "Small" }, icon: "icon-text-height", title: "Font Size" }, bold: { icon: "icon-bold", title: "Bold (Ctrl/Cmd+B)" }, italic: { icon: "icon-italic", title: "Italic (Ctrl/Cmd+I)" }, strikethrough: { icon: "icon-strikethrough", title: "Strikethrough" }, underline: { icon: "icon-underline", title: "Underline" }, insertunorderedlist: { icon: "icon-list-ul", title: "Bullet list" }, insertorderedlist: { icon: "icon-list-ol", title: "Number list" }, outdent: { icon: "icon-indent-left", title: "Reduce indent (Shift+Tab)" }, indent: { icon: "icon-indent-right", title: "Indent (Tab)" }, justifyleft: { icon: "icon-align-left", title: "Align Left (Ctrl/Cmd+L)" }, justifycenter: { icon: "icon-align-center", title: "Center (Ctrl/Cmd+E)" }, justifyright: { icon: "icon-align-right", title: "Align Right (Ctrl/Cmd+R)" }, justifyfull: { icon: "icon-align-justify", title: "Justify (Ctrl/Cmd+J)" }, createLink: { icon: "icon-link", title: "Hyperlink", button_text: "Add", placeholder: "URL", button_class: "btn-primary" }, unlink: { icon: "icon-unlink", title: "Remove Hyperlink" }, insertImage: { icon: "icon-picture", title: "Insert picture", button_text: ' Choose Image …', placeholder: "Image URL", button_insert: "Insert", button_class: "btn-success", button_insert_class: "btn-primary", choose_file: true }, foreColor: { values: e, title: "Change Color" }, backColor: { values: e, title: "Change Background Color" }, undo: { icon: "icon-undo", title: "Undo (Ctrl/Cmd+Z)" }, redo: { icon: "icon-repeat", title: "Redo (Ctrl/Cmd+Y)" }, viewSource: { icon: "icon-code", title: "View Source" } }; var f = d.toolbar || ["font", null, "fontSize", null, "bold", "italic", "strikethrough", "underline", null, "insertunorderedlist", "insertorderedlist", "outdent", "indent", null, "justifyleft", "justifycenter", "justifyright", "justifyfull", null, "createLink", "unlink", null, "insertImage", null, "foreColor", null, "undo", "redo", null, "viewSource"]; this.each(function() { var r = '
    '; for (var n in f) { if (f.hasOwnProperty(n)) { var p = f[n]; if (p === null) { r += '
    '; continue } if (typeof p == "string" && p in g) { p = g[p]; p.name = f[n] } else { if (typeof p == "object" && p.name in g) { p = a.extend(g[p.name], p) } else { continue } } var q = "className" in p ? p.className: ""; switch (p.name) { case "font": r += ' '; r += ' "; break; case "fontSize": r += '   '; r += ' "; break; case "createLink": r += '
    '; r += '
    "; break; case "insertImage": r += '
    '; r += '
    "; break; case "foreColor": case "backColor": r += ' "; r += ' '; break; case "viewSource": r += ' '; break; default: r += ' '; break } } } r += "
    "; if (d.toolbar_place) { r = d.toolbar_place.call(this, r) } else { r = a(this).before(r).prev() } r.find("a[title]").tooltip({ animation: false, container: "body" }); r.find(".dropdown-menu input:not([type=file])").on(ace.click_event, function() { return false }).on("change", function() { a(this).closest(".dropdown-menu").siblings(".dropdown-toggle").dropdown("toggle") }).on("keydown", function(u) { if (u.which == 27) { this.value = ""; a(this).change() } }); r.find("input[type=file]").prev().on(ace.click_event, function(u) { a(this).next().click() }); r.find(".wysiwyg_colorpicker").each(function() { a(this).ace_colorpicker({ pull_right: true }).change(function() { a(this).nextAll("input").eq(0).val(this.value).change() }).next().find(".btn-colorpicker").tooltip({ title: this.title, animation: false, container: "body" }) }); var k; if (d.speech_button && "onwebkitspeechchange" in (k = document.createElement("input"))) { var i = a(this).offset(); r.append(k); a(k).attr({ type: "text", "data-edit": "inserttext", "x-webkit-speech": "" }).addClass("wysiwyg-speech-input").css({ position: "absolute" }).offset({ top: i.top, left: i.left + a(this).innerWidth() - 35 }) } else { k = null } var s = a(this); var l = false; r.find("a[data-view=source]").on("click", function(v) { v.preventDefault(); if (!l) { a("