src/js/widgets.js
branchnew-model
changeset 924 64c2eaafe5e2
parent 922 096c06aea8b5
child 927 977a39c4ee80
equal deleted inserted replaced
923:b3ee7d1b472a 924:64c2eaafe5e2
    52    
    52    
    53     /* Adding classes and html attributes */
    53     /* Adding classes and html attributes */
    54     this.$ = IriSP.jQuery('#' + this.container);
    54     this.$ = IriSP.jQuery('#' + this.container);
    55     this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
    55     this.$.addClass("Ldt-TraceMe Ldt-Widget").attr("widget-type", _type);
    56     
    56     
    57     /* Does the widget require other widgets ? */
       
    58     if (typeof this.requires !== "undefined") {
       
    59         for (var _i = 0; _i < this.requires.length; _i++) {
       
    60             var _subconfig = this.requires[_i];
       
    61             _subconfig.container = IriSP._.uniqueId(this.container + '_' + _subconfig.type + '_');
       
    62             this.$.append(IriSP.jQuery('<div>').attr("id",_subconfig.container));
       
    63             this.player.loadWidget(_subconfig, function(_widget) {
       
    64                 _this[_subconfig.type.replace(/^./,function(_s){return _s.toLowerCase();})] = _widget
       
    65             });
       
    66         }
       
    67     }
       
    68     
       
    69     this.l10n = (
    57     this.l10n = (
    70         typeof this.messages[IriSP.language] !== "undefined"
    58         typeof this.messages[IriSP.language] !== "undefined"
    71         ? this.messages[IriSP.language]
    59         ? this.messages[IriSP.language]
    72         : (
    60         : (
    73             IriSP.language.length > 2 && typeof this.messages[IriSP.language.substr(0,2)] !== "undefined"
    61             IriSP.language.length > 2 && typeof this.messages[IriSP.language.substr(0,2)] !== "undefined"
   118     return this.getWidgetAnnotations().filter(function(_annotation) {
   106     return this.getWidgetAnnotations().filter(function(_annotation) {
   119         return _annotation.begin <= _time && _annotation.end > _time;
   107         return _annotation.begin <= _time && _annotation.end > _time;
   120     });
   108     });
   121 }
   109 }
   122 
   110 
       
   111 IriSP.Widgets.Widget.prototype.insertSubwidget = function(_selector, _propname, _widgetoptions) {
       
   112     var _id = _selector.attr("id"),
       
   113         _this = this;
       
   114     if (typeof _id == "undefined") {
       
   115         _id = IriSP._.uniqueId(this.container + '_sub_widget_' + _widgetoptions.type);
       
   116         _selector.attr("id", _id);
       
   117     }
       
   118     _widgetoptions.container = _id;
       
   119     _this.player.loadWidget(_widgetoptions, function(_widget) {
       
   120         _this[_propname] = _widget;
       
   121     });
       
   122 }
       
   123 
   123 /**
   124 /**
   124  * This method responsible of drawing a widget on screen.
   125  * This method responsible of drawing a widget on screen.
   125  */
   126  */
   126 IriSP.Widgets.Widget.prototype.draw = function() {
   127 IriSP.Widgets.Widget.prototype.draw = function() {
   127     /* implemented by "sub-classes" */
   128     /* implemented by "sub-classes" */