deserialize state values
This commit is contained in:
parent
e8ab2641da
commit
1c2f4a2e92
29
js/reveal.js
29
js/reveal.js
@ -754,6 +754,22 @@ var Reveal = (function(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility for deserializing a value.
|
||||||
|
*/
|
||||||
|
function deserialize( value ) {
|
||||||
|
|
||||||
|
if( typeof value === 'string' ) {
|
||||||
|
if( value === 'null' ) return null;
|
||||||
|
else if( value === 'true' ) return true;
|
||||||
|
else if( value === 'false' ) return false;
|
||||||
|
else if( value.match( /^\d+$/ ) ) return parseFloat( value );
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Measures the distance in pixels between point a
|
* Measures the distance in pixels between point a
|
||||||
* and point b.
|
* and point b.
|
||||||
@ -2352,9 +2368,9 @@ var Reveal = (function(){
|
|||||||
function setState( state ) {
|
function setState( state ) {
|
||||||
|
|
||||||
if( typeof state === 'object' ) {
|
if( typeof state === 'object' ) {
|
||||||
slide( state.indexh, state.indexv, state.indexf );
|
slide( deserialize( state.indexh ), deserialize( state.indexv ), deserialize( state.indexf ) );
|
||||||
togglePause( state.paused );
|
togglePause( deserialize( state.paused ) );
|
||||||
toggleOverview( state.overview );
|
toggleOverview( deserialize( state.overview ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -3430,12 +3446,7 @@ var Reveal = (function(){
|
|||||||
for( var i in query ) {
|
for( var i in query ) {
|
||||||
var value = query[ i ];
|
var value = query[ i ];
|
||||||
|
|
||||||
query[ i ] = unescape( value );
|
query[ i ] = deserialize( unescape( value ) );
|
||||||
|
|
||||||
if( value === 'null' ) query[ i ] = null;
|
|
||||||
else if( value === 'true' ) query[ i ] = true;
|
|
||||||
else if( value === 'false' ) query[ i ] = false;
|
|
||||||
else if( value.match( /^\d+$/ ) ) query[ i ] = parseFloat( value );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
6
js/reveal.min.js
vendored
6
js/reveal.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user