From 1664ae3e2ea063effcd2182bb7fcd2190fb776dd Mon Sep 17 00:00:00 2001 From: max-m Date: Sun, 11 Mar 2012 15:07:28 +0100 Subject: [PATCH 1/2] Seperated counter from chat. --- file/js/jCounter.jQuery.coffee | 20 +++++++++++--- template/chat.tpl | 48 +--------------------------------- 2 files changed, 18 insertions(+), 50 deletions(-) diff --git a/file/js/jCounter.jQuery.coffee b/file/js/jCounter.jQuery.coffee index dd9b96d..5eee1cf 100644 --- a/file/js/jCounter.jQuery.coffee +++ b/file/js/jCounter.jQuery.coffee @@ -10,16 +10,23 @@ $.fn.jCounter = (container, options) -> options = $.extend max: 0 - counterClass: 'jsCounter' + counterClass: 'jCounter' countUp: false + cssFile: 'wcf/style/jCounter.css' + width: '100%' , options if this.attr('maxlength') max = this.attr('maxlength') else max = options.max + if $('#jCounterCSS').length == 0 + $('head').append('') + if !container - this.wrap('
').parent().append('
' + max + '
'); + if !this.hasClass('jCounterInput') + this.addClass('jCounterInput') + this.wrap('
').parent().append('
' + max + '
'); jCounterContainer = $(this).parent().children('.' + options.counterClass) else if typeof container is 'object' @@ -33,7 +40,14 @@ else length = max - this.val().length - if options.countUp + if options.countUp && max > 0 + if length < max / 2 + color = 1 + else if length >= max / 2 and length <= max / 1.2 + color = 2 + else + color = 3 + else if options.countUp color = 1 else if length > max / 2 diff --git a/template/chat.tpl b/template/chat.tpl index 354a35f..cdb8263 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -40,52 +40,6 @@ .ajaxLoad { background-image: url({icon size='S'}spinner1{/icon}); } - - /* - * jCounter CSS - * - * TODO: Seperate jCounter completely from Tims-Chat - */ - .jsCounterContainer { - display: table; - } - - .jsCounterContainer > div { - display: table-row; - } - - .jsCounterInput { - height: 16px; - box-sizing: content-box !important; - } - - .jsCounterInput, .jsCounter { - display: table-cell; - } - - .jsCounterInput, .jsCounterContainer { - width: 100%; - } - - .jsCounter { - background-color: rgba(0, 0, 0, 0.7); - padding: 0 5px 0 10px; - position: relative; - z-index: 0 !important; - border-radius: 0px 5px 5px 0px; - border: 1px solid rgba(255, 255, 255, 0.3); - width: 30px; - } - - .jsCounter.color-1 { - color: #FFFFFF; - } - .jsCounter.color-2 { - color: rgba(255,255,255,0.5); - } - .jsCounter.color-3 { - color: #D40D12; - } @@ -103,7 +57,7 @@
- +
From b7c868ea3274667558384b4afe406e1e600684e9 Mon Sep 17 00:00:00 2001 From: max-m Date: Sun, 11 Mar 2012 15:12:42 +0100 Subject: [PATCH 2/2] Fixed wrong constant name and added forgotten counter CSS file --- file/style/jCounter.scss | 42 ++++++++++++++++++++++++++++++++++++++++ template/chat.tpl | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 file/style/jCounter.scss diff --git a/file/style/jCounter.scss b/file/style/jCounter.scss new file mode 100644 index 0000000..1acc5e9 --- /dev/null +++ b/file/style/jCounter.scss @@ -0,0 +1,42 @@ +.jCounterContainer { + display: table; + + > div { + display: table-row; + } +} + +.jCounterInput { + height: 16px; + width: 100%; + position: relative; + z-index: 9999; + box-sizing: content-box !important; +} + +.jCounterInput, .jCounter { + display: table-cell; +} + +.jCounter { + text-align: center; + background-color: rgba(0, 0, 0, 0.7); + padding: 0 5px 0 10px; + position: relative; + z-index: 0 !important; + border-radius: 0px 5px 5px 0px; + border: 1px solid rgba(255, 255, 255, 0.3); + width: 30px; + + &.color-1 { + color: #FFFFFF; + } + + &.color-2 { + color: rgba(255,255,255,0.5); + } + + &.color-3 { + color: #D40D12; + } +} \ No newline at end of file diff --git a/template/chat.tpl b/template/chat.tpl index cdb8263..4c49f24 100755 --- a/template/chat.tpl +++ b/template/chat.tpl @@ -57,7 +57,7 @@
- +