semantic-ui-sass 2.1.3.0 → 2.1.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 +6 -0
- data/README.md +5 -5
- data/app/assets/javascripts/semantic-ui/api.js +1 -1
- data/app/assets/javascripts/semantic-ui/dropdown.js +9 -4
- data/app/assets/javascripts/semantic-ui/form.js +184 -90
- data/app/assets/javascripts/semantic-ui/search.js +1 -1
- data/app/assets/javascripts/semantic-ui/site.js +2 -2
- data/app/assets/javascripts/semantic-ui/tab.js +2 -2
- data/app/assets/stylesheets/semantic-ui.scss +2 -3
- data/app/assets/stylesheets/semantic-ui/collections/_breadcrumb.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/collections/_form.scss +2 -2
- data/app/assets/stylesheets/semantic-ui/collections/_grid.scss +14 -15
- data/app/assets/stylesheets/semantic-ui/collections/_menu.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/collections/_message.scss +7 -7
- data/app/assets/stylesheets/semantic-ui/collections/_table.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_button.scss +3 -2
- data/app/assets/stylesheets/semantic-ui/elements/_container.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_divider.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_flag.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_header.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_icon.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_image.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_input.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_label.scss +1 -2
- data/app/assets/stylesheets/semantic-ui/elements/_list.scss +1 -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 +1 -1
- data/app/assets/stylesheets/semantic-ui/elements/_segment.scss +3 -2
- data/app/assets/stylesheets/semantic-ui/elements/_step.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/globals/_all.scss +2 -2
- 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 +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_dimmer.scss +1 -1
- data/app/assets/stylesheets/semantic-ui/modules/_dropdown.scss +1 -1
- 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 +1 -1
- data/app/assets/stylesheets/semantic-ui/views/_statistic.scss +1 -1
- data/app/helpers/semantic_breadcrumbs_helper.rb +2 -2
- data/lib/semantic/ui/sass/breadcrumbs.rb +7 -7
- data/lib/semantic/ui/sass/version.rb +2 -2
- data/spec/helpers/semantic_breadcrumbs_helper_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c08a1be10f2cc73025d9569f52491b648d51b4d1
|
4
|
+
data.tar.gz: 20e445ca76c7174564e8aab0076d693d2495398d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a14537dcb2af773a83b0d5f5ca3f24c39976dc8cd97006e611b70b8e69666ae122d5fd92fb69ed556c31a8cf5aa4697ec96db5c1cdd21a237001ed018dd8e20
|
7
|
+
data.tar.gz: 0620e1ae2ddc5065a2ae1c6e4d3603e318ae307d92dffdd38108182f11203b2967b787476d46339043d7f91361b217861990878cfcb9f45648608e80133a8be0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -88,25 +88,25 @@ When using compass, you should visit file in local server, eg `http://localhost:
|
|
88
88
|
|
89
89
|
## Breadcrumbs helper
|
90
90
|
|
91
|
-
Add breadcrumbs helper `<%=
|
91
|
+
Add breadcrumbs helper `<%= semantic_breadcrumbs %>` to your layout.
|
92
92
|
|
93
93
|
```ruby
|
94
94
|
class ApplicationController
|
95
|
-
|
95
|
+
semantic_breadcrumb :index, :root_path
|
96
96
|
end
|
97
97
|
```
|
98
98
|
|
99
99
|
```ruby
|
100
100
|
class ExamplesController < ApplicationController
|
101
|
-
|
101
|
+
semantic_breadcrumb :index, :examples_path
|
102
102
|
|
103
103
|
def index
|
104
104
|
end
|
105
105
|
|
106
106
|
def show
|
107
107
|
@example = Example.find params[:id]
|
108
|
-
|
109
|
-
#
|
108
|
+
semantic_breadcrumb @example.name, example_path(@example)
|
109
|
+
# semantic_breadcrumb :show, example_path(@example)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
```
|
@@ -1103,7 +1103,7 @@ $.api.settings = {
|
|
1103
1103
|
missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',
|
1104
1104
|
missingURL : 'No URL specified for api event',
|
1105
1105
|
noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',
|
1106
|
-
noStorage : 'Caching
|
1106
|
+
noStorage : 'Caching responses locally requires session storage',
|
1107
1107
|
parseError : 'There was an error parsing your request',
|
1108
1108
|
requiredParameter : 'Missing a required URL parameter: ',
|
1109
1109
|
statusMessage : 'Server gave an error: ',
|
@@ -321,6 +321,10 @@ $.fn.dropdown = function(parameters) {
|
|
321
321
|
if($input.is('[multiple]')) {
|
322
322
|
module.set.multiple();
|
323
323
|
}
|
324
|
+
if ($input.prop('disabled')) {
|
325
|
+
module.debug('Disabling dropdown')
|
326
|
+
$module.addClass(className.disabled)
|
327
|
+
}
|
324
328
|
$input
|
325
329
|
.removeAttr('class')
|
326
330
|
.detach()
|
@@ -821,7 +825,7 @@ $.fn.dropdown = function(parameters) {
|
|
821
825
|
module.hide();
|
822
826
|
}
|
823
827
|
},
|
824
|
-
// prevents focus callback from
|
828
|
+
// prevents focus callback from occurring on mousedown
|
825
829
|
mousedown: function() {
|
826
830
|
activated = true;
|
827
831
|
},
|
@@ -1148,6 +1152,7 @@ $.fn.dropdown = function(parameters) {
|
|
1148
1152
|
hasSubMenu = ($subMenu.length> 0),
|
1149
1153
|
hasSelectedItem = ($selectedItem.length > 0),
|
1150
1154
|
selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0),
|
1155
|
+
delimiterPressed = (pressedKey == keys.delimiter && settings.allowAdditions && module.is.multiple()),
|
1151
1156
|
$nextItem,
|
1152
1157
|
isSubMenuItem,
|
1153
1158
|
newIndex
|
@@ -1157,7 +1162,7 @@ $.fn.dropdown = function(parameters) {
|
|
1157
1162
|
if( module.is.visible() ) {
|
1158
1163
|
|
1159
1164
|
// enter (select or open sub-menu)
|
1160
|
-
if(pressedKey == keys.enter ||
|
1165
|
+
if(pressedKey == keys.enter || delimiterPressed) {
|
1161
1166
|
if(pressedKey == keys.enter && hasSelectedItem && hasSubMenu && !settings.allowCategorySelection) {
|
1162
1167
|
module.verbose('Pressed enter on unselectable category, opening sub menu');
|
1163
1168
|
pressedKey = keys.rightArrow;
|
@@ -1274,7 +1279,7 @@ $.fn.dropdown = function(parameters) {
|
|
1274
1279
|
}
|
1275
1280
|
else {
|
1276
1281
|
// delimiter key
|
1277
|
-
if(
|
1282
|
+
if(delimiterPressed) {
|
1278
1283
|
event.preventDefault();
|
1279
1284
|
}
|
1280
1285
|
// down arrow (open menu)
|
@@ -3229,7 +3234,7 @@ $.fn.dropdown.settings = {
|
|
3229
3234
|
|
3230
3235
|
maxSelections : false, // When set to a number limits the number of selections to this count
|
3231
3236
|
useLabels : true, // whether multiple select should filter currently active selections from choices
|
3232
|
-
delimiter : ',', // when multiselect uses normal <input> the values will be
|
3237
|
+
delimiter : ',', // when multiselect uses normal <input> the values will be delimited with this character
|
3233
3238
|
|
3234
3239
|
showOnFocus : true, // show menu on focus
|
3235
3240
|
allowTab : true, // add tabindex to element
|
@@ -225,13 +225,16 @@ $.fn.form = function(parameters) {
|
|
225
225
|
},
|
226
226
|
|
227
227
|
is: {
|
228
|
+
bracketedRule: function(rule) {
|
229
|
+
return (rule.type && rule.type.match(settings.regExp.bracket));
|
230
|
+
},
|
228
231
|
valid: function() {
|
229
232
|
var
|
230
233
|
allValid = true
|
231
234
|
;
|
232
235
|
module.verbose('Checking if form is valid');
|
233
236
|
$.each(validation, function(fieldName, field) {
|
234
|
-
if( !( module.validate.field(field) ) ) {
|
237
|
+
if( !( module.validate.field(field, fieldName) ) ) {
|
235
238
|
allValid = false;
|
236
239
|
}
|
237
240
|
});
|
@@ -285,7 +288,7 @@ $.fn.form = function(parameters) {
|
|
285
288
|
keyup: function() {
|
286
289
|
keyHeldDown = false;
|
287
290
|
},
|
288
|
-
blur: function() {
|
291
|
+
blur: function(event) {
|
289
292
|
var
|
290
293
|
$field = $(this),
|
291
294
|
$fieldGroup = $field.closest($group),
|
@@ -293,13 +296,13 @@ $.fn.form = function(parameters) {
|
|
293
296
|
;
|
294
297
|
if( $fieldGroup.hasClass(className.error) ) {
|
295
298
|
module.debug('Revalidating field', $field, validationRules);
|
296
|
-
module.validate.
|
299
|
+
module.validate.form.call(module, event, true);
|
297
300
|
}
|
298
301
|
else if(settings.on == 'blur' || settings.on == 'change') {
|
299
302
|
module.validate.field( validationRules );
|
300
303
|
}
|
301
304
|
},
|
302
|
-
change: function() {
|
305
|
+
change: function(event) {
|
303
306
|
var
|
304
307
|
$field = $(this),
|
305
308
|
$fieldGroup = $field.closest($group)
|
@@ -308,7 +311,7 @@ $.fn.form = function(parameters) {
|
|
308
311
|
clearTimeout(module.timer);
|
309
312
|
module.timer = setTimeout(function() {
|
310
313
|
module.debug('Revalidating field', $field, module.get.validation($field));
|
311
|
-
module.validate.
|
314
|
+
module.validate.form.call(module, event, true);
|
312
315
|
}, settings.delay);
|
313
316
|
}
|
314
317
|
}
|
@@ -317,6 +320,18 @@ $.fn.form = function(parameters) {
|
|
317
320
|
},
|
318
321
|
|
319
322
|
get: {
|
323
|
+
ancillaryValue: function(rule) {
|
324
|
+
if(!rule.type || !module.is.bracketedRule(rule)) {
|
325
|
+
return false;
|
326
|
+
}
|
327
|
+
return rule.type.match(settings.regExp.bracket)[1] + '';
|
328
|
+
},
|
329
|
+
ruleName: function(rule) {
|
330
|
+
if( module.is.bracketedRule(rule) ) {
|
331
|
+
return rule.type.replace(rule.type.match(settings.regExp.bracket)[0], '');
|
332
|
+
}
|
333
|
+
return rule.type;
|
334
|
+
},
|
320
335
|
changeEvent: function(type, $input) {
|
321
336
|
if(type == 'checkbox' || type == 'radio' || type == 'hidden' || $input.is('select')) {
|
322
337
|
return 'change';
|
@@ -333,16 +348,46 @@ $.fn.form = function(parameters) {
|
|
333
348
|
: 'keyup'
|
334
349
|
;
|
335
350
|
},
|
336
|
-
|
351
|
+
prompt: function(rule, field) {
|
337
352
|
var
|
338
|
-
|
353
|
+
ruleName = module.get.ruleName(rule),
|
354
|
+
ancillary = module.get.ancillaryValue(rule),
|
355
|
+
prompt = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,
|
356
|
+
requiresValue = (prompt.search('{value}') !== -1),
|
357
|
+
requiresName = (prompt.search('{name}') !== -1),
|
358
|
+
$label,
|
359
|
+
$field,
|
360
|
+
name
|
339
361
|
;
|
362
|
+
if(requiresName || requiresValue) {
|
363
|
+
$field = module.get.field(field.identifier);
|
364
|
+
}
|
365
|
+
if(requiresValue) {
|
366
|
+
prompt = prompt.replace('{value}', $field.val());
|
367
|
+
}
|
368
|
+
if(requiresName) {
|
369
|
+
$label = $field.closest(selector.group).find('label').eq(0);
|
370
|
+
name = ($label.size() == 1)
|
371
|
+
? $label.text()
|
372
|
+
: $field.prop('placeholder') || settings.text.unspecifiedField
|
373
|
+
;
|
374
|
+
prompt = prompt.replace('{name}', name);
|
375
|
+
}
|
376
|
+
prompt = prompt.replace('{identifier}', field.identifier);
|
377
|
+
prompt = prompt.replace('{ruleValue}', ancillary);
|
378
|
+
if(!rule.prompt) {
|
379
|
+
module.verbose('Using default validation prompt for type', prompt, ruleName);
|
380
|
+
}
|
381
|
+
return prompt;
|
382
|
+
},
|
383
|
+
settings: function() {
|
340
384
|
if($.isPlainObject(parameters)) {
|
341
385
|
var
|
342
|
-
keys
|
386
|
+
keys = Object.keys(parameters),
|
343
387
|
isLegacySettings = (keys.length > 0)
|
344
388
|
? (parameters[keys[0]].identifier !== undefined && parameters[keys[0]].rules !== undefined)
|
345
|
-
: false
|
389
|
+
: false,
|
390
|
+
ruleKeys
|
346
391
|
;
|
347
392
|
if(isLegacySettings) {
|
348
393
|
// 1.x (ducktyped)
|
@@ -353,6 +398,23 @@ $.fn.form = function(parameters) {
|
|
353
398
|
}
|
354
399
|
else {
|
355
400
|
// 2.x
|
401
|
+
if(parameters.fields) {
|
402
|
+
ruleKeys = Object.keys(parameters.fields);
|
403
|
+
if( typeof parameters.fields[ruleKeys[0]] == 'string' || $.isArray(parameters.fields[ruleKeys[0]]) ) {
|
404
|
+
$.each(parameters.fields, function(name, rules) {
|
405
|
+
if(typeof rules == 'string') {
|
406
|
+
rules = [rules];
|
407
|
+
}
|
408
|
+
parameters.fields[name] = {
|
409
|
+
rules: []
|
410
|
+
};
|
411
|
+
$.each(rules, function(index, rule) {
|
412
|
+
parameters.fields[name].rules.push({ type: rule });
|
413
|
+
});
|
414
|
+
});
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
356
418
|
settings = $.extend(true, {}, $.fn.form.settings, parameters);
|
357
419
|
validation = $.extend({}, $.fn.form.settings.defaults, settings.fields);
|
358
420
|
module.verbose('Extending settings', validation, settings);
|
@@ -406,17 +468,20 @@ $.fn.form = function(parameters) {
|
|
406
468
|
},
|
407
469
|
validation: function($field) {
|
408
470
|
var
|
409
|
-
|
471
|
+
fieldValidation,
|
472
|
+
identifier
|
410
473
|
;
|
411
474
|
if(!validation) {
|
412
475
|
return false;
|
413
476
|
}
|
414
477
|
$.each(validation, function(fieldName, field) {
|
415
|
-
|
416
|
-
|
478
|
+
identifier = field.identifier || fieldName;
|
479
|
+
if( module.get.field(identifier)[0] == $field[0] ) {
|
480
|
+
field.identifier = identifier;
|
481
|
+
fieldValidation = field;
|
417
482
|
}
|
418
483
|
});
|
419
|
-
return
|
484
|
+
return fieldValidation || false;
|
420
485
|
},
|
421
486
|
value: function (field) {
|
422
487
|
var
|
@@ -455,7 +520,7 @@ $.fn.form = function(parameters) {
|
|
455
520
|
}
|
456
521
|
if(isCheckbox) {
|
457
522
|
if(isChecked) {
|
458
|
-
values[name].push(true);
|
523
|
+
values[name].push(value || true);
|
459
524
|
}
|
460
525
|
else {
|
461
526
|
values[name].push(false);
|
@@ -473,7 +538,7 @@ $.fn.form = function(parameters) {
|
|
473
538
|
}
|
474
539
|
else if(isCheckbox) {
|
475
540
|
if(isChecked) {
|
476
|
-
values[name] = true;
|
541
|
+
values[name] = value || true;
|
477
542
|
}
|
478
543
|
else {
|
479
544
|
values[name] = false;
|
@@ -555,6 +620,7 @@ $.fn.form = function(parameters) {
|
|
555
620
|
},
|
556
621
|
errors: function(errors) {
|
557
622
|
module.debug('Adding form error messages', errors);
|
623
|
+
module.set.error();
|
558
624
|
$message
|
559
625
|
.html( settings.templates.error(errors) )
|
560
626
|
;
|
@@ -562,9 +628,9 @@ $.fn.form = function(parameters) {
|
|
562
628
|
},
|
563
629
|
|
564
630
|
remove: {
|
565
|
-
prompt: function(
|
631
|
+
prompt: function(identifier) {
|
566
632
|
var
|
567
|
-
$field = module.get.field(
|
633
|
+
$field = module.get.field(identifier),
|
568
634
|
$fieldGroup = $field.closest($group),
|
569
635
|
$prompt = $fieldGroup.children(selector.prompt)
|
570
636
|
;
|
@@ -572,7 +638,7 @@ $.fn.form = function(parameters) {
|
|
572
638
|
.removeClass(className.error)
|
573
639
|
;
|
574
640
|
if(settings.inline && $prompt.is(':visible')) {
|
575
|
-
module.verbose('Removing prompt for field',
|
641
|
+
module.verbose('Removing prompt for field', identifier);
|
576
642
|
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
|
577
643
|
$prompt.transition(settings.transition + ' out', settings.duration, function() {
|
578
644
|
$prompt.remove();
|
@@ -681,7 +747,7 @@ $.fn.form = function(parameters) {
|
|
681
747
|
|
682
748
|
validate: {
|
683
749
|
|
684
|
-
form: function(event) {
|
750
|
+
form: function(event, ignoreCallbacks) {
|
685
751
|
var
|
686
752
|
values = module.get.values(),
|
687
753
|
apiRequest
|
@@ -697,7 +763,9 @@ $.fn.form = function(parameters) {
|
|
697
763
|
if( module.is.valid() ) {
|
698
764
|
module.debug('Form has no validation errors, submitting');
|
699
765
|
module.set.success();
|
700
|
-
|
766
|
+
if(ignoreCallbacks !== true) {
|
767
|
+
return settings.onSuccess.call(element, event, values);
|
768
|
+
}
|
701
769
|
}
|
702
770
|
else {
|
703
771
|
module.debug('Form has errors');
|
@@ -709,41 +777,48 @@ $.fn.form = function(parameters) {
|
|
709
777
|
if($module.data('moduleApi') !== undefined) {
|
710
778
|
event.stopImmediatePropagation();
|
711
779
|
}
|
712
|
-
|
780
|
+
if(ignoreCallbacks !== true) {
|
781
|
+
return settings.onFailure.call(element, formErrors, values);
|
782
|
+
}
|
713
783
|
}
|
714
784
|
},
|
715
785
|
|
716
786
|
// takes a validation object and returns whether field passes validation
|
717
|
-
field: function(field) {
|
787
|
+
field: function(field, fieldName) {
|
718
788
|
var
|
719
|
-
|
789
|
+
identifier = field.identifier || fieldName,
|
790
|
+
$field = module.get.field(identifier),
|
720
791
|
fieldValid = true,
|
721
792
|
fieldErrors = []
|
722
793
|
;
|
794
|
+
if(!field.identifier) {
|
795
|
+
module.debug('Using field name as identifier', identifier);
|
796
|
+
field.identifier = identifier;
|
797
|
+
}
|
723
798
|
if($field.prop('disabled')) {
|
724
|
-
module.debug('Field is disabled. Skipping',
|
799
|
+
module.debug('Field is disabled. Skipping', identifier);
|
725
800
|
fieldValid = true;
|
726
801
|
}
|
727
802
|
else if(field.optional && $.trim($field.val()) === ''){
|
728
|
-
module.debug('Field is optional and empty. Skipping',
|
803
|
+
module.debug('Field is optional and empty. Skipping', identifier);
|
729
804
|
fieldValid = true;
|
730
805
|
}
|
731
806
|
else if(field.rules !== undefined) {
|
732
807
|
$.each(field.rules, function(index, rule) {
|
733
|
-
if( module.has.field(
|
734
|
-
module.debug('Field is invalid',
|
735
|
-
fieldErrors.push(
|
808
|
+
if( module.has.field(identifier) && !( module.validate.rule(field, rule) ) ) {
|
809
|
+
module.debug('Field is invalid', identifier, rule.type);
|
810
|
+
fieldErrors.push(module.get.prompt(rule, field));
|
736
811
|
fieldValid = false;
|
737
812
|
}
|
738
813
|
});
|
739
814
|
}
|
740
815
|
if(fieldValid) {
|
741
|
-
module.remove.prompt(
|
816
|
+
module.remove.prompt(identifier, fieldErrors);
|
742
817
|
settings.onValid.call($field);
|
743
818
|
}
|
744
819
|
else {
|
745
820
|
formErrors = formErrors.concat(fieldErrors);
|
746
|
-
module.add.prompt(
|
821
|
+
module.add.prompt(identifier, fieldErrors);
|
747
822
|
settings.onInvalid.call($field, fieldErrors);
|
748
823
|
return false;
|
749
824
|
}
|
@@ -751,42 +826,26 @@ $.fn.form = function(parameters) {
|
|
751
826
|
},
|
752
827
|
|
753
828
|
// takes validation rule and returns whether field passes rule
|
754
|
-
rule: function(field,
|
829
|
+
rule: function(field, rule) {
|
755
830
|
var
|
756
|
-
$field
|
757
|
-
type
|
758
|
-
value
|
759
|
-
|
760
|
-
|
761
|
-
rule,
|
762
|
-
|
763
|
-
functionType
|
831
|
+
$field = module.get.field(field.identifier),
|
832
|
+
type = rule.type,
|
833
|
+
value = $field.val(),
|
834
|
+
isValid = true,
|
835
|
+
ancillary = module.get.ancillaryValue(rule),
|
836
|
+
ruleName = module.get.ruleName(rule),
|
837
|
+
ruleFunction = settings.rules[ruleName]
|
764
838
|
;
|
839
|
+
if( !$.isFunction(ruleFunction) ) {
|
840
|
+
module.error(error.noRule, ruleName);
|
841
|
+
return;
|
842
|
+
}
|
765
843
|
// cast to string avoiding encoding special values
|
766
844
|
value = (value === undefined || value === '' || value === null)
|
767
845
|
? ''
|
768
846
|
: $.trim(value + '')
|
769
847
|
;
|
770
|
-
|
771
|
-
if(bracket) {
|
772
|
-
ancillary = '' + bracket[1];
|
773
|
-
functionType = type.replace(bracket[0], '');
|
774
|
-
rule = settings.rules[functionType];
|
775
|
-
if( !$.isFunction(rule) ) {
|
776
|
-
module.error(error.noRule, functionType);
|
777
|
-
return;
|
778
|
-
}
|
779
|
-
isValid = rule.call($field, value, ancillary);
|
780
|
-
}
|
781
|
-
else {
|
782
|
-
rule = settings.rules[type];
|
783
|
-
if( !$.isFunction(rule) ) {
|
784
|
-
module.error(error.noRule, type);
|
785
|
-
return;
|
786
|
-
}
|
787
|
-
isValid = rule.call($field, value);
|
788
|
-
}
|
789
|
-
return isValid;
|
848
|
+
return ruleFunction.call($field, value, ancillary);
|
790
849
|
}
|
791
850
|
},
|
792
851
|
|
@@ -998,6 +1057,40 @@ $.fn.form.settings = {
|
|
998
1057
|
url : /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i
|
999
1058
|
},
|
1000
1059
|
|
1060
|
+
text: {
|
1061
|
+
unspecifiedRule : 'Please enter a valid value',
|
1062
|
+
unspecifiedField : 'This field'
|
1063
|
+
},
|
1064
|
+
|
1065
|
+
prompt: {
|
1066
|
+
empty : '{name} must have a value',
|
1067
|
+
checked : '{name} must be checked',
|
1068
|
+
email : '{name} must be a valid e-mail',
|
1069
|
+
url : '{name} must be a valid url',
|
1070
|
+
regExp : '{name} is not formatted correctly',
|
1071
|
+
integer : '{name} must be an integer',
|
1072
|
+
decimal : '{name} must be a decimal number',
|
1073
|
+
number : '{name} must be set to a number',
|
1074
|
+
is : '{name} must be "{ruleValue}"',
|
1075
|
+
isExactly : '{name} must be exactly "{ruleValue}"',
|
1076
|
+
not : '{name} cannot be set to "{ruleValue}"',
|
1077
|
+
notExactly : '{name} cannot be set to exactly "{ruleValue}"',
|
1078
|
+
contain : '{name} cannot contain "{ruleValue}"',
|
1079
|
+
containExactly : '{name} cannot contain exactly "{ruleValue}"',
|
1080
|
+
doesntContain : '{name} must contain "{ruleValue}"',
|
1081
|
+
doesntContainExactly : '{name} must contain exactly "{ruleValue}"',
|
1082
|
+
minLength : '{name} must be at least {ruleValue} characters',
|
1083
|
+
length : '{name} must be at least {ruleValue} characters',
|
1084
|
+
exactLength : '{name} must be exactly {ruleValue} characters',
|
1085
|
+
maxLength : '{name} cannot be longer than {ruleValue} characters',
|
1086
|
+
match : '{name} must match {ruleValue} field',
|
1087
|
+
different : '{name} must have a different value than {ruleValue} field',
|
1088
|
+
creditCard : '{name} must be a valid credit card number',
|
1089
|
+
minCount : '{name} must have at least {ruleValue} choices',
|
1090
|
+
exactCount : '{name} must have exactly {ruleValue} choices',
|
1091
|
+
maxCount : '{name} must have {ruleValue} or less choices'
|
1092
|
+
},
|
1093
|
+
|
1001
1094
|
selector : {
|
1002
1095
|
checkbox : 'input[type="checkbox"], input[type="radio"]',
|
1003
1096
|
clear : '.clear',
|
@@ -1256,6 +1349,32 @@ $.fn.form.settings = {
|
|
1256
1349
|
: false
|
1257
1350
|
;
|
1258
1351
|
},
|
1352
|
+
|
1353
|
+
// different than another field
|
1354
|
+
different: function(value, identifier) {
|
1355
|
+
// use either id or name of field
|
1356
|
+
var
|
1357
|
+
$form = $(this),
|
1358
|
+
matchingValue
|
1359
|
+
;
|
1360
|
+
if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
|
1361
|
+
matchingValue = $('[data-validate="'+ identifier +'"]').val();
|
1362
|
+
}
|
1363
|
+
else if($('#' + identifier).length > 0) {
|
1364
|
+
matchingValue = $('#' + identifier).val();
|
1365
|
+
}
|
1366
|
+
else if($('[name="' + identifier +'"]').length > 0) {
|
1367
|
+
matchingValue = $('[name="' + identifier + '"]').val();
|
1368
|
+
}
|
1369
|
+
else if( $('[name="' + identifier +'[]"]').length > 0 ) {
|
1370
|
+
matchingValue = $('[name="' + identifier +'[]"]');
|
1371
|
+
}
|
1372
|
+
return (matchingValue !== undefined)
|
1373
|
+
? ( value.toString() !== matchingValue.toString() )
|
1374
|
+
: false
|
1375
|
+
;
|
1376
|
+
},
|
1377
|
+
|
1259
1378
|
creditCard: function(cardNumber, cardTypes) {
|
1260
1379
|
var
|
1261
1380
|
cards = {
|
@@ -1360,29 +1479,14 @@ $.fn.form.settings = {
|
|
1360
1479
|
return (sum % 10 === 0 && sum > 0);
|
1361
1480
|
},
|
1362
1481
|
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
var
|
1367
|
-
$form = $(this),
|
1368
|
-
matchingValue
|
1369
|
-
;
|
1370
|
-
if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
|
1371
|
-
matchingValue = $('[data-validate="'+ identifier +'"]').val();
|
1372
|
-
}
|
1373
|
-
else if($('#' + identifier).length > 0) {
|
1374
|
-
matchingValue = $('#' + identifier).val();
|
1375
|
-
}
|
1376
|
-
else if($('[name="' + identifier +'"]').length > 0) {
|
1377
|
-
matchingValue = $('[name="' + identifier + '"]').val();
|
1482
|
+
minCount: function(value, minCount) {
|
1483
|
+
if(minCount == 0) {
|
1484
|
+
return true;
|
1378
1485
|
}
|
1379
|
-
|
1380
|
-
|
1486
|
+
if(minCount == 1) {
|
1487
|
+
return (value !== '');
|
1381
1488
|
}
|
1382
|
-
return (
|
1383
|
-
? ( value.toString() !== matchingValue.toString() )
|
1384
|
-
: false
|
1385
|
-
;
|
1489
|
+
return (value.split(',').length >= minCount);
|
1386
1490
|
},
|
1387
1491
|
|
1388
1492
|
exactCount: function(value, exactCount) {
|
@@ -1395,16 +1499,6 @@ $.fn.form.settings = {
|
|
1395
1499
|
return (value.split(',').length == exactCount);
|
1396
1500
|
},
|
1397
1501
|
|
1398
|
-
minCount: function(value, minCount) {
|
1399
|
-
if(minCount == 0) {
|
1400
|
-
return true;
|
1401
|
-
}
|
1402
|
-
if(minCount == 1) {
|
1403
|
-
return (value !== '');
|
1404
|
-
}
|
1405
|
-
return (value.split(',').length >= minCount);
|
1406
|
-
},
|
1407
|
-
|
1408
1502
|
maxCount: function(value, maxCount) {
|
1409
1503
|
if(maxCount == 0) {
|
1410
1504
|
return false;
|