GitHub PullRequestReviewCommentEvent at 2014-05-23 20:54:07
Repository: brackets
Actor: njx
Payload: {"comment":{"url":"https://api.github.com/repos/adobe/brackets/pulls/comments/13018536","id":13018536,"diff_hunk":"@@ -112,13 +112,58 @@ define(function (require, exports, module) {\n     DropdownButton.prototype._renderList = function () {\n         var html = \"\";\n         this.items.forEach(function (item, i) {\n-            html += \"<li><a class='stylesheet-link' data-index='\" + i + \"'>\";\n-            html += this.itemRenderer(item, i);\n-            html += \"</a></li>\";\n+            if (item === \"---\") {\n+                html += \"<li class='divider'></li>\";\n+            } else {\n+                html += \"<li><a class='stylesheet-link' data-index='\" + i + \"'>\";\n+                html += this.itemRenderer(item, i);\n+                html += \"</a></li>\";\n+            }\n         }.bind(this));\n         return html;\n     };\n     \n+    /**\n+     * Refresh the dropdown list by removing and re-creating all list items.\n+     * Call this after deleting/adding any item in the dropdown list.\n+     */\n+    DropdownButton.prototype.refresh = function () {\n+        if (!this.$dropdown) {\n+            return;\n+        }\n+        \n+        // Remove all list items and then re-create them from this.items.\n+        $(\"li\", this.$dropdown).remove();\n+        this.$dropdown.append(this._renderList());\n+        \n+        // Also trigger openDropdown handler so that custom event handlers can be\n+        // set up for any custom UI in the list.\n+        $(this).triggerHandler(\"openDropdown\", [this.$dropdown]);","path":"src/widgets/DropdownButton.js","position":33,"original_position":33,"commit_id":"5665631d722e2eeeeed79fca20a31769f1e281ff","original_commit_id":"5665631d722e2eeeeed79fca20a31769f1e281ff","user":{"login":"njx","id":697759,"avatar_url":"https://avatars.githubusercontent.com/u/697759?","gravatar_id":"6b448f9ed49b9b87ae5f86a97e4c0212","url":"https://api.github.com/users/njx","html_url":"https://github.com/njx","followers_url":"https://api.github.com/users/njx/followers","following_url":"https://api.github.com/users/njx/following{/other_user}","gists_url":"https://api.github.com/users/njx/gists{/gist_id}","starred_url":"https://api.github.com/users/njx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njx/subscriptions","organizations_url":"https://api.github.com/users/njx/orgs","repos_url":"https://api.github.com/users/njx/repos","events_url":"https://api.github.com/users/njx/events{/privacy}","received_events_url":"https://api.github.com/users/njx/received_events","type":"User","site_admin":false},"body":"It's a little funny to re-trigger `openDropdown` here since it gets called on every re-render. Perhaps we should change the name of this event to `render` and trigger it from `_renderList()`.","created_at":"2014-05-23T20:54:07Z","updated_at":"2014-05-23T20:54:07Z","html_url":"https://github.com/adobe/brackets/pull/7836#discussion_r13018536","pull_request_url":"https://api.github.com/repos/adobe/brackets/pulls/7836","_links":{"self":{"href":"https://api.github.com/repos/adobe/brackets/pulls/comments/13018536"},"html":{"href":"https://github.com/adobe/brackets/pull/7836#discussion_r13018536"},"pull_request":{"href":"https://api.github.com/repos/adobe/brackets/pulls/7836"}}}}