📄 page.js
字号:
/*
* Isomorphic SmartClient
* Version 6.5 (2008-04-30)
* Copyright(c) 1998-2007 Isomorphic Software, Inc. All rights reserved.
* "SmartClient" is a trademark of Isomorphic Software, Inc.
*
* licensing@smartclient.com
*
* http://smartclient.com/license
*/
//> @class Page//// Provides information about the page you're loaded in. We define "page" here to be roughly// equivalent to the browser window or frame the libraries have been loaded in.//// @treeLocation Client Reference/System// @visibility external//<//// Create the Page singleton object//isc.ClassFactory.defineClass("Page");// define groups for documentation purposesisc.Page.addClassProperties({ _historyActions : [], // flag for whether page.onload has fired yet _doneLoading : false, //> @classAttr isc.Page.defaultUnsupportedBrowserURL (URL : "[SKIN]/unsupported_browser.html" : IRWA) // On a call to <code>Page.checkBrowserAndRedirect()</code>, if no explicit URL // is passed in, and the browser is not supported by ISC, redirect to this URL. // // @group files // @see Page.checkBrowserAndRedirect() // @visibility external //< // Note all the default load_skin.js files will call this method and pass in an // explicit URL for a page to redirect to. This default is unlikely to be modified as // it's easier to just modify the explicit URL passed in when the method is called. defaultUnsupportedBrowserURL : "[SKIN]/unsupported_browser.html", //> @classAttr isc.Page._directoryCache (array : [] : IRW) // URLs in our framework can have keywords embedded in them as // [SKIN] or [ISOMORPHIC], etc. This is where we store the expanded directory names. // Use Page.getURL() to figure that out. // // @group files // @see Page.setDirectories() //< _directoryCache : {}, //> @classAttr Page._protocolURLs (array : [...] : IRW) // Beginnings of URLs that correspond to protocols we recognize. // To support a new protocol in the URL assembly stuff below, // add it here. // @group files // @see Page.getURL() //< // "app-resource:" used by apollo _protocolURLs : ["http://","https://","file://","mailto:", "app-resource:"], //> @classAttr isc.Page.textDirection (TextDirection : (null) : IRW) // What direction is text supposed to run? // LTR (left to right, eg: English) or RTL (right to left, eg: Arabic) // @group textDirection // @platformNotes IE only //< textDirection:null, // don't remove: initalized to null so we will look up the value set in // the body tag if it hasn't been set in our framework. //> @classAttr isc.Page.pollPageSize (boolean : null : IRWA) // Advanced attribute which will cause SmartClient to constantly check for the introduction // of scrollbars due to resizing of native content by direct DOM manipulation, and // automatically adjust percent sized widgets if external code causes the browser window to // be resized. //< //> @type Page.TextDirection // Specifies RTL or LTR direction for text -- IE5+ and FF1.5+ only LTR:"ltr", // @value isc.Page.LTR Show text left-to-right (eg: English) RTL:"rtl" // @value isc.Page.RTL Show text right-to-left (eg: Arabic) // @group appearance //< });isc.Page.addClassMethods({//> @classMethod Page.finishedLoading() (A)// Routine called automatically by the EventHandler when the page finishes loading.// @group eventHandling//<finishedLoading : function () { // If we don't already have it, get the screen size now if (this.width == null || this.height == null) isc.EH._pageResize() isc.Page._doneLoading = true; isc.Log.logInfo("isc.Page is loaded"); // kick off the idle timer when the page starts isc.EH.startIdleTimer(); if (isc.Browser.isSafari) isc.Canvas.clearCSSCaches(); // Open the log window if it should be open if (!window.suppressAutoLogWindow) { var cookie = isc.LogViewer.getLogCookie(); if (cookie != null && cookie.keepOpen) { // NOTE: wait until any existing log window has had time to reconnect before // auto-opening the log window isc.Timer.setTimeout("isc.Log.show(true)", 1000); } } // If we're polling for page size changes, kick this off now. if (isc.Page.pollPageSize) isc.EH._pageResize();},//> @classMethod Page.isLoaded()// Has the page finished loading?//// @return (boolean) true == page is done loading// @visibility external//<isLoaded : function () { return this._doneLoading },// return the URL that should be used for an IFRAME that should be blankgetBlankFrameURL : function () { if (isc.Browser.isIE && ("https:" == window.location.protocol || document.domain != location.hostname )) { // In IE under HTTPS, using "about:blank" as the location for an IFRAME causes a bogus "Mix // of secure and insecure content" dialog, so instead fetch an empty html file. return this.getURL("[HELPERS]empty.html"); } // known to work in IE, Moz, Safari return "about:blank";},//> @classMethod Page.setTitle()// Set the title of the page, which is typically shown as part of the browser window title// @visibility external//<setTitle : function (title) { document.title = title;},//> @classMethod Page.setDirectories()// Set any and all of the directories that the page keeps track of in a single call.//// @param [directories] (object) Object of {directory:URL} paths.// If not specified, we will try to get directories specified in the window objecs.// @group files, images//<setDirectories : function (directories) { if (directories == null) { directories = { imgDir:window.imgDir, isomorphicDir:(window.isomorphicDir ? window.isomorphicDir : window.IsomorphicDir), isomorphicClientDir:window.isomorphicClientDir, isomorphicDocsDir:window.isomorphicDocsDir, skinDir:window.skinDir, helperDir:window.helperDir } } this._deriveAppDir(); this.setIsomorphicDir(directories.isomorphicDir); this.setIsomorphicClientDir(directories.isomorphicClientDir); this.setIsomorphicDocsDir(directories.isomorphicDocsDir); this.setAppImgDir(directories.imgDir); this.setSkinDir(directories.skinDir); this.setHelperDir(directories.helperDir);},// derive the base URL of the application. _deriveAppDir : function () { // get the path to the current file and strip off any query params and leaf file names var filePath = window.location.href; // strip off anything after a "?" if (filePath.contains("?")) filePath = filePath.substring(0,filePath.indexOf("?")); // # references node IDs which, according to the W3C cannot have slashes in them, but in // the AJAX world, # refs are often used to provide back button support rather than // actually reference any node ids in the DOM, so it's best that we don't break if # refs // contain slashes in the value. if (filePath.contains("#")) filePath = filePath.substring(0,filePath.indexOf("#")); // strip off the leaf file name if one exists if (filePath.charAt(filePath.length-1) != "/") { filePath = filePath.substring(0, filePath.lastIndexOf("/") + 1); } this._directoryCache.APP = filePath; //>DEBUG if (this.logIsInfoEnabled()) { this.logInfo("app dir is " + this._directoryCache.APP); } //<DEBUG // call getAppImgDir() so it will change based on the changed app dir... this.setAppImgDir();},//> @classMethod Page.getAppDir()// Returns the base URL of the application, which is the page URL minus the last non-directory // path component. For example, if the page is loaded from// <code>http://foo.com/bar/zoo.jsp</code>, appDir will be <code>http://foo.com/bar/</code>.// <P>// If other page-wide URLs such as +link{Page.setIsomorphicDir()} are specified as// relative paths, they are considered relative to this URL.//// @return (string) URL for page-specific files.// @group files// @visibility external//<getAppDir : function () { return this._directoryCache.APP;},// Application-specific resource directories// ---------------------------------------------------------------------------------------//> @classMethod Page.setAppImgDir()// Specify the directory for app-specific images.// <P>// This becomes the default location where any SmartClient component will load images from// unless the special "[SKIN]" prefix is used to indicate that an image is part of a skin.// <P>// Default is "[APP]images/"//// @param [URL] (string) New imgDir URL.// @group files, images// @visibility external//<// NOTE: Caches the combined appDir + imgDir.setAppImgDir : function (URL) { isc.Page._directoryCache.APPIMG = isc.Page.getURL(URL != null ? URL : "[APP]images/");},//> @classMethod Page.getAppImgDir()// Return the directory for app-specific images.//// @return (string) URL for page-specific images.// @group files, images// @visibility external//<getAppImgDir : function (imgDir) { // specifically check for an imgDir that has been specified as an absolute path. if ( imgDir != null && (isc.startsWith(imgDir, isc.slash) || this.getProtocol(imgDir) != isc.emptyString )) { return imgDir; } if (imgDir) return this._directoryCache.APPIMG + imgDir; else return this._directoryCache.APPIMG; },//> @classMethod Page.setAppFilesDir()// Specify the directory for miscellaneous app-specific files <b>other than</b> images, such as// +link{HTMLFlow.contentsURL,HTML fragments}, +link{ViewLoader,loadable views}, // XML or JSON flat data files, videos, etc.// <P>// This URL also becomes available via the prefix "[APPFILES]" for +link{rpcRequest.actionURL}.// <P>// Defaults to the value of +link{Page.getAppDir()}, that is, the current directory.//// @param [URL] (string) New app files URL.// @group files, images// @visibility external//<// NOTE: Caches the combined appDir + imgDir.setAppFilesDir : function (URL) { this._directoryCache.APPFILES = this.combineURLs(this.getAppDir(), URL);},//> @classMethod Page.getAppFilesDir()// Returns the directory for application-specific files (other than images).//// @param [URL] (string) New app files URL.// @group files, images// @visibility external//<getAppFilesDir : function (URL) { return this._directoryCache.APPFILES;},// Isomorphic-supplied file locations// ---------------------------------------------------------------------------------------//> @classMethod Page.setIsomorphicDir()// Specify the root directory for Isomorphic-supplied files.//// @param [URL] (string) New IsomorphicDir URL.// @group files// @visibility external//<setIsomorphicDir : function (URL) { this._directoryCache.ISOMORPHIC = this.combineURLs(this.getAppDir(), URL != null ? URL : "../isomorphic/"); // call setSkinDir() and setHelperDir() to reset those cached values this.setIsomorphicClientDir(); this.setIsomorphicDocsDir();},//> @classMethod Page.getIsomorphicDir()// Return the root directory for Isomorphic-specific files.//// @return (string) IsomorphicDir URL.// @group files// @visibility external//<getIsomorphicDir : function () { return this._directoryCache.ISOMORPHIC;},// Note skins groupDef is in Canvas.js//> @classMethod Page.setSkinDir()// Specify the URL for media that's part of the skin//// @param [URL] (string) New skinDir URL// @group skins, files, images// @visibility external//<setSkinDir : function (URL) { this._directoryCache.SKIN = this.combineURLs(this.getAppDir(), URL != null ? URL : "[ISOMORPHIC]/skins/standard/"); // remember the skin image directory this._directoryCache.SKINIMG = this._directoryCache.SKIN + "images/"; if (isc.Canvas) isc.Canvas._blankTemplate = isc.Canvas._blankURL = null;},//> @classMethod Page.getSkinDir()// Return the directory for media that's part of the skin//// @return (string) base URL for skin media// @group files, images// @visibility external//<getSkinDir : function () { return this._directoryCache.SKIN;},//> @classMethod Page.getSkinImgDir()// Return the directory for a skin image.//// @param [imgDir] (URL) Partial URL (relative to Page._skinDir) where the image lives.// If not supplied, will use "images/"// @return (string) URL for page-specific images.// @group files, images// @visibility external//<getSkinImgDir : function (imgDir) { if (imgDir == null) return this._directoryCache.SKINIMG; return this.combineURLs(this._directoryCache.SKIN, imgDir);},// Internal directory structures// ---------------------------------------------------------------------------------------// Applications need to tell us the relative path to the "isomorphic/" directory and may// relocate the skin outside of the "isomorphic/" area, however, none of the rest of// the structure under "isomorphic/" is really intended to be changed. The most likely reason// to actually do so might involve needing to move the helpers dir to password protect the log// window.//> @classMethod Page.setIsomorphicClientDir()// Specify the root directory for Isomorphic client files.//// @param [URL] (string) New URL for root of client files.// @group files//<// NOTE: not visible: we don't actually want customers to relocate the client dirsetIsomorphicClientDir : function (URL) { this._directoryCache.ISOMORPHIC_CLIENT = this.combineURLs(this.getAppDir(), URL != null ? URL : "[ISOMORPHIC]/system/");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -