import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement: function(){
var _this = this;
var isMouseDown = false,
isHighlighted;
$("#our_table li").mousedown(function () {
isMouseDown = true;
$(this).toggleClass("highlighted");
isHighlighted = $(this).hasClass("highlighted");
_this.sendUpdate();
return false; // prevent text selection
}).mouseover(function () {
if (isMouseDown) {
$(this).toggleClass("highlighted", isHighlighted);
_this.sendUpdate();
}
}).bind("selectstart", function () {
return false;
})
$(document).mouseup(function () {
isMouseDown = false;
});
console.log('test: ', this);
console.log(this.get('route'));
console.log(this.get('router.queryParams'));
},
sendUpdate: function(){
var dateQuery = $('.highlighted').map(function(index, elt) {
return parseInt($(elt).parent().attr('id')) + parseInt($(elt).html());
}).get().join(',');
dateQuery = (dateQuery == "") ? null : dateQuery;
this.sendAction('action', dateQuery);
}
});