Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardarella committed May 15, 2015
0 parents commit f5abce7
Show file tree
Hide file tree
Showing 41 changed files with 626 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "bower_components",
"analytics": false
}
34 changes: 34 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.js]
indent_style = space
indent_size = 2

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2

[*.css]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 2

[*.{diff,md}]
trim_trailing_whitespace = false
9 changes: 9 additions & 0 deletions .ember-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
/**
Ember CLI sends analytics information by default. The data is completely
anonymous, but there are times when you might want to disable this behavior.

Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false
}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules
/bower_components

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
32 changes: 32 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"predef": [
"document",
"window",
"-Promise"
],
"browser": true,
"boss": true,
"curly": true,
"debug": false,
"devel": true,
"eqeqeq": true,
"evil": true,
"forin": false,
"immed": false,
"laxbreak": false,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": false,
"nomen": false,
"onevar": false,
"plusplus": false,
"regexp": false,
"undef": true,
"sub": true,
"strict": false,
"white": false,
"eqnull": true,
"esnext": true,
"unused": true
}
13 changes: 13 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bower_components/
tests/
tmp/

.bowerrc
.editorconfig
.ember-cli
.travis.yml
.npmignore
**/.gitkeep
bower.json
Brocfile.js
testem.json
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
language: node_js
node_js:
- "0.12"

sudo: false

cache:
directories:
- node_modules

before_install:
- "npm config set spin false"
- "npm install -g npm@^2"

install:
- npm install -g bower
- npm install
- bower install

script:
- npm test
21 changes: 21 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* jshint node: true */
/* global require, module */

var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

var app = new EmberAddon();

// Use `app.import` to add additional libraries to the generated
// output files.
//
// If you need to use different assets in different
// environments, specify an object as the first parameter. That
// object's keys should be the environment name and the values
// should be the asset to use in that environment.
//
// If the library that you are including contains AMD or ES6
// modules that you would like to import into your application
// please specify an object with the list of modules as keys
// along with the exports of each module as its value.

module.exports = app.toTree();
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2015

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Ember skeleton #

[![Build Status](https://secure.travis-ci.org/dockyard/ember-skeleton.svg?branch=master)](http://travis-ci.org/dockyard/ember-skeleton)

## About ##

Show fast-loading temporary images in place of an eventual slow-loading
image.

## Building yourself ##

```bash
npm install && bower install
ember build
```

The builds will be in the `dist/` directory.

## Installing ##

`ember install ember-skeleton`

## Looking for help? ##

If it is a bug [please open an issue on GitHub](https://github.com/dockyard/ember-skeleton/issues).

## Usage ##

Simply use the component in your templates:

```hbs
{{skeleton-img src="/path/to/large/image.png" tmpSrc="/path/to/small/placeholder.png"}}
```

The workflow is thus:

1. The `tmpSrc` image will be loaded first
2. Once complete the `src` image will attempt to load
3. If the `src` completes successfully it will be displayed
4. If the `src` does not complete successfully the `tmpSrc` will stay
5. If an optional `errorSrc` is provided that image will be displayed in
the even of `src` not completing successfully.

### Error Example ###

```hbs
{{skeleton-img src="/path/to/invalid/large/image.png" tmpSrc="/path/to/small/placeholder.png" errorSrc="/path/to/error/placeholder.png"}}
```

## Authors ##

* [Brian Cardarella](http://twitter.com/bcardarella)

[We are very thankful for the many contributors](https://github.com/dockyard/ember-skeleton/graphs/contributors)

## Versioning ##

This library follows [Semantic Versioning](http://semver.org)

## Want to help? ##

Please do! We are always looking to improve this library. Please see our
[Contribution Guidelines](https://github.com/dockyard/ember-skeleton/blob/master/CONTRIBUTING.md)
on how to properly submit issues and pull requests.

## Legal ##

[DockYard](http://dockyard.com), Inc © 2015

[@dockyard](http://twitter.com/dockyard)

[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)
Empty file added addon/.gitkeep
Empty file.
59 changes: 59 additions & 0 deletions addon/components/skeleton-img.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import Ember from 'ember';

const {
set,
get,
on
} = Ember;

export default Ember.Component.extend({
setupSrcs: on('init', function() {
set(this, 'actualSrc', get(this, 'src'));
set(this, 'src', get(this, 'tmpSrc'));
set(this, 'loadState', 'loading');
}),
setupImgBindings: on('init', function() {
set(this, 'imgBindings', {
loadTmp: this.loadTmp.bind(this),
loadActual: this.loadActual.bind(this),
errorActual: this.errorActual.bind(this)
});
}),
classNames: ['skeleton-img'],
classNameBindings: ['loadState'],
tagName: 'img',
attributeBindings: [
'src'
],
didInsertElement() {
let target = this.element;
let loadTmp = get(this, 'imgBindings.loadTmp');
target.addEventListener('load', loadTmp);
},
loadTmp(event) {
let target = event.target;
let loadTmp = get(this, 'imgBindings.loadTmp');
let loadActual = get(this, 'imgBindings.loadActual');
let errorActual = get(this, 'imgBindings.errorActual');
target.removeEventListener('load', loadTmp);
target.addEventListener('load', loadActual);
target.addEventListener('error', errorActual);
set(this, 'src', get(this, 'actualSrc'));
},
loadActual(event) {
set(this, 'loadState', 'loaded');
this.removeEvents(event.target);
},
errorActual(event) {
let errorSrc = get(this, 'errorSrc') || get(this, 'tmpSrc');
this.removeEvents(event.target);
set(this, 'src', errorSrc);
set(this, 'loadState', 'load-error');
},
removeEvents(target) {
let loadActual = get(this, 'imgBindings.loadActual');
let errorActual = get(this, 'imgBindings.errorActual');
target.removeEventListener('load', loadActual);
target.removeEventListener('error', errorActual);
}
});
Empty file added app/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions app/components/skeleton-img.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SkeletonImg from 'ember-skeleton/components/skeleton-img';

export default SkeletonImg.extend();
16 changes: 16 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ember-skeleton",
"dependencies": {
"ember": "1.11.1",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-data": "1.0.0-beta.16.1",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4",
"ember-qunit": "0.3.1",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.15",
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1"
}
}
5 changes: 5 additions & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = function(/* environment, appConfig */) {
return { };
};
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* jshint node: true */
'use strict';

module.exports = {
name: 'ember-skeleton'
};
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "ember-skeleton",
"version": "0.0.0",
"description": "The default blueprint for ember-cli addons.",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"start": "ember server",
"build": "ember build",
"test": "ember try:testall"
},
"repository": "",
"engines": {
"node": ">= 0.10.0"
},
"author": "",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"ember-cli": "0.2.3",
"ember-cli-app-version": "0.3.3",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "0.0.8",
"ember-cli-htmlbars": "0.7.4",
"ember-cli-ic-ajax": "0.1.1",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-qunit": "0.3.10",
"ember-cli-uglify": "1.0.1",
"ember-data": "1.0.0-beta.16.1",
"ember-export-application-global": "^1.0.2",
"ember-disable-prototype-extensions": "^1.0.0",
"ember-try": "0.0.4"
},
"keywords": [
"ember-addon"
],
"dependencies": {
"ember-cli-babel": "^5.0.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
}
}
11 changes: 11 additions & 0 deletions testem.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"framework": "qunit",
"test_page": "tests/index.html?hidepassed",
"launch_in_ci": [
"PhantomJS"
],
"launch_in_dev": [
"PhantomJS",
"Chrome"
]
}
Loading

0 comments on commit f5abce7

Please sign in to comment.