Index: branches/MwEmbedStandAlone/mwEmbed.js |
— | — | @@ -2571,23 +2571,16 @@ |
2572 | 2572 | * that mwEmbed interfaces can support async built out and the include of |
2573 | 2573 | * jQuery. |
2574 | 2574 | */ |
2575 | | -var mwDomIsReady = false; |
2576 | | -function runMwDomReady(){ |
2577 | | - mwDomIsReady = true; |
2578 | | - if( mw.domReady ){ |
2579 | | - mw.domReady(); |
2580 | | - } |
2581 | | -} |
2582 | 2575 | // Check if already ready: |
2583 | 2576 | if ( document.readyState === "complete" ) { |
2584 | | - runMwDomReady(); |
| 2577 | + mw.domReady(); |
2585 | 2578 | } |
2586 | 2579 | |
2587 | 2580 | // Cleanup functions for the document ready method |
2588 | 2581 | if ( document.addEventListener ) { |
2589 | 2582 | DOMContentLoaded = function() { |
2590 | 2583 | document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
2591 | | - runMwDomReady(); |
| 2584 | + mw.domReady(); |
2592 | 2585 | }; |
2593 | 2586 | |
2594 | 2587 | } else if ( document.attachEvent ) { |
— | — | @@ -2596,7 +2589,7 @@ |
2597 | 2590 | // (ticket #5443). |
2598 | 2591 | if ( document.readyState === "complete" ) { |
2599 | 2592 | document.detachEvent( "onreadystatechange", DOMContentLoaded ); |
2600 | | - runMwDomReady(); |
| 2593 | + mw.domReady(); |
2601 | 2594 | } |
2602 | 2595 | }; |
2603 | 2596 | } |
— | — | @@ -2615,7 +2608,7 @@ |
2616 | 2609 | document.attachEvent("onreadystatechange", DOMContentLoaded); |
2617 | 2610 | |
2618 | 2611 | // A fallback to window.onload, that will always work |
2619 | | - window.attachEvent( "onload", runMwDomReady ); |
| 2612 | + window.attachEvent( "onload", mw.domReady ); |
2620 | 2613 | |
2621 | 2614 | // If IE and not a frame |
2622 | 2615 | // continually check to see if the document is ready |
— | — | @@ -2631,10 +2624,6 @@ |
2632 | 2625 | } |
2633 | 2626 | // The DOM ready check for Internet Explorer |
2634 | 2627 | function doScrollCheck() { |
2635 | | - if ( mwDomIsReady ) { |
2636 | | - return; |
2637 | | - } |
2638 | | - |
2639 | 2628 | try { |
2640 | 2629 | // If IE is used, use the trick by Diego Perini |
2641 | 2630 | // http://javascript.nwbox.com/IEContentLoaded/ |
— | — | @@ -2643,9 +2632,7 @@ |
2644 | 2633 | setTimeout( doScrollCheck, 1 ); |
2645 | 2634 | return; |
2646 | 2635 | } |
2647 | | - |
2648 | | - // and execute any waiting functions |
2649 | | - runMwDomReady(); |
| 2636 | + mw.domReady(); |
2650 | 2637 | } |
2651 | 2638 | |
2652 | 2639 | |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -1516,7 +1516,7 @@ |
1517 | 1517 | // |
1518 | 1518 | // NOTE: browsers that do support height width should set "waitForMeta" |
1519 | 1519 | // flag in addElement |
1520 | | - if( ( isNaN( this.height ) && isNaN( this.width ) ) || |
| 1520 | + if( ( isNaN( this.height )|| isNaN( this.width ) ) || |
1521 | 1521 | ( this.height == -1 || this.width == -1 ) || |
1522 | 1522 | // Check for firefox defaults |
1523 | 1523 | // Note: ideally firefox would not do random guesses at css |
— | — | @@ -1524,7 +1524,9 @@ |
1525 | 1525 | ( (this.height == 150 || this.height == 64 ) && this.width == 300 ) |
1526 | 1526 | ) { |
1527 | 1527 | var defaultSize = mw.getConfig( 'EmbedPlayer.DefaultSize' ).split( 'x' ); |
1528 | | - this.width = defaultSize[0]; |
| 1528 | + if( isNaN( this.width ) ){ |
| 1529 | + this.width = defaultSize[0]; |
| 1530 | + } |
1529 | 1531 | |
1530 | 1532 | // Special height default for audio tag ( if not set ) |
1531 | 1533 | if( element.tagName.toLowerCase() == 'audio' ) { |
— | — | @@ -1532,8 +1534,7 @@ |
1533 | 1535 | }else{ |
1534 | 1536 | this.height = defaultSize[1]; |
1535 | 1537 | } |
1536 | | - } |
1537 | | - |
| 1538 | + } |
1538 | 1539 | }, |
1539 | 1540 | /** |
1540 | 1541 | * Resize the player to a new size preserving aspect ratio Wraps the |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerKplayer.js |
— | — | @@ -1,50 +1,49 @@ |
2 | 2 | /* |
3 | | -* The "kaltura player" embedPlayer interface for fallback h.264 and flv video format support |
4 | | -*/ |
| 3 | + * The "kaltura player" embedPlayer interface for fallback h.264 and flv video format support |
| 4 | + */ |
5 | 5 | |
6 | 6 | // Called from the kdp.swf |
7 | | -function jsInterfaceReadyFunc(){ |
| 7 | +function jsInterfaceReadyFunc() { |
8 | 8 | return true; |
9 | 9 | } |
10 | 10 | |
11 | | - |
12 | 11 | mw.EmbedPlayerKplayer = { |
13 | | - |
14 | | - // Instance name: |
15 | | - instanceOf:'Kplayer', |
16 | | - |
17 | | - // List of supported features: |
18 | | - supports: { |
| 12 | + |
| 13 | + // Instance name: |
| 14 | + instanceOf : 'Kplayer', |
| 15 | + |
| 16 | + // List of supported features: |
| 17 | + supports : { |
19 | 18 | 'playHead' : true, |
20 | | - 'pause' : true, |
| 19 | + 'pause' : true, |
21 | 20 | 'stop' : true, |
22 | 21 | 'timeDisplay' : true, |
23 | 22 | 'volumeControl' : true, |
24 | 23 | 'overlays' : true, |
25 | 24 | 'fullscreen' : true |
26 | 25 | }, |
27 | | - |
| 26 | + |
28 | 27 | // Stores the current time as set from flash |
29 | 28 | flashCurrentTime : 0, |
30 | | - |
| 29 | + |
31 | 30 | /* |
32 | | - * Write the Embed html to the target |
33 | | - */ |
34 | | - doEmbedHTML : function () { |
35 | | - var _this = this; |
36 | | - |
37 | | - mw.log("kPlayer:: embed src::" + _this.getSrc() ); |
| 31 | + * Write the Embed html to the target |
| 32 | + */ |
| 33 | + doEmbedHTML : function() { |
| 34 | + var _this = this; |
| 35 | + |
| 36 | + mw.log("kPlayer:: embed src::" + _this.getSrc()); |
38 | 37 | var flashvars = {}; |
39 | 38 | flashvars.autoPlay = "true"; |
40 | | - var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player'; |
41 | | - flashvars.entryId = mw.absoluteUrl( _this.getSrc() ); |
42 | | - |
43 | | - // Use a relative url if the protocal is file:// |
44 | | - if( mw.parseUri( document.URL).protocol == 'file' ) { |
45 | | - playerPath = mw.getRelativeMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player'; |
46 | | - flashvars.entryId = _this.getSrc(); |
| 39 | + var playerPath = mw.getMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player'; |
| 40 | + flashvars.entryId = mw.absoluteUrl(_this.getSrc()); |
| 41 | + |
| 42 | + // Use a relative url if the protocal is file:// |
| 43 | + if (mw.parseUri(document.URL).protocol == 'file') { |
| 44 | + playerPath = mw.getRelativeMwEmbedPath() + 'modules/EmbedPlayer/binPlayers/kaltura-player'; |
| 45 | + flashvars.entryId = _this.getSrc(); |
47 | 46 | } |
48 | | - |
| 47 | + |
49 | 48 | flashvars.debugMode = "true"; |
50 | 49 | flashvars.fileSystemMode = "true"; |
51 | 50 | flashvars.widgetId = "_7463"; |
— | — | @@ -53,439 +52,456 @@ |
54 | 53 | flashvars.kml = "local"; |
55 | 54 | flashvars.kmlPath = playerPath + '/config.xml'; |
56 | 55 | flashvars.sourceType = "url"; |
57 | | - |
58 | | - //flashvars.host = "www.kaltura.com"; |
| 56 | + |
| 57 | + // flashvars.host = "www.kaltura.com"; |
59 | 58 | flashvars.externalInterfaceDisabled = 'false'; |
60 | 59 | flashvars.skinPath = playerPath + '/skin.swf'; |
61 | | - |
| 60 | + |
62 | 61 | flashvars["full.skinPath"] = playerPath + '/LightDoodleskin.swf'; |
63 | | - |
64 | | - var params = { }; |
| 62 | + |
| 63 | + var params = {}; |
65 | 64 | params.quality = "best"; |
66 | 65 | params.wmode = "opaque"; |
67 | 66 | params.allowfullscreen = "true"; |
68 | 67 | params.allowscriptaccess = "always"; |
69 | | - |
| 68 | + |
70 | 69 | var attributes = {}; |
71 | 70 | attributes.id = this.pid; |
72 | 71 | attributes.name = this.pid; |
73 | | - |
| 72 | + |
74 | 73 | mw.log(" about to add the pid container"); |
75 | | - $j( this ).html( |
76 | | - $j('<div />') |
77 | | - .attr( 'id', this.pid + '_container' ) |
78 | | - ); |
79 | | - // call swm dom loaded function: |
| 74 | + $j(this).html($j('<div />').attr('id', this.pid + '_container')); |
| 75 | + // call swm dom loaded function: |
80 | 76 | swfobject.callDomLoadFunctions(); |
81 | | - // Do the flash embedding with embedSWF |
82 | | - swfobject.embedSWF( |
83 | | - playerPath + "/kdp3.swf", |
84 | | - this.pid + '_container', |
85 | | - '100%', |
86 | | - '100%', |
87 | | - "10.0.0", |
88 | | - playerPath + "/expressInstall.swf", |
89 | | - flashvars, |
90 | | - params, |
91 | | - attributes |
92 | | - ); |
93 | | - |
| 77 | + // Do the flash embedding with embedSWF |
| 78 | + swfobject.embedSWF(playerPath + "/kdp3.swf", this.pid + '_container', |
| 79 | + '100%', '100%', "10.0.0", playerPath + "/expressInstall.swf", |
| 80 | + flashvars, params, attributes); |
| 81 | + |
94 | 82 | // Direct object embed |
95 | | - /*$j( this ).html( |
96 | | - '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">'+ |
97 | | - '<param name="movie" value="myContent.swf" />'+ |
98 | | - '<!--[if !IE]>-->'+ |
99 | | - '<object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">'+ |
100 | | - '<!--<![endif]-->'+ |
101 | | - '<p> error with flash embed</p>' |
102 | | - '<!--[if !IE]>-->'+ |
103 | | - '</object>'+ |
104 | | - '<!--<![endif]-->'+ |
105 | | - '</object>' |
106 | | - )*/ |
107 | | - |
108 | | - setTimeout( function() { |
109 | | - _this.postEmbedJS(); |
110 | | - }, 100 ); |
111 | | - |
| 83 | + /* |
| 84 | + * $j( this ).html( '<object |
| 85 | + * classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" |
| 86 | + * height="420">'+ '<param name="movie" value="myContent.swf" />'+ '<!--[if |
| 87 | + * !IE]>-->'+ '<object type="application/x-shockwave-flash" |
| 88 | + * data="myContent.swf" width="780" height="420">'+ '<!--<![endif]-->'+ '<p> |
| 89 | + * error with flash embed</p>' '<!--[if !IE]>-->'+ '</object>'+ '<!--<![endif]-->'+ '</object>' ) |
| 90 | + */ |
| 91 | + |
| 92 | + setTimeout(function() { |
| 93 | + _this.postEmbedJS(); |
| 94 | + }, 100); |
| 95 | + |
112 | 96 | // Flash player loses its bindings once it changes sizes:: |
113 | | - $j( _this ).bind ( 'closeFullScreenEvent', function(){ |
| 97 | + $j(_this).bind('closeFullScreenEvent', function() { |
114 | 98 | _this.postEmbedJS(); |
115 | 99 | }); |
116 | | - $j( _this ).bind ( 'openFullScreenEvent', function(){ |
| 100 | + $j(_this).bind('openFullScreenEvent', function() { |
117 | 101 | _this.postEmbedJS(); |
118 | 102 | }) |
119 | | - |
120 | | - }, |
121 | | - |
| 103 | + |
| 104 | + }, |
| 105 | + |
122 | 106 | /** |
123 | | - * javascript run post player embedding |
124 | | - */ |
125 | | - postEmbedJS:function() { |
| 107 | + * javascript run post player embedding |
| 108 | + */ |
| 109 | + postEmbedJS : function() { |
126 | 110 | var _this = this; |
127 | | - this.getPlayerElement(); |
128 | | - |
129 | | - if( this.playerElement && this.playerElement.addJsListener ) { |
130 | | - |
131 | | - // Add KDP listeners |
132 | | - _this.bindPlayerFunction( 'doPause', 'onPause' ); |
133 | | - _this.bindPlayerFunction( 'doPlay', 'onPlay' ); |
134 | | - _this.bindPlayerFunction( 'durationChange', 'onDurationChange'); |
135 | | - _this.bindPlayerFunction( 'playerPlayEnd', 'onClipDone' ); |
136 | | - _this.bindPlayerFunction( 'playerUpdatePlayhead', 'onUpdatePlayhead' ); |
137 | | - |
138 | | - // Buffering |
139 | | - _this.bindPlayerFunction( 'bytesTotalChange', "onBytesTotalChange" ); |
140 | | - _this.bindPlayerFunction( 'bytesDownloadedChange', "onBytesDownloadedChange" ); |
141 | | - |
| 111 | + this.getPlayerElement(); |
| 112 | + |
| 113 | + var bindEventMap = { |
| 114 | + 'doPause' : 'onPause', |
| 115 | + 'doPlay' : 'onPlay', |
| 116 | + 'durationChange' : 'onDurationChange', |
| 117 | + 'playerPlayEnd' : 'onClipDone', |
| 118 | + 'playerUpdatePlayhead' : 'onUpdatePlayhead', |
| 119 | + 'bytesTotalChange' : 'onBytesTotalChange', |
| 120 | + 'bytesDownloadedChange' : 'onBytesDownloadedChange' |
| 121 | + } |
| 122 | + |
| 123 | + if (this.playerElement && this.playerElement.addJsListener) { |
| 124 | + $j.each(bindEventMap, function(bindName, localMethod) { |
| 125 | + _this.bindPlayerFunction(bindName, localMethod); |
| 126 | + }); |
142 | 127 | // Start the monitor |
143 | 128 | this.monitor(); |
144 | | - }else{ |
| 129 | + } else { |
145 | 130 | // Keep trying to get the player element |
146 | | - //mw.log('insert media: not defined:' + typeof this.playerElement.insertMedia ); |
147 | | - setTimeout( function() { |
| 131 | + // mw.log('insert media: not defined:' + typeof |
| 132 | + // this.playerElement.insertMedia ); |
| 133 | + setTimeout(function() { |
148 | 134 | _this.postEmbedJS(); |
149 | 135 | }, 250); |
150 | | - } |
151 | | - }, |
152 | | - |
| 136 | + } |
| 137 | + }, |
| 138 | + |
153 | 139 | /** |
154 | | - * Bind a Player Function, |
155 | | - * |
156 | | - * Does some tricker to bind to "this" player instance: |
157 | | - * |
158 | | - * @param {String} flash binding name |
159 | | - * @param {String} function callback name |
160 | | - */ |
161 | | - bindPlayerFunction: function( bName, fName ) { |
162 | | - var cbid = fName + '_cb_' + this.id.replace(' ', '_'); |
163 | | - eval( 'window[ \'' + cbid +'\' ] = function( data ) {$j(\'#' + this.id + '\').get(0).'+ fName +'( data );}' ); |
164 | | - this.playerElement.addJsListener( bName , cbid); |
| 140 | + * Bind a Player Function, |
| 141 | + * |
| 142 | + * Does some tricker to bind to "this" player instance: |
| 143 | + * |
| 144 | + * @param {String} |
| 145 | + * flash binding name |
| 146 | + * @param {String} |
| 147 | + * function callback name |
| 148 | + */ |
| 149 | + bindPlayerFunction : function(bindName, methodName) { |
| 150 | + // The kaltura kdp can only call a global function by given name |
| 151 | + var gKdpCallbackName = methodName + '_cb_' + this.id; |
| 152 | + |
| 153 | + // Create an anonymous function with local player scope |
| 154 | + var createGlobalCB = function(cName, embedPlayer) { |
| 155 | + window[cName] = function(data) { |
| 156 | + if (embedPlayer._propagateEvents) { |
| 157 | + embedPlayer[methodName](data); |
| 158 | + } |
| 159 | + }; |
| 160 | + }(gKdpCallbackName, this); |
| 161 | + |
| 162 | + // Add the listener to the KDP flash player: |
| 163 | + this.playerElement.addJsListener(bindName, gKdpCallbackName); |
165 | 164 | }, |
166 | | - |
| 165 | + |
167 | 166 | /** |
168 | | - * on Pause callback from the kaltura flash player |
169 | | - * calls parent_pause to update the interface |
170 | | - */ |
171 | | - onPause: function() { |
| 167 | + * on Pause callback from the kaltura flash player calls parent_pause to |
| 168 | + * update the interface |
| 169 | + */ |
| 170 | + onPause : function() { |
172 | 171 | this.parent_pause(); |
173 | 172 | }, |
174 | | - |
| 173 | + |
175 | 174 | /** |
176 | | - * onPlay function callback from the kaltura flash player |
177 | | - * directly call the parent_play |
| 175 | + * onPlay function callback from the kaltura flash player directly call the |
| 176 | + * parent_play |
178 | 177 | */ |
179 | | - onPlay: function(){ |
| 178 | + onPlay : function() { |
180 | 179 | this.parent_play(); |
181 | 180 | }, |
182 | | - |
183 | | - onDurationChange: function(data, id) { |
| 181 | + |
| 182 | + onDurationChange : function(data, id) { |
184 | 183 | mw.log(" onDurationChange: " + data.newValue); |
185 | | - // update the duration: |
| 184 | + // update the duration: |
186 | 185 | this.duration = data.newValue; |
187 | 186 | }, |
188 | | - |
| 187 | + |
189 | 188 | /** |
190 | | - * play method |
191 | | - * calls parent_play to update the interface |
192 | | - */ |
193 | | - play: function() { |
194 | | - if( this.playerElement && this.playerElement.sendNotification ){ |
195 | | - this.playerElement.sendNotification( 'doPlay' ); |
| 189 | + * play method calls parent_play to update the interface |
| 190 | + */ |
| 191 | + play : function() { |
| 192 | + if (this.playerElement && this.playerElement.sendNotification) { |
| 193 | + this.playerElement.sendNotification('doPlay'); |
196 | 194 | } |
197 | 195 | this.parent_play(); |
198 | 196 | }, |
199 | | - |
| 197 | + |
200 | 198 | /** |
201 | | - * pause method |
202 | | - * calls parent_pause to update the interface |
203 | | - */ |
204 | | - pause: function() { |
205 | | - if( this.playerElement && this.playerElement.sendNotification ){ |
| 199 | + * pause method calls parent_pause to update the interface |
| 200 | + */ |
| 201 | + pause : function() { |
| 202 | + if (this.playerElement && this.playerElement.sendNotification) { |
206 | 203 | this.playerElement.sendNotification('doPause'); |
207 | 204 | } |
208 | 205 | this.parent_pause(); |
209 | 206 | }, |
210 | | - |
| 207 | + |
211 | 208 | /** |
212 | | - * Issues a seek to the playerElement |
213 | | - * @param {Float} percentage Percentage of total stream length to seek to |
214 | | - */ |
215 | | - doSeek: function( percentage ) { |
| 209 | + * Issues a seek to the playerElement |
| 210 | + * |
| 211 | + * @param {Float} |
| 212 | + * percentage Percentage of total stream length to seek to |
| 213 | + */ |
| 214 | + doSeek : function(percentage) { |
216 | 215 | var _this = this; |
217 | | - if ( this.supportsURLTimeEncoding() ){ |
218 | | - |
219 | | - // Make sure we could not do a local seek instead: |
220 | | - if ( !( percentage < this.bufferedPercent && this.playerElement.duration && !this.didSeekJump )) { |
221 | | - // We support URLTimeEncoding call parent seek: |
222 | | - this.parent_doSeek( percentage ); |
| 216 | + if (this.supportsURLTimeEncoding()) { |
| 217 | + |
| 218 | + // Make sure we could not do a local seek instead: |
| 219 | + if (!(percentage < this.bufferedPercent |
| 220 | + && this.playerElement.duration && !this.didSeekJump)) { |
| 221 | + // We support URLTimeEncoding call parent seek: |
| 222 | + this.parent_doSeek(percentage); |
223 | 223 | return; |
224 | 224 | } |
225 | | - } |
| 225 | + } |
226 | 226 | |
227 | | - if( this.playerElement ) { |
228 | | - var seekTime = percentage * this.getDuration(); |
| 227 | + if (this.playerElement) { |
| 228 | + var seekTime = percentage * this.getDuration(); |
229 | 229 | // Issue the seek to the flash player: |
230 | 230 | this.playerElement.sendNotification('doSeek', seekTime); |
231 | | - |
| 231 | + |
232 | 232 | // Kdp is missing seek done callback |
233 | 233 | setTimeout(function() { |
234 | | - _this.seeking= false; |
235 | | - },500); |
| 234 | + _this.seeking = false; |
| 235 | + }, 500); |
236 | 236 | } else { |
237 | | - // try to do a play then seek: |
238 | | - this.doPlayThenSeek( percentage ) |
239 | | - } |
| 237 | + // try to do a play then seek: |
| 238 | + this.doPlayThenSeek(percentage) |
| 239 | + } |
240 | 240 | // Run the onSeeking interface update |
241 | | - this.controlBuilder.onSeek(); |
| 241 | + this.controlBuilder.onSeek(); |
242 | 242 | }, |
243 | | - |
| 243 | + |
244 | 244 | /** |
245 | | - * Seek in a existing stream |
246 | | - * |
247 | | - * @param {Float} percentage Percentage of the stream to seek to between 0 and 1 |
248 | | - */ |
249 | | - doPlayThenSeek: function( percentage ) { |
250 | | - mw.log( 'flash::doPlayThenSeek::' ); |
| 245 | + * Seek in a existing stream |
| 246 | + * |
| 247 | + * @param {Float} |
| 248 | + * percentage Percentage of the stream to seek to between 0 and 1 |
| 249 | + */ |
| 250 | + doPlayThenSeek : function(percentage) { |
| 251 | + mw.log('flash::doPlayThenSeek::'); |
251 | 252 | var _this = this; |
252 | 253 | // issue the play request |
253 | | - this.play(); |
254 | | - |
255 | | - // let the player know we are seeking |
256 | | - _this.seeking = true; |
257 | | - |
258 | | - var getPlayerCount = 0; |
259 | | - var readyForSeek = function() { |
260 | | - _this.getPlayerElement(); |
261 | | - // if we have duration then we are ready to do the seek ( flash can't seek untill there is some buffer ) |
262 | | - if ( _this.playerElement && _this.playerElement.sendNotification && _this.getDuration() && _this.bufferedPercent ) { |
263 | | - var seekTime = percentage * _this.getDuration(); |
264 | | - // Issue the seek to the flash player: |
265 | | - _this.playerElement.sendNotification('doSeek', seekTime); |
| 254 | + this.play(); |
| 255 | + |
| 256 | + // let the player know we are seeking |
| 257 | + _this.seeking = true; |
| 258 | + |
| 259 | + var getPlayerCount = 0; |
| 260 | + var readyForSeek = function() { |
| 261 | + _this.getPlayerElement(); |
| 262 | + // if we have duration then we are ready to do the seek ( flash can't |
| 263 | + // seek untill there is some buffer ) |
| 264 | + if (_this.playerElement && _this.playerElement.sendNotification |
| 265 | + && _this.getDuration() && _this.bufferedPercent) { |
| 266 | + var seekTime = percentage * _this.getDuration(); |
| 267 | + // Issue the seek to the flash player: |
| 268 | + _this.playerElement.sendNotification('doSeek', seekTime); |
| 269 | + } else { |
| 270 | + // Try to get player for 20 seconds: |
| 271 | + if (getPlayerCount < 400) { |
| 272 | + setTimeout(readyForSeek, 50); |
| 273 | + getPlayerCount++; |
266 | 274 | } else { |
267 | | - // Try to get player for 20 seconds: |
268 | | - if ( getPlayerCount < 400 ) { |
269 | | - setTimeout( readyForSeek, 50 ); |
270 | | - getPlayerCount++; |
271 | | - } else { |
272 | | - mw.log( 'Error:doPlayThenSeek failed' ); |
273 | | - } |
| 275 | + mw.log('Error:doPlayThenSeek failed'); |
274 | 276 | } |
275 | 277 | } |
276 | | - readyForSeek(); |
277 | | - }, |
278 | | - |
279 | | - /** |
280 | | - * Issues a volume update to the playerElement |
281 | | - * @param {Float} percentage Percentage to update volume to |
282 | | - */ |
283 | | - setPlayerElementVolume: function( percentage ) { |
284 | | - if( this.playerElement && this.playerElement.sendNotification ){ |
285 | | - this.playerElement.sendNotification('changeVolume', percentage); |
286 | | - } |
287 | | - }, |
288 | | - |
289 | | - /** |
290 | | - * function called by flash at set interval to update the playhead. |
291 | | - */ |
292 | | - onUpdatePlayhead : function ( playheadValue ){ |
293 | | - this.flashCurrentTime = playheadValue; |
294 | | - }, |
295 | | - |
296 | | - /** |
297 | | - * function called by flash when the total media size changes |
298 | | - */ |
299 | | - onBytesTotalChange: function(data, id) { |
300 | | - this.bytesTotal = data.newValue ; |
301 | | - }, |
302 | | - |
303 | | - /** |
304 | | - * function called by flash applet when download bytes changes |
305 | | - */ |
306 | | - onBytesDownloadedChange: function( data, id){ |
307 | | - mw.log( 'onBytesDownloadedChange'); |
308 | | - this.bytesLoaded = data.newValue; |
309 | | - this.bufferedPercent = this.bytesLoaded / this.bytesTotal; |
310 | | - |
311 | | - // Fire the parent html5 action |
312 | | - $j( this ).trigger( 'progress', { |
313 | | - 'loaded' : this.bytesLoaded, |
314 | | - 'total' : this.bytesTotal |
315 | | - } ); |
316 | | - }, |
317 | | - |
318 | | - /** |
319 | | - * Get the embed player time |
320 | | - */ |
321 | | - getPlayerElementTime: function(){ |
322 | | - // update currentTime |
323 | | - return this.flashCurrentTime; |
324 | | - }, |
325 | | - |
326 | | - /** |
327 | | - * Get the embed fla object player Element |
328 | | - */ |
329 | | - getPlayerElement: function () { |
330 | | - this.playerElement = document.getElementById( this.pid ); |
331 | | - return this.playerElement; |
332 | 278 | } |
| 279 | + readyForSeek(); |
| 280 | +}, |
| 281 | + |
| 282 | +/** |
| 283 | + * Issues a volume update to the playerElement |
| 284 | + * |
| 285 | + * @param {Float} |
| 286 | + * percentage Percentage to update volume to |
| 287 | + */ |
| 288 | +setPlayerElementVolume : function(percentage) { |
| 289 | + if (this.playerElement && this.playerElement.sendNotification) { |
| 290 | + this.playerElement.sendNotification('changeVolume', percentage); |
| 291 | + } |
| 292 | +}, |
| 293 | + |
| 294 | +/** |
| 295 | + * function called by flash at set interval to update the playhead. |
| 296 | + */ |
| 297 | +onUpdatePlayhead : function(playheadValue) { |
| 298 | + this.flashCurrentTime = playheadValue; |
| 299 | +}, |
| 300 | + |
| 301 | +/** |
| 302 | + * function called by flash when the total media size changes |
| 303 | + */ |
| 304 | +onBytesTotalChange : function(data, id) { |
| 305 | + this.bytesTotal = data.newValue; |
| 306 | +}, |
| 307 | + |
| 308 | +/** |
| 309 | + * function called by flash applet when download bytes changes |
| 310 | + */ |
| 311 | +onBytesDownloadedChange : function(data, id) { |
| 312 | + mw.log('onBytesDownloadedChange'); |
| 313 | + this.bytesLoaded = data.newValue; |
| 314 | + this.bufferedPercent = this.bytesLoaded / this.bytesTotal; |
| 315 | + |
| 316 | + // Fire the parent html5 action |
| 317 | + $j(this).trigger('progress', { |
| 318 | + 'loaded' : this.bytesLoaded, |
| 319 | + 'total' : this.bytesTotal |
| 320 | + }); |
| 321 | +}, |
| 322 | + |
| 323 | +/** |
| 324 | + * Get the embed player time |
| 325 | + */ |
| 326 | +getPlayerElementTime : function() { |
| 327 | + // update currentTime |
| 328 | + return this.flashCurrentTime; |
| 329 | +}, |
| 330 | + |
| 331 | +/** |
| 332 | + * Get the embed fla object player Element |
| 333 | + */ |
| 334 | +getPlayerElement : function() { |
| 335 | + this.playerElement = document.getElementById(this.pid); |
| 336 | + return this.playerElement; |
333 | 337 | } |
| 338 | +} |
334 | 339 | |
335 | 340 | /** |
336 | | -* function called once player is ready. |
337 | | -* |
338 | | -* NOTE: playerID is not always passed so we can't use this: |
339 | | -*/ |
340 | | -function onKdpReady( playerId ) { |
341 | | - mw.log( "player is ready::" + playerId); |
| 341 | + * function called once player is ready. |
| 342 | + * |
| 343 | + * NOTE: playerID is not always passed so we can't use this: |
| 344 | + */ |
| 345 | +function onKdpReady(playerId) { |
| 346 | + mw.log("player is ready::" + playerId); |
342 | 347 | } |
343 | 348 | |
| 349 | +/* |
| 350 | + * ! SWFObject v2.2 <http://code.google.com/p/swfobject/> is released under the |
| 351 | + * MIT License <http://www.opensource.org/licenses/mit-license.php> |
| 352 | + */ |
344 | 353 | |
| 354 | +var swfobject = function() { |
345 | 355 | |
346 | | -/*! SWFObject v2.2 <http://code.google.com/p/swfobject/> |
347 | | - is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> |
348 | | -*/ |
| 356 | + var UNDEF = "undefined", OBJECT = "object", SHOCKWAVE_FLASH = "Shockwave Flash", SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", FLASH_MIME_TYPE = "application/x-shockwave-flash", EXPRESS_INSTALL_ID = "SWFObjectExprInst", ON_READY_STATE_CHANGE = "onreadystatechange", |
349 | 357 | |
350 | | -var swfobject = function() { |
351 | | - |
352 | | - var UNDEF = "undefined", |
353 | | - OBJECT = "object", |
354 | | - SHOCKWAVE_FLASH = "Shockwave Flash", |
355 | | - SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash", |
356 | | - FLASH_MIME_TYPE = "application/x-shockwave-flash", |
357 | | - EXPRESS_INSTALL_ID = "SWFObjectExprInst", |
358 | | - ON_READY_STATE_CHANGE = "onreadystatechange", |
359 | | - |
360 | | - win = window, |
361 | | - doc = document, |
362 | | - nav = navigator, |
363 | | - |
364 | | - plugin = false, |
365 | | - domLoadFnArr = [main], |
366 | | - regObjArr = [], |
367 | | - objIdArr = [], |
368 | | - listenersArr = [], |
369 | | - storedAltContent, |
370 | | - storedAltContentId, |
371 | | - storedCallbackFn, |
372 | | - storedCallbackObj, |
373 | | - isDomLoaded = false, |
374 | | - isExpressInstallActive = false, |
375 | | - dynamicStylesheet, |
376 | | - dynamicStylesheetMedia, |
377 | | - autoHideShow = true, |
378 | | - |
379 | | - /* Centralized function for browser feature detection |
380 | | - - User agent string detection is only used when no good alternative is possible |
381 | | - - Is executed directly for optimal performance |
382 | | - */ |
| 358 | + win = window, doc = document, nav = navigator, |
| 359 | + |
| 360 | + plugin = false, domLoadFnArr = [ main ], regObjArr = [], objIdArr = [], listenersArr = [], storedAltContent, storedAltContentId, storedCallbackFn, storedCallbackObj, isDomLoaded = false, isExpressInstallActive = false, dynamicStylesheet, dynamicStylesheetMedia, autoHideShow = true, |
| 361 | + |
| 362 | + /* |
| 363 | + * Centralized function for browser feature detection - User agent string |
| 364 | + * detection is only used when no good alternative is possible - Is executed |
| 365 | + * directly for optimal performance |
| 366 | + */ |
383 | 367 | ua = function() { |
384 | | - var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF, |
385 | | - u = nav.userAgent.toLowerCase(), |
386 | | - p = nav.platform.toLowerCase(), |
387 | | - windows = p ? /win/.test(p) : /win/.test(u), |
388 | | - mac = p ? /mac/.test(p) : /mac/.test(u), |
389 | | - webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit |
390 | | - ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html |
391 | | - playerVersion = [0,0,0], |
392 | | - d = null; |
393 | | - if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { |
| 368 | + var w3cdom = typeof doc.getElementById != UNDEF |
| 369 | + && typeof doc.getElementsByTagName != UNDEF |
| 370 | + && typeof doc.createElement != UNDEF, u = nav.userAgent |
| 371 | + .toLowerCase(), p = nav.platform.toLowerCase(), windows = p ? /win/ |
| 372 | + .test(p) |
| 373 | + : /win/.test(u), mac = p ? /mac/.test(p) : /mac/.test(u), webkit = /webkit/ |
| 374 | + .test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, |
| 375 | + "$1")) : false, // returns either the webkit version or false if |
| 376 | + // not webkit |
| 377 | + ie = !+"\v1", // feature detection based on Andrea Giammarchi's |
| 378 | + // solution: |
| 379 | + // http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html |
| 380 | + playerVersion = [ 0, 0, 0 ], d = null; |
| 381 | + if (typeof nav.plugins != UNDEF |
| 382 | + && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) { |
394 | 383 | d = nav.plugins[SHOCKWAVE_FLASH].description; |
395 | | - if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+ |
| 384 | + if (d |
| 385 | + && !(typeof nav.mimeTypes != UNDEF |
| 386 | + && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin |
| 387 | + // indicates |
| 388 | + // whether |
| 389 | + // plug-ins |
| 390 | + // are |
| 391 | + // enabled |
| 392 | + // or |
| 393 | + // disabled |
| 394 | + // in |
| 395 | + // Safari |
| 396 | + // 3+ |
396 | 397 | plugin = true; |
397 | 398 | ie = false; // cascaded feature detection for Internet Explorer |
398 | 399 | d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1"); |
399 | 400 | playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10); |
400 | | - playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10); |
401 | | - playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; |
| 401 | + playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), |
| 402 | + 10); |
| 403 | + playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace( |
| 404 | + /^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0; |
402 | 405 | } |
403 | | - } |
404 | | - else if (typeof win.ActiveXObject != UNDEF) { |
| 406 | + } else if (typeof win.ActiveXObject != UNDEF) { |
405 | 407 | try { |
406 | 408 | var a = new ActiveXObject(SHOCKWAVE_FLASH_AX); |
407 | 409 | if (a) { // a will return null when ActiveX is disabled |
408 | 410 | d = a.GetVariable("$version"); |
409 | 411 | if (d) { |
410 | | - ie = true; // cascaded feature detection for Internet Explorer |
| 412 | + ie = true; // cascaded feature detection for Internet |
| 413 | + // Explorer |
411 | 414 | d = d.split(" ")[1].split(","); |
412 | | - playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; |
| 415 | + playerVersion = [ parseInt(d[0], 10), |
| 416 | + parseInt(d[1], 10), parseInt(d[2], 10) ]; |
413 | 417 | } |
414 | 418 | } |
| 419 | + } catch (e) { |
415 | 420 | } |
416 | | - catch(e) {} |
417 | 421 | } |
418 | | - return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac }; |
| 422 | + return { |
| 423 | + w3 : w3cdom, |
| 424 | + pv : playerVersion, |
| 425 | + wk : webkit, |
| 426 | + ie : ie, |
| 427 | + win : windows, |
| 428 | + mac : mac |
| 429 | + }; |
419 | 430 | }(); |
420 | | - |
421 | | - |
| 431 | + |
422 | 432 | function callDomLoadFunctions() { |
423 | | - if (isDomLoaded) { return; } |
424 | | - try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early |
425 | | - var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span")); |
| 433 | + if (isDomLoaded) { |
| 434 | + return; |
| 435 | + } |
| 436 | + try { // test if we can really add/remove elements to/from the DOM; we |
| 437 | + // don't want to fire it too early |
| 438 | + var t = doc.getElementsByTagName("body")[0] |
| 439 | + .appendChild(createElement("span")); |
426 | 440 | t.parentNode.removeChild(t); |
| 441 | + } catch (e) { |
| 442 | + return; |
427 | 443 | } |
428 | | - catch (e) { return; } |
429 | 444 | isDomLoaded = true; |
430 | 445 | var dl = domLoadFnArr.length; |
431 | | - for (var i = 0; i < dl; i++) { |
| 446 | + for ( var i = 0; i < dl; i++) { |
432 | 447 | domLoadFnArr[i](); |
433 | 448 | } |
434 | 449 | } |
435 | | - |
| 450 | + |
436 | 451 | function addDomLoadEvent(fn) { |
437 | 452 | if (isDomLoaded) { |
438 | 453 | fn(); |
| 454 | + } else { |
| 455 | + domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only |
| 456 | + // available in IE5.5+ |
439 | 457 | } |
440 | | - else { |
441 | | - domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+ |
442 | | - } |
443 | 458 | } |
444 | | - |
445 | | - /* Cross-browser onload |
446 | | - - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/ |
447 | | - - Will fire an event as soon as a web page including all of its assets are loaded |
| 459 | + |
| 460 | + /* |
| 461 | + * Cross-browser onload - Based on James Edwards' solution: |
| 462 | + * http://brothercake.com/site/resources/scripts/onload/ - Will fire an |
| 463 | + * event as soon as a web page including all of its assets are loaded |
448 | 464 | */ |
449 | 465 | function addLoadEvent(fn) { |
450 | 466 | if (typeof win.addEventListener != UNDEF) { |
451 | 467 | win.addEventListener("load", fn, false); |
452 | | - } |
453 | | - else if (typeof doc.addEventListener != UNDEF) { |
| 468 | + } else if (typeof doc.addEventListener != UNDEF) { |
454 | 469 | doc.addEventListener("load", fn, false); |
455 | | - } |
456 | | - else if (typeof win.attachEvent != UNDEF) { |
| 470 | + } else if (typeof win.attachEvent != UNDEF) { |
457 | 471 | addListener(win, "onload", fn); |
458 | | - } |
459 | | - else if (typeof win.onload == "function") { |
| 472 | + } else if (typeof win.onload == "function") { |
460 | 473 | var fnOld = win.onload; |
461 | 474 | win.onload = function() { |
462 | 475 | fnOld(); |
463 | 476 | fn(); |
464 | 477 | }; |
465 | | - } |
466 | | - else { |
| 478 | + } else { |
467 | 479 | win.onload = fn; |
468 | 480 | } |
469 | 481 | } |
470 | | - |
471 | | - /* Main function |
472 | | - - Will preferably execute onDomLoad, otherwise onload (as a fallback) |
473 | | - */ |
474 | | - function main() { |
| 482 | + |
| 483 | + /* |
| 484 | + * Main function - Will preferably execute onDomLoad, otherwise onload (as a |
| 485 | + * fallback) |
| 486 | + */ |
| 487 | + function main() { |
475 | 488 | if (plugin) { |
476 | 489 | testPlayerVersion(); |
477 | | - } |
478 | | - else { |
| 490 | + } else { |
479 | 491 | matchVersions(); |
480 | 492 | } |
481 | 493 | } |
482 | | - |
483 | | - /* Detect the Flash Player version for non-Internet Explorer browsers |
484 | | - - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description: |
485 | | - a. Both release and build numbers can be detected |
486 | | - b. Avoid wrong descriptions by corrupt installers provided by Adobe |
487 | | - c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports |
488 | | - - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available |
489 | | - */ |
| 494 | + |
| 495 | + /* |
| 496 | + * Detect the Flash Player version for non-Internet Explorer browsers - |
| 497 | + * Detecting the plug-in version via the object element is more precise than |
| 498 | + * using the plugins collection item's description: a. Both release and |
| 499 | + * build numbers can be detected b. Avoid wrong descriptions by corrupt |
| 500 | + * installers provided by Adobe c. Avoid wrong descriptions by multiple |
| 501 | + * Flash Player entries in the plugin Array, caused by incorrect browser |
| 502 | + * imports - Disadvantage of this method is that it depends on the |
| 503 | + * availability of the DOM, while the plugins collection is immediately |
| 504 | + * available |
| 505 | + */ |
490 | 506 | function testPlayerVersion() { |
491 | 507 | var b = doc.getElementsByTagName("body")[0]; |
492 | 508 | var o = createElement(OBJECT); |
— | — | @@ -493,19 +509,19 @@ |
494 | 510 | var t = b.appendChild(o); |
495 | 511 | if (t) { |
496 | 512 | var counter = 0; |
497 | | - (function(){ |
| 513 | + (function() { |
498 | 514 | if (typeof t.GetVariable != UNDEF) { |
499 | | - try{ |
| 515 | + try { |
500 | 516 | var d = t.GetVariable("$version"); |
501 | 517 | if (d) { |
502 | 518 | d = d.split(" ")[1].split(","); |
503 | | - ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)]; |
| 519 | + ua.pv = [ parseInt(d[0], 10), parseInt(d[1], 10), |
| 520 | + parseInt(d[2], 10) ]; |
504 | 521 | } |
505 | | - } catch( e ){ |
506 | | - // error in grabbing flash version |
| 522 | + } catch (e) { |
| 523 | + // error in grabbing flash version |
507 | 524 | } |
508 | | - } |
509 | | - else if (counter < 10) { |
| 525 | + } else if (counter < 10) { |
510 | 526 | counter++; |
511 | 527 | setTimeout(arguments.callee, 10); |
512 | 528 | return; |
— | — | @@ -514,61 +530,91 @@ |
515 | 531 | t = null; |
516 | 532 | matchVersions(); |
517 | 533 | })(); |
518 | | - } |
519 | | - else { |
| 534 | + } else { |
520 | 535 | matchVersions(); |
521 | 536 | } |
522 | 537 | } |
523 | | - |
524 | | - /* Perform Flash Player and SWF version matching; static publishing only |
525 | | - */ |
| 538 | + |
| 539 | + /* |
| 540 | + * Perform Flash Player and SWF version matching; static publishing only |
| 541 | + */ |
526 | 542 | function matchVersions() { |
527 | 543 | var rl = regObjArr.length; |
528 | 544 | if (rl > 0) { |
529 | | - for (var i = 0; i < rl; i++) { // for each registered object element |
| 545 | + for ( var i = 0; i < rl; i++) { // for each registered object |
| 546 | + // element |
530 | 547 | var id = regObjArr[i].id; |
531 | 548 | var cb = regObjArr[i].callbackFn; |
532 | | - var cbObj = {success:false, id:id}; |
| 549 | + var cbObj = { |
| 550 | + success : false, |
| 551 | + id : id |
| 552 | + }; |
533 | 553 | if (ua.pv[0] > 0) { |
534 | 554 | var obj = getElementById(id); |
535 | 555 | if (obj) { |
536 | | - if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match! |
| 556 | + if (hasPlayerVersion(regObjArr[i].swfVersion) |
| 557 | + && !(ua.wk && ua.wk < 312)) { // Flash Player |
| 558 | + // version >= |
| 559 | + // published SWF |
| 560 | + // version: |
| 561 | + // Houston, we |
| 562 | + // have a match! |
537 | 563 | setVisibility(id, true); |
538 | 564 | if (cb) { |
539 | 565 | cbObj.success = true; |
540 | 566 | cbObj.ref = getObjectById(id); |
541 | 567 | cb(cbObj); |
542 | 568 | } |
543 | | - } |
544 | | - else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported |
| 569 | + } else if (regObjArr[i].expressInstall |
| 570 | + && canExpressInstall()) { // show the Adobe |
| 571 | + // Express Install |
| 572 | + // dialog if set by |
| 573 | + // the web page |
| 574 | + // author and if |
| 575 | + // supported |
545 | 576 | var att = {}; |
546 | 577 | att.data = regObjArr[i].expressInstall; |
547 | 578 | att.width = obj.getAttribute("width") || "0"; |
548 | 579 | att.height = obj.getAttribute("height") || "0"; |
549 | | - if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); } |
550 | | - if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); } |
551 | | - // parse HTML object param element's name-value pairs |
| 580 | + if (obj.getAttribute("class")) { |
| 581 | + att.styleclass = obj.getAttribute("class"); |
| 582 | + } |
| 583 | + if (obj.getAttribute("align")) { |
| 584 | + att.align = obj.getAttribute("align"); |
| 585 | + } |
| 586 | + // parse HTML object param element's name-value |
| 587 | + // pairs |
552 | 588 | var par = {}; |
553 | 589 | var p = obj.getElementsByTagName("param"); |
554 | 590 | var pl = p.length; |
555 | | - for (var j = 0; j < pl; j++) { |
| 591 | + for ( var j = 0; j < pl; j++) { |
556 | 592 | if (p[j].getAttribute("name").toLowerCase() != "movie") { |
557 | | - par[p[j].getAttribute("name")] = p[j].getAttribute("value"); |
| 593 | + par[p[j].getAttribute("name")] = p[j] |
| 594 | + .getAttribute("value"); |
558 | 595 | } |
559 | 596 | } |
560 | 597 | showExpressInstall(att, par, id, cb); |
561 | | - } |
562 | | - else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF |
| 598 | + } else { // Flash Player and SWF version mismatch or |
| 599 | + // an older Webkit engine that ignores the |
| 600 | + // HTML object element's nested param |
| 601 | + // elements: display alternative content |
| 602 | + // instead of SWF |
563 | 603 | displayAltContent(obj); |
564 | | - if (cb) { cb(cbObj); } |
| 604 | + if (cb) { |
| 605 | + cb(cbObj); |
| 606 | + } |
565 | 607 | } |
566 | 608 | } |
567 | | - } |
568 | | - else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content) |
| 609 | + } else { // if no Flash Player is installed or the fp version |
| 610 | + // cannot be detected we let the HTML object element |
| 611 | + // do its job (either show a SWF or alternative |
| 612 | + // content) |
569 | 613 | setVisibility(id, true); |
570 | 614 | if (cb) { |
571 | | - var o = getObjectById(id); // test whether there is an HTML object element or not |
572 | | - if (o && typeof o.SetVariable != UNDEF) { |
| 615 | + var o = getObjectById(id); // test whether there is an |
| 616 | + // HTML object element or |
| 617 | + // not |
| 618 | + if (o && typeof o.SetVariable != UNDEF) { |
573 | 619 | cbObj.success = true; |
574 | 620 | cbObj.ref = o; |
575 | 621 | } |
— | — | @@ -578,15 +624,14 @@ |
579 | 625 | } |
580 | 626 | } |
581 | 627 | } |
582 | | - |
| 628 | + |
583 | 629 | function getObjectById(objectIdStr) { |
584 | 630 | var r = null; |
585 | 631 | var o = getElementById(objectIdStr); |
586 | 632 | if (o && o.nodeName == "OBJECT") { |
587 | 633 | if (typeof o.SetVariable != UNDEF) { |
588 | 634 | r = o; |
589 | | - } |
590 | | - else { |
| 635 | + } else { |
591 | 636 | var n = o.getElementsByTagName(OBJECT)[0]; |
592 | 637 | if (n) { |
593 | 638 | r = n; |
— | — | @@ -595,59 +640,77 @@ |
596 | 641 | } |
597 | 642 | return r; |
598 | 643 | } |
599 | | - |
600 | | - /* Requirements for Adobe Express Install |
601 | | - - only one instance can be active at a time |
602 | | - - fp 6.0.65 or higher |
603 | | - - Win/Mac OS only |
604 | | - - no Webkit engines older than version 312 |
605 | | - */ |
| 644 | + |
| 645 | + /* |
| 646 | + * Requirements for Adobe Express Install - only one instance can be active |
| 647 | + * at a time - fp 6.0.65 or higher - Win/Mac OS only - no Webkit engines |
| 648 | + * older than version 312 |
| 649 | + */ |
606 | 650 | function canExpressInstall() { |
607 | | - return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); |
| 651 | + return !isExpressInstallActive && hasPlayerVersion("6.0.65") |
| 652 | + && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312); |
608 | 653 | } |
609 | | - |
610 | | - /* Show the Adobe Express Install dialog |
611 | | - - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 |
612 | | - */ |
| 654 | + |
| 655 | + /* |
| 656 | + * Show the Adobe Express Install dialog - Reference: |
| 657 | + * http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 |
| 658 | + */ |
613 | 659 | function showExpressInstall(att, par, replaceElemIdStr, callbackFn) { |
614 | 660 | isExpressInstallActive = true; |
615 | 661 | storedCallbackFn = callbackFn || null; |
616 | | - storedCallbackObj = {success:false, id:replaceElemIdStr}; |
| 662 | + storedCallbackObj = { |
| 663 | + success : false, |
| 664 | + id : replaceElemIdStr |
| 665 | + }; |
617 | 666 | var obj = getElementById(replaceElemIdStr); |
618 | 667 | if (obj) { |
619 | 668 | if (obj.nodeName == "OBJECT") { // static publishing |
620 | 669 | storedAltContent = abstractAltContent(obj); |
621 | 670 | storedAltContentId = null; |
622 | | - } |
623 | | - else { // dynamic publishing |
| 671 | + } else { // dynamic publishing |
624 | 672 | storedAltContent = obj; |
625 | 673 | storedAltContentId = replaceElemIdStr; |
626 | 674 | } |
627 | 675 | att.id = EXPRESS_INSTALL_ID; |
628 | | - if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; } |
629 | | - if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; } |
| 676 | + if (typeof att.width == UNDEF |
| 677 | + || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { |
| 678 | + att.width = "310"; |
| 679 | + } |
| 680 | + if (typeof att.height == UNDEF |
| 681 | + || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { |
| 682 | + att.height = "137"; |
| 683 | + } |
630 | 684 | doc.title = doc.title.slice(0, 47) + " - Flash Player Installation"; |
631 | | - var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", |
632 | | - fv = "MMredirectURL=" + win.location.toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; |
| 685 | + var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn", fv = "MMredirectURL=" |
| 686 | + + win.location.toString().replace(/&/g, "%26") |
| 687 | + + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title; |
633 | 688 | if (typeof par.flashvars != UNDEF) { |
634 | 689 | par.flashvars += "&" + fv; |
635 | | - } |
636 | | - else { |
| 690 | + } else { |
637 | 691 | par.flashvars = fv; |
638 | 692 | } |
639 | | - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, |
640 | | - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work |
| 693 | + // IE only: when a SWF is loading (AND: not available in cache) wait |
| 694 | + // for the readyState of the object element to become 4 before |
| 695 | + // removing it, |
| 696 | + // because you cannot properly cancel a loading SWF file without |
| 697 | + // breaking browser load references, also obj.onreadystatechange |
| 698 | + // doesn't work |
641 | 699 | if (ua.ie && ua.win && obj.readyState != 4) { |
642 | 700 | var newObj = createElement("div"); |
643 | 701 | replaceElemIdStr += "SWFObjectNew"; |
644 | 702 | newObj.setAttribute("id", replaceElemIdStr); |
645 | | - obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf |
| 703 | + obj.parentNode.insertBefore(newObj, obj); // insert |
| 704 | + // placeholder div |
| 705 | + // that will be |
| 706 | + // replaced by the |
| 707 | + // object element |
| 708 | + // that loads |
| 709 | + // expressinstall.swf |
646 | 710 | obj.style.display = "none"; |
647 | | - (function(){ |
| 711 | + (function() { |
648 | 712 | if (obj.readyState == 4) { |
649 | 713 | obj.parentNode.removeChild(obj); |
650 | | - } |
651 | | - else { |
| 714 | + } else { |
652 | 715 | setTimeout(arguments.callee, 10); |
653 | 716 | } |
654 | 717 | })(); |
— | — | @@ -655,44 +718,49 @@ |
656 | 719 | createSWF(att, par, replaceElemIdStr); |
657 | 720 | } |
658 | 721 | } |
659 | | - |
660 | | - /* Functions to abstract and display alternative content |
661 | | - */ |
| 722 | + |
| 723 | + /* |
| 724 | + * Functions to abstract and display alternative content |
| 725 | + */ |
662 | 726 | function displayAltContent(obj) { |
663 | 727 | if (ua.ie && ua.win && obj.readyState != 4) { |
664 | | - // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it, |
665 | | - // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work |
| 728 | + // IE only: when a SWF is loading (AND: not available in cache) wait |
| 729 | + // for the readyState of the object element to become 4 before |
| 730 | + // removing it, |
| 731 | + // because you cannot properly cancel a loading SWF file without |
| 732 | + // breaking browser load references, also obj.onreadystatechange |
| 733 | + // doesn't work |
666 | 734 | var el = createElement("div"); |
667 | | - obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content |
| 735 | + obj.parentNode.insertBefore(el, obj); // insert placeholder div |
| 736 | + // that will be replaced by |
| 737 | + // the alternative content |
668 | 738 | el.parentNode.replaceChild(abstractAltContent(obj), el); |
669 | 739 | obj.style.display = "none"; |
670 | | - (function(){ |
| 740 | + (function() { |
671 | 741 | if (obj.readyState == 4) { |
672 | 742 | obj.parentNode.removeChild(obj); |
673 | | - } |
674 | | - else { |
| 743 | + } else { |
675 | 744 | setTimeout(arguments.callee, 10); |
676 | 745 | } |
677 | 746 | })(); |
678 | | - } |
679 | | - else { |
| 747 | + } else { |
680 | 748 | obj.parentNode.replaceChild(abstractAltContent(obj), obj); |
681 | 749 | } |
682 | | - } |
| 750 | + } |
683 | 751 | |
684 | 752 | function abstractAltContent(obj) { |
685 | 753 | var ac = createElement("div"); |
686 | 754 | if (ua.win && ua.ie) { |
687 | 755 | ac.innerHTML = obj.innerHTML; |
688 | | - } |
689 | | - else { |
| 756 | + } else { |
690 | 757 | var nestedObj = obj.getElementsByTagName(OBJECT)[0]; |
691 | 758 | if (nestedObj) { |
692 | 759 | var c = nestedObj.childNodes; |
693 | 760 | if (c) { |
694 | 761 | var cl = c.length; |
695 | | - for (var i = 0; i < cl; i++) { |
696 | | - if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) { |
| 762 | + for ( var i = 0; i < cl; i++) { |
| 763 | + if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") |
| 764 | + && !(c[i].nodeType == 8)) { |
697 | 765 | ac.appendChild(c[i].cloneNode(true)); |
698 | 766 | } |
699 | 767 | } |
— | — | @@ -701,56 +769,95 @@ |
702 | 770 | } |
703 | 771 | return ac; |
704 | 772 | } |
705 | | - |
706 | | - /* Cross-browser dynamic SWF creation |
707 | | - */ |
| 773 | + |
| 774 | + /* |
| 775 | + * Cross-browser dynamic SWF creation |
| 776 | + */ |
708 | 777 | function createSWF(attObj, parObj, id) { |
709 | 778 | var r, el = getElementById(id); |
710 | | - if (ua.wk && ua.wk < 312) { return r; } |
| 779 | + if (ua.wk && ua.wk < 312) { |
| 780 | + return r; |
| 781 | + } |
711 | 782 | if (el) { |
712 | | - if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content |
| 783 | + if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the |
| 784 | + // object element, it will |
| 785 | + // inherit the 'id' from the |
| 786 | + // alternative content |
713 | 787 | attObj.id = id; |
714 | 788 | } |
715 | | - if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML |
| 789 | + if (ua.ie && ua.win) { // Internet Explorer + the HTML object |
| 790 | + // element + W3C DOM methods do not combine: |
| 791 | + // fall back to outerHTML |
716 | 792 | var att = ""; |
717 | | - for (var i in attObj) { |
718 | | - if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries |
| 793 | + for ( var i in attObj) { |
| 794 | + if (attObj[i] != Object.prototype[i]) { // filter out |
| 795 | + // prototype |
| 796 | + // additions from |
| 797 | + // other potential |
| 798 | + // libraries |
719 | 799 | if (i.toLowerCase() == "data") { |
720 | 800 | parObj.movie = attObj[i]; |
721 | | - } |
722 | | - else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword |
| 801 | + } else if (i.toLowerCase() == "styleclass") { // 'class' |
| 802 | + // is an |
| 803 | + // ECMA4 |
| 804 | + // reserved |
| 805 | + // keyword |
723 | 806 | att += ' class="' + attObj[i] + '"'; |
724 | | - } |
725 | | - else if (i.toLowerCase() != "classid") { |
| 807 | + } else if (i.toLowerCase() != "classid") { |
726 | 808 | att += ' ' + i + '="' + attObj[i] + '"'; |
727 | 809 | } |
728 | 810 | } |
729 | 811 | } |
730 | 812 | var par = ""; |
731 | | - for (var j in parObj) { |
732 | | - if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries |
733 | | - par += '<param name="' + j + '" value="' + parObj[j] + '" />'; |
| 813 | + for ( var j in parObj) { |
| 814 | + if (parObj[j] != Object.prototype[j]) { // filter out |
| 815 | + // prototype |
| 816 | + // additions from |
| 817 | + // other potential |
| 818 | + // libraries |
| 819 | + par += '<param name="' + j + '" value="' + parObj[j] |
| 820 | + + '" />'; |
734 | 821 | } |
735 | 822 | } |
736 | | - el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>'; |
737 | | - objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only) |
738 | | - r = getElementById(attObj.id); |
739 | | - } |
740 | | - else { // well-behaving browsers |
| 823 | + el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' |
| 824 | + + att + '>' + par + '</object>'; |
| 825 | + objIdArr[objIdArr.length] = attObj.id; // stored to fix object |
| 826 | + // 'leaks' on unload |
| 827 | + // (dynamic publishing |
| 828 | + // only) |
| 829 | + r = getElementById(attObj.id); |
| 830 | + } else { // well-behaving browsers |
741 | 831 | var o = createElement(OBJECT); |
742 | 832 | o.setAttribute("type", FLASH_MIME_TYPE); |
743 | | - for (var m in attObj) { |
744 | | - if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries |
745 | | - if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword |
| 833 | + for ( var m in attObj) { |
| 834 | + if (attObj[m] != Object.prototype[m]) { // filter out |
| 835 | + // prototype |
| 836 | + // additions from |
| 837 | + // other potential |
| 838 | + // libraries |
| 839 | + if (m.toLowerCase() == "styleclass") { // 'class' is an |
| 840 | + // ECMA4 |
| 841 | + // reserved |
| 842 | + // keyword |
746 | 843 | o.setAttribute("class", attObj[m]); |
747 | | - } |
748 | | - else if (m.toLowerCase() != "classid") { // filter out IE specific attribute |
| 844 | + } else if (m.toLowerCase() != "classid") { // filter |
| 845 | + // out IE |
| 846 | + // specific |
| 847 | + // attribute |
749 | 848 | o.setAttribute(m, attObj[m]); |
750 | 849 | } |
751 | 850 | } |
752 | 851 | } |
753 | | - for (var n in parObj) { |
754 | | - if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element |
| 852 | + for ( var n in parObj) { |
| 853 | + if (parObj[n] != Object.prototype[n] |
| 854 | + && n.toLowerCase() != "movie") { // filter out |
| 855 | + // prototype |
| 856 | + // additions |
| 857 | + // from other |
| 858 | + // potential |
| 859 | + // libraries and |
| 860 | + // IE specific |
| 861 | + // param element |
755 | 862 | createObjParam(o, n, parObj[n]); |
756 | 863 | } |
757 | 864 | } |
— | — | @@ -760,41 +867,40 @@ |
761 | 868 | } |
762 | 869 | return r; |
763 | 870 | } |
764 | | - |
| 871 | + |
765 | 872 | function createObjParam(el, pName, pValue) { |
766 | 873 | var p = createElement("param"); |
767 | | - p.setAttribute("name", pName); |
| 874 | + p.setAttribute("name", pName); |
768 | 875 | p.setAttribute("value", pValue); |
769 | 876 | el.appendChild(p); |
770 | 877 | } |
771 | | - |
772 | | - /* Cross-browser SWF removal |
773 | | - - Especially needed to safely and completely remove a SWF in Internet Explorer |
774 | | - */ |
| 878 | + |
| 879 | + /* |
| 880 | + * Cross-browser SWF removal - Especially needed to safely and completely |
| 881 | + * remove a SWF in Internet Explorer |
| 882 | + */ |
775 | 883 | function removeSWF(id) { |
776 | 884 | var obj = getElementById(id); |
777 | 885 | if (obj && obj.nodeName == "OBJECT") { |
778 | 886 | if (ua.ie && ua.win) { |
779 | 887 | obj.style.display = "none"; |
780 | | - (function(){ |
| 888 | + (function() { |
781 | 889 | if (obj.readyState == 4) { |
782 | 890 | removeObjectInIE(id); |
783 | | - } |
784 | | - else { |
| 891 | + } else { |
785 | 892 | setTimeout(arguments.callee, 10); |
786 | 893 | } |
787 | 894 | })(); |
788 | | - } |
789 | | - else { |
| 895 | + } else { |
790 | 896 | obj.parentNode.removeChild(obj); |
791 | 897 | } |
792 | 898 | } |
793 | 899 | } |
794 | | - |
| 900 | + |
795 | 901 | function removeObjectInIE(id) { |
796 | 902 | var obj = getElementById(id); |
797 | 903 | if (obj) { |
798 | | - for (var i in obj) { |
| 904 | + for ( var i in obj) { |
799 | 905 | if (typeof obj[i] == "function") { |
800 | 906 | obj[i] = null; |
801 | 907 | } |
— | — | @@ -802,59 +908,72 @@ |
803 | 909 | obj.parentNode.removeChild(obj); |
804 | 910 | } |
805 | 911 | } |
806 | | - |
807 | | - /* Functions to optimize JavaScript compression |
808 | | - */ |
| 912 | + |
| 913 | + /* |
| 914 | + * Functions to optimize JavaScript compression |
| 915 | + */ |
809 | 916 | function getElementById(id) { |
810 | 917 | var el = null; |
811 | 918 | try { |
812 | 919 | el = doc.getElementById(id); |
| 920 | + } catch (e) { |
813 | 921 | } |
814 | | - catch (e) {} |
815 | 922 | return el; |
816 | 923 | } |
817 | | - |
| 924 | + |
818 | 925 | function createElement(el) { |
819 | 926 | return doc.createElement(el); |
820 | 927 | } |
821 | | - |
822 | | - /* Updated attachEvent function for Internet Explorer |
823 | | - - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks |
824 | | - */ |
| 928 | + |
| 929 | + /* |
| 930 | + * Updated attachEvent function for Internet Explorer - Stores attachEvent |
| 931 | + * information in an Array, so on unload the detachEvent functions can be |
| 932 | + * called to avoid memory leaks |
| 933 | + */ |
825 | 934 | function addListener(target, eventType, fn) { |
826 | 935 | target.attachEvent(eventType, fn); |
827 | | - listenersArr[listenersArr.length] = [target, eventType, fn]; |
| 936 | + listenersArr[listenersArr.length] = [ target, eventType, fn ]; |
828 | 937 | } |
829 | | - |
830 | | - /* Flash Player and SWF content version matching |
831 | | - */ |
| 938 | + |
| 939 | + /* |
| 940 | + * Flash Player and SWF content version matching |
| 941 | + */ |
832 | 942 | function hasPlayerVersion(rv) { |
833 | 943 | var pv = ua.pv, v = rv.split("."); |
834 | 944 | v[0] = parseInt(v[0], 10); |
835 | | - v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0" |
| 945 | + v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" |
| 946 | + // instead of "9.0.0" |
836 | 947 | v[2] = parseInt(v[2], 10) || 0; |
837 | | - return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; |
| 948 | + return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] |
| 949 | + && pv[1] == v[1] && pv[2] >= v[2])) ? true : false; |
838 | 950 | } |
839 | | - |
840 | | - /* Cross-browser dynamic CSS creation |
841 | | - - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php |
842 | | - */ |
| 951 | + |
| 952 | + /* |
| 953 | + * Cross-browser dynamic CSS creation - Based on Bobby van der Sluis' |
| 954 | + * solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php |
| 955 | + */ |
843 | 956 | function createCSS(sel, decl, media, newStyle) { |
844 | | - if (ua.ie && ua.mac) { return; } |
| 957 | + if (ua.ie && ua.mac) { |
| 958 | + return; |
| 959 | + } |
845 | 960 | var h = doc.getElementsByTagName("head")[0]; |
846 | | - if (!h) { return; } // to also support badly authored HTML pages that lack a head element |
| 961 | + if (!h) { |
| 962 | + return; |
| 963 | + } // to also support badly authored HTML pages that lack a head |
| 964 | + // element |
847 | 965 | var m = (media && typeof media == "string") ? media : "screen"; |
848 | 966 | if (newStyle) { |
849 | 967 | dynamicStylesheet = null; |
850 | 968 | dynamicStylesheetMedia = null; |
851 | 969 | } |
852 | | - if (!dynamicStylesheet || dynamicStylesheetMedia != m) { |
| 970 | + if (!dynamicStylesheet || dynamicStylesheetMedia != m) { |
853 | 971 | // create dynamic stylesheet + get a global reference to it |
854 | 972 | var s = createElement("style"); |
855 | 973 | s.setAttribute("type", "text/css"); |
856 | 974 | s.setAttribute("media", m); |
857 | 975 | dynamicStylesheet = h.appendChild(s); |
858 | | - if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) { |
| 976 | + if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF |
| 977 | + && doc.styleSheets.length > 0) { |
859 | 978 | dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1]; |
860 | 979 | } |
861 | 980 | dynamicStylesheetMedia = m; |
— | — | @@ -864,66 +983,77 @@ |
865 | 984 | if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) { |
866 | 985 | dynamicStylesheet.addRule(sel, decl); |
867 | 986 | } |
868 | | - } |
869 | | - else { |
| 987 | + } else { |
870 | 988 | if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) { |
871 | | - dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}")); |
| 989 | + dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" |
| 990 | + + decl + "}")); |
872 | 991 | } |
873 | 992 | } |
874 | 993 | } |
875 | | - |
| 994 | + |
876 | 995 | function setVisibility(id, isVisible) { |
877 | | - if (!autoHideShow) { return; } |
| 996 | + if (!autoHideShow) { |
| 997 | + return; |
| 998 | + } |
878 | 999 | var v = isVisible ? "visible" : "hidden"; |
879 | 1000 | if (isDomLoaded && getElementById(id)) { |
880 | 1001 | getElementById(id).style.visibility = v; |
881 | | - } |
882 | | - else { |
| 1002 | + } else { |
883 | 1003 | createCSS("#" + id, "visibility:" + v); |
884 | 1004 | } |
885 | 1005 | } |
886 | 1006 | |
887 | | - /* Filter to avoid XSS attacks |
888 | | - */ |
| 1007 | + /* |
| 1008 | + * Filter to avoid XSS attacks |
| 1009 | + */ |
889 | 1010 | function urlEncodeIfNecessary(s) { |
890 | 1011 | var regex = /[\\\"<>\.;]/; |
891 | 1012 | var hasBadChars = regex.exec(s) != null; |
892 | | - return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s; |
| 1013 | + return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) |
| 1014 | + : s; |
893 | 1015 | } |
894 | | - |
895 | | - /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only) |
896 | | - */ |
| 1016 | + |
| 1017 | + /* |
| 1018 | + * Release memory to avoid memory leaks caused by closures, fix hanging |
| 1019 | + * audio/video threads and force open sockets/NetConnections to disconnect |
| 1020 | + * (Internet Explorer only) |
| 1021 | + */ |
897 | 1022 | var cleanup = function() { |
898 | 1023 | if (ua.ie && ua.win) { |
899 | 1024 | window.attachEvent("onunload", function() { |
900 | 1025 | // remove listeners to avoid memory leaks |
901 | | - var ll = listenersArr.length; |
902 | | - for (var i = 0; i < ll; i++) { |
903 | | - listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]); |
904 | | - } |
905 | | - // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect |
906 | | - var il = objIdArr.length; |
907 | | - for (var j = 0; j < il; j++) { |
908 | | - removeSWF(objIdArr[j]); |
909 | | - } |
910 | | - // cleanup library's main closures to avoid memory leaks |
911 | | - for (var k in ua) { |
912 | | - ua[k] = null; |
913 | | - } |
914 | | - ua = null; |
915 | | - for (var l in swfobject) { |
916 | | - swfobject[l] = null; |
917 | | - } |
918 | | - swfobject = null; |
919 | | - }); |
| 1026 | + var ll = listenersArr.length; |
| 1027 | + for ( var i = 0; i < ll; i++) { |
| 1028 | + listenersArr[i][0].detachEvent(listenersArr[i][1], |
| 1029 | + listenersArr[i][2]); |
| 1030 | + } |
| 1031 | + // cleanup dynamically embedded objects to fix audio/video |
| 1032 | + // threads and force open sockets and NetConnections to |
| 1033 | + // disconnect |
| 1034 | + var il = objIdArr.length; |
| 1035 | + for ( var j = 0; j < il; j++) { |
| 1036 | + removeSWF(objIdArr[j]); |
| 1037 | + } |
| 1038 | + // cleanup library's main closures to avoid memory leaks |
| 1039 | + for ( var k in ua) { |
| 1040 | + ua[k] = null; |
| 1041 | + } |
| 1042 | + ua = null; |
| 1043 | + for ( var l in swfobject) { |
| 1044 | + swfobject[l] = null; |
| 1045 | + } |
| 1046 | + swfobject = null; |
| 1047 | + }); |
920 | 1048 | } |
921 | 1049 | }(); |
922 | | - |
| 1050 | + |
923 | 1051 | return { |
924 | | - /* Public API |
925 | | - - Reference: http://code.google.com/p/swfobject/wiki/documentation |
926 | | - */ |
927 | | - registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) { |
| 1052 | + /* |
| 1053 | + * Public API - Reference: |
| 1054 | + * http://code.google.com/p/swfobject/wiki/documentation |
| 1055 | + */ |
| 1056 | + registerObject : function(objectIdStr, swfVersionStr, xiSwfUrlStr, |
| 1057 | + callbackFn) { |
928 | 1058 | if (ua.w3 && objectIdStr && swfVersionStr) { |
929 | 1059 | var regObj = {}; |
930 | 1060 | regObj.id = objectIdStr; |
— | — | @@ -932,51 +1062,73 @@ |
933 | 1063 | regObj.callbackFn = callbackFn; |
934 | 1064 | regObjArr[regObjArr.length] = regObj; |
935 | 1065 | setVisibility(objectIdStr, false); |
| 1066 | + } else if (callbackFn) { |
| 1067 | + callbackFn( { |
| 1068 | + success : false, |
| 1069 | + id : objectIdStr |
| 1070 | + }); |
936 | 1071 | } |
937 | | - else if (callbackFn) { |
938 | | - callbackFn({success:false, id:objectIdStr}); |
939 | | - } |
940 | 1072 | }, |
941 | | - |
942 | | - getObjectById: function(objectIdStr) { |
| 1073 | + |
| 1074 | + getObjectById : function(objectIdStr) { |
943 | 1075 | if (ua.w3) { |
944 | 1076 | return getObjectById(objectIdStr); |
945 | 1077 | } |
946 | 1078 | }, |
947 | 1079 | // XXX added by mdale ( since we know the dom is ready, |
948 | | - // this works better. |
949 | | - callDomLoadFunctions: function(){ |
950 | | - callDomLoadFunctions(); |
| 1080 | + // this works better. |
| 1081 | + callDomLoadFunctions : function() { |
| 1082 | + callDomLoadFunctions(); |
951 | 1083 | }, |
952 | | - |
953 | | - embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) { |
954 | | - var callbackObj = {success:false, id:replaceElemIdStr}; |
955 | | - if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) { |
| 1084 | + |
| 1085 | + embedSWF : function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, |
| 1086 | + swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, |
| 1087 | + callbackFn) { |
| 1088 | + var callbackObj = { |
| 1089 | + success : false, |
| 1090 | + id : replaceElemIdStr |
| 1091 | + }; |
| 1092 | + if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr |
| 1093 | + && replaceElemIdStr && widthStr && heightStr |
| 1094 | + && swfVersionStr) { |
956 | 1095 | setVisibility(replaceElemIdStr, false); |
957 | 1096 | addDomLoadEvent(function() { |
958 | 1097 | widthStr += ""; // auto-convert to string |
959 | 1098 | heightStr += ""; |
960 | 1099 | var att = {}; |
961 | 1100 | if (attObj && typeof attObj === OBJECT) { |
962 | | - for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs |
| 1101 | + for ( var i in attObj) { // copy object to avoid the |
| 1102 | + // use of references, |
| 1103 | + // because web authors often |
| 1104 | + // reuse attObj for multiple |
| 1105 | + // SWFs |
963 | 1106 | att[i] = attObj[i]; |
964 | 1107 | } |
965 | 1108 | } |
966 | 1109 | att.data = swfUrlStr; |
967 | 1110 | att.width = widthStr; |
968 | 1111 | att.height = heightStr; |
969 | | - var par = {}; |
| 1112 | + var par = {}; |
970 | 1113 | if (parObj && typeof parObj === OBJECT) { |
971 | | - for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs |
| 1114 | + for ( var j in parObj) { // copy object to avoid the |
| 1115 | + // use of references, |
| 1116 | + // because web authors often |
| 1117 | + // reuse parObj for multiple |
| 1118 | + // SWFs |
972 | 1119 | par[j] = parObj[j]; |
973 | 1120 | } |
974 | 1121 | } |
975 | 1122 | if (flashvarsObj && typeof flashvarsObj === OBJECT) { |
976 | | - for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs |
| 1123 | + for ( var k in flashvarsObj) { // copy object to avoid |
| 1124 | + // the use of |
| 1125 | + // references, because |
| 1126 | + // web authors often |
| 1127 | + // reuse flashvarsObj |
| 1128 | + // for multiple SWFs |
977 | 1129 | if (typeof par.flashvars != UNDEF) { |
978 | | - par.flashvars += "&" + k + "=" + flashvarsObj[k]; |
979 | | - } |
980 | | - else { |
| 1130 | + par.flashvars += "&" + k + "=" |
| 1131 | + + flashvarsObj[k]; |
| 1132 | + } else { |
981 | 1133 | par.flashvars = k + "=" + flashvarsObj[k]; |
982 | 1134 | } |
983 | 1135 | } |
— | — | @@ -988,95 +1140,110 @@ |
989 | 1141 | } |
990 | 1142 | callbackObj.success = true; |
991 | 1143 | callbackObj.ref = obj; |
992 | | - } |
993 | | - else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install |
| 1144 | + } else if (xiSwfUrlStr && canExpressInstall()) { // show |
| 1145 | + // Adobe |
| 1146 | + // Express |
| 1147 | + // Install |
994 | 1148 | att.data = xiSwfUrlStr; |
995 | | - showExpressInstall(att, par, replaceElemIdStr, callbackFn); |
| 1149 | + showExpressInstall(att, par, replaceElemIdStr, |
| 1150 | + callbackFn); |
996 | 1151 | return; |
997 | | - } |
998 | | - else { // show alternative content |
| 1152 | + } else { // show alternative content |
999 | 1153 | setVisibility(replaceElemIdStr, true); |
1000 | 1154 | } |
1001 | | - if (callbackFn) { callbackFn(callbackObj); } |
| 1155 | + if (callbackFn) { |
| 1156 | + callbackFn(callbackObj); |
| 1157 | + } |
1002 | 1158 | }); |
| 1159 | + } else if (callbackFn) { |
| 1160 | + callbackFn(callbackObj); |
1003 | 1161 | } |
1004 | | - else if (callbackFn) { callbackFn(callbackObj); } |
1005 | 1162 | }, |
1006 | | - |
1007 | | - switchOffAutoHideShow: function() { |
| 1163 | + |
| 1164 | + switchOffAutoHideShow : function() { |
1008 | 1165 | autoHideShow = false; |
1009 | 1166 | }, |
1010 | | - |
1011 | | - ua: ua, |
1012 | | - |
1013 | | - getFlashPlayerVersion: function() { |
1014 | | - return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] }; |
| 1167 | + |
| 1168 | + ua : ua, |
| 1169 | + |
| 1170 | + getFlashPlayerVersion : function() { |
| 1171 | + return { |
| 1172 | + major : ua.pv[0], |
| 1173 | + minor : ua.pv[1], |
| 1174 | + release : ua.pv[2] |
| 1175 | + }; |
1015 | 1176 | }, |
1016 | | - |
1017 | | - hasFlashPlayerVersion: hasPlayerVersion, |
1018 | | - |
1019 | | - createSWF: function(attObj, parObj, replaceElemIdStr) { |
| 1177 | + |
| 1178 | + hasFlashPlayerVersion : hasPlayerVersion, |
| 1179 | + |
| 1180 | + createSWF : function(attObj, parObj, replaceElemIdStr) { |
1020 | 1181 | if (ua.w3) { |
1021 | 1182 | return createSWF(attObj, parObj, replaceElemIdStr); |
1022 | | - } |
1023 | | - else { |
| 1183 | + } else { |
1024 | 1184 | return undefined; |
1025 | 1185 | } |
1026 | 1186 | }, |
1027 | | - |
1028 | | - showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) { |
| 1187 | + |
| 1188 | + showExpressInstall : function(att, par, replaceElemIdStr, callbackFn) { |
1029 | 1189 | if (ua.w3 && canExpressInstall()) { |
1030 | 1190 | showExpressInstall(att, par, replaceElemIdStr, callbackFn); |
1031 | 1191 | } |
1032 | 1192 | }, |
1033 | | - |
1034 | | - removeSWF: function(objElemIdStr) { |
| 1193 | + |
| 1194 | + removeSWF : function(objElemIdStr) { |
1035 | 1195 | if (ua.w3) { |
1036 | 1196 | removeSWF(objElemIdStr); |
1037 | 1197 | } |
1038 | 1198 | }, |
1039 | | - |
1040 | | - createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) { |
| 1199 | + |
| 1200 | + createCSS : function(selStr, declStr, mediaStr, newStyleBoolean) { |
1041 | 1201 | if (ua.w3) { |
1042 | 1202 | createCSS(selStr, declStr, mediaStr, newStyleBoolean); |
1043 | 1203 | } |
1044 | 1204 | }, |
1045 | | - |
1046 | | - addDomLoadEvent: addDomLoadEvent, |
1047 | | - |
1048 | | - addLoadEvent: addLoadEvent, |
1049 | | - |
1050 | | - getQueryParamValue: function(param) { |
| 1205 | + |
| 1206 | + addDomLoadEvent : addDomLoadEvent, |
| 1207 | + |
| 1208 | + addLoadEvent : addLoadEvent, |
| 1209 | + |
| 1210 | + getQueryParamValue : function(param) { |
1051 | 1211 | var q = doc.location.search || doc.location.hash; |
1052 | 1212 | if (q) { |
1053 | | - if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark |
1054 | | - if (param == null) { |
1055 | | - return urlEncodeIfNecessary(q); |
1056 | | - } |
1057 | | - var pairs = q.split("&"); |
1058 | | - for (var i = 0; i < pairs.length; i++) { |
1059 | | - if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { |
1060 | | - return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1))); |
1061 | | - } |
1062 | | - } |
| 1213 | + if (/\?/.test(q)) { |
| 1214 | + q = q.split("?")[1]; |
| 1215 | + } // strip question mark |
| 1216 | + if (param == null) { |
| 1217 | + return urlEncodeIfNecessary(q); |
| 1218 | + } |
| 1219 | + var pairs = q.split("&"); |
| 1220 | + for ( var i = 0; i < pairs.length; i++) { |
| 1221 | + if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { |
| 1222 | + return urlEncodeIfNecessary(pairs[i].substring((pairs[i] |
| 1223 | + .indexOf("=") + 1))); |
1063 | 1224 | } |
1064 | | - return ""; |
1065 | | - }, |
1066 | | - |
1067 | | - // For internal usage only |
1068 | | - expressInstallCallback: function() { |
| 1225 | + } |
| 1226 | + } |
| 1227 | + return ""; |
| 1228 | +}, |
| 1229 | + |
| 1230 | +// For internal usage only |
| 1231 | + expressInstallCallback : function() { |
1069 | 1232 | if (isExpressInstallActive) { |
1070 | 1233 | var obj = getElementById(EXPRESS_INSTALL_ID); |
1071 | 1234 | if (obj && storedAltContent) { |
1072 | 1235 | obj.parentNode.replaceChild(storedAltContent, obj); |
1073 | 1236 | if (storedAltContentId) { |
1074 | 1237 | setVisibility(storedAltContentId, true); |
1075 | | - if (ua.ie && ua.win) { storedAltContent.style.display = "block"; } |
| 1238 | + if (ua.ie && ua.win) { |
| 1239 | + storedAltContent.style.display = "block"; |
| 1240 | + } |
1076 | 1241 | } |
1077 | | - if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); } |
| 1242 | + if (storedCallbackFn) { |
| 1243 | + storedCallbackFn(storedCallbackObj); |
| 1244 | + } |
1078 | 1245 | } |
1079 | 1246 | isExpressInstallActive = false; |
1080 | | - } |
| 1247 | + } |
1081 | 1248 | } |
1082 | 1249 | }; |
1083 | 1250 | }(); |
\ No newline at end of file |