From 2bbb522546bd9360f725527a0b0e5b2fb3bed171 Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 24 Mar 2013 19:53:17 +0000 Subject: [PATCH] Timestamp toggling --- client/assets/css/style.css | 5 ++++- client/assets/dev/app.js | 2 +- client/assets/dev/applet_settings.js | 7 +++++++ client/assets/dev/index.html.tmpl | 5 +++++ client/assets/dev/view.js | 17 +++++++++++++++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/client/assets/css/style.css b/client/assets/css/style.css index e6f4154..492e0de 100644 --- a/client/assets/css/style.css +++ b/client/assets/css/style.css @@ -337,7 +337,7 @@ html, body { height:100%; } #kiwi.theme_relaxed .messages a { text-decoration:none; } #kiwi.theme_relaxed .messages .msg { border-bottom: 1px solid #DEDEDE; padding: 1px; font-family:arial; font-size:0.9em; } -#kiwi.theme_relaxed .messages .msg .time { width:6em; float:left; color:#777; display:none; } +#kiwi.theme_relaxed .messages .msg .time { width:5em; float:left; color:#777; padding:5px; display:none; } #kiwi.theme_relaxed .messages .msg .nick { width:11em; float:left; font-size:12px; font-family:Arial; text-align:right; padding: 5px; overflow:hidden; } #kiwi.theme_relaxed .messages .msg .text { display:block; margin-left:12em; border-left: 1px solid #DEDEDE; white-space:pre-wrap; word-wrap:break-word; font-family:arial; padding:5px; } @@ -364,6 +364,9 @@ html, body { height:100%; } padding:0.5em; margin-top:1em; margin-bottom:1em; margin-right:2em; } +#kiwi.theme_relaxed.timestamps .messages .msg .time { display:block; } +#kiwi.theme_relaxed.timestamps .messages .msg .text { margin-left:17em; } + #kiwi.theme_relaxed .messages .msg.global_nick_highlight, #kiwi.theme_relaxed .messages .msg.highlight { background:#D9D9D9; } diff --git a/client/assets/dev/app.js b/client/assets/dev/app.js index 9187b5b..046eb3f 100644 --- a/client/assets/dev/app.js +++ b/client/assets/dev/app.js @@ -15,7 +15,7 @@ _kiwi.applets = {}; * and data (think: plugins) */ _kiwi.global = { - settings: undefined, + settings: undefined, // Instance of _kiwi.model.DataStore plugins: undefined, utils: undefined, // TODO: Re-usable methods user: undefined, // TODO: Limited user methods diff --git a/client/assets/dev/applet_settings.js b/client/assets/dev/applet_settings.js index 93a222f..78d235a 100644 --- a/client/assets/dev/applet_settings.js +++ b/client/assets/dev/applet_settings.js @@ -38,6 +38,12 @@ } else { this.$el.find('.setting-show_joins_parts').attr('checked', false); } + + if (typeof settings.get('show_timestamps') === 'undefined' || !settings.get('show_timestamps')) { + this.$el.find('.setting-show_timestamps').attr('checked', false); + } else { + this.$el.find('.setting-show_timestamps').attr('checked', true); + } }, @@ -51,6 +57,7 @@ settings.set('channel_list_style', $('.setting-channel_list_style', this.$el).val()); settings.set('scrollback', $('.setting-scrollback', this.$el).val()); settings.set('show_joins_parts', $('.setting-show_joins_parts', this.$el).is(':checked')); + settings.set('show_timestamps', $('.setting-show_timestamps', this.$el).is(':checked')); settings.save(); diff --git a/client/assets/dev/index.html.tmpl b/client/assets/dev/index.html.tmpl index 16a7dcd..fe98e62 100644 --- a/client/assets/dev/index.html.tmpl +++ b/client/assets/dev/index.html.tmpl @@ -182,6 +182,11 @@ + + Show timestamps + + + ​​​​​​​​​ diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index fa43cab..d6d3ebb 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -1085,6 +1085,9 @@ _kiwi.view.Application = Backbone.View.extend({ _kiwi.global.settings.on('change:channel_list_style', this.setTabLayout, this); this.setTabLayout(_kiwi.global.settings.get('channel_list_style')); + _kiwi.global.settings.on('change:show_timestamps', this.displayTimestamps, this); + this.displayTimestamps(_kiwi.global.settings.get('show_timestamps')); + this.doLayout(); $(document).keydown(this.setKeyFocus); @@ -1134,6 +1137,20 @@ _kiwi.view.Application = Backbone.View.extend({ }, + displayTimestamps: function (show_timestamps) { + // If called by the settings callback, get the correct new_value + if (show_timestamps === _kiwi.global.settings) { + show_timestamps = arguments[1]; + } + + if (show_timestamps) { + this.$el.addClass('timestamps'); + } else { + this.$el.removeClass('timestamps'); + } + }, + + // Globally shift focus to the command input box on a keypress setKeyFocus: function (ev) { // If we're copying text, don't shift focus -- 2.25.1