Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2016-07-26 18:03:10 +0100
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
d05e85efa9e64019dd937c043fbd56b085efb988
d05e85ef
1 parent
547e1177
Fixed back-to-top button on firefox. Fixes #153.
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
10 deletions
resources/assets/js/global.js
resources/assets/js/global.js
View file @
d05e85e
...
...
@@ -10,9 +10,12 @@ require('angular-ui-sortable');
var
ngApp
=
angular
.
module
(
'bookStack'
,
[
'ngResource'
,
'ngAnimate'
,
'ngSanitize'
,
'ui.sortable'
]);
// Global Event System
var
Events
=
{
listeners
:
{},
emit
:
function
(
eventName
,
eventData
)
{
class
Events
{
constructor
()
{
this
.
listeners
=
{};
}
emit
(
eventName
,
eventData
)
{
if
(
typeof
this
.
listeners
[
eventName
]
===
'undefined'
)
return
this
;
var
eventsToStart
=
this
.
listeners
[
eventName
];
for
(
let
i
=
0
;
i
<
eventsToStart
.
length
;
i
++
)
{
...
...
@@ -20,14 +23,15 @@ var Events = {
event
(
eventData
);
}
return
this
;
},
listen
:
function
(
eventName
,
callback
)
{
}
listen
(
eventName
,
callback
)
{
if
(
typeof
this
.
listeners
[
eventName
]
===
'undefined'
)
this
.
listeners
[
eventName
]
=
[];
this
.
listeners
[
eventName
].
push
(
callback
);
return
this
;
}
};
window
.
Events
=
Events
;
window
.
Events
=
new
Events
()
;
var
services
=
require
(
'./services'
)(
ngApp
,
Events
);
var
directives
=
require
(
'./directives'
)(
ngApp
,
Events
);
...
...
@@ -38,14 +42,15 @@ var controllers = require('./controllers')(ngApp, Events);
// Smooth scrolling
jQuery
.
fn
.
smoothScrollTo
=
function
()
{
if
(
this
.
length
===
0
)
return
;
$
(
'body'
).
animate
({
let
scrollElem
=
document
.
documentElement
.
scrollTop
===
0
?
document
.
body
:
document
.
documentElement
;
$
(
scrollElem
).
animate
({
scrollTop
:
this
.
offset
().
top
-
60
// Adjust to change final scroll position top margin
},
800
);
// Adjust to change animations speed (ms)
return
this
;
};
// Making contains text expression not worry about casing
$
.
expr
[
":"
].
contains
=
$
.
expr
.
createPseudo
(
function
(
arg
)
{
jQuery
.
expr
[
":"
].
contains
=
$
.
expr
.
createPseudo
(
function
(
arg
)
{
return
function
(
elem
)
{
return
$
(
elem
).
text
().
toUpperCase
().
indexOf
(
arg
.
toUpperCase
())
>=
0
;
};
...
...
@@ -95,13 +100,14 @@ $(function () {
var
scrollTop
=
document
.
getElementById
(
'back-to-top'
);
var
scrollTopBreakpoint
=
1200
;
window
.
addEventListener
(
'scroll'
,
function
()
{
if
(
!
scrollTopShowing
&&
document
.
body
.
scrollTop
>
scrollTopBreakpoint
)
{
let
scrollTopPos
=
document
.
documentElement
.
scrollTop
||
document
.
body
.
scrollTop
||
0
;
if
(
!
scrollTopShowing
&&
scrollTopPos
>
scrollTopBreakpoint
)
{
scrollTop
.
style
.
display
=
'block'
;
scrollTopShowing
=
true
;
setTimeout
(()
=>
{
scrollTop
.
style
.
opacity
=
0.4
;
},
1
);
}
else
if
(
scrollTopShowing
&&
document
.
body
.
scrollTop
<
scrollTopBreakpoint
)
{
}
else
if
(
scrollTopShowing
&&
scrollTopPos
<
scrollTopBreakpoint
)
{
scrollTop
.
style
.
opacity
=
0
;
scrollTopShowing
=
false
;
setTimeout
(()
=>
{
...
...
Please
register
or
sign in
to post a comment