r61276 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61275‎ | r61276 | r61277 >
Date:23:18, 19 January 2010
Author:dale
Status:deferred
Tags:
Comment:
* fix bug 22144 for preview
* refactor more remoteSearchDriver code
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js
@@ -8,7 +8,7 @@
99 * timed text search & seek interface ( version 2 )
1010 *
1111 * @author: Michael Dale
12 - *
 12+ *
1313 * Some code borrowed from: http://www.annodex.net/~silvia/itext/elephant_no_skin_v2.html
1414 * ( Licensed under: MPL 1.1/GPL 2.0/LGPL 2.1 )
1515 * Contributor(s):
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -1971,88 +1971,18 @@
19721972 var _this = this;
19731973 mw.log( "showImportUI:: update:" + _this.canonicalFileNS + ':' +
19741974 resource.target_resource_title );
1975 -
1976 - // setup the resource description from resource description:
1977 - // FIXME: i18n, namespace
1978 - var desc = '{{Information ' + "\n";
1979 -
1980 - if ( resource.desc ) {
1981 - desc += '|Description= ' + resource.desc + "\n";
1982 - } else {
1983 - desc += '|Description= ' + gM( 'mwe-missing_desc_see_source', resource.link ) + "\n";
1984 - }
1985 -
1986 - // Output search specific info
1987 - desc += '|Source=' + resource.pSobj.getImportResourceDescWiki( resource ) + "\n";
1988 -
1989 - if ( resource.author )
1990 - desc += '|Author=' + resource.author + "\n";
1991 -
1992 - if ( resource.date )
1993 - desc += '|Date=' + resource.date + "\n";
1994 -
1995 - // Add the Permission info:
1996 - desc += '|Permission=' + resource.pSobj.getPermissionWikiTag( resource ) + "\n";
1997 -
1998 - if ( resource.other_versions )
1999 - desc += '|other_versions=' + resource.other_versions + "\n";
2000 -
2001 - desc += '}}';
2002 -
2003 - // Get any extra categories or helpful links
2004 - desc += resource.pSobj.getExtraResourceDescWiki( resource );
2005 -
2006 -
2007 - $j( '#rsd_resource_import' ).remove();// remove any old resource imports
2008 -
2009 - // Show user dialog to import the resource
 1975+
 1976+ var description = _this.getTemplateDescription( resource );
 1977+
 1978+
 1979+ // Remove any old resource imports
 1980+ $j( '#rsd_resource_import' ).remove();
 1981+
 1982+ // Update the interface
20101983 $j( _this.target_container ).append(
2011 - '<div id="rsd_resource_import" ' +
2012 - 'class="ui-widget-content" ' +
2013 - 'style="position:absolute;top:0px;left:0px;right:0px;bottom:0px;z-index:5">' +
2014 - '<h3 style="color:red;padding:5px;">' +
2015 - gM( 'mwe-resource-needs-import', [resource.title, _this.upload_api_name] ) +
2016 - '</h3>' +
2017 - '<div id="rsd_preview_import_container" ' +
2018 - 'style="position:absolute;width:49%;bottom:0px;left:5px;' +
2019 - 'overflow:auto;top:30px;">' +
 1984+ _this.getResourceImportInterface( resource , description )
 1985+ );
20201986
2021 - // Get embedHTML with small thumb:
2022 - resource.pSobj.getEmbedHTML( resource, {
2023 - 'id': _this.target_container + '_rsd_pv_vid',
2024 - 'max_height': '220',
2025 - 'only_poster': true
2026 - } ) +
2027 -
2028 - '<br style="clear both"/>' +
2029 - '<strong>' + gM( 'mwe-resource_page_desc' ) + '</strong>' +
2030 - '<div id="rsd_import_desc" style="display:inline;">' +
2031 - mw.loading_spinner( 'position:absolute;top:5px;left:5px' ) +
2032 - '</div>' +
2033 - '</div>' +
2034 - '<div id="rds_edit_import_container" ' +
2035 - 'style="position:absolute; ' +
2036 - 'left:50%;bottom:0px;top:30px;right:0px;overflow:auto;">' +
2037 - '<strong>' + gM( 'mwe-local_resource_title' ) + '</strong>' +
2038 - '<br/>' +
2039 - '<input id="rsd_filename" type="text" size="30" value="' + resource.target_resource_title + '" />' +
2040 - '<br/>' +
2041 - '<strong>' + gM( 'mwe-edit_resource_desc' ) + '</strong>' +
2042 - '<textarea id="rsd_import_text" ' +
2043 - 'style="width:90%;" rows="8" cols="50">' +
2044 - desc +
2045 - '</textarea>' +
2046 - '<br/>' +
2047 - '<input type="checkbox" value="true" id="wpWatchthis" ' +
2048 - 'name="wpWatchthis" tabindex="7" />' +
2049 - '<label for="wpWatchthis">' + gM( 'mwe-watch_this_page' ) + '</label> ' +
2050 - '<br/><br/><br/>' +
2051 - $j.btnHtml( gM( 'mwe-update_preview' ), 'rsd_import_apreview', 'refresh' ) +
2052 - ' ' +
2053 - '</div>' +
2054 - // Output the rendered and non-rendered version of description for easy switching:
2055 - '</div>' );
2056 -
20571987 var buttonPaneSelector = _this.target_container + '~ .ui-dialog-buttonpane';
20581988 $j( buttonPaneSelector ).html (
20591989 // Add the buttons to the bottom:
@@ -2069,7 +1999,7 @@
20702000
20712001 // Load the preview text:
20722002 _this.parse(
2073 - desc, _this.canonicalFileNS + ':' + resource.target_resource_title,
 2003+ description, _this.canonicalFileNS + ':' + resource.target_resource_title,
20742004 function( descHtml ) {
20752005 $j( '#rsd_import_desc' ).html( descHtml );
20762006 }
@@ -2083,7 +2013,7 @@
20842014 $j( '#rsd_import_desc' ).html( mw.loading_spinner() );
20852015 // load the preview text:
20862016 _this.parse(
2087 - $j( '#rsd_import_text' ).val(),
 2017+ $j( '#wpUploadDescription' ).val(),
20882018 _this.canonicalFileNS + ':' + resource.target_resource_title,
20892019 function( o ) {
20902020 mw.log( 'got updated preview: ' );
@@ -2114,7 +2044,180 @@
21152045 } );
21162046 } );
21172047 },
 2048+
 2049+ /**
 2050+ * Get the resource Import interface
 2051+ */
 2052+ getResourceImportInterface: function( resource, description ){
 2053+ var _this = this;
 2054+ var $rsdResourceImport = $j('<div />')
 2055+ .attr( 'id', 'rsd_resource_import' )
 2056+ .addClass( 'ui-widget-content' )
 2057+ .css( {
 2058+ 'position' : 'absolute',
 2059+ 'top' : '0px',
 2060+ 'left' : '0px',
 2061+ 'right' : '0px',
 2062+ 'bottom' : '0px',
 2063+ 'z-index' : '5'
 2064+ } );
 2065+
 2066+ var $rsdPreviewContainer = $j( '<div />')
 2067+ .attr( 'id', 'rsd_preview_import_container' )
 2068+ .css( {
 2069+ 'position' : 'absolute',
 2070+ 'width' : '49%',
 2071+ 'bottom' : '0px',
 2072+ 'left' : '5px',
 2073+ 'overflow' : 'auto',
 2074+ 'top' : '30px'
 2075+ } )
 2076+ .append(
 2077+ // Get embedHTML with small thumb:
 2078+ resource.pSobj.getEmbedHTML( resource, {
 2079+ 'id': _this.target_container + '_rsd_pv_vid',
 2080+ 'max_height': '220',
 2081+ 'only_poster': true
 2082+ } )
 2083+ )
 2084+ .append(
 2085+ $j('<br />')
 2086+ .css( 'clear', 'both' ),
 2087+ $j( '<span />' )
 2088+ .css( { 'font-weight' : 'bold' } )
 2089+ .text( gM( 'mwe-resource_page_desc' ) ),
 2090+ $j( '<div />' )
 2091+ .attr( 'id', 'rsd_import_desc' )
 2092+ .css( 'display', 'inline' )
 2093+ .loadingSpinner()
 2094+ )
 2095+
 2096+ var $importResourceTitle = $j( '<h3 />' )
 2097+ .css( {
 2098+ 'color' : 'red',
 2099+ 'padding' : '5px'
 2100+ } )
 2101+ .text(
 2102+ gM( 'mwe-resource-needs-import', [resource.title, _this.upload_api_name] )
 2103+ );
 2104+
 2105+ var $importTitle = $j( '<span />' )
 2106+ .css( { 'font-weight' : 'bold' } )
 2107+ .text( gM( 'mwe-local_resource_title' ) );
 2108+
 2109+ var $importDestFile = $j( '<input />' )
 2110+ .attr( {
 2111+ 'id' : 'wpDestFile',
 2112+ 'type' : 'text',
 2113+ 'size' : '30',
 2114+ } )
 2115+ .val ( resource.target_resource_title );
 2116+
 2117+ var $importUploadDescription = $j('<div />')
 2118+ .append(
 2119+ $j( '<span />' )
 2120+ .css( { 'font-weight' : 'bold' } )
 2121+ .text( gM( 'mwe-edit_resource_desc' ) ),
 2122+ $j( '<textarea />' )
 2123+ .attr( {
 2124+ 'id' : 'wpUploadDescription',
 2125+ 'rows' : 8,
 2126+ 'cols' : 50
 2127+ })
 2128+ .css( {
 2129+ 'width': '90%',
 2130+ } )
 2131+ .text( description ),
 2132+ $j( '<input />' )
 2133+ .attr( {
 2134+ 'type' : 'checkbox',
 2135+ 'id' : 'wpWatchthis',
 2136+ 'name' : 'wpWatchthis',
 2137+ 'tabindex' : '7'
 2138+ } )
 2139+ );
 2140+
 2141+ var $editImportContainer = $j( '<div />' )
 2142+ .css( {
 2143+ 'position' : 'absolute',
 2144+ 'left' : '50%',
 2145+ 'bottom' : '0px',
 2146+ 'top' : '30px',
 2147+ 'right' : '0px',
 2148+ 'overflow' : 'auto'
 2149+ })
 2150+ .append(
 2151+ $importTitle,
 2152+ $j( '<br />' ),
 2153+
 2154+ $importDestFile,
 2155+ $j( '<br />' ),
 2156+
 2157+ $importUploadDescription,
 2158+ $j( '<br />' ),
 2159+
 2160+ // Add the watchlist button
 2161+ $j( '<label />' )
 2162+ .attr( {
 2163+ 'for' : 'wpWatchthis'
 2164+ } )
 2165+ .text(
 2166+ gM( 'mwe-watch_this_page' )
 2167+ ),
 2168+ $j( '<br />' ),
 2169+
 2170+ // Add the update preview button:
 2171+ $j( '<br />' ),
 2172+ $j('<span />').append(
 2173+ $j.btnHtml( gM( 'mwe-update_preview' ), 'rsd_import_apreview', 'refresh' )
 2174+ )
 2175+ );
 2176+
 2177+ $rsdResourceImport.append(
 2178+ $importResourceTitle,
 2179+ $rsdPreviewContainer,
 2180+ $editImportContainer
 2181+ )
 2182+ return $rsdResourceImport;
 2183+ },
 2184+
 2185+ /**
 2186+ * Get Template Description wikitext
 2187+ * @pram {Object} resource Resource source for description
 2188+ */
 2189+ getTemplateDescription: function( resource ){
 2190+ // setup the resource description from resource description:
 2191+ // FIXME: i18n, namespace
 2192+ var description = '{{Information ' + "\n";
21182193
 2194+ if ( resource.desc ) {
 2195+ description += '|Description= ' + resource.desc + "\n";
 2196+ } else {
 2197+ description += '|Description= ' + gM( 'mwe-missing_desc_see_source', resource.link ) + "\n";
 2198+ }
 2199+
 2200+ // Output search specific info
 2201+ description += '|Source=' + resource.pSobj.getImportResourceDescWiki( resource ) + "\n";
 2202+
 2203+ if ( resource.author )
 2204+ description += '|Author=' + resource.author + "\n";
 2205+
 2206+ if ( resource.date )
 2207+ description += '|Date=' + resource.date + "\n";
 2208+
 2209+ // Add the Permission info:
 2210+ description += '|Permission=' + resource.pSobj.getPermissionWikiTag( resource ) + "\n";
 2211+
 2212+ if ( resource.other_versions )
 2213+ description += '|other_versions=' + resource.other_versions + "\n";
 2214+
 2215+ description += '}}';
 2216+
 2217+ // Get any extra categories or helpful links
 2218+ description += resource.pSobj.getExtraResourceDescWiki( resource );
 2219+ return description;
 2220+ },
 2221+
