Author: amarkhel
Date: 2010-07-23 15:43:09 -0400 (Fri, 23 Jul 2010)
New Revision: 18224
Modified:
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/resources/script/popupPanel.js
root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml
Log:
Refactoring script and template for popup panel
Modified:
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/resources/script/popupPanel.js
===================================================================
---
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/resources/script/popupPanel.js 2010-07-23
19:04:24 UTC (rev 18223)
+++
root/ui/output/trunk/panels/ui/src/main/resources/META-INF/resources/script/popupPanel.js 2010-07-23
19:43:09 UTC (rev 18224)
@@ -24,10 +24,6 @@
{
jQuery(element).unbind( 'selectstart', selectionEventHandler);
}
- else if (typeof element.style.MozUserSelect!="undefined") //Firefox
- {
- jQuery(element).css('MozUserSelect','');
- }
else //All other (ie: Opera)
{
jQuery(element).unbind( 'mousedown', selectionEventHandler);
@@ -58,7 +54,8 @@
this.scrollerDiv = id + "_content_scroller"
this.borders = new Array();
-
+ this.firstHref = id + "FirstHref";
+ this.lastHref = id + "LastHref";
if (this.options.resizeable) {
this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerN", this,
"N-resize", richfaces.ui.PopupPanel.Sizer.N));
this.borders.push(new richfaces.ui.PopupPanel.Border(id + "ResizerE", this,
"E-resize", richfaces.ui.PopupPanel.Sizer.E));
@@ -137,7 +134,9 @@
destroy: function() {
this._contentElement = null;
-
+ this.firstOutside = null;
+ this.lastOutside = null;
+ this.firstHref = null;
this.parent = null;
if (this.header) {
this.header.destroy();
@@ -203,7 +202,7 @@
show: function(event, opts) {
if(!this.shown &&
this.invokeEvent("beforeshow",event,null,element)) {
-
+ this.preventFocus();
var element = this.id;
if (!this.domReattached) {
@@ -266,9 +265,9 @@
if (!this.options.autosized) {
if (options.width && options.width == -1)
- options.width = 600;
+ options.width = 300;
if (options.height && options.height == -1)
- options.height = 400;
+ options.height = 200;
} else{
//options.width = $(this.div+"_headerSpan").width() +20;
}
@@ -296,7 +295,7 @@
}
$(eContentElt).css('height', options.height + (/px/.test(options.height) ?
'' : 'px'));
$(this.shadowDiv).css('height', options.height + 4 +
(/px/.test(options.height) ? '' : 'px'));
- var headerHeight = $(this.div +"_header")[0].clientHeight;
+ var headerHeight = $(this.div +"_header")[0] ? $(this.div
+"_header")[0].clientHeight : 0;
$(this.scrollerDiv).css('height', options.height - headerHeight +
(/px/.test(options.height) ? '' : 'px'));
@@ -364,12 +363,92 @@
},
startDrag: function(border) {
- for (var k = 0; k < this.borders.length; k++ ) {
- this.borders[k].hide();
- }
+ //for (var k = 0; k < this.borders.length; k++ ) {
+ //this.borders[k].hide();
+ //}
disableSelection(document.body);
},
+ firstOnfocus: function(event) {
+ var e = $(event.data.popup.firstHref)
+ if (e) {
+ e.focus();
+ }
+ },
+
+ formElements: "|a|input|select|button|textarea|",
+
+ processAllFocusElements: function(root, callback) {
+ var idx = -1;
+ var tagName;
+
+ if (root.focus && root.nodeType == 1 && (tagName = root.tagName)
&&
+ // Many not visible elements have focus method, we is had to avoid processing them.
+ (idx = this.formElements.indexOf(tagName.toLowerCase())) != -1 &&
+ this.formElements.charAt(idx - 1) === '|' &&
+ this.formElements.charAt(idx + tagName.length) === '|' &&
+ !root.disabled && root.type!="hidden") {
+ callback.call(this, root);
+ } else {
+ if (root != this.id) {
+ var child = root.firstChild;
+ while (child) {
+ if (!child.style || child.style.display != 'none') {
+ this.processAllFocusElements(child, callback);
+ }
+ child = child.nextSibling;
+ }
+ }
+ }
+ },
+
+ processTabindexes: function(input) {
+ if (!this.firstOutside) {
+ this.firstOutside = input;
+ }
+ if (input.tabIndex && !input.prevTabIndex) {
+ input.prevTabIndex = input.tabIndex;
+ }
+ input.tabIndex = undefined;
+ if (input.accesskey && !input.prevAccesskey) {
+ input.prevAccesskey = input.accesskey;
+ }
+ input.accesskey = undefined;
+ },
+
+ restoreTabindexes: function(input) {
+ if (input.prevTabIndex) {
+ input.tabIndex = input.prevTabIndex;
+ input.prevTabIndex = undefined;
+ }
+ if (input.prevAccesskey) {
+ input.accesskey = input.prevAccesskey;
+ input.prevAccesskey = undefined;
+ }
+ },
+
+ preventFocus: function() {
+ if(this.options.modal){
+ this.processAllFocusElements(document, this.processTabindexes);
+ var popup = this;
+ if (this.firstOutside) {
+
+ jQuery(this.firstOutside).bind("focus", {popup: popup}, this.firstOnfocus);
+ }
+ }
+ },
+
+ restoreFocus: function() {
+ if(this.options.modal){
+ this.processAllFocusElements(document, this.restoreTabindexes);
+
+ if (this.firstOutside) {
+ jQuery(this.firstOutside).unbind("focus", this.firstOnfocus);
+ this.firstOutside = null;
+ }
+ }
+ },
+
endDrag: function(border) {
for (var k = 0; k < this.borders.length; k++ ) {
this.borders[k].show();
@@ -380,6 +459,7 @@
hide: function(event, opts) {
var element = this.id;
+ this.restoreFocus();
if (this.shown &&
this.invokeEvent("beforehide",event,null,element)) {
this.currentMinHeight = undefined;
Modified: root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml
===================================================================
--- root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml 2010-07-23
19:04:24 UTC (rev 18223)
+++ root/ui/output/trunk/panels/ui/src/main/templates/popupPanel.template.xml 2010-07-23
19:43:09 UTC (rev 18224)
@@ -24,7 +24,9 @@
onmousedown="#{component.attributes['onmaskmousedown']}"
onmousemove="#{component.attributes['onmaskmousemove']}"
onmouseover="#{component.attributes['onmaskmouseover']}"
- onmouseout="#{component.attributes['onmaskmouseout']}"
class="mp_shade"/>
+ onmouseout="#{component.attributes['onmaskmouseout']}"
class="mp_shade">
+ <button class="mp-button"
id="#{clientId}FirstHref"></button>
+ </div>
</c:if>
<div id="#{clientId}_shadow" class="mp_shadow"/>
@@ -61,7 +63,6 @@
</c:if>
</div>
-
</div>
<cdk:object type="java.lang.String" name="script"
value="#{buildScript(facesContext, component)}" />
<cdk:object type="java.lang.String" name="showScript"
value="#{buildShowScript(facesContext, component)}" />