more history related work, still not done...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-02-05 19:06:01 +04:00
parent 9fb001c6b4
commit 232576b158
3 changed files with 33 additions and 2 deletions

View File

@ -6,6 +6,9 @@
[_] BUG: no drag threshold on excludedElements (TouchSwipe) [_] BUG: no drag threshold on excludedElements (TouchSwipe)
| stalled... | stalled...
[_] 67% general todo [_] 67% general todo
[_] add separate history manager...
| might be a virtual history rather than browser history which
| tends to slow things down -- just a simple stack...
[_] move some of the current configuration options to the magazine... [_] move some of the current configuration options to the magazine...
| same idea as .no-resize class... | same idea as .no-resize class...
[_] add option to align page to right or left screen border [_] add option to align page to right or left screen border

View File

@ -668,6 +668,14 @@ $(document).ready(function(){
<button id="UPDATE_HASH_URL_POSITION" onclick="toggleSetting(this)"></button> <button id="UPDATE_HASH_URL_POSITION" onclick="toggleSetting(this)"></button>
</td> </td>
</tr> </tr>
<tr>
<td>
Full navigation gistory:
</td>
<td>
<button id="FULL_HISTORY_ENABLED" onclick="toggleSetting(this)"></button>
</td>
</tr>
<tr> <tr>
<td> <td>
Reset stored data: Reset stored data:
@ -738,6 +746,7 @@ $(document).ready(function(){
DRAG_FULL_PAGE = $('#DRAG_FULL_PAGE').text() == 'true' ? true : false DRAG_FULL_PAGE = $('#DRAG_FULL_PAGE').text() == 'true' ? true : false
USE_REAL_PAGE_SIZES = $('#USE_REAL_PAGE_SIZES').text() == 'true' ? true : false USE_REAL_PAGE_SIZES = $('#USE_REAL_PAGE_SIZES').text() == 'true' ? true : false
UPDATE_HASH_URL_POSITION = $('#UPDATE_HASH_URL_POSITION').text() == 'true' ? true : false UPDATE_HASH_URL_POSITION = $('#UPDATE_HASH_URL_POSITION').text() == 'true' ? true : false
FULL_HISTORY_ENABLED = $('#FULL_HISTORY_ENABLED').text() == 'true' ? true : false
} }
function loadSettings(){ function loadSettings(){
$('#PAGES_IN_RIBBON').attr('value', PAGES_IN_RIBBON) $('#PAGES_IN_RIBBON').attr('value', PAGES_IN_RIBBON)
@ -746,6 +755,7 @@ $(document).ready(function(){
$('#DRAG_FULL_PAGE').text(DRAG_FULL_PAGE) $('#DRAG_FULL_PAGE').text(DRAG_FULL_PAGE)
$('#USE_REAL_PAGE_SIZES').text(USE_REAL_PAGE_SIZES) $('#USE_REAL_PAGE_SIZES').text(USE_REAL_PAGE_SIZES)
$('#UPDATE_HASH_URL_POSITION').text(UPDATE_HASH_URL_POSITION) $('#UPDATE_HASH_URL_POSITION').text(UPDATE_HASH_URL_POSITION)
$('#FULL_HISTORY_ENABLED').text(FULL_HISTORY_ENABLED)
$('#FingersSupported').text($.fn.swipe.fingers.ALL) $('#FingersSupported').text($.fn.swipe.fingers.ALL)
var b = $('#BrowserInfo') var b = $('#BrowserInfo')

View File

@ -30,8 +30,17 @@ var USE_REAL_PAGE_SIZES = false
// if true this will make each page flip update the hash url... // if true this will make each page flip update the hash url...
// if false, only direct linking will update the url. // if false, only direct linking will update the url.
// XXX this if false, will break the layer hide/show toggle... // NOTE: this can slow down navigation...
var UPDATE_HASH_URL_POSITION = true // XXX BUG this if false, will break the layer hide/show toggle...
var UPDATE_HASH_URL_POSITION = false
// if true this will enable history for local page navigation regardless
// of weather UPDATE_HASH_URL_POSITION state.
// NOTE: UPDATE_HASH_URL_POSITION implicitly enables full browser history
// based navigation.
// NOTE: this can slow down navigation...
// NOTE: partial history navigation over links will still work.
var FULL_HISTORY_ENABLED = false
@ -680,6 +689,12 @@ function loadURLState(){
.addClass('hidden') .addClass('hidden')
.removeClass('shown') .removeClass('shown')
} }
if(!UPDATE_HASH_URL_POSITION){
// push current position...
// NOTE: this will enable partial history navigation, but only
// on actions envolving actual links...
window.history.pushState(null, null, '#' + getPageNumber())
}
return n return n
} }
} }
@ -705,6 +720,9 @@ function saveURLState(){
} }
if(UPDATE_HASH_URL_POSITION){ if(UPDATE_HASH_URL_POSITION){
window.location.hash = n window.location.hash = n
} else if(FULL_HISTORY_ENABLED){
// XXX add option to disable history altogether...
window.history.pushState(null, null, '#' + n)
} }
return n return n
} }