'+'
'+"";a="
";l=f(a);s=this.$overlay=f(r).overlay({autoOpen:false,destroyOnClose:false,size:this.options.size,closeSelector:".lw_cancel a",title:this.options.title,footer:l,customClass:"lw_crop_overlay",zIndex:1305,close:f.proxy(this._close,this)});if(this.options.hide_aspect_ratio_menu){this.$overlay.find("#lw_image_crop_ar").hide()}else{this.$overlay.find("#lw_image_crop_ar").show()}this.$preview=s.find("#lw_image_crop_preview_image");this.$ar_checkboxes=s.find("#lw_image_crop_ar input[type=checkbox]");l.on("click",".btn-primary",function(e){e.preventDefault();i.saveCrop();return true});s.on("click","#lw_image_crop_ar input[type=checkbox]",function(){var e=f(this);var t=e.closest("label");if(e.prop("checked")){t.siblings().removeClass("selected").find("input[type=checkbox]").prop("checked",false);t.addClass("selected");i.setAspectRatio(e.val())}else{t.removeClass("selected");i.setAspectRatio("")}return true});s.on("keydown","#lw_image_crop_ar label",function(e){switch(e.which){case 13:f(this).find("input").click();break;case 37:f(this).prev().focus();break;case 39:f(this).next().focus();break}});if(this.options.custom_aspect_ratio){this.bind("ready",function(){if(t.jcrop_api){t.setAspectRatio(t.options.custom_aspect_ratio)}})}}},{key:"setAspectRatio",value:function e(t){var i=0;this.aspect_ratio=t;if(t==="orig"){i=this.width/this.height}else if(t.match(/^\d+:\d+$/)){i=parseInt(t.split(":")[0],10)/parseInt(t.split(":")[1],10)}this.jcrop_api.setOptions({aspectRatio:i})}},{key:"setCropSelect",value:function e(t){this.jcrop_api.setSelect(t)}},{key:"setCropCoords",value:function e(t){this.coords=t;this.trigger("set",[{coords:t}])}},{key:"setPreviewImage",value:function e(t){var i,r,s;if(this.height>=this.width){s=this.options.size==="large"?578:500;r=Math.round(s*(this.width/this.height))}else{r=this.options.size==="large"?868:500;s=Math.round(r*(this.height/this.width))}i=t.replace(/\/(?=[^/]*$)/,"/width/"+r+"/height/"+s+"/");this.$preview.attr("src",i).width(r).height(s)}},{key:"initCropper",value:function e(t){var a=this,i=this.$preview.width(),r=this.$preview.height(),s=i/this.width,l=r/this.height,o;if(!_.isArray(t)||t.length!==4){if(i>r){o=[(i-r)/2,0,(i-r)/2+r,r]}else{o=[0,(r-i)/2,i,(r-i)/2+i]}}else{o=[Math.round(t[0]*s),Math.round(t[1]*l),Math.round(t[2]*s),Math.round(t[3]*l)]}this.$preview.Jcrop({aspectRatio:0,keySupport:true,trueSize:[this.width,this.height],setSelect:o,onSelect:f.proxy(this.setCropCoords,this),onChange:f.proxy(this.setCropCoords,this),onRelease:function e(t){}},function(){var l=a.jcrop_api=this;if(a.aspect_ratio){a.$ar_checkboxes.each(function(){if(f(this).val()===a.aspect_ratio){f(this).trigger("click")}})}var o=null;var e=f(".jcrop-handle");var t=f(".jcrop-handle").parent();var i=["nw-resize","n-resize","ne-resize","w-resize","e-resize","sw-resize","s-resize","se-resize"];var r=["top left corner","top side","top right corner","left side","right side","bottom left corner","bottom side","bottom right corner"];function s(e,t){var i=l.tellSelect();var r=o?25:2;var s=null,a=null;if(e.charAt(0)=="n"){a="y"}else if(e.charAt(0)=="s"){a="y2"}if(e.includes("w-")){s="x"}else if(e.includes("e-")){s="x2"}switch(t){case"left":if(s){i[s]=i[s]-r}break;case"right":if(s){i[s]=i[s]+r}break;case"up":if(a){i[a]=i[a]-r}break;case"down":if(a){i[a]=i[a]+r}break}if(o){l.animateTo([i["x"],i["y"],i["x2"],i["y2"]])}else{l.setSelect([i["x"],i["y"],i["x2"],i["y2"]])}}e.attr("tabindex","0").each(function(){var t=f(this).css("cursor");f(this).attr("aria-label","Move "+r[i.indexOf(t)]+" of crop area").attr("data-handle-type",t).attr("data-handle-order",i.indexOf(t)).addClass(t).on("keydown",function(e){switch(e.which){case 37:e.preventDefault();s(t,"left");break;case 39:e.preventDefault();s(t,"right");break;case 38:e.preventDefault();s(t,"up");break;case 40:e.preventDefault();s(t,"down");break}}).on("keyup keydown",function(e){o=e.shiftKey})});t.find(".jcrop-handle").sort(function(e,t){return+e.getAttribute("data-handle-order")-+t.getAttribute("data-handle-order")}).appendTo(t);a.trigger("ready")})}},{key:"open",value:function e(t,i,r,s){var a=this;this.width=i;this.height=r;this.$overlay.overlay("open");this.setPreviewImage(t);this.$preview.parent().imagesLoaded(function(){a.initCropper(s)})}},{key:"saveCrop",value:function e(){var t=this.coords,i;if(_.isPlainObject(t)&&_.keys(t).length===6){i=[t.x,t.y,t.x2,t.y2]}this.trigger("save",[{coords:i,aspect_ratio:this.aspect_ratio}]);this.$overlay.overlay("close")}},{key:"_close",value:function e(){this.coords=null;this.$ar_checkboxes.prop("checked",false);if(this.jcrop_api){this.jcrop_api.destroy();this.jcrop_api=null}this.$preview.removeAttr("src")}}]);return r}(e);h.lib.CropDialog=t;function i(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;var i=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var r=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;var s=arguments.length>4&&arguments[4]!==undefined?arguments[4]:null;this.preview_width=e;this.preview_height=t;this.src=i;this.width=r;this.height=s;this.coords=null}_.extend(i.prototype,h.lib.pubSub(),{open:function e(){var i=this;if(!this.crop_dialog){this.crop_dialog=new h.lib.CropDialog({hide_aspect_ratio_menu:false,title:"Crop image"});this.crop_dialog.bind("save",function(e,t){i.setCrop(t.coords)})}this.crop_dialog.open(this.src,this.width,this.height,this.coords)},setImage:function e(t,i,r){this.src=t;this.width=i;this.height=r;this.resetCoords()},resetCoords:function e(){this.coords=null},getPreviewHeight:function e(t){var i=t[2]-t[0];var r=t[3]-t[1];return this.preview_width*(r/i)},getPreviewWidth:function e(t){var i=t[2]-t[0];var r=t[3]-t[1];return this.preview_height*(i/r)},setCrop:function e(t){if(!_.isArray(t)||t.length!==4){return}this.coords=t;var i,r;if(this.preview_width&&!this.preview_height){i=this.preview_width;r=this.getPreviewHeight(t)}if(this.preview_height&&!this.preview_width){r=this.preview_height;i=this.getPreviewWidth(t)}this.trigger("crop",[{src:this.src,preview_width:i,preview_height:r,width:this.width,height:this.height,coords:t}])}});h.lib.Cropper=i;var r={init:function e(){var t=this.$toolbar=f("#lw-toolbar");if(!t.length){return}this.initGroupSwitcher();this.addDropdownHandlers();this.adjustToolboxColumns();this.initSearch();this.initMobile();if(t.hasClass("lw-toolbar-backend")){t.find(".lw-frontend-only").remove()}else{t.find(".lw-backend-only").remove()}h.eventHub.bind("toolbarOpen",function(e,t){if(t.find(".lw-dropdown-menu .lw-group-switcher, .lw-dropdown-menu a, .lw-dropdown-menu input, .lw-dropdown-menu textarea").first().is("input,textarea")){t.find(".lw-dropdown-menu input, .lw-dropdown-menu textarea").first().trigger("focus")}return true});t.show()},initGroupSwitcher:function e(){if(h.group_fullname&&h.group_title_native!==h.group_fullname){f(".current-page-group").addClass("visible").html('Current Page Owner:
'+h.group_fullname+"").show()}else{f(".current-page-group").hide()}var t=f("#lw-group-filter").attr("role","application");f(".lw-group-switcher .no-results").hide();f(".lw-group-switcher li").attr("data-show-filtered","true");f('
').appendTo(f(".lw-group-switcher"));if(!_.isEmpty(h.top_groups)){f('
').insertBefore(".lw-group-switcher div ul");_.each(h.top_groups,function(e){f(".lw-group-switcher div.all-groups").find('a[href$="group='+e+'"]').parent().appendTo(f(".lw-group-switcher div.all-groups ul.top-groups"));f(".lw-group-switcher div.recent-groups").find('a[href$="group='+e+'"]').parent().appendTo(f(".lw-group-switcher div.recent-groups ul.top-groups"))})}function l(e){var t=f(".lw-group-switcher div.lw-dropdown-menu-inner"),i=t.outerHeight(),r=t.scrollTop(),s=e.position().top,a=e.offset().top;e.addClass("active");if(s+r<160&&r>0){t.scrollTop(0)}else if(a<40||a>i+30){e[0].scrollIntoView()}f(".lw-group-switcher div.system-groups a").prepend('