Merge branch 'develop-feature'

This commit is contained in:
life
2014-09-22 00:43:50 +08:00
6 changed files with 29 additions and 27 deletions

View File

@ -1045,10 +1045,11 @@ require.config({
'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor', 'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor',
'attachment_upload': 'js/app/attachment_upload', 'attachment_upload': 'js/app/attachment_upload',
'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget', '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: { shim: {
'fileupload': {deps: ['jquery.ui.widget']} 'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']}
} }
}); });
require(['leaui_image'], function(leaui_image) { require(['leaui_image'], function(leaui_image) {

View File

@ -1045,10 +1045,11 @@ require.config({
'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor', 'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor',
'attachment_upload': 'js/app/attachment_upload', 'attachment_upload': 'js/app/attachment_upload',
'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget', '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: { shim: {
'fileupload': {deps: ['jquery.ui.widget']} 'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']}
} }
}); });
require(['leaui_image'], function(leaui_image) { require(['leaui_image'], function(leaui_image) {

View File

@ -2,9 +2,6 @@
// 依赖note // 依赖note
var urlPrefix = window.location.protocol + "//" + window.location.host; var urlPrefix = window.location.protocol + "//" + window.location.host;
define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
// var editor = tinymce.activeEditor;
// var dom = editor.dom;
var initUploader = function() { var initUploader = function() {
var $msg = $('#attachUploadMsg'); var $msg = $('#attachUploadMsg');
@ -36,23 +33,28 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
tpl.append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>'); tpl.append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>');
// Add the HTML to the UL element // Add the HTML to the UL element
tpl.appendTo($msg); $msg.html(tpl);
data.context = $msg; data.context = $msg;
// Automatically upload the file once it is added to the queue // Automatically upload the file once it is added to the queue
var jqXHR; var jqXHR;
setTimeout(function() { setTimeout(function() {
jqXHR = data.submit(); jqXHR = data.submit();
}, 0); }, 10);
}, },
/*
progress: function (e, data) {
},
*/
done: function(e, data) { done: function(e, data) {
if (data.result.Ok == true) { if (data.result.Ok == true) {
data.context.remove(); data.context.html("");
Attach.addAttach(data.result.Item); Attach.addAttach(data.result.Item);
} else { } else {
var re = data.result; var re = data.result;
data.context.empty(); data.context.html("");
var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>'); var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');
tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg); tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
data.context.html(tpl); data.context.html(tpl);
@ -65,7 +67,7 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
$("#uploadAttachMsg").scrollTop(1000); $("#uploadAttachMsg").scrollTop(1000);
}, },
fail: function(e, data) { fail: function(e, data) {
data.context.empty(); data.context.html("");
var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>'); var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');
tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown); tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
data.context.html(tpl); 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 // Helper function that formats the file sizes
function formatFileSize(bytes) { function formatFileSize(bytes) {
if (typeof bytes !== 'number') { if (typeof bytes !== 'number') {
@ -99,15 +96,14 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
} }
// drag css // drag css
$(document).bind('dragover', function (e) { var dropZone = $('#dropAttach');
var dropZone = $('#dropAttach'), $("#uploadAttach").bind('dragover', function (e) {
timeout = window.dropZoneTimeout; e.preventDefault();
if (!timeout) { var timeout = window.dropZoneTimeoutAttach;
dropZone.addClass('in'); if(timeout) {
showUpload();
} else {
clearTimeout(timeout); clearTimeout(timeout);
} }
var found = false, var found = false,
node = e.target; node = e.target;
do { do {
@ -122,10 +118,9 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
} else { } else {
dropZone.removeClass('hover'); dropZone.removeClass('hover');
} }
window.dropZoneTimeout = setTimeout(function () { window.dropZoneTimeoutAttach = setTimeout(function () {
window.dropZoneTimeout = null; window.dropZoneTimeoutAttach = null;
dropZone.removeClass('in hover'); dropZone.removeClass('in hover');
hideUpload();
}, 100); }, 100);
}); });
} }

View File

@ -203,6 +203,7 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
} else { } else {
clearTimeout(timeout); clearTimeout(timeout);
} }
var found = false, var found = false,
node = e.target; node = e.target;
do { do {

View File

@ -14,6 +14,7 @@
(function (factory) { (function (factory) {
'use strict'; 'use strict';
/*
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module: // Register as an anonymous AMD module:
define(['jquery'], factory); define(['jquery'], factory);
@ -21,6 +22,8 @@
// Browser globals: // Browser globals:
factory(window.jQuery); factory(window.jQuery);
} }
*/
factory(window.jQuery);
}(function ($) { }(function ($) {
'use strict'; 'use strict';

View File

@ -740,6 +740,7 @@ var o = {
var jqXHR = data.submit(); var jqXHR = data.submit();
}, },
done: function(e, data) { done: function(e, data) {
if (data.result.Ok == true) { if (data.result.Ok == true) {
data.context.remove(); data.context.remove();