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

📄 esri_window.js

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JS
📖 第 1 页 / 共 2 页
字号:
    moveOutline = null;
    EsriUtils.setElementOpacity(self.divObject, 1);
    updateBounds();
    if (self.resizable && ! self.collapsed) resizeAction.activate(self.divObject, processResizeEnd, processResize);

    moving = false;
  }

  function processResize(rect) {
    if (! resizing) {
      updateBounds();
      resizing = true;
    }
    var dx = self.bounds.width - self.pageElement.bounds.width;
    var dy = self.bounds.height - self.pageElement.bounds.height;
    EsriUtils.setElementStyle(self.divObject, "width:" + rect.width + "px; height:" + rect.height + "px;");
    EsriUtils.setElementStyle(self.content, "width:" + (rect.width - dx) + "px; height:" + (rect.height - dy + 1) + "px;");
  }

  function processResizeEnd(rect) {
    processResize(rect);
    updateBounds();
    resizing = false;
  }

  function updateBounds() {
    if (! self.closed) {
      self.bounds = EsriUtils.getElementPageBounds(self.divObject);
      if (! self.collapsed) self.pageElement.bounds = EsriUtils.getElementPageBounds(self.content);
    }
    for (var i=0;i<self.updateListenerNames.length;i++) self.updateListeners[self.updateListenerNames[i]](self);
  }

  function saveState() { if (self.windowMgr) self.windowMgr.saveProperties(); }

  this.setTitle = function(str) { if (this.title) this.title.innerHTML = str; }
  this.setStatus = function(msg) { if (this.status) this.status.innerHTML = msg; }

  this.dispose = function(restore) {
    var chks;
    if (EsriUtils.isIE6) chks = EsriUtils.getCheckBoxStates(this.pageElement.divObject);
    if (restore) origParentNode.appendChild(this.pageElement.divObject);
    origContainer.removeChild(this.divObject);
    if (EsriUtils.isIE6) EsriUtils.setCheckBoxStates(this.pageElement.divObject, chks);
  }

  this.collapse = function(override, skipSave) {
    if ((self.collapsed || self.closed) && ! override) return;
    var b = EsriUtils.getElementPageBounds(titleBar);
    var bd = EsriUtils.getElementPageBounds(this.content);
    var bs = new EsriRectangle(0, 0, 0, 0);
    EsriUtils.hideElement(this.content);
    if (this.showStatusBar) {
      bs = EsriUtils.getElementPageBounds(statusDiv);
      EsriUtils.hideElement(statusDiv);
    }

    expWd = b.width;
    if (! popup) EsriUtils.setElementStyle(titleBar, "width:" + expWd + "px;");

    expHtSet = this.content.style.height == null;
    expHt = bd.height + bs.height;
    var h = this.bounds.height - expHt;
    EsriUtils.setElementStyle(this.divObject, "height:" + ((h < 0 && EsriUtils.isIE) ? 0 : h) + "px;");

    if (colImg) colImg.className = winStyle + "Expand";
    this.collapsed = true;
    updateBounds();
    if (this.resizable) resizeAction.deactivate();
    if (! skipSave) saveState();
  }

  this.expand = function(override, skipSave) {
    if ((! self.collapsed || self.closed) && ! override) return;
    EsriUtils.showElement(this.content);
    if (this.showStatusBar) EsriUtils.showElement(statusDiv);

    EsriUtils.removeElementStyle(titleBar, "width;");
    if (expHtSet) EsriUtils.setElementStyle(this.divObject, "height:" + (this.bounds.height + expHt) + "px;");
    else EsriUtils.removeElementStyle(this.divObject, "height;");

    if (colImg) colImg.className = winStyle + "Collapse";
    this.collapsed = false;
    if (this.resizable) resizeAction.activate(this.divObject, processResizeEnd, processResize);
    updateBounds();
    if (! skipSave) saveState();
  }

  this.hide = function(override, skipSave) {
    if (this.closed && ! override) return;
    EsriUtils.hideElement(this.divObject);
    this.closed = true;
    updateBounds();
    if (! skipSave) saveState();
  }

  this.show = function(override, skipSave) {
    if (! this.closed && ! override) return;
    EsriUtils.showElement(this.divObject);
    this.closed = false;
    updateBounds();
    if (! skipSave) saveState();
  }

  function setZ(z) { EsriUtils.setElementStyle(self.divObject, "z-index:" + z + ";"); }
  this.toFront = function(zi) { setZ((zi) ? zi : 111); }
  this.toBack = function(zi) { setZ((zi) ? zi : 110); }

  this.setWindowManager = function(wm) {
    this.windowMgr = wm;
    self = this;
  }

  this.moveTo = function(x, y) {
    if (! self.movable) return;
    var pb = EsriUtils.getPageBounds();
    EsriUtils.setElementStyle(this.divObject, "left:" + ((x < 0 || x > pb.width) ? 0 : x) + "px; top:" + ((y < 0 || y > pb.height) ? 0 : y) + "px;");
    updateBounds();
    saveState();
  }

  this.resize = function(w, h) {
    if (! this.resizable || this.closed) return;
    var b = EsriUtils.getElementPageBounds(this.divObject);
    var peBd = EsriUtils.getElementPageBounds(this.content);
    EsriUtils.setElementStyle(this.divObject, "width:" + w + "px; height:" + h + "px;");
    var dx = b.width - w;
    var dy = b.height - h;
    if (dx != 0 && (peBd.width - dx) > 0) EsriUtils.setElementStyle(this.content, "width:" + (peBd.width - dx) + "px;");
    if (dy != 0 && (peBd.height - dy) > 0) EsriUtils.setElementStyle(this.content, "height:" + (peBd.height - dy) + "px;");
    if (this.resizable) resizeAction.reactivate();
    updateBounds();
    saveState();
  }

  function normalize() {
    var b = EsriUtils.getElementPageBounds(self.divObject);

    if ((self.minWidth && self.maxWidth) && (b.width < self.minWidth || b.width > self.maxWidth)) {
      var w = (b.width < self.minWidth) ? self.minWidth : self.maxWidth;
      EsriUtils.setElementStyle(self.content, "width:" + w + "px;");
    }

    if ((self.minHeight && self.maxHeight) && (b.height < self.minHeight || b.height > self.maxHeight)) {
      var h = (b.height < self.minHeight) ? self.minHeight : self.maxHeight;
      EsriUtils.setElementStyle(self.content, "height:" + h + "px;");
    }

    b = EsriUtils.getElementPageBounds(self.divObject);
    var pb = EsriUtils.getPageBounds();
    if (b.left > pb.width || b.top > pb.height) self.moveTo(b.left, b.top);
    b = EsriUtils.getElementPageBounds(self.divObject);

    if ((b.left + b.width) > pb.width || (b.top + b.height) > pb.height) {
      var w = ((b.left + b.width) > pb.width) ? pb.width - b.left : b.width;
      var h = ((b.top + b.height) > pb.height) ? pb.height - b.top : b.height;
      self.resize(w, h);
    }
    else if (b.width > pb.width || b.height > pb.height) self.resize((b.width > pb.width) ? pb.width : b.width, (b.height > pb.height) ? pb.height : b.height);
    else updateBounds();
    if (self.resizable) resizeAction.reactivate();
  }

  this.fit = function() {
    if (! this.fittable) return;
    var cl = this.closed;
    var co = this.collapsed;
    if (cl) this.show(true, true);
    if (co) this.expand(true, true);
    EsriUtils.removeElementStyle(this.divObject, "width; height;");
    EsriUtils.removeElementStyle(this.content, "width; height;");
    if (EsriUtils.isIE) {
      var b = EsriUtils.getElementPageBounds(this.content);
      EsriUtils.setElementStyle(this.content, "width:" + (b.width + scrSz) + "px;");
    }
    normalize();
    if (co) this.collapse(true, true);
    if (cl) this.hide(true, true);
    saveState();
  }

  this.update = function() {
    if (! this.bounds.left && ! this.bounds.top && ! this.bounds.width && ! this.bounds.height) return;
    var peBd = this.pageElement.bounds.offset(0, 0);

    this.content = this.pageElement.divObject;
    EsriUtils.removeElementStyle(this.content, "position; left; top;");
    this.content.className = winStyle + "Content";

    EsriUtils.showElement(this.content);
    EsriUtils.showElement(this.divObject);
    EsriUtils.setElementStyle(this.divObject, "left:" + this.bounds.left + "px; top:" + this.bounds.top + "px;");
    var b = EsriUtils.getElementPageBounds(this.divObject);
    EsriUtils.setElementStyle(this.divObject, "width:" + this.bounds.width + "px; height:" + this.bounds.height + "px;");
    var dx = b.width - this.bounds.width;
    var dy = b.height - this.bounds.height;
    if (dx != 0 && (peBd.width - dx) > 0) EsriUtils.setElementStyle(this.content, "width:" + (peBd.width - dx) + "px;");
    if (dy != 0 && (peBd.height - dy) > 0) EsriUtils.setElementStyle(this.content, "height:" + (peBd.height - dy) + "px;");
    normalize();

    this.collapsed ? this.collapse(true, true) : this.expand(true, true);
    this.closed ? this.hide(true, true) : this.show(true, true);
    for (var i=0;i<this.updateListenerNames.length;i++) this.updateListeners[this.updateListenerNames[i]](this);
  }

  if (container) this.init(container);
}

EsriWindow.prototype.center = function() {
  var page = EsriUtils.getPageBounds();
  var wW = page.width;
  var wH = page.height;
  this.moveTo(Math.round(wW / 2) - Math.round(this.bounds.width / 2), Math.round(wH / 2) - Math.round(this.bounds.height / 2));
}

EsriWindow.prototype.addUpdateListener = function(name, listener) {
  if (this.updateListenerNames.indexOf(name) == -1) this.updateListenerNames.push(name);
  this.updateListeners[name] = listener;
}

EsriWindow.prototype.removeUpdateListener = function(name) {
  var index = this.updateListenerNames.indexOf(name);
  if (index != -1) {
    this.updateListenerNames.splice(index, 1);
    this.updateListeners[name] = null;
  }
}

EsriWindow.prototype.toggleVisibility = function() { this.closed ? this.show() : this.hide(); }
EsriWindow.prototype.toggleCollapse = function() { this.collapsed ? this.expand() : this.collapse(); }

⌨️ 快捷键说明

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