Bootstrapping mechanism for the mxGraph thin client. The production version of this file contains all code required to run the mxGraph thin client, as well as global constants to identify the browser and operating system in use. You may have to load chrome://global/content/contentAreaUtils.js in your page to disable certain security restrictions in Mozilla.
mxClient | Bootstrapping mechanism for the mxGraph thin client. |
Variables | |
VERSION | Contains the current version of the mxGraph library. |
IS_IE | True if the current browser is Internet Explorer 10 or below. |
IS_IE6 | True if the current browser is Internet Explorer 6.x. |
IS_IE11 | True if the current browser is Internet Explorer 11.x. |
IS_EDGE | True if the current browser is Microsoft Edge. |
IS_QUIRKS | True if the current browser is Internet Explorer and it is in quirks mode. |
IS_EM | True if the browser is IE11 in enterprise mode (IE8 standards mode). |
VML_PREFIX | Prefix for VML namespace in node names. |
OFFICE_PREFIX | Prefix for VML office namespace in node names. |
IS_NS | True if the current browser is Netscape (including Firefox). |
IS_OP | True if the current browser is Opera. |
IS_OT | True if -o-transform is available as a CSS style, ie for Opera browsers based on a Presto engine with version 2.5 or later. |
IS_SF | True if the current browser is Safari. |
IS_ANDROID | Returns true if the user agent contains Android. |
IS_IOS | Returns true if the user agent is an iPad, iPhone or iPod. |
IS_GC | True if the current browser is Google Chrome. |
IS_CHROMEAPP | True if the this is running inside a Chrome App. |
IS_FF | True if the current browser is Firefox. |
IS_MT | True if -moz-transform is available as a CSS style. |
IS_VML | True if the browser supports VML. |
IS_SVG | True if the browser supports SVG. |
NO_FO | True if foreignObject support is not available. |
IS_WIN | True if the client is a Windows. |
IS_MAC | True if the client is a Mac. |
IS_CHROMEOS | True if the client is a Chrome OS. |
IS_TOUCH | True if this device supports touchstart/-move/-end events (Apple iOS, Android, Chromebook and Chrome Browser on touch-enabled devices). |
IS_POINTER | True if this device supports Microsoft pointer events (always false on Macs). |
IS_LOCAL | True if the documents location does not start with http:// or https://. |
defaultBundles | Contains the base names of the default bundles if mxLoadResources is false. |
Functions | |
isBrowserSupported | Returns true if the current browser is supported, that is, if mxClient.IS_VML or mxClient.IS_SVG is true. |
link | Adds a link node to the head of the document. |
loadResources | Helper method to load the default bundles if mxLoadResources is false. |
include | Dynamically adds a script node to the document header. |
Variables | |
mxLoadResources | Optional global config variable to toggle loading of the two resource files in mxGraph and mxEditor. |
mxForceIncludes | Optional global config variable to force loading the JavaScript files in development mode. |
mxResourceExtension | Optional global config variable to specify the extension of resource files. |
mxLoadStylesheets | Optional global config variable to toggle loading of the CSS files when the library is initialized. |
basePath | Basepath for all URLs in the core without trailing slash. |
imageBasePath | Basepath for all images URLs in the core without trailing slash. |
language | Defines the language of the client, eg. |
defaultLanguage | Defines the default language which is used in the common resource files. |
languages | Defines the optional array of all supported language extensions. |
IS_IE: navigator.userAgent !
True if the current browser is Internet Explorer 10 or below. Use mxClient.IS_IE11 to detect IE 11.
isBrowserSupported: function()
Returns true if the current browser is supported, that is, if mxClient.IS_VML or mxClient.IS_SVG is true.
if (!mxClient.isBrowserSupported()) { mxUtils.error('Browser is not supported!', 200, false); }
link: function( rel, href, doc, id )
Adds a link node to the head of the document. Use this to add a stylesheet to the page as follows:
mxClient.link('stylesheet', filename);
where filename is the (relative) URL of the stylesheet. The charset is hardcoded to ISO-8859-1 and the type is text/css.
rel | String that represents the rel attribute of the link node. |
href | String that represents the href attribute of the link node. |
doc | Optional parent document of the link node. |
id | unique id for the link element to check if it already exists |
loadResources: function( fn, lan )
Helper method to load the default bundles if mxLoadResources is false.
fn | Function to call after all resources have been loaded. |
lan | Optional string to pass to mxResources.add. |
include: function( src )
Dynamically adds a script node to the document header.
In production environments, the includes are resolved in the mxClient.js file to reduce the number of requests required for client startup. This function should only be used in development environments, but not in production systems.
Optional global config variable to toggle loading of the two resource files in mxGraph and mxEditor. Default is true. NOTE: This is a global variable, not a variable of mxClient. If this is false, you can use mxClient.loadResources with its callback to load the default bundles asynchronously.
<script type="text/javascript"> var mxLoadResources = false; </script> <script type="text/javascript" src="/path/to/core/directory/js/mxClient.js"></script>
Optional global config variable to force loading the JavaScript files in development mode. Default is undefined. NOTE: This is a global variable, not a variable of mxClient.
<script type="text/javascript"> var mxLoadResources = true; </script> <script type="text/javascript" src="/path/to/core/directory/js/mxClient.js"></script>
Optional global config variable to specify the extension of resource files. Default is true. NOTE: This is a global variable, not a variable of mxClient.
<script type="text/javascript"> var mxResourceExtension = '.txt'; </script> <script type="text/javascript" src="/path/to/core/directory/js/mxClient.js"></script>
Optional global config variable to toggle loading of the CSS files when the library is initialized. Default is true. NOTE: This is a global variable, not a variable of mxClient.
<script type="text/javascript"> var mxLoadStylesheets = false; </script> <script type="text/javascript" src="/path/to/core/directory/js/mxClient.js"></script>
Basepath for all URLs in the core without trailing slash. Default is ‘.’. Set mxBasePath prior to loading the mxClient library as follows to override this setting:
<script type="text/javascript"> mxBasePath = '/path/to/core/directory'; </script> <script type="text/javascript" src="/path/to/core/directory/js/mxClient.js"></script>
When using a relative path, the path is relative to the URL of the page that contains the assignment. Trailing slashes are automatically removed.
Basepath for all images URLs in the core without trailing slash. Default is mxClient.basePath + ‘/images’. Set mxImageBasePath prior to loading the mxClient library as follows to override this setting:
<script type="text/javascript"> mxImageBasePath = '/path/to/image/directory'; </script> <script type="text/javascript" src="/path/to/core/directory/js/mxClient.js"></script>
When using a relative path, the path is relative to the URL of the page that contains the assignment. Trailing slashes are automatically removed.
Defines the language of the client, eg. en for english, de for german etc. The special value ‘none’ will disable all built-in internationalization and resource loading. See mxResources.getSpecialBundle for handling identifiers with and without a dash.
Set mxLanguage prior to loading the mxClient library as follows to override this setting:
<script type="text/javascript"> mxLanguage = 'en'; </script> <script type="text/javascript" src="js/mxClient.js"></script>
If internationalization is disabled, then the following variables should be overridden to reflect the current language of the system. These variables are cleared when i18n is disabled. mxEditor.askZoomResource, mxEditor.lastSavedResource, mxEditor.currentFileResource, mxEditor.propertiesResource, mxEditor.tasksResource, mxEditor.helpResource, mxEditor.outlineResource, mxElbowEdgeHandler.doubleClickOrientationResource, mxUtils.errorResource, mxUtils.closeResource, mxGraphSelectionModel.doneResource, mxGraphSelectionModel.updatingSelectionResource, mxGraphView.doneResource, mxGraphView.updatingDocumentResource, <mxCellRenderer.collapseExpandResource>, mxGraph.containsValidationErrorsResource and mxGraph.alreadyConnectedResource.
Defines the default language which is used in the common resource files. Any resources for this language will only load the common resource file, but not the language-specific resource file. Default is ‘en’.
Set mxDefaultLanguage prior to loading the mxClient library as follows to override this setting:
<script type="text/javascript"> mxDefaultLanguage = 'de'; </script> <script type="text/javascript" src="js/mxClient.js"></script>
Defines the optional array of all supported language extensions. The default language does not have to be part of this list. See mxResources.isLanguageSupported.
<script type="text/javascript"> mxLanguages = ['de', 'it', 'fr']; </script> <script type="text/javascript" src="js/mxClient.js"></script>
This is used to avoid unnecessary requests to language files, ie. if a 404 will be returned.
Contains the current version of the mxGraph library.
VERSION: '4.2.2'
True if the current browser is Internet Explorer 10 or below.
IS_IE: navigator.userAgent !
True if the current browser is Internet Explorer 6.x.
IS_IE6: navigator.userAgent !
True if the current browser is Internet Explorer 11.x.
IS_IE11: navigator.userAgent !
True if the current browser is Microsoft Edge.
IS_EDGE: navigator.userAgent !
True if the current browser is Internet Explorer and it is in quirks mode.
IS_QUIRKS: navigator.userAgent !
True if the browser is IE11 in enterprise mode (IE8 standards mode).
IS_EM: 'spellcheck' in document.createElement( 'textarea' ) && document.documentMode
Prefix for VML namespace in node names.
VML_PREFIX: 'v'
Prefix for VML office namespace in node names.
OFFICE_PREFIX: 'o'
True if the current browser is Netscape (including Firefox).
IS_NS: navigator.userAgent !
True if the current browser is Opera.
IS_OP: navigator.userAgent !
True if -o-transform is available as a CSS style, ie for Opera browsers based on a Presto engine with version 2.5 or later.
IS_OT: navigator.userAgent !
True if the current browser is Safari.
IS_SF: /Apple Computer
Returns true if the user agent contains Android.
IS_ANDROID: navigator.appVersion.indexOf( 'Android' ) >
Returns true if the user agent is an iPad, iPhone or iPod.
IS_IOS: ( /iP(hone|od|ad)/.test(navigator.platform) )
True if the current browser is Google Chrome.
IS_GC: /Google Inc/.test( navigator.vendor )
True if the this is running inside a Chrome App.
IS_CHROMEAPP: window.chrome !
True if the current browser is Firefox.
IS_FF: typeof InstallTrigger !
True if the browser supports VML.
IS_VML: navigator.appName.toUpperCase()
True if the browser supports SVG.
IS_SVG: navigator.appName.toUpperCase() !
True if foreignObject support is not available.
NO_FO: !document.createElementNS || document.createElementNS( 'http://www.w3.org/2000/svg', 'foreignObject' ) !
True if the client is a Windows.
IS_WIN: navigator.appVersion.indexOf( 'Win' ) > 0
True if the client is a Mac.
IS_MAC: navigator.appVersion.indexOf( 'Mac' ) > 0
True if the client is a Chrome OS.
IS_CHROMEOS: /\bCrOS\b/.test( navigator.appVersion )
True if this device supports touchstart/-move/-end events (Apple iOS, Android, Chromebook and Chrome Browser on touch-enabled devices).
IS_TOUCH: 'ontouchstart' in document.documentElement
True if this device supports Microsoft pointer events (always false on Macs).
IS_POINTER: window.PointerEvent !
Contains the base names of the default bundles if mxLoadResources is false.
defaultBundles: []
Returns true if the current browser is supported, that is, if mxClient.IS_VML or mxClient.IS_SVG is true.
isBrowserSupported: function()
Adds a link node to the head of the document.
link: function( rel, href, doc, id )
Helper method to load the default bundles if mxLoadResources is false.
loadResources: function( fn, lan )
Dynamically adds a script node to the document header.
include: function( src )
Adds the default and current language properties file for the specified basename.
add: function( basename, lan, callback )
Hook for subclassers to return the URL for the special bundle.
getSpecialBundle: function( basename, lan )
Specifies the resource key for the zoom dialog.
mxEditor.prototype.askZoomResource
Specifies the resource key for the last saved info.
mxEditor.prototype.lastSavedResource
Specifies the resource key for the current file info.
mxEditor.prototype.currentFileResource
Specifies the resource key for the properties window title.
mxEditor.prototype.propertiesResource
Specifies the resource key for the tasks window title.
mxEditor.prototype.tasksResource
Specifies the resource key for the help window title.
mxEditor.prototype.helpResource
Specifies the resource key for the outline window title.
mxEditor.prototype.outlineResource
Specifies the resource key for the tooltip to be displayed on the single control point for routed edges.
mxElbowEdgeHandler.prototype.doubleClickOrientationResource
Specifies the resource key for the title of the error window.
errorResource: ( mxClient. language ! = 'none' ) ? 'error' : ''
Specifies the resource key for the label of the close button.
closeResource: ( mxClient. language ! = 'none' ) ? 'close' : ''
Specifies the resource key for the status message after a long operation.
mxGraphSelectionModel.prototype.doneResource
Specifies the resource key for the status message while the selection is being updated.
mxGraphSelectionModel.prototype.updatingSelectionResource
Specifies the resource key for the status message after a long operation.
mxGraphView.prototype.doneResource
Specifies the resource key for the warning message to be displayed when a collapsed cell contains validation errors.
mxGraph.prototype.containsValidationErrorsResource
Specifies the resource key for the error message to be displayed in non-multigraphs when two vertices are already connected.
mxGraph.prototype.alreadyConnectedResource
Hook for subclassers to disable support for a given language.
isLanguageSupported: function( lan )