mxClient

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.

Summary
mxClientBootstrapping mechanism for the mxGraph thin client.
Variables
VERSIONContains the current version of the mxGraph library.
IS_IETrue if the current browser is Internet Explorer 10 or below.
IS_IE6True if the current browser is Internet Explorer 6.x.
IS_IE11True if the current browser is Internet Explorer 11.x.
IS_EDGETrue if the current browser is Microsoft Edge.
IS_QUIRKSTrue if the current browser is Internet Explorer and it is in quirks mode.
IS_EMTrue if the browser is IE11 in enterprise mode (IE8 standards mode).
VML_PREFIXPrefix for VML namespace in node names.
OFFICE_PREFIXPrefix for VML office namespace in node names.
IS_NSTrue if the current browser is Netscape (including Firefox).
IS_OPTrue if the current browser is Opera.
IS_OTTrue 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_SFTrue if the current browser is Safari.
IS_ANDROIDReturns true if the user agent contains Android.
IS_IOSReturns true if the user agent is an iPad, iPhone or iPod.
IS_GCTrue if the current browser is Google Chrome.
IS_CHROMEAPPTrue if the this is running inside a Chrome App.
IS_FFTrue if the current browser is Firefox.
IS_MTTrue if -moz-transform is available as a CSS style.
IS_VMLTrue if the browser supports VML.
IS_SVGTrue if the browser supports SVG.
NO_FOTrue if foreignObject support is not available.
IS_WINTrue if the client is a Windows.
IS_MACTrue if the client is a Mac.
IS_CHROMEOSTrue if the client is a Chrome OS.
IS_TOUCHTrue if this device supports touchstart/-move/-end events (Apple iOS, Android, Chromebook and Chrome Browser on touch-enabled devices).
IS_POINTERTrue if this device supports Microsoft pointer events (always false on Macs).
IS_LOCALTrue if the documents location does not start with http:// or https://.
defaultBundlesContains the base names of the default bundles if mxLoadResources is false.
Functions
isBrowserSupportedReturns true if the current browser is supported, that is, if mxClient.IS_VML or mxClient.IS_SVG is true.
linkAdds a link node to the head of the document.
loadResourcesHelper method to load the default bundles if mxLoadResources is false.
includeDynamically adds a script node to the document header.
Variables
mxLoadResourcesOptional global config variable to toggle loading of the two resource files in mxGraph and mxEditor.
mxForceIncludesOptional global config variable to force loading the JavaScript files in development mode.
mxResourceExtensionOptional global config variable to specify the extension of resource files.
mxLoadStylesheetsOptional global config variable to toggle loading of the CSS files when the library is initialized.
basePathBasepath for all URLs in the core without trailing slash.
imageBasePathBasepath for all images URLs in the core without trailing slash.
languageDefines the language of the client, eg.
defaultLanguageDefines the default language which is used in the common resource files.
languagesDefines the optional array of all supported language extensions.

Variables

VERSION

VERSION: '4.2.2'

Contains the current version of the mxGraph library.  The strings that communicate versions of mxGraph use the following format.

versionMajor.versionMinor.buildNumber.revisionNumber

Current version is 4.2.2.

IS_IE

IS_IE: navigator.userAgent !

True if the current browser is Internet Explorer 10 or below.  Use mxClient.IS_IE11 to detect IE 11.

IS_IE6

IS_IE6: navigator.userAgent !

True if the current browser is Internet Explorer 6.x.

IS_IE11

IS_IE11: navigator.userAgent !

True if the current browser is Internet Explorer 11.x.

IS_EDGE

IS_EDGE: navigator.userAgent !

True if the current browser is Microsoft Edge.

IS_QUIRKS

IS_QUIRKS: navigator.userAgent !

True if the current browser is Internet Explorer and it is in quirks mode.

IS_EM

IS_EM: 'spellcheck' in document.createElement(
   'textarea'
) && document.documentMode

True if the browser is IE11 in enterprise mode (IE8 standards mode).

VML_PREFIX

VML_PREFIX: 'v'

Prefix for VML namespace in node names.  Default is ‘v’.

OFFICE_PREFIX

OFFICE_PREFIX: 'o'

Prefix for VML office namespace in node names.  Default is ‘o’.

