mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
30 lines
708 B
Plaintext
30 lines
708 B
Plaintext
:javascript
|
|
$(document).ready(function() {
|
|
var in_iframe = function(){
|
|
try {
|
|
return window.self !== window.top;
|
|
} catch (e) {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
var embedded_styles_active = $('body.off-canvas').hasClass('embedded');
|
|
|
|
var set_shopfront_styles = function(state) {
|
|
$.ajax({
|
|
url: '/embedded_shopfront/'+state,
|
|
type: 'POST'
|
|
});
|
|
};
|
|
|
|
if (in_iframe() && !embedded_styles_active){
|
|
$('body.off-canvas').addClass('embedded');
|
|
set_shopfront_styles('enable');
|
|
}
|
|
|
|
if (!in_iframe() && embedded_styles_active) {
|
|
$('body.off-canvas').removeClass('embedded');
|
|
set_shopfront_styles('disable');
|
|
}
|
|
});
|