text: /*global jQuery*/
  jQuery.fn.mapToolbarWidget = function (mapModel) {
  	'use strict';
  	var clickMethodNames = ['insertIntermediate', 'scaleUp', 'scaleDown', 'addSubIdea', 'editNode', 'removeSubIdea', 'toggleCollapse', 'addSiblingIdea', 'undo', 'redo',
  			'copy', 'cut', 'paste', 'resetView', 'openAttachment', 'toggleAddLinkMode', 'activateChildren', 'activateNodeAndChildren', 'activateSiblingNodes'],
  		changeMethodNames = ['updateStyle'];
  	return this.each(function () {
  		var element = jQuery(this);
  		mapModel.addEventListener('nodeSelectionChanged', function () {
  			element.find('.updateStyle[data-mm-target-property]').val(function () {
  				return mapModel.getSelectedStyle(jQuery(this).data('mm-target-property'));
  			}).change();
  		});
  		mapModel.addEventListener('addLinkModeToggled', function () {
  			element.find('.toggleAddLinkMode').toggleClass('active');
  		});
  		clickMethodNames.forEach(function (methodName) {
  			element.find('.' + methodName).click(function () {
  				if (mapModel[methodName]) {
  					mapModel[methodName]('toolbar');
  				}
  			});
  		});
  		changeMethodNames.forEach(function (methodName) {
  			element.find('.' + methodName).change(function () {
  				var tool = jQuery(this);
  				if (tool.data('mm-target-property')) {
  					mapModel[methodName]('toolbar', tool.data('mm-target-property'), tool.val());
  				}
  			});
  		});
  	});
  };
  