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

📄 editorshared.js

📁 类似youtube的视频分享网站源码。有后台管理系统及模板
💻 JS
📖 第 1 页 / 共 4 页
字号:
			var fonts = obj.edit_object.document.getElementsByTagName("FONT")
			wp_remove_attributes(fonts, 'color')
		} else if (Action == 'hilitecolor' && color == 'rgb(127, 124, 117)' ) {
			wp_remove_highlight(obj.edit_object.document.body, obj);
		}
	}
	obj.edit_object.focus()
}
function wp_remove_highlight(node, obj) {
	if (node.nodeType != 1) {
		return
	}
	var cn = node.childNodes
	var n = cn.length
	for (var i = 0; i < n; i++) {
		if (cn[i].style) {
				if (cn[i].style.backgroundColor == 'rgb(127, 124, 117)') {
					cn[i].style.backgroundColor = ''
				}
		}
		wp_remove_highlight(cn[i], obj);
	}
}
function wp_paste_word_html(obj) {
	var url = wp_directory + 'pastewin.php?lang='+obj.instance_lang
	var width = 400
	var height = 278
	wp_current_obj = obj
	var pasteWindow = window.open(url ,"pastewin", "dependent=yes,width="+width+"px,height="+height+"px,left="+((screen.width/2)-(width/2))+",top="+((screen.height/2)-(height/2)))
	pasteWindow.focus()
}
function wp_insert_smiley(obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	obj.edit_object.focus()
	imgwin = obj.openDialog(wp_directory + 'smileys.php?lang='+obj.instance_lang ,'modal',380,301)
}
function wp_open_horizontal_rule_window(obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	rulerwin = obj.openDialog(wp_directory + "insert_hr.php?lang="+obj.instance_lang ,'modal',260,212)
}
function wp_custom_object(obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	var custom = obj.openDialog (wp_directory + "dialog_frame.php?window=custom.php&lang="+obj.instance_lang, 'modal',550,411)
}
function wp_open_special_characters_window(obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	specchar = obj.openDialog(wp_directory + "special_characters.php?lang="+obj.instance_lang, 'modal',500,252)
}
function wp_findit(obj) {
	var findwin = obj.openDialog(wp_directory + "find.php?lang="+obj.instance_lang, 'modeless', 318, 146)
}
function wp_toggle_table_borders(obj,srcElement) {
	if (srcElement.className == "wpDisabled") {
		return	
	}
	if (obj.border_visible == 0) {
		wp_show_borders(obj)
	} else {
		wp_hide_borders(obj)
	}
}
function wp_show_borders(obj) {
	if (!obj) {
		obj = wp_current_obj
	}	
	var tables = obj.edit_object.document.getElementsByTagName('TABLE')
	var l=tables.length
	for (var i=0; i < l; i++) {
		if (tables[i].border == 0 || tables[i].border == null) {
			var tableCells = tables[i].getElementsByTagName('TD')
			var m=tableCells.length
			for (var j=0; j < m; j++) {
				if (wp_is_ie) {
					tableCells[j].runtimeStyle.border = "1px dashed #7F7C75"
				} else {
					tableCells[j].style.border = "1px dashed #7F7C75"
				}
			}
		}
	}
	obj.border_visible = 1
	var message = document.getElementById(obj.name + '_messages')
	if (message.innerHTML != obj.lng['guidelines_visible']) {
		message.innerHTML = obj.lng['guidelines_visible']
	}
	message.style.textDecoration = 'none'
}
function wp_hide_borders(obj) {
	var tableCells = obj.edit_object.document.getElementsByTagName('TD')
	var l=tableCells.length
	for (var i=0; i < l; i++) {
		if (wp_is_ie) {
			var rcsstext = tableCells[i].runtimeStyle.cssText
		} else {
			var rcsstext = tableCells[i].style.cssText
		}
		if (rcsstext.length > 1) {
			var propArray = rcsstext.split(';')
			var pl = propArray.length
			var icsstext = ''
			for (var j = 0; j < pl; j++) {
				if (propArray[j].length > 1) {
					var propVal = propArray[j].split(':')
					if (propVal[1] != " 1px dashed rgb(127, 124, 117)"
					&& propVal[1] != " #7f7c75 1px dashed") {							
						icsstext += propVal[0] + ':'
						icsstext += propVal[1] + ';'
					}
				}
			}
			if (wp_is_ie) {
				tableCells[i].runtimeStyle.cssText = icsstext
			} else {
				tableCells[i].style.cssText = icsstext
			}
		}
	}
	obj.border_visible = 0
	var message = document.getElementById(obj.name + '_messages')
	if (message.innerHTML != obj.lng['guidelines_hidden']) {
		message.innerHTML = obj.lng['guidelines_hidden']
	}
	message.style.textDecoration = 'none'
}
/////////////////////////////
// Fancy table editing stuff
/////////////////////////////
// table window
function wp_open_table_window(obj,srcElement) {	
	if (srcElement.className == "wpDisabled") {
		return	
	}
	if (wp_is_ie) {
		var height = 417
	} else {
		var height = 427
	}
	tblwin = obj.openDialog(wp_directory + "table.php?lang="+obj.instance_lang, 'modal', 440, height)
}
function wp_open_table_editor(obj) {
	if (wp_isInside(obj, 'TD')) {
		wp_getTable(obj)
		editTbl = obj.openDialog(wp_directory + 'edittable.php?lang='+obj.instance_lang, 'modal', 431, 516)
	} else {
		alert(obj.lng['place_cursor_in_table'])
	}
}
// adding or removing table rows
function wp_processRow(obj,action) {
	if (wp_isInside(obj, 'TD')) {
	wp_getTable(obj)
	var idx = 0
	var rowidx = 0
	var tr = wp_thisRow
	var numcells = tr.childNodes.length
	if (action == "choose") {
		choose = obj.openDialog(wp_directory + "addrow.php?lang="+obj.instance_lang ,'modal',270,150)
		return
	}
	if ((action == "") || (action == null)) {
		return
	}
	if (action == "addabove") {
		while (tr) {
			if (tr.tagName == "TR") {
				rowidx++
				tr = tr.previousSibling
			}
		}
		rowidx-=1
	} else {
		if (action == "addbelow") {
			while (tr) {
				if (tr.tagName == "TR") {
					rowidx++
					tr = tr.previousSibling
				}
			}
		}		
	}
	var tbl = wp_thisTable
	if (!tbl) {
		alert("Could not " + action + " row.")
		return
	}
	if ((action == "addabove") || (action == "addbelow"))  {
		var r = tbl.insertRow(rowidx)
		for (var i = 0; i < numcells; i++) {
			var c = r.appendChild(obj.edit_object.document.createElement("TD") )
			if (wp_thisCell.colSpan) {
				c.colSpan = wp_thisRow.childNodes[i].colSpan
			}
			c.width = wp_thisRow.childNodes[i].width
			c.vAlign = 'top'
			c.innerHTML = obj.tdInners
			if (obj.border_visible == 1) {
				wp_show_borders(obj)
			}
		}
	} else {
		if (wp_thisTable.getElementsByTagName('TR').length == 1) {
			return
		}
		while (tr) {
			if (tr.tagName == "TR") {
				rowidx++
				tr = tr.previousSibling
			}
		}
		rowidx -= 1
		tbl.deleteRow(rowidx)
		}
		wp_thisCell=null
		wp_thisRow=null
		wp_thisTable=null
	}
	obj.edit_object.focus()
}
// adding or removing a column
function wp_processColumn(obj,action) {
	if (wp_isInside(obj, 'TD')) {
	if (action == "choose") {
		choose = obj.openDialog(wp_directory + "addcolumn.php?lang="+obj.instance_lang ,'modal',270,150)
		return
	}
	//action='addleft'
	if ((action == "") || (action == null)) {
		return
	}
	wp_getTable(obj)
	// store cell index in a var because the cell will be
	// deleted when processing the first row
	var cellidx = wp_thisCell.cellIndex
	var tbl = wp_thisTable
	if (!tbl) {
		alert("Could not " + action + " column.")
		return
	}
	// now we have the table containing the cell
	this.wp_add_remove_columns(obj,tbl, cellidx, action)
	} 
	obj.edit_object.focus()
}
// function for processing columns
function wp_add_remove_columns(obj,tbl, cellidx, action) {
	if (!tbl.childNodes.length)
		return
		var n=tbl.childNodes.length
		for (var i = 0; i < n; i++) {
			if (tbl.childNodes[i].tagName == "TR") {
				var cell = tbl.childNodes[i].childNodes[ cellidx ]
				if (!cell)
					break // can't add cell after cell that doesn't exist
				if (action == "addleft") {
					cell.parentNode.insertBefore( obj.edit_object.document.createElement("TD"), cell)
				} else {
					if (action == "addright") {
						cell.parentNode.insertBefore( obj.edit_object.document.createElement("TD"), cell.nextSibling)
					} else {
					// check for rowspan
						if (cell.rowSpan > 1) {
							i += (cell.rowSpan - 1)
						}
						if (wp_thisRow.getElementsByTagName('TD').length == 1) {
							return
						}
						if (cell.colSpan < 2) { 
							tbl.childNodes[i].removeChild(cell)

						} else {
							cell.colSpan -= 1
						}
					}
				}
			} else {
			// keep looking for a "TR"
			this.wp_add_remove_columns(obj,tbl.childNodes[i], cellidx, action) 
		}
	}
	wp_reprocess_columns(obj)
}
// if there is no other way to split the cell just do it, otherwise (if it could be split vertical or horizontal) ask which way to do it
function wp_splitCell(obj) {
	if (wp_isInside(obj, 'TD')) {
		wp_getTable(obj)
		if ((wp_thisCell.colSpan < 2) && (wp_thisCell.rowSpan < 2)) {
			alert(obj.lng['only_split_merged_cells'])
		}
		if ((wp_thisCell.colSpan >= 2) && (wp_thisCell.rowSpan < 2)) {
			wp_unMergeRight(obj)
		} else if ((wp_thisCell.rowSpan >= 2) && (wp_thisCell.colSpan < 2)) {
			wp_unMergeDown(obj)
		} else if ((wp_thisCell.rowSpan >= 2) && (wp_thisCell.colSpan >= 2)) {
			choose = obj.openDialog(wp_directory + "unmrgcell.php?lang="+obj.instance_lang ,'modal',270,150)
			return
		} 
	}
}
function wp_mergeCell(obj) {
	if (wp_isInside(obj, 'TD')) {
		choose = obj.openDialog(wp_directory + "mrgcell.php?lang="+obj.instance_lang ,'modal',270,150)
		return
	}
}
// merge cells  
function wp_mergeRight(obj) {
	if (wp_isInside(obj, 'TD')) {
		wp_getTable(obj)
		if (!wp_thisCell.nextSibling) {
			alert(obj.lng['no_cell_right'])
			return
		}
		// don't allow user to merge rows with different rowspans
		if (wp_thisCell.rowSpan != wp_thisCell.nextSibling.rowSpan) {
			alert(obj.lng['different_row_spans'])
			return
		}
		if (wp_thisCell.nextSibling.innerHTML.toLowerCase() != obj.tdInners) {
			if (wp_thisCell.innerHTML.toLowerCase() == obj.tdInners) {
				wp_thisCell.innerHTML = wp_thisCell.nextSibling.innerHTML
			} else {
				wp_thisCell.innerHTML += wp_thisCell.nextSibling.innerHTML
			}
		}
		wp_thisCell.setAttribute("WIDTH", '', 0);
		wp_thisCell.nextSibling.setAttribute("WIDTH", '', 0)
		wp_thisCell.colSpan += wp_thisCell.nextSibling.colSpan
		wp_thisRow.removeChild(wp_thisCell.nextSibling)
		wp_thisCell=null
		wp_thisRow=null
		wp_thisTable=null
	}
	obj.edit_object.focus()
}
// spit cells
function wp_unMergeRight(obj) {
	if (wp_isInside(obj, 'TD')) {
		wp_getTable(obj)
		if (wp_thisCell.colSpan < 2) {
			alert(obj.lng['only_split_merged_cells'])	
		} else {
			wp_thisCell.colSpan = wp_thisCell.colSpan - 1
			var newCell = wp_thisCell.parentNode.insertBefore(obj.edit_object.document.createElement("TD"), wp_thisCell.nextSibling)
			newCell.rowSpan = wp_thisCell.rowSpan
			wp_thisCell.setAttribute("WIDTH", '', 0);
			newCell.setAttribute("WIDTH", '', 0)
			newCell.innerHTML = obj.tdInners
			newCell.vAlign = 'top'
		}
		if (obj.border_visible == 1) {
			wp_show_borders(obj)
		}
		wp_thisCell=null
		wp_thisRow=null
		wp_thisTable=null
	} 
	obj.edit_object.focus()
}
// merge with cell below
function wp_mergeDown(obj) {
	if (wp_isInside(obj, 'TD')) {

⌨️ 快捷键说明

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