Advertisement
Guest User

Untitled

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