summaryrefslogtreecommitdiff
path: root/public/assets/js/nav.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-26 09:46:55 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-26 09:46:55 +0100
commit0ef7a5e0dc1a156a20ca75c8d75f0a26e814b02d (patch)
treebffc7969e44daa916c3751ff7429a3a860f06c4c /public/assets/js/nav.js
parentfc37dac763fcc9011121cfad2e91493521ebd0dc (diff)
scrubbing design
Diffstat (limited to 'public/assets/js/nav.js')
-rw-r--r--public/assets/js/nav.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/public/assets/js/nav.js b/public/assets/js/nav.js
index ca231fe..bfddc2c 100644
--- a/public/assets/js/nav.js
+++ b/public/assets/js/nav.js
@@ -11,18 +11,18 @@ var NavView = View.extend({
"click .refresh": "refresh",
"click .random": "random",
},
-
+
initialize: function(){
this.id = -1
this.$pip = this.$("#pip")
this.$pip_img = this.$("#pip img")
this.$image = this.$("#luckyimage")
-
+
$(window).on("keydown", this.keydown.bind(this))
$(document).ajaxError(function(){
this.fetching = false
}.bind(this))
-
+
window.onpopstate = function(event) {
this.display(event.state)
}.bind(this)
@@ -34,7 +34,7 @@ var NavView = View.extend({
else {
this.latest()
}
-
+
$(".prev").on("touchstart", function(){
console.log("<<<<<PREV")
})
@@ -42,7 +42,7 @@ var NavView = View.extend({
console.log("<<<<<CLICKPREV")
})
},
-
+
keydown: function(e){
if (e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) { return }
switch (e.keyCode) {
@@ -60,34 +60,34 @@ var NavView = View.extend({
break
}
},
-
+
latest: function(){
if (this.fetching) return
this.fetch("latest")
this.onLatest = true
},
-
+
prev: function(){
if (this.fetching) return
if (this.id - 1 < 1) { return }
this.fetch(this.id-1)
},
-
+
next: function(){
if (this.fetching) return
if (this.onLatest || this.id < 1) { return }
this.fetch(this.id+1)
},
-
+
random: function(){
if (this.fetching) return
this.fetch("random")
},
-
+
fetch: function(id){
this.fetching = true
this.onLatest = false
- $.get("/get/" + id, function(data){
+ $.get("/p/get/" + id, function(data){
this.fetching = false
this.display(data)
history.pushState(data, document.title, "/p/" + data.id)
@@ -108,7 +108,7 @@ var NavView = View.extend({
}
this.$image.css("background-image", "url(" + data.url + ")")
},
-
+
link: function(){
window.open(this.data.url, "_blank")
},