@innovastudio/contentbox 1.4.3 → 1.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -499,7 +499,7 @@ class SideBar {
499
499
  sideIndex++;
500
500
  });
501
501
  html += '</div>';
502
- html += '' + '<div id="divSidebarSections" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<iframe id="ifrIdeasPanel" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divSidebarSnippets" class="is-sidebar-content scroll-darker" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="max-width:275px;border-left: transparent 50px solid;box-sizing: border-box;">' + '' + '</div>' + '<div id="divSidebarSource" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<div style="position:absolute;width:240px;height:35px;right:10px;top:5px;z-index:1;display:flex;">' + '<button title="' + out('Cancel') + '" id="btnViewHtmlCancel" tabindex="-1" style="height:38px" class="classic-secondary"> ' + out('Cancel') + ' </button>' + '<button title="' + out('Ok') + '" id="btnViewHtmlOk" tabindex="-1" style="height:38px" class="classic-primary"> ' + out('Ok') + ' </button>' + '</div>' + '<div style="height:100%;box-sizing:border-box;border-top:#f3f3f3 50px solid;position:relative">' + '<textarea id="inpViewHtml" tabindex="-1" style="width:100%;height:100%;resize: none;"></textarea>' + '</div>' + '</div>' + '</div>' + '<div id="divSidebarTypography" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div class="scroll-darker">' + '<div style="padding: 15px 0 0 20px">' + '<div class="is-sidebar-title" style="margin-bottom:12px;">' + out('Typography Styles') + '</div>' + '<div>' + out('Apply to') + ':</div>' + '<div style="display:flex;justify-content:space-between;align-items: center;">' + '<div class="typo-target-default" style="display:flex">' + '<label><input type="radio" tabindex="0" name="typoTarget" value="page"> <span>' + out('Page') + '</span></label>' + '<label><input type="radio" tabindex="0" name="typoTarget" value="section" checked> <span>' + out('Section') + '</span></label>' + '</div>' + '<div class="typo-target-box" style="display: flex;">' + '<span>' + out('Active Box') + '</span>' + '</div>' + '<button title="' + out('Clear') + '" tabindex="0" id="btnTypoClear"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>' + '</div>' + '</div>' + '<div id="divSelector"></div>' + '<div id="divStyles"></div>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea1" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea1" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea2" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea2" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>';
502
+ html += '' + '<div id="divSidebarSections" class="is-sidebar-content ' + this.builder.templateThumbnailSize + '" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<iframe id="ifrIdeasPanel" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divSidebarSnippets" class="is-sidebar-content scroll-darker" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="max-width:275px;border-left: transparent 50px solid;box-sizing: border-box;">' + '' + '</div>' + '<div id="divSidebarSource" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div>' + '<div style="position:absolute;width:240px;height:35px;right:10px;top:5px;z-index:1;display:flex;">' + '<button title="' + out('Cancel') + '" id="btnViewHtmlCancel" tabindex="-1" style="height:38px" class="classic-secondary"> ' + out('Cancel') + ' </button>' + '<button title="' + out('Ok') + '" id="btnViewHtmlOk" tabindex="-1" style="height:38px" class="classic-primary"> ' + out('Ok') + ' </button>' + '</div>' + '<div style="height:100%;box-sizing:border-box;border-top:#f3f3f3 50px solid;position:relative">' + '<textarea id="inpViewHtml" tabindex="-1" style="width:100%;height:100%;resize: none;"></textarea>' + '</div>' + '</div>' + '</div>' + '<div id="divSidebarTypography" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="-webkit-transition-duration:0.2s;transition-duration:0.2s;">' + '<div class="scroll-darker">' + '<div style="padding: 15px 0 0 20px">' + '<div class="is-sidebar-title" style="margin-bottom:12px;">' + out('Typography Styles') + '</div>' + '<div>' + out('Apply to') + ':</div>' + '<div style="display:flex;justify-content:space-between;align-items: center;">' + '<div class="typo-target-default" style="display:flex">' + '<label><input type="radio" tabindex="0" name="typoTarget" value="page"> <span>' + out('Page') + '</span></label>' + '<label><input type="radio" tabindex="0" name="typoTarget" value="section" checked> <span>' + out('Section') + '</span></label>' + '</div>' + '<div class="typo-target-box" style="display: flex;">' + '<span>' + out('Active Box') + '</span>' + '</div>' + '<button title="' + out('Clear') + '" tabindex="0" id="btnTypoClear"><svg class="is-icon-flex" style="width:11px;height:11px;"><use xlink:href="#icon-clean"></use></svg></button>' + '</div>' + '</div>' + '<div id="divSelector"></div>' + '<div id="divStyles"></div>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea1" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea1" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>' + '<div id="divCustomSidebarArea2" class="is-sidebar-content" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true" style="max-width:500px;">' + '<div style="padding:0 0 0 50px;box-sizing:border-box;">' + '<iframe id="ifrCustomSidebarArea2" src="about:blank" style="width:100%;height:100%;box-sizing:border-box;border:none;">' + '</iframe>' + '</div>' + '</div>';
503
503
  } else {
504
504
  html = '<div id="divSections" style="display:none"></div>' + '<div class="is-modal addsection" tabindex="-1" role="dialog" aria-modal="true" aria-hidden="true">' + '<div style="max-width: 900px;">' + '<div id="divSectionList" class="is-section-list"></div>' + '</div>' + '</div>';
505
505
  }
