{"action":"created","comment":{"url":"https://api.github.com/repos/clio/lib-themisui/pulls/comments/51766121","id":51766121,"diff_hunk":"@@ -27,36 +10,67 @@ angular.module('ThemisComponents')\n       options: \"=\"\n       ngModel: \"=\"\n       name: \"@\"\n-      disabled: \"@\"\n-      ngChange: \"=?\"\n-\n-    controller: ($scope, $element) ->\n-      @selectedText = @ngModel?.name ? \"Choose…\"\n-\n-      $element.find(\"select\").on 'click', (event) -> return\n-      # when a new option is selected we want to capture the name\n-      # and add it to our styled select replacement.\n-      $element.on 'change', (event) =>\n-        $scope.$apply =>\n-          @selectedText = event.target.selectedOptions[0].text\n+      ngDisabled: \"=\"\n+      ngChange: \"&\"\n+      ngRequired: \"=\"\n+      placeholder: \"@\"\n+\n+    controller: ($scope, $element, $attrs, $transclude) ->\n+      @selectedText = @placeholder\n+      @selectedText = @ngModel.name if @ngModel?\n+      @options ?= []\n+\n+      isSelected = (el) -> el.hasAttribute \"selected\"\n+\n+      isOptionElement = (el) -> el.tagName is \"OPTION\"\n+\n+      # Add transcluded Option element to the @options array.\n+      angular.forEach $transclude(), (el) =>\n+\n+        if el.tagName is \"OPTGROUP\"\n+          groupName = el.label\n+          groupedOptions = angular.element(el).find \"option\"\n+\n+          angular.forEach groupedOptions, (option) =>\n+\n+            if isOptionElement option\n+              @options.push\n+                name: option.text\n+                value: option.value\n+                group: groupName\n+\n+              if isSelected option\n+                @ngModel =\n+                  name: option.text\n+                  value: option.value\n+                  group: groupName\n+\n+        if isOptionElement el\n+          @options.push {name: el.text, value: el.value}\n+\n+          if isSelected el\n+            @ngModel = {name: el.text, value: el.value}\n+\n       return\n \n-    link: (scope, element, attributes) ->\n-      # grab the initially selected option and add\n-      # it's name to our styled replacement select\n-      # this will only be applicable to if we are not\n-      # passing in an array of options so we check for that first.\n+    link: (scope, element, attributes, controller) ->\n+      # On the model change, update the select's text\n+      scope.$watch ->\n+        controller.ngModel\n+      , (newValue) ->\n+        text = newValue?.name ? controller.placeholder\n+        controller.selectedText = text\n+\n+      counter = 0","path":"themis_components/thSelect/thSelect.directive.coffee","position":98,"original_position":98,"commit_id":"bff502ca218cbd480bf36a15b1dda9791b5d67ae","original_commit_id":"bff502ca218cbd480bf36a15b1dda9791b5d67ae","user":{"login":"seanhealy","id":131327,"avatar_url":"https://avatars.githubusercontent.com/u/131327?v=3","gravatar_id":"","url":"https://api.github.com/users/seanhealy","html_url":"https://github.com/seanhealy","followers_url":"https://api.github.com/users/seanhealy/followers","following_url":"https://api.github.com/users/seanhealy/following{/other_user}","gists_url":"https://api.github.com/users/seanhealy/gists{/gist_id}","starred_url":"https://api.github.com/users/seanhealy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seanhealy/subscriptions","organizations_url":"https://api.github.com/users/seanhealy/orgs","repos_url":"https://api.github.com/users/seanhealy/repos","events_url":"https://api.github.com/users/seanhealy/events{/privacy}","received_events_url":"https://api.github.com/users/seanhealy/received_events","type":"User","site_admin":false},"body":"We could give this a bit better of a name say, `selectedElementCount`.","created_at":"2016-02-03T18:39:17Z","updated_at":"2016-02-03T18:39:17Z","html_url":"https://github.com/clio/lib-themisui/pull/80#discussion_r51766121","pull_request_url":"https://api.github.com/repos/clio/lib-themisui/pulls/80","_links":{"self":{"href":"https://api.github.com/repos/clio/lib-themisui/pulls/comments/51766121"},"html":{"href":"https://github.com/clio/lib-themisui/pull/80#discussion_r51766121"},"pull_request":{"href":"https://api.github.com/repos/clio/lib-themisui/pulls/80"}}},"pull_request":{"url":"https://api.github.com/repos/clio/lib-themisui/pulls/80","id":55945795,"html_url":"https://github.com/clio/lib-themisui/pull/80","diff_url":"https://github.com/clio/lib-themisui/pull/80.diff","patch_url":"https://github.com/clio/lib-themisui/pull/80.patch","issue_url":"https://api.github.com/repos/clio/lib-themisui/issues/80","number":80,"state":"open","locked":false,"title":"Allow model changes to be reflected in the view.","user":{"login":"JefCurtis","id":3892972,"avatar_url":"https://avatars.githubusercontent.com/u/3892972?v=3","gravatar_id":"","url":"https://api.github.com/users/JefCurtis","html_url":"https://github.com/JefCurtis","followers_url":"https://api.github.com/users/JefCurtis/followers","following_url":"https://api.github.com/users/JefCurtis/following{/other_user}","gists_url":"https://api.github.com/users/JefCurtis/gists{/gist_id}","starred_url":"https://api.github.com/users/JefCurtis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JefCurtis/subscriptions","organizations_url":"https://api.github.com/users/JefCurtis/orgs","repos_url":"https://api.github.com/users/JefCurtis/repos","events_url":"https://api.github.com/users/JefCurtis/events{/privacy}","received_events_url":"https://api.github.com/users/JefCurtis/received_events","type":"User","site_admin":false},"body":"- Fix for ng-disabled\r\n- As well as styling for ng-disable\r\n- Update to readme\r\n- Add a disabled example","created_at":"2016-01-13T19:46:22Z","updated_at":"2016-02-03T18:39:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f1a021e13c9e6697b91f387bbcb291b1a2725b55","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/clio/lib-themisui/pulls/80/commits","review_comments_url":"https://api.github.com/repos/clio/lib-themisui/pulls/80/comments","review_comment_url":"https://api.github.com/repos/clio/lib-themisui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clio/lib-themisui/issues/80/comments","statuses_url":"https://api.github.com/repos/clio/lib-themisui/statuses/bff502ca218cbd480bf36a15b1dda9791b5d67ae","head":{"label":"JefCurtis:clio-29838-thselect-update","ref":"clio-29838-thselect-update","sha":"bff502ca218cbd480bf36a15b1dda9791b5d67ae","user":{"login":"JefCurtis","id":3892972,"avatar_url":"https://avatars.githubusercontent.com/u/3892972?v=3","gravatar_id":"","url":"https://api.github.com/users/JefCurtis","html_url":"https://github.com/JefCurtis","followers_url":"https://api.github.com/users/JefCurtis/followers","following_url":"https://api.github.com/users/JefCurtis/following{/other_user}","gists_url":"https://api.github.com/users/JefCurtis/gists{/gist_id}","starred_url":"https://api.github.com/users/JefCurtis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JefCurtis/subscriptions","organizations_url":"https://api.github.com/users/JefCurtis/orgs","repos_url":"https://api.github.com/users/JefCurtis/repos","events_url":"https://api.github.com/users/JefCurtis/events{/privacy}","received_events_url":"https://api.github.com/users/JefCurtis/received_events","type":"User","site_admin":false},"repo":{"id":41321568,"name":"lib-themisui","full_name":"JefCurtis/lib-themisui","owner":{"login":"JefCurtis","id":3892972,"avatar_url":"https://avatars.githubusercontent.com/u/3892972?v=3","gravatar_id":"","url":"https://api.github.com/users/JefCurtis","html_url":"https://github.com/JefCurtis","followers_url":"https://api.github.com/users/JefCurtis/followers","following_url":"https://api.github.com/users/JefCurtis/following{/other_user}","gists_url":"https://api.github.com/users/JefCurtis/gists{/gist_id}","starred_url":"https://api.github.com/users/JefCurtis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JefCurtis/subscriptions","organizations_url":"https://api.github.com/users/JefCurtis/orgs","repos_url":"https://api.github.com/users/JefCurtis/repos","events_url":"https://api.github.com/users/JefCurtis/events{/privacy}","received_events_url":"https://api.github.com/users/JefCurtis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JefCurtis/lib-themisui","description":"","fork":true,"url":"https://api.github.com/repos/JefCurtis/lib-themisui","forks_url":"https://api.github.com/repos/JefCurtis/lib-themisui/forks","keys_url":"https://api.github.com/repos/JefCurtis/lib-themisui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JefCurtis/lib-themisui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JefCurtis/lib-themisui/teams","hooks_url":"https://api.github.com/repos/JefCurtis/lib-themisui/hooks","issue_events_url":"https://api.github.com/repos/JefCurtis/lib-themisui/issues/events{/number}","events_url":"https://api.github.com/repos/JefCurtis/lib-themisui/events","assignees_url":"https://api.github.com/repos/JefCurtis/lib-themisui/assignees{/user}","branches_url":"https://api.github.com/repos/JefCurtis/lib-themisui/branches{/branch}","tags_url":"https://api.github.com/repos/JefCurtis/lib-themisui/tags","blobs_url":"https://api.github.com/repos/JefCurtis/lib-themisui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JefCurtis/lib-themisui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JefCurtis/lib-themisui/git/refs{/sha}","trees_url":"https://api.github.com/repos/JefCurtis/lib-themisui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JefCurtis/lib-themisui/statuses/{sha}","languages_url":"https://api.github.com/repos/JefCurtis/lib-themisui/languages","stargazers_url":"https://api.github.com/repos/JefCurtis/lib-themisui/stargazers","contributors_url":"https://api.github.com/repos/JefCurtis/lib-themisui/contributors","subscribers_url":"https://api.github.com/repos/JefCurtis/lib-themisui/subscribers","subscription_url":"https://api.github.com/repos/JefCurtis/lib-themisui/subscription","commits_url":"https://api.github.com/repos/JefCurtis/lib-themisui/commits{/sha}","git_commits_url":"https://api.github.com/repos/JefCurtis/lib-themisui/git/commits{/sha}","comments_url":"https://api.github.com/repos/JefCurtis/lib-themisui/comments{/number}","issue_comment_url":"https://api.github.com/repos/JefCurtis/lib-themisui/issues/comments{/number}","contents_url":"https://api.github.com/repos/JefCurtis/lib-themisui/contents/{+path}","compare_url":"https://api.github.com/repos/JefCurtis/lib-themisui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JefCurtis/lib-themisui/merges","archive_url":"https://api.github.com/repos/JefCurtis/lib-themisui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JefCurtis/lib-themisui/downloads","issues_url":"https://api.github.com/repos/JefCurtis/lib-themisui/issues{/number}","pulls_url":"https://api.github.com/repos/JefCurtis/lib-themisui/pulls{/number}","milestones_url":"https://api.github.com/repos/JefCurtis/lib-themisui/milestones{/number}","notifications_url":"https://api.github.com/repos/JefCurtis/lib-themisui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JefCurtis/lib-themisui/labels{/name}","releases_url":"https://api.github.com/repos/JefCurtis/lib-themisui/releases{/id}","deployments_url":"https://api.github.com/repos/JefCurtis/lib-themisui/deployments","created_at":"2015-08-24T19:03:40Z","updated_at":"2016-02-02T03:42:52Z","pushed_at":"2016-02-03T07:00:31Z","git_url":"git://github.com/JefCurtis/lib-themisui.git","ssh_url":"git@github.com:JefCurtis/lib-themisui.git","clone_url":"https://github.com/JefCurtis/lib-themisui.git","svn_url":"https://github.com/JefCurtis/lib-themisui","homepage":null,"size":888,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"clio:master","ref":"master","sha":"8bfa9e1092f324e0db37d309540299dd8d21c0f0","user":{"login":"clio","id":30769,"avatar_url":"https://avatars.githubusercontent.com/u/30769?v=3","gravatar_id":"","url":"https://api.github.com/users/clio","html_url":"https://github.com/clio","followers_url":"https://api.github.com/users/clio/followers","following_url":"https://api.github.com/users/clio/following{/other_user}","gists_url":"https://api.github.com/users/clio/gists{/gist_id}","starred_url":"https://api.github.com/users/clio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clio/subscriptions","organizations_url":"https://api.github.com/users/clio/orgs","repos_url":"https://api.github.com/users/clio/repos","events_url":"https://api.github.com/users/clio/events{/privacy}","received_events_url":"https://api.github.com/users/clio/received_events","type":"Organization","site_admin":false},"repo":{"id":32031641,"name":"lib-themisui","full_name":"clio/lib-themisui","owner":{"login":"clio","id":30769,"avatar_url":"https://avatars.githubusercontent.com/u/30769?v=3","gravatar_id":"","url":"https://api.github.com/users/clio","html_url":"https://github.com/clio","followers_url":"https://api.github.com/users/clio/followers","following_url":"https://api.github.com/users/clio/following{/other_user}","gists_url":"https://api.github.com/users/clio/gists{/gist_id}","starred_url":"https://api.github.com/users/clio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clio/subscriptions","organizations_url":"https://api.github.com/users/clio/orgs","repos_url":"https://api.github.com/users/clio/repos","events_url":"https://api.github.com/users/clio/events{/privacy}","received_events_url":"https://api.github.com/users/clio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clio/lib-themisui","description":"","fork":false,"url":"https://api.github.com/repos/clio/lib-themisui","forks_url":"https://api.github.com/repos/clio/lib-themisui/forks","keys_url":"https://api.github.com/repos/clio/lib-themisui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clio/lib-themisui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clio/lib-themisui/teams","hooks_url":"https://api.github.com/repos/clio/lib-themisui/hooks","issue_events_url":"https://api.github.com/repos/clio/lib-themisui/issues/events{/number}","events_url":"https://api.github.com/repos/clio/lib-themisui/events","assignees_url":"https://api.github.com/repos/clio/lib-themisui/assignees{/user}","branches_url":"https://api.github.com/repos/clio/lib-themisui/branches{/branch}","tags_url":"https://api.github.com/repos/clio/lib-themisui/tags","blobs_url":"https://api.github.com/repos/clio/lib-themisui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clio/lib-themisui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clio/lib-themisui/git/refs{/sha}","trees_url":"https://api.github.com/repos/clio/lib-themisui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clio/lib-themisui/statuses/{sha}","languages_url":"https://api.github.com/repos/clio/lib-themisui/languages","stargazers_url":"https://api.github.com/repos/clio/lib-themisui/stargazers","contributors_url":"https://api.github.com/repos/clio/lib-themisui/contributors","subscribers_url":"https://api.github.com/repos/clio/lib-themisui/subscribers","subscription_url":"https://api.github.com/repos/clio/lib-themisui/subscription","commits_url":"https://api.github.com/repos/clio/lib-themisui/commits{/sha}","git_commits_url":"https://api.github.com/repos/clio/lib-themisui/git/commits{/sha}","comments_url":"https://api.github.com/repos/clio/lib-themisui/comments{/number}","issue_comment_url":"https://api.github.com/repos/clio/lib-themisui/issues/comments{/number}","contents_url":"https://api.github.com/repos/clio/lib-themisui/contents/{+path}","compare_url":"https://api.github.com/repos/clio/lib-themisui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clio/lib-themisui/merges","archive_url":"https://api.github.com/repos/clio/lib-themisui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clio/lib-themisui/downloads","issues_url":"https://api.github.com/repos/clio/lib-themisui/issues{/number}","pulls_url":"https://api.github.com/repos/clio/lib-themisui/pulls{/number}","milestones_url":"https://api.github.com/repos/clio/lib-themisui/milestones{/number}","notifications_url":"https://api.github.com/repos/clio/lib-themisui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clio/lib-themisui/labels{/name}","releases_url":"https://api.github.com/repos/clio/lib-themisui/releases{/id}","deployments_url":"https://api.github.com/repos/clio/lib-themisui/deployments","created_at":"2015-03-11T17:32:40Z","updated_at":"2016-01-15T22:27:00Z","pushed_at":"2016-02-03T18:26:31Z","git_url":"git://github.com/clio/lib-themisui.git","ssh_url":"git@github.com:clio/lib-themisui.git","clone_url":"https://github.com/clio/lib-themisui.git","svn_url":"https://github.com/clio/lib-themisui","homepage":null,"size":944,"stargazers_count":1,"watchers_count":1,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":6,"forks":8,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clio/lib-themisui/pulls/80"},"html":{"href":"https://github.com/clio/lib-themisui/pull/80"},"issue":{"href":"https://api.github.com/repos/clio/lib-themisui/issues/80"},"comments":{"href":"https://api.github.com/repos/clio/lib-themisui/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/clio/lib-themisui/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/clio/lib-themisui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clio/lib-themisui/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/clio/lib-themisui/statuses/bff502ca218cbd480bf36a15b1dda9791b5d67ae"}}}}