Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
my-cucumbers-ru-github-io
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Лотуга Данила Сергеевич
my-cucumbers-ru-github-io
Commits
310f5d74
Commit
310f5d74
authored
Jan 28, 2013
by
miripiruni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #99: Inner navigation should be also controlled by slide timing
parent
74ea9e80
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
24 deletions
+56
-24
shower.js
shower.js
+56
-24
No files found.
shower.js
View file @
310f5d74
...
@@ -11,6 +11,7 @@ window.shower = (function(window, document, undefined) {
...
@@ -11,6 +11,7 @@ window.shower = (function(window, document, undefined) {
progress
=
document
.
querySelector
(
'div.progress div'
),
progress
=
document
.
querySelector
(
'div.progress div'
),
slideList
=
[],
slideList
=
[],
timer
,
timer
,
timing
=
0
,
isHistoryApiSupported
=
!!
(
window
.
history
&&
history
.
pushState
),
isHistoryApiSupported
=
!!
(
window
.
history
&&
history
.
pushState
),
l
=
slides
.
length
,
i
;
l
=
slides
.
length
,
i
;
...
@@ -32,10 +33,23 @@ window.shower = (function(window, document, undefined) {
...
@@ -32,10 +33,23 @@ window.shower = (function(window, document, undefined) {
slides
[
i
].
id
=
i
+
1
;
slides
[
i
].
id
=
i
+
1
;
}
}
timing
=
shower
.
_getData
(
slides
[
i
],
'timing'
);
if
(
timing
&&
timing
.
indexOf
(
':'
)
!==
-
1
)
{
timing
=
timing
.
split
(
':'
);
// Compute number of milliseconds from format "mm:ss"
timing
=
(
parseInt
(
timing
[
0
],
10
)
*
60
+
parseInt
(
timing
[
1
],
10
))
*
1000
;
if
(
slides
[
i
].
querySelector
(
'.next'
))
{
timing
=
timing
/
(
slides
[
i
].
querySelectorAll
(
'.next'
).
length
+
1
);
}
}
slideList
.
push
({
slideList
.
push
({
id
:
slides
[
i
].
id
,
id
:
slides
[
i
].
id
,
hasInnerNavigation
:
null
!==
slides
[
i
].
querySelector
(
'.next'
),
hasInnerNavigation
:
null
!==
slides
[
i
].
querySelector
(
'.next'
),
hasTiming
:
(
shower
.
_getData
(
slides
[
i
],
'timing'
)
&&
shower
.
_getData
(
slides
[
i
],
'timing'
).
indexOf
(
':'
)
!==
-
1
)
timing
:
timing
,
innerLength
:
slides
[
i
].
querySelectorAll
(
'.next'
).
length
,
innerComplete
:
0
});
});
}
}
...
@@ -175,7 +189,7 @@ window.shower = (function(window, document, undefined) {
...
@@ -175,7 +189,7 @@ window.shower = (function(window, document, undefined) {
if
(
shower
.
isSlideMode
())
{
if
(
shower
.
isSlideMode
())
{
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
run
InnerNavigation
(
slideNumber
);
shower
.
start
InnerNavigation
(
slideNumber
);
}
}
if
(
typeof
(
callback
)
===
'function'
)
{
if
(
typeof
(
callback
)
===
'function'
)
{
...
@@ -213,7 +227,7 @@ window.shower = (function(window, document, undefined) {
...
@@ -213,7 +227,7 @@ window.shower = (function(window, document, undefined) {
}
}
if
(
shower
.
isSlideMode
())
{
if
(
shower
.
isSlideMode
())
{
shower
.
run
InnerNavigation
(
currentSlideNumber
+
1
);
shower
.
start
InnerNavigation
(
currentSlideNumber
+
1
);
}
}
if
(
typeof
(
callback
)
===
'function'
)
{
if
(
typeof
(
callback
)
===
'function'
)
{
...
@@ -314,7 +328,7 @@ window.shower = (function(window, document, undefined) {
...
@@ -314,7 +328,7 @@ window.shower = (function(window, document, undefined) {
var
currentSlideNumber
=
shower
.
getCurrentSlideNumber
();
var
currentSlideNumber
=
shower
.
getCurrentSlideNumber
();
clear
Timeout
(
timer
);
clear
Interval
(
timer
);
if
(
shower
.
isSlideMode
()
&&
isHistoryApiSupported
)
{
if
(
shower
.
isSlideMode
()
&&
isHistoryApiSupported
)
{
history
.
pushState
(
null
,
null
,
url
.
pathname
+
shower
.
getSlideHash
(
currentSlideNumber
));
history
.
pushState
(
null
,
null
,
url
.
pathname
+
shower
.
getSlideHash
(
currentSlideNumber
));
...
@@ -527,29 +541,38 @@ window.shower = (function(window, document, undefined) {
...
@@ -527,29 +541,38 @@ window.shower = (function(window, document, undefined) {
};
};
/**
/**
* Run slide show if presented.
* Start inner navigation by timer or just switch slide after timer.
* time sets in HTML: .slide[data-timer=MM:SS]
* @param {Number} slideNumber
* @param {Number} slideNumber
* @returns {Boolean}
* @returns {Boolean}
*/
*/
shower
.
runInnerNavigation
=
function
(
slideNumber
)
{
shower
.
startInnerNavigation
=
function
(
slideNumber
)
{
if
(
!
shower
.
_isNumber
(
slideNumber
))
{
var
slide
;
throw
new
Error
(
'Gimme slide number as Number, baby!'
);
}
slideNumber
=
shower
.
_normalizeSlideNumber
(
slideNumber
);
slideNumber
=
shower
.
_normalizeSlideNumber
(
slideNumber
);
slide
=
slideList
[
slideNumber
];
clearTimeout
(
timer
);
if
(
!
shower
.
_isNumber
(
slideNumber
))
{
throw
new
Error
(
'Gimme slide number as Number, baby!'
);
}
if
(
slideList
[
slideNumber
].
hasTiming
)
{
clearInterval
(
timer
);
// Compute number of milliseconds from format "X:Y", where X is
// number of minutes, and Y is number of seconds
var
timing
=
shower
.
_getData
(
document
.
getElementById
(
slideList
[
slideNumber
].
id
),
'timing'
).
split
(
':'
);
timing
=
parseInt
(
timing
[
0
],
10
)
*
60
*
1000
+
parseInt
(
timing
[
1
],
10
)
*
1000
;
timer
=
setTimeout
(
function
()
{
if
(
slide
&&
slide
.
timing
)
{
timer
=
setInterval
(
function
()
{
// Inner Navigation not finished
if
(
slide
.
innerLength
>=
slide
.
innerComplete
)
{
shower
.
increaseInnerNavigation
(
slideNumber
);
slide
.
innerComplete
++
;
}
else
{
clearInterval
(
timer
);
// Check if last slide
if
(
slideList
.
length
!==
slideNumber
+
1
)
{
shower
.
next
();
shower
.
next
();
}
}
},
},
timing
);
slide
.
timing
);
}
}
return
true
;
return
true
;
...
@@ -624,6 +647,7 @@ window.shower = (function(window, document, undefined) {
...
@@ -624,6 +647,7 @@ window.shower = (function(window, document, undefined) {
shower
.
go
(
slideNumber
);
shower
.
go
(
slideNumber
);
shower
.
enterSlideMode
();
shower
.
enterSlideMode
();
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
startInnerNavigation
(
slideNumber
);
}
else
{
}
else
{
shower
.
enterListMode
();
shower
.
enterListMode
();
}
}
...
@@ -634,7 +658,7 @@ window.shower = (function(window, document, undefined) {
...
@@ -634,7 +658,7 @@ window.shower = (function(window, document, undefined) {
e
.
preventDefault
();
e
.
preventDefault
();
shower
.
enterSlideMode
();
shower
.
enterSlideMode
();
shower
.
showPresenterNotes
(
currentSlideNumber
);
shower
.
showPresenterNotes
(
currentSlideNumber
);
shower
.
run
InnerNavigation
(
currentSlideNumber
);
shower
.
start
InnerNavigation
(
currentSlideNumber
);
}
}
break
;
break
;
...
@@ -694,13 +718,17 @@ window.shower = (function(window, document, undefined) {
...
@@ -694,13 +718,17 @@ window.shower = (function(window, document, undefined) {
shower
.
go
(
slideNumber
);
shower
.
go
(
slideNumber
);
shower
.
enterSlideMode
();
shower
.
enterSlideMode
();
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
startInnerNavigation
(
slideNumber
);
}
}
},
false
);
},
false
);
document
.
addEventListener
(
'touchstart'
,
function
(
e
)
{
document
.
addEventListener
(
'touchstart'
,
function
(
e
)
{
var
slideNumber
=
shower
.
getSlideNumber
(
shower
.
_getSlideIdByEl
(
e
.
target
)),
x
;
if
(
shower
.
_getSlideIdByEl
(
e
.
target
))
{
if
(
shower
.
_getSlideIdByEl
(
e
.
target
))
{
if
(
shower
.
isSlideMode
()
&&
!
shower
.
_checkInteractiveElement
(
e
))
{
if
(
shower
.
isSlideMode
()
&&
!
shower
.
_checkInteractiveElement
(
e
))
{
var
x
=
e
.
touches
[
0
].
pageX
;
x
=
e
.
touches
[
0
].
pageX
;
if
(
x
>
window
.
innerWidth
/
2
)
{
if
(
x
>
window
.
innerWidth
/
2
)
{
shower
.
next
();
shower
.
next
();
...
@@ -710,8 +738,12 @@ window.shower = (function(window, document, undefined) {
...
@@ -710,8 +738,12 @@ window.shower = (function(window, document, undefined) {
}
}
if
(
shower
.
isListMode
())
{
if
(
shower
.
isListMode
())
{
// Warning: go must be before enterSlideMode.
// Otherwise there is a bug in Chrome
shower
.
go
(
shower
.
getSlideNumber
(
shower
.
_getSlideIdByEl
(
e
.
target
)));
shower
.
go
(
shower
.
getSlideNumber
(
shower
.
_getSlideIdByEl
(
e
.
target
)));
shower
.
enterSlideMode
();
shower
.
enterSlideMode
();
shower
.
showPresenterNotes
(
slideNumber
);
shower
.
startInnerNavigation
(
slideNumber
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment