Skip to content
Browse files

Merge branch 'dev' of github.com:jquerytools/jquerytools into dev

  • Loading branch information...
2 parents 2528b83 + 1359517 commit 70c22361ad14e4a283203d9e33b7533d4b069da9 @bradrobertson bradrobertson committed Aug 31, 2011
View
76 src/dateinput/dateinput.js
@@ -9,7 +9,7 @@
* Since: Mar 2010
* Date: @DATE
*/
-(function($) {
+(function($, undefined) {
/* TODO:
preserve today highlighted
@@ -91,7 +91,7 @@
// @return amount of days in certain month
function dayAm(year, month) {
- return 32 - new Date(year, month, 32).getDate();
+ return new Date(year, month + 1, 0).getDate();
}
function zeropad(val, len) {
@@ -339,10 +339,10 @@
if (index > 41) {
- self.addMonth();
+ showNextMonth();
el = $("#" + css.weeks + " a:eq(" + (index-42) + ")");
} else if (index < 0) {
- self.addMonth(-1);
+ showPreviousMonth();
el = $("#" + css.weeks + " a:eq(" + (index+42) + ")");
} else {
el = days.eq(index);
@@ -354,17 +354,17 @@
}
// pageUp / pageDown
- if (key == 34) { return self.addMonth(); }
- if (key == 33) { return self.addMonth(-1); }
+ if (key == 34) { return showNextMonth(); }
+ if (key == 33) { return showPreviousMonth(); }
// home
- if (key == 36) { return self.today(); }
+ if (key == 36) { return self.today(); }
// enter
if (key == 13) {
if (!$(e.target).is("select")) {
- $("." + css.focus).click();
- }
+ $("." + css.focus).click();
+ }
}
return $([16, 17, 18, 9]).index(key) >= 0;
@@ -382,12 +382,42 @@
});
}
//}}}
-
+
+
+ /**
+ * @private
+ *
+ * Calculates the days in the next month to properly switch months
+ *
+ */
+ function showNextMonth() {
+
+ var daysNextMonth = dayAm(currYear, currMonth + 1);
+
+ /*
+ * If next month has less days than the current date
+ * add number of days in the next month, otherwise add
+ * number of days in the current month
+ */
+ return self.addDay(currDay > daysNextMonth ? daysNextMonth : dayAm(currYear, currMonth));
+ }
+
+ /**
+ * @private
+ *
+ * Return to previous month
+ */
+ function showPreviousMonth() {
+ return self.addDay(-dayAm(currYear, currMonth));
+ }
$.extend(self, {
-//{{{ show
-
+
+ /**
+ * @public
+ * Show the calendar
+ */
show: function(e) {
if (input.attr("readonly") || input.attr("disabled") || opened) { return; }
@@ -417,14 +447,14 @@
// prev / next month
pm = root.find("#" + css.prev).unbind("click").click(function(e) {
if (!pm.hasClass(css.disabled)) {
- self.addMonth(-1);
+ showPreviousMonth();
}
return false;
});
nm = root.find("#" + css.next).unbind("click").click(function(e) {
if (!nm.hasClass(css.disabled)) {
- self.addMonth();
+ showNextMonth();
}
return false;
});
@@ -456,16 +486,15 @@
return self;
},
-//}}}
-
-
-//{{{ setValue
+ /**
+ * @public
+ *
+ * Set the value of the dateinput
+ */
setValue: function(year, month, day) {
-
-
- var date = integer(month) >= -1 ? new Date(integer(year), integer(month), integer(day || 1)) :
+ var date = integer(month) >= -1 ? new Date(integer(year), integer(month), integer(day == undefined || isNaN(day) ? 1 : day)) :
year || value;
if (date < min) { date = min; }
@@ -495,6 +524,7 @@
currMonth = month;
currYear = year;
+ currDay = day;
// variables
var tmp = new Date(year, month, 1 - conf.firstDay), begin = tmp.getDay(),
@@ -508,7 +538,7 @@
// month selector
monthSelector.empty();
$.each(labels.months, function(i, m) {
- if (min < new Date(year, i + 1, -1) && max > new Date(year, i, 0)) {
+ if (min < new Date(year, i + 1, 1) && max > new Date(year, i, 0)) {
monthSelector.append($("<option/>").html(m).attr("value", i));
}
});
@@ -518,7 +548,7 @@
var yearNow = now.getFullYear();
for (var i = yearNow + conf.yearRange[0]; i < yearNow + conf.yearRange[1]; i++) {
- if (min <= new Date(i + 1, -1, 1) && max > new Date(i, 0, 0)) {
+ if (min < new Date(i + 1, 0, 1) && max > new Date(i, 0, 0)) {
yearSelector.append($("<option/>").text(i));
}
}
View
2 test/dateinput/setmin.htm
@@ -7,7 +7,7 @@
<!-- HTML5 date input -->
<input type="date" name="mydate" data-value="2010-12-01" min="2010-12-01" max="2011-12-02" />
-<input type="date" name="mydate" data-value="2010-12-01" min="2010-12-01" max="2012-07-01" />
+<input type="date" name="mydate" data-value="2010-12-30" min="2010-12-30" max="2012-07-01" />
<!-- make it happen -->
<script>
View
2 test/tooltip/click.html
@@ -1,5 +1,5 @@
-<script src="../../../jquery-1.3.2.js"></script>
+<script src="../../../jquery-1.6.2.js"></script>
<script src="../tools.tooltip.js"></script>
<link rel="stylesheet" type="text/css" href="style.css"/>
View
2 test/tooltip/dynamic.html
@@ -1,5 +1,5 @@
-<script src="../../../jquery-1.3.2.js"></script>
+<script src="../../../jquery-1.6.2.js"></script>
<script src="../tools.tooltip.js"></script>
<script src="../tools.tooltip.dynamic.js"></script>
View
2 test/tooltip/index.html
@@ -1,5 +1,5 @@
-<script src="../js/jquery-1.4.1.js"></script>
+<script src="../js/jquery-1.6.2.js"></script>
<script src="../../src/tooltip/tooltip.js"></script>
<script src="../../src/tooltip/tooltip.slide.js"></script>
View
2 test/tooltip/many.html
@@ -1,5 +1,5 @@
-<script src="../js/jquery-1.4.1.js"></script>
+<script src="../js/jquery-1.6.2.js"></script>
<script src="../../src/tooltip/tooltip.js"></script>
<style>
View
50 test/tooltip/vertical_form.html
@@ -0,0 +1,50 @@
+
+<script src="../js/jquery-1.6.2.js"></script>
+<script src="../../src/tooltip/tooltip.js"></script>
+
+<style type="text/css">
+ body{
+ padding:50px;
+ }
+
+ input {
+ display:block;
+ margin:10px;
+ }
+
+ /* tooltip styling. by default the element to be styled is .tooltip */
+ .tooltip {
+ display:none;
+ background:transparent url('http://flowplayer.org/tools/img/tooltip/black_arrow.png');
+ font-size:12px;
+ height:70px;
+ width:160px;
+ padding:25px;
+ color:#fff;
+ }
+</style>
+
+<input type="text" title="The tooltip text #1" />
+<input type="text" title="The tooltip text #2" />
+<input type="text" title="The tooltip text #3" />
+<input type="text" title="The tooltip text #4" />
+<input type="text" title="The tooltip text #5" />
+<input type="text" title="The tooltip text #6" />
+<input type="text" title="The tooltip text #7" />
+<input type="text" title="The tooltip text #8" />
+
+<script type="text/javascript">
+$(function(){
+ $("input").tooltip({
+ events: {
+ input: "focus mouseenter,blur mouseleave"
+ }
+ }).mouseleave(function(){
+ console.log("input mouseleave");
+ });
+
+ $(".tooltip").live('mouseleave', function(){
+ console.log("tooltip mouseleave");
+ });
+});
+</script>

0 comments on commit 70c2236

Please sign in to comment.
Something went wrong with that request. Please try again.