|
4 | 4 | * Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses. |
5 | 5 | * Note: Code is in draft form and is subject to change |
6 | 6 | */ |
7 | | -(function($, undefined ) { |
| 7 | +( function( $, undefined ) { |
8 | 8 | $.widget( "mobile.dialog", $.mobile.widget, { |
9 | 9 | options: { |
10 | 10 | closeBtnText: "Close" |
11 | 11 | }, |
12 | | - _create: function(){ |
| 12 | + _create: function() { |
13 | 13 | var self = this, |
14 | 14 | $el = self.element; |
15 | 15 |
|
16 | 16 | /* class the markup for dialog styling */ |
17 | 17 | this.element |
18 | 18 | //add ARIA role |
19 | | - .attr("role","dialog") |
20 | | - .addClass('ui-page ui-dialog ui-body-a') |
| 19 | + .attr( "role", "dialog" ) |
| 20 | + .addClass( "ui-page ui-dialog ui-body-a" ) |
21 | 21 | .find( ":jqmData(role=header)" ) |
22 | | - .addClass('ui-corner-top ui-overlay-shadow') |
| 22 | + .addClass( "ui-corner-top ui-overlay-shadow" ) |
23 | 23 | .prepend( "<a href='#' data-" + $.mobile.ns + "icon='delete' data-" + $.mobile.ns + "rel='back' data-" + $.mobile.ns + "iconpos='notext'>"+ this.options.closeBtnText +"</a>" ) |
24 | 24 | .end() |
25 | | - .find('.ui-content:not([class*="ui-body-"])') |
26 | | - .addClass('ui-body-c') |
| 25 | + .find( '.ui-content:not([class*="ui-body-"])' ) |
| 26 | + .addClass( 'ui-body-c' ) |
27 | 27 | .end() |
28 | 28 | .find( ".ui-content,:jqmData(role='footer')" ) |
29 | 29 | .last() |
30 | | - .addClass('ui-corner-bottom ui-overlay-shadow'); |
| 30 | + .addClass( "ui-corner-bottom ui-overlay-shadow" ); |
31 | 31 |
|
32 | 32 | /* bind events |
33 | 33 | - clicks and submits should use the closing transition that the dialog opened with |
34 | 34 | unless a data-transition is specified on the link/form |
35 | 35 | - if the click was on the close button, or the link has a data-rel="back" it'll go back in history naturally |
36 | 36 | */ |
37 | | - this.element |
38 | | - .bind( "vclick submit", function(e){ |
39 | | - var $targetel; |
| 37 | + this.element |
| 38 | + .bind( "vclick submit", function( e ) { |
| 39 | + var $target; |
40 | 40 | if( e.type == "vclick" ){ |
41 | | - $targetel = $(e.target).closest("a"); |
| 41 | + $target = $( e.target ).closest( "a" ); |
42 | 42 | } |
43 | 43 | else{ |
44 | | - $targetel = $(e.target).closest("form"); |
| 44 | + $target = $( e.target ).closest( "form" ); |
45 | 45 | } |
46 | 46 |
|
47 | | - if( $targetel.length && !$targetel.jqmData("transition") ){ |
48 | | - $targetel |
49 | | - .attr("data-" + $.mobile.ns + "transition", $.mobile.urlHistory.getActive().transition ) |
50 | | - .attr("data-" + $.mobile.ns + "direction", "reverse"); |
| 47 | + if( $target.length && !$target.jqmData( "transition" ) ){ |
| 48 | + $target |
| 49 | + .attr( "data-" + $.mobile.ns + "transition", $.mobile.urlHistory.getActive().transition ) |
| 50 | + .attr( "data-" + $.mobile.ns + "direction", "reverse" ); |
51 | 51 | } |
52 | 52 | }); |
53 | | - |
54 | 53 | }, |
55 | 54 |
|
56 | 55 | //close method goes back in history |
57 | | - close: function(){ |
| 56 | + close: function() { |
58 | 57 | window.history.back(); |
59 | 58 | } |
60 | 59 | }); |
|
0 commit comments