diff --git a/NOTICE b/NOTICE index c2b4544b95b..7cc91f994f0 100644 --- a/NOTICE +++ b/NOTICE @@ -59,9 +59,6 @@ src/./wicket-examples This product includes ASM, released under a BSD style license (http://asm.objectweb.org). Copyright (c) 2000-2005 INRIA, France Telecom - This product includes software developed by - Joda.org (http://www.joda.org/). - This product includes jhighlight (https://jhighlight.dev.java.net/) which is released under CDDL 1.0 license (http://www.opensource.org/licenses/cddl1.php). @@ -114,9 +111,6 @@ src/./wicket-datetime http://developer.yahoo.net/yui/license.txt Copyright (c) 2010, Yahoo! Inc. - This product includes software developed by - Joda.org (http://www.joda.org/). - --------------------------------------------------------------------------- src/./wicket-metrics --------------------------------------------------------------------------- diff --git a/README.md b/README.md index 3ff8f958a9c..a17dd274242 100644 --- a/README.md +++ b/README.md @@ -157,10 +157,6 @@ the src/ folder. As the following projects all depend on wicket, they inherit these dependencies. - - wicket-datetime: - - Joda-Time 2.4 (http://joda-time.sourceforge.net/) - - wicket-velocity: Apache Velocity 1.7 (http://velocity.apache.org/) and it's dependencies diff --git a/pom.xml b/pom.xml index a5cf4dbbd71..3c2657ed2ea 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,6 @@ wicket wicket-core wicket-util - wicket-datetime wicket-request wicket-devutils wicket-extensions @@ -247,11 +246,6 @@ javax.inject 1 - - joda-time - joda-time - ${joda-time.version} - log4j log4j diff --git a/testing/wicket-common-tests/pom.xml b/testing/wicket-common-tests/pom.xml index 62ccc6131cf..a8a37507451 100644 --- a/testing/wicket-common-tests/pom.xml +++ b/testing/wicket-common-tests/pom.xml @@ -57,11 +57,6 @@ wicket-core test - - org.apache.wicket - wicket-datetime - test - org.apache.wicket wicket-devutils diff --git a/testing/wicket-js-tests/Gruntfile.js b/testing/wicket-js-tests/Gruntfile.js index 6cb79bd060f..29b746b4c04 100644 --- a/testing/wicket-js-tests/Gruntfile.js +++ b/testing/wicket-js-tests/Gruntfile.js @@ -34,9 +34,6 @@ module.exports = function(grunt) { "../../wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/modal/res/modal.js", "../../wicket-extensions/src/main/java/org/apache/wicket/extensions/markup/html/repeater/data/table/filter/wicket-filterform.js" ], - datetimeJs = [ - "../../wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/wicket-date.js" - ], nativeWebSocketJs = [ "../../wicket-native-websocket/wicket-native-websocket-core/src/main/java/org/apache/wicket/protocol/ws/api/res/js/wicket-websocket-jquery.js" ], @@ -75,7 +72,6 @@ module.exports = function(grunt) { jshint: { core: coreJs, extensions: extensionsJs, - datetime: datetimeJs, nativeWebSocket: nativeWebSocketJs, testsJs: testsJs, gymTestsJs: gymTestsJs, diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java index 0112614a017..c85772a59c9 100644 --- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java +++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/FormComponentPanel.java @@ -40,8 +40,7 @@ *

* Here is a simple example of a panel with two components that multiplies and sets that as the * master model object. Note that for this simple example, setting the model value wouldn't make - * sense, as the lhs and rhs cannot be known. For more complete examples of using this class, see - * the wicket-datetime project. + * sense, as the lhs and rhs cannot be known. *

* *
diff --git a/wicket-datetime/pom.xml b/wicket-datetime/pom.xml
deleted file mode 100644
index 26330c38532..00000000000
--- a/wicket-datetime/pom.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-	4.0.0
-	
-		org.apache.wicket
-		wicket-parent
-		8.0.0-SNAPSHOT
-		../pom.xml
-	
-	wicket-datetime
-	bundle
-	Wicket Date/Time
-	Date/Time components and utilities for Wicket
-	
-		
-			joda-time
-			joda-time
-		
-		
-			org.apache.wicket
-			wicket-core
-		
-	
-	
-		
-			
-				org.apache.felix
-				maven-bundle-plugin
-				
-					
-						bundle-manifest
-						process-classes
-						
-							manifest
-						
-						
-							
-								
-									!org.apache.wicket.extensions.yui.yahoo-dom-event,* 
-								
-							
-						
-					
-				
-			
-		
-	
-
diff --git a/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/basic/DateLabel.java b/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/basic/DateLabel.java
deleted file mode 100644
index 3459397257f..00000000000
--- a/wicket-datetime/src/main/java/org/apache/wicket/datetime/markup/html/basic/DateLabel.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.datetime.markup.html.basic;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.wicket.IGenericComponent;
-import org.apache.wicket.datetime.DateConverter;
-import org.apache.wicket.datetime.PatternDateConverter;
-import org.apache.wicket.datetime.StyleDateConverter;
-import org.apache.wicket.markup.ComponentTag;
-import org.apache.wicket.markup.MarkupStream;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.util.convert.IConverter;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.DateTimeFormat;
-
-
-/**
- * A label that is mapped to a java.util.Date object and that uses Joda time to format
- * values.
- * 

- * You can provide a date pattern in two of the constructors. When not provided, - * {@link DateTimeFormat#shortDate()} will be used. - *

- *

- * A special option is applyTimeZoneDifference which is an option that says whether to correct for - * the difference between the client's time zone and server's time zone. This is true by default. - *

- * - * @see DateTime - * @see DateTimeFormat - * @see DateTimeZone - * - * @author eelcohillenius - */ -public class DateLabel extends Label implements IGenericComponent -{ - private static final long serialVersionUID = 1L; - - /** - * Creates a new DateLabel defaulting to using a short date pattern - * - * @param id - * The id of the text field - * @param model - * The model - * @param datePattern - * The pattern to use. Must be not null. See {@link SimpleDateFormat} for available - * patterns. - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel forDatePattern(String id, IModel model, String datePattern) - { - return new DateLabel(id, model, new PatternDateConverter(datePattern, true)); - } - - /** - * Creates a new DateLabel defaulting to using a short date pattern - * - * @param id - * The id of the text field - * @param datePattern - * The pattern to use. Must be not null. See {@link SimpleDateFormat} for available - * patterns. - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel forDatePattern(String id, String datePattern) - { - return forDatePattern(id, null, datePattern); - } - - /** - * Creates a new DateLabel defaulting to using a short date pattern - * - * @param id - * The id of the text field - * @param model - * The model - * @param dateStyle - * style to use in case no pattern is provided. Must be two characters from the set - * {"S", "M", "L", "F", "-"}. Must be not null. See - * {@link DateTimeFormat#forStyle(String)} for options. - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel forDateStyle(String id, IModel model, String dateStyle) - { - return new DateLabel(id, model, new StyleDateConverter(dateStyle, true)); - } - - /** - * Creates a new DateLabel defaulting to using a short date pattern - * - * @param id - * The id of the text field - * @param dateStyle - * style to use in case no pattern is provided. Must be two characters from the set - * {"S", "M", "L", "F", "-"}. Must be not null. See - * {@link DateTimeFormat#forStyle(String)} for options. - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel forDateStyle(String id, String dateStyle) - { - return forDateStyle(id, null, dateStyle); - } - - /** - * Creates a new DateLabel defaulting to using a short date pattern - * - * @param id - * The id of the text field - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel forShortStyle(String id) - { - return forShortStyle(id, null); - } - - /** - * Creates a new DateLabel defaulting to using a short date pattern - * - * @param id - * The id of the text field - * @param model - * The model - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel forShortStyle(String id, IModel model) - { - return new DateLabel(id, model, new StyleDateConverter(true)); - } - - /** - * Creates a new DateLabel using the provided converter. - * - * @param id - * The id of the text field - * @param converter - * the date converter - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel withConverter(String id, DateConverter converter) - { - return withConverter(id, null, converter); - } - - /** - * Creates a new DateLabel using the provided converter. - * - * @param id - * The id of the text field - * @param model - * The model - * @param converter - * the date converter - * @return new instance - * - * @see org.apache.wicket.markup.html.form.TextField - */ - public static DateLabel withConverter(String id, IModel model, DateConverter converter) - { - return new DateLabel(id, model, converter); - } - - /** optionally prepend to label. */ - private String after; - - /** optionally append to label. */ - private String before; - - /** - * The converter for the Label - */ - private final DateConverter converter; - - /** - * Construct with a converter. - * - * @param id - * The component id - * @param converter - * The converter to use - */ - public DateLabel(String id, DateConverter converter) - { - this(id, null, converter); - } - - /** - * Construct with a converter. - * - * @param id - * The component id - * @param model - * The model - * @param converter - * The converter to use - */ - public DateLabel(String id, IModel model, DateConverter converter) - { - super(id, model); - if (converter == null) - { - throw new IllegalStateException("converter may not be null"); - } - this.converter = converter; - } - - /** - * @return after append to label or null - */ - public String getAfter() - { - return after; - } - - /** - * @return before prepend to label or null - */ - public String getBefore() - { - return before; - } - - /** - * Returns the specialized converter. - */ - @Override - protected IConverter createConverter(Class type) - { - if (Date.class.isAssignableFrom(type)) - { - return converter; - } - return null; - } - - /** - * @param after - * append to label - */ - public void setAfter(String after) - { - this.after = after; - } - - /** - * @param before - * prepend to label - */ - public void setBefore(String before) - { - this.before = before; - } - - /** - * {@inheritDoc} - */ - @Override - public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) - { - String s = getDefaultModelObjectAsString(); - if (before != null) - { - s = before + s; - } - if (after != null) - { - s = s + after; - } - replaceComponentTagBody(markupStream, openTag, s); - } -} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/VERSION b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/VERSION deleted file mode 100644 index 094e00c2a0b..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/VERSION +++ /dev/null @@ -1,2 +0,0 @@ -http://developer.yahoo.com/yui/ -this version: 2.8.2r1 diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java deleted file mode 100644 index f8cfec5c870..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/YuiLib.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.extensions.yui; - -import org.apache.wicket.Application; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; -import org.apache.wicket.request.resource.PackageResourceReference; -import org.apache.wicket.request.resource.ResourceReference; - -/** - * Use the {@link #load(org.apache.wicket.markup.head.IHeaderResponse)} method to initialize the YUI library using the YUI loader. - * It is OK to call this multiple times. - * - * By default the resource stream gets gzipped. You may disable it via - * Application.get().getResourceSettings().getDisableGZipCompression() - * - * @author eelcohillenius - */ -public final class YuiLib -{ - private static ResourceReference YUILOADER; - - /** - * Load the YUI loader script. After that, you can declare YUI dependencies using - * YAHOO.util.YUILoader. - * - * @param response - * header response - */ - public static void load(IHeaderResponse response) - { - response.render(JavaScriptHeaderItem.forReference(getYuiLoader())); - } - - private static ResourceReference getYuiLoader() - { - if (YUILOADER == null) - { - StringBuilder sb = new StringBuilder("yuiloader/yuiloader"); - if (Application.get().usesDeploymentConfig()) - { - sb.append("-min"); - } - sb.append(".js"); - YUILOADER = new PackageResourceReference(YuiLib.class, sb.toString()); - } - return YUILOADER; - } - - /** - * Prevent construction. - */ - private YuiLib() - { - } -} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/assets/skins/sam/sprite.png b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/assets/skins/sam/sprite.png deleted file mode 100644 index 73634d6a22c..00000000000 Binary files a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/assets/skins/sam/sprite.png and /dev/null differ diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java deleted file mode 100644 index b448196564e..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/AbstractCalendar.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.extensions.yui.calendar; - -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; - -import org.apache.wicket.extensions.yui.YuiLib; -import org.apache.wicket.markup.head.CssHeaderItem; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.JavaScriptHeaderItem; -import org.apache.wicket.markup.html.WebComponent; -import org.apache.wicket.request.resource.PackageResourceReference; - - -/** - * Abstract calendar component based on the YUI (Yahoo User Interface library) javascript widget. - *

- * Although this component by itself is fully functional, it doesn't do much other than just - * displaying the calendar. Hence, this class is abstract. - *

- *

