| | 1 | jQuery( function($) { |
| | 2 | var w = $("<span class='wp-word-count'><a href='#'>Count words</a><span id='word-count'></span></span>").appendTo('#ed_toolbar'); |
| | 3 | if ( $.browser.safari ) { w.css( 'top', 0 ); } // Lame |
| | 4 | else if ( $.browser.msie ) { w.css( 'top', '-8px' ); } |
| | 5 | |
| | 6 | var wc = function(text) { var t = $.trim(text); w.children('span').html( ': ' + ( t ? $("<div>" + t + "</div>").text().split( /\b[^\w']+\b/ ).length.toString() : '0' ) ); }; |
| | 7 | |
| | 8 | $('a', w).click( function() { |
| | 9 | if ( 'undefined' != typeof tinyMCE && $.isFunction(tinyMCE.getContent) ) { |
| | 10 | var t = tinyMCE.getContent(); |
| | 11 | if ( t ) { wc( t ); tinyMCE.selectedInstance.getWin().focus(); return false; } |
| | 12 | } |
| | 13 | wc( $('#content').focus().val() ); |
| | 14 | return false; |
| | 15 | } ).click(); |
| | 16 | |
| | 17 | if ( 'undefined' == typeof tinyMCE ) { return; } |
| | 18 | w.removeClass().addClass( 'mceStatusbarPathText' ).css( 'border-right', '1px solid #ccc' ).insertBefore('#mce_editor_0_path'); |
| | 19 | |
| | 20 | if ( 'undefined' == typeof TinyMCE_wordpressPlugin ) { return; } |
| | 21 | var cl = TinyMCE_wordpressPlugin.cleanup; |
| | 22 | TinyMCE_wordpressPlugin.cleanup = function(t,c,i) { |
| | 23 | if ( 'submit_content' == t ) |
| | 24 | w.removeClass().addClass( 'wp-word-count' ).css( 'border-right', 'none' ).appendTo('#ed_toolbar'); |
| | 25 | else if ( 'setup_content_dom' == t ) |
| | 26 | w.removeClass().addClass( 'mceStatusbarPathText' ).css( 'border-right', '1px solid #ccc' ).insertBefore('#mce_editor_0_path'); |
| | 27 | return cl(t,c,i); |
| | 28 | }; |
| | 29 | } ); |