semantic-ui-sass 1.12.3.0 → 2.0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/app/assets/javascripts/semantic-ui.js +1 -0
- data/app/assets/javascripts/semantic-ui/accordion.js +67 -53
- data/app/assets/javascripts/semantic-ui/api.js +395 -189
- data/app/assets/javascripts/semantic-ui/checkbox.js +322 -114
- data/app/assets/javascripts/semantic-ui/colorize.js +4 -2
- data/app/assets/javascripts/semantic-ui/dimmer.js +74 -50
- data/app/assets/javascripts/semantic-ui/dropdown.js +2046 -584
- data/app/assets/javascripts/semantic-ui/embed.js +662 -0
- data/app/assets/javascripts/semantic-ui/form.js +345 -163
- data/app/assets/javascripts/semantic-ui/modal.js +119 -90
- data/app/assets/javascripts/semantic-ui/nag.js +8 -9
- data/app/assets/javascripts/semantic-ui/popup.js +390 -228
- data/app/assets/javascripts/semantic-ui/progress.js +112 -103
- data/app/assets/javascripts/semantic-ui/rating.js +79 -55
- data/app/assets/javascripts/semantic-ui/search.js +305 -123
- data/app/assets/javascripts/semantic-ui/shape.js +94 -48
- data/app/assets/javascripts/semantic-ui/sidebar.js +84 -151
- data/app/assets/javascripts/semantic-ui/site.js +5 -5
- data/app/assets/javascripts/semantic-ui/state.js +4 -4
- data/app/assets/javascripts/semantic-ui/sticky.js +108 -35
- data/app/assets/javascripts/semantic-ui/tab.js +220 -125
- data/app/assets/javascripts/semantic-ui/transition.js +205 -171
- data/app/assets/javascripts/semantic-ui/visibility.js +220 -100
- data/app/assets/javascripts/semantic-ui/visit.js +6 -4
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +17 -16
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +223 -121
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +462 -448
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +949 -665
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +134 -92
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +270 -208
- data/app/assets/stylesheets/semantic-ui/elements/_all.scss +1 -0
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +1357 -521
- data/app/assets/stylesheets/semantic-ui/elements/_container.scss +125 -0
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +51 -31
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +3 -3
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +270 -144
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +241 -110
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +30 -16
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +88 -53
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +432 -281
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +172 -128
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +16 -14
- data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +15 -7
- data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +32 -13
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +329 -212
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +291 -99
- data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +2 -2
- data/app/assets/stylesheets/semantic-ui/globals/_site.scss +19 -18
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +17 -18
- data/app/assets/stylesheets/semantic-ui/modules/_all.scss +1 -0
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +265 -161
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +29 -15
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +441 -156
- data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +168 -0
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +163 -85
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +8 -8
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +88 -23
- data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +185 -129
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +75 -60
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +99 -52
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +11 -11
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +16 -12
- data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +4 -4
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +3 -3
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +31 -39
- data/app/assets/stylesheets/semantic-ui/views/_ad.scss +3 -3
- data/app/assets/stylesheets/semantic-ui/views/_all.scss +1 -0
- data/app/assets/stylesheets/semantic-ui/views/_card.scss +204 -162
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +6 -6
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +51 -26
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +62 -36
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +265 -90
- data/lib/semantic/ui/sass/version.rb +2 -2
- data/semantic-ui-sass.gemspec +2 -2
- metadata +9 -6
@@ -1,9 +1,9 @@
|
|
1
1
|
/*!
|
2
|
-
* # Semantic UI
|
2
|
+
* # Semantic UI - Search
|
3
3
|
* http://github.com/semantic-org/semantic-ui/
|
4
4
|
*
|
5
5
|
*
|
6
|
-
* Copyright
|
6
|
+
* Copyright 2015 Contributors
|
7
7
|
* Released under the MIT license
|
8
8
|
* http://opensource.org/licenses/MIT
|
9
9
|
*
|
@@ -29,7 +29,9 @@ $.fn.search = function(parameters) {
|
|
29
29
|
$(this)
|
30
30
|
.each(function() {
|
31
31
|
var
|
32
|
-
settings
|
32
|
+
settings = ( $.isPlainObject(parameters) )
|
33
|
+
? $.extend(true, {}, $.fn.search.settings, parameters)
|
34
|
+
: $.extend({}, $.fn.search.settings),
|
33
35
|
|
34
36
|
className = settings.className,
|
35
37
|
metadata = settings.metadata,
|
@@ -53,37 +55,15 @@ $.fn.search = function(parameters) {
|
|
53
55
|
|
54
56
|
module
|
55
57
|
;
|
58
|
+
|
56
59
|
module = {
|
57
60
|
|
58
61
|
initialize: function() {
|
59
62
|
module.verbose('Initializing module');
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
: (prompt !== undefined && prompt.onpropertychange !== undefined)
|
65
|
-
? 'propertychange'
|
66
|
-
: 'keyup'
|
67
|
-
;
|
68
|
-
if(settings.automatic) {
|
69
|
-
$prompt
|
70
|
-
.on(inputEvent + eventNamespace, module.throttle)
|
71
|
-
.attr('autocomplete', 'off')
|
72
|
-
;
|
73
|
-
}
|
74
|
-
$prompt
|
75
|
-
.on('focus' + eventNamespace, module.event.focus)
|
76
|
-
.on('blur' + eventNamespace, module.event.blur)
|
77
|
-
.on('keydown' + eventNamespace, module.handleKeyboard)
|
78
|
-
;
|
79
|
-
$searchButton
|
80
|
-
.on('click' + eventNamespace, module.query)
|
81
|
-
;
|
82
|
-
$results
|
83
|
-
.on('mousedown' + eventNamespace, module.event.result.mousedown)
|
84
|
-
.on('mouseup' + eventNamespace, module.event.result.mouseup)
|
85
|
-
.on('click' + eventNamespace, selector.result, module.event.result.click)
|
86
|
-
;
|
63
|
+
module.determine.searchFields();
|
64
|
+
module.bind.events();
|
65
|
+
module.set.type();
|
66
|
+
module.create.results();
|
87
67
|
module.instantiate();
|
88
68
|
},
|
89
69
|
instantiate: function() {
|
@@ -96,24 +76,56 @@ $.fn.search = function(parameters) {
|
|
96
76
|
destroy: function() {
|
97
77
|
module.verbose('Destroying instance');
|
98
78
|
$module
|
99
|
-
.removeData(moduleNamespace)
|
100
|
-
;
|
101
|
-
$prompt
|
102
|
-
.off(eventNamespace)
|
103
|
-
;
|
104
|
-
$searchButton
|
105
|
-
.off(eventNamespace)
|
106
|
-
;
|
107
|
-
$results
|
108
79
|
.off(eventNamespace)
|
80
|
+
.removeData(moduleNamespace)
|
109
81
|
;
|
110
82
|
},
|
83
|
+
|
84
|
+
bind: {
|
85
|
+
events: function() {
|
86
|
+
module.verbose('Binding events to search');
|
87
|
+
if(settings.automatic) {
|
88
|
+
$module
|
89
|
+
.on(module.get.inputEvent() + eventNamespace, selector.prompt, module.event.input)
|
90
|
+
;
|
91
|
+
$prompt
|
92
|
+
.attr('autocomplete', 'off')
|
93
|
+
;
|
94
|
+
}
|
95
|
+
$module
|
96
|
+
// prompt
|
97
|
+
.on('focus' + eventNamespace, selector.prompt, module.event.focus)
|
98
|
+
.on('blur' + eventNamespace, selector.prompt, module.event.blur)
|
99
|
+
.on('keydown' + eventNamespace, selector.prompt, module.handleKeyboard)
|
100
|
+
// search button
|
101
|
+
.on('click' + eventNamespace, selector.searchButton, module.query)
|
102
|
+
// results
|
103
|
+
.on('mousedown' + eventNamespace, selector.results, module.event.result.mousedown)
|
104
|
+
.on('mouseup' + eventNamespace, selector.results, module.event.result.mouseup)
|
105
|
+
.on('click' + eventNamespace, selector.result, module.event.result.click)
|
106
|
+
;
|
107
|
+
}
|
108
|
+
},
|
109
|
+
|
110
|
+
determine: {
|
111
|
+
searchFields: function() {
|
112
|
+
// this makes sure $.extend does not add specified search fields to default fields
|
113
|
+
// this is the only setting which should not extend defaults
|
114
|
+
if(parameters && parameters.searchFields !== undefined) {
|
115
|
+
settings.searchFields = parameters.searchFields;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
},
|
119
|
+
|
111
120
|
event: {
|
121
|
+
input: function() {
|
122
|
+
clearTimeout(module.timer);
|
123
|
+
module.timer = setTimeout(module.query, settings.searchDelay);
|
124
|
+
},
|
112
125
|
focus: function() {
|
113
126
|
module.set.focus();
|
114
|
-
clearTimeout(module.timer);
|
115
|
-
module.throttle();
|
116
127
|
if( module.has.minimumCharacters() ) {
|
128
|
+
module.query();
|
117
129
|
module.showResults();
|
118
130
|
}
|
119
131
|
},
|
@@ -143,11 +155,12 @@ $.fn.search = function(parameters) {
|
|
143
155
|
href = $link.attr('href') || false,
|
144
156
|
target = $link.attr('target') || false,
|
145
157
|
title = $title.html(),
|
146
|
-
|
158
|
+
// title is used for result lookup
|
159
|
+
value = ($title.length > 0)
|
147
160
|
? $title.text()
|
148
161
|
: false,
|
149
162
|
results = module.get.results(),
|
150
|
-
result = module.get.result(
|
163
|
+
result = $result.data(metadata.result) || module.get.result(value, results),
|
151
164
|
returnedValue
|
152
165
|
;
|
153
166
|
if( $.isFunction(settings.onSelect) ) {
|
@@ -157,8 +170,8 @@ $.fn.search = function(parameters) {
|
|
157
170
|
}
|
158
171
|
}
|
159
172
|
module.hideResults();
|
160
|
-
if(
|
161
|
-
module.set.value(
|
173
|
+
if(value) {
|
174
|
+
module.set.value(value);
|
162
175
|
}
|
163
176
|
if(href) {
|
164
177
|
module.verbose('Opening search link found in result', $link);
|
@@ -258,9 +271,11 @@ $.fn.search = function(parameters) {
|
|
258
271
|
api: function() {
|
259
272
|
var
|
260
273
|
apiSettings = {
|
274
|
+
debug : settings.debug,
|
261
275
|
on : false,
|
276
|
+
cache : 'local',
|
262
277
|
action : 'search',
|
263
|
-
|
278
|
+
onError : module.error
|
264
279
|
},
|
265
280
|
searchHTML
|
266
281
|
;
|
@@ -291,6 +306,17 @@ $.fn.search = function(parameters) {
|
|
291
306
|
},
|
292
307
|
|
293
308
|
get: {
|
309
|
+
inputEvent: function() {
|
310
|
+
var
|
311
|
+
prompt = $prompt[0],
|
312
|
+
inputEvent = (prompt !== undefined && prompt.oninput !== undefined)
|
313
|
+
? 'input'
|
314
|
+
: (prompt !== undefined && prompt.onpropertychange !== undefined)
|
315
|
+
? 'propertychange'
|
316
|
+
: 'keyup'
|
317
|
+
;
|
318
|
+
return inputEvent;
|
319
|
+
},
|
294
320
|
value: function() {
|
295
321
|
return $prompt.val();
|
296
322
|
},
|
@@ -302,26 +328,34 @@ $.fn.search = function(parameters) {
|
|
302
328
|
},
|
303
329
|
result: function(value, results) {
|
304
330
|
var
|
305
|
-
|
331
|
+
lookupFields = ['title', 'id'],
|
332
|
+
result = false
|
333
|
+
;
|
334
|
+
value = (value !== undefined)
|
335
|
+
? value
|
336
|
+
: module.get.value()
|
337
|
+
;
|
338
|
+
results = (results !== undefined)
|
339
|
+
? results
|
340
|
+
: module.get.results()
|
306
341
|
;
|
307
|
-
value = value || module.get.value();
|
308
|
-
results = results || module.get.results();
|
309
342
|
if(settings.type === 'category') {
|
310
343
|
module.debug('Finding result that matches', value);
|
311
344
|
$.each(results, function(index, category) {
|
312
345
|
if($.isArray(category.results)) {
|
313
|
-
result = module.search.object(value, category.results)[0];
|
314
|
-
if
|
315
|
-
|
346
|
+
result = module.search.object(value, category.results, lookupFields)[0];
|
347
|
+
// dont continue searching if a result is found
|
348
|
+
if(result) {
|
349
|
+
return false;
|
316
350
|
}
|
317
351
|
}
|
318
352
|
});
|
319
353
|
}
|
320
354
|
else {
|
321
355
|
module.debug('Finding result in results object', value);
|
322
|
-
result = module.search.object(value, results)[0];
|
356
|
+
result = module.search.object(value, results, lookupFields)[0];
|
323
357
|
}
|
324
|
-
return result;
|
358
|
+
return result || false;
|
325
359
|
},
|
326
360
|
},
|
327
361
|
|
@@ -334,8 +368,15 @@ $.fn.search = function(parameters) {
|
|
334
368
|
},
|
335
369
|
value: function(value) {
|
336
370
|
module.verbose('Setting search input value', value);
|
337
|
-
$prompt
|
338
|
-
|
371
|
+
$prompt
|
372
|
+
.val(value)
|
373
|
+
;
|
374
|
+
},
|
375
|
+
type: function(type) {
|
376
|
+
type = type || settings.type;
|
377
|
+
if(settings.type == 'category') {
|
378
|
+
$module.addClass(settings.type);
|
379
|
+
}
|
339
380
|
},
|
340
381
|
buttonPressed: function() {
|
341
382
|
$searchButton.addClass(className.pressed);
|
@@ -359,55 +400,52 @@ $.fn.search = function(parameters) {
|
|
359
400
|
searchTerm = module.get.value(),
|
360
401
|
cache = module.read.cache(searchTerm)
|
361
402
|
;
|
362
|
-
if(
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
module.debug('Querying for ' + searchTerm);
|
369
|
-
if($.isPlainObject(settings.source) || $.isArray(settings.source)) {
|
370
|
-
module.search.local(searchTerm);
|
403
|
+
if( module.has.minimumCharacters() ) {
|
404
|
+
if(cache) {
|
405
|
+
module.debug('Reading result from cache', searchTerm);
|
406
|
+
module.save.results(cache.results);
|
407
|
+
module.addResults(cache.html);
|
408
|
+
module.inject.id(cache.results);
|
371
409
|
}
|
372
|
-
else
|
373
|
-
|
374
|
-
|
375
|
-
module.search.
|
410
|
+
else {
|
411
|
+
module.debug('Querying for', searchTerm);
|
412
|
+
if($.isPlainObject(settings.source) || $.isArray(settings.source)) {
|
413
|
+
module.search.local(searchTerm);
|
376
414
|
}
|
377
|
-
else if(
|
378
|
-
module.debug('Searching with default search API endpoint');
|
415
|
+
else if( module.can.useAPI() ) {
|
379
416
|
module.search.remote(searchTerm);
|
380
417
|
}
|
381
418
|
else {
|
382
|
-
module.error(error.
|
419
|
+
module.error(error.source);
|
383
420
|
}
|
421
|
+
settings.onSearchQuery.call(element, searchTerm);
|
384
422
|
}
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
settings.onSearchQuery.call(element, searchTerm);
|
423
|
+
}
|
424
|
+
else {
|
425
|
+
module.hideResults();
|
389
426
|
}
|
390
427
|
},
|
391
428
|
|
392
429
|
search: {
|
393
430
|
local: function(searchTerm) {
|
394
431
|
var
|
395
|
-
|
432
|
+
results = module.search.object(searchTerm, settings.content),
|
396
433
|
searchHTML
|
397
434
|
;
|
398
435
|
module.set.loading();
|
399
|
-
module.save.results(
|
400
|
-
module.debug('Returned local search results',
|
436
|
+
module.save.results(results);
|
437
|
+
module.debug('Returned local search results', results);
|
401
438
|
|
402
439
|
searchHTML = module.generateResults({
|
403
|
-
results:
|
440
|
+
results: results
|
404
441
|
});
|
405
442
|
module.remove.loading();
|
443
|
+
module.addResults(searchHTML);
|
444
|
+
module.inject.id(results);
|
406
445
|
module.write.cache(searchTerm, {
|
407
446
|
html : searchHTML,
|
408
|
-
results :
|
447
|
+
results : results
|
409
448
|
});
|
410
|
-
module.addResults(searchHTML);
|
411
449
|
},
|
412
450
|
remote: function(searchTerm) {
|
413
451
|
var
|
@@ -415,6 +453,9 @@ $.fn.search = function(parameters) {
|
|
415
453
|
onSuccess : function(response) {
|
416
454
|
module.parse.response.call(element, response, searchTerm);
|
417
455
|
},
|
456
|
+
onFailure: function() {
|
457
|
+
module.displayMessage(error.serverError);
|
458
|
+
},
|
418
459
|
urlData: {
|
419
460
|
query: searchTerm
|
420
461
|
}
|
@@ -431,43 +472,60 @@ $.fn.search = function(parameters) {
|
|
431
472
|
.api('query')
|
432
473
|
;
|
433
474
|
},
|
434
|
-
object: function(searchTerm, source) {
|
475
|
+
object: function(searchTerm, source, searchFields) {
|
435
476
|
var
|
436
|
-
results
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
: [settings.searchFields],
|
441
|
-
searchExp = searchTerm.replace(regExp.escape, '\\$&'),
|
442
|
-
searchRegExp = new RegExp(regExp.exact + searchExp, 'i')
|
443
|
-
;
|
477
|
+
results = [],
|
478
|
+
fuzzyResults = [],
|
479
|
+
searchExp = searchTerm.toString().replace(regExp.escape, '\\$&'),
|
480
|
+
matchRegExp = new RegExp(regExp.beginsWith + searchExp, 'i'),
|
444
481
|
|
482
|
+
// avoid duplicates when pushing results
|
483
|
+
addResult = function(array, result) {
|
484
|
+
var
|
485
|
+
notResult = ($.inArray(result, results) == -1),
|
486
|
+
notFuzzyResult = ($.inArray(result, fuzzyResults) == -1)
|
487
|
+
;
|
488
|
+
if(notResult && notFuzzyResult) {
|
489
|
+
array.push(result);
|
490
|
+
}
|
491
|
+
}
|
492
|
+
;
|
445
493
|
source = source || settings.source;
|
494
|
+
searchFields = (searchFields !== undefined)
|
495
|
+
? searchFields
|
496
|
+
: settings.searchFields
|
497
|
+
;
|
498
|
+
|
499
|
+
// search fields should be array to loop correctly
|
500
|
+
if(!$.isArray(searchFields)) {
|
501
|
+
searchFields = [searchFields];
|
502
|
+
}
|
446
503
|
|
447
|
-
// exit conditions
|
448
|
-
if(source === undefined) {
|
504
|
+
// exit conditions if no source
|
505
|
+
if(source === undefined || source === false) {
|
449
506
|
module.error(error.source);
|
450
507
|
return [];
|
451
508
|
}
|
452
509
|
|
453
|
-
// iterate through search fields
|
510
|
+
// iterate through search fields looking for matches
|
454
511
|
$.each(searchFields, function(index, field) {
|
455
512
|
$.each(source, function(label, content) {
|
456
513
|
var
|
457
|
-
fieldExists = (typeof content[field] == 'string')
|
458
|
-
notAlreadyResult = ($.inArray(content, results) == -1 && $.inArray(content, fullTextResults) == -1)
|
514
|
+
fieldExists = (typeof content[field] == 'string')
|
459
515
|
;
|
460
|
-
if(fieldExists
|
461
|
-
if( content[field].
|
462
|
-
results
|
516
|
+
if(fieldExists) {
|
517
|
+
if( content[field].search(matchRegExp) !== -1) {
|
518
|
+
// content starts with value (first in results)
|
519
|
+
addResult(results, content);
|
463
520
|
}
|
464
521
|
else if(settings.searchFullText && module.fuzzySearch(searchTerm, content[field]) ) {
|
465
|
-
|
522
|
+
// content fuzzy matches (last in results)
|
523
|
+
addResult(fuzzyResults, content);
|
466
524
|
}
|
467
525
|
}
|
468
526
|
});
|
469
527
|
});
|
470
|
-
return $.merge(results,
|
528
|
+
return $.merge(results, fuzzyResults);
|
471
529
|
}
|
472
530
|
},
|
473
531
|
|
@@ -476,6 +534,9 @@ $.fn.search = function(parameters) {
|
|
476
534
|
termLength = term.length,
|
477
535
|
queryLength = query.length
|
478
536
|
;
|
537
|
+
if(typeof query !== 'string') {
|
538
|
+
return false;
|
539
|
+
}
|
479
540
|
query = query.toLowerCase();
|
480
541
|
term = term.toLowerCase();
|
481
542
|
if(queryLength > termLength) {
|
@@ -506,27 +567,18 @@ $.fn.search = function(parameters) {
|
|
506
567
|
module.verbose('Parsing server response', response);
|
507
568
|
if(response !== undefined) {
|
508
569
|
if(searchTerm !== undefined && response.results !== undefined) {
|
570
|
+
module.addResults(searchHTML);
|
571
|
+
module.inject.id(response.results);
|
509
572
|
module.write.cache(searchTerm, {
|
510
573
|
html : searchHTML,
|
511
574
|
results : response.results
|
512
575
|
});
|
513
576
|
module.save.results(response.results);
|
514
|
-
module.addResults(searchHTML);
|
515
577
|
}
|
516
578
|
}
|
517
579
|
}
|
518
580
|
},
|
519
581
|
|
520
|
-
throttle: function() {
|
521
|
-
clearTimeout(module.timer);
|
522
|
-
if(module.has.minimumCharacters()) {
|
523
|
-
module.timer = setTimeout(module.query, settings.searchDelay);
|
524
|
-
}
|
525
|
-
else {
|
526
|
-
module.hideResults();
|
527
|
-
}
|
528
|
-
},
|
529
|
-
|
530
582
|
cancel: {
|
531
583
|
query: function() {
|
532
584
|
if( module.can.useAPI() ) {
|
@@ -545,6 +597,23 @@ $.fn.search = function(parameters) {
|
|
545
597
|
}
|
546
598
|
},
|
547
599
|
|
600
|
+
clear: {
|
601
|
+
cache: function(value) {
|
602
|
+
var
|
603
|
+
cache = $module.data(metadata.cache)
|
604
|
+
;
|
605
|
+
if(!value) {
|
606
|
+
module.debug('Clearing cache', value);
|
607
|
+
$module.removeData(metadata.cache);
|
608
|
+
}
|
609
|
+
else if(value && cache && cache[value]) {
|
610
|
+
module.debug('Removing value from cache', value);
|
611
|
+
delete cache[value];
|
612
|
+
$module.data(metadata.cache, cache);
|
613
|
+
}
|
614
|
+
}
|
615
|
+
},
|
616
|
+
|
548
617
|
read: {
|
549
618
|
cache: function(name) {
|
550
619
|
var
|
@@ -561,6 +630,94 @@ $.fn.search = function(parameters) {
|
|
561
630
|
}
|
562
631
|
},
|
563
632
|
|
633
|
+
create: {
|
634
|
+
id: function(resultIndex, categoryIndex) {
|
635
|
+
var
|
636
|
+
resultID = (resultIndex + 1), // not zero indexed
|
637
|
+
categoryID = (categoryIndex + 1),
|
638
|
+
firstCharCode,
|
639
|
+
letterID,
|
640
|
+
id
|
641
|
+
;
|
642
|
+
if(categoryIndex !== undefined) {
|
643
|
+
// start char code for "A"
|
644
|
+
letterID = String.fromCharCode(97 + categoryIndex);
|
645
|
+
id = letterID + resultID;
|
646
|
+
module.verbose('Creating category result id', id);
|
647
|
+
}
|
648
|
+
else {
|
649
|
+
id = resultID;
|
650
|
+
module.verbose('Creating result id', id);
|
651
|
+
}
|
652
|
+
return id;
|
653
|
+
},
|
654
|
+
results: function() {
|
655
|
+
if($results.length === 0) {
|
656
|
+
$results = $('<div />')
|
657
|
+
.addClass(className.results)
|
658
|
+
.appendTo($module)
|
659
|
+
;
|
660
|
+
}
|
661
|
+
}
|
662
|
+
},
|
663
|
+
|
664
|
+
inject: {
|
665
|
+
result: function(result, resultIndex, categoryIndex) {
|
666
|
+
module.verbose('Injecting result into results');
|
667
|
+
var
|
668
|
+
$selectedResult = (categoryIndex !== undefined)
|
669
|
+
? $results
|
670
|
+
.children().eq(categoryIndex)
|
671
|
+
.children(selector.result).eq(resultIndex)
|
672
|
+
: $results
|
673
|
+
.children(selector.result).eq(resultIndex)
|
674
|
+
;
|
675
|
+
module.verbose('Injecting results metadata', $selectedResult);
|
676
|
+
$selectedResult
|
677
|
+
.data(metadata.result, result)
|
678
|
+
;
|
679
|
+
},
|
680
|
+
id: function(results) {
|
681
|
+
module.debug('Injecting unique ids into results');
|
682
|
+
var
|
683
|
+
// since results may be object, we must use counters
|
684
|
+
categoryIndex = 0,
|
685
|
+
resultIndex = 0
|
686
|
+
;
|
687
|
+
if(settings.type === 'category') {
|
688
|
+
// iterate through each category result
|
689
|
+
$.each(results, function(index, category) {
|
690
|
+
resultIndex = 0;
|
691
|
+
$.each(category.results, function(index, value) {
|
692
|
+
var
|
693
|
+
result = category.results[index]
|
694
|
+
;
|
695
|
+
if(result.id === undefined) {
|
696
|
+
result.id = module.create.id(resultIndex, categoryIndex);
|
697
|
+
}
|
698
|
+
module.inject.result(result, resultIndex, categoryIndex);
|
699
|
+
resultIndex++;
|
700
|
+
});
|
701
|
+
categoryIndex++;
|
702
|
+
});
|
703
|
+
}
|
704
|
+
else {
|
705
|
+
// top level
|
706
|
+
$.each(results, function(index, value) {
|
707
|
+
var
|
708
|
+
result = results[index]
|
709
|
+
;
|
710
|
+
if(result.id === undefined) {
|
711
|
+
result.id = module.create.id(resultIndex);
|
712
|
+
}
|
713
|
+
module.inject.result(result, resultIndex);
|
714
|
+
resultIndex++;
|
715
|
+
});
|
716
|
+
}
|
717
|
+
return results;
|
718
|
+
}
|
719
|
+
},
|
720
|
+
|
564
721
|
save: {
|
565
722
|
results: function(results) {
|
566
723
|
module.verbose('Saving current search results to metadata', results);
|
@@ -605,6 +762,8 @@ $.fn.search = function(parameters) {
|
|
605
762
|
$results
|
606
763
|
.transition({
|
607
764
|
animation : settings.transition + ' in',
|
765
|
+
debug : settings.debug,
|
766
|
+
verbose : settings.verbose,
|
608
767
|
duration : settings.duration,
|
609
768
|
queue : true
|
610
769
|
})
|
@@ -627,6 +786,8 @@ $.fn.search = function(parameters) {
|
|
627
786
|
$results
|
628
787
|
.transition({
|
629
788
|
animation : settings.transition + ' out',
|
789
|
+
debug : settings.debug,
|
790
|
+
verbose : settings.verbose,
|
630
791
|
duration : settings.duration,
|
631
792
|
queue : true
|
632
793
|
})
|
@@ -751,7 +912,7 @@ $.fn.search = function(parameters) {
|
|
751
912
|
});
|
752
913
|
}
|
753
914
|
clearTimeout(module.performance.timer);
|
754
|
-
module.performance.timer = setTimeout(module.performance.display,
|
915
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
755
916
|
},
|
756
917
|
display: function() {
|
757
918
|
var
|
@@ -863,36 +1024,55 @@ $.fn.search = function(parameters) {
|
|
863
1024
|
|
864
1025
|
$.fn.search.settings = {
|
865
1026
|
|
866
|
-
name : 'Search
|
1027
|
+
name : 'Search',
|
867
1028
|
namespace : 'search',
|
868
1029
|
|
869
1030
|
debug : false,
|
870
|
-
verbose :
|
1031
|
+
verbose : false,
|
871
1032
|
performance : true,
|
872
1033
|
|
873
1034
|
type : 'standard',
|
1035
|
+
// template to use (specified in settings.templates)
|
1036
|
+
|
874
1037
|
minCharacters : 1,
|
1038
|
+
// minimum characters required to search
|
875
1039
|
|
876
|
-
// api config
|
877
1040
|
apiSettings : false,
|
1041
|
+
// API config
|
878
1042
|
|
879
1043
|
source : false,
|
1044
|
+
// object to search
|
1045
|
+
|
880
1046
|
searchFields : [
|
881
1047
|
'title',
|
882
1048
|
'description'
|
883
1049
|
],
|
1050
|
+
// fields to search
|
1051
|
+
|
884
1052
|
searchFullText : true,
|
1053
|
+
// whether to include fuzzy results in local search
|
1054
|
+
|
1055
|
+
automatic : true,
|
1056
|
+
// whether to add events to prompt automatically
|
885
1057
|
|
886
|
-
automatic : 'true',
|
887
1058
|
hideDelay : 0,
|
888
|
-
|
1059
|
+
// delay before hiding menu after blur
|
1060
|
+
|
1061
|
+
searchDelay : 200,
|
1062
|
+
// delay before searching
|
1063
|
+
|
889
1064
|
maxResults : 7,
|
1065
|
+
// maximum results returned from local
|
1066
|
+
|
890
1067
|
cache : true,
|
1068
|
+
// whether to store lookups in local cache
|
891
1069
|
|
1070
|
+
// transition settings
|
892
1071
|
transition : 'scale',
|
893
|
-
duration :
|
1072
|
+
duration : 200,
|
894
1073
|
easing : 'easeOutExpo',
|
895
1074
|
|
1075
|
+
// callbacks
|
896
1076
|
onSelect : false,
|
897
1077
|
onResultsAdd : false,
|
898
1078
|
|
@@ -907,6 +1087,7 @@ $.fn.search.settings = {
|
|
907
1087
|
empty : 'empty',
|
908
1088
|
focus : 'focus',
|
909
1089
|
loading : 'loading',
|
1090
|
+
results : 'results',
|
910
1091
|
pressed : 'down'
|
911
1092
|
},
|
912
1093
|
|
@@ -916,19 +1097,20 @@ $.fn.search.settings = {
|
|
916
1097
|
logging : 'Error in debug logging, exiting.',
|
917
1098
|
noEndpoint : 'No search endpoint was specified',
|
918
1099
|
noTemplate : 'A valid template name was not specified.',
|
919
|
-
serverError : 'There was an issue
|
1100
|
+
serverError : 'There was an issue querying the server.',
|
920
1101
|
maxResults : 'Results must be an array to use maxResults setting',
|
921
1102
|
method : 'The method you called is not defined.'
|
922
1103
|
},
|
923
1104
|
|
924
1105
|
metadata: {
|
925
1106
|
cache : 'cache',
|
926
|
-
results : 'results'
|
1107
|
+
results : 'results',
|
1108
|
+
result : 'result'
|
927
1109
|
},
|
928
1110
|
|
929
1111
|
regExp: {
|
930
|
-
escape
|
931
|
-
|
1112
|
+
escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
|
1113
|
+
beginsWith : '(?:\s|^)'
|
932
1114
|
},
|
933
1115
|
|
934
1116
|
selector : {
|