MCPcopy Create free account
hub / github.com/TruthHun/BookStack / factory

Function factory

static/editor.md/plugins/file-dialog/file-dialog.js:14–187  ·  view source on GitHub ↗
(exports)

Source from the content-addressed store, hash-verified

12(function() {
13
14 var factory = function (exports) {
15
16 var pluginName = "file-dialog";
17
18 exports.fn.fileDialog = function() {
19
20 var _this = this;
21 var cm = this.cm;
22 var lang = this.lang;
23 var editor = this.editor;
24 var settings = this.settings;
25 var cursor = cm.getCursor();
26 var selection = cm.getSelection();
27 var fileLang = lang.dialog.file;
28 var classPrefix = this.classPrefix;
29 var iframeName = classPrefix + "file-iframe";
30 var dialogName = classPrefix + pluginName, dialog;
31
32 cm.focus();
33
34 var loading = function(show) {
35 var _loading = dialog.find("." + classPrefix + "dialog-mask");
36 _loading[(show) ? "show" : "hide"]();
37 };
38
39 if (editor.find("." + dialogName).length < 1)
40 {
41 var guid = (new Date).getTime();
42 var action = settings.fileUploadURL + (settings.fileUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid;
43
44 if (settings.crossDomainUpload)
45 {
46 action += "&callback=" + settings.uploadCallbackURL + "&dialog_id=editormd-file-dialog-" + guid;
47 }
48
49 var dialogContent = ( (settings.fileUpload) ? "<form action=\"" + action +"\" target=\"" + iframeName + "\" method=\"post\" enctype=\"multipart/form-data\" class=\"" + classPrefix + "form\">" : "<div class=\"" + classPrefix + "form\">" ) +
50 ( (settings.fileUpload) ? "<iframe name=\"" + iframeName + "\" id=\"" + iframeName + "\" guid=\"" + guid + "\"></iframe>" : "" ) +
51 "<label>文件地址</label>" +
52 "<input type=\"text\" data-url />" + (function(){
53 return (settings.fileUpload) ? "<div class=\"" + classPrefix + "file-input\">" +
54 "<input type=\"file\" name=\"" + classPrefix + "file-file\" />" +
55 "<input type=\"submit\" value=\"本地上传\" />" +
56 "</div>" : "";
57 })() +
58 "<br/>" +
59 "<label>文件说明</label>" +
60 "<input type=\"text\" value=\"" + selection + "\" data-alt />" +
61 "<br/>" +
62 "<input type='hidden' data-icon>"+
63 ( (settings.fileUpload) ? "</form>" : "</div>");
64
65 //var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + fileLang.managerButton + "</button>";
66
67 dialog = this.createDialog({
68 title : "文件上传",
69 width : (settings.fileUpload) ? 465 : 380,
70 height : 254,
71 name : dialogName,

Callers 1

file-dialog.jsFile · 0.70

Calls 1

loadingFunction · 0.70

Tested by

no test coverage detected