Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html |
— | — | @@ -3,15 +3,15 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>Sample Themed Player</title> |
7 | | - <!-- Pre-loading demo ( stuff ) likely needed for video display --> |
| 7 | + <!-- Pre-loading demo ( stuff ) likely needed for video display |
8 | 8 | <script type="text/javascript" src="../jsScriptLoader.php?urid=1.1d&class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,kplayerEmbed,javaEmbed,vlcEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script> |
9 | 9 | <link rel="stylesheet" href="../skins/styles.css" type="text/css" media="screen" /> |
10 | 10 | <link rel="stylesheet" href="../skins/mvpcf/playerSkin.css" type="text/css" media="screen" /> |
11 | 11 | <link rel="stylesheet" href="../skins/kskin/playerSkin.css" type="text/css" media="screen" /> |
12 | | - |
13 | | - <!-- |
| 12 | + --> |
| 13 | + |
14 | 14 | <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
15 | | - --> |
| 15 | + |
16 | 16 | |
17 | 17 | </head> |
18 | 18 | <script type="text/javascript"> |
Index: branches/js2-work/phase3/js/mwEmbed/skins/kskin/kskinConfig.js |
— | — | @@ -223,20 +223,23 @@ |
224 | 224 | * Show the credit screen (presently specific to kaltura skin ) |
225 | 225 | */ |
226 | 226 | showCredits: function() { |
227 | | - //set up the shortcuts: |
228 | | - embedPlayer = this.embedPlayer; |
| 227 | + // Set up the shortcuts: |
| 228 | + var embedPlayer = this.embedPlayer; |
229 | 229 | var _this = this; |
230 | | - $target = embedPlayer.$interface.find( '.menu-credits' ); |
| 230 | + var $target = embedPlayer.$interface.find( '.menu-credits' ); |
231 | 231 | |
232 | | - $target.html( '<h2>' + gM( 'mwe-credits' ) + '</h2>' + |
233 | | - '<div class="credits_box ui-corner-all">' + |
234 | | - mw.loading_spinner() + |
235 | | - '</div>' |
| 232 | + $target.empty().append( |
| 233 | + $j('<h2 />') |
| 234 | + .text( gM( 'mwe-credits' ) ), |
| 235 | + $j('<div />') |
| 236 | + .addClass( "credits_box ui-corner-all" ) |
| 237 | + .loadingSpinner() |
236 | 238 | ); |
237 | 239 | |
238 | 240 | if( mw.getConfig( 'k_attribution' ) == true ){ |
239 | 241 | $target.append( |
240 | | - $j( '<div/>' ).addClass( 'k-attribution' ) |
| 242 | + $j( '<div />' ) |
| 243 | + .addClass( 'k-attribution' ) |
241 | 244 | .attr({ |
242 | 245 | 'title': gM('mwe-kaltura-platform-title') |
243 | 246 | }) |
— | — | @@ -252,37 +255,48 @@ |
253 | 256 | ); |
254 | 257 | return ; |
255 | 258 | } |
256 | | - |
257 | | - // Do the api request to populate the credits via the apiTitleKey |
258 | | - var request = { |
259 | | - // Normalize the File NS (ie sometimes its present in apiTitleKey other times not |
260 | | - 'titles' : 'File:' + embedPlayer.apiTitleKey.replace(/File:|Image:/, '' ), |
261 | | - 'prop' : 'revisions', |
262 | | - 'rvprop' : 'content' |
263 | | - }; |
264 | | - var req_categories = new Array(); |
| 259 | + |
| 260 | + _this.getCredits(); |
| 261 | + }, |
| 262 | + |
| 263 | + /** |
| 264 | + * Issues a request to populate the credits box |
| 265 | + */ |
| 266 | + getCredits: function(){ |
| 267 | + // Setup shortcuts: |
| 268 | + var embedPlayer = this.embedPlayer; |
| 269 | + var _this = this; |
| 270 | + var $target = embedPlayer.$interface.find( '.menu-credits' ); |
| 271 | + |
265 | 272 | var api_url = mw.getApiProviderURL( embedPlayer.apiProvider ); |
266 | | - if( ! api_url ){ |
267 | | - mw.log("Error: can't get credit screen without title key"); |
268 | | - return ; |
269 | | - } |
270 | | - mw.getJSON( api_url , request, function( data ) { |
271 | | - if( !data || !data.query || !data.query.pages ){ |
272 | | - $target.find('.credits_box').text( |
273 | | - 'Error: title key: ' + embedPlayer.apiTitleKey + ' not found' |
274 | | - ); |
275 | | - return false; |
276 | | - } |
277 | | - var pages = data.query.pages; |
278 | | - for(var i in pages){ |
279 | | - page = pages[ i ]; |
280 | | - if( page[ 'revisions' ] && page[ 'revisions' ][0]['*'] ){ |
281 | | - $target.find('.credits_box').html( |
282 | | - _this.doCreditLineFromWikiText( page[ 'revisions' ][0]['*'] ) |
283 | | - ); |
| 273 | + var fileTitle = 'File:' + embedPlayer.apiTitleKey.replace(/File:|Image:/, ''); |
| 274 | + |
| 275 | + // Get the image info |
| 276 | + var request = { |
| 277 | + 'prop' : 'imageinfo', |
| 278 | + 'titles': fileTitle, |
| 279 | + 'iiprop' : 'url' |
| 280 | + }; |
| 281 | + var articleUrl = ''; |
| 282 | + mw.getJSON( api_url, request, function( data ){ |
| 283 | + if ( data.query.pages ) { |
| 284 | + for ( var i in data.query.pages ) { |
| 285 | + var imageProps = data.query.pages[i]; |
| 286 | + // Check properites for "missing" |
| 287 | + if( imageProps.imageinfo && imageProps.imageinfo[0] && imageProps.imageinfo[0].descriptionurl ){ |
| 288 | + // Found page |
| 289 | + $target.find('.credits_box').html( |
| 290 | + _this.doCreditLine( imageProps.imageinfo[0].descriptionurl ) |
| 291 | + ); |
| 292 | + }else{ |
| 293 | + // missing page descriptionurl |
| 294 | + $target.find('.credits_box').text( |
| 295 | + 'Error: title key: ' + embedPlayer.apiTitleKey + ' not found' |
| 296 | + ); |
| 297 | + } |
284 | 298 | } |
285 | 299 | } |
286 | | - } ); |
| 300 | + } ); |
287 | 301 | }, |
288 | 302 | |
289 | 303 | /** |
— | — | @@ -292,12 +306,11 @@ |
293 | 307 | * |
294 | 308 | * @parm {String} wikiText Resource wiki text page contents |
295 | 309 | */ |
296 | | - doCreditLineFromWikiText: function ( wikiText ){ |
| 310 | + doCreditLine: function ( articleUrl ){ |
297 | 311 | var embedPlayer = this.embedPlayer; |
298 | 312 | |
299 | 313 | // Get the title str |
300 | | - var titleStr = embedPlayer.apiTitleKey.replace(/_/g, ' '); |
301 | | - var titleLink = 'http://commons.wikimedia.org/wiki/File:' + embedPlayer.apiTitleKey; |
| 314 | + var titleStr = embedPlayer.apiTitleKey.replace(/_/g, ' '); |
302 | 315 | |
303 | 316 | var imgWidth = ( this.getOverlayWidth() < 250 )? 45 : 90; |
304 | 317 | |
— | — | @@ -305,7 +318,7 @@ |
306 | 319 | return $j( '<div/>' ).addClass( 'creditline' ) |
307 | 320 | .append( |
308 | 321 | $j('<a/>').attr({ |
309 | | - 'href' : titleLink, |
| 322 | + 'href' : articleUrl, |
310 | 323 | 'title' : titleStr |
311 | 324 | }).html( |
312 | 325 | $j('<img/>').attr( { |
— | — | @@ -323,7 +336,7 @@ |
324 | 337 | // We use a div container to easialy get at the built out link |
325 | 338 | $j('<div>').html( |
326 | 339 | $j('<a/>').attr({ |
327 | | - 'href' : titleLink, |
| 340 | + 'href' : articleUrl, |
328 | 341 | 'title' : titleStr |
329 | 342 | }).text( titleStr ) |
330 | 343 | ).html() |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -1904,7 +1904,8 @@ |
1905 | 1905 | } else { |
1906 | 1906 | // Check if the file is local ( can be shared repo ) |
1907 | 1907 | if ( provider.check_shared ) { |
1908 | | - _this.findFileInLocalWiki( resource.target_resource_title, function( imagePage ) { |
| 1908 | + var fileTitle =_this.canonicalFileNS + ':' + resource.target_resource_title; |
| 1909 | + _this.findFileInLocalWiki( fileTitle, function( imagePage ) { |
1909 | 1910 | if ( imagePage && imagePage['imagerepository'] == 'shared' || |
1910 | 1911 | imagePage['imagerepository'] == 'commons') { |
1911 | 1912 | myCallback( 'shared' ); |
— | — | @@ -2262,7 +2263,7 @@ |
2263 | 2264 | var _this = this; |
2264 | 2265 | var request = { |
2265 | 2266 | 'action': 'query', |
2266 | | - 'titles': _this.canonicalFileNS + ':' + fileName, |
| 2267 | + 'titles': fileName, |
2267 | 2268 | 'prop': 'imageinfo', |
2268 | 2269 | 'iiprop': 'url', |
2269 | 2270 | 'iiurlwidth': '400' |
— | — | @@ -2273,7 +2274,8 @@ |
2274 | 2275 | for ( var i in data.query.pages ) { |
2275 | 2276 | for ( var j in data.query.pages[i] ) { |
2276 | 2277 | if ( j == 'missing' |
2277 | | - && data.query.pages[i].imagerepository != 'shared' ) |
| 2278 | + && data.query.pages[i].imagerepository != 'shared' |
| 2279 | + && data.query.pages[i].imagerepository != 'commons' ) |
2278 | 2280 | { |
2279 | 2281 | mw.log( fileName + " not found" ); |
2280 | 2282 | callback( false ); |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -1309,6 +1309,49 @@ |
1310 | 1310 | */ |
1311 | 1311 | |
1312 | 1312 | /** |
| 1313 | + * |
| 1314 | + * Shortcut to latest revision text of a given title |
| 1315 | + * |
| 1316 | + * Assumes "follow redirects" |
| 1317 | + * |
| 1318 | + * $j.getTitleText( [url], title, callback ) |
| 1319 | + * |
| 1320 | + * @param {String} url or title key |
| 1321 | + * @parma {Mixed} title or callback function |
| 1322 | + * @param {Function} callback Function or NULL |
| 1323 | + * |
| 1324 | + * @return callback is called with: |
| 1325 | + * {Boolean} false if no page found |
| 1326 | + * {String} text of wiki page |
| 1327 | + */ |
| 1328 | + mw.getTitleText = function( apiUrl, title, callback ){ |
| 1329 | + // Check if optional apiURL was not included |
| 1330 | + if( !callback ){ |
| 1331 | + title = apiUrl; |
| 1332 | + callback = title; |
| 1333 | + apiUrl = mw.getLocalApiUrl(); |
| 1334 | + } |
| 1335 | + var request = { |
| 1336 | + // Normalize the File NS (ie sometimes its present in apiTitleKey other times not |
| 1337 | + 'titles' : title, |
| 1338 | + 'prop' : 'revisions', |
| 1339 | + 'rvprop' : 'content' |
| 1340 | + }; |
| 1341 | + mw.getJSON( apiUrl , request, function( data ) { |
| 1342 | + if( !data || !data.query || !data.query.pages ){ |
| 1343 | + callback( false ); |
| 1344 | + } |
| 1345 | + var pages = data.query.pages; |
| 1346 | + for(var i in pages){ |
| 1347 | + page = pages[ i ]; |
| 1348 | + if( page[ 'revisions' ] && page[ 'revisions' ][0]['*'] ){ |
| 1349 | + callback( page[ 'revisions' ][0]['*'] ); |
| 1350 | + } |
| 1351 | + } |
| 1352 | + }); |
| 1353 | + } |
| 1354 | + |
| 1355 | + /** |
1313 | 1356 | * mediaWiki JSON a wrapper for jQuery getJSON: |
1314 | 1357 | * $j.getJSON( url, [data], [callback] ) |
1315 | 1358 | * |
Index: branches/js2-work/phase3/js/mwEmbed/jsScriptLoader.php |
— | — | @@ -21,17 +21,26 @@ |
22 | 22 | } |
23 | 23 | |
24 | 24 | class jsScriptLoader { |
| 25 | + |
| 26 | + // The list of javascript files |
25 | 27 | var $jsFileList = array(); |
| 28 | + |
| 29 | + // The language code for the script-loader request |
26 | 30 | var $langCode = ''; |
| 31 | + |
| 32 | + // The javascript output string |
27 | 33 | var $jsout = ''; |
28 | | - var $requestKey = ''; // the request key |
29 | | - var $error_msg = ''; |
| 34 | + |
| 35 | + // The request Key for the js |
| 36 | + var $requestKey = ''; |
| 37 | + |
| 38 | + // Error msg |
| 39 | + var $errorMsg = ''; |
| 40 | + |
| 41 | + // Debug flag |
30 | 42 | var $debug = false; |
31 | 43 | |
32 | | - // Whether we should include generated JS (special class '-') |
33 | | - var $jsvarurl = false; |
34 | | - var $doProcReqFlag = true; |
35 | | - |
| 44 | + // The raw requested class |
36 | 45 | private static $rawClassList = ''; |
37 | 46 | |
38 | 47 | /** |
— | — | @@ -89,31 +98,38 @@ |
90 | 99 | // Build the output |
91 | 100 | // Swap in the appropriate language per js_file |
92 | 101 | foreach ( $this->jsFileList as $classKey => $file_name ) { |
| 102 | + |
93 | 103 | // Get the script content |
94 | 104 | $jstxt = $this->getScriptText( $classKey, $file_name ); |
95 | 105 | if( $jstxt ){ |
96 | 106 | $this->jsout .= $this->doProcessJs( $jstxt ); |
97 | 107 | } |
98 | | - // If the core mwEmbed class entry point include loader js |
| 108 | + |
| 109 | + // If the core mwEmbed class entry point include all the loader js |
99 | 110 | if( $classKey == 'mwEmbed' ){ |
100 | 111 | $this->jsout .= jsClassLoader::getCombinedLoaderJs(); |
101 | 112 | } |
102 | 113 | } |
103 | 114 | |
104 | | - // Add a mw.loadDone callback so webkit browsers don't have to check if variables are "ready" |
105 | | - $this->jsout .= self::getOnDoneCallback( ); |
| 115 | + /* |
| 116 | + * Add a mw.loadDone class callback if there was no "error" in getting any of the classes |
| 117 | + */ |
| 118 | + if ( $this->error_msg == '' ){ |
| 119 | + $this->jsout .= self::getOnDoneCallback( ); |
| 120 | + } |
106 | 121 | |
107 | | - |
108 | 122 | // Check if we should minify the whole thing: |
109 | 123 | if ( !$this->debug ) { |
110 | 124 | $this->jsout = self::getMinifiedJs( $this->jsout , $this->requestKey ); |
111 | 125 | } |
| 126 | + |
112 | 127 | // Save to the file cache |
113 | 128 | if ( $wgUseFileCache && !$this->debug ) { |
114 | 129 | $status = $this->sFileCache->saveToFileCache( $this->jsout ); |
115 | 130 | if ( $status !== true ) |
116 | 131 | $this->error_msg .= $status; |
117 | 132 | } |
| 133 | + |
118 | 134 | // Check for an error msg |
119 | 135 | if ( $this->error_msg != '' ) { |
120 | 136 | //just set the content type (don't send cache header) |
— | — | @@ -128,7 +144,10 @@ |
129 | 145 | /** |
130 | 146 | * Get the onDone javascript callback for a given class list |
131 | 147 | * |
132 | | - * @return unknown |
| 148 | + * Enables a done loading callback for browsers like safari |
| 149 | + * that don't consistently support the <script>.onload call |
| 150 | + * |
| 151 | + * @return String |
133 | 152 | */ |
134 | 153 | static private function getOnDoneCallback( ){ |
135 | 154 | return 'if(mw && mw.loadDone){mw.loadDone(\'' . |