| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | @(article: Article, storyPackage: List[Trail])(implicit request: RequestHeader) | |
| 2 | + @import CommonSwitches.DiscussionSwitch | ||
| 2 | 3 | ||
| 3 | 4 | <h2 class="article-zone type-1"> | |
| 4 | 5 | <a class="zone-color" data-link-name="article section" href="/@article.section">@Html(article.sectionName)</a> | |
@@ -19,37 +20,50 @@ <h2 class="article-zone type-1"> | |||
| 19 | 20 | ||
| 20 | 21 | <div class="after-header"></div> | |
| 21 | 22 | ||
| 22 | - @if(!article.isLive && !article.hasVideoAtTop) { | ||
| 23 | - @article.mainPicture.map{ mainPicture => | ||
| 24 | - @article.mainPicture(width=220).map{ smallCrop => | ||
| 25 | - @fragments.img(mainPicture, smallCrop) | ||
| 26 | - } | ||
| 27 | - } | ||
| 28 | - } | ||
| 23 | + @if(!article.isLive && !article.hasVideoAtTop) { | ||
| 24 | + @article.mainPicture.map{ mainPicture => | ||
| 25 | + @article.mainPicture(width=220).map{ smallCrop => | ||
| 26 | + @fragments.img(mainPicture, smallCrop) | ||
| 27 | + } | ||
| 28 | + } | ||
| 29 | + } | ||
| 29 | 30 | ||
| 30 | - @fragments.byline(article.byline, article) | ||
| 31 | + @fragments.byline(article.byline, article) | ||
| 31 | 32 | ||
| 32 | - @if(article.isLive) { | ||
| 33 | - @fragments.autoUpdate() | ||
| 34 | - } | ||
| 33 | + <div class="article__container"> | ||
| 34 | + @if(article.isLive) { | ||
| 35 | + @fragments.autoUpdate() | ||
| 36 | + } | ||
| 35 | 37 | ||
| 36 | - <div class="article-body from-content-api @if(article.isLive) {live-blog}" | ||
| 37 | - itemprop="@if(article.isReview){reviewBody} else {articleBody}"> | ||
| 38 | - @* <!-- ordering of cleaners is important --> *@ | ||
| 39 | - @withJsoup(BulletCleaner(article.body))( | ||
| 40 | - PictureCleaner(article), | ||
| 41 | - InBodyLinkCleaner("in body link"), | ||
| 42 | - BlockNumberCleaner, | ||
| 43 | - TweetCleaner, | ||
| 44 | - WitnessCleaner, | ||
| 45 | - VideoPosterCleaner(article.videoAssets) | ||
| 46 | - ) | ||
| 38 | + <div class="article-body from-content-api @if(article.isLive) {live-blog}" | ||
| 39 | + itemprop="@if(article.isReview){reviewBody} else {articleBody}"> | ||
| 40 | + @withJsoup(BulletCleaner(article.body))( | ||
| 41 | + PictureCleaner(article), | ||
| 42 | + InBodyLinkCleaner("in body link"), | ||
| 43 | + BlockNumberCleaner, | ||
| 44 | + TweetCleaner, | ||
| 45 | + WitnessCleaner, | ||
| 46 | + VideoPosterCleaner(article.videoAssets) | ||
| 47 | + ) | ||
| 48 | + </div> | ||
| 47 | 49 | </div> | |
| 48 | - | ||
| 50 | + | ||
| 51 | + @if(DiscussionSwitch.isSwitchedOn && article.isCommentable) { | ||
| 52 | + <div class="article__discussion"></div> | ||
| 53 | + } | ||
| 54 | + | ||
| 49 | 55 | </article> | |
| 50 | 56 | ||
| 51 | 57 | @fragments.social(article) | |
| 52 | 58 | ||
| 59 | + @if(DiscussionSwitch.isSwitchedOn && article.isCommentable) { | ||
| 60 | + <div class="article__discussion"></div> | ||
| 61 | + <a class="d-show-cta js-show-discussion js-top" href="/discussion/@article.shortUrlId" | ||
| 62 | + data-is-ajax data-link-name="View all comments"> | ||
| 63 | + View all comments <span class="d-commentcount speech-bubble"></span> | ||
| 64 | + </a> | ||
| 65 | + } | ||
| 66 | + | ||
| 53 | 67 | @if(storyPackage.nonEmpty) { | |
| 54 | 68 | <aside role="complementary"> | |
| 55 | 69 | @fragments.relatedTrails(storyPackage, heading = "More on this story", visibleTrails = 5) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,4 +122,4 @@ define('bootstraps/app', [ | |||
| 122 | 122 | go: routes | |
| 123 | 123 | }; | |
| 124 | 124 | ||
| 125 | - }); | ||
| 125 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,12 +3,14 @@ define([ | |||
| 3 | 3 | ||
| 4 | 4 | "modules/autoupdate", | |
| 5 | 5 | "modules/matchnav", | |
| 6 | - "modules/analytics/reading" | ||
| 6 | + "modules/analytics/reading", | ||
| 7 | + "modules/discussion" | ||
| 7 | 8 | ], function ( | |
| 8 | 9 | common, | |
| 9 | 10 | AutoUpdate, | |
| 10 | 11 | MatchNav, | |
| 11 | - Reading | ||
| 12 | + Reading, | ||
| 13 | + Discussion | ||
| 12 | 14 | ) { | |
| 13 | 15 | ||
| 14 | 16 | var modules = { | |
@@ -46,11 +48,23 @@ define([ | |||
| 46 | 48 | }); | |
| 47 | 49 | }, | |
| 48 | 50 | ||
| 51 | + initDiscussion: function() { | ||
| 52 | + common.mediator.on('page:article:ready', function(config, context) { | ||
| 53 | + if (config.page.commentable) { | ||
| 54 | + var discussionArticle = new Discussion({ | ||
| 55 | + id: config.page.shortUrl, | ||
| 56 | + context: context, | ||
| 57 | + config: config | ||
| 58 | + }).init(); | ||
| 59 | + } | ||
| 60 | + }); | ||
| 61 | + }, | ||
| 62 | + | ||
| 49 | 63 | logReading: function(context) { | |
| 50 | 64 | common.mediator.on('page:article:ready', function(config, context) { | |
| 51 | 65 | var wordCount = config.page.wordCount; | |
| 52 | 66 | if(wordCount !== "") { | |
| 53 | - | ||
| 67 | + | ||
| 54 | 68 | var reader = new Reading({ | |
| 55 | 69 | id: config.page.pageId, | |
| 56 | 70 | wordCount: parseInt(config.page.wordCount, 10), | |
@@ -70,6 +84,8 @@ define([ | |||
| 70 | 84 | modules.matchNav(); | |
| 71 | 85 | modules.initLiveBlogging(); | |
| 72 | 86 | modules.logReading(context); | |
| 87 | + | ||
| 88 | + modules.initDiscussion(); | ||
| 73 | 89 | } | |
| 74 | 90 | common.mediator.emit("page:article:ready", config, context); | |
| 75 | 91 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ define(['common', 'modules/detect', 'bean'], function (common, detect, bean) { | |||
| 32 | 32 | return !urlHost || (urlHost === host && urlProtocol === protocol); | |
| 33 | 33 | }; | |
| 34 | 34 | ||
| 35 | - var getClickSpec = function (spec) { | ||
| 35 | + var getClickSpec = function (spec, forceValid) { | ||
| 36 | 36 | var el = spec.el, | |
| 37 | 37 | elName = el.tagName.toLowerCase(), | |
| 38 | 38 | dataLinkName = el.getAttribute('data-link-name'), | |
@@ -59,7 +59,7 @@ define(['common', 'modules/detect', 'bean'], function (common, detect, bean) { | |||
| 59 | 59 | } | |
| 60 | 60 | ||
| 61 | 61 | if(!spec.validTarget) { | |
| 62 | - spec.validTarget = filterSource(el.tagName.toLowerCase()).length > 0; | ||
| 62 | + spec.validTarget = filterSource(el.tagName.toLowerCase()).length > 0 || forceValid; | ||
| 63 | 63 | if(spec.validTarget) { | |
| 64 | 64 | spec.target = el; | |
| 65 | 65 | href = el.getAttribute('href'); | |
@@ -77,16 +77,21 @@ define(['common', 'modules/detect', 'bean'], function (common, detect, bean) { | |||
| 77 | 77 | }; | |
| 78 | 78 | ||
| 79 | 79 | // delegate, emit the derived tag | |
| 80 | - bean.add(document.body, 'click', function (event) { | ||
| 81 | - var clickSpec = getClickSpec({el: event.target}); | ||
| 82 | - if (clickSpec) { | ||
| 83 | - common.mediator.emit('module:clickstream:click', clickSpec); | ||
| 84 | - } | ||
| 85 | - }); | ||
| 80 | + if (opts.addListener !== false) { | ||
| 81 | + bean.add(document.body, 'click', function (event) { | ||
| 82 | + var clickSpec = getClickSpec({el: event.target}); | ||
| 83 | + if (clickSpec) { | ||
| 84 | + common.mediator.emit('module:clickstream:click', clickSpec); | ||
| 85 | + } | ||
| 86 | + }); | ||
| 87 | + } | ||
| 86 | 88 | ||
| 89 | + return { | ||
| 90 | + getClickSpec: getClickSpec | ||
| 91 | + }; | ||
| 87 | 92 | }; | |
| 88 | 93 | ||
| 89 | - return (Clickstream); | ||
| 94 | + return Clickstream; | ||
| 90 | 95 | ||
| 91 | 96 | }); | |
| 92 | 97 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments