src/js/init.js
branchnew-model
changeset 874 38b65761a7d5
parent 870 2c025db10a10
child 875 43629caa77bc
equal deleted inserted replaced
872:d777d05a16e4 874:38b65761a7d5
    38         }
    38         }
    39     }
    39     }
    40 
    40 
    41     /* widget specific requirements */
    41     /* widget specific requirements */
    42     for(var _i = 0; _i < this.config.gui.widgets.length; _i++) {
    42     for(var _i = 0; _i < this.config.gui.widgets.length; _i++) {
    43         if(this.config.gui.widgets[_i].type === "PolemicWidget" || this.config.gui.widgets[_i].type === "StackGraphWidget" || this.config.gui.widgets[_i].type === "SparklineWidget") {
    43         if(this.config.gui.widgets[_i].type === "StackGraphWidget" || this.config.gui.widgets[_i].type === "SparklineWidget") {
    44             $L.script(IriSP.getLib("raphael"));
    44             $L.script(IriSP.getLib("raphael"));
    45         }
    45         }
    46         if(this.config.gui.widgets[_i].type === "TraceWidget") {
    46         if(this.config.gui.widgets[_i].type === "TraceWidget") {
    47             $L.script(IriSP.getLib("tracemanager"))
    47             $L.script(IriSP.getLib("tracemanager"))
    48         }
    48         }
   102         _this.onVideoDataLoaded();
   102         _this.onVideoDataLoaded();
   103     });
   103     });
   104 }
   104 }
   105 
   105 
   106 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() {
   106 IriSP.Metadataplayer.prototype.onVideoDataLoaded = function() {
   107     console.log("Video Data Loaded");
       
   108     if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") {
   107     if (typeof this.videoData !== "undefined" && typeof this.config.player.video === "undefined") {
   109         var _media = this.videoData.currentMedia;
   108         var _media = this.videoData.currentMedia;
   110         console.log(_media);
       
   111         if (typeof _media !== "undefined") {
   109         if (typeof _media !== "undefined") {
   112             this.config.player.video = _media.video;
   110             this.config.player.video = _media.video;
   113             if (typeof _media.streamer !== "undefined") {
   111             if (typeof _media.streamer !== "undefined") {
   114                 this.config.player.streamer = _media.streamer;
   112                 this.config.player.streamer = _media.streamer;
   115                 this.config.player.video = _media.video.replace(_media.streamer,'');
   113                 this.config.player.video = _media.video.replace(_media.streamer,'');
   117         }
   115         }
   118         
   116         
   119     }
   117     }
   120     this.configurePopcorn();
   118     this.configurePopcorn();
   121     this.widgets = [];
   119     this.widgets = [];
   122     console.log("Now instantiating widgets");
       
   123     for(var i = 0; i < this.config.gui.widgets.length; i++) {
   120     for(var i = 0; i < this.config.gui.widgets.length; i++) {
   124         var _widget = this.config.gui.widgets[i];
   121         var _widget = this.config.gui.widgets[i];
   125         if (typeof IriSP[_widget.type] !== "undefined") {
   122         if (typeof IriSP[_widget.type] !== "undefined") {
   126             this.widgets.push(new IriSP[_widget.type](this, _widget));
   123             this.widgets.push(new IriSP[_widget.type](this, _widget));
   127         } else {
   124         } else {
   128             console.log("Error, Call to Undefined Widget Type");
   125             console.log("Error, Call to Undefined Widget Type : "+_widget.type);
   129         }
   126         }
   130     };
   127     };
   131     this.$.find('.Ldt-loader').detach();
   128     this.$.find('.Ldt-loader').detach();
   132 }
   129 }
   133 
   130 
   134 IriSP.Metadataplayer.prototype.configurePopcorn = function() {
   131 IriSP.Metadataplayer.prototype.configurePopcorn = function() {
   135     var pop,
   132     var pop,
   136         ret = this.layoutDivs("video"),
   133         ret = this.layoutDivs("video"),
   137         containerDiv = ret[0],
   134         containerDiv = ret[0],
   138         spacerDiv = ret[1];
   135         spacerDiv = ret[1];
   139 
       
   140     /* insert one pixel of margin between the video and the first widget,
       
   141      * using the spacer.
       
   142      */
       
   143     IriSP.jQuery("#" + spacerDiv).css("height", Math.max(1, this.config.gui.spacer_div_height) + "px");
       
   144     
       
   145     console.log(this.config.player);
       
   146 
   136 
   147     switch(this.config.player.type) {
   137     switch(this.config.player.type) {
   148         /*
   138         /*
   149          todo : dynamically create the div/video tag which
   139          todo : dynamically create the div/video tag which
   150          will contain the video.
   140          will contain the video.
   215     if (typeof(_name) === "undefined") {
   205     if (typeof(_name) === "undefined") {
   216        _name = "";
   206        _name = "";
   217     }
   207     }
   218     var newDiv = IriSP._.uniqueId(this.config.gui.container + "_widget_" + _name + "_"),
   208     var newDiv = IriSP._.uniqueId(this.config.gui.container + "_widget_" + _name + "_"),
   219         spacerDiv = IriSP._.uniqueId("LdtPlayer_spacer_"),
   209         spacerDiv = IriSP._.uniqueId("LdtPlayer_spacer_"),
   220         divTempl = "<div id='{{id}}' style='width: {{width}}px; position: relative; clear: both;'></div>",
   210         divHtml = IriSP.jQuery('<div>')
   221         spacerTempl = "<div id='{{spacer_id}}' style='width: {{width}}px; position: relative; height: {{spacer_div_height}}px;'></div>",
   211             .attr("id",newDiv)
   222         divHtml = Mustache.to_html( divTempl,
   212             .css({
   223             {
   213                 width: this.config.gui.width + "px",
   224                 id: newDiv,
   214                 position: "relative",
   225                 width: this.config.gui.width
   215                 clear: "both"
   226             }),
   216             }),
   227         spacerHtml = Mustache.to_html( spacerTempl,
   217         spacerHtml = IriSP.jQuery('<div>')
   228             {
   218             .attr("id",spacerDiv)
   229                 spacer_id: spacerDiv,
   219             .css({
   230                 width: this.config.gui.width,
   220                 width: this.config.gui.width + "px",
   231                 spacer_div_height: this.config.gui.spacer_div_height
   221                 height: this.config.gui.spacer_div_height + "px",
       
   222                 position: "relative",
       
   223                 clear: "both"
   232             });
   224             });
   233             
   225             
   234     this.$.append(divHtml);
   226     this.$.append(divHtml);
   235     this.$.append(spacerHtml);
   227     this.$.append(spacerHtml);
   236 
   228