Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a80a618

Browse files
committed
injection is now working
1 parent 35ca4fc commit a80a618

24 files changed

+262
-245
lines changed

lib/jsl/jsl.default.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
-missing_break # missing break statement
2424
+missing_break_for_last_case # missing break statement for last case in switch
2525
+comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
26-
+inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
26+
-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
2727
+useless_void # use of the void type may be unnecessary (void is always undefined)
2828
+multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
2929
+use_of_label # use of label
@@ -41,7 +41,7 @@
4141
+useless_assign # useless assignment
4242
+ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
4343
+ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
44-
+missing_default_case # missing default case in switch statement
44+
-missing_default_case # missing default case in switch statement
4545
+duplicate_case_in_switch # duplicate case in switch statements
4646
+default_not_at_end # the default case is not at the end of the switch statement
4747
+legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax

scenario/widgets.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<link rel="stylesheet" type="text/css" href="style.css"></link>
55
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
66
</head>
7-
<body ng-init="$window.$scope = $root">
8-
<table ng-repeat="i in [0, 1]">
7+
<body ng-init="$window.$scope = this">
8+
<table>
99
<tr>
1010
<th>Description</th>
1111
<th>Test</th>
@@ -14,7 +14,7 @@
1414
<tr><th colspan="3">Input text field</th></tr>
1515
<tr>
1616
<td>basic</td>
17-
<td><input type="text" name="text.basic" /></td>
17+
<td><input type="text" name="text.basic" ng-required /></td>
1818
<td>text.basic={{text.basic}}</td>
1919
</tr>
2020
<tr>
@@ -70,7 +70,7 @@
7070
</tr>
7171
<tr><th colspan="3">Buttons</th></tr>
7272
<tr>
73-
<td>ng-action</td>
73+
<td>ng-change<br/>ng-click</td>
7474
<td>
7575
<form ng-init="button.count = 0">
7676
<input type="button" value="button" ng-change="button.count = button.count + 1"/> <br/>

src/Angular.js

Lines changed: 13 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,3 @@
1-
2-
//////////////////////////////
3-
//UrlWatcher
4-
//////////////////////////////
5-
6-
function UrlWatcher(location) {
7-
this.location = location;
8-
this.delay = 25;
9-
this.setTimeout = function(fn, delay) {
10-
window.setTimeout(fn, delay);
11-
};
12-
this.expectedUrl = location.href;
13-
this.listeners = [];
14-
}
15-
16-
UrlWatcher.prototype = {
17-
watch: function(fn){
18-
this.listeners.push(fn);
19-
},
20-
21-
start: function() {
22-
var self = this;
23-
(function pull () {
24-
if (self.expectedUrl !== self.location.href) {
25-
foreach(self.listeners, function(listener){
26-
listener(self.location.href);
27-
});
28-
self.expectedUrl = self.location.href;
29-
}
30-
self.setTimeout(pull, self.delay);
31-
})();
32-
},
33-
34-
set: function(url) {
35-
var existingURL = this.location.href;
36-
if (!existingURL.match(/#/))
37-
existingURL += '#';
38-
if (existingURL != url)
39-
this.location.href = url;
40-
this.existingURL = url;
41-
},
42-
43-
get: function() {
44-
return this.location.href;
45-
}
46-
};
47-
481
////////////////////////////////////
492

503
if (typeof document.getAttribute == 'undefined')
@@ -53,9 +6,9 @@ if (typeof document.getAttribute == 'undefined')
536
if (!window['console']) window['console']={'log':noop, 'error':noop};
547

558
var consoleNode,
56-
PRIORITY_FIRST = -99999;
57-
PRIORITY_WATCH = -1000;
58-
PRIORITY_LAST = 99999;
9+
PRIORITY_FIRST = -99999,
10+
PRIORITY_WATCH = -1000,
11+
PRIORITY_LAST = 99999,
5912
NOOP = 'noop',
6013
NG_ERROR = 'ng-error',
6114
NG_EXCEPTION = 'ng-exception',
@@ -74,16 +27,14 @@ var consoleNode,
7427
angularFilter = extensionMap(angular, 'filter'),
7528
angularFormatter = extensionMap(angular, 'formatter'),
7629
angularService = extensionMap(angular, 'service'),
77-
angularCallbacks = extensionMap(angular, 'callbacks'),
78-
urlWatcher = new UrlWatcher(window.location);
30+
angularCallbacks = extensionMap(angular, 'callbacks');
7931

8032
function angularAlert(){
8133
log(arguments); window.alert.apply(window, arguments);
82-
};
34+
}
8335

8436
extend(angular, {
8537
'compile': compile,
86-
'startUrlWatch': bind(urlWatcher, urlWatcher.start),
8738
'copy': copy,
8839
'extend': extend,
8940
'foreach': foreach,
@@ -166,15 +117,15 @@ function isFunction(value){ return typeof value == 'function';}
166117
function isTextNode(node) { return nodeName(node) == '#text'; }
167118
function lowercase(value){ return isString(value) ? value.toLowerCase() : value; }
168119
function uppercase(value){ return isString(value) ? value.toUpperCase() : value; }
169-
function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; };
120+
function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; }
170121
function nodeName(element) { return (element[0] || element || {}).nodeName; }
171122
function map(obj, iterator, context) {
172123
var results = [];
173124
foreach(obj, function(value, index, list) {
174125
results.push(iterator.call(context, value, index, list));
175126
});
176127
return results;
177-
};
128+
}
178129
function size(obj) {
179130
var size = 0;
180131
if (obj) {
@@ -289,7 +240,7 @@ function copy(source, destination){
289240
});
290241
return destination;
291242
}
292-
};
243+
}
293244

