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