Skip to content

Commit d318a02

Browse files
committed
Merge branch 'dev' into test
Conflicts: .gitignore src/dateinput/dateinput.js src/scrollable/scrollable.js test/dateinput/minimal.htm test/overlay/index.htm test/scrollable/single.html
2 parents 4660bea + fcecfe6 commit d318a02

File tree

21 files changed

+187
-102
lines changed

21 files changed

+187
-102
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
builder
22
build
3+
<<<<<<< HEAD
34
www
45
site
6+
=======
7+
site
8+
www
9+
builder
10+
>>>>>>> dev
511
jquerytools.github.com
612

713
# patch

lib/jquery-1.5.min.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dateinput/dateinput.js

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
2929
min: undefined,
3030
max: undefined,
31-
trigger: false,
31+
trigger: 0,
32+
editable: 0,
3233

3334
css: {
3435

@@ -135,7 +136,7 @@
135136

136137
function parseDate(val) {
137138

138-
if (!val) { return; }
139+
if (val === undefined) { return; }
139140
if (val.constructor == Date) { return val; }
140141

141142
if (typeof val == 'string') {
@@ -166,6 +167,7 @@
166167
// variables
167168
var self = this,
168169
now = new Date(),
170+
yearNow = now.getFullYear(),
169171
css = conf.css,
170172
labels = LABELS[conf.lang],
171173
root = $("#" + css.root),
@@ -176,27 +178,32 @@
176178
value = input.attr("data-value") || conf.value || input.val(),
177179
min = input.attr("min") || conf.min,
178180
max = input.attr("max") || conf.max,
179-
opened;
181+
opened,
182+
original;
180183

181184
// zero min is not undefined
182185
if (min === 0) { min = "0"; }
183186

184187
// use sane values for value, min & max
185-
value = parseDate(value) || now;
186-
min = parseDate(min || conf.yearRange[0] * 365);
187-
max = parseDate(max || conf.yearRange[1] * 365);
188+
value = parseDate(value) || now;
189+
190+
min = parseDate(min || new Date(yearNow + conf.yearRange[0], 1, 1));
191+
max = parseDate(max || new Date( yearNow + conf.yearRange[1]+ 1, 1, -1));
188192

189193

190194
// check that language exists
191195
if (!labels) { throw "Dateinput: invalid language: " + conf.lang; }
192196

193197
// Replace built-in date input: NOTE: input.attr("type", "text") throws exception by the browser
194198
if (input.attr("type") == 'date') {
199+
200+
original = input.clone();
195201
var tmp = $("<input/>");
196202

197-
$.each("class,disabled,id,maxlength,name,readonly,required,size,style,tabindex,title,value".split(","), function(i, attr) {
203+
$.each("class,disabled,id,maxlength,name,placeholder,readonly,required,size,style,tabindex,title,value".split(","), function(i, attr) {
198204
tmp.attr(attr, input.attr(attr));
199-
});
205+
});
206+
200207
input.replaceWith(tmp);
201208
input = tmp;
202209
}
@@ -303,8 +310,8 @@
303310
return self.hide(e);
304311
}
305312

306-
// esc key
307-
if (key == 27) { return self.hide(e); }
313+
// esc or tab key
314+
if (key == 27 || key == 9) { return self.hide(e); }
308315

309316
if ($(KEYS).index(key) >= 0) {
310317

@@ -614,8 +621,15 @@
614621

615622
addYear: function(amount) {
616623
return this.setValue(currYear + (amount || 1), currMonth, currDay);
624+
},
625+
626+
destroy: function() {
627+
input.add(document).unbind("click.d").unbind("keydown.d");
628+
root.add(trigger).remove();
629+
input.removeData("dateinput").removeClass(css.input);
630+
if (original) { input.replaceWith(original); }
617631
},
618-
632+
619633
hide: function(e) {
620634

621635
if (opened) {
@@ -655,22 +669,25 @@
655669
}
656670

657671
});
658-
659-
// show dateinput & assign keyboard shortcuts
660-
input.bind("focus click", self.show).keydown(function(e) {
661672

662-
var key = e.keyCode;
663-
664-
// open dateinput with navigation keyw
665-
if (!opened && $(KEYS).index(key) >= 0) {
666-
self.show(e);
667-
return e.preventDefault();
668-
}
669-
670-
// allow tab
671-
return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault();
673+
if (!conf.editable) {
672674

673-
});
675+
// show dateinput & assign keyboard shortcuts
676+
input.bind("focus.d click.d", self.show).keydown(function(e) {
677+
678+
var key = e.keyCode;
679+
680+
// open dateinput with navigation keyw
681+
if (!opened && $(KEYS).index(key) >= 0) {
682+
self.show(e);
683+
return e.preventDefault();
684+
}
685+
686+
// allow tab
687+
return e.shiftKey || e.ctrlKey || e.altKey || key == 9 ? true : e.preventDefault();
688+
689+
});
690+
}
674691

675692
// initial value
676693
if (parseDate(input.val())) {

src/overlay/overlay.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
maskConf.closeOnClick = maskConf.closeOnEsc = false;
7777
}
7878

79-
// get overlay and triggerr
79+
// get overlay and trigger
8080
var jq = conf.target || trigger.attr("rel");
8181
overlay = jq ? $(jq) : null || trigger;
8282

src/rangeinput/rangeinput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
// Replace built-in range input (type attribute cannot be changed)
177177
if (input.attr("type") == 'range') {
178178
var tmp = $("<input/>");
179-
$.each("class,disabled,id,maxlength,name,readonly,required,size,style,tabindex,title,value".split(","), function(i, attr) {
179+
$.each("class,disabled,id,maxlength,name,placeholder,readonly,required,size,style,tabindex,title,value".split(","), function(i, attr) {
180180
tmp.attr(attr, input.attr(attr));
181181
});
182182
tmp.val(conf.value);

src/scrollable/scrollable.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
},
8383

8484
getItems: function() {
85-
return itemWrap.children(conf.item).not("." + conf.clonedClass);
85+
return itemWrap.find(conf.item).not("." + conf.clonedClass);
8686
},
8787

8888
move: function(offset, time) {
@@ -115,6 +115,8 @@
115115

116116
if (!conf.circular) {
117117
itemWrap.append(item);
118+
next.removeClass("disabled");
119+
118120
} else {
119121
itemWrap.children("." + conf.clonedClass + ":last").before(item);
120122
itemWrap.children("." + conf.clonedClass + ":first").replaceWith(item.clone().addClass(conf.clonedClass));
@@ -205,22 +207,28 @@
205207

206208
// next/prev buttons
207209
var prev = find(root, conf.prev).click(function() { self.prev(); }),
208-
next = find(root, conf.next).click(function() { self.next(); });
210+
next = find(root, conf.next).click(function() { self.next(); });
209211

210-
if (!conf.circular && self.getSize() > 1) {
212+
if (!conf.circular) {
211213

212-
root.bind("onBeforeSeek", function(e, i) {
214+
// perform last from the events
215+
self.onBeforeSeek(function(e, i) {
216+
213217
setTimeout(function() {
214218
if (!e.isDefaultPrevented()) {
215219
prev.toggleClass(conf.disabledClass, i <= 0);
216220
next.toggleClass(conf.disabledClass, i >= self.getSize() -1);
217221
}
218222
}, 1);
219223
});
224+
}
225+
226+
if (!conf.initialIndex) {
227+
prev.addClass(conf.disabledClass);
228+
}
220229

221-
if (!conf.initialIndex) {
222-
prev.addClass(conf.disabledClass);
223-
}
230+
if (self.getSize() < 2) {
231+
prev.add(next).addClass(conf.disabledClass);
224232
}
225233

226234
// mousewheel support
@@ -262,7 +270,9 @@
262270
$(document).bind("keydown.scrollable", function(evt) {
263271

264272
// skip certain conditions
265-
if (!conf.keyboard || evt.altKey || evt.ctrlKey || $(evt.target).is(":input")) { return; }
273+
if (!conf.keyboard || evt.altKey || evt.ctrlKey || evt.metaKey || $(evt.target).is(":input")) {
274+
return;
275+
}
266276

267277
// does this instance have focus?
268278
if (conf.keyboard != 'static' && current != self) { return; }

src/toolbox/toolbox.flashembed.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292

293293
jQuery.fn.flashembed = function(opts, conf) {
294294
return this.each(function() {
295-
$(this).data("flashembed", flashembed(this, opts, conf));
295+
jQuery(this).data("flashembed", flashembed(this, opts, conf));
296296
});
297297
};
298298
}

src/tooltip/tooltip.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@
235235

236236
if (!tip.data("__set")) {
237237

238-
tip.bind(event[0], function() {
238+
tip.unbind(event[0]).bind(event[0], function() {
239239
clearTimeout(timer);
240240
clearTimeout(pretimer);
241241
});
242242

243243
if (event[1] && !trigger.is("input:not(:checkbox, :radio), textarea")) {
244-
tip.bind(event[1], function(e) {
244+
tip.unbind(event[1]).bind(event[1], function(e) {
245245

246246
// being moved to the trigger element
247247
if (e.relatedTarget != trigger[0]) {
@@ -250,7 +250,8 @@
250250
});
251251
}
252252

253-
tip.data("__set", true);
253+
// bind agein for if same tip element
254+
if (!conf.tip) tip.data("__set", true);
254255
}
255256

256257
return self;

src/validator/validator.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@
510510
if (!self.checkValidity(null, e)) {
511511
return e.preventDefault();
512512
}
513+
// Reset event type and target
514+
e.target = form;
515+
e.type = conf.formEvent;
513516
});
514517
}
515518

test/dateinput/minimal.htm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
<script src="../js/jquery-1.4.2.js"></script>
2+
<script src="../js/jquery-1.5.min.js"></script>
33
<script src="../../src/core.js"></script>
44
<script src="../../src/dateinput/dateinput.js"></script>
55

@@ -10,6 +10,10 @@
1010

1111
<!-- make it happen -->
1212
<script>
13-
$(":date").dateinput({ selectors: true, yearRange: [-10, 10] }).data("dateinput").show();
13+
$(":date").dateinput({
14+
selectors: true,
15+
yearRange: [-10, 10]
16+
17+
}).data("dateinput");
1418
</script>
1519

0 commit comments

Comments
 (0)