Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. // VERSION 1
  2. box.getEventSource = function (target) {
  3. var source = target;
  4.  
  5. while (source.id === '' || utils.endsWith(source.id, '-txt')) {
  6. source = source.parentNode;
  7. }
  8.  
  9. return source;
  10. };
  11. // VERSION 1
  12.  
  13. box.onActivate = function (event) {
  14. if (!this.getEnabled() || !this.getEditable()) {
  15. return;
  16. }
  17.  
  18. // VERSION 1
  19. var source = this.getEventSource(event.target);
  20. // VERSION 1
  21.  
  22. var attr = jQuery(source).attr('data-index');
  23. if (typeof attr == 'string' && attr.length > 0) {
  24. var index = parseInt(attr, 10); // Get the selected index from the HTML
  25.  
  26. var items = this.getItems();
  27. var item = items[index]; // item could be a separator, though!
  28.  
  29. // It could be the case that the list of items changed during the click event handling.
  30. // Ensure the item is still the one in
  31. if (items.length <= index) {
  32. index = items.length - 1;
  33. }
  34.  
  35. if (index >= 0 && index < items.length) {
  36. if (item.getEnabled() && !(item instanceof Separator)) {
  37. // Take care of selection and select event
  38. if (event.ctrlKey || event.metaKey) {
  39. this._handleUserActivationCtrl(index, item);
  40. } else {
  41. if (event.shiftKey) {
  42. this.setSelectedIndices(this._getUserSelectionRange(index));
  43. this.fireSelect({
  44. id:this.getId(),
  45. selectedIndex:index,
  46. selectedIndices:this.getSelectedIndices(),
  47. selectedItem:item,
  48. sId:this.getId()
  49. });
  50. this._lastDirectlySelectedIndex = index;
  51. } else {
  52. this._handleUserActivationPlain(index, item);
  53. }
  54. }
  55. }
  56. }
  57. event.preventDefault();
  58. event.stopPropagation();
  59. }
  60. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement