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

📄 esri_window.js

📁 esri的ArcGIS Server超级学习模板程序(for java)
💻 JS
📖 第 1 页 / 共 2 页
字号:
/*
COPYRIGHT 1995-2005 ESRI

TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
Unpublished material - all rights reserved under the
Copyright Laws of the United States.

For additional information, contact:
Environmental Systems Research Institute, Inc.
Attn: Contracts Dept
380 New York Street
Redlands, California, USA 92373

email: contracts@esri.com
*/

function EsriWindow(id, titleText, pageElement, container, isPopup) {
  this.inheritsFrom(new EsriPageElement(id));
  this.divId = "WindowDiv_" + id;
  this.pageElement = pageElement;
  var origContainer = container;
  var origParentNode = pageElement.divObject.parentNode;
  var popup = (isPopup && EsriUtils.getStyleByClassName("table.esriPopup")) ? true : false;
  var winStyle =  popup ? "esriPopup" : "esriWindow";

  this.collapsable = this.closable = this.showTitleBar = this.movable = this.resizable = this.fittable = true;
  this.collapsed = this.closed = false;
  this.showStatusBar = false;
  this.title = this.content = this.status;

  this.minWidth = 200;
  this.minHeight = 50;
  this.maxWidth = 600;
  this.maxHeight = 600;

  this.updateListeners = [];
  this.updateListenerNames = [];
  this.windowMgr = null;

  this.WINDOW_EVENT_OPENED = 0;
  this.WINDOW_EVENT_CLOSED = 1;
  this.WINDOW_EVENT_MOVED = 2;
  this.WINDOW_EVENT_RESIZED = 3;
  this.WINDOW_EVENT_EXPANDED = 4;
  this.WINDOW_EVENT_COLLAPSED = 5;

  var pixelImg = EsriControls.contextPath + "images/pixel.png";
  var titleTxt = titleText;
  var titleBar, contentRow, statusDiv;
  var colImg, cloImg;
  var self = this;
  var scrSz = 20;
  var moveAction, moving, resizeAction, resizing;
  var expWdSet, expWd, expHtSet, expHt, moveOutline;

  this.init = function(container) {
    var b;
    if (this.bounds.left && this.bounds.top && this.bounds.width && this.bounds.height) b = this.bounds;
    else b = EsriUtils.getElementPageBounds(this.pageElement.divObject);
    EsriUtils.removeElementStyle(this.pageElement.divObject, "position; left; top;");

    this.divObject = document.createElement("table");
    this.divObject.id = this.divId;
    this.divObject.cellSpacing = 0;
    this.divObject.cellPadding = 0;
    this.divObject.border = 0;
    this.divObject.className = winStyle;
    EsriUtils.setElementStyle(this.divObject, "position:absolute; left:" + b.left + "px; top:" + b.top + "px;");

    var tbody = this.divObject.appendChild(document.createElement("tbody"));
    var topRow = tbody.appendChild(document.createElement("tr"));
    var cellTL = topRow.appendChild(document.createElement("td"));
    cellTL.className = winStyle + "CellTL";
    var cellT = topRow.appendChild(document.createElement("td"));
    cellT.className = winStyle + "CellT";
    var cellTR = topRow.appendChild(document.createElement("td"));
    cellTR.className = winStyle + "CellTR";

    var midRow = tbody.appendChild(document.createElement("tr"));
    var cellL = midRow.appendChild(document.createElement("td"));
    cellL.className = winStyle + "CellL";
    var cellC = midRow.appendChild(document.createElement("td"));
    cellC.className = winStyle + "CellC";
    cellC.vAlign = "top";
    var cellR = midRow.appendChild(document.createElement("td"));
    cellR.className = winStyle + "CellR";

    var botRow = tbody.appendChild(document.createElement("tr"));
    var cellBL = botRow.appendChild(document.createElement("td"));
    cellBL.className = winStyle + "CellBL";
    var cellB = botRow.appendChild(document.createElement("td"));
    cellB.className = winStyle + "CellB";
    var cellBR = botRow.appendChild(document.createElement("td"));
    cellBR.className = winStyle + "CellBR";

    var contentTable = cellC.appendChild(document.createElement("table"));
    contentTable.width = "100%";
    contentTable.height = "100%";
    contentTable.cellSpacing = 0;
    contentTable.cellPadding = 0;
    contentTable.border = 0;
    contentTable.className = winStyle + "Layout";

    var contentBody = contentTable.appendChild(document.createElement("tbody"));

    if (this.showTitleBar) {
      var titleRow = contentBody.appendChild(document.createElement("tr"));
      titleRow.vAlign = "top";

      titleBar = titleRow.appendChild(document.createElement("td")).appendChild(document.createElement("table"));
      titleBar.className = winStyle + "TitleBar";
      titleBar.width = "100%";
      titleBar.cellSpacing = 1;
      titleBar.cellPadding = 1;
      var titleRowTable = titleBar.appendChild(document.createElement("tbody")).appendChild(document.createElement("tr"));
      var titleCell = titleRowTable.appendChild(document.createElement("td"));
      titleCell.width = "100%";
      this.title = titleCell.appendChild(document.createElement("span"));
      this.title.className = winStyle + "TitleText";
      this.title.appendChild(document.createTextNode(titleTxt));

      titleBar.onclick = function(event) {
        EsriUtils.stopEvent(event);
        (self.windowMgr) ? self.windowMgr.toFront(self.id) : self.toFront();
        return false;
      }

      if (this.fittable) {
        titleBar.ondblclick = function(event) {
          EsriUtils.stopEvent(event);
          self.fit();
          return false;
        }
      }

      if (this.collapsable) {
        colImg = titleRowTable.appendChild(document.createElement("td")).appendChild(document.createElement("img"));
        colImg.src = pixelImg;

        if (this.collapsed) colImg.className = winStyle + "Expand";
        else colImg.className = winStyle + "Collapse";

        colImg.onclick = function(event) {
          EsriUtils.stopEvent(event);
          if (self.collapsed) self.expand();
          else self.collapse();
        };
      }

      if (this.closable) {
        cloImg = titleRowTable.appendChild(document.createElement("td")).appendChild(document.createElement("img"));
        cloImg.src = pixelImg;
        cloImg.className = winStyle + "Close";
        cloImg.onclick = function(event) { self.hide(); EsriUtils.stopEvent(event); };
      }

      if (this.movable) {
        moveAction = new EsriDragElementAction(true);
        moveAction.activate(titleRow, processMoveEnd, processMove);
      }
    }

    contentRow = contentBody.appendChild(document.createElement("tr"));
    contentRow.vAlign = "top";
    var contentCell = contentRow.appendChild(document.createElement("td"));
    contentCell.height = "100%";
    EsriUtils.setElementStyle(contentCell, "position:relative;");
    var chks;
    if (EsriUtils.isIE6) chks = EsriUtils.getCheckBoxStates(this.pageElement.divObject);
    this.content = contentCell.appendChild(this.pageElement.divObject);
    if (EsriUtils.isIE6) EsriUtils.setCheckBoxStates(this.pageElement.divObject, chks);
    this.content.className = winStyle + "Content";

    if (this.showStatusBar) {
      var statusRow = contentBody.appendChild(document.createElement("tr"));
      statusRow.vAlign = "bottom";
      statusDiv = statusRow.appendChild(document.createElement("td")).appendChild(document.createElement("div"));
      statusDiv.className = winStyle + "StatusBar";
      this.status = statusDiv.appendChild(document.createElement("span"));
      this.status.className = winStyle + "StatusBarText";
    }

    if (! container) origContainer = document.body;
    else origContainer = container;

    origContainer.appendChild(this.divObject);
    updateBounds();

    if (this.resizable) {
      resizeAction = new EsriResizeElementAction(true, this.minWidth, this.minHeight, this.maxWidth, this.maxHeight);
      resizeAction.activate(this.divObject, processResizeEnd, processResize);
    }

    if (this.collapsed) this.collapse(true);
    if (this.closed) this.hide(true);
    normalize();
  }

  function processMove(x, y, end) {
    if (! moveOutline) {
      moveOutline = document.body.appendChild(document.createElement("table"));
      moveOutline.className = winStyle + "MoveOutline";
      if (self.showTitleBar) {
        var td = moveOutline.appendChild(document.createElement("tbody")).appendChild(document.createElement("tr")).appendChild(document.createElement("td"));
        td.valign = "middle";
        td.align = "center";
        td.width = "100%";
        td.height = "100%";
        td.appendChild(self.title.cloneNode(true));
      }
      EsriUtils.setElementStyle(moveOutline, "position:absolute; width:" + self.bounds.width + "px; height:" + self.bounds.height + "px;");
      EsriUtils.setElementOpacity(moveOutline, 0.25);
      EsriUtils.setElementOpacity(self.divObject, 0.5);
    }

    var wl = self.bounds.left + x;
    var wt = self.bounds.top + y;
    var l = (wl < 0) ? 0 : wl;
    var t = (wt < 0) ? 0 : wt;
    EsriUtils.setElementStyle(moveOutline, "left:" + l + "px; top:" + t + "px;");
    if (end) {
      EsriUtils.setElementStyle(self.divObject, "left:" + l + "px; top:" + t + "px;");
      EsriUtils.setElementOpacity(self.divObject, 1);
    }
  }

  function processMoveEnd(x, y) {
    if (isNaN(x) || isNaN(y)) return;
    processMove(x, y, true);
    EsriUtils.removeElement(moveOutline);

⌨️ 快捷键说明

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