-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from frankiefu/master
call shadowRootCreated in the right scope and add g-ratings component
- Loading branch information
Showing
6 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
.star { | ||
display: inline-block; | ||
width: 12px; | ||
height: 21px; | ||
background: url('../images/star_blank.svg') center no-repeat; | ||
cursor: default; | ||
} | ||
|
||
.star.full { | ||
background: url('../images/star_full.svg') center no-repeat; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- | ||
/* | ||
* Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
--> | ||
<element name="g-ratings" attributes="value" handlers="click: clickHandler"> | ||
<link rel="components" href="g-component.html"> | ||
<link rel="stylesheet" href="css/g-ratings.css" /> | ||
<template> | ||
<span class="star"></span> | ||
<span class="star"></span> | ||
<span class="star"></span> | ||
<span class="star"></span> | ||
<span class="star"></span> | ||
</template> | ||
<script> | ||
this.component({ | ||
shadowRootCreated: function(inRoot) { | ||
this.stars = ShadowDOM.localQueryAll(inRoot, ".star"); | ||
}, | ||
created: function() { | ||
this.valueAttributeChanged(); | ||
}, | ||
prototype: { | ||
valueAttributeChanged: function() { | ||
for (var i=0, s; s=this.stars[i]; i++) { | ||
s.classList.enable('full', i < Number(this.value)); | ||
} | ||
}, | ||
clickHandler: function(e) { | ||
var s = e.target; | ||
var i = this.stars.indexOf(s); | ||
this.value = i + (s.classList.contains('full') ? 0 : 1); | ||
} | ||
} | ||
}); | ||
</script> | ||
</element> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
Copyright 2012 The Toolkitchen Authors. All rights reserved. | ||
Use of this source code is governed by a BSD-style | ||
license that can be found in the LICENSE file. | ||
--> | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Icon</title> | ||
<script src="../../polyfills/Components/components-polyfill.js" shimShadow></script> | ||
<link rel="components" href="../../toolkit/src/g-ratings.html"> | ||
</head> | ||
<body> | ||
<g-ratings value="3"></g-ratings> | ||
</body> | ||
</html> |