| 42 | | Almanac.onReady(function() { |
| 43 | | // limit input on description |
| 44 | | jQuery(document.getElementById('form.description')).keypress(function(event) { |
| 45 | | if(jQuery(this)[0].value.length > 399 && event.keyCode != 8) { |
| 46 | | event.preventDefault(); |
| 47 | | } |
| | 42 | var nAllowedDescriptionChars = 400; |
| | 43 | jQuery(document).ready(function() { |
| | 44 | jQuery('div.theme-widget input').focus(function() { |
| | 45 | switchStyle(this.getAttribute("value")); |
| | 46 | return false; |
| | 47 | }); |
| | 48 | |
| | 49 | // limit input on description |
| | 50 | var formDescription = document.getElementById('form.description'); |
| | 51 | var almanacSubmit = jQuery('input[@value="Update"]'); |
| | 52 | jQuery(formDescription).keyup(function(event) { |
| | 53 | if(formDescription.value.length > nAllowedDescriptionChars) { |
| | 54 | almanacSubmit.attr('disabled', 'disabled'); |
| | 55 | almanacSubmit.attr('class', 'disabled'); |
| | 56 | } else { |
| | 57 | almanacSubmit.attr('disabled', false); |
| | 58 | almanacSubmit.attr('class', 'button'); |
| | 59 | } |
| | 60 | updateRemainingChars(formDescription); |
| | 61 | }); |
| | 62 | |
| | 63 | updateRemainingChars(formDescription); |
| 49 | | |
| 50 | | jQuery(document.getElementById('form.description')).keyup(function(event) { |
| 51 | | updateRemainingChars(this); |
| 52 | | }); |
| 53 | | |
| 54 | | |
| 55 | | updateRemainingChars(document.getElementById('form.description')); |
| 56 | | }); |
| 57 | | |
| 58 | | |
| 59 | | function updateRemainingChars(textArea) { |
| 60 | | var remaining = 400 - jQuery(textArea)[0].value.length; |
| 61 | | jQuery('#char-count')[0].innerHTML = remaining; |
| 62 | | } |
| | 65 | |
| | 66 | var strCount = jQuery('#char-count'); |
| | 67 | function updateRemainingChars(textArea) { |
| | 68 | var remaining = nAllowedDescriptionChars - jQuery(textArea)[0].value.length; |
| | 69 | strCount[0].innerHTML = remaining; |
| | 70 | if (remaining < 0) { |
| | 71 | strCount.css('color', 'red'); |
| | 72 | } else { |
| | 73 | strCount.css('color', 'green'); |
| | 74 | } |
| | 75 | } |