Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -151,10 +151,13 @@ |
152 | 152 | } |
153 | 153 | |
154 | 154 | remoteSearchDriver.prototype = { |
| 155 | + |
155 | 156 | // Result cleared flag |
156 | 157 | results_cleared: false, |
157 | | - // Caret possition of target text area ( lazy initialised ) |
| 158 | + |
| 159 | + // Caret position of target text area ( lazy initialised ) |
158 | 160 | caretPos: null, |
| 161 | + |
159 | 162 | // Text area value ( lazy initialised ) |
160 | 163 | textboxValue: null, |
161 | 164 | |
— | — | @@ -1721,13 +1724,14 @@ |
1722 | 1725 | |
1723 | 1726 | /** |
1724 | 1727 | * Internal function called by showResourceEditor() to show an image editor |
1725 | | - * @param {Object} resource Show Image Editor for this resource |
| 1728 | + * @param {Object} resource Resource for Image Editor display |
1726 | 1729 | */ |
1727 | 1730 | showImageEditor: function( resource ) { |
1728 | 1731 | var _this = this; |
1729 | 1732 | var options = _this.getClipEditOptions( resource ); |
| 1733 | + |
1730 | 1734 | // Display the mvClipEdit obj once we are done loading: |
1731 | | - mw.load( ['mvClipEdit'], function() { |
| 1735 | + mw.load( 'mvClipEdit', function() { |
1732 | 1736 | // Run the image clip tools |
1733 | 1737 | _this.clipEdit = new mvClipEdit( options ); |
1734 | 1738 | } ); |
— | — | @@ -2150,7 +2154,7 @@ |
2151 | 2155 | * @param {Function} callback Function to be called once api import call is done |
2152 | 2156 | */ |
2153 | 2157 | doApiImport: function( resource, callback ) { |
2154 | | - var _this = this; |
| 2158 | + var _this = this; |
2155 | 2159 | mw.log( ":doApiImport:" ); |
2156 | 2160 | $j.addLoaderDialog( gM( 'mwe-importing_asset' ) ); |
2157 | 2161 | |
— | — | @@ -2224,7 +2228,10 @@ |
2225 | 2229 | |
2226 | 2230 | // If status is missing show import UI |
2227 | 2231 | if ( status === 'missing' ) { |
2228 | | - _this.showImportUI( resource, callback ); |
| 2232 | + _this.showImportUI( resource, function(){ |
| 2233 | + // Once the image is imported re-issue the showPreview request: |
| 2234 | + _this.showPreview( resource ); |
| 2235 | + } ); |
2229 | 2236 | return; |
2230 | 2237 | } |
2231 | 2238 | |
— | — | @@ -2251,6 +2258,7 @@ |
2252 | 2259 | .click( function() { |
2253 | 2260 | _this.insertResource( resource ); |
2254 | 2261 | } ); |
| 2262 | + |
2255 | 2263 | // Update cancel button |
2256 | 2264 | $j( buttonPaneSelector ) |
2257 | 2265 | .append( '<a href="#" class="preview_close">Do More Modification</a>' ) |
— | — | @@ -2269,8 +2277,8 @@ |
2270 | 2278 | _this.target_title, |
2271 | 2279 | function( phtml ) { |
2272 | 2280 | $j( '#rsd_preview_display' ).html( phtml ); |
2273 | | - // update the display of video tag items (if any) |
2274 | | - mwdomReady( true ); |
| 2281 | + // Update the display of video tag items (if any) |
| 2282 | + $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer(); |
2275 | 2283 | } |
2276 | 2284 | ); |
2277 | 2285 | } ); |
— | — | @@ -2331,15 +2339,12 @@ |
2332 | 2340 | * @param {String} title Context title of the content to be parsed |
2333 | 2341 | * @param {Function} callback Function called with api parser output |
2334 | 2342 | */ |
2335 | | - parse: function( wikitext, title, callback ) { |
2336 | | - do_api_req( |
| 2343 | + parse: function( wikitext, title, callback ) { |
| 2344 | + mw.getJSON( this.local_wiki_api_url, |
2337 | 2345 | { |
2338 | | - 'data': { |
2339 | | - 'action': 'parse', |
2340 | | - 'title' : title, |
2341 | | - 'text': wikitext |
2342 | | - }, |
2343 | | - 'url': this.local_wiki_api_url |
| 2346 | + 'action': 'parse', |
| 2347 | + 'title' : title, |
| 2348 | + 'text': wikitext |
2344 | 2349 | }, function( data ) { |
2345 | 2350 | callback( data.parse.text['*'] ); |
2346 | 2351 | } |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -402,8 +402,8 @@ |
403 | 403 | |
404 | 404 | // Reset the done with action flag |
405 | 405 | _this.action_done = false; |
406 | | - |
407 | | - //do the api request |
| 406 | + |
| 407 | + // Do the api request: |
408 | 408 | mw.getJSON(_this.api_url, request, function( data ) { |
409 | 409 | _this.processApiResult( data ); |
410 | 410 | }); |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js |
— | — | @@ -14,6 +14,9 @@ |
15 | 15 | // If the k-skin video player should attribute kaltura |
16 | 16 | mw.setConfig( 'k_attribution', true ); |
17 | 17 | |
| 18 | +// The global player list per page |
| 19 | +mw.player_list = new Array(); |
| 20 | + |
18 | 21 | mw.addMessages( { |
19 | 22 | "mwe-loading_plugin" : "loading plugin ...", |
20 | 23 | "mwe-select_playback" : "Set playback preference", |
— | — | @@ -271,34 +274,10 @@ |
272 | 275 | |
273 | 276 | // Pointer to Selector: |
274 | 277 | var j_selector = this.selector; |
275 | | - |
276 | | - // Process selected elements: |
277 | | - // ie8 does not play well with the jQuery video,audio,playlist selector use native: |
278 | | - if ( $.browser.msie && $j.browser.version >= 8 ) { |
279 | | - var ie_compatible_selector = ''; |
280 | | - var jtags = j_selector.split( ',' ); |
281 | | - var coma = ''; |
282 | | - for ( var i = 0; i < jtags.length; i++ ) { |
283 | | - if ( jtags[i] === 'video' || |
284 | | - jtags[i] === 'audio' || |
285 | | - jtags[i] === 'playlist' ) { |
286 | | - // Use native ElementsByTagName selector |
287 | | - $( document.getElementsByTagName( jtags[i] ) ).each( function() { |
288 | | - mw.playerManager.addElement( this, attributes); |
289 | | - } ); |
290 | | - }else{ |
291 | | - ie_compatible_selector += coma + jtags[i] |
292 | | - coma = ','; |
293 | | - } |
294 | | - } |
295 | | - //Set the selector to IE compatible set and continue processing |
296 | | - j_selector = ie_compatible_selector; |
297 | | - } |
298 | 278 | |
299 | | - // Run the selector |
300 | | - $j( j_selector ).each( function() { |
301 | | - mw.playerManager.addElement( this, attributes); |
302 | | - } ); |
| 279 | + $j( mw.getPlayerTagElements( j_selector ) ).each( function(na, playerElement){ |
| 280 | + mw.playerManager.addElement( playerElement, attributes); |
| 281 | + } ); |
303 | 282 | |
304 | 283 | // Once we are done adding new players start to check if players are ready: |
305 | 284 | mw.playerManager.waitPlayersReadyCallback(); |
— | — | @@ -1676,7 +1655,7 @@ |
1677 | 1656 | } |
1678 | 1657 | } |
1679 | 1658 | }; |
1680 | | - } ); // end do_api_req |
| 1659 | + } ); // end $j.getJSON |
1681 | 1660 | }; |
1682 | 1661 | }, |
1683 | 1662 | |
— | — | @@ -3193,7 +3172,7 @@ |
3194 | 3173 | */ |
3195 | 3174 | setFormatPreference : function ( mime_format ) { |
3196 | 3175 | this.preference['format_preference'] = mime_format; |
3197 | | - this.savePreferences(); |
| 3176 | + mw.setUserConfig( 'playerPref', this.preference); |
3198 | 3177 | }, |
3199 | 3178 | |
3200 | 3179 | /** |
— | — | @@ -3208,8 +3187,9 @@ |
3209 | 3188 | if ( this.players[i].id == player_id ) { |
3210 | 3189 | selected_player = this.players[i]; |
3211 | 3190 | mw.log( 'choosing ' + player_id + ' for ' + mime_type ); |
3212 | | - this.preference[mime_type] = player_id; |
3213 | | - this.savePreferences(); |
| 3191 | + this.preference[ mime_type ] = player_id; |
| 3192 | + |
| 3193 | + mw.setUserConfig( 'playerPref', this.preference); |
3214 | 3194 | break; |
3215 | 3195 | } |
3216 | 3196 | } |
— | — | @@ -3231,30 +3211,8 @@ |
3232 | 3212 | loadPreferences : function ( ) { |
3233 | 3213 | this.preference = new Object(); |
3234 | 3214 | // see if we have a cookie set to a clientSupported type: |
3235 | | - var cookieVal = $j.cookie( 'ogg_player_exp' ); |
3236 | | - if ( cookieVal ) { |
3237 | | - var pairs = cookieVal.split( '&' ); |
3238 | | - for ( var i = 0; i < pairs.length; i++ ) |
3239 | | - { |
3240 | | - var name_value = pairs[i].split( '=' ); |
3241 | | - this.preference[name_value[0]] = name_value[1]; |
3242 | | - // mw.log('load preference for ' + name_value[0] + ' is ' + name_value[1]); |
3243 | | - } |
3244 | | - } |
3245 | | - }, |
3246 | | - |
3247 | | - /** |
3248 | | - * Saves the user preference settings to a cookie |
3249 | | - */ |
3250 | | - savePreferences : function() { |
3251 | | - var cookieVal = ''; |
3252 | | - for ( var i in this.preference ) |
3253 | | - cookieVal += i + '=' + this.preference[i] + '&'; |
3254 | | - |
3255 | | - cookieVal = cookieVal.substr( 0, cookieVal.length -1 ); |
3256 | | - var week = 7 * 86400 * 1000; |
3257 | | - $j.cookie( 'ogg_player_exp', cookieVal, { 'expires':week } ); |
3258 | | - } |
| 3215 | + mw.setUserConfig( 'playerPref' ); |
| 3216 | + } |
3259 | 3217 | }; |
3260 | 3218 | |
3261 | 3219 | /** |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js |
— | — | @@ -396,10 +396,9 @@ |
397 | 397 | */ |
398 | 398 | onloadedmetadata: function() { |
399 | 399 | this.getPlayerElement(); |
400 | | - mw.log( 'f:onloadedmetadata metadata ready Update duration:' + this.playerElement.duration); |
| 400 | + mw.log( 'f:onloadedmetadata metadata ready Update duration:' + this.playerElement.duration + ' old dur: ' + this.getDuration() ); |
401 | 401 | // update duration if not set (for now trust the getDuration more than this.playerElement.duration |
402 | | - if ( this.getDuration() == 0 && ! isNaN( this.playerElement.duration ) ) { |
403 | | - mw.log( 'updaed duration via native video duration: ' + this.playerElement.duration ) |
| 402 | + if ( ! isNaN( this.playerElement.duration ) ) { |
404 | 403 | this.duration = this.playerElement.duration; |
405 | 404 | } |
406 | 405 | |
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | 'action':'query', |
43 | 43 | 'meta':'userinfo' |
44 | 44 | } |
45 | | - //we use normal do_api_req with keywork 'proxy' for the url |
| 45 | + // Do proxy request |
46 | 46 | mw.proxy.doRequest( rObj, |
47 | 47 | function( data ){ |
48 | 48 | //now we get the data back for that domain |
Index: branches/js2-work/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | /* |
3 | | - mvClipEdit hanndles the edit interfaces for images and video |
| 3 | +* mvClipEdit handles the edit interfaces for images and video |
4 | 4 | */ |
| 5 | + |
5 | 6 | // set gMsg object: |
6 | 7 | mw.addMessages( { |
7 | 8 | "mwe-crop" : "Crop image", |
— | — | @@ -32,7 +33,7 @@ |
33 | 34 | } ); |
34 | 35 | |
35 | 36 | /** |
36 | | -* The default clipedit values |
| 37 | +* The default clipEdit values |
37 | 38 | */ |
38 | 39 | var default_clipedit_values = { |
39 | 40 | |
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js |
— | — | @@ -37,8 +37,7 @@ |
38 | 38 | 'skin_name' : 'mvpcf', |
39 | 39 | |
40 | 40 | // Default jquery ui skin name |
41 | | - 'jui_skin' : 'redmond', |
42 | | - |
| 41 | + 'jui_skin' : 'redmond', |
43 | 42 | |
44 | 43 | /** |
45 | 44 | * If jQuery / mwEmbed should always be loaded. |
— | — | @@ -56,19 +55,20 @@ |
57 | 56 | * NOTE: Future architecture will probably do away with this flag and refactor it into |
58 | 57 | * a smaller "remotePageMwEmbed.js" script similar to ../remoteMwEmbed.js |
59 | 58 | */ |
60 | | - 'alwaysSetupMwEmbed' : false, |
| 59 | + 'runSetupMwEmbed' : false, |
61 | 60 | |
62 | 61 | // The mediaWiki path of mvEmbed |
63 | 62 | 'mediaWiki_mwEmbedPath' : 'js2/mwEmbed/', |
64 | 63 | |
| 64 | + // Api actions that must be submited in a POST, and need an api proxy for cross domain calls |
| 65 | + 'apiPostActions': [ 'login', 'purge', 'rollback', 'delete', 'undelete', |
| 66 | + 'protect', 'block', 'unblock', 'move', 'edit', 'upload', 'emailuser', |
| 67 | + 'import', 'userrights' ], |
| 68 | + |
65 | 69 | //If we are in debug mode ( results in fresh debugg javascript includes ) |
66 | 70 | 'debug' : false |
67 | | -} |
| 71 | +}; |
68 | 72 | |
69 | | - |
70 | | -// @@todo move these into mw |
71 | | -var global_req_cb = new Array(); // The global request callback array |
72 | | - |
73 | 73 | /** |
74 | 74 | * The global mw object: |
75 | 75 | * |
— | — | @@ -93,20 +93,21 @@ |
94 | 94 | */ |
95 | 95 | $.skin_list = new Array(); |
96 | 96 | $.init_done = false; |
97 | | - $.cb_count = 0; |
98 | | - $.player_list = new Array(), // The global player list per page |
99 | | - $.req_cb = new Array() // The global request callback array |
| 97 | + $.cb_count = 0; |
100 | 98 | |
101 | 99 | /** |
102 | 100 | * Configuration System: |
103 | 101 | * |
104 | | - * Simple system of inherit defauts, with getter setter functions: |
| 102 | + * Simple system of inherit defaults, with getter setter functions: |
105 | 103 | */ |
106 | 104 | |
107 | 105 | // Local scope configuration var: |
108 | | - mwConfig = { }; |
| 106 | + var mwConfig = { }; |
109 | 107 | |
110 | | - for(var i in mwDefaultConf){ |
| 108 | + //Local scope mwUserConfig var. Stores user configuration |
| 109 | + var mwUserConfig = { }; |
| 110 | + |
| 111 | + for( var i in mwDefaultConf ){ |
111 | 112 | if( typeof mwConfig[ i ] == 'undefined' ) |
112 | 113 | mwConfig[ i ] = mwDefaultConf[ i ]; |
113 | 114 | } |
— | — | @@ -119,7 +120,7 @@ |
120 | 121 | */ |
121 | 122 | $.setConfig = function ( name, value ){ |
122 | 123 | mwConfig[ name ] = value; |
123 | | - } |
| 124 | + } |
124 | 125 | |
125 | 126 | /** |
126 | 127 | * Getter for configuration values |
— | — | @@ -129,13 +130,77 @@ |
130 | 131 | * returns "false" if key not found |
131 | 132 | */ |
132 | 133 | $.getConfig = function ( name ){ |
133 | | - if(mwConfig[ name ] ) |
| 134 | + if( mwConfig[ name ] ) |
134 | 135 | return mwConfig[ name ]; |
135 | 136 | return false; |
136 | 137 | } |
137 | 138 | |
| 139 | + /** |
| 140 | + * Loads the mwUserConfig from a cookie. |
| 141 | + * |
| 142 | + * Modules that want to use "User Config" should call |
| 143 | + * this setup function in their moduleLoader code. |
| 144 | + * |
| 145 | + * For performance interfaces should load '$j.cookie' & 'JSON' |
| 146 | + * in their grouped load request |
| 147 | + * |
| 148 | + * By abstracting user preference we could eventually integrate |
| 149 | + * a persistent per-account preference system on the server. |
| 150 | + * |
| 151 | + * @parma {Function} callback Function to be called once userPrefrences are loaded |
| 152 | + */ |
| 153 | + var setupUserConfigFlag = false; |
| 154 | + $.setupUserConfig = function( callback ){ |
| 155 | + if( setupUserConfigFlag ){ |
| 156 | + if( callback ) |
| 157 | + callback(); |
| 158 | + } |
| 159 | + // Do Setup user config: |
| 160 | + mw.load( [ '$j.cookie', 'JSON' ], function(){ |
| 161 | + if( $j.cookie( 'mwUserConfig' ) ){ |
| 162 | + mwUserConfig = JSON.parse( $j.cookie( 'mwUserConfig' ) ); |
| 163 | + } |
| 164 | + if( callback ) |
| 165 | + callback(); |
| 166 | + setupUserConfigFlag = true; |
| 167 | + }); |
| 168 | + } |
138 | 169 | |
139 | 170 | /** |
| 171 | + * Save a user configuration var to a cookie & local global variable |
| 172 | + * Loads the cookie plugin if not already loaded |
| 173 | + * |
| 174 | + * @param {String} name Name of user configuration value |
| 175 | + * @param {String} value Value of configuration name |
| 176 | + */ |
| 177 | + |
| 178 | + |
| 179 | + $.setUserConfig = function ( name, value, cookieOptions ){ |
| 180 | + // Update local value |
| 181 | + mwUserConfig[ name ] = value; |
| 182 | + |
| 183 | + // Update the cookie ( '$j.cookie' & 'JSON' should already be loaded ) |
| 184 | + mw.load( [ '$j.cookie', 'JSON' ], function(){ |
| 185 | + $j.cookie( 'mwUserConfig', JSON.stringify( mwUserConfig ) ); |
| 186 | + }); |
| 187 | + } |
| 188 | + |
| 189 | + /** |
| 190 | + * Save a user configuration var to a cookie & local global variable |
| 191 | + * Loads the cookie plugin if not already loaded |
| 192 | + * |
| 193 | + * @param {String} name Name of user configuration value |
| 194 | + * @return |
| 195 | + * value of the configuration name |
| 196 | + * false if the configuration name could not be found |
| 197 | + */ |
| 198 | + $.getUserConfig = function ( name ){ |
| 199 | + if( mwUserConfig[ name ] ) |
| 200 | + return mwUserConfig |
| 201 | + return false; |
| 202 | + } |
| 203 | + |
| 204 | + /** |
140 | 205 | * Language classes mw.lang |
141 | 206 | * |
142 | 207 | * Localized Language support attempts to mirror some of the functionality of Language.php in MediaWiki |
— | — | @@ -1031,7 +1096,7 @@ |
1032 | 1097 | var classDone = false; |
1033 | 1098 | |
1034 | 1099 | // Check if the class is ready: ( not all browers support onLoad script attribute ) |
1035 | | - // In the case of a "class" we can pull the javascript state untill its ready |
| 1100 | + // In the case of a "class" we can pull the javascript state until its ready |
1036 | 1101 | setTimeout( function(){ |
1037 | 1102 | $.waitForObject( className, function( className ){ |
1038 | 1103 | if( callback ) |
— | — | @@ -1042,9 +1107,13 @@ |
1043 | 1108 | |
1044 | 1109 | // Issue the request to load the class (include class name in result callback: |
1045 | 1110 | $.getScript( scriptRequest, function( ) { |
1046 | | - if( callback ) |
1047 | | - callback( className ); |
1048 | | - callback = null; |
| 1111 | + if(! $.isset( className )){ |
| 1112 | + mw.log( 'ClassName not set in time ( Use waitForObject )' ); |
| 1113 | + }else{ |
| 1114 | + if( callback ) |
| 1115 | + callback( className ); |
| 1116 | + callback = null; |
| 1117 | + } |
1049 | 1118 | } ); |
1050 | 1119 | //mw.log( 'done with running getScript request ' ); |
1051 | 1120 | }, |
— | — | @@ -1142,12 +1211,13 @@ |
1143 | 1212 | * callback parameter is not needed we setup the callback automatically |
1144 | 1213 | * url param 'action'=>'query' is assumed ( if not set to something else in the "data" param |
1145 | 1214 | * format is set to "json" automatically |
| 1215 | + * automatically issues request over "POST" if action={postActions} |
1146 | 1216 | * |
1147 | 1217 | * @param {Mixed} url or data request |
1148 | 1218 | * @param {Mixed} data or callback |
1149 | 1219 | * @param {Mixed} callbcak |
1150 | 1220 | * |
1151 | | - */ |
| 1221 | + */ |
1152 | 1222 | $.getJSON = function( arg1, arg2, arg3 ){ |
1153 | 1223 | |
1154 | 1224 | // Set up the url |
— | — | @@ -1168,14 +1238,8 @@ |
1169 | 1239 | if( !url ){ |
1170 | 1240 | mw.log( 'Error: no api url for api request' ); |
1171 | 1241 | return false; |
1172 | | - } |
| 1242 | + } |
1173 | 1243 | |
1174 | | - // Add the callback to the url if unset |
1175 | | - if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ){ |
1176 | | - // jQuery specific: ( second ? is replaced with the callback ) |
1177 | | - url += ( url.indexOf('?') == -1 ) ? '?callback=?' : '&callback=?'; |
1178 | | - } |
1179 | | - |
1180 | 1244 | // Add default action if unset: |
1181 | 1245 | if( !data['action'] ) |
1182 | 1246 | data['action'] = 'query'; |
— | — | @@ -1184,21 +1248,35 @@ |
1185 | 1249 | if( !data['format'] ) |
1186 | 1250 | data['format'] = 'json'; |
1187 | 1251 | |
1188 | | - mw.log("run getJSON: " + url + ' data: ' + data); |
1189 | | - // Pass off the jQuery getJSON request: |
1190 | | - $j.getJSON( url, data, callback ); |
| 1252 | + mw.log("run getJSON: " + url + ' data: ' + data['action'] + ' apiPost: ' +mw.getConfig( 'apiPostActions' ) ); |
| 1253 | + |
| 1254 | + if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ){ |
| 1255 | + if( ! $.isLocalDomain( url ) ){ |
| 1256 | + mw.log( "Error:: should setup proxy here" ); |
| 1257 | + } |
| 1258 | + $j.post( url, data, callback, 'json'); |
| 1259 | + }else{ |
| 1260 | + //If cross domain setup a callback: |
| 1261 | + if( ! $.isLocalDomain( url ) ){ |
| 1262 | + if( url.indexOf( 'callback=' ) == -1 || data[ 'callback' ] == -1 ){ |
| 1263 | + // jQuery specific: ( second ? is replaced with the callback ) |
| 1264 | + url += ( url.indexOf('?') == -1 ) ? '?callback=?' : '&callback=?'; |
| 1265 | + } |
| 1266 | + } |
| 1267 | + // Pass off the jQuery getJSON request: |
| 1268 | + $j.getJSON( url, data, callback ); |
| 1269 | + } |
1191 | 1270 | } |
1192 | 1271 | |
1193 | 1272 | /** |
1194 | | - * Metavid spefic roe request helper function |
| 1273 | + * Metavid specific roe request helper function |
1195 | 1274 | * |
1196 | 1275 | * NOTE: depreciated, will be removed once updates are pushed out to metavid.org |
1197 | 1276 | * |
1198 | 1277 | * @param roe_url to be updated |
1199 | 1278 | */ |
1200 | 1279 | $.getMvJsonUrl = function( roe_url , callback){ |
1201 | | - if ( mw.parseUri( document.URL ).host == mw.parseUri( roe_url ).host || |
1202 | | - roe_url.indexOf( '://' ) == -1 ){ |
| 1280 | + if ( $.isLocalDomain( roe_url ) ){ |
1203 | 1281 | $j.get( roe_url, callback ); |
1204 | 1282 | } else { |
1205 | 1283 | roe_url = mw.replaceUrlParams(roe_url, { |
— | — | @@ -1211,6 +1289,19 @@ |
1212 | 1290 | } |
1213 | 1291 | |
1214 | 1292 | /** |
| 1293 | + * Checks if the url is a request for the local domain |
| 1294 | + * relative paths are "local" domain |
| 1295 | + * @param {String} url Url for local domain |
| 1296 | + */ |
| 1297 | + $.isLocalDomain = function( url ) { |
| 1298 | + if( mw.parseUri( document.URL ).host == mw.parseUri( url ).host || |
| 1299 | + url.indexOf( '://' ) == -1 ){ |
| 1300 | + return true; |
| 1301 | + } |
| 1302 | + return false; |
| 1303 | + } |
| 1304 | + |
| 1305 | + /** |
1215 | 1306 | * Simple api helper to grab an edit token |
1216 | 1307 | * |
1217 | 1308 | * @param title The wiki page title you want to edit |
— | — | @@ -1383,14 +1474,23 @@ |
1384 | 1475 | * |
1385 | 1476 | * @param {Function} callback Function to run once DOM and jQuery are ready |
1386 | 1477 | */ |
1387 | | - $.addOnloadHook = function( callback ){ |
| 1478 | + $.addOnloadHook = function( callback ){ |
| 1479 | + mw.log('addOnloadHook:: ' ); |
1388 | 1480 | if( mwReadyFlag === false ){ |
1389 | 1481 | |
1390 | 1482 | // Add the callbcak to the onLoad function stack |
1391 | 1483 | mwOnLoadFuncitons.push ( callback ); |
1392 | 1484 | |
1393 | | - // Run the setup call ( won't run if already called earlier) |
1394 | | - $.setupMwEmbed(); |
| 1485 | + // Set the mwSetup flag. So that onLoad functions can |
| 1486 | + // be called once mwEmbed interfaces are setup. |
| 1487 | + if( !mwDomReadyFlag ){ |
| 1488 | + mw.log( 'set config flag' ); |
| 1489 | + mw.setConfig( 'runSetupMwEmbed', true ); |
| 1490 | + }else{ |
| 1491 | + mw.log( 'run setup directly' ); |
| 1492 | + //DOM is already ready run setup directly: |
| 1493 | + $.setupMwEmbed(); |
| 1494 | + } |
1395 | 1495 | |
1396 | 1496 | return ; |
1397 | 1497 | } |
— | — | @@ -1460,14 +1560,15 @@ |
1461 | 1561 | // Rewrite the rewritePlayerTags with the |
1462 | 1562 | $j( $.getConfig( 'rewritePlayerTags' ) ).embedPlayer() |
1463 | 1563 | // Run mw hooks: |
| 1564 | + mw.log("SetupDone ( player ) run hooks:" ) ; |
1464 | 1565 | mw.runLoadHooks(); |
1465 | 1566 | } ); |
1466 | | - }else{ |
| 1567 | + }else{ |
| 1568 | + mw.log("SetupDone run hooks ( no rewrite players found ):" ) ; |
1467 | 1569 | // Set ready state and run the callback |
1468 | 1570 | mw.runLoadHooks(); |
1469 | 1571 | } |
1470 | | - } ); |
1471 | | - mw.log('ran loader' ); |
| 1572 | + } ); |
1472 | 1573 | } |
1473 | 1574 | |
1474 | 1575 | // Flag to register the domReady has been called |
— | — | @@ -1485,7 +1586,7 @@ |
1486 | 1587 | mwDomReadyFlag = true; |
1487 | 1588 | |
1488 | 1589 | // Check for the force setup flag: |
1489 | | - if ( $.getConfig( 'alwaysSetupMwEmbed' ) ){ |
| 1590 | + if ( $.getConfig( 'runSetupMwEmbed' ) ){ |
1490 | 1591 | $.setupMwEmbed(); |
1491 | 1592 | return ; |
1492 | 1593 | } |
— | — | @@ -1506,8 +1607,8 @@ |
1507 | 1608 | /** |
1508 | 1609 | * Check the current DOM for any tags in "rewritePlayerTags" |
1509 | 1610 | */ |
1510 | | - $.documentHasPlayerTags = function(){ |
1511 | | - var tagElm = $.getPlayerTagElements( true ); |
| 1611 | + $.documentHasPlayerTags = function(){ |
| 1612 | + var tagElm = $.getPlayerTagElements( $.getConfig( 'rewritePlayerTags' ), true ); |
1512 | 1613 | if( tagElm && tagElm.length ) |
1513 | 1614 | return true; |
1514 | 1615 | return false; |
— | — | @@ -1516,26 +1617,62 @@ |
1517 | 1618 | /** |
1518 | 1619 | * Get page elements that match the rewritePlayerTags config |
1519 | 1620 | * |
1520 | | - * @param {Boolean} getOne Flag to retive only one tag ( faster for simple has tag checks ) |
| 1621 | + * @@NOTE we should probably exclud "video" that have already be rewritten |
| 1622 | + * |
| 1623 | + * @param {Boolean} getOne Flag to retrieve only one tag ( faster for simple has tag checks ) |
1521 | 1624 | */ |
1522 | | - $.getPlayerTagElements = function( getOne ){ |
1523 | | - var tagString = $.getConfig( 'rewritePlayerTags' ); |
1524 | | - if( ! tagString || tagString == '' ) |
| 1625 | + $.getPlayerTagElements = function( selector, getOneFlag ){ |
| 1626 | + |
| 1627 | + if( ! selector ){ |
| 1628 | + selector = $.getConfig( 'rewritePlayerTags' ); |
| 1629 | + } |
| 1630 | + |
| 1631 | + if( ! selector ){ |
1525 | 1632 | return false; |
| 1633 | + } |
| 1634 | + var tagsInDOM = [ ]; |
| 1635 | + // Check for tags: |
| 1636 | + // IE8 does not play well with the jQuery video,audio,playlist selector use native: |
| 1637 | + // NOTE: we should re-confirm this bug in-case IE pushes out an update |
| 1638 | + if ( $j.browser.msie && $j.browser.version >= 8 ) { |
| 1639 | + var ie_compatible_selector = ''; |
| 1640 | + var jtags = selector.split( ',' ); |
| 1641 | + var coma = ''; |
| 1642 | + for ( var i = 0; i < jtags.length; i++ ) { |
| 1643 | + if ( jtags[i] === 'video' || |
| 1644 | + jtags[i] === 'audio' || |
| 1645 | + jtags[i] === 'playlist' ) { |
| 1646 | + // Use native ElementsByTagName selector |
| 1647 | + $( document.getElementsByTagName( jtags[i] ) ).each( function() { |
| 1648 | + tagsInDOM.push( this ); |
| 1649 | + if( getOneFlag ) |
| 1650 | + return false; |
| 1651 | + } ); |
| 1652 | + |
| 1653 | + //If only returning the first found element return: |
| 1654 | + if( tagsInDOM.length != 0 && getOneFlag ) |
| 1655 | + return tagsInDOM[0] |
| 1656 | + }else{ |
| 1657 | + ie_compatible_selector += coma + jtags[i] |
| 1658 | + coma = ','; |
| 1659 | + } |
| 1660 | + } |
| 1661 | + //Set the selector to IE compatible set and continue processing |
| 1662 | + selector = ie_compatible_selector; |
| 1663 | + } |
| 1664 | + // Run the selector |
| 1665 | + $j( selector ).each( function() { |
| 1666 | + tagsInDOM.push( this ); |
| 1667 | + if( getOneFlag ) |
| 1668 | + return false; |
| 1669 | + } ); |
| 1670 | + |
| 1671 | + //If only returning the first found element return: |
| 1672 | + if( tagsInDOM.length != 0 && getOneFlag ) |
| 1673 | + return tagsInDOM |
1526 | 1674 | |
1527 | | - // Tags should be separated by "," |
1528 | | - var tags = tagString.split(','); |
1529 | | - var tagsInDOM = [ ]; |
1530 | | - // Check for tags: |
1531 | | - for( var i in tags ){ |
1532 | | - var tagElements = document.getElementsByTagName( tags[ i ] ); |
1533 | | - for(var j = 0; j < tagElements.length; j++ ){ |
1534 | | - tagsInDOM.push( tagElements[ j ] ); |
1535 | | - if( getOne ) |
1536 | | - return tagsInDOM; |
1537 | | - } |
1538 | | - } |
1539 | | - return tagsInDOM; |
| 1675 | + // Return all the player tags: |
| 1676 | + return tagsInDOM; |
1540 | 1677 | } |
1541 | 1678 | |
1542 | 1679 | /** |
— | — | @@ -2159,7 +2296,8 @@ |
2160 | 2297 | '$j.ui', |
2161 | 2298 | 'embedPlayer', |
2162 | 2299 | 'ctrlBuilder', |
2163 | | - '$j.cookie' |
| 2300 | + '$j.cookie', |
| 2301 | + 'JSON' |
2164 | 2302 | ], |
2165 | 2303 | [ |
2166 | 2304 | '$j.ui.slider' |
— | — | @@ -2224,17 +2362,20 @@ |
2225 | 2363 | |
2226 | 2364 | // Load the video libs: |
2227 | 2365 | mw.load( dependencyRequest, function() { |
2228 | | - |
2229 | | - // Detect supported players: |
2230 | | - embedTypes.init(); |
| 2366 | + //Setup userConfig |
| 2367 | + mw.setupUserConfig( function(){ |
| 2368 | + // Detect supported players: |
| 2369 | + embedTypes.init(); |
| 2370 | + |
| 2371 | + // Remove no video html elements: |
| 2372 | + $j( '.videonojs' ).remove(); |
| 2373 | + //mw.log(" run callback: " + callback ); |
| 2374 | + |
| 2375 | + // Run the callback with name of the module |
| 2376 | + if( callback ) |
| 2377 | + callback( 'player' ); |
2231 | 2378 | |
2232 | | - // Remove no video html elements: |
2233 | | - $j( '.videonojs' ).remove(); |
2234 | | - //mw.log(" run callback: " + callback ); |
2235 | | - |
2236 | | - // Run the callback with name of the module |
2237 | | - if( callback ) |
2238 | | - callback( 'player' ); |
| 2379 | + } ); // setupUserConfig |
2239 | 2380 | } ); |
2240 | 2381 | |
2241 | 2382 | } ); // done with embedPlayer loader.js |
— | — | @@ -2265,7 +2406,9 @@ |
2266 | 2407 | /** |
2267 | 2408 | * Set DOM-ready call |
2268 | 2409 | * Does not use jQuery( document ).ready( ) because |
2269 | | -* mwEmbed could have been included without jQuery. |
| 2410 | +* mwEmbed could have been included without jQuery. |
| 2411 | +* |
| 2412 | +* mw.domReady function has checks to only be run once |
2270 | 2413 | */ |
2271 | 2414 | // For Mozilla / modern browsers |
2272 | 2415 | if ( document.addEventListener ) { |
— | — | @@ -2286,7 +2429,18 @@ |
2287 | 2430 | } |
2288 | 2431 | mw.domReady(); |
2289 | 2432 | } |
| 2433 | +// If inserted into an already loaded document: |
| 2434 | +if( document.readyState == 'complete'){ |
| 2435 | + mw.domReady(); |
| 2436 | +} |
| 2437 | +//And just to be sure ( for dynamic inserts ) ... check if "body" tag exists after 25ms |
| 2438 | +setTimeout( function(){ |
| 2439 | + if( document.getElementsByTagName('body')[0] ){ |
| 2440 | + mw.domReady(); |
| 2441 | + } |
| 2442 | +}, 25 ); |
2290 | 2443 | |
| 2444 | + |
2291 | 2445 | /* |
2292 | 2446 | * Store all the mwEmbed jQuery-specific bindings |
2293 | 2447 | * ( to be run after jQuery is available ). |
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mw.timedText.js |
— | — | @@ -6,11 +6,14 @@ |
7 | 7 | * timed text loading request |
8 | 8 | * timed text edit requests |
9 | 9 | * timed text search & seek interface ( version 2 ) |
| 10 | + * |
| 11 | + * @author: Michael Dale |
10 | 12 | * |
11 | 13 | * Some code borrowed from: http://www.annodex.net/~silvia/itext/elephant_no_skin_v2.html |
12 | 14 | * ( Licenced under: MPL 1.1/GPL 2.0/LGPL 2.1 ) |
13 | 15 | * Contributor(s): |
14 | 16 | * Silvia Pfeiffer <silvia@siliva-pfeiffer.de> |
| 17 | + * |
15 | 18 | */ |
16 | 19 | |
17 | 20 | mw.addMessages( { |
— | — | @@ -106,8 +109,7 @@ |
107 | 110 | |
108 | 111 | /** |
109 | 112 | * @constructor |
110 | | - * @param {Object} embedPlayer Host player for timedText interfaces |
111 | | - * |
| 113 | + * @param {Object} embedPlayer Host player for timedText interfaces |
112 | 114 | */ |
113 | 115 | init: function( embedPlayer, options ){ |
114 | 116 | var _this = this; |
— | — | @@ -120,7 +122,7 @@ |
121 | 123 | embedPlayer.addHook( 'monitor', function(){ |
122 | 124 | _this.monitor(); |
123 | 125 | } ) |
124 | | - // @@TODO: Load cookie / page prefrences |
| 126 | + // @@TODO: Load cookie / page preferences |
125 | 127 | |
126 | 128 | // Load textSources |
127 | 129 | _this.loadTextSources( function(){ |
— | — | @@ -137,12 +139,17 @@ |
138 | 140 | /** |
139 | 141 | * Monitor video time and update timed text filed[s] |
140 | 142 | */ |
141 | | - monitor: function(){ |
142 | | - mw.log(' timedText monitor '); |
| 143 | + monitor: function( embedPlayer ){ |
| 144 | + //setup local refrence to currentTime: |
| 145 | + var currentTime = embedPlayer.currentTime; |
| 146 | + |
| 147 | + for( var i in enabledSource) { |
| 148 | + |
| 149 | + } |
143 | 150 | }, |
144 | 151 | |
145 | 152 | /** |
146 | | - * Loads all the avaliable text sources from the inline embed |
| 153 | + * Loads all the available text sources from the inline embed |
147 | 154 | * or from a timedTextProvider |
148 | 155 | */ |
149 | 156 | loadTextSources: function( callback ){ |
— | — | @@ -210,7 +217,7 @@ |
211 | 218 | }, |
212 | 219 | |
213 | 220 | /** |
214 | | - * Selection of a meun item |
| 221 | + * Selection of a menu item |
215 | 222 | * |
216 | 223 | * @param {Element} item Item selected |
217 | 224 | */ |
— | — | @@ -395,10 +402,12 @@ |
396 | 403 | this[i] = source[i]; |
397 | 404 | } |
398 | 405 | }, |
| 406 | + |
399 | 407 | /** |
400 | 408 | * Function to load and parse the source text |
401 | 409 | */ |
402 | 410 | load: function(){ |
| 411 | + var _this = this; |
403 | 412 | // Set parser handler: |
404 | 413 | switch( this.getMIMEType() ){ |
405 | 414 | case 'text/x-srt': |
— | — | @@ -420,7 +429,7 @@ |
421 | 430 | // mw.log("Error can't load non-json src via jsonp:" + this.getSrc() ) |
422 | 431 | // return ; |
423 | 432 | //} |
424 | | - $j.get( this.getSrc(), function(){ |
| 433 | + $j.get( this.getSrc(), function( data ){ |
425 | 434 | // Parse and load captions: |
426 | 435 | _this.captions = handler( data ); |
427 | 436 | // Update the loaded state: |
Index: branches/js2-work/phase3/js2/remoteMwEmbed.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | |
7 | 7 | var urlparts = getRemoteEmbedPath(); |
8 | 8 | var mwEmbedHostPath = urlparts[0]; |
9 | | -var mwRemoteVersion = '1.1c'; |
| 9 | +var mwRemoteVersion = '1.1d'; |
10 | 10 | var mwUseScriptLoader = true; |
11 | 11 | |
12 | 12 | // Setup up request Params: |
— | — | @@ -27,6 +27,9 @@ |
28 | 28 | } |
29 | 29 | } ); |
30 | 30 | |
| 31 | +/** |
| 32 | +* Page specific rewrites for mediaWiki |
| 33 | +*/ |
31 | 34 | function doPageSpecificRewrite() { |
32 | 35 | // Add media wizard |
33 | 36 | if ( wgAction == 'edit' || wgAction == 'submit' ) { |
— | — | @@ -104,7 +107,7 @@ |
105 | 108 | } |
106 | 109 | /* |
107 | 110 | * This will be depreciated when we update to OggHandler |
108 | | -* @param {Object} vidIdList List of video ids to proccess |
| 111 | +* @param {Object} vidIdList List of video ids to process |
109 | 112 | */ |
110 | 113 | function rewrite_for_OggHandler( vidIdList ) { |
111 | 114 | function procVidId( vidId ) { |
— | — | @@ -183,7 +186,7 @@ |
184 | 187 | |
185 | 188 | } |
186 | 189 | }; |
187 | | - // process each item in the vidIdList (with setTimeout to avoid locking) |
| 190 | + // Process each item in the vidIdList (with setTimeout to avoid locking) |
188 | 191 | procVidId( vidIdList.pop() ); |
189 | 192 | } |
190 | 193 | function getRemoteEmbedPath() { |
— | — | @@ -220,6 +223,7 @@ |
221 | 224 | } |
222 | 225 | return rurl; |
223 | 226 | } |
| 227 | + |
224 | 228 | /** |
225 | 229 | * Load the mwEmbed library: |
226 | 230 | * |
— | — | @@ -254,21 +258,22 @@ |
255 | 259 | rurl += '&' + mwGetReqArgs(); |
256 | 260 | importScriptURI( rurl ); |
257 | 261 | } else { |
258 | | - // Ingore classSet (will be loaded onDemand ) |
| 262 | + // Ignore classSet (will be loaded onDemand ) |
259 | 263 | importScriptURI( mwEmbedHostPath + '/mwEmbed/mwEmbed.js?' + mwGetReqArgs() ); |
260 | 264 | } |
261 | 265 | } |
262 | 266 | waitMwEmbedReady( callback ); |
263 | 267 | } |
| 268 | + |
264 | 269 | /** |
265 | | -* waits for mwEmbed to be ready |
| 270 | +* Waits for mwEmbed to be ready |
266 | 271 | */ |
267 | 272 | function waitMwEmbedReady( callback ) { |
268 | 273 | if( ! mwCheckObjectPath( 'mw.version' ) ){ |
269 | 274 | setTimeout( function() { |
270 | 275 | waitMwEmbedReady( callback ); |
271 | 276 | }, 25 ); |
272 | | - } else { |
| 277 | + } else { |
273 | 278 | // Make sure mwEmbed is "setup" by using the addOnLoadHook: |
274 | 279 | mw.addOnloadHook( function(){ |
275 | 280 | callback(); |
— | — | @@ -277,6 +282,7 @@ |
278 | 283 | } |
279 | 284 | /** |
280 | 285 | * Checks an object path to see if its defined |
| 286 | +* @param {String} libVar The objectPath to be checked |
281 | 287 | */ |
282 | 288 | function mwCheckObjectPath ( libVar ) { |
283 | 289 | if ( !libVar ) |