Browse Source

Moves some important logic from toggle to show in popup, so it can be called programmatically

pull/13/head
Jack Lukic 11 years ago
parent
commit
a8914d32d7
1 changed files with 22 additions and 19 deletions
  1. 41
      src/modules/popup.js

41
src/modules/popup.js

@ -130,7 +130,7 @@ $.fn.popup = function(parameters) {
// generates popup html from metadata // generates popup html from metadata
create: function() { create: function() {
module.debug('Creating pop-up content');
module.debug('Creating pop-up html');
var var
html = $module.data(metadata.html) || settings.html, html = $module.data(metadata.html) || settings.html,
variation = $module.data(metadata.variation) || settings.variation, variation = $module.data(metadata.variation) || settings.variation,
@ -245,14 +245,9 @@ $.fn.popup = function(parameters) {
module.debug('Toggling pop-up'); module.debug('Toggling pop-up');
// refresh state of module // refresh state of module
module.refresh(); module.refresh();
if($popup.size() === 0) {
module.verbose('Creating pop-up html');
module.create();
}
if( !$module.hasClass(className.visible) ) { if( !$module.hasClass(className.visible) ) {
if( module.position() ) {
module.show();
}
module.hideAll();
module.show();
} }
else { else {
module.hide(); module.hide();
@ -387,13 +382,10 @@ $.fn.popup = function(parameters) {
show: function() { show: function() {
module.debug('Showing pop-up'); module.debug('Showing pop-up');
$(selector.popup)
.filter(':visible')
.stop()
.fadeOut(200)
.prev($module)
.removeClass(className.visible)
;
if($popup.size() === 0) {
module.create();
}
module.position();
$module $module
.addClass(className.visible) .addClass(className.visible)
; ;
@ -401,12 +393,14 @@ $.fn.popup = function(parameters) {
.removeClass(className.loading) .removeClass(className.loading)
; ;
if(settings.animation == 'pop' && $.fn.popIn !== undefined) { if(settings.animation == 'pop' && $.fn.popIn !== undefined) {
console.log($popup);
$popup $popup
.stop() .stop()
.popIn(settings.duration, settings.easing) .popIn(settings.duration, settings.easing)
; ;
} }
else { else {
console.log($popup);
$popup $popup
.stop() .stop()
.fadeIn(settings.duration, settings.easing) .fadeIn(settings.duration, settings.easing)
@ -421,6 +415,16 @@ $.fn.popup = function(parameters) {
$.proxy(settings.onShow, $popup)(); $.proxy(settings.onShow, $popup)();
}, },
hideAll: function() {
$(selector.popup)
.filter(':visible')
.stop()
.fadeOut(200)
.prev($module)
.removeClass(className.visible)
;
},
hide: function() { hide: function() {
$module $module
.removeClass(className.visible) .removeClass(className.visible)
@ -509,7 +513,6 @@ $.fn.popup = function(parameters) {
} }
}, },
error: function() { error: function() {
console.log($module.next());
module.error = Function.prototype.bind.call(console.warn, console, settings.moduleName + ':'); module.error = Function.prototype.bind.call(console.warn, console, settings.moduleName + ':');
}, },
performance: { performance: {
@ -616,9 +619,9 @@ $.fn.popup = function(parameters) {
$.fn.popup.settings = { $.fn.popup.settings = {
moduleName : 'Popup', moduleName : 'Popup',
debug : false,
verbose : false,
performance : false,
debug : true,
verbose : true,
performance : true,
namespace : 'popup', namespace : 'popup',
onInit : function(){}, onInit : function(){},

Loading…
Cancel
Save