1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
var projectListTimeout = null
window.fuck = 'suck'
var ProjectList = View.extend({
el: ".projectList",
events: {
"click .viewMore": 'viewMore',
"mouseenter .room": 'enter',
"mouseleave .room": 'leave',
},
initialize: function(){
this.$viewMore = this.$(".viewMore")
this.$(".images").each(function(){
$divs = $(this).children("div")
$divs.hide()
$divs.first().show()
$(this).data("index", 0)
})
},
timeout: null,
enter: function(e){
clearTimeout(projectListTimeout)
this.advance(e.currentTarget)
},
leave: function(e){
clearTimeout(projectListTimeout)
var $divs = $(e.currentTarget).find(".images div")
$divs.hide()
$divs.eq(0).show()
},
advance: function(el){
projectListTimeout = setTimeout(function(){
this.advance(el)
}.bind(this), 500)
var $images = $(el).find(".images")
var $divs = $images.children("div")
var index = $images.data("index")
var nextIndex = (index + 1) % $divs.length
$divs.eq(index).hide()
$divs.eq(nextIndex).show()
$images.data("index", nextIndex)
},
viewMore: function(e){
e.preventDefault()
var criteria = {}
criteria.offset = this.$(".projectItem").length
if (window.location.pathname == "/" || window.location.pathname.match("/home")) {
criteria.home = 1
}
else {
criteria.user_id = this.$(".projectItem").first().data("userid")
}
$.get("/api/project/paginate", criteria, function(data){
var offset = this.$viewMore.offset()
var $data = $(data)
var $els = $data.find(".projectItem")
$els.insertBefore( this.$viewMore )
if (! $data.find(".viewMore").length) {
this.$viewMore.hide()
}
$("body,html").animate({ scrollTop: offset.top - 80 }, 300)
}.bind(this))
},
/*
spinOn: function(e){
var iframe = $(e.currentTarget).find("iframe").get('0')
if (! iframe) return
iframe.contentWindow.postMessage("spin-on", window.location.origin)
},
spinOff: function(e){
var iframe = $(e.currentTarget).find("iframe").get('0')
if (! iframe) return
iframe.contentWindow.postMessage("spin-off", window.location.origin)
}
*/
})
|