Setting Tabs close function
        None -> tabs are not closable
761559
def set_close_function(self, func):
        """"""
        state = func is not None
        if state:
            self.sig_close_tab.connect(func)
        try:
            # Assuming Qt >= 4.5
            QTabWidget.setTabsClosable(self, state)
            self.tabCloseRequested.connect(func)
        except AttributeError:
            # Workaround for Qt < 4.5
            close_button = create_toolbutton(self, triggered=func,
                                             icon=ima.icon('fileclose'),
                                             tip=_("Close current tab"))
            self.setCornerWidget(close_button if state else None)
477695
function( event, eventData ) {
		var that = this,
			toShow = eventData.newPanel,
			toHide = eventData.oldPanel;

		this.running = true;

		function complete() {
			that.running = false;
			that._trigger( "activate", event, eventData );
		}

		function show() {
			eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );

			if ( toShow.length && that.options.show ) {
				that._show( toShow, that.options.show, complete );
			} else {
				toShow.show();
				complete();
			}
		}

		// start out by hiding, then showing, then completing
		if ( toHide.length && this.options.hide ) {
			this._hide( toHide, this.options.hide, function() {
				eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
				show();
			});
		} else {
			eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
			toHide.hide();
			show();
		}

		toHide.attr({
			"aria-expanded": "false",
			"aria-hidden": "true"
		});
		eventData.oldTab.attr( "aria-selected", "false" );
		// If we're switching tabs, remove the old tab from the tab order.
		// If we're opening from collapsed state, remove the previous tab from the tab order.
		// If we're collapsing, then keep the collapsing tab in the tab order.
		if ( toShow.length && toHide.length ) {
			eventData.oldTab.attr( "tabIndex", -1 );
		} else if ( toShow.length ) {
			this.tabs.filter(function() {
				return $( this ).attr( "tabIndex" ) === 0;
			})
			.attr( "tabIndex", -1 );
		}

		toShow.attr({
			"aria-expanded": "true",
			"aria-hidden": "false"
		});
		eventData.newTab.attr({
			"aria-selected": "true",
			tabIndex: 0
		});
	}
468916
def close_left(self):
        
        current_widget = self.widget(self.tab_under_menu())
        index = self.indexOf(current_widget)
        if self._try_close_dirty_tabs(tab_range=range(index)):
            while True:
                widget = self.widget(0)
                if widget != current_widget:
                    self.remove_tab(0)
                else:
                    break
1196011
function resetOptionsForActiveTab() {
  var url = getCanonicalUrl(tabs.activeTab.url);
  setPagePreference(url, 'options', '');
  if (isInjectionEnabledForUrl(url)) {
    disableInjectionForUrl(url, true);
    enableInjectionForUrl(url);
  }
}
94936
function tabView_closeTab(aSpec) { 
    var spec = aSpec || {};
    var tab = spec.tab;

    if (!tab) {
      throw new Error(arguments.callee.name + ": Tab not specified.");
    }

    var button = this.getElement({
      type: "tab_closeButton",
      value: tab}
    );
    this._controller.click(button);
  }
832882
function selectTab() {
        layout.resetTabState_(tabs);
        tab.classList.add(layout.CssClasses_.IS_ACTIVE);
    }
764561
function setTabId (sections) {

    sections.forEach(function (section, sectionIndex) {

        if (!Array.isArray(section)) {
            return;
        }

        section.forEach(function (tab, tabIndex) {

            // Replace white space from tab.label with "-", make it lowercase and add the index number at the end.
            // sectionIndex and tabIndex number are added at the end to make the tabID unique in case when more then one tab have the same label (title)
            tab.tabId = (tab.label).replace(/\s+/g, '-').toLowerCase() + '-' + sectionIndex + '-' + tabIndex;

        });

    });

}
356082
function(element, options) {
        var sections, tabs, self = this;

        element = this.setElement(element);
        options = this.setOptions(options, element);

        // Determine cookie name
        if (!options.cookie) {
            options.cookie = element.attr('id');
        }

        // Find all the sections and set ARIA attributes
        this.sections = sections = element.find(this.ns('section')).each(function(index, section) {
            section = $(section);
            section
                .attr('role', 'tabpanel')
                .attr('id', section.attr('id') || self.id('section', index))
                .aria('labelledby', self.id('tab', index))
                .conceal();
        });

        // Find the nav and set ARIA attributes
        this.nav = element.find(this.ns('nav'))
            .attr('role', 'tablist');

        // Find the tabs within the nav and set ARIA attributes
        this.tabs = tabs = this.nav.find('a').each(function(index) {
            $(this)
                .data('tab-index', index)
                .attr({
                    role: 'tab',
                    id: self.id('tab', index)
                })
                .aria({
                    controls: sections.eq(index).attr('id'),
                    selected: false,
                    expanded: false
                })
                .removeClass('is-active');
        });

        // Initialize events
        this.addEvent('{mode}', 'element', 'onShow', this.ns('nav') + ' a');

        if (options.mode !== 'click' && options.preventDefault) {
            this.addEvent('click', 'element', function(e) {
                e.preventDefault();
            }, this.ns('nav') + ' a');
        }

        this.initialize();

        // Trigger default tab to display
        var index = null;

        if (options.persistState) {
            if (options.cookie && $.cookie) {
                index = $.cookie('toolkit.tab.' + options.cookie);
            }

            if (index === null && options.loadFragment && location.hash) {
                index = tabs.filter(function() {
                    return ($(this).attr('href') === location.hash);
                }).eq(0).data('tab-index');
            }
        }

        if (!tabs[index]) {
            index = options.defaultIndex;
        }

        this.jump(index);
    }
