Debian Codegraph @

dojox/embed/Object.js

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