Sha256: 3e6aa78bd034e82b3afcd262748b5a481d171ab61c916330bde4ef615b46dfe5
Contents?: true
Size: 1.36 KB
Versions: 39
Compression:
Stored size: 1.36 KB
Contents
!(function(global) { 'use strict'; var Downloader = L.Class.extend({ options: { spinner: $('<i class="fa fa-spinner fa-spin fa-2x fa-align-center"></i>') }, initialize: function(el, options) { L.Util.setOptions(this, options); this.$el = $(el); this.configureHandler(); }, configureHandler: function() { this.$el.on('click', L.Util.bind(this.download, this)); }, download: function(ev) { var url = this.$el.data('downloadPath'); ev.preventDefault(); this.$el.closest('.btn-group').append(this.options.spinner); $.getJSON(url) .done(L.Util.bind(this.complete, this)) .fail(L.Util.bind(this.error, this)); }, complete: function(data) { this.renderMessage(data); this.options.spinner.hide(); }, error: function(data) { this.options.spinner.hide(); }, renderMessage: function(message) { $.each(message, function(idx, msg) { var flash = '<div class="alert alert-' + msg[0] + '"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + msg[1] + '</div>'; $('div.flash_messages').append(flash); }); } }); global.GeoBlacklight.Downloader = Downloader; global.GeoBlacklight.downloader = function(el, options) { return new Downloader(el, options); }; })(this);
Version data entries
39 entries across 39 versions & 1 rubygems