r80174 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80173‎ | r80174 | r80175 >
Date:17:05, 13 January 2011
Author:dale
Status:deferred
Tags:
Comment:
* sync with kaltura updates
* adds improved support for extending iframe proxy
* some binding name cleanup
Modified paths:
  • /branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiClient.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiServer.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/MiroSubs/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilHooks.js (modified) (history)
  • /branches/MwEmbedStandAlone/modules/TimedText/loader.js (modified) (history)
  • /branches/MwEmbedStandAlone/mwEmbed.js (modified) (history)
  • /branches/MwEmbedStandAlone/remotes/AddMediaWizardEditPage.js (modified) (history)

Diff [purge]

Index: branches/MwEmbedStandAlone/mwEmbed.js
@@ -3,15 +3,13 @@
44 'video audio source track'.replace(/\w+/g, function(n){ document.createElement(n); });
55
66 /**
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+ *
119 * @copyright (C) 2010 Kaltura
1210 * @author Michael Dale ( michael.dale at kaltura.com )
13 - *
 11+ *
1412 * @url http://www.kaltura.org/project/HTML5_Video_Media_JavaScript_Library
15 - *
 13+ *
1614 * Libraries used include code license in headers
1715 */
1816
@@ -68,7 +66,7 @@
6967
7068 /**
7169 * Setter for configuration values
72 - *
 70+ *
7371 * @param [Mixed]
7472 * name Name of configuration value {Object} Will iderate through
7573 * each key and call setConfig {String} Will set configuration by
@@ -122,7 +120,7 @@
123121 /**
124122 * Set a default config value Will only update configuration if no value is
125123 * present
126 - *
 124+ *
127125 * @param [Mixed]
128126 * value Set configuration name to value {Object} Will idorate
129127 * through each key and call setDefaultConfig {String} Will set
@@ -143,7 +141,7 @@
144142
145143 /**
146144 * Getter for configuration values
147 - *
 145+ *
148146 * @param {String}
149147 * name of configuration value to get
150148 * @return {Mixed} value of configuration key returns "false" if key not
@@ -155,8 +153,8 @@
156154 return false;
157155 };
158156 /**
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 )
161159 */
162160 mw.getNonDefaultConfigObject = function(){
163161 var nonDefaultConfig = {};
@@ -169,16 +167,16 @@
170168
171169 /**
172170 * Loads the mwUserConfig from a cookie.
173 - *
 171+ *
174172 * Modules that want to use "User Config" should call this setup function in
175173 * their moduleLoader code.
176 - *
 174+ *
177175 * For performance interfaces using "user config" should load '$j.cookie' &
178176 * 'JSON' in their module loader
179 - *
 177+ *
180178 * By abstracting user preference we could eventually integrate a persistent
181179 * per-account preference system on the server.
182 - *
 180+ *
183181 * @parma {Function} callback Function to be called once userPrefrences are
184182 * loaded
185183 */
@@ -205,7 +203,7 @@
206204 /**
207205 * Save a user configuration var to a cookie & local global variable Loads
208206 * the cookie plugin if not already loaded
209 - *
 207+ *
210208 * @param {String}
211209 * name Name of user configuration value
212210 * @param {String}
@@ -225,7 +223,7 @@
226224
227225 /**
228226 * Save a user configuration var to a cookie & local global variable
229 - *
 227+ *
230228 * @param {String}
231229 * name Name of user configuration value
232230 * @return value of the configuration name false if the configuration name
@@ -239,9 +237,9 @@
240238
241239 /**
242240 * Add a hook system for a target object / interface
243 - *
 241+ *
244242 * depricated you should instead use jQuery's bind and trigger
245 - *
 243+ *
246244 * @param {Object}
247245 * targetObj Interface Object to add hook system to.
248246 */
@@ -252,9 +250,9 @@
253251
254252 /**
255253 * Adds a hook to the target object
256 - *
 254+ *
257255 * Should be called by clients to setup named hooks
258 - *
 256+ *
259257 * @param {String}
260258 * hookName Name of hook to be added
261259 * @param {Function}
@@ -269,9 +267,9 @@
270268
271269 /**
272270 * Runs all the hooks by a given name with reference to the host object
273 - *
 271+ *
274272 * Should be called by the host object at named execution points
275 - *
 273+ *
276274 * @param {String}
277275 * hookName Name of hook to be called
278276 * @return Value of hook result true interface should continue function
@@ -301,7 +299,7 @@
302300 mw.loader = {
303301 /**
304302 * Javascript Module Loader functions
305 - *
 303+ *
306304 * @key Name of Module
307305 * @value function code to load module
308306 */
@@ -309,7 +307,7 @@
310308
311309 /**
312310 * Module resource list queue.
313 - *
 311+ *
314312 * @key Name of Module
315313 * @value .resourceList list of resources to be loaded .functionQueue
316314 * list of functions to be run once module is ready
@@ -318,21 +316,21 @@
319317
320318 /**
321319 * Javascript Class Paths
322 - *
 320+ *
323321 * @key Name of resource
324322 * @value Class file path
325323 */
326324 resourcePaths : { },
327325
328326 /**
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 )
331329 */
332330 requestedResourceQueue: { },
333331
334332 /**
335333 * javascript Resource Paths
336 - *
 334+ *
337335 * @key Name of resource
338336 * @value Name of depenent style sheet
339337 */
@@ -340,34 +338,34 @@
341339
342340 /**
343341 * Core load function:
344 - *
 342+ *
345343 * @param {Mixed}
346344 * loadRequest:
347 - *
 345+ *
348346 * {String} Name of a module to be loaded Modules are added via
349347 * addModuleLoader and can define custom code needed to check config and
350348 * return a list of resources to be loaded
351 - *
 349+ *
352350 * {String} Name of a resource to loaded. Resources are added via
353351 * addResourcePaths function Using defined resource names avoids loading
354352 * the same resource twice by first checking if the named resource is
355353 * defined in the global javascript scope variable
356 - *
 354+ *
357355 * {String} Absolute or relative to url path The same file won't be
358356 * loaded twice
359 - *
 357+ *
360358 * {Array} can be an array of any combination of the above strings. Will
361359 * be loaded in-order or in a single resource loader request if
362360 * scriptLoader is available.
363 - *
 361+ *
364362 * {Array} {Array} Can be a set of Arrays for loading. Some browsers
365363 * execute included scripts out of order. This lets you chain sets of
366364 * request for those browsers. If using the server side resource loader
367365 * order is preserved in output and a single request will be used.
368 - *
 366+ *
369367 * @param {Function}
370368 * callback Function called once loading is complete
371 - *
 369+ *
372370 */
373371 load: function( loadRequest, instanceCallback ) {
374372 // mw.log("mw.load:: " + loadRequest );
@@ -418,17 +416,17 @@
419417
420418 // xxx should use refactor "ready" stuff into a "domReady" class
421419 // So we would not have local scope globals like this:
422 - //if ( mwReadyFlag ) {
 420+ // if ( mwReadyFlag ) {
423421 // Load the module directly if load request is after
424422 // mw.ready has run
425423 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+ // }
433431 return ;
434432 }
435433
@@ -504,7 +502,7 @@
505503 /**
506504 * Load a set of scripts. Will issue many load requests or package the
507505 * request for the resource loader
508 - *
 506+ *
509507 * @param {Object}
510508 * loadSet Set of scripts to be loaded
511509 * @param {Function}
@@ -543,12 +541,12 @@
544542 }
545543
546544 // We are infact loading many:
547 - //mw.log("mw.load: LoadMany:: " + loadSet );
 545+ // mw.log("mw.load: LoadMany:: " + loadSet );
548546
549547 // Issue the load request check check loadStates to see if we are
550548 // "done"
551549 for( var loadName in loadStates ) {
552 - //mw.log("loadMany: load: " + loadName );
 550+ // mw.log("loadMany: load: " + loadName );
553551 this.load( loadName, function ( loadName ) {
554552 loadStates[ loadName ] = 1;
555553
@@ -573,11 +571,11 @@
574572
575573 /**
576574 * Get grouped load state for script loader
577 - *
 575+ *
578576 * Groups the scriptRequest where possible: Modules include "loader
579577 * code" so they are separated into pre-condition code to be run for
580578 * subsequent requests
581 - *
 579+ *
582580 * @param {Object}
583581 * loadSet Loadset to return grouped
584582 * @return {Object} grouped loadSet
@@ -605,7 +603,8 @@
606604 for( var i=0; i < groupedLoadSet.length; i++ ) {
607605 var loadName = groupedLoadSet[ i ];
608606 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
610609 if( !mw.isset( loadName ) && ! uniqueResourceName[ loadName] ){
611610 groupClassKey += coma + loadName;
612611 coma = ',';
@@ -645,7 +644,7 @@
646645 /**
647646 * Load a sets of scripts satisfy dependency order for browsers that
648647 * execute dynamically included scripts out of order
649 - *
 648+ *
650649 * @param {Object}
651650 * loadChain A set of javascript arrays to be loaded. Sets
652651 * are requested in array order.
@@ -815,7 +814,7 @@
816815
817816 /**
818817 * Loads javascript or css associated with a resourceName
819 - *
 818+ *
820819 * @param {String}
821820 * resourceName Name of resource to load
822821 * @param {Function}
@@ -884,7 +883,8 @@
885884 // Send warning if resourceName is not defined
886885 if(! mw.isset( resourceName )
887886 && 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"
889889 // + _this.getResourcePath( resourceName ) );
890890 }
891891
@@ -920,7 +920,7 @@
921921
922922 /**
923923 * Adds a module to the mwLoader object
924 - *
 924+ *
925925 * @param {String}
926926 * name Name of module
927927 * @param {Function}
@@ -932,11 +932,11 @@
933933
934934 /**
935935 * Adds resource file path key value pairs
936 - *
 936+ *
937937 * @param {Object}
938938 * resourceSet JSON formated list of resource name file path
939939 * pairs.
940 - *
 940+ *
941941 * resourceSet must be strict JSON to allow the php scriptLoader to
942942 * parse the file paths.
943943 */
@@ -951,7 +951,7 @@
952952
953953 /*
954954 * Adds a named style sheet dependency to a named resource
955 - *
 955+ *
956956 * @parma {Object} resourceSet JSON formated list of resource names and
957957 * associated style sheet names
958958 */
@@ -974,7 +974,7 @@
975975
976976 /**
977977 * Load done callback for script loader
978 - *
 978+ *
979979 * @param {String}
980980 * requestName Name of the load request
981981 */
@@ -1004,7 +1004,7 @@
10051005
10061006 /**
10071007 * Set a load done callback
1008 - *
 1008+ *
10091009 * @param {String}
10101010 * requestName Name of resource or request set
10111011 * @param {Function}
@@ -1025,7 +1025,7 @@
10261026 /**
10271027 * Shortcut entry points / convenience functions: Lets you write mw.load()
10281028 * instead of mw.loader.load() only these entry points should be used.
1029 - *
 1029+ *
10301030 * future closure optimizations could minify internal function names
10311031 */
10321032
@@ -1068,7 +1068,7 @@
10691069
10701070 /**
10711071 * addLoaderDialog small helper for displaying a loading dialog
1072 - *
 1072+ *
10731073 * @param {String}
10741074 * dialogHtml text Html of the loader msg
10751075 */
@@ -1104,13 +1104,12 @@
11051105
11061106 /**
11071107 * 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
11151114 */
11161115 mw.addDialog = function ( options ) {
11171116 // Remove any other dialog
@@ -1182,7 +1181,7 @@
11831182 mw.isIphone = function(){
11841183 return ( navigator.userAgent.indexOf('iPhone') != -1 && ! mw.isIpad() );
11851184 };
1186 - // Uses hack described at:
 1185+ // Uses hack described at:
11871186 // http://www.bdoran.co.uk/2010/07/19/detecting-the-iphone4-and-resolution-with-javascript-or-php/
11881187 mw.isIphone4 = function(){
11891188 return ( mw.isIphone() && ( window.devicePixelRatio && window.devicePixelRatio >= 2 ) );
@@ -1193,17 +1192,18 @@
11941193 mw.isIpad = function(){
11951194 return ( navigator.userAgent.indexOf('iPad') != -1 );
11961195 };
1197 - // Android 2 has some restrictions vs other mobile platforms
 1196+ // Android 2 has some restrictions vs other mobile platforms
11981197 mw.isAndroid2 = function(){
11991198 return ( navigator.userAgent.indexOf( 'Android 2.') != -1 );
12001199 };
12011200
12021201 /**
12031202 * 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+ *
12081208 */
12091209 mw.isHTML5FallForwardNative = function(){
12101210 if( mw.isMobileHTML5() ){
@@ -1213,12 +1213,13 @@
12141214 if( document.URL.indexOf('forceMobileHTML5') != -1 ){
12151215 return true;
12161216 }
1217 - // Fall forward native:
 1217+ // Fall forward native:
12181218 // if the browser supports flash ( don't use html5 )
12191219 if( mw.supportsFlash() ){
12201220 return false;
12211221 }
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:
12231224 if( mw.supportsHTML5() ){
12241225 return true;
12251226 }
@@ -1227,7 +1228,7 @@
12281229 }
12291230
12301231 mw.isMobileHTML5 = function(){
1231 - // Check for a mobile html5 user agent:
 1232+ // Check for a mobile html5 user agent:
12321233 if ( mw.isIphone() ||
12331234 mw.isIpod() ||
12341235 mw.isIpad() ||
@@ -1238,7 +1239,7 @@
12391240 return false;
12401241 }
12411242 mw.supportsHTML5 = function(){
1242 - // Blackberry is evil in its response to canPlayType calls.
 1243+ // Blackberry is evil in its response to canPlayType calls.
12431244 if( navigator.userAgent.indexOf('BlackBerry') != -1 ){
12441245 return false ;
12451246 }
@@ -1259,13 +1260,13 @@
12601261 type = type.substr( 0, semicolonPos );
12611262 }
12621263 if (type == 'application/x-shockwave-flash' ) {
1263 - // flash is installed
 1264+ // flash is installed
12641265 return true;
12651266 }
12661267 }
12671268 }
12681269
1269 - // for IE:
 1270+ // for IE:
12701271 var hasObj = true;
12711272 if( typeof ActiveXObject != 'undefined' ){
12721273 try {
@@ -1282,7 +1283,7 @@
12831284 /**
12841285 * Similar to php isset function checks if the variable exists. Does a safe
12851286 * check of a descendant method or variable
1286 - *
 1287+ *
12871288 * @param {String}
12881289 * objectPath
12891290 * @return {Boolean} true if objectPath exists false if objectPath is
@@ -1307,7 +1308,7 @@
13081309
13091310 /**
13101311 * Wait for a object to be defined and the call the callback
1311 - *
 1312+ *
13121313 * @param {Object}
13131314 * objectName Name of object to be defined
13141315 * @param {Function}
@@ -1345,7 +1346,7 @@
13461347
13471348 /**
13481349 * Check if an object is empty or if its an empty string.
1349 - *
 1350+ *
13501351 * @param {Object}
13511352 * object Object to be checked
13521353 */
@@ -1371,10 +1372,10 @@
13721373
13731374 /**
13741375 * Log a string msg to the console
1375 - *
 1376+ *
13761377 * all mw.log statements will be removed on minification so lots of mw.log
13771378 * calls will not impact performance in non debug mode
1378 - *
 1379+ *
13791380 * @param {String}
13801381 * string String to output to console
13811382 */
@@ -1383,8 +1384,9 @@
13841385 if ( mw.getConfig( 'Mw.LogPrepend' ) ){
13851386 string = mw.getConfig( 'Mw.LogPrepend' ) + string;
13861387 }
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;
13891391
13901392 if ( window.console ) {
13911393 window.console.log( string );
@@ -1393,19 +1395,15 @@
13941396 * Old IE and non-Firebug debug: ( commented out for now )
13951397 */
13961398
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+ */
14101408 }
14111409 };
14121410 mw.getCallStack = function(){
@@ -1461,11 +1459,11 @@
14621460 * Enables load hooks to run once mwEmbeed is "ready" Will ensure jQuery is
14631461 * available, is in the $j namespace and mw interfaces and configuration has
14641462 * been loaded and applied
1465 - *
 1463+ *
14661464 * This is different from jQuery(document).ready() ( jQuery ready is not
14671465 * friendly with dynamic includes and not friendly with core interface
14681466 * asynchronous build out. )
1469 - *
 1467+ *
14701468 * @param {Function}
14711469 * callback Function to run once DOM and jQuery are ready
14721470 */
@@ -1505,8 +1503,8 @@
15061504
15071505 /**
15081506 * Wrapper for jQuery getScript, Uses the scriptLoader if enabled
1509 - *
1510 - *
 1507+ *
 1508+ *
15111509 * @param {String}
15121510 * scriptRequest The requested path or resourceNames for the
15131511 * scriptLoader
@@ -1563,8 +1561,8 @@
15641562 }
15651563
15661564 /**
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
15691567 */
15701568
15711569 // load style sheet directly if requested loading css
@@ -1592,7 +1590,7 @@
15931591
15941592 /**
15951593 * Add a style sheet string to the document head
1596 - *
 1594+ *
15971595 * @param {String}
15981596 * cssResourceName Name of style sheet that has been defined
15991597 * @param {String}
@@ -1623,7 +1621,7 @@
16241622
16251623 /**
16261624 * Get a style sheet and append the style sheet to the DOM
1627 - *
 1625+ *
16281626 * @param {Mixed}
16291627 * {String} url Url of the style sheet to be loaded {Function}
16301628 * callback Function called once sheet is ready
@@ -1722,7 +1720,7 @@
17231721
17241722 /**
17251723 * Get Script loader path
1726 - *
 1724+ *
17271725 * @returns {String}|{Boolean} Url of the scriptLodaer false if the
17281726 * scriptLoader is not used
17291727 */
@@ -1739,7 +1737,7 @@
17401738 /**
17411739 * Given a float number of seconds, returns npt format response. ( ignore
17421740 * days for now )
1743 - *
 1741+ *
17441742 * @param {Float}
17451743 * sec Seconds
17461744 * @param {Boolean}
@@ -1781,7 +1779,7 @@
17821780 };
17831781 /**
17841782 * Given seconds return array with 'days', 'hours', 'min', 'seconds'
1785 - *
 1783+ *
17861784 * @param {float}
17871785 * sec Seconds to be converted into time measurements
17881786 */
@@ -1797,7 +1795,7 @@
17981796 /**
17991797 * Given a float number of seconds, returns npt format response. ( ignore
18001798 * days for now )
1801 - *
 1799+ *
18021800 * @param {Float}
18031801 * sec Seconds
18041802 * @param {Boolean}
@@ -1914,7 +1912,7 @@
19151913
19161914 /**
19171915 * Replace url parameters via newParams key value pairs
1918 - *
 1916+ *
19191917 * @param {String}
19201918 * url Source url to be updated
19211919 * @param {Object}
@@ -1966,7 +1964,7 @@
19671965
19681966 /**
19691967 * Parse URI function
1970 - *
 1968+ *
19711969 * For documentation on its usage see:
19721970 * http://stevenlevithan.com/demo/parseuri/js/
19731971 */
@@ -1987,10 +1985,12 @@
19881986 /**
19891987 * getAbsoluteUrl takes a src and returns the absolute location given the
19901988 * 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
19951995 * @return {String} absolute url
19961996 */
19971997 mw.absoluteUrl = function( src, contextUrl ) {
@@ -2025,10 +2025,8 @@
20262026 };
20272027 /**
20282028 * 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
20332031 */
20342032 mw.isUrl = function( src ){
20352033 var parsedSrc = mw.parseUri( src );
@@ -2038,7 +2036,7 @@
20392037
20402038 /**
20412039 * Escape quotes in a text string
2042 - *
 2040+ *
20432041 * @param {String}
20442042 * text String to be escaped
20452043 * @return {string} escaped text string
@@ -2053,7 +2051,7 @@
20542052
20552053 /**
20562054 * Escape an HTML text string
2057 - *
 2055+ *
20582056 * @param {String}
20592057 * text String to be escaped
20602058 * @return {string} escaped text html string
@@ -2079,7 +2077,7 @@
20802078 * Add a function to be run during setup ( prior to mw.ready) this is useful
20812079 * for building out interfaces that should be ready before mw.ready is
20822080 * called.
2083 - *
 2081+ *
20842082 * @param {callback}
20852083 * Function Callback function must accept a ready function
20862084 * callback to be called once setup is done
@@ -2136,7 +2134,8 @@
21372135 // Update the image path
21382136 mw.setConfig( 'imagesPath', mw.getMwEmbedPath() + 'skins/common/images/' );
21392137
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
21412140 $j.ajaxSetup( {
21422141 cache: true
21432142 } );
@@ -2145,7 +2144,8 @@
21462145 mw.Language.magicSetup();
21472146
21482147
2149 - // Special Hack for conditional jquery ui inclusion ( once
 2148+ // Special Hack for conditional jquery ui inclusion (
 2149+ // once
21502150 // Usability extension
21512151 // registers the jquery.ui skin in mw.style
21522152 if( mw.hasJQueryUiCss() ){
@@ -2160,7 +2160,8 @@
21612161 // calls
21622162 // and must include a callback.
21632163 //
2164 - // Once complete we can run .ready() queued functions
 2164+ // Once complete we can run .ready() queued
 2165+ // functions
21652166 function runSetupFunctions() {
21662167 if( mwSetupFunctions.length ) {
21672168 mwSetupFunctions.shift()( function() {
@@ -2183,7 +2184,7 @@
21842185 * Checks for jquery ui css by name jquery-ui-1.7.2.css NOTE: this is a hack
21852186 * for usability jquery-ui in the future usability should register a
21862187 * resource in mw.skin
2187 - *
 2188+ *
21882189 * @return true if found, return false if not found
21892190 */
21902191 mw.hasJQueryUiCss = function(){
@@ -2216,10 +2217,10 @@
22172218
22182219 /**
22192220 * Loads the core mwEmbed "loader.js" file config
2220 - *
 2221+ *
22212222 * NOTE: if using the ScriptLoader all the loaders and localization
22222223 * converters are included automatically
2223 - *
 2224+ *
22242225 * @param {Function}
22252226 * callback Function called once core loader file is loaded
22262227 */
@@ -2245,7 +2246,7 @@
22462247
22472248 /**
22482249 * Checks if the javascript is a static package ( not using resource loader )
2249 - *
 2250+ *
22502251 * @return {boolean} true the included script is static false the included
22512252 * script
22522253 */
@@ -2259,7 +2260,7 @@
22602261
22612262 /**
22622263 * Check for resource loader module loaders, and localization files
2263 - *
 2264+ *
22642265 * NOTE: if using the ScriptLoader all the loaders and localization
22652266 * converters are included automatically.
22662267 */
@@ -2362,12 +2363,12 @@
23632364
23642365 /**
23652366 * Checks if a css style rule exists
2366 - *
 2367+ *
23672368 * On a page with lots of rules it can take some time so avoid calling this
23682369 * function where possible and cache its result
2369 - *
 2370+ *
23702371 * NOTE: this only works for style sheets on the same domain :(
2371 - *
 2372+ *
23722373 * @param {String}
23732374 * styleRule Style rule name to check
23742375 * @return {Boolean} true if the rule exists false if the rule does not
@@ -2426,14 +2427,14 @@
24272428 /**
24282429 * A version comparison utility function Handles version of types
24292430 * {Major}.{MinorN}.{Patch}
2430 - *
 2431+ *
24312432 * Note this just handles version numbers not patch letters.
2432 - *
 2433+ *
24332434 * @param {String}
24342435 * minVersion Minnium version needed
24352436 * @param {String}
24362437 * clientVersion Client version to be checked
2437 - *
 2438+ *
24382439 * @return true if the version is at least of minVersion false if the
24392440 * version is less than minVersion
24402441 */
@@ -2460,23 +2461,26 @@
24612462 ( function( $ ) {
24622463
24632464 /**
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
24652467 *
24662468 * 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+ *
24742476 * @param {string}
24752477 * triggerName Name of trigger to be run
24762478 * @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
24782481 * @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+ *
24812485 */
24822486 $.fn.triggerQueueCallback = function( triggerName, triggerParam, callback ){
24832487 var targetObject = this;
@@ -2485,10 +2489,10 @@
24862490 callback = triggerParam;
24872491 triggerParam = null;
24882492 }
2489 - // Support namespaced event segmentation ( jQuery
 2493+ // Support namespaced event segmentation ( jQuery
24902494 var triggerBaseName = triggerName.split(".")[0];
24912495 var triggerNamespace = triggerName.split(".")[1];
2492 - // Get the callback set
 2496+ // Get the callback set
24932497 var callbackSet = [];
24942498 if( ! triggerNamespace ){
24952499 callbackSet = $j( targetObject ).data( 'events' )[ triggerBaseName ];
@@ -2509,10 +2513,12 @@
25102514
25112515 // Set the callbackCount
25122516 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 );
25142519 var callInx = 0;
25152520 var doCallbackCheck = function() {
2516 - mw.log( 'callback for: ' + mw.getCallStack()[0] + callInx);
 2521+ // mw.log( 'callback for: ' + mw.getCallStack()[0] +
 2522+ // callInx);
25172523 callInx++;
25182524 if( callInx == callbackCount ){
25192525 callback();
@@ -2537,6 +2543,7 @@
25382544 }
25392545 return this;
25402546 };
 2547+
25412548 /**
25422549 * Add an absolute overlay spinner useful for cases where the
25432550 * element does not display child elements, ( images, video )
@@ -2655,7 +2662,7 @@
26562663
26572664 /**
26582665 * Resize a dialog to fit the window
2659 - *
 2666+ *
26602667 * @param {Object}
26612668 * options horizontal and vertical space ( default 50 )
26622669 */
@@ -2752,13 +2759,7 @@
27532760 }
27542761 mw.domReady();
27552762 }
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 -}
27612763
2762 -
27632764 // If using the resource loader and jQuery has not been set give a warning to
27642765 // the user:
27652766 // (this is needed because packaged loader.js files could refrence jQuery )
@@ -2773,10 +2774,10 @@
27742775 /**
27752776 * Hack to keep jQuery in $ when its already there, but also use noConflict to
27762777 * get $j = jQuery
2777 - *
 2778+ *
27782779 * This way sites that use $ for jQuery continue to work after including mwEmbed
27792780 * javascript.
2780 - *
 2781+ *
27812782 * Also if jQuery is included prior to mwEmbed we ensure $j is set
27822783 */
27832784
Index: branches/MwEmbedStandAlone/modules/Playlist/mw.Playlist.js
@@ -52,9 +52,9 @@
5353
5454
5555 // 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;
5959 }
6060 });
6161
Index: branches/MwEmbedStandAlone/modules/SmilPlayer/mw.SmilHooks.js
@@ -23,10 +23,9 @@
2424 } );
2525
2626 // 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;
3130 }
3231 });
3332
Index: branches/MwEmbedStandAlone/modules/MiroSubs/loader.js
@@ -4,20 +4,20 @@
55
66 // Wrap in mw to not pollute global namespace
77 ( function( mw ) {
8 - mw.addMessages( {
 8+ mw.addMessages({
99 "mwe-mirosubs-add-universal-subtitles" : "Universal subtitles editor",
1010 "mwe-mirosubs-loading-universal-subtitles" : "Loading <i>universal subtitles</i> editor"
1111 });
1212
1313 // Add as loader dependency 'mw.style.mirosubsMenu'
14 - mw.addResourcePaths( {
 14+ mw.addResourcePaths({
1515 "mirosubs" : "mirosubs/mirosubs-api.min.js",
1616 "mw.MiroSubsConfig" : "mw.MiroSubsConfig.js",
1717 "mw.style.mirosubsMenu" : "css/mw.style.mirosubsMenu.css",
1818 "mw.style.mirosubswidget" : "mirosubs/media/css/mirosubs-widget.css"
1919 });
2020
21 - mw.setDefaultConfig( {
 21+ mw.setDefaultConfig({
2222 'MiroSubs.EnableUniversalSubsEditor': true
2323 });
2424
Index: branches/MwEmbedStandAlone/modules/TimedText/loader.js
@@ -84,8 +84,7 @@
8585 }
8686 // Check for timed text sources or api/ roe url
8787 if (
88 - ( $j( embedPlayer ).attr( embedPlayer.roe )
89 - ||
 88+ (
9089 $j( embedPlayer ).attr('apititlekey')
9190 ||
9291 $j( embedPlayer ).attr('apiTitleKey' )
Index: branches/MwEmbedStandAlone/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -2302,7 +2302,7 @@
23032303 );
23042304 mw.log( 'append html: ' + embedHtml );
23052305 $j( '#clip_edit_disp' ).html( embedHtml );
2306 -
 2306+ var cat = $j.fn.embedPlayer;
23072307 // Make sure we have the 'EmbedPlayer' module:
23082308 mw.load( 'EmbedPlayer', function() {
23092309 // Strange concurrency issue with callbacks
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/loader.js
@@ -93,7 +93,7 @@
9494 'EmbedPLayer.IFramePlayer.DomainWhiteList' : '*',
9595
9696 // If the iframe should send and receive javascript events across domains via postMessage
97 - 'EmbedPlayer.EnableIframeApi' : false
 97+ 'EmbedPlayer.EnableIframeApi' : true
9898 } );
9999
100100 /**
@@ -137,10 +137,10 @@
138138 'titleKey'
139139 ] );
140140
141 - /*
142 - * The default video attributes supported by embedPlayer
 141+ /**
 142+ * Merge in the default video attributes supported by embedPlayer:
143143 */
144 - mw.setDefaultConfig('EmbedPlayer.Attributes', {
 144+ mw.mergeConfig('EmbedPlayer.Attributes', {
145145 /*
146146 * Base html element attributes:
147147 */
@@ -299,12 +299,7 @@
300300 if( $j( rewriteTags ).length != 0 ) {
301301 return true;
302302 }
303 -
304 - var tagCheckObject = { 'hasTags' : false };
305 - $j( mw ).trigger( 'LoaderEmbedPlayerCheckForPlayerTags',
306 - [ tagCheckObject ]);
307 -
308 - return tagCheckObject.hasTags;
 303+ return false;
309304 };
310305
311306 /**
@@ -318,9 +313,14 @@
319314 });
320315
321316 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() ) {
325325 var rewriteElementCount = 0;
326326
327327 // Set each player to loading ( as early on as possible )
@@ -339,12 +339,11 @@
340340 });
341341 // Load the embedPlayer module ( then run queued hooks )
342342 mw.load( 'EmbedPlayer', function ( ) {
343 - mw.log("EmbedPlayer:: do rewrite players:" + $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).length );
344343 // Rewrite the EmbedPlayer.RewriteTags with the
345 - $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer( callback );
 344+ $j( mw.getConfig( 'EmbedPlayer.RewriteTags' ) ).embedPlayer( doModuleTagRewrites );
346345 })
347346 } else {
348 - callback();
 347+ doModuleTagRewrites();
349348 }
350349 };
351350
@@ -399,9 +398,11 @@
400399 if( !!document.createElement('video').canPlayType && !$j.browser.safari ) {
401400 dependencyRequest[0].push( 'mw.EmbedPlayerNative' )
402401 }
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+ ){
406407 dependencyRequest[0].push('mw.EmbedPlayerNative');
407408 dependencyRequest[0].push('$j.postMessage');
408409 dependencyRequest[0].push('mw.IFramePlayerApiServer');
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -13,7 +13,6 @@
1414
1515 mw.includeAllModuleMessages();
1616
17 -
1817 /**
1918 * The base source attribute checks also see:
2019 * http://dev.w3.org/html5/spec/Overview.html#the-source-element
@@ -152,11 +151,13 @@
153152 mw.log( 'EmbedPlayer::trigger: EmbedPlayerManagerReady');
154153 $j( mw ).trigger( 'EmbedPlayerManagerReady' );
155154 }
156 - var addedToPlayerManager = false;
157155 // Make sure we have user preference setup ( for setting preferences on
158156 // video selection )
159157 mw.setupUserConfig( function() {
 158+
 159+ var addedToPlayerManager = false;
160160 mw.log("EmbedPlayer:: do: " + $j( playerSelect ).length + ' players ');
 161+
161162 // Add each selected element to the player manager:
162163 $j( playerSelect ).each( function( index, playerElement) {
163164 // Make sure the video tag was not generated by our library:
@@ -164,18 +165,20 @@
165166 $j('#loadingSpinner_' + $j( playerElement ).attr('id') ).hide();
166167 mw.log( 'EmbedPlayer::$j.embedPlayer skip embedPlayer gennerated video: ' + playerElement );
167168 } else {
168 - addedToPlayerManager = true;
169 - // Add the embedPlayer ready callback
170 - mw.playerManager.addCallback( callback );
 169+ addedToPlayerManager = true;
171170 // Add the player
172 - mw.playerManager.addElement( playerElement, attributes);
 171+ mw.playerManager.addPlayerElement( playerElement, attributes);
173172 }
174 -
175173 } );
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+ }
180183 }
181184
182185 });
@@ -208,21 +211,6 @@
209212 },
210213
211214 /**
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 - /**
227215 * Get the list of players
228216 */
229217 getPlayerList: function( ) {
@@ -230,7 +218,7 @@
231219 },
232220
233221 /**
234 - * Adds an Element for the embedPlayer to rewrite
 222+ * Adds a player element for the embedPlayer to rewrite
235223 *
236224 * uses embedPlayer interface on audio / video elements uses mvPlayList
237225 * interface on playlist elements
@@ -250,12 +238,12 @@
251239 * [Optional] attributes Extra attributes to apply to the player
252240 * interface
253241 */
254 - addElement: function( playerElement, attributes ) {
 242+ addPlayerElement: function( playerElement, attributes ) {
255243 var _this = this;
256244 if ( !playerElement.id || playerElement.id == '' ) {
257245 // give the playerElement an id:
258246 playerElement.id = 'vid' + ( this.playerList.length + 1 );
259 - }
 247+ }
260248 mw.log('EmbedPlayerManager: addElement:: ' + playerElement.id );
261249
262250 // Add the element id to playerList
@@ -265,37 +253,32 @@
266254 // that add to the request set
267255 var playerDependencyRequest = [];
268256
269 - // merge in any custom attributes
 257+ // Merge in any custom attributes
270258 $j.extend( playerElement, attributes );
271259
272260 // 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 )
274262 mw.embedPlayerUpdateLibraryRequest( playerElement, playerDependencyRequest );
 263+
275264 // Load any skins we need then swap in the interface
276265 mw.load( playerDependencyRequest, function() {
277266
278267 var waitForMeta = true;
279268
280 - // Be sure to "stop" the target ( sometimes firefox keeps playing
 269+ // Be sure to "stop" the target ( Firefox 3x keeps playing
281270 // the video even though its been removed from the DOM )
282271 if( playerElement.pause ){
283272 playerElement.pause();
284273 }
 274+
 275+ // Allow modules to override the wait for metadata flag:
 276+ $j( mw ).trigger( 'checkPlayerWaitForMetaData', playerElement );
285277
 278+ // Update the waitForMeta object if set to boolean false:
 279+ waitForMeta = ( playerElement.waitForMeta === false )? false : true;
286280
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 );
294281
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 )
300283 if( waitForMeta ){
301284 waitForMeta = _this.waitForMetaCheck( playerElement );
302285 }
@@ -309,30 +292,18 @@
310293 return ;
311294 }
312295 ranPlayerSwapFlag = true;
313 -
314296 mw.log("EmbedPlayer::runPlayerSwap::" + $j( playerElement ).attr('id') );
315297
316298 var playerInterface = new mw.EmbedPlayer( playerElement , attributes);
317299 var swapPlayer = _this.swapEmbedPlayerElement( playerElement, playerInterface );
 300+
318301
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 );
332304 $j( mw ).trigger ( 'newEmbedPlayerEvent', $j( '#' + playerInterface.id ).get(0) );
333305
334306 // 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:
337308 $j( '#' + playerInterface.id ).get(0).checkPlayerSources();
338309 }
339310
@@ -451,14 +422,12 @@
452423 // Create a new element to swap the player interface into
453424 var swapPlayerElement = document.createElement('div');
454425
455 - // Get properties / methods from playerInterface
 426+ // Get properties / methods from playerInterface:
456427 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 )
459429 swapPlayerElement[ method ] = playerInterface[ method ];
460430 }
461431 }
462 -
463432 // Check if we are using native controls or Persistent player ( should keep the video embed around )
464433 if( playerInterface.useNativePlayerControls() || playerInterface.isPersistentNativePlayer() ) {
465434 $j( targetElement )
@@ -527,13 +496,8 @@
528497 $j('.loadingSpinner').remove();
529498
530499 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' );
538502 }
539503 }
540504 };
@@ -1403,7 +1367,6 @@
14041368
14051369 // Set the player size attributes based loaded video element:
14061370 this.loadPlayerSize( element );
1407 -
14081371 // Set the plugin id
14091372 this.pid = 'pid_' + this.id;
14101373
@@ -1624,7 +1587,9 @@
16251588 emptySources: function(){
16261589 if( this.mediaElement ){
16271590 this.mediaElement.sources = [];
 1591+ this.mediaElement.selectedSource = null;
16281592 }
 1593+
16291594 },
16301595
16311596 /**
@@ -2293,7 +2258,10 @@
22942259 }
22952260 }
22962261 },
2297 -
 2262+ // update the video poster:
 2263+ updatePosterSrc: function( posterSrc ){
 2264+ this.poster = posterSrc;
 2265+ },
22982266 /**
22992267 * Returns the HTML code for the video when it is in thumbnail mode.
23002268 * playing, configuring the player, inline cmml display, HTML linkback,
@@ -2395,7 +2363,6 @@
23962364 */
23972365 showNativePlayer: function(){
23982366 var _this = this;
2399 -
24002367 // Empty the player of any child nodes
24012368 $j(this).empty();
24022369
@@ -2434,7 +2401,7 @@
24352402 this.applyMediaElementBindings();
24362403
24372404 // Android only can play with a special play button ( no native controls
2438 - // persistentNativePlayer has no controls:
 2405+ // persistentNativePlayer has no controls:
24392406 if( mw.isAndroid2() ){
24402407 this.addPlayBtnLarge();
24412408 }
@@ -2442,9 +2409,15 @@
24432410 },
24442411 addPlayBtnLarge:function(){
24452412 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+ })
24492422 );
24502423 },
24512424 /**
@@ -2498,9 +2471,8 @@
24992472 var iframeUrl = mw.getMwEmbedPath() + 'mwEmbedFrame.php?';
25002473 var params = {'src[]':[]};
25012474
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 ) {
25052477 params.apiTitleKey = this.apiTitleKey;
25062478 if ( this.apiProvider ) {
25072479 // Commons always uses the commons api provider ( special hack should refactor )
@@ -2591,10 +2563,8 @@
25922564 embedCode += '&quot; ';
25932565 }
25942566
2595 -
2596 - if ( this.roe ) {
2597 - embedCode += 'roe=&quot;' + mw.escapeQuotesHTML( this.roe ) + '&quot; ';
2598 - } else if( this.apiTitleKey ) {
 2567+ // TODO move to mediaWiki Support module
 2568+ if( this.apiTitleKey ) {
25992569 embedCode += 'apiTitleKey=&quot;' + mw.escapeQuotesHTML( this.apiTitleKey ) + '&quot; ';
26002570 if ( this.apiProvider ) {
26012571 embedCode += 'apiProvider=&quot;' + mw.escapeQuotesHTML( this.apiProvider ) + '&quot; ';
@@ -2623,28 +2593,6 @@
26242594 },
26252595
26262596 /**
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 - /**
26492597 * Base Embed Controls
26502598 */
26512599
@@ -2812,8 +2760,10 @@
28132761 if( this.useNativePlayerControls() ){
28142762 this.getPlayerElement().currentTime = 0;
28152763 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+ }
28182768 } else {
28192769 // Rewrite the html to thumbnail disp
28202770 this.showThumbnail();
@@ -3245,18 +3195,34 @@
32463196 /**
32473197 * Get the current selected media source or first source
32483198 *
 3199+ * @param {Number} Requested time in seconds to be passed to the server if the server supports
 3200+ * supportsURLTimeEncoding
32493201 * @return src url
32503202 */
3251 - getSrc: function() {
 3203+ getSrc: function( serverSeekTime ) {
 3204+ if( serverSeekTime ){
 3205+ this.serverSeekTime = serverSeekTime;
 3206+ }
32523207 if( this.currentTime && !this.serverSeekTime){
32533208 this.serverSeekTime = this.currentTime;
32543209 }
 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:
32553222 if( this.mediaElement.selectedSource ){
3256 - return this.mediaElement.selectedSource.getSrc( this.serverSeekTime );
3257 - } else if( this.mediaElement ){
32583223 // get the first source:
3259 - return this.mediaElement.getSources()[0].getSrc( this.serverSeekTime );
 3224+ return this.mediaElement.selectedSource.getSrc( this.serverSeekTime );
32603225 }
 3226+ // No selected source return false:
32613227 return false;
32623228 },
32633229
@@ -3273,14 +3239,14 @@
32743240 } else if( timeUrls == 'always' ){
32753241 return this.mediaElement.selectedSource.URLTimeEncoding;
32763242 } 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+ }
32813247 } else {
32823248 mw.log("Error:: invalid config value for EmbedPlayer.EnableURLTimeEncoding:: " + mw.getConfig('EmbedPlayer.EnableURLTimeEncoding') );
32833249 }
3284 - return false;
 3250+ return false;
