1 |
|
2 | (function(exports, global, doEval) {
|
3 |
|
4 | var origDefine = global.define;
|
5 |
|
6 | var get = function(name) {
|
7 | var parts = name.split("."),
|
8 | cur = global,
|
9 | i;
|
10 | for (i = 0; i < parts.length; i++) {
|
11 | if (!cur) {
|
12 | break;
|
13 | }
|
14 | cur = cur[parts[i]];
|
15 | }
|
16 | return cur;
|
17 | };
|
18 | var set = function(name, val) {
|
19 | var parts = name.split("."),
|
20 | cur = global,
|
21 | i,
|
22 | part,
|
23 | next;
|
24 | for (i = 0; i < parts.length - 1; i++) {
|
25 | part = parts[i];
|
26 | next = cur[part];
|
27 | if (!next) {
|
28 | next = cur[part] = {};
|
29 | }
|
30 | cur = next;
|
31 | }
|
32 | part = parts[parts.length - 1];
|
33 | cur[part] = val;
|
34 | };
|
35 | var useDefault = function(mod) {
|
36 | if (!mod || !mod.__esModule) return false;
|
37 | var esProps = { __esModule: true, default: true };
|
38 | for (var p in mod) {
|
39 | if (!esProps[p]) return false;
|
40 | }
|
41 | return true;
|
42 | };
|
43 |
|
44 | var hasCjsDependencies = function(deps) {
|
45 | return (
|
46 | deps[0] === "require" && deps[1] === "exports" && deps[2] === "module"
|
47 | );
|
48 | };
|
49 |
|
50 | var modules =
|
51 | (global.define && global.define.modules) ||
|
52 | (global._define && global._define.modules) ||
|
53 | {};
|
54 | var ourDefine = (global.define = function(moduleName, deps, callback) {
|
55 | var module;
|
56 | if (typeof deps === "function") {
|
57 | callback = deps;
|
58 | deps = [];
|
59 | }
|
60 | var args = [],
|
61 | i;
|
62 | for (i = 0; i < deps.length; i++) {
|
63 | args.push(
|
64 | exports[deps[i]]
|
65 | ? get(exports[deps[i]])
|
66 | : modules[deps[i]] || get(deps[i])
|
67 | );
|
68 | }
|
69 | // CJS has no dependencies but 3 callback arguments
|
70 | if (hasCjsDependencies(deps) || (!deps.length && callback.length)) {
|
71 | module = { exports: {} };
|
72 | args[0] = function(name) {
|
73 | return exports[name] ? get(exports[name]) : modules[name];
|
74 | };
|
75 | args[1] = module.exports;
|
76 | args[2] = module;
|
77 | } else if (!args[0] && deps[0] === "exports") {
|
78 |
|
79 | module = { exports: {} };
|
80 | args[0] = module.exports;
|
81 | if (deps[1] === "module") {
|
82 | args[1] = module;
|
83 | }
|
84 | } else if (!args[0] && deps[0] === "module") {
|
85 | args[0] = { id: moduleName };
|
86 | }
|
87 |
|
88 | global.define = origDefine;
|
89 | var result = callback ? callback.apply(null, args) : undefined;
|
90 | global.define = ourDefine;
|
91 |
|
92 |
|
93 | result = module && module.exports ? module.exports : result;
|
94 | modules[moduleName] = result;
|
95 |
|
96 |
|
97 | var globalExport = exports[moduleName];
|
98 | if (globalExport && !get(globalExport)) {
|
99 | if (useDefault(result)) {
|
100 | result = result["default"];
|
101 | }
|
102 | set(globalExport, result);
|
103 | }
|
104 | });
|
105 | global.define.orig = origDefine;
|
106 | global.define.modules = modules;
|
107 | global.define.amd = true;
|
108 | ourDefine("@loader", [], function() {
|
109 |
|
110 | var noop = function() {};
|
111 | return {
|
112 | get: function() {
|
113 | return { prepareGlobal: noop, retrieveGlobal: noop };
|
114 | },
|
115 | global: global,
|
116 | __exec: function(__load) {
|
117 | doEval(__load.source, global);
|
118 | }
|
119 | };
|
120 | });
|
121 | })(
|
122 | {},
|
123 | typeof self == "object" && self.Object == Object ? self : window,
|
124 | function(__$source__, __$global__) {
|
125 |
|
126 | eval("(function() { " + __$source__ + " \n }).call(__$global__);");
|
127 | }
|
128 | );
|
129 |
|
130 |
|
131 | define('syn/synthetic', function (require, exports, module) {
|
132 | var opts = window.syn ? window.syn : {};
|
133 | var extend = function (d, s) {
|
134 | var p;
|
135 | for (p in s) {
|
136 | d[p] = s[p];
|
137 | }
|
138 | return d;
|
139 | }, browser = {
|
140 | msie: !!(window.attachEvent && !window.opera) || navigator.userAgent.indexOf('Trident/') > -1,
|
141 | opera: !!window.opera,
|
142 | webkit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
|
143 | safari: navigator.userAgent.indexOf('AppleWebKit/') > -1 && navigator.userAgent.indexOf('Chrome/') === -1,
|
144 | gecko: navigator.userAgent.indexOf('Gecko') > -1,
|
145 | mobilesafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/),
|
146 | rhino: navigator.userAgent.match(/Rhino/) && true,
|
147 | chrome: !!window.chrome && !!window.chrome.webstore
|
148 | }, createEventObject = function (type, options, element) {
|
149 | var event = element.ownerDocument.createEventObject();
|
150 | return extend(event, options);
|
151 | }, data = {}, id = 1, expando = '_synthetic' + new Date().getTime(), bind, unbind, schedule, key = /keypress|keyup|keydown/, page = /load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll/, activeElement, syn = function (type, element, options, callback) {
|
152 | return new syn.init(type, element, options, callback);
|
153 | };
|
154 | syn.config = opts;
|
155 | syn.__tryFocus = function tryFocus(element) {
|
156 | try {
|
157 | element.focus();
|
158 | } catch (e) {
|
159 | }
|
160 | };
|
161 | bind = function (el, ev, f) {
|
162 | return el.addEventListener ? el.addEventListener(ev, f, false) : el.attachEvent('on' + ev, f);
|
163 | };
|
164 | unbind = function (el, ev, f) {
|
165 | return el.addEventListener ? el.removeEventListener(ev, f, false) : el.detachEvent('on' + ev, f);
|
166 | };
|
167 | schedule = syn.config.schedule || function (fn, ms) {
|
168 | setTimeout(fn, ms);
|
169 | };
|
170 | extend(syn, {
|
171 | init: function (type, element, options, callback) {
|
172 | var args = syn.args(options, element, callback), self = this;
|
173 | this.queue = [];
|
174 | this.element = args.element;
|
175 | if (typeof this[type] === 'function') {
|
176 | this[type](args.element, args.options, function (defaults, el) {
|
177 | if (args.callback) {
|
178 | args.callback.apply(self, arguments);
|
179 | }
|
180 | self.done.apply(self, arguments);
|
181 | });
|
182 | } else {
|
183 | this.result = syn.trigger(args.element, type, args.options);
|
184 | if (args.callback) {
|
185 | args.callback.call(this, args.element, this.result);
|
186 | }
|
187 | }
|
188 | },
|
189 | jquery: function (el, fast) {
|
190 | if (window.FuncUnit && window.FuncUnit.jQuery) {
|
191 | return window.FuncUnit.jQuery;
|
192 | }
|
193 | if (el) {
|
194 | return syn.helpers.getWindow(el).jQuery || window.jQuery;
|
195 | } else {
|
196 | return window.jQuery;
|
197 | }
|
198 | },
|
199 | args: function () {
|
200 | var res = {}, i = 0;
|
201 | for (; i < arguments.length; i++) {
|
202 | if (typeof arguments[i] === 'function') {
|
203 | res.callback = arguments[i];
|
204 | } else if (arguments[i] && arguments[i].jquery) {
|
205 | res.element = arguments[i][0];
|
206 | } else if (arguments[i] && arguments[i].nodeName) {
|
207 | res.element = arguments[i];
|
208 | } else if (res.options && typeof arguments[i] === 'string') {
|
209 | res.element = document.getElementById(arguments[i]);
|
210 | } else if (arguments[i]) {
|
211 | res.options = arguments[i];
|
212 | }
|
213 | }
|
214 | return res;
|
215 | },
|
216 | click: function (element, options, callback) {
|
217 | syn('click!', element, options, callback);
|
218 | },
|
219 | defaults: {
|
220 | focus: function focus() {
|
221 | if (!syn.support.focusChanges) {
|
222 | var element = this, nodeName = element.nodeName.toLowerCase();
|
223 | syn.data(element, 'syntheticvalue', element.value);
|
224 | if (nodeName === 'input' || nodeName === 'textarea') {
|
225 | bind(element, 'blur', function blur() {
|
226 | if (syn.data(element, 'syntheticvalue') !== element.value) {
|
227 | syn.trigger(element, 'change', {});
|
228 | }
|
229 | unbind(element, 'blur', blur);
|
230 | });
|
231 | }
|
232 | }
|
233 | },
|
234 | submit: function () {
|
235 | syn.onParents(this, function (el) {
|
236 | if (el.nodeName.toLowerCase() === 'form') {
|
237 | el.submit();
|
238 | return false;
|
239 | }
|
240 | });
|
241 | }
|
242 | },
|
243 | changeOnBlur: function (element, prop, value) {
|
244 | bind(element, 'blur', function onblur() {
|
245 | if (value !== element[prop]) {
|
246 | syn.trigger(element, 'change', {});
|
247 | }
|
248 | unbind(element, 'blur', onblur);
|
249 | });
|
250 | },
|
251 | closest: function (el, type) {
|
252 | while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
|
253 | el = el.parentNode;
|
254 | }
|
255 | return el;
|
256 | },
|
257 | data: function (el, key, value) {
|
258 | var d;
|
259 | if (!el[expando]) {
|
260 | el[expando] = id++;
|
261 | }
|
262 | if (!data[el[expando]]) {
|
263 | data[el[expando]] = {};
|
264 | }
|
265 | d = data[el[expando]];
|
266 | if (value) {
|
267 | data[el[expando]][key] = value;
|
268 | } else {
|
269 | return data[el[expando]][key];
|
270 | }
|
271 | },
|
272 | onParents: function (el, func) {
|
273 | var res;
|
274 | while (el && res !== false) {
|
275 | res = func(el);
|
276 | el = el.parentNode;
|
277 | }
|
278 | return el;
|
279 | },
|
280 | focusable: /^(a|area|frame|iframe|label|input|select|textarea|button|html|object)$/i,
|
281 | isFocusable: function (elem) {
|
282 | var attributeNode;
|
283 | if (elem.getAttributeNode) {
|
284 | attributeNode = elem.getAttributeNode('tabIndex');
|
285 | }
|
286 | return this.focusable.test(elem.nodeName) || attributeNode && attributeNode.specified && syn.isVisible(elem);
|
287 | },
|
288 | isVisible: function (elem) {
|
289 | return elem.offsetWidth && elem.offsetHeight || elem.clientWidth && elem.clientHeight;
|
290 | },
|
291 | tabIndex: function (elem) {
|
292 | var attributeNode = elem.getAttributeNode('tabIndex');
|
293 | return attributeNode && attributeNode.specified && (parseInt(elem.getAttribute('tabIndex')) || 0);
|
294 | },
|
295 | bind: bind,
|
296 | unbind: unbind,
|
297 | schedule: schedule,
|
298 | browser: browser,
|
299 | helpers: {
|
300 | createEventObject: createEventObject,
|
301 | createBasicStandardEvent: function (type, defaults, doc) {
|
302 | var event;
|
303 | try {
|
304 | event = doc.createEvent('Events');
|
305 | } catch (e2) {
|
306 | event = doc.createEvent('UIEvents');
|
307 | } finally {
|
308 | event.initEvent(type, true, true);
|
309 | extend(event, defaults);
|
310 | }
|
311 | return event;
|
312 | },
|
313 | inArray: function (item, array) {
|
314 | var i = 0;
|
315 | for (; i < array.length; i++) {
|
316 | if (array[i] === item) {
|
317 | return i;
|
318 | }
|
319 | }
|
320 | return -1;
|
321 | },
|
322 | getWindow: function (element) {
|
323 | if (element.ownerDocument) {
|
324 | return element.ownerDocument.defaultView || element.ownerDocument.parentWindow;
|
325 | }
|
326 | },
|
327 | extend: extend,
|
328 | scrollOffset: function (win, set) {
|
329 | var doc = win.document.documentElement, body = win.document.body;
|
330 | if (set) {
|
331 | window.scrollTo(set.left, set.top);
|
332 | } else {
|
333 | return {
|
334 | left: (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0),
|
335 | top: (doc && doc.scrollTop || body && body.scrollTop || 0) + (doc.clientTop || 0)
|
336 | };
|
337 | }
|
338 | },
|
339 | scrollDimensions: function (win) {
|
340 | var doc = win.document.documentElement, body = win.document.body, docWidth = doc.clientWidth, docHeight = doc.clientHeight, compat = win.document.compatMode === 'CSS1Compat';
|
341 | return {
|
342 | height: compat && docHeight || body.clientHeight || docHeight,
|
343 | width: compat && docWidth || body.clientWidth || docWidth
|
344 | };
|
345 | },
|
346 | addOffset: function (options, el) {
|
347 | var jq = syn.jquery(el), off;
|
348 | if (typeof options === 'object' && options.clientX === undefined && options.clientY === undefined && options.pageX === undefined && options.pageY === undefined && jq) {
|
349 | el = jq(el);
|
350 | off = el.offset();
|
351 | options.pageX = off.left + el.width() / 2;
|
352 | options.pageY = off.top + el.height() / 2;
|
353 | }
|
354 | }
|
355 | },
|
356 | key: {
|
357 | ctrlKey: null,
|
358 | altKey: null,
|
359 | shiftKey: null,
|
360 | metaKey: null
|
361 | },
|
362 | dispatch: function (event, element, type, autoPrevent) {
|
363 | if (element.dispatchEvent && event) {
|
364 | var preventDefault = event.preventDefault, prevents = autoPrevent ? -1 : 0;
|
365 | if (autoPrevent) {
|
366 | bind(element, type, function ontype(ev) {
|
367 | ev.preventDefault();
|
368 | unbind(this, type, ontype);
|
369 | });
|
370 | }
|
371 | event.preventDefault = function () {
|
372 | prevents++;
|
373 | if (++prevents > 0) {
|
374 | preventDefault.apply(this, []);
|
375 | }
|
376 | };
|
377 | element.dispatchEvent(event);
|
378 | return prevents <= 0;
|
379 | } else {
|
380 | try {
|
381 | window.event = event;
|
382 | } catch (e) {
|
383 | }
|
384 | return element.sourceIndex <= 0 || element.fireEvent && element.fireEvent('on' + type, event);
|
385 | }
|
386 | },
|
387 | create: {
|
388 | page: {
|
389 | event: function (type, options, element) {
|
390 | var doc = syn.helpers.getWindow(element).document || document, event;
|
391 | if (doc.createEvent) {
|
392 | event = doc.createEvent('Events');
|
393 | event.initEvent(type, true, true);
|
394 | return event;
|
395 | } else {
|
396 | try {
|
397 | event = createEventObject(type, options, element);
|
398 | } catch (e) {
|
399 | }
|
400 | return event;
|
401 | }
|
402 | }
|
403 | },
|
404 | focus: {
|
405 | event: function (type, options, element) {
|
406 | syn.onParents(element, function (el) {
|
407 | if (syn.isFocusable(el)) {
|
408 | if (el.nodeName.toLowerCase() !== 'html') {
|
409 | syn.__tryFocus(el);
|
410 | activeElement = el;
|
411 | } else if (activeElement) {
|
412 | var doc = syn.helpers.getWindow(element).document;
|
413 | if (doc !== window.document) {
|
414 | return false;
|
415 | } else if (doc.activeElement) {
|
416 | doc.activeElement.blur();
|
417 | activeElement = null;
|
418 | } else {
|
419 | activeElement.blur();
|
420 | activeElement = null;
|
421 | }
|
422 | }
|
423 | return false;
|
424 | }
|
425 | });
|
426 | return true;
|
427 | }
|
428 | }
|
429 | },
|
430 | support: {
|
431 | clickChanges: false,
|
432 | clickSubmits: false,
|
433 | keypressSubmits: false,
|
434 | mouseupSubmits: false,
|
435 | radioClickChanges: false,
|
436 | focusChanges: false,
|
437 | linkHrefJS: false,
|
438 | keyCharacters: false,
|
439 | backspaceWorks: false,
|
440 | mouseDownUpClicks: false,
|
441 | tabKeyTabs: false,
|
442 | keypressOnAnchorClicks: false,
|
443 | optionClickBubbles: false,
|
444 | pointerEvents: false,
|
445 | touchEvents: false,
|
446 | ready: 0
|
447 | },
|
448 | trigger: function (element, type, options) {
|
449 | if (!options) {
|
450 | options = {};
|
451 | }
|
452 | var create = syn.create, setup = create[type] && create[type].setup, kind = key.test(type) ? 'key' : page.test(type) ? 'page' : 'mouse', createType = create[type] || {}, createKind = create[kind], event, ret, autoPrevent, dispatchEl = element;
|
453 | if (syn.support.ready === 2 && setup) {
|
454 | setup(type, options, element);
|
455 | }
|
456 | autoPrevent = options._autoPrevent;
|
457 | delete options._autoPrevent;
|
458 | if (createType.event) {
|
459 | ret = createType.event(type, options, element);
|
460 | } else {
|
461 | options = createKind.options ? createKind.options(type, options, element) : options;
|
462 | if (!syn.support.changeBubbles && /option/i.test(element.nodeName)) {
|
463 | dispatchEl = element.parentNode;
|
464 | }
|
465 | event = createKind.event(type, options, dispatchEl);
|
466 | ret = syn.dispatch(event, dispatchEl, type, autoPrevent);
|
467 | }
|
468 | if (ret && syn.support.ready === 2 && syn.defaults[type]) {
|
469 | syn.defaults[type].call(element, options, autoPrevent);
|
470 | }
|
471 | return ret;
|
472 | },
|
473 | eventSupported: function (eventName) {
|
474 | var el = document.createElement('div');
|
475 | eventName = 'on' + eventName;
|
476 | var isSupported = eventName in el;
|
477 | if (!isSupported) {
|
478 | el.setAttribute(eventName, 'return;');
|
479 | isSupported = typeof el[eventName] === 'function';
|
480 | }
|
481 | el = null;
|
482 | return isSupported;
|
483 | }
|
484 | });
|
485 | extend(syn.init.prototype, {
|
486 | then: function (type, element, options, callback) {
|
487 | if (syn.autoDelay) {
|
488 | this.delay();
|
489 | }
|
490 | var args = syn.args(options, element, callback), self = this;
|
491 | this.queue.unshift(function (el, prevented) {
|
492 | if (typeof this[type] === 'function') {
|
493 | this.element = args.element || el;
|
494 | this[type](this.element, args.options, function (defaults, el) {
|
495 | if (args.callback) {
|
496 | args.callback.apply(self, arguments);
|
497 | }
|
498 | self.done.apply(self, arguments);
|
499 | });
|
500 | } else {
|
501 | this.result = syn.trigger(args.element, type, args.options);
|
502 | if (args.callback) {
|
503 | args.callback.call(this, args.element, this.result);
|
504 | }
|
505 | return this;
|
506 | }
|
507 | });
|
508 | return this;
|
509 | },
|
510 | delay: function (timeout, callback) {
|
511 | if (typeof timeout === 'function') {
|
512 | callback = timeout;
|
513 | timeout = null;
|
514 | }
|
515 | timeout = timeout || 600;
|
516 | var self = this;
|
517 | this.queue.unshift(function () {
|
518 | schedule(function () {
|
519 | if (callback) {
|
520 | callback.apply(self, []);
|
521 | }
|
522 | self.done.apply(self, arguments);
|
523 | }, timeout);
|
524 | });
|
525 | return this;
|
526 | },
|
527 | done: function (defaults, el) {
|
528 | if (el) {
|
529 | this.element = el;
|
530 | }
|
531 | if (this.queue.length) {
|
532 | this.queue.pop().call(this, this.element, defaults);
|
533 | }
|
534 | },
|
535 | '_click': function (element, options, callback, force) {
|
536 | syn.helpers.addOffset(options, element);
|
537 | if (syn.support.pointerEvents) {
|
538 | syn.trigger(element, 'pointerdown', options);
|
539 | }
|
540 | if (syn.support.touchEvents) {
|
541 | syn.trigger(element, 'touchstart', options);
|
542 | }
|
543 | syn.trigger(element, 'mousedown', options);
|
544 | schedule(function () {
|
545 | if (syn.support.pointerEvents) {
|
546 | syn.trigger(element, 'pointerup', options);
|
547 | }
|
548 | if (syn.support.touchEvents) {
|
549 | syn.trigger(element, 'touchend', options);
|
550 | }
|
551 | syn.trigger(element, 'mouseup', options);
|
552 | if (!syn.support.mouseDownUpClicks || force) {
|
553 | syn.trigger(element, 'click', options);
|
554 | callback(true);
|
555 | } else {
|
556 | syn.create.click.setup('click', options, element);
|
557 | syn.defaults.click.call(element);
|
558 | schedule(function () {
|
559 | callback(true);
|
560 | }, 1);
|
561 | }
|
562 | }, 1);
|
563 | },
|
564 | '_rightClick': function (element, options, callback) {
|
565 | syn.helpers.addOffset(options, element);
|
566 | var mouseopts = extend(extend({}, syn.mouse.browser.right.mouseup), options);
|
567 | if (syn.support.pointerEvents) {
|
568 | syn.trigger(element, 'pointerdown', mouseopts);
|
569 | }
|
570 | syn.trigger(element, 'mousedown', mouseopts);
|
571 | schedule(function () {
|
572 | if (syn.support.pointerEvents) {
|
573 | syn.trigger(element, 'pointerup', mouseopts);
|
574 | }
|
575 | syn.trigger(element, 'mouseup', mouseopts);
|
576 | if (syn.mouse.browser.right.contextmenu) {
|
577 | syn.trigger(element, 'contextmenu', extend(extend({}, syn.mouse.browser.right.contextmenu), options));
|
578 | }
|
579 | callback(true);
|
580 | }, 1);
|
581 | },
|
582 | '_dblclick': function (element, options, callback) {
|
583 | syn.helpers.addOffset(options, element);
|
584 | var self = this;
|
585 | this._click(element, options, function () {
|
586 | schedule(function () {
|
587 | self._click(element, options, function () {
|
588 | syn.trigger(element, 'dblclick', options);
|
589 | callback(true);
|
590 | }, true);
|
591 | }, 2);
|
592 | });
|
593 | }
|
594 | });
|
595 | var actions = [
|
596 | 'click',
|
597 | 'dblclick',
|
598 | 'move',
|
599 | 'drag',
|
600 | 'key',
|
601 | 'type',
|
602 | 'rightClick'
|
603 | ], makeAction = function (name) {
|
604 | syn[name] = function (element, options, callback) {
|
605 | return syn('_' + name, element, options, callback);
|
606 | };
|
607 | syn.init.prototype[name] = function (element, options, callback) {
|
608 | return this.then('_' + name, element, options, callback);
|
609 | };
|
610 | }, i = 0;
|
611 | for (; i < actions.length; i++) {
|
612 | makeAction(actions[i]);
|
613 | }
|
614 | module.exports = syn;
|
615 | });
|
616 |
|
617 | define('syn/mouse', [
|
618 | 'require',
|
619 | 'exports',
|
620 | 'module',
|
621 | 'syn/synthetic'
|
622 | ], function (require, exports, module) {
|
623 | var syn = require('syn/synthetic');
|
624 | var h = syn.helpers, getWin = h.getWindow;
|
625 | syn.mouse = {};
|
626 | h.extend(syn.defaults, {
|
627 | mousedown: function (options) {
|
628 | syn.trigger(this, 'focus', {});
|
629 | },
|
630 | click: function () {
|
631 | var element = this, href, type, createChange, radioChanged, nodeName, scope;
|
632 | try {
|
633 | href = element.href;
|
634 | type = element.type;
|
635 | createChange = syn.data(element, 'createChange');
|
636 | radioChanged = syn.data(element, 'radioChanged');
|
637 | scope = getWin(element);
|
638 | nodeName = element.nodeName.toLowerCase();
|
639 | } catch (e) {
|
640 | return;
|
641 | }
|
642 | if (!syn.support.linkHrefJS && /^\s*javascript:/.test(href)) {
|
643 | var code = href.replace(/^\s*javascript:/, '');
|
644 | if (code !== '//' && code.indexOf('void(0)') === -1) {
|
645 | if (window.selenium) {
|
646 | eval('with(selenium.browserbot.getCurrentWindow()){' + code + '}');
|
647 | } else {
|
648 | eval('with(scope){' + code + '}');
|
649 | }
|
650 | }
|
651 | }
|
652 | if (!syn.support.clickSubmits && ((nodeName === 'input' || nodeName === 'button') && type === 'submit')) {
|
653 | var form = syn.closest(element, 'form');
|
654 | if (form) {
|
655 | syn.trigger(form, 'submit', {});
|
656 | }
|
657 | }
|
658 | if (nodeName === 'a' && element.href && !/^\s*javascript:/.test(href)) {
|
659 | scope.location.href = href;
|
660 | }
|
661 | if (nodeName === 'input' && type === 'checkbox') {
|
662 | if (!syn.support.clickChanges) {
|
663 | syn.trigger(element, 'change', {});
|
664 | }
|
665 | }
|
666 | if (nodeName === 'input' && type === 'radio') {
|
667 | if (radioChanged && !syn.support.radioClickChanges) {
|
668 | syn.trigger(element, 'change', {});
|
669 | }
|
670 | }
|
671 | if (nodeName === 'option' && createChange) {
|
672 | syn.trigger(element.parentNode, 'change', {});
|
673 | syn.data(element, 'createChange', false);
|
674 | }
|
675 | }
|
676 | });
|
677 | h.extend(syn.create, {
|
678 | mouse: {
|
679 | options: function (type, options, element) {
|
680 | var doc = document.documentElement, body = document.body, center = [
|
681 | options.pageX || 0,
|
682 | options.pageY || 0
|
683 | ], left = syn.mouse.browser && syn.mouse.browser.left[type], right = syn.mouse.browser && syn.mouse.browser.right[type];
|
684 | return h.extend({
|
685 | bubbles: true,
|
686 | cancelable: true,
|
687 | view: window,
|
688 | detail: 1,
|
689 | screenX: 1,
|
690 | screenY: 1,
|
691 | clientX: options.clientX || center[0] - (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0),
|
692 | clientY: options.clientY || center[1] - (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0),
|
693 | ctrlKey: !!syn.key.ctrlKey,
|
694 | altKey: !!syn.key.altKey,
|
695 | shiftKey: !!syn.key.shiftKey,
|
696 | metaKey: !!syn.key.metaKey,
|
697 | button: left && left.button !== null ? left.button : right && right.button || (type === 'contextmenu' ? 2 : 0),
|
698 | relatedTarget: document.documentElement
|
699 | }, options);
|
700 | },
|
701 | event: function (type, defaults, element) {
|
702 | var doc = getWin(element).document || document, event;
|
703 | if (doc.createEvent) {
|
704 | try {
|
705 | event = doc.createEvent('MouseEvents');
|
706 | event.initMouseEvent(type, defaults.bubbles, defaults.cancelable, defaults.view, defaults.detail, defaults.screenX, defaults.screenY, defaults.clientX, defaults.clientY, defaults.ctrlKey, defaults.altKey, defaults.shiftKey, defaults.metaKey, defaults.button, defaults.relatedTarget);
|
707 | } catch (e) {
|
708 | event = h.createBasicStandardEvent(type, defaults, doc);
|
709 | }
|
710 | event.synthetic = true;
|
711 | return event;
|
712 | } else {
|
713 | try {
|
714 | event = h.createEventObject(type, defaults, element);
|
715 | } catch (e) {
|
716 | }
|
717 | return event;
|
718 | }
|
719 | }
|
720 | },
|
721 | click: {
|
722 | setup: function (type, options, element) {
|
723 | var nodeName = element.nodeName.toLowerCase();
|
724 | if (!syn.support.clickChecks && !syn.support.changeChecks && nodeName === 'input') {
|
725 | type = element.type.toLowerCase();
|
726 | if (type === 'checkbox') {
|
727 | element.checked = !element.checked;
|
728 | }
|
729 | if (type === 'radio') {
|
730 | if (!element.checked) {
|
731 | try {
|
732 | syn.data(element, 'radioChanged', true);
|
733 | } catch (e) {
|
734 | }
|
735 | element.checked = true;
|
736 | }
|
737 | }
|
738 | }
|
739 | if (nodeName === 'a' && element.href && !/^\s*javascript:/.test(element.href)) {
|
740 | syn.data(element, 'href', element.href);
|
741 | }
|
742 | if (/option/i.test(element.nodeName)) {
|
743 | var child = element.parentNode.firstChild, i = -1;
|
744 | while (child) {
|
745 | if (child.nodeType === 1) {
|
746 | i++;
|
747 | if (child === element) {
|
748 | break;
|
749 | }
|
750 | }
|
751 | child = child.nextSibling;
|
752 | }
|
753 | if (i !== element.parentNode.selectedIndex) {
|
754 | element.parentNode.selectedIndex = i;
|
755 | syn.data(element, 'createChange', true);
|
756 | }
|
757 | }
|
758 | }
|
759 | },
|
760 | mousedown: {
|
761 | setup: function (type, options, element) {
|
762 | var nn = element.nodeName.toLowerCase();
|
763 | if (syn.browser.safari && (nn === 'select' || nn === 'option')) {
|
764 | options._autoPrevent = true;
|
765 | }
|
766 | }
|
767 | }
|
768 | });
|
769 | });
|
770 |
|
771 | define('syn/mouse.support', [
|
772 | 'require',
|
773 | 'exports',
|
774 | 'module',
|
775 | 'syn/synthetic',
|
776 | 'syn/mouse'
|
777 | ], function (require, exports, module) {
|
778 | var syn = require('syn/synthetic');
|
779 | require('syn/mouse');
|
780 | (function checkSupport() {
|
781 | if (!document.body) {
|
782 | return syn.schedule(checkSupport, 1);
|
783 | }
|
784 | window.__synthTest = function () {
|
785 | syn.support.linkHrefJS = true;
|
786 | };
|
787 | var div = document.createElement('div'), checkbox, submit, form, select;
|
788 | div.innerHTML = '<form id=\'outer\'>' + '<input name=\'checkbox\' type=\'checkbox\'/>' + '<input name=\'radio\' type=\'radio\' />' + '<input type=\'submit\' name=\'submitter\'/>' + '<input type=\'input\' name=\'inputter\'/>' + '<input name=\'one\'>' + '<input name=\'two\'/>' + '<a href=\'javascript:__synthTest()\' id=\'synlink\'></a>' + '<select><option></option></select>' + '</form>';
|
789 | document.documentElement.appendChild(div);
|
790 | form = div.firstChild;
|
791 | checkbox = form.childNodes[0];
|
792 | submit = form.childNodes[2];
|
793 | select = form.getElementsByTagName('select')[0];
|
794 | syn.trigger(form.childNodes[6], 'click', {});
|
795 | checkbox.checked = false;
|
796 | checkbox.onchange = function () {
|
797 | syn.support.clickChanges = true;
|
798 | };
|
799 | syn.trigger(checkbox, 'click', {});
|
800 | syn.support.clickChecks = checkbox.checked;
|
801 | checkbox.checked = false;
|
802 | syn.trigger(checkbox, 'change', {});
|
803 | syn.support.changeChecks = checkbox.checked;
|
804 | form.onsubmit = function (ev) {
|
805 | if (ev.preventDefault) {
|
806 | ev.preventDefault();
|
807 | }
|
808 | syn.support.clickSubmits = true;
|
809 | return false;
|
810 | };
|
811 | syn.trigger(submit, 'click', {});
|
812 | form.childNodes[1].onchange = function () {
|
813 | syn.support.radioClickChanges = true;
|
814 | };
|
815 | syn.trigger(form.childNodes[1], 'click', {});
|
816 | syn.bind(div, 'click', function onclick() {
|
817 | syn.support.optionClickBubbles = true;
|
818 | syn.unbind(div, 'click', onclick);
|
819 | });
|
820 | syn.trigger(select.firstChild, 'click', {});
|
821 | syn.support.changeBubbles = syn.eventSupported('change');
|
822 | div.onclick = function () {
|
823 | syn.support.mouseDownUpClicks = true;
|
824 | };
|
825 | syn.trigger(div, 'mousedown', {});
|
826 | syn.trigger(div, 'mouseup', {});
|
827 | document.documentElement.removeChild(div);
|
828 | syn.support.pointerEvents = syn.eventSupported('pointerdown');
|
829 | syn.support.touchEvents = syn.eventSupported('touchstart');
|
830 | syn.support.ready++;
|
831 | }());
|
832 | });
|
833 |
|
834 | define('syn/browsers', [
|
835 | 'require',
|
836 | 'exports',
|
837 | 'module',
|
838 | 'syn/synthetic',
|
839 | 'syn/mouse'
|
840 | ], function (require, exports, module) {
|
841 | var syn = require('syn/synthetic');
|
842 | require('syn/mouse');
|
843 | syn.key.browsers = {
|
844 | webkit: {
|
845 | 'prevent': {
|
846 | 'keyup': [],
|
847 | 'keydown': [
|
848 | 'char',
|
849 | 'keypress'
|
850 | ],
|
851 | 'keypress': ['char']
|
852 | },
|
853 | 'character': {
|
854 | 'keydown': [
|
855 | 0,
|
856 | 'key'
|
857 | ],
|
858 | 'keypress': [
|
859 | 'char',
|
860 | 'char'
|
861 | ],
|
862 | 'keyup': [
|
863 | 0,
|
864 | 'key'
|
865 | ]
|
866 | },
|
867 | 'specialChars': {
|
868 | 'keydown': [
|
869 | 0,
|
870 | 'char'
|
871 | ],
|
872 | 'keyup': [
|
873 | 0,
|
874 | 'char'
|
875 | ]
|
876 | },
|
877 | 'navigation': {
|
878 | 'keydown': [
|
879 | 0,
|
880 | 'key'
|
881 | ],
|
882 | 'keyup': [
|
883 | 0,
|
884 | 'key'
|
885 | ]
|
886 | },
|
887 | 'special': {
|
888 | 'keydown': [
|
889 | 0,
|
890 | 'key'
|
891 | ],
|
892 | 'keyup': [
|
893 | 0,
|
894 | 'key'
|
895 | ]
|
896 | },
|
897 | 'tab': {
|
898 | 'keydown': [
|
899 | 0,
|
900 | 'char'
|
901 | ],
|
902 | 'keyup': [
|
903 | 0,
|
904 | 'char'
|
905 | ]
|
906 | },
|
907 | 'pause-break': {
|
908 | 'keydown': [
|
909 | 0,
|
910 | 'key'
|
911 | ],
|
912 | 'keyup': [
|
913 | 0,
|
914 | 'key'
|
915 | ]
|
916 | },
|
917 | 'caps': {
|
918 | 'keydown': [
|
919 | 0,
|
920 | 'key'
|
921 | ],
|
922 | 'keyup': [
|
923 | 0,
|
924 | 'key'
|
925 | ]
|
926 | },
|
927 | 'escape': {
|
928 | 'keydown': [
|
929 | 0,
|
930 | 'key'
|
931 | ],
|
932 | 'keyup': [
|
933 | 0,
|
934 | 'key'
|
935 | ]
|
936 | },
|
937 | 'num-lock': {
|
938 | 'keydown': [
|
939 | 0,
|
940 | 'key'
|
941 | ],
|
942 | 'keyup': [
|
943 | 0,
|
944 | 'key'
|
945 | ]
|
946 | },
|
947 | 'scroll-lock': {
|
948 | 'keydown': [
|
949 | 0,
|
950 | 'key'
|
951 | ],
|
952 | 'keyup': [
|
953 | 0,
|
954 | 'key'
|
955 | ]
|
956 | },
|
957 | 'print': {
|
958 | 'keyup': [
|
959 | 0,
|
960 | 'key'
|
961 | ]
|
962 | },
|
963 | 'function': {
|
964 | 'keydown': [
|
965 | 0,
|
966 | 'key'
|
967 | ],
|
968 | 'keyup': [
|
969 | 0,
|
970 | 'key'
|
971 | ]
|
972 | },
|
973 | '\r': {
|
974 | 'keydown': [
|
975 | 0,
|
976 | 'key'
|
977 | ],
|
978 | 'keypress': [
|
979 | 'char',
|
980 | 'key'
|
981 | ],
|
982 | 'keyup': [
|
983 | 0,
|
984 | 'key'
|
985 | ]
|
986 | }
|
987 | },
|
988 | gecko: {
|
989 | 'prevent': {
|
990 | 'keyup': [],
|
991 | 'keydown': ['char'],
|
992 | 'keypress': ['char']
|
993 | },
|
994 | 'character': {
|
995 | 'keydown': [
|
996 | 0,
|
997 | 'key'
|
998 | ],
|
999 | 'keypress': [
|
1000 | 'char',
|
1001 | 0
|
1002 | ],
|
1003 | 'keyup': [
|
1004 | 0,
|
1005 | 'key'
|
1006 | ]
|
1007 | },
|
1008 | 'specialChars': {
|
1009 | 'keydown': [
|
1010 | 0,
|
1011 | 'key'
|
1012 | ],
|
1013 | 'keypress': [
|
1014 | 0,
|
1015 | 'key'
|
1016 | ],
|
1017 | 'keyup': [
|
1018 | 0,
|
1019 | 'key'
|
1020 | ]
|
1021 | },
|
1022 | 'navigation': {
|
1023 | 'keydown': [
|
1024 | 0,
|
1025 | 'key'
|
1026 | ],
|
1027 | 'keypress': [
|
1028 | 0,
|
1029 | 'key'
|
1030 | ],
|
1031 | 'keyup': [
|
1032 | 0,
|
1033 | 'key'
|
1034 | ]
|
1035 | },
|
1036 | 'special': {
|
1037 | 'keydown': [
|
1038 | 0,
|
1039 | 'key'
|
1040 | ],
|
1041 | 'keyup': [
|
1042 | 0,
|
1043 | 'key'
|
1044 | ]
|
1045 | },
|
1046 | '\t': {
|
1047 | 'keydown': [
|
1048 | 0,
|
1049 | 'key'
|
1050 | ],
|
1051 | 'keypress': [
|
1052 | 0,
|
1053 | 'key'
|
1054 | ],
|
1055 | 'keyup': [
|
1056 | 0,
|
1057 | 'key'
|
1058 | ]
|
1059 | },
|
1060 | 'pause-break': {
|
1061 | 'keydown': [
|
1062 | 0,
|
1063 | 'key'
|
1064 | ],
|
1065 | 'keypress': [
|
1066 | 0,
|
1067 | 'key'
|
1068 | ],
|
1069 | 'keyup': [
|
1070 | 0,
|
1071 | 'key'
|
1072 | ]
|
1073 | },
|
1074 | 'caps': {
|
1075 | 'keydown': [
|
1076 | 0,
|
1077 | 'key'
|
1078 | ],
|
1079 | 'keyup': [
|
1080 | 0,
|
1081 | 'key'
|
1082 | ]
|
1083 | },
|
1084 | 'escape': {
|
1085 | 'keydown': [
|
1086 | 0,
|
1087 | 'key'
|
1088 | ],
|
1089 | 'keypress': [
|
1090 | 0,
|
1091 | 'key'
|
1092 | ],
|
1093 | 'keyup': [
|
1094 | 0,
|
1095 | 'key'
|
1096 | ]
|
1097 | },
|
1098 | 'num-lock': {
|
1099 | 'keydown': [
|
1100 | 0,
|
1101 | 'key'
|
1102 | ],
|
1103 | 'keyup': [
|
1104 | 0,
|
1105 | 'key'
|
1106 | ]
|
1107 | },
|
1108 | 'scroll-lock': {
|
1109 | 'keydown': [
|
1110 | 0,
|
1111 | 'key'
|
1112 | ],
|
1113 | 'keyup': [
|
1114 | 0,
|
1115 | 'key'
|
1116 | ]
|
1117 | },
|
1118 | 'print': {
|
1119 | 'keyup': [
|
1120 | 0,
|
1121 | 'key'
|
1122 | ]
|
1123 | },
|
1124 | 'function': {
|
1125 | 'keydown': [
|
1126 | 0,
|
1127 | 'key'
|
1128 | ],
|
1129 | 'keyup': [
|
1130 | 0,
|
1131 | 'key'
|
1132 | ]
|
1133 | },
|
1134 | '\r': {
|
1135 | 'keydown': [
|
1136 | 0,
|
1137 | 'key'
|
1138 | ],
|
1139 | 'keypress': [
|
1140 | 0,
|
1141 | 'key'
|
1142 | ],
|
1143 | 'keyup': [
|
1144 | 0,
|
1145 | 'key'
|
1146 | ]
|
1147 | }
|
1148 | },
|
1149 | msie: {
|
1150 | 'prevent': {
|
1151 | 'keyup': [],
|
1152 | 'keydown': [
|
1153 | 'char',
|
1154 | 'keypress'
|
1155 | ],
|
1156 | 'keypress': ['char']
|
1157 | },
|
1158 | 'character': {
|
1159 | 'keydown': [
|
1160 | null,
|
1161 | 'key'
|
1162 | ],
|
1163 | 'keypress': [
|
1164 | null,
|
1165 | 'char'
|
1166 | ],
|
1167 | 'keyup': [
|
1168 | null,
|
1169 | 'key'
|
1170 | ]
|
1171 | },
|
1172 | 'specialChars': {
|
1173 | 'keydown': [
|
1174 | null,
|
1175 | 'char'
|
1176 | ],
|
1177 | 'keyup': [
|
1178 | null,
|
1179 | 'char'
|
1180 | ]
|
1181 | },
|
1182 | 'navigation': {
|
1183 | 'keydown': [
|
1184 | null,
|
1185 | 'key'
|
1186 | ],
|
1187 | 'keyup': [
|
1188 | null,
|
1189 | 'key'
|
1190 | ]
|
1191 | },
|
1192 | 'special': {
|
1193 | 'keydown': [
|
1194 | null,
|
1195 | 'key'
|
1196 | ],
|
1197 | 'keyup': [
|
1198 | null,
|
1199 | 'key'
|
1200 | ]
|
1201 | },
|
1202 | 'tab': {
|
1203 | 'keydown': [
|
1204 | null,
|
1205 | 'char'
|
1206 | ],
|
1207 | 'keyup': [
|
1208 | null,
|
1209 | 'char'
|
1210 | ]
|
1211 | },
|
1212 | 'pause-break': {
|
1213 | 'keydown': [
|
1214 | null,
|
1215 | 'key'
|
1216 | ],
|
1217 | 'keyup': [
|
1218 | null,
|
1219 | 'key'
|
1220 | ]
|
1221 | },
|
1222 | 'caps': {
|
1223 | 'keydown': [
|
1224 | null,
|
1225 | 'key'
|
1226 | ],
|
1227 | 'keyup': [
|
1228 | null,
|
1229 | 'key'
|
1230 | ]
|
1231 | },
|
1232 | 'escape': {
|
1233 | 'keydown': [
|
1234 | null,
|
1235 | 'key'
|
1236 | ],
|
1237 | 'keypress': [
|
1238 | null,
|
1239 | 'key'
|
1240 | ],
|
1241 | 'keyup': [
|
1242 | null,
|
1243 | 'key'
|
1244 | ]
|
1245 | },
|
1246 | 'num-lock': {
|
1247 | 'keydown': [
|
1248 | null,
|
1249 | 'key'
|
1250 | ],
|
1251 | 'keyup': [
|
1252 | null,
|
1253 | 'key'
|
1254 | ]
|
1255 | },
|
1256 | 'scroll-lock': {
|
1257 | 'keydown': [
|
1258 | null,
|
1259 | 'key'
|
1260 | ],
|
1261 | 'keyup': [
|
1262 | null,
|
1263 | 'key'
|
1264 | ]
|
1265 | },
|
1266 | 'print': {
|
1267 | 'keyup': [
|
1268 | null,
|
1269 | 'key'
|
1270 | ]
|
1271 | },
|
1272 | 'function': {
|
1273 | 'keydown': [
|
1274 | null,
|
1275 | 'key'
|
1276 | ],
|
1277 | 'keyup': [
|
1278 | null,
|
1279 | 'key'
|
1280 | ]
|
1281 | },
|
1282 | '\r': {
|
1283 | 'keydown': [
|
1284 | null,
|
1285 | 'key'
|
1286 | ],
|
1287 | 'keypress': [
|
1288 | null,
|
1289 | 'key'
|
1290 | ],
|
1291 | 'keyup': [
|
1292 | null,
|
1293 | 'key'
|
1294 | ]
|
1295 | }
|
1296 | },
|
1297 | opera: {
|
1298 | 'prevent': {
|
1299 | 'keyup': [],
|
1300 | 'keydown': [],
|
1301 | 'keypress': ['char']
|
1302 | },
|
1303 | 'character': {
|
1304 | 'keydown': [
|
1305 | null,
|
1306 | 'key'
|
1307 | ],
|
1308 | 'keypress': [
|
1309 | null,
|
1310 | 'char'
|
1311 | ],
|
1312 | 'keyup': [
|
1313 | null,
|
1314 | 'key'
|
1315 | ]
|
1316 | },
|
1317 | 'specialChars': {
|
1318 | 'keydown': [
|
1319 | null,
|
1320 | 'char'
|
1321 | ],
|
1322 | 'keypress': [
|
1323 | null,
|
1324 | 'char'
|
1325 | ],
|
1326 | 'keyup': [
|
1327 | null,
|
1328 | 'char'
|
1329 | ]
|
1330 | },
|
1331 | 'navigation': {
|
1332 | 'keydown': [
|
1333 | null,
|
1334 | 'key'
|
1335 | ],
|
1336 | 'keypress': [
|
1337 | null,
|
1338 | 'key'
|
1339 | ]
|
1340 | },
|
1341 | 'special': {
|
1342 | 'keydown': [
|
1343 | null,
|
1344 | 'key'
|
1345 | ],
|
1346 | 'keypress': [
|
1347 | null,
|
1348 | 'key'
|
1349 | ],
|
1350 | 'keyup': [
|
1351 | null,
|
1352 | 'key'
|
1353 | ]
|
1354 | },
|
1355 | 'tab': {
|
1356 | 'keydown': [
|
1357 | null,
|
1358 | 'char'
|
1359 | ],
|
1360 | 'keypress': [
|
1361 | null,
|
1362 | 'char'
|
1363 | ],
|
1364 | 'keyup': [
|
1365 | null,
|
1366 | 'char'
|
1367 | ]
|
1368 | },
|
1369 | 'pause-break': {
|
1370 | 'keydown': [
|
1371 | null,
|
1372 | 'key'
|
1373 | ],
|
1374 | 'keypress': [
|
1375 | null,
|
1376 | 'key'
|
1377 | ],
|
1378 | 'keyup': [
|
1379 | null,
|
1380 | 'key'
|
1381 | ]
|
1382 | },
|
1383 | 'caps': {
|
1384 | 'keydown': [
|
1385 | null,
|
1386 | 'key'
|
1387 | ],
|
1388 | 'keyup': [
|
1389 | null,
|
1390 | 'key'
|
1391 | ]
|
1392 | },
|
1393 | 'escape': {
|
1394 | 'keydown': [
|
1395 | null,
|
1396 | 'key'
|
1397 | ],
|
1398 | 'keypress': [
|
1399 | null,
|
1400 | 'key'
|
1401 | ]
|
1402 | },
|
1403 | 'num-lock': {
|
1404 | 'keyup': [
|
1405 | null,
|
1406 | 'key'
|
1407 | ],
|
1408 | 'keydown': [
|
1409 | null,
|
1410 | 'key'
|
1411 | ],
|
1412 | 'keypress': [
|
1413 | null,
|
1414 | 'key'
|
1415 | ]
|
1416 | },
|
1417 | 'scroll-lock': {
|
1418 | 'keydown': [
|
1419 | null,
|
1420 | 'key'
|
1421 | ],
|
1422 | 'keypress': [
|
1423 | null,
|
1424 | 'key'
|
1425 | ],
|
1426 | 'keyup': [
|
1427 | null,
|
1428 | 'key'
|
1429 | ]
|
1430 | },
|
1431 | 'print': {},
|
1432 | 'function': {
|
1433 | 'keydown': [
|
1434 | null,
|
1435 | 'key'
|
1436 | ],
|
1437 | 'keypress': [
|
1438 | null,
|
1439 | 'key'
|
1440 | ],
|
1441 | 'keyup': [
|
1442 | null,
|
1443 | 'key'
|
1444 | ]
|
1445 | },
|
1446 | '\r': {
|
1447 | 'keydown': [
|
1448 | null,
|
1449 | 'key'
|
1450 | ],
|
1451 | 'keypress': [
|
1452 | null,
|
1453 | 'key'
|
1454 | ],
|
1455 | 'keyup': [
|
1456 | null,
|
1457 | 'key'
|
1458 | ]
|
1459 | }
|
1460 | }
|
1461 | };
|
1462 | syn.mouse.browsers = {
|
1463 | webkit: {
|
1464 | 'right': {
|
1465 | 'mousedown': {
|
1466 | 'button': 2,
|
1467 | 'which': 3
|
1468 | },
|
1469 | 'mouseup': {
|
1470 | 'button': 2,
|
1471 | 'which': 3
|
1472 | },
|
1473 | 'contextmenu': {
|
1474 | 'button': 2,
|
1475 | 'which': 3
|
1476 | }
|
1477 | },
|
1478 | 'left': {
|
1479 | 'mousedown': {
|
1480 | 'button': 0,
|
1481 | 'which': 1
|
1482 | },
|
1483 | 'mouseup': {
|
1484 | 'button': 0,
|
1485 | 'which': 1
|
1486 | },
|
1487 | 'click': {
|
1488 | 'button': 0,
|
1489 | 'which': 1
|
1490 | }
|
1491 | }
|
1492 | },
|
1493 | opera: {
|
1494 | 'right': {
|
1495 | 'mousedown': {
|
1496 | 'button': 2,
|
1497 | 'which': 3
|
1498 | },
|
1499 | 'mouseup': {
|
1500 | 'button': 2,
|
1501 | 'which': 3
|
1502 | }
|
1503 | },
|
1504 | 'left': {
|
1505 | 'mousedown': {
|
1506 | 'button': 0,
|
1507 | 'which': 1
|
1508 | },
|
1509 | 'mouseup': {
|
1510 | 'button': 0,
|
1511 | 'which': 1
|
1512 | },
|
1513 | 'click': {
|
1514 | 'button': 0,
|
1515 | 'which': 1
|
1516 | }
|
1517 | }
|
1518 | },
|
1519 | msie: {
|
1520 | 'right': {
|
1521 | 'mousedown': { 'button': 2 },
|
1522 | 'mouseup': { 'button': 2 },
|
1523 | 'contextmenu': { 'button': 0 }
|
1524 | },
|
1525 | 'left': {
|
1526 | 'mousedown': { 'button': 1 },
|
1527 | 'mouseup': { 'button': 1 },
|
1528 | 'click': { 'button': 0 }
|
1529 | }
|
1530 | },
|
1531 | chrome: {
|
1532 | 'right': {
|
1533 | 'mousedown': {
|
1534 | 'button': 2,
|
1535 | 'which': 3
|
1536 | },
|
1537 | 'mouseup': {
|
1538 | 'button': 2,
|
1539 | 'which': 3
|
1540 | },
|
1541 | 'contextmenu': {
|
1542 | 'button': 2,
|
1543 | 'which': 3
|
1544 | }
|
1545 | },
|
1546 | 'left': {
|
1547 | 'mousedown': {
|
1548 | 'button': 0,
|
1549 | 'which': 1
|
1550 | },
|
1551 | 'mouseup': {
|
1552 | 'button': 0,
|
1553 | 'which': 1
|
1554 | },
|
1555 | 'click': {
|
1556 | 'button': 0,
|
1557 | 'which': 1
|
1558 | }
|
1559 | }
|
1560 | },
|
1561 | gecko: {
|
1562 | 'left': {
|
1563 | 'mousedown': {
|
1564 | 'button': 0,
|
1565 | 'which': 1
|
1566 | },
|
1567 | 'mouseup': {
|
1568 | 'button': 0,
|
1569 | 'which': 1
|
1570 | },
|
1571 | 'click': {
|
1572 | 'button': 0,
|
1573 | 'which': 1
|
1574 | }
|
1575 | },
|
1576 | 'right': {
|
1577 | 'mousedown': {
|
1578 | 'button': 2,
|
1579 | 'which': 3
|
1580 | },
|
1581 | 'mouseup': {
|
1582 | 'button': 2,
|
1583 | 'which': 3
|
1584 | },
|
1585 | 'contextmenu': {
|
1586 | 'button': 2,
|
1587 | 'which': 3
|
1588 | }
|
1589 | }
|
1590 | }
|
1591 | };
|
1592 | syn.key.browser = function () {
|
1593 | if (syn.key.browsers[window.navigator.userAgent]) {
|
1594 | return syn.key.browsers[window.navigator.userAgent];
|
1595 | }
|
1596 | for (var browser in syn.browser) {
|
1597 | if (syn.browser[browser] && syn.key.browsers[browser]) {
|
1598 | return syn.key.browsers[browser];
|
1599 | }
|
1600 | }
|
1601 | return syn.key.browsers.gecko;
|
1602 | }();
|
1603 | syn.mouse.browser = function () {
|
1604 | if (syn.mouse.browsers[window.navigator.userAgent]) {
|
1605 | return syn.mouse.browsers[window.navigator.userAgent];
|
1606 | }
|
1607 | for (var browser in syn.browser) {
|
1608 | if (syn.browser[browser] && syn.mouse.browsers[browser]) {
|
1609 | return syn.mouse.browsers[browser];
|
1610 | }
|
1611 | }
|
1612 | return syn.mouse.browsers.gecko;
|
1613 | }();
|
1614 | });
|
1615 |
|
1616 | define('syn/typeable', [
|
1617 | 'require',
|
1618 | 'exports',
|
1619 | 'module',
|
1620 | 'syn/synthetic'
|
1621 | ], function (require, exports, module) {
|
1622 | var syn = require('syn/synthetic');
|
1623 | var typeables = [];
|
1624 | var __indexOf = [].indexOf || function (item) {
|
1625 | for (var i = 0, l = this.length; i < l; i++) {
|
1626 | if (i in this && this[i] === item) {
|
1627 | return i;
|
1628 | }
|
1629 | }
|
1630 | return -1;
|
1631 | };
|
1632 | syn.typeable = function (fn) {
|
1633 | if (__indexOf.call(typeables, fn) === -1) {
|
1634 | typeables.push(fn);
|
1635 | }
|
1636 | };
|
1637 | syn.typeable.test = function (el) {
|
1638 | for (var i = 0, len = typeables.length; i < len; i++) {
|
1639 | if (typeables[i](el)) {
|
1640 | return true;
|
1641 | }
|
1642 | }
|
1643 | return false;
|
1644 | };
|
1645 | var type = syn.typeable;
|
1646 | var typeableExp = /input|textarea/i;
|
1647 | type(function (el) {
|
1648 | return typeableExp.test(el.nodeName);
|
1649 | });
|
1650 | type(function (el) {
|
1651 | return __indexOf.call([
|
1652 | '',
|
1653 | 'true'
|
1654 | ], el.getAttribute('contenteditable')) !== -1;
|
1655 | });
|
1656 | });
|
1657 |
|
1658 | define('syn/key', [
|
1659 | 'require',
|
1660 | 'exports',
|
1661 | 'module',
|
1662 | 'syn/synthetic',
|
1663 | 'syn/typeable',
|
1664 | 'syn/browsers'
|
1665 | ], function (require, exports, module) {
|
1666 | var syn = require('syn/synthetic');
|
1667 | require('syn/typeable');
|
1668 | require('syn/browsers');
|
1669 | var h = syn.helpers, formElExp = /input|textarea/i, supportsSelection = function (el) {
|
1670 | var result;
|
1671 | try {
|
1672 | result = el.selectionStart !== undefined && el.selectionStart !== null;
|
1673 | } catch (e) {
|
1674 | result = false;
|
1675 | }
|
1676 | return result;
|
1677 | }, getSelection = function (el) {
|
1678 | var real, r, start;
|
1679 | if (supportsSelection(el)) {
|
1680 | if (document.activeElement && document.activeElement !== el && el.selectionStart === el.selectionEnd && el.selectionStart === 0) {
|
1681 | return {
|
1682 | start: el.value.length,
|
1683 | end: el.value.length
|
1684 | };
|
1685 | }
|
1686 | return {
|
1687 | start: el.selectionStart,
|
1688 | end: el.selectionEnd
|
1689 | };
|
1690 | } else {
|
1691 | try {
|
1692 | if (el.nodeName.toLowerCase() === 'input') {
|
1693 | real = h.getWindow(el).document.selection.createRange();
|
1694 | r = el.createTextRange();
|
1695 | r.setEndPoint('EndToStart', real);
|
1696 | start = r.text.length;
|
1697 | return {
|
1698 | start: start,
|
1699 | end: start + real.text.length
|
1700 | };
|
1701 | } else {
|
1702 | real = h.getWindow(el).document.selection.createRange();
|
1703 | r = real.duplicate();
|
1704 | var r2 = real.duplicate(), r3 = real.duplicate();
|
1705 | r2.collapse();
|
1706 | r3.collapse(false);
|
1707 | r2.moveStart('character', -1);
|
1708 | r3.moveStart('character', -1);
|
1709 | r.moveToElementText(el);
|
1710 | r.setEndPoint('EndToEnd', real);
|
1711 | start = r.text.length - real.text.length;
|
1712 | var end = r.text.length;
|
1713 | if (start !== 0 && r2.text === '') {
|
1714 | start += 2;
|
1715 | }
|
1716 | if (end !== 0 && r3.text === '') {
|
1717 | end += 2;
|
1718 | }
|
1719 | return {
|
1720 | start: start,
|
1721 | end: end
|
1722 | };
|
1723 | }
|
1724 | } catch (e) {
|
1725 | var prop = formElExp.test(el.nodeName) ? 'value' : 'textContent';
|
1726 | return {
|
1727 | start: el[prop].length,
|
1728 | end: el[prop].length
|
1729 | };
|
1730 | }
|
1731 | }
|
1732 | }, getFocusable = function (el) {
|
1733 | var document = h.getWindow(el).document, res = [];
|
1734 | var els = document.getElementsByTagName('*'), len = els.length;
|
1735 | for (var i = 0; i < len; i++) {
|
1736 | if (syn.isFocusable(els[i]) && els[i] !== document.documentElement) {
|
1737 | res.push(els[i]);
|
1738 | }
|
1739 | }
|
1740 | return res;
|
1741 | }, textProperty = function () {
|
1742 | var el = document.createElement('span');
|
1743 | return el.textContent != null ? 'textContent' : 'innerText';
|
1744 | }(), getText = function (el) {
|
1745 | if (formElExp.test(el.nodeName)) {
|
1746 | return el.value;
|
1747 | }
|
1748 | return el[textProperty];
|
1749 | }, setText = function (el, value) {
|
1750 | if (formElExp.test(el.nodeName)) {
|
1751 | el.value = value;
|
1752 | } else {
|
1753 | el[textProperty] = value;
|
1754 | }
|
1755 | };
|
1756 | h.extend(syn, {
|
1757 | keycodes: {
|
1758 | '\b': 8,
|
1759 | '\t': 9,
|
1760 | '\r': 13,
|
1761 | 'shift': 16,
|
1762 | 'ctrl': 17,
|
1763 | 'alt': 18,
|
1764 | 'meta': 91,
|
1765 | 'pause-break': 19,
|
1766 | 'caps': 20,
|
1767 | 'escape': 27,
|
1768 | 'num-lock': 144,
|
1769 | 'scroll-lock': 145,
|
1770 | 'print': 44,
|
1771 | 'page-up': 33,
|
1772 | 'page-down': 34,
|
1773 | 'end': 35,
|
1774 | 'home': 36,
|
1775 | 'left': 37,
|
1776 | 'up': 38,
|
1777 | 'right': 39,
|
1778 | 'down': 40,
|
1779 | 'insert': 45,
|
1780 | 'delete': 46,
|
1781 | ' ': 32,
|
1782 | '0': 48,
|
1783 | '1': 49,
|
1784 | '2': 50,
|
1785 | '3': 51,
|
1786 | '4': 52,
|
1787 | '5': 53,
|
1788 | '6': 54,
|
1789 | '7': 55,
|
1790 | '8': 56,
|
1791 | '9': 57,
|
1792 | 'a': 65,
|
1793 | 'b': 66,
|
1794 | 'c': 67,
|
1795 | 'd': 68,
|
1796 | 'e': 69,
|
1797 | 'f': 70,
|
1798 | 'g': 71,
|
1799 | 'h': 72,
|
1800 | 'i': 73,
|
1801 | 'j': 74,
|
1802 | 'k': 75,
|
1803 | 'l': 76,
|
1804 | 'm': 77,
|
1805 | 'n': 78,
|
1806 | 'o': 79,
|
1807 | 'p': 80,
|
1808 | 'q': 81,
|
1809 | 'r': 82,
|
1810 | 's': 83,
|
1811 | 't': 84,
|
1812 | 'u': 85,
|
1813 | 'v': 86,
|
1814 | 'w': 87,
|
1815 | 'x': 88,
|
1816 | 'y': 89,
|
1817 | 'z': 90,
|
1818 | 'num0': 96,
|
1819 | 'num1': 97,
|
1820 | 'num2': 98,
|
1821 | 'num3': 99,
|
1822 | 'num4': 100,
|
1823 | 'num5': 101,
|
1824 | 'num6': 102,
|
1825 | 'num7': 103,
|
1826 | 'num8': 104,
|
1827 | 'num9': 105,
|
1828 | '*': 106,
|
1829 | '+': 107,
|
1830 | 'subtract': 109,
|
1831 | 'decimal': 110,
|
1832 | 'divide': 111,
|
1833 | ';': 186,
|
1834 | '=': 187,
|
1835 | ',': 188,
|
1836 | 'dash': 189,
|
1837 | '-': 189,
|
1838 | 'period': 190,
|
1839 | '.': 190,
|
1840 | 'forward-slash': 191,
|
1841 | '/': 191,
|
1842 | '`': 192,
|
1843 | '[': 219,
|
1844 | '\\': 220,
|
1845 | ']': 221,
|
1846 | '\'': 222,
|
1847 | 'left window key': 91,
|
1848 | 'right window key': 92,
|
1849 | 'select key': 93,
|
1850 | 'f1': 112,
|
1851 | 'f2': 113,
|
1852 | 'f3': 114,
|
1853 | 'f4': 115,
|
1854 | 'f5': 116,
|
1855 | 'f6': 117,
|
1856 | 'f7': 118,
|
1857 | 'f8': 119,
|
1858 | 'f9': 120,
|
1859 | 'f10': 121,
|
1860 | 'f11': 122,
|
1861 | 'f12': 123
|
1862 | },
|
1863 | selectText: function (el, start, end) {
|
1864 | if (supportsSelection(el)) {
|
1865 | if (!end) {
|
1866 | syn.__tryFocus(el);
|
1867 | el.setSelectionRange(start, start);
|
1868 | } else {
|
1869 | el.selectionStart = start;
|
1870 | el.selectionEnd = end;
|
1871 | }
|
1872 | } else if (el.createTextRange) {
|
1873 | var r = el.createTextRange();
|
1874 | r.moveStart('character', start);
|
1875 | end = end || start;
|
1876 | r.moveEnd('character', end - el.value.length);
|
1877 | r.select();
|
1878 | }
|
1879 | },
|
1880 | getText: function (el) {
|
1881 | if (syn.typeable.test(el)) {
|
1882 | var sel = getSelection(el);
|
1883 | return el.value.substring(sel.start, sel.end);
|
1884 | }
|
1885 | var win = syn.helpers.getWindow(el);
|
1886 | if (win.getSelection) {
|
1887 | return win.getSelection().toString();
|
1888 | } else if (win.document.getSelection) {
|
1889 | return win.document.getSelection().toString();
|
1890 | } else {
|
1891 | return win.document.selection.createRange().text;
|
1892 | }
|
1893 | },
|
1894 | getSelection: getSelection
|
1895 | });
|
1896 | h.extend(syn.key, {
|
1897 | data: function (key) {
|
1898 | if (syn.key.browser[key]) {
|
1899 | return syn.key.browser[key];
|
1900 | }
|
1901 | for (var kind in syn.key.kinds) {
|
1902 | if (h.inArray(key, syn.key.kinds[kind]) > -1) {
|
1903 | return syn.key.browser[kind];
|
1904 | }
|
1905 | }
|
1906 | return syn.key.browser.character;
|
1907 | },
|
1908 | isSpecial: function (keyCode) {
|
1909 | var specials = syn.key.kinds.special;
|
1910 | for (var i = 0; i < specials.length; i++) {
|
1911 | if (syn.keycodes[specials[i]] === keyCode) {
|
1912 | return specials[i];
|
1913 | }
|
1914 | }
|
1915 | },
|
1916 | options: function (key, event) {
|
1917 | var keyData = syn.key.data(key);
|
1918 | if (!keyData[event]) {
|
1919 | return null;
|
1920 | }
|
1921 | var charCode = keyData[event][0], keyCode = keyData[event][1], result = {};
|
1922 | if (keyCode === 'key') {
|
1923 | result.keyCode = syn.keycodes[key];
|
1924 | } else if (keyCode === 'char') {
|
1925 | result.keyCode = key.charCodeAt(0);
|
1926 | } else {
|
1927 | result.keyCode = keyCode;
|
1928 | }
|
1929 | if (charCode === 'char') {
|
1930 | result.charCode = key.charCodeAt(0);
|
1931 | } else if (charCode !== null) {
|
1932 | result.charCode = charCode;
|
1933 | }
|
1934 | if (result.keyCode) {
|
1935 | result.which = result.keyCode;
|
1936 | } else {
|
1937 | result.which = result.charCode;
|
1938 | }
|
1939 | return result;
|
1940 | },
|
1941 | kinds: {
|
1942 | special: [
|
1943 | 'shift',
|
1944 | 'ctrl',
|
1945 | 'alt',
|
1946 | 'meta',
|
1947 | 'caps'
|
1948 | ],
|
1949 | specialChars: ['\b'],
|
1950 | navigation: [
|
1951 | 'page-up',
|
1952 | 'page-down',
|
1953 | 'end',
|
1954 | 'home',
|
1955 | 'left',
|
1956 | 'up',
|
1957 | 'right',
|
1958 | 'down',
|
1959 | 'insert',
|
1960 | 'delete'
|
1961 | ],
|
1962 | 'function': [
|
1963 | 'f1',
|
1964 | 'f2',
|
1965 | 'f3',
|
1966 | 'f4',
|
1967 | 'f5',
|
1968 | 'f6',
|
1969 | 'f7',
|
1970 | 'f8',
|
1971 | 'f9',
|
1972 | 'f10',
|
1973 | 'f11',
|
1974 | 'f12'
|
1975 | ]
|
1976 | },
|
1977 | getDefault: function (key) {
|
1978 | if (syn.key.defaults[key]) {
|
1979 | return syn.key.defaults[key];
|
1980 | }
|
1981 | for (var kind in syn.key.kinds) {
|
1982 | if (h.inArray(key, syn.key.kinds[kind]) > -1 && syn.key.defaults[kind]) {
|
1983 | return syn.key.defaults[kind];
|
1984 | }
|
1985 | }
|
1986 | return syn.key.defaults.character;
|
1987 | },
|
1988 | defaults: {
|
1989 | 'character': function (options, scope, key, force, sel) {
|
1990 | if (/num\d+/.test(key)) {
|
1991 | key = key.match(/\d+/)[0];
|
1992 | }
|
1993 | if (force || !syn.support.keyCharacters && syn.typeable.test(this)) {
|
1994 | var current = getText(this), before = current.substr(0, sel.start), after = current.substr(sel.end), character = key;
|
1995 | setText(this, before + character + after);
|
1996 | var charLength = character === '\n' && syn.support.textareaCarriage ? 2 : character.length;
|
1997 | syn.selectText(this, before.length + charLength);
|
1998 | }
|
1999 | },
|
2000 | 'c': function (options, scope, key, force, sel) {
|
2001 | if (syn.key.ctrlKey) {
|
2002 | syn.key.clipboard = syn.getText(this);
|
2003 | } else {
|
2004 | syn.key.defaults.character.apply(this, arguments);
|
2005 | }
|
2006 | },
|
2007 | 'v': function (options, scope, key, force, sel) {
|
2008 | if (syn.key.ctrlKey) {
|
2009 | syn.key.defaults.character.call(this, options, scope, syn.key.clipboard, true, sel);
|
2010 | } else {
|
2011 | syn.key.defaults.character.apply(this, arguments);
|
2012 | }
|
2013 | },
|
2014 | 'a': function (options, scope, key, force, sel) {
|
2015 | if (syn.key.ctrlKey) {
|
2016 | syn.selectText(this, 0, getText(this).length);
|
2017 | } else {
|
2018 | syn.key.defaults.character.apply(this, arguments);
|
2019 | }
|
2020 | },
|
2021 | 'home': function () {
|
2022 | syn.onParents(this, function (el) {
|
2023 | if (el.scrollHeight !== el.clientHeight) {
|
2024 | el.scrollTop = 0;
|
2025 | return false;
|
2026 | }
|
2027 | });
|
2028 | },
|
2029 | 'end': function () {
|
2030 | syn.onParents(this, function (el) {
|
2031 | if (el.scrollHeight !== el.clientHeight) {
|
2032 | el.scrollTop = el.scrollHeight;
|
2033 | return false;
|
2034 | }
|
2035 | });
|
2036 | },
|
2037 | 'page-down': function () {
|
2038 | syn.onParents(this, function (el) {
|
2039 | if (el.scrollHeight !== el.clientHeight) {
|
2040 | var ch = el.clientHeight;
|
2041 | el.scrollTop += ch;
|
2042 | return false;
|
2043 | }
|
2044 | });
|
2045 | },
|
2046 | 'page-up': function () {
|
2047 | syn.onParents(this, function (el) {
|
2048 | if (el.scrollHeight !== el.clientHeight) {
|
2049 | var ch = el.clientHeight;
|
2050 | el.scrollTop -= ch;
|
2051 | return false;
|
2052 | }
|
2053 | });
|
2054 | },
|
2055 | '\b': function (options, scope, key, force, sel) {
|
2056 | if (!syn.support.backspaceWorks && syn.typeable.test(this)) {
|
2057 | var current = getText(this), before = current.substr(0, sel.start), after = current.substr(sel.end);
|
2058 | if (sel.start === sel.end && sel.start > 0) {
|
2059 | setText(this, before.substring(0, before.length - 1) + after);
|
2060 | syn.selectText(this, sel.start - 1);
|
2061 | } else {
|
2062 | setText(this, before + after);
|
2063 | syn.selectText(this, sel.start);
|
2064 | }
|
2065 | }
|
2066 | },
|
2067 | 'delete': function (options, scope, key, force, sel) {
|
2068 | if (!syn.support.backspaceWorks && syn.typeable.test(this)) {
|
2069 | var current = getText(this), before = current.substr(0, sel.start), after = current.substr(sel.end);
|
2070 | if (sel.start === sel.end && sel.start <= getText(this).length - 1) {
|
2071 | setText(this, before + after.substring(1));
|
2072 | } else {
|
2073 | setText(this, before + after);
|
2074 | }
|
2075 | syn.selectText(this, sel.start);
|
2076 | }
|
2077 | },
|
2078 | '\r': function (options, scope, key, force, sel) {
|
2079 | var nodeName = this.nodeName.toLowerCase();
|
2080 | if (nodeName === 'input') {
|
2081 | syn.trigger(this, 'change', {});
|
2082 | }
|
2083 | if (!syn.support.keypressSubmits && nodeName === 'input') {
|
2084 | var form = syn.closest(this, 'form');
|
2085 | if (form) {
|
2086 | syn.trigger(form, 'submit', {});
|
2087 | }
|
2088 | }
|
2089 | if (!syn.support.keyCharacters && nodeName === 'textarea') {
|
2090 | syn.key.defaults.character.call(this, options, scope, '\n', undefined, sel);
|
2091 | }
|
2092 | if (!syn.support.keypressOnAnchorClicks && nodeName === 'a') {
|
2093 | syn.trigger(this, 'click', {});
|
2094 | }
|
2095 | },
|
2096 | '\t': function (options, scope) {
|
2097 | var focusEls = getFocusable(this), current = null, i = 0, el, firstNotIndexed, orders = [];
|
2098 | for (; i < focusEls.length; i++) {
|
2099 | orders.push([
|
2100 | focusEls[i],
|
2101 | i
|
2102 | ]);
|
2103 | }
|
2104 | var sort = function (order1, order2) {
|
2105 | var el1 = order1[0], el2 = order2[0], tab1 = syn.tabIndex(el1) || 0, tab2 = syn.tabIndex(el2) || 0;
|
2106 | if (tab1 === tab2) {
|
2107 | return order1[1] - order2[1];
|
2108 | } else {
|
2109 | if (tab1 === 0) {
|
2110 | return 1;
|
2111 | } else if (tab2 === 0) {
|
2112 | return -1;
|
2113 | } else {
|
2114 | return tab1 - tab2;
|
2115 | }
|
2116 | }
|
2117 | };
|
2118 | orders.sort(sort);
|
2119 | var ordersLength = orders.length;
|
2120 | for (i = 0; i < ordersLength; i++) {
|
2121 | el = orders[i][0];
|
2122 | if (this === el) {
|
2123 | var nextIndex = i;
|
2124 | if (syn.key.shiftKey) {
|
2125 | nextIndex--;
|
2126 | current = nextIndex >= 0 && orders[nextIndex][0] || orders[ordersLength - 1][0];
|
2127 | } else {
|
2128 | nextIndex++;
|
2129 | current = nextIndex < ordersLength && orders[nextIndex][0] || orders[0][0];
|
2130 | }
|
2131 | }
|
2132 | }
|
2133 | if (!current) {
|
2134 | current = firstNotIndexed;
|
2135 | } else {
|
2136 | syn.__tryFocus(current);
|
2137 | }
|
2138 | return current;
|
2139 | },
|
2140 | 'left': function (options, scope, key, force, sel) {
|
2141 | if (syn.typeable.test(this)) {
|
2142 | if (syn.key.shiftKey) {
|
2143 | syn.selectText(this, sel.start === 0 ? 0 : sel.start - 1, sel.end);
|
2144 | } else {
|
2145 | syn.selectText(this, sel.start === 0 ? 0 : sel.start - 1);
|
2146 | }
|
2147 | }
|
2148 | },
|
2149 | 'right': function (options, scope, key, force, sel) {
|
2150 | if (syn.typeable.test(this)) {
|
2151 | if (syn.key.shiftKey) {
|
2152 | syn.selectText(this, sel.start, sel.end + 1 > getText(this).length ? getText(this).length : sel.end + 1);
|
2153 | } else {
|
2154 | syn.selectText(this, sel.end + 1 > getText(this).length ? getText(this).length : sel.end + 1);
|
2155 | }
|
2156 | }
|
2157 | },
|
2158 | 'up': function () {
|
2159 | if (/select/i.test(this.nodeName)) {
|
2160 | this.selectedIndex = this.selectedIndex ? this.selectedIndex - 1 : 0;
|
2161 | }
|
2162 | },
|
2163 | 'down': function () {
|
2164 | if (/select/i.test(this.nodeName)) {
|
2165 | syn.changeOnBlur(this, 'selectedIndex', this.selectedIndex);
|
2166 | this.selectedIndex = this.selectedIndex + 1;
|
2167 | }
|
2168 | },
|
2169 | 'shift': function () {
|
2170 | return null;
|
2171 | },
|
2172 | 'ctrl': function () {
|
2173 | return null;
|
2174 | },
|
2175 | 'alt': function () {
|
2176 | return null;
|
2177 | },
|
2178 | 'meta': function () {
|
2179 | return null;
|
2180 | }
|
2181 | }
|
2182 | });
|
2183 | h.extend(syn.create, {
|
2184 | keydown: {
|
2185 | setup: function (type, options, element) {
|
2186 | if (h.inArray(options, syn.key.kinds.special) !== -1) {
|
2187 | syn.key[options + 'Key'] = element;
|
2188 | }
|
2189 | }
|
2190 | },
|
2191 | keypress: {
|
2192 | setup: function (type, options, element) {
|
2193 | if (syn.support.keyCharacters && !syn.support.keysOnNotFocused) {
|
2194 | syn.__tryFocus(element);
|
2195 | }
|
2196 | }
|
2197 | },
|
2198 | keyup: {
|
2199 | setup: function (type, options, element) {
|
2200 | if (h.inArray(options, syn.key.kinds.special) !== -1) {
|
2201 | syn.key[options + 'Key'] = null;
|
2202 | }
|
2203 | }
|
2204 | },
|
2205 | key: {
|
2206 | options: function (type, options, element) {
|
2207 | options = typeof options !== 'object' ? { character: options } : options;
|
2208 | options = h.extend({}, options);
|
2209 | if (options.character) {
|
2210 | h.extend(options, syn.key.options(options.character, type));
|
2211 | delete options.character;
|
2212 | }
|
2213 | options = h.extend({
|
2214 | ctrlKey: !!syn.key.ctrlKey,
|
2215 | altKey: !!syn.key.altKey,
|
2216 | shiftKey: !!syn.key.shiftKey,
|
2217 | metaKey: !!syn.key.metaKey
|
2218 | }, options);
|
2219 | return options;
|
2220 | },
|
2221 | event: function (type, options, element) {
|
2222 | var doc = h.getWindow(element).document || document, event;
|
2223 | if (doc.createEvent) {
|
2224 | try {
|
2225 | event = doc.createEvent('KeyEvents');
|
2226 | event.initKeyEvent(type, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode);
|
2227 | } catch (e) {
|
2228 | event = h.createBasicStandardEvent(type, options, doc);
|
2229 | }
|
2230 | event.synthetic = true;
|
2231 | return event;
|
2232 | } else {
|
2233 | try {
|
2234 | event = h.createEventObject.apply(this, arguments);
|
2235 | h.extend(event, options);
|
2236 | } catch (e) {
|
2237 | }
|
2238 | return event;
|
2239 | }
|
2240 | }
|
2241 | }
|
2242 | });
|
2243 | var convert = {
|
2244 | 'enter': '\r',
|
2245 | 'backspace': '\b',
|
2246 | 'tab': '\t',
|
2247 | 'space': ' '
|
2248 | };
|
2249 | h.extend(syn.init.prototype, {
|
2250 | _key: function (element, options, callback) {
|
2251 | if (/-up$/.test(options) && h.inArray(options.replace('-up', ''), syn.key.kinds.special) !== -1) {
|
2252 | syn.trigger(element, 'keyup', options.replace('-up', ''));
|
2253 | return callback(true, element);
|
2254 | }
|
2255 | var activeElement = h.getWindow(element).document.activeElement, caret = syn.typeable.test(element) && getSelection(element), key = convert[options] || options, runDefaults = syn.trigger(element, 'keydown', key), getDefault = syn.key.getDefault, prevent = syn.key.browser.prevent, defaultResult, keypressOptions = syn.key.options(key, 'keypress');
|
2256 | if (runDefaults) {
|
2257 | if (!keypressOptions) {
|
2258 | defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret);
|
2259 | } else {
|
2260 | if (activeElement !== h.getWindow(element).document.activeElement) {
|
2261 | element = h.getWindow(element).document.activeElement;
|
2262 | }
|
2263 | runDefaults = syn.trigger(element, 'keypress', keypressOptions);
|
2264 | if (runDefaults) {
|
2265 | defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret);
|
2266 | }
|
2267 | }
|
2268 | } else {
|
2269 | if (keypressOptions && h.inArray('keypress', prevent.keydown) === -1) {
|
2270 | if (activeElement !== h.getWindow(element).document.activeElement) {
|
2271 | element = h.getWindow(element).document.activeElement;
|
2272 | }
|
2273 | syn.trigger(element, 'keypress', keypressOptions);
|
2274 | }
|
2275 | }
|
2276 | if (defaultResult && defaultResult.nodeName) {
|
2277 | element = defaultResult;
|
2278 | }
|
2279 | if (defaultResult !== null) {
|
2280 | syn.schedule(function () {
|
2281 | if (key === '\r' && element.nodeName.toLowerCase() === 'input') {
|
2282 | } else if (syn.support.oninput) {
|
2283 | syn.trigger(element, 'input', syn.key.options(key, 'input'));
|
2284 | }
|
2285 | syn.trigger(element, 'keyup', syn.key.options(key, 'keyup'));
|
2286 | callback(runDefaults, element);
|
2287 | }, 1);
|
2288 | } else {
|
2289 | callback(runDefaults, element);
|
2290 | }
|
2291 | return element;
|
2292 | },
|
2293 | _type: function (element, options, callback) {
|
2294 | var parts = (options + '').match(/(\[[^\]]+\])|([^\[])/g), self = this, runNextPart = function (runDefaults, el) {
|
2295 | var part = parts.shift();
|
2296 | if (!part) {
|
2297 | callback(runDefaults, el);
|
2298 | return;
|
2299 | }
|
2300 | el = el || element;
|
2301 | if (part.length > 1) {
|
2302 | part = part.substr(1, part.length - 2);
|
2303 | }
|
2304 | self._key(el, part, runNextPart);
|
2305 | };
|
2306 | runNextPart();
|
2307 | }
|
2308 | });
|
2309 | });
|
2310 |
|
2311 | define('syn/key.support', [
|
2312 | 'require',
|
2313 | 'exports',
|
2314 | 'module',
|
2315 | 'syn/synthetic',
|
2316 | 'syn/key'
|
2317 | ], function (require, exports, module) {
|
2318 | var syn = require('syn/synthetic');
|
2319 | require('syn/key');
|
2320 | if (!syn.config.support) {
|
2321 | (function checkForSupport() {
|
2322 | if (!document.body) {
|
2323 | return syn.schedule(checkForSupport, 1);
|
2324 | }
|
2325 | var div = document.createElement('div'), checkbox, submit, form, anchor, textarea, inputter, one, doc;
|
2326 | doc = document.documentElement;
|
2327 | div.innerHTML = '<form id=\'outer\'>' + '<input name=\'checkbox\' type=\'checkbox\'/>' + '<input name=\'radio\' type=\'radio\' />' + '<input type=\'submit\' name=\'submitter\'/>' + '<input type=\'input\' name=\'inputter\'/>' + '<input name=\'one\'>' + '<input name=\'two\'/>' + '<a href=\'#abc\'></a>' + '<textarea>1\n2</textarea>' + '</form>';
|
2328 | doc.insertBefore(div, doc.firstElementChild || doc.children[0]);
|
2329 | form = div.firstChild;
|
2330 | checkbox = form.childNodes[0];
|
2331 | submit = form.childNodes[2];
|
2332 | anchor = form.getElementsByTagName('a')[0];
|
2333 | textarea = form.getElementsByTagName('textarea')[0];
|
2334 | inputter = form.childNodes[3];
|
2335 | one = form.childNodes[4];
|
2336 | form.onsubmit = function (ev) {
|
2337 | if (ev.preventDefault) {
|
2338 | ev.preventDefault();
|
2339 | }
|
2340 | syn.support.keypressSubmits = true;
|
2341 | ev.returnValue = false;
|
2342 | return false;
|
2343 | };
|
2344 | syn.__tryFocus(inputter);
|
2345 | syn.trigger(inputter, 'keypress', '\r');
|
2346 | syn.trigger(inputter, 'keypress', 'a');
|
2347 | syn.support.keyCharacters = inputter.value === 'a';
|
2348 | inputter.value = 'a';
|
2349 | syn.trigger(inputter, 'keypress', '\b');
|
2350 | syn.support.backspaceWorks = inputter.value === '';
|
2351 | inputter.onchange = function () {
|
2352 | syn.support.focusChanges = true;
|
2353 | };
|
2354 | syn.__tryFocus(inputter);
|
2355 | syn.trigger(inputter, 'keypress', 'a');
|
2356 | syn.__tryFocus(form.childNodes[5]);
|
2357 | syn.trigger(inputter, 'keypress', 'b');
|
2358 | syn.support.keysOnNotFocused = inputter.value === 'ab';
|
2359 | syn.bind(anchor, 'click', function (ev) {
|
2360 | if (ev.preventDefault) {
|
2361 | ev.preventDefault();
|
2362 | }
|
2363 | syn.support.keypressOnAnchorClicks = true;
|
2364 | ev.returnValue = false;
|
2365 | return false;
|
2366 | });
|
2367 | syn.trigger(anchor, 'keypress', '\r');
|
2368 | syn.support.textareaCarriage = textarea.value.length === 4;
|
2369 | syn.support.oninput = 'oninput' in one;
|
2370 | doc.removeChild(div);
|
2371 | syn.support.ready++;
|
2372 | }());
|
2373 | } else {
|
2374 | syn.helpers.extend(syn.support, syn.config.support);
|
2375 | }
|
2376 | });
|
2377 |
|
2378 | define('syn/drag', [
|
2379 | 'require',
|
2380 | 'exports',
|
2381 | 'module',
|
2382 | 'syn/synthetic'
|
2383 | ], function (require, exports, module) {
|
2384 | var syn = require('syn/synthetic');
|
2385 | var elementFromPoint = function (point, win) {
|
2386 | var clientX = point.clientX;
|
2387 | var clientY = point.clientY;
|
2388 | if (point == null) {
|
2389 | return null;
|
2390 | }
|
2391 | if (syn.support.elementFromPage) {
|
2392 | var off = syn.helpers.scrollOffset(win);
|
2393 | clientX = clientX + off.left;
|
2394 | clientY = clientY + off.top;
|
2395 | }
|
2396 | return win.document.elementFromPoint(Math.round(clientX), Math.round(clientY));
|
2397 | };
|
2398 | var DragonDrop = {
|
2399 | html5drag: false,
|
2400 | focusWindow: null,
|
2401 | dragAndDrop: function (focusWindow, fromPoint, toPoint, duration, callback) {
|
2402 | this.currentDataTransferItem = null;
|
2403 | this.focusWindow = focusWindow;
|
2404 | this._mouseOver(fromPoint);
|
2405 | this._mouseEnter(fromPoint);
|
2406 | this._mouseMove(fromPoint);
|
2407 | this._mouseDown(fromPoint);
|
2408 | this._dragStart(fromPoint);
|
2409 | this._drag(fromPoint);
|
2410 | this._dragEnter(fromPoint);
|
2411 | this._dragOver(fromPoint);
|
2412 | DragonDrop.startMove(fromPoint, toPoint, duration, function () {
|
2413 | DragonDrop._dragLeave(fromPoint);
|
2414 | DragonDrop._dragEnd(fromPoint);
|
2415 | DragonDrop._mouseOut(fromPoint);
|
2416 | DragonDrop._mouseLeave(fromPoint);
|
2417 | DragonDrop._drop(toPoint);
|
2418 | DragonDrop._dragEnd(toPoint);
|
2419 | DragonDrop._mouseOver(toPoint);
|
2420 | DragonDrop._mouseEnter(toPoint);
|
2421 | DragonDrop._mouseMove(toPoint);
|
2422 | DragonDrop._mouseOut(toPoint);
|
2423 | DragonDrop._mouseLeave(toPoint);
|
2424 | callback();
|
2425 | DragonDrop.cleanup();
|
2426 | });
|
2427 | },
|
2428 | _dragStart: function (node, options) {
|
2429 | this.createAndDispatchEvent(node, 'dragstart', options);
|
2430 | },
|
2431 | _drag: function (node, options) {
|
2432 | this.createAndDispatchEvent(node, 'drag', options);
|
2433 | },
|
2434 | _dragEnter: function (node, options) {
|
2435 | this.createAndDispatchEvent(node, 'dragenter', options);
|
2436 | },
|
2437 | _dragOver: function (node, options) {
|
2438 | this.createAndDispatchEvent(node, 'dragover', options);
|
2439 | },
|
2440 | _dragLeave: function (node, options) {
|
2441 | this.createAndDispatchEvent(node, 'dragleave', options);
|
2442 | },
|
2443 | _drop: function (node, options) {
|
2444 | this.createAndDispatchEvent(node, 'drop', options);
|
2445 | },
|
2446 | _dragEnd: function (node, options) {
|
2447 | this.createAndDispatchEvent(node, 'dragend', options);
|
2448 | },
|
2449 | _mouseDown: function (node, options) {
|
2450 | this.createAndDispatchEvent(node, 'mousedown', options);
|
2451 | },
|
2452 | _mouseMove: function (node, options) {
|
2453 | this.createAndDispatchEvent(node, 'mousemove', options);
|
2454 | },
|
2455 | _mouseEnter: function (node, options) {
|
2456 | this.createAndDispatchEvent(node, 'mouseenter', options);
|
2457 | },
|
2458 | _mouseOver: function (node, options) {
|
2459 | this.createAndDispatchEvent(node, 'mouseover', options);
|
2460 | },
|
2461 | _mouseOut: function (node, options) {
|
2462 | this.createAndDispatchEvent(node, 'mouseout', options);
|
2463 | },
|
2464 | _mouseLeave: function (node, options) {
|
2465 | this.createAndDispatchEvent(node, 'mouseleave', options);
|
2466 | },
|
2467 | createAndDispatchEvent: function (point, eventName, options) {
|
2468 | if (point) {
|
2469 | var targetElement = elementFromPoint(point, this.focusWindow);
|
2470 | syn.trigger(targetElement, eventName, options);
|
2471 | }
|
2472 | },
|
2473 | getDataTransferObject: function () {
|
2474 | if (!this.currentDataTransferItem) {
|
2475 | return this.currentDataTransferItem = this.createDataTransferObject();
|
2476 | } else {
|
2477 | return this.currentDataTransferItem;
|
2478 | }
|
2479 | },
|
2480 | cleanup: function () {
|
2481 | this.currentDataTransferItem = null;
|
2482 | this.focusWindow = null;
|
2483 | },
|
2484 | createDataTransferObject: function () {
|
2485 | var dataTransfer = {
|
2486 | dropEffect: 'none',
|
2487 | effectAllowed: 'uninitialized',
|
2488 | files: [],
|
2489 | items: [],
|
2490 | types: [],
|
2491 | data: [],
|
2492 | setData: function (dataFlavor, value) {
|
2493 | var tempdata = {};
|
2494 | tempdata.dataFlavor = dataFlavor;
|
2495 | tempdata.val = value;
|
2496 | this.data.push(tempdata);
|
2497 | },
|
2498 | getData: function (dataFlavor) {
|
2499 | for (var i = 0; i < this.data.length; i++) {
|
2500 | var tempdata = this.data[i];
|
2501 | if (tempdata.dataFlavor === dataFlavor) {
|
2502 | return tempdata.val;
|
2503 | }
|
2504 | }
|
2505 | }
|
2506 | };
|
2507 | return dataTransfer;
|
2508 | },
|
2509 | startMove: function (start, end, duration, callback) {
|
2510 | var startTime = new Date();
|
2511 | var distX = end.clientX - start.clientX;
|
2512 | var distY = end.clientY - start.clientY;
|
2513 | var win = this.focusWindow;
|
2514 | var current = start;
|
2515 | var cursor = win.document.createElement('div');
|
2516 | var calls = 0;
|
2517 | var move;
|
2518 | move = function onmove() {
|
2519 | var now = new Date();
|
2520 | var scrollOffset = syn.helpers.scrollOffset(win);
|
2521 | var fraction = (calls === 0 ? 0 : now - startTime) / duration;
|
2522 | var options = {
|
2523 | clientX: distX * fraction + start.clientX,
|
2524 | clientY: distY * fraction + start.clientY
|
2525 | };
|
2526 | calls++;
|
2527 | if (fraction < 1) {
|
2528 | syn.helpers.extend(cursor.style, {
|
2529 | left: options.clientX + scrollOffset.left + 2 + 'px',
|
2530 | top: options.clientY + scrollOffset.top + 2 + 'px'
|
2531 | });
|
2532 | current = DragonDrop.mouseMove(options, current);
|
2533 | syn.schedule(onmove, 15);
|
2534 | } else {
|
2535 | current = DragonDrop.mouseMove(end, current);
|
2536 | win.document.body.removeChild(cursor);
|
2537 | callback();
|
2538 | }
|
2539 | };
|
2540 | syn.helpers.extend(cursor.style, {
|
2541 | height: '5px',
|
2542 | width: '5px',
|
2543 | backgroundColor: 'red',
|
2544 | position: 'absolute',
|
2545 | zIndex: 19999,
|
2546 | fontSize: '1px'
|
2547 | });
|
2548 | win.document.body.appendChild(cursor);
|
2549 | move();
|
2550 | },
|
2551 | mouseMove: function (thisPoint, previousPoint) {
|
2552 | var thisElement = elementFromPoint(thisPoint, this.focusWindow);
|
2553 | var previousElement = elementFromPoint(previousPoint, this.focusWindow);
|
2554 | var options = syn.helpers.extend({}, thisPoint);
|
2555 | if (thisElement !== previousElement) {
|
2556 | options.relatedTarget = thisElement;
|
2557 | this._dragLeave(previousPoint, options);
|
2558 | options.relatedTarget = previousElement;
|
2559 | this._dragEnter(thisPoint, options);
|
2560 | }
|
2561 | this._dragOver(thisPoint, options);
|
2562 | return thisPoint;
|
2563 | }
|
2564 | };
|
2565 | function createDragEvent(eventName, options, element) {
|
2566 | var dragEvent = syn.create.mouse.event(eventName, options, element);
|
2567 | dragEvent.dataTransfer = DragonDrop.getDataTransferObject();
|
2568 | return syn.dispatch(dragEvent, element, eventName, false);
|
2569 | }
|
2570 | syn.create.dragstart = { event: createDragEvent };
|
2571 | syn.create.dragenter = { event: createDragEvent };
|
2572 | syn.create.dragover = { event: createDragEvent };
|
2573 | syn.create.dragleave = { event: createDragEvent };
|
2574 | syn.create.drag = { event: createDragEvent };
|
2575 | syn.create.drop = { event: createDragEvent };
|
2576 | syn.create.dragend = { event: createDragEvent };
|
2577 | (function dragSupport() {
|
2578 | if (!document.body) {
|
2579 | syn.schedule(dragSupport, 1);
|
2580 | return;
|
2581 | }
|
2582 | var div = document.createElement('div');
|
2583 | document.body.appendChild(div);
|
2584 | syn.helpers.extend(div.style, {
|
2585 | width: '100px',
|
2586 | height: '10000px',
|
2587 | backgroundColor: 'blue',
|
2588 | position: 'absolute',
|
2589 | top: '10px',
|
2590 | left: '0px',
|
2591 | zIndex: 19999
|
2592 | });
|
2593 | document.body.scrollTop = 11;
|
2594 | if (!document.elementFromPoint) {
|
2595 | return;
|
2596 | }
|
2597 | var el = document.elementFromPoint(3, 1);
|
2598 | if (el === div) {
|
2599 | syn.support.elementFromClient = true;
|
2600 | } else {
|
2601 | syn.support.elementFromPage = true;
|
2602 | }
|
2603 | document.body.removeChild(div);
|
2604 | document.body.scrollTop = 0;
|
2605 | }());
|
2606 | var mouseMove = function (point, win, last) {
|
2607 | var el = elementFromPoint(point, win);
|
2608 | if (last !== el && el && last) {
|
2609 | var options = syn.helpers.extend({}, point);
|
2610 | options.relatedTarget = el;
|
2611 | if (syn.support.pointerEvents) {
|
2612 | syn.trigger(last, 'pointerout', options);
|
2613 | syn.trigger(last, 'pointerleave', options);
|
2614 | }
|
2615 | syn.trigger(last, 'mouseout', options);
|
2616 | syn.trigger(last, 'mouseleave', options);
|
2617 | options.relatedTarget = last;
|
2618 | if (syn.support.pointerEvents) {
|
2619 | syn.trigger(el, 'pointerover', options);
|
2620 | syn.trigger(el, 'pointerenter', options);
|
2621 | }
|
2622 | syn.trigger(el, 'mouseover', options);
|
2623 | syn.trigger(el, 'mouseenter', options);
|
2624 | }
|
2625 | if (syn.support.pointerEvents) {
|
2626 | syn.trigger(el || win, 'pointermove', point);
|
2627 | }
|
2628 | if (syn.support.touchEvents) {
|
2629 | syn.trigger(el || win, 'touchmove', point);
|
2630 | }
|
2631 | if (DragonDrop.html5drag) {
|
2632 | if (!syn.support.pointerEvents) {
|
2633 | syn.trigger(el || win, 'mousemove', point);
|
2634 | }
|
2635 | } else {
|
2636 | syn.trigger(el || win, 'mousemove', point);
|
2637 | }
|
2638 | return el;
|
2639 | }, createEventAtPoint = function (event, point, win) {
|
2640 | var el = elementFromPoint(point, win);
|
2641 | syn.trigger(el || win, event, point);
|
2642 | return el;
|
2643 | }, startMove = function (win, start, end, duration, callback) {
|
2644 | var startTime = new Date(), distX = end.clientX - start.clientX, distY = end.clientY - start.clientY, current = elementFromPoint(start, win), cursor = win.document.createElement('div'), calls = 0, move;
|
2645 | move = function onmove() {
|
2646 | var now = new Date(), scrollOffset = syn.helpers.scrollOffset(win), fraction = (calls === 0 ? 0 : now - startTime) / duration, options = {
|
2647 | clientX: distX * fraction + start.clientX,
|
2648 | clientY: distY * fraction + start.clientY
|
2649 | };
|
2650 | calls++;
|
2651 | if (fraction < 1) {
|
2652 | syn.helpers.extend(cursor.style, {
|
2653 | left: options.clientX + scrollOffset.left + 2 + 'px',
|
2654 | top: options.clientY + scrollOffset.top + 2 + 'px'
|
2655 | });
|
2656 | current = mouseMove(options, win, current);
|
2657 | syn.schedule(onmove, 15);
|
2658 | } else {
|
2659 | current = mouseMove(end, win, current);
|
2660 | win.document.body.removeChild(cursor);
|
2661 | callback();
|
2662 | }
|
2663 | };
|
2664 | syn.helpers.extend(cursor.style, {
|
2665 | height: '5px',
|
2666 | width: '5px',
|
2667 | backgroundColor: 'red',
|
2668 | position: 'absolute',
|
2669 | zIndex: 19999,
|
2670 | fontSize: '1px'
|
2671 | });
|
2672 | win.document.body.appendChild(cursor);
|
2673 | move();
|
2674 | }, startDrag = function (win, fromPoint, toPoint, duration, callback) {
|
2675 | if (syn.support.pointerEvents) {
|
2676 | createEventAtPoint('pointerover', fromPoint, win);
|
2677 | createEventAtPoint('pointerenter', fromPoint, win);
|
2678 | }
|
2679 | createEventAtPoint('mouseover', fromPoint, win);
|
2680 | createEventAtPoint('mouseenter', fromPoint, win);
|
2681 | if (syn.support.pointerEvents) {
|
2682 | createEventAtPoint('pointermove', fromPoint, win);
|
2683 | }
|
2684 | createEventAtPoint('mousemove', fromPoint, win);
|
2685 | if (syn.support.pointerEvents) {
|
2686 | createEventAtPoint('pointerdown', fromPoint, win);
|
2687 | }
|
2688 | if (syn.support.touchEvents) {
|
2689 | createEventAtPoint('touchstart', fromPoint, win);
|
2690 | }
|
2691 | createEventAtPoint('mousedown', fromPoint, win);
|
2692 | startMove(win, fromPoint, toPoint, duration, function () {
|
2693 | if (syn.support.pointerEvents) {
|
2694 | createEventAtPoint('pointerup', toPoint, win);
|
2695 | }
|
2696 | if (syn.support.touchEvents) {
|
2697 | createEventAtPoint('touchend', toPoint, win);
|
2698 | }
|
2699 | createEventAtPoint('mouseup', toPoint, win);
|
2700 | if (syn.support.pointerEvents) {
|
2701 | createEventAtPoint('pointerleave', toPoint, win);
|
2702 | }
|
2703 | createEventAtPoint('mouseleave', toPoint, win);
|
2704 | callback();
|
2705 | });
|
2706 | }, center = function (el) {
|
2707 | var j = syn.jquery()(el), o = j.offset();
|
2708 | return {
|
2709 | pageX: o.left + j.outerWidth() / 2,
|
2710 | pageY: o.top + j.outerHeight() / 2
|
2711 | };
|
2712 | }, convertOption = function (option, win, from) {
|
2713 | var page = /(\d+)[x ](\d+)/, client = /(\d+)X(\d+)/, relative = /([+-]\d+)[xX ]([+-]\d+)/, parts;
|
2714 | if (typeof option === 'string' && relative.test(option) && from) {
|
2715 | var cent = center(from);
|
2716 | parts = option.match(relative);
|
2717 | option = {
|
2718 | pageX: cent.pageX + parseInt(parts[1]),
|
2719 | pageY: cent.pageY + parseInt(parts[2])
|
2720 | };
|
2721 | }
|
2722 | if (typeof option === 'string' && page.test(option)) {
|
2723 | parts = option.match(page);
|
2724 | option = {
|
2725 | pageX: parseInt(parts[1]),
|
2726 | pageY: parseInt(parts[2])
|
2727 | };
|
2728 | }
|
2729 | if (typeof option === 'string' && client.test(option)) {
|
2730 | parts = option.match(client);
|
2731 | option = {
|
2732 | clientX: parseInt(parts[1]),
|
2733 | clientY: parseInt(parts[2])
|
2734 | };
|
2735 | }
|
2736 | if (typeof option === 'string') {
|
2737 | option = syn.jquery()(option, win.document)[0];
|
2738 | }
|
2739 | if (option.nodeName) {
|
2740 | option = center(option);
|
2741 | }
|
2742 | if (option.pageX != null) {
|
2743 | var off = syn.helpers.scrollOffset(win);
|
2744 | option = {
|
2745 | clientX: option.pageX - off.left,
|
2746 | clientY: option.pageY - off.top
|
2747 | };
|
2748 | }
|
2749 | return option;
|
2750 | }, adjust = function (from, to, win) {
|
2751 | if (from.clientY < 0) {
|
2752 | var off = syn.helpers.scrollOffset(win);
|
2753 | var top = off.top + from.clientY - 100, diff = top - off.top;
|
2754 | if (top > 0) {
|
2755 | } else {
|
2756 | top = 0;
|
2757 | diff = -off.top;
|
2758 | }
|
2759 | from.clientY = from.clientY - diff;
|
2760 | to.clientY = to.clientY - diff;
|
2761 | syn.helpers.scrollOffset(win, {
|
2762 | top: top,
|
2763 | left: off.left
|
2764 | });
|
2765 | }
|
2766 | };
|
2767 | syn.helpers.extend(syn.init.prototype, {
|
2768 | _move: function (from, options, callback) {
|
2769 | var win = syn.helpers.getWindow(from);
|
2770 | var sourceCoordinates = convertOption(options.from || from, win, from);
|
2771 | var destinationCoordinates = convertOption(options.to || options, win, from);
|
2772 | DragonDrop.html5drag = syn.support.pointerEvents;
|
2773 | if (options.adjust !== false) {
|
2774 | adjust(sourceCoordinates, destinationCoordinates, win);
|
2775 | }
|
2776 | startMove(win, sourceCoordinates, destinationCoordinates, options.duration || 500, callback);
|
2777 | },
|
2778 | _drag: function (from, options, callback) {
|
2779 | var win = syn.helpers.getWindow(from);
|
2780 | var sourceCoordinates = convertOption(options.from || from, win, from);
|
2781 | var destinationCoordinates = convertOption(options.to || options, win, from);
|
2782 | if (options.adjust !== false) {
|
2783 | adjust(sourceCoordinates, destinationCoordinates, win);
|
2784 | }
|
2785 | DragonDrop.html5drag = from.draggable;
|
2786 | if (DragonDrop.html5drag) {
|
2787 | DragonDrop.dragAndDrop(win, sourceCoordinates, destinationCoordinates, options.duration || 500, callback);
|
2788 | } else {
|
2789 | startDrag(win, sourceCoordinates, destinationCoordinates, options.duration || 500, callback);
|
2790 | }
|
2791 | }
|
2792 | });
|
2793 | });
|
2794 |
|
2795 | define('syn', [
|
2796 | 'require',
|
2797 | 'exports',
|
2798 | 'module',
|
2799 | 'syn/synthetic',
|
2800 | 'syn/mouse.support',
|
2801 | 'syn/browsers',
|
2802 | 'syn/key.support',
|
2803 | 'syn/drag'
|
2804 | ], function (require, exports, module) {
|
2805 | var syn = require('syn/synthetic');
|
2806 | require('syn/mouse.support');
|
2807 | require('syn/browsers');
|
2808 | require('syn/key.support');
|
2809 | require('syn/drag');
|
2810 | window.syn = syn;
|
2811 | module.exports = syn;
|
2812 | });
|
2813 |
|
2814 | (function(global) {
|
2815 | global._define = global.define;
|
2816 | global.define = global.define.orig;
|
2817 | }
|
2818 | )(typeof self == "object" && self.Object == Object ? self : window); |
\ | No newline at end of file |