Skip to content

Commit

Permalink
Add special checks and preview for svg files media files for v8
Browse files Browse the repository at this point in the history
  • Loading branch information
elit0451 committed Aug 23, 2019
1 parent 11f2855 commit ac4128d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'use strict';

function MediaNodeInfoDirective($timeout, $location, eventsService, userService, dateHelper, editorService) {
function MediaNodeInfoDirective($timeout, $location, eventsService, userService, dateHelper, editorService, mediaHelper) {

function link(scope, element, attrs, ctrl) {

Expand All @@ -28,6 +28,9 @@

// make sure dates are formatted to the user's locale
formatDatesToLocal();

// set media file extension initially
setMediaExtension();
}

function formatDatesToLocal() {
Expand All @@ -49,6 +52,10 @@
}
}

function setMediaExtension() {
scope.node.extension = mediaHelper.getFileExtension(scope.nodeUrl);
}

scope.openMediaType = function (mediaType) {
var editor = {
id: mediaType.id,
Expand All @@ -62,6 +69,16 @@
editorService.mediaTypeEditor(editor);
};

scope.openSVG = function () {
var popup = window.open('', '_blank');
var html = '<!DOCTYPE html><body><img src="' + scope.nodeUrl + '"/>' +
'<script>history.pushState(null, null,"' + $location.$$absUrl + '");</script></body>';

popup.document.open();
popup.document.write(html);
popup.document.close();
}

// watch for content updates - reload content when node is saved, published etc.
scope.$watch('node.updateDate', function(newValue, oldValue){
if(!newValue) { return; }
Expand All @@ -72,6 +89,9 @@

// Update the create and update dates
formatDatesToLocal();

//Update the media file format
setMediaExtension();
});

//ensure to unregister from all events!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@

<ul ng-if="nodeUrl" class="nav nav-stacked" style="margin-bottom: 0;">
<li>
<a href="{{nodeUrl}}" target="_blank">
<i class="icon icon-out"></i>
<span>{{nodeFileName}}</span>
<ng-container ng-if="node.extension != 'svg'">
<a href="{{nodeUrl}}" target="_blank">
<i class="icon icon-out"></i>
<span>{{nodeFileName}}</span>
</a>
</ng-container>
<a ng-if="node.extension == 'svg'">
<i class="icon icon-window-popin"></i>
<span ng-click="openSVG()">{{nodeFileName}}</span>
</a>
</li>
</ul>
Expand Down

0 comments on commit ac4128d

Please sign in to comment.