Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 0845e79

Browse files
committed
allowing visibility of close button to be configurable on the base modal post initialization
1 parent 52c3930 commit 0845e79

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

js/templates/baseModal.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<div class="js-modal-inner-wrap <%= ob.innerWrapperClass %>">
2-
<% if (ob.includeCloseButton) { %>
3-
<div class="js-modal-close <%= ob.closeButtonClass %>">
4-
<h2 class="ion-android-close clickable"></h2>
5-
</div>
6-
<% } %>
2+
<div class="js-modal-close <%= ob.closeButtonClass %> <% !ob.showCloseButton && print('hide') %>">
3+
<h2 class="ion-android-close clickable"></h2>
4+
</div>
75
<%= ob.innerContent %>
86
</div>

js/views/baseModal.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.exports = baseVw.extend({
1313

1414
defaults = {
1515
dismissOnOverlayClick: false,
16-
includeCloseButton: false,
16+
showCloseButton: false,
1717
closeButtonClass: 'btn-corner btn-cornerTR',
1818
innerWrapperClass: 'modal-child modal-childMain custCol-primary'
1919
};
@@ -22,14 +22,8 @@ module.exports = baseVw.extend({
2222
this.className = 'modal modal-opaque ' + __.result(this, 'className', '');
2323
this._open = false;
2424

25-
if (this.__options.dismissOnOverlayClick) {
26-
events['click'] = '__modalClick';
27-
}
28-
29-
if (this.__options.includeCloseButton) {
30-
events['click .js-modal-close'] = '__closeClick';
31-
}
32-
25+
events['click'] = '__modalClick';
26+
events['click .js-modal-close'] = '__closeClick';
3327
this.events = __.extend({}, events, this.events || {});
3428

3529
baseVw.prototype.constructor.apply(this, arguments);
@@ -73,6 +67,18 @@ module.exports = baseVw.extend({
7367
return this;
7468
},
7569

70+
setModalOptions: function(options) {
71+
if (!options) return;
72+
73+
__.extend(this.__options, options);
74+
75+
if (typeof options.showCloseButton !== 'undefined') {
76+
this.$modalClose[options.showCloseButton ? 'removeClass' : 'addClass']('hide');
77+
}
78+
79+
// TODO: allow other options to be modifiable via this method.
80+
},
81+
7682
remove: function() {
7783
this.close();
7884
baseVw.prototype.remove.apply(this, arguments);
@@ -89,6 +95,8 @@ module.exports = baseVw.extend({
8995
);
9096
});
9197

98+
this.$modalClose = this.$('.js-modal-close');
99+
92100
return this;
93101
}
94102
});

js/views/serverConnectModal.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ module.exports = BaseModal.extend({
2020
'click .js-msg-bar-close': 'hideMessageBar'
2121
},
2222

23+
// constructor: function (options) {
24+
// BaseModal.prototype.constructor.call(this,
25+
// __.extend({
26+
// showCloseButton: true
27+
// }, options));
28+
// },
29+
2330
initialize: function(options) {
2431
this.options = options || {};
2532

@@ -166,6 +173,7 @@ module.exports = BaseModal.extend({
166173
});
167174

168175
this.hideMessageBar();
176+
this.setModalOptions({ showCloseButton: true });
169177

170178
return this;
171179
},
@@ -224,6 +232,8 @@ module.exports = BaseModal.extend({
224232
}
225233
});
226234

235+
this.setModalOptions({ showCloseButton: false });
236+
227237
this.connectAttempt = this.attemptConnection().done(() => {
228238
console.log('great success');
229239

0 commit comments

Comments
 (0)