d2bd1956ec9f9e3ce1972e2a3776d358c003482c
[framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / js / jquery.mobile.page.js
1 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2 //>>description: Basic page definition and formatting.
3 //>>label: Page Creation
4 //>>group: Core
5
6 define( [ "jquery", "./jquery.mobile.widget" ], function( $ ) {
7 //>>excludeEnd("jqmBuildExclude");
8 (function( $, undefined ) {
9
10 $.widget( "mobile.page", $.mobile.widget, {
11         options: {
12                 theme: "c",
13                 domCache: false,
14                 keepNativeDefault: ":jqmData(role='none'), :jqmData(role='nojs')"
15         },
16
17         _create: function() {
18                 
19                 var self = this;
20                 
21                 // if false is returned by the callbacks do not create the page
22                 if( self._trigger( "beforecreate" ) === false ){
23                         return false;
24                 }
25
26                 self.element
27                         .attr( "tabindex", "0" )
28                         .addClass( "ui-page ui-body-" + self.options.theme )
29                         .bind( "pagebeforehide", function(){
30                                 self.removeContainerBackground();
31                         } )
32                         .bind( "pagebeforeshow", function(){
33                                 self.setContainerBackground();
34                         } );
35
36         },
37         
38         removeContainerBackground: function(){
39                 $.mobile.pageContainer.removeClass( "ui-overlay-" + $.mobile.getInheritedTheme( this.element.parent() ) );
40         },
41         
42         // set the page container background to the page theme
43         setContainerBackground: function( theme ){
44                 if( this.options.theme ){
45                         $.mobile.pageContainer.addClass( "ui-overlay-" + ( theme || this.options.theme ) );
46                 }
47         },
48
49         keepNativeSelector: function() {
50                 var options = this.options,
51                         keepNativeDefined = options.keepNative && $.trim(options.keepNative);
52
53                 if( keepNativeDefined && options.keepNative !== options.keepNativeDefault ){
54                         return [options.keepNative, options.keepNativeDefault].join(", ");
55                 }
56
57                 return options.keepNativeDefault;
58         }
59 });
60 })( jQuery );
61 //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
62 });
63 //>>excludeEnd("jqmBuildExclude");