2013-02-21 02:15:50 +08:00
|
|
|
/*global Mousetrap:true */
|
2013-02-23 04:41:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
A view to handle site customizations
|
|
|
|
|
2013-03-02 01:45:25 +08:00
|
|
|
@class AdminCustomizeView
|
|
|
|
@extends Discourse.View
|
2013-02-23 04:41:12 +08:00
|
|
|
@namespace Discourse
|
|
|
|
@module Discourse
|
2013-03-02 01:45:25 +08:00
|
|
|
**/
|
2013-02-23 04:41:12 +08:00
|
|
|
Discourse.AdminCustomizeView = Discourse.View.extend({
|
|
|
|
templateName: 'admin/templates/customize',
|
|
|
|
classNames: ['customize'],
|
2014-01-22 23:52:09 +08:00
|
|
|
selected: 'stylesheet',
|
2015-01-14 18:52:42 +08:00
|
|
|
mobile: false,
|
2014-11-11 04:51:55 +08:00
|
|
|
|
2015-01-14 18:52:42 +08:00
|
|
|
stylesheetActive: Em.computed.equal('selected', 'stylesheet'),
|
2014-04-16 21:49:06 +08:00
|
|
|
headerActive: Em.computed.equal('selected', 'header'),
|
2015-01-14 18:52:42 +08:00
|
|
|
topActive: Em.computed.equal('selected', 'top'),
|
2014-11-11 04:51:55 +08:00
|
|
|
footerActive: Em.computed.equal('selected', 'footer'),
|
2015-01-14 18:52:42 +08:00
|
|
|
headTagActive: Em.computed.equal('selected', 'head_tag'),
|
|
|
|
bodyTagActive: Em.computed.equal('selected', 'body_tag'),
|
|
|
|
|
|
|
|
mobileStylesheetActive: Em.computed.equal('selected', 'mobile_stylesheet'),
|
|
|
|
mobileHeaderActive: Em.computed.equal('selected', 'mobile_header'),
|
|
|
|
mobileTopActive: Em.computed.equal('selected', 'mobile_top'),
|
|
|
|
mobileFooterActive: Em.computed.equal('selected', 'mobile_footer'),
|
2014-01-22 23:52:09 +08:00
|
|
|
|
|
|
|
actions: {
|
2015-01-14 18:52:42 +08:00
|
|
|
toggleMobile: function() {
|
|
|
|
// auto-select best tab
|
|
|
|
var tab = this.get("selected");
|
|
|
|
if (/_tag$/.test(tab)) { tab = "stylesheet"; }
|
|
|
|
if (this.get("mobile")) { tab = tab.replace("mobile_", ""); }
|
|
|
|
else { tab = "mobile_" + tab; }
|
|
|
|
this.set("selected", tab);
|
|
|
|
// toggle mobile
|
|
|
|
this.toggleProperty("mobile");
|
|
|
|
},
|
|
|
|
|
|
|
|
select: function(tab) {
|
|
|
|
this.set('selected', tab);
|
|
|
|
},
|
|
|
|
|
2015-01-02 08:25:15 +08:00
|
|
|
toggleMaximize: function() {
|
|
|
|
this.set("maximized", !this.get("maximized"));
|
|
|
|
|
|
|
|
Em.run.scheduleOnce('afterRender', this, function(){
|
|
|
|
$('.ace-wrapper').each(function(){
|
|
|
|
$(this).data("editor").resize();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2013-09-17 00:21:49 +08:00
|
|
|
},
|
|
|
|
|
2015-01-14 18:52:42 +08:00
|
|
|
_init: function() {
|
2013-06-08 00:13:46 +08:00
|
|
|
var controller = this.get('controller');
|
2014-01-22 23:52:09 +08:00
|
|
|
Mousetrap.bindGlobal('mod+s', function() {
|
|
|
|
controller.send("save");
|
2013-02-23 04:41:12 +08:00
|
|
|
return false;
|
|
|
|
});
|
2015-01-14 18:52:42 +08:00
|
|
|
}.on("didInsertElement"),
|
2013-02-23 04:41:12 +08:00
|
|
|
|
2015-01-14 18:52:42 +08:00
|
|
|
_cleanUp: function() {
|
2014-01-22 23:52:09 +08:00
|
|
|
Mousetrap.unbindGlobal('mod+s');
|
2015-01-14 18:52:42 +08:00
|
|
|
}.on("willDestroyElement")
|
2013-03-02 01:45:25 +08:00
|
|
|
|
2013-02-23 04:41:12 +08:00
|
|
|
});
|