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.
IS_IE6True if the current browser is Internet Explorer 6.x.
IS_QUIRKSTrue if the current browser is Internet Explorer and it is in quirks 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.
IS_SFTrue if the current browser is Safari.
IS_IOSReturns true if the user agent is an iPad, iPhone or iPod.
IS_GCTrue if the current browser is Google Chrome.
IS_FFTrue if the current browser is Firefox.
IS_MTTrue if -moz-transform is available as a CSS style.
IS_SVGTrue if the browser supports SVG.
NO_FOTrue if foreignObject support is not available.
IS_VMLTrue if the browser supports VML.
IS_MACTrue if the client is a Mac.
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 MS pointer events.
IS_LOCALTrue if the documents location does not start with http:// or https://.
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.
includeDynamically adds a script node to the document header.
disposeFrees up memory in IE by resolving cyclic dependencies between the DOM and the JavaScript objects.
Variables
mxLoadResourcesOptional global config variable to toggle loading of the two resource files in mxGraph and mxEditor.
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

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 2.5.0.1.

IS_IE

IS_IE: navigator.userAgent.indexOf('MSIE') >

True if the current browser is Internet Explorer.

IS_IE6

IS_IE6: navigator.userAgent.indexOf('MSIE 6') >

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

IS_QUIRKS

IS_QUIRKS: navigator.userAgent.indexOf('MSIE') >

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

VML_PREFIX

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

OFFICE_PREFIX

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

IS_NS

IS_NS: navigator.userAgent.indexOf('Mozilla/') >

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

IS_OP

IS_OP: navigator.userAgent.indexOf('Opera/') >

True if the current browser is Opera.

IS_OT

True if -o-transform is available as a CSS style.  This is the case for Opera browsers that use Presto/2.5 and later.

IS_SF

IS_SF: navigator.userAgent.indexOf('AppleWebKit/') >

True if the current browser is Safari.

IS_IOS

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

IS_GC

IS_GC: navigator.userAgent.indexOf('Chrome/') >

True if the current browser is Google Chrome.

IS_FF

IS_FF: navigator.userAgent.indexOf('Firefox/') >

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_SVG

IS_SVG: navigator.userAgent.indexOf('Firefox/') >

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 and older SVG-based browsers.

IS_VML

IS_VML: navigator.appName.toUpperCase()

True if the browser supports VML.

IS_MAC

True if the client is a Mac.

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 MS pointer events.

IS_LOCAL

True if the documents location does not start with http:// or https://.

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)

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.

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.

dispose

dispose: function()

Frees up memory in IE by resolving cyclic dependencies between the DOM and the JavaScript objects.

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.

<script type="text/javascript">
     var mxLoadResources = false;
</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.

IS_IE: navigator.userAgent.indexOf('MSIE') >
True if the current browser is Internet Explorer.
IS_IE6: navigator.userAgent.indexOf('MSIE 6') >
True if the current browser is Internet Explorer 6.x.
IS_QUIRKS: navigator.userAgent.indexOf('MSIE') >
True if the current browser is Internet Explorer and it is in quirks mode.
IS_NS: navigator.userAgent.indexOf('Mozilla/') >
True if the current browser is Netscape (including Firefox).
IS_OP: navigator.userAgent.indexOf('Opera/') >
True if the current browser is Opera.
IS_SF: navigator.userAgent.indexOf('AppleWebKit/') >
True if the current browser is Safari.
IS_GC: navigator.userAgent.indexOf('Chrome/') >
True if the current browser is Google Chrome.
IS_FF: navigator.userAgent.indexOf('Firefox/') >
True if the current browser is Firefox.
IS_SVG: navigator.userAgent.indexOf('Firefox/') >
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_VML: navigator.appName.toUpperCase()
True if the browser supports VML.
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)
Adds a link node to the head of the document.
include: function(src)
Dynamically adds a script node to the document header.
dispose: function()
Frees up memory in IE by resolving cyclic dependencies between the DOM and the JavaScript objects.
Extends mxEventSource to implement a graph component for the browser.
Extends mxEventSource to implement a 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.
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.
Specifies the resource key for the title of the error window.
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.
Close