Modified: trunk/Source/WebCore/ChangeLog (129197 => 129198)
--- trunk/Source/WebCore/ChangeLog 2012-09-21 06:32:40 UTC (rev 129197)
+++ trunk/Source/WebCore/ChangeLog 2012-09-21 07:02:20 UTC (rev 129198)
@@ -1,3 +1,27 @@
+2012-09-21 Keishi Hattori <[email protected]>
+
+ Prepare CalendarPicker so we can add another picker, SuggetionPicker
+ https://bugs.webkit.org/show_bug.cgi?id=97193
+
+ Reviewed by Kent Tamura.
+
+ Preparation so we can add another picker to CalendarPicker and switch
+ between them.
+
+ No new tests. No behavior change.
+
+ * Resources/pagepopups/calendarPicker.css:
+ (.calendar-picker): Added so we can apply these styles just to calendar picker.
+ * Resources/pagepopups/calendarPicker.js:
+ (CalendarPicker.validateConfig): Renamed so each picker can validate the config object.
+ (initialize):
+ (closePicker): Call Picker.cleanup().
+ (openCalendarPicker):
+ (CalendarPicker):
+ (CalendarPicker.prototype.cleanup): Cleanup event listener on document.body.
+ * Resources/pagepopups/pickerCommon.js:
+ (Picker.prototype.cleanup):
+
2012-09-20 John Mellor <[email protected]>
Text Autosizing: Cluster text at flow roots, for consistency and to avoid autosizing headers/footers.
Modified: trunk/Source/WebCore/Resources/pagepopups/calendarPicker.css (129197 => 129198)
--- trunk/Source/WebCore/Resources/pagepopups/calendarPicker.css 2012-09-21 06:32:40 UTC (rev 129197)
+++ trunk/Source/WebCore/Resources/pagepopups/calendarPicker.css 2012-09-21 07:02:20 UTC (rev 129198)
@@ -40,14 +40,13 @@
outline: none;
}
-#main {
+.calendar-picker {
background-color: white;
border: solid 1px #8899aa;
box-shadow: inset 2px 2px 2px white,
inset -2px -2px 1px rgba(0,0,0,0.1);
padding: 6px;
- whitespace: nowrap;
- /* width is reset in the JS code. */
+ white-space: nowrap;
width: 500px;
}
Modified: trunk/Source/WebCore/Resources/pagepopups/calendarPicker.js (129197 => 129198)
--- trunk/Source/WebCore/Resources/pagepopups/calendarPicker.js 2012-09-21 06:32:40 UTC (rev 129197)
+++ trunk/Source/WebCore/Resources/pagepopups/calendarPicker.js 2012-09-21 07:02:20 UTC (rev 129198)
@@ -72,7 +72,8 @@
*/
var global = {
argumentsReceived: false,
- params: null
+ params: null,
+ picker: null
};
// ----------------------------------------------------------------
@@ -239,25 +240,25 @@
}
/**
- * @param {!Object} args
+ * @param {!Object} config
* @return {?string} An error message, or null if the argument has no errors.
*/
-function validateArguments(args) {
- if (!args.monthLabels)
+CalendarPicker.validateConfig = function(config) {
+ if (!config.monthLabels)
return "No monthLabels.";
- if (args.monthLabels.length != 12)
+ if (config.monthLabels.length != 12)
return "monthLabels is not an array with 12 elements.";
- if (!args.dayLabels)
+ if (!config.dayLabels)
return "No dayLabels.";
- if (args.dayLabels.length != 7)
+ if (config.dayLabels.length != 7)
return "dayLabels is not an array with 7 elements.";
- if (!args.clearLabel)
+ if (!config.clearLabel)
return "No clearLabel.";
- if (!args.todayLabel)
+ if (!config.todayLabel)
return "No todayLabel.";
- if (args.weekStartDay) {
- if (args.weekStartDay < 0 || args.weekStartDay > 6)
- return "Invalid weekStartDay: " + args.weekStartDay;
+ if (config.weekStartDay) {
+ if (config.weekStartDay < 0 || config.weekStartDay > 6)
+ return "Invalid weekStartDay: " + config.weekStartDay;
}
return null;
}
@@ -266,7 +267,7 @@
* @param {!Object} args
*/
function initialize(args) {
- var errorString = validateArguments(args);
+ var errorString = CalendarPicker.validateConfig(args);
if (errorString) {
var main = $("main");
main.textContent = "Internal error: " + errorString;
@@ -277,15 +278,17 @@
}
}
-function resetMain() {
+function closePicker() {
+ if (global.picker)
+ global.picker.cleanup();
var main = $("main");
main.innerHTML = "";
main.className = "";
};
function openCalendarPicker() {
- resetMain();
- new CalendarPicker($("main"), global.params);
+ closePicker();
+ global.picker = new CalendarPicker($("main"), global.params);
};
/**
@@ -295,6 +298,7 @@
*/
function CalendarPicker(element, config) {
Picker.call(this, element, config);
+ this._element.classList.add("calendar-picker");
// We assume this._config.min is a valid date.
this.minimumDate = (typeof this._config.min !== "undefined") ? parseDateString(this._config.min) : CalendarPicker.MinimumPossibleDate;
// We assume this._config.max is a valid date.
@@ -311,7 +315,8 @@
initialDate = this.maximumDate;
this.daysTable.selectDate(initialDate);
this.fixWindowSize();
- document.body.addEventListener("keydown", this._handleBodyKeyDown.bind(this), false);
+ this._handleBodyKeyDownBound = this._handleBodyKeyDown.bind(this);
+ document.body.addEventListener("keydown", this._handleBodyKeyDownBound, false);
}
CalendarPicker.prototype = Object.create(Picker.prototype);
@@ -321,6 +326,10 @@
// See WebCore/html/DateInputType.cpp.
CalendarPicker.BaseStep = 86400000;
+CalendarPicker.prototype.cleanup = function() {
+ document.body.removeEventListener("keydown", this._handleBodyKeyDownBound, false);
+};
+
CalendarPicker.prototype._layout = function() {
this._element.style.direction = global.params.isRTL ? "rtl" : "ltr";
this.yearMonthController.attachTo(this._element);
Modified: trunk/Source/WebCore/Resources/pagepopups/pickerCommon.js (129197 => 129198)
--- trunk/Source/WebCore/Resources/pagepopups/pickerCommon.js 2012-09-21 06:32:40 UTC (rev 129197)
+++ trunk/Source/WebCore/Resources/pagepopups/pickerCommon.js 2012-09-21 07:02:20 UTC (rev 129198)
@@ -1,3 +1,4 @@
+"use strict";
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
@@ -57,6 +58,9 @@
}
}
+/**
+ * @return {!number}
+ */
function getScrollbarWidth() {
if (typeof window.scrollbarWidth === "undefined") {
var scrollDiv = document.createElement("div");
@@ -104,3 +108,5 @@
Picker.prototype.chooseOtherColor = function() {
window.pagePopupController.setValueAndClosePopup(Picker.Actions.ChooseOtherColor, "");
}
+
+Picker.prototype.cleanup = function() {};