Mwjames has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/63233


Change subject: srf.formats.gallery() fix class inheritance
......................................................................

srf.formats.gallery() fix class inheritance

* Allows proper Qunit testing
* Fix jsDuck docs+

Change-Id: I19857efd0a5f96a6d00e6aaf7f547e9f29d544f2
---
M Resources.php
M SemanticResultFormats.hooks.php
A formats/gallery/resources/ext.srf.formats.gallery.js
M formats/gallery/resources/ext.srf.gallery.carousel.css
M formats/gallery/resources/ext.srf.gallery.carousel.js
M formats/gallery/resources/ext.srf.gallery.overlay.css
M formats/gallery/resources/ext.srf.gallery.overlay.js
M formats/gallery/resources/ext.srf.gallery.redirect.css
M formats/gallery/resources/ext.srf.gallery.redirect.js
M formats/gallery/resources/ext.srf.gallery.slideshow.css
M formats/gallery/resources/ext.srf.gallery.slideshow.js
A tests/qunit/formats/ext.srf.formats.gallery.test.js
12 files changed, 457 insertions(+), 139 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticResultFormats 
refs/changes/33/63233/1

diff --git a/Resources.php b/Resources.php
index 0e779bf..af6fc50 100644
--- a/Resources.php
+++ b/Resources.php
@@ -583,12 +583,18 @@
                'scripts' => 'resources/jquery/jquery.responsiveslides.js',
        ),
 
