diff --git a/app/views/Note/note-dev.html b/app/views/Note/note-dev.html index 088c817..eb220a1 100644 --- a/app/views/Note/note-dev.html +++ b/app/views/Note/note-dev.html @@ -1045,10 +1045,11 @@ require.config({ 'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor', 'attachment_upload': 'js/app/attachment_upload', 'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget', - 'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload' + 'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload', + 'iframe-transport': '/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport' }, shim: { - 'fileupload': {deps: ['jquery.ui.widget']} + 'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']} } }); require(['leaui_image'], function(leaui_image) { diff --git a/app/views/Note/note.html b/app/views/Note/note.html index a2e6df8..3badd17 100755 --- a/app/views/Note/note.html +++ b/app/views/Note/note.html @@ -1045,10 +1045,11 @@ require.config({ 'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor', 'attachment_upload': 'js/app/attachment_upload', 'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget', - 'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload' + 'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload', + 'iframe-transport': '/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport' }, shim: { - 'fileupload': {deps: ['jquery.ui.widget']} + 'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']} } }); require(['leaui_image'], function(leaui_image) { diff --git a/public/js/app/attachment_upload.js b/public/js/app/attachment_upload.js index 5c44e92..ef6bf9b 100644 --- a/public/js/app/attachment_upload.js +++ b/public/js/app/attachment_upload.js @@ -2,9 +2,6 @@ // 依赖note var urlPrefix = window.location.protocol + "//" + window.location.host; define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ - // var editor = tinymce.activeEditor; - // var dom = editor.dom; - var initUploader = function() { var $msg = $('#attachUploadMsg'); @@ -36,23 +33,28 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ tpl.append(data.files[0].name + ' [' + formatFileSize(data.files[0].size) + ']'); // Add the HTML to the UL element - tpl.appendTo($msg); + $msg.html(tpl); data.context = $msg; // Automatically upload the file once it is added to the queue var jqXHR; setTimeout(function() { jqXHR = data.submit(); - }, 0); + }, 10); }, + + /* + progress: function (e, data) { + }, + */ done: function(e, data) { if (data.result.Ok == true) { - data.context.remove(); + data.context.html(""); Attach.addAttach(data.result.Item); } else { var re = data.result; - data.context.empty(); + data.context.html(""); var tpl = $('
'); tpl.append('Error: ' + data.files[0].name + ' [' + formatFileSize(data.files[0].size) + '] ' + data.result.Msg); data.context.html(tpl); @@ -65,7 +67,7 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ $("#uploadAttachMsg").scrollTop(1000); }, fail: function(e, data) { - data.context.empty(); + data.context.html(""); var tpl = $(''); tpl.append('Error: ' + data.files[0].name + ' [' + formatFileSize(data.files[0].size) + '] ' + data.errorThrown); data.context.html(tpl); @@ -79,11 +81,6 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ } }); - // Prevent the default action when a file is dropped on the window - $(document).on('drop dragover', function(e) { - e.preventDefault(); - }); - // Helper function that formats the file sizes function formatFileSize(bytes) { if (typeof bytes !== 'number') { @@ -99,15 +96,14 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ } // drag css - $(document).bind('dragover', function (e) { - var dropZone = $('#dropAttach'), - timeout = window.dropZoneTimeout; - if (!timeout) { - dropZone.addClass('in'); - showUpload(); - } else { + var dropZone = $('#dropAttach'); + $("#uploadAttach").bind('dragover', function (e) { + e.preventDefault(); + var timeout = window.dropZoneTimeoutAttach; + if(timeout) { clearTimeout(timeout); } + var found = false, node = e.target; do { @@ -122,10 +118,9 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ } else { dropZone.removeClass('hover'); } - window.dropZoneTimeout = setTimeout(function () { - window.dropZoneTimeout = null; + window.dropZoneTimeoutAttach = setTimeout(function () { + window.dropZoneTimeoutAttach = null; dropZone.removeClass('in hover'); - hideUpload(); }, 100); }); } diff --git a/public/tinymce/plugins/leaui_image/public/js/for_editor.js b/public/tinymce/plugins/leaui_image/public/js/for_editor.js index bd1846f..27557b9 100644 --- a/public/tinymce/plugins/leaui_image/public/js/for_editor.js +++ b/public/tinymce/plugins/leaui_image/public/js/for_editor.js @@ -203,6 +203,7 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){ } else { clearTimeout(timeout); } + var found = false, node = e.target; do { diff --git a/public/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport.js b/public/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport.js index ed25895..9f304e0 100644 --- a/public/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport.js +++ b/public/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport.js @@ -14,6 +14,7 @@ (function (factory) { 'use strict'; + /* if (typeof define === 'function' && define.amd) { // Register as an anonymous AMD module: define(['jquery'], factory); @@ -21,6 +22,8 @@ // Browser globals: factory(window.jQuery); } + */ + factory(window.jQuery); }(function ($) { 'use strict'; diff --git a/public/tinymce/plugins/leaui_image/public/js/main.js b/public/tinymce/plugins/leaui_image/public/js/main.js index 86109c1..f740d88 100644 --- a/public/tinymce/plugins/leaui_image/public/js/main.js +++ b/public/tinymce/plugins/leaui_image/public/js/main.js @@ -739,6 +739,7 @@ var o = { // Automatically upload the file once it is added to the queue var jqXHR = data.submit(); }, + done: function(e, data) { if (data.result.Ok == true) {