32853251 }
32863252 }
32873253
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiClient.js
@@ -6,16 +6,17 @@
77
88 ( function( mw ) {
99
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 );
1212 }
1313 mw.IFramePlayerApiClient.prototype = {
1414 'exportedMethods': [
1515 'play',
1616 'pause'
1717 ],
18 - // Local store of the post message ( not updated by user js )
 18+ // Local store of the previous sate of player proxy
1919 '_prevPlayerProxy': {},
 20+
2021 // Stores the current playerProxy ( can be updated by user js )
2122 'init': function( iframe , playerProxy, options ){
2223 this.iframe = iframe;
@@ -27,12 +28,16 @@
2829 this.addPlayerReciveApi();
2930 },
3031 '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+
3237 $j.each( this.exportedMethods, function(na, method){
3338 _this.playerProxy[ method ] = function(){
3439 _this.postMessage( {
3540 'method' : method,
36 - 'args' : arguments
 41+ 'args' : $j.makeArray( arguments )
3742 } );
3843 };
3944 });
@@ -47,8 +52,7 @@
4853 * Handle received events
4954 */
5055 'hanldeReciveMsg': function( event ){
51 - var _this = this;
52 - //mw.log("IframePlayerApiClient:: hanldeReciveMsg ");
 56+ var _this = this;
5357 // Confirm the event is coming for the target host:
5458 if( event.origin != this.iframeServer){
5559 mw.log("Skip msg from host does not match iFrame player: " + event.origin +
@@ -57,7 +61,11 @@
5862 };
5963 // Decode the message
6064 var msgObject = JSON.parse( event.data );
 65+ //mw.log("IframePlayerApiClient:: hanldeReciveMsg: " + msgObject.triggerName );
 66+
 67+
6168 var playerAttributes = mw.getConfig( 'EmbedPlayer.Attributes' );
 69+
6270 // Before we update local attributes check that the object has not been updated by user js
6371 for( var attrName in playerAttributes ){
6472 if( attrName != 'id' ){
@@ -89,12 +97,11 @@
9098 //mw.log('IFramePlayerApiClient:: trigger: ' + msgObject.triggerName );
9199 $j( _this.playerProxy ).trigger( msgObject.triggerName, msgObject.triggerArgs );
92100 }
93 - // @@TODO:: Allow extending modules to wrap these api events ( kaltura kdp javascript emulation ? )
94101 },
95 - 'postMessage': function( msgObj ){
 102+ 'postMessage': function( msgObject ){
96103 //mw.log( "IFramePlayerApiClient:: postMessage(): " + JSON.stringify( msgObj ) );
97104 $j.postMessage(
98 - JSON.stringify( msgObj ),
 105+ JSON.stringify( msgObject ),
99106 mw.absoluteUrl( $j( this.iframe ).attr('src') ),
100107 this.iframe.contentWindow
101108 );
@@ -103,13 +110,15 @@
104111
105112 //Add the jQuery binding
106113 ( function( $ ) {
107 - $.fn.iFramePlayer = function( options ){
 114+ $.fn.iFramePlayer = function( readyCallback ){
108115 if( ! this.selector ){
109116 this.selector = $j( this ).get(0);
110117 }
111118 // Append '_ifp' ( iframe player ) to id of real iframe so that 'id', and 'src' attributes don't conflict
112119 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+
114123 // Append the div element proxy after the iframe
115124 $j( this.selector )
116125 .attr('id', iframePlayerId)
@@ -117,19 +126,25 @@
118127 $('<div />')
119128 .attr( 'id', originalIframeId )
120129 );
121 - var playerProxy = $j( '#' + originalIframeId ).get(0);
 130+
 131+ var playerProxy = $j( '#' + originalIframeId ).get(0);
122132 var iframe = $j('#' + iframePlayerId).get(0);
123133 if(!iframe){
124134 mw.log("Error invalide iFramePlayer request");
125135 return false;
126136 }
127137 if( !iframe['playerApi'] ){
128 - iframe['playerApi'] = new mw.IFramePlayerApiClient( iframe, playerProxy, options );
 138+ iframe['playerApi'] = new mw.IFramePlayerApiClient( iframe, playerProxy );
129139 }
130140
131141 // Allow modules to extend the 'iframe' based player
132 - $j( mw ).trigger( 'newIframeEmbedPlayerEvent', playerProxy);
 142+ $j( mw ).trigger( 'newIframePlayerClientSide', [ playerProxy ]);
133143
 144+ // Bind the iFrame player ready callback
 145+ if( readyCallback ){
 146+ $j( playerProxy ).bind( 'playerReady', readyCallback )
 147+ };
 148+
134149 // Return the player proxy for chaining player events / attributes
135150 return $j( playerProxy );
136151 };
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/skins/mw.PlayerControlBuilder.js
@@ -1414,19 +1414,10 @@
14151415 showDownload: function( $target ) {
14161416 var _this = this;
14171417 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+
14281419 // Load additional text sources via apiTitleKey:
14291420 // TODO we should move this to timedText bindings
1430 - } else if( embedPlayer.apiTitleKey ) {
 1421+ if( embedPlayer.apiTitleKey ) {
14311422 // Load text interface ( if not already loaded )
14321423 mw.load( 'TimedText', function() {
14331424 embedPlayer.timedText.setupTextSources(function(){
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.EmbedPlayerNative.js
@@ -99,7 +99,7 @@
100100 && typeof $j( '#' + this.pid ).get(0).play != 'undefined' ) {
101101
102102 // Update the player source:
103 - $j( '#' + this.pid ).attr('src', this.getSrc( this.currentTime ) );
 103+ $j( '#' + this.pid ).attr( 'src', this.getSrc( this.currentTime ) );
104104 $j( '#' + this.pid ).get(0).load();
105105
106106 _this.postEmbedJS();
@@ -359,11 +359,18 @@
360360 // Return the playerElement currentTime
361361 return this.playerElement.currentTime;
362362 },
363 -
364363
 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+
365373 /**
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
368375 *
369376 * @param {string}
370377 * src Video url Source to switch to.
@@ -388,8 +395,11 @@
389396 // Remove all native player bindings
390397 $j(vid).unbind();
391398 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
394404 var updateSrcAndPlay = function() {
395405 var vid = _this.getPlayerElement();
396406 if (!vid){
@@ -397,7 +407,7 @@
398408 return ;
399409 }
400410 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 )
402412 setTimeout(function() {
403413 var vid = _this.getPlayerElement();
404414 if (!vid){
@@ -409,14 +419,16 @@
410420 // Wait another 100ms then bind the end event and any custom events
411421 // for the switchCallback
412422 setTimeout(function() {
413 - var vid = _this.getPlayerElement();
 423+ var vid = _this.getPlayerElement();
 424+ // restore controls
 425+ vid.controls = orginalControlsState;
414426 // add the end binding:
415427 $j(vid).bind('ended', function( event ) {
416428 if(typeof doneCallback == 'function' ){
417429 doneCallback();
418430 }
419431 return false;
420 - })
 432+ });
421433 if (typeof switchCallback == 'function') {
422434 switchCallback(vid);
423435 }
Index: branches/MwEmbedStandAlone/modules/EmbedPlayer/mw.IFramePlayerApiServer.js
@@ -19,7 +19,13 @@
2020
2121 // Bind apiServer to newEmbedPlayers:
2222 $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+ }
2430 });
2531
2632 mw.IFramePlayerApiServer = function( embedPlayer ){
@@ -27,8 +33,11 @@
2834 }
2935
3036 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+ ],
3342
3443 'init': function( embedPlayer ){
3544 this.embedPlayer = embedPlayer;
@@ -41,13 +50,13 @@
4251 this.exportedBindings.push( bindName );
4352 }
4453 }
45 - this.exportedBindings.push( 'monitorEvent' );
4654
4755 // Allow modules to extend the list of iframeExported bindings
48 - $j( mw ).trigger( 'AddIframeExportedBindings', [ this.exportedBindings ]);
 56+ $j( mw ).trigger( 'AddIframePlayerBindings', [ this.exportedBindings ]);
4957
5058 this._addIframeListener();
5159 this._addIframeSender();
 60+ $j( mw ).trigger( 'newIframePlayerServerSide', [embedPlayer]);
5261 },
5362
5463 /**
@@ -73,22 +82,25 @@
7483 mw.log("Error: iFramePlayerApiServer:: could not parse parent url. \n" +
7584 "Player events will be dissabled");
7685 }
 86+ // Set the initial attributes once player is "ready"
 87+ $j( this.embedPlayer ).bind( 'playerReady', function(){
 88+ _this.sendPlayerAttributes();
 89+ });
7790 // On monitor event package the attributes for cross domain delivery:
7891 $j( this.embedPlayer ).bind( 'monitorEvent', function(){
7992 _this.sendPlayerAttributes();
8093 })
81 - // Set the initial attributes once player is "ready"
82 - $j( this.embedPlayer ).bind( 'playerReady', function(){
83 - _this.sendPlayerAttributes();
84 - });
8594
8695 $j.each( this.exportedBindings, function( inx, bindName ){
8796 $j( _this.embedPlayer ).bind( bindName, function( event ){
8897 var argSet = $j.makeArray( arguments );
8998 // remove the event from the arg set
9099 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 );
93105 _this.postMessage({
94106 'triggerName' : bindName,
95107 'triggerArgs' : argSet
Index: branches/MwEmbedStandAlone/remotes/AddMediaWizardEditPage.js
@@ -75,7 +75,6 @@
7676 } else {
7777 // Make sure the wikieditor got binded:
7878 if ( !didWikiEditorBind ) {
79 - mw.log( 'Failed to bind via build section bind via target:' );
8079 var $targetFileButton = $j( ".toolbar [rel='file']" );
8180
8281 $targetFileButton

Status & tagging log