reactjs-rails 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React v0.3.0
2
+ * React v0.3.2
3
3
  */
4
4
  (function(e){if("function"==typeof bootstrap)bootstrap("react",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeReact=e}else"undefined"!=typeof window?window.React=e():global.React=e()})(function(){var define,ses,bootstrap,module,exports;
5
5
  return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){
@@ -2990,7 +2990,7 @@ mixInto(ReactNativeComponent, ReactMultiChild.Mixin);
2990
2990
 
2991
2991
  module.exports = ReactNativeComponent;
2992
2992
 
2993
- },{"./DOMPropertyOperations":34,"./CSSPropertyOperations":32,"./ReactComponent":3,"./ReactEvent":20,"./ReactMultiChild":41,"./escapeTextForBrowser":42,"./flattenChildren":43,"./invariant":10,"./merge":12,"./keyOf":44,"./mixInto":13}],18:[function(require,module,exports){
2993
+ },{"./CSSPropertyOperations":32,"./DOMPropertyOperations":34,"./ReactComponent":3,"./ReactEvent":20,"./ReactMultiChild":41,"./escapeTextForBrowser":42,"./flattenChildren":43,"./invariant":10,"./keyOf":44,"./merge":12,"./mixInto":13}],18:[function(require,module,exports){
2994
2994
  /**
2995
2995
  * Copyright 2013 Facebook, Inc.
2996
2996
  *
@@ -3360,7 +3360,7 @@ var ReactEvent = {
3360
3360
 
3361
3361
  module.exports = ReactEvent;
3362
3362
 
3363
- },{"./BrowserEnv":46,"./EventConstants":47,"./EventPluginHub":27,"./ExecutionEnvironment":14,"./invariant":10,"./NormalizedEventListener":48,"./isEventSupported":49}],21:[function(require,module,exports){
3363
+ },{"./BrowserEnv":46,"./EventConstants":47,"./EventPluginHub":27,"./ExecutionEnvironment":14,"./NormalizedEventListener":48,"./invariant":10,"./isEventSupported":49}],21:[function(require,module,exports){
3364
3364
  /**
3365
3365
  * Copyright 2013 Facebook, Inc.
3366
3366
  *
@@ -3688,7 +3688,7 @@ var ReactInstanceHandles = {
3688
3688
 
3689
3689
  module.exports = ReactInstanceHandles;
3690
3690
 
3691
- },{"./invariant":10,"./getDOMNodeID":50}],22:[function(require,module,exports){
3691
+ },{"./getDOMNodeID":50,"./invariant":10}],22:[function(require,module,exports){
3692
3692
  (function(){/**
3693
3693
  * Copyright 2013 Facebook, Inc.
3694
3694
  *
@@ -4341,7 +4341,7 @@ if (ExecutionEnvironment.canUseDOM) {
4341
4341
  module.exports = EventPluginHub;
4342
4342
 
4343
4343
  })()
4344
- },{"./AbstractEvent":53,"./CallbackRegistry":54,"./EventPluginUtils":55,"./EventPropagators":52,"./ExecutionEnvironment":14,"./accumulate":56,"./forEachAccumulated":57,"./keyMirror":11,"./throwIf":31,"./merge":12}],28:[function(require,module,exports){
4344
+ },{"./AbstractEvent":53,"./CallbackRegistry":54,"./EventPluginUtils":55,"./EventPropagators":52,"./ExecutionEnvironment":14,"./accumulate":56,"./forEachAccumulated":57,"./keyMirror":11,"./merge":12,"./throwIf":31}],28:[function(require,module,exports){
4345
4345
  /**
4346
4346
  * Copyright 2013 Facebook, Inc.
4347
4347
  *
@@ -6073,69 +6073,6 @@ var Transaction = {
6073
6073
  module.exports = Transaction;
6074
6074
 
6075
6075
  })()
6076
- },{"./throwIf":31}],42:[function(require,module,exports){
6077
- /**
6078
- * Copyright 2013 Facebook, Inc.
6079
- *
6080
- * Licensed under the Apache License, Version 2.0 (the "License");
6081
- * you may not use this file except in compliance with the License.
6082
- * You may obtain a copy of the License at
6083
- *
6084
- * http://www.apache.org/licenses/LICENSE-2.0
6085
- *
6086
- * Unless required by applicable law or agreed to in writing, software
6087
- * distributed under the License is distributed on an "AS IS" BASIS,
6088
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6089
- * See the License for the specific language governing permissions and
6090
- * limitations under the License.
6091
- *
6092
- * @providesModule escapeTextForBrowser
6093
- */
6094
-
6095
- "use strict";
6096
-
6097
- var throwIf = require("./throwIf");
6098
-
6099
- var ESCAPE_TYPE_ERR;
6100
-
6101
- if (true) {
6102
- ESCAPE_TYPE_ERR =
6103
- 'The React core has attempted to escape content that is of a ' +
6104
- 'mysterious type (object etc) Escaping only works on numbers and strings';
6105
- }
6106
-
6107
- var ESCAPE_LOOKUP = {
6108
- "&": "&amp;",
6109
- ">": "&gt;",
6110
- "<": "&lt;",
6111
- "\"": "&quot;",
6112
- "'": "&#x27;",
6113
- "/": "&#x2f;"
6114
- };
6115
-
6116
- function escaper(match) {
6117
- return ESCAPE_LOOKUP[match];
6118
- }
6119
-
6120
- var escapeTextForBrowser = function (text) {
6121
- var type = typeof text;
6122
- var invalid = type === 'object';
6123
- if (true) {
6124
- throwIf(invalid, ESCAPE_TYPE_ERR);
6125
- }
6126
- if (text === '' || invalid) {
6127
- return '';
6128
- } else {
6129
- if (type === 'string') {
6130
- return text.replace(/[&><"'\/]/g, escaper);
6131
- } else {
6132
- return (''+text).replace(/[&><"'\/]/g, escaper);
6133
- }
6134
- }
6135
- };
6136
-
6137
- module.exports = escapeTextForBrowser;
6138
-
6139
6076
  },{"./throwIf":31}],41:[function(require,module,exports){
6140
6077
  (function(){/**
6141
6078
  * Copyright 2013 Facebook, Inc.
@@ -6347,7 +6284,70 @@ var ReactMultiChild = {
6347
6284
  module.exports = ReactMultiChild;
6348
6285
 
6349
6286
  })()
6350
- },{"./ReactComponent":3}],43:[function(require,module,exports){
6287
+ },{"./ReactComponent":3}],42:[function(require,module,exports){
6288
+ /**
6289
+ * Copyright 2013 Facebook, Inc.
6290
+ *
6291
+ * Licensed under the Apache License, Version 2.0 (the "License");
6292
+ * you may not use this file except in compliance with the License.
6293
+ * You may obtain a copy of the License at
6294
+ *
6295
+ * http://www.apache.org/licenses/LICENSE-2.0
6296
+ *
6297
+ * Unless required by applicable law or agreed to in writing, software
6298
+ * distributed under the License is distributed on an "AS IS" BASIS,
6299
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6300
+ * See the License for the specific language governing permissions and
6301
+ * limitations under the License.
6302
+ *
6303
+ * @providesModule escapeTextForBrowser
6304
+ */
6305
+
6306
+ "use strict";
6307
+
6308
+ var throwIf = require("./throwIf");
6309
+
6310
+ var ESCAPE_TYPE_ERR;
6311
+
6312
+ if (true) {
6313
+ ESCAPE_TYPE_ERR =
6314
+ 'The React core has attempted to escape content that is of a ' +
6315
+ 'mysterious type (object etc) Escaping only works on numbers and strings';
6316
+ }
6317
+
6318
+ var ESCAPE_LOOKUP = {
6319
+ "&": "&amp;",
6320
+ ">": "&gt;",
6321
+ "<": "&lt;",
6322
+ "\"": "&quot;",
6323
+ "'": "&#x27;",
6324
+ "/": "&#x2f;"
6325
+ };
6326
+
6327
+ function escaper(match) {
6328
+ return ESCAPE_LOOKUP[match];
6329
+ }
6330
+
6331
+ var escapeTextForBrowser = function (text) {
6332
+ var type = typeof text;
6333
+ var invalid = type === 'object';
6334
+ if (true) {
6335
+ throwIf(invalid, ESCAPE_TYPE_ERR);
6336
+ }
6337
+ if (text === '' || invalid) {
6338
+ return '';
6339
+ } else {
6340
+ if (type === 'string') {
6341
+ return text.replace(/[&><"'\/]/g, escaper);
6342
+ } else {
6343
+ return (''+text).replace(/[&><"'\/]/g, escaper);
6344
+ }
6345
+ }
6346
+ };
6347
+
6348
+ module.exports = escapeTextForBrowser;
6349
+
6350
+ },{"./throwIf":31}],43:[function(require,module,exports){
6351
6351
  /**
6352
6352
  * Copyright 2013 Facebook, Inc.
6353
6353
  *
@@ -7001,7 +7001,7 @@ var EventPropagators = {
7001
7001
 
7002
7002
  module.exports = EventPropagators;
7003
7003
 
7004
- },{"./CallbackRegistry":54,"./EventConstants":47,"./accumulate":56,"./forEachAccumulated":57}],55:[function(require,module,exports){
7004
+ },{"./CallbackRegistry":54,"./EventConstants":47,"./accumulate":56,"./forEachAccumulated":57}],53:[function(require,module,exports){
7005
7005
  /**
7006
7006
  * Copyright 2013 Facebook, Inc.
7007
7007
  *
@@ -7017,199 +7017,269 @@ module.exports = EventPropagators;
7017
7017
  * See the License for the specific language governing permissions and
7018
7018
  * limitations under the License.
7019
7019
  *
7020
- * @providesModule EventPluginUtils
7020
+ * @providesModule AbstractEvent
7021
7021
  */
7022
7022
 
7023
7023
  "use strict";
7024
7024
 
7025
- var EventConstants = require("./EventConstants");
7026
- var AbstractEvent = require("./AbstractEvent");
7025
+ var BrowserEnv = require("./BrowserEnv");
7026
+ var PooledClass = require("./PooledClass");
7027
+ var TouchEventUtils = require("./TouchEventUtils");
7027
7028
 
7028
- var invariant = require("./invariant");
7029
+ var throwIf = require("./throwIf");
7029
7030
 
7030
- var topLevelTypes = EventConstants.topLevelTypes;
7031
7031
 
7032
- function isEndish(topLevelType) {
7033
- return topLevelType === topLevelTypes.topMouseUp ||
7034
- topLevelType === topLevelTypes.topTouchEnd ||
7035
- topLevelType === topLevelTypes.topTouchCancel;
7032
+ // Only accessed in __DEV__
7033
+ var CLONE_TYPE_ERR;
7034
+ if (true) {
7035
+ CLONE_TYPE_ERR =
7036
+ 'You may only clone instances of AbstractEvent for ' +
7037
+ 'persistent references. Check yourself.';
7036
7038
  }
7039
+ var MAX_POOL_SIZE = 20;
7037
7040
 
7038
- function isMoveish(topLevelType) {
7039
- return topLevelType === topLevelTypes.topMouseMove ||
7040
- topLevelType === topLevelTypes.topTouchMove;
7041
- }
7042
- function isStartish(topLevelType) {
7043
- return topLevelType === topLevelTypes.topMouseDown ||
7044
- topLevelType === topLevelTypes.topTouchStart;
7045
- }
7041
+ /**
7042
+ * AbstractEvent copy constructor. @see `PooledClass`. Provides a single place
7043
+ * to define all cross browser normalization of DOM events. Does not attempt to
7044
+ * extend a native event, rather creates a completely new object that has a
7045
+ * reference to the nativeEvent through .nativeEvent member. The property .data
7046
+ * should hold all data that is extracted from the event in a cross browser
7047
+ * manner. Application code should use the data field when possible, not the
7048
+ * unreliable native event.
7049
+ */
7050
+ function AbstractEvent(
7051
+ abstractEventType,
7052
+ abstractTargetID, // Allows the abstract target to differ from native.
7053
+ originatingTopLevelEventType,
7054
+ nativeEvent,
7055
+ data) {
7056
+ this.type = abstractEventType;
7057
+ this.abstractTargetID = abstractTargetID || '';
7058
+ this.originatingTopLevelEventType = originatingTopLevelEventType;
7059
+ this.nativeEvent = nativeEvent;
7060
+ this.data = data;
7061
+ // TODO: Deprecate storing target - doesn't always make sense for some types
7062
+ this.target = nativeEvent && nativeEvent.target;
7046
7063
 
7047
- function storePageCoordsIn(obj, nativeEvent) {
7048
- var pageX = AbstractEvent.eventPageX(nativeEvent);
7049
- var pageY = AbstractEvent.eventPageY(nativeEvent);
7050
- obj.pageX = pageX;
7051
- obj.pageY = pageY;
7052
- }
7064
+ /**
7065
+ * As a performance optimization, we tag the existing event with the listeners
7066
+ * (or listener [singular] if only one). This avoids having to package up an
7067
+ * abstract event along with the set of listeners into a wrapping "dispatch"
7068
+ * object. No one should ever read this property except event system and
7069
+ * plugin/dispatcher code. We also tag the abstract event with a parallel
7070
+ * ID array. _dispatchListeners[i] is being dispatched to a DOM node at ID
7071
+ * _dispatchIDs[i]. The lengths should never, ever, ever be different.
7072
+ */
7073
+ this._dispatchListeners = null;
7074
+ this._dispatchIDs = null;
7053
7075
 
7054
- function eventDistance(coords, nativeEvent) {
7055
- var pageX = AbstractEvent.eventPageX(nativeEvent);
7056
- var pageY = AbstractEvent.eventPageY(nativeEvent);
7057
- return Math.pow(
7058
- Math.pow(pageX - coords.pageX, 2) + Math.pow(pageY - coords.pageY, 2),
7059
- 0.5
7060
- );
7076
+ this.isPropagationStopped = false;
7061
7077
  }
7062
7078
 
7063
- var validateEventDispatches;
7064
- if (true) {
7065
- validateEventDispatches = function(abstractEvent) {
7066
- var dispatchListeners = abstractEvent._dispatchListeners;
7067
- var dispatchIDs = abstractEvent._dispatchIDs;
7068
-
7069
- var listenersIsArr = Array.isArray(dispatchListeners);
7070
- var idsIsArr = Array.isArray(dispatchIDs);
7071
- var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
7072
- var listenersLen = listenersIsArr ?
7073
- dispatchListeners.length :
7074
- dispatchListeners ? 1 : 0;
7075
-
7076
- invariant(
7077
- idsIsArr === listenersIsArr && IDsLen === listenersLen,
7078
- 'EventPluginUtils: Invalid `abstractEvent`.'
7079
- );
7080
- };
7081
- }
7079
+ /** `PooledClass` looks for this. */
7080
+ AbstractEvent.poolSize = MAX_POOL_SIZE;
7082
7081
 
7083
7082
  /**
7084
- * Invokes `cb(abstractEvent, listener, id)`. Avoids using call if no scope is
7085
- * provided. The `(listener,id)` pair effectively forms the "dispatch" but are
7086
- * kept separate to conserve memory.
7083
+ * `PooledClass` looks for `destructor` on each instance it releases. We need to
7084
+ * ensure that we remove all references to listeners which could trap large
7085
+ * amounts of memory in their closures.
7087
7086
  */
7088
- function forEachEventDispatch(abstractEvent, cb) {
7089
- var dispatchListeners = abstractEvent._dispatchListeners;
7090
- var dispatchIDs = abstractEvent._dispatchIDs;
7091
- if (true) {
7092
- validateEventDispatches(abstractEvent);
7093
- }
7094
- if (Array.isArray(dispatchListeners)) {
7095
- var i;
7096
- for (
7097
- i = 0;
7098
- i < dispatchListeners.length && !abstractEvent.isPropagationStopped;
7099
- i++) {
7100
- // Listeners and IDs are two parallel arrays that are always in sync.
7101
- cb(abstractEvent, dispatchListeners[i], dispatchIDs[i]);
7102
- }
7103
- } else if (dispatchListeners) {
7104
- cb(abstractEvent, dispatchListeners, dispatchIDs);
7105
- }
7106
- }
7087
+ AbstractEvent.prototype.destructor = function() {
7088
+ this.target = null;
7089
+ this._dispatchListeners = null;
7090
+ this._dispatchIDs = null;
7091
+ };
7107
7092
 
7108
7093
  /**
7109
- * Default implementation of PluginModule.executeDispatch().
7110
- * @param {AbstractEvent} AbstractEvent to handle
7111
- * @param {function} Application-level callback
7112
- * @param {string} domID DOM id to pass to the callback.
7113
- */
7114
- function executeDispatch(abstractEvent, listener, domID) {
7115
- listener(abstractEvent, domID);
7116
- }
7094
+ * Enhance the `AbstractEvent` class to have pooling abilities. We instruct
7095
+ * `PooledClass` that our copy constructor accepts five arguments (this is just
7096
+ * a performance optimization). These objects are instantiated frequently.
7097
+ */
7098
+ PooledClass.addPoolingTo(AbstractEvent, PooledClass.fiveArgumentPooler);
7099
+
7100
+ AbstractEvent.prototype.stopPropagation = function() {
7101
+ this.isPropagationStopped = true;
7102
+ if (this.nativeEvent.stopPropagation) {
7103
+ this.nativeEvent.stopPropagation();
7104
+ }
7105
+ // IE8 only understands cancelBubble, not stopPropagation().
7106
+ this.nativeEvent.cancelBubble = true;
7107
+ };
7108
+
7109
+ AbstractEvent.prototype.preventDefault = function() {
7110
+ AbstractEvent.preventDefaultOnNativeEvent(this.nativeEvent);
7111
+ };
7117
7112
 
7118
7113
  /**
7119
- * Standard/simple iteration through an event's collected dispatches.
7114
+ * Utility function for preventing default in cross browser manner.
7120
7115
  */
7121
- function executeDispatchesInOrder(abstractEvent, executeDispatch) {
7122
- forEachEventDispatch(abstractEvent, executeDispatch);
7123
- abstractEvent._dispatchListeners = null;
7124
- abstractEvent._dispatchIDs = null;
7125
- }
7116
+ AbstractEvent.preventDefaultOnNativeEvent = function(nativeEvent) {
7117
+ if (nativeEvent.preventDefault) {
7118
+ nativeEvent.preventDefault();
7119
+ } else {
7120
+ nativeEvent.returnValue = false;
7121
+ }
7122
+ };
7126
7123
 
7127
7124
  /**
7128
- * Standard/simple iteration through an event's collected dispatches, but stops
7129
- * at the first dispatch execution returning true, and returns that id.
7130
- *
7131
- * @returns id of the first dispatch execution who's listener returns true, or
7132
- * null if no listener returned true.
7125
+ * @param {Element} target The target element.
7133
7126
  */
7134
- function executeDispatchesInOrderStopAtTrue(abstractEvent) {
7135
- var dispatchListeners = abstractEvent._dispatchListeners;
7136
- var dispatchIDs = abstractEvent._dispatchIDs;
7137
- if (true) {
7138
- validateEventDispatches(abstractEvent);
7127
+ AbstractEvent.normalizeScrollDataFromTarget = function(target) {
7128
+ return {
7129
+ scrollTop: target.scrollTop,
7130
+ scrollLeft: target.scrollLeft,
7131
+ clientWidth: target.clientWidth,
7132
+ clientHeight: target.clientHeight,
7133
+ scrollHeight: target.scrollHeight,
7134
+ scrollWidth: target.scrollWidth
7135
+ };
7136
+ };
7137
+
7138
+ /*
7139
+ * There are some normalizations that need to happen for various browsers. In
7140
+ * addition to replacing the general event fixing with a framework such as
7141
+ * jquery, we need to normalize mouse events here. Code below is mostly borrowed
7142
+ * from: jScrollPane/script/jquery.mousewheel.js
7143
+ */
7144
+ AbstractEvent.normalizeMouseWheelData = function(nativeEvent) {
7145
+ var delta = 0;
7146
+ var deltaX = 0;
7147
+ var deltaY = 0;
7148
+
7149
+ /* traditional scroll wheel data */
7150
+ if ( nativeEvent.wheelDelta ) { delta = nativeEvent.wheelDelta/120; }
7151
+ if ( nativeEvent.detail ) { delta = -nativeEvent.detail/3; }
7152
+
7153
+ /* Multidimensional scroll (touchpads) with deltas */
7154
+ deltaY = delta;
7155
+
7156
+ /* Gecko based browsers */
7157
+ if (nativeEvent.axis !== undefined &&
7158
+ nativeEvent.axis === nativeEvent.HORIZONTAL_AXIS ) {
7159
+ deltaY = 0;
7160
+ deltaX = -delta;
7139
7161
  }
7140
- if (Array.isArray(dispatchListeners)) {
7141
- var i;
7142
- for (
7143
- i = 0;
7144
- i < dispatchListeners.length && !abstractEvent.isPropagationStopped;
7145
- i++) {
7146
- // Listeners and IDs are two parallel arrays that are always in sync.
7147
- if (dispatchListeners[i](abstractEvent, dispatchIDs[i])) {
7148
- return dispatchIDs[i];
7149
- }
7150
- }
7151
- } else if (dispatchListeners) {
7152
- if (dispatchListeners(abstractEvent, dispatchIDs)) {
7153
- return dispatchIDs;
7154
- }
7162
+
7163
+ /* Webkit based browsers */
7164
+ if (nativeEvent.wheelDeltaY !== undefined ) {
7165
+ deltaY = nativeEvent.wheelDeltaY/120;
7166
+ }
7167
+ if (nativeEvent.wheelDeltaX !== undefined ) {
7168
+ deltaX = -nativeEvent.wheelDeltaX/120;
7155
7169
  }
7156
- return null;
7157
- }
7170
+
7171
+ return { delta: delta, deltaX: deltaX, deltaY: deltaY };
7172
+ };
7158
7173
 
7159
7174
  /**
7160
- * Execution of a "direct" dispatch - there must be at most one dispatch
7161
- * accumulated on the event or it is considered an error. It doesn't really make
7162
- * sense for an event with multiple dispatches (bubbled) to keep track of the
7163
- * return values at each dispatch execution, but it does tend to make sense when
7164
- * dealing with "direct" dispatches.
7175
+ * I <3 Quirksmode.org:
7176
+ * http://www.quirksmode.org/js/events_properties.html
7177
+ */
7178
+ AbstractEvent.isNativeClickEventRightClick = function(nativeEvent) {
7179
+ return nativeEvent.which ? nativeEvent.which === 3 :
7180
+ nativeEvent.button ? nativeEvent.button === 2 :
7181
+ false;
7182
+ };
7183
+
7184
+ AbstractEvent.normalizePointerData = function(nativeEvent) {
7185
+ return {
7186
+ globalX: AbstractEvent.eventPageX(nativeEvent),
7187
+ globalY: AbstractEvent.eventPageY(nativeEvent),
7188
+ rightMouseButton:
7189
+ AbstractEvent.isNativeClickEventRightClick(nativeEvent)
7190
+ };
7191
+ };
7192
+
7193
+ AbstractEvent.normalizeDragEventData =
7194
+ function(nativeEvent, globalX, globalY, startX, startY) {
7195
+ return {
7196
+ globalX: globalX,
7197
+ globalY: globalY,
7198
+ startX: startX,
7199
+ startY: startY
7200
+ };
7201
+ };
7202
+
7203
+ /**
7204
+ * Warning: It is possible to move your finger on a touch surface, yet not
7205
+ * effect the `eventPageX/Y` because the touch had caused a scroll that
7206
+ * compensated for your movement. To track movements across the page, prevent
7207
+ * default to avoid scrolling, and control scrolling in javascript.
7208
+ */
7209
+
7210
+ /**
7211
+ * Gets the exact position of a touch/mouse event on the page with respect to
7212
+ * the document body. The only reason why this method is needed instead of using
7213
+ * `TouchEventUtils.extractSingleTouch` is to support IE8-. Mouse events in all
7214
+ * browsers except IE8- contain a pageY. IE8 and below require clientY
7215
+ * computation:
7165
7216
  *
7166
- * @returns The return value of executing the single dispatch.
7217
+ * @param {Event} nativeEvent Native event, possibly touch or mouse.
7218
+ * @return {number} Coordinate with respect to document body.
7167
7219
  */
7168
- function executeDirectDispatch(abstractEvent) {
7169
- if (true) {
7170
- validateEventDispatches(abstractEvent);
7220
+ AbstractEvent.eventPageY = function(nativeEvent) {
7221
+ var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
7222
+ if (singleTouch) {
7223
+ return singleTouch.pageY;
7224
+ } else if (typeof nativeEvent.pageY !== 'undefined') {
7225
+ return nativeEvent.pageY;
7226
+ } else {
7227
+ return nativeEvent.clientY + BrowserEnv.currentPageScrollTop;
7171
7228
  }
7172
- var dispatchListener = abstractEvent._dispatchListeners;
7173
- var dispatchID = abstractEvent._dispatchIDs;
7174
- invariant(
7175
- !Array.isArray(dispatchListener),
7176
- 'executeDirectDispatch(...): Invalid `abstractEvent`.'
7177
- );
7178
- var res = dispatchListener ?
7179
- dispatchListener(abstractEvent, dispatchID) :
7180
- null;
7181
- abstractEvent._dispatchListeners = null;
7182
- abstractEvent._dispatchIDs = null;
7183
- return res;
7184
- }
7229
+ };
7185
7230
 
7186
7231
  /**
7187
- * @param {AbstractEvent} abstractEvent
7188
- * @returns {bool} True iff number of dispatches accumulated is greater than 0.
7232
+ * @see `AbstractEvent.eventPageY`.
7233
+ *
7234
+ * @param {Event} nativeEvent Native event, possibly touch or mouse.
7235
+ * @return {number} Coordinate with respect to document body.
7189
7236
  */
7190
- function hasDispatches(abstractEvent) {
7191
- return !!abstractEvent._dispatchListeners;
7192
- }
7237
+ AbstractEvent.eventPageX = function(nativeEvent) {
7238
+ var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
7239
+ if (singleTouch) {
7240
+ return singleTouch.pageX;
7241
+ } else if (typeof nativeEvent.pageX !== 'undefined') {
7242
+ return nativeEvent.pageX;
7243
+ } else {
7244
+ return nativeEvent.clientX + BrowserEnv.currentPageScrollLeft;
7245
+ }
7246
+ };
7193
7247
 
7194
7248
  /**
7195
- * General utilities that are useful in creating custom Event Plugins.
7249
+ * A semantic API around cloning an event for use in another event loop. We
7250
+ * clear out all dispatched `AbstractEvent`s after each event loop, adding them
7251
+ * back into the pool. This allows a way to hold onto a reference that won't be
7252
+ * added back into the pool. Please note that `AbstractEvent.nativeEvent` is
7253
+ * *not* cloned and you will run into problems in IE if you assume that it will
7254
+ * be! The moral of that story is to always normalize any data you need into the
7255
+ * `.data` field. The data field is not cloned either, but there won't be any
7256
+ * issues related to use of `.data` in a future event cycle so long as no part
7257
+ * of your application mutates it. We don't clone the private fields because
7258
+ * your application should never be accessing them.
7259
+ *
7260
+ * - TODO: In __DEV__ when "releasing" events, don't put them back into the
7261
+ * pool. Instead add ES5 getters on all their fields that throw errors so you
7262
+ * can detect any application that's hanging onto events and reusing them.
7263
+ * In prod - we can put them back into the pool for reuse.
7196
7264
  */
7197
- var EventPluginUtils = {
7198
- isEndish: isEndish,
7199
- isMoveish: isMoveish,
7200
- isStartish: isStartish,
7201
- storePageCoordsIn: storePageCoordsIn,
7202
- eventDistance: eventDistance,
7203
- executeDispatchesInOrder: executeDispatchesInOrder,
7204
- executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
7205
- executeDirectDispatch: executeDirectDispatch,
7206
- hasDispatches: hasDispatches,
7207
- executeDispatch: executeDispatch
7265
+ AbstractEvent.persistentCloneOf = function(abstractEvent) {
7266
+ if (true) {
7267
+ throwIf(!(abstractEvent instanceof AbstractEvent), CLONE_TYPE_ERR);
7268
+ }
7269
+ return new AbstractEvent(
7270
+ abstractEvent.type,
7271
+ abstractEvent.abstractTargetID,
7272
+ abstractEvent.originatingTopLevelEventType,
7273
+ abstractEvent.nativeEvent,
7274
+ abstractEvent.data,
7275
+ abstractEvent.target
7276
+ );
7208
7277
  };
7209
7278
 
7210
- module.exports = EventPluginUtils;
7279
+ module.exports = AbstractEvent;
7211
7280
 
7212
- },{"./EventConstants":47,"./AbstractEvent":53,"./invariant":10}],56:[function(require,module,exports){
7281
+
7282
+ },{"./BrowserEnv":46,"./PooledClass":37,"./TouchEventUtils":67,"./throwIf":31}],55:[function(require,module,exports){
7213
7283
  /**
7214
7284
  * Copyright 2013 Facebook, Inc.
7215
7285
  *
@@ -7225,341 +7295,271 @@ module.exports = EventPluginUtils;
7225
7295
  * See the License for the specific language governing permissions and
7226
7296
  * limitations under the License.
7227
7297
  *
7228
- * @providesModule accumulate
7298
+ * @providesModule EventPluginUtils
7229
7299
  */
7230
7300
 
7231
7301
  "use strict";
7232
7302
 
7233
- var throwIf = require("./throwIf");
7303
+ var EventConstants = require("./EventConstants");
7304
+ var AbstractEvent = require("./AbstractEvent");
7234
7305
 
7235
- var INVALID_ARGS = 'INVALID_ACCUM_ARGS';
7306
+ var invariant = require("./invariant");
7236
7307
 
7237
- if (true) {
7238
- INVALID_ARGS =
7239
- 'accumulate requires non empty (non-null, defined) next ' +
7240
- 'values. All arrays accumulated must not contain any empty items.';
7241
- }
7308
+ var topLevelTypes = EventConstants.topLevelTypes;
7242
7309
 
7243
- /**
7244
- * Accumulates items that must never be empty, into a result in a manner that
7245
- * conserves memory - avoiding allocation of arrays until they are needed. The
7246
- * accumulation may start and/or end up being a single element or an array
7247
- * depending on the total count (if greater than one, an array is allocated).
7248
- * Handles most common case first (starting with an empty current value and
7249
- * acquiring one).
7250
- * @returns {Accumulation} An accumulation which is either a single item or an
7251
- * Array of items.
7252
- */
7253
- function accumulate(cur, next) {
7254
- var curValIsEmpty = cur == null; // Will test for emptiness (null/undef)
7255
- var nextValIsEmpty = next === null;
7256
- if (true) {
7257
- throwIf(nextValIsEmpty, INVALID_ARGS);
7258
- }
7259
- if (nextValIsEmpty) {
7260
- return cur;
7261
- } else {
7262
- if (curValIsEmpty) {
7263
- return next;
7264
- } else {
7265
- // Both are not empty. Warning: Never call x.concat(y) when you are not
7266
- // certain that x is an Array (x could be a string with concat method).
7267
- var curIsArray = Array.isArray(cur);
7268
- var nextIsArray = Array.isArray(next);
7269
- if (curIsArray) {
7270
- return cur.concat(next);
7271
- } else {
7272
- if (nextIsArray) {
7273
- return [cur].concat(next);
7274
- } else {
7275
- return [cur, next];
7276
- }
7277
- }
7278
- }
7279
- }
7310
+ function isEndish(topLevelType) {
7311
+ return topLevelType === topLevelTypes.topMouseUp ||
7312
+ topLevelType === topLevelTypes.topTouchEnd ||
7313
+ topLevelType === topLevelTypes.topTouchCancel;
7280
7314
  }
7281
7315
 
7282
- module.exports = accumulate;
7283
-
7284
- },{"./throwIf":31}],53:[function(require,module,exports){
7285
- /**
7286
- * Copyright 2013 Facebook, Inc.
7287
- *
7288
- * Licensed under the Apache License, Version 2.0 (the "License");
7289
- * you may not use this file except in compliance with the License.
7290
- * You may obtain a copy of the License at
7291
- *
7292
- * http://www.apache.org/licenses/LICENSE-2.0
7293
- *
7294
- * Unless required by applicable law or agreed to in writing, software
7295
- * distributed under the License is distributed on an "AS IS" BASIS,
7296
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7297
- * See the License for the specific language governing permissions and
7298
- * limitations under the License.
7299
- *
7300
- * @providesModule AbstractEvent
7301
- */
7302
-
7303
- "use strict";
7304
-
7305
- var BrowserEnv = require("./BrowserEnv");
7306
- var PooledClass = require("./PooledClass");
7307
- var TouchEventUtils = require("./TouchEventUtils");
7308
-
7309
- var throwIf = require("./throwIf");
7316
+ function isMoveish(topLevelType) {
7317
+ return topLevelType === topLevelTypes.topMouseMove ||
7318
+ topLevelType === topLevelTypes.topTouchMove;
7319
+ }
7320
+ function isStartish(topLevelType) {
7321
+ return topLevelType === topLevelTypes.topMouseDown ||
7322
+ topLevelType === topLevelTypes.topTouchStart;
7323
+ }
7310
7324
 
7325
+ function storePageCoordsIn(obj, nativeEvent) {
7326
+ var pageX = AbstractEvent.eventPageX(nativeEvent);
7327
+ var pageY = AbstractEvent.eventPageY(nativeEvent);
7328
+ obj.pageX = pageX;
7329
+ obj.pageY = pageY;
7330
+ }
7311
7331
 
7312
- // Only accessed in __DEV__
7313
- var CLONE_TYPE_ERR;
7314
- if (true) {
7315
- CLONE_TYPE_ERR =
7316
- 'You may only clone instances of AbstractEvent for ' +
7317
- 'persistent references. Check yourself.';
7332
+ function eventDistance(coords, nativeEvent) {
7333
+ var pageX = AbstractEvent.eventPageX(nativeEvent);
7334
+ var pageY = AbstractEvent.eventPageY(nativeEvent);
7335
+ return Math.pow(
7336
+ Math.pow(pageX - coords.pageX, 2) + Math.pow(pageY - coords.pageY, 2),
7337
+ 0.5
7338
+ );
7318
7339
  }
7319
- var MAX_POOL_SIZE = 20;
7320
7340
 
7321
- /**
7322
- * AbstractEvent copy constructor. @see `PooledClass`. Provides a single place
7323
- * to define all cross browser normalization of DOM events. Does not attempt to
7324
- * extend a native event, rather creates a completely new object that has a
7325
- * reference to the nativeEvent through .nativeEvent member. The property .data
7326
- * should hold all data that is extracted from the event in a cross browser
7327
- * manner. Application code should use the data field when possible, not the
7328
- * unreliable native event.
7329
- */
7330
- function AbstractEvent(
7331
- abstractEventType,
7332
- abstractTargetID, // Allows the abstract target to differ from native.
7333
- originatingTopLevelEventType,
7334
- nativeEvent,
7335
- data) {
7336
- this.type = abstractEventType;
7337
- this.abstractTargetID = abstractTargetID || '';
7338
- this.originatingTopLevelEventType = originatingTopLevelEventType;
7339
- this.nativeEvent = nativeEvent;
7340
- this.data = data;
7341
- // TODO: Deprecate storing target - doesn't always make sense for some types
7342
- this.target = nativeEvent && nativeEvent.target;
7341
+ var validateEventDispatches;
7342
+ if (true) {
7343
+ validateEventDispatches = function(abstractEvent) {
7344
+ var dispatchListeners = abstractEvent._dispatchListeners;
7345
+ var dispatchIDs = abstractEvent._dispatchIDs;
7343
7346
 
7344
- /**
7345
- * As a performance optimization, we tag the existing event with the listeners
7346
- * (or listener [singular] if only one). This avoids having to package up an
7347
- * abstract event along with the set of listeners into a wrapping "dispatch"
7348
- * object. No one should ever read this property except event system and
7349
- * plugin/dispatcher code. We also tag the abstract event with a parallel
7350
- * ID array. _dispatchListeners[i] is being dispatched to a DOM node at ID
7351
- * _dispatchIDs[i]. The lengths should never, ever, ever be different.
7352
- */
7353
- this._dispatchListeners = null;
7354
- this._dispatchIDs = null;
7347
+ var listenersIsArr = Array.isArray(dispatchListeners);
7348
+ var idsIsArr = Array.isArray(dispatchIDs);
7349
+ var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
7350
+ var listenersLen = listenersIsArr ?
7351
+ dispatchListeners.length :
7352
+ dispatchListeners ? 1 : 0;
7355
7353
 
7356
- this.isPropagationStopped = false;
7354
+ invariant(
7355
+ idsIsArr === listenersIsArr && IDsLen === listenersLen,
7356
+ 'EventPluginUtils: Invalid `abstractEvent`.'
7357
+ );
7358
+ };
7357
7359
  }
7358
7360
 
7359
- /** `PooledClass` looks for this. */
7360
- AbstractEvent.poolSize = MAX_POOL_SIZE;
7361
-
7362
- /**
7363
- * `PooledClass` looks for `destructor` on each instance it releases. We need to
7364
- * ensure that we remove all references to listeners which could trap large
7365
- * amounts of memory in their closures.
7366
- */
7367
- AbstractEvent.prototype.destructor = function() {
7368
- this.target = null;
7369
- this._dispatchListeners = null;
7370
- this._dispatchIDs = null;
7371
- };
7372
-
7373
7361
  /**
7374
- * Enhance the `AbstractEvent` class to have pooling abilities. We instruct
7375
- * `PooledClass` that our copy constructor accepts five arguments (this is just
7376
- * a performance optimization). These objects are instantiated frequently.
7362
+ * Invokes `cb(abstractEvent, listener, id)`. Avoids using call if no scope is
7363
+ * provided. The `(listener,id)` pair effectively forms the "dispatch" but are
7364
+ * kept separate to conserve memory.
7377
7365
  */
7378
- PooledClass.addPoolingTo(AbstractEvent, PooledClass.fiveArgumentPooler);
7379
-
7380
- AbstractEvent.prototype.stopPropagation = function() {
7381
- this.isPropagationStopped = true;
7382
- if (this.nativeEvent.stopPropagation) {
7383
- this.nativeEvent.stopPropagation();
7366
+ function forEachEventDispatch(abstractEvent, cb) {
7367
+ var dispatchListeners = abstractEvent._dispatchListeners;
7368
+ var dispatchIDs = abstractEvent._dispatchIDs;
7369
+ if (true) {
7370
+ validateEventDispatches(abstractEvent);
7384
7371
  }
7385
- // IE8 only understands cancelBubble, not stopPropagation().
7386
- this.nativeEvent.cancelBubble = true;
7387
- };
7388
-
7389
- AbstractEvent.prototype.preventDefault = function() {
7390
- AbstractEvent.preventDefaultOnNativeEvent(this.nativeEvent);
7391
- };
7372
+ if (Array.isArray(dispatchListeners)) {
7373
+ var i;
7374
+ for (
7375
+ i = 0;
7376
+ i < dispatchListeners.length && !abstractEvent.isPropagationStopped;
7377
+ i++) {
7378
+ // Listeners and IDs are two parallel arrays that are always in sync.
7379
+ cb(abstractEvent, dispatchListeners[i], dispatchIDs[i]);
7380
+ }
7381
+ } else if (dispatchListeners) {
7382
+ cb(abstractEvent, dispatchListeners, dispatchIDs);
7383
+ }
7384
+ }
7392
7385
 
7393
7386
  /**
7394
- * Utility function for preventing default in cross browser manner.
7387
+ * Default implementation of PluginModule.executeDispatch().
7388
+ * @param {AbstractEvent} AbstractEvent to handle
7389
+ * @param {function} Application-level callback
7390
+ * @param {string} domID DOM id to pass to the callback.
7395
7391
  */
7396
- AbstractEvent.preventDefaultOnNativeEvent = function(nativeEvent) {
7397
- if (nativeEvent.preventDefault) {
7398
- nativeEvent.preventDefault();
7399
- } else {
7400
- nativeEvent.returnValue = false;
7401
- }
7402
- };
7392
+ function executeDispatch(abstractEvent, listener, domID) {
7393
+ listener(abstractEvent, domID);
7394
+ }
7403
7395
 
7404
7396
  /**
7405
- * @param {Element} target The target element.
7397
+ * Standard/simple iteration through an event's collected dispatches.
7406
7398
  */
7407
- AbstractEvent.normalizeScrollDataFromTarget = function(target) {
7408
- return {
7409
- scrollTop: target.scrollTop,
7410
- scrollLeft: target.scrollLeft,
7411
- clientWidth: target.clientWidth,
7412
- clientHeight: target.clientHeight,
7413
- scrollHeight: target.scrollHeight,
7414
- scrollWidth: target.scrollWidth
7415
- };
7416
- };
7399
+ function executeDispatchesInOrder(abstractEvent, executeDispatch) {
7400
+ forEachEventDispatch(abstractEvent, executeDispatch);
7401
+ abstractEvent._dispatchListeners = null;
7402
+ abstractEvent._dispatchIDs = null;
7403
+ }
7417
7404
 
7418
- /*
7419
- * There are some normalizations that need to happen for various browsers. In
7420
- * addition to replacing the general event fixing with a framework such as
7421
- * jquery, we need to normalize mouse events here. Code below is mostly borrowed
7422
- * from: jScrollPane/script/jquery.mousewheel.js
7405
+ /**
7406
+ * Standard/simple iteration through an event's collected dispatches, but stops
7407
+ * at the first dispatch execution returning true, and returns that id.
7408
+ *
7409
+ * @returns id of the first dispatch execution who's listener returns true, or
7410
+ * null if no listener returned true.
7423
7411
  */
7424
- AbstractEvent.normalizeMouseWheelData = function(nativeEvent) {
7425
- var delta = 0;
7426
- var deltaX = 0;
7427
- var deltaY = 0;
7428
-
7429
- /* traditional scroll wheel data */
7430
- if ( nativeEvent.wheelDelta ) { delta = nativeEvent.wheelDelta/120; }
7431
- if ( nativeEvent.detail ) { delta = -nativeEvent.detail/3; }
7432
-
7433
- /* Multidimensional scroll (touchpads) with deltas */
7434
- deltaY = delta;
7435
-
7436
- /* Gecko based browsers */
7437
- if (nativeEvent.axis !== undefined &&
7438
- nativeEvent.axis === nativeEvent.HORIZONTAL_AXIS ) {
7439
- deltaY = 0;
7440
- deltaX = -delta;
7441
- }
7442
-
7443
- /* Webkit based browsers */
7444
- if (nativeEvent.wheelDeltaY !== undefined ) {
7445
- deltaY = nativeEvent.wheelDeltaY/120;
7412
+ function executeDispatchesInOrderStopAtTrue(abstractEvent) {
7413
+ var dispatchListeners = abstractEvent._dispatchListeners;
7414
+ var dispatchIDs = abstractEvent._dispatchIDs;
7415
+ if (true) {
7416
+ validateEventDispatches(abstractEvent);
7446
7417
  }
7447
- if (nativeEvent.wheelDeltaX !== undefined ) {
7448
- deltaX = -nativeEvent.wheelDeltaX/120;
7418
+ if (Array.isArray(dispatchListeners)) {
7419
+ var i;
7420
+ for (
7421
+ i = 0;
7422
+ i < dispatchListeners.length && !abstractEvent.isPropagationStopped;
7423
+ i++) {
7424
+ // Listeners and IDs are two parallel arrays that are always in sync.
7425
+ if (dispatchListeners[i](abstractEvent, dispatchIDs[i])) {
7426
+ return dispatchIDs[i];
7427
+ }
7428
+ }
7429
+ } else if (dispatchListeners) {
7430
+ if (dispatchListeners(abstractEvent, dispatchIDs)) {
7431
+ return dispatchIDs;
7432
+ }
7449
7433
  }
7450
-
7451
- return { delta: delta, deltaX: deltaX, deltaY: deltaY };
7452
- };
7434
+ return null;
7435
+ }
7453
7436
 
7454
7437
  /**
7455
- * I <3 Quirksmode.org:
7456
- * http://www.quirksmode.org/js/events_properties.html
7438
+ * Execution of a "direct" dispatch - there must be at most one dispatch
7439
+ * accumulated on the event or it is considered an error. It doesn't really make
7440
+ * sense for an event with multiple dispatches (bubbled) to keep track of the
7441
+ * return values at each dispatch execution, but it does tend to make sense when
7442
+ * dealing with "direct" dispatches.
7443
+ *
7444
+ * @returns The return value of executing the single dispatch.
7457
7445
  */
7458
- AbstractEvent.isNativeClickEventRightClick = function(nativeEvent) {
7459
- return nativeEvent.which ? nativeEvent.which === 3 :
7460
- nativeEvent.button ? nativeEvent.button === 2 :
7461
- false;
7462
- };
7463
-
7464
- AbstractEvent.normalizePointerData = function(nativeEvent) {
7465
- return {
7466
- globalX: AbstractEvent.eventPageX(nativeEvent),
7467
- globalY: AbstractEvent.eventPageY(nativeEvent),
7468
- rightMouseButton:
7469
- AbstractEvent.isNativeClickEventRightClick(nativeEvent)
7470
- };
7471
- };
7472
-
7473
- AbstractEvent.normalizeDragEventData =
7474
- function(nativeEvent, globalX, globalY, startX, startY) {
7475
- return {
7476
- globalX: globalX,
7477
- globalY: globalY,
7478
- startX: startX,
7479
- startY: startY
7480
- };
7481
- };
7446
+ function executeDirectDispatch(abstractEvent) {
7447
+ if (true) {
7448
+ validateEventDispatches(abstractEvent);
7449
+ }
7450
+ var dispatchListener = abstractEvent._dispatchListeners;
7451
+ var dispatchID = abstractEvent._dispatchIDs;
7452
+ invariant(
7453
+ !Array.isArray(dispatchListener),
7454
+ 'executeDirectDispatch(...): Invalid `abstractEvent`.'
7455
+ );
7456
+ var res = dispatchListener ?
7457
+ dispatchListener(abstractEvent, dispatchID) :
7458
+ null;
7459
+ abstractEvent._dispatchListeners = null;
7460
+ abstractEvent._dispatchIDs = null;
7461
+ return res;
7462
+ }
7482
7463
 
7483
7464
  /**
7484
- * Warning: It is possible to move your finger on a touch surface, yet not
7485
- * effect the `eventPageX/Y` because the touch had caused a scroll that
7486
- * compensated for your movement. To track movements across the page, prevent
7487
- * default to avoid scrolling, and control scrolling in javascript.
7465
+ * @param {AbstractEvent} abstractEvent
7466
+ * @returns {bool} True iff number of dispatches accumulated is greater than 0.
7488
7467
  */
7468
+ function hasDispatches(abstractEvent) {
7469
+ return !!abstractEvent._dispatchListeners;
7470
+ }
7489
7471
 
7490
7472
  /**
7491
- * Gets the exact position of a touch/mouse event on the page with respect to
7492
- * the document body. The only reason why this method is needed instead of using
7493
- * `TouchEventUtils.extractSingleTouch` is to support IE8-. Mouse events in all
7494
- * browsers except IE8- contain a pageY. IE8 and below require clientY
7495
- * computation:
7496
- *
7497
- * @param {Event} nativeEvent Native event, possibly touch or mouse.
7498
- * @return {number} Coordinate with respect to document body.
7473
+ * General utilities that are useful in creating custom Event Plugins.
7499
7474
  */
7500
- AbstractEvent.eventPageY = function(nativeEvent) {
7501
- var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
7502
- if (singleTouch) {
7503
- return singleTouch.pageY;
7504
- } else if (typeof nativeEvent.pageY !== 'undefined') {
7505
- return nativeEvent.pageY;
7506
- } else {
7507
- return nativeEvent.clientY + BrowserEnv.currentPageScrollTop;
7508
- }
7475
+ var EventPluginUtils = {
7476
+ isEndish: isEndish,
7477
+ isMoveish: isMoveish,
7478
+ isStartish: isStartish,
7479
+ storePageCoordsIn: storePageCoordsIn,
7480
+ eventDistance: eventDistance,
7481
+ executeDispatchesInOrder: executeDispatchesInOrder,
7482
+ executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
7483
+ executeDirectDispatch: executeDirectDispatch,
7484
+ hasDispatches: hasDispatches,
7485
+ executeDispatch: executeDispatch
7509
7486
  };
7510
7487
 
7488
+ module.exports = EventPluginUtils;
7489
+
7490
+ },{"./EventConstants":47,"./AbstractEvent":53,"./invariant":10}],56:[function(require,module,exports){
7511
7491
  /**
7512
- * @see `AbstractEvent.eventPageY`.
7492
+ * Copyright 2013 Facebook, Inc.
7513
7493
  *
7514
- * @param {Event} nativeEvent Native event, possibly touch or mouse.
7515
- * @return {number} Coordinate with respect to document body.
7494
+ * Licensed under the Apache License, Version 2.0 (the "License");
7495
+ * you may not use this file except in compliance with the License.
7496
+ * You may obtain a copy of the License at
7497
+ *
7498
+ * http://www.apache.org/licenses/LICENSE-2.0
7499
+ *
7500
+ * Unless required by applicable law or agreed to in writing, software
7501
+ * distributed under the License is distributed on an "AS IS" BASIS,
7502
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7503
+ * See the License for the specific language governing permissions and
7504
+ * limitations under the License.
7505
+ *
7506
+ * @providesModule accumulate
7516
7507
  */
7517
- AbstractEvent.eventPageX = function(nativeEvent) {
7518
- var singleTouch = TouchEventUtils.extractSingleTouch(nativeEvent);
7519
- if (singleTouch) {
7520
- return singleTouch.pageX;
7521
- } else if (typeof nativeEvent.pageX !== 'undefined') {
7522
- return nativeEvent.pageX;
7523
- } else {
7524
- return nativeEvent.clientX + BrowserEnv.currentPageScrollLeft;
7525
- }
7526
- };
7508
+
7509
+ "use strict";
7510
+
7511
+ var throwIf = require("./throwIf");
7512
+
7513
+ var INVALID_ARGS = 'INVALID_ACCUM_ARGS';
7514
+
7515
+ if (true) {
7516
+ INVALID_ARGS =
7517
+ 'accumulate requires non empty (non-null, defined) next ' +
7518
+ 'values. All arrays accumulated must not contain any empty items.';
7519
+ }
7527
7520
 
7528
7521
  /**
7529
- * A semantic API around cloning an event for use in another event loop. We
7530
- * clear out all dispatched `AbstractEvent`s after each event loop, adding them
7531
- * back into the pool. This allows a way to hold onto a reference that won't be
7532
- * added back into the pool. Please note that `AbstractEvent.nativeEvent` is
7533
- * *not* cloned and you will run into problems in IE if you assume that it will
7534
- * be! The moral of that story is to always normalize any data you need into the
7535
- * `.data` field. The data field is not cloned either, but there won't be any
7536
- * issues related to use of `.data` in a future event cycle so long as no part
7537
- * of your application mutates it. We don't clone the private fields because
7538
- * your application should never be accessing them.
7539
- *
7540
- * - TODO: In __DEV__ when "releasing" events, don't put them back into the
7541
- * pool. Instead add ES5 getters on all their fields that throw errors so you
7542
- * can detect any application that's hanging onto events and reusing them.
7543
- * In prod - we can put them back into the pool for reuse.
7522
+ * Accumulates items that must never be empty, into a result in a manner that
7523
+ * conserves memory - avoiding allocation of arrays until they are needed. The
7524
+ * accumulation may start and/or end up being a single element or an array
7525
+ * depending on the total count (if greater than one, an array is allocated).
7526
+ * Handles most common case first (starting with an empty current value and
7527
+ * acquiring one).
7528
+ * @returns {Accumulation} An accumulation which is either a single item or an
7529
+ * Array of items.
7544
7530
  */
7545
- AbstractEvent.persistentCloneOf = function(abstractEvent) {
7531
+ function accumulate(cur, next) {
7532
+ var curValIsEmpty = cur == null; // Will test for emptiness (null/undef)
7533
+ var nextValIsEmpty = next === null;
7546
7534
  if (true) {
7547
- throwIf(!(abstractEvent instanceof AbstractEvent), CLONE_TYPE_ERR);
7535
+ throwIf(nextValIsEmpty, INVALID_ARGS);
7548
7536
  }
7549
- return new AbstractEvent(
7550
- abstractEvent.type,
7551
- abstractEvent.abstractTargetID,
7552
- abstractEvent.originatingTopLevelEventType,
7553
- abstractEvent.nativeEvent,
7554
- abstractEvent.data,
7555
- abstractEvent.target
7556
- );
7557
- };
7558
-
7559
- module.exports = AbstractEvent;
7537
+ if (nextValIsEmpty) {
7538
+ return cur;
7539
+ } else {
7540
+ if (curValIsEmpty) {
7541
+ return next;
7542
+ } else {
7543
+ // Both are not empty. Warning: Never call x.concat(y) when you are not
7544
+ // certain that x is an Array (x could be a string with concat method).
7545
+ var curIsArray = Array.isArray(cur);
7546
+ var nextIsArray = Array.isArray(next);
7547
+ if (curIsArray) {
7548
+ return cur.concat(next);
7549
+ } else {
7550
+ if (nextIsArray) {
7551
+ return [cur].concat(next);
7552
+ } else {
7553
+ return [cur, next];
7554
+ }
7555
+ }
7556
+ }
7557
+ }
7558
+ }
7560
7559
 
7560
+ module.exports = accumulate;
7561
7561
 
7562
- },{"./BrowserEnv":46,"./TouchEventUtils":67,"./throwIf":31,"./PooledClass":37}],58:[function(require,module,exports){
7562
+ },{"./throwIf":31}],58:[function(require,module,exports){
7563
7563
  /**
7564
7564
  * Copyright 2013 Facebook, Inc.
7565
7565
  *