<commit_before>/**
 * @fileoverview This file is responsible for the expand/collapse behavior of
 * tabs on the staff notation area and the related toolbar buttons.
 */
/* global define: false */
define([
	'jquery', 
	'lodash', 
	'app/config',
	'app/view/modal'
], function(
	$, 
	_, 
	Config, 
	Modal
) {
	"use strict";

	/**
	 * Defines the title of the app info modal.
	 * @type {string}
	 * @const
	 */
	var APP_INFO_TITLE = Config.get('helpText.appInfo.title');
	/**
	 * Defines the content of the app info modal.
	 * @type {string}
	 * @const
	 */
	var APP_INFO_CONTENT = Config.get('helpText.appInfo.content');

	/**
	 * Defines a namespace for setting up tab behavior around the notation
	 * canvas.
	 *
	 * @namespace
	 */
	var notation_tabs = {
		/**
		 * Holds the tab elements.
		 * @type {array}
		 */
		tabs: [],
		/**
		 * Flag to indicate if tabs are all expanded or not.
		 * @type {boolean}
		 */
		tabsExpanded: false,
		/**
		 * Initializes the tab expand/collapse behavior and other buttons.
		 *
		 * @return undefined
		 */
		init: function() {
			_.bindAll(this, ['initTab', 'onClickToggleTabs']);

			$('.js-tab').each(this.initTab);
			$('.js-toggle-tabs')
				.on('mousedown', this.cancelEvent) // fixes issue with unwated text selections on click
				.on('click', this.onClickToggleTabs); // handles the expand/collapse behavior we want
			
			$('.js-btn-screenshot').on('mousedown', this.onClickScreenshot);
			$('.js-btn-info').on('click', this.onClickInfo);
		},
		/**
		 * Initializes each tab so it can expand/collapse.
		 *
		 * @param {number} index
		 * @param {object} el
		 * @return undefined
		 */
		initTab: function(index, el) {
			var $el = $(el);
			var tab = {
				'el': $el,
				'animEl': $el.parent(),
				'width': $el.next().width(),
				'expanded': false
			};

			if($el.hasClass('js-tab-left')) {
				tab.expand = this.makeExpander(tab, '-=', true);
				tab.collapse = this.makeExpander(tab, '+=', false);
			} else {
				tab.expand = this.makeExpander(tab, '+=', true);
				tab.collapse = this.makeExpander(tab, '-=', false);
			}

			$el.on('click', function(ev) {
				tab[tab.expanded?'collapse':'expand']();
				return false;
			});

			this.tabs.push(tab);
		},
		/**
		 * Expands or collapses *all* tabs.
		 *
		 * @param {object} evt
		 * @return {boolean} false
		 */
		onClickToggleTabs: function(evt) {
			var el = evt.target;
			var cls = ['icon-btn-open','icon-btn-close'];
			var tabsExpanded = this.tabsExpanded;

			if($(el).hasClass('icon-btn-close')) {
				cls.revterse();
			}

			$(el).removeClass(cls[0]).addClass(cls[1]);

			$.each(this.tabs, function(index, tab) {
				tab[tabsExpanded?'collapse':'expand']();
			});

			this.tabsExpanded = !tabsExpanded;

			return false;
		},
		/**
		 * Handler to generate a screenshot/image of the staff area.
		 *<commit_msg>fix typo in notation tabs<commit_after>/**
 * @fileoverview This file is responsible for the expand/collapse behavior of
 * tabs on the staff notation area and the related toolbar buttons.
 */
/* global define: false */
define([
	'jquery', 
	'lodash', 
	'app/config',
	'app/view/modal'
], function(
	$, 
	_, 
	Config, 
	Modal
) {
	"use strict";

	/**
	 * Defines the title of the app info modal.
	 * @type {string}
	 * @const
	 */
	var APP_INFO_TITLE = Config.get('helpText.appInfo.title');
	/**
	 * Defines the content of the app info modal.
	 * @type {string}
	 * @const
	 */
	var APP_INFO_CONTENT = Config.get('helpText.appInfo.content');

	/**
	 * Defines a namespace for setting up tab behavior around the notation
	 * canvas.
	 *
	 * @namespace
	 */
	var notation_tabs = {
		/**
		 * Holds the tab elements.
		 * @type {array}
		 */
		tabs: [],
		/**
		 * Flag to indicate if tabs are all expanded or not.
		 * @type {boolean}
		 */
		tabsExpanded: false,
		/**
		 * Initializes the tab expand/collapse behavior and other buttons.
		 *
		 * @return undefined
		 */
		init: function() {
			_.bindAll(this, ['initTab', 'onClickToggleTabs']);

			$('.js-tab').each(this.initTab);
			$('.js-toggle-tabs')
				.on('mousedown', this.cancelEvent) // fixes issue with unwated text selections on click
				.on('click', this.onClickToggleTabs); // handles the expand/collapse behavior we want
			
			$('.js-btn-screenshot').on('mousedown', this.onClickScreenshot);
			$('.js-btn-info').on('click', this.onClickInfo);
		},
		/**
		 * Initializes each tab so it can expand/collapse.
		 *
		 * @param {number} index
		 * @param {object} el
		 * @return undefined
		 */
		initTab: function(index, el) {
			var $el = $(el);
			var tab = {
				'el': $el,
				'animEl': $el.parent(),
				'width': $el.next().width(),
				'expanded': false
			};

			if($el.hasClass('js-tab-left')) {
				tab.expand = this.makeExpander(tab, '-=', true);
				tab.collapse = this.makeExpander(tab, '+=', false);
			} else {
				tab.expand = this.makeExpander(tab, '+=', true);
				tab.collapse = this.makeExpander(tab, '-=', false);
			}

			$el.on('click', function(ev) {
				tab[tab.expanded?'collapse':'expand']();
				return false;
			});

			this.tabs.push(tab);
		},
		/**
		 * Expands or collapses *all* tabs.
		 *
		 * @param {object} evt
		 * @return {boolean} false
		 */
		onClickToggleTabs: function(evt) {
			var el = evt.target;
			var cls = ['icon-btn-open','icon-btn-close'];
			var tabsExpanded = this.tabsExpanded;

			if($(el).hasClass('icon-btn-close')) {
				cls.reverse();
			}

			$(el).removeClass(cls[0]).addClass(cls[1]);

			$.each(this.tabs, function(index, tab) {
				tab[tabsExpanded?'collapse':'expand']();
			});

			this.tabsExpanded = !tabsExpanded;

			return false;
		},
		/**
		 * Handler to generate a screenshot/image of the staff area.
		 *
{'fraction_non_alphanumeric': 0.1747845964480394, 'fraction_numerical': 0.000703358537014243, 'mean_word_length': 2.941787941787942, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6098521', 'n_tokens_mistral': 2283, 'n_tokens_neox': 1891, 'n_words': 466}