294245
function setHtml(node, html) {
295246
if (isLeafNode(node)) {
@@ -367,22 +318,10 @@ function merge(src, dst) {
367318
}
368319
}
369320

370-
function compile(element, config) {
321+
function compile(element, parentScope, overrides) {
371322
var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget);
372-
$element = jqLite(element),
373-
rootScope = createScope({
374-
$element: $element,
375-
$config: extend({
376-
'onUpdateView': noop,
377-
'server': "",
378-
'location': {
379-
'get':bind(urlWatcher, urlWatcher.get),
380-
'set':bind(urlWatcher, urlWatcher.set),
381-
'watch':bind(urlWatcher, urlWatcher.watch)
382-
}
383-
}, config || {})
384-
}, serviceAdapter(angularService));
385-
return compiler.compile($element)($element, rootScope);
323+
$element = jqLite(element);
324+
return compiler.compile($element)($element, parentScope, overrides);
386325
}
387326
/////////////////////////////////////////////////
388327

@@ -404,11 +343,10 @@ function toKeyValue(obj) {
404343
parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
405344
});
406345
return parts.length ? parts.join('&') : '';
407-
};
346+
}
408347

409348
function angularInit(config){
410349
if (config.autobind) {
411-
compile(window.document, config).$init();
350+
compile(window.document, null, {'$config':config}).$init();
412351
}
413352
}
414-

