syn-0.14.1.js 97 KB

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