From 46ca44927a6416d8cf72dea43e17910014c2d768 Mon Sep 17 00:00:00 2001 From: Michael Dale Date: Tue, 24 Nov 2009 20:32:54 +0000 Subject: [PATCH] * some code comment cleanup --- js2/mwEmbed/libAddMedia/dragDropFile.js | 10 +- js2/mwEmbed/libAddMedia/mvAdvFirefogg.js | 2 - .../searchLibs/baseRemoteSearch.js | 2 +- .../libAddMedia/searchLibs/flickrSearch.js | 106 ++++++++++-------- js2/mwEmbed/libEmbedVideo/omtkEmbed.js | 2 +- 5 files changed, 69 insertions(+), 53 deletions(-) diff --git a/js2/mwEmbed/libAddMedia/dragDropFile.js b/js2/mwEmbed/libAddMedia/dragDropFile.js index dad7b042d7..85201a6b24 100644 --- a/js2/mwEmbed/libAddMedia/dragDropFile.js +++ b/js2/mwEmbed/libAddMedia/dragDropFile.js @@ -1,4 +1,6 @@ /* firefox 3.6 drag-drop uploading +* +* Note: this file is still under development */ loadGM( { "mwe-upload-multi" : "Upload {{PLURAL:$1|file|files}}", @@ -50,11 +52,11 @@ loadGM( { ); - var cBtn = { }; - cBtn[ gM( 'mwe-cancel' ) ] = function() { + var buttons = { }; + buttons[ gM( 'mwe-cancel' ) ] = function() { $j( this ).dialog( 'close' ); } - cBtn[ gM( 'mwe-upload-multi', fileCount ) ] = function() { + buttons[ gM( 'mwe-upload-multi', fileCount ) ] = function() { alert( 'do multiple file upload' ); } // open up the dialog @@ -64,7 +66,7 @@ loadGM( { modal: true, draggable:false, resizable:false, - buttons:cBtn + buttons : buttons } ); $j( '#multiple_file_input' ).dialogFitWindow(); $j( window ).resize( function() { diff --git a/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js b/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js index b132954061..f1f88ba70c 100644 --- a/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js +++ b/js2/mwEmbed/libAddMedia/mvAdvFirefogg.js @@ -2,8 +2,6 @@ * Advanced Firefogg support. Lets you control many aspects of video encoding. */ -//@@todo put all msg text into loadGM json - loadGM({ "fogg-help-sticky" : "Help (click to stick)", "fogg-cg-preset" : "Preset: $1<\/strong>", diff --git a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js index a81720a288..66bc7b4acd 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js @@ -272,7 +272,7 @@ baseRemoteSearch.prototype = { 'url' : rObj.poster } ); }, - /* + /** * Gets the inline wikiText description of the resource Object */ getInlineDescWiki:function( rObj ) { diff --git a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js index 3969e32b83..f022f04877 100644 --- a/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js +++ b/js2/mwEmbed/libAddMedia/searchLibs/flickrSearch.js @@ -1,10 +1,7 @@ /* - * basic flickr search uses flickr jsonp api + * Basic flickr search uses flickr jsonp api * http://www.flickr.com/services/api/ * - * uses the "example api_key" 519b66e3fd8d8080e27a64fe51101e2c - * should update with a different "public" key sometime soon - * http://www.flickr.com/services/rest/?method=flickr.test.echo&format=json&api_key=519b66e3fd8d8080e27a64fe51101e2c * * we look for licenses from method=flickr.photos.licenses.getInfo * per http://commons.wikimedia.org/wiki/Special:Upload?uselang=fromflickr @@ -22,7 +19,7 @@ flickrSearch.prototype = { dtUrl : 'http://www.flickr.com/photos/', // @@todo probably would be good to read the api-key from configuration apikey : '2867787a545cc66c0bce6f2e57aca1d1', - // what licence we are interested in + // What licence we are interested in _licence_keys: '4,5,7,8', _srctypes: ['t', 'sq', 's', 'm', 'o'], licenceMap: { @@ -31,9 +28,11 @@ flickrSearch.prototype = { '7' : 'http://www.flickr.com/commons/usage/', '8' : 'http://www.usa.gov/copyright.shtml' }, - init:function( iObj ) { - // init base class and inherit: - var baseSearch = new baseRemoteSearch( iObj ); + /** + * Initialize the flickr Search with provided options + */ + init:function( options ) { + var baseSearch = new baseRemoteSearch( options ); for ( var i in baseSearch ) { if ( typeof this[i] == 'undefined' ) { this[i] = baseSearch[i]; @@ -41,8 +40,10 @@ flickrSearch.prototype = { this['parent_' + i] = baseSearch[i]; } } - // inherit the cp settings for }, + /** + * Gets the Search results setting _loading flag to false once results have been added + */ getSearchResults:function() { var _this = this; js_log( "flickr::getSearchResults" ); @@ -68,6 +69,9 @@ flickrSearch.prototype = { _this.loading = false; } ); }, + /** + * Adds Results for a given data response from api query + */ addResults:function( data ) { var _this = this; if ( data.photos && data.photos.photo ) { @@ -77,43 +81,51 @@ flickrSearch.prototype = { this.more_results = true; } for ( var resource_id in data.photos.photo ) { - var resource = data.photos.photo[resource_id]; - - var rObj = { - 'titleKey' : resource.title + '.jpg', - 'resourceKey': resource.id, - 'link' : _this.dtUrl + resource.pathalias + '/' + resource.id, - 'title' : resource.title, - 'thumbwidth' : resource.width_t, - 'thumbheight': resource.height_t, - 'desc' : resource.title, - // set the license: (rsd is a pointer to the parent remoteSearchDriver ) - 'license' : this.rsd.getLicenceFromUrl( _this.licenceMap[ resource.license ] ), - 'pSobj' : _this, - // assume image/jpeg for "photos" - 'mime' : 'image/jpeg' - }; - // set all the provided srcs: - rObj['srcSet'] = { }; - for ( var i in _this._srctypes ) { - var st = _this._srctypes[i]; - // if resource has a url add it to the srcSet: - if ( resource['url_' + st] ) { - rObj['srcSet'][st] = { - 'h': resource['height_' + st], - 'w': resource['width_' + st], - 'src': resource['url_' + st] - } - // set src to the largest - rObj['src'] = resource['url_' + st]; - } - } - + var sourceResource = data.photos.photo[ resource_id ]; + var rObj = _this.getResourceObjet( sourceResource ); _this.resultsObj[ resource_id ] = rObj; } } }, - // return image transform via callback + /** + * Gets an individual resource object from a given source Resource + */ + getResourceObjet: function( resource ){ + var _this = this; + var rObj = { + 'titleKey' : resource.title + '.jpg', + 'resourceKey': resource.id, + 'link' : _this.dtUrl + resource.pathalias + '/' + resource.id, + 'title' : resource.title, + 'thumbwidth' : resource.width_t, + 'thumbheight': resource.height_t, + 'desc' : resource.title, + // Set the license + 'license' : this.rsd.getLicenceFromUrl( _this.licenceMap[ resource.license ] ), + 'pSobj' : _this, + // Assume image/jpeg for flickr response + 'mime' : 'image/jpeg' + }; + // Add all the provided src types that are avaliable + rObj['srcSet'] = { }; + for ( var i in _this._srctypes ) { + var st = _this._srctypes[i]; + // if resource has a url add it to the srcSet: + if ( resource['url_' + st] ) { + rObj['srcSet'][st] = { + 'h': resource['height_' + st], + 'w': resource['width_' + st], + 'src': resource['url_' + st] + } + // Set src to the largest + rObj['src'] = resource['url_' + st]; + } + } + return rObj; + }, + /** + * return image transform via callback + */ getImageObj:function( rObj, size, callback ) { if ( size.width ) { var skey = this.getSrcTypeKey( rObj, size.width ) @@ -124,10 +136,14 @@ flickrSearch.prototype = { } ); } }, - getImageTransform:function( rObj, opt ) { - if ( opt.width ) { - return rObj.srcSet[ this.getSrcTypeKey( rObj, opt.width ) ].src; + /** + * Gets an image transformation based a SrcTypeKey gennerated by the requested options + */ + getImageTransform:function( rObj, options ) { + if ( options.width ) { + return rObj.srcSet[ this.getSrcTypeKey( rObj, options.width ) ].src; } + return rObj.srcSet[ _srctypes[_srctypes.length-1] ]; }, getSrcTypeKey:function( rObj, width ) { if ( width <= 75 ) { diff --git a/js2/mwEmbed/libEmbedVideo/omtkEmbed.js b/js2/mwEmbed/libEmbedVideo/omtkEmbed.js index 2a978294e5..0dae32d70d 100644 --- a/js2/mwEmbed/libEmbedVideo/omtkEmbed.js +++ b/js2/mwEmbed/libEmbedVideo/omtkEmbed.js @@ -6,7 +6,7 @@ var omtkEmbed = { }, getEmbedHTML : function () { var embed_code = this.getEmbedObj(); - // need omtk to fire an onReady event. + // Need omtk to fire an onReady event. setTimeout( '$j(\'#' + this.id + '\').get(0).postEmbedJS()', 2000 ); return this.wrapEmebedContainer( embed_code ); }, -- 2.20.1