ideyabox 0.0.1 → 0.0.2

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 (52) hide show
  1. data/lib/generators/ideyabox/admin/admin_generator.rb +25 -0
  2. data/lib/generators/ideyabox/admin/templates/.DS_Store +0 -0
  3. data/lib/generators/ideyabox/admin/templates/assets/.DS_Store +0 -0
  4. data/lib/generators/ideyabox/admin/templates/assets/images/.DS_Store +0 -0
  5. data/lib/generators/ideyabox/admin/templates/assets/images/admin/.DS_Store +0 -0
  6. data/lib/generators/ideyabox/admin/templates/assets/images/admin/addphoto.png +0 -0
  7. data/lib/generators/ideyabox/admin/templates/assets/images/admin/background-image.png +0 -0
  8. data/lib/generators/ideyabox/admin/templates/assets/images/admin/rdws_cat.png +0 -0
  9. data/lib/generators/ideyabox/admin/templates/assets/images/admin/search.png +0 -0
  10. data/lib/generators/ideyabox/admin/templates/assets/images/admin/search_button.png +0 -0
  11. data/lib/generators/ideyabox/admin/templates/assets/images/admin/small_button.png +0 -0
  12. data/lib/generators/ideyabox/admin/templates/assets/images/admin/uploadify/#swfobject.js +4 -0
  13. data/lib/generators/ideyabox/admin/templates/assets/images/admin/uploadify/cancel.png +0 -0
  14. data/lib/generators/ideyabox/admin/templates/assets/images/admin/uploadify/jquery.uploadify.min.js +26 -0
  15. data/lib/generators/ideyabox/admin/templates/assets/images/admin/uploadify/uploadify-cancel.png +0 -0
  16. data/lib/generators/ideyabox/admin/templates/assets/images/admin/uploadify/uploadify.css +66 -0
  17. data/lib/generators/ideyabox/admin/templates/assets/images/admin/uploadify/uploadify.swf +0 -0
  18. data/lib/generators/ideyabox/admin/templates/assets/javascripts/.DS_Store +0 -0
  19. data/lib/generators/ideyabox/admin/templates/assets/javascripts/admin.js +14 -0
  20. data/lib/generators/ideyabox/admin/templates/assets/javascripts/chosen.jquery.js +1018 -0
  21. data/lib/generators/ideyabox/admin/templates/assets/javascripts/jquery.ui.nestedSortable.js +390 -0
  22. data/lib/generators/ideyabox/admin/templates/assets/javascripts/jquery.uploadify.min.js +26 -0
  23. data/lib/generators/ideyabox/admin/templates/assets/javascripts/modernizr.js +4 -0
  24. data/lib/generators/ideyabox/admin/templates/assets/javascripts/swfobject.js +4 -0
  25. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/.DS_Store +0 -0
  26. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/admin.scss.erb +393 -0
  27. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/chosen.scss.erb +398 -0
  28. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/font-awesome.css +303 -0
  29. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/font_awesome/.gitignore +29 -0
  30. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/font_awesome/font/fontawesome-webfont.eot +0 -0
  31. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/font_awesome/font/fontawesome-webfont.svg +255 -0
  32. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/font_awesome/font/fontawesome-webfont.ttf +0 -0
  33. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/font_awesome/font/fontawesome-webfont.woff +0 -0
  34. data/lib/generators/ideyabox/admin/templates/assets/stylesheets/normalize.css +500 -0
  35. data/lib/generators/ideyabox/admin/templates/controllers/.DS_Store +0 -0
  36. data/lib/generators/ideyabox/admin/templates/controllers/admin/.DS_Store +0 -0
  37. data/lib/generators/ideyabox/admin/templates/controllers/admin/application_controller.rb +8 -0
  38. data/lib/generators/ideyabox/admin/templates/helpers/.DS_Store +0 -0
  39. data/lib/generators/ideyabox/admin/templates/helpers/admin_helper.rb +104 -0
  40. data/lib/generators/ideyabox/admin/templates/tasks/reset_db.rake +9 -0
  41. data/lib/generators/ideyabox/admin/templates/tasks/seeds.rb +2 -0
  42. data/lib/generators/ideyabox/admin/templates/views/.DS_Store +0 -0
  43. data/lib/generators/ideyabox/admin/templates/views/admin/.DS_Store +0 -0
  44. data/lib/generators/ideyabox/admin/templates/views/admin/shared/_header.html.haml +11 -0
  45. data/lib/generators/ideyabox/admin/templates/views/admin/shared/_launchbar.html.haml +10 -0
  46. data/lib/generators/ideyabox/admin/templates/views/admin/shared/_topbar.html.haml +6 -0
  47. data/lib/generators/ideyabox/admin/templates/views/layouts/admin.html.haml +39 -0
  48. data/lib/generators/ideyabox/admin/templates/views/layouts/login.html.haml +32 -0
  49. data/lib/ideyabox/version.rb +1 -1
  50. data/lib/ideyabox.rb +1 -2
  51. metadata +49 -2
  52. data/lib/ideyabox/engine.rb +0 -4
