dever há 7 anos atrás
pai
commit
40a441c376

+ 78 - 15
assets/lib/kindeditor/kindeditor-all-min.js

@@ -4902,7 +4902,7 @@ function KEditor(options) {
 	setOption('width', _addUnit(self.width));
 	setOption('height', _addUnit(self.height));
 	if (_MOBILE && (!_IOS || _V < 534)) {
-		self.designMode = false;
+		//self.designMode = false;
 	}
 	self.srcElement = se;
 	self.initContent = '';
@@ -6242,7 +6242,7 @@ KindEditor.lang({
 	fullscreen : '全屏显示',
 	about : '关于',
 	print : '打印(Ctrl+P)',
-	filemanager : '文件空间',
+	filemanager : '文件',
 	code : '插入程序代码',
 	map : 'Google地图',
 	baidumap : '百度地图',
@@ -6333,7 +6333,8 @@ KindEditor.lang({
 	'image.imgTitle' : '图片说明',
 	'image.upload' : '浏览...',
 	'image.viewServer' : '图片空间',
-	'multiimage.uploadDesc' : '允许用户同时上传<%=uploadLimit%>张图片,单张图片容量不超过<%=sizeLimit%>',
+	//'multiimage.uploadDesc' : '允许用户同时上传<%=uploadLimit%>张图片,单张图片容量不超过<%=sizeLimit%>',
+	'multiimage.uploadDesc' : '',
 	'multiimage.startUpload' : '开始上传',
 	'multiimage.clearAll' : '全部清空',
 	'multiimage.insertAll' : '全部插入',
@@ -7000,6 +7001,10 @@ KindEditor.plugin('filemanager', function(K) {
 			'<a class="ke-inline-block" name="moveupLink" href="javascript:;">' + lang.moveup + '</a>',
 			'</div>',
 			'<div class="ke-right">',
+			'标签 <input type="text" style="width:100px;" value="" name="viewTag">',
+			'分类 <select class="ke-inline-block" name="viewCate">',
+			'',
+			'</select> ',
 			lang.viewType + ' <select class="ke-inline-block" name="viewType">',
 			'<option value="VIEW">' + lang.viewImage + '</option>',
 			'<option value="LIST">' + lang.listImage + '</option>',
@@ -7027,10 +7032,18 @@ KindEditor.plugin('filemanager', function(K) {
 		moveupImg = K('[name="moveupImg"]', div),
 		moveupLink = K('[name="moveupLink"]', div),
 		viewServerBtn = K('[name="viewServer"]', div),
+		viewCateBox = K('[name="viewCate"]', div),
+		viewTagBox = K('[name="viewTag"]', div),
 		viewTypeBox = K('[name="viewType"]', div),
 		orderTypeBox = K('[name="orderType"]', div);
-		function reloadPage(path, order, func) {
+		function reloadPage(path, order, func, cate, tag) {
 			var param = 'path=' + path + '&order=' + order + '&dir=' + dirName;
+			if (cate) {
+				param += '&cate=' + cate;
+			}
+			if (tag) {
+				param += '&tag=' + tag;
+			}
 			dialog.showLoading(self.lang('ajaxLoading'));
 			K.ajax(K.addParam(fileManagerJson, param + '&' + new Date().getTime()), function(data) {
 				dialog.hideLoading();
@@ -7039,19 +7052,19 @@ KindEditor.plugin('filemanager', function(K) {
 		}
 		var elList = [];
 		function bindEvent(el, result, data, createFunc) {
-			var fileUrl = K.formatUrl(result.current_url + data.filename, 'absolute'),
-				dirPath = encodeURIComponent(result.current_dir_path + data.filename + '/');
+			var fileUrl = K.formatUrl(result.current_url + data.file, 'absolute'),
+				dirPath = encodeURIComponent(result.current_dir_path + data.path + '/');
 			if (data.is_dir) {
 				el.click(function(e) {
 					reloadPage(dirPath, orderTypeBox.val(), createFunc);
 				});
 			} else if (data.is_photo) {
 				el.click(function(e) {
-					clickFn.call(this, fileUrl, data.filename);
+					clickFn.call(this, fileUrl, data.file);
 				});
 			} else {
 				el.click(function(e) {
-					clickFn.call(this, fileUrl, data.filename);
+					clickFn.call(this, fileUrl, data.file);
 				});
 			}
 			elList.push(el);
@@ -7070,13 +7083,14 @@ KindEditor.plugin('filemanager', function(K) {
 			}
 			function changeFunc() {
 				if (viewTypeBox.val() == 'VIEW') {
-					reloadPage(result.current_dir_path, orderTypeBox.val(), createView);
+					reloadPage(result.current_dir_path, orderTypeBox.val(), createView, viewCateBox.val(), viewTagBox.val());
 				} else {
-					reloadPage(result.current_dir_path, orderTypeBox.val(), createList);
+					reloadPage(result.current_dir_path, orderTypeBox.val(), createList, viewCateBox.val(), viewTagBox.val());
 				}
 			}
 			viewTypeBox.change(changeFunc);
 			orderTypeBox.change(changeFunc);
+			viewCateBox.change(changeFunc);
 			bodyDiv.html('');
 		}
 		function createList(result) {
@@ -7125,7 +7139,7 @@ KindEditor.plugin('filemanager', function(K) {
 						K(this).removeClass('ke-on');
 					});
 				div.append(photoDiv);
-				var fileUrl = result.current_url + data.filename,
+				var fileUrl = result.current_url + data.file,
 					iconUrl = data.is_dir ? imgPath + 'folder-64.gif' : (data.is_photo ? fileUrl : imgPath + 'file-64.gif');
 				var img = K('<img src="' + iconUrl + '" width="80" height="80" alt="' + data.filename + '" />');
 				if (!data.is_dir || data.has_file) {
@@ -7262,6 +7276,18 @@ KindEditor.plugin('flash', function(K) {
 			}
 			if (allowFileManager) {
 				viewServerBtn.click(function(e) {
+
+					var clickFn = function(url, title) {
+						K('[name="url"]', div).val(url);
+						if (self.afterSelectFile) {
+							self.afterSelectFile.call(self, url);
+						}
+					};
+
+					var cur = K('[name="url"]', div).val();
+					editorShowUpload(cur, self.fileManagerJson, 'flash库', clickFn, this);
+
+					/*
 					self.loadPlugin('filemanager', function() {
 						self.plugin.filemanagerDialog({
 							viewType : 'LIST',
@@ -7277,6 +7303,7 @@ KindEditor.plugin('flash', function(K) {
 							}
 						});
 					});
+					*/
 				});
 			} else {
 				viewServerBtn.hide();
@@ -7502,6 +7529,18 @@ KindEditor.plugin('image', function(K) {
 		});
 		if (allowFileManager) {
 			viewServerBtn.click(function(e) {
+
+				//clickFn.call(this, fileUrl, data.file);
+				var clickFn = function(url, title) {
+					K('[name="url"]', div).val(url);
+					if (self.afterSelectFile) {
+						self.afterSelectFile.call(self, url);
+					}
+				};
+
+				var cur = K('[name="url"]', div).val();
+				editorShowUpload(cur, self.uploadJson.replace('save.kindeditor', 'view.files'), '图库', clickFn, this);
+				/*
 				self.loadPlugin('filemanager', function() {
 					self.plugin.filemanagerDialog({
 						viewType : 'VIEW',
@@ -7517,6 +7556,7 @@ KindEditor.plugin('image', function(K) {
 						}
 					});
 				});
+				*/
 			});
 		} else {
 			viewServerBtn.hide();
@@ -7708,21 +7748,31 @@ KindEditor.plugin('insertfile', function(K) {
 		}
 		if (allowFileManager) {
 			viewServerBtn.click(function(e) {
+
+				var clickFn = function(url, title) {
+					K('[name="url"]', div).val(url);
+					if (self.afterSelectFile) {
+						self.afterSelectFile.call(self, url);
+					}
+				};
+
+				var cur = K('[name="url"]', div).val();
+				editorShowUpload(cur, self.uploadJson.replace('save.kindeditor', 'view.files'), '文件库', clickFn, this);
+
+				/*
 				self.loadPlugin('filemanager', function() {
 					self.plugin.filemanagerDialog({
 						viewType : 'LIST',
 						dirName : 'file',
 						clickFn : function(url, title) {
 							if (self.dialogs.length > 1) {
-								K('[name="url"]', div).val(url);
-								if (self.afterSelectFile) {
-									self.afterSelectFile.call(self, url);
-								}
+								
 								self.hideDialog();
 							}
 						}
 					});
 				});
+				*/
 			});
 		} else {
 			viewServerBtn.hide();
@@ -7968,6 +8018,17 @@ KindEditor.plugin('media', function(K) {
 			}
 			if (allowFileManager) {
 				viewServerBtn.click(function(e) {
+
+					var clickFn = function(url, title) {
+						K('[name="url"]', div).val(url);
+						if (self.afterSelectFile) {
+							self.afterSelectFile.call(self, url);
+						}
+					};
+
+					var cur = K('[name="url"]', div).val();
+					editorShowUpload(cur, self.fileManagerJson, '音视频库', clickFn, this);
+					/*
 					self.loadPlugin('filemanager', function() {
 						self.plugin.filemanagerDialog({
 							viewType : 'LIST',
@@ -7983,6 +8044,7 @@ KindEditor.plugin('media', function(K) {
 							}
 						});
 					});
+					*/
 				});
 			} else {
 				viewServerBtn.hide();
@@ -8201,6 +8263,7 @@ KindEditor.plugin('multiimage', function(K) {
 	self.plugin.multiImageDialog = function(options) {
 		var clickFn = options.clickFn,
 			uploadDesc = K.tmpl(lang.uploadDesc, {uploadLimit : imageUploadLimit, sizeLimit : imageSizeLimit});
+			uploadDesc = '';
 		var html = [
 			'<div style="padding:20px;">',
 			'<div class="swfupload">',

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
assets/lib/layui/lay/modules/upload.js


+ 185 - 49
assets/lib/layui/upload.js

@@ -1,7 +1,127 @@
 var upload_pic = [];
 var upload_file = [];
 var upload = [];
+var showUploadE;
+var showUploadUrl;
+var showUploadType = 1;
+var showUploadCall = false;
+var showUploadThis = false;
+var xhrOnProgress=function(fun) {
+	xhrOnProgress.onprogress = fun; //绑定监听
+ //使用闭包实现监听绑
+	return function() {
+	//通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
+		var xhr = $.ajaxSettings.xhr();
+		 //判断监听函数是否为函数
+		  if (typeof xhrOnProgress.onprogress !== 'function')
+		       return xhr;
+		   //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
+		    if (xhrOnProgress.onprogress && xhr.upload) {
+		          xhr.upload.onprogress = xhrOnProgress.onprogress;
+		    }
+		    return xhr;
+	}
+}
+
+function showUpload(i,e,key,url,assets)
+{
+	layui.use(['upload','layer','element'], function() {
+		var html = '';
+		var layer = layui.layer;
+		var config = {
+		  type: 0,
+		  title: e.attr('value'),
+		  shade: 0,
+		  shadeClose : true,
+		  content: html,
+		  area: '800px'
+		};
+		e.click(function()
+		{
+			url = url.replace('save', 'view');
+			showUploadE = e;
+			showUploadType = 1;
+			showUploadUrl = url;
+			var cur = $('#' + showUploadE.attr('v')).val();
+			$.getJSON(url, {json:1,key:key,cur:cur}, function(t)
+			{
+				config.content = t.data;
+				layer.open(config);
+			})
+		})
+	});
+}
+
+function editorShowUpload(cur, url, title, func, self)
+{
+	showUploadType = 2;
+	showUploadCall = func;
+	showUploadThis = self;
+	layui.use(['upload','layer','element'], function() {
+		var html = '';
+		var layer = layui.layer;
+		var config = {
+		  type: 0,
+		  title: title,
+		  shade: 0,
+		  shadeClose : true,
+		  content: html,
+		  area: '800px'
+		};
+		url = url.replace('save', 'view');
+		showUploadUrl = url;
+		$.getJSON(url, {json:1,cur:cur}, function(t)
+		{
+			config.content = t.data;
+			layer.open(config);
+		})
+	});
+}
+
+function showUploadFilesSet(e, name, url)
+{
+	$('.layui-anim-yes').addClass('layui-anim-no');
+	$('.layui-anim-yes').removeClass('layui-anim-yes');
+	e.parent().removeClass('layui-anim-no');
+	e.parent().addClass('layui-anim-yes');
+
+	$('.file_cur').val(url);
+	if (showUploadType == 1) {
+		var value = showUploadE.attr('v');
+		loadUploadSet(showUploadE, value, {name:name,url:url});
+	} else if (showUploadType == 2) {
+		showUploadCall.call(showUploadThis, url, name);
+		layer.closeAll();
+	}
+}
+
+function showUploadFilesSearch(e)
+{
+	var p = e.parent();
+	var pg = p.find('.file_pg').val();
+	var key = p.find('.file_key').val();
+	var name = p.find('.file_filename').val();
+	var tag = p.find('.file_tag').val();
+	var cate = p.find('.file_cate').val();
+	var cur = p.find('.file_cur').val();
+
+	var url = showUploadUrl;
+
+	showUploadFiles(url, name, key, cate, tag, cur, pg);
+}
 
+function showUploadFiles(url, name, key, cate, tag, cur, pg)
+{
+	if (!pg) {
+		pg = 1;
+	}
+	$.getJSON(url, {json:1,key:key, name:name,cate:cate, tag:tag, pg:pg, cur:cur}, function(t)
+	{
+		var t = '<div>' + t.data + '</div>';
+        html = $(t).find('#component-anim').html();
+		$("#component-anim").html(html);
+	})
+}
 function loadUpload(i,e,key,url,assets)
 {
 	var value = e.attr('v');
@@ -13,9 +133,10 @@ function loadUpload(i,e,key,url,assets)
 	upload_file[value] = [];
 
 	var id = e.attr('id');
-	layui.use(['upload','layer'], function() {
+	layui.use(['upload','layer','element'], function() {
 		var layer = layui.layer;
 		var layuiUpload = layui.upload;
+		var element = layui.element;
 		var uploadInst = layuiUpload.render({
 			elem: '#' + id
 			,data: {'key' : key}
@@ -23,59 +144,24 @@ function loadUpload(i,e,key,url,assets)
 			,url: url
 			,multiple: true
 			,accept:'file'
+			,xhr:xhrOnProgress
+			,progress:function(value){//上传进度回调 value进度值
+				$('#' + id + '_progress').show();
+			    element.progress(id + '_progress', value+'%')//设置页面进度条
+			}
 			,choose: function(obj){
-				layer.load();
+				element.progress(id + '_progress', '0%')
+				//layer.load();
 			}
 			,done: function(data) {
-				layer.closeAll('loading');
+				element.progress(id + '_progress', '0%')
+				$('#' + id + '_progress').hide();
+				//layer.closeAll('loading');
 				if (data.status == 1) {
-					var mul = e.attr('mul');
-					if (mul == 'yes') {
-						if (e.attr('t') == 'file') {
-							if (upload_file[value].length <= 0 && $("#" + value).val()) {
-								upload_file[value] = $("#" + value).val().split(',');
-							}
-
-							var m = $('.' +value+'_mul');
-							var i = m.find('li').eq(upload_file[value].length);
-							if (i.length) {
-								i.find('a').eq(0).html(data.name);
-							} else {
-								m.append('<li><a href="'+data.url+'" target="_blank" title="点此下载" >'+data.name+'</a>&nbsp;&nbsp;<a href="javascript:;" title="点此删除" style="color:red;" onclick="fileDel($(this), \''+value+'\')">[删除]</a></li>');
-							}
-
-							upload_file[value].push(data.url);
-
-							$("#" + value).val(upload_file.join(','));
-						} else {
-							if (upload_pic[value].length <= 0 && $("#" + value).val()) {
-								upload_pic[value] = $("#" + value).val().split(',');
-							}
-							var m = $('.' +value+'_mul');
-							var i = m.find('img').eq(upload_pic[value].length);
-							if (i.length) {
-								i.attr('src', data.url);
-							} else {
-								m.append('<a href="javascript:;" title="点此删除" onclick="picDel($(this), \''+value+'\')"><img src="'+data.url+'" width="150" style="margin-left:5px;" alt="点此删除"/></a>');
-							}
-							upload_pic[value].push(data.url);
-							$("#" + value).val(upload_pic[value].join(','));
-						}
-						
-					} else {
-						if (e.attr('t') == 'file') {
-							
-						} else {
-							$('#show_'+value).attr('src',data.url).show();
-							$('#show_'+value).click(function()
-							{
-								picDel($(this), value, 1);
-							})
-						}
-						$('#'+value).val(data.url);
-					}
+					loadUploadSet(e,value,data);
 				} else {
-					layer.msg(data.msg, {icon: 4});
+					element.progress(id + '_progress', '0%')
+					layer.alert(data.message);
 					return false;
 				}
 			}
@@ -85,6 +171,56 @@ function loadUpload(i,e,key,url,assets)
 		});
 	});
 }
+
+function loadUploadSet(e,value,data)
+{
+	var mul = e.attr('mul');
+	if (mul == 'yes') {
+		if (e.attr('t') == 'file') {
+			if (upload_file[value].length <= 0 && $("#" + value).val()) {
+				upload_file[value] = $("#" + value).val().split(',');
+			}
+
+			var m = $('.' +value+'_mul');
+			var i = m.find('li').eq(upload_file[value].length);
+			if (i.length) {
+				i.find('a').eq(0).html(data.name);
+			} else {
+				m.append('<li><a href="'+data.url+'" target="_blank" title="点此下载" >'+data.name+'</a>&nbsp;&nbsp;<a href="javascript:;" title="点此删除" style="color:red;" onclick="fileDel($(this), \''+value+'\')">[删除]</a></li>');
+			}
+
+			upload_file[value].push(data.url);
+
+			$("#" + value).val(upload_file.join(','));
+		} else {
+			if (upload_pic[value].length <= 0 && $("#" + value).val()) {
+				upload_pic[value] = $("#" + value).val().split(',');
+			}
+			var m = $('.' +value+'_mul');
+			var i = m.find('img').eq(upload_pic[value].length);
+			if (i.length) {
+				i.attr('src', data.url);
+			} else {
+				m.append('<a href="javascript:;" title="点此删除" onclick="picDel($(this), \''+value+'\')"><img src="'+data.url+'" width="150" style="margin-left:5px;" alt="点此删除"/></a>');
+			}
+			upload_pic[value].push(data.url);
+			$("#" + value).val(upload_pic[value].join(','));
+		}
+		
+	} else {
+		if (e.attr('t') == 'file') {
+			
+		} else {
+			$('#show_'+value).attr('src',data.url).show();
+			$('#show_'+value).unbind('click').bind('click', function()
+			{
+				picDel($(this), value, 1);
+			})
+		}
+		$('#'+value).val(data.url);
+	}
+}
+
 function picDel(e,v,s)
 {
 	if (confirm('确定要删除图片吗?')) {

+ 16 - 1
assets/lib/manage/main.js

@@ -320,7 +320,9 @@ function loadEditorParam(e)
 		filePostName : 'file',
 		dialogOffset : 0, //对话框距离页面顶部的位置,默认为0居中,
 		uploadJson : config.upload + '.kindeditor?key=' + key,
-		fileManagerJson : view + '.kindeditorFile?key=' + media,
+		fileManagerJson : view + '.files?key=' + media,
+		uploadLimit : 20,
+		sizeLimit : '50m',
 
 		items : [
 		        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
@@ -1546,6 +1548,19 @@ function image()
 			loadUpload(i,$(this),$(this).attr('key'),config.upload + '.start', config.lib + 'upload/');//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
 		})
 	}
+
+	if($(".upload_show").length)
+	{
+		$(".upload_show").each(function(i)
+		{
+			var parent = $(this).parent().parent();
+			if(parent.attr('id') && parent.attr('id').indexOf('-child-0') != -1)
+			{
+				return;
+			}
+			showUpload(i,$(this),$(this).attr('key'),config.upload + '.files', config.lib + 'upload/');//三个参数说明1:第几个上传框2:文件对象3:图片的基本配置标题
+		})
+	}
 }
 
 /**

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff