Skip to content

Commit

Permalink
Nineties-nbsp
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalec committed May 12, 2014
1 parent 61df9d0 commit c96d363
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ Show an "Under Construction" animated icon, along with some custom text.
<nineties-under-construction>This page is under construction!</nineties-under-construction>
```

### 90s `&nbsp`
Places as many `&nbsp`s as you need.

#####Things that you can learn by reading the code
- Everything included in the 90s Welcome element
- How to create Shadow DOM
- How to read custom attributes

#####Usage
```html
<nineties-nbsp length="10"></nineties-nbsp>
```

### 90s Blink
Makes the contents inside this element blink

Expand Down
23 changes: 23 additions & 0 deletions nineties-nbsp/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>90s Nbsp</title>

<!-- Importing Custom Elements -->
<link rel="import" href="nineties-nbsp.html">

<style>
:unresolved {
display: none !important;
}
</style>
</head>
<body>
Here you have
<!-- Using Custom Elements -->
<nineties-nbsp length="10"></nineties-nbsp>
text indented by 10 <code>&amp;nbsp;</code>

</body>
</html>
18 changes: 18 additions & 0 deletions nineties-nbsp/nineties-nbsp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script>
var Nbsp = Object.create(HTMLImageElement.prototype);

Nbsp.createdCallback = function () {
// build &nbsp;.. string
var nbsps = "",
howMany = parseInt(this.getAttribute("length"), 10) || 1;
while(howMany--){
nbsps += "&nbsp;"
}

// Add it into element's shadowRoot
var shadowRoot = this.createShadowRoot();
shadowRoot.innerHTML = nbsps;
}

document.registerElement('nineties-nbsp', {prototype: Nbsp});
</script>

0 comments on commit c96d363

Please sign in to comment.