{"action":"created","comment":{"url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/comments/33191613","id":33191613,"diff_hunk":"@@ -160,55 +160,65 @@ TODO: remove instrinsic ratio implementation from index.html and it to the plugi\n             sizeModal();\n         },\n         \n+        /** \n+         * Returns whether a CTA can be added based on its config.\n+         */\n+        canAddCTA = function(cta) {\n+            return isValidString(cta.text)\n+                && (isValidLink(cta.link) || isValidFunction(cta.callback));\n+        },\n+        \n         /**\n         * Adds CTAs to the displayer based on player configuration.\n         */\n         addCTAs = function(ctaConfig) {\n             var i,\n-                addedCTAs = 0, // number of CTAs added to the display\n                 $ctaContainer = $detailDiv.find('.bcc-cta-container'),\n-                totalCTAs = (ctaConfig) ? ctaConfig.length : 0;\n+                totalCTAs = (ctaConfig) ? ctaConfig.length : 0,\n+                smartPhone = isSmallScreen();\n             \n             //Removes CTAs from the container before adding new ones,\n             $ctaContainer.empty();\n+            $ctaContainer.addClass(\"bcc-has-ctas\");\n                        \n             for (i = 0; i < totalCTAs; i++) {\n-             // Validates CTA configuration.             \n-             // breaks one iteration in the loop, if the condition below occurs.\n-             if (!isValidString(ctaConfig[i].text) || !(isValidLink(ctaConfig[i].link) || isValidFunction(ctaConfig[i].callback)) || ctaConfig[i].displayOnDesktop === false) {\n-                 log(\"-------- skip cta.\"); //TODO: remove when testing is done\n-                 continue;\n-             } \n-                \n-             // Adds elements and listeners.    \n-             (function(cta){\n-                 var $item;\n+                // Validates CTA configuration.             \n+                if (!canAddCTA(ctaConfig[i])) continue;\n \n-                 //Creates the div element\n-                 $item = $('<div class=\"bcc-cta-button\"></div>').html(cta.text);\n+                // Adds elements and listeners.    \n+                (function(cta){\n+                    var $item;\n \n-                 $item.on(\"click touchstart\", function(){\n-                     if (isValidFunction(cta.callback)){\n-                         cta.callback(videoConfig); \n-                     } else {\n-                         window.open(cta.link ,'_blank');\n-                     }\n-                 }); \n+                    //Creates the div element\n+                    $item = $('<div class=\"bcc-cta-button\"></div>').html(cta.text);\n+                    // unless specified, all appear on desktop\n+                    if (cta.displayOnDesktop !== false) {\n+                        $item.addClass(\"bcc-cta-desktop-show\");\n+                    }\n+                    // first appears on mobile if displayOnMobile isn't set to false;\n+                    // subsequent only appear if displayOnMobile is set to true\n+                    if ((!i && cta.displayOnMobile !== false) || cta.displayOnMobile === true) {\n+                        $item.addClass(\"bcc-cta-mobile-show\");\n+                    }\n+                    $item.on(\"click touchstart\", function(){\n+                        if (isValidFunction(cta.callback)){\n+                            cta.callback(videoConfig); \n+                        } else {\n+                            window.open(cta.link, '_blank');\n+                        }\n+                    }); \n \n-                 //Adds element to the display\n-                 $ctaContainer.append($item);\n+                    //Adds element to the display\n+                    $ctaContainer.append($item);\n \n-             }(ctaConfig[i]));\n+                }(ctaConfig[i]));\n                 \n                 // Exits loop if the number of added CTAs is greater to the max allowed.\n-                log(addedCTAs + \". Added CTA: \" +  ctaConfig[i].text); //TODO: remove when testing is done\n-                if (++addedCTAs >= CTA_MAX) break;               \n+                if ($ctaContainer.children().filter(\":visible\").length >= CTA_MAX) break;               \n             }","path":"lib/bcgs_ford_modal.js","position":83,"original_position":85,"commit_id":"502ddafe7b229d0c6e2fe1a72a9662b1fb46772a","original_commit_id":"b58b90d7985c95f2b46471fab231881ab8269ff9","user":{"login":"tyard","id":1273020,"avatar_url":"https://avatars.githubusercontent.com/u/1273020?v=3","gravatar_id":"","url":"https://api.github.com/users/tyard","html_url":"https://github.com/tyard","followers_url":"https://api.github.com/users/tyard/followers","following_url":"https://api.github.com/users/tyard/following{/other_user}","gists_url":"https://api.github.com/users/tyard/gists{/gist_id}","starred_url":"https://api.github.com/users/tyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyard/subscriptions","organizations_url":"https://api.github.com/users/tyard/orgs","repos_url":"https://api.github.com/users/tyard/repos","events_url":"https://api.github.com/users/tyard/events{/privacy}","received_events_url":"https://api.github.com/users/tyard/received_events","type":"User","site_admin":false},"body":"In the last iteration CTAs were being incorrectly added, not following the func spec and API, and I was trying to address that. In doing that I thought it was cleaner controlling what appeared and did not appear through the CSS. Again, what that allows is for logic that may or may not come up like \"on landscape tablet, display all buttons, but in portrait only display the mobile-only buttons\" and variations on that. Had to do that a lot for Met and thought I could prepare the files in a similar way here if it comes up. If it doesn't, I think controlling visibility through the CSS is still a clean way to go.","created_at":"2015-06-24T20:24:41Z","updated_at":"2015-06-24T20:24:41Z","html_url":"https://github.com/BrightcovePS/FordPlayer/pull/30#discussion_r33191613","pull_request_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/comments/33191613"},"html":{"href":"https://github.com/BrightcovePS/FordPlayer/pull/30#discussion_r33191613"},"pull_request":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30","id":38477027,"html_url":"https://github.com/BrightcovePS/FordPlayer/pull/30","diff_url":"https://github.com/BrightcovePS/FordPlayer/pull/30.diff","patch_url":"https://github.com/BrightcovePS/FordPlayer/pull/30.patch","issue_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/30","number":30,"state":"closed","locked":false,"title":"CTAs and layout on smart phones","user":{"login":"tyard","id":1273020,"avatar_url":"https://avatars.githubusercontent.com/u/1273020?v=3","gravatar_id":"","url":"https://api.github.com/users/tyard","html_url":"https://github.com/tyard","followers_url":"https://api.github.com/users/tyard/followers","following_url":"https://api.github.com/users/tyard/following{/other_user}","gists_url":"https://api.github.com/users/tyard/gists{/gist_id}","starred_url":"https://api.github.com/users/tyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tyard/subscriptions","organizations_url":"https://api.github.com/users/tyard/orgs","repos_url":"https://api.github.com/users/tyard/repos","events_url":"https://api.github.com/users/tyard/events{/privacy}","received_events_url":"https://api.github.com/users/tyard/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-24T19:16:13Z","updated_at":"2015-06-24T20:24:41Z","closed_at":"2015-06-24T20:09:32Z","merged_at":"2015-06-24T20:09:32Z","merge_commit_sha":"037ff7ebfb315a04b7618746f779e2d0b089121d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30/commits","review_comments_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30/comments","review_comment_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/30/comments","statuses_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/statuses/502ddafe7b229d0c6e2fe1a72a9662b1fb46772a","head":{"label":"BrightcovePS:bug/smartphone-sizing","ref":"bug/smartphone-sizing","sha":"502ddafe7b229d0c6e2fe1a72a9662b1fb46772a","user":{"login":"BrightcovePS","id":552419,"avatar_url":"https://avatars.githubusercontent.com/u/552419?v=3","gravatar_id":"","url":"https://api.github.com/users/BrightcovePS","html_url":"https://github.com/BrightcovePS","followers_url":"https://api.github.com/users/BrightcovePS/followers","following_url":"https://api.github.com/users/BrightcovePS/following{/other_user}","gists_url":"https://api.github.com/users/BrightcovePS/gists{/gist_id}","starred_url":"https://api.github.com/users/BrightcovePS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrightcovePS/subscriptions","organizations_url":"https://api.github.com/users/BrightcovePS/orgs","repos_url":"https://api.github.com/users/BrightcovePS/repos","events_url":"https://api.github.com/users/BrightcovePS/events{/privacy}","received_events_url":"https://api.github.com/users/BrightcovePS/received_events","type":"Organization","site_admin":false},"repo":{"id":36770895,"name":"FordPlayer","full_name":"BrightcovePS/FordPlayer","owner":{"login":"BrightcovePS","id":552419,"avatar_url":"https://avatars.githubusercontent.com/u/552419?v=3","gravatar_id":"","url":"https://api.github.com/users/BrightcovePS","html_url":"https://github.com/BrightcovePS","followers_url":"https://api.github.com/users/BrightcovePS/followers","following_url":"https://api.github.com/users/BrightcovePS/following{/other_user}","gists_url":"https://api.github.com/users/BrightcovePS/gists{/gist_id}","starred_url":"https://api.github.com/users/BrightcovePS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrightcovePS/subscriptions","organizations_url":"https://api.github.com/users/BrightcovePS/orgs","repos_url":"https://api.github.com/users/BrightcovePS/repos","events_url":"https://api.github.com/users/BrightcovePS/events{/privacy}","received_events_url":"https://api.github.com/users/BrightcovePS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BrightcovePS/FordPlayer","description":"Ford / Team Detroit custom player","fork":false,"url":"https://api.github.com/repos/BrightcovePS/FordPlayer","forks_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/forks","keys_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/teams","hooks_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/hooks","issue_events_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/events{/number}","events_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/events","assignees_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/assignees{/user}","branches_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/branches{/branch}","tags_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/tags","blobs_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/refs{/sha}","trees_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/statuses/{sha}","languages_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/languages","stargazers_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/stargazers","contributors_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/contributors","subscribers_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/subscribers","subscription_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/subscription","commits_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/commits{/sha}","git_commits_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/commits{/sha}","comments_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/comments{/number}","issue_comment_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/comments{/number}","contents_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/contents/{+path}","compare_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/merges","archive_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/downloads","issues_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues{/number}","pulls_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls{/number}","milestones_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/milestones{/number}","notifications_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/labels{/name}","releases_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/releases{/id}","created_at":"2015-06-03T00:57:35Z","updated_at":"2015-06-03T00:57:35Z","pushed_at":"2015-06-24T20:19:05Z","git_url":"git://github.com/BrightcovePS/FordPlayer.git","ssh_url":"git@github.com:BrightcovePS/FordPlayer.git","clone_url":"https://github.com/BrightcovePS/FordPlayer.git","svn_url":"https://github.com/BrightcovePS/FordPlayer","homepage":null,"size":2264,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"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":"BrightcovePS:dev","ref":"dev","sha":"e8ac89b7fe2c1c20d68e4247eba217d09f2d49df","user":{"login":"BrightcovePS","id":552419,"avatar_url":"https://avatars.githubusercontent.com/u/552419?v=3","gravatar_id":"","url":"https://api.github.com/users/BrightcovePS","html_url":"https://github.com/BrightcovePS","followers_url":"https://api.github.com/users/BrightcovePS/followers","following_url":"https://api.github.com/users/BrightcovePS/following{/other_user}","gists_url":"https://api.github.com/users/BrightcovePS/gists{/gist_id}","starred_url":"https://api.github.com/users/BrightcovePS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrightcovePS/subscriptions","organizations_url":"https://api.github.com/users/BrightcovePS/orgs","repos_url":"https://api.github.com/users/BrightcovePS/repos","events_url":"https://api.github.com/users/BrightcovePS/events{/privacy}","received_events_url":"https://api.github.com/users/BrightcovePS/received_events","type":"Organization","site_admin":false},"repo":{"id":36770895,"name":"FordPlayer","full_name":"BrightcovePS/FordPlayer","owner":{"login":"BrightcovePS","id":552419,"avatar_url":"https://avatars.githubusercontent.com/u/552419?v=3","gravatar_id":"","url":"https://api.github.com/users/BrightcovePS","html_url":"https://github.com/BrightcovePS","followers_url":"https://api.github.com/users/BrightcovePS/followers","following_url":"https://api.github.com/users/BrightcovePS/following{/other_user}","gists_url":"https://api.github.com/users/BrightcovePS/gists{/gist_id}","starred_url":"https://api.github.com/users/BrightcovePS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BrightcovePS/subscriptions","organizations_url":"https://api.github.com/users/BrightcovePS/orgs","repos_url":"https://api.github.com/users/BrightcovePS/repos","events_url":"https://api.github.com/users/BrightcovePS/events{/privacy}","received_events_url":"https://api.github.com/users/BrightcovePS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BrightcovePS/FordPlayer","description":"Ford / Team Detroit custom player","fork":false,"url":"https://api.github.com/repos/BrightcovePS/FordPlayer","forks_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/forks","keys_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/teams","hooks_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/hooks","issue_events_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/events{/number}","events_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/events","assignees_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/assignees{/user}","branches_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/branches{/branch}","tags_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/tags","blobs_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/refs{/sha}","trees_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/statuses/{sha}","languages_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/languages","stargazers_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/stargazers","contributors_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/contributors","subscribers_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/subscribers","subscription_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/subscription","commits_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/commits{/sha}","git_commits_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/git/commits{/sha}","comments_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/comments{/number}","issue_comment_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/comments{/number}","contents_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/contents/{+path}","compare_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/merges","archive_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/downloads","issues_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues{/number}","pulls_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls{/number}","milestones_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/milestones{/number}","notifications_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/labels{/name}","releases_url":"https://api.github.com/repos/BrightcovePS/FordPlayer/releases{/id}","created_at":"2015-06-03T00:57:35Z","updated_at":"2015-06-03T00:57:35Z","pushed_at":"2015-06-24T20:19:05Z","git_url":"git://github.com/BrightcovePS/FordPlayer.git","ssh_url":"git@github.com:BrightcovePS/FordPlayer.git","clone_url":"https://github.com/BrightcovePS/FordPlayer.git","svn_url":"https://github.com/BrightcovePS/FordPlayer","homepage":null,"size":2264,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30"},"html":{"href":"https://github.com/BrightcovePS/FordPlayer/pull/30"},"issue":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/30"},"comments":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/BrightcovePS/FordPlayer/statuses/502ddafe7b229d0c6e2fe1a72a9662b1fb46772a"}}}}