speedo 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. data/app/views/layouts/speedo/application.html.haml +26 -21
  2. data/app/views/speedo/home/examples.html.haml +15 -16
  3. data/config/routes.rb +2 -2
  4. data/lib/generators/speedo/install_generator.rb +2 -2
  5. data/lib/speedo/sass.rb +1 -2
  6. data/lib/speedo/version.rb +1 -1
  7. data/vendor/assets/javascripts/chosen.jquery.js +952 -0
  8. data/vendor/assets/javascripts/jquery.autoSuggest.js +368 -0
  9. data/vendor/assets/javascripts/jquery.autogrow.js +50 -0
  10. data/vendor/assets/javascripts/jquery.dataTables.js +11612 -0
  11. data/vendor/assets/javascripts/jquery.fancybox-1.3.4.js +1156 -0
  12. data/vendor/assets/javascripts/jquery.livequery.js +250 -0
  13. data/vendor/assets/javascripts/jquery.mousewheel-3.0.4.pack.js +14 -0
  14. data/vendor/assets/javascripts/jquery.placeholder.min.js +2 -0
  15. data/vendor/assets/javascripts/jquery.uniform.js +672 -0
  16. data/vendor/assets/javascripts/modernizr.min.js +13 -0
  17. data/vendor/assets/javascripts/respond.js +326 -0
  18. data/vendor/assets/stylesheets/autoSuggest.css +217 -0
  19. data/vendor/assets/stylesheets/chosen-sprite.png +0 -0
  20. data/vendor/assets/stylesheets/chosen.css +392 -0
  21. data/vendor/assets/stylesheets/dataTables/Sorting icons.psd +0 -0
  22. data/vendor/assets/stylesheets/dataTables/back_disabled.png +0 -0
  23. data/vendor/assets/stylesheets/dataTables/back_enabled.png +0 -0
  24. data/vendor/assets/stylesheets/dataTables/back_enabled_hover.png +0 -0
  25. data/vendor/assets/stylesheets/dataTables/favicon.ico +0 -0
  26. data/vendor/assets/stylesheets/dataTables/forward_disabled.png +0 -0
  27. data/vendor/assets/stylesheets/dataTables/forward_enabled.png +0 -0
  28. data/vendor/assets/stylesheets/dataTables/forward_enabled_hover.png +0 -0
  29. data/vendor/assets/stylesheets/dataTables/sort_asc.png +0 -0
  30. data/vendor/assets/stylesheets/dataTables/sort_asc_disabled.png +0 -0
  31. data/vendor/assets/stylesheets/dataTables/sort_both.png +0 -0
  32. data/vendor/assets/stylesheets/dataTables/sort_desc.png +0 -0
  33. data/vendor/assets/stylesheets/dataTables/sort_desc_disabled.png +0 -0
  34. data/vendor/assets/stylesheets/dataTables/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  35. data/vendor/assets/stylesheets/dataTables/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  36. data/vendor/assets/stylesheets/dataTables/ui-bg_glass_65_ffffff_1x400.png +0 -0
  37. data/vendor/assets/stylesheets/dataTables/ui-bg_glass_75_dadada_1x400.png +0 -0
  38. data/vendor/assets/stylesheets/dataTables/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  39. data/vendor/assets/stylesheets/dataTables/ui-bg_glass_75_ffffff_1x400.png +0 -0
  40. data/vendor/assets/stylesheets/dataTables/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  41. data/vendor/assets/stylesheets/dataTables/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
  42. data/vendor/assets/stylesheets/dataTables/ui-icons_222222_256x240.png +0 -0
  43. data/vendor/assets/stylesheets/dataTables/ui-icons_2e83ff_256x240.png +0 -0
  44. data/vendor/assets/stylesheets/dataTables/ui-icons_454545_256x240.png +0 -0
  45. data/vendor/assets/stylesheets/dataTables/ui-icons_888888_256x240.png +0 -0
  46. data/vendor/assets/stylesheets/dataTables/ui-icons_cd0a0a_256x240.png +0 -0
  47. data/vendor/assets/stylesheets/fancybox/blank.gif +0 -0
  48. data/vendor/assets/stylesheets/fancybox/fancy_close.png +0 -0
  49. data/vendor/assets/stylesheets/fancybox/fancy_loading.png +0 -0
  50. data/vendor/assets/stylesheets/fancybox/fancy_nav_left.png +0 -0
  51. data/vendor/assets/stylesheets/fancybox/fancy_nav_right.png +0 -0
  52. data/vendor/assets/stylesheets/fancybox/fancy_shadow_e.png +0 -0
  53. data/vendor/assets/stylesheets/fancybox/fancy_shadow_n.png +0 -0
  54. data/vendor/assets/stylesheets/fancybox/fancy_shadow_ne.png +0 -0
  55. data/vendor/assets/stylesheets/fancybox/fancy_shadow_nw.png +0 -0
  56. data/vendor/assets/stylesheets/fancybox/fancy_shadow_s.png +0 -0
  57. data/vendor/assets/stylesheets/fancybox/fancy_shadow_se.png +0 -0
  58. data/vendor/assets/stylesheets/fancybox/fancy_shadow_sw.png +0 -0
  59. data/vendor/assets/stylesheets/fancybox/fancy_shadow_w.png +0 -0
  60. data/vendor/assets/stylesheets/fancybox/fancy_title_left.png +0 -0
  61. data/vendor/assets/stylesheets/fancybox/fancy_title_main.png +0 -0
  62. data/vendor/assets/stylesheets/fancybox/fancy_title_over.png +0 -0
  63. data/vendor/assets/stylesheets/fancybox/fancy_title_right.png +0 -0
  64. data/vendor/assets/stylesheets/fancybox/fancybox-x.png +0 -0
  65. data/vendor/assets/stylesheets/fancybox/fancybox-y.png +0 -0
  66. data/vendor/assets/stylesheets/fancybox/fancybox.png +0 -0
  67. data/vendor/assets/stylesheets/gh-buttons.css +393 -0
  68. data/vendor/assets/stylesheets/gh-icons.png +0 -0
  69. data/vendor/assets/stylesheets/jquery-ui-1.8.18.custom.css +565 -0
  70. data/vendor/assets/stylesheets/jquery.dataTables.css +219 -0
  71. data/vendor/assets/stylesheets/jquery.fancybox-1.3.4.css +359 -0
  72. data/vendor/assets/stylesheets/jqueryui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  73. data/vendor/assets/stylesheets/jqueryui/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  74. data/vendor/assets/stylesheets/jqueryui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  75. data/vendor/assets/stylesheets/jqueryui/ui-bg_glass_75_dadada_1x400.png +0 -0
  76. data/vendor/assets/stylesheets/jqueryui/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  77. data/vendor/assets/stylesheets/jqueryui/ui-bg_glass_75_ffffff_1x400.png +0 -0
  78. data/vendor/assets/stylesheets/jqueryui/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  79. data/vendor/assets/stylesheets/jqueryui/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
  80. data/vendor/assets/stylesheets/jqueryui/ui-icons_222222_256x240.png +0 -0
  81. data/vendor/assets/stylesheets/jqueryui/ui-icons_2e83ff_256x240.png +0 -0
  82. data/vendor/assets/stylesheets/jqueryui/ui-icons_454545_256x240.png +0 -0
  83. data/vendor/assets/stylesheets/jqueryui/ui-icons_888888_256x240.png +0 -0
  84. data/vendor/assets/stylesheets/jqueryui/ui-icons_cd0a0a_256x240.png +0 -0
  85. data/vendor/assets/stylesheets/normalize.css +504 -0
  86. data/vendor/assets/stylesheets/uniform/bg-input-focus.png +0 -0
  87. data/vendor/assets/stylesheets/uniform/bg-input.png +0 -0
  88. data/vendor/assets/stylesheets/uniform/sprite-aristo.png +0 -0
  89. data/vendor/assets/stylesheets/uniform/sprite.png +0 -0
  90. data/vendor/assets/stylesheets/uniform.default.css +610 -0
  91. metadata +100 -16
@@ -0,0 +1,368 @@
1
+ /*
2
+ * AutoSuggest
3
+ * Copyright 2009-2010 Drew Wilson
4
+ * www.drewwilson.com
5
+ * code.drewwilson.com/entry/autosuggest-jquery-plugin
6
+ *
7
+ * Version 1.4 - Updated: Mar. 23, 2010
8
+ *
9
+ * This Plug-In will auto-complete or auto-suggest completed search queries
10
+ * for you as you type. You can add multiple selections and remove them on
11
+ * the fly. It supports keybord navigation (UP + DOWN + RETURN), as well
12
+ * as multiple AutoSuggest fields on the same page.
13
+ *
14
+ * Inspied by the Autocomplete plugin by: J�rn Zaefferer
15
+ * and the Facelist plugin by: Ian Tearle (iantearle.com)
16
+ *
17
+ * This AutoSuggest jQuery plug-in is dual licensed under the MIT and GPL licenses:
18
+ * http://www.opensource.org/licenses/mit-license.php
19
+ * http://www.gnu.org/licenses/gpl.html
20
+ */
21
+
22
+ (function($){
23
+ $.fn.autoSuggest = function(data, options) {
24
+ var defaults = {
25
+ asHtmlID: false,
26
+ startText: "Enter Name Here",
27
+ emptyText: "No Results Found",
28
+ preFill: {},
29
+ limitText: "No More Selections Are Allowed",
30
+ selectedItemProp: "value", //name of object property
31
+ selectedValuesProp: "value", //name of object property
32
+ searchObjProps: "value", //comma separated list of object property names
33
+ queryParam: "q",
34
+ retrieveLimit: false, //number for 'limit' param on ajax request
35
+ extraParams: "",
36
+ matchCase: false,
37
+ minChars: 1,
38
+ keyDelay: 400,
39
+ resultsHighlight: true,
40
+ neverSubmit: false,
41
+ selectionLimit: false,
42
+ showResultList: true,
43
+ start: function(){},
44
+ selectionClick: function(elem){},
45
+ selectionAdded: function(elem){},
46
+ selectionRemoved: function(elem){ elem.remove(); },
47
+ formatList: false, //callback function
48
+ beforeRetrieve: function(string){ return string; },
49
+ retrieveComplete: function(data){ return data; },
50
+ resultClick: function(data){},
51
+ resultsComplete: function(){}
52
+ };
53
+ var opts = $.extend(defaults, options);
54
+
55
+ var d_type = "object";
56
+ var d_count = 0;
57
+ if(typeof data == "string") {
58
+ d_type = "string";
59
+ var req_string = data;
60
+ } else {
61
+ var org_data = data;
62
+ for (k in data) if (data.hasOwnProperty(k)) d_count++;
63
+ }
64
+ if((d_type == "object" && d_count > 0) || d_type == "string"){
65
+ return this.each(function(x){
66
+ if(!opts.asHtmlID){
67
+ x = x+""+Math.floor(Math.random()*100); //this ensures there will be unique IDs on the page if autoSuggest() is called multiple times
68
+ var x_id = "as-input-"+x;
69
+ } else {
70
+ x = opts.asHtmlID;
71
+ var x_id = x;
72
+ }
73
+ opts.start.call(this);
74
+ var input = $(this);
75
+ input.attr("autocomplete","off").addClass("as-input").attr("id",x_id).val(opts.startText);
76
+ var input_focus = false;
77
+
78
+ // Setup basic elements and render them to the DOM
79
+ input.wrap('<ul class="as-selections" id="as-selections-'+x+'"></ul>').wrap('<li class="as-original" id="as-original-'+x+'"></li>');
80
+ var selections_holder = $("#as-selections-"+x);
81
+ var org_li = $("#as-original-"+x);
82
+ var results_holder = $('<div class="as-results" id="as-results-'+x+'"></div>').hide();
83
+ var results_ul = $('<ul class="as-list"></ul>');
84
+ var values_input = $('<input type="hidden" class="as-values" name="as_values_'+x+'" id="as-values-'+x+'" />');
85
+ var prefill_value = "";
86
+ if(typeof opts.preFill == "string"){
87
+ var vals = opts.preFill.split(",");
88
+ for(var i=0; i < vals.length; i++){
89
+ var v_data = {};
90
+ v_data[opts.selectedValuesProp] = vals[i];
91
+ if(vals[i] != ""){
92
+ add_selected_item(v_data, "000"+i);
93
+ }
94
+ }
95
+ prefill_value = opts.preFill;
96
+ } else {
97
+ prefill_value = "";
98
+ var prefill_count = 0;
99
+ for (k in opts.preFill) if (opts.preFill.hasOwnProperty(k)) prefill_count++;
100
+ if(prefill_count > 0){
101
+ for(var i=0; i < prefill_count; i++){
102
+ var new_v = opts.preFill[i][opts.selectedValuesProp];
103
+ if(new_v == undefined){ new_v = ""; }
104
+ prefill_value = prefill_value+new_v+",";
105
+ if(new_v != ""){
106
+ add_selected_item(opts.preFill[i], "000"+i);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ if(prefill_value != ""){
112
+ input.val("");
113
+ var lastChar = prefill_value.substring(prefill_value.length-1);
114
+ if(lastChar != ","){ prefill_value = prefill_value+","; }
115
+ values_input.val(","+prefill_value);
116
+ $("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
117
+ }
118
+ input.after(values_input);
119
+ selections_holder.click(function(){
120
+ input_focus = true;
121
+ input.focus();
122
+ }).mousedown(function(){ input_focus = false; }).after(results_holder);
123
+
124
+ var timeout = null;
125
+ var prev = "";
126
+ var totalSelections = 0;
127
+ var tab_press = false;
128
+
129
+ // Handle input field events
130
+ input.focus(function(){
131
+ if($(this).val() == opts.startText && values_input.val() == ""){
132
+ $(this).val("");
133
+ } else if(input_focus){
134
+ $("li.as-selection-item", selections_holder).removeClass("blur");
135
+ if($(this).val() != ""){
136
+ results_ul.css("width",selections_holder.outerWidth());
137
+ results_holder.show();
138
+ }
139
+ }
140
+ input_focus = true;
141
+ return true;
142
+ }).blur(function(){
143
+ if($(this).val() == "" && values_input.val() == "" && prefill_value == ""){
144
+ $(this).val(opts.startText);
145
+ } else if(input_focus){
146
+ $("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
147
+ results_holder.hide();
148
+ }
149
+ }).keydown(function(e) {
150
+ // track last key pressed
151
+ lastKeyPressCode = e.keyCode;
152
+ first_focus = false;
153
+ switch(e.keyCode) {
154
+ case 38: // up
155
+ e.preventDefault();
156
+ moveSelection("up");
157
+ break;
158
+ case 40: // down
159
+ e.preventDefault();
160
+ moveSelection("down");
161
+ break;
162
+ case 8: // delete
163
+ if(input.val() == ""){
164
+ var last = values_input.val().split(",");
165
+ last = last[last.length - 2];
166
+ selections_holder.children().not(org_li.prev()).removeClass("selected");
167
+ if(org_li.prev().hasClass("selected")){
168
+ values_input.val(values_input.val().replace(","+last+",",","));
169
+ opts.selectionRemoved.call(this, org_li.prev());
170
+ } else {
171
+ opts.selectionClick.call(this, org_li.prev());
172
+ org_li.prev().addClass("selected");
173
+ }
174
+ }
175
+ if(input.val().length == 1){
176
+ results_holder.hide();
177
+ prev = "";
178
+ }
179
+ if($(":visible",results_holder).length > 0){
180
+ if (timeout){ clearTimeout(timeout); }
181
+ timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
182
+ }
183
+ break;
184
+ case 9: case 188: // tab or comma
185
+ tab_press = true;
186
+ var i_input = input.val().replace(/(,)/g, "");
187
+ if(i_input != "" && values_input.val().search(","+i_input+",") < 0 && i_input.length >= opts.minChars){
188
+ e.preventDefault();
189
+ var n_data = {};
190
+ n_data[opts.selectedItemProp] = i_input;
191
+ n_data[opts.selectedValuesProp] = i_input;
192
+ var lis = $("li", selections_holder).length;
193
+ add_selected_item(n_data, "00"+(lis+1));
194
+ input.val("");
195
+ }
196
+ case 13: // return
197
+ tab_press = false;
198
+ var active = $("li.active:first", results_holder);
199
+ if(active.length > 0){
200
+ active.click();
201
+ results_holder.hide();
202
+ }
203
+ if(opts.neverSubmit || active.length > 0){
204
+ e.preventDefault();
205
+ }
206
+ break;
207
+ default:
208
+ if(opts.showResultList){
209
+ if(opts.selectionLimit && $("li.as-selection-item", selections_holder).length >= opts.selectionLimit){
210
+ results_ul.html('<li class="as-message">'+opts.limitText+'</li>');
211
+ results_holder.show();
212
+ } else {
213
+ if (timeout){ clearTimeout(timeout); }
214
+ timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
215
+ }
216
+ }
217
+ break;
218
+ }
219
+ });
220
+
221
+ function keyChange() {
222
+ // ignore if the following keys are pressed: [del] [shift] [capslock]
223
+ if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ){ return results_holder.hide(); }
224
+ var string = input.val().replace(/[\\]+|[\/]+/g,"");
225
+ if (string == prev) return;
226
+ prev = string;
227
+ if (string.length >= opts.minChars) {
228
+ selections_holder.addClass("loading");
229
+ if(d_type == "string"){
230
+ var limit = "";
231
+ if(opts.retrieveLimit){
232
+ limit = "&limit="+encodeURIComponent(opts.retrieveLimit);
233
+ }
234
+ if(opts.beforeRetrieve){
235
+ string = opts.beforeRetrieve.call(this, string);
236
+ }
237
+ $.getJSON(req_string+"?"+opts.queryParam+"="+encodeURIComponent(string)+limit+opts.extraParams, function(data){
238
+ d_count = 0;
239
+ var new_data = opts.retrieveComplete.call(this, data);
240
+ for (k in new_data) if (new_data.hasOwnProperty(k)) d_count++;
241
+ processData(new_data, string);
242
+ });
243
+ } else {
244
+ if(opts.beforeRetrieve){
245
+ string = opts.beforeRetrieve.call(this, string);
246
+ }
247
+ processData(org_data, string);
248
+ }
249
+ } else {
250
+ selections_holder.removeClass("loading");
251
+ results_holder.hide();
252
+ }
253
+ }
254
+ var num_count = 0;
255
+ function processData(data, query){
256
+ if (!opts.matchCase){ query = query.toLowerCase(); }
257
+ var matchCount = 0;
258
+ results_holder.html(results_ul.html("")).hide();
259
+ for(var i=0;i<d_count;i++){
260
+ var num = i;
261
+ num_count++;
262
+ var forward = false;
263
+ if(opts.searchObjProps == "value") {
264
+ var str = data[num].value;
265
+ } else {
266
+ var str = "";
267
+ var names = opts.searchObjProps.split(",");
268
+ for(var y=0;y<names.length;y++){
269
+ var name = $.trim(names[y]);
270
+ str = str+data[num][name]+" ";
271
+ }
272
+ }
273
+ if(str){
274
+ if (!opts.matchCase){ str = str.toLowerCase(); }
275
+ if(str.search(query) != -1 && values_input.val().search(","+data[num][opts.selectedValuesProp]+",") == -1){
276
+ forward = true;
277
+ }
278
+ }
279
+ if(forward){
280
+ var formatted = $('<li class="as-result-item" id="as-result-item-'+num+'"></li>').click(function(){
281
+ var raw_data = $(this).data("data");
282
+ var number = raw_data.num;
283
+ if($("#as-selection-"+number, selections_holder).length <= 0 && !tab_press){
284
+ var data = raw_data.attributes;
285
+ input.val("").focus();
286
+ prev = "";
287
+ add_selected_item(data, number);
288
+ opts.resultClick.call(this, raw_data);
289
+ results_holder.hide();
290
+ }
291
+ tab_press = false;
292
+ }).mousedown(function(){ input_focus = false; }).mouseover(function(){
293
+ $("li", results_ul).removeClass("active");
294
+ $(this).addClass("active");
295
+ }).data("data",{attributes: data[num], num: num_count});
296
+ var this_data = $.extend({},data[num]);
297
+ if (!opts.matchCase){
298
+ var regx = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + query + ")(?![^<>]*>)(?![^&;]+;)", "gi");
299
+ } else {
300
+ var regx = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + query + ")(?![^<>]*>)(?![^&;]+;)", "g");
301
+ }
302
+
303
+ if(opts.resultsHighlight){
304
+ this_data[opts.selectedItemProp] = this_data[opts.selectedItemProp].replace(regx,"<em>$1</em>");
305
+ }
306
+ if(!opts.formatList){
307
+ formatted = formatted.html(this_data[opts.selectedItemProp]);
308
+ } else {
309
+ formatted = opts.formatList.call(this, this_data, formatted);
310
+ }
311
+ results_ul.append(formatted);
312
+ delete this_data;
313
+ matchCount++;
314
+ if(opts.retrieveLimit && opts.retrieveLimit == matchCount ){ break; }
315
+ }
316
+ }
317
+ selections_holder.removeClass("loading");
318
+ if(matchCount <= 0){
319
+ results_ul.html('<li class="as-message">'+opts.emptyText+'</li>');
320
+ }
321
+ results_ul.css("width", selections_holder.outerWidth());
322
+ results_holder.show();
323
+ opts.resultsComplete.call(this);
324
+ }
325
+
326
+ function add_selected_item(data, num){
327
+ values_input.val(values_input.val()+data[opts.selectedValuesProp]+",");
328
+ var item = $('<li class="as-selection-item" id="as-selection-'+num+'"></li>').click(function(){
329
+ opts.selectionClick.call(this, $(this));
330
+ selections_holder.children().removeClass("selected");
331
+ $(this).addClass("selected");
332
+ }).mousedown(function(){ input_focus = false; });
333
+ var close = $('<a class="as-close">&times;</a>').click(function(){
334
+ values_input.val(values_input.val().replace(","+data[opts.selectedValuesProp]+",",","));
335
+ opts.selectionRemoved.call(this, item);
336
+ input_focus = true;
337
+ input.focus();
338
+ return false;
339
+ });
340
+ org_li.before(item.html(data[opts.selectedItemProp]).prepend(close));
341
+ opts.selectionAdded.call(this, org_li.prev());
342
+ }
343
+
344
+ function moveSelection(direction){
345
+ if($(":visible",results_holder).length > 0){
346
+ var lis = $("li", results_holder);
347
+ if(direction == "down"){
348
+ var start = lis.eq(0);
349
+ } else {
350
+ var start = lis.filter(":last");
351
+ }
352
+ var active = $("li.active:first", results_holder);
353
+ if(active.length > 0){
354
+ if(direction == "down"){
355
+ start = active.next();
356
+ } else {
357
+ start = active.prev();
358
+ }
359
+ }
360
+ lis.removeClass("active");
361
+ start.addClass("active");
362
+ }
363
+ }
364
+
365
+ });
366
+ }
367
+ }
368
+ })(jQuery);
@@ -0,0 +1,50 @@
1
+ (function($) {
2
+ /*
3
+ * Auto-growing textareas
4
+ */
5
+ $.fn.autogrow = function(options) {
6
+
7
+ this.filter('textarea').each(function() {
8
+
9
+ var $this = $(this),
10
+ minHeight = $this.height(),
11
+ lineHeight = $this.css('lineHeight');
12
+
13
+ var shadow = $('<div></div>').css({
14
+ position: 'absolute',
15
+ top: -10000,
16
+ left: -10000,
17
+ width: $(this).width() - parseInt($this.css('paddingLeft')) - parseInt($this.css('paddingRight')),
18
+ fontSize: $this.css('fontSize'),
19
+ fontFamily: $this.css('fontFamily'),
20
+ lineHeight: $this.css('lineHeight'),
21
+ resize: 'none'
22
+ }).appendTo(document.body);
23
+
24
+ var update = function() {
25
+
26
+ var times = function(string, number) {
27
+ var _res = '';
28
+ for(var i = 0; i < number; i ++) {
29
+ _res = _res + string;
30
+ }
31
+ return _res;
32
+ };
33
+
34
+ var val = this.value.replace(/</g, '&lt;')
35
+ .replace(/>/g, '&gt;')
36
+ .replace(/&/g, '&amp;')
37
+ .replace(/\n$/, '<br/>&nbsp;')
38
+ .replace(/\n/g, '<br/>')
39
+ .replace(/ {2,}/g, function(space) { return times('&nbsp;', space.length -1) + ' ' });
40
+
41
+ shadow.html(val);
42
+ $(this).css('height', Math.max(shadow.height() + 20, minHeight));
43
+ }
44
+
45
+ $(this).change(update).keyup(update).keydown(update);
46
+ update.apply(this);
47
+ });
48
+ return this;
49
+ }
50
+ })(jQuery);