1// the semi-colon at the start is a safety net against concatenated 2// scripts and/or other plugins which may not be closed properly. 3; 4// Init Namespaces 5window.WebTheme = window.WebTheme || {}; 6 7(function (ns, $) { 8 "use strict"; 9 10 /** 11 *Oening hours script 12 * 13 * Dependencies (runtime): jQuery 14 * @constructor 15 */ 16 ns.OpeningHours = function (options) { 17 this._initWidget(options); 18 }; 19 20 /** 21 * Widget static init methods. 22 */ 23 $.extend(ns.OpeningHours.prototype, { 24 _defaults: { 25 selectors: { 26 openingTablePlaceholder: '.opening-hours__placeholder', 27 openingTableSimplePlaceholder: '.opening-hours-simple__placeholder' 28 }, 29 elements: { 30 }, 31 classes: { 32 }, 33 state: { 34 }, 35 data: {}, 36 placeholders: { 37 drop: '<!--drop-->', 38 stethoscope: '<!--stethoscope-->', 39 }, 40 icons: { 41 drop: `<svg style="vertical-align: bottom;" fill="#dd0000" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M192 512C86 512 0 426 0 320C0 228.8 130.2 57.7 166.6 11.7C172.6 4.2 181.5 0 191.1 0l1.8 0c9.6 0 18.5 4.2 24.5 11.7C253.8 57.7 384 228.8 384 320c0 106-86 192-192 192zM96 336c0-8.8-7.2-16-16-16s-16 7.2-16 16c0 61.9 50.1 112 112 112c8.8 0 16-7.2 16-16s-7.2-16-16-16c-44.2 0-80-35.8-80-80z"/></svg>`, 42 stethoscope: `<svg style="vertical-align: bottom;" fill="#406eac" height="20" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M142.4 21.9c5.6 16.8-3.5 34.9-20.2 40.5L96 71.1 96 192c0 53 43 96 96 96s96-43 96-96l0-120.9-26.1-8.7c-16.8-5.6-25.8-23.7-20.2-40.5s23.7-25.8 40.5-20.2l26.1 8.7C334.4 19.1 352 43.5 352 71.1L352 192c0 77.2-54.6 141.6-127.3 156.7C231 404.6 278.4 448 336 448c61.9 0 112-50.1 112-112l0-70.7c-28.3-12.3-48-40.5-48-73.3c0-44.2 35.8-80 80-80s80 35.8 80 80c0 32.8-19.7 61-48 73.3l0 70.7c0 97.2-78.8 176-176 176c-92.9 0-168.9-71.9-175.5-163.1C87.2 334.2 32 269.6 32 192L32 71.1c0-27.5 17.6-52 43.8-60.7l26.1-8.7c16.8-5.6 34.9 3.5 40.5 20.2zM480 224a32 32 0 1 0 0-64 32 32 0 1 0 0 64z"/></svg>`, 43 } 44 }, 45 46 _initWidget: function (options) { 47 var module = this; 48 49 // Init configuration 50 // perform deep copy of options 51 module._config = $.extend(true, {}, module._defaults, options || {}); 52 53 module._loadDaysOfWeek(); 54 module._loadPersons(); 55 module._loadOpeningHours(); 56 57 module._appendTablesToDom(); 58 module._appendTablesSimpleToDom(); 59 }, 60 61 _getCurrentDayOfWeek: function () { 62 var today = new Date(); 63 return today.getDay(); 64 }, 65 66 _getDayOfWeekName: function (dayIndex) { 67 var module = this; 68 69 return module._config.data.daysOfWeek[dayIndex]; 70 }, 71 72 _loadDaysOfWeek: function () { 73 var module = this; 74 var data = module._config.data; 75 data.daysOfWeek = window.WebTheme.data.daysOfWeek['cs_CZ']; 76 }, 77 78 _loadOpeningHours: function () { 79 var module = this; 80 var data = module._config.data; 81 data.openingHours = window.WebTheme.data.openingHours; 82 83 }, 84 85 _loadPersons: function () { 86 var module = this; 87 var data = module._config.data; 88 data.persons = window.WebTheme.data.persons; 89 }, 90 91 _createOpeningHoursTable: function (department, personId) { 92 var module = this; 93 var data = module._config.data; 94 var $table = undefined; 95 96 if (data.openingHours.hasOwnProperty(department) && data.persons.hasOwnProperty(personId)) { 97 var openingHours = data.openingHours[department]; 98 var person = data.persons[personId]; 99 $table = $('<table class="opening-hours__table--complete-view"></table>'); 100 var $thead = $('<thead>\n' + 101 ' <tr>\n' + 102 ' <td colspan="3"><h2>' + person.name + '</h2>\n' + 103 (person.contact !== null ? '<div class="opening-hours__contact-email"><a href="mailto:' + person.contact + '">' + person.contact + '</a>\n' : '') + 104 ' </div>\n' + 105 ' </td>\n' + 106 ' </tr>\n' + 107 ' </thead>'); 108 $table.append($thead); 109 $table.append(module._createOpeningHoursRows(openingHours, personId)); 110 } else { 111 console.log('no department or person: ' + department + '/' + personId); 112 } 113 return $table; 114 }, 115 116 _createOpeningHoursRows: function (openingHours, personId) { 117 var module = this; 118 var $tbody = $('<tbody></tbody>'); 119 var dayOfWeek; 120 var icons = module._config.icons; 121 var placeholders = module._config.placeholders; 122 123 $.each(openingHours, function (index, day) { 124 dayOfWeek = index; 125 126 $.each(day.slots, function (index, slot) { 127 var $row; 128 var description = slot.description.replace(placeholders.drop, icons.drop).replace(placeholders.stethoscope, icons.stethoscope); 129 130 if (slot.rowspan > 0) { 131 $row = $('<tr><td class="opening-hours__table-cell--day-of-week" rowspan="' + slot.rowspan +'">' + module._getDayOfWeekName(dayOfWeek) + '</td>' + 132 '<td class="opening-hours__table-cell--time">' + slot.time + '</td>' + 133 '<td class="opening-hours__table-cell--description">' + description + '</td></tr>'); 134 } else { 135 $row = $('<tr><td>' + slot.time + '</td><td>' + description + '</td></tr>'); 136 } 137 if (slot.person === personId) { 138 $tbody.append($row); 139 } 140 }); 141 }); 142 143 return $tbody; 144 }, 145 146 _appendTablesToDom: function () { 147 var module = this; 148 var $table; 149 var $placeholders = $(module._config.selectors.openingTablePlaceholder); 150 151 $.each($placeholders, function (index, section) { 152 var department = $(section).data('department'); 153 var person = $(section).data('person'); 154 155 $table = module._createOpeningHoursTable(department, person); 156 157 if ($table !== undefined) { 158 $(section).after($table); 159 } 160 161 $(section).detach(); 162 }); 163 }, 164 165 _createOpeningHoursTableSimple: function (department) { 166 var module = this; 167 var data = module._config.data; 168 var actualDayIndex = module._getCurrentDayOfWeek(); 169 var $table = undefined; 170 171 if (data.openingHours.hasOwnProperty(department)) { 172 var openingHours = data.openingHours[department]; 173 $table = $('<table class="opening-hours__table--simple-view"></table>'); 174 $table.append(module._createOpeningHoursRowsSimple(openingHours, actualDayIndex)); 175 } else { 176 console.log('no department: ' + department); 177 } 178 return $table; 179 }, 180 181 _createOpeningHoursRowsSimple: function (openingHours, actualDayIndex) { 182 var module = this; 183 var $tbody = $('<tbody></tbody>'); 184 185 if ((actualDayIndex === 0) || (actualDayIndex === 6)) { // Sunday, Saturday 186 $tbody.append('<tr><td>Dnes:</td><td colspan="2">ZavÅeno</td></tr>'); 187 $tbody.append('<tr><td>' + module._getDayOfWeekName(1) + ':</td><td>' + module._getOpeningHoursSimple(openingHours, 1)[0] + '</td><td>' + module._getOpeningHoursSimple(openingHours, 1)[1] + '</td></tr>'); 188 } else { 189 $tbody.append('<tr><td>Dnes:</td><td>' + module._getOpeningHoursSimple(openingHours, actualDayIndex)[0] + '</td><td>' + module._getOpeningHoursSimple(openingHours, actualDayIndex)[1] + '</td></tr>'); 190 if (actualDayIndex === 5) { // Friday 191 $tbody.append('<tr><td>' + module._getDayOfWeekName(1) + ':</td><td>' + module._getOpeningHoursSimple(openingHours, 1)[0] + '</td><td>' + module._getOpeningHoursSimple(openingHours, 1)[1] + '</td></tr>'); 192 } else { // Monday, Tuesday, Friday, Thursday 193 $tbody.append('<tr><td>ZÃtra:</td><td>' + module._getOpeningHoursSimple(openingHours, actualDayIndex + 1)[0] + '</td><td>' + module._getOpeningHoursSimple(openingHours, actualDayIndex + 1)[1] + '</td></tr>'); 194 } 195 } 196 return $tbody; 197 }, 198 199 _getOpeningHoursSimple: function(openingHours, dayIndex) { 200 var day; 201 202 if (openingHours.hasOwnProperty(dayIndex)) { 203 day = openingHours[dayIndex]; 204 return [day.overview[0], day.overview[1]]; 205 } else { 206 return ['ZavÅeno', '']; 207 } 208 }, 209 210 _appendTablesSimpleToDom: function () { 211 var module = this; 212 var $table; 213 var $placeholders = $(module._config.selectors.openingTableSimplePlaceholder); 214 215 $.each($placeholders, function (index, section) { 216 var department = $(section).data('department'); 217 218 $table = module._createOpeningHoursTableSimple(department); 219 220 if ($table !== undefined) { 221 $(section).after($table); 222 } 223 224 $(section).detach(); 225 }); 226 } 227 });
228})(window.WebTheme, jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.