syn-0.15.0.js 100 KB

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