/*! * jquery.sumogallery - v1.0.0 * http://hemantnegi.github.io/jquery.sumogallery * created : 2015-01-21 * * Copyright 2014 Hemant Negi * Email : hemant.frnz@gmail.com * Compressor http://refresh-sf.com/yui/ */ (function ($) { 'namespace sg'; sgallery = { settings: { sattr: 'data-sgallery', // attrribute on image to be looked by plugin. by which we can set group name. showImgCount: true, //display image counts on bottom right showThumbs: false }, //bind all generic events here. bindEvents: function () { var O = this; var S = O.settings; //add click to all the images having attribute data-sgallery $('img[' + S.sattr + ']').on('click.sg', function () { O.SG.reset(); var _d = O.prepareData($(this)); O.prepareHTML(_d); }); }, //accepts current clicked element. //returns a json object prepareData: function (c_img) { var O = this; var S = O.settings; gname = c_img.attr(S.sattr); var imgs = []; $('img[data-sgallery="' + gname + '"]').each(function (i, e) { e = $(e); var d = {}; d['thumb'] = e.data('thumb') || false; d['full'] = e.data('full') || false; d['title'] = e.attr('title') || ''; d['alt'] = e.attr('alt') || ''; if (d['thumb'] && d['full']) imgs.push(d); // exclude if thumb or full is not set. else return; //collect the index of selected item. if (e.is(c_img)) O.SG.sindex = i; }); return imgs; }, //prepares all the required markup for the gallery. prepareHTML: function (imgs) { var O = this; O.SG.imgs = imgs; //dont do any thing if no proper data available. if (imgs.length == 0) { console.log('no images with appropriate data!!'); return; } $('.SumoGallery').remove(); O.SG._SG = $('