Skip to content

Instantly share code, notes, and snippets.

@brianally
Created July 2, 2015 18:41
Show Gist options
  • Save brianally/740b06b1ee6e2a54edec to your computer and use it in GitHub Desktop.
Save brianally/740b06b1ee6e2a54edec to your computer and use it in GitHub Desktop.
Set a class on body if Ember app is embedded in iframe, so as to hide certain elements and/or take/suppress other actions.
// config/environment.js
module.exports = function(environment) {
var ENV = {
// ...
APP: {
inIframe: false
}
// ...
};
return ENV;
};
// app/app.js
import Ember from "ember";
import Resolver from "ember/resolver";
import loadInitializers from "ember/load-initializers";
import config from "./config/environment";
var App;
Ember.MODEL_FACTORY_INJECTIONS = true;
App = Ember.Application.extend({
modulePrefix : config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver : Resolver,
ready: function() {
if ( window.self !== window.top ) {
this.inIframe = true;
Ember.$("body").addClass("in-iframe");
}
}
});
loadInitializers(App, config.modulePrefix);
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment