app/assets/javascripts/vex.js in vex_rails-0.1.0 vs app/assets/javascripts/vex.js in vex_rails-0.1.1
- old
+ new
@@ -20,11 +20,12 @@
baseClassNames: {
vex: 'vex',
content: 'vex-content',
overlay: 'vex-overlay',
close: 'vex-close',
- closing: 'vex-closing'
+ closing: 'vex-closing',
+ open: 'vex-open'
},
defaultOptions: {
content: '',
showCloseButton: true,
escapeButtonCloses: true,
@@ -69,10 +70,11 @@
return vex.close($(this).data().vex.id);
});
options.$vexContent.append(options.$closeButton);
}
$(options.appendLocation).append(options.$vex);
+ vex.setupBodyClassName(options.$vex);
if (options.afterOpen) {
options.afterOpen(options.$vexContent, options);
}
setTimeout((function() {
return options.$vexContent.trigger('vexOpen', options);
@@ -154,9 +156,18 @@
$lastVex = vex.getVexByID(id);
if ($lastVex.data().vex.escapeButtonCloses !== true) {
return false;
}
return vex.closeByID(id);
+ },
+ setupBodyClassName: function($vex) {
+ return $vex.bind('vexOpen.vex', function() {
+ return $('body').addClass(vex.baseClassNames.open);
+ }).bind('vexClose.vex', function() {
+ if (!vex.getAllVexes().length) {
+ return $('body').removeClass(vex.baseClassNames.open);
+ }
+ });
},
hideLoading: function() {
return $('.vex-loading-spinner').remove();
},
showLoading: function() {