| 1 | function ensure_dd_helper() { |
|---|
| 2 | // Insert div that covers everything when dragging the borders |
|---|
| 3 | if ( $( "#DD-helper" ).length == 0 ) { |
|---|
| 4 | $( "<div id='DD-helper'/>" ).css( { |
|---|
| 5 | background: 'white', opacity: 0, zIndex: 9000, |
|---|
| 6 | position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' |
|---|
| 7 | } ).appendTo( "body" ).hide(); |
|---|
| 8 | } |
|---|
| 9 | } |
|---|
| 10 | |
|---|
| 11 | function make_left_panel( panel_el, center_el, border_el ) { |
|---|
| 12 | var hidden = false; |
|---|
| 13 | var saved_size = null; |
|---|
| 14 | // Functions for managing panel |
|---|
| 15 | var resize = function( x ) { |
|---|
| 16 | var oldx = x; |
|---|
| 17 | if ( x < 0 ) x = 0; |
|---|
| 18 | $( panel_el ).css( "width", x ); |
|---|
| 19 | $( border_el ).css( "left", oldx ); |
|---|
| 20 | $( center_el ).css( "left", x+7 ); |
|---|
| 21 | // ie7-recalc.js |
|---|
| 22 | if ( document.recalc ) { document.recalc() }; |
|---|
| 23 | }; |
|---|
| 24 | var toggle = function() { |
|---|
| 25 | if ( hidden ) { |
|---|
| 26 | $( border_el ).removeClass( "hover" ); |
|---|
| 27 | $( border_el).animate( {left: saved_size }, "fast" ); |
|---|
| 28 | $( panel_el ).css( "left", - saved_size ).show().animate( { "left": 0 }, "fast", function () { |
|---|
| 29 | resize( saved_size ); |
|---|
| 30 | $( border_el ).removeClass( "hidden" ); |
|---|
| 31 | }); |
|---|
| 32 | hidden = false; |
|---|
| 33 | } else { |
|---|
| 34 | saved_size = $( border_el ).position().left; |
|---|
| 35 | // Move center |
|---|
| 36 | $( center_el ).css( "left", $(border_el).innerWidth() ); |
|---|
| 37 | if ( document.recalc ) { document.recalc() }; |
|---|
| 38 | $( border_el).removeClass( "hover" ); |
|---|
| 39 | $( panel_el ).animate( { left: - saved_size }, "fast" ); |
|---|
| 40 | $( border_el ).animate( { left: -1 }, "fast", function() { |
|---|
| 41 | $( this ).addClass( "hidden" ); |
|---|
| 42 | }); |
|---|
| 43 | hidden = true; |
|---|
| 44 | } |
|---|
| 45 | }; |
|---|
| 46 | // Connect to elements |
|---|
| 47 | $( border_el ).hover( |
|---|
| 48 | function() { $( this ).addClass( "hover" ) }, |
|---|
| 49 | function() { $( this ).removeClass( "hover" ) } |
|---|
| 50 | ).bind( "dragstart", function( e ) { |
|---|
| 51 | $( '#DD-helper' ).show(); |
|---|
| 52 | }).bind( "dragend", function( e ) { |
|---|
| 53 | $( '#DD-helper' ).hide(); |
|---|
| 54 | }).bind( "drag", function( e ) { |
|---|
| 55 | x = e.offsetX; |
|---|
| 56 | // Limit range |
|---|
| 57 | x = Math.min( 400, Math.max( 100, x ) ); |
|---|
| 58 | // Resize |
|---|
| 59 | if ( hidden ) { |
|---|
| 60 | $( panel_el ).css( "left", 0 ); |
|---|
| 61 | $( border_el ).removeClass( "hidden" ); |
|---|
| 62 | hidden = false; |
|---|
| 63 | } |
|---|
| 64 | resize( x ); |
|---|
| 65 | }).bind( "dragclickonly", function( e ) { |
|---|
| 66 | toggle(); |
|---|
| 67 | }).find( "div" ).show(); |
|---|
| 68 | var force_panel = function( op ) { |
|---|
| 69 | if ( ( hidden && op == 'show' ) || ( ! hidden && op == 'hide' ) ) { |
|---|
| 70 | toggle(); |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | return { force_panel: force_panel }; |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | function make_right_panel( panel_el, center_el, border_el ) { |
|---|
| 77 | var hidden = false; |
|---|
| 78 | var hidden_by_tool = false; |
|---|
| 79 | var saved_size = null; |
|---|
| 80 | var resize = function( x ) { |
|---|
| 81 | $( panel_el ).css( "width", x ); |
|---|
| 82 | $( center_el ).css( "right", x+9 ); |
|---|
| 83 | $( border_el ).css( "right", x ).css( "left", "" ) |
|---|
| 84 | // ie7-recalc.js |
|---|
| 85 | if ( document.recalc ) { document.recalc() }; |
|---|
| 86 | }; |
|---|
| 87 | var toggle = function() { |
|---|
| 88 | if ( hidden ) { |
|---|
| 89 | $( border_el).removeClass( "hover" ); |
|---|
| 90 | $( border_el ).animate( { right: saved_size }, "fast" ); |
|---|
| 91 | $( panel_el ).css( "right", - saved_size ).show().animate( { "right": 0 }, "fast", function () { |
|---|
| 92 | resize( saved_size ); |
|---|
| 93 | $( border_el ).removeClass( "hidden" ) |
|---|
| 94 | }); |
|---|
| 95 | hidden = false; |
|---|
| 96 | } |
|---|
| 97 | else |
|---|
| 98 | { |
|---|
| 99 | saved_size = $(document).width() - $( border_el ).position().left - $(border_el).outerWidth(); |
|---|
| 100 | // Move center |
|---|
| 101 | $( center_el ).css( "right", $(border_el).innerWidth() + 1 ); |
|---|
| 102 | if ( document.recalc ) { document.recalc() }; |
|---|
| 103 | // Hide border |
|---|
| 104 | $( border_el ).removeClass( "hover" ); |
|---|
| 105 | $( panel_el ).animate( { right: - saved_size }, "fast" ); |
|---|
| 106 | $( border_el ).animate( { right: -1 }, "fast", function() { |
|---|
| 107 | $( this ).addClass( "hidden" ) |
|---|
| 108 | }); |
|---|
| 109 | hidden = true; |
|---|
| 110 | } |
|---|
| 111 | hidden_by_tool = false; |
|---|
| 112 | }; |
|---|
| 113 | var handle_minwidth_hint = function( x ) { |
|---|
| 114 | var space = $( center_el ).width() - ( hidden ? saved_size : 0 ); |
|---|
| 115 | if ( space < x ) |
|---|
| 116 | { |
|---|
| 117 | if ( ! hidden ) { |
|---|
| 118 | toggle(); |
|---|
| 119 | hidden_by_tool = true |
|---|
| 120 | } |
|---|
| 121 | } else { |
|---|
| 122 | if ( hidden_by_tool ) { |
|---|
| 123 | toggle(); |
|---|
| 124 | hidden_by_tool = false; |
|---|
| 125 | } |
|---|
| 126 | } |
|---|
| 127 | }; |
|---|
| 128 | $( border_el ).hover( |
|---|
| 129 | function() { $( this ).addClass( "hover" ) }, |
|---|
| 130 | function() { $( this ).removeClass( "hover" ) } |
|---|
| 131 | ).bind( "dragstart", function( e ) { |
|---|
| 132 | $( '#DD-helper' ).show(); |
|---|
| 133 | }).bind( "dragend", function( e ) { |
|---|
| 134 | $( '#DD-helper' ).hide(); |
|---|
| 135 | }).bind( "drag", function( e ) { |
|---|
| 136 | x = e.offsetX; |
|---|
| 137 | w = $(window).width(); |
|---|
| 138 | // Limit range |
|---|
| 139 | x = Math.min( w - 100, x ); |
|---|
| 140 | x = Math.max( w - 400, x ); |
|---|
| 141 | // Resize |
|---|
| 142 | if ( hidden ) { |
|---|
| 143 | $( panel_el ).css( "right", 0 ); |
|---|
| 144 | $( border_el ).removeClass( "hidden" ); |
|---|
| 145 | hidden = false; |
|---|
| 146 | } |
|---|
| 147 | resize( w - x - $(this).outerWidth() ); |
|---|
| 148 | }).bind( "dragclickonly", function( e ) { |
|---|
| 149 | toggle(); |
|---|
| 150 | }).find( "div" ).show(); |
|---|
| 151 | var force_panel = function( op ) { |
|---|
| 152 | if ( ( hidden && op == 'show' ) || ( ! hidden && op == 'hide' ) ) { |
|---|
| 153 | toggle(); |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | return { handle_minwidth_hint: handle_minwidth_hint, force_panel: force_panel }; |
|---|
| 157 | }; |
|---|
| 158 | |
|---|
| 159 | // Modal dialog boxes |
|---|
| 160 | |
|---|
| 161 | function hide_modal() { |
|---|
| 162 | $(".dialog-box-container" ).fadeOut( function() { |
|---|
| 163 | $("#overlay").hide(); |
|---|
| 164 | $( ".dialog-box" ).find( ".body" ).children().remove(); |
|---|
| 165 | } ); |
|---|
| 166 | }; |
|---|
| 167 | |
|---|
| 168 | function show_modal( title, body, buttons, extra_buttons, init_fn ) { |
|---|
| 169 | if ( title ) { |
|---|
| 170 | $( ".dialog-box" ).find( ".title" ).html( title ); |
|---|
| 171 | $( ".dialog-box" ).find( ".unified-panel-header" ).show(); |
|---|
| 172 | } else { |
|---|
| 173 | $( ".dialog-box" ).find( ".unified-panel-header" ).hide(); |
|---|
| 174 | } |
|---|
| 175 | var b = $( ".dialog-box" ).find( ".buttons" ).html( "" ); |
|---|
| 176 | if ( buttons ) { |
|---|
| 177 | $.each( buttons, function( name, value ) { |
|---|
| 178 | b.append( $( '<button/>' ).text( name ).click( value ) ); |
|---|
| 179 | b.append( " " ); |
|---|
| 180 | }); |
|---|
| 181 | b.show(); |
|---|
| 182 | } else { |
|---|
| 183 | b.hide(); |
|---|
| 184 | } |
|---|
| 185 | var b = $( ".dialog-box" ).find( ".extra_buttons" ).html( "" ); |
|---|
| 186 | if ( extra_buttons ) { |
|---|
| 187 | $.each( extra_buttons, function( name, value ) { |
|---|
| 188 | b.append( $( '<button/>' ).text( name ).click( value ) ); |
|---|
| 189 | b.append( " " ); |
|---|
| 190 | }); |
|---|
| 191 | b.show(); |
|---|
| 192 | } else { |
|---|
| 193 | b.hide(); |
|---|
| 194 | } |
|---|
| 195 | if ( body == "progress" ) { |
|---|
| 196 | body = $("<img/>").attr("src", image_path + "/yui/rel_interstitial_loading.gif"); |
|---|
| 197 | } |
|---|
| 198 | $( ".dialog-box" ).find( ".body" ).html( body ); |
|---|
| 199 | if ( ! $(".dialog-box-container").is( ":visible" ) ) { |
|---|
| 200 | $("#overlay").show(); |
|---|
| 201 | $(".dialog-box-container").fadeIn() |
|---|
| 202 | } |
|---|
| 203 | if ( init_fn ) { |
|---|
| 204 | init_fn(); |
|---|
| 205 | } |
|---|
| 206 | }; |
|---|
| 207 | |
|---|
| 208 | function show_in_overlay( options ) { |
|---|
| 209 | var width = options.width || '600'; |
|---|
| 210 | var height = options.height || '400'; |
|---|
| 211 | var scroll = options.scroll || 'auto'; |
|---|
| 212 | $("#overlay-background").bind( "click.overlay", function() { |
|---|
| 213 | hide_modal(); |
|---|
| 214 | $("#overlay-background").unbind( "click.overlay" ); |
|---|
| 215 | }); |
|---|
| 216 | show_modal( null, $("<div style='margin: -5px;'><img id='close_button' style='position:absolute;right:-17px;top:-15px;' src='../images/closebox.png'><iframe style='margin: 0; padding: 0;' src='" + options.url + "' width='" + width + "' height='" + height + "' scrolling='" + scroll + "' frameborder='0'></iframe></div>" ) ); |
|---|
| 217 | $("#close_button").bind( "click", function() { hide_modal() } ); |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| 220 | // Tab management |
|---|
| 221 | |
|---|
| 222 | $(function() { |
|---|
| 223 | $(".tab").each( function() { |
|---|
| 224 | var submenu = $(this).children( ".submenu" ); |
|---|
| 225 | if ( submenu.length > 0 ) { |
|---|
| 226 | if ( $.browser.msie ) { |
|---|
| 227 | // Vile IE iframe hack -- even IE7 needs this |
|---|
| 228 | submenu.prepend( "<iframe style=\"position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; filter:Alpha(Opacity='0');\"></iframe>" ); |
|---|
| 229 | } |
|---|
| 230 | $(this).hover( function() { submenu.show(); }, function() { submenu.hide(); } ); |
|---|
| 231 | submenu.click( function() { submenu.hide(); } ); |
|---|
| 232 | } |
|---|
| 233 | }); |
|---|
| 234 | }); |
|---|
| 235 | |
|---|
| 236 | function user_changed( user_email, is_admin ) { |
|---|
| 237 | if ( user_email ) { |
|---|
| 238 | $(".loggedin-only").show(); |
|---|
| 239 | $(".loggedout-only").hide(); |
|---|
| 240 | $("#user-email").text( user_email ); |
|---|
| 241 | if ( is_admin ) { |
|---|
| 242 | $(".admin-only").show(); |
|---|
| 243 | } |
|---|
| 244 | } else { |
|---|
| 245 | $(".loggedin-only").hide(); |
|---|
| 246 | $(".loggedout-only").show(); |
|---|
| 247 | $(".admin-only").hide(); |
|---|
| 248 | } |
|---|
| 249 | } |
|---|