unserver-unify
Version:
47 lines (42 loc) • 1.47 kB
JavaScript
'use strict';
angular.module('bamboo.course').controller("cvPreviewModalCtrl", function($uibModalInstance,config,$sce,$scope) {
var self = this;
self.type = config.type;
self.fileURL = config.absURL;
var msoffice = ['doc','docx','docm','dotm','dotx','xlsx','xlsb','xlsm','pptx','ppsx','ppt','pps','pptm','potm','ppam','potx','ppsm'];
var imgType = ['gif','jpeg','jpg','jpeg','png'];
var videoType = ['ogg','mp4'];
if (msoffice.indexOf(self.type)>-1) {
var fullurl = self.fileURL;
if(self.fileURL.indexOf('http')===-1)
{
var _protocol = window.location.protocol;
fullurl = _protocol + self.fileURL;
}
console.log(fullurl);
self.fileURL = "https://view.officeapps.live.com/op/embed.aspx?src=" + fullurl;
self.type = 'msoffice';
console.log(self.type);
}else if (imgType.indexOf(self.type)>-1) {
self.type = 'img';
}
else if (videoType.indexOf(self.type)>-1) {
self.type = 'video';
}else if (self.type == 'pdf') {
self.type = 'pdf';
}else if (self.type == 'txt') {
self.type = 'txt';
}else{
self.type = undefined;
}
self.title = self.fileURL && self.fileURL.split('/').pop();
self.fileURL = $sce.trustAsResourceUrl(self.fileURL);
$scope.ok = function() {
$uibModalInstance.close("ok");
};
self.cancel = function() {
console.log("---");
//$uibModalInstance.dismiss();
$uibModalInstance.close();
};
});