semantic-ui-sass 0.19.3.1 → 1.7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +5 -6
  4. data/app/assets/fonts/semantic-ui/icons.eot +0 -0
  5. data/app/assets/fonts/semantic-ui/icons.otf +0 -0
  6. data/app/assets/fonts/semantic-ui/icons.svg +472 -367
  7. data/app/assets/fonts/semantic-ui/icons.ttf +0 -0
  8. data/app/assets/fonts/semantic-ui/icons.woff +0 -0
  9. data/app/assets/images/semantic-ui/flags.png +0 -0
  10. data/app/assets/javascripts/semantic-ui.js +9 -5
  11. data/app/assets/javascripts/semantic-ui/accordion.js +169 -102
  12. data/app/assets/javascripts/semantic-ui/api.js +840 -0
  13. data/app/assets/javascripts/semantic-ui/checkbox.js +203 -46
  14. data/app/assets/javascripts/semantic-ui/{behavior/colorize.js → colorize.js} +4 -2
  15. data/app/assets/javascripts/semantic-ui/dimmer.js +110 -76
  16. data/app/assets/javascripts/semantic-ui/dropdown.js +897 -285
  17. data/app/assets/javascripts/semantic-ui/{behavior/form.js → form.js} +127 -42
  18. data/app/assets/javascripts/semantic-ui/modal.js +294 -219
  19. data/app/assets/javascripts/semantic-ui/nag.js +120 -186
  20. data/app/assets/javascripts/semantic-ui/popup.js +491 -223
  21. data/app/assets/javascripts/semantic-ui/progress.js +779 -0
  22. data/app/assets/javascripts/semantic-ui/rating.js +66 -22
  23. data/app/assets/javascripts/semantic-ui/search.js +219 -99
  24. data/app/assets/javascripts/semantic-ui/shape.js +72 -29
  25. data/app/assets/javascripts/semantic-ui/sidebar.js +678 -142
  26. data/app/assets/javascripts/semantic-ui/site.js +487 -0
  27. data/app/assets/javascripts/semantic-ui/{behavior/state.js → state.js} +116 -151
  28. data/app/assets/javascripts/semantic-ui/sticky.js +771 -0
  29. data/app/assets/javascripts/semantic-ui/tab.js +680 -603
  30. data/app/assets/javascripts/semantic-ui/transition.js +269 -158
  31. data/app/assets/javascripts/semantic-ui/video.js +113 -32
  32. data/app/assets/javascripts/semantic-ui/visibility.js +970 -0
  33. data/app/assets/javascripts/semantic-ui/visit.js +513 -0
  34. data/app/assets/stylesheets/semantic-ui.scss +2 -0
  35. data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +58 -14
  36. data/app/assets/stylesheets/semantic-ui/collections/_form.scss +464 -372
  37. data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +1385 -533
  38. data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +482 -655
  39. data/app/assets/stylesheets/semantic-ui/collections/_message.scss +238 -139
  40. data/app/assets/stylesheets/semantic-ui/collections/_table.scss +631 -280
  41. data/app/assets/stylesheets/semantic-ui/elements/_all.scss +3 -2
  42. data/app/assets/stylesheets/semantic-ui/elements/_button.scss +1614 -657
  43. data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +143 -80
  44. data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1018 -0
  45. data/app/assets/stylesheets/semantic-ui/elements/_header.scss +302 -145
  46. data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +1653 -1365
  47. data/app/assets/stylesheets/semantic-ui/elements/_image.scss +160 -59
  48. data/app/assets/stylesheets/semantic-ui/elements/_input.scss +247 -118
  49. data/app/assets/stylesheets/semantic-ui/elements/_label.scss +501 -470
  50. data/app/assets/stylesheets/semantic-ui/elements/_list.scss +888 -0
  51. data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +189 -98
  52. data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +125 -0
  53. data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +147 -212
  54. data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +328 -190
  55. data/app/assets/stylesheets/semantic-ui/elements/_step.scss +261 -185
  56. data/app/assets/stylesheets/semantic-ui/globals/_all.scss +2 -0
  57. data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +430 -0
  58. data/app/assets/stylesheets/semantic-ui/globals/_site.scss +128 -0
  59. data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +190 -106
  60. data/app/assets/stylesheets/semantic-ui/modules/_all.scss +2 -1
  61. data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +303 -201
  62. data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +72 -63
  63. data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +711 -331
  64. data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +262 -140
  65. data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +82 -71
  66. data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +163 -119
  67. data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +435 -0
  68. data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +163 -68
  69. data/app/assets/stylesheets/semantic-ui/modules/_search.scss +223 -150
  70. data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +39 -40
  71. data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +413 -147
  72. data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +80 -0
  73. data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +49 -20
  74. data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +542 -568
  75. data/app/assets/stylesheets/semantic-ui/modules/_video.scss +69 -37
  76. data/app/assets/stylesheets/semantic-ui/views/_ad.scss +265 -0
  77. data/app/assets/stylesheets/semantic-ui/views/_all.scss +1 -1
  78. data/app/assets/stylesheets/semantic-ui/views/_card.scss +758 -0
  79. data/app/assets/stylesheets/semantic-ui/views/_comment.scss +133 -92
  80. data/app/assets/stylesheets/semantic-ui/views/_feed.scss +200 -87
  81. data/app/assets/stylesheets/semantic-ui/views/_item.scss +298 -523
  82. data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +390 -12
  83. data/lib/semantic/ui/sass/version.rb +2 -2
  84. data/tasks/converter.rb +99 -216
  85. metadata +22 -27
  86. data/app/assets/fonts/semantic-ui/basic.icons.eot +0 -0
  87. data/app/assets/fonts/semantic-ui/basic.icons.svg +0 -450
  88. data/app/assets/fonts/semantic-ui/basic.icons.ttf +0 -0
  89. data/app/assets/fonts/semantic-ui/basic.icons.woff +0 -0
  90. data/app/assets/images/semantic-ui/loader-large-inverted.gif +0 -0
  91. data/app/assets/images/semantic-ui/loader-large.gif +0 -0
  92. data/app/assets/images/semantic-ui/loader-medium-inverted.gif +0 -0
  93. data/app/assets/images/semantic-ui/loader-medium.gif +0 -0
  94. data/app/assets/images/semantic-ui/loader-mini-inverted.gif +0 -0
  95. data/app/assets/images/semantic-ui/loader-mini.gif +0 -0
  96. data/app/assets/images/semantic-ui/loader-small-inverted.gif +0 -0
  97. data/app/assets/images/semantic-ui/loader-small.gif +0 -0
  98. data/app/assets/javascripts/semantic-ui/behavior/api.js +0 -634
  99. data/app/assets/javascripts/semantic-ui/chatroom.js +0 -772
  100. data/app/assets/stylesheets/semantic-ui/depends/_basic.icon.scss +0 -4
  101. data/app/assets/stylesheets/semantic-ui/depends/_icon.scss +0 -4
  102. data/app/assets/stylesheets/semantic-ui/depends/_loader.scss +0 -8
  103. data/app/assets/stylesheets/semantic-ui/elements/_basic.icon.scss +0 -1124
  104. data/app/assets/stylesheets/semantic-ui/elements/_progress.scss +0 -280
  105. data/app/assets/stylesheets/semantic-ui/modules/_chatroom.scss +0 -299
  106. data/app/assets/stylesheets/semantic-ui/modules/_reveal.scss +0 -322
  107. data/app/assets/stylesheets/semantic-ui/views/_list.scss +0 -700
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  * # Semantic - Rating
3
- * http://github.com/jlukic/semantic-ui/
3
+ * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2014 Contributor
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -11,6 +11,8 @@
11
11
 
