Show More
@@ -280,33 +280,37 var IPython = (function (IPython) { | |||||
280 | }; |
|
280 | }; | |
281 |
|
281 | |||
282 |
|
282 | |||
283 |
OutputArea.prototype. |
|
283 | OutputArea.prototype._dblclick_to_reset_size = function (img) { | |
284 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_png"); |
|
284 | // schedule wrapping image in resizable after a delay, | |
285 | var img = $("<img/>").attr('src','data:image/png;base64,'+png); |
|
285 | // so we don't end up calling resize on a zero-size object | |
|
286 | var that = this; | |||
286 | setTimeout(function () { |
|
287 | setTimeout(function () { | |
|
288 | var h0 = img.height(); | |||
|
289 | var w0 = img.width(); | |||
|
290 | if (!(h0 && w0)) { | |||
|
291 | // zero size, schedule another timeout | |||
|
292 | that._dblclick_to_reset_size(img); | |||
|
293 | return | |||
|
294 | } | |||
287 | img.resizable({ |
|
295 | img.resizable({ | |
288 | aspectRatio: true, |
|
296 | aspectRatio: true, | |
289 |
autoHide: true |
|
297 | autoHide: true | |
290 | start: function(evt, ui) { |
|
298 | }); | |
291 | var wrapper = $(evt.target); |
|
299 | img.dblclick(function () { | |
292 | var original_height = ui.originalSize.height; |
|
300 | // resize wrapper & image together for some reason: | |
293 | var original_width = ui.originalSize.width; |
|
301 | img.parent().height(h0); | |
294 | if (original_height == 0 || original_width == 0) { |
|
302 | img.height(h0); | |
295 | // protect against weird case of zero size; |
|
303 | img.parent().width(w0); | |
296 | return; |
|
304 | img.width(w0); | |
297 | } |
|
|||
298 | // only do this once: |
|
|||
299 | wrapper.unbind("resizestart"); |
|
|||
300 | wrapper.dblclick(function () { |
|
|||
301 | // resize wrapper & image together for some reason: |
|
|||
302 | wrapper.height(original_height); |
|
|||
303 | img.height(original_height); |
|
|||
304 | wrapper.width(original_width); |
|
|||
305 | img.width(original_width); |
|
|||
306 | }); |
|
|||
307 | } |
|
|||
308 | }); |
|
305 | }); | |
309 | }, 250); |
|
306 | }, 250); | |
|
307 | } | |||
|
308 | ||||
|
309 | ||||
|
310 | OutputArea.prototype.append_png = function (png, element) { | |||
|
311 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_png"); | |||
|
312 | var img = $("<img/>").attr('src','data:image/png;base64,'+png); | |||
|
313 | this._dblclick_to_reset_size(img); | |||
310 | toinsert.append(img); |
|
314 | toinsert.append(img); | |
311 | element.append(toinsert); |
|
315 | element.append(toinsert); | |
312 | }; |
|
316 | }; | |
@@ -315,30 +319,7 var IPython = (function (IPython) { | |||||
315 | OutputArea.prototype.append_jpeg = function (jpeg, element) { |
|
319 | OutputArea.prototype.append_jpeg = function (jpeg, element) { | |
316 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_jpeg"); |
|
320 | var toinsert = $("<div/>").addClass("box-flex1 output_subarea output_jpeg"); | |
317 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); |
|
321 | var img = $("<img/>").attr('src','data:image/jpeg;base64,'+jpeg); | |
318 | setTimeout(function () { |
|
322 | this._dblclick_to_reset_size(img); | |
319 | img.resizable({ |
|
|||
320 | aspectRatio: true, |
|
|||
321 | autoHide: true, |
|
|||
322 | start: function(evt, ui) { |
|
|||
323 | var wrapper = $(evt.target); |
|
|||
324 | var original_height = ui.originalSize.height; |
|
|||
325 | var original_width = ui.originalSize.width; |
|
|||
326 | if (original_height == 0 || original_width == 0) { |
|
|||
327 | // protect against weird case of zero size; |
|
|||
328 | return; |
|
|||
329 | } |
|
|||
330 | // only do this once: |
|
|||
331 | wrapper.unbind("resizestart"); |
|
|||
332 | wrapper.dblclick(function () { |
|
|||
333 | // resize wrapper & image together for some reason: |
|
|||
334 | wrapper.height(original_height); |
|
|||
335 | img.height(original_height); |
|
|||
336 | wrapper.width(original_width); |
|
|||
337 | img.width(original_width); |
|
|||
338 | }); |
|
|||
339 | } |
|
|||
340 | }); |
|
|||
341 | }, 250); |
|
|||
342 | toinsert.append(img); |
|
323 | toinsert.append(img); | |
343 | element.append(toinsert); |
|
324 | element.append(toinsert); | |
344 | }; |
|
325 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now