Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

[extract 1.6]Toggle panels and panel active icons in extension toolbar #11924

Open
abose opened this issue Nov 17, 2015 · 1 comment
Open

[extract 1.6]Toggle panels and panel active icons in extension toolbar #11924

abose opened this issue Nov 17, 2015 · 1 comment

Comments

@abose
Copy link
Contributor

abose commented Nov 17, 2015

There's a small issue with toggle panels though (other than the shortcut not showing up/working)

  1. Open foo.js
  2. Create a validation error (I am using brackets-eslint)
  3. Click Toggle Panels -> nothing happens (expected: panel closes)
  4. Click Toggle Panels -> panel closes.

That issue that affects brackets-git affects other Extensions too, such as brackets-todo. Is there a way to (at least temporarily / during 1.6.) to throw a warning if panel was closed but the button state remained + link to say Brackets-Wiki where those events would be explained). That would provide a easy way for extension makers that use panels to know that they should update their extensions).

@petetnt
Copy link
Collaborator

petetnt commented Nov 17, 2015

A simple/naive way to catch it is to check if the buttons have changed after toggling the panels. Something along the lines of

    //locals
    var _previouslyOpenPanelIDs = [],
        panelsToggled = false,
        layoutUpdated = false,
        panelToggleUpgradeNeededCheck = true; // This local can be removed in 1.7

    // A bit later

    /**
     * hide all open panels. Remove the check in 1.7.
     */
    function _hidePanelsIfRequired() {
        var panelIDs = WorkspaceManager.getAllPanelIDs(),
            i = 0,
            panelButtonsBefore,
            panelButtonsAfter;

        if (panelToggleUpgradeNeededCheck) {
            panelButtonsBefore = $("#main-toolbar").find(".buttons > a");
        }

        _previouslyOpenPanelIDs = [];
        for (i = 0; i < panelIDs.length; i++) {
            if (WorkspaceManager.getPanelForID(panelIDs[i]).isVisible()) {
                WorkspaceManager.getPanelForID(panelIDs[i]).hide();
                _previouslyOpenPanelIDs.push(panelIDs[i]);
            }
        }

        if (panelToggleUpgradeNeededCheck) {
            panelButtonsAfter = $("#main-toolbar").find(".buttons > a");

            panelButtonsBefore.each(function (i, elem) {
                var $this = $(this),
                    classList = $this.attr("class");

                if (classList && classList === panelButtonsAfter.eq(i).attr("class")) {
                    console.warn("Extension panel upgrade warning here + link to wiki. Extension icon is " +
                                 ($this.attr("title") || $this.attr("id") || $this.html()));
                }
            });

            panelToggleUpgradeNeededCheck = false;
        }
    }

Another way would be checking if the icon has actually changed by checking the background image for example, but the approach would be the same.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants
@zaggino @abose @petetnt @ficristo @swmitra and others