author | nowmad@23.1.168.192.in-addr.arpa |
Fri, 22 Jan 2016 13:15:47 +0100 | |
changeset 98 | 2e6bfce6f99c |
parent 92 | 3437f5191645 |
child 120 | e5e15547ffb1 |
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; |
98
2e6bfce6f99c
add details tab for perma-link to documents
nowmad@23.1.168.192.in-addr.arpa
parents:
92
diff
changeset
|
13 |
Ember.$("#chrono-table li").mousedown(function () { |
54
5b2b161dd4ce
bind chono visu with query parameters
nowmad@nowmads-macbook-pro.local
parents:
48
diff
changeset
|
14 |
isMouseDown = true; |
92 | 15 |
Ember.$(this).toggleClass("highlighted"); |
16 |
isHighlighted = Ember.$(this).hasClass("highlighted"); |
|
54
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) { |
92 | 21 |
Ember.$(this).toggleClass("highlighted", isHighlighted); |
54
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; |
92 | 26 |
}); |
48
9ef0952033e0
add example of visualisation for "chonologie"
nowmad@nowmads-macbook-pro.local
parents:
diff
changeset
|
27 |
|
92 | 28 |
Ember.$(document).mouseup(function () { |
54
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 = []; |
92 | 34 |
Ember.$('.highlighted').map(function(index, elt) { |
35 |
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
|
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){ |
92 | 40 |
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
|
41 |
var year = Math.floor(parseInt(elt)/10)*10; |
92 | 42 |
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
|
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 |
}); |