semantic-ui-sass 2.0.7.0 → 2.1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/semantic-ui/accordion.js +17 -13
- data/app/assets/javascripts/semantic-ui/api.js +25 -7
- data/app/assets/javascripts/semantic-ui/checkbox.js +124 -48
- data/app/assets/javascripts/semantic-ui/dropdown.js +193 -108
- data/app/assets/javascripts/semantic-ui/embed.js +1 -4
- data/app/assets/javascripts/semantic-ui/form.js +125 -12
- data/app/assets/javascripts/semantic-ui/modal.js +13 -13
- data/app/assets/javascripts/semantic-ui/nag.js +11 -1
- data/app/assets/javascripts/semantic-ui/popup.js +23 -10
- data/app/assets/javascripts/semantic-ui/search.js +83 -54
- data/app/assets/javascripts/semantic-ui/sticky.js +34 -32
- data/app/assets/javascripts/semantic-ui/tab.js +8 -7
- data/app/assets/javascripts/semantic-ui/transition.js +5 -5
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +2 -2
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +102 -31
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +159 -10
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +151 -60
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +18 -1
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +187 -97
- data/app/assets/stylesheets/semantic-ui/elements/_container.scss +29 -5
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +6 -3
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +1 -3
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +23 -38
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +69 -39
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +423 -222
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +16 -1
- data/app/assets/stylesheets/semantic-ui/elements/_loader.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_rail.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_reveal.scss +5 -13
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +9 -6
- data/app/assets/stylesheets/semantic-ui/globals/_reset.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/globals/_site.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_accordion.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_checkbox.scss +7 -7
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +26 -9
- data/app/assets/stylesheets/semantic-ui/modules/_embed.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_modal.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_nag.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_popup.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_progress.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_rating.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_search.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_shape.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_sidebar.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_sticky.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_tab.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_transition.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_ad.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_card.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_comment.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_feed.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_item.scss +7 -7
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +1 -1
- data/lib/semantic/ui/sass/version.rb +2 -2
- metadata +2 -2
@@ -97,7 +97,6 @@ $.fn.embed = function(parameters) {
|
|
97
97
|
events: function() {
|
98
98
|
if( module.has.placeholder() ) {
|
99
99
|
module.debug('Adding placeholder events');
|
100
|
-
console.log($module, selector.placeholder);
|
101
100
|
$module
|
102
101
|
.on('click' + eventNamespace, selector.placeholder, module.createAndShow)
|
103
102
|
.on('click' + eventNamespace, selector.icon, module.createAndShow)
|
@@ -132,7 +131,6 @@ $.fn.embed = function(parameters) {
|
|
132
131
|
createEmbed: function(url) {
|
133
132
|
module.refresh();
|
134
133
|
url = url || module.get.url();
|
135
|
-
console.log(url);
|
136
134
|
$embed = $('<div/>')
|
137
135
|
.addClass(className.embed)
|
138
136
|
.html( module.generate.embed(url) )
|
@@ -143,7 +141,6 @@ $.fn.embed = function(parameters) {
|
|
143
141
|
},
|
144
142
|
|
145
143
|
createAndShow: function() {
|
146
|
-
console.log('cands');
|
147
144
|
module.createEmbed();
|
148
145
|
module.show();
|
149
146
|
},
|
@@ -630,7 +627,7 @@ $.fn.embed.settings = {
|
|
630
627
|
templates: {
|
631
628
|
iframe : function(url, parameters) {
|
632
629
|
return ''
|
633
|
-
+ '<iframe src="' + url + '
|
630
|
+
+ '<iframe src="' + url + '?' + parameters + '"'
|
634
631
|
+ ' width="100%" height="100%"'
|
635
632
|
+ ' frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
|
636
633
|
;
|
@@ -455,11 +455,10 @@ $.fn.form = function(parameters) {
|
|
455
455
|
}
|
456
456
|
if(isCheckbox) {
|
457
457
|
if(isChecked) {
|
458
|
-
values[name].push(
|
458
|
+
values[name].push(true);
|
459
459
|
}
|
460
460
|
else {
|
461
|
-
|
462
|
-
return true;
|
461
|
+
values[name].push(false);
|
463
462
|
}
|
464
463
|
}
|
465
464
|
else {
|
@@ -477,8 +476,7 @@ $.fn.form = function(parameters) {
|
|
477
476
|
values[name] = true;
|
478
477
|
}
|
479
478
|
else {
|
480
|
-
|
481
|
-
return true;
|
479
|
+
values[name] = false;
|
482
480
|
}
|
483
481
|
}
|
484
482
|
else {
|
@@ -685,6 +683,7 @@ $.fn.form = function(parameters) {
|
|
685
683
|
|
686
684
|
form: function(event) {
|
687
685
|
var
|
686
|
+
values = module.get.values(),
|
688
687
|
apiRequest
|
689
688
|
;
|
690
689
|
|
@@ -698,7 +697,7 @@ $.fn.form = function(parameters) {
|
|
698
697
|
if( module.is.valid() ) {
|
699
698
|
module.debug('Form has no validation errors, submitting');
|
700
699
|
module.set.success();
|
701
|
-
return settings.onSuccess.call(element, event);
|
700
|
+
return settings.onSuccess.call(element, event, values);
|
702
701
|
}
|
703
702
|
else {
|
704
703
|
module.debug('Form has errors');
|
@@ -710,7 +709,7 @@ $.fn.form = function(parameters) {
|
|
710
709
|
if($module.data('moduleApi') !== undefined) {
|
711
710
|
event.stopImmediatePropagation();
|
712
711
|
}
|
713
|
-
return settings.onFailure.call(element, formErrors);
|
712
|
+
return settings.onFailure.call(element, formErrors, values);
|
714
713
|
}
|
715
714
|
},
|
716
715
|
|
@@ -990,10 +989,12 @@ $.fn.form.settings = {
|
|
990
989
|
|
991
990
|
regExp: {
|
992
991
|
bracket : /\[(.*)\]/i,
|
993
|
-
|
992
|
+
decimal : /^\-?\d*(\.\d+)?$/,
|
994
993
|
email : "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
|
995
|
-
|
994
|
+
escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
|
996
995
|
flags : /^\/(.*)\/(.*)?/,
|
996
|
+
integer : /^\-?\d+$/,
|
997
|
+
number : /^\-?\d*(\.\d+)?$/,
|
997
998
|
url : /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i
|
998
999
|
},
|
999
1000
|
|
@@ -1020,10 +1021,10 @@ $.fn.form.settings = {
|
|
1020
1021
|
},
|
1021
1022
|
|
1022
1023
|
error: {
|
1023
|
-
oldSyntax : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.',
|
1024
1024
|
identifier : 'You must specify a string identifier for each field',
|
1025
|
+
method : 'The method you called is not defined.',
|
1025
1026
|
noRule : 'There is no rule matching the one you specified',
|
1026
|
-
|
1027
|
+
oldSyntax : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.'
|
1027
1028
|
},
|
1028
1029
|
|
1029
1030
|
templates: {
|
@@ -1043,7 +1044,7 @@ $.fn.form.settings = {
|
|
1043
1044
|
// template that produces label
|
1044
1045
|
prompt: function(errors) {
|
1045
1046
|
return $('<div/>')
|
1046
|
-
.addClass('ui red pointing prompt label')
|
1047
|
+
.addClass('ui basic red pointing prompt label')
|
1047
1048
|
.html(errors[0])
|
1048
1049
|
;
|
1049
1050
|
}
|
@@ -1126,6 +1127,15 @@ $.fn.form.settings = {
|
|
1126
1127
|
);
|
1127
1128
|
},
|
1128
1129
|
|
1130
|
+
// is valid number (with decimal)
|
1131
|
+
decimal: function(value) {
|
1132
|
+
return $.fn.form.settings.regExp.decimal.test(value);
|
1133
|
+
},
|
1134
|
+
|
1135
|
+
// is valid number
|
1136
|
+
number: function(value) {
|
1137
|
+
return $.fn.form.settings.regExp.number.test(value);
|
1138
|
+
},
|
1129
1139
|
|
1130
1140
|
// is value (case insensitive)
|
1131
1141
|
is: function(value, text) {
|
@@ -1246,6 +1256,109 @@ $.fn.form.settings = {
|
|
1246
1256
|
: false
|
1247
1257
|
;
|
1248
1258
|
},
|
1259
|
+
creditCard: function(cardNumber, cardTypes) {
|
1260
|
+
var
|
1261
|
+
cards = {
|
1262
|
+
visa: {
|
1263
|
+
pattern : /^4/,
|
1264
|
+
length : [16]
|
1265
|
+
},
|
1266
|
+
amex: {
|
1267
|
+
pattern : /^3[47]/,
|
1268
|
+
length : [15]
|
1269
|
+
},
|
1270
|
+
mastercard: {
|
1271
|
+
pattern : /^5[1-5]/,
|
1272
|
+
length : [16]
|
1273
|
+
},
|
1274
|
+
discover: {
|
1275
|
+
pattern : /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,
|
1276
|
+
length : [16]
|
1277
|
+
},
|
1278
|
+
unionPay: {
|
1279
|
+
pattern : /^(62|88)/,
|
1280
|
+
length : [16, 17, 18, 19]
|
1281
|
+
},
|
1282
|
+
jcb: {
|
1283
|
+
pattern : /^35(2[89]|[3-8][0-9])/,
|
1284
|
+
length : [16]
|
1285
|
+
},
|
1286
|
+
maestro: {
|
1287
|
+
pattern : /^(5018|5020|5038|6304|6759|676[1-3])/,
|
1288
|
+
length : [12, 13, 14, 15, 16, 17, 18, 19]
|
1289
|
+
},
|
1290
|
+
dinersClub: {
|
1291
|
+
pattern : /^(30[0-5]|^36)/,
|
1292
|
+
length : [14]
|
1293
|
+
},
|
1294
|
+
laser: {
|
1295
|
+
pattern : /^(6304|670[69]|6771)/,
|
1296
|
+
length : [16, 17, 18, 19]
|
1297
|
+
},
|
1298
|
+
visaElectron: {
|
1299
|
+
pattern : /^(4026|417500|4508|4844|491(3|7))/,
|
1300
|
+
length : [16]
|
1301
|
+
}
|
1302
|
+
},
|
1303
|
+
valid = {},
|
1304
|
+
validCard = false,
|
1305
|
+
requiredTypes = (typeof cardTypes == 'string')
|
1306
|
+
? cardTypes.split(',')
|
1307
|
+
: false,
|
1308
|
+
unionPay,
|
1309
|
+
validation
|
1310
|
+
;
|
1311
|
+
|
1312
|
+
if(typeof cardNumber !== 'string' || cardNumber.length === 0) {
|
1313
|
+
return;
|
1314
|
+
}
|
1315
|
+
|
1316
|
+
// verify card types
|
1317
|
+
if(requiredTypes) {
|
1318
|
+
$.each(requiredTypes, function(index, type){
|
1319
|
+
// verify each card type
|
1320
|
+
validation = cards[type];
|
1321
|
+
if(validation) {
|
1322
|
+
valid = {
|
1323
|
+
length : ($.inArray(cardNumber.length, validation.length) !== -1),
|
1324
|
+
pattern : (cardNumber.search(validation.pattern) !== -1)
|
1325
|
+
};
|
1326
|
+
if(valid.length && valid.pattern) {
|
1327
|
+
validCard = true;
|
1328
|
+
}
|
1329
|
+
}
|
1330
|
+
});
|
1331
|
+
|
1332
|
+
if(!validCard) {
|
1333
|
+
return false;
|
1334
|
+
}
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
// skip luhn for UnionPay
|
1338
|
+
unionPay = {
|
1339
|
+
number : ($.inArray(cardNumber.length, cards.unionPay.length) !== -1),
|
1340
|
+
pattern : (cardNumber.search(cards.unionPay.pattern) !== -1)
|
1341
|
+
};
|
1342
|
+
if(unionPay.number && unionPay.pattern) {
|
1343
|
+
return true;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
// verify luhn, adapted from <https://gist.github.com/2134376>
|
1347
|
+
var
|
1348
|
+
length = cardNumber.length,
|
1349
|
+
multiple = 0,
|
1350
|
+
producedValue = [
|
1351
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
1352
|
+
[0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
|
1353
|
+
],
|
1354
|
+
sum = 0
|
1355
|
+
;
|
1356
|
+
while (length--) {
|
1357
|
+
sum += producedValue[multiple][parseInt(cardNumber.charAt(length), 10)];
|
1358
|
+
multiple ^= 1;
|
1359
|
+
}
|
1360
|
+
return (sum % 10 === 0 && sum > 0);
|
1361
|
+
},
|
1249
1362
|
|
1250
1363
|
// different than another field
|
1251
1364
|
different: function(value, identifier) {
|
@@ -341,7 +341,9 @@ $.fn.modal = function(parameters) {
|
|
341
341
|
module.add.keyboardShortcuts();
|
342
342
|
module.save.focus();
|
343
343
|
module.set.active();
|
344
|
-
|
344
|
+
if(settings.autofocus) {
|
345
|
+
module.set.autofocus();
|
346
|
+
}
|
345
347
|
callback();
|
346
348
|
}
|
347
349
|
})
|
@@ -562,17 +564,15 @@ $.fn.modal = function(parameters) {
|
|
562
564
|
|
563
565
|
set: {
|
564
566
|
autofocus: function() {
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
$input.focus();
|
575
|
-
}
|
567
|
+
var
|
568
|
+
$inputs = $module.find(':input').filter(':visible'),
|
569
|
+
$autofocus = $inputs.filter('[autofocus]'),
|
570
|
+
$input = ($autofocus.length > 0)
|
571
|
+
? $autofocus.first()
|
572
|
+
: $inputs.first()
|
573
|
+
;
|
574
|
+
if($input.length > 0) {
|
575
|
+
$input.focus();
|
576
576
|
}
|
577
577
|
},
|
578
578
|
clickaway: function() {
|
@@ -866,7 +866,7 @@ $.fn.modal.settings = {
|
|
866
866
|
onDeny : function(){ return true; },
|
867
867
|
|
868
868
|
selector : {
|
869
|
-
close : '.close',
|
869
|
+
close : '> .close',
|
870
870
|
approve : '.actions .positive, .actions .approve, .actions .ok',
|
871
871
|
deny : '.actions .negative, .actions .deny, .actions .cancel',
|
872
872
|
modal : '.ui.modal'
|
@@ -194,6 +194,10 @@ $.fn.nag = function(parameters) {
|
|
194
194
|
window.localStorage.setItem(key, value);
|
195
195
|
module.debug('Value stored using local storage', key, value);
|
196
196
|
}
|
197
|
+
else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) {
|
198
|
+
window.sessionStorage.setItem(key, value);
|
199
|
+
module.debug('Value stored using session storage', key, value);
|
200
|
+
}
|
197
201
|
else if($.cookie !== undefined) {
|
198
202
|
$.cookie(key, value, options);
|
199
203
|
module.debug('Value stored using cookie', key, value, options);
|
@@ -210,6 +214,9 @@ $.fn.nag = function(parameters) {
|
|
210
214
|
if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) {
|
211
215
|
storedValue = window.localStorage.getItem(key);
|
212
216
|
}
|
217
|
+
else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) {
|
218
|
+
storedValue = window.sessionStorage.getItem(key);
|
219
|
+
}
|
213
220
|
// get by cookie
|
214
221
|
else if($.cookie !== undefined) {
|
215
222
|
storedValue = $.cookie(key);
|
@@ -226,9 +233,12 @@ $.fn.nag = function(parameters) {
|
|
226
233
|
var
|
227
234
|
options = module.get.storageOptions()
|
228
235
|
;
|
229
|
-
if(settings.storageMethod == '
|
236
|
+
if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) {
|
230
237
|
window.localStorage.removeItem(key);
|
231
238
|
}
|
239
|
+
else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) {
|
240
|
+
window.sessionStorage.removeItem(key);
|
241
|
+
}
|
232
242
|
// store by cookie
|
233
243
|
else if($.cookie !== undefined) {
|
234
244
|
$.removeCookie(key, options);
|
@@ -96,7 +96,7 @@ $.fn.popup = function(parameters) {
|
|
96
96
|
}
|
97
97
|
else {
|
98
98
|
if(settings.inline) {
|
99
|
-
$popup = $target.
|
99
|
+
$popup = $target.nextAll(selector.popup).eq(0);
|
100
100
|
settings.popup = $popup;
|
101
101
|
}
|
102
102
|
}
|
@@ -124,6 +124,9 @@ $.fn.popup = function(parameters) {
|
|
124
124
|
module.debug('Setting page as offset parent');
|
125
125
|
$offsetParent = $body;
|
126
126
|
}
|
127
|
+
if( module.get.variation() ) {
|
128
|
+
module.set.variation();
|
129
|
+
}
|
127
130
|
},
|
128
131
|
|
129
132
|
reposition: function() {
|
@@ -194,7 +197,6 @@ $.fn.popup = function(parameters) {
|
|
194
197
|
create: function() {
|
195
198
|
var
|
196
199
|
html = module.get.html(),
|
197
|
-
variation = module.get.variation(),
|
198
200
|
title = module.get.title(),
|
199
201
|
content = module.get.content()
|
200
202
|
;
|
@@ -209,15 +211,9 @@ $.fn.popup = function(parameters) {
|
|
209
211
|
}
|
210
212
|
$popup = $('<div/>')
|
211
213
|
.addClass(className.popup)
|
212
|
-
.addClass(variation)
|
213
214
|
.data(metadata.activator, $module)
|
214
215
|
.html(html)
|
215
216
|
;
|
216
|
-
if(variation) {
|
217
|
-
$popup
|
218
|
-
.addClass(variation)
|
219
|
-
;
|
220
|
-
}
|
221
217
|
if(settings.inline) {
|
222
218
|
module.verbose('Inserting popup element inline', $popup);
|
223
219
|
$popup
|
@@ -231,6 +227,8 @@ $.fn.popup = function(parameters) {
|
|
231
227
|
;
|
232
228
|
}
|
233
229
|
module.refresh();
|
230
|
+
module.set.variation();
|
231
|
+
|
234
232
|
if(settings.hoverable) {
|
235
233
|
module.bind.popup();
|
236
234
|
}
|
@@ -344,12 +342,12 @@ $.fn.popup = function(parameters) {
|
|
344
342
|
},
|
345
343
|
|
346
344
|
removePopup: function() {
|
347
|
-
module.debug('Removing popup', $popup);
|
348
345
|
if( module.has.popup() && !settings.popup) {
|
346
|
+
module.debug('Removing popup', $popup);
|
349
347
|
$popup.remove();
|
350
348
|
$popup = undefined;
|
349
|
+
settings.onRemove.call($popup, element);
|
351
350
|
}
|
352
|
-
settings.onRemove.call($popup, element);
|
353
351
|
},
|
354
352
|
|
355
353
|
save: {
|
@@ -853,6 +851,14 @@ $.fn.popup = function(parameters) {
|
|
853
851
|
$popup.css('width', calculations.container.width);
|
854
852
|
},
|
855
853
|
|
854
|
+
variation: function(variation) {
|
855
|
+
variation = variation || module.get.variation();
|
856
|
+
if(variation && module.has.popup() ) {
|
857
|
+
module.verbose('Adding variation to popup', variation);
|
858
|
+
$popup.addClass(variation);
|
859
|
+
}
|
860
|
+
},
|
861
|
+
|
856
862
|
visible: function() {
|
857
863
|
$module.addClass(className.visible);
|
858
864
|
}
|
@@ -862,6 +868,13 @@ $.fn.popup = function(parameters) {
|
|
862
868
|
loading: function() {
|
863
869
|
$popup.removeClass(className.loading);
|
864
870
|
},
|
871
|
+
variation: function(variation) {
|
872
|
+
variation = variation || module.get.variation();
|
873
|
+
if(variation) {
|
874
|
+
module.verbose('Removing variation', variation);
|
875
|
+
$popup.removeClass(variation);
|
876
|
+
}
|
877
|
+
},
|
865
878
|
visible: function() {
|
866
879
|
$module.removeClass(className.visible);
|
867
880
|
},
|
@@ -36,6 +36,7 @@ $.fn.search = function(parameters) {
|
|
36
36
|
className = settings.className,
|
37
37
|
metadata = settings.metadata,
|
38
38
|
regExp = settings.regExp,
|
39
|
+
fields = settings.fields,
|
39
40
|
selector = settings.selector,
|
40
41
|
error = settings.error,
|
41
42
|
namespace = settings.namespace,
|
@@ -126,7 +127,9 @@ $.fn.search = function(parameters) {
|
|
126
127
|
module.set.focus();
|
127
128
|
if( module.has.minimumCharacters() ) {
|
128
129
|
module.query();
|
129
|
-
module.
|
130
|
+
if( module.can.show() ) {
|
131
|
+
module.showResults();
|
132
|
+
}
|
130
133
|
}
|
131
134
|
},
|
132
135
|
blur: function(event) {
|
@@ -288,6 +291,9 @@ $.fn.search = function(parameters) {
|
|
288
291
|
useAPI: function() {
|
289
292
|
return $.fn.api !== undefined;
|
290
293
|
},
|
294
|
+
show: function() {
|
295
|
+
return module.is.focused() && !module.is.visible() && !module.is.empty();
|
296
|
+
},
|
291
297
|
transition: function() {
|
292
298
|
return settings.transition && $.fn.transition !== undefined && $module.transition('is supported');
|
293
299
|
}
|
@@ -566,14 +572,14 @@ $.fn.search = function(parameters) {
|
|
566
572
|
;
|
567
573
|
module.verbose('Parsing server response', response);
|
568
574
|
if(response !== undefined) {
|
569
|
-
if(searchTerm !== undefined && response.results !== undefined) {
|
575
|
+
if(searchTerm !== undefined && response[fields.results] !== undefined) {
|
570
576
|
module.addResults(searchHTML);
|
571
|
-
module.inject.id(response.results);
|
577
|
+
module.inject.id(response[fields.results]);
|
572
578
|
module.write.cache(searchTerm, {
|
573
579
|
html : searchHTML,
|
574
|
-
results : response.results
|
580
|
+
results : response[fields.results]
|
575
581
|
});
|
576
|
-
module.save.results(response.results);
|
582
|
+
module.save.results(response[fields.results]);
|
577
583
|
}
|
578
584
|
}
|
579
585
|
}
|
@@ -752,11 +758,13 @@ $.fn.search = function(parameters) {
|
|
752
758
|
$results
|
753
759
|
.html(html)
|
754
760
|
;
|
755
|
-
module.
|
761
|
+
if( module.can.show() ) {
|
762
|
+
module.showResults();
|
763
|
+
}
|
756
764
|
},
|
757
765
|
|
758
766
|
showResults: function() {
|
759
|
-
if(
|
767
|
+
if(!module.is.visible()) {
|
760
768
|
if( module.can.transition() ) {
|
761
769
|
module.debug('Showing results with css animations');
|
762
770
|
$results
|
@@ -808,8 +816,8 @@ $.fn.search = function(parameters) {
|
|
808
816
|
module.debug('Generating html from response', response);
|
809
817
|
var
|
810
818
|
template = settings.templates[settings.type],
|
811
|
-
isProperObject = ($.isPlainObject(response.results) && !$.isEmptyObject(response.results)),
|
812
|
-
isProperArray = ($.isArray(response.results) && response.results.length > 0),
|
819
|
+
isProperObject = ($.isPlainObject(response[fields.results]) && !$.isEmptyObject(response[fields.results])),
|
820
|
+
isProperArray = ($.isArray(response[fields.results]) && response[fields.results].length > 0),
|
813
821
|
html = ''
|
814
822
|
;
|
815
823
|
if(isProperObject || isProperArray ) {
|
@@ -820,11 +828,11 @@ $.fn.search = function(parameters) {
|
|
820
828
|
}
|
821
829
|
}
|
822
830
|
else {
|
823
|
-
response.results = response.results.slice(0, settings.maxResults);
|
831
|
+
response[fields.results] = response[fields.results].slice(0, settings.maxResults);
|
824
832
|
}
|
825
833
|
}
|
826
834
|
if($.isFunction(template)) {
|
827
|
-
html = template(response);
|
835
|
+
html = template(response, fields);
|
828
836
|
}
|
829
837
|
else {
|
830
838
|
module.error(error.noTemplate, false);
|
@@ -1049,6 +1057,9 @@ $.fn.search.settings = {
|
|
1049
1057
|
],
|
1050
1058
|
// fields to search
|
1051
1059
|
|
1060
|
+
displayField : '',
|
1061
|
+
// field to display in standard results template
|
1062
|
+
|
1052
1063
|
searchFullText : true,
|
1053
1064
|
// whether to include fuzzy results in local search
|
1054
1065
|
|
@@ -1076,7 +1087,7 @@ $.fn.search.settings = {
|
|
1076
1087
|
onSelect : false,
|
1077
1088
|
onResultsAdd : false,
|
1078
1089
|
|
1079
|
-
onSearchQuery : function(){},
|
1090
|
+
onSearchQuery : function(query){},
|
1080
1091
|
onResults : function(response){},
|
1081
1092
|
|
1082
1093
|
onResultsOpen : function(){},
|
@@ -1113,6 +1124,21 @@ $.fn.search.settings = {
|
|
1113
1124
|
beginsWith : '(?:\s|^)'
|
1114
1125
|
},
|
1115
1126
|
|
1127
|
+
// maps api response attributes to internal representation
|
1128
|
+
fields: {
|
1129
|
+
categories : 'results', // array of categories (category view)
|
1130
|
+
categoryName : 'name', // name of category (category view)
|
1131
|
+
categoryResults : 'results', // array of results (category view)
|
1132
|
+
description : 'description', // result description
|
1133
|
+
image : 'image', // result image
|
1134
|
+
price : 'price', // result price
|
1135
|
+
results : 'results', // array of results (standard)
|
1136
|
+
title : 'title', // result title
|
1137
|
+
action : 'action', // "view more" object name
|
1138
|
+
actionText : 'text', // "view more" text
|
1139
|
+
actionURL : 'url' // "view more" url
|
1140
|
+
},
|
1141
|
+
|
1116
1142
|
selector : {
|
1117
1143
|
prompt : '.prompt',
|
1118
1144
|
searchButton : '.search.button',
|
@@ -1166,95 +1192,98 @@ $.fn.search.settings = {
|
|
1166
1192
|
}
|
1167
1193
|
return html;
|
1168
1194
|
},
|
1169
|
-
category: function(response) {
|
1195
|
+
category: function(response, fields) {
|
1170
1196
|
var
|
1171
1197
|
html = '',
|
1172
1198
|
escape = $.fn.search.settings.templates.escape
|
1173
1199
|
;
|
1174
|
-
if(response.
|
1200
|
+
if(response[fields.categoryResults] !== undefined) {
|
1201
|
+
|
1175
1202
|
// each category
|
1176
|
-
$.each(response.
|
1177
|
-
if(category.results !== undefined && category.results.length > 0) {
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1203
|
+
$.each(response[fields.categoryResults], function(index, category) {
|
1204
|
+
if(category[fields.results] !== undefined && category.results.length > 0) {
|
1205
|
+
|
1206
|
+
html += '<div class="category">';
|
1207
|
+
|
1208
|
+
if(category[fields.categoryName] !== undefined) {
|
1209
|
+
html += '<div class="name">' + category[fields.categoryName] + '</div>';
|
1210
|
+
}
|
1211
|
+
|
1182
1212
|
// each item inside category
|
1183
1213
|
$.each(category.results, function(index, result) {
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1214
|
+
if(response[fields.url]) {
|
1215
|
+
html += '<a class="result" href="' + response[fields.url] + '">';
|
1216
|
+
}
|
1217
|
+
else {
|
1218
|
+
html += '<a class="result">';
|
1187
1219
|
}
|
1188
|
-
if(result.image !== undefined) {
|
1189
|
-
result.image = escape(result.image);
|
1220
|
+
if(result[fields.image] !== undefined) {
|
1190
1221
|
html += ''
|
1191
1222
|
+ '<div class="image">'
|
1192
|
-
+ ' <img src="' + result.image + '"
|
1223
|
+
+ ' <img src="' + result[fields.image] + '">'
|
1193
1224
|
+ '</div>'
|
1194
1225
|
;
|
1195
1226
|
}
|
1196
1227
|
html += '<div class="content">';
|
1197
|
-
if(result.price !== undefined) {
|
1198
|
-
|
1199
|
-
html += '<div class="price">' + result.price + '</div>';
|
1228
|
+
if(result[fields.price] !== undefined) {
|
1229
|
+
html += '<div class="price">' + result[fields.price] + '</div>';
|
1200
1230
|
}
|
1201
|
-
if(result.title !== undefined) {
|
1202
|
-
|
1203
|
-
html += '<div class="title">' + result.title + '</div>';
|
1231
|
+
if(result[fields.title] !== undefined) {
|
1232
|
+
html += '<div class="title">' + result[fields.title] + '</div>';
|
1204
1233
|
}
|
1205
|
-
if(result.description !== undefined) {
|
1206
|
-
html += '<div class="description">' + result.description + '</div>';
|
1234
|
+
if(result[fields.description] !== undefined) {
|
1235
|
+
html += '<div class="description">' + result[fields.description] + '</div>';
|
1207
1236
|
}
|
1208
1237
|
html += ''
|
1209
1238
|
+ '</div>'
|
1210
|
-
+ '</div>'
|
1211
1239
|
;
|
1240
|
+
html += '</a>';
|
1212
1241
|
});
|
1213
1242
|
html += ''
|
1214
1243
|
+ '</div>'
|
1215
1244
|
;
|
1216
1245
|
}
|
1217
1246
|
});
|
1218
|
-
if(response.action) {
|
1247
|
+
if(response[fields.action]) {
|
1219
1248
|
html += ''
|
1220
|
-
+ '<a href="' + response.action.
|
1221
|
-
+ response.action.
|
1249
|
+
+ '<a href="' + response[fields.action][fields.actionURL] + '" class="action">'
|
1250
|
+
+ response[fields.action][fields.actionText]
|
1222
1251
|
+ '</a>';
|
1223
1252
|
}
|
1224
1253
|
return html;
|
1225
1254
|
}
|
1226
1255
|
return false;
|
1227
1256
|
},
|
1228
|
-
standard: function(response) {
|
1257
|
+
standard: function(response, fields) {
|
1229
1258
|
var
|
1230
1259
|
html = ''
|
1231
1260
|
;
|
1232
|
-
if(response.results !== undefined) {
|
1261
|
+
if(response[fields.results] !== undefined) {
|
1233
1262
|
|
1234
1263
|
// each result
|
1235
|
-
$.each(response.results, function(index, result) {
|
1236
|
-
if(
|
1237
|
-
html += '<a class="result" href="' +
|
1264
|
+
$.each(response[fields.results], function(index, result) {
|
1265
|
+
if(response[fields.url]) {
|
1266
|
+
html += '<a class="result" href="' + response[fields.url] + '">';
|
1238
1267
|
}
|
1239
1268
|
else {
|
1240
1269
|
html += '<a class="result">';
|
1241
1270
|
}
|
1242
|
-
if(result.image !== undefined) {
|
1271
|
+
if(result[fields.image] !== undefined) {
|
1243
1272
|
html += ''
|
1244
1273
|
+ '<div class="image">'
|
1245
|
-
+ ' <img src="' + result.image + '">'
|
1274
|
+
+ ' <img src="' + result[fields.image] + '">'
|
1246
1275
|
+ '</div>'
|
1247
1276
|
;
|
1248
1277
|
}
|
1249
1278
|
html += '<div class="content">';
|
1250
|
-
if(result.price !== undefined) {
|
1251
|
-
html += '<div class="price">' + result.price + '</div>';
|
1279
|
+
if(result[fields.price] !== undefined) {
|
1280
|
+
html += '<div class="price">' + result[fields.price] + '</div>';
|
1252
1281
|
}
|
1253
|
-
if(result.title !== undefined) {
|
1254
|
-
html += '<div class="title">' + result.title + '</div>';
|
1282
|
+
if(result[fields.title] !== undefined) {
|
1283
|
+
html += '<div class="title">' + result[fields.title] + '</div>';
|
1255
1284
|
}
|
1256
|
-
if(result.description !== undefined) {
|
1257
|
-
html += '<div class="description">' + result.description + '</div>';
|
1285
|
+
if(result[fields.description] !== undefined) {
|
1286
|
+
html += '<div class="description">' + result[fields.description] + '</div>';
|
1258
1287
|
}
|
1259
1288
|
html += ''
|
1260
1289
|
+ '</div>'
|
@@ -1262,10 +1291,10 @@ $.fn.search.settings = {
|
|
1262
1291
|
html += '</a>';
|
1263
1292
|
});
|
1264
1293
|
|
1265
|
-
if(response.action) {
|
1294
|
+
if(response[fields.action]) {
|
1266
1295
|
html += ''
|
1267
|
-
+ '<a href="' + response.action.
|
1268
|
-
+ response.action.
|
1296
|
+
+ '<a href="' + response[fields.action][fields.actionURL] + '" class="action">'
|
1297
|
+
+ response[fields.action][fields.actionText]
|
1269
1298
|
+ '</a>';
|
1270
1299
|
}
|
1271
1300
|
return html;
|