/trunk/api/js/dojo/src/html/images/shadowL.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowL.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowBL.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowBL.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowTL.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowTL.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowB.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowB.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowR.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowR.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowBR.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowBR.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowT.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowT.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/images/shadowTR.png |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo/src/html/images/shadowTR.png |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo/src/html/layout.js |
---|
New file |
0,0 → 1,386 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.layout"); |
dojo.require("dojo.html.common"); |
dojo.require("dojo.html.style"); |
dojo.require("dojo.html.display"); |
dojo.html.sumAncestorProperties = function (node, prop) { |
node = dojo.byId(node); |
if (!node) { |
return 0; |
} |
var retVal = 0; |
while (node) { |
if (dojo.html.getComputedStyle(node, "position") == "fixed") { |
return 0; |
} |
var val = node[prop]; |
if (val) { |
retVal += val - 0; |
if (node == dojo.body()) { |
break; |
} |
} |
node = node.parentNode; |
} |
return retVal; |
}; |
dojo.html.setStyleAttributes = function (node, attributes) { |
node = dojo.byId(node); |
var splittedAttribs = attributes.replace(/(;)?\s*$/, "").split(";"); |
for (var i = 0; i < splittedAttribs.length; i++) { |
var nameValue = splittedAttribs[i].split(":"); |
var name = nameValue[0].replace(/\s*$/, "").replace(/^\s*/, "").toLowerCase(); |
var value = nameValue[1].replace(/\s*$/, "").replace(/^\s*/, ""); |
switch (name) { |
case "opacity": |
dojo.html.setOpacity(node, value); |
break; |
case "content-height": |
dojo.html.setContentBox(node, {height:value}); |
break; |
case "content-width": |
dojo.html.setContentBox(node, {width:value}); |
break; |
case "outer-height": |
dojo.html.setMarginBox(node, {height:value}); |
break; |
case "outer-width": |
dojo.html.setMarginBox(node, {width:value}); |
break; |
default: |
node.style[dojo.html.toCamelCase(name)] = value; |
} |
} |
}; |
dojo.html.boxSizing = {MARGIN_BOX:"margin-box", BORDER_BOX:"border-box", PADDING_BOX:"padding-box", CONTENT_BOX:"content-box"}; |
dojo.html.getAbsolutePosition = dojo.html.abs = function (node, includeScroll, boxType) { |
node = dojo.byId(node, node.ownerDocument); |
var ret = {x:0, y:0}; |
var bs = dojo.html.boxSizing; |
if (!boxType) { |
boxType = bs.CONTENT_BOX; |
} |
var nativeBoxType = 2; |
var targetBoxType; |
switch (boxType) { |
case bs.MARGIN_BOX: |
targetBoxType = 3; |
break; |
case bs.BORDER_BOX: |
targetBoxType = 2; |
break; |
case bs.PADDING_BOX: |
default: |
targetBoxType = 1; |
break; |
case bs.CONTENT_BOX: |
targetBoxType = 0; |
break; |
} |
var h = dojo.render.html; |
var db = document["body"] || document["documentElement"]; |
if (h.ie) { |
with (node.getBoundingClientRect()) { |
ret.x = left - 2; |
ret.y = top - 2; |
} |
} else { |
if (document.getBoxObjectFor) { |
nativeBoxType = 1; |
try { |
var bo = document.getBoxObjectFor(node); |
ret.x = bo.x - dojo.html.sumAncestorProperties(node, "scrollLeft"); |
ret.y = bo.y - dojo.html.sumAncestorProperties(node, "scrollTop"); |
} |
catch (e) { |
} |
} else { |
if (node["offsetParent"]) { |
var endNode; |
if ((h.safari) && (node.style.getPropertyValue("position") == "absolute") && (node.parentNode == db)) { |
endNode = db; |
} else { |
endNode = db.parentNode; |
} |
if (node.parentNode != db) { |
var nd = node; |
if (dojo.render.html.opera) { |
nd = db; |
} |
ret.x -= dojo.html.sumAncestorProperties(nd, "scrollLeft"); |
ret.y -= dojo.html.sumAncestorProperties(nd, "scrollTop"); |
} |
var curnode = node; |
do { |
var n = curnode["offsetLeft"]; |
if (!h.opera || n > 0) { |
ret.x += isNaN(n) ? 0 : n; |
} |
var m = curnode["offsetTop"]; |
ret.y += isNaN(m) ? 0 : m; |
curnode = curnode.offsetParent; |
} while ((curnode != endNode) && (curnode != null)); |
} else { |
if (node["x"] && node["y"]) { |
ret.x += isNaN(node.x) ? 0 : node.x; |
ret.y += isNaN(node.y) ? 0 : node.y; |
} |
} |
} |
} |
if (includeScroll) { |
var scroll = dojo.html.getScroll(); |
ret.y += scroll.top; |
ret.x += scroll.left; |
} |
var extentFuncArray = [dojo.html.getPaddingExtent, dojo.html.getBorderExtent, dojo.html.getMarginExtent]; |
if (nativeBoxType > targetBoxType) { |
for (var i = targetBoxType; i < nativeBoxType; ++i) { |
ret.y += extentFuncArray[i](node, "top"); |
ret.x += extentFuncArray[i](node, "left"); |
} |
} else { |
if (nativeBoxType < targetBoxType) { |
for (var i = targetBoxType; i > nativeBoxType; --i) { |
ret.y -= extentFuncArray[i - 1](node, "top"); |
ret.x -= extentFuncArray[i - 1](node, "left"); |
} |
} |
} |
ret.top = ret.y; |
ret.left = ret.x; |
return ret; |
}; |
dojo.html.isPositionAbsolute = function (node) { |
return (dojo.html.getComputedStyle(node, "position") == "absolute"); |
}; |
dojo.html._sumPixelValues = function (node, selectors, autoIsZero) { |
var total = 0; |
for (var x = 0; x < selectors.length; x++) { |
total += dojo.html.getPixelValue(node, selectors[x], autoIsZero); |
} |
return total; |
}; |
dojo.html.getMargin = function (node) { |
return {width:dojo.html._sumPixelValues(node, ["margin-left", "margin-right"], (dojo.html.getComputedStyle(node, "position") == "absolute")), height:dojo.html._sumPixelValues(node, ["margin-top", "margin-bottom"], (dojo.html.getComputedStyle(node, "position") == "absolute"))}; |
}; |
dojo.html.getBorder = function (node) { |
return {width:dojo.html.getBorderExtent(node, "left") + dojo.html.getBorderExtent(node, "right"), height:dojo.html.getBorderExtent(node, "top") + dojo.html.getBorderExtent(node, "bottom")}; |
}; |
dojo.html.getBorderExtent = function (node, side) { |
return (dojo.html.getStyle(node, "border-" + side + "-style") == "none" ? 0 : dojo.html.getPixelValue(node, "border-" + side + "-width")); |
}; |
dojo.html.getMarginExtent = function (node, side) { |
return dojo.html._sumPixelValues(node, ["margin-" + side], dojo.html.isPositionAbsolute(node)); |
}; |
dojo.html.getPaddingExtent = function (node, side) { |
return dojo.html._sumPixelValues(node, ["padding-" + side], true); |
}; |
dojo.html.getPadding = function (node) { |
return {width:dojo.html._sumPixelValues(node, ["padding-left", "padding-right"], true), height:dojo.html._sumPixelValues(node, ["padding-top", "padding-bottom"], true)}; |
}; |
dojo.html.getPadBorder = function (node) { |
var pad = dojo.html.getPadding(node); |
var border = dojo.html.getBorder(node); |
return {width:pad.width + border.width, height:pad.height + border.height}; |
}; |
dojo.html.getBoxSizing = function (node) { |
var h = dojo.render.html; |
var bs = dojo.html.boxSizing; |
if (((h.ie) || (h.opera)) && node.nodeName.toLowerCase() != "img") { |
var cm = document["compatMode"]; |
if ((cm == "BackCompat") || (cm == "QuirksMode")) { |
return bs.BORDER_BOX; |
} else { |
return bs.CONTENT_BOX; |
} |
} else { |
if (arguments.length == 0) { |
node = document.documentElement; |
} |
var sizing; |
if (!h.ie) { |
sizing = dojo.html.getStyle(node, "-moz-box-sizing"); |
if (!sizing) { |
sizing = dojo.html.getStyle(node, "box-sizing"); |
} |
} |
return (sizing ? sizing : bs.CONTENT_BOX); |
} |
}; |
dojo.html.isBorderBox = function (node) { |
return (dojo.html.getBoxSizing(node) == dojo.html.boxSizing.BORDER_BOX); |
}; |
dojo.html.getBorderBox = function (node) { |
node = dojo.byId(node); |
return {width:node.offsetWidth, height:node.offsetHeight}; |
}; |
dojo.html.getPaddingBox = function (node) { |
var box = dojo.html.getBorderBox(node); |
var border = dojo.html.getBorder(node); |
return {width:box.width - border.width, height:box.height - border.height}; |
}; |
dojo.html.getContentBox = function (node) { |
node = dojo.byId(node); |
var padborder = dojo.html.getPadBorder(node); |
return {width:node.offsetWidth - padborder.width, height:node.offsetHeight - padborder.height}; |
}; |
dojo.html.setContentBox = function (node, args) { |
node = dojo.byId(node); |
var width = 0; |
var height = 0; |
var isbb = dojo.html.isBorderBox(node); |
var padborder = (isbb ? dojo.html.getPadBorder(node) : {width:0, height:0}); |
var ret = {}; |
if (typeof args.width != "undefined") { |
width = args.width + padborder.width; |
ret.width = dojo.html.setPositivePixelValue(node, "width", width); |
} |
if (typeof args.height != "undefined") { |
height = args.height + padborder.height; |
ret.height = dojo.html.setPositivePixelValue(node, "height", height); |
} |
return ret; |
}; |
dojo.html.getMarginBox = function (node) { |
var borderbox = dojo.html.getBorderBox(node); |
var margin = dojo.html.getMargin(node); |
return {width:borderbox.width + margin.width, height:borderbox.height + margin.height}; |
}; |
dojo.html.setMarginBox = function (node, args) { |
node = dojo.byId(node); |
var width = 0; |
var height = 0; |
var isbb = dojo.html.isBorderBox(node); |
var padborder = (!isbb ? dojo.html.getPadBorder(node) : {width:0, height:0}); |
var margin = dojo.html.getMargin(node); |
var ret = {}; |
if (typeof args.width != "undefined") { |
width = args.width - padborder.width; |
width -= margin.width; |
ret.width = dojo.html.setPositivePixelValue(node, "width", width); |
} |
if (typeof args.height != "undefined") { |
height = args.height - padborder.height; |
height -= margin.height; |
ret.height = dojo.html.setPositivePixelValue(node, "height", height); |
} |
return ret; |
}; |
dojo.html.getElementBox = function (node, type) { |
var bs = dojo.html.boxSizing; |
switch (type) { |
case bs.MARGIN_BOX: |
return dojo.html.getMarginBox(node); |
case bs.BORDER_BOX: |
return dojo.html.getBorderBox(node); |
case bs.PADDING_BOX: |
return dojo.html.getPaddingBox(node); |
case bs.CONTENT_BOX: |
default: |
return dojo.html.getContentBox(node); |
} |
}; |
dojo.html.toCoordinateObject = dojo.html.toCoordinateArray = function (coords, includeScroll, boxtype) { |
if (coords instanceof Array || typeof coords == "array") { |
dojo.deprecated("dojo.html.toCoordinateArray", "use dojo.html.toCoordinateObject({left: , top: , width: , height: }) instead", "0.5"); |
while (coords.length < 4) { |
coords.push(0); |
} |
while (coords.length > 4) { |
coords.pop(); |
} |
var ret = {left:coords[0], top:coords[1], width:coords[2], height:coords[3]}; |
} else { |
if (!coords.nodeType && !(coords instanceof String || typeof coords == "string") && ("width" in coords || "height" in coords || "left" in coords || "x" in coords || "top" in coords || "y" in coords)) { |
var ret = {left:coords.left || coords.x || 0, top:coords.top || coords.y || 0, width:coords.width || 0, height:coords.height || 0}; |
} else { |
var node = dojo.byId(coords); |
var pos = dojo.html.abs(node, includeScroll, boxtype); |
var marginbox = dojo.html.getMarginBox(node); |
var ret = {left:pos.left, top:pos.top, width:marginbox.width, height:marginbox.height}; |
} |
} |
ret.x = ret.left; |
ret.y = ret.top; |
return ret; |
}; |
dojo.html.setMarginBoxWidth = dojo.html.setOuterWidth = function (node, width) { |
return dojo.html._callDeprecated("setMarginBoxWidth", "setMarginBox", arguments, "width"); |
}; |
dojo.html.setMarginBoxHeight = dojo.html.setOuterHeight = function () { |
return dojo.html._callDeprecated("setMarginBoxHeight", "setMarginBox", arguments, "height"); |
}; |
dojo.html.getMarginBoxWidth = dojo.html.getOuterWidth = function () { |
return dojo.html._callDeprecated("getMarginBoxWidth", "getMarginBox", arguments, null, "width"); |
}; |
dojo.html.getMarginBoxHeight = dojo.html.getOuterHeight = function () { |
return dojo.html._callDeprecated("getMarginBoxHeight", "getMarginBox", arguments, null, "height"); |
}; |
dojo.html.getTotalOffset = function (node, type, includeScroll) { |
return dojo.html._callDeprecated("getTotalOffset", "getAbsolutePosition", arguments, null, type); |
}; |
dojo.html.getAbsoluteX = function (node, includeScroll) { |
return dojo.html._callDeprecated("getAbsoluteX", "getAbsolutePosition", arguments, null, "x"); |
}; |
dojo.html.getAbsoluteY = function (node, includeScroll) { |
return dojo.html._callDeprecated("getAbsoluteY", "getAbsolutePosition", arguments, null, "y"); |
}; |
dojo.html.totalOffsetLeft = function (node, includeScroll) { |
return dojo.html._callDeprecated("totalOffsetLeft", "getAbsolutePosition", arguments, null, "left"); |
}; |
dojo.html.totalOffsetTop = function (node, includeScroll) { |
return dojo.html._callDeprecated("totalOffsetTop", "getAbsolutePosition", arguments, null, "top"); |
}; |
dojo.html.getMarginWidth = function (node) { |
return dojo.html._callDeprecated("getMarginWidth", "getMargin", arguments, null, "width"); |
}; |
dojo.html.getMarginHeight = function (node) { |
return dojo.html._callDeprecated("getMarginHeight", "getMargin", arguments, null, "height"); |
}; |
dojo.html.getBorderWidth = function (node) { |
return dojo.html._callDeprecated("getBorderWidth", "getBorder", arguments, null, "width"); |
}; |
dojo.html.getBorderHeight = function (node) { |
return dojo.html._callDeprecated("getBorderHeight", "getBorder", arguments, null, "height"); |
}; |
dojo.html.getPaddingWidth = function (node) { |
return dojo.html._callDeprecated("getPaddingWidth", "getPadding", arguments, null, "width"); |
}; |
dojo.html.getPaddingHeight = function (node) { |
return dojo.html._callDeprecated("getPaddingHeight", "getPadding", arguments, null, "height"); |
}; |
dojo.html.getPadBorderWidth = function (node) { |
return dojo.html._callDeprecated("getPadBorderWidth", "getPadBorder", arguments, null, "width"); |
}; |
dojo.html.getPadBorderHeight = function (node) { |
return dojo.html._callDeprecated("getPadBorderHeight", "getPadBorder", arguments, null, "height"); |
}; |
dojo.html.getBorderBoxWidth = dojo.html.getInnerWidth = function () { |
return dojo.html._callDeprecated("getBorderBoxWidth", "getBorderBox", arguments, null, "width"); |
}; |
dojo.html.getBorderBoxHeight = dojo.html.getInnerHeight = function () { |
return dojo.html._callDeprecated("getBorderBoxHeight", "getBorderBox", arguments, null, "height"); |
}; |
dojo.html.getContentBoxWidth = dojo.html.getContentWidth = function () { |
return dojo.html._callDeprecated("getContentBoxWidth", "getContentBox", arguments, null, "width"); |
}; |
dojo.html.getContentBoxHeight = dojo.html.getContentHeight = function () { |
return dojo.html._callDeprecated("getContentBoxHeight", "getContentBox", arguments, null, "height"); |
}; |
dojo.html.setContentBoxWidth = dojo.html.setContentWidth = function (node, width) { |
return dojo.html._callDeprecated("setContentBoxWidth", "setContentBox", arguments, "width"); |
}; |
dojo.html.setContentBoxHeight = dojo.html.setContentHeight = function (node, height) { |
return dojo.html._callDeprecated("setContentBoxHeight", "setContentBox", arguments, "height"); |
}; |
/trunk/api/js/dojo/src/html/util.js |
---|
New file |
0,0 → 1,354 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.util"); |
dojo.require("dojo.html.layout"); |
dojo.html.getElementWindow = function (element) { |
return dojo.html.getDocumentWindow(element.ownerDocument); |
}; |
dojo.html.getDocumentWindow = function (doc) { |
if (dojo.render.html.safari && !doc._parentWindow) { |
var fix = function (win) { |
win.document._parentWindow = win; |
for (var i = 0; i < win.frames.length; i++) { |
fix(win.frames[i]); |
} |
}; |
fix(window.top); |
} |
if (dojo.render.html.ie && window !== document.parentWindow && !doc._parentWindow) { |
doc.parentWindow.execScript("document._parentWindow = window;", "Javascript"); |
var win = doc._parentWindow; |
doc._parentWindow = null; |
return win; |
} |
return doc._parentWindow || doc.parentWindow || doc.defaultView; |
}; |
dojo.html.gravity = function (node, e) { |
node = dojo.byId(node); |
var mouse = dojo.html.getCursorPosition(e); |
with (dojo.html) { |
var absolute = getAbsolutePosition(node, true); |
var bb = getBorderBox(node); |
var nodecenterx = absolute.x + (bb.width / 2); |
var nodecentery = absolute.y + (bb.height / 2); |
} |
with (dojo.html.gravity) { |
return ((mouse.x < nodecenterx ? WEST : EAST) | (mouse.y < nodecentery ? NORTH : SOUTH)); |
} |
}; |
dojo.html.gravity.NORTH = 1; |
dojo.html.gravity.SOUTH = 1 << 1; |
dojo.html.gravity.EAST = 1 << 2; |
dojo.html.gravity.WEST = 1 << 3; |
dojo.html.overElement = function (element, e) { |
element = dojo.byId(element); |
var mouse = dojo.html.getCursorPosition(e); |
var bb = dojo.html.getBorderBox(element); |
var absolute = dojo.html.getAbsolutePosition(element, true, dojo.html.boxSizing.BORDER_BOX); |
var top = absolute.y; |
var bottom = top + bb.height; |
var left = absolute.x; |
var right = left + bb.width; |
return (mouse.x >= left && mouse.x <= right && mouse.y >= top && mouse.y <= bottom); |
}; |
dojo.html.renderedTextContent = function (node) { |
node = dojo.byId(node); |
var result = ""; |
if (node == null) { |
return result; |
} |
for (var i = 0; i < node.childNodes.length; i++) { |
switch (node.childNodes[i].nodeType) { |
case 1: |
case 5: |
var display = "unknown"; |
try { |
display = dojo.html.getStyle(node.childNodes[i], "display"); |
} |
catch (E) { |
} |
switch (display) { |
case "block": |
case "list-item": |
case "run-in": |
case "table": |
case "table-row-group": |
case "table-header-group": |
case "table-footer-group": |
case "table-row": |
case "table-column-group": |
case "table-column": |
case "table-cell": |
case "table-caption": |
result += "\n"; |
result += dojo.html.renderedTextContent(node.childNodes[i]); |
result += "\n"; |
break; |
case "none": |
break; |
default: |
if (node.childNodes[i].tagName && node.childNodes[i].tagName.toLowerCase() == "br") { |
result += "\n"; |
} else { |
result += dojo.html.renderedTextContent(node.childNodes[i]); |
} |
break; |
} |
break; |
case 3: |
case 2: |
case 4: |
var text = node.childNodes[i].nodeValue; |
var textTransform = "unknown"; |
try { |
textTransform = dojo.html.getStyle(node, "text-transform"); |
} |
catch (E) { |
} |
switch (textTransform) { |
case "capitalize": |
var words = text.split(" "); |
for (var i = 0; i < words.length; i++) { |
words[i] = words[i].charAt(0).toUpperCase() + words[i].substring(1); |
} |
text = words.join(" "); |
break; |
case "uppercase": |
text = text.toUpperCase(); |
break; |
case "lowercase": |
text = text.toLowerCase(); |
break; |
default: |
break; |
} |
switch (textTransform) { |
case "nowrap": |
break; |
case "pre-wrap": |
break; |
case "pre-line": |
break; |
case "pre": |
break; |
default: |
text = text.replace(/\s+/, " "); |
if (/\s$/.test(result)) { |
text.replace(/^\s/, ""); |
} |
break; |
} |
result += text; |
break; |
default: |
break; |
} |
} |
return result; |
}; |
dojo.html.createNodesFromText = function (txt, trim) { |
if (trim) { |
txt = txt.replace(/^\s+|\s+$/g, ""); |
} |
var tn = dojo.doc().createElement("div"); |
tn.style.visibility = "hidden"; |
dojo.body().appendChild(tn); |
var tableType = "none"; |
if ((/^<t[dh][\s\r\n>]/i).test(txt.replace(/^\s+/))) { |
txt = "<table><tbody><tr>" + txt + "</tr></tbody></table>"; |
tableType = "cell"; |
} else { |
if ((/^<tr[\s\r\n>]/i).test(txt.replace(/^\s+/))) { |
txt = "<table><tbody>" + txt + "</tbody></table>"; |
tableType = "row"; |
} else { |
if ((/^<(thead|tbody|tfoot)[\s\r\n>]/i).test(txt.replace(/^\s+/))) { |
txt = "<table>" + txt + "</table>"; |
tableType = "section"; |
} |
} |
} |
tn.innerHTML = txt; |
if (tn["normalize"]) { |
tn.normalize(); |
} |
var parent = null; |
switch (tableType) { |
case "cell": |
parent = tn.getElementsByTagName("tr")[0]; |
break; |
case "row": |
parent = tn.getElementsByTagName("tbody")[0]; |
break; |
case "section": |
parent = tn.getElementsByTagName("table")[0]; |
break; |
default: |
parent = tn; |
break; |
} |
var nodes = []; |
for (var x = 0; x < parent.childNodes.length; x++) { |
nodes.push(parent.childNodes[x].cloneNode(true)); |
} |
tn.style.display = "none"; |
dojo.html.destroyNode(tn); |
return nodes; |
}; |
dojo.html.placeOnScreen = function (node, desiredX, desiredY, padding, hasScroll, corners, tryOnly) { |
if (desiredX instanceof Array || typeof desiredX == "array") { |
tryOnly = corners; |
corners = hasScroll; |
hasScroll = padding; |
padding = desiredY; |
desiredY = desiredX[1]; |
desiredX = desiredX[0]; |
} |
if (corners instanceof String || typeof corners == "string") { |
corners = corners.split(","); |
} |
if (!isNaN(padding)) { |
padding = [Number(padding), Number(padding)]; |
} else { |
if (!(padding instanceof Array || typeof padding == "array")) { |
padding = [0, 0]; |
} |
} |
var scroll = dojo.html.getScroll().offset; |
var view = dojo.html.getViewport(); |
node = dojo.byId(node); |
var oldDisplay = node.style.display; |
node.style.display = ""; |
var bb = dojo.html.getBorderBox(node); |
var w = bb.width; |
var h = bb.height; |
node.style.display = oldDisplay; |
if (!(corners instanceof Array || typeof corners == "array")) { |
corners = ["TL"]; |
} |
var bestx, besty, bestDistance = Infinity, bestCorner; |
for (var cidex = 0; cidex < corners.length; ++cidex) { |
var corner = corners[cidex]; |
var match = true; |
var tryX = desiredX - (corner.charAt(1) == "L" ? 0 : w) + padding[0] * (corner.charAt(1) == "L" ? 1 : -1); |
var tryY = desiredY - (corner.charAt(0) == "T" ? 0 : h) + padding[1] * (corner.charAt(0) == "T" ? 1 : -1); |
if (hasScroll) { |
tryX -= scroll.x; |
tryY -= scroll.y; |
} |
if (tryX < 0) { |
tryX = 0; |
match = false; |
} |
if (tryY < 0) { |
tryY = 0; |
match = false; |
} |
var x = tryX + w; |
if (x > view.width) { |
x = view.width - w; |
match = false; |
} else { |
x = tryX; |
} |
x = Math.max(padding[0], x) + scroll.x; |
var y = tryY + h; |
if (y > view.height) { |
y = view.height - h; |
match = false; |
} else { |
y = tryY; |
} |
y = Math.max(padding[1], y) + scroll.y; |
if (match) { |
bestx = x; |
besty = y; |
bestDistance = 0; |
bestCorner = corner; |
break; |
} else { |
var dist = Math.pow(x - tryX - scroll.x, 2) + Math.pow(y - tryY - scroll.y, 2); |
if (bestDistance > dist) { |
bestDistance = dist; |
bestx = x; |
besty = y; |
bestCorner = corner; |
} |
} |
} |
if (!tryOnly) { |
node.style.left = bestx + "px"; |
node.style.top = besty + "px"; |
} |
return {left:bestx, top:besty, x:bestx, y:besty, dist:bestDistance, corner:bestCorner}; |
}; |
dojo.html.placeOnScreenPoint = function (node, desiredX, desiredY, padding, hasScroll) { |
dojo.deprecated("dojo.html.placeOnScreenPoint", "use dojo.html.placeOnScreen() instead", "0.5"); |
return dojo.html.placeOnScreen(node, desiredX, desiredY, padding, hasScroll, ["TL", "TR", "BL", "BR"]); |
}; |
dojo.html.placeOnScreenAroundElement = function (node, aroundNode, padding, aroundType, aroundCorners, tryOnly) { |
var best, bestDistance = Infinity; |
aroundNode = dojo.byId(aroundNode); |
var oldDisplay = aroundNode.style.display; |
aroundNode.style.display = ""; |
var mb = dojo.html.getElementBox(aroundNode, aroundType); |
var aroundNodeW = mb.width; |
var aroundNodeH = mb.height; |
var aroundNodePos = dojo.html.getAbsolutePosition(aroundNode, true, aroundType); |
aroundNode.style.display = oldDisplay; |
for (var nodeCorner in aroundCorners) { |
var pos, desiredX, desiredY; |
var corners = aroundCorners[nodeCorner]; |
desiredX = aroundNodePos.x + (nodeCorner.charAt(1) == "L" ? 0 : aroundNodeW); |
desiredY = aroundNodePos.y + (nodeCorner.charAt(0) == "T" ? 0 : aroundNodeH); |
pos = dojo.html.placeOnScreen(node, desiredX, desiredY, padding, true, corners, true); |
if (pos.dist == 0) { |
best = pos; |
break; |
} else { |
if (bestDistance > pos.dist) { |
bestDistance = pos.dist; |
best = pos; |
} |
} |
} |
if (!tryOnly) { |
node.style.left = best.left + "px"; |
node.style.top = best.top + "px"; |
} |
return best; |
}; |
dojo.html.scrollIntoView = function (node) { |
if (!node) { |
return; |
} |
if (dojo.render.html.ie) { |
if (dojo.html.getBorderBox(node.parentNode).height <= node.parentNode.scrollHeight) { |
node.scrollIntoView(false); |
} |
} else { |
if (dojo.render.html.mozilla) { |
node.scrollIntoView(false); |
} else { |
var parent = node.parentNode; |
var parentBottom = parent.scrollTop + dojo.html.getBorderBox(parent).height; |
var nodeBottom = node.offsetTop + dojo.html.getMarginBox(node).height; |
if (parentBottom < nodeBottom) { |
parent.scrollTop += (nodeBottom - parentBottom); |
} else { |
if (parent.scrollTop > node.offsetTop) { |
parent.scrollTop -= (parent.scrollTop - node.offsetTop); |
} |
} |
} |
} |
}; |
/trunk/api/js/dojo/src/html/color.js |
---|
New file |
0,0 → 1,36 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.require("dojo.html.style"); |
dojo.provide("dojo.html.color"); |
dojo.require("dojo.gfx.color"); |
dojo.require("dojo.lang.common"); |
dojo.html.getBackgroundColor = function (node) { |
node = dojo.byId(node); |
var color; |
do { |
color = dojo.html.getStyle(node, "background-color"); |
if (color.toLowerCase() == "rgba(0, 0, 0, 0)") { |
color = "transparent"; |
} |
if (node == document.getElementsByTagName("body")[0]) { |
node = null; |
break; |
} |
node = node.parentNode; |
} while (node && dojo.lang.inArray(["transparent", ""], color)); |
if (color == "transparent") { |
color = [255, 255, 255, 0]; |
} else { |
color = dojo.gfx.color.extractRGB(color); |
} |
return color; |
}; |
/trunk/api/js/dojo/src/html/style.js |
---|
New file |
0,0 → 1,481 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.style"); |
dojo.require("dojo.html.common"); |
dojo.require("dojo.uri.Uri"); |
dojo.html.getClass = function (node) { |
node = dojo.byId(node); |
if (!node) { |
return ""; |
} |
var cs = ""; |
if (node.className) { |
cs = node.className; |
} else { |
if (dojo.html.hasAttribute(node, "class")) { |
cs = dojo.html.getAttribute(node, "class"); |
} |
} |
return cs.replace(/^\s+|\s+$/g, ""); |
}; |
dojo.html.getClasses = function (node) { |
var c = dojo.html.getClass(node); |
return (c == "") ? [] : c.split(/\s+/g); |
}; |
dojo.html.hasClass = function (node, classname) { |
return (new RegExp("(^|\\s+)" + classname + "(\\s+|$)")).test(dojo.html.getClass(node)); |
}; |
dojo.html.prependClass = function (node, classStr) { |
classStr += " " + dojo.html.getClass(node); |
return dojo.html.setClass(node, classStr); |
}; |
dojo.html.addClass = function (node, classStr) { |
if (dojo.html.hasClass(node, classStr)) { |
return false; |
} |
classStr = (dojo.html.getClass(node) + " " + classStr).replace(/^\s+|\s+$/g, ""); |
return dojo.html.setClass(node, classStr); |
}; |
dojo.html.setClass = function (node, classStr) { |
node = dojo.byId(node); |
var cs = new String(classStr); |
try { |
if (typeof node.className == "string") { |
node.className = cs; |
} else { |
if (node.setAttribute) { |
node.setAttribute("class", classStr); |
node.className = cs; |
} else { |
return false; |
} |
} |
} |
catch (e) { |
dojo.debug("dojo.html.setClass() failed", e); |
} |
return true; |
}; |
dojo.html.removeClass = function (node, classStr, allowPartialMatches) { |
try { |
if (!allowPartialMatches) { |
var newcs = dojo.html.getClass(node).replace(new RegExp("(^|\\s+)" + classStr + "(\\s+|$)"), "$1$2"); |
} else { |
var newcs = dojo.html.getClass(node).replace(classStr, ""); |
} |
dojo.html.setClass(node, newcs); |
} |
catch (e) { |
dojo.debug("dojo.html.removeClass() failed", e); |
} |
return true; |
}; |
dojo.html.replaceClass = function (node, newClass, oldClass) { |
dojo.html.removeClass(node, oldClass); |
dojo.html.addClass(node, newClass); |
}; |
dojo.html.classMatchType = {ContainsAll:0, ContainsAny:1, IsOnly:2}; |
dojo.html.getElementsByClass = function (classStr, parent, nodeType, classMatchType, useNonXpath) { |
useNonXpath = false; |
var _document = dojo.doc(); |
parent = dojo.byId(parent) || _document; |
var classes = classStr.split(/\s+/g); |
var nodes = []; |
if (classMatchType != 1 && classMatchType != 2) { |
classMatchType = 0; |
} |
var reClass = new RegExp("(\\s|^)((" + classes.join(")|(") + "))(\\s|$)"); |
var srtLength = classes.join(" ").length; |
var candidateNodes = []; |
if (!useNonXpath && _document.evaluate) { |
var xpath = ".//" + (nodeType || "*") + "[contains("; |
if (classMatchType != dojo.html.classMatchType.ContainsAny) { |
xpath += "concat(' ',@class,' '), ' " + classes.join(" ') and contains(concat(' ',@class,' '), ' ") + " ')"; |
if (classMatchType == 2) { |
xpath += " and string-length(@class)=" + srtLength + "]"; |
} else { |
xpath += "]"; |
} |
} else { |
xpath += "concat(' ',@class,' '), ' " + classes.join(" ') or contains(concat(' ',@class,' '), ' ") + " ')]"; |
} |
var xpathResult = _document.evaluate(xpath, parent, null, XPathResult.ANY_TYPE, null); |
var result = xpathResult.iterateNext(); |
while (result) { |
try { |
candidateNodes.push(result); |
result = xpathResult.iterateNext(); |
} |
catch (e) { |
break; |
} |
} |
return candidateNodes; |
} else { |
if (!nodeType) { |
nodeType = "*"; |
} |
candidateNodes = parent.getElementsByTagName(nodeType); |
var node, i = 0; |
outer: |
while (node = candidateNodes[i++]) { |
var nodeClasses = dojo.html.getClasses(node); |
if (nodeClasses.length == 0) { |
continue outer; |
} |
var matches = 0; |
for (var j = 0; j < nodeClasses.length; j++) { |
if (reClass.test(nodeClasses[j])) { |
if (classMatchType == dojo.html.classMatchType.ContainsAny) { |
nodes.push(node); |
continue outer; |
} else { |
matches++; |
} |
} else { |
if (classMatchType == dojo.html.classMatchType.IsOnly) { |
continue outer; |
} |
} |
} |
if (matches == classes.length) { |
if ((classMatchType == dojo.html.classMatchType.IsOnly) && (matches == nodeClasses.length)) { |
nodes.push(node); |
} else { |
if (classMatchType == dojo.html.classMatchType.ContainsAll) { |
nodes.push(node); |
} |
} |
} |
} |
return nodes; |
} |
}; |
dojo.html.getElementsByClassName = dojo.html.getElementsByClass; |
dojo.html.toCamelCase = function (selector) { |
var arr = selector.split("-"), cc = arr[0]; |
for (var i = 1; i < arr.length; i++) { |
cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1); |
} |
return cc; |
}; |
dojo.html.toSelectorCase = function (selector) { |
return selector.replace(/([A-Z])/g, "-$1").toLowerCase(); |
}; |
if (dojo.render.html.ie) { |
dojo.html.getComputedStyle = function (node, property, value) { |
node = dojo.byId(node); |
if (!node || !node.style) { |
return value; |
} |
return node.currentStyle[dojo.html.toCamelCase(property)]; |
}; |
dojo.html.getComputedStyles = function (node) { |
return node.currentStyle; |
}; |
} else { |
dojo.html.getComputedStyle = function (node, property, value) { |
node = dojo.byId(node); |
if (!node || !node.style) { |
return value; |
} |
var s = document.defaultView.getComputedStyle(node, null); |
return (s && s[dojo.html.toCamelCase(property)]) || ""; |
}; |
dojo.html.getComputedStyles = function (node) { |
return document.defaultView.getComputedStyle(node, null); |
}; |
} |
dojo.html.getStyleProperty = function (node, cssSelector) { |
node = dojo.byId(node); |
return (node && node.style ? node.style[dojo.html.toCamelCase(cssSelector)] : undefined); |
}; |
dojo.html.getStyle = function (node, cssSelector) { |
var value = dojo.html.getStyleProperty(node, cssSelector); |
return (value ? value : dojo.html.getComputedStyle(node, cssSelector)); |
}; |
dojo.html.setStyle = function (node, cssSelector, value) { |
node = dojo.byId(node); |
if (node && node.style) { |
var camelCased = dojo.html.toCamelCase(cssSelector); |
node.style[camelCased] = value; |
} |
}; |
dojo.html.setStyleText = function (target, text) { |
try { |
target.style.cssText = text; |
} |
catch (e) { |
target.setAttribute("style", text); |
} |
}; |
dojo.html.copyStyle = function (target, source) { |
if (!source.style.cssText) { |
target.setAttribute("style", source.getAttribute("style")); |
} else { |
target.style.cssText = source.style.cssText; |
} |
dojo.html.addClass(target, dojo.html.getClass(source)); |
}; |
dojo.html.getUnitValue = function (node, cssSelector, autoIsZero) { |
var s = dojo.html.getComputedStyle(node, cssSelector); |
if ((!s) || ((s == "auto") && (autoIsZero))) { |
return {value:0, units:"px"}; |
} |
var match = s.match(/(\-?[\d.]+)([a-z%]*)/i); |
if (!match) { |
return dojo.html.getUnitValue.bad; |
} |
return {value:Number(match[1]), units:match[2].toLowerCase()}; |
}; |
dojo.html.getUnitValue.bad = {value:NaN, units:""}; |
if (dojo.render.html.ie) { |
dojo.html.toPixelValue = function (element, styleValue) { |
if (!styleValue) { |
return 0; |
} |
if (styleValue.slice(-2) == "px") { |
return parseFloat(styleValue); |
} |
var pixelValue = 0; |
with (element) { |
var sLeft = style.left; |
var rsLeft = runtimeStyle.left; |
runtimeStyle.left = currentStyle.left; |
try { |
style.left = styleValue || 0; |
pixelValue = style.pixelLeft; |
style.left = sLeft; |
runtimeStyle.left = rsLeft; |
} |
catch (e) { |
} |
} |
return pixelValue; |
}; |
} else { |
dojo.html.toPixelValue = function (element, styleValue) { |
return (styleValue && (styleValue.slice(-2) == "px") ? parseFloat(styleValue) : 0); |
}; |
} |
dojo.html.getPixelValue = function (node, styleProperty, autoIsZero) { |
return dojo.html.toPixelValue(node, dojo.html.getComputedStyle(node, styleProperty)); |
}; |
dojo.html.setPositivePixelValue = function (node, selector, value) { |
if (isNaN(value)) { |
return false; |
} |
node.style[selector] = Math.max(0, value) + "px"; |
return true; |
}; |
dojo.html.styleSheet = null; |
dojo.html.insertCssRule = function (selector, declaration, index) { |
if (!dojo.html.styleSheet) { |
if (document.createStyleSheet) { |
dojo.html.styleSheet = document.createStyleSheet(); |
} else { |
if (document.styleSheets[0]) { |
dojo.html.styleSheet = document.styleSheets[0]; |
} else { |
return null; |
} |
} |
} |
if (arguments.length < 3) { |
if (dojo.html.styleSheet.cssRules) { |
index = dojo.html.styleSheet.cssRules.length; |
} else { |
if (dojo.html.styleSheet.rules) { |
index = dojo.html.styleSheet.rules.length; |
} else { |
return null; |
} |
} |
} |
if (dojo.html.styleSheet.insertRule) { |
var rule = selector + " { " + declaration + " }"; |
return dojo.html.styleSheet.insertRule(rule, index); |
} else { |
if (dojo.html.styleSheet.addRule) { |
return dojo.html.styleSheet.addRule(selector, declaration, index); |
} else { |
return null; |
} |
} |
}; |
dojo.html.removeCssRule = function (index) { |
if (!dojo.html.styleSheet) { |
dojo.debug("no stylesheet defined for removing rules"); |
return false; |
} |
if (dojo.render.html.ie) { |
if (!index) { |
index = dojo.html.styleSheet.rules.length; |
dojo.html.styleSheet.removeRule(index); |
} |
} else { |
if (document.styleSheets[0]) { |
if (!index) { |
index = dojo.html.styleSheet.cssRules.length; |
} |
dojo.html.styleSheet.deleteRule(index); |
} |
} |
return true; |
}; |
dojo.html._insertedCssFiles = []; |
dojo.html.insertCssFile = function (URI, doc, checkDuplicates, fail_ok) { |
if (!URI) { |
return; |
} |
if (!doc) { |
doc = document; |
} |
var cssStr = dojo.hostenv.getText(URI, false, fail_ok); |
if (cssStr === null) { |
return; |
} |
cssStr = dojo.html.fixPathsInCssText(cssStr, URI); |
if (checkDuplicates) { |
var idx = -1, node, ent = dojo.html._insertedCssFiles; |
for (var i = 0; i < ent.length; i++) { |
if ((ent[i].doc == doc) && (ent[i].cssText == cssStr)) { |
idx = i; |
node = ent[i].nodeRef; |
break; |
} |
} |
if (node) { |
var styles = doc.getElementsByTagName("style"); |
for (var i = 0; i < styles.length; i++) { |
if (styles[i] == node) { |
return; |
} |
} |
dojo.html._insertedCssFiles.shift(idx, 1); |
} |
} |
var style = dojo.html.insertCssText(cssStr, doc); |
dojo.html._insertedCssFiles.push({"doc":doc, "cssText":cssStr, "nodeRef":style}); |
if (style && djConfig.isDebug) { |
style.setAttribute("dbgHref", URI); |
} |
return style; |
}; |
dojo.html.insertCssText = function (cssStr, doc, URI) { |
if (!cssStr) { |
return; |
} |
if (!doc) { |
doc = document; |
} |
if (URI) { |
cssStr = dojo.html.fixPathsInCssText(cssStr, URI); |
} |
var style = doc.createElement("style"); |
style.setAttribute("type", "text/css"); |
var head = doc.getElementsByTagName("head")[0]; |
if (!head) { |
dojo.debug("No head tag in document, aborting styles"); |
return; |
} else { |
head.appendChild(style); |
} |
if (style.styleSheet) { |
var setFunc = function () { |
try { |
style.styleSheet.cssText = cssStr; |
} |
catch (e) { |
dojo.debug(e); |
} |
}; |
if (style.styleSheet.disabled) { |
setTimeout(setFunc, 10); |
} else { |
setFunc(); |
} |
} else { |
var cssText = doc.createTextNode(cssStr); |
style.appendChild(cssText); |
} |
return style; |
}; |
dojo.html.fixPathsInCssText = function (cssStr, URI) { |
if (!cssStr || !URI) { |
return; |
} |
var match, str = "", url = "", urlChrs = "[\\t\\s\\w\\(\\)\\/\\.\\\\'\"-:#=&?~]+"; |
var regex = new RegExp("url\\(\\s*(" + urlChrs + ")\\s*\\)"); |
var regexProtocol = /(file|https?|ftps?):\/\//; |
regexTrim = new RegExp("^[\\s]*(['\"]?)(" + urlChrs + ")\\1[\\s]*?$"); |
if (dojo.render.html.ie55 || dojo.render.html.ie60) { |
var regexIe = new RegExp("AlphaImageLoader\\((.*)src=['\"](" + urlChrs + ")['\"]"); |
while (match = regexIe.exec(cssStr)) { |
url = match[2].replace(regexTrim, "$2"); |
if (!regexProtocol.exec(url)) { |
url = (new dojo.uri.Uri(URI, url).toString()); |
} |
str += cssStr.substring(0, match.index) + "AlphaImageLoader(" + match[1] + "src='" + url + "'"; |
cssStr = cssStr.substr(match.index + match[0].length); |
} |
cssStr = str + cssStr; |
str = ""; |
} |
while (match = regex.exec(cssStr)) { |
url = match[1].replace(regexTrim, "$2"); |
if (!regexProtocol.exec(url)) { |
url = (new dojo.uri.Uri(URI, url).toString()); |
} |
str += cssStr.substring(0, match.index) + "url(" + url + ")"; |
cssStr = cssStr.substr(match.index + match[0].length); |
} |
return str + cssStr; |
}; |
dojo.html.setActiveStyleSheet = function (title) { |
var i = 0, a, els = dojo.doc().getElementsByTagName("link"); |
while (a = els[i++]) { |
if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { |
a.disabled = true; |
if (a.getAttribute("title") == title) { |
a.disabled = false; |
} |
} |
} |
}; |
dojo.html.getActiveStyleSheet = function () { |
var i = 0, a, els = dojo.doc().getElementsByTagName("link"); |
while (a = els[i++]) { |
if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) { |
return a.getAttribute("title"); |
} |
} |
return null; |
}; |
dojo.html.getPreferredStyleSheet = function () { |
var i = 0, a, els = dojo.doc().getElementsByTagName("link"); |
while (a = els[i++]) { |
if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) { |
return a.getAttribute("title"); |
} |
} |
return null; |
}; |
dojo.html.applyBrowserClass = function (node) { |
var drh = dojo.render.html; |
var classes = {dj_ie:drh.ie, dj_ie55:drh.ie55, dj_ie6:drh.ie60, dj_ie7:drh.ie70, dj_iequirks:drh.ie && drh.quirks, dj_opera:drh.opera, dj_opera8:drh.opera && (Math.floor(dojo.render.version) == 8), dj_opera9:drh.opera && (Math.floor(dojo.render.version) == 9), dj_khtml:drh.khtml, dj_safari:drh.safari, dj_gecko:drh.mozilla}; |
for (var p in classes) { |
if (classes[p]) { |
dojo.html.addClass(node, p); |
} |
} |
}; |
/trunk/api/js/dojo/src/html/iframe.js |
---|
New file |
0,0 → 1,82 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.iframe"); |
dojo.require("dojo.html.util"); |
dojo.html.iframeContentWindow = function (iframe_el) { |
var win = dojo.html.getDocumentWindow(dojo.html.iframeContentDocument(iframe_el)) || dojo.html.iframeContentDocument(iframe_el).__parent__ || (iframe_el.name && document.frames[iframe_el.name]) || null; |
return win; |
}; |
dojo.html.iframeContentDocument = function (iframe_el) { |
var doc = iframe_el.contentDocument || ((iframe_el.contentWindow) && (iframe_el.contentWindow.document)) || ((iframe_el.name) && (document.frames[iframe_el.name]) && (document.frames[iframe_el.name].document)) || null; |
return doc; |
}; |
dojo.html.BackgroundIframe = function (node) { |
if (dojo.render.html.ie55 || dojo.render.html.ie60) { |
var html = "<iframe src='javascript:false'" + " style='position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;" + "z-index: -1; filter:Alpha(Opacity=\"0\");' " + ">"; |
this.iframe = dojo.doc().createElement(html); |
this.iframe.tabIndex = -1; |
if (node) { |
node.appendChild(this.iframe); |
this.domNode = node; |
} else { |
dojo.body().appendChild(this.iframe); |
this.iframe.style.display = "none"; |
} |
} |
}; |
dojo.lang.extend(dojo.html.BackgroundIframe, {iframe:null, onResized:function () { |
if (this.iframe && this.domNode && this.domNode.parentNode) { |
var outer = dojo.html.getMarginBox(this.domNode); |
if (outer.width == 0 || outer.height == 0) { |
dojo.lang.setTimeout(this, this.onResized, 100); |
return; |
} |
this.iframe.style.width = outer.width + "px"; |
this.iframe.style.height = outer.height + "px"; |
} |
}, size:function (node) { |
if (!this.iframe) { |
return; |
} |
var coords = dojo.html.toCoordinateObject(node, true, dojo.html.boxSizing.BORDER_BOX); |
with (this.iframe.style) { |
width = coords.width + "px"; |
height = coords.height + "px"; |
left = coords.left + "px"; |
top = coords.top + "px"; |
} |
}, setZIndex:function (node) { |
if (!this.iframe) { |
return; |
} |
if (dojo.dom.isNode(node)) { |
this.iframe.style.zIndex = dojo.html.getStyle(node, "z-index") - 1; |
} else { |
if (!isNaN(node)) { |
this.iframe.style.zIndex = node; |
} |
} |
}, show:function () { |
if (this.iframe) { |
this.iframe.style.display = "block"; |
} |
}, hide:function () { |
if (this.iframe) { |
this.iframe.style.display = "none"; |
} |
}, remove:function () { |
if (this.iframe) { |
dojo.html.removeNode(this.iframe, true); |
delete this.iframe; |
this.iframe = null; |
} |
}}); |
/trunk/api/js/dojo/src/html/display.js |
---|
New file |
0,0 → 1,145 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.display"); |
dojo.require("dojo.html.style"); |
dojo.html._toggle = function (node, tester, setter) { |
node = dojo.byId(node); |
setter(node, !tester(node)); |
return tester(node); |
}; |
dojo.html.show = function (node) { |
node = dojo.byId(node); |
if (dojo.html.getStyleProperty(node, "display") == "none") { |
dojo.html.setStyle(node, "display", (node.dojoDisplayCache || "")); |
node.dojoDisplayCache = undefined; |
} |
}; |
dojo.html.hide = function (node) { |
node = dojo.byId(node); |
if (typeof node["dojoDisplayCache"] == "undefined") { |
var d = dojo.html.getStyleProperty(node, "display"); |
if (d != "none") { |
node.dojoDisplayCache = d; |
} |
} |
dojo.html.setStyle(node, "display", "none"); |
}; |
dojo.html.setShowing = function (node, showing) { |
dojo.html[(showing ? "show" : "hide")](node); |
}; |
dojo.html.isShowing = function (node) { |
return (dojo.html.getStyleProperty(node, "display") != "none"); |
}; |
dojo.html.toggleShowing = function (node) { |
return dojo.html._toggle(node, dojo.html.isShowing, dojo.html.setShowing); |
}; |
dojo.html.displayMap = {tr:"", td:"", th:"", img:"inline", span:"inline", input:"inline", button:"inline"}; |
dojo.html.suggestDisplayByTagName = function (node) { |
node = dojo.byId(node); |
if (node && node.tagName) { |
var tag = node.tagName.toLowerCase(); |
return (tag in dojo.html.displayMap ? dojo.html.displayMap[tag] : "block"); |
} |
}; |
dojo.html.setDisplay = function (node, display) { |
dojo.html.setStyle(node, "display", ((display instanceof String || typeof display == "string") ? display : (display ? dojo.html.suggestDisplayByTagName(node) : "none"))); |
}; |
dojo.html.isDisplayed = function (node) { |
return (dojo.html.getComputedStyle(node, "display") != "none"); |
}; |
dojo.html.toggleDisplay = function (node) { |
return dojo.html._toggle(node, dojo.html.isDisplayed, dojo.html.setDisplay); |
}; |
dojo.html.setVisibility = function (node, visibility) { |
dojo.html.setStyle(node, "visibility", ((visibility instanceof String || typeof visibility == "string") ? visibility : (visibility ? "visible" : "hidden"))); |
}; |
dojo.html.isVisible = function (node) { |
return (dojo.html.getComputedStyle(node, "visibility") != "hidden"); |
}; |
dojo.html.toggleVisibility = function (node) { |
return dojo.html._toggle(node, dojo.html.isVisible, dojo.html.setVisibility); |
}; |
dojo.html.setOpacity = function (node, opacity, dontFixOpacity) { |
node = dojo.byId(node); |
var h = dojo.render.html; |
if (!dontFixOpacity) { |
if (opacity >= 1) { |
if (h.ie) { |
dojo.html.clearOpacity(node); |
return; |
} else { |
opacity = 0.999999; |
} |
} else { |
if (opacity < 0) { |
opacity = 0; |
} |
} |
} |
if (h.ie) { |
if (node.nodeName.toLowerCase() == "tr") { |
var tds = node.getElementsByTagName("td"); |
for (var x = 0; x < tds.length; x++) { |
tds[x].style.filter = "Alpha(Opacity=" + opacity * 100 + ")"; |
} |
} |
node.style.filter = "Alpha(Opacity=" + opacity * 100 + ")"; |
} else { |
if (h.moz) { |
node.style.opacity = opacity; |
node.style.MozOpacity = opacity; |
} else { |
if (h.safari) { |
node.style.opacity = opacity; |
node.style.KhtmlOpacity = opacity; |
} else { |
node.style.opacity = opacity; |
} |
} |
} |
}; |
dojo.html.clearOpacity = function (node) { |
node = dojo.byId(node); |
var ns = node.style; |
var h = dojo.render.html; |
if (h.ie) { |
try { |
if (node.filters && node.filters.alpha) { |
ns.filter = ""; |
} |
} |
catch (e) { |
} |
} else { |
if (h.moz) { |
ns.opacity = 1; |
ns.MozOpacity = 1; |
} else { |
if (h.safari) { |
ns.opacity = 1; |
ns.KhtmlOpacity = 1; |
} else { |
ns.opacity = 1; |
} |
} |
} |
}; |
dojo.html.getOpacity = function (node) { |
node = dojo.byId(node); |
var h = dojo.render.html; |
if (h.ie) { |
var opac = (node.filters && node.filters.alpha && typeof node.filters.alpha.opacity == "number" ? node.filters.alpha.opacity : 100) / 100; |
} else { |
var opac = node.style.opacity || node.style.MozOpacity || node.style.KhtmlOpacity || 1; |
} |
return opac >= 0.999999 ? 1 : Number(opac); |
}; |
/trunk/api/js/dojo/src/html/selection.js |
---|
New file |
0,0 → 1,337 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.require("dojo.html.common"); |
dojo.provide("dojo.html.selection"); |
dojo.require("dojo.dom"); |
dojo.require("dojo.lang.common"); |
dojo.html.selectionType = {NONE:0, TEXT:1, CONTROL:2}; |
dojo.html.clearSelection = function () { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
try { |
if (_window["getSelection"]) { |
if (dojo.render.html.safari) { |
_window.getSelection().collapse(); |
} else { |
_window.getSelection().removeAllRanges(); |
} |
} else { |
if (_document.selection) { |
if (_document.selection.empty) { |
_document.selection.empty(); |
} else { |
if (_document.selection.clear) { |
_document.selection.clear(); |
} |
} |
} |
} |
return true; |
} |
catch (e) { |
dojo.debug(e); |
return false; |
} |
}; |
dojo.html.disableSelection = function (element) { |
element = dojo.byId(element) || dojo.body(); |
var h = dojo.render.html; |
if (h.mozilla) { |
element.style.MozUserSelect = "none"; |
} else { |
if (h.safari) { |
element.style.KhtmlUserSelect = "none"; |
} else { |
if (h.ie) { |
element.unselectable = "on"; |
} else { |
return false; |
} |
} |
} |
return true; |
}; |
dojo.html.enableSelection = function (element) { |
element = dojo.byId(element) || dojo.body(); |
var h = dojo.render.html; |
if (h.mozilla) { |
element.style.MozUserSelect = ""; |
} else { |
if (h.safari) { |
element.style.KhtmlUserSelect = ""; |
} else { |
if (h.ie) { |
element.unselectable = "off"; |
} else { |
return false; |
} |
} |
} |
return true; |
}; |
dojo.html.selectElement = function (element) { |
dojo.deprecated("dojo.html.selectElement", "replaced by dojo.html.selection.selectElementChildren", 0.5); |
}; |
dojo.html.selectInputText = function (element) { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
element = dojo.byId(element); |
if (_document["selection"] && dojo.body()["createTextRange"]) { |
var range = element.createTextRange(); |
range.moveStart("character", 0); |
range.moveEnd("character", element.value.length); |
range.select(); |
} else { |
if (_window["getSelection"]) { |
var selection = _window.getSelection(); |
element.setSelectionRange(0, element.value.length); |
} |
} |
element.focus(); |
}; |
dojo.html.isSelectionCollapsed = function () { |
dojo.deprecated("dojo.html.isSelectionCollapsed", "replaced by dojo.html.selection.isCollapsed", 0.5); |
return dojo.html.selection.isCollapsed(); |
}; |
dojo.lang.mixin(dojo.html.selection, {getType:function () { |
if (dojo.doc()["selection"]) { |
return dojo.html.selectionType[dojo.doc().selection.type.toUpperCase()]; |
} else { |
var stype = dojo.html.selectionType.TEXT; |
var oSel; |
try { |
oSel = dojo.global().getSelection(); |
} |
catch (e) { |
} |
if (oSel && oSel.rangeCount == 1) { |
var oRange = oSel.getRangeAt(0); |
if (oRange.startContainer == oRange.endContainer && (oRange.endOffset - oRange.startOffset) == 1 && oRange.startContainer.nodeType != dojo.dom.TEXT_NODE) { |
stype = dojo.html.selectionType.CONTROL; |
} |
} |
return stype; |
} |
}, isCollapsed:function () { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
if (_document["selection"]) { |
return _document.selection.createRange().text == ""; |
} else { |
if (_window["getSelection"]) { |
var selection = _window.getSelection(); |
if (dojo.lang.isString(selection)) { |
return selection == ""; |
} else { |
return selection.isCollapsed || selection.toString() == ""; |
} |
} |
} |
}, getSelectedElement:function () { |
if (dojo.html.selection.getType() == dojo.html.selectionType.CONTROL) { |
if (dojo.doc()["selection"]) { |
var range = dojo.doc().selection.createRange(); |
if (range && range.item) { |
return dojo.doc().selection.createRange().item(0); |
} |
} else { |
var selection = dojo.global().getSelection(); |
return selection.anchorNode.childNodes[selection.anchorOffset]; |
} |
} |
}, getParentElement:function () { |
if (dojo.html.selection.getType() == dojo.html.selectionType.CONTROL) { |
var p = dojo.html.selection.getSelectedElement(); |
if (p) { |
return p.parentNode; |
} |
} else { |
if (dojo.doc()["selection"]) { |
return dojo.doc().selection.createRange().parentElement(); |
} else { |
var selection = dojo.global().getSelection(); |
if (selection) { |
var node = selection.anchorNode; |
while (node && node.nodeType != dojo.dom.ELEMENT_NODE) { |
node = node.parentNode; |
} |
return node; |
} |
} |
} |
}, getSelectedText:function () { |
if (dojo.doc()["selection"]) { |
if (dojo.html.selection.getType() == dojo.html.selectionType.CONTROL) { |
return null; |
} |
return dojo.doc().selection.createRange().text; |
} else { |
var selection = dojo.global().getSelection(); |
if (selection) { |
return selection.toString(); |
} |
} |
}, getSelectedHtml:function () { |
if (dojo.doc()["selection"]) { |
if (dojo.html.selection.getType() == dojo.html.selectionType.CONTROL) { |
return null; |
} |
return dojo.doc().selection.createRange().htmlText; |
} else { |
var selection = dojo.global().getSelection(); |
if (selection && selection.rangeCount) { |
var frag = selection.getRangeAt(0).cloneContents(); |
var div = document.createElement("div"); |
div.appendChild(frag); |
return div.innerHTML; |
} |
return null; |
} |
}, hasAncestorElement:function (tagName) { |
return (dojo.html.selection.getAncestorElement.apply(this, arguments) != null); |
}, getAncestorElement:function (tagName) { |
var node = dojo.html.selection.getSelectedElement() || dojo.html.selection.getParentElement(); |
while (node) { |
if (dojo.html.selection.isTag(node, arguments).length > 0) { |
return node; |
} |
node = node.parentNode; |
} |
return null; |
}, isTag:function (node, tags) { |
if (node && node.tagName) { |
for (var i = 0; i < tags.length; i++) { |
if (node.tagName.toLowerCase() == String(tags[i]).toLowerCase()) { |
return String(tags[i]).toLowerCase(); |
} |
} |
} |
return ""; |
}, selectElement:function (element) { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
element = dojo.byId(element); |
if (_document.selection && dojo.body().createTextRange) { |
try { |
var range = dojo.body().createControlRange(); |
range.addElement(element); |
range.select(); |
} |
catch (e) { |
dojo.html.selection.selectElementChildren(element); |
} |
} else { |
if (_window["getSelection"]) { |
var selection = _window.getSelection(); |
if (selection["removeAllRanges"]) { |
var range = _document.createRange(); |
range.selectNode(element); |
selection.removeAllRanges(); |
selection.addRange(range); |
} |
} |
} |
}, selectElementChildren:function (element) { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
element = dojo.byId(element); |
if (_document.selection && dojo.body().createTextRange) { |
var range = dojo.body().createTextRange(); |
range.moveToElementText(element); |
range.select(); |
} else { |
if (_window["getSelection"]) { |
var selection = _window.getSelection(); |
if (selection["setBaseAndExtent"]) { |
selection.setBaseAndExtent(element, 0, element, element.innerText.length - 1); |
} else { |
if (selection["selectAllChildren"]) { |
selection.selectAllChildren(element); |
} |
} |
} |
} |
}, getBookmark:function () { |
var bookmark; |
var _document = dojo.doc(); |
if (_document["selection"]) { |
var range = _document.selection.createRange(); |
bookmark = range.getBookmark(); |
} else { |
var selection; |
try { |
selection = dojo.global().getSelection(); |
} |
catch (e) { |
} |
if (selection) { |
var range = selection.getRangeAt(0); |
bookmark = range.cloneRange(); |
} else { |
dojo.debug("No idea how to store the current selection for this browser!"); |
} |
} |
return bookmark; |
}, moveToBookmark:function (bookmark) { |
var _document = dojo.doc(); |
if (_document["selection"]) { |
var range = _document.selection.createRange(); |
range.moveToBookmark(bookmark); |
range.select(); |
} else { |
var selection; |
try { |
selection = dojo.global().getSelection(); |
} |
catch (e) { |
} |
if (selection && selection["removeAllRanges"]) { |
selection.removeAllRanges(); |
selection.addRange(bookmark); |
} else { |
dojo.debug("No idea how to restore selection for this browser!"); |
} |
} |
}, collapse:function (beginning) { |
if (dojo.global()["getSelection"]) { |
var selection = dojo.global().getSelection(); |
if (selection.removeAllRanges) { |
if (beginning) { |
selection.collapseToStart(); |
} else { |
selection.collapseToEnd(); |
} |
} else { |
dojo.global().getSelection().collapse(beginning); |
} |
} else { |
if (dojo.doc().selection) { |
var range = dojo.doc().selection.createRange(); |
range.collapse(beginning); |
range.select(); |
} |
} |
}, remove:function () { |
if (dojo.doc().selection) { |
var selection = dojo.doc().selection; |
if (selection.type.toUpperCase() != "NONE") { |
selection.clear(); |
} |
return selection; |
} else { |
var selection = dojo.global().getSelection(); |
for (var i = 0; i < selection.rangeCount; i++) { |
selection.getRangeAt(i).deleteContents(); |
} |
return selection; |
} |
}}); |
/trunk/api/js/dojo/src/html/shadow.js |
---|
New file |
0,0 → 1,15 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.shadow"); |
dojo.require("dojo.lfx.shadow"); |
dojo.deprecated("dojo.html.shadow has been moved to dojo.lfx.", "0.5"); |
dojo.html.shadow = dojo.lfx.shadow; |
/trunk/api/js/dojo/src/html/metrics.js |
---|
New file |
0,0 → 1,213 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.metrics"); |
dojo.require("dojo.html.layout"); |
dojo.html.getScrollbar = function () { |
var scroll = document.createElement("div"); |
scroll.style.width = "100px"; |
scroll.style.height = "100px"; |
scroll.style.overflow = "scroll"; |
scroll.style.position = "absolute"; |
scroll.style.top = "-300px"; |
scroll.style.left = "0px"; |
var test = document.createElement("div"); |
test.style.width = "400px"; |
test.style.height = "400px"; |
scroll.appendChild(test); |
dojo.body().appendChild(scroll); |
var width = scroll.offsetWidth - scroll.clientWidth; |
dojo.body().removeChild(scroll); |
scroll.removeChild(test); |
scroll = test = null; |
return {width:width}; |
}; |
dojo.html.getFontMeasurements = function () { |
var heights = {"1em":0, "1ex":0, "100%":0, "12pt":0, "16px":0, "xx-small":0, "x-small":0, "small":0, "medium":0, "large":0, "x-large":0, "xx-large":0}; |
if (dojo.render.html.ie) { |
document.documentElement.style.fontSize = "100%"; |
} |
var div = document.createElement("div"); |
div.style.position = "absolute"; |
div.style.left = "-100px"; |
div.style.top = "0"; |
div.style.width = "30px"; |
div.style.height = "1000em"; |
div.style.border = "0"; |
div.style.margin = "0"; |
div.style.padding = "0"; |
div.style.outline = "0"; |
div.style.lineHeight = "1"; |
div.style.overflow = "hidden"; |
dojo.body().appendChild(div); |
for (var p in heights) { |
div.style.fontSize = p; |
heights[p] = Math.round(div.offsetHeight * 12 / 16) * 16 / 12 / 1000; |
} |
dojo.body().removeChild(div); |
div = null; |
return heights; |
}; |
dojo.html._fontMeasurements = null; |
dojo.html.getCachedFontMeasurements = function (recalculate) { |
if (recalculate || !dojo.html._fontMeasurements) { |
dojo.html._fontMeasurements = dojo.html.getFontMeasurements(); |
} |
return dojo.html._fontMeasurements; |
}; |
dojo.html.measureFragment = function (node, html, boxType) { |
var clone = node.cloneNode(true); |
clone.innerHTML = html; |
node.parentNode.appendChild(clone); |
var ret = dojo.html.getElementBox(clone, boxType); |
node.parentNode.removeChild(clone); |
clone = null; |
return ret; |
}; |
dojo.html.getFittedFragment = function (node, html) { |
function cl(node) { |
var element = document.createElement(node.tagName); |
element.id = node.id + "-clone"; |
element.className = node.className; |
for (var j = 0; j < node.attributes.length; j++) { |
if (node.attributes[j].specified) { |
if (node.attributes[j].nodeName.toLowerCase() != "style" && node.attributes[j].nodeName.toLowerCase() != "edited" && node.attributes[j].nodeName.toLowerCase() != "contenteditable" && node.attributes[j].nodeName.toLowerCase() != "id" && node.attributes[j].nodeName.toLowerCase() != "class") { |
element.setAttribute(node.attributes[j].nodeName.toLowerCase(), node.attributes[j].nodeValue); |
} |
} |
} |
return element; |
} |
var height = dojo.html.getFontMeasurements()["16px"]; |
var n = cl(node); |
n.style.width = dojo.html.getBorderBox(node).width + "px"; |
n.style.height = (height + 4) + "px"; |
node.parentNode.appendChild(n); |
var rem = dojo.html.fitToElement(n, html); |
var ret = n.innerHTML; |
n.parentNode.removeChild(n); |
return ret; |
}; |
dojo.html.fitToElement = function (node, html) { |
function cl(node) { |
var element = document.createElement(node.tagName); |
element.id = node.id + "-clone"; |
element.className = node.className; |
for (var j = 0; j < node.attributes.length; j++) { |
if (node.attributes[j].specified) { |
if (node.attributes[j].nodeName.toLowerCase() != "style" && node.attributes[j].nodeName.toLowerCase() != "edited" && node.attributes[j].nodeName.toLowerCase() != "contenteditable" && node.attributes[j].nodeName.toLowerCase() != "id" && node.attributes[j].nodeName.toLowerCase() != "class") { |
element.setAttribute(node.attributes[j].nodeName.toLowerCase(), node.attributes[j].nodeValue); |
} |
} |
} |
return element; |
} |
var clone = cl(node); |
node.parentNode.appendChild(clone); |
var t = dojo.html.getBorderBox(node); |
clone.style.width = t.width + "px"; |
var singletons = ["br", "img", "hr", "input", "!--"]; |
var chop = ["<BR>", "<br>", "<br/>", "<br />", "<p></p>", "<P></P>"]; |
var openTags = []; |
var str = html; |
var i = 0; |
var limit = str.length; |
var add = 0; |
var doLoop = true; |
clone.innerHTML = str; |
while (doLoop) { |
add = Math.round((limit - i) / 2); |
if (add <= 1) { |
doLoop = false; |
} |
i += add; |
clone.innerHTML = str.substr(0, i); |
if (clone.offsetHeight > t.height) { |
limit = i; |
i -= add; |
} |
} |
if (str.substr(0, i) != str) { |
var lastSpace = str.substr(0, i).lastIndexOf(" "); |
var lastNewLine = str.substr(0, i).lastIndexOf("\n"); |
var lastGreater = str.substr(0, i).lastIndexOf(">"); |
var lastLess = str.substr(0, i).lastIndexOf("<"); |
if (lastLess <= lastGreater && lastNewLine == i - 1) { |
i = i; |
} else { |
if (lastSpace != -1 && lastSpace > lastGreater && lastGreater > lastLess) { |
i = lastSpace + 1; |
} else { |
if (lastLess > lastGreater) { |
i = lastLess; |
} else { |
if (lastGreater != -1) { |
i = lastGreater + 1; |
} |
} |
} |
} |
} |
str = str.substr(0, i); |
var ret = html.substr(str.length); |
var doPush = true; |
var tags = str.split("<"); |
tags.shift(); |
for (var j = 0; j < tags.length; j++) { |
tags[j] = tags[j].split(">")[0]; |
if (tags[j].charAt(tags[j].length - 1) == "/") { |
continue; |
} |
if (tags[j].charAt(0) != "/") { |
for (var k = 0; k < singletons.length; k++) { |
if (tags[j].split(" ")[0].toLowerCase() == singletons[k]) { |
doPush = false; |
} |
} |
if (doPush) { |
openTags.push(tags[j]); |
} |
doPush = true; |
} else { |
openTags.pop(); |
} |
} |
for (var j = 0; j < chop.length; j++) { |
if (ret.charAt(0) == "\n") { |
ret = ret.substr(1); |
} |
while (ret.indexOf(chop[j]) == 0) { |
ret = ret.substr(chop[j].length); |
} |
} |
for (var j = openTags.length - 1; j >= 0; j--) { |
if (str.lastIndexOf(openTags[j]) == (str.length - openTags[j].length - 1)) { |
str = str.substring(0, str.lastIndexOf(openTags[j])); |
} else { |
str += "</" + openTags[j] + ">"; |
} |
if (ret.length > 0) { |
ret = "<" + openTags[j] + ">" + ret; |
} |
} |
for (var j = 0; j < chop.length; j++) { |
if (ret.charAt(0) == "\n") { |
ret = ret.substr(1); |
} |
while (ret.indexOf(chop[j]) == 0) { |
ret = ret.substr(chop[j].length); |
} |
} |
node.innerHTML = str; |
clone.parentNode.removeChild(clone); |
clone = null; |
return ret; |
}; |
/trunk/api/js/dojo/src/html/__package__.js |
---|
New file |
0,0 → 1,13 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.kwCompoundRequire({common:["dojo.html.common", "dojo.html.style"]}); |
dojo.provide("dojo.html.*"); |
/trunk/api/js/dojo/src/html/common.js |
---|
New file |
0,0 → 1,180 |
/* |
Copyright (c) 2004-2006, The Dojo Foundation |
All Rights Reserved. |
Licensed under the Academic Free License version 2.1 or above OR the |
modified BSD license. For more information on Dojo licensing, see: |
http://dojotoolkit.org/community/licensing.shtml |
*/ |
dojo.provide("dojo.html.common"); |
dojo.require("dojo.lang.common"); |
dojo.require("dojo.dom"); |
dojo.lang.mixin(dojo.html, dojo.dom); |
dojo.html.body = function () { |
dojo.deprecated("dojo.html.body() moved to dojo.body()", "0.5"); |
return dojo.body(); |
}; |
dojo.html.getEventTarget = function (evt) { |
if (!evt) { |
evt = dojo.global().event || {}; |
} |
var t = (evt.srcElement ? evt.srcElement : (evt.target ? evt.target : null)); |
while ((t) && (t.nodeType != 1)) { |
t = t.parentNode; |
} |
return t; |
}; |
dojo.html.getViewport = function () { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
var w = 0; |
var h = 0; |
if (dojo.render.html.mozilla) { |
w = _document.documentElement.clientWidth; |
h = _window.innerHeight; |
} else { |
if (!dojo.render.html.opera && _window.innerWidth) { |
w = _window.innerWidth; |
h = _window.innerHeight; |
} else { |
if (!dojo.render.html.opera && dojo.exists(_document, "documentElement.clientWidth")) { |
var w2 = _document.documentElement.clientWidth; |
if (!w || w2 && w2 < w) { |
w = w2; |
} |
h = _document.documentElement.clientHeight; |
} else { |
if (dojo.body().clientWidth) { |
w = dojo.body().clientWidth; |
h = dojo.body().clientHeight; |
} |
} |
} |
} |
return {width:w, height:h}; |
}; |
dojo.html.getScroll = function () { |
var _window = dojo.global(); |
var _document = dojo.doc(); |
var top = _window.pageYOffset || _document.documentElement.scrollTop || dojo.body().scrollTop || 0; |
var left = _window.pageXOffset || _document.documentElement.scrollLeft || dojo.body().scrollLeft || 0; |
return {top:top, left:left, offset:{x:left, y:top}}; |
}; |
dojo.html.getParentByType = function (node, type) { |
var _document = dojo.doc(); |
var parent = dojo.byId(node); |
type = type.toLowerCase(); |
while ((parent) && (parent.nodeName.toLowerCase() != type)) { |
if (parent == (_document["body"] || _document["documentElement"])) { |
return null; |
} |
parent = parent.parentNode; |
} |
return parent; |
}; |
dojo.html.getAttribute = function (node, attr) { |
node = dojo.byId(node); |
if ((!node) || (!node.getAttribute)) { |
return null; |
} |
var ta = typeof attr == "string" ? attr : new String(attr); |
var v = node.getAttribute(ta.toUpperCase()); |
if ((v) && (typeof v == "string") && (v != "")) { |
return v; |
} |
if (v && v.value) { |
return v.value; |
} |
if ((node.getAttributeNode) && (node.getAttributeNode(ta))) { |
return (node.getAttributeNode(ta)).value; |
} else { |
if (node.getAttribute(ta)) { |
return node.getAttribute(ta); |
} else { |
if (node.getAttribute(ta.toLowerCase())) { |
return node.getAttribute(ta.toLowerCase()); |
} |
} |
} |
return null; |
}; |
dojo.html.hasAttribute = function (node, attr) { |
return dojo.html.getAttribute(dojo.byId(node), attr) ? true : false; |
}; |
dojo.html.getCursorPosition = function (e) { |
e = e || dojo.global().event; |
var cursor = {x:0, y:0}; |
if (e.pageX || e.pageY) { |
cursor.x = e.pageX; |
cursor.y = e.pageY; |
} else { |
var de = dojo.doc().documentElement; |
var db = dojo.body(); |
cursor.x = e.clientX + ((de || db)["scrollLeft"]) - ((de || db)["clientLeft"]); |
cursor.y = e.clientY + ((de || db)["scrollTop"]) - ((de || db)["clientTop"]); |
} |
return cursor; |
}; |
dojo.html.isTag = function (node) { |
node = dojo.byId(node); |
if (node && node.tagName) { |
for (var i = 1; i < arguments.length; i++) { |
if (node.tagName.toLowerCase() == String(arguments[i]).toLowerCase()) { |
return String(arguments[i]).toLowerCase(); |
} |
} |
} |
return ""; |
}; |
if (dojo.render.html.ie && !dojo.render.html.ie70) { |
if (window.location.href.substr(0, 6).toLowerCase() != "https:") { |
(function () { |
var xscript = dojo.doc().createElement("script"); |
xscript.src = "javascript:'dojo.html.createExternalElement=function(doc, tag){ return doc.createElement(tag); }'"; |
dojo.doc().getElementsByTagName("head")[0].appendChild(xscript); |
})(); |
} |
} else { |
dojo.html.createExternalElement = function (doc, tag) { |
return doc.createElement(tag); |
}; |
} |
dojo.html._callDeprecated = function (inFunc, replFunc, args, argName, retValue) { |
dojo.deprecated("dojo.html." + inFunc, "replaced by dojo.html." + replFunc + "(" + (argName ? "node, {" + argName + ": " + argName + "}" : "") + ")" + (retValue ? "." + retValue : ""), "0.5"); |
var newArgs = []; |
if (argName) { |
var argsIn = {}; |
argsIn[argName] = args[1]; |
newArgs.push(args[0]); |
newArgs.push(argsIn); |
} else { |
newArgs = args; |
} |
var ret = dojo.html[replFunc].apply(dojo.html, args); |
if (retValue) { |
return ret[retValue]; |
} else { |
return ret; |
} |
}; |
dojo.html.getViewportWidth = function () { |
return dojo.html._callDeprecated("getViewportWidth", "getViewport", arguments, null, "width"); |
}; |
dojo.html.getViewportHeight = function () { |
return dojo.html._callDeprecated("getViewportHeight", "getViewport", arguments, null, "height"); |
}; |
dojo.html.getViewportSize = function () { |
return dojo.html._callDeprecated("getViewportSize", "getViewport", arguments); |
}; |
dojo.html.getScrollTop = function () { |
return dojo.html._callDeprecated("getScrollTop", "getScroll", arguments, null, "top"); |
}; |
dojo.html.getScrollLeft = function () { |
return dojo.html._callDeprecated("getScrollLeft", "getScroll", arguments, null, "left"); |
}; |
dojo.html.getScrollOffset = function () { |
return dojo.html._callDeprecated("getScrollOffset", "getScroll", arguments, null, "offset"); |
}; |