JBoss Rich Faces SVN: r20085 - in sandbox/trunk/ui/drag-drop: ui and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-18 09:26:51 -0500 (Thu, 18 Nov 2010)
New Revision: 20085
Added:
sandbox/trunk/ui/drag-drop/pom.xml
sandbox/trunk/ui/drag-drop/ui/
sandbox/trunk/ui/drag-drop/ui/pom.xml
sandbox/trunk/ui/drag-drop/ui/src/
sandbox/trunk/ui/drag-drop/ui/src/main/
sandbox/trunk/ui/drag-drop/ui/src/main/java/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragSupport.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDropSupport.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/package-info.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
sandbox/trunk/ui/drag-drop/ui/src/main/resources/
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-dnd.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-ui-core.js
sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js
Removed:
sandbox/trunk/ui/drag-drop/src/
Log:
initial commit
Added: sandbox/trunk/ui/drag-drop/pom.xml
===================================================================
--- sandbox/trunk/ui/drag-drop/pom.xml (rev 0)
+++ sandbox/trunk/ui/drag-drop/pom.xml 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces</groupId>
+ <artifactId>richfaces-root-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.richfaces.ui.output</groupId>
+ <artifactId>richfaces-ui-output-aggregator</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Richfaces UI Components: Drag-n-Drop Aggregator</name>
+
+ <modules>
+ <module>api</module>
+ <module>ui</module>
+ </modules>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/ui/output</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/ui/output</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces</url>
+ </scm>
+</project>
\ No newline at end of file
Added: sandbox/trunk/ui/drag-drop/ui/pom.xml
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/pom.xml (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/pom.xml 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>richfaces-ui-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.richfaces.ui.dnd</groupId>
+ <artifactId>richfaces-ui-dnd-ui</artifactId>
+ <name>Richfaces UI Components: DND UI</name>
+ <packaging>jar</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <suppressionsLocation>${project.basedir}/richfaces-suppressions.xml</suppressionsLocation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.common</groupId>
+ <artifactId>richfaces-ui-common-ui</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-ui</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.dnd</groupId>
+ <artifactId>richfaces-ui-dnd-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <version>1.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/trunk/ui/output/panels/ui</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/ui/output/panels/ui</developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces</url>
+ </scm>
+
+</project>
\ No newline at end of file
Added: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragSupport.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragSupport.java (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDragSupport.java 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+
+package org.richfaces.component;
+
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+
+
+/**
+ * @author abelevich
+ *
+ */
+
+@JsfComponent(
+ generate = "org.richfaces.component.UIDragSupport",
+ renderer = @JsfRenderer(type = "org.richfaces.DragSupportRenderer"),
+ tag = @Tag(name="dragSupport"),
+ type = AbstractDragSupport.COMPONENT_TYPE,
+ family = AbstractDragSupport.COMPONENT_FAMILY
+)
+public abstract class AbstractDragSupport extends AbstractActionComponent {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.DragSupport";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.DragSupport";
+
+}
+
+
Added: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDropSupport.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDropSupport.java (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/AbstractDropSupport.java 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+
+/**
+ * @author abelevich
+ *
+ */
+@JsfComponent(
+ generate = "org.richfaces.component.UIDropSupport",
+ renderer = @JsfRenderer(type = "org.richfaces.DropSupportRenderer"),
+ tag = @Tag(name="dropSupport"),
+ type = AbstractDropSupport.COMPONENT_TYPE,
+ family = AbstractDropSupport.COMPONENT_FAMILY
+ )
+public abstract class AbstractDropSupport extends AbstractActionComponent {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.DropSupport";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.DropSupport";
+
+}
Added: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/package-info.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/package-info.java (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/component/package-info.java 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+(a)org.richfaces.cdk.annotations.TagLibrary(uri="http://richfaces.org/dnd", shortName="dnd")
+package org.richfaces.component;
Added: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DragBehaviorRendererBase.java 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+package org.richfaces.renderkit;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+
+/**
+ * @author abelevich
+ *
+ */
+
+@ResourceDependencies({
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "jquery-ui-core.js"),
+ @ResourceDependency(name = "jquery-dnd.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-dnd.js")
+})
+public class DragBehaviorRendererBase extends AjaxComponentRendererBase {
+
+}
Added: sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/java/org/richfaces/renderkit/DropBehaviorRendererBase.java 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, 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.
+ */
+
+package org.richfaces.renderkit;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+
+/**
+ * @author abelevich
+ *
+ */
+
+@ResourceDependencies({
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "jquery-ui-core.js"),
+ @ResourceDependency(name = "jquery-dnd.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-dnd.js")
+})
+public class DropBehaviorRendererBase extends AjaxComponentRendererBase {
+}
Added: sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-dnd.js
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-dnd.js (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-dnd.js 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,1082 @@
+/*
+ * jQuery UI Draggable 1.8.6
+ *
+ * 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/Draggables
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.mouse.js
+ * jquery.ui.widget.js
+ */
+(function( $, undefined ) {
+
+$.widget("ui.draggable", $.ui.mouse, {
+ widgetEventPrefix: "drag",
+ options: {
+ addClasses: true,
+ appendTo: "parent",
+ axis: false,
+ connectToSortable: false,
+ containment: false,
+ cursor: "auto",
+ cursorAt: false,
+ grid: false,
+ handle: false,
+ helper: "original",
+ iframeFix: false,
+ opacity: false,
+ refreshPositions: false,
+ revert: false,
+ revertDuration: 500,
+ scope: "default",
+ scroll: true,
+ scrollSensitivity: 20,
+ scrollSpeed: 20,
+ snap: false,
+ snapMode: "both",
+ snapTolerance: 20,
+ stack: false,
+ zIndex: false
+ },
+ _create: function() {
+
+ if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position")))
+ this.element[0].style.position = 'relative';
+
+ (this.options.addClasses && this.element.addClass("ui-draggable"));
+ (this.options.disabled && this.element.addClass("ui-draggable-disabled"));
+
+ this._mouseInit();
+
+ },
+
+ destroy: function() {
+ if(!this.element.data('draggable')) return;
+ this.element
+ .removeData("draggable")
+ .unbind(".draggable")
+ .removeClass("ui-draggable"
+ + " ui-draggable-dragging"
+ + " ui-draggable-disabled");
+ this._mouseDestroy();
+
+ return this;
+ },
+
+ _mouseCapture: function(event) {
+
+ var o = this.options;
+
+ // among others, prevent a drag on a resizable-handle
+ if (this.helper || o.disabled || $(event.target).is('.ui-resizable-handle'))
+ return false;
+
+ //Quit if we're not on a valid handle
+ this.handle = this._getHandle(event);
+ if (!this.handle)
+ return false;
+
+ return true;
+
+ },
+
+ _mouseStart: function(event) {
+
+ var o = this.options;
+
+ //Create and append the visible helper
+ this.helper = this._createHelper(event);
+
+ //Cache the helper size
+ this._cacheHelperProportions();
+
+ //If ddmanager is used for droppables, set the global draggable
+ if($.ui.ddmanager)
+ $.ui.ddmanager.current = this;
+
+ /*
+ * - Position generation -
+ * This block generates everything position related - it's the core of draggables.
+ */
+
+ //Cache the margins of the original element
+ this._cacheMargins();
+
+ //Store the helper's css position
+ this.cssPosition = this.helper.css("position");
+ this.scrollParent = this.helper.scrollParent();
+
+ //The element's absolute position on the page minus margins
+ this.offset = this.positionAbs = this.element.offset();
+ this.offset = {
+ top: this.offset.top - this.margins.top,
+ left: this.offset.left - this.margins.left
+ };
+
+ $.extend(this.offset, {
+ click: { //Where the click happened, relative to the element
+ left: event.pageX - this.offset.left,
+ top: event.pageY - this.offset.top
+ },
+ parent: this._getParentOffset(),
+ relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
+ });
+
+ //Generate the original position
+ this.originalPosition = this.position = this._generatePosition(event);
+ this.originalPageX = event.pageX;
+ this.originalPageY = event.pageY;
+
+ //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
+ (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
+
+ //Set a containment if given in the options
+ if(o.containment)
+ this._setContainment();
+
+ //Trigger event + callbacks
+ if(this._trigger("start", event) === false) {
+ this._clear();
+ return false;
+ }
+
+ //Recache the helper size
+ this._cacheHelperProportions();
+
+ //Prepare the droppable offsets
+ if ($.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(this, event);
+
+ this.helper.addClass("ui-draggable-dragging");
+ this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+ return true;
+ },
+
+ _mouseDrag: function(event, noPropagation) {
+
+ //Compute the helpers position
+ this.position = this._generatePosition(event);
+ this.positionAbs = this._convertPositionTo("absolute");
+
+ //Call plugins and callbacks and use the resulting position if something is returned
+ if (!noPropagation) {
+ var ui = this._uiHash();
+ if(this._trigger('drag', event, ui) === false) {
+ this._mouseUp({});
+ return false;
+ }
+ this.position = ui.position;
+ }
+
+ if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
+ if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
+
+ return false;
+ },
+
+ _mouseStop: function(event) {
+
+ //If we are using droppables, inform the manager about the drop
+ var dropped = false;
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
+ dropped = $.ui.ddmanager.drop(this, event);
+
+ //if a drop comes from outside (a sortable)
+ if(this.dropped) {
+ dropped = this.dropped;
+ this.dropped = false;
+ }
+
+ //if the original element is removed, don't bother to continue
+ if(!this.element[0] || !this.element[0].parentNode)
+ return false;
+
+ if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
+ var self = this;
+ $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
+ if(self._trigger("stop", event) !== false) {
+ self._clear();
+ }
+ });
+ } else {
+ if(this._trigger("stop", event) !== false) {
+ this._clear();
+ }
+ }
+
+ return false;
+ },
+
+ cancel: function() {
+
+ if(this.helper.is(".ui-draggable-dragging")) {
+ this._mouseUp({});
+ } else {
+ this._clear();
+ }
+
+ return this;
+
+ },
+
+ _getHandle: function(event) {
+
+ var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
+ $(this.options.handle, this.element)
+ .find("*")
+ .andSelf()
+ .each(function() {
+ if(this == event.target) handle = true;
+ });
+
+ return handle;
+
+ },
+
+ _createHelper: function(event) {
+
+ var o = this.options;
+ var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element);
+
+ if(!helper.parents('body').length)
+ helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
+
+ if(helper[0] != this.element[0] && !(/(fixed|absolute)/).test(helper.css("position")))
+ helper.css("position", "absolute");
+
+ return helper;
+
+ },
+
+ _adjustOffsetFromHelper: function(obj) {
+ if (typeof obj == 'string') {
+ obj = obj.split(' ');
+ }
+ if ($.isArray(obj)) {
+ obj = {left: +obj[0], top: +obj[1] || 0};
+ }
+ if ('left' in obj) {
+ this.offset.click.left = obj.left + this.margins.left;
+ }
+ if ('right' in obj) {
+ this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
+ }
+ if ('top' in obj) {
+ this.offset.click.top = obj.top + this.margins.top;
+ }
+ if ('bottom' in obj) {
+ this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
+ }
+ },
+
+ _getParentOffset: function() {
+
+ //Get the offsetParent and cache its position
+ this.offsetParent = this.helper.offsetParent();
+ var po = this.offsetParent.offset();
+
+ // This is a special case where we need to modify a offset calculated on start, since the following happened:
+ // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
+ // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
+ // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+ po.left += this.scrollParent.scrollLeft();
+ po.top += this.scrollParent.scrollTop();
+ }
+
+ if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
+ po = { top: 0, left: 0 };
+
+ return {
+ top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
+ left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
+ };
+
+ },
+
+ _getRelativeOffset: function() {
+
+ if(this.cssPosition == "relative") {
+ var p = this.element.position();
+ return {
+ top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
+ left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
+ };
+ } else {
+ return { top: 0, left: 0 };
+ }
+
+ },
+
+ _cacheMargins: function() {
+ this.margins = {
+ left: (parseInt(this.element.css("marginLeft"),10) || 0),
+ top: (parseInt(this.element.css("marginTop"),10) || 0)
+ };
+ },
+
+ _cacheHelperProportions: function() {
+ this.helperProportions = {
+ width: this.helper.outerWidth(),
+ height: this.helper.outerHeight()
+ };
+ },
+
+ _setContainment: function() {
+
+ var o = this.options;
+ if(o.containment == 'parent') o.containment = this.helper[0].parentNode;
+ if(o.containment == 'document' || o.containment == 'window') this.containment = [
+ 0 - this.offset.relative.left - this.offset.parent.left,
+ 0 - this.offset.relative.top - this.offset.parent.top,
+ $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left,
+ ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
+ ];
+
+ if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
+ var ce = $(o.containment)[0]; if(!ce) return;
+ var co = $(o.containment).offset();
+ var over = ($(ce).css("overflow") != 'hidden');
+
+ this.containment = [
+ co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
+ co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
+ co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left,
+ co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top
+ ];
+ } else if(o.containment.constructor == Array) {
+ this.containment = o.containment;
+ }
+
+ },
+
+ _convertPositionTo: function(d, pos) {
+
+ if(!pos) pos = this.position;
+ var mod = d == "absolute" ? 1 : -1;
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+
+ return {
+ top: (
+ pos.top // The absolute mouse position
+ + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border)
+ - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
+ ),
+ left: (
+ pos.left // The absolute mouse position
+ + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent
+ + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border)
+ - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
+ )
+ };
+
+ },
+
+ _generatePosition: function(event) {
+
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var pageX = event.pageX;
+ var pageY = event.pageY;
+
+ /*
+ * - Position constraining -
+ * Constrain the position to a mix of grid, containment.
+ */
+
+ if(this.originalPosition) { //If we are not dragging yet, we won't check for options
+
+ if(this.containment) {
+ if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top;
+ if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left;
+ if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top;
+ }
+
+ if(o.grid) {
+ var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
+ pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
+
+ var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
+ pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
+ }
+
+ }
+
+ return {
+ top: (
+ pageY // The absolute mouse position
+ - this.offset.click.top // Click offset (relative to the element)
+ - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.top // The offsetParent's offset without borders (offset + border)
+ + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
+ ),
+ left: (
+ pageX // The absolute mouse position
+ - this.offset.click.left // Click offset (relative to the element)
+ - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent
+ - this.offset.parent.left // The offsetParent's offset without borders (offset + border)
+ + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
+ )
+ };
+
+ },
+
+ _clear: function() {
+ this.helper.removeClass("ui-draggable-dragging");
+ if(this.helper[0] != this.element[0] && !this.cancelHelperRemoval) this.helper.remove();
+ //if($.ui.ddmanager) $.ui.ddmanager.current = null;
+ this.helper = null;
+ this.cancelHelperRemoval = false;
+ },
+
+ // From now on bulk stuff - mainly helpers
+
+ _trigger: function(type, event, ui) {
+ ui = ui || this._uiHash();
+ $.ui.plugin.call(this, type, [event, ui]);
+ if(type == "drag") this.positionAbs = this._convertPositionTo("absolute"); //The absolute position has to be recalculated after plugins
+ return $.Widget.prototype._trigger.call(this, type, event, ui);
+ },
+
+ plugins: {},
+
+ _uiHash: function(event) {
+ return {
+ helper: this.helper,
+ position: this.position,
+ originalPosition: this.originalPosition,
+ offset: this.positionAbs
+ };
+ }
+
+});
+
+$.extend($.ui.draggable, {
+ version: "1.8.6"
+});
+
+$.ui.plugin.add("draggable", "connectToSortable", {
+ start: function(event, ui) {
+
+ var inst = $(this).data("draggable"), o = inst.options,
+ uiSortable = $.extend({}, ui, { item: inst.element });
+ inst.sortables = [];
+ $(o.connectToSortable).each(function() {
+ var sortable = $.data(this, 'sortable');
+ if (sortable && !sortable.options.disabled) {
+ inst.sortables.push({
+ instance: sortable,
+ shouldRevert: sortable.options.revert
+ });
+ sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache
+ sortable._trigger("activate", event, uiSortable);
+ }
+ });
+
+ },
+ stop: function(event, ui) {
+
+ //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
+ var inst = $(this).data("draggable"),
+ uiSortable = $.extend({}, ui, { item: inst.element });
+
+ $.each(inst.sortables, function() {
+ if(this.instance.isOver) {
+
+ this.instance.isOver = 0;
+
+ inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
+ this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
+
+ //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: 'valid/invalid'
+ if(this.shouldRevert) this.instance.options.revert = true;
+
+ //Trigger the stop of the sortable
+ this.instance._mouseStop(event);
+
+ this.instance.options.helper = this.instance.options._helper;
+
+ //If the helper has been the original item, restore properties in the sortable
+ if(inst.options.helper == 'original')
+ this.instance.currentItem.css({ top: 'auto', left: 'auto' });
+
+ } else {
+ this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
+ this.instance._trigger("deactivate", event, uiSortable);
+ }
+
+ });
+
+ },
+ drag: function(event, ui) {
+
+ var inst = $(this).data("draggable"), self = this;
+
+ var checkPos = function(o) {
+ var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
+ var helperTop = this.positionAbs.top, helperLeft = this.positionAbs.left;
+ var itemHeight = o.height, itemWidth = o.width;
+ var itemTop = o.top, itemLeft = o.left;
+
+ return $.ui.isOver(helperTop + dyClick, helperLeft + dxClick, itemTop, itemLeft, itemHeight, itemWidth);
+ };
+
+ $.each(inst.sortables, function(i) {
+
+ //Copy over some variables to allow calling the sortable's native _intersectsWith
+ this.instance.positionAbs = inst.positionAbs;
+ this.instance.helperProportions = inst.helperProportions;
+ this.instance.offset.click = inst.offset.click;
+
+ if(this.instance._intersectsWith(this.instance.containerCache)) {
+
+ //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
+ if(!this.instance.isOver) {
+
+ this.instance.isOver = 1;
+ //Now we fake the start of dragging for the sortable instance,
+ //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
+ //We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
+ this.instance.currentItem = $(self).clone().appendTo(this.instance.element).data("sortable-item", true);
+ this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
+ this.instance.options.helper = function() { return ui.helper[0]; };
+
+ event.target = this.instance.currentItem[0];
+ this.instance._mouseCapture(event, true);
+ this.instance._mouseStart(event, true, true);
+
+ //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
+ this.instance.offset.click.top = inst.offset.click.top;
+ this.instance.offset.click.left = inst.offset.click.left;
+ this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
+ this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
+
+ inst._trigger("toSortable", event);
+ inst.dropped = this.instance.element; //draggable revert needs that
+ //hack so receive/update callbacks work (mostly)
+ inst.currentItem = inst.element;
+ this.instance.fromOutside = inst;
+
+ }
+
+ //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable
+ if(this.instance.currentItem) this.instance._mouseDrag(event);
+
+ } else {
+
+ //If it doesn't intersect with the sortable, and it intersected before,
+ //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
+ if(this.instance.isOver) {
+
+ this.instance.isOver = 0;
+ this.instance.cancelHelperRemoval = true;
+
+ //Prevent reverting on this forced stop
+ this.instance.options.revert = false;
+
+ // The out event needs to be triggered independently
+ this.instance._trigger('out', event, this.instance._uiHash(this.instance));
+
+ this.instance._mouseStop(event, true);
+ this.instance.options.helper = this.instance.options._helper;
+
+ //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
+ this.instance.currentItem.remove();
+ if(this.instance.placeholder) this.instance.placeholder.remove();
+
+ inst._trigger("fromSortable", event);
+ inst.dropped = false; //draggable revert needs that
+ }
+
+ };
+
+ });
+
+ }
+});
+
+$.ui.plugin.add("draggable", "cursor", {
+ start: function(event, ui) {
+ var t = $('body'), o = $(this).data('draggable').options;
+ if (t.css("cursor")) o._cursor = t.css("cursor");
+ t.css("cursor", o.cursor);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ if (o._cursor) $('body').css("cursor", o._cursor);
+ }
+});
+
+$.ui.plugin.add("draggable", "iframeFix", {
+ start: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
+ .css({
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
+ position: "absolute", opacity: "0.001", zIndex: 1000
+ })
+ .css($(this).offset())
+ .appendTo("body");
+ });
+ },
+ stop: function(event, ui) {
+ $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
+ }
+});
+
+$.ui.plugin.add("draggable", "opacity", {
+ start: function(event, ui) {
+ var t = $(ui.helper), o = $(this).data('draggable').options;
+ if(t.css("opacity")) o._opacity = t.css("opacity");
+ t.css('opacity', o.opacity);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data('draggable').options;
+ if(o._opacity) $(ui.helper).css('opacity', o._opacity);
+ }
+});
+
+$.ui.plugin.add("draggable", "scroll", {
+ start: function(event, ui) {
+ var i = $(this).data("draggable");
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') i.overflowOffset = i.scrollParent.offset();
+ },
+ drag: function(event, ui) {
+
+ var i = $(this).data("draggable"), o = i.options, scrolled = false;
+
+ if(i.scrollParent[0] != document && i.scrollParent[0].tagName != 'HTML') {
+
+ if(!o.axis || o.axis != 'x') {
+ if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
+ else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity)
+ i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
+ }
+
+ if(!o.axis || o.axis != 'y') {
+ if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
+ else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity)
+ i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
+ }
+
+ } else {
+
+ if(!o.axis || o.axis != 'x') {
+ if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ }
+
+ if(!o.axis || o.axis != 'y') {
+ if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ }
+
+ }
+
+ if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
+ $.ui.ddmanager.prepareOffsets(i, event);
+
+ }
+});
+
+$.ui.plugin.add("draggable", "snap", {
+ start: function(event, ui) {
+
+ var i = $(this).data("draggable"), o = i.options;
+ i.snapElements = [];
+
+ $(o.snap.constructor != String ? ( o.snap.items || ':data(draggable)' ) : o.snap).each(function() {
+ var $t = $(this); var $o = $t.offset();
+ if(this != i.element[0]) i.snapElements.push({
+ item: this,
+ width: $t.outerWidth(), height: $t.outerHeight(),
+ top: $o.top, left: $o.left
+ });
+ });
+
+ },
+ drag: function(event, ui) {
+
+ var inst = $(this).data("draggable"), o = inst.options;
+ var d = o.snapTolerance;
+
+ var x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
+ y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
+
+ for (var i = inst.snapElements.length - 1; i >= 0; i--){
+
+ var l = inst.snapElements[i].left, r = l + inst.snapElements[i].width,
+ t = inst.snapElements[i].top, b = t + inst.snapElements[i].height;
+
+ //Yes, I know, this is insane ;)
+ if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) {
+ if(inst.snapElements[i].snapping) (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ inst.snapElements[i].snapping = false;
+ continue;
+ }
+
+ if(o.snapMode != 'inner') {
+ var ts = Math.abs(t - y2) <= d;
+ var bs = Math.abs(b - y1) <= d;
+ var ls = Math.abs(l - x2) <= d;
+ var rs = Math.abs(r - x1) <= d;
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
+ }
+
+ var first = (ts || bs || ls || rs);
+
+ if(o.snapMode != 'outer') {
+ var ts = Math.abs(t - y1) <= d;
+ var bs = Math.abs(b - y2) <= d;
+ var ls = Math.abs(l - x1) <= d;
+ var rs = Math.abs(r - x2) <= d;
+ if(ts) ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
+ if(bs) ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
+ if(ls) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
+ if(rs) ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
+ }
+
+ if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first))
+ (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
+ inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
+
+ };
+
+ }
+});
+
+$.ui.plugin.add("draggable", "stack", {
+ start: function(event, ui) {
+
+ var o = $(this).data("draggable").options;
+
+ var group = $.makeArray($(o.stack)).sort(function(a,b) {
+ return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
+ });
+ if (!group.length) { return; }
+
+ var min = parseInt(group[0].style.zIndex) || 0;
+ $(group).each(function(i) {
+ this.style.zIndex = min + i;
+ });
+
+ this[0].style.zIndex = min + group.length;
+
+ }
+});
+
+$.ui.plugin.add("draggable", "zIndex", {
+ start: function(event, ui) {
+ var t = $(ui.helper), o = $(this).data("draggable").options;
+ if(t.css("zIndex")) o._zIndex = t.css("zIndex");
+ t.css('zIndex', o.zIndex);
+ },
+ stop: function(event, ui) {
+ var o = $(this).data("draggable").options;
+ if(o._zIndex) $(ui.helper).css('zIndex', o._zIndex);
+ }
+});
+
+})(jQuery);
+/*
+ * jQuery UI Droppable 1.8.6
+ *
+ * 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/Droppables
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.widget.js
+ * jquery.ui.mouse.js
+ * jquery.ui.draggable.js
+ */
+(function( $, undefined ) {
+
+$.widget("ui.droppable", {
+ widgetEventPrefix: "drop",
+ options: {
+ accept: '*',
+ activeClass: false,
+ addClasses: true,
+ greedy: false,
+ hoverClass: false,
+ scope: 'default',
+ tolerance: 'intersect'
+ },
+ _create: function() {
+
+ var o = this.options, accept = o.accept;
+ this.isover = 0; this.isout = 1;
+
+ this.accept = $.isFunction(accept) ? accept : function(d) {
+ return d.is(accept);
+ };
+
+ //Store the droppable's proportions
+ this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
+
+ // Add the reference and positions to the manager
+ $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
+ $.ui.ddmanager.droppables[o.scope].push(this);
+
+ (o.addClasses && this.element.addClass("ui-droppable"));
+
+ },
+
+ destroy: function() {
+ var drop = $.ui.ddmanager.droppables[this.options.scope];
+ for ( var i = 0; i < drop.length; i++ )
+ if ( drop[i] == this )
+ drop.splice(i, 1);
+
+ this.element
+ .removeClass("ui-droppable ui-droppable-disabled")
+ .removeData("droppable")
+ .unbind(".droppable");
+
+ return this;
+ },
+
+ _setOption: function(key, value) {
+
+ if(key == 'accept') {
+ this.accept = $.isFunction(value) ? value : function(d) {
+ return d.is(value);
+ };
+ }
+ $.Widget.prototype._setOption.apply(this, arguments);
+ },
+
+ _activate: function(event) {
+ var draggable = $.ui.ddmanager.current;
+ if(this.options.activeClass) this.element.addClass(this.options.activeClass);
+ (draggable && this._trigger('activate', event, this.ui(draggable)));
+ },
+
+ _deactivate: function(event) {
+ var draggable = $.ui.ddmanager.current;
+ if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
+ (draggable && this._trigger('deactivate', event, this.ui(draggable)));
+ },
+
+ _over: function(event) {
+
+ var draggable = $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
+
+ if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.hoverClass) this.element.addClass(this.options.hoverClass);
+ this._trigger('over', event, this.ui(draggable));
+ }
+
+ },
+
+ _out: function(event) {
+
+ var draggable = $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return; // Bail if draggable and droppable are same element
+
+ if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
+ this._trigger('out', event, this.ui(draggable));
+ }
+
+ },
+
+ _drop: function(event,custom) {
+
+ var draggable = custom || $.ui.ddmanager.current;
+ if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false; // Bail if draggable and droppable are same element
+
+ var childrenIntersection = false;
+ this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
+ var inst = $.data(this, 'droppable');
+ if(
+ inst.options.greedy
+ && !inst.options.disabled
+ && inst.options.scope == draggable.options.scope
+ && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
+ && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
+ ) { childrenIntersection = true; return false; }
+ });
+ if(childrenIntersection) return false;
+
+ if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ if(this.options.activeClass) this.element.removeClass(this.options.activeClass);
+ if(this.options.hoverClass) this.element.removeClass(this.options.hoverClass);
+ this._trigger('drop', event, this.ui(draggable));
+ return this.element;
+ }
+
+ return false;
+
+ },
+
+ ui: function(c) {
+ return {
+ draggable: (c.currentItem || c.element),
+ helper: c.helper,
+ position: c.position,
+ offset: c.positionAbs
+ };
+ }
+
+});
+
+$.extend($.ui.droppable, {
+ version: "1.8.6"
+});
+
+$.ui.intersect = function(draggable, droppable, toleranceMode) {
+
+ if (!droppable.offset) return false;
+
+ var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
+ y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
+ var l = droppable.offset.left, r = l + droppable.proportions.width,
+ t = droppable.offset.top, b = t + droppable.proportions.height;
+
+ switch (toleranceMode) {
+ case 'fit':
+ return (l <= x1 && x2 <= r
+ && t <= y1 && y2 <= b);
+ break;
+ case 'intersect':
+ return (l < x1 + (draggable.helperProportions.width / 2) // Right Half
+ && x2 - (draggable.helperProportions.width / 2) < r // Left Half
+ && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
+ && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
+ break;
+ case 'pointer':
+ var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
+ draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
+ isOver = $.ui.isOver(draggableTop, draggableLeft, t, l, droppable.proportions.height, droppable.proportions.width);
+ return isOver;
+ break;
+ case 'touch':
+ return (
+ (y1 >= t && y1 <= b) || // Top edge touching
+ (y2 >= t && y2 <= b) || // Bottom edge touching
+ (y1 < t && y2 > b) // Surrounded vertically
+ ) && (
+ (x1 >= l && x1 <= r) || // Left edge touching
+ (x2 >= l && x2 <= r) || // Right edge touching
+ (x1 < l && x2 > r) // Surrounded horizontally
+ );
+ break;
+ default:
+ return false;
+ break;
+ }
+
+};
+
+/*
+ This manager tracks offsets of draggables and droppables
+*/
+$.ui.ddmanager = {
+ current: null,
+ droppables: { 'default': [] },
+ prepareOffsets: function(t, event) {
+
+ var m = $.ui.ddmanager.droppables[t.options.scope] || [];
+ var type = event ? event.type : null; // workaround for #2317
+ var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
+
+ droppablesLoop: for (var i = 0; i < m.length; i++) {
+
+ if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue; //No disabled and non-accepted
+ for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item
+ m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
+
+ m[i].offset = m[i].element.offset();
+ m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
+
+ if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables
+
+ }
+
+ },
+ drop: function(draggable, event) {
+
+ var dropped = false;
+ $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
+
+ if(!this.options) return;
+ if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
+ dropped = dropped || this._drop.call(this, event);
+
+ if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
+ this.isout = 1; this.isover = 0;
+ this._deactivate.call(this, event);
+ }
+
+ });
+ return dropped;
+
+ },
+ drag: function(draggable, event) {
+
+ //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
+ if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, event);
+
+ //Run through all droppables and check their positions based on specific tolerance options
+ $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
+
+ if(this.options.disabled || this.greedyChild || !this.visible) return;
+ var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
+
+ var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
+ if(!c) return;
+
+ var parentInstance;
+ if (this.options.greedy) {
+ var parent = this.element.parents(':data(droppable):eq(0)');
+ if (parent.length) {
+ parentInstance = $.data(parent[0], 'droppable');
+ parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
+ }
+ }
+
+ // we just moved into a greedy child
+ if (parentInstance && c == 'isover') {
+ parentInstance['isover'] = 0;
+ parentInstance['isout'] = 1;
+ parentInstance._out.call(parentInstance, event);
+ }
+
+ this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
+ this[c == "isover" ? "_over" : "_out"].call(this, event);
+
+ // we just moved out of a greedy child
+ if (parentInstance && c == 'isout') {
+ parentInstance['isout'] = 0;
+ parentInstance['isover'] = 1;
+ parentInstance._over.call(parentInstance, event);
+ }
+ });
+
+ }
+};
+
+})(jQuery);
Added: sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-ui-core.js
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-ui-core.js (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/jquery-ui-core.js 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,969 @@
+/*!
+ * jQuery UI 1.8.6
+ *
+ * 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
+ */
+(function( $, undefined ) {
+
+// prevent duplicate loading
+// this is only a problem because we proxy existing functions
+// and we don't want to double proxy them
+$.ui = $.ui || {};
+if ( $.ui.version ) {
+ return;
+}
+
+$.extend( $.ui, {
+ version: "1.8.6",
+
+ keyCode: {
+ ALT: 18,
+ BACKSPACE: 8,
+ CAPS_LOCK: 20,
+ COMMA: 188,
+ COMMAND: 91,
+ COMMAND_LEFT: 91, // COMMAND
+ COMMAND_RIGHT: 93,
+ CONTROL: 17,
+ DELETE: 46,
+ DOWN: 40,
+ END: 35,
+ ENTER: 13,
+ ESCAPE: 27,
+ HOME: 36,
+ INSERT: 45,
+ LEFT: 37,
+ MENU: 93, // COMMAND_RIGHT
+ NUMPAD_ADD: 107,
+ NUMPAD_DECIMAL: 110,
+ NUMPAD_DIVIDE: 111,
+ NUMPAD_ENTER: 108,
+ NUMPAD_MULTIPLY: 106,
+ NUMPAD_SUBTRACT: 109,
+ PAGE_DOWN: 34,
+ PAGE_UP: 33,
+ PERIOD: 190,
+ RIGHT: 39,
+ SHIFT: 16,
+ SPACE: 32,
+ TAB: 9,
+ UP: 38,
+ WINDOWS: 91 // COMMAND
+ }
+});
+
+// plugins
+$.fn.extend({
+ _focus: $.fn.focus,
+ focus: function( delay, fn ) {
+ return typeof delay === "number" ?
+ this.each(function() {
+ var elem = this;
+ setTimeout(function() {
+ $( elem ).focus();
+ if ( fn ) {
+ fn.call( elem );
+ }
+ }, delay );
+ }) :
+ this._focus.apply( this, arguments );
+ },
+
+ scrollParent: function() {
+ var scrollParent;
+ if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ scrollParent = this.parents().filter(function() {
+ return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ } else {
+ scrollParent = this.parents().filter(function() {
+ return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ }).eq(0);
+ }
+
+ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
+ },
+
+ zIndex: function( zIndex ) {
+ if ( zIndex !== undefined ) {
+ return this.css( "zIndex", zIndex );
+ }
+
+ if ( this.length ) {
+ var elem = $( this[ 0 ] ), position, value;
+ while ( elem.length && elem[ 0 ] !== document ) {
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
+ // This makes behavior of this function consistent across browsers
+ // WebKit always returns auto if the element is positioned
+ position = elem.css( "position" );
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
+ // IE returns 0 when zIndex is not specified
+ // other browsers return a string
+ // we ignore the case of nested elements with an explicit value of 0
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
+ value = parseInt( elem.css( "zIndex" ), 10 );
+ if ( !isNaN( value ) && value !== 0 ) {
+ return value;
+ }
+ }
+ elem = elem.parent();
+ }
+ }
+
+ return 0;
+ },
+
+ disableSelection: function() {
+ return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
+ ".ui-disableSelection", function( event ) {
+ event.preventDefault();
+ });
+ },
+
+ enableSelection: function() {
+ return this.unbind( ".ui-disableSelection" );
+ }
+});
+
+$.each( [ "Width", "Height" ], function( i, name ) {
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
+ type = name.toLowerCase(),
+ orig = {
+ innerWidth: $.fn.innerWidth,
+ innerHeight: $.fn.innerHeight,
+ outerWidth: $.fn.outerWidth,
+ outerHeight: $.fn.outerHeight
+ };
+
+ function reduce( elem, size, border, margin ) {
+ $.each( side, function() {
+ size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
+ if ( border ) {
+ size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
+ }
+ if ( margin ) {
+ size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
+ }
+ });
+ return size;
+ }
+
+ $.fn[ "inner" + name ] = function( size ) {
+ if ( size === undefined ) {
+ return orig[ "inner" + name ].call( this );
+ }
+
+ return this.each(function() {
+ $( this ).css( type, reduce( this, size ) + "px" );
+ });
+ };
+
+ $.fn[ "outer" + name] = function( size, margin ) {
+ if ( typeof size !== "number" ) {
+ return orig[ "outer" + name ].call( this, size );
+ }
+
+ return this.each(function() {
+ $( this).css( type, reduce( this, size, true, margin ) + "px" );
+ });
+ };
+});
+
+// selectors
+function visible( element ) {
+ return !$( element ).parents().andSelf().filter(function() {
+ return $.curCSS( this, "visibility" ) === "hidden" ||
+ $.expr.filters.hidden( this );
+ }).length;
+}
+
+$.extend( $.expr[ ":" ], {
+ data: function( elem, i, match ) {
+ return !!$.data( elem, match[ 3 ] );
+ },
+
+ focusable: function( element ) {
+ var nodeName = element.nodeName.toLowerCase(),
+ tabIndex = $.attr( element, "tabindex" );
+ if ( "area" === nodeName ) {
+ var map = element.parentNode,
+ mapName = map.name,
+ img;
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
+ return false;
+ }
+ img = $( "img[usemap=#" + mapName + "]" )[0];
+ return !!img && visible( img );
+ }
+ return ( /input|select|textarea|button|object/.test( nodeName )
+ ? !element.disabled
+ : "a" == nodeName
+ ? element.href || !isNaN( tabIndex )
+ : !isNaN( tabIndex ))
+ // the element and all of its ancestors must be visible
+ && visible( element );
+ },
+
+ tabbable: function( element ) {
+ var tabIndex = $.attr( element, "tabindex" );
+ return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" );
+ }
+});
+
+// support
+$(function() {
+ var body = document.body,
+ div = body.appendChild( div = document.createElement( "div" ) );
+
+ $.extend( div.style, {
+ minHeight: "100px",
+ height: "auto",
+ padding: 0,
+ borderWidth: 0
+ });
+
+ $.support.minHeight = div.offsetHeight === 100;
+ $.support.selectstart = "onselectstart" in div;
+
+ // set display to none to avoid a layout bug in IE
+ // http://dev.jquery.com/ticket/4014
+ body.removeChild( div ).style.display = "none";
+});
+
+
+
+
+
+// deprecated
+$.extend( $.ui, {
+ // $.ui.plugin is deprecated. Use the proxy pattern instead.
+ plugin: {
+ add: function( module, option, set ) {
+ var proto = $.ui[ module ].prototype;
+ for ( var i in set ) {
+ proto.plugins[ i ] = proto.plugins[ i ] || [];
+ proto.plugins[ i ].push( [ option, set[ i ] ] );
+ }
+ },
+ call: function( instance, name, args ) {
+ var set = instance.plugins[ name ];
+ if ( !set || !instance.element[ 0 ].parentNode ) {
+ return;
+ }
+
+ for ( var i = 0; i < set.length; i++ ) {
+ if ( instance.options[ set[ i ][ 0 ] ] ) {
+ set[ i ][ 1 ].apply( instance.element, args );
+ }
+ }
+ }
+ },
+
+ // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
+ contains: function( a, b ) {
+ return document.compareDocumentPosition ?
+ a.compareDocumentPosition( b ) & 16 :
+ a !== b && a.contains( b );
+ },
+
+ // only used by resizable
+ hasScroll: function( el, a ) {
+
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
+ if ( $( el ).css( "overflow" ) === "hidden") {
+ return false;
+ }
+
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
+ has = false;
+
+ if ( el[ scroll ] > 0 ) {
+ return true;
+ }
+
+ // TODO: determine which cases actually cause this to happen
+ // if the element doesn't have the scroll set, see if it's possible to
+ // set the scroll
+ el[ scroll ] = 1;
+ has = ( el[ scroll ] > 0 );
+ el[ scroll ] = 0;
+ return has;
+ },
+
+ // these are odd functions, fix the API or move into individual plugins
+ isOverAxis: function( x, reference, size ) {
+ //Determines when x coordinate is over "b" element axis
+ return ( x > reference ) && ( x < ( reference + size ) );
+ },
+ isOver: function( y, x, top, left, height, width ) {
+ //Determines when x, y coordinates is over "b" element
+ return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
+ }
+});
+
+})( jQuery );
+/*!
+ * jQuery UI Widget 1.8.6
+ *
+ * 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/Widget
+ */
+(function( $, undefined ) {
+
+// jQuery 1.4+
+if ( $.cleanData ) {
+ var _cleanData = $.cleanData;
+ $.cleanData = function( elems ) {
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+ $( elem ).triggerHandler( "remove" );
+ }
+ _cleanData( elems );
+ };
+} else {
+ var _remove = $.fn.remove;
+ $.fn.remove = function( selector, keepData ) {
+ return this.each(function() {
+ if ( !keepData ) {
+ if ( !selector || $.filter( selector, [ this ] ).length ) {
+ $( "*", this ).add( [ this ] ).each(function() {
+ $( this ).triggerHandler( "remove" );
+ });
+ }
+ }
+ return _remove.call( $(this), selector, keepData );
+ });
+ };
+}
+
+$.widget = function( name, base, prototype ) {
+ var namespace = name.split( "." )[ 0 ],
+ fullName;
+ name = name.split( "." )[ 1 ];
+ fullName = namespace + "-" + name;
+
+ if ( !prototype ) {
+ prototype = base;
+ base = $.Widget;
+ }
+
+ // create selector for plugin
+ $.expr[ ":" ][ fullName ] = function( elem ) {
+ return !!$.data( elem, name );
+ };
+
+ $[ namespace ] = $[ namespace ] || {};
+ $[ namespace ][ name ] = function( options, element ) {
+ // allow instantiation without initializing for simple inheritance
+ if ( arguments.length ) {
+ this._createWidget( options, element );
+ }
+ };
+
+ var basePrototype = new base();
+ // we need to make the options hash a property directly on the new instance
+ // otherwise we'll modify the options hash on the prototype that we're
+ // inheriting from
+// $.each( basePrototype, function( key, val ) {
+// if ( $.isPlainObject(val) ) {
+// basePrototype[ key ] = $.extend( {}, val );
+// }
+// });
+ basePrototype.options = $.extend( true, {}, basePrototype.options );
+ $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
+ namespace: namespace,
+ widgetName: name,
+ widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
+ widgetBaseClass: fullName
+ }, prototype );
+
+ $.widget.bridge( name, $[ namespace ][ name ] );
+};
+
+$.widget.bridge = function( name, object ) {
+ $.fn[ name ] = function( options ) {
+ var isMethodCall = typeof options === "string",
+ args = Array.prototype.slice.call( arguments, 1 ),
+ returnValue = this;
+
+ // allow multiple hashes to be passed on init
+ options = !isMethodCall && args.length ?
+ $.extend.apply( null, [ true, options ].concat(args) ) :
+ options;
+
+ // prevent calls to internal methods
+ if ( isMethodCall && options.charAt( 0 ) === "_" ) {
+ return returnValue;
+ }
+
+ if ( isMethodCall ) {
+ this.each(function() {
+ var instance = $.data( this, name ),
+ methodValue = instance && $.isFunction( instance[options] ) ?
+ instance[ options ].apply( instance, args ) :
+ instance;
+ // TODO: add this back in 1.9 and use $.error() (see #5972)
+// if ( !instance ) {
+// throw "cannot call methods on " + name + " prior to initialization; " +
+// "attempted to call method '" + options + "'";
+// }
+// if ( !$.isFunction( instance[options] ) ) {
+// throw "no such method '" + options + "' for " + name + " widget instance";
+// }
+// var methodValue = instance[ options ].apply( instance, args );
+ if ( methodValue !== instance && methodValue !== undefined ) {
+ returnValue = methodValue;
+ return false;
+ }
+ });
+ } else {
+ this.each(function() {
+ var instance = $.data( this, name );
+ if ( instance ) {
+ instance.option( options || {} )._init();
+ } else {
+ $.data( this, name, new object( options, this ) );
+ }
+ });
+ }
+
+ return returnValue;
+ };
+};
+
+$.Widget = function( options, element ) {
+ // allow instantiation without initializing for simple inheritance
+ if ( arguments.length ) {
+ this._createWidget( options, element );
+ }
+};
+
+$.Widget.prototype = {
+ widgetName: "widget",
+ widgetEventPrefix: "",
+ options: {
+ disabled: false
+ },
+ _createWidget: function( options, element ) {
+ // $.widget.bridge stores the plugin instance, but we do it anyway
+ // so that it's stored even before the _create function runs
+ $.data( element, this.widgetName, this );
+ this.element = $( element );
+ this.options = $.extend( true, {},
+ this.options,
+ this._getCreateOptions(),
+ options );
+
+ var self = this;
+ this.element.bind( "remove." + this.widgetName, function() {
+ self.destroy();
+ });
+
+ this._create();
+ this._trigger( "create" );
+ this._init();
+ },
+ _getCreateOptions: function() {
+ return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
+ },
+ _create: function() {},
+ _init: function() {},
+
+ destroy: function() {
+ this.element
+ .unbind( "." + this.widgetName )
+ .removeData( this.widgetName );
+ this.widget()
+ .unbind( "." + this.widgetName )
+ .removeAttr( "aria-disabled" )
+ .removeClass(
+ this.widgetBaseClass + "-disabled " +
+ "ui-state-disabled" );
+ },
+
+ widget: function() {
+ return this.element;
+ },
+
+ option: function( key, value ) {
+ var options = key;
+
+ if ( arguments.length === 0 ) {
+ // don't return a reference to the internal hash
+ return $.extend( {}, this.options );
+ }
+
+ if (typeof key === "string" ) {
+ if ( value === undefined ) {
+ return this.options[ key ];
+ }
+ options = {};
+ options[ key ] = value;
+ }
+
+ this._setOptions( options );
+
+ return this;
+ },
+ _setOptions: function( options ) {
+ var self = this;
+ $.each( options, function( key, value ) {
+ self._setOption( key, value );
+ });
+
+ return this;
+ },
+ _setOption: function( key, value ) {
+ this.options[ key ] = value;
+
+ if ( key === "disabled" ) {
+ this.widget()
+ [ value ? "addClass" : "removeClass"](
+ this.widgetBaseClass + "-disabled" + " " +
+ "ui-state-disabled" )
+ .attr( "aria-disabled", value );
+ }
+
+ return this;
+ },
+
+ enable: function() {
+ return this._setOption( "disabled", false );
+ },
+ disable: function() {
+ return this._setOption( "disabled", true );
+ },
+
+ _trigger: function( type, event, data ) {
+ var callback = this.options[ type ];
+
+ event = $.Event( event );
+ event.type = ( type === this.widgetEventPrefix ?
+ type :
+ this.widgetEventPrefix + type ).toLowerCase();
+ data = data || {};
+
+ // copy original event properties over to the new event
+ // this would happen if we could call $.event.fix instead of $.Event
+ // but we don't have a way to force an event to be fixed multiple times
+ if ( event.originalEvent ) {
+ for ( var i = $.event.props.length, prop; i; ) {
+ prop = $.event.props[ --i ];
+ event[ prop ] = event.originalEvent[ prop ];
+ }
+ }
+
+ this.element.trigger( event, data );
+
+ return !( $.isFunction(callback) &&
+ callback.call( this.element[0], event, data ) === false ||
+ event.isDefaultPrevented() );
+ }
+};
+
+})( jQuery );
+/*!
+ * jQuery UI Mouse 1.8.6
+ *
+ * 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/Mouse
+ *
+ * Depends:
+ * jquery.ui.widget.js
+ */
+(function( $, undefined ) {
+
+$.widget("ui.mouse", {
+ options: {
+ cancel: ':input,option',
+ distance: 1,
+ delay: 0
+ },
+ _mouseInit: function() {
+ var self = this;
+
+ this.element
+ .bind('mousedown.'+this.widgetName, function(event) {
+ return self._mouseDown(event);
+ })
+ .bind('click.'+this.widgetName, function(event) {
+ if(self._preventClickEvent) {
+ self._preventClickEvent = false;
+ event.stopImmediatePropagation();
+ return false;
+ }
+ });
+
+ this.started = false;
+ },
+
+ // TODO: make sure destroying one instance of mouse doesn't mess with
+ // other instances of mouse
+ _mouseDestroy: function() {
+ this.element.unbind('.'+this.widgetName);
+ },
+
+ _mouseDown: function(event) {
+ // don't let more than one widget handle mouseStart
+ // TODO: figure out why we have to use originalEvent
+ event.originalEvent = event.originalEvent || {};
+ if (event.originalEvent.mouseHandled) { return; }
+
+ // we may have missed mouseup (out of window)
+ (this._mouseStarted && this._mouseUp(event));
+
+ this._mouseDownEvent = event;
+
+ var self = this,
+ btnIsLeft = (event.which == 1),
+ elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false);
+ if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
+ return true;
+ }
+
+ this.mouseDelayMet = !this.options.delay;
+ if (!this.mouseDelayMet) {
+ this._mouseDelayTimer = setTimeout(function() {
+ self.mouseDelayMet = true;
+ }, this.options.delay);
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted = (this._mouseStart(event) !== false);
+ if (!this._mouseStarted) {
+ event.preventDefault();
+ return true;
+ }
+ }
+
+ // these delegates are required to keep context
+ this._mouseMoveDelegate = function(event) {
+ return self._mouseMove(event);
+ };
+ this._mouseUpDelegate = function(event) {
+ return self._mouseUp(event);
+ };
+ $(document)
+ .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ event.preventDefault();
+ event.originalEvent.mouseHandled = true;
+ return true;
+ },
+
+ _mouseMove: function(event) {
+ // IE mouseup check - mouseup happened when mouse was out of window
+ if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
+ return this._mouseUp(event);
+ }
+
+ if (this._mouseStarted) {
+ this._mouseDrag(event);
+ return event.preventDefault();
+ }
+
+ if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
+ this._mouseStarted =
+ (this._mouseStart(this._mouseDownEvent, event) !== false);
+ (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
+ }
+
+ return !this._mouseStarted;
+ },
+
+ _mouseUp: function(event) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+
+ if (this._mouseStarted) {
+ this._mouseStarted = false;
+ this._preventClickEvent = (event.target == this._mouseDownEvent.target);
+ this._mouseStop(event);
+ }
+
+ return false;
+ },
+
+ _mouseDistanceMet: function(event) {
+ return (Math.max(
+ Math.abs(this._mouseDownEvent.pageX - event.pageX),
+ Math.abs(this._mouseDownEvent.pageY - event.pageY)
+ ) >= this.options.distance
+ );
+ },
+
+ _mouseDelayMet: function(event) {
+ return this.mouseDelayMet;
+ },
+
+ // These are placeholder methods, to be overriden by extending plugin
+ _mouseStart: function(event) {},
+ _mouseDrag: function(event) {},
+ _mouseStop: function(event) {},
+ _mouseCapture: function(event) { return true; }
+});
+
+})(jQuery);
+/*
+ * jQuery UI Position 1.8.6
+ *
+ * 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/Position
+ */
+(function( $, undefined ) {
+
+$.ui = $.ui || {};
+
+var horizontalPositions = /left|center|right/,
+ verticalPositions = /top|center|bottom/,
+ center = "center",
+ _position = $.fn.position,
+ _offset = $.fn.offset;
+
+$.fn.position = function( options ) {
+ if ( !options || !options.of ) {
+ return _position.apply( this, arguments );
+ }
+
+ // make a copy, we don't want to modify arguments
+ options = $.extend( {}, options );
+
+ var target = $( options.of ),
+ targetElem = target[0],
+ collision = ( options.collision || "flip" ).split( " " ),
+ offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
+ targetWidth,
+ targetHeight,
+ basePosition;
+
+ if ( targetElem.nodeType === 9 ) {
+ targetWidth = target.width();
+ targetHeight = target.height();
+ basePosition = { top: 0, left: 0 };
+ // TODO: use $.isWindow() in 1.9
+ } else if ( targetElem.setTimeout ) {
+ targetWidth = target.width();
+ targetHeight = target.height();
+ basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
+ } else if ( targetElem.preventDefault ) {
+ // force left top to allow flipping
+ options.at = "left top";
+ targetWidth = targetHeight = 0;
+ basePosition = { top: options.of.pageY, left: options.of.pageX };
+ } else {
+ targetWidth = target.outerWidth();
+ targetHeight = target.outerHeight();
+ basePosition = target.offset();
+ }
+
+ // force my and at to have valid horizontal and veritcal positions
+ // if a value is missing or invalid, it will be converted to center
+ $.each( [ "my", "at" ], function() {
+ var pos = ( options[this] || "" ).split( " " );
+ if ( pos.length === 1) {
+ pos = horizontalPositions.test( pos[0] ) ?
+ pos.concat( [center] ) :
+ verticalPositions.test( pos[0] ) ?
+ [ center ].concat( pos ) :
+ [ center, center ];
+ }
+ pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
+ pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
+ options[ this ] = pos;
+ });
+
+ // normalize collision option
+ if ( collision.length === 1 ) {
+ collision[ 1 ] = collision[ 0 ];
+ }
+
+ // normalize offset option
+ offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
+ if ( offset.length === 1 ) {
+ offset[ 1 ] = offset[ 0 ];
+ }
+ offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
+
+ if ( options.at[0] === "right" ) {
+ basePosition.left += targetWidth;
+ } else if (options.at[0] === center ) {
+ basePosition.left += targetWidth / 2;
+ }
+
+ if ( options.at[1] === "bottom" ) {
+ basePosition.top += targetHeight;
+ } else if ( options.at[1] === center ) {
+ basePosition.top += targetHeight / 2;
+ }
+
+ basePosition.left += offset[ 0 ];
+ basePosition.top += offset[ 1 ];
+
+ return this.each(function() {
+ var elem = $( this ),
+ elemWidth = elem.outerWidth(),
+ elemHeight = elem.outerHeight(),
+ marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
+ marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
+ collisionWidth = elemWidth + marginLeft +
+ parseInt( $.curCSS( this, "marginRight", true ) ) || 0,
+ collisionHeight = elemHeight + marginTop +
+ parseInt( $.curCSS( this, "marginBottom", true ) ) || 0,
+ position = $.extend( {}, basePosition ),
+ collisionPosition;
+
+ if ( options.my[0] === "right" ) {
+ position.left -= elemWidth;
+ } else if ( options.my[0] === center ) {
+ position.left -= elemWidth / 2;
+ }
+
+ if ( options.my[1] === "bottom" ) {
+ position.top -= elemHeight;
+ } else if ( options.my[1] === center ) {
+ position.top -= elemHeight / 2;
+ }
+
+ // prevent fractions (see #5280)
+ position.left = parseInt( position.left );
+ position.top = parseInt( position.top );
+
+ collisionPosition = {
+ left: position.left - marginLeft,
+ top: position.top - marginTop
+ };
+
+ $.each( [ "left", "top" ], function( i, dir ) {
+ if ( $.ui.position[ collision[i] ] ) {
+ $.ui.position[ collision[i] ][ dir ]( position, {
+ targetWidth: targetWidth,
+ targetHeight: targetHeight,
+ elemWidth: elemWidth,
+ elemHeight: elemHeight,
+ collisionPosition: collisionPosition,
+ collisionWidth: collisionWidth,
+ collisionHeight: collisionHeight,
+ offset: offset,
+ my: options.my,
+ at: options.at
+ });
+ }
+ });
+
+ if ( $.fn.bgiframe ) {
+ elem.bgiframe();
+ }
+ elem.offset( $.extend( position, { using: options.using } ) );
+ });
+};
+
+$.ui.position = {
+ fit: {
+ left: function( position, data ) {
+ var win = $( window ),
+ over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
+ position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
+ },
+ top: function( position, data ) {
+ var win = $( window ),
+ over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
+ position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
+ }
+ },
+
+ flip: {
+ left: function( position, data ) {
+ if ( data.at[0] === center ) {
+ return;
+ }
+ var win = $( window ),
+ over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
+ myOffset = data.my[ 0 ] === "left" ?
+ -data.elemWidth :
+ data.my[ 0 ] === "right" ?
+ data.elemWidth :
+ 0,
+ atOffset = data.at[ 0 ] === "left" ?
+ data.targetWidth :
+ -data.targetWidth,
+ offset = -2 * data.offset[ 0 ];
+ position.left += data.collisionPosition.left < 0 ?
+ myOffset + atOffset + offset :
+ over > 0 ?
+ myOffset + atOffset + offset :
+ 0;
+ },
+ top: function( position, data ) {
+ if ( data.at[1] === center ) {
+ return;
+ }
+ var win = $( window ),
+ over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
+ myOffset = data.my[ 1 ] === "top" ?
+ -data.elemHeight :
+ data.my[ 1 ] === "bottom" ?
+ data.elemHeight :
+ 0,
+ atOffset = data.at[ 1 ] === "top" ?
+ data.targetHeight :
+ -data.targetHeight,
+ offset = -2 * data.offset[ 1 ];
+ position.top += data.collisionPosition.top < 0 ?
+ myOffset + atOffset + offset :
+ over > 0 ?
+ myOffset + atOffset + offset :
+ 0;
+ }
+ }
+};
+
+// offset setter from jQuery 1.4
+if ( !$.offset.setOffset ) {
+ $.offset.setOffset = function( elem, options ) {
+ // set position first, in-case top/left are set even on static elem
+ if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
+ elem.style.position = "relative";
+ }
+ var curElem = $( elem ),
+ curOffset = curElem.offset(),
+ curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
+ curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
+ props = {
+ top: (options.top - curOffset.top) + curTop,
+ left: (options.left - curOffset.left) + curLeft
+ };
+
+ if ( 'using' in options ) {
+ options.using.call( elem, props );
+ } else {
+ curElem.css( props );
+ }
+ };
+
+ $.fn.offset = function( options ) {
+ var elem = this[ 0 ];
+ if ( !elem || !elem.ownerDocument ) { return null; }
+ if ( options ) {
+ return this.each(function() {
+ $.offset.setOffset( this, options );
+ });
+ }
+ return _offset.call( this );
+ };
+}
+
+}( jQuery ));
\ No newline at end of file
Added: sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js
===================================================================
--- sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js (rev 0)
+++ sandbox/trunk/ui/drag-drop/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-dnd.js 2010-11-18 14:26:51 UTC (rev 20085)
@@ -0,0 +1,140 @@
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.indicator = function(id, options) {
+ this.indicator = $(document.getElementById(id));
+ };
+
+ var defaultOptions = {
+ };
+
+ $.extend(rf.ui.indicator.prototype, ( function () {
+ return {
+ show : function() {
+ this.indicator.show();
+ },
+
+ hide: function() {
+ this.indicator.hide();
+ },
+
+ getDomElement: function() {
+ return this.indicator[0];
+ }
+ }
+ })());
+
+})(jQuery, window.RichFaces);
+
+
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.draggable = function(id, options) {
+ this.dragElement = $(document.getElementById(id));
+ this.indicator = new rf.ui.indicator(options.indicator, {});
+
+ this.options = options;
+
+ this.dragElement.draggable({addClasses: false});
+ this.dragElement.draggable("option", "helper", $.proxy(this.indicator.getDomElement, this.indicator));
+ this.dragElement.data('acceptType', this.options.acceptType);
+ this.dragElement.data('indicator', $(document.getElementById(options.indicator)));
+
+ this.dragElement.bind('dragstart', $.proxy(this.dragStart, this));
+ this.dragElement.bind('drag', $.proxy(this.drag, this));
+ this.dragElement.bind('dragstop', $.proxy(this.dragStop, this));
+ };
+
+
+ var defaultOptions = {
+ };
+
+ $.extend(rf.ui.draggable.prototype, ( function () {
+ return {
+
+ dragStart: function(e, ui) {
+ ui.helper.show();
+ },
+
+ drag: function(e, ui) {
+ ui.helper.removeClass("ui-draggable-dragging")
+ ui.helper.addClass("rf-ind-dragging");
+ },
+
+ dragStop: function(e, ui){
+ ui.helper.hide();
+ }
+ }
+ })());
+
+})(jQuery, window.RichFaces);
+
+
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.droppable = function(id, options) {
+ this.options = options;
+ this.dropElement = $(document.getElementById(id));
+ this.dropElement.droppable({addClasses: false});
+ this.dropElement.droppable("option", "hoverClass", 'rf-drop-hover');
+ this.dropElement.droppable("option", "activeClass", 'rf-drop-highlight' );
+
+ this.dropElement.bind('drop', $.proxy(this.drop, this));
+ this.dropElement.bind('dropover', $.proxy(this.dropover, this));
+ this.dropElement.bind('dropout', $.proxy(this.dropout, this));
+ };
+
+ $.extend(rf.ui.droppable.prototype, ( function () {
+ return {
+ drop: function(e, ui) {
+ var draggable = ui.draggable;
+ var indicator = draggable.data("indicator");
+ indicator.removeClass("rf-accept");
+ indicator.removeClass("rf-reject");
+ if(this.accept(draggable)) {
+ draggable.detach();
+ draggable.appendTo(this.dropElement);
+ }
+ },
+
+ dropover: function(event, ui) {
+ var draggable = ui.draggable;
+ var indicator = draggable.data("indicator");
+ if(this.accept(draggable)) {
+ indicator.removeClass("rf-reject");
+ indicator.addClass("rf-accept");
+ } else {
+ indicator.removeClass("rf-accept");
+ indicator.addClass("rf-reject");
+ }
+ },
+
+ dropout: function(event, ui) {
+ var draggable = ui.draggable;
+ var indicator = draggable.data("indicator");
+ indicator.removeClass("rf-accept");
+ indicator.removeClass("rf-reject");
+ },
+
+ accept: function(draggable) {
+ var accept;
+ var acceptType = draggable.data("acceptType");
+
+ $.each(this.options.acceptTypes, function() {
+ accept = (acceptType == this);
+ return !(accept);
+ });
+
+ return accept;
+ }
+ }
+ })());
+
+})(jQuery, window.RichFaces);
\ No newline at end of file
14 years, 1 month
JBoss Rich Faces SVN: r20084 - in trunk: ui/input/ui/src/main/java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-11-18 03:34:56 -0500 (Thu, 18 Nov 2010)
New Revision: 20084
Modified:
trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
Log:
http://jira.jboss.com/jira/browse/RF-9672
Modified: trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/examples/input-demo/src/main/webapp/examples/autocomplete.xhtml 2010-11-18 08:34:56 UTC (rev 20084)
@@ -38,7 +38,7 @@
</script>
<input:autocomplete autofill="false" id="myAutocomplete" clientFilterFunction="customFilterFunction" mode="#{autoCompleteBean.mode}" minChars="2" autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country" fetchValue="#{country.name}" showButton="true"
- value = "#{autoCompleteBean.value}"
+ value = "#{autoCompleteBean.value}" layout="list"
onchange="return onEvent.call(this, event);" onselectitem="return onEvent.call(this, event);" onblur="return onEvent.call(this, event);" onfocus="return onEvent.call(this, event);">
#{country.name} #{country.iso} #{country.domain}
<a4j:ajax event="change" render="output"/>
@@ -88,6 +88,29 @@
<a4j:log mode="inline"></a4j:log>
</div>
</h:form>
+ <h:form>
+ RF-9567:<br/><br/>
+ <a4j:outputPanel ajaxRendered="true"><h:messages /></a4j:outputPanel>
+
+
+ <input:autocomplete mode="ajax" id="autocomplete" autocompleteMethod="#{autoCompleteBean.autocomplete}" value="#{autoCompleteBean.value}">
+ <f:validateRegex pattern="Alabama" />
+ </input:autocomplete>
+
+ <a4j:commandButton render="@form" execute="autocomplete" />
+ </h:form>
+ <h:form>
+ <input:autocomplete mode="cachedAjax" tokens="," minChars="0"
+autofill="true" selectFirst="false" layout="table"
+autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country" fetchValue="#{country.name}">
+<h:column>
+#{country.name}
+</h:column>
+<h:column>
+#{country.iso}
+</h:column>
+</input:autocomplete>
+</h:form>
</ui:define>
</ui:composition>
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteDivLayoutStrategy.java 2010-11-18 08:34:56 UTC (rev 20084)
@@ -64,7 +64,7 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
encodeItemBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt rf-au-fnt rf-au-inp", null);
for (UIComponent child : component.getChildren()) {
child.encodeAll(facesContext);
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteListLayoutStrategy.java 2010-11-18 08:34:56 UTC (rev 20084)
@@ -22,7 +22,7 @@
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HtmlConstants.UL_ELEMENT, component);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, getContainerElementId(facesContext, component), null);
- responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-list-ul", null);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-lst-ul", null);
}
public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException {
@@ -43,7 +43,7 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
encodeItemBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt rf-au-fnt rf-au-inp", null);
for (UIComponent child : component.getChildren()) {
child.encodeAll(facesContext);
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-11-18 08:34:56 UTC (rev 20084)
@@ -212,7 +212,7 @@
} else {
if (item != null) {
strategy.encodeItemBegin(facesContext, comboBox);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm rf-au-opt rf-au-fnt rf-au-inp", null);
// TODO nick - use converter
String value = null;
if (comboBox.getItemConverter() != null) {
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteTableLayoutStrategy.java 2010-11-18 08:34:56 UTC (rev 20084)
@@ -25,6 +25,7 @@
ResponseWriter responseWriter = facesContext.getResponseWriter();
responseWriter.startElement(HtmlConstants.TABLE_ELEMENT, component);
responseWriter.writeAttribute(HtmlConstants.ID_ATTRIBUTE, getContainerElementId(facesContext, component), null);
+ responseWriter.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-tbl", null);
responseWriter.startElement(HtmlConstants.TBODY_ELEMENT, component);
}
@@ -37,6 +38,7 @@
public void encodeItemBegin(FacesContext facesContext, UIComponent component) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm", null);
writer.startElement(HtmlConstants.TD_ELEM, component);
}
@@ -59,10 +61,11 @@
public void encodeItem(FacesContext facesContext, UIComponent component) throws IOException {
ResponseWriter writer = facesContext.getResponseWriter();
writer.startElement(HtmlConstants.TR_ELEMENT, component);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-itm", null);
for (UIComponent child : component.getChildren()) {
if (child instanceof UIColumn) {
encodeItemChildBegin(facesContext, component);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-opt rf-au-fnt rf-au-inp", null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, "rf-au-fnt rf-au-inp", null);
child.encodeAll(facesContext);
encodeItemChildEnd(facesContext, component);
}
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.ecss 2010-11-18 08:34:56 UTC (rev 20084)
@@ -1,5 +1,4 @@
-
-.rf-au-inp.rf-au-fnt, .rf-au-opt.rf-au-fnt{
+.rf-au-fnt{
color: '#{richSkin.generalTextColor}';
font-size: '#{richSkin.generalSizeFont}';
font-family: '#{richSkin.generalFamilyFont}';
@@ -72,22 +71,28 @@
min-height: 20px;
}
-.rf-au-opt{
+.rf-au-itm{
+ cursor: default;
padding: 2px;
- white-space: nowrap;
- cursor: default;
- list-style-type: none;
}
-.rf-au-sel{
- padding: 1px;
- width: 100%;
+.rf-au-itm-sel{
background-color: '#{richSkin.headerBackgroundColor}';
border-width: 1px;
border-style: dotted;
border-color: '#{richSkin.generalTextColor}';
+ padding: 1px;
}
+.rf-au-opt{
+ white-space: nowrap;
+ list-style-type: none;
+}
+
+.rf-au-opt-sel{
+ width: 100%;
+}
+
.rf-au-shdw{
border: 0px solid red;
display: inline-block;
@@ -141,4 +146,9 @@
.rf-au-lst-ul{
margin: 0px;
padding: 0px;
+}
+
+.rf-au-tbl{
+ border-spacing: 0px;
+
}
\ No newline at end of file
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-11-18 08:29:52 UTC (rev 20083)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-11-18 08:34:56 UTC (rev 20084)
@@ -115,8 +115,10 @@
var $super = rf.ui.Autocomplete.$super;
var defaultOptions = {
- selectedItemClass:'rf-au-sel',
- itemClass:'rf-au-opt',
+ itemClass:'rf-au-itm',
+ selectedItemClass:'rf-au-itm-sel',
+ subItemClass:'rf-au-opt',
+ selectedSubItemClass:'rf-au-opt-sel',
autofill:true,
minChars:1,
selectFirst:true,
@@ -244,7 +246,10 @@
if (this.items.length==0 || (!isOffset && this.index == index)) return;
if (this.index!=-1) {
- this.items.eq(this.index).removeClass(this.options.selectedItemClass);
+ var element = this.items.eq(this.index)
+ if (element.removeClass(this.options.selectedItemClass).hasClass(this.options.subItemClass)){
+ element.removeClass(this.options.selectedSubItemClass);
+ }
}
if (index==undefined) {
@@ -268,7 +273,9 @@
this.index = index;
}
var item = this.items.eq(this.index);
- item.addClass(this.options.selectedItemClass);
+ if (item.addClass(this.options.selectedItemClass).hasClass(this.options.subItemClass)) {
+ item.addClass(this.options.selectedSubItemClass);
+ }
scrollToSelectedItem.call(this);
if (event &&
event.which != rf.KEYS.BACKSPACE &&
14 years, 1 month
JBoss Rich Faces SVN: r20083 - in trunk: examples/input-demo/src/main/java/org/richfaces/demo and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-11-18 03:29:52 -0500 (Thu, 18 Nov 2010)
New Revision: 20083
Modified:
trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
Log:
https://jira.jboss.org/browse/RF-9650
https://jira.jboss.org/browse/RF-9644
Modified: trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js
===================================================================
--- trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-11-18 07:24:59 UTC (rev 20082)
+++ trunk/core/impl/src/main/resources/META-INF/resources/jquery.position.js 2010-11-18 08:29:52 UTC (rev 20083)
@@ -5,7 +5,7 @@
*/
// draft examples of usage
-// jQuery('#tooltip').setPosition('#aaa',{from:'LB', to:'AA'});
+// jQuery('#tooltip').setPosition('#aaa',{from:'bottom-left', to:'auto-auto'});
// jQuery('#bbb').bind("click",function(e){jQuery('#tooltip').setPosition(e);});
// TODO: clear code
// TODO: optimization
@@ -81,6 +81,14 @@
var def = params.type || params.from || params.to ? $.PositionTypes[params.type || defaultType] : {noPositionType:true};
var options = $.extend({}, defaults, def, params);
+ if (!options.noPositionType) {
+ if (options.from.length>2) {
+ options.from = positionDefinition[options.from.toLowerCase()];
+ }
+ if (options.to.length>2) {
+ options.to = positionDefinition[options.to.toLowerCase()];
+ }
+ }
return this.each(function() {
element = $(this);
//alert(rect.left+" "+rect.top+" "+rect.width+" "+rect.height);
@@ -98,6 +106,17 @@
var re = /^(left|right)-(top|buttom|auto)$/i;
// TODO: make it private
+ var positionDefinition = {
+ 'top-left':'LT',
+ 'top-right':'RT',
+ 'bottom-left':'LB',
+ 'bottom-right':'RB',
+ 'top-auto':'AT',
+ 'bottom-auto':'AB',
+ 'auto-left':'LA',
+ 'auto-right':'RA',
+ 'auto-auto':'AA'
+ };
$.PositionTypes = {
// horisontal constants: L-left, R-right, C-center, A-auto
// vertical constants: T-top, B-bottom, M-middle, A-auto
@@ -147,15 +166,15 @@
offset = e.offset();
var d = rect.left - offset.left;
if (d<0) {
- rect.width = (width > rect.width) ? width : rect.width - d;
+ if (width-d > rect.width) rect.width = width - d;
} else {
- if (d + width > rect.width) rect.width = d + width;
+ rect.width += d;
}
var d = rect.top - offset.top;
if (d<0) {
- rect.height = (height > rect.height) ? height : rect.height - d;
+ if (height-d > rect.height) rect.height = height -d;
} else {
- if (d + height > rect.height) rect.height = d + height;
+ rect.height += d;
}
if (offset.left < rect.left) rect.left = offset.left;
if (offset.top < rect.top) rect.top = offset.top;
Modified: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-18 07:24:59 UTC (rev 20082)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-18 08:29:52 UTC (rev 20083)
@@ -18,6 +18,8 @@
private boolean showApply = true;
private boolean useCustomDayLabels;
private String mode = "client";
+ private String jointPoint = "auto-auto";
+ private String direction = "auto-auto";
public CalendarBean() {
@@ -92,4 +94,20 @@
this.showApply = showApply;
}
+ public void setJointPoint(String jointPoint) {
+ this.jointPoint = jointPoint;
+ }
+
+ public String getJointPoint() {
+ return jointPoint;
+ }
+
+ public void setDirection(String direction) {
+ this.direction = direction;
+ }
+
+ public String getDirection() {
+ return direction;
+ }
+
}
\ No newline at end of file
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-18 07:24:59 UTC (rev 20082)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-18 08:29:52 UTC (rev 20083)
@@ -37,14 +37,14 @@
<h:panelGrid id="panel" columns="2">
<h:panelGroup layout="block">
<calendar:calendar value="#{calendarBean.selectedDate}" id="calendar"
+ jointPoint="#{calendarBean.jointPoint}" direction="#{calendarBean.direction}"
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
dataModel="#{calendarDataModel}"
mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
- cellHeight="22px" style="width:200px">
- <f:convertDateTime pattern="#{calendarBean.pattern}"
- onchange="alert('1')" />
+ cellHeight="22px" style="width:200px" minDaysInFirstWeek="3">
+ <f:convertDateTime pattern="#{calendarBean.pattern}" />
</calendar:calendar>
</h:panelGroup>
<h:panelGrid columns="2">
@@ -82,6 +82,24 @@
<f:selectItem itemValue="ajax"/>
</h:selectOneMenu><br/>
+ <h:outputText value="Select joint point:" />
+ <h:selectOneMenu value="#{calendarBean.jointPoint}">
+ <f:ajax execute="@form" event="change" render="calendar @this" />
+ <f:selectItem itemLabel="auto-auto" itemValue="auto-auto" />
+ <f:selectItem itemLabel="top-left" itemValue="top-left" />
+ <f:selectItem itemLabel="top-right" itemValue="top-right" />
+ <f:selectItem itemLabel="bottom-left" itemValue="bottom-left" />
+ <f:selectItem itemLabel="bottom-right" itemValue="bottom-right" />
+ </h:selectOneMenu>
+ <h:outputText value="Select direction:" />
+ <h:selectOneMenu value="#{calendarBean.direction}">
+ <f:ajax execute="@form" event="change" render="calendar @this" />
+ <f:selectItem itemLabel="auto-auto" itemValue="auto-auto" />
+ <f:selectItem itemLabel="top-left" itemValue="top-left" />
+ <f:selectItem itemLabel="top-right" itemValue="top-right" />
+ <f:selectItem itemLabel="bottom-left" itemValue="bottom-left" />
+ <f:selectItem itemLabel="bottom-right" itemValue="bottom-right" />
+ </h:selectOneMenu>
</h:panelGrid>
</h:panelGrid>
</h:form>
Modified: trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-11-18 07:24:59 UTC (rev 20082)
+++ trunk/examples/output-demo/src/main/webapp/examples/tooltip.xhtml 2010-11-18 08:29:52 UTC (rev 20083)
@@ -26,7 +26,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:pn="http://richfaces.org/output">
+ xmlns:rich="http://richfaces.org/output">
<body>
<ui:composition template="/templates/template.xhtml">
@@ -39,11 +39,67 @@
<ui:define name="body_head">TOOLTIP JS Development</ui:define>
<ui:define name="body">
- <h:form id="f" style="border:blue solid thin;">
- <pn:tooltip id="tooltip">
- <!-- TODO -->
- </pn:tooltip>
- </h:form>
+ <h:panelGrid columns="2">
+ <rich:panel id="sample1" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>Here you can see <b>default client-side</b> tool-tip</p>
+ <rich:tooltip id="tt1" styleClass="tooltip">
+ <span style="white-space: nowrap"> This tool-tip content was
+ <strong>pre-rendered</strong> to the page.<br />
+ Also the tooltip following mouse by default </span>
+ </rich:tooltip>
+ </rich:panel>
+ <rich:panel id="sample2" styleClass="tooltip"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip will not <b>follow mouse</b>. Also this tool-tip
+ has a <b>delay 1.5 sec</b>, so be patient!</p>
+ <rich:tooltip followMouse="false" showDelay="1500"
+ styleClass="tooltip-custom-body">
+ <span style="white-space: nowrap"> This tool-tip content also
+ <strong>pre-rendered</strong> to the page.<br />
+ </span>
+ </rich:tooltip>
+ </rich:panel>
+ <h:form>
+ <rich:panel id="sample3" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip rendered on server <b>in separate request</b>.
+ </p>
+ <rich:tooltip mode="ajax" styleClass="tooltip" layout="block">
+ <f:facet name="defaultContent">
+ <strong>Wait...</strong>
+ </f:facet>
+ <span style="white-space: nowrap">This tool-tip content was
+ <strong>rendered on server</strong> </span>
+ <h:panelGrid columns="2">
+ <h:outputText style="white-space:nowrap"
+ value="tooltips requested" />
+ </h:panelGrid>
+ </rich:tooltip>
+ </rich:panel>
+ </h:form>
+ <h:form>
+ <rich:panel id="sample4" styleClass="tooltip-text"
+ bodyClass="rich-laguna-panel-no-header">
+ <p>This tool-tip will be <b>activated on mouse click</b>.</p>
+ <rich:tooltip showEvent="click" mode="ajax" styleClass="tooltip"
+ layout="block">
+ <f:facet name="defaultContent">
+ <strong>Wait...</strong>
+ </f:facet>
+ <span style="white-space: nowrap">This tool-tip content was
+ <strong>rendered on server</strong><br />
+ </span>
+ <h:panelGrid columns="2">
+ <h:outputText style="white-space:nowrap"
+ value="tooltips requested:" />
+ <h:outputText value="#{tooltipData.tooltipCounter}"
+ styleClass="tooltipData" />
+ </h:panelGrid>
+ </rich:tooltip>
+ </rich:panel>
+ </h:form>
+ </h:panelGrid>
</ui:define>
</ui:composition>
</body>
14 years, 1 month
JBoss Rich Faces SVN: r20082 - in modules/docs/trunk/Component_Reference/src/main/docbook/en-US: extras and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-11-18 02:24:59 -0500 (Thu, 18 Nov 2010)
New Revision: 20082
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-0.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-1.xml_sample
Removed:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items.xml_sample
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
Log:
Re-draft of rich:select based on tech review
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml 2010-11-18 02:05:03 UTC (rev 20081)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Rich_inputs.xml 2010-11-18 07:24:59 UTC (rev 20082)
@@ -822,7 +822,7 @@
<section id="sect-Component_Reference-Rich_inputs-richselect">
<title><sgmltag><rich:select></sgmltag></title>
<para>
- The <sgmltag><rich:select></sgmltag> component provides a drop-down list box for selecting a single value from multiple options. The component supports keyboard navigation and can optionally accept typed input as a combo-box.
+ The <sgmltag><rich:select></sgmltag> component provides a drop-down list box for selecting a single value from multiple options. The component supports keyboard navigation and can optionally accept typed input. The <sgmltag><rich:select></sgmltag> component functions similarly to the JavaServer Faces <sgmltag><h:selectOneMenu></sgmltag> component.
</para>
<figure id="figu-Component_Reference-richselect-richselect">
@@ -833,7 +833,7 @@
</imageobject>
<textobject>
<para>
- A <sgmltag><rich:select></sgmltag> component used as a combo-box.
+ A <sgmltag><rich:select></sgmltag> component.
</para>
</textobject>
</mediaobject>
@@ -842,28 +842,54 @@
<section id="sect-Component_Reference-richselect-Basic_usage">
<title>Basic usage</title>
<para>
- Simple usage of the <sgmltag><rich:select></sgmltag> component does not need any attributes declared, but child tags to manage the list of selections are required. An <sgmltag><f:selectItem></sgmltag> tag manages the currently selected value, while an <sgmltag><f:selectItems></sgmltag> tag points to the list of selection items.
+ Simple usage of the <sgmltag><rich:select></sgmltag> component does not need any attributes declared, but child tags to manage the list of selections are required. The child tags can either be a number of <sgmltag><f:selectItem></sgmltag> tags or a <sgmltag><f:selectItems></sgmltag> tag which points to a data model containing a list of selection items. The <varname>value</varname> attribute is used to store the current selection.
</para>
<example id="exam-Component_Reference-richselect-Selection_items">
<title>Selection items</title>
- <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richselect-Selection_items.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <variablelist>
+ <varlistentry>
+ <term>Using multiple <sgmltag><f:selectItem></sgmltag> tags</term>
+ <listitem>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richselect-Selection_items-0.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Using a single <sgmltag><f:selectItems></sgmltag> tag</term>
+ <listitem>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richselect-Selection_items-1.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</example>
<para>
- The arrow keys on a keyboard can be used to highlight different items in the list, even if the list is closed with the control still focused. If the control loses focus or the <keycap function="enter">Enter</keycap> key is pressed, the highlighted option is chosen as the value and the list is closed. Pressing the <keycap function="escape">Esc</keycap> key will close the list but not change the value.
+ The arrow keys on a keyboard can be used to highlight different items in the list. If the control loses focus or the <keycap function="enter">Enter</keycap> key is pressed, the highlighted option is chosen as the value and the list is closed. Pressing the <keycap function="escape">Esc</keycap> key will close the list but not change the value.
</para>
</section>
- <section id="sect-Component_Reference-richselect-Using_richselect_as_a_combo-box">
- <title>Using <sgmltag><rich:select></sgmltag> as a combo-box</title>
+ <section id="sect-Component_Reference-richselect-Advanced_options">
+ <title>Advanced options</title>
<para>
- Combo-boxes are drop-down lists that allow the user to type into a text field to scroll through or filter the list. By default, the <sgmltag><rich:select></sgmltag> component functions as a drop-down list. To add keyboard support to make it function like a combo-box, set <code>enableManualInput="true"</code>.
+ Use the <varname>defaultLabel</varname> attribute to set a place-holder label, such as <code>defaultLabel="select an option"</code>.
</para>
<para>
+ Server-side processing occurs in the same manner as for an <sgmltag><h:selectOneMenu></sgmltag> component. As such, custom objects used for selection items should use the same converters as for an <sgmltag><h:selectOneMenu></sgmltag> component.
+ </para>
+ </section>
+
+ <section id="sect-Component_Reference-richselect-Using_manual_input">
+ <title>Using manual input</title>
+ <para>
+ Selection lists can allow the user to type into a text field to scroll through or filter the list. By default, the <sgmltag><rich:select></sgmltag> component functions as a drop-down list with no manual input. To add keyboard support for manual input, set <code>enableManualInput="true"</code>.
+ </para>
+ <para>
Once the user begins typing, the first available matching option is highlighted. If the typed text does not match any values in the list, no value is chosen and the drop-down list displays as empty. Other keyboard interaction remains the same as the basic drop-down list.
</para>
+ <!-- TODO: not in M4 -->
+ <!--
<para>
- Typing text into a combo-box causes the list to scroll to the relevant item by default. This behavior can be changed so that the typed text filters the contents of the list instead, showing only those items that begin with the typed text. To use typed text as a filter for combo-box lists, set <code>filterOnUpdates="true"</code>.
+ Typing text into the text box causes the list to scroll to the relevant item by default. This behavior can be changed so that the typed text filters the contents of the list instead, showing only those items that begin with the typed text. To use typed text as a filter for manual-input lists, set <code>filterOnUpdates="true"</code>.
</para>
+ -->
</section>
<section id="sect-Component_Reference-richselect-Reference_data">
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2010-11-18 02:05:03 UTC (rev 20081)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2010-11-18 07:24:59 UTC (rev 20082)
@@ -1265,18 +1265,18 @@
<para>
Tables entries can be sorted by the user through either the basic method built in to the <sgmltag><rich:column></sgmltag> component, or by defining external sorting algorithms. Refer to <xref linkend="sect-Component_Reference-Tables_and_grids-richcolumn" /> for details on using the <sgmltag><rich:column></sgmltag> component in tables.
</para>
+ <note>
+ <title>Sorting non-English tables</title>
+ <para>
+ To sort a table whose contents are not in English, add the <literal>org.richfaces.datatableUsesViewLocale</literal> context parameter to the project's <filename>web.xml</filename> settings file. Set the value of the context parameter to <literal>true</literal>.
+ </para>
+ </note>
<section id="sect-Component_Reference-Tables_and_grids-Basic_sorting">
<title>Basic sorting</title>
<para>
The built-in sorting functionality of the <sgmltag><rich:column></sgmltag> component allows a user to click the header of a column to sort it in ascending or descending order.
</para>
- <note>
- <title>Sorting non-English tables</title>
- <para>
- To sort a table whose contents are not in English, add the <literal>org.richfaces.datatableUsesViewLocale</literal> context parameter to the project's <filename>web.xml</filename> settings file. Set the value of the context parameter to <literal>true</literal>.
- </para>
- </note>
<para>
Set the <varname>sortBy</varname> attribute to indicate which value to use when sorting the column. Expressions in the <varname>sortBy</varname> attribute must refer to the variable declared in the table's <varname>var</varname> attribute, which is used to fill the contents of the table.
</para>
Copied: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-0.xml_sample (from rev 20081, modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items.xml_sample)
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-0.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-0.xml_sample 2010-11-18 07:24:59 UTC (rev 20082)
@@ -0,0 +1,7 @@
+<rich:select>
+ <f:selectItem itemValue="0" itemLabel="Option 1" />
+ <f:selectItem itemValue="1" itemLabel="Option 2" />
+ <f:selectItem itemValue="2" itemLabel="Option 3" />
+ <f:selectItem itemValue="3" itemLabel="Option 4" />
+ <f:selectItem itemValue="4" itemLabel="Option 5" />
+</rich:select>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-1.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-1.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items-1.xml_sample 2010-11-18 07:24:59 UTC (rev 20082)
@@ -0,0 +1,3 @@
+<rich:select>
+ <f:selectItems value="#{bean.options}" />
+</rich:select>
Deleted: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items.xml_sample 2010-11-18 02:05:03 UTC (rev 20081)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richselect-Selection_items.xml_sample 2010-11-18 07:24:59 UTC (rev 20082)
@@ -1,4 +0,0 @@
-<rich:select>
- <f:selectItem itemLabel="constantOption" itemValue="0">
- <f:selectItems="#{bean.items}">
-</rich:select>
14 years, 1 month
JBoss Rich Faces SVN: r20081 - in sandbox/trunk/ui/fileupload/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-11-17 21:05:03 -0500 (Wed, 17 Nov 2010)
New Revision: 20081
Added:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif
Removed:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fu-uld.gif
Modified:
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml
Log:
RF-9496
Modified: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-11-17 16:58:18 UTC (rev 20080)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-11-18 02:05:03 UTC (rev 20081)
@@ -37,7 +37,7 @@
width: 34%;
}
-.rf-fu-btn {
+.rf-fu-btn-add, .rf-fu-btn-upl, .rf-fu-btn-clr {
background-color: '#{richSkin.trimColor}';
background-image: url("#{resource['org.richfaces.images:fuBtnGrad.png']}");
background-position:left top;
@@ -51,36 +51,38 @@
vertical-align: top;
}
-/*TODO Add disabled state for buttons*/
+.rf-fu-btn-upl, .rf-fu-btn-clr {
+ display: none;
+}
-.rf-fu-btn-add, .rf-fu-btn-uld, .rf-fu-btn-clr, .rf-fu-itm-lbl, .rf-fu-itm-lnk {
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-lnk {
font-family: '#{richSkin.generalFamilyFont}';
font-size: '#{richSkin.generalSizeFont}';
}
-.rf-fu-btn-add, .rf-fu-btn-uld, .rf-fu-btn-clr, .rf-fu-itm-lbl {
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl {
color: '#{richSkin.generalTextColor}';
}
-.rf-fu-btn-add, .rf-fu-btn-uld, .rf-fu-btn-clr {
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr {
background-position: 2px 2px;
background-repeat: no-repeat;
display: inline-block;
padding: 3px 5px 3px 21px;
}
-.rf-fu-btn-add {
+.rf-fu-btn-cnt-add {
background-image: url("#{resource['org.richfaces:fu-add.gif']}");
overflow: hidden;
position: relative;
}
-.rf-fu-btn-uld {
- background-image: url("#{resource['org.richfaces:fu-uld.gif']}");
+.rf-fu-btn-cnt-upl {
+ background-image: url("#{resource['org.richfaces:fu-upl.gif']}");
font-weight: bold;
}
-.rf-fu-btn-clr {
+.rf-fu-btn-cnt-clr {
background-image: url("#{resource['org.richfaces:fu-clr.gif']}");
}
Modified: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-11-17 16:58:18 UTC (rev 20080)
+++ sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-11-18 02:05:03 UTC (rev 20081)
@@ -20,54 +20,116 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
(function(richfaces, jQuery) {
+ var ITEM_STATE = {
+ NEW: {},
+ IN_PROGRESS: {},
+ DONE: {}
+ };
+
+ var ITEM_HTML = '<div class="rf-fu-itm"><span class="rf-fu-itm-lft"><span class="rf-fu-itm-lbl"/></span>'
+ + '<span class="rf-fu-itm-rgh"><a href="javascript:void(0)" class="rf-fu-itm-lnk"/></span></div>';
+
richfaces.ui = richfaces.ui || {};
richfaces.ui.FileUpload = richfaces.BaseComponent.extendClass({
name: "FileUpload",
- init: function (id) {
+ items: [],
+
+ init: function(id) {
this.id = id;
this.element = jQuery(this.attachToDom());
var header = this.element.children(".rf-fu-hdr:first");
- var buttons = header.children(".rf-fu-btns-lft:first").children(".rf-fu-btn");
- this.addButton = buttons.first();
-// this.uploadButton = buttons.last();
-// this.clearButton = header.children(".rf-fu-btns-rgh:first").children(".rf-fu-btn:first");
+ var leftButtons = header.children(".rf-fu-btns-lft:first");
+ this.addButton = leftButtons.children(".rf-fu-btn-add:first");
+ this.uploadButton = leftButtons.children(".rf-fu-btn-upl:first");
+ this.clearButton = header.children(".rf-fu-btns-rgh:first").children(".rf-fu-btn-clr:first");
this.inputContainer = this.addButton.find(".rf-fu-inp-cntr:first");
this.input = this.inputContainer.children("input");
this.list = this.element.children(".rf-fu-lst:first");
this.cleanInput = this.input.clone();
- this.addProxy = jQuery.proxy(this.__add, this)
+ this.addProxy = jQuery.proxy(this.__addItem, this);
this.input.change(this.addProxy);
+ this.clearButton.click(jQuery.proxy(this.__removeAllItems, this));
},
- __add: function () {
+ __addItem: function() {
this.input.hide();
this.input.unbind("change", this.addProxy);
- var item = new Item(this.input);
+ var item = new Item(this);
this.list.append(item.getJQuery());
+ this.items.push(item);
this.input = this.cleanInput.clone();
this.inputContainer.append(this.input);
this.input.change(this.addProxy);
+ this.__updateButtons();
+ },
+
+ __removeItem: function(item) {
+ item.input.remove();
+ item.element.remove();
+ this.items.splice(this.items.indexOf(item), 1);
+ this.__updateButtons();
+ },
+
+ __removeAllItems: function(item) {
+ this.inputContainer.children(":not(:visible)").remove();
+ this.list.empty();
+ this.items.splice(0);
+ this.__updateButtons();
+ },
+
+ __updateButtons: function() {
+ if (this.items.length) {
+ var hide = true;
+ for ( var i = 0; i < this.items.length && hide; i++) {
+ if (this.items[i].state == ITEM_STATE.NEW) {
+ this.uploadButton.css("display", "inline-block");
+ hide = false;
+ }
+ }
+ if (hide) {
+ this.uploadButton.hide();
+ }
+ this.clearButton.css("display", "inline-block");
+ } else {
+ this.uploadButton.hide();
+ this.clearButton.hide();
+ }
+ },
+
+ __getLinkText: function(state) {
+ var text = "";
+ if (state == ITEM_STATE.NEW) {
+ text = "Delete";
+ } else if (state == ITEM_STATE.DONE) {
+ text = "Clear";
+ }
+ return text;
}
});
- var ITEM_HTML = '<div class="rf-fu-itm"><span class="rf-fu-itm-lft"><span class="rf-fu-itm-lbl"/></span>'
- + '<span class="rf-fu-itm-rgh"><a href="javascript:void(0)" class="rf-fu-itm-lnk"/></span></div>';
-
- var Item = function(input) {
- this.input = input;
+ var Item = function(fileUpload) {
+ this.fileUpload = fileUpload;
};
jQuery.extend(Item.prototype, {
getJQuery: function() {
+ this.state = ITEM_STATE.NEW;
+ this.input = this.fileUpload.input;
this.element = jQuery(ITEM_HTML);
this.label = this.element.children(".rf-fu-itm-lft:first").children(".rf-fu-itm-lbl:first");
this.link = this.element.children(".rf-fu-itm-rgh:first").children("a");
- this.label.append(this.input.val());
- this.link.append("Delete");
+ this.label.html(this.input.val());
+ this.link.html(this.fileUpload.__getLinkText(this.state));
+
+ this.link.click(jQuery.proxy(this.remove, this));
return this.element;
- }
+ },
+
+ remove: function() {
+ this.fileUpload.__removeItem(this);
+ }
});
}(window.RichFaces, jQuery));
Deleted: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fu-uld.gif
===================================================================
(Binary files differ)
Copied: sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif (from rev 20072, sandbox/trunk/ui/fileupload/ui/src/main/resources/META-INF/resources/org.richfaces/fu-uld.gif)
===================================================================
(Binary files differ)
Modified: sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml
===================================================================
--- sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml 2010-11-17 16:58:18 UTC (rev 20080)
+++ sandbox/trunk/ui/fileupload/ui/src/main/templates/fileupload.template.xml 2010-11-18 02:05:03 UTC (rev 20081)
@@ -39,21 +39,21 @@
<div id="#{clientId}" class="rf-fu">
<div class="rf-fu-hdr">
<span class="rf-fu-btns-lft">
- <span class="rf-fu-btn">
- <span class="rf-fu-btn-add">
+ <span class="rf-fu-btn-add">
+ <span class="rf-fu-btn-cnt-add">
<span class="rf-fu-inp-cntr"> <!-- This span is needed for IE7 only. -->
<input type="file" class="rf-fu-inp" />
</span>
Add...
</span>
</span>
- <span class="rf-fu-btn">
- <span class="rf-fu-btn-uld">Upload</span>
+ <span class="rf-fu-btn-upl">
+ <span class="rf-fu-btn-cnt-upl">Upload</span>
</span>
</span>
<span class="rf-fu-btns-rgh">
- <span class="rf-fu-btn">
- <span class="rf-fu-btn-clr">Clear All</span>
+ <span class="rf-fu-btn-clr">
+ <span class="rf-fu-btn-cnt-clr">Clear All</span>
</span>
</span>
</div>
14 years, 1 month
JBoss Rich Faces SVN: r20080 - in trunk/examples/input-demo/src/main: webapp/examples and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-17 11:58:18 -0500 (Wed, 17 Nov 2010)
New Revision: 20080
Added:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
Modified:
trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
Log:
RF-9683 Calendar component: data model support, RF-9684 Calendar component: AJAX scrolling. Demo is updated.
Modified: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-17 16:53:40 UTC (rev 20079)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarBean.java 2010-11-17 16:58:18 UTC (rev 20080)
@@ -4,11 +4,11 @@
import java.util.Locale;
import javax.faces.bean.ManagedBean;
-import javax.faces.bean.RequestScoped;
+import javax.faces.bean.SessionScoped;
import javax.faces.event.ValueChangeEvent;
@ManagedBean
-@RequestScoped
+@SessionScoped
public class CalendarBean {
private Locale locale;
@@ -17,6 +17,7 @@
private Date selectedDate;
private boolean showApply = true;
private boolean useCustomDayLabels;
+ private String mode = "client";
public CalendarBean() {
@@ -25,6 +26,14 @@
pattern = "d/M/yy HH:mm";
}
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
public Locale getLocale() {
return locale;
}
Added: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelImpl.java 2010-11-17 16:58:18 UTC (rev 20080)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.demo;
+
+import java.util.Date;
+import java.util.Random;
+
+import javax.faces.bean.ApplicationScoped;
+import javax.faces.bean.ManagedBean;
+
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 30.06.2007
+ *
+ */
+@ManagedBean(name="calendarDataModel")
+@ApplicationScoped
+public class CalendarDataModelImpl implements CalendarDataModel {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModel#getData(java.util.Date[])
+ */
+ public CalendarDataModelItem[] getData(Date[] dateArray) {
+ if (dateArray == null) {
+ return null;
+ }
+
+ CalendarDataModelItem[] items = new CalendarDataModelItem[dateArray.length];
+ for (int i = 0; i < dateArray.length; i++) {
+ items[i] = createDataModelItem(dateArray[i]);
+ }
+
+ return items;
+ }
+
+ protected CalendarDataModelItem createDataModelItem(Date date) {
+ CalendarDataModelItemImpl item = new CalendarDataModelItemImpl();
+
+ if (new Random().nextInt(10) > 5) {
+ item.setEnabled(true);
+
+ } else {
+ item.setEnabled(false);
+ }
+
+ return item;
+ }
+}
Added: trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java
===================================================================
--- trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java (rev 0)
+++ trunk/examples/input-demo/src/main/java/org/richfaces/demo/CalendarDataModelItemImpl.java 2010-11-17 16:58:18 UTC (rev 20080)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * 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.demo;
+
+import org.richfaces.model.CalendarDataModelItem;
+
+/**
+ * @author Nick Belaevski - mailto:nbelaevski@exadel.com
+ * created 04.07.2007
+ *
+ */
+public class CalendarDataModelItemImpl implements CalendarDataModelItem {
+
+ private boolean enabled = true;
+ private String styleClass = "";
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.component.CalendarDataModelItem#isEnabled()
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+ public void setStyleClass(String styleClass) {
+ this.styleClass = styleClass;
+ }
+}
Modified: trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-17 16:53:40 UTC (rev 20079)
+++ trunk/examples/input-demo/src/main/webapp/examples/calendar.xhtml 2010-11-17 16:58:18 UTC (rev 20080)
@@ -39,6 +39,8 @@
<calendar:calendar value="#{calendarBean.selectedDate}" id="calendar"
locale="#{calendarBean.locale}" popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
+ dataModel="#{calendarDataModel}"
+ mode="#{calendarBean.mode}"
showApplyButton="#{calendarBean.showApply}" cellWidth="24px"
cellHeight="22px" style="width:200px">
<f:convertDateTime pattern="#{calendarBean.pattern}"
@@ -73,6 +75,13 @@
<f:selectItem itemLabel="d/MMM/y" itemValue="d/MMM/y" />
<f:selectItem itemLabel="MMM d, yyyy" itemValue="MMM d, yyyy" />
</h:selectOneMenu>
+
+ <h:outputText value="Mode" />
+ <h:selectOneMenu value="#{calendarBean.mode}" onchange="submit()">
+ <f:selectItem itemValue="client"/>
+ <f:selectItem itemValue="ajax"/>
+ </h:selectOneMenu><br/>
+
</h:panelGrid>
</h:panelGrid>
</h:form>
14 years, 1 month
JBoss Rich Faces SVN: r20079 - in trunk/ui/input/ui/src/main: java/org/richfaces/component and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-11-17 11:53:40 -0500 (Wed, 17 Nov 2010)
New Revision: 20079
Added:
trunk/ui/input/ui/src/main/java/org/richfaces/model/
trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
Log:
RF-9683 Calendar component: data model support, RF-9684 Calendar component: AJAX scrolling
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-17 16:48:10 UTC (rev 20078)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractCalendar.java 2010-11-17 16:53:40 UTC (rev 20079)
@@ -22,16 +22,24 @@
package org.richfaces.component;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.visit.VisitCallback;
+import javax.faces.component.visit.VisitContext;
+import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.convert.DateTimeConverter;
import javax.faces.event.AbortProcessingException;
@@ -43,22 +51,28 @@
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.context.ExtendedVisitContext;
+import org.richfaces.context.ExtendedVisitContextMode;
+import org.richfaces.event.CurrentDateChangeEvent;
+import org.richfaces.event.CurrentDateChangeListener;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
+import org.richfaces.model.CalendarDataModel;
+import org.richfaces.model.CalendarDataModelItem;
+import org.richfaces.renderkit.MetaComponentRenderer;
import org.richfaces.utils.CalendarHelper;
-import org.richfaces.event.CurrentDateChangeEvent;
-import org.richfaces.event.CurrentDateChangeListener;
-
/**
* @author amarkhel
*
*/
@JsfComponent(type = AbstractCalendar.COMPONENT_TYPE, family = AbstractCalendar.COMPONENT_FAMILY, generate = "org.richfaces.component.UICalendar", renderer = @JsfRenderer(type = "org.richfaces.CalendarRenderer"), tag = @Tag(name = "calendar"))
-public abstract class AbstractCalendar extends UIInput {
+public abstract class AbstractCalendar extends UIInput implements MetaComponentResolver, MetaComponentEncoder {
+ public static final String DAYSDATA_META_COMPONENT_ID = "daysData";
+
public static final String COMPONENT_TYPE = "org.richfaces.Calendar";
public static final String COMPONENT_FAMILY = "org.richfaces.Calendar";
@@ -75,7 +89,12 @@
locale
};
+ public enum Modes {
+ CLIENT,
+ AJAX
+ }
+
@Attribute(defaultValue = "MMM d, yyyy")
public abstract String getDatePattern();
@@ -144,6 +163,9 @@
@Attribute(defaultValue = "3")
public abstract int getZindex();
+
+ @Attribute(defaultValue = "client")
+ public abstract String getMode();
@Attribute
public abstract String getStyle();
@@ -184,6 +206,7 @@
@Attribute
public abstract Object getCurrentDate();
+ @Attribute
public abstract void setCurrentDate(Object date);
@Attribute
@@ -194,6 +217,19 @@
@Attribute
public abstract Object getDefaultTime();
+
+ @Attribute(defaultValue = "getDefaultPreloadBegin(getCurrentDateOrDefault())")
+ public abstract Object getPreloadDateRangeBegin();
+
+ public abstract void setPreloadDateRangeBegin(Object date);
+
+ @Attribute(defaultValue = "getDefaultPreloadEnd(getCurrentDateOrDefault())")
+ public abstract Object getPreloadDateRangeEnd();
+
+ public abstract void setPreloadDateRangeEnd(Object date);
+
+ @Attribute
+ public abstract CalendarDataModel getDataModel();
@Attribute(events = @EventName("inputclick"))
public abstract String getOninputclick();
@@ -306,7 +342,46 @@
public CurrentDateChangeListener[] getCurrentDateChangeListeners() {
return (CurrentDateChangeListener[]) getFacesListeners(CurrentDateChangeListener.class);
}
+
+ protected Date getDefaultPreloadBegin(Date date) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Calendar calendar = Calendar.getInstance(getTimeZone(),
+ CalendarHelper.getAsLocale(facesContext, this, getLocale()));
+ calendar.setTime(date);
+ calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
+ return calendar.getTime();
+ }
+ protected Date getDefaultPreloadEnd(Date date) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Calendar calendar = Calendar.getInstance(getTimeZone(),
+ CalendarHelper.getAsLocale(facesContext, this, getLocale()));
+ calendar.setTime(date);
+ calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
+ /*
+ * //force recalculation calendar.getTimeInMillis();
+ * calendar.set(Calendar.DAY_OF_WEEK, getLastDayOfWeek(calendar));
+ */
+ return calendar.getTime();
+ }
+
+ public Date getCurrentDateOrDefault() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ Date date = CalendarHelper.getAsDate(facesContext, this, getCurrentDate());
+
+ if (date != null) {
+ return date;
+ } else {
+ Date value = CalendarHelper.getAsDate(facesContext, this, this.getValue());
+ if (value != null) {
+ return value;
+ } else {
+ return java.util.Calendar.getInstance(getTimeZone()).getTime();
+ }
+ }
+ }
+
public void broadcast(FacesEvent event) throws AbortProcessingException {
if (event instanceof CurrentDateChangeEvent) {
FacesContext facesContext = getFacesContext();
@@ -348,4 +423,110 @@
event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
}
}
+
+ public String resolveClientId(FacesContext facesContext, UIComponent contextComponent, String metaComponentId) {
+ if (DAYSDATA_META_COMPONENT_ID.equals(metaComponentId)) {
+ return getClientId(facesContext) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR + metaComponentId;
+ }
+ return null;
+ }
+
+ public String substituteUnresolvedClientId(FacesContext facesContext, UIComponent contextComponent,
+ String metaComponentId) {
+ return null;
+ }
+
+ @Override
+ public boolean visitTree(VisitContext context, VisitCallback callback) {
+ if (context instanceof ExtendedVisitContext) {
+ ExtendedVisitContext extendedVisitContext = (ExtendedVisitContext) context;
+ if (extendedVisitContext.getVisitMode() == ExtendedVisitContextMode.RENDER) {
+
+ VisitResult result = extendedVisitContext.invokeMetaComponentVisitCallback(this, callback,
+ DAYSDATA_META_COMPONENT_ID);
+ if (result == VisitResult.COMPLETE) {
+ return true;
+ } else if (result == VisitResult.REJECT) {
+ return false;
+ }
+ }
+ }
+
+ return super.visitTree(context, callback);
+ }
+
+ public void encodeMetaComponent(FacesContext context, String metaComponentId) throws IOException {
+ ((MetaComponentRenderer) getRenderer(context)).encodeMetaComponent(context, this, metaComponentId);
+ }
+
+ public Object getPreload() {
+ Date[] preloadDateRange = getPreloadDateRange();
+ if (preloadDateRange != null && preloadDateRange.length != 0) {
+ CalendarDataModel calendarDataModel = (CalendarDataModel) getDataModel();
+ if (calendarDataModel != null) {
+ CalendarDataModelItem[] calendarDataModelItems = calendarDataModel
+ .getData(preloadDateRange);
+
+ HashMap<String, Object> args = new HashMap<String, Object>();
+
+ args.put("startDate", formatStartDate(preloadDateRange[0]));
+ args.put("days", calendarDataModelItems);
+ return args;
+ }
+ }
+ return null;
+ }
+
+ public static Object formatStartDate(Date date) {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ HashMap <String, Object> hashDate = new HashMap<String,Object>();
+ hashDate.put("month", calendar.get(Calendar.MONTH));
+ hashDate.put("year", calendar.get(Calendar.YEAR));
+ return hashDate;
+ }
+
+ public Date[] getPreloadDateRange() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+
+ Date dateRangeBegin = null;
+ Date dateRangeEnd = null;
+
+ if (Modes.AJAX.toString().equalsIgnoreCase(getMode())) {
+ dateRangeBegin = CalendarHelper.getAsDate(facesContext, this,
+ getDefaultPreloadBegin((Date) getCurrentDate()));
+ dateRangeEnd = CalendarHelper.getAsDate(facesContext, this,
+ getDefaultPreloadEnd((Date) getCurrentDate()));
+ } else {
+ dateRangeBegin = CalendarHelper.getAsDate(facesContext, this, getPreloadDateRangeBegin());
+ dateRangeEnd = CalendarHelper.getAsDate(facesContext, this, getPreloadDateRangeEnd());
+ }
+
+ if (dateRangeBegin == null && dateRangeEnd == null) {
+ return null;
+ } else {
+ if (dateRangeBegin.after(dateRangeEnd)) {
+ // XXX add message
+ FacesMessage message = new FacesMessage(
+ "preloadDateRangeBegin is greater than preloadDateRangeEnd");
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ facesContext.addMessage(getClientId(facesContext), message);
+ throw new IllegalArgumentException();
+ }
+
+ List<Date> dates = new ArrayList<Date>();
+
+ Calendar calendar = Calendar.getInstance(this.getTimeZone(), CalendarHelper.getAsLocale(facesContext, this, this.getLocale()));
+ Calendar calendar2 = (Calendar) calendar.clone();
+ calendar.setTime(dateRangeBegin);
+ calendar2.setTime(dateRangeEnd);
+
+ do {
+ dates.add(calendar.getTime());
+ calendar.add(Calendar.DATE, 1);
+ } while (!calendar.after(calendar2));
+
+ return (Date[]) dates.toArray(new Date[dates.size()]);
+ }
+ }
}
Added: trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModel.java 2010-11-17 16:53:40 UTC (rev 20079)
@@ -0,0 +1,40 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.model;
+
+import java.util.Date;
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+public interface CalendarDataModel {
+ /**
+ * @return array of CalendarDataModelItems for selected dates.
+ * This method will be called every time when components will need next
+ * block of CalendarDataItems.
+ * That may happens when calendar rendered, or when user navigate to
+ * next(previous) month or in any other case when calendar renders.
+ * This method will be called in Ajax mode when Calendar renders new page.
+ * */
+ CalendarDataModelItem[] getData(Date[] dateArray);
+
+}
Added: trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java (rev 0)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2010-11-17 16:53:40 UTC (rev 20079)
@@ -0,0 +1,47 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - 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.model;
+
+
+
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+
+public interface CalendarDataModelItem {
+ /**
+ *@return true if date is �selectable� on calendar, default
+ *implementation return true
+ **/
+ boolean isEnabled();
+
+ /**
+ * @return String that will be appended to style class for that date span.
+ * For example it may be �relevant holyday� � that mean class will be like �rich-cal-day relevant holyday�.
+ * Default implementation return empty string.
+ * */
+ public String getStyleClass();
+}
+
+
+
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-17 16:48:10 UTC (rev 20078)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/CalendarRendererBase.java 2010-11-17 16:53:40 UTC (rev 20079)
@@ -40,14 +40,17 @@
import javax.faces.application.ResourceDependency;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.context.PartialViewContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.convert.DateTimeConverter;
+import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.component.AbstractCalendar;
+import org.richfaces.component.MetaComponentResolver;
import org.richfaces.component.util.HtmlUtil;
import org.richfaces.component.util.MessageUtil;
import org.richfaces.component.util.SelectUtils;
@@ -73,7 +76,7 @@
@ResourceDependency(library = "org.richfaces", name = "calendar-utils.js"),
@ResourceDependency(library = "org.richfaces", name = "calendar.js"),
@ResourceDependency(library = "org.richfaces", name = "calendar.ecss") })
-public class CalendarRendererBase extends InputRendererBase {
+public class CalendarRendererBase extends InputRendererBase implements MetaComponentRenderer {
public static final String CALENDAR_BUNDLE = "org.richfaces.renderkit.calendar";
@@ -146,9 +149,8 @@
public static final String CALENDAR_DISABLE_ICON_RESOURCE_NAME = "disabledCalendarIcon.png";
public static final String CURRENT_DATE_INPUT = "InputCurrentDate";
-
-
+ public static final String OPTION_MODE = "mode";
protected static final Map<String, ComponentAttribute> CALENDAR_INPUT_HANDLER_ATTRIBUTES = Collections.unmodifiableMap(ComponentAttribute.createMap(
@@ -200,7 +202,7 @@
private static final String MINUTES_VALUE = "minutes";
protected void doDecode(FacesContext context, UIComponent component) {
- if(!(component instanceof AbstractCalendar)) {
+ if (!(component instanceof AbstractCalendar)) {
return;
}
@@ -221,6 +223,15 @@
if (selectedDateString != null) {
calendar.setSubmittedValue(selectedDateString);
}
+
+ if (requestParameterMap.get(component.getClientId(context) + ".ajax") != null) {
+ PartialViewContext pvc = context.getPartialViewContext();
+ pvc.getRenderIds().add(
+ component.getClientId(context) + MetaComponentResolver.META_COMPONENT_SEPARATOR_CHAR
+ + AbstractCalendar.DAYSDATA_META_COMPONENT_ID);
+
+ context.renderResponse();
+ }
}
public void renderInputHandlers(FacesContext facesContext, UIComponent component) throws IOException {
@@ -256,7 +267,7 @@
@Override
public String getInputValue(FacesContext facesContext, UIComponent component) {
- if(!(component instanceof AbstractCalendar)) {
+ if (!(component instanceof AbstractCalendar)) {
return null;
}
@@ -290,11 +301,11 @@
public String getButtonIcon(FacesContext facesContext, UIComponent component) {
boolean disable = (Boolean)component.getAttributes().get("disabled");
String buttonIcon = (String)component.getAttributes().get("buttonIcon");
- if(disable) {
+ if (disable) {
buttonIcon = (String)component.getAttributes().get("buttonIconDisabled");
}
- if(buttonIcon != null && buttonIcon.trim().length() != 0) {
+ if (buttonIcon != null && buttonIcon.trim().length() != 0) {
buttonIcon = ViewUtil.getResourceURL(buttonIcon, facesContext);
} else {
buttonIcon = disable ? CALENDAR_ICON_RESOURCE_NAME: CALENDAR_ICON_RESOURCE_NAME;
@@ -307,11 +318,11 @@
public Object getSelectedDate(FacesContext facesContext, UIComponent component) throws IOException {
Object returnValue = null;
AbstractCalendar calendar = (AbstractCalendar)component;
- if(calendar.isValid()) {
+ if (calendar.isValid()) {
Date date;
Object value = calendar.getValue();
date = CalendarHelper.getAsDate(facesContext, calendar, value);
- if(date != null) {
+ if (date != null) {
returnValue = formatSelectedDate(calendar.getTimeZone(), date);
}
}
@@ -382,7 +393,6 @@
return ((dayStyleClass != null && dayStyleClass.trim().length() != 0)) ? new JSReference(dayStyleClass) : null;
}
-
public Map<String, Object> getLabels(FacesContext facesContext, AbstractCalendar calendar) {
ResourceBundle bundle1 = null;
ResourceBundle bundle2 = null;
@@ -409,11 +419,11 @@
protected Map<String, Object> getCollectedLabels(ResourceBundle [] bundles , String[] names) {
Map<String, Object> labels = new HashMap<String, Object>();
- if(bundles != null && names != null) {
+ if (bundles != null && names != null) {
for (String name: names) {
String label = null;
String bundleKey = "RICH_CALENDAR_" + name.toUpperCase() + "_LABEL";
- for(ResourceBundle bundle: bundles) {
+ for (ResourceBundle bundle: bundles) {
if (bundle != null) {
try {
label = bundle.getString(bundleKey);
@@ -421,7 +431,7 @@
// Current key was not found, ignore this exception;
}
}
- if(label != null) {
+ if (label != null) {
break;
}
}
@@ -478,36 +488,35 @@
int monthMin = calendar.getActualMinimum(Calendar.MONTH);
String [] weekDayLabels = RenderKitUtils.asArray(calendarComponent.getWeekDayLabels());
- if(weekDayLabels == null) {
+ if (weekDayLabels == null) {
weekDayLabels = dateFormat.getWeekdays();
weekDayLabels = shiftDates(minimum, maximum, weekDayLabels);
}
RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS, weekDayLabels);
String [] weekDayLabelsShort = RenderKitUtils.asArray(calendarComponent.getWeekDayLabelsShort());
- if(weekDayLabelsShort == null) {
+ if (weekDayLabelsShort == null) {
weekDayLabelsShort = dateFormat.getShortWeekdays();
weekDayLabelsShort = shiftDates(minimum, maximum, weekDayLabelsShort);
}
RenderKitUtils.addToScriptHash(map, WEEK_DAY_LABELS_SHORT, weekDayLabelsShort);
String [] monthLabels = RenderKitUtils.asArray(calendarComponent.getMonthLabels());
- if(monthLabels == null) {
+ if (monthLabels == null) {
monthLabels = dateFormat.getMonths();
monthLabels = shiftDates(monthMin, monthMax, monthLabels);
}
RenderKitUtils.addToScriptHash(map, MONTH_LABELS, monthLabels);
-
String [] monthLabelsShort = RenderKitUtils.asArray(calendarComponent.getMonthLabelsShort());
- if(monthLabelsShort == null) {
+ if (monthLabelsShort == null) {
monthLabelsShort = dateFormat.getShortMonths();
monthLabelsShort = shiftDates(monthMin, monthMax, monthLabelsShort);
}
RenderKitUtils.addToScriptHash(map, MONTH_LABELS_SHORT, monthLabelsShort);
int minDaysInFirstWeek = calendarComponent.getMinDaysInFirstWeek();
- if(minDaysInFirstWeek == Integer.MIN_VALUE) {
+ if (minDaysInFirstWeek == Integer.MIN_VALUE) {
minDaysInFirstWeek = calendar.getMinimalDaysInFirstWeek();
}
@@ -516,7 +525,7 @@
}
int day = calendarComponent.getFirstWeekDay();
- if(day == Integer.MIN_VALUE) {
+ if (day == Integer.MIN_VALUE) {
day = calendar.getFirstDayOfWeek();
day = calendar.getFirstDayOfWeek() - calendar.getActualMinimum(Calendar.DAY_OF_WEEK);
}
@@ -526,7 +535,6 @@
} else if (day != Integer.MIN_VALUE) {
facesContext.getExternalContext().log(day + " value of firstWeekDay attribute is not a legal one for component: " + MessageUtil.getLabel(facesContext, calendarComponent) + ". Default value was applied.");
}
-
return map;
}
@@ -538,7 +546,7 @@
scriptOptions.addOption(OPTION_READONLY);
scriptOptions.addOption(OPTION_RESET_TIME_ON_DATE_SELECT);
scriptOptions.addOption(OPTION_SHOW_APPLY_BUTTON);
- scriptOptions.addOption(OPTION_POPUP);
+ scriptOptions.addOption(OPTION_POPUP);
scriptOptions.addOption(OPTION_SHOW_INPUT);
scriptOptions.addOption(OPTION_SHOW_HEADER);
scriptOptions.addOption(OPTION_SHOW_FOOTER);
@@ -565,12 +573,13 @@
scriptOptions.addOption("styleClass");
scriptOptions.addOption("style", HtmlUtil.concatStyles("z-index: " + calendar.getZindex(), calendar.getStyle()));
+ scriptOptions.addOption(OPTION_MODE, calendar.getMode());
return scriptOptions;
}
public void buildAddLocaleScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
- if(component instanceof AbstractCalendar) {
+ if (component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
JSFunction function = new JSFunction("RichFaces.ui.Calendar.addLocale", CalendarHelper.getAsLocale(facesContext, calendar).toString(), getLocaleOptions(facesContext, calendar));
writer.write(function.toScript());
@@ -579,12 +588,18 @@
}
public void buildCalendarScript(ResponseWriter writer, FacesContext facesContext, UIComponent component) throws IOException {
- if(component instanceof AbstractCalendar) {
+ if (component instanceof AbstractCalendar) {
AbstractCalendar calendar = (AbstractCalendar)component;
ScriptOptions scriptOptions = createCalendarScriptOption(facesContext, calendar);
JSFunction function = new JSFunction("new RichFaces.ui.Calendar", calendar.getClientId(facesContext), CalendarHelper.getAsLocale(facesContext, calendar).toString(), scriptOptions, "");
StringBuffer scriptBuffer = new StringBuffer();
- scriptBuffer.append(function.toScript()).append(".load();");
+ scriptBuffer.append(function.toScript()).append(".load(");
+ Object preload = calendar.getPreload();
+ if (null != preload){
+ scriptBuffer.append(RenderKitUtils.toScriptArgs(preload));
+ }
+
+ scriptBuffer.append(");");
writer.write(scriptBuffer.toString());
}
}
@@ -599,11 +614,11 @@
}
protected Converter setupConverter(FacesContext facesContext, Converter converter, AbstractCalendar calendar) {
- if(converter == null || calendar == null) {
+ if (converter == null || calendar == null) {
return null;
}
- if(converter instanceof DateTimeConverter) {
+ if (converter instanceof DateTimeConverter) {
DateTimeConverter defaultConverter = (DateTimeConverter) converter;
defaultConverter.setPattern(calendar.getDatePattern());
defaultConverter.setLocale( CalendarHelper.getAsLocale(facesContext, calendar));
@@ -611,5 +626,21 @@
}
return converter;
}
+
+ public void encodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId)
+ throws IOException {
+ if (AbstractCalendar.DAYSDATA_META_COMPONENT_ID.equals(metaComponentId)) {
+ Object preload = ((AbstractCalendar) component).getPreload();
+ if (preload != null) {
+ Map<String, Object> dataMap = AjaxContext.getCurrentInstance(context).getResponseComponentDataMap();
+ dataMap.put(component.getClientId(context), preload);
+ }
+ } else {
+ throw new IllegalArgumentException(metaComponentId);
+ }
+ }
+ public void decodeMetaComponent(FacesContext context, UIComponent component, String metaComponentId) {
+ throw new UnsupportedOperationException();
+ }
}
\ No newline at end of file
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-11-17 16:48:10 UTC (rev 20078)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/calendar.js 2010-11-17 16:53:40 UTC (rev 20079)
@@ -261,6 +261,7 @@
selectedDate: null,
currentDate: null,
defaultTime: {hours:12,minutes:0, seconds:0},
+ mode: "client",
hidePopupOnScroll: true
};
@@ -494,6 +495,9 @@
this.scrollElements = null;
//alert(new Date().getTime()-_d.getTime());
+
+ //define isAjaxMode variable
+ "ajax" == this.params.mode ? this.isAjaxMode = true : this.isAjaxMode = false;
};
@@ -1118,10 +1122,12 @@
}
},
- indexData:function(daysData, isAjaxMode) {
- var dateYear = daysData.startDate.getFullYear();
- var dateMonth = daysData.startDate.getMonth();
+ indexData: function(daysData, isAjaxMode) {
+ var dateYear = daysData.startDate.year;
+ var dateMonth = daysData.startDate.month;
+ daysData.startDate = new Date(dateYear,dateMonth)
+
daysData.index = [];
daysData.index[dateYear+'-'+dateMonth] = 0;
if (isAjaxMode)
@@ -1402,12 +1408,31 @@
var formattedDate = rf.calendarUtils.formatDate(this.getCurrentDate(),"MM/yyyy");
rf.getDomElement(this.id+'InputCurrentDate').value=formattedDate;
- if (this.submitFunction)
- this.submitFunction.call(this, formattedDate);
+ if (this.isAjaxMode && this.callAjax)
+ this.callAjax.call(this, formattedDate);
else
this.render();
},
+ callAjax: function(calendar, date) {
+ var _this = this;
+ var ajaxSuccess = function (event) {
+ if (event.componentData && event.componentData[_this.id])
+ {
+ var dataDays=event.componentData[_this.id]
+ _this.load(dataDays, true);
+ }
+ }
+ var ajaxError = function (event) {
+ // do nothing
+ }
+ var params = {};
+ params[this.id + ".ajax"] = "1";
+
+ rf.ajax(this.id, null, {parameters: params, error: ajaxError, complete:ajaxSuccess});
+
+ },
+
nextMonth: function() {
this.changeCurrentDateOffset(0,1);
},
14 years, 1 month
JBoss Rich Faces SVN: r20078 - in branches/RF-8742-1: ui/input/api/src/main/java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-11-17 11:48:10 -0500 (Wed, 17 Nov 2010)
New Revision: 20078
Modified:
branches/RF-8742-1/
branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
Log:
Merged revisions 20074-20077 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20074 | abelevich | 2010-11-17 07:45:24 -0800 (Wed, 17 Nov 2010) | 1 line
RF-9791, RF-9664
.......
r20075 | abelevich | 2010-11-17 07:47:13 -0800 (Wed, 17 Nov 2010) | 1 line
RF-9664
.......
r20076 | abelevich | 2010-11-17 07:49:15 -0800 (Wed, 17 Nov 2010) | 1 line
RF-9607
.......
r20077 | abelevich | 2010-11-17 08:26:50 -0800 (Wed, 17 Nov 2010) | 1 line
fix behavior id
.......
Property changes on: branches/RF-8742-1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20022
+ /trunk:1-20077
Modified: branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java
===================================================================
--- branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/component/InplaceComponent.java 2010-11-17 16:48:10 UTC (rev 20078)
@@ -45,7 +45,7 @@
public String getChangedStateClass();
- public String getDisableStateClass();
+ public String getDisabledStateClass();
public String getEditClass();
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceInput.java 2010-11-17 16:48:10 UTC (rev 20078)
@@ -77,7 +77,7 @@
public abstract String getChangedStateClass();
@Attribute
- public abstract String getDisableStateClass();
+ public abstract String getDisabledStateClass();
@Attribute
public abstract String getEditClass();
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-11-17 16:48:10 UTC (rev 20078)
@@ -198,7 +198,7 @@
}
public String getDisableStateCss(InplaceComponent component) {
- String css = component.getDisableStateClass();
+ String css = component.getDisabledStateClass();
return concatClasses("rf-ii-dis-s", css);
}
Modified: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java 2010-11-17 16:48:10 UTC (rev 20078)
@@ -111,7 +111,7 @@
}
public String getDisableStateCss(InplaceComponent component) {
- String css = component.getDisableStateClass();
+ String css = component.getDisabledStateClass();
return concatClasses("rf-is-dis-s", css);
}
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-11-17 16:48:10 UTC (rev 20078)
@@ -13,8 +13,8 @@
this.selValueInput = $(document.getElementById(id+"selValue"));
this.list = $(document.getElementById(id+"List"));
this.list.bind("click", $.proxy(this.__onListClick, this));
- this.openOnEdit = options.openOnEdit;
- this.saveOnSelect = options.saveOnSelect;
+ this.openOnEdit = mergedOptions.openOnEdit;
+ this.saveOnSelect = mergedOptions.saveOnSelect;
this.savedIndex = -1;
}
@@ -23,6 +23,8 @@
var defaultOptions = {
defaultLabel: "",
+ saveOnSelect: true,
+ openOnEdit: true,
showControl: false,
itemCss: "rf-is-opt",
selectItemCss: "rf-is-sel",
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-17 16:48:10 UTC (rev 20078)
@@ -129,7 +129,6 @@
if (this.items.length>0 && this.enableManualInput) {
this.cache = new rf.utils.Cache("", this.items, getData, true);
}
-
this.changeDelay = mergedOptions.changeDelay;
};
@@ -241,10 +240,8 @@
__onChangeValue: function(e) {
this.popupList.__selectByIndex();
var newValue = this.getValue();
-
if(this.cache && this.cache.isCached(newValue)) {
this.__updateItems();
-
if(!this.popupList.isVisible()) {
this.showPopup();
}
@@ -290,44 +287,51 @@
processItem: function(item) {
var key = $(item).attr("id");
- var value = this.getItemValue(key);
- this.selValueInput.val(value);
- var label = this.getItemLabel(key);
+ var label;
+ $.each(this.clientItems, function() {
+ if(this.id == key) {
+ label = this.label;
+ return false;
+ }
+ });
this.setValue(label);
this.hidePopup();
this.__setInputFocus();
},
- getItemValue: function(key) {
- for(var i in this.clientItems) {
- var item = this.clientItems[i];
- if(item && item.id == key) {
- return item.value;
- }
- }
- },
-
- getItemLabel: function(key) {
- for(var i in this.clientItems) {
- var item = this.clientItems[i];
- if(item && item.id == key) {
- return item.label;
- }
- }
- },
-
onblur: function(e) {
- this.hidePopup();
+ this.hidePopup();
+ var value = "";
+ var label = this.defaultLabel;
var inputLabel = this.getValue();
- if(!inputLabel || inputLabel == "") {
- this.setValue(this.defaultLabel);
- this.selValueInput.val("");
- }
-
+ if(inputLabel && inputLabel != "") {
+ var items = this.cache.getItems(inputLabel);
+ if(items.length > 0) {
+ var first = $(items[0]);
+ $.each(this.clientItems, function() {
+ if(this.id == first.attr("id")) {
+ label = this.label;
+ value = this.value;
+ return false;
+ }
+ });
+ } else {
+ var prevValue = this.selValueInput.val();
+ if(prevValue && prevValue != "") {
+ $.each(this.clientItems, function() {
+ if(this.value == prevValue) {
+ label = this.label;
+ value = this.value
+ return false;
+ }
+ });
+ }
+ }
+ }
+ this.setValue(label);
+ this.selValueInput.val(value);
this.focused = false;
-
this.invokeEvent.call(this,"blur", document.getElementById(this.id + 'Input'), e);
-
if(this.focusValue != this.selValueInput.val() ) {
this.invokeEvent.call(this, "change", document.getElementById(this.id + 'Input'), e);
}
Modified: branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-11-17 16:26:50 UTC (rev 20077)
+++ branches/RF-8742-1/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-11-17 16:48:10 UTC (rev 20078)
@@ -39,7 +39,7 @@
*
*/
-@JsfBehavior(id = "org.richfaces.behavior.ToggleControl", tag = @Tag(name = "toggleControl", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets))
+@JsfBehavior(id = "org.richfaces.component.behavior.ToggleControl", tag = @Tag(name = "toggleControl", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets))
public class ToggleControl extends ClientBehavior {
public static final String BEHAVIOR_ID = "org.richfaces.component.behavior.ToggleControl";
14 years, 1 month
JBoss Rich Faces SVN: r20077 - trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-17 11:26:50 -0500 (Wed, 17 Nov 2010)
New Revision: 20077
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
Log:
fix behavior id
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-11-17 15:49:15 UTC (rev 20076)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-11-17 16:26:50 UTC (rev 20077)
@@ -39,7 +39,7 @@
*
*/
-@JsfBehavior(id = "org.richfaces.behavior.ToggleControl", tag = @Tag(name = "toggleControl", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets))
+@JsfBehavior(id = "org.richfaces.component.behavior.ToggleControl", tag = @Tag(name = "toggleControl", handler = "org.richfaces.view.facelets.html.CustomBehaviorHandler", type = TagType.Facelets))
public class ToggleControl extends ClientBehavior {
public static final String BEHAVIOR_ID = "org.richfaces.component.behavior.ToggleControl";
14 years, 1 month
JBoss Rich Faces SVN: r20076 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2010-11-17 10:49:15 -0500 (Wed, 17 Nov 2010)
New Revision: 20076
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
Log:
RF-9607
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-17 15:47:13 UTC (rev 20075)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-17 15:49:15 UTC (rev 20076)
@@ -129,7 +129,6 @@
if (this.items.length>0 && this.enableManualInput) {
this.cache = new rf.utils.Cache("", this.items, getData, true);
}
-
this.changeDelay = mergedOptions.changeDelay;
};
@@ -241,10 +240,8 @@
__onChangeValue: function(e) {
this.popupList.__selectByIndex();
var newValue = this.getValue();
-
if(this.cache && this.cache.isCached(newValue)) {
this.__updateItems();
-
if(!this.popupList.isVisible()) {
this.showPopup();
}
@@ -290,44 +287,51 @@
processItem: function(item) {
var key = $(item).attr("id");
- var value = this.getItemValue(key);
- this.selValueInput.val(value);
- var label = this.getItemLabel(key);
+ var label;
+ $.each(this.clientItems, function() {
+ if(this.id == key) {
+ label = this.label;
+ return false;
+ }
+ });
this.setValue(label);
this.hidePopup();
this.__setInputFocus();
},
- getItemValue: function(key) {
- for(var i in this.clientItems) {
- var item = this.clientItems[i];
- if(item && item.id == key) {
- return item.value;
- }
- }
- },
-
- getItemLabel: function(key) {
- for(var i in this.clientItems) {
- var item = this.clientItems[i];
- if(item && item.id == key) {
- return item.label;
- }
- }
- },
-
onblur: function(e) {
- this.hidePopup();
+ this.hidePopup();
+ var value = "";
+ var label = this.defaultLabel;
var inputLabel = this.getValue();
- if(!inputLabel || inputLabel == "") {
- this.setValue(this.defaultLabel);
- this.selValueInput.val("");
- }
-
+ if(inputLabel && inputLabel != "") {
+ var items = this.cache.getItems(inputLabel);
+ if(items.length > 0) {
+ var first = $(items[0]);
+ $.each(this.clientItems, function() {
+ if(this.id == first.attr("id")) {
+ label = this.label;
+ value = this.value;
+ return false;
+ }
+ });
+ } else {
+ var prevValue = this.selValueInput.val();
+ if(prevValue && prevValue != "") {
+ $.each(this.clientItems, function() {
+ if(this.value == prevValue) {
+ label = this.label;
+ value = this.value
+ return false;
+ }
+ });
+ }
+ }
+ }
+ this.setValue(label);
+ this.selValueInput.val(value);
this.focused = false;
-
this.invokeEvent.call(this,"blur", document.getElementById(this.id + 'Input'), e);
-
if(this.focusValue != this.selValueInput.val() ) {
this.invokeEvent.call(this, "change", document.getElementById(this.id + 'Input'), e);
}
14 years, 1 month