text: /*!
   * froala_editor v2.2.3 (https://www.froala.com/wysiwyg-editor)
   * License https://froala.com/wysiwyg-editor/terms/
   * Copyright 2014-2016 Froala Labs
   */
  
  /* window.alert = function(ar) {
   	// console.log(ar);
   	var display2 = document.querySelector('#display2');
   	if (display2) {
   		display2.innerHTML += "</br>" + ar;
   	}
   }*/
  
   ! function(a) {
   	"function" == typeof define && define.amd ? define(["jquery"], a) : "object" == typeof module && module.exports ? module.exports = function(b, c) {
   		return void 0 === c && (c = "undefined" != typeof window ? require("jquery") : require("jquery")(b)), a(c), c
   	} : a(jQuery)
   }(function(a) {
   	"use strict";
   	a.extend(a.FE.POPUP_TEMPLATES, {
   		"image.insert": "[_BUTTONS_][_UPLOAD_LAYER_][_BY_URL_LAYER_][_PROGRESS_BAR_]",
   		"image.edit": "[_BUTTONS_]",
   		"image.alt": "[_BUTTONS_][_ALT_LAYER_]",
   		"image.size": "[_BUTTONS_][_SIZE_LAYER_]"
   	}), a.extend(a.FE.DEFAULTS, {
   		imageInsertButtons: ["imageBack", "|", "imageUpload", "imageByURL"],
   		imageEditButtons: [/*"imageReplace", */"imageAlign", "imageRemove"/*, "|", "imageLink", "linkOpen", "linkEdit", "linkRemove", "-", "imageDisplay", "imageStyle", "imageAlt", "imageSize"*/],
   		imageAltButtons: ["imageBack", "|"],
   		imageSizeButtons: ["imageBack", "|"],
          imageUploadURL: "/file/upload64",//http://i.froala.com/upload",
          imageUploadParam: "file",
          imageUploadParams: {},
          imageUploadToS3: !1,
          imageUploadMethod: "POST",
          imageMaxSize: 10485760,
          imageAllowedTypes: ["jpeg", "jpg", "png", "gif", "svg+xml"],
          imageResize: !0,
          imageResizeWithPercent: !1,
          imageRoundPercent: !1,
          imageDefaultWidth: "auto",
          imageDefaultAlign: "center",
          imageDefaultDisplay: "block",
          imageSplitHTML: !1,
          imageStyles: {
          	"fr-rounded": "Rounded",
          	"fr-bordered": "Bordered"
          },
          imageMove: !0,
          imageMultipleStyles: !0,
          imageTextNear: !0,
          imagePaste: !0,
          imageMinWidth: 16,
          imageOutputSize: !1
      }), a.FE.PLUGINS.image = function(b) {
   		function c() {
   			var a = b.popups.get("image.insert"),
   			c = a.find(".fr-image-by-url-layer input");
              //注释了一段不知名代码
              c.val(""), oa && c.val(oa.attr("src")), c.trigger("change")
          }
  
          function d() {
          	var a = b.$tb.find('.fr-command[data-cmd="insertImage"]'),
          	c = b.popups.get("image.insert");
          	alert("click the image icon");
          	if (c || (c = J()), r(), !c.hasClass("fr-active"))
          		if (b.popups.refresh("image.insert"), b.popups.setContainer("image.insert", b.$tb), a.is(":visible")) {
          			var d = a.offset().left + a.outerWidth() / 2,
          			e = a.offset().top + (b.opts.toolbarBottom ? 10 : a.outerHeight() - 10);
          			var z = b.popups.get("image.insert");
          			b.popups.show("image.insert", d, e, a.outerHeight())
          		} else b.position.forSelection(c), b.popups.show("image.insert")
          	}
  
          //click cllback
          function e() {
  
              //	debugger;
              var c = b.popups.get("image.edit");
              c || (c = p()), b.popups.setContainer("image.edit", a(b.opts.scrollableContainer)), b.popups.refresh("image.edit");
              var d = oa.offset().left + oa.outerWidth() / 2,
              e = oa.offset().top + oa.outerHeight();
              b.popups.show("image.edit", d, e, oa.outerHeight())
          }
  
          function f() {
          	r()
          }
  
          function g(a) {
          	if (!a.hasClass("fr-dii") && !a.hasClass("fr-dib")) {
          		var c = a.css("float");
          		a.css("float", "none"), "block" == a.css("display") ? (a.css("float", c), b.opts.imageEditButtons.indexOf("imageAlign") >= 0 && (0 === parseInt(a.css("margin-left"), 10) && (a.attr("style") || "").indexOf("margin-right: auto") >= 0 ? a.addClass("fr-fil") : 0 === parseInt(a.css("margin-right"), 10) && (a.attr("style") || "").indexOf("margin-left: auto") >= 0 && a.addClass("fr-fir")), a.addClass("fr-dib")) : (a.css("float", c), b.opts.imageEditButtons.indexOf("imageAlign") >= 0 && ("left" == a.css("float") ? a.addClass("fr-fil") : "right" == a.css("float") && a.addClass("fr-fir")), a.addClass("fr-dii")), a.css("margin", ""), a.css("float", ""), a.css("display", ""), a.css("z-index", ""), a.css("position", ""), a.css("overflow", ""), a.css("vertical-align", "")
          	}
          }
  
          function h() {
          	for (var c = "IMG" == b.$el.get(0).tagName ? [b.$el.get(0)] : b.$el.get(0).querySelectorAll("img"), d = 0; d < c.length; d++) {
          		var e = a(c[d]);
          		(b.opts.imageEditButtons.indexOf("imageAlign") >= 0 || b.opts.imageEditButtons.indexOf("imageDisplay") >= 0) && g(e), e.attr("width") && (e.css("width", e.width()), e.removeAttr("width")), b.opts.imageTextNear || e.removeClass("fr-dii").addClass("fr-dib"), b.opts.iframe && e.on("load", b.size.syncIframe)
          	}
          }
  
          function i() {
          	var c, d = Array.prototype.slice.call(b.$el.get(0).querySelectorAll("img")),
          	e = [];
          	for (c = 0; c < d.length; c++) e.push(d[c].getAttribute("src")), a(d[c]).toggleClass("fr-draggable", b.opts.imageMove);
          		if (Ba)
          			for (c = 0; c < Ba.length; c++) e.indexOf(Ba[c].getAttribute("src")) < 0 && b.events.trigger("image.removed", [a(Ba[c])]);
          				Ba = d
          		}
  
          		function j() {
          			pa || V();
          			var c = b.$wp || a(b.opts.scrollableContainer);
          			c.append(pa), pa.data("instance", b);
          			var d = c.scrollTop() - ("static" != c.css("position") ? c.offset().top : 0),
          			e = c.scrollLeft() - ("static" != c.css("position") ? c.offset().left : 0);
          			e -= b.helpers.getPX(c.css("border-left-width")), d -= b.helpers.getPX(c.css("border-top-width")), pa.css("top", (b.opts.iframe ? oa.offset().top : oa.offset().top + d) - 1).css("left", (b.opts.iframe ? oa.offset().left : oa.offset().left + e) - 1).css("width", oa.get(0).getBoundingClientRect().width).css("height", oa.get(0).getBoundingClientRect().height).addClass("fr-active")
          		}
  
          		function k(a) {
          			return '<div class="fr-handler fr-h' + a + '"></div>'
          		}
  
          		function l(c) {
          			if (!b.core.sameInstance(pa)) return !0;
          			if (c.preventDefault(), c.stopPropagation(), b.$el.find("img.fr-error").left) return !1;
          			b.undo.canDo() || b.undo.saveStep(), qa = a(this), qa.data("start-x", c.pageX || c.originalEvent.touches[0].pageX), qa.data("start-width", oa.width());
          			var d = oa.width();
          			if (b.opts.imageResizeWithPercent) {
          				var e = oa.parentsUntil(b.$el, b.html.blockTagsQuery()).get(0) || b.$el.get(0);
          				oa.css("width", (d / a(e).outerWidth() * 100).toFixed(2) + "%")
          			} else oa.css("width", d);
          			ra.show(), b.popups.hideAll(), ca()
          		}
  
          		function m(c) {
          			if (!b.core.sameInstance(pa)) return !0;
          			if (qa && oa) {
          				if (c.preventDefault(), b.$el.find("img.fr-error").left) return !1;
          				var d = c.pageX || (c.originalEvent.touches ? c.originalEvent.touches[0].pageX : null);
          				if (!d) return !1;
          				var e = qa.data("start-x"),
          				f = d - e,
          				g = qa.data("start-width");
          				if ((qa.hasClass("fr-hnw") || qa.hasClass("fr-hsw")) && (f = 0 - f), b.opts.imageResizeWithPercent) {
          					var h = oa.parentsUntil(b.$el, b.html.blockTagsQuery()).get(0) || b.$el.get(0);
          					g = ((g + f) / a(h).outerWidth() * 100).toFixed(2), b.opts.imageRoundPercent && (g = Math.round(g)), oa.css("width", g + "%")
          				} else g + f >= b.opts.imageMinWidth && oa.css("width", g + f);
          				oa.css("height", "").removeAttr("height"), j(), b.events.trigger("image.resize", [ma()])
          			}
          		}
  
          		function n(a) {
          			if (!b.core.sameInstance(pa)) return !0;
          			if (qa && oa) {
          				if (a && a.stopPropagation(), b.$el.find("img.fr-error").left) return !1;
          				qa = null, ra.hide(), j(), e(), b.undo.saveStep(), b.events.trigger("image.resizeEnd", [ma()])
          			}
          		}
  
          		function o(a, c) {
          			b.edit.on(), oa && oa.addClass("fr-error"), t(b.language.translate("Something went wrong. Please try again.")), b.events.trigger("image.error", [{
          				code: a,
          				message: Aa[a]
          			}, c])
          		}
  
          		function p(a) {
          			if (a) return b.$wp && b.events.$on(b.$wp, "scroll", function() {
          				oa && b.popups.isVisible("image.edit") && e()
          			}), !0;
          				var c = "";
          				b.opts.imageEditButtons.length > 1 && (c += '<div class="fr-buttons">', c += b.button.buildList(b.opts.imageEditButtons), c += "</div>");
          				var d = {
          					buttons: c
          				},
          				f = b.popups.create("image.edit", d);
          				return f
          			}
  
          			function q(c) {
          				var d = b.popups.get("image.insert");
          				if (d || (d = J()), b.popups.setContainer("image.insert", a(b.opts.scrollableContainer)), d.find(".fr-layer.fr-active").removeClass("fr-active").addClass("fr-pactive"), d.find(".fr-image-progress-bar-layer").addClass("fr-active"), d.find(".fr-buttons").hide(), oa) {
          					var e = oa.offset().left + oa.width() / 2,
          					f = oa.offset().top + oa.height();
          					b.popups.show("image.insert", e, f, oa.outerHeight())
          				}
          				"undefined" == typeof c && s("Uploading", 0)
          			}
  
          			function r(a) {
          				var c = b.popups.get("image.insert");
  
  
  
  
          				c && (c.find(".fr-layer.fr-pactive").addClass("fr-active").removeClass("fr-pactive"), c.find(".fr-image-progress-bar-layer").removeClass("fr-active"), c.find(".fr-buttons").hide(), (a || b.$el.find("img.fr-error").length) && (b.events.focus(), b.$el.find("img.fr-error").remove(), b.undo.saveStep(), b.undo.run(), b.undo.dropRedo()))
          			}
  
          //pop up image status info
          function s(a, c) {
          	var d = b.popups.get("image.insert");
          	if (d) {
          		var e = d.find(".fr-image-progress-bar-layer");
          		e.find("h3").text(a + (c ? " " + c + "%" : "")), e.removeClass("fr-error"), c ? (e.find("div").removeClass("fr-indeterminate"), e.find("div > span").css("width", c + "%")) : e.find("div").addClass("fr-indeterminate")
          	}
          }
  
          function t(a) {
          	var c = b.popups.get("image.insert"),
          	d = c.find(".fr-image-progress-bar-layer");
          	d.addClass("fr-error"), d.find("h3").text(a)
          }
  
          function u() {
          	var a = b.popups.get("image.insert"),
          	c = a.find(".fr-image-by-url-layer input");
          	c.val().length > 0 && (q(), s("Loading image"), x(b.helpers.sanitizeURL(c.val()), !0, [], oa), c.val(""), c.blur())
          }
  
          function v(a) {
          	_.call(a.get(0))
          }
  
          function w() {
          	var c = a(this);
          	b.popups.hide("image.insert"), c.removeClass("fr-uploading"), c.next().is("br") && c.next().remove(), v(c), b.events.trigger("image.loaded", [c])
          }
  
          function x(a, c, d, e, f) {
          	b.edit.off(), s("Loading image");
          	var g = new Image;
          	g.onload = function() {
          		var c, g;
          		alert("local img load remote link");
          		if (e) {
          			var h = e.data("fr-old-src");
          			b.$wp ? (c = e.clone().removeData("fr-old-src").removeClass("fr-uploading"), h && e.attr("src", h), e.replaceWith(c), c.off("load")) : c = e;
          			for (var j = c.get(0).attributes, k = 0; k < j.length; k++) {
          				var l = j[k];
          				0 === l.nodeName.indexOf("data-") && c.removeAttr(l.nodeName)
          			}
          			alert("if e");
          			if ("undefined" != typeof d)
          				for (g in d) d.hasOwnProperty(g) && "link" != g && c.attr("data-" + g, d[g]);
          					c.on("load", w), c.attr("src", a), b.edit.on(), i(), b.undo.saveStep(), b.events.trigger(h ? "image.replaced" : "image.inserted", [c, f])
          			} else {
          				alert("else");
          				c = D(a, d, w), i(), b.undo.saveStep(), b.events.trigger("image.inserted", [c, f])
          			}
          		}, g.onerror = function() {
          			o(ta)
          		}, g.src = a
          	}
  
          	function y(c) {
          		try {
          			if (b.events.trigger("image.uploaded", [c], !0) === !1) return b.edit.on(), !1;
          			var d = a.parseJSON(c);
          			return d.link ? d : (o(ua, c), !1)
          		} catch (e) {
          			return o(wa, c), !1
          		}
          	}
  
          	function z(c) {
          		try {
          			var d = a(c).find("Location").text(),
          			e = a(c).find("Key").text();
          			return b.events.trigger("image.uploadedToS3", [d, e, c], !0) === !1 ? (b.edit.on(), !1) : d
          		} catch (f) {
          			return o(wa, c), !1
          		}
          	}
  
          //ajax load callback
          function A(a) {
          	s("Loading image");
          	var c = this.status,
          	d = this.response,
          	e = this.responseXML,
          	f = this.responseText;
          	try {
          		if (b.opts.imageUploadToS3)
          			if (201 == c) {
          				var g = z(e);
          				g && x(g, !1, [], a, d || e);
          				debugger;
          			} else {
          				debugger;
          				o(wa, d || e);
          			}
          			else if (c >= 200 && 300 > c) {
          				debugger;
          				var h = y(f);
          				h = { link: "https://ss0.baidu.com/73x1bjeh1BF3odCf/it/u=3117273064,622399950&fm=96&s=51AABB571F9A544158D14F6E0300507C" };
                      //上传成功 然后替换url
                      h && x(h.link, !1, h, a, d || f);
                  } else {
                  	debugger;
                  	o(va, d || f);
                  }
              } catch (i) {
              	o(wa, d || f)
              }
          }
  
          //ajax fail callback
          function B() {
          	console.warn("ajax fail");
          	o(wa, this.response || this.responseText || this.responseXML)
          }
  
          function C(a) {
          	if (a.lengthComputable) {
          		var b = a.loaded / a.total * 100 | 0;
          		s("Uploading", b)
          	}
          }
  
  
  
          function sendImg(data, callback) {
  
          	var xhr = b.core.getXHR(b.opts.imageUploadURL, "POST");
  
          	xhr.onload = function() {
          		a('.loading').removeClass('showing');
          		if (200 == xhr.status) {
          			if ("function" == typeof callback) {
          				callback(xhr.responseText);
          			}
          		}
          	}
          	xhr.onerror = function() {
          		a('.loading').removeClass('showing');('showing');
          		callback("");
                  alert("网络错误 请重新上传");
          	}
          	xhr.ontimeout=function(){
          		a('.loading').removeClass('showing');
          		callback("");
                  alert("上传超时 请重新上传");
          	}
          	xhr.timeout=15000;
          	/*setTimeout(function(){
          		xhr.abort();
          		a('.loading').removeClass('showing');	
          		callback("http://a.hiphotos.baidu.com/zhidao/wh%3D450%2C600/sign=00ecb208249759ee4a0568cf87cb6f20/c995d143ad4bd1137be6613758afa40f4bfb058f.jpg");
          		alert("remove class showing");
          	},xhr.timeout);*/
          	
          	alert("start to send data");
          	xhr.send(data);
          }
  
          //compress image use canvas toDataURL
          //then send base64
          function D(c, d, e) {
          	var f, g = "";
  
          	alert("arrange preview image");
          	if (d && "undefined" != typeof d)
          		for (f in d) d.hasOwnProperty(f) && "link" != f && (g += " data-" + f + '="' + d[f] + '"');
          			var h = b.opts.imageDefaultWidth || "auto";
          		h && "auto" != h && ("" + h).indexOf("px") < 0 && ("" + h).indexOf("%") < 0 && (h += "px");
  
          		var img = new Image();
          		img.onload = function() {
  
          			alert("compress image");
          			var imgWidth = img.naturalWidth,
          			imgHeight = img.naturalHeight,
          			canvas = document.createElement('canvas'),
          			compressWidth = 800;
          			var ctx = canvas.getContext('2d'),
          			compressHeight = compressWidth * imgHeight / imgWidth;
                      if(imgWidth<800){
                          compressWidth=imgWidth;
                          compressHeight=imgHeight;
                      }
          			var orientation = 1;
          			EXIF.getData(img, function() {
          				orientation = parseInt(EXIF.getTag(img, "Orientation"));
          				orientation = orientation ? orientation : 1;
          			});
          			alert("image orientation " + orientation);
          			if (orientation <= 4) {
          				canvas.setAttribute('height', compressHeight);
          				canvas.setAttribute('width', compressWidth);
          				if (3 == orientation || 4 == orientation) {
          					ctx.translate(compressWidth, compressHeight);
          					ctx.rotate(180 * Math.PI / 180);
          				}
          			} else {
          				canvas.setAttribute('height', compressWidth);
          				canvas.setAttribute('width', compressHeight);
          				if (orientation == 5 || orientation == 6) {
          					ctx.translate(compressHeight, 0);
          					ctx.rotate(90 * Math.PI / 180);
          				} else if (orientation == 7 || orientation == 8) {
          					ctx.translate(0, compressWidth);
          					ctx.rotate(270 * Math.PI / 180);
          				}
          			}
                      var toType=img.src.match(/(image\/[^]*);/)[1];
                      ctx.drawImage(img, 0, 0, imgWidth, imgHeight, 0, 0, compressWidth, compressHeight);
                      //console.log(toType);
                      var compressSrc = (canvas.toDataURL(toType, 0.9));
                      alert("compressed image size is " + ~~(compressSrc.length / 1024) + "kb");
  
          			var formData = new FormData();
          			formData.append('file', compressSrc);
          			formData.append('width', compressWidth);
          			formData.append('height', compressHeight);
          			formData.append('random', +new Date());
  
          			sendImg(formData, function(imgUrl) {
          				alert("load remote image url");
          				var iu=compressSrc;
          				var i = a('<img class="fr-di' + b.opts.imageDefaultDisplay[0] + ("center" != b.opts.imageDefaultAlign ? " fr-fi" + b.opts.imageDefaultAlign[0] : "") + '" src="' + imgUrl + '"' + g + (h ? ' style="max-width:100%;margin:5px auto;display:block;width: ' + h + ';"' : "") + ">");
          				i.on("load", e), b.edit.on(), b.events.focus(!0), b.selection.restore(), b.undo.saveStep(), b.opts.imageSplitHTML ? b.markers.split() : b.markers.insert();
                      //find marmker and replace with image 
                      var j = b.$el.find(".fr-marker");
                      return j.replaceWith(i), b.html.wrap(), b.selection.clear(), i
  
                      i.attr("src", "http://www.hdb.com/captcha?time=" + (+new Date()) + "&send_type=0");
                  });
  
          		}
          		img.src = c;
          	}
  
          //show preview img src use blob
          //and send formdata 
          function E(c, d, e) {
          	function f() {
          		return;
          		var e = a(this);
          		debugger;
          		e.off("load"), e.addClass("fr-uploading"), e.next().is("br") && e.next().remove(), b.placeholder.refresh(), e.is(oa) || v(e), j(), q(), b.edit.off(), c.onload = function() {
  
          			alert("compress img");
          			A.call(c, e);
          		}, c.onerror = B, c.upload.onprogress = C, c.send(d)
          	}
          	var g, h = new FileReader;
              if(!e){
                  return;
              }
          	alert("start 2 read file");
                  a('.loading').addClass('showing');
          	h.addEventListener("load", function(ar) {
          		alert("load file");
                  alert("file type is "+ar.target.result.substring(0,15));
          		for (var a = atob(h.result.split(",")[1]), c = [], d = 0; d < a.length; d++)
          			c.push(a.charCodeAt(d));
          		try {
          			var e = window.URL.createObjectURL(new Blob([new Uint8Array(c)], {
          				type: "image/jpeg"
          			}));
          		} catch (e) {
          			alert("create objectUrl fail");
          		}
          		alert("create ObjectUrl success");
          		oa ? (oa.on("load", f), b.edit.on(), b.undo.saveStep(), oa.data("fr-old-src", oa.attr("src")), oa.attr("src", ar.target.result)) : g = D(ar.target.result, null, f)
          	}, !1), h.readAsDataURL(e)
          }
  
          //form data and ready2send
          function F(a) {
          	if (b.events.trigger("image.beforeUpload", [a]) === !1) return !1;
          	if ("undefined" != typeof a && a.length > 0) {
          		var c = a[0];
          		if (c.size > b.opts.imageMaxSize) return o(xa), !1;
          		if (b.opts.imageAllowedTypes.indexOf(c.type.replace(/image\//g, "")) < 0) return o(ya), !1;
          		var d;
          		if (b.drag_support.formdata && (d = b.drag_support.formdata ? new FormData : null), d) {
          			var e;
          			if (b.opts.imageUploadToS3 !== !1) {
          				d.append("key", b.opts.imageUploadToS3.keyStart + (new Date).getTime() + "-" + (c.name || "untitled")), d.append("success_action_status", "201"), d.append("X-Requested-With", "xhr"), d.append("Content-Type", c.type);
          				for (e in b.opts.imageUploadToS3.params) b.opts.imageUploadToS3.params.hasOwnProperty(e) && d.append(e, b.opts.imageUploadToS3.params[e])
          			}
          		for (e in b.opts.imageUploadParams) b.opts.imageUploadParams.hasOwnProperty(e) && d.append(e, b.opts.imageUploadParams[e]);
          			d.append(b.opts.imageUploadParam, c);
          		var f = b.opts.imageUploadURL;
          		b.opts.imageUploadToS3 && (f = "https://" + b.opts.imageUploadToS3.region + ".amazonaws.com/" + b.opts.imageUploadToS3.bucket);
  
          		var g = b.core.getXHR(f, b.opts.imageUploadMethod);
  
          		E(g, d, c)
          	}
          }
      }
  
      function G(c) {
      	b.events.$on(c, "dragover dragenter", ".fr-image-upload-layer", function() {
      		return a(this).addClass("fr-drop"), !1
      	}), b.events.$on(c, "dragleave dragend", ".fr-image-upload-layer", function() {
      		return a(this).removeClass("fr-drop"), !1
      	}), b.events.$on(c, "drop", ".fr-image-upload-layer", function(d) {
      		d.preventDefault(), d.stopPropagation(), a(this).removeClass("fr-drop");
      		var e = d.originalEvent.dataTransfer;
      		if (e && e.files) {
      			var f = c.data("instance") || b;
      			f.image.upload(e.files)
      		}
      	}), b.events.$on(c, "change", '.fr-image-upload-layer input[type="file"]', function() {
      		if (this.files) {
      			var d = c.data("instance") || b;
      			a('.fr-popup.fr-mobile').removeClass('fr-active');
      			d.image.upload(this.files)
      		}
      		a(this).val("")
      	})
      }
  
      function H(c) {
      	var d = c.originalEvent.dataTransfer;
      	if (d && d.files && d.files.length) {
      		var e = d.files[0];
      		if (e && e.type && b.opts.imageAllowedTypes.indexOf(e.type.replace(/image\//g, "")) >= 0) {
      			b.markers.remove(), b.markers.insertAtPoint(c.originalEvent), b.$el.find(".fr-marker").replaceWith(a.FE.MARKERS), b.popups.hideAll();
      			var f = b.popups.get("image.insert");
      			return f || (f = J()), b.popups.setContainer("image.insert", a(b.opts.scrollableContainer)), b.popups.show("image.insert", c.originalEvent.pageX, c.originalEvent.pageY), q(), F(d.files), c.preventDefault(), c.stopPropagation(), !1
      		}
      	}
      }
  
      function I() {
      	b.events.$on(b.$el, b._mousedown, "IMG" == b.$el.get(0).tagName ? null : 'img:not([contenteditable="false"])', function(c) {
      		return a(this).parents('[contenteditable="false"]:not(.fr-element)').length ? !0 : (b.selection.clear(), sa = !0, b.browser.msie && (b.events.disableBlur(), b.$el.attr("contenteditable", !1)), b.draggable || c.preventDefault(), void c.stopPropagation())
      	}), b.events.$on(b.$el, b._mouseup, "IMG" == b.$el.get(0).tagName ? null : 'img:not([contenteditable="false"])', function(c) {
      		return a(this).parents('[contenteditable="false"]:not(.fr-element)').length ? !0 : void(sa && (sa = !1, c.stopPropagation(), b.browser.msie && (b.$el.attr("contenteditable", !0), b.events.enableBlur())))
      	}), b.events.on("drop", H), b.events.on("mousedown window.mousedown", ba), b.events.on("window.touchmove", ca), b.events.on("mouseup window.mouseup", aa), b.events.on("commands.mousedown", function(a) {
      		a.parents(".fr-toolbar").length > 0 && aa()
      	}), b.events.on("blur image.hideResizer commands.undo commands.redo element.dropped", function() {
      		sa = !1, aa(!0)
      	})
      }
  
      function J(a) {
      	if (a) return b.popups.onRefresh("image.insert", c), b.popups.onHide("image.insert", f), !0;
      	var d, e = "";
      	b.opts.imageInsertButtons.length > 1 && (e = '<div class="fr-buttons">' + b.button.buildList(b.opts.imageInsertButtons) + "</div>");
      	var g = b.opts.imageInsertButtons.indexOf("imageUpload"),
      	h = b.opts.imageInsertButtons.indexOf("imageByURL"),
      	i = "";
      	g >= 0 && (d = " fr-active", h >= 0 && g > h && (d = ""), 
      		i = '<div class="fr-image-upload-layer' + 
      		d + ' fr-layer" id="fr-image-upload-layer-' + b.id +
      		'"><strong>' + "点击选择图片" + "</strong>" + 
      		'<div class="fr-form"><input type="file" id="compressImgInput" accept="image/*" tabIndex="-1"></div></div>');
      	var j = "";
      	h >= 0 && (d = " fr-active", g >= 0 && h > g && (d = ""), j = '<div class="fr-image-by-url-layer' + d + ' fr-layer" id="fr-image-by-url-layer-' + b.id + '"><div class="fr-input-line"><input type="text" placeholder="http://" tabIndex="1"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="imageInsertByURL" tabIndex="2">' + b.language.translate("Insert") + "</button></div></div>");
      	alert("arrange button");
      	var k = '<div class="fr-image-progress-bar-layer fr-layer"><h3 class="fr-message">Uploading</h3><div class="fr-loader"><span class="fr-progress"></span></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-back" data-cmd="imageDismissError" tabIndex="2">OK</button></div></div>',
      	l = {
      		buttons: e,
      		upload_layer: i,
      		by_url_layer: j,
      		progress_bar: k
      	},
      	m = b.popups.create("image.insert", l);
      	return b.$wp && b.events.$on(b.$wp, "scroll", function() {
      		oa && b.popups.isVisible("image.insert") && ja()
      	}), G(m), m
      }
  
      function K() {
      	if (oa) {
      		var a = b.popups.get("image.alt");
      		a.find("input").val(oa.attr("alt") || "").trigger("change")
      	}
      }
  
      function L() {
      	var c = b.popups.get("image.alt");
      	c || (c = M()), r(), b.popups.refresh("image.alt"), b.popups.setContainer("image.alt", a(b.opts.scrollableContainer));
      	var d = oa.offset().left + oa.width() / 2,
      	e = oa.offset().top + oa.height();
      	b.popups.show("image.alt", d, e, oa.outerHeight())
      }
  
      function M(a) {
      	if (a) return b.popups.onRefresh("image.alt", K), !0;
      	var c = "";
      	c = '<div class="fr-buttons">' + b.button.buildList(b.opts.imageAltButtons) + "</div>";
      	var d = "";
      	d = '<div class="fr-image-alt-layer fr-layer fr-active" id="fr-image-alt-layer-' + b.id + '"><div class="fr-input-line"><input type="text" placeholder="' + b.language.translate("Alternate Text") + '" tabIndex="1"></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="imageSetAlt" tabIndex="2">' + b.language.translate("Update") + "</button></div></div>";
      	var e = {
      		buttons: c,
      		alt_layer: d
      	},
      	f = b.popups.create("image.alt", e);
      	return b.$wp && b.events.$on(b.$wp, "scroll.image-alt", function() {
      		oa && b.popups.isVisible("image.alt") && L()
      	}), f
      }
  
      function N(a) {
      	if (oa) {
      		var c = b.popups.get("image.alt");
      		oa.attr("alt", a || c.find("input").val() || ""), c.find("input:focus").blur(), v(oa)
      	}
      }
  
      function O() {
      	if (oa) {
      		var a = b.popups.get("image.size");
      		a.find('input[name="width"]').val(oa.get(0).style.width).trigger("change"), a.find('input[name="height"]').val(oa.get(0).style.height).trigger("change")
      	}
      }
  
      function P() {
      	var c = b.popups.get("image.size");
      	c || (c = Q()), r(), b.popups.refresh("image.size"), b.popups.setContainer("image.size", a(b.opts.scrollableContainer));
      	var d = oa.offset().left + oa.width() / 2,
      	e = oa.offset().top + oa.height();
      	b.popups.show("image.size", d, e, oa.outerHeight())
      }
  
      function Q(a) {
      	if (a) return b.popups.onRefresh("image.size", O), !0;
      	var c = "";
      	c = '<div class="fr-buttons">' + b.button.buildList(b.opts.imageSizeButtons) + "</div>";
      	var d = "";
      	d = '<div class="fr-image-size-layer fr-layer fr-active" id="fr-image-size-layer-' + b.id + '"><div class="fr-image-group"><div class="fr-input-line"><input type="text" name="width" placeholder="' + b.language.translate("Width") + '" tabIndex="1"></div><div class="fr-input-line"><input type="text" name="height" placeholder="' + b.language.translate("Height") + '" tabIndex="1"></div></div><div class="fr-action-buttons"><button type="button" class="fr-command fr-submit" data-cmd="imageSetSize" tabIndex="2">' + b.language.translate("Update") + "</button></div></div>";
      	var e = {
      		buttons: c,
      		size_layer: d
      	},
      	f = b.popups.create("image.size", e);
      	return b.$wp && b.events.$on(b.$wp, "scroll.image-size", function() {
      		oa && b.popups.isVisible("image.size") && P()
      	}), f
      }
  
      function R(a, c) {
      	if (oa) {
      		var d = b.popups.get("image.size");
      		oa.css("width", a || d.find('input[name="width"]').val()), oa.css("height", c || d.find('input[name="height"]').val()), d.find("input:focus").blur(), v(oa)
      	}
      }
  
      function S(a) {
      	var c, d, e = b.popups.get("image.insert");
      	if (oa || b.opts.toolbarInline) oa && (d = oa.offset().top + oa.outerHeight());
      	else {
      		var f = b.$tb.find('.fr-command[data-cmd="insertImage"]');
      		c = f.offset().left + f.outerWidth() / 2, d = f.offset().top + (b.opts.toolbarBottom ? 10 : f.outerHeight() - 10)
      	}!oa && b.opts.toolbarInline && (d = e.offset().top - b.helpers.getPX(e.css("margin-top")), e.hasClass("fr-above") && (d += e.outerHeight())), e.find(".fr-layer").removeClass("fr-active"), e.find(".fr-" + a + "-layer").addClass("fr-active"), b.popups.show("image.insert", c, d, oa ? oa.outerHeight() : 0)
      }
  
      function T(a) {
      	var c = b.popups.get("image.insert");
      	c.find(".fr-image-upload-layer").hasClass("fr-active") && a.addClass("fr-active")
      }
  
      function U(a) {
      	var c = b.popups.get("image.insert");
      	c.find(".fr-image-by-url-layer").hasClass("fr-active") && a.addClass("fr-active")
      }
  
      function V() {
      	var c;
      	b.shared.$image_resizer ? (pa = b.shared.$image_resizer, ra = b.shared.$img_overlay, b.events.on("destroy", function() {
      		pa.removeClass("fr-active").appendTo(a("body"))
      	}, !0)) : (b.shared.$image_resizer = a('<div class="fr-image-resizer"></div>'), pa = b.shared.$image_resizer, b.events.$on(pa, "mousedown", function(a) {
      		a.stopPropagation()
      	}, !0), b.opts.imageResize && (pa.append(k("nw") + k("ne") + k("sw") + k("se")), b.shared.$img_overlay = a('<div class="fr-image-overlay"></div>'), ra = b.shared.$img_overlay, c = pa.get(0).ownerDocument, a(c).find("body").append(ra))), b.events.on("shared.destroy", function() {
      		pa.html("").removeData().remove(), b.opts.imageResize && ra.remove()
      	}, !0), b.helpers.isMobile() || b.events.$on(a(b.o_win), "resize", function() {
      		oa && !oa.hasClass("fr-uploading") ? aa(!0) : oa && (j(), ja(), q(!1))
      	}), b.opts.imageResize && (c = pa.get(0).ownerDocument, b.events.$on(pa, b._mousedown, ".fr-handler", l), b.events.$on(a(c), b._mousemove, m), b.events.$on(a(c.defaultView || c.parentWindow), b._mouseup, n), b.events.$on(ra, "mouseleave", n))
      }
  
      function W(c) {
      	c = c || oa, c && b.events.trigger("image.beforeRemove", [c]) !== !1 && (b.popups.hideAll(), aa(!0), c.get(0) == b.$el.get(0) ? c.removeAttr("src") : ("A" == c.get(0).parentNode.tagName ? (b.selection.setBefore(c.get(0).parentNode) || b.selection.setAfter(c.get(0).parentNode), a(c.get(0).parentNode).remove()) : (b.selection.setBefore(c.get(0)) || b.selection.setAfter(c.get(0)), c.remove()), b.selection.restore(), b.html.fillEmptyBlocks()), b.undo.saveStep())
      }
  
      function X() {
      	if (I(), "IMG" == b.$el.get(0).tagName && b.$el.addClass("fr-view"), b.events.$on(b.$el, b.helpers.isMobile() && !b.helpers.isWindowsPhone() ? "touchend" : "click", "IMG" == b.$el.get(0).tagName ? null : 'img:not([contenteditable="false"])', _), b.helpers.isMobile() && (b.events.$on(b.$el, "touchstart", "IMG" == b.$el.get(0).tagName ? null : 'img:not([contenteditable="false"])', function() {
      		Ca = !1
      	}), b.events.$on(b.$el, "touchmove", function() {
      		Ca = !0
      	})), b.events.on("window.keydown keydown", function(c) {
      		var d = c.which;
      		return !oa || d != a.FE.KEYCODE.BACKSPACE && d != a.FE.KEYCODE.DELETE ? oa && d == a.FE.KEYCODE.ESC ? (aa(!0), c.preventDefault(), !1) : oa && !b.keys.ctrlKey(c) ? (c.preventDefault(), !1) : void 0 : (c.preventDefault(), c.stopPropagation(), W(), !1)
      	}, !0), b.events.$on(a(b.o_win), "keydown", function(b) {
      		var c = b.which;
      		return oa && c == a.FE.KEYCODE.BACKSPACE ? (b.preventDefault(), !1) : void 0
      	}), b.events.on("paste.before", Z), b.events.on("paste.beforeCleanup", $), b.events.on("paste.after", Y), b.events.on("html.set", h), h(), b.events.on("html.get", function(a) {
      		return a = a.replace(/<(img)((?:[\w\W]*?))class="([\w\W]*?)(fr-uploading|fr-error)([\w\W]*?)"((?:[\w\W]*?))>/g, "")
      	}), b.opts.imageOutputSize) {
      		var c;
      		b.events.on("html.beforeGet", function() {
      			c = b.$el.get(0).querySelectorAll("img");
      			for (var d = 0; d < c.length; d++) c[d].setAttribute("width", a(c[d]).width()), c[d].setAttribute("height", a(c[d]).height())
      		}), b.events.on("html.afterGet", function() {
      			for (var a = 0; a < c.length; a++) c[a].removeAttribute("width"), c[a].removeAttribute("height")
      		})
      }
      b.opts.iframe && b.events.on("image.loaded", b.size.syncIframe), b.$wp && (i(), b.events.on("contentChanged", i)), b.events.$on(a(b.o_win), "orientationchange.image", function() {
      	setTimeout(function() {
      		var a = ma();
      		a && v(a)
      	}, 0)
      }), p(!0), J(!0), Q(!0), M(!0), b.events.on("node.remove", function(a) {
      	return "IMG" == a.get(0).tagName ? (W(a), !1) : void 0
      })
  }
  
  function Y() {
  	b.opts.imagePaste ? b.$el.find("img[data-fr-image-pasted]").each(function(c, d) {
  		if (0 === d.src.indexOf("data:")) {
  			if (b.events.trigger("image.beforePasteUpload", [d]) === !1) return !1;
  			var f = b.opts.imageDefaultWidth || "auto";
  			"auto" != f && (f += b.opts.imageResizeWithPercent ? "%" : "px"), a(d).css("width", f).css("max-width","100%"), a(d).addClass("fr-dib"), oa = a(d), j(), e(), ja(), q(), b.edit.off();
  			for (var g = atob(a(d).attr("src").split(",")[1]), h = [], i = 0; i < g.length; i++) h.push(g.charCodeAt(i));
  				var k = new Blob([new Uint8Array(h)], {
  					type: "image/jpeg"
  				});
  			F([k]), a(d).removeAttr("data-fr-image-pasted")
  		} else 0 !== d.src.indexOf("http") ? (b.selection.save(), a(d).remove(), b.selection.restore()) : a(d).removeAttr("data-fr-image-pasted")
  	}) : b.$el.find("img[data-fr-image-pasted]").remove()
  }
  
  function Z(a) {
  	if (a && a.clipboardData && a.clipboardData.items && a.clipboardData.items[0]) {
  		var c = a.clipboardData.items[0].getAsFile();
  		if (c) {
  			var d = new FileReader;
  			return d.onload = function(a) {
  				var c = a.target.result,
  				d = b.opts.imageDefaultWidth || "auto";
  				d && "auto" != d && ("" + d).indexOf("px") < 0 && ("" + d).indexOf("%") < 0 && (d += "px"), b.html.insert('<img data-fr-image-pasted="true" class="fr-di' + b.opts.imageDefaultDisplay[0] + ("center" != b.opts.imageDefaultAlign ? " fr-fi" + b.opts.imageDefaultAlign[0] : "") + '" src="' + c + '"' + (d ? ' style="width: ' + d + ';"' : "") + ">"), b.events.trigger("paste.after")
  			}, d.readAsDataURL(c), !1
  		}
  	}
  }
  
  function $(a) {
  	return a = a.replace(/<img /gi, '<img data-fr-image-pasted="true" ')
  }
  
  function _(c) {
  	if (a(this).parents('[contenteditable="false"]:not(.fr-element)').length) return !0;
  	if (c && "touchend" == c.type && Ca) return !0;
  	if (c && b.edit.isDisabled()) return c.stopPropagation(), c.preventDefault(), !1;
  	for (var d = 0; d < a.FE.INSTANCES.length; d++) a.FE.INSTANCES[d] != b && a.FE.INSTANCES[d].events.trigger("image.hideResizer");
  		b.toolbar.disable(), c && (c.stopPropagation(), c.preventDefault()), b.helpers.isMobile() && (b.events.disableBlur(), b.$el.blur(), b.events.enableBlur()), b.opts.iframe && b.size.syncIframe(), oa = a(this), ka(), j(), e(), b.selection.clear(), b.button.bulkRefresh(), b.events.trigger("video.hideResizer")
  }
  
  function aa(a) {
  	oa && (da() || a === !0) && (b.toolbar.enable(), pa.removeClass("fr-active"), b.popups.hide("image.edit"), oa = null, ca())
  }
  
  function ba() {
  	Da = !0
  }
  
  function ca() {
  	Da = !1
  }
  
  function da() {
  	return Da
  }
  
  function ea(a) {
  	oa.removeClass("fr-fir fr-fil"), "left" == a ? oa.addClass("fr-fil") : "right" == a && oa.addClass("fr-fir"), j(), e()
  }
  
  function fa(a) {
  	oa && (oa.hasClass("fr-fil") ? a.find("> *:first").replaceWith(b.icon.create("align-left")) : oa.hasClass("fr-fir") ? a.find("> *:first").replaceWith(b.icon.create("align-right")) : a.find("> *:first").replaceWith(b.icon.create("align-justify")))
  }
  
  function ga(a, b) {
  	if (oa) {
  		var c = "justify";
  		oa.hasClass("fr-fil") ? c = "left" : oa.hasClass("fr-fir") && (c = "right"), b.find('.fr-command[data-param1="' + c + '"]').addClass("fr-active")
  	}
  }
  
  function ha(a) {
  	oa.removeClass("fr-dii fr-dib"), "inline" == a ? oa.addClass("fr-dii") : "block" == a && oa.addClass("fr-dib"), j(), e()
  }
  
  function ia(a, b) {
  	var c = "block";
  	oa.hasClass("fr-dii") && (c = "inline"), b.find('.fr-command[data-param1="' + c + '"]').addClass("fr-active")
  }
  
  function ja() {
  	return;
  	var c = b.popups.get("image.insert");
  	c || (c = J()), b.popups.isVisible("image.insert") || (r(), b.popups.refresh("image.insert"), b.popups.setContainer("image.insert", a(b.opts.scrollableContainer)));
  	var d = oa.offset().left + oa.width() / 2,
  	e = oa.offset().top + oa.height();
  	b.popups.show("image.insert", d, e, oa.outerHeight())
  }
  
  function ka() {
  	if (oa) {
  		b.selection.clear();
  		var a = b.doc.createRange();
  		a.selectNode(oa.get(0));
  		var c = b.selection.get();
  		c.addRange(a)
  	}
  }
  
  function la() {
  	oa ? (a(".fr-popup input:focus").blur(), v(oa)) : (b.events.disableBlur(), b.selection.restore(), b.events.enableBlur(), b.popups.hide("image.insert"), b.toolbar.showInline())
  }
  
  function ma() {
  	return oa
  }
  
  function na(a, c, d) {
  	if ("undefined" == typeof c && (c = b.opts.imageStyles), "undefined" == typeof d && (d = b.opts.imageMultipleStyles), !oa) return !1;
  	if (!d) {
  		var e = Object.keys(c);
  		e.splice(e.indexOf(a), 1), oa.removeClass(e.join(" "))
  	}
  	oa.toggleClass(a), v(oa)
  }
  var oa, pa, qa, ra, sa = !1,
  ta = 1,
  ua = 2,
  va = 3,
  wa = 4,
  xa = 5,
  ya = 6,
  za = 7,
  Aa = {};
  Aa[ta] = "Image cannot be loaded from the passed link.", Aa[ua] = "No link in upload response.", Aa[va] = "Error during file upload.", Aa[wa] = "Parsing response failed.", Aa[xa] = "File is too large.", Aa[ya] = "Image file type is invalid.", Aa[za] = "Files can be uploaded only to same domain in IE 8 and IE 9.";
  var Ba, Ca, Da = !1;
  return {
  	_init: X,
  	showInsertPopup: d,
  	showLayer: S,
  	refreshUploadButton: T,
  	refreshByURLButton: U,
  	upload: F,
  	insertByURL: u,
  	align: ea,
  	refreshAlign: fa,
  	refreshAlignOnShow: ga,
  	display: ha,
  	refreshDisplayOnShow: ia,
  	replace: ja,
  	back: la,
  	get: ma,
  	insert: x,
  	showProgressBar: q,
  	remove: W,
  	hideProgressBar: r,
  	applyStyle: na,
  	showAltPopup: L,
  	showSizePopup: P,
  	setAlt: N,
  	setSize: R,
  	exitEdit: aa,
  	edit: v
  }
  }, a.FE.DefineIcon("insertImage", {
  	NAME: "image"
  }), a.FE.RegisterShortcut(80, "insertImage"), a.FE.RegisterCommand("insertImage", {
  	title: "Insert Image",
  	undo: !1,
  	focus: !0,
  	refershAfterCallback: !1,
  	popup: !0,
  	callback: function() {
  		this.popups.isVisible("image.insert") ? (this.$el.find(".fr-marker") && (this.events.disableBlur(), this.selection.restore()), this.popups.hide("image.insert")) : this.image.showInsertPopup()
  	},
  	plugin: "image"
  }), a.FE.DefineIcon("imageUpload", {
  	NAME: "upload"
  }), a.FE.RegisterCommand("imageUpload", {
  	title: "Upload Image",
  	undo: !1,
  	focus: !1,
  	callback: function() {
  		this.image.showLayer("image-upload")
  	},
  	refresh: function(a) {
  		this.image.refreshUploadButton(a)
  	}
  }), a.FE.DefineIcon("imageByURL", {
  	NAME: "link"
  }), a.FE.RegisterCommand("imageByURL", {
  	title: "By URL",
  	undo: !1,
  	focus: !1,
  	callback: function() {
  		this.image.showLayer("image-by-url")
  	},
  	refresh: function(a) {
  		this.image.refreshByURLButton(a)
  	}
  }), a.FE.RegisterCommand("imageInsertByURL", {
  	title: "Insert Image",
  	undo: !0,
  	refreshAfterCallback: !1,
  	callback: function() {
  		this.image.insertByURL()
  	},
  	refresh: function(a) {
  		var b = this.image.get();
  		b ? a.text(this.language.translate("Replace")) : a.text(this.language.translate("Insert"))
  	}
  }), a.FE.DefineIcon("imageDisplay", {
  	NAME: "star"
  }), a.FE.RegisterCommand("imageDisplay", {
  	title: "Display",
  	type: "dropdown",
  	options: {
  		inline: "Inline",
  		block: "Break Text"
  	},
  	callback: function(a, b) {
  		this.image.display(b)
  	},
  	refresh: function(a) {
  		this.opts.imageTextNear || a.addClass("fr-hidden")
  	},
  	refreshOnShow: function(a, b) {
  		this.image.refreshDisplayOnShow(a, b)
  	}
  }), a.FE.DefineIcon("imageAlign", {
  	NAME: "align-center"
  }), a.FE.RegisterCommand("imageAlign", {
  	type: "dropdown",
  	title: "Align",
  	options: {
  		left: "Align Left",
  		justify: "None",
  		right: "Align Right"
  	},
  	html: function() {
  		var b = '<ul class="fr-dropdown-list">',
  		c = a.FE.COMMANDS.imageAlign.options;
  		for (var d in c) c.hasOwnProperty(d) && (b += '<li><a class="fr-command fr-title" data-cmd="imageAlign" data-param1="' + d + '" title="' + this.language.translate(c[d]) + '">' + this.icon.create("align-" + d) + "</a></li>");
  			return b += "</ul>"
  	},
  	callback: function(a, b) {
  		this.image.align(b)
  	},
  	refresh: function(a) {
  		this.image.refreshAlign(a)
  	},
  	refreshOnShow: function(a, b) {
  		this.image.refreshAlignOnShow(a, b)
  	}
  }), a.FE.DefineIcon("imageReplace", {
  	NAME: "exchange"
  }), a.FE.RegisterCommand("imageReplace", {
  	title: "Replace",
  	undo: !1,
  	focus: !1,
  	refreshAfterCallback: !1,
  	callback: function() {
  		this.image.replace()
  	}
  }), a.FE.DefineIcon("imageRemove", {
  	NAME: "trash"
  }), a.FE.RegisterCommand("imageRemove", {
  	title: "Remove",
  	callback: function() {
  		this.image.remove()
  	}
  }), a.FE.DefineIcon("imageBack", {
  	NAME: "arrow-left"
  }), a.FE.RegisterCommand("imageBack", {
  	title: "Back",
  	undo: !1,
  	focus: !1,
  	back: !0,
  	callback: function() {
  		this.image.back()
  	},
  	refresh: function(a) {
  		var b = this.image.get();
  		b || this.opts.toolbarInline ? (a.removeClass("fr-hidden"), a.next(".fr-separator").removeClass("fr-hidden")) : (a.addClass("fr-hidden"), a.next(".fr-separator").addClass("fr-hidden"))
  	}
  }), a.FE.RegisterCommand("imageDismissError", {
  	title: "OK",
  	undo: !1,
  	callback: function() {
  		this.image.hideProgressBar(!0)
  	}
  }), a.FE.DefineIcon("imageStyle", {
  	NAME: "magic"
  }), a.FE.RegisterCommand("imageStyle", {
  	title: "Style",
  	type: "dropdown",
  	html: function() {
  		var a = '<ul class="fr-dropdown-list">',
  		b = this.opts.imageStyles;
  		for (var c in b) b.hasOwnProperty(c) && (a += '<li><a class="fr-command" data-cmd="imageStyle" data-param1="' + c + '">' + this.language.translate(b[c]) + "</a></li>");
  			return a += "</ul>"
  	},
  	callback: function(a, b) {
  		this.image.applyStyle(b)
  	},
  	refreshOnShow: function(b, c) {
  		var d = this.image.get();
  		d && c.find(".fr-command").each(function() {
  			var b = a(this).data("param1");
  			a(this).toggleClass("fr-active", d.hasClass(b))
  		})
  	}
  }), a.FE.DefineIcon("imageAlt", {
  	NAME: "info"
  }), a.FE.RegisterCommand("imageAlt", {
  	undo: !1,
  	focus: !1,
  	title: "Alternate Text",
  	callback: function() {
  		this.image.showAltPopup()
  	}
  }), a.FE.RegisterCommand("imageSetAlt", {
  	undo: !0,
  	focus: !1,
  	title: "Update",
  	refreshAfterCallback: !1,
  	callback: function() {
  		this.image.setAlt()
  	}
  }), a.FE.DefineIcon("imageSize", {
  	NAME: "arrows-alt"
  }), a.FE.RegisterCommand("imageSize", {
  	undo: !1,
  	focus: !1,
  	title: "Change Size",
  	callback: function() {
  		this.image.showSizePopup()
  	}
  }), a.FE.RegisterCommand("imageSetSize", {
  	undo: !0,
  	focus: !1,
  	title: "Update",
  	refreshAfterCallback: !1,
  	callback: function() {
  		this.image.setSize()
  	}
  })
  });
  
  //exif lib
  var EXIF = function() {
  	function e(e) {
  		return !!e.exifdata
  	}
  
  	function t(e, t) {
  		t = t || e.match(/^data\:([^\;]+)\;base64,/im)[1] || "", e = e.replace(/^data\:([^\;]+)\;base64,/gim, "");
  		for (var n = atob(e), r = n.length, a = new ArrayBuffer(r), o = new Uint8Array(a), i = 0; r > i; i++) o[i] = n.charCodeAt(i);
  			return a
  	}
  
  	function r(e, t) {
  		var n = new XMLHttpRequest;
  		n.open("GET", e, !0), n.responseType = "blob", n.onload = function() {
  			(200 == this.status || 0 === this.status) && t(this.response)
  		}, n.send()
  	}
  
  	function a(e, n) {
  		function a(t) {
  			var r = o(t),
  			a = i(t);
  			e.exifdata = r || {}, e.iptcdata = a || {}, n && n.call(e)
  		}
  		if (e instanceof Image || e instanceof HTMLImageElement)
  			if (/^data\:/i.test(e.src)) {
  				var s = t(e.src);
  				a(s)
  			} else if (/^blob\:/i.test(e.src)) {
  				var l = new FileReader;
  				l.onload = function(e) { a(e.target.result) }, r(e.src, function(e) { l.readAsArrayBuffer(e) })
  			} else {
  				var u = new XMLHttpRequest;
  				u.onload = function() {
  					if ("200" != u.status) throw "Could not load image";
  					a(u.response), u = null
  				}, u.open("GET", e.src, !0), u.responseType = "arraybuffer", u.send(null)
  			} else if (window.FileReader && (e instanceof window.Blob || e instanceof window.File)) {
  				var l = new FileReader;
  				l.onload = function(e) { S && console.log("Got file of length " + e.target.result.byteLength), a(e.target.result) }, l.readAsArrayBuffer(e)
  			}
  		}
  
  		function o(e) {
  			var t = new DataView(e);
  			if (S && console.log("Got file of length " + e.byteLength), 255 != t.getUint8(0) || 216 != t.getUint8(1)) return S && console.log("Not a valid JPEG"), !1;
  			for (var n, r = 2, a = e.byteLength; a > r;) {
  				if (255 != t.getUint8(r)) return S && console.log("Not a valid marker at offset " + r + ", found: " + t.getUint8(r)), !1;
  				if (n = t.getUint8(r + 1), S && console.log(n), 225 == n) return S && console.log("Found 0xFFE1 marker"), d(t, r + 4, t.getUint16(r + 2) - 2);
  				r += 2 + t.getUint16(r + 2)
  			}
  		}
  
  		function i(e) {
  			var t = new DataView(e);
  			if (S && console.log("Got file of length " + e.byteLength), 255 != t.getUint8(0) || 216 != t.getUint8(1)) return S && console.log("Not a valid JPEG"), !1;
  			for (var n = 2, r = e.byteLength, a = function(e, t) {
  				return 56 === e.getUint8(t) && 66 === e.getUint8(t + 1) && 73 === e.getUint8(t + 2) && 77 === e.getUint8(t + 3) && 4 === e.getUint8(t + 4) && 4 === e.getUint8(t + 5)
  			}; r > n;) {
  				if (a(t, n)) {
  					var o = t.getUint8(n + 7);
  					0 !== o % 2 && (o += 1), 0 === o && (o = 4);
  					var i = n + 8 + o,
  					l = t.getUint16(n + 6 + o);
  					return s(e, i, l)
  				}
  				n++
  			}
  		}
  
  		function s(e, t, n) {
  			for (var r, a, o, i, s, l = new DataView(e), u = {}, d = t; t + n > d;) 28 === l.getUint8(d) && 2 === l.getUint8(d + 1) && (i = l.getUint8(d + 2), i in I && (o = l.getInt16(d + 3), s = o + 5, a = I[i], r = c(l, d + 5, o), u.hasOwnProperty(a) ? u[a] instanceof Array ? u[a].push(r) : u[a] = [u[a], r] : u[a] = r)), d++;
  				return u
  		}
  
  		function l(e, t, n, r, a) {
  			var o, i, s, l = e.getUint16(n, !a),
  			c = {};
  			for (s = 0; l > s; s++) o = n + 12 * s + 2, i = r[e.getUint16(o, !a)], !i && S && console.log("Unknown tag: " + e.getUint16(o, !a)), c[i] = u(e, o, t, n, a);
  				return c
  		}
  
  		function u(e, t, n, r, a) {
  			var o, i, s, l, u, d, g = e.getUint16(t + 2, !a),
  			f = e.getUint32(t + 4, !a),
  			h = e.getUint32(t + 8, !a) + n;
  			switch (g) {
  				case 1:
  				case 7:
  				if (1 == f) return e.getUint8(t + 8, !a);
  				for (o = f > 4 ? h : t + 8, i = [], l = 0; f > l; l++) i[l] = e.getUint8(o + l);
  					return i;
  				case 2:
  				return o = f > 4 ? h : t + 8, c(e, o, f - 1);
  				case 3:
  				if (1 == f) return e.getUint16(t + 8, !a);
  				for (o = f > 2 ? h : t + 8, i = [], l = 0; f > l; l++) i[l] = e.getUint16(o + 2 * l, !a);
  					return i;
  				case 4:
  				if (1 == f) return e.getUint32(t + 8, !a);
  				for (i = [], l = 0; f > l; l++) i[l] = e.getUint32(h + 4 * l, !a);
  					return i;
  				case 5:
  				if (1 == f) return u = e.getUint32(h, !a), d = e.getUint32(h + 4, !a), s = new Number(u / d), s.numerator = u, s.denominator = d, s;
  				for (i = [], l = 0; f > l; l++) u = e.getUint32(h + 8 * l, !a), d = e.getUint32(h + 4 + 8 * l, !a), i[l] = new Number(u / d), i[l].numerator = u, i[l].denominator = d;
  					return i;
  				case 9:
  				if (1 == f) return e.getInt32(t + 8, !a);
  				for (i = [], l = 0; f > l; l++) i[l] = e.getInt32(h + 4 * l, !a);
  					return i;
  				case 10:
  				if (1 == f) return e.getInt32(h, !a) / e.getInt32(h + 4, !a);
  				for (i = [], l = 0; f > l; l++) i[l] = e.getInt32(h + 8 * l, !a) / e.getInt32(h + 4 + 8 * l, !a);
  					return i
  			}
  		}
  
  		function c(e, t, r) {
  			var a = "";
  			for (n = t; t + r > n; n++) a += String.fromCharCode(e.getUint8(n));
  				return a
  		}
  
  		function d(e, t) {
  			if ("Exif" != c(e, t, 4)) return S && console.log("Not valid EXIF data! " + c(e, t, 4)), !1;
  			var n, r, a, o, i, s = t + 6;
  			if (18761 == e.getUint16(s)) n = !1;
  			else {
  				if (19789 != e.getUint16(s)) return S && console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"), !1;
  				n = !0
  			}
  			if (42 != e.getUint16(s + 2, !n)) return S && console.log("Not valid TIFF data! (no 0x002A)"), !1;
  			var u = e.getUint32(s + 4, !n);
  			if (8 > u) return S && console.log("Not valid TIFF data! (First offset less than 8)", e.getUint32(s + 4, !n)), !1;
  			if (r = l(e, s, s + u, F, n), r.ExifIFDPointer) {
  				o = l(e, s, s + r.ExifIFDPointer, P, n);
  				for (a in o) {
  					switch (a) {
  						case "LightSource":
  						case "Flash":
  						case "MeteringMode":
  						case "ExposureProgram":
  						case "SensingMethod":
  						case "SceneCaptureType":
  						case "SceneType":
  						case "CustomRendered":
  						case "WhiteBalance":
  						case "GainControl":
  						case "Contrast":
  						case "Saturation":
  						case "Sharpness":
  						case "SubjectDistanceRange":
  						case "FileSource":
  						o[a] = D[a][o[a]];
  						break;
  						case "ExifVersion":
  						case "FlashpixVersion":
  						o[a] = String.fromCharCode(o[a][0], o[a][1], o[a][2], o[a][3]);
  						break;
  						case "ComponentsConfiguration":
  						o[a] = D.Components[o[a][0]] + D.Components[o[a][1]] + D.Components[o[a][2]] + D.Components[o[a][3]]
  					}
  					r[a] = o[a]
  				}
  			}
  			if (r.GPSInfoIFDPointer) {
  				i = l(e, s, s + r.GPSInfoIFDPointer, y, n);
  				for (a in i) {
  					switch (a) {
  						case "GPSVersionID":
  						i[a] = i[a][0] + "." + i[a][1] + "." + i[a][2] + "." + i[a][3]
  					}
  					r[a] = i[a]
  				}
  			}
  			return r
  		}
  
  		function g(t, n) {
  			return (t instanceof Image || t instanceof HTMLImageElement) && !t.complete ? !1 : (e(t) ? n && n.call(t) : a(t, n), !0)
  		}
  
  		function f(t, n) {
  			return e(t) ? t.exifdata[n] : void 0
  		}
  
  		function h(t) {
  			if (!e(t)) return {};
  			var n, r = t.exifdata,
  			a = {};
  			for (n in r) r.hasOwnProperty(n) && (a[n] = r[n]);
  				return a
  		}
  
  		function m(t) {
  			if (!e(t)) return "";
  			var n, r = t.exifdata,
  			a = "";
  			for (n in r) r.hasOwnProperty(n) && (a += "object" == typeof r[n] ? r[n] instanceof Number ? n + " : " + r[n] + " [" + r[n].numerator + "/" + r[n].denominator + "]\r\n" : n + " : [" + r[n].length + " values]\r\n" : n + " : " + r[n] + "\r\n");
  				return a
  		}
  
  		function p(e) {
  			return o(e)
  		}
  		var S = !1,
  		P = { 36864: "ExifVersion", 40960: "FlashpixVersion", 40961: "ColorSpace", 40962: "PixelXDimension", 40963: "PixelYDimension", 37121: "ComponentsConfiguration", 37122: "CompressedBitsPerPixel", 37500: "MakerNote", 37510: "UserComment", 40964: "RelatedSoundFile", 36867: "DateTimeOriginal", 36868: "DateTimeDigitized", 37520: "SubsecTime", 37521: "SubsecTimeOriginal", 37522: "SubsecTimeDigitized", 33434: "ExposureTime", 33437: "FNumber", 34850: "ExposureProgram", 34852: "SpectralSensitivity", 34855: "ISOSpeedRatings", 34856: "OECF", 37377: "ShutterSpeedValue", 37378: "ApertureValue", 37379: "BrightnessValue", 37380: "ExposureBias", 37381: "MaxApertureValue", 37382: "SubjectDistance", 37383: "MeteringMode", 37384: "LightSource", 37385: "Flash", 37396: "SubjectArea", 37386: "FocalLength", 41483: "FlashEnergy", 41484: "SpatialFrequencyResponse", 41486: "FocalPlaneXResolution", 41487: "FocalPlaneYResolution", 41488: "FocalPlaneResolutionUnit", 41492: "SubjectLocation", 41493: "ExposureIndex", 41495: "SensingMethod", 41728: "FileSource", 41729: "SceneType", 41730: "CFAPattern", 41985: "CustomRendered", 41986: "ExposureMode", 41987: "WhiteBalance", 41988: "DigitalZoomRation", 41989: "FocalLengthIn35mmFilm", 41990: "SceneCaptureType", 41991: "GainControl", 41992: "Contrast", 41993: "Saturation", 41994: "Sharpness", 41995: "DeviceSettingDescription", 41996: "SubjectDistanceRange", 40965: "InteroperabilityIFDPointer", 42016: "ImageUniqueID" },
  		F = { 256: "ImageWidth", 257: "ImageHeight", 34665: "ExifIFDPointer", 34853: "GPSInfoIFDPointer", 40965: "InteroperabilityIFDPointer", 258: "BitsPerSample", 259: "Compression", 262: "PhotometricInterpretation", 274: "Orientation", 277: "SamplesPerPixel", 284: "PlanarConfiguration", 530: "YCbCrSubSampling", 531: "YCbCrPositioning", 282: "XResolution", 283: "YResolution", 296: "ResolutionUnit", 273: "StripOffsets", 278: "RowsPerStrip", 279: "StripByteCounts", 513: "JPEGInterchangeFormat", 514: "JPEGInterchangeFormatLength", 301: "TransferFunction", 318: "WhitePoint", 319: "PrimaryChromaticities", 529: "YCbCrCoefficients", 532: "ReferenceBlackWhite", 306: "DateTime", 270: "ImageDescription", 271: "Make", 272: "Model", 305: "Software", 315: "Artist", 33432: "Copyright" },
  		y = { 0: "GPSVersionID", 1: "GPSLatitudeRef", 2: "GPSLatitude", 3: "GPSLongitudeRef", 4: "GPSLongitude", 5: "GPSAltitudeRef", 6: "GPSAltitude", 7: "GPSTimeStamp", 8: "GPSSatellites", 9: "GPSStatus", 10: "GPSMeasureMode", 11: "GPSDOP", 12: "GPSSpeedRef", 13: "GPSSpeed", 14: "GPSTrackRef", 15: "GPSTrack", 16: "GPSImgDirectionRef", 17: "GPSImgDirection", 18: "GPSMapDatum", 19: "GPSDestLatitudeRef", 20: "GPSDestLatitude", 21: "GPSDestLongitudeRef", 22: "GPSDestLongitude", 23: "GPSDestBearingRef", 24: "GPSDestBearing", 25: "GPSDestDistanceRef", 26: "GPSDestDistance", 27: "GPSProcessingMethod", 28: "GPSAreaInformation", 29: "GPSDateStamp", 30: "GPSDifferential" },
  		D = { ExposureProgram: { 0: "Not defined", 1: "Manual", 2: "Normal program", 3: "Aperture priority", 4: "Shutter priority", 5: "Creative program", 6: "Action program", 7: "Portrait mode", 8: "Landscape mode" }, MeteringMode: { 0: "Unknown", 1: "Average", 2: "CenterWeightedAverage", 3: "Spot", 4: "MultiSpot", 5: "Pattern", 6: "Partial", 255: "Other" }, LightSource: { 0: "Unknown", 1: "Daylight", 2: "Fluorescent", 3: "Tungsten (incandescent light)", 4: "Flash", 9: "Fine weather", 10: "Cloudy weather", 11: "Shade", 12: "Daylight fluorescent (D 5700 - 7100K)", 13: "Day white fluorescent (N 4600 - 5400K)", 14: "Cool white fluorescent (W 3900 - 4500K)", 15: "White fluorescent (WW 3200 - 3700K)", 17: "Standard light A", 18: "Standard light B", 19: "Standard light C", 20: "D55", 21: "D65", 22: "D75", 23: "D50", 24: "ISO studio tungsten", 255: "Other" }, Flash: { 0: "Flash did not fire", 1: "Flash fired", 5: "Strobe return light not detected", 7: "Strobe return light detected", 9: "Flash fired, compulsory flash mode", 13: "Flash fired, compulsory flash mode, return light not detected", 15: "Flash fired, compulsory flash mode, return light detected", 16: "Flash did not fire, compulsory flash mode", 24: "Flash did not fire, auto mode", 25: "Flash fired, auto mode", 29: "Flash fired, auto mode, return light not detected", 31: "Flash fired, auto mode, return light detected", 32: "No flash function", 65: "Flash fired, red-eye reduction mode", 69: "Flash fired, red-eye reduction mode, return light not detected", 71: "Flash fired, red-eye reduction mode, return light detected", 73: "Flash fired, compulsory flash mode, red-eye reduction mode", 77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", 79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", 89: "Flash fired, auto mode, red-eye reduction mode", 93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 95: "Flash fired, auto mode, return light detected, red-eye reduction mode" }, SensingMethod: { 1: "Not defined", 2: "One-chip color area sensor", 3: "Two-chip color area sensor", 4: "Three-chip color area sensor", 5: "Color sequential area sensor", 7: "Trilinear sensor", 8: "Color sequential linear sensor" }, SceneCaptureType: { 0: "Standard", 1: "Landscape", 2: "Portrait", 3: "Night scene" }, SceneType: { 1: "Directly photographed" }, CustomRendered: { 0: "Normal process", 1: "Custom process" }, WhiteBalance: { 0: "Auto white balance", 1: "Manual white balance" }, GainControl: { 0: "None", 1: "Low gain up", 2: "High gain up", 3: "Low gain down", 4: "High gain down" }, Contrast: { 0: "Normal", 1: "Soft", 2: "Hard" }, Saturation: { 0: "Normal", 1: "Low saturation", 2: "High saturation" }, Sharpness: { 0: "Normal", 1: "Soft", 2: "Hard" }, SubjectDistanceRange: { 0: "Unknown", 1: "Macro", 2: "Close view", 3: "Distant view" }, FileSource: { 3: "DSC" }, Components: { 0: "", 1: "Y", 2: "Cb", 3: "Cr", 4: "R", 5: "G", 6: "B" } },
  		I = { 120: "caption", 110: "credit", 25: "keywords", 55: "dateCreated", 80: "byline", 85: "bylineTitle", 122: "captionWriter", 105: "headline", 116: "copyright", 15: "category" };
  		return { readFromBinaryFile: p, pretty: m, getTag: f, getAllTags: h, getData: g, Tags: P, TiffTags: F, GPSTags: y, StringValues: D }
  	}();
  