Skip to content

Commit abe7b1f

Browse files
committed
reset function for validator. required attribute for date- and rangeinputs
1 parent 8c6bd80 commit abe7b1f

File tree

5 files changed

+20
-35
lines changed

5 files changed

+20
-35
lines changed

src/dateinput/dateinput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
// Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser
200200
if (input.attr("type") == 'date') {
201201
var tmp = $("<input/>");
202-
$.each("name,readonly,disabled,value".split(","), function(i, attr) {
202+
$.each("name,readonly,disabled,value,required".split(","), function(i, attr) {
203203
tmp.attr(attr, input.attr(attr));
204204
});
205205
input.replaceWith(tmp);

src/rangeinput/rangeinput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
// Replace built-in range input (type attribute cannot be changed)
178178
if (input.attr("type") == 'range') {
179179
var tmp = $("<input/>");
180-
$.each("name,readonly,disabled".split(","), function(i, attr) {
180+
$.each("name,readonly,disabled,required".split(","), function(i, attr) {
181181
tmp.attr(attr, input.attr(attr));
182182
});
183183
tmp.val(conf.value);

src/scrollable/scrollable.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@
151151
item = self.getItems().eq(i);
152152
}
153153

154-
155-
156154
// onBeforeSeek
157155
var e = $.Event("onBeforeSeek");
158156
if (!fn) {
@@ -164,10 +162,7 @@
164162

165163
index = i;
166164
current = self;
167-
if (time === undefined) { time = conf.speed; }
168-
169-
170-
165+
if (time === undefined) { time = conf.speed; }
171166

172167
itemWrap.animate(props, time, conf.easing, fn || function() {
173168
fire.trigger("onSeek", [i]);
@@ -202,6 +197,7 @@
202197

203198
self.onBeforeSeek(function(e, i, time) {
204199

200+
205201
if (e.isDefaultPrevented()) { return; }
206202

207203
/*

src/validator/validator.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,17 @@
331331
return self;
332332
},
333333

334+
reset: function(els) {
335+
els = els || inputs;
336+
els.removeClass(conf.errorClass).each(function() {
337+
var msg = $(this).data("msg.el");
338+
if (msg) {
339+
msg.remove();
340+
$(this).data("msg.el", null);
341+
}
342+
});
343+
},
344+
334345
//{{{ checkValidity() - flesh and bone of this tool
335346

336347
/* @returns boolean */
@@ -462,9 +473,8 @@
462473
}
463474

464475
// form reset
465-
form.bind("reset", function() {
466-
$("." + conf.messageClass).remove();
467-
inputs.removeClass(conf.errorClass).data("msg.el", null);
476+
form.bind("reset", function() {
477+
self.reset();
468478
});
469479

470480
// disable browser's default validation mechanism

test/scrollable/index.html

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,25 @@
11

2-
<script src="../jquery-1.3.2.js"></script>
2+
<script src="../js/jquery-1.3.2.js"></script>
33
<script src="../../src/scrollable/scrollable.js"></script>
4-
<script src="../../src/scrollable/scrollable.circular.js"></script>
54
<script src="../../src/scrollable/scrollable.navigator.js"></script>
65
<script src="../../src/scrollable/scrollable.autoscroll.js"></script>
7-
86
<script src="../../src/toolbox/toolbox.history.js"></script>
9-
<script src="../../src/toolbox/toolbox.mousewheel.js"></script>
107

118
<link rel="stylesheet" type="text/css" href="style.css"/>
129

1310
<style>
1411
div.cloned {
1512
background-color:#ffc !important;
1613
}
17-
18-
div.active {
19-
background-color:#66d !important;
20-
}
21-
2214
.disabled {
2315
visibility:hidden;
2416
}
2517
</style>
2618

2719
<script>
2820
$(function() {
29-
window.api = $("div.scrollable").scrollable({
30-
mousewheel: true
31-
32-
}).navigator({idPrefix: 'a', history: true}).bind("onSeek", function() {
33-
console.info("BIND", this, arguments);
34-
35-
}).data("scrollable");
36-
37-
38-
api.onBeforeSeek(function (e, i) {
39-
console.info("API", this, arguments);
40-
});
41-
21+
window.api = $(".scrollable").scrollable({ mousewheel: true})
22+
.navigator({idPrefix: 'a', history: true}).data("scrollable");
4223
});
4324
</script>
4425

@@ -47,7 +28,6 @@
4728

4829

4930
<a class="prev">prev</a>
50-
<a class="prevPage">prevPage</a>
5131

5232
<div class="scrollable">
5333

@@ -60,7 +40,6 @@
6040
</div>
6141

6242
<a class="next">next</a>
63-
<a class="nextPage">nextPage</a>
6443

6544
<br clear="all" />
6645

0 commit comments

Comments
 (0)