From 286047cc4408413c74eb85131ecd10c540efe111 Mon Sep 17 00:00:00 2001 From: Jordan Bates Date: Tue, 30 Apr 2013 07:04:22 -0700 Subject: [PATCH] Fix link title depending on embedding --- CHANGELOG.md | 1 + builds/4chan-X.js | 11 ++++++++--- builds/4chan-X.user.js | 11 ++++++++--- builds/crx/script.js | 11 ++++++++--- src/Linkification/Linkify.coffee | 14 +++++++++----- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95a7e2056..f875ffe17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ seaweedchan: - Fix various embedding issues +- Fix Link Title depending on Embedding ### 1.1.4 - 2013-04-29 seaweedchan: diff --git a/builds/4chan-X.js b/builds/4chan-X.js index ad12d3832..a3890f26c 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -4211,6 +4211,7 @@ textContent: this.getAttribute("data-title") || url }); this.textContent = '(embed)'; + $.addClass(el, "" + (this.getAttribute('data-service'))); } else { el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; @@ -4320,7 +4321,7 @@ embedder: function(a) { var callbacks, embed, key, match, service, titles, type, _ref; - if (!Conf['Embedding']) { + if (!Conf['Link Title']) { return [a]; } titles = {}; @@ -4331,7 +4332,7 @@ switch (this.status) { case 200: case 304: - title = "[" + (embed.getAttribute('data-service')) + "] " + (service.text.call(this)); + title = "" + (service.text.call(this)); embed.setAttribute('data-title', title); titles[embed.name] = [title, Date.now()]; $.set('CachedTitles', titles); @@ -4359,7 +4360,11 @@ }); embed.setAttribute('data-service', key); embed.setAttribute('data-originalURL', a.href); + $.addClass(a, "" + (embed.getAttribute('data-service'))); $.on(embed, 'click', Linkify.toggle); + if (!Conf['Embedding']) { + embed.hidden = true; + } if (Conf['Link Title'] && (service = type.title)) { $.get('CachedTitles', {}, function(item) { var err, title; @@ -4377,8 +4382,8 @@ } } }); + return [a, $.tn(' '), embed]; } - return [a, $.tn(' '), embed]; } return [a]; } diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 7839b12e0..4ad397f4f 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -4207,6 +4207,7 @@ textContent: this.getAttribute("data-title") || url }); this.textContent = '(embed)'; + $.addClass(el, "" + (this.getAttribute('data-service'))); } else { el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; @@ -4316,7 +4317,7 @@ embedder: function(a) { var callbacks, embed, key, match, service, titles, type, _ref; - if (!Conf['Embedding']) { + if (!Conf['Link Title']) { return [a]; } titles = {}; @@ -4327,7 +4328,7 @@ switch (this.status) { case 200: case 304: - title = "[" + (embed.getAttribute('data-service')) + "] " + (service.text.call(this)); + title = "" + (service.text.call(this)); embed.setAttribute('data-title', title); titles[embed.name] = [title, Date.now()]; $.set('CachedTitles', titles); @@ -4355,7 +4356,11 @@ }); embed.setAttribute('data-service', key); embed.setAttribute('data-originalURL', a.href); + $.addClass(a, "" + (embed.getAttribute('data-service'))); $.on(embed, 'click', Linkify.toggle); + if (!Conf['Embedding']) { + embed.hidden = true; + } if (Conf['Link Title'] && (service = type.title)) { $.get('CachedTitles', {}, function(item) { var err, title; @@ -4373,8 +4378,8 @@ } } }); + return [a, $.tn(' '), embed]; } - return [a, $.tn(' '), embed]; } return [a]; } diff --git a/builds/crx/script.js b/builds/crx/script.js index db053f8bf..50f15cef6 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4210,6 +4210,7 @@ textContent: this.getAttribute("data-title") || url }); this.textContent = '(embed)'; + $.addClass(el, "" + (this.getAttribute('data-service'))); } else { el = (type = Linkify.types[this.getAttribute("data-service")]).el.call(this); el.style.cssText = (style = type.style) ? style : "border: 0; width: 640px; height: 390px"; @@ -4319,7 +4320,7 @@ embedder: function(a) { var callbacks, embed, key, match, service, titles, type, _ref; - if (!Conf['Embedding']) { + if (!Conf['Link Title']) { return [a]; } titles = {}; @@ -4330,7 +4331,7 @@ switch (this.status) { case 200: case 304: - title = "[" + (embed.getAttribute('data-service')) + "] " + (service.text.call(this)); + title = "" + (service.text.call(this)); embed.setAttribute('data-title', title); titles[embed.name] = [title, Date.now()]; $.set('CachedTitles', titles); @@ -4358,7 +4359,11 @@ }); embed.setAttribute('data-service', key); embed.setAttribute('data-originalURL', a.href); + $.addClass(a, "" + (embed.getAttribute('data-service'))); $.on(embed, 'click', Linkify.toggle); + if (!Conf['Embedding']) { + embed.hidden = true; + } if (Conf['Link Title'] && (service = type.title)) { $.get('CachedTitles', {}, function(item) { var err, title; @@ -4376,8 +4381,8 @@ } } }); + return [a, $.tn(' '), embed]; } - return [a, $.tn(' '), embed]; } return [a]; } diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 95cd856e5..77a8fc673 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -125,6 +125,7 @@ Linkify = textContent: @getAttribute("data-title") or url @textContent = '(embed)' + $.addClass el, "#{@getAttribute 'data-service'}" else # We create an element to embed @@ -203,16 +204,16 @@ Linkify = regExp: /.*(?:pastebin.com\/)([^#\&\?]*).*/ el: -> div = $.el 'iframe', - src: "http://pastebin.com/embed_iframe.php?i=#{@name}" + src: "http://pastebin.com/embed_iframe.php?i=#{@name}" embedder: (a) -> - return [a] unless Conf['Embedding'] + return [a] unless Conf['Link Title'] titles = {} callbacks = -> a.textContent = switch @status when 200, 304 - title = "[#{embed.getAttribute 'data-service'}] #{service.text.call @}" + title = "#{service.text.call @}" embed.setAttribute 'data-title', title titles[embed.name] = [title, Date.now()] $.set 'CachedTitles', titles @@ -235,13 +236,16 @@ Linkify = embed.setAttribute 'data-service', key embed.setAttribute 'data-originalURL', a.href + $.addClass a, "#{embed.getAttribute 'data-service'}" $.on embed, 'click', Linkify.toggle + unless Conf['Embedding'] + embed.hidden = true + if Conf['Link Title'] and (service = type.title) $.get 'CachedTitles', {}, (item) -> titles = item['CachedTitles'] - if title = titles[match[1]] a.textContent = title[0] embed.setAttribute 'data-title', title[0] @@ -251,5 +255,5 @@ Linkify = catch err a.innerHTML = "[#{key}] Title Link Blocked (are you using NoScript?)" - return [a, $.tn(' '), embed] + return [a, $.tn(' '), embed] return [a] \ No newline at end of file