ie5script.js

来自「类似youtube的视频分享网站源码。有后台管理系统及模板」· JavaScript 代码 · 共 923 行 · 第 1/3 页

JS
923
字号
			}
			sel(0).alt = ialt
			sel(0).title = ialt
			if ((imargin != '') && (imargin!=null)) {
				sel(0).style.margin = imargin
			}
			//sel(0).src = sel(0).src
		}
	}
	obj.edit_object.focus()
}
// create the horizontal rule html
function wp_create_hr(obj,code) {
	if (code == ""){
		return
	}
	var sel = obj.edit_object.document.selection.createRange()
	obj.edit_object.focus()
	sel.pasteHTML(code)
}
function wp_insert_code(obj,code) {
	if ((code != "") && (code != null)) {
		obj.edit_object.focus()
		if (obj.edit_object.document.selection.type == "Control") {
			obj.edit_object.document.execCommand('delete')
		}
		obj.edit_object.document.selection.createRange().pasteHTML(code)
	}
	if (obj.border_visible == 1) {
		wp_show_borders(obj)
	}
	obj.edit_object.focus()
}
function wp_open_bookmark_window(obj,srcElement) {	
	if (srcElement.className == "wpDisabled") {
		return	
	}
	var arr = ''
	if (obj.edit_object.document.selection.type == "Control") {
		var sel = obj.edit_object.document.selection.createRange()
		if (sel(0).tagName == "IMG") {
			if ((sel(0).getAttribute('name')) && (sel(0).src.search(wp_directory+"/images/bookmark_symbol.gif") != -1)) {
				arr= sel(0).name
			}
		} 
	}
	bookwin = obj.openDialog(wp_directory + "bookmark.php?bookmark="+arr+"&lang="+obj.instance_lang, 'modal', 300, 106)
}
function wp_create_bookmark (obj,name) {
	if ((name != '') && (name!= null)) {
		wp_insert_code(obj,'<img name="'+name+'" src="' + wp_directory + '/images/bookmark_symbol.gif" contenteditable="false" width="16" height="13" alt="Bookmark: '+name+'" title="Bookmark: '+name+'" border="0">')
	}
}
function wp_isInside(obj, tag) {
	sel = obj.edit_object.document.selection.createRange()
	//if (sel.type == "Control") {
		//return false
	//}
	if (!obj.edit_object.document.queryCommandEnabled("InsertHorizontalRule")) {
		return false
	}
	var thisTag = sel.parentElement()
	while(thisTag.tagName!=tag&&thisTag.tagName!="HTML") {
			thisTag = thisTag.parentElement
	}
	if (thisTag.tagName == tag) {
		return true
	} else {
		return false
	}
}
////////////////////////////
// Table editing features //
////////////////////////////
// finds the current table, row and cell and puts them in global variables that the other table functions and the table editing window can use.
// requires the current selection
function wp_getTable(obj, sel) {
	if (sel == null) {
		sel = obj.edit_object.document.selection.createRange()
	}
	wp_thisCell = sel.parentElement()
	while(wp_thisCell.tagName!="TD"&&wp_thisCell.tagName!="HTML") {
			wp_thisCell = wp_thisCell.parentElement
	}
	wp_thisRow = wp_thisCell
	while(wp_thisRow.tagName!="TR"&&wp_thisRow.tagName!="HTML") {
		wp_thisRow = wp_thisRow.parentElement
	}
	wp_thisTable = wp_thisRow
	while(wp_thisTable.tagName!="TABLE"&&wp_thisTable.tagName!="HTML") {
			wp_thisTable = wp_thisTable.parentElement
	}
}
// creates the table html for the insert table window
function wp_insertTable(obj,rows,cols,attrs) {
	obj.edit_object.focus()
	// generate column widths
	var tdwidth = 100/cols
	tdwidth +="%"
		var code = "<table" + attrs + ">\r\n"
		for (var i = 0; i < rows; i++) {
			code += "\t<tr>\r\n"
			for (var j = 0; j < cols; j++) {
				// spacers are autoinserted to ensure table displays as expected. column widths are also set.
				code += "\t\t<td valign=\"top\" width=\"" + tdwidth + "\">"+obj.tdInners+"</td>\r\n"
			}
			code += "\t</tr>\r\n"
		}
		code += "</table>\r\n"
	var sel = obj.edit_object.document.selection.createRange()
	sel.pasteHTML(code)
	if (obj.border_visible == 1) {
		wp_show_borders(obj)
	}
	obj.edit_object.focus()
}
/////////////////////////
// CSS style functions //
/////////////////////////
// these fucntions are still a little messey!!!!!!
// mouse over button style
function wp_m_over(element, obj) {
	if (obj.initfocus == false) {
		return
	}
	var cmd = element.getAttribute("cid")
	if (element.className=="wpDisabled") {
		return
	}
	if ((cmd=="edittable") || (cmd=="splitcell")) {
		cmd="inserthorizontalrule"
	}
	if (cmd == "border") {
		if (obj.border_visible) {
			element.className="wpLatchedOver"
		} else {
			element.className="wpOver"
		}
		return
	} else if (cmd=="ignore") {
		element.className="wpOver"
		return	
	} else if ((cmd=="undo") ||  (cmd=="redo")) {
		element.className="wpOver"
		return
	} else if (obj.edit_object.document.queryCommandState(cmd)) {
		element.className="wpLatchedOver"
		return
	}
	element.className="wpOver"
}
// mouse out button style
function wp_m_out(element, obj) {
	if (obj.initfocus == false) {
		return
	}
	var cmd = element.getAttribute("cid")
	if (element.className=="wpDisabled") {
		return
	}
	if ((cmd=="edittable") || (cmd=="splitcell")) {
		cmd="inserthorizontalrule"
	}
	if (cmd == "border") {
		if (obj.border_visible) {
			element.className="wpLatched"
		} else {
			element.className="wpReady"
		}
		return
	} else if (cmd=="ignore") {
		element.className="wpReady"
		return	
	} else if ((cmd=="undo") ||  (cmd=="redo")) {
		element.className="wpReady"
		return
	} else if (!obj.edit_object.document.queryCommandEnabled(cmd)) {
		element.className="wpDisabled"
		return
	} else if (obj.edit_object.document.queryCommandState(cmd)) {
		element.className="wpLatched"
		return
	}
	element.className="wpReady"
}
// mouse down button style
function wp_m_down(element, obj) {
	if (obj.initfocus == false) {
		obj.edit_object.focus();
		obj.initfocus = true;
	}
	if (element.className == "wpDisabled") {
		return
	}
	element.className="wpDown"
}
// mouse up button style
function wp_m_up(element, obj) {
	var style=element.className
	if (style=="wpDisabled") {
		return
	} else {
		if (style=="wpLatched") {
			return
		}
	}
	element.className="wpOver"
}
///////////////////////
// Set button states //
///////////////////////
// This changes the states of buttons everytime the selection changes, so that buttons that cannot be used based on the current user selection appear disabled.
// this is the crappiest slowest function in zeusedit, it really needs an overhaul!!
function wp_set_button_states(obj) {
	obj.initfocus = true
	var sel=obj.edit_object.document.selection.createRange()
	var inside_link = wp_isInside(obj, 'A')
	var inside_table = wp_isInside(obj, 'TD')
	if (inside_table) {
		var wp_thisCell = sel.parentElement()
		while(wp_thisCell.tagName!="TD"&&wp_thisCell.tagName!="HTML") {
			wp_thisCell = wp_thisCell.parentElement
		}
	}	
	// evalute and set the toolbar button states
	for(var i = 0; i < obj.tbarlength; i++) {
		var pbtn = obj.tbarimages(i)
		if ((pbtn.type=="btn")) {
			var cmd = pbtn.getAttribute("cid")
			if (!obj.safe) {
				pbtn.className="wpDisabled"
			} else if ((cmd=="edittable") || (cmd == 'splitcell')) {
			// table editing buttons
				if (inside_table) {
					if (cmd == 'splitcell') {
						if ((wp_thisCell.rowSpan >= 2) || (wp_thisCell.colSpan >=2)) {
							pbtn.className="wpReady"
						} else {
							pbtn.className="wpDisabled"
						}
					} else {
						pbtn.className="wpReady"
					}
				} else {
					pbtn.className="wpDisabled"
				}
			} else if (cmd == "border") {
				if (obj.border_visible) {
					pbtn.className="wpLatched"
				} else {
					pbtn.className="wpReady"
				}
			} else if (cmd=="createlink") {
				if ((inside_link) || (sel.text != '')) {
					pbtn.className="wpReady"
				} else {
					pbtn.className="wpDisabled"
				}
			} else if ((cmd=="undo") ||  (cmd=="redo")) {
					pbtn.className="wpReady"
			} else if (obj.edit_object.document.queryCommandState(cmd)) {
				pbtn.className="wpLatched"
			} else if (!obj.edit_object.document.queryCommandEnabled(cmd)) {
				pbtn.className="wpDisabled"
			} else {	
				pbtn.className="wpReady"
			}
		}
	}
	var font_face_value = obj.edit_object.document.queryCommandValue('FontName')
	var font_size_value = obj.edit_object.document.queryCommandValue('FontSize')
	var format_list_value = obj.edit_object.document.queryCommandValue('FormatBlock')
	if (obj.edit_object.document.selection.type == "Control") {
		var class_menu_value = ''
	} else {
		var foo = sel.parentElement()
		while(!foo.className&&foo.tagName!="HTML") {
			foo = foo.parentElement
		}
		var class_menu_value = foo.className
	}
	wp_set_list_text ('font-face', font_face_value, 'font', obj)
	wp_set_list_text ('font_size', font_size_value, 'size', obj)
	wp_set_list_text ('format_list', format_list_value, 'format', obj)
	var class_menu_text = document.getElementById(obj.name+'_class_menu-text')
	if (class_menu_value) {
		if (class_menu_value == "wp_none") {
			if (class_menu_text.innerHTML != obj.lng['class'])
				class_menu_text.innerHTML = obj.lng['class']
		} else if (class_menu_text.innerHTML != class_menu_value) {
			class_menu_text.innerHTML = class_menu_value
		}
	} else {
		if (class_menu_text.innerHTML != obj.lng['class'])
			class_menu_text.innerHTML = obj.lng['class']
	}
}
function wp_set_list_text (list, value, lang, obj) {
	var list_text = document.getElementById(obj.name+'_'+list+'-text')
	if (value) {
		if (list_text.innerHTML != value)
			list_text.innerHTML = value
	} else {
		if (list_text.innerHTML != obj.lng[lang])
			list_text.innerHTML = obj.lng[lang]
	}
}

⌨️ 快捷键说明

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