Skip to content

Commit

Permalink
GPII-113: jslinted everything, fixed a code weirdness where I checked…
Browse files Browse the repository at this point in the history
… for null in conditional expanders
  • Loading branch information
Kasper Markus committed Jun 13, 2013
1 parent 1a4d3de commit 4413fc7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
32 changes: 17 additions & 15 deletions src/webapp/framework/core/js/ModelTransformations.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var fluid = fluid || fluid_1_5;
if (inputPath !== undefined) {
paths.push(fluid.model.composePaths(expander.inputPrefix, inputPath));
}
}
};

fluid.model.transform.accumulateStandardInputPath = function (input, expandSpec, expander, paths) {
fluid.model.transform.getValue(undefined, expandSpec[input], expander);
Expand All @@ -100,7 +100,7 @@ var fluid = fluid || fluid_1_5;
fluid.each(inputVariables, function (v, k) {
fluid.model.transform.accumulateStandardInputPath(k, expandSpec, expander, paths);
});
}
};

fluid.model.transform.getValue = function (inputPath, value, expander) {
var togo;
Expand All @@ -124,7 +124,7 @@ var fluid = fluid || fluid_1_5;
var outputPath = fluid.model.composePaths(expander.outputPrefix, userOutputPath);
// TODO: custom resolver config here to create non-hash output model structure
if (toset !== undefined) {
expander.applier.requestChange(outputPath, toset, merge? "MERGE": undefined);
expander.applier.requestChange(outputPath, toset, merge ? "MERGE" : undefined);
}
return userOutputPath ? fluid.model.transform.NONDEFAULT_OUTPUT_PATH_RETURN : toset;
};
Expand All @@ -150,9 +150,9 @@ var fluid = fluid || fluid_1_5;
}
}
else {
if (typeof(expected) !== typeof(actual)) {
if (typeof expected !== typeof actual) {
++stats.mismatchCount;
stats.messages.push("Type mismatch at path " + stats.path + ": expected " + typeof(expected) + " actual " + typeof(actual));
stats.messages.push("Type mismatch at path " + stats.path + ": expected " + typeof expected + " actual " + typeof actual);
} else {
fluid.each(expected, function (value, key) {
stats.pathOps.push(key);
Expand Down Expand Up @@ -236,7 +236,7 @@ var fluid = fluid || fluid_1_5;
}
var expanderFn = fluid.getGlobalValue(typeName);
var expdef = fluid.defaults(typeName);
if (typeof(expanderFn) !== "function") {
if (typeof expanderFn !== "function") {
fluid.fail("Transformation record specifies transformation function with name " +
expandSpec.type + " which is not a function - ", expanderFn);
}
Expand Down Expand Up @@ -294,7 +294,7 @@ var fluid = fluid || fluid_1_5;

// unsupported, NON-API function
fluid.model.transform.hasWildcard = function (path) {
return typeof(path) === "string" && path.indexOf("*") !== -1;
return typeof path === "string" && path.indexOf("*") !== -1;
};

// unsupported, NON-API function
Expand Down Expand Up @@ -360,7 +360,7 @@ var fluid = fluid || fluid_1_5;

// unsupported, NON-API function
fluid.model.transform.expandValue = function (rule, expander) {
if (typeof(rule) === "string") {
if (typeof rule === "string") {
rule = fluid.model.transform.pathToRule(rule);
}
// special dispensation to allow "value" at top level
Expand Down Expand Up @@ -483,7 +483,7 @@ var fluid = fluid || fluid_1_5;

fluid.model.compareByPathLength = function (changea, changeb) {
var pdiff = changea.path.length - changeb.path.length;
return pdiff === 0? changea.sequence - changeb.sequence : pdiff;
return pdiff === 0 ? changea.sequence - changeb.sequence : pdiff;
};

/** Fires an accumulated set of change requests in increasing order of target pathlength
Expand Down Expand Up @@ -562,18 +562,20 @@ var fluid = fluid || fluid_1_5;

/** Utility function to produce a standard options transformation record for a single set of rules **/
fluid.transformOne = function (rules) {
return {transformOptions: {
transformer: "fluid.model.transformWithRules",
config: rules
return {
transformOptions: {
transformer: "fluid.model.transformWithRules",
config: rules
}
};
};

/** Utility function to produce a standard options transformation record for multiple rules to be applied in sequence **/
fluid.transformMany = function (rules) {
return {transformOptions: {
transformer: "fluid.model.transform.sequence",
config: rules
return {
transformOptions: {
transformer: "fluid.model.transform.sequence",
config: rules
}
};
};
Expand Down
10 changes: 6 additions & 4 deletions src/webapp/framework/core/js/ModelTransformationsExpanders.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ var fluid = fluid || fluid_1_5;
return undefined;
}

return (inputs.condition) ?
(inputs["true"] === null ? undefined : inputs["true"]) :
(inputs["false"] === null ? undefined : inputs["false"]);
return inputs[inputs.condition];
};


Expand Down Expand Up @@ -400,7 +398,11 @@ var fluid = fluid || fluid_1_5;
*/
fluid.model.transform.applyPaths = function (operation, pathOp, paths) {
for (var i = 0; i < paths.length; ++i) {
operation === "push" ? pathOp.push(paths[i]) : pathOp.pop();
if (operation === "push") {
pathOp.push(paths[i]);
} else {
pathOp.pop();
}
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<script type="text/javascript" src="../../../../framework/core/js/FluidView.js"></script>
<script type="text/javascript" src="../../../../framework/core/js/DataBinding.js"></script>
<script type="text/javascript" src="../../../../framework/core/js/ModelTransformations.js"></script>
<script type="text/javascript" src="../../../../framework/core/js/ModelTransformationUtils.js"></script>
<script type="text/javascript" src="../../../../framework/core/js/ModelTransformationsExpanders.js"></script>
<script type="text/javascript" src="../../../../framework/core/js/FluidIoC.js"></script>
<script type="text/javascript" src="../../../../framework/enhancement/js/ProgressiveEnhancement.js"></script>

Expand Down

0 comments on commit 4413fc7

Please sign in to comment.