+       // Gallery base class
+       'ext.srf.formats.gallery' => $formatModule + array(
+               'scripts' => 'gallery/resources/ext.srf.formats.gallery.js',
+               'dependencies' => 'ext.srf.util'
+       ),
+
        //
        'ext.srf.gallery.carousel' => $formatModule + array(
                'styles'  => 'gallery/resources/ext.srf.gallery.carousel.css',
                'scripts' => 'gallery/resources/ext.srf.gallery.carousel.js',
                'dependencies' => array(
-                       'ext.srf.util',
+                       'ext.srf.formats.gallery',
                        'ext.jquery.jcarousel'
                ),
                'position' => 'top',
@@ -599,7 +605,7 @@
                'scripts' => 'gallery/resources/ext.srf.gallery.slideshow.js',
                'styles'  => 'gallery/resources/ext.srf.gallery.slideshow.css',
                'dependencies' => array(
-                       'ext.srf.util',
+                       'ext.srf.formats.gallery',
                        'ext.jquery.responsiveslides'
                ),
                'messages' => array(
@@ -614,7 +620,7 @@
                'scripts' => 'gallery/resources/ext.srf.gallery.overlay.js',
                'styles'  => 'gallery/resources/ext.srf.gallery.overlay.css',
                'dependencies' => array(
-                       'ext.srf.util',
+                       'ext.srf.formats.gallery',
                        'ext.jquery.fancybox'
                ),
                'messages' => array(
@@ -628,7 +634,7 @@
        'ext.srf.gallery.redirect' => $formatModule + array(
                'scripts' => 'gallery/resources/ext.srf.gallery.redirect.js',
                'styles'  => 'gallery/resources/ext.srf.gallery.redirect.css',
-               'dependencies' => 'ext.srf.util',
+               'dependencies' => 'ext.srf.formats.gallery',
                'messages' => array(
                        'srf-gallery-image-url-error'
                ),
diff --git a/SemanticResultFormats.hooks.php b/SemanticResultFormats.hooks.php
index 0541d0e..cebbc2b 100644
--- a/SemanticResultFormats.hooks.php
+++ b/SemanticResultFormats.hooks.php
@@ -97,6 +97,7 @@
                                // Formats
                                
'tests/qunit/formats/ext.srf.formats.eventcalendar.tests.js',
                                
'tests/qunit/formats/ext.srf.formats.datatables.test.js',
+                               
'tests/qunit/formats/ext.srf.formats.gallery.test.js',
 
                                // Widgets
                                
'tests/qunit/widgets/ext.srf.widgets.eventcalendar.tests.js',
@@ -110,7 +111,11 @@
                                'ext.srf.util',
                                'ext.srf.eventcalendar',
                                'ext.srf.datatables',
-                               'ext.srf.widgets'
+                               'ext.srf.widgets',
+                               'ext.srf.gallery.overlay',
+                               'ext.srf.gallery.carousel',
+                               'ext.srf.gallery.slideshow',
+                               'ext.srf.gallery.redirect'
                        ),
                        'position' => 'top',
                        'localBasePath' => __DIR__,
diff --git a/formats/gallery/resources/ext.srf.formats.gallery.js 
b/formats/gallery/resources/ext.srf.formats.gallery.js
new file mode 100644
index 0000000..2fcfb28
--- /dev/null
+++ b/formats/gallery/resources/ext.srf.formats.gallery.js
@@ -0,0 +1,80 @@
+/**
+ * This file is part of the Semantic Result Formats Gallery module
+ * @see https://www.semantic-mediawiki.org/wiki/Help:Gallery_formats
+ *
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
+ *
+ * @file
+ * @ignore
+ *
+ * @since 1.9
+ * @ingroup SRF
+ *
+ * @licence GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * Base srf.formats.gallery class that reserves the namespace
+ *
+ * There is a method ImageGallery->add which allows to override the
+ * image url but this feature is only introduced in MW 1.20 therefore
+ * we have to catch the "real" image location url from the api to be able
+ * to display the image in the fancybox
+ *
+ * @ignore
+ */
+( function( $, mw, srf ) {
+       'use strict';
+
+       /**
+        * Inheritance class for the srf.formats constructor
+        *
+        * @since 1.9
+        *
+        * @class
+        * @abstract
+        */
+       srf.formats = srf.formats || {};
+
+       /**
+        * Base constructor for objects representing a gallery instance
+        *
+        * @since 1.9
+        *
+        * @class
+        * @constructor
+        * @extends srf.formats
+        */
+       srf.formats.gallery = function() {};
+
+       /**
+        * Public interface
+        *
+        * @ignore
+        */
+       srf.formats.gallery.prototype = {
+
+               /**
+                * Stores default values
+                *
+                * @property
+                * @type {Object}
+                */
+               defaults: {},
+       }
+
+} )( jQuery, mediaWiki, semanticFormats );
\ No newline at end of file
diff --git a/formats/gallery/resources/ext.srf.gallery.carousel.css 
b/formats/gallery/resources/ext.srf.gallery.carousel.css
index eeef0a8..26b06a6 100644
--- a/formats/gallery/resources/ext.srf.gallery.carousel.css
+++ b/formats/gallery/resources/ext.srf.gallery.carousel.css
@@ -1,11 +1,33 @@
 /**
- * CSS for SRF Gallery Carousel module
- * Adopted .jcarousel-skin-tango
+ * This file is part of the SRF gallery carousel module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * @licence: GNU GPL v2 or later
- * @author:  mwjames and others
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * @release: 0.1.3
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
+ *
+ * @file
+ *
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ *
+ * @ignore
  */
 .jcarousel-skin-smw {
        clear: both;
@@ -81,7 +103,8 @@
 }
 
 /**
- *  Horizontal Buttons
+ * Horizontal Buttons
+ * @ignore
  */
 .jcarousel-skin-smw .jcarousel-next-horizontal  {
        position: absolute;
@@ -182,7 +205,8 @@
 }
 
 /**
- *  Vertical Buttons
+ * Vertical Buttons
+ * @ignore
  */
 .jcarousel-skin-smw .jcarousel-next-vertical {
        position: absolute;
diff --git a/formats/gallery/resources/ext.srf.gallery.carousel.js 
b/formats/gallery/resources/ext.srf.gallery.carousel.js
index 922d742..fd03153 100644
--- a/formats/gallery/resources/ext.srf.gallery.carousel.js
+++ b/formats/gallery/resources/ext.srf.gallery.carousel.js
@@ -1,36 +1,51 @@
 /**
- * JavaScript for SRF Gallery jcarousel module
- * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery format
+ * This file is part of the SRF gallery carousel module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * @since 1.8
- * @release 0.3
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
  *
  * @file
- * @ingroup SemanticResultFormats
+ * @ignore
  *
- * @licence GNU GPL v2 or later
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
  * @author mwjames
+ */
+
+/**
+ * Extends base class with a carousel function
+ *
+ * @class srf.formats.gallery.carousel
  */
 ( function( $, mw, srf ) {
        'use strict';
 
-       /*global mediaWiki:true semanticFormats:true */
        /**
-        * Module for formats extensions
-        * @since 1.8
-        * @type Object
+        * @class srf.formats.gallery
+        * @mixins srf.formats.gallery.carousel
         */
-       srf.formats = srf.formats || {};
 
-       /**
-        * Base constructor for objects representing a gallery instance
-        * @since 1.8
-        * @type Object
-        */
-       srf.formats.gallery = function() {};
+       $.extend( srf.formats.gallery.prototype, {
 
-       srf.formats.gallery.prototype = {
                /**
+                * Provides the redirect functionality
                 *
                 * data-scroll Number of items to be scrolled
                 * data-visible Calculated and set visible elements
@@ -39,10 +54,14 @@
                 * data-rtl Directionality
                 *
                 * @since 1.8
-                * @type Object
+                *
+                * @param {string} context
+                *
+                * @return {Function}
                 */
                carousel: function( context ) {
                        return context.each( function() {
+                               var util = new srf.util();
                                var $this = $( this ),
                                        carousel = $this.find( '.jcarousel' );
 
@@ -60,19 +79,18 @@
                                        } );
                        } );
                }
-       };
+       } );
 
        /**
-        * Implementation representing a gallery instance
+        * Implementation of an carousel instance
         * @since 1.8
-        * @type Object
+        * @ignore
         */
-       var gallery = new srf.formats.gallery();
-       var util = new srf.util();
-
        $( document ).ready( function() {
                $( '.srf-gallery-carousel' ).each(function() {
+                       var gallery = new srf.formats.gallery();
                        gallery.carousel( $( this ) );
                } );
        } );
+
 } )( jQuery, mediaWiki, semanticFormats  );
\ No newline at end of file
diff --git a/formats/gallery/resources/ext.srf.gallery.overlay.css 
b/formats/gallery/resources/ext.srf.gallery.overlay.css
index 727b974..e7c7aa3 100644
--- a/formats/gallery/resources/ext.srf.gallery.overlay.css
+++ b/formats/gallery/resources/ext.srf.gallery.overlay.css
@@ -1,12 +1,33 @@
 /**
- * CSS for SRF gallery fancybox module
+ * This file is part of the SRF gallery overlay module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * @licence: GNU GPL v2 or later
- * @author:  mwjames
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * @since: 1.8
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * @release: 0.1
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
+ *
+ * @file
+ *
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ *
+ * @ignore
  */
 .srf-fancybox-title {
        text-align: left;
diff --git a/formats/gallery/resources/ext.srf.gallery.overlay.js 
b/formats/gallery/resources/ext.srf.gallery.overlay.js
index 83e9e2b..0bd0d4d 100644
--- a/formats/gallery/resources/ext.srf.gallery.overlay.js
+++ b/formats/gallery/resources/ext.srf.gallery.overlay.js
@@ -1,41 +1,68 @@
 /**
- * JavaScript for SRF gallery overlay/fancybox module
- * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery format
+ * This file is part of the SRF gallery overlay/fancybox module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * There is a method ImageGallery->add which allows to override the
- * image url but this feature is only introduced in MW 1.20 therefore
- * we have to catch the "real" image location url from the api to be able
- * to display the image in the fancybox
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * @since 1.8
- * @version 0.3
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
  *
  * @file
- * @ingroup SemanticResultFormats
+ * @ignore
  *
- * @licence GNU GPL v2 or later
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
  * @author mwjames
+ */
+
+/**
+ * Extends base class with an overlay function
+ *
+ * @class srf.formats.gallery.overlay
  */
 ( function( $, mw, srf ) {
        'use strict';
 
-       /*global mediaWiki:true semanticFormats:true */
        /**
-        * Module for formats extensions
-        * @since 1.8
-        * @type Object
+        * @class srf.formats.gallery
+        * @mixins srf.formats.gallery.overlay
         */
-       srf.formats = srf.formats || {};
 
-       /**
-        * Base constructor for objects representing a gallery instance
-        * @since 1.8
-        * @type Object
-        */
-       srf.formats.gallery = function() {};
+       $.extend( srf.formats.gallery.prototype, {
 
-       srf.formats.gallery.prototype = {
+               /**
+                * Provides the overlay functionality
+                *
+                * @since 1.8
+                *
+                * @param {string} context
+                * @param {string} ns
+                *
+                * @return {Function}
+                */
                overlay: function( context, ns ) {
+                       var self = this,
+                               util = new srf.util();
+
+                       // Override defaults
+                       self.defaults = {
+                               ns: ns,
+                               path: srf.settings.get( 'srfgScriptPath' )
+                       }
 
                        // Encode the namespace (NS_FILE) otherwise languages
                        // like Japanese, Chinese will fail
@@ -43,8 +70,7 @@
 
                        context.each( function() {
                                var $this = $( this ),
-                                       galleryID = $this.attr( 'id' ),
-                                       srfPath = mw.config.get( 'srf.options' 
).srfgScriptPath;
+                                       galleryID = $this.attr( 'id' );
 
                                // Loop over all relevant gallery items
                                $this.find( '.gallerybox' ).each( function () {
@@ -96,7 +122,7 @@
 
                                // Formatting the title
                                function formatTitle( title, currentArray, 
currentIndex /*,currentOpts*/ ) {
-                                       return '<div 
class="srf-fancybox-title"><span class="button"><a href="javascript:;" 
onclick="$.fancybox.close();"><img src=' +  srfPath + 
'/resources/jquery/fancybox/closelabel.gif' + '></a></span>' + (title && 
title.length ? '<b>' + title : '' ) + '<span class="count"> (' +  mw.msg( 
'srf-gallery-overlay-count', (currentIndex + 1) , currentArray.length ) + 
')</span></div>';
+                                       return '<div 
class="srf-fancybox-title"><span class="button"><a href="javascript:;" 
onclick="$.fancybox.close();"><img src=' +  self.defaults.path + 
'/resources/jquery/fancybox/closelabel.gif' + '></a></span>' + (title && 
title.length ? '<b>' + title : '' ) + '<span class="count"> (' +  mw.msg( 
'srf-gallery-overlay-count', (currentIndex + 1) , currentArray.length ) + 
')</span></div>';
                                }
 
                                // Display all images related to a group
@@ -105,18 +131,15 @@
                                        'titlePosition'   : 'inside',
                                        'titleFormat'     : formatTitle
                                } );
-               } );
+                       } );
                }
-       };
+       } );
 
        /**
-        * Implementation representing a slideshow instance
+        * Implementation of an overlay instance
         * @since 1.8
-        * @type Object
+        * @ignore
         */
-       var gallery = new srf.formats.gallery();
-       var util = new srf.util();
-
        $( document ).ready( function() {
                var ns = 'File';
 
@@ -126,7 +149,9 @@
                } );
 
                $( '.srf-overlay' ).each( function() {
+                       var gallery = new srf.formats.gallery();
                        gallery.overlay( $( this ), ns );
                } );
        } );
+
 } )( jQuery, mediaWiki, semanticFormats  );
