home *** CD-ROM | disk | FTP | other *** search
- /* ======================================================================
- OBJECT: com_netobjects_Dialog
-
- DESC: This control allows developers to render 3 different kinds of
- dialogs from one simple object: alert, prompt and confirm.
-
- TESTED
- PLATFORMS: Netscape Navigator 4.05,
- Microsoft Internet Explorer 4.01
- ====================================================================== */
- function com_netobjects_Dialog(params) {
-
- // Public Properties
- this.name = (params.name != null) ? params.name : "";
- if ((params.dlgType.toLowerCase() != "prompt") && (params.dlgType.toLowerCase() != "confirm"))
- {this.dlgType = "alert"} else {this.dlgType = params.dlgType.toLowerCase()};
- this.message = (params.message != null) ? params.message : "";
- this.value = (params.value != null) ? params.value : "";
-
- this.testMode = (params.testMode != null) ? params.testMode : "none"
-
- // Private Properties
- this.validateProperties = _dialog_validateProperties;
-
- // Public Methods
- this.open = _dialog_open;
-
- // Public Events
- this.onOpen = _dialog_onOpen;
-
- // Validate object properties
- this.validateProperties();
-
- // Public Methods ----------------------------------------
- /* ======================================================================
-
- METHOD: _dialog_open. Opens the JavaScript dialog box of the type indicated
- by this.dlgType.
-
- ====================================================================== */
- function _dialog_open() {
-
- if (this.dlgType == "alert") {
- eval("alert(\"" + this.message + "\")");
- } else if (this.dlgType == "prompt") {
- eval("this.value = prompt(\"" + this.message + "\",\""+ this.value + "\")");
- } else if (this.dlgType == "confirm") {
- eval("this.value = confirm(\"" + this.message + "\")");
- }
-
- // Fire public events
- this.onOpen();
-
- } // END _dialog_open
-
-
- // Private Methods ----------------------------------------
- /* ======================================================================
-
- METHOD: _dialog_validateProperties. If the test mode is set,
- generate error and/or warning messages if required or recommended properties
- are set with invalid property values or are not set at all.
-
- ====================================================================== */
- function _dialog_validateProperties() {
- if ((this.testMode.toLowerCase() == "text") || (this.testMode.toLowerCase() == "alerts")) {
- var errors = new Array()
- iIndex = 0;
-
- // Check for errors
- if (this.name == "")
- errors[iIndex++] = "Name is a required property.";
- if (params.dlgType == "")
- errors[iIndex++] = "dlgType is a required property.";
-
- // Display errors
- for (var i=0; i<errors.length; i++) {
- if (this.testMode.toLowerCase() == "text")
- document.write( "<BR><HR><B><FONT COLOR=RED>TEST MODE, com_netobjects_Dialog, '" + this.name + "' : </FONT> " + errors[i] + "</B><HR>\n");
- else
- alert("TEST MODE, com_netobjects_Dialog, '" + this.name + "' : " + errors[i]);
-
- }
- }
- } // END _dialog_validateProperties
-
-
-
-
- // Public Event Handlers ----------------------------------------
- function _dialog_onOpen() {
- }
-
- } // END CONSTRUCTOR com_netobjects_Dialog
-
-