Index: branches/js2-work/phase3/skins/common/preview.js |
— | — | @@ -55,4 +55,4 @@ |
56 | 56 | } ); |
57 | 57 | } |
58 | 58 | |
59 | | -js2AddOnloadHook( setupLivePreview ); |
| 59 | +mw.addOnloadHook( setupLivePreview ); |
Index: branches/js2-work/phase3/includes/OutputPage.php |
— | — | @@ -16,6 +16,9 @@ |
17 | 17 | |
18 | 18 | var $mScriptLoaderClassList = array(); |
19 | 19 | |
| 20 | + //Flag if we have initialised javascript Classes |
| 21 | + var $mLoadedJavascriptClasses = false; |
| 22 | + |
20 | 23 | var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array(); |
21 | 24 | var $mInlineMsg = array(); |
22 | 25 | |
— | — | @@ -175,10 +178,10 @@ |
176 | 179 | function addCoreScripts2Top(){ |
177 | 180 | global $wgEnableScriptLoader, $wgJSAutoloadLocalClasses, $wgScriptPath, $wgEnableJS2system; |
178 | 181 | global $wgUser, $wgJsMimeType; |
179 | | - // @todo We should deprecate wikibits in favor of some mv_embed pieces and jQuery |
| 182 | + // @todo We should deprecate wikibits in favor of some mwEmbed pieces and jQuery |
180 | 183 | |
181 | 184 | if( $wgEnableJS2system ){ |
182 | | - $core_classes = array( 'window.jQuery', 'mv_embed', 'wikibits' ); |
| 185 | + $core_classes = array( 'window.jQuery', 'mwEmbed', 'wikibits' ); |
183 | 186 | } else { |
184 | 187 | $core_classes = array( 'wikibits' ); |
185 | 188 | } |
— | — | @@ -205,9 +208,18 @@ |
206 | 209 | * @return boolean False if the class wasn't found, true on success |
207 | 210 | */ |
208 | 211 | function addScriptClass( $js_class ){ |
209 | | - global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses, |
| 212 | + global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses, $IP, |
210 | 213 | $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath, $wgEnableJS2system; |
211 | 214 | |
| 215 | + // Load the javascript script class paths |
| 216 | + if( ! $this->mLoadedJavascriptClasses ){ |
| 217 | + require_once("$IP/js2/mwEmbed/php/jsAutoloadLocalClasses.php"); |
| 218 | + // Issue the load request: |
| 219 | + wfLoadMwEmbedClassPaths(); |
| 220 | + // Set the flag to true |
| 221 | + $this->mLoadedJavascriptClasses = true; |
| 222 | + } |
| 223 | + |
212 | 224 | $path = jsScriptLoader::getJsPathFromClass( $js_class ); |
213 | 225 | if( $path !== false ){ |
214 | 226 | if( $wgEnableScriptLoader ) { |
— | — | @@ -228,7 +240,7 @@ |
229 | 241 | } |
230 | 242 | $this->addScript( Html::linkedScript( $path . "?" . $this->getURIDparam( $js_class ) ) ); |
231 | 243 | |
232 | | - // Merge in language text (if js2 is on and we have loadGM function & scriptLoader is "off") |
| 244 | + // Merge in language text (if js2 is on and we have mw.addMessages function & scriptLoader is "off") |
233 | 245 | if( $wgEnableJS2system ){ |
234 | 246 | if( !$this->mScriptLoader ) |
235 | 247 | $this->mScriptLoader = new jsScriptLoader(); |
Index: branches/js2-work/phase3/includes/DefaultSettings.php |
— | — | @@ -921,7 +921,7 @@ |
922 | 922 | $wgHtml5Version = null; |
923 | 923 | |
924 | 924 | /** |
925 | | - * Enabled RDFa attributes for use in wikitext. |
| 925 | + * Enabled RDFa attributes for use in wikitext. |
926 | 926 | * NOTE: Interaction with HTML5 is somewhat underspecified. |
927 | 927 | */ |
928 | 928 | $wgAllowRdfaAttributes = true; |
— | — | @@ -2831,7 +2831,7 @@ |
2832 | 2832 | |
2833 | 2833 | /* |
2834 | 2834 | * enable js2 Script System |
2835 | | - * if enabled we include jquery, mv_embed and js2 versions of editPage.js |
| 2835 | + * if enabled we include jquery, mwEmbed and js2 versions of editPage.js |
2836 | 2836 | */ |
2837 | 2837 | $wgEnableJS2system = false; |
2838 | 2838 | |
— | — | @@ -2841,7 +2841,7 @@ |
2842 | 2842 | $wgEnableIframeApiProxy = false; |
2843 | 2843 | |
2844 | 2844 | /* |
2845 | | - * boolean; if we should enable javascript localization (it loads loadGM json |
| 2845 | + * boolean; if we should enable javascript localization (it loads mw.addMessages json |
2846 | 2846 | * call with mediaWiki msgs) |
2847 | 2847 | */ |
2848 | 2848 | $wgEnableScriptLocalization = true; |
Index: branches/js2-work/phase3/includes/upload/UploadFromChunks.php |
— | — | @@ -92,7 +92,7 @@ |
93 | 93 | // first append last chunk (so we can do a real verifyFile check... (check file type etc) |
94 | 94 | $status = $this->doChunkAppend(); |
95 | 95 | if( $status->isOK() ){ |
96 | | - $this->mTempPath = $this->getRealPath( $this->mTempAppendPath ); |
| 96 | + $this->mTempPath = UploadBase::getRealPath( $this->mTempAppendPath ); |
97 | 97 | // verify the completed merged chunks as if it was the file that got uploaded: |
98 | 98 | return parent::verifyFile( $this->mTempPath ); |
99 | 99 | } else { |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | ob_clean(); |
174 | 174 | echo FormatJson::encode( array( |
175 | 175 | 'result' => 1, |
176 | | - 'filesize' => filesize( $this->getRealPath( $this->mTempAppendPath ) ) |
| 176 | + 'filesize' => filesize( UploadBase::getRealPath( $this->mTempAppendPath ) ) |
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | exit( 0 ); |
— | — | @@ -227,13 +227,13 @@ |
228 | 228 | } |
229 | 229 | return $status; |
230 | 230 | } else { |
231 | | - if( is_file( $this->getRealPath( $this->mTempAppendPath ) ) ){ |
| 231 | + if( is_file( UploadBase::getRealPath( $this->mTempAppendPath ) ) ){ |
232 | 232 | $status = $this->appendToUploadFile( $this->mTempAppendPath, $this->mTempPath ); |
233 | 233 | } else { |
234 | 234 | $status = Status::newFatal( 'filenotfound', $this->mTempAppendPath ); |
235 | 235 | } |
236 | 236 | //check to make sure we have not expanded beyond $wgMaxUploadSize |
237 | | - if( filesize( $this->getRealPath( $this->mTempAppendPath ) ) > $wgMaxUploadSize ) |
| 237 | + if( filesize( UploadBase::getRealPath( $this->mTempAppendPath ) ) > $wgMaxUploadSize ) |
238 | 238 | $status = Status::newFatal( 'largefileserver' ); |
239 | 239 | |
240 | 240 | return $status; |
Index: branches/js2-work/phase3/includes/Setup.php |
— | — | @@ -343,11 +343,6 @@ |
344 | 344 | # |
345 | 345 | $wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php"; |
346 | 346 | |
347 | | -# Include the js2/mwEmbed autoLoadClasses if js2 is enabled |
348 | | -if( $wgEnableJS2system ){ |
349 | | - require_once("$IP/js2/mwEmbed/php/jsAutoloadLocalClasses.php"); |
350 | | -} |
351 | | - |
352 | 347 | # Extension setup functions for extensions other than skins |
353 | 348 | # Entries should be added to this variable during the inclusion |
354 | 349 | # of the extension file. This allows the extension to perform |
Index: branches/js2-work/phase3/js2/uploadPage.js |
— | — | @@ -138,6 +138,6 @@ |
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | | -js2AddOnloadHook( function() { |
| 142 | +mw.addOnloadHook( function() { |
143 | 143 | mwUploadHelper.init(); |
144 | 144 | } ); |
\ No newline at end of file |
Index: branches/js2-work/phase3/js2/editPage.js |
— | — | @@ -20,8 +20,8 @@ |
21 | 21 | 'local_wiki_api_url': wgServer + wgScriptPath + '/api.php' |
22 | 22 | }; |
23 | 23 | |
24 | | -js2AddOnloadHook( function() { |
25 | | - js_log( "edit page js2AddOnloadHook::" ); |
| 24 | +mw.addOnloadHook( function() { |
| 25 | + js_log( "edit page mw.addOnloadHook::" ); |
26 | 26 | var amwConf = $j.extend( true, defaultAddMediaConfig, mwAddMediaConfig ); |
27 | 27 | // kind of tricky, it would be nice to use run on ready "loader" call here |
28 | 28 | var didWikiEditorBind = false; |
Index: branches/js2-work/phase3/js2/mwEmbed/mv_embed.js |
— | — | @@ -1,2144 +0,0 @@ |
2 | | -/* |
3 | | - * ~mv_embed ~ |
4 | | - * For details see: http://metavid.org/wiki/index.php/Mv_embed |
5 | | - * |
6 | | - * All Metavid Wiki code is released under the GPL2. |
7 | | - * For more information visit http://metavid.org/wiki/Code |
8 | | - * |
9 | | - * @url http://metavid.org |
10 | | - * |
11 | | - * mw.parseUri: |
12 | | - * http://stevenlevithan.com/demo/parseuri/js/ |
13 | | - * |
14 | | - * Config values: you can manually set the location of the mv_embed folder here |
15 | | - * (in cases where media will be hosted in a different place than the embedding page) |
16 | | - * |
17 | | - */ |
18 | | - |
19 | | -/** |
20 | | - * AutoLoader paths |
21 | | - * @path The path to the file (or set of files) with ending slash |
22 | | - * @gClasses The set of classes |
23 | | - * if it's an array, $j.className becomes jquery.className.js |
24 | | - * if it's an associative object then key => value pairs are used |
25 | | - */ |
26 | | -if ( typeof mvAutoLoadClasses == 'undefined' ) |
27 | | - mvAutoLoadClasses = { }; |
28 | | - |
29 | | -// The script that loads the class set |
30 | | -function lcPaths( classSet ) { |
31 | | - for ( var i in classSet ) { |
32 | | - mvAutoLoadClasses[i] = classSet[i]; |
33 | | - } |
34 | | -} |
35 | | - |
36 | | -function mvGetClassPath( k ) { |
37 | | - if ( mvAutoLoadClasses[k] ) { |
38 | | - // js_log('got class path:' + k + ' : '+ mvClassPaths[k]); |
39 | | - return mvAutoLoadClasses[k]; |
40 | | - } else { |
41 | | - js_log( 'Error:: Could not find path for requested class ' + k ); |
42 | | - return false; |
43 | | - } |
44 | | -} |
45 | | - |
46 | | -if ( typeof mvCssPaths == 'undefined' ) |
47 | | - mvCssPaths = { }; |
48 | | - |
49 | | -function lcCssPath( cssSet ) { |
50 | | - for ( var i in cssSet ) { |
51 | | - mvCssPaths[i] = cssSet[i]; |
52 | | - } |
53 | | -} |
54 | | - |
55 | | -/* |
56 | | - * -- Load Class Paths -- |
57 | | - * |
58 | | - * MUST BE VALID JSON (NOT JS) |
59 | | - * This is used by the script loader to auto-load classes (so we only define |
60 | | - * this once for PHP & JavaScript) |
61 | | - * |
62 | | - * Right now the PHP AutoLoader only reads this mv_embed.js file. |
63 | | - * In the future we could have multiple lcPath calls that PHP reads |
64 | | - * (if our autoloading class list becomes too long) |
65 | | - * or |
66 | | - * we could support direct file requests to the script loader instead |
67 | | - * of shared class names read from a central location. |
68 | | - */ |
69 | | -lcPaths( { |
70 | | - "mv_embed" : "mv_embed.js", |
71 | | - "window.jQuery" : "jquery/jquery-1.3.2.js", |
72 | | - "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", |
73 | | - "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", |
74 | | - "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", |
75 | | - "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
76 | | - "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
77 | | - "$j.fn.ColorPicker" : "libClipEdit/colorpicker/js/colorpicker.js", |
78 | | - "$j.Jcrop" : "libClipEdit/Jcrop/js/jquery.Jcrop.js", |
79 | | - "$j.fn.simpleUploadForm" : "libAddMedia/simpleUploadForm.js", |
80 | | - |
81 | | - "mw.proxy" : "libMwApi/mw.proxy.js", |
82 | | - |
83 | | - "mw.testLang" : "tests/testLang.js", |
84 | | - |
85 | | - "ctrlBuilder" : "skins/ctrlBuilder.js", |
86 | | - "kskinConfig" : "skins/kskin/kskin.js", |
87 | | - "mvpcfConfig" : "skins/mvpcf/mvpcf.js", |
88 | | - |
89 | | - "JSON" : "libMwApi/json2.js", |
90 | | - "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
91 | | - "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
92 | | - "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
93 | | - "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
94 | | - |
95 | | - "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
96 | | - "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
97 | | - "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js", |
98 | | - "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js", |
99 | | - "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js", |
100 | | - "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js", |
101 | | - "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js", |
102 | | - "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js", |
103 | | - "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js", |
104 | | - "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js", |
105 | | - "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js", |
106 | | - "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js", |
107 | | - "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js", |
108 | | - "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js", |
109 | | - "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js", |
110 | | - "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js", |
111 | | - "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js", |
112 | | - "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js", |
113 | | - "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js", |
114 | | - "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js", |
115 | | - "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js", |
116 | | - "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js", |
117 | | - "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", |
118 | | - "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js", |
119 | | - |
120 | | - "$j.fn.dragDropFile" : "libAddMedia/dragDropFile.js", |
121 | | - "mvFirefogg" : "libAddMedia/mvFirefogg.js", |
122 | | - "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js", |
123 | | - "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js", |
124 | | - "remoteSearchDriver" : "libAddMedia/remoteSearchDriver.js", |
125 | | - "seqRemoteSearchDriver" : "libSequencer/seqRemoteSearchDriver.js", |
126 | | - |
127 | | - "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", |
128 | | - "mediaWikiSearch" : "libAddMedia/searchLibs/mediaWikiSearch.js", |
129 | | - "metavidSearch" : "libAddMedia/searchLibs/metavidSearch.js", |
130 | | - "archiveOrgSearch" : "libAddMedia/searchLibs/archiveOrgSearch.js", |
131 | | - "flickrSearch" : "libAddMedia/searchLibs/flickrSearch.js", |
132 | | - "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", |
133 | | - |
134 | | - "mvClipEdit" : "libClipEdit/mvClipEdit.js", |
135 | | - |
136 | | - "embedPlayer" : "libEmbedPlayer/embedPlayer.js", |
137 | | - "flowplayerEmbed" : "libEmbedPlayer/flowplayerEmbed.js", |
138 | | - "kplayerEmbed" : "libEmbedPlayer/kplayerEmbed.js", |
139 | | - "genericEmbed" : "libEmbedPlayer/genericEmbed.js", |
140 | | - "htmlEmbed" : "libEmbedPlayer/htmlEmbed.js", |
141 | | - "javaEmbed" : "libEmbedPlayer/javaEmbed.js", |
142 | | - "nativeEmbed" : "libEmbedPlayer/nativeEmbed.js", |
143 | | - "quicktimeEmbed" : "libEmbedPlayer/quicktimeEmbed.js", |
144 | | - "vlcEmbed" : "libEmbedPlayer/vlcEmbed.js", |
145 | | - |
146 | | - "mvPlayList" : "libSequencer/mvPlayList.js", |
147 | | - "mvSequencer" : "libSequencer/mvSequencer.js", |
148 | | - "mvFirefoggRender" : "libSequencer/mvFirefoggRender.js", |
149 | | - "mvTimedEffectsEdit": "libSequencer/mvTimedEffectsEdit.js", |
150 | | - |
151 | | - "mvTextInterface" : "libTimedText/mvTextInterface.js", |
152 | | - "mvTimeTextEdit" : "libTimedText/mvTimeTextEdit.js" |
153 | | -} ); |
154 | | - |
155 | | -// Dependency mapping for CSS files for self-contained included plugins: |
156 | | -lcCssPath( { |
157 | | - '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css', |
158 | | - '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css' |
159 | | -}) |
160 | | - |
161 | | -// For use when mv_embed with script-loader is in the root MediaWiki path |
162 | | -var mediaWiki_mvEmbed_path = 'js2/mwEmbed/'; |
163 | | - |
164 | | -// The global scope: will be depreciated once we get everything into mw |
165 | | -var _global = this; |
166 | | - |
167 | | -/* |
168 | | -* setup the empty global mw object |
169 | | -* will ensure all our functions and variables are properly namespaced |
170 | | -* reducing chance of conflicts |
171 | | -*/ |
172 | | -if ( !window['mw'] ) { |
173 | | - window['mw'] = { } |
174 | | -} |
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 | | - |
193 | | -// @@todo move these into mw |
194 | | -var global_req_cb = new Array(); // The global request callback array |
195 | | - |
196 | | -/** |
197 | | -* The global mw object: |
198 | | -* |
199 | | -* Any global functions/classes that are not jQuery plugins should make |
200 | | -* there way into the mw namespace |
201 | | -*/ |
202 | | -( function( $ ) { |
203 | | - // list valid skins here: |
204 | | - $.valid_skins = ['mvpcf', 'kskin']; |
205 | | - // the version of mwEmbed |
206 | | - $.version = '1.0r21'; |
207 | | - |
208 | | - // special case of commons api url |
209 | | - // (used for default subtitles server for media with a "wikiTitleKey" atm) |
210 | | - // (@@todo eventually we should have wikiTitleKey be namespaced with interwiki ns |
211 | | - $.commons_api_url = 'http://commons.wikimedia.org/w/api.php'; |
212 | | - /* |
213 | | - * some global containers flags |
214 | | - */ |
215 | | - $.skin_list = new Array(); |
216 | | - $.init_done = false; |
217 | | - $.cb_count = 0; |
218 | | - $.player_list = new Array(), // The global player list per page |
219 | | - $.req_cb = new Array() // The global request callback array |
220 | | - |
221 | | - /* |
222 | | - * Language classes mw.lang |
223 | | - * |
224 | | - * Localized Language support attempts to mirror the functionality of Language.php in MediaWiki |
225 | | - * It contains methods for loading and transforming msg text |
226 | | - * |
227 | | - */ |
228 | | - $.lang = { }; |
229 | | - /** |
230 | | - * Setup the lang object |
231 | | - */ |
232 | | - var gMsg = { }; |
233 | | - var gRuleSet = { }; |
234 | | - |
235 | | - /** |
236 | | - * loadGM function |
237 | | - * Loads a set of json messages into the lng object. |
238 | | - * |
239 | | - * @param json msgSet The set of msgs to be loaded |
240 | | - */ |
241 | | - $.lang.loadGM = function( msgSet ) { |
242 | | - for ( var i in msgSet ) { |
243 | | - gMsg[ i ] = msgSet[i]; |
244 | | - } |
245 | | - } |
246 | | - |
247 | | - /** |
248 | | - * loadRS function |
249 | | - * Loads a ruleset by given template key ie PLURAL : { //ruleSetObj } |
250 | | - * |
251 | | - * @param json ruleSet The ruleset object ( extends gRuleSet ) |
252 | | - */ |
253 | | - $.lang.loadRS = function( ruleSet ) { |
254 | | - for ( var i in ruleSet ) { |
255 | | - gRuleSet[ i ] = ruleSet[ i ]; |
256 | | - } |
257 | | - } |
258 | | - |
259 | | - /** |
260 | | - * Returns a transformed msg string |
261 | | - * |
262 | | - * it take a msg key and array of replacement values of form |
263 | | - * $1, $2 and does relevant msgkey transformation returning |
264 | | - * the user msg. |
265 | | - * |
266 | | - * @param string key The msg key as set by loadGm |
267 | | - * @param [mixed] args An array of replacement strings |
268 | | - * @return string |
269 | | - */ |
270 | | - $.lang.gM = function( key , args ) { |
271 | | - if ( ! gMsg[ key ] ) |
272 | | - return '<' + key + '>';// Missing key placeholder |
273 | | - |
274 | | - // swap in the arg values |
275 | | - var ms = $.lang.gMsgSwap( key, args ); |
276 | | - |
277 | | - // a quick check to see if we need to send the msg via the 'parser' |
278 | | - // (we can add more detailed check once we support more wiki syntax) |
279 | | - if ( ms.indexOf( '{{' ) === -1 && ms.indexOf( '[' ) === -1 ) { |
280 | | - return ms; |
281 | | - } |
282 | | - |
283 | | - // make sure we have the lagMagic setup: |
284 | | - // @@todo move to init |
285 | | - $.lang.magicSetup(); |
286 | | - // send the msg key through the parser |
287 | | - var pObj = $.parser.pNew( ms ); |
288 | | - // return the transformed msg |
289 | | - return pObj.getHTML(); |
290 | | - } |
291 | | - /** |
292 | | - * gMsgSwap |
293 | | - * |
294 | | - * @param string key The msg key as set by loadGm |
295 | | - * @param [mixed] args An array or string to be replaced |
296 | | - * @return string |
297 | | - */ |
298 | | - $.lang.gMsgSwap = function( key , args ) { |
299 | | - if ( ! gMsg[ key ] ) |
300 | | - return '<' + key + '>';// Missing key placeholder |
301 | | - // get the message string: |
302 | | - var ms = gMsg[ key ]; |
303 | | - |
304 | | - // replace values |
305 | | - if ( typeof args == 'object' || typeof args == 'array' ) { |
306 | | - for ( var v in args ) { |
307 | | - // Message test replace arguments start at 1 instead of zero: |
308 | | - var rep = new RegExp( '\\$' + ( parseInt( v ) + 1 ), 'g' ); |
309 | | - ms = ms.replace( rep, args[v] ); |
310 | | - } |
311 | | - } else if ( typeof args == 'string' || typeof args == 'number' ) { |
312 | | - ms = ms.replace( /\$1/g, args ); |
313 | | - } |
314 | | - return ms; |
315 | | - } |
316 | | - |
317 | | - /** |
318 | | - * gMsgNoTrans |
319 | | - * |
320 | | - * @returns string The msg key without transforming it |
321 | | - */ |
322 | | - $.lang.gMsgNoTrans = function( key ) { |
323 | | - if ( gMsg[ key ] ) |
324 | | - return gMsg[ key ] |
325 | | - |
326 | | - // Missing key placeholder |
327 | | - return '<' + key + '>'; |
328 | | - } |
329 | | - /** |
330 | | - * Add Supported Magic Words to parser |
331 | | - */ |
332 | | - // Set the setupflag to false: |
333 | | - $.lang.doneSetup = false; |
334 | | - $.lang.magicSetup = function() { |
335 | | - if ( !$.lang.doneSetup ) { |
336 | | - $.parser.addMagic ( { |
337 | | - 'PLURAL' : $.lang.procPLURAL |
338 | | - } ) |
339 | | - |
340 | | - $.lang.doneSetup = true; |
341 | | - } |
342 | | - |
343 | | - } |
344 | | - /** |
345 | | - * Process the PLURAL special language template key: |
346 | | - */ |
347 | | - $.lang.procPLURAL = function( tObj ) { |
348 | | - // setup shortcuts |
349 | | - // (gRuleSet is loaded from script-loader to contains local ruleset) |
350 | | - var rs = gRuleSet['PLURAL']; |
351 | | - |
352 | | - /* |
353 | | - * Plural matchRuleTest |
354 | | - */ |
355 | | - function matchRuleTest( cRule, val ) { |
356 | | - js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val ); |
357 | | - function checkValue( compare, val ) { |
358 | | - if ( typeof compare == 'string' ) { |
359 | | - range = compare.split( '-' ); |
360 | | - if ( range.length >= 1 ) { |
361 | | - if ( val >= range[0] && val <= range[1] ) |
362 | | - return true; |
363 | | - } |
364 | | - } |
365 | | - // else do a direct compare |
366 | | - if ( compare == val ) { |
367 | | - return true; |
368 | | - } |
369 | | - return false; |
370 | | - } |
371 | | - // check for simple cRule type: |
372 | | - if ( typeof cRule == 'number' ) { |
373 | | - return ( parseInt( val ) == parseInt( cRule ) ); |
374 | | - } else if ( typeof cRule == 'object' ) { |
375 | | - var cmatch = { }; |
376 | | - // if a list we need to match all for rule match |
377 | | - for ( var i in cRule ) { |
378 | | - var cr = cRule[i]; |
379 | | - // set cr type |
380 | | - var crType = ''; |
381 | | - for ( var j in cr ) { |
382 | | - if ( j == 'mod' ) |
383 | | - crType = 'mod' |
384 | | - } |
385 | | - switch( crType ) { |
386 | | - case 'mod': |
387 | | - if ( cr ['is'] ) { |
388 | | - if ( checkValue( val % cr['mod'], cr ['is'] ) ) |
389 | | - cmatch[i] = true; |
390 | | - } else if ( cr['not'] ) { |
391 | | - if ( ! checkValue( val % cr['mod'], cr ['not'] ) ) |
392 | | - cmatch[i] = true; |
393 | | - } |
394 | | - break; |
395 | | - } |
396 | | - } |
397 | | - // check all the matches (taking into consideration "or" order) |
398 | | - for ( var i in cRule ) { |
399 | | - if ( ! cmatch[i] ) |
400 | | - return false; |
401 | | - } |
402 | | - return true; |
403 | | - |
404 | | - } |
405 | | - } |
406 | | - /** |
407 | | - * Maps a given rule Index to template params: |
408 | | - * |
409 | | - * if index is out of range return last param |
410 | | - * @param |
411 | | - */ |
412 | | - function getTempParamFromRuleInx( tObj, ruleInx ) { |
413 | | - // js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length ); |
414 | | - if ( ruleInx >= tObj.param.length ) |
415 | | - return tObj.param[ tObj.param.length - 1 ]; |
416 | | - // else return the requested index: |
417 | | - return tObj.param[ ruleInx ]; |
418 | | - } |
419 | | - var rCount = 0 |
420 | | - // run the actual rule lookup: |
421 | | - for ( var ruleInx in rs ) { |
422 | | - cRule = rs[ruleInx]; |
423 | | - if ( matchRuleTest( cRule, tObj.arg ) ) { |
424 | | - js_log("matched rule: " + ruleInx ); |
425 | | - return getTempParamFromRuleInx( tObj, rCount ); |
426 | | - } |
427 | | - rCount ++; |
428 | | - } |
429 | | - js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] ); |
430 | | - //debugger; |
431 | | - // return the last /"other" template param |
432 | | - return tObj.param [ tObj.param.length - 1 ]; |
433 | | - } |
434 | | - |
435 | | - /** |
436 | | - * gMsgLoadRemote loads remote msg strings |
437 | | - * |
438 | | - * @param mixed msgSet the set of msg to load remotely |
439 | | - * @param function callback the callback to issue once string is ready |
440 | | - */ |
441 | | - $.lang.gMsgLoadRemote = function( msgSet, callback ) { |
442 | | - var ammessages = ''; |
443 | | - if ( typeof msgSet == 'object' ) { |
444 | | - for ( var i in msgSet ) { |
445 | | - ammessages += msgSet[i] + '|'; |
446 | | - } |
447 | | - } else if ( typeof msgSet == 'string' ) { |
448 | | - ammessages += msgSet; |
449 | | - } |
450 | | - if ( ammessages == '' ) { |
451 | | - js_log( 'gMsgLoadRemote: no message set requested' ); |
452 | | - return false; |
453 | | - } |
454 | | - do_api_req( { |
455 | | - 'data': { |
456 | | - 'meta': 'allmessages', |
457 | | - 'ammessages': ammessages |
458 | | - } |
459 | | - }, function( data ) { |
460 | | - if ( data.query.allmessages ) { |
461 | | - var msgs = data.query.allmessages; |
462 | | - for ( var i in msgs ) { |
463 | | - var ld = { }; |
464 | | - ld[ msgs[i]['name'] ] = msgs[i]['*']; |
465 | | - loadGM( ld ); |
466 | | - } |
467 | | - } |
468 | | - callback(); |
469 | | - } ); |
470 | | - } |
471 | | - /** |
472 | | - * Format a size in bytes for output, using an appropriate |
473 | | - * unit (B, KB, MB or GB) according to the magnitude in question |
474 | | - * |
475 | | - * @param size Size to format |
476 | | - * @return string Plain text (not HTML) |
477 | | - */ |
478 | | - $.lang.formatSize = function ( size ) { |
479 | | - // For small sizes no decimal places are necessary |
480 | | - var round = 0; |
481 | | - var msg = ''; |
482 | | - if ( size > 1024 ) { |
483 | | - size = size / 1024; |
484 | | - if ( size > 1024 ) { |
485 | | - size = size / 1024; |
486 | | - // For MB and bigger two decimal places are smarter |
487 | | - round = 2; |
488 | | - if ( size > 1024 ) { |
489 | | - size = size / 1024; |
490 | | - msg = 'mwe-size-gigabytes'; |
491 | | - } else { |
492 | | - msg = 'mwe-size-megabytes'; |
493 | | - } |
494 | | - } else { |
495 | | - msg = 'mwe-size-kilobytes'; |
496 | | - } |
497 | | - } else { |
498 | | - msg = 'mwe-size-bytes'; |
499 | | - } |
500 | | - // JavaScript does not let you choose the precision when rounding |
501 | | - var p = Math.pow( 10, round ); |
502 | | - var size = Math.round( size * p ) / p; |
503 | | - return gM( msg , size ); |
504 | | - }; |
505 | | - |
506 | | - $.lang.formatNumber = function( num ) { |
507 | | - /* |
508 | | - * addSeparatorsNF |
509 | | - * @param Str: The number to be formatted, as a string or number. |
510 | | - * @param outD: The decimal character for the output, such as ',' for the number 100,2 |
511 | | - * @param sep: The separator character for the output, such as ',' for the number 1,000.2 |
512 | | - */ |
513 | | - function addSeparatorsNF( nStr, outD, sep ) { |
514 | | - nStr += ''; |
515 | | - var dpos = nStr.indexOf( '.' ); |
516 | | - var nStrEnd = ''; |
517 | | - if ( dpos != -1 ) { |
518 | | - nStrEnd = outD + nStr.substring( dpos + 1, nStr.length ); |
519 | | - nStr = nStr.substring( 0, dpos ); |
520 | | - } |
521 | | - var rgx = /(\d+)(\d{3})/; |
522 | | - while ( rgx.test( nStr ) ) { |
523 | | - nStr = nStr.replace( rgx, '$1' + sep + '$2' ); |
524 | | - } |
525 | | - return nStr + nStrEnd; |
526 | | - } |
527 | | - // @@todo read language code and give periods or comas: |
528 | | - return addSeparatorsNF( num, '.', ',' ); |
529 | | - } |
530 | | - |
531 | | - |
532 | | - |
533 | | - /** |
534 | | - * MediaWiki wikitext "Parser" |
535 | | - * |
536 | | - * This is not feature complete but we need a way to get at template properties |
537 | | - * |
538 | | - * |
539 | | - * @param {String} wikiText the wikitext to be parsed |
540 | | - * @return {Object} parserObj returns a parser object that has methods for getting at |
541 | | - * things you would want |
542 | | - */ |
543 | | - $.parser = { }; |
544 | | - var pMagicSet = { }; |
545 | | - /** |
546 | | - * parser addMagic |
547 | | - * |
548 | | - * Lets you add a set of magic keys and associated callback functions |
549 | | - * |
550 | | - * @param object magicSet key:callback |
551 | | - */ |
552 | | - $.parser.addMagic = function( magicSet ) { |
553 | | - for ( var i in magicSet ) |
554 | | - pMagicSet[ i ] = magicSet[i]; |
555 | | - } |
556 | | - |
557 | | - // actual parse call (returns parser object) |
558 | | - $.parser.pNew = function( wikiText, opt ) { |
559 | | - var parseObj = function( wikiText, opt ) { |
560 | | - return this.init( wikiText, opt ) |
561 | | - } |
562 | | - parseObj.prototype = { |
563 | | - // the wikiText "DOM"... stores the parsed wikiText structure |
564 | | - // wtDOM : {}, (not yet supported ) |
565 | | - |
566 | | - pOut : '', // the parser output string container |
567 | | - init :function( wikiText ) { |
568 | | - this.wikiText = wikiText; |
569 | | - }, |
570 | | - updateText : function( wikiText ) { |
571 | | - this.wikiText = wikiText; |
572 | | - // invalidate the output (will force a re-parse ) |
573 | | - this.pOut = ''; |
574 | | - }, |
575 | | - parse : function() { |
576 | | - /* |
577 | | - * quickly recursive / parse out templates: |
578 | | - */ |
579 | | - |
580 | | - // ~ probably a better algorithm out there / should mirror php parser flow ~ |
581 | | - // (we are already running white-space issues ie php parse strips whitespace differently) |
582 | | - // or at least expose something similar to: http://www.mediawiki.org/wiki/Extension:Page_Object_Model |
583 | | - |
584 | | - // ... but I am having fun with recursion so here it is... |
585 | | - function rdpp ( txt , cn ) { |
586 | | - var node = { }; |
587 | | - // inspect each char |
588 | | - for ( var a = 0; a < txt.length; a++ ) { |
589 | | - if ( txt[a] == '{' && txt[a + 1] == '{' ) { |
590 | | - a = a + 2; |
591 | | - node['p'] = node; |
592 | | - if ( !node['c'] ) |
593 | | - node['c'] = new Array(); |
594 | | - |
595 | | - node['c'].push( rdpp( txt.substr( a ), true ) ); |
596 | | - } else if ( txt[a] == '}' && txt[a + 1] == '}' ) { |
597 | | - a = a + 2; |
598 | | - if ( !node['p'] ) { |
599 | | - return node; |
600 | | - } |
601 | | - node = node['p']; |
602 | | - } |
603 | | - if ( !node['t'] ) |
604 | | - node['t'] = ''; |
605 | | - // don't put closures into output: |
606 | | - if ( txt[a] && txt[a] != '}' ) |
607 | | - node['t'] += txt[a]; |
608 | | - |
609 | | - } |
610 | | - return node; |
611 | | - } |
612 | | - /** |
613 | | - * parse template text as template name and named params |
614 | | - */ |
615 | | - function parseTmplTxt( ts ) { |
616 | | - var tObj = { }; |
617 | | - // Get template name: |
618 | | - tname = ts.split( '\|' ).shift() ; |
619 | | - tname = tname.split( '\{' ).shift() ; |
620 | | - tname = tname.replace( /^\s+|\s+$/g, "" ); //trim |
621 | | - |
622 | | - // check for arguments: |
623 | | - if ( tname.split( ':' ).length == 1 ) { |
624 | | - tObj["name"] = tname; |
625 | | - } else { |
626 | | - tObj["name"] = tname.split( ':' ).shift(); |
627 | | - tObj["arg"] = tname.split( ':' ).pop(); |
628 | | - } |
629 | | - |
630 | | - var pSet = ts.split( '\|' ); |
631 | | - pSet.splice( 0, 1 ); |
632 | | - if ( pSet.length ) { |
633 | | - tObj.param = new Array(); |
634 | | - for ( var pInx in pSet ) { |
635 | | - var tStr = pSet[ pInx ]; |
636 | | - // check for empty param |
637 | | - if ( tStr == '' ) { |
638 | | - tObj.param[ pInx ] = ''; |
639 | | - continue; |
640 | | - } |
641 | | - for ( var b = 0 ; b < tStr.length ; b++ ) { |
642 | | - if ( tStr[b] == '=' && b > 0 && b < tStr.length && tStr[b - 1] != '\\' ) { |
643 | | - // named param |
644 | | - tObj.param[ tStr.split( '=' ).shift() ] = tStr.split( '=' ).pop(); |
645 | | - } else { |
646 | | - // indexed param |
647 | | - tObj.param[ pInx ] = tStr; |
648 | | - } |
649 | | - } |
650 | | - } |
651 | | - } |
652 | | - return tObj; |
653 | | - } |
654 | | - function getMagicTxtFromTempNode( node ) { |
655 | | - node.tObj = parseTmplTxt ( node.t ); |
656 | | - // do magic swap if template key found in pMagicSet |
657 | | - if ( node.tObj.name in pMagicSet ) { |
658 | | - var nt = pMagicSet[ node.tObj.name ]( node.tObj ); |
659 | | - return nt; |
660 | | - } else { |
661 | | - // don't swap just return text |
662 | | - return node.t; |
663 | | - } |
664 | | - } |
665 | | - /** |
666 | | - * recurse_magic_swap |
667 | | - * |
668 | | - * go last child first swap upward: (could probably be integrated above somehow) |
669 | | - */ |
670 | | - var pNode = null; |
671 | | - function recurse_magic_swap( node ) { |
672 | | - if ( !pNode ) |
673 | | - pNode = node; |
674 | | - |
675 | | - if ( node['c'] ) { |
676 | | - // swap all the kids: |
677 | | - for ( var i in node['c'] ) { |
678 | | - var nt = recurse_magic_swap( node['c'][i] ); |
679 | | - // swap it into current |
680 | | - if ( node.t ) { |
681 | | - node.t = node.t.replace( node['c'][i].t, nt ); |
682 | | - } |
683 | | - // swap into parent |
684 | | - pNode.t = pNode.t.replace( node['c'][i].t, nt ); |
685 | | - } |
686 | | - // do the current node: |
687 | | - var nt = getMagicTxtFromTempNode( node ); |
688 | | - pNode.t = pNode.t.replace( node.t , nt ); |
689 | | - // run the swap for the outer most node |
690 | | - return node.t; |
691 | | - } else { |
692 | | - // node.t = getMagicFromTempObj( node.t ) |
693 | | - return getMagicTxtFromTempNode( node ); |
694 | | - } |
695 | | - } |
696 | | - // parse out the template node structure: |
697 | | - this.pNode = rdpp ( this.wikiText ); |
698 | | - // strip out the parent from the root |
699 | | - this.pNode['p'] = null; |
700 | | - |
701 | | - // do the recursive magic swap text: |
702 | | - this.pOut = recurse_magic_swap( this.pNode ); |
703 | | - |
704 | | - }, |
705 | | - /* |
706 | | - * parsed template api ~loosely based off of ~POM~ |
707 | | - * http://www.mediawiki.org/wiki/Extension:Page_Object_Model |
708 | | - */ |
709 | | - |
710 | | - /** |
711 | | - * templates |
712 | | - * |
713 | | - * gets a requested template from the wikitext (if available) |
714 | | - * |
715 | | - */ |
716 | | - templates: function( tname ) { |
717 | | - this.parse(); |
718 | | - var tmplSet = new Array(); |
719 | | - function getMatchingTmpl( node ) { |
720 | | - if ( node['c'] ) { |
721 | | - for ( var i in node['c'] ) { |
722 | | - getMatchingTmpl( node['c'] ); |
723 | | - } |
724 | | - } |
725 | | - if ( tname && node.tObj ) { |
726 | | - if ( node.tObj['name'] == tname ) |
727 | | - tmplSet.push( node.tObj ); |
728 | | - } else if ( node.tObj ) { |
729 | | - tmplSet.push( node.tObj ); |
730 | | - } |
731 | | - } |
732 | | - getMatchingTmpl( this.pNode ); |
733 | | - return tmplSet; |
734 | | - }, |
735 | | - |
736 | | - /** |
737 | | - * getTemplateVars |
738 | | - * returns a set of template values in a given wikitext page |
739 | | - * |
740 | | - * NOTE: should be integrated with the parser |
741 | | - */ |
742 | | - getTemplateVars: function(){ |
743 | | - //js_log('matching against: ' + wikiText); |
744 | | - templateVars = new Array(); |
745 | | - var tempVars = wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi); |
746 | | - |
747 | | - // Clean up results: |
748 | | - for(var i=0; i < tempVars.length; i++){ |
749 | | - //match |
750 | | - var tvar = tempVars[i].replace('{{{','').replace('}}}',''); |
751 | | - |
752 | | - // Strip anything after a | |
753 | | - if(tvar.indexOf('|') != -1){ |
754 | | - tvar = tvar.substr(0, tvar.indexOf('|')); |
755 | | - } |
756 | | - |
757 | | - // Check for duplicates: |
758 | | - var do_add=true; |
759 | | - for(var j=0; j < templateVars.length; j++){ |
760 | | - if( templateVars[j] == tvar) |
761 | | - do_add=false; |
762 | | - } |
763 | | - |
764 | | - // Add the template vars to the output obj |
765 | | - if(do_add) |
766 | | - templateVars.push( tvar ); |
767 | | - } |
768 | | - return templateVars; |
769 | | - }, |
770 | | - |
771 | | - /** |
772 | | - * Returns the transformed wikitext |
773 | | - * |
774 | | - * Build output from swapable index |
775 | | - * (all transforms must be expanded in parse stage and linearly rebuilt) |
776 | | - * Alternatively we could build output using a place-holder & replace system |
777 | | - * (this lets us be slightly more sloppy with ordering and indexes, but probably slower) |
778 | | - * |
779 | | - * Ideal: we build a 'wiki DOM' |
780 | | - * When editing you update the data structure directly |
781 | | - * Then in output time you just go DOM->html-ish output without re-parsing anything |
782 | | - */ |
783 | | - getHTML : function() { |
784 | | - // wikiText updates should invalidate pOut |
785 | | - if ( this.pOut == '' ) { |
786 | | - this.parse(); |
787 | | - } |
788 | | - return this.pOut; |
789 | | - } |
790 | | - }; |
791 | | - // return the parserObj |
792 | | - return new parseObj( wikiText, opt ) ; |
793 | | - } |
794 | | - |
795 | | - /* |
796 | | - * API and request functions |
797 | | - */ |
798 | | - $.getLocalApiUrl = function() { |
799 | | - if ( typeof wgServer != 'undefined' && typeof wgScriptPath != 'undefined' ) { |
800 | | - return wgServer + wgScriptPath + '/api.php'; |
801 | | - } |
802 | | - return false; |
803 | | - } |
804 | | - |
805 | | - /** |
806 | | - * Utility Functions |
807 | | - */ |
808 | | - |
809 | | - |
810 | | - /** |
811 | | - * parseUri 1.2.2 |
812 | | - * (c) Steven Levithan <stevenlevithan.com> |
813 | | - * MIT License |
814 | | - */ |
815 | | - $.parseUri = function (str) { |
816 | | - var o = $.parseUri.options, |
817 | | - m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), |
818 | | - uri = {}, |
819 | | - i = 14; |
820 | | - |
821 | | - while (i--) uri[o.key[i]] = m[i] || ""; |
822 | | - |
823 | | - uri[o.q.name] = {}; |
824 | | - uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { |
825 | | - if ($1) uri[o.q.name][$1] = $2; |
826 | | - }); |
827 | | - |
828 | | - return uri; |
829 | | - }; |
830 | | - $.parseUri.options = { |
831 | | - strictMode: false, |
832 | | - key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], |
833 | | - q: { |
834 | | - name: "queryKey", |
835 | | - parser: /(?:^|&)([^&=]*)=?([^&]*)/g |
836 | | - }, |
837 | | - parser: { |
838 | | - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, |
839 | | - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ |
840 | | - } |
841 | | - }; |
842 | | - |
843 | | - /** |
844 | | - * getAbsoluteUrl takes a src and returns the absolute location given the document.URL |
845 | | - * @param {String} src path or url |
846 | | - */ |
847 | | - $.absoluteUrl = function( src, contextUrl ){ |
848 | | - var pSrc = mw.parseUri( src ); |
849 | | - if( pSrc.protocol != '') |
850 | | - return src; |
851 | | - |
852 | | - // Get parent Url location the context URL |
853 | | - if( contextUrl){ |
854 | | - var pUrl = mw.parseUri( contextUrl ); |
855 | | - } else { |
856 | | - var pUrl = mw.parseUri( document.URL ); |
857 | | - } |
858 | | - // If a leading slash: |
859 | | - if( src.indexOf( '/' ) == 1 ){ |
860 | | - return pUrl.protocol + '://' + pUrl.authority + src; |
861 | | - }else{ |
862 | | - return pUrl.protocol + '://' + pUrl.authority + pUrl.directory + src; |
863 | | - } |
864 | | - }; |
865 | | - /** |
866 | | - * Takes in a string returns an xml dom object |
867 | | - */ |
868 | | - $.parseXML = function ( str ){ |
869 | | - if ( $j.browser.msie ) { |
870 | | - // Attempt to parse as XML for IE |
871 | | - var xmldata = new ActiveXObject( "Microsoft.XMLDOM" ); |
872 | | - xmldata.async = "false"; |
873 | | - try{ |
874 | | - xmldata.loadXML( str ); |
875 | | - return xmldata; |
876 | | - } catch (e){ |
877 | | - js_log( 'XML parse ERROR: ' + e.message ); |
878 | | - return false; |
879 | | - } |
880 | | - } |
881 | | - |
882 | | - // For others (Firefox, Safari etc, older browsers |
883 | | - // Some don't have native DOMParser either fallback defined bellow. |
884 | | - try { |
885 | | - var xmldata = ( new DOMParser() ).parseFromString( str, "text/xml" ); |
886 | | - } catch ( e ) { |
887 | | - js_log( 'XML parse ERROR: ' + e.message ); |
888 | | - return false; |
889 | | - } |
890 | | - return xmldata; |
891 | | - } |
892 | | -} )( window.mw ); |
893 | | - |
894 | | -// Get the mv_embed location if it has not been set |
895 | | -if ( !mv_embed_path ) { |
896 | | - var mv_embed_path = getMvEmbedPath(); |
897 | | -} |
898 | | - |
899 | | -// load in js2 stopgap into proper location: |
900 | | -if ( typeof gMsg != 'undefined' ) { |
901 | | - mw.lang.loadGM( gMsg ) |
902 | | -} |
903 | | - |
904 | | -// setup legacy global shortcuts: |
905 | | -var loadGM = mw.lang.loadGM; |
906 | | -var loadRS = mw.lang.loadRS; |
907 | | -var gM = mw.lang.gM; |
908 | | - |
909 | | -// All default messages in [English] should be overwritten by the CMS language message system. |
910 | | -mw.lang.loadGM( { |
911 | | - "mwe-loading_txt" : "Loading ...", |
912 | | - "mwe-size-gigabytes" : "$1 GB", |
913 | | - "mwe-size-megabytes" : "$1 MB", |
914 | | - "mwe-size-kilobytes" : "$1 K", |
915 | | - "mwe-size-bytes" : "$1 B", |
916 | | - "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2", |
917 | | - "mwe-loading-add-media-wiz" : "Loading add media wizard", |
918 | | - "mwe-apiproxy-setup" : "Setting up API proxy", |
919 | | - "mwe-load-drag-item" : "Loading dragged item", |
920 | | - "mwe-ok" : "OK", |
921 | | - "mwe-cancel" : "Cancel" |
922 | | -} ); |
923 | | - |
924 | | - |
925 | | -// Get the loading image |
926 | | -function mv_get_loading_img( style, class_attr ) { |
927 | | - var style_txt = ( style ) ? style:''; |
928 | | - var class_attr = ( class_attr ) ? 'class="' + class_attr + '"' : 'class="mv_loading_img"'; |
929 | | - return '<div ' + class_attr + ' style="' + style + '"></div>'; |
930 | | -} |
931 | | - |
932 | | -function mv_set_loading( target, load_id ) { |
933 | | - var id_attr = ( load_id ) ? ' id="' + load_id + '" ':''; |
934 | | - $j( target ).append( '<div ' + id_attr + ' style="position:absolute;top:0px;left:0px;height:100%;width:100%;' + |
935 | | - 'background-color:#FFF;">' + |
936 | | - mv_get_loading_img( 'top:30px;left:30px' ) + |
937 | | - '</div>' ); |
938 | | -} |
939 | | - |
940 | | -/** |
941 | | -* mvJsLoader class handles initialization and js file loads |
942 | | -*/ |
943 | | -var mvJsLoader = { |
944 | | - libreq : { }, |
945 | | - libs : { }, |
946 | | - |
947 | | - // Base lib flags |
948 | | - onReadyEvents: new Array(), |
949 | | - doneReadyEvents: false, |
950 | | - jQuerySetupFlag: false, |
951 | | - |
952 | | - // To keep consistency across threads |
953 | | - ptime: 0, |
954 | | - ctime: 0, |
955 | | - |
956 | | - load_error: false, // Load error flag (false by default) |
957 | | - load_time: 0, |
958 | | - callbacks: new Array(), |
959 | | - cur_path: null, |
960 | | - missing_path : null, |
961 | | - doLoad: function( loadLibs, callback ) { |
962 | | - this.ctime++; |
963 | | - if ( loadLibs && loadLibs.length != 0 ) { |
964 | | - // js_log("doLoad setup::" + JSON.stringify( loadLibs ) ); |
965 | | - // Set up this.libs |
966 | | - // First check if we already have this library loaded |
967 | | - var all_libs_loaded = true; |
968 | | - for ( var i = 0; i < loadLibs.length; i++ ) { |
969 | | - // Check if the library is already loaded |
970 | | - if ( ! this.checkObjPath( loadLibs[i] ) ) { |
971 | | - all_libs_loaded = false; |
972 | | - } |
973 | | - } |
974 | | - if ( all_libs_loaded ) { |
975 | | - js_log( 'Libraries ( ' + loadLibs + ') already loaded... skipping load request' ); |
976 | | - callback(); |
977 | | - return; |
978 | | - } |
979 | | - |
980 | | - // Do a check for any CSS we may need and get it |
981 | | - for ( var i = 0; i < loadLibs.length; i++ ) { |
982 | | - if ( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ) { |
983 | | - loadExternalCss( mv_embed_path + mvCssPaths[ loadLibs[i] ] ); |
984 | | - } |
985 | | - } |
986 | | - |
987 | | - // Check if we should use the script loader to combine all the requests into one |
988 | | - // ( the scriptloader defines the mwSlScript global ) |
989 | | - if ( typeof mwSlScript != 'undefined' ) { |
990 | | - var class_set = ''; |
991 | | - var last_class = ''; |
992 | | - var coma = ''; |
993 | | - for ( var i = 0; i < loadLibs.length; i++ ) { |
994 | | - var curLib = loadLibs[i]; |
995 | | - // Only add if not included yet: |
996 | | - if ( ! this.checkObjPath( curLib ) ) { |
997 | | - class_set += coma + curLib; |
998 | | - last_class = curLib; |
999 | | - coma = ','; |
1000 | | - } |
1001 | | - } |
1002 | | - // Build the url to the scriptServer striping its request parameters: |
1003 | | - var puri = mw.parseUri( getMvEmbedURL() ); |
1004 | | - if ( ( getMvEmbedURL().indexOf( '://' ) != -1 ) |
1005 | | - && puri.host != mw.parseUri( document.URL ).host ) |
1006 | | - { |
1007 | | - var scriptPath = puri.protocol + '://' + puri.authority + puri.path; |
1008 | | - } else { |
1009 | | - var scriptPath = puri.path; |
1010 | | - } |
1011 | | - // js_log('scriptServer Path is: ' + scriptPath + "\n host script path:" + getMvEmbedURL() ); |
1012 | | - this.libs[ last_class ] = scriptPath + '?class=' + class_set + |
1013 | | - '&' + getMwReqParam(); |
1014 | | - |
1015 | | - } else { |
1016 | | - // Do many requests |
1017 | | - for ( var i = 0; i < loadLibs.length; i++ ) { |
1018 | | - var curLib = loadLibs[i]; |
1019 | | - if ( curLib ) { |
1020 | | - var libLoc = mvGetClassPath( curLib ); |
1021 | | - // Do a direct load of the file (pass along unique request id from |
1022 | | - // request or mv_embed Version ) |
1023 | | - var qmark = ( libLoc.indexOf( '?' ) !== true ) ? '?' : '&'; |
1024 | | - this.libs[curLib] = mv_embed_path + libLoc + qmark + getMwReqParam(); |
1025 | | - } |
1026 | | - } |
1027 | | - } |
1028 | | - } |
1029 | | - |
1030 | | - if ( callback ) { |
1031 | | - this.callbacks.push( callback ); |
1032 | | - } |
1033 | | - if ( this.checkLoading() ) { |
1034 | | - // @@todo we should check the <script> Element .onLoad property to |
1035 | | - // make sure its just not a very slow connection |
1036 | | - // (even though the class is not loaded) |
1037 | | - if ( this.load_time++ > 4000 ) { // Time out after ~80 seconds |
1038 | | - js_log( gM( 'mwe-error_load_lib', [mvGetClassPath( this.missing_path ), this.missing_path] ) ); |
1039 | | - this.load_error = true; |
1040 | | - } else { |
1041 | | - setTimeout( 'mvJsLoader.doLoad()', 20 ); |
1042 | | - } |
1043 | | - } else { |
1044 | | - // js_log('checkLoading passed. Running callbacks...'); |
1045 | | - // Only do callbacks if we are in the same instance (weird concurrency issue) |
1046 | | - var cb_count = 0; |
1047 | | - for ( var i = 0; i < this.callbacks.length; i++ ) |
1048 | | - cb_count++; |
1049 | | - // js_log('RESET LIBS: loading is: '+ loading + ' callback count: '+cb_count + |
1050 | | - // ' p:'+ this.ptime +' c:'+ this.ctime); |
1051 | | - |
1052 | | - // Reset the libs |
1053 | | - this.libs = { }; |
1054 | | - // js_log('done loading, do call: ' + this.callbacks[0] ); |
1055 | | - while ( this.callbacks.length != 0 ) { |
1056 | | - if ( this.ptime == this.ctime - 1 ) { // Enforce thread consistency |
1057 | | - this.callbacks.pop()(); |
1058 | | - // func = this.callbacks.pop(); |
1059 | | - // js_log(' run: '+this.ctime+ ' p: ' + this.ptime + ' ' +loading+ ' :'+ func); |
1060 | | - // func(); |
1061 | | - } else { |
1062 | | - // Re-issue doLoad ( ptime will be set to ctime so we should catch up) |
1063 | | - setTimeout( 'mvJsLoader.doLoad()', 25 ); |
1064 | | - break; |
1065 | | - } |
1066 | | - } |
1067 | | - } |
1068 | | - this.ptime = this.ctime; |
1069 | | - }, |
1070 | | - doLoadDepMode: function( loadChain, callback ) { |
1071 | | - // Firefox executes JS in the order in which it is included, so just directly issue the request |
1072 | | - if ( $j.browser.firefox ) { |
1073 | | - var loadSet = []; |
1074 | | - for ( var i = 0; i < loadChain.length; i++ ) { |
1075 | | - for ( var j = 0; j < loadChain[i].length; j++ ) { |
1076 | | - loadSet.push( loadChain[i][j] ); |
1077 | | - } |
1078 | | - } |
1079 | | - mvJsLoader.doLoad( loadSet, callback ); |
1080 | | - } else { |
1081 | | - // Safari and IE tend to execute out of order so load with dependency checks |
1082 | | - mvJsLoader.doLoad( loadChain.shift(), function() { |
1083 | | - if ( loadChain.length != 0 ) { |
1084 | | - mvJsLoader.doLoadDepMode( loadChain, callback ); |
1085 | | - } else { |
1086 | | - callback(); |
1087 | | - } |
1088 | | - } ); |
1089 | | - } |
1090 | | - }, |
1091 | | - checkLoading: function() { |
1092 | | - var loading = 0; |
1093 | | - var i = null; |
1094 | | - for ( var i in this.libs ) { // for/in loop is OK on an object |
1095 | | - if ( !this.checkObjPath( i ) ) { |
1096 | | - if ( !this.libreq[i] ) { |
1097 | | - loadExternalJs( this.libs[i] ); |
1098 | | - } |
1099 | | - this.libreq[i] = 1; |
1100 | | - // js_log("has not yet loaded: " + i); |
1101 | | - loading = 1; |
1102 | | - } |
1103 | | - } |
1104 | | - return loading; |
1105 | | - }, |
1106 | | - checkObjPath: function( libVar ) { |
1107 | | - if ( !libVar ) |
1108 | | - return false; |
1109 | | - var objPath = libVar.split( '.' ) |
1110 | | - var cur_path = ''; |
1111 | | - for ( var p = 0; p < objPath.length; p++ ) { |
1112 | | - cur_path = ( cur_path == '' ) ? cur_path + objPath[p] : cur_path + '.' + objPath[p]; |
1113 | | - eval( 'var ptest = typeof ( ' + cur_path + ' ); ' ); |
1114 | | - if ( ptest == 'undefined' ) { |
1115 | | - this.missing_path = cur_path; |
1116 | | - return false; |
1117 | | - } |
1118 | | - } |
1119 | | - this.cur_path = cur_path; |
1120 | | - return true; |
1121 | | - }, |
1122 | | - /** |
1123 | | - * checks for jQuery and adds the $j noConflict var |
1124 | | - */ |
1125 | | - jQueryCheck: function( callback ) { |
1126 | | - // js_log( 'jQueryCheck::' + this.jQuerySetupFlag); |
1127 | | - var _this = this; |
1128 | | - if ( _global['$j'] && _this.jQuerySetupFlag ) { |
1129 | | - callback(); // call the callback now |
1130 | | - } |
1131 | | - // Load jQuery |
1132 | | - _this.doLoad( [ |
1133 | | - 'window.jQuery' |
1134 | | - ], function() { |
1135 | | - // only do the $j setup once: |
1136 | | - if ( !_global['$j'] ) { |
1137 | | - _global['$j'] = jQuery.noConflict(); |
1138 | | - } |
1139 | | - if ( _this.jQuerySetupFlag == false ) { |
1140 | | - // js_log('setup mv_embed jQuery bindings'); |
1141 | | - // Setup our global settings using the (jQuery helper) |
1142 | | - |
1143 | | - // Set up the skin path |
1144 | | - _global['mv_jquery_skin_path'] = mv_embed_path + 'jquery/jquery.ui/themes/' + mw.conf['jui_skin'] + '/'; |
1145 | | - _global['mv_skin_img_path'] = mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/images/'; |
1146 | | - _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg'; |
1147 | | - |
1148 | | - // Make sure the skin/style sheets are always available: |
1149 | | - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
1150 | | - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/styles.css' ); |
1151 | | - |
1152 | | - // Set up AJAX to not send dynamic URLs for loading scripts (we control that with |
1153 | | - // the scriptLoader) |
1154 | | - $j.ajaxSetup( { |
1155 | | - cache: true |
1156 | | - } ); |
1157 | | - |
1158 | | - js_log( 'jQuery loaded into $j' ); |
1159 | | - // Set up mvEmbed jQuery bindings and config based dependencies |
1160 | | - mv_jqueryBindings(); |
1161 | | - _this.jQuerySetupFlag = true; |
1162 | | - |
1163 | | - // js_log('should run callback: ' + callback); |
1164 | | - // Run the callback if not already run above |
1165 | | - if ( callback ) { |
1166 | | - callback(); |
1167 | | - } |
1168 | | - } |
1169 | | - } ); |
1170 | | - }, |
1171 | | - embedPlayerCheck:function( callback ) { |
1172 | | - var _this = this; |
1173 | | - js_log( 'embedPlayerCheck:' ); |
1174 | | - // Make sure we have jQuery |
1175 | | - _this.jQueryCheck( function() { |
1176 | | - // set class videonojs to loading |
1177 | | - $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) ); |
1178 | | - // Set up the embed video player class request: (include the skin js as well) |
1179 | | - var depReq = [ |
1180 | | - [ |
1181 | | - '$j.ui', |
1182 | | - 'embedPlayer', |
1183 | | - 'ctrlBuilder', |
1184 | | - '$j.cookie' |
1185 | | - ], |
1186 | | - [ |
1187 | | - '$j.ui.slider' |
1188 | | - ] |
1189 | | - ]; |
1190 | | - |
1191 | | - // add any requested skins (supports multiple skins per single page) |
1192 | | - if ( mw.skin_list ) { |
1193 | | - for ( var i in mw.skin_list ) { |
1194 | | - depReq[0].push( mw.skin_list[i] + 'Config' ); |
1195 | | - } |
1196 | | - } |
1197 | | - |
1198 | | - // Add PNG fix if needed: |
1199 | | - if ( $j.browser.msie || $j.browser.version < 7 ) |
1200 | | - depReq[0].push( '$j.fn.pngFix' ); |
1201 | | - |
1202 | | - // load the video libs: |
1203 | | - _this.doLoadDepMode( depReq, function() { |
1204 | | - embedTypes.init(); |
1205 | | - callback(); |
1206 | | - $j( '.videonojs' ).remove(); |
1207 | | - } ); |
1208 | | - } ); |
1209 | | - }, |
1210 | | - addLoadEvent: function( fn ) { |
1211 | | - // js_log('add ready event: ' + fn ); |
1212 | | - this.onReadyEvents.push( fn ); |
1213 | | - }, |
1214 | | - // Check the jQuery flag. This way, when remote embedding, we don't load jQuery |
1215 | | - // unless js2AddOnloadHook was used or there is video on the page. |
1216 | | - runQueuedFunctions: function() { |
1217 | | - js_log( "runQueuedFunctions" ); |
1218 | | - var _this = this; |
1219 | | - this.jQueryCheck( function() { |
1220 | | - _this.runReadyEvents(); |
1221 | | - _this.doneReadyEvents = true; |
1222 | | - } ); |
1223 | | - }, |
1224 | | - runReadyEvents: function() { |
1225 | | - js_log( "runReadyEvents" + this.onReadyEvents.length ); |
1226 | | - while ( this.onReadyEvents.length ) { |
1227 | | - var func = this.onReadyEvents.shift(); |
1228 | | - // js_log('run onReady:: ' + func ); |
1229 | | - func(); |
1230 | | - } |
1231 | | - } |
1232 | | -} |
1233 | | - |
1234 | | -// Shortcut ( @@todo consolidate shortcuts & re-factor mvJsLoader ) |
1235 | | -function mwLoad( loadSet, callback ) { |
1236 | | - mvJsLoader.doLoad( loadSet, callback ); |
1237 | | -} |
1238 | | -// mw.shortcut |
1239 | | -mw.load = mwLoad; |
1240 | | - |
1241 | | -// Load an external JS file. Similar to jquery .require plugin, |
1242 | | -// but checks for object availability rather than load state. |
1243 | | - |
1244 | | -/*********** INITIALIZATION CODE ************* |
1245 | | - * This will get called when the DOM is ready |
1246 | | - *********************************************/ |
1247 | | -/* jQuery .ready does not work when jQuery is loaded dynamically. |
1248 | | - * For an example of the problem see: 1.1.3 working: http://pastie.caboo.se/92588 |
1249 | | - * and >= 1.1.4 not working: http://pastie.caboo.se/92595 |
1250 | | - * $j(document).ready( function(){ */ |
1251 | | -function mwdomReady( force ) { |
1252 | | - js_log( 'f:mwdomReady:' ); |
1253 | | - if ( !force && mw.init_done ) { |
1254 | | - js_log( "mw done, do nothing..." ); |
1255 | | - return false; |
1256 | | - } |
1257 | | - mw.init_done = true; |
1258 | | - // Handle the execution of queued functions with jQuery "ready" |
1259 | | - |
1260 | | - // Check if this page has a video, audio or playlist tag |
1261 | | - var e = [ |
1262 | | - document.getElementsByTagName( "video" ), |
1263 | | - document.getElementsByTagName( "audio" ), |
1264 | | - document.getElementsByTagName( "playlist" ) |
1265 | | - ]; |
1266 | | - if ( e[0].length != 0 || e[1].length != 0 || e[2].length != 0 ) { |
1267 | | - // look for any skin classes we have to load: |
1268 | | - for ( var j in e ) { |
1269 | | - for ( var k in e[j] ) { |
1270 | | - if ( e[j][k] && typeof( e[j][k] ) == 'object' ) { |
1271 | | - var sn = e[j][k].getAttribute( 'class' ); |
1272 | | - // Try "className" for good old IE |
1273 | | - if( !sn ){ |
1274 | | - var sn = e[j][k].getAttribute( 'className' ); |
1275 | | - } |
1276 | | - if ( sn && sn != '' ) { |
1277 | | - for ( var n = 0; n < mw.valid_skins.length; n++ ) { |
1278 | | - if ( sn.indexOf( mw.valid_skins[n] ) !== -1 ) { |
1279 | | - mw.skin_list.push( mw.valid_skins[n] ); |
1280 | | - } |
1281 | | - } |
1282 | | - } |
1283 | | - } |
1284 | | - } |
1285 | | - } |
1286 | | - // Load libs and process videos |
1287 | | - mvJsLoader.embedPlayerCheck( function() { |
1288 | | - // Convert all supported elements into embed players: |
1289 | | - $j.embedPlayers( function(){ |
1290 | | - // Run any queued global events: |
1291 | | - mvJsLoader.runQueuedFunctions(); |
1292 | | - }); |
1293 | | - } ); |
1294 | | - } else { |
1295 | | - mvJsLoader.runQueuedFunctions(); |
1296 | | - } |
1297 | | -} |
1298 | | - |
1299 | | -// js2AddOnloadHook: ensure jQuery and the DOM are ready |
1300 | | -function js2AddOnloadHook( func ) { |
1301 | | - // js_log('js2AddOnloadHook:: jquery:' +func); |
1302 | | - // If we are ready run directly else add load event: |
1303 | | - if ( mvJsLoader.doneReadyEvents ) { |
1304 | | - //js_log( 'run queued event: ' + func ); |
1305 | | - func(); |
1306 | | - } else { |
1307 | | - //js_log( 'add to load event: ' + func ); |
1308 | | - mvJsLoader.addLoadEvent( func ); |
1309 | | - } |
1310 | | -} |
1311 | | -// Deprecated mwAddOnloadHook in favour of js2 naming (for clear separation of js2 code from old MW code |
1312 | | -var mwAddOnloadHook = js2AddOnloadHook; |
1313 | | -/* |
1314 | | - * This function allows for targeted rewriting |
1315 | | - */ |
1316 | | -function rewrite_by_id( vid_id, ready_callback ) { |
1317 | | - js_log( 'f:rewrite_by_id: ' + vid_id ); |
1318 | | - // Force a re-check of the DOM for playlist or video elements: |
1319 | | - mvJsLoader.eembedPlayerheck( function() { |
1320 | | - mv_video_embed( ready_callback, vid_id ); |
1321 | | - } ); |
1322 | | -} |
1323 | | - |
1324 | | - |
1325 | | -/*********** INITIALIZATION CODE ************* |
1326 | | - * set DOM-ready callback to init_mv_embed |
1327 | | - *********************************************/ |
1328 | | -// for Mozilla / modern browsers |
1329 | | -if ( document.addEventListener ) { |
1330 | | - document.addEventListener( "DOMContentLoaded", mwdomReady, false ); |
1331 | | -} |
1332 | | -var temp_f; |
1333 | | -if ( window.onload ) { |
1334 | | - temp_f = window.onload; |
1335 | | -} |
1336 | | -// Use the onload method as a backup |
1337 | | -window.onload = function () { |
1338 | | - if ( temp_f ) |
1339 | | - temp_f(); |
1340 | | - mwdomReady(); |
1341 | | -} |
1342 | | - |
1343 | | -/* |
1344 | | - * Store all the mwEmbed jQuery-specific bindings |
1345 | | - * (set up after jQuery is available). |
1346 | | - * |
1347 | | - * These functions are generally are loaders that do the dynamic mapping of |
1348 | | - * dependencies for a given component |
1349 | | - * |
1350 | | - * |
1351 | | - */ |
1352 | | -function mv_jqueryBindings() { |
1353 | | - js_log( 'mv_jqueryBindings' ); |
1354 | | - ( function( $ ) { |
1355 | | - /* |
1356 | | - * dragDrop file loader |
1357 | | - */ |
1358 | | - $.fn.dragFileUpload = function ( conf ) { |
1359 | | - if ( this.selector ) { |
1360 | | - var _this = this; |
1361 | | - // load the dragger and "setup" |
1362 | | - mw.load( ['$j.fn.dragDropFile'], function() { |
1363 | | - $j( _this.selector ).dragDropFile(); |
1364 | | - } ); |
1365 | | - } |
1366 | | - } |
1367 | | - /* |
1368 | | - * apiProxy Loader loader: |
1369 | | - * |
1370 | | - * @param mode is either 'server' or 'client' |
1371 | | - */ |
1372 | | - $.apiProxy = function( mode, pConf, callback ) { |
1373 | | - js_log( 'do apiProxy setup' ); |
1374 | | - mvJsLoader.doLoad( [ |
1375 | | - 'mw.proxy', |
1376 | | - 'JSON' |
1377 | | - ], function() { |
1378 | | - // do the proxy setup or |
1379 | | - if ( mode == 'client' ) { |
1380 | | - // just do the setup (no callbcak for client setup) |
1381 | | - mw.proxy.client( pConf ); |
1382 | | - if ( callback ) |
1383 | | - callback(); |
1384 | | - } else if ( mode == 'server' ) { |
1385 | | - // do the request with the callback |
1386 | | - mw.proxy.server( pConf , callback ); |
1387 | | - } |
1388 | | - } ); |
1389 | | - } |
1390 | | - |
1391 | | - // non selector based add-media-wizard direct invocation with loader |
1392 | | - $.addMediaWiz = function( iObj, callback ) { |
1393 | | - js_log( ".addMediaWiz call" ); |
1394 | | - // check if already loaded: |
1395 | | - if ( _global['rsdMVRS'] ) { |
1396 | | - _global['rsdMVRS'].showDialog(); |
1397 | | - if ( callback ) |
1398 | | - callback( _global['rsdMVRS'] ); |
1399 | | - return ; |
1400 | | - } |
1401 | | - // display a loader: |
1402 | | - $.addLoaderDialog( gM( 'mwe-loading-add-media-wiz' ) ); |
1403 | | - // load the addMedia wizard without a target: |
1404 | | - $.fn.addMediaWiz ( iObj, function( amwObj ) { |
1405 | | - // close the dialog |
1406 | | - $.closeLoaderDialog(); |
1407 | | - // do the add-media-wizard display |
1408 | | - amwObj.createUI(); |
1409 | | - // call the parent callback: |
1410 | | - if ( callback ) |
1411 | | - callback( _global['rsdMVRS'] ); |
1412 | | - } ); |
1413 | | - } |
1414 | | - $.fn.addMediaWiz = function( iObj, callback ) { |
1415 | | - if ( this.selector ) { |
1416 | | - // First set the cursor for the button to "loading" |
1417 | | - $j( this.selector ).css( 'cursor', 'wait' ).attr( 'title', gM( 'mwe-loading_txt' ) ); |
1418 | | - // set the target: |
1419 | | - iObj['target_invoke_button'] = this.selector; |
1420 | | - } |
1421 | | - |
1422 | | - // Load the mv_embed_base skin: |
1423 | | - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
1424 | | - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/styles.css' ); |
1425 | | - // Load all the required libs: |
1426 | | - mvJsLoader.jQueryCheck( function() { |
1427 | | - // Load with staged dependencies (for IE that does not execute in order) |
1428 | | - mvJsLoader.doLoadDepMode( [ |
1429 | | - [ 'remoteSearchDriver', |
1430 | | - '$j.cookie', |
1431 | | - '$j.fn.textSelection', |
1432 | | - '$j.ui' |
1433 | | - ], [ |
1434 | | - '$j.ui.resizable', |
1435 | | - '$j.ui.draggable', |
1436 | | - '$j.ui.dialog', |
1437 | | - '$j.ui.tabs', |
1438 | | - '$j.ui.sortable' |
1439 | | - ] |
1440 | | - ], function() { |
1441 | | - iObj['instance_name'] = 'rsdMVRS'; |
1442 | | - if ( ! _global['rsdMVRS'] ) |
1443 | | - _global['rsdMVRS'] = new remoteSearchDriver( iObj ); |
1444 | | - if ( callback ) { |
1445 | | - callback( _global['rsdMVRS'] ); |
1446 | | - } |
1447 | | - } ); |
1448 | | - } ); |
1449 | | - } |
1450 | | - /* |
1451 | | - * Sequencer loader |
1452 | | - */ |
1453 | | - $.fn.sequencer = function( iObj, callback ) { |
1454 | | - // Debugger |
1455 | | - iObj['target_sequence_container'] = this.selector; |
1456 | | - // Issue a request to get the CSS file (if not already included): |
1457 | | - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
1458 | | - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/mv_sequence.css' ); |
1459 | | - // Make sure we have the required mv_embed libs (they are not loaded when no video |
1460 | | - // element is on the page) |
1461 | | - mvJsLoader.eembedPlayerheck( function() { |
1462 | | - // Load the playlist object and then the jQuery UI stuff: |
1463 | | - mvJsLoader.doLoadDepMode( [ |
1464 | | - [ |
1465 | | - 'mvPlayList', |
1466 | | - '$j.ui', |
1467 | | - '$j.contextMenu', |
1468 | | - 'JSON', |
1469 | | - 'mvSequencer' |
1470 | | - ], |
1471 | | - [ |
1472 | | - '$j.ui.accordion', |
1473 | | - '$j.ui.dialog', |
1474 | | - '$j.ui.droppable', |
1475 | | - '$j.ui.draggable', |
1476 | | - '$j.ui.progressbar', |
1477 | | - '$j.ui.sortable', |
1478 | | - '$j.ui.resizable', |
1479 | | - '$j.ui.slider', |
1480 | | - '$j.ui.tabs' |
1481 | | - ] |
1482 | | - ], function() { |
1483 | | - js_log( 'calling new mvSequencer' ); |
1484 | | - // Initialise the sequence object (it will take over from there) |
1485 | | - // No more than one mvSeq obj for now: |
1486 | | - if ( !_global['mvSeq'] ) { |
1487 | | - _global['mvSeq'] = new mvSequencer( iObj ); |
1488 | | - } else { |
1489 | | - js_log( 'mvSeq already init' ); |
1490 | | - } |
1491 | | - } ); |
1492 | | - } ); |
1493 | | - } |
1494 | | - /* |
1495 | | - * The Firefogg jQuery function: |
1496 | | - * @@note This Firefogg invocation could be made to work more like real jQuery plugins |
1497 | | - */ |
1498 | | - var queuedFirefoggConf = { }; |
1499 | | - $.fn.firefogg = function( iObj, callback ) { |
1500 | | - if ( !iObj ) |
1501 | | - iObj = { }; |
1502 | | - // Add the base theme CSS: |
1503 | | - loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
1504 | | - loadExternalCss( mv_embed_path + 'skins/' + mw.conf['skin_name'] + '/styles.css' ); |
1505 | | - |
1506 | | - // Check if we already have Firefogg loaded (the call just updates the element's |
1507 | | - // properties) |
1508 | | - var sElm = $j( this.selector ).get( 0 ); |
1509 | | - if ( sElm['firefogg'] ) { |
1510 | | - if ( sElm['firefogg'] == 'loading' ) { |
1511 | | - js_log( "Queued firefogg operations ( firefogg " + |
1512 | | - "not done loading ) " ); |
1513 | | - $j.extend( queuedFirefoggConf, iObj ); |
1514 | | - return false; |
1515 | | - } |
1516 | | - // Update properties |
1517 | | - for ( var i in iObj ) { |
1518 | | - js_log( "firefogg::updated: " + i + ' to ' + iObj[i] ); |
1519 | | - sElm['firefogg'][i] = iObj[i]; |
1520 | | - } |
1521 | | - return sElm['firefogg']; |
1522 | | - } else { |
1523 | | - // Avoid concurrency |
1524 | | - sElm['firefogg'] = 'loading'; |
1525 | | - } |
1526 | | - // Add the selector |
1527 | | - iObj['selector'] = this.selector; |
1528 | | - |
1529 | | - var loadSet = [ |
1530 | | - [ |
1531 | | - 'mvBaseUploadInterface', |
1532 | | - 'mvFirefogg', |
1533 | | - '$j.ui' |
1534 | | - ], |
1535 | | - [ |
1536 | | - '$j.ui.progressbar', |
1537 | | - '$j.ui.dialog', |
1538 | | - '$j.ui.draggable' |
1539 | | - ] |
1540 | | - ]; |
1541 | | - if ( iObj.encoder_interface ) { |
1542 | | - loadSet.push( [ |
1543 | | - 'mvAdvFirefogg', |
1544 | | - '$j.cookie', |
1545 | | - '$j.ui.accordion', |
1546 | | - '$j.ui.slider', |
1547 | | - '$j.ui.datepicker' |
1548 | | - ] ); |
1549 | | - } |
1550 | | - // Make sure we have everything loaded that we need: |
1551 | | - mvJsLoader.doLoadDepMode( loadSet, function() { |
1552 | | - js_log( 'firefogg libs loaded. target select:' + iObj.selector ); |
1553 | | - // Select interface provider based on whether we want to include the |
1554 | | - // encoder interface or not |
1555 | | - if ( iObj.encoder_interface ) { |
1556 | | - var myFogg = new mvAdvFirefogg( iObj ); |
1557 | | - } else { |
1558 | | - var myFogg = new mvFirefogg( iObj ); |
1559 | | - } |
1560 | | - if ( myFogg ) { |
1561 | | - myFogg.doRewrite( callback ); |
1562 | | - var selectorElement = $j( iObj.selector ).get( 0 ); |
1563 | | - selectorElement['firefogg'] = myFogg; |
1564 | | - |
1565 | | - js_log( 'pre:' + selectorElement['firefogg']['firefogg_form_action'] ) |
1566 | | - if ( queuedFirefoggConf ) |
1567 | | - $j.extend( selectorElement['firefogg'], queuedFirefoggConf ); |
1568 | | - js_log( 'post:' + selectorElement['firefogg']['firefogg_form_action'] ) |
1569 | | - } |
1570 | | - } ); |
1571 | | - } |
1572 | | - // Take an input player as the selector and expose basic rendering controls |
1573 | | - $.fn.firefoggRender = function( iObj, callback ) { |
1574 | | - // Check if we already have render loaded then just pass on updates/actions |
1575 | | - var sElm = $j( this.selector ).get( 0 ); |
1576 | | - //add a special attribute to the selector: |
1577 | | - if ( sElm['fogg_render'] ) { |
1578 | | - if ( sElm['fogg_render'] == 'loading' ) { |
1579 | | - js_log( "Error: called firefoggRender while loading" ); |
1580 | | - return false; |
1581 | | - } |
1582 | | - // Call or update the property: |
1583 | | - } |
1584 | | - sElm['fogg_render'] = 'loading'; |
1585 | | - // Add the selector |
1586 | | - iObj['player_target'] = this.selector; |
1587 | | - mvJsLoader.doLoad( [ |
1588 | | - 'mvBaseUploadInterface', |
1589 | | - 'mvFirefogg', |
1590 | | - 'mvFirefoggRender' |
1591 | | - ], function() { |
1592 | | - // Attach the firefoggRender obj to the selected elm: |
1593 | | - sElm['fogg_render'] = new mvFirefoggRender( iObj ); |
1594 | | - if ( callback && typeof callback == 'function' ) |
1595 | | - callback( sElm['fogg_render'] ); |
1596 | | - } ); |
1597 | | - } |
1598 | | - |
1599 | | - $.fn.baseUploadInterface = function( iObj ) { |
1600 | | - mvJsLoader.doLoadDepMode( [ |
1601 | | - [ |
1602 | | - 'mvBaseUploadInterface', |
1603 | | - '$j.ui', |
1604 | | - ], |
1605 | | - [ |
1606 | | - '$j.ui.progressbar', |
1607 | | - '$j.ui.dialog' |
1608 | | - ] |
1609 | | - ], function() { |
1610 | | - myUp = new mvBaseUploadInterface( iObj ); |
1611 | | - myUp.setupForm(); |
1612 | | - } ); |
1613 | | - } |
1614 | | - |
1615 | | - // Shortcut to a themed button |
1616 | | - $.btnHtml = function( msg, className, iconId, opt ) { |
1617 | | - if ( !opt ) |
1618 | | - opt = { }; |
1619 | | - var href = ( opt.href ) ? opt.href : '#'; |
1620 | | - var target_attr = ( opt.target ) ? ' target="' + opt.target + '" ' : ''; |
1621 | | - var style_attr = ( opt.style ) ? ' style="' + opt.style + '" ' : ''; |
1622 | | - return '<a href="' + href + '" ' + target_attr + style_attr + |
1623 | | - ' class="ui-state-default ui-corner-all ui-icon_link ' + |
1624 | | - className + '"><span class="ui-icon ui-icon-' + iconId + '" ></span>' + |
1625 | | - '<span class="btnText">' + msg + '</span></a>'; |
1626 | | - } |
1627 | | - // Shortcut to bind hover state |
1628 | | - $.fn.btnBind = function() { |
1629 | | - $j( this ).hover( |
1630 | | - function() { |
1631 | | - $j( this ).addClass( 'ui-state-hover' ); |
1632 | | - }, |
1633 | | - function() { |
1634 | | - $j( this ).removeClass( 'ui-state-hover' ); |
1635 | | - } |
1636 | | - ) |
1637 | | - return this; |
1638 | | - } |
1639 | | - /** |
1640 | | - * resize the dialog to fit the window |
1641 | | - */ |
1642 | | - $.fn.dialogFitWindow = function( opt ) { |
1643 | | - var opt_default = { 'hspace':50, 'vspace':50 }; |
1644 | | - if ( !opt ) |
1645 | | - var opt = { }; |
1646 | | - $j.extend( opt, opt_default ); |
1647 | | - $j( this.selector ).dialog( 'option', 'width', $j( window ).width() - opt.hspace ); |
1648 | | - $j( this.selector ).dialog( 'option', 'height', $j( window ).height() - opt.vspace ); |
1649 | | - $j( this.selector ).dialog( 'option', 'position', 'center' ); |
1650 | | - // update the child position: (some of this should be pushed up-stream via dialog config options |
1651 | | - $j( this.selector + '~ .ui-dialog-buttonpane' ).css( { |
1652 | | - 'position':'absolute', |
1653 | | - 'left':'0px', |
1654 | | - 'right':'0px', |
1655 | | - 'bottom':'0px' |
1656 | | - } ); |
1657 | | - } |
1658 | | - |
1659 | | - /** |
1660 | | - * addLoaderDialog |
1661 | | - * small helper for putting a loading dialog box on top of everything |
1662 | | - * (helps block for request that |
1663 | | - * |
1664 | | - * @param msg text text of the loader msg |
1665 | | - */ |
1666 | | - $.addLoaderDialog = function( msg_txt ) { |
1667 | | - $.addDialog( msg_txt, msg_txt + '<br>' + mv_get_loading_img() ); |
1668 | | - } |
1669 | | - |
1670 | | - $.addDialog = function ( title, msg_txt, btn ) { |
1671 | | - $( '#mwe_tmp_loader' ).remove(); |
1672 | | - // append the style free loader ontop: |
1673 | | - $( 'body' ).append( '<div id="mwe_tmp_loader" style="display:none" title="' + title + '" >' + |
1674 | | - msg_txt + |
1675 | | - '</div>' ); |
1676 | | - // special btn == ok gives empty give a single "oky" -> "close" |
1677 | | - if ( btn == 'ok' ) { |
1678 | | - btn[ gM( 'mwe-ok' ) ] = function() { |
1679 | | - $j( '#mwe_tmp_loader' ).close(); |
1680 | | - } |
1681 | | - } |
1682 | | - // turn the loader into a real dialog loader: |
1683 | | - mvJsLoader.doLoadDepMode( [ |
1684 | | - [ |
1685 | | - '$j.ui' |
1686 | | - ], |
1687 | | - [ |
1688 | | - '$j.ui.dialog' |
1689 | | - ] |
1690 | | - ], function() { |
1691 | | - $( '#mwe_tmp_loader' ).dialog( { |
1692 | | - bgiframe: true, |
1693 | | - draggable: false, |
1694 | | - resizable: false, |
1695 | | - modal: true, |
1696 | | - width:400, |
1697 | | - buttons: btn |
1698 | | - } ); |
1699 | | - } ); |
1700 | | - } |
1701 | | - $.closeLoaderDialog = function() { |
1702 | | - mvJsLoader.doLoadDepMode( [ |
1703 | | - [ |
1704 | | - '$j.ui' |
1705 | | - ], |
1706 | | - [ |
1707 | | - '$j.ui.dialog' |
1708 | | - ] |
1709 | | - ], function() { |
1710 | | - $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove(); |
1711 | | - } ); |
1712 | | - } |
1713 | | - |
1714 | | - $.mwProxy = function( apiConf ) { |
1715 | | - mvJsLoader.doLoad( ['mw.apiProxy'], |
1716 | | - function() { |
1717 | | - mw.apiProxy( apiConf ); |
1718 | | - } ); |
1719 | | - } |
1720 | | - } )( jQuery ); |
1721 | | -} |
1722 | | -/* |
1723 | | -* Utility functions: |
1724 | | -*/ |
1725 | | -// Simple URL rewriter (could probably be refactored into an inline regular exp) |
1726 | | -function getURLParamReplace( url, opt ) { |
1727 | | - var pSrc = mw.parseUri( url ); |
1728 | | - if ( pSrc.protocol != '' ) { |
1729 | | - var new_url = pSrc.protocol + '://' + pSrc.authority + pSrc.path + '?'; |
1730 | | - } else { |
1731 | | - var new_url = pSrc.path + '?'; |
1732 | | - } |
1733 | | - var amp = ''; |
1734 | | - for ( var key in pSrc.queryKey ) { |
1735 | | - var val = pSrc.queryKey[ key ]; |
1736 | | - // Do override if requested |
1737 | | - if ( opt[ key ] ) |
1738 | | - val = opt[ key ]; |
1739 | | - new_url += amp + key + '=' + val; |
1740 | | - amp = '&'; |
1741 | | - }; |
1742 | | - // Add any vars that were not already there: |
1743 | | - for ( var i in opt ) { |
1744 | | - if ( !pSrc.queryKey[i] ) { |
1745 | | - new_url += amp + i + '=' + opt[i]; |
1746 | | - amp = '&'; |
1747 | | - } |
1748 | | - } |
1749 | | - return new_url; |
1750 | | -} |
1751 | | -/** |
1752 | | - * Given a float number of seconds, returns npt format response. |
1753 | | - * |
1754 | | - * @param float Seconds |
1755 | | - * @param boolean If we should show milliseconds or not. |
1756 | | - */ |
1757 | | -function seconds2npt( sec, show_ms ) { |
1758 | | - if ( isNaN( sec ) ) { |
1759 | | - // js_log("warning: trying to get npt time on NaN:" + sec); |
1760 | | - return '0:0:0'; |
1761 | | - } |
1762 | | - var hours = Math.floor( sec / 3600 ); |
1763 | | - var minutes = Math.floor( ( sec / 60 ) % 60 ); |
1764 | | - var seconds = sec % 60; |
1765 | | - // Round the number of seconds to the required number of significant digits |
1766 | | - if ( show_ms ) { |
1767 | | - seconds = Math.round( seconds * 1000 ) / 1000; |
1768 | | - } else { |
1769 | | - seconds = Math.round( seconds ); |
1770 | | - } |
1771 | | - if ( seconds < 10 ) |
1772 | | - seconds = '0' + seconds; |
1773 | | - if ( minutes < 10 ) |
1774 | | - minutes = '0' + minutes; |
1775 | | - |
1776 | | - return hours + ":" + minutes + ":" + seconds; |
1777 | | -} |
1778 | | -/* |
1779 | | - * Take hh:mm:ss,ms or hh:mm:ss.ms input, return the number of seconds |
1780 | | - */ |
1781 | | -function npt2seconds( npt_str ) { |
1782 | | - if ( !npt_str ) { |
1783 | | - // js_log('npt2seconds:not valid ntp:'+ntp); |
1784 | | - return false; |
1785 | | - } |
1786 | | - // Strip {npt:}01:02:20 or 32{s} from time if present |
1787 | | - npt_str = npt_str.replace( /npt:|s/g, '' ); |
1788 | | - |
1789 | | - var hour = 0; |
1790 | | - var min = 0; |
1791 | | - var sec = 0; |
1792 | | - |
1793 | | - times = npt_str.split( ':' ); |
1794 | | - if ( times.length == 3 ) { |
1795 | | - sec = times[2]; |
1796 | | - min = times[1]; |
1797 | | - hour = times[0]; |
1798 | | - } else if ( times.length == 2 ) { |
1799 | | - sec = times[1]; |
1800 | | - min = times[0]; |
1801 | | - } else { |
1802 | | - sec = times[0]; |
1803 | | - } |
1804 | | - // Sometimes a comma is used instead of period for ms |
1805 | | - sec = sec.replace( /,\s?/, '.' ); |
1806 | | - // Return seconds float |
1807 | | - return parseInt( hour * 3600 ) + parseInt( min * 60 ) + parseFloat( sec ); |
1808 | | -} |
1809 | | -/* |
1810 | | - * Simple helper to grab an edit token |
1811 | | - * |
1812 | | - * @param title The wiki page title you want to edit |
1813 | | - * @param api_url 'optional' The target API URL |
1814 | | - * @param callback The callback function to pass the token to |
1815 | | - */ |
1816 | | -function get_mw_token( title, api_url, callback ) { |
1817 | | - js_log( ':get_mw_token:' ); |
1818 | | - if ( !title && wgUserName ) { |
1819 | | - title = 'User:' + wgUserName; |
1820 | | - } |
1821 | | - var reqObj = { |
1822 | | - 'action': 'query', |
1823 | | - 'prop': 'info', |
1824 | | - 'intoken': 'edit', |
1825 | | - 'titles': title |
1826 | | - }; |
1827 | | - do_api_req( { |
1828 | | - 'data': reqObj, |
1829 | | - 'url' : api_url |
1830 | | - }, function( data ) { |
1831 | | - for ( var i in data.query.pages ) { |
1832 | | - if ( data.query.pages[i]['edittoken'] ) { |
1833 | | - if ( typeof callback == 'function' ) |
1834 | | - callback ( data.query.pages[i]['edittoken'] ); |
1835 | | - } |
1836 | | - } |
1837 | | - // No token found: |
1838 | | - return false; |
1839 | | - } |
1840 | | - ); |
1841 | | -} |
1842 | | -// Do a remote or local API request based on request URL |
1843 | | -// @param options: url, data, cbParam, callback |
1844 | | -function do_api_req( options, callback ) { |
1845 | | - if ( typeof options.data != 'object' ) { |
1846 | | - return js_error( 'Error: request paramaters must be an object' ); |
1847 | | - } |
1848 | | - // Generate the URL if it's missing |
1849 | | - if ( typeof options.url == 'undefined' || !options.url ) { |
1850 | | - if ( typeof wgServer == 'undefined' ) { |
1851 | | - return js_error( 'Error: no api url for api request' ); |
1852 | | - } |
1853 | | - options.url = mw.getLocalApiUrl(); |
1854 | | - } |
1855 | | - if ( typeof options.data == 'undefined' ) |
1856 | | - options.data = { }; |
1857 | | - |
1858 | | - // Force format to JSON |
1859 | | - options.data['format'] = 'json'; |
1860 | | - |
1861 | | - // If action is not set, assume query |
1862 | | - if ( ! options.data['action'] ) |
1863 | | - options.data['action'] = 'query'; |
1864 | | - |
1865 | | - // js_log('do api req: ' + options.url +'?' + jQuery.param(options.data) ); |
1866 | | - if ( options.url == 'proxy' && mw.proxy ) { |
1867 | | - // assume the proxy is already "setup" since mw.proxy is defined. |
1868 | | - // @@todo should probably integrate that setup into the api call |
1869 | | - mw.proxy.doRequest( options.data, callback ); |
1870 | | - } else if ( mw.parseUri( document.URL ).host == mw.parseUri( options.url ).host ) { |
1871 | | - // Local request: do API request directly |
1872 | | - $j.ajax( { |
1873 | | - type: "POST", |
1874 | | - url: options.url, |
1875 | | - data: options.data, |
1876 | | - dataType: 'json', // API requests _should_ always return JSON data: |
1877 | | - async: false, |
1878 | | - success: function( data ) { |
1879 | | - callback( data ); |
1880 | | - }, |
1881 | | - error: function( e ) { |
1882 | | - js_error( ' error' + e + ' in getting: ' + options.url ); |
1883 | | - } |
1884 | | - } ); |
1885 | | - } else { |
1886 | | - // Remote request |
1887 | | - // Set the callback param if it's not already set |
1888 | | - if ( typeof options.jsonCB == 'undefined' ) |
1889 | | - options.jsonCB = 'callback'; |
1890 | | - |
1891 | | - var req_url = options.url; |
1892 | | - var paramAnd = ( req_url.indexOf( '?' ) == -1 ) ? '?' : '&'; |
1893 | | - // Put all the parameters into the URL |
1894 | | - for ( var i in options.data ) { |
1895 | | - req_url += paramAnd + encodeURIComponent( i ) + '=' + encodeURIComponent( options.data[i] ); |
1896 | | - paramAnd = '&'; |
1897 | | - } |
1898 | | - var fname = 'mycpfn_' + ( mw.cb_count++ ); |
1899 | | - _global[ fname ] = callback; |
1900 | | - req_url += '&' + options.jsonCB + '=' + fname; |
1901 | | - loadExternalJs( req_url ); |
1902 | | - } |
1903 | | -} |
1904 | | -// Do a request: |
1905 | | -// @@note this contains metavid specific local vs remote api remapping. |
1906 | | -// this should be depreciated and we should use "$j.get" or an explicate api call |
1907 | | -// (we should not mix the two request types) |
1908 | | -function do_request( req_url, callback ) { |
1909 | | - js_log( 'do_request::req_url:' + mw.parseUri( document.URL ) + ' != ' + mw.parseUri( req_url ).host ); |
1910 | | - // If we are doing a request to the same domain or relative link, do a normal GET |
1911 | | - if ( mw.parseUri( document.URL ).host == mw.parseUri( req_url ).host || |
1912 | | - req_url.indexOf( '://' ) == -1 ){ // if its a relative url go directly as well |
1913 | | - // Do a direct request |
1914 | | - $j.ajax( { |
1915 | | - type: "GET", |
1916 | | - url: req_url, |
1917 | | - async: false, |
1918 | | - success: function( data ) { |
1919 | | - callback( data ); |
1920 | | - } |
1921 | | - } ); |
1922 | | - } else { |
1923 | | - // Get data via DOM injection with callback |
1924 | | - global_req_cb.push( callback ); |
1925 | | - // Prepend json_ to feed_format if not already requesting json format (metavid specific) |
1926 | | - if ( req_url.indexOf( "feed_format=" ) != -1 && req_url.indexOf( "feed_format=json" ) == -1 ) |
1927 | | - req_url = req_url.replace( /feed_format=/, 'feed_format=json_' ); |
1928 | | - loadExternalJs( req_url + '&cb=mv_jsdata_cb&cb_inx=' + ( global_req_cb.length -1 ) ); |
1929 | | - } |
1930 | | -} |
1931 | | - |
1932 | | -function mv_jsdata_cb( response ) { |
1933 | | - js_log( 'f:mv_jsdata_cb:' + response['cb_inx'] ); |
1934 | | - // Run the callback from the global request callback object |
1935 | | - if ( !global_req_cb[response['cb_inx']] ) { |
1936 | | - js_log( 'missing req cb index' ); |
1937 | | - return false; |
1938 | | - } |
1939 | | - if ( !response['pay_load'] ) { |
1940 | | - js_log( "missing pay load" ); |
1941 | | - return false; |
1942 | | - } |
1943 | | - switch( response['content-type'] ) { |
1944 | | - case 'text/plain': |
1945 | | - break; |
1946 | | - case 'text/xml': |
1947 | | - if ( typeof response['pay_load'] == 'string' ) { |
1948 | | - response['pay_load'] = mw.parseXML( response['pay_load'] ); |
1949 | | - } |
1950 | | - break |
1951 | | - default: |
1952 | | - js_log( 'bad response type' + response['content-type'] ); |
1953 | | - return false; |
1954 | | - break; |
1955 | | - } |
1956 | | - global_req_cb[response['cb_inx']]( response['pay_load'] ); |
1957 | | -} |
1958 | | -// Load external JS via DOM injection |
1959 | | -function loadExternalJs( url, callback ) { |
1960 | | - js_log( 'load js: ' + url ); |
1961 | | - // if(window['$j']) // use jquery call: |
1962 | | - /*$j.ajax({ |
1963 | | - type: "GET", |
1964 | | - url: url, |
1965 | | - dataType: 'script', |
1966 | | - cache: true |
1967 | | - });*/ |
1968 | | - // else{ |
1969 | | - var e = document.createElement( "script" ); |
1970 | | - e.setAttribute( 'src', url ); |
1971 | | - e.setAttribute( 'type', "text/javascript" ); |
1972 | | - /*if(callback) |
1973 | | - e.onload = callback; |
1974 | | - */ |
1975 | | - // e.setAttribute('defer', true); |
1976 | | - document.getElementsByTagName( "head" )[0].appendChild( e ); |
1977 | | - // } |
1978 | | -} |
1979 | | -function styleSheetPresent( url ) { |
1980 | | - style_elements = document.getElementsByTagName( 'link' ); |
1981 | | - if ( style_elements.length > 0 ) { |
1982 | | - for ( i = 0; i < style_elements.length; i++ ) { |
1983 | | - if ( style_elements[i].href == url ) |
1984 | | - return true; |
1985 | | - } |
1986 | | - } |
1987 | | - return false; |
1988 | | -} |
1989 | | -function loadExternalCss( url ) { |
1990 | | - // We could have the script loader group these CSS requests. |
1991 | | - // But it's debatable: it may hurt more than it helps with caching and all |
1992 | | - if ( typeof url == 'object' ) { |
1993 | | - for ( var i in url ) { |
1994 | | - loadExternalCss( url[i] ); |
1995 | | - } |
1996 | | - return ; |
1997 | | - } |
1998 | | - |
1999 | | - if ( url.indexOf( '?' ) == -1 ) { |
2000 | | - url += '?' + getMwReqParam(); |
2001 | | - } |
2002 | | - if ( !styleSheetPresent( url ) ) { |
2003 | | - js_log( 'load css: ' + url ); |
2004 | | - var e = document.createElement( "link" ); |
2005 | | - e.href = url; |
2006 | | - e.type = "text/css"; |
2007 | | - e.rel = 'stylesheet'; |
2008 | | - document.getElementsByTagName( "head" )[0].appendChild( e ); |
2009 | | - } |
2010 | | -} |
2011 | | -function getMvEmbedURL() { |
2012 | | - if ( _global['mv_embed_url'] ) |
2013 | | - return _global['mv_embed_url']; |
2014 | | - var js_elements = document.getElementsByTagName( "script" ); |
2015 | | - for ( var i = 0; i < js_elements.length; i++ ) { |
2016 | | - // Check for mv_embed.js and/or script loader |
2017 | | - var src = js_elements[i].getAttribute( "src" ); |
2018 | | - if ( src ) { |
2019 | | - if ( src.indexOf( 'mv_embed.js' ) != -1 || ( |
2020 | | - ( src.indexOf( 'mwScriptLoader.php' ) != -1 || src.indexOf( 'jsScriptLoader.php' ) != -1 ) |
2021 | | - && src.indexOf( 'mv_embed' ) != -1 ) ) // (check for class=mv_embed script_loader call) |
2022 | | - { |
2023 | | - _global['mv_embed_url'] = src; |
2024 | | - return src; |
2025 | | - } |
2026 | | - } |
2027 | | - } |
2028 | | - js_error( 'Error: getMvEmbedURL failed to get Embed Path' ); |
2029 | | - return false; |
2030 | | -} |
2031 | | -// Get a unique request ID to ensure fresh JavaScript |
2032 | | -function getMwReqParam() { |
2033 | | - if ( _global['req_param'] ) |
2034 | | - return _global['req_param']; |
2035 | | - var mv_embed_url = getMvEmbedURL(); |
2036 | | - |
2037 | | - var req_param = ''; |
2038 | | - |
2039 | | - // If we have a URI, add it to the req |
2040 | | - var urid = mw.parseUri( mv_embed_url ).queryKey['urid'] |
2041 | | - // If we're in debug mode, get a fresh unique request key and pass on "debug" param |
2042 | | - if ( mw.parseUri( mv_embed_url ).queryKey['debug'] == 'true' ) { |
2043 | | - var d = new Date(); |
2044 | | - req_param += 'urid=' + d.getTime() + '&debug=true'; |
2045 | | - } else if ( urid ) { |
2046 | | - // Set from request urid: |
2047 | | - req_param += 'urid=' + urid; |
2048 | | - } else { |
2049 | | - // Otherwise, just use the mv_embed version |
2050 | | - req_param += 'urid=' + mw.version; |
2051 | | - } |
2052 | | - // add the lang param: |
2053 | | - var langKey = mw.parseUri( mv_embed_url ).queryKey['uselang']; |
2054 | | - if ( langKey ) |
2055 | | - req_param += '&uselang=' + langKey; |
2056 | | - |
2057 | | - _global['req_param'] = req_param; |
2058 | | - |
2059 | | - return _global['req_param']; |
2060 | | -} |
2061 | | -/* |
2062 | | - * Set the global mv_embed path based on the script's location |
2063 | | - */ |
2064 | | -function getMvEmbedPath() { |
2065 | | - if ( _global['mv_embed_path'] ) |
2066 | | - return _global['mv_embed_path']; |
2067 | | - var mv_embed_url = getMvEmbedURL(); |
2068 | | - if ( mv_embed_url.indexOf( 'mv_embed.js' ) !== -1 ) { |
2069 | | - mv_embed_path = mv_embed_url.substr( 0, mv_embed_url.indexOf( 'mv_embed.js' ) ); |
2070 | | - } else if ( mv_embed_url.indexOf( 'mwScriptLoader.php' ) !== -1 ) { |
2071 | | - // Script loader is in the root of MediaWiki, so include the default mv_embed extension path |
2072 | | - mv_embed_path = mv_embed_url.substr( 0, mv_embed_url.indexOf( 'mwScriptLoader.php' ) ) |
2073 | | - + mediaWiki_mvEmbed_path; |
2074 | | - } else { |
2075 | | - mv_embed_path = mv_embed_url.substr( 0, mv_embed_url.indexOf( 'jsScriptLoader.php' ) ); |
2076 | | - } |
2077 | | - // Make an absolute URL (if it's relative and we don't have an mv_embed path) |
2078 | | - if ( mv_embed_path.indexOf( '://' ) == -1 ) { |
2079 | | - var pURL = mw.parseUri( document.URL ); |
2080 | | - if ( mv_embed_path.charAt( 0 ) == '/' ) { |
2081 | | - mv_embed_path = pURL.protocol + '://' + pURL.authority + mv_embed_path; |
2082 | | - } else { |
2083 | | - // Relative |
2084 | | - if ( mv_embed_path == '' ) { |
2085 | | - mv_embed_path = pURL.protocol + '://' + pURL.authority + pURL.directory + mv_embed_path; |
2086 | | - } |
2087 | | - } |
2088 | | - } |
2089 | | - _global['mv_embed_path'] = mv_embed_path; |
2090 | | - return mv_embed_path; |
2091 | | -} |
2092 | | - |
2093 | | -if ( typeof DOMParser == "undefined" ) { |
2094 | | - DOMParser = function () { } |
2095 | | - DOMParser.prototype.parseFromString = function ( str, contentType ) { |
2096 | | - if ( typeof ActiveXObject != "undefined" ) { |
2097 | | - var d = new ActiveXObject( "MSXML.DomDocument" ); |
2098 | | - d.loadXML( str ); |
2099 | | - return d; |
2100 | | - } else if ( typeof XMLHttpRequest != "undefined" ) { |
2101 | | - var req = new XMLHttpRequest; |
2102 | | - req.open( "GET", "data:" + ( contentType || "application/xml" ) + |
2103 | | - ";charset=utf-8," + encodeURIComponent( str ), false ); |
2104 | | - if ( req.overrideMimeType ) { |
2105 | | - req.overrideMimeType( contentType ); |
2106 | | - } |
2107 | | - req.send( null ); |
2108 | | - return req.responseXML; |
2109 | | - } |
2110 | | - } |
2111 | | -} |
2112 | | -/* |
2113 | | -* Utility functions |
2114 | | -*/ |
2115 | | -function js_log( string ) { |
2116 | | - // Add any prepend debug strings if necessary (used for cross browser) |
2117 | | - if ( mw.conf['debug_pre'] ) |
2118 | | - string = mw.conf['debug_pre'] + string; |
2119 | | - |
2120 | | - if ( window.console ) { |
2121 | | - window.console.log( string ); |
2122 | | - } else { |
2123 | | - /* |
2124 | | - * IE and non-Firebug debug: |
2125 | | - */ |
2126 | | - /*var log_elm = document.getElementById('mv_js_log'); |
2127 | | - if(!log_elm){ |
2128 | | - document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + |
2129 | | - '<div style="position:absolute;z-index:500;top:0px;left:0px;right:0px;height:10px;">'+ |
2130 | | - '<textarea id="mv_js_log" cols="120" rows="5"></textarea>'+ |
2131 | | - '</div>'; |
2132 | | - |
2133 | | - var log_elm = document.getElementById('mv_js_log'); |
2134 | | - } |
2135 | | - if(log_elm){ |
2136 | | - log_elm.value+=string+"\n"; |
2137 | | - }*/ |
2138 | | - } |
2139 | | - return false; |
2140 | | -} |
2141 | | - |
2142 | | -function js_error( string ) { |
2143 | | - alert( string ); |
2144 | | - return false; |
2145 | | -} |
Index: branches/js2-work/phase3/js2/mwEmbed/php/noMediaWikiConfig.php |
— | — | @@ -43,6 +43,8 @@ |
44 | 44 | |
45 | 45 | // Get the autoload classes |
46 | 46 | require_once( realpath( dirname( __FILE__ ) ) . '/jsAutoloadLocalClasses.php' ); |
| 47 | +// Load the javascript Classes |
| 48 | +wfLoadMwEmbedClassPaths(); |
47 | 49 | |
48 | 50 | // Get the JSmin class: |
49 | 51 | require_once( realpath( dirname( __FILE__ ) ) . '/minify/JSMin.php' ); |
Index: branches/js2-work/phase3/js2/mwEmbed/php/maintenance/mergeJavascriptMsg.php |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | $jsFileText = file_get_contents( $fname ); |
98 | 98 | $mwPos = strpos( $fname, 'mwEmbed' ) + 7; |
99 | 99 | $curFileName = substr( $fname, $mwPos ); |
100 | | - if ( preg_match( '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text |
| 100 | + if ( preg_match( '/mw\.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text |
101 | 101 | $jsFileText, |
102 | 102 | $matches ) ) { |
103 | 103 | $msgSet .= doJsonMerge( $matches[1] ); |
— | — | @@ -147,8 +147,8 @@ |
148 | 148 | // escape $1 for preg replace: |
149 | 149 | $json_txt = str_replace( '$', '\$', $json_txt ); |
150 | 150 | // print "json:\n$json_txt \n"; |
151 | | - $str = preg_replace ( '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', |
152 | | - "loadGM(" . $json_txt . ")", |
| 151 | + $str = preg_replace ( '/mw.addMessages\s*\(\s*{(.*)}\s*\)\s*/siU', |
| 152 | + "mw.addMessages(" . $json_txt . ")", |
153 | 153 | $jsFileText ); |
154 | 154 | |
155 | 155 | // print substr($str, 0, 600); |
Index: branches/js2-work/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php |
— | — | @@ -1,36 +1,38 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
4 | 5 | |
5 | 6 | global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory; |
6 | 7 | |
7 | | -// Load classes from mv_embed.js |
8 | | -if ( is_file( $wgMwEmbedDirectory . 'mv_embed.js' ) ) { |
| 8 | +/** |
| 9 | + * loads javascript class name paths from mwEmbed.js |
| 10 | + */ |
| 11 | +function wfLoadMwEmbedClassPaths ( ) { |
| 12 | + global $wgMwEmbedDirectory; |
| 13 | + // Load classes from mwEmbed.js |
| 14 | + if ( is_file( $wgMwEmbedDirectory . 'mwEmbed.js' ) ) { |
9 | 15 | |
10 | | - //read the head of the file:: |
11 | | - $f = fopen( $wgMwEmbedDirectory . 'mv_embed.js' , 'r'); |
12 | | - $jsvar = ''; |
13 | | - $file_head=''; |
14 | | - while (!feof($f)) { |
15 | | - $file_head.= fread($f, 8192); |
| 16 | + // NOTE: ideally we could cache this json var and or update it php side per release |
| 17 | + |
| 18 | + // Read the file: |
| 19 | + $file_content = file_get_contents( $wgMwEmbedDirectory . 'mwEmbed.js' ); |
16 | 20 | // Call jsClassPathLoader() for each lcPaths() call in the JS source |
17 | 21 | $replace_test = preg_replace_callback( |
18 | | - '/lcPaths\s*\(\s*{(.*)}\s*\)\s*/siU', |
19 | | - 'jsClassPathLoader', |
20 | | - $file_head |
| 22 | + '/mw\.addClassFilePaths\s*\(\s*{(.*)}\s*\)\s*/siU', |
| 23 | + 'wfClassPathLoader', |
| 24 | + $file_content |
21 | 25 | ); |
22 | | - if( $replace_test !== false ) |
23 | | - break; |
24 | 26 | } |
25 | | - fclose( $f ); |
26 | 27 | } |
27 | | -function jsClassPathLoader( $jvar ) { |
| 28 | +function wfClassPathLoader( $jvar ) { |
28 | 29 | global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory; |
29 | 30 | if ( !isset( $jvar[1] ) ) |
30 | 31 | return false; |
31 | | - $jClassSet = json_decode( '{' . $jvar[1] . '}', true ); |
| 32 | + $jClassSet = FormatJson::decode( '{' . $jvar[1] . '}', true ); |
32 | 33 | foreach ( $jClassSet as $jClass => $jPath ) { |
33 | 34 | // Strip $ from jClass (as they are stripped on URL request parameter input) |
34 | 35 | $jClass = str_replace( '$', '', $jClass ); |
35 | | - $wgJSAutoloadLocalClasses[$jClass] = $wgMwEmbedDirectory . $jPath; |
| 36 | + $wgJSAutoloadLocalClasses[ $jClass ] = $wgMwEmbedDirectory . $jPath; |
36 | 37 | } |
| 38 | + |
37 | 39 | } |
Index: branches/js2-work/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | 'mwe-sequencer_credit_line' => 'Developed by <a href="http://kaltura.com">Kaltura, Inc.</a> in partnership with the <a href="http://wikimediafoundation.org/wiki/Home">Wikimedia Foundation</a> (<a href="#">more information</a>).', |
113 | 113 | |
114 | 114 | /* |
115 | | - * js file: /mv_embed.js |
| 115 | + * js file: /mwEmbed.js |
116 | 116 | */ |
117 | 117 | 'mwe-loading_txt' => 'Loading ...', |
118 | 118 | 'mwe-size-gigabytes' => '$1 GB', |
— | — | @@ -347,7 +347,7 @@ |
348 | 348 | 'mwe-loading_plugin' => 'loading plugin ...', |
349 | 349 | 'mwe-select_playback' => 'Set playback preference', |
350 | 350 | 'mwe-link_back' => 'Link back', |
351 | | - 'mwe-error_swap_vid' => 'Error: mv_embed was unable to swap the video tag for the mv_embed interface', |
| 351 | + 'mwe-error_swap_vid' => 'Error: mwEmbed was unable to swap the video tag for the mwEmbed interface', |
352 | 352 | 'mwe-add_to_end_of_sequence' => 'Add to end of sequence', |
353 | 353 | 'mwe-missing_video_stream' => 'The video file for this stream is missing', |
354 | 354 | 'mwe-play_clip' => 'Play clip', |
Index: branches/js2-work/phase3/js2/mwEmbed/skins/kskin/kskin.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * skin js allows you to override contrlBuilder html/class output |
4 | 4 | */ |
5 | 5 | |
6 | | -loadGM( { |
| 6 | +mw.addMessages( { |
7 | 7 | "mwe-credit-title" : "Title: $1", |
8 | 8 | "mwe-kaltura-platform-title" : "Kaltura open source video platform" |
9 | 9 | } ); |
— | — | @@ -160,7 +160,7 @@ |
161 | 161 | '</div>' |
162 | 162 | ); |
163 | 163 | |
164 | | - if( mw.conf.k_attribution == true ){ |
| 164 | + if( mw.getConfig( 'k_attribution' ) == true ){ |
165 | 165 | $target.append( |
166 | 166 | $j('<div/>').addClass( 'k-attribution' ) |
167 | 167 | .attr({ |
Index: branches/js2-work/phase3/js2/mwEmbed/skins/ctrlBuilder.js |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | }, |
61 | 61 | |
62 | 62 | /** |
63 | | - * Gets the controlls html |
| 63 | + * Gets the controls html |
64 | 64 | * @return {String} html output of controls |
65 | 65 | */ |
66 | 66 | getControls:function() { |
Index: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js |
— | — | @@ -0,0 +1,2698 @@ |
| 2 | +/* |
| 3 | + * ~mwEmbed ~ |
| 4 | + * For details see: http://www.mediawiki.org/wiki/MwEmbed |
| 5 | + * |
| 6 | + * All MediaWiki code is released under the GPL2. |
| 7 | + * For more information visit http://metavid.org/wiki/Code |
| 8 | + * |
| 9 | + * @author Michael Dale |
| 10 | + * |
| 11 | + * mwEmbed uses the following libraries: |
| 12 | + * |
| 13 | + * jQuery: |
| 14 | + * http://jquery.com/ |
| 15 | + * |
| 16 | + * mw.parseUri: |
| 17 | + * http://stevenlevithan.com/demo/parseuri/js/ |
| 18 | + * |
| 19 | + */ |
| 20 | + |
| 21 | +/** |
| 22 | + * AutoLoader paths |
| 23 | + * @path The path to the file (or set of files) with ending slash |
| 24 | + * @gClasses The set of classes |
| 25 | + * if it's an array, $j.className becomes jquery.className.js |
| 26 | + * if it's an associative object then key => value pairs are used |
| 27 | + */ |
| 28 | +if ( typeof mvAutoLoadClasses == 'undefined' ) |
| 29 | + mvAutoLoadClasses = { }; |
| 30 | + |
| 31 | +// The script that loads the class set |
| 32 | +function lcPaths( classSet ) { |
| 33 | + for ( var i in classSet ) { |
| 34 | + mvAutoLoadClasses[i] = classSet[i]; |
| 35 | + } |
| 36 | +} |
| 37 | + |
| 38 | +function mvGetClassPath( k ) { |
| 39 | + if ( mvAutoLoadClasses[k] ) { |
| 40 | + // js_log('got class path:' + k + ' : '+ mvClassPaths[k]); |
| 41 | + return mvAutoLoadClasses[k]; |
| 42 | + } else { |
| 43 | + js_log( 'Error:: Could not find path for requested class ' + k ); |
| 44 | + return false; |
| 45 | + } |
| 46 | +} |
| 47 | + |
| 48 | +if ( typeof mvCssPaths == 'undefined' ) |
| 49 | + mvCssPaths = { }; |
| 50 | + |
| 51 | +function lcCssPath( cssSet ) { |
| 52 | + for ( var i in cssSet ) { |
| 53 | + mvCssPaths[i] = cssSet[i]; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +// Dependency mapping for CSS files for self-contained included plugins: |
| 58 | +lcCssPath( { |
| 59 | + '$j.Jcrop' : 'libClipEdit/Jcrop/css/jquery.Jcrop.css', |
| 60 | + '$j.fn.ColorPicker' : 'libClipEdit/colorpicker/css/colorpicker.css' |
| 61 | +}) |
| 62 | + |
| 63 | +// The global scope: will be depreciated once we get everything into mw |
| 64 | +var _global = this; |
| 65 | + |
| 66 | +/* |
| 67 | +* setup the empty global mw object |
| 68 | +* will ensure all our functions and variables are properly namespaced |
| 69 | +* reducing chance of conflicts |
| 70 | +*/ |
| 71 | +if ( !window['mw'] ) { |
| 72 | + window['mw'] = { } |
| 73 | +} |
| 74 | + |
| 75 | + |
| 76 | +/** |
| 77 | +* Default global config values. Configuration values are set via mw.setConfig |
| 78 | +* Configuration values should genneraly be set prior to dom-ready |
| 79 | +*/ |
| 80 | +var mwDefaultConf = { |
| 81 | + // Default skin name |
| 82 | + 'skin_name' : 'mvpcf', |
| 83 | + |
| 84 | + // Default jquery ui skin name |
| 85 | + 'jui_skin' : 'redmond', |
| 86 | + |
| 87 | + // What tags will be re-written to video player by default |
| 88 | + // set to empty string or null to avoid automatic rewrites |
| 89 | + 'rewriteTags' : 'video,audio,playlist', |
| 90 | + |
| 91 | + /** |
| 92 | + * If jQuery / mwEmbed should always be loaded. |
| 93 | + * |
| 94 | + * mwEmbedSetup ignores this flag and is run if: |
| 95 | + * If your js calls mw.addOnloadHook ( callback_function ) |
| 96 | + * If your page includes any tags set in config.rewriteTags |
| 97 | + * |
| 98 | + * This flag increases page performace on pages that do not use mwEmbed |
| 99 | + * and don't already load jQuery |
| 100 | + * |
| 101 | + * For examle when including the mwEmbed.js in your blog template |
| 102 | + * mwEmbed will only load extra js on blog posts that include the video tag. |
| 103 | + * |
| 104 | + * NOTE: Future articture will probably do away with this flag and refactor it into |
| 105 | + * a smaller "remotePageMwEmbed.js" script similar to remoteMwEmbed.js in the js2 folder |
| 106 | + */ |
| 107 | + 'alwaysSetupMwEmbed' : false, |
| 108 | + |
| 109 | + // Default video size ( if no size provided ) |
| 110 | + 'video_size' : '400x300', |
| 111 | + |
| 112 | + // If the k-skin video player should attribute kaltura |
| 113 | + 'k_attribution' : true, |
| 114 | + |
| 115 | + // The path of mvEmbed in mediaWiki folder |
| 116 | + 'mediaWikiPath' : 'js2/mwEmbed/' |
| 117 | +} |
| 118 | + |
| 119 | + |
| 120 | +// @@todo move these into mw |
| 121 | +var global_req_cb = new Array(); // The global request callback array |
| 122 | + |
| 123 | +/** |
| 124 | +* The global mw object: |
| 125 | +* |
| 126 | +* Any global functions/classes that are not jQuery plugins should make |
| 127 | +* there way into the mw namespace |
| 128 | +*/ |
| 129 | +( function( $ ) { |
| 130 | + // list valid skins here: |
| 131 | + $.valid_skins = [ 'mvpcf', 'kskin' ]; |
| 132 | + // the version of mwEmbed |
| 133 | + $.version = '1.1'; |
| 134 | + |
| 135 | + // special case of commons api url |
| 136 | + // (used for default subtitles server for media with a "wikiTitleKey" atm) |
| 137 | + // (@@todo eventually we should have wikiTitleKey be namespaced with interwiki ns |
| 138 | + $.commons_api_url = 'http://commons.wikimedia.org/w/api.php'; |
| 139 | + |
| 140 | + /** |
| 141 | + * Some global containers flags |
| 142 | + */ |
| 143 | + $.skin_list = new Array(); |
| 144 | + $.init_done = false; |
| 145 | + $.cb_count = 0; |
| 146 | + $.player_list = new Array(), // The global player list per page |
| 147 | + $.req_cb = new Array() // The global request callback array |
| 148 | + |
| 149 | + /** |
| 150 | + * Configuration System: |
| 151 | + * |
| 152 | + * Simple system of inherit defauts, with getter setter functions: |
| 153 | + */ |
| 154 | + |
| 155 | + // Local scope configuration var: |
| 156 | + mwConfig = { }; |
| 157 | + |
| 158 | + for(var i in mwDefaultConf){ |
| 159 | + if( typeof mwConfig[ i ] == 'undefined' ) |
| 160 | + mwConfig[ i ] = mwDefaultConf[ i ]; |
| 161 | + } |
| 162 | + |
| 163 | + /** |
| 164 | + * Setter for configuration values |
| 165 | + * |
| 166 | + * @param {String} name Name of configuration value |
| 167 | + * @param {String} value Value of configuration name |
| 168 | + */ |
| 169 | + $.setConfig = function ( name, value ){ |
| 170 | + mwConfig[ name ] = value; |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * Getter for configuration values |
| 175 | + * |
| 176 | + * @param {String} name of configuration value to get |
| 177 | + * @return {Mixed} value of configuration key |
| 178 | + * returns "false" if key not found |
| 179 | + */ |
| 180 | + $.getConfig = function ( name ){ |
| 181 | + if(mwConfig[ name ] ) |
| 182 | + return mwConfig[ name ]; |
| 183 | + return false; |
| 184 | + } |
| 185 | + |
| 186 | + |
| 187 | + |
| 188 | + /** |
| 189 | + * Language classes mw.lang |
| 190 | + * |
| 191 | + * Localized Language support attempts to mirror some of the functionality of Language.php in MediaWiki |
| 192 | + * It contains methods for loading and transforming msg text |
| 193 | + * |
| 194 | + */ |
| 195 | + $.lang = { }; |
| 196 | + |
| 197 | + /** |
| 198 | + * Setup the lang object |
| 199 | + */ |
| 200 | + var messageCache = { }; |
| 201 | + var gRuleSet = { }; |
| 202 | + |
| 203 | + /** |
| 204 | + * mw.addMessages function |
| 205 | + * Loads a set of json messages into the messegeCache object. |
| 206 | + * |
| 207 | + * @param json msgSet The set of msgs to be loaded |
| 208 | + */ |
| 209 | + $.addMessages = function( msgSet ) { |
| 210 | + for ( var i in msgSet ) { |
| 211 | + messageCache[ i ] = msgSet[i]; |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * loadRS function |
| 217 | + * Loads a ruleset by given template key ie PLURAL : { //ruleSetObj } |
| 218 | + * |
| 219 | + * @param json ruleSet The ruleset object ( extends gRuleSet ) |
| 220 | + */ |
| 221 | + $.lang.loadRS = function( ruleSet ) { |
| 222 | + for ( var i in ruleSet ) { |
| 223 | + gRuleSet[ i ] = ruleSet[ i ]; |
| 224 | + } |
| 225 | + } |
| 226 | + |
| 227 | + /** |
| 228 | + * Returns a transformed msg string |
| 229 | + * |
| 230 | + * it take a msg key and array of replacement values of form |
| 231 | + * $1, $2 and does relevant msgkey transformation returning |
| 232 | + * the user msg. |
| 233 | + * |
| 234 | + * @param {String} key The msg key as set by mw.addMessages |
| 235 | + * @param [mixed] args An array of replacement strings |
| 236 | + * @return string |
| 237 | + */ |
| 238 | + $.lang.gM = function( key , args ) { |
| 239 | + |
| 240 | + // Check for missing message key |
| 241 | + if ( ! messageCache[ key ] ) |
| 242 | + return '<' + key + '>'; |
| 243 | + |
| 244 | + // swap in the arg values |
| 245 | + var ms = $.lang.gMsgSwap( key, args ); |
| 246 | + |
| 247 | + // a quick check to see if we need to send the msg via the 'parser' |
| 248 | + // (we can add more detailed check once we support more wiki syntax) |
| 249 | + if ( ms.indexOf( '{{' ) === -1 && ms.indexOf( '[' ) === -1 ) { |
| 250 | + return ms; |
| 251 | + } |
| 252 | + |
| 253 | + // make sure we have the lagMagic setup: |
| 254 | + // @@todo move to init |
| 255 | + $.lang.magicSetup(); |
| 256 | + // send the msg key through the parser |
| 257 | + var pObj = $.parser.pNew( ms ); |
| 258 | + // return the transformed msg |
| 259 | + return pObj.getHTML(); |
| 260 | + } |
| 261 | + /** |
| 262 | + * gMsgSwap |
| 263 | + * |
| 264 | + * @param string key The msg key as set by mw.addMessages |
| 265 | + * @param [mixed] args An array or string to be replaced |
| 266 | + * @return string |
| 267 | + */ |
| 268 | + $.lang.gMsgSwap = function( key , args ) { |
| 269 | + if ( ! messageCache[ key ] ) |
| 270 | + return '<' + key + '>';// Missing key placeholder |
| 271 | + // get the message string: |
| 272 | + var ms = messageCache[ key ]; |
| 273 | + |
| 274 | + // replace values |
| 275 | + if ( typeof args == 'object' || typeof args == 'array' ) { |
| 276 | + for ( var v in args ) { |
| 277 | + // Message test replace arguments start at 1 instead of zero: |
| 278 | + var rep = new RegExp( '\\$' + ( parseInt( v ) + 1 ), 'g' ); |
| 279 | + ms = ms.replace( rep, args[v] ); |
| 280 | + } |
| 281 | + } else if ( typeof args == 'string' || typeof args == 'number' ) { |
| 282 | + ms = ms.replace( /\$1/g, args ); |
| 283 | + } |
| 284 | + return ms; |
| 285 | + } |
| 286 | + |
| 287 | + /** |
| 288 | + * gMsgNoTrans |
| 289 | + * |
| 290 | + * @returns string The msg key without transforming it |
| 291 | + */ |
| 292 | + $.lang.gMsgNoTrans = function( key ) { |
| 293 | + if ( messageCache[ key ] ) |
| 294 | + return messageCache[ key ] |
| 295 | + |
| 296 | + // Missing key placeholder |
| 297 | + return '<' + key + '>'; |
| 298 | + } |
| 299 | + |
| 300 | + /** |
| 301 | + * Add Supported Magic Words to parser |
| 302 | + */ |
| 303 | + // Set the setupflag to false: |
| 304 | + $.lang.doneSetup = false; |
| 305 | + $.lang.magicSetup = function() { |
| 306 | + if ( !$.lang.doneSetup ) { |
| 307 | + $.parser.addTemplateTransform ( { |
| 308 | + 'PLURAL' : $.lang.procPLURAL |
| 309 | + } ) |
| 310 | + |
| 311 | + $.lang.doneSetup = true; |
| 312 | + } |
| 313 | + |
| 314 | + } |
| 315 | + |
| 316 | + /** |
| 317 | + * Process the PLURAL special language template key: |
| 318 | + */ |
| 319 | + $.lang.procPLURAL = function( tObj ) { |
| 320 | + // setup shortcuts |
| 321 | + // (gRuleSet is loaded from script-loader to contains local ruleset) |
| 322 | + var rs = gRuleSet['PLURAL']; |
| 323 | + |
| 324 | + /* |
| 325 | + * Plural matchRuleTest |
| 326 | + */ |
| 327 | + function matchRuleTest( cRule, val ) { |
| 328 | + js_log("matchRuleTest:: " + typeof cRule + ' ' + cRule + ' == ' + val ); |
| 329 | + function checkValue( compare, val ) { |
| 330 | + if ( typeof compare == 'string' ) { |
| 331 | + range = compare.split( '-' ); |
| 332 | + if ( range.length >= 1 ) { |
| 333 | + if ( val >= range[0] && val <= range[1] ) |
| 334 | + return true; |
| 335 | + } |
| 336 | + } |
| 337 | + // else do a direct compare |
| 338 | + if ( compare == val ) { |
| 339 | + return true; |
| 340 | + } |
| 341 | + return false; |
| 342 | + } |
| 343 | + // check for simple cRule type: |
| 344 | + if ( typeof cRule == 'number' ) { |
| 345 | + return ( parseInt( val ) == parseInt( cRule ) ); |
| 346 | + } else if ( typeof cRule == 'object' ) { |
| 347 | + var cmatch = { }; |
| 348 | + // if a list we need to match all for rule match |
| 349 | + for ( var i in cRule ) { |
| 350 | + var cr = cRule[i]; |
| 351 | + // set cr type |
| 352 | + var crType = ''; |
| 353 | + for ( var j in cr ) { |
| 354 | + if ( j == 'mod' ) |
| 355 | + crType = 'mod' |
| 356 | + } |
| 357 | + switch( crType ) { |
| 358 | + case 'mod': |
| 359 | + if ( cr ['is'] ) { |
| 360 | + if ( checkValue( val % cr['mod'], cr ['is'] ) ) |
| 361 | + cmatch[i] = true; |
| 362 | + } else if ( cr['not'] ) { |
| 363 | + if ( ! checkValue( val % cr['mod'], cr ['not'] ) ) |
| 364 | + cmatch[i] = true; |
| 365 | + } |
| 366 | + break; |
| 367 | + } |
| 368 | + } |
| 369 | + // check all the matches (taking into consideration "or" order) |
| 370 | + for ( var i in cRule ) { |
| 371 | + if ( ! cmatch[i] ) |
| 372 | + return false; |
| 373 | + } |
| 374 | + return true; |
| 375 | + |
| 376 | + } |
| 377 | + } |
| 378 | + /** |
| 379 | + * Maps a given rule Index to template params: |
| 380 | + * |
| 381 | + * if index is out of range return last param |
| 382 | + * @param |
| 383 | + */ |
| 384 | + function getTempParamFromRuleInx( tObj, ruleInx ) { |
| 385 | + // js_log('getTempParamFromRuleInx: ruleInx: ' + ruleInx + ' tempParamLength ' + tObj.param.length ); |
| 386 | + if ( ruleInx >= tObj.param.length ) |
| 387 | + return tObj.param[ tObj.param.length - 1 ]; |
| 388 | + // else return the requested index: |
| 389 | + return tObj.param[ ruleInx ]; |
| 390 | + } |
| 391 | + var rCount = 0 |
| 392 | + // run the actual rule lookup: |
| 393 | + for ( var ruleInx in rs ) { |
| 394 | + cRule = rs[ruleInx]; |
| 395 | + if ( matchRuleTest( cRule, tObj.arg ) ) { |
| 396 | + js_log("matched rule: " + ruleInx ); |
| 397 | + return getTempParamFromRuleInx( tObj, rCount ); |
| 398 | + } |
| 399 | + rCount ++; |
| 400 | + } |
| 401 | + js_log('no match found for: ' + tObj.arg + ' using last/other : ' + tObj.param [ tObj.param.length -1 ] ); |
| 402 | + //debugger; |
| 403 | + // return the last /"other" template param |
| 404 | + return tObj.param [ tObj.param.length - 1 ]; |
| 405 | + } |
| 406 | + |
| 407 | + /** |
| 408 | + * gMsgLoadRemote loads remote msg strings |
| 409 | + * |
| 410 | + * @param mixed msgSet the set of msg to load remotely |
| 411 | + * @param function callback the callback to issue once string is ready |
| 412 | + */ |
| 413 | + $.lang.gMsgLoadRemote = function( msgSet, callback ) { |
| 414 | + var ammessages = ''; |
| 415 | + if ( typeof msgSet == 'object' ) { |
| 416 | + for ( var i in msgSet ) { |
| 417 | + ammessages += msgSet[i] + '|'; |
| 418 | + } |
| 419 | + } else if ( typeof msgSet == 'string' ) { |
| 420 | + ammessages += msgSet; |
| 421 | + } |
| 422 | + if ( ammessages == '' ) { |
| 423 | + js_log( 'gMsgLoadRemote: no message set requested' ); |
| 424 | + return false; |
| 425 | + } |
| 426 | + do_api_req( { |
| 427 | + 'data': { |
| 428 | + 'meta': 'allmessages', |
| 429 | + 'ammessages': ammessages |
| 430 | + } |
| 431 | + }, function( data ) { |
| 432 | + if ( data.query.allmessages ) { |
| 433 | + var msgs = data.query.allmessages; |
| 434 | + for ( var i in msgs ) { |
| 435 | + var ld = { }; |
| 436 | + ld[ msgs[i]['name'] ] = msgs[i]['*']; |
| 437 | + mw.addMessages( ld ); |
| 438 | + } |
| 439 | + } |
| 440 | + callback(); |
| 441 | + } ); |
| 442 | + } |
| 443 | + |
| 444 | + /** |
| 445 | + * Format a size in bytes for output, using an appropriate |
| 446 | + * unit (B, KB, MB or GB) according to the magnitude in question |
| 447 | + * |
| 448 | + * @param size Size to format |
| 449 | + * @return string Plain text (not HTML) |
| 450 | + */ |
| 451 | + $.lang.formatSize = function ( size ) { |
| 452 | + // For small sizes no decimal places are necessary |
| 453 | + var round = 0; |
| 454 | + var msg = ''; |
| 455 | + if ( size > 1024 ) { |
| 456 | + size = size / 1024; |
| 457 | + if ( size > 1024 ) { |
| 458 | + size = size / 1024; |
| 459 | + // For MB and bigger two decimal places are smarter |
| 460 | + round = 2; |
| 461 | + if ( size > 1024 ) { |
| 462 | + size = size / 1024; |
| 463 | + msg = 'mwe-size-gigabytes'; |
| 464 | + } else { |
| 465 | + msg = 'mwe-size-megabytes'; |
| 466 | + } |
| 467 | + } else { |
| 468 | + msg = 'mwe-size-kilobytes'; |
| 469 | + } |
| 470 | + } else { |
| 471 | + msg = 'mwe-size-bytes'; |
| 472 | + } |
| 473 | + // JavaScript does not let you choose the precision when rounding |
| 474 | + var p = Math.pow( 10, round ); |
| 475 | + var size = Math.round( size * p ) / p; |
| 476 | + return gM( msg , size ); |
| 477 | + }; |
| 478 | + |
| 479 | + $.lang.formatNumber = function( num ) { |
| 480 | + /* |
| 481 | + * addSeparatorsNF |
| 482 | + * @param Str: The number to be formatted, as a string or number. |
| 483 | + * @param outD: The decimal character for the output, such as ',' for the number 100,2 |
| 484 | + * @param sep: The separator character for the output, such as ',' for the number 1,000.2 |
| 485 | + */ |
| 486 | + function addSeparatorsNF( nStr, outD, sep ) { |
| 487 | + nStr += ''; |
| 488 | + var dpos = nStr.indexOf( '.' ); |
| 489 | + var nStrEnd = ''; |
| 490 | + if ( dpos != -1 ) { |
| 491 | + nStrEnd = outD + nStr.substring( dpos + 1, nStr.length ); |
| 492 | + nStr = nStr.substring( 0, dpos ); |
| 493 | + } |
| 494 | + var rgx = /(\d+)(\d{3})/; |
| 495 | + while ( rgx.test( nStr ) ) { |
| 496 | + nStr = nStr.replace( rgx, '$1' + sep + '$2' ); |
| 497 | + } |
| 498 | + return nStr + nStrEnd; |
| 499 | + } |
| 500 | + // @@todo read language code and give periods or comas: |
| 501 | + return addSeparatorsNF( num, '.', ',' ); |
| 502 | + } |
| 503 | + |
| 504 | + |
| 505 | + |
| 506 | + /** |
| 507 | + * MediaWiki wikitext "Parser" |
| 508 | + * |
| 509 | + * This is not feature complete but we need a way to get at template properties |
| 510 | + * |
| 511 | + * |
| 512 | + * @param {String} wikiText the wikitext to be parsed |
| 513 | + * @return {Object} parserObj returns a parser object that has methods for getting at |
| 514 | + * things you would want |
| 515 | + */ |
| 516 | + $.parser = { }; |
| 517 | + var pMagicSet = { }; |
| 518 | + |
| 519 | + /** |
| 520 | + * parser addTemplateTransform |
| 521 | + * |
| 522 | + * Lets you add a set template key to be transformed by a callback function |
| 523 | + * |
| 524 | + * @param {Object} magicSet key:callback |
| 525 | + */ |
| 526 | + $.parser.addTemplateTransform = function( magicSet ) { |
| 527 | + for ( var i in magicSet ) |
| 528 | + pMagicSet[ i ] = magicSet[i]; |
| 529 | + } |
| 530 | + |
| 531 | + // Create a new parser Object |
| 532 | + $.parser.pNew = function( wikiText, opt ) { |
| 533 | + var parseObj = function( wikiText, opt ) { |
| 534 | + return this.init( wikiText, opt ) |
| 535 | + } |
| 536 | + parseObj.prototype = { |
| 537 | + // the wikiText "DOM"... stores the parsed wikiText structure |
| 538 | + // wtDOM : {}, (not yet supported ) |
| 539 | + |
| 540 | + pOut : '', // the parser output string container |
| 541 | + init :function( wikiText ) { |
| 542 | + this.wikiText = wikiText; |
| 543 | + }, |
| 544 | + updateText : function( wikiText ) { |
| 545 | + this.wikiText = wikiText; |
| 546 | + // invalidate the output (will force a re-parse ) |
| 547 | + this.pOut = ''; |
| 548 | + }, |
| 549 | + parse : function() { |
| 550 | + /* |
| 551 | + * quickly recursive / parse out templates: |
| 552 | + */ |
| 553 | + |
| 554 | + // ~ probably a better algorithm out there / should mirror php parser flow ~ |
| 555 | + // (we are already running white-space issues ie php parse strips whitespace differently) |
| 556 | + // or at least expose something similar to: http://www.mediawiki.org/wiki/Extension:Page_Object_Model |
| 557 | + |
| 558 | + // ... but I am having fun with recursion so here it is... |
| 559 | + function rdpp ( txt , cn ) { |
| 560 | + var node = { }; |
| 561 | + // inspect each char |
| 562 | + for ( var a = 0; a < txt.length; a++ ) { |
| 563 | + if ( txt[a] == '{' && txt[a + 1] == '{' ) { |
| 564 | + a = a + 2; |
| 565 | + node['p'] = node; |
| 566 | + if ( !node['c'] ) |
| 567 | + node['c'] = new Array(); |
| 568 | + |
| 569 | + node['c'].push( rdpp( txt.substr( a ), true ) ); |
| 570 | + } else if ( txt[a] == '}' && txt[a + 1] == '}' ) { |
| 571 | + a = a + 2; |
| 572 | + if ( !node['p'] ) { |
| 573 | + return node; |
| 574 | + } |
| 575 | + node = node['p']; |
| 576 | + } |
| 577 | + if ( !node['t'] ) |
| 578 | + node['t'] = ''; |
| 579 | + // don't put closures into output: |
| 580 | + if ( txt[a] && txt[a] != '}' ) |
| 581 | + node['t'] += txt[a]; |
| 582 | + |
| 583 | + } |
| 584 | + return node; |
| 585 | + } |
| 586 | + /** |
| 587 | + * parse template text as template name and named params |
| 588 | + */ |
| 589 | + function parseTmplTxt( ts ) { |
| 590 | + var tObj = { }; |
| 591 | + // Get template name: |
| 592 | + tname = ts.split( '\|' ).shift() ; |
| 593 | + tname = tname.split( '\{' ).shift() ; |
| 594 | + tname = tname.replace( /^\s+|\s+$/g, "" ); //trim |
| 595 | + |
| 596 | + // check for arguments: |
| 597 | + if ( tname.split( ':' ).length == 1 ) { |
| 598 | + tObj["name"] = tname; |
| 599 | + } else { |
| 600 | + tObj["name"] = tname.split( ':' ).shift(); |
| 601 | + tObj["arg"] = tname.split( ':' ).pop(); |
| 602 | + } |
| 603 | + |
| 604 | + var pSet = ts.split( '\|' ); |
| 605 | + pSet.splice( 0, 1 ); |
| 606 | + if ( pSet.length ) { |
| 607 | + tObj.param = new Array(); |
| 608 | + for ( var pInx in pSet ) { |
| 609 | + var tStr = pSet[ pInx ]; |
| 610 | + // check for empty param |
| 611 | + if ( tStr == '' ) { |
| 612 | + tObj.param[ pInx ] = ''; |
| 613 | + continue; |
| 614 | + } |
| 615 | + for ( var b = 0 ; b < tStr.length ; b++ ) { |
| 616 | + if ( tStr[b] == '=' && b > 0 && b < tStr.length && tStr[b - 1] != '\\' ) { |
| 617 | + // named param |
| 618 | + tObj.param[ tStr.split( '=' ).shift() ] = tStr.split( '=' ).pop(); |
| 619 | + } else { |
| 620 | + // indexed param |
| 621 | + tObj.param[ pInx ] = tStr; |
| 622 | + } |
| 623 | + } |
| 624 | + } |
| 625 | + } |
| 626 | + return tObj; |
| 627 | + } |
| 628 | + function getMagicTxtFromTempNode( node ) { |
| 629 | + node.tObj = parseTmplTxt ( node.t ); |
| 630 | + // do magic swap if template key found in pMagicSet |
| 631 | + if ( node.tObj.name in pMagicSet ) { |
| 632 | + var nt = pMagicSet[ node.tObj.name ]( node.tObj ); |
| 633 | + return nt; |
| 634 | + } else { |
| 635 | + // don't swap just return text |
| 636 | + return node.t; |
| 637 | + } |
| 638 | + } |
| 639 | + /** |
| 640 | + * recurse_magic_swap |
| 641 | + * |
| 642 | + * go last child first swap upward: (could probably be integrated above somehow) |
| 643 | + */ |
| 644 | + var pNode = null; |
| 645 | + function recurse_magic_swap( node ) { |
| 646 | + if ( !pNode ) |
| 647 | + pNode = node; |
| 648 | + |
| 649 | + if ( node['c'] ) { |
| 650 | + // swap all the kids: |
| 651 | + for ( var i in node['c'] ) { |
| 652 | + var nt = recurse_magic_swap( node['c'][i] ); |
| 653 | + // swap it into current |
| 654 | + if ( node.t ) { |
| 655 | + node.t = node.t.replace( node['c'][i].t, nt ); |
| 656 | + } |
| 657 | + // swap into parent |
| 658 | + pNode.t = pNode.t.replace( node['c'][i].t, nt ); |
| 659 | + } |
| 660 | + // do the current node: |
| 661 | + var nt = getMagicTxtFromTempNode( node ); |
| 662 | + pNode.t = pNode.t.replace( node.t , nt ); |
| 663 | + // run the swap for the outer most node |
| 664 | + return node.t; |
| 665 | + } else { |
| 666 | + // node.t = getMagicFromTempObj( node.t ) |
| 667 | + return getMagicTxtFromTempNode( node ); |
| 668 | + } |
| 669 | + } |
| 670 | + // parse out the template node structure: |
| 671 | + this.pNode = rdpp ( this.wikiText ); |
| 672 | + // strip out the parent from the root |
| 673 | + this.pNode['p'] = null; |
| 674 | + |
| 675 | + // do the recursive magic swap text: |
| 676 | + this.pOut = recurse_magic_swap( this.pNode ); |
| 677 | + }, |
| 678 | + /* |
| 679 | + * parsed template api ~loosely based off of ~POM~ |
| 680 | + * http://www.mediawiki.org/wiki/Extension:Page_Object_Model |
| 681 | + */ |
| 682 | + |
| 683 | + /** |
| 684 | + * templates |
| 685 | + * |
| 686 | + * gets a requested template from the wikitext (if available) |
| 687 | + * |
| 688 | + */ |
| 689 | + templates: function( tname ) { |
| 690 | + this.parse(); |
| 691 | + var tmplSet = new Array(); |
| 692 | + function getMatchingTmpl( node ) { |
| 693 | + if ( node['c'] ) { |
| 694 | + for ( var i in node['c'] ) { |
| 695 | + getMatchingTmpl( node['c'] ); |
| 696 | + } |
| 697 | + } |
| 698 | + if ( tname && node.tObj ) { |
| 699 | + if ( node.tObj['name'] == tname ) |
| 700 | + tmplSet.push( node.tObj ); |
| 701 | + } else if ( node.tObj ) { |
| 702 | + tmplSet.push( node.tObj ); |
| 703 | + } |
| 704 | + } |
| 705 | + getMatchingTmpl( this.pNode ); |
| 706 | + return tmplSet; |
| 707 | + }, |
| 708 | + |
| 709 | + /** |
| 710 | + * getTemplateVars |
| 711 | + * returns a set of template values in a given wikitext page |
| 712 | + * |
| 713 | + * NOTE: should be integrated with the parser |
| 714 | + */ |
| 715 | + getTemplateVars: function(){ |
| 716 | + //js_log('matching against: ' + wikiText); |
| 717 | + templateVars = new Array(); |
| 718 | + var tempVars = wikiText.match(/\{\{\{([^\}]*)\}\}\}/gi); |
| 719 | + |
| 720 | + // Clean up results: |
| 721 | + for(var i=0; i < tempVars.length; i++){ |
| 722 | + //match |
| 723 | + var tvar = tempVars[i].replace('{{{','').replace('}}}',''); |
| 724 | + |
| 725 | + // Strip anything after a | |
| 726 | + if(tvar.indexOf('|') != -1){ |
| 727 | + tvar = tvar.substr(0, tvar.indexOf('|')); |
| 728 | + } |
| 729 | + |
| 730 | + // Check for duplicates: |
| 731 | + var do_add=true; |
| 732 | + for(var j=0; j < templateVars.length; j++){ |
| 733 | + if( templateVars[j] == tvar) |
| 734 | + do_add=false; |
| 735 | + } |
| 736 | + |
| 737 | + // Add the template vars to the output obj |
| 738 | + if(do_add) |
| 739 | + templateVars.push( tvar ); |
| 740 | + } |
| 741 | + return templateVars; |
| 742 | + }, |
| 743 | + |
| 744 | + /** |
| 745 | + * Returns the transformed wikitext |
| 746 | + * |
| 747 | + * Build output from swappable index |
| 748 | + * (all transforms must be expanded in parse stage and linearly rebuilt) |
| 749 | + * Alternatively we could build output using a place-holder & replace system |
| 750 | + * (this lets us be slightly more sloppy with ordering and indexes, but probably slower) |
| 751 | + * |
| 752 | + * Ideal: we build a 'wiki DOM' |
| 753 | + * When editing you update the data structure directly |
| 754 | + * Then in output time you just go DOM->html-ish output without re-parsing anything |
| 755 | + */ |
| 756 | + getHTML : function() { |
| 757 | + // wikiText updates should invalidate pOut |
| 758 | + if ( this.pOut == '' ) { |
| 759 | + this.parse(); |
| 760 | + } |
| 761 | + return this.pOut; |
| 762 | + } |
| 763 | + }; |
| 764 | + // return the parserObj |
| 765 | + return new parseObj( wikiText, opt ) ; |
| 766 | + }; |
| 767 | + |
| 768 | + |
| 769 | + /** |
| 770 | + * The loader prototype: |
| 771 | + */ |
| 772 | + $.loader = { |
| 773 | + /* |
| 774 | + * Javascript Module Set |
| 775 | + * @key Name of Module |
| 776 | + * @value function code to load module |
| 777 | + */ |
| 778 | + moduleNames : { }, |
| 779 | + |
| 780 | + /** |
| 781 | + * Javascript Class Names |
| 782 | + * @key Name of class |
| 783 | + * @value Class file path |
| 784 | + */ |
| 785 | + classNames : { }, |
| 786 | + |
| 787 | + /** |
| 788 | + * Load a set of scripts. |
| 789 | + * Will issue many load requests or package the request for the script-loader |
| 790 | + * |
| 791 | + * @param {Object} loadSet Set of scripts to be loaded |
| 792 | + * @param {Function} callback Function to call once all scripts are loaded. |
| 793 | + */ |
| 794 | + loadMany: function( loadSet, callback ){ |
| 795 | + //Setup up the local "loadState" |
| 796 | + var loadState = { }; |
| 797 | + // Check if its a dependency set ( nested objects ) |
| 798 | + if( typeof loadSet [ 0 ] == 'object' ){ |
| 799 | + //Load sets of classes ( to preserver order for some browsers ) |
| 800 | + this.loadDependencyChain( loadSet, callback ); |
| 801 | + return ; |
| 802 | + } |
| 803 | + |
| 804 | + // Set the initial load state for every item in the loadSet |
| 805 | + for( var i in loadSet ){ |
| 806 | + var loadName = loadSet[ i ]; |
| 807 | + loadState[ loadName ] = 0; |
| 808 | + } |
| 809 | + |
| 810 | + // Issue the load request check check loadState to see if we are "done" |
| 811 | + for( var i in loadSet ){ |
| 812 | + var loadName = loadSet[ i ]; |
| 813 | + $.load( loadName, function ( loadName ){ |
| 814 | + loadState[ loadName ] = 1; |
| 815 | + |
| 816 | + var loadDone = true; |
| 817 | + for( var j in loadState ){ |
| 818 | + if( loadState[ j ] === 0 ) |
| 819 | + loadDone = false; |
| 820 | + } |
| 821 | + // Run the parent scope callback for "loadMany" |
| 822 | + if( loadDone ) |
| 823 | + callback(); |
| 824 | + } ); |
| 825 | + } |
| 826 | + }, |
| 827 | + |
| 828 | + /** |
| 829 | + * Load a sets of scripts satisfy dependency order for browsers that execute out of order |
| 830 | + * |
| 831 | + * @param {Object} loadChain A set of javascript arrays to be loaded. |
| 832 | + * Sets are requested in array order. |
| 833 | + */ |
| 834 | + loadDependencyChain: function( loadChain, callback ){ |
| 835 | + var _this = this; |
| 836 | + // Load with dependency checks |
| 837 | + this.load( loadChain.shift(), function() { |
| 838 | + if ( loadChain.length != 0 ) { |
| 839 | + _this.loadDependencyChain( loadChain, callback ); |
| 840 | + } else { |
| 841 | + callback(); |
| 842 | + } |
| 843 | + } ); |
| 844 | + }, |
| 845 | + |
| 846 | + /** |
| 847 | + * Core load function: |
| 848 | + * |
| 849 | + * @param {Mixed} loadRequest: |
| 850 | + * |
| 851 | + * {String} Name of a module to be loaded |
| 852 | + * Modules are added via addModuleLoader and can define custom |
| 853 | + * code needed to load the module dependencies |
| 854 | + * Module loader function should accept a callback argument |
| 855 | + * |
| 856 | + * {String} Name of a class to loaded. |
| 857 | + * Using defined class names avoids loading the same class |
| 858 | + * twice by first checking if the "class variable" is defined |
| 859 | + * |
| 860 | + * {String} Absolute or relative to mwEmbed file path. |
| 861 | + * The same file won't be loaded twice |
| 862 | + * |
| 863 | + * {Array} can be an array of any combination of the above strings. |
| 864 | + * Will be loaded in-order or in a single |
| 865 | + * script-loader request if scriptLoader is enabled |
| 866 | + * |
| 867 | + * {Array} {Array} Can be a set of Arrays for loading. |
| 868 | + * Some browsers execute included scripts out of order. |
| 869 | + * This lets you chain sets of request for thouse browers. |
| 870 | + * If using the script-loader order is preserved in output and |
| 871 | + * a single request will be used. |
| 872 | + * |
| 873 | + * @param {Function} callback Function called once loading is complete |
| 874 | + */ |
| 875 | + load: function( loadRequest, callback ){ |
| 876 | + |
| 877 | + // Check if its a multi-part request: |
| 878 | + if( typeof loadRequest == 'object' ){ |
| 879 | + this.loadMany ( loadRequest, callback ); |
| 880 | + return ; |
| 881 | + } |
| 882 | + |
| 883 | + // Check for the module name loader function |
| 884 | + if( this.moduleNames[ loadRequest ] && |
| 885 | + typeof ( this.moduleNames[ loadRequest ] ) == 'function' |
| 886 | + ){ |
| 887 | + //Run the module with the parent callback |
| 888 | + this.moduleNames[ loadRequest ]( callback ); |
| 889 | + return ; |
| 890 | + } |
| 891 | + |
| 892 | + // Check for javascript class |
| 893 | + if( this.classNames[ loadRequest ] ){ |
| 894 | + this.loadClass( loadRequest, callback ); |
| 895 | + return ; |
| 896 | + } |
| 897 | + |
| 898 | + // Try loading as a "file" |
| 899 | + if( loadRequest ) { |
| 900 | + $.getScript( loadRequest, callback ); |
| 901 | + return ; |
| 902 | + } |
| 903 | + |
| 904 | + //possible error? |
| 905 | + js_log( "Error could not handle load request" ); |
| 906 | + }, |
| 907 | + |
| 908 | + /** |
| 909 | + * Loads javascript associated with a className |
| 910 | + * |
| 911 | + * @param {String} className Name of class to load |
| 912 | + * @param {Function} callback Function to run once class is loaded |
| 913 | + */ |
| 914 | + loadClass: function( className , callback){ |
| 915 | + |
| 916 | + // Make sure the class is not already defined: |
| 917 | + if ( $.isset( className ) ){ |
| 918 | + js_log( 'Class ( ' + className + ' ) already defined ' ); |
| 919 | + return ; |
| 920 | + } |
| 921 | + |
| 922 | + // Get the class url: |
| 923 | + var baseClassPath = this.classNames[ className ]; |
| 924 | + |
| 925 | + var url = null; |
| 926 | + // Load the mwEmbed path ( if not a root dir url ) |
| 927 | + if( baseClassPath.indexOf( '/' ) !== 0 ){ |
| 928 | + url = $.getMwEmbedPath() + baseClassPath; |
| 929 | + }else{ |
| 930 | + url = baseClassPath; |
| 931 | + } |
| 932 | + |
| 933 | + if( ! url ){ |
| 934 | + js_log( "Could not get url for class " + className ); |
| 935 | + return ; |
| 936 | + } |
| 937 | + |
| 938 | + // Issue the request to load the class (include class name in result callback: |
| 939 | + $.getScript( url, function( ) { |
| 940 | + callback( className ); |
| 941 | + } ); |
| 942 | + |
| 943 | + }, |
| 944 | + |
| 945 | + /** |
| 946 | + * Adds a module to the mwLoader object |
| 947 | + * |
| 948 | + * @param {String} name Name of module |
| 949 | + * @param {Function} moduleLoader Function that |
| 950 | + * loads dependencies for a module |
| 951 | + */ |
| 952 | + addModuleLoader: function( name, moduleLoader ){ |
| 953 | + this.moduleNames [ name ] = moduleLoader; |
| 954 | + }, |
| 955 | + |
| 956 | + /** |
| 957 | + * Adds file path key value pairs |
| 958 | + * |
| 959 | + * @param {Object} classSet JSON formated list of |
| 960 | + * class name file path pairs. |
| 961 | + * |
| 962 | + * classSet must be strict JSON to allow the |
| 963 | + * scriptLoader to parse the file paths. |
| 964 | + */ |
| 965 | + addClassFilePaths: function( classSet ){ |
| 966 | + for( var i in classSet ){ |
| 967 | + this.classNames[ i ] = classSet[ i ]; |
| 968 | + } |
| 969 | + } |
| 970 | + } |
| 971 | + |
| 972 | + /** |
| 973 | + * Shortcut entry points / convenience functions: |
| 974 | + * |
| 975 | + * Lets you write mw.load() instead of mw.loader.load() |
| 976 | + */ |
| 977 | + |
| 978 | + /** |
| 979 | + * Load Object entry point: Loads a requested set of javascript |
| 980 | + */ |
| 981 | + $.load = function( loadRequest, callback ){ |
| 982 | + return $.loader.load( loadRequest, callback ); |
| 983 | + } |
| 984 | + |
| 985 | + /** |
| 986 | + * Add module entry point: Adds a module to the mwLoader object |
| 987 | + */ |
| 988 | + $.addModuleLoader = function ( name, loaderFunction ){ |
| 989 | + return $.loader.addModuleLoader( name, loaderFunction ); |
| 990 | + } |
| 991 | + |
| 992 | + /** |
| 993 | + * Add Class File Paths entry point: |
| 994 | + */ |
| 995 | + $.addClassFilePaths = function ( classSet ) { |
| 996 | + return $.loader.addClassFilePaths( classSet ); |
| 997 | + } |
| 998 | + |
| 999 | + |
| 1000 | + /** |
| 1001 | + * Utility Functions |
| 1002 | + */ |
| 1003 | + |
| 1004 | + /** |
| 1005 | + * Similar to php isset function checks if the variable exists. |
| 1006 | + * Does a safe check of a descendent method or variable |
| 1007 | + * |
| 1008 | + * @param {String} objectPath |
| 1009 | + * @return {Boolean} |
| 1010 | + * true if objectPath exists |
| 1011 | + * false if objectPath is undefined |
| 1012 | + */ |
| 1013 | + $.isset = function( objectPath ) { |
| 1014 | + if ( !objectPath ) |
| 1015 | + return false; |
| 1016 | + var pathSet = objectPath.split( '.' ); |
| 1017 | + var cur_path = ''; |
| 1018 | + for ( var p = 0; p < pathSet.length; p++ ) { |
| 1019 | + cur_path = ( cur_path == '' ) ? cur_path + pathSet[p] : cur_path + '.' + pathSet[p]; |
| 1020 | + eval( 'var ptest = typeof ( ' + cur_path + ' ); ' ); |
| 1021 | + if ( ptest == 'undefined' ) { |
| 1022 | + return false; |
| 1023 | + } |
| 1024 | + } |
| 1025 | + return true; |
| 1026 | + } |
| 1027 | + |
| 1028 | + |
| 1029 | + //Setup the local mwOnLoadFuncitons array: |
| 1030 | + var mwOnLoadFuncitons = new Array(); |
| 1031 | + |
| 1032 | + //mw Ready flag ( set once mwEmbed is ready ) |
| 1033 | + var mwReadyFlag = false; |
| 1034 | + |
| 1035 | + /** |
| 1036 | + * Enables load hooks to run once DOM is "ready" |
| 1037 | + * Will ensure jQuery is available, is in the $j namespace |
| 1038 | + * and mw interfaces and configuration has been loaded and applied |
| 1039 | + * |
| 1040 | + * @param {Function} callback Function to run once DOM and jQuery are ready |
| 1041 | + */ |
| 1042 | + $.addOnloadHook = function( callback ){ |
| 1043 | + if( mwReadyFlag == false ){ |
| 1044 | + mwOnLoadFuncitons.push ( callback ); |
| 1045 | + |
| 1046 | + // If the dom is ready but we have not run mwSetup:: |
| 1047 | + // Have a rare case where a dynamically included script is calling mw.addOnloadHook :: |
| 1048 | + if ( mwDomReadyFlag && !mwSetupFlag ){ |
| 1049 | + $.setupMwEmbed(); |
| 1050 | + } |
| 1051 | + return ; |
| 1052 | + } |
| 1053 | + // If mwReadyFlag is already "ready" call the callback directly: |
| 1054 | + callback(); |
| 1055 | + } |
| 1056 | + |
| 1057 | + /** |
| 1058 | + * Runs all the queued functions |
| 1059 | + */ |
| 1060 | + $.runLoadHooks = function ( ){ |
| 1061 | + // Sets mwReadyFlag to true so that future addOnLoadHook calls |
| 1062 | + // know to call the callback directly |
| 1063 | + mwReadyFlag = true; |
| 1064 | + |
| 1065 | + // Run all the queued functions: |
| 1066 | + while( mwOnLoadFuncitons.length ) |
| 1067 | + mwOnLoadFuncitons.pop()(); |
| 1068 | + } |
| 1069 | + |
| 1070 | + /** |
| 1071 | + * One time "setup" for mwEmbed |
| 1072 | + * run onDomReady ( so calls to setConfg apply to setup ) |
| 1073 | + */ |
| 1074 | + |
| 1075 | + // Flag to ensure setup is only run once: |
| 1076 | + var mwSetupFlag = false; |
| 1077 | + |
| 1078 | + $.setupMwEmbed = function ( ) { |
| 1079 | + |
| 1080 | + // Only run the setup once: |
| 1081 | + if( mwSetupFlag ) |
| 1082 | + return ; |
| 1083 | + mwSetupFlag = true; |
| 1084 | + |
| 1085 | + // Make sure jQuery is loaded: |
| 1086 | + $.load( 'window.jQuery', function(){ |
| 1087 | + if ( !_global['$j'] ) { |
| 1088 | + _global['$j'] = jQuery.noConflict(); |
| 1089 | + } |
| 1090 | + |
| 1091 | + // Set up the skin paths |
| 1092 | + _global['mv_jquery_skin_path'] = mw.getMwEmbedPath() + 'jquery/jquery.ui/themes/' + mw.getConfig( 'jui_skin' ) + '/'; |
| 1093 | + _global['mv_skin_img_path'] = mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/images/'; |
| 1094 | + _global['mv_default_thumb_url'] = mv_skin_img_path + 'vid_default_thumb.jpg'; |
| 1095 | + |
| 1096 | + // Make Core skin/style sheets are always available: |
| 1097 | + loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
| 1098 | + loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/styles.css' ); |
| 1099 | + |
| 1100 | + // Set up AJAX to not send dynamic URLs for loading scripts |
| 1101 | + $j.ajaxSetup( { |
| 1102 | + cache: true |
| 1103 | + } ); |
| 1104 | + |
| 1105 | + // Set up mvEmbed jQuery bindings |
| 1106 | + mwDojQueryBindings(); |
| 1107 | + |
| 1108 | + // Check for tag-rewrites ( sometimes checked twice but ensures fresh dom check ) |
| 1109 | + if( $.documentHasRewriteTags() ){ |
| 1110 | + // Load the embedPlayer module ( then run queued hooks ) |
| 1111 | + ms.load( 'embedPlayer', function ( ) { |
| 1112 | + mw.runLoadHooks(); |
| 1113 | + } ); |
| 1114 | + }else{ |
| 1115 | + // Set ready state and run the callback |
| 1116 | + mw.runLoadHooks(); |
| 1117 | + } |
| 1118 | + } ); |
| 1119 | + } |
| 1120 | + //Flag to register the domReady has been called |
| 1121 | + var mwDomReadyFlag = false; |
| 1122 | + /** |
| 1123 | + * This will get called when the DOM is ready |
| 1124 | + * Will check configuration and issue a mw.setupMwEmbed call if needed |
| 1125 | + */ |
| 1126 | + $.domReady = function ( ) { |
| 1127 | + if( mwDomReadyFlag ) |
| 1128 | + return ; |
| 1129 | + js_log( 'run:domReady' ); |
| 1130 | + // Set the onDomReady Flag |
| 1131 | + mwDomReadyFlag = true; |
| 1132 | + |
| 1133 | + // Check for the force setup flag: |
| 1134 | + if ( $.getConfig( 'alwaysSetupMwEmbed' ) ){ |
| 1135 | + $.setupMwEmbed(); |
| 1136 | + return ; |
| 1137 | + } |
| 1138 | + |
| 1139 | + // Check for rewrite tags: |
| 1140 | + if ( $.documentHasRewriteTags() ) { |
| 1141 | + $.setupMwEmbed(); |
| 1142 | + return ; |
| 1143 | + } |
| 1144 | + |
| 1145 | + // Check for queued functions that use mw interfaces: |
| 1146 | + if ( mwOnLoadFuncitons.length ){ |
| 1147 | + $.setupMwEmbed(); |
| 1148 | + return ; |
| 1149 | + } |
| 1150 | + |
| 1151 | + // If we have any queued functions we need to run setup as well: |
| 1152 | + |
| 1153 | + /* |
| 1154 | + // Load libs and process videos |
| 1155 | + mvJsLoader.embedPlayerCheck( function() { |
| 1156 | + // Convert all supported elements into embed players: |
| 1157 | + $j.embedPlayers( function(){ |
| 1158 | + // Run any queued global events: |
| 1159 | + mvJsLoader.runQueuedFunctions(); |
| 1160 | + }); |
| 1161 | + } ); |
| 1162 | + } else { |
| 1163 | + mvJsLoader.runQueuedFunctions(); |
| 1164 | + } |
| 1165 | + */ |
| 1166 | + } |
| 1167 | + |
| 1168 | + /** |
| 1169 | + * Check the current DOM for any tags in "rewriteTags" |
| 1170 | + */ |
| 1171 | + $.documentHasRewriteTags = function(){ |
| 1172 | + var tags = $.getRewriteTags(); |
| 1173 | + return ( tags && tags.length ); |
| 1174 | + } |
| 1175 | + $.getRewriteTags = function(){ |
| 1176 | + var tagString = $.getConfig( 'rewriteTags' ); |
| 1177 | + if( ! tagString || tagString == '' ) |
| 1178 | + return false; |
| 1179 | + |
| 1180 | + // Tags should be separated by "," |
| 1181 | + var tags = tagString.split(','); |
| 1182 | + |
| 1183 | + // Check for tags: |
| 1184 | + for( var i in tags ){ |
| 1185 | + var tagsInDOM = document.getElementsByTagName( tags[ i ] ); |
| 1186 | + // If tags found return true |
| 1187 | + if( tagsInDOM.length > 0 ){ |
| 1188 | + return true; |
| 1189 | + } |
| 1190 | + } |
| 1191 | + return false; |
| 1192 | + } |
| 1193 | + |
| 1194 | + /** |
| 1195 | + * Wrapper for jQuery getScript |
| 1196 | + * |
| 1197 | + * If jQuery is not ready load it. |
| 1198 | + * |
| 1199 | + * @param {String} url Url of script |
| 1200 | + * @param {Function} callback Function to call once script is loaded |
| 1201 | + */ |
| 1202 | + $.getScript = function( url, callback ){ |
| 1203 | + |
| 1204 | + js_log( 'mw.getScript: ' + url ); |
| 1205 | + |
| 1206 | + // If jQuery is available just use getScript |
| 1207 | + if( $.isset( 'window.jQuery' ) ) { |
| 1208 | + $j.getScript( url, callback ); |
| 1209 | + return ; |
| 1210 | + } |
| 1211 | + |
| 1212 | + // No jQuery load and bind manually: ( copied from jQuery ajax function ) |
| 1213 | + var head = document.getElementsByTagName("head")[0]; |
| 1214 | + var script = document.createElement("script"); |
| 1215 | + script.setAttribute( 'src', url ); |
| 1216 | + |
| 1217 | + // Attach handlers for all browsers ( might not work in safari < version 2.0 ) |
| 1218 | + var done = false; |
| 1219 | + script.onload = script.onreadystatechange = function(){ |
| 1220 | + if ( !done && (!this.readyState || |
| 1221 | + this.readyState == "loaded" || this.readyState == "complete") ) { |
| 1222 | + done = true; |
| 1223 | + callback(); |
| 1224 | + } |
| 1225 | + }; |
| 1226 | + // Append the script to the DOM: |
| 1227 | + head.appendChild( script ); |
| 1228 | + } |
| 1229 | + |
| 1230 | + /** |
| 1231 | + * Get Api URL from mediaWiki output page defined variables |
| 1232 | + */ |
| 1233 | + $.getLocalApiUrl = function() { |
| 1234 | + if ( typeof wgServer != 'undefined' && typeof wgScriptPath != 'undefined' ) { |
| 1235 | + return wgServer + wgScriptPath + '/api.php'; |
| 1236 | + } |
| 1237 | + return false; |
| 1238 | + } |
| 1239 | + |
| 1240 | + // Local mwEmbedPath variable ( for cache of $.getMwEmbedPath ) |
| 1241 | + var mwEmbedPath = null; |
| 1242 | + |
| 1243 | + /** |
| 1244 | + * Gets the path to the mwEmbed folder |
| 1245 | + */ |
| 1246 | + $.getMwEmbedPath = function() { |
| 1247 | + if ( mwEmbedPath ) |
| 1248 | + return mwEmbedPath; |
| 1249 | + |
| 1250 | + // Get mwEmbed src: |
| 1251 | + var src = $.getMwEmbedSrc(); |
| 1252 | + var mwpath = null; |
| 1253 | + // Check for direct include of the mwEmbed.js |
| 1254 | + if ( src.indexOf( 'mwEmbed.js' ) !== -1 ) { |
| 1255 | + mwpath = src.substr( 0, src.indexOf( 'mwEmbed.js' ) ); |
| 1256 | + } |
| 1257 | + |
| 1258 | + // Check for scriptLoader include of mwEmbed: |
| 1259 | + if ( src.indexOf( 'mwScriptLoader.php' ) !== -1 ) { |
| 1260 | + // Script loader is in the root of MediaWiki, Include the default mwEmbed extension path: |
| 1261 | + mwpath = src.substr( 0, src.indexOf( 'mwScriptLoader.php' ) ) + $.conf.mediaWikiPath; |
| 1262 | + } |
| 1263 | + |
| 1264 | + // Script-loader has jsScriptLoader name when local: |
| 1265 | + if( src.indexOf( 'jsScriptLoader.php' ) !== -1 ){ |
| 1266 | + mwpath = src.substr( 0, src.indexOf( 'jsScriptLoader.php' ) ); |
| 1267 | + } |
| 1268 | + |
| 1269 | + // Error out if we could not get the path: |
| 1270 | + if( ! mwpath ){ |
| 1271 | + js_log( "Error could not get mwEmbed path " ); |
| 1272 | + return ; |
| 1273 | + } |
| 1274 | + |
| 1275 | + // Update the cached var with the absolute path: |
| 1276 | + mwEmbedPath = $.absoluteUrl( mwpath ) ; |
| 1277 | + return mwEmbedPath; |
| 1278 | + } |
| 1279 | + |
| 1280 | + // Local mwEmbedSrc variable ( for cache of $.getMwEmbedSrc ) |
| 1281 | + var mwEmbedSrc = null; |
| 1282 | + |
| 1283 | + /** |
| 1284 | + * Gets the mwEmbed script src attribute |
| 1285 | + */ |
| 1286 | + $.getMwEmbedSrc = function() { |
| 1287 | + if ( mwEmbedSrc ) |
| 1288 | + return mwEmbedSrc; |
| 1289 | + |
| 1290 | + // Get all the javascript includes: |
| 1291 | + var js_elements = document.getElementsByTagName( "script" ); |
| 1292 | + for ( var i = 0; i < js_elements.length; i++ ) { |
| 1293 | + // Check for mwEmbed.js and/or script loader |
| 1294 | + var src = js_elements[i].getAttribute( "src" ); |
| 1295 | + if ( src ) { |
| 1296 | + if ( src.indexOf( 'mwEmbed.js' ) !== -1 || ( |
| 1297 | + ( src.indexOf( 'mwScriptLoader.php' ) !== -1 || src.indexOf( 'jsScriptLoader.php' ) !== -1 ) |
| 1298 | + && src.indexOf( 'mwEmbed' ) !== -1 ) ) // (check for class=mwEmbed script_loader call) |
| 1299 | + { |
| 1300 | + mwEmbedSrc = src; |
| 1301 | + return mwEmbedSrc; |
| 1302 | + } |
| 1303 | + } |
| 1304 | + } |
| 1305 | + js_log( 'Error: getMwEmbedScriptURL failed to get script path' ); |
| 1306 | + return false; |
| 1307 | + } |
| 1308 | + |
| 1309 | + // Local mwUrlParam variable ( for cache of $.getUrlParam ) |
| 1310 | + var mwUrlParam = null; |
| 1311 | + |
| 1312 | + /** |
| 1313 | + * Get URL Paramaters per paramaters in the host script include |
| 1314 | + */ |
| 1315 | + $.getUrlParam = function() { |
| 1316 | + if ( mwUrlParam ) |
| 1317 | + return mwUrlParam; |
| 1318 | + |
| 1319 | + var mwEmbedSrc = $.getMwEmbedSrc(); |
| 1320 | + var req_param = ''; |
| 1321 | + |
| 1322 | + // If we already have a URI, add it to the param request: |
| 1323 | + var urid = mw.parseUri( mwEmbedSrc ).queryKey['urid'] |
| 1324 | + |
| 1325 | + // If we're in debug mode, get a fresh unique request key and pass on "debug" param |
| 1326 | + if ( mw.parseUri( mwEmbedSrc ).queryKey['debug'] == 'true' ) { |
| 1327 | + |
| 1328 | + var d = new Date(); |
| 1329 | + req_param += 'urid=' + d.getTime() + '&debug=true'; |
| 1330 | + |
| 1331 | + } else if ( urid ) { // Just pass on the existing urid: |
| 1332 | + |
| 1333 | + req_param += 'urid=' + urid; |
| 1334 | + } else { |
| 1335 | + // Otherwise, Use the mwEmbed version |
| 1336 | + req_param += 'urid=' + mw.version; |
| 1337 | + } |
| 1338 | + |
| 1339 | + // Add the language param: |
| 1340 | + var langKey = mw.parseUri( mwEmbedSrc ).queryKey['uselang']; |
| 1341 | + if ( langKey ) |
| 1342 | + req_param += '&uselang=' + langKey; |
| 1343 | + |
| 1344 | + // Update the local cache and return the value |
| 1345 | + mwUrlParam = req_param; |
| 1346 | + return mwUrlParam; |
| 1347 | + } |
| 1348 | + |
| 1349 | + /** |
| 1350 | + * parseUri 1.2.2 |
| 1351 | + * (c) Steven Levithan <stevenlevithan.com> |
| 1352 | + * MIT License |
| 1353 | + */ |
| 1354 | + $.parseUri = function (str) { |
| 1355 | + var o = $.parseUri.options, |
| 1356 | + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), |
| 1357 | + uri = {}, |
| 1358 | + i = 14; |
| 1359 | + |
| 1360 | + while (i--) uri[o.key[i]] = m[i] || ""; |
| 1361 | + |
| 1362 | + uri[o.q.name] = {}; |
| 1363 | + uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { |
| 1364 | + if ($1) uri[o.q.name][$1] = $2; |
| 1365 | + }); |
| 1366 | + |
| 1367 | + return uri; |
| 1368 | + }; |
| 1369 | + |
| 1370 | + /** |
| 1371 | + * Parse URI function |
| 1372 | + * |
| 1373 | + * For documentation on its usage see: |
| 1374 | + * http://stevenlevithan.com/demo/parseuri/js/ |
| 1375 | + */ |
| 1376 | + $.parseUri.options = { |
| 1377 | + strictMode: false, |
| 1378 | + key: ["source", "protocol", "authority", "userInfo", "user","password","host","port","relative","path","directory","file","query","anchor"], |
| 1379 | + q: { |
| 1380 | + name: "queryKey", |
| 1381 | + parser: /(?:^|&)([^&=]*)=?([^&]*)/g |
| 1382 | + }, |
| 1383 | + parser: { |
| 1384 | + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, |
| 1385 | + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ |
| 1386 | + } |
| 1387 | + }; |
| 1388 | + |
| 1389 | + /** |
| 1390 | + * getAbsoluteUrl takes a src and returns the absolute location given the document.URL |
| 1391 | + * |
| 1392 | + * @param {String} src path or url |
| 1393 | + * @return {String} absolute url |
| 1394 | + */ |
| 1395 | + $.absoluteUrl = function( src, contextUrl ){ |
| 1396 | + var pSrc = mw.parseUri( src ); |
| 1397 | + if( pSrc.protocol != '') |
| 1398 | + return src; |
| 1399 | + |
| 1400 | + // Get parent Url location the context URL |
| 1401 | + if( contextUrl){ |
| 1402 | + var pUrl = mw.parseUri( contextUrl ); |
| 1403 | + } else { |
| 1404 | + var pUrl = mw.parseUri( document.URL ); |
| 1405 | + } |
| 1406 | + // If a leading slash: |
| 1407 | + if( src.indexOf( '/' ) == 1 ){ |
| 1408 | + return pUrl.protocol + '://' + pUrl.authority + src; |
| 1409 | + }else{ |
| 1410 | + return pUrl.protocol + '://' + pUrl.authority + pUrl.directory + src; |
| 1411 | + } |
| 1412 | + }; |
| 1413 | + |
| 1414 | + /** |
| 1415 | + * Takes in a string returns an xml dom object |
| 1416 | + * |
| 1417 | + * @param {String} str String of XML content to be parsed |
| 1418 | + * @return |
| 1419 | + * {Object} XML |
| 1420 | + * false If XML could not be parsed |
| 1421 | + * |
| 1422 | + */ |
| 1423 | + $.parseXML = function ( str ){ |
| 1424 | + if ( $j.browser.msie ) { |
| 1425 | + // Attempt to parse as XML for IE |
| 1426 | + var xmldata = new ActiveXObject( "Microsoft.XMLDOM" ); |
| 1427 | + xmldata.async = "false"; |
| 1428 | + try{ |
| 1429 | + xmldata.loadXML( str ); |
| 1430 | + return xmldata; |
| 1431 | + } catch (e){ |
| 1432 | + js_log( 'XML parse ERROR: ' + e.message ); |
| 1433 | + return false; |
| 1434 | + } |
| 1435 | + } |
| 1436 | + |
| 1437 | + // For others (Firefox, Safari etc, older browsers |
| 1438 | + // Some don't have native DOMParser either fallback defined bellow. |
| 1439 | + try { |
| 1440 | + var xmldata = ( new DOMParser() ).parseFromString( str, "text/xml" ); |
| 1441 | + } catch ( e ) { |
| 1442 | + js_log( 'XML parse ERROR: ' + e.message ); |
| 1443 | + return false; |
| 1444 | + } |
| 1445 | + return xmldata; |
| 1446 | + } |
| 1447 | +} )( window.mw ); |
| 1448 | + |
| 1449 | +// load in js2 stopgap into proper location: |
| 1450 | +if ( typeof gMsg != 'undefined' ) { |
| 1451 | + mw.addMessages( gMsg ) |
| 1452 | +} |
| 1453 | + |
| 1454 | +var gM = mw.lang.gM; |
| 1455 | +// setup legacy global shortcuts: |
| 1456 | +var loadRS = mw.lang.loadRS; |
| 1457 | + |
| 1458 | +/** |
| 1459 | + * -- Load Class Paths -- |
| 1460 | + * |
| 1461 | + * MUST BE VALID JSON (NOT JS) |
| 1462 | + * This is used by the script loader to auto-load classes (so we only define |
| 1463 | + * this once for PHP & JavaScript) |
| 1464 | + * |
| 1465 | + * Right now the PHP AutoLoader only reads this mwEmbed.js file. |
| 1466 | + * In the future we could have multiple "loader" files |
| 1467 | + * |
| 1468 | + */ |
| 1469 | + |
| 1470 | + |
| 1471 | +mw.addClassFilePaths( { |
| 1472 | + "mwEmbed" : "mwEmbed.js", |
| 1473 | + "window.jQuery" : "jquery/jquery-1.3.2.js", |
| 1474 | + "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", |
| 1475 | + "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", |
| 1476 | + "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", |
| 1477 | + "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
| 1478 | + "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
| 1479 | + "$j.fn.ColorPicker" : "libClipEdit/colorpicker/js/colorpicker.js", |
| 1480 | + "$j.Jcrop" : "libClipEdit/Jcrop/js/jquery.Jcrop.js", |
| 1481 | + "$j.fn.simpleUploadForm" : "libAddMedia/simpleUploadForm.js", |
| 1482 | + |
| 1483 | + "mw.proxy" : "libMwApi/mw.proxy.js", |
| 1484 | + |
| 1485 | + "mw.testLang" : "tests/testLang.js", |
| 1486 | + |
| 1487 | + "ctrlBuilder" : "skins/ctrlBuilder.js", |
| 1488 | + "kskinConfig" : "skins/kskin/kskin.js", |
| 1489 | + "mvpcfConfig" : "skins/mvpcf/mvpcf.js", |
| 1490 | + |
| 1491 | + "JSON" : "libMwApi/json2.js", |
| 1492 | + "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
| 1493 | + "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
| 1494 | + "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
| 1495 | + "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
| 1496 | + |
| 1497 | + "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
| 1498 | + "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
| 1499 | + "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js", |
| 1500 | + "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js", |
| 1501 | + "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js", |
| 1502 | + "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js", |
| 1503 | + "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js", |
| 1504 | + "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js", |
| 1505 | + "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js", |
| 1506 | + "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js", |
| 1507 | + "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js", |
| 1508 | + "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js", |
| 1509 | + "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js", |
| 1510 | + "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js", |
| 1511 | + "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js", |
| 1512 | + "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js", |
| 1513 | + "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js", |
| 1514 | + "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js", |
| 1515 | + "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js", |
| 1516 | + "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js", |
| 1517 | + "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js", |
| 1518 | + "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js", |
| 1519 | + "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", |
| 1520 | + "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js", |
| 1521 | + |
| 1522 | + "$j.fn.dragDropFile" : "libAddMedia/dragDropFile.js", |
| 1523 | + "mvFirefogg" : "libAddMedia/mvFirefogg.js", |
| 1524 | + "mvAdvFirefogg" : "libAddMedia/mvAdvFirefogg.js", |
| 1525 | + "mvBaseUploadInterface" : "libAddMedia/mvBaseUploadInterface.js", |
| 1526 | + "remoteSearchDriver" : "libAddMedia/remoteSearchDriver.js", |
| 1527 | + "seqRemoteSearchDriver" : "libSequencer/seqRemoteSearchDriver.js", |
| 1528 | + |
| 1529 | + "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", |
| 1530 | + "mediaWikiSearch" : "libAddMedia/searchLibs/mediaWikiSearch.js", |
| 1531 | + "metavidSearch" : "libAddMedia/searchLibs/metavidSearch.js", |
| 1532 | + "archiveOrgSearch" : "libAddMedia/searchLibs/archiveOrgSearch.js", |
| 1533 | + "flickrSearch" : "libAddMedia/searchLibs/flickrSearch.js", |
| 1534 | + "baseRemoteSearch" : "libAddMedia/searchLibs/baseRemoteSearch.js", |
| 1535 | + |
| 1536 | + "mvClipEdit" : "libClipEdit/mvClipEdit.js", |
| 1537 | + |
| 1538 | + "mvPlayList" : "libSequencer/mvPlayList.js", |
| 1539 | + "mvSequencer" : "libSequencer/mvSequencer.js", |
| 1540 | + "mvFirefoggRender" : "libSequencer/mvFirefoggRender.js", |
| 1541 | + "mvTimedEffectsEdit": "libSequencer/mvTimedEffectsEdit.js", |
| 1542 | + |
| 1543 | + "mvTextInterface" : "libTimedText/mvTextInterface.js", |
| 1544 | + "mvTimeTextEdit" : "libTimedText/mvTimeTextEdit.js" |
| 1545 | + |
| 1546 | +} ); |
| 1547 | + |
| 1548 | +/** |
| 1549 | +* libEmbedPlayer Depenency Module Loader: |
| 1550 | +* |
| 1551 | +* NOTE: this code block could eventually be put in: |
| 1552 | +* "libEmbedPlayer/loader.js" |
| 1553 | +* |
| 1554 | +* That it could be dynamically inserted into mwEmbed requests |
| 1555 | +* at poit of release or at runtime via the script-loader. |
| 1556 | +* |
| 1557 | +* A per module loader enables a dynamic set of modules with only minimal |
| 1558 | +* loader code per module in the core mwEmbed included js |
| 1559 | +* |
| 1560 | +*/ |
| 1561 | +// Add class file paths: |
| 1562 | +mw.addClassFilePaths( { |
| 1563 | + "embedPlayer" : "libEmbedPlayer/embedPlayer.js", |
| 1564 | + "flowplayerEmbed" : "libEmbedPlayer/flowplayerEmbed.js", |
| 1565 | + "kplayerEmbed" : "libEmbedPlayer/kplayerEmbed.js", |
| 1566 | + "genericEmbed" : "libEmbedPlayer/genericEmbed.js", |
| 1567 | + "htmlEmbed" : "libEmbedPlayer/htmlEmbed.js", |
| 1568 | + "javaEmbed" : "libEmbedPlayer/javaEmbed.js", |
| 1569 | + "nativeEmbed" : "libEmbedPlayer/nativeEmbed.js", |
| 1570 | + "quicktimeEmbed" : "libEmbedPlayer/quicktimeEmbed.js", |
| 1571 | + "vlcEmbed" : "libEmbedPlayer/vlcEmbed.js", |
| 1572 | + |
| 1573 | +} ); |
| 1574 | + |
| 1575 | +// Add the module loader function: |
| 1576 | +mw.addModuleLoader( 'player', function(){ |
| 1577 | + var _this = this; |
| 1578 | + js_log( 'loadModule: player :' ); |
| 1579 | + |
| 1580 | + // Set module specifc class videonojs to loading: |
| 1581 | + $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) ); |
| 1582 | + |
| 1583 | + // Set up the embed video player class request: (include the skin js as well) |
| 1584 | + var dependencyRequest = [ |
| 1585 | + [ |
| 1586 | + '$j.ui', |
| 1587 | + 'embedPlayer', |
| 1588 | + 'ctrlBuilder', |
| 1589 | + '$j.cookie' |
| 1590 | + ], |
| 1591 | + [ |
| 1592 | + '$j.ui.slider' |
| 1593 | + ] |
| 1594 | + ]; |
| 1595 | + |
| 1596 | + // Get any other skins that we need to load |
| 1597 | + // That way skin js can be part of the single script-loader request: |
| 1598 | + |
| 1599 | + var sn = e[j][k].getAttribute('class'); |
| 1600 | + if( sn && sn != ''){ |
| 1601 | + for(var n=0;n< $mw.valid_skins.length;n++){ |
| 1602 | + if( sn.indexOf($mw.valid_skins[n]) !== -1){ |
| 1603 | + $mw.skin_list.push( $mw.valid_skins[n] ); |
| 1604 | + } |
| 1605 | + } |
| 1606 | + } |
| 1607 | + // Add any requested skins (supports multiple skins per single page) |
| 1608 | + if ( mw.skin_list ) { |
| 1609 | + for ( var i in mw.skin_list ) { |
| 1610 | + depReq[0].push( mw.skin_list[i] + 'Config' ); |
| 1611 | + } |
| 1612 | + } |
| 1613 | + |
| 1614 | + // Add PNG fix if needed: |
| 1615 | + if ( $j.browser.msie || $j.browser.version < 7 ) |
| 1616 | + depReq[0].push( '$j.fn.pngFix' ); |
| 1617 | + |
| 1618 | + // Load the video libs: |
| 1619 | + _this.doLoadDepMode( depReq, function() { |
| 1620 | + embedTypes.init(); |
| 1621 | + callback(); |
| 1622 | + $j( '.videonojs' ).remove(); |
| 1623 | + } ); |
| 1624 | + |
| 1625 | +} ); |
| 1626 | + |
| 1627 | + |
| 1628 | + |
| 1629 | + |
| 1630 | + |
| 1631 | + |
| 1632 | + |
| 1633 | + |
| 1634 | + |
| 1635 | +// Add the core mvEmbed Messages ( will be localized by script server ) |
| 1636 | +mw.addMessages( { |
| 1637 | + "mwe-loading_txt" : "Loading ...", |
| 1638 | + "mwe-size-gigabytes" : "$1 GB", |
| 1639 | + "mwe-size-megabytes" : "$1 MB", |
| 1640 | + "mwe-size-kilobytes" : "$1 K", |
| 1641 | + "mwe-size-bytes" : "$1 B", |
| 1642 | + "mwe-error_load_lib" : "Error: JavaScript $1 was not retrievable or does not define $2", |
| 1643 | + "mwe-loading-add-media-wiz" : "Loading add media wizard", |
| 1644 | + "mwe-apiproxy-setup" : "Setting up API proxy", |
| 1645 | + "mwe-load-drag-item" : "Loading dragged item", |
| 1646 | + "mwe-ok" : "OK", |
| 1647 | + "mwe-cancel" : "Cancel" |
| 1648 | +} ); |
| 1649 | + |
| 1650 | + |
| 1651 | + |
| 1652 | + |
| 1653 | +/** |
| 1654 | +* Set DOM-ready call |
| 1655 | +* Does not use jQuery( document ).ready( ) because |
| 1656 | +* mwEmbed could have been included without jQuery. |
| 1657 | +*/ |
| 1658 | +// For Mozilla / modern browsers |
| 1659 | +if ( document.addEventListener ) { |
| 1660 | + document.addEventListener( "DOMContentLoaded", mw.domReady, false ); |
| 1661 | +} |
| 1662 | +// Preserve any existing window.onload binding: |
| 1663 | +var mwOriginalOnLoad; |
| 1664 | +if ( window.onload && typeof window.onload == 'function' ) { |
| 1665 | + mwOriginalOnLoad = window.onload; |
| 1666 | +} |
| 1667 | +// Use the onload method as a backup: |
| 1668 | +window.onload = function () { |
| 1669 | + if ( mwOriginalOnLoad ) |
| 1670 | + mwOriginalOnLoad(); |
| 1671 | + mw.domReady(); |
| 1672 | +} |
| 1673 | + |
| 1674 | + |
| 1675 | + |
| 1676 | + |
| 1677 | + |
| 1678 | + |
| 1679 | + |
| 1680 | + |
| 1681 | + |
| 1682 | + |
| 1683 | + |
| 1684 | + |
| 1685 | + |
| 1686 | + |
| 1687 | + |
| 1688 | + |
| 1689 | + |
| 1690 | +// Get the loading image |
| 1691 | +function mv_get_loading_img( style, class_attr ) { |
| 1692 | + var style_txt = ( style ) ? style:''; |
| 1693 | + var class_attr = ( class_attr ) ? 'class="' + class_attr + '"' : 'class="mv_loading_img"'; |
| 1694 | + return '<div ' + class_attr + ' style="' + style + '"></div>'; |
| 1695 | +} |
| 1696 | + |
| 1697 | +function mv_set_loading( target, load_id ) { |
| 1698 | + var id_attr = ( load_id ) ? ' id="' + load_id + '" ':''; |
| 1699 | + $j( target ).append( '<div ' + id_attr + ' style="position:absolute;top:0px;left:0px;height:100%;width:100%;' + |
| 1700 | + 'background-color:#FFF;">' + |
| 1701 | + mv_get_loading_img( 'top:30px;left:30px' ) + |
| 1702 | + '</div>' ); |
| 1703 | +} |
| 1704 | + |
| 1705 | +/** |
| 1706 | +* mvJsLoader class handles initialization and js file loads |
| 1707 | + |
| 1708 | +var mvJsLoader = { |
| 1709 | + libreq : { }, |
| 1710 | + libs : { }, |
| 1711 | + |
| 1712 | + // Base lib flags |
| 1713 | + onReadyEvents: new Array(), |
| 1714 | + doneReadyEvents: false, |
| 1715 | + jQuerySetupFlag: false, |
| 1716 | + |
| 1717 | + // To keep consistency across threads |
| 1718 | + ptime: 0, |
| 1719 | + ctime: 0, |
| 1720 | + |
| 1721 | + load_error: false, // Load error flag (false by default) |
| 1722 | + load_time: 0, |
| 1723 | + callbacks: new Array(), |
| 1724 | + cur_path: null, |
| 1725 | + missing_path : null, |
| 1726 | + doLoad: function( loadLibs, callback ) { |
| 1727 | + this.ctime++; |
| 1728 | + if ( loadLibs && loadLibs.length != 0 ) { |
| 1729 | + // js_log("doLoad setup::" + JSON.stringify( loadLibs ) ); |
| 1730 | + // Set up this.libs |
| 1731 | + // First check if we already have this library loaded |
| 1732 | + var all_libs_loaded = true; |
| 1733 | + for ( var i = 0; i < loadLibs.length; i++ ) { |
| 1734 | + // Check if the library is already loaded |
| 1735 | + if ( ! this.checkObjPath( loadLibs[i] ) ) { |
| 1736 | + all_libs_loaded = false; |
| 1737 | + } |
| 1738 | + } |
| 1739 | + |
| 1740 | + if ( all_libs_loaded ) { |
| 1741 | + js_log( 'Libraries ( ' + loadLibs + ') already loaded... skipping load request' ); |
| 1742 | + callback(); |
| 1743 | + return; |
| 1744 | + } |
| 1745 | + |
| 1746 | + // Do a check for any CSS we may need and get it |
| 1747 | + for ( var i = 0; i < loadLibs.length; i++ ) { |
| 1748 | + if ( typeof mvCssPaths[ loadLibs[i] ] != 'undefined' ) { |
| 1749 | + loadExternalCss( mw.getMwEmbedPath() + mvCssPaths[ loadLibs[i] ] ); |
| 1750 | + } |
| 1751 | + } |
| 1752 | + |
| 1753 | + // Check if we should use the script loader to combine all the requests into one |
| 1754 | + // ( the scriptloader defines the mwSlScript global ) |
| 1755 | + if ( typeof mwSlScript != 'undefined' ) { |
| 1756 | + var class_set = ''; |
| 1757 | + var last_class = ''; |
| 1758 | + var coma = ''; |
| 1759 | + for ( var i = 0; i < loadLibs.length; i++ ) { |
| 1760 | + var curLib = loadLibs[i]; |
| 1761 | + // Only add if not included yet: |
| 1762 | + if ( ! this.checkObjPath( curLib ) ) { |
| 1763 | + class_set += coma + curLib; |
| 1764 | + last_class = curLib; |
| 1765 | + coma = ','; |
| 1766 | + } |
| 1767 | + } |
| 1768 | + // Build the url to the scriptServer striping its request parameters: |
| 1769 | + var puri = mw.parseUri( getMwEmbedURL() ); |
| 1770 | + if ( ( getMwEmbedURL().indexOf( '://' ) != -1 ) |
| 1771 | + && puri.host != mw.parseUri( document.URL ).host ) |
| 1772 | + { |
| 1773 | + var scriptPath = puri.protocol + '://' + puri.authority + puri.path; |
| 1774 | + } else { |
| 1775 | + var scriptPath = puri.path; |
| 1776 | + } |
| 1777 | + // js_log('scriptServer Path is: ' + scriptPath + "\n host script path:" + getMwEmbedURL() ); |
| 1778 | + this.libs[ last_class ] = scriptPath + '?class=' + class_set + |
| 1779 | + '&' + mw.getUrlParam(); |
| 1780 | + |
| 1781 | + } else { |
| 1782 | + // Do many requests |
| 1783 | + for ( var i = 0; i < loadLibs.length; i++ ) { |
| 1784 | + var curLib = loadLibs[i]; |
| 1785 | + if ( curLib ) { |
| 1786 | + var libLoc = mvGetClassPath( curLib ); |
| 1787 | + // Do a direct load of the file (pass along unique request id from |
| 1788 | + // request or mwEmbed Version ) |
| 1789 | + var qmark = ( libLoc.indexOf( '?' ) !== true ) ? '?' : '&'; |
| 1790 | + this.libs[curLib] = mw.getMwEmbedPath() + libLoc + qmark + mw.getUrlParam(); |
| 1791 | + } |
| 1792 | + } |
| 1793 | + } |
| 1794 | + } |
| 1795 | + |
| 1796 | + if ( callback ) { |
| 1797 | + this.callbacks.push( callback ); |
| 1798 | + } |
| 1799 | + if ( this.checkLoading() ) { |
| 1800 | + // @@todo we should check the <script> Element .onLoad property to |
| 1801 | + // make sure its just not a very slow connection |
| 1802 | + // (even though the class is not loaded) |
| 1803 | + if ( this.load_time++ > 4000 ) { // Time out after ~80 seconds |
| 1804 | + js_log( gM( 'mwe-error_load_lib', [mvGetClassPath( this.missing_path ), this.missing_path] ) ); |
| 1805 | + this.load_error = true; |
| 1806 | + } else { |
| 1807 | + setTimeout( 'mw.load()', 20 ); |
| 1808 | + } |
| 1809 | + } else { |
| 1810 | + // js_log('checkLoading passed. Running callbacks...'); |
| 1811 | + // Only do callbacks if we are in the same instance (weird concurrency issue) |
| 1812 | + var cb_count = 0; |
| 1813 | + for ( var i = 0; i < this.callbacks.length; i++ ) |
| 1814 | + cb_count++; |
| 1815 | + // js_log('RESET LIBS: loading is: '+ loading + ' callback count: '+cb_count + |
| 1816 | + // ' p:'+ this.ptime +' c:'+ this.ctime); |
| 1817 | + |
| 1818 | + // Reset the libs |
| 1819 | + this.libs = { }; |
| 1820 | + // js_log('done loading, do call: ' + this.callbacks[0] ); |
| 1821 | + while ( this.callbacks.length != 0 ) { |
| 1822 | + if ( this.ptime == this.ctime - 1 ) { // Enforce thread consistency |
| 1823 | + this.callbacks.pop()(); |
| 1824 | + // func = this.callbacks.pop(); |
| 1825 | + // js_log(' run: '+this.ctime+ ' p: ' + this.ptime + ' ' +loading+ ' :'+ func); |
| 1826 | + // func(); |
| 1827 | + } else { |
| 1828 | + // Re-issue doLoad ( ptime will be set to ctime so we should catch up) |
| 1829 | + setTimeout( 'mw.load()', 25 ); |
| 1830 | + break; |
| 1831 | + } |
| 1832 | + } |
| 1833 | + } |
| 1834 | + this.ptime = this.ctime; |
| 1835 | + }, |
| 1836 | + doLoadDepMode: function( loadChain, callback ) { |
| 1837 | + // Firefox executes JS in the order in which it is included, so just directly issue the request |
| 1838 | + if ( $j.browser.firefox ) { |
| 1839 | + var loadSet = []; |
| 1840 | + for ( var i = 0; i < loadChain.length; i++ ) { |
| 1841 | + for ( var j = 0; j < loadChain[i].length; j++ ) { |
| 1842 | + loadSet.push( loadChain[i][j] ); |
| 1843 | + } |
| 1844 | + } |
| 1845 | + mw.load( loadSet, callback ); |
| 1846 | + } else { |
| 1847 | + // Safari and IE tend to execute out of order so load with dependency checks |
| 1848 | + mw.load( loadChain.shift(), function() { |
| 1849 | + if ( loadChain.length != 0 ) { |
| 1850 | + mw.load( loadChain, callback ); |
| 1851 | + } else { |
| 1852 | + callback(); |
| 1853 | + } |
| 1854 | + } ); |
| 1855 | + } |
| 1856 | + }, |
| 1857 | + checkLoading: function() { |
| 1858 | + var loading = 0; |
| 1859 | + var i = null; |
| 1860 | + for ( var i in this.libs ) { // for/in loop is OK on an object |
| 1861 | + if ( !this.checkObjPath( i ) ) { |
| 1862 | + if ( !this.libreq[i] ) { |
| 1863 | + loadExternalJs( this.libs[i] ); |
| 1864 | + } |
| 1865 | + this.libreq[i] = 1; |
| 1866 | + // js_log("has not yet loaded: " + i); |
| 1867 | + loading = 1; |
| 1868 | + } |
| 1869 | + } |
| 1870 | + return loading; |
| 1871 | + }, |
| 1872 | + checkObjPath: function( libVar ) { |
| 1873 | + if ( !libVar ) |
| 1874 | + return false; |
| 1875 | + var objPath = libVar.split( '.' ) |
| 1876 | + var cur_path = ''; |
| 1877 | + for ( var p = 0; p < objPath.length; p++ ) { |
| 1878 | + cur_path = ( cur_path == '' ) ? cur_path + objPath[p] : cur_path + '.' + objPath[p]; |
| 1879 | + eval( 'var ptest = typeof ( ' + cur_path + ' ); ' ); |
| 1880 | + if ( ptest == 'undefined' ) { |
| 1881 | + this.missing_path = cur_path; |
| 1882 | + return false; |
| 1883 | + } |
| 1884 | + } |
| 1885 | + this.cur_path = cur_path; |
| 1886 | + return true; |
| 1887 | + }, |
| 1888 | + // |
| 1889 | + // checks for jQuery and adds the $j noConflict var |
| 1890 | + // |
| 1891 | + jQueryCheck: function( callback ) { |
| 1892 | + // js_log( 'jQueryCheck::' + this.jQuerySetupFlag); |
| 1893 | + var _this = this; |
| 1894 | + if ( _global['$j'] && _this.jQuerySetupFlag ) { |
| 1895 | + callback(); // call the callback now |
| 1896 | + } |
| 1897 | + // Load jQuery |
| 1898 | + _this.doLoad( [ |
| 1899 | + 'window.jQuery' |
| 1900 | + ], function() { |
| 1901 | + |
| 1902 | + } ); |
| 1903 | + }, |
| 1904 | + embedPlayerCheck:function( callback ) { |
| 1905 | + var _this = this; |
| 1906 | + js_log( 'embedPlayerCheck:' ); |
| 1907 | + // Make sure we have jQuery |
| 1908 | + _this.jQueryCheck( function() { |
| 1909 | + // set class videonojs to loading |
| 1910 | + $j( '.videonojs' ).html( gM( 'mwe-loading_txt' ) ); |
| 1911 | + // Set up the embed video player class request: (include the skin js as well) |
| 1912 | + var depReq = [ |
| 1913 | + [ |
| 1914 | + '$j.ui', |
| 1915 | + 'embedPlayer', |
| 1916 | + 'ctrlBuilder', |
| 1917 | + '$j.cookie' |
| 1918 | + ], |
| 1919 | + [ |
| 1920 | + '$j.ui.slider' |
| 1921 | + ] |
| 1922 | + ]; |
| 1923 | + |
| 1924 | + // add any requested skins (supports multiple skins per single page) |
| 1925 | + if ( mw.skin_list ) { |
| 1926 | + for ( var i in mw.skin_list ) { |
| 1927 | + depReq[0].push( mw.skin_list[i] + 'Config' ); |
| 1928 | + } |
| 1929 | + } |
| 1930 | + |
| 1931 | + // Add PNG fix if needed: |
| 1932 | + if ( $j.browser.msie || $j.browser.version < 7 ) |
| 1933 | + depReq[0].push( '$j.fn.pngFix' ); |
| 1934 | + |
| 1935 | + // load the video libs: |
| 1936 | + _this.doLoadDepMode( depReq, function() { |
| 1937 | + embedTypes.init(); |
| 1938 | + callback(); |
| 1939 | + $j( '.videonojs' ).remove(); |
| 1940 | + } ); |
| 1941 | + } ); |
| 1942 | + }, |
| 1943 | + addLoadEvent: function( fn ) { |
| 1944 | + // js_log('add ready event: ' + fn ); |
| 1945 | + this.onReadyEvents.push( fn ); |
| 1946 | + }, |
| 1947 | + // Check the jQuery flag. This way, when remote embedding, we don't load jQuery |
| 1948 | + // unless mw.addOnloadHook was used or there is video on the page. |
| 1949 | + runQueuedFunctions: function() { |
| 1950 | + js_log( "runQueuedFunctions" ); |
| 1951 | + var _this = this; |
| 1952 | + this.jQueryCheck( function() { |
| 1953 | + _this.runReadyEvents(); |
| 1954 | + _this.doneReadyEvents = true; |
| 1955 | + } ); |
| 1956 | + }, |
| 1957 | + runReadyEvents: function() { |
| 1958 | + js_log( "runReadyEvents" + this.onReadyEvents.length ); |
| 1959 | + while ( this.onReadyEvents.length ) { |
| 1960 | + var func = this.onReadyEvents.shift(); |
| 1961 | + // js_log('run onReady:: ' + func ); |
| 1962 | + func(); |
| 1963 | + } |
| 1964 | + } |
| 1965 | +} |
| 1966 | +*/ |
| 1967 | + |
| 1968 | + |
| 1969 | +/* |
| 1970 | +* js2AddOnloadHook depreciated use mw.addOnloadHook instead |
| 1971 | +*/ |
| 1972 | +function js2AddOnloadHook( func ) { |
| 1973 | + mw.addOnloadHook( func ); |
| 1974 | +} |
| 1975 | + |
| 1976 | + |
| 1977 | +/* |
| 1978 | + * Store all the mwEmbed jQuery-specific bindings |
| 1979 | + * (set up after jQuery is available). |
| 1980 | + * |
| 1981 | + * These functions are generally are loaders that do the dynamic mapping of |
| 1982 | + * dependencies for a given component |
| 1983 | + * |
| 1984 | + * Should be repaced by "loader" calls |
| 1985 | + * |
| 1986 | + * |
| 1987 | + */ |
| 1988 | +function mwDojQueryBindings() { |
| 1989 | + js_log( 'mv_jqueryBindings' ); |
| 1990 | + ( function( $ ) { |
| 1991 | + /* |
| 1992 | + * dragDrop file loader |
| 1993 | + */ |
| 1994 | + $.fn.dragFileUpload = function ( conf ) { |
| 1995 | + if ( this.selector ) { |
| 1996 | + var _this = this; |
| 1997 | + // load the dragger and "setup" |
| 1998 | + mw.load( ['$j.fn.dragDropFile'], function() { |
| 1999 | + $j( _this.selector ).dragDropFile(); |
| 2000 | + } ); |
| 2001 | + } |
| 2002 | + } |
| 2003 | + /* |
| 2004 | + * apiProxy Loader loader: |
| 2005 | + * |
| 2006 | + * @param mode is either 'server' or 'client' |
| 2007 | + */ |
| 2008 | + $.apiProxy = function( mode, pConf, callback ) { |
| 2009 | + js_log( 'do apiProxy setup' ); |
| 2010 | + mw.load( [ |
| 2011 | + 'mw.proxy', |
| 2012 | + 'JSON' |
| 2013 | + ], function() { |
| 2014 | + // do the proxy setup or |
| 2015 | + if ( mode == 'client' ) { |
| 2016 | + // just do the setup (no callbcak for client setup) |
| 2017 | + mw.proxy.client( pConf ); |
| 2018 | + if ( callback ) |
| 2019 | + callback(); |
| 2020 | + } else if ( mode == 'server' ) { |
| 2021 | + // do the request with the callback |
| 2022 | + mw.proxy.server( pConf , callback ); |
| 2023 | + } |
| 2024 | + } ); |
| 2025 | + } |
| 2026 | + |
| 2027 | + // non selector based add-media-wizard direct invocation with loader |
| 2028 | + $.addMediaWiz = function( options, callback ) { |
| 2029 | + js_log( ".addMediaWiz call" ); |
| 2030 | + // check if already loaded: |
| 2031 | + if ( _global['rsdMVRS'] ) { |
| 2032 | + _global['rsdMVRS'].showDialog(); |
| 2033 | + if ( callback ) |
| 2034 | + callback( _global['rsdMVRS'] ); |
| 2035 | + return ; |
| 2036 | + } |
| 2037 | + // display a loader: |
| 2038 | + $.addLoaderDialog( gM( 'mwe-loading-add-media-wiz' ) ); |
| 2039 | + // load the addMedia wizard without a target: |
| 2040 | + $.fn.addMediaWiz ( options, function( amwObj ) { |
| 2041 | + // close the dialog |
| 2042 | + $.closeLoaderDialog(); |
| 2043 | + // do the add-media-wizard display |
| 2044 | + amwObj.createUI(); |
| 2045 | + // call the parent callback: |
| 2046 | + if ( callback ) |
| 2047 | + callback( _global['rsdMVRS'] ); |
| 2048 | + } ); |
| 2049 | + } |
| 2050 | + |
| 2051 | + $.fn.addMediaWiz = function( options, callback ) { |
| 2052 | + if ( this.selector ) { |
| 2053 | + // First set the cursor for the button to "loading" |
| 2054 | + $j( this.selector ).css( 'cursor', 'wait' ).attr( 'title', gM( 'mwe-loading_txt' ) ); |
| 2055 | + // set the target: |
| 2056 | + options['target_invoke_button'] = this.selector; |
| 2057 | + } |
| 2058 | + |
| 2059 | + // Load the mwEmbed_base skin: |
| 2060 | + loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
| 2061 | + loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/styles.css' ); |
| 2062 | + // Load all the required libs: |
| 2063 | + mw.load( [ |
| 2064 | + [ 'remoteSearchDriver', |
| 2065 | + '$j.cookie', |
| 2066 | + '$j.fn.textSelection', |
| 2067 | + '$j.ui' |
| 2068 | + ], [ |
| 2069 | + '$j.ui.resizable', |
| 2070 | + '$j.ui.draggable', |
| 2071 | + '$j.ui.dialog', |
| 2072 | + '$j.ui.tabs', |
| 2073 | + '$j.ui.sortable' |
| 2074 | + ] |
| 2075 | + ], function() { |
| 2076 | + options['instance_name'] = 'rsdMVRS'; |
| 2077 | + if ( ! _global['rsdMVRS'] ) |
| 2078 | + _global['rsdMVRS'] = new remoteSearchDriver( options ); |
| 2079 | + if ( callback ) { |
| 2080 | + callback( _global['rsdMVRS'] ); |
| 2081 | + } |
| 2082 | + } ); |
| 2083 | + } |
| 2084 | + /* |
| 2085 | + * Sequencer loader |
| 2086 | + */ |
| 2087 | + $.fn.sequencer = function( options, callback ) { |
| 2088 | + // Debugger |
| 2089 | + options['target_sequence_container'] = this.selector; |
| 2090 | + // Issue a request to get the CSS file (if not already included): |
| 2091 | + loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
| 2092 | + loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/mv_sequence.css' ); |
| 2093 | + // Make sure we have the required mwEmbed libs (they are not loaded when no video |
| 2094 | + // element is on the page) |
| 2095 | + mvJsLoader.eembedPlayerheck( function() { |
| 2096 | + // Load the playlist object and then the jQuery UI stuff: |
| 2097 | + mw.load( [ |
| 2098 | + [ |
| 2099 | + 'mvPlayList', |
| 2100 | + '$j.ui', |
| 2101 | + '$j.contextMenu', |
| 2102 | + 'JSON', |
| 2103 | + 'mvSequencer' |
| 2104 | + ], |
| 2105 | + [ |
| 2106 | + '$j.ui.accordion', |
| 2107 | + '$j.ui.dialog', |
| 2108 | + '$j.ui.droppable', |
| 2109 | + '$j.ui.draggable', |
| 2110 | + '$j.ui.progressbar', |
| 2111 | + '$j.ui.sortable', |
| 2112 | + '$j.ui.resizable', |
| 2113 | + '$j.ui.slider', |
| 2114 | + '$j.ui.tabs' |
| 2115 | + ] |
| 2116 | + ], function() { |
| 2117 | + js_log( 'calling new mvSequencer' ); |
| 2118 | + // Initialise the sequence object (it will take over from there) |
| 2119 | + // No more than one mvSeq obj for now: |
| 2120 | + if ( !_global['mvSeq'] ) { |
| 2121 | + _global['mvSeq'] = new mvSequencer( options ); |
| 2122 | + } else { |
| 2123 | + js_log( 'mvSeq already init' ); |
| 2124 | + } |
| 2125 | + } ); |
| 2126 | + } ); |
| 2127 | + } |
| 2128 | + /* |
| 2129 | + * The Firefogg jQuery function: |
| 2130 | + * @@note This Firefogg invocation could be made to work more like real jQuery plugins |
| 2131 | + */ |
| 2132 | + var queuedFirefoggConf = { }; |
| 2133 | + $.fn.firefogg = function( iObj, callback ) { |
| 2134 | + if ( !iObj ) |
| 2135 | + iObj = { }; |
| 2136 | + // Add the base theme CSS: |
| 2137 | + loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css' ); |
| 2138 | + loadExternalCss( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skin_name' ) + '/styles.css' ); |
| 2139 | + |
| 2140 | + // Check if we already have Firefogg loaded (the call just updates the element's |
| 2141 | + // properties) |
| 2142 | + var sElm = $j( this.selector ).get( 0 ); |
| 2143 | + if ( sElm['firefogg'] ) { |
| 2144 | + if ( sElm['firefogg'] == 'loading' ) { |
| 2145 | + js_log( "Queued firefogg operations ( firefogg " + |
| 2146 | + "not done loading ) " ); |
| 2147 | + $j.extend( queuedFirefoggConf, iObj ); |
| 2148 | + return false; |
| 2149 | + } |
| 2150 | + // Update properties |
| 2151 | + for ( var i in iObj ) { |
| 2152 | + js_log( "firefogg::updated: " + i + ' to ' + iObj[i] ); |
| 2153 | + sElm['firefogg'][i] = iObj[i]; |
| 2154 | + } |
| 2155 | + return sElm['firefogg']; |
| 2156 | + } else { |
| 2157 | + // Avoid concurrency |
| 2158 | + sElm['firefogg'] = 'loading'; |
| 2159 | + } |
| 2160 | + // Add the selector |
| 2161 | + iObj['selector'] = this.selector; |
| 2162 | + |
| 2163 | + var loadSet = [ |
| 2164 | + [ |
| 2165 | + 'mvBaseUploadInterface', |
| 2166 | + 'mvFirefogg', |
| 2167 | + '$j.ui' |
| 2168 | + ], |
| 2169 | + [ |
| 2170 | + '$j.ui.progressbar', |
| 2171 | + '$j.ui.dialog', |
| 2172 | + '$j.ui.draggable' |
| 2173 | + ] |
| 2174 | + ]; |
| 2175 | + if ( iObj.encoder_interface ) { |
| 2176 | + loadSet.push( [ |
| 2177 | + 'mvAdvFirefogg', |
| 2178 | + '$j.cookie', |
| 2179 | + '$j.ui.accordion', |
| 2180 | + '$j.ui.slider', |
| 2181 | + '$j.ui.datepicker' |
| 2182 | + ] ); |
| 2183 | + } |
| 2184 | + // Make sure we have everything loaded that we need: |
| 2185 | + mw.load( loadSet, function() { |
| 2186 | + js_log( 'firefogg libs loaded. target select:' + iObj.selector ); |
| 2187 | + // Select interface provider based on whether we want to include the |
| 2188 | + // encoder interface or not |
| 2189 | + if ( iObj.encoder_interface ) { |
| 2190 | + var myFogg = new mvAdvFirefogg( iObj ); |
| 2191 | + } else { |
| 2192 | + var myFogg = new mvFirefogg( iObj ); |
| 2193 | + } |
| 2194 | + if ( myFogg ) { |
| 2195 | + myFogg.doRewrite( callback ); |
| 2196 | + var selectorElement = $j( iObj.selector ).get( 0 ); |
| 2197 | + selectorElement['firefogg'] = myFogg; |
| 2198 | + |
| 2199 | + js_log( 'pre:' + selectorElement['firefogg']['firefogg_form_action'] ) |
| 2200 | + if ( queuedFirefoggConf ) |
| 2201 | + $j.extend( selectorElement['firefogg'], queuedFirefoggConf ); |
| 2202 | + js_log( 'post:' + selectorElement['firefogg']['firefogg_form_action'] ) |
| 2203 | + } |
| 2204 | + } ); |
| 2205 | + } |
| 2206 | + // Take an input player as the selector and expose basic rendering controls |
| 2207 | + $.fn.firefoggRender = function( iObj, callback ) { |
| 2208 | + // Check if we already have render loaded then just pass on updates/actions |
| 2209 | + var sElm = $j( this.selector ).get( 0 ); |
| 2210 | + //add a special attribute to the selector: |
| 2211 | + if ( sElm['fogg_render'] ) { |
| 2212 | + if ( sElm['fogg_render'] == 'loading' ) { |
| 2213 | + js_log( "Error: called firefoggRender while loading" ); |
| 2214 | + return false; |
| 2215 | + } |
| 2216 | + // Call or update the property: |
| 2217 | + } |
| 2218 | + sElm['fogg_render'] = 'loading'; |
| 2219 | + // Add the selector |
| 2220 | + iObj['player_target'] = this.selector; |
| 2221 | + mw.load( [ |
| 2222 | + 'mvBaseUploadInterface', |
| 2223 | + 'mvFirefogg', |
| 2224 | + 'mvFirefoggRender' |
| 2225 | + ], function() { |
| 2226 | + // Attach the firefoggRender obj to the selected elm: |
| 2227 | + sElm['fogg_render'] = new mvFirefoggRender( iObj ); |
| 2228 | + if ( callback && typeof callback == 'function' ) |
| 2229 | + callback( sElm['fogg_render'] ); |
| 2230 | + } ); |
| 2231 | + } |
| 2232 | + |
| 2233 | + $.fn.baseUploadInterface = function( iObj ) { |
| 2234 | + mw.load( [ |
| 2235 | + [ |
| 2236 | + 'mvBaseUploadInterface', |
| 2237 | + '$j.ui', |
| 2238 | + ], |
| 2239 | + [ |
| 2240 | + '$j.ui.progressbar', |
| 2241 | + '$j.ui.dialog' |
| 2242 | + ] |
| 2243 | + ], function() { |
| 2244 | + myUp = new mvBaseUploadInterface( iObj ); |
| 2245 | + myUp.setupForm(); |
| 2246 | + } ); |
| 2247 | + } |
| 2248 | + |
| 2249 | + // Shortcut to a themed button |
| 2250 | + $.btnHtml = function( msg, className, iconId, opt ) { |
| 2251 | + if ( !opt ) |
| 2252 | + opt = { }; |
| 2253 | + var href = ( opt.href ) ? opt.href : '#'; |
| 2254 | + var target_attr = ( opt.target ) ? ' target="' + opt.target + '" ' : ''; |
| 2255 | + var style_attr = ( opt.style ) ? ' style="' + opt.style + '" ' : ''; |
| 2256 | + return '<a href="' + href + '" ' + target_attr + style_attr + |
| 2257 | + ' class="ui-state-default ui-corner-all ui-icon_link ' + |
| 2258 | + className + '"><span class="ui-icon ui-icon-' + iconId + '" ></span>' + |
| 2259 | + '<span class="btnText">' + msg + '</span></a>'; |
| 2260 | + } |
| 2261 | + // Shortcut to bind hover state |
| 2262 | + $.fn.btnBind = function() { |
| 2263 | + $j( this ).hover( |
| 2264 | + function() { |
| 2265 | + $j( this ).addClass( 'ui-state-hover' ); |
| 2266 | + }, |
| 2267 | + function() { |
| 2268 | + $j( this ).removeClass( 'ui-state-hover' ); |
| 2269 | + } |
| 2270 | + ) |
| 2271 | + return this; |
| 2272 | + } |
| 2273 | + /** |
| 2274 | + * resize the dialog to fit the window |
| 2275 | + */ |
| 2276 | + $.fn.dialogFitWindow = function( opt ) { |
| 2277 | + var opt_default = { 'hspace':50, 'vspace':50 }; |
| 2278 | + if ( !opt ) |
| 2279 | + var opt = { }; |
| 2280 | + $j.extend( opt, opt_default ); |
| 2281 | + $j( this.selector ).dialog( 'option', 'width', $j( window ).width() - opt.hspace ); |
| 2282 | + $j( this.selector ).dialog( 'option', 'height', $j( window ).height() - opt.vspace ); |
| 2283 | + $j( this.selector ).dialog( 'option', 'position', 'center' ); |
| 2284 | + // update the child position: (some of this should be pushed up-stream via dialog config options |
| 2285 | + $j( this.selector + '~ .ui-dialog-buttonpane' ).css( { |
| 2286 | + 'position':'absolute', |
| 2287 | + 'left':'0px', |
| 2288 | + 'right':'0px', |
| 2289 | + 'bottom':'0px' |
| 2290 | + } ); |
| 2291 | + } |
| 2292 | + |
| 2293 | + /** |
| 2294 | + * addLoaderDialog |
| 2295 | + * small helper for putting a loading dialog box on top of everything |
| 2296 | + * (helps block for request that |
| 2297 | + * |
| 2298 | + * @param msg text text of the loader msg |
| 2299 | + */ |
| 2300 | + $.addLoaderDialog = function( msg_txt ) { |
| 2301 | + $.addDialog( msg_txt, msg_txt + '<br>' + mv_get_loading_img() ); |
| 2302 | + } |
| 2303 | + |
| 2304 | + $.addDialog = function ( title, msg_txt, btn ) { |
| 2305 | + $( '#mwe_tmp_loader' ).remove(); |
| 2306 | + // append the style free loader ontop: |
| 2307 | + $( 'body' ).append( '<div id="mwe_tmp_loader" style="display:none" title="' + title + '" >' + |
| 2308 | + msg_txt + |
| 2309 | + '</div>' ); |
| 2310 | + // special btn == ok gives empty give a single "oky" -> "close" |
| 2311 | + if ( btn == 'ok' ) { |
| 2312 | + btn[ gM( 'mwe-ok' ) ] = function() { |
| 2313 | + $j( '#mwe_tmp_loader' ).close(); |
| 2314 | + } |
| 2315 | + } |
| 2316 | + // turn the loader into a real dialog loader: |
| 2317 | + mw.load( [ |
| 2318 | + [ |
| 2319 | + '$j.ui' |
| 2320 | + ], |
| 2321 | + [ |
| 2322 | + '$j.ui.dialog' |
| 2323 | + ] |
| 2324 | + ], function() { |
| 2325 | + $( '#mwe_tmp_loader' ).dialog( { |
| 2326 | + bgiframe: true, |
| 2327 | + draggable: false, |
| 2328 | + resizable: false, |
| 2329 | + modal: true, |
| 2330 | + width:400, |
| 2331 | + buttons: btn |
| 2332 | + } ); |
| 2333 | + } ); |
| 2334 | + } |
| 2335 | + $.closeLoaderDialog = function() { |
| 2336 | + mw.load( [ |
| 2337 | + [ |
| 2338 | + '$j.ui' |
| 2339 | + ], |
| 2340 | + [ |
| 2341 | + '$j.ui.dialog' |
| 2342 | + ] |
| 2343 | + ], function() { |
| 2344 | + $j( '#mwe_tmp_loader' ).dialog( 'destroy' ).remove(); |
| 2345 | + } ); |
| 2346 | + } |
| 2347 | + |
| 2348 | + $.mwProxy = function( apiConf ) { |
| 2349 | + mw.load( ['mw.apiProxy'], |
| 2350 | + function() { |
| 2351 | + mw.apiProxy( apiConf ); |
| 2352 | + } ); |
| 2353 | + } |
| 2354 | + } )( jQuery ); |
| 2355 | +} |
| 2356 | +/* |
| 2357 | +* Utility functions: |
| 2358 | +*/ |
| 2359 | +// Simple URL rewriter (could probably be refactored into an inline regular exp) |
| 2360 | +function getURLParamReplace( url, opt ) { |
| 2361 | + var pSrc = mw.parseUri( url ); |
| 2362 | + if ( pSrc.protocol != '' ) { |
| 2363 | + var new_url = pSrc.protocol + '://' + pSrc.authority + pSrc.path + '?'; |
| 2364 | + } else { |
| 2365 | + var new_url = pSrc.path + '?'; |
| 2366 | + } |
| 2367 | + var amp = ''; |
| 2368 | + for ( var key in pSrc.queryKey ) { |
| 2369 | + var val = pSrc.queryKey[ key ]; |
| 2370 | + // Do override if requested |
| 2371 | + if ( opt[ key ] ) |
| 2372 | + val = opt[ key ]; |
| 2373 | + new_url += amp + key + '=' + val; |
| 2374 | + amp = '&'; |
| 2375 | + }; |
| 2376 | + // Add any vars that were not already there: |
| 2377 | + for ( var i in opt ) { |
| 2378 | + if ( !pSrc.queryKey[i] ) { |
| 2379 | + new_url += amp + i + '=' + opt[i]; |
| 2380 | + amp = '&'; |
| 2381 | + } |
| 2382 | + } |
| 2383 | + return new_url; |
| 2384 | +} |
| 2385 | +/** |
| 2386 | + * Given a float number of seconds, returns npt format response. |
| 2387 | + * |
| 2388 | + * @param float Seconds |
| 2389 | + * @param boolean If we should show milliseconds or not. |
| 2390 | + */ |
| 2391 | +function seconds2npt( sec, show_ms ) { |
| 2392 | + if ( isNaN( sec ) ) { |
| 2393 | + // js_log("warning: trying to get npt time on NaN:" + sec); |
| 2394 | + return '0:0:0'; |
| 2395 | + } |
| 2396 | + var hours = Math.floor( sec / 3600 ); |
| 2397 | + var minutes = Math.floor( ( sec / 60 ) % 60 ); |
| 2398 | + var seconds = sec % 60; |
| 2399 | + // Round the number of seconds to the required number of significant digits |
| 2400 | + if ( show_ms ) { |
| 2401 | + seconds = Math.round( seconds * 1000 ) / 1000; |
| 2402 | + } else { |
| 2403 | + seconds = Math.round( seconds ); |
| 2404 | + } |
| 2405 | + if ( seconds < 10 ) |
| 2406 | + seconds = '0' + seconds; |
| 2407 | + if ( minutes < 10 ) |
| 2408 | + minutes = '0' + minutes; |
| 2409 | + |
| 2410 | + return hours + ":" + minutes + ":" + seconds; |
| 2411 | +} |
| 2412 | +/* |
| 2413 | + * Take hh:mm:ss,ms or hh:mm:ss.ms input, return the number of seconds |
| 2414 | + */ |
| 2415 | +function npt2seconds( npt_str ) { |
| 2416 | + if ( !npt_str ) { |
| 2417 | + // js_log('npt2seconds:not valid ntp:'+ntp); |
| 2418 | + return false; |
| 2419 | + } |
| 2420 | + // Strip {npt:}01:02:20 or 32{s} from time if present |
| 2421 | + npt_str = npt_str.replace( /npt:|s/g, '' ); |
| 2422 | + |
| 2423 | + var hour = 0; |
| 2424 | + var min = 0; |
| 2425 | + var sec = 0; |
| 2426 | + |
| 2427 | + times = npt_str.split( ':' ); |
| 2428 | + if ( times.length == 3 ) { |
| 2429 | + sec = times[2]; |
| 2430 | + min = times[1]; |
| 2431 | + hour = times[0]; |
| 2432 | + } else if ( times.length == 2 ) { |
| 2433 | + sec = times[1]; |
| 2434 | + min = times[0]; |
| 2435 | + } else { |
| 2436 | + sec = times[0]; |
| 2437 | + } |
| 2438 | + // Sometimes a comma is used instead of period for ms |
| 2439 | + sec = sec.replace( /,\s?/, '.' ); |
| 2440 | + // Return seconds float |
| 2441 | + return parseInt( hour * 3600 ) + parseInt( min * 60 ) + parseFloat( sec ); |
| 2442 | +} |
| 2443 | +/* |
| 2444 | + * Simple helper to grab an edit token |
| 2445 | + * |
| 2446 | + * @param title The wiki page title you want to edit |
| 2447 | + * @param api_url 'optional' The target API URL |
| 2448 | + * @param callback The callback function to pass the token to |
| 2449 | + */ |
| 2450 | +function get_mw_token( title, api_url, callback ) { |
| 2451 | + js_log( ':get_mw_token:' ); |
| 2452 | + if ( !title && wgUserName ) { |
| 2453 | + title = 'User:' + wgUserName; |
| 2454 | + } |
| 2455 | + var reqObj = { |
| 2456 | + 'action': 'query', |
| 2457 | + 'prop': 'info', |
| 2458 | + 'intoken': 'edit', |
| 2459 | + 'titles': title |
| 2460 | + }; |
| 2461 | + do_api_req( { |
| 2462 | + 'data': reqObj, |
| 2463 | + 'url' : api_url |
| 2464 | + }, function( data ) { |
| 2465 | + for ( var i in data.query.pages ) { |
| 2466 | + if ( data.query.pages[i]['edittoken'] ) { |
| 2467 | + if ( typeof callback == 'function' ) |
| 2468 | + callback ( data.query.pages[i]['edittoken'] ); |
| 2469 | + } |
| 2470 | + } |
| 2471 | + // No token found: |
| 2472 | + return false; |
| 2473 | + } |
| 2474 | + ); |
| 2475 | +} |
| 2476 | +// Do a remote or local API request based on request URL |
| 2477 | +// @param options: url, data, cbParam, callback |
| 2478 | +function do_api_req( options, callback ) { |
| 2479 | + if ( typeof options.data != 'object' ) { |
| 2480 | + return js_error( 'Error: request paramaters must be an object' ); |
| 2481 | + } |
| 2482 | + // Generate the URL if it's missing |
| 2483 | + if ( typeof options.url == 'undefined' || !options.url ) { |
| 2484 | + if ( typeof wgServer == 'undefined' ) { |
| 2485 | + return js_error( 'Error: no api url for api request' ); |
| 2486 | + } |
| 2487 | + options.url = mw.getLocalApiUrl(); |
| 2488 | + } |
| 2489 | + if ( typeof options.data == 'undefined' ) |
| 2490 | + options.data = { }; |
| 2491 | + |
| 2492 | + // Force format to JSON |
| 2493 | + options.data['format'] = 'json'; |
| 2494 | + |
| 2495 | + // If action is not set, assume query |
| 2496 | + if ( ! options.data['action'] ) |
| 2497 | + options.data['action'] = 'query'; |
| 2498 | + |
| 2499 | + // js_log('do api req: ' + options.url +'?' + jQuery.param(options.data) ); |
| 2500 | + if ( options.url == 'proxy' && mw.proxy ) { |
| 2501 | + // assume the proxy is already "setup" since mw.proxy is defined. |
| 2502 | + // @@todo should probably integrate that setup into the api call |
| 2503 | + mw.proxy.doRequest( options.data, callback ); |
| 2504 | + } else if ( mw.parseUri( document.URL ).host == mw.parseUri( options.url ).host ) { |
| 2505 | + // Local request: do API request directly |
| 2506 | + $j.ajax( { |
| 2507 | + type: "POST", |
| 2508 | + url: options.url, |
| 2509 | + data: options.data, |
| 2510 | + dataType: 'json', // API requests _should_ always return JSON data: |
| 2511 | + async: false, |
| 2512 | + success: function( data ) { |
| 2513 | + callback( data ); |
| 2514 | + }, |
| 2515 | + error: function( e ) { |
| 2516 | + js_error( ' error' + e + ' in getting: ' + options.url ); |
| 2517 | + } |
| 2518 | + } ); |
| 2519 | + } else { |
| 2520 | + // Remote request |
| 2521 | + // Set the callback param if it's not already set |
| 2522 | + if ( typeof options.jsonCB == 'undefined' ) |
| 2523 | + options.jsonCB = 'callback'; |
| 2524 | + |
| 2525 | + var req_url = options.url; |
| 2526 | + var paramAnd = ( req_url.indexOf( '?' ) == -1 ) ? '?' : '&'; |
| 2527 | + // Put all the parameters into the URL |
| 2528 | + for ( var i in options.data ) { |
| 2529 | + req_url += paramAnd + encodeURIComponent( i ) + '=' + encodeURIComponent( options.data[i] ); |
| 2530 | + paramAnd = '&'; |
| 2531 | + } |
| 2532 | + var fname = 'mycpfn_' + ( mw.cb_count++ ); |
| 2533 | + _global[ fname ] = callback; |
| 2534 | + req_url += '&' + options.jsonCB + '=' + fname; |
| 2535 | + loadExternalJs( req_url ); |
| 2536 | + } |
| 2537 | +} |
| 2538 | +// Do a request: |
| 2539 | +// @@note this contains metavid specific local vs remote api remapping. |
| 2540 | +// this should be depreciated and we should use "$j.get" or an explicate api call |
| 2541 | +// (we should not mix the two request types) |
| 2542 | +function do_request( req_url, callback ) { |
| 2543 | + js_log( 'do_request::req_url:' + mw.parseUri( document.URL ) + ' != ' + mw.parseUri( req_url ).host ); |
| 2544 | + // If we are doing a request to the same domain or relative link, do a normal GET |
| 2545 | + if ( mw.parseUri( document.URL ).host == mw.parseUri( req_url ).host || |
| 2546 | + req_url.indexOf( '://' ) == -1 ){ // if its a relative url go directly as well |
| 2547 | + // Do a direct request |
| 2548 | + $j.ajax( { |
| 2549 | + type: "GET", |
| 2550 | + url: req_url, |
| 2551 | + async: false, |
| 2552 | + success: function( data ) { |
| 2553 | + callback( data ); |
| 2554 | + } |
| 2555 | + } ); |
| 2556 | + } else { |
| 2557 | + // Get data via DOM injection with callback |
| 2558 | + global_req_cb.push( callback ); |
| 2559 | + // Prepend json_ to feed_format if not already requesting json format (metavid specific) |
| 2560 | + if ( req_url.indexOf( "feed_format=" ) != -1 && req_url.indexOf( "feed_format=json" ) == -1 ) |
| 2561 | + req_url = req_url.replace( /feed_format=/, 'feed_format=json_' ); |
| 2562 | + loadExternalJs( req_url + '&cb=mv_jsdata_cb&cb_inx=' + ( global_req_cb.length -1 ) ); |
| 2563 | + } |
| 2564 | +} |
| 2565 | + |
| 2566 | +function mv_jsdata_cb( response ) { |
| 2567 | + js_log( 'f:mv_jsdata_cb:' + response['cb_inx'] ); |
| 2568 | + // Run the callback from the global request callback object |
| 2569 | + if ( !global_req_cb[response['cb_inx']] ) { |
| 2570 | + js_log( 'missing req cb index' ); |
| 2571 | + return false; |
| 2572 | + } |
| 2573 | + if ( !response['pay_load'] ) { |
| 2574 | + js_log( "missing pay load" ); |
| 2575 | + return false; |
| 2576 | + } |
| 2577 | + switch( response['content-type'] ) { |
| 2578 | + case 'text/plain': |
| 2579 | + break; |
| 2580 | + case 'text/xml': |
| 2581 | + if ( typeof response['pay_load'] == 'string' ) { |
| 2582 | + response['pay_load'] = mw.parseXML( response['pay_load'] ); |
| 2583 | + } |
| 2584 | + break |
| 2585 | + default: |
| 2586 | + js_log( 'bad response type' + response['content-type'] ); |
| 2587 | + return false; |
| 2588 | + break; |
| 2589 | + } |
| 2590 | + global_req_cb[response['cb_inx']]( response['pay_load'] ); |
| 2591 | +} |
| 2592 | +// Load external JS via DOM injection |
| 2593 | +function loadExternalJs( url, callback ) { |
| 2594 | + js_log( 'load js: ' + url ); |
| 2595 | + // if(window['$j']) // use jquery call: |
| 2596 | + /*$j.ajax({ |
| 2597 | + type: "GET", |
| 2598 | + url: url, |
| 2599 | + dataType: 'script', |
| 2600 | + cache: true |
| 2601 | + });*/ |
| 2602 | + // else{ |
| 2603 | + var e = document.createElement( "script" ); |
| 2604 | + e.setAttribute( 'src', url ); |
| 2605 | + e.setAttribute( 'type', "text/javascript" ); |
| 2606 | + /*if(callback) |
| 2607 | + e.onload = callback; |
| 2608 | + */ |
| 2609 | + // e.setAttribute('defer', true); |
| 2610 | + document.getElementsByTagName( "head" )[0].appendChild( e ); |
| 2611 | + // } |
| 2612 | +} |
| 2613 | +function styleSheetPresent( url ) { |
| 2614 | + style_elements = document.getElementsByTagName( 'link' ); |
| 2615 | + if ( style_elements.length > 0 ) { |
| 2616 | + for ( i = 0; i < style_elements.length; i++ ) { |
| 2617 | + if ( style_elements[i].href == url ) |
| 2618 | + return true; |
| 2619 | + } |
| 2620 | + } |
| 2621 | + return false; |
| 2622 | +} |
| 2623 | +function loadExternalCss( url ) { |
| 2624 | + // We could have the script loader group these CSS requests. |
| 2625 | + // But it's debatable: it may hurt more than it helps with caching and all |
| 2626 | + if ( typeof url == 'object' ) { |
| 2627 | + for ( var i in url ) { |
| 2628 | + loadExternalCss( url[i] ); |
| 2629 | + } |
| 2630 | + return ; |
| 2631 | + } |
| 2632 | + |
| 2633 | + if ( url.indexOf( '?' ) == -1 ) { |
| 2634 | + url += '?' + mw.getUrlParam(); |
| 2635 | + } |
| 2636 | + if ( !styleSheetPresent( url ) ) { |
| 2637 | + js_log( 'load css: ' + url ); |
| 2638 | + var e = document.createElement( "link" ); |
| 2639 | + e.href = url; |
| 2640 | + e.type = "text/css"; |
| 2641 | + e.rel = 'stylesheet'; |
| 2642 | + document.getElementsByTagName( "head" )[0].appendChild( e ); |
| 2643 | + } |
| 2644 | +} |
| 2645 | + |
| 2646 | + |
| 2647 | +if ( typeof DOMParser == "undefined" ) { |
| 2648 | + DOMParser = function () { } |
| 2649 | + DOMParser.prototype.parseFromString = function ( str, contentType ) { |
| 2650 | + if ( typeof ActiveXObject != "undefined" ) { |
| 2651 | + var d = new ActiveXObject( "MSXML.DomDocument" ); |
| 2652 | + d.loadXML( str ); |
| 2653 | + return d; |
| 2654 | + } else if ( typeof XMLHttpRequest != "undefined" ) { |
| 2655 | + var req = new XMLHttpRequest; |
| 2656 | + req.open( "GET", "data:" + ( contentType || "application/xml" ) + |
| 2657 | + ";charset=utf-8," + encodeURIComponent( str ), false ); |
| 2658 | + if ( req.overrideMimeType ) { |
| 2659 | + req.overrideMimeType( contentType ); |
| 2660 | + } |
| 2661 | + req.send( null ); |
| 2662 | + return req.responseXML; |
| 2663 | + } |
| 2664 | + } |
| 2665 | +} |
| 2666 | +/* |
| 2667 | +* Utility functions |
| 2668 | +*/ |
| 2669 | +function js_log( string ) { |
| 2670 | + // Add any prepend debug strings if necessary (used for cross browser) |
| 2671 | + if ( mw.getConfig( 'pre-append-log' ) ) |
| 2672 | + string = mw.getConfig( 'pre-append-log' ) + string; |
| 2673 | + |
| 2674 | + if ( window.console ) { |
| 2675 | + window.console.log( string ); |
| 2676 | + } else { |
| 2677 | + /** |
| 2678 | + * old IE and non-Firebug debug: |
| 2679 | + */ |
| 2680 | + /*var log_elm = document.getElementById('mv_js_log'); |
| 2681 | + if(!log_elm){ |
| 2682 | + document.getElementsByTagName("body")[0].innerHTML = document.getElementsByTagName("body")[0].innerHTML + |
| 2683 | + '<div style="position:absolute;z-index:500;top:0px;left:0px;right:0px;height:10px;">'+ |
| 2684 | + '<textarea id="mv_js_log" cols="120" rows="5"></textarea>'+ |
| 2685 | + '</div>'; |
| 2686 | + |
| 2687 | + var log_elm = document.getElementById('mv_js_log'); |
| 2688 | + } |
| 2689 | + if(log_elm){ |
| 2690 | + log_elm.value+=string+"\n"; |
| 2691 | + }*/ |
| 2692 | + } |
| 2693 | + return false; |
| 2694 | +} |
| 2695 | + |
| 2696 | +function js_error( string ) { |
| 2697 | + alert( string ); |
| 2698 | + return false; |
| 2699 | +} |
Property changes on: branches/js2-work/phase3/js2/mwEmbed/mwEmbed.js |
___________________________________________________________________ |
Added: svn:mergeinfo |
1 | 2700 | Merged /branches/REL1_15/phase3/js2/mwEmbed/mv_embed.js:r51646 |
2 | 2701 | Merged /branches/sqlite/js2/mwEmbed/mv_embed.js:r58211-58321 |
Added: svn:eol-style |
3 | 2702 | + native |
Index: branches/js2-work/phase3/js2/mwEmbed/jsScriptLoader.php |
— | — | @@ -420,7 +420,7 @@ |
421 | 421 | } |
422 | 422 | static public function getLoadGmIndex( $str ){ |
423 | 423 | $returnIndex = array(); |
424 | | - preg_match('/loadGM\s*\(\s*\{/', $str, $matches, PREG_OFFSET_CAPTURE ); |
| 424 | + preg_match('/mw.addMessages\s*\(\s*\{/', $str, $matches, PREG_OFFSET_CAPTURE ); |
425 | 425 | if( count($matches) == 0){ |
426 | 426 | return false; |
427 | 427 | } |
— | — | @@ -460,7 +460,7 @@ |
461 | 461 | $jsmsg = $this->getMsgKeysFromClass( $class ); |
462 | 462 | if( $jsmsg ){ |
463 | 463 | self::getMsgKeys ( $jsmsg ); |
464 | | - return 'loadGM(' . FormatJson::encode( $jsmsg ) . ');'; |
| 464 | + return 'mw.addMessages(' . FormatJson::encode( $jsmsg ) . ');'; |
465 | 465 | }else{ |
466 | 466 | //if could not parse return empty string: |
467 | 467 | return ''; |
— | — | @@ -503,7 +503,7 @@ |
504 | 504 | //developers will read the js source when its not behaving as expected. |
505 | 505 | return "\n/* |
506 | 506 | * Could not parse JSON language messages in this file, |
507 | | -* Please check that loadGM call contains valid JSON (not javascript) |
| 507 | +* Please check that mw.addMessages call contains valid JSON (not javascript) |
508 | 508 | */\n\n" . $json_str; //include the original fallback loadGM |
509 | 509 | |
510 | 510 | } |
— | — | @@ -609,7 +609,8 @@ |
610 | 610 | $mydir2 = substr( $this->filename, 0, strrpos( $this->filename, '/' ) ); # subdirectory level 2 |
611 | 611 | $mydir1 = substr( $mydir2, 0, strrpos( $mydir2, '/' ) ); # subdirectory level 1 |
612 | 612 | |
613 | | - if ( wfMkdirParents( $mydir1 ) === false || wfMkdirParents( $mydir2 ) === false ) { |
| 613 | + // Suppress error so javascript can format it |
| 614 | + if ( @wfMkdirParents( $mydir1 ) === false || @wfMkdirParents( $mydir2 ) === false ) { |
614 | 615 | return 'Could not create cache directory. Check your cache directory permissions?'; |
615 | 616 | } else { |
616 | 617 | return true; |
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -loadGM( { |
| 2 | +mw.addMessages( { |
3 | 3 | "mwe-select_transcript_set" : "Select subtitles", |
4 | 4 | "mwe-auto_scroll" : "auto scroll", |
5 | 5 | "mwe-close" : "close", |
Index: branches/js2-work/phase3/js2/mwEmbed/libTimedText/mvTimeTextEdit.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | |
10 | 10 | var mvTimeTextEdit = { }; |
11 | 11 | |
12 | | -loadGM( { |
| 12 | +mw.addMessages( { |
13 | 13 | "mwe-upload-subs-file" : "Upload subtitle", |
14 | 14 | "mwe-add-subs-file-title" : "Select subtitle to upload", |
15 | 15 | "mwe-error-only-srt" : "You can only upload srt files.", |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | } ) |
20 | 20 | |
21 | 21 | |
22 | | -js2AddOnloadHook( function() { |
| 22 | +mw.addOnloadHook( function() { |
23 | 23 | function getSubtitle( f ) { |
24 | 24 | var name = f.files[0].name; |
25 | 25 | var srtData = f.files[0].getAsBinary(); |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>Simple Video Tag Usage</title> |
7 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 7 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
8 | 8 | </head> |
9 | 9 | <body> |
10 | 10 | <h3> Related Videos </h3> |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html |
— | — | @@ -1,8 +1,8 @@ |
2 | | -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | +<!DOCTYPE HT ML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
3 | 3 | "http://www.w3.org/TR/html4/loose.dtd"> |
4 | 4 | <html> |
5 | 5 | <head> |
6 | | - <title> Sample mv Embed</title> |
| 6 | + <title> Sample mwEmbed Add Media Wizard</title> |
7 | 7 | <style type="text/css"> |
8 | 8 | body{ |
9 | 9 | font-size:80%; |
— | — | @@ -11,16 +11,16 @@ |
12 | 12 | border:medium none; |
13 | 13 | } |
14 | 14 | </style> |
15 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
16 | | - <!--<script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mv_embed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script> --> |
| 15 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
| 16 | + <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed,remoteSearchDriver,$j.ui,$j.ui.resizable,$j.ui.draggable,$j.ui.dialog,$j.ui.tabs,$j.ui.sortable,$j.cookie,baseRemoteSearch&urid=1257728132531&debug=true&uselang=en"></script> --> |
17 | 17 | <script type="text/javascript"> |
18 | | - js2AddOnloadHook(function(){ |
| 18 | + mw.addOnloadHook(function(){ |
19 | 19 | |
20 | 20 | $j('#add_media_link').addMediaWiz( { |
21 | | - 'profile':'html_edit', |
22 | | - 'target_textbox': '#wpTextbox1', |
23 | | - 'target_render_area':'#inline_append', |
24 | | - 'import_url_mode':'remote_link', |
| 21 | + 'profile' : 'html_edit', |
| 22 | + 'target_textbox' : '#wpTextbox1', |
| 23 | + 'target_render_area' : '#inline_append', |
| 24 | + 'import_url_mode' : 'remote_link', |
25 | 25 | 'remote_insert_description' : true, |
26 | 26 | //note selections in the textbox will take over the default query |
27 | 27 | 'default_query': 'fish', |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Sequence_Render.html |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | <html> |
4 | 4 | <head> |
5 | 5 | <title>Seeking Render Example</title> |
6 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 6 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
7 | 7 | <style> |
8 | 8 | #render_box { |
9 | 9 | position:absolute; |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html |
— | — | @@ -2,8 +2,8 @@ |
3 | 3 | <html><head> |
4 | 4 | <meta http-equiv="content-type" content="text/html; charset=UTF-8"> |
5 | 5 | <title>Firefogg - Make Ogg Video in your Browser</title> |
6 | | - <script type="text/javascript" src="../jsScriptLoader.php?urid=r58125&class=mv_embed,window.jQuery,mvBaseUploadInterface,mvFirefogg,mvAdvFirefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.cookie,$j.ui.accordion,$j.ui.slider,$j.ui.datepicker,$j.ui.draggable"></script> |
7 | | - <!-- <script type="text/javascript" src="../mv_embed.js"></script> --> |
| 6 | + <script type="text/javascript" src="../jsScriptLoader.php?urid=r58125&class=mwEmbed,window.jQuery,mvBaseUploadInterface,mvFirefogg,mvAdvFirefogg,$j.ui,$j.ui.progressbar,$j.ui.dialog,$j.cookie,$j.ui.accordion,$j.ui.slider,$j.ui.datepicker,$j.ui.draggable"></script> |
| 7 | + <!-- <script type="text/javascript" src="../mwEmbed.js"></script> --> |
8 | 8 | <style type="text/css" media="all">body { |
9 | 9 | margin: 0; |
10 | 10 | padding: 0; |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Audio.html |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | <html> |
4 | 4 | <head> |
5 | 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
6 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 6 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
7 | 7 | <title>Audio Player sample</title> |
8 | 8 | </head> |
9 | 9 | <body> |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Themable.html |
— | — | @@ -3,8 +3,8 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>Sample Themed Player</title> |
7 | | - <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed,embedVideo&urid=1"></script> --> |
8 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 7 | + <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mwEmbed,embedVideo&urid=1"></script> --> |
| 8 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
9 | 9 | </head> |
10 | 10 | <script type="text/javascript"> |
11 | 11 | </script> |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Multi_Upload.html |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>Sample Themed Player</title> |
7 | | - <script type="text/javascript" src="../mv_embed.js"></script> |
| 7 | + <script type="text/javascript" src="../mwEmbed.js"></script> |
8 | 8 | </head> |
9 | 9 | <script type="text/javascript"> |
10 | 10 | mwAddOnloadHook(function(){ |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>SMIL Sequence Editor example</title> |
7 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 7 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
8 | 8 | <script type="text/javascript"> |
9 | 9 | mwAddOnloadHook(function(){ |
10 | 10 | $j('#seqcontainer').sequencer({ |
Index: branches/js2-work/phase3/js2/mwEmbed/example_usage/Player_Timed_Text.html |
— | — | @@ -3,10 +3,10 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>sample mv embed</title> |
7 | | - <script type="text/javascript" src="../mv_embed.js?debug=true"></script> |
| 7 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
8 | 8 | </head> |
9 | 9 | <body> |
10 | | -<h3> Mv_Embed Timed Text Examples:</h3> |
| 10 | +<h3> mwEmbed Timed Text Examples:</h3> |
11 | 11 | Click on the little lower right "CC" icon to expose the timed text |
12 | 12 | <table border="1" cellpadding="6" width="950"> |
13 | 13 | <tr> |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvFirefogg.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * autodetects: new upload api or old http POST. |
4 | 4 | */ |
5 | 5 | |
6 | | -loadGM({ |
| 6 | +mw.addMessages({ |
7 | 7 | "fogg-select_file" : "Select file", |
8 | 8 | "fogg-select_new_file" : "Select new file", |
9 | 9 | "fogg-select_url" : "Select URL", |
— | — | @@ -152,7 +152,7 @@ |
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Rewrite the upload form, or create our own upload controls for local transcoding. |
156 | | - * Called from $j.firefogg(), in mv_embed.js. |
| 156 | + * Called from $j.firefogg(), in mwEmbed.js. |
157 | 157 | */ |
158 | 158 | doRewrite: function( callback ) { |
159 | 159 | var _this = this; |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * Is optionally extended by Sequence Remote Search Driver |
8 | 8 | */ |
9 | 9 | |
10 | | -loadGM( { |
| 10 | +mw.addMessages( { |
11 | 11 | "mwe-add_media_wizard" : "Add media wizard", |
12 | 12 | "mwe-media_search" : "Media search", |
13 | 13 | "rsd_box_layout" : "Box layout", |
— | — | @@ -817,7 +817,7 @@ |
818 | 818 | */ |
819 | 819 | showUploadForm: function() { |
820 | 820 | var _this = this; |
821 | | - mvJsLoader.doLoad( ['$j.fn.simpleUploadForm'], function() { |
| 821 | + mw.load( ['$j.fn.simpleUploadForm'], function() { |
822 | 822 | var provider = _this.content_providers['this_wiki']; |
823 | 823 | |
824 | 824 | // check for "this_wiki" enabled |
— | — | @@ -1083,7 +1083,7 @@ |
1084 | 1084 | loadSearchLib: function( provider, callback ) { |
1085 | 1085 | var _this = this; |
1086 | 1086 | // Set up the library req: |
1087 | | - mvJsLoader.doLoad( [ |
| 1087 | + mw.load( [ |
1088 | 1088 | 'baseRemoteSearch', |
1089 | 1089 | provider.lib + 'Search' |
1090 | 1090 | ], function() { |
— | — | @@ -1149,7 +1149,7 @@ |
1150 | 1150 | var content = ''; |
1151 | 1151 | for ( var providerName in this.content_providers ) { |
1152 | 1152 | var provider = this.content_providers[providerName]; |
1153 | | - var tabImage = mv_embed_path + '/skins/common/remote_cp/' + providerName + '_tab.png'; |
| 1153 | + var tabImage = mw.getMwEmbedPath() + '/skins/common/remote_cp/' + providerName + '_tab.png'; |
1154 | 1154 | if ( provider.enabled && provider.checked && provider.api_url ) { |
1155 | 1155 | // Add selected default if set |
1156 | 1156 | if ( this.currentProvider == providerName ) |
— | — | @@ -1673,7 +1673,7 @@ |
1674 | 1674 | var _this = this; |
1675 | 1675 | var options = _this.getClipEditOptions( resource ); |
1676 | 1676 | // Display the mvClipEdit obj once we are done loading: |
1677 | | - mvJsLoader.doLoad( ['mvClipEdit'], function() { |
| 1677 | + mw.load( ['mvClipEdit'], function() { |
1678 | 1678 | // Run the image clip tools |
1679 | 1679 | _this.clipEdit = new mvClipEdit( options ); |
1680 | 1680 | } ); |
— | — | @@ -1710,25 +1710,29 @@ |
1711 | 1711 | { id : 'embed_vid' } ); |
1712 | 1712 | js_log( 'append html: ' + embedHtml ); |
1713 | 1713 | $j( '#clip_edit_disp' ).html( embedHtml ); |
1714 | | - js_log( "about to call rewrite_by_id::embed_vid" ); |
1715 | 1714 | |
1716 | | - // Rewrite by id |
1717 | | - rewrite_by_id( 'embed_vid', function() { |
| 1715 | + js_log( "about to call $j.embedPlayer::embed_vid" ); |
1718 | 1716 | |
1719 | | - // Grab information available from the embed instance |
1720 | | - resource.pSobj.addResourceInfoFromEmbedInstance( resource, 'embed_vid' ); |
1721 | | - |
1722 | | - // Add libraries resizable and hoverIntent to support video edit tools |
1723 | | - var librarySet = [ |
1724 | | - 'mvClipEdit', |
1725 | | - '$j.ui.resizable', |
1726 | | - '$j.fn.hoverIntent' |
1727 | | - ] |
1728 | | - mvJsLoader.doLoad( librarySet, function() { |
1729 | | - // Make sure the rsd_edit_img is removed: |
1730 | | - $j( '#rsd_edit_img' ).remove(); |
1731 | | - // Run the image clip tools |
1732 | | - _this.clipEdit = new mvClipEdit( options ); |
| 1717 | + //Make sure we have embedPlayer libs: |
| 1718 | + mvJsLoader.embedPlayerCheck( function() { |
| 1719 | + // Rewrite by id |
| 1720 | + $j( '#embed_vid').embedPlayer ( function() { |
| 1721 | + |
| 1722 | + // Grab information available from the embed instance |
| 1723 | + resource.pSobj.addResourceInfoFromEmbedInstance( resource, 'embed_vid' ); |
| 1724 | + |
| 1725 | + // Add libraries resizable and hoverIntent to support video edit tools |
| 1726 | + var librarySet = [ |
| 1727 | + 'mvClipEdit', |
| 1728 | + '$j.ui.resizable', |
| 1729 | + '$j.fn.hoverIntent' |
| 1730 | + ] |
| 1731 | + mw.load( librarySet, function() { |
| 1732 | + // Make sure the rsd_edit_img is removed: |
| 1733 | + $j( '#rsd_edit_img' ).remove(); |
| 1734 | + // Run the image clip tools |
| 1735 | + _this.clipEdit = new mvClipEdit( options ); |
| 1736 | + } ); |
1733 | 1737 | } ); |
1734 | 1738 | } ); |
1735 | 1739 | } ); |
— | — | @@ -1960,8 +1964,10 @@ |
1961 | 1965 | ); |
1962 | 1966 | |
1963 | 1967 | // Update video tag (if a video) |
1964 | | - if ( resource.mime.indexOf( 'video/' ) !== -1 ) |
1965 | | - rewrite_by_id( $j( _this.target_container ).attr( 'id' ) + '_rsd_pv_vid' ); |
| 1968 | + if ( resource.mime.indexOf( 'video/' ) !== -1 ){ |
| 1969 | + var target_rewrite_id = $j( _this.target_container ).attr( 'id' ) + '_rsd_pv_vid'; |
| 1970 | + $j('#' + target_rewrite_id ).embedPlayer(); |
| 1971 | + } |
1966 | 1972 | |
1967 | 1973 | // Load the preview text: |
1968 | 1974 | _this.parse( |
— | — | @@ -2102,7 +2108,7 @@ |
2103 | 2109 | $j.addLoaderDialog( gM( 'mwe-importing_asset' ) ); |
2104 | 2110 | |
2105 | 2111 | // Load the BaseUploadInterface: |
2106 | | - mvJsLoader.doLoad( |
| 2112 | + mw.load( |
2107 | 2113 | [ |
2108 | 2114 | 'mvBaseUploadInterface', |
2109 | 2115 | '$j.ui.progressbar' |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/dragDropFile.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * |
4 | 4 | * Note: this file is still under development |
5 | 5 | */ |
6 | | -loadGM( { |
| 6 | +mw.addMessages( { |
7 | 7 | "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}", |
8 | 8 | "mwe-review-upload": "Review file {{PLURAL:$1|upload|uploads}}" |
9 | 9 | } ); |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/simpleUploadForm.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | | -loadGM( { |
| 8 | +mw.addMessages( { |
9 | 9 | "mwe-select_file" : "Select file", |
10 | 10 | "mwe-more_license_options" : "For more license options, view the <a href=\"$1\">normal upload page<\/a>", |
11 | 11 | "mwe-select_ownwork" : "I am uploading entirely my own work, and licencing it under:", |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvBaseUploadInterface.js |
— | — | @@ -4,7 +4,7 @@ |
5 | 5 | * This base upload class is optionally extended by Firefogg |
6 | 6 | * |
7 | 7 | */ |
8 | | -loadGM({ |
| 8 | +mw.addMessages({ |
9 | 9 | "mwe-upload-transcode-in-progress" : "Transcode and upload in progress (do not close this window)", |
10 | 10 | "mwe-upload-in-progress" : "Upload in progress (do not close this window)", |
11 | 11 | "mwe-upload-transcoded-status" : "Transcoded", |
— | — | @@ -467,7 +467,7 @@ |
468 | 468 | //update status to 100% |
469 | 469 | _this.updateProgress( 1 ); |
470 | 470 | //see if we need JSON |
471 | | - mvJsLoader.doLoad( [ |
| 471 | + mw.load( [ |
472 | 472 | 'JSON' |
473 | 473 | ], function() { |
474 | 474 | var apiResult = {}; |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * Base remote search Object. |
4 | 4 | * provides the base class for the other search system to extend. |
5 | 5 | */ |
6 | | -loadGM( { |
| 6 | +mw.addMessages( { |
7 | 7 | "mwe-imported_from" : "$1 imported from [$2 $3]. See the original [$4 resource page] for more information.", |
8 | 8 | "mwe-import-description" : "$1, imported from $2" |
9 | 9 | } ); |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/searchLibs/metavidSearch.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /* |
3 | 3 | * API modes (implementations should call these objects which inherit the mvBaseRemoteSearch |
4 | 4 | */ |
5 | | -loadGM( { |
| 5 | +mw.addMessages( { |
6 | 6 | "mwe-stream_title" : "$1 $2 to $3" |
7 | 7 | } ); |
8 | 8 | var metavidSearch = function( iObj ) { |
Index: branches/js2-work/phase3/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | * Advanced Firefogg support. Lets you control many aspects of video encoding. |
4 | 4 | */ |
5 | 5 | |
6 | | -loadGM({ |
| 6 | +mw.addMessages({ |
7 | 7 | "fogg-help-sticky" : "Help (click to stick)", |
8 | 8 | "fogg-cg-preset" : "Preset: <strong>$1<\/strong>", |
9 | 9 | "fogg-cg-quality" : "Basic quality and resolution control", |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/javaEmbed.js |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | } |
42 | 42 | } else { |
43 | 43 | // should be identical to cortado.jar |
44 | | - applet_loc = mv_embed_path + 'libEmbedPlayer/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar'; |
| 44 | + applet_loc = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/cortado/cortado-ovt-stripped-0.5.0.jar'; |
45 | 45 | } |
46 | 46 | // load directly in the page.. |
47 | 47 | // (media must be on the same server or applet must be signed) |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/flowplayerEmbed.js |
— | — | @@ -1438,7 +1438,7 @@ |
1439 | 1439 | } )(); |
1440 | 1440 | |
1441 | 1441 | /************************************************ |
1442 | | -********* mv_embed extension to flowplayer.js *** |
| 1442 | +********* mwEmbed extension to flowplayer.js *** |
1443 | 1443 | ************************************************/ |
1444 | 1444 | var flowplayerEmbed = { |
1445 | 1445 | instanceOf:'flowplayerEmbed', |
— | — | @@ -1472,7 +1472,7 @@ |
1473 | 1473 | postEmbedJS: function() |
1474 | 1474 | { |
1475 | 1475 | var _this = this; |
1476 | | - js_log( 'embedFlow: uri:' + this.getSrc() + "\n" + mv_embed_path + 'libEmbedPlayer/binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ; |
| 1476 | + js_log( 'embedFlow: uri:' + this.getSrc() + "\n" + mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/flowplayer/flowplayer-3.0.1.swf' ) ; |
1477 | 1477 | var flowConfig = { |
1478 | 1478 | clip: { |
1479 | 1479 | url: this.getSrc(), |
— | — | @@ -1500,7 +1500,7 @@ |
1501 | 1501 | flowConfig.screen.opacity = 0.2; |
1502 | 1502 | } |
1503 | 1503 | |
1504 | | - $f( this.pid, mv_embed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf', flowConfig ); |
| 1504 | + $f( this.pid, mwEmbed_path + 'binPlayers/flowplayer/flowplayer-3.0.1.swf', flowConfig ); |
1505 | 1505 | // get the this.fla value: |
1506 | 1506 | this.getFLA(); |
1507 | 1507 | // set up bindings (for when interacting with the swf causes action: |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/nativeEmbed.js |
— | — | @@ -1,4 +1,9 @@ |
2 | | -// native embed library: |
| 2 | + |
| 3 | +/* |
| 4 | +* Native embed library: |
| 5 | +* |
| 6 | +* Enables embedPlayer support for native html5 browser playback system |
| 7 | +*/ |
3 | 8 | var nativeEmbed = { |
4 | 9 | instanceOf:'nativeEmbed', |
5 | 10 | canPlayThrough:false, |
— | — | @@ -24,7 +29,7 @@ |
25 | 30 | return this.wrapEmebedContainer( embed_code ); |
26 | 31 | }, |
27 | 32 | getEmbedObj:function() { |
28 | | - // we want to let mv_embed handle the controls so notice the absence of control attribute |
| 33 | + // we want to let mwEmbed handle the controls so notice the absence of control attribute |
29 | 34 | // controls=false results in controls being displayed: |
30 | 35 | // http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-August/016159.html |
31 | 36 | js_log( "native play url:" + this.getSrc() + ' start_offset: ' + this.start_ntp + ' end: ' + this.end_ntp ); |
— | — | @@ -37,7 +42,8 @@ |
38 | 43 | /*if(!this.onlyLoadFlag) |
39 | 44 | eb+='autoplay="true" ';*/ |
40 | 45 | |
41 | | - // continue with the other attr: |
| 46 | + // continue with the other attr: |
| 47 | + // NOTE: could be binded in "post embed js" |
42 | 48 | eb += 'oncanplaythrough="$j(\'#' + this.id + '\').get(0).oncanplaythrough();return false;" ' + |
43 | 49 | 'onloadedmetadata="$j(\'#' + this.id + '\').get(0).onloadedmetadata();return false;" ' + |
44 | 50 | 'loadedmetadata="$j(\'#' + this.id + '\').get(0).onloadedmetadata();return false;" ' + |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/kplayerEmbed.js |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | return this.wrapEmebedContainer( embed_code ); |
22 | 22 | }, |
23 | 23 | getEmbedObj:function() { |
24 | | - var player_path = mv_embed_path + 'libEmbedPlayer/binPlayers/kaltura-player'; |
| 24 | + var player_path = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/kaltura-player'; |
25 | 25 | return '<object width="' + this.width + '" height="' + this.height + '" '+ |
26 | 26 | 'data="' + player_path + '/wrapper.swf" allowfullscreen="true" '+ |
27 | 27 | 'allownetworking="all" allowscriptaccess="always" '+ |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/omtkEmbed.js |
— | — | @@ -11,7 +11,7 @@ |
12 | 12 | return this.wrapEmebedContainer( embed_code ); |
13 | 13 | }, |
14 | 14 | getEmbedObj:function() { |
15 | | - var player_path = mv_embed_path + 'libEmbedPlayer/binPlayers/omtk-fx/omtkp.swf'; |
| 15 | + var player_path = mw.getMwEmbedPath() + 'libEmbedPlayer/binPlayers/omtk-fx/omtkp.swf'; |
16 | 16 | // player_path = 'omtkp.swf'; |
17 | 17 | js_log( "player path: " + player_path ); |
18 | 18 | return '<object id="' + this.pid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="1" height="1">' + |
Index: branches/js2-work/phase3/js2/mwEmbed/libEmbedPlayer/embedPlayer.js |
— | — | @@ -8,11 +8,11 @@ |
9 | 9 | * |
10 | 10 | */ |
11 | 11 | |
12 | | -loadGM( { |
| 12 | +mw.addMessages( { |
13 | 13 | "mwe-loading_plugin" : "loading plugin ...", |
14 | 14 | "mwe-select_playback" : "Set playback preference", |
15 | 15 | "mwe-link_back" : "Link back", |
16 | | - "mwe-error_swap_vid" : "Error: mv_embed was unable to swap the video tag for the mv_embed interface", |
| 16 | + "mwe-error_swap_vid" : "Error: mwEmbed was unable to swap the video tag for the mwEmbed interface", |
17 | 17 | "mwe-add_to_end_of_sequence" : "Add to end of sequence", |
18 | 18 | "mwe-missing_video_stream" : "The video file for this stream is missing", |
19 | 19 | "mwe-play_clip" : "Play clip", |
— | — | @@ -216,17 +216,6 @@ |
217 | 217 | * Adds jQuery binding for embedPlayer |
218 | 218 | */ |
219 | 219 | ( function( $ ) { |
220 | | - |
221 | | - /** |
222 | | - * The base embedPlayers function converts all |
223 | | - * video, audio, playlist tags into javascript player interfaces |
224 | | - * |
225 | | - * @param {Object} attributes Attributes applied to all players |
226 | | - * @param [ Optional ] {Function} callback Function to be called once player interfaces are ready |
227 | | - */ |
228 | | - $.embedPlayers = function( attributes, callback ){ |
229 | | - $( 'video,audio,playlist' ).embedPlayer( attributes, callback ); |
230 | | - } |
231 | 220 | |
232 | 221 | /** |
233 | 222 | * Selector based embedPlayer jQuery binding |
— | — | @@ -281,6 +270,7 @@ |
282 | 271 | //Set the selector to IE compatible set and continue processing |
283 | 272 | j_selector = ie_compatible_selector; |
284 | 273 | } |
| 274 | + |
285 | 275 | // Run the selector |
286 | 276 | $j( j_selector ).each( function() { |
287 | 277 | mw.playerManager.addElement( this, attributes); |
— | — | @@ -351,7 +341,7 @@ |
352 | 342 | break; |
353 | 343 | case 'playlist': |
354 | 344 | // Make sure we have the necessary playlist libs loaded: |
355 | | - mvJsLoader.doLoad( [ |
| 345 | + mw.load( [ |
356 | 346 | 'mvPlayList', |
357 | 347 | '$j.ui', // Include dialog for pop-ing up things |
358 | 348 | '$j.ui.dialog' |
— | — | @@ -1142,7 +1132,7 @@ |
1143 | 1133 | |
1144 | 1134 | // Set the default skin if unset: |
1145 | 1135 | if ( !this.skin_name ) |
1146 | | - this.skin_name = mw.conf.skin_name; |
| 1136 | + this.skin_name = mw.getConfig( 'skin_name' ); |
1147 | 1137 | |
1148 | 1138 | // Make sure startOffset is cast as an int |
1149 | 1139 | if ( this.startOffset && this.startOffset.split( ':' ).length >= 2 ) |
— | — | @@ -1181,7 +1171,7 @@ |
1182 | 1172 | this.ctrlBuilder = new ctrlBuilder( this ); |
1183 | 1173 | } |
1184 | 1174 | // Load player skin css: |
1185 | | - loadExternalCss( mv_embed_path + 'skins/' + this.skin_name + '/playerSkin.css' ); |
| 1175 | + loadExternalCss( mw.getMwEmbedPath() + 'skins/' + this.skin_name + '/playerSkin.css' ); |
1186 | 1176 | }, |
1187 | 1177 | |
1188 | 1178 | /** |
— | — | @@ -1196,7 +1186,7 @@ |
1197 | 1187 | if( element.tagName.toLowerCase() == 'audio' && dim == 'height' ) |
1198 | 1188 | return this[ dim ] = 0; |
1199 | 1189 | // Grab width/height from default value (for video) |
1200 | | - var dwh = mw.conf['video_size'].split( 'x' ); |
| 1190 | + var dwh = mw.getConfig( 'video_size' ).split( 'x' ); |
1201 | 1191 | this[ dim ] = ( dim == 'width' )? dwh[0] : dwh[1]; |
1202 | 1192 | } |
1203 | 1193 | }, |
— | — | @@ -1251,7 +1241,7 @@ |
1252 | 1242 | }, |
1253 | 1243 | |
1254 | 1244 | /** |
1255 | | - * Sources Ready Innitialization |
| 1245 | + * Sources Ready Initialisation |
1256 | 1246 | * |
1257 | 1247 | * issues autoSelectSource call |
1258 | 1248 | * |
— | — | @@ -1379,7 +1369,7 @@ |
1380 | 1370 | return false; |
1381 | 1371 | } |
1382 | 1372 | } |
1383 | | - // See if we are using mv_embed without a ogg source in which case no point in promoting firefox :P |
| 1373 | + // See if we are using mwEmbed without a ogg source in which case no point in promoting firefox :P |
1384 | 1374 | if ( this.media_element && this.media_element.sources ) { |
1385 | 1375 | var foundOgg = false; |
1386 | 1376 | var playable_sources = this.media_element.getPlayableSources(); |
— | — | @@ -1456,16 +1446,16 @@ |
1457 | 1447 | /* |
1458 | 1448 | * Seek function (should be implemented by embed player interface ) |
1459 | 1449 | */ |
1460 | | - doSeek : function( perc ) { |
| 1450 | + doSeek : function( percent ) { |
1461 | 1451 | var _this = this; |
1462 | 1452 | if ( this.supportsURLTimeEncoding() ) { |
1463 | 1453 | // Make sure this.seek_time_sec is up-to-date: |
1464 | | - this.seek_time_sec = npt2seconds( this.start_npt ) + parseFloat( perc * this.getDuration() ); |
| 1454 | + this.seek_time_sec = npt2seconds( this.start_npt ) + parseFloat( percent * this.getDuration() ); |
1465 | 1455 | js_log( 'updated seek_time_sec: ' + seconds2npt ( this.seek_time_sec ) ); |
1466 | 1456 | this.stop(); |
1467 | 1457 | this.didSeekJump = true; |
1468 | 1458 | // Update the slider |
1469 | | - this.setSliderValue( perc ); |
| 1459 | + this.setSliderValue( percent ); |
1470 | 1460 | } |
1471 | 1461 | // Do play request in 100ms ( give the dom time to swap out the embed player ) |
1472 | 1462 | setTimeout( function(){ |
— | — | @@ -1948,8 +1938,8 @@ |
1949 | 1939 | } |
1950 | 1940 | } |
1951 | 1941 | }, |
1952 | | - updateThumbPerc:function( perc ) { |
1953 | | - return this.updateThumbTime( ( this.getDuration() * perc ) ); |
| 1942 | + updateThumbPerc:function( percent ) { |
| 1943 | + return this.updateThumbTime( ( this.getDuration() * percent ) ); |
1954 | 1944 | }, |
1955 | 1945 | // Updates the thumbnail if the thumbnail is being displayed |
1956 | 1946 | updateThumbnail : function( src, quick_switch ) { |
— | — | @@ -2029,14 +2019,14 @@ |
2030 | 2020 | |
2031 | 2021 | var embed_thumb_html; |
2032 | 2022 | if ( thumbnail.substring( 0, 1 ) == '/' ) { |
2033 | | - eURL = mw.parseUri( mv_embed_path ); |
| 2023 | + eURL = mw.parseUri( mw.getMwEmbedPath() ); |
2034 | 2024 | embed_thumb_url = eURL.protocol + '://' + eURL.host + thumbnail; |
2035 | | - // js_log('set from mv_embed_path:'+embed_thumb_html); |
| 2025 | + // js_log('set from mwEmbed_path:'+embed_thumb_html); |
2036 | 2026 | } else { |
2037 | | - embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != -1 ) ? thumbnail:mv_embed_path + thumbnail; |
| 2027 | + embed_thumb_url = ( thumbnail.indexOf( 'http://' ) != -1 ) ? thumbnail : mw.getMwEmbedPath() + thumbnail; |
2038 | 2028 | } |
2039 | 2029 | var embed_code_html = '<script type="text/javascript" ' + |
2040 | | - 'src="' + mv_embed_path + 'mv_embed.js"></script>' + |
| 2030 | + 'src="' + mw.getMwEmbedPath() + 'mwEmbed.js"></script>' + |
2041 | 2031 | '<video '; |
2042 | 2032 | if ( this.roe ) { |
2043 | 2033 | embed_code_html += 'roe="' + escape( this.roe ) + '" '; |
— | — | @@ -2145,7 +2135,7 @@ |
2146 | 2136 | // check if textObj present: |
2147 | 2137 | if ( typeof this.textInterface == 'undefined' ) { |
2148 | 2138 | // load the default text interface: |
2149 | | - mvJsLoader.doLoad( [ |
| 2139 | + mw.load( [ |
2150 | 2140 | 'mvTextInterface', |
2151 | 2141 | '$j.fn.hoverIntent' |
2152 | 2142 | ], function() { |
— | — | @@ -2166,9 +2156,9 @@ |
2167 | 2157 | } |
2168 | 2158 | }, |
2169 | 2159 | /** |
2170 | | - * Generic function to display custom HTML inside the mv_embed element. |
| 2160 | + * Generic function to display custom HTML inside the mwEmbed element. |
2171 | 2161 | * The code should call the closeDisplayedHTML function to close the |
2172 | | - * display of the custom HTML and restore the regular mv_embed display. |
| 2162 | + * display of the custom HTML and restore the regular mwEmbed display. |
2173 | 2163 | * @param {String} html_code code for the selection list. |
2174 | 2164 | */ |
2175 | 2165 | displayHTML:function( html_code ) |
— | — | @@ -2212,7 +2202,7 @@ |
2213 | 2203 | }, |
2214 | 2204 | /** |
2215 | 2205 | * Close the custom HTML displayed using displayHTML and restores the |
2216 | | - * regular mv_embed display. |
| 2206 | + * regular mwEmbed display. |
2217 | 2207 | */ |
2218 | 2208 | closeDisplayedHTML:function() { |
2219 | 2209 | var sel_id = ( this.pc != null ) ? this.pc.pp.id:this.id; |
— | — | @@ -2367,7 +2357,7 @@ |
2368 | 2358 | pause: function() { |
2369 | 2359 | var _this = this; |
2370 | 2360 | var eid = ( this.pc != null ) ? this.pc.pp.id:this.id; |
2371 | | - // js_log('mv_embed:do pause'); |
| 2361 | + // js_log('mwEmbed:do pause'); |
2372 | 2362 | // (playing) do pause |
2373 | 2363 | this.paused = true; |
2374 | 2364 | var $pt = $j( '#' + eid); |
— | — | @@ -2670,21 +2660,23 @@ |
2671 | 2661 | library:null, |
2672 | 2662 | loaded:false, |
2673 | 2663 | loading_callbacks:null, |
2674 | | - supportsMIMEType : function( type ) |
| 2664 | + supportsMIMEType: function( type ) |
2675 | 2665 | { |
2676 | 2666 | for ( var i = 0; i < this.supported_types.length; i++ ) |
2677 | 2667 | if ( this.supported_types[i] == type ) |
2678 | 2668 | return true; |
2679 | 2669 | return false; |
2680 | 2670 | }, |
2681 | | - getName : function() |
| 2671 | + getName: function() |
2682 | 2672 | { |
2683 | 2673 | return gM( 'mwe-ogg-player-' + this.id ); |
2684 | 2674 | }, |
2685 | | - load : function( callback ) { |
2686 | | - mvJsLoader.doLoad( [ |
| 2675 | + load: function( callback ) { |
| 2676 | + debugger; |
| 2677 | + mw.load( [ |
2687 | 2678 | this.library + 'Embed' |
2688 | 2679 | ], function() { |
| 2680 | + var cat = nativeEmbed; |
2689 | 2681 | callback(); |
2690 | 2682 | } ); |
2691 | 2683 | } |
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvPlayList.js |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | }, |
176 | 176 | showShare:function() { |
177 | 177 | var embed_code = '<script type="text/javascript" ' + |
178 | | - 'src="' + mv_embed_path + 'mv_embed.js"></script> ' + "\n" + |
| 178 | + 'src="' + mw.getMwEmbedPath() + 'mwEmbed.js"></script> ' + "\n" + |
179 | 179 | '<playlist id="' + this.id + '" '; |
180 | 180 | if ( this.src ) { |
181 | 181 | embed_code += 'src="' + this.src + '" />'; |
— | — | @@ -1130,7 +1130,7 @@ |
1131 | 1131 | |
1132 | 1132 | this.embed = null; |
1133 | 1133 | // js_log('setup embed for clip '+ this.id + ':id is a function?'); |
1134 | | - // set up the pl_mv_embed object: |
| 1134 | + // set up the pl_mwEmbed object: |
1135 | 1135 | var init_pl_embed = { id:'e_' + this.id, |
1136 | 1136 | pc:this, // parent clip |
1137 | 1137 | src:this.src |
— | — | @@ -1270,7 +1270,7 @@ |
1271 | 1271 | return mv_clip_colors[num]; |
1272 | 1272 | } |
1273 | 1273 | } |
1274 | | -/* mv_embed extensions for playlists */ |
| 1274 | +/* mwEmbed extensions for playlists */ |
1275 | 1275 | var PlMvEmbed = function( vid_init ) { |
1276 | 1276 | // js_log('PlMvEmbed: '+ vid_init.id); |
1277 | 1277 | // create the div container |
— | — | @@ -1733,7 +1733,7 @@ |
1734 | 1734 | this[ 'type' ][ tObj.type ][ tObj.subtype ].u( tObj, percent, callback); |
1735 | 1735 | }, |
1736 | 1736 | getTransitionIcon:function( type, subtype ) { |
1737 | | - return mv_embed_path + '/skins/common/transition_images/' + type + '_' + subtype + '.png'; |
| 1737 | + return mw.getMwEmbedPath() + '/skins/common/transition_images/' + type + '_' + subtype + '.png'; |
1738 | 1738 | }, |
1739 | 1739 | /* |
1740 | 1740 | * mvTransLib: functional library mapping: |
— | — | @@ -2040,7 +2040,7 @@ |
2041 | 2041 | var mvSMILClip = function( sClipElm, mvClipInit ) { |
2042 | 2042 | return this.init( sClipElm, mvClipInit ); |
2043 | 2043 | } |
2044 | | -// all the overwritten and new methods for SMIL extension of mv_embed |
| 2044 | +// all the overwritten and new methods for SMIL extension of mwEmbed |
2045 | 2045 | mvSMILClip.prototype = { |
2046 | 2046 | instanceOf:'mvSMILClip', |
2047 | 2047 | params : { }, // support param as child of ref clips per SMIL spec |
— | — | @@ -2076,7 +2076,7 @@ |
2077 | 2077 | js_log( "SET wholeText for: " + this['tagName'] + ' ' + this['wholeText'] ); |
2078 | 2078 | } |
2079 | 2079 | // debugger; |
2080 | | - // mv_embed specific property: |
| 2080 | + // mwEmbed specific property: |
2081 | 2081 | if ( $j( sClipElm ).attr( 'poster' ) ) |
2082 | 2082 | this['img'] = $j( sClipElm ).attr( 'poster' ); |
2083 | 2083 | |
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvTimedEffectsEdit.js |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | // add our local msgs |
10 | | -loadGM( { |
| 10 | +mw.addMessages( { |
11 | 11 | "mwe-transition_in" : "Transition in", |
12 | 12 | "mwe-transition_out" : "Transition out", |
13 | 13 | "mwe-effects" : "Effects stack", |
— | — | @@ -128,11 +128,11 @@ |
129 | 129 | js_log( 'type:' + _this.rObj['type'] ); |
130 | 130 | $j( appendTarget ).html( gM( 'mwe-loading_txt' ) ); |
131 | 131 | // @@todo integrate into core and loading system: |
132 | | - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/editor.js?' + getMwReqParam() ); |
133 | | - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() ); |
134 | | - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/ui.js?' + getMwReqParam() ); |
135 | | - loadExternalJs( mv_embed_path + 'libClipEdit/pixastic-editor/uidata.js?' + getMwReqParam() ); |
136 | | - loadExternalCss( mv_embed_path + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() ); |
| 132 | + loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/editor.js?' + getMwReqParam() ); |
| 133 | + loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() ); |
| 134 | + loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/ui.js?' + getMwReqParam() ); |
| 135 | + loadExternalJs( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/uidata.js?' + getMwReqParam() ); |
| 136 | + loadExternalCss( mw.getMwEmbedPath() + 'libClipEdit/pixastic-editor/pixastic.all.js?' + getMwReqParam() ); |
137 | 137 | |
138 | 138 | var isPixasticReady = function() { |
139 | 139 | if ( typeof PixasticEditor != 'undefined' ) { |
Index: branches/js2-work/phase3/js2/mwEmbed/libSequencer/mvSequencer.js |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * exports back out to json or inline format |
20 | 20 | */ |
21 | 21 | |
22 | | -loadGM( { |
| 22 | +mw.addMessages( { |
23 | 23 | "mwe-menu_clipedit" : "Edit media", |
24 | 24 | "mwe-menu_transition" : "Transitions and effects", |
25 | 25 | "mwe-menu_cliplib" : "Add media", |
— | — | @@ -155,7 +155,7 @@ |
156 | 156 | 'html': gM( 'mwe-loading_txt' ), |
157 | 157 | 'js':function( this_seq ) { |
158 | 158 | // Load the search interface with sequence tool targets |
159 | | - mvJsLoader.doLoad( [ |
| 159 | + mw.load( [ |
160 | 160 | 'remoteSearchDriver', |
161 | 161 | 'seqRemoteSearchDriver' |
162 | 162 | ], function() { |
— | — | @@ -384,16 +384,16 @@ |
385 | 385 | '<div id="' + this.timeline_id + '_left_cnt" class="mv_tl_left_cnt">' + |
386 | 386 | '<div id="' + this.timeline_id + '_head_control" style="position:absolute;top:0px;left:0px;right:0px;height:30px;">' + |
387 | 387 | '<a title="' + gM( 'mwe-play_from_position' ) + '" href="javascript:' + this.instance_name + '.play_jt()">' + |
388 | | - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/control_play_blue.png">' + |
| 388 | + '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/control_play_blue.png">' + |
389 | 389 | '</a>' + |
390 | 390 | '<a title="' + gM( 'mwe-zoom_in' ) + '" href="javascript:' + this.instance_name + '.zoom_in()">' + |
391 | | - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/zoom_in.png">' + |
| 391 | + '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/zoom_in.png">' + |
392 | 392 | '</a>' + |
393 | 393 | '<a title="' + gM( 'mwe-zoom_out' ) + '" href="javascript:' + this.instance_name + '.zoom_out()">' + |
394 | | - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/zoom_out.png">' + |
| 394 | + '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/zoom_out.png">' + |
395 | 395 | '</a>' + |
396 | 396 | '<a title="' + gM( 'mwe-cut_clip' ) + '" href="javascript:' + this.instance_name + '.cut_mode()">' + |
397 | | - '<img style="width:16px;height:16px;border:0" src="' + mv_embed_path + 'images/cut.png">' + |
| 397 | + '<img style="width:16px;height:16px;border:0" src="' + mw.getMwEmbedPath() + 'images/cut.png">' + |
398 | 398 | '</a>' + |
399 | 399 | '</div>' + |
400 | 400 | '</div>' + |
— | — | @@ -430,7 +430,7 @@ |
431 | 431 | '<div id="track_cnt_' + i + '" style="top:' + top_pos + 'px;height:' + track_height + 'px;" class="track_name">' + |
432 | 432 | '<a id="mv_exc_' + i + '" title="' + exc_msg + '" href="javascript:' + this_sq.instance_name + '.exc_track(' + i + ',\'' + exc_action + '\')">' + |
433 | 433 | '<img id="' + this_sq.timeline_id + '_close_expand" style="width:16px;height:16px;border:0" ' + |
434 | | - ' src="' + mv_embed_path + 'images/' + exc_img + '.png">' + |
| 434 | + ' src="' + mw.getMwEmbedPath() + 'images/' + exc_img + '.png">' + |
435 | 435 | '</a>' + |
436 | 436 | track.title + '</div>' |
437 | 437 | ); |
— | — | @@ -776,7 +776,7 @@ |
777 | 777 | var _this = this; |
778 | 778 | // Add a loading image |
779 | 779 | mv_get_loading_img( '#transitions_ic' ); |
780 | | - mvJsLoader.doLoad( [ |
| 780 | + mw.load( [ |
781 | 781 | '$j.fn.ColorPicker', |
782 | 782 | 'mvTimedEffectsEdit' |
783 | 783 | ], function() { |
— | — | @@ -800,7 +800,7 @@ |
801 | 801 | mv_get_loading_img( '#clipedit_ic' ); |
802 | 802 | |
803 | 803 | // Load the clipEdit library if not already loaded: |
804 | | - mvJsLoader.doLoad( [ |
| 804 | + mw.load( [ |
805 | 805 | 'mvClipEdit' |
806 | 806 | ], function() { |
807 | 807 | // Zero out the current editor: |
— | — | @@ -1022,7 +1022,7 @@ |
1023 | 1023 | this_seq = this; |
1024 | 1024 | if ( req == 'close' ) { |
1025 | 1025 | $j( '#mv_exc_' + inx ).attr( 'href', 'javascript:' + this.instance_name + '.exc_track(' + inx + ',\'open\')' ); |
1026 | | - $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mv_embed_path + 'images/closed.png' ); |
| 1026 | + $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mw.getMwEmbedPath() + 'images/closed.png' ); |
1027 | 1027 | $j( '#track_cnt_' + inx + ',#container_track_' + inx ).animate( { height:this.track_text_height }, "slow", '', |
1028 | 1028 | function() { |
1029 | 1029 | this_seq.plObj.tracks[inx].disp_mode = 'text'; |
— | — | @@ -1030,7 +1030,7 @@ |
1031 | 1031 | } ); |
1032 | 1032 | } else if ( req == 'open' ) { |
1033 | 1033 | $j( '#mv_exc_' + inx ).attr( 'href', 'javascript:' + this.instance_name + '.exc_track(' + inx + ',\'close\')' ); |
1034 | | - $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mv_embed_path + 'images/opened.png' ); |
| 1034 | + $j( '#mv_exc_' + inx + ' > img' ).attr( 'src', mw.getMwEmbedPath() + 'images/opened.png' ); |
1035 | 1035 | $j( '#track_cnt_' + inx + ',#container_track_' + inx ).animate( { height:this.track_thumb_height }, "slow", '', |
1036 | 1036 | function() { |
1037 | 1037 | this_seq.plObj.tracks[inx].disp_mode = 'timeline_thumb'; |
— | — | @@ -1154,9 +1154,9 @@ |
1155 | 1155 | '" class="mv_time_clip_text mv_clip_drag">' + clip.title; |
1156 | 1156 | } |
1157 | 1157 | // add in per clip controls |
1158 | | - track_html += '<div title="' + gM( 'mwe-clip_in' ) + ' ' + clip.embed.start_ntp + '" class="ui-resizable-w ui-resizable-handle" style="width: 16px; height: 16px; left: 0px; top: 2px;background:url(\'' + mv_embed_path + 'images/application_side_contract.png\');" ></div>' + "\n"; |
1159 | | - track_html += '<div title="' + gM( 'mwe-clip_out' ) + ' ' + clip.embed.end_ntp + '" class="ui-resizable-e ui-resizable-handle" style="width: 16px; height: 16px; right: 0px; top: 2px;background:url(\'' + mv_embed_path + 'images/application_side_expand.png\');" ></div>' + "\n"; |
1160 | | - track_html += '<div title="' + gM( 'mwe-rmclip' ) + '" onClick="' + this.instance_name + '.removeClips(new Array([' + track_id + ',' + j + ']))" style="position:absolute;cursor:pointer;width: 16px; height: 16px; left: 0px; bottom:2px;background:url(\'' + mv_embed_path + 'images/delete.png\');"></div>' + "\n"; |
| 1158 | + track_html += '<div title="' + gM( 'mwe-clip_in' ) + ' ' + clip.embed.start_ntp + '" class="ui-resizable-w ui-resizable-handle" style="width: 16px; height: 16px; left: 0px; top: 2px;background:url(\'' + mw.getMwEmbedPath() + 'images/application_side_contract.png\');" ></div>' + "\n"; |
| 1159 | + track_html += '<div title="' + gM( 'mwe-clip_out' ) + ' ' + clip.embed.end_ntp + '" class="ui-resizable-e ui-resizable-handle" style="width: 16px; height: 16px; right: 0px; top: 2px;background:url(\'' + mw.getMwEmbedPath() + 'images/application_side_expand.png\');" ></div>' + "\n"; |
| 1160 | + track_html += '<div title="' + gM( 'mwe-rmclip' ) + '" onClick="' + this.instance_name + '.removeClips(new Array([' + track_id + ',' + j + ']))" style="position:absolute;cursor:pointer;width: 16px; height: 16px; left: 0px; bottom:2px;background:url(\'' + mw.getMwEmbedPath() + 'images/delete.png\');"></div>' + "\n"; |
1161 | 1161 | track_html += '<span style="display:none;" class="mv_clip_stats"></span>'; |
1162 | 1162 | |
1163 | 1163 | track_html += '</span>'; |
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testApiProxy.html |
— | — | @@ -3,14 +3,14 @@ |
4 | 4 | <head> |
5 | 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
6 | 6 | <title>Api Proxy Test</title> |
7 | | -<script type="text/javascript" src="../mv_embed.js"></script> |
| 7 | +<script type="text/javascript" src="../mwEmbed.js"></script> |
8 | 8 | |
9 | 9 | <script type="text/javascript" > |
10 | 10 | //HARD coded local test: |
11 | 11 | var remote_wiki_host = 'http://test.wikipedia.org'; |
12 | 12 | var remote_script_path = '/w'; |
13 | 13 | |
14 | | -js2AddOnloadHook( function(){ |
| 14 | +mw.addOnloadHook( function(){ |
15 | 15 | $j('#hostName').text( remote_wiki_host ); |
16 | 16 | //run the api-proxy setup: |
17 | 17 | $j.apiProxy( |
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testLang.html |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <html> |
3 | 3 | <head> |
4 | 4 | <title>Test Plural Conversions (should match php) </title> |
5 | | -<script type="text/javascript" src="../mv_embed.js"></script> |
| 5 | +<script type="text/javascript" src="../mwEmbed.js"></script> |
6 | 6 | <style> |
7 | 7 | td{ |
8 | 8 | border:solid thin black; |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | 'cy' |
176 | 176 | ]; |
177 | 177 | |
178 | | -js2AddOnloadHook( function(){ |
| 178 | +mw.addOnloadHook( function(){ |
179 | 179 | //do mauall script loaders calls to test multiple languages: |
180 | 180 | function doLangTable( langSet ){ |
181 | 181 | //build table output: |
Index: branches/js2-work/phase3/js2/mwEmbed/tests/testLang.js |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | /* a simple language tester replacements |
3 | 3 | */ |
4 | 4 | |
5 | | -loadGM( { |
| 5 | +mw.addMessages( { |
6 | 6 | "undelete_short" : "Undelete {{PLURAL:$1|one edit|$1 edits}}", |
7 | 7 | "category-subcat-count" : "{{PLURAL:$2|This category has only the following subcategory.|This category has the following {{PLURAL:$1|subcategory|$1 subcategories}}, out of $2 total.}}", |
8 | 8 | "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}" |
Index: branches/js2-work/phase3/js2/mwEmbed/libClipEdit/mvClipEdit.js |
— | — | @@ -1,8 +1,8 @@ |
2 | | -k/* |
| 2 | +/* |
3 | 3 | mvClipEdit hanndles the edit interfaces for images and video |
4 | 4 | */ |
5 | 5 | // set gMsg object: |
6 | | -loadGM( { |
| 6 | +mw.addMessages( { |
7 | 7 | "mwe-crop" : "Crop image", |
8 | 8 | "mwe-apply_crop" : "Apply crop to image", |
9 | 9 | "mwe-reset_crop" : "Reset crop", |
— | — | @@ -862,7 +862,7 @@ |
863 | 863 | $j( '.mv_crop_msg' ).hide(); |
864 | 864 | $j( '.mv_crop_msg_load' ).show(); |
865 | 865 | // load the jcrop library if needed: |
866 | | - mvJsLoader.doLoad( [ |
| 866 | + mw.load( [ |
867 | 867 | '$j.Jcrop' |
868 | 868 | ], function() { |
869 | 869 | _this.bindCrop(); |
Index: branches/js2-work/phase3/js2/mwEmbed/libMwApi/mw.proxy.js |
— | — | @@ -34,7 +34,7 @@ |
35 | 35 | * |
36 | 36 | */ |
37 | 37 | |
38 | | -loadGM( { |
| 38 | +mw.addMessages( { |
39 | 39 | "mwe-setting-up-proxy" : "Setting up proxy...", |
40 | 40 | "mwe-re-try" : "Retry API request", |
41 | 41 | "mwe-re-trying" : "Retrying API request...", |
Index: branches/js2-work/phase3/js2/apiProxyPage.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * Since this is proxy server set a pre-append debug flag to know which debug msgs are coming from where |
10 | 10 | */ |
11 | 11 | |
12 | | -mw.conf['debug_pre'] = 'Proxy'; |
| 12 | +mw.getConfig( 'pre-append-log' ) = 'Proxy'; |
13 | 13 | |
14 | 14 | if ( !mwApiProxyConfig ) |
15 | 15 | var mwApiProxyConfig = { }; |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | }; |
23 | 23 | |
24 | 24 | // User white_list should also be checked and configured at runtime. |
25 | | -js2AddOnloadHook( function() { |
| 25 | +mw.addOnloadHook( function() { |
26 | 26 | // build our configuration from the default and mwApiProxyConfig vars |
27 | 27 | mwApiProxyConfig = $j.extend( true, mwApiProxyDefaultConfig, mwApiProxyConfig ); |
28 | 28 | $j.apiProxy( 'server', mwApiProxyConfig ); |
Index: branches/js2-work/phase3/js2/ajaxcategories.js |
— | — | @@ -1,4 +1,4 @@ |
2 | | -loadGM( { |
| 2 | +mw.addMessages( { |
3 | 3 | "ajax-add-category" : "[Add Category]", |
4 | 4 | "ajax-add-category-submit" : "[Add]", |
5 | 5 | "ajax-confirm-prompt" : "[Confirmation Text]", |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | e.preventDefault(); |
19 | 19 | |
20 | 20 | // Make sure the suggestion plugin is loaded. Load everything else while we're at it |
21 | | - mvJsLoader.doLoad( |
| 21 | + mw.load( |
22 | 22 | ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'], |
23 | 23 | function() { |
24 | 24 | $j( '#mw-addcategory-prompt' ).toggle(); |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | |
82 | 82 | confirmEdit : function( page, fn, actionSummary, doneFn ) { |
83 | 83 | // Load jQuery UI |
84 | | - mvJsLoader.doLoad( |
| 84 | + mw.load( |
85 | 85 | ['$j.ui', '$j.ui.dialog', '$j.fn.suggestions'], |
86 | 86 | function() { |
87 | 87 | // Produce a confirmation dialog |
— | — | @@ -323,4 +323,4 @@ |
324 | 324 | } |
325 | 325 | }; |
326 | 326 | |
327 | | -js2AddOnloadHook( ajaxCategories.setupAJAXCategories ); |
| 327 | +mw.addOnloadHook( ajaxCategories.setupAJAXCategories ); |
Index: branches/js2-work/phase3/js2/js2stopgap.js |
— | — | @@ -9455,7 +9455,7 @@ |
9456 | 9456 | |
9457 | 9457 | /** |
9458 | 9458 | * This is designed to be directly compatible with (and is essentially taken |
9459 | | - * directly from) the mv_embed code for bringing internationalized messages into |
| 9459 | + * directly from) the mwEmbed code for bringing internationalized messages into |
9460 | 9460 | * the JavaScript space. As such, if we get to the point of merging that stuff |
9461 | 9461 | * into the main branch this code will be uneeded and probably cause issues. |
9462 | 9462 | */ |
— | — | @@ -9465,7 +9465,7 @@ |
9466 | 9466 | * Caches a list of messages for later retrieval |
9467 | 9467 | * @param {Object} msgSet Hash of key:value pairs of messages to cache |
9468 | 9468 | */ |
9469 | | -function loadGM( msgSet ){ |
| 9469 | +function mw.addMessages( msgSet ){ |
9470 | 9470 | for ( var i in msgSet ){ |
9471 | 9471 | gMsg[ i ] = msgSet[i]; |
9472 | 9472 | } |
— | — | @@ -9497,13 +9497,17 @@ |
9498 | 9498 | * Mimics the no-conflict method used by the js2 stuff |
9499 | 9499 | */ |
9500 | 9500 | $j = jQuery.noConflict(); |
| 9501 | + |
| 9502 | +if( !mw ) |
| 9503 | + mw = { }; |
| 9504 | + |
9501 | 9505 | /** |
9502 | 9506 | * Provides js2 compatible onload hook |
9503 | 9507 | * @param func Function to call when ready |
9504 | 9508 | */ |
9505 | | -function js2AddOnloadHook( func ) { |
| 9509 | +mw.addOnloadHook = function( func ) { |
9506 | 9510 | $j(document).ready( func ); |
9507 | 9511 | } |
9508 | 9512 | |
9509 | | -// Define a dummy mvJsLoader.doLoad() function |
| 9513 | +// Define a dummy mw.load() function |
9510 | 9514 | mvJsLoader = { doLoad: function( deps, callback ) { callback(); } }; |
Index: branches/js2-work/phase3/js2/remoteMwEmbed.js |
— | — | @@ -18,8 +18,8 @@ |
19 | 19 | } |
20 | 20 | |
21 | 21 | addOnloadHook( function() { |
22 | | - // Only do rewrites if MV_EMBED / js2 is "off" |
23 | | - if ( typeof MV_EMBED_VERSION == 'undefined' ) { |
| 22 | + // Only do rewrites if mwEmbed / js2 is "off" |
| 23 | + if ( typeof mwEmbed_VERSION == 'undefined' ) { |
24 | 24 | doPageSpecificRewrite(); |
25 | 25 | } |
26 | 26 | } ); |
— | — | @@ -28,14 +28,14 @@ |
29 | 29 | // Add media wizard |
30 | 30 | if ( wgAction == 'edit' || wgAction == 'submit' ) { |
31 | 31 | var jsSetEdit = [ 'remoteSearchDriver', '$j.fn.textSelection', '$j.ui', '$j.ui.sortable' ] |
32 | | - mwr_load_mv_embed( jsSetEdit, function() { |
| 32 | + mwr_load_mwEmbed( jsSetEdit, function() { |
33 | 33 | loadExternalJs( mwEmbedHostPath + '/editPage.js?' + mwGetReqArgs() ); |
34 | 34 | } ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | // Timed text display: |
38 | 38 | if ( wgPageName.indexOf( "TimedText" ) === 0 ) { |
39 | | - mwr_load_mv_embed( function() { |
| 39 | + mwr_load_mwEmbed( function() { |
40 | 40 | // Load with mw loader to get localized interface: |
41 | 41 | mw.load( ['mvTimeTextEdit'], function() { |
42 | 42 | // Could run init here (but mvTimeTextEdit already included onLoad actions) |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | if ( wgPageName == "Special:Upload" ) { |
49 | 49 | var jsSetUpload = [ 'mvBaseUploadInterface', 'mvFirefogg' , '$j.ui', |
50 | 50 | '$j.ui.progressbar', '$j.ui.dialog', '$j.ui.draggable' ]; |
51 | | - mwr_load_mv_embed( jsSetUpload, function() { |
| 51 | + mwr_load_mwEmbed( jsSetUpload, function() { |
52 | 52 | loadExternalJs( mwEmbedHostPath + '/uploadPage.js?' + mwGetReqArgs() ); |
53 | 53 | } ); |
54 | 54 | } |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | // Special api proxy page |
57 | 57 | if ( wgPageName == 'MediaWiki:ApiProxy' ) { |
58 | 58 | var wgEnableIframeApiProxy = true; |
59 | | - mwr_load_mv_embed( [ 'mw.proxy' ], function() { |
| 59 | + mwr_load_mwEmbed( [ 'mw.proxy' ], function() { |
60 | 60 | loadExternalJs( mwEmbedHostPath + '/apiProxyPage.js?' + mwGetReqArgs() ); |
61 | 61 | } ); |
62 | 62 | } |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | if ( navigator.userAgent && navigator.userAgent.indexOf("Firefox") != -1 ) |
80 | 80 | jsSetVideo.push( 'nativeEmbed' ); |
81 | 81 | |
82 | | - mwr_load_mv_embed( jsSetVideo, function() { |
| 82 | + mwr_load_mwEmbed( jsSetVideo, function() { |
83 | 83 | mvJsLoader.embedPlayerCheck( function() { |
84 | 84 | // Do utility rewrite of OggHandler content: |
85 | 85 | rewrite_for_OggHandler( vidIdList ); |
— | — | @@ -199,16 +199,16 @@ |
200 | 200 | /** |
201 | 201 | * @param {mixed} function or classSet to preload |
202 | 202 | * classSet saves round trips to the server by grabbing things we will likely need in the first request. |
203 | | -* ( this is essentially a shortcut to mv_jqueryBindings in mv_embed.js ) |
204 | | -* @param {callback} function callback to be called once mv_embed is ready |
| 203 | +* ( this is essentially a shortcut to mv_jqueryBindings in mwEmbed.js ) |
| 204 | +* @param {callback} function callback to be called once mwEmbed is ready |
205 | 205 | */ |
206 | | -function mwr_load_mv_embed( classSet, callback ) { |
| 206 | +function mwr_load_mwEmbed( classSet, callback ) { |
207 | 207 | if( typeof classSet == 'function') |
208 | 208 | callback = classSet; |
209 | | - // Inject mv_embed if needed |
| 209 | + // Inject mwEmbed if needed |
210 | 210 | if ( typeof mw == 'undefined' ) { |
211 | 211 | if ( ( mwReqParam['uselang'] || mwReqParam['useloader'] ) && mwUseScriptLoader ) { |
212 | | - var rurl = mwEmbedHostPath + '/mwEmbed/jsScriptLoader.php?class=mv_embed'; |
| 212 | + var rurl = mwEmbedHostPath + '/mwEmbed/jsScriptLoader.php?class=mwEmbed'; |
213 | 213 | |
214 | 214 | // Add jQuery too if we need it: |
215 | 215 | if ( typeof window.jQuery == 'undefined' ) { |
— | — | @@ -229,16 +229,16 @@ |
230 | 230 | importScriptURI( rurl ); |
231 | 231 | } else { |
232 | 232 | // Ingore classSet (will be loaded onDemand ) |
233 | | - importScriptURI( mwEmbedHostPath + '/mwEmbed/mv_embed.js?' + mwGetReqArgs() ); |
| 233 | + importScriptURI( mwEmbedHostPath + '/mwEmbed/mwEmbed.js?' + mwGetReqArgs() ); |
234 | 234 | } |
235 | 235 | } |
236 | | - mwr_check_for_mv_embed( callback ); |
| 236 | + mwr_check_for_mwEmbed( callback ); |
237 | 237 | } |
238 | 238 | |
239 | | -function mwr_check_for_mv_embed( callback ) { |
| 239 | +function mwr_check_for_mwEmbed( callback ) { |
240 | 240 | if ( typeof mw == 'undefined' ) { |
241 | 241 | setTimeout( function() { |
242 | | - mwr_check_for_mv_embed( callback ); |
| 242 | + mwr_check_for_mwEmbed( callback ); |
243 | 243 | }, 25 ); |
244 | 244 | } else { |
245 | 245 | callback(); |
Index: branches/js2-work/phase3/js2/js2stopgap.min.js |
— | — | @@ -778,5 +778,5 @@ |
779 | 779 | return $.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this[0]].concat(otherArgs));return this.each(function(){typeof options=='string'?$.datepicker['_'+options+'Datepicker'].apply($.datepicker,[this].concat(otherArgs)):$.datepicker._attachDatepicker(this,options);});};$.datepicker=new Datepicker();$.datepicker.initialized=false;$.datepicker.uuid=new Date().getTime();$.datepicker.version="1.7.2";window.DP_jQuery=$;})(jQuery);if(!gMsg)var gMsg={};function loadGM(msgSet){for(var i in msgSet){gMsg[i]=msgSet[i];}} |
780 | 780 | function gM(key,args){var ms='';if(key in gMsg){ms=gMsg[key];if(typeof args=='object'||typeof args=='array'){for(var v in args){var rep='\$'+(parseInt(v)+1);ms=ms.replace(rep,args[v]);}}else if(typeof args=='string'||typeof args=='number'){ms=ms.replace(/\$1/,args);} |
781 | 781 | return ms;}else{return'['+key+']';}} |
782 | | -$j=jQuery.noConflict();function js2AddOnloadHook(func){$j(document).ready(func);} |
| 782 | +$j=jQuery.noConflict();function mw.addOnloadHook(func){$j(document).ready(func);} |
783 | 783 | mvJsLoader={doLoad:function(deps,callback){callback();}}; |
\ No newline at end of file |