Fix link title depending on embedding

This commit is contained in:
Jordan Bates 2013-04-30 07:04:22 -07:00
parent 23f1b9a1bf
commit 286047cc44
5 changed files with 34 additions and 14 deletions

View File

@ -1,5 +1,6 @@
seaweedchan:
- Fix various embedding issues
- Fix Link Title depending on Embedding
### 1.1.4 - 2013-04-29
seaweedchan:

View File

@ -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];
}

View File

@ -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];
}

View File

@ -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];
}

View File

@ -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}] <span class=warning>Title Link Blocked</span> (are you using NoScript?)</a>"
return [a, $.tn(' '), embed]
return [a, $.tn(' '), embed]
return [a]