(exports)
| 12 | (function() { |
| 13 | |
| 14 | var factory = function (exports) { |
| 15 | |
| 16 | var pluginName = "image-dialog"; |
| 17 | |
| 18 | exports.fn.imageDialog = 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 imageLang = lang.dialog.image; |
| 28 | var classPrefix = this.classPrefix; |
| 29 | var iframeName = classPrefix + "image-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.imageUploadURL + (settings.imageUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid+"&type=image"; |
| 43 | |
| 44 | if (settings.crossDomainUpload) |
| 45 | { |
| 46 | action += "&callback=" + settings.uploadCallbackURL + "&dialog_id=editormd-image-dialog-" + guid; |
| 47 | } |
| 48 | |
| 49 | var dialogContent = ( (settings.imageUpload) ? "<form action=\"" + action +"\" target=\"" + iframeName + "\" method=\"post\" enctype=\"multipart/form-data\" class=\"" + classPrefix + "form\">" : "<div class=\"" + classPrefix + "form\">" ) + |
| 50 | ( (settings.imageUpload) ? "<iframe name=\"" + iframeName + "\" id=\"" + iframeName + "\" guid=\"" + guid + "\"></iframe>" : "" ) + |
| 51 | "<label>" + imageLang.url + "</label>" + |
| 52 | "<input type=\"text\" data-url />" + (function(){ |
| 53 | return (settings.imageUpload) ? "<div class=\"" + classPrefix + "file-input\">" + |
| 54 | "<input type=\"file\" name=\"" + classPrefix + "image-file\" accept=\"image/*\" />" + |
| 55 | "<input type=\"submit\" value=\"" + imageLang.uploadButton + "\" />" + |
| 56 | "</div>" : ""; |
| 57 | })() + |
| 58 | "<br/>" + |
| 59 | "<label>" + imageLang.alt + "</label>" + |
| 60 | "<input type=\"text\" value=\"" + selection + "\" data-alt />" + |
| 61 | "<br/>" + |
| 62 | "<label>" + imageLang.link + "</label>" + |
| 63 | "<input type=\"text\" value=\"http://\" data-link />" + |
| 64 | "<br/>" + |
| 65 | ( (settings.imageUpload) ? "</form>" : "</div>"); |
| 66 | |
| 67 | //var imageFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "image-manager-btn\" style=\"float:left;\">" + imageLang.managerButton + "</button>"; |
| 68 | |
| 69 | dialog = this.createDialog({ |
| 70 | title : imageLang.title, |
| 71 | width : (settings.imageUpload) ? 465 : 380, |
no test coverage detected