!function( exports, $ ){ "use strict" var ensure_dd_helper = function () { // Insert div that covers everything when dragging the borders if ( $( "#DD-helper" ).length == 0 ) { $( "
" ).appendTo( "body" ).hide(); } } // Panels var MIN_PANEL_WIDTH = 160, MAX_PANEL_WIDTH = 800; var Panel = function( options ) { this.$panel = options.panel; this.$center = options.center; this.$drag = options.drag; this.$toggle = options.toggle; this.left = !options.right; this.hidden = false; this.hidden_by_tool = false; this.saved_size = null; this.init(); } $.extend( Panel.prototype, { resize: function( x ) { this.$panel.css( "width", x ); if ( this.left ) { this.$center.css( "left", x ); } else { this.$center.css( "right", x ); } // ie7-recalc.js if ( document.recalc ) { document.recalc(); } }, do_toggle: function() { var self = this; if ( this.hidden ) { this.$toggle.removeClass( "hidden" ); if ( this.left ) { this.$panel.css( "left", - this.saved_size ).show().animate( { "left": 0 }, "fast", function () { self.resize( self.saved_size ); }); } else { this.$panel.css( "right", - this.saved_size ).show().animate( { "right": 0 }, "fast", function () { self.resize( self.saved_size ); }); } self.hidden = false; } else { self.saved_size = this.$panel.width(); if ( document.recalc ) { document.recalc(); } // Hide border if ( this.left ) { this.$panel.animate( { left: - this.saved_size }, "fast" ); } else { this.$panel.animate( { right: - this.saved_size }, "fast" ); } // self.resize(0); if ( this.left ) { this.$center.css( "left", 0 ); } else { this.$center.css( "right", 0 ); } self.hidden = true; self.$toggle.addClass( "hidden" ); } this.hidden_by_tool = false; }, handle_minwidth_hint: function( x ) { var space = this.$center.width() - ( this.hidden ? this.saved_size : 0 ); if ( space < x ) { if ( ! this.hidden ) { this.do_toggle(); this.hidden_by_tool = true; } } else { if ( this.hidden_by_tool ) { this.do_toggle(); this.hidden_by_tool = false; } } }, force_panel: function( op ) { if ( ( this.hidden && op == 'show' ) || ( ! this.hidden && op == 'hide' ) ) { this.do_toggle(); } }, init: function() { var self = this, prevX; // Pull the collapse element out to body level so it is visible when panel is hidden self.$toggle.remove().appendTo( "body" ); // Hide/show using toggle element self.$toggle.on( "click", function() { self.do_toggle(); } ); // Resizing using drag element function move( e ){ var delta = e.pageX - prevX; prevX = e.pageX; var oldWidth = self.$panel.width(), newWidth = ( self.left )?( oldWidth + delta ):( oldWidth - delta ); // Limit range newWidth = Math.min( MAX_PANEL_WIDTH, Math.max( MIN_PANEL_WIDTH, newWidth ) ); self.resize( newWidth ); } this.$drag.on( "mousedown", function( e ) { prevX = e.pageX; $( '#DD-helper' ).show() .on( 'mousemove', move ) .one( 'mouseup', function( e ){ $( this ).hide().off( 'mousemove', move ); }); }); } }); // Modal dialog boxes var Modal = function( options ) { this.$overlay = options.overlay; this.$dialog = options.dialog; this.$header = this.$dialog.find( ".modal-header" ); this.$body = this.$dialog.find( ".modal-body" ); this.$footer = this.$dialog.find( ".modal-footer" ); this.$backdrop = options.backdrop; // Close button this.$header.find( ".close" ).on( "click", $.proxy( this.hide, this ) ); } $.extend( Modal.prototype, { setContent: function( options ) { this.$header.hide(); // Title if ( options.title ) { this.$header.find( ".title" ).html( options.title ); this.$header.show(); } if ( options.closeButton ) { this.$header.find( ".close" ).show(); this.$header.show(); } else { this.$header.find( ".close" ).hide(); } // Buttons this.$footer.hide(); var $buttons = this.$footer.find( ".buttons" ).html( "" ); if ( options.buttons ) { $.each( options.buttons, function( name, value ) { $buttons.append( $( ' ' ).text( name ).click( value ) ).append( " " ); }); this.$footer.show(); } var $extraButtons = this.$footer.find( ".extra_buttons" ).html( "" ); if ( options.extra_buttons ) { $.each( options.extra_buttons, function( name, value ) { $extraButtons.append( $( '' ).text( name ).click( value ) ).append( " " ); }); this.$footer.show(); } // Body var body = options.body; if ( body == "progress" ) { body = $("