⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editimage.js

📁 WordPress是一个Blog程序,用它你可以架设完全属于你自己的Blog. 而WordPress现在的应用又不仅仅只是在Blog方面,因为其强大的扩展性,部分网站甚至已经开始使用WordPress
💻 JS
📖 第 1 页 / 共 2 页
字号:
var tinymce = null, tinyMCEPopup, tinyMCE;tinyMCEPopup = {	init: function() {		var t = this, w, ti, li, q, i, it;		li = ('' + document.location.search).replace(/^\?/, '').split('&');		q = {};		for (i=0; i<li.length; i++) {			it = li[i].split('=');			q[unescape(it[0])] = unescape(it[1]);		}		if (q.mce_rdomain)			document.domain = q.mce_rdomain;		// Find window & API		w = t.getWin();		tinymce = w.tinymce;		tinyMCE = w.tinyMCE;		t.editor = tinymce.EditorManager.activeEditor;		t.params = t.editor.windowManager.params;		// Setup local DOM		t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);		t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);	},	getWin : function() {		return window.dialogArguments || opener || parent || top;	},	getParam : function(n, dv) {		return this.editor.getParam(n, dv);	},	close : function() {		var t = this, win = t.getWin();		// To avoid domain relaxing issue in Opera		function close() {			win.tb_remove();			tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup		};		if (tinymce.isOpera)			win.setTimeout(close, 0);		else			close();	},	execCommand : function(cmd, ui, val, a) {		a = a || {};		a.skip_focus = 1;		this.restoreSelection();		return this.editor.execCommand(cmd, ui, val, a);	},	storeSelection : function() {		this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');	},	restoreSelection : function() {		var t = tinyMCEPopup;		if (tinymce.isIE)			t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);	}}tinyMCEPopup.init();var wpImage = {	preInit : function() {		// import colors stylesheet from parent		var win = tinyMCEPopup.getWin();		var styles = win.document.styleSheets;		for ( i = 0; i < styles.length; i++ ) {			var url = styles.item(i).href;			if ( url && url.indexOf('colors') != -1 )				document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );		}	},	I : function(e) {		return document.getElementById(e);	},	current : '',	link : '',	link_rel : '',	target_value : '',	current_size_sel : 's100',	width : '',	height : '',	align : '',	img_alt : '',	setTabs : function(tab) {		var t = this;		if ( 'current' == tab.className ) return false;		t.I('div_advanced').style.display = ( 'tab_advanced' == tab.id ) ? 'block' : 'none';		t.I('div_basic').style.display = ( 'tab_basic' == tab.id ) ? 'block' : 'none';		t.I('tab_basic').className = t.I('tab_advanced').className = '';		tab.className = 'current';		return false;	},	img_seturl : function(u) {		var t = this, rel = t.I('link_rel').value;		if ( 'current' == u ) {			t.I('link_href').value = t.current;			t.I('link_rel').value = t.link_rel;		} else {			t.I('link_href').value = t.link;			if ( rel ) {				rel = rel.replace( /attachment|wp-att-[0-9]+/gi, '' );				t.I('link_rel').value = tinymce.trim(rel);			}		}	},	imgAlignCls : function(v) {		var t = this, cls = t.I('img_classes').value;		t.I('img_demo').className = t.align = v;		cls = cls.replace( /align[^ "']+/gi, '' );		cls += (' ' + v);		cls = cls.replace( /\s+/g, ' ' ).replace( /^\s/, '' );		if ( 'aligncenter' == v ) {			t.I('hspace').value = '';			t.updateStyle('hspace');		}		t.I('img_classes').value = cls;	},	showSize : function(el) {		var t = this, demo = t.I('img_demo'), w = t.width, h = t.height, id = el.id || 's100', size;		size = parseInt(id.substring(1)) / 200;		demo.width = Math.round(w * size);		demo.height = Math.round(h * size);		t.showSizeClear();		el.style.borderColor = '#A3A3A3';		el.style.backgroundColor = '#E5E5E5';	},	showSizeSet : function() {		var t = this;		if ( (t.width * 1.3) > parseInt(t.preloadImg.width) ) {			var s130 = t.I('s130'), s120 = t.I('s120'), s110 = t.I('s110');			s130.onclick = s120.onclick = s110.onclick = null;			s130.onmouseover = s120.onmouseover = s110.onmouseover = null;			s130.style.color = s120.style.color = s110.style.color = '#aaa';		}	},	showSizeRem : function() {		var t = this, demo = t.I('img_demo'), f = document.forms[0];		demo.width = Math.round(f.width.value * 0.5);		demo.height = Math.round(f.height.value * 0.5);		t.showSizeClear();		t.I(t.current_size_sel).style.borderColor = '#A3A3A3';		t.I(t.current_size_sel).style.backgroundColor = '#E5E5E5';		return false;	},	showSizeClear : function() {		var divs = this.I('img_size').getElementsByTagName('div');		for ( i = 0; i < divs.length; i++ ) {			divs[i].style.borderColor = '#f1f1f1';			divs[i].style.backgroundColor = '#f1f1f1';		}	},	imgEditSize : function(el) {		var t = this, f = document.forms[0];		if ( ! t.preloadImg || ! t.preloadImg.width || ! t.preloadImg.height )	return;		var W = parseInt(t.preloadImg.width), H = parseInt(t.preloadImg.height), w = t.width || W, h = t.height || H, id = el.id || 's100';		size = parseInt(id.substring(1)) / 100;		w = Math.round(w * size);		h = Math.round(h * size);		f.width.value = Math.min(W, w);		f.height.value = Math.min(H, h);		t.current_size_sel = id;		t.demoSetSize();	},	demoSetSize : function(img) {		var demo = this.I('img_demo'), f = document.forms[0];		demo.width = f.width.value ? Math.round(f.width.value * 0.5) : '';		demo.height = f.height.value ? Math.round(f.height.value * 0.5) : '';	},	demoSetStyle : function() {		var f = document.forms[0], demo = this.I('img_demo'), dom = tinyMCEPopup.editor.dom;		if (demo) {			dom.setAttrib(demo, 'style', f.img_style.value);			dom.setStyle(demo, 'width', '');			dom.setStyle(demo, 'height', '');		}	},	origSize : function() {		var t = this, f = document.forms[0], el = t.I('s100');		f.width.value = t.width = t.preloadImg.width;		f.height.value = t.height = t.preloadImg.height;		t.showSizeSet();		t.demoSetSize();		t.showSize(el);	},	init : function() {		var ed = tinyMCEPopup.editor, h;		h = document.body.innerHTML;		// Replace a=x with a="x" in IE		if (tinymce.isIE)			h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')		document.body.innerHTML = ed.translate(h);		window.setTimeout( function(){wpImage.setup();}, 100 );	},	setup : function() {		var t = this, h, c, el, id, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '';		document.dir = tinyMCEPopup.editor.getParam('directionality','');		if ( tinyMCEPopup.editor.getParam('wpeditimage_disable_captions', false) )			t.I('cap_field').style.display = 'none';		tinyMCEPopup.restoreSelection();		el = ed.selection.getNode();		if (el.nodeName != 'IMG') return;		f.img_src.value = d.src = link = ed.dom.getAttrib(el, 'src');		ed.dom.setStyle(el, 'float', '');		t.getImageData();		c = ed.dom.getAttrib(el, 'class');		if ( DL = dom.getParent(el, 'dl') ) {			var dlc = ed.dom.getAttrib(DL, 'class');			dlc = dlc.match(/align[^ "']+/i);			if ( dlc && ! dom.hasClass(el, dlc) ) {				c += ' '+dlc;				tinymce.trim(c);			}			tinymce.each(DL.childNodes, function(e) {				if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) {					caption = e.innerHTML;					return;				}			});		}		f.img_cap.value = caption;		f.img_title.value = ed.dom.getAttrib(el, 'title');		f.img_alt.value = ed.dom.getAttrib(el, 'alt');		f.border.value = ed.dom.getAttrib(el, 'border');		f.vspace.value = ed.dom.getAttrib(el, 'vspace');		f.hspace.value = ed.dom.getAttrib(el, 'hspace');		f.align.value = ed.dom.getAttrib(el, 'align');		f.width.value = t.width = ed.dom.getAttrib(el, 'width');		f.height.value = t.height = ed.dom.getAttrib(el, 'height');		f.img_classes.value = c;		f.img_style.value = ed.dom.getAttrib(el, 'style');		// Move attribs to styles		if (dom.getAttrib(el, 'hspace'))			t.updateStyle('hspace');		if (dom.getAttrib(el, 'border'))			t.updateStyle('border');		if (dom.getAttrib(el, 'vspace'))			t.updateStyle('vspace');		if (pa = ed.dom.getParent(el, 'A')) {			f.link_href.value = t.current = ed.dom.getAttrib(pa, 'href');			f.link_title.value = ed.dom.getAttrib(pa, 'title');			f.link_rel.value = t.link_rel = ed.dom.getAttrib(pa, 'rel');

⌨️ 快捷键说明

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