mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Merge branch 'directives' of github.com:angular/angular.js into directives
This commit is contained in:
commit
82cb18db28
8 changed files with 29 additions and 46 deletions
|
|
@ -1,34 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<script type="text/javascript" src="../src/angular-bootstrap.js"></script>
|
||||
<script type="text/javascript">
|
||||
function asyncValidate(value, callback){
|
||||
var x = value.length % 2 ? null: "even";
|
||||
//callback(x);
|
||||
_(callback).delay(1000, x);
|
||||
}
|
||||
</script>
|
||||
<link rel="StyleSheet" type="text/css" href="../css/angular.css"/>
|
||||
</head>
|
||||
<body onload="angular.compile(document).$init()">
|
||||
|
||||
<input type="checkbox" name="form.checked" ng-format="boolean" value="true" checked="checked" />
|
||||
<input ng-show="form.checked" name="form.required" ng-required/>
|
||||
<hr/>
|
||||
<input name="form.list" ng-format="list" ng-required/>
|
||||
<input name="form.list" ng-format="list" />
|
||||
<hr/>
|
||||
<input type="checkbox" name="form.boolean" ng-format="boolean" value="true" checked="checked" />
|
||||
<input type="checkbox" name="form.boolean" ng-format="boolean" value="true" />
|
||||
<hr/>
|
||||
<select name="select">
|
||||
<option>A</option>
|
||||
<option selected>B</option>
|
||||
</select>
|
||||
<pre>
|
||||
form={{form}}
|
||||
$invalidWidgets.length={{$invalidWidgets.length}}
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="style.css"></link>
|
||||
<!--<script type="text/javascript" src="../lib/jquery/jquery-1.4.2.js"></script>-->
|
||||
<script type="text/javascript" src="../lib/jquery/jquery-1.4.2.js"></script>
|
||||
<script type="text/javascript" src="../src/angular-bootstrap.js#autobind"></script>
|
||||
</head>
|
||||
<body ng-init="$window.$scope = this">
|
||||
|
|
@ -82,6 +82,16 @@
|
|||
</td>
|
||||
<td>button={{button}}</td>
|
||||
</tr>
|
||||
<tr><th colspan="3">Repeaters</th></tr>
|
||||
<tr>
|
||||
<td>ng-repeat</td>
|
||||
<td>
|
||||
<ul>
|
||||
<li ng-repeat="name in ['misko', 'adam']">{{name}}</li>
|
||||
</ul>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ JQLite.prototype = {
|
|||
});
|
||||
},
|
||||
|
||||
//TODO: remove
|
||||
trigger: function(type) {
|
||||
var evnt = document.createEvent('MouseEvent');
|
||||
evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
|
|
|
|||
|
|
@ -706,13 +706,13 @@ BinderTest.prototype.testItShouldSelectTheCorrectRadioBox = function() {
|
|||
var female = jqLite(c.node[0].childNodes[0]);
|
||||
var male = jqLite(c.node[0].childNodes[1]);
|
||||
|
||||
female.click();
|
||||
trigger(female, 'click');
|
||||
assertEquals("female", c.scope.sex);
|
||||
assertEquals(true, female[0].checked);
|
||||
assertEquals(false, male[0].checked);
|
||||
assertEquals("female", female.val());
|
||||
|
||||
male.click();
|
||||
trigger(male, 'click');
|
||||
assertEquals("male", c.scope.sex);
|
||||
assertEquals(false, female[0].checked);
|
||||
assertEquals(true, male[0].checked);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ describe('compiler', function(){
|
|||
var scope = compile('<span hello="misko" stop="true"><span hello="adam"/></span>');
|
||||
expect(log).toEqual("hello misko");
|
||||
});
|
||||
|
||||
|
||||
it('should allow creation of templates', function(){
|
||||
directives.duplicate = function(expr, element){
|
||||
element.replaceWith(document.createComment("marker"));
|
||||
|
|
@ -97,7 +97,7 @@ describe('compiler', function(){
|
|||
if (text == 'middle') {
|
||||
expect(textNode.text()).toEqual(text);
|
||||
parentNode.attr('hello', text);
|
||||
textNode.text('replaced');
|
||||
textNode[0].textContent = 'replaced';
|
||||
}
|
||||
});
|
||||
var scope = compile('before<span>middle</span>after');
|
||||
|
|
|
|||
|
|
@ -142,19 +142,19 @@ describe("directives", function(){
|
|||
it('should ng-show', function(){
|
||||
var scope = compile('<div ng-hide="hide"></div>');
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('');
|
||||
expect(isVisible(element)).toEqual(true);
|
||||
scope.$set('hide', true);
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('none');
|
||||
expect(isVisible(element)).toEqual(false);
|
||||
});
|
||||
|
||||
it('should ng-hide', function(){
|
||||
var scope = compile('<div ng-show="show"></div>');
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('none');
|
||||
expect(isVisible(element)).toEqual(false);
|
||||
scope.$set('show', true);
|
||||
scope.$eval();
|
||||
expect(element.css('display')).toEqual('');
|
||||
expect(isVisible(element)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should ng-controller', function(){
|
||||
|
|
|
|||
|
|
@ -27,6 +27,12 @@ extend(angular, {
|
|||
});
|
||||
|
||||
|
||||
function trigger(element, type) {
|
||||
var evnt = document.createEvent('MouseEvent');
|
||||
evnt.initMouseEvent(type, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
(element[0] || element).dispatchEvent(evnt);
|
||||
}
|
||||
|
||||
function sortedHtml(element) {
|
||||
var html = "";
|
||||
(function toString(node) {
|
||||
|
|
|
|||
|
|
@ -115,10 +115,10 @@ describe("input widget", function(){
|
|||
it('should type="checkbox"', function(){
|
||||
compile('<input type="checkbox" name="checkbox" checked ng-change="action = true"/>');
|
||||
expect(scope.checkbox).toEqual(true);
|
||||
element.click();
|
||||
trigger(element, 'click');
|
||||
expect(scope.checkbox).toEqual(false);
|
||||
expect(scope.action).toEqual(true);
|
||||
element.click();
|
||||
trigger(element, 'click');
|
||||
expect(scope.checkbox).toEqual(true);
|
||||
});
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ describe("input widget", function(){
|
|||
expect(b.checked).toEqual(true);
|
||||
expect(scope.clicked).not.toBeDefined();
|
||||
|
||||
jqLite(a).click();
|
||||
trigger(a, 'click');
|
||||
expect(scope.chose).toEqual('A');
|
||||
expect(scope.clicked).toEqual(1);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue