jail 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +11 -4
- data/app/models/jail/cdnjs.rb +22 -5
- data/app/models/jail/github.rb +2 -1
- data/app/views/jail/cdnjs/show.html.erb +14 -7
- data/lib/jail/version.rb +1 -1
- metadata +39 -127
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -59
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -37
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/jail.rb +0 -4
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/jail.inmates.yml +0 -4
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -42628
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/dummy/tmp/cache/assets/C78/2D0/sprockets%2F049c9453e2d03a13463ad15568c8521f +0 -0
- data/test/dummy/tmp/cache/assets/CBE/8B0/sprockets%2F45f037820eca943af359e247967580cf +0 -0
- data/test/dummy/tmp/cache/assets/CFA/570/sprockets%2Ffe84858b375458bd418cb85c8f84803c +0 -0
- data/test/dummy/tmp/cache/assets/D15/AE0/sprockets%2F3fd1b8f0c577d6bd951f40857132eb74 +0 -0
- data/test/dummy/tmp/cache/assets/D29/F40/sprockets%2F15ce02e64710b4fa1d3a21f6270fdc74 +0 -0
- data/test/dummy/tmp/cache/assets/D34/BF0/sprockets%2F18a1d0fec1cd74447e07b02d058a289d +0 -0
- data/test/dummy/tmp/cache/assets/D46/B30/sprockets%2F36e940335f9fc2de06c6d8aad556d822 +0 -0
- data/test/dummy/tmp/cache/assets/D4B/BC0/sprockets%2Fa3a0b270a0bb2747cad33e424662fba2 +0 -0
- data/test/dummy/tmp/cache/assets/D76/A70/sprockets%2F360c75fdc8ed695061e3b08da593d7cc +0 -0
- data/test/dummy/tmp/cache/assets/D81/500/sprockets%2F23e9c52aedd634ee57e66663cffa1868 +0 -0
- data/test/dummy/tmp/cache/assets/D9E/630/sprockets%2F0efe12c5dc1902e8cf8f6844b7bca812 +0 -0
- data/test/dummy/tmp/cache/assets/DDF/C90/sprockets%2Fc4dff5559e7f91debdf5da74921c028e +0 -0
- data/test/dummy/tmp/cache/assets/E64/6F0/sprockets%2F8f0e4dd1aa8c3ddea851bf771dce8f8c +0 -0
- data/test/dummy/tmp/pids/server.pid +0 -1
- data/test/dummy/vendor/assets/images/chosen-sprite.png +0 -0
- data/test/dummy/vendor/assets/javascripts/chosen.jquery.js +0 -952
- data/test/dummy/vendor/assets/stylesheets/chosen.css +0 -392
- data/test/fixtures/jqplug/jqgithubs.yml +0 -11
- data/test/functional/jqplug/githubs_controller_test.rb +0 -51
- data/test/functional/jqplug/jqgithubs_controller_test.rb +0 -51
- data/test/integration/navigation_test.rb +0 -10
- data/test/jqplug_test.rb +0 -7
- data/test/test_helper.rb +0 -15
- data/test/unit/helpers/jqplug/githubs_helper_test.rb +0 -6
- data/test/unit/helpers/jqplug/jqgithubs_helper_test.rb +0 -6
- data/test/unit/jqplug/jqgithub_test.rb +0 -9
data/test/dummy/public/404.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/404.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/test/dummy/public/422.html
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/422.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>The change you wanted was rejected.</h1>
|
23
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
-
</div>
|
25
|
-
</body>
|
26
|
-
</html>
|
data/test/dummy/public/500.html
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<style type="text/css">
|
6
|
-
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
-
div.dialog {
|
8
|
-
width: 25em;
|
9
|
-
padding: 0 4em;
|
10
|
-
margin: 4em auto 0 auto;
|
11
|
-
border: 1px solid #ccc;
|
12
|
-
border-right-color: #999;
|
13
|
-
border-bottom-color: #999;
|
14
|
-
}
|
15
|
-
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
-
</style>
|
17
|
-
</head>
|
18
|
-
|
19
|
-
<body>
|
20
|
-
<!-- This file lives in public/500.html -->
|
21
|
-
<div class="dialog">
|
22
|
-
<h1>We're sorry, but something went wrong.</h1>
|
23
|
-
</div>
|
24
|
-
</body>
|
25
|
-
</html>
|
File without changes
|
data/test/dummy/script/rails
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
59422
|
Binary file
|
@@ -1,952 +0,0 @@
|
|
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 === "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 === "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.default_text_default = this.is_multiple ? "Select Some Options" : "Select an Option";
|
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.search_contains = this.options.search_contains || false;
|
133
|
-
this.choices = 0;
|
134
|
-
return this.results_none_found = this.options.no_results_text || "No results match";
|
135
|
-
};
|
136
|
-
|
137
|
-
AbstractChosen.prototype.mouse_enter = function() {
|
138
|
-
return this.mouse_on_container = true;
|
139
|
-
};
|
140
|
-
|
141
|
-
AbstractChosen.prototype.mouse_leave = function() {
|
142
|
-
return this.mouse_on_container = false;
|
143
|
-
};
|
144
|
-
|
145
|
-
AbstractChosen.prototype.input_focus = function(evt) {
|
146
|
-
var _this = this;
|
147
|
-
if (!this.active_field) {
|
148
|
-
return setTimeout((function() {
|
149
|
-
return _this.container_mousedown();
|
150
|
-
}), 50);
|
151
|
-
}
|
152
|
-
};
|
153
|
-
|
154
|
-
AbstractChosen.prototype.input_blur = function(evt) {
|
155
|
-
var _this = this;
|
156
|
-
if (!this.mouse_on_container) {
|
157
|
-
this.active_field = false;
|
158
|
-
return setTimeout((function() {
|
159
|
-
return _this.blur_test();
|
160
|
-
}), 100);
|
161
|
-
}
|
162
|
-
};
|
163
|
-
|
164
|
-
AbstractChosen.prototype.result_add_option = function(option) {
|
165
|
-
var classes, style;
|
166
|
-
if (!option.disabled) {
|
167
|
-
option.dom_id = this.container_id + "_o_" + option.array_index;
|
168
|
-
classes = option.selected && this.is_multiple ? [] : ["active-result"];
|
169
|
-
if (option.selected) classes.push("result-selected");
|
170
|
-
if (option.group_array_index != null) classes.push("group-option");
|
171
|
-
if (option.classes !== "") classes.push(option.classes);
|
172
|
-
style = option.style.cssText !== "" ? " style=\"" + option.style + "\"" : "";
|
173
|
-
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '"' + style + '>' + option.html + '</li>';
|
174
|
-
} else {
|
175
|
-
return "";
|
176
|
-
}
|
177
|
-
};
|
178
|
-
|
179
|
-
AbstractChosen.prototype.results_update_field = function() {
|
180
|
-
this.result_clear_highlight();
|
181
|
-
this.result_single_selected = null;
|
182
|
-
return this.results_build();
|
183
|
-
};
|
184
|
-
|
185
|
-
AbstractChosen.prototype.results_toggle = function() {
|
186
|
-
if (this.results_showing) {
|
187
|
-
return this.results_hide();
|
188
|
-
} else {
|
189
|
-
return this.results_show();
|
190
|
-
}
|
191
|
-
};
|
192
|
-
|
193
|
-
AbstractChosen.prototype.results_search = function(evt) {
|
194
|
-
if (this.results_showing) {
|
195
|
-
return this.winnow_results();
|
196
|
-
} else {
|
197
|
-
return this.results_show();
|
198
|
-
}
|
199
|
-
};
|
200
|
-
|
201
|
-
AbstractChosen.prototype.keyup_checker = function(evt) {
|
202
|
-
var stroke, _ref;
|
203
|
-
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
204
|
-
this.search_field_scale();
|
205
|
-
switch (stroke) {
|
206
|
-
case 8:
|
207
|
-
if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
|
208
|
-
return this.keydown_backstroke();
|
209
|
-
} else if (!this.pending_backstroke) {
|
210
|
-
this.result_clear_highlight();
|
211
|
-
return this.results_search();
|
212
|
-
}
|
213
|
-
break;
|
214
|
-
case 13:
|
215
|
-
evt.preventDefault();
|
216
|
-
if (this.results_showing) return this.result_select(evt);
|
217
|
-
break;
|
218
|
-
case 27:
|
219
|
-
if (this.results_showing) this.results_hide();
|
220
|
-
return true;
|
221
|
-
case 9:
|
222
|
-
case 38:
|
223
|
-
case 40:
|
224
|
-
case 16:
|
225
|
-
case 91:
|
226
|
-
case 17:
|
227
|
-
break;
|
228
|
-
default:
|
229
|
-
return this.results_search();
|
230
|
-
}
|
231
|
-
};
|
232
|
-
|
233
|
-
AbstractChosen.prototype.generate_field_id = function() {
|
234
|
-
var new_id;
|
235
|
-
new_id = this.generate_random_id();
|
236
|
-
this.form_field.id = new_id;
|
237
|
-
return new_id;
|
238
|
-
};
|
239
|
-
|
240
|
-
AbstractChosen.prototype.generate_random_char = function() {
|
241
|
-
var chars, newchar, rand;
|
242
|
-
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
|
243
|
-
rand = Math.floor(Math.random() * chars.length);
|
244
|
-
return newchar = chars.substring(rand, rand + 1);
|
245
|
-
};
|
246
|
-
|
247
|
-
return AbstractChosen;
|
248
|
-
|
249
|
-
})();
|
250
|
-
|
251
|
-
root.AbstractChosen = AbstractChosen;
|
252
|
-
|
253
|
-
}).call(this);
|
254
|
-
|
255
|
-
/*
|
256
|
-
Chosen source: generate output using 'cake build'
|
257
|
-
Copyright (c) 2011 by Harvest
|
258
|
-
*/
|
259
|
-
|
260
|
-
(function() {
|
261
|
-
var $, Chosen, get_side_border_padding, root,
|
262
|
-
__hasProp = Object.prototype.hasOwnProperty,
|
263
|
-
__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; };
|
264
|
-
|
265
|
-
root = this;
|
266
|
-
|
267
|
-
$ = jQuery;
|
268
|
-
|
269
|
-
$.fn.extend({
|
270
|
-
chosen: function(options) {
|
271
|
-
if ($.browser.msie && ($.browser.version === "6.0" || $.browser.version === "7.0")) {
|
272
|
-
return this;
|
273
|
-
}
|
274
|
-
return $(this).each(function(input_field) {
|
275
|
-
if (!($(this)).hasClass("chzn-done")) return new Chosen(this, options);
|
276
|
-
});
|
277
|
-
}
|
278
|
-
});
|
279
|
-
|
280
|
-
Chosen = (function(_super) {
|
281
|
-
|
282
|
-
__extends(Chosen, _super);
|
283
|
-
|
284
|
-
function Chosen() {
|
285
|
-
Chosen.__super__.constructor.apply(this, arguments);
|
286
|
-
}
|
287
|
-
|
288
|
-
Chosen.prototype.setup = function() {
|
289
|
-
this.form_field_jq = $(this.form_field);
|
290
|
-
return this.is_rtl = this.form_field_jq.hasClass("chzn-rtl");
|
291
|
-
};
|
292
|
-
|
293
|
-
Chosen.prototype.finish_setup = function() {
|
294
|
-
return this.form_field_jq.addClass("chzn-done");
|
295
|
-
};
|
296
|
-
|
297
|
-
Chosen.prototype.set_up_html = function() {
|
298
|
-
var container_div, dd_top, dd_width, sf_width;
|
299
|
-
this.container_id = this.form_field.id.length ? this.form_field.id.replace(/(:|\.)/g, '_') : this.generate_field_id();
|
300
|
-
this.container_id += "_chzn";
|
301
|
-
this.f_width = this.form_field_jq.outerWidth();
|
302
|
-
this.default_text = this.form_field_jq.data('placeholder') ? this.form_field_jq.data('placeholder') : this.default_text_default;
|
303
|
-
container_div = $("<div />", {
|
304
|
-
id: this.container_id,
|
305
|
-
"class": "chzn-container" + (this.is_rtl ? ' chzn-rtl' : ''),
|
306
|
-
style: 'width: ' + this.f_width + 'px;'
|
307
|
-
});
|
308
|
-
if (this.is_multiple) {
|
309
|
-
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>');
|
310
|
-
} else {
|
311
|
-
container_div.html('<a href="javascript:void(0)" class="chzn-single chzn-default"><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>');
|
312
|
-
}
|
313
|
-
this.form_field_jq.hide().after(container_div);
|
314
|
-
this.container = $('#' + this.container_id);
|
315
|
-
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
|
316
|
-
this.dropdown = this.container.find('div.chzn-drop').first();
|
317
|
-
dd_top = this.container.height();
|
318
|
-
dd_width = this.f_width - get_side_border_padding(this.dropdown);
|
319
|
-
this.dropdown.css({
|
320
|
-
"width": dd_width + "px",
|
321
|
-
"top": dd_top + "px"
|
322
|
-
});
|
323
|
-
this.search_field = this.container.find('input').first();
|
324
|
-
this.search_results = this.container.find('ul.chzn-results').first();
|
325
|
-
this.search_field_scale();
|
326
|
-
this.search_no_results = this.container.find('li.no-results').first();
|
327
|
-
if (this.is_multiple) {
|
328
|
-
this.search_choices = this.container.find('ul.chzn-choices').first();
|
329
|
-
this.search_container = this.container.find('li.search-field').first();
|
330
|
-
} else {
|
331
|
-
this.search_container = this.container.find('div.chzn-search').first();
|
332
|
-
this.selected_item = this.container.find('.chzn-single').first();
|
333
|
-
sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
|
334
|
-
this.search_field.css({
|
335
|
-
"width": sf_width + "px"
|
336
|
-
});
|
337
|
-
}
|
338
|
-
this.results_build();
|
339
|
-
this.set_tab_index();
|
340
|
-
return this.form_field_jq.trigger("liszt:ready", {
|
341
|
-
chosen: this
|
342
|
-
});
|
343
|
-
};
|
344
|
-
|
345
|
-
Chosen.prototype.register_observers = function() {
|
346
|
-
var _this = this;
|
347
|
-
this.container.mousedown(function(evt) {
|
348
|
-
return _this.container_mousedown(evt);
|
349
|
-
});
|
350
|
-
this.container.mouseup(function(evt) {
|
351
|
-
return _this.container_mouseup(evt);
|
352
|
-
});
|
353
|
-
this.container.mouseenter(function(evt) {
|
354
|
-
return _this.mouse_enter(evt);
|
355
|
-
});
|
356
|
-
this.container.mouseleave(function(evt) {
|
357
|
-
return _this.mouse_leave(evt);
|
358
|
-
});
|
359
|
-
this.search_results.mouseup(function(evt) {
|
360
|
-
return _this.search_results_mouseup(evt);
|
361
|
-
});
|
362
|
-
this.search_results.mouseover(function(evt) {
|
363
|
-
return _this.search_results_mouseover(evt);
|
364
|
-
});
|
365
|
-
this.search_results.mouseout(function(evt) {
|
366
|
-
return _this.search_results_mouseout(evt);
|
367
|
-
});
|
368
|
-
this.form_field_jq.bind("liszt:updated", function(evt) {
|
369
|
-
return _this.results_update_field(evt);
|
370
|
-
});
|
371
|
-
this.search_field.blur(function(evt) {
|
372
|
-
return _this.input_blur(evt);
|
373
|
-
});
|
374
|
-
this.search_field.keyup(function(evt) {
|
375
|
-
return _this.keyup_checker(evt);
|
376
|
-
});
|
377
|
-
this.search_field.keydown(function(evt) {
|
378
|
-
return _this.keydown_checker(evt);
|
379
|
-
});
|
380
|
-
if (this.is_multiple) {
|
381
|
-
this.search_choices.click(function(evt) {
|
382
|
-
return _this.choices_click(evt);
|
383
|
-
});
|
384
|
-
return this.search_field.focus(function(evt) {
|
385
|
-
return _this.input_focus(evt);
|
386
|
-
});
|
387
|
-
} else {
|
388
|
-
return this.container.click(function(evt) {
|
389
|
-
return evt.preventDefault();
|
390
|
-
});
|
391
|
-
}
|
392
|
-
};
|
393
|
-
|
394
|
-
Chosen.prototype.search_field_disabled = function() {
|
395
|
-
this.is_disabled = this.form_field_jq[0].disabled;
|
396
|
-
if (this.is_disabled) {
|
397
|
-
this.container.addClass('chzn-disabled');
|
398
|
-
this.search_field[0].disabled = true;
|
399
|
-
if (!this.is_multiple) {
|
400
|
-
this.selected_item.unbind("focus", this.activate_action);
|
401
|
-
}
|
402
|
-
return this.close_field();
|
403
|
-
} else {
|
404
|
-
this.container.removeClass('chzn-disabled');
|
405
|
-
this.search_field[0].disabled = false;
|
406
|
-
if (!this.is_multiple) {
|
407
|
-
return this.selected_item.bind("focus", this.activate_action);
|
408
|
-
}
|
409
|
-
}
|
410
|
-
};
|
411
|
-
|
412
|
-
Chosen.prototype.container_mousedown = function(evt) {
|
413
|
-
var target_closelink;
|
414
|
-
if (!this.is_disabled) {
|
415
|
-
target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false;
|
416
|
-
if (evt && evt.type === "mousedown" && !this.results_showing) {
|
417
|
-
evt.stopPropagation();
|
418
|
-
}
|
419
|
-
if (!this.pending_destroy_click && !target_closelink) {
|
420
|
-
if (!this.active_field) {
|
421
|
-
if (this.is_multiple) this.search_field.val("");
|
422
|
-
$(document).click(this.click_test_action);
|
423
|
-
this.results_show();
|
424
|
-
} else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chzn-single").length)) {
|
425
|
-
evt.preventDefault();
|
426
|
-
this.results_toggle();
|
427
|
-
}
|
428
|
-
return this.activate_field();
|
429
|
-
} else {
|
430
|
-
return this.pending_destroy_click = false;
|
431
|
-
}
|
432
|
-
}
|
433
|
-
};
|
434
|
-
|
435
|
-
Chosen.prototype.container_mouseup = function(evt) {
|
436
|
-
if (evt.target.nodeName === "ABBR") return this.results_reset(evt);
|
437
|
-
};
|
438
|
-
|
439
|
-
Chosen.prototype.blur_test = function(evt) {
|
440
|
-
if (!this.active_field && this.container.hasClass("chzn-container-active")) {
|
441
|
-
return this.close_field();
|
442
|
-
}
|
443
|
-
};
|
444
|
-
|
445
|
-
Chosen.prototype.close_field = function() {
|
446
|
-
$(document).unbind("click", this.click_test_action);
|
447
|
-
if (!this.is_multiple) {
|
448
|
-
this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
|
449
|
-
this.search_field.attr("tabindex", -1);
|
450
|
-
}
|
451
|
-
this.active_field = false;
|
452
|
-
this.results_hide();
|
453
|
-
this.container.removeClass("chzn-container-active");
|
454
|
-
this.winnow_results_clear();
|
455
|
-
this.clear_backstroke();
|
456
|
-
this.show_search_field_default();
|
457
|
-
return this.search_field_scale();
|
458
|
-
};
|
459
|
-
|
460
|
-
Chosen.prototype.activate_field = function() {
|
461
|
-
if (!this.is_multiple && !this.active_field) {
|
462
|
-
this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
|
463
|
-
this.selected_item.attr("tabindex", -1);
|
464
|
-
}
|
465
|
-
this.container.addClass("chzn-container-active");
|
466
|
-
this.active_field = true;
|
467
|
-
this.search_field.val(this.search_field.val());
|
468
|
-
return this.search_field.focus();
|
469
|
-
};
|
470
|
-
|
471
|
-
Chosen.prototype.test_active_click = function(evt) {
|
472
|
-
if ($(evt.target).parents('#' + this.container_id).length) {
|
473
|
-
return this.active_field = true;
|
474
|
-
} else {
|
475
|
-
return this.close_field();
|
476
|
-
}
|
477
|
-
};
|
478
|
-
|
479
|
-
Chosen.prototype.results_build = function() {
|
480
|
-
var content, data, _i, _len, _ref;
|
481
|
-
this.parsing = true;
|
482
|
-
this.results_data = root.SelectParser.select_to_array(this.form_field);
|
483
|
-
if (this.is_multiple && this.choices > 0) {
|
484
|
-
this.search_choices.find("li.search-choice").remove();
|
485
|
-
this.choices = 0;
|
486
|
-
} else if (!this.is_multiple) {
|
487
|
-
this.selected_item.find("span").text(this.default_text);
|
488
|
-
if (this.form_field.options.length <= this.disable_search_threshold) {
|
489
|
-
this.container.addClass("chzn-container-single-nosearch");
|
490
|
-
} else {
|
491
|
-
this.container.removeClass("chzn-container-single-nosearch");
|
492
|
-
}
|
493
|
-
}
|
494
|
-
content = '';
|
495
|
-
_ref = this.results_data;
|
496
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
497
|
-
data = _ref[_i];
|
498
|
-
if (data.group) {
|
499
|
-
content += this.result_add_group(data);
|
500
|
-
} else if (!data.empty) {
|
501
|
-
content += this.result_add_option(data);
|
502
|
-
if (data.selected && this.is_multiple) {
|
503
|
-
this.choice_build(data);
|
504
|
-
} else if (data.selected && !this.is_multiple) {
|
505
|
-
this.selected_item.removeClass("chzn-default").find("span").text(data.text);
|
506
|
-
if (this.allow_single_deselect) this.single_deselect_control_build();
|
507
|
-
}
|
508
|
-
}
|
509
|
-
}
|
510
|
-
this.search_field_disabled();
|
511
|
-
this.show_search_field_default();
|
512
|
-
this.search_field_scale();
|
513
|
-
this.search_results.html(content);
|
514
|
-
return this.parsing = false;
|
515
|
-
};
|
516
|
-
|
517
|
-
Chosen.prototype.result_add_group = function(group) {
|
518
|
-
if (!group.disabled) {
|
519
|
-
group.dom_id = this.container_id + "_g_" + group.array_index;
|
520
|
-
return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
|
521
|
-
} else {
|
522
|
-
return "";
|
523
|
-
}
|
524
|
-
};
|
525
|
-
|
526
|
-
Chosen.prototype.result_do_highlight = function(el) {
|
527
|
-
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
528
|
-
if (el.length) {
|
529
|
-
this.result_clear_highlight();
|
530
|
-
this.result_highlight = el;
|
531
|
-
this.result_highlight.addClass("highlighted");
|
532
|
-
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
|
533
|
-
visible_top = this.search_results.scrollTop();
|
534
|
-
visible_bottom = maxHeight + visible_top;
|
535
|
-
high_top = this.result_highlight.position().top + this.search_results.scrollTop();
|
536
|
-
high_bottom = high_top + this.result_highlight.outerHeight();
|
537
|
-
if (high_bottom >= visible_bottom) {
|
538
|
-
return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
|
539
|
-
} else if (high_top < visible_top) {
|
540
|
-
return this.search_results.scrollTop(high_top);
|
541
|
-
}
|
542
|
-
}
|
543
|
-
};
|
544
|
-
|
545
|
-
Chosen.prototype.result_clear_highlight = function() {
|
546
|
-
if (this.result_highlight) this.result_highlight.removeClass("highlighted");
|
547
|
-
return this.result_highlight = null;
|
548
|
-
};
|
549
|
-
|
550
|
-
Chosen.prototype.results_show = function() {
|
551
|
-
var dd_top;
|
552
|
-
if (!this.is_multiple) {
|
553
|
-
this.selected_item.addClass("chzn-single-with-drop");
|
554
|
-
if (this.result_single_selected) {
|
555
|
-
this.result_do_highlight(this.result_single_selected);
|
556
|
-
}
|
557
|
-
}
|
558
|
-
dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
|
559
|
-
this.dropdown.css({
|
560
|
-
"top": dd_top + "px",
|
561
|
-
"left": 0
|
562
|
-
});
|
563
|
-
this.results_showing = true;
|
564
|
-
this.search_field.focus();
|
565
|
-
this.search_field.val(this.search_field.val());
|
566
|
-
return this.winnow_results();
|
567
|
-
};
|
568
|
-
|
569
|
-
Chosen.prototype.results_hide = function() {
|
570
|
-
if (!this.is_multiple) {
|
571
|
-
this.selected_item.removeClass("chzn-single-with-drop");
|
572
|
-
}
|
573
|
-
this.result_clear_highlight();
|
574
|
-
this.dropdown.css({
|
575
|
-
"left": "-9000px"
|
576
|
-
});
|
577
|
-
return this.results_showing = false;
|
578
|
-
};
|
579
|
-
|
580
|
-
Chosen.prototype.set_tab_index = function(el) {
|
581
|
-
var ti;
|
582
|
-
if (this.form_field_jq.attr("tabindex")) {
|
583
|
-
ti = this.form_field_jq.attr("tabindex");
|
584
|
-
this.form_field_jq.attr("tabindex", -1);
|
585
|
-
if (this.is_multiple) {
|
586
|
-
return this.search_field.attr("tabindex", ti);
|
587
|
-
} else {
|
588
|
-
this.selected_item.attr("tabindex", ti);
|
589
|
-
return this.search_field.attr("tabindex", -1);
|
590
|
-
}
|
591
|
-
}
|
592
|
-
};
|
593
|
-
|
594
|
-
Chosen.prototype.show_search_field_default = function() {
|
595
|
-
if (this.is_multiple && this.choices < 1 && !this.active_field) {
|
596
|
-
this.search_field.val(this.default_text);
|
597
|
-
return this.search_field.addClass("default");
|
598
|
-
} else {
|
599
|
-
this.search_field.val("");
|
600
|
-
return this.search_field.removeClass("default");
|
601
|
-
}
|
602
|
-
};
|
603
|
-
|
604
|
-
Chosen.prototype.search_results_mouseup = function(evt) {
|
605
|
-
var target;
|
606
|
-
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
607
|
-
if (target.length) {
|
608
|
-
this.result_highlight = target;
|
609
|
-
return this.result_select(evt);
|
610
|
-
}
|
611
|
-
};
|
612
|
-
|
613
|
-
Chosen.prototype.search_results_mouseover = function(evt) {
|
614
|
-
var target;
|
615
|
-
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
616
|
-
if (target) return this.result_do_highlight(target);
|
617
|
-
};
|
618
|
-
|
619
|
-
Chosen.prototype.search_results_mouseout = function(evt) {
|
620
|
-
if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
|
621
|
-
return this.result_clear_highlight();
|
622
|
-
}
|
623
|
-
};
|
624
|
-
|
625
|
-
Chosen.prototype.choices_click = function(evt) {
|
626
|
-
evt.preventDefault();
|
627
|
-
if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
|
628
|
-
return this.results_show();
|
629
|
-
}
|
630
|
-
};
|
631
|
-
|
632
|
-
Chosen.prototype.choice_build = function(item) {
|
633
|
-
var choice_id, link,
|
634
|
-
_this = this;
|
635
|
-
choice_id = this.container_id + "_c_" + item.array_index;
|
636
|
-
this.choices += 1;
|
637
|
-
this.search_container.before('<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>');
|
638
|
-
link = $('#' + choice_id).find("a").first();
|
639
|
-
return link.click(function(evt) {
|
640
|
-
return _this.choice_destroy_link_click(evt);
|
641
|
-
});
|
642
|
-
};
|
643
|
-
|
644
|
-
Chosen.prototype.choice_destroy_link_click = function(evt) {
|
645
|
-
evt.preventDefault();
|
646
|
-
if (!this.is_disabled) {
|
647
|
-
this.pending_destroy_click = true;
|
648
|
-
return this.choice_destroy($(evt.target));
|
649
|
-
} else {
|
650
|
-
return evt.stopPropagation;
|
651
|
-
}
|
652
|
-
};
|
653
|
-
|
654
|
-
Chosen.prototype.choice_destroy = function(link) {
|
655
|
-
this.choices -= 1;
|
656
|
-
this.show_search_field_default();
|
657
|
-
if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
|
658
|
-
this.results_hide();
|
659
|
-
}
|
660
|
-
this.result_deselect(link.attr("rel"));
|
661
|
-
return link.parents('li').first().remove();
|
662
|
-
};
|
663
|
-
|
664
|
-
Chosen.prototype.results_reset = function(evt) {
|
665
|
-
this.form_field.options[0].selected = true;
|
666
|
-
this.selected_item.find("span").text(this.default_text);
|
667
|
-
if (!this.is_multiple) this.selected_item.addClass("chzn-default");
|
668
|
-
this.show_search_field_default();
|
669
|
-
$(evt.target).remove();
|
670
|
-
this.form_field_jq.trigger("change");
|
671
|
-
if (this.active_field) return this.results_hide();
|
672
|
-
};
|
673
|
-
|
674
|
-
Chosen.prototype.result_select = function(evt) {
|
675
|
-
var high, high_id, item, position;
|
676
|
-
if (this.result_highlight) {
|
677
|
-
high = this.result_highlight;
|
678
|
-
high_id = high.attr("id");
|
679
|
-
this.result_clear_highlight();
|
680
|
-
if (this.is_multiple) {
|
681
|
-
this.result_deactivate(high);
|
682
|
-
} else {
|
683
|
-
this.search_results.find(".result-selected").removeClass("result-selected");
|
684
|
-
this.result_single_selected = high;
|
685
|
-
this.selected_item.removeClass("chzn-default");
|
686
|
-
}
|
687
|
-
high.addClass("result-selected");
|
688
|
-
position = high_id.substr(high_id.lastIndexOf("_") + 1);
|
689
|
-
item = this.results_data[position];
|
690
|
-
item.selected = true;
|
691
|
-
this.form_field.options[item.options_index].selected = true;
|
692
|
-
if (this.is_multiple) {
|
693
|
-
this.choice_build(item);
|
694
|
-
} else {
|
695
|
-
this.selected_item.find("span").first().text(item.text);
|
696
|
-
if (this.allow_single_deselect) this.single_deselect_control_build();
|
697
|
-
}
|
698
|
-
if (!(evt.metaKey && this.is_multiple)) this.results_hide();
|
699
|
-
this.search_field.val("");
|
700
|
-
this.form_field_jq.trigger("change");
|
701
|
-
return this.search_field_scale();
|
702
|
-
}
|
703
|
-
};
|
704
|
-
|
705
|
-
Chosen.prototype.result_activate = function(el) {
|
706
|
-
return el.addClass("active-result");
|
707
|
-
};
|
708
|
-
|
709
|
-
Chosen.prototype.result_deactivate = function(el) {
|
710
|
-
return el.removeClass("active-result");
|
711
|
-
};
|
712
|
-
|
713
|
-
Chosen.prototype.result_deselect = function(pos) {
|
714
|
-
var result, result_data;
|
715
|
-
result_data = this.results_data[pos];
|
716
|
-
result_data.selected = false;
|
717
|
-
this.form_field.options[result_data.options_index].selected = false;
|
718
|
-
result = $("#" + this.container_id + "_o_" + pos);
|
719
|
-
result.removeClass("result-selected").addClass("active-result").show();
|
720
|
-
this.result_clear_highlight();
|
721
|
-
this.winnow_results();
|
722
|
-
this.form_field_jq.trigger("change");
|
723
|
-
return this.search_field_scale();
|
724
|
-
};
|
725
|
-
|
726
|
-
Chosen.prototype.single_deselect_control_build = function() {
|
727
|
-
if (this.allow_single_deselect && this.selected_item.find("abbr").length < 1) {
|
728
|
-
return this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
|
729
|
-
}
|
730
|
-
};
|
731
|
-
|
732
|
-
Chosen.prototype.winnow_results = function() {
|
733
|
-
var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref;
|
734
|
-
this.no_results_clear();
|
735
|
-
results = 0;
|
736
|
-
searchText = this.search_field.val() === this.default_text ? "" : $('<div/>').text($.trim(this.search_field.val())).html();
|
737
|
-
regexAnchor = this.search_contains ? "" : "^";
|
738
|
-
regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
|
739
|
-
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
|
740
|
-
_ref = this.results_data;
|
741
|
-
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
742
|
-
option = _ref[_i];
|
743
|
-
if (!option.disabled && !option.empty) {
|
744
|
-
if (option.group) {
|
745
|
-
$('#' + option.dom_id).css('display', 'none');
|
746
|
-
} else if (!(this.is_multiple && option.selected)) {
|
747
|
-
found = false;
|
748
|
-
result_id = option.dom_id;
|
749
|
-
result = $("#" + result_id);
|
750
|
-
if (regex.test(option.html)) {
|
751
|
-
found = true;
|
752
|
-
results += 1;
|
753
|
-
} else if (option.html.indexOf(" ") >= 0 || option.html.indexOf("[") === 0) {
|
754
|
-
parts = option.html.replace(/\[|\]/g, "").split(" ");
|
755
|
-
if (parts.length) {
|
756
|
-
for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
|
757
|
-
part = parts[_j];
|
758
|
-
if (regex.test(part)) {
|
759
|
-
found = true;
|
760
|
-
results += 1;
|
761
|
-
}
|
762
|
-
}
|
763
|
-
}
|
764
|
-
}
|
765
|
-
if (found) {
|
766
|
-
if (searchText.length) {
|
767
|
-
startpos = option.html.search(zregex);
|
768
|
-
text = option.html.substr(0, startpos + searchText.length) + '</em>' + option.html.substr(startpos + searchText.length);
|
769
|
-
text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
|
770
|
-
} else {
|
771
|
-
text = option.html;
|
772
|
-
}
|
773
|
-
result.html(text);
|
774
|
-
this.result_activate(result);
|
775
|
-
if (option.group_array_index != null) {
|
776
|
-
$("#" + this.results_data[option.group_array_index].dom_id).css('display', 'list-item');
|
777
|
-
}
|
778
|
-
} else {
|
779
|
-
if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
|
780
|
-
this.result_clear_highlight();
|
781
|
-
}
|
782
|
-
this.result_deactivate(result);
|
783
|
-
}
|
784
|
-
}
|
785
|
-
}
|
786
|
-
}
|
787
|
-
if (results < 1 && searchText.length) {
|
788
|
-
return this.no_results(searchText);
|
789
|
-
} else {
|
790
|
-
return this.winnow_results_set_highlight();
|
791
|
-
}
|
792
|
-
};
|
793
|
-
|
794
|
-
Chosen.prototype.winnow_results_clear = function() {
|
795
|
-
var li, lis, _i, _len, _results;
|
796
|
-
this.search_field.val("");
|
797
|
-
lis = this.search_results.find("li");
|
798
|
-
_results = [];
|
799
|
-
for (_i = 0, _len = lis.length; _i < _len; _i++) {
|
800
|
-
li = lis[_i];
|
801
|
-
li = $(li);
|
802
|
-
if (li.hasClass("group-result")) {
|
803
|
-
_results.push(li.css('display', 'auto'));
|
804
|
-
} else if (!this.is_multiple || !li.hasClass("result-selected")) {
|
805
|
-
_results.push(this.result_activate(li));
|
806
|
-
} else {
|
807
|
-
_results.push(void 0);
|
808
|
-
}
|
809
|
-
}
|
810
|
-
return _results;
|
811
|
-
};
|
812
|
-
|
813
|
-
Chosen.prototype.winnow_results_set_highlight = function() {
|
814
|
-
var do_high, selected_results;
|
815
|
-
if (!this.result_highlight) {
|
816
|
-
selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
|
817
|
-
do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
|
818
|
-
if (do_high != null) return this.result_do_highlight(do_high);
|
819
|
-
}
|
820
|
-
};
|
821
|
-
|
822
|
-
Chosen.prototype.no_results = function(terms) {
|
823
|
-
var no_results_html;
|
824
|
-
no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
|
825
|
-
no_results_html.find("span").first().html(terms);
|
826
|
-
return this.search_results.append(no_results_html);
|
827
|
-
};
|
828
|
-
|
829
|
-
Chosen.prototype.no_results_clear = function() {
|
830
|
-
return this.search_results.find(".no-results").remove();
|
831
|
-
};
|
832
|
-
|
833
|
-
Chosen.prototype.keydown_arrow = function() {
|
834
|
-
var first_active, next_sib;
|
835
|
-
if (!this.result_highlight) {
|
836
|
-
first_active = this.search_results.find("li.active-result").first();
|
837
|
-
if (first_active) this.result_do_highlight($(first_active));
|
838
|
-
} else if (this.results_showing) {
|
839
|
-
next_sib = this.result_highlight.nextAll("li.active-result").first();
|
840
|
-
if (next_sib) this.result_do_highlight(next_sib);
|
841
|
-
}
|
842
|
-
if (!this.results_showing) return this.results_show();
|
843
|
-
};
|
844
|
-
|
845
|
-
Chosen.prototype.keyup_arrow = function() {
|
846
|
-
var prev_sibs;
|
847
|
-
if (!this.results_showing && !this.is_multiple) {
|
848
|
-
return this.results_show();
|
849
|
-
} else if (this.result_highlight) {
|
850
|
-
prev_sibs = this.result_highlight.prevAll("li.active-result");
|
851
|
-
if (prev_sibs.length) {
|
852
|
-
return this.result_do_highlight(prev_sibs.first());
|
853
|
-
} else {
|
854
|
-
if (this.choices > 0) this.results_hide();
|
855
|
-
return this.result_clear_highlight();
|
856
|
-
}
|
857
|
-
}
|
858
|
-
};
|
859
|
-
|
860
|
-
Chosen.prototype.keydown_backstroke = function() {
|
861
|
-
if (this.pending_backstroke) {
|
862
|
-
this.choice_destroy(this.pending_backstroke.find("a").first());
|
863
|
-
return this.clear_backstroke();
|
864
|
-
} else {
|
865
|
-
this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
|
866
|
-
return this.pending_backstroke.addClass("search-choice-focus");
|
867
|
-
}
|
868
|
-
};
|
869
|
-
|
870
|
-
Chosen.prototype.clear_backstroke = function() {
|
871
|
-
if (this.pending_backstroke) {
|
872
|
-
this.pending_backstroke.removeClass("search-choice-focus");
|
873
|
-
}
|
874
|
-
return this.pending_backstroke = null;
|
875
|
-
};
|
876
|
-
|
877
|
-
Chosen.prototype.keydown_checker = function(evt) {
|
878
|
-
var stroke, _ref;
|
879
|
-
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
880
|
-
this.search_field_scale();
|
881
|
-
if (stroke !== 8 && this.pending_backstroke) this.clear_backstroke();
|
882
|
-
switch (stroke) {
|
883
|
-
case 8:
|
884
|
-
this.backstroke_length = this.search_field.val().length;
|
885
|
-
break;
|
886
|
-
case 9:
|
887
|
-
if (this.results_showing && !this.is_multiple) this.result_select(evt);
|
888
|
-
this.mouse_on_container = false;
|
889
|
-
break;
|
890
|
-
case 13:
|
891
|
-
evt.preventDefault();
|
892
|
-
break;
|
893
|
-
case 38:
|
894
|
-
evt.preventDefault();
|
895
|
-
this.keyup_arrow();
|
896
|
-
break;
|
897
|
-
case 40:
|
898
|
-
this.keydown_arrow();
|
899
|
-
break;
|
900
|
-
}
|
901
|
-
};
|
902
|
-
|
903
|
-
Chosen.prototype.search_field_scale = function() {
|
904
|
-
var dd_top, div, h, style, style_block, styles, w, _i, _len;
|
905
|
-
if (this.is_multiple) {
|
906
|
-
h = 0;
|
907
|
-
w = 0;
|
908
|
-
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
|
909
|
-
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
|
910
|
-
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
911
|
-
style = styles[_i];
|
912
|
-
style_block += style + ":" + this.search_field.css(style) + ";";
|
913
|
-
}
|
914
|
-
div = $('<div />', {
|
915
|
-
'style': style_block
|
916
|
-
});
|
917
|
-
div.text(this.search_field.val());
|
918
|
-
$('body').append(div);
|
919
|
-
w = div.width() + 25;
|
920
|
-
div.remove();
|
921
|
-
if (w > this.f_width - 10) w = this.f_width - 10;
|
922
|
-
this.search_field.css({
|
923
|
-
'width': w + 'px'
|
924
|
-
});
|
925
|
-
dd_top = this.container.height();
|
926
|
-
return this.dropdown.css({
|
927
|
-
"top": dd_top + "px"
|
928
|
-
});
|
929
|
-
}
|
930
|
-
};
|
931
|
-
|
932
|
-
Chosen.prototype.generate_random_id = function() {
|
933
|
-
var string;
|
934
|
-
string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
|
935
|
-
while ($("#" + string).length > 0) {
|
936
|
-
string += this.generate_random_char();
|
937
|
-
}
|
938
|
-
return string;
|
939
|
-
};
|
940
|
-
|
941
|
-
return Chosen;
|
942
|
-
|
943
|
-
})(AbstractChosen);
|
944
|
-
|
945
|
-
get_side_border_padding = function(elmt) {
|
946
|
-
var side_border_padding;
|
947
|
-
return side_border_padding = elmt.outerWidth() - elmt.width();
|
948
|
-
};
|
949
|
-
|
950
|
-
root.get_side_border_padding = get_side_border_padding;
|
951
|
-
|
952
|
-
}).call(this);
|