Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nineties-nbsp #1

Merged
merged 1 commit into from
May 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Nineties-nbsp
  • Loading branch information
tomalec committed May 12, 2014
commit c96d36393cbf326fadb000426c2d3d059846b273
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>