contract thumbnails in hover preview
... and don't clone the video element
This commit is contained in:
parent
e69d6b2e7c
commit
deeba623a0
@ -1214,8 +1214,8 @@
|
|||||||
return this.board.posts.rm(this);
|
return this.board.posts.rm(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.prototype.addClone = function(context) {
|
Post.prototype.addClone = function(context, contractThumb) {
|
||||||
return new Clone(this, context);
|
return new Clone(this, context, contractThumb);
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.prototype.rmClone = function(index) {
|
Post.prototype.rmClone = function(index) {
|
||||||
@ -1235,8 +1235,8 @@
|
|||||||
Clone = (function(_super) {
|
Clone = (function(_super) {
|
||||||
__extends(Clone, _super);
|
__extends(Clone, _super);
|
||||||
|
|
||||||
function Clone(origin, context) {
|
function Clone(origin, context, contractThumb) {
|
||||||
var file, info, inline, inlined, key, nodes, post, root, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
|
var file, info, inline, inlined, key, nodes, post, root, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
_ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
|
_ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
|
||||||
@ -1245,7 +1245,7 @@
|
|||||||
this[key] = origin[key];
|
this[key] = origin[key];
|
||||||
}
|
}
|
||||||
nodes = origin.nodes;
|
nodes = origin.nodes;
|
||||||
root = nodes.root.cloneNode(true);
|
root = contractThumb ? this.cloneWithoutVideo(nodes.root) : nodes.root.cloneNode(true);
|
||||||
post = $('.post', root);
|
post = $('.post', root);
|
||||||
info = $('.postInfo', post);
|
info = $('.postInfo', post);
|
||||||
this.nodes = {
|
this.nodes = {
|
||||||
@ -1305,6 +1305,13 @@
|
|||||||
this.file.text = file.firstElementChild;
|
this.file.text = file.firstElementChild;
|
||||||
this.file.thumb = $('img[data-md5]', file);
|
this.file.thumb = $('img[data-md5]', file);
|
||||||
this.file.fullImage = $('.full-image', file);
|
this.file.fullImage = $('.full-image', file);
|
||||||
|
if (contractThumb) {
|
||||||
|
$.rmClass(this.nodes.root, 'expanded-image');
|
||||||
|
$.rmClass(this.file.thumb, 'expanding');
|
||||||
|
}
|
||||||
|
if ((_ref4 = this.file.fullImage) != null) {
|
||||||
|
_ref4.removeAttribute('id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (origin.isDead) {
|
if (origin.isDead) {
|
||||||
this.isDead = true;
|
this.isDead = true;
|
||||||
@ -1313,6 +1320,23 @@
|
|||||||
root.dataset.clone = origin.clones.push(this) - 1;
|
root.dataset.clone = origin.clones.push(this) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Clone.prototype.cloneWithoutVideo = function(node) {
|
||||||
|
var child, clone, _i, _len, _ref;
|
||||||
|
if (node.tagName === 'VIDEO') {
|
||||||
|
return [];
|
||||||
|
} else if (node.nodeType === Node.ELEMENT_NODE && $('video', node)) {
|
||||||
|
clone = node.cloneNode(false);
|
||||||
|
_ref = node.childNodes;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
child = _ref[_i];
|
||||||
|
$.add(clone, this.cloneWithoutVideo(child));
|
||||||
|
}
|
||||||
|
return clone;
|
||||||
|
} else {
|
||||||
|
return node.cloneNode(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return Clone;
|
return Clone;
|
||||||
|
|
||||||
})(Post);
|
})(Post);
|
||||||
@ -3325,7 +3349,7 @@
|
|||||||
if (!root.parentNode) {
|
if (!root.parentNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clone = post.addClone(context);
|
clone = post.addClone(context, $.hasClass(root, 'dialog'));
|
||||||
Main.callbackNodes(Clone, [clone]);
|
Main.callbackNodes(Clone, [clone]);
|
||||||
nodes = clone.nodes;
|
nodes = clone.nodes;
|
||||||
$.rmAll(nodes.root);
|
$.rmAll(nodes.root);
|
||||||
|
|||||||
@ -1251,8 +1251,8 @@
|
|||||||
return this.board.posts.rm(this);
|
return this.board.posts.rm(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.prototype.addClone = function(context) {
|
Post.prototype.addClone = function(context, contractThumb) {
|
||||||
return new Clone(this, context);
|
return new Clone(this, context, contractThumb);
|
||||||
};
|
};
|
||||||
|
|
||||||
Post.prototype.rmClone = function(index) {
|
Post.prototype.rmClone = function(index) {
|
||||||
@ -1272,8 +1272,8 @@
|
|||||||
Clone = (function(_super) {
|
Clone = (function(_super) {
|
||||||
__extends(Clone, _super);
|
__extends(Clone, _super);
|
||||||
|
|
||||||
function Clone(origin, context) {
|
function Clone(origin, context, contractThumb) {
|
||||||
var file, info, inline, inlined, key, nodes, post, root, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3;
|
var file, info, inline, inlined, key, nodes, post, root, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
_ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
|
_ref = ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply'];
|
||||||
@ -1282,7 +1282,7 @@
|
|||||||
this[key] = origin[key];
|
this[key] = origin[key];
|
||||||
}
|
}
|
||||||
nodes = origin.nodes;
|
nodes = origin.nodes;
|
||||||
root = nodes.root.cloneNode(true);
|
root = contractThumb ? this.cloneWithoutVideo(nodes.root) : nodes.root.cloneNode(true);
|
||||||
post = $('.post', root);
|
post = $('.post', root);
|
||||||
info = $('.postInfo', post);
|
info = $('.postInfo', post);
|
||||||
this.nodes = {
|
this.nodes = {
|
||||||
@ -1342,6 +1342,13 @@
|
|||||||
this.file.text = file.firstElementChild;
|
this.file.text = file.firstElementChild;
|
||||||
this.file.thumb = $('img[data-md5]', file);
|
this.file.thumb = $('img[data-md5]', file);
|
||||||
this.file.fullImage = $('.full-image', file);
|
this.file.fullImage = $('.full-image', file);
|
||||||
|
if (contractThumb) {
|
||||||
|
$.rmClass(this.nodes.root, 'expanded-image');
|
||||||
|
$.rmClass(this.file.thumb, 'expanding');
|
||||||
|
}
|
||||||
|
if ((_ref4 = this.file.fullImage) != null) {
|
||||||
|
_ref4.removeAttribute('id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (origin.isDead) {
|
if (origin.isDead) {
|
||||||
this.isDead = true;
|
this.isDead = true;
|
||||||
@ -1350,6 +1357,23 @@
|
|||||||
root.dataset.clone = origin.clones.push(this) - 1;
|
root.dataset.clone = origin.clones.push(this) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Clone.prototype.cloneWithoutVideo = function(node) {
|
||||||
|
var child, clone, _i, _len, _ref;
|
||||||
|
if (node.tagName === 'VIDEO') {
|
||||||
|
return [];
|
||||||
|
} else if (node.nodeType === Node.ELEMENT_NODE && $('video', node)) {
|
||||||
|
clone = node.cloneNode(false);
|
||||||
|
_ref = node.childNodes;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
child = _ref[_i];
|
||||||
|
$.add(clone, this.cloneWithoutVideo(child));
|
||||||
|
}
|
||||||
|
return clone;
|
||||||
|
} else {
|
||||||
|
return node.cloneNode(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return Clone;
|
return Clone;
|
||||||
|
|
||||||
})(Post);
|
})(Post);
|
||||||
@ -3366,7 +3390,7 @@
|
|||||||
if (!root.parentNode) {
|
if (!root.parentNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clone = post.addClone(context);
|
clone = post.addClone(context, $.hasClass(root, 'dialog'));
|
||||||
Main.callbackNodes(Clone, [clone]);
|
Main.callbackNodes(Clone, [clone]);
|
||||||
nodes = clone.nodes;
|
nodes = clone.nodes;
|
||||||
$.rmAll(nodes.root);
|
$.rmAll(nodes.root);
|
||||||
|
|||||||
@ -85,7 +85,7 @@ Get =
|
|||||||
insert: (post, root, context) ->
|
insert: (post, root, context) ->
|
||||||
# Stop here if the container has been removed while loading.
|
# Stop here if the container has been removed while loading.
|
||||||
return unless root.parentNode
|
return unless root.parentNode
|
||||||
clone = post.addClone context
|
clone = post.addClone context, ($.hasClass root, 'dialog')
|
||||||
Main.callbackNodes Clone, [clone]
|
Main.callbackNodes Clone, [clone]
|
||||||
|
|
||||||
# Get rid of the side arrows.
|
# Get rid of the side arrows.
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
class Clone extends Post
|
class Clone extends Post
|
||||||
constructor: (@origin, @context) ->
|
constructor: (@origin, @context, contractThumb) ->
|
||||||
for key in ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply']
|
for key in ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply']
|
||||||
# Copy or point to the origin's key value.
|
# Copy or point to the origin's key value.
|
||||||
@[key] = origin[key]
|
@[key] = origin[key]
|
||||||
|
|
||||||
{nodes} = origin
|
{nodes} = origin
|
||||||
root = nodes.root.cloneNode true
|
root = if contractThumb
|
||||||
|
@cloneWithoutVideo nodes.root
|
||||||
|
else
|
||||||
|
nodes.root.cloneNode true
|
||||||
post = $ '.post', root
|
post = $ '.post', root
|
||||||
info = $ '.postInfo', post
|
info = $ '.postInfo', post
|
||||||
@nodes =
|
@nodes =
|
||||||
@ -56,6 +59,25 @@ class Clone extends Post
|
|||||||
@file.thumb = $ 'img[data-md5]', file
|
@file.thumb = $ 'img[data-md5]', file
|
||||||
@file.fullImage = $ '.full-image', file
|
@file.fullImage = $ '.full-image', file
|
||||||
|
|
||||||
|
# Contract thumbnails in quote preview
|
||||||
|
if contractThumb
|
||||||
|
$.rmClass @nodes.root, 'expanded-image'
|
||||||
|
$.rmClass @file.thumb, 'expanding'
|
||||||
|
|
||||||
|
# Remove any #ihover ID
|
||||||
|
@file.fullImage?.removeAttribute 'id'
|
||||||
|
|
||||||
@isDead = true if origin.isDead
|
@isDead = true if origin.isDead
|
||||||
@isClone = true
|
@isClone = true
|
||||||
root.dataset.clone = origin.clones.push(@) - 1
|
root.dataset.clone = origin.clones.push(@) - 1
|
||||||
|
|
||||||
|
cloneWithoutVideo: (node) ->
|
||||||
|
if node.tagName is 'VIDEO'
|
||||||
|
[]
|
||||||
|
else if node.nodeType is Node.ELEMENT_NODE and $ 'video', node
|
||||||
|
clone = node.cloneNode false
|
||||||
|
$.add clone, @cloneWithoutVideo child for child in node.childNodes
|
||||||
|
clone
|
||||||
|
else
|
||||||
|
node.cloneNode true
|
||||||
|
|
||||||
|
|||||||
@ -214,8 +214,8 @@ class Post
|
|||||||
@thread.posts.rm @
|
@thread.posts.rm @
|
||||||
@board.posts.rm @
|
@board.posts.rm @
|
||||||
|
|
||||||
addClone: (context) ->
|
addClone: (context, contractThumb) ->
|
||||||
new Clone @, context
|
new Clone @, context, contractThumb
|
||||||
|
|
||||||
rmClone: (index) ->
|
rmClone: (index) ->
|
||||||
@clones.splice index, 1
|
@clones.splice index, 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user