You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by cm...@apache.org on 2012/07/03 14:22:29 UTC
[10/28] git commit: WICKET-4635 Improve JavaScript files by applying
common JSHint rules
WICKET-4635 Improve JavaScript files by applying common JSHint rules
Add wicket-date.js (-datetime module) to the linted files
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/091e847c
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/091e847c
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/091e847c
Branch: refs/heads/sandbox/resourcefinder
Commit: 091e847c913bd6414a5ad3afb2b3061f5effbd86
Parents: 95481df
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jul 3 10:09:45 2012 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jul 3 10:09:45 2012 +0200
----------------------------------------------------------------------
grunt.js | 12 +-
.../extensions/yui/calendar/DatePickerInit.js | 3 +-
.../wicket/extensions/yui/calendar/wicket-date.js | 545 ++++++++-------
3 files changed, 298 insertions(+), 262 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/091e847c/grunt.js
----------------------------------------------------------------------
diff --git a/grunt.js b/grunt.js
index 2397560..65a71b9 100644
--- a/grunt.js
+++ b/grunt.js
@@ -15,7 +15,7 @@ module.exports = function(grunt) {
"use strict";
var
- lintCore = [
+ coreJs = [
'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-event-jquery.js',
'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery-debug.js',
'wicket-core/src/main/java/org/apache/wicket/ajax/res/js/wicket-ajax-jquery.js',
@@ -25,13 +25,16 @@ module.exports = function(grunt) {
"wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.js",
"wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxSelector.js"
],
- lintExtensions = [
+ extensionsJs = [
"wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js",
"wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/form/palette/palette.js",
"wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/tree/res/tree.js",
"wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/autocomplete/wicket-autocomplete.js",
"wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js"
],
+ datetimeJs = [
+ "wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js"
+ ],
gruntJs = [
"grunt.js"
];
@@ -39,8 +42,9 @@ module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
lint: {
- core: lintCore,
- extensions: lintExtensions,
+ core: coreJs,
+ extensions: extensionsJs,
+ datetime: datetimeJs,
grunt: gruntJs
},
http://git-wip-us.apache.org/repos/asf/wicket/blob/091e847c/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePickerInit.js
----------------------------------------------------------------------
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePickerInit.js b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePickerInit.js
index 61b4056..82c689c 100644
--- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePickerInit.js
+++ b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePickerInit.js
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
if (typeof(Wicket) === 'undefined') {
window.Wicket = {};
}
@@ -54,4 +55,4 @@ Wicket.DateTimeInit.YuiLoader.addModule({
requires: ["calendar"],
fullpath: "${Wicket.DateTimeInit.DatePath}"
});
-Wicket.DateTimeInit.YuiLoader.insert();
+Wicket.DateTimeInit.YuiLoader.insert();
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/091e847c/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
----------------------------------------------------------------------
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
index d2c295b..96bcc85 100644
--- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
+++ b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js
@@ -19,288 +19,319 @@
* Wicket Date parse function for the Calendar/ Date picker component.
*/
-// Wicket Namespace
+/*globals YAHOO: true */
-if (typeof(Wicket) == "undefined")
- Wicket = { };
+;(function (undefined) {
+ 'use strict';
-Wicket.DateTime = { }
+ // Wicket Namespace
-/**
- * Parses date from simple date pattern.
- *
- * Supports patterns built up from the following elements:
- * yy OR yyyy for year
- * M OR MM OR MMM OR MMMM for month
- * d OR dd for day
- * EEEE for weekday (optional)
- */
-Wicket.DateTime.parseDate = function(cfg, value) {
- var numbers = value.match(/(\d+)/g);
- var pattern = cfg.datePattern;
- if (numbers == null) return Number.NaN;
- var day, month, year;
- var arrayPos = 0;
- for (var i = 0; i < pattern.length; i++) {
- var c = pattern.charAt(i);
- var len = 0;
- while ((pattern.charAt(i) == c) && (i < pattern.length)) {
- i++;
- len++;
+ if (typeof(Wicket) === "undefined") {
+ window.Wicket = {};
+ }
+
+ Wicket.DateTime = {};
+
+ /**
+ * Parses date from simple date pattern.
+ *
+ * Supports patterns built up from the following elements:
+ * yy OR yyyy for year
+ * M OR MM OR MMM OR MMMM for month
+ * d OR dd for day
+ * EEEE for weekday (optional)
+ */
+ Wicket.DateTime.parseDate = function(cfg, value) {
+ var numbers = value.match(/(\d+)/g);
+ var pattern = cfg.datePattern;
+ if (!numbers) {
+ return NaN;
}
- if (c == 'y') {
- year = numbers[arrayPos++];
- } else if (c == 'M') {
- var nameArray;
- switch (len) {
- case 3:
- nameArray = cfg.calendarInit.MONTHS_SHORT;
- break;
- case 4:
- nameArray = cfg.calendarInit.MONTHS_LONG;
- break;
- default:
- nameArray = null;
+
+ var day, month, year;
+ var arrayPos = 0;
+ for (var i = 0; i < pattern.length; i++) {
+ var c = pattern.charAt(i);
+ var len = 0;
+ while ((pattern.charAt(i) === c) && (i < pattern.length)) {
+ i++;
+ len++;
}
- if (nameArray != null) {
- for (var j = 0; j < nameArray.length; j++) {
- if (value.indexOf(nameArray[j]) >= 0) {
- month = j + 1;
- break;
+ if (c === 'y') {
+ year = numbers[arrayPos++];
+ } else if (c === 'M') {
+ var nameArray;
+ switch (len) {
+ case 3:
+ nameArray = cfg.calendarInit.MONTHS_SHORT;
+ break;
+ case 4:
+ nameArray = cfg.calendarInit.MONTHS_LONG;
+ break;
+ default:
+ nameArray = null;
+ }
+ if (nameArray) {
+ for (var j = 0; j < nameArray.length; j++) {
+ if (value.indexOf(nameArray[j]) >= 0) {
+ month = j + 1;
+ break;
+ }
}
+ } else {
+ month = numbers[arrayPos++];
}
+ } else if (c === 'd') {
+ day = numbers[arrayPos++];
+ }
+ if (arrayPos > 2) {
+ break;
+ }
+ }
+ // TODO this is a bit crude. Make nicer some time.
+ if (year < 100) {
+ if (year < 70) {
+ year = year * 1 + 2000;
} else {
- month = numbers[arrayPos++];
+ year = year * 1 + 1900;
}
- } else if (c == 'd') {
- day = numbers[arrayPos++];
}
- if (arrayPos > 2) break;
- }
- // TODO this is a bit crude. Make nicer some time.
- if (year < 100) {
- if (year < 70) {
- year = year * 1 + 2000;
+ var date = new Date();
+ date.setHours(0);
+ date.setMinutes(0);
+ date.setSeconds(0);
+ date.setMilliseconds(0);
+ date.setFullYear(year, (month - 1), day);
+
+ return date;
+ };
+
+ /**
+ * Returns a string containing the value, with a leading zero if the value is < 10.
+ */
+ Wicket.DateTime.padDateFragment = function(value) {
+ return (value < 10 ? "0" : "") + value;
+ };
+
+ /**
+ * Gets the height of the displayed area of the window, as YAHOO.util.Dom.getViewportHeight()
+ * has issues with Firefox.
+ * See http://tech.groups.yahoo.com/group/ydn-javascript/message/5850
+ * Implementation taken from: http://www.quirksmode.org/viewport/compatibility.html#link2
+ */
+ Wicket.DateTime.getViewportHeight = function() {
+ var viewPortHeight;
+
+ if (window.innerHeight) {// all browsers except IE
+ viewPortHeight = window.innerHeight;
+ } else if (document.documentElement && document.documentElement.clientHeight) {// IE 6 strict mode
+ viewPortHeight = document.documentElement.height;
+ } else if (document.body) {// other IEs
+ viewPortHeight = document.body.clientHeight;
+ }
+ return viewPortHeight;
+ };
+
+ /**
+ * Position subject relative to target top-left by default.
+ * If there is too little space on the right side/bottom,
+ * the datepicker's position is corrected so that the right side/bottom
+ * is aligned with the display area's right side/bottom.
+ * @param subject the dom element to has to be positioned
+ * @param target id of the dom element to position relative to
+ */
+ Wicket.DateTime.positionRelativeTo = function(subject, target) {
+
+ var targetPos = YAHOO.util.Dom.getXY(target);
+ var targetHeight = YAHOO.util.Dom.get(target).offsetHeight;
+ var subjectHeight = YAHOO.util.Dom.get(subject).offsetHeight;
+ var subjectWidth = YAHOO.util.Dom.get(subject).offsetWidth;
+
+ var viewPortHeight = Wicket.DateTime.getViewportHeight();
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+
+ // also take scroll position into account
+ var scrollPos = [YAHOO.util.Dom.getDocumentScrollLeft(), YAHOO.util.Dom.getDocumentScrollTop()];
+
+ // correct datepicker's position so that it isn't rendered off screen on the right side or bottom
+ if (targetPos[0] + subjectWidth > scrollPos[0] + viewPortWidth) {
+ // correct horizontal position
+ YAHOO.util.Dom.setX(subject, Math.max(targetPos[0], viewPortWidth) - subjectWidth);
} else {
- year = year * 1 + 1900;
+ YAHOO.util.Dom.setX(subject, targetPos[0]);
}
- }
- var date = new Date();
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- date.setMilliseconds(0);
- date.setFullYear(year, (month - 1), day);
-
- return date;
-}
-
-/**
- * Returns a string containing the value, with a leading zero if the value is < 10.
- */
-Wicket.DateTime.padDateFragment = function(value) {
- return (value < 10 ? "0" : "") + value;
-}
-
-/**
- * Gets the height of the displayed area of the window, as YAHOO.util.Dom.getViewportHeight()
- * has issues with Firefox.
- * See http://tech.groups.yahoo.com/group/ydn-javascript/message/5850
- * Implementation taken from: http://www.quirksmode.org/viewport/compatibility.html#link2
- */
-Wicket.DateTime.getViewportHeight = function() {
- if (window.innerHeight) // all browsers except IE
- viewPortHeight = window.innerHeight;
- else if (document.documentElement && document.documentElement.clientHeight) // IE 6 strict mode
- viewPortHeight = document.documentElement.height;
- else if (document.body) // other IEs
- viewPortHeight = document.body.clientHeight;
- return viewPortHeight;
-}
-
-/**
- * Position subject relative to target top-left by default.
- * If there is too little space on the right side/bottom,
- * the datepicker's position is corrected so that the right side/bottom
- * is aligned with the display area's right side/bottom.
- * @param subject the dom element to has to be positioned
- * @param target id of the dom element to position relative to
- */
-Wicket.DateTime.positionRelativeTo = function(subject, target) {
-
- targetPos = YAHOO.util.Dom.getXY(target);
- targetHeight = YAHOO.util.Dom.get(target).offsetHeight;
- subjectHeight = YAHOO.util.Dom.get(subject).offsetHeight;
- subjectWidth = YAHOO.util.Dom.get(subject).offsetWidth;
-
- viewPortHeight = Wicket.DateTime.getViewportHeight();
- viewPortWidth = YAHOO.util.Dom.getViewportWidth();
-
- // also take scroll position into account
- scrollPos = [YAHOO.util.Dom.getDocumentScrollLeft(), YAHOO.util.Dom.getDocumentScrollTop()];
-
- // correct datepicker's position so that it isn't rendered off screen on the right side or bottom
- if (targetPos[0] + subjectWidth > scrollPos[0] + viewPortWidth) {
- // correct horizontal position
- YAHOO.util.Dom.setX(subject, Math.max(targetPos[0], viewPortWidth) - subjectWidth);
- } else {
- YAHOO.util.Dom.setX(subject, targetPos[0]);
- }
- if (targetPos[1] + targetHeight + 1 + subjectHeight > scrollPos[1] + viewPortHeight) {
- // correct vertical position
- YAHOO.util.Dom.setY(subject, Math.max(targetPos[1], viewPortHeight) - subjectHeight);
- } else {
- YAHOO.util.Dom.setY(subject, targetPos[1] + targetHeight + 1);
- }
-}
-
-/**
- * Return the result of interpolating the value (date) argument with the date pattern.
- * The date has to be an array, where year is in the first, month in the second
- * and date (day of month) in the third slot.
- */
-Wicket.DateTime.substituteDate = function(cfg, date) {
- var day = date[2];
- var month = date[1];
- var year = date[0];
-
- var date = new Date();
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- date.setMilliseconds(0);
- date.setFullYear(year, (month - 1), day);
-
- var dayName = null;
- var datePattern = cfg.datePattern;
-
- // optionally do some padding to match the pattern
- if(datePattern.match(/dd+/)) day = Wicket.DateTime.padDateFragment(day);
- if (datePattern.match(/MMMM/)) month = cfg.calendarInit.MONTHS_LONG[month - 1];
- else if (datePattern.match(/MMM/)) month = cfg.calendarInit.MONTHS_SHORT[month - 1];
- else if(datePattern.match(/MM+/)) month = Wicket.DateTime.padDateFragment(month);
- if(datePattern.match(/yyy+/)) {
- year = Wicket.DateTime.padDateFragment(year);
- } else if(datePattern.match(/yy+/)) {
- year = Wicket.DateTime.padDateFragment(year % 100);
- }
- if (datePattern.match(/EEEE/)) {
- // figure out which weekday it is...
- var engDayName = date.toString().match(/(\S*)/)[0];
- var engDayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
- for (var i = 0; i < engDayNames.length; i++) {
- if (engDayName === engDayNames[i]) {
- dayName = cfg.calendarInit.WEEKDAYS_LONG[i];
- break;
+ if (targetPos[1] + targetHeight + 1 + subjectHeight > scrollPos[1] + viewPortHeight) {
+ // correct vertical position
+ YAHOO.util.Dom.setY(subject, Math.max(targetPos[1], viewPortHeight) - subjectHeight);
+ } else {
+ YAHOO.util.Dom.setY(subject, targetPos[1] + targetHeight + 1);
+ }
+ };
+
+ /**
+ * Return the result of interpolating the value (datetime) argument with the date pattern.
+ * The date has to be an array, where year is in the first, month in the second
+ * and date (day of month) in the third slot.
+ */
+ Wicket.DateTime.substituteDate = function(cfg, datetime) {
+ var day = datetime[2];
+ var month = datetime[1];
+ var year = datetime[0];
+
+ var date = new Date();
+ date.setHours(0);
+ date.setMinutes(0);
+ date.setSeconds(0);
+ date.setMilliseconds(0);
+ date.setFullYear(year, (month - 1), day);
+
+ var dayName = null;
+ var datePattern = cfg.datePattern;
+
+ // optionally do some padding to match the pattern
+ if(datePattern.match(/dd+/)) {
+ day = Wicket.DateTime.padDateFragment(day);
+ }
+ if (datePattern.match(/MMMM/)) {
+ month = cfg.calendarInit.MONTHS_LONG[month - 1];
+ }
+ else if (datePattern.match(/MMM/)) {
+ month = cfg.calendarInit.MONTHS_SHORT[month - 1];
+ }
+ else if(datePattern.match(/MM+/)) {
+ month = Wicket.DateTime.padDateFragment(month);
+ }
+ if(datePattern.match(/yyy+/)) {
+ year = Wicket.DateTime.padDateFragment(year);
+ } else if(datePattern.match(/yy+/)) {
+ year = Wicket.DateTime.padDateFragment(year % 100);
+ }
+ if (datePattern.match(/EEEE/)) {
+ // figure out which weekday it is...
+ var engDayName = date.toString().match(/(\S*)/)[0];
+ var engDayNames = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
+ for (var i = 0; i < engDayNames.length; i++) {
+ if (engDayName === engDayNames[i]) {
+ dayName = cfg.calendarInit.WEEKDAYS_LONG[i];
+ break;
+ }
}
}
- }
- // replace pattern with real values
- var result = datePattern.replace(/d+/, day).replace(/y+/, year).replace(/M+/, month);
+ // replace pattern with real values
+ var result = datePattern.replace(/d+/, day).replace(/y+/, year).replace(/M+/, month);
- if (dayName != null) {
- result = result.replace(/EEEE/, dayName);
- }
-
- return result;
-}
+ if (dayName != null) {
+ result = result.replace(/EEEE/, dayName);
+ }
-/**
- * Display the YUI calendar widget. If the date is not null (should be a string) then it is parsed
- * using the provided date pattern, and set as the current date on the widget.
- */
-Wicket.DateTime.showCalendar = function(widget, date, cfg) {
- if (date) {
- date = Wicket.DateTime.parseDate(cfg, date);
- if (!isNaN(date)) {
- widget.select(date);
- firstDate = widget.getSelectedDates()[0];
- if (firstDate) {
- widget.cfg.setProperty("pagedate", (firstDate.getMonth() + 1) + "/" + firstDate.getFullYear());
- widget.render();
+ return result;
+ };
+
+ /**
+ * Display the YUI calendar widget. If the date is not null (should be a string) then it is parsed
+ * using the provided date pattern, and set as the current date on the widget.
+ */
+ Wicket.DateTime.showCalendar = function(widget, date, cfg) {
+ if (date) {
+ date = Wicket.DateTime.parseDate(cfg, date);
+ if (!isNaN(date)) {
+ widget.select(date);
+ var firstDate = widget.getSelectedDates()[0];
+ if (firstDate) {
+ widget.cfg.setProperty("pagedate", (firstDate.getMonth() + 1) + "/" + firstDate.getFullYear());
+ widget.render();
+ }
}
}
- }
- widget.show();
-}
-
-// configures a datepicker using the cfg object
-Wicket.DateTime.init = function(cfg) {
- cfg.dpJs = cfg.widgetId + "DpJs";
- cfg.dp = cfg.widgetId + "Dp";
- cfg.icon = cfg.widgetId +"Icon";
- YAHOO.namespace("wicket");
-
- if (cfg.calendarInit.pages && cfg.calendarInit.pages > 1) {
- YAHOO.wicket[cfg.dpJs] = new YAHOO.widget.CalendarGroup(cfg.dpJs,cfg.dp, cfg.calendarInit);
- } else {
- YAHOO.wicket[cfg.dpJs] = new YAHOO.widget.Calendar(cfg.dpJs,cfg.dp, cfg.calendarInit);
- }
- YAHOO.wicket[cfg.dpJs].isVisible = function() { return YAHOO.wicket[cfg.dpJs].oDomContainer.style.display == 'block'; }
+ widget.show();
+ };
+
+ // configures a datepicker using the cfg object
+ Wicket.DateTime.init = function(cfg) {
+ cfg.dpJs = cfg.widgetId + "DpJs";
+ cfg.dp = cfg.widgetId + "Dp";
+ cfg.icon = cfg.widgetId +"Icon";
+ YAHOO.namespace("wicket");
+
+ if (cfg.calendarInit.pages && cfg.calendarInit.pages > 1) {
+ YAHOO.wicket[cfg.dpJs] = new YAHOO.widget.CalendarGroup(cfg.dpJs,cfg.dp, cfg.calendarInit);
+ } else {
+ YAHOO.wicket[cfg.dpJs] = new YAHOO.widget.Calendar(cfg.dpJs,cfg.dp, cfg.calendarInit);
+ }
+ YAHOO.wicket[cfg.dpJs].isVisible = function() { return YAHOO.wicket[cfg.dpJs].oDomContainer.style.display === 'block'; };
- function showCalendar() {
- Wicket.DateTime.showCalendar(YAHOO.wicket[cfg.dpJs], YAHOO.util.Dom.get(cfg.componentId).value, cfg);
- if (cfg.alignWithIcon) Wicket.DateTime.positionRelativeTo(YAHOO.wicket[cfg.dpJs].oDomContainer, cfg.icon);
- }
+ function showCalendar() {
+ Wicket.DateTime.showCalendar(YAHOO.wicket[cfg.dpJs], YAHOO.util.Dom.get(cfg.componentId).value, cfg);
+ if (cfg.alignWithIcon) {
+ Wicket.DateTime.positionRelativeTo(YAHOO.wicket[cfg.dpJs].oDomContainer, cfg.icon);
+ }
+ }
- YAHOO.util.Event.addListener(cfg.icon, "click", showCalendar, YAHOO.wicket[cfg.dpJs], true);
+ YAHOO.util.Event.addListener(cfg.icon, "click", showCalendar, YAHOO.wicket[cfg.dpJs], true);
- if (cfg.showOnFieldClick) {
- YAHOO.util.Event.addListener(cfg.widgetId, "click", showCalendar, YAHOO.wicket[cfg.dpJs], true);
- }
+ if (cfg.showOnFieldClick) {
+ YAHOO.util.Event.addListener(cfg.widgetId, "click", showCalendar, YAHOO.wicket[cfg.dpJs], true);
+ }
- function selectHandler(type, args, cal) {
- YAHOO.util.Dom.get(cfg.componentId).value = Wicket.DateTime.substituteDate(cfg, args[0][0]);
- if (cal.isVisible()) {
- if (cfg.hideOnSelect) cal.hide();
- if (cfg.fireChangeEvent) {
- var field = YAHOO.util.Dom.get(cfg.componentId);
- if (field.onchangeoriginal != null && typeof(field.onchangeoriginal) != 'undefined') field.onchangeoriginal();
- if (field.onchange != null && typeof(field.onchange) != 'undefined') field.onchange();
+ function selectHandler(type, args, cal) {
+ YAHOO.util.Dom.get(cfg.componentId).value = Wicket.DateTime.substituteDate(cfg, args[0][0]);
+ if (cal.isVisible()) {
+ if (cfg.hideOnSelect) {
+ cal.hide();
+ }
+ if (cfg.fireChangeEvent) {
+ var field = YAHOO.util.Dom.get(cfg.componentId);
+ if (field.onchangeoriginal) {
+ field.onchangeoriginal();
+ }
+ if (field.onchange) {
+ field.onchange();
+ }
+ }
}
}
- }
- YAHOO.wicket[cfg.dpJs].selectEvent.subscribe(selectHandler,YAHOO.wicket[cfg.dpJs]);
+ YAHOO.wicket[cfg.dpJs].selectEvent.subscribe(selectHandler, YAHOO.wicket[cfg.dpJs]);
- if(cfg.autoHide) {
- YAHOO.util.Event.on(document, "click", function(e) {
+ if(cfg.autoHide) {
+ YAHOO.util.Event.on(document, "click", function(e) {
- var el = YAHOO.util.Event.getTarget(e);
- var dialogEl = document.getElementById(cfg.dp);
- var showBtn = document.getElementById(cfg.icon);
- var fieldEl = document.getElementById(cfg.componentId);
+ var el = YAHOO.util.Event.getTarget(e);
+ var dialogEl = document.getElementById(cfg.dp);
+ var showBtn = document.getElementById(cfg.icon);
+ var fieldEl = document.getElementById(cfg.componentId);
- if (el != dialogEl && el != fieldEl && !YAHOO.util.Dom.isAncestor(dialogEl, el) && el != showBtn && !YAHOO.util.Dom.isAncestor(showBtn, el)) {
- YAHOO.wicket[cfg.dpJs].hide();
- }
- });
- }
- YAHOO.wicket[cfg.dpJs].render();
-}
-
-// init method variant that needs less character to invoke
-Wicket.DateTime.init2 = function(widgetId, componentId, calendarInit, datePattern,
- alignWithIcon, fireChangeEvent, hideOnSelect, showOnFieldClick, i18n, autoHide) {
- calendarInit.MONTHS_SHORT = i18n.MONTHS_SHORT;
- calendarInit.MONTHS_LONG = i18n.MONTHS_LONG;
- calendarInit.WEEKDAYS_MEDIUM = i18n.WEEKDAYS_MEDIUM;
- calendarInit.WEEKDAYS_LONG = i18n.WEEKDAYS_LONG;
- calendarInit.START_WEEKDAY = i18n.START_WEEKDAY;
- calendarInit.WEEKDAYS_1CHAR = i18n.WEEKDAYS_1CHAR;
- calendarInit.WEEKDAYS_SHORT = i18n.WEEKDAYS_SHORT;
-
- Wicket.DateTime.init({
- widgetId: widgetId,
- componentId: componentId,
- calendarInit: calendarInit,
- datePattern: datePattern,
- alignWithIcon: alignWithIcon,
- fireChangeEvent: fireChangeEvent,
- hideOnSelect: hideOnSelect,
- showOnFieldClick: showOnFieldClick,
- autoHide: autoHide
- });
-}
-
-YAHOO.register("wicket-date", Wicket.DateTime, {version: "1.5.5", build: "1"});
+ if (el !== dialogEl && el !== fieldEl && !YAHOO.util.Dom.isAncestor(dialogEl, el) && el !== showBtn && !YAHOO.util.Dom.isAncestor(showBtn, el)) {
+ YAHOO.wicket[cfg.dpJs].hide();
+ }
+ });
+ }
+ YAHOO.wicket[cfg.dpJs].render();
+ };
+
+ // init method variant that needs less character to invoke
+ Wicket.DateTime.init2 = function(widgetId, componentId, calendarInit, datePattern,
+ alignWithIcon, fireChangeEvent, hideOnSelect, showOnFieldClick, i18n, autoHide) {
+ calendarInit.MONTHS_SHORT = i18n.MONTHS_SHORT;
+ calendarInit.MONTHS_LONG = i18n.MONTHS_LONG;
+ calendarInit.WEEKDAYS_MEDIUM = i18n.WEEKDAYS_MEDIUM;
+ calendarInit.WEEKDAYS_LONG = i18n.WEEKDAYS_LONG;
+ calendarInit.START_WEEKDAY = i18n.START_WEEKDAY;
+ calendarInit.WEEKDAYS_1CHAR = i18n.WEEKDAYS_1CHAR;
+ calendarInit.WEEKDAYS_SHORT = i18n.WEEKDAYS_SHORT;
+
+ Wicket.DateTime.init({
+ widgetId: widgetId,
+ componentId: componentId,
+ calendarInit: calendarInit,
+ datePattern: datePattern,
+ alignWithIcon: alignWithIcon,
+ fireChangeEvent: fireChangeEvent,
+ hideOnSelect: hideOnSelect,
+ showOnFieldClick: showOnFieldClick,
+ autoHide: autoHide
+ });
+ };
+
+ YAHOO.register("wicket-date", Wicket.DateTime, {version: "6.0.0", build: "1"});
+})();
\ No newline at end of file