Skip to content

Commit

Permalink
Theme selector
Browse files Browse the repository at this point in the history
  • Loading branch information
hsw committed May 13, 2015
1 parent f8ad85e commit 67a2359
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
7 changes: 5 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Pepyatka</title>
<link rel="stylesheet" href="/css/common/common.css" />
<!--<link rel="stylesheet" href="/css/themes/fresh/app.css" />-->
<link rel="stylesheet" href="/css/themes/helvetica/app.css" />
<noscript><link rel="stylesheet" href="/css/themes/helvetica/app.css" /></noscript>
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="icon" href="/img/favicon.png" type="image/x-icon" />
<script type="text/javascript">
var theme = /(?:^| )theme=([a-z0-9]+)/.exec(document.cookie);
document.write('<link rel="stylesheet" id="theme-css" href="/css/themes/' + (theme && theme[1] || 'helvetica') + '/app.css" />');
</script>
</head>
<body>
<script src="/js/libs/requirejs/2.1.15/require.min.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions public/js/app/controllers/SettingsGenericController.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ define(["config",
})
},

themes: ["helvetica", "fresh"],

actions: {
previewProfilePicture: function (newFile) {
this.set('newProfilePicture', newFile)
},

themeSelect: function(theme) {
document.cookie = "theme=" + theme;
Ember.$('link#theme-css').attr("href", "/css/themes/" + theme + "/app.css");
}
}
})
Expand Down
11 changes: 11 additions & 0 deletions public/js/app/fields/ThemeSelectorView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
define(["app/app"], function(App) {
"use strict";

App.ThemeSelectorView = Ember.Select.extend({
classNames: ['form-control theme-selector'],

change: function(event) {
this.get('controller').send('themeSelect', event.target.value);
}
})
})
1 change: 1 addition & 0 deletions public/js/app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ define([
"fields/CreateCommentView",
"fields/EditCommentView",
"fields/UpdateProfilePictureView",
"fields/ThemeSelectorView",

"routes/ForgotPasswordRoute",
"routes/GroupsHomeRoute",
Expand Down
5 changes: 5 additions & 0 deletions public/js/app/templates/settingsIndexTemplate.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@
<span id="error-message">{{profilePicErrors}}</span>
</div>
{{/if}}

<div class="form-group p-settings-themeselector">
<label for="theme-selector">Theme:</label>
{{view 'theme-selector' content=themes value=theme}}
</div>

0 comments on commit 67a2359

Please sign in to comment.