@@ -5,32 +5,31 @@ if (window.Mobilebone && Mobilebone.support) {
5
5
index_page = 0 ,
6
6
hash = location . hash . replace ( "#&" , "" ) ;
7
7
8
- if ( hash != "" && hash != "#" ) [ ] . slice . call ( pages ) . forEach ( function ( page , index ) {
9
- if ( page . id == hash ) {
8
+ [ ] . slice . call ( pages ) . forEach ( function ( page , index ) {
9
+ if ( ! page . id ) page . id = "page" + ( index + 1 ) ;
10
+
11
+ if ( hash != "" && hash != "#" && page . id == hash ) {
10
12
index_page = index ;
11
13
}
12
14
} ) ;
13
15
14
16
var prev = function ( ) {
15
- if ( index_page > 0 ) {
17
+ if ( index_page > 0 && Mobilebone . transition ( pages [ index_page - 1 ] , pages [ index_page ] , true ) !== false ) {
16
18
index_page -- ;
17
- Mobilebone . transition ( pages [ index_page ] , pages [ index_page + 1 ] , true ) ;
18
19
}
19
20
} , next = function ( ) {
20
- if ( index_page < length_page - 1 ) {
21
+ if ( index_page < length_page - 1 && Mobilebone . transition ( pages [ index_page + 1 ] , pages [ index_page ] ) !== false ) {
21
22
index_page ++ ;
22
- Mobilebone . transition ( pages [ index_page ] , pages [ index_page - 1 ] ) ;
23
23
}
24
24
} ;
25
25
26
- document . addEventListener ( "click" , function ( event ) {
26
+ /* document.addEventListener("click", function(event) {
27
27
var target = event.target;
28
28
if (target.tagName.toLowerCase() == "a" || target.getParentElementByTag("a")) return;
29
29
next();
30
- } ) ;
30
+ });*/
31
31
32
32
document . addEventListener ( "keyup" , function ( event ) {
33
- console . log ( event . keyCode ) ;
34
33
switch ( event . keyCode ) {
35
34
case 38 : case 37 : {
36
35
prev ( ) ;
@@ -57,5 +56,29 @@ if (window.Mobilebone && Mobilebone.support) {
57
56
prev ( ) ;
58
57
}
59
58
} ) ;
59
+
60
+
61
+ Mobilebone . preventdefault = function ( pagein , pageout ) {
62
+ if ( pageout == null ) return ;
63
+ var isBack = Mobilebone . isBack ( pagein , pageout ) ;
64
+ if ( isBack == true ) {
65
+ var elein = pageout . querySelector ( ".in" ) ;
66
+ if ( elein ) {
67
+ elein . style . display = "block" ;
68
+ elein . classList . remove ( "in" ) ;
69
+ elein . classList . add ( "out" ) ;
70
+ return true ;
71
+ }
72
+ } else {
73
+ var eleout = pageout . querySelector ( ".out" ) ;
74
+
75
+ if ( eleout ) {
76
+ eleout . classList . remove ( "out" ) ;
77
+ eleout . classList . add ( "in" ) ;
78
+ return true ;
79
+ }
80
+ }
81
+ } ;
82
+
60
83
} ) ( window , document ) ;
61
84
}
0 commit comments