rave-navigation.js 36 KB

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