IS_NS

IS_NS: navigator.userAgent !

True if the current browser is Netscape (including Firefox).

IS_OP

IS_OP: navigator.userAgent !

True if the current browser is Opera.

IS_OT

IS_OT: 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_SF

IS_SF: /Apple Computer

True if the current browser is Safari.

IS_ANDROID

IS_ANDROID: navigator.appVersion.indexOf('Android') >

Returns true if the user agent contains Android.

IS_IOS

IS_IOS: (/iP(hone|od|ad)/.test(navigator.platform))

Returns true if the user agent is an iPad, iPhone or iPod.

IS_GC

IS_GC: /Google Inc/.test(navigator.vendor)

True if the current browser is Google Chrome.

IS_CHROMEAPP

IS_CHROMEAPP: window.chrome !

True if the this is running inside a Chrome App.

IS_FF

IS_FF: typeof InstallTrigger !

True if the current browser is Firefox.

IS_MT

True if -moz-transform is available as a CSS style.  This is the case for all Firefox-based browsers newer than or equal 3, such as Camino, Iceweasel, Seamonkey and Iceape.

IS_VML

IS_VML: navigator.appName.toUpperCase()

True if the browser supports VML.

IS_SVG

IS_SVG: navigator.appName.toUpperCase() !

True if the browser supports SVG.

NO_FO

NO_FO: !document.createElementNS || document.createElementNS(
   'http://www.w3.org/2000/svg',
   'foreignObject'
) !

True if foreignObject support is not available.  This is the case for Opera, older SVG-based browsers and all versions of IE.

IS_WIN

IS_WIN: navigator.appVersion.indexOf('Win') > 0

True if the client is a Windows.

IS_MAC

IS_MAC: navigator.appVersion.indexOf('Mac') > 0

True if the client is a Mac.

IS_CHROMEOS

IS_CHROMEOS: /\bCrOS\b/.test(navigator.appVersion)

True if the client is a Chrome OS.

IS_TOUCH

IS_TOUCH: 'ontouchstart' in document.documentElement

True if this device supports touchstart/-move/-end events (Apple iOS, Android, Chromebook and Chrome Browser on touch-enabled devices).

IS_POINTER

IS_POINTER: window.PointerEvent !

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

defaultBundles: []

Contains the base names of the default bundles if mxLoadResources is false.

Functions

isBrowserSupported

isBrowserSupported: function()

Returns true if the current browser is supported, that is, if mxClient.IS_VML or mxClient.IS_SVG is true.

Example

if (!mxClient.isBrowserSupported())
{
  mxUtils.error('Browser is not supported!', 200, false);
}

link

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.

Parameters

relString that represents the rel attribute of the link node.
hrefString that represents the href attribute of the link node.
docOptional parent document of the link node.
idunique id for the link element to check if it already exists

loadResources

loadResources: function(fn,
lan)

Helper method to load the default bundles if mxLoadResources is false.

Parameters

fnFunction to call after all resources have been loaded.
lanOptional string to pass to mxResources.add.

include

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.

Variables

mxLoadResources

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>

mxForceIncludes

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>

mxResourceExtension

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>

mxLoadStylesheets

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

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.

imageBasePath

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.

language

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.

defaultLanguage

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>

languages

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.

VERSION: '4.2.2'
Contains the current version of the mxGraph library.
IS_IE: navigator.userAgent !
True if the current browser is Internet Explorer 10 or below.
IS_IE6: navigator.userAgent !
True if the current browser is Internet Explorer 6.x.
IS_IE11: navigator.userAgent !
True if the current browser is Internet Explorer 11.x.
IS_EDGE: navigator.userAgent !
True if the current browser is Microsoft Edge.
IS_QUIRKS: navigator.userAgent !
True if the current browser is Internet Explorer and it is in quirks mode.
IS_EM: 'spellcheck' in document.createElement(
   'textarea'
) && document.documentMode
True if the browser is IE11 in enterprise mode (IE8 standards mode).
VML_PREFIX: 'v'
Prefix for VML namespace in node names.
OFFICE_PREFIX: 'o'
Prefix for VML office namespace in node names.
IS_NS: navigator.userAgent !
True if the current browser is Netscape (including Firefox).
IS_OP: navigator.userAgent !
True if the current browser is Opera.
IS_OT: 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_SF: /Apple Computer
True if the current browser is Safari.
IS_ANDROID: navigator.appVersion.indexOf('Android') >
Returns true if the user agent contains Android.
IS_IOS: (/iP(hone|od|ad)/.test(navigator.platform))
Returns true if the user agent is an iPad, iPhone or iPod.
IS_GC: /Google Inc/.test(navigator.vendor)
True if the current browser is Google Chrome.
IS_CHROMEAPP: window.chrome !
True if the this is running inside a Chrome App.
IS_FF: typeof InstallTrigger !
True if the current browser is Firefox.
IS_VML: navigator.appName.toUpperCase()
True if the browser supports VML.
IS_SVG: navigator.appName.toUpperCase() !
True if the browser supports SVG.
NO_FO: !document.createElementNS || document.createElementNS(
   'http://www.w3.org/2000/svg',
   'foreignObject'
) !
True if foreignObject support is not available.
IS_WIN: navigator.appVersion.indexOf('Win') > 0
True if the client is a Windows.
IS_MAC: navigator.appVersion.indexOf('Mac') > 0
True if the client is a Mac.
IS_CHROMEOS: /\bCrOS\b/.test(navigator.appVersion)
True if the client is a Chrome OS.
IS_TOUCH: 'ontouchstart' in document.documentElement
True if this device supports touchstart/-move/-end events (Apple iOS, Android, Chromebook and Chrome Browser on touch-enabled devices).
IS_POINTER: window.PointerEvent !
True if this device supports Microsoft pointer events (always false on Macs).
defaultBundles: []
Contains the base names of the default bundles if mxLoadResources is false.
isBrowserSupported: function()
Returns true if the current browser is supported, that is, if mxClient.IS_VML or mxClient.IS_SVG is true.
link: function(rel,
href,
doc,
id)
Adds a link node to the head of the document.
loadResources: function(fn,
lan)
Helper method to load the default bundles if mxLoadResources is false.
include: function(src)
Dynamically adds a script node to the document header.
Extends mxEventSource to implement a graph component for the browser.
Extends mxEventSource to implement an application wrapper for a graph that adds actions, I/O using mxCodec, auto-layout using mxLayoutManager, command history using undoManager, and standard dialogs and widgets, eg.
add: function(basename,
lan,
callback)
Adds the default and current language properties file for the specified basename.
Basepath for all URLs in the core without trailing slash.
getSpecialBundle: function(basename,
lan)
Hook for subclassers to return the URL for the special bundle.
mxEditor.prototype.askZoomResource
Specifies the resource key for the zoom dialog.
mxEditor.prototype.lastSavedResource
Specifies the resource key for the last saved info.
mxEditor.prototype.currentFileResource
Specifies the resource key for the current file info.
mxEditor.prototype.propertiesResource
Specifies the resource key for the properties window title.
mxEditor.prototype.tasksResource
Specifies the resource key for the tasks window title.
mxEditor.prototype.helpResource
Specifies the resource key for the help window title.
mxEditor.prototype.outlineResource
Specifies the resource key for the outline window title.
mxElbowEdgeHandler.prototype.doubleClickOrientationResource
Specifies the resource key for the tooltip to be displayed on the single control point for routed edges.
errorResource: (mxClient.language ! =  'none') ? 'error' : ''
Specifies the resource key for the title of the error window.
closeResource: (mxClient.language ! =  'none') ? 'close' : ''
Specifies the resource key for the label of the close button.
mxGraphSelectionModel.prototype.doneResource
Specifies the resource key for the status message after a long operation.
mxGraphSelectionModel.prototype.updatingSelectionResource
Specifies the resource key for the status message while the selection is being updated.
mxGraphView.prototype.doneResource
Specifies the resource key for the status message after a long operation.
Specifies the resource key for the status message while the document is being updated.
mxGraph.prototype.containsValidationErrorsResource
Specifies the resource key for the warning message to be displayed when a collapsed cell contains validation errors.
mxGraph.prototype.alreadyConnectedResource
Specifies the resource key for the error message to be displayed in non-multigraphs when two vertices are already connected.
isLanguageSupported: function(lan)
Hook for subclassers to disable support for a given language.
Close