12
12
  ;(function ($, window, document, undefined) {
13
13
 
14
+ "use strict";
15
+
14
16
  $.fn.rating = function(parameters) {
15
17
  var
16
18
  $allModules = $(this),
@@ -54,13 +56,16 @@ $.fn.rating = function(parameters) {
54
56
  initialize: function() {
55
57
  module.verbose('Initializing rating module', settings);
56
58
 
59
+ if($icon.size() === 0) {
60
+ module.setup.layout();
61
+ }
62
+
57
63
  if(settings.interactive) {
58
64
  module.enable();
59
65
  }
60
66
  else {
61
67
  module.disable();
62
68
  }
63
-
64
69
  if(settings.initialRating) {
65
70
  module.debug('Setting initial rating');
66
71
  module.setRating(settings.initialRating);
@@ -90,6 +95,23 @@ $.fn.rating = function(parameters) {
90
95
  ;
91
96
  },
92
97
 
98
+ refresh: function() {
99
+ $icon = $module.find(selector.icon);
100
+ },
101
+
102
+ setup: {
103
+ layout: function() {
104
+ var
105
+ maxRating = $module.data(metadata.maxRating) || settings.maxRating
106
+ ;
107
+ module.debug('Generating icon html dynamically');
108
+ $module
109
+ .html($.fn.rating.settings.templates.icon(maxRating))
110
+ ;
111
+ module.refresh();
112
+ }
113
+ },
114
+
93
115
  event: {
94
116
  mouseenter: function() {
95
117
  var
@@ -97,32 +119,35 @@ $.fn.rating = function(parameters) {
97
119
  ;
98
120
  $activeIcon
99
121
  .nextAll()
100
- .removeClass(className.hover)
122
+ .removeClass(className.selected)
101
123
  ;
102
124
  $module
103
- .addClass(className.hover)
125
+ .addClass(className.selected)
104
126
  ;
105
127
  $activeIcon
106
- .addClass(className.hover)
128
+ .addClass(className.selected)
107
129
  .prevAll()
108
- .addClass(className.hover)
130
+ .addClass(className.selected)
109
131
  ;
110
132
  },
111
133
  mouseleave: function() {
112
134
  $module
113
- .removeClass(className.hover)
135
+ .removeClass(className.selected)
114
136
  ;
115
137
  $icon
116
- .removeClass(className.hover)
138
+ .removeClass(className.selected)
117
139
  ;
118
140
  },
119
141
  click: function() {
120
142
  var
121
143
  $activeIcon = $(this),
122
144
  currentRating = module.getRating(),
123
- rating = $icon.index($activeIcon) + 1
145
+ rating = $icon.index($activeIcon) + 1,
146
+ canClear = (settings.clearable == 'auto')
147
+ ? ($icon.size() === 1)
148
+ : settings.clearable
124
149
  ;
125
- if(settings.clearable && currentRating == rating) {
150
+ if(canClear && currentRating == rating) {
126
151
  module.clearRating();
127
152
  }
128
153
  else {
@@ -174,17 +199,17 @@ $.fn.rating = function(parameters) {
174
199
  $activeIcon = $icon.eq(ratingIndex)
175
200
  ;
176
201
  $module
177
- .removeClass(className.hover)
202
+ .removeClass(className.selected)
178
203
  ;
179
204
  $icon
180
- .removeClass(className.hover)
205
+ .removeClass(className.selected)
181
206
  .removeClass(className.active)
182
207
  ;
183
208
  if(rating > 0) {
184
209
  module.verbose('Setting current rating to', rating);
185
210
  $activeIcon
186
- .addClass(className.active)
187
- .prevAll()
211
+ .prevAll()
212
+ .andSelf()
188
213
  .addClass(className.active)
189
214
  ;
190
215
  }
@@ -192,6 +217,7 @@ $.fn.rating = function(parameters) {
192
217
  },
193
218
 
194
219
  setting: function(name, value) {
220
+ module.debug('Changing setting', name, value);
195
221
  if( $.isPlainObject(name) ) {
196
222
  $.extend(true, settings, name);
197
223
  }
@@ -252,9 +278,9 @@ $.fn.rating = function(parameters) {
252
278
  executionTime = currentTime - previousTime;
253
279
  time = currentTime;
254
280
  performance.push({
255
- 'Element' : element,
256
281
  'Name' : message[0],
257
282
  'Arguments' : [].slice.call(message, 1) || '',
283
+ 'Element' : element,
258
284
  'Execution Time' : executionTime
259
285
  });
260
286
  }
@@ -373,33 +399,51 @@ $.fn.rating.settings = {
373
399
  name : 'Rating',
374
400
  namespace : 'rating',
375
401
 
376
- verbose : true,
377
402
  debug : false,
403
+ verbose : true,
378
404
  performance : true,
379
405
 
380
406
  initialRating : 0,
381
407
  interactive : true,
382
- clearable : false,
408
+ maxRating : 4,
409
+ clearable : 'auto',
383
410
 
384
411
  onRate : function(rating){},
385
412
 
386
- error : {
387
- method : 'The method you called is not defined'
413
+ error : {
414
+ method : 'The method you called is not defined',
415
+ noMaximum : 'No maximum rating specified. Cannot generate HTML automatically'
388
416
  },
389
417
 
418
+
390
419
  metadata: {
391
- rating: 'rating'
420
+ rating : 'rating',
421
+ maxRating : 'maxRating'
392
422
  },
393
423
 
394
424
  className : {
395
425
  active : 'active',
396
426
  disabled : 'disabled',
397
- hover : 'hover',
427
+ selected : 'selected',
398
428
  loading : 'loading'
399
429
  },
400
430
 
401
431
  selector : {
402
432
  icon : '.icon'
433
+ },
434
+
435
+ templates: {
436
+ icon: function(maxRating) {
437
+ var
438
+ icon = 1,
439
+ html = ''
440
+ ;
441
+ while(icon <= maxRating) {
442
+ html += '<i class="icon"></i>';
443
+ icon++;
444
+ }
445
+ return html;
446
+ }
403
447
  }
404
448
 
405
449
  };
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  * # Semantic - Search
3
- * http://github.com/jlukic/semantic-ui/
3
+ * http://github.com/semantic-org/semantic-ui/
4
4
  *
5
5
  *
6
- * Copyright 2014 Contributors
6
+ * Copyright 2014 Contributor
7
7
  * Released under the MIT license
8
8
  * http://opensource.org/licenses/MIT
9
9
  *
@@ -11,7 +11,9 @@
11
11
 
12
12
  ;(function ($, window, document, undefined) {
13
13
 
14
- $.fn.search = function(source, parameters) {
14
+ "use strict";
15
+
16
+ $.fn.search = function(parameters) {
15
17
  var
16
18
  $allModules = $(this),
17
19
  moduleSelector = $allModules.selector || '',
@@ -55,27 +57,28 @@ $.fn.search = function(source, parameters) {
55
57
  module.verbose('Initializing module');
56
58
  var
57
59
  prompt = $prompt[0],
58
- inputEvent = (prompt.oninput !== undefined)
60
+ inputEvent = (prompt !== undefined && prompt.oninput !== undefined)
59
61
  ? 'input'
60
- : (prompt.onpropertychange !== undefined)
62
+ : (prompt !== undefined && prompt.onpropertychange !== undefined)
61
63
  ? 'propertychange'
62
64
  : 'keyup'
63
65
  ;
64
- // attach events
65
- $prompt
66
- .on('focus' + eventNamespace, module.event.focus)
67
- .on('blur' + eventNamespace, module.event.blur)
68
- .on('keydown' + eventNamespace, module.handleKeyboard)
69
- ;
70
66
  if(settings.automatic) {
71
67
  $prompt
72
68
  .on(inputEvent + eventNamespace, module.search.throttle)
73
69
  ;
74
70
  }
71
+ $prompt
72
+ .on('focus' + eventNamespace, module.event.focus)
73
+ .on('blur' + eventNamespace, module.event.blur)
74
+ .on('keydown' + eventNamespace, module.handleKeyboard)
75
+ ;
75
76
  $searchButton
76
77
  .on('click' + eventNamespace, module.search.query)
77
78
  ;
78
79
  $results
80
+ .on('mousedown' + eventNamespace, module.event.mousedown)
81
+ .on('mouseup' + eventNamespace, module.event.mouseup)
79
82
  .on('click' + eventNamespace, selector.result, module.results.select)
80
83
  ;
81
84
  module.instantiate();
@@ -92,20 +95,41 @@ $.fn.search = function(source, parameters) {
92
95
  $module
93
96
  .removeData(moduleNamespace)
94
97
  ;
98
+ $prompt
99
+ .off(eventNamespace)
100
+ ;
101
+ $searchButton
102
+ .off(eventNamespace)
103
+ ;
104
+ $results
105
+ .off(eventNamespace)
106
+ ;
95
107
  },
96
108
  event: {
97
109
  focus: function() {
98
110
  $module
99
111
  .addClass(className.focus)
100
112
  ;
101
- module.results.show();
113
+ clearTimeout(module.timer);
114
+ module.search.throttle();
115
+ if(module.has.minimum()) {
116
+ module.results.show();
117
+ }
102
118
  },
103
- blur: function() {
119
+ mousedown: function() {
120
+ module.resultsClicked = true;
121
+ },
122
+ mouseup: function() {
123
+ module.resultsClicked = false;
124
+ },
125
+ blur: function(event) {
104
126
  module.search.cancel();
105
127
  $module
106
128
  .removeClass(className.focus)
107
129
  ;
108
- module.results.hide();
130
+ if(!module.resultsClicked) {
131
+ module.timer = setTimeout(module.results.hide, settings.hideDelay);
132
+ }
109
133
  }
110
134
  },
111
135
  handleKeyboard: function(event) {
@@ -138,7 +162,7 @@ $.fn.search = function(source, parameters) {
138
162
  if(keyCode == keys.enter) {
139
163
  module.verbose('Enter key pressed, selecting active result');
140
164
  if( $result.filter('.' + activeClass).size() > 0 ) {
141
- $.proxy(module.results.select, $result.filter('.' + activeClass) )();
165
+ $.proxy(module.results.select, $result.filter('.' + activeClass) )(event);
142
166
  event.preventDefault();
143
167
  return false;
144
168
  }
@@ -198,6 +222,15 @@ $.fn.search = function(source, parameters) {
198
222
  }
199
223
  }
200
224
  },
225
+ has: {
226
+ minimum: function() {
227
+ var
228
+ searchTerm = $prompt.val(),
229
+ numCharacters = searchTerm.length
230
+ ;
231
+ return (numCharacters >= settings.minCharacters);
232
+ }
233
+ },
201
234
  search: {
202
235
  cancel: function() {
203
236
  var
@@ -209,13 +242,9 @@ $.fn.search = function(source, parameters) {
209
242
  }
210
243
  },
211
244
  throttle: function() {
212
- var
213
- searchTerm = $prompt.val(),
214
- numCharacters = searchTerm.length
215
- ;
216
245
  clearTimeout(module.timer);
217
- if(numCharacters >= settings.minCharacters) {
218
- module.timer = setTimeout(module.search.query, settings.searchThrottle);
246
+ if(module.has.minimum()) {
247
+ module.timer = setTimeout(module.search.query, settings.searchDelay);
219
248
  }
220
249
  else {
221
250
  module.results.hide();
@@ -232,12 +261,22 @@ $.fn.search = function(source, parameters) {
232
261
  }
233
262
  else {
234
263
  module.debug("Querying for '" + searchTerm + "'");
235
- if(typeof source == 'object') {
264
+ if($.isPlainObject(settings.source) || $.isArray(settings.source)) {
236
265
  module.search.local(searchTerm);
237
266
  }
238
- else {
267
+ else if(settings.apiSettings) {
268
+ module.search.remote(searchTerm);
269
+ }
270
+ else if($.fn.api !== undefined && $.api.settings.api.search !== undefined) {
271
+ module.debug('Searching with default search API endpoint');
272
+ settings.apiSettings = {
273
+ action: 'search'
274
+ };
239
275
  module.search.remote(searchTerm);
240
276
  }
277
+ else {
278
+ module.error(error.source);
279
+ }
241
280
  $.proxy(settings.onSearchQuery, $module)(searchTerm);
242
281
  }
243
282
  },
@@ -248,7 +287,6 @@ $.fn.search = function(source, parameters) {
248
287
  searchFields = $.isArray(settings.searchFields)
249
288
  ? settings.searchFields
250
289
  : [settings.searchFields],
251
-
252
290
  searchRegExp = new RegExp('(?:\s|^)' + searchTerm, 'i'),
253
291
  fullTextRegExp = new RegExp(searchTerm, 'i'),
254
292
  searchHTML
@@ -258,13 +296,17 @@ $.fn.search = function(source, parameters) {
258
296
  ;
259
297
  // iterate through search fields in array order
260
298
  $.each(searchFields, function(index, field) {
261
- $.each(source, function(label, thing) {
262
- if(typeof thing[field] == 'string' && ($.inArray(thing, results) == -1) && ($.inArray(thing, fullTextResults) == -1) ) {
263
- if( searchRegExp.test( thing[field] ) ) {
264
- results.push(thing);
299
+ $.each(settings.source, function(label, content) {
300
+ var
301
+ fieldExists = (typeof content[field] == 'string'),
302
+ notAlreadyResult = ($.inArray(content, results) == -1 && $.inArray(content, fullTextResults) == -1)
303
+ ;
304
+ if(fieldExists && notAlreadyResult) {
305
+ if( content[field].match(searchRegExp) ) {
306
+ results.push(content);
265
307
  }
266
- else if( fullTextRegExp.test( thing[field] ) ) {
267
- fullTextResults.push(thing);
308
+ else if( settings.searchFullText && content[field].match(content[field]) ) {
309
+ fullTextResults.push(content);
268
310
  }
269
311
  }
270
312
  });
@@ -281,15 +323,16 @@ $.fn.search = function(source, parameters) {
281
323
  remote: function(searchTerm) {
282
324
  var
283
325
  apiSettings = {
284
- stateContext : $module,
285
- url : source,
286
- urlData: { query: searchTerm },
287
- success : function(response) {
326
+ stateContext : $module,
327
+ urlData : {
328
+ query: searchTerm
329
+ },
330
+ onSuccess : function(response) {
288
331
  searchHTML = module.results.generate(response);
289
332
  module.search.cache.write(searchTerm, searchHTML);
290
333
  module.results.add(searchHTML);
291
334
  },
292
- failure : module.error
335
+ onFailure : module.error
293
336
  },
294
337
  searchHTML
295
338
  ;
@@ -332,15 +375,16 @@ $.fn.search = function(source, parameters) {
332
375
  ;
333
376
  if(($.isPlainObject(response.results) && !$.isEmptyObject(response.results)) || ($.isArray(response.results) && response.results.length > 0) ) {
334
377
  if(settings.maxResults > 0) {
335
- response.results = $.makeArray(response.results).slice(0, settings.maxResults);
378
+ response.results = $.isArray(response.results)
379
+ ? response.results.slice(0, settings.maxResults)
380
+ : response.results
381
+ ;
336
382
  }
337
- if(response.results.length > 0) {
338
- if($.isFunction(template)) {
339
- html = template(response);
340
- }
341
- else {
342
- module.error(error.noTemplate, false);
343
- }
383
+ if($.isFunction(template)) {
384
+ html = template(response);
385
+ }
386
+ else {
387
+ module.error(error.noTemplate, false);
344
388
  }
345
389
  }
346
390
  else {
@@ -359,19 +403,45 @@ $.fn.search = function(source, parameters) {
359
403
  },
360
404
  show: function() {
361
405
  if( ($results.filter(':visible').size() === 0) && ($prompt.filter(':focus').size() > 0) && $results.html() !== '') {
362
- $results
363
- .stop()
364
- .fadeIn(200)
365
- ;
406
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported') && !$results.transition('is inward')) {
407
+ module.debug('Showing results with css animations');
408
+ $results
409
+ .transition({
410
+ animation : settings.transition + ' in',
411
+ duration : settings.duration,
412
+ queue : true
413
+ })
414
+ ;
415
+ }
416
+ else {
417
+ module.debug('Showing results with javascript');
418
+ $results
419
+ .stop()
420
+ .fadeIn(settings.duration, settings.easing)
421
+ ;
422
+ }
366
423
  $.proxy(settings.onResultsOpen, $results)();
367
424
  }
368
425
  },
369
426
  hide: function() {
370
427
  if($results.filter(':visible').size() > 0) {
371
- $results
372
- .stop()
373
- .fadeOut(200)
374
- ;
428
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported') && !$results.transition('is outward')) {
429
+ module.debug('Hiding results with css animations');
430
+ $results
431
+ .transition({
432
+ animation : settings.transition + ' out',
433
+ duration : settings.duration,
434
+ queue : true
435
+ })
436
+ ;
437
+ }
438
+ else {
439
+ module.debug('Hiding results with javascript');
440
+ $results
441
+ .stop()
442
+ .fadeIn(settings.duration, settings.easing)
443
+ ;
444
+ }
375
445
  $.proxy(settings.onResultsClose, $results)();
376
446
  }
377
447
  },
@@ -385,13 +455,17 @@ $.fn.search = function(source, parameters) {
385
455
  if(settings.onSelect == 'default' || $.proxy(settings.onSelect, this)(event) == 'default') {
386
456
  var
387
457
  $link = $result.find('a[href]').eq(0),
458
+ $title = $result.find(selector.title).eq(0),
388
459
  href = $link.attr('href') || false,
389
- target = $link.attr('target') || false
460
+ target = $link.attr('target') || false,
461
+ name = ($title.size() > 0)
462
+ ? $title.text()
463
+ : false
390
464
  ;
391
465
  module.results.hide();
392
- $prompt
393
- .val(title)
394
- ;
466
+ if(name) {
467
+ $prompt.val(name);
468
+ }
395
469
  if(href) {
396
470
  if(target == '_blank' || event.ctrlKey) {
397
471
  window.open(href);
@@ -404,6 +478,13 @@ $.fn.search = function(source, parameters) {
404
478
  }
405
479
  },
406
480
 
481
+ // displays mesage visibly in search results
482
+ message: function(text, type) {
483
+ type = type || 'standard';
484
+ module.results.add( settings.templates.message(text, type) );
485
+ return settings.templates.message(text, type);
486
+ },
487
+
407
488
  setting: function(name, value) {
408
489
  if( $.isPlainObject(name) ) {
409
490
  $.extend(true, settings, name);
@@ -465,9 +546,9 @@ $.fn.search = function(source, parameters) {
465
546
  executionTime = currentTime - previousTime;
466
547
  time = currentTime;
467
548
  performance.push({
468
- 'Element' : element,
469
549
  'Name' : message[0],
470
550
  'Arguments' : [].slice.call(message, 1) || '',
551
+ 'Element' : element,
471
552
  'Execution Time' : executionTime
472
553
  });
473
554
  }
@@ -591,6 +672,28 @@ $.fn.search.settings = {
591
672
  verbose : true,
592
673
  performance : true,
593
674
 
675
+ // api config
676
+ apiSettings : false,
677
+ type : 'standard',
678
+ minCharacters : 1,
679
+
680
+ source : false,
681
+ searchFields : [
682
+ 'title',
683
+ 'description'
684
+ ],
685
+ searchFullText : true,
686
+
687
+ automatic : 'true',
688
+ hideDelay : 0,
689
+ searchDelay : 300,
690
+ maxResults : 7,
691
+ cache : true,
692
+
693
+ transition : 'scale',
694
+ duration : 300,
695
+ easing : 'easeOutExpo',
696
+
594
697
  // onSelect default action is defined in module
595
698
  onSelect : 'default',
596
699
  onResultsAdd : 'default',
@@ -601,23 +704,6 @@ $.fn.search.settings = {
601
704
  onResultsOpen : function(){},
602
705
  onResultsClose : function(){},
603
706
 
604
- automatic : 'true',
605
- type : 'simple',
606
- minCharacters : 3,
607
- searchThrottle : 300,
608
- maxResults : 7,
609
- cache : true,
610
-
611
- searchFields : [
612
- 'title',
613
- 'description'
614
- ],
615
-
616
- // api config
617
- apiSettings: {
618
-
619
- },
620
-
621
707
  className: {
622
708
  active : 'active',
623
709
  down : 'down',
@@ -627,6 +713,7 @@ $.fn.search.settings = {
627
713
  },
628
714
 
629
715
  error : {
716
+ source : 'Cannot search. No source used, and Semantic API module was not included',
630
717
  noResults : 'Your search returned no results',
631
718
  logging : 'Error in debug logging, exiting.',
632
719
  noTemplate : 'A valid template name was not specified.',
@@ -639,17 +726,39 @@ $.fn.search.settings = {
639
726
  searchButton : '.search.button',
640
727
  results : '.results',
641
728
  category : '.category',
642
- result : '.result'
729
+ result : '.result',
730
+ title : '.title, .name'
643
731
  },
644
732
 
645
733
  templates: {
734
+ escape: function(string) {
735
+ var
736
+ badChars = /[&<>"'`]/g,
737
+ shouldEscape = /[&<>"'`]/,
738
+ escape = {
739
+ "&": "&amp;",
740
+ "<": "&lt;",
741
+ ">": "&gt;",
742
+ '"': "&quot;",
743
+ "'": "&#x27;",
744
+ "`": "&#x60;"
745
+ },
746
+ escapedChar = function(chr) {
747
+ return escape[chr];
748
+ }
749
+ ;
750
+ if(shouldEscape.test(string)) {
751
+ return string.replace(badChars, escapedChar);
752
+ }
753
+ return string;
754
+ },
646
755
  message: function(message, type) {
647
756
  var
648
757
  html = ''
649
758
  ;
650
759
  if(message !== undefined && type !== undefined) {
651
760
  html += ''
652
- + '<div class="message ' + type +'">'
761
+ + '<div class="message ' + type + '">'
653
762
  ;
654
763
  // message type
655
764
  if(type == 'empty') {
@@ -665,9 +774,10 @@ $.fn.search.settings = {
665
774
  }
666
775
  return html;
667
776
  },
668
- categories: function(response) {
777
+ category: function(response) {
669
778
  var
670
- html = ''
779
+ html = '',
780
+ escape = $.fn.search.settings.templates.escape
671
781
  ;
672
782
  if(response.results !== undefined) {
673
783
  // each category
@@ -680,23 +790,28 @@ $.fn.search.settings = {
680
790
  // each item inside category
681
791
  $.each(category.results, function(index, result) {
682
792
  html += '<div class="result">';
683
- html += '<a href="' + result.url + '"></a>';
793
+ if(result.url) {
794
+ html += '<a href="' + result.url + '"></a>';
795
+ }
684
796
  if(result.image !== undefined) {
685
- html+= ''
797
+ result.image = escape(result.image);
798
+ html += ''
686
799
  + '<div class="image">'
687
- + ' <img src="' + result.image + '">'
800
+ + ' <img src="' + result.image + '" alt="">'
688
801
  + '</div>'
689
802
  ;
690
803
  }
691
- html += '<div class="info">';
804
+ html += '<div class="content">';
692
805
  if(result.price !== undefined) {
693
- html+= '<div class="price">' + result.price + '</div>';
806
+ result.price = escape(result.price);
807
+ html += '<div class="price">' + result.price + '</div>';
694
808
  }
695
809
  if(result.title !== undefined) {
696
- html+= '<div class="title">' + result.title + '</div>';
810
+ result.title = escape(result.title);
811
+ html += '<div class="title">' + result.title + '</div>';
697
812
  }
698
813
  if(result.description !== undefined) {
699
- html+= '<div class="description">' + result.description + '</div>';
814
+ html += '<div class="description">' + result.description + '</div>';
700
815
  }
701
816
  html += ''
702
817
  + '</div>'
@@ -708,17 +823,17 @@ $.fn.search.settings = {
708
823
  ;
709
824
  }
710
825
  });
711
- if(response.resultPage) {
826
+ if(response.action) {
712
827
  html += ''
713
- + '<a href="' + response.resultPage.url + '" class="all">'
714
- + response.resultPage.text
828
+ + '<a href="' + response.action.url + '" class="action">'
829
+ + response.action.text
715
830
  + '</a>';
716
831
  }
717
832
  return html;
718
833
  }
719
834
  return false;
720
835
  },
721
- simple: function(response) {
836
+ standard: function(response) {
722
837
  var
723
838
  html = ''
724
839
  ;
@@ -726,34 +841,39 @@ $.fn.search.settings = {
726
841
 
727
842
  // each result
728
843
  $.each(response.results, function(index, result) {
729
- html += '<a class="result" href="' + result.url + '">';
844
+ if(result.url) {
845
+ html += '<a class="result" href="' + result.url + '">';
846
+ }
847
+ else {
848
+ html += '<a class="result">';
849
+ }
730
850
  if(result.image !== undefined) {
731
- html+= ''
851
+ html += ''
732
852
  + '<div class="image">'
733
853
  + ' <img src="' + result.image + '">'
734
854
  + '</div>'
735
855
  ;
736
856
  }
737
- html += '<div class="info">';
857
+ html += '<div class="content">';
738
858
  if(result.price !== undefined) {
739
- html+= '<div class="price">' + result.price + '</div>';
859
+ html += '<div class="price">' + result.price + '</div>';
740
860
  }
741
861
  if(result.title !== undefined) {
742
- html+= '<div class="title">' + result.title + '</div>';
862
+ html += '<div class="title">' + result.title + '</div>';
743
863
  }
744
864
  if(result.description !== undefined) {
745
- html+= '<div class="description">' + result.description + '</div>';
865
+ html += '<div class="description">' + result.description + '</div>';
746
866
  }
747
867
  html += ''
748
868
  + '</div>'
749
- + '</a>'
750
869
  ;
870
+ html += '</a>';
751
871
  });
752
872
 
753
- if(response.resultPage) {
873
+ if(response.action) {
754
874
  html += ''
755
- + '<a href="' + response.resultPage.url + '" class="all">'
756
- + response.resultPage.text
875
+ + '<a href="' + response.action.url + '" class="action">'
876
+ + response.action.text
757
877
  + '</a>';
758
878
  }
759
879
  return html;
@@ -763,4 +883,4 @@ $.fn.search.settings = {
763
883
  }
764
884
  };
765
885
 
766
- })( jQuery, window , document );
886
+ })( jQuery, window , document );