Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -936,7 +936,6 @@ |
937 | 937 | }); |
938 | 938 | }, |
939 | 939 | dialog: { |
940 | | - width: 550, // FIXME: autoresize width |
941 | 940 | buttons: { |
942 | 941 | 'edittoolbar-tool-link-insert': function() { |
943 | 942 | function escapeInternalText( s ) { |
— | — | @@ -1069,7 +1068,6 @@ |
1070 | 1069 | $j( '#edittoolbar-table-dimensions-columns' ).val( 2 ); |
1071 | 1070 | }, |
1072 | 1071 | dialog: { |
1073 | | - width: 350, // FIXME: autoresize |
1074 | 1072 | buttons: { |
1075 | 1073 | 'edittoolbar-tool-table-insert': function() { |
1076 | 1074 | var rows = parseInt( $j( '#edittoolbar-table-dimensions-rows' ).val() ); |
— | — | @@ -1139,7 +1137,6 @@ |
1140 | 1138 | }); |
1141 | 1139 | }, |
1142 | 1140 | dialog: { |
1143 | | - width: 350, // FIXME: autoresize width |
1144 | 1141 | buttons: { |
1145 | 1142 | 'edittoolbar-tool-replace-button': function() { |
1146 | 1143 | var searchStr = $j( '#edittoolbar-replace-search' ).val(); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.dialogs.js |
— | — | @@ -67,9 +67,51 @@ |
68 | 68 | .data( 'context', context ) |
69 | 69 | .appendTo( $( 'body' ) ) |
70 | 70 | .each( module.init ) |
71 | | - .dialog( configuration ); |
| 71 | + .dialog( configuration ) |
| 72 | + .bind( 'dialogopen', $.wikiEditor.modules.dialogs.fn.resize ) |
| 73 | + .find( '.ui-tabs' ).bind( 'tabsshow', function() { |
| 74 | + $(this).closest( '.ui-dialog-content' ).each( |
| 75 | + $.wikiEditor.modules.dialogs.fn.resize ); |
| 76 | + }); |
72 | 77 | } |
73 | 78 | } |
| 79 | + }, |
| 80 | + |
| 81 | + /** |
| 82 | + * Resize a dialog so its contents fit |
| 83 | + * |
| 84 | + * Usage: dialog.each( resize ); or dialog.bind( 'blah', resize ); |
| 85 | + */ |
| 86 | + resize: function() { |
| 87 | + var wrapper = $(this).closest( '.ui-dialog' ); |
| 88 | + // Make sure elements don't wrapped so we get an accurate idea |
| 89 | + // of whether they really fit. Also temporarily show hidden |
| 90 | + // elements. |
| 91 | + |
| 92 | + // Work around jQuery bug where <div style="display:inline;" /> |
| 93 | + // inside a dialog is both :visible and :hidden |
| 94 | + var oldHidden = $(this).find( '*' ).not( ':visible' ); |
| 95 | + |
| 96 | + // Save the style attributes of the hidden elements to restore |
| 97 | + // them later. Calling hide() after show() messes up for |
| 98 | + // elements hidden with a class |
| 99 | + oldHidden.each( function() { |
| 100 | + $(this).data( 'oldstyle', $(this).attr( 'style' ) ); |
| 101 | + }); |
| 102 | + oldHidden.show(); |
| 103 | + var oldWS = $(this).css( 'white-space' ); |
| 104 | + $(this).css( 'white-space', 'nowrap' ); |
| 105 | + |
| 106 | + if ( wrapper.width() <= $(this).get(0).scrollWidth ) { |
| 107 | + $(this).width( $(this).get(0).scrollWidth ); |
| 108 | + wrapper.width( wrapper.get(0).scrollWidth ); |
| 109 | + $(this).dialog( { 'width': wrapper.width() } ); |
| 110 | + } |
| 111 | + |
| 112 | + $(this).css( 'white-space', oldWS ); |
| 113 | + oldHidden.each( function() { |
| 114 | + $(this).attr( 'style', $(this).data( 'oldstyle' ) ); |
| 115 | + }); |
74 | 116 | } |
75 | 117 | }, |
76 | 118 | 'modules': {} |