mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 17:53:44 +08:00
FIX: youtube preview video title link doesn't work
This commit is contained in:
parent
87ef1d0de1
commit
0f4a4651a9
|
@ -1,23 +1,10 @@
|
|||
/**
|
||||
Used for tracking when the user clicks on a link
|
||||
export default {
|
||||
trackClick(e) {
|
||||
// cancel click if triggered as part of selection.
|
||||
if (Discourse.Utilities.selectedText() !== "") { return false; }
|
||||
|
||||
@class ClickTrack
|
||||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
|
||||
Discourse.ClickTrack = {
|
||||
|
||||
/**
|
||||
Track a click on a link
|
||||
|
||||
@method trackClick
|
||||
@param {jQuery.Event} e The click event that occurred
|
||||
**/
|
||||
trackClick: function(e) {
|
||||
if (Discourse.Utilities.selectedText()!=="") return false; //cancle click if triggered as part of selection.
|
||||
var $link = $(e.currentTarget);
|
||||
if ($link.hasClass('lightbox')) return true;
|
||||
if ($link.hasClass('lightbox')) { return true; }
|
||||
|
||||
var href = $link.attr('href') || $link.data('href'),
|
||||
$article = $link.closest('article'),
|
||||
|
@ -25,9 +12,7 @@ Discourse.ClickTrack = {
|
|||
topicId = $('#topic').data('topic-id'),
|
||||
userId = $link.data('user-id');
|
||||
|
||||
if (!href || href.trim().length === 0){
|
||||
return;
|
||||
}
|
||||
if (!href || href.trim().length === 0) { return; }
|
||||
|
||||
if (!userId) userId = $article.data('user-id');
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import AddCategoryClass from 'discourse/mixins/add-category-class';
|
||||
import AddArchetypeClass from 'discourse/mixins/add-archetype-class';
|
||||
import ClickTrack from 'discourse/lib/click-track';
|
||||
import { listenForViewEvent } from 'discourse/lib/app-events';
|
||||
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
|
||||
|
||||
|
@ -55,7 +56,7 @@ var TopicView = Discourse.View.extend(AddCategoryClass, AddArchetypeClass, Disco
|
|||
var $target = $(e.target);
|
||||
if ($target.hasClass('mention') || $target.parents('.expanded-embed').length) { return false; }
|
||||
|
||||
return Discourse.ClickTrack.trackClick(e);
|
||||
return ClickTrack.trackClick(e);
|
||||
});
|
||||
|
||||
}.on('didInsertElement'),
|
||||
|
|
|
@ -52,7 +52,7 @@ class TopicLinkClick < ActiveRecord::Base
|
|||
# If we have it somewhere else on the site, just allow the redirect.
|
||||
# This is likely due to a onebox of another topic.
|
||||
link = TopicLink.find_by(url: url)
|
||||
return link.present? ? link.url : nil
|
||||
return link.present? ? link.url : url
|
||||
end
|
||||
|
||||
return url if args[:user_id] && link.user_id == args[:user_id]
|
||||
|
|
|
@ -8,7 +8,7 @@ describe DirectoryItem do
|
|||
DirectoryItem.refresh!
|
||||
expect(DirectoryItem.where(period_type: DirectoryItem.period_types[:all])
|
||||
.where(user_id: post.user.id)
|
||||
.exists?).to be_true
|
||||
.exists?).to be_truthy
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -47,8 +47,8 @@ describe TopicLinkClick do
|
|||
context 'without a url' do
|
||||
let(:click) { TopicLinkClick.create_from(url: "url that doesn't exist", post_id: @post.id, ip: '127.0.0.1') }
|
||||
|
||||
it "returns nil" do
|
||||
expect(click).to eq(nil)
|
||||
it "returns the url" do
|
||||
expect(click).to eq("url that doesn't exist")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import ClickTrack from "discourse/lib/click-track";
|
||||
|
||||
var windowOpen,
|
||||
win,
|
||||
redirectTo;
|
||||
|
||||
module("Discourse.ClickTrack", {
|
||||
module("ClickTrack", {
|
||||
setup: function() {
|
||||
|
||||
// Prevent any of these tests from navigating away
|
||||
|
@ -30,7 +32,7 @@ module("Discourse.ClickTrack", {
|
|||
}
|
||||
});
|
||||
|
||||
var track = Discourse.ClickTrack.trackClick;
|
||||
var track = ClickTrack.trackClick;
|
||||
|
||||
// test
|
||||
var generateClickEventOn = function(selector) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user