Skip to content

Commit

Permalink
Add mission modal js code
Browse files Browse the repository at this point in the history
  • Loading branch information
veteran29 committed Jun 14, 2020
1 parent 3121587 commit 4a42b6b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
5 changes: 3 additions & 2 deletions assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import yall from 'yall-js';

// Init Bootstrap jQuery plugins
import 'bootstrap';
import * as form from './form';
import * as modal from './modal';

$(() => {
$('[data-toggle="tooltip"]').tooltip();
Expand All @@ -22,7 +22,8 @@ $(() => {
});
});

form.initConfirmModals();
modal.initConfirmModals();
modal.initMissionModals();

// Image lazy loading
yall();
Expand Down
24 changes: 24 additions & 0 deletions assets/form.js → assets/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,27 @@ export const initConfirmModals = () => {
});
});
};

export const createMissionModal = (title, content) => {
let template = $('#modal-mission-template').html();
template = template.replace('__content__', content);
template = template.replace('__title__', title);

let $modal = $(template).modal({
'backdrop': 'static',
'keyboard': false,
});
};

export const initMissionModals = () => {
$('[data-mission-widget]').on('click', '[data-mission-title]', (e) => {
e.preventDefault();
e.stopPropagation();

const $mission = jQuery(e.delegateTarget);
const title = $mission.find('[data-mission-title]').text();
const description = $mission.find('[data-mission-description]').html();

createMissionModal(title, description)
});
};

0 comments on commit 4a42b6b

Please sign in to comment.