Created
September 29, 2010 02:51
-
-
Save thefrosty/602228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm going to set an option in the settings page to opt into this. So if users wanted to tweet from the admin a longer script, like tweet-longer then can. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready( function($) { | |
/* jQuery jqEasyCharCounter plugin | |
* Examples and documentation at: http://www.jqeasy.com/ | |
* Version: 1.0 (05/07/2010) | |
* No license. Use it however you want. Just keep this notice included. | |
* Requires: jQuery v1.3+ | |
* | |
* Modified by: Austin Passy 09/29/2010 | |
* @link http://austinpassy.com | |
*/ | |
(function(a){a.fn.extend({jqEasyCounter:function(b){return this.each(function(){var f=a(this),e=a.extend({maxChars:100,maxCharsWarning:80,msgFontSize:"12px",msgFontColor:"#000000",msgFontFamily:"Arial",msgTextAlign:"right",msgWarningColor:"#F00",msgAppendMethod:"insertAfter"},b);if(e.maxChars<=0){return}var d=a('<div class="jqEasyCounterMsg" style="padding:2px 7px;"> </div>');var c={"font-size":e.msgFontSize,"font-family":e.msgFontFamily,color:e.msgFontColor,"text-align":e.msgTextAlign,width:f.width(),opacity:0};d.css(c);d[e.msgAppendMethod](f);f.bind("keydown keyup keypress",g).bind("focus paste",function(){setTimeout(g,10)}).bind("blur",function(){d.stop().fadeTo("fast",0);return false});function g(){var i=f.val(),h=i.length;if(h>=e.maxChars){i=i.substring(0,e.maxChars)}if(h>e.maxChars){var j=f.scrollTop();f.val(i.substring(0,e.maxChars));f.scrollTop(j);$('input#publish').attr('disabled','disabled')}else{$('input#publish').removeAttr('disabled')}if(h>=e.maxCharsWarning){d.css({color:e.msgWarningColor});$(this).css({"backgroundColor":"#ffcccc"})}else{d.css({color:e.msgFontColor});$(this).css({"backgroundColor":"#fff"})}d.html("Characters: "+f.val().length+"/"+e.maxChars);d.stop().fadeTo("fast",1)}})}})})(jQuery); | |
/* | |
$('#content').keydown(function(e){ | |
var words = $.trim($(this).val()).split(' ').length; | |
if ( words > 10 && e.keyCode > 65 ) { return false; } | |
}); | |
$('#wp-word-count').html('Characters:' + words +); | |
*/ | |
$('#content').jqEasyCounter({ | |
'maxChars': 140, | |
'maxCharsWarning': 130, | |
'msgFontSize': '11px', | |
'msgFontColor': '#333', | |
'msgFontFamily': '"Lucida Grande",Verdana,Arial,"Bitstream Vera Sans",sans-serif', | |
'msgTextAlign': 'left', | |
'msgWarningColor': '#F00', | |
'msgAppendMethod': 'insertAfter' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
//This is the else statement I've created if a user opts out of limiting the content to just 140 characters.
//It's a stripped down version, that allows more than 140 characters, but warns the user and still counts characters.