      1 (function ($, rf) {
      2
      3     rf.ui = rf.ui || {};
      4
      5     rf.ui.ComponentControl = rf.ui.ComponentControl || {};
      6
      7     $.extend(rf.ui.ComponentControl, {
      8
      9             execute: function(event, parameters) {
     10                 var targetList = parameters.target;
     11                 var selector = parameters.selector;
     12                 var callback = parameters.callback;
     13
     14                 if (parameters.onbeforeoperation && typeof parameters.onbeforeoperation == "function") {
     15                     var result = parameters.onbeforeoperation(event);
     16                     if (result == "false" || result == 0) return;
     17                 }
     18
     19                 if (targetList) {
     20                     for (var i = 0; i < targetList.length; i++) {
     21                         var component = document.getElementById(targetList[i]);
     22                         if (component) {
     23                             rf.ui.ComponentControl.invokeOnComponent(event, component, callback);
     24                         }
     25                     }
     26                 }
     27
     28                 if (selector) {
     29                     rf.ui.ComponentControl.invokeOnComponent(event, selector, callback);
     30                 }
     31             },
     32
     33             invokeOnComponent : function(event, target, callback) {
     34                 if (callback && typeof callback == 'function') {
     35                     $(target).each(function() {
     36                         var component = rf.component(this);
     37                         if (component) {
     38                             callback(event, component);
     39                         }
     40                     });
     41                 }
     42             }
     43         });
     44
     45 })(RichFaces.jQuery, window.RichFaces);