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

📄 toggle.js

📁 这是一个关于java的JSP页面中使用象Swing组件的一个库文件.
💻 JS
字号:
function uiHtml_Toggle(triggerOn, triggerOff, initialIsOn, toggleEvent) {  this._super();  this.__triggerOn = triggerOn;  this.__debugId = this.__triggerOn.getDomObject().id;  this.__onPropertyArray = new Array();  this.__offPropertyArray = new Array();  this.__toggleEvent = uiUtil_Type.getString(      toggleEvent, uiHtml_Toggle.DEFAULT_EVENT);  if (triggerOff != null) {      this.__triggerOff = triggerOff;    this.__strategyDisplayOn = this.__doubleDisplayOn;    this.__strategyDisplayOff = this.__doubleDisplayOff;    this.__strategyAppendOnStateOn = this.__doubleAppendOnStateOn;    this.__strategyAppendOnStateOff = this.__doubleAppendOnStateOff;    this.__strategyPrependOnStateOn = this.__doublePrependOnStateOn;    this.__strategyPrependOnStateOff = this.__doublePrependOnStateOff;    var toggle = this;    this.__triggerOn.prependEventHandler(this.__toggleEvent, function(e) {      toggle.switchOff();    });    this.__triggerOff.prependEventHandler(this.__toggleEvent, function(e) {      toggle.switchOn();    });  }  else {      this.__triggerOff = this.__triggerOn;      this.__strategyDisplayOn = this.__singleDisplayOn;    this.__strategyDisplayOff = this.__singleDisplayOff;    this.__strategyAppendOnStateOn = this.__singleAppendOnStateOn;    this.__strategyAppendOnStateOff = this.__singleAppendOnStateOff;    this.__strategyPrependOnStateOn = this.__singlePrependOnStateOn;    this.__strategyPrependOnStateOff = this.__singlePrependOnStateOff;    var toggle = this;    this.__triggerOn.prependEventHandler(this.__toggleEvent, function(e) {      toggle._switchState();    });  }  if (uiUtil_Type.getBoolean(initialIsOn, true)) {    this.switchOn();  }  else {    this.switchOff();  }}uiHtml_Toggle = uiUtil_Object.declareClass(uiHtml_Toggle, uiUtil_Object);uiHtml_Toggle.DEFAULT_EVENT = "click";uiHtml_Toggle.__toggles = new Array();uiHtml_Toggle.prototype._switchState = function() {  if (this.__stateOn) {    this.switchOff();  }  else {    this.switchOn();  }};uiHtml_Toggle.prototype.switchOn = function() {  this.__logger.info("switching on " + this.__debugId);  this.__stateOn = true;  this.__strategyDisplayOn();  var domTrigger = this.__triggerOn.getDomObject();  for (prop in this.__onPropertyArray) {    domTrigger[prop] = this.__onPropertyArray[prop];  }};uiHtml_Toggle.prototype.switchOff = function() {  this.__logger.info("switching off " + this.__debugId);  this.__stateOn = false;  this.__strategyDisplayOff();  var domTrigger = this.__triggerOff.getDomObject();  for (prop in this.__offPropertyArray) {    domTrigger[prop] = this.__offPropertyArray[prop];  }};uiHtml_Toggle.prototype.appendOnStateOn = function(eventHandler) {  this.__strategyAppendOnStateOn(eventHandler);};uiHtml_Toggle.prototype.appendOnStateOff = function(eventHandler) {  this.__strategyAppendOnStateOff(eventHandler);};uiHtml_Toggle.prototype.setOnProperties = function(propArray) {  this.__onPropertyArray = propArray;};uiHtml_Toggle.prototype.setOffProperties = function(propArray) {  this.__offPropertyArray = propArray;};uiHtml_Toggle.prototype.__doubleDisplayOn = function() {  this.__triggerOff.disappear();  this.__triggerOn.appear();};uiHtml_Toggle.prototype.__doubleDisplayOff = function() {  this.__triggerOn.disappear();  this.__triggerOff.appear();};uiHtml_Toggle.prototype.__doublePrependOnStateOn = function(eventHandler) {  this.__triggerOff.prependEventHandler(this.__toggleEvent, eventHandler);};uiHtml_Toggle.prototype.__doublePrependOnStateOff = function(eventHandler) {  this.__triggerOn.prependEventHandler(this.__toggleEvent, eventHandler);};uiHtml_Toggle.prototype.__doubleAppendOnStateOn = function(eventHandler) {  this.__triggerOff.appendEventHandler(this.__toggleEvent, eventHandler);};uiHtml_Toggle.prototype.__doubleAppendOnStateOff = function(eventHandler) {  this.__triggerOn.appendEventHandler(this.__toggleEvent, eventHandler);};uiHtml_Toggle.prototype.__singleDisplayOn = function() {};uiHtml_Toggle.prototype.__singleDisplayOff = function() {};uiHtml_Toggle.prototype.__singlePrependOnStateOn = function(eventHandler) {  var obj = this;  this.__triggerOn.prependEventHandler(this.__toggleEvent, function(e) {    if (!obj.__stateOn) {      eventHandler.call(this, e);    }  });};uiHtml_Toggle.prototype.__singlePrependOnStateOff = function(eventHandler) {  var obj = this;  this.__triggerOn.prependEventHandler(this.__toggleEvent, function(e) {    if (obj.__stateOn) {      eventHandler.call(this, e);    }  });};uiHtml_Toggle.prototype.__singleAppendOnStateOn = function(eventHandler) {  var obj = this;  this.__triggerOn.appendEventHandler(this.__toggleEvent, function(e) {    if (obj.__stateOn) {      eventHandler.call(this, e);    }  });};uiHtml_Toggle.prototype.__singleAppendOnStateOff = function(eventHandler) {  var obj = this;  this.__triggerOn.appendEventHandler(this.__toggleEvent, function(e) {    if (!obj.__stateOn) {      eventHandler.call(this, e);    }  });};uiHtml_Toggle.createByEither = function(    onId, onName, offId, offName, initialIsOn, eventType) {  var triggerOn = uiHtml_Element.createByEither(onId, onName);  var triggerOff = null;  try {    triggerOff = uiHtml_Element.createByEither(offId, offName);  }  catch(e) {    uiUtil_Logger.getInstance(uiHtml_Toggle).warn(        onId + ": triggerOff does not exist.");  }  return new uiHtml_Toggle(triggerOn, triggerOff, initialIsOn, eventType);};

⌨️ 快捷键说明

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