(exports)
| 1 | (function() { |
| 2 | |
| 3 | var factory = function (exports) { |
| 4 | |
| 5 | var pluginName = "audio-dialog"; |
| 6 | |
| 7 | exports.fn.audioDialog = function() { |
| 8 | |
| 9 | var _this = this; |
| 10 | var cm = this.cm; |
| 11 | var lang = this.lang; |
| 12 | var editor = this.editor; |
| 13 | var settings = this.settings; |
| 14 | var cursor = cm.getCursor(); |
| 15 | var selection = cm.getSelection(); |
| 16 | var audioLang = lang.dialog.audio; |
| 17 | var classPrefix = this.classPrefix; |
| 18 | var iframeName = classPrefix + "audio-iframe"; |
| 19 | var dialogName = classPrefix + pluginName, dialog; |
| 20 | |
| 21 | cm.focus(); |
| 22 | |
| 23 | var loading = function(show) { |
| 24 | var _loading = dialog.find("." + classPrefix + "dialog-mask"); |
| 25 | _loading[(show) ? "show" : "hide"](); |
| 26 | }; |
| 27 | |
| 28 | if (editor.find("." + dialogName).length < 1) |
| 29 | { |
| 30 | var guid = (new Date).getTime(); |
| 31 | var action = settings.audioUploadURL + (settings.audioUploadURL.indexOf("?") >= 0 ? "&" : "?") + "guid=" + guid+"&type=audio"; |
| 32 | |
| 33 | if (settings.crossDomainUpload) |
| 34 | { |
| 35 | action += "&callback=" + settings.uploadCallbackURL + "&dialog_id=editormd-audio-dialog-" + guid; |
| 36 | } |
| 37 | |
| 38 | var dialogContent = ( (settings.audioUpload) ? "<form action=\"" + action +"\" target=\"" + iframeName + "\" method=\"post\" enctype=\"multipart/form-data\" class=\"" + classPrefix + "form\">" : "<div class=\"" + classPrefix + "form\">" ) + |
| 39 | ( (settings.audioUpload) ? "<iframe name=\"" + iframeName + "\" id=\"" + iframeName + "\" guid=\"" + guid + "\"></iframe>" : "" ) + |
| 40 | "<label>" + audioLang.url + "</label>" + |
| 41 | "<input type=\"text\" data-url />" + (function(){ |
| 42 | return (settings.audioUpload) ? "<div class=\"" + classPrefix + "file-input\">" + |
| 43 | "<input type=\"file\" name=\"" + classPrefix + "audio-file\" accept=\"audio/*\" />" + |
| 44 | "<input type=\"submit\" value=\"" + audioLang.uploadButton + "\" />" + |
| 45 | "</div>" : ""; |
| 46 | })() + |
| 47 | "<br/>" + |
| 48 | "<label>" + audioLang.alt + "</label>" + |
| 49 | "<input type=\"text\" value=\"" + selection + "\" data-alt />" + |
| 50 | "<br/>" + |
| 51 | "<label>" + audioLang.link + "</label>" + |
| 52 | "<input type=\"text\" value=\"\" data-link />" + |
| 53 | "<br/>" + |
| 54 | ( (settings.audioUpload) ? "</form>" : "</div>"); |
| 55 | |
| 56 | //var audioFooterHTML = "<button class=\"" + classPrefix + "btn " + classPrefix + "audio-manager-btn\" style=\"float:left;\">" + audioLang.managerButton + "</button>"; |
| 57 | |
| 58 | dialog = this.createDialog({ |
| 59 | title : audioLang.title, |
| 60 | width : (settings.audioUpload) ? 465 : 380, |
no test coverage detected