Dataform Applications

Jump to: navigation, search

Note: You are currently viewing documentation for Moodle 2.6. Up-to-date documentation for the latest stable version of Moodle may be available here: Dataform Applications.

Journal

TBC

Poll

TBC

Photo Gallery

Dataform-based photo galleries are very easy to create by including available javascript libraries and short javascript snippets for applying gallery effects to designated views in the Dataform activity. Such Dataform galleries could be used either as resources for disseminating designated content or graded activities. They could serve as a platform for collaboration and sharing users contributions.

Fancybox gallery

With a Picture field called Image (if you prefer another name you need to change the tags in the view html accordingly) create a Grid view named Gallery (if you prefer another name etc.) with the following html in the Repeated entry template:

<xdiv class="entry">
<xdiv style="text-align: center; width: 100px; height: 100px;" class="imageTn">||Image||</xdiv>
<xdiv class="imageHref"><xspan class="hide">||Image:url||</xspan></xdiv>
</xdiv>

(remove x from html tag names)

Now all that remains is to add the Fancybox related javascript and css in the respective tabs.

The Fancybox is a library that you can download from http://fancybox.net/. The download zip contains a folder titled fancybox which files that you need to extract and store somewhere accessible. One approach is to create a folder recourse on your site and add the fancybox files there.

Then you need to add the following javascript in the javascript tab. Note the reference to jquery from googleapis. You can have a local copy and reference it instead.

Included external js:


And js code:

YUI().use('node', function (Y) {
 
   if (Y.one('.dataformview-Gallery')) {
        var thisView = Y.one('.dataformview-Gallery');
 
        // Link the thumbnails
        var entries = thisView.all('.entry');
        entries.each(function(ent){
            var imgHolder = ent.one('.imageTn');
            var imgTn = imgHolder.one('img');
            var imgHref = ent.one('.imageHref span').get('innerHTML');
            var link = Y.Node.create('<a class="myGallery" rel="gallery" href="'+imgHref+'"></a>');
            link.appendChild(imgTn);
            imgHolder.appendChild(link);
        });
 
    $(document).ready(function() {
        $("a.myGallery").fancybox({
            'transitionIn'    :    'elastic',
            'transitionOut'    :    'elastic',
            'speedIn'        :    600,
            'speedOut'        :    200,
             'overlayShow'    :    true,
            'opacity'    :    true,
            'cyclic'    :    true
        });
    });
    }
 
});

Then add reference to the fancybox css in the css tab.

Included external css:

TCycle

A minimalist jQuery slideshow using the tcycle plugin by malsup (http://jquery.malsup.com/cycle2/tcycle/).

Cycle

TBC