feat(torrents): new directive for torrent overview picture reorganize

This commit is contained in:
OldHawk
2018-01-17 18:39:56 +08:00
parent aee57a00e3
commit 492ae70bc2
2 changed files with 31 additions and 9 deletions

View File

@@ -9,7 +9,6 @@
function torrentImageList($sce, $parse, $compile, $timeout) {
var directive = {
restrict: 'A',
replace: true,
priority: 10,
link: link
};
@@ -18,15 +17,36 @@
function link(scope, element, attrs) {
scope.$watch(attrs.torrentImageList, function (til) {
if (til) {
console.log(element[0]);
hideImage();
var targetNode = document.getElementById(attrs.torrentImageList);
var config = {childList: true};
var callback = function (mutationsList) {
for (var mutation of mutationsList) {
if (mutation.type === 'childList') {
hideImage();
}
}
};
var observer = new MutationObserver(callback);
observer.observe(targetNode, config);
//observer.disconnect();
function hideImage() {
var imgs = element[0].querySelectorAll('img:not(.emoji)');
console.log(imgs);
angular.forEach(imgs, function (i) {
if (i.previousSibling && i.previousSibling.tagName.toUpperCase() === 'BR') {
i.previousSibling.remove();
}
if (i.parentElement.childElementCount === 1) {
angular.element(i.parentElement).css('display', 'none');
angular.element(i.parentElement).remove();
} else {
angular.element(i).css('display', 'none');
angular.element(i).remove();
}
});
}

View File

@@ -182,9 +182,10 @@
{{vm.TGI.getTorrentOverview(vm.torrentLocalInfo)}}
</div>
<div ng-if="vm.torrentLocalInfo.torrent_type!='movie' && vm.torrentLocalInfo.torrent_type!='tvserial'">
<div id="{{vm.torrentLocalInfo._id}}" data-provide="markdown"
ng-bind-html="vm.getOverviewMarkedContent(vm.TGI.getTorrentOverview(vm.torrentLocalInfo))"
torrent-image-list="vm.torrentLocalInfo">
<div id="til_{{vm.torrentLocalInfo._id}}" torrent-image-list="til_{{vm.torrentLocalInfo._id}}">
<div id="{{vm.torrentLocalInfo._id}}" data-provide="markdown"
ng-bind-html="vm.getOverviewMarkedContent(vm.TGI.getTorrentOverview(vm.torrentLocalInfo))">
</div>
</div>
<div class="edit-overview-div" ng-if="vm.isOwner(vm.torrentLocalInfo) || vm.user.isOper">
<a href="#" ng-click="vm.beginEditOverview(vm.torrentLocalInfo)">{{'EDIT_THIS_OVERVIEW' | translate}}</a>
@@ -344,7 +345,8 @@
</div>
<div class="timeline-comment-body">
<textarea id="commentContent" name="commentContent" ng-model="vm.new_comment_content"
mt-markdown-editor="commentContent" maxlength="{{vm.inputLengthConfig.torrentCommentLength}}"></textarea>
mt-markdown-editor="commentContent"
maxlength="{{vm.inputLengthConfig.torrentCommentLength}}"></textarea>
<div class="row margin-top-10">
<div class="col-sm-6" style="display: table;">