src/js/widgets/arrowWidget.js
author hamidouk
Wed, 23 Nov 2011 15:45:41 +0100
branchpopcorn-port
changeset 313 7df805ebb75e
parent 305 e8d05c3f77ed
child 321 21d840371c6b
permissions -rw-r--r--
fixed some rounding errrors in segmentsWidget.js and animated the arrow and added a position fix to the arrowWidget.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
299
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     1
IriSP.ArrowWidget = function(Popcorn, config, Serializer) {
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     2
  IriSP.Widget.call(this, Popcorn, config, Serializer);
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     3
  
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     4
};
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     5
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     6
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     7
IriSP.ArrowWidget.prototype = new IriSP.Widget();
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     8
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
     9
IriSP.ArrowWidget.prototype.clear = function() {
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    10
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    11
};
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    12
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    13
IriSP.ArrowWidget.prototype.clearWidget = function() {
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    14
};
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    15
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    16
IriSP.ArrowWidget.prototype.draw = function() {
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    17
  var templ = Mustache.to_html(IriSP.arrowWidget_template, {});
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    18
  this.selector.append(templ);
305
e8d05c3f77ed created an arrow widget.
hamidouk
parents: 299
diff changeset
    19
  this._Popcorn.listen("IriSP.SegmentsWidget.segmentClick", IriSP.wrap(this, this.segmentClickHandler));
299
d2005f747d5a added a new widget, the arrowWidget.
hamidouk
parents:
diff changeset
    20
};
305
e8d05c3f77ed created an arrow widget.
hamidouk
parents: 299
diff changeset
    21
e8d05c3f77ed created an arrow widget.
hamidouk
parents: 299
diff changeset
    22
IriSP.ArrowWidget.prototype.segmentClickHandler = function(percents) {
313
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    23
 // we need to apply a fix because the arrow has a certain length
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    24
 // it's half the length of the arrow (27 / 2). We need to convert
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    25
 // it in percents though.
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    26
 var totalWidth = this.selector.width();
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    27
 var correction = ((27 / 2) / totalWidth) * 100;
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    28
 var corrected_percents = percents - correction;
7df805ebb75e fixed some rounding errrors in segmentsWidget.js and animated the arrow and added
hamidouk
parents: 305
diff changeset
    29
 this.selector.children(".Ldt-arrowWidget").animate({"left" : corrected_percents + "%"});
305
e8d05c3f77ed created an arrow widget.
hamidouk
parents: 299
diff changeset
    30
}