Medyada BBSK

” }, apiUrl = ‘https://api.flickr.com/services/rest/’, photos = []; // The actual plugin constructor function Plugin(element, options) { this.element = jQuery(element); this.settings = jQuery.extend({}, defaults, options); this._defaults = defaults; this._name = pluginName; this._hideSpinner = function () { this.element.find(‘.spinner-wrapper’).hide().find(‘*’).hide(); }; this._printError = function () { this.element.find(‘.gallery-container’).append(jQuery(“
“, {“class”: “col-lg-12 col-lg-offset-1”}) .append(jQuery(“
“, {“class”: “error-wrapper”}) .append(jQuery(““, {“class”: “label label-danger error”}) .html(this.settings.errorText)))); }; this._flickrAnimate = function () { this.element.find(‘.gallery-container img’).each(jQuery.proxy(function (index, el) { var image = el; setTimeout(function () { jQuery(image).parent().fadeIn(); }, this.settings.loadingSpeed * index); }, this)); }; this._printGallery = function (photos) { var element = this.element.find(‘.gallery-container’); jQuery.each(photos, function (key, photo) { var flick_str = photo.title; var flick_title = flick_str.substr(0, 15); var img = jQuery(‘‘, { ‘class’: ‘thumb img-thumbnail gall-img-responsive’, src: photo.href, }); element.append(jQuery(‘
‘, {‘class’: ‘grid col-md-3’}) .append(jQuery(‘‘, { ‘class’: ‘grid-item’, title: photo.title, href: photo.href, ‘data-gallery’: ” }).hide().append(jQuery(‘ ‘)) .append(img)).append(jQuery(‘‘ + flick_title + ‘‘))); }); element.imagesLoaded() .done(jQuery.proxy(this._flickrAnimate, this)) .always(jQuery.proxy(this._hideSpinner, this)); }; this._flickrPhotoset = function (photoset) { var _this = this; var hidemeval = “”; photos[photoset.id] = []; jQuery.each(photoset.photo, function (key, photo) { if (key > 39) { hidemeval = “hidepics”; } // Limit number of photos. if (key >= _this.settings.photosLimit) { return false; } photos[photoset.id][key] = { thumbnail: ‘https://farm’ + photo.farm + ‘.static.flickr.com/’ + photo.server + ‘/’ + photo.id + ‘_’ + photo.secret + ‘_q.jpg’, href: ‘https://farm’ + photo.farm + ‘.static.flickr.com/’ + photo.server + ‘/’ + photo.id + ‘_’ + photo.secret + ‘_b.jpg’, title: photo.title, hideme: hidemeval }; }); this._printGallery(photos[photoset.id]); }; this._onFlickrResponse = function (response) { if (response.stat === “ok”) { this._flickrPhotoset(response.photoset); } else { this._hideSpinner(); this._printError(); } }; this._flickrRequest = function (method, data) { var url = apiUrl + “?format=json&jsoncallback=?&method=” + method + “&api_key=” + this.settings.apiKey; jQuery.each(data, function (key, value) { url += “&” + key + “=” + value; }); jQuery.ajax({ dataType: “json”, url: url, context: this, success: this._onFlickrResponse }); }; this._flickrInit = function () { this._flickrRequest(‘flickr.photosets.getPhotos’, { photoset_id: this.settings.photosetId }); }; // Init this.init(); } Plugin.prototype = { init: function () { this._flickrInit(); } }; // Wrapper jQuery.fn[pluginName] = function (options) { this.each(function () { if (!jQuery.data(this, “plugin_” + pluginName)) { jQuery.data(this, “plugin_” + pluginName, new Plugin(this, options)); } }); // Chain return this; }; })(jQuery, window, document);
Photo Gallery For Flickr Powered By: Weblizar

Pin It on Pinterest