cms/app-client/app/components/visu-chrono.js
changeset 92 3437f5191645
parent 81 848e4a5ad4d9
child 98 2e6bfce6f99c
equal deleted inserted replaced
91:acfeddc7821d 92:3437f5191645
     8       this.highlightQuery(this.get('container').lookup('controller:application').date);
     8       this.highlightQuery(this.get('container').lookup('controller:application').date);
     9     }
     9     }
    10 
    10 
    11     var isMouseDown = false,
    11     var isMouseDown = false,
    12       isHighlighted;
    12       isHighlighted;
    13     $("#our_table li").mousedown(function () {
    13     Ember.$("#our_table li").mousedown(function () {
    14       isMouseDown = true;
    14       isMouseDown = true;
    15       $(this).toggleClass("highlighted");
    15       Ember.$(this).toggleClass("highlighted");
    16       isHighlighted = $(this).hasClass("highlighted");
    16       isHighlighted = Ember.$(this).hasClass("highlighted");
    17       _this.sendUpdate();
    17       _this.sendUpdate();
    18       return false; // prevent text selection
    18       return false; // prevent text selection
    19     }).mouseover(function () {
    19     }).mouseover(function () {
    20       if (isMouseDown) {
    20       if (isMouseDown) {
    21         $(this).toggleClass("highlighted", isHighlighted);
    21         Ember.$(this).toggleClass("highlighted", isHighlighted);
    22         _this.sendUpdate();
    22         _this.sendUpdate();
    23       }
    23       }
    24     }).bind("selectstart", function () {
    24     }).bind("selectstart", function () {
    25       return false;
    25       return false;
    26     })
    26     });
    27 
    27 
    28     $(document).mouseup(function () {
    28     Ember.$(document).mouseup(function () {
    29       isMouseDown = false;
    29       isMouseDown = false;
    30     });
    30     });
    31   },
    31   },
    32   sendUpdate: function(){
    32   sendUpdate: function(){
    33     var dateQuery = [];
    33     var dateQuery = [];
    34     $('.highlighted').map(function(index, elt) {
    34     Ember.$('.highlighted').map(function(index, elt) {
    35       dateQuery.push(parseInt($(elt).parent().attr('id')) + parseInt($(elt).html()));
    35       dateQuery.push(parseInt(Ember.$(elt).parent().attr('id')) + parseInt(Ember.$(elt).html()));
    36     });
    36     });
    37     this.sendAction('action', dateQuery);
    37     this.sendAction('action', dateQuery);
    38   },
    38   },
    39   highlightQuery: function(list){
    39   highlightQuery: function(list){
    40     list.map(function(elt, index){
    40     list.map(function(elt){
    41       var year = Math.floor(parseInt(elt)/10)*10;
    41       var year = Math.floor(parseInt(elt)/10)*10;
    42       $("#"+year+" ."+(parseInt(elt)-year)).toggleClass("highlighted", true);
    42       Ember.$("#"+year+" ."+(parseInt(elt)-year)).toggleClass("highlighted", true);
    43     });
    43     });
    44   }
    44   }
    45 });
    45 });