21192222 /**
21202223 * Sets up the proxy for the remote inserts
21212224 *
@@ -2226,8 +2329,8 @@
22272330 mw.closeLoaderDialog();
22282331 uploader.doHttpUpload( {
22292332 'url' : resource.src,
2230 - 'filename' : $j( '#rsd_filename' ).val(),
2231 - 'comment' : $j( '#rsd_import_text' ).val()
 2333+ 'filename' : $j( '#wpDestFile' ).val(),
 2334+ 'comment' : $j( '#wpUploadDescription' ).val()
22322335 } );
22332336 } );
22342337 }
@@ -2312,16 +2415,15 @@
23132416 .children( '.preview_close' )
23142417 .click( function() {
23152418 $j( '#rsd_preview_display' ).remove();
2316 - // restore title:
 2419+ // Restore title:
23172420 $j( _this.target_container ).dialog( 'option', 'title', origTitle );
2318 - // restore buttons (from the clipEdit object::)
 2421+ // Restore buttons (from the clipEdit object::)
23192422 _this.clipEdit.updateInsertControlActions();
23202423 } );
23212424
23222425 // Get the preview wikitext
23232426 var embed_code = _this.getEmbedCode( resource );
2324 - //var pos = $j( _this.target_textbox ).getCaretPosition();
2325 - var pos = 0;
 2427+ var pos = $j( _this.target_textbox ).textSelection( 'getCaretPosition' );
23262428 var editWikiText = $j( _this.target_textbox ).val();
23272429 var parseText = editWikiText.substr(0, pos) + embed_code + editWikiText.substr( pos );
23282430 _this.parse(
@@ -2350,7 +2452,7 @@
23512453 */
23522454 getEmbedCode: function( resource ) {
23532455 if ( this.import_url_mode == 'remote_link' ) {
2354 - return resource.pSobj.getEmbedHTML( resource, {'insert_description': true } );
 2456+ return resource.pSobj.getEmbedHTML( resource, { 'insert_description': true } );
23552457 } else {
23562458 return resource.pSobj.getEmbedWikiCode( resource );
23572459 }
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -40,7 +40,7 @@
4141 'skinName' : 'mvpcf',
4242
4343 // Default jquery ui skin name
44 - 'jui_skin' : 'redmond',
 44+ 'jQueryUISkin' : 'redmond',
4545
4646 /**
4747 * If jQuery / mwEmbed should be loaded.
@@ -2233,7 +2233,7 @@
22342234 if ( !window['$j'] ) {
22352235 window['$j'] = jQuery.noConflict();
22362236 }
2237 - mw.setConfig( 'jquery_skin_path', mw.getMwEmbedPath() + 'jquery/jquery.ui/themes/' + mw.getConfig( 'jui_skin' ) + '/' );
 2237+ mw.setConfig( 'jquery_skin_path', mw.getMwEmbedPath() + 'jquery/jquery.ui/themes/' + mw.getConfig( 'jQueryUISkin' ) + '/' );
22382238
22392239 // Only load jquery ui theme sheet if ui-widget does not exist.
22402240 if( ! mw.styleRuleExists( 'ui-widget' ) ){

Status & tagging log