Skip to content

Commit

Permalink
State management beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
nenomaz committed Dec 11, 2016
1 parent 95be85c commit 7c04513
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions jquery.easy-overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ along with jQuery Easy Overlay. If not, see <http://www.gnu.org/licenses/>.
*/
(function( $ ){
$.fn.easyOverlay = function(action, options) {

var defaults = {
zindex: "99999",
spin: true,
delay: 400,
};

var _options = $.extend(true, defaults, $.fn.easyOverlay.options || {}, options || {});

var STATE_VISIBLE = 1;
var STATE_HIDDEN = 0;

var overlayZIndex;
$.fn.easyOverlay.indexCounter++;

function init(target) {
var easyOverlayIndex = $.fn.easyOverlay.indexCounter;
if(target.length <= 0) return;
if(target.length <= 0 || target.data('easyOverlayState') == STATE_VISIBLE) return;

// Calculating OVERLAY DIV z-index
overlayZIndex;
Expand Down Expand Up @@ -102,13 +105,15 @@ along with jQuery Easy Overlay. If not, see <http://www.gnu.org/licenses/>.

// Show OVERLAY DIV
$("#jqueryEasyOverlayDiv"+easyOverlayIndex).fadeIn(_options.delay);
target.data('easyOverlayState', STATE_VISIBLE);
}

function stop(target) {
var easyOverlayIndex = target.data('easyOverlayIndex');
if( $("#jqueryEasyOverlayDiv"+easyOverlayIndex).length ) {
$("#jqueryEasyOverlayDiv"+easyOverlayIndex).fadeOut(_options.delay, function(){this.remove()});
}
target.data('easyOverlayState', STATE_HIDDEN);
}

switch (action) {
Expand Down

0 comments on commit 7c04513

Please sign in to comment.