File Editor
Directories:
.. (Back)
widgets
Files:
accordion.js
accordion.min.js
code-editor.js
code-editor.min.js
color-picker.js
color-picker.min.js
comment.js
comment.min.js
common.js
common.min.js
custom-background.js
custom-background.min.js
custom-header.js
customize-controls.js
customize-controls.min.js
customize-nav-menus.js
customize-nav-menus.min.js
customize-widgets.js
customize-widgets.min.js
dashboard.js
dashboard.min.js
edit-comments.js
edit-comments.min.js
editor-expand.js
editor-expand.min.js
editor.js
editor.min.js
farbtastic.js
gallery.js
gallery.min.js
image-edit.js
image-edit.min.js
inline-edit-post.js
inline-edit-post.min.js
inline-edit-tax.js
inline-edit-tax.min.js
iris.min.js
language-chooser.js
language-chooser.min.js
link.js
link.min.js
media-gallery.js
media-gallery.min.js
media-upload.js
media-upload.min.js
media.js
media.min.js
nav-menu.js
nav-menu.min.js
password-strength-meter.js
password-strength-meter.min.js
plugin-install.js
plugin-install.min.js
post.js
post.min.js
postbox.js
postbox.min.js
privacy-tools.js
privacy-tools.min.js
revisions.js
revisions.min.js
set-post-thumbnail.js
set-post-thumbnail.min.js
site-health.js
site-health.min.js
svg-painter.js
svg-painter.min.js
tags-box.js
tags-box.min.js
tags-suggest.js
tags-suggest.min.js
tags.js
tags.min.js
theme-plugin-editor.js
theme-plugin-editor.min.js
theme.js
theme.min.js
updates.js
updates.min.js
user-profile.js
user-profile.min.js
user-suggest.js
user-suggest.min.js
widgets.js
widgets.min.js
word-count.js
word-count.min.js
wp-fullscreen-stub.js
wp-fullscreen-stub.min.js
xfn.js
xfn.min.js
Create New File
Create
Edit File: image-edit.min.js
!function(g){var d=window.imageEdit={iasapi:{},hold:{},postid:"",_view:!1,handleCropToolClick:function(i,t,e){var a=g("#image-preview-"+i),s=this.iasapi.getSelection();isNaN(s.x1)&&(this.setCropSelection(i,{x1:0,y1:0,x2:a.innerWidth(),y2:a.innerHeight(),width:a.innerWidth(),height:a.innerHeight()}),s=this.iasapi.getSelection()),0===s.x1&&0===s.y1&&0===s.x2&&0===s.y2?(this.iasapi.setSelection(0,0,a.innerWidth(),a.innerHeight(),!0),this.iasapi.setOptions({show:!0}),this.iasapi.update()):d.crop(i,t,e)},intval:function(i){return 0|i},setDisabled:function(i,t){t?i.removeClass("disabled").prop("disabled",!1):i.addClass("disabled").prop("disabled",!0)},init:function(i){var t=this,e=g("#image-editor-"+t.postid),a=t.intval(g("#imgedit-x-"+i).val()),s=t.intval(g("#imgedit-y-"+i).val());t.postid!==i&&e.length&&t.close(t.postid),t.hold.w=t.hold.ow=a,t.hold.h=t.hold.oh=s,t.hold.xy_ratio=a/s,t.hold.sizer=parseFloat(g("#imgedit-sizer-"+i).val()),t.postid=i,g("#imgedit-response-"+i).empty(),g('input[type="text"]',"#imgedit-panel-"+i).keypress(function(i){var t=i.keyCode;if(36<t&&t<41&&g(this).blur(),13===t)return i.preventDefault(),i.stopPropagation(),!1})},toggleEditor:function(i,t){i=g("#imgedit-wait-"+i);t?i.fadeIn("fast"):i.fadeOut("fast")},toggleHelp:function(i){i=g(i);return i.attr("aria-expanded","false"===i.attr("aria-expanded")?"true":"false").parents(".imgedit-group-top").toggleClass("imgedit-help-toggled").find(".imgedit-help").slideToggle("fast"),!1},getTarget:function(i){return g('input[name="imgedit-target-'+i+'"]:checked',"#imgedit-save-target-"+i).val()||"full"},scaleChanged:function(i,t,e){var a=g("#imgedit-scale-width-"+i),s=g("#imgedit-scale-height-"+i),o=g("#imgedit-scale-warn-"+i),n="",i="";!1!==this.validateNumeric(e)&&(t?(i=""!==a.val()?Math.round(a.val()/this.hold.xy_ratio):"",s.val(i)):(n=""!==s.val()?Math.round(s.val()*this.hold.xy_ratio):"",a.val(n)),i&&i>this.hold.oh||n&&n>this.hold.ow?o.css("visibility","visible"):o.css("visibility","hidden"))},getSelRatio:function(i){var t=this.hold.w,e=this.hold.h,a=this.intval(g("#imgedit-crop-width-"+i).val()),i=this.intval(g("#imgedit-crop-height-"+i).val());return a&&i?a+":"+i:t&&e?t+":"+e:"1:1"},filterHistory:function(i,t){var e,a,s,o=g("#imgedit-history-"+i).val(),n=[];if(""===o)return"";if(o=JSON.parse(o),0<(e=this.intval(g("#imgedit-undone-"+i).val())))for(;0<e;)o.pop(),e--;if(t){if(!o.length)return this.hold.w=this.hold.ow,this.hold.h=this.hold.oh,"";(t=(t=o[o.length-1]).c||t.r||t.f||!1)&&(this.hold.w=t.fw,this.hold.h=t.fh)}for(a in o)(s=o[a]).hasOwnProperty("c")?n[a]={c:{x:s.c.x,y:s.c.y,w:s.c.w,h:s.c.h}}:s.hasOwnProperty("r")?n[a]={r:s.r.r}:s.hasOwnProperty("f")&&(n[a]={f:s.f.f});return JSON.stringify(n)},refreshEditor:function(s,i,o){var n,t=this;t.toggleEditor(s,1),i={action:"imgedit-preview",_ajax_nonce:i,postid:s,history:t.filterHistory(s,1),rand:t.intval(1e6*Math.random())},n=g('<img id="image-preview-'+s+'" alt="" />').on("load",{history:i.history},function(i){var t,e=g("#imgedit-crop-"+s),a=d;""!==i.data.history&&(t=JSON.parse(i.data.history))[t.length-1].hasOwnProperty("c")&&(a.setDisabled(g("#image-undo-"+s),!0),g("#image-undo-"+s).focus()),e.empty().append(n),i=Math.max(a.hold.w,a.hold.h),t=Math.max(g(n).width(),g(n).height()),a.hold.sizer=t<i?t/i:1,a.initCrop(s,n,e),null!=o&&o(),g("#imgedit-history-"+s).val()&&"0"===g("#imgedit-undone-"+s).val()?g("input.imgedit-submit-btn","#imgedit-panel-"+s).removeAttr("disabled"):g("input.imgedit-submit-btn","#imgedit-panel-"+s).prop("disabled",!0),a.toggleEditor(s,0)}).on("error",function(){g("#imgedit-crop-"+s).empty().append('<div class="error"><p>'+imageEditL10n.error+"</p></div>"),t.toggleEditor(s,0)}).attr("src",ajaxurl+"?"+g.param(i))},action:function(t,i,e){var a,s,o,n,d=this;if(d.notsaved(t))return!1;if(a={action:"image-editor",_ajax_nonce:i,postid:t},"scale"===e){if(s=g("#imgedit-scale-width-"+t),o=g("#imgedit-scale-height-"+t),n=d.intval(s.val()),i=d.intval(o.val()),n<1)return s.focus(),!1;if(i<1)return o.focus(),!1;if(n===d.hold.ow||i===d.hold.oh)return!1;a.do="scale",a.fwidth=n,a.fheight=i}else{if("restore"!==e)return!1;a.do="restore"}d.toggleEditor(t,1),g.post(ajaxurl,a,function(i){g("#image-editor-"+t).empty().append(i),d.toggleEditor(t,0),d._view&&d._view.refresh()})},save:function(t,i){var e=this.getTarget(t),a=this.filterHistory(t,0),s=this;if(""===a)return!1;this.toggleEditor(t,1),e={action:"image-editor",_ajax_nonce:i,postid:t,history:a,target:e,context:g("#image-edit-context").length?g("#image-edit-context").val():null,do:"save"},g.post(ajaxurl,e,function(i){i=JSON.parse(i);if(i.error)return g("#imgedit-response-"+t).html('<div class="error"><p>'+i.error+"</p></div>"),void d.close(t);i.fw&&i.fh&&g("#media-dims-"+t).html(i.fw+" × "+i.fh),i.thumbnail&&g(".thumbnail","#thumbnail-head-"+t).attr("src",""+i.thumbnail),i.msg&&g("#imgedit-response-"+t).html('<div class="updated"><p>'+i.msg+"</p></div>"),s._view?s._view.save():d.close(t)})},open:function(t,i,e){this._view=e;var a=g("#image-editor-"+t),s=g("#media-head-"+t),o=g("#imgedit-open-btn-"+t),n=o.siblings(".spinner");if(!o.hasClass("button-activated"))return n.addClass("is-active"),g.ajax({url:ajaxurl,type:"post",data:{action:"image-editor",_ajax_nonce:i,postid:t,do:"open"},beforeSend:function(){o.addClass("button-activated")}}).done(function(i){a.html(i),s.fadeOut("fast",function(){a.fadeIn("fast"),o.removeClass("button-activated"),n.removeClass("is-active")}),d.init(t)})},imgLoaded:function(i){var t=g("#image-preview-"+i),e=g("#imgedit-crop-"+i);void 0===this.hold.sizer&&this.init(i),this.initCrop(i,t,e),this.setCropSelection(i,{x1:0,y1:0,x2:0,y2:0,width:t.innerWidth(),height:t.innerHeight()}),this.toggleEditor(i,0),g(".imgedit-wrap .imgedit-help-toggle").eq(0).focus()},initCrop:function(a,i,t){var s=this,o=g("#imgedit-sel-width-"+a),n=g("#imgedit-sel-height-"+a);s.iasapi=g(i).imgAreaSelect({parent:t,instance:!0,handles:!0,keys:!0,minWidth:3,minHeight:3,onInit:function(i){g(i).next().css("position","absolute").nextAll(".imgareaselect-outer").css("position","absolute"),t.children().on("mousedown, touchstart",function(i){var t,e=!1;i.shiftKey&&(t=s.iasapi.getSelection(),i=s.getSelRatio(a),e=t&&t.width&&t.height?t.width+":"+t.height:i),s.iasapi.setOptions({aspectRatio:e})})},onSelectStart:function(){d.setDisabled(g("#imgedit-crop-sel-"+a),1)},onSelectEnd:function(i,t){d.setCropSelection(a,t)},onSelectChange:function(i,t){var e=d.hold.sizer;o.val(d.round(t.width/e)),n.val(d.round(t.height/e))}})},setCropSelection:function(i,t){if(!(t=t||0)||t.width<3&&t.height<3)return this.setDisabled(g(".imgedit-crop","#imgedit-panel-"+i),1),this.setDisabled(g("#imgedit-crop-sel-"+i),1),g("#imgedit-sel-width-"+i).val(""),g("#imgedit-sel-height-"+i).val(""),g("#imgedit-selection-"+i).val(""),!1;t={x:t.x1,y:t.y1,w:t.width,h:t.height},this.setDisabled(g(".imgedit-crop","#imgedit-panel-"+i),1),g("#imgedit-selection-"+i).val(JSON.stringify(t))},close:function(i,t){if((t=t||!1)&&this.notsaved(i))return!1;this.iasapi={},this.hold={},this._view?this._view.back():g("#image-editor-"+i).fadeOut("fast",function(){g("#media-head-"+i).fadeIn("fast",function(){g("#imgedit-open-btn-"+i).focus()}),g(this).empty()})},notsaved:function(i){var t=g("#imgedit-history-"+i).val(),t=""!==t?JSON.parse(t):[];return this.intval(g("#imgedit-undone-"+i).val())<t.length&&!confirm(g("#imgedit-leaving-"+i).html())},addStep:function(i,t,e){for(var a=this,s=g("#imgedit-history-"+t),o=""!==s.val()?JSON.parse(s.val()):[],n=g("#imgedit-undone-"+t),d=a.intval(n.val());0<d;)o.pop(),d--;n.val(0),o.push(i),s.val(JSON.stringify(o)),a.refreshEditor(t,e,function(){a.setDisabled(g("#image-undo-"+t),!0),a.setDisabled(g("#image-redo-"+t),!1)})},rotate:function(i,t,e,a){if(g(a).hasClass("disabled"))return!1;this.addStep({r:{r:i,fw:this.hold.h,fh:this.hold.w}},t,e)},flip:function(i,t,e,a){if(g(a).hasClass("disabled"))return!1;this.addStep({f:{f:i,fw:this.hold.w,fh:this.hold.h}},t,e)},crop:function(i,t,e){var a=g("#imgedit-selection-"+i).val(),s=this.intval(g("#imgedit-sel-width-"+i).val()),o=this.intval(g("#imgedit-sel-height-"+i).val());if(g(e).hasClass("disabled")||""===a)return!1;0<(a=JSON.parse(a)).w&&0<a.h&&0<s&&0<o&&(a.fw=s,a.fh=o,this.addStep({c:a},i,t))},undo:function(t,i){var e=this,a=g("#image-undo-"+t),s=g("#imgedit-undone-"+t),o=e.intval(s.val())+1;a.hasClass("disabled")||(s.val(o),e.refreshEditor(t,i,function(){var i=g("#imgedit-history-"+t),i=""!==i.val()?JSON.parse(i.val()):[];e.setDisabled(g("#image-redo-"+t),!0),e.setDisabled(a,o<i.length),i.length===o&&g("#image-redo-"+t).focus()}))},redo:function(i,t){var e=this,a=g("#image-redo-"+i),s=g("#imgedit-undone-"+i),o=e.intval(s.val())-1;a.hasClass("disabled")||(s.val(o),e.refreshEditor(i,t,function(){e.setDisabled(g("#image-undo-"+i),!0),e.setDisabled(a,0<o),0==o&&g("#image-undo-"+i).focus()}))},setNumSelection:function(i,t){var e,a=g("#imgedit-sel-width-"+i),s=g("#imgedit-sel-height-"+i),o=this.intval(a.val()),n=this.intval(s.val()),d=g("#image-preview-"+i),r=d.height(),l=d.width(),h=this.hold.sizer,d=this.iasapi;if(!1!==this.validateNumeric(t))return o<1?(a.val(""),!1):n<1?(s.val(""),!1):void(o&&n&&(e=d.getSelection())&&(t=e.x1+Math.round(o*h),o=e.y1+Math.round(n*h),n=e.x1,e=e.y1,l<t&&(n=0,t=l,a.val(Math.round(t/h))),r<o&&(e=0,o=r,s.val(Math.round(o/h))),d.setSelection(n,e,t,o),d.update(),this.setCropSelection(i,d.getSelection())))},round:function(i){var t;return i=Math.round(i),.6<this.hold.sizer?i:"1"===(t=i.toString().slice(-1))?i-1:"9"===t?i+1:i},setRatioSelection:function(i,t,e){var a=this.intval(g("#imgedit-crop-width-"+i).val()),s=this.intval(g("#imgedit-crop-height-"+i).val()),o=g("#image-preview-"+i).height();!1!==this.validateNumeric(e)&&a&&s&&(this.iasapi.setOptions({aspectRatio:a+":"+s}),(e=this.iasapi.getSelection(!0))&&(o<(s=Math.ceil(e.y1+(e.x2-e.x1)/(a/s)))&&(s=o,g(t?"#imgedit-crop-height-"+i:"#imgedit-crop-width-"+i).val("")),this.iasapi.setSelection(e.x1,e.y1,e.x2,s),this.iasapi.update()))},validateNumeric:function(i){if(!this.intval(g(i).val()))return g(i).val(""),!1}}}(jQuery);
Save Changes
Rename File
Rename