"+d.FE.INVISIBLE_SPACE+"").insertAfter(e),n=(a.outerHeight()-e.next().outerHeight())/2,e.next().remove()),r.opts.iframe&&(t+=r.$iframe.offset().top),a.hasClass("fr-on")&&0<=t&&l.css("top",t-n),0<=t&&t-Math.abs(n)<=r.$box.outerHeight()-e.outerHeight()?(a.hasClass("fr-hidden")&&(a.hasClass("fr-on")&&o(),a.removeClass("fr-hidden")),a.css("top",t-n)):a.hasClass("fr-visible")&&(a.addClass("fr-hidden"),u()),a.css("left",i)}function i(e){a||function(){r.shared.$quick_insert||(r.shared.$quick_insert=d('"));a=r.shared.$quick_insert,r.tooltip.bind(r.$box,".fr-quick-insert > a.fr-floating-btn"),r.events.on("destroy",function(){a.removeClass("fr-on").appendTo(d("body:first")).css("left",-9999).css("top",-9999),l&&(u(),l.appendTo(d("body:first")))},!0),r.events.on("shared.destroy",function(){a.html("").removeData().remove(),a=null,l&&(l.html("").removeData().remove(),l=null)},!0),r.events.on("commands.before",s),r.events.on("commands.after",function(){r.popups.areVisible()||n()}),r.events.bindClick(r.$box,".fr-quick-insert > a",o),r.events.bindClick(r.$box,".fr-qi-helper > a.fr-btn",function(e){var t=d(e.currentTarget).data("cmd");if(!1===r.events.trigger("quickInsert.commands.before",[t]))return!1;d.FE.QUICK_INSERT_BUTTONS[t].callback.apply(r,[e.currentTarget]),d.FE.QUICK_INSERT_BUTTONS[t].undo&&r.undo.saveStep(),r.events.trigger("quickInsert.commands.after",[t]),r.quickInsert.hide()}),r.events.$on(r.$wp,"scroll",function(){a.hasClass("fr-visible")&&t(a.data("tag"))})}(),a.hasClass("fr-on")&&u(),r.$box.append(a),t(e),a.data("tag",e),a.addClass("fr-visible")}function n(){if(r.core.hasFocus()){var e=r.selection.element();if(r.opts.enter==d.FE.ENTER_BR||r.node.isBlock(e)||(e=r.node.blockParent(e)),r.opts.enter==d.FE.ENTER_BR&&!r.node.isBlock(e)){var t=r.node.deepestParent(e);t&&(e=t)}e&&(r.opts.enter!=d.FE.ENTER_BR&&r.node.isEmpty(e)&&0<=r.opts.quickInsertTags.indexOf(e.tagName.toLowerCase())||r.opts.enter==d.FE.ENTER_BR&&("BR"==e.tagName&&(!e.previousSibling||"BR"==e.previousSibling.tagName||r.node.isBlock(e.previousSibling))||r.node.isEmpty(e)&&(!e.previousSibling||"BR"==e.previousSibling.tagName||r.node.isBlock(e.previousSibling))&&(!e.nextSibling||"BR"==e.nextSibling.tagName||r.node.isBlock(e.nextSibling))))?a&&a.data("tag").is(d(e))&&a.hasClass("fr-on")?u():r.selection.isCollapsed()&&i(d(e)):s()}}function s(){a&&(a.hasClass("fr-on")&&u(),a.removeClass("fr-visible fr-on"),a.css("left",-9999).css("top",-9999))}function o(e){if(e&&e.preventDefault(),a.hasClass("fr-on")&&!a.hasClass("fr-hidden"))u();else{if(!r.shared.$qi_helper){for(var t=r.opts.quickInsertButtons,i='',n=0,s=0;s'+r.icon.create(o.icon)+"")}i+="
",r.shared.$qi_helper=d(i),r.tooltip.bind(r.shared.$qi_helper,"> a.fr-btn"),r.events.$on(r.shared.$qi_helper,"mousedown",function(e){e.preventDefault()},!0)}(l=r.shared.$qi_helper).appendTo(r.$box),setTimeout(function(){l.css("top",parseFloat(a.css("top"))),l.css("left",parseFloat(a.css("left"))+a.outerWidth()),l.find("a").addClass("fr-size-1"),a.addClass("fr-on")},10)}}function u(){var e=r.$box.find(".fr-qi-helper");e.length&&(e.find("a").removeClass("fr-size-1"),e.css("left",-9999),a.hasClass("fr-hidden")||a.removeClass("fr-on"))}return{_init:function(){if(!r.$wp||!r.opts.quickInsertEnabled)return!1;r.popups.onShow("image.edit",s),r.events.on("mouseup",n),r.helpers.isMobile()&&r.events.$on(d(r.o_doc),"selectionchange",n),r.events.on("blur",s),r.events.on("keyup",n),r.events.on("keydown",function(){setTimeout(function(){n()},0)})},hide:s}}});