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/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 354a35f..4c49f24 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 @@