Index: trunk/extensions/MoodBar/modules/jquery.NobleCount/jquery.NobleCount.js |
— | — | @@ -0,0 +1,480 @@ |
| 2 | +/****************************************************************************************************** |
| 3 | + |
| 4 | + jQuery.NobleCount |
| 5 | + |
| 6 | + Author Jeremy Horn |
| 7 | + Version 1.0 |
| 8 | + Date: 3/21/2010 |
| 9 | + |
| 10 | + Copyright (c) 2010 Jeremy Horn- jeremydhorn(at)gmail(dot)c0m | http://tpgblog.com |
| 11 | + Dual licensed under MIT and GPL. |
| 12 | + |
| 13 | + DESCRIPTION |
| 14 | + NobleCount... for a more 'proper' count of the characters remaining. |
| 15 | + |
| 16 | + NobleCount is a customizable jQuery plugin for a more the improved counting of the remaining |
| 17 | + characters, and resulting behaviors, of a text entry object, e.g. input textfield, textarea. |
| 18 | + |
| 19 | + As text is entered into the target text area an object for the purposes of tracking |
| 20 | + the total number of characters remaining, defined as the maximum number of characters |
| 21 | + minus the current total number of characters within the text entry object, and storing |
| 22 | + that information visually and/or within the DOM as an HTML 5 compliant data-* attribute. |
| 23 | + |
| 24 | + Events and CSS Class alterations, if defined, are triggered based on current user |
| 25 | + interaction with the target text entry object as well as the current state (positive or |
| 26 | + negative) of the character remaining value. |
| 27 | + |
| 28 | + NobleCount supports pre-existing text within the text object. |
| 29 | + NobleCount supports jQuery chaining. |
| 30 | + |
| 31 | + Within NobleCount context... |
| 32 | + NEGATIVE is defined as Integers < 0 |
| 33 | + POSITIVE is defined as Integers >= 0 [on_positive will fire when char_rem == 0] |
| 34 | + |
| 35 | + BY DEFAULT |
| 36 | + - maximum characters EQUAL 140 characters |
| 37 | + - no events defined |
| 38 | + - no class changes defined |
| 39 | + - no DOM attributes are created/altered |
| 40 | + - user permitted to type past the maximum number of characters limit, resulting in |
| 41 | + negative number of characters remaining |
| 42 | + |
| 43 | + IMPLEMENTATION |
| 44 | + |
| 45 | + $('#textarea1').NobleCount('#characters_remaining1'); |
| 46 | + $('#textfield2').NobleCount('#characters_remaining2', { / * OPTIONS * / }); |
| 47 | + |
| 48 | + COMPATIBILITY |
| 49 | + |
| 50 | + Tested in FF3.5, IE7 |
| 51 | + With jQuery 1.3.x, 1.4.x |
| 52 | + |
| 53 | + METHOD(S) |
| 54 | + To properly intialize, both the text entry object and the object that will store the |
| 55 | + total number of characters remaining must exist and be passed to NobleCount. |
| 56 | + |
| 57 | + $(TEXT_ENTRY_OBJECT).NobleCount(CHARACTERS_REMAINING_OBJECT); |
| 58 | + |
| 59 | + Any callback functions assigned to any of the availale events are passed the following |
| 60 | + parameters: t_obj, char_area, c_settings, char_rem |
| 61 | + |
| 62 | + t_obj text entry object |
| 63 | + |
| 64 | + char_area selection of the characters remaining object |
| 65 | + |
| 66 | + c_settings result of the options passed into NobleCount at time of |
| 67 | + initialization merged with the default options |
| 68 | + |
| 69 | + ** this is a GREAT way to pass in and remember other state |
| 70 | + information that will be needed upon the triggering of |
| 71 | + NobleCount events ** |
| 72 | + |
| 73 | + char_rem integer representation of the total number of characters |
| 74 | + remaining resulting from the calculated difference between |
| 75 | + the target maximum number of characters and the current |
| 76 | + number of characters currently within t_obj |
| 77 | + |
| 78 | + Both TEXT_ENTRY_OBJECT and CHARACTERS_REMAINING_OBJECT must be specified and valid. |
| 79 | + |
| 80 | + Upon successful initialization, all appropriate events and classes are applied to |
| 81 | + the CHARACTERS_REMAINING_OBJECT, including the storage (if not disabled) visually |
| 82 | + or only in the DOM (if enabled) of the integer representing the number of characters |
| 83 | + remaining. |
| 84 | + |
| 85 | + The target maximum number of characters (max_chars) are determined by the following |
| 86 | + precedence rules.... |
| 87 | + |
| 88 | + if max_chars passed via constructor |
| 89 | + max_chars = max_chars passed |
| 90 | + else if number exists within characters_remaining object and number > 0 |
| 91 | + max_chars = number within the text() of characters_remaining object |
| 92 | + else use the NobleCount's default max_chars |
| 93 | + |
| 94 | + CUSTOMIZATION |
| 95 | + |
| 96 | + NobleCount(c_obj, <OPTIONS>) |
| 97 | + e.g. $(t_obj).NobleCount(c_obj, {max_chars:100px}); |
| 98 | + |
| 99 | + |
| 100 | + on_negative class (STRING) or FUNCTION that is applied/called |
| 101 | + when characters remaining is negative IF DEFINED |
| 102 | + |
| 103 | + on_positive class (STRING) or FUNCTION that is applied/called |
| 104 | + when characters remaining is positive IF DEFINED |
| 105 | + |
| 106 | + on_update FUNCTION that is called when characters remaining changes |
| 107 | + |
| 108 | + max_chars target maximum number of characters |
| 109 | + |
| 110 | + block_negative if TRUE, then all attempts are made to block entering |
| 111 | + more than max_characters; not effective against user |
| 112 | + pasting in blocks of text that exceed the max_chars value |
| 113 | + otherwise, text area will let individual entering the text |
| 114 | + to exceed max_chars limit (characters remaining becomes |
| 115 | + negative) |
| 116 | + |
| 117 | + cloak: false, if TRUE, then no visual updates of characters remaining |
| 118 | + object (c_obj) will occur; this does not have any effect |
| 119 | + on the char_rem value returned via any event callbacks |
| 120 | + otherwise, the text within c_obj is constantly updated to |
| 121 | + represent the total number of characters remaining until |
| 122 | + the max_chars limit has been reached |
| 123 | + |
| 124 | + in_dom: false if TRUE and cloak is ALSO TRUE, then the number of characters |
| 125 | + remaining are stored as the attribute of c_obj |
| 126 | + named 'data-noblecount' |
| 127 | + |
| 128 | + !NOTE: if enabled, due to constant updating of a DOM element |
| 129 | + attribute user experience can appear sluggish while |
| 130 | + the individual is modifying the text entry object (t_obj) |
| 131 | + |
| 132 | + |
| 133 | + EXAMPLE OPTIONS = |
| 134 | + { |
| 135 | + on_negative: 'go_red', |
| 136 | + on_positive: 'go_green', |
| 137 | + max_chars: 25, |
| 138 | + on_update: function(t_obj, char_area, c_settings, char_rem){ |
| 139 | + if ((char_rem % 10) == 0) { |
| 140 | + char_area.css('font-weight', 'bold'); |
| 141 | + char_area.css('font-size', '300%'); |
| 142 | + } else { |
| 143 | + char_area.css('font-weight', 'normal'); |
| 144 | + char_area.css('font-size', '100%'); |
| 145 | + } |
| 146 | + } |
| 147 | + }; |
| 148 | + |
| 149 | + MORE |
| 150 | + |
| 151 | + For more details about NobleCount, its implementation, usage, and examples, go to: |
| 152 | + http://tpgblog.com/noblecount/ |
| 153 | + |
| 154 | +******************************************************************************************************/ |
| 155 | + |
| 156 | +(function($) { |
| 157 | + |
| 158 | + /********************************************************************************** |
| 159 | + |
| 160 | + FUNCTION |
| 161 | + NobleCount |
| 162 | + |
| 163 | + DESCRIPTION |
| 164 | + NobleCount method constructor |
| 165 | + |
| 166 | + allows for customization of maximum length and related update/length |
| 167 | + behaviors |
| 168 | + |
| 169 | + e.g. $(text_obj).NobleCount(characters_remaining_obj); |
| 170 | + |
| 171 | + REQUIRED: c_obj |
| 172 | + OPTIONAL: options |
| 173 | + |
| 174 | + **********************************************************************************/ |
| 175 | + |
| 176 | + $.fn.NobleCount = function(c_obj, options) { |
| 177 | + var c_settings; |
| 178 | + var mc_passed = false; |
| 179 | + |
| 180 | + // if c_obj is not specified, then nothing to do here |
| 181 | + if (typeof c_obj == 'string') { |
| 182 | + // check for new & valid options |
| 183 | + c_settings = $.extend({}, $.fn.NobleCount.settings, options); |
| 184 | + |
| 185 | + // was max_chars passed via options parameter? |
| 186 | + if (typeof options != 'undefined') { |
| 187 | + mc_passed = ((typeof options.max_chars == 'number') ? true : false); |
| 188 | + } |
| 189 | + |
| 190 | + // process all provided objects |
| 191 | + return this.each(function(){ |
| 192 | + var $this = $(this); |
| 193 | + |
| 194 | + // attach events to c_obj |
| 195 | + attach_nobility($this, c_obj, c_settings, mc_passed); |
| 196 | + }); |
| 197 | + } |
| 198 | + |
| 199 | + return this; |
| 200 | + }; |
| 201 | + |
| 202 | + |
| 203 | + /********************************************************************************** |
| 204 | + |
| 205 | + FUNCTION |
| 206 | + NobleCount.settings |
| 207 | + |
| 208 | + DESCRIPTION |
| 209 | + publically accessible data stucture containing the max_chars and |
| 210 | + event handling specifications for NobleCount |
| 211 | + |
| 212 | + can be directly accessed by '$.fn.NobleCount.settings = ... ;' |
| 213 | + |
| 214 | + **********************************************************************************/ |
| 215 | + $.fn.NobleCount.settings = { |
| 216 | + |
| 217 | + on_negative: null, // class (STRING) or FUNCTION that is applied/called |
| 218 | + // when characters remaining is negative |
| 219 | + on_positive: null, // class (STRING) or FUNCTION that is applied/called |
| 220 | + // when characters remaining is positive |
| 221 | + on_update: null, // FUNCTION that is called when characters remaining |
| 222 | + // changes |
| 223 | + max_chars: 140, // maximum number of characters |
| 224 | + block_negative: false, // if true, then all attempts are made to block entering |
| 225 | + // more than max_characters |
| 226 | + cloak: false, // if true, then no visual updates of characters |
| 227 | + // remaining (c_obj) occur |
| 228 | + in_dom: false // if true and cloak == true, then number of characters |
| 229 | + // remaining are stored as the attribute |
| 230 | + // 'data-noblecount' of c_obj |
| 231 | + |
| 232 | + }; |
| 233 | + |
| 234 | + |
| 235 | + ////////////////////////////////////////////////////////////////////////////////// |
| 236 | + |
| 237 | + // private functions and settings |
| 238 | + |
| 239 | + /********************************************************************************** |
| 240 | + |
| 241 | + FUNCTION |
| 242 | + attach_nobility |
| 243 | + |
| 244 | + DESCRIPTION |
| 245 | + performs all initialization routines and display initiation |
| 246 | + |
| 247 | + assigns both the keyup and keydown events to the target text entry |
| 248 | + object; both keyup and keydown are used to provide the smoothest |
| 249 | + user experience |
| 250 | + |
| 251 | + if max_chars_passed via constructor |
| 252 | + max_chars = max_chars_passed |
| 253 | + else if number exists within counting_object (and number > 0) |
| 254 | + max_chars = counting_object.number |
| 255 | + else use default max_chars |
| 256 | + |
| 257 | + PRE |
| 258 | + t_obj and c_obj EXIST |
| 259 | + c_settings and mc_passed initialized |
| 260 | + |
| 261 | + POST |
| 262 | + maximum number of characters for t_obj calculated and stored in max_char |
| 263 | + key events attached to t_obj |
| 264 | + |
| 265 | + **********************************************************************************/ |
| 266 | + |
| 267 | + function attach_nobility(t_obj, c_obj, c_settings, mc_passed){ |
| 268 | + var max_char = c_settings.max_chars; |
| 269 | + var char_area = $(c_obj); |
| 270 | + |
| 271 | + // first determine if max_char needs adjustment |
| 272 | + if (!mc_passed) { |
| 273 | + var tmp_num = char_area.text(); |
| 274 | + var isPosNumber = (/^[1-9]\d*$/).test(tmp_num); |
| 275 | + |
| 276 | + if (isPosNumber) { |
| 277 | + max_char = tmp_num; |
| 278 | + } |
| 279 | + } |
| 280 | + |
| 281 | + // initialize display of characters remaining |
| 282 | + // * note: initializing should not trigger on_update |
| 283 | + event_internals(t_obj, char_area, c_settings, max_char, true); |
| 284 | + |
| 285 | + // then attach the events -- seem to work better than keypress |
| 286 | + $(t_obj).keydown(function(e) { |
| 287 | + event_internals(t_obj, char_area, c_settings, max_char, false); |
| 288 | + |
| 289 | + // to block text entry, return false |
| 290 | + if (check_block_negative(e, t_obj, c_settings, max_char) == false) { |
| 291 | + return false; |
| 292 | + } |
| 293 | + }); |
| 294 | + |
| 295 | + $(t_obj).keyup(function(e) { |
| 296 | + event_internals(t_obj, char_area, c_settings, max_char, false); |
| 297 | + |
| 298 | + // to block text entry, return false |
| 299 | + if (check_block_negative(e, t_obj, c_settings, max_char) == false) { |
| 300 | + return false; |
| 301 | + } |
| 302 | + }); |
| 303 | + } |
| 304 | + |
| 305 | + |
| 306 | + /********************************************************************************** |
| 307 | + |
| 308 | + FUNCTION |
| 309 | + check_block_negative |
| 310 | + |
| 311 | + DESCRIPTION |
| 312 | + determines whether or not text entry within t_obj should be prevented |
| 313 | + |
| 314 | + PRE |
| 315 | + e EXISTS |
| 316 | + t_obj VALID |
| 317 | + c_settings and max_char initialized / calculated |
| 318 | + |
| 319 | + POST |
| 320 | + if t_obj text entry should be prevented FALSE is returned |
| 321 | + otherwise TRUE returned |
| 322 | + |
| 323 | + TODO |
| 324 | + improve selection detection and permissible behaviors experience |
| 325 | + ALSO |
| 326 | + doesnt CURRENTLY block from the pasting of large chunks of text that |
| 327 | + exceed max_char |
| 328 | + |
| 329 | + **********************************************************************************/ |
| 330 | + |
| 331 | + function check_block_negative(e, t_obj, c_settings, max_char){ |
| 332 | + if (c_settings.block_negative) { |
| 333 | + var char_code = e.which; |
| 334 | + var selected; |
| 335 | + |
| 336 | + // goofy handling required to work in both IE and FF |
| 337 | + if (typeof document.selection != 'undefined') { |
| 338 | + selected = (document.selection.createRange().text.length > 0); |
| 339 | + } else { |
| 340 | + selected = (t_obj[0].selectionStart != t_obj[0].selectionEnd); |
| 341 | + } |
| 342 | + |
| 343 | + //return false if can't write more |
| 344 | + if ((!((find_remaining(t_obj, max_char) < 1) && |
| 345 | + (char_code > 47 || char_code == 32 || char_code == 0 || char_code == 13) && |
| 346 | + !e.ctrlKey && |
| 347 | + !e.altKey && |
| 348 | + !selected)) == false) { |
| 349 | + |
| 350 | + // block text entry |
| 351 | + return false; |
| 352 | + } |
| 353 | + } |
| 354 | + |
| 355 | + // allow text entry |
| 356 | + return true; |
| 357 | + } |
| 358 | + |
| 359 | + |
| 360 | + /********************************************************************************** |
| 361 | + |
| 362 | + FUNCTION |
| 363 | + find_remaining |
| 364 | + |
| 365 | + DESCRIPTION |
| 366 | + determines of the number of characters permitted (max_char), the number of |
| 367 | + characters remaining until that limit has been reached |
| 368 | + |
| 369 | + PRE |
| 370 | + t_obj and max_char EXIST and are VALID |
| 371 | + |
| 372 | + POST |
| 373 | + returns integer of the difference between max_char and total number of |
| 374 | + characters within the text entry object (t_obj) |
| 375 | + |
| 376 | + **********************************************************************************/ |
| 377 | + |
| 378 | + function find_remaining(t_obj, max_char){ |
| 379 | + return max_char - ($(t_obj).val()).length; |
| 380 | + } |
| 381 | + |
| 382 | + |
| 383 | + /********************************************************************************** |
| 384 | + |
| 385 | + FUNCTION |
| 386 | + event_internals |
| 387 | + |
| 388 | + DESCRIPTION |
| 389 | + primarily used for the calculation of appropriate behavior resulting from |
| 390 | + any event attached to the text entry object (t_obj) |
| 391 | + |
| 392 | + whenever the char_rem and related display and/or DOM information needs |
| 393 | + updating this function is called |
| 394 | + |
| 395 | + if cloaking is being used, then no visual representation of the characters |
| 396 | + remaining, nor attempt by this plugin to change any of its visual |
| 397 | + characteristics will occur |
| 398 | + |
| 399 | + if cloaking and in_dom are both TRUE, then the number of characters |
| 400 | + remaining are stored within the HTML 5 compliant attribute of the |
| 401 | + character count remaining object (c_obj) labeled 'data-noblecount' |
| 402 | + |
| 403 | + PRE |
| 404 | + c_settings, init_disp initialized |
| 405 | + |
| 406 | + POST |
| 407 | + performs all updates to the DOM visual and otherwise required |
| 408 | + performs all relevant function calls |
| 409 | + |
| 410 | + **********************************************************************************/ |
| 411 | + |
| 412 | + function event_internals(t_obj, char_area, c_settings, max_char, init_disp) { |
| 413 | + var char_rem = find_remaining(t_obj, max_char); |
| 414 | + |
| 415 | + // is chararacters remaining positive or negative |
| 416 | + if (char_rem < 0) { |
| 417 | + toggle_states(c_settings.on_negative, c_settings.on_positive, t_obj, char_area, c_settings, char_rem); |
| 418 | + } else { |
| 419 | + toggle_states(c_settings.on_positive, c_settings.on_negative, t_obj, char_area, c_settings, char_rem); |
| 420 | + } |
| 421 | + |
| 422 | + // determine whether or not to update the text of the char_area (or c_obj) |
| 423 | + if (c_settings.cloak) { |
| 424 | + // this slows stuff down quite a bit; TODO: implement better method of publically accessible data storage |
| 425 | + if (c_settings.in_dom) { |
| 426 | + char_area.attr('data-noblecount', char_rem); |
| 427 | + } |
| 428 | + } else { |
| 429 | + // show the numbers of characters remaining |
| 430 | + char_area.text(char_rem); |
| 431 | + } |
| 432 | + |
| 433 | + // if event_internals isn't being called for initialization purposes and |
| 434 | + // on_update is a properly defined function then call it on this update |
| 435 | + if (!init_disp && jQuery.isFunction(c_settings.on_update)) { |
| 436 | + c_settings.on_update(t_obj, char_area, c_settings, char_rem); |
| 437 | + } |
| 438 | + } |
| 439 | + |
| 440 | + |
| 441 | + /********************************************************************************** |
| 442 | + |
| 443 | + FUNCTION |
| 444 | + toggle_states |
| 445 | + |
| 446 | + DESCRIPTION |
| 447 | + performs the toggling operations between the watched positive and negative |
| 448 | + characteristics |
| 449 | + |
| 450 | + first, enables/triggers/executes the toggle_on behavior/class |
| 451 | + second, disables the trigger_off class |
| 452 | + |
| 453 | + PRE |
| 454 | + toggle_on, toggle_off |
| 455 | + IF DEFINED, |
| 456 | + must be a string representation of a VALID class |
| 457 | + OR |
| 458 | + must be a VALID function |
| 459 | + |
| 460 | + POST |
| 461 | + toggle_on objects have been applied/executed |
| 462 | + toggle_off class has been removed (if it is a class) |
| 463 | + |
| 464 | + **********************************************************************************/ |
| 465 | + |
| 466 | + function toggle_states(toggle_on, toggle_off, t_obj, char_area, c_settings, char_rem){ |
| 467 | + if (toggle_on != null) { |
| 468 | + if (typeof toggle_on == 'string') { |
| 469 | + char_area.addClass(toggle_on); |
| 470 | + } else if (jQuery.isFunction(toggle_on)) { |
| 471 | + toggle_on(t_obj, char_area, c_settings, char_rem); |
| 472 | + } |
| 473 | + } |
| 474 | + |
| 475 | + if (toggle_off != null) { |
| 476 | + if (typeof toggle_off == 'string') { |
| 477 | + char_area.removeClass(toggle_off); |
| 478 | + } |
| 479 | + } |
| 480 | + } |
| 481 | +})(jQuery); |
Property changes on: trunk/extensions/MoodBar/modules/jquery.NobleCount/jquery.NobleCount.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 482 | + native |
Added: svn:executable |
2 | 483 | + * |
Index: trunk/extensions/MoodBar/modules/jquery.NobleCount/jquery.NobleCount.min.js |
— | — | @@ -0,0 +1,3 @@ |
| 2 | +/* jQuery.NobleCount v 1.0 http://tpgblog.com/noblecount/ |
| 3 | +compiled by http://yui.2clics.net/ */ |
| 4 | +(function(c){c.fn.NobleCount=function(i,h){var j;var g=false;if(typeof i=="string"){j=c.extend({},c.fn.NobleCount.settings,h);if(typeof h!="undefined"){g=((typeof h.max_chars=="number")?true:false)}return this.each(function(){var k=c(this);f(k,i,j,g)})}return this};c.fn.NobleCount.settings={on_negative:null,on_positive:null,on_update:null,max_chars:140,block_negative:false,cloak:false,in_dom:false};function f(g,m,n,h){var l=n.max_chars;var j=c(m);if(!h){var k=j.text();var i=(/^[1-9]\d*$/).test(k);if(i){l=k}}b(g,j,n,l,true);c(g).keydown(function(o){b(g,j,n,l,false);if(a(o,g,n,l)==false){return false}});c(g).keyup(function(o){b(g,j,n,l,false);if(a(o,g,n,l)==false){return false}})}function a(k,g,l,j){if(l.block_negative){var h=k.which;var i;if(typeof document.selection!="undefined"){i=(document.selection.createRange().text.length>0)}else{i=(g[0].selectionStart!=g[0].selectionEnd)}if((!((e(g,j)<1)&&(h>47||h==32||h==0||h==13)&&!k.ctrlKey&&!k.altKey&&!i))==false){return false}}return true}function e(g,h){return h-(c(g).val()).length}function b(g,i,l,j,h){var k=e(g,j);if(k<0){d(l.on_negative,l.on_positive,g,i,l,k)}else{d(l.on_positive,l.on_negative,g,i,l,k)}if(l.cloak){if(l.in_dom){i.attr("data-noblecount",k)}}else{i.text(k)}if(!h&&jQuery.isFunction(l.on_update)){l.on_update(g,i,l,k)}}function d(i,g,h,j,l,k){if(i!=null){if(typeof i=="string"){j.addClass(i)}else{if(jQuery.isFunction(i)){i(h,j,l,k)}}}if(g!=null){if(typeof g=="string"){j.removeClass(g)}}}})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/extensions/MoodBar/modules/jquery.NobleCount/jquery.NobleCount.min.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 5 | + native |
Added: svn:executable |
2 | 6 | + * |
Index: trunk/extensions/MoodBar/modules/ext.moodBar/ext.moodBar.core.js |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | </div>\ |
24 | 24 | <div class="mw-moodBar-form">\ |
25 | 25 | <div class="mw-moodBar-formTitle">\ |
26 | | - <span class="mw-moodBar-formNote"><html:msg key="moodbar-form-note" /></span>\ |
| 26 | + <span class="mw-moodBar-formNote"><span id="mw-moodBar-charCount"></span><html:msg key="moodbar-form-note-dynamic" /></span>\ |
27 | 27 | <html:msg key="moodbar-form-title" />\ |
28 | 28 | </div>\ |
29 | 29 | <div class="mw-moodBar-formInputs">\ |
30 | | - <textarea rows="3" maxlength="140" class="mw-moodBar-formInput" /></textarea>\ |
| 30 | + <textarea rows="3" maxlength="140" id="mw-moodBar-feedbackInput" class="mw-moodBar-formInput" /></textarea>\ |
31 | 31 | <div class="mw-moodBar-privacy"></div>\ |
32 | 32 | <input type="button" class="mw-moodBar-formSubmit" disabled="disabled" />\ |
33 | 33 | </div>\ |
— | — | @@ -207,6 +207,22 @@ |
208 | 208 | } |
209 | 209 | ) |
210 | 210 | .end() |
| 211 | + // set up character count |
| 212 | + .find( '.mw-moodBar-formNote' ) |
| 213 | + .html( |
| 214 | + function() { |
| 215 | + var message, counterElement; |
| 216 | + message = mw.msg( 'moodbar-form-note-dynamic' ); |
| 217 | + counterElement = mw.html.element( 'span', { |
| 218 | + 'id': 'mw-moodBar-charCount', |
| 219 | + } ); |
| 220 | + return mw.html.escape( message ) |
| 221 | + .replace( /\$1/, counterElement ); |
| 222 | + } |
| 223 | + ) |
| 224 | + .end() |
| 225 | + |
| 226 | + |
211 | 227 | // Submit |
212 | 228 | .find( '.mw-moodBar-formSubmit' ) |
213 | 229 | .val( mw.msg( 'moodbar-form-submit' ) ) |
— | — | @@ -216,6 +232,11 @@ |
217 | 233 | $.moodBar.submit( mb.feedbackItem ); |
218 | 234 | } ) |
219 | 235 | .end(); |
| 236 | + |
| 237 | + // Set up character counter |
| 238 | + // This is probably not the right way to do this. |
| 239 | + $( '#mw-moodBar-feedbackInput' ).NobleCount('#mw-moodBar-charCount', {max_chars:140}); |
| 240 | + |
220 | 241 | }, |
221 | 242 | |
222 | 243 | core: function() { |
— | — | @@ -249,7 +270,7 @@ |
250 | 271 | |
251 | 272 | mb.ui.overlay.width(newWidth); |
252 | 273 | mb.ui.overlay.hide(); |
253 | | - |
| 274 | + |
254 | 275 | // Bind triger |
255 | 276 | mb.ui.trigger.click( mb.event.trigger ); |
256 | 277 | }, |
Index: trunk/extensions/MoodBar/MoodBar.php |
— | — | @@ -92,6 +92,11 @@ |
93 | 93 | $wgResourceModules['ext.moodBar.init']['dependencies'][] = 'mediawiki.user'; |
94 | 94 | } |
95 | 95 | |
| 96 | + |
| 97 | +$wgResourceModules['jquery.NobleCount'] = $mbResourceTemplate + array( |
| 98 | + 'scripts' => 'jquery.NobleCount/jquery.NobleCount.min.js', |
| 99 | +); |
| 100 | + |
96 | 101 | $wgResourceModules['ext.moodBar.core'] = $mbResourceTemplate + array( |
97 | 102 | 'styles' => 'ext.moodBar/ext.moodBar.core.css', |
98 | 103 | 'scripts' => 'ext.moodBar/ext.moodBar.core.js', |
— | — | @@ -130,6 +135,7 @@ |
131 | 136 | 'mediawiki.util', |
132 | 137 | 'ext.moodBar.init', // just in case |
133 | 138 | 'jquery.localize', |
| 139 | + 'jquery.NobleCount', |
134 | 140 | 'jquery.moodBar', |
135 | 141 | ), |
136 | 142 | 'position' => 'bottom', |
Index: trunk/extensions/MoodBar/MoodBar.i18n.php |
— | — | @@ -447,7 +447,7 @@ |
448 | 448 | 'moodbar-type-confused-title' => 'Зьмешаныя пачуцьці', |
449 | 449 | 'tooltip-moodbar-what' => 'Даведацца болей пра гэтую магчымасьць', |
450 | 450 | 'moodbar-what-label' => 'Што гэта?', |
451 | | - 'moodbar-what-content' => 'Гэтая магчымасьць распрацаваная для дапамогі супольнасьці зразумець вопыт людзей, якія рэдагуюць сайт. |
| 451 | + 'moodbar-what-content' => 'Гэтая магчымасьць распрацаваная для дапамогі супольнасьці зразумець вопыт людзей, якія рэдагуюць сайт. |
452 | 452 | Для дадатковай інфармацыі, калі ласка, наведайце $1.', |
453 | 453 | 'moodbar-what-link' => 'старонка магчымасьці', |
454 | 454 | 'moodbar-privacy' => 'Дасылаючы, Вы пагаджаецеся на доступ на гэтых $1.', |