social_stream-base 0.9.21 → 0.9.22

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 (35) hide show
  1. data/app/assets/images/lightbox-blank.gif +0 -0
  2. data/app/assets/images/lightbox-btn-close.gif +0 -0
  3. data/app/assets/images/lightbox-btn-next.gif +0 -0
  4. data/app/assets/images/lightbox-btn-prev.gif +0 -0
  5. data/app/assets/images/lightbox-ico-loading.gif +0 -0
  6. data/app/assets/javascripts/activities.js.erb +40 -5
  7. data/app/assets/javascripts/activities_security_chosen-modified.jquery.js +767 -0
  8. data/app/assets/javascripts/messages.js +1 -0
  9. data/app/assets/javascripts/social_stream-base.js +1 -0
  10. data/app/assets/stylesheets/base.css.scss +1 -1
  11. data/app/assets/stylesheets/messages.css.scss +1 -0
  12. data/app/controllers/contacts_controller.rb +11 -7
  13. data/app/controllers/groups_controller.rb +11 -2
  14. data/app/views/activities/_new.html.erb +16 -2
  15. data/app/views/activities/index.js.erb +2 -0
  16. data/app/views/comments/create.js.erb +2 -0
  17. data/app/views/conversations/_conversation_full.html.erb +62 -44
  18. data/app/views/conversations/show.html.erb +1 -1
  19. data/app/views/conversations/show.js.erb +1 -1
  20. data/app/views/home/index.js.erb +3 -0
  21. data/app/views/layouts/_header_signed_in.erb +1 -0
  22. data/app/views/messages/new.js.erb +1 -1
  23. data/app/views/settings/_destroy.html.erb +17 -0
  24. data/app/views/settings/_index.html.erb +3 -2
  25. data/app/views/subjects/_show.js.erb +3 -0
  26. data/config/locales/en.yml +5 -0
  27. data/config/locales/es.yml +6 -1
  28. data/lib/social_stream/base/version.rb +1 -1
  29. data/spec/controllers/contacts_controller_spec.rb +8 -1
  30. data/spec/controllers/groups_controller_spec.rb +8 -11
  31. data/vendor/assets/javascripts/jquery.ae.image.resize.js +69 -0
  32. data/vendor/assets/javascripts/jquery.lightbox-with-resize-plugin.js +533 -0
  33. metadata +13 -6
  34. data/app/views/settings/_contacts.html.erb +0 -16
  35. data/vendor/assets/javascripts/chosen.jquery.js +0 -755
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-base
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 21
10
- version: 0.9.21
9
+ - 22
10
+ version: 0.9.22
11
11
  platform: ruby
12
12
  authors:
13
13
  - GING - DIT - UPM
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-17 00:00:00 +02:00
19
+ date: 2011-10-19 00:00:00 +02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -610,6 +610,11 @@ files:
610
610
  - app/assets/images/icon_checkbox.png
611
611
  - app/assets/images/icons/favicon.ico
612
612
  - app/assets/images/left.png
613
+ - app/assets/images/lightbox-blank.gif
614
+ - app/assets/images/lightbox-btn-close.gif
615
+ - app/assets/images/lightbox-btn-next.gif
616
+ - app/assets/images/lightbox-btn-prev.gif
617
+ - app/assets/images/lightbox-ico-loading.gif
613
618
  - app/assets/images/loader.gif
614
619
  - app/assets/images/loading.gif
615
620
  - app/assets/images/logo.png
@@ -629,6 +634,7 @@ files:
629
634
  - app/assets/images/right.png
630
635
  - app/assets/images/tipsy.gif
631
636
  - app/assets/javascripts/activities.js.erb
637
+ - app/assets/javascripts/activities_security_chosen-modified.jquery.js
632
638
  - app/assets/javascripts/contacts.js
633
639
  - app/assets/javascripts/conversations.js
634
640
  - app/assets/javascripts/groups.js
@@ -903,7 +909,7 @@ files:
903
909
  - app/views/search/index.html.erb
904
910
  - app/views/search/index.js.erb
905
911
  - app/views/settings/_api_key.html.erb
906
- - app/views/settings/_contacts.html.erb
912
+ - app/views/settings/_destroy.html.erb
907
913
  - app/views/settings/_index.html.erb
908
914
  - app/views/settings/_notifications.html.erb
909
915
  - app/views/settings/index.html.erb
@@ -1046,15 +1052,16 @@ files:
1046
1052
  - spec/support/devise.rb
1047
1053
  - spec/support/mock.rb
1048
1054
  - vendor/assets/javascripts/ajax.paginate.js
1049
- - vendor/assets/javascripts/chosen.jquery.js
1050
1055
  - vendor/assets/javascripts/d3.geom.js
1051
1056
  - vendor/assets/javascripts/d3.js
1052
1057
  - vendor/assets/javascripts/d3.layout.js
1053
1058
  - vendor/assets/javascripts/hoverIntent.js
1054
1059
  - vendor/assets/javascripts/jqcloud-0.1.3.js
1060
+ - vendor/assets/javascripts/jquery.ae.image.resize.js
1055
1061
  - vendor/assets/javascripts/jquery.ba-url.js
1056
1062
  - vendor/assets/javascripts/jquery.cleditor.min.js
1057
1063
  - vendor/assets/javascripts/jquery.fcbkcomplete.js
1064
+ - vendor/assets/javascripts/jquery.lightbox-with-resize-plugin.js
1058
1065
  - vendor/assets/javascripts/jquery.livequery.js
1059
1066
  - vendor/assets/javascripts/jquery.scrollTo.min.js
1060
1067
  - vendor/assets/javascripts/jquery.tipsy.js
@@ -1,16 +0,0 @@
1
- <div class="block" id="manage_settings">
2
- <div class="header">
3
- <div class="header_text">
4
- <%= t('settings.manage.name')%>
5
- </div>
6
- <div class="header_icon_right">
7
- <%= link_to image_tag('btn/edit.png'), contacts_path %>
8
- </div>
9
- </div>
10
- <div class="content" id="contact_settings_briefing">
11
- <div class="form_row">
12
- <%= t('settings.manage.briefing')%>
13
- </div>
14
- </div>
15
- </div>
16
-
@@ -1,755 +0,0 @@
1
- (function() {
2
- /*
3
- Chosen, a Select Box Enhancer for jQuery and Protoype
4
- by Patrick Filler for Harvest, http://getharvest.com
5
-
6
- Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
7
-
8
- Copyright (c) 2011 by Harvest
9
- */ var $, Chosen, SelectParser, get_side_border_padding, root;
10
- var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
11
- root = typeof exports !== "undefined" && exports !== null ? exports : this;
12
- $ = jQuery;
13
- $.fn.extend({
14
- chosen: function(data, options) {
15
- return $(this).each(function(input_field) {
16
- if (!($(this)).hasClass("chzn-done")) {
17
- return new Chosen(this, data, options);
18
- }
19
- });
20
- }
21
- });
22
- Chosen = (function() {
23
- function Chosen(elmn) {
24
- this.set_default_values();
25
- this.form_field = elmn;
26
- this.form_field_jq = $(this.form_field);
27
- this.is_multiple = this.form_field.multiple;
28
- this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
29
- this.set_up_html();
30
- this.register_observers();
31
- this.form_field_jq.addClass("chzn-done");
32
- }
33
- Chosen.prototype.set_default_values = function() {
34
- this.click_test_action = __bind(function(evt) {
35
- return this.test_active_click(evt);
36
- }, this);
37
- this.active_field = false;
38
- this.mouse_on_container = false;
39
- this.results_showing = false;
40
- this.result_highlighted = null;
41
- this.result_single_selected = null;
42
- return this.choices = 0;
43
- };
44
- Chosen.prototype.set_up_html = function() {
45
- var container_div, dd_top, dd_width, sf_width;
46
- this.container_id = this.form_field.id + "_chzn";
47
- this.f_width = this.form_field_jq.width();
48
- this.default_text = this.form_field_jq.attr('title') ? this.form_field_jq.attr('title') : this.default_text_default;
49
- container_div = $("<div />", {
50
- id: this.container_id,
51
- "class": 'chzn-container'
52
- // style: 'width: ' + this.f_width + 'px;'
53
- });
54
- if (this.is_multiple) {
55
- container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
56
- } else {
57
- container_div.html('<a href="javascript:void(0)" class="chzn-single"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" /></div><ul class="chzn-results"></ul></div>');
58
- }
59
- this.form_field_jq.hide().after(container_div);
60
- this.container = $('#' + this.container_id);
61
- this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
62
- this.dropdown = this.container.find('div.chzn-drop').first();
63
- dd_top = this.container.height();
64
- dd_width = this.f_width - get_side_border_padding(this.dropdown);
65
- this.dropdown.css({
66
- "width": dd_width + "px",
67
- "top": dd_top + "px"
68
- });
69
- this.search_field = this.container.find('input').first();
70
- this.search_results = this.container.find('ul.chzn-results').first();
71
- this.search_field_scale();
72
- this.search_no_results = this.container.find('li.no-results').first();
73
- if (this.is_multiple) {
74
- this.search_choices = this.container.find('ul.chzn-choices').first();
75
- this.search_container = this.container.find('li.search-field').first();
76
- } else {
77
- this.search_container = this.container.find('div.chzn-search').first();
78
- this.selected_item = this.container.find('.chzn-single').first();
79
- sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
80
- this.search_field.css({
81
- "width": sf_width + "px"
82
- });
83
- }
84
- this.results_build();
85
- return this.set_tab_index();
86
- };
87
- Chosen.prototype.register_observers = function() {
88
- this.container.click(__bind(function(evt) {
89
- return this.container_click(evt);
90
- }, this));
91
- this.container.mouseenter(__bind(function(evt) {
92
- return this.mouse_enter(evt);
93
- }, this));
94
- this.container.mouseleave(__bind(function(evt) {
95
- return this.mouse_leave(evt);
96
- }, this));
97
- this.search_results.click(__bind(function(evt) {
98
- return this.search_results_click(evt);
99
- }, this));
100
- this.search_results.mouseover(__bind(function(evt) {
101
- return this.search_results_mouseover(evt);
102
- }, this));
103
- this.search_results.mouseout(__bind(function(evt) {
104
- return this.search_results_mouseout(evt);
105
- }, this));
106
- this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
107
- return this.results_update_field(evt);
108
- }, this));
109
- this.search_field.blur(__bind(function(evt) {
110
- return this.input_blur(evt);
111
- }, this));
112
- this.search_field.keyup(__bind(function(evt) {
113
- return this.keyup_checker(evt);
114
- }, this));
115
- this.search_field.keydown(__bind(function(evt) {
116
- return this.keydown_checker(evt);
117
- }, this));
118
- if (this.is_multiple) {
119
- this.search_choices.click(__bind(function(evt) {
120
- return this.choices_click(evt);
121
- }, this));
122
- return this.search_field.focus(__bind(function(evt) {
123
- return this.input_focus(evt);
124
- }, this));
125
- } else {
126
- return this.selected_item.focus(__bind(function(evt) {
127
- return this.activate_field(evt);
128
- }, this));
129
- }
130
- };
131
- Chosen.prototype.container_click = function(evt) {
132
- if (evt && evt.type === "click") {
133
- evt.stopPropagation();
134
- }
135
- if (!this.pending_destroy_click) {
136
- if (!this.active_field) {
137
- if (this.is_multiple) {
138
- this.search_field.val("");
139
- }
140
- $(document).click(this.click_test_action);
141
- this.results_show();
142
- } else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
143
- evt.preventDefault();
144
- this.results_toggle();
145
- }
146
- return this.activate_field();
147
- } else {
148
- return this.pending_destroy_click = false;
149
- }
150
- };
151
- Chosen.prototype.mouse_enter = function() {
152
- return this.mouse_on_container = true;
153
- };
154
- Chosen.prototype.mouse_leave = function() {
155
- return this.mouse_on_container = false;
156
- };
157
- Chosen.prototype.input_focus = function(evt) {
158
- if (!this.active_field) {
159
- return setTimeout((__bind(function() {
160
- return this.container_click();
161
- }, this)), 50);
162
- }
163
- };
164
- Chosen.prototype.input_blur = function(evt) {
165
- if (!this.mouse_on_container) {
166
- this.active_field = false;
167
- return setTimeout((__bind(function() {
168
- return this.blur_test();
169
- }, this)), 100);
170
- }
171
- };
172
- Chosen.prototype.blur_test = function(evt) {
173
- if (!this.active_field && this.container.hasClass("chzn-container-active")) {
174
- return this.close_field();
175
- }
176
- };
177
- Chosen.prototype.close_field = function() {
178
- $(document).unbind("click", this.click_test_action);
179
- if (!this.is_multiple) {
180
- this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
181
- this.search_field.attr("tabindex", -1);
182
- }
183
- this.active_field = false;
184
- this.results_hide();
185
- this.container.removeClass("chzn-container-active");
186
- this.winnow_results_clear();
187
- this.clear_backstroke();
188
- this.show_search_field_default();
189
- return this.search_field_scale();
190
- };
191
- Chosen.prototype.activate_field = function() {
192
- if (!this.is_multiple && !this.active_field) {
193
- this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
194
- this.selected_item.attr("tabindex", -1);
195
- }
196
- this.container.addClass("chzn-container-active");
197
- this.active_field = true;
198
- this.search_field.val(this.search_field.val());
199
- return this.search_field.focus();
200
- };
201
- Chosen.prototype.test_active_click = function(evt) {
202
- if ($(evt.target).parents('#' + this.container.id).length) {
203
- return this.active_field = true;
204
- } else {
205
- return this.close_field();
206
- }
207
- };
208
- Chosen.prototype.results_build = function() {
209
- var content, data, startTime, _i, _len, _ref;
210
- startTime = new Date();
211
- this.parsing = true;
212
- this.results_data = SelectParser.select_to_array(this.form_field);
213
- if (this.is_multiple && this.choices > 0) {
214
- this.search_choices.find("li.search-choice").remove();
215
- this.choices = 0;
216
- } else if (!this.is_multiple) {
217
- this.selected_item.find("span").text(this.default_text);
218
- }
219
- content = '';
220
- _ref = this.results_data;
221
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
222
- data = _ref[_i];
223
- if (data.group) {
224
- content += this.result_add_group(data);
225
- } else if (!data.empty) {
226
- content += this.result_add_option(data);
227
- if (data.selected && this.is_multiple) {
228
- this.choice_build(data);
229
- } else if (data.selected && !this.is_multiple) {
230
- this.selected_item.find("span").text(data.text);
231
- }
232
- }
233
- }
234
- this.show_search_field_default();
235
- this.search_field_scale();
236
- this.search_results.html(content);
237
- return this.parsing = false;
238
- };
239
- Chosen.prototype.result_add_group = function(group) {
240
- if (!group.disabled) {
241
- group.dom_id = this.form_field.id + "chzn_g_" + group.array_index;
242
- return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
243
- } else {
244
- return "";
245
- }
246
- };
247
- Chosen.prototype.result_add_option = function(option) {
248
- var classes;
249
- if (!option.disabled) {
250
- option.dom_id = this.form_field.id + "chzn_o_" + option.array_index;
251
- classes = option.selected && this.is_multiple ? [] : ["active-result"];
252
- if (option.selected) {
253
- classes.push("result-selected");
254
- }
255
- if (option.group_array_index != null) {
256
- classes.push("group-option");
257
- }
258
- return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + $("<div />").text(option.text).html() + '</li>';
259
- } else {
260
- return "";
261
- }
262
- };
263
- Chosen.prototype.results_update_field = function() {
264
- this.result_clear_highlight();
265
- this.result_single_selected = null;
266
- return this.results_build();
267
- };
268
- Chosen.prototype.result_do_highlight = function(el) {
269
- var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
270
- if (el.length) {
271
- this.result_clear_highlight();
272
- this.result_highlight = el;
273
- this.result_highlight.addClass("highlighted");
274
- maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
275
- visible_top = this.search_results.scrollTop();
276
- visible_bottom = maxHeight + visible_top;
277
- high_top = this.result_highlight.position().top + this.search_results.scrollTop();
278
- high_bottom = high_top + this.result_highlight.outerHeight();
279
- if (high_bottom >= visible_bottom) {
280
- return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
281
- } else if (high_top < visible_top) {
282
- return this.search_results.scrollTop(high_top);
283
- }
284
- }
285
- };
286
- Chosen.prototype.result_clear_highlight = function() {
287
- if (this.result_highlight) {
288
- this.result_highlight.removeClass("highlighted");
289
- }
290
- return this.result_highlight = null;
291
- };
292
- Chosen.prototype.results_toggle = function() {
293
- if (this.results_showing) {
294
- return this.results_hide();
295
- } else {
296
- return this.results_show();
297
- }
298
- };
299
- Chosen.prototype.results_show = function() {
300
- var dd_top;
301
- if (!this.is_multiple) {
302
- this.selected_item.addClass("chzn-single-with-drop");
303
- if (this.result_single_selected) {
304
- this.result_do_highlight(this.result_single_selected);
305
- }
306
- }
307
- dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
308
- this.dropdown.css({
309
- "top": dd_top + "px",
310
- "left": 0
311
- });
312
- this.results_showing = true;
313
- this.search_field.focus();
314
- this.search_field.val(this.search_field.val());
315
- return this.winnow_results();
316
- };
317
- Chosen.prototype.results_hide = function() {
318
- if (!this.is_multiple) {
319
- this.selected_item.removeClass("chzn-single-with-drop");
320
- }
321
- this.result_clear_highlight();
322
- this.dropdown.css({
323
- "left": "-9000px"
324
- });
325
- return this.results_showing = false;
326
- };
327
- Chosen.prototype.set_tab_index = function(el) {
328
- var ti;
329
- if (this.form_field_jq.attr("tabindex")) {
330
- ti = this.form_field_jq.attr("tabindex");
331
- this.form_field_jq.attr("tabindex", -1);
332
- if (this.is_multiple) {
333
- return this.search_field.attr("tabindex", ti);
334
- } else {
335
- this.selected_item.attr("tabindex", ti);
336
- return this.search_field.attr("tabindex", -1);
337
- }
338
- }
339
- };
340
- Chosen.prototype.show_search_field_default = function() {
341
- if (this.is_multiple && this.choices < 1 && !this.active_field) {
342
- this.search_field.val(this.default_text);
343
- return this.search_field.addClass("default");
344
- } else {
345
- this.search_field.val("");
346
- return this.search_field.removeClass("default");
347
- }
348
- };
349
- Chosen.prototype.search_results_click = function(evt) {
350
- var target;
351
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
352
- if (target.length) {
353
- this.result_highlight = target;
354
- return this.result_select();
355
- }
356
- };
357
- Chosen.prototype.search_results_mouseover = function(evt) {
358
- var target;
359
- target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
360
- if (target) {
361
- return this.result_do_highlight(target);
362
- }
363
- };
364
- Chosen.prototype.search_results_mouseout = function(evt) {
365
- if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
366
- return this.result_clear_highlight();
367
- }
368
- };
369
- Chosen.prototype.choices_click = function(evt) {
370
- evt.preventDefault();
371
- if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
372
- return this.results_show();
373
- }
374
- };
375
- Chosen.prototype.choice_build = function(item) {
376
- var choice_id, link;
377
- choice_id = this.form_field.id + "_chzn_c_" + item.array_index;
378
- this.choices += 1;
379
- this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.text + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
380
- link = $('#' + choice_id).find("a").first();
381
- return link.click(__bind(function(evt) {
382
- return this.choice_destroy_link_click(evt);
383
- }, this));
384
- };
385
- Chosen.prototype.choice_destroy_link_click = function(evt) {
386
- evt.preventDefault();
387
- this.pending_destroy_click = true;
388
- return this.choice_destroy($(evt.target));
389
- };
390
- Chosen.prototype.choice_destroy = function(link) {
391
- this.choices -= 1;
392
- this.show_search_field_default();
393
- if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
394
- this.results_hide();
395
- }
396
- this.result_deselect(link.attr("rel"));
397
- return link.parents('li').first().remove();
398
- };
399
- Chosen.prototype.result_select = function() {
400
- var high, high_id, item, position;
401
- if (this.result_highlight) {
402
- high = this.result_highlight;
403
- high_id = high.attr("id");
404
- this.result_clear_highlight();
405
- high.addClass("result-selected");
406
- if (this.is_multiple) {
407
- this.result_deactivate(high);
408
- } else {
409
- this.result_single_selected = high;
410
- }
411
- position = high_id.substr(high_id.lastIndexOf("_") + 1);
412
- item = this.results_data[position];
413
- item.selected = true;
414
- this.form_field.options[item.options_index].selected = true;
415
- if (this.is_multiple) {
416
- this.choice_build(item);
417
- } else {
418
- this.selected_item.find("span").first().text(item.text);
419
- }
420
- this.results_hide();
421
- this.search_field.val("");
422
- this.form_field_jq.trigger("change");
423
- return this.search_field_scale();
424
- }
425
- };
426
- Chosen.prototype.result_activate = function(el) {
427
- return el.addClass("active-result").show();
428
- };
429
- Chosen.prototype.result_deactivate = function(el) {
430
- return el.removeClass("active-result").hide();
431
- };
432
- Chosen.prototype.result_deselect = function(pos) {
433
- var result, result_data;
434
- result_data = this.results_data[pos];
435
- result_data.selected = false;
436
- this.form_field.options[result_data.options_index].selected = false;
437
- result = $("#" + this.form_field.id + "chzn_o_" + pos);
438
- result.removeClass("result-selected").addClass("active-result").show();
439
- this.result_clear_highlight();
440
- this.winnow_results();
441
- this.form_field_jq.trigger("change");
442
- return this.search_field_scale();
443
- };
444
- Chosen.prototype.results_search = function(evt) {
445
- if (this.results_showing) {
446
- return this.winnow_results();
447
- } else {
448
- return this.results_show();
449
- }
450
- };
451
- Chosen.prototype.winnow_results = function() {
452
- var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
453
- startTime = new Date();
454
- this.no_results_clear();
455
- results = 0;
456
- searchText = this.search_field.val() === this.default_text ? "" : $.trim(this.search_field.val());
457
- regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
458
- zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
459
- _ref = this.results_data;
460
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
461
- option = _ref[_i];
462
- if (!option.disabled && !option.empty) {
463
- if (option.group) {
464
- $('#' + option.dom_id).hide();
465
- } else if (!(this.is_multiple && option.selected)) {
466
- found = false;
467
- result_id = option.dom_id;
468
- if (regex.test(option.text)) {
469
- found = true;
470
- results += 1;
471
- } else if (option.text.indexOf(" ") >= 0 || option.text.indexOf("[") === 0) {
472
- parts = option.text.replace(/\[|\]/g, "").split(" ");
473
- if (parts.length) {
474
- for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
475
- part = parts[_j];
476
- if (regex.test(part)) {
477
- found = true;
478
- results += 1;
479
- }
480
- }
481
- }
482
- }
483
- if (found) {
484
- if (searchText.length) {
485
- startpos = option.text.search(zregex);
486
- text = option.text.substr(0, startpos + searchText.length) + '</em>' + option.text.substr(startpos + searchText.length);
487
- text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
488
- } else {
489
- text = option.text;
490
- }
491
- if ($("#" + result_id).html !== text) {
492
- $("#" + result_id).html(text);
493
- }
494
- this.result_activate($("#" + result_id));
495
- if (option.group_array_index != null) {
496
- $("#" + this.results_data[option.group_array_index].dom_id).show();
497
- }
498
- } else {
499
- if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
500
- this.result_clear_highlight();
501
- }
502
- this.result_deactivate($("#" + result_id));
503
- }
504
- }
505
- }
506
- }
507
- if (results < 1 && searchText.length) {
508
- return this.no_results(searchText);
509
- } else {
510
- return this.winnow_results_set_highlight();
511
- }
512
- };
513
- Chosen.prototype.winnow_results_clear = function() {
514
- var li, lis, _i, _len, _results;
515
- this.search_field.val("");
516
- lis = this.search_results.find("li");
517
- _results = [];
518
- for (_i = 0, _len = lis.length; _i < _len; _i++) {
519
- li = lis[_i];
520
- li = $(li);
521
- _results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
522
- }
523
- return _results;
524
- };
525
- Chosen.prototype.winnow_results_set_highlight = function() {
526
- var do_high;
527
- if (!this.result_highlight) {
528
- do_high = this.search_results.find(".active-result").first();
529
- if (do_high) {
530
- return this.result_do_highlight(do_high);
531
- }
532
- }
533
- };
534
- Chosen.prototype.no_results = function(terms) {
535
- var no_results_html;
536
- no_results_html = $('<li class="no-results">No results match "<span></span>"</li>');
537
- no_results_html.find("span").first().text(terms);
538
- return this.search_results.append(no_results_html);
539
- };
540
- Chosen.prototype.no_results_clear = function() {
541
- return this.search_results.find(".no-results").remove();
542
- };
543
- Chosen.prototype.keydown_arrow = function() {
544
- var first_active, next_sib;
545
- if (!this.result_highlight) {
546
- first_active = this.search_results.find("li.active-result").first();
547
- if (first_active) {
548
- this.result_do_highlight($(first_active));
549
- }
550
- } else if (this.results_showing) {
551
- next_sib = this.result_highlight.nextAll("li.active-result").first();
552
- if (next_sib) {
553
- this.result_do_highlight(next_sib);
554
- }
555
- }
556
- if (!this.results_showing) {
557
- return this.results_show();
558
- }
559
- };
560
- Chosen.prototype.keyup_arrow = function() {
561
- var prev_sibs;
562
- if (!this.results_showing && !this.is_multiple) {
563
- return this.results_show();
564
- } else if (this.result_highlight) {
565
- prev_sibs = this.result_highlight.prevAll("li.active-result");
566
- if (prev_sibs.length) {
567
- return this.result_do_highlight(prev_sibs.first());
568
- } else {
569
- if (this.choices > 0) {
570
- this.results_hide();
571
- }
572
- return this.result_clear_highlight();
573
- }
574
- }
575
- };
576
- Chosen.prototype.keydown_backstroke = function() {
577
- if (this.pending_backstroke) {
578
- this.choice_destroy(this.pending_backstroke.find("a").first());
579
- return this.clear_backstroke();
580
- } else {
581
- this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
582
- return this.pending_backstroke.addClass("search-choice-focus");
583
- }
584
- };
585
- Chosen.prototype.clear_backstroke = function() {
586
- if (this.pending_backstroke) {
587
- this.pending_backstroke.removeClass("search-choice-focus");
588
- }
589
- return this.pending_backstroke = null;
590
- };
591
- Chosen.prototype.keyup_checker = function(evt) {
592
- var stroke, _ref;
593
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
594
- this.search_field_scale();
595
- switch (stroke) {
596
- case 8:
597
- if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
598
- return this.keydown_backstroke();
599
- } else if (!this.pending_backstroke) {
600
- this.result_clear_highlight();
601
- return this.results_search();
602
- }
603
- break;
604
- case 13:
605
- evt.preventDefault();
606
- if (this.results_showing) {
607
- return this.result_select();
608
- }
609
- break;
610
- case 27:
611
- if (this.results_showing) {
612
- return this.results_hide();
613
- }
614
- break;
615
- case 9:
616
- case 38:
617
- case 40:
618
- case 16:
619
- break;
620
- default:
621
- return this.results_search();
622
- }
623
- };
624
- Chosen.prototype.keydown_checker = function(evt) {
625
- var stroke, _ref;
626
- stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
627
- this.search_field_scale();
628
- if (stroke !== 8 && this.pending_backstroke) {
629
- this.clear_backstroke();
630
- }
631
- switch (stroke) {
632
- case 8:
633
- this.backstroke_length = this.search_field.val().length;
634
- break;
635
- case 9:
636
- this.mouse_on_container = false;
637
- break;
638
- case 13:
639
- evt.preventDefault();
640
- break;
641
- case 38:
642
- evt.preventDefault();
643
- this.keyup_arrow();
644
- break;
645
- case 40:
646
- this.keydown_arrow();
647
- break;
648
- }
649
- };
650
- Chosen.prototype.search_field_scale = function() {
651
- var dd_top, div, h, style, style_block, styles, w, _i, _len;
652
- if (this.is_multiple) {
653
- h = 0;
654
- w = 0;
655
- style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
656
- styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
657
- for (_i = 0, _len = styles.length; _i < _len; _i++) {
658
- style = styles[_i];
659
- style_block += style + ":" + this.search_field.css(style) + ";";
660
- }
661
- div = $('<div />', {
662
- 'style': style_block
663
- });
664
- div.text(this.search_field.val());
665
- $('body').append(div);
666
- w = div.width() + 25;
667
- div.remove();
668
- if (w > this.f_width - 10) {
669
- w = this.f_width - 10;
670
- }
671
- this.search_field.css({
672
- 'width': w + 'px'
673
- });
674
- dd_top = this.container.height();
675
- return this.dropdown.css({
676
- "top": dd_top + "px"
677
- });
678
- }
679
- };
680
- return Chosen;
681
- })();
682
- get_side_border_padding = function(elmt) {
683
- var side_border_padding;
684
- return side_border_padding = elmt.outerWidth() - elmt.width();
685
- };
686
- root.get_side_border_padding = get_side_border_padding;
687
- SelectParser = (function() {
688
- function SelectParser() {
689
- this.options_index = 0;
690
- this.parsed = [];
691
- }
692
- SelectParser.prototype.add_node = function(child) {
693
- if (child.nodeName === "OPTGROUP") {
694
- return this.add_group(child);
695
- } else {
696
- return this.add_option(child);
697
- }
698
- };
699
- SelectParser.prototype.add_group = function(group) {
700
- var group_position, option, _i, _len, _ref, _results;
701
- group_position = this.parsed.length;
702
- this.parsed.push({
703
- array_index: group_position,
704
- group: true,
705
- label: group.label,
706
- children: 0,
707
- disabled: group.disabled
708
- });
709
- _ref = group.childNodes;
710
- _results = [];
711
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
712
- option = _ref[_i];
713
- _results.push(this.add_option(option, group_position, group.disabled));
714
- }
715
- return _results;
716
- };
717
- SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
718
- if (option.nodeName === "OPTION") {
719
- if (option.text !== "") {
720
- if (group_position != null) {
721
- this.parsed[group_position].children += 1;
722
- }
723
- this.parsed.push({
724
- array_index: this.parsed.length,
725
- options_index: this.options_index,
726
- value: option.value,
727
- text: option.text,
728
- selected: option.selected,
729
- disabled: group_disabled === true ? group_disabled : option.disabled,
730
- group_array_index: group_position
731
- });
732
- } else {
733
- this.parsed.push({
734
- array_index: this.parsed.length,
735
- options_index: this.options_index,
736
- empty: true
737
- });
738
- }
739
- return this.options_index += 1;
740
- }
741
- };
742
- return SelectParser;
743
- })();
744
- SelectParser.select_to_array = function(select) {
745
- var child, parser, _i, _len, _ref;
746
- parser = new SelectParser();
747
- _ref = select.childNodes;
748
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
749
- child = _ref[_i];
750
- parser.add_node(child);
751
- }
752
- return parser.parsed;
753
- };
754
- root.SelectParser = SelectParser;
755
- }).call(this);