Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- box.onActivate = function (event) {
- if (!this.getEnabled() || !this.getEditable()) {
- return;
- }
- var source = event.target;
- if (source.id === '' || utils.endsWith(source.id, '-txt')) {
- source = source.parentNode;
- if (source.id === '') { // could be the image inside the first cell
- source = source.parentNode;
- }
- }
- var attr = jQuery(source).attr('data-index');
- if (typeof attr == 'string' && attr.length > 0) {
- var index = parseInt(attr, 10); // Get the selected index from the HTML
- var items = this.getItems();
- var item = items[index]; // item could be a separator, though!
- // It could be the case that the list of items changed during the click event handling.
- // Ensure the item is still the one in
- if (items.length <= index) {
- index = items.length - 1;
- }
- if (index >= 0 && index < items.length) {
- if (item.getEnabled() && !(item instanceof Separator)) {
- // Take care of selection and select event
- if (event.ctrlKey || event.metaKey) {
- this._handleUserActivationCtrl(index, item);
- } else {
- if (event.shiftKey) {
- this.setSelectedIndices(this._getUserSelectionRange(index));
- this.fireSelect({
- id:this.getId(),
- selectedIndex:index,
- selectedIndices:this.getSelectedIndices(),
- selectedItem:item,
- sId:this.getId()
- });
- this._lastDirectlySelectedIndex = index;
- } else {
- this._handleUserActivationPlain(index, item);
- }
- }
- }
- }
- event.preventDefault();
- event.stopPropagation();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement