JavaScript 翻转图像按钮到WYSIWYG编辑器,如TinyMCE,FCKEditor,Kupu

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript 翻转图像按钮到WYSIWYG编辑器,如TinyMCE,FCKEditor,Kupu相关的知识,希望对你有一定的参考价值。

/**
 * The following jQuery snippets allows use of roll over image effects in
 * WYSIWYG HTML editors such as TinyMCe, FCKEditor and Kupu.
 * 
 * 
 * 
 * Criteria which must be met:
 * 
 * 1) This javascript is linked in
 * 
 * 2) Image has two versions with URLs lik
 * 
 *    - images/my_button.gif
 *    
 *    - images/my_button_rollover.gif
 *    
 * 
 * 
 * 3) You will have WYSIWYG editor style Rollover image link (a.image-button-link) created
 * 
 * Creation of a button in WYSIWYG editor:
 * 
 * - Upload my_button.gif and my_button_rollover.gif to your site
 * 
 * - Place my_button.gif image to the document in your WYSIWYG editor
 * 
 * - Click image, make a link of it
 * 
 * - Apply style "Rollover image" to the link
 * 
 * - Reload the page
 * 
 * When the page is loaded, this snippet adds and loads hidden rollover
 * button images. 
 * 
 * 
 * 
 */function bootstrapImageButtonRollOvers() {
	jq("a.image-button-link").each( function() {
		var t= jq(this);		
		
		var img = t.find("img");
		
		var imageSrc= img.attr("src");
		
		// Construct URLs
		var hoverSrc = imageSrc;		
		
		var	filename = imageSrc
		var splitted = filename.split(".gif");
		hoverSrc = splitted[0] + "_rollover.gif" + splitted[1]; 
						
		// Create hidden hover image and roll over image holders
		var hoverButton = jq('<img src="' + hoverSrc + '" style="display:none" class="hover-image">');
		
		hoverButton.insertBefore(img);
				
		// Hide src image
		img.addClass("normal-image");

		var normalImage = img;
		var hoverImage = t.find(".hover-image");
								
		t.bind("mouseenter", function(e) {
			normalImage.css("display", "none");
			hoverImage.css("display", "inline");
			return true;
		});

		t.bind("mouseleave", function(e) {
			normalImage.css("display", "inline");
			hoverImage.css("display", "none");		
			return true;			
		});
	});
}

以上是关于JavaScript 翻转图像按钮到WYSIWYG编辑器,如TinyMCE,FCKEditor,Kupu的主要内容,如果未能解决你的问题,请参考以下文章

PHP 添加按钮到WordPress wysiwyg编辑器

如何在 JavaScript 中水平翻转图像

从 SummerNote WYSIWYG Bootstrap 生成的图像损坏

JavaScript 图像翻转(DOM)

JavaScript MooTools图像翻转

HTML 没有javascript的图像翻转()