{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/fireplace/pulls/comments/27602502","id":27602502,"diff_hunk":"@@ -0,0 +1,218 @@\n+/*\n+    Marketplace Selector element. Extends the <select> element, externally\n+    acts like a <select> element, while being much more stylizable.\n+\n+    - Markup expects a <mkt-selected>, and <option>s within an <optgroup>. The\n+      <mkt-selected> element displays the current selection where\n+      <mkt-selected-text> displays the exact option label.\n+    - <mkt-select> proxies the HTMLSelectElement interface to a stored select\n+      element. <mkt-optgroup> and <mkt-option> respectively do the same.\n+    - Whenever a <mkt-option> is clicked, the <mkt-select>'s internal select\n+      element value is changed. Then we trigger a 'changed' event on the\n+      <select> which propagates to the <mkt-select>. Because we proxy to the\n+      internal <select>, interfaces like HTMLSelectElement.selectedIndex and\n+      HTMLSelectElement.value will automatically work.\n+    - <mkt-select> visibility is toggled on click (.mkt-select--visible).\n+    - <mkt-option> elements have their padding-left programmatically set to\n+      all align with the <mkt-selected-text>.\n+    - <mkt-option> elements keep their data-mkt-option--index up-to-date so\n+      that colors can be set appropriate on each while ignoring the selected\n+      option.\n+*/\n+define('elements/select',\n+    ['core/log', 'core/z', 'jquery', 'underscore'],\n+    function(log, z, $, _) {\n+    'use strict';\n+    var logger = log('elements/select');\n+\n+    var VISIBLE = 'mkt-select--visible';\n+\n+    var MktOptionElement = document.registerElement('mkt-option', {\n+        prototype: Object.create(HTMLOptionElement.prototype, {\n+            option: {\n+                // Value set in <mkt-select>'s createdCallback.\n+                value: null,\n+                writable: true\n+            }\n+        })\n+    });\n+\n+    var MktOptGroupElement = document.registerElement('mkt-optgroup', {\n+        prototype: Object.create(HTMLOptGroupElement.prototype, {\n+            option: {\n+                // Value set in <mkt-select>'s createdCallback.\n+                value: null,\n+                writable: true\n+            }\n+        })\n+    });\n+\n+    var MktSelectElement = document.registerElement('mkt-select', {\n+        prototype: Object.create(HTMLSelectElement.prototype, {\n+            createdCallback: {\n+                value: function() {\n+                    var root = this;\n+\n+                    // Create a hidden <select> element.\n+                    var select = document.createElement('select');\n+                    select.style.display = 'none';\n+                    copyAttrs(select, root);\n+\n+                    var mktOptGroup = document.createElement('mkt-optgroup');\n+                    var optGroup = root.querySelector('optgroup');\n+                    var options = root.querySelectorAll('option');\n+                    for (var i = 0; i < options.length; i++) {\n+                        var option = options[i];\n+\n+                        // Create <mkt-option>s into the <mkt-optgroup>.\n+                        var mktOption = document.createElement('mkt-option');\n+                        copyAttrs(mktOption, option);\n+                        mktOption.innerHTML = option.innerHTML;\n+                        mktOption.option = option;\n+                        mktOptGroup.appendChild(mktOption);\n+                    }\n+                    root.appendChild(mktOptGroup);\n+                    mktOptGroup.optGroup = optGroup;\n+                    select.appendChild(optGroup);\n+\n+                    root.appendChild(select);\n+                    root.select = select;  // Set select element.\n+\n+                    updateMktOptionIndices(\n+                        root, root.querySelector('mkt-option[selected]'));\n+\n+                    // Align options with <mkt-selected-text>.\n+                    if (alignMktOptions(root) > 0) {\n+                        root.setAttribute('data-mkt-select--aligned', true);\n+                    }\n+                }\n+            },\n+            toggle: {\n+                // Toggles visibility of the <mkt-option>s.\n+                value: function(bool) {\n+                    if (!this.getAttribute('data-mkt-select--aligned')) {\n+                        if (alignMktOptions(this) > 0) {\n+                            this.setAttribute('data-mkt-select--aligned', true);\n+                        }\n+                    }\n+                    if (bool) {\n+                        this.classList.toggle(VISIBLE, bool);\n+                    } else {\n+                        this.classList.toggle(VISIBLE);\n+                    }\n+                    return this;\n+                },\n+            },\n+            select: {\n+                // Value is set in the createdCallback.\n+                value: null,\n+                writable: true\n+            }\n+        }),\n+    });\n+\n+    function alignMktOptions(mktSelect) {\n+        var offset = $('mkt-selected-text', mktSelect).position().left;\n+        $('mkt-option', mktSelect).css('padding-left', offset);\n+        return offset;\n+    }\n+\n+    function updateMktOptionIndices(mktSelect, selectedOption) {","path":"src/media/js/elements/select.js","position":120,"original_position":120,"commit_id":"805e78c244c3e0e0b789a9328acf00d48890426a","original_commit_id":"805e78c244c3e0e0b789a9328acf00d48890426a","user":{"login":"ngokevin","id":674727,"avatar_url":"https://avatars.githubusercontent.com/u/674727?v=3","gravatar_id":"","url":"https://api.github.com/users/ngokevin","html_url":"https://github.com/ngokevin","followers_url":"https://api.github.com/users/ngokevin/followers","following_url":"https://api.github.com/users/ngokevin/following{/other_user}","gists_url":"https://api.github.com/users/ngokevin/gists{/gist_id}","starred_url":"https://api.github.com/users/ngokevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngokevin/subscriptions","organizations_url":"https://api.github.com/users/ngokevin/orgs","repos_url":"https://api.github.com/users/ngokevin/repos","events_url":"https://api.github.com/users/ngokevin/events{/privacy}","received_events_url":"https://api.github.com/users/ngokevin/received_events","type":"User","site_admin":false},"body":"good idea","created_at":"2015-04-01T19:26:16Z","updated_at":"2015-04-01T19:26:16Z","html_url":"https://github.com/mozilla/fireplace/pull/1106#discussion_r27602502","pull_request_url":"https://api.github.com/repos/mozilla/fireplace/pulls/1106","_links":{"self":{"href":"https://api.github.com/repos/mozilla/fireplace/pulls/comments/27602502"},"html":{"href":"https://github.com/mozilla/fireplace/pull/1106#discussion_r27602502"},"pull_request":{"href":"https://api.github.com/repos/mozilla/fireplace/pulls/1106"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/fireplace/pulls/1106","id":32280822,"html_url":"https://github.com/mozilla/fireplace/pull/1106","diff_url":"https://github.com/mozilla/fireplace/pull/1106.diff","patch_url":"https://github.com/mozilla/fireplace/pull/1106.patch","issue_url":"https://api.github.com/repos/mozilla/fireplace/issues/1106","number":1106,"state":"open","locked":false,"title":"platform selector (bug 1148157)","user":{"login":"ngokevin","id":674727,"avatar_url":"https://avatars.githubusercontent.com/u/674727?v=3","gravatar_id":"","url":"https://api.github.com/users/ngokevin","html_url":"https://github.com/ngokevin","followers_url":"https://api.github.com/users/ngokevin/followers","following_url":"https://api.github.com/users/ngokevin/following{/other_user}","gists_url":"https://api.github.com/users/ngokevin/gists{/gist_id}","starred_url":"https://api.github.com/users/ngokevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngokevin/subscriptions","organizations_url":"https://api.github.com/users/ngokevin/orgs","repos_url":"https://api.github.com/users/ngokevin/repos","events_url":"https://api.github.com/users/ngokevin/events{/privacy}","received_events_url":"https://api.github.com/users/ngokevin/received_events","type":"User","site_admin":false},"body":"*Entering 9 3/4*\r\n\r\n```<mkt-select>```, ```<mkt-optgroup>```, ```<mkt-option>``` that all proxy the HTML```X```Element interfaces to an internal HTML element.\r\n\r\nTODO:\r\n\r\n- [x] have ```toggle``` dynamically figure out what's select to not display it twice\r\n- [x] fire a onchange to the select whenever option is clicked (somehow harness the HTMLSelectElement interface)\r\n- [x] register the onchange to the compat filter code\r\n- [x] line up the options, not centered\r\n- [x] animation for options sliding down\r\n\r\n**Current State 3:**\r\n\r\n![screen shot 2015-04-01 at 12 24 53 pm](https://cloud.githubusercontent.com/assets/674727/6949591/24309c68-d86a-11e4-8f11-5af6ec5c5879.png)\r\n![screen shot 2015-04-01 at 12 24 55 pm](https://cloud.githubusercontent.com/assets/674727/6949593/2433230c-d86a-11e4-8f0c-93a4a9971233.png)\r\n![screen shot 2015-04-01 at 12 24 49 pm](https://cloud.githubusercontent.com/assets/674727/6949598/276c3d2e-d86a-11e4-9592-8a09c12450fc.png)\r\n\r\n","created_at":"2015-03-31T00:23:44Z","updated_at":"2015-04-01T19:26:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"275531b8608465783c4489c37a19fb4700c3f7e8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/fireplace/pulls/1106/commits","review_comments_url":"https://api.github.com/repos/mozilla/fireplace/pulls/1106/comments","review_comment_url":"https://api.github.com/repos/mozilla/fireplace/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/fireplace/issues/1106/comments","statuses_url":"https://api.github.com/repos/mozilla/fireplace/statuses/805e78c244c3e0e0b789a9328acf00d48890426a","head":{"label":"ngokevin:compat2","ref":"compat2","sha":"805e78c244c3e0e0b789a9328acf00d48890426a","user":{"login":"ngokevin","id":674727,"avatar_url":"https://avatars.githubusercontent.com/u/674727?v=3","gravatar_id":"","url":"https://api.github.com/users/ngokevin","html_url":"https://github.com/ngokevin","followers_url":"https://api.github.com/users/ngokevin/followers","following_url":"https://api.github.com/users/ngokevin/following{/other_user}","gists_url":"https://api.github.com/users/ngokevin/gists{/gist_id}","starred_url":"https://api.github.com/users/ngokevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngokevin/subscriptions","organizations_url":"https://api.github.com/users/ngokevin/orgs","repos_url":"https://api.github.com/users/ngokevin/repos","events_url":"https://api.github.com/users/ngokevin/events{/privacy}","received_events_url":"https://api.github.com/users/ngokevin/received_events","type":"User","site_admin":false},"repo":{"id":11646521,"name":"fireplace","full_name":"ngokevin/fireplace","owner":{"login":"ngokevin","id":674727,"avatar_url":"https://avatars.githubusercontent.com/u/674727?v=3","gravatar_id":"","url":"https://api.github.com/users/ngokevin","html_url":"https://github.com/ngokevin","followers_url":"https://api.github.com/users/ngokevin/followers","following_url":"https://api.github.com/users/ngokevin/following{/other_user}","gists_url":"https://api.github.com/users/ngokevin/gists{/gist_id}","starred_url":"https://api.github.com/users/ngokevin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ngokevin/subscriptions","organizations_url":"https://api.github.com/users/ngokevin/orgs","repos_url":"https://api.github.com/users/ngokevin/repos","events_url":"https://api.github.com/users/ngokevin/events{/privacy}","received_events_url":"https://api.github.com/users/ngokevin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ngokevin/fireplace","description":"Frontend for the Firefox Marketplace","fork":true,"url":"https://api.github.com/repos/ngokevin/fireplace","forks_url":"https://api.github.com/repos/ngokevin/fireplace/forks","keys_url":"https://api.github.com/repos/ngokevin/fireplace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ngokevin/fireplace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ngokevin/fireplace/teams","hooks_url":"https://api.github.com/repos/ngokevin/fireplace/hooks","issue_events_url":"https://api.github.com/repos/ngokevin/fireplace/issues/events{/number}","events_url":"https://api.github.com/repos/ngokevin/fireplace/events","assignees_url":"https://api.github.com/repos/ngokevin/fireplace/assignees{/user}","branches_url":"https://api.github.com/repos/ngokevin/fireplace/branches{/branch}","tags_url":"https://api.github.com/repos/ngokevin/fireplace/tags","blobs_url":"https://api.github.com/repos/ngokevin/fireplace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ngokevin/fireplace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ngokevin/fireplace/git/refs{/sha}","trees_url":"https://api.github.com/repos/ngokevin/fireplace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ngokevin/fireplace/statuses/{sha}","languages_url":"https://api.github.com/repos/ngokevin/fireplace/languages","stargazers_url":"https://api.github.com/repos/ngokevin/fireplace/stargazers","contributors_url":"https://api.github.com/repos/ngokevin/fireplace/contributors","subscribers_url":"https://api.github.com/repos/ngokevin/fireplace/subscribers","subscription_url":"https://api.github.com/repos/ngokevin/fireplace/subscription","commits_url":"https://api.github.com/repos/ngokevin/fireplace/commits{/sha}","git_commits_url":"https://api.github.com/repos/ngokevin/fireplace/git/commits{/sha}","comments_url":"https://api.github.com/repos/ngokevin/fireplace/comments{/number}","issue_comment_url":"https://api.github.com/repos/ngokevin/fireplace/issues/comments{/number}","contents_url":"https://api.github.com/repos/ngokevin/fireplace/contents/{+path}","compare_url":"https://api.github.com/repos/ngokevin/fireplace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ngokevin/fireplace/merges","archive_url":"https://api.github.com/repos/ngokevin/fireplace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ngokevin/fireplace/downloads","issues_url":"https://api.github.com/repos/ngokevin/fireplace/issues{/number}","pulls_url":"https://api.github.com/repos/ngokevin/fireplace/pulls{/number}","milestones_url":"https://api.github.com/repos/ngokevin/fireplace/milestones{/number}","notifications_url":"https://api.github.com/repos/ngokevin/fireplace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ngokevin/fireplace/labels{/name}","releases_url":"https://api.github.com/repos/ngokevin/fireplace/releases{/id}","created_at":"2013-07-24T22:13:26Z","updated_at":"2015-02-03T19:11:47Z","pushed_at":"2015-04-01T19:19:06Z","git_url":"git://github.com/ngokevin/fireplace.git","ssh_url":"git@github.com:ngokevin/fireplace.git","clone_url":"https://github.com/ngokevin/fireplace.git","svn_url":"https://github.com/ngokevin/fireplace","homepage":"https://marketplace.firefox.com/","size":29777,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"921506e709e5e9efc9ae9cb1a653e19fbe5b02a2","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":8046076,"name":"fireplace","full_name":"mozilla/fireplace","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/fireplace","description":"Frontend for the Firefox Marketplace","fork":false,"url":"https://api.github.com/repos/mozilla/fireplace","forks_url":"https://api.github.com/repos/mozilla/fireplace/forks","keys_url":"https://api.github.com/repos/mozilla/fireplace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/fireplace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/fireplace/teams","hooks_url":"https://api.github.com/repos/mozilla/fireplace/hooks","issue_events_url":"https://api.github.com/repos/mozilla/fireplace/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/fireplace/events","assignees_url":"https://api.github.com/repos/mozilla/fireplace/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/fireplace/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/fireplace/tags","blobs_url":"https://api.github.com/repos/mozilla/fireplace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/fireplace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/fireplace/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/fireplace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/fireplace/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/fireplace/languages","stargazers_url":"https://api.github.com/repos/mozilla/fireplace/stargazers","contributors_url":"https://api.github.com/repos/mozilla/fireplace/contributors","subscribers_url":"https://api.github.com/repos/mozilla/fireplace/subscribers","subscription_url":"https://api.github.com/repos/mozilla/fireplace/subscription","commits_url":"https://api.github.com/repos/mozilla/fireplace/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/fireplace/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/fireplace/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/fireplace/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/fireplace/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/fireplace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/fireplace/merges","archive_url":"https://api.github.com/repos/mozilla/fireplace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/fireplace/downloads","issues_url":"https://api.github.com/repos/mozilla/fireplace/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/fireplace/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/fireplace/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/fireplace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/fireplace/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/fireplace/releases{/id}","created_at":"2013-02-06T06:41:06Z","updated_at":"2015-04-01T18:51:44Z","pushed_at":"2015-04-01T19:19:06Z","git_url":"git://github.com/mozilla/fireplace.git","ssh_url":"git@github.com:mozilla/fireplace.git","clone_url":"https://github.com/mozilla/fireplace.git","svn_url":"https://github.com/mozilla/fireplace","homepage":"https://marketplace.firefox.com/","size":92008,"stargazers_count":58,"watchers_count":58,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":98,"mirror_url":null,"open_issues_count":4,"forks":98,"open_issues":4,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/fireplace/pulls/1106"},"html":{"href":"https://github.com/mozilla/fireplace/pull/1106"},"issue":{"href":"https://api.github.com/repos/mozilla/fireplace/issues/1106"},"comments":{"href":"https://api.github.com/repos/mozilla/fireplace/issues/1106/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/fireplace/pulls/1106/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/fireplace/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/fireplace/pulls/1106/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/fireplace/statuses/805e78c244c3e0e0b789a9328acf00d48890426a"}}}}