rave-navigation.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  1. (function() {
  2. // During the rave-navigation.js build, this file is added to the top.
  3. // Create an inner self-executing function that will be run with the global scope
  4. // On browsers, this is 'window'. Everywhere else should use 'this' if available.
  5. // Need to run eval('this') "indirectly" by having eval returned by (1,eval). OBVIOUSLY :)
  6. var _window = (1, eval)('this');
  7. (function (global, factory) {
  8. // dynamically determine how 'rave' variable should be loaded depeneding on loader type
  9. var _rave;
  10. if (typeof module === "object" && typeof module.exports === "object" && typeof require == "function") {
  11. // CommonJS/node.js
  12. var rave = require("rave");
  13. var navigation = factory(global,rave);
  14. module.exports = rave;
  15. } else if (typeof define === "function" && define.amd) {
  16. // AMD
  17. define(['rave'], function(rave) {
  18. return factory(global,rave);
  19. });
  20. } else {
  21. // probably loading via script tag. run as is, setting stuff on rave
  22. factory(global,global['rave']);
  23. }
  24. }(_window, function (_global, _rave) {// $source: com/ibm/rave/navigation/internal/nativeImpl/ModuleHeader
  25. /************************************************************************
  26. ** IBM Confidential
  27. **
  28. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  29. **
  30. ** (C) Copyright IBM Corp. 2014, 2015
  31. **
  32. ** The source code for this program is not published or otherwise divested of its trade secrets,
  33. ** irrespective of what has been deposited with the U.S. Copyright Office.
  34. ************************************************************************/
  35. // setup
  36. var global = typeof _global !== "undefined" ? _global : (1, eval)('this');
  37. var rave = typeof _rave !== "undefined" ? _rave : global['rave'];
  38. var rave_externs = {},
  39. com_ibm_rave_core_Rave = rave,
  40. com_ibm_rave_core_nativeImpl_Declare = rave["_"]["com_ibm_rave_core_nativeImpl_Declare"],
  41. com_ibm_rave_core_selector_Selector = rave["internal"]["Selector"],
  42. com_ibm_rave_core_context_RaveContextManager = rave["internal"]["RaveContextManager"],
  43. com_ibm_rave_core_selector_SelectorDelegate = rave["internal"]["SelectorDelegate"];
  44. // $source: com/ibm/rave/navigation/focus/FocusController
  45. /************************************************************************
  46. ** IBM Confidential
  47. **
  48. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  49. **
  50. ** (C) Copyright IBM Corp. 2017
  51. **
  52. ** The source code for this program is not published or otherwise divested of its trade secrets,
  53. ** irrespective of what has been deposited with the U.S. Copyright Office.
  54. ************************************************************************/
  55. // GENERATED
  56. //@import com/ibm/rave/navigation/NavigationConstants (runtime) // NavigationConstants
  57. /**
  58. * Controller that determines focus order based on navigation index rules. Order is determined in the same way as 'tabIndex'.
  59. */
  60. var com_ibm_rave_navigation_focus_FocusController = rave_externs["FocusController"] = {
  61. };
  62. /**
  63. * Return the focusable node on the previous level.
  64. * @param (com.ibm.rave.core.scene.SceneNode) node The node with focus.
  65. * @return (com.ibm.rave.core.scene.SceneNode) The node on the previous level that should receive focus, or <code>null</code> if none is found.
  66. */
  67. /** @expose */
  68. com_ibm_rave_navigation_focus_FocusController.previousLevelFocusableNode = function(node) {
  69. var focused = node, parent;
  70. while ((parent = focused.rave_getParentNode())) {
  71. if (com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(parent) >= 0) {
  72. break;
  73. }
  74. focused = parent;
  75. }
  76. return parent;
  77. };
  78. /**
  79. * Return the focusable node on the next level.
  80. * @param (com.ibm.rave.core.scene.SceneNode) node The node with focus.
  81. * @return (com.ibm.rave.core.scene.SceneNode) The node on the next level that should receive focus, or <code>null</code> if none is found.
  82. */
  83. /** @expose */
  84. com_ibm_rave_navigation_focus_FocusController.nextLevelFocusableNode = function(node) {
  85. var firstChild = com_ibm_rave_navigation_focus_FocusController.firstChild(node);
  86. var focused = com_ibm_rave_navigation_focus_FocusController.nextFocusableNodeFromStart(firstChild);
  87. if (!focused) {
  88. for (var __i_enFor0 = 0, __exp_enFor0 = node.rave_getChildNodes(), __len_enFor0 = __exp_enFor0.length;
  89. __i_enFor0 < __len_enFor0; ++__i_enFor0) {
  90. var child = __exp_enFor0[__i_enFor0];
  91. focused = com_ibm_rave_navigation_focus_FocusController.nextLevelFocusableNode(child);
  92. if (focused) {
  93. break;
  94. }
  95. }
  96. }
  97. return focused;
  98. };
  99. /**
  100. * Return the previous node that should receive focus, starting from the end of the current scope. The end is determined by using the last child of the current scope.
  101. * @param (com.ibm.rave.core.scene.SceneNode) node The node to use as the current scope.
  102. * @return (com.ibm.rave.core.scene.SceneNode) The previous node that should receive focus, or <code>null</code> if none is found.
  103. */
  104. /** @expose */
  105. com_ibm_rave_navigation_focus_FocusController.previousFocusableNodeFromEnd = function(node) {
  106. return com_ibm_rave_navigation_focus_FocusController._previousFocusableNode(node, null);
  107. };
  108. /**
  109. * Return the previous node that should receive focus.
  110. * @param (com.ibm.rave.core.scene.SceneNode) node The node with focus.
  111. * @return (com.ibm.rave.core.scene.SceneNode) The previous node that should receive focus, or <code>null</code> if none is found.
  112. */
  113. /** @expose */
  114. com_ibm_rave_navigation_focus_FocusController.previousFocusableNode = function(node) {
  115. return com_ibm_rave_navigation_focus_FocusController._previousFocusableNode(node, node);
  116. };
  117. /**
  118. * Find the previous node that should receive focus. A start node can be given to indicate the starting point of the search. If none is given, the scope is used to get the last child as the starting point.
  119. * @param (com.ibm.rave.core.scene.SceneNode) scope A node to indicate the scope of the search.
  120. * @param (com.ibm.rave.core.scene.SceneNode) start The starting point of the search.
  121. * @return (com.ibm.rave.core.scene.SceneNode) The previous node that should receive focus, or <code>null</code> if none is found.
  122. */
  123. com_ibm_rave_navigation_focus_FocusController._previousFocusableNode = function(scope, start) {
  124. var last = com_ibm_rave_navigation_focus_FocusController.lastChild(scope ? scope.rave_getParentNode() : null);
  125. var startingIndex;
  126. var startingNode;
  127. if (start) {
  128. startingIndex = com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(start);
  129. startingNode = start.rave_getPreviousSibling();
  130. } else {
  131. startingIndex = 0;
  132. startingNode = last;
  133. }
  134. if (startingIndex < 0) {
  135. for (var target = startingNode; target; target = target.rave_getPreviousSibling()) {
  136. if (com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(target) >= 0) {
  137. return target;
  138. }
  139. }
  140. } else {
  141. var sameIndex = com_ibm_rave_navigation_focus_FocusController.findNodeWithIndex(startingNode, startingIndex, false);
  142. if (sameIndex) {
  143. return sameIndex;
  144. }
  145. }
  146. startingIndex = start && startingIndex != 0 ? startingIndex : 2147483647;
  147. return com_ibm_rave_navigation_focus_FocusController.findPreviousNodeWithLowerIndex(last, startingIndex);
  148. };
  149. /**
  150. * Return the next node that should receive focus, from the start of the current scope. The start is determined by using the first child of the current scope.
  151. * @param (com.ibm.rave.core.scene.SceneNode) node The node to use as the current scope.
  152. * @return (com.ibm.rave.core.scene.SceneNode) The next node that should receive focus, or <code>null</code> if none is found.
  153. */
  154. /** @expose */
  155. com_ibm_rave_navigation_focus_FocusController.nextFocusableNodeFromStart = function(node) {
  156. return com_ibm_rave_navigation_focus_FocusController._nextFocusableNode(node, null);
  157. };
  158. /**
  159. * Return the next node that should receive focus.
  160. * @param (com.ibm.rave.core.scene.SceneNode) node The node with focus.
  161. * @return (com.ibm.rave.core.scene.SceneNode) The next node that should receive focus, or <code>null</code> if none is found.
  162. */
  163. /** @expose */
  164. com_ibm_rave_navigation_focus_FocusController.nextFocusableNode = function(node) {
  165. return com_ibm_rave_navigation_focus_FocusController._nextFocusableNode(node, node);
  166. };
  167. /**
  168. * Find the next node that should receive focus. A start node can be given to indicate the starting point of the search. If none is given, the scope is used to get the first child as the starting point.
  169. * @param (com.ibm.rave.core.scene.SceneNode) scope A node to indicate the scope of the search.
  170. * @param (com.ibm.rave.core.scene.SceneNode) start The starting point of the search.
  171. * @return (com.ibm.rave.core.scene.SceneNode) The next node that should receive focus, or <code>null</code> if none is found.
  172. */
  173. com_ibm_rave_navigation_focus_FocusController._nextFocusableNode = function(scope, start) {
  174. if (start) {
  175. var index = com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(start);
  176. if (index < 0) {
  177. for (var target = start.rave_getNextSibling(); target; target = target.rave_getNextSibling()) {
  178. if (com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(target) >= 0) {
  179. return target;
  180. }
  181. }
  182. } else {
  183. var sameIndex = com_ibm_rave_navigation_focus_FocusController.findNodeWithIndex(start.rave_getNextSibling(), index, true);
  184. if (sameIndex) {
  185. return sameIndex;
  186. }
  187. }
  188. if (index == 0) {
  189. return null;
  190. }
  191. }
  192. var first = com_ibm_rave_navigation_focus_FocusController.firstChild(scope ? scope.rave_getParentNode() : null);
  193. var next = com_ibm_rave_navigation_focus_FocusController.findNextNodeWithGreaterIndex(first, start ? com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(start) : 0);
  194. if (next) {
  195. return next;
  196. }
  197. return com_ibm_rave_navigation_focus_FocusController.findNodeWithIndex(first, 0, true);
  198. };
  199. /**
  200. * Get the navigation index property on the given node.
  201. * @param (com.ibm.rave.core.scene.SceneNode) node The node.
  202. * @return (int) The value of the navigation index, or 0 if none was found.
  203. */
  204. com_ibm_rave_navigation_focus_FocusController.getNavigationIndex = function(node) {
  205. var index = node.rave_getProperty(com_ibm_rave_navigation_NavigationConstants.NAVIGATION_INDEX_KEY);
  206. return index != null ? ~~ (index) : 0;
  207. };
  208. /**
  209. * Find a node with the specified index.
  210. * @param (com.ibm.rave.core.scene.SceneNode) node The node to use as the starting point of the search. This node is included in the search.
  211. * @param (int) index The index to match.
  212. * @param (boolean) forward The direction of the search. <code>true</true> to search forward, <code>false</false> to search backwards.
  213. * @return (com.ibm.rave.core.scene.SceneNode) The node with the specified index, or <code>null</code> if none is found.
  214. */
  215. com_ibm_rave_navigation_focus_FocusController.findNodeWithIndex = function(node, index, forward) {
  216. for (var target = node; target; target = forward ? target.rave_getNextSibling() : target.rave_getPreviousSibling()) {
  217. if (com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(target) == index) {
  218. return target;
  219. }
  220. }
  221. return null;
  222. };
  223. /**
  224. * Find the next node with an index greater than the one specified.
  225. * @param (com.ibm.rave.core.scene.SceneNode) node The node to use as the starting point of the search. This node is included in the search.
  226. * @param (int) index The index.
  227. * @return (com.ibm.rave.core.scene.SceneNode) The node with an index greater than the one specified, or <code>null</code> if none is found.
  228. */
  229. com_ibm_rave_navigation_focus_FocusController.findNextNodeWithGreaterIndex = function(node, index) {
  230. var greater;
  231. var maxIndex = 2147483647;
  232. for (var target = node; target; target = target.rave_getNextSibling()) {
  233. var currentIndex = com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(target);
  234. if (currentIndex > index && currentIndex < maxIndex) {
  235. maxIndex = currentIndex;
  236. greater = target;
  237. }
  238. }
  239. return greater;
  240. };
  241. /**
  242. * Find the previous node with an index less than the one specified.
  243. * @param (com.ibm.rave.core.scene.SceneNode) node The node to use as the starting point of the search. This node is included in the search.
  244. * @param (int) index The index.
  245. * @return (com.ibm.rave.core.scene.SceneNode) The node with an index lower than the one specified, or <code>null</code> if none is found.
  246. */
  247. com_ibm_rave_navigation_focus_FocusController.findPreviousNodeWithLowerIndex = function(node, index) {
  248. var lower;
  249. var minIndex = 0;
  250. for (var target = node; target; target = target.rave_getPreviousSibling()) {
  251. var currentIndex = com_ibm_rave_navigation_focus_FocusController.getNavigationIndex(target);
  252. if (currentIndex < index && currentIndex > minIndex) {
  253. minIndex = currentIndex;
  254. lower = target;
  255. }
  256. }
  257. return lower;
  258. };
  259. /**
  260. * Get the first child of the provided node.
  261. * @param (com.ibm.rave.core.scene.SceneNode) node The parent node.
  262. * @return (com.ibm.rave.core.scene.SceneNode) The first child of the provided node, or <code>null</code> if none is found.
  263. */
  264. com_ibm_rave_navigation_focus_FocusController.firstChild = function(node) {
  265. var firstChild;
  266. if (node && node.rave_hasChildNodes()) {
  267. firstChild = node.rave_getChildNodes()[0];
  268. }
  269. return firstChild;
  270. };
  271. /**
  272. * Get the last child of the provided node.
  273. * @param (com.ibm.rave.core.scene.SceneNode) node The parent node.
  274. * @return (com.ibm.rave.core.scene.SceneNode) The last child of the provided node, or <code>null</code> if none is found.
  275. */
  276. com_ibm_rave_navigation_focus_FocusController.lastChild = function(node) {
  277. var lastChild;
  278. if (node && node.rave_hasChildNodes()) {
  279. var children = node.rave_getChildNodes();
  280. lastChild = children[children.length - 1];
  281. }
  282. return lastChild;
  283. };
  284. // $source: com/ibm/rave/navigation/NavigationConstants
  285. /************************************************************************
  286. ** IBM Confidential
  287. **
  288. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  289. **
  290. ** (C) Copyright IBM Corp. 2017
  291. **
  292. ** The source code for this program is not published or otherwise divested of its trade secrets,
  293. ** irrespective of what has been deposited with the U.S. Copyright Office.
  294. ************************************************************************/
  295. // GENERATED
  296. var com_ibm_rave_navigation_NavigationConstants = rave_externs["NavigationConstants"] = {
  297. };
  298. /**
  299. * Key for the navigation selector. To access navigation methods on a selector, get the navigation selector from the core selector this way: <code> NavigationSelector navSelector = (NavigationSelector) Rave.select("id").extension(Navigation.SELECTOR_ID); </code>
  300. */
  301. /** @expose */
  302. com_ibm_rave_navigation_NavigationConstants.SELECTOR_ID = "raveNavigation";
  303. /**
  304. * Property key for navigation index.
  305. */
  306. /** @expose */
  307. com_ibm_rave_navigation_NavigationConstants.NAVIGATION_INDEX_KEY = "__raveNavigationIndex__";
  308. // $source: com/ibm/rave/navigation/keyboard/KeyBinding
  309. /************************************************************************
  310. ** IBM Confidential
  311. **
  312. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  313. **
  314. ** (C) Copyright IBM Corp. 2017
  315. **
  316. ** The source code for this program is not published or otherwise divested of its trade secrets,
  317. ** irrespective of what has been deposited with the U.S. Copyright Office.
  318. ************************************************************************/
  319. // GENERATED
  320. //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
  321. var com_ibm_rave_navigation_keyboard_KeyBinding = rave_externs["KeyBinding"] = com_ibm_rave_core_nativeImpl_Declare({
  322. //keyDownMap : null,
  323. //keyPressMap : null,
  324. /**
  325. * Define the keydown listener. It will act on the keydown event by calling the function mapped to the key code(s) in the provided mappings.
  326. */
  327. //keyDownListener : null,
  328. /**
  329. * Define the keypress listener. It will act on the keypress event by calling the function mapped to the key character code(s) in the provided mappings.
  330. */
  331. //keyPressListener : null,
  332. _$functionClassMethod : function() {
  333. var _$self = /**
  334. * @see _$self.KeyBinding#_$self.keybinding(com_ibm_rave_core_selector_Selector)
  335. */
  336. function(args) {
  337. if (args !== null || arguments.length > 1){
  338. args = Array.prototype.slice.call(arguments, 0);
  339. }
  340. {
  341. _$self.keybinding(args[0]);
  342. return null;
  343. }
  344. };
  345. return _$self;
  346. },
  347. constructor : function() {
  348. this.keyDownMap = {};
  349. this.keyPressMap = {};
  350. {
  351. var self = this;
  352. this.keyDownListener = function(data, index, groupIndex, event) {
  353. var callback = com_ibm_rave_navigation_keyboard_KeyBinding.getCallback(self.keyDownMap);
  354. if (callback) {
  355. callback.call(event.target, event);
  356. }
  357. };
  358. this.keyPressListener = function(data, index, groupIndex, event) {
  359. var callback = com_ibm_rave_navigation_keyboard_KeyBinding.getCallback(self.keyPressMap);
  360. if (callback) {
  361. callback.call(event.target, event);
  362. }
  363. };
  364. }
  365. },
  366. /**
  367. * Attach the keydown listener to the keydown event on the provided node. Attach the keypress listener to the keypress event on the provided node.
  368. * @param (com.ibm.rave.core.selector.Selector) g the selector context.
  369. */
  370. /** @expose */
  371. keybinding : function(g) {
  372. g.on("keydown", this.keyDownListener);
  373. g.on("keypress", this.keyPressListener);
  374. },
  375. /**
  376. * Associates a key code to a callback. The key code will trigger the callback on the keydown event.
  377. * @param (int) keyCode The key code.
  378. * @param (com.ibm.rave.core.selector.RunFunction) callback The callback for the key code.
  379. * @return (com.ibm.rave.navigation.keyboard.KeyBinding) This KeyBinding object.
  380. */
  381. on$0 : function(keyCode, callback) {
  382. com_ibm_rave_navigation_keyboard_KeyBinding.addKeyCallback(keyCode, callback, 0, this.keyDownMap);
  383. return this;
  384. },
  385. /**
  386. * Get the callback associated with the provided key.
  387. * @param (int) keyCode The key code.
  388. * @return (com.ibm.rave.core.selector.RunFunction) The callback associated with the key, or null if none found.
  389. */
  390. get$0 : function(keyCode) {
  391. return com_ibm_rave_navigation_keyboard_KeyBinding.getKeyCallback(keyCode, 0, this.keyDownMap);
  392. },
  393. /**
  394. * Associates a key code combination to a callback. The key code combination will trigger the callback on the keydown event.
  395. * @param (int) keyCode The key code.
  396. * @param (com.ibm.rave.core.selector.RunFunction) callback The callback for the key combination.
  397. * @param (int) modifiers bitwise OR value of modifiers from @see Keys
  398. * @return (com.ibm.rave.navigation.keyboard.KeyBinding) This KeyBinding object.
  399. */
  400. on$1 : function(keyCode, callback, modifiers) {
  401. com_ibm_rave_navigation_keyboard_KeyBinding.addKeyCallback(keyCode, callback, modifiers, this.keyDownMap);
  402. return this;
  403. },
  404. /**
  405. * Get the callback associated with the provided key combination.
  406. * @param (int) keyCode The key code.
  407. * @return (com.ibm.rave.core.selector.RunFunction) The callback associated with the key, or null if none found.
  408. */
  409. get$1 : function(keyCode, modifiers) {
  410. return com_ibm_rave_navigation_keyboard_KeyBinding.getKeyCallback(keyCode, modifiers, this.keyDownMap);
  411. },
  412. /**
  413. * Associates a key to a callback. The key will trigger the callback on the keypress event.
  414. * @param (String) key The key.
  415. * @param (com.ibm.rave.core.selector.RunFunction) callback The callback for the key.
  416. * @return (com.ibm.rave.navigation.keyboard.KeyBinding) This KeyBinding object.
  417. */
  418. on$2 : function(key, callback) {
  419. if (key != null && key.length > 0) {
  420. com_ibm_rave_navigation_keyboard_KeyBinding.addKeyCallback(key.charCodeAt(0), callback, 0, this.keyPressMap);
  421. }
  422. return this;
  423. },
  424. /**
  425. * Get the callback associated with the provided key.
  426. * @param (String) key The key.
  427. * @return (com.ibm.rave.core.selector.RunFunction) The callback associated with the key, or null if none found.
  428. */
  429. get$2 : function(key) {
  430. if (key != null && key.length > 0) {
  431. return com_ibm_rave_navigation_keyboard_KeyBinding.getKeyCallback(key.charCodeAt(0), 0, this.keyPressMap);
  432. }
  433. return null;
  434. },
  435. /**
  436. * Associates a key combination to a callback. If the SHIFT modifier is present, the key combination will trigger the callback on the keypress event. Otherwise, the key combination will trigger the callback on the keydown event.
  437. * @param (String) key The key.
  438. * @param (com.ibm.rave.core.selector.RunFunction) callback The callback for the key combination.
  439. * @param (int) modifiers bitwise OR value of modifiers from @see Keys
  440. * @return (com.ibm.rave.navigation.keyboard.KeyBinding) This KeyBinding object.
  441. */
  442. on$3 : function(key, callback, modifiers) {
  443. if (key != null && key.length > 0) {
  444. com_ibm_rave_navigation_keyboard_KeyBinding.addKeyCallback(key.charCodeAt(0), callback, modifiers, modifiers == 8 || modifiers == 0 ? this.keyPressMap : this.keyDownMap);
  445. }
  446. return this;
  447. },
  448. /**
  449. * Get the callback associated with the provided key combination.
  450. * @param (String) key The key.
  451. * @return (com.ibm.rave.core.selector.RunFunction) The callback associated with the key, or null if none found.
  452. */
  453. get$3 : function(key, modifiers) {
  454. if (key != null && key.length > 0) {
  455. return com_ibm_rave_navigation_keyboard_KeyBinding.getKeyCallback(key.charCodeAt(0), modifiers, modifiers == 8 || modifiers == 0 ? this.keyPressMap : this.keyDownMap);
  456. }
  457. return null;
  458. },
  459. /** @expose */
  460. on : function(a0, a1, a2) {
  461. var args = arguments;
  462. if (args.length == 2 && (a0 == null || typeof a0 === "string")) {
  463. return this.on$2(a0, a1);
  464. }
  465. if (args.length == 2) {
  466. return this.on$0(a0, a1);
  467. }
  468. if (args.length == 3 && (a0 == null || typeof a0 === "string") && (a2 == null || typeof a2 === "number")) {
  469. return this.on$3(a0, a1, a2);
  470. }
  471. return this.on$1(a0, a1, a2);
  472. },
  473. /** @expose */
  474. get : function(a0, a1) {
  475. var args = arguments;
  476. if (args.length == 1 && (a0 == null || typeof a0 === "string")) {
  477. return this.get$2(a0);
  478. }
  479. if (args.length == 1) {
  480. return this.get$0(a0);
  481. }
  482. if (args.length == 2 && (a0 == null || typeof a0 === "string") && (a1 == null || typeof a1 === "number")) {
  483. return this.get$3(a0, a1);
  484. }
  485. return this.get$1(a0, a1);
  486. }
  487. });
  488. /**
  489. * Add the key combination and callback to the map.
  490. * @param (int) keyCode The key code.
  491. * @param (com.ibm.rave.core.selector.RunFunction) callback The callback for the key combination.
  492. * @param (int) modifiers Bitwise ORed key modifiers.
  493. * @param (Object) map The map to insert into.
  494. */
  495. com_ibm_rave_navigation_keyboard_KeyBinding.addKeyCallback = function(keyCode, callback, modifiers, map) {
  496. var key = com_ibm_rave_navigation_keyboard_KeyBinding.generateMapKey(keyCode, modifiers);
  497. map[key] = callback;
  498. };
  499. /**
  500. * Return the callback associated to the key combination in the map.
  501. * @param (int) keyCode The key code.
  502. * @param (int) modifiers Bitwise ORed key modifiers.
  503. * @param (Object) map The lookup map.
  504. * @return (com.ibm.rave.core.selector.RunFunction) The callback for the key combination, or null if none found.
  505. */
  506. com_ibm_rave_navigation_keyboard_KeyBinding.getKeyCallback = function(keyCode, modifiers, map) {
  507. var key = com_ibm_rave_navigation_keyboard_KeyBinding.generateMapKey(keyCode, modifiers);
  508. return map[key];
  509. };
  510. /**
  511. * Generate a key from the key code and modifiers.
  512. * @param (int) keyCode The key code.
  513. * @param (int) modifiers Bitwise ORed key modifiers.
  514. * @return (String) A string representation of the generated key.
  515. */
  516. com_ibm_rave_navigation_keyboard_KeyBinding.generateMapKey = function(keyCode, modifiers) {
  517. return keyCode + ":" + modifiers;
  518. };
  519. /**
  520. * Get the callback for the key on the keyboard event.
  521. * @param (Object) map The target map.
  522. * @return (com.ibm.rave.core.selector.RunFunction) The callback function.
  523. */
  524. com_ibm_rave_navigation_keyboard_KeyBinding.getCallback = function(map) {
  525. return map[com_ibm_rave_navigation_keyboard_KeyBinding.getKeyFromEvent(rave.event)];
  526. };
  527. /**
  528. * Get the key code from the keyboard event.
  529. * @param (com.ibm.rave.core.internal.nativeImpl.event.Event) event The KeyBoard event.
  530. * @return (String) The key code.
  531. */
  532. com_ibm_rave_navigation_keyboard_KeyBinding.getKeyFromEvent = function(event) {
  533. var modifiers = 0;
  534. if (event.shiftKey) {
  535. modifiers |= 8;
  536. }
  537. if (event.ctrlKey) {
  538. modifiers |= 4;
  539. }
  540. if (event.altKey) {
  541. modifiers |= 2;
  542. }
  543. if (event.metaKey) {
  544. modifiers |= 1;
  545. }
  546. var keyCode = event.keyCode == 0 ? event.which : event.keyCode;
  547. return com_ibm_rave_navigation_keyboard_KeyBinding.generateMapKey(keyCode, modifiers);
  548. };
  549. // $source: com/ibm/rave/navigation/keyboard/DefaultKeyboard
  550. /************************************************************************
  551. ** IBM Confidential
  552. **
  553. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  554. **
  555. ** (C) Copyright IBM Corp. 2017
  556. **
  557. ** The source code for this program is not published or otherwise divested of its trade secrets,
  558. ** irrespective of what has been deposited with the U.S. Copyright Office.
  559. ************************************************************************/
  560. // GENERATED
  561. //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
  562. //@import com/ibm/rave/navigation/keyboard/KeyBinding (runtime) // new
  563. //@import com/ibm/rave/core/Rave (runtime) // select, Rave
  564. //@import com/ibm/rave/navigation/focus/FocusController (runtime) // nextFocusableNode, nextFocusableNodeFromStart, previousFocusableNodeFromEnd, nextLevelFocusableNode, previousLevelFocusableNode, previousFocusableNode
  565. var com_ibm_rave_navigation_keyboard_DefaultKeyboard = rave_externs["DefaultKeyboard"] = com_ibm_rave_core_nativeImpl_Declare({
  566. //kb : null,
  567. //eventHandler : null,
  568. /** @expose */
  569. next : null,
  570. /** @expose */
  571. previous : null,
  572. /** @expose */
  573. nextLevel : null,
  574. /** @expose */
  575. previousLevel : null,
  576. _$functionClassMethod : function() {
  577. var _$self = function(args) {
  578. if (args !== null || arguments.length > 1){
  579. args = Array.prototype.slice.call(arguments, 0);
  580. }
  581. {
  582. _$self.bind(args[0]);
  583. return null;
  584. }
  585. };
  586. return _$self;
  587. },
  588. constructor : function() {
  589. this.kb = new com_ibm_rave_navigation_keyboard_KeyBinding();
  590. this.eventHandler = com_ibm_rave_core_Rave.behavior.focusEventHandler();
  591. {
  592. var self = this;
  593. this.next = function(args) {
  594. if (args !== null || arguments.length > 1){
  595. args = Array.prototype.slice.call(arguments, 0);
  596. }
  597. {
  598. var focused = self.eventHandler.focusedNode;
  599. if (focused && !(com_ibm_rave_navigation_keyboard_DefaultKeyboard.isNavigationRoot(focused))) {
  600. var nextSibling = com_ibm_rave_navigation_focus_FocusController.nextFocusableNode(focused);
  601. if (!nextSibling) {
  602. nextSibling = com_ibm_rave_navigation_focus_FocusController.nextFocusableNodeFromStart(focused);
  603. }
  604. if (nextSibling) {
  605. self.eventHandler.fireFocus(nextSibling);
  606. }
  607. rave.event.preventDefault();
  608. }
  609. return null;
  610. }
  611. };
  612. this.previous = function(args) {
  613. if (args !== null || arguments.length > 1){
  614. args = Array.prototype.slice.call(arguments, 0);
  615. }
  616. {
  617. var focused = self.eventHandler.focusedNode;
  618. if (focused && !(com_ibm_rave_navigation_keyboard_DefaultKeyboard.isNavigationRoot(focused))) {
  619. var previousSibling = com_ibm_rave_navigation_focus_FocusController.previousFocusableNode(focused);
  620. if (!previousSibling) {
  621. previousSibling = com_ibm_rave_navigation_focus_FocusController.previousFocusableNodeFromEnd(focused);
  622. }
  623. if (previousSibling) {
  624. self.eventHandler.fireFocus(previousSibling);
  625. }
  626. rave.event.preventDefault();
  627. }
  628. return null;
  629. }
  630. };
  631. this.nextLevel = function(args) {
  632. if (args !== null || arguments.length > 1){
  633. args = Array.prototype.slice.call(arguments, 0);
  634. }
  635. {
  636. var focused = self.eventHandler.focusedNode;
  637. if (focused) {
  638. focused = com_ibm_rave_navigation_focus_FocusController.nextLevelFocusableNode(focused);
  639. if (focused) {
  640. self.eventHandler.fireFocus(focused);
  641. }
  642. }
  643. rave.event.preventDefault();
  644. return null;
  645. }
  646. };
  647. this.previousLevel = function(args) {
  648. if (args !== null || arguments.length > 1){
  649. args = Array.prototype.slice.call(arguments, 0);
  650. }
  651. {
  652. var focused = self.eventHandler.focusedNode;
  653. if (focused) {
  654. var parent = com_ibm_rave_navigation_focus_FocusController.previousLevelFocusableNode(focused);
  655. if (com_ibm_rave_navigation_keyboard_DefaultKeyboard.isNavigationRoot(parent)) {
  656. self.eventHandler.fireBlur(focused);
  657. self.eventHandler.focusedNode = parent;
  658. } else if (!(com_ibm_rave_navigation_keyboard_DefaultKeyboard.isNavigationRoot(focused))) {
  659. self.eventHandler.fireFocus(parent);
  660. }
  661. rave.event.preventDefault();
  662. }
  663. return null;
  664. }
  665. };
  666. }
  667. {
  668. this.kb.on(10, this.nextLevel).on(13, this.nextLevel).on(27, this.previousLevel).on(9, this.next).on(9, this.previous, 8);
  669. }
  670. },
  671. /** @expose */
  672. bind : function(g) {
  673. var self = this;
  674. g.each(function(data, index, groupIndex) {
  675. var s = com_ibm_rave_core_Rave.select(this);
  676. com_ibm_rave_core_Rave.select(this.rave_getOwner()).call(self.kb);
  677. s.property(com_ibm_rave_navigation_keyboard_DefaultKeyboard.NATIVATION_ROOT, true);
  678. self.eventHandler.focusedNode = this;
  679. });
  680. },
  681. /** @expose */
  682. keyBinding : function() {
  683. return this.kb;
  684. },
  685. focusEventHandler$0 : function() {
  686. return this.eventHandler;
  687. },
  688. focusEventHandler$1 : function(handler) {
  689. this.eventHandler = handler;
  690. return this;
  691. },
  692. /** @expose */
  693. focusEventHandler : function(a0) {
  694. var args = arguments;
  695. if (args.length == 0) {
  696. return this.focusEventHandler$0();
  697. }
  698. return this.focusEventHandler$1(a0);
  699. }
  700. });
  701. com_ibm_rave_navigation_keyboard_DefaultKeyboard.isNavigationRoot = function(item) {
  702. return item.rave_getProperty(com_ibm_rave_navigation_keyboard_DefaultKeyboard.NATIVATION_ROOT) != null;
  703. };
  704. com_ibm_rave_navigation_keyboard_DefaultKeyboard.NATIVATION_ROOT = "__rave-kbnav-root__";
  705. // $source: com/ibm/rave/navigation/selector/NavigationSelector
  706. /************************************************************************
  707. ** IBM Confidential
  708. **
  709. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  710. **
  711. ** (C) Copyright IBM Corp. 2017
  712. **
  713. ** The source code for this program is not published or otherwise divested of its trade secrets,
  714. ** irrespective of what has been deposited with the U.S. Copyright Office.
  715. ************************************************************************/
  716. // GENERATED
  717. //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
  718. //@import com/ibm/rave/core/selector/SelectorDelegate (loadtime) // superclass
  719. //@import com/ibm/rave/navigation/NavigationConstants (runtime) // NavigationConstants
  720. /**
  721. * Navigation extension to {@link (com.ibm.rave.core.selector.SelectorDelegate) SelectorDelegate} . Adds the ability to perform navigation related functions to a selector.
  722. */
  723. var com_ibm_rave_navigation_selector_NavigationSelector = rave_externs["NavigationSelector"] = com_ibm_rave_core_nativeImpl_Declare(com_ibm_rave_core_selector_SelectorDelegate, {
  724. /**
  725. * Constructor
  726. */
  727. /** @expose */
  728. constructor : function() {},
  729. /**
  730. * Create the extension to the selector.
  731. * @param (com.ibm.rave.core.selector.Selector) s The core selector.
  732. * @return (com.ibm.rave.core.selector.Selector) The extended selector.
  733. */
  734. /** @expose */
  735. create : function(s) {
  736. var ns = new com_ibm_rave_navigation_selector_NavigationSelector();
  737. return ns.setDelegate(s);
  738. },
  739. /**
  740. * Get the navigation index for the first SceneNode in this Selector.
  741. * @return (Object) the navigation index of the first SceneNode in this Selector
  742. */
  743. navigationIndex$0 : function() {
  744. var node = this.node();
  745. return !node ? null : node.rave_getProperty(com_ibm_rave_navigation_NavigationConstants.NAVIGATION_INDEX_KEY);
  746. },
  747. /**
  748. * Set the navigation index for each SceneNode in this Selector.
  749. * @param (int) index the navigation index
  750. * @return (com.ibm.rave.navigation.selector.NavigationSelector) this {@link (com.ibm.rave.navigation.selector.NavigationSelector) NavigationSelector}
  751. */
  752. navigationIndex$1 : function(index) {
  753. this.each$0(function(data, idx, groupIndex) {
  754. this.rave_setProperty(com_ibm_rave_navigation_NavigationConstants.NAVIGATION_INDEX_KEY, index);
  755. });
  756. return this;
  757. },
  758. /**
  759. * Set the navigation index for each SceneNode in this Selector.
  760. * @param (com.ibm.rave.core.selector.ValueFunction) valueFunction a function which returns a navigation index
  761. * @return (com.ibm.rave.navigation.selector.NavigationSelector) this {@link (com.ibm.rave.navigation.selector.NavigationSelector) NavigationSelector}
  762. */
  763. navigationIndex$2 : function(valueFunction) {
  764. this.each$0(function(data, index, groupIndex) {
  765. this.rave_setProperty(com_ibm_rave_navigation_NavigationConstants.NAVIGATION_INDEX_KEY, valueFunction.call(this, data, index, groupIndex));
  766. });
  767. return this;
  768. },
  769. /** @expose */
  770. navigationIndex : function(a0) {
  771. var args = arguments;
  772. if (args.length == 0) {
  773. return this.navigationIndex$0();
  774. }
  775. if (args.length == 1 && typeof a0 === "function") {
  776. return this.navigationIndex$2(a0);
  777. }
  778. return this.navigationIndex$1(a0);
  779. }
  780. });
  781. // $source: com/ibm/rave/navigation/keys/Keys
  782. /************************************************************************
  783. ** IBM Confidential
  784. **
  785. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  786. **
  787. ** (C) Copyright IBM Corp. 2017
  788. **
  789. ** The source code for this program is not published or otherwise divested of its trade secrets,
  790. ** irrespective of what has been deposited with the U.S. Copyright Office.
  791. ************************************************************************/
  792. // GENERATED
  793. //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
  794. /**
  795. * Key mappings for navigation keys and for keyboard modifiers: Shift, Control, Alt and Meta
  796. */
  797. var com_ibm_rave_navigation_keys_Keys = com_ibm_rave_core_nativeImpl_Declare({
  798. /** @expose */
  799. ENTER : 10,
  800. /** @expose */
  801. RETURN : 13,
  802. /** @expose */
  803. ESC : 27,
  804. /** @expose */
  805. TAB : 9,
  806. /** @expose */
  807. SHIFT : 0x08,
  808. /** @expose */
  809. CTRL : 0x04,
  810. /** @expose */
  811. ALT : 0x02,
  812. /** @expose */
  813. META : 0x01
  814. //constructor : function() {}
  815. });
  816. /** @expose */
  817. com_ibm_rave_navigation_keys_Keys.INSTANCE = new com_ibm_rave_navigation_keys_Keys();
  818. // $source: com/ibm/rave/navigation/Navigation
  819. /************************************************************************
  820. ** IBM Confidential
  821. **
  822. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  823. **
  824. ** (C) Copyright IBM Corp. 2017
  825. **
  826. ** The source code for this program is not published or otherwise divested of its trade secrets,
  827. ** irrespective of what has been deposited with the U.S. Copyright Office.
  828. ************************************************************************/
  829. // GENERATED
  830. //@import com/ibm/rave/navigation/keyboard/KeyBinding (static) // new
  831. //@import com/ibm/rave/navigation/keyboard/DefaultKeyboard (static) // new
  832. //@import com/ibm/rave/core/context/RaveContextManager (static) // RaveContextManager
  833. //@import com/ibm/rave/core/selector/Selector (static) // extension
  834. //@import com/ibm/rave/navigation/selector/NavigationSelector (runtime) // new
  835. //@import com/ibm/rave/core/nativeImpl/Declare (loadtime) // declare
  836. //@import com/ibm/rave/navigation/keys/Keys (static) // Keys
  837. //@import com/ibm/rave/navigation/NavigationConstants (static) // NavigationConstants
  838. /**
  839. * Entry point for navigation capabilities.
  840. */
  841. var com_ibm_rave_navigation_Navigation = rave_externs["Navigation"] = {
  842. /**
  843. * Singleton
  844. */
  845. //constructor : function() {}
  846. };
  847. /**
  848. * Creates a new instance of {@link (com.ibm.rave.navigation.keyboard.KeyBinding) KeyBinding} .
  849. * @return (com.ibm.rave.navigation.keyboard.KeyBinding) new instance of {@link (com.ibm.rave.navigation.keyboard.KeyBinding) KeyBinding}
  850. */
  851. /** @expose */
  852. com_ibm_rave_navigation_Navigation.keybinding = function() {
  853. return new com_ibm_rave_navigation_keyboard_KeyBinding();
  854. };
  855. /**
  856. * Creates a new instance of {@link (com.ibm.rave.navigation.keyboard.DefaultKeyboard) DefaultKeyboard} .
  857. * @return (com.ibm.rave.navigation.keyboard.DefaultKeyboard) new instance of {@link (com.ibm.rave.navigation.keyboard.DefaultKeyboard) DefaultKeyboard}
  858. */
  859. /** @expose */
  860. com_ibm_rave_navigation_Navigation.keyboard = function() {
  861. return new com_ibm_rave_navigation_keyboard_DefaultKeyboard();
  862. };
  863. com_ibm_rave_navigation_Navigation.getRegistrationStatus = function() {
  864. var registrationStatus = com_ibm_rave_core_context_RaveContextManager.INSTANCE.getRaveContext().getData("NAVIGATION_EXTENSION_REGISTRATION_STATUS_KEY");
  865. if (!registrationStatus) {
  866. registrationStatus = new com_ibm_rave_navigation_Navigation.RegistrationStatus();
  867. com_ibm_rave_core_context_RaveContextManager.INSTANCE.getRaveContext().putData("NAVIGATION_EXTENSION_REGISTRATION_STATUS_KEY", registrationStatus);
  868. }
  869. return registrationStatus;
  870. };
  871. /**
  872. * Initialize the Navigation feature. This needs to be called before using any navigation features.
  873. */
  874. /** @expose */
  875. com_ibm_rave_navigation_Navigation.init = function() {
  876. var registrationStatus = com_ibm_rave_navigation_Navigation.getRegistrationStatus();
  877. if (!registrationStatus.registered) {
  878. registrationStatus.registered = com_ibm_rave_core_selector_Selector.extension(com_ibm_rave_navigation_Navigation.SELECTOR_ID, function() {
  879. return new com_ibm_rave_navigation_selector_NavigationSelector();
  880. });
  881. }
  882. };
  883. com_ibm_rave_navigation_Navigation.RegistrationStatus = com_ibm_rave_core_nativeImpl_Declare({
  884. registered : false
  885. });
  886. //com_ibm_rave_navigation_Navigation.EXTENSION_REGISTRATION_STATUS_KEY = "NAVIGATION_EXTENSION_REGISTRATION_STATUS_KEY";
  887. /**
  888. * @see (com.ibm.rave.navigation.keys.Keys) Keys
  889. */
  890. /** @expose */
  891. com_ibm_rave_navigation_Navigation.keys = com_ibm_rave_navigation_keys_Keys.INSTANCE;
  892. /**
  893. * @see this.NavigationConstants#com_ibm_rave_navigation_NavigationConstants.SELECTOR_ID
  894. */
  895. /** @expose */
  896. com_ibm_rave_navigation_Navigation.SELECTOR_ID = com_ibm_rave_navigation_NavigationConstants.SELECTOR_ID;
  897. // $source: com/ibm/rave/navigation/internal/nativeImpl/Module
  898. /************************************************************************
  899. ** IBM Confidential
  900. **
  901. ** IBM Business Analytics: Rapidly Adaptive Visualization Engine
  902. **
  903. ** (C) Copyright IBM Corp. 2014, 2015
  904. **
  905. ** The source code for this program is not published or otherwise divested of its trade secrets,
  906. ** irrespective of what has been deposited with the U.S. Copyright Office.
  907. ************************************************************************/
  908. // @OnDemandLoad("rave-navigation")
  909. // Must be the first import
  910. // @import ./ModuleHeader
  911. // Other module dependencies
  912. // @import com/ibm/rave/core/internal/nativeImpl/Module
  913. // @import com/ibm/rave/navigation/Navigation
  914. com_ibm_rave_navigation_Navigation.init();
  915. // expose navigation to the global variable rave
  916. rave["navigation"] = com_ibm_rave_navigation_Navigation;
  917. rave["navigation"]["internal"] = rave_externs;
  918. // This is the end of the factory method defined in the header. Added only during a full compiled JS build.
  919. return rave;
  920. }));})();