1253869
function destroy() {
        this._removeEventHandlers();

        // iob
        if (this._indicator) this._indicator.parentNode.removeChild(this._indicator);

        if (this.options.swipeable) {
          this._teardownSwipeableTabs();
        } else {
          this._teardownNormalTabs();
        }

        this.$el[0].M_Tabs = undefined;
      }
985838
function tabbing(script) {
	var prev, data;
	script = script[0];
	if ((prev = script.prev) && (data = prev.data)) {
		return data.replace(/\n/g, '');
	}
	return '';
}
805233
function( tabConfig ) {
			if ( !tabConfig )
				tabConfig = defaultTabConfig;

			var allowedAttrs = [];
			if ( tabConfig.id )
				allowedAttrs.push( 'id' );
			if ( tabConfig.dir )
				allowedAttrs.push( 'dir' );

			var allowed = '';

			if ( allowedAttrs.length )
				allowed += '[' + allowedAttrs.join( ',' ) +  ']';

			if ( tabConfig.classes )
				allowed += '(*)';
			if ( tabConfig.styles )
				allowed += '{*}';

			return allowed;
		}
1119813
def remove_tab(self, index):
        
        widget = self.widget(index)
        try:
            document = widget.document()
        except AttributeError:
            document = None  # not a QPlainTextEdit
        clones = self._close_widget(widget)
        self.tab_closed.emit(widget)
        self.removeTab(index)
        self._restore_original(clones)
        widget._original_tab_widget._tabs.remove(widget)
        if self.count() == 0:
            self.last_tab_closed.emit()
        if SplittableTabWidget.tab_under_menu == widget:
            SplittableTabWidget.tab_under_menu = None
        if not clones:
            widget.setParent(None)
        else:
            try:
                clones[0].syntax_highlighter.setDocument(document)
            except AttributeError:
                pass
993465
function(node) {
            var $activeTab = $(node);
            var data = $($activeTab).data('cfw.tab');
            if (data) {
                var $activePane = data.$target;
                var $paneContainer = $activePane.closest('.tab-content');
                $paneContainer.find('[data-cfw="collapse"]').each(function() {
                    $(this).one('afterHide.cfw.collapse', function(e) {
                            e.stopPropagation();
                            e.preventDefault();
                        })
                        .CFW_Collapse('hide');
                });

                var $collapseItem = $activePane.find('[data-cfw="collapse"]');
                $collapseItem.one('afterShow.cfw.collapse', function(e) {
                        e.stopPropagation();
                        e.preventDefault();
                    })
                    .CFW_Collapse('show');
            }
        }
1051876
def tab_complete(self):
        
        opts = self._complete_options()
        if len(opts) == 1:
            self.set_current_text(opts[0] + os.sep)
            self.hide_completer()
713647
function focusTab(tabId) {
    var updateProperties = { "active": true };
    chrome.tabs.update(tabId, updateProperties, function (tab) { });
  }
1020664
def keep_only_sticked_and_selected_tabs(self):
        """"""
        # Only if the user didn't deactivate this behaviour
        if not global_gui_config.get_config_value('KEEP_ONLY_STICKY_STATES_OPEN', True):
            return

        page_id = self.view.notebook.get_current_page()
        # No tabs are open
        if page_id == -1:
            return

        page = self.view.notebook.get_nth_page(page_id)
        current_state_identifier = self.get_state_identifier_for_page(page)

        states_to_be_closed = []
        # Iterate over all tabs
        for state_identifier, tab_info in list(self.tabs.items()):
            # If the tab is currently open, keep it open
            if current_state_identifier == state_identifier:
                continue
            # If the tab is sticky, keep it open
            if tab_info['is_sticky']:
                continue
            # Otherwise close it
            states_to_be_closed.append(state_identifier)

        for state_identifier in states_to_be_closed:
            self.close_page(state_identifier, delete=False)
589152
function () {
            topic.subscribe("/focus", lang.hitch(this, "onPageFocus"));
            topic.subscribe("/new", lang.hitch(this, "onNew"));
            topic.subscribe("/deleted", lang.hitch(this, "onDeleted"));

            aspect.before(this.tabContainer, "closeChild", function (child) {
                this.closing = true;
                // TODO around is better but somehow does not work
                setTimeout(function () {
                    //this.closing = false;
                }.bind(this), 0);
            }.bind(this));
            aspect.after(this.tabContainer, "closeChild", function (value, args) {
                this.closing = false;
                this.onClose(args[0]);
            }.bind(this));
            aspect.after(this.tabContainer, "selectChild", function (promise, args) {
                if (!this.closing) {
                    this.tabSelected(args[0]);
                }
            }.bind(this));


            var menu = registry.byId(this.tabContainer.id + "_tablist_Menu");

            var me = this;
            menu.addChild(
                new MenuItem({
                    label: messages["tabopener.closeall"],
                    ownerDocument: this.tabContainer.ownerDocument,
                    dir: this.tabContainer.dir,
                    lang: this.tabContainer.lang,
                    textDir: this.tabContainer.textDir,
                    onClick: function (evt) {
                        me.closeTabs();
                    }
                })
            );
            menu.addChild(
                new MenuItem({
                    label: messages["tabopener.closeothers"],
                    ownerDocument: this.tabContainer.ownerDocument,
                    dir: this.tabContainer.dir,
                    lang: this.tabContainer.lang,
                    textDir: this.tabContainer.textDir,
                    onClick: function (evt) {
                        var tabElement = this.getParent().currentTarget;
                        var tab = registry.byNode(tabElement);
                        me.closeTabs(tab.page);
                    }
                })
            );
        }