@@ -0,0 +1,1018 @@
1
+ // Chosen, a Select Box Enhancer for jQuery and Protoype
2
+ // by Patrick Filler for Harvest, http://getharvest.com
3
+ //
4
+ // Version 0.9.8
5
+ // Full source at https://github.com/harvesthq/chosen
6
+ // Copyright (c) 2011 Harvest http://getharvest.com
7
+
8
+ // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
9
+ // This file is generated by `cake build`, do not edit it by hand.
10
+ (function() {
11
+ var SelectParser;
12
+
13
+ SelectParser = (function() {
14
+
15
+ function SelectParser() {
16
+ this.options_index = 0;
17
+ this.parsed = [];
18
+ }
19
+
20
+ SelectParser.prototype.add_node = function(child) {
21
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
22
+ return this.add_group(child);
23
+ } else {
24
+ return this.add_option(child);
25
+ }
26
+ };
27
+
28
+ SelectParser.prototype.add_group = function(group) {
29
+ var group_position, option, _i, _len, _ref, _results;
30
+ group_position = this.parsed.length;
31
+ this.parsed.push({
32
+ array_index: group_position,
33
+ group: true,
34
+ label: group.label,
35
+ children: 0,
36
+ disabled: group.disabled
37
+ });
38
+ _ref = group.childNodes;
39
+ _results = [];
40
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
41
+ option = _ref[_i];
42
+ _results.push(this.add_option(option, group_position, group.disabled));
43
+ }
44
+ return _results;
45
+ };
46
+
47
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
48
+ if (option.nodeName.toUpperCase() === "OPTION") {
49
+ if (option.text !== "") {
50
+ if (group_position != null) this.parsed[group_position].children += 1;
51
+ this.parsed.push({
52
+ array_index: this.parsed.length,
53
+ options_index: this.options_index,
54
+ value: option.value,
55
+ text: option.text,
56
+ html: option.innerHTML,
57
+ selected: option.selected,
58
+ disabled: group_disabled === true ? group_disabled : option.disabled,
59
+ group_array_index: group_position,
60
+ classes: option.className,
61
+ style: option.style.cssText
62
+ });
63
+ } else {
64
+ this.parsed.push({
65
+ array_index: this.parsed.length,
66
+ options_index: this.options_index,
67
+ empty: true
68
+ });
69
+ }
70
+ return this.options_index += 1;
71
+ }
72
+ };
73
+
74
+ return SelectParser;
75
+
76
+ })();
77
+
78
+ SelectParser.select_to_array = function(select) {
79
+ var child, parser, _i, _len, _ref;
80
+ parser = new SelectParser();
81
+ _ref = select.childNodes;
82
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
83
+ child = _ref[_i];
84
+ parser.add_node(child);
85
+ }
86
+ return parser.parsed;
87
+ };
88
+
89
+ this.SelectParser = SelectParser;
90
+
91
+ }).call(this);
92
+
93
+ /*
94
+ Chosen source: generate output using 'cake build'
95
+ Copyright (c) 2011 by Harvest
96
+ */
97
+
98
+ (function() {
99
+ var AbstractChosen, root;
100
+
101
+ root = this;
102
+
103
+ AbstractChosen = (function() {
104
+
105
+ function AbstractChosen(form_field, options) {
106
+ this.form_field = form_field;
107
+ this.options = options != null ? options : {};
108
+ this.set_default_values();
109
+ this.is_multiple = this.form_field.multiple;
110
+ this.set_default_text();
111
+ this.setup();
112
+ this.set_up_html();
113
+ this.register_observers();
114
+ this.finish_setup();
115
+ }
116
+
117
+ AbstractChosen.prototype.set_default_values = function() {
118
+ var _this = this;
119
+ this.click_test_action = function(evt) {
120
+ return _this.test_active_click(evt);
121
+ };
122
+ this.activate_action = function(evt) {
123
+ return _this.activate_field(evt);
124
+ };
125
+ this.active_field = false;
126
+ this.mouse_on_container = false;
127
+ this.results_showing = false;
128
+ this.result_highlighted = null;
129
+ this.result_single_selected = null;
130
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
131
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
132
+ this.disable_search = this.options.disable_search || false;
133
+ this.search_contains = this.options.search_contains || false;
134
+ this.choices = 0;
135
+ this.single_backstroke_delete = this.options.single_backstroke_delete || false;
136
+ return this.max_selected_options = this.options.max_selected_options || Infinity;
137
+ };
138
+
139
+ AbstractChosen.prototype.set_default_text = function() {
140
+ if (this.form_field.getAttribute("data-placeholder")) {
141
+ this.default_text = this.form_field.getAttribute("data-placeholder");
142
+ } else if (this.is_multiple) {
143
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || "Select Some Options";
144
+ } else {
145
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || "Select an Option";
146
+ }
147
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || "No results match";
148
+ };
149
+
150
+ AbstractChosen.prototype.mouse_enter = function() {
151
+ return this.mouse_on_container = true;
152
+ };
153
+
154
+ AbstractChosen.prototype.mouse_leave = function() {
155
+ return this.mouse_on_container = false;
156
+ };
157
+
158
+ AbstractChosen.prototype.input_focus = function(evt) {
159
+ var _this = this;
160
+ if (this.is_multiple) {
161
+ if (!this.active_field) {
162
+ return setTimeout((function() {
163
+ return _this.container_mousedown();
164
+ }), 50);
165
+ }
166
+ } else {
167
+ if (!this.active_field) return this.activate_field();
168
+ }
169
+ };
170
+
171
+ AbstractChosen.prototype.input_blur = function(evt) {
172
+ var _this = this;
173
+ if (!this.mouse_on_container) {
174
+ this.active_field = false;
175
+ return setTimeout((function() {
176
+ return _this.blur_test();
177
+ }), 100);
178
+ }
179
+ };
180
+
181
+ AbstractChosen.prototype.result_add_option = function(option) {
182
+ var classes, style;
183
+ if (!option.disabled) {
184
+ option.dom_id = this.container_id + "_o_" + option.array_index;
185
+ classes = option.selected && this.is_multiple ? [] : ["active-result"];
186
+ if (option.selected) classes.push("result-selected");
187
+ if (option.group_array_index != null) classes.push("group-option");
188
+ if (option.classes !== "") classes.push(option.classes);
189
+ style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
190
+ return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
191
+ } else {
192
+ return "";
193
+ }
194
+ };
195
+
196
+ AbstractChosen.prototype.results_update_field = function() {
197
+ if (!this.is_multiple) this.results_reset_cleanup();
198
+ this.result_clear_highlight();
199
+ this.result_single_selected = null;
200
+ return this.results_build();
201
+ };
202
+
203
+ AbstractChosen.prototype.results_toggle = function() {
204
+ if (this.results_showing) {
205
+ return this.results_hide();
206
+ } else {
207
+ return this.results_show();
208
+ }
209
+ };
210
+
211
+ AbstractChosen.prototype.results_search = function(evt) {
212
+ if (this.results_showing) {
213
+ return this.winnow_results();
214
+ } else {
215
+ return this.results_show();
216
+ }
217
+ };
218
+
219
+ AbstractChosen.prototype.keyup_checker = function(evt) {
220
+ var stroke, _ref;
221
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
222
+ this.search_field_scale();
223
+ switch (stroke) {
224
+ case 8:
225
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
226
+ return this.keydown_backstroke();
227
+ } else if (!this.pending_backstroke) {
228
+ this.result_clear_highlight();
229
+ return this.results_search();
230
+ }
231
+ break;
232
+ case 13:
233
+ evt.preventDefault();
234
+ if (this.results_showing) return this.result_select(evt);
235
+ break;
236
+ case 27:
237
+ if (this.results_showing) this.results_hide();
238
+ return true;
239
+ case 9:
240
+ case 38:
241
+ case 40:
242
+ case 16:
243
+ case 91:
244
+ case 17:
245
+ break;
246
+ default:
247
+ return this.results_search();
248
+ }
249
+ };
250
+
251
+ AbstractChosen.prototype.generate_field_id = function() {
252
+ var new_id;
253
+ new_id = this.generate_random_id();
254
+ this.form_field.id = new_id;
255
+ return new_id;
256
+ };
257
+
258
+ AbstractChosen.prototype.generate_random_char = function() {
259
+ var chars, newchar, rand;
260
+ chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
261
+ rand = Math.floor(Math.random() * chars.length);
262
+ return newchar = chars.substring(rand, rand + 1);
263
+ };
264
+
265
+ return AbstractChosen;
266
+
267
+ })();
268
+
269
+ root.AbstractChosen = AbstractChosen;
270
+
271
+ }).call(this);
272
+
273
+ /*
274
+ Chosen source: generate output using 'cake build'
275
+ Copyright (c) 2011 by Harvest
276
+ */
277
+
278
+ (function() {
279
+ var $, Chosen, get_side_border_padding, root,
280
+ __hasProp = Object.prototype.hasOwnProperty,
281
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
282
+
283
+ root = this;
284
+
285
+ $ = jQuery;
286
+
287
+ $.fn.extend({
288
+ chosen: function(options) {
289
+ if ($.browser.msie && ($.browser.version === "6.0" || ($.browser.version === "7.0" && document.documentMode === 7))) {
290
+ return this;
291
+ }
292
+ return this.each(function(input_field) {
293
+ var $this;
294
+ $this = $(this);
295
+ if (!$this.hasClass("chzn-done")) {
296
+ return $this.data('chosen', new Chosen(this, options));
297
+ }
298
+ });
299
+ }
300
+ });
301
+
302
+ Chosen = (function(_super) {
303
+
304
+ __extends(Chosen, _super);
305
+
306
+ function Chosen() {
307
+ Chosen.__super__.constructor.apply(this, arguments);
308
+ }
309
+
310
+ Chosen.prototype.setup = function() {
311
+ this.form_field_jq = $(this.form_field);
312
+ this.current_value = this.form_field_jq.val();
313
+ return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
314
+ };
315
+
316
+ Chosen.prototype.finish_setup = function() {
317
+ return this.form_field_jq.addClass("chzn-done");
318
+ };
319
+
320
+ Chosen.prototype.set_up_html = function() {
321
+ var container_div, dd_top, dd_width, sf_width;
322
+ this.container_id = this.form_field.id.length ? this.form_field.id.replace(/[^\w]/g, '_') : this.generate_field_id();
323
+ this.container_id += "_chzn";
324
+ this.f_width = this.form_field_jq.outerWidth();
325
+ container_div = $("<div />", {
326
+ id: this.container_id,
327
+ "class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
328
+ style: 'width: ' + this.f_width + 'px;'
329
+ });
330
+ if (this.is_multiple) {
331
+ container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
332
+ } else {
333
+ container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default" tabindex="-1"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" autocomplete="off" /></div><ul class="chzn-results"></ul></div>');
334
+ }
335
+ this.form_field_jq.hide().after(container_div);
336
+ this.container = $('#' + this.container_id);
337
+ this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
338
+ this.dropdown = this.container.find('div.chzn-drop').first();
339
+ dd_top = this.container.height();
340
+ dd_width = this.f_width - get_side_border_padding(this.dropdown);
341
+ this.dropdown.css({
342
+ "width": dd_width + "px",
343
+ "top": dd_top + "px"
344
+ });
345
+ this.search_field = this.container.find('input').first();
346
+ this.search_results = this.container.find('ul.chzn-results').first();
347
+ this.search_field_scale();
348
+ this.search_no_results = this.container.find('li.no-results').first();
349
+ if (this.is_multiple) {
350
+ this.search_choices = this.container.find('ul.chzn-choices').first();
351
+ this.search_container = this.container.find('li.search-field').first();
352
+ } else {
353
+ this.search_container = this.container.find('div.chzn-search').first();
354
+ this.selected_item = this.container.find('.chzn-single').first();
355
+ sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
356
+ this.search_field.css({
357
+ "width": sf_width + "px"
358
+ });
359
+ }
360
+ this.results_build();
361
+ this.set_tab_index();
362
+ return this.form_field_jq.trigger("liszt:ready", {
363
+ chosen: this
364
+ });
365
+ };
366
+
367
+ Chosen.prototype.register_observers = function() {
368
+ var _this = this;
369
+ this.container.mousedown(function(evt) {
370
+ return _this.container_mousedown(evt);
371
+ });
372
+ this.container.mouseup(function(evt) {
373
+ return _this.container_mouseup(evt);
374
+ });
375
+ this.container.mouseenter(function(evt) {
376
+ return _this.mouse_enter(evt);
377
+ });
378
+ this.container.mouseleave(function(evt) {
379
+ return _this.mouse_leave(evt);
380
+ });
381
+ this.search_results.mouseup(function(evt) {
382
+ return _this.search_results_mouseup(evt);
383
+ });
384
+ this.search_results.mouseover(function(evt) {
385
+ return _this.search_results_mouseover(evt);
386
+ });
387
+ this.search_results.mouseout(function(evt) {
388
+ return _this.search_results_mouseout(evt);
389
+ });
390
+ this.form_field_jq.bind("liszt:updated", function(evt) {
391
+ return _this.results_update_field(evt);
392
+ });
393
+ this.form_field_jq.bind("liszt:activate", function(evt) {
394
+ return _this.activate_field(evt);
395
+ });
396
+ this.form_field_jq.bind("liszt:open", function(evt) {
397
+ return _this.container_mousedown(evt);
398
+ });
399
+ this.search_field.blur(function(evt) {
400
+ return _this.input_blur(evt);
401
+ });
402
+ this.search_field.keyup(function(evt) {
403
+ return _this.keyup_checker(evt);
404
+ });
405
+ this.search_field.keydown(function(evt) {
406
+ return _this.keydown_checker(evt);
407
+ });
408
+ this.search_field.focus(function(evt) {
409
+ return _this.input_focus(evt);
410
+ });
411
+ if (this.is_multiple) {
412
+ return this.search_choices.click(function(evt) {
413
+ return _this.choices_click(evt);
414
+ });
415
+ } else {
416
+ return this.container.click(function(evt) {
417
+ return evt.preventDefault();
418
+ });
419
+ }
420
+ };
421
+
422
+ Chosen.prototype.search_field_disabled = function() {
423
+ this.is_disabled = this.form_field_jq[0].disabled;
424
+ if (this.is_disabled) {
425
+ this.container.addClass('chzn-disabled');
426
+ this.search_field[0].disabled = true;
427
+ if (!this.is_multiple) {
428
+ this.selected_item.unbind("focus", this.activate_action);
429
+ }
430
+ return this.close_field();
431
+ } else {
432
+ this.container.removeClass('chzn-disabled');
433
+ this.search_field[0].disabled = false;
434
+ if (!this.is_multiple) {
435
+ return this.selected_item.bind("focus", this.activate_action);
436
+ }
437
+ }
438
+ };
439
+
440
+ Chosen.prototype.container_mousedown = function(evt) {
441
+ var target_closelink;
442
+ if (!this.is_disabled) {
443
+ target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
444
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
445
+ evt.stopPropagation();
446
+ }
447
+ if (!this.pending_destroy_click && !target_closelink) {
448
+ if (!this.active_field) {
449
+ if (this.is_multiple) this.search_field.val("");
450
+ $(document).click(this.click_test_action);
451
+ this.results_show();
452
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
453
+ evt.preventDefault();
454
+ this.results_toggle();
455
+ }
456
+ return this.activate_field();
457
+ } else {
458
+ return this.pending_destroy_click = false;
459
+ }
460
+ }
461
+ };
462
+
463
+ Chosen.prototype.container_mouseup = function(evt) {
464
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
465
+ return this.results_reset(evt);
466
+ }
467
+ };
468
+
469
+ Chosen.prototype.blur_test = function(evt) {
470
+ if (!this.active_field && this.container.hasClass("chzn-container-active")) {
471
+ return this.close_field();
472
+ }
473
+ };
474
+
475
+ Chosen.prototype.close_field = function() {
476
+ $(document).unbind("click", this.click_test_action);
477
+ this.active_field = false;
478
+ this.results_hide();
479
+ this.container.removeClass("chzn-container-active");
480
+ this.winnow_results_clear();
481
+ this.clear_backstroke();
482
+ this.show_search_field_default();
483
+ return this.search_field_scale();
484
+ };
485
+
486
+ Chosen.prototype.activate_field = function() {
487
+ this.container.addClass("chzn-container-active");
488
+ this.active_field = true;
489
+ this.search_field.val(this.search_field.val());
490
+ return this.search_field.focus();
491
+ };
492
+
493
+ Chosen.prototype.test_active_click = function(evt) {
494
+ if ($(evt.target).parents('#' + this.container_id).length) {
495
+ return this.active_field = true;
496
+ } else {
497
+ return this.close_field();
498
+ }
499
+ };
500
+
501
+ Chosen.prototype.results_build = function() {
502
+ var content, data, _i, _len, _ref;
503
+ this.parsing = true;
504
+ this.results_data = root.SelectParser.select_to_array(this.form_field);
505
+ if (this.is_multiple && this.choices > 0) {
506
+ this.search_choices.find("li.search-choice").remove();
507
+ this.choices = 0;
508
+ } else if (!this.is_multiple) {
509
+ this.selected_item.addClass("chzn-default").find("span").text(this.default_text);
510
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
511
+ this.container.addClass("chzn-container-single-nosearch");
512
+ } else {
513
+ this.container.removeClass("chzn-container-single-nosearch");
514
+ }
515
+ }
516
+ content = '';
517
+ _ref = this.results_data;
518
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
519
+ data = _ref[_i];
520
+ if (data.group) {
521
+ content += this.result_add_group(data);
522
+ } else if (!data.empty) {
523
+ content += this.result_add_option(data);
524
+ if (data.selected && this.is_multiple) {
525
+ this.choice_build(data);
526
+ } else if (data.selected && !this.is_multiple) {
527
+ this.selected_item.removeClass("chzn-default").find("span").text(data.text);
528
+ if (this.allow_single_deselect) this.single_deselect_control_build();
529
+ }
530
+ }
531
+ }
532
+ this.search_field_disabled();
533
+ this.show_search_field_default();
534
+ this.search_field_scale();
535
+ this.search_results.html(content);
536
+ return this.parsing = false;
537
+ };
538
+
539
+ Chosen.prototype.result_add_group = function(group) {
540
+ if (!group.disabled) {
541
+ group.dom_id = this.container_id + "_g_" + group.array_index;
542
+ return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
543
+ } else {
544
+ return "";
545
+ }
546
+ };
547
+
548
+ Chosen.prototype.result_do_highlight = function(el) {
549
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
550
+ if (el.length) {
551
+ this.result_clear_highlight();
552
+ this.result_highlight = el;
553
+ this.result_highlight.addClass("highlighted");
554
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
555
+ visible_top = this.search_results.scrollTop();
556
+ visible_bottom = maxHeight + visible_top;
557
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
558
+ high_bottom = high_top + this.result_highlight.outerHeight();
559
+ if (high_bottom >= visible_bottom) {
560
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
561
+ } else if (high_top < visible_top) {
562
+ return this.search_results.scrollTop(high_top);
563
+ }
564
+ }
565
+ };
566
+
567
+ Chosen.prototype.result_clear_highlight = function() {
568
+ if (this.result_highlight) this.result_highlight.removeClass("highlighted");
569
+ return this.result_highlight = null;
570
+ };
571
+
572
+ Chosen.prototype.results_show = function() {
573
+ var dd_top;
574
+ if (!this.is_multiple) {
575
+ this.selected_item.addClass("chzn-single-with-drop");
576
+ if (this.result_single_selected) {
577
+ this.result_do_highlight(this.result_single_selected);
578
+ }
579
+ } else if (this.max_selected_options <= this.choices) {
580
+ this.form_field_jq.trigger("liszt:maxselected", {
581
+ chosen: this
582
+ });
583
+ return false;
584
+ }
585
+ dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
586
+ this.form_field_jq.trigger("liszt:showing_dropdown", {
587
+ chosen: this
588
+ });
589
+ this.dropdown.css({
590
+ "top": dd_top + "px",
591
+ "left": 0
592
+ });
593
+ this.results_showing = true;
594
+ this.search_field.focus();
595
+ this.search_field.val(this.search_field.val());
596
+ return this.winnow_results();
597
+ };
598
+
599
+ Chosen.prototype.results_hide = function() {
600
+ if (!this.is_multiple) {
601
+ this.selected_item.removeClass("chzn-single-with-drop");
602
+ }
603
+ this.result_clear_highlight();
604
+ this.form_field_jq.trigger("liszt:hiding_dropdown", {
605
+ chosen: this
606
+ });
607
+ this.dropdown.css({
608
+ "left": "-9000px"
609
+ });
610
+ return this.results_showing = false;
611
+ };
612
+
613
+ Chosen.prototype.set_tab_index = function(el) {
614
+ var ti;
615
+ if (this.form_field_jq.attr("tabindex")) {
616
+ ti = this.form_field_jq.attr("tabindex");
617
+ this.form_field_jq.attr("tabindex", -1);
618
+ return this.search_field.attr("tabindex", ti);
619
+ }
620
+ };
621
+
622
+ Chosen.prototype.show_search_field_default = function() {
623
+ if (this.is_multiple && this.choices < 1 && !this.active_field) {
624
+ this.search_field.val(this.default_text);
625
+ return this.search_field.addClass("default");
626
+ } else {
627
+ this.search_field.val("");
628
+ return this.search_field.removeClass("default");
629
+ }
630
+ };
631
+
632
+ Chosen.prototype.search_results_mouseup = function(evt) {
633
+ var target;
634
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
635
+ if (target.length) {
636
+ this.result_highlight = target;
637
+ this.result_select(evt);
638
+ return this.search_field.focus();
639
+ }
640
+ };
641
+
642
+ Chosen.prototype.search_results_mouseover = function(evt) {
643
+ var target;
644
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
645
+ if (target) return this.result_do_highlight(target);
646
+ };
647
+
648
+ Chosen.prototype.search_results_mouseout = function(evt) {
649
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
650
+ return this.result_clear_highlight();
651
+ }
652
+ };
653
+
654
+ Chosen.prototype.choices_click = function(evt) {
655
+ evt.preventDefault();
656
+ if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
657
+ return this.results_show();
658
+ }
659
+ };
660
+
661
+ Chosen.prototype.choice_build = function(item) {
662
+ var choice_id, html, link,
663
+ _this = this;
664
+ if (this.is_multiple && this.max_selected_options <= this.choices) {
665
+ this.form_field_jq.trigger("liszt:maxselected", {
666
+ chosen: this
667
+ });
668
+ return false;
669
+ }
670
+ choice_id = this.container_id + "_c_" + item.array_index;
671
+ this.choices += 1;
672
+ if (item.disabled) {
673
+ html = '<li class="search-choice search-choice-disabled" id="' + choice_id + '"><span>' + item.html + '</span></li>';
674
+ } else {
675
+ html = '<li class="search-choice" id="' + choice_id + '"><span>' + item.html + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>';
676
+ }
677
+ this.search_container.before(html);
678
+ link = $('#' + choice_id).find("a").first();
679
+ return link.click(function(evt) {
680
+ return _this.choice_destroy_link_click(evt);
681
+ });
682
+ };
683
+
684
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
685
+ evt.preventDefault();
686
+ if (!this.is_disabled) {
687
+ this.pending_destroy_click = true;
688
+ return this.choice_destroy($(evt.target));
689
+ } else {
690
+ return evt.stopPropagation;
691
+ }
692
+ };
693
+
694
+ Chosen.prototype.choice_destroy = function(link) {
695
+ if (this.result_deselect(link.attr("rel"))) {
696
+ this.choices -= 1;
697
+ this.show_search_field_default();
698
+ if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
699
+ this.results_hide();
700
+ }
701
+ return link.parents('li').first().remove();
702
+ }
703
+ };
704
+
705
+ Chosen.prototype.results_reset = function() {
706
+ this.form_field.options[0].selected = true;
707
+ this.selected_item.find("span").text(this.default_text);
708
+ if (!this.is_multiple) this.selected_item.addClass("chzn-default");
709
+ this.show_search_field_default();
710
+ this.results_reset_cleanup();
711
+ this.form_field_jq.trigger("change");
712
+ if (this.active_field) return this.results_hide();
713
+ };
714
+
715
+ Chosen.prototype.results_reset_cleanup = function() {
716
+ this.current_value = this.form_field_jq.val();
717
+ return this.selected_item.find("abbr").remove();
718
+ };
719
+
720
+ Chosen.prototype.result_select = function(evt) {
721
+ var high, high_id, item, position;
722
+ if (this.result_highlight) {
723
+ high = this.result_highlight;
724
+ high_id = high.attr("id");
725
+ this.result_clear_highlight();
726
+ if (this.is_multiple) {
727
+ this.result_deactivate(high);
728
+ } else {
729
+ this.search_results.find(".result-selected").removeClass("result-selected");
730
+ this.result_single_selected = high;
731
+ this.selected_item.removeClass("chzn-default");
732
+ }
733
+ high.addClass("result-selected");
734
+ position = high_id.substr(high_id.lastIndexOf("_") + 1);
735
+ item = this.results_data[position];
736
+ item.selected = true;
737
+ this.form_field.options[item.options_index].selected = true;
738
+ if (this.is_multiple) {
739
+ this.choice_build(item);
740
+ } else {
741
+ this.selected_item.find("span").first().text(item.text);
742
+ if (this.allow_single_deselect) this.single_deselect_control_build();
743
+ }
744
+ if (!(evt.metaKey && this.is_multiple)) this.results_hide();
745
+ this.search_field.val("");
746
+ if (this.is_multiple || this.form_field_jq.val() !== this.current_value) {
747
+ this.form_field_jq.trigger("change", {
748
+ 'selected': this.form_field.options[item.options_index].value
749
+ });
750
+ }
751
+ this.current_value = this.form_field_jq.val();
752
+ return this.search_field_scale();
753
+ }
754
+ };
755
+
756
+ Chosen.prototype.result_activate = function(el) {
757
+ return el.addClass("active-result");
758
+ };
759
+
760
+ Chosen.prototype.result_deactivate = function(el) {
761
+ return el.removeClass("active-result");
762
+ };
763
+
764
+ Chosen.prototype.result_deselect = function(pos) {
765
+ var result, result_data;
766
+ result_data = this.results_data[pos];
767
+ if (!this.form_field.options[result_data.options_index].disabled) {
768
+ result_data.selected = false;
769
+ this.form_field.options[result_data.options_index].selected = false;
770
+ result = $("#" + this.container_id + "_o_" + pos);
771
+ result.removeClass("result-selected").addClass("active-result").show();
772
+ this.result_clear_highlight();
773
+ this.winnow_results();
774
+ this.form_field_jq.trigger("change", {
775
+ deselected: this.form_field.options[result_data.options_index].value
776
+ });
777
+ this.search_field_scale();
778
+ return true;
779
+ } else {
780
+ return false;
781
+ }
782
+ };
783
+
784
+ Chosen.prototype.single_deselect_control_build = function() {
785
+ if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
786
+ return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
787
+ }
788
+ };
789
+
790
+ Chosen.prototype.winnow_results = function() {
791
+ var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
792
+ this.no_results_clear();
793
+ results = 0;
794
+ searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
795
+ regexAnchor = this.search_contains ? "" : "^";
796
+ regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
797
+ zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
798
+ _ref = this.results_data;
799
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
800
+ option = _ref[_i];
801
+ if (!option.disabled && !option.empty) {
802
+ if (option.group) {
803
+ $('#' + option.dom_id).css('display', 'none');
804
+ } else if (!(this.is_multiple && option.selected)) {
805
+ found = false;
806
+ result_id = option.dom_id;
807
+ result = $("#" + result_id);
808
+ if (regex.test(option.html)) {
809
+ found = true;
810
+ results += 1;
811
+ } else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
812
+ parts = option.html.replace(/\[|\]/g, "").split(" ");
813
+ if (parts.length) {
814
+ for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
815
+ part = parts[_j];
816
+ if (regex.test(part)) {
817
+ found = true;
818
+ results += 1;
819
+ }
820
+ }
821
+ }
822
+ }
823
+ if (found) {
824
+ if (searchText.length) {
825
+ startpos = option.html.search(zregex);
826
+ text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
827
+ text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
828
+ } else {
829
+ text = option.html;
830
+ }
831
+ result.html(text);
832
+ this.result_activate(result);
833
+ if (option.group_array_index != null) {
834
+ $("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
835
+ }
836
+ } else {
837
+ if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
838
+ this.result_clear_highlight();
839
+ }
840
+ this.result_deactivate(result);
841
+ }
842
+ }
843
+ }
844
+ }
845
+ if (results < 1 && searchText.length) {
846
+ return this.no_results(searchText);
847
+ } else {
848
+ return this.winnow_results_set_highlight();
849
+ }
850
+ };
851
+
852
+ Chosen.prototype.winnow_results_clear = function() {
853
+ var li, lis, _i, _len, _results;
854
+ this.search_field.val("");
855
+ lis = this.search_results.find("li");
856
+ _results = [];
857
+ for (_i = 0, _len = lis.length; _i < _len; _i++) {
858
+ li = lis[_i];
859
+ li = $(li);
860
+ if (li.hasClass("group-result")) {
861
+ _results.push(li.css('display', 'auto'));
862
+ } else if (!this.is_multiple || !li.hasClass("result-selected")) {
863
+ _results.push(this.result_activate(li));
864
+ } else {
865
+ _results.push(void 0);
866
+ }
867
+ }
868
+ return _results;
869
+ };
870
+
871
+ Chosen.prototype.winnow_results_set_highlight = function() {
872
+ var do_high, selected_results;
873
+ if (!this.result_highlight) {
874
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
875
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
876
+ if (do_high != null) return this.result_do_highlight(do_high);
877
+ }
878
+ };
879
+
880
+ Chosen.prototype.no_results = function(terms) {
881
+ var no_results_html;
882
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
883
+ no_results_html.find("span").first().html(terms);
884
+ return this.search_results.append(no_results_html);
885
+ };
886
+
887
+ Chosen.prototype.no_results_clear = function() {
888
+ return this.search_results.find(".no-results").remove();
889
+ };
890
+
891
+ Chosen.prototype.keydown_arrow = function() {
892
+ var first_active, next_sib;
893
+ if (!this.result_highlight) {
894
+ first_active = this.search_results.find("li.active-result").first();
895
+ if (first_active) this.result_do_highlight($(first_active));
896
+ } else if (this.results_showing) {
897
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
898
+ if (next_sib) this.result_do_highlight(next_sib);
899
+ }
900
+ if (!this.results_showing) return this.results_show();
901
+ };
902
+
903
+ Chosen.prototype.keyup_arrow = function() {
904
+ var prev_sibs;
905
+ if (!this.results_showing && !this.is_multiple) {
906
+ return this.results_show();
907
+ } else if (this.result_highlight) {
908
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
909
+ if (prev_sibs.length) {
910
+ return this.result_do_highlight(prev_sibs.first());
911
+ } else {
912
+ if (this.choices > 0) this.results_hide();
913
+ return this.result_clear_highlight();
914
+ }
915
+ }
916
+ };
917
+
918
+ Chosen.prototype.keydown_backstroke = function() {
919
+ var next_available_destroy;
920
+ if (this.pending_backstroke) {
921
+ this.choice_destroy(this.pending_backstroke.find("a").first());
922
+ return this.clear_backstroke();
923
+ } else {
924
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
925
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
926
+ this.pending_backstroke = next_available_destroy;
927
+ if (this.single_backstroke_delete) {
928
+ return this.keydown_backstroke();
929
+ } else {
930
+ return this.pending_backstroke.addClass("search-choice-focus");
931
+ }
932
+ }
933
+ }
934
+ };
935
+
936
+ Chosen.prototype.clear_backstroke = function() {
937
+ if (this.pending_backstroke) {
938
+ this.pending_backstroke.removeClass("search-choice-focus");
939
+ }
940
+ return this.pending_backstroke = null;
941
+ };
942
+
943
+ Chosen.prototype.keydown_checker = function(evt) {
944
+ var stroke, _ref;
945
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
946
+ this.search_field_scale();
947
+ if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
948
+ switch (stroke) {
949
+ case 8:
950
+ this.backstroke_length = this.search_field.val().length;
951
+ break;
952
+ case 9:
953
+ if (this.results_showing && !this.is_multiple) this.result_select(evt);
954
+ this.mouse_on_container = false;
955
+ break;
956
+ case 13:
957
+ evt.preventDefault();
958
+ break;
959
+ case 38:
960
+ evt.preventDefault();
961
+ this.keyup_arrow();
962
+ break;
963
+ case 40:
964
+ this.keydown_arrow();
965
+ break;
966
+ }
967
+ };
968
+
969
+ Chosen.prototype.search_field_scale = function() {
970
+ var dd_top, div, h, style, style_block, styles, w, _i, _len;
971
+ if (this.is_multiple) {
972
+ h = 0;
973
+ w = 0;
974
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
975
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
976
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
977
+ style = styles[_i];
978
+ style_block += style + ":" + this.search_field.css(style) + ";";
979
+ }
980
+ div = $('<div />', {
981
+ 'style': style_block
982
+ });
983
+ div.text(this.search_field.val());
984
+ $('body').append(div);
985
+ w = div.width() + 25;
986
+ div.remove();
987
+ if (w > this.f_width - 10) w = this.f_width - 10;
988
+ this.search_field.css({
989
+ 'width': w + 'px'
990
+ });
991
+ dd_top = this.container.height();
992
+ return this.dropdown.css({
993
+ "top": dd_top + "px"
994
+ });
995
+ }
996
+ };
997
+
998
+ Chosen.prototype.generate_random_id = function() {
999
+ var string;
1000
+ string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
1001
+ while ($("#" + string).length > 0) {
1002
+ string += this.generate_random_char();
1003
+ }
1004
+ return string;
1005
+ };
1006
+
1007
+ return Chosen;
1008
+
1009
+ })(AbstractChosen);
1010
+
1011
+ get_side_border_padding = function(elmt) {
1012
+ var side_border_padding;
1013
+ return side_border_padding = elmt.outerWidth() - elmt.width();
1014
+ };
1015
+
1016
+ root.get_side_border_padding = get_side_border_padding;
1017
+
1018
+ }).call(this);