Index: branches/MwEmbedStandAlone/components/mw.Language.js |
— | — | @@ -434,7 +434,7 @@ |
435 | 435 | } |
436 | 436 | } |
437 | 437 | return ( typeInt )? parseInt( convertedNumber) : convertedNumber; |
438 | | - } |
| 438 | + }; |
439 | 439 | |
440 | 440 | /** |
441 | 441 | * Checks if a language key is valid ( is part of languageCodeList ) |
— | — | @@ -443,7 +443,7 @@ |
444 | 444 | */ |
445 | 445 | mw.isValidLang = function( langKey ) { |
446 | 446 | return ( mw.Language.names[ langKey ] )? true : false; |
447 | | - } |
| 447 | + }; |
448 | 448 | |
449 | 449 | /** |
450 | 450 | * Get a language transform key |
— | — | @@ -462,7 +462,7 @@ |
463 | 463 | } |
464 | 464 | // By default return the base 'en' class |
465 | 465 | return 'en'; |
466 | | - } |
| 466 | + }; |
467 | 467 | |
468 | 468 | /** |
469 | 469 | * getRemoteMsg loads remote msg strings |
Index: branches/MwEmbedStandAlone/components/mw.Api.js |
— | — | @@ -106,7 +106,7 @@ |
107 | 107 | * |
108 | 108 | * @param {Mixed} url or data request |
109 | 109 | * @param {Mixed} data or callback |
110 | | - * @param {Function} callbcak function called on success |
| 110 | + * @param {Function} callback function called on success |
111 | 111 | * @param {Function} callbackTimeout - optional function called on timeout |
112 | 112 | * Setting timeout callback also avoids default timed-out dialog for proxy requests |
113 | 113 | */ |
Index: branches/MwEmbedStandAlone/mwEmbed.js |
— | — | @@ -2595,7 +2595,7 @@ |
2596 | 2596 | |
2597 | 2597 | if( window.jQuery ){ |
2598 | 2598 | if( ! mw.versionIsAtLeast( '1.4.0', jQuery.fn.jquery ) ){ |
2599 | | - if( console && console.log ) { |
| 2599 | + if( window.console && window.console.log ) { |
2600 | 2600 | console.log( 'Error mwEmbed requires jQuery 1.4 or above' ); |
2601 | 2601 | } |
2602 | 2602 | } |
Index: branches/MwEmbedStandAlone/modules/Sequencer/mw.SequencerServer.js |
— | — | @@ -6,6 +6,8 @@ |
7 | 7 | |
8 | 8 | //Wrap in mw closure |
9 | 9 | ( function( mw ) { |
| 10 | + |
| 11 | + var SEQUENCER_PAYLOADKEY = '@gadgetSequencePayload@_$%^%'; |
10 | 12 | |
11 | 13 | mw.SequencerServer = function( sequencer ) { |
12 | 14 | return this.init( sequencer ); |
— | — | @@ -100,20 +102,51 @@ |
101 | 103 | */ |
102 | 104 | getSmilXml: function( callback ){ |
103 | 105 | var _this = this; |
104 | | - mw.getTitleText( this.getApiUrl(), this.getTitleKey(), function( smilXml ){ |
105 | | - // set smil to empty string if unset: |
106 | | - if(!smilXml ) |
107 | | - smilXml = ''; |
| 106 | + mw.getTitleText( this.getApiUrl(), this.getTitleKey(), function( smilPage ){ |
| 107 | + // Check for remote payload wrapper |
| 108 | + // XXX need to support multipe pages in single context |
| 109 | + _this.currentSequencePage = _this.parseSequencerPage( smilPage ); |
| 110 | + // Cache the latest serverSmil ( for local change checks ) |
| 111 | + // ( save requests automatically respond with warnings on other user updates ) |
| 112 | + _this.serverSmilXml =_this.currentSequencePage.sequenceXML; |
108 | 113 | |
109 | | - // Check for remote payload wrapper |
110 | | - smilXml = mw.getRemoteSequencerPayLoad( smilXml ); |
| 114 | + // Cache the pre / post bits |
111 | 115 | |
112 | | - // Cache the latest serverSmil ( for local change checks ) |
113 | | - // ( save requests automatically respond with warnings on other user updates ) |
114 | | - _this.serverSmilXml = smilXml; |
115 | | - callback( smilXml ); |
| 116 | + callback( _this.serverSmilXml ); |
116 | 117 | }) |
117 | 118 | }, |
| 119 | + wrapSequencerWikiText : function( xmlString ){ |
| 120 | + var _this = this; |
| 121 | + if( !_this.currentSequencePage.pageStart ){ |
| 122 | + _this.currentSequencePage.pageStart ="\nTo edit this sequence " + |
| 123 | + '[{{fullurl:{{FULLPAGENAME}}|withJS=MediaWiki:MwEmbed.js}} enable the sequencer] for this page'; |
| 124 | + } |
| 125 | + return _this.currentSequencePage.pageStart + |
| 126 | + "\n\n<!-- " + SEQUENCER_PAYLOADKEY + "\n" + |
| 127 | + xmlString + |
| 128 | + "\n\n " + SEQUENCER_PAYLOADKEY + " -->\n" + |
| 129 | + _this.currentSequencePage.pageEnd; |
| 130 | + }, |
| 131 | + |
| 132 | + parseSequencerPage : function( pageText ){ |
| 133 | + var _this = this; |
| 134 | + var startKey = '<!-- ' + SEQUENCER_PAYLOADKEY; |
| 135 | + var endKey = SEQUENCER_PAYLOADKEY + ' -->'; |
| 136 | + // If the key is not found fail |
| 137 | + if( !pageText || pageText.indexOf( startKey ) == -1 || pageText.indexOf(endKey) == -1 ){ |
| 138 | + mw.log("Error could not find sequence payload"); |
| 139 | + return ''; |
| 140 | + } |
| 141 | + // trim the output: |
| 142 | + return { |
| 143 | + 'pageStart' : pageText.substring(0, pageText.indexOf( startKey ) ), |
| 144 | + 'sequenceXML' : pageText.substring( pageText.indexOf( startKey ) + startKey.length, |
| 145 | + pageText.indexOf(endKey ) ), |
| 146 | + 'pageEnd' : pageText.substring( pageText.indexOf(endKey) ) |
| 147 | + } |
| 148 | + }, |
| 149 | + |
| 150 | + |
118 | 151 | getTemplateText: function( templateTitle, callback ){ |
119 | 152 | var _this = this; |
120 | 153 | if( this.templateTextCache[templateTitle] ){ |
— | — | @@ -159,7 +192,7 @@ |
160 | 193 | 'action' : 'edit', |
161 | 194 | 'summary' : saveSummary, |
162 | 195 | 'title' : _this.titleKey, |
163 | | - 'text' : mw.getRemoteSequencerPageHelper( sequenceXML ), |
| 196 | + 'text' : _this.wrapSequencerWikiText( sequenceXML ), |
164 | 197 | 'token': token |
165 | 198 | }; |
166 | 199 | mw.getJSON( _this.getApiUrl(), request, function( data ) { |
— | — | @@ -175,7 +208,8 @@ |
176 | 209 | } |
177 | 210 | }) |
178 | 211 | }) |
179 | | - }, |
| 212 | + }, |
| 213 | + |
180 | 214 | /** |
181 | 215 | * Check if the published file is up-to-date with the saved sequence |
182 | 216 | * ( higher page revision for file than sequence ) |
Index: branches/MwEmbedStandAlone/modules/Sequencer/remotes/mw.MediaWikiRemoteSequencer.js |
— | — | @@ -49,31 +49,6 @@ |
50 | 50 | return url; |
51 | 51 | }; |
52 | 52 | |
53 | | -var SEQUENCER_PAYLOADKEY = '@gadgetSequencePayload@_$%^%'; |
54 | | - |
55 | | - |
56 | | -mw.getRemoteSequencerPageHelper = function( xmlString ){ |
57 | | - return 'To edit this sequence ' + |
58 | | - '[{{fullurl:{{FULLPAGENAME}}|withJS=MediaWiki:MwEmbed.js}} enable the sequencer] for this page' + |
59 | | - "\n\n<!-- " + SEQUENCER_PAYLOADKEY + "\n" + |
60 | | - xmlString + |
61 | | - "\n\n " + SEQUENCER_PAYLOADKEY + " -->" |
62 | | -}; |
63 | | -mw.getRemoteSequencerPayLoad = function( pageText ){ |
64 | | - var startKey = '<!-- ' + SEQUENCER_PAYLOADKEY; |
65 | | - var endKey = SEQUENCER_PAYLOADKEY + ' -->'; |
66 | | - // if the key is not found fail |
67 | | - if( pageText.indexOf( startKey ) == -1 || pageText.indexOf(endKey) == -1 ){ |
68 | | - mw.log("Error could not find sequence payload"); |
69 | | - return ''; |
70 | | - } |
71 | | - var payload = pageText.substring( pageText.indexOf( startKey ) + startKey.length, |
72 | | - pageText.indexOf(endKey ) |
73 | | - ); |
74 | | - // trim the output: |
75 | | - return $j.trim( payload ); |
76 | | -}; |
77 | | - |
78 | 53 | // Add player pause binding if config is set:: |
79 | 54 | $j( mw ).bind( 'newEmbedPlayerEvent', function( event, embedPlayerId ) { |
80 | 55 | if( mw.getConfig( 'Sequencer.KalturaPlayerEditOverlay' )){ |