@@ -2578,58 +2578,6 @@ define("../cardkit/render", [
2578
2578
2579
2579
} ) ;
2580
2580
2581
- /* @source ../cardkit/pagesession.js */ ;
2582
-
2583
-
2584
- define ( "../cardkit/pagesession" , [
2585
- "mo/lang"
2586
- ] , function ( ) {
2587
-
2588
- var exports = {
2589
-
2590
- init : function ( ) {
2591
- this . name = 'ck_ss' ;
2592
- if ( sessionStorage [ this . name ] ) {
2593
- this . list = JSON . parse ( sessionStorage [ this . name ] ) ;
2594
- } else {
2595
- this . reset ( ) ;
2596
- }
2597
- } ,
2598
-
2599
- reset : function ( ) {
2600
- this . list = [ ] ;
2601
- this . save ( ) ;
2602
- } ,
2603
-
2604
- save : function ( ) {
2605
- sessionStorage [ this . name ] = JSON . stringify ( this . list ) ;
2606
- } ,
2607
-
2608
- indexOf : function ( url ) {
2609
- var n = this . list . map ( function ( item ) {
2610
- return item [ 0 ] ;
2611
- } ) . indexOf ( url ) ;
2612
- return ( n === - 1 || this . list [ n ] [ 1 ] < history . length ) ? n : - 1 ;
2613
- } ,
2614
-
2615
- push : function ( url ) {
2616
- this . list . push ( [ url , history . length ] ) ;
2617
- this . save ( ) ;
2618
- } ,
2619
-
2620
- clear : function ( n ) {
2621
- if ( n !== - 1 ) {
2622
- this . list = this . list . slice ( 0 , n + 2 ) ;
2623
- this . save ( ) ;
2624
- }
2625
- }
2626
-
2627
- } ;
2628
-
2629
- return exports ;
2630
-
2631
- } ) ;
2632
-
2633
2581
/* @source eventmaster.js */ ;
2634
2582
2635
2583
/**
@@ -6515,6 +6463,7 @@ define('soviet', [
6515
6463
define ( "../cardkit/app" , [
6516
6464
"dollar" ,
6517
6465
"mo/lang" ,
6466
+ "mo/browsers" ,
6518
6467
"mo/template" ,
6519
6468
"soviet" ,
6520
6469
"choreo" ,
@@ -6531,21 +6480,22 @@ define("../cardkit/app", [
6531
6480
"../cardkit/view/growl" ,
6532
6481
"../cardkit/view/slidelist" ,
6533
6482
"../cardkit/bus" ,
6534
- "../cardkit/pagesession" ,
6535
6483
"../cardkit/render" ,
6536
6484
"mo/domready"
6537
- ] , function ( $ , _ , tpl , soviet , choreo ,
6485
+ ] , function ( $ , _ , tpl , browsers , soviet , choreo ,
6538
6486
momoBase , momoTap , momoSwipe , momoDrag , momoScroll ,
6539
6487
control , picker , stars , modalCard , actionView , growl , slidelist ,
6540
- bus , pageSession , render ) {
6488
+ bus , render ) {
6541
6489
6542
6490
var window = this ,
6491
+ history = window . history ,
6543
6492
location = window . location ,
6544
6493
document = window . document ,
6545
6494
body = document . body ,
6546
6495
back_timeout ,
6547
6496
gc_id = 0 ,
6548
6497
6498
+ SUPPORT_HISTORY = ! browsers . crios && 'pushState' in history ,
6549
6499
SUPPORT_OVERFLOWSCROLL = "webkitOverflowScrolling" in body . style ,
6550
6500
6551
6501
TPL_MASK = '<div class="ck-globalmask"></div>' ;
@@ -6885,90 +6835,97 @@ define("../cardkit/app", [
6885
6835
6886
6836
initState : function ( ) {
6887
6837
6888
- $ ( window ) . bind ( "popstate" , function ( e ) {
6889
- // alert(['pop', e.state && [e.state.prev, e.state.next], ck.viewport && ck.viewport[0].id].join(', '))
6890
- if ( ck . sessionLocked ) {
6891
- pageSession . reset ( ) ;
6892
- location . reload ( ) ;
6893
- return ;
6894
- }
6895
- clearTimeout ( back_timeout ) ;
6896
- var loading = ck . viewport [ 0 ] . id === 'ckLoading' ;
6897
- if ( e . state ) {
6898
- if ( e . state . next === '_modal_' ) {
6899
- // 11. forward from normal card, show modal card. alert(11)
6900
- if ( modalCard . isOpened || loading || ! ck . viewport ) {
6901
- modalCard . event . once ( 'close' , function ( ) {
6902
- pageSession . reset ( ) ;
6903
- } ) ;
6838
+ ck . sessionLocked = false ;
6839
+
6840
+ var is_forward , restore_state ;
6841
+
6842
+ if ( SUPPORT_HISTORY ) {
6843
+ $ ( window ) . bind ( "popstate" , function ( e ) {
6844
+ // alert(['pop', e.state && [e.state.prev, e.state.next].join('-'), ck.viewport && ck.viewport[0].id].join(', '))
6845
+ if ( ck . sessionLocked ) {
6846
+ location . reload ( ) ;
6847
+ return ;
6848
+ }
6849
+ clearTimeout ( back_timeout ) ;
6850
+ var loading = ck . viewport [ 0 ] . id === 'ckLoading' ;
6851
+ if ( e . state ) {
6852
+ if ( e . state . next === '_modal_' ) {
6853
+ // 11. forward from normal card, show modal card. alert(11)
6854
+ if ( modalCard . isOpened || loading || ! ck . viewport ) {
6855
+ history . back ( ) ;
6856
+ } else {
6857
+ modalCard . set ( e . state . opt ) . open ( ) ;
6858
+ }
6859
+ } else if ( modalCard . isOpened ) {
6860
+ // 12. back from modal card. alert(12)
6861
+ ck . closeModal ( ) ;
6862
+ } else if ( loading ) {
6863
+ if ( e . state . next === 'ckLoading' ) {
6864
+ // 6. back from other page, no GC.
6865
+ // go to 2. alert(6)
6866
+ history . back ( ) ;
6867
+ } else if ( e . state . next ) {
6868
+ // 7. from 6, hide loading immediately. alert(7)
6869
+ ck . changeView ( e . state . next ) ;
6870
+ ck . hideLoading ( ) ;
6871
+ }
6872
+ } else if ( e . state . prev === ck . viewport [ 0 ] . id ) {
6873
+ // 3. forward from normal card. alert(3)
6874
+ link_handler ( e . state . next , e . state . link ) ;
6875
+ } else if ( e . state . next === ck . viewport [ 0 ] . id ) { // @TODO hotfix for chrome
6904
6876
history . back ( ) ;
6905
6877
} else {
6906
- modalCard . set ( e . state . opt ) . open ( ) ;
6878
+ // 2. back from normal card. alert(2)
6879
+ back_handler ( e . state . next ) ;
6907
6880
}
6908
- } else if ( modalCard . isOpened ) {
6909
- // 12. back from modal card. alert(12)
6910
- ck . closeModal ( ) ;
6911
6881
} else if ( loading ) {
6912
- if ( e . state . next === 'ckLoading' ) {
6913
- // 6. back from other page, no GC.
6914
- // go to 2. alert(6)
6915
- history . back ( ) ;
6916
- } else {
6917
- // 7. from 6, hide loading immediately. alert(7)
6918
- ck . changeView ( e . state . next ) ;
6919
- ck . hideLoading ( ) ;
6920
- }
6921
- } else if ( e . state . prev === ck . viewport [ 0 ] . id ) {
6922
- // 3. forward from normal card. alert(3)
6923
- link_handler ( e . state . next , e . state . link ) ;
6924
- } else if ( e . state . next === ck . viewport [ 0 ] . id ) { // @TODO hotfix for chrome
6925
- history . back ( ) ;
6926
- } else {
6927
- // 2. back from normal card. alert(2)
6928
- back_handler ( e . state . next ) ;
6882
+ // 5. forward from other page, no GC. alert(5)
6883
+ history . forward ( ) ;
6884
+ } else {
6885
+ // 4. back to other page, shift left and show loading.
6886
+ // if no GC: go to 6.
6887
+ // if no prev page: reload, go to 8
6888
+ // else: go to 8. alert(4)
6889
+ back_handler ( 'ckLoading' ) ;
6929
6890
}
6930
- } else if ( loading ) {
6931
- // 5. forward from other page, no GC. alert(5)
6932
- history . forward ( ) ;
6933
- } else {
6934
- // 4. back to other page, shift left and show loading.
6935
- // if no GC: go to 6.
6936
- // if no prev page: reload, go to 8
6937
- // else: go to 8. alert(4)
6938
- back_handler ( 'ckLoading' ) ;
6939
- }
6940
- } ) ;
6941
-
6942
- ck . sessionLocked = false ;
6943
-
6944
- pageSession . init ( ) ;
6891
+ } ) ;
6945
6892
6946
- var current_state = history . state ,
6947
- restore_state = current_state && current_state . next ; // alert(['init', current_state && [current_state.prev, current_state.next], ck.viewport && ck.viewport[0].id].join(', '))
6948
- if ( restore_state === '_modal_' ) { // @TODO
6949
- restore_state = current_state . prev ;
6950
- if ( ! modalCard . isOpened && ck . viewport ) {
6951
- modalCard . set ( history . state . opt ) . open ( ) ;
6893
+ //alert('length: ' + history.length + ', ' + document.referrer)
6894
+ var last_length = sessionStorage [ 'ck_ss_n' ] ,
6895
+ last_loc = sessionStorage [ 'ck_ss_loc' ] ;
6896
+ is_forward = last_length && last_length == history . length
6897
+ && document . referrer && last_loc === document . referrer ;
6898
+ sessionStorage [ 'ck_ss_n' ] = history . length ;
6899
+ sessionStorage [ 'ck_ss_loc' ] = location . href ;
6900
+
6901
+ var current_state = history . state ,
6902
+ restore_state = current_state && current_state . next ; // alert(['init', current_state && [current_state.prev, current_state.next].join('-'), ck.viewport && ck.viewport[0].id].join(', '))
6903
+ if ( restore_state === '_modal_' ) { // @TODO
6904
+ restore_state = current_state . prev ;
6905
+ if ( ! modalCard . isOpened && ck . viewport ) {
6906
+ modalCard . set ( history . state . opt ) . open ( ) ;
6907
+ }
6952
6908
}
6909
+
6953
6910
}
6911
+
6954
6912
if ( restore_state ) {
6955
- // 1. reload from normal card. alert(0 )
6913
+ // 1. reload from normal card. alert(1 )
6956
6914
ck . changeView ( restore_state ) ;
6957
6915
if ( restore_state === 'ckLoading' ) {
6958
6916
// 9. alert(9)
6959
6917
history . back ( ) ;
6960
6918
}
6961
6919
} else {
6962
- if ( pageSession . indexOf ( location . href ) !== - 1 ) {
6963
- // 8. reload from loading card.
6964
- // or forward from other page . alert(8)
6920
+ //console.info(is_refresh, history.state, ck.viewport[0].id, last_url, location.href)
6921
+ if ( is_forward ) {
6922
+ // 8 . alert(8)
6965
6923
ck . changeView ( ck . loadingCard ) ;
6966
6924
history . forward ( ) ;
6967
6925
} else {
6968
- // 0. new page. alert(1 )
6926
+ // 0. alert(0 )
6969
6927
ck . changeView ( ck . defaultCard ) ;
6970
6928
push_history ( ck . loadingCard [ 0 ] . id , ck . defaultCard [ 0 ] . id ) ;
6971
- pageSession . push ( location . href ) ;
6972
6929
}
6973
6930
}
6974
6931
@@ -7145,8 +7102,6 @@ define("../cardkit/app", [
7145
7102
next_id = 'ckLoading' ;
7146
7103
next = ck . loadingCard ;
7147
7104
true_link = me . href ;
7148
- //pageSession.clear(pageSession.indexOf(location.href));
7149
- pageSession . reset ( ) ;
7150
7105
} else {
7151
7106
return ;
7152
7107
}
@@ -7169,7 +7124,7 @@ define("../cardkit/app", [
7169
7124
ck . globalMask . hide ( ) ;
7170
7125
ck . sessionLocked = false ;
7171
7126
if ( true_link ) {
7172
- if ( is_forward ) {
7127
+ if ( is_forward && SUPPORT_HISTORY ) {
7173
7128
history . forward ( ) ;
7174
7129
} else {
7175
7130
location . href = true_link ;
@@ -7197,7 +7152,7 @@ define("../cardkit/app", [
7197
7152
current . hide ( ) . removeClass ( 'moving' ) ;
7198
7153
ck . globalMask . hide ( ) ;
7199
7154
ck . sessionLocked = false ;
7200
- if ( prev_id === 'ckLoading' ) {
7155
+ if ( prev_id === 'ckLoading' && SUPPORT_HISTORY ) {
7201
7156
history . back ( ) ;
7202
7157
back_timeout = setTimeout ( function ( ) {
7203
7158
location . reload ( ) ;
@@ -7207,13 +7162,15 @@ define("../cardkit/app", [
7207
7162
}
7208
7163
7209
7164
function push_history ( prev_id , next_id , link , opt ) {
7210
- history . pushState ( {
7211
- prev : prev_id ,
7212
- next : next_id ,
7213
- link : link ,
7214
- opt : opt ,
7215
- i : history . length
7216
- } , document . title , location . href ) ;
7165
+ if ( SUPPORT_HISTORY ) {
7166
+ history . pushState ( {
7167
+ prev : prev_id ,
7168
+ next : next_id ,
7169
+ link : link ,
7170
+ opt : opt ,
7171
+ i : history . length
7172
+ } , document . title , location . href ) ;
7173
+ }
7217
7174
}
7218
7175
7219
7176
function prevent_window_scroll ( ) {
@@ -7250,8 +7207,6 @@ define("../cardkit/app", [
7250
7207
ck . sessionLocked = true ;
7251
7208
var next_id = 'ckLoading' ;
7252
7209
var next = ck . loadingCard ;
7253
- //pageSession.clear(pageSession.indexOf(location.href));
7254
- pageSession . reset ( ) ;
7255
7210
var current = ck . viewport ;
7256
7211
ck . globalMask . show ( ) ;
7257
7212
push_history ( current [ 0 ] . id , next_id , true_link ) ;
0 commit comments