You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by al...@apache.org on 2011/01/27 01:36:07 UTC
svn commit: r1063932 - in
/myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main:
java/org/apache/myfaces/html5/component/output/
java/org/apache/myfaces/html5/renderkit/output/
resources/META-INF/resources/org.apache.myfaces.html5/
Author: aliok
Date: Thu Jan 27 00:36:07 2011
New Revision: 1063932
URL: http://svn.apache.org/viewvc?rev=1063932&view=rev
Log:
Html5
New functionality to enable/disable navigation with arrow keys and mouse wheel scroll
Modified:
myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java
myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/renderkit/output/SlideViewRenderer.java
myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/resources/META-INF/resources/org.apache.myfaces.html5/slide.js
Modified: myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java
URL: http://svn.apache.org/viewvc/myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java?rev=1063932&r1=1063931&r2=1063932&view=diff
==============================================================================
--- myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java (original)
+++ myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/component/output/AbstractSlideView.java Thu Jan 27 00:36:07 2011
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
package org.apache.myfaces.html5.component.output;
import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
@@ -58,5 +77,19 @@ public abstract class AbstractSlideView
public abstract double getInactiveSlideScale();
+ /**
+ * If true, arrow keys will be registered to navigate between slides.<br/>
+ * Defaults to true.<br/>
+ * widgetVar can be used to navigate between slides manually.
+ */
+ @JSFProperty(required = false, deferredValueType = "java.lang.Boolean", defaultValue = "true")
+ public abstract boolean isNavigateOnArrowKeys();
+ /**
+ * If true, mouse wheel scroll will be registered to navigate between slides.<br/>
+ * Defaults to true.
+ * widgetVar can be used to navigate between slides manually.
+ */
+ @JSFProperty(required = false, deferredValueType = "java.lang.Boolean", defaultValue = "true")
+ public abstract boolean isNavigateOnMouseWheel();
}
Modified: myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/renderkit/output/SlideViewRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/renderkit/output/SlideViewRenderer.java?rev=1063932&r1=1063931&r2=1063932&view=diff
==============================================================================
--- myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/renderkit/output/SlideViewRenderer.java (original)
+++ myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/java/org/apache/myfaces/html5/renderkit/output/SlideViewRenderer.java Thu Jan 27 00:36:07 2011
@@ -160,8 +160,11 @@ public class SlideViewRenderer extends H
else
widgetVar = Html5RendererUtils.generateWidgetVar(clientId);
+ final boolean navigateOnArrowKeys = component.isNavigateOnArrowKeys();
+ final boolean navigateOnMouseWheel = component.isNavigateOnMouseWheel();
+
writer.startElement(HTML5.SCRIPT_ELEM, component);
- String jsDefinition = MessageFormat.format("var {0} = new myfaces.html5.slide.SlideView(document.getElementById(''{1}''));", widgetVar, clientId);
+ String jsDefinition = MessageFormat.format("var {0} = new myfaces.html5.slide.SlideView(document.getElementById(''{1}''), {2}, {3});", widgetVar, clientId, navigateOnArrowKeys, navigateOnMouseWheel);
writer.write(jsDefinition);
writer.endElement(HTML5.SCRIPT_ELEM);
}
Modified: myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/resources/META-INF/resources/org.apache.myfaces.html5/slide.js
URL: http://svn.apache.org/viewvc/myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/resources/META-INF/resources/org.apache.myfaces.html5/slide.js?rev=1063932&r1=1063931&r2=1063932&view=diff
==============================================================================
--- myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/resources/META-INF/resources/org.apache.myfaces.html5/slide.js (original)
+++ myfaces/gsoc/html5-comp-lib/trunk/html5-comp-lib-core/src/main/resources/META-INF/resources/org.apache.myfaces.html5/slide.js Thu Jan 27 00:36:07 2011
@@ -34,7 +34,7 @@ if(myfaces.html5.slide == undefined || m
element : null
};
- myfaces.html5.slide.SlideView = function(_root){
+ myfaces.html5.slide.SlideView = function(_root, _navigateOnArrowKeys, _navigateOnMouseWheel){
this.slides = new Array();
for(var i=0; i<_root.children.length; i++)
@@ -50,9 +50,14 @@ if(myfaces.html5.slide == undefined || m
myfaces.html5.effect.addEffect(_root, 'mf-slideview');
var slideView = this;
- document.addEventListener('keydown', function(e) { slideView.handleKeyDown(e); }, false);
- document.addEventListener('mousewheel', function(e) { slideView.handleMouseWheel(e); }, false);
- document.addEventListener('DOMMouseScroll', function(e) { slideView.handleMouseWheel(e); }, false);
+ if(_navigateOnArrowKeys){
+ document.addEventListener('keydown', function(e) { slideView.handleKeyDown(e); }, false);
+ }
+ if(_navigateOnMouseWheel){
+ document.addEventListener('mousewheel', function(e) { slideView.handleMouseWheel(e); }, false);
+ document.addEventListener('DOMMouseScroll', function(e) { slideView.handleMouseWheel(e); }, false);
+ }
+
var userAgent = navigator.userAgent;
var opera = parseFloat(userAgent.split('Opera/')[1]) || undefined;