Skip to content

Commit bfbcca9

Browse files
committed
+++ gulp files
1 parent a07d5e7 commit bfbcca9

File tree

6 files changed

+85
-85
lines changed

6 files changed

+85
-85
lines changed

dist/bootstrap-decorator.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bootstrap-decorator.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/schema-form.js

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -51,81 +51,6 @@ angular.module('schemaForm').provider('sfPath',
5151
};
5252
}]);
5353

54-
/**
55-
* @ngdoc service
56-
* @name sfSelect
57-
* @kind function
58-
*
59-
*/
60-
angular.module('schemaForm').factory('sfSelect', ['sfPath', function(sfPath) {
61-
var numRe = /^\d+$/;
62-
63-
/**
64-
* @description
65-
* Utility method to access deep properties without
66-
* throwing errors when things are not defined.
67-
* Can also set a value in a deep structure, creating objects when missing
68-
* ex.
69-
* var foo = Select('address.contact.name',obj)
70-
* Select('address.contact.name',obj,'Leeroy')
71-
*
72-
* @param {string} projection A dot path to the property you want to get/set
73-
* @param {object} obj (optional) The object to project on, defaults to 'this'
74-
* @param {Any} valueToSet (opional) The value to set, if parts of the path of
75-
* the projection is missing empty objects will be created.
76-
* @returns {Any|undefined} returns the value at the end of the projection path
77-
* or undefined if there is none.
78-
*/
79-
return function(projection, obj, valueToSet) {
80-
if (!obj) {
81-
obj = this;
82-
}
83-
//Support [] array syntax
84-
var parts = typeof projection === 'string' ? sfPath.parse(projection) : projection;
85-
86-
if (typeof valueToSet !== 'undefined' && parts.length === 1) {
87-
//special case, just setting one variable
88-
obj[parts[0]] = valueToSet;
89-
return obj;
90-
}
91-
92-
if (typeof valueToSet !== 'undefined' &&
93-
typeof obj[parts[0]] === 'undefined') {
94-
// We need to look ahead to check if array is appropriate
95-
obj[parts[0]] = parts.length > 2 && numRe.test(parts[1]) ? [] : {};
96-
}
97-
98-
var value = obj[parts[0]];
99-
for (var i = 1; i < parts.length; i++) {
100-
// Special case: We allow JSON Form syntax for arrays using empty brackets
101-
// These will of course not work here so we exit if they are found.
102-
if (parts[i] === '') {
103-
return undefined;
104-
}
105-
if (typeof valueToSet !== 'undefined') {
106-
if (i === parts.length - 1) {
107-
//last step. Let's set the value
108-
value[parts[i]] = valueToSet;
109-
return valueToSet;
110-
} else {
111-
// Make sure to create new objects on the way if they are not there.
112-
// We need to look ahead to check if array is appropriate
113-
var tmp = value[parts[i]];
114-
if (typeof tmp === 'undefined' || tmp === null) {
115-
tmp = numRe.test(parts[i + 1]) ? [] : {};
116-
value[parts[i]] = tmp;
117-
}
118-
value = tmp;
119-
}
120-
} else if (value) {
121-
//Just get nex value.
122-
value = value[parts[i]];
123-
}
124-
}
125-
return value;
126-
};
127-
}]);
128-
12954
angular.module('schemaForm').provider('schemaFormDecorators',
13055
['$compileProvider', 'sfPathProvider', function($compileProvider, sfPathProvider) {
13156
var defaultDecorator = '';
@@ -1128,6 +1053,81 @@ angular.module('schemaForm').provider('schemaForm',
11281053

11291054
}]);
11301055

1056+
/**
1057+
* @ngdoc service
1058+
* @name sfSelect
1059+
* @kind function
1060+
*
1061+
*/
1062+
angular.module('schemaForm').factory('sfSelect', ['sfPath', function(sfPath) {
1063+
var numRe = /^\d+$/;
1064+
1065+
/**
1066+
* @description
1067+
* Utility method to access deep properties without
1068+
* throwing errors when things are not defined.
1069+
* Can also set a value in a deep structure, creating objects when missing
1070+
* ex.
1071+
* var foo = Select('address.contact.name',obj)
1072+
* Select('address.contact.name',obj,'Leeroy')
1073+
*
1074+
* @param {string} projection A dot path to the property you want to get/set
1075+
* @param {object} obj (optional) The object to project on, defaults to 'this'
1076+
* @param {Any} valueToSet (opional) The value to set, if parts of the path of
1077+
* the projection is missing empty objects will be created.
1078+
* @returns {Any|undefined} returns the value at the end of the projection path
1079+
* or undefined if there is none.
1080+
*/
1081+
return function(projection, obj, valueToSet) {
1082+
if (!obj) {
1083+
obj = this;
1084+
}
1085+
//Support [] array syntax
1086+
var parts = typeof projection === 'string' ? sfPath.parse(projection) : projection;
1087+
1088+
if (typeof valueToSet !== 'undefined' && parts.length === 1) {
1089+
//special case, just setting one variable
1090+
obj[parts[0]] = valueToSet;
1091+
return obj;
1092+
}
1093+
1094+
if (typeof valueToSet !== 'undefined' &&
1095+
typeof obj[parts[0]] === 'undefined') {
1096+
// We need to look ahead to check if array is appropriate
1097+
obj[parts[0]] = parts.length > 2 && numRe.test(parts[1]) ? [] : {};
1098+
}
1099+
1100+
var value = obj[parts[0]];
1101+
for (var i = 1; i < parts.length; i++) {
1102+
// Special case: We allow JSON Form syntax for arrays using empty brackets
1103+
// These will of course not work here so we exit if they are found.
1104+
if (parts[i] === '') {
1105+
return undefined;
1106+
}
1107+
if (typeof valueToSet !== 'undefined') {
1108+
if (i === parts.length - 1) {
1109+
//last step. Let's set the value
1110+
value[parts[i]] = valueToSet;
1111+
return valueToSet;
1112+
} else {
1113+
// Make sure to create new objects on the way if they are not there.
1114+
// We need to look ahead to check if array is appropriate
1115+
var tmp = value[parts[i]];
1116+
if (typeof tmp === 'undefined' || tmp === null) {
1117+
tmp = numRe.test(parts[i + 1]) ? [] : {};
1118+
value[parts[i]] = tmp;
1119+
}
1120+
value = tmp;
1121+
}
1122+
} else if (value) {
1123+
//Just get nex value.
1124+
value = value[parts[i]];
1125+
}
1126+
}
1127+
return value;
1128+
};
1129+
}]);
1130+
11311131
/* Common code for validating a value against its form and schema definition */
11321132
/* global tv4 */
11331133
angular.module('schemaForm').factory('sfValidator', [function() {

0 commit comments

Comments
 (0)