Index: branches/js2-work/phase3/includes/OutputPage.php |
— | — | @@ -184,7 +184,6 @@ |
185 | 185 | // @todo We should deprecate wikibits in favor of some mwEmbed pieces and jQuery |
186 | 186 | $coreClasses = array( 'window.jQuery', 'mwEmbed', 'wikibits' ); |
187 | 187 | |
188 | | - |
189 | 188 | //make sure scripts are on top: |
190 | 189 | $postScripts = $this->mScripts; |
191 | 190 | $this->mScripts = ''; |
Index: branches/js2-work/phase3/includes/AutoLoader.php |
— | — | @@ -632,7 +632,7 @@ |
633 | 633 | 'upload' => 'skins/common/upload.js', |
634 | 634 | 'wikibits' => 'skins/common/wikibits.js', |
635 | 635 | |
636 | | - // phase 2 javascript: |
| 636 | + // phase 2 javascript @@todo could be loaded from "loader.js" in $IP/js/loader.js |
637 | 637 | 'uploadPage' => 'js/uploadPage.js', |
638 | 638 | 'editPage' => 'js/editPage.js', |
639 | 639 | 'ajaxCategories' => 'js/ajaxcategories.js', |
Index: branches/js2-work/phase3/js/mwEmbed/loader.js |
— | — | @@ -0,0 +1,97 @@ |
| 2 | +/** |
| 3 | +* |
| 4 | +* Core "loader.js" for mwEmbed |
| 5 | +* |
| 6 | +* This loader along with all the enabled module loaders is combined with mwEmbed.js |
| 7 | +* via the script-loader. |
| 8 | +* |
| 9 | +*/ |
| 10 | + |
| 11 | +/** |
| 12 | +* The set of modules that you want enable. |
| 13 | +* |
| 14 | +* Each enabledModules array value should be a name |
| 15 | +* of a folder in mwEmbed/modules |
| 16 | +* |
| 17 | +* Modules must define a loader.js file in the root |
| 18 | +* of the module folder. |
| 19 | +* |
| 20 | +* The loader file should be short and only include: |
| 21 | +* Class paths of the module classes |
| 22 | +* Sytle sheets of the module |
| 23 | +* Loader function(s) that load module classes |
| 24 | +* |
| 25 | +* When using the scriptLoader the enabledModules loader code |
| 26 | +* is transcluded into base mwEmbed class include. |
| 27 | +*/ |
| 28 | +var mwEnabledModuleList = [ |
| 29 | + 'AddMedia', |
| 30 | + 'ClipEdit', |
| 31 | + 'EmbedPlayer', |
| 32 | + 'ApiProxy', |
| 33 | + 'Sequencer', |
| 34 | + 'TimedText' |
| 35 | +]; |
| 36 | + |
| 37 | +mw.setConfig( 'enabledModules', mwEnabledModuleList ); |
| 38 | + |
| 39 | +/** |
| 40 | +* -- Load Class Paths -- |
| 41 | +* |
| 42 | +* PHP AutoLoader reads this loader.js file along with |
| 43 | +* all the "loader.js" files to determin script-loader |
| 44 | +* class paths |
| 45 | +* |
| 46 | +*/ |
| 47 | + |
| 48 | +// Set the loaderContext for the classFiles paths call: |
| 49 | +mw.setConfig('loaderContext', '' ); |
| 50 | + |
| 51 | +mw.addClassFilePaths( { |
| 52 | + "mwEmbed" : "mwEmbed.js", |
| 53 | + "window.jQuery" : "jquery/jquery-1.3.2.js", |
| 54 | + |
| 55 | + "ctrlBuilder" : "skins/ctrlBuilder.js", |
| 56 | + "kskinConfig" : "skins/kskin/kskinConfig.js", |
| 57 | + "mvpcfConfig" : "skins/mvpcf/mvpcfConfig.js", |
| 58 | + |
| 59 | + "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", |
| 60 | + "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", |
| 61 | + "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", |
| 62 | + "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
| 63 | + "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
| 64 | + |
| 65 | + "mw.testLang" : "tests/testLang.js", |
| 66 | + |
| 67 | + "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
| 68 | + "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
| 69 | + "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
| 70 | + "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
| 71 | + "$j.browserTest" : "jquery/plugins/jquery.browserTest.js", |
| 72 | + |
| 73 | + "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
| 74 | + "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
| 75 | + "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js", |
| 76 | + "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js", |
| 77 | + "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js", |
| 78 | + "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js", |
| 79 | + "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js", |
| 80 | + "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js", |
| 81 | + "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js", |
| 82 | + "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js", |
| 83 | + "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js", |
| 84 | + "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js", |
| 85 | + "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js", |
| 86 | + "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js", |
| 87 | + "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js", |
| 88 | + "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js", |
| 89 | + "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js", |
| 90 | + "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js", |
| 91 | + "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js", |
| 92 | + "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js", |
| 93 | + "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js", |
| 94 | + "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js", |
| 95 | + "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", |
| 96 | + "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js" |
| 97 | + |
| 98 | +} ); |
\ No newline at end of file |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Player_Themable.html |
— | — | @@ -3,13 +3,14 @@ |
4 | 4 | <html> |
5 | 5 | <head> |
6 | 6 | <title>Sample Themed Player</title> |
7 | | - <!-- Pre-loading demo ( stuff ) likely needed for video display |
8 | | - <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText&debug=true"></script> |
| 7 | + <!-- Pre-loading demo ( stuff ) likely needed for video display --> |
| 8 | + <script type="text/javascript" src="../jsScriptLoader.php?class=mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText"></script> |
9 | 9 | <link rel="stylesheet" href="../skins/styles.css" type="text/css" media="screen" /> |
10 | 10 | <link rel="stylesheet" href="../skins/mvpcf/playerSkin.css" type="text/css" media="screen" /> |
11 | 11 | <link rel="stylesheet" href="../skins/kskin/playerSkin.css" type="text/css" media="screen" /> |
12 | | - --> |
| 12 | + <!-- |
13 | 13 | <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
| 14 | + --> |
14 | 15 | </head> |
15 | 16 | <script type="text/javascript"> |
16 | 17 | </script> |
Index: branches/js2-work/phase3/js/mwEmbed/tests/Add_Media_Wizard.html |
— | — | @@ -11,11 +11,16 @@ |
12 | 12 | border:medium none; |
13 | 13 | } |
14 | 14 | </style> |
15 | | - <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
| 15 | + <!-- |
| 16 | + <script type="text/javascript" src="../mwEmbed.js?debug=true"></script> |
| 17 | + --> |
| 18 | + |
16 | 19 | <script type="text/javascript" src="../jsScriptLoader.php?class=window.jQuery,mwEmbed,mw.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> |
| 20 | + |
17 | 21 | <script type="text/javascript"> |
18 | | - mw.ready(function(){ |
| 22 | + mw.ready( function(){ |
19 | 23 | mw.load( 'AddMedia.addMediaWizard', function(){ |
| 24 | + |
20 | 25 | $j('#add_media_link').addMediaWizard( { |
21 | 26 | 'profile' : 'html_edit', |
22 | 27 | 'target_textbox' : '#wpTextbox1', |
Index: branches/js2-work/phase3/js/mwEmbed/includes/jsClassLoader.php |
— | — | @@ -32,16 +32,13 @@ |
33 | 33 | throw new MWException( "mwEmbed.js missing check \$wgMwEmbedDirectory path\n" ); |
34 | 34 | return false; |
35 | 35 | } |
| 36 | + // Read the mwEmbed loader file: |
36 | 37 | |
37 | | - // Read the file: |
38 | | - $fileContent = file_get_contents( $wgMwEmbedDirectory . 'mwEmbed.js' ); |
| 38 | + $fileContent = file_get_contents( $wgMwEmbedDirectory . 'loader.js' ); |
| 39 | + |
39 | 40 | // Get class paths from mwEmbed.js |
40 | 41 | self::$directoryContext = $wgMwEmbedDirectory; |
41 | | - preg_replace_callback( |
42 | | - self::$classReplaceExp, |
43 | | - 'jsClassLoader::preg_classPathLoader', |
44 | | - $fileContent |
45 | | - ); |
| 42 | + self::proccessLoaderContent( $fileContent ); |
46 | 43 | |
47 | 44 | // Get the list of enabled modules into $wgJSModuleList |
48 | 45 | preg_replace_callback( |
— | — | @@ -52,28 +49,38 @@ |
53 | 50 | |
54 | 51 | // Get all the classes from the loader files: |
55 | 52 | foreach( self::$moduleList as $na => $moduleName){ |
56 | | - // Setup the directory context: |
| 53 | + // Setup the directory context for mwEmbed modules: |
57 | 54 | self::$directoryContext = $wgMwEmbedDirectory; |
| 55 | + |
58 | 56 | self::proccessLoaderPath( $wgMwEmbedDirectory . |
59 | 57 | 'modules/' . $moduleName . '/loader.js' ); |
60 | | - |
61 | 58 | } |
62 | 59 | |
63 | 60 | // Get all the extension loader paths registered mwEmbed modules |
64 | 61 | foreach( $wgExtensionJavascriptLoader as $na => $loaderPath){ |
65 | | - // Setup the directory context: |
| 62 | + // Setup the directory context for extensions |
66 | 63 | self::$directoryContext = 'extensions/' .str_replace('loader.js', '' , $loaderPath); |
67 | 64 | self::proccessLoaderPath( $IP . '/extensions/' . $loaderPath ); |
68 | 65 | } |
69 | 66 | } |
70 | 67 | /** |
71 | | - * Process a loader path |
| 68 | + * Process a loader path, passes off to proccessLoaderContent |
72 | 69 | * |
73 | 70 | * @param String $path |
74 | 71 | */ |
75 | 72 | private static function proccessLoaderPath( $path ){ |
| 73 | + // Get the loader content |
76 | 74 | $fileContent = file_get_contents( $path ); |
77 | | - |
| 75 | + self::proccessLoaderContent( $fileContent ); |
| 76 | + } |
| 77 | + /** |
| 78 | + * Process loader content |
| 79 | + * |
| 80 | + * parses the loader files and adds |
| 81 | + * |
| 82 | + * @param String $fileContent content of loader.js file |
| 83 | + */ |
| 84 | + private static function proccessLoaderContent( & $fileContent ){ |
78 | 85 | // Add the mwEmbed loader js to its global collector: |
79 | 86 | self::$combinedLoadersJs .= $fileContent; |
80 | 87 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | this.textSources = [ ]; |
257 | 257 | // Get local reference to all timed text sources: ( text/xml, text/x-srt etc ) |
258 | 258 | var inlineSources = this.embedPlayer.mediaElement.getSources( 'text' ); |
259 | | - //add all the sources to textSources |
| 259 | + // Add all the sources to textSources |
260 | 260 | for( var i = 0 ; i < inlineSources.length ; i++ ){ |
261 | 261 | // make a new textSource: |
262 | 262 | var source = new TextSource( inlineSources[i] ); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js |
— | — | @@ -33,21 +33,18 @@ |
34 | 34 | * Runs an api call then calls addResults with the resulting data |
35 | 35 | * @param {String} search_query Text search string |
36 | 36 | */ |
37 | | - getSearchResults:function( search_query ) { |
| 37 | + getProviderResults: function( search_query, callback ) { |
38 | 38 | var _this = this; |
39 | 39 | |
40 | | - // call parent for common initialisation: |
41 | | - this.parent_getSearchResults(); |
42 | | - |
43 | 40 | // setup the flickr request: |
44 | 41 | var request = { |
45 | 42 | 's': search_query, |
46 | 43 | 'page': this.provider.offset/this.provider.limit + 1 |
47 | 44 | } |
48 | | - mw.log( "Kaltura::getSearchResults query: " + request['s'] + " page: " + request['page']); |
| 45 | + mw.log( "Kaltura::getProviderResults query: " + request['s'] + " page: " + request['page']); |
49 | 46 | $j.getJSON( this.provider.api_url + '?callback=?', request, function( data ) { |
50 | 47 | _this.addResults( data ); |
51 | | - _this.loading = false; |
| 48 | + callback( 'ok' ); |
52 | 49 | } ); |
53 | 50 | }, |
54 | 51 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/mediaWikiSearch.js |
— | — | @@ -122,13 +122,11 @@ |
123 | 123 | * |
124 | 124 | * @param {String} search_query Text search string |
125 | 125 | */ |
126 | | - getSearchResults: function( search_query ) { |
127 | | - // call parent for common initialisation: |
128 | | - this.parent_getSearchResults(); |
| 126 | + getProviderResults: function( search_query, callback ) { |
129 | 127 | // Set local ref: |
130 | 128 | var _this = this; |
131 | 129 | |
132 | | - mw.log( 'f:getSearchResults for:' + search_query ); |
| 130 | + mw.log( 'metavid: getProviderResults for:' + search_query ); |
133 | 131 | |
134 | 132 | // Build the image request |
135 | 133 | var request = { |
— | — | @@ -149,7 +147,7 @@ |
150 | 148 | mw.getJSON( this.provider.api_url, request, function( data ) { |
151 | 149 | // Add result data: |
152 | 150 | _this.addResults( data ); |
153 | | - _this.loading = false; |
| 151 | + callback(); |
154 | 152 | } ); |
155 | 153 | }, |
156 | 154 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | * Does some common initialisation for search results |
74 | 74 | * @param {String} search_query Text search string |
75 | 75 | */ |
76 | | - getSearchResults: function( search_query ) { |
| 76 | + getSearchResults: function( search_query , callback ) { |
77 | 77 | // Empty out the current results before issuing a request |
78 | 78 | this.resultsObj = { }; |
79 | 79 | |
— | — | @@ -80,11 +80,19 @@ |
81 | 81 | this.last_query = search_query; |
82 | 82 | this.last_offset = this.provider.offset; |
83 | 83 | |
84 | | - // Set the loading flag: |
85 | | - this.loading = true; |
| 84 | + // Get the provider specifc results |
| 85 | + this.getProviderResults( search_query , callback); |
86 | 86 | }, |
87 | 87 | |
88 | 88 | /** |
| 89 | + * getProviderResults abstract method |
| 90 | + */ |
| 91 | + getProviderResults: function( searchQuery , calback){ |
| 92 | + mw.log( 'Error: getProviderResults not set by provider' ); |
| 93 | + callback( 'error-provider' ); |
| 94 | + }, |
| 95 | + |
| 96 | + /** |
89 | 97 | * Clears Results |
90 | 98 | */ |
91 | 99 | clearResults:function() { |
— | — | @@ -429,7 +437,7 @@ |
430 | 438 | */ |
431 | 439 | updateTargetResourceTitle:function( resource ) { |
432 | 440 | if( resource.titleKey ){ |
433 | | - resource.target_resource_title = resource.titleKey.replace( /^(File:|Image:)/ , '' ); |
| 441 | + resource.target_resource_title = resource.titleKey.replace( /^(File:|Image:)/ , '' ).replace(':', ''); |
434 | 442 | resource.target_resource_title = this.provider.resource_prefix + resource.target_resource_title; |
435 | 443 | } |
436 | 444 | }, |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/archiveOrgSearch.js |
— | — | @@ -35,13 +35,10 @@ |
36 | 36 | * |
37 | 37 | * @param {String} search_query Text search string |
38 | 38 | */ |
39 | | - getSearchResults: function( search_query ) { |
40 | | - |
41 | | - // call parent for common initialization: |
42 | | - this.parent_getSearchResults(); |
| 39 | + getProviderResults: function( search_query, callback ) { |
43 | 40 | |
44 | 41 | var _this = this; |
45 | | - mw.log( 'archive_org:getSearchResults for:' + search_query + ' from: ' + this.provider.api_url ); |
| 42 | + mw.log( 'archive_org:getProviderResults for:' + search_query + ' from: ' + this.provider.api_url ); |
46 | 43 | |
47 | 44 | |
48 | 45 | // For now force (Ogg video) & url based license |
— | — | @@ -60,7 +57,7 @@ |
61 | 58 | } |
62 | 59 | mw.getJSON( this.provider.api_url + '?json.wrf=?', request, function( data ) { |
63 | 60 | _this.addResults( data ); |
64 | | - _this.loading = false; |
| 61 | + callback( 'ok' ); |
65 | 62 | } ); |
66 | 63 | }, |
67 | 64 | /** |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/metavidSearch.js |
— | — | @@ -30,15 +30,11 @@ |
31 | 31 | * |
32 | 32 | * @param {String} search_query Text search string |
33 | 33 | */ |
34 | | - getSearchResults: function( search_query ) { |
35 | | - |
36 | | - // Call parent for common initialisation: |
37 | | - this.parent_getSearchResults(); |
38 | | - |
| 34 | + getProviderResults: function( search_query, callback ) { |
39 | 35 | // Set local ref: |
40 | 36 | var _this = this; |
41 | 37 | |
42 | | - mw.log( 'metavidSearch::getSearchResults()' ); |
| 38 | + mw.log( 'metavidSearch::getProviderResults()' ); |
43 | 39 | |
44 | 40 | // Process all options |
45 | 41 | var url = this.provider.api_url; |
— | — | @@ -90,7 +86,7 @@ |
91 | 87 | resource['license_template_tag'] = 'PD-USGov'; |
92 | 88 | } |
93 | 89 | // done loading: |
94 | | - _this.loading = 0; |
| 90 | + callback( 'ok' ); |
95 | 91 | } ); |
96 | 92 | }, |
97 | 93 | |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/flickrSearch.js |
— | — | @@ -51,13 +51,11 @@ |
52 | 52 | * Runs an api call then calls addResults with the resulting data |
53 | 53 | * @param {String} search_query Text search string |
54 | 54 | */ |
55 | | - getSearchResults:function( search_query ) { |
| 55 | + getProviderResults: function( search_query, callback ) { |
56 | 56 | var _this = this; |
57 | | - mw.log( "flickr::getSearchResults" ); |
| 57 | + mw.log( "flickr::getProviderResults" ); |
| 58 | + |
58 | 59 | |
59 | | - // call parent for common initialisation: |
60 | | - this.parent_getSearchResults(); |
61 | | - |
62 | 60 | // setup the flickr request: |
63 | 61 | var request = { |
64 | 62 | 'method':'flickr.photos.search', |
— | — | @@ -71,7 +69,7 @@ |
72 | 70 | } |
73 | 71 | $j.getJSON( this.provider.api_url + '?jsoncallback=?', request, function( data ) { |
74 | 72 | _this.addResults( data ); |
75 | | - _this.loading = false; |
| 73 | + callback( 'ok' ); |
76 | 74 | } ); |
77 | 75 | }, |
78 | 76 | /** |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -161,8 +161,6 @@ |
162 | 162 | } |
163 | 163 | |
164 | 164 | } )( jQuery ); |
165 | | - |
166 | | - |
167 | 165 | /** |
168 | 166 | * Set the mediaWiki globals if unset |
169 | 167 | */ |
— | — | @@ -1037,38 +1035,33 @@ |
1038 | 1036 | |
1039 | 1037 | // Else do showSearchTab |
1040 | 1038 | var provider = this.content_providers[ providerName ]; |
1041 | | - |
| 1039 | + |
1042 | 1040 | // Check if we need to update: |
1043 | 1041 | if ( typeof provider.sObj != 'undefined' ) { |
1044 | 1042 | if ( provider.sObj.last_query == $j( '#rsd_q' ).val() |
1045 | | - && provider.sObj.last_offset == provider.offset ) |
1046 | | - { |
| 1043 | + && provider.sObj.last_offset == provider.offset ) { |
| 1044 | + |
1047 | 1045 | mw.log( 'last query is: ' + provider.sObj.last_query + |
1048 | | - ' matches: ' + $j( '#rsd_q' ).val() ); |
1049 | | - } else { |
1050 | | - mw.log( 'last query is: ' + provider.sObj.last_query + |
1051 | | - ' not match: ' + $j( '#rsd_q' ).val() ); |
1052 | | - draw_direct_flag = false; |
| 1046 | + ' matches: ' + $j( '#rsd_q' ).val() + ' no search needed'); |
| 1047 | + |
| 1048 | + // Show search results directly |
| 1049 | + this.showResults(); |
1053 | 1050 | } |
1054 | | - } else { |
1055 | | - draw_direct_flag = false; |
1056 | 1051 | } |
1057 | | - |
1058 | | - if ( !draw_direct_flag ) { |
1059 | | - // See if we should reset the paging |
1060 | | - if ( resetPaging ) { |
1061 | | - provider.offset = 0; |
1062 | | - if (provider.sObj && provider.sObj.offset) { |
1063 | | - provider.sObj.offset = 0; |
1064 | | - } |
| 1052 | + |
| 1053 | + // See if we should reset the paging |
| 1054 | + if ( resetPaging ) { |
| 1055 | + provider.offset = 0; |
| 1056 | + if (provider.sObj && provider.sObj.offset) { |
| 1057 | + provider.sObj.offset = 0; |
1065 | 1058 | } |
1066 | | - |
1067 | | - // Set the content to loading while we do the search: |
1068 | | - $j( '#rsd_results_container' ).html( mw.loading_spinner() ); |
1069 | | - |
1070 | | - // Make sure the search library is loaded and issue the search request |
1071 | | - this.getLibSearchResults( provider ); |
1072 | 1059 | } |
| 1060 | + |
| 1061 | + // Set the content to loading while we do the search: |
| 1062 | + $j( '#rsd_results_container' ).html( mw.loading_spinner() ); |
| 1063 | + |
| 1064 | + // Make sure the search library is loaded and issue the search request |
| 1065 | + this.getProviderResults( provider ); |
1073 | 1066 | }, |
1074 | 1067 | |
1075 | 1068 | /* |
— | — | @@ -1171,15 +1164,15 @@ |
1172 | 1165 | * |
1173 | 1166 | * @param {Object} provider the provider to be searched. |
1174 | 1167 | */ |
1175 | | - getLibSearchResults: function( provider ) { |
| 1168 | + getProviderResults: function( provider ) { |
1176 | 1169 | var _this = this; |
1177 | | - mw.log('f: getLibSearchResults ' ); |
| 1170 | + mw.log('f: getProviderResults ' ); |
1178 | 1171 | // First check if we should even run the search at all (can we import / insert |
1179 | 1172 | // into the page? ) |
1180 | 1173 | if ( !this.isProviderLocal( provider ) && this.import_url_mode == 'autodetect' ) { |
1181 | 1174 | // provider is not local check if we can support the import mode: |
1182 | 1175 | this.checkForCopyURLSupport( function() { |
1183 | | - _this.getLibSearchResults( provider ); |
| 1176 | + _this.getProviderResults( provider ); |
1184 | 1177 | } ); |
1185 | 1178 | return false; |
1186 | 1179 | } else if ( !this.isProviderLocal( provider ) && this.import_url_mode == 'none' ) { |
— | — | @@ -1188,23 +1181,29 @@ |
1189 | 1182 | provider.sObj.loading = false; |
1190 | 1183 | } else { |
1191 | 1184 | $j( '#rsd_results_container' ).html( |
1192 | | - '<div style="padding:10px">' + |
1193 | | - gM( 'mwe-no_import_by_url' ) + |
1194 | | - '</div>' ); |
| 1185 | + gM( 'mwe-no_import_by_url' ) |
| 1186 | + ) |
1195 | 1187 | } |
1196 | 1188 | return false; |
1197 | 1189 | } |
| 1190 | + |
1198 | 1191 | _this.loadSearchLib( provider, function( provider ) { |
1199 | | - // Do the search: |
1200 | | - provider.sObj.getSearchResults( $j( '#rsd_q' ).val() ); |
1201 | | - |
1202 | | - _this.waitForResults( function( resultStatus ) { |
1203 | | - if( resultStatus == 'ok' ){ |
| 1192 | + var d = new Date(); |
| 1193 | + var searchTime = d.getMilliseconds(); |
| 1194 | + // Do the search: |
| 1195 | + provider.sObj.getSearchResults( $j( '#rsd_q' ).val() , function( resultStatus ){ |
| 1196 | + //if( resultStatus == 'ok' ){ |
1204 | 1197 | _this.showResults(); |
1205 | | - }else{ |
1206 | | - _this.showFailure( resultStatus ) |
1207 | | - } |
1208 | | - } ); |
| 1198 | + //}else{ |
| 1199 | + // _this.showFailure( resultStatus ) |
| 1200 | + //} |
| 1201 | + }); |
| 1202 | + |
| 1203 | + // Set a timeout of 20 seconds |
| 1204 | + setTimeout(function(){ |
| 1205 | + |
| 1206 | + }, 20 * 1000 ); |
| 1207 | + |
1209 | 1208 | } ); |
1210 | 1209 | }, |
1211 | 1210 | |
— | — | @@ -1242,49 +1241,6 @@ |
1243 | 1242 | callback( provider ); |
1244 | 1243 | } ); |
1245 | 1244 | }, |
1246 | | - |
1247 | | - /** |
1248 | | - * Waits for all results to be finished then calls the callback |
1249 | | - * |
1250 | | - * @param {Function} callback called once loading is done. calls callback with: |
1251 | | - * 'ok' search results retrived |
1252 | | - * 'error_key' search results not retrived |
1253 | | - * @param {Null} _callNumber Used internally to keep track of wait time |
1254 | | - */ |
1255 | | - waitForResults: function( callback, _callNumber ) { |
1256 | | - // mw.log('rsd:waitForResults'); |
1257 | | - var _this = this; |
1258 | | - var loading_done = true; |
1259 | | - |
1260 | | - if( !_callNumber ) |
1261 | | - _callNumber = 1; |
1262 | | - |
1263 | | - for ( var cp_id in this.content_providers ) { |
1264 | | - var cp = this.content_providers[ cp_id ]; |
1265 | | - if ( typeof cp['sObj'] != 'undefined' ) { |
1266 | | - if ( cp.sObj.loading ) |
1267 | | - loading_done = false; |
1268 | | - } |
1269 | | - } |
1270 | | - if( this.search_provider_timeout && |
1271 | | - (50/1000 * _callNumber) > this.search_provider_timeout ){ |
1272 | | - callback( 'timeout' ) |
1273 | | - return ; |
1274 | | - } |
1275 | | - |
1276 | | - if ( loading_done ) { |
1277 | | - callback( 'ok' ); |
1278 | | - return ; |
1279 | | - } |
1280 | | - |
1281 | | - setTimeout( |
1282 | | - function() { |
1283 | | - _callNumber++; |
1284 | | - _this.waitForResults( callback, _callNumber ); |
1285 | | - }, |
1286 | | - 50 |
1287 | | - ); |
1288 | | - }, |
1289 | 1245 | |
1290 | 1246 | /** |
1291 | 1247 | * Get a resource object from a resource id |
— | — | @@ -1502,10 +1458,9 @@ |
1503 | 1459 | /** |
1504 | 1460 | * Add Resource edit layout and display a loader. |
1505 | 1461 | */ |
1506 | | - addResourceEditLoader: function( maxWidth, overflowStyle ) { |
| 1462 | + addResourceEditLoader: function( maxWidth ) { |
1507 | 1463 | var _this = this; |
1508 | 1464 | if ( !maxWidth ) maxWidth = 400; |
1509 | | - if ( !overflowStyle ) overflowStyle = 'overflow:auto;'; |
1510 | 1465 | // Remove any old instance: |
1511 | 1466 | $j( _this.target_container ).find( '#rsd_resource_edit' ).remove(); |
1512 | 1467 | |
— | — | @@ -1513,24 +1468,53 @@ |
1514 | 1469 | $j( '#rsd_results_container' ).hide(); |
1515 | 1470 | |
1516 | 1471 | var pt = $j( _this.target_container ).html(); |
| 1472 | + |
| 1473 | + // Set up the interface compoents: |
| 1474 | + var $clipEditControl = $j('<div />') |
| 1475 | + .attr( 'id', 'clip_edit_ctrl' ) |
| 1476 | + .addClass('ui-widget ui-widget-content ui-corner-all') |
| 1477 | + .css( { |
| 1478 | + 'position' : 'absolute', |
| 1479 | + 'left' : '2px', |
| 1480 | + 'top' : '5px', |
| 1481 | + 'bottom' : '10px', |
| 1482 | + 'width' : ( maxWidth + 5 ) + 'px', |
| 1483 | + 'overflow' : 'auto', |
| 1484 | + 'padding' : '5px' |
| 1485 | + } ) |
| 1486 | + .loadingSpinner(); |
| 1487 | + |
| 1488 | + var $clipEditDisplay = $j('<div />') |
| 1489 | + .attr( 'id', 'clip_edit_disp' ) |
| 1490 | + .addClass( 'ui-widget ui-widget-content ui-corner-all' ) |
| 1491 | + .css({ |
| 1492 | + 'position' : 'absolute', |
| 1493 | + 'overflow' : 'auto;', |
| 1494 | + 'left' : ( maxWidth + 25 ) + 'px', |
| 1495 | + 'right' :'0px', |
| 1496 | + 'top' : '5px', |
| 1497 | + 'bottom' : '10px', |
| 1498 | + 'padding' : '5px' |
| 1499 | + }) |
| 1500 | + .loadingSpinner(); |
| 1501 | + |
| 1502 | + |
1517 | 1503 | // Add the edit layout window with loading place holders |
1518 | 1504 | $j( _this.target_container ).append( |
1519 | | - '<div id="rsd_resource_edit" ' + |
1520 | | - 'style="position:absolute;top:0px;left:0px;' + |
1521 | | - 'bottom:0px;right:4px;background-color:#FFF;"> ' + |
1522 | | - '<div id="clip_edit_ctrl" ' + |
1523 | | - 'class="ui-widget ui-widget-content ui-corner-all" ' + |
1524 | | - 'style="position:absolute;left:2px;top:5px;bottom:10px;' + |
1525 | | - 'width:' + ( maxWidth + 5 ) + 'px;overflow:auto;padding:5px;" >' + |
1526 | | - '</div>' + |
1527 | | - '<div id="clip_edit_disp" ' + |
1528 | | - 'class="ui-widget ui-widget-content ui-corner-all"' + |
1529 | | - 'style="position:absolute;' + overflowStyle + ';' + |
1530 | | - 'left:' + ( maxWidth + 20 ) + 'px;right:0px;top:5px;bottom:10px;' + |
1531 | | - 'padding:5px;" >' + |
1532 | | - mw.loading_spinner( 'position:absolute;top:30px;left:30px' ) + |
1533 | | - '</div>' + |
1534 | | - '</div>' ); |
| 1505 | + $j('<div />') |
| 1506 | + .attr( 'id', 'rsd_resource_edit' ) |
| 1507 | + .css( { |
| 1508 | + 'position' : 'absolute', |
| 1509 | + 'top' : '0px', |
| 1510 | + 'left' : '0px', |
| 1511 | + 'bottom' : '0px', |
| 1512 | + 'right' : '4px', |
| 1513 | + 'background-color' : '#FFF' |
| 1514 | + } ).append( |
| 1515 | + $clipEditControl, |
| 1516 | + $clipEditDisplay |
| 1517 | + ) |
| 1518 | + ); |
1535 | 1519 | }, |
1536 | 1520 | |
1537 | 1521 | /** |
— | — | @@ -1586,10 +1570,8 @@ |
1587 | 1571 | var mediaType = _this.getMediaType( resource ); |
1588 | 1572 | var maxWidth = _this.getMaxEditWidth( resource ); |
1589 | 1573 | |
1590 | | - // So that transcripts show on top |
1591 | | - var overflow_style = ( mediaType == 'video' ) ? '' : 'overflow:auto;'; |
1592 | 1574 | // Append to the top level of model window: |
1593 | | - _this.addResourceEditLoader( maxWidth, overflow_style ); |
| 1575 | + _this.addResourceEditLoader( maxWidth ); |
1594 | 1576 | // update add media wizard title: |
1595 | 1577 | var dialogTitle = gM( 'mwe-add_media_wizard' ) + ': ' + |
1596 | 1578 | gM( 'rsd_resource_edit', resource.title ); |
— | — | @@ -2047,10 +2029,10 @@ |
2048 | 2030 | 'left:50%;bottom:0px;top:30px;right:0px;overflow:auto;">' + |
2049 | 2031 | '<strong>' + gM( 'mwe-local_resource_title' ) + '</strong>' + |
2050 | 2032 | '<br/>' + |
2051 | | - '<input type="text" size="30" value="' + resource.target_resource_title + '" />' + |
| 2033 | + '<input id="rsd_filename" type="text" size="30" value="' + resource.target_resource_title + '" />' + |
2052 | 2034 | '<br/>' + |
2053 | 2035 | '<strong>' + gM( 'mwe-edit_resource_desc' ) + '</strong>' + |
2054 | | - '<textarea id="rsd_import_ta" ' + |
| 2036 | + '<textarea id="rsd_import_text" ' + |
2055 | 2037 | 'style="width:90%;" rows="8" cols="50">' + |
2056 | 2038 | desc + |
2057 | 2039 | '</textarea>' + |
— | — | @@ -2095,7 +2077,7 @@ |
2096 | 2078 | $j( '#rsd_import_desc' ).html( mw.loading_spinner() ); |
2097 | 2079 | // load the preview text: |
2098 | 2080 | _this.parse( |
2099 | | - $j( '#rsd_import_ta' ).val(), |
| 2081 | + $j( '#rsd_import_text' ).val(), |
2100 | 2082 | _this.canonicalFileNS + ':' + resource.target_resource_title, |
2101 | 2083 | function( o ) { |
2102 | 2084 | mw.log( 'got updated preview: ' ); |
— | — | @@ -2110,13 +2092,7 @@ |
2111 | 2093 | mw.log( "do import asset:" + _this.import_url_mode ); |
2112 | 2094 | // check import mode: |
2113 | 2095 | if ( _this.import_url_mode == 'api' ) { |
2114 | | - if ( _this.upload_api_target == 'proxy' ) { |
2115 | | - _this.setupProxy( function() { |
2116 | | - _this.doApiImport( resource, callback ); |
2117 | | - } ); |
2118 | | - } else { |
2119 | | - _this.doApiImport( resource, callback ); |
2120 | | - } |
| 2096 | + _this.doApiImport( resource, callback ); |
2121 | 2097 | } else { |
2122 | 2098 | mw.log( "Error: import mode is not form or API (can not copy asset)" ); |
2123 | 2099 | } |
— | — | @@ -2243,9 +2219,9 @@ |
2244 | 2220 | // Close the loader now that we are ready to present the progress dialog:: |
2245 | 2221 | mw.closeLoaderDialog(); |
2246 | 2222 | uploader.doHttpUpload( { |
2247 | | - 'url': resource.src, |
2248 | | - 'filename': resource.target_resource_title, |
2249 | | - 'comment': $j( '#rsd_import_ta' ).val() |
| 2223 | + 'url' : resource.src, |
| 2224 | + 'filename' : $j( '#rsd_filename' ).val(), |
| 2225 | + 'comment' : $j( '#rsd_import_text' ).val() |
2250 | 2226 | } ); |
2251 | 2227 | } ); |
2252 | 2228 | } |
— | — | @@ -2305,7 +2281,7 @@ |
2306 | 2282 | 'right' : '0px', |
2307 | 2283 | 'left' : '0px', |
2308 | 2284 | 'background-color' : '#FFF' |
2309 | | - }) |
| 2285 | + }).loadingSpinner() |
2310 | 2286 | ) |
2311 | 2287 | |
2312 | 2288 | var buttonPaneSelector = _this.target_container + '~ .ui-dialog-buttonpane'; |
— | — | @@ -2338,9 +2314,12 @@ |
2339 | 2315 | |
2340 | 2316 | // Get the preview wikitext |
2341 | 2317 | var embed_code = _this.getEmbedCode( resource ); |
2342 | | - $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } ); |
| 2318 | + //var pos = $j( _this.target_textbox ).getCaretPosition(); |
| 2319 | + var pos = 0; |
| 2320 | + var editWikiText = $j( _this.target_textbox ).val(); |
| 2321 | + var parseText = editWikiText.substr(0, pos) + embed_code + editWikiText.substr( pos ); |
2343 | 2322 | _this.parse( |
2344 | | - $j( _this.target_textbox ).val(), |
| 2323 | + parseText, |
2345 | 2324 | _this.target_title, |
2346 | 2325 | function( phtml ) { |
2347 | 2326 | $j( '#rsd_preview_display' ).html( phtml ); |
Index: branches/js2-work/phase3/js/mwEmbed/modules/ClipEdit/mw.ClipEdit.js |
— | — | @@ -641,7 +641,7 @@ |
642 | 642 | .buttonHover() |
643 | 643 | .click( function() { |
644 | 644 | _this.applyEdit(); |
645 | | - _this.controlActionsCallback['insert_seq']( _this.resource ); |
| 645 | + _this.controlActionsCallback[ 'insert_seq' ]( _this.resource ); |
646 | 646 | } ); |
647 | 647 | break; |
648 | 648 | case 'insert': |
— | — | @@ -659,7 +659,7 @@ |
660 | 660 | .buttonHover() |
661 | 661 | .click( function() { |
662 | 662 | _this.applyEdit(); |
663 | | - _this.controlActionsCallback['preview']( _this.resource ); |
| 663 | + _this.controlActionsCallback[ 'preview' ]( _this.resource ); |
664 | 664 | } ).show( 'slow' ); |
665 | 665 | break; |
666 | 666 | case 'cancel': |
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js |
— | — | @@ -31,39 +31,11 @@ |
32 | 32 | var MW_EMBED_VERSION = '1.0'; |
33 | 33 | |
34 | 34 | /** |
35 | | -* The set of modules that you want enable. |
36 | | -* |
37 | | -* Each enabledModules array value should be a name |
38 | | -* of a folder in mwEmbed/modules |
39 | | -* |
40 | | -* Modules must define a loader.js file in the root |
41 | | -* of the module folder. |
42 | | -* |
43 | | -* The loader file should be short and only include: |
44 | | -* Class paths of the module classes |
45 | | -* Sytle sheets of the module |
46 | | -* Loader function(s) that load module classes |
47 | | -* |
48 | | -* When using the scriptLoader the enabledModules loader code |
49 | | -* is transcluded into base mwEmbed class include. |
50 | | -*/ |
51 | | -var mwEnabledModuleList = [ |
52 | | - 'AddMedia', |
53 | | - 'ClipEdit', |
54 | | - 'EmbedPlayer', |
55 | | - 'ApiProxy', |
56 | | - 'Sequencer', |
57 | | - 'TimedText' |
58 | | -]; |
59 | | - |
60 | | -/** |
61 | 35 | * Default global config values. Configuration values are set via mw.setConfig |
62 | 36 | * Configuration values should generally be set prior to dom-ready |
63 | 37 | */ |
64 | 38 | var mwDefaultConf = { |
65 | 39 | |
66 | | - 'enabledModules' : mwEnabledModuleList, |
67 | | - |
68 | 40 | // Default skin name |
69 | 41 | 'skinName' : 'mvpcf', |
70 | 42 | |
— | — | @@ -930,7 +902,7 @@ |
931 | 903 | mw.log( 'Empty load request: ' + loadRequest ); |
932 | 904 | callback( loadRequest ); |
933 | 905 | return ; |
934 | | - } |
| 906 | + } |
935 | 907 | |
936 | 908 | // Check if its a multi-part request: |
937 | 909 | if( typeof loadRequest == 'object' ){ |
— | — | @@ -941,9 +913,7 @@ |
942 | 914 | // If an array of length 1 set as first element |
943 | 915 | loadRequest = loadRequest[0]; |
944 | 916 | } |
945 | | - } |
946 | | - //Add the string loadRequest callback ( for script-loader onDone callback ) |
947 | | - mwLoadDoneCB[ loadRequest ] = callback; |
| 917 | + } |
948 | 918 | |
949 | 919 | // Check for the module name loader function |
950 | 920 | if( this.moduleLoaders[ loadRequest ] && |
— | — | @@ -1026,9 +996,8 @@ |
1027 | 997 | loadDone = false; |
1028 | 998 | } |
1029 | 999 | // Run the parent scope callback for "loadMany" |
1030 | | - if( loadDone && callback && mwLoadDoneCB[ loadName ] != 'done' ){ |
1031 | | - callback( loadName ); |
1032 | | - mwLoadDoneCB[ loadName ] = 'done'; |
| 1000 | + if( loadDone ){ |
| 1001 | + callback( loadName ); |
1033 | 1002 | } |
1034 | 1003 | } ); |
1035 | 1004 | } |
— | — | @@ -1172,23 +1141,25 @@ |
1173 | 1142 | } |
1174 | 1143 | |
1175 | 1144 | // Include class defined check for older browsers |
1176 | | - var classDone = false; |
| 1145 | + var classDone = false; |
1177 | 1146 | |
| 1147 | + // Set the top level load done to the callback |
| 1148 | + mw.setLoadDoneCB( className, callback ); |
| 1149 | + |
1178 | 1150 | // Issue the request to load the class (include class name in result callback: |
1179 | | - mw.getScript( scriptRequest, function( scriptRequest ) { |
1180 | | - if(! mw.isset( className ) && callback){ |
| 1151 | + mw.getScript( scriptRequest, function( scriptRequest ) { |
| 1152 | + // Debug output |
| 1153 | + if(! mw.isset( className ) |
| 1154 | + && mwLoadDoneCB[ className ] != 'done' ){ |
1181 | 1155 | mw.log( 'Possible Error: ' + className +' not set in time, or not defined in:' + "\n" + _this.getClassPath( className ) ); |
1182 | 1156 | } |
1183 | | - // make sure callback is set and mwLoadDoneCB has not been called |
1184 | | - if( callback ){ |
1185 | | - callback( className ); |
1186 | | - } |
1187 | | - callback = null; |
| 1157 | + // Call load done (incase the script did not include a loadDone callback ) |
| 1158 | + mw.loadDone( className ); |
1188 | 1159 | } ); |
1189 | 1160 | //mw.log( 'done with running getScript request ' ); |
1190 | 1161 | |
1191 | 1162 | /* |
1192 | | - * If scriptLoader is not enabled |
| 1163 | + * ( If scriptLoader is not enabled ) |
1193 | 1164 | * |
1194 | 1165 | * Check if the class is ready: |
1195 | 1166 | * ( not all browsers support onLoad script attribute ) |
— | — | @@ -1196,11 +1167,9 @@ |
1197 | 1168 | */ |
1198 | 1169 | if( !mw.getScriptLoaderPath() ){ |
1199 | 1170 | setTimeout( function(){ |
1200 | | - mw.waitForObject( className, function( className ){ |
1201 | | - if( callback ){ |
1202 | | - callback( className ); |
1203 | | - callback = null; |
1204 | | - } |
| 1171 | + mw.waitForObject( className, function( className ){ |
| 1172 | + // Once object is ready run loadDone |
| 1173 | + mw.loadDone( className ); |
1205 | 1174 | } ); |
1206 | 1175 | }, 25 ); |
1207 | 1176 | } |
— | — | @@ -1277,13 +1246,21 @@ |
1278 | 1247 | * Load done callback for script loader |
1279 | 1248 | * this way webkit browsers don't have to check if variables are "ready" |
1280 | 1249 | */ |
1281 | | - mw.loadDone = function( requestName ) { |
1282 | | - mw.log( "LoadDone: " + requestName ); |
| 1250 | + mw.loadDone = function( requestName ) { |
1283 | 1251 | if( mwLoadDoneCB[ requestName ] && mwLoadDoneCB[ requestName ] != 'done'){ |
| 1252 | + mw.log( "LoadDone: " + requestName + ' run callback '); |
1284 | 1253 | mwLoadDoneCB[ requestName ]( requestName ); |
1285 | 1254 | mwLoadDoneCB[ requestName ] = 'done'; |
1286 | 1255 | } |
1287 | 1256 | }, |
| 1257 | + /** |
| 1258 | + * Set a load done callback |
| 1259 | + * @param {String} requestName Name of class or request set |
| 1260 | + * @param {Function} callback Function called once requestName is ready |
| 1261 | + */ |
| 1262 | + mw.setLoadDoneCB = function( requestName, callback ){ |
| 1263 | + mwLoadDoneCB[ requestName ] = callback; |
| 1264 | + } |
1288 | 1265 | |
1289 | 1266 | /** |
1290 | 1267 | * Add module entry point: Adds a module to the mwLoader object |
— | — | @@ -1371,7 +1348,7 @@ |
1372 | 1349 | if( !data['format'] ) |
1373 | 1350 | data['format'] = 'json'; |
1374 | 1351 | |
1375 | | - mw.log("run getJSON: " + url + ' data: ' + data['action'] ); |
| 1352 | + mw.log("run getJSON: " + mw.replaceUrlParams(url, data ) ); |
1376 | 1353 | |
1377 | 1354 | // Check if we need to setup proxy or do the request as a "post" |
1378 | 1355 | if( $j.inArray( data['action'], mw.getConfig( 'apiPostActions' ) ) != -1 ){ |
— | — | @@ -1490,6 +1467,13 @@ |
1491 | 1468 | mw.addDialog( msg_txt, msg_txt + '<br>' + mw.loading_spinner() ); |
1492 | 1469 | } |
1493 | 1470 | |
| 1471 | + /*mw.status = function( status ) |
| 1472 | + |
| 1473 | + |
| 1474 | + var Status = function(){ |
| 1475 | + |
| 1476 | + }*/ |
| 1477 | + |
1494 | 1478 | /** |
1495 | 1479 | * Add a dialog window: |
1496 | 1480 | * @param {String} title Title string for the dialog |
— | — | @@ -1590,7 +1574,7 @@ |
1591 | 1575 | callback( false ); |
1592 | 1576 | return ; |
1593 | 1577 | } |
1594 | | - |
| 1578 | + // If the object is defined ( or we are done loading from a callback ) |
1595 | 1579 | if ( mw.isset( objectName ) || mwLoadDoneCB[ objectName ] == 'done' ){ |
1596 | 1580 | callback( objectName ) |
1597 | 1581 | }else{ |
— | — | @@ -2242,42 +2226,37 @@ |
2243 | 2227 | |
2244 | 2228 | mw.log( 'mw:setupMwEmbed :: ' + mw.getMwEmbedSrc() ); |
2245 | 2229 | |
2246 | | - // Make sure jQuery is loaded |
2247 | | - mw.load( 'window.jQuery', function(){ |
2248 | | - |
2249 | | - if ( !window['$j'] ) { |
2250 | | - window['$j'] = jQuery.noConflict(); |
2251 | | - } |
2252 | | - |
2253 | | - mw.log(" loadded all ~loaders~ " ); |
2254 | | - |
2255 | | - mw.setConfig( 'jquery_skin_path', mw.getMwEmbedPath() + 'jquery/jquery.ui/themes/' + mw.getConfig( 'jui_skin' ) + '/' ); |
2256 | | - |
2257 | | - // Only load jquery ui theme sheet if ui-widget does not exist. |
2258 | | - if( ! mw.styleRuleExists( 'ui-widget' ) ){ |
2259 | | - mw.getStyleSheet( mw.getConfig( 'jquery_skin_path' ) + 'jquery-ui-1.7.1.custom.css' ); |
2260 | | - } |
2261 | | - |
2262 | | - mw.setConfig( 'skin_img_path', mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skinName' ) + '/images/' ); |
2263 | | - mw.setConfig( 'default_video_thumb', mw.getConfig( 'skin_img_path' ) + 'vid_default_thumb.jpg' ); |
2264 | | - |
2265 | | - // Make Core skin/style sheets are always available: |
2266 | | - mw.getStyleSheet( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skinName' ) + '/styles.css' ); |
2267 | | - |
2268 | | - // Set up AJAX to not send dynamic URLs for loading scripts |
2269 | | - $j.ajaxSetup( { |
2270 | | - cache: true |
2271 | | - } ); |
2272 | | - |
2273 | | - //Update the magic keywords |
2274 | | - mw.lang.magicSetup(); |
2275 | | - |
2276 | | - // Set up mvEmbed utility jQuery bindings |
2277 | | - mwDojQueryBindings(); |
2278 | | - |
2279 | | - //Make sure we have all the module loaders |
2280 | | - mw.moduleLoaderCheck( function(){ |
2281 | | - |
| 2230 | + // Make sure we have all the module loaders |
| 2231 | + mw.moduleLoaderCheck( function(){ |
| 2232 | + // Make sure we have jQuery: |
| 2233 | + mw.load( 'window.jQuery', function(){ |
| 2234 | + if ( !window['$j'] ) { |
| 2235 | + window['$j'] = jQuery.noConflict(); |
| 2236 | + } |
| 2237 | + mw.setConfig( 'jquery_skin_path', mw.getMwEmbedPath() + 'jquery/jquery.ui/themes/' + mw.getConfig( 'jui_skin' ) + '/' ); |
| 2238 | + |
| 2239 | + // Only load jquery ui theme sheet if ui-widget does not exist. |
| 2240 | + if( ! mw.styleRuleExists( 'ui-widget' ) ){ |
| 2241 | + mw.getStyleSheet( mw.getConfig( 'jquery_skin_path' ) + 'jquery-ui-1.7.1.custom.css' ); |
| 2242 | + } |
| 2243 | + |
| 2244 | + mw.setConfig( 'skin_img_path', mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skinName' ) + '/images/' ); |
| 2245 | + mw.setConfig( 'default_video_thumb', mw.getConfig( 'skin_img_path' ) + 'vid_default_thumb.jpg' ); |
| 2246 | + |
| 2247 | + // Make Core skin/style sheets are always available: |
| 2248 | + mw.getStyleSheet( mw.getMwEmbedPath() + 'skins/' + mw.getConfig( 'skinName' ) + '/styles.css' ); |
| 2249 | + |
| 2250 | + // Set up AJAX to not send dynamic URLs for loading scripts |
| 2251 | + $j.ajaxSetup( { |
| 2252 | + cache: true |
| 2253 | + } ); |
| 2254 | + |
| 2255 | + //Update the magic keywords |
| 2256 | + mw.lang.magicSetup(); |
| 2257 | + |
| 2258 | + // Set up mvEmbed utility jQuery bindings |
| 2259 | + mwDojQueryBindings(); |
| 2260 | + |
2282 | 2261 | // Check DOM for tag-rewrites |
2283 | 2262 | if( mw.documentHasPlayerTags() ){ |
2284 | 2263 | // Load the embedPlayer module ( then run queued hooks ) |
— | — | @@ -2297,7 +2276,9 @@ |
2298 | 2277 | |
2299 | 2278 | /** |
2300 | 2279 | * Check for module loaders |
2301 | | - * loads module loaders if we are not using a scriptLoader entry point |
| 2280 | + * loads module loaders. |
| 2281 | + * |
| 2282 | + * Note if using a scriptLoader all the loaders are included automatically. |
2302 | 2283 | */ |
2303 | 2284 | mw.moduleLoaderCheck = function( callback ){ |
2304 | 2285 | mw.log( 'doLoaderCheck::' ); |
— | — | @@ -2306,17 +2287,19 @@ |
2307 | 2288 | callback(); |
2308 | 2289 | return ; |
2309 | 2290 | } |
2310 | | - |
2311 | | - // Load all the "loaders" of the enabled modules: |
2312 | | - var loaderRequest = []; |
2313 | | - var enabledModules = mw.getConfig( 'enabledModules' ); |
2314 | | - $j.each( enabledModules, function( na, module_name ){ |
2315 | | - loaderRequest.push( 'modules/' + module_name + '/loader.js' ); |
2316 | | - }) |
2317 | | - mw.setConfig('loaderContext', '' ); |
2318 | | - mw.load( loaderRequest, function(){ |
2319 | | - callback(); |
2320 | | - } ); |
| 2291 | + // Add the Core loader to the request |
| 2292 | + mw.load( 'loader.js', function(){ |
| 2293 | + // Load all the "loaders" of the enabled modules: |
| 2294 | + var loaderRequest = []; |
| 2295 | + var enabledModules = mw.getConfig( 'enabledModules' ); |
| 2296 | + for(var i=0; i < enabledModules.length; i++ ){ |
| 2297 | + loaderRequest.push( 'modules/' + enabledModules[ i ] + '/loader.js' ); |
| 2298 | + }; |
| 2299 | + mw.setConfig('loaderContext', '' ); |
| 2300 | + mw.load( loaderRequest, function(){ |
| 2301 | + callback(); |
| 2302 | + } ); |
| 2303 | + } ); |
2321 | 2304 | } |
2322 | 2305 | |
2323 | 2306 | /** |
— | — | @@ -2404,66 +2387,7 @@ |
2405 | 2388 | // Setup legacy global shortcuts: |
2406 | 2389 | var loadRS = mw.lang.loadRS; |
2407 | 2390 | |
2408 | | -/** |
2409 | | -* -- Load Class Paths -- |
2410 | | -* |
2411 | | -* PHP AutoLoader reads this mwEmbed.js file along with |
2412 | | -* all the "loader.js" files to determin script-loader |
2413 | | -* class paths |
2414 | | -* |
2415 | | -*/ |
2416 | | -mw.setConfig('loaderContext', '' ); |
2417 | 2391 | |
2418 | | -mw.addClassFilePaths( { |
2419 | | - "mwEmbed" : "mwEmbed.js", |
2420 | | - "window.jQuery" : "jquery/jquery-1.3.2.js", |
2421 | | - |
2422 | | - "ctrlBuilder" : "skins/ctrlBuilder.js", |
2423 | | - "kskinConfig" : "skins/kskin/kskinConfig.js", |
2424 | | - "mvpcfConfig" : "skins/mvpcf/mvpcfConfig.js", |
2425 | | - |
2426 | | - "$j.fn.pngFix" : "jquery/plugins/jquery.pngFix.js", |
2427 | | - "$j.fn.autocomplete": "jquery/plugins/jquery.autocomplete.js", |
2428 | | - "$j.fn.hoverIntent" : "jquery/plugins/jquery.hoverIntent.js", |
2429 | | - "$j.fn.datePicker" : "jquery/plugins/jquery.datePicker.js", |
2430 | | - "$j.ui" : "jquery/jquery.ui/ui/ui.core.js", |
2431 | | - |
2432 | | - "mw.testLang" : "tests/testLang.js", |
2433 | | - |
2434 | | - "$j.cookie" : "jquery/plugins/jquery.cookie.js", |
2435 | | - "$j.contextMenu" : "jquery/plugins/jquery.contextMenu.js", |
2436 | | - "$j.fn.suggestions" : "jquery/plugins/jquery.suggestions.js", |
2437 | | - "$j.fn.textSelection" : "jquery/plugins/jquery.textSelection.js", |
2438 | | - "$j.browserTest" : "jquery/plugins/jquery.browserTest.js", |
2439 | | - |
2440 | | - "$j.effects.blind" : "jquery/jquery.ui/ui/effects.blind.js", |
2441 | | - "$j.effects.drop" : "jquery/jquery.ui/ui/effects.drop.js", |
2442 | | - "$j.effects.pulsate" : "jquery/jquery.ui/ui/effects.pulsate.js", |
2443 | | - "$j.effects.transfer" : "jquery/jquery.ui/ui/effects.transfer.js", |
2444 | | - "$j.ui.droppable" : "jquery/jquery.ui/ui/ui.droppable.js", |
2445 | | - "$j.ui.slider" : "jquery/jquery.ui/ui/ui.slider.js", |
2446 | | - "$j.effects.bounce" : "jquery/jquery.ui/ui/effects.bounce.js", |
2447 | | - "$j.effects.explode" : "jquery/jquery.ui/ui/effects.explode.js", |
2448 | | - "$j.effects.scale" : "jquery/jquery.ui/ui/effects.scale.js", |
2449 | | - "$j.ui.datepicker" : "jquery/jquery.ui/ui/ui.datepicker.js", |
2450 | | - "$j.ui.progressbar" : "jquery/jquery.ui/ui/ui.progressbar.js", |
2451 | | - "$j.ui.sortable" : "jquery/jquery.ui/ui/ui.sortable.js", |
2452 | | - "$j.effects.clip" : "jquery/jquery.ui/ui/effects.clip.js", |
2453 | | - "$j.effects.fold" : "jquery/jquery.ui/ui/effects.fold.js", |
2454 | | - "$j.effects.shake" : "jquery/jquery.ui/ui/effects.shake.js", |
2455 | | - "$j.ui.dialog" : "jquery/jquery.ui/ui/ui.dialog.js", |
2456 | | - "$j.ui.resizable" : "jquery/jquery.ui/ui/ui.resizable.js", |
2457 | | - "$j.ui.tabs" : "jquery/jquery.ui/ui/ui.tabs.js", |
2458 | | - "$j.effects.core" : "jquery/jquery.ui/ui/effects.core.js", |
2459 | | - "$j.effects.highlight" : "jquery/jquery.ui/ui/effects.highlight.js", |
2460 | | - "$j.effects.slide" : "jquery/jquery.ui/ui/effects.slide.js", |
2461 | | - "$j.ui.accordion" : "jquery/jquery.ui/ui/ui.accordion.js", |
2462 | | - "$j.ui.draggable" : "jquery/jquery.ui/ui/ui.draggable.js", |
2463 | | - "$j.ui.selectable" : "jquery/jquery.ui/ui/ui.selectable.js" |
2464 | | - |
2465 | | -} ); |
2466 | | - |
2467 | | - |
2468 | 2392 | /** |
2469 | 2393 | * Add the core mvEmbed Messages ( will be localized by script server ) |
2470 | 2394 | */ |
Index: branches/js2-work/phase3/js/loader.js |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +/** |
| 3 | +* Loader to support dynamic loading of mediaWiki js pages |
| 4 | +*/ |
| 5 | + |
| 6 | +mw.setConfig('loaderContext', wgScriptPath + '/js/'); |
| 7 | + |
| 8 | +mw.addClassFilePaths( { |
| 9 | + 'uploadPage' => 'js/uploadPage.js', |
| 10 | + 'editPage' => 'js/editPage.js', |
| 11 | + 'ajaxCategories' => 'js/ajaxcategories.js', |
| 12 | + 'apiProxyPage' => 'js/apiProxyPage.js' |
| 13 | +} ); |
\ No newline at end of file |