author | ymh <ymh.work@gmail.com> |
Mon, 25 Apr 2016 13:21:42 +0200 | |
changeset 156 | 7203efa0ddbf |
parent 120 | e5e15547ffb1 |
child 189 | 21b30ee23191 |
permissions | -rw-r--r-- |
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
1 |
import Ember from 'ember'; |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
2 |
|
120 | 3 |
const { getOwner } = Ember; |
4 |
||
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
5 |
export default Ember.Component.extend({ |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
6 |
didInsertElement: function(){ |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
7 |
var _this = this; |
77
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
8 |
|
120 | 9 |
if (getOwner(this).lookup('controller:application').date !== null){ |
10 |
this.highlightQuery(getOwner(this).lookup('controller:application').date); |
|
77
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
11 |
} |
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
12 |
|
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
13 |
var isMouseDown = false, |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
14 |
isHighlighted; |
98
2e6bfce6f99c
add details tab for perma-link to documents
nowmad@23.1.168.192.in-addr.arpa
parents:
92
diff
changeset
|
15 |
Ember.$("#chrono-table li").mousedown(function () { |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
16 |
isMouseDown = true; |
92 | 17 |
Ember.$(this).toggleClass("highlighted"); |
18 |
isHighlighted = Ember.$(this).hasClass("highlighted"); |
|
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
19 |
_this.sendUpdate(); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
20 |
return false; // prevent text selection |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
21 |
}).mouseover(function () { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
22 |
if (isMouseDown) { |
92 | 23 |
Ember.$(this).toggleClass("highlighted", isHighlighted); |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
24 |
_this.sendUpdate(); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
25 |
} |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
26 |
}).bind("selectstart", function () { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
27 |
return false; |
92 | 28 |
}); |
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
29 |
|
92 | 30 |
Ember.$(document).mouseup(function () { |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
31 |
isMouseDown = false; |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
32 |
}); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
33 |
}, |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
34 |
sendUpdate: function(){ |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
77
diff
changeset
|
35 |
var dateQuery = []; |
92 | 36 |
Ember.$('.highlighted').map(function(index, elt) { |
37 |
dateQuery.push(parseInt(Ember.$(elt).parent().attr('id')) + parseInt(Ember.$(elt).html())); |
|
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
77
diff
changeset
|
38 |
}); |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
39 |
this.sendAction('action', dateQuery); |
77
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
40 |
}, |
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
41 |
highlightQuery: function(list){ |
92 | 42 |
list.map(function(elt){ |
77
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
43 |
var year = Math.floor(parseInt(elt)/10)*10; |
92 | 44 |
Ember.$("#"+year+" ."+(parseInt(elt)-year)).toggleClass("highlighted", true); |
77
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
45 |
}); |
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
46 |
} |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
47 |
}); |