Comparing version 0.0.6 to 0.0.7
@@ -216,19 +216,2 @@ | ||
// Workaround for event transparency in VML with transparent color | ||
// is to use a non-transparent color with near zero opacity | ||
if (mxClient.IS_QUIRKS || document.documentMode == 8) | ||
{ | ||
if (this.shape.stroke == 'transparent') | ||
{ | ||
// KNOWN: Quirks mode does not seem to catch events if | ||
// we do not force an update of the DOM via a change such | ||
// as mxLog.debug. Since IE6 is EOL we do not add a fix. | ||
this.shape.stroke = 'white'; | ||
this.shape.opacity = 1; | ||
} | ||
else | ||
{ | ||
this.shape.opacity = this.opacity; | ||
} | ||
} | ||
@@ -283,3 +266,3 @@ this.shape.redraw(); | ||
// Quirks mode is currently not supported as it used a different coordinate system | ||
if (this.shape != null && document.elementFromPoint != null && !mxClient.IS_QUIRKS) | ||
if (this.shape != null && document.elementFromPoint != null) | ||
{ | ||
@@ -286,0 +269,0 @@ var elt = document.elementFromPoint(x, y); |
@@ -443,12 +443,2 @@ | ||
// Fixes lost event tracking for images in quirks / IE8 standards | ||
if (mxClient.IS_QUIRKS || document.documentMode == 8) | ||
{ | ||
mxEvent.addListener(icon.node, 'dragstart', function(evt) | ||
{ | ||
mxEvent.consume(evt); | ||
return false; | ||
}); | ||
} | ||
@@ -455,0 +445,0 @@ // Move the icon behind all other overlays |
@@ -7,3 +7,2 @@ import { mxUtils } from './../util/mxUtils'; | ||
/** | ||
@@ -1151,10 +1150,2 @@ * Class: mxText | ||
oh = sizeDiv.offsetHeight + 2; | ||
if ( | ||
mxClient.IS_QUIRKS && | ||
this.border != null && | ||
this.border != mxConstants.NONE | ||
) { | ||
oh += 3; | ||
} | ||
} else if ( | ||
@@ -1190,12 +1181,3 @@ sizeDiv.firstChild != null && | ||
// Simulates max-height CSS in quirks mode | ||
if ( | ||
mxClient.IS_QUIRKS && | ||
(this.clipped || (this.overflow == 'width' && h > 0)) | ||
) { | ||
h = Math.min(h, oh); | ||
style.height = Math.round(h) + 'px'; | ||
} else { | ||
h = oh; | ||
} | ||
h = oh; | ||
@@ -1210,3 +1192,3 @@ if (this.overflow != 'fill' && this.overflow != 'width') { | ||
// Simulates max-width CSS in quirks mode | ||
if ((mxClient.IS_QUIRKS && this.clipped) || this.wrap) { | ||
if (this.wrap) { | ||
style.width = Math.round(w) + 'px'; | ||
@@ -1269,12 +1251,4 @@ } | ||
if (this.overflow != 'fill' && mxClient.IS_QUIRKS) { | ||
if (this.valign == mxConstants.ALIGN_TOP) { | ||
dy -= 1; | ||
} else if (this.valign == mxConstants.ALIGN_BOTTOM) { | ||
dy += 2; | ||
} else { | ||
dy += 1; | ||
} | ||
} | ||
style.zoom = s; | ||
@@ -1446,8 +1420,4 @@ style.left = Math.round(this.bounds.x + left_fix - w / 2) + 'px'; | ||
if (!mxClient.IS_QUIRKS) { | ||
style.maxHeight = h + 'px'; | ||
style.maxWidth = w + 'px'; | ||
} else { | ||
style.width = w + 'px'; | ||
} | ||
style.maxHeight = h + 'px'; | ||
style.maxWidth = w + 'px'; | ||
} else if (this.overflow == 'fill') { | ||
@@ -1454,0 +1424,0 @@ style.width = w + 1 + 'px'; |
@@ -0,1 +1,5 @@ | ||
import { mxEvent, mxUtils, mxWindow } from "."; | ||
import { mxClient } from ".."; | ||
/** | ||
@@ -5,2 +9,3 @@ * Copyright (c) 2006-2015, JGraph Ltd | ||
*/ | ||
export const mxLog = | ||
@@ -7,0 +12,0 @@ { |
@@ -292,7 +292,2 @@ /** | ||
// Workaround for lost current selection in page because of focus in IE | ||
if (document.selection != null && (mxClient.IS_QUIRKS || document.documentMode == 8)) | ||
{ | ||
currentSelection = document.selection.createRange(); | ||
} | ||
@@ -299,0 +294,0 @@ mxEvent.consume(evt); |
@@ -1860,3 +1860,3 @@ /** | ||
div.style.visibility = 'hidden'; | ||
div.style.display = (mxClient.IS_QUIRKS) ? 'inline' : 'inline-block'; | ||
div.style.display = 'inline-block'; | ||
div.style.zoom = '1'; | ||
@@ -1863,0 +1863,0 @@ |
@@ -9,2 +9,9 @@ /** | ||
import { mxRectangle } from './mxRectangle'; | ||
import { mxUtils, mxEvent, mxEventObject, mxConstants } from '.'; | ||
import resizeGif from './../assets/resize.gif'; | ||
import maximizeGif from './../assets/maximize.gif'; | ||
import closeGif from './../assets/close.gif'; | ||
import minimizeGif from './../assets/minimize.gif'; | ||
import normalizeGif from './../assets/normalize.gif'; | ||
/** | ||
@@ -229,3 +236,2 @@ * Class: mxWindow | ||
/** | ||
@@ -242,3 +248,3 @@ * Extends mxEventSource. | ||
*/ | ||
mxWindow.prototype.closeImage = mxClient.imageBasePath + '/close.gif'; | ||
mxWindow.prototype.closeImage = closeGif; | ||
@@ -250,3 +256,3 @@ /** | ||
*/ | ||
mxWindow.prototype.minimizeImage = mxClient.imageBasePath + '/minimize.gif'; | ||
mxWindow.prototype.minimizeImage = minimizeGif; | ||
@@ -258,3 +264,3 @@ /** | ||
*/ | ||
mxWindow.prototype.normalizeImage = mxClient.imageBasePath + '/normalize.gif'; | ||
mxWindow.prototype.normalizeImage = normalizeGif; | ||
@@ -266,3 +272,3 @@ /** | ||
*/ | ||
mxWindow.prototype.maximizeImage = mxClient.imageBasePath + '/maximize.gif'; | ||
mxWindow.prototype.maximizeImage = maximizeGif; | ||
@@ -274,3 +280,3 @@ /** | ||
*/ | ||
mxWindow.prototype.resizeImage = mxClient.imageBasePath + '/resize.gif'; | ||
mxWindow.prototype.resizeImage = resizeGif; | ||
@@ -346,6 +352,2 @@ /** | ||
if (width != null) { | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.width = width + 'px'; | ||
} | ||
this.table.style.width = width + 'px'; | ||
@@ -355,6 +357,2 @@ } | ||
if (height != null) { | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.height = height + 'px'; | ||
} | ||
this.table.style.height = height + 'px'; | ||
@@ -396,3 +394,3 @@ } | ||
// of inner div if outerdiv has hidden overflow | ||
if (mxClient.IS_QUIRKS || this.content.nodeName.toUpperCase() != 'DIV') { | ||
if (this.content.nodeName.toUpperCase() != 'DIV') { | ||
this.contentWrapper.style.height = '100%'; | ||
@@ -615,7 +613,4 @@ } | ||
// Workaround for table size problems in FF | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.width = width + 'px'; | ||
this.div.style.height = height + 'px'; | ||
} | ||
this.div.style.width = width + 'px'; | ||
this.div.style.height = height + 'px'; | ||
@@ -625,9 +620,7 @@ this.table.style.width = width + 'px'; | ||
if (!mxClient.IS_QUIRKS) { | ||
this.contentWrapper.style.height = | ||
this.div.offsetHeight - | ||
this.title.offsetHeight - | ||
this.contentHeightCorrection + | ||
'px'; | ||
} | ||
this.contentWrapper.style.height = | ||
this.div.offsetHeight - | ||
this.title.offsetHeight - | ||
this.contentHeightCorrection + | ||
'px'; | ||
}; | ||
@@ -692,5 +685,3 @@ | ||
if (minSize.height > 0) { | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.height = minSize.height + 'px'; | ||
} | ||
this.div.style.height = minSize.height + 'px'; | ||
@@ -701,5 +692,3 @@ this.table.style.height = minSize.height + 'px'; | ||
if (minSize.width > 0) { | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.width = minSize.width + 'px'; | ||
} | ||
this.div.style.width = minSize.width + 'px'; | ||
@@ -722,5 +711,3 @@ this.table.style.width = minSize.width + 'px'; | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.height = height; | ||
} | ||
this.div.style.height = height; | ||
@@ -801,6 +788,4 @@ this.table.style.height = height; | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.width = document.body.clientWidth - 2 + 'px'; | ||
this.div.style.height = docHeight - 2 + 'px'; | ||
} | ||
this.div.style.width = document.body.clientWidth - 2 + 'px'; | ||
this.div.style.height = docHeight - 2 + 'px'; | ||
@@ -814,12 +799,10 @@ this.table.style.width = document.body.clientWidth - 2 + 'px'; | ||
if (!mxClient.IS_QUIRKS) { | ||
var style = mxUtils.getCurrentStyle(this.contentWrapper); | ||
var style = mxUtils.getCurrentStyle(this.contentWrapper); | ||
if (style.overflow == 'auto' || this.resize != null) { | ||
this.contentWrapper.style.height = | ||
this.div.offsetHeight - | ||
this.title.offsetHeight - | ||
this.contentHeightCorrection + | ||
'px'; | ||
} | ||
if (style.overflow == 'auto' || this.resize != null) { | ||
this.contentWrapper.style.height = | ||
this.div.offsetHeight - | ||
this.title.offsetHeight - | ||
this.contentHeightCorrection + | ||
'px'; | ||
} | ||
@@ -840,15 +823,13 @@ | ||
if (!mxClient.IS_QUIRKS) { | ||
this.div.style.height = height; | ||
this.div.style.width = width; | ||
this.div.style.height = height; | ||
this.div.style.width = width; | ||
var style = mxUtils.getCurrentStyle(this.contentWrapper); | ||
var style = mxUtils.getCurrentStyle(this.contentWrapper); | ||
if (style.overflow == 'auto' || this.resize != null) { | ||
this.contentWrapper.style.height = | ||
this.div.offsetHeight - | ||
this.title.offsetHeight - | ||
this.contentHeightCorrection + | ||
'px'; | ||
} | ||
if (style.overflow == 'auto' || this.resize != null) { | ||
this.contentWrapper.style.height = | ||
this.div.offsetHeight - | ||
this.title.offsetHeight - | ||
this.contentHeightCorrection + | ||
'px'; | ||
} | ||
@@ -1061,3 +1042,2 @@ | ||
if ( | ||
!mxClient.IS_QUIRKS && | ||
(style.overflow == 'auto' || this.resize != null) && | ||
@@ -1064,0 +1044,0 @@ this.contentWrapper.style.display != 'none' |
@@ -7,9 +7,9 @@ /** | ||
* Class: mxXmlRequest | ||
* | ||
* | ||
* XML HTTP request wrapper. See also: <mxUtils.get>, <mxUtils.post> and | ||
* <mxUtils.load>. This class provides a cross-browser abstraction for Ajax | ||
* requests. | ||
* | ||
* | ||
* Encoding: | ||
* | ||
* | ||
* For encoding parameter values, the built-in encodeURIComponent JavaScript | ||
@@ -21,5 +21,5 @@ * method must be used. For automatic encoding of post data in <mxEditor> the | ||
* <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* (code) | ||
@@ -30,3 +30,3 @@ * var onload = function(req) | ||
* } | ||
* | ||
* | ||
* var onerror = function(req) | ||
@@ -38,7 +38,7 @@ * { | ||
* (end) | ||
* | ||
* | ||
* Sends an asynchronous POST request to the specified URL. | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* (code) | ||
@@ -49,7 +49,7 @@ * var req = new mxXmlRequest(url, 'key=value', 'POST', false); | ||
* (end) | ||
* | ||
* | ||
* Sends a synchronous POST request to the specified URL. | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* (code) | ||
@@ -61,12 +61,12 @@ * var encoder = new mxCodec(); | ||
* (end) | ||
* | ||
* | ||
* Sends an encoded graph model to the specified URL using xml as the | ||
* parameter name. The parameter can then be retrieved in C# as follows: | ||
* | ||
* | ||
* (code) | ||
* string xml = HttpUtility.UrlDecode(context.Request.Params["xml"]); | ||
* (end) | ||
* | ||
* | ||
* Or in Java as follows: | ||
* | ||
* | ||
* (code) | ||
@@ -78,9 +78,9 @@ * String xml = URLDecoder.decode(request.getParameter("xml"), "UTF-8").replace("\n", "
"); | ||
* processed in Java, for example when creating an image. | ||
* | ||
* | ||
* Constructor: mxXmlRequest | ||
* | ||
* | ||
* Constructs an XML HTTP request. | ||
* | ||
* | ||
* Parameters: | ||
* | ||
* | ||
* url - Target URL of the request. | ||
@@ -95,15 +95,14 @@ * params - Form encoded parameters to send with a POST request. | ||
*/ | ||
export function mxXmlRequest(url, params, method, async, username, password) | ||
{ | ||
this.url = url; | ||
this.params = params; | ||
this.method = method || 'POST'; | ||
this.async = (async != null) ? async : true; | ||
this.username = username; | ||
this.password = password; | ||
}; | ||
export function mxXmlRequest(url, params, method, async, username, password) { | ||
this.url = url; | ||
this.params = params; | ||
this.method = method || 'POST'; | ||
this.async = async != null ? async : true; | ||
this.username = username; | ||
this.password = password; | ||
} | ||
/** | ||
* Variable: url | ||
* | ||
* | ||
* Holds the target URL of the request. | ||
@@ -115,3 +114,3 @@ */ | ||
* Variable: params | ||
* | ||
* | ||
* Holds the form encoded data for the POST request. | ||
@@ -123,3 +122,3 @@ */ | ||
* Variable: method | ||
* | ||
* | ||
* Specifies the request method. Possible values are POST and GET. Default | ||
@@ -132,3 +131,3 @@ * is POST. | ||
* Variable: async | ||
* | ||
* | ||
* Boolean indicating if the request is asynchronous. | ||
@@ -140,3 +139,3 @@ */ | ||
* Variable: binary | ||
* | ||
* | ||
* Boolean indicating if the request is binary. This option is ignored in IE. | ||
@@ -150,3 +149,3 @@ * In all other browsers the requested mime type is set to | ||
* Variable: withCredentials | ||
* | ||
* | ||
* Specifies if withCredentials should be used in HTML5-compliant browsers. Default is | ||
@@ -159,3 +158,3 @@ * false. | ||
* Variable: username | ||
* | ||
* | ||
* Specifies the username to be used for authentication. | ||
@@ -167,3 +166,3 @@ */ | ||
* Variable: password | ||
* | ||
* | ||
* Specifies the password to be used for authentication. | ||
@@ -175,3 +174,3 @@ */ | ||
* Variable: request | ||
* | ||
* | ||
* Holds the inner, browser-specific request object. | ||
@@ -183,3 +182,3 @@ */ | ||
* Variable: decodeSimulateValues | ||
* | ||
* | ||
* Specifies if request values should be decoded as URIs before setting the | ||
@@ -193,8 +192,7 @@ * textarea value in <simulate>. Defaults to false for backwards compatibility, | ||
* Function: isBinary | ||
* | ||
* | ||
* Returns <binary>. | ||
*/ | ||
mxXmlRequest.prototype.isBinary = function() | ||
{ | ||
return this.binary; | ||
mxXmlRequest.prototype.isBinary = function () { | ||
return this.binary; | ||
}; | ||
@@ -204,8 +202,7 @@ | ||
* Function: setBinary | ||
* | ||
* | ||
* Sets <binary>. | ||
*/ | ||
mxXmlRequest.prototype.setBinary = function(value) | ||
{ | ||
this.binary = value; | ||
mxXmlRequest.prototype.setBinary = function (value) { | ||
this.binary = value; | ||
}; | ||
@@ -215,8 +212,7 @@ | ||
* Function: getText | ||
* | ||
* | ||
* Returns the response as a string. | ||
*/ | ||
mxXmlRequest.prototype.getText = function() | ||
{ | ||
return this.request.responseText; | ||
mxXmlRequest.prototype.getText = function () { | ||
return this.request.responseText; | ||
}; | ||
@@ -226,8 +222,7 @@ | ||
* Function: isReady | ||
* | ||
* | ||
* Returns true if the response is ready. | ||
*/ | ||
mxXmlRequest.prototype.isReady = function() | ||
{ | ||
return this.request.readyState == 4; | ||
mxXmlRequest.prototype.isReady = function () { | ||
return this.request.readyState == 4; | ||
}; | ||
@@ -237,15 +232,13 @@ | ||
* Function: getDocumentElement | ||
* | ||
* | ||
* Returns the document element of the response XML document. | ||
*/ | ||
mxXmlRequest.prototype.getDocumentElement = function() | ||
{ | ||
var doc = this.getXml(); | ||
if (doc != null) | ||
{ | ||
return doc.documentElement; | ||
} | ||
return null; | ||
mxXmlRequest.prototype.getDocumentElement = function () { | ||
var doc = this.getXml(); | ||
if (doc != null) { | ||
return doc.documentElement; | ||
} | ||
return null; | ||
}; | ||
@@ -255,21 +248,23 @@ | ||
* Function: getXml | ||
* | ||
* | ||
* Returns the response as an XML document. Use <getDocumentElement> to get | ||
* the document element of the XML document. | ||
*/ | ||
mxXmlRequest.prototype.getXml = function() | ||
{ | ||
var xml = this.request.responseXML; | ||
// Handles missing response headers in IE, the first condition handles | ||
// the case where responseXML is there, but using its nodes leads to | ||
// type errors in the mxCellCodec when putting the nodes into a new | ||
// document. This happens in IE9 standards mode and with XML user | ||
// objects only, as they are used directly as values in cells. | ||
if (document.documentMode >= 9 || xml == null || xml.documentElement == null) | ||
{ | ||
xml = mxUtils.parseXml(this.request.responseText); | ||
} | ||
return xml; | ||
mxXmlRequest.prototype.getXml = function () { | ||
var xml = this.request.responseXML; | ||
// Handles missing response headers in IE, the first condition handles | ||
// the case where responseXML is there, but using its nodes leads to | ||
// type errors in the mxCellCodec when putting the nodes into a new | ||
// document. This happens in IE9 standards mode and with XML user | ||
// objects only, as they are used directly as values in cells. | ||
if ( | ||
document.documentMode >= 9 || | ||
xml == null || | ||
xml.documentElement == null | ||
) { | ||
xml = mxUtils.parseXml(this.request.responseText); | ||
} | ||
return xml; | ||
}; | ||
@@ -279,9 +274,8 @@ | ||
* Function: getStatus | ||
* | ||
* | ||
* Returns the status as a number, eg. 404 for "Not found" or 200 for "OK". | ||
* Note: The NS_ERROR_NOT_AVAILABLE for invalid responses cannot be cought. | ||
*/ | ||
mxXmlRequest.prototype.getStatus = function() | ||
{ | ||
return (this.request != null) ? this.request.status : null; | ||
mxXmlRequest.prototype.getStatus = function () { | ||
return this.request != null ? this.request.status : null; | ||
}; | ||
@@ -291,42 +285,35 @@ | ||
* Function: create | ||
* | ||
* | ||
* Creates and returns the inner <request> object. | ||
*/ | ||
mxXmlRequest.prototype.create = function() | ||
{ | ||
if (window.XMLHttpRequest) | ||
{ | ||
return function() | ||
{ | ||
var req = new XMLHttpRequest(); | ||
// TODO: Check for overrideMimeType required here? | ||
if (this.isBinary() && req.overrideMimeType) | ||
{ | ||
req.overrideMimeType('text/plain; charset=x-user-defined'); | ||
} | ||
mxXmlRequest.prototype.create = (function () { | ||
if (window.XMLHttpRequest) { | ||
return function () { | ||
var req = new XMLHttpRequest(); | ||
return req; | ||
}; | ||
} | ||
else if (typeof(ActiveXObject) != 'undefined') | ||
{ | ||
return function() | ||
{ | ||
// TODO: Implement binary option | ||
return new ActiveXObject('Microsoft.XMLHTTP'); | ||
}; | ||
} | ||
}(); | ||
// TODO: Check for overrideMimeType required here? | ||
if (this.isBinary() && req.overrideMimeType) { | ||
req.overrideMimeType('text/plain; charset=x-user-defined'); | ||
} | ||
return req; | ||
}; | ||
} else if (typeof ActiveXObject != 'undefined') { | ||
return function () { | ||
// TODO: Implement binary option | ||
return new ActiveXObject('Microsoft.XMLHTTP'); | ||
}; | ||
} | ||
})(); | ||
/** | ||
* Function: send | ||
* | ||
* | ||
* Send the <request> to the target URL using the specified functions to | ||
* process the response asychronously. | ||
* | ||
* | ||
* Note: Due to technical limitations, onerror is currently ignored. | ||
* | ||
* | ||
* Parameters: | ||
* | ||
* | ||
* onload - Function to be invoked if a successful response was received. | ||
@@ -337,38 +324,33 @@ * onerror - Function to be called on any error. Unused in this implementation, intended for overriden function. | ||
*/ | ||
mxXmlRequest.prototype.send = function(onload, onerror, timeout, ontimeout) | ||
{ | ||
this.request = this.create(); | ||
if (this.request != null) | ||
{ | ||
if (onload != null) | ||
{ | ||
this.request.onreadystatechange = mxUtils.bind(this, function() | ||
{ | ||
if (this.isReady()) | ||
{ | ||
onload(this); | ||
this.request.onreadystatechange = null; | ||
} | ||
}); | ||
} | ||
mxXmlRequest.prototype.send = function (onload, onerror, timeout, ontimeout) { | ||
this.request = this.create(); | ||
this.request.open(this.method, this.url, this.async, | ||
this.username, this.password); | ||
this.setRequestHeaders(this.request, this.params); | ||
if (window.XMLHttpRequest && this.withCredentials) | ||
{ | ||
this.request.withCredentials = 'true'; | ||
} | ||
if (!mxClient.IS_QUIRKS && (document.documentMode == null || document.documentMode > 9) && | ||
window.XMLHttpRequest && timeout != null && ontimeout != null) | ||
{ | ||
this.request.timeout = timeout; | ||
this.request.ontimeout = ontimeout; | ||
} | ||
this.request.send(this.params); | ||
} | ||
if (this.request != null) { | ||
if (onload != null) { | ||
this.request.onreadystatechange = mxUtils.bind(this, function () { | ||
if (this.isReady()) { | ||
onload(this); | ||
this.request.onreadystatechange = null; | ||
} | ||
}); | ||
} | ||
this.request.open( | ||
this.method, | ||
this.url, | ||
this.async, | ||
this.username, | ||
this.password, | ||
); | ||
this.setRequestHeaders(this.request, this.params); | ||
if (window.XMLHttpRequest && this.withCredentials) { | ||
this.request.withCredentials = 'true'; | ||
} | ||
this.request.timeout = timeout; | ||
this.request.ontimeout = ontimeout; | ||
this.request.send(this.params); | ||
} | ||
}; | ||
@@ -378,8 +360,8 @@ | ||
* Function: setRequestHeaders | ||
* | ||
* | ||
* Sets the headers for the given request and parameters. This sets the | ||
* content-type to application/x-www-form-urlencoded if any params exist. | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* (code) | ||
@@ -397,12 +379,13 @@ * request.setRequestHeaders = function(request, params) | ||
* (end) | ||
* | ||
* | ||
* Use the code above before calling <send> if you require a | ||
* multipart/form-data request. | ||
* multipart/form-data request. | ||
*/ | ||
mxXmlRequest.prototype.setRequestHeaders = function(request, params) | ||
{ | ||
if (params != null) | ||
{ | ||
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | ||
} | ||
mxXmlRequest.prototype.setRequestHeaders = function (request, params) { | ||
if (params != null) { | ||
request.setRequestHeader( | ||
'Content-Type', | ||
'application/x-www-form-urlencoded', | ||
); | ||
} | ||
}; | ||
@@ -412,73 +395,64 @@ | ||
* Function: simulate | ||
* | ||
* | ||
* Creates and posts a request to the given target URL using a dynamically | ||
* created form inside the given document. | ||
* | ||
* | ||
* Parameters: | ||
* | ||
* | ||
* docs - Document that contains the form element. | ||
* target - Target to send the form result to. | ||
*/ | ||
mxXmlRequest.prototype.simulate = function(doc, target) | ||
{ | ||
doc = doc || document; | ||
var old = null; | ||
mxXmlRequest.prototype.simulate = function (doc, target) { | ||
doc = doc || document; | ||
var old = null; | ||
if (doc == document) | ||
{ | ||
old = window.onbeforeunload; | ||
window.onbeforeunload = null; | ||
} | ||
var form = doc.createElement('form'); | ||
form.setAttribute('method', this.method); | ||
form.setAttribute('action', this.url); | ||
if (doc == document) { | ||
old = window.onbeforeunload; | ||
window.onbeforeunload = null; | ||
} | ||
if (target != null) | ||
{ | ||
form.setAttribute('target', target); | ||
} | ||
var form = doc.createElement('form'); | ||
form.setAttribute('method', this.method); | ||
form.setAttribute('action', this.url); | ||
form.style.display = 'none'; | ||
form.style.visibility = 'hidden'; | ||
var pars = (this.params.indexOf('&') > 0) ? | ||
this.params.split('&') : | ||
this.params.split(); | ||
if (target != null) { | ||
form.setAttribute('target', target); | ||
} | ||
// Adds the parameters as textareas to the form | ||
for (var i=0; i<pars.length; i++) | ||
{ | ||
var pos = pars[i].indexOf('='); | ||
if (pos > 0) | ||
{ | ||
var name = pars[i].substring(0, pos); | ||
var value = pars[i].substring(pos+1); | ||
if (this.decodeSimulateValues) | ||
{ | ||
value = decodeURIComponent(value); | ||
} | ||
var textarea = doc.createElement('textarea'); | ||
textarea.setAttribute('wrap', 'off'); | ||
textarea.setAttribute('name', name); | ||
mxUtils.write(textarea, value); | ||
form.appendChild(textarea); | ||
} | ||
} | ||
doc.body.appendChild(form); | ||
form.submit(); | ||
if (form.parentNode != null) | ||
{ | ||
form.parentNode.removeChild(form); | ||
} | ||
form.style.display = 'none'; | ||
form.style.visibility = 'hidden'; | ||
if (old != null) | ||
{ | ||
window.onbeforeunload = old; | ||
} | ||
var pars = | ||
this.params.indexOf('&') > 0 ? this.params.split('&') : this.params.split(); | ||
// Adds the parameters as textareas to the form | ||
for (var i = 0; i < pars.length; i++) { | ||
var pos = pars[i].indexOf('='); | ||
if (pos > 0) { | ||
var name = pars[i].substring(0, pos); | ||
var value = pars[i].substring(pos + 1); | ||
if (this.decodeSimulateValues) { | ||
value = decodeURIComponent(value); | ||
} | ||
var textarea = doc.createElement('textarea'); | ||
textarea.setAttribute('wrap', 'off'); | ||
textarea.setAttribute('name', name); | ||
mxUtils.write(textarea, value); | ||
form.appendChild(textarea); | ||
} | ||
} | ||
doc.body.appendChild(form); | ||
form.submit(); | ||
if (form.parentNode != null) { | ||
form.parentNode.removeChild(form); | ||
} | ||
if (old != null) { | ||
window.onbeforeunload = old; | ||
} | ||
}; |
@@ -1,2 +0,1 @@ | ||
/** | ||
@@ -241,7 +240,3 @@ * Class: mxCellEditor | ||
*/ | ||
mxCellEditor.prototype.wordWrapPadding = mxClient.IS_QUIRKS | ||
? 2 | ||
: !mxClient.IS_IE11 | ||
? 1 | ||
: 0; | ||
mxCellEditor.prototype.wordWrapPadding = 1; | ||
@@ -328,11 +323,5 @@ /** | ||
// Workaround for trailing line breaks being ignored in the editor | ||
if ( | ||
!mxClient.IS_QUIRKS && | ||
document.documentMode != 8 && | ||
document.documentMode != 9 && | ||
document.documentMode != 10 | ||
) { | ||
result = mxUtils.replaceTrailingNewlines(result, '<div><br></div>'); | ||
} | ||
result = mxUtils.replaceTrailingNewlines(result, '<div><br></div>'); | ||
return result.replace(/\n/g, '<br>'); | ||
@@ -419,3 +408,3 @@ }; | ||
(!mxClient.IS_FF || | ||
(evt.keyCode != 8 /* Backspace */ && evt.keyCode != 46) /* Delete */) | ||
(evt.keyCode != 8 /* Backspace */ && evt.keyCode != 46)) /* Delete */ | ||
) { | ||
@@ -535,12 +524,6 @@ this.clearOnChange = false; | ||
// FIXME: Offset when scaled | ||
if (document.documentMode == 8 || mxClient.IS_QUIRKS) { | ||
this.textarea.style.left = Math.round(this.bounds.x) + 'px'; | ||
this.textarea.style.top = Math.round(this.bounds.y) + 'px'; | ||
} else { | ||
this.textarea.style.left = | ||
Math.max(0, Math.round(this.bounds.x + 1)) + 'px'; | ||
this.textarea.style.top = | ||
Math.max(0, Math.round(this.bounds.y + 1)) + 'px'; | ||
} | ||
this.textarea.style.left = | ||
Math.max(0, Math.round(this.bounds.x + 1)) + 'px'; | ||
this.textarea.style.top = | ||
Math.max(0, Math.round(this.bounds.y + 1)) + 'px'; | ||
@@ -737,90 +720,29 @@ // Installs native word wrapping and avoids word wrap for empty label placeholder | ||
// LATER: Keep in visible area, add fine tuning for pixel precision | ||
if (document.documentMode == 8) { | ||
// LATER: Scaled wrapping and position is wrong in IE8 | ||
this.textarea.style.left = | ||
Math.max( | ||
0, | ||
Math.ceil( | ||
(this.bounds.x - | ||
m.x * (this.bounds.width - (ow + 1) * scale) + | ||
ow * (scale - 1) * 0 + | ||
(m.x + 0.5) * 2) / | ||
scale, | ||
), | ||
) + 'px'; | ||
this.textarea.style.top = | ||
Math.max( | ||
0, | ||
Math.ceil( | ||
(this.bounds.y - | ||
m.y * (this.bounds.height - (oh + 0.5) * scale) + | ||
oh * (scale - 1) * 0 + | ||
Math.abs(m.y + 0.5) * 1) / | ||
scale, | ||
), | ||
) + 'px'; | ||
// Workaround for wrong event handling width and height | ||
this.textarea.style.width = Math.round(ow * scale) + 'px'; | ||
this.textarea.style.height = Math.round(oh * scale) + 'px'; | ||
} else if (mxClient.IS_QUIRKS) { | ||
this.textarea.style.left = | ||
Math.max( | ||
0, | ||
Math.ceil( | ||
this.bounds.x - | ||
m.x * (this.bounds.width - (ow + 1) * scale) + | ||
ow * (scale - 1) * 0 + | ||
(m.x + 0.5) * 2, | ||
), | ||
) + 'px'; | ||
this.textarea.style.top = | ||
Math.max( | ||
0, | ||
Math.ceil( | ||
this.bounds.y - | ||
m.y * (this.bounds.height - (oh + 0.5) * scale) + | ||
oh * (scale - 1) * 0 + | ||
Math.abs(m.y + 0.5) * 1, | ||
), | ||
) + 'px'; | ||
} else { | ||
this.textarea.style.left = | ||
Math.max( | ||
0, | ||
Math.round(this.bounds.x - m.x * (this.bounds.width - 2)) + 1, | ||
) + 'px'; | ||
this.textarea.style.top = | ||
Math.max( | ||
0, | ||
Math.round( | ||
this.bounds.y - | ||
m.y * (this.bounds.height - 4) + | ||
(m.y == -1 ? 3 : 0), | ||
) + 1, | ||
) + 'px'; | ||
} | ||
this.textarea.style.left = | ||
Math.max( | ||
0, | ||
Math.round(this.bounds.x - m.x * (this.bounds.width - 2)) + 1, | ||
) + 'px'; | ||
this.textarea.style.top = | ||
Math.max( | ||
0, | ||
Math.round( | ||
this.bounds.y - | ||
m.y * (this.bounds.height - 4) + | ||
(m.y == -1 ? 3 : 0), | ||
) + 1, | ||
) + 'px'; | ||
} | ||
if (mxClient.IS_VML) { | ||
this.textarea.style.zoom = scale; | ||
} else { | ||
mxUtils.setPrefixedStyle( | ||
this.textarea.style, | ||
'transformOrigin', | ||
'0px 0px', | ||
); | ||
mxUtils.setPrefixedStyle( | ||
this.textarea.style, | ||
'transform', | ||
'scale(' + | ||
scale + | ||
',' + | ||
scale + | ||
')' + | ||
(m == null | ||
? '' | ||
: ' translate(' + m.x * 100 + '%,' + m.y * 100 + '%)'), | ||
); | ||
} | ||
mxUtils.setPrefixedStyle(this.textarea.style, 'transformOrigin', '0px 0px'); | ||
mxUtils.setPrefixedStyle( | ||
this.textarea.style, | ||
'transform', | ||
'scale(' + | ||
scale + | ||
',' + | ||
scale + | ||
')' + | ||
(m == null ? '' : ' translate(' + m.x * 100 + '%,' + m.y * 100 + '%)'), | ||
); | ||
} | ||
@@ -827,0 +749,0 @@ }; |
@@ -6,3 +6,3 @@ /** | ||
import { mxUtils } from "../util"; | ||
import { mxUtils,mxResources } from "../util"; | ||
@@ -54,2 +54,3 @@ /** | ||
export function mxMultiplicity(source, type, attr, value, min, max, | ||
@@ -56,0 +57,0 @@ validNeighbors, countError, typeError, validNeighborsAllowed) |
{ | ||
"name": "thgraph", | ||
"version": "0.0.6", | ||
"description": "mxgraph graph svg editor", | ||
"version": "0.0.7", | ||
"description": "a graph editor render with svg base from mxgraph", | ||
"main": "graph/index.js", | ||
@@ -42,2 +42,3 @@ "type": "module", | ||
"jgraph", | ||
"draw.io", | ||
"svg", | ||
@@ -44,0 +45,0 @@ "editor", |
# thgraph | ||
## 介绍 | ||
mxgraph 已经不在维护,学习 jgraph/mxgraph 源码,准备TS 重构,去掉旧浏览器的兼容代码,面向现代浏览器。 | ||
因为项目代码是在太多了,一次完成转化不现实,现在的策略是,先转成esmodule 然后,能和主流框架 vue react以及vite/webpack 一起配合使用, 后续重构和优化. | ||
因为项目代码是在太多了,一次完成转化不现实,现在的策略是,先转成esmodule 然后,能和主流框架 vue react以及vite/webpack 一起配合使用, 后续重构和优化. | ||
https://github.com/jgraph/mxgraph-js | ||
[mxgraph代码库](https://github.com/jgraph/mxgraph-js) | ||
## 文档 | ||
[mxgraph文档](https://jgraph.github.io/mxgraph/); | ||
# 计划 | ||
## 计划 | ||
- [x] 跑通 helloworld 示例 | ||
@@ -22,8 +17,47 @@ - [x] 转化成esmodule 模块 | ||
### 目录结构 | ||
# 文档 | ||
目前只是把mxgraph 转换成esmodule,所以之前全局变量,引入后就能用了。 | ||
### 参与贡献 | ||
## helloworld | ||
``` javascript | ||
// | ||
import { mxGraph ,mxRubberband} from 'thgraph'; | ||
const container = document.getElementById('graphContainer'); | ||
// Creates the graph inside the given container | ||
const graph = new mxGraph(container); | ||
// Enables rubberband selection | ||
new mxRubberband(graph); | ||
// Gets the default parent for inserting new cells. This | ||
// is normally the first child of the root (ie. layer 0). | ||
const parent = graph.getDefaultParent(); | ||
// Adds cells to the model in a single step | ||
graph.getModel().beginUpdate(); | ||
try { | ||
const v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30); | ||
const v2 = graph.insertVertex(parent, null, 'World!', 200, 150, 80, 30); | ||
const e1 = graph.insertEdge(parent, null, '', v1, v2); | ||
} finally { | ||
// Updates the display | ||
graph.getModel().endUpdate(); | ||
} | ||
``` | ||
其他可以参看mxgraph 文档 | ||
[mxgraph文档](https://jgraph.github.io/mxgraph/); | ||
## 参与贡献 | ||
1. Fork 本仓库 | ||
@@ -30,0 +64,0 @@ 2. 新建 Feat_xxx 分支 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2349200
171
68
79530