|
105 | 105 | } |
106 | 106 |
|
107 | 107 | function updateResizeSettings() { |
108 | | - if (jQuery('#tinypng_sizes_0').prop('checked')) { |
| 108 | + if (propOf('#tinypng_sizes_0', 'checked')) { |
109 | 109 | jQuery('.tiny-resize-available').show() |
110 | 110 | jQuery('.tiny-resize-unavailable').hide() |
111 | 111 | } else { |
112 | 112 | jQuery('.tiny-resize-available').hide() |
113 | 113 | jQuery('.tiny-resize-unavailable').show() |
114 | 114 | } |
115 | 115 |
|
116 | | - var original_enabled = jQuery('#tinypng_resize_original_enabled').prop('checked') |
| 116 | + var original_enabled = propOf('#tinypng_resize_original_enabled', 'checked') |
117 | 117 | jQuery('#tinypng_resize_original_width, #tinypng_resize_original_height').each(function (i, el) { |
118 | 118 | el.disabled = !original_enabled |
119 | 119 | }) |
120 | 120 | } |
121 | 121 |
|
122 | 122 | function updatePreserveSettings() { |
123 | | - if (jQuery('#tinypng_sizes_0').prop('checked')) { |
| 123 | + if (propOf('#tinypng_sizes_0', 'checked')) { |
124 | 124 | jQuery('.tiny-preserve').show() |
125 | 125 | } else { |
126 | 126 | jQuery('.tiny-preserve').hide() |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 |
|
| 151 | + function propOf(selector, property) { |
| 152 | + if (typeof jQuery.fn.prop === 'function') { |
| 153 | + /* Added in 1.6. Before jQuery 1.6, the .attr() method sometimes took |
| 154 | + property values into account. */ |
| 155 | + return jQuery(selector).prop(property) |
| 156 | + } else { |
| 157 | + return jQuery(selector).attr(property) |
| 158 | + } |
| 159 | + } |
| 160 | + |
| 161 | + function setPropOf(selector, property, value) { |
| 162 | + if (typeof jQuery.fn.prop === 'function') { |
| 163 | + /* Added in 1.6. Before jQuery 1.6, the .attr() method sometimes took |
| 164 | + property values into account. */ |
| 165 | + jQuery(selector).prop(property, value) |
| 166 | + } else { |
| 167 | + jQuery(selector).attr(property, value) |
| 168 | + } |
| 169 | + } |
| 170 | + |
151 | 171 | function changeEnterKeyTarget(selector, button) { |
152 | 172 | eventOn('keyup keypress', selector, function(event) { |
153 | 173 | var code = event.keyCode || event.which |
|
162 | 182 | case 'upload-php': |
163 | 183 | eventOn('click', 'button.tiny-compress', compressImage) |
164 | 184 |
|
165 | | - if (typeof jQuery.fn.prop === 'function') { |
166 | | - jQuery('button.tiny-compress').prop('disabled', null) |
167 | | - } else { |
168 | | - jQuery('button.tiny-compress').attr('disabled', null) |
169 | | - } |
| 185 | + setPropOf('button.tiny-compress', 'disabled', null) |
170 | 186 |
|
171 | 187 | jQuery('<option>').val('tiny_bulk_action').text(tinyCompress.L10nBulkAction).appendTo('select[name=action]') |
172 | 188 | jQuery('<option>').val('tiny_bulk_action').text(tinyCompress.L10nBulkAction).appendTo('select[name=action2]') |
|
188 | 204 | }) |
189 | 205 | } |
190 | 206 |
|
191 | | - jQuery('input[name*=tinypng_sizes], input#tinypng_resize_original_enabled').on('click', function() { |
| 207 | + eventOn('click', 'input[name*=tinypng_sizes], #tinypng_resize_original_enabled', function() { |
192 | 208 | /* Unfortunately, we need some additional information to display |
193 | 209 | the correct notice. */ |
194 | 210 | totalSelectedSizes = jQuery('input[name*=tinypng_sizes]:checked').length |
195 | 211 | var image_count_url = ajaxurl + '?action=tiny_image_sizes_notice&image_sizes_selected=' + totalSelectedSizes |
196 | | - if (jQuery('input#tinypng_resize_original_enabled').prop('checked') && jQuery('input#tinypng_sizes_0').prop('checked')) { |
| 212 | + if (propOf('#tinypng_resize_original_enabled', 'checked') && propOf('#tinypng_sizes_0', 'checked')) { |
197 | 213 | image_count_url += '&resize_original=true' |
198 | 214 | } |
199 | 215 | jQuery('#tiny-image-sizes-notice').load(image_count_url) |
|
0 commit comments