All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.focuspoints.bloomreach.plugins.focuspoint-plugin.js Maven / Gradle / Ivy

There is a newer version: 2.0.1
Show newest version
(function ($) {
	var initFocuspointButton = function (clicked) {

		$('.focuspoint-button').each(function () {

			$(this).removeAttr('onclick');

			$(this).on('click', function () {
				// console.log('click');
				var $this = $(this);
				var $currentItem = $this.parents('.hippo-editor');
				var $focuspointContainer = $('.focuspoint-container', $currentItem);

				$focuspointContainer.toggle();
				if (!$focuspointContainer.hasClass('initialized')) {
					focuspointHelper.initialize($focuspointContainer);
				}

			});

			if (clicked) {
				$(this).click();
			}

		});

	};

	var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;

	$.fn.mutated = function (callback) {
		if (MutationObserver) {
			var options = {
				childList: true
			};

			var observer = new MutationObserver(function (mutations) {
				mutations.forEach(function (e) {

					if (e.addedNodes.length > 0) {
						callback.call(e.target, e.attributeName);
					}
				});
			});

			return this.each(function () {
				observer.observe(this, options);
			});

		}
	};

	var listen = function (name) {
		$(name + ' *').mutated(function (attrName) {

			var find = 'browse-perspective-center';

			if ($(this).hasClass(find)) {

				listen('.' + find);
			}

			if ($(this).parents('.' + find).length > 0) {
				initFocuspointButton();
			}


		});
	};

	$(document).ready(function () {
		$(document).on('focus-button-clicked', function () {
			initFocuspointButton(true);
		});
		//listen('body');
		initFocuspointButton(false);
	});

})(jQuery);




© 2015 - 2025 Weber Informatics LLC | Privacy Policy