Commit 4657e752 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

FileHandler2: integrated CodeEditor and Gallery

parent 42ea9c4b
define(["vispa/extension", "./view", "css!../css/styles"],
function(Extension, CodeEditorView) {
define([
"vispa/extension",
"vispa/filehandler2",
"./view",
"css!../css/styles"
], function(
Extension,
FileHandler2,
CodeEditorView
) {
var CodeEditorExtension = Extension._extend({
init: function init() {
......@@ -10,5 +18,23 @@ define(["vispa/extension", "./view", "css!../css/styles"],
},
});
var fileExtensions = [
"bsc", "c", "cc", "conf", "cpp", "csh", "css", "cxx", "diff", "f", "f70", "f90", "f95", "f03",
"h", "hh", "hxx", "hpp", "html", "ini", "java", "js", "less", "log", "json", "m", "md", "orig",
"php", "py", "r", "rb", "sh", "tex", "txt", "xml", "yml", "yaml", "zsh"
];
FileHandler2.addOpen("codeeditor", {
label: "Code Editor",
iconClass: function (ext) {
return (~fileExtensions.indexOf(ext)) ? ("fi fi-" + ext) : "fa fa-file-text";
},
position: function (ext) {
return (~fileExtensions.indexOf(ext)) ? 1 : 1001;
},
}, function(path) {
return ["codeeditor", "CodeEditorView", {path: path}];
});
return CodeEditorExtension;
});
......@@ -3,9 +3,17 @@ define([
"vispa/extension",
"vispa/views/dialog",
"vispa/common/dialog",
"vispa/filehandler2",
"text!../html/galleryBody.html",
"css!../css/gallery"
], function ($, Extension, DialogView, Dialog, galleryBodyTmpl) {
], function (
$,
Extension,
DialogView,
Dialog,
FileHandler2,
galleryBodyTmpl
) {
var GalleryExtension = Extension._extend({
init: function init() {
......@@ -217,5 +225,27 @@ define([
}]
});
var fext = ["png", "jpg", "jpeg", "bmp", "pdf"];
FileHandler2.addOpen("gallery", {
label: "Preview in gallery",
iconClass: "fa-image",
position: 10,
}, function (ext, info) {
var args = {};
var base = info.pathBase + "/";
if (info._f2br) {
var self = this;
// TODO: have this in sort order
args.paths = info._f2br.items.filter(function (it) {
return self._testExt(self.ext({data: it}), fext);
}).map(function (it) {
return base + it.name;
});
args.index = args.paths.indexOf(base + info.data.name);
} else
args.path = base + info.data.name;
return ["gallery", "Gallery", args];
}, fext);
return GalleryExtension;
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment