Created
July 2, 2015 18:41
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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