author | nowmad@nowmads-macbook-pro.local |
Wed, 20 Jan 2016 23:05:52 +0100 | |
changeset 91 | acfeddc7821d |
parent 81 | 848e4a5ad4d9 |
child 92 | 3437f5191645 |
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 |
|
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
3 |
export default Ember.Component.extend({ |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
4 |
didInsertElement: function(){ |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
5 |
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
|
6 |
|
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
7 |
if (this.get('container').lookup('controller:application').date !== null){ |
81
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
77
diff
changeset
|
8 |
this.highlightQuery(this.get('container').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
|
9 |
} |
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
10 |
|
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
11 |
var isMouseDown = false, |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
12 |
isHighlighted; |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
13 |
$("#our_table li").mousedown(function () { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
14 |
isMouseDown = true; |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
15 |
$(this).toggleClass("highlighted"); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
16 |
isHighlighted = $(this).hasClass("highlighted"); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
17 |
_this.sendUpdate(); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
18 |
return false; // prevent text selection |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
19 |
}).mouseover(function () { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
20 |
if (isMouseDown) { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
21 |
$(this).toggleClass("highlighted", isHighlighted); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
22 |
_this.sendUpdate(); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
23 |
} |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
24 |
}).bind("selectstart", function () { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
25 |
return false; |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
26 |
}) |
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
27 |
|
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
28 |
$(document).mouseup(function () { |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
29 |
isMouseDown = false; |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
30 |
}); |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
31 |
}, |
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
32 |
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
|
33 |
var dateQuery = []; |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
77
diff
changeset
|
34 |
$('.highlighted').map(function(index, elt) { |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
77
diff
changeset
|
35 |
dateQuery.push(parseInt($(elt).parent().attr('id')) + parseInt($(elt).html())); |
848e4a5ad4d9
update date params to be an array of date instead of a string
nowmad@nowmads-macbook-pro.local
parents:
77
diff
changeset
|
36 |
}); |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
37 |
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
|
38 |
}, |
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
39 |
highlightQuery: function(list){ |
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 |
list.map(function(elt, index){ |
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 |
var year = Math.floor(parseInt(elt)/10)*10; |
0889740f79c2
on page load, hilight the objects corresponding to the query params
nowmad@23.1.168.192.in-addr.arpa
parents:
72
diff
changeset
|
42 |
$("#"+year+" ."+(parseInt(elt)-year)).toggleClass("highlighted", true); |
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 |
}); |
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
44 |
} |
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
45 |
}); |