Index: trunk/phase3/js2/mwEmbed/libMwApi/mw.proxy.js |
— | — | @@ -2,11 +2,10 @@ |
3 | 3 | * |
4 | 4 | * Api proxy system |
5 | 5 | * |
6 | | -* Built to support cross domain uploading, and api actions for a approved set of domains. |
7 | | -* mwProxy enables a system for fluid contributions across wikis domains for which your logged in. |
| 6 | +* Supports cross domain uploading, and api actions for a approved set of domains. |
8 | 7 | * |
9 | | -* The framework support a request approval system for per-user domain approval |
10 | | -* and a central blacklisting of domains controlled by site or system administrators. |
| 8 | +* The framework /will/ support a request approval system for per-user domain approval |
| 9 | +* and a central blacklisting of domains controlled by the site |
11 | 10 | * |
12 | 11 | * Flow outline below: |
13 | 12 | * |
— | — | @@ -56,34 +55,38 @@ |
57 | 56 | */ |
58 | 57 | $.proxy.client = function( pConf, conf ) { |
59 | 58 | var _this = this; |
60 | | - // do setup: |
| 59 | + // Do client setup: |
61 | 60 | if ( pConf.server_frame ) |
62 | 61 | $.proxy.server_frame = pConf.server_frame; |
63 | 62 | |
64 | 63 | if ( pConf.client_frame_path ) { |
65 | 64 | $.proxy.client_frame_path = pConf.client_frame_path; |
66 | 65 | } else { |
67 | | - // guess the client frame path: |
| 66 | + // Set to default mwEmbed iframe path: |
68 | 67 | $.proxy.client_frame_path = wgScriptPath + '/js2/mwEmbed/libMwApi/NestedCallbackIframe.html'; |
69 | 68 | } |
70 | 69 | |
71 | 70 | if ( mw.parseUri( $.proxy.server_frame ).host == mw.parseUri( document.URL ).host ) { |
72 | | - js_log( "Error: why are you trying to proxy yourself? " ); |
| 71 | + js_log( "Error: trying to proxy local domain? " ); |
73 | 72 | return false; |
74 | 73 | } |
75 | 74 | return true; |
76 | 75 | } |
77 | | - // set the frameProxy Flag: |
| 76 | + // Set the frameProxy Flag: |
78 | 77 | var frameProxyOk = false; |
79 | | - /* setup a iframe request hash */ |
80 | | - $.proxy.doFrameProxy = function( reqObj ) { |
| 78 | + |
| 79 | + /** |
| 80 | + * doFrameProxy |
| 81 | + * Writes an iframe with a hashed value of the requestQuery |
| 82 | + */ |
| 83 | + $.proxy.doFrameProxy = function( requestQuery ) { |
81 | 84 | var hashPack = { |
82 | 85 | 'cd': mw.parseUri( document.URL ).host, |
83 | 86 | 'cfp': $.proxy.client_frame_path, |
84 | | - 'req': reqObj |
| 87 | + 'req': requestQuery |
85 | 88 | } |
86 | 89 | js_log( "Do frame proxy request on src: \n" + $.proxy.server_frame + "\n" + |
87 | | - JSON.stringify( reqObj ) ); |
| 90 | + JSON.stringify( requestQuery ) ); |
88 | 91 | // we can't update src's so we have to remove and add all the time :( |
89 | 92 | // @@todo we should support frame msg system |
90 | 93 | $j( '#frame_proxy' ).remove(); |
— | — | @@ -106,57 +109,70 @@ |
107 | 110 | } |
108 | 111 | var lastApiReq = { }; |
109 | 112 | $.proxy.proxyNotReadyDialog = function() { |
110 | | - var btn = { }; |
111 | | - btn[ gM( 'mwe-re-try' ) ] = function() { |
| 113 | + var buttons = { }; |
| 114 | + buttons[ gM( 'mwe-re-try' ) ] = function() { |
112 | 115 | $j.addLoaderDialog( gM( 'mwe-re-trying' ) ); |
113 | 116 | $.proxy.doFrameProxy( lastApiReq ); |
114 | 117 | } |
115 | | - btn[ gM( 'mwe-cancel' ) ] = function() { |
| 118 | + buttons[ gM( 'mwe-cancel' ) ] = function() { |
116 | 119 | $j.closeLoaderDialog(); |
117 | 120 | } |
118 | 121 | var pUri = mw.parseUri( $.proxy.server_frame ); |
119 | | - // this is sort of a temporary hack if we change the MediaWiki:ApiProxy key |
120 | | - // we will have to deal with that here as well: |
121 | | - var login_url = pUri.protocol + '://' + pUri.host + |
122 | | - pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' ); |
123 | | - $j.addDialog( gM( 'mwe-proxy-not-ready' ), gM( 'mwe-please-login', [ login_url, pUri.host] ) + |
124 | | - '<p style="font-size:small">' + gM( 'mwe-remember-loging' ) + '</p>', |
125 | | - btn |
| 122 | + |
| 123 | + // FIXME we should have a Hosted iframe once we deploy mwEmbed on the servers. |
| 124 | + // A hosted iframe would be much faster since than a normal page view |
| 125 | + |
| 126 | + var login_url = pUri.protocol + '://' + pUri.host; |
| 127 | + login_url += pUri.path.replace( 'MediaWiki:ApiProxy', 'Special:UserLogin' ); |
| 128 | + |
| 129 | + $j.addDialog( |
| 130 | + gM( 'mwe-proxy-not-ready' ), |
| 131 | + gM( 'mwe-please-login', [ login_url, pUri.host] ) + |
| 132 | + '<p style="font-size:small">' + |
| 133 | + gM( 'mwe-remember-loging' ) + |
| 134 | + '</p>', |
| 135 | + buttons |
126 | 136 | ) |
127 | 137 | } |
128 | | - /* the do_api_request with callback: */ |
129 | | - $.proxy.doRequest = function( reqObj, callback ) { |
| 138 | + /* |
| 139 | + * doRequest |
| 140 | + * Takes a requestQuery, executes the query and then calls the callback |
| 141 | + */ |
| 142 | + $.proxy.doRequest = function( requestQuery, callback ) { |
130 | 143 | js_log( "doRequest:: " + JSON.stringify( reqObj ) ); |
131 | 144 | lastApiReq = reqObj; |
132 | 145 | // setup the callback: |
133 | 146 | $.proxy.callback = callback; |
134 | 147 | // do the proxy req: |
135 | | - $.proxy.doFrameProxy( reqObj ); |
| 148 | + $.proxy.doFrameProxy( requestQuery ); |
136 | 149 | } |
137 | 150 | /** |
138 | | - * The nested iframe action that passes its msg back up to the top instance |
| 151 | + * The nested iframe action that passes its result back up to the top frame instance |
139 | 152 | */ |
140 | 153 | $.proxy.nested = function( hashResult ) { |
141 | | - // close the loader if present: |
| 154 | + // Close the loader if present: |
142 | 155 | $j.closeLoaderDialog(); |
143 | 156 | js_log( '$.proxy.nested callback :: ' + unescape( hashResult ) ); |
144 | 157 | frameProxyOk = true; |
145 | | - // try to parse the hash result: |
| 158 | + |
| 159 | + // Try to parse the hash result: |
146 | 160 | try { |
147 | 161 | var rObj = JSON.parse( unescape( hashResult ) ); |
148 | 162 | } catch ( e ) { |
149 | 163 | js_log( "Error could not parse hashResult" ); |
150 | 164 | } |
151 | | - // special callback to frameProxyOk flag (not an api result, don't call callback) |
| 165 | + |
| 166 | + // Special callback to frameProxyOk flag |
| 167 | + // (only used to test the proxy connection) |
152 | 168 | if ( rObj.state == 'ok' ) |
153 | 169 | return ; |
154 | 170 | |
155 | | - // if all good pass it to the callback: |
| 171 | + // Pass the callback: |
156 | 172 | $.proxy.callback( rObj ); |
157 | 173 | } |
158 | 174 | /** |
159 | | - * The serverApiProxy handles the actual proxy |
160 | | - * and child frames pointing to the parent "blank" frames |
| 175 | + * The server handles the actual proxy |
| 176 | + * it adds child frames pointing to the parent "blank" frames |
161 | 177 | * |
162 | 178 | * This is (Domain B) in the above described setup |
163 | 179 | */ |
— | — | @@ -180,30 +196,30 @@ |
181 | 197 | ' client from: ' + aObj.cd + |
182 | 198 | ' to nested target: ' + aObj.cfp ); |
183 | 199 | |
184 | | - // make sure we are logged in |
| 200 | + // Make sure we are logged in |
185 | 201 | // (its a normal mediaWiki page so all site vars should be defined) |
186 | 202 | if ( !wgUserName ) { |
187 | | - js_log( 'error Not logged in' ); |
| 203 | + js_log( 'Error Not logged in' ); |
188 | 204 | return false; |
189 | 205 | } |
190 | 206 | |
191 | 207 | var domain = aObj.cd; |
192 | 208 | var nested_frame_src = 'http://' + aObj.cd + aObj.cfp; |
193 | | - // check the master whitelist |
| 209 | + // Check the master whitelist |
194 | 210 | for ( var i in pConf.master_whitelist ) { |
195 | 211 | if ( domain == pConf.master_whitelist[ i ] ) { |
196 | | - // do the request: |
| 212 | + // Do the request: |
197 | 213 | return doNestedProxy( aObj.req ); |
198 | 214 | } |
199 | 215 | } |
200 | | - // check master blacklist |
| 216 | + // Check master blacklist |
201 | 217 | for ( var i in pConf.master_blacklist ) { |
202 | 218 | if ( domain == pConf.master_blacklist ) { |
203 | 219 | js_log( 'domain: ' + domain + ' is blacklisted' ); |
204 | 220 | return false; |
205 | 221 | } |
206 | 222 | } |
207 | | - // @@todo grab the users whitelist for our current domain |
| 223 | + // FIXME grab the users whitelist for our current domain |
208 | 224 | /*var local_api = wgScriptPath + '/index' + wgScriptExtension + '?title=' + |
209 | 225 | 'User:' + wgUserName + '/apiProxyDomainList.js' + |
210 | 226 | '&action=raw&smaxage=0&gen=js'; |
— | — | @@ -214,31 +230,34 @@ |
215 | 231 | // if still not found: |
216 | 232 | js_log( "domain " + domain + " not approved" ); |
217 | 233 | |
218 | | - // offer the user the ability to "approve" requested domain save to their user page |
| 234 | + // FIXME :: offer the user the ability to "approve" requested domain save to |
| 235 | + // their user/ apiProxyDomainList.js page |
219 | 236 | |
220 | 237 | function doNestedProxy( reqObj ) { |
221 | 238 | js_log( "doNestedProxy to: " + nested_frame_src ); |
222 | | - // output iframe prior to running api request |
223 | | - // (so we can fail faster / cache the nested page / simotaniusly load things) |
| 239 | + |
| 240 | + // Do a quick response to establish the proxy is working |
| 241 | + // ( before we actually run the api-request ) |
224 | 242 | doNestedFrame ( 'nested_ok' , { 'state':'ok' } ); |
225 | 243 | |
226 | 244 | var outputhash = escape( JSON.stringify( reqObj ) ); |
227 | | - // add some api stuff: |
228 | | - reqObj['format'] = 'json'; |
229 | | - // process the api request |
| 245 | + |
| 246 | + // Add some api stuff: |
| 247 | + reqObj[ 'format' ] = 'json'; |
| 248 | + |
| 249 | + // Process the api request |
230 | 250 | $j.post( wgScriptPath + '/api' + wgScriptExtension, |
231 | 251 | reqObj, |
232 | | - function( data ) { |
233 | | - // js_log("Proxy GOT Res: " + data ); |
234 | | - // put it into the nested frame hash string: |
| 252 | + function( data ) { |
| 253 | + // Put it into the nested frame hash string: |
235 | 254 | doNestedFrame( 'nested_push', JSON.parse( data ) ); |
236 | 255 | } |
237 | 256 | ); |
238 | 257 | } |
239 | | - // add the doNestedFrame iframe: |
| 258 | + // Add the doNestedFrame iframe: |
240 | 259 | function doNestedFrame( nestname, resultObj ) { |
241 | 260 | $j( '#nested_push' ).remove(); |
242 | | - // setup the nested proxy that points back to top domain: |
| 261 | + // Setup the nested proxy that points back to top domain: |
243 | 262 | $j( 'body' ).append( '<iframe id="nested_push" name="nested_push" ' + |
244 | 263 | 'src="' + nested_frame_src + |
245 | 264 | '#' + escape( JSON.stringify( resultObj ) ) + |
Index: trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php |
— | — | @@ -388,6 +388,11 @@ |
389 | 389 | 'mwe-related_videos' => 'Related videos', |
390 | 390 | 'mwe-seeking' => 'seeking', |
391 | 391 | 'mwe-copy-code' => 'Copy code', |
| 392 | + |
| 393 | + /* |
| 394 | + * File: /skins/kskin/kskin.js |
| 395 | + */ |
| 396 | + 'mwe-credit-title' => 'Title: $1', |
392 | 397 | ); |
393 | 398 | |
394 | 399 | /** Message documentation (Message documentation) |
Index: trunk/phase3/js2/mwEmbed/skins/kskin/kskin.js |
— | — | @@ -2,12 +2,22 @@ |
3 | 3 | * skin js allows you to override contrlBuilder html/class output |
4 | 4 | */ |
5 | 5 | |
| 6 | +loadGM( { |
| 7 | + "mwe-credit-title" : "Title: $1" |
| 8 | +} ); |
| 9 | + |
6 | 10 | var kskinConfig = { |
7 | 11 | pClass: 'k-player', |
8 | 12 | // display time progress |
9 | 13 | long_time_disp: false, |
10 | 14 | body_options: false, |
11 | 15 | volume_layout: 'horizontal', |
| 16 | + menu_items:[ |
| 17 | + 'playerselect', |
| 18 | + 'download', |
| 19 | + 'share', |
| 20 | + 'credits', |
| 21 | + ], |
12 | 22 | components: { |
13 | 23 | 'play-btn-large' : { |
14 | 24 | 'h' : 55 |
— | — | @@ -76,10 +86,8 @@ |
77 | 87 | $target = $j( '#' + embedObj.id + ' .menu-' + mk ).hide(); |
78 | 88 | // Generate the menu html not already done: |
79 | 89 | if ( $target.children().length == 0 ) { |
80 | | - // call the function show{Menuitem} with target: |
81 | | - embedObj['show' + mk.charAt( 0 ).toUpperCase() + mk.substring( 1 )]( |
82 | | - $j( '#' + embedObj.id + ' .menu-' + mk ) |
83 | | - ); |
| 90 | + // call the function show{Menuitem} with target: |
| 91 | + _this.showMenuItem( mk ); |
84 | 92 | } |
85 | 93 | // Slide out the others |
86 | 94 | $j( '#' + embedObj.id + ' .menu-screen' ).hide(); |
— | — | @@ -93,10 +101,10 @@ |
94 | 102 | // Options menu display: |
95 | 103 | $tp.find( '.k-options' ).click( function() { |
96 | 104 | if ( $j( '#' + embedObj.id + ' .k-menu' ).length == 0 ) { |
97 | | - // stop the player if it does not support overlays: |
98 | | - if ( !embedObj.supports['overlays'] ) |
| 105 | + // Stop the player if it does not support overlays: |
| 106 | + if ( !embedObj.supports['overlay'] ) |
99 | 107 | $tp.get( 0 ).stop(); |
100 | | - // Add the options |
| 108 | + // Add the options |
101 | 109 | addMvOptions(); |
102 | 110 | } |
103 | 111 | // Set up the text and menu: |
— | — | @@ -115,5 +123,104 @@ |
116 | 124 | } |
117 | 125 | } ); |
118 | 126 | |
| 127 | + }, |
| 128 | + showMenuItem:function( menu_item ) { |
| 129 | + //handle special k-skin specific display; |
| 130 | + if( menu_item == 'credits'){ |
| 131 | + this.showCredits(); |
| 132 | + }else{ |
| 133 | + //call the base embedObj "show{Item}" |
| 134 | + this.embedObj['show' + menu_item.charAt( 0 ).toUpperCase() + menu_item.substring( 1 )]( |
| 135 | + $j( '#' + this.embedObj.id + ' .menu-' + menu_item ) |
| 136 | + ); |
| 137 | + } |
| 138 | + }, |
| 139 | + // Do the credit screen (presently specific to kaltura skin:) |
| 140 | + showCredits:function() { |
| 141 | + //set up the shortcuts: |
| 142 | + embedObj = this.embedObj; |
| 143 | + var _this = this; |
| 144 | + $target = $j( '#' + embedObj.id + ' .menu-credits' ); |
| 145 | + $target.html( '<h2>' + gM( 'mwe-credits' ) + '</h2>' + |
| 146 | + '<div class="credits_box ui-corner-all">' + |
| 147 | + mv_get_loading_img() + |
| 148 | + '</div>' |
| 149 | + ); |
| 150 | + |
| 151 | + if( mw.conf.k_attribution == true ){ |
| 152 | + $target.append( |
| 153 | + $j('<div/>').addClass( 'k-attribution') |
| 154 | + ); |
| 155 | + } |
| 156 | + |
| 157 | + if( !embedObj.wikiTitleKey ){ |
| 158 | + $target.find('.credits_box').text( |
| 159 | + 'Error: no title key to grab credits with' |
| 160 | + ); |
| 161 | + return ; |
| 162 | + } |
| 163 | + // Do the api request to populate the credits via the wikiTitleKey ( tied to "commons" ) |
| 164 | + var reqObj = { |
| 165 | + 'action' : 'query', |
| 166 | + // Normalize the File NS (ie sometimes its present in wikiTitleKey other times not |
| 167 | + 'titles' : 'File:' + embedObj.wikiTitleKey.replace(/File:|Image:/, '' ), |
| 168 | + 'prop' : 'revisions', |
| 169 | + 'rvprop' : 'content' |
| 170 | + }; |
| 171 | + var req_categories = new Array(); |
| 172 | + do_api_req( { |
| 173 | + 'url' : mw.commons_api_url, |
| 174 | + 'data' : reqObj |
| 175 | + }, function( data ) { |
| 176 | + if( !data || !data.query || !data.query.pages ){ |
| 177 | + $target.find('.credits_box').text( |
| 178 | + 'Error: title key: ' + embedObj.wikiTitleKey + ' not found' |
| 179 | + ); |
| 180 | + return false; |
| 181 | + } |
| 182 | + var pages = data.query.pages; |
| 183 | + for(var i in pages){ |
| 184 | + page = pages[ i ]; |
| 185 | + if( page[ 'revisions' ] && page[ 'revisions' ][0]['*'] ){ |
| 186 | + $target.find('.credits_box').html( |
| 187 | + _this.doCreditLineFromWikiText( page[ 'revisions' ][0]['*'] ) |
| 188 | + ); |
| 189 | + } |
| 190 | + } |
| 191 | + } ); |
| 192 | + }, |
| 193 | + doCreditLineFromWikiText:function ( wikiText ){ |
| 194 | + var embedObj = this.embedObj; |
| 195 | + |
| 196 | + // Get the title str |
| 197 | + var titleStr = embedObj.wikiTitleKey.replace(/_/g, ' '); |
| 198 | + var titleLink = 'http://commons.wikimedia.org/wiki/File:' + embedObj.wikiTitleKey; |
| 199 | + |
| 200 | + // @@FIXME Do a quick check for source line: |
| 201 | + return $j( '<div/>' ).addClass( 'creditline' ) |
| 202 | + .append( |
| 203 | + $j('<a/>').attr({ |
| 204 | + 'href' : titleLink, |
| 205 | + 'title' : titleStr |
| 206 | + }).html( |
| 207 | + $j('<img/>').attr( { |
| 208 | + 'border': 0, |
| 209 | + 'src' : embedObj.thumbnail, |
| 210 | + } ) |
| 211 | + ) |
| 212 | + ) |
| 213 | + .append( |
| 214 | + $j('<span>').html( |
| 215 | + gM( 'mwe-credit-title' , |
| 216 | + // We use a div container to easialy get at the built out link |
| 217 | + $j('<div>').html( |
| 218 | + $j('<a/>').attr({ |
| 219 | + 'href' : titleLink, |
| 220 | + 'title' : titleStr |
| 221 | + }).text( titleStr ) |
| 222 | + ).html() |
| 223 | + ) |
| 224 | + ) |
| 225 | + ); |
119 | 226 | } |
120 | 227 | } |
\ No newline at end of file |
Index: trunk/phase3/js2/mwEmbed/skins/kskin/playerSkin.css |
— | — | @@ -36,6 +36,14 @@ |
37 | 37 | background-position: -16px -48px; |
38 | 38 | } |
39 | 39 | |
| 40 | +/* cc icon */ |
| 41 | +.k-player .ui-state-default .ui-icon-comment { |
| 42 | + background-position: 0px -65px; |
| 43 | +} |
| 44 | +.k-player .ui-state-hover .ui-icon-comment { |
| 45 | + background-position: -17px -65px; |
| 46 | +} |
| 47 | + |
40 | 48 | .k-player .ui-state-default .ui-icon-play { |
41 | 49 | background: url(images/ksprite.png) no-repeat 0 0; |
42 | 50 | } |
— | — | @@ -337,7 +345,7 @@ |
338 | 346 | border: 1px solid #000000; |
339 | 347 | color: #000000; |
340 | 348 | float: right; |
341 | | - height: 24px; |
| 349 | + height: 34px; |
342 | 350 | padding: 0 5px 3px; |
343 | 351 | width: 84px; |
344 | 352 | font-size: 1em; |
— | — | @@ -385,4 +393,24 @@ |
386 | 394 | margin: -3px 5px 0 -1px; |
387 | 395 | position: absolute; |
388 | 396 | width: 8px; |
| 397 | +} |
| 398 | + |
| 399 | +.k-player .credits_box { |
| 400 | + background-attachment:scroll; |
| 401 | + background-color:white; |
| 402 | + background-image:none; |
| 403 | + background-position:0 0; |
| 404 | + bottom:30px; |
| 405 | + left:15px; |
| 406 | + position:absolute; |
| 407 | + right:61px; |
| 408 | + top:48px; |
| 409 | +} |
| 410 | +.k-player .credits_box a{ |
| 411 | + color:#666; |
| 412 | +} |
| 413 | +.k-player .creditline img { |
| 414 | + float: left; |
| 415 | + width: 90px; |
| 416 | + margin: 4px; |
389 | 417 | } |
\ No newline at end of file |
Index: trunk/phase3/js2/mwEmbed/skins/ctrlBuilder.js |
— | — | @@ -39,12 +39,6 @@ |
40 | 40 | 'options':true, |
41 | 41 | 'borders':true |
42 | 42 | }, |
43 | | - menu_items:[ |
44 | | - 'playerselect', |
45 | | - 'download', |
46 | | - 'share', |
47 | | - 'credits', |
48 | | - ], |
49 | 43 | getControls:function() { |
50 | 44 | // set up local pointer to the embedObj |
51 | 45 | var embedObj = this.embedObj; |
— | — | @@ -432,7 +426,7 @@ |
433 | 427 | 'play_head': { |
434 | 428 | 'w':0, // special case (takes up remaining space) |
435 | 429 | 'o':function( ctrlObj ) { |
436 | | - return '<div class="play_head" style="width: ' + ( ctrlObj.available_width - 30 ) + 'px;"></div>'; |
| 430 | + return '<div class="play_head" style="width: ' + ( ctrlObj.available_width - 34 ) + 'px;"></div>'; |
437 | 431 | } |
438 | 432 | } |
439 | 433 | } |
Index: trunk/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -172,6 +172,23 @@ |
173 | 173 | window['mw'] = { } |
174 | 174 | } |
175 | 175 | |
| 176 | + |
| 177 | +// Inherit the default global config |
| 178 | +var mwDefaultConf = { |
| 179 | + 'skin_name' : 'mvpcf', |
| 180 | + 'jui_skin' : 'redmond', |
| 181 | + 'video_size' : '400x300', |
| 182 | + 'k_attribution' : true |
| 183 | +} |
| 184 | +if( !mw.conf ) |
| 185 | + mw.conf = { } |
| 186 | + |
| 187 | +for(var i in mwDefaultConf){ |
| 188 | + if( typeof mw.conf[ i ] == 'undefined' ) |
| 189 | + mw.conf[ i ] = mwDefaultConf[ i ]; |
| 190 | +} |
| 191 | + |
| 192 | + |
176 | 193 | // @@todo move these into mw |
177 | 194 | var global_req_cb = new Array(); // The global request callback array |
178 | 195 | |
— | — | @@ -181,15 +198,7 @@ |
182 | 199 | * Any global functions/classes that are not jQuery plugins should make |
183 | 200 | * there way into the mw namespace |
184 | 201 | */ |
185 | | -( function( $ ) { |
186 | | - /* |
187 | | - * global config |
188 | | - */ |
189 | | - $.conf = { |
190 | | - 'skin_name' : 'mvpcf', |
191 | | - 'jui_skin' : 'redmond', |
192 | | - 'video_size' : '400x300' |
193 | | - } |
| 202 | +( function( $ ) { |
194 | 203 | // list valid skins here: |
195 | 204 | $.valid_skins = ['mvpcf', 'kskin']; |
196 | 205 | // the version of mwEmbed |
— | — | @@ -343,8 +352,7 @@ |
344 | 353 | * Plural matchRuleTest |
345 | 354 | */ |
346 | 355 | function matchRuleTest( cRule, val ) { |
347 | | - // js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val ); |
348 | | - |
| 356 | + js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val ); |
349 | 357 | function checkValue( compare, val ) { |
350 | 358 | if ( typeof compare == 'string' ) { |
351 | 359 | range = compare.split( '-' ); |
— | — | @@ -412,12 +420,13 @@ |
413 | 421 | for ( var ruleInx in rs ) { |
414 | 422 | cRule = rs[ruleInx]; |
415 | 423 | if ( matchRuleTest( cRule, tObj.arg ) ) { |
416 | | - // js_log("matched rule: " + ruleInx ); |
| 424 | + js_log("matched rule: " + ruleInx ); |
417 | 425 | return getTempParamFromRuleInx( tObj, rCount ); |
418 | 426 | } |
419 | 427 | rCount ++; |
420 | 428 | } |
421 | | - // js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] ); |
| 429 | + js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] ); |
| 430 | + //debugger; |
422 | 431 | // return the last /"other" template param |
423 | 432 | return tObj.param [ tObj.param.length - 1 ]; |
424 | 433 | } |
— | — | @@ -691,34 +700,7 @@ |
692 | 701 | // do the recursive magic swap text: |
693 | 702 | this.pOut = recurse_magic_swap( this.pNode ); |
694 | 703 | |
695 | | - }, |
696 | | - /** |
697 | | - * getTemplateVars special function to grab template paramaters |
698 | | - * from template text |
699 | | - * |
700 | | - * @returns {Array} template vars names |
701 | | - */ |
702 | | - getTemplateVars:function() { |
703 | | - // do a regular ex to get the ~likely~ template values |
704 | | - // (of course this sucks) |
705 | | - // but maybe this will make its way into the api sometime soon to support wysiwyg type editors |
706 | | - // ideally it would expose a good deal of info about the template params |
707 | | - js_log( 'matching against: ' + this.wikiText ); |
708 | | - var tempVars = this.wikiText.match( /\{\{\{([^\}]*)\}\}\}/gi ); |
709 | | - // clean up results: |
710 | | - var tVars = new Array(); |
711 | | - for ( var i = 0; i < tempVars.length; i++ ) { |
712 | | - var tvar = tempVars[i].replace( '{{{', '' ).replace( '}}}', '' ); |
713 | | - // Strip anything after a | |
714 | | - if ( tvar.indexOf( '|' ) != -1 ) { |
715 | | - tvar = tvar.substr( 0, tvar.indexOf( '|' ) ); |
716 | | - } |
717 | | - // Add if not already there |
718 | | - if ( $j.inArray( tvar, tVars ) == -1 ) |
719 | | - tVars.push( tvar ); |
720 | | - } |
721 | | - return tVars; |
722 | | - }, |
| 704 | + }, |
723 | 705 | /* |
724 | 706 | * parsed template api ~loosely based off of ~POM~ |
725 | 707 | * http://www.mediawiki.org/wiki/Extension:Page_Object_Model |
— | — | @@ -953,6 +935,7 @@ |
954 | 936 | callback(); |
955 | 937 | return; |
956 | 938 | } |
| 939 | + |
957 | 940 | // Do a check for any CSS we may need and get it |
958 | 941 | for ( var i = 0; i < loadLibs.length; i++ ) { |
959 | 942 | if ( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ) { |
— | — | @@ -961,6 +944,7 @@ |
962 | 945 | } |
963 | 946 | |
964 | 947 | // Check if we should use the script loader to combine all the requests into one |
| 948 | + // ( the scriptloader defines the mwSlScript global ) |
965 | 949 | if ( typeof mwSlScript != 'undefined' ) { |
966 | 950 | var class_set = ''; |
967 | 951 | var last_class = ''; |
— | — | @@ -1100,13 +1084,8 @@ |
1101 | 1085 | jQueryCheck: function( callback ) { |
1102 | 1086 | // js_log( 'jQueryCheck::' + this.jQuerySetupFlag); |
1103 | 1087 | var _this = this; |
1104 | | - // Skip stuff if $j is already loaded: |
1105 | | - if ( _global['$j'] ) { |
1106 | | - callback(); // call the callback now |
1107 | | - callback = null; |
1108 | | - // This is tricky because js2stopgap registers $j without doing the "setup" |
1109 | | - if ( _this.jQuerySetupFlag ) |
1110 | | - return ; |
| 1088 | + if ( _global['$j'] && _this.jQuerySetupFlag ) { |
| 1089 | + callback(); // call the callback now |
1111 | 1090 | } |
1112 | 1091 | // Load jQuery |
1113 | 1092 | _this.doLoad( [ |
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/vlcEmbed.js |
— | — | @@ -4,8 +4,9 @@ |
5 | 5 | * assume version > 0.8.5.1 |
6 | 6 | */ |
7 | 7 | var vlcEmbed = { |
8 | | - instanceOf:'vlcEmbed', |
9 | | - supports: { 'play_head':true, |
| 8 | + instanceOf : 'vlcEmbed', |
| 9 | + supports : { |
| 10 | + 'play_head':true, |
10 | 11 | 'pause':true, |
11 | 12 | 'stop':true, |
12 | 13 | 'fullscreen':true, |
— | — | @@ -260,7 +261,7 @@ |
261 | 262 | this.parent_stop(); |
262 | 263 | }, |
263 | 264 | pause : function() { |
264 | | - this.parent_pause(); // update the inteface if paused via native control |
| 265 | + this.parent_pause(); // update the interface if paused via native control |
265 | 266 | if ( this.vlc ) { |
266 | 267 | this.vlc.playlist.togglePause(); |
267 | 268 | } |
— | — | @@ -271,13 +272,13 @@ |
272 | 273 | if ( this.vlc ) |
273 | 274 | this.vlc.audio.toggleMute(); |
274 | 275 | }, |
275 | | - // @@ Suport UpDateVolumen |
| 276 | + // @@ Support UpDateVolumen |
276 | 277 | updateVolumen:function( perc ) { |
277 | 278 | this.getVLC(); |
278 | 279 | if ( this.vlc ) |
279 | 280 | this.vlc.audio.volume = perc * 100; |
280 | 281 | }, |
281 | | - // @@ Get Volumen |
| 282 | + // @@ Get Volumen |
282 | 283 | getVolumen:function() { |
283 | 284 | this.getVLC(); |
284 | 285 | if ( this.vlc ) |
— | — | @@ -288,19 +289,7 @@ |
289 | 290 | if ( this.vlc.video ) |
290 | 291 | this.vlc.video.toggleFullscreen(); |
291 | 292 | } |
292 | | - }, |
293 | | - /* returns current time in float seconds |
294 | | - * as per html5 we should just have an attribute by name of CurrentTime |
295 | | - * http://www.whatwg.org/specs/web-apps/current-work/#currenttime |
296 | | - currentTime : function(){ |
297 | | - if(typeof this.vlc != 'undefined' ){ |
298 | | - if(typeof this.vlc.input != 'undefined' ){ |
299 | | - return this.vlc.input.time/1000; |
300 | | - } |
301 | | - } |
302 | | - return '0'; |
303 | | - }, |
304 | | - */ |
| 293 | + }, |
305 | 294 | // get the embed vlc object |
306 | 295 | getVLC : function() { |
307 | 296 | this.vlc = this.getPluginEmbed(); |
Index: trunk/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js |
— | — | @@ -909,8 +909,11 @@ |
910 | 910 | var dcss = parseInt( $j(element).css( dim ).replace( 'px' , '' ) ); |
911 | 911 | var dattr = parseInt( $j(element).attr( dim ) ); |
912 | 912 | this[ dim ] = ( dcss )? dcss : dattr; |
913 | | - if(!this[ dim ]){ |
914 | | - // Grab width/height from default value |
| 913 | + if( !this[ dim ] ){ |
| 914 | + //special height default for audio tag: |
| 915 | + if( element.tagName.toLowerCase() == 'audio' && dim == 'height' ) |
| 916 | + return this[ dim ] = 0; |
| 917 | + // Grab width/height from default value (for video) |
915 | 918 | var dwh = mw.conf['video_size'].split( 'x' ); |
916 | 919 | this[ dim ] = ( dim == 'width' )? dwh[0] : dwh[1]; |
917 | 920 | } |
— | — | @@ -1868,7 +1871,7 @@ |
1869 | 1872 | } ); |
1870 | 1873 | return false; // onclick action return false |
1871 | 1874 | }, |
1872 | | - showPlayerselect:function( $target ) { |
| 1875 | + showPlayerselect:function( $target ) { |
1873 | 1876 | // Get id (in case where we have a parent container) |
1874 | 1877 | var this_id = ( this.pc != null ) ? this.pc.pp.id:this.id; |
1875 | 1878 | var _this = this; |
— | — | @@ -1949,9 +1952,9 @@ |
1950 | 1953 | } ); |
1951 | 1954 | |
1952 | 1955 | if ( dl_list != '' ) |
1953 | | - out += gM( 'mwe-download_full' ) + '<blockquote style="background:#000">' + dl_list + '</blockquote>'; |
| 1956 | + out += '<h2>' + gM( 'mwe-download_full' ) + '</h2><ul>' + dl_list + '</ul>'; |
1954 | 1957 | if ( dl_txt_list != '' ) |
1955 | | - out += gM( 'mwe-download_text' ) + '<blockquote style="background:#000">' + dl_txt_list + '</blockquote>'; |
| 1958 | + out += '<h2>' +gM( 'mwe-download_text' ) + '</h2><ul>' + dl_txt_list + '</ul>'; |
1956 | 1959 | out += '</div>'; |
1957 | 1960 | return out; |
1958 | 1961 | } |
— | — | @@ -1967,9 +1970,6 @@ |
1968 | 1971 | $target.html( getShowVideoDownload() ); |
1969 | 1972 | } |
1970 | 1973 | }, |
1971 | | - showCredits:function( $target ) { |
1972 | | - $target.html( '<h2>' + gM( 'mwe-credits' ) + '</h2>' ); |
1973 | | - }, |
1974 | 1974 | /* |
1975 | 1975 | * Base embed controls |
1976 | 1976 | * The Play Action: |
— | — | @@ -2332,10 +2332,11 @@ |
2333 | 2333 | { |
2334 | 2334 | return gM( 'mwe-ogg-player-' + this.id ); |
2335 | 2335 | }, |
2336 | | - load : function( callback ) { |
| 2336 | + load : function( callback ) { |
2337 | 2337 | mvJsLoader.doLoad( [ |
2338 | 2338 | this.library + 'Embed' |
2339 | | - ], function() { |
| 2339 | + ], function() { |
| 2340 | + js_log("wtf: " + typeof( vlcEmbed ) ); |
2340 | 2341 | callback(); |
2341 | 2342 | } ); |
2342 | 2343 | } |
Index: trunk/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html |
— | — | @@ -6,16 +6,16 @@ |
7 | 7 | <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
8 | 8 | </head> |
9 | 9 | <body> |
10 | | -<h3> Simple Video Relational Audio and Video the Commons </h3> |
11 | | -This Example search primitive video in the Wikimedia Commons |
| 10 | +<h3> Related Videos </h3> |
| 11 | + |
12 | 12 | <span id="default_attr"> |
13 | 13 | </span> <br /> |
14 | 14 | <br /> |
15 | 15 | <table border="1" cellpadding="6" width="600"> |
16 | 16 | <tr> |
17 | 17 | <td valign="top"> |
18 | | - <video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video></td> |
19 | | - <td valign="top"><b>Sample Relational Video And Audio</b><br /> |
| 18 | + <video wikiTitleKey="B-36_bomber.ogg" durationHint="2" poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" src="http://upload.wikimedia.org/wikipedia/commons/0/0d/B-36_bomber.ogg"></video></td> |
| 19 | + <td valign="top"><b>Sample Related Videos</b><br /> |
20 | 20 | <pre>The Example Code ::: </pre> |
21 | 21 | <video wikiTitleKey="File:B-36_bomber.ogg" durationHint="2" |
22 | 22 | poster="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/B-36_bomber.ogg/mid-B-36_bomber.ogg.jpg&size=400x300" |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -734,7 +734,7 @@ |
735 | 735 | } |
736 | 736 | }; |
737 | 737 | // Create the "return to form" button |
738 | | - bObj[ gM( 'mwe-return-to-form' ) ] = function() { |
| 738 | + buttons[ gM( 'mwe-return-to-form' ) ] = function() { |
739 | 739 | $j( this ).dialog( 'close' ); |
740 | 740 | _this.form_post_override = false; |
741 | 741 | } |
— | — | @@ -742,7 +742,7 @@ |
743 | 743 | _this.updateProgressWin( |
744 | 744 | gM( 'mwe-uploadwarning' ), |
745 | 745 | '<h3>' + gM( 'mwe-uploadwarning' ) + '</h3>' + wmsg + '<p>', |
746 | | - bObj ); |
| 746 | + buttons ); |
747 | 747 | return false; |
748 | 748 | } |
749 | 749 | // No error! |
— | — | @@ -783,21 +783,21 @@ |
784 | 784 | return false; |
785 | 785 | } |
786 | 786 | |
787 | | - var bObj = {}; |
| 787 | + var buttons = {}; |
788 | 788 | // "Return" button |
789 | | - bObj[ gM( 'mwe-return-to-form' ) ] = function() { |
| 789 | + buttons[ gM( 'mwe-return-to-form' ) ] = function() { |
790 | 790 | $j( this ).dialog( 'close' ); |
791 | 791 | _this.form_post_override = false; |
792 | 792 | } |
793 | 793 | // "Go to resource" button |
794 | | - bObj[ gM('mwe-go-to-resource') ] = function() { |
| 794 | + buttons[ gM('mwe-go-to-resource') ] = function() { |
795 | 795 | window.location = url; |
796 | 796 | }; |
797 | 797 | _this.action_done = true; |
798 | 798 | _this.updateProgressWin( |
799 | 799 | gM( 'mwe-successfulupload' ), |
800 | 800 | gM( 'mwe-upload_done', url), |
801 | | - bObj ); |
| 801 | + buttons ); |
802 | 802 | js_log( 'apiRes.upload.imageinfo::' + url ); |
803 | 803 | return true; |
804 | 804 | } |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js |
— | — | @@ -1,16 +1,26 @@ |
2 | | -// base remote search obj |
3 | | - |
| 2 | +/* |
| 3 | +* Base remote search Object. |
| 4 | +* provies the base class for the other search system to extend. |
| 5 | +*/ |
4 | 6 | loadGM( { |
5 | 7 | "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information." |
6 | 8 | } ) |
7 | | -// @key is name of rObj variable |
8 | | -// @value is where to find the value in the item xml |
9 | | -// |
10 | | -// *format:* |
11 | | -// . indicates multiple tags @ separates the tag from attribute list |
12 | | -// {.}tag_name@{attribute1|attribute12} |
13 | 9 | |
14 | | -// @@todo should probably switch this over to something like Xpath if we end up parsing a lot of rss formats |
| 10 | +/* |
| 11 | +* rsd_default_rss_item_mapping |
| 12 | +* |
| 13 | +* @key is name of rObj variable |
| 14 | +* @value is where to find the value in the item xml |
| 15 | +* |
| 16 | +* *value format:* |
| 17 | +* . indicates multiple tags |
| 18 | +* @ separates the tag from attribute list |
| 19 | +* {.}tag_name@{attribute1|attribute2} |
| 20 | +* |
| 21 | +* Also see mapAttributeToResource function bellow |
| 22 | +* |
| 23 | +* FIXME should switch this over to something like Xpath if we end up parsing a lot of rss formats |
| 24 | +*/ |
15 | 25 | var rsd_default_rss_item_mapping = { |
16 | 26 | 'poster' : 'media:thumbnail@url', |
17 | 27 | 'roe_url' : 'media:roe_embed@url', |
— | — | @@ -31,36 +41,41 @@ |
32 | 42 | |
33 | 43 | completed_req:0, |
34 | 44 | num_req:0, |
35 | | - |
| 45 | + |
| 46 | + // ResultsObj holds the array of results |
36 | 47 | resultsObj: { }, |
37 | 48 | |
38 | | - // default search result values for paging: |
| 49 | + // Default search result values for paging: |
39 | 50 | offset :0, |
40 | 51 | limit : 30, |
41 | 52 | more_results : false, |
42 | 53 | num_results : 0, |
43 | 54 | |
44 | | - // init the object: |
45 | | - init: function( iObj ) { |
| 55 | + /** |
| 56 | + * Initialise the baseRemoteSearch |
| 57 | + */ |
| 58 | + init: function( options ) { |
46 | 59 | js_log( 'mvBaseRemoteSearch:init' ); |
47 | | - for ( var i in iObj ) { |
48 | | - this[i] = iObj[i]; |
| 60 | + for ( var i in options ) { |
| 61 | + this[i] = options[i]; |
49 | 62 | } |
50 | 63 | return this; |
51 | 64 | }, |
52 | 65 | getSearchResults:function() { |
53 | | - // empty out the current results before issuing a request |
| 66 | + // Empty out the current results before issuing a request |
54 | 67 | this.resultsObj = { }; |
55 | | - // do global getSearchResults bindings |
| 68 | + |
| 69 | + // Do global getSearchResults bindings |
56 | 70 | this.last_query = $j( '#rsd_q' ).val(); |
57 | 71 | this.last_offset = this.cp.offset; |
58 | | - // set the loading flag: |
| 72 | + |
| 73 | + // Set the loading flag: |
59 | 74 | this.loading = true; |
60 | 75 | }, |
61 | 76 | /* |
62 | 77 | * Parses and adds video rss based input format |
63 | | - * @param $data XML data to parse |
64 | | - * @param provider_url the source url (used to generate absolute links) |
| 78 | + * @param {XML Nodes} data the data to be parsed |
| 79 | + * @param {String} provider_url the source url (used to generate absolute links) |
65 | 80 | */ |
66 | 81 | addRSSData:function( data , provider_url ) { |
67 | 82 | js_log( 'f:addRSSData' ); |
— | — | @@ -102,7 +117,15 @@ |
103 | 118 | _this.num_results++; |
104 | 119 | } ); |
105 | 120 | }, |
106 | | - mapAttributeToResource: function(rObj, item, attr){ |
| 121 | + /* |
| 122 | + * Maps a given attribute to a resource object per mapping defined in |
| 123 | + * rsd_default_rss_item_mapping |
| 124 | + * |
| 125 | + * @param {Object} rObj the resource object |
| 126 | + * @param {XML Node} the xml result node |
| 127 | + * @param {attr} the name attribute we are maping to the resource object |
| 128 | + */ |
| 129 | + mapAttributeToResource: function( rObj, item, attr ){ |
107 | 130 | var selector = rsd_default_rss_item_mapping[ attr ].split( '@' ); |
108 | 131 | var flag_multiple = ( selector[0].substr( 0, 1 ) == '.' ) ? true : false; |
109 | 132 | if ( flag_multiple ) { |
— | — | @@ -147,6 +170,10 @@ |
148 | 171 | } ); |
149 | 172 | // Nothing to return we update the "rObj" directly |
150 | 173 | }, |
| 174 | + |
| 175 | + /** |
| 176 | + * Get the html representation of the resource Object paramater |
| 177 | + */ |
151 | 178 | getEmbedHTML: function( rObj , options ) { |
152 | 179 | if ( !options ) |
153 | 180 | options = { }; |
— | — | @@ -185,6 +212,9 @@ |
186 | 213 | js_log( "ERROR:: no embed code for mime type: " + rObj.mime ); |
187 | 214 | return 'Error missing embed code for: ' + escape( rObj.mime ); |
188 | 215 | }, |
| 216 | + /** |
| 217 | + * Get the embed html specificaly for an image type resource Object. |
| 218 | + */ |
189 | 219 | getImageEmbedHTML:function( rObj, options ) { |
190 | 220 | // if crop is null do base output: |
191 | 221 | var imgHtml = '<img ' + options.id_attr + ' src="' + rObj.edit_url + '"' + options.style_attr + ' ></img>'; |
— | — | @@ -197,13 +227,22 @@ |
198 | 228 | '</div>' + |
199 | 229 | '</div>'; |
200 | 230 | }, |
201 | | - // by default just return the existing image with callback |
| 231 | + /** |
| 232 | + * Gets an image object from a requested transformation via callback |
| 233 | + * ( letting api search implementations query the remote server for a |
| 234 | + * given transformation ) |
| 235 | + * |
| 236 | + * By default just return the existing image. |
| 237 | + */ |
202 | 238 | getImageObj:function( rObj, size, callback ) { |
203 | 239 | callback( { |
204 | 240 | 'url' : rObj.poster |
205 | 241 | } ); |
206 | 242 | }, |
207 | | - // by default just return the rObj.desc |
| 243 | + /* |
| 244 | + * Gets the inline wikiText description of the resource Object |
| 245 | + * By default just return the rObj description value |
| 246 | + */ |
208 | 247 | getInlineDescWiki:function( rObj ) { |
209 | 248 | // return striped html & trim white space |
210 | 249 | if ( rObj.desc ) |
— | — | @@ -211,11 +250,21 @@ |
212 | 251 | // no desc avaliable: |
213 | 252 | return ''; |
214 | 253 | }, |
215 | | - // default license permission wiki text is cc based template mapping (does not confirm the templates actually exist) |
| 254 | + /** |
| 255 | + * Get the licence wikiText tag for a given resource Object. |
| 256 | + * |
| 257 | + * By default license permission wiki text is cc based template mapping |
| 258 | + * (does not confirm the templates actually exist) |
| 259 | + */ |
216 | 260 | getPermissionWikiTag: function( rObj ) { |
217 | 261 | if ( !rObj.license ) |
218 | 262 | return '';// no license info |
219 | | - // check that its a defined creative commons licnese key: |
| 263 | + |
| 264 | + // First check if we have a special license template tag already set: |
| 265 | + if( rObj.license_template_tag ) |
| 266 | + return '{{' + rObj.license_template_tag + '}}'; |
| 267 | + |
| 268 | + // Check that its a defined creative commons license key: |
220 | 269 | if ( this.rsd.licenses.cc.licenses[ rObj.license.key ] != 'undefined' ) { |
221 | 270 | return '{{Cc-' + rObj.license.key + '}}'; |
222 | 271 | } else if ( rObj.license.lurl ) { |
— | — | @@ -223,23 +272,51 @@ |
224 | 273 | } |
225 | 274 | |
226 | 275 | }, |
| 276 | + /** |
| 277 | + * Gets the resource import description text |
| 278 | + */ |
227 | 279 | getImportResourceDescWiki:function( rObj ) { |
228 | 280 | return gM( 'mwe-imported_from', [rObj.title, this.cp.homepage, gM('rsd-' + this.cp.id + '-title'), rObj.link] ); |
229 | 281 | }, |
230 | | - // for thigns like categories and the like |
| 282 | + /** |
| 283 | + * Get any extra wikitext description for the given resource object. |
| 284 | + * For content outside of the main template description, |
| 285 | + * like categories or additional wikitext notes. |
| 286 | + * |
| 287 | + * By default its an empty string. |
| 288 | + */ |
231 | 289 | getExtraResourceDescWiki:function( rObj ) { |
232 | 290 | return ''; |
233 | 291 | }, |
234 | | - // by default just return the poster (clients can override) |
| 292 | + |
| 293 | + /** |
| 294 | + * Gets a image transformation |
| 295 | + * by default it just return the poster |
| 296 | + */ |
235 | 297 | getImageTransform:function( rObj, opt ) { |
236 | 298 | return rObj.poster; |
237 | 299 | }, |
238 | | - getEmbedObjParsedInfo:function( rObj, eb_id ) { |
| 300 | + |
| 301 | + /** |
| 302 | + * Adds additional resource information post clip embedding. |
| 303 | + */ |
| 304 | + addResourceInfoFromEmbedInstance : function( rObj, eb_id ) { |
239 | 305 | return rObj; |
240 | 306 | }, |
241 | | - getEmbedTimeMeta:function( rObj, callback ) { |
| 307 | + |
| 308 | + /** |
| 309 | + * Adds resource info with a callback function |
| 310 | + * |
| 311 | + * Usefull for grabbing extra info that is not avaliable in the innitial |
| 312 | + * search results api request. |
| 313 | + */ |
| 314 | + addResourceInfoCallback:function( rObj, callback ) { |
242 | 315 | callback(); |
243 | 316 | }, |
| 317 | + |
| 318 | + /** |
| 319 | + * Get the wiki embed code for a given resource object |
| 320 | + */ |
244 | 321 | getEmbedWikiCode:function( rObj ) { |
245 | 322 | var layout = ( rObj.layout ) ? rObj.layout:"right" |
246 | 323 | var o = '[[' + this.rsd.cFileNS + ':' + rObj.target_resource_title + '|thumb|' + layout; |
— | — | @@ -257,11 +334,11 @@ |
258 | 335 | o += ']]'; |
259 | 336 | return o; |
260 | 337 | }, |
| 338 | + /** |
| 339 | + * Updates / normalizes the target_resource_title |
| 340 | + */ |
261 | 341 | updateTargetResourceTitle:function( rObj ) { |
262 | 342 | rObj.target_resource_title = rObj.titleKey.replace( / File: | Image: / , '' ); |
263 | 343 | rObj.target_resource_title = this.cp.resource_prefix + rObj.target_resource_title; |
264 | | - }, |
265 | | - updateDataForImport:function( rObj ) { |
266 | | - return rObj; |
267 | 344 | } |
268 | 345 | } |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/archiveOrgSearch.js |
— | — | @@ -1,17 +1,24 @@ |
2 | | -// archive.org uses solr engine: |
3 | | -// more about solr here: |
4 | | -// http://lucene.apache.org/solr/ |
| 2 | +/* |
| 3 | +* Archive.org Search |
| 4 | +* |
| 5 | +* archive.org uses the solr engine: |
| 6 | +* more about solr here: |
| 7 | +* http://lucene.apache.org/solr/ |
| 8 | +*/ |
5 | 9 | |
6 | 10 | var archiveOrgSearch = function ( iObj ) { |
7 | 11 | return this.init( iObj ); |
8 | 12 | } |
9 | 13 | archiveOrgSearch.prototype = { |
10 | 14 | // Archive.org constants: |
11 | | - dnUrl:'http://www.archive.org/download/', |
12 | | - dtUrl:'http://www.archive.org/details/', |
13 | | - init:function( iObj ) { |
14 | | - // Init base class and inherit: |
15 | | - var baseSearch = new baseRemoteSearch( iObj ); |
| 15 | + downloadUrl : 'http://www.archive.org/download/', |
| 16 | + detailsUrl : 'http://www.archive.org/details/', |
| 17 | + /* |
| 18 | + * Inititalize the archiveOrgSearch class. |
| 19 | + * archiveOrgSearch inherits the baseSearch class |
| 20 | + */ |
| 21 | + init:function( options ) { |
| 22 | + var baseSearch = new baseRemoteSearch( options ); |
16 | 23 | for ( var i in baseSearch ) { |
17 | 24 | if ( typeof this[i] == 'undefined' ) { |
18 | 25 | this[i] = baseSearch[i]; |
— | — | @@ -19,8 +26,10 @@ |
20 | 27 | this['parent_' + i] = baseSearch[i]; |
21 | 28 | } |
22 | 29 | } |
23 | | - // Inherit the cp settings for |
24 | 30 | }, |
| 31 | + /** |
| 32 | + * Gets the search results from the api query |
| 33 | + */ |
25 | 34 | getSearchResults:function() { |
26 | 35 | // call parent: |
27 | 36 | this.parent_getSearchResults(); |
— | — | @@ -49,10 +58,13 @@ |
50 | 59 | } |
51 | 60 | ); |
52 | 61 | }, |
| 62 | + /** |
| 63 | + * Adds the search results to the local resultsObj |
| 64 | + */ |
53 | 65 | addResults:function( data ) { |
54 | 66 | var _this = this; |
55 | 67 | if ( data.response && data.response.docs ) { |
56 | | - // set result info: |
| 68 | + // Set result info: |
57 | 69 | this.num_results = data.response.numFound; |
58 | 70 | |
59 | 71 | for ( var resource_id in data.response.docs ) { |
— | — | @@ -61,17 +73,17 @@ |
62 | 74 | // @@todo we should add .ogv or oga if video or audio: |
63 | 75 | 'titleKey' : resource.identifier + '.ogg', |
64 | 76 | 'resourceKey': resource.identifier, |
65 | | - 'link' : _this.dtUrl + resource.identifier, |
| 77 | + 'link' : _this.detailsUrl + resource.identifier, |
66 | 78 | 'title' : resource.title, |
67 | | - 'poster' : _this.dnUrl + resource.identifier + '/format=thumbnail', |
68 | | - 'poster_ani' : _this.dnUrl + resource.identifier + '/format=Animated+Gif', |
| 79 | + 'poster' : _this.downloadUrl + resource.identifier + '/format=thumbnail', |
| 80 | + 'poster_ani' : _this.downloadUrl + resource.identifier + '/format=Animated+Gif', |
69 | 81 | 'thumbwidth' : 160, |
70 | 82 | 'thumbheight': 110, |
71 | 83 | 'desc' : resource.description, |
72 | | - 'src' : _this.dnUrl + resource.identifier + '/format=Ogg+video', |
73 | | - 'mime' : 'application/ogg', |
74 | | - // set the license: (rsd is a pointer to the parent remoteSearchDriver ) |
75 | | - 'license' : this.rsd.getLicenceFromUrl( resource.licenseurl ), |
| 84 | + 'src' : _this.downloadUrl + resource.identifier + '/format=Ogg+video', |
| 85 | + 'mime' : 'application/ogg', |
| 86 | + // Set the license: (rsd is a pointer to the parent remoteSearchDriver ) |
| 87 | + 'license' : this.rsd.getLicenceFromUrl( resource.licenseurl ), |
76 | 88 | 'pSobj' :_this |
77 | 89 | |
78 | 90 | }; |
— | — | @@ -79,14 +91,14 @@ |
80 | 92 | } |
81 | 93 | } |
82 | 94 | }, |
83 | | - // getTitleKey:function(rObj){ |
84 | | - // return rObj['stream_name'] + '__' + rObj['start_time'].replace(/:/g,'.') + '_to_' + rObj['end_time'].replace(/:/g,'.') + '.ogg';; |
85 | | - // } |
86 | | - getEmbedTimeMeta:function( rObj, callback ) { |
| 95 | + /** |
| 96 | + * Gets some media metadata via a archive.org special entry point "avinfo" |
| 97 | + */ |
| 98 | + addResourceInfoCallback:function( rObj, callback ) { |
87 | 99 | var _this = this; |
88 | 100 | do_api_req( { |
89 | | - 'data': { 'avinfo':1 }, |
90 | | - 'url':_this.dnUrl + rObj.resourceKey + '/format=Ogg+video' |
| 101 | + 'data': { 'avinfo' : 1 }, |
| 102 | + 'url':_this.downloadUrl + rObj.resourceKey + '/format=Ogg+video' |
91 | 103 | }, function( data ) { |
92 | 104 | if ( data['length'] ) |
93 | 105 | rObj.duration = data['length']; |
— | — | @@ -98,6 +110,9 @@ |
99 | 111 | callback(); |
100 | 112 | } ); |
101 | 113 | }, |
| 114 | + /* |
| 115 | + * Returns html to embed a given result Object ( rObj ) |
| 116 | + */ |
102 | 117 | getEmbedHTML: function( rObj , options ) { |
103 | 118 | js_log( 'getEmbedHTML:: ' + rObj.poster ); |
104 | 119 | if ( !options ) |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js |
— | — | @@ -73,6 +73,15 @@ |
74 | 74 | |
75 | 75 | // Default width of metavid clips: |
76 | 76 | rObj['target_width'] = 400; |
| 77 | + |
| 78 | + rObj['author'] = 'US Government'; |
| 79 | + |
| 80 | + // Add in the date as UTC "toDateString" : |
| 81 | + var d = _this.getDateFromLink( rObj.link ); |
| 82 | + rObj['date'] = d.toDateString(); |
| 83 | + |
| 84 | + // Set the license_template_tag ( all metavid content is PD-USGov ) |
| 85 | + rObj['license_template_tag'] = 'PD-USGov'; |
77 | 86 | } |
78 | 87 | // done loading: |
79 | 88 | _this.loading = 0; |
— | — | @@ -89,10 +98,6 @@ |
90 | 99 | sn = sn.charAt( 0 ).toUpperCase() + sn.substr( 1 ); |
91 | 100 | return gM( 'mwe-stream_title', [ sn, rObj.start_time, rObj.end_time ] ); |
92 | 101 | }, |
93 | | - // metavid descption tied to public domain license key (government produced content) |
94 | | - getPermissionWikiTag:function( rObj ) { |
95 | | - return '{{PD-USGov}}'; |
96 | | - }, |
97 | 102 | getExtraResourceDescWiki:function( rObj ) { |
98 | 103 | var o = "\n"; |
99 | 104 | // check for person |
— | — | @@ -180,8 +185,8 @@ |
181 | 186 | return getURLParamReplace( rObj.poster, { 'size' : 'full' } ) |
182 | 187 | } |
183 | 188 | }, |
184 | | - getEmbedObjParsedInfo:function( rObj, eb_id ) { |
185 | | - var sources = $j( '#' + eb_id ).get( 0 ).media_element.getSources(); |
| 189 | + addResourceInfoFromEmbedInstance : function( rObj, embed_id ) { |
| 190 | + var sources = $j( '#' + embed_id ).get( 0 ).media_element.getSources(); |
186 | 191 | rObj.other_versions = '*[' + rObj['roe_url'] + ' XML of all Video Formats and Timed Text]' + "\n"; |
187 | 192 | for ( var i in sources ) { |
188 | 193 | var cur_source = sources[i]; |
— | — | @@ -192,18 +197,6 @@ |
193 | 198 | // js_log('set url to: ' + rObj['url']); |
194 | 199 | return rObj; |
195 | 200 | }, |
196 | | - // update rObj for import: |
197 | | - updateDataForImport:function( rObj ) { |
198 | | - rObj['author'] = 'US Government'; |
199 | | - // convert data to UTC type date: |
200 | | - var d = this.getDateFromLink( rObj.link ); |
201 | | - rObj['date'] = d.toDateString(); |
202 | | - rObj['license_template_tag'] = 'PD-USGov'; |
203 | | - // update based on new start time: |
204 | | - js_log( 'url is: ' + rObj.src + ' ns: ' + rObj.start_time + ' ne:' + rObj.end_time ); |
205 | | - |
206 | | - return rObj; |
207 | | - }, |
208 | 201 | getDateFromLink:function( link ) { |
209 | 202 | var dateExp = new RegExp( /_([0-9]+)\-([0-9]+)\-([0-9]+)/ ); |
210 | 203 | var dParts = link.match ( dateExp ); |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js |
— | — | @@ -110,15 +110,15 @@ |
111 | 111 | } ); |
112 | 112 | }, |
113 | 113 | getSearchResults:function() { |
114 | | - // call parent: |
| 114 | + // Call parent: |
115 | 115 | this.parent_getSearchResults(); |
116 | | - // set local ref: |
| 116 | + // Set local ref: |
117 | 117 | var _this = this; |
118 | 118 | |
119 | 119 | js_log( 'f:getSearchResults for:' + $j( '#rsd_q' ).val() ); |
120 | | - // do two queries against the Image / File / MVD namespace: |
| 120 | + // Do two queries against the Image / File / MVD namespace: |
121 | 121 | |
122 | | - // build the image request object: |
| 122 | + // Build the image request object: |
123 | 123 | var reqObj = { |
124 | 124 | 'action':'query', |
125 | 125 | 'generator':'search', |
— | — | @@ -132,11 +132,11 @@ |
133 | 133 | 'iiurlwidth': parseInt( this.rsd.thumb_width ), |
134 | 134 | 'rvprop':'content' |
135 | 135 | }; |
136 | | - // set up the number of request: |
| 136 | + // Set up the number of request: |
137 | 137 | this.completed_req = 0; |
138 | 138 | this.num_req = 1; |
139 | | - // setup the number of requests result flag: |
140 | | - // also do a request for page titles (would be nice if api could query both at the same time) |
| 139 | + // Setup the number of requests result flag: |
| 140 | + // Also do a request for page titles (would be nice if api could query both at the same time) |
141 | 141 | reqObj['gsrwhat'] = 'text'; |
142 | 142 | do_api_req( { |
143 | 143 | 'data':reqObj, |
— | — | @@ -161,24 +161,24 @@ |
162 | 162 | if ( typeof data['query-continue'].search != 'undefined' ) |
163 | 163 | this.more_results = true; |
164 | 164 | } |
165 | | - // make sure we have pages to idorate: |
| 165 | + // Make sure we have pages to idorate: |
166 | 166 | if ( data.query && data.query.pages ) { |
167 | 167 | for ( var page_id in data.query.pages ) { |
168 | 168 | var page = data.query.pages[ page_id ]; |
169 | 169 | |
170 | | - // make sure the reop is shared (don't show for now it confusing things) |
| 170 | + // Make sure the reop is shared (don't show for now it confusing things) |
171 | 171 | // @@todo support remote repository better |
172 | 172 | if ( page.imagerepository == 'shared' ) { |
173 | 173 | continue; |
174 | 174 | } |
175 | 175 | |
176 | | - // make sure the page is not a redirect |
| 176 | + // Make sure the page is not a redirect |
177 | 177 | if ( page.revisions && page.revisions[0] && |
178 | 178 | page.revisions[0]['*'] && page.revisions[0]['*'].indexOf( '#REDIRECT' ) === 0 ) { |
179 | 179 | // skip page is redirect |
180 | 180 | continue; |
181 | 181 | } |
182 | | - // skip if its an empty or missing imageinfo: |
| 182 | + // Skip if its an empty or missing imageinfo: |
183 | 183 | if ( !page.imageinfo ) |
184 | 184 | continue; |
185 | 185 | var rObj = { |
— | — | @@ -204,10 +204,11 @@ |
205 | 205 | //to use once we get the wiki-text parser in shape |
206 | 206 | var pObj = mw.parser.pNew( rObj.desc ); |
207 | 207 | //structured data on commons is based on the "information" template: |
208 | | - var tmplInfo = pObj.templates( 'information' ); |
| 208 | + var tmplInfo = pObj.templates( 'information' ); |
| 209 | + rObj.desc = tmplInfo.description |
209 | 210 | */ |
210 | 211 | |
211 | | - // attempt to parse out the description current user desc from the commons template: |
| 212 | + // Attempt to parse out the description current user desc from the commons template: |
212 | 213 | // @@todo these could be combined to a single regEx |
213 | 214 | // or better improve the wiki-text parsing and use above |
214 | 215 | var desc = rObj.desc.match( /\|\s*description\s*=\s*(([^\n]*\n)*)\|\s*source=/i ); |
— | — | @@ -231,15 +232,15 @@ |
232 | 233 | } |
233 | 234 | } |
234 | 235 | |
235 | | - // likely a audio clip if no poster and type application/ogg |
| 236 | + // Likely a audio clip if no poster and type application/ogg |
236 | 237 | // @@todo we should return audio/ogg for the mime type or some other way to specify its "audio" |
237 | 238 | if ( ! rObj.poster && rObj.mime == 'application/ogg' ) { |
238 | 239 | rObj.mime = 'audio/ogg'; |
239 | 240 | } |
240 | | - // add to the resultObj |
| 241 | + // Add to the resultObj |
241 | 242 | this.resultsObj[page_id] = rObj; |
242 | 243 | |
243 | | - // if returnFirst flag: |
| 244 | + // If returnFirst flag: |
244 | 245 | if ( returnFirst ) |
245 | 246 | return this.resultsObj[page_id]; |
246 | 247 | |
— | — | @@ -253,9 +254,9 @@ |
254 | 255 | js_log( 'no results:' + data ); |
255 | 256 | } |
256 | 257 | }, |
257 | | - // check request done used for when we have multiple requests to check before formating results. |
| 258 | + // Check request done used for when we have multiple requests to check before formating results. |
258 | 259 | checkRequestDone:function() { |
259 | | - // display output if done: |
| 260 | + // Display output if done: |
260 | 261 | this.completed_req++; |
261 | 262 | if ( this.completed_req == this.num_req ) { |
262 | 263 | this.loading = 0; |
— | — | @@ -265,7 +266,7 @@ |
266 | 267 | if ( rObj.mime == 'application/ogg' ) |
267 | 268 | return callback( { 'url':rObj.src, 'poster' : rObj.url } ); |
268 | 269 | |
269 | | - // his could be depreciated if thumb.php improves |
| 270 | + // This could be depreciated if thumb.php support is standard |
270 | 271 | var reqObj = { |
271 | 272 | 'action':'query', |
272 | 273 | 'format':'json', |
— | — | @@ -273,7 +274,7 @@ |
274 | 275 | 'prop':'imageinfo', |
275 | 276 | 'iiprop':'url|size|mime' |
276 | 277 | } |
277 | | - // set the width: |
| 278 | + // Set the width: |
278 | 279 | if ( size.width ) |
279 | 280 | reqObj['iiurlwidth'] = size.width; |
280 | 281 | js_log( 'going to do req: ' + this.cp.api_url + ' ' + reqObj ); |
— | — | @@ -310,10 +311,10 @@ |
311 | 312 | getInlineDescWiki:function( rObj ) { |
312 | 313 | var desc = this.parent_getInlineDescWiki( rObj ); |
313 | 314 | |
314 | | - // strip categories for inline Desc: (should strip license tags too but not as easy) |
| 315 | + // Strip categories for inline Desc: (should strip license tags too but not as easy) |
315 | 316 | desc = desc.replace( /\[\[Category\:[^\]]*\]\]/gi, '' ); |
316 | 317 | |
317 | | - // just grab the description tag for inline desc: |
| 318 | + // Just grab the description tag for inline desc: |
318 | 319 | var descMatch = new RegExp( /Description=(\{\{en\|)?([^|]*|)/ ); |
319 | 320 | var dparts = desc.match( descMatch ); |
320 | 321 | |
— | — | @@ -333,14 +334,14 @@ |
334 | 335 | js_log( 'Error: No Description Tag, Using::' + desc ); |
335 | 336 | return desc; |
336 | 337 | }, |
337 | | - // returns the inline wikitext for insertion (template based crops for now) |
| 338 | + // Returns the inline wikitext for insertion (template based crops for now) |
338 | 339 | getEmbedWikiCode: function( rObj ) { |
339 | | - // set default layout to right justified |
| 340 | + // Set default layout to right justified |
340 | 341 | var layout = ( rObj.layout ) ? rObj.layout:"right" |
341 | 342 | // if crop is null do base output: |
342 | 343 | if ( rObj.crop == null ) |
343 | 344 | return this.parent_getEmbedWikiCode( rObj ); |
344 | | - // using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop |
| 345 | + // Using the preview crop template: http://en.wikipedia.org/wiki/Template:Preview_Crop |
345 | 346 | // @@todo should be replaced with server side cropping |
346 | 347 | return '{{Preview Crop ' + "\n" + |
347 | 348 | '|Image = ' + rObj.target_resource_title + "\n" + |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -282,13 +282,15 @@ |
283 | 283 | return; |
284 | 284 | } |
285 | 285 | |
286 | | - // Otherwise show the "install Firefogg" message |
287 | | - // FIXME: getFirefoggInstallUrl() may return false, this is not handled |
| 286 | + // Otherwise show the "install Firefogg" message |
288 | 287 | var upMsg = ( _this.form_type == 'upload' ) ? gM( 'fogg-for_improved_uploads' ) : ''; |
289 | | - $j( _this.target_please_install ) |
290 | | - .html( upMsg + gM( 'fogg-please_install', _this.getFirefoggInstallUrl() ) ) |
291 | | - .css( 'padding', '10px' ) |
292 | | - .show(); |
| 288 | + var firefoggUrl = _this.getFirefoggInstallUrl(); |
| 289 | + if( firefoggUrl ){ |
| 290 | + $j( _this.target_please_install ) |
| 291 | + .html( upMsg + gM( 'fogg-please_install', firefoggUrl ) ) |
| 292 | + .css( 'padding', '10px' ) |
| 293 | + .show(); |
| 294 | + } |
293 | 295 | } |
294 | 296 | |
295 | 297 | // Set up the click handler for the "save local file" button |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -1271,7 +1271,7 @@ |
1272 | 1272 | js_log( 'media type:: ' + mediaType ); |
1273 | 1273 | // Get any additional embedding helper meta data prior to doing the actual embed |
1274 | 1274 | // normally this meta should be provided in the search result (but archive.org has another query for more media meta) |
1275 | | - rObj.pSobj.getEmbedTimeMeta( rObj, function() { |
| 1275 | + rObj.pSobj.addResourceInfoCallback( rObj, function() { |
1276 | 1276 | // Make sure we have the embedVideo libs: |
1277 | 1277 | var runFlag = false; |
1278 | 1278 | mvJsLoader.embedVideoCheck( function() { |
— | — | @@ -1292,13 +1292,14 @@ |
1293 | 1293 | js_log( "about to call rewrite_by_id::embed_vid" ); |
1294 | 1294 | // Rewrite by id |
1295 | 1295 | rewrite_by_id( 'embed_vid', function() { |
1296 | | - // Grab any information that we got from the ROE xml or parsed from the media file |
1297 | | - rObj.pSobj.getEmbedObjParsedInfo( rObj, 'embed_vid' ); |
| 1296 | + // Grab information avaliable from the embed instance |
| 1297 | + rObj.pSobj.addResourceInfoFromEmbedInstance( rObj, 'embed_vid' ); |
| 1298 | + |
1298 | 1299 | // Add the re-sizable to the doLoad request: |
1299 | 1300 | clibs.push( '$j.ui.resizable' ); |
1300 | | - clibs.push( '$j.fn.hoverIntent' ); |
| 1301 | + clibs.push( '$j.fn.hoverIntent' ); |
1301 | 1302 | mvJsLoader.doLoad( clibs, function() { |
1302 | | - // Make sure the rsd_edit_img is hidden: |
| 1303 | + // Make sure the rsd_edit_img is removed: |
1303 | 1304 | $j( '#rsd_edit_img' ).remove(); |
1304 | 1305 | // Run the image clip tools |
1305 | 1306 | _this.cEdit = new mvClipEdit( mvClipInit ); |
— | — | @@ -1390,9 +1391,7 @@ |
1391 | 1392 | }, |
1392 | 1393 | doImportInterface : function( rObj, callback ) { |
1393 | 1394 | var _this = this; |
1394 | | - js_log( "doImportInterface:: update:" + _this.cFileNS + ':' + rObj.target_resource_title ); |
1395 | | - // update the rObj with import info |
1396 | | - rObj.pSobj.updateDataForImport( rObj ); |
| 1395 | + js_log( "doImportInterface:: update:" + _this.cFileNS + ':' + rObj.target_resource_title ); |
1397 | 1396 | |
1398 | 1397 | // setup the resource description from resource description: |
1399 | 1398 | var wt = '{{Information ' + "\n"; |
Index: trunk/phase3/js2/mwEmbed/libSequencer/mvPlayList.js |
— | — | @@ -259,11 +259,11 @@ |
260 | 260 | this.doWhenClipLoadDone(); |
261 | 261 | } else { |
262 | 262 | js_log( "only " + _this.clip_ready_count + " clips done, scheduling callback:" ); |
263 | | - var doParseDoneCheck = function() { |
264 | | - _this.doWhenParseDone(); |
265 | | - } |
266 | 263 | if ( !mvJsLoader.load_error ) // re-issue request if no load error: |
267 | | - setTimeout( doParseDoneCheck, 100 ); |
| 264 | + setTimeout( function(){ |
| 265 | + _this.doWhenParseDone(); |
| 266 | + //debugger; |
| 267 | + }, 100 ); |
268 | 268 | } |
269 | 269 | }, |
270 | 270 | doWhenClipLoadDone:function() { |
Index: trunk/phase3/js2/mwEmbed/libSequencer/mvFirefoggRender.js |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | /* |
3 | 3 | * Handles driving the firefogg render system |
4 | 4 | */ |
5 | | -var mvFirefoggRender = function( iObj ) { |
6 | | - return this.init( iObj ); |
| 5 | +var mvFirefoggRender = function( options ) { |
| 6 | + return this.init( options ); |
7 | 7 | }; |
8 | 8 | var default_render_options = { |
9 | 9 | "videoQuality" : 10, |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | // default empty render options: |
20 | 20 | renderOptions: { }, |
21 | 21 | continue_rendering:false, |
22 | | - init:function( iObj ) { |
| 22 | + init:function( options ) { |
23 | 23 | var _this = this; |
24 | 24 | |
25 | 25 | // grab the mvFirefogg object to do basic tests |
— | — | @@ -38,12 +38,12 @@ |
39 | 39 | this.fogg = this.myFogg.fogg; |
40 | 40 | |
41 | 41 | // setup player instance |
42 | | - this.player = $j( iObj.player_target ).get( 0 ); |
43 | | - this.player_target = iObj.player_target; |
| 42 | + this.player = $j( options.player_target ).get( 0 ); |
| 43 | + this.player_target = options.player_target; |
44 | 44 | |
45 | 45 | // Extend the render options with any provided details |
46 | | - if( iObj['render_options'] ) |
47 | | - $j.extend(this.renderOptions, iObj['render_options']); |
| 46 | + if( options['render_options'] ) |
| 47 | + $j.extend(this.renderOptions, options['render_options']); |
48 | 48 | |
49 | 49 | // If no height width provided use target DOM width/height |
50 | 50 | if( !this.renderOptions.width && !this.renderOptions.height ){ |
— | — | @@ -54,28 +54,28 @@ |
55 | 55 | |
56 | 56 | // Setup the application options (with defaults) |
57 | 57 | for ( var i in default_FirefoggRender_options ) { |
58 | | - if ( iObj[ i ] ) { |
59 | | - this[ i ] = iObj[ i ]; |
| 58 | + if ( options[ i ] ) { |
| 59 | + this[ i ] = options[ i ]; |
60 | 60 | } else { |
61 | 61 | this[ i ] = default_FirefoggRender_options[i]; |
62 | 62 | } |
63 | 63 | } |
64 | | - // Should be exteranlly controlled |
65 | | - if ( iObj.target_startRender ) { |
66 | | - $j( iObj.target_startRender ).click( function() { |
| 64 | + // Should be externally controlled |
| 65 | + if ( options.target_startRender ) { |
| 66 | + $j( options.target_startRender ).click( function() { |
67 | 67 | js_log( "Start render" ); |
68 | 68 | _this.startRender(); |
69 | 69 | } ) |
70 | | - this.target_startRender = iObj.target_startRender; |
| 70 | + this.target_startRender = options.target_startRender; |
71 | 71 | } |
72 | | - if ( iObj.target_stopRender ) { |
73 | | - $j( iObj.target_stopRender ).click( function() { |
| 72 | + if ( options.target_stopRender ) { |
| 73 | + $j( options.target_stopRender ).click( function() { |
74 | 74 | _this.stopRender(); |
75 | 75 | } ) |
76 | | - this.target_stopRender = iObj.target_stopRender; |
| 76 | + this.target_stopRender = options.target_stopRender; |
77 | 77 | } |
78 | | - if ( iObj.target_timeStatus ) { |
79 | | - this.target_timeStatus = iObj.target_timeStatus; |
| 78 | + if ( options.target_timeStatus ) { |
| 79 | + this.target_timeStatus = options.target_timeStatus; |
80 | 80 | } |
81 | 81 | }, |
82 | 82 | startRender:function() { |
Index: trunk/phase3/js2/mwEmbed/libSequencer/mvSequencer.js |
— | — | @@ -76,53 +76,61 @@ |
77 | 77 | plObj_id:'seq_pl', |
78 | 78 | plObj:'null', |
79 | 79 | |
80 | | - timeline_scale:.06, // in pixel to second ratio ie 100pixles for every ~30seconds |
81 | | - timeline_duration:500, // default timeline length in seconds |
| 80 | + // In pixel to second ratio ie 100pixles for every ~30seconds |
| 81 | + timeline_scale:.06, |
| 82 | + |
| 83 | + // Default timeline duration in seconds |
| 84 | + timeline_duration:500, |
| 85 | + |
82 | 86 | playline_time:0, |
83 | 87 | track_thumb_height:60, |
84 | 88 | track_text_height:20, |
85 | 89 | |
86 | | - // default timeline mode: "story" (i-movie like) or "time" (finalCut like) |
| 90 | + // Default timeline mode: "story" (i-movie like) or "time" (finalCut like) |
87 | 91 | timeline_mode:'storyboard', |
88 | 92 | |
89 | | - track_clipThumb_height:80, // how large are the i-movie type clips |
| 93 | + // How large are the i-movie type clips |
| 94 | + track_clipThumb_height:80, |
90 | 95 | |
91 | | - base_adj_duration:.5, // default time to subtract or add when adjusting clips. |
| 96 | + // Default time to subtract or add when adjusting clips. |
| 97 | + base_adj_duration:.5, |
92 | 98 | |
93 | | - // default clipboard is empty: |
| 99 | + // Default clipboard is empty: |
94 | 100 | clipboard:new Array(), |
95 | | - // stores the clipboard edit token (if user has rights to edit their User page) |
| 101 | + |
| 102 | + // Stores the clipboard edit token (if user has rights to edit their User page) |
96 | 103 | clipboardEditToken:null, |
97 | | - // stores the sequence edit token (if user has rights to edit the current sequence) |
| 104 | + |
| 105 | + // Stores the sequence edit token (if user has rights to edit the current sequence) |
98 | 106 | sequenceEditToken:null, |
99 | | - // the time the sequence was last touched (grabbed at time of startup) |
| 107 | + |
| 108 | + // The time the sequence was last touched (grabbed at time of startup) |
100 | 109 | sequenceTouchedTime:null, |
101 | 110 | |
102 | 111 | // the default config for the add media wizard |
103 | 112 | amw_conf: { }, |
104 | 113 | |
105 | | - |
106 | | - // Msg are all the language specific values ... |
107 | | - // (@@todo overwrite by msg values preloaded in the page) |
108 | | - // tack/clips can be pushed via json or inline playlist format |
109 | | - inline_playlist:'null', // text value so its a valid property |
| 114 | + |
| 115 | + inline_playlist:'null', |
110 | 116 | inline_playlist_id:'null', |
111 | 117 | mv_pl_src:'null', |
112 | | - // the edit stack: |
| 118 | + |
| 119 | + // The edit stack (so that you can "undo" edits) |
113 | 120 | edit_stack:new Array(), |
114 | 121 | disp_menu_item:null, |
115 | | - // trackObj used to payload playlist Track Object (when inline not present) |
| 122 | + |
| 123 | + // Track Object |
116 | 124 | tracks: { } |
117 | 125 | } |
118 | 126 | var mvSequencer = function( iObj ) { |
119 | 127 | return this.init( iObj ); |
120 | 128 | }; |
121 | | -// set up the mvSequencer object |
| 129 | +// Set up the mvSequencer object |
122 | 130 | mvSequencer.prototype = { |
123 | | - // the menu_items Object contains: default html, js setup/loader functions |
| 131 | + // The menu_items Object contains: default html, js setup/loader functions |
124 | 132 | menu_items : { |
125 | 133 | 'clipedit': { |
126 | | - 'd':0, |
| 134 | + 'default':0, |
127 | 135 | 'html':'', |
128 | 136 | 'js': function( this_seq ) { |
129 | 137 | this_seq.doEditSelectedClip(); |
— | — | @@ -132,21 +140,21 @@ |
133 | 141 | } |
134 | 142 | }, |
135 | 143 | 'transition': { |
136 | | - 'd':0, |
| 144 | + 'default':0, |
137 | 145 | 'html' : '<h3>' + gM( 'mwe-menu_transition' ) + '</h3>', |
138 | 146 | 'js':function( this_seq ) { |
139 | 147 | this_seq.doEditTransitionSelectedClip(); |
140 | 148 | }, |
141 | 149 | 'click_js':function( this_seq ) { |
142 | | - // highlight the transition of the selected clip: |
| 150 | + // Highlight the transition of the selected clip: |
143 | 151 | this_seq.doEditTransitionSelectedClip(); |
144 | 152 | } |
145 | 153 | }, |
146 | 154 | 'cliplib': { |
147 | | - 'd':0, |
| 155 | + 'default':0, |
148 | 156 | 'html': gM( 'mwe-loading_txt' ), |
149 | 157 | 'js':function( this_seq ) { |
150 | | - // load the search interface with sequence tool targets |
| 158 | + // Load the search interface with sequence tool targets |
151 | 159 | mvJsLoader.doLoad( [ |
152 | 160 | 'remoteSearchDriver', |
153 | 161 | 'seqRemoteSearchDriver' |
— | — | @@ -157,7 +165,7 @@ |
158 | 166 | } |
159 | 167 | }, |
160 | 168 | 'options': { |
161 | | - 'd':0, |
| 169 | + 'default':0, |
162 | 170 | 'html' : '<h3>' + gM( 'mwe-menu_options' ) + '</h3>' + |
163 | 171 | gM( 'mwe-editor_mode' ) + '<br> ' + |
164 | 172 | '<blockquote><input type="radio" value="simple_editor" name="opt_editor">' + |
— | — | @@ -351,7 +359,7 @@ |
352 | 360 | if ( !dispCall ) |
353 | 361 | $j( "#seq_menu" ).tabs( 'select', this.menu_items[item].inx ); |
354 | 362 | |
355 | | - this.menu_items[item].d = 1; |
| 363 | + this.menu_items[item].default = 1; |
356 | 364 | // do any click_js actions:getInsertControl |
357 | 365 | if ( this.menu_items[item].click_js ) |
358 | 366 | this.menu_items[item].click_js( this ); |
— | — | @@ -541,7 +549,7 @@ |
542 | 550 | } |
543 | 551 | |
544 | 552 | |
545 | | - // render the menu tabs:: |
| 553 | + // Render the menu tabs:: |
546 | 554 | var item_containers = ''; |
547 | 555 | var inx = 0; |
548 | 556 | var selected_tab = 0; |
— | — | @@ -551,14 +559,14 @@ |
552 | 560 | for ( var tab_id in this.menu_items ) { |
553 | 561 | menu_item = this.menu_items[tab_id]; |
554 | 562 | menu_item.inx = inx; |
555 | | - if ( menu_item.d ) { |
| 563 | + if ( menu_item.default ) { |
556 | 564 | selected_tab = inx; |
557 | 565 | _this.disp_menu_item = tab_id; |
558 | 566 | } |
559 | 567 | |
560 | 568 | o += '<li>' + |
561 | | - '<a id="mv_menu_item_' + tab_id + '" href="#' + tab_id + '_ic">' + gM( 'mwe-menu_' + tab_id ) + '</a>' + |
562 | | - '</li>'; |
| 569 | + '<a id="mv_menu_item_' + tab_id + '" href="#' + tab_id + '_ic">' + gM( 'mwe-menu_' + tab_id ) + '</a>' + |
| 570 | + '</li>'; |
563 | 571 | |
564 | 572 | tabc += '<div id="' + tab_id + '_ic" style="overflow:auto;height:268px;" >'; |
565 | 573 | tabc += ( menu_item.html ) ? menu_item.html : '<h3>' + gM( 'mwe-menu_' + tab_id ) + '</h3>'; |
— | — | @@ -575,20 +583,20 @@ |
576 | 584 | select: function( event, ui ) { |
577 | 585 | _this.disp( $j( ui.tab ).attr( 'id' ).replace( 'mv_menu_item_', '' ), true ); |
578 | 586 | } |
579 | | - // add sorting |
| 587 | + // Add sorting |
580 | 588 | } ).find( ".ui-tabs-nav" ).sortable( { axis : 'x' } ); |
581 | 589 | |
582 | 590 | |
583 | | - // render the timeline |
| 591 | + // Render the timeline |
584 | 592 | this.renderTimeLine(); |
585 | 593 | this.do_refresh_timeline(); |
586 | 594 | |
587 | | - // load init content into containers |
| 595 | + // Load initial content into containers |
588 | 596 | this.setupMenuItems(); |
589 | 597 | |
590 | 598 | this.doFocusBindings(); |
591 | 599 | |
592 | | - // set up key bidnings |
| 600 | + // Set up key bidnings |
593 | 601 | $j( window ).keydown( function( e ) { |
594 | 602 | js_log( 'pushed down on:' + e.which ); |
595 | 603 | if ( e.which == 16 ) |
— | — | @@ -603,32 +611,33 @@ |
604 | 612 | if ( ( e.which == 88 && _this.key_ctrl_down ) && !_this.inputFocus ) |
605 | 613 | _this.cutSelectedClips(); |
606 | 614 | |
607 | | - // paste cips on v + ctrl while not focused on a text area: |
| 615 | + // Paste cips on v + ctrl while not focused on a text area: |
608 | 616 | if ( ( e.which == 86 && _this.key_ctrl_down ) && !_this.inputFocus ) |
609 | 617 | _this.pasteClipBoardClips(); |
610 | 618 | |
611 | 619 | } ); |
612 | 620 | $j( window ).keyup( function( e ) { |
613 | 621 | js_log( 'key up on ' + e.which ); |
614 | | - // user let go of "shift" turn off multi-select |
| 622 | + // User let go of "shift" turn off multi-select |
615 | 623 | if ( e.which == 16 ) |
616 | 624 | _this.key_shift_down = false; |
617 | 625 | |
618 | 626 | if ( e.which == 17 ) |
619 | 627 | _this.key_ctrl_down = false; |
620 | 628 | |
621 | | - // escape key (for now deselect) |
| 629 | + // Escape key ( deselect ) |
622 | 630 | if ( e.which == 27 ) |
623 | 631 | _this.deselectClip(); |
624 | 632 | |
625 | 633 | |
626 | | - // backspace or delete key while not focused on a text area: |
| 634 | + // Backspace or Delete key while not focused on a text area: |
627 | 635 | if ( ( e.which == 8 || e.which == 46 ) && !_this.inputFocus ) |
628 | 636 | _this.removeSelectedClips(); |
629 | 637 | } ); |
630 | 638 | }, |
631 | | - // check all nodes for focus |
632 | | - // @@todo it would probably be faster to search a given subnode instead of all text |
| 639 | + /** |
| 640 | + * Check all text nodes for focus |
| 641 | + */ |
633 | 642 | doFocusBindings:function() { |
634 | 643 | var _this = this; |
635 | 644 | // if an input or text area has focus disable delete key binding |
— | — | @@ -641,22 +650,34 @@ |
642 | 651 | _this.inputFocus = false; |
643 | 652 | } ) |
644 | 653 | }, |
| 654 | + /* |
| 655 | + * Update the timeline hook |
| 656 | + */ |
645 | 657 | update_tl_hook:function( jh_time_ms ) { |
646 | | - // put into seconds scale: |
| 658 | + // Put into seconds scale: |
647 | 659 | var jh_time_sec_float = jh_time_ms / 1000; |
648 | | - // render playline at given time |
649 | | - // js_log('tl scale: '+this.timeline_scale); |
650 | | - $j( '#' + this.timeline_id + '_playline' ).css( 'left', Math.round( jh_time_sec_float / this.timeline_scale ) + 'px' ); |
| 660 | + // Render playline at given time |
| 661 | + $j( '#' + this.timeline_id + '_playline' ) |
| 662 | + .css( |
| 663 | + 'left', |
| 664 | + Math.round( jh_time_sec_float / this.timeline_scale ) + 'px' |
| 665 | + ); |
651 | 666 | // js_log('at time:'+ jh_time_sec + ' px:'+ Math.round(jh_time_sec_float/this.timeline_scale)); |
652 | 667 | }, |
653 | | - /*returns a xml or json representation of the current sequence */ |
| 668 | + /* |
| 669 | + * Returns a xml or json representation of the current sequence |
| 670 | + */ |
654 | 671 | getSeqOutputJSON:function() { |
655 | 672 | js_log( 'json output:' ); |
656 | 673 | }, |
| 674 | + /* |
| 675 | + * Gets the Sequence as a formated high level resource description xml string |
| 676 | + * @returns {xml} |
| 677 | + */ |
657 | 678 | getSeqOutputHLRDXML:function() { |
658 | 679 | var o = '<sequence_hlrd>' + "\n"; |
659 | 680 | o += "\t<head>\n"; |
660 | | - // get transitions |
| 681 | + // Get transitions |
661 | 682 | for ( var i in this.plObj.transitions ) { |
662 | 683 | if ( this.plObj.transitions[i] ) { |
663 | 684 | var tObj = this.plObj.transitions[i].getAttributeObj(); |
— | — | @@ -669,9 +690,9 @@ |
670 | 691 | } |
671 | 692 | o += "\t</head>\n"; |
672 | 693 | |
673 | | - // get clips |
| 694 | + // Get clips |
674 | 695 | o += "\t<body>\n"; |
675 | | - // output each track: |
| 696 | + // Output each track: |
676 | 697 | for ( var i in this.plObj.tracks ) { |
677 | 698 | var curTrack = this.plObj.tracks[i]; |
678 | 699 | o += "\t<seq"; |
— | — | @@ -700,15 +721,39 @@ |
701 | 722 | o += "\n</seq>\n"; |
702 | 723 | } |
703 | 724 | o += "\t</body>\n"; |
704 | | - // close the tag |
| 725 | + // Close the tag |
705 | 726 | o += '</sequence_hlrd>'; |
706 | 727 | |
707 | 728 | return o; |
708 | 729 | }, |
| 730 | + /** |
| 731 | + * Takes a track index and a clip index, to get a clip Object. |
| 732 | + * It then calls doEditClip with that clip Object. |
| 733 | + */ |
709 | 734 | editClip:function( track_inx, clip_inx ) { |
710 | 735 | var cObj = this.plObj.tracks[ track_inx ].clips[ clip_inx ]; |
711 | 736 | this.doEditClip( cObj ); |
712 | 737 | }, |
| 738 | + /** |
| 739 | + * Calls the doEditClip interface on the selected clip |
| 740 | + * Handles cases where no clips are selected or multiple clips are selected. |
| 741 | + */ |
| 742 | + doEditSelectedClip:function() { |
| 743 | + js_log( "f:doEditSelectedClip:" ); |
| 744 | + // And only one clip selected |
| 745 | + if ( $j( '.mv_selected_clip' ).length == 1 ) { |
| 746 | + this.doEditClip( this.getClipFromSeqID( $j( '.mv_selected_clip' ).parent().attr( 'id' ) ) ); |
| 747 | + } else if ( $j( '.mv_selected_clip' ).length === 0 ) { |
| 748 | + // No clip selected warning: |
| 749 | + $j( '#clipedit_ic' ).html( gM( 'mwe-no_selected_resource' ) ); |
| 750 | + } else { |
| 751 | + // Multiple clip selected warning: |
| 752 | + $j( '#clipedit_ic' ).html( gM( 'mwe-error_edit_multiple' ) ); |
| 753 | + } |
| 754 | + }, |
| 755 | + /** |
| 756 | + * Pulls up the edit transition interface for the selected clip |
| 757 | + */ |
713 | 758 | doEditTransitionSelectedClip:function() { |
714 | 759 | var _this = this; |
715 | 760 | js_log( "f:doEditTransitionSelectedClip:" + $j( '.mv_selected_clip' ).length ); |
— | — | @@ -722,28 +767,21 @@ |
723 | 768 | $j( '#transition_ic' ).html( gM( 'mwe-error_edit_multiple' ) ); |
724 | 769 | } |
725 | 770 | }, |
726 | | - doEditSelectedClip:function() { |
727 | | - js_log( "f:doEditSelectedClip:" ); |
728 | | - // and only one clip selected |
729 | | - if ( $j( '.mv_selected_clip' ).length == 1 ) { |
730 | | - this.doEditClip( this.getClipFromSeqID( $j( '.mv_selected_clip' ).parent().attr( 'id' ) ) ); |
731 | | - } else if ( $j( '.mv_selected_clip' ).length === 0 ) { |
732 | | - // no clip selected warning: |
733 | | - $j( '#clipedit_ic' ).html( gM( 'mwe-no_selected_resource' ) ); |
734 | | - } else { |
735 | | - // multiple clip selected warning: |
736 | | - $j( '#clipedit_ic' ).html( gM( 'mwe-error_edit_multiple' ) ); |
737 | | - } |
738 | | - }, |
| 771 | + /** |
| 772 | + * Loads the transition edit javascript libs and |
| 773 | + * displays the transition edit interface. |
| 774 | + */ |
739 | 775 | doEditTransition:function( cObj ) { |
740 | 776 | js_log( "sequence:doEditTransition" ); |
741 | 777 | var _this = this; |
| 778 | + // Add a loading image |
742 | 779 | mv_get_loading_img( '#transitions_ic' ); |
743 | 780 | mvJsLoader.doLoad( [ |
744 | 781 | '$j.fn.ColorPicker', |
745 | 782 | 'mvTimedEffectsEdit' |
746 | 783 | ], function() { |
747 | | - // no idea why this works / is needed. |
| 784 | + // For some reason we lose scope in the options passed to mvTimedEffectsEdit |
| 785 | + // so we re refrence the sequence here: |
748 | 786 | var localSeqRef = _this; |
749 | 787 | _this.myEffectEdit = new mvTimedEffectsEdit( { |
750 | 788 | 'rObj' : cObj, |
— | — | @@ -752,22 +790,25 @@ |
753 | 791 | } ); |
754 | 792 | } ) |
755 | 793 | }, |
756 | | - // updates the clip details div if edit resource is set |
| 794 | + /* |
| 795 | + * Updates the clip details div if edit resource is set |
| 796 | + */ |
757 | 797 | doEditClip:function( cObj ) { |
758 | 798 | js_log( 'seq:doEditClip' ); |
759 | 799 | var _this = this; |
760 | 800 | |
761 | | - // set default edit action (maybe edit_action can be sent via by context click) |
| 801 | + // Set default edit action |
762 | 802 | var edit_action = 'fileopts'; |
763 | 803 | |
764 | 804 | mv_get_loading_img( '#clipedit_ic' ); |
765 | | - // load the clipEdit library if not already loaded: |
| 805 | + |
| 806 | + // Load the clipEdit library if not already loaded: |
766 | 807 | mvJsLoader.doLoad( [ |
767 | 808 | 'mvClipEdit' |
768 | 809 | ], function() { |
769 | | - // zero out the current editor: |
| 810 | + // Zero out the current editor: |
770 | 811 | _this.myClipEditor = { }; |
771 | | - // setup the cliploader |
| 812 | + // Setup the cliploader options |
772 | 813 | _this.myClipEditor = new mvClipEdit( { |
773 | 814 | 'rObj' : cObj, |
774 | 815 | 'control_ct' : 'clipedit_ic', |
— | — | @@ -778,46 +819,58 @@ |
779 | 820 | } ); |
780 | 821 | } ); |
781 | 822 | }, |
782 | | - // save new clip segment |
| 823 | + |
| 824 | + /* |
| 825 | + * Save new clip segment |
| 826 | + * FIXME this is just a stub |
| 827 | + */ |
783 | 828 | saveClipEdit:function() { |
784 | 829 | // saves the clip updates |
785 | 830 | }, |
| 831 | + |
| 832 | + /** |
| 833 | + * Closes the sequence and dereferences the global instance. |
| 834 | + */ |
786 | 835 | closeModEditor:function() { |
787 | 836 | // unset the sequencer |
788 | 837 | _global['mvSeq'] = null; |
789 | 838 | $j( this.target_sequence_container + ',.ui-widget-overlay' ).remove(); |
790 | 839 | }, |
791 | | - pasteClipBoardClips:function() { |
792 | | - js_log( 'f:pasteClipBoardClips' ); |
793 | | - // @@todo query the server for updated clipboard |
794 | | - // paste before the "current clip" |
795 | | - this.addClips( this.clipboard, this.plObj.cur_clip.order ); |
796 | | - }, |
| 840 | + |
| 841 | + /** |
| 842 | + * Copies the selected clips to the server hosted "clipboard" |
| 843 | + * |
| 844 | + * FIXME need to support local clipboard for stand alone editing. |
| 845 | + * FIXME this does not really work at all right now |
| 846 | + */ |
797 | 847 | copySelectedClips:function() { |
798 | 848 | var this_seq = this; |
799 | 849 | // set all the selected clips |
800 | 850 | this.clipboard = new Array(); |
801 | 851 | $j( '.mv_selected_clip' ).each( function() { |
802 | | - // add each clip to the clip board: |
| 852 | + |
| 853 | + // Add each clip to the clip board: |
803 | 854 | var cur_clip = this_seq.getClipFromSeqID( $j( this ).parent().attr( 'id' ) ); |
804 | 855 | this_seq.clipboard.push( cur_clip.getAttributeObj() ); |
| 856 | + |
805 | 857 | } ); |
806 | | - // upload clipboard to the server (if possible) |
| 858 | + |
| 859 | + // Upload clipboard to the server (if possible) |
807 | 860 | if ( mw.parseUri( document.URL ).host != mw.parseUri( this_seq.plObj.interface_url ).host ) { |
808 | 861 | js_log( 'error: presently we can\'t copy clips across domains' ); |
809 | 862 | } else { |
810 | | - // @@we need a api entry point to store a "clipboard" |
| 863 | + // FIXME we need to add an api entry point to store a "clipboard" |
| 864 | + // right now this is dependent on a custom hook: |
811 | 865 | if ( this_seq.clipboardEditToken && this_seq.plObj.interface_url ) { |
812 | 866 | var req_url = this_seq.plObj.interface_url.replace( /api.php/, 'index.php' ) + '?action=ajax&rs=mv_seqtool_clipboard&rsargs[]=copy'; |
813 | 867 | $j.ajax( { |
814 | 868 | type: "POST", |
815 | | - url:req_url, |
| 869 | + url : req_url, |
816 | 870 | data: $j.param( { |
817 | 871 | "clipboard_data": $j.toJSON( this_seq.clipboard ), |
818 | 872 | "clipboardEditToken": this_seq.clipboardEditToken |
819 | 873 | } ), |
820 | 874 | success:function( data ) { |
821 | | - // callback( data ); |
822 | 875 | js_log( 'did clipboard push ' + $j.toJSON( this_seq.clipboard ) ); |
823 | 876 | } |
824 | 877 | } ); |
— | — | @@ -826,13 +879,30 @@ |
827 | 880 | } |
828 | 881 | } |
829 | 882 | }, |
| 883 | + /* |
| 884 | + * Paste the clipboard clips into the sequence |
| 885 | + */ |
| 886 | + pasteClipBoardClips:function() { |
| 887 | + js_log( 'f:pasteClipBoardClips' ); |
| 888 | + // @@todo query the server for updated clipboard |
| 889 | + // paste before the "current clip" |
| 890 | + this.addClips( this.clipboard, this.plObj.cur_clip.order ); |
| 891 | + }, |
| 892 | + |
| 893 | + /** |
| 894 | + * Cut selected clips from the timeline |
| 895 | + */ |
830 | 896 | cutSelectedClips:function() { |
831 | 897 | this.copySelectedClips(); |
832 | 898 | this.removeSelectedClips(); |
833 | 899 | }, |
| 900 | + |
| 901 | + /** |
| 902 | + * Remove selected clips from the timeline |
| 903 | + */ |
834 | 904 | removeSelectedClips:function() { |
835 | 905 | var remove_clip_ary = new Array(); |
836 | | - // remove selected clips from display |
| 906 | + // Remove selected clips from display |
837 | 907 | $j( '.container_track .mv_selected_clip' ).each( function() { |
838 | 908 | // grab the track index from the id (assumes track_#_clip_# |
839 | 909 | remove_clip_ary.push ( $j( this ).parent().attr( 'id' ).replace( 'track_', '' ).replace( 'clip_', '' ).split( '_' ) ); |
— | — | @@ -844,11 +914,16 @@ |
845 | 915 | // @@todo refresh menu of current |
846 | 916 | this.doEditSelectedClip(); |
847 | 917 | }, |
| 918 | + /* |
| 919 | + * Add a clip to the timeline |
| 920 | + */ |
848 | 921 | addClip:function( clip, before_clip_pos, track_inx ) { |
849 | 922 | this.addClips( [clip], before_clip_pos, track_inx ) |
850 | 923 | }, |
851 | | - // add a single or set of clips |
852 | | - // to a given position and track_inx |
| 924 | + /** |
| 925 | + * add a single or set of clips |
| 926 | + * to a given position and track_inx |
| 927 | + */ |
853 | 928 | addClips:function( clipSet, before_clip_pos, track_inx ) { |
854 | 929 | this_seq = this; |
855 | 930 | |
— | — | @@ -874,6 +949,10 @@ |
875 | 950 | // debugger; |
876 | 951 | this.do_refresh_timeline(); |
877 | 952 | }, |
| 953 | + |
| 954 | + /** |
| 955 | + * Removes Clips listed in the remove_clip_ary paramater |
| 956 | + */ |
878 | 957 | removeClips:function( remove_clip_ary ) { |
879 | 958 | var this_seq = this; |
880 | 959 | var jselect = coma = ''; |
Index: trunk/phase3/js2/mwEmbed/tests/testLang.html |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | } |
10 | 10 | </style> |
11 | 11 | <script type="text/javascript" > |
12 | | -var scriptLoaderURID = 't14'; |
| 12 | +var scriptLoaderURID = 't15'; |
13 | 13 | //for just setting one or two to test at a time for debug |
14 | 14 | //var langKeyDebug = ['sl']; //pl |
15 | 15 | var langKeyDebug = [ 'az', 'da', 'pt', 'fr', 'lv', 'en']; |
— | — | @@ -195,7 +195,7 @@ |
196 | 196 | |
197 | 197 | //do a manual call to the script-lodaer: |
198 | 198 | function doProcLangKey(langKey){ |
199 | | - $j.getScript('../../../mwScriptLoader.php?class=$mw.testLang&urid='+ scriptLoaderURID +'&uselang='+langKey, function(){ |
| 199 | + $j.getScript('../../../mwScriptLoader.php?class=mw.testLang&urid='+ scriptLoaderURID +'&uselang='+langKey, function(){ |
200 | 200 | var o=''; |
201 | 201 | o+='<tr><td colspan="6" height="20" style="font-size:large"><b>Lang:' + langKey + '</b></td></tr>'; |
202 | 202 | //now for each langage msg: |
— | — | @@ -217,8 +217,8 @@ |
218 | 218 | o+='<tr>'+ |
219 | 219 | '<td>' + numVal + '</td>' + |
220 | 220 | '<td>' + mKey + '</td>' + |
221 | | - '<td>' + $mw.lang.gMsgNoTrans( mKey ) + '</td>' + |
222 | | - '<td id="' + tkey + '_js">' + $mw.lang.gM( mKey, numVal ) + '</td>'; |
| 221 | + '<td>' + mw.lang.gMsgNoTrans( mKey ) + '</td>' + |
| 222 | + '<td id="' + tkey + '_js">' + mw.lang.gM( mKey, numVal ) + '</td>'; |
223 | 223 | //show mw col: |
224 | 224 | if( mKey.substr(0, 5) == 'test_' ){ |
225 | 225 | o+='<td> (test msg) </td>'; |
Index: trunk/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.09'; |
| 9 | +var mwRemoteVersion = '1.10'; |
10 | 10 | var mwUseScriptLoader = true; |
11 | 11 | |
12 | 12 | // setup up request Params: |
— | — | @@ -68,10 +68,8 @@ |
69 | 69 | vidIdList.push( divs[i].getAttribute( "id" ) ); |
70 | 70 | } |
71 | 71 | } |
72 | | - if ( vidIdList.length > 0 ) { |
73 | | - |
74 | | - var jsSetVideo = [ 'embedVideo', '$j.ui', 'ctrlBuilder', '$j.cookie', '$j.ui.slider' ]; |
75 | | - |
| 72 | + if ( vidIdList.length > 0 ) { |
| 73 | + var jsSetVideo = [ 'embedVideo', '$j.ui', 'ctrlBuilder', '$j.cookie', '$j.ui.slider', 'kskinConfig' ]; |
76 | 74 | // Quick sniff use java if IE and native if firefox |
77 | 75 | // ( other browsers will run detect and get on-demand ) |
78 | 76 | if (navigator.userAgent.indexOf("MSIE") != -1) |
— | — | @@ -96,22 +94,20 @@ |
97 | 95 | return ; |
98 | 96 | js_log( 'vidIdList on: ' + vidId + ' length: ' + vidIdList.length + ' left in the set: ' + vidIdList ); |
99 | 97 | |
100 | | - // Grab the thumbnail and src of the video |
101 | | - var pimg = $j( '#' + vidId + ' img' ); |
102 | | - var poster_attr = 'poster = "' + pimg.attr( 'src' ) + '" '; |
| 98 | + tag_type = 'video'; |
| 99 | + // Check type: |
103 | 100 | var pwidth = $j( '#' + vidId ).width(); |
104 | | - var pheight = $j( '#' + vidId + ' img :first' ).attr( 'height' ); |
105 | | - if(!pheight) |
106 | | - pheight = parseInt( pwidth * .75 ); |
107 | | - var tag_type = 'video'; |
108 | | - |
109 | | - // Check for audio |
110 | | - if ( pheight == '22' || pheight == '52' ) { |
111 | | - // set width to parent width: |
| 101 | + var $pimg = $j( '#' + vidId + ' img:first' ); |
| 102 | + if( $pimg.attr('src').split('/').pop() == 'play.png'){ |
112 | 103 | tag_type = 'audio'; |
113 | | - poster_attr = ''; |
| 104 | + poster_attr = ''; |
| 105 | + pheight = 0; |
| 106 | + }else{ |
| 107 | + var poster_attr = 'poster = "' + $pimg.attr( 'src' ) + '" '; |
| 108 | + var pheight = $pimg.attr( 'height' ); |
114 | 109 | } |
115 | 110 | |
| 111 | + |
116 | 112 | // Parsed values: |
117 | 113 | var src = ''; |
118 | 114 | var duration_attr = ''; |
— | — | @@ -137,8 +133,9 @@ |
138 | 134 | 'wikiTitleKey="' + wikiTitleKey + '" ' + |
139 | 135 | 'src="' + src + '" ' + |
140 | 136 | duration_attr + |
141 | | - offset_attr + ' '; |
142 | | - |
| 137 | + offset_attr + ' ' + |
| 138 | + 'class="kskin" '; |
| 139 | + |
143 | 140 | if ( tag_type == 'audio' ) { |
144 | 141 | html_out = '<audio' + common_attr + ' style="width:' + pwidth + 'px;"></audio>'; |
145 | 142 | } else { |
— | — | @@ -147,18 +144,20 @@ |
148 | 145 | 'style="width:' + pwidth + 'px;height:' + pheight + 'px;">' + |
149 | 146 | '</video>'; |
150 | 147 | } |
151 | | - // set the video tag inner html and update the height |
| 148 | + // Set the video tag inner html and update the height |
152 | 149 | $j( '#' + vidId ).html( html_out ) |
153 | 150 | .css( 'height', pheight + 30 ); |
154 | 151 | |
155 | | - } |
156 | | - rewrite_by_id( 'mwe_' + vidId, function() { |
157 | | - if ( vidIdList.length != 0 ) { |
158 | | - setTimeout( function() { |
159 | | - procVidId( vidIdList.pop() ) |
160 | | - }, 10 ); |
161 | | - } |
162 | | - } ); |
| 152 | + // Do the actual rewrite |
| 153 | + rewrite_by_id( 'mwe_' + vidId, function() { |
| 154 | + if ( vidIdList.length != 0 ) { |
| 155 | + setTimeout( function() { |
| 156 | + procVidId( vidIdList.pop() ) |
| 157 | + }, 10 ); |
| 158 | + } |
| 159 | + } ); |
| 160 | + |
| 161 | + } |
163 | 162 | }; |
164 | 163 | // process each item in the vidIdList (with setTimeout to avoid locking) |
165 | 164 | procVidId( vidIdList.pop() ); |