{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/34447740","id":34447740,"diff_hunk":"@@ -0,0 +1,487 @@\n+/* global ContactsButtons, LazyLoader, utils, WebrtcClient */\n+/* global Normalizer, ContactPhotoHelper */\n+/* global TAG_OPTIONS */\n+\n+/* exported DetailsUI */\n+\n+/**\n+ * Handles each interaction between the user and the UI of this view.\n+ */\n+(function(exports) {\n+  'use strict';\n+\n+  const PHOTO_POS = 7;\n+  const INIT_MARGIN = 8;\n+  const MAX_POSITION = 150;\n+  // Scale ratio for different devices\n+  var SCALE_RATIO = window.devicePixelRatio || 1;\n+\n+  var DetailsUI = {\n+    init: function() {\n+      var self = this;\n+      function initContainers() {\n+        self._ = navigator.mozL10n.get;\n+        self.header = document.querySelector('#details-view-header');\n+        self.contactDetails = document.querySelector('#contact-detail');\n+        self.listContainer = document.querySelector('#details-list');\n+        self.detailsName = document.querySelector('#contact-name-title');\n+        self.detailsNameText =\n+          document.querySelector('#contact-name-title bdi');\n+        self.orgTitle = document.querySelector('#org-title');\n+        self.datesTemplate = document.querySelector('#dates-template-\\\\#i\\\\#');\n+        self.addressesTemplate =\n+          document.querySelector('#address-details-template-\\\\#i\\\\#');\n+        self.duplicateTemplate =\n+          document.querySelector('#duplicate-contacts-template');\n+        self.editContactButton = document.querySelector('#edit-contact-button');\n+        self.cover = document.querySelector('#cover-img');\n+        self.detailsInner = document.querySelector('#contact-detail-inner');\n+        self.favoriteMessage = document.querySelector('#toggle-favorite');\n+        self.notesTemplate =\n+          document.querySelector('#note-details-template-\\\\#i\\\\#');\n+        self.socialTemplate =\n+          document.querySelector('#social-template-\\\\#i\\\\#');\n+      }\n+\n+      function addListeners() {\n+        self.initPullEffect(self.cover);\n+\n+        self.favoriteMessage.addEventListener('click',\n+          self.toggleFavorite.bind(self));\n+\n+        self.header.addEventListener('action',\n+          self.handleBackAction.bind(self));\n+        self.editContactButton.addEventListener('click',\n+          self.handleEditAction.bind(self));\n+\n+        ContactsButtons.init(self.listContainer, self.contactDetails, null);\n+\n+        window.addEventListener('toggleFavoriteDone',\n+          self.toggleFavoriteHandler.bind(self));\n+      }\n+\n+      initContainers();\n+      addListeners();\n+    },\n+\n+    handleBackAction: function(evt) {\n+      this.dispatchEvent('backAction');\n+    },\n+\n+    handleEditAction: function(evt) {\n+      this.dispatchEvent('editAction');\n+    },\n+\n+    initPullEffect: function(cover) {\n+      var maxPosition = Math.round(MAX_POSITION * SCALE_RATIO);\n+      var startPosition = 0;\n+      var self = this;\n+\n+      function onTouchStart(e) {\n+        if (self.contactDetails.classList.contains('no-photo')) {\n+          return;\n+        }\n+        e.preventDefault();\n+        startPosition = e.changedTouches[0].clientY;\n+\n+        self.contactDetails.classList.add('up');\n+        cover.classList.add('up');\n+\n+        window.addEventListener('touchmove', onTouchMove, true);\n+        window.addEventListener('touchend', onTouchEnd, true);\n+      }\n+\n+      function onTouchEnd(e) {\n+        e.preventDefault();\n+\n+        self.contactDetails.style.transform = null;\n+        self.contactDetails.classList.add('up');\n+\n+        cover.style.transform = null;\n+        cover.classList.add('up');\n+\n+        window.removeEventListener('touchmove', onTouchMove, true);\n+        window.removeEventListener('touchend', onTouchEnd, true);\n+      }\n+\n+      function onTouchMove(e) {\n+        e.preventDefault();\n+\n+        var deltaY = e.changedTouches[0].clientY - startPosition;\n+        deltaY = Math.min(maxPosition, Math.max(0, deltaY));\n+\n+        var calc = 'calc(' + INIT_MARGIN + 'rem + ' + deltaY + 'px)';\n+        self.contactDetails.style.transform = 'translateY(' + calc + ')';\n+        self.contactDetails.classList.remove('up');\n+\n+        // Divide by 40 (4 times slower and in rems)\n+        var coverPosition = (-PHOTO_POS + (deltaY / 40)) + 'rem';\n+        cover.style.transform = 'translateY(' + coverPosition + ')';\n+        cover.classList.remove('up');\n+      }\n+\n+      cover.addEventListener('touchstart', onTouchStart, true);\n+    },\n+\n+    render: function(currentContact, contactsCount, readOnly) {\n+      if(this.isAFavoriteChange){\n+        this.isAFavoriteChange = false;\n+        return Promise.resolve(this.isAFavoriteChange);\n+      }\n+\n+      this.dispatchEvent('renderinit');\n+\n+      this.contactData = currentContact;\n+      this.contactsCount = contactsCount;\n+\n+      // Initially enabled and only disabled if necessary\n+      this.editContactButton.removeAttribute('disabled');\n+      this.editContactButton.classList.remove('hide');\n+      this.header.setAttribute('action', 'back');\n+\n+      if (readOnly) {\n+        this.editContactButton.classList.add('hide');\n+        this.header.setAttribute('action', 'close');\n+      }\n+\n+      this.doReloadContactDetails(this.contactData);\n+    },\n+\n+    doReloadContactDetails: function(contact) {\n+      this.setUpDisplayName(contact);\n+      this.contactDetails.classList.remove('no-photo');\n+      this.contactDetails.classList.remove('up');\n+      utils.dom.removeChildNodes(this.listContainer);\n+\n+      this.renderFavorite(contact);\n+      this.renderOrg(contact);\n+\n+      ContactsButtons.renderPhones(contact);\n+      ContactsButtons.renderEmails(contact);\n+\n+      this.renderWebrtcClient(contact);\n+\n+      this.renderAddresses(contact);\n+\n+      this.renderDates(contact);\n+\n+      this.renderNotes(contact);\n+\n+      this.renderShareButton(contact);\n+\n+      this.renderDuplicate(contact);\n+\n+      this.renderPhoto(contact);\n+\n+      this.dispatchEvent('renderdone');\n+    },\n+\n+    setUpDisplayName: function(contact) {","path":"apps/communications/contacts/views/details/js/details_ui.js","position":179,"original_position":179,"commit_id":"132244352ebb0984cfb6597838bfa8bd25c17fa8","original_commit_id":"132244352ebb0984cfb6597838bfa8bd25c17fa8","user":{"login":"arcturus","id":60801,"avatar_url":"https://avatars.githubusercontent.com/u/60801?v=3","gravatar_id":"","url":"https://api.github.com/users/arcturus","html_url":"https://github.com/arcturus","followers_url":"https://api.github.com/users/arcturus/followers","following_url":"https://api.github.com/users/arcturus/following{/other_user}","gists_url":"https://api.github.com/users/arcturus/gists{/gist_id}","starred_url":"https://api.github.com/users/arcturus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcturus/subscriptions","organizations_url":"https://api.github.com/users/arcturus/orgs","repos_url":"https://api.github.com/users/arcturus/repos","events_url":"https://api.github.com/users/arcturus/events{/privacy}","received_events_url":"https://api.github.com/users/arcturus/received_events","type":"User","site_admin":false},"body":"nit: `setupDisplayName`","created_at":"2015-07-13T09:50:48Z","updated_at":"2015-07-13T09:50:48Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/30750#discussion_r34447740","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/34447740"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/30750#discussion_r34447740"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750","id":38853451,"html_url":"https://github.com/mozilla-b2g/gaia/pull/30750","diff_url":"https://github.com/mozilla-b2g/gaia/pull/30750.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/30750.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30750","number":30750,"state":"open","locked":false,"title":"Contacts #open activity in a separate html","user":{"login":"mancas","id":2591048,"avatar_url":"https://avatars.githubusercontent.com/u/2591048?v=3","gravatar_id":"","url":"https://api.github.com/users/mancas","html_url":"https://github.com/mancas","followers_url":"https://api.github.com/users/mancas/followers","following_url":"https://api.github.com/users/mancas/following{/other_user}","gists_url":"https://api.github.com/users/mancas/gists{/gist_id}","starred_url":"https://api.github.com/users/mancas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mancas/subscriptions","organizations_url":"https://api.github.com/users/mancas/orgs","repos_url":"https://api.github.com/users/mancas/repos","events_url":"https://api.github.com/users/mancas/events{/privacy}","received_events_url":"https://api.github.com/users/mancas/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-30T08:30:02Z","updated_at":"2015-07-13T09:50:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bfb49957f1cfbcd7d99fcffc3479793b87904b87","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30750/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/132244352ebb0984cfb6597838bfa8bd25c17fa8","head":{"label":"mancas:bug1178646","ref":"bug1178646","sha":"132244352ebb0984cfb6597838bfa8bd25c17fa8","user":{"login":"mancas","id":2591048,"avatar_url":"https://avatars.githubusercontent.com/u/2591048?v=3","gravatar_id":"","url":"https://api.github.com/users/mancas","html_url":"https://github.com/mancas","followers_url":"https://api.github.com/users/mancas/followers","following_url":"https://api.github.com/users/mancas/following{/other_user}","gists_url":"https://api.github.com/users/mancas/gists{/gist_id}","starred_url":"https://api.github.com/users/mancas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mancas/subscriptions","organizations_url":"https://api.github.com/users/mancas/orgs","repos_url":"https://api.github.com/users/mancas/repos","events_url":"https://api.github.com/users/mancas/events{/privacy}","received_events_url":"https://api.github.com/users/mancas/received_events","type":"User","site_admin":false},"repo":{"id":21567415,"name":"gaia","full_name":"mancas/gaia","owner":{"login":"mancas","id":2591048,"avatar_url":"https://avatars.githubusercontent.com/u/2591048?v=3","gravatar_id":"","url":"https://api.github.com/users/mancas","html_url":"https://github.com/mancas","followers_url":"https://api.github.com/users/mancas/followers","following_url":"https://api.github.com/users/mancas/following{/other_user}","gists_url":"https://api.github.com/users/mancas/gists{/gist_id}","starred_url":"https://api.github.com/users/mancas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mancas/subscriptions","organizations_url":"https://api.github.com/users/mancas/orgs","repos_url":"https://api.github.com/users/mancas/repos","events_url":"https://api.github.com/users/mancas/events{/privacy}","received_events_url":"https://api.github.com/users/mancas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mancas/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":true,"url":"https://api.github.com/repos/mancas/gaia","forks_url":"https://api.github.com/repos/mancas/gaia/forks","keys_url":"https://api.github.com/repos/mancas/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mancas/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mancas/gaia/teams","hooks_url":"https://api.github.com/repos/mancas/gaia/hooks","issue_events_url":"https://api.github.com/repos/mancas/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mancas/gaia/events","assignees_url":"https://api.github.com/repos/mancas/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mancas/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mancas/gaia/tags","blobs_url":"https://api.github.com/repos/mancas/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mancas/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mancas/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mancas/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mancas/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mancas/gaia/languages","stargazers_url":"https://api.github.com/repos/mancas/gaia/stargazers","contributors_url":"https://api.github.com/repos/mancas/gaia/contributors","subscribers_url":"https://api.github.com/repos/mancas/gaia/subscribers","subscription_url":"https://api.github.com/repos/mancas/gaia/subscription","commits_url":"https://api.github.com/repos/mancas/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mancas/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mancas/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mancas/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mancas/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mancas/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mancas/gaia/merges","archive_url":"https://api.github.com/repos/mancas/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mancas/gaia/downloads","issues_url":"https://api.github.com/repos/mancas/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mancas/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mancas/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mancas/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mancas/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mancas/gaia/releases{/id}","created_at":"2014-07-07T10:56:55Z","updated_at":"2015-01-19T09:24:10Z","pushed_at":"2015-07-13T07:09:30Z","git_url":"git://github.com/mancas/gaia.git","ssh_url":"git@github.com:mancas/gaia.git","clone_url":"https://github.com/mancas/gaia.git","svn_url":"https://github.com/mancas/gaia","homepage":"https://wiki.mozilla.org/B2G","size":937200,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla-b2g:master","ref":"master","sha":"167a22b2fcba06f9d09472bbaadd877252ef709a","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","created_at":"2011-09-03T01:38:46Z","updated_at":"2015-07-12T01:46:24Z","pushed_at":"2015-07-13T09:39:33Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1648580,"stargazers_count":1952,"watchers_count":1952,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2373,"mirror_url":null,"open_issues_count":1076,"forks":2373,"open_issues":1076,"watchers":1952,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/30750"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30750"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/30750/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/30750/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/132244352ebb0984cfb6597838bfa8bd25c17fa8"}}}}