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

Fastbooting #430

Merged
merged 7 commits into from
Jul 12, 2016
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Contributions and pull requests are always welcome. Contributors may often be fo
- `paper-sidenav-toggle` is now tagless. It is essentially a functional component that yields an action to its block
- `paper-sidenav` now can use a `position` param that positions the sidenav `left` (default) or `right`
- `paper-backdrop` action `onTap` changed to `onClick`
- [#408](https://github.com/miguelcobain/ember-paper/pull/408) added paper-form component. `paper-input`'s `onInvalid` action renamed to `onValidityChange`
- [#408](https://github.com/miguelcobain/ember-paper/pull/408) added paper-form component. `paper-input`'s `onInvalid` action renamed to `onValidityChange`
- [#430](https://github.com/miguelcobain/ember-paper/pull/430) added fastboot support. Removed errors associated with `document` when running `ember fastboot`

#### 1.0.0-alpha.1

Expand Down
6 changes: 5 additions & 1 deletion addon/components/paper-sidenav-inner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default Component.extend(TransitionMixin, {
transitionTriggers: ['isLockedOpen:md-locked-open', 'closed:md-closed'],

constants: inject.service(),
fastboot: inject.service(),
paperSidenav: inject.service(),

name: 'default',
Expand All @@ -26,14 +27,17 @@ export default Component.extend(TransitionMixin, {
init() {
// need to updateLockedOpen() first because otherwise the transition classes
// would be applied due to transition mixin's `init`
this.updateLockedOpen();
if (!Ember.get(this, 'fastboot.isFastBoot')) {
this.updateLockedOpen();
}
this._super(...arguments);
this.get('paperSidenav').register(this.get('name'), this);
},

didInsertElement() {
this._super(...arguments);
$(window).on(`resize.${this.elementId}`, run.bind(this, 'updateLockedOpen'));
this.updateLockedOpen();
},

willDestroyElement() {
Expand Down
20 changes: 16 additions & 4 deletions app/services/sniffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@ let toInt = function(str) {
};

export default Ember.Service.extend({
fastboot: Ember.inject.service(),
vendorPrefix: '',
transitions: false,
animations: false,
document,
window,
_document: null,
_window: null,

android: Ember.computed('', function() {
return toInt((/android (\d+)/.exec(lowercase((this.get('window').navigator || {}).userAgent)) || [])[1]);
return toInt((/android (\d+)/.exec(lowercase((this.get('_window').navigator || {}).userAgent)) || [])[1]);
}),

init() {
this._super(...arguments);
if (Ember.get(this, 'fastboot.isFastBoot')) {
return;
}

let _document = document;
let _window = window;

this.setProperties({
_document,
_window
});

let bodyStyle = this.get('document').body && this.get('document').body.style;
let bodyStyle = _document.body && _document.body.style;
let vendorPrefix;
let vendorRegex = /^(Moz|webkit|ms)(?=[A-Z])/;

Expand Down
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ module.exports = {
if (!process.env.EMBER_CLI_FASTBOOT) {
app.import(app.bowerDirectory + '/hammer.js/hammer.js')
app.import(app.bowerDirectory + '/matchMedia/matchMedia.js');
};

app.import('vendor/propagating.js');
app.import('vendor/propagating.js');
}
},

contentFor: function(type) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"ember-cli-app-version": "^1.0.0",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-fastboot": "1.0.0-beta.4",
"ember-cli-github-pages": "^0.1.0",
"ember-cli-htmlbars": "^1.0.3",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
Expand Down