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) {
...
@@ -104,12 +104,12 @@ window.shower = (function(window, document, undefined) {
};
};
/**
/**
* Get
containing slide id
.
* Get
slide id from HTML element
.
* @private
* @private
* @param {domElem} el
* @param {domElem} el
* @returns {String}
* @returns {String}
*/
*/
shower
.
_get
ContainingSlideId
=
function
(
el
)
{
shower
.
_get
SlideIdByEl
=
function
(
el
)
{
while
(
'BODY'
!==
el
.
nodeName
&&
'HTML'
!==
el
.
nodeName
)
{
while
(
'BODY'
!==
el
.
nodeName
&&
'HTML'
!==
el
.
nodeName
)
{
if
(
el
.
classList
.
contains
(
'slide'
))
{
if
(
el
.
classList
.
contains
(
'slide'
))
{
return
el
.
id
;
return
el
.
id
;
...
@@ -122,28 +122,33 @@ window.shower = (function(window, document, undefined) {
...
@@ -122,28 +122,33 @@ window.shower = (function(window, document, undefined) {
};
};
/**
/**
* Dispatch single slide mode.
* For touch devices: check if click on links...
* @TODO: Renaming needed? Or just some handlers rewriting?
*
* @TODO: add support for textareas/inputs/...
*
* @private
* @private
* @param {domElem} e
* @param {domElem} e
* @returns {
Undefined
}
* @returns {
Boolean
}
*/
*/
shower
.
_dispatchSingleSlideMode
=
function
(
e
)
{
shower
.
_checkInteractiveElement
=
function
(
e
)
{
// Process links
// @TODO: presentation links support
if
(
'A'
===
e
.
target
.
nodeName
)
{
if
(
'A'
===
e
.
target
.
nodeName
)
{
e
.
preventDefault
();
return
true
;
}
else
{
window
.
open
(
e
.
target
.
getAttribute
(
'href'
));
return
false
;
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
;
slideNumber
;
if
(
slideId
===
''
)
{
if
(
slideId
===
''
)
{
return
false
;
slideNumber
=
0
;
}
}
for
(;
i
>=
0
;
--
i
)
{
for
(;
i
>=
0
;
--
i
)
{
...
@@ -153,16 +158,10 @@ window.shower = (function(window, document, undefined) {
...
@@ -153,16 +158,10 @@ window.shower = (function(window, document, undefined) {
}
}
}
}
shower
.
go
(
slideNumber
);
return
slideNumber
;
if
(
shower
.
isListMode
())
{
e
.
preventDefault
();
shower
.
enterSlideMode
();
}
return
true
;
};
};
/**
/**
* Show next slide. If slide is last returns false, otherwise return slide
* Show next slide. If slide is last returns false, otherwise return slide
* number which been shown.
* number which been shown.
...
@@ -690,25 +689,37 @@ window.shower = (function(window, document, undefined) {
...
@@ -690,25 +689,37 @@ window.shower = (function(window, document, undefined) {
}
}
},
false
);
},
false
);
document
.
addEventListener
(
'click'
,
shower
.
_dispatchSingleSlideMode
,
false
);
document
.
addEventListener
(
'click'
,
function
(
e
)
{
document
.
addEventListener
(
'touchend'
,
shower
.
_dispatchSingleSlideMode
,
false
);
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
)
{
document
.
addEventListener
(
'touchstart'
,
function
(
e
)
{
if
(
!
shower
.
isListMode
())
{
if
(
shower
.
_getSlideIdByEl
(
e
.
target
))
{
var
currentSlideNumber
=
shower
.
getCurrentSlideNumber
(),
if
(
shower
.
isSlideMode
()
&&
!
shower
.
_checkInteractiveElement
(
e
))
{
x
=
e
.
touches
[
0
].
pageX
;
var
x
=
e
.
touches
[
0
].
pageX
;
if
(
x
>
window
.
innerWidth
/
2
)
{
currentSlideNumber
++
;
if
(
x
>
window
.
innerWidth
/
2
)
{
}
else
{
shower
.
next
();
currentSlideNumber
--
;
}
else
{
shower
.
previous
();
}
}
}
shower
.
go
(
currentSlideNumber
);
if
(
shower
.
isListMode
())
{
shower
.
go
(
shower
.
getSlideNumber
(
shower
.
_getSlideIdByEl
(
e
.
target
)));
shower
.
enterSlideMode
();
}
}
}
},
false
);
},
false
);
document
.
addEventListener
(
'touchmove'
,
function
(
e
)
{
document
.
addEventListener
(
'touchmove'
,
function
(
e
)
{
if
(
!
shower
.
isList
Mode
())
{
if
(
shower
.
isSlide
Mode
())
{
e
.
preventDefault
();
e
.
preventDefault
();
}
}
},
false
);
},
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