PageRenderTime 25ms CodeModel.GetById 11ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/source/Plug-in/kind/plugins/anchor/anchor.js

http://prosporous.googlecode.com/
JavaScript | 46 lines | 37 code | 1 blank | 8 comment | 1 complexity | 58fc7fc243214eb0e10199309a7f6420 MD5 | raw file
 1/*******************************************************************************
 2* KindEditor - WYSIWYG HTML Editor for Internet
 3* Copyright (C) 2006-2011 kindsoft.net
 4*
 5* @author Roddy <luolonghao@gmail.com>
 6* @site http://www.kindsoft.net/
 7* @licence http://www.kindsoft.net/license.php
 8*******************************************************************************/
 9
10KindEditor.plugin('anchor', function(K) {
11	var self = this, name = 'anchor', lang = self.lang(name + '.');
12	self.plugin.anchor = {
13		edit : function() {
14			var html = ['<div style="padding:10px 20px;">',
15					'<div class="ke-dialog-row">',
16					'<label for="keName">' + lang.name + '</label>',
17					'<input class="ke-input-text" type="text" id="keName" name="name" value="" style="width:100px;" />',
18					'</div>',
19					'</div>'].join('');
20			var dialog = self.createDialog({
21				name : name,
22				width : 300,
23				title : self.lang(name),
24				body : html,
25				yesBtn : {
26					name : self.lang('yes'),
27					click : function(e) {
28						self.insertHtml('<a name="' + nameBox.val() + '">').hideDialog().focus();
29					}
30				}
31			});
32			var div = dialog.div,
33				nameBox = K('input[name="name"]', div);
34			var img = self.plugin.getSelectedAnchor();
35			if (img) {
36				nameBox.val(unescape(img.attr('data-ke-name')));
37			}
38			nameBox[0].focus();
39			nameBox[0].select();
40		},
41		'delete' : function() {
42			self.plugin.getSelectedAnchor().remove();
43		}
44	};
45	self.clickToolbar(name, self.plugin.anchor.edit);
46});