Last active
March 7, 2017 19:22
-
-
Save YurePereira/a32aec53d44331db900a4e4a140c637a to your computer and use it in GitHub Desktop.
Loading process image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var j = jQuery.noConflict(); | |
| var loadingImage = (function ($) { | |
| var loadImage = $('body img.load-image'); | |
| var configDefault = { | |
| callbacks: { | |
| show: function() {}, | |
| hide: function() {} | |
| } | |
| }; | |
| var init = function(config) { | |
| if (typeof config['callbacks']['show'] !== 'undefined') { | |
| configDefault.callbacks.show = function() { | |
| config['callbacks']['show'].apply(null, []); | |
| }; | |
| } | |
| if (typeof config['callbacks']['hide'] !== 'undefined') { | |
| configDefault.callbacks.hide = function() { | |
| config['callbacks']['hide'].apply(null, []); | |
| }; | |
| } | |
| }; | |
| var reloadSelector = function () { | |
| loadImage = $('body img.load-image'); | |
| }; | |
| return { | |
| show: function(config) { | |
| init(config); | |
| configDefault.callbacks.show(); | |
| reloadSelector(); | |
| if (loadImage.length > 0) { | |
| loadImage.show(); | |
| } else { | |
| $('<img>', { | |
| class: 'load-image', | |
| src: '/img/slices/ajax-loader.gif' | |
| }).css({ | |
| width: '54px', | |
| height: '54px', | |
| position: 'fixed', | |
| left: '50%', | |
| top: '50%', | |
| 'margin-top': '-27px', | |
| 'margin-left': '-27px', | |
| 'z-index': 9999, | |
| }).appendTo('body'); | |
| } | |
| }, | |
| hide: function() { | |
| configDefault.callbacks.hide(); | |
| reloadSelector(); | |
| if (loadImage.length > 0) { | |
| loadImage.hide(); | |
| } | |
| } | |
| }; | |
| })(j); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment