Replace data-dismiss=modal with action close. It's better to use our own ember code instead of relying on bootbox magic.

This commit is contained in:
Neil Lalonde 2013-11-01 12:13:09 -04:00
parent 6b31e4fda5
commit 0060050c08
8 changed files with 26 additions and 19 deletions

View File

@ -13,11 +13,13 @@ Discourse.AdminBanUserController = Discourse.ObjectController.extend(Discourse.M
ban: function() {
var duration = parseInt(this.get('duration'), 10);
if (duration > 0) {
var self = this;
this.send('hideModal');
this.get('model').ban(duration, this.get('reason')).then(function() {
window.location.reload();
}, function(e) {
var error = I18n.t('admin.user.ban_failed', { error: "http: " + e.status + " - " + e.body });
bootbox.alert(error);
bootbox.alert(error, function() { self.send('showModal'); });
});
}
}

View File

@ -10,6 +10,6 @@
</form>
</div>
<div class="modal-footer">
<button class='btn btn-danger' {{action ban}} data-dismiss="modal"><i class='icon icon-ban-circle'></i>{{i18n admin.user.ban}}</button>
<a data-dismiss="modal">{{i18n cancel}}</a>
<button class='btn btn-danger' {{action ban}}><i class='icon icon-ban-circle'></i>{{i18n admin.user.ban}}</button>
<a {{action closeModal}}>{{i18n cancel}}</a>
</div>

View File

@ -31,16 +31,18 @@ Discourse.EditTopicAutoCloseController = Discourse.ObjectController.extend(Disco
},
setAutoClose: function(days) {
var editTopicAutoCloseController = this;
var self = this;
this.send('hideModal');
Discourse.ajax({
url: '/t/' + this.get('id') + '/autoclose',
type: 'PUT',
dataType: 'html', // no custom errors, jquery 1.9 enforces json
data: { auto_close_days: days > 0 ? days : null }
}).then(function(){
editTopicAutoCloseController.set('details.auto_close_at', moment().add('days', days).format());
self.send('closeModal');
self.set('details.auto_close_at', moment().add('days', days).format());
}, function (error) {
bootbox.alert(I18n.t('generic_error'));
bootbox.alert(I18n.t('generic_error'), function() { self.send('showModal'); } );
});
}

View File

@ -46,6 +46,7 @@ Discourse.PreferencesRoute = Discourse.RestrictedUserRoute.extend({
'uploaded_avatar_template'
));
user.set('avatar_template', avatarSelector.get('avatarTemplate'));
avatarSelector.send('closeModal');
}
}
});

View File

@ -4,7 +4,7 @@
</form>
</div>
<div class="modal-footer">
<button class='btn btn-primary' {{action saveAutoClose}} data-dismiss="modal">{{i18n topic.auto_close_save}}</button>
<a data-dismiss="modal">{{i18n cancel}}</a>
<button class='btn pull-right' {{action removeAutoClose}} data-dismiss="modal">{{i18n topic.auto_close_remove}}</button>
<button class='btn btn-primary' {{action saveAutoClose}}>{{i18n topic.auto_close_save}}</button>
<a {{action closeModal}}>{{i18n cancel}}</a>
<button class='btn pull-right' {{action removeAutoClose}}>{{i18n topic.auto_close_remove}}</button>
</div>

View File

@ -29,6 +29,6 @@
</div>
<div class="modal-footer">
<button class="btn btn-primary" {{action saveAvatarSelection}} data-dismiss="modal" {{bindAttr disabled="view.saveDisabled"}}>{{i18n save}}</button>
<a data-dismiss="modal">{{i18n cancel}}</a>
<button class="btn btn-primary" {{action saveAvatarSelection}} {{bindAttr disabled="view.saveDisabled"}}>{{i18n save}}</button>
<a {{action closeModal}}>{{i18n cancel}}</a>
</div>

View File

@ -27,9 +27,9 @@
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" {{action upload target="view"}}>
<button class="btn btn-primary" {{action upload target="view"}}>
<span class='add-upload'><i {{bindAttr class="view.uploadIcon"}}></i><i class='icon-plus'></i></span>
{{i18n upload}}
</button>
<a data-dismiss="modal">{{i18n cancel}}</a>
<a {{action closeModal}}>{{i18n cancel}}</a>
</div>

View File

@ -42,12 +42,14 @@ Discourse.UploadSelectorView = Discourse.ModalBodyView.extend({
});
}.observes('controller.local'),
upload: function() {
if (this.get("controller.local")) {
$('#reply-control').fileupload('add', { fileInput: $('#filename-input') });
} else {
this.get('controller.composerView').addMarkdown($('#fileurl-input').val());
this.get('controller').send('closeModal');
actions: {
upload: function() {
if (this.get("controller.local")) {
$('#reply-control').fileupload('add', { fileInput: $('#filename-input') });
} else {
this.get('controller.composerView').addMarkdown($('#fileurl-input').val());
this.get('controller').send('closeModal');
}
}
}