mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 06:36:47 +01:00
968d57a6b3
This updates the 4.5 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy. Because older branches use (really) old versions of NodeJS, the local Docker environment cannot be backported since the needed dependencies will not run on these older versions (see #48301). This also blocks the ability to move automated testing over to GitHub Actions (see #50401). This also replaces the `npm-shrinkwrap.json` with a `package-lock.json` file. Lock files were not supported in earlier versions of NPM, but can now be used. In addition to backporting the package updates that happened after branching 4.5, dependencies that were removed in future releases have also been updated to their latest versions. Props desrosj, dd32, netweb, jorbin. Merges [37185,37212,37612,38111,38688,39110,39113-39119,39478,42460-42461,42463,42887,43320,43323,43977,44219,44233,44728,45321,45765,46404,46408-46409,47404,47867-47869,47872-47873,48705,49636,49933,49937,49939,50017,50126,50176,50185,50192] to the 4.5 branch. See #52341. Built from https://develop.svn.wordpress.org/branches/4.5@50208 git-svn-id: http://core.svn.wordpress.org/branches/4.5@49880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
9.2 KiB
JavaScript
1 line
9.2 KiB
JavaScript
!function(g){var d=window.imageEdit={iasapi:{},hold:{},postid:"",_view:!1,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()),o=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=o,t.hold.xy_ratio=a/o,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){var e=g("#imgedit-scale-width-"+i),a=g("#imgedit-scale-height-"+i),o=g("#imgedit-scale-warn-"+i),s="",i="";t?(i=""!==e.val()?Math.round(e.val()/this.hold.xy_ratio):"",a.val(i)):(s=""!==a.val()?Math.round(a.val()*this.hold.xy_ratio):"",e.val(s)),i&&i>this.hold.oh||s&&s>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,o,s=g("#imgedit-history-"+i).val(),n=[];if(""===s)return"";if(s=JSON.parse(s),0<(e=this.intval(g("#imgedit-undone-"+i).val())))for(;0<e;)s.pop(),e--;if(t){if(!s.length)return this.hold.w=this.hold.ow,this.hold.h=this.hold.oh,"";(t=(t=s[s.length-1]).c||t.r||t.f||!1)&&(this.hold.w=t.fw,this.hold.h=t.fh)}for(a in s)(o=s[a]).hasOwnProperty("c")?n[a]={c:{x:o.c.x,y:o.c.y,w:o.c.w,h:o.c.h}}:o.hasOwnProperty("r")?n[a]={r:o.r.r}:o.hasOwnProperty("f")&&(n[a]={f:o.f.f});return JSON.stringify(n)},refreshEditor:function(o,i,s){var n,t=this;t.toggleEditor(o,1),i={action:"imgedit-preview",_ajax_nonce:i,postid:o,history:t.filterHistory(o,1),rand:t.intval(1e6*Math.random())},n=g('<img id="image-preview-'+o+'" alt="" />').on("load",{history:i.history},function(i){var t,e=g("#imgedit-crop-"+o),a=d;""!==i.data.history&&(t=JSON.parse(i.data.history))[t.length-1].hasOwnProperty("c")&&(a.setDisabled(g("#image-undo-"+o),!0),g("#image-undo-"+o).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(o,n,e),a.setCropSelection(o,0),null!=s&&s(),g("#imgedit-history-"+o).val()&&"0"===g("#imgedit-undone-"+o).val()?g("input.imgedit-submit-btn","#imgedit-panel-"+o).removeAttr("disabled"):g("input.imgedit-submit-btn","#imgedit-panel-"+o).prop("disabled",!0),a.toggleEditor(o,0)}).on("error",function(){g("#imgedit-crop-"+o).empty().append('<div class="error"><p>'+imageEditL10n.error+"</p></div>"),t.toggleEditor(o,0)}).attr("src",ajaxurl+"?"+g.param(i))},action:function(t,i,e){var a,o,s,n,d=this;if(d.notsaved(t))return!1;if(a={action:"image-editor",_ajax_nonce:i,postid:t},"scale"===e){if(o=g("#imgedit-scale-width-"+t),s=g("#imgedit-scale-height-"+t),n=d.intval(o.val()),i=d.intval(s.val()),n<1)return o.focus(),!1;if(i<1)return s.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),o=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>"),o._view?o._view.save():d.close(t)})},open:function(i,t,e){this._view=e;var a=g("#image-editor-"+i),o=g("#media-head-"+i),s=g("#imgedit-open-btn-"+i),n=s.siblings(".spinner");if(!s.hasClass("button-activated"))return n.addClass("is-active"),i={action:"image-editor",_ajax_nonce:t,postid:i,"do":"open"},g.ajax({url:ajaxurl,type:"post",data:i,beforeSend:function(){s.addClass("button-activated")}}).done(function(i){a.html(i),o.fadeOut("fast",function(){a.fadeIn("fast"),s.removeClass("button-activated"),n.removeClass("is-active")})})},imgLoaded:function(i){var t=g("#image-preview-"+i),e=g("#imgedit-crop-"+i);this.initCrop(i,t,e),this.setCropSelection(i,0),this.toggleEditor(i,0),g(".imgedit-wrap .imgedit-help-toggle").eq(0).focus()},initCrop:function(a,i,t){var o=this,s=g("#imgedit-sel-width-"+a),n=g("#imgedit-sel-height-"+a);o.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().mousedown(function(i){var t,e=!1;i.shiftKey&&(t=o.iasapi.getSelection(),i=o.getSelRatio(a),e=t&&t.width&&t.height?t.width+":"+t.height:i),o.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;s.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),0),this.setDisabled(g("#imgedit-crop-sel-"+i),0),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,o=g("#imgedit-history-"+t),s=""!==o.val()?JSON.parse(o.val()):[],n=g("#imgedit-undone-"+t),d=a.intval(n.val());0<d;)s.pop(),d--;n.val(0),s.push(i),o.val(JSON.stringify(s)),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(),o=this.intval(g("#imgedit-sel-width-"+i).val()),s=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<o&&0<s&&(a.fw=o,a.fh=s,this.addStep({c:a},i,t))},undo:function(t,i){var e=this,a=g("#image-undo-"+t),o=g("#imgedit-undone-"+t),s=e.intval(o.val())+1;a.hasClass("disabled")||(o.val(s),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,s<i.length),i.length===s&&g("#image-redo-"+t).focus()}))},redo:function(i,t){var e=this,a=g("#image-redo-"+i),o=g("#imgedit-undone-"+i),s=e.intval(o.val())-1;a.hasClass("disabled")||(o.val(s),e.refreshEditor(i,t,function(){e.setDisabled(g("#image-undo-"+i),!0),e.setDisabled(a,0<s),0==s&&g("#image-undo-"+i).focus()}))},setNumSelection:function(i){var t,e=g("#imgedit-sel-width-"+i),a=g("#imgedit-sel-height-"+i),o=this.intval(e.val()),s=this.intval(a.val()),n=g("#image-preview-"+i),d=n.height(),r=n.width(),l=this.hold.sizer,h=this.iasapi;return o<1?(e.val(""),!1):s<1?(a.val(""),!1):void(o&&s&&(t=h.getSelection())&&(n=t.x1+Math.round(o*l),o=t.y1+Math.round(s*l),s=t.x1,t=t.y1,r<n&&(s=0,n=r,e.val(Math.round(n/l))),d<o&&(t=0,o=d,a.val(Math.round(o/l))),h.setSelection(s,t,n,o),h.update(),this.setCropSelection(i,h.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,o=this.intval(g("#imgedit-crop-width-"+i).val()),s=this.intval(g("#imgedit-crop-height-"+i).val()),n=g("#image-preview-"+i).height();this.intval(g(e).val())?o&&s&&(this.iasapi.setOptions({aspectRatio:o+":"+s}),(a=this.iasapi.getSelection(!0))&&(n<(s=Math.ceil(a.y1+(a.x2-a.x1)/(o/s)))&&(s=n,g(t?"#imgedit-crop-height-"+i:"#imgedit-crop-width-"+i).val("")),this.iasapi.setSelection(a.x1,a.y1,a.x2,s),this.iasapi.update())):g(e).val("")}}}(jQuery); |