Adam Shaw преди 10 години
родител
ревизия
226e5af49c
променени са 2 файла, в които са добавени 60 реда и са изтрити 2 реда
  1. 14 0
      src/common/common.css
  2. 46 2
      src/util.js

+ 14 - 0
src/common/common.css

@@ -682,3 +682,17 @@ a.fc-more:hover {
 	position: absolute;
 	position: absolute;
 	border: 0 solid red;
 	border: 0 solid red;
 }
 }
+
+
+/* Utilities
+--------------------------------------------------------------------------------------------------*/
+
+.fc-unselectable {
+	-webkit-user-select: none;
+	 -khtml-user-select: none;
+	   -moz-user-select: none;
+	    -ms-user-select: none;
+	        user-select: none;
+	-webkit-touch-callout: none;
+	-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
+}

+ 46 - 2
src/util.js

@@ -156,7 +156,7 @@ function subtractInnerElHeight(outerEl, innerEl) {
 }
 }
 
 
 
 
-/* General DOM Utilities
+/* Element Geom Utilities
 ----------------------------------------------------------------------------------------------------------------------*/
 ----------------------------------------------------------------------------------------------------------------------*/
 
 
 FC.getOuterRect = getOuterRect;
 FC.getOuterRect = getOuterRect;
@@ -293,13 +293,57 @@ function getCssFloat(el, prop) {
 }
 }
 
 
 
 
+/* Mouse / Touch Utilities
+----------------------------------------------------------------------------------------------------------------------*/
+
+
 // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
 // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
 function isPrimaryMouseButton(ev) {
 function isPrimaryMouseButton(ev) {
 	return ev.which == 1 && !ev.ctrlKey;
 	return ev.which == 1 && !ev.ctrlKey;
 }
 }
 
 
 
 
-/* Geometry
+function isSingleTouch(ev) {
+	var touches = ev.originalEvent.touches;
+	return touches && touches.length == 1;
+}
+
+
+function getEvX(ev) {
+	if (ev.pageX !== undefined) {
+		return ev.pageX;
+	}
+	var touches = ev.originalEvent.touches;
+	if (touches && touches.length == 1) {
+		return touches[0].pageX;
+	}
+}
+
+
+function getEvY(ev) {
+	if (ev.pageY !== undefined) {
+		return ev.pageY;
+	}
+	var touches = ev.originalEvent.touches;
+	if (touches && touches.length == 1) {
+		return touches[0].pageY;
+	}
+}
+
+
+function preventSelection(el) {
+	el.addClass('fc-unselectable')
+		.on('selectstart', preventDefault);
+}
+
+
+// Stops a mouse/touch event from doing it's native browser action
+function preventDefault(ev) {
+	ev.preventDefault();
+}
+
+
+/* General Geometry Utils
 ----------------------------------------------------------------------------------------------------------------------*/
 ----------------------------------------------------------------------------------------------------------------------*/
 
 
 FC.intersectRects = intersectRects;
 FC.intersectRects = intersectRects;