1 // ========================================================================== 2 // Project: SproutCore - JavaScript Application Framework 3 // Copyright: ©2006-2011 Strobe Inc. and contributors. 4 // Portions ©2008-2011 Apple Inc. All rights reserved. 5 // License: Licensed under MIT license (see license.js) 6 // ========================================================================== 7 8 sc_require('panes/pane'); 9 sc_require('panes/keyboard'); 10 sc_require('panes/layout'); 11 sc_require('panes/manipulation'); 12 sc_require('panes/pane_statechart'); 13 14 /** @class 15 16 Most SproutCore applications have a main pane, which dominates the 17 application page. You can extend from this view to implement your own main 18 pane. This class will automatically make itself main whenever you append it 19 to a document, removing any other main pane that might be currently in 20 place. If you do have another already focused as the keyPane, this view 21 will also make itself key automatically. The default way to use the main 22 pane is to simply add it to your page like this: 23 24 SC.MainPane.create().append(); 25 26 This will cause your root view to display. The default layout for a 27 MainPane is to cover the entire document window and to resize with the 28 window. 29 30 @extends SC.Pane 31 @since SproutCore 1.0 32 */ 33 SC.MainPane = SC.Pane.extend({ 34 /** @private */ 35 layout: { minHeight: 200, minWidth: 200 }, 36 37 /** 38 Called when the pane is attached. Takes on main pane status. 39 */ 40 didAppendToDocument: function () { 41 var responder = this.rootResponder; 42 43 responder.makeMainPane(this); 44 this.becomeKeyPane(); 45 46 // Update the body overflow on attach. 47 this.setBodyOverflowIfNeeded(); 48 }, 49 50 /** 51 Called when the pane is detached. Resigns main pane status. 52 */ 53 willRemoveFromDocument: function () { 54 var responder = this.rootResponder; 55 56 // Stop controlling the body overflow on detach. 57 this.unsetBodyOverflowIfNeeded(); 58 59 responder.makeMainPane(null); 60 this.resignKeyPane(); 61 }, 62 63 /** @private The 'updatedLayout' event. */ 64 _updatedLayout: function () { 65 sc_super(); 66 67 // If by chance the minHeight or minWidth changed we would need to alter the body overflow request. 68 this.setBodyOverflowIfNeeded(); 69 }, 70 71 /** @private */ 72 acceptsKeyPane: YES, 73 74 /** @private */ 75 classNames: ['sc-main'] 76 }); 77