1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818 |
- /*[global-shim-start]*/
- (function(exports, global, doEval) {
- // jshint ignore:line
- var origDefine = global.define;
- var get = function(name) {
- var parts = name.split("."),
- cur = global,
- i;
- for (i = 0; i < parts.length; i++) {
- if (!cur) {
- break;
- }
- cur = cur[parts[i]];
- }
- return cur;
- };
- var set = function(name, val) {
- var parts = name.split("."),
- cur = global,
- i,
- part,
- next;
- for (i = 0; i < parts.length - 1; i++) {
- part = parts[i];
- next = cur[part];
- if (!next) {
- next = cur[part] = {};
- }
- cur = next;
- }
- part = parts[parts.length - 1];
- cur[part] = val;
- };
- var useDefault = function(mod) {
- if (!mod || !mod.__esModule) return false;
- var esProps = { __esModule: true, default: true };
- for (var p in mod) {
- if (!esProps[p]) return false;
- }
- return true;
- };
- var hasCjsDependencies = function(deps) {
- return (
- deps[0] === "require" && deps[1] === "exports" && deps[2] === "module"
- );
- };
- var modules =
- (global.define && global.define.modules) ||
- (global._define && global._define.modules) ||
- {};
- var ourDefine = (global.define = function(moduleName, deps, callback) {
- var module;
- if (typeof deps === "function") {
- callback = deps;
- deps = [];
- }
- var args = [],
- i;
- for (i = 0; i < deps.length; i++) {
- args.push(
- exports[deps[i]]
- ? get(exports[deps[i]])
- : modules[deps[i]] || get(deps[i])
- );
- }
- // CJS has no dependencies but 3 callback arguments
- if (hasCjsDependencies(deps) || (!deps.length && callback.length)) {
- module = { exports: {} };
- args[0] = function(name) {
- return exports[name] ? get(exports[name]) : modules[name];
- };
- args[1] = module.exports;
- args[2] = module;
- } else if (!args[0] && deps[0] === "exports") {
- // Babel uses the exports and module object.
- module = { exports: {} };
- args[0] = module.exports;
- if (deps[1] === "module") {
- args[1] = module;
- }
- } else if (!args[0] && deps[0] === "module") {
- args[0] = { id: moduleName };
- }
- global.define = origDefine;
- var result = callback ? callback.apply(null, args) : undefined;
- global.define = ourDefine;
- // Favor CJS module.exports over the return value
- result = module && module.exports ? module.exports : result;
- modules[moduleName] = result;
- // Set global exports
- var globalExport = exports[moduleName];
- if (globalExport && !get(globalExport)) {
- if (useDefault(result)) {
- result = result["default"];
- }
- set(globalExport, result);
- }
- });
- global.define.orig = origDefine;
- global.define.modules = modules;
- global.define.amd = true;
- ourDefine("@loader", [], function() {
- // shim for @@global-helpers
- var noop = function() {};
- return {
- get: function() {
- return { prepareGlobal: noop, retrieveGlobal: noop };
- },
- global: global,
- __exec: function(__load) {
- doEval(__load.source, global);
- }
- };
- });
- })(
- {},
- typeof self == "object" && self.Object == Object ? self : window,
- function(__$source__, __$global__) {
- // jshint ignore:line
- eval("(function() { " + __$source__ + " \n }).call(__$global__);");
- }
- );
- /*syn@0.14.1#synthetic*/
- define('syn/synthetic', function (require, exports, module) {
- var opts = window.syn ? window.syn : {};
- var extend = function (d, s) {
- var p;
- for (p in s) {
- d[p] = s[p];
- }
- return d;
- }, browser = {
- msie: !!(window.attachEvent && !window.opera) || navigator.userAgent.indexOf('Trident/') > -1,
- opera: !!window.opera,
- webkit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
- safari: navigator.userAgent.indexOf('AppleWebKit/') > -1 && navigator.userAgent.indexOf('Chrome/') === -1,
- gecko: navigator.userAgent.indexOf('Gecko') > -1,
- mobilesafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/),
- rhino: navigator.userAgent.match(/Rhino/) && true,
- chrome: !!window.chrome && !!window.chrome.webstore
- }, createEventObject = function (type, options, element) {
- var event = element.ownerDocument.createEventObject();
- return extend(event, options);
- }, 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) {
- return new syn.init(type, element, options, callback);
- };
- syn.config = opts;
- syn.__tryFocus = function tryFocus(element) {
- try {
- element.focus();
- } catch (e) {
- }
- };
- bind = function (el, ev, f) {
- return el.addEventListener ? el.addEventListener(ev, f, false) : el.attachEvent('on' + ev, f);
- };
- unbind = function (el, ev, f) {
- return el.addEventListener ? el.removeEventListener(ev, f, false) : el.detachEvent('on' + ev, f);
- };
- schedule = syn.config.schedule || function (fn, ms) {
- setTimeout(fn, ms);
- };
- extend(syn, {
- init: function (type, element, options, callback) {
- var args = syn.args(options, element, callback), self = this;
- this.queue = [];
- this.element = args.element;
- if (typeof this[type] === 'function') {
- this[type](args.element, args.options, function (defaults, el) {
- if (args.callback) {
- args.callback.apply(self, arguments);
- }
- self.done.apply(self, arguments);
- });
- } else {
- this.result = syn.trigger(args.element, type, args.options);
- if (args.callback) {
- args.callback.call(this, args.element, this.result);
- }
- }
- },
- jquery: function (el, fast) {
- if (window.FuncUnit && window.FuncUnit.jQuery) {
- return window.FuncUnit.jQuery;
- }
- if (el) {
- return syn.helpers.getWindow(el).jQuery || window.jQuery;
- } else {
- return window.jQuery;
- }
- },
- args: function () {
- var res = {}, i = 0;
- for (; i < arguments.length; i++) {
- if (typeof arguments[i] === 'function') {
- res.callback = arguments[i];
- } else if (arguments[i] && arguments[i].jquery) {
- res.element = arguments[i][0];
- } else if (arguments[i] && arguments[i].nodeName) {
- res.element = arguments[i];
- } else if (res.options && typeof arguments[i] === 'string') {
- res.element = document.getElementById(arguments[i]);
- } else if (arguments[i]) {
- res.options = arguments[i];
- }
- }
- return res;
- },
- click: function (element, options, callback) {
- syn('click!', element, options, callback);
- },
- defaults: {
- focus: function focus() {
- if (!syn.support.focusChanges) {
- var element = this, nodeName = element.nodeName.toLowerCase();
- syn.data(element, 'syntheticvalue', element.value);
- if (nodeName === 'input' || nodeName === 'textarea') {
- bind(element, 'blur', function blur() {
- if (syn.data(element, 'syntheticvalue') !== element.value) {
- syn.trigger(element, 'change', {});
- }
- unbind(element, 'blur', blur);
- });
- }
- }
- },
- submit: function () {
- syn.onParents(this, function (el) {
- if (el.nodeName.toLowerCase() === 'form') {
- el.submit();
- return false;
- }
- });
- }
- },
- changeOnBlur: function (element, prop, value) {
- bind(element, 'blur', function onblur() {
- if (value !== element[prop]) {
- syn.trigger(element, 'change', {});
- }
- unbind(element, 'blur', onblur);
- });
- },
- closest: function (el, type) {
- while (el && el.nodeName.toLowerCase() !== type.toLowerCase()) {
- el = el.parentNode;
- }
- return el;
- },
- data: function (el, key, value) {
- var d;
- if (!el[expando]) {
- el[expando] = id++;
- }
- if (!data[el[expando]]) {
- data[el[expando]] = {};
- }
- d = data[el[expando]];
- if (value) {
- data[el[expando]][key] = value;
- } else {
- return data[el[expando]][key];
- }
- },
- onParents: function (el, func) {
- var res;
- while (el && res !== false) {
- res = func(el);
- el = el.parentNode;
- }
- return el;
- },
- focusable: /^(a|area|frame|iframe|label|input|select|textarea|button|html|object)$/i,
- isFocusable: function (elem) {
- var attributeNode;
- if (elem.getAttributeNode) {
- attributeNode = elem.getAttributeNode('tabIndex');
- }
- return this.focusable.test(elem.nodeName) || attributeNode && attributeNode.specified && syn.isVisible(elem);
- },
- isVisible: function (elem) {
- return elem.offsetWidth && elem.offsetHeight || elem.clientWidth && elem.clientHeight;
- },
- tabIndex: function (elem) {
- var attributeNode = elem.getAttributeNode('tabIndex');
- return attributeNode && attributeNode.specified && (parseInt(elem.getAttribute('tabIndex')) || 0);
- },
- bind: bind,
- unbind: unbind,
- schedule: schedule,
- browser: browser,
- helpers: {
- createEventObject: createEventObject,
- createBasicStandardEvent: function (type, defaults, doc) {
- var event;
- try {
- event = doc.createEvent('Events');
- } catch (e2) {
- event = doc.createEvent('UIEvents');
- } finally {
- event.initEvent(type, true, true);
- extend(event, defaults);
- }
- return event;
- },
- inArray: function (item, array) {
- var i = 0;
- for (; i < array.length; i++) {
- if (array[i] === item) {
- return i;
- }
- }
- return -1;
- },
- getWindow: function (element) {
- if (element.ownerDocument) {
- return element.ownerDocument.defaultView || element.ownerDocument.parentWindow;
- }
- },
- extend: extend,
- scrollOffset: function (win, set) {
- var doc = win.document.documentElement, body = win.document.body;
- if (set) {
- window.scrollTo(set.left, set.top);
- } else {
- return {
- left: (doc && doc.scrollLeft || body && body.scrollLeft || 0) + (doc.clientLeft || 0),
- top: (doc && doc.scrollTop || body && body.scrollTop || 0) + (doc.clientTop || 0)
- };
- }
- },
- scrollDimensions: function (win) {
- var doc = win.document.documentElement, body = win.document.body, docWidth = doc.clientWidth, docHeight = doc.clientHeight, compat = win.document.compatMode === 'CSS1Compat';
- return {
- height: compat && docHeight || body.clientHeight || docHeight,
- width: compat && docWidth || body.clientWidth || docWidth
- };
- },
- addOffset: function (options, el) {
- var jq = syn.jquery(el), off;
- if (typeof options === 'object' && options.clientX === undefined && options.clientY === undefined && options.pageX === undefined && options.pageY === undefined && jq) {
- el = jq(el);
- off = el.offset();
- options.pageX = off.left + el.width() / 2;
- options.pageY = off.top + el.height() / 2;
- }
- }
- },
- key: {
- ctrlKey: null,
- altKey: null,
- shiftKey: null,
- metaKey: null
- },
- dispatch: function (event, element, type, autoPrevent) {
- if (element.dispatchEvent && event) {
- var preventDefault = event.preventDefault, prevents = autoPrevent ? -1 : 0;
- if (autoPrevent) {
- bind(element, type, function ontype(ev) {
- ev.preventDefault();
- unbind(this, type, ontype);
- });
- }
- event.preventDefault = function () {
- prevents++;
- if (++prevents > 0) {
- preventDefault.apply(this, []);
- }
- };
- element.dispatchEvent(event);
- return prevents <= 0;
- } else {
- try {
- window.event = event;
- } catch (e) {
- }
- return element.sourceIndex <= 0 || element.fireEvent && element.fireEvent('on' + type, event);
- }
- },
- create: {
- page: {
- event: function (type, options, element) {
- var doc = syn.helpers.getWindow(element).document || document, event;
- if (doc.createEvent) {
- event = doc.createEvent('Events');
- event.initEvent(type, true, true);
- return event;
- } else {
- try {
- event = createEventObject(type, options, element);
- } catch (e) {
- }
- return event;
- }
- }
- },
- focus: {
- event: function (type, options, element) {
- syn.onParents(element, function (el) {
- if (syn.isFocusable(el)) {
- if (el.nodeName.toLowerCase() !== 'html') {
- syn.__tryFocus(el);
- activeElement = el;
- } else if (activeElement) {
- var doc = syn.helpers.getWindow(element).document;
- if (doc !== window.document) {
- return false;
- } else if (doc.activeElement) {
- doc.activeElement.blur();
- activeElement = null;
- } else {
- activeElement.blur();
- activeElement = null;
- }
- }
- return false;
- }
- });
- return true;
- }
- }
- },
- support: {
- clickChanges: false,
- clickSubmits: false,
- keypressSubmits: false,
- mouseupSubmits: false,
- radioClickChanges: false,
- focusChanges: false,
- linkHrefJS: false,
- keyCharacters: false,
- backspaceWorks: false,
- mouseDownUpClicks: false,
- tabKeyTabs: false,
- keypressOnAnchorClicks: false,
- optionClickBubbles: false,
- pointerEvents: false,
- touchEvents: false,
- ready: 0
- },
- trigger: function (element, type, options) {
- if (!options) {
- options = {};
- }
- 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;
- if (syn.support.ready === 2 && setup) {
- setup(type, options, element);
- }
- autoPrevent = options._autoPrevent;
- delete options._autoPrevent;
- if (createType.event) {
- ret = createType.event(type, options, element);
- } else {
- options = createKind.options ? createKind.options(type, options, element) : options;
- if (!syn.support.changeBubbles && /option/i.test(element.nodeName)) {
- dispatchEl = element.parentNode;
- }
- event = createKind.event(type, options, dispatchEl);
- ret = syn.dispatch(event, dispatchEl, type, autoPrevent);
- }
- if (ret && syn.support.ready === 2 && syn.defaults[type]) {
- syn.defaults[type].call(element, options, autoPrevent);
- }
- return ret;
- },
- eventSupported: function (eventName) {
- var el = document.createElement('div');
- eventName = 'on' + eventName;
- var isSupported = eventName in el;
- if (!isSupported) {
- el.setAttribute(eventName, 'return;');
- isSupported = typeof el[eventName] === 'function';
- }
- el = null;
- return isSupported;
- }
- });
- extend(syn.init.prototype, {
- then: function (type, element, options, callback) {
- if (syn.autoDelay) {
- this.delay();
- }
- var args = syn.args(options, element, callback), self = this;
- this.queue.unshift(function (el, prevented) {
- if (typeof this[type] === 'function') {
- this.element = args.element || el;
- this[type](this.element, args.options, function (defaults, el) {
- if (args.callback) {
- args.callback.apply(self, arguments);
- }
- self.done.apply(self, arguments);
- });
- } else {
- this.result = syn.trigger(args.element, type, args.options);
- if (args.callback) {
- args.callback.call(this, args.element, this.result);
- }
- return this;
- }
- });
- return this;
- },
- delay: function (timeout, callback) {
- if (typeof timeout === 'function') {
- callback = timeout;
- timeout = null;
- }
- timeout = timeout || 600;
- var self = this;
- this.queue.unshift(function () {
- schedule(function () {
- if (callback) {
- callback.apply(self, []);
- }
- self.done.apply(self, arguments);
- }, timeout);
- });
- return this;
- },
- done: function (defaults, el) {
- if (el) {
- this.element = el;
- }
- if (this.queue.length) {
- this.queue.pop().call(this, this.element, defaults);
- }
- },
- '_click': function (element, options, callback, force) {
- syn.helpers.addOffset(options, element);
- if (syn.support.pointerEvents) {
- syn.trigger(element, 'pointerdown', options);
- }
- if (syn.support.touchEvents) {
- syn.trigger(element, 'touchstart', options);
- }
- syn.trigger(element, 'mousedown', options);
- schedule(function () {
- if (syn.support.pointerEvents) {
- syn.trigger(element, 'pointerup', options);
- }
- if (syn.support.touchEvents) {
- syn.trigger(element, 'touchend', options);
- }
- syn.trigger(element, 'mouseup', options);
- if (!syn.support.mouseDownUpClicks || force) {
- syn.trigger(element, 'click', options);
- callback(true);
- } else {
- syn.create.click.setup('click', options, element);
- syn.defaults.click.call(element);
- schedule(function () {
- callback(true);
- }, 1);
- }
- }, 1);
- },
- '_rightClick': function (element, options, callback) {
- syn.helpers.addOffset(options, element);
- var mouseopts = extend(extend({}, syn.mouse.browser.right.mouseup), options);
- if (syn.support.pointerEvents) {
- syn.trigger(element, 'pointerdown', mouseopts);
- }
- syn.trigger(element, 'mousedown', mouseopts);
- schedule(function () {
- if (syn.support.pointerEvents) {
- syn.trigger(element, 'pointerup', mouseopts);
- }
- syn.trigger(element, 'mouseup', mouseopts);
- if (syn.mouse.browser.right.contextmenu) {
- syn.trigger(element, 'contextmenu', extend(extend({}, syn.mouse.browser.right.contextmenu), options));
- }
- callback(true);
- }, 1);
- },
- '_dblclick': function (element, options, callback) {
- syn.helpers.addOffset(options, element);
- var self = this;
- this._click(element, options, function () {
- schedule(function () {
- self._click(element, options, function () {
- syn.trigger(element, 'dblclick', options);
- callback(true);
- }, true);
- }, 2);
- });
- }
- });
- var actions = [
- 'click',
- 'dblclick',
- 'move',
- 'drag',
- 'key',
- 'type',
- 'rightClick'
- ], makeAction = function (name) {
- syn[name] = function (element, options, callback) {
- return syn('_' + name, element, options, callback);
- };
- syn.init.prototype[name] = function (element, options, callback) {
- return this.then('_' + name, element, options, callback);
- };
- }, i = 0;
- for (; i < actions.length; i++) {
- makeAction(actions[i]);
- }
- module.exports = syn;
- });
- /*syn@0.14.1#mouse*/
- define('syn/mouse', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- var h = syn.helpers, getWin = h.getWindow;
- syn.mouse = {};
- h.extend(syn.defaults, {
- mousedown: function (options) {
- syn.trigger(this, 'focus', {});
- },
- click: function () {
- var element = this, href, type, createChange, radioChanged, nodeName, scope;
- try {
- href = element.href;
- type = element.type;
- createChange = syn.data(element, 'createChange');
- radioChanged = syn.data(element, 'radioChanged');
- scope = getWin(element);
- nodeName = element.nodeName.toLowerCase();
- } catch (e) {
- return;
- }
- if (!syn.support.linkHrefJS && /^\s*javascript:/.test(href)) {
- var code = href.replace(/^\s*javascript:/, '');
- if (code !== '//' && code.indexOf('void(0)') === -1) {
- if (window.selenium) {
- eval('with(selenium.browserbot.getCurrentWindow()){' + code + '}');
- } else {
- eval('with(scope){' + code + '}');
- }
- }
- }
- if (!syn.support.clickSubmits && ((nodeName === 'input' || nodeName === 'button') && type === 'submit')) {
- var form = syn.closest(element, 'form');
- if (form) {
- syn.trigger(form, 'submit', {});
- }
- }
- if (nodeName === 'a' && element.href && !/^\s*javascript:/.test(href)) {
- scope.location.href = href;
- }
- if (nodeName === 'input' && type === 'checkbox') {
- if (!syn.support.clickChanges) {
- syn.trigger(element, 'change', {});
- }
- }
- if (nodeName === 'input' && type === 'radio') {
- if (radioChanged && !syn.support.radioClickChanges) {
- syn.trigger(element, 'change', {});
- }
- }
- if (nodeName === 'option' && createChange) {
- syn.trigger(element.parentNode, 'change', {});
- syn.data(element, 'createChange', false);
- }
- }
- });
- h.extend(syn.create, {
- mouse: {
- options: function (type, options, element) {
- var doc = document.documentElement, body = document.body, center = [
- options.pageX || 0,
- options.pageY || 0
- ], left = syn.mouse.browser && syn.mouse.browser.left[type], right = syn.mouse.browser && syn.mouse.browser.right[type];
- return h.extend({
- bubbles: true,
- cancelable: true,
- view: window,
- detail: 1,
- screenX: 1,
- screenY: 1,
- clientX: options.clientX || center[0] - (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0),
- clientY: options.clientY || center[1] - (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0),
- ctrlKey: !!syn.key.ctrlKey,
- altKey: !!syn.key.altKey,
- shiftKey: !!syn.key.shiftKey,
- metaKey: !!syn.key.metaKey,
- button: left && left.button !== null ? left.button : right && right.button || (type === 'contextmenu' ? 2 : 0),
- relatedTarget: document.documentElement
- }, options);
- },
- event: function (type, defaults, element) {
- var doc = getWin(element).document || document, event;
- if (doc.createEvent) {
- try {
- event = doc.createEvent('MouseEvents');
- 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);
- } catch (e) {
- event = h.createBasicStandardEvent(type, defaults, doc);
- }
- event.synthetic = true;
- return event;
- } else {
- try {
- event = h.createEventObject(type, defaults, element);
- } catch (e) {
- }
- return event;
- }
- }
- },
- click: {
- setup: function (type, options, element) {
- var nodeName = element.nodeName.toLowerCase();
- if (!syn.support.clickChecks && !syn.support.changeChecks && nodeName === 'input') {
- type = element.type.toLowerCase();
- if (type === 'checkbox') {
- element.checked = !element.checked;
- }
- if (type === 'radio') {
- if (!element.checked) {
- try {
- syn.data(element, 'radioChanged', true);
- } catch (e) {
- }
- element.checked = true;
- }
- }
- }
- if (nodeName === 'a' && element.href && !/^\s*javascript:/.test(element.href)) {
- syn.data(element, 'href', element.href);
- }
- if (/option/i.test(element.nodeName)) {
- var child = element.parentNode.firstChild, i = -1;
- while (child) {
- if (child.nodeType === 1) {
- i++;
- if (child === element) {
- break;
- }
- }
- child = child.nextSibling;
- }
- if (i !== element.parentNode.selectedIndex) {
- element.parentNode.selectedIndex = i;
- syn.data(element, 'createChange', true);
- }
- }
- }
- },
- mousedown: {
- setup: function (type, options, element) {
- var nn = element.nodeName.toLowerCase();
- if (syn.browser.safari && (nn === 'select' || nn === 'option')) {
- options._autoPrevent = true;
- }
- }
- }
- });
- });
- /*syn@0.14.1#mouse.support*/
- define('syn/mouse.support', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic',
- 'syn/mouse'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- require('syn/mouse');
- (function checkSupport() {
- if (!document.body) {
- return syn.schedule(checkSupport, 1);
- }
- window.__synthTest = function () {
- syn.support.linkHrefJS = true;
- };
- var div = document.createElement('div'), checkbox, submit, form, select;
- 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>';
- document.documentElement.appendChild(div);
- form = div.firstChild;
- checkbox = form.childNodes[0];
- submit = form.childNodes[2];
- select = form.getElementsByTagName('select')[0];
- syn.trigger(form.childNodes[6], 'click', {});
- checkbox.checked = false;
- checkbox.onchange = function () {
- syn.support.clickChanges = true;
- };
- syn.trigger(checkbox, 'click', {});
- syn.support.clickChecks = checkbox.checked;
- checkbox.checked = false;
- syn.trigger(checkbox, 'change', {});
- syn.support.changeChecks = checkbox.checked;
- form.onsubmit = function (ev) {
- if (ev.preventDefault) {
- ev.preventDefault();
- }
- syn.support.clickSubmits = true;
- return false;
- };
- syn.trigger(submit, 'click', {});
- form.childNodes[1].onchange = function () {
- syn.support.radioClickChanges = true;
- };
- syn.trigger(form.childNodes[1], 'click', {});
- syn.bind(div, 'click', function onclick() {
- syn.support.optionClickBubbles = true;
- syn.unbind(div, 'click', onclick);
- });
- syn.trigger(select.firstChild, 'click', {});
- syn.support.changeBubbles = syn.eventSupported('change');
- div.onclick = function () {
- syn.support.mouseDownUpClicks = true;
- };
- syn.trigger(div, 'mousedown', {});
- syn.trigger(div, 'mouseup', {});
- document.documentElement.removeChild(div);
- syn.support.pointerEvents = syn.eventSupported('pointerdown');
- syn.support.touchEvents = syn.eventSupported('touchstart');
- syn.support.ready++;
- }());
- });
- /*syn@0.14.1#browsers*/
- define('syn/browsers', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic',
- 'syn/mouse'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- require('syn/mouse');
- syn.key.browsers = {
- webkit: {
- 'prevent': {
- 'keyup': [],
- 'keydown': [
- 'char',
- 'keypress'
- ],
- 'keypress': ['char']
- },
- 'character': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 'char',
- 'char'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'specialChars': {
- 'keydown': [
- 0,
- 'char'
- ],
- 'keyup': [
- 0,
- 'char'
- ]
- },
- 'navigation': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'special': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'tab': {
- 'keydown': [
- 0,
- 'char'
- ],
- 'keyup': [
- 0,
- 'char'
- ]
- },
- 'pause-break': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'caps': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'escape': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'num-lock': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'scroll-lock': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'print': {
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'function': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- '\r': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 'char',
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- }
- },
- gecko: {
- 'prevent': {
- 'keyup': [],
- 'keydown': ['char'],
- 'keypress': ['char']
- },
- 'character': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 'char',
- 0
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'specialChars': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'navigation': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'special': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- '\t': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'pause-break': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'caps': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'escape': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'num-lock': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'scroll-lock': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'print': {
- 'keyup': [
- 0,
- 'key'
- ]
- },
- 'function': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- },
- '\r': {
- 'keydown': [
- 0,
- 'key'
- ],
- 'keypress': [
- 0,
- 'key'
- ],
- 'keyup': [
- 0,
- 'key'
- ]
- }
- },
- msie: {
- 'prevent': {
- 'keyup': [],
- 'keydown': [
- 'char',
- 'keypress'
- ],
- 'keypress': ['char']
- },
- 'character': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'char'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'specialChars': {
- 'keydown': [
- null,
- 'char'
- ],
- 'keyup': [
- null,
- 'char'
- ]
- },
- 'navigation': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'special': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'tab': {
- 'keydown': [
- null,
- 'char'
- ],
- 'keyup': [
- null,
- 'char'
- ]
- },
- 'pause-break': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'caps': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'escape': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'num-lock': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'scroll-lock': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'print': {
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'function': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- '\r': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- }
- },
- opera: {
- 'prevent': {
- 'keyup': [],
- 'keydown': [],
- 'keypress': ['char']
- },
- 'character': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'char'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'specialChars': {
- 'keydown': [
- null,
- 'char'
- ],
- 'keypress': [
- null,
- 'char'
- ],
- 'keyup': [
- null,
- 'char'
- ]
- },
- 'navigation': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ]
- },
- 'special': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'tab': {
- 'keydown': [
- null,
- 'char'
- ],
- 'keypress': [
- null,
- 'char'
- ],
- 'keyup': [
- null,
- 'char'
- ]
- },
- 'pause-break': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'caps': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'escape': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ]
- },
- 'num-lock': {
- 'keyup': [
- null,
- 'key'
- ],
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ]
- },
- 'scroll-lock': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- 'print': {},
- 'function': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- },
- '\r': {
- 'keydown': [
- null,
- 'key'
- ],
- 'keypress': [
- null,
- 'key'
- ],
- 'keyup': [
- null,
- 'key'
- ]
- }
- }
- };
- syn.mouse.browsers = {
- webkit: {
- 'right': {
- 'mousedown': {
- 'button': 2,
- 'which': 3
- },
- 'mouseup': {
- 'button': 2,
- 'which': 3
- },
- 'contextmenu': {
- 'button': 2,
- 'which': 3
- }
- },
- 'left': {
- 'mousedown': {
- 'button': 0,
- 'which': 1
- },
- 'mouseup': {
- 'button': 0,
- 'which': 1
- },
- 'click': {
- 'button': 0,
- 'which': 1
- }
- }
- },
- opera: {
- 'right': {
- 'mousedown': {
- 'button': 2,
- 'which': 3
- },
- 'mouseup': {
- 'button': 2,
- 'which': 3
- }
- },
- 'left': {
- 'mousedown': {
- 'button': 0,
- 'which': 1
- },
- 'mouseup': {
- 'button': 0,
- 'which': 1
- },
- 'click': {
- 'button': 0,
- 'which': 1
- }
- }
- },
- msie: {
- 'right': {
- 'mousedown': { 'button': 2 },
- 'mouseup': { 'button': 2 },
- 'contextmenu': { 'button': 0 }
- },
- 'left': {
- 'mousedown': { 'button': 1 },
- 'mouseup': { 'button': 1 },
- 'click': { 'button': 0 }
- }
- },
- chrome: {
- 'right': {
- 'mousedown': {
- 'button': 2,
- 'which': 3
- },
- 'mouseup': {
- 'button': 2,
- 'which': 3
- },
- 'contextmenu': {
- 'button': 2,
- 'which': 3
- }
- },
- 'left': {
- 'mousedown': {
- 'button': 0,
- 'which': 1
- },
- 'mouseup': {
- 'button': 0,
- 'which': 1
- },
- 'click': {
- 'button': 0,
- 'which': 1
- }
- }
- },
- gecko: {
- 'left': {
- 'mousedown': {
- 'button': 0,
- 'which': 1
- },
- 'mouseup': {
- 'button': 0,
- 'which': 1
- },
- 'click': {
- 'button': 0,
- 'which': 1
- }
- },
- 'right': {
- 'mousedown': {
- 'button': 2,
- 'which': 3
- },
- 'mouseup': {
- 'button': 2,
- 'which': 3
- },
- 'contextmenu': {
- 'button': 2,
- 'which': 3
- }
- }
- }
- };
- syn.key.browser = function () {
- if (syn.key.browsers[window.navigator.userAgent]) {
- return syn.key.browsers[window.navigator.userAgent];
- }
- for (var browser in syn.browser) {
- if (syn.browser[browser] && syn.key.browsers[browser]) {
- return syn.key.browsers[browser];
- }
- }
- return syn.key.browsers.gecko;
- }();
- syn.mouse.browser = function () {
- if (syn.mouse.browsers[window.navigator.userAgent]) {
- return syn.mouse.browsers[window.navigator.userAgent];
- }
- for (var browser in syn.browser) {
- if (syn.browser[browser] && syn.mouse.browsers[browser]) {
- return syn.mouse.browsers[browser];
- }
- }
- return syn.mouse.browsers.gecko;
- }();
- });
- /*syn@0.14.1#typeable*/
- define('syn/typeable', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- var typeables = [];
- var __indexOf = [].indexOf || function (item) {
- for (var i = 0, l = this.length; i < l; i++) {
- if (i in this && this[i] === item) {
- return i;
- }
- }
- return -1;
- };
- syn.typeable = function (fn) {
- if (__indexOf.call(typeables, fn) === -1) {
- typeables.push(fn);
- }
- };
- syn.typeable.test = function (el) {
- for (var i = 0, len = typeables.length; i < len; i++) {
- if (typeables[i](el)) {
- return true;
- }
- }
- return false;
- };
- var type = syn.typeable;
- var typeableExp = /input|textarea/i;
- type(function (el) {
- return typeableExp.test(el.nodeName);
- });
- type(function (el) {
- return __indexOf.call([
- '',
- 'true'
- ], el.getAttribute('contenteditable')) !== -1;
- });
- });
- /*syn@0.14.1#key*/
- define('syn/key', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic',
- 'syn/typeable',
- 'syn/browsers'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- require('syn/typeable');
- require('syn/browsers');
- var h = syn.helpers, formElExp = /input|textarea/i, supportsSelection = function (el) {
- var result;
- try {
- result = el.selectionStart !== undefined && el.selectionStart !== null;
- } catch (e) {
- result = false;
- }
- return result;
- }, getSelection = function (el) {
- var real, r, start;
- if (supportsSelection(el)) {
- if (document.activeElement && document.activeElement !== el && el.selectionStart === el.selectionEnd && el.selectionStart === 0) {
- return {
- start: el.value.length,
- end: el.value.length
- };
- }
- return {
- start: el.selectionStart,
- end: el.selectionEnd
- };
- } else {
- try {
- if (el.nodeName.toLowerCase() === 'input') {
- real = h.getWindow(el).document.selection.createRange();
- r = el.createTextRange();
- r.setEndPoint('EndToStart', real);
- start = r.text.length;
- return {
- start: start,
- end: start + real.text.length
- };
- } else {
- real = h.getWindow(el).document.selection.createRange();
- r = real.duplicate();
- var r2 = real.duplicate(), r3 = real.duplicate();
- r2.collapse();
- r3.collapse(false);
- r2.moveStart('character', -1);
- r3.moveStart('character', -1);
- r.moveToElementText(el);
- r.setEndPoint('EndToEnd', real);
- start = r.text.length - real.text.length;
- var end = r.text.length;
- if (start !== 0 && r2.text === '') {
- start += 2;
- }
- if (end !== 0 && r3.text === '') {
- end += 2;
- }
- return {
- start: start,
- end: end
- };
- }
- } catch (e) {
- var prop = formElExp.test(el.nodeName) ? 'value' : 'textContent';
- return {
- start: el[prop].length,
- end: el[prop].length
- };
- }
- }
- }, getFocusable = function (el) {
- var document = h.getWindow(el).document, res = [];
- var els = document.getElementsByTagName('*'), len = els.length;
- for (var i = 0; i < len; i++) {
- if (syn.isFocusable(els[i]) && els[i] !== document.documentElement) {
- res.push(els[i]);
- }
- }
- return res;
- }, textProperty = function () {
- var el = document.createElement('span');
- return el.textContent != null ? 'textContent' : 'innerText';
- }(), getText = function (el) {
- if (formElExp.test(el.nodeName)) {
- return el.value;
- }
- return el[textProperty];
- }, setText = function (el, value) {
- if (formElExp.test(el.nodeName)) {
- el.value = value;
- } else {
- el[textProperty] = value;
- }
- };
- h.extend(syn, {
- keycodes: {
- '\b': 8,
- '\t': 9,
- '\r': 13,
- 'shift': 16,
- 'ctrl': 17,
- 'alt': 18,
- 'meta': 91,
- 'pause-break': 19,
- 'caps': 20,
- 'escape': 27,
- 'num-lock': 144,
- 'scroll-lock': 145,
- 'print': 44,
- 'page-up': 33,
- 'page-down': 34,
- 'end': 35,
- 'home': 36,
- 'left': 37,
- 'up': 38,
- 'right': 39,
- 'down': 40,
- 'insert': 45,
- 'delete': 46,
- ' ': 32,
- '0': 48,
- '1': 49,
- '2': 50,
- '3': 51,
- '4': 52,
- '5': 53,
- '6': 54,
- '7': 55,
- '8': 56,
- '9': 57,
- 'a': 65,
- 'b': 66,
- 'c': 67,
- 'd': 68,
- 'e': 69,
- 'f': 70,
- 'g': 71,
- 'h': 72,
- 'i': 73,
- 'j': 74,
- 'k': 75,
- 'l': 76,
- 'm': 77,
- 'n': 78,
- 'o': 79,
- 'p': 80,
- 'q': 81,
- 'r': 82,
- 's': 83,
- 't': 84,
- 'u': 85,
- 'v': 86,
- 'w': 87,
- 'x': 88,
- 'y': 89,
- 'z': 90,
- 'num0': 96,
- 'num1': 97,
- 'num2': 98,
- 'num3': 99,
- 'num4': 100,
- 'num5': 101,
- 'num6': 102,
- 'num7': 103,
- 'num8': 104,
- 'num9': 105,
- '*': 106,
- '+': 107,
- 'subtract': 109,
- 'decimal': 110,
- 'divide': 111,
- ';': 186,
- '=': 187,
- ',': 188,
- 'dash': 189,
- '-': 189,
- 'period': 190,
- '.': 190,
- 'forward-slash': 191,
- '/': 191,
- '`': 192,
- '[': 219,
- '\\': 220,
- ']': 221,
- '\'': 222,
- 'left window key': 91,
- 'right window key': 92,
- 'select key': 93,
- 'f1': 112,
- 'f2': 113,
- 'f3': 114,
- 'f4': 115,
- 'f5': 116,
- 'f6': 117,
- 'f7': 118,
- 'f8': 119,
- 'f9': 120,
- 'f10': 121,
- 'f11': 122,
- 'f12': 123
- },
- selectText: function (el, start, end) {
- if (supportsSelection(el)) {
- if (!end) {
- syn.__tryFocus(el);
- el.setSelectionRange(start, start);
- } else {
- el.selectionStart = start;
- el.selectionEnd = end;
- }
- } else if (el.createTextRange) {
- var r = el.createTextRange();
- r.moveStart('character', start);
- end = end || start;
- r.moveEnd('character', end - el.value.length);
- r.select();
- }
- },
- getText: function (el) {
- if (syn.typeable.test(el)) {
- var sel = getSelection(el);
- return el.value.substring(sel.start, sel.end);
- }
- var win = syn.helpers.getWindow(el);
- if (win.getSelection) {
- return win.getSelection().toString();
- } else if (win.document.getSelection) {
- return win.document.getSelection().toString();
- } else {
- return win.document.selection.createRange().text;
- }
- },
- getSelection: getSelection
- });
- h.extend(syn.key, {
- data: function (key) {
- if (syn.key.browser[key]) {
- return syn.key.browser[key];
- }
- for (var kind in syn.key.kinds) {
- if (h.inArray(key, syn.key.kinds[kind]) > -1) {
- return syn.key.browser[kind];
- }
- }
- return syn.key.browser.character;
- },
- isSpecial: function (keyCode) {
- var specials = syn.key.kinds.special;
- for (var i = 0; i < specials.length; i++) {
- if (syn.keycodes[specials[i]] === keyCode) {
- return specials[i];
- }
- }
- },
- options: function (key, event) {
- var keyData = syn.key.data(key);
- if (!keyData[event]) {
- return null;
- }
- var charCode = keyData[event][0], keyCode = keyData[event][1], result = {};
- if (keyCode === 'key') {
- result.keyCode = syn.keycodes[key];
- } else if (keyCode === 'char') {
- result.keyCode = key.charCodeAt(0);
- } else {
- result.keyCode = keyCode;
- }
- if (charCode === 'char') {
- result.charCode = key.charCodeAt(0);
- } else if (charCode !== null) {
- result.charCode = charCode;
- }
- if (result.keyCode) {
- result.which = result.keyCode;
- } else {
- result.which = result.charCode;
- }
- return result;
- },
- kinds: {
- special: [
- 'shift',
- 'ctrl',
- 'alt',
- 'meta',
- 'caps'
- ],
- specialChars: ['\b'],
- navigation: [
- 'page-up',
- 'page-down',
- 'end',
- 'home',
- 'left',
- 'up',
- 'right',
- 'down',
- 'insert',
- 'delete'
- ],
- 'function': [
- 'f1',
- 'f2',
- 'f3',
- 'f4',
- 'f5',
- 'f6',
- 'f7',
- 'f8',
- 'f9',
- 'f10',
- 'f11',
- 'f12'
- ]
- },
- getDefault: function (key) {
- if (syn.key.defaults[key]) {
- return syn.key.defaults[key];
- }
- for (var kind in syn.key.kinds) {
- if (h.inArray(key, syn.key.kinds[kind]) > -1 && syn.key.defaults[kind]) {
- return syn.key.defaults[kind];
- }
- }
- return syn.key.defaults.character;
- },
- defaults: {
- 'character': function (options, scope, key, force, sel) {
- if (/num\d+/.test(key)) {
- key = key.match(/\d+/)[0];
- }
- if (force || !syn.support.keyCharacters && syn.typeable.test(this)) {
- var current = getText(this), before = current.substr(0, sel.start), after = current.substr(sel.end), character = key;
- setText(this, before + character + after);
- var charLength = character === '\n' && syn.support.textareaCarriage ? 2 : character.length;
- syn.selectText(this, before.length + charLength);
- }
- },
- 'c': function (options, scope, key, force, sel) {
- if (syn.key.ctrlKey) {
- syn.key.clipboard = syn.getText(this);
- } else {
- syn.key.defaults.character.apply(this, arguments);
- }
- },
- 'v': function (options, scope, key, force, sel) {
- if (syn.key.ctrlKey) {
- syn.key.defaults.character.call(this, options, scope, syn.key.clipboard, true, sel);
- } else {
- syn.key.defaults.character.apply(this, arguments);
- }
- },
- 'a': function (options, scope, key, force, sel) {
- if (syn.key.ctrlKey) {
- syn.selectText(this, 0, getText(this).length);
- } else {
- syn.key.defaults.character.apply(this, arguments);
- }
- },
- 'home': function () {
- syn.onParents(this, function (el) {
- if (el.scrollHeight !== el.clientHeight) {
- el.scrollTop = 0;
- return false;
- }
- });
- },
- 'end': function () {
- syn.onParents(this, function (el) {
- if (el.scrollHeight !== el.clientHeight) {
- el.scrollTop = el.scrollHeight;
- return false;
- }
- });
- },
- 'page-down': function () {
- syn.onParents(this, function (el) {
- if (el.scrollHeight !== el.clientHeight) {
- var ch = el.clientHeight;
- el.scrollTop += ch;
- return false;
- }
- });
- },
- 'page-up': function () {
- syn.onParents(this, function (el) {
- if (el.scrollHeight !== el.clientHeight) {
- var ch = el.clientHeight;
- el.scrollTop -= ch;
- return false;
- }
- });
- },
- '\b': function (options, scope, key, force, sel) {
- if (!syn.support.backspaceWorks && syn.typeable.test(this)) {
- var current = getText(this), before = current.substr(0, sel.start), after = current.substr(sel.end);
- if (sel.start === sel.end && sel.start > 0) {
- setText(this, before.substring(0, before.length - 1) + after);
- syn.selectText(this, sel.start - 1);
- } else {
- setText(this, before + after);
- syn.selectText(this, sel.start);
- }
- }
- },
- 'delete': function (options, scope, key, force, sel) {
- if (!syn.support.backspaceWorks && syn.typeable.test(this)) {
- var current = getText(this), before = current.substr(0, sel.start), after = current.substr(sel.end);
- if (sel.start === sel.end && sel.start <= getText(this).length - 1) {
- setText(this, before + after.substring(1));
- } else {
- setText(this, before + after);
- }
- syn.selectText(this, sel.start);
- }
- },
- '\r': function (options, scope, key, force, sel) {
- var nodeName = this.nodeName.toLowerCase();
- if (nodeName === 'input') {
- syn.trigger(this, 'change', {});
- }
- if (!syn.support.keypressSubmits && nodeName === 'input') {
- var form = syn.closest(this, 'form');
- if (form) {
- syn.trigger(form, 'submit', {});
- }
- }
- if (!syn.support.keyCharacters && nodeName === 'textarea') {
- syn.key.defaults.character.call(this, options, scope, '\n', undefined, sel);
- }
- if (!syn.support.keypressOnAnchorClicks && nodeName === 'a') {
- syn.trigger(this, 'click', {});
- }
- },
- '\t': function (options, scope) {
- var focusEls = getFocusable(this), current = null, i = 0, el, firstNotIndexed, orders = [];
- for (; i < focusEls.length; i++) {
- orders.push([
- focusEls[i],
- i
- ]);
- }
- var sort = function (order1, order2) {
- var el1 = order1[0], el2 = order2[0], tab1 = syn.tabIndex(el1) || 0, tab2 = syn.tabIndex(el2) || 0;
- if (tab1 === tab2) {
- return order1[1] - order2[1];
- } else {
- if (tab1 === 0) {
- return 1;
- } else if (tab2 === 0) {
- return -1;
- } else {
- return tab1 - tab2;
- }
- }
- };
- orders.sort(sort);
- var ordersLength = orders.length;
- for (i = 0; i < ordersLength; i++) {
- el = orders[i][0];
- if (this === el) {
- var nextIndex = i;
- if (syn.key.shiftKey) {
- nextIndex--;
- current = nextIndex >= 0 && orders[nextIndex][0] || orders[ordersLength - 1][0];
- } else {
- nextIndex++;
- current = nextIndex < ordersLength && orders[nextIndex][0] || orders[0][0];
- }
- }
- }
- if (!current) {
- current = firstNotIndexed;
- } else {
- syn.__tryFocus(current);
- }
- return current;
- },
- 'left': function (options, scope, key, force, sel) {
- if (syn.typeable.test(this)) {
- if (syn.key.shiftKey) {
- syn.selectText(this, sel.start === 0 ? 0 : sel.start - 1, sel.end);
- } else {
- syn.selectText(this, sel.start === 0 ? 0 : sel.start - 1);
- }
- }
- },
- 'right': function (options, scope, key, force, sel) {
- if (syn.typeable.test(this)) {
- if (syn.key.shiftKey) {
- syn.selectText(this, sel.start, sel.end + 1 > getText(this).length ? getText(this).length : sel.end + 1);
- } else {
- syn.selectText(this, sel.end + 1 > getText(this).length ? getText(this).length : sel.end + 1);
- }
- }
- },
- 'up': function () {
- if (/select/i.test(this.nodeName)) {
- this.selectedIndex = this.selectedIndex ? this.selectedIndex - 1 : 0;
- }
- },
- 'down': function () {
- if (/select/i.test(this.nodeName)) {
- syn.changeOnBlur(this, 'selectedIndex', this.selectedIndex);
- this.selectedIndex = this.selectedIndex + 1;
- }
- },
- 'shift': function () {
- return null;
- },
- 'ctrl': function () {
- return null;
- },
- 'alt': function () {
- return null;
- },
- 'meta': function () {
- return null;
- }
- }
- });
- h.extend(syn.create, {
- keydown: {
- setup: function (type, options, element) {
- if (h.inArray(options, syn.key.kinds.special) !== -1) {
- syn.key[options + 'Key'] = element;
- }
- }
- },
- keypress: {
- setup: function (type, options, element) {
- if (syn.support.keyCharacters && !syn.support.keysOnNotFocused) {
- syn.__tryFocus(element);
- }
- }
- },
- keyup: {
- setup: function (type, options, element) {
- if (h.inArray(options, syn.key.kinds.special) !== -1) {
- syn.key[options + 'Key'] = null;
- }
- }
- },
- key: {
- options: function (type, options, element) {
- options = typeof options !== 'object' ? { character: options } : options;
- options = h.extend({}, options);
- if (options.character) {
- h.extend(options, syn.key.options(options.character, type));
- delete options.character;
- }
- options = h.extend({
- ctrlKey: !!syn.key.ctrlKey,
- altKey: !!syn.key.altKey,
- shiftKey: !!syn.key.shiftKey,
- metaKey: !!syn.key.metaKey
- }, options);
- return options;
- },
- event: function (type, options, element) {
- var doc = h.getWindow(element).document || document, event;
- if (doc.createEvent) {
- try {
- event = doc.createEvent('KeyEvents');
- event.initKeyEvent(type, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode);
- } catch (e) {
- event = h.createBasicStandardEvent(type, options, doc);
- }
- event.synthetic = true;
- return event;
- } else {
- try {
- event = h.createEventObject.apply(this, arguments);
- h.extend(event, options);
- } catch (e) {
- }
- return event;
- }
- }
- }
- });
- var convert = {
- 'enter': '\r',
- 'backspace': '\b',
- 'tab': '\t',
- 'space': ' '
- };
- h.extend(syn.init.prototype, {
- _key: function (element, options, callback) {
- if (/-up$/.test(options) && h.inArray(options.replace('-up', ''), syn.key.kinds.special) !== -1) {
- syn.trigger(element, 'keyup', options.replace('-up', ''));
- return callback(true, element);
- }
- 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');
- if (runDefaults) {
- if (!keypressOptions) {
- defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret);
- } else {
- if (activeElement !== h.getWindow(element).document.activeElement) {
- element = h.getWindow(element).document.activeElement;
- }
- runDefaults = syn.trigger(element, 'keypress', keypressOptions);
- if (runDefaults) {
- defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret);
- }
- }
- } else {
- if (keypressOptions && h.inArray('keypress', prevent.keydown) === -1) {
- if (activeElement !== h.getWindow(element).document.activeElement) {
- element = h.getWindow(element).document.activeElement;
- }
- syn.trigger(element, 'keypress', keypressOptions);
- }
- }
- if (defaultResult && defaultResult.nodeName) {
- element = defaultResult;
- }
- if (defaultResult !== null) {
- syn.schedule(function () {
- if (key === '\r' && element.nodeName.toLowerCase() === 'input') {
- } else if (syn.support.oninput) {
- syn.trigger(element, 'input', syn.key.options(key, 'input'));
- }
- syn.trigger(element, 'keyup', syn.key.options(key, 'keyup'));
- callback(runDefaults, element);
- }, 1);
- } else {
- callback(runDefaults, element);
- }
- return element;
- },
- _type: function (element, options, callback) {
- var parts = (options + '').match(/(\[[^\]]+\])|([^\[])/g), self = this, runNextPart = function (runDefaults, el) {
- var part = parts.shift();
- if (!part) {
- callback(runDefaults, el);
- return;
- }
- el = el || element;
- if (part.length > 1) {
- part = part.substr(1, part.length - 2);
- }
- self._key(el, part, runNextPart);
- };
- runNextPart();
- }
- });
- });
- /*syn@0.14.1#key.support*/
- define('syn/key.support', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic',
- 'syn/key'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- require('syn/key');
- if (!syn.config.support) {
- (function checkForSupport() {
- if (!document.body) {
- return syn.schedule(checkForSupport, 1);
- }
- var div = document.createElement('div'), checkbox, submit, form, anchor, textarea, inputter, one, doc;
- doc = document.documentElement;
- 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>';
- doc.insertBefore(div, doc.firstElementChild || doc.children[0]);
- form = div.firstChild;
- checkbox = form.childNodes[0];
- submit = form.childNodes[2];
- anchor = form.getElementsByTagName('a')[0];
- textarea = form.getElementsByTagName('textarea')[0];
- inputter = form.childNodes[3];
- one = form.childNodes[4];
- form.onsubmit = function (ev) {
- if (ev.preventDefault) {
- ev.preventDefault();
- }
- syn.support.keypressSubmits = true;
- ev.returnValue = false;
- return false;
- };
- syn.__tryFocus(inputter);
- syn.trigger(inputter, 'keypress', '\r');
- syn.trigger(inputter, 'keypress', 'a');
- syn.support.keyCharacters = inputter.value === 'a';
- inputter.value = 'a';
- syn.trigger(inputter, 'keypress', '\b');
- syn.support.backspaceWorks = inputter.value === '';
- inputter.onchange = function () {
- syn.support.focusChanges = true;
- };
- syn.__tryFocus(inputter);
- syn.trigger(inputter, 'keypress', 'a');
- syn.__tryFocus(form.childNodes[5]);
- syn.trigger(inputter, 'keypress', 'b');
- syn.support.keysOnNotFocused = inputter.value === 'ab';
- syn.bind(anchor, 'click', function (ev) {
- if (ev.preventDefault) {
- ev.preventDefault();
- }
- syn.support.keypressOnAnchorClicks = true;
- ev.returnValue = false;
- return false;
- });
- syn.trigger(anchor, 'keypress', '\r');
- syn.support.textareaCarriage = textarea.value.length === 4;
- syn.support.oninput = 'oninput' in one;
- doc.removeChild(div);
- syn.support.ready++;
- }());
- } else {
- syn.helpers.extend(syn.support, syn.config.support);
- }
- });
- /*syn@0.14.1#drag*/
- define('syn/drag', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- var elementFromPoint = function (point, win) {
- var clientX = point.clientX;
- var clientY = point.clientY;
- if (point == null) {
- return null;
- }
- if (syn.support.elementFromPage) {
- var off = syn.helpers.scrollOffset(win);
- clientX = clientX + off.left;
- clientY = clientY + off.top;
- }
- return win.document.elementFromPoint(Math.round(clientX), Math.round(clientY));
- };
- var DragonDrop = {
- html5drag: false,
- focusWindow: null,
- dragAndDrop: function (focusWindow, fromPoint, toPoint, duration, callback) {
- this.currentDataTransferItem = null;
- this.focusWindow = focusWindow;
- this._mouseOver(fromPoint);
- this._mouseEnter(fromPoint);
- this._mouseMove(fromPoint);
- this._mouseDown(fromPoint);
- this._dragStart(fromPoint);
- this._drag(fromPoint);
- this._dragEnter(fromPoint);
- this._dragOver(fromPoint);
- DragonDrop.startMove(fromPoint, toPoint, duration, function () {
- DragonDrop._dragLeave(fromPoint);
- DragonDrop._dragEnd(fromPoint);
- DragonDrop._mouseOut(fromPoint);
- DragonDrop._mouseLeave(fromPoint);
- DragonDrop._drop(toPoint);
- DragonDrop._dragEnd(toPoint);
- DragonDrop._mouseOver(toPoint);
- DragonDrop._mouseEnter(toPoint);
- DragonDrop._mouseMove(toPoint);
- DragonDrop._mouseOut(toPoint);
- DragonDrop._mouseLeave(toPoint);
- callback();
- DragonDrop.cleanup();
- });
- },
- _dragStart: function (node, options) {
- this.createAndDispatchEvent(node, 'dragstart', options);
- },
- _drag: function (node, options) {
- this.createAndDispatchEvent(node, 'drag', options);
- },
- _dragEnter: function (node, options) {
- this.createAndDispatchEvent(node, 'dragenter', options);
- },
- _dragOver: function (node, options) {
- this.createAndDispatchEvent(node, 'dragover', options);
- },
- _dragLeave: function (node, options) {
- this.createAndDispatchEvent(node, 'dragleave', options);
- },
- _drop: function (node, options) {
- this.createAndDispatchEvent(node, 'drop', options);
- },
- _dragEnd: function (node, options) {
- this.createAndDispatchEvent(node, 'dragend', options);
- },
- _mouseDown: function (node, options) {
- this.createAndDispatchEvent(node, 'mousedown', options);
- },
- _mouseMove: function (node, options) {
- this.createAndDispatchEvent(node, 'mousemove', options);
- },
- _mouseEnter: function (node, options) {
- this.createAndDispatchEvent(node, 'mouseenter', options);
- },
- _mouseOver: function (node, options) {
- this.createAndDispatchEvent(node, 'mouseover', options);
- },
- _mouseOut: function (node, options) {
- this.createAndDispatchEvent(node, 'mouseout', options);
- },
- _mouseLeave: function (node, options) {
- this.createAndDispatchEvent(node, 'mouseleave', options);
- },
- createAndDispatchEvent: function (point, eventName, options) {
- if (point) {
- var targetElement = elementFromPoint(point, this.focusWindow);
- syn.trigger(targetElement, eventName, options);
- }
- },
- getDataTransferObject: function () {
- if (!this.currentDataTransferItem) {
- return this.currentDataTransferItem = this.createDataTransferObject();
- } else {
- return this.currentDataTransferItem;
- }
- },
- cleanup: function () {
- this.currentDataTransferItem = null;
- this.focusWindow = null;
- },
- createDataTransferObject: function () {
- var dataTransfer = {
- dropEffect: 'none',
- effectAllowed: 'uninitialized',
- files: [],
- items: [],
- types: [],
- data: [],
- setData: function (dataFlavor, value) {
- var tempdata = {};
- tempdata.dataFlavor = dataFlavor;
- tempdata.val = value;
- this.data.push(tempdata);
- },
- getData: function (dataFlavor) {
- for (var i = 0; i < this.data.length; i++) {
- var tempdata = this.data[i];
- if (tempdata.dataFlavor === dataFlavor) {
- return tempdata.val;
- }
- }
- }
- };
- return dataTransfer;
- },
- startMove: function (start, end, duration, callback) {
- var startTime = new Date();
- var distX = end.clientX - start.clientX;
- var distY = end.clientY - start.clientY;
- var win = this.focusWindow;
- var current = start;
- var cursor = win.document.createElement('div');
- var calls = 0;
- var move;
- move = function onmove() {
- var now = new Date();
- var scrollOffset = syn.helpers.scrollOffset(win);
- var fraction = (calls === 0 ? 0 : now - startTime) / duration;
- var options = {
- clientX: distX * fraction + start.clientX,
- clientY: distY * fraction + start.clientY
- };
- calls++;
- if (fraction < 1) {
- syn.helpers.extend(cursor.style, {
- left: options.clientX + scrollOffset.left + 2 + 'px',
- top: options.clientY + scrollOffset.top + 2 + 'px'
- });
- current = DragonDrop.mouseMove(options, current);
- syn.schedule(onmove, 15);
- } else {
- current = DragonDrop.mouseMove(end, current);
- win.document.body.removeChild(cursor);
- callback();
- }
- };
- syn.helpers.extend(cursor.style, {
- height: '5px',
- width: '5px',
- backgroundColor: 'red',
- position: 'absolute',
- zIndex: 19999,
- fontSize: '1px'
- });
- win.document.body.appendChild(cursor);
- move();
- },
- mouseMove: function (thisPoint, previousPoint) {
- var thisElement = elementFromPoint(thisPoint, this.focusWindow);
- var previousElement = elementFromPoint(previousPoint, this.focusWindow);
- var options = syn.helpers.extend({}, thisPoint);
- if (thisElement !== previousElement) {
- options.relatedTarget = thisElement;
- this._dragLeave(previousPoint, options);
- options.relatedTarget = previousElement;
- this._dragEnter(thisPoint, options);
- }
- this._dragOver(thisPoint, options);
- return thisPoint;
- }
- };
- function createDragEvent(eventName, options, element) {
- var dragEvent = syn.create.mouse.event(eventName, options, element);
- dragEvent.dataTransfer = DragonDrop.getDataTransferObject();
- return syn.dispatch(dragEvent, element, eventName, false);
- }
- syn.create.dragstart = { event: createDragEvent };
- syn.create.dragenter = { event: createDragEvent };
- syn.create.dragover = { event: createDragEvent };
- syn.create.dragleave = { event: createDragEvent };
- syn.create.drag = { event: createDragEvent };
- syn.create.drop = { event: createDragEvent };
- syn.create.dragend = { event: createDragEvent };
- (function dragSupport() {
- if (!document.body) {
- syn.schedule(dragSupport, 1);
- return;
- }
- var div = document.createElement('div');
- document.body.appendChild(div);
- syn.helpers.extend(div.style, {
- width: '100px',
- height: '10000px',
- backgroundColor: 'blue',
- position: 'absolute',
- top: '10px',
- left: '0px',
- zIndex: 19999
- });
- document.body.scrollTop = 11;
- if (!document.elementFromPoint) {
- return;
- }
- var el = document.elementFromPoint(3, 1);
- if (el === div) {
- syn.support.elementFromClient = true;
- } else {
- syn.support.elementFromPage = true;
- }
- document.body.removeChild(div);
- document.body.scrollTop = 0;
- }());
- var mouseMove = function (point, win, last) {
- var el = elementFromPoint(point, win);
- if (last !== el && el && last) {
- var options = syn.helpers.extend({}, point);
- options.relatedTarget = el;
- if (syn.support.pointerEvents) {
- syn.trigger(last, 'pointerout', options);
- syn.trigger(last, 'pointerleave', options);
- }
- syn.trigger(last, 'mouseout', options);
- syn.trigger(last, 'mouseleave', options);
- options.relatedTarget = last;
- if (syn.support.pointerEvents) {
- syn.trigger(el, 'pointerover', options);
- syn.trigger(el, 'pointerenter', options);
- }
- syn.trigger(el, 'mouseover', options);
- syn.trigger(el, 'mouseenter', options);
- }
- if (syn.support.pointerEvents) {
- syn.trigger(el || win, 'pointermove', point);
- }
- if (syn.support.touchEvents) {
- syn.trigger(el || win, 'touchmove', point);
- }
- if (DragonDrop.html5drag) {
- if (!syn.support.pointerEvents) {
- syn.trigger(el || win, 'mousemove', point);
- }
- } else {
- syn.trigger(el || win, 'mousemove', point);
- }
- return el;
- }, createEventAtPoint = function (event, point, win) {
- var el = elementFromPoint(point, win);
- syn.trigger(el || win, event, point);
- return el;
- }, startMove = function (win, start, end, duration, callback) {
- 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;
- move = function onmove() {
- var now = new Date(), scrollOffset = syn.helpers.scrollOffset(win), fraction = (calls === 0 ? 0 : now - startTime) / duration, options = {
- clientX: distX * fraction + start.clientX,
- clientY: distY * fraction + start.clientY
- };
- calls++;
- if (fraction < 1) {
- syn.helpers.extend(cursor.style, {
- left: options.clientX + scrollOffset.left + 2 + 'px',
- top: options.clientY + scrollOffset.top + 2 + 'px'
- });
- current = mouseMove(options, win, current);
- syn.schedule(onmove, 15);
- } else {
- current = mouseMove(end, win, current);
- win.document.body.removeChild(cursor);
- callback();
- }
- };
- syn.helpers.extend(cursor.style, {
- height: '5px',
- width: '5px',
- backgroundColor: 'red',
- position: 'absolute',
- zIndex: 19999,
- fontSize: '1px'
- });
- win.document.body.appendChild(cursor);
- move();
- }, startDrag = function (win, fromPoint, toPoint, duration, callback) {
- if (syn.support.pointerEvents) {
- createEventAtPoint('pointerover', fromPoint, win);
- createEventAtPoint('pointerenter', fromPoint, win);
- }
- createEventAtPoint('mouseover', fromPoint, win);
- createEventAtPoint('mouseenter', fromPoint, win);
- if (syn.support.pointerEvents) {
- createEventAtPoint('pointermove', fromPoint, win);
- }
- createEventAtPoint('mousemove', fromPoint, win);
- if (syn.support.pointerEvents) {
- createEventAtPoint('pointerdown', fromPoint, win);
- }
- if (syn.support.touchEvents) {
- createEventAtPoint('touchstart', fromPoint, win);
- }
- createEventAtPoint('mousedown', fromPoint, win);
- startMove(win, fromPoint, toPoint, duration, function () {
- if (syn.support.pointerEvents) {
- createEventAtPoint('pointerup', toPoint, win);
- }
- if (syn.support.touchEvents) {
- createEventAtPoint('touchend', toPoint, win);
- }
- createEventAtPoint('mouseup', toPoint, win);
- if (syn.support.pointerEvents) {
- createEventAtPoint('pointerleave', toPoint, win);
- }
- createEventAtPoint('mouseleave', toPoint, win);
- callback();
- });
- }, center = function (el) {
- var j = syn.jquery()(el), o = j.offset();
- return {
- pageX: o.left + j.outerWidth() / 2,
- pageY: o.top + j.outerHeight() / 2
- };
- }, convertOption = function (option, win, from) {
- var page = /(\d+)[x ](\d+)/, client = /(\d+)X(\d+)/, relative = /([+-]\d+)[xX ]([+-]\d+)/, parts;
- if (typeof option === 'string' && relative.test(option) && from) {
- var cent = center(from);
- parts = option.match(relative);
- option = {
- pageX: cent.pageX + parseInt(parts[1]),
- pageY: cent.pageY + parseInt(parts[2])
- };
- }
- if (typeof option === 'string' && page.test(option)) {
- parts = option.match(page);
- option = {
- pageX: parseInt(parts[1]),
- pageY: parseInt(parts[2])
- };
- }
- if (typeof option === 'string' && client.test(option)) {
- parts = option.match(client);
- option = {
- clientX: parseInt(parts[1]),
- clientY: parseInt(parts[2])
- };
- }
- if (typeof option === 'string') {
- option = syn.jquery()(option, win.document)[0];
- }
- if (option.nodeName) {
- option = center(option);
- }
- if (option.pageX != null) {
- var off = syn.helpers.scrollOffset(win);
- option = {
- clientX: option.pageX - off.left,
- clientY: option.pageY - off.top
- };
- }
- return option;
- }, adjust = function (from, to, win) {
- if (from.clientY < 0) {
- var off = syn.helpers.scrollOffset(win);
- var top = off.top + from.clientY - 100, diff = top - off.top;
- if (top > 0) {
- } else {
- top = 0;
- diff = -off.top;
- }
- from.clientY = from.clientY - diff;
- to.clientY = to.clientY - diff;
- syn.helpers.scrollOffset(win, {
- top: top,
- left: off.left
- });
- }
- };
- syn.helpers.extend(syn.init.prototype, {
- _move: function (from, options, callback) {
- var win = syn.helpers.getWindow(from);
- var sourceCoordinates = convertOption(options.from || from, win, from);
- var destinationCoordinates = convertOption(options.to || options, win, from);
- DragonDrop.html5drag = syn.support.pointerEvents;
- if (options.adjust !== false) {
- adjust(sourceCoordinates, destinationCoordinates, win);
- }
- startMove(win, sourceCoordinates, destinationCoordinates, options.duration || 500, callback);
- },
- _drag: function (from, options, callback) {
- var win = syn.helpers.getWindow(from);
- var sourceCoordinates = convertOption(options.from || from, win, from);
- var destinationCoordinates = convertOption(options.to || options, win, from);
- if (options.adjust !== false) {
- adjust(sourceCoordinates, destinationCoordinates, win);
- }
- DragonDrop.html5drag = from.draggable;
- if (DragonDrop.html5drag) {
- DragonDrop.dragAndDrop(win, sourceCoordinates, destinationCoordinates, options.duration || 500, callback);
- } else {
- startDrag(win, sourceCoordinates, destinationCoordinates, options.duration || 500, callback);
- }
- }
- });
- });
- /*syn@0.14.1#syn*/
- define('syn', [
- 'require',
- 'exports',
- 'module',
- 'syn/synthetic',
- 'syn/mouse.support',
- 'syn/browsers',
- 'syn/key.support',
- 'syn/drag'
- ], function (require, exports, module) {
- var syn = require('syn/synthetic');
- require('syn/mouse.support');
- require('syn/browsers');
- require('syn/key.support');
- require('syn/drag');
- window.syn = syn;
- module.exports = syn;
- });
- /*[global-shim-end]*/
- (function(global) { // jshint ignore:line
- global._define = global.define;
- global.define = global.define.orig;
- }
- )(typeof self == "object" && self.Object == Object ? self : window);
|