Permalink
Browse files

the home for mobile helper code for RichFaces 4.1.0

  • Loading branch information...
1 parent c1ac51b commit d507d44095397eebf4665c7494746d60481f252c @wesleyhales wesleyhales committed Nov 10, 2011
Showing with 992 additions and 0 deletions.
  1. +7 −0 mobile/README
  2. +104 −0 mobile/rf-dnd.js
  3. +515 −0 mobile/rf-mobile-skin.css
  4. +177 −0 mobile/slidfast.css
  5. +189 −0 mobile/slidfast.js
View
@@ -0,0 +1,7 @@
+SlidFast is a minimalistic approach to writing mobile web apps with RichFaces 4.1.0.
+It utilizes core HTML5 APIs for WebKit based web browsers.
+
+Include the slidfast.js, slidfast.css and rf-mobile-skin.css files in your project, then initialize with:
+//initialize mobile project with SlidFast
+//parameters are for "default page ID" and "default page hash"
+slidfast.init('home-page','home');
View
@@ -0,0 +1,104 @@
+/*!
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, 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.
+ *
+ * Author: Dave Furfero
+ * Description: Adapted from https://github.com/furf/jquery-ui-touch-punch
+ * For use with the RichFaces Drag and Drop component on iOS
+ */
+
+(function (jQuery) {
+
+ jQuery.support.touch = typeof Touch === 'object';
+
+ if (!jQuery.support.touch) {
+ return;
+ }
+
+ var mouseProto = jQuery.ui.mouse.prototype,
+ _mouseInit = mouseProto._mouseInit,
+ _mouseDown = mouseProto._mouseDown,
+ _mouseUp = mouseProto._mouseUp,
+
+ mouseEvents = {
+ touchstart: 'mousedown',
+ touchmove: 'mousemove',
+ touchend: 'mouseup'
+ };
+
+ function makeMouseEvent(event) {
+
+ var touch = event.originalEvent.changedTouches[0];
+
+ return jQuery.extend(event, {
+ type: mouseEvents[event.type],
+ which: 1,
+ pageX: touch.pageX,
+ pageY: touch.pageY,
+ screenX: touch.screenX,
+ screenY: touch.screenY,
+ clientX: touch.clientX,
+ clientY: touch.clientY
+ });
+ }
+
+ mouseProto._mouseInit = function () {
+
+ var self = this;
+
+ self.element.bind('touchstart.' + self.widgetName, function (event) {
+ return self._mouseDown(makeMouseEvent(event));
+ });
+
+ _mouseInit.call(self);
+ };
+
+ mouseProto._mouseDown = function (event) {
+
+ var self = this,
+ ret = _mouseDown.call(self, event);
+
+ self._touchMoveDelegate = function (event) {
+ return self._mouseMove(makeMouseEvent(event));
+ };
+
+ self._touchEndDelegate = function(event) {
+ return self._mouseUp(makeMouseEvent(event));
+ };
+
+ jQuery(document)
+ .bind('touchmove.' + self.widgetName, self._touchMoveDelegate)
+ .bind('touchend.' + self.widgetName, self._touchEndDelegate);
+
+ return ret;
+ };
+
+ mouseProto._mouseUp = function (event) {
+
+ var self = this;
+
+ jQuery(document)
+ .unbind('touchmove.' + self.widgetName, self._touchMoveDelegate)
+ .unbind('touchend.' + self.widgetName, self._touchEndDelegate);
+
+ return _mouseUp.call(self, event);
+ };
+
+})(jQuery);
Oops, something went wrong.

0 comments on commit d507d44

Please sign in to comment.