aloha_src/static/js/plugins/common/link/lib/link-plugin.js
/**
	 * Selection change handler.
	 *
	 * @param {LinkPlugin} that This Link Plugin object
	 * @param {RangeObject} rangeObject Selection Range
	 * @returns {boolean} True if the link Scope was activated,
	 *                    False otherwise
	 */
Selection change handler.
@param {LinkPlugin} that This Link Plugin object
@param {RangeObject} rangeObject Selection Range
@returns {boolean} True if the link Scope was activated,
False otherwise
Selection change handler . @param { LinkPlugin } that This Link Plugin object @param { RangeObject } rangeObject Selection Range @returns { boolean } True if the link Scope was activated False otherwise
function selectionChangeHandler(that, rangeObject) {
		var foundMarkup,
		    enteredLinkScope = false;
		if (!that.ignoreNextSelectionChangedEvent &&
			Aloha.Selection.isSelectionEditable() &&
			Aloha.activeEditable != null ) {
			foundMarkup = that.findLinkMarkup(rangeObject);
			if (foundMarkup) {
				that.toggleLinkScope(true);
				that.hrefField.setTargetObject(foundMarkup, 'href');
				addAdditionalTargetObject(rangeObject, that.hrefField);
				if (jQuery('#' + that.hrefField.getInputId()).length == 0) {
					if (that.hrefUpdateInt !== null) {
						clearInterval(that.hrefUpdateInt);
					}
					that.hrefUpdateInt = setInterval( function () {
						if (jQuery( '#' + that.hrefField.getInputId()).length > 0) { 
							that.hrefField.setTargetObject(foundMarkup, 'href');
							clearInterval(that.hrefUpdateInt);
						}
					}, 200);
				}
				Aloha.trigger('aloha-link-selected');
				enteredLinkScope = true;
				PubSub.pub('aloha.link.selected', {
					input: that.hrefField.getInputElem(),
					href: that.hrefField.getValue(),
					element: that.hrefField.getTargetObject()
				});
			} else {
				that.toggleLinkScope(false);
				that.hrefField.setTargetObject(null);
				Aloha.trigger('aloha-link-unselected');
			}
		} else {
			that.toggleLinkScope(false);
		}
		that.ignoreNextSelectionChangedEvent = false;
		return enteredLinkScope;
	}
function selectionChangeHandler ( that , rangeObject ) { var foundMarkup , enteredLinkScope = false ; if ( ! that . ignoreNextSelectionChangedEvent && Aloha . Selection . isSelectionEditable ( ) && Aloha . activeEditable != null ) { foundMarkup = that . findLinkMarkup ( rangeObject ) ; if ( foundMarkup ) { that . toggleLinkScope ( true ) ; that . hrefField . setTargetObject ( foundMarkup , 'href' ) ; addAdditionalTargetObject ( rangeObject , that . hrefField ) ; if ( jQuery ( '#' + that . hrefField . getInputId ( ) ) . length == 0 ) { if ( that . hrefUpdateInt !== null ) { clearInterval ( that . hrefUpdateInt ) ; } that . hrefUpdateInt = setInterval ( function ( ) { if ( jQuery ( '#' + that . hrefField . getInputId ( ) ) . length > 0 ) { that . hrefField . setTargetObject ( foundMarkup , 'href' ) ; clearInterval ( that . hrefUpdateInt ) ; } } , 200 ) ; } Aloha . trigger ( 'aloha-link-selected' ) ; enteredLinkScope = true ; PubSub . pub ( 'aloha.link.selected' , { input : that . hrefField . getInputElem ( ) , href : that . hrefField . getValue ( ) , element : that . hrefField . getTargetObject ( ) } ) ; } else { that . toggleLinkScope ( false ) ; that . hrefField . setTargetObject ( null ) ; Aloha . trigger ( 'aloha-link-unselected' ) ; } } else { that . toggleLinkScope ( false ) ; } that . ignoreNextSelectionChangedEvent = false ; return enteredLinkScope ; }
Selection change handler.
Selection change handler .
// Check if we need to ignore this selection changed event for // now and check whether the selection was placed within a // editable area. // now we are ready to set the target object // if the selection-changed event was raised by the first click interaction on this page // the hrefField component might not be initialized. When the user switches to the link // tab to edit the link the field would be empty. We check for that situation and add a // special interval check to set the value once again // there must only be one update interval running at the same time // register a timeout that will set the value as soon as the href field was initialized // the object was finally created