| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 | 
							- /*******************************************************************************
 
- * KindEditor - WYSIWYG HTML Editor for Internet
 
- * Copyright (C) 2006-2011 kindsoft.net
 
- *
 
- * @author Roddy <luolonghao@gmail.com>
 
- * @site http://www.kindsoft.net/
 
- * @licence http://www.kindsoft.net/license.php
 
- *******************************************************************************/
 
- KindEditor.plugin('flash', function(K) {
 
- 	var self = this, name = 'flash', lang = self.lang(name + '.'),
 
- 		allowFlashUpload = K.undef(self.allowFlashUpload, true),
 
- 		allowFileManager = K.undef(self.allowFileManager, false),
 
- 		uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
 
- 	self.plugin.flash = {
 
- 		edit : function() {
 
- 			var html = [
 
- 				'<div style="padding:10px 20px;">',
 
- 				//url
 
- 				'<div class="ke-dialog-row">',
 
- 				'<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
 
- 				'<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" />  ',
 
- 				'<input type="button" class="ke-upload-button" value="' + lang.upload + '" />  ',
 
- 				'<span class="ke-button-common ke-button-outer">',
 
- 				'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
 
- 				'</span>',
 
- 				'</div>',
 
- 				//width
 
- 				'<div class="ke-dialog-row">',
 
- 				'<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
 
- 				'<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" /> ',
 
- 				'</div>',
 
- 				//height
 
- 				'<div class="ke-dialog-row">',
 
- 				'<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
 
- 				'<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" /> ',
 
- 				'</div>',
 
- 				'</div>'
 
- 			].join('');
 
- 			var dialog = self.createDialog({
 
- 				name : name,
 
- 				width : 450,
 
- 				height : 200,
 
- 				title : self.lang(name),
 
- 				body : html,
 
- 				yesBtn : {
 
- 					name : self.lang('yes'),
 
- 					click : function(e) {
 
- 						var url = K.trim(urlBox.val()),
 
- 							width = widthBox.val(),
 
- 							height = heightBox.val();
 
- 						if (url == 'http://' || K.invalidUrl(url)) {
 
- 							alert(self.lang('invalidUrl'));
 
- 							urlBox[0].focus();
 
- 							return;
 
- 						}
 
- 						if (!/^\d*$/.test(width)) {
 
- 							alert(self.lang('invalidWidth'));
 
- 							widthBox[0].focus();
 
- 							return;
 
- 						}
 
- 						if (!/^\d*$/.test(height)) {
 
- 							alert(self.lang('invalidHeight'));
 
- 							heightBox[0].focus();
 
- 							return;
 
- 						}
 
- 						var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
 
- 								src : url,
 
- 								type : K.mediaType('.swf'),
 
- 								width : width,
 
- 								height : height,
 
- 								quality : 'high'
 
- 							});
 
- 						self.insertHtml(html).hideDialog().focus();
 
- 					}
 
- 				}
 
- 			}),
 
- 			div = dialog.div,
 
- 			urlBox = K('[name="url"]', div),
 
- 			viewServerBtn = K('[name="viewServer"]', div),
 
- 			widthBox = K('[name="width"]', div),
 
- 			heightBox = K('[name="height"]', div);
 
- 			urlBox.val('http://');
 
- 			if (allowFlashUpload) {
 
- 				var uploadbutton = K.uploadbutton({
 
- 					button : K('.ke-upload-button', div)[0],
 
- 					fieldName : 'imgFile',
 
- 					url : K.addParam(uploadJson, 'dir=flash'),
 
- 					afterUpload : function(data) {
 
- 						dialog.hideLoading();
 
- 						if (data.error === 0) {
 
- 							var url = K.formatUrl(data.url, 'absolute');
 
- 							urlBox.val(url);
 
- 							if (self.afterUpload) {
 
- 								self.afterUpload.call(self, url);
 
- 							}
 
- 							alert(self.lang('uploadSuccess'));
 
- 						} else {
 
- 							alert(data.message);
 
- 						}
 
- 					},
 
- 					afterError : function(html) {
 
- 						dialog.hideLoading();
 
- 						self.errorDialog(html);
 
- 					}
 
- 				});
 
- 				uploadbutton.fileBox.change(function(e) {
 
- 					dialog.showLoading(self.lang('uploadLoading'));
 
- 					uploadbutton.submit();
 
- 				});
 
- 			} else {
 
- 				K('.ke-upload-button', div).hide();
 
- 				urlBox.width(250);
 
- 			}
 
- 			if (allowFileManager) {
 
- 				viewServerBtn.click(function(e) {
 
- 					self.loadPlugin('filemanager', function() {
 
- 						self.plugin.filemanagerDialog({
 
- 							viewType : 'LIST',
 
- 							dirName : 'flash',
 
- 							clickFn : function(url, title) {
 
- 								if (self.dialogs.length > 1) {
 
- 									K('[name="url"]', div).val(url);
 
- 									self.hideDialog();
 
- 								}
 
- 							}
 
- 						});
 
- 					});
 
- 				});
 
- 			} else {
 
- 				viewServerBtn.hide();
 
- 			}
 
- 			var img = self.plugin.getSelectedFlash();
 
- 			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);
 
- 			}
 
- 			urlBox[0].focus();
 
- 			urlBox[0].select();
 
- 		},
 
- 		'delete' : function() {
 
- 			self.plugin.getSelectedFlash().remove();
 
- 		}
 
- 	};
 
- 	self.clickToolbar(name, self.plugin.flash.edit);
 
- });
 
 
  |