Index: branches/MwEmbedStandAlone/mwEmbed.js |
— | — | @@ -3,15 +3,13 @@ |
4 | 4 | 'video audio source track'.replace(/\w+/g, function(n){ document.createElement(n); }); |
5 | 5 | |
6 | 6 | /** |
7 | | - * @license |
8 | | - * mwEmbed |
9 | | - * Dual licensed under the MIT or GPL Version 2 licenses. |
10 | | - * |
| 7 | + * @license mwEmbed Dual licensed under the MIT or GPL Version 2 licenses. |
| 8 | + * |
11 | 9 | * @copyright (C) 2010 Kaltura |
12 | 10 | * @author Michael Dale ( michael.dale at kaltura.com ) |
13 | | - * |
| 11 | + * |
14 | 12 | * @url http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library |
15 | | - * |
| 13 | + * |
16 | 14 | * Libraries used include code license in headers |
17 | 15 | */ |
18 | 16 | |
— | — | @@ -68,7 +66,7 @@ |
69 | 67 | |
70 | 68 | /** |
71 | 69 | * Setter for configuration values |
72 | | - * |
| 70 | + * |
73 | 71 | * @param [Mixed] |
74 | 72 | * name Name of configuration value {Object} Will iderate through |
75 | 73 | * each key and call setConfig {String} Will set configuration by |
— | — | @@ -122,7 +120,7 @@ |
123 | 121 | /** |
124 | 122 | * Set a default config value Will only update configuration if no value is |
125 | 123 | * present |
126 | | - * |
| 124 | + * |
127 | 125 | * @param [Mixed] |
128 | 126 | * value Set configuration name to value {Object} Will idorate |
129 | 127 | * through each key and call setDefaultConfig {String} Will set |
— | — | @@ -143,7 +141,7 @@ |
144 | 142 | |
145 | 143 | /** |
146 | 144 | * Getter for configuration values |
147 | | - * |
| 145 | + * |
148 | 146 | * @param {String} |
149 | 147 | * name of configuration value to get |
150 | 148 | * @return {Mixed} value of configuration key returns "false" if key not |
— | — | @@ -155,8 +153,8 @@ |
156 | 154 | return false; |
157 | 155 | }; |
158 | 156 | /** |
159 | | - * Get all the non-default configuration |
160 | | - * ( useful for passing state to iframes in limited hash url length of a few K ) |
| 157 | + * Get all the non-default configuration ( useful for passing state to |
| 158 | + * iframes in limited hash url length of a few K ) |
161 | 159 | */ |
162 | 160 | mw.getNonDefaultConfigObject = function(){ |
163 | 161 | var nonDefaultConfig = {}; |
— | — | @@ -169,16 +167,16 @@ |
170 | 168 | |
171 | 169 | /** |
172 | 170 | * Loads the mwUserConfig from a cookie. |
173 | | - * |
| 171 | + * |
174 | 172 | * Modules that want to use "User Config" should call this setup function in |
175 | 173 | * their moduleLoader code. |
176 | | - * |
| 174 | + * |
177 | 175 | * For performance interfaces using "user config" should load '$j.cookie' & |
178 | 176 | * 'JSON' in their module loader |
179 | | - * |
| 177 | + * |
180 | 178 | * By abstracting user preference we could eventually integrate a persistent |
181 | 179 | * per-account preference system on the server. |
182 | | - * |
| 180 | + * |
183 | 181 | * @parma {Function} callback Function to be called once userPrefrences are |
184 | 182 | * loaded |
185 | 183 | */ |
— | — | @@ -205,7 +203,7 @@ |
206 | 204 | /** |
207 | 205 | * Save a user configuration var to a cookie & local global variable Loads |
208 | 206 | * the cookie plugin if not already loaded |
209 | | - * |
| 207 | + * |
210 | 208 | * @param {String} |
211 | 209 | * name Name of user configuration value |
212 | 210 | * @param {String} |
— | — | @@ -225,7 +223,7 @@ |
226 | 224 | |
227 | 225 | /** |
228 | 226 | * Save a user configuration var to a cookie & local global variable |
229 | | - * |
| 227 | + * |
230 | 228 | * @param {String} |
231 | 229 | * name Name of user configuration value |
232 | 230 | * @return value of the configuration name false if the configuration name |
— | — | @@ -239,9 +237,9 @@ |
240 | 238 | |
241 | 239 | /** |
242 | 240 | * Add a hook system for a target object / interface |
243 | | - * |
| 241 | + * |
244 | 242 | * depricated you should instead use jQuery's bind and trigger |
245 | | - * |
| 243 | + * |
246 | 244 | * @param {Object} |
247 | 245 | * targetObj Interface Object to add hook system to. |
248 | 246 | */ |
— | — | @@ -252,9 +250,9 @@ |
253 | 251 | |
254 | 252 | /** |
255 | 253 | * Adds a hook to the target object |
256 | | - * |
| 254 | + * |
257 | 255 | * Should be called by clients to setup named hooks |
258 | | - * |
| 256 | + * |
259 | 257 | * @param {String} |
260 | 258 | * hookName Name of hook to be added |
261 | 259 | * @param {Function} |
— | — | @@ -269,9 +267,9 @@ |
270 | 268 | |
271 | 269 | /** |
272 | 270 | * Runs all the hooks by a given name with reference to the host object |
273 | | - * |
| 271 | + * |
274 | 272 | * Should be called by the host object at named execution points |
275 | | - * |
| 273 | + * |
276 | 274 | * @param {String} |
277 | 275 | * hookName Name of hook to be called |
278 | 276 | * @return Value of hook result true interface should continue function |
— | — | @@ -301,7 +299,7 @@ |
302 | 300 | mw.loader = { |
303 | 301 | /** |
304 | 302 | * Javascript Module Loader functions |
305 | | - * |
| 303 | + * |
306 | 304 | * @key Name of Module |
307 | 305 | * @value function code to load module |
308 | 306 | */ |
— | — | @@ -309,7 +307,7 @@ |
310 | 308 | |
311 | 309 | /** |
312 | 310 | * Module resource list queue. |
313 | | - * |
| 311 | + * |
314 | 312 | * @key Name of Module |
315 | 313 | * @value .resourceList list of resources to be loaded .functionQueue |
316 | 314 | * list of functions to be run once module is ready |
— | — | @@ -318,21 +316,21 @@ |
319 | 317 | |
320 | 318 | /** |
321 | 319 | * Javascript Class Paths |
322 | | - * |
| 320 | + * |
323 | 321 | * @key Name of resource |
324 | 322 | * @value Class file path |
325 | 323 | */ |
326 | 324 | resourcePaths : { }, |
327 | 325 | |
328 | 326 | /** |
329 | | - * Stores resources that have been requested ( to avoid re-requesting the same resources ) |
330 | | - * in concurrent requests ) |
| 327 | + * Stores resources that have been requested ( to avoid re-requesting |
| 328 | + * the same resources ) in concurrent requests ) |
331 | 329 | */ |
332 | 330 | requestedResourceQueue: { }, |
333 | 331 | |
334 | 332 | /** |
335 | 333 | * javascript Resource Paths |
336 | | - * |
| 334 | + * |
337 | 335 | * @key Name of resource |
338 | 336 | * @value Name of depenent style sheet |
339 | 337 | */ |
— | — | @@ -340,34 +338,34 @@ |
341 | 339 | |
342 | 340 | /** |
343 | 341 | * Core load function: |
344 | | - * |
| 342 | + * |
345 | 343 | * @param {Mixed} |
346 | 344 | * loadRequest: |
347 | | - * |
| 345 | + * |
348 | 346 | * {String} Name of a module to be loaded Modules are added via |
349 | 347 | * addModuleLoader and can define custom code needed to check config and |
350 | 348 | * return a list of resources to be loaded |
351 | | - * |
| 349 | + * |
352 | 350 | * {String} Name of a resource to loaded. Resources are added via |
353 | 351 | * addResourcePaths function Using defined resource names avoids loading |
354 | 352 | * the same resource twice by first checking if the named resource is |
355 | 353 | * defined in the global javascript scope variable |
356 | | - * |
| 354 | + * |
357 | 355 | * {String} Absolute or relative to url path The same file won't be |
358 | 356 | * loaded twice |
359 | | - * |
| 357 | + * |
360 | 358 | * {Array} can be an array of any combination of the above strings. Will |
361 | 359 | * be loaded in-order or in a single resource loader request if |
362 | 360 | * scriptLoader is available. |
363 | | - * |
| 361 | + * |
364 | 362 | * {Array} {Array} Can be a set of Arrays for loading. Some browsers |
365 | 363 | * execute included scripts out of order. This lets you chain sets of |
366 | 364 | * request for those browsers. If using the server side resource loader |
367 | 365 | * order is preserved in output and a single request will be used. |
368 | | - * |
| 366 | + * |
369 | 367 | * @param {Function} |
370 | 368 | * callback Function called once loading is complete |
371 | | - * |
| 369 | + * |
372 | 370 | */ |
373 | 371 | load: function( loadRequest, instanceCallback ) { |
374 | 372 | // mw.log("mw.load:: " + loadRequest ); |
— | — | @@ -418,17 +416,17 @@ |
419 | 417 | |
420 | 418 | // xxx should use refactor "ready" stuff into a "domReady" class |
421 | 419 | // So we would not have local scope globals like this: |
422 | | - //if ( mwReadyFlag ) { |
| 420 | + // if ( mwReadyFlag ) { |
423 | 421 | // Load the module directly if load request is after |
424 | 422 | // mw.ready has run |
425 | 423 | this.load( resourceSet, callback ); |
426 | | - //} else { |
427 | | - // this.addToModuleLoaderQueue( |
428 | | - // loadRequest, |
429 | | - // resourceSet, |
430 | | - // callback |
431 | | - // ); |
432 | | - //} |
| 424 | + // } else { |
| 425 | + // this.addToModuleLoaderQueue( |
| 426 | + // loadRequest, |
| 427 | + // resourceSet, |
| 428 | + // callback |
| 429 | + // ); |
| 430 | + // } |
433 | 431 | return ; |
434 | 432 | } |
435 | 433 | |
— | — | @@ -504,7 +502,7 @@ |
505 | 503 | /** |
506 | 504 | * Load a set of scripts. Will issue many load requests or package the |
507 | 505 | * request for the resource loader |
508 | | - * |
| 506 | + * |
509 | 507 | * @param {Object} |
510 | 508 | * loadSet Set of scripts to be loaded |
511 | 509 | * @param {Function} |
— | — | @@ -543,12 +541,12 @@ |
544 | 542 | } |
545 | 543 | |
546 | 544 | // We are infact loading many: |
547 | | - //mw.log("mw.load: LoadMany:: " + loadSet ); |
| 545 | + // mw.log("mw.load: LoadMany:: " + loadSet ); |
548 | 546 | |
549 | 547 | // Issue the load request check check loadStates to see if we are |
550 | 548 | // "done" |
551 | 549 | for( var loadName in loadStates ) { |
552 | | - //mw.log("loadMany: load: " + loadName ); |
| 550 | + // mw.log("loadMany: load: " + loadName ); |
553 | 551 | this.load( loadName, function ( loadName ) { |
554 | 552 | loadStates[ loadName ] = 1; |
555 | 553 | |
— | — | @@ -573,11 +571,11 @@ |
574 | 572 | |
575 | 573 | /** |
576 | 574 | * Get grouped load state for script loader |
577 | | - * |
| 575 | + * |
578 | 576 | * Groups the scriptRequest where possible: Modules include "loader |
579 | 577 | * code" so they are separated into pre-condition code to be run for |
580 | 578 | * subsequent requests |
581 | | - * |
| 579 | + * |
582 | 580 | * @param {Object} |
583 | 581 | * loadSet Loadset to return grouped |
584 | 582 | * @return {Object} grouped loadSet |
— | — | @@ -605,7 +603,8 @@ |
606 | 604 | for( var i=0; i < groupedLoadSet.length; i++ ) { |
607 | 605 | var loadName = groupedLoadSet[ i ]; |
608 | 606 | if( this.getResourcePath( loadName ) ) { |
609 | | - // Check if not already in request queue and not defined in global namespace |
| 607 | + // Check if not already in request queue and not defined in |
| 608 | + // global namespace |
610 | 609 | if( !mw.isset( loadName ) && ! uniqueResourceName[ loadName] ){ |
611 | 610 | groupClassKey += coma + loadName; |
612 | 611 | coma = ','; |
— | — | @@ -645,7 +644,7 @@ |
646 | 645 | /** |
647 | 646 | * Load a sets of scripts satisfy dependency order for browsers that |
648 | 647 | * execute dynamically included scripts out of order |
649 | | - * |
| 648 | + * |
650 | 649 | * @param {Object} |
651 | 650 | * loadChain A set of javascript arrays to be loaded. Sets |
652 | 651 | * are requested in array order. |
— | — | @@ -815,7 +814,7 @@ |
816 | 815 | |
817 | 816 | /** |
818 | 817 | * Loads javascript or css associated with a resourceName |
819 | | - * |
| 818 | + * |
820 | 819 | * @param {String} |
821 | 820 | * resourceName Name of resource to load |
822 | 821 | * @param {Function} |
— | — | @@ -884,7 +883,8 @@ |
885 | 884 | // Send warning if resourceName is not defined |
886 | 885 | if(! mw.isset( resourceName ) |
887 | 886 | && mwLoadDoneCB[ resourceName ] != 'done' ) { |
888 | | - // mw.log( 'Possible Error: ' + resourceName +' not set in time, or not defined in:' + "\n" |
| 887 | + // mw.log( 'Possible Error: ' + resourceName +' not set in |
| 888 | + // time, or not defined in:' + "\n" |
889 | 889 | // + _this.getResourcePath( resourceName ) ); |
890 | 890 | } |
891 | 891 | |
— | — | @@ -920,7 +920,7 @@ |
921 | 921 | |
922 | 922 | /** |
923 | 923 | * Adds a module to the mwLoader object |
924 | | - * |
| 924 | + * |
925 | 925 | * @param {String} |
926 | 926 | * name Name of module |
927 | 927 | * @param {Function} |
— | — | @@ -932,11 +932,11 @@ |
933 | 933 | |
934 | 934 | /** |
935 | 935 | * Adds resource file path key value pairs |
936 | | - * |
| 936 | + * |
937 | 937 | * @param {Object} |
938 | 938 | * resourceSet JSON formated list of resource name file path |
939 | 939 | * pairs. |
940 | | - * |
| 940 | + * |
941 | 941 | * resourceSet must be strict JSON to allow the php scriptLoader to |
942 | 942 | * parse the file paths. |
943 | 943 | */ |
— | — | @@ -951,7 +951,7 @@ |
952 | 952 | |
953 | 953 | /* |
954 | 954 | * Adds a named style sheet dependency to a named resource |
955 | | - * |
| 955 | + * |
956 | 956 | * @parma {Object} resourceSet JSON formated list of resource names and |
957 | 957 | * associated style sheet names |
958 | 958 | */ |
— | — | @@ -974,7 +974,7 @@ |
975 | 975 | |
976 | 976 | /** |
977 | 977 | * Load done callback for script loader |
978 | | - * |
| 978 | + * |
979 | 979 | * @param {String} |
980 | 980 | * requestName Name of the load request |
981 | 981 | */ |
— | — | @@ -1004,7 +1004,7 @@ |
1005 | 1005 | |
1006 | 1006 | /** |
1007 | 1007 | * Set a load done callback |
1008 | | - * |
| 1008 | + * |
1009 | 1009 | * @param {String} |
1010 | 1010 | * requestName Name of resource or request set |
1011 | 1011 | * @param {Function} |
— | — | @@ -1025,7 +1025,7 @@ |
1026 | 1026 | /** |
1027 | 1027 | * Shortcut entry points / convenience functions: Lets you write mw.load() |
1028 | 1028 | * instead of mw.loader.load() only these entry points should be used. |
1029 | | - * |
| 1029 | + * |
1030 | 1030 | * future closure optimizations could minify internal function names |
1031 | 1031 | */ |
1032 | 1032 | |
— | — | @@ -1068,7 +1068,7 @@ |
1069 | 1069 | |
1070 | 1070 | /** |
1071 | 1071 | * addLoaderDialog small helper for displaying a loading dialog |
1072 | | - * |
| 1072 | + * |
1073 | 1073 | * @param {String} |
1074 | 1074 | * dialogHtml text Html of the loader msg |
1075 | 1075 | */ |
— | — | @@ -1104,13 +1104,12 @@ |
1105 | 1105 | |
1106 | 1106 | /** |
1107 | 1107 | * Add a (temporary) dialog window: |
1108 | | - * |
1109 | | - * @param {Object} with following keys: |
1110 | | - * title: {String} Title string for the dialog |
1111 | | - * content: {String} to be inserted in msg box |
1112 | | - * buttons: {Object} A button object for the dialog Can be a string |
1113 | | - * for the close button |
1114 | | - * any jquery.ui.dialog option |
| 1108 | + * |
| 1109 | + * @param {Object} |
| 1110 | + * with following keys: title: {String} Title string for the |
| 1111 | + * dialog content: {String} to be inserted in msg box buttons: |
| 1112 | + * {Object} A button object for the dialog Can be a string for |
| 1113 | + * the close button any jquery.ui.dialog option |
1115 | 1114 | */ |
1116 | 1115 | mw.addDialog = function ( options ) { |
1117 | 1116 | // Remove any other dialog |
— | — | @@ -1182,7 +1181,7 @@ |
1183 | 1182 | mw.isIphone = function(){ |
1184 | 1183 | return ( navigator.userAgent.indexOf('iPhone') != -1 && ! mw.isIpad() ); |
1185 | 1184 | }; |
1186 | | - // Uses hack described at: |
| 1185 | + // Uses hack described at: |
1187 | 1186 | // http://www.bdoran.co.uk/2010/07/19/detecting-the-iphone4-and-resolution-with-javascript-or-php/ |
1188 | 1187 | mw.isIphone4 = function(){ |
1189 | 1188 | return ( mw.isIphone() && ( window.devicePixelRatio && window.devicePixelRatio >= 2 ) ); |
— | — | @@ -1193,17 +1192,18 @@ |
1194 | 1193 | mw.isIpad = function(){ |
1195 | 1194 | return ( navigator.userAgent.indexOf('iPad') != -1 ); |
1196 | 1195 | }; |
1197 | | - // Android 2 has some restrictions vs other mobile platforms |
| 1196 | + // Android 2 has some restrictions vs other mobile platforms |
1198 | 1197 | mw.isAndroid2 = function(){ |
1199 | 1198 | return ( navigator.userAgent.indexOf( 'Android 2.') != -1 ); |
1200 | 1199 | }; |
1201 | 1200 | |
1202 | 1201 | /** |
1203 | 1202 | * Fallforward system by default prefers flash. |
1204 | | - * |
1205 | | - * This is separate from the EmbedPlayer library detection to provide package loading control |
1206 | | - * NOTE: should be phased out in favor of browser feature detection where possible |
1207 | | - * |
| 1203 | + * |
| 1204 | + * This is separate from the EmbedPlayer library detection to provide |
| 1205 | + * package loading control NOTE: should be phased out in favor of browser |
| 1206 | + * feature detection where possible |
| 1207 | + * |
1208 | 1208 | */ |
1209 | 1209 | mw.isHTML5FallForwardNative = function(){ |
1210 | 1210 | if( mw.isMobileHTML5() ){ |
— | — | @@ -1213,12 +1213,13 @@ |
1214 | 1214 | if( document.URL.indexOf('forceMobileHTML5') != -1 ){ |
1215 | 1215 | return true; |
1216 | 1216 | } |
1217 | | - // Fall forward native: |
| 1217 | + // Fall forward native: |
1218 | 1218 | // if the browser supports flash ( don't use html5 ) |
1219 | 1219 | if( mw.supportsFlash() ){ |
1220 | 1220 | return false; |
1221 | 1221 | } |
1222 | | - // No flash return true if the browser supports html5 video tag with basic support for canPlayType: |
| 1222 | + // No flash return true if the browser supports html5 video tag with |
| 1223 | + // basic support for canPlayType: |
1223 | 1224 | if( mw.supportsHTML5() ){ |
1224 | 1225 | return true; |
1225 | 1226 | } |
— | — | @@ -1227,7 +1228,7 @@ |
1228 | 1229 | } |
1229 | 1230 | |
1230 | 1231 | mw.isMobileHTML5 = function(){ |
1231 | | - // Check for a mobile html5 user agent: |
| 1232 | + // Check for a mobile html5 user agent: |
1232 | 1233 | if ( mw.isIphone() || |
1233 | 1234 | mw.isIpod() || |
1234 | 1235 | mw.isIpad() || |
— | — | @@ -1238,7 +1239,7 @@ |
1239 | 1240 | return false; |
1240 | 1241 | } |
1241 | 1242 | mw.supportsHTML5 = function(){ |
1242 | | - // Blackberry is evil in its response to canPlayType calls. |
| 1243 | + // Blackberry is evil in its response to canPlayType calls. |
1243 | 1244 | if( navigator.userAgent.indexOf('BlackBerry') != -1 ){ |
1244 | 1245 | return false ; |
1245 | 1246 | } |
— | — | @@ -1259,13 +1260,13 @@ |
1260 | 1261 | type = type.substr( 0, semicolonPos ); |
1261 | 1262 | } |
1262 | 1263 | if (type == 'application/x-shockwave-flash' ) { |
1263 | | - // flash is installed |
| 1264 | + // flash is installed |
1264 | 1265 | return true; |
1265 | 1266 | } |
1266 | 1267 | } |
1267 | 1268 | } |
1268 | 1269 | |
1269 | | - // for IE: |
| 1270 | + // for IE: |
1270 | 1271 | var hasObj = true; |
1271 | 1272 | if( typeof ActiveXObject != 'undefined' ){ |
1272 | 1273 | try { |
— | — | @@ -1282,7 +1283,7 @@ |
1283 | 1284 | /** |
1284 | 1285 | * Similar to php isset function checks if the variable exists. Does a safe |
1285 | 1286 | * check of a descendant method or variable |
1286 | | - * |
| 1287 | + * |
1287 | 1288 | * @param {String} |
1288 | 1289 | * objectPath |
1289 | 1290 | * @return {Boolean} true if objectPath exists false if objectPath is |
— | — | @@ -1307,7 +1308,7 @@ |
1308 | 1309 | |
1309 | 1310 | /** |
1310 | 1311 | * Wait for a object to be defined and the call the callback |
1311 | | - * |
| 1312 | + * |
1312 | 1313 | * @param {Object} |
1313 | 1314 | * objectName Name of object to be defined |
1314 | 1315 | * @param {Function} |
— | — | @@ -1345,7 +1346,7 @@ |
1346 | 1347 | |
1347 | 1348 | /** |
1348 | 1349 | * Check if an object is empty or if its an empty string. |
1349 | | - * |
| 1350 | + * |
1350 | 1351 | * @param {Object} |
1351 | 1352 | * object Object to be checked |
1352 | 1353 | */ |
— | — | @@ -1371,10 +1372,10 @@ |
1372 | 1373 | |
1373 | 1374 | /** |
1374 | 1375 | * Log a string msg to the console |
1375 | | - * |
| 1376 | + * |
1376 | 1377 | * all mw.log statements will be removed on minification so lots of mw.log |
1377 | 1378 | * calls will not impact performance in non debug mode |
1378 | | - * |
| 1379 | + * |
1379 | 1380 | * @param {String} |
1380 | 1381 | * string String to output to console |
1381 | 1382 | */ |
— | — | @@ -1383,8 +1384,9 @@ |
1384 | 1385 | if ( mw.getConfig( 'Mw.LogPrepend' ) ){ |
1385 | 1386 | string = mw.getConfig( 'Mw.LogPrepend' ) + string; |
1386 | 1387 | } |
1387 | | - // To debug stack size ( useful for iPad / safari that have a 100 call stack limit |
1388 | | - //string = mw.getCallStack().length -1 + ' : ' + string; |
| 1388 | + // To debug stack size ( useful for iPad / safari that have a 100 call |
| 1389 | + // stack limit |
| 1390 | + // string = mw.getCallStack().length -1 + ' : ' + string; |
1389 | 1391 | |
1390 | 1392 | if ( window.console ) { |
1391 | 1393 | window.console.log( string ); |
— | — | @@ -1393,19 +1395,15 @@ |
1394 | 1396 | * Old IE and non-Firebug debug: ( commented out for now ) |
1395 | 1397 | */ |
1396 | 1398 | |
1397 | | - /*var log_elm = document.getElementById('mv_js_log'); |
1398 | | - if(!log_elm) { |
1399 | | - document.getElementsByTagName("body")[0].innerHTML += '<div ' + |
1400 | | - 'style="position:absolute;z-index:500;bottom:0px;left:0px;right:0px;height:200px;">' + |
1401 | | - '<textarea id="mv_js_log" cols="120" rows="12"></textarea>' + |
1402 | | - '</div>'; |
1403 | | - } |
1404 | | - var log_elm = document.getElementById('mv_js_log'); |
1405 | | - if(log_elm) { |
1406 | | - log_elm.value+=string+"\n"; |
1407 | | - // scroll to bottom: |
1408 | | - log_elm.scrollTop = log_elm.scrollHeight; |
1409 | | - }*/ |
| 1399 | + /* |
| 1400 | + * var log_elm = document.getElementById('mv_js_log'); if(!log_elm) { |
| 1401 | + * document.getElementsByTagName("body")[0].innerHTML += '<div ' + |
| 1402 | + * 'style="position:absolute;z-index:500;bottom:0px;left:0px;right:0px;height:200px;">' + '<textarea |
| 1403 | + * id="mv_js_log" cols="120" rows="12"></textarea>' + '</div>'; } |
| 1404 | + * var log_elm = document.getElementById('mv_js_log'); if(log_elm) { |
| 1405 | + * log_elm.value+=string+"\n"; // scroll to bottom: |
| 1406 | + * log_elm.scrollTop = log_elm.scrollHeight; } |
| 1407 | + */ |
1410 | 1408 | } |
1411 | 1409 | }; |
1412 | 1410 | mw.getCallStack = function(){ |
— | — | @@ -1461,11 +1459,11 @@ |
1462 | 1460 | * Enables load hooks to run once mwEmbeed is "ready" Will ensure jQuery is |
1463 | 1461 | * available, is in the $j namespace and mw interfaces and configuration has |
1464 | 1462 | * been loaded and applied |
1465 | | - * |
| 1463 | + * |
1466 | 1464 | * This is different from jQuery(document).ready() ( jQuery ready is not |
1467 | 1465 | * friendly with dynamic includes and not friendly with core interface |
1468 | 1466 | * asynchronous build out. ) |
1469 | | - * |
| 1467 | + * |
1470 | 1468 | * @param {Function} |
1471 | 1469 | * callback Function to run once DOM and jQuery are ready |
1472 | 1470 | */ |
— | — | @@ -1505,8 +1503,8 @@ |
1506 | 1504 | |
1507 | 1505 | /** |
1508 | 1506 | * Wrapper for jQuery getScript, Uses the scriptLoader if enabled |
1509 | | - * |
1510 | | - * |
| 1507 | + * |
| 1508 | + * |
1511 | 1509 | * @param {String} |
1512 | 1510 | * scriptRequest The requested path or resourceNames for the |
1513 | 1511 | * scriptLoader |
— | — | @@ -1563,8 +1561,8 @@ |
1564 | 1562 | } |
1565 | 1563 | |
1566 | 1564 | /** |
1567 | | - * No jQuery OR In debug mode OR Is css file |
1568 | | - * :: inject the script instead of doing an XHR eval |
| 1565 | + * No jQuery OR In debug mode OR Is css file :: inject the script |
| 1566 | + * instead of doing an XHR eval |
1569 | 1567 | */ |
1570 | 1568 | |
1571 | 1569 | // load style sheet directly if requested loading css |
— | — | @@ -1592,7 +1590,7 @@ |
1593 | 1591 | |
1594 | 1592 | /** |
1595 | 1593 | * Add a style sheet string to the document head |
1596 | | - * |
| 1594 | + * |
1597 | 1595 | * @param {String} |
1598 | 1596 | * cssResourceName Name of style sheet that has been defined |
1599 | 1597 | * @param {String} |
— | — | @@ -1623,7 +1621,7 @@ |
1624 | 1622 | |
1625 | 1623 | /** |
1626 | 1624 | * Get a style sheet and append the style sheet to the DOM |
1627 | | - * |
| 1625 | + * |
1628 | 1626 | * @param {Mixed} |
1629 | 1627 | * {String} url Url of the style sheet to be loaded {Function} |
1630 | 1628 | * callback Function called once sheet is ready |
— | — | @@ -1722,7 +1720,7 @@ |
1723 | 1721 | |
1724 | 1722 | /** |
1725 | 1723 | * Get Script loader path |
1726 | | - * |
| 1724 | + * |
1727 | 1725 | * @returns {String}|{Boolean} Url of the scriptLodaer false if the |
1728 | 1726 | * scriptLoader is not used |
1729 | 1727 | */ |
— | — | @@ -1739,7 +1737,7 @@ |
1740 | 1738 | /** |
1741 | 1739 | * Given a float number of seconds, returns npt format response. ( ignore |
1742 | 1740 | * days for now ) |
1743 | | - * |
| 1741 | + * |
1744 | 1742 | * @param {Float} |
1745 | 1743 | * sec Seconds |
1746 | 1744 | * @param {Boolean} |
— | — | @@ -1781,7 +1779,7 @@ |
1782 | 1780 | }; |
1783 | 1781 | /** |
1784 | 1782 | * Given seconds return array with 'days', 'hours', 'min', 'seconds' |
1785 | | - * |
| 1783 | + * |
1786 | 1784 | * @param {float} |
1787 | 1785 | * sec Seconds to be converted into time measurements |
1788 | 1786 | */ |
— | — | @@ -1797,7 +1795,7 @@ |
1798 | 1796 | /** |
1799 | 1797 | * Given a float number of seconds, returns npt format response. ( ignore |
1800 | 1798 | * days for now ) |
1801 | | - * |
| 1799 | + * |
1802 | 1800 | * @param {Float} |
1803 | 1801 | * sec Seconds |
1804 | 1802 | * @param {Boolean} |
— | — | @@ -1914,7 +1912,7 @@ |
1915 | 1913 | |
1916 | 1914 | /** |
1917 | 1915 | * Replace url parameters via newParams key value pairs |
1918 | | - * |
| 1916 | + * |
1919 | 1917 | * @param {String} |
1920 | 1918 | * url Source url to be updated |
1921 | 1919 | * @param {Object} |
— | — | @@ -1966,7 +1964,7 @@ |
1967 | 1965 | |
1968 | 1966 | /** |
1969 | 1967 | * Parse URI function |
1970 | | - * |
| 1968 | + * |
1971 | 1969 | * For documentation on its usage see: |
1972 | 1970 | * http://stevenlevithan.com/demo/parseuri/js/ |
1973 | 1971 | */ |
— | — | @@ -1987,10 +1985,12 @@ |
1988 | 1986 | /** |
1989 | 1987 | * getAbsoluteUrl takes a src and returns the absolute location given the |
1990 | 1988 | * document.URL or a contextUrl param |
1991 | | - * |
1992 | | - * @param {String} src path or url |
1993 | | - * @param {String} contextUrl The domain / context for creating an absolute url |
1994 | | - * from a relative path |
| 1989 | + * |
| 1990 | + * @param {String} |
| 1991 | + * src path or url |
| 1992 | + * @param {String} |
| 1993 | + * contextUrl The domain / context for creating an absolute url |
| 1994 | + * from a relative path |
1995 | 1995 | * @return {String} absolute url |
1996 | 1996 | */ |
1997 | 1997 | mw.absoluteUrl = function( src, contextUrl ) { |
— | — | @@ -2025,10 +2025,8 @@ |
2026 | 2026 | }; |
2027 | 2027 | /** |
2028 | 2028 | * Check if a given source string is likely a url |
2029 | | - * |
2030 | | - * @return {boolean} |
2031 | | - * true if a url |
2032 | | - * false if a string |
| 2029 | + * |
| 2030 | + * @return {boolean} true if a url false if a string |
2033 | 2031 | */ |
2034 | 2032 | mw.isUrl = function( src ){ |
2035 | 2033 | var parsedSrc = mw.parseUri( src ); |
— | — | @@ -2038,7 +2036,7 @@ |
2039 | 2037 | |
2040 | 2038 | /** |
2041 | 2039 | * Escape quotes in a text string |
2042 | | - * |
| 2040 | + * |
2043 | 2041 | * @param {String} |
2044 | 2042 | * text String to be escaped |
2045 | 2043 | * @return {string} escaped text string |
— | — | @@ -2053,7 +2051,7 @@ |
2054 | 2052 | |
2055 | 2053 | /** |
2056 | 2054 | * Escape an HTML text string |
2057 | | - * |
| 2055 | + * |
2058 | 2056 | * @param {String} |
2059 | 2057 | * text String to be escaped |
2060 | 2058 | * @return {string} escaped text html string |
— | — | @@ -2079,7 +2077,7 @@ |
2080 | 2078 | * Add a function to be run during setup ( prior to mw.ready) this is useful |
2081 | 2079 | * for building out interfaces that should be ready before mw.ready is |
2082 | 2080 | * called. |
2083 | | - * |
| 2081 | + * |
2084 | 2082 | * @param {callback} |
2085 | 2083 | * Function Callback function must accept a ready function |
2086 | 2084 | * callback to be called once setup is done |
— | — | @@ -2136,7 +2134,8 @@ |
2137 | 2135 | // Update the image path |
2138 | 2136 | mw.setConfig( 'imagesPath', mw.getMwEmbedPath() + 'skins/common/images/' ); |
2139 | 2137 | |
2140 | | - // Set up AJAX to not send dynamic URLs for loading scripts |
| 2138 | + // Set up AJAX to not send dynamic URLs for loading |
| 2139 | + // scripts |
2141 | 2140 | $j.ajaxSetup( { |
2142 | 2141 | cache: true |
2143 | 2142 | } ); |
— | — | @@ -2145,7 +2144,8 @@ |
2146 | 2145 | mw.Language.magicSetup(); |
2147 | 2146 | |
2148 | 2147 | |
2149 | | - // Special Hack for conditional jquery ui inclusion ( once |
| 2148 | + // Special Hack for conditional jquery ui inclusion ( |
| 2149 | + // once |
2150 | 2150 | // Usability extension |
2151 | 2151 | // registers the jquery.ui skin in mw.style |
2152 | 2152 | if( mw.hasJQueryUiCss() ){ |
— | — | @@ -2160,7 +2160,8 @@ |
2161 | 2161 | // calls |
2162 | 2162 | // and must include a callback. |
2163 | 2163 | // |
2164 | | - // Once complete we can run .ready() queued functions |
| 2164 | + // Once complete we can run .ready() queued |
| 2165 | + // functions |
2165 | 2166 | function runSetupFunctions() { |
2166 | 2167 | if( mwSetupFunctions.length ) { |
2167 | 2168 | mwSetupFunctions.shift()( function() { |
— | — | @@ -2183,7 +2184,7 @@ |
2184 | 2185 | * Checks for jquery ui css by name jquery-ui-1.7.2.css NOTE: this is a hack |
2185 | 2186 | * for usability jquery-ui in the future usability should register a |
2186 | 2187 | * resource in mw.skin |
2187 | | - * |
| 2188 | + * |
2188 | 2189 | * @return true if found, return false if not found |
2189 | 2190 | */ |
2190 | 2191 | mw.hasJQueryUiCss = function(){ |
— | — | @@ -2216,10 +2217,10 @@ |
2217 | 2218 | |
2218 | 2219 | /** |
2219 | 2220 | * Loads the core mwEmbed "loader.js" file config |
2220 | | - * |
| 2221 | + * |
2221 | 2222 | * NOTE: if using the ScriptLoader all the loaders and localization |
2222 | 2223 | * converters are included automatically |
2223 | | - * |
| 2224 | + * |
2224 | 2225 | * @param {Function} |
2225 | 2226 | * callback Function called once core loader file is loaded |
2226 | 2227 | */ |
— | — | @@ -2245,7 +2246,7 @@ |
2246 | 2247 | |
2247 | 2248 | /** |
2248 | 2249 | * Checks if the javascript is a static package ( not using resource loader ) |
2249 | | - * |
| 2250 | + * |
2250 | 2251 | * @return {boolean} true the included script is static false the included |
2251 | 2252 | * script |
2252 | 2253 | */ |
— | — | @@ -2259,7 +2260,7 @@ |
2260 | 2261 | |
2261 | 2262 | /** |
2262 | 2263 | * Check for resource loader module loaders, and localization files |
2263 | | - * |
| 2264 | + * |
2264 | 2265 | * NOTE: if using the ScriptLoader all the loaders and localization |
2265 | 2266 | * converters are included automatically. |
2266 | 2267 | */ |
— | — | @@ -2362,12 +2363,12 @@ |
2363 | 2364 | |
2364 | 2365 | /** |
2365 | 2366 | * Checks if a css style rule exists |
2366 | | - * |
| 2367 | + * |
2367 | 2368 | * On a page with lots of rules it can take some time so avoid calling this |
2368 | 2369 | * function where possible and cache its result |
2369 | | - * |
| 2370 | + * |
2370 | 2371 | * NOTE: this only works for style sheets on the same domain :( |
2371 | | - * |
| 2372 | + * |
2372 | 2373 | * @param {String} |
2373 | 2374 | * styleRule Style rule name to check |
2374 | 2375 | * @return {Boolean} true if the rule exists false if the rule does not |
— | — | @@ -2426,14 +2427,14 @@ |
2427 | 2428 | /** |
2428 | 2429 | * A version comparison utility function Handles version of types |
2429 | 2430 | * {Major}.{MinorN}.{Patch} |
2430 | | - * |
| 2431 | + * |
2431 | 2432 | * Note this just handles version numbers not patch letters. |
2432 | | - * |
| 2433 | + * |
2433 | 2434 | * @param {String} |
2434 | 2435 | * minVersion Minnium version needed |
2435 | 2436 | * @param {String} |
2436 | 2437 | * clientVersion Client version to be checked |
2437 | | - * |
| 2438 | + * |
2438 | 2439 | * @return true if the version is at least of minVersion false if the |
2439 | 2440 | * version is less than minVersion |
2440 | 2441 | */ |
— | — | @@ -2460,23 +2461,26 @@ |
2461 | 2462 | ( function( $ ) { |
2462 | 2463 | |
2463 | 2464 | /** |
2464 | | - * Runs all the triggers on all the named bindings of an object with a single callback |
| 2465 | + * Runs all the triggers on all the named bindings of an object with |
| 2466 | + * a single callback |
2465 | 2467 | * |
2466 | 2468 | * NOTE THIS REQUIRES JQUERY 1.4.2 and above |
2467 | | - * |
2468 | | - * Normal jQuery tirgger calls will run the callback directly multiple times for |
2469 | | - * every binded function. |
2470 | | - * |
2471 | | - * With triggerQueueCallback() callback is not called until all the binded |
2472 | | - * events have been run. |
2473 | | - * |
| 2469 | + * |
| 2470 | + * Normal jQuery tirgger calls will run the callback directly |
| 2471 | + * multiple times for every binded function. |
| 2472 | + * |
| 2473 | + * With triggerQueueCallback() callback is not called until all the |
| 2474 | + * binded events have been run. |
| 2475 | + * |
2474 | 2476 | * @param {string} |
2475 | 2477 | * triggerName Name of trigger to be run |
2476 | 2478 | * @param {object=} |
2477 | | - * arguments Optional arguments object to be passed to the callback |
| 2479 | + * arguments Optional arguments object to be passed to |
| 2480 | + * the callback |
2478 | 2481 | * @param {function} |
2479 | | - * callback Function called once all triggers have been run |
2480 | | - * |
| 2482 | + * callback Function called once all triggers have been |
| 2483 | + * run |
| 2484 | + * |
2481 | 2485 | */ |
2482 | 2486 | $.fn.triggerQueueCallback = function( triggerName, triggerParam, callback ){ |
2483 | 2487 | var targetObject = this; |
— | — | @@ -2485,10 +2489,10 @@ |
2486 | 2490 | callback = triggerParam; |
2487 | 2491 | triggerParam = null; |
2488 | 2492 | } |
2489 | | - // Support namespaced event segmentation ( jQuery |
| 2493 | + // Support namespaced event segmentation ( jQuery |
2490 | 2494 | var triggerBaseName = triggerName.split(".")[0]; |
2491 | 2495 | var triggerNamespace = triggerName.split(".")[1]; |
2492 | | - // Get the callback set |
| 2496 | + // Get the callback set |
2493 | 2497 | var callbackSet = []; |
2494 | 2498 | if( ! triggerNamespace ){ |
2495 | 2499 | callbackSet = $j( targetObject ).data( 'events' )[ triggerBaseName ]; |
— | — | @@ -2509,10 +2513,12 @@ |
2510 | 2514 | |
2511 | 2515 | // Set the callbackCount |
2512 | 2516 | var callbackCount = ( callbackSet.length )? callbackSet.length : 1; |
2513 | | - //mw.log("mwEmbed::jQuery.triggerQueueCallback: " + triggerName + ' number of queued functions:' + callbackCount ); |
| 2517 | + // mw.log("mwEmbed::jQuery.triggerQueueCallback: " + triggerName |
| 2518 | + // + ' number of queued functions:' + callbackCount ); |
2514 | 2519 | var callInx = 0; |
2515 | 2520 | var doCallbackCheck = function() { |
2516 | | - mw.log( 'callback for: ' + mw.getCallStack()[0] + callInx); |
| 2521 | + // mw.log( 'callback for: ' + mw.getCallStack()[0] + |
| 2522 | + // callInx); |
2517 | 2523 | callInx++; |
2518 | 2524 | if( callInx == callbackCount ){ |
2519 | 2525 | callback(); |
— | — | @@ -2537,6 +2543,7 @@ |
2538 | 2544 | } |
2539 | 2545 | return this; |
2540 | 2546 | }; |
| 2547 | + |
2541 | 2548 | /** |
2542 | 2549 | * Add an absolute overlay spinner useful for cases where the |
2543 | 2550 | * element does not display child elements, ( images, video ) |
— | — | @@ -2655,7 +2662,7 @@ |
2656 | 2663 | |
2657 | 2664 | /** |
2658 | 2665 | * Resize a dialog to fit the window |
2659 | | - * |
| 2666 | + * |
2660 | 2667 | * @param {Object} |
2661 | 2668 | * options horizontal and vertical space ( default 50 ) |
2662 | 2669 | */ |
— | — | @@ -2752,13 +2759,7 @@ |
2753 | 2760 | } |
2754 | 2761 | mw.domReady(); |
2755 | 2762 | } |
2756 | | -// temporary hack to work around dom ready breakage when loading |
2757 | | -// dynamically with other dom ready scripts |
2758 | | -if( typeof KALTURA_LOADER_REV != 'undefined' ){ |
2759 | | - mw.domReady(); |
2760 | | -} |
2761 | 2763 | |
2762 | | - |
2763 | 2764 | // If using the resource loader and jQuery has not been set give a warning to |
2764 | 2765 | // the user: |
2765 | 2766 | // (this is needed because packaged loader.js files could refrence jQuery ) |
— | — | @@ -2773,10 +2774,10 @@ |
2774 | 2775 | /** |
2775 | 2776 | * Hack to keep jQuery in $ when its already there, but also use noConflict to |
2776 | 2777 | * get $j = jQuery |
2777 | | - * |
| 2778 | + * |
2778 | 2779 | * This way sites that use $ for jQuery continue to work after including mwEmbed |
2779 | 2780 | * javascript. |
2780 | | - * |
| 2781 | + * |
2781 | 2782 | * Also if jQuery is included prior to mwEmbed we ensure $j is set |
2782 | 2783 | */ |
2783 | 2784 | |
Index: branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js |
— | — | @@ -52,9 +52,9 @@ |
53 | 53 | |
54 | 54 | |
55 | 55 | // Set binding to disable "waitForMeta" for playlist items ( we know the size and length ) |
56 | | - $j( mw ).bind( 'addElementWaitForMetaEvent', function(even, waitForMetaObject ){ |
57 | | - if( $j( waitForMetaObject[ 'playerElement' ] ).hasClass( 'mwPlaylist') ){ |
58 | | - waitForMetaObject[ 'waitForMeta' ] = false; |
| 56 | + $j( mw ).bind( 'checkPlayerWaitForMetaData', function(even, playerElement ){ |
| 57 | + if( $j( playerElement ).hasClass( 'mwPlaylist') ){ |
| 58 | + playerElement.waitForMeta = false; |
59 | 59 | } |
60 | 60 | }); |
61 | 61 | |
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilHooks.js |
— | — | @@ -23,10 +23,9 @@ |
24 | 24 | } ); |
25 | 25 | |
26 | 26 | // Tell embedPlayer not to wait for height / width metadata in cases of smil documents |
27 | | -$j( mw ).bind( 'addElementWaitForMetaEvent', function( event, waitForMetaObject ) { |
28 | | - if( mw.CheckElementForSMIL( waitForMetaObject[ 'playerElement' ] ) ){ |
29 | | - waitForMetaObject[ 'waitForMeta' ] = false; |
30 | | - return false; |
| 27 | +$j( mw ).bind( 'checkPlayerWaitForMetaData', function( event, playerElement ) { |
| 28 | + if( mw.CheckElementForSMIL( playerElement ) ){ |
| 29 | + playerElement.waitForMeta = false; |
31 | 30 | } |
32 | 31 | }); |
33 | 32 | |
Index: branches/MwEmbedStandAlone/modules/MiroSubs/loader.js |
— | — | @@ -4,20 +4,20 @@ |
5 | 5 | |
6 | 6 | // Wrap in mw to not pollute global namespace |
7 | 7 | ( function( mw ) { |
8 | | - mw.addMessages( { |
| 8 | + mw.addMessages({ |
9 | 9 | "mwe-mirosubs-add-universal-subtitles" : "Universal subtitles editor", |
10 | 10 | "mwe-mirosubs-loading-universal-subtitles" : "Loading <i>universal subtitles</i> editor" |
11 | 11 | }); |
12 | 12 | |
13 | 13 | // Add as loader dependency 'mw.style.mirosubsMenu' |
14 | | - mw.addResourcePaths( { |
| 14 | + mw.addResourcePaths({ |
15 | 15 | "mirosubs" : "mirosubs/mirosubs-api.min.js", |
16 | 16 | "mw.MiroSubsConfig" : "mw.MiroSubsConfig.js", |
17 | 17 | "mw.style.mirosubsMenu" : "css/mw.style.mirosubsMenu.css", |
18 | 18 | "mw.style.mirosubswidget" : "mirosubs/media/css/mirosubs-widget.css" |
19 | 19 | }); |
20 | 20 | |
21 | | - mw.setDefaultConfig( { |
| 21 | + mw.setDefaultConfig({ |
22 | 22 | 'MiroSubs.EnableUniversalSubsEditor': true |
23 | 23 | }); |
24 | 24 | |
Index: branches/MwEmbedStandAlone/modules/TimedText/loader.js |
— | — | @@ -84,8 +84,7 @@ |
85 | 85 | } |
86 | 86 | // Check for timed text sources or api/ roe url |
87 | 87 | if ( |
88 | | - ( $j( embedPlayer ).attr( embedPlayer.roe ) |
89 | | - || |
| 88 | + ( |
90 | 89 | $j( embedPlayer ).attr('apititlekey') |
91 | 90 | || |
92 | 91 | $j( embedPlayer ).attr('apiTitleKey' ) |
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -2302,7 +2302,7 @@ |
2303 | 2303 | ); |
2304 | 2304 | mw.log( 'append html: ' + embedHtml ); |
2305 | 2305 | $j( '#clip_edit_disp' ).html( embedHtml ); |
2306 | | - |
| 2306 | + var cat = $j.fn.embedPlayer; |
2307 | 2307 | // Make sure we have the 'EmbedPlayer' module: |
2308 | 2308 | mw.load( 'EmbedPlayer', function() { |
2309 | 2309 | // Strange concurrency issue with callbacks |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | 'EmbedPLayer.IFramePlayer.DomainWhiteList' : '*', |
95 | 95 | |
96 | 96 | // If the iframe should send and receive javascript events across domains via postMessage |
97 | | - 'EmbedPlayer.EnableIframeApi' : false |
| 97 | + 'EmbedPlayer.EnableIframeApi' : true |
98 | 98 | } ); |
99 | 99 | |
100 | 100 | /** |
— | — | @@ -137,10 +137,10 @@ |
138 | 138 | 'titleKey' |
139 | 139 | ] ); |
140 | 140 | |
141 | | - /* |
142 | | - * The default video attributes supported by embedPlayer |
| 141 | + /** |
| 142 | + * Merge in the default video attributes supported by embedPlayer: |
143 | 143 | */ |
144 | | - mw.setDefaultConfig('EmbedPlayer.Attributes', { |
| 144 | + mw.mergeConfig('EmbedPlayer.Attributes', { |
145 | 145 | /* |
146 | 146 | * Base html element attributes: |
147 | 147 | */ |
— | — | @@ -299,12 +299,7 @@ |
300 | 300 | if( $j( rewriteTags ).length != 0 ) { |
301 | 301 | return true; |
302 | 302 | } |
303 | | - |
304 | | - var tagCheckObject = { 'hasTags' : false }; |
305 | | - $j( mw ).trigger( 'LoaderEmbedPlayerCheckForPlayerTags', |
306 | | - [ tagCheckObject ]); |
307 | | - |
308 | | - return tagCheckObject.hasTags; |
| 303 | + return false; |
309 | 304 | }; |
310 | 305 | |
311 | 306 | /** |
— | — | @@ -318,9 +313,14 @@ |
319 | 314 | }); |
320 | 315 | |
321 | 316 | mw.rewritePagePlayerTags = function( callback ) { |
322 | | - var rewriteCount = mw.documentHasPlayerTags() |
323 | | - mw.log( 'EmbedPlayer:: Document::' + rewriteCount); |
324 | | - if( rewriteCount ) { |
| 317 | + mw.log( 'Loader::EmbedPlayer:rewritePagePlayerTags:' + mw.documentHasPlayerTags() ); |
| 318 | + |
| 319 | + // Allow modules to do tag rewrites as well: |
| 320 | + var doModuleTagRewrites = function(){ |
| 321 | + $j(mw).triggerQueueCallback( 'LoadeRewritePlayerTags', callback ); |
| 322 | + } |
| 323 | + |
| 324 | + if( mw.documentHasPlayerTags() ) { |
325 | 325 | var rewriteElementCount = 0; |
326 | 326 | |
327 | 327 | // Set each player to loading ( as early on as possible ) |
— | — | @@ -339,12 +339,11 @@ |
340 | 340 | }); |
341 | 341 | // Load the embedPlayer module ( then run queued hooks ) |
342 | 342 | mw.load( 'EmbedPlayer', function ( ) { |
343 | | - mw.log("EmbedPlayer:: do rewrite players:" + $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).length ); |
344 | 343 | // Rewrite the EmbedPlayer.RewriteTags with the |
345 | | - $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer( callback ); |
| 344 | + $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer( doModuleTagRewrites ); |
346 | 345 | }) |
347 | 346 | } else { |
348 | | - callback(); |
| 347 | + doModuleTagRewrites(); |
349 | 348 | } |
350 | 349 | }; |
351 | 350 | |
— | — | @@ -399,9 +398,11 @@ |
400 | 399 | if( !!document.createElement('video').canPlayType && !$j.browser.safari ) { |
401 | 400 | dependencyRequest[0].push( 'mw.EmbedPlayerNative' ) |
402 | 401 | } |
403 | | - // Check if the iFrame player server is enabled: |
404 | | - //alert('ifmra' + mw.getConfig('EmbedPlayer.EnableIframeApi')); |
405 | | - if ( mw.getConfig('EmbedPlayer.EnableIframeApi') ) { |
| 402 | + // Check if the iFrame player api is enabled and we have a parent iframe url: |
| 403 | + if ( mw.getConfig('EmbedPlayer.EnableIframeApi') |
| 404 | + && |
| 405 | + mw.getConfig( 'EmbedPlayer.IframeParentUrl' ) |
| 406 | + ){ |
406 | 407 | dependencyRequest[0].push('mw.EmbedPlayerNative'); |
407 | 408 | dependencyRequest[0].push('$j.postMessage'); |
408 | 409 | dependencyRequest[0].push('mw.IFramePlayerApiServer'); |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js |
— | — | @@ -13,7 +13,6 @@ |
14 | 14 | |
15 | 15 | mw.includeAllModuleMessages(); |
16 | 16 | |
17 | | - |
18 | 17 | /** |
19 | 18 | * The base source attribute checks also see: |
20 | 19 | * http://dev.w3.org/html5/spec/Overview.html#the-source-element |
— | — | @@ -152,11 +151,13 @@ |
153 | 152 | mw.log( 'EmbedPlayer::trigger: EmbedPlayerManagerReady'); |
154 | 153 | $j( mw ).trigger( 'EmbedPlayerManagerReady' ); |
155 | 154 | } |
156 | | - var addedToPlayerManager = false; |
157 | 155 | // Make sure we have user preference setup ( for setting preferences on |
158 | 156 | // video selection ) |
159 | 157 | mw.setupUserConfig( function() { |
| 158 | + |
| 159 | + var addedToPlayerManager = false; |
160 | 160 | mw.log("EmbedPlayer:: do: " + $j( playerSelect ).length + ' players '); |
| 161 | + |
161 | 162 | // Add each selected element to the player manager: |
162 | 163 | $j( playerSelect ).each( function( index, playerElement) { |
163 | 164 | // Make sure the video tag was not generated by our library: |
— | — | @@ -164,18 +165,20 @@ |
165 | 166 | $j('#loadingSpinner_' + $j( playerElement ).attr('id') ).hide(); |
166 | 167 | mw.log( 'EmbedPlayer::$j.embedPlayer skip embedPlayer gennerated video: ' + playerElement ); |
167 | 168 | } else { |
168 | | - addedToPlayerManager = true; |
169 | | - // Add the embedPlayer ready callback |
170 | | - mw.playerManager.addCallback( callback ); |
| 169 | + addedToPlayerManager = true; |
171 | 170 | // Add the player |
172 | | - mw.playerManager.addElement( playerElement, attributes); |
| 171 | + mw.playerManager.addPlayerElement( playerElement, attributes); |
173 | 172 | } |
174 | | - |
175 | 173 | } ); |
176 | | - // run the callback directly if no players were added to the |
177 | | - // playerManager |
178 | | - if( !addedToPlayerManager && callback ){ |
179 | | - callback(); |
| 174 | + if( addedToPlayerManager ){ |
| 175 | + if( callback ){ |
| 176 | + $j( mw ).bind( "playersReadyEvent", callback ); |
| 177 | + } |
| 178 | + } else { |
| 179 | + // Run the callback directly if no players were added to the |
| 180 | + if( callback ){ |
| 181 | + callback(); |
| 182 | + } |
180 | 183 | } |
181 | 184 | |
182 | 185 | }); |
— | — | @@ -208,21 +211,6 @@ |
209 | 212 | }, |
210 | 213 | |
211 | 214 | /** |
212 | | - * Adds a callback to the callbackFunctions list the callback functions are |
213 | | - * called once the players are ready. |
214 | | - * |
215 | | - * @param {Function} |
216 | | - * callback Function to be called once players are ready |
217 | | - * |
218 | | - * TODO: move all EmbedPlayerManager.addCallback calls to $j( mw ).bind( 'playersReady' ); |
219 | | - */ |
220 | | - addCallback: function( callback ) { |
221 | | - if( typeof callback == 'function' ){ |
222 | | - this.callbackFunctions.push( callback ); |
223 | | - } |
224 | | - }, |
225 | | - |
226 | | - /** |
227 | 215 | * Get the list of players |
228 | 216 | */ |
229 | 217 | getPlayerList: function( ) { |
— | — | @@ -230,7 +218,7 @@ |
231 | 219 | }, |
232 | 220 | |
233 | 221 | /** |
234 | | - * Adds an Element for the embedPlayer to rewrite |
| 222 | + * Adds a player element for the embedPlayer to rewrite |
235 | 223 | * |
236 | 224 | * uses embedPlayer interface on audio / video elements uses mvPlayList |
237 | 225 | * interface on playlist elements |
— | — | @@ -250,12 +238,12 @@ |
251 | 239 | * [Optional] attributes Extra attributes to apply to the player |
252 | 240 | * interface |
253 | 241 | */ |
254 | | - addElement: function( playerElement, attributes ) { |
| 242 | + addPlayerElement: function( playerElement, attributes ) { |
255 | 243 | var _this = this; |
256 | 244 | if ( !playerElement.id || playerElement.id == '' ) { |
257 | 245 | // give the playerElement an id: |
258 | 246 | playerElement.id = 'vid' + ( this.playerList.length + 1 ); |
259 | | - } |
| 247 | + } |
260 | 248 | mw.log('EmbedPlayerManager: addElement:: ' + playerElement.id ); |
261 | 249 | |
262 | 250 | // Add the element id to playerList |
— | — | @@ -265,37 +253,32 @@ |
266 | 254 | // that add to the request set |
267 | 255 | var playerDependencyRequest = []; |
268 | 256 | |
269 | | - // merge in any custom attributes |
| 257 | + // Merge in any custom attributes |
270 | 258 | $j.extend( playerElement, attributes ); |
271 | 259 | |
272 | 260 | // Update the list of dependent libraries for the player |
273 | | - // ( allows extensions to add to the dependency list ) |
| 261 | + // ( allows modules to add to the player dependency list ) |
274 | 262 | mw.embedPlayerUpdateLibraryRequest( playerElement, playerDependencyRequest ); |
| 263 | + |
275 | 264 | // Load any skins we need then swap in the interface |
276 | 265 | mw.load( playerDependencyRequest, function() { |
277 | 266 | |
278 | 267 | var waitForMeta = true; |
279 | 268 | |
280 | | - // Be sure to "stop" the target ( sometimes firefox keeps playing |
| 269 | + // Be sure to "stop" the target ( Firefox 3x keeps playing |
281 | 270 | // the video even though its been removed from the DOM ) |
282 | 271 | if( playerElement.pause ){ |
283 | 272 | playerElement.pause(); |
284 | 273 | } |
| 274 | + |
| 275 | + // Allow modules to override the wait for metadata flag: |
| 276 | + $j( mw ).trigger( 'checkPlayerWaitForMetaData', playerElement ); |
285 | 277 | |
| 278 | + // Update the waitForMeta object if set to boolean false: |
| 279 | + waitForMeta = ( playerElement.waitForMeta === false )? false : true; |
286 | 280 | |
287 | | - // Let extensions determine if its worthwhile to wait for metadata: |
288 | | - // We pass an object to the trigger to preserve reference values |
289 | | - var eventObject = { |
290 | | - 'playerElement' : playerElement, |
291 | | - 'waitForMeta' : waitForMeta |
292 | | - }; |
293 | | - $j( mw ).trigger( 'addElementWaitForMetaEvent', eventObject ); |
294 | 281 | |
295 | | - // update the waitForMeta |
296 | | - waitForMeta = eventObject[ 'waitForMeta' ]; |
297 | | - |
298 | | - |
299 | | - // Set the wait for meta flag if unset by extension |
| 282 | + // Confirm we want to wait for meta data ( if not already set to false by module ) |
300 | 283 | if( waitForMeta ){ |
301 | 284 | waitForMeta = _this.waitForMetaCheck( playerElement ); |
302 | 285 | } |
— | — | @@ -309,30 +292,18 @@ |
310 | 293 | return ; |
311 | 294 | } |
312 | 295 | ranPlayerSwapFlag = true; |
313 | | - |
314 | 296 | mw.log("EmbedPlayer::runPlayerSwap::" + $j( playerElement ).attr('id') ); |
315 | 297 | |
316 | 298 | var playerInterface = new mw.EmbedPlayer( playerElement , attributes); |
317 | 299 | var swapPlayer = _this.swapEmbedPlayerElement( playerElement, playerInterface ); |
| 300 | + |
318 | 301 | |
319 | | - // Copy over any data attributes from the playerElement |
320 | | - if( mw.getConfig( 'EmbedPlayer.DataAttributes' ) ) { |
321 | | - var dataAttr = mw.getConfig( 'EmbedPlayer.DataAttributes' ); |
322 | | - for( var i in dataAttr ){ |
323 | | - if( $j( playerElement ).data( i ) ){ |
324 | | - $j( '#' + playerInterface.id ).data( i, $j( playerElement ).data( i ) ); |
325 | | - } |
326 | | - } |
327 | | - } |
328 | | - |
329 | | - // Pass the id to any hook that needs to interface prior to |
330 | | - // checkPlayerSources |
331 | | - mw.log("EmbedPlayer::addElement :trigger " + playerInterface.id ); |
| 302 | + // Trigger the newEmbedPlayerEvent for embedPlayer interface |
| 303 | + mw.log("EmbedPlayer::addPlayerElement :trigger " + playerInterface.id ); |
332 | 304 | $j( mw ).trigger ( 'newEmbedPlayerEvent', $j( '#' + playerInterface.id ).get(0) ); |
333 | 305 | |
334 | 306 | // Issue the checkPlayerSources call to the new player |
335 | | - // interface: |
336 | | - // make sure to use the element that is in the DOM: |
| 307 | + // interface: make sure to use the element that is in the DOM: |
337 | 308 | $j( '#' + playerInterface.id ).get(0).checkPlayerSources(); |
338 | 309 | } |
339 | 310 | |
— | — | @@ -451,14 +422,12 @@ |
452 | 423 | // Create a new element to swap the player interface into |
453 | 424 | var swapPlayerElement = document.createElement('div'); |
454 | 425 | |
455 | | - // Get properties / methods from playerInterface |
| 426 | + // Get properties / methods from playerInterface: |
456 | 427 | for ( var method in playerInterface ) { |
457 | | - if ( method != 'readyState' ) { // readyState crashes IE ( don't |
458 | | - // include ) |
| 428 | + if ( method != 'readyState' ) { // readyState crashes IE ( don't include ) |
459 | 429 | swapPlayerElement[ method ] = playerInterface[ method ]; |
460 | 430 | } |
461 | 431 | } |
462 | | - |
463 | 432 | // Check if we are using native controls or Persistent player ( should keep the video embed around ) |
464 | 433 | if( playerInterface.useNativePlayerControls() || playerInterface.isPersistentNativePlayer() ) { |
465 | 434 | $j( targetElement ) |
— | — | @@ -527,13 +496,8 @@ |
528 | 497 | $j('.loadingSpinner').remove(); |
529 | 498 | |
530 | 499 | mw.log( "EmbedPlayer::All on-page players ready run playerManager callbacks" ); |
531 | | - // Run queued functions |
532 | | - if( _this.callbackFunctions ) { |
533 | | - while ( _this.callbackFunctions.length ) { |
534 | | - _this.callbackFunctions.shift()(); |
535 | | - } |
536 | | - } |
537 | | - $j(mw).trigger( 'playersReady' ); |
| 500 | + |
| 501 | + $j(mw).trigger( 'playersReadyEvent' ); |
538 | 502 | } |
539 | 503 | } |
540 | 504 | }; |
— | — | @@ -1403,7 +1367,6 @@ |
1404 | 1368 | |
1405 | 1369 | // Set the player size attributes based loaded video element: |
1406 | 1370 | this.loadPlayerSize( element ); |
1407 | | - |
1408 | 1371 | // Set the plugin id |
1409 | 1372 | this.pid = 'pid_' + this.id; |
1410 | 1373 | |
— | — | @@ -1624,7 +1587,9 @@ |
1625 | 1588 | emptySources: function(){ |
1626 | 1589 | if( this.mediaElement ){ |
1627 | 1590 | this.mediaElement.sources = []; |
| 1591 | + this.mediaElement.selectedSource = null; |
1628 | 1592 | } |
| 1593 | + |
1629 | 1594 | }, |
1630 | 1595 | |
1631 | 1596 | /** |
— | — | @@ -2293,7 +2258,10 @@ |
2294 | 2259 | } |
2295 | 2260 | } |
2296 | 2261 | }, |
2297 | | - |
| 2262 | + // update the video poster: |
| 2263 | + updatePosterSrc: function( posterSrc ){ |
| 2264 | + this.poster = posterSrc; |
| 2265 | + }, |
2298 | 2266 | /** |
2299 | 2267 | * Returns the HTML code for the video when it is in thumbnail mode. |
2300 | 2268 | * playing, configuring the player, inline cmml display, HTML linkback, |
— | — | @@ -2395,7 +2363,6 @@ |
2396 | 2364 | */ |
2397 | 2365 | showNativePlayer: function(){ |
2398 | 2366 | var _this = this; |
2399 | | - |
2400 | 2367 | // Empty the player of any child nodes |
2401 | 2368 | $j(this).empty(); |
2402 | 2369 | |
— | — | @@ -2434,7 +2401,7 @@ |
2435 | 2402 | this.applyMediaElementBindings(); |
2436 | 2403 | |
2437 | 2404 | // Android only can play with a special play button ( no native controls |
2438 | | - // persistentNativePlayer has no controls: |
| 2405 | + // persistentNativePlayer has no controls: |
2439 | 2406 | if( mw.isAndroid2() ){ |
2440 | 2407 | this.addPlayBtnLarge(); |
2441 | 2408 | } |
— | — | @@ -2442,9 +2409,15 @@ |
2443 | 2410 | }, |
2444 | 2411 | addPlayBtnLarge:function(){ |
2445 | 2412 | var _this = this; |
2446 | | - $j( '#' + _this.pid ).siblings('.play-btn-large').remove(); |
2447 | | - this.$interface.append( |
2448 | | - this.controlBuilder.getComponent('playButtonLarge') |
| 2413 | + var $pid = $j( '#' + _this.pid ); |
| 2414 | + $pid.siblings('.play-btn-large').remove(); |
| 2415 | + $playButton = this.controlBuilder.getComponent('playButtonLarge'); |
| 2416 | + $pid.after( |
| 2417 | + $playButton |
| 2418 | + .css({ |
| 2419 | + 'left' : parseInt( $pid.position().left ) + parseInt( $playButton.css('left') ), |
| 2420 | + 'top' : parseInt( $pid.position().top ) + parseInt( $playButton.css('top') ) |
| 2421 | + }) |
2449 | 2422 | ); |
2450 | 2423 | }, |
2451 | 2424 | /** |
— | — | @@ -2498,9 +2471,8 @@ |
2499 | 2472 | var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?'; |
2500 | 2473 | var params = {'src[]':[]}; |
2501 | 2474 | |
2502 | | - if ( this.roe ) { |
2503 | | - params.roe = this.roe; |
2504 | | - } else if( this.apiTitleKey ) { |
| 2475 | + // TODO move to mediaWiki Support module |
| 2476 | + if( this.apiTitleKey ) { |
2505 | 2477 | params.apiTitleKey = this.apiTitleKey; |
2506 | 2478 | if ( this.apiProvider ) { |
2507 | 2479 | // Commons always uses the commons api provider ( special hack should refactor ) |
— | — | @@ -2591,10 +2563,8 @@ |
2592 | 2564 | embedCode += '" '; |
2593 | 2565 | } |
2594 | 2566 | |
2595 | | - |
2596 | | - if ( this.roe ) { |
2597 | | - embedCode += 'roe="' + mw.escapeQuotesHTML( this.roe ) + '" '; |
2598 | | - } else if( this.apiTitleKey ) { |
| 2567 | + // TODO move to mediaWiki Support module |
| 2568 | + if( this.apiTitleKey ) { |
2599 | 2569 | embedCode += 'apiTitleKey="' + mw.escapeQuotesHTML( this.apiTitleKey ) + '" '; |
2600 | 2570 | if ( this.apiProvider ) { |
2601 | 2571 | embedCode += 'apiProvider="' + mw.escapeQuotesHTML( this.apiProvider ) + '" '; |
— | — | @@ -2623,28 +2593,6 @@ |
2624 | 2594 | }, |
2625 | 2595 | |
2626 | 2596 | /** |
2627 | | - * Follows a linkback. Loads the ROE xml if no linkback is found |
2628 | | - */ |
2629 | | - doLinkBack: function() { |
2630 | | - if ( ! this.linkback && this.roe && this.mediaElement.addedROEData == false ) { |
2631 | | - var _this = this; |
2632 | | - this.displayMenuOverlay( gM( 'mwe-loading_txt' ) ); |
2633 | | - this.getMvJsonUrl( this.roe, function( data ) { |
2634 | | - _this.mediaElement.addROE( data ); |
2635 | | - _this.doLinkBack(); |
2636 | | - } ); |
2637 | | - } else { |
2638 | | - if ( this.linkback ) { |
2639 | | - window.location = this.linkback; |
2640 | | - } else if ( this.mediaElement.linkback ) { |
2641 | | - window.location = this.mediaElement.linkback; |
2642 | | - } else { |
2643 | | - this.displayMenuOverlay( gM( 'mwe-embedplayer-could_not_find_linkback' ) ); |
2644 | | - } |
2645 | | - } |
2646 | | - }, |
2647 | | - |
2648 | | - /** |
2649 | 2597 | * Base Embed Controls |
2650 | 2598 | */ |
2651 | 2599 | |
— | — | @@ -2812,8 +2760,10 @@ |
2813 | 2761 | if( this.useNativePlayerControls() ){ |
2814 | 2762 | this.getPlayerElement().currentTime = 0; |
2815 | 2763 | this.getPlayerElement().pause(); |
2816 | | - // add play button on top |
2817 | | - this.addPlayBtnLarge(); |
| 2764 | + // If on android when we "stop" we re add the large play button |
| 2765 | + if( mw.isAndroid2() ){ |
| 2766 | + this.addPlayBtnLarge(); |
| 2767 | + } |
2818 | 2768 | } else { |
2819 | 2769 | // Rewrite the html to thumbnail disp |
2820 | 2770 | this.showThumbnail(); |
— | — | @@ -3245,18 +3195,34 @@ |
3246 | 3196 | /** |
3247 | 3197 | * Get the current selected media source or first source |
3248 | 3198 | * |
| 3199 | + * @param {Number} Requested time in seconds to be passed to the server if the server supports |
| 3200 | + * supportsURLTimeEncoding |
3249 | 3201 | * @return src url |
3250 | 3202 | */ |
3251 | | - getSrc: function() { |
| 3203 | + getSrc: function( serverSeekTime ) { |
| 3204 | + if( serverSeekTime ){ |
| 3205 | + this.serverSeekTime = serverSeekTime; |
| 3206 | + } |
3252 | 3207 | if( this.currentTime && !this.serverSeekTime){ |
3253 | 3208 | this.serverSeekTime = this.currentTime; |
3254 | 3209 | } |
| 3210 | + |
| 3211 | + // No media element we can't return src |
| 3212 | + if( !this.mediaElement ){ |
| 3213 | + return false; |
| 3214 | + } |
| 3215 | + |
| 3216 | + // If no source selected auto select the source: |
| 3217 | + if( !this.mediaElement.selectedSource ){ |
| 3218 | + this.mediaElement.autoSelectSource(); |
| 3219 | + }; |
| 3220 | + |
| 3221 | + // Return selected source: |
3255 | 3222 | if( this.mediaElement.selectedSource ){ |
3256 | | - return this.mediaElement.selectedSource.getSrc( this.serverSeekTime ); |
3257 | | - } else if( this.mediaElement ){ |
3258 | 3223 | // get the first source: |
3259 | | - return this.mediaElement.getSources()[0].getSrc( this.serverSeekTime ); |
| 3224 | + return this.mediaElement.selectedSource.getSrc( this.serverSeekTime ); |
3260 | 3225 | } |
| 3226 | + // No selected source return false: |
3261 | 3227 | return false; |
3262 | 3228 | }, |
3263 | 3229 | |
— | — | @@ -3273,14 +3239,14 @@ |
3274 | 3240 | } else if( timeUrls == 'always' ){ |
3275 | 3241 | return this.mediaElement.selectedSource.URLTimeEncoding; |
3276 | 3242 | } else if( timeUrls == 'flash' ){ |
3277 | | - if( this.mediaElement.selectedSource.URLTimeEncoding){ |
3278 | | - // see if the current selected player is flash: |
3279 | | - return ( this.instanceOf == 'Kplayer' ); |
3280 | | - } |
| 3243 | + if( this.mediaElement.selectedSource.URLTimeEncoding){ |
| 3244 | + // see if the current selected player is flash: |
| 3245 | + return ( this.instanceOf == 'Kplayer' ); |
| 3246 | + } |
3281 | 3247 | } else { |
3282 | 3248 | mw.log("Error:: invalid config value for EmbedPlayer.EnableURLTimeEncoding:: " + mw.getConfig('EmbedPlayer.EnableURLTimeEncoding') ); |
3283 | 3249 | } |
3284 | | - return false; |
| 3250 | + return false; |
3285 | 3251 | } |
3286 | 3252 | } |
3287 | 3253 | |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiClient.js |
— | — | @@ -6,16 +6,17 @@ |
7 | 7 | |
8 | 8 | ( function( mw ) { |
9 | 9 | |
10 | | -mw.IFramePlayerApiClient = function( iframe, playerProxy, options ){ |
11 | | - return this.init( iframe , playerProxy, options); |
| 10 | +mw.IFramePlayerApiClient = function( iframe, playerProxy ){ |
| 11 | + return this.init( iframe , playerProxy ); |
12 | 12 | } |
13 | 13 | mw.IFramePlayerApiClient.prototype = { |
14 | 14 | 'exportedMethods': [ |
15 | 15 | 'play', |
16 | 16 | 'pause' |
17 | 17 | ], |
18 | | - // Local store of the post message ( not updated by user js ) |
| 18 | + // Local store of the previous sate of player proxy |
19 | 19 | '_prevPlayerProxy': {}, |
| 20 | + |
20 | 21 | // Stores the current playerProxy ( can be updated by user js ) |
21 | 22 | 'init': function( iframe , playerProxy, options ){ |
22 | 23 | this.iframe = iframe; |
— | — | @@ -27,12 +28,16 @@ |
28 | 29 | this.addPlayerReciveApi(); |
29 | 30 | }, |
30 | 31 | 'addPlayerSendApi': function(){ |
31 | | - var _this = this; |
| 32 | + var _this = this; |
| 33 | + |
| 34 | + // Allow modules to extend the list of iframeExported bindings |
| 35 | + $j( mw ).trigger( 'AddIframePlayerMethods', [ this.exportedMethods ]); |
| 36 | + |
32 | 37 | $j.each( this.exportedMethods, function(na, method){ |
33 | 38 | _this.playerProxy[ method ] = function(){ |
34 | 39 | _this.postMessage( { |
35 | 40 | 'method' : method, |
36 | | - 'args' : arguments |
| 41 | + 'args' : $j.makeArray( arguments ) |
37 | 42 | } ); |
38 | 43 | }; |
39 | 44 | }); |
— | — | @@ -47,8 +52,7 @@ |
48 | 53 | * Handle received events |
49 | 54 | */ |
50 | 55 | 'hanldeReciveMsg': function( event ){ |
51 | | - var _this = this; |
52 | | - //mw.log("IframePlayerApiClient:: hanldeReciveMsg "); |
| 56 | + var _this = this; |
53 | 57 | // Confirm the event is coming for the target host: |
54 | 58 | if( event.origin != this.iframeServer){ |
55 | 59 | mw.log("Skip msg from host does not match iFrame player: " + event.origin + |
— | — | @@ -57,7 +61,11 @@ |
58 | 62 | }; |
59 | 63 | // Decode the message |
60 | 64 | var msgObject = JSON.parse( event.data ); |
| 65 | + //mw.log("IframePlayerApiClient:: hanldeReciveMsg: " + msgObject.triggerName ); |
| 66 | + |
| 67 | + |
61 | 68 | var playerAttributes = mw.getConfig( 'EmbedPlayer.Attributes' ); |
| 69 | + |
62 | 70 | // Before we update local attributes check that the object has not been updated by user js |
63 | 71 | for( var attrName in playerAttributes ){ |
64 | 72 | if( attrName != 'id' ){ |
— | — | @@ -89,12 +97,11 @@ |
90 | 98 | //mw.log('IFramePlayerApiClient:: trigger: ' + msgObject.triggerName ); |
91 | 99 | $j( _this.playerProxy ).trigger( msgObject.triggerName, msgObject.triggerArgs ); |
92 | 100 | } |
93 | | - // @@TODO:: Allow extending modules to wrap these api events ( kaltura kdp javascript emulation ? ) |
94 | 101 | }, |
95 | | - 'postMessage': function( msgObj ){ |
| 102 | + 'postMessage': function( msgObject ){ |
96 | 103 | //mw.log( "IFramePlayerApiClient:: postMessage(): " + JSON.stringify( msgObj ) ); |
97 | 104 | $j.postMessage( |
98 | | - JSON.stringify( msgObj ), |
| 105 | + JSON.stringify( msgObject ), |
99 | 106 | mw.absoluteUrl( $j( this.iframe ).attr('src') ), |
100 | 107 | this.iframe.contentWindow |
101 | 108 | ); |
— | — | @@ -103,13 +110,15 @@ |
104 | 111 | |
105 | 112 | //Add the jQuery binding |
106 | 113 | ( function( $ ) { |
107 | | - $.fn.iFramePlayer = function( options ){ |
| 114 | + $.fn.iFramePlayer = function( readyCallback ){ |
108 | 115 | if( ! this.selector ){ |
109 | 116 | this.selector = $j( this ).get(0); |
110 | 117 | } |
111 | 118 | // Append '_ifp' ( iframe player ) to id of real iframe so that 'id', and 'src' attributes don't conflict |
112 | 119 | var originalIframeId = ( $( this.selector ).attr( 'id' ) )? $( this.selector ).attr( 'id' ) : Math.floor( 9999999 * Math.random() ); |
113 | | - var iframePlayerId = originalIframeId + '_ifp' ; // use random to generate a unique id |
| 120 | + |
| 121 | + var iframePlayerId = originalIframeId + '_ifp' ; |
| 122 | + |
114 | 123 | // Append the div element proxy after the iframe |
115 | 124 | $j( this.selector ) |
116 | 125 | .attr('id', iframePlayerId) |
— | — | @@ -117,19 +126,25 @@ |
118 | 127 | $('<div />') |
119 | 128 | .attr( 'id', originalIframeId ) |
120 | 129 | ); |
121 | | - var playerProxy = $j( '#' + originalIframeId ).get(0); |
| 130 | + |
| 131 | + var playerProxy = $j( '#' + originalIframeId ).get(0); |
122 | 132 | var iframe = $j('#' + iframePlayerId).get(0); |
123 | 133 | if(!iframe){ |
124 | 134 | mw.log("Error invalide iFramePlayer request"); |
125 | 135 | return false; |
126 | 136 | } |
127 | 137 | if( !iframe['playerApi'] ){ |
128 | | - iframe['playerApi'] = new mw.IFramePlayerApiClient( iframe, playerProxy, options ); |
| 138 | + iframe['playerApi'] = new mw.IFramePlayerApiClient( iframe, playerProxy ); |
129 | 139 | } |
130 | 140 | |
131 | 141 | // Allow modules to extend the 'iframe' based player |
132 | | - $j( mw ).trigger( 'newIframeEmbedPlayerEvent', playerProxy); |
| 142 | + $j( mw ).trigger( 'newIframePlayerClientSide', [ playerProxy ]); |
133 | 143 | |
| 144 | + // Bind the iFrame player ready callback |
| 145 | + if( readyCallback ){ |
| 146 | + $j( playerProxy ).bind( 'playerReady', readyCallback ) |
| 147 | + }; |
| 148 | + |
134 | 149 | // Return the player proxy for chaining player events / attributes |
135 | 150 | return $j( playerProxy ); |
136 | 151 | }; |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js |
— | — | @@ -1414,19 +1414,10 @@ |
1415 | 1415 | showDownload: function( $target ) { |
1416 | 1416 | var _this = this; |
1417 | 1417 | var embedPlayer = this.embedPlayer; |
1418 | | - |
1419 | | - // Load the roe if available (to populate out download options: |
1420 | | - // mw.log('f:showDownload '+ this.roe + ' ' + this.mediaElement.addedROEData); |
1421 | | - if ( embedPlayer.roe && embedPlayer.mediaElement.addedROEData == false ) { |
1422 | | - $target.html( gM( 'mwe-loading_txt' ) ); |
1423 | | - embedPlayer.getMvJsonUrl( this.roe, function( data ) { |
1424 | | - embedPlayer.mediaElement.addROE( data ); |
1425 | | - _this.showDownloadWithSources( $target ); |
1426 | | - } ); |
1427 | | - |
| 1418 | + |
1428 | 1419 | // Load additional text sources via apiTitleKey: |
1429 | 1420 | // TODO we should move this to timedText bindings |
1430 | | - } else if( embedPlayer.apiTitleKey ) { |
| 1421 | + if( embedPlayer.apiTitleKey ) { |
1431 | 1422 | // Load text interface ( if not already loaded ) |
1432 | 1423 | mw.load( 'TimedText', function() { |
1433 | 1424 | embedPlayer.timedText.setupTextSources(function(){ |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js |
— | — | @@ -99,7 +99,7 @@ |
100 | 100 | && typeof $j( '#' + this.pid ).get(0).play != 'undefined' ) { |
101 | 101 | |
102 | 102 | // Update the player source: |
103 | | - $j( '#' + this.pid ).attr('src', this.getSrc( this.currentTime ) ); |
| 103 | + $j( '#' + this.pid ).attr( 'src', this.getSrc( this.currentTime ) ); |
104 | 104 | $j( '#' + this.pid ).get(0).load(); |
105 | 105 | |
106 | 106 | _this.postEmbedJS(); |
— | — | @@ -359,11 +359,18 @@ |
360 | 360 | // Return the playerElement currentTime |
361 | 361 | return this.playerElement.currentTime; |
362 | 362 | }, |
363 | | - |
364 | 363 | |
| 364 | + // Update the poster src ( updates the native object if in dom ) |
| 365 | + updatePosterSrc: function( src ){ |
| 366 | + if( this.getPlayerElement() ){ |
| 367 | + this.getPlayerElement().poster = src; |
| 368 | + } |
| 369 | + // Also update the embedPlayer poster |
| 370 | + this.parent_updatePosterSrc( src ); |
| 371 | + }, |
| 372 | + |
365 | 373 | /** |
366 | | - * switchPlaySrc switches the player source working around a few bugs in |
367 | | - * browsers |
| 374 | + * switchPlaySrc switches the player source working around a few bugs in browsers |
368 | 375 | * |
369 | 376 | * @param {string} |
370 | 377 | * src Video url Source to switch to. |
— | — | @@ -388,8 +395,11 @@ |
389 | 396 | // Remove all native player bindings |
390 | 397 | $j(vid).unbind(); |
391 | 398 | vid.pause(); |
392 | | - // Local scope update source and play function to work around google chrome |
393 | | - // bug |
| 399 | + var orginalControlsState = vid.controls; |
| 400 | + // Hide controls ( to not display native play button while switching sources ) |
| 401 | + vid.removeAttribute('controls'); |
| 402 | + |
| 403 | + // Local scope update source and play function to work around google chrome bug |
394 | 404 | var updateSrcAndPlay = function() { |
395 | 405 | var vid = _this.getPlayerElement(); |
396 | 406 | if (!vid){ |
— | — | @@ -397,7 +407,7 @@ |
398 | 408 | return ; |
399 | 409 | } |
400 | 410 | vid.src = src; |
401 | | - // Give iOS 50ms to figure out the src got updated ( iPad OS 3.0 ) |
| 411 | + // Give iOS 50ms to figure out the src got updated ( iPad OS 4.0 ) |
402 | 412 | setTimeout(function() { |
403 | 413 | var vid = _this.getPlayerElement(); |
404 | 414 | if (!vid){ |
— | — | @@ -409,14 +419,16 @@ |
410 | 420 | // Wait another 100ms then bind the end event and any custom events |
411 | 421 | // for the switchCallback |
412 | 422 | setTimeout(function() { |
413 | | - var vid = _this.getPlayerElement(); |
| 423 | + var vid = _this.getPlayerElement(); |
| 424 | + // restore controls |
| 425 | + vid.controls = orginalControlsState; |
414 | 426 | // add the end binding: |
415 | 427 | $j(vid).bind('ended', function( event ) { |
416 | 428 | if(typeof doneCallback == 'function' ){ |
417 | 429 | doneCallback(); |
418 | 430 | } |
419 | 431 | return false; |
420 | | - }) |
| 432 | + }); |
421 | 433 | if (typeof switchCallback == 'function') { |
422 | 434 | switchCallback(vid); |
423 | 435 | } |
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiServer.js |
— | — | @@ -19,7 +19,13 @@ |
20 | 20 | |
21 | 21 | // Bind apiServer to newEmbedPlayers: |
22 | 22 | $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayer ) { |
23 | | - embedPlayer['iFrameServer'] = new mw.IFramePlayerApiServer( embedPlayer ); |
| 23 | + // Check if the iFrame player api is enabled and we have a parent iframe url: |
| 24 | + if ( mw.getConfig('EmbedPlayer.EnableIframeApi') |
| 25 | + && |
| 26 | + mw.getConfig( 'EmbedPlayer.IframeParentUrl' ) |
| 27 | + ){ |
| 28 | + embedPlayer['iFrameServer'] = new mw.IFramePlayerApiServer( embedPlayer ); |
| 29 | + } |
24 | 30 | }); |
25 | 31 | |
26 | 32 | mw.IFramePlayerApiServer = function( embedPlayer ){ |
— | — | @@ -27,8 +33,11 @@ |
28 | 34 | } |
29 | 35 | |
30 | 36 | mw.IFramePlayerApiServer.prototype = { |
31 | | - // Exported methods populated by native video/audio tag api. |
32 | | - 'exportedBindings': [], |
| 37 | + // Exported bindings / events. ( all the native html5 events are added in 'init' ) |
| 38 | + 'exportedBindings': [ |
| 39 | + 'playerReady', |
| 40 | + 'monitorEvent' |
| 41 | + ], |
33 | 42 | |
34 | 43 | 'init': function( embedPlayer ){ |
35 | 44 | this.embedPlayer = embedPlayer; |
— | — | @@ -41,13 +50,13 @@ |
42 | 51 | this.exportedBindings.push( bindName ); |
43 | 52 | } |
44 | 53 | } |
45 | | - this.exportedBindings.push( 'monitorEvent' ); |
46 | 54 | |
47 | 55 | // Allow modules to extend the list of iframeExported bindings |
48 | | - $j( mw ).trigger( 'AddIframeExportedBindings', [ this.exportedBindings ]); |
| 56 | + $j( mw ).trigger( 'AddIframePlayerBindings', [ this.exportedBindings ]); |
49 | 57 | |
50 | 58 | this._addIframeListener(); |
51 | 59 | this._addIframeSender(); |
| 60 | + $j( mw ).trigger( 'newIframePlayerServerSide', [embedPlayer]); |
52 | 61 | }, |
53 | 62 | |
54 | 63 | /** |
— | — | @@ -73,22 +82,25 @@ |
74 | 83 | mw.log("Error: iFramePlayerApiServer:: could not parse parent url. \n" + |
75 | 84 | "Player events will be dissabled"); |
76 | 85 | } |
| 86 | + // Set the initial attributes once player is "ready" |
| 87 | + $j( this.embedPlayer ).bind( 'playerReady', function(){ |
| 88 | + _this.sendPlayerAttributes(); |
| 89 | + }); |
77 | 90 | // On monitor event package the attributes for cross domain delivery: |
78 | 91 | $j( this.embedPlayer ).bind( 'monitorEvent', function(){ |
79 | 92 | _this.sendPlayerAttributes(); |
80 | 93 | }) |
81 | | - // Set the initial attributes once player is "ready" |
82 | | - $j( this.embedPlayer ).bind( 'playerReady', function(){ |
83 | | - _this.sendPlayerAttributes(); |
84 | | - }); |
85 | 94 | |
86 | 95 | $j.each( this.exportedBindings, function( inx, bindName ){ |
87 | 96 | $j( _this.embedPlayer ).bind( bindName, function( event ){ |
88 | 97 | var argSet = $j.makeArray( arguments ); |
89 | 98 | // remove the event from the arg set |
90 | 99 | argSet.shift(); |
91 | | - |
92 | | - //mw.log("IFramePlayerApiServer::postMessage: bindName: " + bindName + ' arg:' + argSet ); |
| 100 | + // protect against a jQuery event getting past as an arguments: |
| 101 | + if( argSet[0] && argSet[0].originalEvent ){ |
| 102 | + argSet.shift(); |
| 103 | + } |
| 104 | + //mw.log("IFramePlayerApiServer::postMessage:: " + bindName + ' arg count:' + argSet.length ); |
93 | 105 | _this.postMessage({ |
94 | 106 | 'triggerName' : bindName, |
95 | 107 | 'triggerArgs' : argSet |
Index: branches/MwEmbedStandAlone/remotes/AddMediaWizardEditPage.js |
— | — | @@ -75,7 +75,6 @@ |
76 | 76 | } else { |
77 | 77 | // Make sure the wikieditor got binded: |
78 | 78 | if ( !didWikiEditorBind ) { |
79 | | - mw.log( 'Failed to bind via build section bind via target:' ); |
80 | 79 | var $targetFileButton = $j( ".toolbar [rel='file']" ); |
81 | 80 | |
82 | 81 | $targetFileButton |