radeditortestmodule.js

来自「Telerik是很大的第三方软件制造商」· JavaScript 代码 · 共 42 行

JS
42
字号
/*--------------RadEditorTestModule module------------------------------*/
RadEditorTestModule.prototype = new RadEditorModuleBase();
RadEditorTestModule.prototype.base = RadEditorModuleBase.prototype.constructor;

/* Constructor - the module receives a moduleArgs object that helps for the intialization. You need to pass it to the base constuctor.
	this.Editor - the editor object	
	this.Localization  - the localization object 
	this.Document  - the document obect that is used to create dynamic HTML elements						
	this.TopElement - the module top element that gets shown when the module is made visible.	
	this.IsEnabled - shows whether the module is currently enabled.
 */
function RadEditorTestModule (moduleArgs)
{		
	moduleArgs.ModuleElement = moduleArgs.Document.createElement ("DIV");
	this.base(moduleArgs);				
};


/* Implement the OnCreate method which is called before the module is first shown */
RadEditorTestModule.prototype.OnCreate = function () 
{
	var selfPointer = this;		
	this.AttachEventHandler("RADEVENT_SEL_CHANGED",  function (){ selfPointer.DoSomething(); });
	this.DoSomething();
	
};

/* A method that does the actual work - it is usually attached to the "selection changed" editor event */
RadEditorTestModule.prototype.DoSomething = function ()
{		
	if (!this.IsEnabled) return;
			
	var span = this.Document.createElement ("SPAN");
	span.innerHTML = this.Editor.GetHtml();
	
	var imageCount = span.getElementsByTagName("IMG").length;
	var tableCount = span.getElementsByTagName("TABLE").length;
		
	this.ModuleElement.innerHTML = "TEST MODULE: Images: " + imageCount + " Tables: " + tableCount;
	this.ModuleElement.style.border = "1px solid blue";
	this.ModuleElement.style.backgroundColor = "yellow";
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?