<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// VERSION 1.0.2

this.__defineGetter__('tabGroups', function() { return window.tabGroups; });

this.tg = {
	id: '<EMAIL>',

	initialized: false,

	onEnabled: function(addon) {
		if(addon.id == this.id) { this.enable(); }
	},

	onDisabled: function(addon) {
		if(addon.id == this.id) { this.disable(); }
	},

	listen: function() {
		AddonManager.addAddonListener(this);
		AddonManager.getAddonByID(this.id, (addon) => {
			if(addon && addon.isActive) { this.enable(); }
		});
	},

	unlisten: function() {
		AddonManager.removeAddonListener(this);
		this.disable();
	},

	handleEvent: function(e) {
		switch(e.type) {
			case 'TabBarUpdated':
			case 'tabviewhidden':
				let placement = CustomizableUI.getPlacementOfWidget(tabGroups.TabView.kButtonId);
				if(placement) {
					let bar = bars.get(placement.area);
					if(bar) {
						bar._puzzleBar.move();
					}
				}
				break;
		}
	},

	enable: function() {
		if(this.initialized) { return; }
		this.initialized = true;

		// Preventing "blinking" TG's quick access panel.
		Piggyback.add('tabGroups', tabGroups.quickAccess, 'toggle', function() {
			// check to see if it's placed in our toolbars
			let placement = CustomizableUI.getPlacementOfWidget(tabGroups.TabView.kButtonId);
			if(!placement || possibleBars.indexOf(placement.area) == -1) {
				return true;
			}

			// Is bar initialized?
			let bar = bars.get(placement.area);
			if(!bar || !bar._autohide) {
				return true;
			}

			// Bar is already showing, just make sure it doesn't hide for a bit.
			if(autoHide.isBarShowing(bar)) {
				autoHide.initialShow(bar);
				return true;
			}

			// re-command the panel to open when the bar finishes showing
			let listener = () => {
				bar._transition.remove(listener);

				// unfortunately this won't happen inside popupsFinishedVisible in this case
				if(bar.hovers === 1 && $$('#'+bar.id+':hover')[0]) {
					autoHide.setHover(bar, true);
				}

				// get the anchor reference again, in case the previous node was lost
				this._toggle();
			};
			bar._transition.add(listener);

			// show the toolbar
			autoHide.initialShow(bar);

			return false;
		}, Piggyback.MODE_BEFORE);

		Listeners.add(gBrowser.tabContainer, 'TabBarUpdated', this);
		Listeners.add(window, 'tabviewhidden', this);
	},

	disable: function() {
		if(!this.initialized) { return; }
		this.initialized = false;

		Piggyback.revert('tabGroups', tabGroups.quickAccess, 'toggle');

		Listeners.remove(gBrowser.tabContainer, 'TabBarUpdated', this);
		Listeners.remove(window, 'tabviewhidden', this);
	}
};

Modules.LOADMODULE = function() {
	tg.listen();
};
<commit_msg>#98 better compat with active group label in button<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// VERSION 1.0.3

this.__defineGetter__('tabGroups', function() { return window.tabGroups; });

this.tg = {
	id: '<EMAIL>',

	initialized: false,

	onEnabled: function(addon) {
		if(addon.id == this.id) { this.enable(); }
	},

	onDisabled: function(addon) {
		if(addon.id == this.id) { this.disable(); }
	},

	listen: function() {
		AddonManager.addAddonListener(this);
		AddonManager.getAddonByID(this.id, (addon) => {
			if(addon && addon.isActive) { this.enable(); }
		});
	},

	unlisten: function() {
		AddonManager.removeAddonListener(this);
		this.disable();
	},

	handleEvent: function(e) {
		switch(e.type) {
			case 'ActiveGroupNameChanged':
				let placement = CustomizableUI.getPlacementOfWidget(tabGroups.TabView.kButtonId);
				if(placement) {
					let bar = bars.get(placement.area);
					if(bar) {
						bar._puzzleBar.move();
					}
				}
				break;
		}
	},

	enable: function() {
		if(this.initialized) { return; }
		this.initialized = true;

		Listeners.add(window, 'ActiveGroupNameChanged', this);

		// Preventing "blinking" TG's quick access panel.
		Piggyback.add('tabGroups', tabGroups.quickAccess, 'toggle', function() {
			// check to see if it's placed in our toolbars
			let placement = CustomizableUI.getPlacementOfWidget(tabGroups.TabView.kButtonId);
			if(!placement || possibleBars.indexOf(placement.area) == -1) {
				return true;
			}

			// Is bar initialized?
			let bar = bars.get(placement.area);
			if(!bar || !bar._autohide) {
				return true;
			}

			// Bar is already showing, just make sure it doesn't hide for a bit.
			if(autoHide.isBarShowing(bar)) {
				autoHide.initialShow(bar);
				return true;
			}

			// re-command the panel to open when the bar finishes showing
			let listener = () => {
				bar._transition.remove(listener);

				// unfortunately this won't happen inside popupsFinishedVisible in this case
				if(bar.hovers === 1 && $$('#'+bar.id+':hover')[0]) {
					autoHide.setHover(bar, true);
				}

				// get the anchor reference again, in case the previous node was lost
				this._toggle();
			};
			bar._transition.add(listener);

			// show the toolbar
			autoHide.initialShow(bar);

			return false;
		}, Piggyback.MODE_BEFORE);
	},

	disable: function() {
		if(!this.initialized) { return; }
		this.initialized = false;

		Listeners.remove(window, 'ActiveGroupNameChanged', this);

		Piggyback.revert('tabGroups', tabGroups.quickAccess, 'toggle');
	}
};

Modules.LOADMODULE = function() {
	tg.listen();
};

{'fraction_non_alphanumeric': 0.14662125829001613, 'fraction_numerical': 0.00394335902491486, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3623829', 'n_tokens_mistral': 2133, 'n_tokens_neox': 1837, 'n_words': 434}