/*! * openfile dialog plugin for Editor.md * * @file open-dialog.js * @author shileiye * @version 1.0.0 * @updateTime 2016-04-07 * {@link https://shileiye.com/md} * @license MIT */ (function() { var factory = function (exports) { var $ = jQuery; var pluginName = "open-dialog"; exports.fn.openDialog = function() { var _this = this; var lang = this.lang; var editor = this.editor; var settings = this.settings; var path = settings.pluginPath + pluginName + "/"; var classPrefix = this.classPrefix; var dialogName = classPrefix + pluginName, dialog; var dialogLang = lang.dialog.open; if (editor.find("." + dialogName).length < 1) { var dialogContent = "
"; dialog = this.createDialog({ name : dialogName, title : dialogLang.title, width : 840, height : 540, mask : settings.dialogShowMask, drag : settings.dialogDraggable, content : dialogContent, lockScreen : settings.dialogLockScreen, maskStyle : { opacity : settings.dialogMaskOpacity, backgroundColor : settings.dialogMaskBgColor }, buttons : { close : [lang.buttons.close, function() { this.hide().lockScreen(false).hideMask(); return false; }] } }); } dialog = editor.find("." + dialogName); this.dialogShowMask(dialog); this.dialogLockScreen(); dialog.show(); var openContent = dialog.find(".markdown-body"); if (openContent.html() === "") { $.get(path + "open.php", function(text) { var md = exports.$marked(text); openContent.html(md); openContent.find("a").attr("target", "_blank"); }); } }; }; // CommonJS/Node.js if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { module.exports = factory; } else if (typeof define === "function") // AMD/CMD/Sea.js { if (define.amd) { // for Require.js define(["editormd"], function(editormd) { factory(editormd); }); } else { // for Sea.js define(function(require) { var editormd = require("./../../editormd"); factory(editormd); }); } } else { factory(window.editormd); } })();