source: Dev/branches/rest-dojo-ui/client/dojox/embed/Object.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.9 KB
Line 
1define([
2        "dojo/_base/kernel",
3        "dojo/_base/declare",   // dojo.declare
4        "dojo/dom-geometry",
5        "dijit/_Widget",
6        "./Flash",
7        "./Quicktime"
8], function (dojo, declare, domGeometry, _Widget, Flash, Quicktime) {
9dojo.experimental("dojox.embed.Object");
10
11return dojo.declare("dojox.embed.Object", _Widget, {
12        //      summary:
13        //              A widget you can use to embed either a Flash or Quicktime
14        //              movie.
15        //
16        //      example:
17        //      From markup:
18        //      |       <div dojoType="dojox.embed.Object" src="path/to/movie.swf"></div>
19        //
20        //      example:
21        //      Programmatic:
22        //      |       var mov=new dojox.embed.Object({
23        //      |               src: "path/to/movie.swf"
24        //      |       }, node);
25        //
26        //      width: Number?
27        //              The width of the movie. If not provided, the width of this.domNode is used.
28        //      height: Number?
29        //              The height of the movie. If not provided, the height of this.domNode is used.
30        //      src: String
31        //              The URL of the movie to embed.
32        //      movie: HTMLEmbed
33        //              The eventual reference to the movie embedded.  If you are looking to script
34        //              control over the movie, you'd access it this way.
35        //      params: Object
36        //              A property bag that is created postCreate.  Any additional attributes you
37        //              define on your domNode will be collected and placed into this, which will
38        //              then be passed to the movie constructor.
39        //      reFlash: RegExp
40        //              Expression used on the src property to determine if this is Flash or Quicktime.
41        //      reQtMovie: RegExp
42        //              Expression used on the src property to determine if this is Flash or Quicktime.
43        //      reQtAudio: RegExp
44        //              Expression used on the src property to determine if this is Flash or Quicktime.
45       
46        width: 0,
47        height: 0,
48        src: "",
49        movie: null,
50        params: null,
51
52        reFlash: /\.swf|\.flv/gi,
53        reQtMovie: /\.3gp|\.avi|\.m4v|\.mov|\.mp4|\.mpg|\.mpeg|\.qt/gi,
54        reQtAudio:/\.aiff|\.aif|\.m4a|\.m4b|\.m4p|\.midi|\.mid|\.mp3|\.mpa|\.wav/gi,
55       
56        postCreate: function(){
57                //      summary
58                //              Constructs the movie and places it in the document.
59                if(!this.width || !this.height){
60                        //      get the width and height from the domNode
61                        var box=domGeometry.getMarginBox(this.domNode);
62                        this.width=box.w, this.height=box.h;
63                }
64
65                //      the default embed constructor.
66                var em=Flash;
67
68                //      figure out what kind of movie this is.
69                if(this.src.match(this.reQtMovie) || this.src.match(this.reQtAudio)){
70                        em=Quicktime;
71                }
72
73                //      loop through any attributes and set up our params object.
74                if(!this.params){
75                        this.params={};
76                        if(this.domNode.hasAttributes()){
77                                // ignore list
78                                var ignore = {
79                                        dojoType: "",
80                                        width: "",
81                                        height: "",
82                                        "class": "",
83                                        style: "",
84                                        id: "",
85                                        src: ""
86                                };
87
88                                var attrs=this.domNode.attributes;
89                                for(var i=0, l=attrs.length; i<l; i++){
90                                        if(!ignore[attrs[i].name]){
91                                                this.params[attrs[i].name]=attrs[i].value;
92                                        }
93                                }
94                        }
95                }
96
97                //      set up our arguments.
98                var kwArgs={
99                        path: this.src,
100                        width: this.width,
101                        height: this.height,
102                        params: this.params
103                };
104
105                //      set up the movie.
106                this.movie=new (em)(kwArgs, this.domNode);
107        }
108});
109});
Note: See TracBrowser for help on using the repository browser.