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

menuBox JSON #2

Closed
StuartNicholls opened this issue May 2, 2023 · 3 comments
Closed

menuBox JSON #2

StuartNicholls opened this issue May 2, 2023 · 3 comments

Comments

@StuartNicholls
Copy link

The js is looking for a JSON object called _boxMenu - should this be unique?

Requires:

adaptlearning/adapt-contrib-core#366

@oliverfoster
Copy link
Member

const ChildView = (model.get('_type') === 'menu' && model.get('_boxMenu') && model.get('_boxMenu')._renderAsGroup) ?
MenuBoxGroupView :
MenuBoxItemView;
const $parentContainer = this.$(this.constructor.childContainer);
const childView = new ChildView({ model });
childViews.push(childView);
$parentContainer.append(childView.$el);
});
this.setChildViews(childViews);
}
setStyles() {
this.addBackgroundLayer();
this.setBackgroundImage();
this.setBackgroundStyles();
this.processHeader();
}
addBackgroundLayer() {
if (this.$el.find(' > .background').length) return;
this.$background = $('<div class="background" aria-hidden="true"></div>')
.prependTo(this.$el);
}
setBackgroundImage() {
const config = this.model.get('_boxMenu');
const backgroundImages = config?._backgroundImage;
if (!backgroundImages) return;
const backgroundImage = backgroundImages[`_${Adapt.device.screenSize}`] ?? backgroundImages._small;
this.$el.toggleClass('has-bg-image', Boolean(backgroundImage));
this.$background
.css('background-image', backgroundImage ? 'url(' + backgroundImage + ')' : '');
}
setBackgroundStyles() {
const config = this.model.get('_boxMenu');
const styles = config?._backgroundStyles;
if (!styles) return;
this.$background.css({
'background-repeat': styles._backgroundRepeat,
'background-size': styles._backgroundSize,
'background-position': styles._backgroundPosition
});
}
processHeader() {
const config = this.model.get('_boxMenu');
const header = config?._menuHeader;
if (!header) return;
const $header = this.$('.menu__header');
this.setHeaderTextAlignment(header);
this.addHeaderBackgroundLayer($header);
this.setHeaderBackgroundImage(header, $header);
this.setHeaderBackgroundStyles(header, $header);
this.setHeaderMinimumHeight(header, $header);
}

@oliverfoster
Copy link
Member

The references in the background stuff will be removed with #5, the ones in the render function just need their name changing inline with schema updates.

@oliverfoster
Copy link
Member

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants