Commit bb40d7c0 by Arnaud

add list option

parent a5615f8c
.doodle-list {
list-style-type: none;
}
.doodle-label {
margin-left: 15px;
}
.doodle-table { .doodle-table {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
*/ */
let DoodleFront = function(item, config) { let DoodleFront = function(item, config) {
this.item = item; this.item = item;
this.config = config; this.config = config;
this.json = null; this.json = null;
...@@ -20,6 +19,8 @@ ...@@ -20,6 +19,8 @@
this.initLoad = () => { this.initLoad = () => {
this.getJsonData(); this.getJsonData();
console.log(this.json);
if(!this.json) { if(!this.json) {
console.warn('Invalid Json data'); console.warn('Invalid Json data');
return; return;
...@@ -27,22 +28,31 @@ ...@@ -27,22 +28,31 @@
this.getDays(); this.getDays();
this.getHours(); this.getHours();
this.createTable(); this.createTable(config);
this.initCSS(); this.initCSS(config);
//Remet l'overflow pour le responsive en front //Remet l'overflow pour le responsive en front
$('table').parent().css('overflow-x', 'auto'); if(!config.vertical) {
$('table').parent().css('overflow-x', 'auto');
}
}; };
/** /**
* Create Table * Create Table
*/ */
this.createTable = () => { this.createTable = (config) => {
console.log(config);
$(document).on('click', 'input[type=checkbox]', this.eventInput); $(document).on('click', 'input[type=checkbox]', this.eventInput);
this.item.append(` if(config.vertical) {
this.item.append(`
<ul class="doodle-list">
${this.createList()}
</ul>
`);
} else {
this.item.append(`
<table class="table doodle-table frontend"> <table class="table doodle-table frontend">
<thead> <thead>
${this.createHeaderTable()} ${this.createHeaderTable()}
...@@ -53,11 +63,39 @@ ...@@ -53,11 +63,39 @@
</tbody> </tbody>
</table> </table>
`); `);
}
}; };
this.createList = function() {
let div = $('<div>');
// DAYS =>
for(let index in this.days) {
let formatDateDay = moment(this.days[index], this.dateFormat).locale('fr').format('dddd DD');
let formatDateMonth = moment(this.days[index], this.dateFormat).locale('fr').format('MMMM');
let $h3 = $('<h5><span class="date_format"><b>' + formatDateDay + '</b></span> ' + formatDateMonth + '</td>');
div.append($h3);
for(let index2 in this.hours) {
let $li = $('<li class="p-3">');
if(this.json[this.days[index]].includes(this.hours[index2])) {
let hour = this.hours[index2];
if (hour.indexOf(':') === -1) {
hour += 'h';
} else {
hour = hour.replace(':', 'h');
}
$li.html(this.createInputBox(this.hours[index2], formatDateDay) + '<label class="doodle-label">' + hour + '</label>');
div.append($li);
}
}
}
return div.html();
}
this.initCSS = function() { this.initCSS = function() {
$('.empty').css('background', '#fafafa') $('.empty').css('background', '#fafafa')
}; };
/** /**
...@@ -185,9 +223,8 @@ ...@@ -185,9 +223,8 @@
this.json = JSON.parse(dataJson); this.json = JSON.parse(dataJson);
} else { } else {
let data = this.fileExistsAndGetData(dataJson); let data = this.fileExistsAndGetData(dataJson);
if(data){ if(data) {
let json = JSON.parse(data); let json = JSON.parse(data);
if (!$.isEmptyObject(json)) { if (!$.isEmptyObject(json)) {
this.json = json; this.json = json;
} }
......
$( document ).ready(function() { $( document ).ready(function() {
$('.doodle').Doodle({ $('.doodle').Doodle({
editMode: true, editMode: false,
inputSelector: '#inputVal' inputSelector: '#inputVal'
}); });
}); });
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment