dever 6 years ago
parent
commit
aee6e6612b

+ 62 - 10
assets/lib/kindeditor/kindeditor-all-min.js

@@ -5859,7 +5859,7 @@ _plugin('core', function(K) {
 	};
 	self.plugin.getSelectedImage = function() {
 		return _getImageFromRange(self.edit.cmd.range, function(img) {
-			return !/^ke-\w+$/i.test(img[0].className);
+			return !/^ke-\w+$/i.test(img[0].className) && !img[0].getAttribute('data-key') && !img[0].getAttribute('data-applet') && !img[0].getAttribute('data-file');
 		});
 	};
 	self.plugin.getSelectedFlash = function() {
@@ -5869,7 +5869,12 @@ _plugin('core', function(K) {
 	};
 	self.plugin.getSelectedMedia = function() {
 		return _getImageFromRange(self.edit.cmd.range, function(img) {
-			return img[0].className == 'ke-media' || img[0].className == 'ke-rm';
+			return img[0].className == 'ke-media' || img[0].className == 'ke-rm' || img[0].getAttribute('data-file');
+		});
+	};
+	self.plugin.getSelectedDiy = function() {
+		return _getImageFromRange(self.edit.cmd.range, function(img) {
+			return img[0].getAttribute('data-applet') || img[0].getAttribute('data-key');
 		});
 	};
 	self.plugin.getSelectedAnchor = function() {
@@ -5877,7 +5882,7 @@ _plugin('core', function(K) {
 			return img[0].className == 'ke-anchor';
 		});
 	};
-	_each('link,image,flash,media,anchor'.split(','), function(i, name) {
+	_each('diy,link,image,flash,media,anchor'.split(','), function(i, name) {
 		var uName = name.charAt(0).toUpperCase() + name.substr(1);
 		_each('edit,delete'.split(','), function(j, val) {
 			self.addContextmenu({
@@ -7704,6 +7709,45 @@ KindEditor.plugin('image', function(K) {
 	self.clickToolbar(name, self.plugin.image.edit);
 });
 
+
+KindEditor.plugin('diy', function(K) {
+	var self = this, name = 'diy';
+	self.plugin.diy = {
+		edit : function() {
+			var value = self.plugin.getSelectedDiy();
+			if (value.attr('data-applet')) {
+				$('.update_show_editor').each(function(i)
+				{
+					var key = $(this).attr('key');
+					if (key.indexOf('http://') > -1) {
+						$(this).attr('data-value', value.attr('data-applet'));
+						$(this).click();
+						$(this).attr('data-value', '');
+					}
+				})
+			} else if (value.attr('data-key')) {
+				var data_key = value.attr('data-key');
+				$('.upload_show_editor').each(function(i)
+				{
+					var key = $(this).attr('key');
+					if (key == data_key) {
+						$(this).attr('data-value', value.attr('data-id'));
+						$(this).click();
+						$(this).attr('data-value', '');
+					}
+				})
+			}
+		},
+		'delete' : function() {
+			var target = self.plugin.getSelectedDiy();
+			if (target.parent().name == 'a') {
+				target = target.parent();
+			}
+			target.remove();
+			self.addBookmark();
+		}
+	};
+});
 /*******************************************************************************
 * KindEditor - WYSIWYG HTML Editor for Internet
 * Copyright (C) 2006-2011 kindsoft.net
@@ -8206,13 +8250,13 @@ KindEditor.plugin('media', function(K) {
 				viewCoverServerBtn.click(function(e) {
 
 					var clickFn = function(url, title, id) {
-						K('[name="cover_url"]', div).val(url);
+						coverUrlBox.val(url);
 						if (self.afterSelectFile) {
 							self.afterSelectFile.call(self, url);
 						}
 					};
 
-					var cur = K('[name="cover_url"]', div).val();
+					var cur = coverUrlBox.val();
 					editorShowUpload(cur, self.uploadJson.replace('save.kindeditor', 'view.files'), '图库', clickFn, this);
 
 					/*
@@ -8236,11 +8280,19 @@ KindEditor.plugin('media', function(K) {
 			}
 			var img = self.plugin.getSelectedMedia();
 			if (img) {
-				var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
-				urlBox.val(attrs.src);
-				widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
-				heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
-				autostartBox[0].checked = (attrs.autostart === 'true');
+				if (img.attr('data-file')) {
+					var temp = img.attr('data-file').split('||');
+					nameBox.val(temp[1]);
+					whBox.val(temp[2]);
+					urlBox.val(temp[0]);
+					coverUrlBox.val(img.attr('src'));
+				} else {
+					var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
+					urlBox.val(attrs.src);
+					widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
+					heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
+					autostartBox[0].checked = (attrs.autostart === 'true');
+				}
 			}
 			urlBox[0].focus();
 			urlBox[0].select();

+ 2 - 0
assets/lib/kindeditor/lang/zh-CN.js

@@ -65,6 +65,8 @@ KindEditor.lang({
 	yes : '确定',
 	no : '取消',
 	close : '关闭',
+	editDiy : '编辑',
+	deleteDiy : '删除',
 	editImage : '图片属性',
 	deleteImage : '删除图片',
 	editFlash : 'Flash属性',

+ 7 - 2
assets/lib/layui/upload.js

@@ -38,7 +38,7 @@ function showUpload(i,e,key,url,assets,type)
 		  content: html,
 		  area: '800px'
 		};
-		e.click(function()
+		e.unbind('click').bind('click', function()
 		{
 			url = url.replace('save', 'view');
 			showUploadE = e;
@@ -48,8 +48,13 @@ function showUpload(i,e,key,url,assets,type)
 			showUploadType = type;
 			showUploadUrl = url;
 			var cur = $('#' + showUploadE.attr('v')).val();
-			$.getJSON(url, {json:1,key:key,cur:cur}, function(t)
+			var value = '';
+			if (e.attr('data-value')) {
+				value = e.attr('data-value');
+			}
+			$.getJSON(url, {json:1,key:key,cur:cur,value:value}, function(t)
 			{
+				layer.closeAll();
 				config.content = t.data;
 				showUploadIndex = layer.open(config);
 			})

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

@@ -79,7 +79,11 @@ function initUpdate()
 				var url = $(this).attr('key');
 				var value = $(this).attr('editor_id');
 				var title = $(this).attr('value');
-				$.get(url, {}, function(t)
+				var send = '';
+				if ($(this).attr('data-value')) {
+					send = $(this).attr('data-value');
+				}
+				$.post(url, {value:send}, function(t)
 				{
 					var func = function() {
 						var url = $('#editor_applet_pic').val();