lib/packages/core-classes.js
function(view, targets, callback, callback_arguments, global_targets_object) {

		var i = 0,
			count = targets.length,
			target,
			target_name,
			widget,
			template_arguments,
			bubble_index = 0,
			bubble_targets_copy,
			bubble_targets_count;

		this._nested_dispatch_count++;

		for (; i < count; i++) {

			target = targets[i];
			target_name = target.name;
			template_arguments = ('arguments' in target) ? this._evalTargetArguments(view, target) : null;
			widget = null;

			if ('locator_type' in target) {

				/*
				 Note: there is similar view location mechanism in view.Abstract, but the algorithms are different:
				 when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy.
				 Also, hardcoded labels differ.
				 */
				widget = this['_locateWidgetBy' + target.locator_type](view.getWidget(), target.locator);

				if (!widget) {

					Lava.logError('ViewManager: callback target (widget) not found. Type: ' + target.locator_type + ', locator: ' + target.locator);

				} else if (!widget.isWidget) {

					Lava.logError('ViewManager: callback target is not a widget');

				} else if (!callback(widget, target_name, view, template_arguments, callback_arguments)) {

					Lava.logError('ViewManager: targeted widget did not handle the role or event: ' + target_name);

				}

				// ignore possible call to cancelBubble()
				this._cancel_bubble = false;

			} else {

				// bubble
				widget = view.getWidget();

				do {

					callback(widget, target_name, view, template_arguments, callback_arguments);
					widget = widget.getParentWidget();

				} while (widget && !this._cancel_bubble);

				if (this._cancel_bubble) {
					this._cancel_bubble = false;
					continue;
				}

				if (target_name in global_targets_object) {

					// cause target can be removed inside event handler
					bubble_targets_copy = global_targets_object[target_name].slice();
					for (bubble_targets_count = bubble_targets_copy.length; bubble_index < bubble_targets_count; bubble_index++) {

						callback(
							bubble_targets_copy[bubble_index],
							target_name,
							view,
							template_arguments,
							callback_arguments
						);

						if (this._cancel_bubble) {
							this._cancel_bubble = false;
							break;
						}

					}

				}

			}

		}

		this._nested_dispatch_count--;

	}
function(view, targets, callback, callback_arguments, global_targets_object) {

		var i = 0,
			count = targets.length,
			target,
			target_name,
			widget,
			template_arguments,
			bubble_index = 0,
			bubble_targets_copy,
			bubble_targets_count;

		this._nested_dispatch_count++;

		for (; i < count; i++) {

			target = targets[i];
			target_name = target.name;
			template_arguments = ('arguments' in target) ? this._evalTargetArguments(view, target) : null;
			widget = null;

			if ('locator_type' in target) {

				/*
				 Note: there is similar view location mechanism in view.Abstract, but the algorithms are different:
				 when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy.
				 Also, hardcoded labels differ.
				 */
				widget = this['_locateWidgetBy' + target.locator_type](view.getWidget(), target.locator);

				if (!widget) {

					Lava.logError('ViewManager: callback target (widget) not found. Type: ' + target.locator_type + ', locator: ' + target.locator);

				} else if (!widget.isWidget) {

					Lava.logError('ViewManager: callback target is not a widget');

				} else if (!callback(widget, target_name, view, template_arguments, callback_arguments)) {

					Lava.logError('ViewManager: targeted widget did not handle the role or event: ' + target_name);

				}

				// ignore possible call to cancelBubble()
				this._cancel_bubble = false;

			} else {

				// bubble
				widget = view.getWidget();

				do {

					callback(widget, target_name, view, template_arguments, callback_arguments);
					widget = widget.getParentWidget();

				} while (widget && !this._cancel_bubble);

				if (this._cancel_bubble) {
					this._cancel_bubble = false;
					continue;
				}

				if (target_name in global_targets_object) {

					// cause target can be removed inside event handler
					bubble_targets_copy = global_targets_object[target_name].slice();
					for (bubble_targets_count = bubble_targets_copy.length; bubble_index < bubble_targets_count; bubble_index++) {

						callback(
							bubble_targets_copy[bubble_index],
							target_name,
							view,
							template_arguments,
							callback_arguments
						);

						if (this._cancel_bubble) {
							this._cancel_bubble = false;
							break;
						}

					}

				}

			}

		}

		this._nested_dispatch_count--;

	}
function ( view , targets , callback , callback_arguments , global_targets_object ) { var i = 0 , count = targets . length , target , target_name , widget , template_arguments , bubble_index = 0 , bubble_targets_copy , bubble_targets_count ; this . _nested_dispatch_count ++ ; for ( ; i < count ; i ++ ) { target = targets [ i ] ; target_name = target . name ; template_arguments = ( 'arguments' in target ) ? this . _evalTargetArguments ( view , target ) : null ; widget = null ; if ( 'locator_type' in target ) { /*
				 Note: there is similar view location mechanism in view.Abstract, but the algorithms are different:
				 when ViewManager seeks by label - it searches only for widgets, while view checks all views in hierarchy.
				 Also, hardcoded labels differ.
				 */ widget = this [ '_locateWidgetBy' + target . locator_type ] ( view . getWidget ( ) , target . locator ) ; if ( ! widget ) { Lava . logError ( 'ViewManager: callback target (widget) not found. Type: ' + target . locator_type + ', locator: ' + target . locator ) ; } else if ( ! widget . isWidget ) { Lava . logError ( 'ViewManager: callback target is not a widget' ) ; } else if ( ! callback ( widget , target_name , view , template_arguments , callback_arguments ) ) { Lava . logError ( 'ViewManager: targeted widget did not handle the role or event: ' + target_name ) ; } // ignore possible call to cancelBubble() this . _cancel_bubble = false ; } else { // bubble widget = view . getWidget ( ) ; do { callback ( widget , target_name , view , template_arguments , callback_arguments ) ; widget = widget . getParentWidget ( ) ; } while ( widget && ! this . _cancel_bubble ) ; if ( this . _cancel_bubble ) { this . _cancel_bubble = false ; continue ; } if ( target_name in global_targets_object ) { // cause target can be removed inside event handler bubble_targets_copy = global_targets_object [ target_name ] . slice ( ) ; for ( bubble_targets_count = bubble_targets_copy . length ; bubble_index < bubble_targets_count ; bubble_index ++ ) { callback ( bubble_targets_copy [ bubble_index ] , target_name , view , template_arguments , callback_arguments ) ; if ( this . _cancel_bubble ) { this . _cancel_bubble = false ; break ; } } } } } this . _nested_dispatch_count -- ; }
Dispatch events and roles to their targets.
Warning! Violates codestyle with multiple return statements

@param {Lava.view.Abstract} view The source of events or roles
@param {Array.<_cTarget>} targets The target routes
@param {function} callback The ViewManager callback that will perform dispatching
@param {*} callback_arguments Will be passed to `callback`
@param {Object.<string, Array>} global_targets_object Either {@link Lava.system.ViewManager#_global_role_targets}
or {@link Lava.system.ViewManager#_global_event_targets}
Dispatch events and roles to their targets . Warning! Violates codestyle with multiple return statements