Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Commit

Permalink
close #2: Option "cssclass" is present on subsequent modals
Browse files Browse the repository at this point in the history
  • Loading branch information
terebentina committed Jun 27, 2013
1 parent ec0d501 commit b2e291b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/sco.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@

,close: function() {
this.$modal.hide().off('.' + pluginName).find('.inner').html('');
if (this.options.cssclass !== undefined) {
this.$modal.removeClass(this.options.cssclass);
}
$(document).off('keyup.' + pluginName);
$('.modal-backdrop').remove();
if (typeof this.options.onClose === 'function') {
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/sco.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,27 @@ $(function () {
$modal.destroy();
});

test('cssclass should be removed between different modals using the same modal block', function() {
var $modal = $.scojs_modal({
content: 'abcd'
,cssclass: 'test'
,appendTo: '#qunit-fixture'
}).show();
ok($('#qunit-fixture #modal').hasClass('test'), 'class exists');
$('#qunit-fixture #modal .close').trigger('click');
ok(!$('#qunit-fixture #modal').hasClass('test'), 'class doesn\'t exists after close');
var $modal = $.scojs_modal({
content: 'abcd'
,cssclass: 'foo'
,appendTo: '#qunit-fixture'
}).show();
ok(!$('#qunit-fixture #modal').hasClass('test'), 'old class doesn\'t exists in the new modal');
ok($('#qunit-fixture #modal').hasClass('foo'), 'new class exists');
$('#qunit-fixture #modal .close').trigger('click');
ok(!$('#qunit-fixture #modal').hasClass('foo'), 'class doesn\'t exists after close');
$modal.destroy();
});


module('modal data-api');

Expand Down

0 comments on commit b2e291b

Please sign in to comment.