Review Board 1.7.22


Selection Service doesn't work correctly in IE8

Review Request #2576 - Created Oct. 26, 2011 and submitted

Jason Chiang
SHINDIG-1652
Reviewers
shindig
ddumont, rbaxter
shindig
IE8 doesn't support both "forEach" and "indexOf" Javascript methods, replace these methods with for loop.
Test it with the sample container in IE8
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/selection/selection.js
Revision 1189339 New Change
[20] 59 lines
[+20] [+] addListener: function(listener) {
60
        listeners.push(listener);
60
        listeners.push(listener);
61
        // lazily create and add the callback
61
        // lazily create and add the callback
62
        if (selectionChangedFunc == null) {
62
        if (selectionChangedFunc == null) {
63
          selectionChangedFunc = function(selection) {
63
          selectionChangedFunc = function(selection) {
64
            currentSelection = selection;
64
            currentSelection = selection;
65
            listeners.forEach(function(listener) {
65
            for (var i=0; i<listeners.length; i++) {
66
              listener(selection);
66
              listeners[i](selection);
67
            });
67
            }
68
          };
68
          };
69
          gadgets.rpc.call('..', 'gadgets.selection', null, 'add',
69
          gadgets.rpc.call('..', 'gadgets.selection', null, 'add',
70
              selectionChangedFunc);
70
              selectionChangedFunc);
71
        }
71
        }
72
      }
72
      }
73
    },
73
    },
74

    
   
74

   
75
    /**
75
    /**
76
     * Removes a listener for selection.
76
     * Removes a listener for selection.
77
     * @param {function} listener The listener to remove.
77
     * @param {function} listener The listener to remove.
78
     */
78
     */
79
    removeListener: function(listener) {
79
    removeListener: function(listener) {
80
      var index = listeners.indexOf(listener);
80
      for (var i = 0; i<listeners.length; i++) {
81
      if (index != -1) {
81
        if (listeners[i] === listener) {
82
        listeners.splice(index, 1);
82
          listeners.splice(i, 1);

    
   
83
          break;

    
   
84
        }
83
      }
85
      }
84
    }
86
    }
85
  };
87
  };
86
}();
88
}();
http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/selection/selection_container.js
Revision 1189339 New Change
 
  1. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/selection/selection.js: Loading...
  2. http://svn.apache.org/repos/asf/shindig/trunk/features/src/main/javascript/features/selection/selection_container.js: Loading...