Skip to content

Commit

Permalink
refs #12863 update dojox/html to min AMD \!strict
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.dojotoolkit.org/src/dojox/trunk@26238 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
ccmitchellusa committed Aug 16, 2011
1 parent a2837b2 commit 1b32b2d
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 103 deletions.
5 changes: 2 additions & 3 deletions html/entities.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
define(["dojo", "dojox"], function(dojo, dojox) {
define(["dojo/_base/lang"], function(lang) {
// dojox.html.entities.html [public] Array
// Entity characters for HTML, represented as an array of
// character code, entity name (minus & and ; wrapping.
// The function wrapper is to fix global leking with the build tools.
var dhe = lang.getObject("dojox.html.entities",true);

var _applyEncodingMap = function(str, map){
// summary:
Expand Down Expand Up @@ -77,8 +78,6 @@ define(["dojo", "dojox"], function(dojo, dojox) {
return str;
};

var dhe = dojo.getObject("html.entities",true,dojox);

dhe.html = [
["\u0026","amp"], ["\u0022","quot"],["\u003C","lt"], ["\u003E","gt"],
["\u00A0","nbsp"]
Expand Down
57 changes: 28 additions & 29 deletions html/ext-dojo/style.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
define([
"dojo/_base/kernel", "dojo/dom-style", "dojo/_base/lang", "dojo/_base/html", "dojo/_base/sniff",
"dojo/_base/window", "dojo/dom", "dojo/dom-construct"
], function(dojo, domStyle, lang, html, has, win, dom, domConstruct){
dojo.experimental("dojox.html.ext-dojo.style");
var st = lang.getObject("html.ext-dojo.style", true, dojox);

define(["dojo/_base/kernel", "dojo/dom-style", "dojo/_base/lang", "dojo/_base/html", "dojo/_base/sniff",
"dojo/_base/window", "dojo/dom", "dojo/dom-construct", "dojo/dom-style", "dojo/dom-attr"],
function(kernel, domStyle, lang, Html, has, win, DOM, DOMConstruct, DOMStyle, DOMAttr){
kernel.experimental("dojox.html.ext-dojo.style");
var st = lang.getObject("dojox.html.ext-dojo.style", true);
var HtmlX = lang.getObject("dojox.html");
// summary: Extensions to dojo.style adding the css3 "transform" and "transform-origin" properties on IE5.5+
// description:
// A Package to extend the dojo.style function
// Supported transformation functions:
// matrix, translate, translateX, translateY, scale, scaleX, scaleY, rotate, skewX, skewY, skew
lang.mixin(dojox.html["ext-dojo"].style, {
lang.mixin(HtmlX["ext-dojo"].style, {
supportsTransform: true,
_toPx: function(measure){
var ds = html.style, _conversion = this._conversion;
var ds = Html.style, _conversion = this._conversion;
if(typeof measure === "number"){
return measure + "px";
}else if(measure.toLowerCase().indexOf("px") != -1){
return measure;
}
// "native" conversion in px
!_conversion.parentNode && domConstruct.place(_conversion, win.body());
!_conversion.parentNode && DOMConstruct.place(_conversion, win.body());
ds(_conversion, "margin", measure);
return ds(_conversion, "margin");
},
init: function(){
var docStyle = win.doc.documentElement.style, extStyle = dojox.html["ext-dojo"].style,
sget = domStyle.get, sset = domStyle.set;
domStyle.get = function(/*DOMNode|String*/ node, /*String|Object*/ name){
var docStyle = win.doc.documentElement.style, extStyle = HtmlX["ext-dojo"].style,
sget = DOMStyle.get, sset = DOMStyle.set;
DOMStyle.get = function(/*DOMNode|String*/ node, /*String|Object*/ name){
var tr = (name == "transform"),
to = (name == "transformOrigin");
if(tr){
Expand All @@ -38,10 +37,10 @@ define([
return arguments.length == 2 ? sget(node, name) : sget(node);
}
};
domStyle.set = function(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){
DOMStyle.set = function(/*DOMNode|String*/ node, /*String|Object*/ name, /*String?*/ value){
var tr = (name == "transform"),
to = (name == "transformOrigin"),
n = dom.byId(node)
n = DOM.byId(node)
;
if(tr){
return extStyle.setTransform(n, value, true);
Expand All @@ -62,10 +61,10 @@ define([
}
if(this.tPropertyName){
this.setTransform = function(/*DomNode*/node, /*String*/ transform){
return domStyle.set(node, this.tPropertyName, transform);
return DOMStyle.set(node, this.tPropertyName, transform);
};
this.getTransform = function(/*DomNode*/node){
return domStyle.get(node, this.tPropertyName);
return DOMStyle.get(node, this.tPropertyName);
};
}else if(has("ie")){
this.setTransform = this._setTransformFilter;
Expand All @@ -84,7 +83,7 @@ define([
}else{
this.supportsTransform = false;
}
this._conversion = domConstruct.create("div", {
this._conversion = DOMConstruct.create("div", {
style: {
position: "absolute",
top: "-100px",
Expand All @@ -108,7 +107,7 @@ define([
.replace("right ", "100% ")
.replace(/\s+/, " "),
toAry = to.split(" "),
n = dom.byId(node),
n = DOM.byId(node),
t = this.getTransform(n),
validOrigin = true
;
Expand All @@ -121,22 +120,22 @@ define([
if(!validOrigin || !toAry.length || toAry.length > 2 ){
return transformOrigin;
}
html.attr(n, "dojo-transform-origin", toAry.join(" "));
Html.attr(n, "dojo-transform-origin", toAry.join(" "));
t && this.setTransform(node, t);
return transformOrigin;
},
_getTransformOriginFilter: function(/*DomNode*/ node){
return html.attr(node, "dojo-transform-origin") || "50% 50%";
return Html.attr(node, "dojo-transform-origin") || "50% 50%";
},
_setTransformFilter: function(/*DomNode*/ node, /*String*/ transform){
// Using the Matrix Filter to implement the transform property on IE
var t = transform.replace(/\s/g, ""),
n = dom.byId(node),
n = DOM.byId(node),
transforms = t.split(")"),
toRad = 1, toRad1 = 1,
mstr = "DXImageTransform.Microsoft.Matrix",
hasAttr = domAttr.hasAttr,
attr = html.attr,
hasAttr = DOMAttr.hasAttr,
attr = Html.attr,
// Math functions
PI = Math.PI, cos = Math.cos, sin = Math.sin, tan = Math.tan, max = Math.max, min = Math.min, abs = Math.abs,
degToRad = PI/180, gradToRad = PI/200,
Expand All @@ -153,7 +152,7 @@ define([
tx = 0, ty = 0,
props = [m11, m12, m21, m22, tx, ty],
hasMatrix = false,
ds = html.style,
ds = Html.style,
newPosition = ds(n, "position") == "absolute" ? "absolute" : "relative",
w = ds(n, "width") + ds(n, "paddingLeft") + ds(n, "paddingRight"),
h = ds(n, "height") + ds(n, "paddingTop") + ds(n, "paddingBottom"),
Expand Down Expand Up @@ -435,11 +434,11 @@ define([
},
_getTransformFilter: function(/*DomNode*/ node){
try{
var n = dom.byId(node),
var n = DOM.byId(node),
item = n.filters.item(0)
;
return "matrix(" + item.M11 + ", " + item.M12 + ", " + item.M21 + ", " +
item.M22 + ", " + (html.attr(node, "dojo-transform-tx") || "0") + ", " + (html.attr(node, "dojo-transform-ty") || "0") + ")";
item.M22 + ", " + (Html.attr(node, "dojo-transform-tx") || "0") + ", " + (Html.attr(node, "dojo-transform-ty") || "0") + ")";
}catch(e){
return "matrix(1, 0, 0, 1, 0, 0)";
}
Expand All @@ -452,6 +451,6 @@ define([
}
});

dojox.html["ext-dojo"].style.init();
return html.style;
HtmlX["ext-dojo"].style.init();
return Html.style;
});
39 changes: 20 additions & 19 deletions html/format.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array", "dojo/_base/window"], function(d, dhe) {
var dhf = d.getObject("html.format",true,dojox);
define(["dojo/_base/kernel", "./entities", "dojo/_base/array", "dojo/_base/window", "dojo/_base/sniff"],
function(lang, Entities, ArrayUtil, Window, has) {
var dhf = lang.getObject("dojox.html.format",true);

dhf.prettyPrint = function(html/*String*/, indentBy /*Integer?*/, maxLineLength /*Integer?*/, map/*Array?*/, /*boolean*/ xhtml){
// summary:
Expand Down Expand Up @@ -46,13 +47,13 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"

//Build the content outside of the editor so we can walk
//via DOM and build a 'pretty' output.
var contentDiv = d.doc.createElement("div");
var contentDiv = Window.doc.createElement("div");
contentDiv.innerHTML = html;

// Use the entity encode/decode functions, they cache on the map,
// so it won't multiprocess a map.
var encode = dhe.encode;
var decode = dhe.decode;
var encode = Entities.encode;
var decode = Entities.decode;

/** Define a bunch of formatters to format the output. **/
var isInlineFormat = function(tag){
Expand Down Expand Up @@ -144,10 +145,10 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
// anyway.
var _lines = txt.split("\n");
for(i = 0; i < _lines.length; i++){
_lines[i] = d.trim(_lines[i]);
_lines[i] = lang.trim(_lines[i]);
}
txt = _lines.join(" ");
txt = d.trim(txt);
txt = lang.trim(txt);
if(txt !== ""){
var lines = [];
if(maxLineLength && maxLineLength > 0){
Expand All @@ -168,9 +169,9 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
}
}
var line = txt.substring(0, i);
line = d.trim(line);
line = lang.trim(line);
// Shift up the text string to the next chunk.
txt = d.trim(txt.substring((i == txt.length)?txt.length:i + 1, txt.length));
txt = lang.trim(txt.substring((i == txt.length)?txt.length:i + 1, txt.length));
if(line){
_iTxt = "";
for(i = 0; i < indentDepth; i++){
Expand Down Expand Up @@ -233,7 +234,7 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
for (i = 0; i < scriptLines.length; i++){
var line = scriptLines[i];
var hasNewlines = (line.indexOf("\n") > -1);
line = d.trim(line);
line = lang.trim(line);
if(line){
var iLevel = indent;
// Not all blank, so we need to process.
Expand Down Expand Up @@ -273,7 +274,7 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
// Function to open a new tag for writing content.
var name = node.nodeName.toLowerCase();
// Generate the outer node content (tag with attrs)
var nText = d.trim(outerHTML(node));
var nText = lang.trim(outerHTML(node));
var tag = nText.substring(0, nText.indexOf(">") + 1);

// Also thanks to IE, we need to check for quotes around
Expand All @@ -287,11 +288,11 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
var sL = match.substring(0,6);
var style = match.substring(6, match.length);
var closure = style.charAt(0);
style = d.trim(style.substring(1,style.length -1));
style = lang.trim(style.substring(1,style.length -1));
style = style.split(";");
var trimmedStyles = [];
d.forEach(style, function(s){
s = d.trim(s);
ArrayUtil.forEach(style, function(s){
s = lang.trim(s);
if(s){
// Lower case the style name, leave the value alone. Mainly a fixup for IE.
s = s.substring(0, s.indexOf(":")).toLowerCase() + s.substring(s.indexOf(":"), s.length);
Expand All @@ -302,7 +303,7 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"

// Reassemble and return the styles in sorted order.
style = trimmedStyles.join("; ");
var ts = d.trim(style);
var ts = lang.trim(style);
if(!ts || ts === ";"){
// Just remove any style attrs that are empty.
return "";
Expand All @@ -315,7 +316,7 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
// Try and sort the attributes while we're at it.
var attrs = [];
tag = tag.replace(rgxp_attrsMatch, function(attr){
attrs.push(d.trim(attr));
attrs.push(lang.trim(attr));
return "";
});
attrs = attrs.sort();
Expand Down Expand Up @@ -415,8 +416,8 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
for(i = 0; i < children.length; i++){
var n = children[i];
if(n.nodeType === 1){
var tg = d.trim(n.tagName.toLowerCase());
if(d.isIE && n.parentNode != node){
var tg = lang.trim(n.tagName.toLowerCase());
if(has("ie") && n.parentNode != node){
// IE is broken. DOMs are supposed to be a tree.
// But in the case of malformed HTML, IE generates a graph
// meaning one node ends up with multiple references
Expand All @@ -437,7 +438,7 @@ define(["dojo/_base/kernel", "./entities", "dojo/_base/lang", "dojo/_base/array"
content.push(formatScript(n.innerHTML));
}else if(tg === "pre"){
var preTxt = n.innerHTML;
if(d.isMoz){
if(has("mozilla")){
//Mozilla screws this up, so fix it up.
preTxt = preTxt.replace("<br>", "\n");
preTxt = preTxt.replace("<pre>", "");
Expand Down
Loading

0 comments on commit 1b32b2d

Please sign in to comment.