\ No newline at end of file
diff --git a/formats/gallery/resources/ext.srf.gallery.redirect.css 
b/formats/gallery/resources/ext.srf.gallery.redirect.css
index dab3ddb..c5aa1ee 100644
--- a/formats/gallery/resources/ext.srf.gallery.redirect.css
+++ b/formats/gallery/resources/ext.srf.gallery.redirect.css
@@ -1,14 +1,34 @@
 /**
- * CSS for SRF gallery redirect module
+ * This file is part of the SRF gallery redirect module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * @licence: GNU GPL v2 or later
- * @author:  mwjames
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * @since: 1.8
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * @release: 0.1
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
+ *
+ * @file
+ *
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ *
+ * @ignore
  */
-
 .srf-redirect li {
        position: relative;
 }
diff --git a/formats/gallery/resources/ext.srf.gallery.redirect.js 
b/formats/gallery/resources/ext.srf.gallery.redirect.js
index 4adc60c..8de2d3c 100644
--- a/formats/gallery/resources/ext.srf.gallery.redirect.js
+++ b/formats/gallery/resources/ext.srf.gallery.redirect.js
@@ -1,40 +1,60 @@
 /**
- * JavaScript for SRF gallery overlay/fancybox module
- * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery format
+ * This file is part of the SRF gallery redirect module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * There is a method ImageGallery->add which allows to override the
- * image url but this feature is only introduced in MW 1.20 therefore
- * we have to catch the "real" image location url from the api
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * @since 1.8
- * @version 0.4
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
  *
  * @file
- * @ingroup SemanticResultFormats
+ * @ignore
  *
- * @licence GNU GPL v2 or later
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
  * @author mwjames
+ */
+
+/**
+ * Extends base class with a redirect function
+ *
+ * @class srf.formats.gallery.redirect
  */
 ( function( $, mw, srf ) {
        'use strict';
 
-       /*global mediaWiki:true semanticFormats:true */
        /**
-        * Module for formats extensions
-        * @since 1.8
-        * @type Object
+        * @class srf.formats.gallery
+        * @mixins srf.formats.gallery.redirect
         */
-       srf.formats = srf.formats || {};
 
-       /**
-        * Base constructor for objects representing a gallery instance
-        * @since 1.8
-        * @type Object
-        */
-       srf.formats.gallery = function() {};
+       $.extend( srf.formats.gallery.prototype, {
 
-       srf.formats.gallery.prototype = {
+               /**
+                * Provides the redirect functionality
+                *
+                * @since 1.8
+                *
+                * @param {string} context
+                *
+                * @return {Function}
+                */
                redirect: function( context ) {
+                       var util = new srf.util();
                        var type = context.data( 'redirect-type' );
                        return context.find( '.gallerybox' ).each( function() {
                                var $this = $( this ),
@@ -81,19 +101,18 @@
                                }
                } );
                }
-       };
+       } );
 
        /**
-        * Implementation and representation of the gallery instance
+        * Implementation of an redirect instance
         * @since 1.8
-        * @type Object
+        * @ignore
         */
-       var gallery = new srf.formats.gallery();
-       var util = new srf.util();
-
        $( document ).ready( function() {
                $( '.srf-redirect' ).each(function() {
+                       var gallery = new srf.formats.gallery();
                        gallery.redirect( $( this ) );
                } );
        } );
+
 } )( jQuery, mediaWiki, semanticFormats );
