Author: alexsmirnov
Date: 2010-10-13 14:56:29 -0400 (Wed, 13 Oct 2010)
New Revision: 19559
Modified:
branches/RF-8742/
branches/RF-8742/core/impl/src/main/resources/META-INF/resources/richfaces.js
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js
branches/RF-8742/ui/input/ui/src/main/templates/inplaceSelect.template.xml
Log:
Merged revisions 19548,19550,19555,19557 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r19548 | abelevich | 2010-10-13 03:01:15 -0700 (Wed, 13 Oct 2010) | 1 line
.......
r19550 | pyaschenko | 2010-10-13 03:53:02 -0700 (Wed, 13 Oct 2010) | 3 lines
RF-9152, RF-9168
richfaces container fixes
RichFaces.$$ was added
.......
r19555 | abelevich | 2010-10-13 08:35:34 -0700 (Wed, 13 Oct 2010) | 1 line
remove odd css class, fix selection, fix inplace specific popup behavior
.......
r19557 | abelevich | 2010-10-13 10:50:11 -0700 (Wed, 13 Oct 2010) | 1 line
add openOnEdit attribute, fix keyboard navigation
.......
Property changes on: branches/RF-8742
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-19546
+ /trunk:1-19558
Modified: branches/RF-8742/core/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
---
branches/RF-8742/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-10-13
18:56:29 UTC (rev 19559)
@@ -40,9 +40,20 @@
var element = richfaces.getDomElement(source);
if (element) {
- return (element["richfaces"] || {})["component"];
+ return (element[richfaces.RICH_CONTAINER] || {})["component"];
}
}
+
+ richfaces.$$ = function(componentName, element)
+ {
+ while (element.parentNode) {
+ var e = element[richfaces.RICH_CONTAINER];
+ if (e && e.component && e.component.name==componentName)
+ return e.component;
+ else
+ element = element.parentNode;
+ }
+ }
// find component and call his method
richfaces.invokeMethod = function(source, method) {
Modified:
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-10-13
18:56:29 UTC (rev 19559)
@@ -60,7 +60,10 @@
@Attribute
public abstract String getDefaultLabel();
-
+
+ @Attribute(defaultValue="false")
+ public abstract boolean isOpenOnEdit();
+
@Attribute(defaultValue="true")
public abstract boolean isSaveOnBlur();
Modified:
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectBaseRenderer.java 2010-10-13
18:56:29 UTC (rev 19559)
@@ -55,7 +55,9 @@
@ResourceDependency(name = "richfaces-base-component.js"),
@ResourceDependency(name = "richfaces-selection.js"),
@ResourceDependency(library = "org.richfaces", name =
"inplaceBase.js"),
- @ResourceDependency(library = "org.richfaces", name =
"select.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"popup.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"popupList.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"selectList.js"),
@ResourceDependency(library = "org.richfaces", name =
"inplaceInput.js"),
@ResourceDependency(library = "org.richfaces", name =
"inplaceSelect.js"),
@ResourceDependency(library = "org.richfaces", name =
"inplaceSelect.ecss") })
@@ -72,6 +74,8 @@
public static final String OPTIONS_SELECT_ITEMS = "selectItems";
public static final String OPTIONS_SELECT_ITEM_VALUE_INPUT =
"selValueInput";
+
+ public static final String OPTIONS_VISIBLE = "visible";
protected static final class ClientSelectItem implements ScriptString {
@@ -164,6 +168,7 @@
options.put(OPTIONS_ITEMS_CORD, clientId + "Items");
options.put(OPTIONS_SELECT_ITEMS, additional);
options.put(OPTIONS_SELECT_ITEM_VALUE_INPUT, clientId + "selValue");
+ options.put(OPTIONS_VISIBLE,
component.getAttributes().get("openOnEdit"));
}
public void encodeOptions(FacesContext facesContext, UIComponent component,
@@ -225,7 +230,8 @@
}
public String getListStyles(FacesContext facesContext, UIComponent component) {
- return "";
+ AbstractInplaceSelect inplaceSelect = (AbstractInplaceSelect) component;
+ return inplaceSelect.isOpenOnEdit() ? "" : "display: none";
}
public String getReadyStateCss() {
Modified:
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-10-13
18:56:29 UTC (rev 19559)
@@ -57,11 +57,14 @@
switch(code) {
case 27:
+ e.preventDefault();
this.cancel();
break;
case 13:
+ e.preventDefault();
this.save();
return false;
+ break;
}
},
Modified:
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-10-13
18:56:29 UTC (rev 19559)
@@ -4,7 +4,7 @@
rf.ui.InplaceSelect = function(id, options) {
$super.constructor.call(this, id, options)
- this.select = new rf.ui.Select(options.listCord, this, options);
+ this.select = new rf.ui.SelectList(options.listCord, this, options);
this.selectItems = options.selectItems;
this.selValueInput = $(document.getElementById(options.selValueInput));
this.openPopup = false;
@@ -46,15 +46,17 @@
},
processItem: function(event, element) {
- var key = element.attr("id");
- var value = this.getItemValue(key);
- this.saveItemValue(value);
+ if(element) {
+ var key = $(element).attr("id");
+ var value = this.getItemValue(key);
+ this.saveItemValue(value);
+ var label = this.getItemLabel(key);
+ //inplace label
+ this.setValue(label);
+ }
- var label = this.getItemLabel(key);
- //inplace label
- this.setValue(label);
this.select.hide();
-
+ this.openPopup = false;
this.__setInputFocus();
},
@@ -81,7 +83,6 @@
},
__keydownHandler: function(e) {
- $super.__keydownHandler(e);
var code;
@@ -91,17 +92,30 @@
code = e.which;
}
- switch(code) {
- case rf.KEYS.DOWN:
- e.preventDefault();
- this.select.__onKeyDown(e);
- break;
-
- case rf.KEYS.UP:
- e.preventDefault();
- this.select.__onKeyUp(e);
- break;
- }
+ if(this.select.isVisible()) {
+ switch(code) {
+ case rf.KEYS.DOWN:
+ e.preventDefault();
+ this.select.__onKeyDown(e);
+ this.__setInputFocus();
+ break;
+
+ case rf.KEYS.UP:
+ e.preventDefault();
+ this.select.__onKeyUp(e);
+ this.__setInputFocus();
+ break;
+
+ case rf.KEYS.RETURN:
+ e.preventDefault();
+ this.select.__onEnter(e);
+ return false;
+ break;
+ }
+ }
+
+ $super.__keydownHandler.call(this,e);
+
},
__blurHandler: function(e) {
@@ -114,7 +128,7 @@
__isPopupList: function(target) {
var parentId =
target.parents(".rf-is-lst-cord").attr("id");
- return (parentId && (parentId == this.select.__getId()));
+ return (parentId && (parentId == this.select.getId()));
}
}
Modified:
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popup.js 2010-10-13
18:56:29 UTC (rev 19559)
@@ -4,19 +4,17 @@
rf.ui.Popup = function(id, options) {
this.id = id;
+ this.attachToDom(id);
this.popup = $(document.getElementById(id));
- this.visible = options.visible;
-
- //TODO: remove this?
- this.popup.bind("blur", $.proxy(this.__onBlur, this));
-
- this.popup.bind("mouseover", $.proxy(this.__onMouseOver, this));
- this.popup.bind("click", $.proxy(this.__onClick, this));
+
+ this.visible = options.visible;;
+ this.popup.bind("mouseover", $.proxy(this.__onMouseOver, this));
+ this.popup.bind("click", $.proxy(this.__onClick, this));
};
rf.BaseComponent.extend(rf.ui.Popup);
var $super = rf.ui.Popup.$super;
-
+
$.extend(rf.ui.Popup.prototype, (function () {
return{
@@ -24,12 +22,14 @@
name : "popup",
show: function() {
- this.select.css("display", "");
+ this.popup.css('display', '');
+ //add attachToBody logic
this.visible = true;
},
hide: function() {
- this.select.css("display", "none");
+ this.popup.css('display', 'none');
+ //add attachToBody logic
this.visible = false;
},
@@ -45,11 +45,9 @@
},
__onClick: function(e) {
- },
-
- __onBlurHandler: function(e) {
- }
+ }
+ }
- })());
+ })());
})(jQuery, window.RichFaces);
\ No newline at end of file
Modified:
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/popupList.js 2010-10-13
18:56:29 UTC (rev 19559)
@@ -16,7 +16,6 @@
//TODO: from option map?
this.index = -1;
- this.visible = false;
this.__updateItemsList();
};
@@ -48,21 +47,41 @@
this.items = this.popup.find("."+this.itemCss);
},
- __select: function(index) {
- var item;
+ __select: function(item) {
+ var index = this.items.index(item);
+ this.__selectByIndex(index);
+ },
+
+ __selectByIndex: function(index, isOffset) {
+ if (this.items.length==0 || (!isOffset && this.index == index)) return;
+ var item;
if (this.index != -1) {
item = this.items.eq(this.index);
this.__unSelectItem(item);
}
-
- this.index += index;
- if (this.index < 0 ) {
- this.index = this.items.length - 1;
- } else if (this.index >= this.items.length) {
- this.index = 0;
- }
+
+ if (index==undefined) {
+ this.index = -1;
+ return;
+ }
+ if (isOffset) {
+ this.index += index;
+ if ( this.index<0 ) {
+ this.index = this.items.length - 1;
+ } else if (this.index >= this.items.length) {
+ this.index = 0;
+ }
+ } else {
+ if (index<0) {
+ index = 0;
+ } else if (index>=this.items.length) {
+ index = this.items.length - 1;
+ }
+ this.index = index;
+ }
+
item = this.items.eq(this.index);
this.__selectItem(item);
},
@@ -75,34 +94,40 @@
item.removeClass(this.selectItemCss);
},
+ //remove event, rename ???
__onEnter: function(e) {
+ var item;
+ if(this.items) {
+ item = this.items.eq(this.index);
+ this.processItem(e, item);
+ }
},
//remove event, rename
__onKeyUp: function(e) {
- this.__select(-1);
+ this.__selectByIndex(-1, true);
},
//remove event, rename
__onKeyDown: function(e) {
- this.__select(1);
+ this.__selectByIndex(1, true);
},
__onMouseOver: function(e) {
var item = this.__getItem(e);
- var index = this.items.index(item);
- this.__select(index);
+ if(item) {
+ this.__select(item);
+ }
},
__onClick: function(e) {
var item = this.__getItem(e);
- var index = this.items.index(item);
- this.__select(index);
this.processItem(e, item);
+ this.__select(item);
},
__getItem: function(e) {
- return $(e.target).closest("."+this.itemCss, e.currentTarget);
+ return $(e.target).closest("."+this.itemCss, e.currentTarget).get(0);
},
__getItems: function () {
Modified:
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js
===================================================================
---
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js 2010-10-13
18:43:22 UTC (rev 19558)
+++
branches/RF-8742/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/selectList.js 2010-10-13
18:56:29 UTC (rev 19559)
@@ -3,7 +3,7 @@
rf.ui = rf.ui || {};
rf.ui.SelectList = function(id, listener, options) {
- $super.constructor.call(this, id, options);
+ $super.constructor.call(this, id, listener, options);
};
rf.ui.PopupList.extend(rf.ui.SelectList);
Modified: branches/RF-8742/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- branches/RF-8742/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-13
18:43:22 UTC (rev 19558)
+++ branches/RF-8742/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-10-13
18:56:29 UTC (rev 19559)
@@ -79,7 +79,7 @@
</span>
</span>
</c:if>
- <span id="#{clientId}List" class="rf-is-none
rf-is-lst-cord">
+ <span id="#{clientId}List" style="#{getListStyles(facesContext,
component)}" class="rf-is-lst-cord">
<span class="rf-is-lst-pos" style="width:
#{component.attributes['listWidth']}">
<span class="rf-is-shdw">
<span class="rf-is-shdw-t"></span>