JBoss Rich Faces SVN: r19635 - in sandbox/trunk/ui/calendar/ui/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-10-21 08:50:44 -0400 (Thu, 21 Oct 2010)
New Revision: 19635
Modified:
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml
Log:
RF-9152, RF-9169
fix renderer, migrate some methods to calendar component class
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-21 09:18:29 UTC (rev 19634)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-21 12:50:44 UTC (rev 19635)
@@ -23,11 +23,22 @@
package org.richfaces.component;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.DateTimeConverter;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.EventName;
@@ -78,6 +89,12 @@
public abstract boolean isEnableManualInput();
@Attribute
+ public abstract boolean isDayEnabled();
+
+ @Attribute
+ public abstract String getDayStyleClass();
+
+ @Attribute
public abstract String getTabindex();
@Attribute
@@ -103,6 +120,9 @@
@Attribute
public abstract String getButtonIconDisabled();
+
+ @Attribute
+ public abstract Object getDefaultTime();
@Attribute(events=@EventName("inputclick"))
public abstract String getOninputclick();
@@ -146,94 +166,151 @@
@Attribute(events=@EventName("inputblur"))
public abstract String getOninputblur();
+ public Calendar getCalendar() {
+ return Calendar.getInstance(getTimeZone(), getAsLocale(getLocale()));
+ }
+
public Date getCurrentDateOrDefault() {
- /*
Date date = getAsDate(getCurrentDate());
-
- if (date != null) {
- return date;
- } else {
- Date value = getAsDate(this.getValue());
- if (value != null) {
- return value;
- } else {
- return java.util.Calendar.getInstance(getTimeZone()).getTime();
+ if (date == null) {
+ date = getAsDate(this.getValue());
+
+ if (date == null) {
+ TimeZone timeZone = getTimeZone();
+ Calendar calendar = timeZone != null ? Calendar.getInstance(timeZone) : Calendar.getInstance();
+ date = calendar.getTime();
}
-
+
}
- */
- return null;
+ return date;
}
public Date getAsDate(Object date) {
- /*
+ if(date == null) {
+ return null;
+ }
- if (date == null) {
- return null;
+ Date value = null;
+ FacesContext facesContext = getFacesContext();
+ if(date instanceof Date) {
+ value = (Date)date;
+
+ } else if(date instanceof String) {
+ DateTimeConverter converter = new DateTimeConverter();
+ converter.setPattern(this.getDatePattern());
+ converter.setLocale(getAsLocale(this.getLocale()));
+ converter.setTimeZone(this.getTimeZone());
+ value = (Date)converter.getAsObject(facesContext, this,(String) date);
+
+ } else if(date instanceof Calendar) {
+ value = ((Calendar) date).getTime();
+
} else {
+ Converter converter = getConverter();
+ if(converter != null) {
+ return getAsDate(converter.getAsString(facesContext, this, date));
+ }
- if (date instanceof Date) {
- return (Date) date;
+ Application application = facesContext.getApplication();
+ converter = application.createConverter(date.getClass());
+ if (null != converter) {
+ value = getAsDate(converter.getAsString(facesContext, this, date));
} else {
- if (date instanceof String) {
- DateTimeConverter converter = new DateTimeConverter();
- converter.setPattern(this.getDatePattern());
- converter.setLocale(getAsLocale(this.getLocale()));
- converter.setTimeZone(this.getTimeZone());
- FacesContext context = FacesContext.getCurrentInstance();
- return (Date) converter.getAsObject(context, this,
- (String) date);
- } else {
- if (date instanceof Calendar) {
- return ((Calendar) date).getTime();
- } else {
-
- FacesContext context = FacesContext.getCurrentInstance();
- Converter converter = getConverter();
-
- if(converter != null) {
- return getAsDate(converter.getAsString(context, this, date));
- }
-
- Application application = context.getApplication();
- converter = application.createConverter(date.getClass());
- if (null != converter) {
- return getAsDate(converter.getAsString(context, this, date));
- } else {
- throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
- }
-
- }
- }
+ throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
}
+
}
- */
- return null;
+
+ return value;
}
public Locale getAsLocale(Object locale) {
- /*
+ Locale localeValue = null;
if (locale instanceof Locale) {
- return (Locale) locale;
+ localeValue = (Locale)locale;
} else if (locale instanceof String) {
+ localeValue = parseLocale((String) locale);
- return parseLocale((String) locale);
-
} else {
-
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
Converter converter = application .createConverter(locale.getClass());
+
if (null != converter) {
- return parseLocale(converter.getAsString(context, this, locale));
+ localeValue = parseLocale(converter.getAsString(context, this, locale));
} else {
- throw new FacesException(
- "Wrong locale attibute type or there is no converter for custom attibute type");
+ throw new FacesException("Wrong locale attibute type or there is no converter for custom attibute type");
}
- }*/
- return null;
+ }
+ return localeValue;
}
+
+ public Locale parseLocale(String localeStr){
+ if(null==localeStr || localeStr.trim().length() < 2) {
+ return Locale.getDefault();
+ }
+
+ //Lookup index of first '_' in string locale representation.
+ int index1 = localeStr.indexOf("_");
+ //Get first charters (if exist) from string
+ String language = null;
+ if(index1!=-1){
+ language = localeStr.substring(0, index1);
+ }else{
+ return new Locale(localeStr);
+ }
+
+ //Lookup index of second '_' in string locale representation.
+ int index2 = localeStr.indexOf("_", index1+1);
+ String country = null;
+ if(index2!=-1){
+ country = localeStr.substring(index1+1, index2);
+ String variant = localeStr.substring(index2+1);
+ return new Locale(language, country, variant);
+ }else{
+ country = localeStr.substring(index1+1);
+ return new Locale(language, country);
+ }
+ }
+
+ public Date getFormattedDefaultTime() {
+ Object defaultTime = getDefaultTime();
+ if(defaultTime == null) {
+ return null;
+ }
+
+ Date result = null;
+ if (defaultTime instanceof Calendar) {
+ result = ((Calendar) defaultTime).getTime();
+
+ } else if (defaultTime instanceof Date) {
+ result = (Date) defaultTime;
+
+ } else {
+ String defaultTimeString = defaultTime.toString();
+ String datePattern = getDatePattern();
+
+ String timePattern = "\\s*[hHkKma]+[\\W&&\\S]+[hHkKma]+\\s*";
+ Pattern pattern = Pattern.compile(timePattern);
+ Matcher matcher = pattern.matcher(datePattern);
+
+ String subTimePattern = DEFAULT_TIME_PATTERN;
+ if(matcher.find()) {
+ subTimePattern = matcher.group().trim();
+ }
+
+ DateFormat format = new SimpleDateFormat(subTimePattern);
+ try {
+ result = format.parse(defaultTimeString);
+ } catch (ParseException parseException) {
+ // log??
+ result = null;
+ }
+ }
+
+ return result;
+ }
}
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java 2010-10-21 09:18:29 UTC (rev 19634)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java 2010-10-21 12:50:44 UTC (rev 19635)
@@ -20,5 +20,5 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
//TODO: rename to input after move to trunk
-(a)org.richfaces.cdk.annotations.TagLibrary(uri="http://richfaces.org/input", shortName="input")
+(a)org.richfaces.cdk.annotations.TagLibrary(uri="http://richfaces.org/calendar", shortName="calendar")
package org.richfaces.component;
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-21 09:18:29 UTC (rev 19634)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-21 12:50:44 UTC (rev 19635)
@@ -26,6 +26,7 @@
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
@@ -50,7 +51,10 @@
*/
@ResourceDependencies({ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "jquery.position.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
@ResourceDependency(name = "richfaces-event.js"),
@ResourceDependency(library = "org.richfaces", name = "json-dom.js"),
@ResourceDependency(library = "org.richfaces", name = "jquery.effects.core.js"),
@@ -60,7 +64,7 @@
@ResourceDependency(library = "org.richfaces", name = "calendar.js"),
@ResourceDependency(library = "org.richfaces", name = "calendar.ecss") })
public class CalendarRendererBase extends InputRendererBase {
-
+
public static final String OPTION_ENABLE_MANUAL_INPUT = "enableManualInput";
public static final String OPTION_DISABLED = "disabled";
@@ -110,8 +114,7 @@
public static final String OPTION_LABELS = "labels";
public static final String OPTION_DEFAULT_TIME = "defaultTime";
-
-
+
protected static final Map<String, ComponentAttribute> CALENDAR_INPUT_HANDLER_ATTRIBUTES = Collections.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
.setEventNames("inputclick")
@@ -156,7 +159,11 @@
.setEventNames("inputselect")
.setComponentAttributeName("oninputselect")));
+ private static final String HOURS_VALUE = "hours";
+
+ private static final String MINUTES_VALUE = "minutes";
+
public void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component, CALENDAR_INPUT_HANDLER_ATTRIBUTES);
}
@@ -227,7 +234,6 @@
return result;
}
-
public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar) throws IOException {
Date date = calendar.getCurrentDateOrDefault();
return formatDate(date);
@@ -260,30 +266,12 @@
}
public JSReference getIsDayEnabled(FacesContext facesContext, AbstractCalendar calendar) {
- /*UICalendar calendar = (UICalendar) component;
- String isDayEnabled = (String) calendar.getAttributes().get(
- "isDayEnabled");
- if (isDayEnabled != null && isDayEnabled.length() != 0) {
- return new JSReference(isDayEnabled); //new JSFunction(isDayEnabled);
- }*/
-
- return null;
+ return calendar.isDayEnabled() ? JSReference.TRUE : JSReference.FALSE;
}
-
-
public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar) {
-// TODO: refactor this
-
- /*
- UICalendar calendar = (UICalendar) component;
- String dayStyleClass = (String) calendar.getAttributes().get(
- "dayStyleClass");
- if (dayStyleClass != null && dayStyleClass.length() != 0) {
- return new JSReference(dayStyleClass);
- }*/
-
- return null;
+ String dayStyleClass = calendar.getDayStyleClass();
+ return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ? new JSReference(dayStyleClass) : null;
}
public Map<String, Object> getLabels(FacesContext facesContext, AbstractCalendar calendar) {
@@ -375,12 +363,11 @@
return null;
}
- public Map<String, Object> getPreparedDefaultTime(AbstractCalendar calendar) {
- /*
- Date date = component.getFormattedDefaultTime();
+ public Map<String, Object> getPreparedDefaultTime(AbstractCalendar abstractCalendar) {
+ Date date = abstractCalendar.getFormattedDefaultTime();
Map<String, Object> result = new HashMap<String, Object>();
if (date != null) {
- Calendar calendar = component.getCalendar();
+ Calendar calendar = abstractCalendar.getCalendar();
calendar.setTime(date);
int hours = calendar.get(Calendar.HOUR_OF_DAY);
int minutes = calendar.get(Calendar.MINUTE);
@@ -390,8 +377,7 @@
result.put(MINUTES_VALUE, minutes);
}
}
- return result; */
- return null;
+ return result;
}
public ScriptOptions createCalendarScriptOption(FacesContext facesContext, UIComponent component) throws IOException {
@@ -439,7 +425,8 @@
AbstractCalendar calendar = (AbstractCalendar)component;
ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
- JSFunction function = new JSFunction("new rf.ui.Calendar", calendar.getClientId(facesContext), scriptOptions);
+ //new RichFaces.ui.Calendar(id, locale, options, markups);
+ JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), "", scriptOptions, "");
StringBuffer scriptBuffer = new StringBuffer();
scriptBuffer.append(function.toScript()).append(".load()");
writer.write(scriptBuffer.toString());
Modified: sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml 2010-10-21 09:18:29 UTC (rev 19634)
+++ sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml 2010-10-21 12:50:44 UTC (rev 19635)
@@ -29,7 +29,6 @@
<cdk:class>org.richfaces.renderkit.html.CalendarRenderer</cdk:class>
<cdk:superclass>org.richfaces.renderkit.CalendarRendererBase</cdk:superclass>
<cdk:renderer-type>org.richfaces.CalendarRenderer</cdk:renderer-type>
- <cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
</cc:interface>
<cc:implementation>
<span id="#{clientId}" class="rf-ca #{component.attributes['styleClass']}" cdk:passThroughWithExclusions="id class">
13 years, 8 months
JBoss Rich Faces SVN: r19633 - sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-10-21 05:17:11 -0400 (Thu, 21 Oct 2010)
New Revision: 19633
Added:
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
Removed:
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java
Log:
rename class
Added: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java (rev 0)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparator.java 2010-10-21 09:17:11 UTC (rev 19633)
@@ -0,0 +1,84 @@
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author amarkhel
+ *
+ */
+public class CalendarSeparator implements Java2DUserResource, StateHolderResource {
+
+ private static final Dimension DIMENSION = new Dimension(1, 15);
+
+ private Integer headerTextColor;
+
+ @PostConstructResource
+ public void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ this.headerTextColor = skin.getColorParameter(context, Skin.HEAD_TEXT_COLOR);
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(this.headerTextColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ this.headerTextColor = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.GIF;
+ }
+
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ graphics2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ graphics2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
+ graphics2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ Color color = new Color(this.headerTextColor);
+ graphics2d.setColor(color);
+
+ for (int i = 0;i < DIMENSION.getHeight(); i += 2 ) {
+ graphics2d.drawLine(0, i, 0, i);
+ }
+ }
+}
Deleted: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java 2010-10-21 09:10:33 UTC (rev 19632)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java 2010-10-21 09:17:11 UTC (rev 19633)
@@ -1,84 +0,0 @@
-package org.richfaces.renderkit.html.images;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.richfaces.resource.ImageType;
-import org.richfaces.resource.Java2DUserResource;
-import org.richfaces.resource.PostConstructResource;
-import org.richfaces.resource.StateHolderResource;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
-/**
- * @author amarkhel
- *
- */
-public class CalendarSeparatorNew implements Java2DUserResource, StateHolderResource {
-
- private static final Dimension DIMENSION = new Dimension(1, 15);
-
- private Integer headerTextColor;
-
- @PostConstructResource
- public void initialize() {
- FacesContext context = FacesContext.getCurrentInstance();
- Skin skin = SkinFactory.getInstance(context).getSkin(context);
-
- this.headerTextColor = skin.getColorParameter(context, Skin.HEAD_TEXT_COLOR);
- }
-
- public boolean isTransient() {
- return false;
- }
-
- public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
- dataOutput.writeInt(this.headerTextColor);
- }
-
- public void readState(FacesContext context, DataInput dataInput) throws IOException {
- this.headerTextColor = dataInput.readInt();
- }
-
- public Map<String, String> getResponseHeaders() {
- return null;
- }
-
- public Date getLastModified() {
- return null;
- }
-
- public ImageType getImageType() {
- return ImageType.GIF;
- }
-
- public Dimension getDimension() {
- return DIMENSION;
- }
-
- public void paint(Graphics2D graphics2d, Dimension dimension) {
- graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
- graphics2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
- graphics2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
- graphics2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
- graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
-
- Color color = new Color(this.headerTextColor);
- graphics2d.setColor(color);
-
- for (int i = 0;i < DIMENSION.getHeight(); i += 2 ) {
- graphics2d.drawLine(0, i, 0, i);
- }
- }
-}
13 years, 8 months
JBoss Rich Faces SVN: r19632 - in sandbox/trunk/ui/calendar/ui/src/main: java/org/richfaces/renderkit and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-10-21 05:10:33 -0400 (Thu, 21 Oct 2010)
New Revision: 19632
Added:
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java
Modified:
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml
Log:
RF-9152, RF-9169
continue renderer migration from 3.3.X to 4.X, fix checkstyles violations
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-21 08:57:27 UTC (rev 19631)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-10-21 09:10:33 UTC (rev 19632)
@@ -23,6 +23,7 @@
package org.richfaces.component;
+import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -145,6 +146,72 @@
@Attribute(events=@EventName("inputblur"))
public abstract String getOninputblur();
+ public Date getCurrentDateOrDefault() {
+ /*
+ Date date = getAsDate(getCurrentDate());
+
+ if (date != null) {
+ return date;
+ } else {
+ Date value = getAsDate(this.getValue());
+ if (value != null) {
+ return value;
+ } else {
+ return java.util.Calendar.getInstance(getTimeZone()).getTime();
+ }
+
+ }
+ */
+ return null;
+ }
+
+ public Date getAsDate(Object date) {
+ /*
+
+ if (date == null) {
+ return null;
+ } else {
+
+ if (date instanceof Date) {
+ return (Date) date;
+ } else {
+ if (date instanceof String) {
+ DateTimeConverter converter = new DateTimeConverter();
+ converter.setPattern(this.getDatePattern());
+ converter.setLocale(getAsLocale(this.getLocale()));
+ converter.setTimeZone(this.getTimeZone());
+ FacesContext context = FacesContext.getCurrentInstance();
+ return (Date) converter.getAsObject(context, this,
+ (String) date);
+ } else {
+ if (date instanceof Calendar) {
+ return ((Calendar) date).getTime();
+ } else {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ Converter converter = getConverter();
+
+ if(converter != null) {
+ return getAsDate(converter.getAsString(context, this, date));
+ }
+
+ Application application = context.getApplication();
+ converter = application.createConverter(date.getClass());
+ if (null != converter) {
+ return getAsDate(converter.getAsString(context, this, date));
+ } else {
+ throw new FacesException("Wrong attibute type or there is no converter for custom attibute type");
+ }
+
+ }
+ }
+ }
+ }
+ */
+ return null;
+ }
+
+
public Locale getAsLocale(Object locale) {
/*
if (locale instanceof Locale) {
Added: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java (rev 0)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/component/package-info.java 2010-10-21 09:10:33 UTC (rev 19632)
@@ -0,0 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+//TODO: rename to input after move to trunk
+(a)org.richfaces.cdk.annotations.TagLibrary(uri="http://richfaces.org/input", shortName="input")
+package org.richfaces.component;
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-21 08:57:27 UTC (rev 19631)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-10-21 09:10:33 UTC (rev 19632)
@@ -23,18 +23,23 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
+import java.util.TimeZone;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractCalendar;
import org.richfaces.component.util.SelectUtils;
import org.richfaces.component.util.ViewUtil;
@@ -56,6 +61,57 @@
@ResourceDependency(library = "org.richfaces", name = "calendar.ecss") })
public class CalendarRendererBase extends InputRendererBase {
+ public static final String OPTION_ENABLE_MANUAL_INPUT = "enableManualInput";
+
+ public static final String OPTION_DISABLED = "disabled";
+
+ public static final String OPTION_READONLY = "readonly";
+
+ public static final String OPTION_RESET_TIME_ON_DATE_SELECT = "resetTimeOnDateSelect";
+
+ public static final String OPTION_SHOW_APPLY_BUTTON = "showApplyButton";
+
+ public static final String OPTION_MIN_DAYS_IN_FIRST_WEEK = "minDaysInFirstWeek";
+
+ public static final String OPTION_POPUP = "popup";
+
+ public static final String OPTION_SHOW_INPUT = "showInput";
+
+ public static final String OPTION_SHOW_HEADER = "showHeader";
+
+ public static final String OPTION_SHOW_FOOTER = "showFooter";
+
+ public static final String OPTION_SHOW_WEEKS_BAR = "showWeeksBar";
+
+ public static final String OPTION_TODAY_CONTROL_MODE = "todayControlMode";
+
+ public static final String OPTION_DATE_PATTERN = "datePattern";
+
+ public static final String OPTION_JOINT_POINT = "jointPoint";
+
+ public static final String OPTION_DIRECTION = "direction";
+
+ public static final String OPTION_BOUNDARY_DATES_MODE = "boundaryDatesMode";
+
+ public static final String OPTION_HORIZONTAL_OFFSET = "horizontalOffset";
+
+ public static final String OPTION_VERTICAL_OFFSET = "verticalOffset";
+
+ public static final String OPTION_CURRENT_DATE = "currentDate";
+
+ public static final String OPTION_SELECTED_DATE = "selectedDate";
+
+ public static final String OPTION_SUBMIT_FUNCTION = "submitFunction";
+
+ public static final String OPTION_DAY_CELL_CLASS = "dayCellClass";
+
+ public static final String OPTION_DAY_STYLE_CLASS = "dayStyleClass";
+
+ public static final String OPTION_LABELS = "labels";
+
+ public static final String OPTION_DEFAULT_TIME = "defaultTime";
+
+
protected static final Map<String, ComponentAttribute> CALENDAR_INPUT_HANDLER_ATTRIBUTES = Collections.unmodifiableMap(ComponentAttribute.createMap(
new ComponentAttribute(HtmlConstants.ONCLICK_ATTRIBUTE)
.setEventNames("inputclick")
@@ -142,6 +198,253 @@
return (buttonIcon != null && !"".equals(buttonIcon)) ? getResourcePath(facesContext, buttonIcon) : "";
}
+ public Object getSelectedDate(FacesContext facesContext, AbstractCalendar calendar) throws IOException {
+ Object returnValue = null;
+ if(calendar.isValid()) {
+ Date date;
+ Object value = calendar.getValue();
+ date = calendar.getAsDate(value);
+ if(date != null) {
+ returnValue = formatSelectedDate(calendar.getTimeZone(), date);
+ }
+ }
+ return returnValue;
+ }
+
+ public static Object formatSelectedDate(TimeZone timeZone, Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeZone(timeZone);
+ calendar.setTime(date);
+
+ JSFunction result = new JSFunction("new Date");
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.HOUR_OF_DAY)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MINUTE)));
+ result.addParameter(new Integer(0));
+
+ return result;
+ }
+
+
+ public Object getCurrentDate(FacesContext facesContext, AbstractCalendar calendar) throws IOException {
+ Date date = calendar.getCurrentDateOrDefault();
+ return formatDate(date);
+ }
+
+ public static Object formatDate(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ JSFunction result = new JSFunction("new Date");
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.YEAR)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.MONTH)));
+ result.addParameter(Integer.valueOf(calendar.get(Calendar.DATE)));
+
+ return result;
+ }
+
+ public String getDayCellClass(FacesContext facesContext, AbstractCalendar calendar) {
+ //TODO: refactor this
+ /*
+ String cellwidth = (String) component.getAttributes().get("cellWidth");
+ String cellheight = (String) component.getAttributes().get("cellHeight");
+ if (cellwidth != null && cellwidth.length() != 0 || cellheight != null
+ && cellheight.length() != 0) {
+ String clientId = component.getClientId(context);
+ String value = clientId.replace(':', '_') + "DayCell";
+ return value;
+ }
+ */
+ return null;
+ }
+
+ public JSReference getIsDayEnabled(FacesContext facesContext, AbstractCalendar calendar) {
+ /*UICalendar calendar = (UICalendar) component;
+ String isDayEnabled = (String) calendar.getAttributes().get(
+ "isDayEnabled");
+ if (isDayEnabled != null && isDayEnabled.length() != 0) {
+ return new JSReference(isDayEnabled); //new JSFunction(isDayEnabled);
+ }*/
+
+ return null;
+ }
+
+
+
+ public JSReference getDayStyleClass(FacesContext context, AbstractCalendar calendar) {
+// TODO: refactor this
+
+ /*
+ UICalendar calendar = (UICalendar) component;
+ String dayStyleClass = (String) calendar.getAttributes().get(
+ "dayStyleClass");
+ if (dayStyleClass != null && dayStyleClass.length() != 0) {
+ return new JSReference(dayStyleClass);
+ }*/
+
+ return null;
+ }
+
+ public Map<String, Object> getLabels(FacesContext facesContext, AbstractCalendar calendar) {
+ /*
+ ResourceBundle bundle1 = null;
+ ResourceBundle bundle2 = null;
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ String messageBundle = context.getApplication().getMessageBundle();
+ Object locale = calendar.getLocale();
+ if (null != messageBundle) {
+ bundle1 = ResourceBundle.getBundle(messageBundle, calendar.getAsLocale(locale), loader);
+ }
+ try {
+ bundle2 = ResourceBundle.getBundle(CALENDAR_BUNDLE, calendar.getAsLocale(locale), loader);
+
+ } catch (MissingResourceException e) {
+ //No external bundle was found, ignore this exception.
+ }
+
+ Map<String, Object> labels = new HashMap<String, Object>();
+
+ if (null != bundle1 || null != bundle2) {
+ // TODO: make one function call
+ String[] names = {"apply", "today", "clean", "cancel", "ok", "close"};
+ RendererUtils utils= getUtils();
+
+ for (String name : names) {
+ String label = null;
+ String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() + "_LABEL";
+
+ if (bundle1 != null) {
+ try {
+ label = bundle1.getString(bundleKey);
+ } catch (MissingResourceException mre) {
+ // Current key was not found, ignore this exception;
+ }
+ }
+
+ // Current key wasn't found in application bundle, use CALENDAR_BUNDLE,
+ // if it is not null
+ if((label == null) && (bundle2 != null)) {
+ try {
+ label = bundle2.getString(bundleKey);
+ } catch (MissingResourceException mre) {
+ // Current key was not found, ignore this exception;
+ }
+ }
+ utils.addToScriptHash(labels, name, label);
+ }
+ }
+ return labels; */
+ return null;
+ }
+
+ public Object getSubmitFunction(FacesContext context, AbstractCalendar calendar) throws IOException {
+ /*
+ if (!UICalendar.AJAX_MODE.equals(calendar.getAttributes().get("mode")))
+ return null;
+
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(calendar, context,
+ AjaxRendererUtils.AJAX_FUNCTION_NAME);
+ ajaxFunction.addParameter(JSReference.NULL);
+
+ HashMap<String, Object> params = new HashMap<String, Object>();
+ params.put(calendar.getClientId(context) + CURRENT_DATE_PRELOAD, Boolean.TRUE);
+
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, calendar, params, true);
+ options.put("calendar", JSReference.THIS);
+
+ String oncomplete = AjaxRendererUtils.getAjaxOncomplete(calendar);
+ JSFunctionDefinition oncompleteDefinition = new JSFunctionDefinition();
+ oncompleteDefinition.addParameter("request");
+ oncompleteDefinition.addParameter("event");
+ oncompleteDefinition.addParameter("data");
+ oncompleteDefinition.addToBody("this.calendar.load(data, true);");
+ if (oncomplete != null) {
+ oncompleteDefinition.addToBody(oncomplete);
+ }
+
+ options.put("oncomplete", oncompleteDefinition);
+ JSReference requestValue = new JSReference("requestValue");
+ ajaxFunction.addParameter(options);
+ JSFunctionDefinition definition = new JSFunctionDefinition();
+ definition.addParameter(requestValue);
+ definition.addToBody(ajaxFunction);
+ return definition;
+ */
+
+ return null;
+ }
+
+ public Map<String, Object> getPreparedDefaultTime(AbstractCalendar calendar) {
+ /*
+ Date date = component.getFormattedDefaultTime();
+ Map<String, Object> result = new HashMap<String, Object>();
+ if (date != null) {
+ Calendar calendar = component.getCalendar();
+ calendar.setTime(date);
+ int hours = calendar.get(Calendar.HOUR_OF_DAY);
+ int minutes = calendar.get(Calendar.MINUTE);
+
+ if (hours != 12 || minutes != 0) {
+ result.put(HOURS_VALUE, hours);
+ result.put(MINUTES_VALUE, minutes);
+ }
+ }
+ return result; */
+ return null;
+ }
+
+ public ScriptOptions createCalendarScriptOption(FacesContext facesContext, UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar)component;
+
+ ScriptOptions scriptOptions = new ScriptOptions(component);
+ scriptOptions.addOption(OPTION_ENABLE_MANUAL_INPUT);
+ scriptOptions.addOption("disabled");
+ scriptOptions.addOption("readonly");
+ scriptOptions.addOption("resetTimeOnDateSelect"); //component
+ scriptOptions.addOption("showApplyButton"); //component
+ scriptOptions.addOption("styleClass"); //component
+ scriptOptions.addOption("minDaysInFirstWeek"); //component
+ scriptOptions.addOption("popup", true);
+ scriptOptions.addOption("showInput", true);
+ scriptOptions.addOption("showHeader", true);
+ scriptOptions.addOption("showFooter", true);
+ scriptOptions.addOption("showWeeksBar", true);
+ scriptOptions.addOption("showWeekDaysBar", true);
+ scriptOptions.addOption("todayControlMode", "select");
+ scriptOptions.addOption("datePattern", "MMM d, YYYY");
+ scriptOptions.addOption("jointPoint", "bottom-left");
+ scriptOptions.addOption("direction", "bottom-right");
+ scriptOptions.addOption("boundaryDatesMode", "inactive");
+ scriptOptions.addOption("horizontalOffset", 0);
+ scriptOptions.addOption("verticalOffset", 0);
+ scriptOptions.addOption("currentDate", getCurrentDate(facesContext, calendar));
+ scriptOptions.addOption("selectedDate", getSelectedDate(facesContext, calendar));
+ /*<cdk:scriptOption name="style" value="z-index: #{component.attributes['zindex']}; #{component.attributes['style']}" defaultValue="z-index: 3; "/>*/
+ scriptOptions.addOption("style", 0);
+ scriptOptions.addOption("submitFunction", getSubmitFunction(facesContext, calendar));
+ scriptOptions.addOption("dayCellClass", getDayCellClass(facesContext, calendar));
+ scriptOptions.addOption("dayStyleClass", getDayStyleClass(facesContext, calendar));
+ /*
+ *add to script option
+ *<cdk:scriptOption attributes="ondateselected, ondateselect, ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand, oncollapse, oncurrentdateselect, oncurrentdateselected" wrapper="eventHandler" />
+ * */
+ scriptOptions.addOption("labels", getLabels(facesContext, calendar));
+ scriptOptions.addOption("defaultTime", getPreparedDefaultTime(calendar));
+
+ return scriptOptions;
+ }
+
+ public void buildScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
+ AbstractCalendar calendar = (AbstractCalendar)component;
+
+ ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
+ JSFunction function = new JSFunction("new rf.ui.Calendar", calendar.getClientId(facesContext), scriptOptions);
+ StringBuffer scriptBuffer = new StringBuffer();
+ scriptBuffer.append(function.toScript()).append(".load()");
+ writer.write(scriptBuffer.toString());
+ }
+
protected String getResourcePath(FacesContext facesContext, String source) {
return (source != null && !"".equals(source)) ? ViewUtil.getResourceURL(source, facesContext) :"" ;
}
@@ -170,4 +473,5 @@
return converter;
}
+
}
\ No newline at end of file
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java 2010-10-21 08:57:27 UTC (rev 19631)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java 2010-10-21 09:10:33 UTC (rev 19632)
@@ -33,7 +33,7 @@
@DynamicResource
public class CalendarIcon implements Java2DUserResource, StateHolderResource{
- private static Dimension DIMENSION = new Dimension(20, 20);
+ private static final Dimension DIMENSION = new Dimension(20, 20);
private Integer headerTextColor;
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java 2010-10-21 08:57:27 UTC (rev 19631)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java 2010-10-21 09:10:33 UTC (rev 19632)
@@ -25,7 +25,7 @@
*/
public class CalendarSeparatorNew implements Java2DUserResource, StateHolderResource {
- private final static Dimension DIMENSION = new Dimension(1, 15);
+ private static final Dimension DIMENSION = new Dimension(1, 15);
private Integer headerTextColor;
Modified: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java 2010-10-21 08:57:27 UTC (rev 19631)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java 2010-10-21 09:10:33 UTC (rev 19632)
@@ -30,17 +30,17 @@
/**
* @author Maksim Kaszynski
- *
+ *
*/
public class DisabledCalendarIcon extends CalendarIcon {
- @Override
- protected BufferedImage createImage(int width, int height) {
- ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
- ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
- WritableRaster raster = ccm.createCompatibleWritableRaster(width, height);
+ @Override
+ protected BufferedImage createImage(int width, int height) {
+ ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+ ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
+ WritableRaster raster = ccm.createCompatibleWritableRaster(width, height);
- return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null);
- }
+ return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null);
+ }
}
Modified: sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml 2010-10-21 08:57:27 UTC (rev 19631)
+++ sandbox/trunk/ui/calendar/ui/src/main/templates/calendar.template.xml 2010-10-21 09:10:33 UTC (rev 19632)
@@ -81,49 +81,12 @@
name="#{clientId}InputCurrentDate"
value="#{component.attributes['currentDate']}" type="hidden" />
</span>
- <div style="display: none;" id="#{clientId}">
- </div>
-
- <!--cdk:scriptObject var="options" >
- <cdk:scriptOption attributes="enableManualInput, disabled, readonly, resetTimeOnDateSelect, showApplyButton, styleClass, minDaysInFirstWeek" />
- <cdk:scriptOption attributes="popup" defaultValue="true" />
- <cdk:scriptOption attributes="showInput" defaultValue="true" />
- <cdk:scriptOption attributes="ajaxSingle" defaultValue="true" />
- <cdk:scriptOption attributes="showHeader" defaultValue="true" />
- <cdk:scriptOption attributes="showFooter" defaultValue="true" />
- <cdk:scriptOption attributes="showWeeksBar" defaultValue="true" />
- <cdk:scriptOption attributes="showWeekDaysBar" defaultValue="true" />
- <cdk:scriptOption attributes="todayControlMode" defaultValue="select" />
- <cdk:scriptOption attributes="datePattern" defaultValue="MMM d, yyyy" />
- <cdk:scriptOption attributes="jointPoint" defaultValue="bottom-left" />
- <cdk:scriptOption attributes="direction" defaultValue="bottom-right" />
- <cdk:scriptOption attributes="boundaryDatesMode" defaultValue="inactive" />
- <cdk:scriptOption attributes="horizontalOffset" defaultValue="0" />
- <cdk:scriptOption attributes="verticalOffset" defaultValue="0" />
- <cdk:scriptOption attributes="hidePopupOnScroll" defaultValue="true" />
-
- <cdk:scriptOption name="currentDate" value="#{this:getCurrentDate(facesContext, component, currentDate)}" />
- <cdk:scriptOption name="selectedDate" value="#{this:getSelectedDate(facesContext, component)}" />
- <cdk:scriptOption name="style" value="z-index: #{component.attributes['zindex']}; #{component.attributes['style']}" defaultValue="z-index: 3; "/>
- <cdk:scriptOption name="submitFunction" value="#{this:getSubmitFunction(facesContext, component)}" />
- <cdk:scriptOption name="dayCellClass" value="#{this:getDayCellClass(facesContext, component)}" />
- <cdk:scriptOption name="dayStyleClass" value="#{this:getDayStyleClass(facesContext, component)}" />
- <cdk:scriptOption name="isDayEnabled" value="#{this:getIsDayEnabled(facesContext, component)}" />
-
- <cdk:scriptOption attributes="ondateselected, ondateselect, ontimeselect, ontimeselected, onchanged, ondatemouseover, ondatemouseout, onexpand, oncollapse, oncurrentdateselect, oncurrentdateselected" wrapper="eventHandler" />
- <cdk:scriptOption name="labels" value="#{this:getLabels(facesContext, component)}" />
- <cdk:scriptOption name="defaultTime" value="#{this:getPreparedDefaultTime(component)}" />
- </cdk:scriptObject>
+ <div style="display: none;" id="#{clientId}"></div>
+
<script type="text/javascript">
- new Calendar('#{clientId}',
- <c:if test="#{not empty options}">
- "#{options}"
- </c:if>
- <c:if test="#{empty options}">
- {}
- </c:if>
- ).load();
- </script-->
+ <cdk:call expression="buildScript(responseWriter, facesContext, component);" />
+ </script>
+
</span>
</cc:implementation>
</cdk:root>
13 years, 8 months
JBoss Rich Faces SVN: r19631 - sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-10-21 04:57:27 -0400 (Thu, 21 Oct 2010)
New Revision: 19631
Modified:
sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
Log:
https://jira.jboss.org/browse/RF-5364
client side support for seconds is implemented
Modified: sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-10-21 08:49:37 UTC (rev 19630)
+++ sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-10-21 08:57:27 UTC (rev 19631)
@@ -260,7 +260,7 @@
showApplyButton: false,
selectedDate: null,
currentDate: null,
- defaultTime: {hours:12,minutes:0},
+ defaultTime: {hours:12,minutes:0, seconds:0},
hidePopupOnScroll: true
};
@@ -616,6 +616,12 @@
}
th.value = (this.timeHoursDigits==2 && h<10 ? '0'+h : h);
tm.value = (m<10 ? '0'+m : m);
+
+ if (this.showSeconds) {
+ var tsec=rf.getDomElement(this.id+'TimeSeconds');
+ var s = this.selectedDate.getSeconds();
+ tsec.value = (s<10 ? '0'+s : s);
+ }
},
@@ -652,6 +658,10 @@
sbjQuery(ts).SpinButton({});
}
sbjQuery(tm).SpinButton({digits:2,min:0,max:59});
+ if (this.showSeconds) {
+ var tsec=rf.getDomElement(this.id+'TimeSeconds');
+ sbjQuery(tsec).SpinButton({digits:2,min:0,max:59});
+ }
this.correctEditorButtons(editor, this.TIME_EDITOR_BUTTON_OK, this.TIME_EDITOR_BUTTON_CANCEL);
@@ -762,7 +772,7 @@
var dateTimePattern = this.params.datePattern;
var pattern = [];
- var re = /(\\\\|\\[yMdaHhm])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g;
+ var re = /(\\\\|\\[yMdaHhms])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2}|s{2})/g;
var r;
while (r = re.exec(dateTimePattern))
if (!r[1])
@@ -771,7 +781,7 @@
var datePattern = "";
var timePattern = "";
- var digits,h,hh,m,a;
+ var digits,h,hh,m,s,a;
var id = this.id;
var getString = function (p) {
@@ -805,6 +815,11 @@
m=true;
timePattern+=getString(timePattern);
}
+ else if (ch=='s')
+ {
+ this.showSeconds=true;
+ timePattern+=getString(timePattern);
+ }
}
@@ -813,7 +828,7 @@
var calendar = this;
- this.timePatternHtml = timePattern.replace(/(\\\\|\\[yMdaHhm])|(H{1,2}|h{1,2}|m{2}|a)/g,
+ this.timePatternHtml = timePattern.replace(/(\\\\|\\[yMdaHhms])|(H{1,2}|h{1,2}|m{2}|s{2}|a)/g,
function($1,$2,$3) {
if ($2) return $2.charAt(1);
switch ($3) {
@@ -823,6 +838,7 @@
case 'h' :
case 'hh' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeHours')+'</td><td>';
case 'mm' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeMinutes')+'</td><td>';
+ case 'ss' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeSeconds')+'</td><td>';
}
}
);
@@ -1007,10 +1023,12 @@
{
date.setHours(this.selectedDate.getHours());
date.setMinutes(this.selectedDate.getMinutes());
+ date.setSeconds(this.selectedDate.getSeconds());
} else
{
date.setHours(this.params.defaultTime.hours);
date.setMinutes(this.params.defaultTime.minutes);
+ date.setSeconds(this.params.defaultTime.seconds);
}
},
@@ -1725,8 +1743,9 @@
this.hideEditor();
if (updateTime && this.selectedDate)
{
+ var s = this.showSeconds ? parseInt(rf.getDomElement(this.id+'TimeSeconds').value,10) : this.params.defaultTime.seconds;
var m = parseInt(rf.getDomElement(this.id+'TimeMinutes').value,10);
- var h=parseInt(rf.getDomElement(this.id+'TimeHours').value,10);
+ var h = parseInt(rf.getDomElement(this.id+'TimeHours').value,10);
if (this.timeType==2)
{
if (rf.getDomElement(this.id+'TimeSign').value.toLowerCase()=="am")
@@ -1738,7 +1757,7 @@
if (h!=12) h+=12;
}
}
- var date = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate(), h, m, 0);
+ var date = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate(), h, m, s);
if (date-this.selectedDate && this.invokeEvent("timeselect",null, null, date))
{
this.selectedDate = date;
13 years, 8 months
JBoss Rich Faces SVN: r19630 - sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-10-21 04:49:37 -0400 (Thu, 21 Oct 2010)
New Revision: 19630
Added:
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java
sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
Log:
add icons
Added: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java (rev 0)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarIcon.java 2010-10-21 08:49:37 UTC (rev 19630)
@@ -0,0 +1,164 @@
+package org.richfaces.renderkit.html.images;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Paint;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.DynamicResource;
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author amarkhel
+ *
+ */
+@DynamicResource
+public class CalendarIcon implements Java2DUserResource, StateHolderResource{
+
+ private static Dimension DIMENSION = new Dimension(20, 20);
+
+ private Integer headerTextColor;
+
+ private Integer headerBackgroundColor;
+
+
+ @PostConstructResource
+ public final void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ this.headerTextColor = skin.getColorParameter(context, Skin.HEAD_TEXT_COLOR);
+ this.headerBackgroundColor = skin.getColorParameter(context, Skin.HEADER_BACKGROUND_COLOR);
+ }
+
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(this.headerTextColor);
+ dataOutput.writeInt(this.headerBackgroundColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ this.headerTextColor = dataInput.readInt();
+ this.headerBackgroundColor = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.GIF;
+ }
+
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ protected BufferedImage createImage(int width, int height) {
+ return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ }
+
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ BufferedImage image = paintImage();
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics2d.drawImage(image, 0, 0, dimension.width, dimension.height, null);
+ }
+
+ public BufferedImage paintImage() {
+
+ BufferedImage image = createImage(16, 16);
+
+ Graphics2D g2d = image.createGraphics();
+
+ Color borderColor = new Color(this.headerTextColor);
+ Color activeColor = new Color(this.headerBackgroundColor);
+
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+
+ g2d.setStroke(new BasicStroke(1));
+
+ int w = 16;
+ int h = 16;
+
+ //Draw Border
+ g2d.setColor(borderColor);
+ Rectangle2D border = new Rectangle2D.Double(1, 1, w - 3, h - 3);
+ RoundRectangle2D round = new RoundRectangle2D.Double(1, 1, w- 3, h - 3, 2, 2);
+ g2d.draw(round);
+
+ Color lightBlue = new Color(216, 226, 240);
+ Paint gradient1 = new GradientPaint(w-4, h-4, lightBlue, 2, 2, Color.white);
+ g2d.setPaint(gradient1);
+ border = new Rectangle2D.Double(2, 2, w - 4, h - 4);
+ g2d.fill(border);
+
+ border = new Rectangle2D.Double(3, 3, w - 6, h - 6);
+ gradient1 = new GradientPaint(3, 3, lightBlue , w - 6, h - 6, borderColor);
+ g2d.setPaint(gradient1);
+ g2d.fill(border);
+
+ g2d.setColor(Color.white);
+ g2d.drawLine(3, 6, 3, 11);
+ g2d.drawLine(5, 6, 5, 11);
+ g2d.drawLine(7, 6, 7, 11);
+ g2d.drawLine(9, 6, 9, 11);
+ g2d.drawLine(11, 6, 11, 11);
+
+ //Draw orange rectangle
+ border = new Rectangle2D.Double(3, 3, 10, 3);
+ g2d.setColor(Color.white);
+ g2d.fill(border);
+
+ Color c = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 100);
+ Color c2 = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 200);
+
+ gradient1 = new GradientPaint(12, 4, activeColor, 4, 7, c2);
+ g2d.setPaint(gradient1);
+ g2d.fill(border);
+ //g2d.setColor(activeColor);
+
+ c = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 150);
+ c2 = new Color(activeColor.getRed(), activeColor.getGreen(), activeColor.getBlue(), 200);
+ border = new Rectangle2D.Double(4, 4, 8, 1);
+
+ g2d.setColor(Color.white);
+ g2d.fill(border);
+
+ gradient1 = new GradientPaint(4, 4, c, 10, 4, c2);
+ //g2d.setPaint(gradient1);
+ g2d.setColor(c);
+ g2d.fill(border);
+
+ g2d.dispose();
+
+ return image;
+ }
+}
Added: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java (rev 0)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/CalendarSeparatorNew.java 2010-10-21 08:49:37 UTC (rev 19630)
@@ -0,0 +1,84 @@
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.PostConstructResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author amarkhel
+ *
+ */
+public class CalendarSeparatorNew implements Java2DUserResource, StateHolderResource {
+
+ private final static Dimension DIMENSION = new Dimension(1, 15);
+
+ private Integer headerTextColor;
+
+ @PostConstructResource
+ public void initialize() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+
+ this.headerTextColor = skin.getColorParameter(context, Skin.HEAD_TEXT_COLOR);
+ }
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ dataOutput.writeInt(this.headerTextColor);
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException {
+ this.headerTextColor = dataInput.readInt();
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.GIF;
+ }
+
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ public void paint(Graphics2D graphics2d, Dimension dimension) {
+ graphics2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ graphics2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
+ graphics2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
+ graphics2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ graphics2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+
+ Color color = new Color(this.headerTextColor);
+ graphics2d.setColor(color);
+
+ for (int i = 0;i < DIMENSION.getHeight(); i += 2 ) {
+ graphics2d.drawLine(0, i, 0, i);
+ }
+ }
+}
Added: sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java (rev 0)
+++ sandbox/trunk/ui/calendar/ui/src/main/java/org/richfaces/renderkit/html/images/DisabledCalendarIcon.java 2010-10-21 08:49:37 UTC (rev 19630)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.renderkit.html.images;
+
+import java.awt.Transparency;
+import java.awt.color.ColorSpace;
+import java.awt.image.BufferedImage;
+import java.awt.image.ComponentColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.WritableRaster;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class DisabledCalendarIcon extends CalendarIcon {
+
+ @Override
+ protected BufferedImage createImage(int width, int height) {
+ ColorSpace gsColorSpace = ColorSpace.getInstance(ColorSpace.CS_GRAY);
+ ComponentColorModel ccm = new ComponentColorModel(gsColorSpace, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);
+ WritableRaster raster = ccm.createCompatibleWritableRaster(width, height);
+
+ return new BufferedImage(ccm, raster, ccm.isAlphaPremultiplied(), null);
+ }
+
+}
13 years, 8 months
JBoss Rich Faces SVN: r19629 - sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-10-21 04:13:53 -0400 (Thu, 21 Oct 2010)
New Revision: 19629
Modified:
sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js
Log:
https://jira.jboss.org/browse/RF-5364
Modified: sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js
===================================================================
--- sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js 2010-10-21 08:07:06 UTC (rev 19628)
+++ sandbox/trunk/ui/calendar/ui/src/main/resources/META-INF/resources/org.richfaces/calendar-utils.js 2010-10-21 08:13:53 UTC (rev 19629)
@@ -112,11 +112,11 @@
var counter=1;
var y,m,d;
- var a,h,min;
+ var a,h,min,s;
var shortLabel=false;
pattern = pattern.replace(/([.*+?^<>=!:${}()|[\]\/\\])/g, '\\$1');
- pattern = pattern.replace(/(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
+ pattern = pattern.replace(/(y+|M+|d+|a|H{1,2}|h{1,2}|m{2}|s{2})/g,
function($1) {
switch ($1) {
case 'y' :
@@ -131,6 +131,8 @@
case 'H' :
case 'h' : h=counter; counter++; return '(\\d{1,2})?';
case 'mm' : min=counter; counter++; return '(\\d{2})?';
+ case 'ss' : s=counter; counter++; return '(\\d{2})?';
+
}
// y+,M+,d+
var ch = $1.charAt(0);
@@ -185,6 +187,11 @@
else if (hh<0 || hh>23) return null;
date.setHours(hh); date.setMinutes(mmin);
+ if (s!=undefined)
+ {
+ sec = parseInt(match[s], 10); if (isNaN(sec) || sec<0 || sec>59) return null;
+ date.setSeconds(sec);
+ }
}
if (correctYear) {
@@ -202,8 +209,8 @@
formatDate: function(date, pattern, monthNames, monthNamesShort) {
if (!monthNames) monthNames = getDefaultMonthNames();
if (!monthNamesShort) monthNamesShort = getDefaultMonthNames(true);
- var mm; var dd; var hh; var min;
- var result = pattern.replace(/(\\\\|\\[yMdaHhm])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
+ var mm,dd,hh,min,sec;
+ var result = pattern.replace(/(\\\\|\\[yMdaHhms])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2}|s{2})/g,
function($1,$2,$3) {
if ($2) return $2.charAt(1);
switch ($3) {
@@ -219,6 +226,7 @@
case 'hh' : return ((hh = date.getHours())==0 ? '12' : (hh<10 ? '0'+hh : (hh>21 ? hh-12 : (hh>12) ? '0'+(hh-12) : hh)));
case 'h' : return ((hh = date.getHours())==0 ? '12' : (hh>12 ? hh-12 : hh));
case 'mm' : return ((min = date.getMinutes())<10 ? '0'+min : min);
+ case 'ss' : return ((sec = date.getSeconds())<10 ? '0'+sec : sec);
}
// y+,M+,d+
var ch = $3.charAt(0);
13 years, 8 months
JBoss Rich Faces SVN: r19628 - sandbox/trunk/prototypes/calendar.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-10-21 04:07:06 -0400 (Thu, 21 Oct 2010)
New Revision: 19628
Removed:
sandbox/trunk/prototypes/calendar/JQuerySpinBtn.js
sandbox/trunk/prototypes/calendar/calendar-utils.js
sandbox/trunk/prototypes/calendar/calendar.js
sandbox/trunk/prototypes/calendar/jquery.effects.core.js
sandbox/trunk/prototypes/calendar/jquery.effects.highlight.js
sandbox/trunk/prototypes/calendar/json-dom.js
Log:
https://jira.jboss.org/browse/RF-9152
https://jira.jboss.org/browse/RF-9168
Deleted: sandbox/trunk/prototypes/calendar/JQuerySpinBtn.js
===================================================================
--- sandbox/trunk/prototypes/calendar/JQuerySpinBtn.js 2010-10-21 06:35:50 UTC (rev 19627)
+++ sandbox/trunk/prototypes/calendar/JQuerySpinBtn.js 2010-10-21 08:07:06 UTC (rev 19628)
@@ -1,295 +0,0 @@
-/* SpinButton control
- *
- * Adds bells and whistles to any ordinary textbox to
- * make it look and feel like a SpinButton Control.
- *
- * Originally written by George Adamson, Software Unity (george.jquery(a)softwareunity.com) August 2006.
- * - Added min/max options
- * - Added step size option
- * - Added bigStep (page up/down) option
- *
- * Modifications made by Mark Gibson, (mgibson(a)designlinks.net) September 2006:
- * - Converted to jQuery plugin
- * - Allow limited or unlimited min/max values
- * - Allow custom class names, and add class to input element
- * - Removed global vars
- * - Reset (to original or through config) when invalid value entered
- * - Repeat whilst holding mouse button down (with initial pause, like keyboard repeat)
- * - Support mouse wheel in Firefox
- * - Fix double click in IE
- * - Refactored some code and renamed some vars
- *
- * Tested in IE6, Opera9, Firefox 1.5
- * v1.0 11 Aug 2006 - George Adamson - First release
- * v1.1 Aug 2006 - George Adamson - Minor enhancements
- * v1.2 27 Sep 2006 - Mark Gibson - Major enhancements
- * v1.3a 28 Sep 2006 - George Adamson - Minor enhancements
- * rf1.3a 15 Nov 2007 - Pavel Yaschenko - some changes
-
- Sample usage:
-
- // Create group of settings to initialise spinbutton(s). (Optional)
- var myOptions = {
- min: 0, // Set lower limit.
- max: 100, // Set upper limit.
- step: 1, // Set increment size.
- spinClass: mySpinBtnClass, // CSS class to style the spinbutton. (Class also specifies url of the up/down button image.)
- upClass: mySpinUpClass, // CSS class for style when mouse over up button.
- downClass: mySpinDnClass // CSS class for style when mouse over down button.
- }
-
- $(document).ready(function(){
-
- // Initialise INPUT element(s) as SpinButtons: (passing options if desired)
- $("#myInputElement").SpinButton(myOptions);
-
- });
-
- */
-var sbjQuery = jQuery;
-sbjQuery.fn.SpinButton = function(cfg){
- return this.each(function(){
-
- // Apply specified options or defaults:
- // (Ought to refactor this some day to use $.extend() instead)
- this.spinCfg = {
- //min: cfg && cfg.min ? Number(cfg.min) : null,
- //max: cfg && cfg.max ? Number(cfg.max) : null,
- min: cfg && !isNaN(parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0
- max: cfg && !isNaN(parseFloat(cfg.max)) ? Number(cfg.max) : null,
- step: cfg && cfg.step ? Number(cfg.step) : 1,
- page: cfg && cfg.page ? Number(cfg.page) : 10,
- upClass: cfg && cfg.upClass ? cfg.upClass : 'up',
- downClass: cfg && cfg.downClass ? cfg.downClass : 'down',
- reset: cfg && cfg.reset ? cfg.reset : this.value,
- delay: cfg && cfg.delay ? Number(cfg.delay) : 500,
- interval: cfg && cfg.interval ? Number(cfg.interval) : 100,
- _btn_width: 20,
- _btn_height: 12,
- _direction: null,
- _delay: null,
- _repeat: null,
-
- digits: cfg && cfg.digits ? Number(cfg.digits) : 1
- };
-
- this.adjustValue = function(i){
- var v = this.value.toLowerCase();
- if (v=="am")
- {
- this.value="PM";
- return;
- }
- else if (v=="pm") {
- this.value="AM";
- return;
- }
- v = (isNaN(this.value) ? this.spinCfg.reset : Number(this.value)) + Number(i);
- if (this.spinCfg.min !== null) v = (v<this.spinCfg.min ? (this.spinCfg.max != null ? this.spinCfg.max : this.spinCfg.min) : v);
- if (this.spinCfg.max !== null) v = (v>this.spinCfg.max ? (this.spinCfg.min != null ? this.spinCfg.min : this.spinCfg.max) : v);
-
- var value = String(v);
- while (value.length<this.spinCfg.digits) value="0"+value;
-
- this.value = value;
- };
-
- sbjQuery(this)
-// .addClass(cfg && cfg.spinClass ? cfg.spinClass : 'spin-button')
-//
-// .mousemove(function(e){
-// // Determine which button mouse is over, or not (spin direction):
-// var x = e.pageX || e.x;
-// var y = e.pageY || e.y;
-// var el = e.target || e.srcElement;
-// var direction =
-// (x > coord(el,'offsetLeft') + el.offsetWidth - this.spinCfg._btn_width)
-// ? ((y < coord(el,'offsetTop') + this.spinCfg._btn_height) ? 1 : -1) : 0;
-//
-// if (direction !== this.spinCfg._direction) {
-// // Style up/down buttons:
-// switch(direction){
-// case 1: // Up arrow:
-// sbjQuery(this).removeClass(this.spinCfg.downClass).addClass(this.spinCfg.upClass);
-// break;
-// case -1: // Down arrow:
-// sbjQuery(this).removeClass(this.spinCfg.upClass).addClass(this.spinCfg.downClass);
-// break;
-// default: // Mouse is elsewhere in the textbox
-// sbjQuery(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);
-// }
-//
-// // Set spin direction:
-// this.spinCfg._direction = direction;
-// }
-// })
-//
-// .mouseout(function(){
-// // Reset up/down buttons to their normal appearance when mouse moves away:
-// sbjQuery(this).removeClass(this.spinCfg.upClass).removeClass(this.spinCfg.downClass);
-// this.spinCfg._direction = null;
-// })
-
-// .mousedown(function(e){
-// if (this.spinCfg._direction != 0) {
-// // Respond to click on one of the buttons:
-// var self = this;
-// var adjust = function() {
-// self.adjustValue(self.spinCfg._direction * self.spinCfg.step);
-// };
-//
-// adjust();
-//
-// // Initial delay before repeating adjustment
-// self.spinCfg._delay = window.setTimeout(function() {
-// adjust();
-// // Repeat adjust at regular intervals
-// self.spinCfg._repeat = window.setInterval(adjust, self.spinCfg.interval);
-// }, self.spinCfg.delay);
-// }
-// })
-//
-// .mouseup(function(e){
-// // Cancel repeating adjustment
-// window.clearInterval(this.spinCfg._repeat);
-// window.clearTimeout(this.spinCfg._delay);
-// })
-//
-// .dblclick(function(e) {
-// if (sbjQuery.browser.msie)
-// this.adjustValue(this.spinCfg._direction * this.spinCfg.step);
-// })
-
- .keydown(function(e){
- // Respond to up/down arrow keys.
- switch(e.keyCode){
- case 38: this.adjustValue(this.spinCfg.step); break; // Up
- case 40: this.adjustValue(-this.spinCfg.step); break; // Down
- case 33: this.adjustValue(this.spinCfg.page); break; // PageUp
- case 34: this.adjustValue(-this.spinCfg.page); break; // PageDown
- }
- })
-
- .bind("mousewheel", function(e){
- // Respond to mouse wheel in IE. (It returns up/dn motion in multiples of 120)
- if (e.wheelDelta >= 120)
- this.adjustValue(this.spinCfg.step);
- else if (e.wheelDelta <= -120)
- this.adjustValue(-this.spinCfg.step);
-
- e.preventDefault();
- })
-
- .change(function(e){
- this.adjustValue(0);
- });
-
- var self = this;
-
- var btnUp = document.getElementById(this.id + 'BtnUp');
- sbjQuery(btnUp)
- .mousedown(function(e){
- // Respond to click on one of the buttons:
- var adjust = function() {
- self.adjustValue(self.spinCfg.step);
- };
-
- adjust();
-
- // Initial delay before repeating adjustment
- self.spinCfg._delay = window.setTimeout(function() {
- adjust();
- // Repeat adjust at regular intervals
- self.spinCfg._repeat = window.setInterval(adjust, self.spinCfg.interval);
- }, self.spinCfg.delay);
- self.spinCfg._repeater = true;
- return false;
- })
-
- .mouseup(function(e){
- // Cancel repeating adjustment
- self.spinCfg._repeater = false;
- window.clearInterval(self.spinCfg._repeat);
- window.clearTimeout(self.spinCfg._delay);
- })
-
- .dblclick(function(e) {
- if (sbjQuery.browser.msie)
- self.adjustValue(self.spinCfg.step);
- })
- .mouseout(function(e){
- // Cancel repeating adjustment
- if (self.spinCfg._repeater)
- {
- self.spinCfg._repeater = false
- window.clearInterval(self.spinCfg._repeat);
- window.clearTimeout(self.spinCfg._delay);
- }
- });
-
- var btnDown = document.getElementById(this.id + 'BtnDown');
- sbjQuery(btnDown)
- .mousedown(function(e){
- // Respond to click on one of the buttons:
- var adjust = function() {
- self.adjustValue(-self.spinCfg.step);
- };
-
- adjust();
-
- // Initial delay before repeating adjustment
- self.spinCfg._delay = window.setTimeout(function() {
- adjust();
- // Repeat adjust at regular intervals
- self.spinCfg._repeat = window.setInterval(adjust, self.spinCfg.interval);
- }, self.spinCfg.delay);
- self.spinCfg._repeater = true;
- return false;
- })
-
- .mouseup(function(e){
- // Cancel repeating adjustment
- self.spinCfg._repeater = false;
- window.clearInterval(self.spinCfg._repeat);
- window.clearTimeout(self.spinCfg._delay);
- })
-
- .dblclick(function(e) {
- if (sbjQuery.browser.msie)
- self.adjustValue(-self.spinCfg.step);
- })
- .mouseout(function(e){
- // Cancel repeating adjustment
- if (self.spinCfg._repeater)
- {
- self.spinCfg._repeater = false
- window.clearInterval(self.spinCfg._repeat);
- window.clearTimeout(self.spinCfg._delay);
- }
- });
-
-
- if (this.addEventListener) {
- // Respond to mouse wheel in Firefox
- this.addEventListener('DOMMouseScroll', function(e) {
- if (e.detail > 0)
- this.adjustValue(-this.spinCfg.step);
- else if (e.detail < 0)
- this.adjustValue(this.spinCfg.step);
-
- e.preventDefault();
- }, false);
- }
- });
-
- function coord(el,prop) {
- var c = el[prop], b = document.body;
-
- while ((el = el.offsetParent) && (el != b)) {
- if (!sbjQuery.browser.msie || (el.currentStyle.position != 'relative'))
- c += el[prop];
- }
-
- return c;
- }
-};
Deleted: sandbox/trunk/prototypes/calendar/calendar-utils.js
===================================================================
--- sandbox/trunk/prototypes/calendar/calendar-utils.js 2010-10-21 06:35:50 UTC (rev 19627)
+++ sandbox/trunk/prototypes/calendar/calendar-utils.js 2010-10-21 08:07:06 UTC (rev 19628)
@@ -1,343 +0,0 @@
-(function ($, rf) {
-
- rf.calendarUtils = rf.calendarUtils || {};
-
- var getDefaultMonthNames = function(shortNames)
- {
- return (shortNames
- ? ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
- : ['January','February','March','April','May','June','July','August','September','October','November','December']);
- };
-
- $.extend(rf.calendarUtils, {
- // TODO: rewrite this function or use the same function if exists
- /*clonePosition: function (elements, source)
- {
- if (!elements.length) elements = [elements];
- var offset = Position.cumulativeOffset(source);
- offset = {left:offset[0], top:offset[1]};
- var offsetTemp;
- if (source.style.position!='absolute')
- {
- offsetTemp = Position.realOffset(source);
- offset.left -= offsetTemp.left;
- offset.top -= offsetTemp.top;
- offsetTemp = Richfaces.Calendar.getWindowScrollOffset();
- offset.left += offsetTemp.left;
- offset.top += offsetTemp.top;
- }
-
- for (var i=0;i<elements.length;i++)
- {
- offsetTemp = Richfaces.Calendar.getParentOffset(elements[i]);
- elements[i].style.left = (offset.left - offsetTemp.left) + 'px';
- elements[i].style.top = (offset.top - offsetTemp.top) + 'px';
- }
- return offset;
- }*/
-
- //TODO: not used
- /*Object.extend(Event, {
- findElementByAttr : function(event, tagName, attribute, value, flag) {
- var element = Event.findElement(event, tagName);
- while (!element[attribute] || (flag ? element[attribute].indexOf(value)!=0 : element[attribute]!=value) )
- {
- element = element.parentNode;
- }
- return element;
- }
- });
-
- Object.extend(Element, {
- replaceClassName : function (element, whichClassName, toClassName) {
- if (!(element = $(element))) return;
- var e = Element.classNames(element);
- e.remove(whichClassName);
- e.add(toClassName);
- return element;
- }
- });*/
-
- // TODO: move joinArray to richfaces utils
- joinArray: function(array, begin, end, separator)
- {
- var value = '';
- if (array.length!=0) value = begin+array.pop()+end;
- while (array.length)
- value = begin+array.pop()+end+separator+value;
- return value;
- },
-
- getMonthByLabel: function (monthLabel, monthNames) {
- var toLowerMonthLabel = monthLabel.toLowerCase();
- var i = 0;
- while (i < monthNames.length) {
- if (monthNames[i].toLowerCase() == toLowerMonthLabel) {
- return i;
- }
-
- i++;
- }
- },
-
- /* Year:
- * y,yy - 00-99
- * yyy+ - 1999
- * Month:
- * M - 1-12
- * MM - 01-12
- * MMM - short (Jul)
- * MMMM+ - long (July)
- * Date:
- * d - 1-31
- * dd+ - 01-31 */
- parseDate: function(dateString, pattern, monthNames, monthNamesShort)
- {
- var re = /([.*+?^<>=!:${}()[\]\/\\])/g;
- var monthNamesStr
- var monthNamesShortStr;
- if (!monthNames) {
- monthNames = getDefaultMonthNames();
- monthNamesStr = monthNames.join('|');
- } else {
- monthNamesStr = monthNames.join('|').replace(re, '\\$1');
- }
-
- if (!monthNamesShort) {
- monthNamesShort = getDefaultMonthNames(true);
- monthNamesShortStr = monthNamesShort.join('|');
- } else {
- monthNamesShortStr = monthNamesShort.join('|').replace(re, '\\$1');
- }
-
- var counter=1;
- var y,m,d;
- var a,h,min;
- var shortLabel=false;
-
- pattern = pattern.replace(/([.*+?^<>=!:${}()|[\]\/\\])/g, '\\$1');
- pattern = pattern.replace(/(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
- function($1) {
- switch ($1) {
- case 'y' :
- case 'yy' : y=counter; counter++; return '(\\d{2})';
- case 'MM' : m=counter; counter++; return '(\\d{2})';
- case 'M' : m=counter; counter++; return '(\\d{1,2})';
- case 'd' : d=counter; counter++; return '(\\d{1,2})';
- case 'MMM': m=counter; counter++; shortLabel=true; return '('+monthNamesShortStr+')';
- case 'a' : a=counter; counter++; return '(AM|am|PM|pm)?';
- case 'HH' :
- case 'hh' : h=counter; counter++; return '(\\d{2})?';
- case 'H' :
- case 'h' : h=counter; counter++; return '(\\d{1,2})?';
- case 'mm' : min=counter; counter++; return '(\\d{2})?';
- }
- // y+,M+,d+
- var ch = $1.charAt(0);
- if (ch=='y') {y=counter; counter++; return '(\\d{3,4})'};
- if (ch=='M') {m=counter; counter++; return '('+monthNamesStr+')'};
- if (ch=='d') {d=counter; counter++; return '(\\d{2})'};
- }
- );
-
- var re = new RegExp(pattern,'i');
- var match = dateString.match(re);
- if (match!=null)
- {
- // set default century start
- var correctYear = false;
- var defaultCenturyStart = new Date();
- defaultCenturyStart.setFullYear(defaultCenturyStart.getFullYear()-80);
-
- var yy = parseInt(match[y],10);
- if (isNaN(yy)) return null;
- else if (yy<100){
- // calculate full year if year has only two digits
- var defaultCenturyStartYear = defaultCenturyStart.getFullYear();
- var ambiguousTwoDigitYear = defaultCenturyStartYear % 100;
- correctYear = yy == ambiguousTwoDigitYear;
- yy += Math.floor(defaultCenturyStartYear/100)*100 + (yy < ambiguousTwoDigitYear ? 100 : 0);
- }
-
- var mm = parseInt(match[m],10); if (isNaN(mm)) mm = Richfaces.Calendar.getMonthByLabel(match[m], shortLabel ? monthNamesShort : monthNames); else if (--mm<0 || mm>11) return null;
- var addDay = correctYear ? 1 : 0;
- var dd = parseInt(match[d],10); if (isNaN(dd) || dd<1 || dd>this.daysInMonth(yy, mm) + addDay) return null;
-
- var date = new Date(yy, mm, dd);
-
- // time parsing
- if (min!=undefined && h!=undefined)
- {
- var hh,mmin,aa;
- mmin = parseInt(match[min],10); if (isNaN(mmin) || mmin<0 || mmin>59) return null;
- hh = parseInt(match[h],10); if (isNaN(hh)) return null;
- if (a!=undefined)
- {
- aa = match[a];
- if (!aa) return null;
- aa = aa.toLowerCase();
- if ((aa!='am' && aa!='pm') || hh<1 || hh>12) return null;
- if (aa=='pm')
- {
- if (hh!=12) hh+=12;
- } else if (hh==12) hh = 0;
- }
- else if (hh<0 || hh>23) return null;
-
- date.setHours(hh); date.setMinutes(mmin);
- }
-
- if (correctYear) {
- if (date.getTime() < defaultCenturyStart.getTime()) {
- date.setFullYear(yy + 100);
- }
- if (date.getMonth() != mm) return null;
- }
-
- return date;
- }
- return null;
- },
-
- formatDate: function(date, pattern, monthNames, monthNamesShort) {
- if (!monthNames) monthNames = getDefaultMonthNames();
- if (!monthNamesShort) monthNamesShort = getDefaultMonthNames(true);
- var mm; var dd; var hh; var min;
- var result = pattern.replace(/(\\\\|\\[yMdaHhm])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g,
- function($1,$2,$3) {
- if ($2) return $2.charAt(1);
- switch ($3) {
- case 'y':
- case 'yy': return date.getYear().toString().slice(-2);
- case 'M': return (date.getMonth()+1);
- case 'MM': return ((mm = date.getMonth()+1)<10 ? '0'+mm : mm);
- case 'MMM': return monthNamesShort[date.getMonth()];
- case 'd': return date.getDate();
- case 'a' : return (date.getHours()<12 ? 'AM' : 'PM');
- case 'HH' : return ((hh = date.getHours())<10 ? '0'+hh : hh);
- case 'H' : return date.getHours();
- case 'hh' : return ((hh = date.getHours())==0 ? '12' : (hh<10 ? '0'+hh : (hh>21 ? hh-12 : (hh>12) ? '0'+(hh-12) : hh)));
- case 'h' : return ((hh = date.getHours())==0 ? '12' : (hh>12 ? hh-12 : hh));
- case 'mm' : return ((min = date.getMinutes())<10 ? '0'+min : min);
- }
- // y+,M+,d+
- var ch = $3.charAt(0);
- if (ch=='y') return date.getFullYear();
- if (ch=='M') return monthNames[date.getMonth()];
- if (ch=='d') return ((dd = date.getDate())<10 ? '0'+dd : dd);
- }
- );
- return result;
- },
-
- isLeapYear: function(year) {
- return new Date(year, 1, 29).getDate()==29;
- },
-
- daysInMonth: function(year,month) {
- return 32 - new Date(year, month, 32).getDate();
- },
-
- daysInMonthByDate: function(date) {
- return 32 - new Date(date.getFullYear(), date.getMonth(), 32).getDate();
- },
-
- getDay: function(date, firstWeekDay ) {
- var value = date.getDay() - firstWeekDay;
- if (value < 0) value = 7 + value;
- return value;
- },
-
- getFirstWeek: function(year, mdifw, fdow) {
- var date = new Date(year,0,1);
- var firstday = this.getDay(date, fdow);
-
- var weeknumber = (7-firstday<mdifw) ? 0 : 1;
-
- return {date:date, firstDay:firstday, weekNumber:weeknumber, mdifw:mdifw, fdow:fdow};
- },
-
- getLastWeekOfPrevYear: function(o) {
- var year = o.date.getFullYear()-1;
- var days = (isLeapYear(year) ? 366 : 365);
- var obj = this.getFirstWeek(year, o.mdifw, o.fdow);
- days = (days - 7 + o.firstDay);
- var weeks = Math.floor(days/7)+1;
-
- return weeks+obj.weekNumber;
- },
-
- weekNumber: function(year, month, mdifw, fdow) {
-
- var o = this.getFirstWeek(year, mdifw, fdow);
-
- if (month==0)
- {
- if (o.weekNumber==1) return 1;
- return getLastWeekOfPrevYear(o);
- }
- var oneweek = 604800000;
- var d = new Date(year, month,1);
- d.setDate( 1+o.firstDay + (this.getDay(d,fdow)==0?1:0));
-
- weeknumber = o.weekNumber + Math.floor((d.getTime() - o.date.getTime()) / oneweek);
-
- return weeknumber;
- }
-
- });
-
- rf.calendarTemplates = rf.calendarTemplates || {};
-
- $.extend(rf.calendarTemplates, (function (){
-
- var VARIABLE_NAME_PATTERN = /^\s*[_,A-Z,a-z][\w,_\.]*\s*$/;
-
- var getObjectValue = function (str, object) {
- var a=str.split(".");
- var value=object[a[0]];
- var c=1;
- while (value && c<a.length) value = value[a[c++]];
- return (value ? value : "");
- };
-
- return {
- evalMacro: function(template, object)
- {
- var _value_="";
- // variable evaluation
- if (VARIABLE_NAME_PATTERN.test(template))
- {
- if (template.indexOf('.')==-1) {
- _value_ = object[template];
- if (!_value_) _value_=window[template];
- }
- // object's variable evaluation
- else {
- _value_ = getObjectValue(template, object);
- if (!_value_) _value_=getObjectValue(template, window);
- }
- if (_value_ && typeof _value_=='function') _value_ = _value_(object);
- if (!_value_) _value_="";
- }
- //js string evaluation
- else {
- try {
- if (object.eval) {
- _value_ = object.eval(template);
- }
- else with (object) {
- _value_ = eval(template) ;
- }
-
- if (typeof _value_ == 'function') {
- _value_ = _value_(object);
- }
- } catch (e) { LOG.warn("Exception: "+e.Message + "\n[" + template + "]"); }
- }
- return _value_;
- }
- };
- })());
-
-})(jQuery, RichFaces);
\ No newline at end of file
Deleted: sandbox/trunk/prototypes/calendar/calendar.js
===================================================================
--- sandbox/trunk/prototypes/calendar/calendar.js 2010-10-21 06:35:50 UTC (rev 19627)
+++ sandbox/trunk/prototypes/calendar/calendar.js 2010-10-21 08:07:06 UTC (rev 19628)
@@ -1,1788 +0,0 @@
-/*if(!window.LOG){
- window.LOG = {warn:function(){}};
-}*/
-
-// TODO: try to change RichFaces.$ to $$ if possible
-
-(function ($, rf) {
-
- rf.ui = rf.ui || {};
-
- //calendar templates
- var CalendarView = {
- getControl: function(text, attributes, functionName, paramsStr) {
- var attr = $.extend({
- onclick: (functionName ? "RichFaces.$$('Calendar',this)."+functionName+"("+(paramsStr ? paramsStr : "")+");" : "")+"return true;"
- }, attributes);
- return new E('div',attr,[new T(text)]);
- },
-
- getSelectedDateControl: function(calendar) {
-
- if (!calendar.selectedDate || calendar.params.showApplyButton) return "";
-
- var text = rf.calendarUtils.formatDate(calendar.selectedDate,(calendar.timeType ? calendar.datePattern : calendar.params.datePattern), calendar.params.monthLabels, calendar.params.monthLabelsShort);
- var onclick = "RichFaces.$$('Calendar',this).showSelectedDate(); return true;"
- var markup = ( calendar.params.disabled ?
- new E('div', {'class': 'rich-calendar-tool-btn-disabled'}, [new ET(text)]) :
- new E('div', {'class': 'rich-calendar-tool-btn', 'onclick': onclick}, [new ET(text)]) );
-
- return markup;
- },
-
- getTimeControl: function(calendar) {
-
- if (!calendar.selectedDate || !calendar.timeType) return "";
-
- var text = rf.calendarUtils.formatDate(calendar.selectedDate, calendar.timePattern, calendar.params.monthLabels, calendar.params.monthLabelsShort);
-
- var onmouseover = "jQuery(this).removeClass('rich-calendar-tool-btn-press');";
- var onmouseout = "jQuery(this).addClass('rich-calendar-tool-btn-press');";
- var onclick = "RichFaces.$$('Calendar',this).showTimeEditor();return true;";
- var markup = calendar.params.disabled || calendar.params.readonly ?
- new E('div', {'class': 'rich-calendar-tool-btn-disabled'}, [new ET(text)]) :
- new E('div', {'class': 'rich-calendar-tool-btn rich-calendar-tool-btn-hover rich-calendar-tool-btn-press', 'onclick': onclick,
- 'onmouseover': + onmouseover ,
- 'onmouseout' : + onmouseout}, [new ET(text)]);
-
- return markup;
- },
-
- toolButtonAttributes: {className: "rich-calendar-tool-btn", onmouseover:"this.className='rich-calendar-tool-btn rich-calendar-tool-btn-hover'", onmouseout:"this.className='rich-calendar-tool-btn'", onmousedown:"this.className='rich-calendar-tool-btn rich-calendar-tool-btn-hover rich-calendar-tool-btn-press'", onmouseup:"this.className='rich-calendar-tool-btn rich-calendar-tool-btn-hover'"},
- nextYearControl: function (context) {
- return (!context.calendar.params.disabled ? CalendarView.getControl(">>", CalendarView.toolButtonAttributes, "nextYear") : "");
- },
- previousYearControl: function (context) {
- return (!context.calendar.params.disabled ? CalendarView.getControl("<<", CalendarView.toolButtonAttributes, "prevYear") : "");
- },
- nextMonthControl: function (context) {
- return (!context.calendar.params.disabled ? CalendarView.getControl(">", CalendarView.toolButtonAttributes, "nextMonth") : "");
- },
- previousMonthControl: function (context) {
- return (!context.calendar.params.disabled ? CalendarView.getControl("<", CalendarView.toolButtonAttributes, "prevMonth") : "");
- },
- currentMonthControl: function (context) {
- var text = rf.calendarUtils.formatDate(context.calendar.getCurrentDate(), "MMMM, yyyy", context.monthLabels, context.monthLabelsShort);
- var markup = context.calendar.params.disabled ?
- new E('div',{className: "rich-calendar-tool-btn-disabled"},[new T(text)]) :
- CalendarView.getControl(text, CalendarView.toolButtonAttributes, "showDateEditor");
- return markup;
- },
- todayControl: function (context) {
- return (!context.calendar.params.disabled && context.calendar.params.todayControlMode!='hidden' ? CalendarView.getControl(context.controlLabels.today, CalendarView.toolButtonAttributes, "today") : "");
- },
- closeControl: function (context) {
- return (context.calendar.params.popup ? CalendarView.getControl(context.controlLabels.close, CalendarView.toolButtonAttributes, "close", "false") : "");
- },
- applyControl: function (context) {
- return (!context.calendar.params.disabled && !context.calendar.params.readonly && context.calendar.params.showApplyButton ? CalendarView.getControl(context.controlLabels.apply, CalendarView.toolButtonAttributes, "close", "true") : "");
- },
- cleanControl: function (context) {
- return (!context.calendar.params.disabled && !context.calendar.params.readonly && context.calendar.selectedDate ? CalendarView.getControl(context.controlLabels.clean, CalendarView.toolButtonAttributes, "resetSelectedDate") : "");
- },
-
- selectedDateControl: function (context) { return CalendarView.getSelectedDateControl(context.calendar);},
- timeControl: function (context) { return CalendarView.getTimeControl(context.calendar);},
- timeEditorFields: function (context) {return context.calendar.timePatternHtml;},
-
- header: [
- new E('table',{'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'width': '100%'},
- [
- new E('tbody',{},
- [
- new E('tr',{},
- [
- new E('td',{'class': 'rich-calendar-tool'},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("previousYearControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-tool'},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("previousMonthControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-month'},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("currentMonthControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-tool'},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("nextMonthControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-tool'},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("nextYearControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-tool rich-calendar-tool-close', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("closeControl", context)})
- ])
- ])
- ])
- ]
- )],
-
- footer: [
- new E('table',{'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'width': '100%'},
- [
- new E('tbody',{},
- [
- new E('tr',{},
- [
- new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("selectedDateControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("cleanControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '');}},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("timeControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-toolfooter', 'style': 'background-image:none;', 'width': '100%'}, []),
- new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '')+(context.calendar.params.disabled || context.calendar.params.readonly || !context.calendar.params.showApplyButton ? 'background-image:none;' : '');}},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("todayControl", context)})
- ]),
- new E('td',{'class': 'rich-calendar-toolfooter', 'style':function(context){return (this.isEmpty ? 'display:none;' : '')+'background-image:none;';}},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("applyControl", context)})
- ])
- ])
- ])
- ]
- )],
-
- timeEditorLayout: [
-
- new E('table',{'id': function(context){return context.calendar.TIME_EDITOR_LAYOUT_ID}, 'border': '0', 'cellpadding': '0', 'cellspacing': '0', 'class': 'rich-calendar-time-layout'},
- [
- new E('tbody',{},
- [
- new E('tr',{},
- [
- new E('td',{'class': 'rich-calendar-time-layout-fields', 'colspan': '2', 'align': 'center'},
- [
- new ET(function (context) { return rf.calendarTemplates.evalMacro("timeEditorFields", context)})
- ])
- ]),
- new E('tr',{},
- [
- new E('td',{'class': 'rich-calendar-time-layout-ok'},
- [
- new E('div',{'id': function(context){return context.calendar.TIME_EDITOR_BUTTON_OK}, 'class': 'rich-calendar-time-btn', 'style': 'float:right;', 'onmousedown': "jQuery(this).addClass('rich-calendar-time-btn-press');", 'onmouseout': "jQuery(this).removeClass('rich-calendar-time-btn-press');", 'onmouseup': "jQuery(this).removeClass('rich-calendar-time-btn-press');", 'onclick': function(context){return "RichFaces.$('"+context.calendar.id+"').hideTimeEditor(true)";}},
- [
- new E('span',{},
- [
- new ET(function (context) { return context.controlLabels.ok; })
- ])
- ])
- ])
- ,
- new E('td',{'class': 'rich-calendar-time-layout-cancel'},
- [
- new E('div',{'id': function(context){return context.calendar.TIME_EDITOR_BUTTON_CANCEL}, 'class': 'rich-calendar-time-btn', 'style': 'float:left;', 'onmousedown': "jQuery(this).addClass('rich-calendar-time-btn-press');", 'onmouseout': "jQuery(this).removeClass('rich-calendar-time-btn-press');", 'onmouseup': "jQuery(this).removeClass('rich-calendar-time-btn-press');", 'onclick': function(context){return "RichFaces.$('"+context.calendar.id+"').hideTimeEditor(false)";}},
- [
- new E('span',{},
- [
- new ET(function (context) { return context.controlLabels.cancel; })
- ])
- ])
- ])
- ])
- ])
- ]
- )],
-
- dayList: [new ET(function (context) { return context.day})],
- weekNumber: [new ET(function (context) { return context.weekNumber})],
- weekDay: [new ET(function (context) { return context.weekDayLabelShort})]
- };
- // calendar templates end
-
- // calendar context
- var CalendarContext = function(calendar) {
- this.calendar=calendar;
- this.monthLabels=calendar.params.monthLabels;
- this.monthLabelsShort=calendar.params.monthLabelsShort;
- this.weekDayLabels=calendar.params.weekDayLabels;
- this.weekDayLabelsShort=calendar.params.weekDayLabelsShort;
- this.controlLabels=calendar.params.labels;
- };
-
- $.extend(CalendarContext.prototype, {
- nextYearControl: CalendarView.nextYearControl,
- previousYearControl: CalendarView.previousYearControl,
- nextMonthControl: CalendarView.nextMonthControl,
- previousMonthControl: CalendarView.previousMonthControl,
- currentMonthControl: CalendarView.currentMonthControl,
- selectedDateControl: CalendarView.selectedDateControl,
- cleanControl: CalendarView.cleanControl,
- timeControl: CalendarView.timeControl,
- todayControl: CalendarView.todayControl,
- closeControl: CalendarView.closeControl,
- applyControl: CalendarView.applyControl,
- timeEditorFields: CalendarView.timeEditorFields,
- });
-
- // must be :defaultTime, minDaysInFirstWeek, firstWeekday, weekDayLabels, weekDayLabelsShort, monthLabels, monthLabelsShort
-
- // defaults definition
- var defaultOptions = {
- showWeekDaysBar: true,
- showWeeksBar: true,
- datePattern: "MMM d, yyyy",
- horizontalOffset: 0,
- verticalOffset: 0,
- dayListMarkup: CalendarView.dayList,
- weekNumberMarkup: CalendarView.weekNumber,
- weekDayMarkup: CalendarView.weekDay,
- headerMarkup: CalendarView.header,
- footerMarkup: CalendarView.footer,
- isDayEnabled: function (context) {return true;},
- dayStyleClass: function (context) {return "";},
- showHeader: true,
- showFooter: true,
- direction: "AA",
- jointPoint: "AA",
- popup: true,
- boundaryDatesMode: "inactive",
- todayControlMode: "select",
- style: "",
- className: "",
- disabled: false,
- readonly: false,
- enableManualInput: false,
- showInput: true,
- resetTimeOnDateSelect: false,
- style: "z-index: 3;",
- showApplyButton: false,
- selectedDate: null,
- currentDate: null,
- defaultTime: {hours:12,minutes:0},
- hidePopupOnScroll: true
- };
-
- var defaultLabels = {apply:'Apply', today:'Today', clean:'Clean', ok:'OK', cancel:'Cancel', close:'x'};
-
- // Constructor definition
- rf.ui.Calendar = function(componentId, locale, options, markups) {
-
- // dayListMarkup - day cell markup
- // context: {day, date, weekNumber, weekDayNumber, isWeekend, isCurrentMonth, elementId, component}
- // weekNumberMarkup - week number cell markup
- // context: {weekNumber, elementId, component}
- // weekDayMarkup - week day cell markup
- // context: {weekDayLabel, weekDayLabelShort, weekDayNumber, isWeekend, elementId, component}
-
- // headerMarkup
- // footerMarkup
- // optionalHeaderMarkup - user defined header (optional)
- // optionalFooterMarkup - user defined footer (optional)
-
- // currentDate - date to show month (day not used) (mm/yyyy)
- // selectedDate - selected date (mm/dd/yyyy)
- // weekDayLabels - collection of week day labels keyed by week day numbers
- // weekDayLabelsShort - collection of week day short labels keyed by week day numbers
- // minDaysInFirstWeek - locale-specific constant defining number of days in the first week
- // firstWeekDay - (0..6) locale-specific constant defining number of the first week day
- // showWeekDaysBar - show WeekDays Bar [default value is true]
- // showWeeksBar - show Weeks numbers bar [default value is true]
- // showApplyButton
- // showHeader
- // showFooter
-
- // POPUP description
- // direction - [top-left, top-right, bottom-left, bottom-right, auto]
- // jointPoint - [top-left, top-right, bottom-left, bottom-right]
- // popup - true
- // id+PopupButton, id+InputDate,
-
- // boundaryDatesMode - boundary dates onclick action:
- // "inactive" or undefined - no action (default)
- // "scroll" - change current month
- // "select" - change current month and select date
- //
- // todayControlMode - today control onclick action:
- // "scroll"
- // "select"
- // "hidden"
-
- // isDayEnabled - end-developer JS function
- // dayStyleClass - end-developer JS function that provide style class for day's cells.
-
- // dayCellClass - add div to day cell with class 'rich-calendar-cell-div' and add this class to TD if defined
- // style - table style
- // styleClass - table class
-
- // disabled
- // readonly
-
- //var _d = new Date();
-
- // call constructor of parent class
- $super.constructor.call(this, componentId);
-
- this.namespace = "."+rf.Event.createNamespace(this.name, componentId);
-
- //create parameters
- //this.options = $.extend(this.options, defaultOptions, options);
- this.params = $.extend({}, defaultOptions, locales[locale], options, markups);
-
- // labels
- var value = options.labels || {};
- for (var name in defaultLabels) {
- if (!value[name]) value[name] = defaultLabels[name];
- }
- this.params.labels = value;
-
- this.popupOffset = {dx:this.params.horizontalOffset, dy:this.params.verticalOffset};
-
- //
- if (!this.params.popup) this.params.showApplyButton = false;
-
- //
- this.params.boundaryDatesMode = this.params.boundaryDatesMode.toLowerCase();
- this.params.todayControlMode = this.params.todayControlMode.toLowerCase();
-
- // time
- this.setTimeProperties();
-
- this.customDayListMarkup = (this.params.dayListMarkup!=CalendarView.dayList);
-
- this.currentDate = this.params.currentDate ? this.params.currentDate : (this.params.selectedDate ? this.params.selectedDate : new Date());
- this.currentDate.setDate(1);
- this.selectedDate = this.params.selectedDate;
-
- this.todayDate = new Date();
-
- this.firstWeekendDayNumber = 6-this.params.firstWeekDay;
- this.secondWeekendDayNumber = (this.params.firstWeekDay>0 ? 7-this.params.firstWeekDay : 0);
-
- this.calendarContext = new CalendarContext(this);
-
- // TODO: move it from constructor
- this.DATE_ELEMENT_ID = this.id+'DayCell';
- this.WEEKNUMBER_BAR_ID = this.id+"WeekNum";
- this.WEEKNUMBER_ELEMENT_ID = this.WEEKNUMBER_BAR_ID+'Cell';
- this.WEEKDAY_BAR_ID = this.id+"WeekDay";
- this.WEEKDAY_ELEMENT_ID = this.WEEKDAY_BAR_ID+'Cell';
- this.POPUP_ID = this.id+'Popup';
- this.POPUP_BUTTON_ID = this.id+'PopupButton';
- this.INPUT_DATE_ID = this.id+'InputDate';
- this.EDITOR_ID = this.id+'Editor';
- this.EDITOR_SHADOW_ID = this.id+'EditorShadow';
-
- this.TIME_EDITOR_LAYOUT_ID = this.id+'TimeEditorLayout';
- this.DATE_EDITOR_LAYOUT_ID = this.id+'DateEditorLayout';
- this.EDITOR_LAYOUT_SHADOW_ID = this.id+'EditorLayoutShadow';
- this.TIME_EDITOR_BUTTON_OK = this.id+'TimeEditorButtonOk';
- this.TIME_EDITOR_BUTTON_CANCEL = this.id+'TimeEditorButtonCancel';
- this.DATE_EDITOR_BUTTON_OK = this.id+'DateEditorButtonOk';
- this.DATE_EDITOR_BUTTON_CANCEL = this.id+'DateEditorButtonCancel';
-
- this.firstDateIndex = 0;
-
- this.daysData = {startDate:null, days:[]};
- this.days = [];
- this.todayCellId = null;
- this.todayCellColor = "";
-
- this.selectedDateCellId = null;
- this.selectedDateCellColor = "";
-
- var popupStyles = "";
- this.isVisible = true;
- if (this.params.popup==true)
- {
- // popup mode initialisation
- popupStyles = "display:none; position:absolute;"
- this.isVisible = false;
- }
-
- var tempStr = "RichFaces.$('"+this.id+"').";
-
- var htmlTextHeader = '<table id="'+this.id+'" border="0" cellpadding="0" cellspacing="0" class="rich-calendar-exterior rich-calendar-popup '+this.params.styleClass+'" style="'+popupStyles+this.params.style+'" onclick="'+tempStr+'skipEventOnCollapse=true;"><tbody>';
- var colspan = (this.params.showWeeksBar ? "8" : "7");
- var htmlHeaderOptional = (this.params.optionalHeaderMarkup) ? '<tr><td class="rich-calendar-header-optional" colspan="'+colspan+'" id="'+this.id+'HeaderOptional"></td></tr>' : '';
- var htmlFooterOptional = (this.params.optionalFooterMarkup) ? '<tr><td class="rich-calendar-footer-optional" colspan="'+colspan+'" id="'+this.id+'FooterOptional"></td></tr>' : '';
- var htmlControlsHeader = (this.params.showHeader ? '<tr><td class="rich-calendar-header" colspan="'+colspan+'" id="'+this.id+'Header"></td></tr>' : '');
- var htmlControlsFooter = (this.params.showFooter ? '<tr><td class="rich-calendar-footer" colspan="'+colspan+'" id="'+this.id+'Footer"></td></tr>' : '');
- var htmlTextFooter = '</tbody></table>'
-
- // days bar creation
- var styleClass;
- var bottomStyleClass;
- var htmlTextWeekDayBar=[];
- var context;
-
- var eventsStr = this.params.disabled || this.params.readonly ? '' : 'onclick="'+tempStr+'eventCellOnClick(event, this);" onmouseover="'+tempStr+'eventCellOnMouseOver(event, this);" onmouseout="'+tempStr+'eventCellOnMouseOut(event, this);"';
- if (this.params.showWeekDaysBar)
- {
- htmlTextWeekDayBar.push('<tr id="'+this.WEEKDAY_BAR_ID+'">');
- if (this.params.showWeeksBar) htmlTextWeekDayBar.push('<td class="rich-calendar-days"><br/></td>');
- var weekDayCounter = this.params.firstWeekDay;
- for (var i=0;i<7;i++)
- {
- context = {weekDayLabel: this.params.weekDayLabels[weekDayCounter], weekDayLabelShort: this.params.weekDayLabelsShort[weekDayCounter], weekDayNumber:weekDayCounter, isWeekend:this.isWeekend(i), elementId:this.WEEKDAY_ELEMENT_ID+i, component:this};
- var weekDayHtml = this.evaluateMarkup(this.params.weekDayMarkup, context );
- if (weekDayCounter==6) weekDayCounter=0; else weekDayCounter++;
-
- styleClass = "rich-calendar-days";
- if (context.isWeekend)
- {
- styleClass += " rich-calendar-weekends";
- }
- if (i==6) styleClass += " rich-right-cell";
- htmlTextWeekDayBar.push('<td class="'+styleClass+'" id="'+context.elementId+'">'+weekDayHtml+'</td>');
- }
- htmlTextWeekDayBar.push('</tr>\n');
- }
-
- // week & weekNumber creation
- var htmlTextWeek=[];
- var p=0;
- this.dayCellClassName = [];
-
- for (k=1;k<7;k++)
- {
- bottomStyleClass = (k==6 ? "rich-bottom-cell " : "");
- htmlTextWeek.push('<tr id="'+this.WEEKNUMBER_BAR_ID+k+'">');
- if (this.params.showWeeksBar)
- {
- context = {weekNumber: k, elementId:this.WEEKNUMBER_ELEMENT_ID+k, component:this};
- var weekNumberHtml = this.evaluateMarkup(this.params.weekNumberMarkup, context );
- htmlTextWeek.push('<td class="rich-calendar-week '+bottomStyleClass+'" id="'+context.elementId+'">'+weekNumberHtml+'</td>');
- }
-
- // day cells creation
- for (var i=0;i<7;i++)
- {
- styleClass = bottomStyleClass+(!this.params.dayCellClass ? "rich-calendar-cell-size" : (!this.customDayListMarkup ? this.params.dayCellClass : ""))+" rich-calendar-cell";
- if (i==this.firstWeekendDayNumber || i==this.secondWeekendDayNumber) styleClass+=" rich-calendar-holly";
- if (i==6) styleClass+=" rich-right-cell";
-
- this.dayCellClassName.push(styleClass);
- htmlTextWeek.push('<td class="'+styleClass+'" id="'+this.DATE_ELEMENT_ID+p+'" '+
- eventsStr+
- '>'+(this.customDayListMarkup ? '<div class="rich-calendar-cell-div'+(this.params.dayCellClass ? ' '+this.params.dayCellClass : '')+'"></div>' : '')+'</td>');
- p++;
- }
- htmlTextWeek.push('</tr>');
- }
-
- var div = rf.getDomElement(this.id);
- div = $(div).replaceWith(htmlTextHeader+htmlHeaderOptional+htmlControlsHeader+htmlTextWeekDayBar.join('')+htmlTextWeek.join('')+htmlControlsFooter+htmlFooterOptional+htmlTextFooter);
- this.attachToDom(this.id); // TODO: optimize double $
-
- // memory leaks fix // from old 3.3.x code, may be not needed now
- div = null;
-
- // add onclick event handlers to input field and popup button
- if (this.params.popup && !this.params.disabled)
- {
- var handler = new Function ('event', "RichFaces.$('"+this.id+"').doSwitch();");
- rf.Event.bindById(this.POPUP_BUTTON_ID, "click"+this.namespace, handler, this);
- if (!this.params.enableManualInput)
- {
- rf.Event.bindById(this.INPUT_DATE_ID, "click"+this.namespace, handler, this);
- }
- }
-
- this.scrollElements = null;
-
- //alert(new Date().getTime()-_d.getTime());
-
- };
-
- // Extend component class and add protected methods from parent class to our container
- rf.BaseComponent.extend(rf.ui.Calendar);
-
- // define super class link
- var $super = rf.ui.Calendar.$super;
-
- // static methods definition
- var locales = {};
-
- rf.ui.Calendar.addLocale = function (locale, symbols) {
- if (!locales[locale]) {
- locales[locale] = symbols;
- }
- };
-
- /*
- * Prototype definition
- */
- $.extend(rf.ui.Calendar.prototype, {
- name: "Calendar",
- destructor: function()
- {
- if (this.params.popup && this.isVisible)
- {
- this.scrollElements && rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- this.scrollElements = null;
- rf.Event.unbind(window.document, "click"+this.namespace);
- }
- },
-
- dateEditorSelectYear: function(value)
- {
- if (this.dateEditorYearID)
- {
- $(rf.getDomElement(this.dateEditorYearID)).removeClass('rich-calendar-editor-btn-selected');
- }
- this.dateEditorYear = this.dateEditorStartYear + value;
- this.dateEditorYearID = this.DATE_EDITOR_LAYOUT_ID+'Y'+value;
- $(rf.getDomElement(this.dateEditorYearID)).addClass('rich-calendar-editor-btn-selected');
- },
-
- dateEditorSelectMonth: function(value)
- {
- this.dateEditorMonth = value;
- $(rf.getDomElement(this.dateEditorMonthID)).removeClass('rich-calendar-editor-btn-selected');
- this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+value;
- $(rf.getDomElement(this.dateEditorMonthID)).addClass('rich-calendar-editor-btn-selected');
- },
-
- scrollEditorYear: function(value)
- {
- var element = rf.getDomElement(this.DATE_EDITOR_LAYOUT_ID+'TR');
-
- if (this.dateEditorYearID)
- {
- $(rf.getDomElement(this.dateEditorYearID)).removeClass('rich-calendar-editor-btn-selected');
- this.dateEditorYearID='';
- }
-
- if (!value)
- {
- // update month selection when open editor (value == 0)
- if (this.dateEditorMonth != this.getCurrentMonth())
- {
- this.dateEditorMonth = this.getCurrentMonth();
- $(rf.getDomElement(this.dateEditorMonthID)).removeClass('rich-calendar-editor-btn-selected');
- this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
- $(rf.getDomElement(this.dateEditorMonthID)).addClass('rich-calendar-editor-btn-selected');
- }
- }
-
- if (element)
- {
- var div;
- var year = this.dateEditorStartYear = this.dateEditorStartYear+value*10;
- for (var i=0;i<5;i++)
- {
- element = element.nextSibling;
- div = element.firstChild.nextSibling.nextSibling;
- div.firstChild.innerHTML=year;
- if (year == this.dateEditorYear)
- {
- $(div.firstChild).addClass('rich-calendar-editor-btn-selected');
- this.dateEditorYearID = div.firstChild.id;
- }
- div = div.nextSibling;
- div.firstChild.innerHTML=year+5;
- if (year+5 == this.dateEditorYear)
- {
- $(div.firstChild).addClass('rich-calendar-editor-btn-selected');
- this.dateEditorYearID = div.firstChild.id;
- }
- year++;
- }
- }
- },
-
- updateDateEditor: function()
- {
- this.dateEditorYear = this.getCurrentYear();
- this.dateEditorStartYear = this.getCurrentYear() - 4;
- this.scrollEditorYear(0);
- },
-
- updateTimeEditor: function()
- {
- var th=rf.getDomElement(this.id+'TimeHours');
- var ts=rf.getDomElement(this.id+'TimeSign');
- var tm=rf.getDomElement(this.id+'TimeMinutes');
-
- var h = this.selectedDate.getHours();
- var m = this.selectedDate.getMinutes();
- if (this.timeType==2)
- {
- var a = (h<12 ? 'AM' : 'PM');
- ts.value = a;
- h = (h==0 ? '12' : (h>12 ? h-12 : h));
- }
- th.value = (this.timeHoursDigits==2 && h<10 ? '0'+h : h);
- tm.value = (m<10 ? '0'+m : m);
- },
-
-
- createEditor: function()
- {
- var element = $(rf.getDomElement(this.id));
- var zindex = parseInt(element.css('z-index'), 10);
- var htmlBegin = '<div id="'+this.EDITOR_SHADOW_ID+'" class="rich-calendar-editor-shadow" style="position:absolute; display:none;z-index:'+zindex+'"></div><table border="0" cellpadding="0" cellspacing="0" id="'+this.EDITOR_ID+'" style="position:absolute; display:none;z-index:'+(zindex+1)+'" onclick="RichFaces.$(\''+this.id+'\').skipEventOnCollapse=true;"><tbody><tr><td class="rich-calendar-editor-container" align="center"><div style="position:relative; width:100%">';
- var htmlContent = '<div id="'+this.EDITOR_LAYOUT_SHADOW_ID+'" class="rich-calendar-editor-layout-shadow"></div>';
-
- var htmlEnd = '</div></td></tr></tbody></table>';
- element.after(htmlBegin+htmlContent+htmlEnd);
-
- this.isEditorCreated = true;
-
- return rf.getDomElement(this.EDITOR_ID);
- },
-
- createTimeEditorLayout: function(editor)
- {
- $(rf.getDomElement(this.EDITOR_LAYOUT_SHADOW_ID)).after(this.evaluateMarkup(CalendarView.timeEditorLayout, this.calendarContext));
-
- var th=rf.getDomElement(this.id+'TimeHours');
- var ts;
- var tm=rf.getDomElement(this.id+'TimeMinutes');
- if (this.timeType==1)
- {
- sbjQuery(th).SpinButton({digits:this.timeHoursDigits,min:0,max:23});
- }
- else
- {
- sbjQuery(th).SpinButton({digits:this.timeHoursDigits,min:1,max:12});
- ts=rf.getDomElement(this.id+'TimeSign');
- sbjQuery(ts).SpinButton({});
- }
- sbjQuery(tm).SpinButton({digits:2,min:0,max:59});
-
- this.correctEditorButtons(editor, this.TIME_EDITOR_BUTTON_OK, this.TIME_EDITOR_BUTTON_CANCEL);
-
- this.isTimeEditorLayoutCreated = true;
- },
-
- correctEditorButtons: function(editor, buttonID1, buttonID2)
- {
- var button1 = rf.getDomElement(buttonID1);
- var button2 = rf.getDomElement(buttonID2);
- editor.style.visibility = "hidden";
- editor.style.display = "";
- var width1 = $(button1.firstChild).width();
- var width2 = $(button2.firstChild).width();
- editor.style.display = "none";
- editor.style.visibility = "";
-
- if (width1!=width2)
- {
- button1.style.width = button2.style.width = (width1>width2 ? width1 : width2)+"px";
- }
- },
-
- createDECell: function(id, value, buttonType, param, className)
- {
- if (buttonType==0)
- {
- return '<div id="'+id+'" class="rich-calendar-editor-btn'+(className ? ' '+className : '')+
- '" onmouseover="this.className=\'rich-calendar-editor-btn rich-calendar-editor-tool-over\';" onmouseout="this.className=\'rich-calendar-editor-btn\';" onmousedown="this.className=\'rich-calendar-editor-btn rich-calendar-editor-tool-press\';" onmouseup="this.className=\'rich-calendar-editor-btn rich-calendar-editor-tool-over\';" onclick="RichFaces.$(\''+this.id+'\').scrollEditorYear('+param+');">'+value+'</div>';
- }
- else
- {
- var onclick = (buttonType==1 ? 'RichFaces.$(\''+this.id+'\').dateEditorSelectMonth('+param+');':
- 'RichFaces.$(\''+this.id+'\').dateEditorSelectYear('+param+');' );
- return '<div id="'+id+'" class="rich-calendar-editor-btn'+(className ? ' '+className : '')+
- '" onmouseover="jQuery(this).addClass(\'rich-calendar-editor-btn-over\');" onmouseout="$(this).removeClass(\'rich-calendar-editor-btn-over\');" onclick="'+onclick+'">'+value+'</div>';
- }
- },
-
- createDateEditorLayout: function(editor)
- {
- var htmlBegin = '<table id="'+this.DATE_EDITOR_LAYOUT_ID+'" class="rich-calendar-date-layout" border="0" cellpadding="0" cellspacing="0"><tbody><tr id="'+this.DATE_EDITOR_LAYOUT_ID+'TR">';
- var htmlEnd = '</tr></tbody></table>';
- var month = 0;
- this.dateEditorYear = this.getCurrentYear();
- var year = this.dateEditorStartYear = this.dateEditorYear-4;
- var htmlContent = '<td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
- +'<td align="center" class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
- +'<td align="center">'+this.createDECell('','<', 0, -1)+'</td>'
- +'<td align="center">'+this.createDECell('','>', 0, 1)+'</td>';
- month++;
-
- for (var i=0;i<5;i++)
- {
- htmlContent+='</tr><tr><td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+month, this.params.monthLabelsShort[month], 1, month)+'</td>'
- +'<td align="center" class="rich-calendar-date-layout-split">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'M'+(month+6), this.params.monthLabelsShort[month+6], 1, month+6)+'</td>'
- +'<td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+i, year, 2, i, (i==4 ? 'rich-calendar-editor-btn-selected' : ''))+'</td>'
- +'<td align="center">'+this.createDECell(this.DATE_EDITOR_LAYOUT_ID+'Y'+(i+5), year+5, 2, i+5)+'</td>';
- month++;
- year++;
- }
- this.dateEditorYearID = this.DATE_EDITOR_LAYOUT_ID+'Y4';
- this.dateEditorMonth = this.getCurrentMonth();
- this.dateEditorMonthID = this.DATE_EDITOR_LAYOUT_ID+'M'+this.dateEditorMonth;
-
- htmlContent+='</tr><tr><td colspan="2" class="rich-calendar-date-layout-ok">'+
- '<div id="'+this.DATE_EDITOR_BUTTON_OK+'" class="rich-calendar-time-btn" style="float:right;" onmousedown="jQuery(this).addClass(\'rich-calendar-time-btn-press\');" onmouseout="$(this).removeClass(\'rich-calendar-time-btn-press\');" onmouseup="$(this).removeClass(\'rich-calendar-time-btn-press\');" onclick="RichFaces.$(\''+this.id+'\').hideDateEditor(true);"><span>'+this.params.labels.ok+'</span></div>'+
- '</td><td colspan="2" class="rich-calendar-date-layout-cancel">'+
- '<div id="'+this.DATE_EDITOR_BUTTON_CANCEL+'" class="rich-calendar-time-btn" style="float:left;" onmousedown="jQuery(this).addClass(\'rich-calendar-time-btn-press\');" onmouseout="$(this).removeClass(\'rich-calendar-time-btn-press\');" onmouseup="$(this).removeClass(\'rich-calendar-time-btn-press\');" onclick="RichFaces.$(\''+this.id+'\').hideDateEditor(false);"><span>'+this.params.labels.cancel+'</span></div>'+
- '</td>';
-
-
- $(rf.getDomElement(this.EDITOR_LAYOUT_SHADOW_ID)).after(htmlBegin+htmlContent+htmlEnd);
-
- $(rf.getDomElement(this.dateEditorMonthID)).addClass('rich-calendar-editor-btn-selected');
-
- this.correctEditorButtons(editor, this.DATE_EDITOR_BUTTON_OK, this.DATE_EDITOR_BUTTON_CANCEL);
-
- this.isDateEditorLayoutCreated = true;
- },
-
- createSpinnerTable: function(id) {
- return '<table cellspacing="0" cellpadding="0" border="0"><tbody><tr>'+
- '<td class="rich-calendar-spinner-input-container">'+
- '<input id="' + id + '" name="' + id + '" class="rich-calendar-spinner-input" type="text" />'+
- '</td>'+
- '<td class="rich-calendar-spinner-buttons">'+
- '<table border="0" cellspacing="0" cellpadding="0"><tbody>'+
- '<tr><td>'+
- '<div id="'+id+'BtnUp" class="rich-calendar-spinner-up"'+
- ' onmousedown="this.className=\'rich-calendar-spinner-up rich-calendar-spinner-pressed\'"'+
- ' onmouseup="this.className=\'rich-calendar-spinner-up\'"'+
- ' onmouseout="this.className=\'rich-calendar-spinner-up\'"><span></span></div>'+
- '</td></tr>'+
- '<tr><td>'+
- '<div id="'+id+'BtnDown" class="rich-calendar-spinner-down"'+
- ' onmousedown="this.className=\'rich-calendar-spinner-down rich-calendar-spinner-pressed\'"'+
- ' onmouseup="this.className=\'rich-calendar-spinner-down\'"'+
- ' onmouseout="this.className=\'rich-calendar-spinner-down\'"><span></span></div>'+
- '</td></tr>'+
- '</tbody></table>'+
- '</td>'+
- '</tr></tbody></table>';
- },
-
- setTimeProperties: function() {
- this.timeType = 0;
-
- var dateTimePattern = this.params.datePattern;
- var pattern = [];
- var re = /(\\\\|\\[yMdaHhm])|(y+|M+|d+|a|H{1,2}|h{1,2}|m{2})/g;
- var r;
- while (r = re.exec(dateTimePattern))
- if (!r[1])
- pattern.push({str:r[0],marker:r[2],idx:r.index});
-
- var datePattern = "";
- var timePattern = "";
-
- var digits,h,hh,m,a;
- var id = this.id;
-
- var getString = function (p) {
- return (p.length==0 ? obj.marker : dateTimePattern.substring(pattern[i-1].str.length+pattern[i-1].idx, obj.idx+obj.str.length));
- };
-
- for (var i=0;i<pattern.length;i++)
- {
- var obj = pattern[i];
- var ch = obj.marker.charAt(0);
- if (ch=='y'||ch=='M'||ch=='d') datePattern+=getString(datePattern);
- else if (ch=='a')
- {
- a=true;
- timePattern+=getString(timePattern);
- }
- else if (ch=='H')
- {
- h=true;
- digits=obj.marker.length;
- timePattern+=getString(timePattern);
- }
- else if (ch=='h')
- {
- hh=true;
- digits=obj.marker.length;
- timePattern+=getString(timePattern);
- }
- else if (ch=='m')
- {
- m=true;
- timePattern+=getString(timePattern);
- }
-
-
- }
- this.datePattern = datePattern;
- this.timePattern = timePattern;
-
- var calendar = this;
-
- this.timePatternHtml = timePattern.replace(/(\\\\|\\[yMdaHhm])|(H{1,2}|h{1,2}|m{2}|a)/g,
- function($1,$2,$3) {
- if ($2) return $2.charAt(1);
- switch ($3) {
- case 'a' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeSign')+'</td><td>';
- case 'H' :
- case 'HH' :
- case 'h' :
- case 'hh' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeHours')+'</td><td>';
- case 'mm' : return '</td><td>'+calendar.createSpinnerTable(id+'TimeMinutes')+'</td><td>';
- }
- }
- );
-
- this.timePatternHtml = '<table border="0" cellpadding="0"><tbody><tr><td>'+this.timePatternHtml+'</td></tr></tbody></table>';
-
- if (m && h)
- {
- this.timeType = 1;
- }
- else if (m && hh && a)
- {
- this.timeType = 2;
- }
- this.timeHoursDigits = digits;
- },
-
- eventOnScroll: function (e) {
- this.doCollapse();
- },
-
- doCollapse: function() {
-
- if (!this.params.popup || !this.isVisible) return;
-
- var element = rf.getDomElement(this.id);
-
- if (this.invokeEvent("collapse", element))
- {
- if (this.isEditorVisible) this.hideEditor();
- this.scrollElements && rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- this.scrollElements = null;
- rf.Event.unbind(window.document, "click"+this.namespace);
-
- $(element).hide();
- this.isVisible = false;
-
- }
- },
-
- collapse: function() {
- this.doCollapse();
- },
-
- doExpand: function(e) {
- if (!this.isRendered) {
- this.isRendered = true;
- this.render();
- }
- this.skipEventOnCollapse = false;
- if (e && e.type=='click') this.skipEventOnCollapse = true;
- if (!this.params.popup || this.isVisible) return;
-
- var element = rf.getDomElement(this.id);
-
- if (this.invokeEvent("expand", element, e))
- {
- var base = rf.getDomElement(this.POPUP_ID)
- var baseInput = base.firstChild;
- var baseButton = baseInput.nextSibling;
-
- if (baseInput && baseInput.value!=undefined)
- {
- this.selectDate(baseInput.value, false, {event:e, element:element});
- }
-
- //rect calculation
-
- if (this.params.showInput)
- {
- base = base.children;
- } else {
- base = baseButton;
- };
-
- $(element).setPosition(base, {type:"DROPDOWN", from: this.params.jointPoint, to:this.params.direction, offset: this.popupOffset}).show();
-
- this.isVisible = true;
-
- rf.Event.bind(window.document, "click"+this.namespace, this.eventOnCollapse, this);
-
- this.scrollElements && rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
- this.scrollElements = null;
- if (this.params.hidePopupOnScroll) {
- this.scrollElements = rf.Event.bindScrollEventHandlers(element, this.eventOnScroll, this);
- }
- }
- },
-
- expand: function(e) {
- this.doExpand(e);
- },
-
- doSwitch: function(e) {
- this.isVisible ? this.doCollapse() : this.doExpand(e);
- },
-
- switchState: function(e) {
- this.doSwitch(e);
- },
-
- eventOnCollapse: function (e) {
- if (this.skipEventOnCollapse)
- {
- this.skipEventOnCollapse = false;
- return true;
- }
-
- if (e.target.id == this.POPUP_BUTTON_ID || (!this.params.enableManualInput && e.target.id == this.INPUT_DATE_ID) ) return true;
-
- this.doCollapse();
-
- return true;
- },
-
- setInputField: function(dateStr, event)
- {
- var field = rf.getDomElement(this.INPUT_DATE_ID);
- if (field.value!=dateStr)
- {
- field.value=dateStr;
- this.invokeEvent("changed",field, event, this.selectedDate);
- }
- },
-
- getCurrentDate: function() {
- return this.currentDate;
- },
- getSelectedDate: function() {
- if (!this.selectedDate) return null; else return this.selectedDate;
- },
- getSelectedDateString: function(pattern) {
- if (!this.selectedDate) return "";
- if (!pattern) pattern = this.params.datePattern;
- return rf.calendarUtils.formatDate(this.selectedDate, pattern, this.params.monthLabels, this.params.monthLabelsShort);
- },
-
- getPrevYear: function() {
- var value = this.currentDate.getFullYear()-1;
- if (value<0) value = 0;
- return value;
- },
- getPrevMonth: function(asMonthLabel) {
- var value = this.currentDate.getMonth()-1;
- if (value < 0 ) value = 11;
- if (asMonthLabel)
- {
- return this.params.monthLabels[value];
- } else return value;
- },
- getCurrentYear: function() {
- return this.currentDate.getFullYear();
- },
- getCurrentMonth: function(asMonthLabel) {
- var value = this.currentDate.getMonth();
- if (asMonthLabel)
- {
- return this.params.monthLabels[value];
- } else return value;
- },
- getNextYear: function() {
- return this.currentDate.getFullYear()+1;
- },
- getNextMonth: function(asMonthLabel) {
- var value = this.currentDate.getMonth()+1;
- if (value > 11 ) value = 0;
- if (asMonthLabel)
- {
- return this.params.monthLabels[value];
- } else return value;
- },
-
- isWeekend: function(weekday) {
- return (weekday == this.firstWeekendDayNumber || weekday == this.secondWeekendDayNumber);
- },
-
- setupTimeForDate: function (date) {
- if (this.selectedDate && (!this.params.resetTimeOnDateSelect ||
- (this.selectedDate.getFullYear() == date.getFullYear() &&
- this.selectedDate.getMonth() == date.getMonth() &&
- this.selectedDate.getDate() == date.getDate())))
- {
- date.setHours(this.selectedDate.getHours());
- date.setMinutes(this.selectedDate.getMinutes());
- } else
- {
- date.setHours(this.params.defaultTime.hours);
- date.setMinutes(this.params.defaultTime.minutes);
- }
- },
-
- eventCellOnClick: function (e, obj) {
- var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (daydata.enabled && daydata._month==0)
- {
- var date=new Date(this.currentDate);
- date.setDate(daydata.day);
- if (this.timeType)
- {
- this.setupTimeForDate(date);
- }
-
- if (this.selectDate(date,true, {event:e, element:obj}) && !this.params.showApplyButton)
- {
- this.doCollapse();
- }
-
- } else if (daydata._month!=0){
- if (this.params.boundaryDatesMode == "scroll")
- if (daydata._month==-1) this.prevMonth(); else this.nextMonth();
- else if (this.params.boundaryDatesMode == "select")
- {
- var date = new Date(daydata.date);
- if (this.timeType)
- {
- this.setupTimeForDate(date);
- }
-
- if (this.selectDate(date, false, {event:e, element:obj}) && !this.params.showApplyButton)
- {
- this.doCollapse();
- }
- }
- }
- },
-
- eventCellOnMouseOver: function (e, obj) {
- var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (this.invokeEvent("datemouseover", obj, e, daydata.date) && daydata.enabled)
- {
- if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) {
- $(obj).addClass('rich-calendar-hover');
- }
- }
- },
-
- eventCellOnMouseOut: function (e, obj) {
- var daydata = this.days[parseInt(obj.id.substr(this.DATE_ELEMENT_ID.length),10)];
- if (this.invokeEvent("datemouseout", obj, e, daydata.date) && daydata.enabled)
- {
- if (daydata._month==0 && obj.id!=this.selectedDateCellId && obj.id!=this.todayCellId) {
- $(obj).removeClass('rich-calendar-hover');
- }
- }
- },
-
- load:function(daysData, isAjaxMode) {
- // startDate,
- // daysData:array[]
- // {
- // day
- // enabled boolean
- // text1: 'Meeting...',
- // text2: 'Meeting...'
- // tooltip
- // hasTooltip
- // styleClass
- // }
-
-
- if (daysData) {
- this.daysData = this.indexData(daysData, isAjaxMode);
- } else {
- this.daysData = null;
- }
-
- this.isRendered = false;
- if (this.isVisible) {
- this.render();
- };
-
- if (typeof this.afterLoad=='function')
- {
- this.afterLoad();
- this.afterLoad=null;
- }
- },
-
- indexData:function(daysData, isAjaxMode) {
- var dateYear = daysData.startDate.getFullYear();
- var dateMonth = daysData.startDate.getMonth();
-
- daysData.index = [];
- daysData.index[dateYear+'-'+dateMonth] = 0;
- if (isAjaxMode)
- {
- this.currentDate = daysData.startDate;
- this.currentDate.setDate(1);
- return daysData;
- }
- var idx = rf.calendarUtils.daysInMonthByDate(daysData.startDate)-daysData.startDate.getDate()+1;
-
- while (daysData.days[idx])
- {
- if (dateMonth==11) {dateYear++; dateMonth=0;} else dateMonth++;
- daysData.index[dateYear+'-'+dateMonth] = idx;
- idx+= (32 - new Date(dateYear, dateMonth, 32).getDate());
- }
- return daysData;
- },
-
- getCellBackgroundColor: function(element)
- {
- return $(element).css('background-color');
- },
-
- clearEffect: function (element_id, className, className1)
- {
- if (element_id)
- {
- var e = $(rf.getDomElement(element_id)).stop(true, true);
- if (className) e.removeClass(className);
- if (className1) e.addClass(className1);
- }
- return null;
- },
-
- render:function() {
- //var _d=new Date();
- this.isRendered = true;
- this.todayDate = new Date();
-
- var currentYear = this.getCurrentYear();
- var currentMonth = this.getCurrentMonth();
-
- var todayflag = (currentYear == this.todayDate.getFullYear() && currentMonth == this.todayDate.getMonth());
- var todaydate = this.todayDate.getDate();
-
- var selectedflag = this.selectedDate && (currentYear == this.selectedDate.getFullYear() && currentMonth == this.selectedDate.getMonth())
- var selecteddate = this.selectedDate && this.selectedDate.getDate();
-
- var wd = rf.calendarUtils.getDay(this.currentDate, this.params.firstWeekDay);
- var currentMonthDays = rf.calendarUtils.daysInMonthByDate(this.currentDate);
- var previousMonthDays = rf.calendarUtils.daysInMonth(currentYear, currentMonth-1);
-
- var p=0;
- var month=-1;
- this.days = [];
- var dayCounter = previousMonthDays - wd + 1;
-
- // previuos month days
- if (wd>0) while (dayCounter<=previousMonthDays)
- {
- this.days.push({day:dayCounter, isWeekend: this.isWeekend(p), _month:month}); dayCounter++; p++;
- }
-
- dayCounter = 1;
- month=0;
-
- this.firstDateIndex = p;
-
- // current month days
- if (this.daysData && this.daysData.index[currentYear+'-'+currentMonth]!=undefined)
- {
- var idx = this.daysData.index[currentYear+'-'+currentMonth];
- if (this.daysData.startDate.getFullYear()==currentYear && this.daysData.startDate.getMonth()==currentMonth)
- {
- var firstDay = firstDay=(this.daysData.days[idx].day ? this.daysData.days[idx].day : this.daysData.startDate.getDate());
- while (dayCounter<firstDay)
- {
- this.days.push({day:dayCounter, isWeekend:this.isWeekend(p%7), _month:month});
-
- dayCounter++;
- p++;
- }
- }
-
- var len = this.daysData.days.length;
- var obj;
- var flag;
- while (idx<len && dayCounter<=currentMonthDays)
- {
- flag = this.isWeekend(p%7);
- obj = this.daysData.days[idx];
- obj.day = dayCounter;
- obj.isWeekend = flag;
- obj._month = month;
- this.days.push(obj);
- idx++;
- dayCounter++;
- p++;
- }
- }
- while (p<42)
- {
- if (dayCounter>currentMonthDays) {dayCounter=1; month=1;}
- this.days.push({day:dayCounter, isWeekend: this.isWeekend(p%7), _month:month});
- dayCounter++;
- p++;
- }
-
- // render
- this.renderHF();
-
- //days render
- p=0;
- var element;
- var dataobj;
- var wn;
- if (this.params.showWeeksBar) wn = rf.calendarUtils.weekNumber(currentYear, currentMonth, this.params.minDaysInFirstWeek, this.params.firstWeekDay); /// fix it
- this.selectedDayElement=null;
- var weekflag=true;
-
- var e;
-
- var boundaryDatesModeFlag = (this.params.boundaryDatesMode == "scroll" || this.params.boundaryDatesMode == "select");
-
- this.todayCellId = this.clearEffect(this.todayCellId);
- this.selectedDateCellId = this.clearEffect(this.selectedDateCellId);
-
- //var _d=new Date();
- var obj = rf.getDomElement(this.WEEKNUMBER_BAR_ID+"1");
- for (var k=1;k<7;k++)
- {
- //
- dataobj = this.days[p];
-
- element = obj.firstChild;
- var weeknumber;
-
- // week number update
- if (this.params.showWeeksBar)
- {
- // TODO: fix: there is no weekNumber in dataobj if showWeeksBar == false;
- if (weekflag && currentMonth==11 &&
- (k==5||k==6) &&
- (dataobj._month==1 || (7 - (currentMonthDays - dataobj.day + 1)) >= this.params.minDaysInFirstWeek) )
- {
- wn=1;
- weekflag=false;
- }
- weeknumber = wn;
- element.innerHTML = this.evaluateMarkup(this.params.weekNumberMarkup, {weekNumber: wn++, elementId:element.id, component:this} );
- if (k==1&&wn>52) wn=1;
- element = element.nextSibling;
- }
-
- var weekdaycounter = this.params.firstWeekDay;
- var contentElement = null;
-
- while (element)
- {
- dataobj.elementId=element.id;
- dataobj.date=new Date(currentYear, currentMonth+dataobj._month, dataobj.day);
- dataobj.weekNumber = weeknumber;
- dataobj.component = this;
- dataobj.isCurrentMonth = (dataobj._month==0);
- dataobj.weekDayNumber = weekdaycounter;
-
- // call user function to get day state
- if (dataobj.enabled != false) dataobj.enabled = this.params.isDayEnabled(dataobj);
- // call user function to custom class style
- if (!dataobj.styleClass) dataobj.customStyleClass = this.params.dayStyleClass(dataobj);
- else
- {
- var styleclass = this.params.dayStyleClass(dataobj);
- dataobj.customStyleClass = dataobj.styleClass;
- if (styleclass) dataobj.customStyleClass += " " + styleclass;
- }
-
- contentElement = (this.customDayListMarkup ? element.firstChild : element);
- contentElement.innerHTML = this.evaluateMarkup(this.params.dayListMarkup, dataobj );
-
- if (weekdaycounter==6) weekdaycounter=0; else weekdaycounter++;
-
- var classNames = this.dayCellClassName[p];
-
- // class styles
- if (dataobj._month!=0)
- {
- classNames+=' rich-calendar-boundary-dates';
- if (!this.params.disabled && !this.params.readonly && boundaryDatesModeFlag)
- {
- classNames+=' rich-calendar-btn';
- }
- }
- else
- {
- if (todayflag && dataobj.day==todaydate)
- {
- this.todayCellId = element.id;
- this.todayCellColor = this.getCellBackgroundColor(element);
- classNames+=" rich-calendar-today";
- }
-
- if (selectedflag && dataobj.day==selecteddate)
- {
- this.selectedDateCellId = element.id;
- this.selectedDateCellColor = this.getCellBackgroundColor(element);
- classNames+=" rich-calendar-select";
- }
- else if (!this.params.disabled && !this.params.readonly && dataobj.enabled) classNames+=' rich-calendar-btn';
-
- // add custom style class
- if (dataobj.customStyleClass)
- {
- classNames+=' '+dataobj.customStyleClass;
- }
- }
- element.className = classNames;
-
- p++;
-
- dataobj = this.days[p];
- element=element.nextSibling;
- }
- obj = obj.nextSibling;
- }
-
- //alert(new Date().getTime()-_d.getTime());
-
- },
-
- renderHF: function()
- {
- if (this.params.showHeader) this.renderMarkup(this.params.headerMarkup, this.id+"Header", this.calendarContext);
- if (this.params.showFooter) this.renderMarkup(this.params.footerMarkup, this.id+"Footer", this.calendarContext);
-
- this.renderHeaderOptional();
- this.renderFooterOptional();
- },
-
- renderHeaderOptional: function()
- {
- this.renderMarkup(this.params.optionalHeaderMarkup, this.id+"HeaderOptional", this.calendarContext);
- },
-
- renderFooterOptional: function()
- {
- this.renderMarkup(this.params.optionalFooterMarkup, this.id+"FooterOptional", this.calendarContext);
- },
-
- renderMarkup: function (markup, elementId, context)
- {
- if (!markup) return;
-
- var e = rf.getDomElement(elementId);
- if (!e) return;
-
- e.innerHTML = this.evaluateMarkup(markup, context);
- },
-
- evaluateMarkup: function(markup, context)
- {
- if (!markup) return "";
-
- var result = [];
- var m;
- for (var i=0; i<markup.length; i++) {
- m = markup[i];
- if (m['getContent']) {
- result.push(m.getContent(context));
- }
- }
- return result.join('');
- },
-
- onUpdate: function()
- {
- var formattedDate = rf.calendarUtils.formatDate(this.getCurrentDate(),"MM/yyyy");
- rf.getDomElement(this.id+'InputCurrentDate').value=formattedDate;
-
- if (this.submitFunction)
- this.submitFunction.call(this, formattedDate);
- else
- this.render();
- },
-
- nextMonth: function() {
- this.changeCurrentDateOffset(0,1);
- },
-
- prevMonth: function() {
- this.changeCurrentDateOffset(0,-1);
- },
-
- nextYear: function() {
- this.changeCurrentDateOffset(1,0);
- },
-
- prevYear: function() {
- this.changeCurrentDateOffset(-1,0);
- },
-
- changeCurrentDate: function(year, month, noUpdate) {
- if (this.getCurrentMonth()!=month || this.getCurrentYear()!=year)
- {
- var date = new Date(year, month,1);
- if (this.invokeEvent("currentdateselect", rf.getDomElement(this.id), null, date))
- {
- // fix for RF-2450.
- // Additional event is fired: after the hidden input with current date
- // value is updated in function onUpdate() and then
- // the "currentdateselected" Event is fired.
- this.currentDate = date;
- if (noUpdate) this.render(); else this.onUpdate();
- this.invokeEvent("currentdateselected", rf.getDomElement(this.id), null, date);
- return true;
- }
- }
- return false;
- },
-
- changeCurrentDateOffset: function(yearOffset, monthOffset) {
- var date = new Date(this.currentDate.getFullYear()+yearOffset, this.currentDate.getMonth()+monthOffset,1);
-
- if (this.invokeEvent("currentdateselect", rf.getDomElement(this.id), null, date))
- {
- // fix for RF-2450.
- // Additional event is fired: after the hidden input with current date
- // value is updated in function onUpdate() and then
- // the "currentdateselected" Event is fired.
- this.currentDate = date;
- this.onUpdate();
- this.invokeEvent("currentdateselected", rf.getDomElement(this.id), null, date);
- }
- },
-
- today: function(noUpdate, noHighlight) {
-
- var now = new Date();
-
- var nowyear = now.getFullYear();
- var nowmonth = now.getMonth();
- var nowdate = now.getDate();
- var updateflag = false;
-
- if (nowdate!=this.todayDate.getDate()) {updateflag=true; this.todayDate = now;}
-
- if (nowyear != this.currentDate.getFullYear() || nowmonth != this.currentDate.getMonth() )
- {
- updateflag = true;
- this.currentDate = new Date(nowyear, nowmonth, 1);
- }
-
- if (this.params.todayControlMode=='select')
- {
- noHighlight=true;
- }
-
- if (updateflag)
- {
- if (noUpdate) this.render(); else this.onUpdate();
- }
- else
- {
- // highlight today
-
- if (this.isVisible && this.todayCellId && !noHighlight)
- {
- this.clearEffect(this.todayCellId);
- if (this.todayCellColor!="transparent")
- {
- $(rf.getDomElement(this.todayCellId)).effect("highlight", {easing:'easeInOutSine', color: this.todayCellColor}, 300);
- }
- }
- }
-
- // todayControl select mode
- if (this.params.todayControlMode=='select' && !this.params.disabled && !this.params.readonly)
- if (updateflag && !noUpdate && this.submitFunction)
- {
- this.afterLoad = this.selectToday;
- }
- else this.selectToday();
-
- },
-
- selectToday: function()
- {
- if (this.todayCellId)
- {
- var daydata = this.days[parseInt(this.todayCellId.substr(this.DATE_ELEMENT_ID.length),10)];
- var today = new Date();
- var date = new Date(today.getFullYear(), today.getMonth(), today.getDate());
- if (this.timeType)
- {
- this.setupTimeForDate(date);
- }
- if (daydata.enabled && this.selectDate(date,true) && !this.params.showApplyButton)
- {
- this.doCollapse();
- }
- }
- },
-
- selectDate: function(date, noUpdate, eventData) {
-
- if (!eventData)
- {
- eventData = {event: null, element: null};
- }
-
- var oldSelectedDate = this.selectedDate;
- var newSelectedDate;
- if (date)
- {
- if (typeof date=='string')
- {
- date = rf.calendarUtils.parseDate(date,this.params.datePattern, this.params.monthLabels, this.params.monthLabelsShort);
- }
- newSelectedDate = date;
- }
- else
- {
- newSelectedDate = null;
- }
-
- // fire user event
- var flag = true;
- var isDateChange = false;
- if ( (oldSelectedDate - newSelectedDate) && (oldSelectedDate!=null || newSelectedDate!=null) )
- {
- isDateChange = true;
- flag = this.invokeEvent("dateselect", eventData.element, eventData.event, date);
- }
-
- if (flag)
- {
- if (newSelectedDate!=null)
- {
- if (newSelectedDate.getMonth()==this.currentDate.getMonth() && newSelectedDate.getFullYear()==this.currentDate.getFullYear())
- {
- this.selectedDate = newSelectedDate;
- if (!oldSelectedDate || (oldSelectedDate - this.selectedDate))
- {
- // find cell and change style class
- var e = $(rf.getDomElement(this.DATE_ELEMENT_ID+(this.firstDateIndex + this.selectedDate.getDate()-1)));
-
- this.clearEffect(this.selectedDateCellId, "rich-calendar-select", (this.params.disabled || this.params.readonly ? null : "rich-calendar-btn"));
- this.selectedDateCellId = e.attr('id');
- this.selectedDateCellColor = this.getCellBackgroundColor(e);
-
- e.removeClass("rich-calendar-btn");
- e.removeClass("rich-calendar-hover");
- e.addClass("rich-calendar-select");
-
- this.renderHF();
- }
- else if (this.timeType!=0) this.renderHF();
- }
- else
- {
- //RF-5600
- this.selectedDate = newSelectedDate;
-
- // change currentDate and call this.onUpdate();
- if (this.changeCurrentDate(newSelectedDate.getFullYear(), newSelectedDate.getMonth(), noUpdate))
- {
- //this.selectedDate = newSelectedDate;
- } else {
- this.selectedDate = oldSelectedDate;
- isDateChange = false;
- }
- }
- }
- else
- {
- this.selectedDate = null;
-
- this.clearEffect(this.selectedDateCellId, "rich-calendar-select", (this.params.disabled || this.params.readonly ? null : "rich-calendar-btn"));
-
- if (this.selectedDateCellId)
- {
- this.selectedDateCellId = null;
- this.renderHF();
- }
-
- var date = new Date();
- if (this.currentDate.getMonth()==date.getMonth() && this.currentDate.getFullYear()==date.getFullYear())
- {
- this.renderHF();
- }
-
- var todayControlMode = this.params.todayControlMode;
- this.params.todayControlMode = '';
- this.today(noUpdate, true);
- this.params.todayControlMode = todayControlMode;
- }
-
- // call user event
- if (isDateChange)
- {
- this.invokeEvent("dateselected", eventData.element, eventData.event, this.selectedDate);
- if (!this.params.showApplyButton)
- {
- this.setInputField(this.selectedDate!=null ? this.getSelectedDateString(this.params.datePattern) : "", eventData.event);
- }
- }
- }
-
- return isDateChange;
- },
-
- resetSelectedDate: function()
- {
- if (!this.selectedDate) return;
- if (this.invokeEvent("dateselect", null, null, null))
- {
- this.selectedDate = null;
- this.invokeEvent("dateselected", null, null, null);
-
- this.selectedDateCellId = this.clearEffect(this.selectedDateCellId, "rich-calendar-select", (this.params.disabled || this.params.readonly ? null : "rich-calendar-btn"));
-
- this.renderHF();
- if (!this.params.showApplyButton)
- {
- this.setInputField("", null);
- this.doCollapse();
- }
- }
- },
-
- showSelectedDate: function()
- {
- if (!this.selectedDate) return;
- if (this.currentDate.getMonth()!=this.selectedDate.getMonth() || this.currentDate.getFullYear()!=this.selectedDate.getFullYear())
- {
- this.currentDate = new Date(this.selectedDate);
- this.currentDate.setDate(1);
- this.onUpdate();
- }
- else
- {
- // highlight Selected Date
- if (this.isVisible && this.selectedDateCellId)
- {
- this.clearEffect(this.selectedDateCellId);
- if (this.selectedDateCellColor!="transparent")
- {
- $(rf.getDomElement(this.selectedDateCellId)).effect("highlight", {easing:'easeInOutSine', color: this.selectedDateCellColor}, 300);
-
- }
- }
- }
- },
-
- close: function(updateDate)
- {
- if (updateDate)
- {
- this.setInputField(this.getSelectedDateString(this.params.datePattern), null);
- }
- this.doCollapse();
- },
-
- clonePosition: function (source, elements, offset)
- {
- var jqe = $(source);
- if (!elements.length) elements = [elements];
- offset = offset || {left:0,top:0};
- var width = jqe.outerWidth()+"px", height = jqe.outerHeight()+"px";
- var pos = jqe.position();
- var left = Math.floor(pos.left)+offset.left+"px", top = Math.floor(pos.top)+offset.top+"px";
- var element;
- for (var i = 0; i<elements.length;i++) {
- element = elements[i];
- element.style.width = width;
- element.style.height = height;
- element.style.left = left;
- element.style.top = top;
- }
- },
-
- showTimeEditor: function()
- {
- var editor;
- if (this.timeType==0) return;
- if (!this.isEditorCreated) editor = this.createEditor();
- else editor = rf.getDomElement(this.EDITOR_ID);
- if (!this.isTimeEditorLayoutCreated) this.createTimeEditorLayout(editor);
-
- $(rf.getDomElement(this.TIME_EDITOR_LAYOUT_ID)).show();
-
- var editor_shadow = rf.getDomElement(this.EDITOR_SHADOW_ID);
-
- this.clonePosition(rf.getDomElement(this.id), [editor, editor_shadow]);
-
- this.updateTimeEditor();
-
- $(editor_shadow).show();
-
- $(editor).show();
-
- this.clonePosition(rf.getDomElement(this.TIME_EDITOR_LAYOUT_ID), rf.getDomElement(this.EDITOR_LAYOUT_SHADOW_ID), {left: 3, top: 3});
- this.isEditorVisible = true;
- },
-
- hideEditor: function()
- {
- if (this.isTimeEditorLayoutCreated) $(rf.getDomElement(this.TIME_EDITOR_LAYOUT_ID)).hide();
- if (this.isDateEditorLayoutCreated) $(rf.getDomElement(this.DATE_EDITOR_LAYOUT_ID)).hide();
- $(rf.getDomElement(this.EDITOR_ID)).hide();
- $(rf.getDomElement(this.EDITOR_SHADOW_ID)).hide();
- this.isEditorVisible = false;
- },
-
- hideTimeEditor: function(updateTime)
- {
- this.hideEditor();
- if (updateTime && this.selectedDate)
- {
- var m = parseInt(rf.getDomElement(this.id+'TimeMinutes').value,10);
- var h=parseInt(rf.getDomElement(this.id+'TimeHours').value,10);
- if (this.timeType==2)
- {
- if (rf.getDomElement(this.id+'TimeSign').value.toLowerCase()=="am")
- {
- if (h==12) h = 0;
- }
- else
- {
- if (h!=12) h+=12;
- }
- }
- var date = new Date(this.selectedDate.getFullYear(), this.selectedDate.getMonth(), this.selectedDate.getDate(), h, m, 0);
- if (date-this.selectedDate && this.invokeEvent("timeselect",null, null, date))
- {
- this.selectedDate = date;
- this.renderHF();
- if (!this.params.popup || !this.params.showApplyButton) this.setInputField(this.getSelectedDateString(this.params.datePattern), null);
- this.invokeEvent("timeselected",null, null, this.selectedDate);
- }
- }
- if (this.params.popup && !this.params.showApplyButton) this.close(false);
- },
-
- showDateEditor: function()
- {
- var editor;
- if (!this.isEditorCreated) editor = this.createEditor();
- else editor = rf.getDomElement(this.EDITOR_ID);
- if (!this.isDateEditorLayoutCreated) this.createDateEditorLayout(editor);
- else this.updateDateEditor();
-
- $(rf.getDomElement(this.DATE_EDITOR_LAYOUT_ID)).show();
-
- var editor_shadow = rf.getDomElement(this.EDITOR_SHADOW_ID);
-
- this.clonePosition(rf.getDomElement(this.id), [editor, editor_shadow]);
-
- $(editor_shadow).show();
- $(editor).show();
-
- this.clonePosition(rf.getDomElement(this.DATE_EDITOR_LAYOUT_ID), rf.getDomElement(this.EDITOR_LAYOUT_SHADOW_ID), {left: 3, top: 3});
-
- this.isEditorVisible = true;
- },
-
- hideDateEditor: function(updateCurrentDate)
- {
- this.hideEditor();
- if (updateCurrentDate)
- {
- this.changeCurrentDate(this.dateEditorYear, this.dateEditorMonth);
- }
- },
-
- getNamespace: function () {
- return this.namespace;
- }
- });
-})(jQuery, RichFaces);
\ No newline at end of file
Deleted: sandbox/trunk/prototypes/calendar/jquery.effects.core.js
===================================================================
--- sandbox/trunk/prototypes/calendar/jquery.effects.core.js 2010-10-21 06:35:50 UTC (rev 19627)
+++ sandbox/trunk/prototypes/calendar/jquery.effects.core.js 2010-10-21 08:07:06 UTC (rev 19628)
@@ -1,714 +0,0 @@
-/*
- * jQuery UI Effects 1.8.5
- *
- * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * http://docs.jquery.com/UI/Effects/
- */
-;jQuery.effects || (function($, undefined) {
-
-$.effects = {};
-
-
-
-/******************************************************************************/
-/****************************** COLOR ANIMATIONS ******************************/
-/******************************************************************************/
-
-// override the animation for color styles
-$.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
- 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'],
-function(i, attr) {
- $.fx.step[attr] = function(fx) {
- if (!fx.colorInit) {
- fx.start = getColor(fx.elem, attr);
- fx.end = getRGB(fx.end);
- fx.colorInit = true;
- }
-
- fx.elem.style[attr] = 'rgb(' +
- Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + ',' +
- Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + ',' +
- Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ')';
- };
-});
-
-// Color Conversion functions from highlightFade
-// By Blair Mitchelmore
-// http://jquery.offput.ca/highlightFade/
-
-// Parse strings looking for color tuples [255,255,255]
-function getRGB(color) {
- var result;
-
- // Check if we're already dealing with an array of colors
- if ( color && color.constructor == Array && color.length == 3 )
- return color;
-
- // Look for rgb(num,num,num)
- if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
- return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)];
-
- // Look for rgb(num%,num%,num%)
- if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
- return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
-
- // Look for #a0b1c2
- if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
- return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
-
- // Look for #fff
- if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
- return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
-
- // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
- if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
- return colors['transparent'];
-
- // Otherwise, we're most likely dealing with a named color
- return colors[$.trim(color).toLowerCase()];
-}
-
-function getColor(elem, attr) {
- var color;
-
- do {
- color = $.curCSS(elem, attr);
-
- // Keep going until we find an element that has color, or we hit the body
- if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
- break;
-
- attr = "backgroundColor";
- } while ( elem = elem.parentNode );
-
- return getRGB(color);
-};
-
-// Some named colors to work with
-// From Interface by Stefan Petre
-// http://interface.eyecon.ro/
-
-var colors = {
- aqua:[0,255,255],
- azure:[240,255,255],
- beige:[245,245,220],
- black:[0,0,0],
- blue:[0,0,255],
- brown:[165,42,42],
- cyan:[0,255,255],
- darkblue:[0,0,139],
- darkcyan:[0,139,139],
- darkgrey:[169,169,169],
- darkgreen:[0,100,0],
- darkkhaki:[189,183,107],
- darkmagenta:[139,0,139],
- darkolivegreen:[85,107,47],
- darkorange:[255,140,0],
- darkorchid:[153,50,204],
- darkred:[139,0,0],
- darksalmon:[233,150,122],
- darkviolet:[148,0,211],
- fuchsia:[255,0,255],
- gold:[255,215,0],
- green:[0,128,0],
- indigo:[75,0,130],
- khaki:[240,230,140],
- lightblue:[173,216,230],
- lightcyan:[224,255,255],
- lightgreen:[144,238,144],
- lightgrey:[211,211,211],
- lightpink:[255,182,193],
- lightyellow:[255,255,224],
- lime:[0,255,0],
- magenta:[255,0,255],
- maroon:[128,0,0],
- navy:[0,0,128],
- olive:[128,128,0],
- orange:[255,165,0],
- pink:[255,192,203],
- purple:[128,0,128],
- violet:[128,0,128],
- red:[255,0,0],
- silver:[192,192,192],
- white:[255,255,255],
- yellow:[255,255,0],
- transparent: [255,255,255]
-};
-
-
-
-/******************************************************************************/
-/****************************** CLASS ANIMATIONS ******************************/
-/******************************************************************************/
-
-var classAnimationActions = ['add', 'remove', 'toggle'],
- shorthandStyles = {
- border: 1,
- borderBottom: 1,
- borderColor: 1,
- borderLeft: 1,
- borderRight: 1,
- borderTop: 1,
- borderWidth: 1,
- margin: 1,
- padding: 1
- };
-
-function getElementStyles() {
- var style = document.defaultView
- ? document.defaultView.getComputedStyle(this, null)
- : this.currentStyle,
- newStyle = {},
- key,
- camelCase;
-
- // webkit enumerates style porperties
- if (style && style.length && style[0] && style[style[0]]) {
- var len = style.length;
- while (len--) {
- key = style[len];
- if (typeof style[key] == 'string') {
- camelCase = key.replace(/\-(\w)/g, function(all, letter){
- return letter.toUpperCase();
- });
- newStyle[camelCase] = style[key];
- }
- }
- } else {
- for (key in style) {
- if (typeof style[key] === 'string') {
- newStyle[key] = style[key];
- }
- }
- }
-
- return newStyle;
-}
-
-function filterStyles(styles) {
- var name, value;
- for (name in styles) {
- value = styles[name];
- if (
- // ignore null and undefined values
- value == null ||
- // ignore functions (when does this occur?)
- $.isFunction(value) ||
- // shorthand styles that need to be expanded
- name in shorthandStyles ||
- // ignore scrollbars (break in IE)
- (/scrollbar/).test(name) ||
-
- // only colors or values that can be converted to numbers
- (!(/color/i).test(name) && isNaN(parseFloat(value)))
- ) {
- delete styles[name];
- }
- }
-
- return styles;
-}
-
-function styleDifference(oldStyle, newStyle) {
- var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
- name;
-
- for (name in newStyle) {
- if (oldStyle[name] != newStyle[name]) {
- diff[name] = newStyle[name];
- }
- }
-
- return diff;
-}
-
-$.effects.animateClass = function(value, duration, easing, callback) {
- if ($.isFunction(easing)) {
- callback = easing;
- easing = null;
- }
-
- return this.each(function() {
-
- var that = $(this),
- originalStyleAttr = that.attr('style') || ' ',
- originalStyle = filterStyles(getElementStyles.call(this)),
- newStyle,
- className = that.attr('className');
-
- $.each(classAnimationActions, function(i, action) {
- if (value[action]) {
- that[action + 'Class'](value[action]);
- }
- });
- newStyle = filterStyles(getElementStyles.call(this));
- that.attr('className', className);
-
- that.animate(styleDifference(originalStyle, newStyle), duration, easing, function() {
- $.each(classAnimationActions, function(i, action) {
- if (value[action]) { that[action + 'Class'](value[action]); }
- });
- // work around bug in IE by clearing the cssText before setting it
- if (typeof that.attr('style') == 'object') {
- that.attr('style').cssText = '';
- that.attr('style').cssText = originalStyleAttr;
- } else {
- that.attr('style', originalStyleAttr);
- }
- if (callback) { callback.apply(this, arguments); }
- });
- });
-};
-
-$.fn.extend({
- _addClass: $.fn.addClass,
- addClass: function(classNames, speed, easing, callback) {
- return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
- },
-
- _removeClass: $.fn.removeClass,
- removeClass: function(classNames,speed,easing,callback) {
- return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
- },
-
- _toggleClass: $.fn.toggleClass,
- toggleClass: function(classNames, force, speed, easing, callback) {
- if ( typeof force == "boolean" || force === undefined ) {
- if ( !speed ) {
- // without speed parameter;
- return this._toggleClass(classNames, force);
- } else {
- return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
- }
- } else {
- // without switch parameter;
- return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
- }
- },
-
- switchClass: function(remove,add,speed,easing,callback) {
- return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
- }
-});
-
-
-
-/******************************************************************************/
-/*********************************** EFFECTS **********************************/
-/******************************************************************************/
-
-$.extend($.effects, {
- version: "1.8.5",
-
- // Saves a set of properties in a data storage
- save: function(element, set) {
- for(var i=0; i < set.length; i++) {
- if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]);
- }
- },
-
- // Restores a set of previously saved properties from a data storage
- restore: function(element, set) {
- for(var i=0; i < set.length; i++) {
- if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i]));
- }
- },
-
- setMode: function(el, mode) {
- if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
- return mode;
- },
-
- getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
- // this should be a little more flexible in the future to handle a string & hash
- var y, x;
- switch (origin[0]) {
- case 'top': y = 0; break;
- case 'middle': y = 0.5; break;
- case 'bottom': y = 1; break;
- default: y = origin[0] / original.height;
- };
- switch (origin[1]) {
- case 'left': x = 0; break;
- case 'center': x = 0.5; break;
- case 'right': x = 1; break;
- default: x = origin[1] / original.width;
- };
- return {x: x, y: y};
- },
-
- // Wraps the element around a wrapper that copies position properties
- createWrapper: function(element) {
-
- // if the element is already wrapped, return it
- if (element.parent().is('.ui-effects-wrapper')) {
- return element.parent();
- }
-
- // wrap the element
- var props = {
- width: element.outerWidth(true),
- height: element.outerHeight(true),
- 'float': element.css('float')
- },
- wrapper = $('<div></div>')
- .addClass('ui-effects-wrapper')
- .css({
- fontSize: '100%',
- background: 'transparent',
- border: 'none',
- margin: 0,
- padding: 0
- });
-
- element.wrap(wrapper);
- wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element
-
- // transfer positioning properties to the wrapper
- if (element.css('position') == 'static') {
- wrapper.css({ position: 'relative' });
- element.css({ position: 'relative' });
- } else {
- $.extend(props, {
- position: element.css('position'),
- zIndex: element.css('z-index')
- });
- $.each(['top', 'left', 'bottom', 'right'], function(i, pos) {
- props[pos] = element.css(pos);
- if (isNaN(parseInt(props[pos], 10))) {
- props[pos] = 'auto';
- }
- });
- element.css({position: 'relative', top: 0, left: 0 });
- }
-
- return wrapper.css(props).show();
- },
-
- removeWrapper: function(element) {
- if (element.parent().is('.ui-effects-wrapper'))
- return element.parent().replaceWith(element);
- return element;
- },
-
- setTransition: function(element, list, factor, value) {
- value = value || {};
- $.each(list, function(i, x){
- unit = element.cssUnit(x);
- if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
- });
- return value;
- }
-});
-
-
-function _normalizeArguments(effect, options, speed, callback) {
- // shift params for method overloading
- if (typeof effect == 'object') {
- callback = options;
- speed = null;
- options = effect;
- effect = options.effect;
- }
- if ($.isFunction(options)) {
- callback = options;
- speed = null;
- options = {};
- }
- if (typeof options == 'number' || $.fx.speeds[options]) {
- callback = speed;
- speed = options;
- options = {};
- }
- if ($.isFunction(speed)) {
- callback = speed;
- speed = null;
- }
-
- options = options || {};
-
- speed = speed || options.duration;
- speed = $.fx.off ? 0 : typeof speed == 'number'
- ? speed : $.fx.speeds[speed] || $.fx.speeds._default;
-
- callback = callback || options.complete;
-
- return [effect, options, speed, callback];
-}
-
-$.fn.extend({
- effect: function(effect, options, speed, callback) {
- var args = _normalizeArguments.apply(this, arguments),
- // TODO: make effects takes actual parameters instead of a hash
- args2 = {
- options: args[1],
- duration: args[2],
- callback: args[3]
- },
- effectMethod = $.effects[effect];
-
- return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this;
- },
-
- _show: $.fn.show,
- show: function(speed) {
- if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
- return this._show.apply(this, arguments);
- } else {
- var args = _normalizeArguments.apply(this, arguments);
- args[1].mode = 'show';
- return this.effect.apply(this, args);
- }
- },
-
- _hide: $.fn.hide,
- hide: function(speed) {
- if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
- return this._hide.apply(this, arguments);
- } else {
- var args = _normalizeArguments.apply(this, arguments);
- args[1].mode = 'hide';
- return this.effect.apply(this, args);
- }
- },
-
- // jQuery core overloads toggle and creates _toggle
- __toggle: $.fn.toggle,
- toggle: function(speed) {
- if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ||
- typeof speed == 'boolean' || $.isFunction(speed)) {
- return this.__toggle.apply(this, arguments);
- } else {
- var args = _normalizeArguments.apply(this, arguments);
- args[1].mode = 'toggle';
- return this.effect.apply(this, args);
- }
- },
-
- // helper functions
- cssUnit: function(key) {
- var style = this.css(key), val = [];
- $.each( ['em','px','%','pt'], function(i, unit){
- if(style.indexOf(unit) > 0)
- val = [parseFloat(style), unit];
- });
- return val;
- }
-});
-
-
-
-/******************************************************************************/
-/*********************************** EASING ***********************************/
-/******************************************************************************/
-
-/*
- * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
- *
- * Uses the built in easing capabilities added In jQuery 1.1
- * to offer multiple easing options
- *
- * TERMS OF USE - jQuery Easing
- *
- * Open source under the BSD License.
- *
- * Copyright 2008 George McGinley Smith
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * Neither the name of the author nor the names of contributors may be used to endorse
- * or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
-*/
-
-// t: current time, b: begInnIng value, c: change In value, d: duration
-$.easing.jswing = $.easing.swing;
-
-$.extend($.easing,
-{
- def: 'easeOutQuad',
- swing: function (x, t, b, c, d) {
- //alert($.easing.default);
- return $.easing[$.easing.def](x, t, b, c, d);
- },
- easeInQuad: function (x, t, b, c, d) {
- return c*(t/=d)*t + b;
- },
- easeOutQuad: function (x, t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- },
- easeInOutQuad: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t + b;
- return -c/2 * ((--t)*(t-2) - 1) + b;
- },
- easeInCubic: function (x, t, b, c, d) {
- return c*(t/=d)*t*t + b;
- },
- easeOutCubic: function (x, t, b, c, d) {
- return c*((t=t/d-1)*t*t + 1) + b;
- },
- easeInOutCubic: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t + b;
- return c/2*((t-=2)*t*t + 2) + b;
- },
- easeInQuart: function (x, t, b, c, d) {
- return c*(t/=d)*t*t*t + b;
- },
- easeOutQuart: function (x, t, b, c, d) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
- },
- easeInOutQuart: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
- },
- easeInQuint: function (x, t, b, c, d) {
- return c*(t/=d)*t*t*t*t + b;
- },
- easeOutQuint: function (x, t, b, c, d) {
- return c*((t=t/d-1)*t*t*t*t + 1) + b;
- },
- easeInOutQuint: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
- return c/2*((t-=2)*t*t*t*t + 2) + b;
- },
- easeInSine: function (x, t, b, c, d) {
- return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
- },
- easeOutSine: function (x, t, b, c, d) {
- return c * Math.sin(t/d * (Math.PI/2)) + b;
- },
- easeInOutSine: function (x, t, b, c, d) {
- return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
- },
- easeInExpo: function (x, t, b, c, d) {
- return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
- },
- easeOutExpo: function (x, t, b, c, d) {
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
- },
- easeInOutExpo: function (x, t, b, c, d) {
- if (t==0) return b;
- if (t==d) return b+c;
- if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
- return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
- },
- easeInCirc: function (x, t, b, c, d) {
- return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
- },
- easeOutCirc: function (x, t, b, c, d) {
- return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
- },
- easeInOutCirc: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
- return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
- },
- easeInElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- },
- easeOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
- },
- easeInOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
- easeInBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
- easeOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
- easeInOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
- },
- easeInBounce: function (x, t, b, c, d) {
- return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
- },
- easeOutBounce: function (x, t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- } else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- }
- },
- easeInOutBounce: function (x, t, b, c, d) {
- if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
- return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
-});
-
-/*
- *
- * TERMS OF USE - EASING EQUATIONS
- *
- * Open source under the BSD License.
- *
- * Copyright 2001 Robert Penner
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * Neither the name of the author nor the names of contributors may be used to endorse
- * or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-})(jQuery);
Deleted: sandbox/trunk/prototypes/calendar/jquery.effects.highlight.js
===================================================================
--- sandbox/trunk/prototypes/calendar/jquery.effects.highlight.js 2010-10-21 06:35:50 UTC (rev 19627)
+++ sandbox/trunk/prototypes/calendar/jquery.effects.highlight.js 2010-10-21 08:07:06 UTC (rev 19628)
@@ -1,50 +0,0 @@
-/*
- * jQuery UI Effects Highlight 1.8.5
- *
- * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * http://docs.jquery.com/UI/Effects/Highlight
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.highlight = function(o) {
- return this.queue(function() {
- var elem = $(this),
- props = ['backgroundImage', 'backgroundColor', 'opacity'],
- mode = $.effects.setMode(elem, o.options.mode || 'show'),
- animation = {
- backgroundColor: elem.css('backgroundColor')
- };
-
- if (mode == 'hide') {
- animation.opacity = 0;
- }
-
- $.effects.save(elem, props);
- elem
- .show()
- .css({
- backgroundImage: 'none',
- backgroundColor: o.options.color || '#ffff99'
- })
- .animate(animation, {
- queue: false,
- duration: o.duration,
- easing: o.options.easing,
- complete: function() {
- (mode == 'hide' && elem.hide());
- $.effects.restore(elem, props);
- (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
- (o.callback && o.callback.apply(this, arguments));
- elem.dequeue();
- }
- });
- });
-};
-
-})(jQuery);
Deleted: sandbox/trunk/prototypes/calendar/json-dom.js
===================================================================
--- sandbox/trunk/prototypes/calendar/json-dom.js 2010-10-21 06:35:50 UTC (rev 19627)
+++ sandbox/trunk/prototypes/calendar/json-dom.js 2010-10-21 08:07:06 UTC (rev 19628)
@@ -1,133 +0,0 @@
-// AJAX-JSF AJAX-like library, for communicate with view Tree on server side.
-// In case of XMLHttpRequest don't worked, use :
-// JSHttpRequest v1.12. (C) Dmitry Koterov, 2005-01-27.
-// http://forum.dklab.ru/users/DmitryKoterov/
-//
-// Do not remove this comment if you want to use script!
-// ?? ???????? ?????? ???????????, ???? ?? ?????? ???????????? ??????!
-//
-// Modified by Alexander J. Smirnov to use as JSF AJAX-like components.
-
-// DOM - like elements for JSRequest. JS serialiser encode
-// XML sax events to creation of corresponding objects.
-JSNode = function() {
-};
-
-// Base node
-JSNode.prototype = {
- tag : null,
- attrs : {},
- childs : [],
- value : "",
- _symbols : {
- '&':"&",
- '<':"<",
- '>':">",
- '"':""",
- '\'':"'",
- '\u00A0':" "
- },
- // Public functions
- getInnerHTML : function(context) {
- var children = [];
- for (var i = 0; i < this.childs.length; i++)
- {
- children.push(this.childs[i].getContent(context));
- }
- return children.join('');
- },
- // Escape XML symbols - < > & ' ...
- xmlEscape : function(value) {
- var text = value ? value.toString() : "";
- for(var i in this._symbols ) {
- text = text.replace(i,this._symbols[i]);
-
- }
- return text;
- }
-};
-
-// Element node
-E = function(tagname,attributes,childnodes) {
- this.tag = tagname;
- if (attributes) this.attrs = attributes;
- if(childnodes) this.childs = childnodes;
-};
-
-E.prototype = new JSNode();
-E.prototype.getContent = function(context) {
- var html = "<"+this.tag;
- var inner = this.getInnerHTML(context);
- if (inner=='') this.isEmpty = true; else this.isEmpty=false;
- for(var i in this.attrs) {
- if (!this.attrs.hasOwnProperty(i)) {
- continue ;
- }
-
- var attrValue = this.attrs[i];
-
- if (typeof attrValue == "function")
- attrValue = attrValue.call(this, context);
-
- if (attrValue)
- html += " "+(i=='className'?'class':i)+'="'+this.xmlEscape(attrValue)+'"';
- }
- html+= ">"+inner+"</"+this.tag+">";
- return html;
-};
-
-// Escaped Text node
-ET = function(text) {
- this.value = text;
-};
-
-
-//ET.prototype = new JSNode();
-ET.prototype.getContent = function(context) {
- var value = this.value;
- if (typeof value=="function") value=value(context);
- if (value && value.getContent) {
- value = value.getContent(context);
- }
-
- if (value) return value;
-
- return "";
-};
-
-// Text node
-T = function(text) {
- this.value = text;
-};
-
-T.prototype = new JSNode();
-T.prototype.getContent = function(context) {
- var value = this.value;
- if (typeof value=="function") value=value(context);
-
- if (value) return this.xmlEscape(value);
-
- return "";
-};
-
-// Comment node
-C = function(text) {
- this.value = text;
-};
-
-//C.prototype = new JSNode();
-C.prototype.getContent = function(context) {
- return "<!--"+this.value+"-->";
-};
-
-// CDATA Section node.
-D = function(text) {
- this.value = text;
-};
-
-//D.prototype = new JSNode();
-D.prototype.getContent = function(context) {
- return "<![CDATA["+this.value+"]]>";
-};
-
-
13 years, 8 months