{"action":"created","comment":{"url":"https://api.github.com/repos/openstyles/stylus/pulls/comments/218778593","pull_request_review_id":156788781,"id":218778593,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxODc3ODU5Mw==","diff_hunk":"@@ -286,7 +316,33 @@ function configDialog(style) {\n   }\n \n   function updateVarOnChange() {\n-    this.va.value = this.type !== 'checkbox' ? this.value : this.checked ? '1' : '0';\n+    if (this.type === 'number') {\n+      this.value = this.va.value = clampValue(this.value, this.va);\n+    } else if (this.type === 'range') {\n+      this.va.value = Number(this.value);\n+      $('.current-value', this.closest('.config-range')).textContent = this.va.value + (this.va.units || '');\n+    } else {\n+      this.va.value = this.type !== 'checkbox' ? this.value : this.checked ? '1' : '0';\n+    }\n+  }\n+\n+  // Clamp input[type=number] to a valid range\n+  function clampValue(value, va, break = false) {","path":"manage/config-dialog.js","position":null,"original_position":72,"commit_id":"df6a3018752fa8863ce93f1288b202216c23f650","original_commit_id":"59bf22092553c8d30b18b2bfd422e8d9a5b377fd","user":{"login":"Mottie","id":136959,"node_id":"MDQ6VXNlcjEzNjk1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/136959?v=4","gravatar_id":"","url":"https://api.github.com/users/Mottie","html_url":"https://github.com/Mottie","followers_url":"https://api.github.com/users/Mottie/followers","following_url":"https://api.github.com/users/Mottie/following{/other_user}","gists_url":"https://api.github.com/users/Mottie/gists{/gist_id}","starred_url":"https://api.github.com/users/Mottie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mottie/subscriptions","organizations_url":"https://api.github.com/users/Mottie/orgs","repos_url":"https://api.github.com/users/Mottie/repos","events_url":"https://api.github.com/users/Mottie/events{/privacy}","received_events_url":"https://api.github.com/users/Mottie/received_events","type":"User","site_admin":false},"body":"Yeah, I forgot `break` was a keyword... long day yesterday.","created_at":"2018-09-19T12:14:33Z","updated_at":"2018-09-19T12:14:34Z","html_url":"https://github.com/openstyles/stylus/pull/494#discussion_r218778593","pull_request_url":"https://api.github.com/repos/openstyles/stylus/pulls/494","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/openstyles/stylus/pulls/comments/218778593"},"html":{"href":"https://github.com/openstyles/stylus/pull/494#discussion_r218778593"},"pull_request":{"href":"https://api.github.com/repos/openstyles/stylus/pulls/494"}},"in_reply_to_id":218679760},"pull_request":{"url":"https://api.github.com/repos/openstyles/stylus/pulls/494","id":213152720,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEzMTUyNzIw","html_url":"https://github.com/openstyles/stylus/pull/494","diff_url":"https://github.com/openstyles/stylus/pull/494.diff","patch_url":"https://github.com/openstyles/stylus/pull/494.patch","issue_url":"https://api.github.com/repos/openstyles/stylus/issues/494","number":494,"state":"open","locked":false,"title":"Add number & range Usercss variables (#492)","user":{"login":"Mottie","id":136959,"node_id":"MDQ6VXNlcjEzNjk1OQ==","avatar_url":"https://avatars2.githubusercontent.com/u/136959?v=4","gravatar_id":"","url":"https://api.github.com/users/Mottie","html_url":"https://github.com/Mottie","followers_url":"https://api.github.com/users/Mottie/followers","following_url":"https://api.github.com/users/Mottie/following{/other_user}","gists_url":"https://api.github.com/users/Mottie/gists{/gist_id}","starred_url":"https://api.github.com/users/Mottie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mottie/subscriptions","organizations_url":"https://api.github.com/users/Mottie/orgs","repos_url":"https://api.github.com/users/Mottie/repos","events_url":"https://api.github.com/users/Mottie/events{/privacy}","received_events_url":"https://api.github.com/users/Mottie/received_events","type":"User","site_admin":false},"body":"Adds new usercss variables & behavior:\r\n\r\n* Add number & range variables:\r\n  * `@var number some-number \"Number\" [10, 0, 20, 1, \"px\"]` (`[default, min, max, step, units]`).\r\n  * `@var range  some-range  \"Range (0-10)\"  [5, 0, 10, 1, \"em\"]` (`[default, min, max, step, units]`)\r\n  * The `min`, `max`, `step` and `units` are optional; but added sequentially.\r\n* Focusing on a text input will select all content.\r\n* Default select option is set by including a `*` at the end of the key, e.g.\r\n  * `@var select aSelect \"Font\"   [\"Arial\", \"Consolas*\", \"Times New Roman\"]`\r\n  * ```\r\n    @var select aSelect \"Font\" {\r\n      \"Arial\": \"arial\",\r\n      \"Consolas*\": \"consolas\",\r\n      \"Times\": \"Times New Roman\"\r\n    }\r\n    ```\r\n\r\n------\r\n\r\nExample UserCSS:\r\n\r\n```css\r\n/* ==UserStyle==\r\n@namespace      stylus#492\r\n@name           new variables\r\n@version        1.0.0\r\n@description    Testing new variables\r\n@author         Me\r\n@var text   aTxt    \"Text\"    \"Blah\"\r\n@var number aNum    \"Margin\"  [1, 0, 10, 0.5, \"em\"]\r\n@var select aSelect \"Font\"    [\"Arial\", \"Consolas*\", \"Times New Roman\"]\r\n@var range  aRange0 \"Opacity\" [1, 0, 1, 0.1]\r\n@var range  aRange1 \"Width\"   [5, 1, 10, 1, \"px\"]\r\n@var range  aRange2 \"Height\"  [11, 10, \"vh\"]\r\n@preprocessor uso\r\n==/UserStyle== */\r\n@-moz-document domain(\"google.com\") {\r\n  body > div:last-child {\r\n    content: '/*[[aTxt]]*/';\r\n    margin: /*[[aNum]]*/;\r\n    font-family: '/*[[aSelect]]*/';\r\n    opacity: /*[[aRange0]]*/;\r\n    width: /*[[aRange1]]*/;\r\n    height: /*[[aRange2]]*/;\r\n  }\r\n}\r\n```\r\n\r\n![](https://user-images.githubusercontent.com/136959/45601540-35b41600-b9d4-11e8-8229-939460c3b5e7.png)\r\n\r\n","created_at":"2018-09-05T02:31:09Z","updated_at":"2018-09-19T12:14:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2efde92a97de0f0bc3f78b746de17184d05b662","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/openstyles/stylus/pulls/494/commits","review_comments_url":"https://api.github.com/repos/openstyles/stylus/pulls/494/comments","review_comment_url":"https://api.github.com/repos/openstyles/stylus/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openstyles/stylus/issues/494/comments","statuses_url":"https://api.github.com/repos/openstyles/stylus/statuses/df6a3018752fa8863ce93f1288b202216c23f650","head":{"label":"openstyles:usercss","ref":"usercss","sha":"df6a3018752fa8863ce93f1288b202216c23f650","user":{"login":"openstyles","id":29350089,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5MzUwMDg5","avatar_url":"https://avatars2.githubusercontent.com/u/29350089?v=4","gravatar_id":"","url":"https://api.github.com/users/openstyles","html_url":"https://github.com/openstyles","followers_url":"https://api.github.com/users/openstyles/followers","following_url":"https://api.github.com/users/openstyles/following{/other_user}","gists_url":"https://api.github.com/users/openstyles/gists{/gist_id}","starred_url":"https://api.github.com/users/openstyles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstyles/subscriptions","organizations_url":"https://api.github.com/users/openstyles/orgs","repos_url":"https://api.github.com/users/openstyles/repos","events_url":"https://api.github.com/users/openstyles/events{/privacy}","received_events_url":"https://api.github.com/users/openstyles/received_events","type":"Organization","site_admin":false},"repo":{"id":78330996,"node_id":"MDEwOlJlcG9zaXRvcnk3ODMzMDk5Ng==","name":"stylus","full_name":"openstyles/stylus","private":false,"owner":{"login":"openstyles","id":29350089,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5MzUwMDg5","avatar_url":"https://avatars2.githubusercontent.com/u/29350089?v=4","gravatar_id":"","url":"https://api.github.com/users/openstyles","html_url":"https://github.com/openstyles","followers_url":"https://api.github.com/users/openstyles/followers","following_url":"https://api.github.com/users/openstyles/following{/other_user}","gists_url":"https://api.github.com/users/openstyles/gists{/gist_id}","starred_url":"https://api.github.com/users/openstyles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstyles/subscriptions","organizations_url":"https://api.github.com/users/openstyles/orgs","repos_url":"https://api.github.com/users/openstyles/repos","events_url":"https://api.github.com/users/openstyles/events{/privacy}","received_events_url":"https://api.github.com/users/openstyles/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/openstyles/stylus","description":"Stylus - Userstyles Manager","fork":false,"url":"https://api.github.com/repos/openstyles/stylus","forks_url":"https://api.github.com/repos/openstyles/stylus/forks","keys_url":"https://api.github.com/repos/openstyles/stylus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstyles/stylus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstyles/stylus/teams","hooks_url":"https://api.github.com/repos/openstyles/stylus/hooks","issue_events_url":"https://api.github.com/repos/openstyles/stylus/issues/events{/number}","events_url":"https://api.github.com/repos/openstyles/stylus/events","assignees_url":"https://api.github.com/repos/openstyles/stylus/assignees{/user}","branches_url":"https://api.github.com/repos/openstyles/stylus/branches{/branch}","tags_url":"https://api.github.com/repos/openstyles/stylus/tags","blobs_url":"https://api.github.com/repos/openstyles/stylus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstyles/stylus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstyles/stylus/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstyles/stylus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstyles/stylus/statuses/{sha}","languages_url":"https://api.github.com/repos/openstyles/stylus/languages","stargazers_url":"https://api.github.com/repos/openstyles/stylus/stargazers","contributors_url":"https://api.github.com/repos/openstyles/stylus/contributors","subscribers_url":"https://api.github.com/repos/openstyles/stylus/subscribers","subscription_url":"https://api.github.com/repos/openstyles/stylus/subscription","commits_url":"https://api.github.com/repos/openstyles/stylus/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstyles/stylus/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstyles/stylus/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstyles/stylus/issues/comments{/number}","contents_url":"https://api.github.com/repos/openstyles/stylus/contents/{+path}","compare_url":"https://api.github.com/repos/openstyles/stylus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstyles/stylus/merges","archive_url":"https://api.github.com/repos/openstyles/stylus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstyles/stylus/downloads","issues_url":"https://api.github.com/repos/openstyles/stylus/issues{/number}","pulls_url":"https://api.github.com/repos/openstyles/stylus/pulls{/number}","milestones_url":"https://api.github.com/repos/openstyles/stylus/milestones{/number}","notifications_url":"https://api.github.com/repos/openstyles/stylus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstyles/stylus/labels{/name}","releases_url":"https://api.github.com/repos/openstyles/stylus/releases{/id}","deployments_url":"https://api.github.com/repos/openstyles/stylus/deployments","created_at":"2017-01-08T08:35:15Z","updated_at":"2018-09-18T15:39:44Z","pushed_at":"2018-09-19T12:10:07Z","git_url":"git://github.com/openstyles/stylus.git","ssh_url":"git@github.com:openstyles/stylus.git","clone_url":"https://github.com/openstyles/stylus.git","svn_url":"https://github.com/openstyles/stylus","homepage":"https://add0n.com/stylus.html","size":9019,"stargazers_count":1259,"watchers_count":1259,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"archived":false,"open_issues_count":58,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":83,"open_issues":58,"watchers":1259,"default_branch":"master"}},"base":{"label":"openstyles:master","ref":"master","sha":"2a52139b6a1212be2daeadae4eb56e9bab2ed0b4","user":{"login":"openstyles","id":29350089,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5MzUwMDg5","avatar_url":"https://avatars2.githubusercontent.com/u/29350089?v=4","gravatar_id":"","url":"https://api.github.com/users/openstyles","html_url":"https://github.com/openstyles","followers_url":"https://api.github.com/users/openstyles/followers","following_url":"https://api.github.com/users/openstyles/following{/other_user}","gists_url":"https://api.github.com/users/openstyles/gists{/gist_id}","starred_url":"https://api.github.com/users/openstyles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstyles/subscriptions","organizations_url":"https://api.github.com/users/openstyles/orgs","repos_url":"https://api.github.com/users/openstyles/repos","events_url":"https://api.github.com/users/openstyles/events{/privacy}","received_events_url":"https://api.github.com/users/openstyles/received_events","type":"Organization","site_admin":false},"repo":{"id":78330996,"node_id":"MDEwOlJlcG9zaXRvcnk3ODMzMDk5Ng==","name":"stylus","full_name":"openstyles/stylus","private":false,"owner":{"login":"openstyles","id":29350089,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI5MzUwMDg5","avatar_url":"https://avatars2.githubusercontent.com/u/29350089?v=4","gravatar_id":"","url":"https://api.github.com/users/openstyles","html_url":"https://github.com/openstyles","followers_url":"https://api.github.com/users/openstyles/followers","following_url":"https://api.github.com/users/openstyles/following{/other_user}","gists_url":"https://api.github.com/users/openstyles/gists{/gist_id}","starred_url":"https://api.github.com/users/openstyles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openstyles/subscriptions","organizations_url":"https://api.github.com/users/openstyles/orgs","repos_url":"https://api.github.com/users/openstyles/repos","events_url":"https://api.github.com/users/openstyles/events{/privacy}","received_events_url":"https://api.github.com/users/openstyles/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/openstyles/stylus","description":"Stylus - Userstyles Manager","fork":false,"url":"https://api.github.com/repos/openstyles/stylus","forks_url":"https://api.github.com/repos/openstyles/stylus/forks","keys_url":"https://api.github.com/repos/openstyles/stylus/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openstyles/stylus/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openstyles/stylus/teams","hooks_url":"https://api.github.com/repos/openstyles/stylus/hooks","issue_events_url":"https://api.github.com/repos/openstyles/stylus/issues/events{/number}","events_url":"https://api.github.com/repos/openstyles/stylus/events","assignees_url":"https://api.github.com/repos/openstyles/stylus/assignees{/user}","branches_url":"https://api.github.com/repos/openstyles/stylus/branches{/branch}","tags_url":"https://api.github.com/repos/openstyles/stylus/tags","blobs_url":"https://api.github.com/repos/openstyles/stylus/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openstyles/stylus/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openstyles/stylus/git/refs{/sha}","trees_url":"https://api.github.com/repos/openstyles/stylus/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openstyles/stylus/statuses/{sha}","languages_url":"https://api.github.com/repos/openstyles/stylus/languages","stargazers_url":"https://api.github.com/repos/openstyles/stylus/stargazers","contributors_url":"https://api.github.com/repos/openstyles/stylus/contributors","subscribers_url":"https://api.github.com/repos/openstyles/stylus/subscribers","subscription_url":"https://api.github.com/repos/openstyles/stylus/subscription","commits_url":"https://api.github.com/repos/openstyles/stylus/commits{/sha}","git_commits_url":"https://api.github.com/repos/openstyles/stylus/git/commits{/sha}","comments_url":"https://api.github.com/repos/openstyles/stylus/comments{/number}","issue_comment_url":"https://api.github.com/repos/openstyles/stylus/issues/comments{/number}","contents_url":"https://api.github.com/repos/openstyles/stylus/contents/{+path}","compare_url":"https://api.github.com/repos/openstyles/stylus/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openstyles/stylus/merges","archive_url":"https://api.github.com/repos/openstyles/stylus/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openstyles/stylus/downloads","issues_url":"https://api.github.com/repos/openstyles/stylus/issues{/number}","pulls_url":"https://api.github.com/repos/openstyles/stylus/pulls{/number}","milestones_url":"https://api.github.com/repos/openstyles/stylus/milestones{/number}","notifications_url":"https://api.github.com/repos/openstyles/stylus/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openstyles/stylus/labels{/name}","releases_url":"https://api.github.com/repos/openstyles/stylus/releases{/id}","deployments_url":"https://api.github.com/repos/openstyles/stylus/deployments","created_at":"2017-01-08T08:35:15Z","updated_at":"2018-09-18T15:39:44Z","pushed_at":"2018-09-19T12:10:07Z","git_url":"git://github.com/openstyles/stylus.git","ssh_url":"git@github.com:openstyles/stylus.git","clone_url":"https://github.com/openstyles/stylus.git","svn_url":"https://github.com/openstyles/stylus","homepage":"https://add0n.com/stylus.html","size":9019,"stargazers_count":1259,"watchers_count":1259,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"archived":false,"open_issues_count":58,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":83,"open_issues":58,"watchers":1259,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/openstyles/stylus/pulls/494"},"html":{"href":"https://github.com/openstyles/stylus/pull/494"},"issue":{"href":"https://api.github.com/repos/openstyles/stylus/issues/494"},"comments":{"href":"https://api.github.com/repos/openstyles/stylus/issues/494/comments"},"review_comments":{"href":"https://api.github.com/repos/openstyles/stylus/pulls/494/comments"},"review_comment":{"href":"https://api.github.com/repos/openstyles/stylus/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openstyles/stylus/pulls/494/commits"},"statuses":{"href":"https://api.github.com/repos/openstyles/stylus/statuses/df6a3018752fa8863ce93f1288b202216c23f650"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"Mottie"}}