SO Question
https://stackoverflow.com/q/56471917/1093087
by klenwell
JavaScript
$.fn.sheets = function(options){
const sheets = this;
let defaults = {
type: 'standard'
};
const head = sheets.find('.head'),
body = sheets.find('.body'),
headHeight = head.outerHeight(),
bodyHeight = body.outerHeight(),
sheetHeight = headHeight+bodyHeight;
const opts = $.extend({}, defaults, options);
if(options == 'open'){
// opts is not defined here. extending the defaults will also not work. I need the information here if the sheet is of type standard or modal
openSheet(sheets, head, body, opts);
} else {
head.on('click', function(e){
if(sheets.hasClass('active'))
closeSheet(sheets, head, body);
else
openSheet(sheets, head, body, opts);
});
}
function openSheet(sheets, head, body, opts){
console.log('openSheet');
console.log(opts);
}
}
//initializing with type modal
$('.sheets').sheets({
type: 'modal'
});
$('.sheets').sheets('open');