Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
shower-presentation
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
Шардт Максим Александрович
shower-presentation
Commits
1bbce711
Commit
1bbce711
authored
Jul 16, 2011
by
Vadim Makeev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new ?full parameter and list mode events
parent
79a17c23
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
71 deletions
+62
-71
script.js
scripts/script.js
+62
-71
No files found.
scripts/script.js
View file @
1bbce711
(
function
()
{
(
function
()
{
var
url
=
window
.
location
,
var
url
=
window
.
location
,
body
=
document
.
body
;
body
=
document
.
body
,
slides
=
document
.
querySelectorAll
(
'div.slide'
),
slides
=
document
.
querySelectorAll
(
'div.slide'
),
slideList
=
[],
hashList
=
{},
progress
=
document
.
querySelector
(
'div.progress div'
),
progress
=
document
.
querySelector
(
'div.progress div'
),
fullscreen
=
false
;
slideList
=
[]
;
for
(
var
i
=
0
,
slidesLength
=
slides
.
length
;
i
<
slidesLength
;
i
++
)
{
for
(
var
i
=
0
,
slidesLength
=
slides
.
length
;
i
<
slidesLength
;
i
++
)
{
var
id
=
slides
[
i
].
id
;
slides
[
i
].
addEventListener
(
'click'
,
enterFull
,
false
);
slideList
[
i
]
=
'#'
+
id
;
slideList
[
i
]
=
slides
[
i
].
id
;
hashList
[
'#'
+
id
]
=
i
;
slides
[
i
].
addEventListener
(
'click'
,
function
(){
enterSingle
();
turnSlide
(
hashList
[
'#'
+
this
.
id
]);
},
false
);
}
}
function
resizeBody
(
p
)
{
function
resizeFull
(
p
)
{
if
(
typeof
p
==
'boolean'
&&
p
)
{
if
(
p
)
{
var
transform
=
'none'
;
}
else
{
var
sx
=
body
.
clientWidth
/
window
.
innerWidth
,
var
sx
=
body
.
clientWidth
/
window
.
innerWidth
,
sy
=
body
.
clientHeight
/
window
.
innerHeight
,
sy
=
body
.
clientHeight
/
window
.
innerHeight
,
transform
=
'scale('
+
(
1
/
Math
.
max
(
sx
,
sy
))
+
')'
;
transform
=
'scale('
+
(
1
/
Math
.
max
(
sx
,
sy
))
+
')'
;
}
else
{
var
transform
=
'none'
;
}
}
body
.
style
.
MozTransform
=
transform
;
body
.
style
.
MozTransform
=
transform
;
body
.
style
.
WebkitTransform
=
transform
;
body
.
style
.
WebkitTransform
=
transform
;
...
@@ -33,78 +27,75 @@
...
@@ -33,78 +27,75 @@
}
}
function
turnSlide
(
e
)
{
function
turnSlide
(
e
)
{
var
current
=
hashList
[
url
.
hash
],
var
current
=
slideList
.
indexOf
(
url
.
hash
.
substr
(
1
));
target
;
if
(
e
)
{
if
(
e
.
type
==
'keyup'
)
{
// Key-Based
if
(
e
.
type
==
'keydown'
)
{
switch
(
e
.
which
)
{
switch
(
e
.
which
)
{
case
33
:
// PgUp
case
33
:
// PgUp
case
38
:
// Up
case
38
:
// Up
case
37
:
// Left
case
37
:
// Left
case
72
:
// h
case
75
:
// k
case
75
:
// k
current
--
;
current
--
;
e
.
preventDefault
();
break
;
break
;
case
34
:
// PgDown
case
34
:
// PgDown
case
40
:
// Down
case
40
:
// Down
case
39
:
// Right
case
39
:
// Right
case
76
:
// l
case
74
:
// j
case
74
:
// j
current
++
;
current
++
;
e
.
preventDefault
();
break
;
break
;
case
36
:
// Home
case
36
:
// Home
current
=
0
;
current
=
0
;
e
.
preventDefault
();
break
;
break
;
case
35
:
// End
case
35
:
// End
current
=
slideList
.
length
-
1
;
current
=
slideList
.
length
-
1
;
e
.
preventDefault
();
break
;
break
;
case
32
:
// Space
case
32
:
// Space
current
+=
e
.
shiftKey
?
-
1
:
1
;
current
+=
e
.
shiftKey
?
-
1
:
1
;
e
.
preventDefault
();
break
;
break
;
}
}
e
.
preventDefault
();
}
if
(
e
.
type
==
'click'
)
{
current
=
slideList
.
indexOf
(
e
.
target
.
parentNode
.
id
);
}
}
else
{
}
else
{
current
=
e
||
0
;
current
=
(
current
+
1
)
?
current
:
0
;
}
}
target
=
slideList
[
current
];
target
=
slideList
[
current
];
if
(
target
)
url
.
hash
=
target
;
if
(
target
)
url
.
hash
=
target
;
updateProgress
();
}
}
function
enter
Single
(
)
{
function
enter
Full
(
e
)
{
body
.
className
=
'full'
;
body
.
className
=
'full'
;
resizeBody
();
resizeFull
(
1
);
updateProgress
();
turnSlide
(
e
);
window
.
addEventListener
(
'resize'
,
resizeBody
,
false
);
if
(
!
isFull
())
history
.
pushState
(
null
,
null
,
url
.
pathname
+
'?full'
+
url
.
hash
);
document
.
addEventListener
(
'keyup'
,
turnSlide
,
false
);
document
.
addEventListener
(
'keyup'
,
exitFullEsc
,
false
);
document
.
addEventListener
(
'keyup'
,
exitSingleEsc
,
false
);
}
}
function
exit
Single
()
{
function
exit
Full
()
{
body
.
className
=
'list'
;
body
.
className
=
'list'
;
resizeBody
(
true
);
resizeFull
(
0
);
window
.
removeEventListener
(
'resize'
,
resizeBody
,
false
);
history
.
pushState
(
null
,
null
,
url
.
href
.
replace
(
'?full'
,
''
));
window
.
removeEventListener
(
'keyup'
,
turnSlide
,
false
);
document
.
removeEventListener
(
'keyup'
,
exitFullEsc
,
false
);
document
.
removeEventListener
(
'keyup'
,
exitSingleEsc
,
false
);
}
}
function
exit
Single
Esc
(
e
)
{
function
exit
Full
Esc
(
e
)
{
if
(
e
.
which
!=
27
)
return
;
if
(
e
.
which
!=
27
)
return
;
exitSingle
();
exitFull
();
url
.
hash
=
''
;
}
}
function
checkHash
()
{
function
isFull
()
{
// if(!window.location.search.length) history.pushState(null, null, window.location.href + '?list');
return
url
.
search
.
substr
(
1
)
==
'full'
;
if
(
typeof
hashList
[
url
.
hash
]
!=
'undefined'
)
{
enterSingle
();
}
}
function
updateProgress
()
{
if
(
!
progress
)
return
;
progress
.
style
.
width
=
(
100
/
(
slideList
.
length
-
1
)
*
hashList
[
url
.
hash
]).
toFixed
(
2
)
+
'%'
;
}
}
window
.
addEventListener
(
'DOMContentLoaded'
,
checkHash
,
false
);
window
.
addEventListener
(
'DOMContentLoaded'
,
function
()
{
if
(
isFull
())
enterFull
();
},
false
);
document
.
addEventListener
(
'keydown'
,
turnSlide
,
false
);
})();
})();
\ No newline at end of file
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