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

📄 escape-fromhtmlarea.js

📁 Hippo CMS是一个以信息为中心的开源内容管理系统。Hippo CMS目标是供中,大型企业来管理其发布在互连网
💻 JS
字号:
function EscapeFromHTMLArea(editor) {
/* plugin to remove focus from htmlarea when TAB is pressed */
	this.editor = editor;
};

EscapeFromHTMLArea._pluginInfo = {
	name          : "EscapeFromHTMLArea",
	version       : "1.0",
	developer     : "Dennis Dam",
	developer_url : "http://www.hippo.nl/",
 license       : "Apache 2.0"
};

EscapeFromHTMLArea.prototype.isTabbedElement = function(el){
  var s = String(el.localName).toLowerCase();
  if (s == 'a' || s == 'input' || s == 'button' || s == 'select' ||
       s=='iframe')
    return true;
  return false;
}

EscapeFromHTMLArea.prototype.getFirstTabbedElement = function(el){
  var result = null;

  if (this.isTabbedElement(el)) return el;
  var i;
  for (i=0; i< el.childNodes.length; i++){
    if (el.childNodes[i].localName != null && this.isTabbedElement(el.childNodes[i])){
      return el.childNodes[i];
    } else
    if (el.childNodes[i].nodeType == document.ELEMENT_NODE){
      result = this.getFirstTabbedElement(el.childNodes[i]);
      if (result != null)
        return result;
    }
  }

  return null;
}

EscapeFromHTMLArea.prototype.getNextTabbedElement = function(el){
  var nextEl = null;
  if (el.nextSibling != null){
    nextEl = this.getFirstTabbedElement(el.nextSibling);
    if (nextEl != null) return nextEl;
    return this.getNextTabbedElement(el.nextSibling);
  } else
  if (el.parentNode != null){
    return this.getNextTabbedElement(el.parentNode);
  }
  return null;
}

EscapeFromHTMLArea.prototype.onKeyPress  = function(event) {
  if (!HTMLArea.is_ie && event.keyCode == 9) {
    HTMLArea._stopEvent(event);
    var nextLink;
    var myEditor=this.editor;
    var myPlugin = this;
    setTimeout(function(){
    try{
        var nextEl = myPlugin.getNextTabbedElement(myEditor._iframe);
        if (typeof nextEl != 'undefined'){
          var tagName = nextEl.localName.toLowerCase();
          if (tagName == 'iframe'){
            nextEl.contentWindow.focus();
          } else {
            nextEl.focus();
          }
        }
        else
          document.focus();
      } catch (e){ 
         // do nothing
      }
    },200);
  }
};

⌨️ 快捷键说明

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