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
ce373040
Commit
ce373040
authored
Jan 19, 2013
by
miripiruni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed problems with touch devices; Small refactoring.
parent
c4edbb3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
33 deletions
+44
-33
shower.js
shower.js
+44
-33
No files found.
shower.js
View file @
ce373040
...
...
@@ -104,12 +104,12 @@ window.shower = (function(window, document, undefined) {
};
/**
* Get
containing slide id
.
* Get
slide id from HTML element
.
* @private
* @param {domElem} el
* @returns {String}
*/
shower
.
_get
ContainingSlideId
=
function
(
el
)
{
shower
.
_get
SlideIdByEl
=
function
(
el
)
{
while
(
'BODY'
!==
el
.
nodeName
&&
'HTML'
!==
el
.
nodeName
)
{
if
(
el
.
classList
.
contains
(
'slide'
))
{
return
el
.
id
;
...
...
@@ -122,28 +122,33 @@ window.shower = (function(window, document, undefined) {
};
/**
* Dispatch single slide mode.
* @TODO: Renaming needed? Or just some handlers rewriting?
* For touch devices: check if click on links...
*
* @TODO: add support for textareas/inputs/...
*
* @private
* @param {domElem} e
* @returns {
Undefined
}
* @returns {
Boolean
}
*/
shower
.
_dispatchSingleSlideMode
=
function
(
e
)
{
// Process links
// @TODO: presentation links support
shower
.
_checkInteractiveElement
=
function
(
e
)
{
if
(
'A'
===
e
.
target
.
nodeName
)
{
e
.
preventDefault
();
window
.
open
(
e
.
target
.
getAttribute
(
'href'
));
return
true
;
}
else
{
return
false
;
}
};
var
slideId
=
shower
.
_getContainingSlideId
(
e
.
target
),
i
=
slideList
.
length
-
1
,
/**
* Get slide number by slideId
* @param {Number} slideId (HTML id or position in slideList)
* @returns {Number}
*/
shower
.
getSlideNumber
=
function
(
slideId
)
{
var
i
=
slideList
.
length
-
1
,
slideNumber
;
if
(
slideId
===
''
)
{
return
false
;
slideNumber
=
0
;
}
for
(;
i
>=
0
;
--
i
)
{
...
...
@@ -153,16 +158,10 @@ window.shower = (function(window, document, undefined) {
}
}
shower
.
go
(
slideNumber
);
if
(
shower
.
isListMode
())
{
e
.
preventDefault
();
shower
.
enterSlideMode
();
}
return
true
;
return
slideNumber
;
};
/**
* Show next slide. If slide is last returns false, otherwise return slide
* number which been shown.
...
...
@@ -690,25 +689,37 @@ window.shower = (function(window, document, undefined) {
}
},
false
);
document
.
addEventListener
(
'click'
,
shower
.
_dispatchSingleSlideMode
,
false
);
document
.
addEventListener
(
'touchend'
,
shower
.
_dispatchSingleSlideMode
,
false
);
document
.
addEventListener
(
'click'
,
function
(
e
)
{
if
(
shower
.
isListMode
()
&&
shower
.
_getSlideIdByEl
(
e
.
target
))
{
e
.
preventDefault
();
shower
.
go
(
shower
.
getSlideNumber
(
shower
.
_getSlideIdByEl
(
e
.
target
)));
shower
.
enterSlideMode
();
}
},
false
);
document
.
addEventListener
(
'touchstart'
,
function
(
e
)
{
if
(
!
shower
.
isListMode
())
{
var
currentSlideNumber
=
shower
.
getCurrentSlideNumber
(),
x
=
e
.
touches
[
0
].
pageX
;
if
(
x
>
window
.
innerWidth
/
2
)
{
currentSlideNumber
++
;
}
else
{
currentSlideNumber
--
;
if
(
shower
.
_getSlideIdByEl
(
e
.
target
))
{
if
(
shower
.
isSlideMode
()
&&
!
shower
.
_checkInteractiveElement
(
e
))
{
var
x
=
e
.
touches
[
0
].
pageX
;
if
(
x
>
window
.
innerWidth
/
2
)
{
shower
.
next
();
}
else
{
shower
.
previous
();
}
}
shower
.
go
(
currentSlideNumber
);
if
(
shower
.
isListMode
())
{
shower
.
go
(
shower
.
getSlideNumber
(
shower
.
_getSlideIdByEl
(
e
.
target
)));
shower
.
enterSlideMode
();
}
}
},
false
);
document
.
addEventListener
(
'touchmove'
,
function
(
e
)
{
if
(
!
shower
.
isList
Mode
())
{
if
(
shower
.
isSlide
Mode
())
{
e
.
preventDefault
();
}
},
false
);
...
...
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