2015-05-16 22:56:19 -04:00
|
|
|
import showModal from 'discourse/lib/show-modal';
|
|
|
|
|
2014-07-22 23:20:45 -04:00
|
|
|
export default Ember.ArrayController.extend({
|
2013-02-22 15:41:12 -05:00
|
|
|
|
2015-07-24 11:19:53 -04:00
|
|
|
undoPreviewUrl: function() {
|
|
|
|
return Discourse.getURL("/?preview-style=");
|
|
|
|
}.property(),
|
|
|
|
|
|
|
|
defaultStyleUrl: function() {
|
|
|
|
return Discourse.getURL("/?preview-style=default");
|
|
|
|
}.property(),
|
|
|
|
|
2013-11-12 12:13:17 -05:00
|
|
|
actions: {
|
|
|
|
|
|
|
|
/**
|
|
|
|
Create a new customization style
|
|
|
|
|
|
|
|
@method newCustomization
|
|
|
|
**/
|
|
|
|
newCustomization: function() {
|
|
|
|
var item = Discourse.SiteCustomization.create({name: I18n.t("admin.customize.new_style")});
|
|
|
|
this.pushObject(item);
|
|
|
|
this.set('selectedItem', item);
|
|
|
|
},
|
|
|
|
|
2015-05-16 22:56:19 -04:00
|
|
|
importModal: function() {
|
|
|
|
showModal('upload-customization');
|
|
|
|
},
|
|
|
|
|
2013-11-12 12:13:17 -05:00
|
|
|
/**
|
|
|
|
Select a given style
|
|
|
|
|
|
|
|
@method selectStyle
|
|
|
|
@param {Discourse.SiteCustomization} style The style we are selecting
|
|
|
|
**/
|
|
|
|
selectStyle: function(style) {
|
|
|
|
this.set('selectedItem', style);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
Save the current customization
|
|
|
|
|
|
|
|
@method save
|
|
|
|
**/
|
|
|
|
save: function() {
|
|
|
|
this.get('selectedItem').save();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destroy the current customization
|
|
|
|
|
|
|
|
@method destroy
|
|
|
|
**/
|
|
|
|
destroy: function() {
|
|
|
|
var _this = this;
|
|
|
|
return bootbox.confirm(I18n.t("admin.customize.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
|
|
|
var selected;
|
|
|
|
if (result) {
|
|
|
|
selected = _this.get('selectedItem');
|
|
|
|
selected.destroy();
|
|
|
|
_this.set('selectedItem', null);
|
|
|
|
return _this.removeObject(selected);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-02-22 15:41:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|