src/Browser.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
//////////////////////////////
3+
// Browser
4+
//////////////////////////////
5+
6+
function Browser(location) {
7+
this.location = location;
8+
this.delay = 25;
9+
this.setTimeout = function(fn, delay) {
10+
window.setTimeout(fn, delay);
11+
};
12+
this.expectedUrl = location.href;
13+
this.listeners = [];
14+
}
15+
16+
Browser.prototype = {
17+
watchUrl: function(fn){
18+
this.listeners.push(fn);
19+
},
20+
21+
startUrlWatcher: function() {
22+
var self = this;
23+
(function pull () {
24+
if (self.expectedUrl !== self.location.href) {
25+
foreach(self.listeners, function(listener){
26+
listener(self.location.href);
27+
});
28+
self.expectedUrl = self.location.href;
29+
}
30+
self.setTimeout(pull, self.delay);
31+
})();
32+
},
33+
34+
setUrl: function(url) {
35+
var existingURL = this.location.href;
36+
if (!existingURL.match(/#/))
37+
existingURL += '#';
38+
if (existingURL != url)
39+
this.location.href = url;
40+
this.existingURL = url;
41+
},
42+
43+
getUrl: function() {
44+
return this.location.href;
45+
}
46+
};

src/Compiler.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Template provides directions an how to bind to a given element.
2+
= * Template provides directions an how to bind to a given element.
33
* It contains a list of init functions which need to be called to
44
* bind to a new instance of elements. It also provides a list
55
* of child paths which contain child templates
@@ -43,7 +43,7 @@ Template.prototype = {
4343
},
4444

4545
empty: function() {
46-
return this.inits.length == 0 && this.paths.length == 0;
46+
return this.inits.length === 0 && this.paths.length === 0;
4747
}
4848
};
4949

@@ -63,8 +63,9 @@ Compiler.prototype = {
6363
var template = this.templatize(rawElement) || new Template();
6464
return function(element, parentScope){
6565
element = jqLite(element);
66-
parentScope = parentScope || {};
67-
var scope = createScope(parentScope);
66+
var scope = parentScope && parentScope.$eval ?
67+
parentScope :
68+
createScope(parentScope || {}, angularService);
6869
return extend(scope, {
6970
$element:element,
7071
$init: function() {
@@ -161,7 +162,7 @@ function eachNode(element, fn){
161162
function eachAttribute(element, fn){
162163
var i, attrs = element[0].attributes || [], size = attrs.length, chld, attr, attrValue = {};
163164
for (i = 0; i < size; i++) {
164-
var attr = attrs[i];
165+
attr = attrs[i];
165166
attrValue[attr.name] = attr.value;
166167
}
167168
foreach(attrValue, fn);

src/Formatters.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function formater(format, parse) {return {'format':format, 'parse':parse || format};}
2-
function toString(obj) {return isDefined(obj) ? "" + obj : obj;};
2+
function toString(obj) {return isDefined(obj) ? "" + obj : obj;}
33
extend(angularFormatter, {
44
'noop':formater(identity, identity),
55
'boolean':formater(toString, toBoolean),

src/JSON.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ function toJson(obj, pretty){
44
var buf = [];
55
toJsonArray(buf, obj, pretty ? "\n " : null, []);
66
return buf.join('');
7-
};
7+
}
88

99
function toPrettyJson(obj) {
1010
return toJson(obj, true);
11-
};
11+
}
1212

1313
function fromJson(json) {
1414
if (!json) return json;
@@ -21,7 +21,7 @@ function fromJson(json) {
2121
error("fromJson error: ", json, e);
2222
throw e;
2323
}
24-
};
24+
}
2525

2626
angular['toJson'] = toJson;
2727
angular['fromJson'] = fromJson;
@@ -102,4 +102,4 @@ function toJsonArray(buf, obj, pretty, stack){
102102
if (typeof obj == "object") {
103103
stack.pop();
104104
}
105-
};
105+
}

src/Parser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Lexer(text, parsStrings){
44
this.dateParseLength = parsStrings ? 20 : -1;
55
this.tokens = [];
66
this.index = 0;
7-
};
7+
}
88

99
Lexer.OPERATORS = {
1010
'null':function(self){return null;},
@@ -244,7 +244,7 @@ function Parser(text, parseStrings){
244244
this.text = text;
245245
this.tokens = new Lexer(text, parseStrings).parse();
246246
this.index = 0;
247-
};
247+
}
248248

249249
Parser.ZERO = function(){
250250
return 0;

src/Resource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Route.prototype = {
1515
var self = this;
1616
var url = this.template;
1717
params = params || {};
18-
foreach(this.urlParams, function(value, urlParam){
18+
foreach(this.urlParams, function(_, urlParam){
1919
var value = params[urlParam] || self.defaults[urlParam] || "";
2020
url = url.replace(new RegExp(":" + urlParam + "(\\W)"), value + "$1");
2121
});
@@ -57,7 +57,7 @@ ResourceFactory.prototype = {
5757

5858
function Resource(value){
5959
copy(value || {}, this);
60-
};
60+
}
6161

6262
foreach(actions, function(action, name){
6363
var isGet = action.method == 'GET';
@@ -105,7 +105,7 @@ ResourceFactory.prototype = {
105105
var params = {};
106106
var callback = noop;
107107
switch(arguments.length) {
108-
case 2: params = a1, callback = a2;
108+
case 2: params = a1; callback = a2;
109109
case 1: if (typeof a1 == 'function') callback = a1; else params = a1;
110110
case 0: break;
111111
default:

0 commit comments

Comments
 (0)