src/js/widgets/annotationsListWidget.js
branchpopcorn-port
changeset 629 b13bcfd2f9b1
parent 621 170a8cd859d5
child 642 37693f217f8c
equal deleted inserted replaced
628:55282f5ef477 629:b13bcfd2f9b1
     9 
     9 
    10 IriSP.AnnotationsListWidget.prototype.clear = function() {
    10 IriSP.AnnotationsListWidget.prototype.clear = function() {
    11 };
    11 };
    12 
    12 
    13 IriSP.AnnotationsListWidget.prototype.clearWidget = function() {
    13 IriSP.AnnotationsListWidget.prototype.clearWidget = function() {
       
    14 };
       
    15 
       
    16 /** effectively redraw the widget - called by drawList */
       
    17 IriSP.AnnotationsListWidget.prototype.do_redraw = function(list) {
       
    18     var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
       
    19     this.selector.html(widgetMarkup);
    14 };
    20 };
    15 
    21 
    16 /** draw the annotation list */
    22 /** draw the annotation list */
    17 IriSP.AnnotationsListWidget.prototype.drawList = function(force_redraw) {
    23 IriSP.AnnotationsListWidget.prototype.drawList = function(force_redraw) {
    18   var _this = this;
    24   var _this = this;
    54   }
    60   }
    55   
    61   
    56   var idList = IriSP.underscore.pluck(list, "id").sort();
    62   var idList = IriSP.underscore.pluck(list, "id").sort();
    57   
    63   
    58   if (idList.length !== this.__oldList.length) {
    64   if (idList.length !== this.__oldList.length) {
    59     var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
    65     this.do_redraw(list);
    60     this.selector.html(widgetMarkup);
       
    61   }
    66   }
    62     
    67     
    63   var res = 1;
    68   var res = 1;
    64   for (var i = 0; i < idList.length; i++) {
    69   for (var i = 0; i < idList.length; i++) {
    65     if (idList[i] !== this.__oldList[i])
    70     if (idList[i] !== this.__oldList[i])
    69   
    74   
    70   this.__oldList = idList; /* save for next call */
    75   this.__oldList = idList; /* save for next call */
    71 
    76 
    72   if (typeof(force_redraw) !== "undefined") {
    77   if (typeof(force_redraw) !== "undefined") {
    73     console.log("forced redraw");
    78     console.log("forced redraw");
    74     var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
    79     this.do_redraw(list);
    75     this.selector.html(widgetMarkup);
       
    76   }
    80   }
    77   
    81   
    78   /* the two lists are equal, no need to redraw */
    82   /* the two lists are equal, no need to redraw */
    79   if (res === 1) {
    83   if (res === 1) {
    80     return;
    84     return;
    81   } else {
    85   } else {
    82     var widgetMarkup = IriSP.templToHTML(IriSP.annotationsListWidget_template, {annotations: list});
    86     this.do_redraw(list);
    83     this.selector.html(widgetMarkup);
       
    84   }
    87   }
    85   
    88   
    86 };
    89 };
    87 
    90 
    88 IriSP.AnnotationsListWidget.prototype.draw = function() {
    91 IriSP.AnnotationsListWidget.prototype.draw = function() {