Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michael Iseard
Kudos-Website
Commits
399af44f
Commit
399af44f
authored
Oct 05, 2020
by
Michael Iseard
Browse files
Fix formatting
parent
f27887e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
resources/assets/scripts/routes/home.js
View file @
399af44f
export
default
{
init
()
{
// JavaScript to be fired on the home page
let
$introTarget
=
$
(
'
#intro-variable
'
)
;
let
introArray
=
$
(
'
.intro-text
'
).
data
(
'
list
'
)
;
init
()
{
// JavaScript to be fired on the home page
let
$introTarget
=
$
(
'
#intro-variable
'
)
let
introArray
=
$
(
'
.intro-text
'
).
data
(
'
list
'
)
let
index
=
0
;
let
total
=
introArray
.
length
;
changeText
(
3000
)
;
let
index
=
0
let
total
=
introArray
.
length
changeText
(
3000
)
function
changeText
(
timeout
)
{
setTimeout
(()
=>
{
function
changeText
(
timeout
)
{
setTimeout
(()
=>
{
$introTarget
.
toggleClass
(
'
swap-out swap-in
'
)
;
$introTarget
.
toggleClass
(
'
swap-out swap-in
'
)
setTimeout
(()
=>
{
$introTarget
.
toggleClass
(
'
swap-out swap-in
'
)
;
$introTarget
.
text
(
introArray
[
index
])
},
500
)
setTimeout
(()
=>
{
$introTarget
.
toggleClass
(
'
swap-out swap-in
'
)
$introTarget
.
text
(
introArray
[
index
])
},
500
)
index
++
;
if
(
index
===
(
total
))
{
index
=
0
;
}
changeText
(
5000
);
},
timeout
);
index
++
if
(
index
===
(
total
))
{
index
=
0
}
changeText
(
5000
)
},
timeout
)
}
},
finalize
()
{
// JavaScript to be fired on the home page, after the init JS
},
}
;
},
finalize
()
{
// JavaScript to be fired on the home page, after the init JS
},
}
resources/assets/scripts/routes/templateFaq.js
View file @
399af44f
import
{
library
,
dom
}
from
'
@fortawesome/fontawesome-svg-core
'
;
import
{
faChevronRight
,
faSearch
}
from
'
@fortawesome/free-solid-svg-icons
'
;
library
.
add
(
faChevronRight
,
faSearch
);
dom
.
watch
();
import
{
dom
,
library
}
from
'
@fortawesome/fontawesome-svg-core
'
import
{
faChevronRight
,
faSearch
}
from
'
@fortawesome/free-solid-svg-icons
'
library
.
add
(
faChevronRight
,
faSearch
)
dom
.
watch
()
export
default
{
init
()
{
init
()
{
const
kudos_website
=
window
.
kudos_website
const
url
=
kudos_website
.
ajax_url
;
const
site_url
=
kudos_website
.
site_url
;
const
page_name
=
kudos_website
.
page_name
;
const
wpnonce
=
kudos_website
.
nonce
;
const
$main
=
$
(
'
main.main .row
'
)
;
const
$categories
=
$
(
'
.faq-category
'
)
;
const
$searchBox
=
$
(
'
#keyword
'
)
;
const
$body
=
$
(
'
body
'
)
;
const
kudos_website
=
window
.
kudos_website
const
url
=
kudos_website
.
ajax_url
const
site_url
=
kudos_website
.
site_url
const
page_name
=
kudos_website
.
page_name
const
wpnonce
=
kudos_website
.
nonce
const
$main
=
$
(
'
main.main .row
'
)
const
$categories
=
$
(
'
.faq-category
'
)
const
$searchBox
=
$
(
'
#keyword
'
)
const
$body
=
$
(
'
body
'
)
// Search box type action
$searchBox
.
keyup
(
delay
(
function
(
e
)
{
let
keywords
=
$
(
e
.
currentTarget
).
val
()
;
let
category
=
$categories
.
filter
(
'
.current
'
).
data
(
'
category
'
)
;
ajaxRequest
(
category
,
keywords
)
;
},
500
))
;
// Search box type action
$searchBox
.
keyup
(
delay
(
function
(
e
)
{
let
keywords
=
$
(
e
.
currentTarget
).
val
()
let
category
=
$categories
.
filter
(
'
.current
'
).
data
(
'
category
'
)
ajaxRequest
(
category
,
keywords
)
},
500
))
// Category click action
$categories
.
each
(
function
()
{
$
(
this
).
click
(
function
(
e
)
{
e
.
preventDefault
()
;
// Stop if current category
if
(
$
(
e
.
currentTarget
).
hasClass
(
'
current
'
))
{
return
;
}
// Define input
let
category
=
$
(
this
).
data
(
'
category
'
)
;
let
keywords
=
$
(
'
#keyword
'
).
val
()
;
ajaxRequest
(
category
,
keywords
)
;
})
;
$
(
this
).
click
(
function
(
e
)
{
e
.
preventDefault
()
// Stop if current category
if
(
$
(
e
.
currentTarget
).
hasClass
(
'
current
'
))
{
return
}
// Define input
let
category
=
$
(
this
).
data
(
'
category
'
)
let
keywords
=
$
(
'
#keyword
'
).
val
()
ajaxRequest
(
category
,
keywords
)
})
})
function
ajaxRequest
(
category
=
null
,
keywords
=
null
)
{
$
.
ajax
({
type
:
'
POST
'
,
url
:
url
,
dataType
:
'
json
'
,
data
:
{
action
:
'
get_questions
'
,
nonce
:
wpnonce
,
category
:
category
,
keywords
:
keywords
,
},
beforeSend
:
function
()
{
$body
.
addClass
(
'
ajax-loading
'
);
$main
.
fadeTo
(
200
,
0.5
,
'
linear
'
);
history
.
pushState
(
null
,
null
,
site_url
+
'
/
'
+
page_name
+
'
/
'
+
(
category
?
category
+
'
/
'
:
''
))
},
success
:
function
(
response
)
{
$categories
.
removeClass
(
'
btn-outline-primary
'
);
$categories
.
filter
(
'
[data-category="
'
+
category
+
'
"]
'
).
addClass
(
'
btn-outline-primary
'
);
$main
.
html
(
response
);
$main
.
fadeTo
(
200
,
1
,
'
linear
'
);
$body
.
removeClass
(
'
ajax-loading
'
);
},
})
function
ajaxRequest
(
category
=
null
,
keywords
=
null
)
{
$
.
ajax
({
type
:
'
POST
'
,
url
:
url
,
dataType
:
'
json
'
,
data
:
{
action
:
'
get_questions
'
,
nonce
:
wpnonce
,
category
:
category
,
keywords
:
keywords
,
},
beforeSend
:
function
()
{
$body
.
addClass
(
'
ajax-loading
'
)
$main
.
fadeTo
(
200
,
0.5
,
'
linear
'
)
history
.
pushState
(
null
,
null
,
site_url
+
'
/
'
+
page_name
+
'
/
'
+
(
category
?
category
+
'
/
'
:
''
))
},
success
:
function
(
response
)
{
$categories
.
removeClass
(
'
btn-outline-primary
'
)
$categories
.
filter
(
'
[data-category="
'
+
category
+
'
"]
'
).
addClass
(
'
btn-outline-primary
'
)
$main
.
html
(
response
)
$main
.
fadeTo
(
200
,
1
,
'
linear
'
)
$body
.
removeClass
(
'
ajax-loading
'
)
},
})
}
function
delay
(
fn
,
ms
)
{
let
timer
=
0
return
function
(...
args
)
{
clearTimeout
(
timer
)
timer
=
setTimeout
(
fn
.
bind
(
this
,
...
args
),
ms
||
0
)
}
function
delay
(
fn
,
ms
)
{
let
timer
=
0
return
function
(...
args
)
{
clearTimeout
(
timer
)
timer
=
setTimeout
(
fn
.
bind
(
this
,
...
args
),
ms
||
0
)
}
}
},
}
;
},
}
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