{"action":"created","comment":{"url":"https://api.github.com/repos/shanebo/suiter/pulls/comments/133859529","pull_request_review_id":57088873,"id":133859529,"diff_hunk":"@@ -0,0 +1,131 @@\n+/*\n+name: Suiter\n+description: Simple powerful responsive queries\n+license: MIT-style\n+authors:\n+  - Shane Thacker (steadymade.com)\n+requires:\n+  - Nothing\n+*/\n+\n+\n+function cleanString(str) {\n+  return str.replace(/\\s+/g, ' ').trim();\n+}\n+\n+function isValidQuery(query) {\n+  return /[swh]\\s[><=](?:=)?\\s\\d+(?:(?:\\s?\\&\\&\\s[swh]\\s[><=](?:=)?\\s\\d+)?)+/gi.test(query);\n+}\n+\n+function queryToClass(query) {\n+  return query\n+    .replace(/</g, 'lt')\n+    .replace(/>/g, 'gt')\n+    .replace(/=/g, 'e')\n+    .replace(/\\|\\|/g, 'or')\n+    .replace(/\\&\\&/g, 'and')\n+    .replace(/\\s/g, '-');\n+}\n+\n+function addClass(el, style) {\n+  if (!el.classList.contains(style)) {\n+    el.classList.add(style);\n+  }\n+}\n+\n+function addClasses(el, style) {\n+  Array.isArray(style)\n+    ? style.forEach(addClass.bind(null, el))\n+    : addClass(el, style);\n+}\n+\n+function removeClass(el, style) {\n+  if (el.classList.contains(style)) {\n+    el.classList.remove(style);\n+  }\n+}\n+\n+function removeClasses(el, style) {\n+  Array.isArray(style)\n+    ? style.forEach(removeClass.bind(null, el))\n+    : removeClass(el, style);\n+}\n+\n+function getQueries(el) {\n+  const responsiveQuery = el.getAttribute('data-suiter-queries');\n+  const queries = responsiveQuery.split(',');\n+  const suiterClasses = el.getAttribute('data-suiter-classes');\n+  let classes;\n+\n+  if (suiterClasses) {\n+    classes = suiterClasses.split(',')\n+      .map(function(style){\n+        return cleanString(style).split(' ');\n+      });\n+  }\n+\n+  return queries\n+    .map(cleanString)\n+    .filter(isValidQuery)\n+    .map(function(query, q){\n+      return {\n+        statement: query,\n+        class: queryToClass(query),\n+        customClass: classes ? classes[q] : null\n+      };\n+    });\n+}\n+\n+function getRules(selector) {\n+  const els = Array.prototype.slice.call(document.querySelectorAll(selector));\n+\n+  return els.map(function(el){\n+    return {\n+      el: el,\n+      queries: getQueries(el)\n+    };\n+  });\n+}\n+\n+module.exports = function suiter(elementSelector) {\n+\n+  let resizing = false;\n+  const rules = getRules(elementSelector);\n+\n+  function throttle() {\n+    if (!resizing) {\n+      window.requestAnimationFrame(resize);\n+      resizing = true;\n+    }\n+  }\n+\n+  function resize() {\n+    // eval(query.statment) uses these values for comparisons\n+    const sw = window.innerWidth;","path":"index.js","position":104,"original_position":104,"commit_id":"6542d30af62faec5b30661c901fb7f80589f8c25","original_commit_id":"6542d30af62faec5b30661c901fb7f80589f8c25","user":{"login":"shanebo","id":5044,"avatar_url":"https://avatars3.githubusercontent.com/u/5044?v=4","gravatar_id":"","url":"https://api.github.com/users/shanebo","html_url":"https://github.com/shanebo","followers_url":"https://api.github.com/users/shanebo/followers","following_url":"https://api.github.com/users/shanebo/following{/other_user}","gists_url":"https://api.github.com/users/shanebo/gists{/gist_id}","starred_url":"https://api.github.com/users/shanebo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shanebo/subscriptions","organizations_url":"https://api.github.com/users/shanebo/orgs","repos_url":"https://api.github.com/users/shanebo/repos","events_url":"https://api.github.com/users/shanebo/events{/privacy}","received_events_url":"https://api.github.com/users/shanebo/received_events","type":"User","site_admin":false},"body":"@scottcorgan great catch pulling these out of the loop since they don't change on each iteration.","created_at":"2017-08-18T00:29:01Z","updated_at":"2017-08-18T00:34:07Z","html_url":"https://github.com/shanebo/suiter/pull/3#discussion_r133859529","pull_request_url":"https://api.github.com/repos/shanebo/suiter/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/shanebo/suiter/pulls/comments/133859529"},"html":{"href":"https://github.com/shanebo/suiter/pull/3#discussion_r133859529"},"pull_request":{"href":"https://api.github.com/repos/shanebo/suiter/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/shanebo/suiter/pulls/3","id":136359696,"html_url":"https://github.com/shanebo/suiter/pull/3","diff_url":"https://github.com/shanebo/suiter/pull/3.diff","patch_url":"https://github.com/shanebo/suiter/pull/3.patch","issue_url":"https://api.github.com/repos/shanebo/suiter/issues/3","number":3,"state":"open","locked":false,"title":"Prepare for packaging","user":{"login":"scottcorgan","id":974723,"avatar_url":"https://avatars3.githubusercontent.com/u/974723?v=4","gravatar_id":"","url":"https://api.github.com/users/scottcorgan","html_url":"https://github.com/scottcorgan","followers_url":"https://api.github.com/users/scottcorgan/followers","following_url":"https://api.github.com/users/scottcorgan/following{/other_user}","gists_url":"https://api.github.com/users/scottcorgan/gists{/gist_id}","starred_url":"https://api.github.com/users/scottcorgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottcorgan/subscriptions","organizations_url":"https://api.github.com/users/scottcorgan/orgs","repos_url":"https://api.github.com/users/scottcorgan/repos","events_url":"https://api.github.com/users/scottcorgan/events{/privacy}","received_events_url":"https://api.github.com/users/scottcorgan/received_events","type":"User","site_admin":false},"body":"Closes #1 \r\n\r\n---\r\n\r\nThis is a bit of a large PR, but you can look at each commit to see its progress.\r\n\r\n## What changed\r\n\r\n* Sets it up as a CommonSJ module\r\n* Adds tests to verify that it works\r\n* Adds a WIP readme with instructions for viewing demo\r\n* Adds example directory to play with (has live reload 👍 )\r\n* Small refactor to pull the pure functions out of the main closure.\r\n\r\nIt's not ready to be published yet as we discuss #2. But a review and merge would be great 💯 ","created_at":"2017-08-17T21:39:47Z","updated_at":"2017-08-18T00:34:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef1ad87e326c030ff3ce051d4bbb62dfe4f2f9a9","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/shanebo/suiter/pulls/3/commits","review_comments_url":"https://api.github.com/repos/shanebo/suiter/pulls/3/comments","review_comment_url":"https://api.github.com/repos/shanebo/suiter/pulls/comments{/number}","comments_url":"https://api.github.com/repos/shanebo/suiter/issues/3/comments","statuses_url":"https://api.github.com/repos/shanebo/suiter/statuses/6542d30af62faec5b30661c901fb7f80589f8c25","head":{"label":"scottcorgan:master","ref":"master","sha":"6542d30af62faec5b30661c901fb7f80589f8c25","user":{"login":"scottcorgan","id":974723,"avatar_url":"https://avatars3.githubusercontent.com/u/974723?v=4","gravatar_id":"","url":"https://api.github.com/users/scottcorgan","html_url":"https://github.com/scottcorgan","followers_url":"https://api.github.com/users/scottcorgan/followers","following_url":"https://api.github.com/users/scottcorgan/following{/other_user}","gists_url":"https://api.github.com/users/scottcorgan/gists{/gist_id}","starred_url":"https://api.github.com/users/scottcorgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottcorgan/subscriptions","organizations_url":"https://api.github.com/users/scottcorgan/orgs","repos_url":"https://api.github.com/users/scottcorgan/repos","events_url":"https://api.github.com/users/scottcorgan/events{/privacy}","received_events_url":"https://api.github.com/users/scottcorgan/received_events","type":"User","site_admin":false},"repo":{"id":100638453,"name":"suiter","full_name":"scottcorgan/suiter","owner":{"login":"scottcorgan","id":974723,"avatar_url":"https://avatars3.githubusercontent.com/u/974723?v=4","gravatar_id":"","url":"https://api.github.com/users/scottcorgan","html_url":"https://github.com/scottcorgan","followers_url":"https://api.github.com/users/scottcorgan/followers","following_url":"https://api.github.com/users/scottcorgan/following{/other_user}","gists_url":"https://api.github.com/users/scottcorgan/gists{/gist_id}","starred_url":"https://api.github.com/users/scottcorgan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottcorgan/subscriptions","organizations_url":"https://api.github.com/users/scottcorgan/orgs","repos_url":"https://api.github.com/users/scottcorgan/repos","events_url":"https://api.github.com/users/scottcorgan/events{/privacy}","received_events_url":"https://api.github.com/users/scottcorgan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scottcorgan/suiter","description":"Simple and powerful responsive queries","fork":true,"url":"https://api.github.com/repos/scottcorgan/suiter","forks_url":"https://api.github.com/repos/scottcorgan/suiter/forks","keys_url":"https://api.github.com/repos/scottcorgan/suiter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scottcorgan/suiter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scottcorgan/suiter/teams","hooks_url":"https://api.github.com/repos/scottcorgan/suiter/hooks","issue_events_url":"https://api.github.com/repos/scottcorgan/suiter/issues/events{/number}","events_url":"https://api.github.com/repos/scottcorgan/suiter/events","assignees_url":"https://api.github.com/repos/scottcorgan/suiter/assignees{/user}","branches_url":"https://api.github.com/repos/scottcorgan/suiter/branches{/branch}","tags_url":"https://api.github.com/repos/scottcorgan/suiter/tags","blobs_url":"https://api.github.com/repos/scottcorgan/suiter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scottcorgan/suiter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scottcorgan/suiter/git/refs{/sha}","trees_url":"https://api.github.com/repos/scottcorgan/suiter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scottcorgan/suiter/statuses/{sha}","languages_url":"https://api.github.com/repos/scottcorgan/suiter/languages","stargazers_url":"https://api.github.com/repos/scottcorgan/suiter/stargazers","contributors_url":"https://api.github.com/repos/scottcorgan/suiter/contributors","subscribers_url":"https://api.github.com/repos/scottcorgan/suiter/subscribers","subscription_url":"https://api.github.com/repos/scottcorgan/suiter/subscription","commits_url":"https://api.github.com/repos/scottcorgan/suiter/commits{/sha}","git_commits_url":"https://api.github.com/repos/scottcorgan/suiter/git/commits{/sha}","comments_url":"https://api.github.com/repos/scottcorgan/suiter/comments{/number}","issue_comment_url":"https://api.github.com/repos/scottcorgan/suiter/issues/comments{/number}","contents_url":"https://api.github.com/repos/scottcorgan/suiter/contents/{+path}","compare_url":"https://api.github.com/repos/scottcorgan/suiter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scottcorgan/suiter/merges","archive_url":"https://api.github.com/repos/scottcorgan/suiter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scottcorgan/suiter/downloads","issues_url":"https://api.github.com/repos/scottcorgan/suiter/issues{/number}","pulls_url":"https://api.github.com/repos/scottcorgan/suiter/pulls{/number}","milestones_url":"https://api.github.com/repos/scottcorgan/suiter/milestones{/number}","notifications_url":"https://api.github.com/repos/scottcorgan/suiter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scottcorgan/suiter/labels{/name}","releases_url":"https://api.github.com/repos/scottcorgan/suiter/releases{/id}","deployments_url":"https://api.github.com/repos/scottcorgan/suiter/deployments","created_at":"2017-08-17T19:32:20Z","updated_at":"2017-08-17T19:32:21Z","pushed_at":"2017-08-17T21:38:23Z","git_url":"git://github.com/scottcorgan/suiter.git","ssh_url":"git@github.com:scottcorgan/suiter.git","clone_url":"https://github.com/scottcorgan/suiter.git","svn_url":"https://github.com/scottcorgan/suiter","homepage":null,"size":40,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"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":"shanebo:master","ref":"master","sha":"c2d6dcaf444faab8eebc4651dfd08731a5b7f98f","user":{"login":"shanebo","id":5044,"avatar_url":"https://avatars3.githubusercontent.com/u/5044?v=4","gravatar_id":"","url":"https://api.github.com/users/shanebo","html_url":"https://github.com/shanebo","followers_url":"https://api.github.com/users/shanebo/followers","following_url":"https://api.github.com/users/shanebo/following{/other_user}","gists_url":"https://api.github.com/users/shanebo/gists{/gist_id}","starred_url":"https://api.github.com/users/shanebo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shanebo/subscriptions","organizations_url":"https://api.github.com/users/shanebo/orgs","repos_url":"https://api.github.com/users/shanebo/repos","events_url":"https://api.github.com/users/shanebo/events{/privacy}","received_events_url":"https://api.github.com/users/shanebo/received_events","type":"User","site_admin":false},"repo":{"id":100396843,"name":"suiter","full_name":"shanebo/suiter","owner":{"login":"shanebo","id":5044,"avatar_url":"https://avatars3.githubusercontent.com/u/5044?v=4","gravatar_id":"","url":"https://api.github.com/users/shanebo","html_url":"https://github.com/shanebo","followers_url":"https://api.github.com/users/shanebo/followers","following_url":"https://api.github.com/users/shanebo/following{/other_user}","gists_url":"https://api.github.com/users/shanebo/gists{/gist_id}","starred_url":"https://api.github.com/users/shanebo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shanebo/subscriptions","organizations_url":"https://api.github.com/users/shanebo/orgs","repos_url":"https://api.github.com/users/shanebo/repos","events_url":"https://api.github.com/users/shanebo/events{/privacy}","received_events_url":"https://api.github.com/users/shanebo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/shanebo/suiter","description":"Simple and powerful responsive queries","fork":false,"url":"https://api.github.com/repos/shanebo/suiter","forks_url":"https://api.github.com/repos/shanebo/suiter/forks","keys_url":"https://api.github.com/repos/shanebo/suiter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/shanebo/suiter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/shanebo/suiter/teams","hooks_url":"https://api.github.com/repos/shanebo/suiter/hooks","issue_events_url":"https://api.github.com/repos/shanebo/suiter/issues/events{/number}","events_url":"https://api.github.com/repos/shanebo/suiter/events","assignees_url":"https://api.github.com/repos/shanebo/suiter/assignees{/user}","branches_url":"https://api.github.com/repos/shanebo/suiter/branches{/branch}","tags_url":"https://api.github.com/repos/shanebo/suiter/tags","blobs_url":"https://api.github.com/repos/shanebo/suiter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/shanebo/suiter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/shanebo/suiter/git/refs{/sha}","trees_url":"https://api.github.com/repos/shanebo/suiter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/shanebo/suiter/statuses/{sha}","languages_url":"https://api.github.com/repos/shanebo/suiter/languages","stargazers_url":"https://api.github.com/repos/shanebo/suiter/stargazers","contributors_url":"https://api.github.com/repos/shanebo/suiter/contributors","subscribers_url":"https://api.github.com/repos/shanebo/suiter/subscribers","subscription_url":"https://api.github.com/repos/shanebo/suiter/subscription","commits_url":"https://api.github.com/repos/shanebo/suiter/commits{/sha}","git_commits_url":"https://api.github.com/repos/shanebo/suiter/git/commits{/sha}","comments_url":"https://api.github.com/repos/shanebo/suiter/comments{/number}","issue_comment_url":"https://api.github.com/repos/shanebo/suiter/issues/comments{/number}","contents_url":"https://api.github.com/repos/shanebo/suiter/contents/{+path}","compare_url":"https://api.github.com/repos/shanebo/suiter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/shanebo/suiter/merges","archive_url":"https://api.github.com/repos/shanebo/suiter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/shanebo/suiter/downloads","issues_url":"https://api.github.com/repos/shanebo/suiter/issues{/number}","pulls_url":"https://api.github.com/repos/shanebo/suiter/pulls{/number}","milestones_url":"https://api.github.com/repos/shanebo/suiter/milestones{/number}","notifications_url":"https://api.github.com/repos/shanebo/suiter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/shanebo/suiter/labels{/name}","releases_url":"https://api.github.com/repos/shanebo/suiter/releases{/id}","deployments_url":"https://api.github.com/repos/shanebo/suiter/deployments","created_at":"2017-08-15T16:26:02Z","updated_at":"2017-08-15T16:29:18Z","pushed_at":"2017-08-17T21:39:47Z","git_url":"git://github.com/shanebo/suiter.git","ssh_url":"git@github.com:shanebo/suiter.git","clone_url":"https://github.com/shanebo/suiter.git","svn_url":"https://github.com/shanebo/suiter","homepage":null,"size":1,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/shanebo/suiter/pulls/3"},"html":{"href":"https://github.com/shanebo/suiter/pull/3"},"issue":{"href":"https://api.github.com/repos/shanebo/suiter/issues/3"},"comments":{"href":"https://api.github.com/repos/shanebo/suiter/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/shanebo/suiter/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/shanebo/suiter/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/shanebo/suiter/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/shanebo/suiter/statuses/6542d30af62faec5b30661c901fb7f80589f8c25"}}}}
{"actor":{"display_login":"shanebo"}}