@@ -762,8 +762,14 @@ class SideBar {
762
762
  var doc = ifr.contentWindow.document;
763
763
 
764
764
  if (doc.body.innerHTML === '') {
765
- doc.open();
766
- doc.write(this.getTemplatesHtml());
765
+ doc.open(); // doc.write(this.getTemplatesHtml());
766
+
767
+ if (this.builder.templates.length === 0) {
768
+ doc.write(this.getTemplatesHtml_OLD());
769
+ } else {
770
+ doc.write(this.getTemplatesHtml());
771
+ }
772
+
767
773
  doc.close();
768
774
  }
769
775
  } else if (designPath) {
@@ -1121,6 +1127,903 @@ class SideBar {
1121
1127
  }
1122
1128
 
1123
1129
  getTemplatesHtml() {
1130
+ let sTemplateJSON = '';
1131
+ this.builder.templateJSON.forEach(item => {
1132
+ sTemplateJSON += `{
1133
+ url: '${item.url}',
1134
+ path: '${item.path}',
1135
+ pathReplace: '${item.pathReplace}',
1136
+ },`;
1137
+ });
1138
+ let sTemplates = '';
1139
+ this.builder.templates.forEach(item => {
1140
+ sTemplates += `{
1141
+ url: '${item.url}',
1142
+ path: '${item.path}',
1143
+ pathReplace: '${item.pathReplace}',
1144
+ },`;
1145
+ });
1146
+ let sCategories = '';
1147
+ this.builder.featuredCategories.forEach(item => {
1148
+ sCategories += `{
1149
+ id: '${item.id}',
1150
+ name: '${item.name}',
1151
+ },`;
1152
+ });
1153
+ let thumbWidth = '';
1154
+ let thumbMargin = '';
1155
+ let thumbMaxHeight = '';
1156
+
1157
+ if (this.builder.templateThumbnailSize === 'small') {
1158
+ thumbWidth = '250px';
1159
+ thumbMargin = '30px 0 0 30px';
1160
+ thumbMaxHeight = '513px';
1161
+ } else if (this.builder.templateThumbnailSize === 'medium') {
1162
+ thumbWidth = '350px';
1163
+ thumbMargin = '40px 0 0 40px';
1164
+ thumbMaxHeight = '214px';
1165
+ } else {
1166
+ thumbWidth = '450px'; // '500px';
1167
+
1168
+ thumbMargin = '50px 0 0 50px'; // '62px 0 0 60px';
1169
+
1170
+ thumbMaxHeight = '275'; // '305px'
1171
+ }
1172
+
1173
+ let html = `
1174
+ <!DOCTYPE html>
1175
+ <html lang="en">
1176
+ <head>
1177
+ <meta charset="utf-8">
1178
+ <title>Browse</title>
1179
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1180
+ <meta name="description" content="">
1181
+ <link rel="shortcut icon" href="#" />
1182
+ <style>
1183
+ body {
1184
+ margin: 0;
1185
+ background: #fff;
1186
+ font-family: sans-serif;
1187
+ font-weight: 300;
1188
+ }
1189
+ h2 {
1190
+ font-weight: 300;
1191
+ }
1192
+ button {
1193
+ cursor: pointer;
1194
+ border: none;
1195
+ background: #fdfdfd;
1196
+ padding: 12px 25px;
1197
+ border-radius: 500px;
1198
+ font-size: 11px;
1199
+ text-transform: uppercase;
1200
+ letter-spacing: 1px;;
1201
+ color: #333;
1202
+ }
1203
+ button.on {
1204
+ background: #f5f5f5;
1205
+ }
1206
+
1207
+ .featured-categories {
1208
+ background-color: #f5f5f5;
1209
+ position: absolute;
1210
+ width: 100%;
1211
+ height: 88px;
1212
+ z-index: 1;
1213
+ padding: 14px 15px 0 25px;
1214
+ box-sizing: border-box;
1215
+ /* box-shadow: 0 5px 15px rgb(0 0 0 / 5%); */
1216
+ }
1217
+ .featured-categories button {
1218
+ margin: 10px 15px 0 0;
1219
+ font-size: 11px;
1220
+ }
1221
+
1222
+ .is-design-list {
1223
+ position: fixed;
1224
+ top: 0px;
1225
+ left: 0px;
1226
+ border-top: transparent 88px solid;
1227
+ width: 100%;
1228
+ height: 100%;
1229
+ overflow-y: auto;
1230
+ padding: 0px 0px 30px 0px;
1231
+ box-sizing: border-box;
1232
+ overflow: auto;
1233
+ transition: all 200ms ease;
1234
+ }
1235
+ .is-design-list > button {
1236
+ position: relative;
1237
+ width: ${thumbWidth};
1238
+ max-height: ${thumbMaxHeight};
1239
+ overflow: hidden;
1240
+ margin: ${thumbMargin};
1241
+ cursor: pointer;
1242
+ display: inline-block;
1243
+ padding: 0px;
1244
+ border: rgba(219, 219, 219, 0.39) 1px solid;
1245
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
1246
+ border-radius: 2px;
1247
+ }
1248
+ .is-design-list > button img {
1249
+ box-shadow: none;
1250
+ opacity: 1;
1251
+ display: block;
1252
+ box-sizing: border-box;
1253
+ transition: all 0.2s ease-in-out;
1254
+ max-width: 500px;
1255
+ width: 100%
1256
+ }
1257
+ .is-design-list > button .is-overlay {
1258
+ position: absolute;
1259
+ top:0px;
1260
+ left:0px;
1261
+ width:100%;
1262
+ height:100%;
1263
+ }
1264
+ .is-design-list > button .is-overlay:after {
1265
+ background: rgba(0, 0, 0, 0.05);
1266
+ position: absolute;
1267
+ content: "";
1268
+ display: block;
1269
+ top: 0;
1270
+ left: 0;
1271
+ right: 0;
1272
+ bottom: 0;
1273
+ transition: all 0.2s ease-in-out;
1274
+ opacity: 0;
1275
+ }
1276
+ .is-design-list > button:hover .is-overlay:after {
1277
+ opacity: 0.5;
1278
+ }
1279
+
1280
+ .mega-menu {
1281
+ display: none;
1282
+ transform: translateY(-100%);
1283
+ background: #f5f5f5;
1284
+ overflow-x: hidden;
1285
+ overflow-y: auto;
1286
+ position: fixed;
1287
+ top: 88px;
1288
+ left: 0;
1289
+ right: 0;
1290
+ width: 100%;
1291
+ height: auto;
1292
+ z-index: 1;
1293
+ padding: 10px 50px 40px 40px;
1294
+ box-sizing: border-box;
1295
+ transition: all 300ms ease;
1296
+ min-width:400px;
1297
+ min-height: 200px;
1298
+ /* box-shadow: 0 5px 15px rgb(0 0 0 / 5%); */
1299
+ }
1300
+ .mega-menu.active {
1301
+ opacity: 1;
1302
+ transform: scale(1);
1303
+ transform: translateY(0);
1304
+ }
1305
+ .mega-menu h2 {
1306
+ margin-top:30px;
1307
+ font-size: 21px
1308
+ }
1309
+ .mega-menu button {
1310
+ margin:15px 15px 0 0;
1311
+ }
1312
+ .mega-menu .close {
1313
+ position: absolute;
1314
+ top: 0px; right: 0px;
1315
+ background: transparent;
1316
+ width: 50px;
1317
+ height: 50px;
1318
+ display: flex;
1319
+ justify-content: center;
1320
+ align-items: center;
1321
+ border-radius: 2px;;
1322
+ }
1323
+
1324
+ .is-waiting {
1325
+ position: fixed;
1326
+ top: 0px;
1327
+ left: 0px;
1328
+ border-top: transparent 88px solid;
1329
+ width: 100%;
1330
+ height: 100%;
1331
+ background-color: #fff;
1332
+ display: flex;
1333
+ justify-content: flex-start;
1334
+ align-items: flex-start;
1335
+ padding: 50px
1336
+ }
1337
+ .is-waiting2 {
1338
+ position: absolute;
1339
+ top: 0px;
1340
+ left: 0px;
1341
+ width: 100%;
1342
+ height: 100%;
1343
+ background-color: #f5f5f5;
1344
+ display: flex;
1345
+ justify-content: flex-start;
1346
+ align-items: flex-start;
1347
+ padding: 20px 50px;
1348
+ }
1349
+ </style>
1350
+ </head>
1351
+ <body style="touch-action: pan-y">`;
1352
+ html += `
1353
+ <div class="mega-menu">
1354
+ <div class="is-waiting2">
1355
+ <div style="color:rgba(125, 125, 125, 0.5)" class="loader loader--style2" title="1">
1356
+ <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
1357
+ <path fill="currentColor" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z">
1358
+ <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.7s" repeatCount="indefinite"></animateTransform>
1359
+ </path>
1360
+ </svg>
1361
+ </div>
1362
+ </div>
1363
+
1364
+ <button class="close" tabindex="0"><svg style="width:40px;height:40px;flex:none;"><use xlink:href="#iconclose"></use></svg></button>
1365
+
1366
+ <div class="mega-menu-content">
1367
+ </div>
1368
+ </div>
1369
+
1370
+ <div class="featured-categories">
1371
+ </div>
1372
+
1373
+ <div class="is-design-list">
1374
+ </div>
1375
+
1376
+ <div class="is-waiting">
1377
+ <div style="color:rgba(125, 125, 125, 0.5)" class="loader loader--style2" title="1">
1378
+ <svg version="1.1" id="loader-1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="40px" height="40px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
1379
+ <path fill="currentColor" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z">
1380
+ <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.7s" repeatCount="indefinite"></animateTransform>
1381
+ </path>
1382
+ </svg>
1383
+ </div>
1384
+ </div>
1385
+
1386
+ <svg width="0" height="0" style="position:absolute;display:none;">
1387
+ <defs>
1388
+ <symbol viewBox="0 0 24 24" id="iconclose" stroke-width="0.7" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
1389
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>
1390
+ </symbol>
1391
+ </defs>
1392
+ </svg>
1393
+
1394
+ <script>
1395
+ var template_list = [];
1396
+ </script>
1397
+ <!-- <script src="basic.js" type="text/javascript"></script>
1398
+ <script src="examples.js" type="text/javascript"></script> -->
1399
+
1400
+ <script>
1401
+
1402
+ // Configuration
1403
+ const featuredCategories = [
1404
+ ${sCategories}
1405
+ ];
1406
+ const defaultCat = ${this.builder.defaultDesignCategory};
1407
+ const navbar = ${this.builder.navbar ? 'true' : 'false'};
1408
+
1409
+ const slider = '${this.builder.slider}';
1410
+
1411
+ const framework = '${this.builder.framework}';
1412
+ const contentStylePath = '${this.builder.contentStylePath}';
1413
+
1414
+ let templates = [
1415
+ ${sTemplates}
1416
+ ];
1417
+
1418
+ let templateJSON = [
1419
+ ${sTemplateJSON}
1420
+ ];
1421
+ // /Configuration
1422
+
1423
+ if(templates.length > 0) templateJSON = [...templates];
1424
+
1425
+ const loadJsFiles = (list, callback) => {
1426
+ if(list.length===0) {
1427
+ return;
1428
+ } else {
1429
+ const url = list[0].url;
1430
+ const script = document.createElement('script');
1431
+ script.src = url;
1432
+ script.async = true;
1433
+ script.onload = () => {
1434
+ callback(list[0]);
1435
+ loadJsFiles(list.slice(1), callback);
1436
+ };
1437
+ document.body.appendChild(script);
1438
+ }
1439
+ }
1440
+
1441
+ const imageObserver = new IntersectionObserver((entries, imgObserver) => {
1442
+ entries.forEach((entry) => {
1443
+ if (entry.isIntersecting) {
1444
+ const lazyImage = entry.target
1445
+ // console.log("lazy loading ", lazyImage)
1446
+ lazyImage.src = lazyImage.dataset.src
1447
+ lazyImage.classList.remove("lzy-img");
1448
+ imgObserver.unobserve(lazyImage);
1449
+ }
1450
+ })
1451
+ });
1452
+
1453
+ const makeid = () => { //http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
1454
+ var text = "";
1455
+ var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
1456
+ for (var i = 0; i < 2; i++)
1457
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
1458
+
1459
+ var text2 = "";
1460
+ var possible2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1461
+ for (var i = 0; i < 5; i++)
1462
+ text2 += possible2.charAt(Math.floor(Math.random() * possible2.length));
1463
+
1464
+ return text + text2;
1465
+ }
1466
+
1467
+ const addDesign = (designid) => {
1468
+
1469
+ const wrapper = parent._cb.doc.querySelector('.is-wrapper');
1470
+
1471
+ let nIndex = 0;
1472
+ template_list.forEach(gallery=>{
1473
+ let designs = gallery.designs;
1474
+ designs.forEach(item=>{
1475
+
1476
+ item.id = nIndex; //Give id
1477
+
1478
+ if(nIndex===parseInt(designid)) {
1479
+ // alert(item.html);
1480
+ // alert(gallery.path);
1481
+ // alert(gallery.pathReplace);
1482
+
1483
+ let html = item.html;
1484
+ let googleFonts = item.googleFonts;
1485
+ let contentCss = item.contentCss;
1486
+ let contentClass = item.contentClass;
1487
+
1488
+ let designPath = gallery.path;
1489
+ let snippetPathReplace = gallery.pathReplace;
1490
+
1491
+ //To Tailwind
1492
+ if (framework == 'tailwind') {
1493
+ html = html.replace(new RegExp(' container', 'g'), ' container');
1494
+ html = html.replace(new RegExp('row clearfix', 'g'), 'flex flex-col md:flex-row');
1495
+ html = html.replace(new RegExp('column full', 'g'), 'w-full px-4');
1496
+ html = html.replace(new RegExp('column half', 'g'), 'w-full md:w-6/12 px-4');
1497
+ html = html.replace(new RegExp('column third', 'g'), 'w-full md:w-4/12 px-4');
1498
+ html = html.replace(new RegExp('column fourth', 'g'), 'w-full md:w-3/12 px-4');
1499
+ html = html.replace(new RegExp('column fifth', 'g'), 'w-full md:w-2/12 px-4'); //not needed
1500
+ html = html.replace(new RegExp('column sixth', 'g'), 'w-full md:w-2/12 px-4');
1501
+ html = html.replace(new RegExp('column two-third', 'g'), 'w-full md:w-8/12 px-4');
1502
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'w-full md:w-9/12 px-4');
1503
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'w-full md:w-10/12 px-4');
1504
+ }
1505
+
1506
+ //To Bootstrap
1507
+ if (framework == 'bootstrap') {
1508
+ html = html.replace(new RegExp(' container', 'g'), ' container-fluid');
1509
+ html = html.replace(new RegExp('row clearfix', 'g'), 'row');
1510
+ html = html.replace(new RegExp('column full', 'g'), 'col-md-12');
1511
+ html = html.replace(new RegExp('column half', 'g'), 'col-md-6');
1512
+ html = html.replace(new RegExp('column third', 'g'), 'col-md-4');
1513
+ html = html.replace(new RegExp('column fourth', 'g'), 'col-md-3');
1514
+ html = html.replace(new RegExp('column fifth', 'g'), 'col-md-2');
1515
+ html = html.replace(new RegExp('column sixth', 'g'), 'col-md-2');
1516
+ html = html.replace(new RegExp('column two-third', 'g'), 'col-md-8');
1517
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'col-md-9');
1518
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'col-md-10');
1519
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'btn btn-primary btn-lg');
1520
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'btn btn-default btn-lg');
1521
+ }`;
1522
+ html += `
1523
+ //To Foundation
1524
+ if (framework == 'foundation') {
1525
+ //html = html.replace(new RegExp(' container', 'g'), ' container');
1526
+ html = html.replace(new RegExp('row clearfix', 'g'), 'row');
1527
+ html = html.replace(new RegExp('column full', 'g'), 'large-12 columns');
1528
+ html = html.replace(new RegExp('column half', 'g'), 'large-6 columns');
1529
+ html = html.replace(new RegExp('column third', 'g'), 'large-4 columns');
1530
+ html = html.replace(new RegExp('column fourth', 'g'), 'large-3 columns');
1531
+ html = html.replace(new RegExp('column fifth', 'g'), 'large-2 columns');
1532
+ html = html.replace(new RegExp('column sixth', 'g'), 'large-2 columns');
1533
+ html = html.replace(new RegExp('column two-third', 'g'), 'large-8 columns');
1534
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'large-9 columns');
1535
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'large-10 columns');
1536
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'button');
1537
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'secondary button');
1538
+ }
1539
+
1540
+ //To UIKit
1541
+ if (framework == 'uikit') {
1542
+ html = html.replace(new RegExp(' container', 'g'), ' uk-container uk-container-center');
1543
+ html = html.replace(new RegExp('row clearfix', 'g'), 'uk-grid');
1544
+ html = html.replace(new RegExp('column full', 'g'), 'uk-width-1-1');
1545
+ html = html.replace(new RegExp('column half', 'g'), 'uk-width-1-2');
1546
+ html = html.replace(new RegExp('column third', 'g'), 'uk-width-1-3');
1547
+ html = html.replace(new RegExp('column fourth', 'g'), 'uk-width-1-4');
1548
+ html = html.replace(new RegExp('column fifth', 'g'), 'uk-width-1-5');
1549
+ html = html.replace(new RegExp('column sixth', 'g'), 'uk-width-1-6');
1550
+ html = html.replace(new RegExp('column two-third', 'g'), 'uk-width-2-3');
1551
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'uk-width-3-4');
1552
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'uk-width-5-6');
1553
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'uk-button uk-button-primary uk-button-large');
1554
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'uk-button uk-button-large');
1555
+ }
1556
+
1557
+ //To Material
1558
+ if (framework == 'material') {
1559
+ html = html.replace(new RegExp(' container', 'g'), '');
1560
+ html = html.replace(new RegExp('row clearfix', 'g'), 'mdl-grid');
1561
+ html = html.replace(new RegExp('column full', 'g'), 'mdl-cell mdl-cell--12-col');
1562
+ html = html.replace(new RegExp('column half', 'g'), 'mdl-cell mdl-cell--6-col');
1563
+ html = html.replace(new RegExp('column third', 'g'), 'mdl-cell mdl-cell--4-col');
1564
+ html = html.replace(new RegExp('column fourth', 'g'), 'mdl-cell mdl-cell--3-col');
1565
+ html = html.replace(new RegExp('column fifth', 'g'), 'mdl-cell mdl-cell--2-col');
1566
+ html = html.replace(new RegExp('column sixth', 'g'), 'mdl-cell mdl-cell--2-col');
1567
+ html = html.replace(new RegExp('column two-third', 'g'), 'mdl-cell mdl-cell--8-col');
1568
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'mdl-cell mdl-cell--9-col');
1569
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'mdl-cell mdl-cell--10-col');
1570
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'mdl-button mdl-js-button mdl-button--raised mdl-button--accent');
1571
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'mdl-button mdl-js-button mdl-button--raised');
1572
+ }
1573
+
1574
+ html = html.replace(/{id}/g, makeid());
1575
+
1576
+ if(snippetPathReplace.length>0) {
1577
+ if (snippetPathReplace[0] != '') {
1578
+ var regex = new RegExp(snippetPathReplace[0], 'g');
1579
+ html = html.replace(regex, snippetPathReplace[1]);
1580
+ }
1581
+ }
1582
+
1583
+ html = html.replace(/\\[%IMAGE_PATH%\\]/g, designPath);
1584
+ html = html.replace(/%5B%25IMAGE_PATH%25%5D/g, designPath); //If [%IMAGE_PATH%] is encoded (inside data-html)
1585
+
1586
+ //Add html
1587
+ parent.contentbox.addIdea(html);
1588
+
1589
+ //Add contentCss
1590
+ let exist = false;
1591
+ let links = parent._cb.doc.getElementsByTagName("link");
1592
+ for (let i = 0; i < links.length; i++) {
1593
+ let src = links[i].href.toLowerCase();
1594
+ if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
1595
+ }
1596
+
1597
+ if (!exist) wrapper.insertAdjacentHTML('beforeend', '<link data-name="contentstyle" data-class="' + contentClass + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
1598
+ }
1599
+
1600
+ nIndex++;
1601
+ });
1602
+ });
1603
+ }
1604
+
1605
+ const showDesigns = (catId) => {
1606
+
1607
+ const wait = document.querySelector('.is-waiting');
1608
+ wait.style.display = 'none';
1609
+
1610
+ const designList = document.querySelector('.is-design-list');
1611
+ designList.style.opacity = 0;
1612
+ setTimeout(()=>{
1613
+ designList.innerHTML = '';
1614
+ designList.style.opacity = 1;
1615
+
1616
+ let nIndex = 0;
1617
+
1618
+ template_list.forEach(gallery=>{
1619
+ let designs = gallery.designs;
1620
+ designs.forEach(item=>{
1621
+ let isSelected = false;
1622
+ let catSplit = item.category.split(',');
1623
+ for (let j = 0; j < catSplit.length; j++) {
1624
+ if (parseInt(catSplit[j]) === parseInt(catId)) {
1625
+ isSelected = true;
1626
+ }
1627
+ }
1628
+
1629
+ item.id = nIndex; //Give id
1630
+
1631
+ if (isSelected) {
1632
+
1633
+ let html = '<button tabindex="0" class="active" data-id="' + item.id + '" data-cat=""' + item.category + '">' +
1634
+ '<img class="lzy-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAK5GlDQ1BJQ0MgUHJvZmlsZQAASImVlwdUE1kXgN/MpBdaIAJSQm+CdAJICT2AgHQQlZCEJJQQUlCxK4sruBZURLCs6EpTcHUFZC2IBdsioNh1QRYVdV0s2FDZAX7C7v7n///z33PuvG/u3HffvXPeO+c+AKgpHIkkC1YDIFssl0YH+zESk5IZ+McABxBARpXG4cokrKiocIDK5Ph3eXcTQGPjdduxWP/+/b+KBo8v4wIApaCcxpNxs1FuRfUrVyKVA4CgDEwWyiVj/BvKmlI0QZQ/jLFgnDGUMU6bYMa4T2y0P8rOABAoHI5UAADFF7Uz8rgCNA4lFWV7MU8kRnkTyt5cIYeHcifKM7Kzc8b4M8qWqL8EAKopysy0v8QU/C1+mjI+hyNQ8kRd40IIEMkkWZzF/+ev+d+SnaWYXMMcVYpQGhI9wdDtzJwwJYvTIiInWcSb9IduCxUhcZPMlfknTzKPExCmnJsVET7J6aIgtjKOnB07yXxZYMwkS3OilWulS/1Zk8yRTq2ryIxT2oV8tjJ+vjA2YZLzRPERkyzLjAmb8vFX2qWKaGX+fHGw39S6Qcras2V/qVfEVs6VC2NDlLVzpvLni1lTMWWJytx4/IDAKZ84pb9E7qdcS5IVpfTnZwUr7bK8GOVcObo5p+ZGKf9hBic0apJBLBACBRADHuADKUgDOSALyAEDBAARkAEJ+sYB6HaS8xfJx4rzz5EslooEQjmDhZ5APoMt5trNYDjaOzoCMHaeJ7b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B4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWURpbWVuc2lvbj4xNjwvZXhpZjpQaXhlbFlEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4xNjwvZXhpZjpQaXhlbFhEaW1lbnNpb24+CiAgICAgICAgIDxleGlmOlVzZXJDb21tZW50PlNjcmVlbnNob3Q8L2V4aWY6VXNlckNvbW1lbnQ+CiAgICAgIDwvcmRmOkRlc2NyaXB0aW9uPgogICA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgpzPGLtAAAAIklEQVQ4EWP8DwQMFAAmCvSCtY4awMAwGgajYQDKDAOfDgBrygQcINQZEQAAAABJRU5ErkJggg==" data-src="' + gallery.path + item.thumbnail + '">' +
1635
+ '<span class="is-overlay"></span>' +
1636
+ '</button>';
1637
+
1638
+ if(item.type === 'glide' || item.type === 'slick') {
1639
+ if(slider==='glide') {
1640
+ if(item.type === 'glide') {
1641
+ designList.insertAdjacentHTML('beforeend', html);
1642
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1643
+ btn.addEventListener('click', (e)=>{
1644
+ const designid = btn.getAttribute('data-id');
1645
+ addDesign(designid);
1646
+ });
1647
+ }
1648
+ } else if(slider==='slick') {
1649
+ if(item.type === 'slick') {
1650
+ designList.insertAdjacentHTML('beforeend', html);
1651
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1652
+ btn.addEventListener('click', (e)=>{
1653
+ const designid = btn.getAttribute('data-id');
1654
+ addDesign(designid);
1655
+ });
1656
+ }
1657
+ } else if(slider==='all') {
1658
+ designList.insertAdjacentHTML('beforeend', html);
1659
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1660
+ btn.addEventListener('click', (e)=>{
1661
+ const designid = btn.getAttribute('data-id');
1662
+ addDesign(designid);
1663
+ });
1664
+ }
1665
+ } else if(item.type === 'navbar' ) {
1666
+ if(navbar) {
1667
+ designList.insertAdjacentHTML('beforeend', html);
1668
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1669
+ btn.addEventListener('click', (e)=>{
1670
+ const designid = btn.getAttribute('data-id');
1671
+ addDesign(designid);
1672
+ });
1673
+ }
1674
+ } else {
1675
+ designList.insertAdjacentHTML('beforeend', html);
1676
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1677
+ btn.addEventListener('click', (e)=>{
1678
+ const designid = btn.getAttribute('data-id');
1679
+ addDesign(designid);
1680
+ });
1681
+ }
1682
+ }`;
1683
+ html += `
1684
+ nIndex++;
1685
+ });
1686
+ });
1687
+
1688
+ const arr = document.querySelectorAll('img.lzy-img')
1689
+ arr.forEach((v) => {
1690
+ imageObserver.observe(v);
1691
+ });
1692
+
1693
+ closeMegaMenu();
1694
+
1695
+ }, 200);
1696
+
1697
+ // Set active Button
1698
+ const menu = document.querySelector('.mega-menu');
1699
+ menu.setAttribute('data-active-cat', catId);
1700
+ const featuredCat = document.querySelector('.featured-categories');
1701
+ const btnActive1 = menu.querySelector('button.on');
1702
+ const btnActive2 = featuredCat.querySelector('button.on');
1703
+ if(btnActive1) btnActive1.classList.remove('on');
1704
+ if(btnActive2) btnActive2.classList.remove('on');
1705
+ const btn1 = menu.querySelector('[data-cat="' + catId + '"]');
1706
+ const btn2 = featuredCat.querySelector('[data-cat="' + catId + '"]');
1707
+ if(btn1) btn1.classList.add('on');
1708
+ if(btn2) btn2.classList.add('on');
1709
+ }
1710
+
1711
+ const renderMegaMenu = () => {
1712
+
1713
+ const wait2 = document.querySelector('.is-waiting2');
1714
+ wait2.style.display = 'none';
1715
+
1716
+ const menu = document.querySelector('.mega-menu');
1717
+ const menuContent = document.querySelector('.mega-menu-content');
1718
+ menuContent.innerHTML = '';
1719
+
1720
+ let catNum = 0;
1721
+ template_list.forEach(gallery=>{
1722
+ let categories = gallery.categories;
1723
+ let html = '<h2>' + gallery.name + '</h2><div class="cat' +catNum+ '"></div>';
1724
+ menuContent.insertAdjacentHTML('beforeend', html);
1725
+ const catList = menuContent.querySelector('.cat'+catNum);
1726
+ categories.forEach(categoryItem=>{
1727
+ let html= '<button data-cat="'+categoryItem.id+'">'+categoryItem.name+'</button>';
1728
+ catList.insertAdjacentHTML('beforeend', html);
1729
+ const btn = catList.querySelector('[data-cat="'+categoryItem.id+'"]');
1730
+ btn.addEventListener('click', (e)=>{
1731
+ const catId = btn.getAttribute('data-cat');
1732
+ showDesigns(catId);
1733
+
1734
+ closeMegaMenu();
1735
+ });
1736
+ });
1737
+
1738
+ catNum++;
1739
+ });
1740
+
1741
+ // Set active Button
1742
+ const catId = menu.getAttribute('data-active-cat');
1743
+ if(catId) {
1744
+ const btnActive = menu.querySelector('button.on');
1745
+ if(btnActive) btnActive.classList.remove('on');
1746
+ const btn = menu.querySelector('[data-cat="' + catId + '"]');
1747
+ if(btn) btn.classList.add('on');
1748
+ }
1749
+ }
1750
+
1751
+ const handleClick = (e) => {
1752
+ if(!e.target.closest('.mega-menu') && !e.target.closest('[data-cat="0"]')) {
1753
+ closeMegaMenu();
1754
+ }
1755
+ };
1756
+
1757
+ const showMegaMenu = () => {
1758
+ const menu = document.querySelector('.mega-menu');
1759
+ menu.style.display = 'block';
1760
+ setTimeout(()=>{
1761
+ menu.classList.add('active');
1762
+ const menuClose = menu.querySelector('.close');
1763
+ menuClose.focus();
1764
+ }, 10);
1765
+ const btn = document.querySelector('[data-cat="0"]');
1766
+ btn.classList.add('on');
1767
+
1768
+ document.addEventListener('click', handleClick); // handleClick
1769
+ }
1770
+
1771
+ const closeMegaMenu = () => {
1772
+ const menu = document.querySelector('.mega-menu.active');
1773
+ if(!menu) return;
1774
+ menu.classList.remove('active');
1775
+ setTimeout(()=>{
1776
+ menu.style.display = '';
1777
+ }, 300);
1778
+ const btn = document.querySelector('[data-cat="0"]');
1779
+ btn.classList.remove('on');
1780
+
1781
+ document.removeEventListener('keydown', handleClick); // handleClick
1782
+ }
1783
+
1784
+ const renderResize = () => {
1785
+ const btns = document.querySelectorAll('.featured-categories button');
1786
+ let viewportWidth = document.body.clientWidth;
1787
+ if(viewportWidth < 1024 && viewportWidth>=800) {
1788
+ let n = 0;
1789
+ btns.forEach(btn=>{
1790
+ if(n>=5) {
1791
+ btns[n].style.display = 'none';
1792
+ } else {
1793
+ btns[n].style.display = '';
1794
+ }
1795
+ n++;
1796
+ });
1797
+ } else if(viewportWidth < 800) {
1798
+ let n = 0;
1799
+ btns.forEach(btn=>{
1800
+ if(n>=2) {
1801
+ btns[n].style.display = 'none';
1802
+ } else {
1803
+ btns[n].style.display = '';
1804
+ }
1805
+ n++;
1806
+ });
1807
+ } else {
1808
+ let n = 0;
1809
+ btns.forEach(btn=>{
1810
+ btns[n].style.display = '';
1811
+ n++;
1812
+ });
1813
+ }
1814
+ btns[btns.length-1].style.display = '';
1815
+ };
1816
+
1817
+ const renderFeaturedCategories= () => {
1818
+ let html = '';
1819
+ const div = document.querySelector('.featured-categories');
1820
+ featuredCategories.forEach(item=>{
1821
+ html += '<button data-cat="'+item.id+'">'+item.name+'</button>';
1822
+ });
1823
+ html += '<button data-cat="0">All Categories</button>';
1824
+ div.insertAdjacentHTML('beforeend', html);
1825
+
1826
+ const menu = document.querySelector('.mega-menu');
1827
+ const btns = div.querySelectorAll('[data-cat]');
1828
+ btns.forEach(btn=>{
1829
+ btn.addEventListener('click', (e)=>{
1830
+ const catId = btn.getAttribute('data-cat');
1831
+ if(catId==='0') {
1832
+ // Show All Categories' Mega Menu
1833
+ showMegaMenu();
1834
+ } else {
1835
+ showDesigns(catId);
1836
+ }
1837
+ });
1838
+ });`;
1839
+ html += `
1840
+ const menuClose = menu.querySelector('.close');
1841
+ menuClose.addEventListener('click',()=>{
1842
+ closeMegaMenu();
1843
+ });
1844
+
1845
+ renderResize();
1846
+ }
1847
+
1848
+ document.addEventListener("DOMContentLoaded", function() {
1849
+
1850
+ renderFeaturedCategories();
1851
+
1852
+ const wait = document.querySelector('.is-waiting');
1853
+ wait.style.display = 'flex';
1854
+ const wait2 = document.querySelector('.is-waiting2');
1855
+ wait2.style.display = 'flex';
1856
+
1857
+ renderMegaMenu();
1858
+
1859
+ showDesigns(defaultCat); // If not ready (not loaded yet) will show empty
1860
+
1861
+ loadJsFiles(templateJSON, (template)=>{
1862
+ // console.log(template)
1863
+ const templateAdded = template_list[template_list.length-1];
1864
+ templateAdded.path = template.path;
1865
+ templateAdded.pathReplace = template.pathReplace;
1866
+ // console.log(templateAdded);
1867
+
1868
+ renderMegaMenu();
1869
+
1870
+ const designList = document.querySelector('.is-design-list');
1871
+ if(designList.innerHTML.trim()==='') { // first load
1872
+ const cats = templateAdded.categories;
1873
+ cats.forEach(cat=>{
1874
+ if(parseInt(cat.id)===defaultCat) {
1875
+ showDesigns(defaultCat);
1876
+ }
1877
+ });
1878
+ }
1879
+ });
1880
+ })
1881
+
1882
+
1883
+ document.addEventListener('keydown', (e)=>{
1884
+ if(e.keyCode === 27) { // escape key
1885
+
1886
+ const menu = document.querySelector('.mega-menu.active');
1887
+ if(menu) {
1888
+ closeMegaMenu();
1889
+
1890
+ e.preventDefault();
1891
+ return;
1892
+ }
1893
+ }
1894
+ });
1895
+
1896
+ window.addEventListener('resize', ()=>{
1897
+ renderResize();
1898
+ });
1899
+
1900
+ applyParentStyles();
1901
+
1902
+ // Style stuff
1903
+ function applyParentStyles() {
1904
+ var cssString = '' +
1905
+ 'body {' +
1906
+ 'background: ' + parent._cb.styleSnippetBackground + ';' +
1907
+ 'color: ' + parent._cb.styleSnippetColor + ';' +
1908
+ 'margin: 0;' +
1909
+ '}' +
1910
+
1911
+ 'button {' +
1912
+ 'background: ' + parent._cb.styleSnippetTabItemBackground + ';' +
1913
+ 'color: ' + parent._cb.styleSnippetTabItemColor + ';' +
1914
+ '}' +
1915
+ 'button.on {' +
1916
+ 'background: ' + parent._cb.styleSnippetTabItemBackgroundActive + ';' +
1917
+ '}' +
1918
+ '.featured-categories {' +
1919
+ 'background-color: ' + parent._cb.styleSnippetTabsBackground + ';' +
1920
+ '}' +
1921
+
1922
+ '.dark .is-design-list > button {' +
1923
+ 'border: transparent 1px solid;' +
1924
+ '}' +
1925
+
1926
+ '.mega-menu {' +
1927
+ 'background: ' + parent._cb.styleSnippetTabsBackground + ';' +
1928
+ '}' +
1929
+
1930
+ '/* Scrollbar for modal */' +
1931
+
1932
+ '/* Darker color, because background for snippet thumbnails is always light. */' +
1933
+ '.dark * {' +
1934
+ 'scrollbar-width: thin;' +
1935
+ 'scrollbar-color: rgb(78 78 78 / 62%) auto;' +
1936
+ '}' +
1937
+ '.dark *::-webkit-scrollbar {' +
1938
+ 'width: 12px;' +
1939
+ '}' +
1940
+ '.dark *::-webkit-scrollbar-track {' +
1941
+ 'background: transparent;' +
1942
+ '}' +
1943
+ '.dark *::-webkit-scrollbar-thumb {' +
1944
+ 'background-color:rgb(78 78 78 / 62%);' +
1945
+ '}' +
1946
+
1947
+ '.colored-dark * {' +
1948
+ 'scrollbar-width: thin;' +
1949
+ 'scrollbar-color: rgb(100, 100, 100) auto;' +
1950
+ '}' +
1951
+ '.colored-dark *::-webkit-scrollbar {' +
1952
+ 'width: 12px;' +
1953
+ '}' +
1954
+ '.colored-dark *::-webkit-scrollbar-track {' +
1955
+ 'background: transparent;' +
1956
+ '}' +
1957
+ '.colored-dark *::-webkit-scrollbar-thumb {' +
1958
+ 'background-color:rgb(100, 100, 100);' +
1959
+ '}' +
1960
+
1961
+ '.colored * {' +
1962
+ 'scrollbar-width: thin;' +
1963
+ 'scrollbar-color: rgba(0, 0, 0, 0.4) auto;' +
1964
+ '}' +
1965
+ '.colored *::-webkit-scrollbar {' +
1966
+ 'width: 12px;' +
1967
+ '}' +
1968
+ '.colored *::-webkit-scrollbar-track {' +
1969
+ 'background: transparent;' +
1970
+ '}' +
1971
+ '.colored *::-webkit-scrollbar-thumb {' +
1972
+ 'background-color: rgba(0, 0, 0, 0.4);' +
1973
+ '}' +
1974
+
1975
+ '.light * {' +
1976
+ 'scrollbar-width: thin;' +
1977
+ 'scrollbar-color: rgba(0, 0, 0, 0.4) auto;' +
1978
+ '}' +
1979
+ '.light *::-webkit-scrollbar {' +
1980
+ 'width: 12px;' +
1981
+ '}' +
1982
+ '.light *::-webkit-scrollbar-track {' +
1983
+ 'background: transparent;' +
1984
+ '}' +
1985
+ '.light *::-webkit-scrollbar-thumb {' +
1986
+ 'background-color: rgba(0, 0, 0, 0.4);' +
1987
+ '}' +
1988
+
1989
+ 'svg {' +
1990
+ 'fill: ' + parent._cb.styleSnippetColor + ';' +
1991
+ '}' +
1992
+
1993
+ '.dark .is-design-list>div .is-overlay:after {' +
1994
+ 'background: rgb(78 78 78 / 13%);' +
1995
+ '}' +
1996
+ '';
1997
+
1998
+ let themestyle = document.querySelector('[data-theme-style]');
1999
+ if(themestyle) themestyle.parentNode.removeChild(themestyle);
2000
+
2001
+ var style = document.createElement("style");
2002
+ style.setAttribute('data-theme-style','');
2003
+ style.type = "text/css";
2004
+ style.innerHTML = cssString;
2005
+ document.head.appendChild(style);
2006
+
2007
+ if(parent._cb.styleDark) {
2008
+ document.body.setAttribute('class', 'dark');
2009
+ } else if(parent._cb.styleColored) {
2010
+ document.body.setAttribute('class', 'colored');
2011
+ } else if(parent._cb.styleColoredDark) {
2012
+ document.body.setAttribute('class', 'colored-dark');
2013
+ } else if(parent._cb.styleLight) {
2014
+ document.body.setAttribute('class', 'light');
2015
+ } else {
2016
+ document.body.setAttribute('class', '');
2017
+ }
2018
+ }
2019
+ </script>
2020
+ </body>
2021
+ </html>
2022
+ `;
2023
+ return html;
2024
+ }
2025
+
2026
+ getTemplatesHtml_OLD() {
1124
2027
  const designUrl1 = this.builder.designUrl1;
1125
2028
  const designUrl2 = this.builder.designUrl2;
1126
2029
  let html = `
@@ -89783,11 +90686,59 @@ class ContentBox {
89783
90686
  designUrl2: 'assets/designs/examples.js',
89784
90687
  designPath: 'assets/designs/',
89785
90688
  designPathReplace: [],
89786
- // Example:
89787
- // designUrl1: 'https://.../assets/designs/basic.js',
89788
- // designUrl2: 'https://.../assets/designs/examples.js',
89789
- // designPath: 'https://.../assets/designs/',
89790
- // designPathReplace: ['assets/', 'https://.../assets/'],
90689
+
90690
+ /*
90691
+ Example:
90692
+ designUrl1: 'https://.../assets/designs/basic.js',
90693
+ designUrl2: 'https://.../assets/designs/examples.js',
90694
+ designPath: 'https://.../assets/designs/',
90695
+ designPathReplace: ['assets/', 'https://.../assets/'], // Only if needed
90696
+ */
90697
+ templates: [],
90698
+ // ver.5.3
90699
+
90700
+ /*
90701
+ Example: => this will replace the previous approach (designUrl1, designUrl2, designPath & designPathReplace)
90702
+ templates: [
90703
+ {
90704
+ url: 'assets/designs/basic.js',
90705
+ path: 'assets/designs/',
90706
+ pathReplace: []
90707
+ },
90708
+ {
90709
+ url: 'assets/designs/examples.js',
90710
+ path: 'assets/designs/',
90711
+ pathReplace: []
90712
+ },
90713
+ {
90714
+ url: 'assets/writing-set/basic.js',
90715
+ path: 'assets/writing-set/',
90716
+ pathReplace: []
90717
+ }
90718
+ ]
90719
+ */
90720
+ featuredCategories: [{
90721
+ id: 5,
90722
+ name: 'Random'
90723
+ }, // If apos ' is used, use: \\\'
90724
+ {
90725
+ id: 1,
90726
+ name: 'Basic'
90727
+ }, {
90728
+ id: 2,
90729
+ name: 'Slider'
90730
+ }, {
90731
+ id: 101,
90732
+ name: 'Header'
90733
+ }, {
90734
+ id: 118,
90735
+ name: 'Article'
90736
+ }, {
90737
+ id: 102,
90738
+ name: 'Photos'
90739
+ }],
90740
+ templateThumbnailSize: '',
90741
+ //small, medium, large or '' (empty => dynamic)
89791
90742
  // ContentBuilder
89792
90743
  scriptPath: '',
89793
90744
  snippetUrl: 'assets/minimalist-blocks/content.js',
@@ -90544,7 +91495,8 @@ class ContentBox {
90544
91495
  'category': 1,
90545
91496
  'default': false,
90546
91497
  'caption': 'Poppins & Lekton'
90547
- }, {
91498
+ }, // { 'css': 'basetype-poppins-lekton-v2.css', 'sectioncss': 'type-poppins-lekton-v2.css', 'classname': 'type-poppins-lekton-v2', 'img': '099.png', 'category': 1, 'default': false, 'caption': 'Poppins & Lekton v2' },
91499
+ {
90548
91500
  'css': 'basetype-raleway-neuton.css',
90549
91501
  'sectioncss': 'type-raleway-neuton.css',
90550
91502
  'classname': 'type-raleway-neuton',
@@ -92153,6 +93105,28 @@ class ContentBox {
92153
93105
  contentHtmlEnd: '</div></div></div>'
92154
93106
  };
92155
93107
  this.settings = Object.assign(this, defaults, settings);
93108
+ this.templateJSON = [{
93109
+ url: this.settings.designUrl1,
93110
+ path: this.settings.designPath,
93111
+ pathReplace: this.settings.designPathReplace
93112
+ }, {
93113
+ url: this.settings.designUrl2,
93114
+ path: this.settings.designPath,
93115
+ pathReplace: this.settings.designPathReplace
93116
+ }];
93117
+
93118
+ if (this.settings.templates.length !== 0 && this.settings.templateThumbnailSize === '') {
93119
+ // this.settings.templateThumbnailSize = 'large';
93120
+ let viewportWidth = document.body.clientWidth;
93121
+
93122
+ if (viewportWidth <= 1440) {
93123
+ this.settings.templateThumbnailSize = 'small';
93124
+ } else if (viewportWidth > 1440 && viewportWidth <= 1920) {
93125
+ this.settings.templateThumbnailSize = 'medium';
93126
+ } else {
93127
+ this.settings.templateThumbnailSize = 'large';
93128
+ }
93129
+ }
92156
93130
 
92157
93131
  if (this.settings.imageSelect !== '') {
92158
93132
  this.settings.imageselect = this.settings.imageSelect;