Show More
@@ -661,12 +661,6 define([ | |||||
661 | .width(width) |
|
661 | .width(width) | |
662 | .height(height); |
|
662 | .height(height); | |
663 |
|
663 | |||
664 | // The jQuery resize handlers don't seem to work on the svg element. |
|
|||
665 | // When the svg renders completely, measure it's size and set the parent |
|
|||
666 | // div to that size. Then set the svg to 100% the size of the parent |
|
|||
667 | // div and make the parent div resizable. |
|
|||
668 | this._dblclick_to_reset_size(svg_area, true, false); |
|
|||
669 |
|
||||
670 | svg_area.append(svg); |
|
664 | svg_area.append(svg); | |
671 | toinsert.append(svg_area); |
|
665 | toinsert.append(svg_area); | |
672 | element.append(toinsert); |
|
666 | element.append(toinsert); | |
@@ -674,46 +668,6 define([ | |||||
674 | return toinsert; |
|
668 | return toinsert; | |
675 | }; |
|
669 | }; | |
676 |
|
670 | |||
677 | OutputArea.prototype._dblclick_to_reset_size = function (img, immediately, resize_parent) { |
|
|||
678 | /** |
|
|||
679 | * Add a resize handler to an element |
|
|||
680 | * |
|
|||
681 | * img: jQuery element |
|
|||
682 | * immediately: bool=False |
|
|||
683 | * Wait for the element to load before creating the handle. |
|
|||
684 | * resize_parent: bool=True |
|
|||
685 | * Should the parent of the element be resized when the element is |
|
|||
686 | * reset (by double click). |
|
|||
687 | */ |
|
|||
688 | var callback = function (){ |
|
|||
689 | var h0 = img.height(); |
|
|||
690 | var w0 = img.width(); |
|
|||
691 | if (!(h0 && w0)) { |
|
|||
692 | // zero size, don't make it resizable |
|
|||
693 | return; |
|
|||
694 | } |
|
|||
695 | img.resizable({ |
|
|||
696 | aspectRatio: true, |
|
|||
697 | autoHide: true |
|
|||
698 | }); |
|
|||
699 | img.dblclick(function () { |
|
|||
700 | // resize wrapper & image together for some reason: |
|
|||
701 | img.height(h0); |
|
|||
702 | img.width(w0); |
|
|||
703 | if (resize_parent === undefined || resize_parent) { |
|
|||
704 | img.parent().height(h0); |
|
|||
705 | img.parent().width(w0); |
|
|||
706 | } |
|
|||
707 | }); |
|
|||
708 | }; |
|
|||
709 |
|
||||
710 | if (immediately) { |
|
|||
711 | callback(); |
|
|||
712 | } else { |
|
|||
713 | img.on("load", callback); |
|
|||
714 | } |
|
|||
715 | }; |
|
|||
716 |
|
||||
717 | var set_width_height = function (img, md, mime) { |
|
671 | var set_width_height = function (img, md, mime) { | |
718 | /** |
|
672 | /** | |
719 | * set width and height of an img element from metadata |
|
673 | * set width and height of an img element from metadata | |
@@ -735,7 +689,6 define([ | |||||
735 | } |
|
689 | } | |
736 | img[0].src = 'data:image/png;base64,'+ png; |
|
690 | img[0].src = 'data:image/png;base64,'+ png; | |
737 | set_width_height(img, md, 'image/png'); |
|
691 | set_width_height(img, md, 'image/png'); | |
738 | this._dblclick_to_reset_size(img); |
|
|||
739 | toinsert.append(img); |
|
692 | toinsert.append(img); | |
740 | element.append(toinsert); |
|
693 | element.append(toinsert); | |
741 | return toinsert; |
|
694 | return toinsert; | |
@@ -753,7 +706,6 define([ | |||||
753 | } |
|
706 | } | |
754 | img[0].src = 'data:image/jpeg;base64,'+ jpeg; |
|
707 | img[0].src = 'data:image/jpeg;base64,'+ jpeg; | |
755 | set_width_height(img, md, 'image/jpeg'); |
|
708 | set_width_height(img, md, 'image/jpeg'); | |
756 | this._dblclick_to_reset_size(img); |
|
|||
757 | toinsert.append(img); |
|
709 | toinsert.append(img); | |
758 | element.append(toinsert); |
|
710 | element.append(toinsert); | |
759 | return toinsert; |
|
711 | return toinsert; |
General Comments 0
You need to be logged in to leave comments.
Login now