author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:40:08 +0200 | |
changeset 21 | 48c4eec2b7e6 |
parent 19 | 3d72ae0968f4 |
child 22 | 8c2e4d02f4ef |
permissions | -rw-r--r-- |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1 |
/** |
9 | 2 |
* The functions necessary for editing images. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* |
9 | 4 |
* @since 2.9.0 |
5 |
* @output wp-admin/js/image-edit.js |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
*/ |
0 | 7 |
|
16 | 8 |
/* global ajaxurl, confirm */ |
9 | 9 |
|
0 | 10 |
(function($) { |
16 | 11 |
var __ = wp.i18n.__; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
14 |
* Contains all the methods to initialize and control the image editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
* @namespace imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
var imageEdit = window.imageEdit = { |
0 | 19 |
iasapi : {}, |
20 |
hold : {}, |
|
21 |
postid : '', |
|
5 | 22 |
_view : false, |
0 | 23 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
25 |
* Enable crop tool. |
9 | 26 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
27 |
toggleCropTool: function( postid, nonce, cropButton ) { |
9 | 28 |
var img = $( '#image-preview-' + postid ), |
29 |
selection = this.iasapi.getSelection(); |
|
30 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
31 |
imageEdit.toggleControls( cropButton ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
32 |
var $el = $( cropButton ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
33 |
var state = ( $el.attr( 'aria-expanded' ) === 'true' ) ? 'true' : 'false'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
34 |
// Crop tools have been closed. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
35 |
if ( 'false' === state ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
36 |
// Cancel selection, but do not unset inputs. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
37 |
this.iasapi.cancelSelection(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
38 |
imageEdit.setDisabled($('.imgedit-crop-clear'), 0); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
39 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
40 |
imageEdit.setDisabled($('.imgedit-crop-clear'), 1); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
41 |
// Get values from inputs to restore previous selection. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
42 |
var startX = ( $( '#imgedit-start-x-' + postid ).val() ) ? $('#imgedit-start-x-' + postid).val() : 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
43 |
var startY = ( $( '#imgedit-start-y-' + postid ).val() ) ? $('#imgedit-start-y-' + postid).val() : 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
44 |
var width = ( $( '#imgedit-sel-width-' + postid ).val() ) ? $('#imgedit-sel-width-' + postid).val() : img.innerWidth(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
45 |
var height = ( $( '#imgedit-sel-height-' + postid ).val() ) ? $('#imgedit-sel-height-' + postid).val() : img.innerHeight(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
46 |
// Ensure selection is available, otherwise reset to full image. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
47 |
if ( isNaN( selection.x1 ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
48 |
this.setCropSelection( postid, { 'x1': startX, 'y1': startY, 'x2': width, 'y2': height, 'width': width, 'height': height } ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
49 |
selection = this.iasapi.getSelection(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
50 |
} |
9 | 51 |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
52 |
// If we don't already have a selection, select the entire image. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
53 |
if ( 0 === selection.x1 && 0 === selection.y1 && 0 === selection.x2 && 0 === selection.y2 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
54 |
this.iasapi.setSelection( 0, 0, img.innerWidth(), img.innerHeight(), true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
55 |
this.iasapi.setOptions( { show: true } ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
56 |
this.iasapi.update(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
57 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
58 |
this.iasapi.setSelection( startX, startY, width, height, true ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
59 |
this.iasapi.setOptions( { show: true } ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
60 |
this.iasapi.update(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
61 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
62 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
63 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
64 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
65 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
66 |
* Handle crop tool clicks. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
67 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
68 |
handleCropToolClick: function( postid, nonce, cropButton ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
69 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
70 |
if ( cropButton.classList.contains( 'imgedit-crop-clear' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
71 |
this.iasapi.cancelSelection(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
72 |
imageEdit.setDisabled($('.imgedit-crop-apply'), 0); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
73 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
74 |
$('#imgedit-sel-width-' + postid).val(''); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
75 |
$('#imgedit-sel-height-' + postid).val(''); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
76 |
$('#imgedit-start-x-' + postid).val('0'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
77 |
$('#imgedit-start-y-' + postid).val('0'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
78 |
$('#imgedit-selection-' + postid).val(''); |
9 | 79 |
} else { |
80 |
// Otherwise, perform the crop. |
|
81 |
imageEdit.crop( postid, nonce , cropButton ); |
|
82 |
} |
|
83 |
}, |
|
84 |
||
85 |
/** |
|
86 |
* Converts a value to an integer. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
* |
16 | 88 |
* @since 2.9.0 |
89 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
* @param {number} f The float value that should be converted. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
* @return {number} The integer representation from the float value. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
*/ |
0 | 96 |
intval : function(f) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
* Bitwise OR operator: one of the obscure ways to truncate floating point figures, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
* worth reminding JavaScript doesn't have a distinct "integer" type. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
*/ |
0 | 101 |
return f | 0; |
102 |
}, |
|
103 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
/** |
9 | 105 |
* Adds the disabled attribute and class to a single form element or a field set. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
* |
16 | 107 |
* @since 2.9.0 |
108 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
* @param {jQuery} el The element that should be modified. |
16 | 112 |
* @param {boolean|number} s The state for the element. If set to true |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
* the element is disabled, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
* otherwise the element is enabled. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
* The function is sometimes called with a 0 or 1 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
* instead of true or false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
* |
16 | 118 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
setDisabled : function( el, s ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
* `el` can be a single form element or a fieldset. Before #28864, the disabled state on |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
* some text fields was handled targeting $('input', el). Now we need to handle the |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
* disabled state on buttons too so we can just target `el` regardless if it's a single |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
* element or a fieldset because when a fieldset is disabled, its descendants are disabled too. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
*/ |
0 | 127 |
if ( s ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
el.removeClass( 'disabled' ).prop( 'disabled', false ); |
0 | 129 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
el.addClass( 'disabled' ).prop( 'disabled', true ); |
0 | 131 |
} |
132 |
}, |
|
133 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
/** |
9 | 135 |
* Initializes the image editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
* |
16 | 137 |
* @since 2.9.0 |
138 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
* |
16 | 141 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* |
16 | 143 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
*/ |
5 | 145 |
init : function(postid) { |
0 | 146 |
var t = this, old = $('#image-editor-' + t.postid), |
147 |
x = t.intval( $('#imgedit-x-' + postid).val() ), |
|
148 |
y = t.intval( $('#imgedit-y-' + postid).val() ); |
|
149 |
||
5 | 150 |
if ( t.postid !== postid && old.length ) { |
0 | 151 |
t.close(t.postid); |
5 | 152 |
} |
0 | 153 |
|
5 | 154 |
t.hold.w = t.hold.ow = x; |
155 |
t.hold.h = t.hold.oh = y; |
|
156 |
t.hold.xy_ratio = x / y; |
|
157 |
t.hold.sizer = parseFloat( $('#imgedit-sizer-' + postid).val() ); |
|
0 | 158 |
t.postid = postid; |
159 |
$('#imgedit-response-' + postid).empty(); |
|
160 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
161 |
$('#imgedit-panel-' + postid).on( 'keypress', function(e) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
162 |
var nonce = $( '#imgedit-nonce-' + postid ).val(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
163 |
if ( e.which === 26 && e.ctrlKey ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
164 |
imageEdit.undo( postid, nonce ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
165 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
166 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
167 |
if ( e.which === 25 && e.ctrlKey ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
168 |
imageEdit.redo( postid, nonce ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
169 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
170 |
}); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
171 |
|
18 | 172 |
$('#imgedit-panel-' + postid).on( 'keypress', 'input[type="text"]', function(e) { |
0 | 173 |
var k = e.keyCode; |
174 |
||
16 | 175 |
// Key codes 37 through 40 are the arrow keys. |
5 | 176 |
if ( 36 < k && k < 41 ) { |
18 | 177 |
$(this).trigger( 'blur' ); |
5 | 178 |
} |
0 | 179 |
|
16 | 180 |
// The key code 13 is the Enter key. |
5 | 181 |
if ( 13 === k ) { |
0 | 182 |
e.preventDefault(); |
183 |
e.stopPropagation(); |
|
184 |
return false; |
|
185 |
} |
|
186 |
}); |
|
16 | 187 |
|
188 |
$( document ).on( 'image-editor-ui-ready', this.focusManager ); |
|
0 | 189 |
}, |
190 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
/** |
9 | 192 |
* Toggles the wait/load icon in the editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
* |
16 | 194 |
* @since 2.9.0 |
195 |
* @since 5.5.0 Added the triggerUIReady parameter. |
|
196 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
* |
16 | 199 |
* @param {number} postid The post ID. |
200 |
* @param {number} toggle Is 0 or 1, fades the icon in when 1 and out when 0. |
|
201 |
* @param {boolean} triggerUIReady Whether to trigger a custom event when the UI is ready. Default false. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
* |
16 | 203 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
*/ |
16 | 205 |
toggleEditor: function( postid, toggle, triggerUIReady ) { |
0 | 206 |
var wait = $('#imgedit-wait-' + postid); |
207 |
||
5 | 208 |
if ( toggle ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
wait.fadeIn( 'fast' ); |
5 | 210 |
} else { |
16 | 211 |
wait.fadeOut( 'fast', function() { |
212 |
if ( triggerUIReady ) { |
|
213 |
$( document ).trigger( 'image-editor-ui-ready' ); |
|
214 |
} |
|
215 |
} ); |
|
5 | 216 |
} |
0 | 217 |
}, |
218 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
220 |
* Shows or hides image menu popup. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
221 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
222 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
223 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
224 |
* @memberof imageEdit |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
225 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
226 |
* @param {HTMLElement} el The activated control element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
227 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
228 |
* @return {boolean} Always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
229 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
230 |
togglePopup : function(el) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
231 |
var $el = $( el ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
232 |
var $targetEl = $( el ).attr( 'aria-controls' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
233 |
var $target = $( '#' + $targetEl ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
234 |
$el |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
235 |
.attr( 'aria-expanded', 'false' === $el.attr( 'aria-expanded' ) ? 'true' : 'false' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
236 |
// Open menu and set z-index to appear above image crop area if it is enabled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
237 |
$target |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
238 |
.toggleClass( 'imgedit-popup-menu-open' ).slideToggle( 'fast' ).css( { 'z-index' : 200000 } ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
239 |
// Move focus to first item in menu when opening menu. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
240 |
if ( 'true' === $el.attr( 'aria-expanded' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
241 |
$target.find( 'button' ).first().trigger( 'focus' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
242 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
243 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
244 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
245 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
246 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
247 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
248 |
* Observes whether the popup should remain open based on focus position. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
249 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
250 |
* @since 6.4.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
251 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
252 |
* @memberof imageEdit |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
253 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
254 |
* @param {HTMLElement} el The activated control element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
255 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
256 |
* @return {boolean} Always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
257 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
258 |
monitorPopup : function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
259 |
var $parent = document.querySelector( '.imgedit-rotate-menu-container' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
260 |
var $toggle = document.querySelector( '.imgedit-rotate-menu-container .imgedit-rotate' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
261 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
262 |
setTimeout( function() { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
263 |
var $focused = document.activeElement; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
264 |
var $contains = $parent.contains( $focused ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
265 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
266 |
// If $focused is defined and not inside the menu container, close the popup. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
267 |
if ( $focused && ! $contains ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
268 |
if ( 'true' === $toggle.getAttribute( 'aria-expanded' ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
269 |
imageEdit.togglePopup( $toggle ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
270 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
271 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
272 |
}, 100 ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
273 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
274 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
275 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
276 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
277 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
278 |
* Navigate popup menu by arrow keys. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
279 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
280 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
281 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
282 |
* @memberof imageEdit |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
283 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
284 |
* @param {HTMLElement} el The current element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
285 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
286 |
* @return {boolean} Always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
287 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
288 |
browsePopup : function(el) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
289 |
var $el = $( el ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
290 |
var $collection = $( el ).parent( '.imgedit-popup-menu' ).find( 'button' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
291 |
var $index = $collection.index( $el ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
292 |
var $prev = $index - 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
293 |
var $next = $index + 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
294 |
var $last = $collection.length; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
295 |
if ( $prev < 0 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
296 |
$prev = $last - 1; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
297 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
298 |
if ( $next === $last ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
299 |
$next = 0; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
300 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
301 |
var $target = false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
302 |
if ( event.keyCode === 40 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
303 |
$target = $collection.get( $next ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
304 |
} else if ( event.keyCode === 38 ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
305 |
$target = $collection.get( $prev ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
306 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
307 |
if ( $target ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
308 |
$target.focus(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
309 |
event.preventDefault(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
310 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
311 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
312 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
313 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
314 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
315 |
/** |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
316 |
* Close popup menu and reset focus on feature activation. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
317 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
318 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
319 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
320 |
* @memberof imageEdit |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
321 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
322 |
* @param {HTMLElement} el The current element. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
323 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
324 |
* @return {boolean} Always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
325 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
326 |
closePopup : function(el) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
var $parent = $(el).parent( '.imgedit-popup-menu' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
328 |
var $controlledID = $parent.attr( 'id' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
329 |
var $target = $( 'button[aria-controls="' + $controlledID + '"]' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
330 |
$target |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
331 |
.attr( 'aria-expanded', 'false' ).trigger( 'focus' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
332 |
$parent |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
333 |
.toggleClass( 'imgedit-popup-menu-open' ).slideToggle( 'fast' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
334 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
335 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
336 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
337 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
338 |
/** |
9 | 339 |
* Shows or hides the image edit help box. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
* |
16 | 341 |
* @since 2.9.0 |
342 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
* @param {HTMLElement} el The element to create the help window in. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
* |
16 | 347 |
* @return {boolean} Always returns false. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
*/ |
0 | 349 |
toggleHelp : function(el) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
var $el = $( el ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
$el |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
.attr( 'aria-expanded', 'false' === $el.attr( 'aria-expanded' ) ? 'true' : 'false' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
.parents( '.imgedit-group-top' ).toggleClass( 'imgedit-help-toggled' ).find( '.imgedit-help' ).slideToggle( 'fast' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
|
0 | 355 |
return false; |
356 |
}, |
|
357 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
359 |
* Shows or hides image edit input fields when enabled. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
360 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
361 |
* @since 6.3.0 |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
362 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
363 |
* @memberof imageEdit |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
364 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
365 |
* @param {HTMLElement} el The element to trigger the edit panel. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
366 |
* |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
367 |
* @return {boolean} Always returns false. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
368 |
*/ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
369 |
toggleControls : function(el) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
370 |
var $el = $( el ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
371 |
var $target = $( '#' + $el.attr( 'aria-controls' ) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
372 |
$el |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
373 |
.attr( 'aria-expanded', 'false' === $el.attr( 'aria-expanded' ) ? 'true' : 'false' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
374 |
$target |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
375 |
.parent( '.imgedit-group' ).toggleClass( 'imgedit-panel-active' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
376 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
377 |
return false; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
378 |
}, |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
379 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
380 |
/** |
9 | 381 |
* Gets the value from the image edit target. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
* The image edit target contains the image sizes where the (possible) changes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
* have to be applied to. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
* |
16 | 386 |
* @since 2.9.0 |
387 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* |
16 | 390 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
* |
16 | 392 |
* @return {string} The value from the imagedit-save-target input field when available, |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
393 |
* 'full' when not selected, or 'all' if it doesn't exist. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
395 |
getTarget : function( postid ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
396 |
var element = $( '#imgedit-save-target-' + postid ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
397 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
398 |
if ( element.length ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
399 |
return element.find( 'input[name="imgedit-target-' + postid + '"]:checked' ).val() || 'full'; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
400 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
401 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
402 |
return 'all'; |
0 | 403 |
}, |
404 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
/** |
9 | 406 |
* Recalculates the height or width and keeps the original aspect ratio. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
* If the original image size is exceeded a red exclamation mark is shown. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
* |
16 | 410 |
* @since 2.9.0 |
411 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
* |
16 | 414 |
* @param {number} postid The current post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
* @param {number} x Is 0 when it applies the y-axis |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
* and 1 when applicable for the x-axis. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* @param {jQuery} el Element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
* |
16 | 419 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
scaleChanged : function( postid, x, el ) { |
0 | 422 |
var w = $('#imgedit-scale-width-' + postid), h = $('#imgedit-scale-height-' + postid), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
423 |
warn = $('#imgedit-scale-warn-' + postid), w1 = '', h1 = '', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
424 |
scaleBtn = $('#imgedit-scale-button'); |
0 | 425 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
if ( false === this.validateNumeric( el ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
|
0 | 430 |
if ( x ) { |
5 | 431 |
h1 = ( w.val() !== '' ) ? Math.round( w.val() / this.hold.xy_ratio ) : ''; |
0 | 432 |
h.val( h1 ); |
433 |
} else { |
|
5 | 434 |
w1 = ( h.val() !== '' ) ? Math.round( h.val() * this.hold.xy_ratio ) : ''; |
0 | 435 |
w.val( w1 ); |
436 |
} |
|
437 |
||
5 | 438 |
if ( ( h1 && h1 > this.hold.oh ) || ( w1 && w1 > this.hold.ow ) ) { |
0 | 439 |
warn.css('visibility', 'visible'); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
440 |
scaleBtn.prop('disabled', true); |
5 | 441 |
} else { |
0 | 442 |
warn.css('visibility', 'hidden'); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
443 |
scaleBtn.prop('disabled', false); |
5 | 444 |
} |
0 | 445 |
}, |
446 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
/** |
9 | 448 |
* Gets the selected aspect ratio. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
* |
16 | 450 |
* @since 2.9.0 |
451 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
* |
16 | 454 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* |
16 | 456 |
* @return {string} The aspect ratio. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
*/ |
0 | 458 |
getSelRatio : function(postid) { |
5 | 459 |
var x = this.hold.w, y = this.hold.h, |
0 | 460 |
X = this.intval( $('#imgedit-crop-width-' + postid).val() ), |
461 |
Y = this.intval( $('#imgedit-crop-height-' + postid).val() ); |
|
462 |
||
5 | 463 |
if ( X && Y ) { |
0 | 464 |
return X + ':' + Y; |
5 | 465 |
} |
0 | 466 |
|
5 | 467 |
if ( x && y ) { |
0 | 468 |
return x + ':' + y; |
5 | 469 |
} |
0 | 470 |
|
471 |
return '1:1'; |
|
472 |
}, |
|
473 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
/** |
9 | 475 |
* Removes the last action from the image edit history. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
476 |
* The history consist of (edit) actions performed on the image. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
* |
16 | 478 |
* @since 2.9.0 |
479 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
* |
16 | 482 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
* @param {number} setSize 0 or 1, when 1 the image resets to its original size. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
* |
16 | 485 |
* @return {string} JSON string containing the history or an empty string if no history exists. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
*/ |
0 | 487 |
filterHistory : function(postid, setSize) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
// Apply undo state to history. |
0 | 489 |
var history = $('#imgedit-history-' + postid).val(), pop, n, o, i, op = []; |
490 |
||
5 | 491 |
if ( history !== '' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
// Read the JSON string with the image edit history. |
0 | 493 |
history = JSON.parse(history); |
494 |
pop = this.intval( $('#imgedit-undone-' + postid).val() ); |
|
495 |
if ( pop > 0 ) { |
|
496 |
while ( pop > 0 ) { |
|
497 |
history.pop(); |
|
498 |
pop--; |
|
499 |
} |
|
500 |
} |
|
501 |
||
18 | 502 |
// Reset size to its original state. |
0 | 503 |
if ( setSize ) { |
504 |
if ( !history.length ) { |
|
5 | 505 |
this.hold.w = this.hold.ow; |
506 |
this.hold.h = this.hold.oh; |
|
0 | 507 |
return ''; |
508 |
} |
|
509 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
// Restore original 'o'. |
0 | 511 |
o = history[history.length - 1]; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
|
16 | 513 |
// c = 'crop', r = 'rotate', f = 'flip'. |
0 | 514 |
o = o.c || o.r || o.f || false; |
515 |
||
516 |
if ( o ) { |
|
16 | 517 |
// fw = Full image width. |
5 | 518 |
this.hold.w = o.fw; |
16 | 519 |
// fh = Full image height. |
5 | 520 |
this.hold.h = o.fh; |
0 | 521 |
} |
522 |
} |
|
523 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
524 |
// Filter the last step/action from the history. |
0 | 525 |
for ( n in history ) { |
526 |
i = history[n]; |
|
527 |
if ( i.hasOwnProperty('c') ) { |
|
528 |
op[n] = { 'c': { 'x': i.c.x, 'y': i.c.y, 'w': i.c.w, 'h': i.c.h } }; |
|
529 |
} else if ( i.hasOwnProperty('r') ) { |
|
530 |
op[n] = { 'r': i.r.r }; |
|
531 |
} else if ( i.hasOwnProperty('f') ) { |
|
532 |
op[n] = { 'f': i.f.f }; |
|
533 |
} |
|
534 |
} |
|
535 |
return JSON.stringify(op); |
|
536 |
} |
|
537 |
return ''; |
|
538 |
}, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
/** |
9 | 540 |
* Binds the necessary events to the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
541 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
542 |
* When the image source is reloaded the image will be reloaded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
543 |
* |
16 | 544 |
* @since 2.9.0 |
545 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
* |
16 | 548 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
* @param {string} nonce The nonce to verify the request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
* @param {function} callback Function to execute when the image is loaded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
* |
16 | 552 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
553 |
*/ |
0 | 554 |
refreshEditor : function(postid, nonce, callback) { |
555 |
var t = this, data, img; |
|
556 |
||
557 |
t.toggleEditor(postid, 1); |
|
558 |
data = { |
|
559 |
'action': 'imgedit-preview', |
|
560 |
'_ajax_nonce': nonce, |
|
561 |
'postid': postid, |
|
562 |
'history': t.filterHistory(postid, 1), |
|
563 |
'rand': t.intval(Math.random() * 1000000) |
|
564 |
}; |
|
565 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
566 |
img = $( '<img id="image-preview-' + postid + '" alt="" />' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
.on( 'load', { history: data.history }, function( event ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
568 |
var max1, max2, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
parent = $( '#imgedit-crop-' + postid ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
t = imageEdit, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
historyObj; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
// Checks if there already is some image-edit history. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
if ( '' !== event.data.history ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
historyObj = JSON.parse( event.data.history ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
// If last executed action in history is a crop action. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
if ( historyObj[historyObj.length - 1].hasOwnProperty( 'c' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
* A crop action has completed and the crop button gets disabled |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
* ensure the undo button is enabled. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
t.setDisabled( $( '#image-undo-' + postid) , true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
// Move focus to the undo button to avoid a focus loss. |
18 | 584 |
$( '#image-undo-' + postid ).trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
} |
0 | 587 |
|
588 |
parent.empty().append(img); |
|
589 |
||
16 | 590 |
// w, h are the new full size dimensions. |
0 | 591 |
max1 = Math.max( t.hold.w, t.hold.h ); |
592 |
max2 = Math.max( $(img).width(), $(img).height() ); |
|
5 | 593 |
t.hold.sizer = max1 > max2 ? max2 / max1 : 1; |
0 | 594 |
|
595 |
t.initCrop(postid, img, parent); |
|
596 |
||
5 | 597 |
if ( (typeof callback !== 'undefined') && callback !== null ) { |
0 | 598 |
callback(); |
5 | 599 |
} |
0 | 600 |
|
5 | 601 |
if ( $('#imgedit-history-' + postid).val() && $('#imgedit-undone-' + postid).val() === '0' ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
602 |
$('button.imgedit-submit-btn', '#imgedit-panel-' + postid).prop('disabled', false); |
5 | 603 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
604 |
$('button.imgedit-submit-btn', '#imgedit-panel-' + postid).prop('disabled', true); |
5 | 605 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
606 |
var successMessage = __( 'Image updated.' ); |
0 | 607 |
|
608 |
t.toggleEditor(postid, 0); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
609 |
wp.a11y.speak( successMessage, 'assertive' ); |
0 | 610 |
}) |
16 | 611 |
.on( 'error', function() { |
612 |
var errorMessage = __( 'Could not load the preview image. Please reload the page and try again.' ); |
|
613 |
||
614 |
$( '#imgedit-crop-' + postid ) |
|
615 |
.empty() |
|
616 |
.append( '<div class="notice notice-error" tabindex="-1" role="alert"><p>' + errorMessage + '</p></div>' ); |
|
617 |
||
618 |
t.toggleEditor( postid, 0, true ); |
|
619 |
wp.a11y.speak( errorMessage, 'assertive' ); |
|
620 |
} ) |
|
0 | 621 |
.attr('src', ajaxurl + '?' + $.param(data)); |
622 |
}, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
/** |
9 | 624 |
* Performs an image edit action. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
* |
16 | 626 |
* @since 2.9.0 |
627 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
629 |
* |
16 | 630 |
* @param {number} postid The post ID. |
631 |
* @param {string} nonce The nonce to verify the request. |
|
632 |
* @param {string} action The action to perform on the image. |
|
633 |
* The possible actions are: "scale" and "restore". |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
* |
16 | 635 |
* @return {boolean|void} Executes a post request that refreshes the page |
636 |
* when the action is performed. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
637 |
* Returns false if an invalid action is given, |
16 | 638 |
* or when the action cannot be performed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
*/ |
0 | 640 |
action : function(postid, nonce, action) { |
641 |
var t = this, data, w, h, fw, fh; |
|
642 |
||
5 | 643 |
if ( t.notsaved(postid) ) { |
0 | 644 |
return false; |
5 | 645 |
} |
0 | 646 |
|
647 |
data = { |
|
648 |
'action': 'image-editor', |
|
649 |
'_ajax_nonce': nonce, |
|
650 |
'postid': postid |
|
651 |
}; |
|
652 |
||
5 | 653 |
if ( 'scale' === action ) { |
0 | 654 |
w = $('#imgedit-scale-width-' + postid), |
655 |
h = $('#imgedit-scale-height-' + postid), |
|
656 |
fw = t.intval(w.val()), |
|
657 |
fh = t.intval(h.val()); |
|
658 |
||
659 |
if ( fw < 1 ) { |
|
18 | 660 |
w.trigger( 'focus' ); |
0 | 661 |
return false; |
662 |
} else if ( fh < 1 ) { |
|
18 | 663 |
h.trigger( 'focus' ); |
0 | 664 |
return false; |
665 |
} |
|
666 |
||
5 | 667 |
if ( fw === t.hold.ow || fh === t.hold.oh ) { |
0 | 668 |
return false; |
5 | 669 |
} |
0 | 670 |
|
671 |
data['do'] = 'scale'; |
|
5 | 672 |
data.fwidth = fw; |
673 |
data.fheight = fh; |
|
674 |
} else if ( 'restore' === action ) { |
|
0 | 675 |
data['do'] = 'restore'; |
676 |
} else { |
|
677 |
return false; |
|
678 |
} |
|
679 |
||
680 |
t.toggleEditor(postid, 1); |
|
16 | 681 |
$.post( ajaxurl, data, function( response ) { |
682 |
$( '#image-editor-' + postid ).empty().append( response.data.html ); |
|
683 |
t.toggleEditor( postid, 0, true ); |
|
684 |
// Refresh the attachment model so that changes propagate. |
|
5 | 685 |
if ( t._view ) { |
686 |
t._view.refresh(); |
|
687 |
} |
|
16 | 688 |
} ).done( function( response ) { |
689 |
// Whether the executed action was `scale` or `restore`, the response does have a message. |
|
690 |
if ( response && response.data.message.msg ) { |
|
691 |
wp.a11y.speak( response.data.message.msg ); |
|
692 |
return; |
|
693 |
} |
|
694 |
||
695 |
if ( response && response.data.message.error ) { |
|
696 |
wp.a11y.speak( response.data.message.error ); |
|
697 |
} |
|
698 |
} ); |
|
0 | 699 |
}, |
700 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
/** |
9 | 702 |
* Stores the changes that are made to the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
* |
16 | 704 |
* @since 2.9.0 |
705 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
* |
16 | 708 |
* @param {number} postid The post ID to get the image from the database. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
* @param {string} nonce The nonce to verify the request. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
* |
16 | 711 |
* @return {boolean|void} If the actions are successfully saved a response message is shown. |
712 |
* Returns false if there is no image editing history, |
|
713 |
* thus there are not edit-actions performed on the image. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
*/ |
0 | 715 |
save : function(postid, nonce) { |
5 | 716 |
var data, |
717 |
target = this.getTarget(postid), |
|
718 |
history = this.filterHistory(postid, 0), |
|
719 |
self = this; |
|
0 | 720 |
|
5 | 721 |
if ( '' === history ) { |
0 | 722 |
return false; |
5 | 723 |
} |
0 | 724 |
|
725 |
this.toggleEditor(postid, 1); |
|
726 |
data = { |
|
727 |
'action': 'image-editor', |
|
728 |
'_ajax_nonce': nonce, |
|
729 |
'postid': postid, |
|
730 |
'history': history, |
|
731 |
'target': target, |
|
732 |
'context': $('#image-edit-context').length ? $('#image-edit-context').val() : null, |
|
733 |
'do': 'save' |
|
734 |
}; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
735 |
// Post the image edit data to the backend. |
16 | 736 |
$.post( ajaxurl, data, function( response ) { |
737 |
// If a response is returned, close the editor and show an error. |
|
738 |
if ( response.data.error ) { |
|
739 |
$( '#imgedit-response-' + postid ) |
|
740 |
.html( '<div class="notice notice-error" tabindex="-1" role="alert"><p>' + response.data.error + '</p></div>' ); |
|
0 | 741 |
|
742 |
imageEdit.close(postid); |
|
16 | 743 |
wp.a11y.speak( response.data.error ); |
0 | 744 |
return; |
745 |
} |
|
746 |
||
16 | 747 |
if ( response.data.fw && response.data.fh ) { |
748 |
$( '#media-dims-' + postid ).html( response.data.fw + ' × ' + response.data.fh ); |
|
5 | 749 |
} |
0 | 750 |
|
16 | 751 |
if ( response.data.thumbnail ) { |
752 |
$( '.thumbnail', '#thumbnail-head-' + postid ).attr( 'src', '' + response.data.thumbnail ); |
|
5 | 753 |
} |
0 | 754 |
|
16 | 755 |
if ( response.data.msg ) { |
756 |
$( '#imgedit-response-' + postid ) |
|
757 |
.html( '<div class="notice notice-success" tabindex="-1" role="alert"><p>' + response.data.msg + '</p></div>' ); |
|
758 |
||
759 |
wp.a11y.speak( response.data.msg ); |
|
5 | 760 |
} |
0 | 761 |
|
5 | 762 |
if ( self._view ) { |
763 |
self._view.save(); |
|
764 |
} else { |
|
765 |
imageEdit.close(postid); |
|
766 |
} |
|
0 | 767 |
}); |
768 |
}, |
|
769 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
/** |
9 | 771 |
* Creates the image edit window. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
* |
16 | 773 |
* @since 2.9.0 |
774 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
775 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
* |
16 | 777 |
* @param {number} postid The post ID for the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
* @param {string} nonce The nonce to verify the request. |
16 | 779 |
* @param {Object} view The image editor view to be used for the editing. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
* |
16 | 781 |
* @return {void|promise} Either returns void if the button was already activated |
782 |
* or returns an instance of the image editor, wrapped in a promise. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
*/ |
5 | 784 |
open : function( postid, nonce, view ) { |
785 |
this._view = view; |
|
786 |
||
16 | 787 |
var dfd, data, |
788 |
elem = $( '#image-editor-' + postid ), |
|
789 |
head = $( '#media-head-' + postid ), |
|
790 |
btn = $( '#imgedit-open-btn-' + postid ), |
|
791 |
spin = btn.siblings( '.spinner' ); |
|
0 | 792 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
793 |
/* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
794 |
* Instead of disabling the button, which causes a focus loss and makes screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
795 |
* readers announce "unavailable", return if the button was already clicked. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
796 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
797 |
if ( btn.hasClass( 'button-activated' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
798 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
799 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
|
5 | 801 |
spin.addClass( 'is-active' ); |
0 | 802 |
|
803 |
data = { |
|
804 |
'action': 'image-editor', |
|
805 |
'_ajax_nonce': nonce, |
|
806 |
'postid': postid, |
|
807 |
'do': 'open' |
|
808 |
}; |
|
809 |
||
16 | 810 |
dfd = $.ajax( { |
5 | 811 |
url: ajaxurl, |
812 |
type: 'post', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
data: data, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
814 |
beforeSend: function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
815 |
btn.addClass( 'button-activated' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
816 |
} |
16 | 817 |
} ).done( function( response ) { |
818 |
var errorMessage; |
|
819 |
||
820 |
if ( '-1' === response ) { |
|
821 |
errorMessage = __( 'Could not load the preview image.' ); |
|
822 |
elem.html( '<div class="notice notice-error" tabindex="-1" role="alert"><p>' + errorMessage + '</p></div>' ); |
|
823 |
} |
|
824 |
||
825 |
if ( response.data && response.data.html ) { |
|
826 |
elem.html( response.data.html ); |
|
827 |
} |
|
828 |
||
829 |
head.fadeOut( 'fast', function() { |
|
830 |
elem.fadeIn( 'fast', function() { |
|
831 |
if ( errorMessage ) { |
|
832 |
$( document ).trigger( 'image-editor-ui-ready' ); |
|
833 |
} |
|
834 |
} ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
btn.removeClass( 'button-activated' ); |
5 | 836 |
spin.removeClass( 'is-active' ); |
16 | 837 |
} ); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
838 |
// Initialize the Image Editor now that everything is ready. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
imageEdit.init( postid ); |
16 | 840 |
} ); |
5 | 841 |
|
842 |
return dfd; |
|
0 | 843 |
}, |
844 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
845 |
/** |
9 | 846 |
* Initializes the cropping tool and sets a default cropping selection. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
* |
16 | 848 |
* @since 2.9.0 |
849 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
851 |
* |
16 | 852 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
* |
16 | 854 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
*/ |
0 | 856 |
imgLoaded : function(postid) { |
857 |
var img = $('#image-preview-' + postid), parent = $('#imgedit-crop-' + postid); |
|
858 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
// Ensure init has run even when directly loaded. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
if ( 'undefined' === typeof this.hold.sizer ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
this.init( postid ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
|
0 | 864 |
this.initCrop(postid, img, parent); |
9 | 865 |
this.setCropSelection( postid, { 'x1': 0, 'y1': 0, 'x2': 0, 'y2': 0, 'width': img.innerWidth(), 'height': img.innerHeight() } ); |
866 |
||
16 | 867 |
this.toggleEditor( postid, 0, true ); |
868 |
}, |
|
869 |
||
870 |
/** |
|
871 |
* Manages keyboard focus in the Image Editor user interface. |
|
872 |
* |
|
873 |
* @since 5.5.0 |
|
874 |
* |
|
875 |
* @return {void} |
|
876 |
*/ |
|
877 |
focusManager: function() { |
|
878 |
/* |
|
879 |
* Editor is ready. Move focus to one of the admin alert notices displayed |
|
880 |
* after a user action or to the first focusable element. Since the DOM |
|
881 |
* update is pretty large, the timeout helps browsers update their |
|
882 |
* accessibility tree to better support assistive technologies. |
|
883 |
*/ |
|
884 |
setTimeout( function() { |
|
885 |
var elementToSetFocusTo = $( '.notice[role="alert"]' ); |
|
886 |
||
887 |
if ( ! elementToSetFocusTo.length ) { |
|
888 |
elementToSetFocusTo = $( '.imgedit-wrap' ).find( ':tabbable:first' ); |
|
889 |
} |
|
890 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
891 |
elementToSetFocusTo.attr( 'tabindex', '-1' ).trigger( 'focus' ); |
16 | 892 |
}, 100 ); |
0 | 893 |
}, |
894 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
895 |
/** |
9 | 896 |
* Initializes the cropping tool. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
897 |
* |
16 | 898 |
* @since 2.9.0 |
899 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
* |
16 | 902 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
* @param {HTMLElement} image The preview image. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
* @param {HTMLElement} parent The preview image container. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
* |
16 | 906 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
907 |
*/ |
0 | 908 |
initCrop : function(postid, image, parent) { |
5 | 909 |
var t = this, |
910 |
selW = $('#imgedit-sel-width-' + postid), |
|
911 |
selH = $('#imgedit-sel-height-' + postid), |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
912 |
selX = $('#imgedit-start-x-' + postid), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
913 |
selY = $('#imgedit-start-y-' + postid), |
16 | 914 |
$image = $( image ), |
5 | 915 |
$img; |
0 | 916 |
|
16 | 917 |
// Already initialized? |
918 |
if ( $image.data( 'imgAreaSelect' ) ) { |
|
919 |
return; |
|
920 |
} |
|
921 |
||
922 |
t.iasapi = $image.imgAreaSelect({ |
|
0 | 923 |
parent: parent, |
924 |
instance: true, |
|
925 |
handles: true, |
|
926 |
keys: true, |
|
927 |
minWidth: 3, |
|
928 |
minHeight: 3, |
|
929 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
930 |
/** |
9 | 931 |
* Sets the CSS styles and binds events for locking the aspect ratio. |
932 |
* |
|
933 |
* @ignore |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
* @param {jQuery} img The preview image. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
*/ |
5 | 937 |
onInit: function( img ) { |
16 | 938 |
// Ensure that the imgAreaSelect wrapper elements are position:absolute |
939 |
// (even if we're in a position:fixed modal). |
|
5 | 940 |
$img = $( img ); |
941 |
$img.next().css( 'position', 'absolute' ) |
|
942 |
.nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
943 |
/** |
9 | 944 |
* Binds mouse down event to the cropping container. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
* |
16 | 946 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
948 |
parent.children().on( 'mousedown, touchstart', function(e){ |
0 | 949 |
var ratio = false, sel, defRatio; |
950 |
||
951 |
if ( e.shiftKey ) { |
|
952 |
sel = t.iasapi.getSelection(); |
|
953 |
defRatio = t.getSelRatio(postid); |
|
954 |
ratio = ( sel && sel.width && sel.height ) ? sel.width + ':' + sel.height : defRatio; |
|
955 |
} |
|
956 |
||
957 |
t.iasapi.setOptions({ |
|
958 |
aspectRatio: ratio |
|
959 |
}); |
|
960 |
}); |
|
961 |
}, |
|
962 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
/** |
9 | 964 |
* Event triggered when starting a selection. |
965 |
* |
|
966 |
* @ignore |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
967 |
* |
16 | 968 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
969 |
*/ |
5 | 970 |
onSelectStart: function() { |
0 | 971 |
imageEdit.setDisabled($('#imgedit-crop-sel-' + postid), 1); |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
972 |
imageEdit.setDisabled($('.imgedit-crop-clear'), 1); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
973 |
imageEdit.setDisabled($('.imgedit-crop-apply'), 1); |
0 | 974 |
}, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
/** |
9 | 976 |
* Event triggered when the selection is ended. |
977 |
* |
|
978 |
* @ignore |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
979 |
* |
16 | 980 |
* @param {Object} img jQuery object representing the image. |
981 |
* @param {Object} c The selection. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
* |
16 | 983 |
* @return {Object} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
984 |
*/ |
0 | 985 |
onSelectEnd: function(img, c) { |
986 |
imageEdit.setCropSelection(postid, c); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
987 |
if ( ! $('#imgedit-crop > *').is(':visible') ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
988 |
imageEdit.toggleControls($('.imgedit-crop.button')); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
989 |
} |
0 | 990 |
}, |
991 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
/** |
9 | 993 |
* Event triggered when the selection changes. |
994 |
* |
|
995 |
* @ignore |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
* |
16 | 997 |
* @param {Object} img jQuery object representing the image. |
998 |
* @param {Object} c The selection. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
* |
16 | 1000 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
*/ |
0 | 1002 |
onSelectChange: function(img, c) { |
1003 |
var sizer = imageEdit.hold.sizer; |
|
1004 |
selW.val( imageEdit.round(c.width / sizer) ); |
|
1005 |
selH.val( imageEdit.round(c.height / sizer) ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1006 |
selX.val( imageEdit.round(c.x1 / sizer) ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1007 |
selY.val( imageEdit.round(c.y1 / sizer) ); |
0 | 1008 |
} |
1009 |
}); |
|
1010 |
}, |
|
1011 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
/** |
9 | 1013 |
* Stores the current crop selection. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
* |
16 | 1015 |
* @since 2.9.0 |
1016 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
* |
16 | 1019 |
* @param {number} postid The post ID. |
1020 |
* @param {Object} c The selection. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
* |
16 | 1022 |
* @return {boolean} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1023 |
*/ |
0 | 1024 |
setCropSelection : function(postid, c) { |
5 | 1025 |
var sel; |
1026 |
||
1027 |
c = c || 0; |
|
0 | 1028 |
|
1029 |
if ( !c || ( c.width < 3 && c.height < 3 ) ) { |
|
9 | 1030 |
this.setDisabled( $( '.imgedit-crop', '#imgedit-panel-' + postid ), 1 ); |
1031 |
this.setDisabled( $( '#imgedit-crop-sel-' + postid ), 1 ); |
|
0 | 1032 |
$('#imgedit-sel-width-' + postid).val(''); |
1033 |
$('#imgedit-sel-height-' + postid).val(''); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1034 |
$('#imgedit-start-x-' + postid).val('0'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1035 |
$('#imgedit-start-y-' + postid).val('0'); |
0 | 1036 |
$('#imgedit-selection-' + postid).val(''); |
1037 |
return false; |
|
1038 |
} |
|
1039 |
||
1040 |
sel = { 'x': c.x1, 'y': c.y1, 'w': c.width, 'h': c.height }; |
|
1041 |
this.setDisabled($('.imgedit-crop', '#imgedit-panel-' + postid), 1); |
|
1042 |
$('#imgedit-selection-' + postid).val( JSON.stringify(sel) ); |
|
1043 |
}, |
|
1044 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
/** |
9 | 1047 |
* Closes the image editor. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1048 |
* |
16 | 1049 |
* @since 2.9.0 |
1050 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1051 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1052 |
* |
16 | 1053 |
* @param {number} postid The post ID. |
1054 |
* @param {boolean} warn Warning message. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
* |
16 | 1056 |
* @return {void|boolean} Returns false if there is a warning. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
*/ |
0 | 1058 |
close : function(postid, warn) { |
1059 |
warn = warn || false; |
|
1060 |
||
5 | 1061 |
if ( warn && this.notsaved(postid) ) { |
0 | 1062 |
return false; |
5 | 1063 |
} |
0 | 1064 |
|
1065 |
this.iasapi = {}; |
|
1066 |
this.hold = {}; |
|
5 | 1067 |
|
16 | 1068 |
// If we've loaded the editor in the context of a Media Modal, |
1069 |
// then switch to the previous view, whatever that might have been. |
|
5 | 1070 |
if ( this._view ){ |
1071 |
this._view.back(); |
|
1072 |
} |
|
1073 |
||
16 | 1074 |
// In case we are not accessing the image editor in the context of a View, |
1075 |
// close the editor the old-school way. |
|
5 | 1076 |
else { |
1077 |
$('#image-editor-' + postid).fadeOut('fast', function() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
$( '#media-head-' + postid ).fadeIn( 'fast', function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1079 |
// Move focus back to the Edit Image button. Runs also when saving. |
18 | 1080 |
$( '#imgedit-open-btn-' + postid ).trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
}); |
5 | 1082 |
$(this).empty(); |
1083 |
}); |
|
1084 |
} |
|
1085 |
||
1086 |
||
0 | 1087 |
}, |
1088 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
/** |
9 | 1090 |
* Checks if the image edit history is saved. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
* |
16 | 1092 |
* @since 2.9.0 |
1093 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
* |
16 | 1096 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
* |
16 | 1098 |
* @return {boolean} Returns true if the history is not saved. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
*/ |
0 | 1100 |
notsaved : function(postid) { |
1101 |
var h = $('#imgedit-history-' + postid).val(), |
|
5 | 1102 |
history = ( h !== '' ) ? JSON.parse(h) : [], |
0 | 1103 |
pop = this.intval( $('#imgedit-undone-' + postid).val() ); |
1104 |
||
1105 |
if ( pop < history.length ) { |
|
19 | 1106 |
if ( confirm( $('#imgedit-leaving-' + postid).text() ) ) { |
0 | 1107 |
return false; |
5 | 1108 |
} |
0 | 1109 |
return true; |
1110 |
} |
|
1111 |
return false; |
|
1112 |
}, |
|
1113 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1114 |
/** |
9 | 1115 |
* Adds an image edit action to the history. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1116 |
* |
16 | 1117 |
* @since 2.9.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1118 |
* |
16 | 1119 |
* @memberof imageEdit |
1120 |
* |
|
1121 |
* @param {Object} op The original position. |
|
1122 |
* @param {number} postid The post ID. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
* @param {string} nonce The nonce. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
* |
16 | 1125 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
*/ |
0 | 1127 |
addStep : function(op, postid, nonce) { |
1128 |
var t = this, elem = $('#imgedit-history-' + postid), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
history = ( elem.val() !== '' ) ? JSON.parse( elem.val() ) : [], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
undone = $( '#imgedit-undone-' + postid ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
pop = t.intval( undone.val() ); |
0 | 1132 |
|
1133 |
while ( pop > 0 ) { |
|
1134 |
history.pop(); |
|
1135 |
pop--; |
|
1136 |
} |
|
16 | 1137 |
undone.val(0); // Reset. |
0 | 1138 |
|
1139 |
history.push(op); |
|
1140 |
elem.val( JSON.stringify(history) ); |
|
1141 |
||
1142 |
t.refreshEditor(postid, nonce, function() { |
|
1143 |
t.setDisabled($('#image-undo-' + postid), true); |
|
1144 |
t.setDisabled($('#image-redo-' + postid), false); |
|
1145 |
}); |
|
1146 |
}, |
|
1147 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1148 |
/** |
9 | 1149 |
* Rotates the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1150 |
* |
16 | 1151 |
* @since 2.9.0 |
1152 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1153 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1155 |
* @param {string} angle The angle the image is rotated with. |
16 | 1156 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
* @param {string} nonce The nonce. |
16 | 1158 |
* @param {Object} t The target element. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
* |
16 | 1160 |
* @return {boolean} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
*/ |
0 | 1162 |
rotate : function(angle, postid, nonce, t) { |
5 | 1163 |
if ( $(t).hasClass('disabled') ) { |
0 | 1164 |
return false; |
5 | 1165 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1166 |
this.closePopup(t); |
5 | 1167 |
this.addStep({ 'r': { 'r': angle, 'fw': this.hold.h, 'fh': this.hold.w }}, postid, nonce); |
0 | 1168 |
}, |
1169 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1170 |
/** |
9 | 1171 |
* Flips the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
* |
16 | 1173 |
* @since 2.9.0 |
1174 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1175 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
* @param {number} axis The axle the image is flipped on. |
16 | 1178 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1179 |
* @param {string} nonce The nonce. |
16 | 1180 |
* @param {Object} t The target element. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
* |
16 | 1182 |
* @return {boolean} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
*/ |
0 | 1184 |
flip : function (axis, postid, nonce, t) { |
5 | 1185 |
if ( $(t).hasClass('disabled') ) { |
0 | 1186 |
return false; |
5 | 1187 |
} |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1188 |
this.closePopup(t); |
5 | 1189 |
this.addStep({ 'f': { 'f': axis, 'fw': this.hold.w, 'fh': this.hold.h }}, postid, nonce); |
0 | 1190 |
}, |
1191 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1192 |
/** |
9 | 1193 |
* Crops the image. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1194 |
* |
16 | 1195 |
* @since 2.9.0 |
1196 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1197 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1198 |
* |
16 | 1199 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1200 |
* @param {string} nonce The nonce. |
16 | 1201 |
* @param {Object} t The target object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1202 |
* |
16 | 1203 |
* @return {void|boolean} Returns false if the crop button is disabled. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1204 |
*/ |
0 | 1205 |
crop : function (postid, nonce, t) { |
1206 |
var sel = $('#imgedit-selection-' + postid).val(), |
|
1207 |
w = this.intval( $('#imgedit-sel-width-' + postid).val() ), |
|
1208 |
h = this.intval( $('#imgedit-sel-height-' + postid).val() ); |
|
1209 |
||
5 | 1210 |
if ( $(t).hasClass('disabled') || sel === '' ) { |
0 | 1211 |
return false; |
5 | 1212 |
} |
0 | 1213 |
|
1214 |
sel = JSON.parse(sel); |
|
1215 |
if ( sel.w > 0 && sel.h > 0 && w > 0 && h > 0 ) { |
|
5 | 1216 |
sel.fw = w; |
1217 |
sel.fh = h; |
|
0 | 1218 |
this.addStep({ 'c': sel }, postid, nonce); |
1219 |
} |
|
18 | 1220 |
|
1221 |
// Clear the selection fields after cropping. |
|
1222 |
$('#imgedit-sel-width-' + postid).val(''); |
|
1223 |
$('#imgedit-sel-height-' + postid).val(''); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1224 |
$('#imgedit-start-x-' + postid).val('0'); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1225 |
$('#imgedit-start-y-' + postid).val('0'); |
0 | 1226 |
}, |
1227 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
/** |
9 | 1229 |
* Undoes an image edit action. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
* |
16 | 1231 |
* @since 2.9.0 |
1232 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
* |
16 | 1235 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
* @param {string} nonce The nonce. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
* |
16 | 1238 |
* @return {void|false} Returns false if the undo button is disabled. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
*/ |
0 | 1240 |
undo : function (postid, nonce) { |
1241 |
var t = this, button = $('#image-undo-' + postid), elem = $('#imgedit-undone-' + postid), |
|
1242 |
pop = t.intval( elem.val() ) + 1; |
|
1243 |
||
5 | 1244 |
if ( button.hasClass('disabled') ) { |
0 | 1245 |
return; |
5 | 1246 |
} |
0 | 1247 |
|
1248 |
elem.val(pop); |
|
1249 |
t.refreshEditor(postid, nonce, function() { |
|
1250 |
var elem = $('#imgedit-history-' + postid), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
history = ( elem.val() !== '' ) ? JSON.parse( elem.val() ) : []; |
0 | 1252 |
|
1253 |
t.setDisabled($('#image-redo-' + postid), true); |
|
1254 |
t.setDisabled(button, pop < history.length); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
// When undo gets disabled, move focus to the redo button to avoid a focus loss. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
if ( history.length === pop ) { |
18 | 1257 |
$( '#image-redo-' + postid ).trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
} |
0 | 1259 |
}); |
1260 |
}, |
|
1261 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
* Reverts a undo action. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
* |
16 | 1265 |
* @since 2.9.0 |
1266 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
* |
16 | 1269 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
* @param {string} nonce The nonce. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
* |
16 | 1272 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
*/ |
0 | 1274 |
redo : function(postid, nonce) { |
1275 |
var t = this, button = $('#image-redo-' + postid), elem = $('#imgedit-undone-' + postid), |
|
1276 |
pop = t.intval( elem.val() ) - 1; |
|
1277 |
||
5 | 1278 |
if ( button.hasClass('disabled') ) { |
0 | 1279 |
return; |
5 | 1280 |
} |
0 | 1281 |
|
1282 |
elem.val(pop); |
|
1283 |
t.refreshEditor(postid, nonce, function() { |
|
1284 |
t.setDisabled($('#image-undo-' + postid), true); |
|
1285 |
t.setDisabled(button, pop > 0); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1286 |
// When redo gets disabled, move focus to the undo button to avoid a focus loss. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1287 |
if ( 0 === pop ) { |
18 | 1288 |
$( '#image-undo-' + postid ).trigger( 'focus' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1289 |
} |
0 | 1290 |
}); |
1291 |
}, |
|
1292 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1293 |
/** |
9 | 1294 |
* Sets the selection for the height and width in pixels. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1295 |
* |
16 | 1296 |
* @since 2.9.0 |
1297 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
* |
16 | 1300 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
* @param {jQuery} el The element containing the values. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
* |
16 | 1303 |
* @return {void|boolean} Returns false when the x or y value is lower than 1, |
1304 |
* void when the value is not numeric or when the operation |
|
1305 |
* is successful. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
setNumSelection : function( postid, el ) { |
0 | 1308 |
var sel, elX = $('#imgedit-sel-width-' + postid), elY = $('#imgedit-sel-height-' + postid), |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1309 |
elX1 = $('#imgedit-start-x-' + postid), elY1 = $('#imgedit-start-y-' + postid), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1310 |
xS = this.intval( elX1.val() ), yS = this.intval( elY1.val() ), |
0 | 1311 |
x = this.intval( elX.val() ), y = this.intval( elY.val() ), |
1312 |
img = $('#image-preview-' + postid), imgh = img.height(), imgw = img.width(), |
|
5 | 1313 |
sizer = this.hold.sizer, x1, y1, x2, y2, ias = this.iasapi; |
0 | 1314 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
if ( false === this.validateNumeric( el ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
|
0 | 1319 |
if ( x < 1 ) { |
1320 |
elX.val(''); |
|
1321 |
return false; |
|
1322 |
} |
|
1323 |
||
1324 |
if ( y < 1 ) { |
|
1325 |
elY.val(''); |
|
1326 |
return false; |
|
1327 |
} |
|
1328 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1329 |
if ( ( ( x && y ) || ( xS && yS ) ) && ( sel = ias.getSelection() ) ) { |
0 | 1330 |
x2 = sel.x1 + Math.round( x * sizer ); |
1331 |
y2 = sel.y1 + Math.round( y * sizer ); |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1332 |
x1 = ( xS === sel.x1 ) ? sel.x1 : Math.round( xS * sizer ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1333 |
y1 = ( yS === sel.y1 ) ? sel.y1 : Math.round( yS * sizer ); |
0 | 1334 |
|
1335 |
if ( x2 > imgw ) { |
|
1336 |
x1 = 0; |
|
1337 |
x2 = imgw; |
|
1338 |
elX.val( Math.round( x2 / sizer ) ); |
|
1339 |
} |
|
1340 |
||
1341 |
if ( y2 > imgh ) { |
|
1342 |
y1 = 0; |
|
1343 |
y2 = imgh; |
|
1344 |
elY.val( Math.round( y2 / sizer ) ); |
|
1345 |
} |
|
1346 |
||
1347 |
ias.setSelection( x1, y1, x2, y2 ); |
|
1348 |
ias.update(); |
|
1349 |
this.setCropSelection(postid, ias.getSelection()); |
|
1350 |
} |
|
1351 |
}, |
|
1352 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* Rounds a number to a whole. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* |
16 | 1356 |
* @since 2.9.0 |
1357 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
* @param {number} num The number. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
* |
16 | 1362 |
* @return {number} The number rounded to a whole number. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
*/ |
0 | 1364 |
round : function(num) { |
1365 |
var s; |
|
1366 |
num = Math.round(num); |
|
1367 |
||
5 | 1368 |
if ( this.hold.sizer > 0.6 ) { |
0 | 1369 |
return num; |
5 | 1370 |
} |
0 | 1371 |
|
1372 |
s = num.toString().slice(-1); |
|
1373 |
||
5 | 1374 |
if ( '1' === s ) { |
0 | 1375 |
return num - 1; |
5 | 1376 |
} else if ( '9' === s ) { |
0 | 1377 |
return num + 1; |
5 | 1378 |
} |
0 | 1379 |
|
1380 |
return num; |
|
1381 |
}, |
|
1382 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1384 |
* Sets a locked aspect ratio for the selection. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1385 |
* |
16 | 1386 |
* @since 2.9.0 |
1387 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1389 |
* |
16 | 1390 |
* @param {number} postid The post ID. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* @param {number} n The ratio to set. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* @param {jQuery} el The element containing the values. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
* |
16 | 1394 |
* @return {void} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
*/ |
0 | 1396 |
setRatioSelection : function(postid, n, el) { |
1397 |
var sel, r, x = this.intval( $('#imgedit-crop-width-' + postid).val() ), |
|
1398 |
y = this.intval( $('#imgedit-crop-height-' + postid).val() ), |
|
1399 |
h = $('#image-preview-' + postid).height(); |
|
1400 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
if ( false === this.validateNumeric( el ) ) { |
16 | 1402 |
this.iasapi.setOptions({ |
1403 |
aspectRatio: null |
|
1404 |
}); |
|
1405 |
||
0 | 1406 |
return; |
1407 |
} |
|
1408 |
||
1409 |
if ( x && y ) { |
|
1410 |
this.iasapi.setOptions({ |
|
1411 |
aspectRatio: x + ':' + y |
|
1412 |
}); |
|
1413 |
||
1414 |
if ( sel = this.iasapi.getSelection(true) ) { |
|
5 | 1415 |
r = Math.ceil( sel.y1 + ( ( sel.x2 - sel.x1 ) / ( x / y ) ) ); |
0 | 1416 |
|
1417 |
if ( r > h ) { |
|
1418 |
r = h; |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1419 |
var errorMessage = __( 'Selected crop ratio exceeds the boundaries of the image. Try a different ratio.' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1420 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1421 |
$( '#imgedit-crop-' + postid ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1422 |
.prepend( '<div class="notice notice-error" tabindex="-1" role="alert"><p>' + errorMessage + '</p></div>' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1423 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1424 |
wp.a11y.speak( errorMessage, 'assertive' ); |
5 | 1425 |
if ( n ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1426 |
$('#imgedit-crop-height-' + postid).val( '' ); |
5 | 1427 |
} else { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1428 |
$('#imgedit-crop-width-' + postid).val( ''); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1429 |
} |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1430 |
} else { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1431 |
var error = $( '#imgedit-crop-' + postid ).find( '.notice-error' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1432 |
if ( 'undefined' !== typeof( error ) ) { |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1433 |
error.remove(); |
5 | 1434 |
} |
0 | 1435 |
} |
1436 |
||
1437 |
this.iasapi.setSelection( sel.x1, sel.y1, sel.x2, r ); |
|
1438 |
this.iasapi.update(); |
|
1439 |
} |
|
1440 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
}, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
* Validates if a value in a jQuery.HTMLElement is numeric. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
* |
16 | 1446 |
* @since 4.6.0 |
1447 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
* @memberof imageEdit |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
* @param {jQuery} el The html element. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
* |
16 | 1452 |
* @return {void|boolean} Returns false if the value is not numeric, |
1453 |
* void when it is. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1455 |
validateNumeric: function( el ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
1456 |
if ( false === this.intval( $( el ).val() ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
$( el ).val( '' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
} |
0 | 1460 |
} |
5 | 1461 |
}; |
0 | 1462 |
})(jQuery); |