\ No newline at end of file
diff --git a/formats/gallery/resources/ext.srf.gallery.slideshow.css 
b/formats/gallery/resources/ext.srf.gallery.slideshow.css
index 370a8ee..6f87fa6 100644
--- a/formats/gallery/resources/ext.srf.gallery.slideshow.css
+++ b/formats/gallery/resources/ext.srf.gallery.slideshow.css
@@ -1,13 +1,34 @@
 /**
- * CSS for SRF gallery slides module
+ * This file is part of the SRF gallery slideshow module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * @licence: GNU GPL v2 or later
- * @author:  viljamis
- * @author:  mwjames
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
- * @since: 1.8
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * @release: 0.1
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
+ *
+ * @file
+ *
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
+ * @author mwjames
+ * @author viljamis
+ *
+ * @ignore
  */
 .srf-gallery-slideshow ul.gallery {
        padding: 0px 0px 0px 0px;
@@ -41,8 +62,10 @@
        float: left;
 }
 
-// pager
-
+/**
+ * Pager
+ * @ignore
+ */
 .srf-gallery-slideshow .rslides_tabs {
        padding: 0;
        margin: 1em 0;
diff --git a/formats/gallery/resources/ext.srf.gallery.slideshow.js 
b/formats/gallery/resources/ext.srf.gallery.slideshow.js
index 782f107..d5e871f 100644
--- a/formats/gallery/resources/ext.srf.gallery.slideshow.js
+++ b/formats/gallery/resources/ext.srf.gallery.slideshow.js
@@ -1,37 +1,61 @@
 /**
- * JavaScript for SRF gallery slides module
- * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery format
+ * This file is part of the SRF gallery slideshow module
+ * @see http://www.semantic-mediawiki.org/wiki/Help:Gallery_format
  *
- * @since 1.8
- * @release 0.2
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
  *
  * @file
- * @ingroup SemanticResultFormats
+ * @ignore
  *
- * @licence GNU GPL v2 or later
+ * @since 1.8
+ * @revision 0.4
+ *
+ * @ingroup SRF
+ *
+ * @license GNU GPL v2+
  * @author mwjames
+ */
+
+/**
+ * Extends base class with a slideshow function
+ *
+ * @class srf.formats.gallery.slideshow
  */
 ( function( $, mw, srf ) {
        'use strict';
 
-       /*global mediaWiki:true semanticFormats:true */
        /**
-        * Module for formats extensions
-        * @since 1.8
-        * @type Object
+        * @class srf.formats.gallery
+        * @mixins srf.formats.gallery.slideshow
         */
-       srf.formats = srf.formats || {};
 
-       /**
-        * Base constructor for objects representing a gallery instance
-        * @since 1.8
-        * @type Object
-        */
-       srf.formats.gallery = function() {};
+       $.extend( srf.formats.gallery.prototype, {
 
-       srf.formats.gallery.prototype = {
+               /**
+                * Provides the slideshow functionality
+                *
+                * @since 1.8
+                *
+                * @param {string} context
+                *
+                * @return {Function}
+                */
                slideshow: function( context ) {
                        return context.each( function() {
+                               var util = new srf.util();
                                var $this = $( this );
                                var maxHeight = 0;
                                var gallery   = $this.find( 'ul' );
@@ -75,19 +99,18 @@
                                }
                } );
                }
-       };
+       } );
 
        /**
-        * Implementation and representation of the gallery instance
+        * Implementation of an slideshow instance
         * @since 1.8
-        * @type Object
+        * @ignore
         */
-       var gallery = new srf.formats.gallery();
-       var util = new srf.util();
-
        $( document ).ready( function() {
                $( '.srf-gallery-slideshow' ).each(function() {
+                       var gallery = new srf.formats.gallery();
                        gallery.slideshow( $( this ) );
                } );
        } );
+
 } )( jQuery, mediaWiki, semanticFormats );
\ No newline at end of file
diff --git a/tests/qunit/formats/ext.srf.formats.gallery.test.js 
b/tests/qunit/formats/ext.srf.formats.gallery.test.js
new file mode 100644
index 0000000..088a405
--- /dev/null
+++ b/tests/qunit/formats/ext.srf.formats.gallery.test.js
@@ -0,0 +1,54 @@
+/**
+ * This file is part of the Semantic Result Formats QUnit Suite
+ * @see https://www.semantic-mediawiki.org/wiki/QUnit
+ *
+ * @section LICENSE
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA
+ *
+ * @file
+ *
+ * @since 1.9
+ * @ingroup SRF
+ *
+ * @licence GNU GPL v2+
+ * @author mwjames
+ */
+
+/**
+ * QUnit tests for the srf.formats.gallery class
+ *
+ */
+( function ( mw, srf ) {
+       'use strict';
+
+       QUnit.module( 'ext.srf.formats.gallery', QUnit.newMwEnvironment() );
+
+       /**
+        * Test initialization and accessibility
+        *
+        * @since: 1.9
+        */
+       QUnit.test( 'init', 5, function ( assert ) {
+               var gallery = new srf.formats.gallery();
+
+               assert.ok( gallery instanceof Object, 'gallery instance was 
accessible' );
+               assert.equal( $.type( gallery.redirect ), 'function', 
'.redirect() was accessible' );
+               assert.equal( $.type( gallery.overlay ), 'function', 
'.overlay() was accessible' );
+               assert.equal( $.type( gallery.slideshow ), 'function', 
'.slideshow() was accessible' );
+               assert.equal( $.type( gallery.carousel ), 'function', 
'.carousel() was accessible' );
+
+       } );
+
+}( mediaWiki, semanticFormats ) );
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/63233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19857efd0a5f96a6d00e6aaf7f547e9f29d544f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticResultFormats
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to