- * An easy way to build upon this component is to override - * {@link #appendToInit(String, String, String, StringBuffer)} and add event handlers etc. in the - * YUI widget's initialization function. - *

- * See YUI's calendar documentation for more - * info. - * - * @author eelcohillenius - * - * @see DatePicker - */ -// TODO provide localization strings (base them on the messages of -// JsDatePicker?) -public abstract class AbstractCalendar extends WebComponent -{ - private static final long serialVersionUID = 1L; - - private final boolean contributeDependencies; - - /** - * Construct. Contributes packaged dependencies. - * - * @param id - * The component id - */ - public AbstractCalendar(String id) - { - this(id, true); - } - - /** - * Construct. - * - * @param id - * The component id - * @param contributeDependencies - * Whether to contribute the packaged dependencies. Pass false in case you want to - * include the dependencies manually in your own page, e.g. when you want to keep - * them in your web application dir. To contribute yourself (in case you want to pass - * false), your page header should look like: - * - *
-	 * 	 <script type="text/javascript" src="yahoo.js"></script>
-	 * 	 <script type="text/javascript" src="dom.js"></script>
-	 * 	 <script type="text/javascript" src="event.js"></script>
-	 * 	 <script type="text/javascript" src="calendar.js"></script>
-	 * 	 <link rel="stylesheet" type="text/css" href="calendar.css" />
-	 * 
- */ - public AbstractCalendar(String id, boolean contributeDependencies) - { - - super(id); - setOutputMarkupId(true); - this.contributeDependencies = contributeDependencies; - } - - /** - * Gets the id of the javascript widget. Note that this is the non-namespaced id, so depending - * on what you want to do with it, you may need to prepend 'YAHOO.wicket.' to it. Or you can - * call {@link #getJavaScriptWidgetId()}. - * - * @return The javascript id - * @see #getJavaScriptWidgetId() - */ - public final String getJavaScriptId() - { - return getMarkupId() + "Js"; - } - - /** - * The name spaced id of the widget. - * - * @return The widget id - * @see #getJavaScriptId() - */ - public final String getJavaScriptWidgetId() - { - return "YAHOO.wicket." + getJavaScriptId(); - } - - /** - * add header contributions for packaged resources. - * - * @param response - * the header response to contribute to - */ - private void contributeDependencies(IHeaderResponse response) - { - response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference( - YuiLib.class, "yahoodomevent/yahoo-dom-event.js"))); - response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference( - AbstractCalendar.class, "calendar-min.js"))); - response.render(CssHeaderItem.forReference(new PackageResourceReference( - AbstractCalendar.class, "assets/skins/sam/calendar.css"))); - } - - /** - * Append javascript to the initialization function for the YUI widget. Can be used by - * subclasses to conveniently extend configuration without having to write a separate - * contribution. - * - * @param markupId - * The markup id of the calendar component - * @param javascriptId - * the non-name spaced javascript id of the widget - * @param javascriptWidgetId - * the name space id of the widget - * @param b - * the buffer to append the script to - */ - protected void appendToInit(String markupId, String javascriptId, String javascriptWidgetId, - StringBuilder b) - { - } - - /** - * Gives overriding classes the option of adding (or even changing/ removing) configuration - * properties for the javascript widget. See the widget's documentation for the - * available options. If you want to override/ remove properties, you obviously should call - * super.configureWidgetProperties(properties). - * - * @param widgetProperties - * the current widget properties - */ - protected void configureWidgetProperties(Map widgetProperties) - { - } - - @Override - public void renderHead(IHeaderResponse response) - { - if (contributeDependencies) - { - contributeDependencies(response); - } - - - // not pretty to look at, but cheaper than using a template - String markupId = AbstractCalendar.this.getMarkupId(); - String javascriptId = getJavaScriptId(); - String javascriptWidgetId = getJavaScriptWidgetId(); - StringBuilder b = new StringBuilder(); - // initialize wicket namespace and register the init function - // for the YUI widget - b.append("YAHOO.namespace(\"wicket\");\nfunction init"); - b.append(javascriptId); - b.append("() {\n"); - - // instantiate the calendar object - b.append(" "); - b.append(javascriptWidgetId); - b.append(" = new YAHOO.widget.Calendar(\""); - b.append(javascriptId); - b.append("\",\""); - b.append(markupId); - - Properties p = new Properties(); - configureWidgetProperties(p); - b.append("\", { "); - for (Iterator> i = p.entrySet().iterator(); i.hasNext();) - { - Entry entry = i.next(); - b.append(entry.getKey()); - Object value = entry.getValue(); - if (value instanceof CharSequence) - { - b.append(":\""); - b.append(value); - b.append("\""); - } - else if (value instanceof CharSequence[]) - { - b.append(":["); - CharSequence[] valueArray = (CharSequence[])value; - for (int j = 0; j < valueArray.length; j++) - { - CharSequence tmpValue = valueArray[j]; - b.append("\""); - b.append(tmpValue); - b.append("\""); - if (j < valueArray.length - 1) - { - b.append(","); - } - } - b.append("]"); - } - else - { - b.append(":"); - b.append(value); - } - // TODO handle arrays - if (i.hasNext()) - { - b.append(","); - } - } - - b.append(" });\n"); - - // append the javascript we want for our init function; call - // this in an overridable method so that clients can add their - // stuff without needing a big ass API - appendToInit(markupId, javascriptId, javascriptWidgetId, b); - - // trigger rendering - b.append(" "); - b.append(javascriptWidgetId); - b.append(".render();\n"); - - b.append("}\n"); - // register the function for execution when the page is loaded - b.append("YAHOO.util.Event.addListener(window, \"load\", init"); - b.append(javascriptId); - b.append(");"); - - response.render(JavaScriptHeaderItem.forScript(b, null)); - } -} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateField.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateField.java deleted file mode 100644 index 5c08241c0ad..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateField.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.extensions.yui.calendar; - -import java.util.Date; - -import org.apache.wicket.datetime.markup.html.form.DateTextField; -import org.apache.wicket.model.IModel; - -/** - * Works on a {@link java.util.Date} object. Displays a {@link DateTextField} and a - * {@link DatePicker calendar popup}.
- *

- * Note: {@link DateField} must not be associated with an - * <input> tag, as opposed to {@link DateTextField}! The corresponding tag is - * typically either a <div> or a <span> tag. - *

- * - * Example: - *

- * Java: - * - *

- * DateField dateField = new DateField("birthday");
- * 
- * - *

- *

- * Markup: - * - *

- * <div wicket:id="birthday"></div>
- * 
- * - *

- * - * @author eelcohillenius - */ -public class DateField extends DateTimeField -{ - private static final long serialVersionUID = 1L; - - /** - * Construct. - * - * @param id - */ - public DateField(String id) - { - this(id, null); - } - - /** - * Construct. - * - * @param id - * @param model - */ - public DateField(String id, IModel model) - { - super(id, model); - - get(HOURS).setVisibilityAllowed(false); - get(MINUTES).setVisibilityAllowed(false); - get(AM_OR_PM_CHOICE).setVisibilityAllowed(false); - } -} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java deleted file mode 100644 index 6b09e7a385b..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.java +++ /dev/null @@ -1,890 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.extensions.yui.calendar; - -import java.text.DateFormatSymbols; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.wicket.Application; -import org.apache.wicket.Component; -import org.apache.wicket.WicketRuntimeException; -import org.apache.wicket.ajax.AjaxEventBehavior; -import org.apache.wicket.behavior.Behavior; -import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; -import org.apache.wicket.datetime.markup.html.form.DateTextField; -import org.apache.wicket.extensions.yui.YuiLib; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.head.OnDomReadyHeaderItem; -import org.apache.wicket.markup.html.form.AbstractTextComponent.ITextFormatProvider; -import org.apache.wicket.request.Response; -import org.apache.wicket.request.cycle.RequestCycle; -import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler; -import org.apache.wicket.request.resource.JavaScriptResourceReference; -import org.apache.wicket.request.resource.PackageResourceReference; -import org.apache.wicket.request.resource.ResourceReference; -import org.apache.wicket.util.convert.IConverter; -import org.apache.wicket.util.convert.converter.DateConverter; -import org.apache.wicket.util.lang.Objects; -import org.apache.wicket.util.string.Strings; -import org.apache.wicket.util.template.PackageTextTemplate; -import org.apache.wicket.util.template.TextTemplate; -import org.joda.time.DateTime; - -/** - * Pops up a YUI calendar component so that the user can select a date. On selection, the date is - * set in the component it is coupled to, after which the popup is closed again. This behavior can - * only be used with components that either implement {@link ITextFormatProvider} or that use - * {@link DateConverter} configured with an instance of {@link SimpleDateFormat} (like Wicket's - * default configuration has).
- * - * To use, simply add a new instance to your component, which would typically a TextField, like - * {@link DateTextField}.
- * - * The CalendarNavigator can be configured by overriding {@link #configure(java.util.Map, org.apache.wicket.markup.head.IHeaderResponse, java.util.Map)} and setting the - * property or by returning true for {@link #enableMonthYearSelection()}. - * - * @see http://developer.yahoo.com/yui/calendar/ - * - * @author eelcohillenius - */ -public class DatePicker extends Behavior -{ - - /** - * Exception thrown when the bound component does not produce a format this date picker can work - * with. - */ - private static final class UnableToDetermineFormatException extends WicketRuntimeException - { - private static final long serialVersionUID = 1L; - - public UnableToDetermineFormatException() - { - super("This behavior can only be added to components that either implement " + - ITextFormatProvider.class.getName() + - " AND produce a non-null format, or that use" + - " converters that this DatePicker can use to determine" + - " the pattern being used. Alternatively, you can extend " + - " the DatePicker and override getDatePattern to provide your own."); - } - } - - /** - * Format to be used when configuring YUI calendar. Can be used when using the - * "selected" property. - */ - // See wicket-1988: SimpleDateFormat is not thread safe. Do not use static final - // See wicket-2525: SimpleDateFormat consumes a lot of memory - public static String FORMAT_DATE = "MM/dd/yyyy"; - - /** - * For specifying which page (month/year) to show in the calendar, use this format for the date. - * This is to be used together with the property "pagedate" - */ - // See wicket-1988: SimpleDateFormat is not thread safe. Do not use static final - // See wicket-2525: SimpleDateFormat consumes a lot of memory - public static String FORMAT_PAGEDATE = "MM/yyyy"; - - private static final ResourceReference YUI = new JavaScriptResourceReference(YuiLib.class, ""); - - private static final ResourceReference WICKET_DATE = new JavaScriptResourceReference( - DatePicker.class, "wicket-date.js"); - - private static final long serialVersionUID = 1L; - - /** The target component. */ - private Component component; - - private boolean showOnFieldClick = false; - - /** - * A setting that decides whether to close the date picker when the user clicks somewhere else - * on the document. - */ - private boolean autoHide = false; - - /** - * The string to use for the close button label. - */ - private String closeLabel = ""; - - /** - * Construct. - */ - public DatePicker() - { - } - - /** - * {@inheritDoc} - */ - @Override - public void bind(final Component component) - { - this.component = component; - checkComponentProvidesDateFormat(component); - component.setOutputMarkupId(true); - } - - /** - * {@inheritDoc} - */ - @Override - public void afterRender(final Component component) - { - super.afterRender(component); - - // Append the span and img icon right after the rendering of the - // component. Not as pretty as working with a panel etc, but works - // for behaviors and is more efficient - Response response = component.getResponse(); - response.write("\n \"");"); - - if (renderOnLoad()) - { - response.write("
"); - } - response.write("
"); - } - - /** - * Controls whether or not datepicker will contribute YUI libraries to the page as part of its - * rendering lifecycle. - * - * There may be cases when the user wants to use their own version of YUI contribution code, in - * those cases this method should be overridden to return false. - * - * @return a flag whether to contribute YUI libraries to the page. {@code true} by default. - */ - protected boolean includeYUILibraries() - { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public void renderHead(Component component, IHeaderResponse response) - { - super.renderHead(component, response); - - if (includeYUILibraries()) - { - YuiLib.load(response); - } - - renderHeadInit(response); - - // variables for the initialization script - Map variables = new HashMap<>(); - String widgetId = getEscapedComponentMarkupId(); - variables.put("componentId", getComponentMarkupId()); - variables.put("widgetId", widgetId); - variables.put("datePattern", getDatePattern()); - variables.put("fireChangeEvent", notifyComponentOnDateSelected()); - variables.put("alignWithIcon", alignWithIcon()); - variables.put("hideOnSelect", hideOnSelect()); - variables.put("showOnFieldClick", showOnFieldClick()); - variables.put("autoHide", autoHide()); - variables.put("closeLabel", closeLabel()); - - String script = getAdditionalJavaScript(); - if (script != null) - { - variables.put("additionalJavascript", - Strings.replaceAll(script, "${calendar}", "YAHOO.wicket." + widgetId + "DpJs")); - } - - // print out the initialization properties - Map p = new LinkedHashMap<>(); - configure(p, response, variables); - if (!p.containsKey("navigator") && enableMonthYearSelection()) - { - p.put("navigator", Boolean.TRUE); - } - - if (enableMonthYearSelection() && p.containsKey("pages") && - Objects.longValue(p.get("pages")) > 1) - { - throw new IllegalStateException( - "You cannot use a CalendarGroup with month/year selection!"); - } - - // ${calendarInit} - StringBuilder calendarInit = new StringBuilder(); - appendMapping(p, calendarInit); - variables.put("calendarInit", calendarInit.toString()); - - // render initialization script with the variables interpolated - TextTemplate datePickerJs = new PackageTextTemplate(DatePicker.class, "DatePicker.js"); - datePickerJs.interpolate(variables); - response.render(OnDomReadyHeaderItem.forScript(datePickerJs.asString())); - - // remove previously generated markup (see onRendered) via javascript in - // ajax requests to not render the yui calendar multiple times - component.getRequestCycle().find(IPartialPageRequestHandler.class).ifPresent(target -> { - String escapedComponentMarkupId = getEscapedComponentMarkupId(); - String javascript = "var e = Wicket.$('" + escapedComponentMarkupId + "Dp" + - "'); if (e != null && typeof(e.parentNode) != 'undefined' && " + - "typeof(e.parentNode.parentNode != 'undefined')) {" + - "e.parentNode.parentNode.removeChild(e.parentNode);" + "YAHOO.wicket." + - escapedComponentMarkupId + "DpJs.destroy(); delete YAHOO.wicket." + - escapedComponentMarkupId + "DpJs;}"; - - target.prependJavaScript(javascript); - }); - } - - /** - * Renders yui & wicket calendar js module loading. It is done only once per page. - * - * @param response - * header response - */ - protected void renderHeadInit(IHeaderResponse response) - { - String key = "DatePickerInit.js"; - if (response.wasRendered(key)) - { - return; - } - - // variables for YUILoader - Map variables = new HashMap<>(); - variables.put("basePath", - Strings.stripJSessionId(RequestCycle.get().urlFor(YUI, null).toString()) + "/"); - variables.put("Wicket.DateTimeInit.DatePath", RequestCycle.get().urlFor(WICKET_DATE, null)); - - if (Application.get().usesDevelopmentConfig()) - { - variables.put("filter", "filter: \"RAW\","); - variables.put("allowRollup", false); - } - else - { - variables.put("filter", ""); - variables.put("allowRollup", true); - } - - TextTemplate template = new PackageTextTemplate(DatePicker.class, key); - response.render(OnDomReadyHeaderItem.forScript(template.asString(variables))); - - response.markRendered(key); - } - - /** - * Check that this behavior can get a date format out of the component it is coupled to. It - * checks whether {@link #getDatePattern()} produces a non-null value. If that method returns - * null, and exception will be thrown - * - * @param component - * the component this behavior is being coupled to - * @throws UnableToDetermineFormatException - * if this date picker is unable to determine a format. - */ - private void checkComponentProvidesDateFormat(final Component component) - { - if (getDatePattern() == null) - { - throw new UnableToDetermineFormatException(); - } - } - - /** - * Set widget property if the array is null and has a length greater than 0. - * - * @param widgetProperties - * @param key - * @param array - */ - private void setWidgetProperty(final Map widgetProperties, final String key, - final String[] array) - { - if (array != null && array.length > 0) - { - widgetProperties.put(key, array); - } - } - - /** - * Whether to position the date picker relative to the trigger icon. - * - * @return If true, the date picker is aligned with the left position of the icon, and with the - * top right under. If false, the date picker will skip positioning and will let you do - * the positioning yourself. Returns true by default. - */ - protected boolean alignWithIcon() - { - return true; - } - - /** - * Gives overriding classes the option of adding (or even changing/ removing) configuration - * properties for the javascript widget. See the widget's documentation for the - * available options. If you want to override/ remove properties, you should call - * super.configure(properties) first. If you don't call that, be aware that you will have to - * call {@link #localize(java.util.Map, org.apache.wicket.markup.head.IHeaderResponse, java.util.Map)} manually if you like localized strings to be added. - * - * @param widgetProperties - * the current widget properties - * @param response - * the header response - * @param initVariables - * variables passed to the Wicket.DateTime.init() js method - */ - protected void configure(final Map widgetProperties, - final IHeaderResponse response, final Map initVariables) - { - widgetProperties.put("close", true); - - // localize date fields - localize(widgetProperties, response, initVariables); - - Object modelObject = component.getDefaultModelObject(); - // null and cast check - if (modelObject instanceof Date) - { - Date date = (Date)modelObject; - widgetProperties.put("selected", new SimpleDateFormat(FORMAT_DATE).format(date)); - widgetProperties.put("pagedate", new SimpleDateFormat(FORMAT_PAGEDATE).format(date)); - } - } - - /** - * Filter all empty elements (workaround for {@link DateFormatSymbols} returning arrays with - * empty elements). - * - * @param stringArray - * array to filter - * @return filtered array (without null or empty string elements) - */ - protected final String[] filterEmpty(String[] stringArray) - { - if (stringArray == null) - { - return null; - } - - List list = new ArrayList<>(stringArray.length); - for (String string : stringArray) - { - if (!Strings.isEmpty(string)) - { - list.add(string); - } - } - return list.toArray(new String[list.size()]); - } - - /** - * Gets the id of the component that the calendar widget will get attached to. - * - * @return The DOM id of the component - */ - protected final String getComponentMarkupId() - { - return component.getMarkupId(); - } - - /** - * Gets the date pattern to use for putting selected values in the coupled component. - * - * @return The date pattern - */ - protected String getDatePattern() - { - String format = null; - if (component instanceof ITextFormatProvider) - { - format = ((ITextFormatProvider)component).getTextFormat(); - // it is possible that components implement ITextFormatProvider but - // don't provide a format - } - - if (format == null) - { - IConverter converter = component.getConverter(DateTime.class); - if (!(converter instanceof DateConverter)) - { - converter = component.getConverter(Date.class); - } - format = ((SimpleDateFormat)((DateConverter)converter).getDateFormat(component.getLocale())).toPattern(); - } - - return format; - } - - /** - * Gets the escaped DOM id that the calendar widget will get attached to. All non word - * characters (\W) will be removed from the string. - * - * @return The DOM id of the calendar widget - same as the component's markup id + 'Dp'} - */ - protected final String getEscapedComponentMarkupId() - { - return component.getMarkupId().replaceAll("\\W", ""); - } - - /** - * Gets the id of the icon that triggers the popup. - * - * @return The id of the icon - */ - protected final String getIconId() - { - return getEscapedComponentMarkupId() + "Icon"; - } - - /** - * Gets the style of the icon that triggers the popup. - * - * @return The style of the icon, e.g. 'cursor: point' etc. - */ - protected String getIconStyle() - { - return "cursor: pointer; border: none;"; - } - - /** - * Gets the title attribute of the datepicker icon - * - * @return text - */ - protected CharSequence getIconTitle() - { - return ""; - } - - /** - * Gets the icon alt text for the datepicker icon - * - * @return text - */ - protected CharSequence getIconAltText() - { - return ""; - } - - /** - * Gets the url for the popup button. Users can override to provide their own icon URL. - * - * @return the url to use for the popup button/ icon - */ - protected CharSequence getIconUrl() - { - return RequestCycle.get().urlFor( - new ResourceReferenceRequestHandler(new PackageResourceReference(DatePicker.class, - "icon1.gif"))); - } - - /** - * Gets the locale that should be used to configure this widget. - * - * @return By default the locale of the bound component. - */ - protected Locale getLocale() - { - return component.getLocale(); - } - - /** - * Configure the localized strings for the datepicker widget. This implementation uses - * {@link DateFormatSymbols} and some slight string manipulation to get the strings for months - * and week days. Also, the first week day is set according to the {@link Locale} returned by - * {@link #getLocale()}. It should work well for most locales. - *

- * This method is called from {@link #configure(java.util.Map, org.apache.wicket.markup.head.IHeaderResponse, java.util.Map)} and can be overridden if - * you want to customize setting up the localized strings but are happy with the rest of - * {@link #configure(java.util.Map, org.apache.wicket.markup.head.IHeaderResponse, java.util.Map)}'s behavior. Note that you can call (overridable) - * method {@link #getLocale()} to get the locale that should be used for setting up the widget. - *

- *

- * See YUI Calendar's - * German and Japanese examples - * for more info. - *

- * - * @param widgetProperties - * the current widget properties - * @param response - * the header response - * @param initVariables - * variables passed to the Wicket.DateTime.init() js method - */ - protected void localize(Map widgetProperties, IHeaderResponse response, - Map initVariables) - { - Locale locale = getLocale(); - String key = "Wicket.DateTimeInit.CalendarI18n[\"" + locale.toString() + "\"]"; - initVariables.put("i18n", key); - - if (response.wasRendered(key)) - { - return; - } - - DateFormatSymbols dfSymbols = DateFormatSymbols.getInstance(locale); - if (dfSymbols == null) - { - dfSymbols = new DateFormatSymbols(locale); - } - - Map i18nVariables = new LinkedHashMap<>(); - setWidgetProperty(i18nVariables, "MONTHS_SHORT", filterEmpty(dfSymbols.getShortMonths())); - setWidgetProperty(i18nVariables, "MONTHS_LONG", filterEmpty(dfSymbols.getMonths())); - setWidgetProperty(i18nVariables, "WEEKDAYS_MEDIUM", - filterEmpty(dfSymbols.getShortWeekdays())); - setWidgetProperty(i18nVariables, "WEEKDAYS_LONG", filterEmpty(dfSymbols.getWeekdays())); - - i18nVariables.put("START_WEEKDAY", getFirstDayOfWeek(locale)); - - if (Locale.SIMPLIFIED_CHINESE.equals(locale) || Locale.TRADITIONAL_CHINESE.equals(locale)) - { - setWidgetProperty(i18nVariables, "WEEKDAYS_1CHAR", - filterEmpty(substring(dfSymbols.getShortWeekdays(), 2, 1))); - i18nVariables.put("WEEKDAYS_SHORT", - filterEmpty(substring(dfSymbols.getShortWeekdays(), 2, 1))); - } - else - { - setWidgetProperty(i18nVariables, "WEEKDAYS_1CHAR", - filterEmpty(substring(dfSymbols.getShortWeekdays(), 0, 1))); - setWidgetProperty(i18nVariables, "WEEKDAYS_SHORT", - filterEmpty(substring(dfSymbols.getShortWeekdays(), 0, 2))); - } - - StringBuilder i18n = new StringBuilder(key); - i18n.append('='); - appendMapping(i18nVariables, i18n); - i18n.append(';'); - - response.render(OnDomReadyHeaderItem.forScript(i18n.toString())); - - response.wasRendered(key); - } - - /** - * Gets the first day of week of a given locale. - * - * @return By default the first day of week accordingly to Calendar class. - */ - protected int getFirstDayOfWeek(Locale locale) - { - return Calendar.getInstance(locale).getFirstDayOfWeek() - 1; - } - - /** - * Whether to notify the associated component when a date is selected. Notifying is done by - * calling the associated component's onchange JavaScript event handler. You can for instance - * attach an {@link AjaxEventBehavior} to that component to get a call back to the server. The - * default is true. - * - * @return if true, notifies the associated component when a date is selected - */ - protected boolean notifyComponentOnDateSelected() - { - return true; - } - - /** - * Makes a copy of the provided array and for each element copy the substring 0..len to the new - * array - * - * @param array - * array to copy from - * @param len - * size of substring for each element to copy - * @return copy of the array filled with substrings. - */ - protected final String[] substring(final String[] array, final int len) - { - return substring(array, 0, len); - } - - /** - * Makes a copy of the provided array and for each element copy the substring 0..len to the new - * array - * - * @param array - * array to copy from - * @param start - * start position of the substring - * @param len - * size of substring for each element to copy - * @return copy of the array filled with substrings. - */ - protected final String[] substring(final String[] array, final int start, final int len) - { - if (array != null) - { - String[] copy = new String[array.length]; - for (int i = 0; i < array.length; i++) - { - String el = array[i]; - if (el != null) - { - if (el.length() > (start + len)) - { - copy[i] = el.substring(start, start + len); - } - else - { - copy[i] = el; - } - } - } - return copy; - } - return null; - } - - /** - * Indicates whether plain text is rendered or two select boxes are used to allow direct - * selection of month and year. - * - * @return true if select boxes should be rendered to allow month and year - * selection.
- * false to render just plain text. - */ - protected boolean enableMonthYearSelection() - { - return false; - } - - /** - * Indicates whether the calendar should be hidden after a date was selected. - * - * @return true (default) if the calendar should be hidden after the date selection
- * false if the calendar should remain visible after the date selection. - */ - protected boolean hideOnSelect() - { - return true; - } - - /** - * Indicates whether the calendar should be shown when corresponding text input is clicked. - * - * @return true
- * false (default) - */ - protected boolean showOnFieldClick() - { - return showOnFieldClick; - } - - /** - * @param show - * a flag indicating whether to show the picker on click event - * @return {@code this} instance to be able to chain calls - * @see {@link #showOnFieldClick()} - */ - public DatePicker setShowOnFieldClick(boolean show) - { - showOnFieldClick = show; - return this; - } - - - /** - * Indicates whether the calendar should be hidden when the user clicks on an area of the - * document outside of the dialog. - * - * @return true
- * false (default) - */ - protected boolean autoHide() - { - return autoHide; - } - - /** - * @param autoHide - * a flag indicating whether to hide the picker on click event - * @return {@code this} instance to be able to chain calls - * @see {@link #autoHide()} - */ - public DatePicker setAutoHide(boolean autoHide) - { - this.autoHide = autoHide; - return this; - } - - /** - * The string to use for the close button label. - * - * @return label - */ - protected String closeLabel() - { - return closeLabel; - } - - /** - * @param closeLabel - * The string to use for the close button label. - */ - public void setCloseLabel(String closeLabel) - { - this.closeLabel = closeLabel; - } - - /** - * Indicates whether the calendar should be rendered after it has been loaded. - * - * @return true if the calendar should be rendered after it has been loaded.
- * false (default) if it's initially hidden. - */ - protected boolean renderOnLoad() - { - return false; - } - - /** - * Override this method to further customize the YUI Calendar with additional JavaScript code. - * The code returned by this method is executed right after the Calendar has been constructed - * and initialized. To refer to the actual Calendar DOM object, use ${calendar} in - * your code.
- * See the widget's documentation for - * more information about the YUI Calendar.
- * Example: - * - *
-	 * protected String getAdditionalJavaScript()
-	 * {
-	 * 	return "${calendar}.addRenderer(\"10/3\", ${calendar}.renderCellStyleHighlight1);";
-	 * }
-	 * 
- * - * @return a String containing additional JavaScript code - */ - protected String getAdditionalJavaScript() - { - return ""; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isEnabled(final Component component) - { - return component.isEnabledInHierarchy(); - } - - /** - * - * @param map - * the key-value pairs to be serialized - * @param json - * the buffer holding the constructed json - */ - private void appendMapping(final Map map, final StringBuilder json) - { - json.append('{'); - for (Iterator> i = map.entrySet().iterator(); i.hasNext();) - { - Entry entry = i.next(); - json.append(entry.getKey()); - Object value = entry.getValue(); - if (value instanceof CharSequence) - { - json.append(":\""); - json.append(Strings.toEscapedUnicode(value.toString())); - json.append('"'); - } - else if (value instanceof CharSequence[]) - { - json.append(":["); - CharSequence[] valueArray = (CharSequence[])value; - for (int j = 0; j < valueArray.length; j++) - { - CharSequence tmpValue = valueArray[j]; - if (j > 0) - { - json.append(','); - } - if (tmpValue != null) - { - json.append('"'); - json.append(Strings.toEscapedUnicode(tmpValue.toString())); - json.append('"'); - } - } - json.append(']'); - } - else if (value instanceof Map) - { - json.append(':'); - @SuppressWarnings("unchecked") - Map nmap = (Map)value; - appendMapping(nmap, json); - } - else - { - json.append(':'); - json.append(Strings.toEscapedUnicode(String.valueOf(value))); - } - if (i.hasNext()) - { - json.append(','); - } - } - json.append('}'); - } -} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.js b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.js deleted file mode 100644 index e40e0c23d35..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePicker.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -Wicket.DateTimeInit.CalendarAdd(function() { - Wicket.DateTime.init2("${widgetId}", "${componentId}", ${calendarInit}, "${datePattern}", - ${alignWithIcon}, ${fireChangeEvent}, ${hideOnSelect}, ${showOnFieldClick}, ${i18n}, ${autoHide}, "${closeLabel}"); - ${additionalJavascript} -}); 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 deleted file mode 100644 index 61b4056c8eb..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DatePickerInit.js +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -if (typeof(Wicket) === 'undefined') { - window.Wicket = {}; -} -if (typeof(Wicket.DateTimeInit) === 'undefined') { - Wicket.DateTimeInit = {}; -} - -Wicket.DateTimeInit.CalendarInits = []; -Wicket.DateTimeInit.CalendarInitFinished = false; -Wicket.DateTimeInit.CalendarI18n = {}; -Wicket.DateTimeInit.CalendarAdd = function(initFn) { - if (Wicket.DateTimeInit.CalendarInitFinished) { - // when a DatePicker is added via ajax, the loader is already finished, so - // we call the init function directly. - initFn(); - } else { - // when page is rendered, all calendar components will be initialized after - // the required js libraries have been loaded. - Wicket.DateTimeInit.CalendarInits.push(initFn); - } -}; - -Wicket.DateTimeInit.YuiLoader = new YAHOO.util.YUILoader({ - base: "${basePath}", - ${filter} - allowRollup: ${allowRollup}, - require: ["wicket-date"], - onSuccess: function() { - Wicket.DateTimeInit.CalendarInitFinished = true; - while (Wicket.DateTimeInit.CalendarInits.length > 0) { - Wicket.DateTimeInit.CalendarInits.pop()(); - } - } -}); -Wicket.DateTimeInit.YuiLoader.addModule({ - name: "wicket-date", - type: "js", - requires: ["calendar"], - fullpath: "${Wicket.DateTimeInit.DatePath}" -}); -Wicket.DateTimeInit.YuiLoader.insert(); diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java deleted file mode 100644 index ecab7b6b382..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/DateTimeField.java +++ /dev/null @@ -1,616 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.extensions.yui.calendar; - -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - -import org.apache.wicket.Session; -import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; -import org.apache.wicket.core.request.ClientInfo; -import org.apache.wicket.datetime.markup.html.form.DateTextField; -import org.apache.wicket.markup.head.IHeaderResponse; -import org.apache.wicket.markup.html.WebMarkupContainer; -import org.apache.wicket.markup.html.form.DropDownChoice; -import org.apache.wicket.markup.html.form.FormComponentPanel; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.model.IModel; -import org.apache.wicket.model.Model; -import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.protocol.http.request.WebClientInfo; -import org.apache.wicket.util.convert.IConverter; -import org.apache.wicket.util.convert.converter.IntegerConverter; -import org.apache.wicket.validation.validator.RangeValidator; -import org.joda.time.DateTimeFieldType; -import org.joda.time.DateTimeZone; -import org.joda.time.MutableDateTime; -import org.joda.time.format.DateTimeFormat; - -/** - * Works on a {@link java.util.Date} object. Displays a date field and a {@link DatePicker}, a field - * for hours and a field for minutes, and an AM/PM field. The format (12h/24h) of the hours field - * depends on the time format of this {@link DateTimeField}'s {@link Locale}, as does the visibility - * of the AM/PM field (see {@link DateTimeField#use12HourFormat}). - *

- * Ajaxifying the DateTimeField: If you want to update a DateTimeField with an - * {@link AjaxFormComponentUpdatingBehavior}, you have to attach it to the contained - * {@link DateTextField} by overriding {@link #newDateTextField(String, PropertyModel)} and calling - * {@link #processInput()}: - * - *

{@code
- *  DateTimeField dateTimeField = new DateTimeField(...) {
- *    protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel)
- *    {
- *      DateTextField dateField = super.newDateTextField(id, dateFieldModel);     
- *      dateField.add(new AjaxFormComponentUpdatingBehavior("change") {
- *        protected void onUpdate(AjaxRequestTarget target) {
- *          processInput(); // let DateTimeField process input too
- *
- *          ...
- *        }
- *      });
- *      return recorder;
- *    }
- *  }
- * }
- * - * @author eelcohillenius - * @see DateField for a variant with just the date field and date picker - */ -public class DateTimeField extends FormComponentPanel -{ - /** - * Enumerated type for different ways of handling the render part of requests. - */ - public static enum AM_PM { - /** */ - AM("AM"), - - /** */ - PM("PM"); - - /** */ - private String value; - - AM_PM(final String name) - { - value = name; - } - - /** - * @see java.lang.Enum#toString() - */ - @Override - public String toString() - { - return value; - } - } - - private static final long serialVersionUID = 1L; - - // Component-IDs - protected static final String DATE = "date"; - protected static final String HOURS = "hours"; - protected static final String MINUTES = "minutes"; - protected static final String AM_OR_PM_CHOICE = "amOrPmChoice"; - - // PropertyModel string to access getAmOrPm - private static final String AM_OR_PM = "amOrPm"; - - private static final IConverter MINUTES_CONVERTER = new IntegerConverter() { - protected NumberFormat newNumberFormat(Locale locale) { - return new DecimalFormat("00"); - } - }; - - // The dropdown list for AM/PM and it's associated model object - private DropDownChoice amOrPmChoice; - private AM_PM amOrPm = AM_PM.AM; - - // The date TextField and it's associated model object - // Note that any time information in date will be ignored - private DateTextField dateField; - private Date date; - - // The TextField for "hours" and it's associated model object - private TextField hoursField; - private Integer hours; - - // The TextField for "minutes" and it's associated model object - private TextField minutesField; - private Integer minutes; - - /** - * Construct. - * - * @param id - */ - public DateTimeField(final String id) - { - this(id, null); - } - - /** - * Construct. - * - * @param id - * @param model - */ - public DateTimeField(final String id, final IModel model) - { - super(id, model); - - // Sets the type that will be used when updating the model for this component. - setType(Date.class); - - // Create and add the date TextField - PropertyModel dateFieldModel = new PropertyModel<>(this, DATE); - add(dateField = newDateTextField(DATE, dateFieldModel)); - - // Add a date picker to the date TextField - dateField.add(newDatePicker()); - - // Create and add the "hours" TextField - add(hoursField = newHoursTextField(HOURS, new PropertyModel(this, HOURS), - Integer.class)); - - // Create and add the "minutes" TextField - add(minutesField = newMinutesTextField(MINUTES, new PropertyModel(this, MINUTES), - Integer.class)); - - // Create and add the "AM/PM" Listbox - add(amOrPmChoice = new DropDownChoice(AM_OR_PM_CHOICE, new PropertyModel( - this, AM_OR_PM), Arrays.asList(AM_PM.values()))); - - add(new WebMarkupContainer("hoursSeparator") - { - private static final long serialVersionUID = 1L; - - @Override - public boolean isVisible() - { - return minutesField.determineVisibility(); - } - }); - } - - /** - * create a new {@link TextField} instance for hours to be added to this panel. - * - * @param id - * the component id - * @param model - * model that should be used by the {@link TextField} - * @param type - * the type of the text field - * @return a new text field instance - */ - protected TextField newHoursTextField(final String id, IModel model, Class type) { - TextField hoursTextField = new TextField<>(id, model, type); - hoursTextField.add(getMaximumHours() == 24 ? RangeValidator.range(0, 23) : RangeValidator - .range(1, 12)); - hoursTextField.setLabel(new Model<>(HOURS)); - return hoursTextField; - } - - /** - * create a new {@link TextField} instance for minutes to be added to this panel. - * - * @param id - * the component id - * @param model - * model that should be used by the {@link TextField} - * @param type - * the type of the text field - * @return a new text field instance - */ - protected TextField newMinutesTextField(final String id, IModel model, - Class type) - { - TextField minutesField = new TextField(id, model, type) - { - private static final long serialVersionUID = 1L; - - @Override - protected IConverter createConverter(Class type) - { - if (Integer.class.isAssignableFrom(type)) - { - return MINUTES_CONVERTER; - } - return null; - } - }; - minutesField.add(new RangeValidator<>(0, 59)); - minutesField.setLabel(new Model<>(MINUTES)); - return minutesField; - } - - /** - * - * @return The date TextField - */ - protected final DateTextField getDateTextField() - { - return dateField; - } - - /** - * Gets the amOrPm model object of the drop down choice. - * - * @return amOrPm - * - * @deprecated valid during rendering only - */ - public final AM_PM getAmOrPm() - { - return amOrPm; - } - - /** - * Gets the date model object for the date TextField. Any associated time information will be - * ignored. - * - * @return date - * - * @deprecated valid during rendering only - */ - public final Date getDate() - { - return date; - } - - /** - * Gets the hours model object for the TextField - * - * @return hours - * - * @deprecated valid during rendering only - */ - public final Integer getHours() - { - return hours; - } - - /** - * Gets the minutes model object for the TextField - * - * @return minutes - * - * @deprecated valid during rendering only - */ - public final Integer getMinutes() - { - return minutes; - } - - /** - * Gives overriding classes the option of adding (or even changing/ removing) configuration - * properties for the javascript widget. See the widget's documentation for the - * available options. If you want to override/ remove properties, you should call - * super.configure(properties) first. If you don't call that, be aware that you will have to - * call {@link #configure(java.util.Map)} manually if you like localized strings to be added. - * - * @param widgetProperties - * the current widget properties - */ - protected void configure(Map widgetProperties) - { - } - - @Override - public String getInput() - { - // since we override convertInput, we can let this method return a value - // that is just suitable for error reporting - return dateField.getInput() + ", " + hoursField.getInput() + ":" + minutesField.getInput(); - } - - /** - * Sets the amOrPm model object associated with the drop down choice. - * - * @param amOrPm - * amOrPm - */ - public final void setAmOrPm(final AM_PM amOrPm) - { - this.amOrPm = amOrPm; - } - - /** - * Sets the date model object associated with the date TextField. It does not affect hours or - * minutes. - * - * @param date - * date - */ - public final void setDate(final Date date) - { - this.date = date; - } - - /** - * Sets hours. - * - * @param hours - * hours - */ - public final void setHours(final Integer hours) - { - this.hours = hours; - } - - /** - * Sets minutes. - * - * @param minutes - * minutes - */ - public final void setMinutes(final Integer minutes) - { - this.minutes = minutes; - } - - /** - * Gets the client's time zone. - * - * @return The client's time zone or null - */ - protected TimeZone getClientTimeZone() - { - ClientInfo info = Session.get().getClientInfo(); - if (info instanceof WebClientInfo) - { - return ((WebClientInfo)info).getProperties().getTimeZone(); - } - return null; - } - - /** - * Sets the converted input, which is an instance of {@link Date}, possibly null. It combines - * the inputs of the nested date, hours, minutes and am/pm fields and constructs a date from it. - *

- * Note that overriding this method is a better option than overriding {@link #updateModel()} - * like the first versions of this class did. The reason for that is that this method can be - * used by form validators without having to depend on the actual model being updated, and this - * method is called by the default implementation of {@link #updateModel()} anyway (so we don't - * have to override that anymore). - */ - @Override - public void convertInput() - { - try - { - // Get the converted input values - Date dateFieldInput = dateField.getConvertedInput(); - Integer hoursInput = hoursField.getConvertedInput(); - Integer minutesInput = minutesField.getConvertedInput(); - AM_PM amOrPmInput = amOrPmChoice.getConvertedInput(); - - if (dateFieldInput == null) - { - return; - } - - // Get year, month and day ignoring any timezone of the Date object - Calendar cal = Calendar.getInstance(); - cal.setTime(dateFieldInput); - int year = cal.get(Calendar.YEAR); - int month = cal.get(Calendar.MONTH) + 1; - int day = cal.get(Calendar.DAY_OF_MONTH); - int hours = (hoursInput == null ? 0 : hoursInput % 24); - int minutes = (minutesInput == null ? 0 : minutesInput); - - // Use the input to create a date object with proper timezone - MutableDateTime date = new MutableDateTime(year, month, day, hours, minutes, 0, 0, - DateTimeZone.forTimeZone(getClientTimeZone())); - - // Adjust for halfday if needed - if (use12HourFormat()) - { - int halfday = (amOrPmInput == AM_PM.PM ? 1 : 0); - date.set(DateTimeFieldType.halfdayOfDay(), halfday); - date.set(DateTimeFieldType.hourOfHalfday(), hours % 12); - } - - // The date will be in the server's timezone - setConvertedInput(newDateInstance(date.getMillis())); - } - catch (RuntimeException e) - { - DateTimeField.this.error(e.getMessage()); - invalid(); - } - } - - /** - * A factory method for the DateTextField's model object. - * - * @return any specialization of java.util.Date - */ - protected Date newDateInstance() - { - return new Date(); - } - - /** - * A factory method for the DateTextField's model object. - * - * @param time - * the time in milliseconds - * @return any specialization of java.util.Date - */ - protected Date newDateInstance(long time) - { - return new Date(time); - } - - /** - * create a new {@link DateTextField} instance to be added to this panel. - * - * @param id - * the component id - * @param dateFieldModel - * model that should be used by the {@link DateTextField} - * @return a new date text field instance - */ - protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel) - { - return DateTextField.forShortStyle(id, dateFieldModel, false); - } - - /** - * @see org.apache.wicket.Component#onBeforeRender() - */ - @Override - protected void onBeforeRender() - { - dateField.setRequired(isRequired()); - hoursField.setRequired(isRequired()); - minutesField.setRequired(isRequired()); - - boolean use12HourFormat = use12HourFormat(); - amOrPmChoice.setVisible(use12HourFormat); - - Date modelObject = (Date)getDefaultModelObject(); - if (modelObject == null) - { - date = null; - hours = null; - minutes = null; - } - else - { - MutableDateTime mDate = new MutableDateTime(modelObject); - // convert date to the client's time zone if we have that info - TimeZone zone = getClientTimeZone(); - if (zone != null) - { - mDate.setZone(DateTimeZone.forTimeZone(zone)); - } - - date = mDate.toDateTime().toLocalDate().toDate(); - - if (use12HourFormat) - { - int hourOfHalfDay = mDate.get(DateTimeFieldType.hourOfHalfday()); - hours = hourOfHalfDay == 0 ? 12 : hourOfHalfDay; - } - else - { - hours = mDate.get(DateTimeFieldType.hourOfDay()); - } - - amOrPm = (mDate.get(DateTimeFieldType.halfdayOfDay()) == 0) ? AM_PM.AM : AM_PM.PM; - minutes = mDate.getMinuteOfHour(); - } - - super.onBeforeRender(); - } - - /** - * Change a date in another timezone - * - * @param date - * The input date. - * @param zone - * The target timezone. - * @return A new converted date. - */ - public static Date changeTimeZone(Date date, TimeZone zone) - { - Calendar first = Calendar.getInstance(zone); - first.setTimeInMillis(date.getTime()); - - Calendar output = Calendar.getInstance(); - output.set(Calendar.YEAR, first.get(Calendar.YEAR)); - output.set(Calendar.MONTH, first.get(Calendar.MONTH)); - output.set(Calendar.DAY_OF_MONTH, first.get(Calendar.DAY_OF_MONTH)); - output.set(Calendar.HOUR_OF_DAY, first.get(Calendar.HOUR_OF_DAY)); - output.set(Calendar.MINUTE, first.get(Calendar.MINUTE)); - output.set(Calendar.SECOND, first.get(Calendar.SECOND)); - output.set(Calendar.MILLISECOND, first.get(Calendar.MILLISECOND)); - - return output.getTime(); - } - - /** - * Checks whether the current {@link Locale} uses the 12h or 24h time format. This method can be - * overridden to e.g. always use 24h format. - * - * @return true, if the current {@link Locale} uses the 12h format.
- * false, otherwise - */ - protected boolean use12HourFormat() - { - String pattern = DateTimeFormat.patternForStyle("-S", getLocale()); - return pattern.indexOf('a') != -1 || pattern.indexOf('h') != -1 - || pattern.indexOf('K') != -1; - } - - /** - * @return either 12 or 24, depending on the hour format of the current {@link Locale} - */ - private int getMaximumHours() - { - return getMaximumHours(use12HourFormat()); - } - - /** - * Convenience method (mainly for optimization purposes), in case {@link #use12HourFormat()} has - * already been stored in a local variable and thus doesn't need to be computed again. - * - * @param use12HourFormat - * the hour format to use - * @return either 12 or 24, depending on the parameter use12HourFormat - */ - private int getMaximumHours(boolean use12HourFormat) - { - return use12HourFormat ? 12 : 24; - } - - /** - * The DatePicker that gets added to the DateTimeField component. Users may override this method - * with a DatePicker of their choice. - * - * @return a new {@link DatePicker} instance - */ - protected DatePicker newDatePicker() - { - return new DatePicker() - { - private static final long serialVersionUID = 1L; - - @Override - protected void configure(final Map widgetProperties, - final IHeaderResponse response, final Map initVariables) - { - super.configure(widgetProperties, response, initVariables); - - DateTimeField.this.configure(widgetProperties); - } - }; - } -} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/TimeField.java b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/TimeField.java deleted file mode 100644 index 3d98b31fd23..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/TimeField.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.extensions.yui.calendar; - -import java.util.Date; -import java.util.Locale; - -import org.apache.wicket.model.IModel; - -/** - * Works on a {@link java.util.Date} object. Displays a field for hours and a field for minutes, and - * an AM/PM field. The format (12h/24h) of the hours field depends on the time format of this - * {@link TimeField}'s {@link Locale}, as does the visibility of the AM/PM field (see - * {@link TimeField#use12HourFormat}). - * - * @author eelcohillenius - * @see DateField for a variant with just the date field and date picker - */ -public class TimeField extends DateTimeField -{ - private static final long serialVersionUID = 1L; - - /** - * Construct. - * - * @param id - * the component id - */ - public TimeField(String id) - { - this(id, null); - } - - /** - * Construct. - * - * @param id - * the component id - * @param model - * the component's model - */ - public TimeField(String id, IModel model) - { - super(id, model); - - getDateTextField().setVisibilityAllowed(false); - } - - @Override - public void convertInput() - { - Date modelObject = (Date)getDefaultModelObject(); - getDateTextField().setConvertedInput(modelObject != null ? modelObject : newDateInstance()); - super.convertInput(); - } - -} \ No newline at end of file diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/assets/skins/sam/calendar.css b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/assets/skins/sam/calendar.css deleted file mode 100644 index 3e932f4d977..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/assets/skins/sam/calendar.css +++ /dev/null @@ -1,8 +0,0 @@ -/* -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -.yui-calcontainer{position:relative;float:left;_overflow:hidden}.yui-calcontainer iframe{position:absolute;border:0;margin:0;padding:0;z-index:0;width:100%;height:100%;left:0;top:0}.yui-calcontainer iframe.fixedsize{width:50em;height:50em;top:-1px;left:-1px}.yui-calcontainer.multi .groupcal{z-index:1;float:left;position:relative}.yui-calcontainer .title{position:relative;z-index:1}.yui-calcontainer .close-icon{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden}.yui-calendar{position:relative}.yui-calendar .calnavleft{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden}.yui-calendar .calnavright{position:absolute;z-index:1;text-indent:-10000em;overflow:hidden}.yui-calendar .calheader{position:relative;width:100%;text-align:center}.yui-calcontainer .yui-cal-nav-mask{position:absolute;z-index:2;margin:0;padding:0;width:100%;height:100%;_width:0;_height:0;left:0;top:0;display:none}.yui-calcontainer .yui-cal-nav{position:absolute;z-index:3;top:0;display:none}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{display:-moz-inline-box;display:inline-block}.yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{display:block;*display:inline-block;*overflow:visible;border:0;background-color:transparent;cursor:pointer}.yui-calendar .calbody a:hover{background:inherit}p#clear{clear:left;padding-top:10px}.yui-skin-sam .yui-calcontainer{background-color:#f2f2f2;border:1px solid #808080;padding:10px}.yui-skin-sam .yui-calcontainer.multi{padding:0 5px 0 5px}.yui-skin-sam .yui-calcontainer.multi .groupcal{background-color:transparent;border:0;padding:10px 5px 10px 5px;margin:0}.yui-skin-sam .yui-calcontainer .title{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-bottom:1px solid #ccc;font:100% sans-serif;color:#000;font-weight:bold;height:auto;padding:.4em;margin:0 -10px 10px -10px;top:0;left:0;text-align:left}.yui-skin-sam .yui-calcontainer.multi .title{margin:0 -5px 0 -5px}.yui-skin-sam .yui-calcontainer.withtitle{padding-top:0}.yui-skin-sam .yui-calcontainer .calclose{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -300px;width:25px;height:15px;top:.4em;right:.4em;cursor:pointer}.yui-skin-sam .yui-calendar{border-spacing:0;border-collapse:collapse;font:100% sans-serif;text-align:center;margin:0}.yui-skin-sam .yui-calendar .calhead{background:transparent;border:0;vertical-align:middle;padding:0}.yui-skin-sam .yui-calendar .calheader{background:transparent;font-weight:bold;padding:0 0 .6em 0;text-align:center}.yui-skin-sam .yui-calendar .calheader img{border:0}.yui-skin-sam .yui-calendar .calnavleft{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -450px;width:25px;height:15px;top:0;bottom:0;left:-10px;margin-left:.4em;cursor:pointer}.yui-skin-sam .yui-calendar .calnavright{background:url(../../../../assets/skins/sam/sprite.png) no-repeat 0 -500px;width:25px;height:15px;top:0;bottom:0;right:-10px;margin-right:.4em;cursor:pointer}.yui-skin-sam .yui-calendar .calweekdayrow{height:2em}.yui-skin-sam .yui-calendar .calweekdayrow th{padding:0;border:0}.yui-skin-sam .yui-calendar .calweekdaycell{color:#000;font-weight:bold;text-align:center;width:2em}.yui-skin-sam .yui-calendar .calfoot{background-color:#f2f2f2}.yui-skin-sam .yui-calendar .calrowhead,.yui-skin-sam .yui-calendar .calrowfoot{color:#a6a6a6;font-size:85%;font-style:normal;font-weight:normal;border:0}.yui-skin-sam .yui-calendar .calrowhead{text-align:right;padding:0 2px 0 0}.yui-skin-sam .yui-calendar .calrowfoot{text-align:left;padding:0 0 0 2px}.yui-skin-sam .yui-calendar td.calcell{border:1px solid #ccc;background:#fff;padding:1px;height:1.6em;line-height:1.6em;text-align:center;white-space:nowrap}.yui-skin-sam .yui-calendar td.calcell a{color:#06c;display:block;height:100%;text-decoration:none}.yui-skin-sam .yui-calendar td.calcell.today{background-color:#000}.yui-skin-sam .yui-calendar td.calcell.today a{background-color:#fff}.yui-skin-sam .yui-calendar td.calcell.oom{background-color:#ccc;color:#a6a6a6;cursor:default}.yui-skin-sam .yui-calendar td.calcell.oom a{color:#a6a6a6}.yui-skin-sam .yui-calendar td.calcell.selected{background-color:#fff;color:#000}.yui-skin-sam .yui-calendar td.calcell.selected a{background-color:#b3d4ff;color:#000}.yui-skin-sam .yui-calendar td.calcell.calcellhover{background-color:#426fd9;color:#fff;cursor:pointer}.yui-skin-sam .yui-calendar td.calcell.calcellhover a{background-color:#426fd9;color:#fff}.yui-skin-sam .yui-calendar td.calcell.previous{color:#e0e0e0}.yui-skin-sam .yui-calendar td.calcell.restricted{text-decoration:line-through}.yui-skin-sam .yui-calendar td.calcell.highlight1{background-color:#cf9}.yui-skin-sam .yui-calendar td.calcell.highlight2{background-color:#9cf}.yui-skin-sam .yui-calendar td.calcell.highlight3{background-color:#fcc}.yui-skin-sam .yui-calendar td.calcell.highlight4{background-color:#cf9}.yui-skin-sam .yui-calendar a.calnav{border:1px solid #f2f2f2;padding:0 4px;text-decoration:none;color:#000;zoom:1}.yui-skin-sam .yui-calendar a.calnav:hover{background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;border-color:#a0a0a0;cursor:pointer}.yui-skin-sam .yui-calcontainer .yui-cal-nav-mask{background-color:#000;opacity:.25;filter:alpha(opacity=25)}.yui-skin-sam .yui-calcontainer .yui-cal-nav{font-family:arial,helvetica,clean,sans-serif;font-size:93%;border:1px solid #808080;left:50%;margin-left:-7em;width:14em;padding:0;top:2.5em;background-color:#f2f2f2}.yui-skin-sam .yui-calcontainer.withtitle .yui-cal-nav{top:4.5em}.yui-skin-sam .yui-calcontainer.multi .yui-cal-nav{width:16em;margin-left:-8em}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y,.yui-skin-sam .yui-calcontainer .yui-cal-nav-m,.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{padding:5px 10px 5px 10px}.yui-skin-sam .yui-calcontainer .yui-cal-nav-b{text-align:center}.yui-skin-sam .yui-calcontainer .yui-cal-nav-e{margin-top:5px;padding:5px;background-color:#edf5ff;border-top:1px solid black;display:none}.yui-skin-sam .yui-calcontainer .yui-cal-nav label{display:block;font-weight:bold} -.yui-skin-sam .yui-calcontainer .yui-cal-nav-mc{width:100%;_width:auto}.yui-skin-sam .yui-calcontainer .yui-cal-nav-y input.yui-invalid{background-color:#ffee69;border:1px solid #000}.yui-skin-sam .yui-calcontainer .yui-cal-nav-yc{width:4em}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn{border:1px solid #808080;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 0;background-color:#ccc;margin:auto .15em}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn button{padding:0 8px;font-size:93%;line-height:2;*line-height:1.7;min-height:2em;*min-height:auto;color:#000}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default{border:1px solid #304369;background-color:#426fd9;background:url(../../../../assets/skins/sam/sprite.png) repeat-x 0 -1400px}.yui-skin-sam .yui-calcontainer .yui-cal-nav .yui-cal-nav-btn.yui-default button{color:#fff} diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/calendar-min.js b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/calendar-min.js deleted file mode 100644 index 223cdcfa22b..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/calendar-min.js +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -(function(){YAHOO.util.Config=function(d){if(d){this.init(d);}};var b=YAHOO.lang,c=YAHOO.util.CustomEvent,a=YAHOO.util.Config;a.CONFIG_CHANGED_EVENT="configChanged";a.BOOLEAN_TYPE="boolean";a.prototype={owner:null,queueInProgress:false,config:null,initialConfig:null,eventQueue:null,configChangedEvent:null,init:function(d){this.owner=d;this.configChangedEvent=this.createEvent(a.CONFIG_CHANGED_EVENT);this.configChangedEvent.signature=c.LIST;this.queueInProgress=false;this.config={};this.initialConfig={};this.eventQueue=[];},checkBoolean:function(d){return(typeof d==a.BOOLEAN_TYPE);},checkNumber:function(d){return(!isNaN(d));},fireEvent:function(d,f){var e=this.config[d];if(e&&e.event){e.event.fire(f);}},addProperty:function(e,d){e=e.toLowerCase();this.config[e]=d;d.event=this.createEvent(e,{scope:this.owner});d.event.signature=c.LIST;d.key=e;if(d.handler){d.event.subscribe(d.handler,this.owner);}this.setProperty(e,d.value,true);if(!d.suppressEvent){this.queueProperty(e,d.value);}},getConfig:function(){var d={},f=this.config,g,e;for(g in f){if(b.hasOwnProperty(f,g)){e=f[g];if(e&&e.event){d[g]=e.value;}}}return d;},getProperty:function(d){var e=this.config[d.toLowerCase()];if(e&&e.event){return e.value;}else{return undefined;}},resetProperty:function(d){d=d.toLowerCase();var e=this.config[d];if(e&&e.event){if(d in this.initialConfig){this.setProperty(d,this.initialConfig[d]);return true;}}else{return false;}},setProperty:function(e,g,d){var f;e=e.toLowerCase();if(this.queueInProgress&&!d){this.queueProperty(e,g);return true;}else{f=this.config[e];if(f&&f.event){if(f.validator&&!f.validator(g)){return false;}else{f.value=g;if(!d){this.fireEvent(e,g);this.configChangedEvent.fire([e,g]);}return true;}}else{return false;}}},queueProperty:function(v,r){v=v.toLowerCase();var u=this.config[v],l=false,k,g,h,j,p,t,f,n,o,d,m,w,e;if(u&&u.event){if(!b.isUndefined(r)&&u.validator&&!u.validator(r)){return false;}else{if(!b.isUndefined(r)){u.value=r;}else{r=u.value;}l=false;k=this.eventQueue.length;for(m=0;m0){g=f-1;do{d=e.subscribers[g];if(d&&d.obj==j&&d.fn==h){return true;}}while(g--);}return false;};YAHOO.lang.augmentProto(a,YAHOO.util.EventProvider);}());YAHOO.widget.DateMath={DAY:"D",WEEK:"W",YEAR:"Y",MONTH:"M",ONE_DAY_MS:1000*60*60*24,WEEK_ONE_JAN_DATE:1,add:function(a,e,c){var g=new Date(a.getTime());switch(e){case this.MONTH:var f=a.getMonth()+c;var b=0;if(f<0){while(f<0){f+=12;b-=1;}}else{if(f>11){while(f>11){f-=12;b+=1;}}}g.setMonth(f);g.setFullYear(a.getFullYear()+b);break;case this.DAY:this._addDays(g,c);break;case this.YEAR:g.setFullYear(a.getFullYear()+c);break;case this.WEEK:this._addDays(g,(c*7));break;}return g;},_addDays:function(e,c){if(YAHOO.env.ua.webkit&&YAHOO.env.ua.webkit<420){if(c<0){for(var b=-128;ca;c-=a){e.setDate(e.getDate()+a);}}}e.setDate(e.getDate()+c);},subtract:function(a,c,b){return this.add(a,c,(b*-1));},before:function(c,b){var a=b.getTime();if(c.getTime()a){return true;}else{return false;}},between:function(b,a,c){if(this.after(b,a)&&this.before(b,c)){return true;}else{return false;}},getJan1:function(a){return this.getDate(a,0,1);},getDayOffset:function(b,d){var c=this.getJan1(d);var a=Math.ceil((b.getTime()-c.getTime())/this.ONE_DAY_MS);return a;},getWeekNumber:function(d,b,g){b=b||0;g=g||this.WEEK_ONE_JAN_DATE;var h=this.clearTime(d),l,m;if(h.getDay()===b){l=h;}else{l=this.getFirstDayOfWeek(h,b);}var i=l.getFullYear();m=new Date(l.getTime()+6*this.ONE_DAY_MS);var f;if(i!==m.getFullYear()&&m.getDate()>=g){f=1;}else{var e=this.clearTime(this.getDate(i,0,g)),a=this.getFirstDayOfWeek(e,b);var j=Math.round((h.getTime()-a.getTime())/this.ONE_DAY_MS);var k=j%7;var c=(j-k)/7;f=c+1;}return f;},getFirstDayOfWeek:function(d,a){a=a||0; -var b=d.getDay(),c=(b-a+7)%7;return this.subtract(d,this.DAY,c);},isYearOverlapWeek:function(a){var c=false;var b=this.add(a,this.DAY,6);if(b.getFullYear()!=a.getFullYear()){c=true;}return c;},isMonthOverlapWeek:function(a){var c=false;var b=this.add(a,this.DAY,6);if(b.getMonth()!=a.getMonth()){c=true;}return c;},findMonthStart:function(a){var b=this.getDate(a.getFullYear(),a.getMonth(),1);return b;},findMonthEnd:function(b){var d=this.findMonthStart(b);var c=this.add(d,this.MONTH,1);var a=this.subtract(c,this.DAY,1);return a;},clearTime:function(a){a.setHours(12,0,0,0);return a;},getDate:function(e,a,c){var b=null;if(YAHOO.lang.isUndefined(c)){c=1;}if(e>=100){b=new Date(e,a,c);}else{b=new Date();b.setFullYear(e);b.setMonth(a);b.setDate(c);b.setHours(0,0,0,0);}return b;}};(function(){var c=YAHOO.util.Dom,a=YAHOO.util.Event,e=YAHOO.lang,d=YAHOO.widget.DateMath;function f(i,g,h){this.init.apply(this,arguments);}f.IMG_ROOT=null;f.DATE="D";f.MONTH_DAY="MD";f.WEEKDAY="WD";f.RANGE="R";f.MONTH="M";f.DISPLAY_DAYS=42;f.STOP_RENDER="S";f.SHORT="short";f.LONG="long";f.MEDIUM="medium";f.ONE_CHAR="1char";f.DEFAULT_CONFIG={YEAR_OFFSET:{key:"year_offset",value:0,supercedes:["pagedate","selected","mindate","maxdate"]},TODAY:{key:"today",value:new Date(),supercedes:["pagedate"]},PAGEDATE:{key:"pagedate",value:null},SELECTED:{key:"selected",value:[]},TITLE:{key:"title",value:""},CLOSE:{key:"close",value:false},IFRAME:{key:"iframe",value:(YAHOO.env.ua.ie&&YAHOO.env.ua.ie<=6)?true:false},MINDATE:{key:"mindate",value:null},MAXDATE:{key:"maxdate",value:null},MULTI_SELECT:{key:"multi_select",value:false},OOM_SELECT:{key:"oom_select",value:false},START_WEEKDAY:{key:"start_weekday",value:0},SHOW_WEEKDAYS:{key:"show_weekdays",value:true},SHOW_WEEK_HEADER:{key:"show_week_header",value:false},SHOW_WEEK_FOOTER:{key:"show_week_footer",value:false},HIDE_BLANK_WEEKS:{key:"hide_blank_weeks",value:false},NAV_ARROW_LEFT:{key:"nav_arrow_left",value:null},NAV_ARROW_RIGHT:{key:"nav_arrow_right",value:null},MONTHS_SHORT:{key:"months_short",value:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},MONTHS_LONG:{key:"months_long",value:["January","February","March","April","May","June","July","August","September","October","November","December"]},WEEKDAYS_1CHAR:{key:"weekdays_1char",value:["S","M","T","W","T","F","S"]},WEEKDAYS_SHORT:{key:"weekdays_short",value:["Su","Mo","Tu","We","Th","Fr","Sa"]},WEEKDAYS_MEDIUM:{key:"weekdays_medium",value:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},WEEKDAYS_LONG:{key:"weekdays_long",value:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},LOCALE_MONTHS:{key:"locale_months",value:"long"},LOCALE_WEEKDAYS:{key:"locale_weekdays",value:"short"},DATE_DELIMITER:{key:"date_delimiter",value:","},DATE_FIELD_DELIMITER:{key:"date_field_delimiter",value:"/"},DATE_RANGE_DELIMITER:{key:"date_range_delimiter",value:"-"},MY_MONTH_POSITION:{key:"my_month_position",value:1},MY_YEAR_POSITION:{key:"my_year_position",value:2},MD_MONTH_POSITION:{key:"md_month_position",value:1},MD_DAY_POSITION:{key:"md_day_position",value:2},MDY_MONTH_POSITION:{key:"mdy_month_position",value:1},MDY_DAY_POSITION:{key:"mdy_day_position",value:2},MDY_YEAR_POSITION:{key:"mdy_year_position",value:3},MY_LABEL_MONTH_POSITION:{key:"my_label_month_position",value:1},MY_LABEL_YEAR_POSITION:{key:"my_label_year_position",value:2},MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix",value:" "},MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix",value:""},NAV:{key:"navigator",value:null},STRINGS:{key:"strings",value:{previousMonth:"Previous Month",nextMonth:"Next Month",close:"Close"},supercedes:["close","title"]}};f._DEFAULT_CONFIG=f.DEFAULT_CONFIG;var b=f.DEFAULT_CONFIG;f._EVENT_TYPES={BEFORE_SELECT:"beforeSelect",SELECT:"select",BEFORE_DESELECT:"beforeDeselect",DESELECT:"deselect",CHANGE_PAGE:"changePage",BEFORE_RENDER:"beforeRender",RENDER:"render",BEFORE_DESTROY:"beforeDestroy",DESTROY:"destroy",RESET:"reset",CLEAR:"clear",BEFORE_HIDE:"beforeHide",HIDE:"hide",BEFORE_SHOW:"beforeShow",SHOW:"show",BEFORE_HIDE_NAV:"beforeHideNav",HIDE_NAV:"hideNav",BEFORE_SHOW_NAV:"beforeShowNav",SHOW_NAV:"showNav",BEFORE_RENDER_NAV:"beforeRenderNav",RENDER_NAV:"renderNav"};f.STYLES={CSS_ROW_HEADER:"calrowhead",CSS_ROW_FOOTER:"calrowfoot",CSS_CELL:"calcell",CSS_CELL_SELECTOR:"selector",CSS_CELL_SELECTED:"selected",CSS_CELL_SELECTABLE:"selectable",CSS_CELL_RESTRICTED:"restricted",CSS_CELL_TODAY:"today",CSS_CELL_OOM:"oom",CSS_CELL_OOB:"previous",CSS_HEADER:"calheader",CSS_HEADER_TEXT:"calhead",CSS_BODY:"calbody",CSS_WEEKDAY_CELL:"calweekdaycell",CSS_WEEKDAY_ROW:"calweekdayrow",CSS_FOOTER:"calfoot",CSS_CALENDAR:"yui-calendar",CSS_SINGLE:"single",CSS_CONTAINER:"yui-calcontainer",CSS_NAV_LEFT:"calnavleft",CSS_NAV_RIGHT:"calnavright",CSS_NAV:"calnav",CSS_CLOSE:"calclose",CSS_CELL_TOP:"calcelltop",CSS_CELL_LEFT:"calcellleft",CSS_CELL_RIGHT:"calcellright",CSS_CELL_BOTTOM:"calcellbottom",CSS_CELL_HOVER:"calcellhover",CSS_CELL_HIGHLIGHT1:"highlight1",CSS_CELL_HIGHLIGHT2:"highlight2",CSS_CELL_HIGHLIGHT3:"highlight3",CSS_CELL_HIGHLIGHT4:"highlight4",CSS_WITH_TITLE:"withtitle",CSS_FIXED_SIZE:"fixedsize",CSS_LINK_CLOSE:"link-close"};f._STYLES=f.STYLES;f.prototype={Config:null,parent:null,index:-1,cells:null,cellDates:null,id:null,containerId:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,oNavigator:null,_selectedDates:null,domEventMap:null,_parseArgs:function(h){var g={id:null,container:null,config:null};if(h&&h.length&&h.length>0){switch(h.length){case 1:g.id=null;g.container=h[0];g.config=null;break;case 2:if(e.isObject(h[1])&&!h[1].tagName&&!(h[1] instanceof String)){g.id=null;g.container=h[0];g.config=h[1];}else{g.id=h[0];g.container=h[1];g.config=null;}break;default:g.id=h[0];g.container=h[1];g.config=h[2];break;}}else{}return g;},init:function(j,h,i){var g=this._parseArgs(arguments);j=g.id;h=g.container;i=g.config;this.oDomContainer=c.get(h);this._oDoc=this.oDomContainer.ownerDocument;if(!this.oDomContainer.id){this.oDomContainer.id=c.generateId(); -}if(!j){j=this.oDomContainer.id+"_t";}this.id=j;this.containerId=this.oDomContainer.id;this.initEvents();this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.initStyles();c.addClass(this.oDomContainer,this.Style.CSS_CONTAINER);c.addClass(this.oDomContainer,this.Style.CSS_SINGLE);this.cellDates=[];this.cells=[];this.renderStack=[];this._renderStack=[];this.setupConfig();if(i){this.cfg.applyConfig(i,true);}this.cfg.fireQueue();this.today=this.cfg.getProperty("today");},configIframe:function(i,h,j){var g=h[0];if(!this.parent){if(c.inDocument(this.oDomContainer)){if(g){var k=c.getStyle(this.oDomContainer,"position");if(k=="absolute"||k=="relative"){if(!c.inDocument(this.iframe)){this.iframe=document.createElement("iframe");this.iframe.src="javascript:false;";c.setStyle(this.iframe,"opacity","0");if(YAHOO.env.ua.ie&&YAHOO.env.ua.ie<=6){c.addClass(this.iframe,this.Style.CSS_FIXED_SIZE);}this.oDomContainer.insertBefore(this.iframe,this.oDomContainer.firstChild);}}}else{if(this.iframe){if(this.iframe.parentNode){this.iframe.parentNode.removeChild(this.iframe);}this.iframe=null;}}}}},configTitle:function(h,g,i){var k=g[0];if(k){this.createTitleBar(k);}else{var j=this.cfg.getProperty(b.CLOSE.key);if(!j){this.removeTitleBar();}else{this.createTitleBar(" ");}}},configClose:function(h,g,i){var k=g[0],j=this.cfg.getProperty(b.TITLE.key);if(k){if(!j){this.createTitleBar(" ");}this.createCloseButton();}else{this.removeCloseButton();if(!j){this.removeTitleBar();}}},initEvents:function(){var g=f._EVENT_TYPES,i=YAHOO.util.CustomEvent,h=this;h.beforeSelectEvent=new i(g.BEFORE_SELECT);h.selectEvent=new i(g.SELECT);h.beforeDeselectEvent=new i(g.BEFORE_DESELECT);h.deselectEvent=new i(g.DESELECT);h.changePageEvent=new i(g.CHANGE_PAGE);h.beforeRenderEvent=new i(g.BEFORE_RENDER);h.renderEvent=new i(g.RENDER);h.beforeDestroyEvent=new i(g.BEFORE_DESTROY);h.destroyEvent=new i(g.DESTROY);h.resetEvent=new i(g.RESET);h.clearEvent=new i(g.CLEAR);h.beforeShowEvent=new i(g.BEFORE_SHOW);h.showEvent=new i(g.SHOW);h.beforeHideEvent=new i(g.BEFORE_HIDE);h.hideEvent=new i(g.HIDE);h.beforeShowNavEvent=new i(g.BEFORE_SHOW_NAV);h.showNavEvent=new i(g.SHOW_NAV);h.beforeHideNavEvent=new i(g.BEFORE_HIDE_NAV);h.hideNavEvent=new i(g.HIDE_NAV);h.beforeRenderNavEvent=new i(g.BEFORE_RENDER_NAV);h.renderNavEvent=new i(g.RENDER_NAV);h.beforeSelectEvent.subscribe(h.onBeforeSelect,this,true);h.selectEvent.subscribe(h.onSelect,this,true);h.beforeDeselectEvent.subscribe(h.onBeforeDeselect,this,true);h.deselectEvent.subscribe(h.onDeselect,this,true);h.changePageEvent.subscribe(h.onChangePage,this,true);h.renderEvent.subscribe(h.onRender,this,true);h.resetEvent.subscribe(h.onReset,this,true);h.clearEvent.subscribe(h.onClear,this,true);},doPreviousMonthNav:function(h,g){a.preventDefault(h);setTimeout(function(){g.previousMonth();var j=c.getElementsByClassName(g.Style.CSS_NAV_LEFT,"a",g.oDomContainer);if(j&&j[0]){try{j[0].focus();}catch(i){}}},0);},doNextMonthNav:function(h,g){a.preventDefault(h);setTimeout(function(){g.nextMonth();var j=c.getElementsByClassName(g.Style.CSS_NAV_RIGHT,"a",g.oDomContainer);if(j&&j[0]){try{j[0].focus();}catch(i){}}},0);},doSelectCell:function(m,g){var r,o,i,l;var n=a.getTarget(m),h=n.tagName.toLowerCase(),k=false;while(h!="td"&&!c.hasClass(n,g.Style.CSS_CELL_SELECTABLE)){if(!k&&h=="a"&&c.hasClass(n,g.Style.CSS_CELL_SELECTOR)){k=true;}n=n.parentNode;h=n.tagName.toLowerCase();if(n==this.oDomContainer||h=="html"){return;}}if(k){a.preventDefault(m);}r=n;if(c.hasClass(r,g.Style.CSS_CELL_SELECTABLE)){l=g.getIndexFromId(r.id);if(l>-1){o=g.cellDates[l];if(o){i=d.getDate(o[0],o[1]-1,o[2]);var q;if(g.Options.MULTI_SELECT){q=r.getElementsByTagName("a")[0];if(q){q.blur();}var j=g.cellDates[l];var p=g._indexOfSelectedFieldArray(j);if(p>-1){g.deselectCell(l);}else{g.selectCell(l);}}else{q=r.getElementsByTagName("a")[0];if(q){q.blur();}g.selectCell(l);}}}}},doCellMouseOver:function(i,h){var g;if(i){g=a.getTarget(i);}else{g=this;}while(g.tagName&&g.tagName.toLowerCase()!="td"){g=g.parentNode;if(!g.tagName||g.tagName.toLowerCase()=="html"){return;}}if(c.hasClass(g,h.Style.CSS_CELL_SELECTABLE)){c.addClass(g,h.Style.CSS_CELL_HOVER);}},doCellMouseOut:function(i,h){var g;if(i){g=a.getTarget(i);}else{g=this;}while(g.tagName&&g.tagName.toLowerCase()!="td"){g=g.parentNode;if(!g.tagName||g.tagName.toLowerCase()=="html"){return;}}if(c.hasClass(g,h.Style.CSS_CELL_SELECTABLE)){c.removeClass(g,h.Style.CSS_CELL_HOVER);}},setupConfig:function(){var g=this.cfg;g.addProperty(b.TODAY.key,{value:new Date(b.TODAY.value.getTime()),supercedes:b.TODAY.supercedes,handler:this.configToday,suppressEvent:true});g.addProperty(b.PAGEDATE.key,{value:b.PAGEDATE.value||new Date(b.TODAY.value.getTime()),handler:this.configPageDate});g.addProperty(b.SELECTED.key,{value:b.SELECTED.value.concat(),handler:this.configSelected});g.addProperty(b.TITLE.key,{value:b.TITLE.value,handler:this.configTitle});g.addProperty(b.CLOSE.key,{value:b.CLOSE.value,handler:this.configClose});g.addProperty(b.IFRAME.key,{value:b.IFRAME.value,handler:this.configIframe,validator:g.checkBoolean});g.addProperty(b.MINDATE.key,{value:b.MINDATE.value,handler:this.configMinDate});g.addProperty(b.MAXDATE.key,{value:b.MAXDATE.value,handler:this.configMaxDate});g.addProperty(b.MULTI_SELECT.key,{value:b.MULTI_SELECT.value,handler:this.configOptions,validator:g.checkBoolean});g.addProperty(b.OOM_SELECT.key,{value:b.OOM_SELECT.value,handler:this.configOptions,validator:g.checkBoolean});g.addProperty(b.START_WEEKDAY.key,{value:b.START_WEEKDAY.value,handler:this.configOptions,validator:g.checkNumber});g.addProperty(b.SHOW_WEEKDAYS.key,{value:b.SHOW_WEEKDAYS.value,handler:this.configOptions,validator:g.checkBoolean});g.addProperty(b.SHOW_WEEK_HEADER.key,{value:b.SHOW_WEEK_HEADER.value,handler:this.configOptions,validator:g.checkBoolean});g.addProperty(b.SHOW_WEEK_FOOTER.key,{value:b.SHOW_WEEK_FOOTER.value,handler:this.configOptions,validator:g.checkBoolean});g.addProperty(b.HIDE_BLANK_WEEKS.key,{value:b.HIDE_BLANK_WEEKS.value,handler:this.configOptions,validator:g.checkBoolean}); -g.addProperty(b.NAV_ARROW_LEFT.key,{value:b.NAV_ARROW_LEFT.value,handler:this.configOptions});g.addProperty(b.NAV_ARROW_RIGHT.key,{value:b.NAV_ARROW_RIGHT.value,handler:this.configOptions});g.addProperty(b.MONTHS_SHORT.key,{value:b.MONTHS_SHORT.value,handler:this.configLocale});g.addProperty(b.MONTHS_LONG.key,{value:b.MONTHS_LONG.value,handler:this.configLocale});g.addProperty(b.WEEKDAYS_1CHAR.key,{value:b.WEEKDAYS_1CHAR.value,handler:this.configLocale});g.addProperty(b.WEEKDAYS_SHORT.key,{value:b.WEEKDAYS_SHORT.value,handler:this.configLocale});g.addProperty(b.WEEKDAYS_MEDIUM.key,{value:b.WEEKDAYS_MEDIUM.value,handler:this.configLocale});g.addProperty(b.WEEKDAYS_LONG.key,{value:b.WEEKDAYS_LONG.value,handler:this.configLocale});var h=function(){g.refireEvent(b.LOCALE_MONTHS.key);g.refireEvent(b.LOCALE_WEEKDAYS.key);};g.subscribeToConfigEvent(b.START_WEEKDAY.key,h,this,true);g.subscribeToConfigEvent(b.MONTHS_SHORT.key,h,this,true);g.subscribeToConfigEvent(b.MONTHS_LONG.key,h,this,true);g.subscribeToConfigEvent(b.WEEKDAYS_1CHAR.key,h,this,true);g.subscribeToConfigEvent(b.WEEKDAYS_SHORT.key,h,this,true);g.subscribeToConfigEvent(b.WEEKDAYS_MEDIUM.key,h,this,true);g.subscribeToConfigEvent(b.WEEKDAYS_LONG.key,h,this,true);g.addProperty(b.LOCALE_MONTHS.key,{value:b.LOCALE_MONTHS.value,handler:this.configLocaleValues});g.addProperty(b.LOCALE_WEEKDAYS.key,{value:b.LOCALE_WEEKDAYS.value,handler:this.configLocaleValues});g.addProperty(b.YEAR_OFFSET.key,{value:b.YEAR_OFFSET.value,supercedes:b.YEAR_OFFSET.supercedes,handler:this.configLocale});g.addProperty(b.DATE_DELIMITER.key,{value:b.DATE_DELIMITER.value,handler:this.configLocale});g.addProperty(b.DATE_FIELD_DELIMITER.key,{value:b.DATE_FIELD_DELIMITER.value,handler:this.configLocale});g.addProperty(b.DATE_RANGE_DELIMITER.key,{value:b.DATE_RANGE_DELIMITER.value,handler:this.configLocale});g.addProperty(b.MY_MONTH_POSITION.key,{value:b.MY_MONTH_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MY_YEAR_POSITION.key,{value:b.MY_YEAR_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MD_MONTH_POSITION.key,{value:b.MD_MONTH_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MD_DAY_POSITION.key,{value:b.MD_DAY_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MDY_MONTH_POSITION.key,{value:b.MDY_MONTH_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MDY_DAY_POSITION.key,{value:b.MDY_DAY_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MDY_YEAR_POSITION.key,{value:b.MDY_YEAR_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MY_LABEL_MONTH_POSITION.key,{value:b.MY_LABEL_MONTH_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MY_LABEL_YEAR_POSITION.key,{value:b.MY_LABEL_YEAR_POSITION.value,handler:this.configLocale,validator:g.checkNumber});g.addProperty(b.MY_LABEL_MONTH_SUFFIX.key,{value:b.MY_LABEL_MONTH_SUFFIX.value,handler:this.configLocale});g.addProperty(b.MY_LABEL_YEAR_SUFFIX.key,{value:b.MY_LABEL_YEAR_SUFFIX.value,handler:this.configLocale});g.addProperty(b.NAV.key,{value:b.NAV.value,handler:this.configNavigator});g.addProperty(b.STRINGS.key,{value:b.STRINGS.value,handler:this.configStrings,validator:function(i){return e.isObject(i);},supercedes:b.STRINGS.supercedes});},configStrings:function(h,g,i){var j=e.merge(b.STRINGS.value,g[0]);this.cfg.setProperty(b.STRINGS.key,j,true);},configPageDate:function(h,g,i){this.cfg.setProperty(b.PAGEDATE.key,this._parsePageDate(g[0]),true);},configMinDate:function(h,g,i){var j=g[0];if(e.isString(j)){j=this._parseDate(j);this.cfg.setProperty(b.MINDATE.key,d.getDate(j[0],(j[1]-1),j[2]));}},configMaxDate:function(h,g,i){var j=g[0];if(e.isString(j)){j=this._parseDate(j);this.cfg.setProperty(b.MAXDATE.key,d.getDate(j[0],(j[1]-1),j[2]));}},configToday:function(i,h,j){var k=h[0];if(e.isString(k)){k=this._parseDate(k);}var g=d.clearTime(k);if(!this.cfg.initialConfig[b.PAGEDATE.key]){this.cfg.setProperty(b.PAGEDATE.key,g);}this.today=g;this.cfg.setProperty(b.TODAY.key,g,true);},configSelected:function(i,g,k){var h=g[0],j=b.SELECTED.key;if(h){if(e.isString(h)){this.cfg.setProperty(j,this._parseDates(h),true);}}if(!this._selectedDates){this._selectedDates=this.cfg.getProperty(j);}},configOptions:function(h,g,i){this.Options[h.toUpperCase()]=g[0];},configLocale:function(h,g,i){this.Locale[h.toUpperCase()]=g[0];this.cfg.refireEvent(b.LOCALE_MONTHS.key);this.cfg.refireEvent(b.LOCALE_WEEKDAYS.key);},configLocaleValues:function(j,i,k){j=j.toLowerCase();var m=i[0],h=this.cfg,n=this.Locale;switch(j){case b.LOCALE_MONTHS.key:switch(m){case f.SHORT:n.LOCALE_MONTHS=h.getProperty(b.MONTHS_SHORT.key).concat();break;case f.LONG:n.LOCALE_MONTHS=h.getProperty(b.MONTHS_LONG.key).concat();break;}break;case b.LOCALE_WEEKDAYS.key:switch(m){case f.ONE_CHAR:n.LOCALE_WEEKDAYS=h.getProperty(b.WEEKDAYS_1CHAR.key).concat();break;case f.SHORT:n.LOCALE_WEEKDAYS=h.getProperty(b.WEEKDAYS_SHORT.key).concat();break;case f.MEDIUM:n.LOCALE_WEEKDAYS=h.getProperty(b.WEEKDAYS_MEDIUM.key).concat();break;case f.LONG:n.LOCALE_WEEKDAYS=h.getProperty(b.WEEKDAYS_LONG.key).concat();break;}var l=h.getProperty(b.START_WEEKDAY.key);if(l>0){for(var g=0;g'+h+"";}this.oDomContainer.appendChild(l);return l;},removeCloseButton:function(){var g=c.getElementsByClassName(this.Style.CSS_LINK_CLOSE,"a",this.oDomContainer)[0]||null;if(g){a.purgeElement(g);this.oDomContainer.removeChild(g);}},renderHeader:function(q){var p=7,o="us/tr/callt.gif",g="us/tr/calrt.gif",n=this.cfg,k=n.getProperty(b.PAGEDATE.key),l=n.getProperty(b.STRINGS.key),v=(l&&l.previousMonth)?l.previousMonth:"",h=(l&&l.nextMonth)?l.nextMonth:"",m;if(n.getProperty(b.SHOW_WEEK_HEADER.key)){p+=1;}if(n.getProperty(b.SHOW_WEEK_FOOTER.key)){p+=1;}q[q.length]="";q[q.length]="";q[q.length]='';q[q.length]='

';var x,u=false;if(this.parent){if(this.index===0){x=true;}if(this.index==(this.parent.cfg.getProperty("pages")-1)){u=true;}}else{x=true;u=true;}if(x){m=this._buildMonthLabel(d.subtract(k,d.MONTH,1));var r=n.getProperty(b.NAV_ARROW_LEFT.key);if(r===null&&f.IMG_ROOT!==null){r=f.IMG_ROOT+o;}var i=(r===null)?"":' style="background-image:url('+r+')"';q[q.length]=''+v+" ("+m+")"+"";}var w=this.buildMonthLabel();var s=this.parent||this;if(s.cfg.getProperty("navigator")){w=''+w+"";}q[q.length]=w;if(u){m=this._buildMonthLabel(d.add(k,d.MONTH,1));var t=n.getProperty(b.NAV_ARROW_RIGHT.key);if(t===null&&f.IMG_ROOT!==null){t=f.IMG_ROOT+g;}var j=(t===null)?"":' style="background-image:url('+t+')"';q[q.length]=''+h+" ("+m+")"+"";}q[q.length]="
\n\n";if(n.getProperty(b.SHOW_WEEKDAYS.key)){q=this.buildWeekdays(q);}q[q.length]="";return q;},buildWeekdays:function(h){h[h.length]='';if(this.cfg.getProperty(b.SHOW_WEEK_HEADER.key)){h[h.length]=" ";}for(var g=0;g'+this.Locale.LOCALE_WEEKDAYS[g]+"";}if(this.cfg.getProperty(b.SHOW_WEEK_FOOTER.key)){h[h.length]=" ";}h[h.length]="";return h;},renderBody:function(T,Q){var ao=this.cfg.getProperty(b.START_WEEKDAY.key);this.preMonthDays=T.getDay();if(ao>0){this.preMonthDays-=ao;}if(this.preMonthDays<0){this.preMonthDays+=7;}this.monthDays=d.findMonthEnd(T).getDate();this.postMonthDays=f.DISPLAY_DAYS-this.preMonthDays-this.monthDays;T=d.subtract(T,d.DAY,this.preMonthDays);var F,q,o="w",L="_cell",J="wd",Z="d",v,X,af=this.today,u=this.cfg,ae,D=af.getFullYear(),Y=af.getMonth(),k=af.getDate(),ad=u.getProperty(b.PAGEDATE.key),j=u.getProperty(b.HIDE_BLANK_WEEKS.key),P=u.getProperty(b.SHOW_WEEK_FOOTER.key),I=u.getProperty(b.SHOW_WEEK_HEADER.key),O=u.getProperty(b.OOM_SELECT.key),B=u.getProperty(b.MINDATE.key),H=u.getProperty(b.MAXDATE.key),A=this.Locale.YEAR_OFFSET;if(B){B=d.clearTime(B);}if(H){H=d.clearTime(H);}Q[Q.length]='';var am=0,w=document.createElement("div"),R=document.createElement("td");w.appendChild(R);var ac=this.parent||this;for(var ah=0;ah<6;ah++){F=d.getWeekNumber(T,ao);q=o+F;if(ah!==0&&j===true&&T.getMonth()!=ad.getMonth()){break;}else{Q[Q.length]='';if(I){Q=this.renderRowHeader(F,Q);}for(var an=0;an<7;an++){v=[];this.clearElement(R);R.className=this.Style.CSS_CELL;R.id=this.id+L+am;if(T.getDate()==k&&T.getMonth()==Y&&T.getFullYear()==D){v[v.length]=ac.renderCellStyleToday;}var G=[T.getFullYear(),T.getMonth()+1,T.getDate()];this.cellDates[this.cellDates.length]=G;ae=T.getMonth()!=ad.getMonth();if(ae&&!O){v[v.length]=ac.renderCellNotThisMonth;}else{c.addClass(R,J+T.getDay());c.addClass(R,Z+T.getDate());var S=this.renderStack.concat();for(var ag=0,al=S.length;ag=ak.getTime()&&T.getTime()<=aj.getTime()){X=aa[2];if(T.getTime()==aj.getTime()){this.renderStack.splice(ag,1); -}}break;case f.WEEKDAY:var y=aa[1][0];if(T.getDay()+1==y){X=aa[2];}break;case f.MONTH:h=aa[1][0];if(T.getMonth()+1==h){X=aa[2];}break;}if(X){v[v.length]=X;}}}if(this._indexOfSelectedFieldArray(G)>-1){v[v.length]=ac.renderCellStyleSelected;}if(ae){v[v.length]=ac.styleCellNotThisMonth;}if((B&&(T.getTime()H.getTime()))){v[v.length]=ac.renderOutOfBoundsDate;}else{v[v.length]=ac.styleCellDefault;v[v.length]=ac.renderCellDefault;}for(var ab=0;ab=0&&am<=6){c.addClass(R,this.Style.CSS_CELL_TOP);}if((am%7)===0){c.addClass(R,this.Style.CSS_CELL_LEFT);}if(((am+1)%7)===0){c.addClass(R,this.Style.CSS_CELL_RIGHT);}var V=this.postMonthDays;if(j&&V>=7){var C=Math.floor(V/7);for(var ai=0;ai=((this.preMonthDays+V+this.monthDays)-7)){c.addClass(R,this.Style.CSS_CELL_BOTTOM);}Q[Q.length]=w.innerHTML;am++;}if(P){Q=this.renderRowFooter(F,Q);}Q[Q.length]="";}}Q[Q.length]="";return Q;},renderFooter:function(g){return g;},render:function(){this.beforeRenderEvent.fire();var i=d.findMonthStart(this.cfg.getProperty(b.PAGEDATE.key));this.resetRenderers();this.cellDates.length=0;a.purgeElement(this.oDomContainer,true);var g=[],h;g[g.length]='';g=this.renderHeader(g);g=this.renderBody(i,g);g=this.renderFooter(g);g[g.length]="
";this.oDomContainer.innerHTML=g.join("\n");this.applyListeners();h=((this._oDoc)&&this._oDoc.getElementById(this.id))||(this.id);this.cells=c.getElementsByClassName(this.Style.CSS_CELL,"td",h);this.cfg.refireEvent(b.TITLE.key);this.cfg.refireEvent(b.CLOSE.key);this.cfg.refireEvent(b.IFRAME.key);this.renderEvent.fire();},applyListeners:function(){var q=this.oDomContainer,h=this.parent||this,m="a",t="click";var n=c.getElementsByClassName(this.Style.CSS_NAV_LEFT,m,q),j=c.getElementsByClassName(this.Style.CSS_NAV_RIGHT,m,q);if(n&&n.length>0){this.linkLeft=n[0];a.addListener(this.linkLeft,t,this.doPreviousMonthNav,h,true);}if(j&&j.length>0){this.linkRight=j[0];a.addListener(this.linkRight,t,this.doNextMonthNav,h,true);}if(h.cfg.getProperty("navigator")!==null){this.applyNavListeners();}if(this.domEventMap){var k,g;for(var s in this.domEventMap){if(e.hasOwnProperty(this.domEventMap,s)){var o=this.domEventMap[s];if(!(o instanceof Array)){o=[o];}for(var l=0;l0){a.addListener(g,"click",function(n,m){var l=a.getTarget(n);if(this===l||c.isAncestor(this,l)){a.preventDefault(n);}var j=h.oNavigator;if(j){var k=i.cfg.getProperty("pagedate");j.setYear(k.getFullYear()+i.Locale.YEAR_OFFSET);j.setMonth(k.getMonth());j.show();}});}},getDateByCellId:function(h){var g=this.getDateFieldsByCellId(h);return(g)?d.getDate(g[0],g[1]-1,g[2]):null;},getDateFieldsByCellId:function(g){g=this.getIndexFromId(g);return(g>-1)?this.cellDates[g]:null;},getCellIndex:function(j){var h=-1;if(j){var g=j.getMonth(),p=j.getFullYear(),o=j.getDate(),l=this.cellDates;for(var k=0;k-1){h=parseInt(i.substring(g+5),10);}return h;},renderOutOfBoundsDate:function(h,g){c.addClass(g,this.Style.CSS_CELL_OOB);g.innerHTML=h.getDate();return f.STOP_RENDER;},renderRowHeader:function(h,g){g[g.length]=''+h+"";return g;},renderRowFooter:function(h,g){g[g.length]=''+h+"";return g;},renderCellDefault:function(h,g){g.innerHTML=''+this.buildDayLabel(h)+"";},styleCellDefault:function(h,g){c.addClass(g,this.Style.CSS_CELL_SELECTABLE);},renderCellStyleHighlight1:function(h,g){c.addClass(g,this.Style.CSS_CELL_HIGHLIGHT1);},renderCellStyleHighlight2:function(h,g){c.addClass(g,this.Style.CSS_CELL_HIGHLIGHT2);},renderCellStyleHighlight3:function(h,g){c.addClass(g,this.Style.CSS_CELL_HIGHLIGHT3);},renderCellStyleHighlight4:function(h,g){c.addClass(g,this.Style.CSS_CELL_HIGHLIGHT4);},renderCellStyleToday:function(h,g){c.addClass(g,this.Style.CSS_CELL_TODAY);},renderCellStyleSelected:function(h,g){c.addClass(g,this.Style.CSS_CELL_SELECTED);},renderCellNotThisMonth:function(h,g){this.styleCellNotThisMonth(h,g);g.innerHTML=h.getDate();return f.STOP_RENDER;},styleCellNotThisMonth:function(h,g){YAHOO.util.Dom.addClass(g,this.Style.CSS_CELL_OOM);},renderBodyCellRestricted:function(h,g){c.addClass(g,this.Style.CSS_CELL);c.addClass(g,this.Style.CSS_CELL_RESTRICTED);g.innerHTML=h.getDate();return f.STOP_RENDER;},addMonths:function(i){var h=b.PAGEDATE.key,j=this.cfg.getProperty(h),g=d.add(j,d.MONTH,i);this.cfg.setProperty(h,g);this.resetRenderers();this.changePageEvent.fire(j,g);},subtractMonths:function(g){this.addMonths(-1*g);},addYears:function(i){var h=b.PAGEDATE.key,j=this.cfg.getProperty(h),g=d.add(j,d.YEAR,i);this.cfg.setProperty(h,g);this.resetRenderers();this.changePageEvent.fire(j,g);},subtractYears:function(g){this.addYears(-1*g);},nextMonth:function(){this.addMonths(1);},previousMonth:function(){this.addMonths(-1);},nextYear:function(){this.addYears(1);},previousYear:function(){this.addYears(-1);},reset:function(){this.cfg.resetProperty(b.SELECTED.key);this.cfg.resetProperty(b.PAGEDATE.key);this.resetEvent.fire();},clear:function(){this.cfg.setProperty(b.SELECTED.key,[]); -this.cfg.setProperty(b.PAGEDATE.key,new Date(this.today.getTime()));this.clearEvent.fire();},select:function(i){var l=this._toFieldArray(i),h=[],k=[],m=b.SELECTED.key;for(var g=0;g0){if(this.parent){this.parent.cfg.setProperty(m,k);}else{this.cfg.setProperty(m,k);}this.selectEvent.fire(h);}return this.getSelectedDates();},selectCell:function(j){var h=this.cells[j],n=this.cellDates[j],m=this._toDate(n),i=c.hasClass(h,this.Style.CSS_CELL_SELECTABLE);if(i){this.beforeSelectEvent.fire();var l=b.SELECTED.key;var k=this.cfg.getProperty(l);var g=n.concat();if(this._indexOfSelectedFieldArray(g)==-1){k[k.length]=g;}if(this.parent){this.parent.cfg.setProperty(l,k);}else{this.cfg.setProperty(l,k);}this.renderCellStyleSelected(m,h);this.selectEvent.fire([g]);this.doCellMouseOut.call(h,null,this);}return this.getSelectedDates();},deselect:function(k){var g=this._toFieldArray(k),j=[],m=[],n=b.SELECTED.key;for(var h=0;h0){if(this.parent){this.parent.cfg.setProperty(n,m);}else{this.cfg.setProperty(n,m);}this.deselectEvent.fire(j);}return this.getSelectedDates();},deselectCell:function(k){var h=this.cells[k],n=this.cellDates[k],i=this._indexOfSelectedFieldArray(n);var j=c.hasClass(h,this.Style.CSS_CELL_SELECTABLE);if(j){this.beforeDeselectEvent.fire();var l=this.cfg.getProperty(b.SELECTED.key),m=this._toDate(n),g=n.concat();if(i>-1){if((this.cfg.getProperty(b.PAGEDATE.key).getMonth()==m.getMonth()&&this.cfg.getProperty(b.PAGEDATE.key).getFullYear()==m.getFullYear())||this.cfg.getProperty(b.OOM_SELECT.key)){c.removeClass(h,this.Style.CSS_CELL_SELECTED);}l.splice(i,1);}if(this.parent){this.parent.cfg.setProperty(b.SELECTED.key,l);}else{this.cfg.setProperty(b.SELECTED.key,l);}this.deselectEvent.fire([g]);}return this.getSelectedDates();},deselectAll:function(){this.beforeDeselectEvent.fire();var j=b.SELECTED.key,g=this.cfg.getProperty(j),h=g.length,i=g.concat();if(this.parent){this.parent.cfg.setProperty(j,[]);}else{this.cfg.setProperty(j,[]);}if(h>0){this.deselectEvent.fire(i);}return this.getSelectedDates();},_toFieldArray:function(h){var g=[];if(h instanceof Date){g=[[h.getFullYear(),h.getMonth()+1,h.getDate()]];}else{if(e.isString(h)){g=this._parseDates(h);}else{if(e.isArray(h)){for(var j=0;jk.getTime()));},_parsePageDate:function(g){var j;if(g){if(g instanceof Date){j=d.findMonthStart(g);}else{var k,i,h;h=g.split(this.cfg.getProperty(b.DATE_FIELD_DELIMITER.key));k=parseInt(h[this.cfg.getProperty(b.MY_MONTH_POSITION.key)-1],10)-1;i=parseInt(h[this.cfg.getProperty(b.MY_YEAR_POSITION.key)-1],10)-this.Locale.YEAR_OFFSET;j=d.getDate(i,k,1);}}else{j=d.getDate(this.today.getFullYear(),this.today.getMonth(),1);}return j;},onBeforeSelect:function(){if(this.cfg.getProperty(b.MULTI_SELECT.key)===false){if(this.parent){this.parent.callChildFunction("clearAllBodyCellStyles",this.Style.CSS_CELL_SELECTED);this.parent.deselectAll();}else{this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);this.deselectAll();}}},onSelect:function(g){},onBeforeDeselect:function(){},onDeselect:function(g){},onChangePage:function(){this.render();},onRender:function(){},onReset:function(){this.render();},onClear:function(){this.render();},validate:function(){return true;},_parseDate:function(j){var k=j.split(this.Locale.DATE_FIELD_DELIMITER),g;if(k.length==2){g=[k[this.Locale.MD_MONTH_POSITION-1],k[this.Locale.MD_DAY_POSITION-1]];g.type=f.MONTH_DAY;}else{g=[k[this.Locale.MDY_YEAR_POSITION-1]-this.Locale.YEAR_OFFSET,k[this.Locale.MDY_MONTH_POSITION-1],k[this.Locale.MDY_DAY_POSITION-1]];g.type=f.DATE;}for(var h=0;h0){this.init.apply(this,arguments);}}b.DEFAULT_CONFIG=b._DEFAULT_CONFIG=g.DEFAULT_CONFIG;b.DEFAULT_CONFIG.PAGES={key:"pages",value:2};var c=b.DEFAULT_CONFIG;b.prototype={init:function(k,i,j){var h=this._parseArgs(arguments);k=h.id;i=h.container;j=h.config;this.oDomContainer=d.get(i);if(!this.oDomContainer.id){this.oDomContainer.id=d.generateId();}if(!k){k=this.oDomContainer.id+"_t";}this.id=k;this.containerId=this.oDomContainer.id;this.initEvents();this.initStyles();this.pages=[];d.addClass(this.oDomContainer,b.CSS_CONTAINER);d.addClass(this.oDomContainer,b.CSS_MULTI_UP);this.cfg=new YAHOO.util.Config(this);this.Options={};this.Locale={};this.setupConfig();if(j){this.cfg.applyConfig(j,true);}this.cfg.fireQueue();},setupConfig:function(){var h=this.cfg;h.addProperty(c.PAGES.key,{value:c.PAGES.value,validator:h.checkNumber,handler:this.configPages});h.addProperty(c.YEAR_OFFSET.key,{value:c.YEAR_OFFSET.value,handler:this.delegateConfig,supercedes:c.YEAR_OFFSET.supercedes,suppressEvent:true});h.addProperty(c.TODAY.key,{value:new Date(c.TODAY.value.getTime()),supercedes:c.TODAY.supercedes,handler:this.configToday,suppressEvent:false});h.addProperty(c.PAGEDATE.key,{value:c.PAGEDATE.value||new Date(c.TODAY.value.getTime()),handler:this.configPageDate});h.addProperty(c.SELECTED.key,{value:[],handler:this.configSelected});h.addProperty(c.TITLE.key,{value:c.TITLE.value,handler:this.configTitle});h.addProperty(c.CLOSE.key,{value:c.CLOSE.value,handler:this.configClose});h.addProperty(c.IFRAME.key,{value:c.IFRAME.value,handler:this.configIframe,validator:h.checkBoolean});h.addProperty(c.MINDATE.key,{value:c.MINDATE.value,handler:this.delegateConfig});h.addProperty(c.MAXDATE.key,{value:c.MAXDATE.value,handler:this.delegateConfig});h.addProperty(c.MULTI_SELECT.key,{value:c.MULTI_SELECT.value,handler:this.delegateConfig,validator:h.checkBoolean});h.addProperty(c.OOM_SELECT.key,{value:c.OOM_SELECT.value,handler:this.delegateConfig,validator:h.checkBoolean});h.addProperty(c.START_WEEKDAY.key,{value:c.START_WEEKDAY.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.SHOW_WEEKDAYS.key,{value:c.SHOW_WEEKDAYS.value,handler:this.delegateConfig,validator:h.checkBoolean});h.addProperty(c.SHOW_WEEK_HEADER.key,{value:c.SHOW_WEEK_HEADER.value,handler:this.delegateConfig,validator:h.checkBoolean});h.addProperty(c.SHOW_WEEK_FOOTER.key,{value:c.SHOW_WEEK_FOOTER.value,handler:this.delegateConfig,validator:h.checkBoolean});h.addProperty(c.HIDE_BLANK_WEEKS.key,{value:c.HIDE_BLANK_WEEKS.value,handler:this.delegateConfig,validator:h.checkBoolean});h.addProperty(c.NAV_ARROW_LEFT.key,{value:c.NAV_ARROW_LEFT.value,handler:this.delegateConfig});h.addProperty(c.NAV_ARROW_RIGHT.key,{value:c.NAV_ARROW_RIGHT.value,handler:this.delegateConfig});h.addProperty(c.MONTHS_SHORT.key,{value:c.MONTHS_SHORT.value,handler:this.delegateConfig});h.addProperty(c.MONTHS_LONG.key,{value:c.MONTHS_LONG.value,handler:this.delegateConfig});h.addProperty(c.WEEKDAYS_1CHAR.key,{value:c.WEEKDAYS_1CHAR.value,handler:this.delegateConfig});h.addProperty(c.WEEKDAYS_SHORT.key,{value:c.WEEKDAYS_SHORT.value,handler:this.delegateConfig});h.addProperty(c.WEEKDAYS_MEDIUM.key,{value:c.WEEKDAYS_MEDIUM.value,handler:this.delegateConfig});h.addProperty(c.WEEKDAYS_LONG.key,{value:c.WEEKDAYS_LONG.value,handler:this.delegateConfig});h.addProperty(c.LOCALE_MONTHS.key,{value:c.LOCALE_MONTHS.value,handler:this.delegateConfig});h.addProperty(c.LOCALE_WEEKDAYS.key,{value:c.LOCALE_WEEKDAYS.value,handler:this.delegateConfig});h.addProperty(c.DATE_DELIMITER.key,{value:c.DATE_DELIMITER.value,handler:this.delegateConfig});h.addProperty(c.DATE_FIELD_DELIMITER.key,{value:c.DATE_FIELD_DELIMITER.value,handler:this.delegateConfig});h.addProperty(c.DATE_RANGE_DELIMITER.key,{value:c.DATE_RANGE_DELIMITER.value,handler:this.delegateConfig});h.addProperty(c.MY_MONTH_POSITION.key,{value:c.MY_MONTH_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber}); -h.addProperty(c.MY_YEAR_POSITION.key,{value:c.MY_YEAR_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MD_MONTH_POSITION.key,{value:c.MD_MONTH_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MD_DAY_POSITION.key,{value:c.MD_DAY_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MDY_MONTH_POSITION.key,{value:c.MDY_MONTH_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MDY_DAY_POSITION.key,{value:c.MDY_DAY_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MDY_YEAR_POSITION.key,{value:c.MDY_YEAR_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MY_LABEL_MONTH_POSITION.key,{value:c.MY_LABEL_MONTH_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MY_LABEL_YEAR_POSITION.key,{value:c.MY_LABEL_YEAR_POSITION.value,handler:this.delegateConfig,validator:h.checkNumber});h.addProperty(c.MY_LABEL_MONTH_SUFFIX.key,{value:c.MY_LABEL_MONTH_SUFFIX.value,handler:this.delegateConfig});h.addProperty(c.MY_LABEL_YEAR_SUFFIX.key,{value:c.MY_LABEL_YEAR_SUFFIX.value,handler:this.delegateConfig});h.addProperty(c.NAV.key,{value:c.NAV.value,handler:this.configNavigator});h.addProperty(c.STRINGS.key,{value:c.STRINGS.value,handler:this.configStrings,validator:function(i){return e.isObject(i);},supercedes:c.STRINGS.supercedes});},initEvents:function(){var j=this,l="Event",m=YAHOO.util.CustomEvent;var i=function(o,s,n){for(var r=0;r0){m=new Date(o);this._setMonthOnDate(m,m.getMonth()+i);q.pageDate=m;}var h=this.constructChild(v,r,q);d.removeClass(h.oDomContainer,this.Style.CSS_SINGLE);d.addClass(h.oDomContainer,t);if(i===0){o=h.cfg.getProperty(j);d.addClass(h.oDomContainer,w);}if(i==(l-1)){d.addClass(h.oDomContainer,k);}h.parent=this;h.index=i;this.pages[this.pages.length]=h;}},configPageDate:function(o,n,l){var j=n[0],m;var k=c.PAGEDATE.key;for(var i=0;i0)?this.pages[0].cfg.getProperty(k):[];this.cfg.setProperty(k,i,true);},delegateConfig:function(i,h,l){var m=h[0];var k;for(var j=0;j0){j+=1;}k.setYear(j);}},render:function(){this.renderHeader();for(var i=0;i=0;--i){var h=this.pages[i];h.previousMonth();}},nextYear:function(){for(var i=0;i11)){var h=f.add(i,f.MONTH,j-i.getMonth());i.setTime(h.getTime());}else{i.setMonth(j);}},_fixWidth:function(){var h=0;for(var j=0;j0){this.oDomContainer.style.width=h+"px";}},toString:function(){return"CalendarGroup "+this.id;},destroy:function(){if(this.beforeDestroyEvent.fire()){var k=this;if(k.navigator){k.navigator.destroy();}if(k.cfg){k.cfg.destroy();}a.purgeElement(k.oDomContainer,true);d.removeClass(k.oDomContainer,b.CSS_CONTAINER);d.removeClass(k.oDomContainer,b.CSS_MULTI_UP);for(var j=0,h=k.pages.length;j=0&&a<12){this._month=a;}this._updateMonthUI();},setYear:function(b){var a=YAHOO.widget.CalendarNavigator.YR_PATTERN;if(YAHOO.lang.isNumber(b)&&a.test(b+"")){this._year=b;}this._updateYearUI();},render:function(){this.cal.beforeRenderNavEvent.fire();if(!this.__rendered){this.createNav();this.createMask();this.applyListeners(); -this.__rendered=true;}this.cal.renderNavEvent.fire();},createNav:function(){var b=YAHOO.widget.CalendarNavigator;var c=this._doc;var e=c.createElement("div");e.className=b.CLASSES.NAV;var a=this.renderNavContents([]);e.innerHTML=a.join("");this.cal.oDomContainer.appendChild(e);this.navEl=e;this.yearEl=c.getElementById(this.id+b.YEAR_SUFFIX);this.monthEl=c.getElementById(this.id+b.MONTH_SUFFIX);this.errorEl=c.getElementById(this.id+b.ERROR_SUFFIX);this.submitEl=c.getElementById(this.id+b.SUBMIT_SUFFIX);this.cancelEl=c.getElementById(this.id+b.CANCEL_SUFFIX);if(YAHOO.env.ua.gecko&&this.yearEl&&this.yearEl.type=="text"){this.yearEl.setAttribute("autocomplete","off");}this._setFirstLastElements();},createMask:function(){var b=YAHOO.widget.CalendarNavigator.CLASSES;var a=this._doc.createElement("div");a.className=b.MASK;this.cal.oDomContainer.appendChild(a);this.maskEl=a;},_syncMask:function(){var b=this.cal.oDomContainer;if(b&&this.maskEl){var a=YAHOO.util.Dom.getRegion(b);YAHOO.util.Dom.setStyle(this.maskEl,"width",a.right-a.left+"px");YAHOO.util.Dom.setStyle(this.maskEl,"height",a.bottom-a.top+"px");}},renderNavContents:function(a){var c=YAHOO.widget.CalendarNavigator,d=c.CLASSES,b=a;b[b.length]='
';this.renderMonth(b);b[b.length]="
";b[b.length]='
';this.renderYear(b);b[b.length]="
";b[b.length]='
';this.renderButtons(b);b[b.length]="
";b[b.length]='
';return b;},renderMonth:function(c){var f=YAHOO.widget.CalendarNavigator,g=f.CLASSES;var j=this.id+f.MONTH_SUFFIX,e=this.__getCfg("monthFormat"),a=this.cal.cfg.getProperty((e==YAHOO.widget.Calendar.SHORT)?"MONTHS_SHORT":"MONTHS_LONG"),d=c;if(a&&a.length>0){d[d.length]='";d[d.length]='";}return d;},renderYear:function(b){var d=YAHOO.widget.CalendarNavigator,e=d.CLASSES;var f=this.id+d.YEAR_SUFFIX,a=d.YR_MAX_DIGITS,c=b;c[c.length]='";c[c.length]='';return c;},renderButtons:function(a){var c=YAHOO.widget.CalendarNavigator.CLASSES;var b=a;b[b.length]='';b[b.length]='";b[b.length]="";b[b.length]='';b[b.length]='";b[b.length]="";return b;},applyListeners:function(){var b=YAHOO.util.Event;function a(){if(this.validate()){this.setYear(this._getYearFromUI());}}function c(){this.setMonth(this._getMonthFromUI());}b.on(this.submitEl,"click",this.submit,this,true);b.on(this.cancelEl,"click",this.cancel,this,true);b.on(this.yearEl,"blur",a,this,true);b.on(this.monthEl,"change",c,this,true);if(this.__isIEQuirks){YAHOO.util.Event.on(this.cal.oDomContainer,"resize",this._syncMask,this,true);}this.applyKeyListeners();},purgeListeners:function(){var a=YAHOO.util.Event;a.removeListener(this.submitEl,"click",this.submit);a.removeListener(this.cancelEl,"click",this.cancel);a.removeListener(this.yearEl,"blur");a.removeListener(this.monthEl,"change");if(this.__isIEQuirks){a.removeListener(this.cal.oDomContainer,"resize",this._syncMask);}this.purgeKeyListeners();},applyKeyListeners:function(){var d=YAHOO.util.Event,a=YAHOO.env.ua;var c=(a.ie||a.webkit)?"keydown":"keypress";var b=(a.ie||a.opera||a.webkit)?"keydown":"keypress";d.on(this.yearEl,"keypress",this._handleEnterKey,this,true);d.on(this.yearEl,c,this._handleDirectionKeys,this,true);d.on(this.lastCtrl,b,this._handleTabKey,this,true);d.on(this.firstCtrl,b,this._handleShiftTabKey,this,true);},purgeKeyListeners:function(){var d=YAHOO.util.Event,a=YAHOO.env.ua;var c=(a.ie||a.webkit)?"keydown":"keypress";var b=(a.ie||a.opera||a.webkit)?"keydown":"keypress";d.removeListener(this.yearEl,"keypress",this._handleEnterKey);d.removeListener(this.yearEl,c,this._handleDirectionKeys);d.removeListener(this.lastCtrl,b,this._handleTabKey);d.removeListener(this.firstCtrl,b,this._handleShiftTabKey);},submit:function(){if(this.validate()){this.hide();this.setMonth(this._getMonthFromUI());this.setYear(this._getYearFromUI());var b=this.cal;var a=YAHOO.widget.CalendarNavigator.UPDATE_DELAY;if(a>0){var c=this;window.setTimeout(function(){c._update(b);},a);}else{this._update(b);}}},_update:function(b){var a=YAHOO.widget.DateMath.getDate(this.getYear()-b.cfg.getProperty("YEAR_OFFSET"),this.getMonth(),1);b.cfg.setProperty("pagedate",a);b.render();},cancel:function(){this.hide();},validate:function(){if(this._getYearFromUI()!==null){this.clearErrors();return true;}else{this.setYearError();this.setError(this.__getCfg("invalidYear",true));return false;}},setError:function(a){if(this.errorEl){this.errorEl.innerHTML=a;this._show(this.errorEl,true);}},clearError:function(){if(this.errorEl){this.errorEl.innerHTML="";this._show(this.errorEl,false);}},setYearError:function(){YAHOO.util.Dom.addClass(this.yearEl,YAHOO.widget.CalendarNavigator.CLASSES.INVALID);},clearYearError:function(){YAHOO.util.Dom.removeClass(this.yearEl,YAHOO.widget.CalendarNavigator.CLASSES.INVALID);},clearErrors:function(){this.clearError();this.clearYearError();},setInitialFocus:function(){var a=this.submitEl,c=this.__getCfg("initialFocus");if(c&&c.toLowerCase){c=c.toLowerCase();if(c=="year"){a=this.yearEl;try{this.yearEl.select();}catch(b){}}else{if(c=="month"){a=this.monthEl;}}}if(a&&YAHOO.lang.isFunction(a.focus)){try{a.focus();}catch(d){}}},erase:function(){if(this.__rendered){this.purgeListeners(); -this.yearEl=null;this.monthEl=null;this.errorEl=null;this.submitEl=null;this.cancelEl=null;this.firstCtrl=null;this.lastCtrl=null;if(this.navEl){this.navEl.innerHTML="";}var b=this.navEl.parentNode;if(b){b.removeChild(this.navEl);}this.navEl=null;var a=this.maskEl.parentNode;if(a){a.removeChild(this.maskEl);}this.maskEl=null;this.__rendered=false;}},destroy:function(){this.erase();this._doc=null;this.cal=null;this.id=null;},_show:function(b,a){if(b){YAHOO.util.Dom.setStyle(b,"display",(a)?"block":"none");}},_getMonthFromUI:function(){if(this.monthEl){return this.monthEl.selectedIndex;}else{return 0;}},_getYearFromUI:function(){var b=YAHOO.widget.CalendarNavigator;var a=null;if(this.yearEl){var c=this.yearEl.value;c=c.replace(b.TRIM,"$1");if(b.YR_PATTERN.test(c)){a=parseInt(c,10);}}return a;},_updateYearUI:function(){if(this.yearEl&&this._year!==null){this.yearEl.value=this._year;}},_updateMonthUI:function(){if(this.monthEl){this.monthEl.selectedIndex=this._month;}},_setFirstLastElements:function(){this.firstCtrl=this.monthEl;this.lastCtrl=this.cancelEl;if(this.__isMac){if(YAHOO.env.ua.webkit&&YAHOO.env.ua.webkit<420){this.firstCtrl=this.monthEl;this.lastCtrl=this.yearEl;}if(YAHOO.env.ua.gecko){this.firstCtrl=this.yearEl;this.lastCtrl=this.yearEl;}}},_handleEnterKey:function(b){var a=YAHOO.util.KeyListener.KEY;if(YAHOO.util.Event.getCharCode(b)==a.ENTER){YAHOO.util.Event.preventDefault(b);this.submit();}},_handleDirectionKeys:function(h){var g=YAHOO.util.Event,a=YAHOO.util.KeyListener.KEY,d=YAHOO.widget.CalendarNavigator;var f=(this.yearEl.value)?parseInt(this.yearEl.value,10):null;if(isFinite(f)){var b=false;switch(g.getCharCode(h)){case a.UP:this.yearEl.value=f+d.YR_MINOR_INC;b=true;break;case a.DOWN:this.yearEl.value=Math.max(f-d.YR_MINOR_INC,0);b=true;break;case a.PAGE_UP:this.yearEl.value=f+d.YR_MAJOR_INC;b=true;break;case a.PAGE_DOWN:this.yearEl.value=Math.max(f-d.YR_MAJOR_INC,0);b=true;break;default:break;}if(b){g.preventDefault(h);try{this.yearEl.select();}catch(c){}}}},_handleTabKey:function(d){var c=YAHOO.util.Event,a=YAHOO.util.KeyListener.KEY;if(c.getCharCode(d)==a.TAB&&!d.shiftKey){try{c.preventDefault(d);this.firstCtrl.focus();}catch(b){}}},_handleShiftTabKey:function(d){var c=YAHOO.util.Event,a=YAHOO.util.KeyListener.KEY;if(d.shiftKey&&c.getCharCode(d)==a.TAB){try{c.preventDefault(d);this.lastCtrl.focus();}catch(b){}}},__getCfg:function(d,b){var c=YAHOO.widget.CalendarNavigator.DEFAULT_CONFIG;var a=this.cal.cfg.getProperty("navigator");if(b){return(a!==true&&a.strings&&a.strings[d])?a.strings[d]:c.strings[d];}else{return(a!==true&&a[d])?a[d]:c[d];}},__isMac:(navigator.userAgent.toLowerCase().indexOf("macintosh")!=-1)};YAHOO.register("calendar",YAHOO.widget.Calendar,{version:"2.9.0",build:"2800"}); \ No newline at end of file diff --git a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/calendar.js b/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/calendar.js deleted file mode 100644 index 05ce3ce3e11..00000000000 --- a/wicket-datetime/src/main/java/org/apache/wicket/extensions/yui/calendar/calendar.js +++ /dev/null @@ -1,7390 +0,0 @@ -/* -Copyright (c) 2011, Yahoo! Inc. All rights reserved. -Code licensed under the BSD License: -http://developer.yahoo.com/yui/license.html -version: 2.9.0 -*/ -(function () { - - /** - * Config is a utility used within an Object to allow the implementer to - * maintain a list of local configuration properties and listen for changes - * to those properties dynamically using CustomEvent. The initial values are - * also maintained so that the configuration can be reset at any given point - * to its initial state. - * @namespace YAHOO.util - * @class Config - * @constructor - * @param {Object} owner The owner Object to which this Config Object belongs - */ - YAHOO.util.Config = function (owner) { - - if (owner) { - this.init(owner); - } - - - }; - - - var Lang = YAHOO.lang, - CustomEvent = YAHOO.util.CustomEvent, - Config = YAHOO.util.Config; - - - /** - * Constant representing the CustomEvent type for the config changed event. - * @property YAHOO.util.Config.CONFIG_CHANGED_EVENT - * @private - * @static - * @final - */ - Config.CONFIG_CHANGED_EVENT = "configChanged"; - - /** - * Constant representing the boolean type string - * @property YAHOO.util.Config.BOOLEAN_TYPE - * @private - * @static - * @final - */ - Config.BOOLEAN_TYPE = "boolean"; - - Config.prototype = { - - /** - * Object reference to the owner of this Config Object - * @property owner - * @type Object - */ - owner: null, - - /** - * Boolean flag that specifies whether a queue is currently - * being executed - * @property queueInProgress - * @type Boolean - */ - queueInProgress: false, - - /** - * Maintains the local collection of configuration property objects and - * their specified values - * @property config - * @private - * @type Object - */ - config: null, - - /** - * Maintains the local collection of configuration property objects as - * they were initially applied. - * This object is used when resetting a property. - * @property initialConfig - * @private - * @type Object - */ - initialConfig: null, - - /** - * Maintains the local, normalized CustomEvent queue - * @property eventQueue - * @private - * @type Object - */ - eventQueue: null, - - /** - * Custom Event, notifying subscribers when Config properties are set - * (setProperty is called without the silent flag - * @event configChangedEvent - */ - configChangedEvent: null, - - /** - * Initializes the configuration Object and all of its local members. - * @method init - * @param {Object} owner The owner Object to which this Config - * Object belongs - */ - init: function (owner) { - - this.owner = owner; - - this.configChangedEvent = - this.createEvent(Config.CONFIG_CHANGED_EVENT); - - this.configChangedEvent.signature = CustomEvent.LIST; - this.queueInProgress = false; - this.config = {}; - this.initialConfig = {}; - this.eventQueue = []; - - }, - - /** - * Validates that the value passed in is a Boolean. - * @method checkBoolean - * @param {Object} val The value to validate - * @return {Boolean} true, if the value is valid - */ - checkBoolean: function (val) { - return (typeof val == Config.BOOLEAN_TYPE); - }, - - /** - * Validates that the value passed in is a number. - * @method checkNumber - * @param {Object} val The value to validate - * @return {Boolean} true, if the value is valid - */ - checkNumber: function (val) { - return (!isNaN(val)); - }, - - /** - * Fires a configuration property event using the specified value. - * @method fireEvent - * @private - * @param {String} key The configuration property's name - * @param {value} Object The value of the correct type for the property - */ - fireEvent: function ( key, value ) { - var property = this.config[key]; - - if (property && property.event) { - property.event.fire(value); - } - }, - - /** - * Adds a property to the Config Object's private config hash. - * @method addProperty - * @param {String} key The configuration property's name - * @param {Object} propertyObject The Object containing all of this - * property's arguments - */ - addProperty: function ( key, propertyObject ) { - key = key.toLowerCase(); - - this.config[key] = propertyObject; - - propertyObject.event = this.createEvent(key, { scope: this.owner }); - propertyObject.event.signature = CustomEvent.LIST; - - - propertyObject.key = key; - - if (propertyObject.handler) { - propertyObject.event.subscribe(propertyObject.handler, - this.owner); - } - - this.setProperty(key, propertyObject.value, true); - - if (! propertyObject.suppressEvent) { - this.queueProperty(key, propertyObject.value); - } - - }, - - /** - * Returns a key-value configuration map of the values currently set in - * the Config Object. - * @method getConfig - * @return {Object} The current config, represented in a key-value map - */ - getConfig: function () { - - var cfg = {}, - currCfg = this.config, - prop, - property; - - for (prop in currCfg) { - if (Lang.hasOwnProperty(currCfg, prop)) { - property = currCfg[prop]; - if (property && property.event) { - cfg[prop] = property.value; - } - } - } - - return cfg; - }, - - /** - * Returns the value of specified property. - * @method getProperty - * @param {String} key The name of the property - * @return {Object} The value of the specified property - */ - getProperty: function (key) { - var property = this.config[key.toLowerCase()]; - if (property && property.event) { - return property.value; - } else { - return undefined; - } - }, - - /** - * Resets the specified property's value to its initial value. - * @method resetProperty - * @param {String} key The name of the property - * @return {Boolean} True is the property was reset, false if not - */ - resetProperty: function (key) { - key = key.toLowerCase(); - - var property = this.config[key]; - - if (property && property.event) { - if (key in this.initialConfig) { - this.setProperty(key, this.initialConfig[key]); - return true; - } - } else { - return false; - } - }, - - /** - * Sets the value of a property. If the silent property is passed as - * true, the property's event will not be fired. - * @method setProperty - * @param {String} key The name of the property - * @param {String} value The value to set the property to - * @param {Boolean} silent Whether the value should be set silently, - * without firing the property event. - * @return {Boolean} True, if the set was successful, false if it failed. - */ - setProperty: function (key, value, silent) { - - var property; - - key = key.toLowerCase(); - - if (this.queueInProgress && ! silent) { - // Currently running through a queue... - this.queueProperty(key,value); - return true; - - } else { - property = this.config[key]; - if (property && property.event) { - if (property.validator && !property.validator(value)) { - return false; - } else { - property.value = value; - if (! silent) { - this.fireEvent(key, value); - this.configChangedEvent.fire([key, value]); - } - return true; - } - } else { - return false; - } - } - }, - - /** - * Sets the value of a property and queues its event to execute. If the - * event is already scheduled to execute, it is - * moved from its current position to the end of the queue. - * @method queueProperty - * @param {String} key The name of the property - * @param {String} value The value to set the property to - * @return {Boolean} true, if the set was successful, false if - * it failed. - */ - queueProperty: function (key, value) { - - key = key.toLowerCase(); - - var property = this.config[key], - foundDuplicate = false, - iLen, - queueItem, - queueItemKey, - queueItemValue, - sLen, - supercedesCheck, - qLen, - queueItemCheck, - queueItemCheckKey, - queueItemCheckValue, - i, - s, - q; - - if (property && property.event) { - - if (!Lang.isUndefined(value) && property.validator && - !property.validator(value)) { // validator - return false; - } else { - - if (!Lang.isUndefined(value)) { - property.value = value; - } else { - value = property.value; - } - - foundDuplicate = false; - iLen = this.eventQueue.length; - - for (i = 0; i < iLen; i++) { - queueItem = this.eventQueue[i]; - - if (queueItem) { - queueItemKey = queueItem[0]; - queueItemValue = queueItem[1]; - - if (queueItemKey == key) { - - /* - found a dupe... push to end of queue, null - current item, and break - */ - - this.eventQueue[i] = null; - - this.eventQueue.push( - [key, (!Lang.isUndefined(value) ? - value : queueItemValue)]); - - foundDuplicate = true; - break; - } - } - } - - // this is a refire, or a new property in the queue - - if (! foundDuplicate && !Lang.isUndefined(value)) { - this.eventQueue.push([key, value]); - } - } - - if (property.supercedes) { - - sLen = property.supercedes.length; - - for (s = 0; s < sLen; s++) { - - supercedesCheck = property.supercedes[s]; - qLen = this.eventQueue.length; - - for (q = 0; q < qLen; q++) { - queueItemCheck = this.eventQueue[q]; - - if (queueItemCheck) { - queueItemCheckKey = queueItemCheck[0]; - queueItemCheckValue = queueItemCheck[1]; - - if (queueItemCheckKey == - supercedesCheck.toLowerCase() ) { - - this.eventQueue.push([queueItemCheckKey, - queueItemCheckValue]); - - this.eventQueue[q] = null; - break; - - } - } - } - } - } - - - return true; - } else { - return false; - } - }, - - /** - * Fires the event for a property using the property's current value. - * @method refireEvent - * @param {String} key The name of the property - */ - refireEvent: function (key) { - - key = key.toLowerCase(); - - var property = this.config[key]; - - if (property && property.event && - - !Lang.isUndefined(property.value)) { - - if (this.queueInProgress) { - - this.queueProperty(key); - - } else { - - this.fireEvent(key, property.value); - - } - - } - }, - - /** - * Applies a key-value Object literal to the configuration, replacing - * any existing values, and queueing the property events. - * Although the values will be set, fireQueue() must be called for their - * associated events to execute. - * @method applyConfig - * @param {Object} userConfig The configuration Object literal - * @param {Boolean} init When set to true, the initialConfig will - * be set to the userConfig passed in, so that calling a reset will - * reset the properties to the passed values. - */ - applyConfig: function (userConfig, init) { - - var sKey, - oConfig; - - if (init) { - oConfig = {}; - for (sKey in userConfig) { - if (Lang.hasOwnProperty(userConfig, sKey)) { - oConfig[sKey.toLowerCase()] = userConfig[sKey]; - } - } - this.initialConfig = oConfig; - } - - for (sKey in userConfig) { - if (Lang.hasOwnProperty(userConfig, sKey)) { - this.queueProperty(sKey, userConfig[sKey]); - } - } - }, - - /** - * Refires the events for all configuration properties using their - * current values. - * @method refresh - */ - refresh: function () { - - var prop; - - for (prop in this.config) { - if (Lang.hasOwnProperty(this.config, prop)) { - this.refireEvent(prop); - } - } - }, - - /** - * Fires the normalized list of queued property change events - * @method fireQueue - */ - fireQueue: function () { - - var i, - queueItem, - key, - value, - property; - - this.queueInProgress = true; - for (i = 0;i < this.eventQueue.length; i++) { - queueItem = this.eventQueue[i]; - if (queueItem) { - - key = queueItem[0]; - value = queueItem[1]; - property = this.config[key]; - - property.value = value; - - // Clear out queue entry, to avoid it being - // re-added to the queue by any queueProperty/supercedes - // calls which are invoked during fireEvent - this.eventQueue[i] = null; - - this.fireEvent(key,value); - } - } - - this.queueInProgress = false; - this.eventQueue = []; - }, - - /** - * Subscribes an external handler to the change event for any - * given property. - * @method subscribeToConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to - * the property's event - * @param {Object} obj The Object to use for scoping the event handler - * (see CustomEvent documentation) - * @param {Boolean} overrideContext Optional. If true, will override - * "this" within the handler to map to the scope Object passed into the - * method. - * @return {Boolean} True, if the subscription was successful, - * otherwise false. - */ - subscribeToConfigEvent: function (key, handler, obj, overrideContext) { - - var property = this.config[key.toLowerCase()]; - - if (property && property.event) { - if (!Config.alreadySubscribed(property.event, handler, obj)) { - property.event.subscribe(handler, obj, overrideContext); - } - return true; - } else { - return false; - } - - }, - - /** - * Unsubscribes an external handler from the change event for any - * given property. - * @method unsubscribeFromConfigEvent - * @param {String} key The property name - * @param {Function} handler The handler function to use subscribe to - * the property's event - * @param {Object} obj The Object to use for scoping the event - * handler (see CustomEvent documentation) - * @return {Boolean} True, if the unsubscription was successful, - * otherwise false. - */ - unsubscribeFromConfigEvent: function (key, handler, obj) { - var property = this.config[key.toLowerCase()]; - if (property && property.event) { - return property.event.unsubscribe(handler, obj); - } else { - return false; - } - }, - - /** - * Returns a string representation of the Config object - * @method toString - * @return {String} The Config object in string format. - */ - toString: function () { - var output = "Config"; - if (this.owner) { - output += " [" + this.owner.toString() + "]"; - } - return output; - }, - - /** - * Returns a string representation of the Config object's current - * CustomEvent queue - * @method outputEventQueue - * @return {String} The string list of CustomEvents currently queued - * for execution - */ - outputEventQueue: function () { - - var output = "", - queueItem, - q, - nQueue = this.eventQueue.length; - - for (q = 0; q < nQueue; q++) { - queueItem = this.eventQueue[q]; - if (queueItem) { - output += queueItem[0] + "=" + queueItem[1] + ", "; - } - } - return output; - }, - - /** - * Sets all properties to null, unsubscribes all listeners from each - * property's change event and all listeners from the configChangedEvent. - * @method destroy - */ - destroy: function () { - - var oConfig = this.config, - sProperty, - oProperty; - - - for (sProperty in oConfig) { - - if (Lang.hasOwnProperty(oConfig, sProperty)) { - - oProperty = oConfig[sProperty]; - - oProperty.event.unsubscribeAll(); - oProperty.event = null; - - } - - } - - this.configChangedEvent.unsubscribeAll(); - - this.configChangedEvent = null; - this.owner = null; - this.config = null; - this.initialConfig = null; - this.eventQueue = null; - - } - - }; - - - - /** - * Checks to determine if a particular function/Object pair are already - * subscribed to the specified CustomEvent - * @method YAHOO.util.Config.alreadySubscribed - * @static - * @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check - * the subscriptions - * @param {Function} fn The function to look for in the subscribers list - * @param {Object} obj The execution scope Object for the subscription - * @return {Boolean} true, if the function/Object pair is already subscribed - * to the CustomEvent passed in - */ - Config.alreadySubscribed = function (evt, fn, obj) { - - var nSubscribers = evt.subscribers.length, - subsc, - i; - - if (nSubscribers > 0) { - i = nSubscribers - 1; - do { - subsc = evt.subscribers[i]; - if (subsc && subsc.obj == obj && subsc.fn == fn) { - return true; - } - } - while (i--); - } - - return false; - - }; - - YAHOO.lang.augmentProto(Config, YAHOO.util.EventProvider); - -}()); -/** -* The datemath module provides utility methods for basic JavaScript Date object manipulation and -* comparison. -* -* @module datemath -*/ - -/** -* YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility -* used for adding, subtracting, and comparing dates. -* @namespace YAHOO.widget -* @class DateMath -*/ -YAHOO.widget.DateMath = { - /** - * Constant field representing Day - * @property DAY - * @static - * @final - * @type String - */ - DAY : "D", - - /** - * Constant field representing Week - * @property WEEK - * @static - * @final - * @type String - */ - WEEK : "W", - - /** - * Constant field representing Year - * @property YEAR - * @static - * @final - * @type String - */ - YEAR : "Y", - - /** - * Constant field representing Month - * @property MONTH - * @static - * @final - * @type String - */ - MONTH : "M", - - /** - * Constant field representing one day, in milliseconds - * @property ONE_DAY_MS - * @static - * @final - * @type Number - */ - ONE_DAY_MS : 1000*60*60*24, - - /** - * Constant field representing the date in first week of January - * which identifies the first week of the year. - *

- * In the U.S, Jan 1st is normally used based on a Sunday start of week. - * ISO 8601, used widely throughout Europe, uses Jan 4th, based on a Monday start of week. - *

- * @property WEEK_ONE_JAN_DATE - * @static - * @type Number - */ - WEEK_ONE_JAN_DATE : 1, - - /** - * Adds the specified amount of time to the this instance. - * @method add - * @param {Date} date The JavaScript Date object to perform addition on - * @param {String} field The field constant to be used for performing addition. - * @param {Number} amount The number of units (measured in the field constant) to add to the date. - * @return {Date} The resulting Date object - */ - add : function(date, field, amount) { - var d = new Date(date.getTime()); - switch (field) { - case this.MONTH: - var newMonth = date.getMonth() + amount; - var years = 0; - - if (newMonth < 0) { - while (newMonth < 0) { - newMonth += 12; - years -= 1; - } - } else if (newMonth > 11) { - while (newMonth > 11) { - newMonth -= 12; - years += 1; - } - } - - d.setMonth(newMonth); - d.setFullYear(date.getFullYear() + years); - break; - case this.DAY: - this._addDays(d, amount); - // d.setDate(date.getDate() + amount); - break; - case this.YEAR: - d.setFullYear(date.getFullYear() + amount); - break; - case this.WEEK: - this._addDays(d, (amount * 7)); - // d.setDate(date.getDate() + (amount * 7)); - break; - } - return d; - }, - - /** - * Private helper method to account for bug in Safari 2 (webkit < 420) - * when Date.setDate(n) is called with n less than -128 or greater than 127. - *

- * Fix approach and original findings are available here: - * http://brianary.blogspot.com/2006/03/safari-date-bug.html - *

- * @method _addDays - * @param {Date} d JavaScript date object - * @param {Number} nDays The number of days to add to the date object (can be negative) - * @private - */ - _addDays : function(d, nDays) { - if (YAHOO.env.ua.webkit && YAHOO.env.ua.webkit < 420) { - if (nDays < 0) { - // Ensure we don't go below -128 (getDate() is always 1 to 31, so we won't go above 127) - for(var min = -128; nDays < min; nDays -= min) { - d.setDate(d.getDate() + min); - } - } else { - // Ensure we don't go above 96 + 31 = 127 - for(var max = 96; nDays > max; nDays -= max) { - d.setDate(d.getDate() + max); - } - } - // nDays should be remainder between -128 and 96 - } - d.setDate(d.getDate() + nDays); - }, - - /** - * Subtracts the specified amount of time from the this instance. - * @method subtract - * @param {Date} date The JavaScript Date object to perform subtraction on - * @param {Number} field The this field constant to be used for performing subtraction. - * @param {Number} amount The number of units (measured in the field constant) to subtract from the date. - * @return {Date} The resulting Date object - */ - subtract : function(date, field, amount) { - return this.add(date, field, (amount*-1)); - }, - - /** - * Determines whether a given date is before another date on the calendar. - * @method before - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs before the compared date; false if not. - */ - before : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() < ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is after another date on the calendar. - * @method after - * @param {Date} date The Date object to compare with the compare argument - * @param {Date} compareTo The Date object to use for the comparison - * @return {Boolean} true if the date occurs after the compared date; false if not. - */ - after : function(date, compareTo) { - var ms = compareTo.getTime(); - if (date.getTime() > ms) { - return true; - } else { - return false; - } - }, - - /** - * Determines whether a given date is between two other dates on the calendar. - * @method between - * @param {Date} date The date to check for - * @param {Date} dateBegin The start of the range - * @param {Date} dateEnd The end of the range - * @return {Boolean} true if the date occurs between the compared dates; false if not. - */ - between : function(date, dateBegin, dateEnd) { - if (this.after(date, dateBegin) && this.before(date, dateEnd)) { - return true; - } else { - return false; - } - }, - - /** - * Retrieves a JavaScript Date object representing January 1 of any given year. - * @method getJan1 - * @param {Number} calendarYear The calendar year for which to retrieve January 1 - * @return {Date} January 1 of the calendar year specified. - */ - getJan1 : function(calendarYear) { - return this.getDate(calendarYear,0,1); - }, - - /** - * Calculates the number of days the specified date is from January 1 of the specified calendar year. - * Passing January 1 to this function would return an offset value of zero. - * @method getDayOffset - * @param {Date} date The JavaScript date for which to find the offset - * @param {Number} calendarYear The calendar year to use for determining the offset - * @return {Number} The number of days since January 1 of the given year - */ - getDayOffset : function(date, calendarYear) { - var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1. - - // Find the number of days the passed in date is away from the calendar year start - var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS); - return dayOffset; - }, - - /** - * Calculates the week number for the given date. Can currently support standard - * U.S. week numbers, based on Jan 1st defining the 1st week of the year, and - * ISO8601 week numbers, based on Jan 4th defining the 1st week of the year. - * - * @method getWeekNumber - * @param {Date} date The JavaScript date for which to find the week number - * @param {Number} firstDayOfWeek The index of the first day of the week (0 = Sun, 1 = Mon ... 6 = Sat). - * Defaults to 0 - * @param {Number} janDate The date in the first week of January which defines week one for the year - * Defaults to the value of YAHOO.widget.DateMath.WEEK_ONE_JAN_DATE, which is 1 (Jan 1st). - * For the U.S, this is normally Jan 1st. ISO8601 uses Jan 4th to define the first week of the year. - * - * @return {Number} The number of the week containing the given date. - */ - getWeekNumber : function(date, firstDayOfWeek, janDate) { - - // Setup Defaults - firstDayOfWeek = firstDayOfWeek || 0; - janDate = janDate || this.WEEK_ONE_JAN_DATE; - - var targetDate = this.clearTime(date), - startOfWeek, - endOfWeek; - - if (targetDate.getDay() === firstDayOfWeek) { - startOfWeek = targetDate; - } else { - startOfWeek = this.getFirstDayOfWeek(targetDate, firstDayOfWeek); - } - - var startYear = startOfWeek.getFullYear(); - - // DST shouldn't be a problem here, math is quicker than setDate(); - endOfWeek = new Date(startOfWeek.getTime() + 6*this.ONE_DAY_MS); - - var weekNum; - if (startYear !== endOfWeek.getFullYear() && endOfWeek.getDate() >= janDate) { - // If years don't match, endOfWeek is in Jan. and if the - // week has WEEK_ONE_JAN_DATE in it, it's week one by definition. - weekNum = 1; - } else { - // Get the 1st day of the 1st week, and - // find how many days away we are from it. - var weekOne = this.clearTime(this.getDate(startYear, 0, janDate)), - weekOneDayOne = this.getFirstDayOfWeek(weekOne, firstDayOfWeek); - - // Round days to smoothen out 1 hr DST diff - var daysDiff = Math.round((targetDate.getTime() - weekOneDayOne.getTime())/this.ONE_DAY_MS); - - // Calc. Full Weeks - var rem = daysDiff % 7; - var weeksDiff = (daysDiff - rem)/7; - weekNum = weeksDiff + 1; - } - return weekNum; - }, - - /** - * Get the first day of the week, for the give date. - * @param {Date} dt The date in the week for which the first day is required. - * @param {Number} startOfWeek The index for the first day of the week, 0 = Sun, 1 = Mon ... 6 = Sat (defaults to 0) - * @return {Date} The first day of the week - */ - getFirstDayOfWeek : function (dt, startOfWeek) { - startOfWeek = startOfWeek || 0; - var dayOfWeekIndex = dt.getDay(), - dayOfWeek = (dayOfWeekIndex - startOfWeek + 7) % 7; - - return this.subtract(dt, this.DAY, dayOfWeek); - }, - - /** - * Determines if a given week overlaps two different years. - * @method isYearOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different years. - */ - isYearOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Determines if a given week overlaps two different months. - * @method isMonthOverlapWeek - * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week. - * @return {Boolean} true if the date overlaps two different months. - */ - isMonthOverlapWeek : function(weekBeginDate) { - var overlaps = false; - var nextWeek = this.add(weekBeginDate, this.DAY, 6); - if (nextWeek.getMonth() != weekBeginDate.getMonth()) { - overlaps = true; - } - return overlaps; - }, - - /** - * Gets the first day of a month containing a given date. - * @method findMonthStart - * @param {Date} date The JavaScript Date used to calculate the month start - * @return {Date} The JavaScript Date representing the first day of the month - */ - findMonthStart : function(date) { - var start = this.getDate(date.getFullYear(), date.getMonth(), 1); - return start; - }, - - /** - * Gets the last day of a month containing a given date. - * @method findMonthEnd - * @param {Date} date The JavaScript Date used to calculate the month end - * @return {Date} The JavaScript Date representing the last day of the month - */ - findMonthEnd : function(date) { - var start = this.findMonthStart(date); - var nextMonth = this.add(start, this.MONTH, 1); - var end = this.subtract(nextMonth, this.DAY, 1); - return end; - }, - - /** - * Clears the time fields from a given date, effectively setting the time to 12 noon. - * @method clearTime - * @param {Date} date The JavaScript Date for which the time fields will be cleared - * @return {Date} The JavaScript Date cleared of all time fields - */ - clearTime : function(date) { - date.setHours(12,0,0,0); - return date; - }, - - /** - * Returns a new JavaScript Date object, representing the given year, month and date. Time fields (hr, min, sec, ms) on the new Date object - * are set to 0. The method allows Date instances to be created with the a year less than 100. "new Date(year, month, date)" implementations - * set the year to 19xx if a year (xx) which is less than 100 is provided. - *

- * NOTE:Validation on argument values is not performed. It is the caller's responsibility to ensure - * arguments are valid as per the ECMAScript-262 Date object specification for the new Date(year, month[, date]) constructor. - *

- * @method getDate - * @param {Number} y Year. - * @param {Number} m Month index from 0 (Jan) to 11 (Dec). - * @param {Number} d (optional) Date from 1 to 31. If not provided, defaults to 1. - * @return {Date} The JavaScript date object with year, month, date set as provided. - */ - getDate : function(y, m, d) { - var dt = null; - if (YAHOO.lang.isUndefined(d)) { - d = 1; - } - if (y >= 100) { - dt = new Date(y, m, d); - } else { - dt = new Date(); - dt.setFullYear(y); - dt.setMonth(m); - dt.setDate(d); - dt.setHours(0,0,0,0); - } - return dt; - } -}; -/** -* The Calendar component is a UI control that enables users to choose one or more dates from a graphical calendar presented in a one-month or -* multi-month interface. Calendars are generated entirely via script and can be navigated without any page refreshes. -* @module calendar -* @title Calendar -* @namespace YAHOO.widget -* @requires yahoo,dom,event -*/ -(function(){ - - var Dom = YAHOO.util.Dom, - Event = YAHOO.util.Event, - Lang = YAHOO.lang, - DateMath = YAHOO.widget.DateMath; - -/** -* Calendar is the base class for the Calendar widget. In its most basic -* implementation, it has the ability to render a calendar widget on the page -* that can be manipulated to select a single date, move back and forth between -* months and years. -*

To construct the placeholder for the calendar widget, the code is as -* follows: -*

-* <div id="calContainer"></div> -* -*

-*

-* NOTE: As of 2.4.0, the constructor's ID argument is optional. -* The Calendar can be constructed by simply providing a container ID string, -* or a reference to a container DIV HTMLElement (the element needs to exist -* in the document). -* -* E.g.: -*

-* var c = new YAHOO.widget.Calendar("calContainer", configOptions); -* -* or: -* -* var containerDiv = YAHOO.util.Dom.get("calContainer"); -* var c = new YAHOO.widget.Calendar(containerDiv, configOptions); -* -*

-*

-* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. -* For example if an ID is not provided, and the container's ID is "calContainer", the Calendar's ID will be set to "calContainer_t". -*

-* -* @namespace YAHOO.widget -* @class Calendar -* @constructor -* @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional. -* @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document. -* @param {Object} config optional The configuration object containing the initial configuration values for the Calendar. -*/ -function Calendar(id, containerId, config) { - this.init.apply(this, arguments); -} - -/** -* The path to be used for images loaded for the Calendar -* @property YAHOO.widget.Calendar.IMG_ROOT -* @static -* @deprecated You can now customize images by overriding the calclose, calnavleft and calnavright default CSS classes for the close icon, left arrow and right arrow respectively -* @type String -*/ -Calendar.IMG_ROOT = null; - -/** -* Type constant used for renderers to represent an individual date (M/D/Y) -* @property YAHOO.widget.Calendar.DATE -* @static -* @final -* @type String -*/ -Calendar.DATE = "D"; - -/** -* Type constant used for renderers to represent an individual date across any year (M/D) -* @property YAHOO.widget.Calendar.MONTH_DAY -* @static -* @final -* @type String -*/ -Calendar.MONTH_DAY = "MD"; - -/** -* Type constant used for renderers to represent a weekday -* @property YAHOO.widget.Calendar.WEEKDAY -* @static -* @final -* @type String -*/ -Calendar.WEEKDAY = "WD"; - -/** -* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y) -* @property YAHOO.widget.Calendar.RANGE -* @static -* @final -* @type String -*/ -Calendar.RANGE = "R"; - -/** -* Type constant used for renderers to represent a month across any year -* @property YAHOO.widget.Calendar.MONTH -* @static -* @final -* @type String -*/ -Calendar.MONTH = "M"; - -/** -* Constant that represents the total number of date cells that are displayed in a given month -* @property YAHOO.widget.Calendar.DISPLAY_DAYS -* @static -* @final -* @type Number -*/ -Calendar.DISPLAY_DAYS = 42; - -/** -* Constant used for halting the execution of the remainder of the render stack -* @property YAHOO.widget.Calendar.STOP_RENDER -* @static -* @final -* @type String -*/ -Calendar.STOP_RENDER = "S"; - -/** -* Constant used to represent short date field string formats (e.g. Tu or Feb) -* @property YAHOO.widget.Calendar.SHORT -* @static -* @final -* @type String -*/ -Calendar.SHORT = "short"; - -/** -* Constant used to represent long date field string formats (e.g. Monday or February) -* @property YAHOO.widget.Calendar.LONG -* @static -* @final -* @type String -*/ -Calendar.LONG = "long"; - -/** -* Constant used to represent medium date field string formats (e.g. Mon) -* @property YAHOO.widget.Calendar.MEDIUM -* @static -* @final -* @type String -*/ -Calendar.MEDIUM = "medium"; - -/** -* Constant used to represent single character date field string formats (e.g. M, T, W) -* @property YAHOO.widget.Calendar.ONE_CHAR -* @static -* @final -* @type String -*/ -Calendar.ONE_CHAR = "1char"; - -/** -* The set of default Config property keys and values for the Calendar. -* -*

-* NOTE: This property is made public in order to allow users to change -* the default values of configuration properties. Users should not -* modify the key string, unless they are overriding the Calendar implementation -*

-* -*

-* The property is an object with key/value pairs, the key being the -* uppercase configuration property name and the value being an object -* literal with a key string property, and a value property, specifying the -* default value of the property. To override a default value, you can set -* the value property, for example, YAHOO.widget.Calendar.DEFAULT_CONFIG.MULTI_SELECT.value = true; -* -* @property YAHOO.widget.Calendar.DEFAULT_CONFIG -* @static -* @type Object -*/ - -Calendar.DEFAULT_CONFIG = { - YEAR_OFFSET : {key:"year_offset", value:0, supercedes:["pagedate", "selected", "mindate","maxdate"]}, - TODAY : {key:"today", value:new Date(), supercedes:["pagedate"]}, - PAGEDATE : {key:"pagedate", value:null}, - SELECTED : {key:"selected", value:[]}, - TITLE : {key:"title", value:""}, - CLOSE : {key:"close", value:false}, - IFRAME : {key:"iframe", value:(YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) ? true : false}, - MINDATE : {key:"mindate", value:null}, - MAXDATE : {key:"maxdate", value:null}, - MULTI_SELECT : {key:"multi_select", value:false}, - OOM_SELECT : {key:"oom_select", value:false}, - START_WEEKDAY : {key:"start_weekday", value:0}, - SHOW_WEEKDAYS : {key:"show_weekdays", value:true}, - SHOW_WEEK_HEADER : {key:"show_week_header", value:false}, - SHOW_WEEK_FOOTER : {key:"show_week_footer", value:false}, - HIDE_BLANK_WEEKS : {key:"hide_blank_weeks", value:false}, - NAV_ARROW_LEFT: {key:"nav_arrow_left", value:null} , - NAV_ARROW_RIGHT : {key:"nav_arrow_right", value:null} , - MONTHS_SHORT : {key:"months_short", value:["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]}, - MONTHS_LONG: {key:"months_long", value:["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]}, - WEEKDAYS_1CHAR: {key:"weekdays_1char", value:["S", "M", "T", "W", "T", "F", "S"]}, - WEEKDAYS_SHORT: {key:"weekdays_short", value:["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]}, - WEEKDAYS_MEDIUM: {key:"weekdays_medium", value:["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]}, - WEEKDAYS_LONG: {key:"weekdays_long", value:["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]}, - LOCALE_MONTHS:{key:"locale_months", value:"long"}, - LOCALE_WEEKDAYS:{key:"locale_weekdays", value:"short"}, - DATE_DELIMITER:{key:"date_delimiter", value:","}, - DATE_FIELD_DELIMITER:{key:"date_field_delimiter", value:"/"}, - DATE_RANGE_DELIMITER:{key:"date_range_delimiter", value:"-"}, - MY_MONTH_POSITION:{key:"my_month_position", value:1}, - MY_YEAR_POSITION:{key:"my_year_position", value:2}, - MD_MONTH_POSITION:{key:"md_month_position", value:1}, - MD_DAY_POSITION:{key:"md_day_position", value:2}, - MDY_MONTH_POSITION:{key:"mdy_month_position", value:1}, - MDY_DAY_POSITION:{key:"mdy_day_position", value:2}, - MDY_YEAR_POSITION:{key:"mdy_year_position", value:3}, - MY_LABEL_MONTH_POSITION:{key:"my_label_month_position", value:1}, - MY_LABEL_YEAR_POSITION:{key:"my_label_year_position", value:2}, - MY_LABEL_MONTH_SUFFIX:{key:"my_label_month_suffix", value:" "}, - MY_LABEL_YEAR_SUFFIX:{key:"my_label_year_suffix", value:""}, - NAV: {key:"navigator", value: null}, - STRINGS : { - key:"strings", - value: { - previousMonth : "Previous Month", - nextMonth : "Next Month", - close: "Close" - }, - supercedes : ["close", "title"] - } -}; - -/** -* The set of default Config property keys and values for the Calendar -* @property YAHOO.widget.Calendar._DEFAULT_CONFIG -* @deprecated Made public. See the public DEFAULT_CONFIG property for details -* @final -* @static -* @private -* @type Object -*/ -Calendar._DEFAULT_CONFIG = Calendar.DEFAULT_CONFIG; - -var DEF_CFG = Calendar.DEFAULT_CONFIG; - -/** -* The set of Custom Event types supported by the Calendar -* @property YAHOO.widget.Calendar._EVENT_TYPES -* @final -* @static -* @private -* @type Object -*/ -Calendar._EVENT_TYPES = { - BEFORE_SELECT : "beforeSelect", - SELECT : "select", - BEFORE_DESELECT : "beforeDeselect", - DESELECT : "deselect", - CHANGE_PAGE : "changePage", - BEFORE_RENDER : "beforeRender", - RENDER : "render", - BEFORE_DESTROY : "beforeDestroy", - DESTROY : "destroy", - RESET : "reset", - CLEAR : "clear", - BEFORE_HIDE : "beforeHide", - HIDE : "hide", - BEFORE_SHOW : "beforeShow", - SHOW : "show", - BEFORE_HIDE_NAV : "beforeHideNav", - HIDE_NAV : "hideNav", - BEFORE_SHOW_NAV : "beforeShowNav", - SHOW_NAV : "showNav", - BEFORE_RENDER_NAV : "beforeRenderNav", - RENDER_NAV : "renderNav" -}; - -/** -* The set of default style constants for the Calendar -* @property YAHOO.widget.Calendar.STYLES -* @static -* @type Object An object with name/value pairs for the class name identifier/value. -*/ -Calendar.STYLES = { - CSS_ROW_HEADER: "calrowhead", - CSS_ROW_FOOTER: "calrowfoot", - CSS_CELL : "calcell", - CSS_CELL_SELECTOR : "selector", - CSS_CELL_SELECTED : "selected", - CSS_CELL_SELECTABLE : "selectable", - CSS_CELL_RESTRICTED : "restricted", - CSS_CELL_TODAY : "today", - CSS_CELL_OOM : "oom", - CSS_CELL_OOB : "previous", - CSS_HEADER : "calheader", - CSS_HEADER_TEXT : "calhead", - CSS_BODY : "calbody", - CSS_WEEKDAY_CELL : "calweekdaycell", - CSS_WEEKDAY_ROW : "calweekdayrow", - CSS_FOOTER : "calfoot", - CSS_CALENDAR : "yui-calendar", - CSS_SINGLE : "single", - CSS_CONTAINER : "yui-calcontainer", - CSS_NAV_LEFT : "calnavleft", - CSS_NAV_RIGHT : "calnavright", - CSS_NAV : "calnav", - CSS_CLOSE : "calclose", - CSS_CELL_TOP : "calcelltop", - CSS_CELL_LEFT : "calcellleft", - CSS_CELL_RIGHT : "calcellright", - CSS_CELL_BOTTOM : "calcellbottom", - CSS_CELL_HOVER : "calcellhover", - CSS_CELL_HIGHLIGHT1 : "highlight1", - CSS_CELL_HIGHLIGHT2 : "highlight2", - CSS_CELL_HIGHLIGHT3 : "highlight3", - CSS_CELL_HIGHLIGHT4 : "highlight4", - CSS_WITH_TITLE: "withtitle", - CSS_FIXED_SIZE: "fixedsize", - CSS_LINK_CLOSE: "link-close" -}; - -/** -* The set of default style constants for the Calendar -* @property YAHOO.widget.Calendar._STYLES -* @deprecated Made public. See the public STYLES property for details -* @final -* @static -* @private -* @type Object -*/ -Calendar._STYLES = Calendar.STYLES; - -Calendar.prototype = { - - /** - * The configuration object used to set up the calendars various locale and style options. - * @property Config - * @private - * @deprecated Configuration properties should be set by calling Calendar.cfg.setProperty. - * @type Object - */ - Config : null, - - /** - * The parent CalendarGroup, only to be set explicitly by the parent group - * @property parent - * @type CalendarGroup - */ - parent : null, - - /** - * The index of this item in the parent group - * @property index - * @type Number - */ - index : -1, - - /** - * The collection of calendar table cells - * @property cells - * @type HTMLTableCellElement[] - */ - cells : null, - - /** - * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D]. - * @property cellDates - * @type Array[](Number[]) - */ - cellDates : null, - - /** - * The id that uniquely identifies this Calendar. - * @property id - * @type String - */ - id : null, - - /** - * The unique id associated with the Calendar's container - * @property containerId - * @type String - */ - containerId: null, - - /** - * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered. - * @property oDomContainer - * @type HTMLElement - */ - oDomContainer : null, - - /** - * A Date object representing today's date. - * @deprecated Use the "today" configuration property - * @property today - * @type Date - */ - today : null, - - /** - * The list of render functions, along with required parameters, used to render cells. - * @property renderStack - * @type Array[] - */ - renderStack : null, - - /** - * A copy of the initial render functions created before rendering. - * @property _renderStack - * @private - * @type Array - */ - _renderStack : null, - - /** - * A reference to the CalendarNavigator instance created for this Calendar. - * Will be null if the "navigator" configuration property has not been set - * @property oNavigator - * @type CalendarNavigator - */ - oNavigator : null, - - /** - * The private list of initially selected dates. - * @property _selectedDates - * @private - * @type Array - */ - _selectedDates : null, - - /** - * A map of DOM event handlers to attach to cells associated with specific CSS class names - * @property domEventMap - * @type Object - */ - domEventMap : null, - - /** - * Protected helper used to parse Calendar constructor/init arguments. - * - * As of 2.4.0, Calendar supports a simpler constructor - * signature. This method reconciles arguments - * received in the pre 2.4.0 and 2.4.0 formats. - * - * @protected - * @method _parseArgs - * @param {Array} Function "arguments" array - * @return {Object} Object with id, container, config properties containing - * the reconciled argument values. - **/ - _parseArgs : function(args) { - /* - 2.4.0 Constructors signatures - - new Calendar(String) - new Calendar(HTMLElement) - new Calendar(String, ConfigObject) - new Calendar(HTMLElement, ConfigObject) - - Pre 2.4.0 Constructor signatures - - new Calendar(String, String) - new Calendar(String, HTMLElement) - new Calendar(String, String, ConfigObject) - new Calendar(String, HTMLElement, ConfigObject) - */ - var nArgs = {id:null, container:null, config:null}; - - if (args && args.length && args.length > 0) { - switch (args.length) { - case 1: - nArgs.id = null; - nArgs.container = args[0]; - nArgs.config = null; - break; - case 2: - if (Lang.isObject(args[1]) && !args[1].tagName && !(args[1] instanceof String)) { - nArgs.id = null; - nArgs.container = args[0]; - nArgs.config = args[1]; - } else { - nArgs.id = args[0]; - nArgs.container = args[1]; - nArgs.config = null; - } - break; - default: // 3+ - nArgs.id = args[0]; - nArgs.container = args[1]; - nArgs.config = args[2]; - break; - } - } else { - } - return nArgs; - }, - - /** - * Initializes the Calendar widget. - * @method init - * - * @param {String} id optional The id of the table element that will represent the Calendar widget. As of 2.4.0, this argument is optional. - * @param {String | HTMLElement} container The id of the container div element that will wrap the Calendar table, or a reference to a DIV element which exists in the document. - * @param {Object} config optional The configuration object containing the initial configuration values for the Calendar. - */ - init : function(id, container, config) { - // Normalize 2.4.0, pre 2.4.0 args - var nArgs = this._parseArgs(arguments); - - id = nArgs.id; - container = nArgs.container; - config = nArgs.config; - - this.oDomContainer = Dom.get(container); - - this._oDoc = this.oDomContainer.ownerDocument; - - if (!this.oDomContainer.id) { - this.oDomContainer.id = Dom.generateId(); - } - - if (!id) { - id = this.oDomContainer.id + "_t"; - } - - this.id = id; - this.containerId = this.oDomContainer.id; - - this.initEvents(); - - /** - * The Config object used to hold the configuration variables for the Calendar - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the Calendar's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the Calendar's locale settings - * @property Locale - * @type Object - */ - this.Locale = {}; - - this.initStyles(); - - Dom.addClass(this.oDomContainer, this.Style.CSS_CONTAINER); - Dom.addClass(this.oDomContainer, this.Style.CSS_SINGLE); - - this.cellDates = []; - this.cells = []; - this.renderStack = []; - this._renderStack = []; - - this.setupConfig(); - - if (config) { - this.cfg.applyConfig(config, true); - } - - this.cfg.fireQueue(); - - this.today = this.cfg.getProperty("today"); - }, - - /** - * Default Config listener for the iframe property. If the iframe config property is set to true, - * renders the built-in IFRAME shim if the container is relatively or absolutely positioned. - * - * @method configIframe - */ - configIframe : function(type, args, obj) { - var useIframe = args[0]; - - if (!this.parent) { - if (Dom.inDocument(this.oDomContainer)) { - if (useIframe) { - var pos = Dom.getStyle(this.oDomContainer, "position"); - - if (pos == "absolute" || pos == "relative") { - - if (!Dom.inDocument(this.iframe)) { - this.iframe = document.createElement("iframe"); - this.iframe.src = "javascript:false;"; - - Dom.setStyle(this.iframe, "opacity", "0"); - - if (YAHOO.env.ua.ie && YAHOO.env.ua.ie <= 6) { - Dom.addClass(this.iframe, this.Style.CSS_FIXED_SIZE); - } - - this.oDomContainer.insertBefore(this.iframe, this.oDomContainer.firstChild); - } - } - } else { - if (this.iframe) { - if (this.iframe.parentNode) { - this.iframe.parentNode.removeChild(this.iframe); - } - this.iframe = null; - } - } - } - } - }, - - /** - * Default handler for the "title" property - * @method configTitle - */ - configTitle : function(type, args, obj) { - var title = args[0]; - - // "" disables title bar - if (title) { - this.createTitleBar(title); - } else { - var close = this.cfg.getProperty(DEF_CFG.CLOSE.key); - if (!close) { - this.removeTitleBar(); - } else { - this.createTitleBar(" "); - } - } - }, - - /** - * Default handler for the "close" property - * @method configClose - */ - configClose : function(type, args, obj) { - var close = args[0], - title = this.cfg.getProperty(DEF_CFG.TITLE.key); - - if (close) { - if (!title) { - this.createTitleBar(" "); - } - this.createCloseButton(); - } else { - this.removeCloseButton(); - if (!title) { - this.removeTitleBar(); - } - } - }, - - /** - * Initializes Calendar's built-in CustomEvents - * @method initEvents - */ - initEvents : function() { - - var defEvents = Calendar._EVENT_TYPES, - CE = YAHOO.util.CustomEvent, - cal = this; // To help with minification - - /** - * Fired before a date selection is made - * @event beforeSelectEvent - */ - cal.beforeSelectEvent = new CE(defEvents.BEFORE_SELECT); - - /** - * Fired when a date selection is made - * @event selectEvent - * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. - */ - cal.selectEvent = new CE(defEvents.SELECT); - - /** - * Fired before a date or set of dates is deselected - * @event beforeDeselectEvent - */ - cal.beforeDeselectEvent = new CE(defEvents.BEFORE_DESELECT); - - /** - * Fired when a date or set of dates is deselected - * @event deselectEvent - * @param {Array} Array of Date field arrays in the format [YYYY, MM, DD]. - */ - cal.deselectEvent = new CE(defEvents.DESELECT); - - /** - * Fired when the Calendar page is changed - * @event changePageEvent - * @param {Date} prevDate The date before the page was changed - * @param {Date} newDate The date after the page was changed - */ - cal.changePageEvent = new CE(defEvents.CHANGE_PAGE); - - /** - * Fired before the Calendar is rendered - * @event beforeRenderEvent - */ - cal.beforeRenderEvent = new CE(defEvents.BEFORE_RENDER); - - /** - * Fired when the Calendar is rendered - * @event renderEvent - */ - cal.renderEvent = new CE(defEvents.RENDER); - - /** - * Fired just before the Calendar is to be destroyed - * @event beforeDestroyEvent - */ - cal.beforeDestroyEvent = new CE(defEvents.BEFORE_DESTROY); - - /** - * Fired after the Calendar is destroyed. This event should be used - * for notification only. When this event is fired, important Calendar instance - * properties, dom references and event listeners have already been - * removed/dereferenced, and hence the Calendar instance is not in a usable - * state. - * - * @event destroyEvent - */ - cal.destroyEvent = new CE(defEvents.DESTROY); - - /** - * Fired when the Calendar is reset - * @event resetEvent - */ - cal.resetEvent = new CE(defEvents.RESET); - - /** - * Fired when the Calendar is cleared - * @event clearEvent - */ - cal.clearEvent = new CE(defEvents.CLEAR); - - /** - * Fired just before the Calendar is to be shown - * @event beforeShowEvent - */ - cal.beforeShowEvent = new CE(defEvents.BEFORE_SHOW); - - /** - * Fired after the Calendar is shown - * @event showEvent - */ - cal.showEvent = new CE(defEvents.SHOW); - - /** - * Fired just before the Calendar is to be hidden - * @event beforeHideEvent - */ - cal.beforeHideEvent = new CE(defEvents.BEFORE_HIDE); - - /** - * Fired after the Calendar is hidden - * @event hideEvent - */ - cal.hideEvent = new CE(defEvents.HIDE); - - /** - * Fired just before the CalendarNavigator is to be shown - * @event beforeShowNavEvent - */ - cal.beforeShowNavEvent = new CE(defEvents.BEFORE_SHOW_NAV); - - /** - * Fired after the CalendarNavigator is shown - * @event showNavEvent - */ - cal.showNavEvent = new CE(defEvents.SHOW_NAV); - - /** - * Fired just before the CalendarNavigator is to be hidden - * @event beforeHideNavEvent - */ - cal.beforeHideNavEvent = new CE(defEvents.BEFORE_HIDE_NAV); - - /** - * Fired after the CalendarNavigator is hidden - * @event hideNavEvent - */ - cal.hideNavEvent = new CE(defEvents.HIDE_NAV); - - /** - * Fired just before the CalendarNavigator is to be rendered - * @event beforeRenderNavEvent - */ - cal.beforeRenderNavEvent = new CE(defEvents.BEFORE_RENDER_NAV); - - /** - * Fired after the CalendarNavigator is rendered - * @event renderNavEvent - */ - cal.renderNavEvent = new CE(defEvents.RENDER_NAV); - - cal.beforeSelectEvent.subscribe(cal.onBeforeSelect, this, true); - cal.selectEvent.subscribe(cal.onSelect, this, true); - cal.beforeDeselectEvent.subscribe(cal.onBeforeDeselect, this, true); - cal.deselectEvent.subscribe(cal.onDeselect, this, true); - cal.changePageEvent.subscribe(cal.onChangePage, this, true); - cal.renderEvent.subscribe(cal.onRender, this, true); - cal.resetEvent.subscribe(cal.onReset, this, true); - cal.clearEvent.subscribe(cal.onClear, this, true); - }, - - /** - * The default event handler for clicks on the "Previous Month" navigation UI - * - * @method doPreviousMonthNav - * @param {DOMEvent} e The DOM event - * @param {Calendar} cal A reference to the calendar - */ - doPreviousMonthNav : function(e, cal) { - Event.preventDefault(e); - // previousMonth invoked in a timeout, to allow - // event to bubble up, with correct target. Calling - // previousMonth, will call render which will remove - // HTML which generated the event, resulting in an - // invalid event target in certain browsers. - setTimeout(function() { - cal.previousMonth(); - var navs = Dom.getElementsByClassName(cal.Style.CSS_NAV_LEFT, "a", cal.oDomContainer); - if (navs && navs[0]) { - try { - navs[0].focus(); - } catch (ex) { - // ignore - } - } - }, 0); - }, - - /** - * The default event handler for clicks on the "Next Month" navigation UI - * - * @method doNextMonthNav - * @param {DOMEvent} e The DOM event - * @param {Calendar} cal A reference to the calendar - */ - doNextMonthNav : function(e, cal) { - Event.preventDefault(e); - setTimeout(function() { - cal.nextMonth(); - var navs = Dom.getElementsByClassName(cal.Style.CSS_NAV_RIGHT, "a", cal.oDomContainer); - if (navs && navs[0]) { - try { - navs[0].focus(); - } catch (ex) { - // ignore - } - } - }, 0); - }, - - /** - * The default event handler for date cell selection. Currently attached to - * the Calendar's bounding box, referenced by it's oDomContainer property. - * - * @method doSelectCell - * @param {DOMEvent} e The DOM event - * @param {Calendar} cal A reference to the calendar - */ - doSelectCell : function(e, cal) { - var cell, d, date, index; - - var target = Event.getTarget(e), - tagName = target.tagName.toLowerCase(), - defSelector = false; - - while (tagName != "td" && !Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - - if (!defSelector && tagName == "a" && Dom.hasClass(target, cal.Style.CSS_CELL_SELECTOR)) { - defSelector = true; - } - - target = target.parentNode; - tagName = target.tagName.toLowerCase(); - - if (target == this.oDomContainer || tagName == "html") { - return; - } - } - - if (defSelector) { - // Stop link href navigation for default renderer - Event.preventDefault(e); - } - - cell = target; - - if (Dom.hasClass(cell, cal.Style.CSS_CELL_SELECTABLE)) { - index = cal.getIndexFromId(cell.id); - if (index > -1) { - d = cal.cellDates[index]; - if (d) { - date = DateMath.getDate(d[0],d[1]-1,d[2]); - - var link; - - if (cal.Options.MULTI_SELECT) { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); - } - - var cellDate = cal.cellDates[index]; - var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate); - - if (cellDateIndex > -1) { - cal.deselectCell(index); - } else { - cal.selectCell(index); - } - - } else { - link = cell.getElementsByTagName("a")[0]; - if (link) { - link.blur(); - } - cal.selectCell(index); - } - } - } - } - }, - - /** - * The event that is executed when the user hovers over a cell - * @method doCellMouseOver - * @param {DOMEvent} e The event - * @param {Calendar} cal A reference to the calendar passed by the Event utility - */ - doCellMouseOver : function(e, cal) { - var target; - if (e) { - target = Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName && target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (!target.tagName || target.tagName.toLowerCase() == "html") { - return; - } - } - - if (Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - Dom.addClass(target, cal.Style.CSS_CELL_HOVER); - } - }, - - /** - * The event that is executed when the user moves the mouse out of a cell - * @method doCellMouseOut - * @param {DOMEvent} e The event - * @param {Calendar} cal A reference to the calendar passed by the Event utility - */ - doCellMouseOut : function(e, cal) { - var target; - if (e) { - target = Event.getTarget(e); - } else { - target = this; - } - - while (target.tagName && target.tagName.toLowerCase() != "td") { - target = target.parentNode; - if (!target.tagName || target.tagName.toLowerCase() == "html") { - return; - } - } - - if (Dom.hasClass(target, cal.Style.CSS_CELL_SELECTABLE)) { - Dom.removeClass(target, cal.Style.CSS_CELL_HOVER); - } - }, - - setupConfig : function() { - - var cfg = this.cfg; - - /** - * The date to use to represent "Today". - * - * @config today - * @type Date - * @default The client side date (new Date()) when the Calendar is instantiated. - */ - cfg.addProperty(DEF_CFG.TODAY.key, { value: new Date(DEF_CFG.TODAY.value.getTime()), supercedes:DEF_CFG.TODAY.supercedes, handler:this.configToday, suppressEvent:true } ); - - /** - * The month/year representing the current visible Calendar date (mm/yyyy) - * @config pagedate - * @type String | Date - * @default Today's date - */ - cfg.addProperty(DEF_CFG.PAGEDATE.key, { value: DEF_CFG.PAGEDATE.value || new Date(DEF_CFG.TODAY.value.getTime()), handler:this.configPageDate } ); - - /** - * The date or range of dates representing the current Calendar selection - * @config selected - * @type String - * @default [] - */ - cfg.addProperty(DEF_CFG.SELECTED.key, { value:DEF_CFG.SELECTED.value.concat(), handler:this.configSelected } ); - - /** - * The title to display above the Calendar's month header. The title is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config title - * @type HTML - * @default "" - */ - cfg.addProperty(DEF_CFG.TITLE.key, { value:DEF_CFG.TITLE.value, handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this Calendar - * @config close - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.CLOSE.key, { value:DEF_CFG.CLOSE.value, handler:this.configClose } ); - - /** - * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. - * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be - * enabled if required. - * - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all other browsers - */ - cfg.addProperty(DEF_CFG.IFRAME.key, { value:DEF_CFG.IFRAME.value, handler:this.configIframe, validator:cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String | Date - * @default null - */ - cfg.addProperty(DEF_CFG.MINDATE.key, { value:DEF_CFG.MINDATE.value, handler:this.configMinDate } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String | Date - * @default null - */ - cfg.addProperty(DEF_CFG.MAXDATE.key, { value:DEF_CFG.MAXDATE.value, handler:this.configMaxDate } ); - - // Options properties - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.MULTI_SELECT.key, { value:DEF_CFG.MULTI_SELECT.value, handler:this.configOptions, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should allow selection of out-of-month dates. False by default. - * @config OOM_SELECT - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.OOM_SELECT.key, { value:DEF_CFG.OOM_SELECT.value, handler:this.configOptions, validator:cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday = 0, Monday = 1 ... Saturday = 6). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - cfg.addProperty(DEF_CFG.START_WEEKDAY.key, { value:DEF_CFG.START_WEEKDAY.value, handler:this.configOptions, validator:cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - cfg.addProperty(DEF_CFG.SHOW_WEEKDAYS.key, { value:DEF_CFG.SHOW_WEEKDAYS.value, handler:this.configOptions, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.SHOW_WEEK_HEADER.key, { value:DEF_CFG.SHOW_WEEK_HEADER.value, handler:this.configOptions, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.SHOW_WEEK_FOOTER.key,{ value:DEF_CFG.SHOW_WEEK_FOOTER.value, handler:this.configOptions, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should suppress weeks that are not a part of the current month. False by default. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.HIDE_BLANK_WEEKS.key, { value:DEF_CFG.HIDE_BLANK_WEEKS.value, handler:this.configOptions, validator:cfg.checkBoolean } ); - - /** - * The image URL that should be used for the left navigation arrow. The image URL is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config NAV_ARROW_LEFT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" - * @default null - */ - cfg.addProperty(DEF_CFG.NAV_ARROW_LEFT.key, { value:DEF_CFG.NAV_ARROW_LEFT.value, handler:this.configOptions } ); - - /** - * The image URL that should be used for the right navigation arrow. The image URL is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config NAV_ARROW_RIGHT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" - * @default null - */ - cfg.addProperty(DEF_CFG.NAV_ARROW_RIGHT.key, { value:DEF_CFG.NAV_ARROW_RIGHT.value, handler:this.configOptions } ); - - // Locale properties - - /** - * The short month labels for the current locale. The month labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config MONTHS_SHORT - * @type HTML[] - * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] - */ - cfg.addProperty(DEF_CFG.MONTHS_SHORT.key, { value:DEF_CFG.MONTHS_SHORT.value, handler:this.configLocale } ); - - /** - * The long month labels for the current locale. The month labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config MONTHS_LONG - * @type HTML[] - * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - */ - cfg.addProperty(DEF_CFG.MONTHS_LONG.key, { value:DEF_CFG.MONTHS_LONG.value, handler:this.configLocale } ); - - /** - * The 1-character weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_1CHAR - * @type HTML[] - * @default ["S", "M", "T", "W", "T", "F", "S"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_1CHAR.key, { value:DEF_CFG.WEEKDAYS_1CHAR.value, handler:this.configLocale } ); - - /** - * The short weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_SHORT - * @type HTML[] - * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_SHORT.key, { value:DEF_CFG.WEEKDAYS_SHORT.value, handler:this.configLocale } ); - - /** - * The medium weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_MEDIUM - * @type HTML[] - * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_MEDIUM.key, { value:DEF_CFG.WEEKDAYS_MEDIUM.value, handler:this.configLocale } ); - - /** - * The long weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_LONG - * @type HTML[] - * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_LONG.key, { value:DEF_CFG.WEEKDAYS_LONG.value, handler:this.configLocale } ); - - /** - * Refreshes the locale values used to build the Calendar. - * @method refreshLocale - * @private - */ - var refreshLocale = function() { - cfg.refireEvent(DEF_CFG.LOCALE_MONTHS.key); - cfg.refireEvent(DEF_CFG.LOCALE_WEEKDAYS.key); - }; - - cfg.subscribeToConfigEvent(DEF_CFG.START_WEEKDAY.key, refreshLocale, this, true); - cfg.subscribeToConfigEvent(DEF_CFG.MONTHS_SHORT.key, refreshLocale, this, true); - cfg.subscribeToConfigEvent(DEF_CFG.MONTHS_LONG.key, refreshLocale, this, true); - cfg.subscribeToConfigEvent(DEF_CFG.WEEKDAYS_1CHAR.key, refreshLocale, this, true); - cfg.subscribeToConfigEvent(DEF_CFG.WEEKDAYS_SHORT.key, refreshLocale, this, true); - cfg.subscribeToConfigEvent(DEF_CFG.WEEKDAYS_MEDIUM.key, refreshLocale, this, true); - cfg.subscribeToConfigEvent(DEF_CFG.WEEKDAYS_LONG.key, refreshLocale, this, true); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - cfg.addProperty(DEF_CFG.LOCALE_MONTHS.key, { value:DEF_CFG.LOCALE_MONTHS.value, handler:this.configLocaleValues } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - cfg.addProperty(DEF_CFG.LOCALE_WEEKDAYS.key, { value:DEF_CFG.LOCALE_WEEKDAYS.value, handler:this.configLocaleValues } ); - - /** - * The positive or negative year offset from the Gregorian calendar year (assuming a January 1st rollover) to - * be used when displaying and parsing dates. NOTE: All JS Date objects returned by methods, or expected as input by - * methods will always represent the Gregorian year, in order to maintain date/month/week values. - * - * @config YEAR_OFFSET - * @type Number - * @default 0 - */ - cfg.addProperty(DEF_CFG.YEAR_OFFSET.key, { value:DEF_CFG.YEAR_OFFSET.value, supercedes:DEF_CFG.YEAR_OFFSET.supercedes, handler:this.configLocale } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - cfg.addProperty(DEF_CFG.DATE_DELIMITER.key, { value:DEF_CFG.DATE_DELIMITER.value, handler:this.configLocale } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - cfg.addProperty(DEF_CFG.DATE_FIELD_DELIMITER.key, { value:DEF_CFG.DATE_FIELD_DELIMITER.value, handler:this.configLocale } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - cfg.addProperty(DEF_CFG.DATE_RANGE_DELIMITER.key, { value:DEF_CFG.DATE_RANGE_DELIMITER.value, handler:this.configLocale } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MY_MONTH_POSITION.key, { value:DEF_CFG.MY_MONTH_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MY_YEAR_POSITION.key, { value:DEF_CFG.MY_YEAR_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MD_MONTH_POSITION.key, { value:DEF_CFG.MD_MONTH_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MD_DAY_POSITION.key, { value:DEF_CFG.MD_DAY_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MDY_MONTH_POSITION.key, { value:DEF_CFG.MDY_MONTH_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MDY_DAY_POSITION.key, { value:DEF_CFG.MDY_DAY_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - cfg.addProperty(DEF_CFG.MDY_YEAR_POSITION.key, { value:DEF_CFG.MDY_YEAR_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the month in the month year label string used as the Calendar header - * @config MY_LABEL_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MY_LABEL_MONTH_POSITION.key, { value:DEF_CFG.MY_LABEL_MONTH_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The position of the year in the month year label string used as the Calendar header - * @config MY_LABEL_YEAR_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MY_LABEL_YEAR_POSITION.key, { value:DEF_CFG.MY_LABEL_YEAR_POSITION.value, handler:this.configLocale, validator:cfg.checkNumber } ); - - /** - * The suffix used after the month when rendering the Calendar header. The suffix is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config MY_LABEL_MONTH_SUFFIX - * @type HTML - * @default " " - */ - cfg.addProperty(DEF_CFG.MY_LABEL_MONTH_SUFFIX.key, { value:DEF_CFG.MY_LABEL_MONTH_SUFFIX.value, handler:this.configLocale } ); - - /** - * The suffix used after the year when rendering the Calendar header. The suffix is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config MY_LABEL_YEAR_SUFFIX - * @type HTML - * @default "" - */ - cfg.addProperty(DEF_CFG.MY_LABEL_YEAR_SUFFIX.key, { value:DEF_CFG.MY_LABEL_YEAR_SUFFIX.value, handler:this.configLocale } ); - - /** - * Configuration for the Month/Year CalendarNavigator UI which allows the user to jump directly to a - * specific Month/Year without having to scroll sequentially through months. - *

- * Setting this property to null (default value) or false, will disable the CalendarNavigator UI. - *

- *

- * Setting this property to true will enable the CalendarNavigatior UI with the default CalendarNavigator configuration values. - *

- *

- * This property can also be set to an object literal containing configuration properties for the CalendarNavigator UI. - * The configuration object expects the the following case-sensitive properties, with the "strings" property being a nested object. - * Any properties which are not provided will use the default values (defined in the CalendarNavigator class). - *

- *
- *
strings
- *
Object : An object with the properties shown below, defining the string labels to use in the Navigator's UI. The strings are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - *
- *
month
HTML : The markup to use for the month label. Defaults to "Month".
- *
year
HTML : The markup to use for the year label. Defaults to "Year".
- *
submit
HTML : The markup to use for the submit button label. Defaults to "Okay".
- *
cancel
HTML : The markup to use for the cancel button label. Defaults to "Cancel".
- *
invalidYear
HTML : The markup to use for invalid year values. Defaults to "Year needs to be a number".
- *
- *
- *
monthFormat
String : The month format to use. Either YAHOO.widget.Calendar.LONG, or YAHOO.widget.Calendar.SHORT. Defaults to YAHOO.widget.Calendar.LONG
- *
initialFocus
String : Either "year" or "month" specifying which input control should get initial focus. Defaults to "year"
- *
- *

E.g.

- *
-        * var navConfig = {
-        *   strings: {
-        *    month:"Calendar Month",
-        *    year:"Calendar Year",
-        *    submit: "Submit",
-        *    cancel: "Cancel",
-        *    invalidYear: "Please enter a valid year"
-        *   },
-        *   monthFormat: YAHOO.widget.Calendar.SHORT,
-        *   initialFocus: "month"
-        * }
-        * 
- * @config navigator - * @type {Object|Boolean} - * @default null - */ - cfg.addProperty(DEF_CFG.NAV.key, { value:DEF_CFG.NAV.value, handler:this.configNavigator } ); - - /** - * The map of UI strings which the Calendar UI uses. - * - * @config strings - * @type {Object} - * @default An object with the properties shown below: - *
- *
previousMonth
HTML : The markup to use for the "Previous Month" navigation label. Defaults to "Previous Month". The string is added to the DOM as HTML, and should be escaped by the implementor if coming from an external source.
- *
nextMonth
HTML : The markup to use for the "Next Month" navigation UI. Defaults to "Next Month". The string is added to the DOM as HTML, and should be escaped by the implementor if coming from an external source.
- *
close
HTML : The markup to use for the close button label. Defaults to "Close". The string is added to the DOM as HTML, and should be escaped by the implementor if coming from an external source.
- *
- */ - cfg.addProperty(DEF_CFG.STRINGS.key, { - value:DEF_CFG.STRINGS.value, - handler:this.configStrings, - validator: function(val) { - return Lang.isObject(val); - }, - supercedes:DEF_CFG.STRINGS.supercedes - }); - }, - - /** - * The default handler for the "strings" property - * @method configStrings - */ - configStrings : function(type, args, obj) { - var val = Lang.merge(DEF_CFG.STRINGS.value, args[0]); - this.cfg.setProperty(DEF_CFG.STRINGS.key, val, true); - }, - - /** - * The default handler for the "pagedate" property - * @method configPageDate - */ - configPageDate : function(type, args, obj) { - this.cfg.setProperty(DEF_CFG.PAGEDATE.key, this._parsePageDate(args[0]), true); - }, - - /** - * The default handler for the "mindate" property - * @method configMinDate - */ - configMinDate : function(type, args, obj) { - var val = args[0]; - if (Lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(DEF_CFG.MINDATE.key, DateMath.getDate(val[0],(val[1]-1),val[2])); - } - }, - - /** - * The default handler for the "maxdate" property - * @method configMaxDate - */ - configMaxDate : function(type, args, obj) { - var val = args[0]; - if (Lang.isString(val)) { - val = this._parseDate(val); - this.cfg.setProperty(DEF_CFG.MAXDATE.key, DateMath.getDate(val[0],(val[1]-1),val[2])); - } - }, - - /** - * The default handler for the "today" property - * @method configToday - */ - configToday : function(type, args, obj) { - // Only do this for initial set. Changing the today property after the initial - // set, doesn't affect pagedate - var val = args[0]; - if (Lang.isString(val)) { - val = this._parseDate(val); - } - var today = DateMath.clearTime(val); - if (!this.cfg.initialConfig[DEF_CFG.PAGEDATE.key]) { - this.cfg.setProperty(DEF_CFG.PAGEDATE.key, today); - } - this.today = today; - this.cfg.setProperty(DEF_CFG.TODAY.key, today, true); - }, - - /** - * The default handler for the "selected" property - * @method configSelected - */ - configSelected : function(type, args, obj) { - var selected = args[0], - cfgSelected = DEF_CFG.SELECTED.key; - - if (selected) { - if (Lang.isString(selected)) { - this.cfg.setProperty(cfgSelected, this._parseDates(selected), true); - } - } - if (! this._selectedDates) { - this._selectedDates = this.cfg.getProperty(cfgSelected); - } - }, - - /** - * The default handler for all configuration options properties - * @method configOptions - */ - configOptions : function(type, args, obj) { - this.Options[type.toUpperCase()] = args[0]; - }, - - /** - * The default handler for all configuration locale properties - * @method configLocale - */ - configLocale : function(type, args, obj) { - this.Locale[type.toUpperCase()] = args[0]; - - this.cfg.refireEvent(DEF_CFG.LOCALE_MONTHS.key); - this.cfg.refireEvent(DEF_CFG.LOCALE_WEEKDAYS.key); - }, - - /** - * The default handler for all configuration locale field length properties - * @method configLocaleValues - */ - configLocaleValues : function(type, args, obj) { - - type = type.toLowerCase(); - - var val = args[0], - cfg = this.cfg, - Locale = this.Locale; - - switch (type) { - case DEF_CFG.LOCALE_MONTHS.key: - switch (val) { - case Calendar.SHORT: - Locale.LOCALE_MONTHS = cfg.getProperty(DEF_CFG.MONTHS_SHORT.key).concat(); - break; - case Calendar.LONG: - Locale.LOCALE_MONTHS = cfg.getProperty(DEF_CFG.MONTHS_LONG.key).concat(); - break; - } - break; - case DEF_CFG.LOCALE_WEEKDAYS.key: - switch (val) { - case Calendar.ONE_CHAR: - Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_1CHAR.key).concat(); - break; - case Calendar.SHORT: - Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_SHORT.key).concat(); - break; - case Calendar.MEDIUM: - Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_MEDIUM.key).concat(); - break; - case Calendar.LONG: - Locale.LOCALE_WEEKDAYS = cfg.getProperty(DEF_CFG.WEEKDAYS_LONG.key).concat(); - break; - } - - var START_WEEKDAY = cfg.getProperty(DEF_CFG.START_WEEKDAY.key); - - if (START_WEEKDAY > 0) { - for (var w=0; w < START_WEEKDAY; ++w) { - Locale.LOCALE_WEEKDAYS.push(Locale.LOCALE_WEEKDAYS.shift()); - } - } - break; - } - }, - - /** - * The default handler for the "navigator" property - * @method configNavigator - */ - configNavigator : function(type, args, obj) { - var val = args[0]; - if (YAHOO.widget.CalendarNavigator && (val === true || Lang.isObject(val))) { - if (!this.oNavigator) { - this.oNavigator = new YAHOO.widget.CalendarNavigator(this); - // Cleanup DOM Refs/Events before innerHTML is removed. - this.beforeRenderEvent.subscribe(function () { - if (!this.pages) { - this.oNavigator.erase(); - } - }, this, true); - } - } else { - if (this.oNavigator) { - this.oNavigator.destroy(); - this.oNavigator = null; - } - } - }, - - /** - * Defines the class names used by Calendar when rendering to DOM. NOTE: The class names are added to the DOM as HTML and should be escaped by the implementor if coming from an external source. - * @method initStyles - */ - initStyles : function() { - - var defStyle = Calendar.STYLES; - - this.Style = { - /** - * @property Style.CSS_ROW_HEADER - */ - CSS_ROW_HEADER: defStyle.CSS_ROW_HEADER, - /** - * @property Style.CSS_ROW_FOOTER - */ - CSS_ROW_FOOTER: defStyle.CSS_ROW_FOOTER, - /** - * @property Style.CSS_CELL - */ - CSS_CELL : defStyle.CSS_CELL, - /** - * @property Style.CSS_CELL_SELECTOR - */ - CSS_CELL_SELECTOR : defStyle.CSS_CELL_SELECTOR, - /** - * @property Style.CSS_CELL_SELECTED - */ - CSS_CELL_SELECTED : defStyle.CSS_CELL_SELECTED, - /** - * @property Style.CSS_CELL_SELECTABLE - */ - CSS_CELL_SELECTABLE : defStyle.CSS_CELL_SELECTABLE, - /** - * @property Style.CSS_CELL_RESTRICTED - */ - CSS_CELL_RESTRICTED : defStyle.CSS_CELL_RESTRICTED, - /** - * @property Style.CSS_CELL_TODAY - */ - CSS_CELL_TODAY : defStyle.CSS_CELL_TODAY, - /** - * @property Style.CSS_CELL_OOM - */ - CSS_CELL_OOM : defStyle.CSS_CELL_OOM, - /** - * @property Style.CSS_CELL_OOB - */ - CSS_CELL_OOB : defStyle.CSS_CELL_OOB, - /** - * @property Style.CSS_HEADER - */ - CSS_HEADER : defStyle.CSS_HEADER, - /** - * @property Style.CSS_HEADER_TEXT - */ - CSS_HEADER_TEXT : defStyle.CSS_HEADER_TEXT, - /** - * @property Style.CSS_BODY - */ - CSS_BODY : defStyle.CSS_BODY, - /** - * @property Style.CSS_WEEKDAY_CELL - */ - CSS_WEEKDAY_CELL : defStyle.CSS_WEEKDAY_CELL, - /** - * @property Style.CSS_WEEKDAY_ROW - */ - CSS_WEEKDAY_ROW : defStyle.CSS_WEEKDAY_ROW, - /** - * @property Style.CSS_FOOTER - */ - CSS_FOOTER : defStyle.CSS_FOOTER, - /** - * @property Style.CSS_CALENDAR - */ - CSS_CALENDAR : defStyle.CSS_CALENDAR, - /** - * @property Style.CSS_SINGLE - */ - CSS_SINGLE : defStyle.CSS_SINGLE, - /** - * @property Style.CSS_CONTAINER - */ - CSS_CONTAINER : defStyle.CSS_CONTAINER, - /** - * @property Style.CSS_NAV_LEFT - */ - CSS_NAV_LEFT : defStyle.CSS_NAV_LEFT, - /** - * @property Style.CSS_NAV_RIGHT - */ - CSS_NAV_RIGHT : defStyle.CSS_NAV_RIGHT, - /** - * @property Style.CSS_NAV - */ - CSS_NAV : defStyle.CSS_NAV, - /** - * @property Style.CSS_CLOSE - */ - CSS_CLOSE : defStyle.CSS_CLOSE, - /** - * @property Style.CSS_CELL_TOP - */ - CSS_CELL_TOP : defStyle.CSS_CELL_TOP, - /** - * @property Style.CSS_CELL_LEFT - */ - CSS_CELL_LEFT : defStyle.CSS_CELL_LEFT, - /** - * @property Style.CSS_CELL_RIGHT - */ - CSS_CELL_RIGHT : defStyle.CSS_CELL_RIGHT, - /** - * @property Style.CSS_CELL_BOTTOM - */ - CSS_CELL_BOTTOM : defStyle.CSS_CELL_BOTTOM, - /** - * @property Style.CSS_CELL_HOVER - */ - CSS_CELL_HOVER : defStyle.CSS_CELL_HOVER, - /** - * @property Style.CSS_CELL_HIGHLIGHT1 - */ - CSS_CELL_HIGHLIGHT1 : defStyle.CSS_CELL_HIGHLIGHT1, - /** - * @property Style.CSS_CELL_HIGHLIGHT2 - */ - CSS_CELL_HIGHLIGHT2 : defStyle.CSS_CELL_HIGHLIGHT2, - /** - * @property Style.CSS_CELL_HIGHLIGHT3 - */ - CSS_CELL_HIGHLIGHT3 : defStyle.CSS_CELL_HIGHLIGHT3, - /** - * @property Style.CSS_CELL_HIGHLIGHT4 - */ - CSS_CELL_HIGHLIGHT4 : defStyle.CSS_CELL_HIGHLIGHT4, - /** - * @property Style.CSS_WITH_TITLE - */ - CSS_WITH_TITLE : defStyle.CSS_WITH_TITLE, - /** - * @property Style.CSS_FIXED_SIZE - */ - CSS_FIXED_SIZE : defStyle.CSS_FIXED_SIZE, - /** - * @property Style.CSS_LINK_CLOSE - */ - CSS_LINK_CLOSE : defStyle.CSS_LINK_CLOSE - }; - }, - - /** - * Builds the date label that will be displayed in the calendar header or - * footer, depending on configuration. - * @method buildMonthLabel - * @return {HTML} The formatted calendar month label - */ - buildMonthLabel : function() { - return this._buildMonthLabel(this.cfg.getProperty(DEF_CFG.PAGEDATE.key)); - }, - - /** - * Helper method, to format a Month Year string, given a JavaScript Date, based on the - * Calendar localization settings - * - * @method _buildMonthLabel - * @private - * @param {Date} date - * @return {HTML} Formated month, year string - */ - _buildMonthLabel : function(date) { - var monthLabel = this.Locale.LOCALE_MONTHS[date.getMonth()] + this.Locale.MY_LABEL_MONTH_SUFFIX, - yearLabel = (date.getFullYear() + this.Locale.YEAR_OFFSET) + this.Locale.MY_LABEL_YEAR_SUFFIX; - - if (this.Locale.MY_LABEL_MONTH_POSITION == 2 || this.Locale.MY_LABEL_YEAR_POSITION == 1) { - return yearLabel + monthLabel; - } else { - return monthLabel + yearLabel; - } - }, - - /** - * Builds the date digit that will be displayed in calendar cells - * @method buildDayLabel - * @param {Date} workingDate The current working date - * @return {Number} The day - */ - buildDayLabel : function(workingDate) { - return workingDate.getDate(); - }, - - /** - * Creates the title bar element and adds it to Calendar container DIV. NOTE: The title parameter passed into this method is added to the DOM as HTML and should be escaped by the implementor if coming from an external source. - * - * @method createTitleBar - * @param {HTML} strTitle The title to display in the title bar - * @return The title bar element - */ - createTitleBar : function(strTitle) { - var tDiv = Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || document.createElement("div"); - tDiv.className = YAHOO.widget.CalendarGroup.CSS_2UPTITLE; - tDiv.innerHTML = strTitle; - this.oDomContainer.insertBefore(tDiv, this.oDomContainer.firstChild); - - Dom.addClass(this.oDomContainer, this.Style.CSS_WITH_TITLE); - - return tDiv; - }, - - /** - * Removes the title bar element from the DOM - * - * @method removeTitleBar - */ - removeTitleBar : function() { - var tDiv = Dom.getElementsByClassName(YAHOO.widget.CalendarGroup.CSS_2UPTITLE, "div", this.oDomContainer)[0] || null; - if (tDiv) { - Event.purgeElement(tDiv); - this.oDomContainer.removeChild(tDiv); - } - Dom.removeClass(this.oDomContainer, this.Style.CSS_WITH_TITLE); - }, - - /** - * Creates the close button HTML element and adds it to Calendar container DIV - * - * @method createCloseButton - * @return {HTMLElement} The close HTML element created - */ - createCloseButton : function() { - var cssClose = YAHOO.widget.CalendarGroup.CSS_2UPCLOSE, - cssLinkClose = this.Style.CSS_LINK_CLOSE, - DEPR_CLOSE_PATH = "us/my/bn/x_d.gif", - - lnk = Dom.getElementsByClassName(cssLinkClose, "a", this.oDomContainer)[0], - strings = this.cfg.getProperty(DEF_CFG.STRINGS.key), - closeStr = (strings && strings.close) ? strings.close : ""; - - if (!lnk) { - lnk = document.createElement("a"); - Event.addListener(lnk, "click", function(e, cal) { - cal.hide(); - Event.preventDefault(e); - }, this); - } - - lnk.href = "#"; - lnk.className = cssLinkClose; - - if (Calendar.IMG_ROOT !== null) { - var img = Dom.getElementsByClassName(cssClose, "img", lnk)[0] || document.createElement("img"); - img.src = Calendar.IMG_ROOT + DEPR_CLOSE_PATH; - img.className = cssClose; - lnk.appendChild(img); - } else { - lnk.innerHTML = '' + closeStr + ''; - } - this.oDomContainer.appendChild(lnk); - - return lnk; - }, - - /** - * Removes the close button HTML element from the DOM - * - * @method removeCloseButton - */ - removeCloseButton : function() { - var btn = Dom.getElementsByClassName(this.Style.CSS_LINK_CLOSE, "a", this.oDomContainer)[0] || null; - if (btn) { - Event.purgeElement(btn); - this.oDomContainer.removeChild(btn); - } - }, - - /** - * Renders the calendar header. NOTE: The contents of the array passed into this method are added to the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @method renderHeader - * @param {HTML[]} html The current working HTML array - * @return {HTML[]} The current working HTML array - */ - renderHeader : function(html) { - - - var colSpan = 7, - DEPR_NAV_LEFT = "us/tr/callt.gif", - DEPR_NAV_RIGHT = "us/tr/calrt.gif", - cfg = this.cfg, - pageDate = cfg.getProperty(DEF_CFG.PAGEDATE.key), - strings= cfg.getProperty(DEF_CFG.STRINGS.key), - prevStr = (strings && strings.previousMonth) ? strings.previousMonth : "", - nextStr = (strings && strings.nextMonth) ? strings.nextMonth : "", - monthLabel; - - if (cfg.getProperty(DEF_CFG.SHOW_WEEK_HEADER.key)) { - colSpan += 1; - } - - if (cfg.getProperty(DEF_CFG.SHOW_WEEK_FOOTER.key)) { - colSpan += 1; - } - - html[html.length] = ""; - html[html.length] = ""; - html[html.length] = ''; - html[html.length] = '
'; - - var renderLeft, renderRight = false; - - if (this.parent) { - if (this.index === 0) { - renderLeft = true; - } - if (this.index == (this.parent.cfg.getProperty("pages") -1)) { - renderRight = true; - } - } else { - renderLeft = true; - renderRight = true; - } - - if (renderLeft) { - monthLabel = this._buildMonthLabel(DateMath.subtract(pageDate, DateMath.MONTH, 1)); - - var leftArrow = cfg.getProperty(DEF_CFG.NAV_ARROW_LEFT.key); - // Check for deprecated customization - If someone set IMG_ROOT, but didn't set NAV_ARROW_LEFT, then set NAV_ARROW_LEFT to the old deprecated value - if (leftArrow === null && Calendar.IMG_ROOT !== null) { - leftArrow = Calendar.IMG_ROOT + DEPR_NAV_LEFT; - } - var leftStyle = (leftArrow === null) ? "" : ' style="background-image:url(' + leftArrow + ')"'; - html[html.length] = '' + prevStr + ' (' + monthLabel + ')' + ''; - } - - var lbl = this.buildMonthLabel(); - var cal = this.parent || this; - if (cal.cfg.getProperty("navigator")) { - lbl = "" + lbl + ""; - } - html[html.length] = lbl; - - if (renderRight) { - monthLabel = this._buildMonthLabel(DateMath.add(pageDate, DateMath.MONTH, 1)); - - var rightArrow = cfg.getProperty(DEF_CFG.NAV_ARROW_RIGHT.key); - if (rightArrow === null && Calendar.IMG_ROOT !== null) { - rightArrow = Calendar.IMG_ROOT + DEPR_NAV_RIGHT; - } - var rightStyle = (rightArrow === null) ? "" : ' style="background-image:url(' + rightArrow + ')"'; - html[html.length] = '' + nextStr + ' (' + monthLabel + ')' + ''; - } - - html[html.length] = '
\n\n'; - - if (cfg.getProperty(DEF_CFG.SHOW_WEEKDAYS.key)) { - html = this.buildWeekdays(html); - } - - html[html.length] = ''; - - return html; - }, - - /** - * Renders the Calendar's weekday headers. NOTE: The contents of the array passed into this method are added to the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @method buildWeekdays - * @param {HTML[]} html The current working HTML array - * @return {HTML[]} The current working HTML array - */ - buildWeekdays : function(html) { - - html[html.length] = ''; - - if (this.cfg.getProperty(DEF_CFG.SHOW_WEEK_HEADER.key)) { - html[html.length] = ' '; - } - - for(var i=0;i < this.Locale.LOCALE_WEEKDAYS.length; ++i) { - html[html.length] = '' + this.Locale.LOCALE_WEEKDAYS[i] + ''; - } - - if (this.cfg.getProperty(DEF_CFG.SHOW_WEEK_FOOTER.key)) { - html[html.length] = ' '; - } - - html[html.length] = ''; - - return html; - }, - - /** - * Renders the calendar body. NOTE: The contents of the array passed into this method are added to the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @method renderBody - * @param {Date} workingDate The current working Date being used for the render process - * @param {HTML[]} html The current working HTML array - * @return {HTML[]} The current working HTML array - */ - renderBody : function(workingDate, html) { - - var startDay = this.cfg.getProperty(DEF_CFG.START_WEEKDAY.key); - - this.preMonthDays = workingDate.getDay(); - if (startDay > 0) { - this.preMonthDays -= startDay; - } - if (this.preMonthDays < 0) { - this.preMonthDays += 7; - } - - this.monthDays = DateMath.findMonthEnd(workingDate).getDate(); - this.postMonthDays = Calendar.DISPLAY_DAYS-this.preMonthDays-this.monthDays; - - - workingDate = DateMath.subtract(workingDate, DateMath.DAY, this.preMonthDays); - - var weekNum, - weekClass, - weekPrefix = "w", - cellPrefix = "_cell", - workingDayPrefix = "wd", - dayPrefix = "d", - cellRenderers, - renderer, - t = this.today, - cfg = this.cfg, - oom, - todayYear = t.getFullYear(), - todayMonth = t.getMonth(), - todayDate = t.getDate(), - useDate = cfg.getProperty(DEF_CFG.PAGEDATE.key), - hideBlankWeeks = cfg.getProperty(DEF_CFG.HIDE_BLANK_WEEKS.key), - showWeekFooter = cfg.getProperty(DEF_CFG.SHOW_WEEK_FOOTER.key), - showWeekHeader = cfg.getProperty(DEF_CFG.SHOW_WEEK_HEADER.key), - oomSelect = cfg.getProperty(DEF_CFG.OOM_SELECT.key), - mindate = cfg.getProperty(DEF_CFG.MINDATE.key), - maxdate = cfg.getProperty(DEF_CFG.MAXDATE.key), - yearOffset = this.Locale.YEAR_OFFSET; - - if (mindate) { - mindate = DateMath.clearTime(mindate); - } - if (maxdate) { - maxdate = DateMath.clearTime(maxdate); - } - - html[html.length] = ''; - - var i = 0, - tempDiv = document.createElement("div"), - cell = document.createElement("td"); - - tempDiv.appendChild(cell); - - var cal = this.parent || this; - - for (var r = 0; r < 6; r++) { - weekNum = DateMath.getWeekNumber(workingDate, startDay); - weekClass = weekPrefix + weekNum; - - // Local OOM check for performance, since we already have pagedate - if (r !== 0 && hideBlankWeeks === true && workingDate.getMonth() != useDate.getMonth()) { - break; - } else { - html[html.length] = ''; - - if (showWeekHeader) { html = this.renderRowHeader(weekNum, html); } - - for (var d=0; d < 7; d++){ // Render actual days - - cellRenderers = []; - - this.clearElement(cell); - cell.className = this.Style.CSS_CELL; - cell.id = this.id + cellPrefix + i; - - if (workingDate.getDate() == todayDate && - workingDate.getMonth() == todayMonth && - workingDate.getFullYear() == todayYear) { - cellRenderers[cellRenderers.length]=cal.renderCellStyleToday; - } - - var workingArray = [workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; - this.cellDates[this.cellDates.length] = workingArray; // Add this date to cellDates - - // Local OOM check for performance, since we already have pagedate - oom = workingDate.getMonth() != useDate.getMonth(); - if (oom && !oomSelect) { - cellRenderers[cellRenderers.length]=cal.renderCellNotThisMonth; - } else { - Dom.addClass(cell, workingDayPrefix + workingDate.getDay()); - Dom.addClass(cell, dayPrefix + workingDate.getDate()); - - // Concat, so that we're not splicing from an array - // which we're also iterating - var rs = this.renderStack.concat(); - - for (var s=0, l = rs.length; s < l; ++s) { - - renderer = null; - - var rArray = rs[s], - type = rArray[0], - month, - day, - year; - - switch (type) { - case Calendar.DATE: - month = rArray[1][1]; - day = rArray[1][2]; - year = rArray[1][0]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - - break; - case Calendar.MONTH_DAY: - month = rArray[1][0]; - day = rArray[1][1]; - - if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) { - renderer = rArray[2]; - this.renderStack.splice(s,1); - } - break; - case Calendar.RANGE: - var date1 = rArray[1][0], - date2 = rArray[1][1], - d1month = date1[1], - d1day = date1[2], - d1year = date1[0], - d1 = DateMath.getDate(d1year, d1month-1, d1day), - d2month = date2[1], - d2day = date2[2], - d2year = date2[0], - d2 = DateMath.getDate(d2year, d2month-1, d2day); - - if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) { - renderer = rArray[2]; - - if (workingDate.getTime()==d2.getTime()) { - this.renderStack.splice(s,1); - } - } - break; - case Calendar.WEEKDAY: - var weekday = rArray[1][0]; - if (workingDate.getDay()+1 == weekday) { - renderer = rArray[2]; - } - break; - case Calendar.MONTH: - month = rArray[1][0]; - if (workingDate.getMonth()+1 == month) { - renderer = rArray[2]; - } - break; - } - - if (renderer) { - cellRenderers[cellRenderers.length]=renderer; - } - } - - } - - if (this._indexOfSelectedFieldArray(workingArray) > -1) { - cellRenderers[cellRenderers.length]=cal.renderCellStyleSelected; - } - - if (oom) { - cellRenderers[cellRenderers.length] = cal.styleCellNotThisMonth; - } - - if ((mindate && (workingDate.getTime() < mindate.getTime())) || (maxdate && (workingDate.getTime() > maxdate.getTime()))) { - cellRenderers[cellRenderers.length] = cal.renderOutOfBoundsDate; - } else { - cellRenderers[cellRenderers.length] = cal.styleCellDefault; - cellRenderers[cellRenderers.length] = cal.renderCellDefault; - } - - for (var x=0; x < cellRenderers.length; ++x) { - if (cellRenderers[x].call(cal, workingDate, cell) == Calendar.STOP_RENDER) { - break; - } - } - - workingDate.setTime(workingDate.getTime() + DateMath.ONE_DAY_MS); - // Just in case we crossed DST/Summertime boundaries - workingDate = DateMath.clearTime(workingDate); - - if (i >= 0 && i <= 6) { - Dom.addClass(cell, this.Style.CSS_CELL_TOP); - } - if ((i % 7) === 0) { - Dom.addClass(cell, this.Style.CSS_CELL_LEFT); - } - if (((i+1) % 7) === 0) { - Dom.addClass(cell, this.Style.CSS_CELL_RIGHT); - } - - var postDays = this.postMonthDays; - if (hideBlankWeeks && postDays >= 7) { - var blankWeeks = Math.floor(postDays/7); - for (var p=0;p= ((this.preMonthDays+postDays+this.monthDays)-7)) { - Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM); - } - - html[html.length] = tempDiv.innerHTML; - i++; - } - - if (showWeekFooter) { html = this.renderRowFooter(weekNum, html); } - - html[html.length] = ''; - } - } - - html[html.length] = ''; - - return html; - }, - - /** - * Renders the calendar footer. In the default implementation, there is no footer. NOTE: The contents of the array passed into this method are added to the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @method renderFooter - * @param {HTML[]} html The current working HTML array - * @return {HTML[]} The current working HTML array - */ - renderFooter : function(html) { return html; }, - - /** - * Renders the calendar after it has been configured. The render() method has a specific call chain that will execute - * when the method is called: renderHeader, renderBody, renderFooter. - * Refer to the documentation for those methods for information on individual render tasks. - * @method render - */ - render : function() { - this.beforeRenderEvent.fire(); - - // Find starting day of the current month - var workingDate = DateMath.findMonthStart(this.cfg.getProperty(DEF_CFG.PAGEDATE.key)); - - this.resetRenderers(); - this.cellDates.length = 0; - - Event.purgeElement(this.oDomContainer, true); - - var html = [], - table; - - html[html.length] = ''; - html = this.renderHeader(html); - html = this.renderBody(workingDate, html); - html = this.renderFooter(html); - html[html.length] = '
'; - - this.oDomContainer.innerHTML = html.join("\n"); - - this.applyListeners(); - - // Using oDomContainer.ownerDocument, to allow for cross-frame rendering - table = ((this._oDoc) && this._oDoc.getElementById(this.id)) || (this.id); - - this.cells = Dom.getElementsByClassName(this.Style.CSS_CELL, "td", table); - - this.cfg.refireEvent(DEF_CFG.TITLE.key); - this.cfg.refireEvent(DEF_CFG.CLOSE.key); - this.cfg.refireEvent(DEF_CFG.IFRAME.key); - - this.renderEvent.fire(); - }, - - /** - * Applies the Calendar's DOM listeners to applicable elements. - * @method applyListeners - */ - applyListeners : function() { - var root = this.oDomContainer, - cal = this.parent || this, - anchor = "a", - click = "click"; - - var linkLeft = Dom.getElementsByClassName(this.Style.CSS_NAV_LEFT, anchor, root), - linkRight = Dom.getElementsByClassName(this.Style.CSS_NAV_RIGHT, anchor, root); - - if (linkLeft && linkLeft.length > 0) { - this.linkLeft = linkLeft[0]; - Event.addListener(this.linkLeft, click, this.doPreviousMonthNav, cal, true); - } - - if (linkRight && linkRight.length > 0) { - this.linkRight = linkRight[0]; - Event.addListener(this.linkRight, click, this.doNextMonthNav, cal, true); - } - - if (cal.cfg.getProperty("navigator") !== null) { - this.applyNavListeners(); - } - - if (this.domEventMap) { - var el,elements; - for (var cls in this.domEventMap) { - if (Lang.hasOwnProperty(this.domEventMap, cls)) { - var items = this.domEventMap[cls]; - - if (! (items instanceof Array)) { - items = [items]; - } - - for (var i=0;i 0) { - - Event.addListener(navBtns, "click", function (e, obj) { - var target = Event.getTarget(e); - // this == navBtn - if (this === target || Dom.isAncestor(this, target)) { - Event.preventDefault(e); - } - var navigator = calParent.oNavigator; - if (navigator) { - var pgdate = cal.cfg.getProperty("pagedate"); - navigator.setYear(pgdate.getFullYear() + cal.Locale.YEAR_OFFSET); - navigator.setMonth(pgdate.getMonth()); - navigator.show(); - } - }); - } - }, - - /** - * Retrieves the Date object for the specified Calendar cell - * @method getDateByCellId - * @param {String} id The id of the cell - * @return {Date} The Date object for the specified Calendar cell - */ - getDateByCellId : function(id) { - var date = this.getDateFieldsByCellId(id); - return (date) ? DateMath.getDate(date[0],date[1]-1,date[2]) : null; - }, - - /** - * Retrieves the Date object for the specified Calendar cell - * @method getDateFieldsByCellId - * @param {String} id The id of the cell - * @return {Array} The array of Date fields for the specified Calendar cell - */ - getDateFieldsByCellId : function(id) { - id = this.getIndexFromId(id); - return (id > -1) ? this.cellDates[id] : null; - }, - - /** - * Find the Calendar's cell index for a given date. - * If the date is not found, the method returns -1. - *

- * The returned index can be used to lookup the cell HTMLElement - * using the Calendar's cells array or passed to selectCell to select - * cells by index. - *

- * - * See cells, selectCell. - * - * @method getCellIndex - * @param {Date} date JavaScript Date object, for which to find a cell index. - * @return {Number} The index of the date in Calendars cellDates/cells arrays, or -1 if the date - * is not on the curently rendered Calendar page. - */ - getCellIndex : function(date) { - var idx = -1; - if (date) { - var m = date.getMonth(), - y = date.getFullYear(), - d = date.getDate(), - dates = this.cellDates; - - for (var i = 0; i < dates.length; ++i) { - var cellDate = dates[i]; - if (cellDate[0] === y && cellDate[1] === m+1 && cellDate[2] === d) { - idx = i; - break; - } - } - } - return idx; - }, - - /** - * Given the id used to mark each Calendar cell, this method - * extracts the index number from the id. - * - * @param {String} strId The cell id - * @return {Number} The index of the cell, or -1 if id does not contain an index number - */ - getIndexFromId : function(strId) { - var idx = -1, - li = strId.lastIndexOf("_cell"); - - if (li > -1) { - idx = parseInt(strId.substring(li + 5), 10); - } - - return idx; - }, - - // BEGIN BUILT-IN TABLE CELL RENDERERS - - /** - * Renders a cell that falls before the minimum date or after the maximum date. - * @method renderOutOfBoundsDate - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - * @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering - * should not be terminated - */ - renderOutOfBoundsDate : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_OOB); - cell.innerHTML = workingDate.getDate(); - return Calendar.STOP_RENDER; - }, - - /** - * Renders the row header HTML for a week. - * - * @method renderRowHeader - * @param {Number} weekNum The week number of the current row - * @param {HTML[]} cell The current working HTML array - */ - renderRowHeader : function(weekNum, html) { - html[html.length] = '' + weekNum + ''; - return html; - }, - - /** - * Renders the row footer HTML for a week. - * - * @method renderRowFooter - * @param {Number} weekNum The week number of the current row - * @param {HTML[]} cell The current working HTML array - */ - renderRowFooter : function(weekNum, html) { - html[html.length] = '' + weekNum + ''; - return html; - }, - - /** - * Renders a single standard calendar cell in the calendar widget table. - * - * All logic for determining how a standard default cell will be rendered is - * encapsulated in this method, and must be accounted for when extending the - * widget class. - * - * @method renderCellDefault - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - renderCellDefault : function(workingDate, cell) { - cell.innerHTML = '' + this.buildDayLabel(workingDate) + ""; - }, - - /** - * Styles a selectable cell. - * @method styleCellDefault - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - styleCellDefault : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_SELECTABLE); - }, - - - /** - * Renders a single standard calendar cell using the CSS hightlight1 style - * @method renderCellStyleHighlight1 - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - renderCellStyleHighlight1 : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1); - }, - - /** - * Renders a single standard calendar cell using the CSS hightlight2 style - * @method renderCellStyleHighlight2 - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - renderCellStyleHighlight2 : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2); - }, - - /** - * Renders a single standard calendar cell using the CSS hightlight3 style - * @method renderCellStyleHighlight3 - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - renderCellStyleHighlight3 : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3); - }, - - /** - * Renders a single standard calendar cell using the CSS hightlight4 style - * @method renderCellStyleHighlight4 - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - renderCellStyleHighlight4 : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4); - }, - - /** - * Applies the default style used for rendering today's date to the current calendar cell - * @method renderCellStyleToday - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - renderCellStyleToday : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_TODAY); - }, - - /** - * Applies the default style used for rendering selected dates to the current calendar cell - * @method renderCellStyleSelected - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - * @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering - * should not be terminated - */ - renderCellStyleSelected : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL_SELECTED); - }, - - /** - * Applies the default style used for rendering dates that are not a part of the current - * month (preceding or trailing the cells for the current month) - * - * @method renderCellNotThisMonth - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - * @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering - * should not be terminated - */ - renderCellNotThisMonth : function(workingDate, cell) { - this.styleCellNotThisMonth(workingDate, cell); - cell.innerHTML=workingDate.getDate(); - return Calendar.STOP_RENDER; - }, - - /** Applies the style used for rendering out-of-month dates to the current calendar cell - * @method styleCellNotThisMonth - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - */ - styleCellNotThisMonth : function(workingDate, cell) { - YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM); - }, - - /** - * Renders the current calendar cell as a non-selectable "black-out" date using the default - * restricted style. - * @method renderBodyCellRestricted - * @param {Date} workingDate The current working Date object being used to generate the calendar - * @param {HTMLTableCellElement} cell The current working cell in the calendar - * @return {String} YAHOO.widget.Calendar.STOP_RENDER if rendering should stop with this style, null or nothing if rendering - * should not be terminated - */ - renderBodyCellRestricted : function(workingDate, cell) { - Dom.addClass(cell, this.Style.CSS_CELL); - Dom.addClass(cell, this.Style.CSS_CELL_RESTRICTED); - cell.innerHTML=workingDate.getDate(); - return Calendar.STOP_RENDER; - }, - - // END BUILT-IN TABLE CELL RENDERERS - - // BEGIN MONTH NAVIGATION METHODS - - /** - * Adds the designated number of months to the current calendar month, and sets the current - * calendar page date to the new month. - * @method addMonths - * @param {Number} count The number of months to add to the current calendar - */ - addMonths : function(count) { - var cfgPageDate = DEF_CFG.PAGEDATE.key, - - prevDate = this.cfg.getProperty(cfgPageDate), - newDate = DateMath.add(prevDate, DateMath.MONTH, count); - - this.cfg.setProperty(cfgPageDate, newDate); - this.resetRenderers(); - this.changePageEvent.fire(prevDate, newDate); - }, - - /** - * Subtracts the designated number of months from the current calendar month, and sets the current - * calendar page date to the new month. - * @method subtractMonths - * @param {Number} count The number of months to subtract from the current calendar - */ - subtractMonths : function(count) { - this.addMonths(-1*count); - }, - - /** - * Adds the designated number of years to the current calendar, and sets the current - * calendar page date to the new month. - * @method addYears - * @param {Number} count The number of years to add to the current calendar - */ - addYears : function(count) { - var cfgPageDate = DEF_CFG.PAGEDATE.key, - - prevDate = this.cfg.getProperty(cfgPageDate), - newDate = DateMath.add(prevDate, DateMath.YEAR, count); - - this.cfg.setProperty(cfgPageDate, newDate); - this.resetRenderers(); - this.changePageEvent.fire(prevDate, newDate); - }, - - /** - * Subtcats the designated number of years from the current calendar, and sets the current - * calendar page date to the new month. - * @method subtractYears - * @param {Number} count The number of years to subtract from the current calendar - */ - subtractYears : function(count) { - this.addYears(-1*count); - }, - - /** - * Navigates to the next month page in the calendar widget. - * @method nextMonth - */ - nextMonth : function() { - this.addMonths(1); - }, - - /** - * Navigates to the previous month page in the calendar widget. - * @method previousMonth - */ - previousMonth : function() { - this.addMonths(-1); - }, - - /** - * Navigates to the next year in the currently selected month in the calendar widget. - * @method nextYear - */ - nextYear : function() { - this.addYears(1); - }, - - /** - * Navigates to the previous year in the currently selected month in the calendar widget. - * @method previousYear - */ - previousYear : function() { - this.addYears(-1); - }, - - // END MONTH NAVIGATION METHODS - - // BEGIN SELECTION METHODS - - /** - * Resets the calendar widget to the originally selected month and year, and - * sets the calendar to the initial selection(s). - * @method reset - */ - reset : function() { - this.cfg.resetProperty(DEF_CFG.SELECTED.key); - this.cfg.resetProperty(DEF_CFG.PAGEDATE.key); - this.resetEvent.fire(); - }, - - /** - * Clears the selected dates in the current calendar widget and sets the calendar - * to the current month and year. - * @method clear - */ - clear : function() { - this.cfg.setProperty(DEF_CFG.SELECTED.key, []); - this.cfg.setProperty(DEF_CFG.PAGEDATE.key, new Date(this.today.getTime())); - this.clearEvent.fire(); - }, - - /** - * Selects a date or a collection of dates on the current calendar. This method, by default, - * does not call the render method explicitly. Once selection has completed, render must be - * called for the changes to be reflected visually. - * - * Any dates which are OOB (out of bounds, not selectable) will not be selected and the array of - * selected dates passed to the selectEvent will not contain OOB dates. - * - * If all dates are OOB, the no state change will occur; beforeSelect and select events will not be fired. - * - * @method select - * @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are - * individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). - * Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). - * This method can also take a JavaScript Date object or an array of Date objects. - * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. - */ - select : function(date) { - - var aToBeSelected = this._toFieldArray(date), - validDates = [], - selected = [], - cfgSelected = DEF_CFG.SELECTED.key; - - - for (var a=0; a < aToBeSelected.length; ++a) { - var toSelect = aToBeSelected[a]; - - if (!this.isDateOOB(this._toDate(toSelect))) { - - if (validDates.length === 0) { - this.beforeSelectEvent.fire(); - selected = this.cfg.getProperty(cfgSelected); - } - validDates.push(toSelect); - - if (this._indexOfSelectedFieldArray(toSelect) == -1) { - selected[selected.length] = toSelect; - } - } - } - - - if (validDates.length > 0) { - if (this.parent) { - this.parent.cfg.setProperty(cfgSelected, selected); - } else { - this.cfg.setProperty(cfgSelected, selected); - } - this.selectEvent.fire(validDates); - } - - return this.getSelectedDates(); - }, - - /** - * Selects a date on the current calendar by referencing the index of the cell that should be selected. - * This method is used to easily select a single cell (usually with a mouse click) without having to do - * a full render. The selected style is applied to the cell directly. - * - * If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month - * or out of bounds cells), it will not be selected and in such a case beforeSelect and select events will not be fired. - * - * @method selectCell - * @param {Number} cellIndex The index of the cell to select in the current calendar. - * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. - */ - selectCell : function(cellIndex) { - - var cell = this.cells[cellIndex], - cellDate = this.cellDates[cellIndex], - dCellDate = this._toDate(cellDate), - selectable = Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE); - - - if (selectable) { - - this.beforeSelectEvent.fire(); - - var cfgSelected = DEF_CFG.SELECTED.key; - var selected = this.cfg.getProperty(cfgSelected); - - var selectDate = cellDate.concat(); - - if (this._indexOfSelectedFieldArray(selectDate) == -1) { - selected[selected.length] = selectDate; - } - if (this.parent) { - this.parent.cfg.setProperty(cfgSelected, selected); - } else { - this.cfg.setProperty(cfgSelected, selected); - } - this.renderCellStyleSelected(dCellDate,cell); - this.selectEvent.fire([selectDate]); - - this.doCellMouseOut.call(cell, null, this); - } - - return this.getSelectedDates(); - }, - - /** - * Deselects a date or a collection of dates on the current calendar. This method, by default, - * does not call the render method explicitly. Once deselection has completed, render must be - * called for the changes to be reflected visually. - * - * The method will not attempt to deselect any dates which are OOB (out of bounds, and hence not selectable) - * and the array of deselected dates passed to the deselectEvent will not contain any OOB dates. - * - * If all dates are OOB, beforeDeselect and deselect events will not be fired. - * - * @method deselect - * @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are - * individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). - * Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). - * This method can also take a JavaScript Date object or an array of Date objects. - * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. - */ - deselect : function(date) { - - var aToBeDeselected = this._toFieldArray(date), - validDates = [], - selected = [], - cfgSelected = DEF_CFG.SELECTED.key; - - - for (var a=0; a < aToBeDeselected.length; ++a) { - var toDeselect = aToBeDeselected[a]; - - if (!this.isDateOOB(this._toDate(toDeselect))) { - - if (validDates.length === 0) { - this.beforeDeselectEvent.fire(); - selected = this.cfg.getProperty(cfgSelected); - } - - validDates.push(toDeselect); - - var index = this._indexOfSelectedFieldArray(toDeselect); - if (index != -1) { - selected.splice(index,1); - } - } - } - - - if (validDates.length > 0) { - if (this.parent) { - this.parent.cfg.setProperty(cfgSelected, selected); - } else { - this.cfg.setProperty(cfgSelected, selected); - } - this.deselectEvent.fire(validDates); - } - - return this.getSelectedDates(); - }, - - /** - * Deselects a date on the current calendar by referencing the index of the cell that should be deselected. - * This method is used to easily deselect a single cell (usually with a mouse click) without having to do - * a full render. The selected style is removed from the cell directly. - * - * If the cell is not marked with the CSS_CELL_SELECTABLE class (as is the case by default for out of month - * or out of bounds cells), the method will not attempt to deselect it and in such a case, beforeDeselect and - * deselect events will not be fired. - * - * @method deselectCell - * @param {Number} cellIndex The index of the cell to deselect in the current calendar. - * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. - */ - deselectCell : function(cellIndex) { - var cell = this.cells[cellIndex], - cellDate = this.cellDates[cellIndex], - cellDateIndex = this._indexOfSelectedFieldArray(cellDate); - - var selectable = Dom.hasClass(cell, this.Style.CSS_CELL_SELECTABLE); - - if (selectable) { - - this.beforeDeselectEvent.fire(); - - var selected = this.cfg.getProperty(DEF_CFG.SELECTED.key), - dCellDate = this._toDate(cellDate), - selectDate = cellDate.concat(); - - if (cellDateIndex > -1) { - if ((this.cfg.getProperty(DEF_CFG.PAGEDATE.key).getMonth() == dCellDate.getMonth() && - this.cfg.getProperty(DEF_CFG.PAGEDATE.key).getFullYear() == dCellDate.getFullYear()) || this.cfg.getProperty(DEF_CFG.OOM_SELECT.key)) { - Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED); - } - selected.splice(cellDateIndex, 1); - } - - if (this.parent) { - this.parent.cfg.setProperty(DEF_CFG.SELECTED.key, selected); - } else { - this.cfg.setProperty(DEF_CFG.SELECTED.key, selected); - } - - this.deselectEvent.fire([selectDate]); - } - - return this.getSelectedDates(); - }, - - /** - * Deselects all dates on the current calendar. - * @method deselectAll - * @return {Date[]} Array of JavaScript Date objects representing all individual dates that are currently selected. - * Assuming that this function executes properly, the return value should be an empty array. - * However, the empty array is returned for the sake of being able to check the selection status - * of the calendar. - */ - deselectAll : function() { - this.beforeDeselectEvent.fire(); - - var cfgSelected = DEF_CFG.SELECTED.key, - selected = this.cfg.getProperty(cfgSelected), - count = selected.length, - sel = selected.concat(); - - if (this.parent) { - this.parent.cfg.setProperty(cfgSelected, []); - } else { - this.cfg.setProperty(cfgSelected, []); - } - - if (count > 0) { - this.deselectEvent.fire(sel); - } - - return this.getSelectedDates(); - }, - - // END SELECTION METHODS - - // BEGIN TYPE CONVERSION METHODS - - /** - * Converts a date (either a JavaScript Date object, or a date string) to the internal data structure - * used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]]. - * @method _toFieldArray - * @private - * @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are - * individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006). - * Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005). - * This method can also take a JavaScript Date object or an array of Date objects. - * @return {Array[](Number[])} Array of date field arrays - */ - _toFieldArray : function(date) { - var returnDate = []; - - if (date instanceof Date) { - returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]]; - } else if (Lang.isString(date)) { - returnDate = this._parseDates(date); - } else if (Lang.isArray(date)) { - for (var i=0;i maxDate.getTime())); - }, - - /** - * Parses a pagedate configuration property value. The value can either be specified as a string of form "mm/yyyy" or a Date object - * and is parsed into a Date object normalized to the first day of the month. If no value is passed in, the month and year from today's date are used to create the Date object - * @method _parsePageDate - * @private - * @param {Date|String} date Pagedate value which needs to be parsed - * @return {Date} The Date object representing the pagedate - */ - _parsePageDate : function(date) { - var parsedDate; - - if (date) { - if (date instanceof Date) { - parsedDate = DateMath.findMonthStart(date); - } else { - var month, year, aMonthYear; - aMonthYear = date.split(this.cfg.getProperty(DEF_CFG.DATE_FIELD_DELIMITER.key)); - month = parseInt(aMonthYear[this.cfg.getProperty(DEF_CFG.MY_MONTH_POSITION.key)-1], 10)-1; - year = parseInt(aMonthYear[this.cfg.getProperty(DEF_CFG.MY_YEAR_POSITION.key)-1], 10) - this.Locale.YEAR_OFFSET; - - parsedDate = DateMath.getDate(year, month, 1); - } - } else { - parsedDate = DateMath.getDate(this.today.getFullYear(), this.today.getMonth(), 1); - } - return parsedDate; - }, - - // END UTILITY METHODS - - // BEGIN EVENT HANDLERS - - /** - * Event executed before a date is selected in the calendar widget. - * @deprecated Event handlers for this event should be susbcribed to beforeSelectEvent. - */ - onBeforeSelect : function() { - if (this.cfg.getProperty(DEF_CFG.MULTI_SELECT.key) === false) { - if (this.parent) { - this.parent.callChildFunction("clearAllBodyCellStyles", this.Style.CSS_CELL_SELECTED); - this.parent.deselectAll(); - } else { - this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED); - this.deselectAll(); - } - } - }, - - /** - * Event executed when a date is selected in the calendar widget. - * @param {Array} selected An array of date field arrays representing which date or dates were selected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ] - * @deprecated Event handlers for this event should be susbcribed to selectEvent. - */ - onSelect : function(selected) { }, - - /** - * Event executed before a date is deselected in the calendar widget. - * @deprecated Event handlers for this event should be susbcribed to beforeDeselectEvent. - */ - onBeforeDeselect : function() { }, - - /** - * Event executed when a date is deselected in the calendar widget. - * @param {Array} selected An array of date field arrays representing which date or dates were deselected. Example: [ [2006,8,6],[2006,8,7],[2006,8,8] ] - * @deprecated Event handlers for this event should be susbcribed to deselectEvent. - */ - onDeselect : function(deselected) { }, - - /** - * Event executed when the user navigates to a different calendar page. - * @deprecated Event handlers for this event should be susbcribed to changePageEvent. - */ - onChangePage : function() { - this.render(); - }, - - /** - * Event executed when the calendar widget is rendered. - * @deprecated Event handlers for this event should be susbcribed to renderEvent. - */ - onRender : function() { }, - - /** - * Event executed when the calendar widget is reset to its original state. - * @deprecated Event handlers for this event should be susbcribed to resetEvemt. - */ - onReset : function() { this.render(); }, - - /** - * Event executed when the calendar widget is completely cleared to the current month with no selections. - * @deprecated Event handlers for this event should be susbcribed to clearEvent. - */ - onClear : function() { this.render(); }, - - /** - * Validates the calendar widget. This method has no default implementation - * and must be extended by subclassing the widget. - * @return Should return true if the widget validates, and false if - * it doesn't. - * @type Boolean - */ - validate : function() { return true; }, - - // END EVENT HANDLERS - - // BEGIN DATE PARSE METHODS - - /** - * Converts a date string to a date field array - * @private - * @param {String} sDate Date string. Valid formats are mm/dd and mm/dd/yyyy. - * @return A date field array representing the string passed to the method - * @type Array[](Number[]) - */ - _parseDate : function(sDate) { - var aDate = sDate.split(this.Locale.DATE_FIELD_DELIMITER), - rArray; - - if (aDate.length == 2) { - rArray = [aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]]; - rArray.type = Calendar.MONTH_DAY; - } else { - rArray = [aDate[this.Locale.MDY_YEAR_POSITION-1] - this.Locale.YEAR_OFFSET, aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]]; - rArray.type = Calendar.DATE; - } - - for (var i=0;iNOTE: The contents of the cell set by the renderer will be added to the DOM as HTML. The custom renderer implementation should - * escape markup used to set the cell contents, if coming from an external source.

- * @method addRenderer - * @param {String} sDates A date string to associate with the specified renderer. Valid formats - * include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005) - * @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. - */ - addRenderer : function(sDates, fnRender) { - var aDates = this._parseDates(sDates); - for (var i=0;iNOTE: The contents of the cell set by the renderer will be added to the DOM as HTML. The custom renderer implementation should - * escape markup used to set the cell contents, if coming from an external source.

- * @method addMonthRenderer - * @param {Number} month The month (1-12) to associate with this renderer - * @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. - */ - addMonthRenderer : function(month, fnRender) { - this._addRenderer(Calendar.MONTH,[month],fnRender); - }, - - /** - * Adds a weekday renderer to the render stack. The function reference passed to this method will be executed - * when a date cell matches the weekday passed to this method. - * - *

NOTE: The contents of the cell set by the renderer will be added to the DOM as HTML. The custom renderer implementation should - * escape HTML used to set the cell contents, if coming from an external source.

- * - * @method addWeekdayRenderer - * @param {Number} weekday The weekday (Sunday = 1, Monday = 2 ... Saturday = 7) to associate with this renderer - * @param {Function} fnRender The function executed to render cells that match the render rules for this renderer. - */ - addWeekdayRenderer : function(weekday, fnRender) { - this._addRenderer(Calendar.WEEKDAY,[weekday],fnRender); - }, - - // END RENDERER METHODS - - // BEGIN CSS METHODS - - /** - * Removes all styles from all body cells in the current calendar table. - * @method clearAllBodyCellStyles - * @param {style} style The CSS class name to remove from all calendar body cells - */ - clearAllBodyCellStyles : function(style) { - for (var c=0;c -*

-*
-* -* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers. -* -*

-* NOTE: As of 2.4.0, the constructor's ID argument is optional. -* The CalendarGroup can be constructed by simply providing a container ID string, -* or a reference to a container DIV HTMLElement (the element needs to exist -* in the document). -* -* E.g.: -*

-* var c = new YAHOO.widget.CalendarGroup("calContainer", configOptions); -* -* or: -* -* var containerDiv = YAHOO.util.Dom.get("calContainer"); -* var c = new YAHOO.widget.CalendarGroup(containerDiv, configOptions); -* -*

-*

-* If not provided, the ID will be generated from the container DIV ID by adding an "_t" suffix. -* For example if an ID is not provided, and the container's ID is "calContainer", the CalendarGroup's ID will be set to "calContainer_t". -*

-* -* @namespace YAHOO.widget -* @class CalendarGroup -* @constructor -* @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. -* @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. -* @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. -*/ -function CalendarGroup(id, containerId, config) { - if (arguments.length > 0) { - this.init.apply(this, arguments); - } -} - -/** -* The set of default Config property keys and values for the CalendarGroup. -* -*

-* NOTE: This property is made public in order to allow users to change -* the default values of configuration properties. Users should not -* modify the key string, unless they are overriding the Calendar implementation -*

-* -* @property YAHOO.widget.CalendarGroup.DEFAULT_CONFIG -* @static -* @type Object An object with key/value pairs, the key being the -* uppercase configuration property name and the value being an objec -* literal with a key string property, and a value property, specifying the -* default value of the property -*/ - -/** -* The set of default Config property keys and values for the CalendarGroup -* @property YAHOO.widget.CalendarGroup._DEFAULT_CONFIG -* @deprecated Made public. See the public DEFAULT_CONFIG property for details -* @private -* @static -* @type Object -*/ -CalendarGroup.DEFAULT_CONFIG = CalendarGroup._DEFAULT_CONFIG = Calendar.DEFAULT_CONFIG; -CalendarGroup.DEFAULT_CONFIG.PAGES = {key:"pages", value:2}; - -var DEF_CFG = CalendarGroup.DEFAULT_CONFIG; - -CalendarGroup.prototype = { - - /** - * Initializes the calendar group. All subclasses must call this method in order for the - * group to be initialized properly. - * @method init - * @param {String} id optional The id of the table element that will represent the CalendarGroup widget. As of 2.4.0, this argument is optional. - * @param {String | HTMLElement} container The id of the container div element that will wrap the CalendarGroup table, or a reference to a DIV element which exists in the document. - * @param {Object} config optional The configuration object containing the initial configuration values for the CalendarGroup. - */ - init : function(id, container, config) { - - // Normalize 2.4.0, pre 2.4.0 args - var nArgs = this._parseArgs(arguments); - - id = nArgs.id; - container = nArgs.container; - config = nArgs.config; - - this.oDomContainer = Dom.get(container); - - if (!this.oDomContainer.id) { - this.oDomContainer.id = Dom.generateId(); - } - if (!id) { - id = this.oDomContainer.id + "_t"; - } - - /** - * The unique id associated with the CalendarGroup - * @property id - * @type String - */ - this.id = id; - - /** - * The unique id associated with the CalendarGroup container - * @property containerId - * @type String - */ - this.containerId = this.oDomContainer.id; - - this.initEvents(); - this.initStyles(); - - /** - * The collection of Calendar pages contained within the CalendarGroup - * @property pages - * @type YAHOO.widget.Calendar[] - */ - this.pages = []; - - Dom.addClass(this.oDomContainer, CalendarGroup.CSS_CONTAINER); - Dom.addClass(this.oDomContainer, CalendarGroup.CSS_MULTI_UP); - - /** - * The Config object used to hold the configuration variables for the CalendarGroup - * @property cfg - * @type YAHOO.util.Config - */ - this.cfg = new YAHOO.util.Config(this); - - /** - * The local object which contains the CalendarGroup's options - * @property Options - * @type Object - */ - this.Options = {}; - - /** - * The local object which contains the CalendarGroup's locale settings - * @property Locale - * @type Object - */ - this.Locale = {}; - - this.setupConfig(); - - if (config) { - this.cfg.applyConfig(config, true); - } - - this.cfg.fireQueue(); - - }, - - setupConfig : function() { - - var cfg = this.cfg; - - /** - * The number of pages to include in the CalendarGroup. This value can only be set once, in the CalendarGroup's constructor arguments. - * @config pages - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.PAGES.key, { value:DEF_CFG.PAGES.value, validator:cfg.checkNumber, handler:this.configPages } ); - - /** - * The positive or negative year offset from the Gregorian calendar year (assuming a January 1st rollover) to - * be used when displaying or parsing dates. NOTE: All JS Date objects returned by methods, or expected as input by - * methods will always represent the Gregorian year, in order to maintain date/month/week values. - * - * @config year_offset - * @type Number - * @default 0 - */ - cfg.addProperty(DEF_CFG.YEAR_OFFSET.key, { value:DEF_CFG.YEAR_OFFSET.value, handler: this.delegateConfig, supercedes:DEF_CFG.YEAR_OFFSET.supercedes, suppressEvent:true } ); - - /** - * The date to use to represent "Today". - * - * @config today - * @type Date - * @default Today's date - */ - cfg.addProperty(DEF_CFG.TODAY.key, { value: new Date(DEF_CFG.TODAY.value.getTime()), supercedes:DEF_CFG.TODAY.supercedes, handler: this.configToday, suppressEvent:false } ); - - /** - * The month/year representing the current visible Calendar date (mm/yyyy) - * @config pagedate - * @type String | Date - * @default Today's date - */ - cfg.addProperty(DEF_CFG.PAGEDATE.key, { value: DEF_CFG.PAGEDATE.value || new Date(DEF_CFG.TODAY.value.getTime()), handler:this.configPageDate } ); - - /** - * The date or range of dates representing the current Calendar selection - * - * @config selected - * @type String - * @default [] - */ - cfg.addProperty(DEF_CFG.SELECTED.key, { value:[], handler:this.configSelected } ); - - /** - * The title to display above the CalendarGroup's month header. The title is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config title - * @type HTML - * @default "" - */ - cfg.addProperty(DEF_CFG.TITLE.key, { value:DEF_CFG.TITLE.value, handler:this.configTitle } ); - - /** - * Whether or not a close button should be displayed for this CalendarGroup - * @config close - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.CLOSE.key, { value:DEF_CFG.CLOSE.value, handler:this.configClose } ); - - /** - * Whether or not an iframe shim should be placed under the Calendar to prevent select boxes from bleeding through in Internet Explorer 6 and below. - * This property is enabled by default for IE6 and below. It is disabled by default for other browsers for performance reasons, but can be - * enabled if required. - * - * @config iframe - * @type Boolean - * @default true for IE6 and below, false for all other browsers - */ - cfg.addProperty(DEF_CFG.IFRAME.key, { value:DEF_CFG.IFRAME.value, handler:this.configIframe, validator:cfg.checkBoolean } ); - - /** - * The minimum selectable date in the current Calendar (mm/dd/yyyy) - * @config mindate - * @type String | Date - * @default null - */ - cfg.addProperty(DEF_CFG.MINDATE.key, { value:DEF_CFG.MINDATE.value, handler:this.delegateConfig } ); - - /** - * The maximum selectable date in the current Calendar (mm/dd/yyyy) - * @config maxdate - * @type String | Date - * @default null - */ - cfg.addProperty(DEF_CFG.MAXDATE.key, { value:DEF_CFG.MAXDATE.value, handler:this.delegateConfig } ); - - /** - * True if the Calendar should allow multiple selections. False by default. - * @config MULTI_SELECT - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.MULTI_SELECT.key, { value:DEF_CFG.MULTI_SELECT.value, handler:this.delegateConfig, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should allow selection of out-of-month dates. False by default. - * @config OOM_SELECT - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.OOM_SELECT.key, { value:DEF_CFG.OOM_SELECT.value, handler:this.delegateConfig, validator:cfg.checkBoolean } ); - - /** - * The weekday the week begins on. Default is 0 (Sunday). - * @config START_WEEKDAY - * @type number - * @default 0 - */ - cfg.addProperty(DEF_CFG.START_WEEKDAY.key, { value:DEF_CFG.START_WEEKDAY.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * True if the Calendar should show weekday labels. True by default. - * @config SHOW_WEEKDAYS - * @type Boolean - * @default true - */ - cfg.addProperty(DEF_CFG.SHOW_WEEKDAYS.key, { value:DEF_CFG.SHOW_WEEKDAYS.value, handler:this.delegateConfig, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row headers. False by default. - * @config SHOW_WEEK_HEADER - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.SHOW_WEEK_HEADER.key,{ value:DEF_CFG.SHOW_WEEK_HEADER.value, handler:this.delegateConfig, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should show week row footers. False by default. - * @config SHOW_WEEK_FOOTER - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.SHOW_WEEK_FOOTER.key,{ value:DEF_CFG.SHOW_WEEK_FOOTER.value, handler:this.delegateConfig, validator:cfg.checkBoolean } ); - - /** - * True if the Calendar should suppress weeks that are not a part of the current month. False by default. - * @config HIDE_BLANK_WEEKS - * @type Boolean - * @default false - */ - cfg.addProperty(DEF_CFG.HIDE_BLANK_WEEKS.key,{ value:DEF_CFG.HIDE_BLANK_WEEKS.value, handler:this.delegateConfig, validator:cfg.checkBoolean } ); - - /** - * The image URL that should be used for the left navigation arrow. The image URL is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config NAV_ARROW_LEFT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the left arrow - "calnavleft" - * @default null - */ - cfg.addProperty(DEF_CFG.NAV_ARROW_LEFT.key, { value:DEF_CFG.NAV_ARROW_LEFT.value, handler:this.delegateConfig } ); - - /** - * The image URL that should be used for the right navigation arrow. The image URL is inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config NAV_ARROW_RIGHT - * @type String - * @deprecated You can customize the image by overriding the default CSS class for the right arrow - "calnavright" - * @default null - */ - cfg.addProperty(DEF_CFG.NAV_ARROW_RIGHT.key, { value:DEF_CFG.NAV_ARROW_RIGHT.value, handler:this.delegateConfig } ); - - // Locale properties - - /** - * The short month labels for the current locale. The month labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config MONTHS_SHORT - * @type HTML[] - * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] - */ - cfg.addProperty(DEF_CFG.MONTHS_SHORT.key, { value:DEF_CFG.MONTHS_SHORT.value, handler:this.delegateConfig } ); - - /** - * The long month labels for the current locale. The month labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config MONTHS_LONG - * @type HTML[] - * @default ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" - */ - cfg.addProperty(DEF_CFG.MONTHS_LONG.key, { value:DEF_CFG.MONTHS_LONG.value, handler:this.delegateConfig } ); - - /** - * The 1-character weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_1CHAR - * @type HTML[] - * @default ["S", "M", "T", "W", "T", "F", "S"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_1CHAR.key, { value:DEF_CFG.WEEKDAYS_1CHAR.value, handler:this.delegateConfig } ); - - /** - * The short weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_SHORT - * @type HTML[] - * @default ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_SHORT.key, { value:DEF_CFG.WEEKDAYS_SHORT.value, handler:this.delegateConfig } ); - - /** - * The medium weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_MEDIUM - * @type HTML[] - * @default ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_MEDIUM.key, { value:DEF_CFG.WEEKDAYS_MEDIUM.value, handler:this.delegateConfig } ); - - /** - * The long weekday labels for the current locale. The weekday labels are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - * @config WEEKDAYS_LONG - * @type HTML[] - * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] - */ - cfg.addProperty(DEF_CFG.WEEKDAYS_LONG.key, { value:DEF_CFG.WEEKDAYS_LONG.value, handler:this.delegateConfig } ); - - /** - * The setting that determines which length of month labels should be used. Possible values are "short" and "long". - * @config LOCALE_MONTHS - * @type String - * @default "long" - */ - cfg.addProperty(DEF_CFG.LOCALE_MONTHS.key, { value:DEF_CFG.LOCALE_MONTHS.value, handler:this.delegateConfig } ); - - /** - * The setting that determines which length of weekday labels should be used. Possible values are "1char", "short", "medium", and "long". - * @config LOCALE_WEEKDAYS - * @type String - * @default "short" - */ - cfg.addProperty(DEF_CFG.LOCALE_WEEKDAYS.key, { value:DEF_CFG.LOCALE_WEEKDAYS.value, handler:this.delegateConfig } ); - - /** - * The value used to delimit individual dates in a date string passed to various Calendar functions. - * @config DATE_DELIMITER - * @type String - * @default "," - */ - cfg.addProperty(DEF_CFG.DATE_DELIMITER.key, { value:DEF_CFG.DATE_DELIMITER.value, handler:this.delegateConfig } ); - - /** - * The value used to delimit date fields in a date string passed to various Calendar functions. - * @config DATE_FIELD_DELIMITER - * @type String - * @default "/" - */ - cfg.addProperty(DEF_CFG.DATE_FIELD_DELIMITER.key,{ value:DEF_CFG.DATE_FIELD_DELIMITER.value, handler:this.delegateConfig } ); - - /** - * The value used to delimit date ranges in a date string passed to various Calendar functions. - * @config DATE_RANGE_DELIMITER - * @type String - * @default "-" - */ - cfg.addProperty(DEF_CFG.DATE_RANGE_DELIMITER.key,{ value:DEF_CFG.DATE_RANGE_DELIMITER.value, handler:this.delegateConfig } ); - - /** - * The position of the month in a month/year date string - * @config MY_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MY_MONTH_POSITION.key, { value:DEF_CFG.MY_MONTH_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the year in a month/year date string - * @config MY_YEAR_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MY_YEAR_POSITION.key, { value:DEF_CFG.MY_YEAR_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the month in a month/day date string - * @config MD_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MD_MONTH_POSITION.key, { value:DEF_CFG.MD_MONTH_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the day in a month/year date string - * @config MD_DAY_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MD_DAY_POSITION.key, { value:DEF_CFG.MD_DAY_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the month in a month/day/year date string - * @config MDY_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MDY_MONTH_POSITION.key, { value:DEF_CFG.MDY_MONTH_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the day in a month/day/year date string - * @config MDY_DAY_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MDY_DAY_POSITION.key, { value:DEF_CFG.MDY_DAY_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the year in a month/day/year date string - * @config MDY_YEAR_POSITION - * @type Number - * @default 3 - */ - cfg.addProperty(DEF_CFG.MDY_YEAR_POSITION.key, { value:DEF_CFG.MDY_YEAR_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the month in the month year label string used as the Calendar header - * @config MY_LABEL_MONTH_POSITION - * @type Number - * @default 1 - */ - cfg.addProperty(DEF_CFG.MY_LABEL_MONTH_POSITION.key, { value:DEF_CFG.MY_LABEL_MONTH_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The position of the year in the month year label string used as the Calendar header - * @config MY_LABEL_YEAR_POSITION - * @type Number - * @default 2 - */ - cfg.addProperty(DEF_CFG.MY_LABEL_YEAR_POSITION.key, { value:DEF_CFG.MY_LABEL_YEAR_POSITION.value, handler:this.delegateConfig, validator:cfg.checkNumber } ); - - /** - * The suffix used after the month when rendering the Calendar header - * @config MY_LABEL_MONTH_SUFFIX - * @type String - * @default " " - */ - cfg.addProperty(DEF_CFG.MY_LABEL_MONTH_SUFFIX.key, { value:DEF_CFG.MY_LABEL_MONTH_SUFFIX.value, handler:this.delegateConfig } ); - - /** - * The suffix used after the year when rendering the Calendar header - * @config MY_LABEL_YEAR_SUFFIX - * @type String - * @default "" - */ - cfg.addProperty(DEF_CFG.MY_LABEL_YEAR_SUFFIX.key, { value:DEF_CFG.MY_LABEL_YEAR_SUFFIX.value, handler:this.delegateConfig } ); - - /** - * Configuration for the Month/Year CalendarNavigator UI which allows the user to jump directly to a - * specific Month/Year without having to scroll sequentially through months. - *

- * Setting this property to null (default value) or false, will disable the CalendarNavigator UI. - *

- *

- * Setting this property to true will enable the CalendarNavigatior UI with the default CalendarNavigator configuration values. - *

- *

- * This property can also be set to an object literal containing configuration properties for the CalendarNavigator UI. - * The configuration object expects the the following case-sensitive properties, with the "strings" property being a nested object. - * Any properties which are not provided will use the default values (defined in the CalendarNavigator class). - *

- *
- *
strings
- *
Object : An object with the properties shown below, defining the string labels to use in the Navigator's UI. The strings are inserted into the DOM as HTML, and should be escaped by the implementor if coming from an external source. - *
- *
month
HTML : The markup to use for the month label. Defaults to "Month".
- *
year
HTML : The markup to use for the year label. Defaults to "Year".
- *
submit
HTML : The markup to use for the submit button label. Defaults to "Okay".
- *
cancel
HTML : The markup to use for the cancel button label. Defaults to "Cancel".
- *
invalidYear
HTML : The markup to use for invalid year values. Defaults to "Year needs to be a number".
- *
- *
- *
monthFormat
String : The month format to use. Either YAHOO.widget.Calendar.LONG, or YAHOO.widget.Calendar.SHORT. Defaults to YAHOO.widget.Calendar.LONG
- *
initialFocus
String : Either "year" or "month" specifying which input control should get initial focus. Defaults to "year"
- *
- *

E.g.

- *
-        * var navConfig = {
-        *   strings: {
-        *    month:"Calendar Month",
-        *    year:"Calendar Year",
-        *    submit: "Submit",
-        *    cancel: "Cancel",
-        *    invalidYear: "Please enter a valid year"
-        *   },
-        *   monthFormat: YAHOO.widget.Calendar.SHORT,
-        *   initialFocus: "month"
-        * }
-        * 
- * @config navigator - * @type {Object|Boolean} - * @default null - */ - cfg.addProperty(DEF_CFG.NAV.key, { value:DEF_CFG.NAV.value, handler:this.configNavigator } ); - - /** - * The map of UI strings which the CalendarGroup UI uses. - * - * @config strings - * @type {Object} - * @default An object with the properties shown below: - *
- *
previousMonth
HTML : The markup to use for the "Previous Month" navigation label. Defaults to "Previous Month". The string is added to the DOM as HTML, and should be escaped by the implementor if coming from an external source.
- *
nextMonth
HTML : The markup to use for the "Next Month" navigation UI. Defaults to "Next Month". The string is added to the DOM as HTML, and should be escaped by the implementor if coming from an external source.
- *
close
HTML : The markup to use for the close button label. Defaults to "Close". The string is added to the DOM as HTML, and should be escaped by the implementor if coming from an external source.
- *
- */ - cfg.addProperty(DEF_CFG.STRINGS.key, { - value:DEF_CFG.STRINGS.value, - handler:this.configStrings, - validator: function(val) { - return Lang.isObject(val); - }, - supercedes: DEF_CFG.STRINGS.supercedes - }); - }, - - /** - * Initializes CalendarGroup's built-in CustomEvents - * @method initEvents - */ - initEvents : function() { - - var me = this, - strEvent = "Event", - CE = YAHOO.util.CustomEvent; - - /** - * Proxy subscriber to subscribe to the CalendarGroup's child Calendars' CustomEvents - * @method sub - * @private - * @param {Function} fn The function to subscribe to this CustomEvent - * @param {Object} obj The CustomEvent's scope object - * @param {Boolean} bOverride Whether or not to apply scope correction - */ - var sub = function(fn, obj, bOverride) { - for (var p=0;p