@innovastudio/contentbox 1.4.3 → 1.4.4

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,840 @@ 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
+
1156
+ if (this.builder.templateThumbnailSize === 'small') {
1157
+ thumbWidth = '250px';
1158
+ thumbMargin = '30px 0 0 30px';
1159
+ } else if (this.builder.templateThumbnailSize === 'medium') {
1160
+ thumbWidth = '350px';
1161
+ thumbMargin = '40px 0 0 40px';
1162
+ } else {
1163
+ thumbWidth = '450px'; // '500px';
1164
+
1165
+ thumbMargin = '50px 0 0 50px'; // '62px 0 0 60px';
1166
+ }
1167
+
1168
+ let html = `
1169
+ <!DOCTYPE html>
1170
+ <html lang="en">
1171
+ <head>
1172
+ <meta charset="utf-8">
1173
+ <title>Browse</title>
1174
+ <meta name="viewport" content="width=device-width, initial-scale=1">
1175
+ <meta name="description" content="">
1176
+ <link rel="shortcut icon" href="#" />
1177
+ <style>
1178
+ body {
1179
+ margin: 0;
1180
+ background: #fff;
1181
+ font-family: sans-serif;
1182
+ font-weight: 300;
1183
+ }
1184
+ h2 {
1185
+ font-weight: 300;
1186
+ }
1187
+ button {
1188
+ cursor: pointer;
1189
+ border: none;
1190
+ background: #fdfdfd;
1191
+ padding: 12px 25px;
1192
+ border-radius: 500px;
1193
+ font-size: 11px;
1194
+ text-transform: uppercase;
1195
+ letter-spacing: 1px;;
1196
+ color: #333;
1197
+ }
1198
+ button.on {
1199
+ background: #f5f5f5;
1200
+ }
1201
+
1202
+ .featured-categories {
1203
+ background-color: #f5f5f5;
1204
+ position: absolute;
1205
+ width: 100%;
1206
+ height: 88px;
1207
+ z-index: 1;
1208
+ padding: 14px 15px 0 25px;
1209
+ box-sizing: border-box;
1210
+ /* box-shadow: 0 5px 15px rgb(0 0 0 / 5%); */
1211
+ }
1212
+ .featured-categories button {
1213
+ margin: 10px 15px 0 0;
1214
+ font-size: 11px;
1215
+ }
1216
+
1217
+ .is-design-list {
1218
+ position: fixed;
1219
+ top: 0px;
1220
+ left: 0px;
1221
+ border-top: transparent 88px solid;
1222
+ width: 100%;
1223
+ height: 100%;
1224
+ overflow-y: auto;
1225
+ padding: 0px 0px 30px 0px;
1226
+ box-sizing: border-box;
1227
+ overflow: auto;
1228
+ transition: all 200ms ease;
1229
+ }
1230
+ .is-design-list > button {
1231
+ position: relative;
1232
+ width: ${thumbWidth};;
1233
+ overflow: hidden;
1234
+ margin: ${thumbMargin};
1235
+ cursor: pointer;
1236
+ display: inline-block;
1237
+ padding: 0px;
1238
+ border: rgba(219, 219, 219, 0.39) 1px solid;
1239
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
1240
+ border-radius: 2px;
1241
+ }
1242
+ .is-design-list > button img {
1243
+ box-shadow: none;
1244
+ opacity: 1;
1245
+ display: block;
1246
+ box-sizing: border-box;
1247
+ transition: all 0.2s ease-in-out;
1248
+ max-width: 500px;
1249
+ width: 100%
1250
+ }
1251
+ .is-design-list > button .is-overlay {
1252
+ position: absolute;
1253
+ top:0px;
1254
+ left:0px;
1255
+ width:100%;
1256
+ height:100%;
1257
+ }
1258
+ .is-design-list > button .is-overlay:after {
1259
+ background: rgba(0, 0, 0, 0.05);
1260
+ position: absolute;
1261
+ content: "";
1262
+ display: block;
1263
+ top: 0;
1264
+ left: 0;
1265
+ right: 0;
1266
+ bottom: 0;
1267
+ transition: all 0.2s ease-in-out;
1268
+ opacity: 0;
1269
+ }
1270
+ .is-design-list > button:hover .is-overlay:after {
1271
+ opacity: 0.5;
1272
+ }
1273
+
1274
+ .mega-menu {
1275
+ display: none;
1276
+ transform: translateY(-100%);
1277
+ background: #f5f5f5;
1278
+ overflow-x: hidden;
1279
+ overflow-y: auto;
1280
+ position: fixed;
1281
+ top: 88px;
1282
+ left: 0;
1283
+ right: 0;
1284
+ width: 100%;
1285
+ height: auto;
1286
+ z-index: 1;
1287
+ padding: 10px 50px 40px 40px;
1288
+ box-sizing: border-box;
1289
+ transition: all 300ms ease;
1290
+ min-width:400px;
1291
+ /* box-shadow: 0 5px 15px rgb(0 0 0 / 5%); */
1292
+ }
1293
+ .mega-menu.active {
1294
+ opacity: 1;
1295
+ transform: scale(1);
1296
+ transform: translateY(0);
1297
+ }
1298
+ .mega-menu h2 {
1299
+ margin-top:30px;
1300
+ font-size: 21px
1301
+ }
1302
+ .mega-menu button {
1303
+ margin:15px 15px 0 0;
1304
+ }
1305
+ .mega-menu .close {
1306
+ position: absolute;
1307
+ top: 0px; right: 0px;
1308
+ background: transparent;
1309
+ width: 50px;
1310
+ height: 50px;
1311
+ display: flex;
1312
+ justify-content: center;
1313
+ align-items: center;
1314
+ border-radius: 2px;;
1315
+ }
1316
+ </style>
1317
+ </head>
1318
+ <body style="touch-action: pan-y">`;
1319
+ html += `
1320
+ <div class="mega-menu">
1321
+ <button class="close" tabindex="0"><svg style="width:40px;height:40px;flex:none;"><use xlink:href="#iconclose"></use></svg></button>
1322
+
1323
+ <div class="mega-menu-content">
1324
+ </div>
1325
+ </div>
1326
+
1327
+ <div class="featured-categories">
1328
+ </div>
1329
+
1330
+ <div class="is-design-list">
1331
+ </div>
1332
+
1333
+
1334
+ <svg width="0" height="0" style="position:absolute;display:none;">
1335
+ <defs>
1336
+ <symbol viewBox="0 0 24 24" id="iconclose" stroke-width="0.7" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
1337
+ <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>
1338
+ </symbol>
1339
+ </defs>
1340
+ </svg>
1341
+
1342
+ <script>
1343
+ var template_list = [];
1344
+ </script>
1345
+ <!-- <script src="basic.js" type="text/javascript"></script>
1346
+ <script src="examples.js" type="text/javascript"></script> -->
1347
+
1348
+ <script>
1349
+
1350
+ // Configuration
1351
+ const featuredCategories = [
1352
+ ${sCategories}
1353
+ ];
1354
+ const defaultCat = ${this.builder.defaultDesignCategory};
1355
+ const navbar = ${this.builder.navbar ? 'true' : 'false'};
1356
+
1357
+ const slider = '${this.builder.slider}';
1358
+
1359
+ const framework = '${this.builder.framework}';
1360
+ const contentStylePath = '${this.builder.contentStylePath}';
1361
+
1362
+ let templates = [
1363
+ ${sTemplates}
1364
+ ];
1365
+
1366
+ let templateJSON = [
1367
+ ${sTemplateJSON}
1368
+ ];
1369
+ // /Configuration
1370
+
1371
+ if(templates.length > 0) templateJSON = [...templates];
1372
+
1373
+ const loadJsFiles = (list, callback) => {
1374
+ if(list.length===0) {
1375
+ return;
1376
+ } else {
1377
+ const url = list[0].url;
1378
+ const script = document.createElement('script');
1379
+ script.src = url;
1380
+ script.async = true;
1381
+ script.onload = () => {
1382
+ callback(list[0]);
1383
+ loadJsFiles(list.slice(1), callback);
1384
+ };
1385
+ document.body.appendChild(script);
1386
+ }
1387
+ }
1388
+
1389
+ const imageObserver = new IntersectionObserver((entries, imgObserver) => {
1390
+ entries.forEach((entry) => {
1391
+ if (entry.isIntersecting) {
1392
+ const lazyImage = entry.target
1393
+ // console.log("lazy loading ", lazyImage)
1394
+ lazyImage.src = lazyImage.dataset.src
1395
+ lazyImage.classList.remove("lzy-img");
1396
+ imgObserver.unobserve(lazyImage);
1397
+ }
1398
+ })
1399
+ });
1400
+
1401
+ const makeid = () => { //http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
1402
+ var text = "";
1403
+ var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
1404
+ for (var i = 0; i < 2; i++)
1405
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
1406
+
1407
+ var text2 = "";
1408
+ var possible2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1409
+ for (var i = 0; i < 5; i++)
1410
+ text2 += possible2.charAt(Math.floor(Math.random() * possible2.length));
1411
+
1412
+ return text + text2;
1413
+ }
1414
+
1415
+ const addDesign = (designid) => {
1416
+
1417
+ const wrapper = parent._cb.doc.querySelector('.is-wrapper');
1418
+
1419
+ let nIndex = 0;
1420
+ template_list.forEach(gallery=>{
1421
+ let designs = gallery.designs;
1422
+ designs.forEach(item=>{
1423
+
1424
+ item.id = nIndex; //Give id
1425
+
1426
+ if(nIndex===parseInt(designid)) {
1427
+ // alert(item.html);
1428
+ // alert(gallery.path);
1429
+ // alert(gallery.pathReplace);
1430
+
1431
+ let html = item.html;
1432
+ let googleFonts = item.googleFonts;
1433
+ let contentCss = item.contentCss;
1434
+ let contentClass = item.contentClass;
1435
+
1436
+ let designPath = gallery.path;
1437
+ let snippetPathReplace = gallery.pathReplace;
1438
+
1439
+ //To Tailwind
1440
+ if (framework == 'tailwind') {
1441
+ html = html.replace(new RegExp(' container', 'g'), ' container');
1442
+ html = html.replace(new RegExp('row clearfix', 'g'), 'flex flex-col md:flex-row');
1443
+ html = html.replace(new RegExp('column full', 'g'), 'w-full px-4');
1444
+ html = html.replace(new RegExp('column half', 'g'), 'w-full md:w-6/12 px-4');
1445
+ html = html.replace(new RegExp('column third', 'g'), 'w-full md:w-4/12 px-4');
1446
+ html = html.replace(new RegExp('column fourth', 'g'), 'w-full md:w-3/12 px-4');
1447
+ html = html.replace(new RegExp('column fifth', 'g'), 'w-full md:w-2/12 px-4'); //not needed
1448
+ html = html.replace(new RegExp('column sixth', 'g'), 'w-full md:w-2/12 px-4');
1449
+ html = html.replace(new RegExp('column two-third', 'g'), 'w-full md:w-8/12 px-4');
1450
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'w-full md:w-9/12 px-4');
1451
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'w-full md:w-10/12 px-4');
1452
+ }
1453
+
1454
+ //To Bootstrap
1455
+ if (framework == 'bootstrap') {
1456
+ html = html.replace(new RegExp(' container', 'g'), ' container-fluid');
1457
+ html = html.replace(new RegExp('row clearfix', 'g'), 'row');
1458
+ html = html.replace(new RegExp('column full', 'g'), 'col-md-12');
1459
+ html = html.replace(new RegExp('column half', 'g'), 'col-md-6');
1460
+ html = html.replace(new RegExp('column third', 'g'), 'col-md-4');
1461
+ html = html.replace(new RegExp('column fourth', 'g'), 'col-md-3');
1462
+ html = html.replace(new RegExp('column fifth', 'g'), 'col-md-2');
1463
+ html = html.replace(new RegExp('column sixth', 'g'), 'col-md-2');
1464
+ html = html.replace(new RegExp('column two-third', 'g'), 'col-md-8');
1465
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'col-md-9');
1466
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'col-md-10');
1467
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'btn btn-primary btn-lg');
1468
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'btn btn-default btn-lg');
1469
+ }`;
1470
+ html += `
1471
+ //To Foundation
1472
+ if (framework == 'foundation') {
1473
+ //html = html.replace(new RegExp(' container', 'g'), ' container');
1474
+ html = html.replace(new RegExp('row clearfix', 'g'), 'row');
1475
+ html = html.replace(new RegExp('column full', 'g'), 'large-12 columns');
1476
+ html = html.replace(new RegExp('column half', 'g'), 'large-6 columns');
1477
+ html = html.replace(new RegExp('column third', 'g'), 'large-4 columns');
1478
+ html = html.replace(new RegExp('column fourth', 'g'), 'large-3 columns');
1479
+ html = html.replace(new RegExp('column fifth', 'g'), 'large-2 columns');
1480
+ html = html.replace(new RegExp('column sixth', 'g'), 'large-2 columns');
1481
+ html = html.replace(new RegExp('column two-third', 'g'), 'large-8 columns');
1482
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'large-9 columns');
1483
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'large-10 columns');
1484
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'button');
1485
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'secondary button');
1486
+ }
1487
+
1488
+ //To UIKit
1489
+ if (framework == 'uikit') {
1490
+ html = html.replace(new RegExp(' container', 'g'), ' uk-container uk-container-center');
1491
+ html = html.replace(new RegExp('row clearfix', 'g'), 'uk-grid');
1492
+ html = html.replace(new RegExp('column full', 'g'), 'uk-width-1-1');
1493
+ html = html.replace(new RegExp('column half', 'g'), 'uk-width-1-2');
1494
+ html = html.replace(new RegExp('column third', 'g'), 'uk-width-1-3');
1495
+ html = html.replace(new RegExp('column fourth', 'g'), 'uk-width-1-4');
1496
+ html = html.replace(new RegExp('column fifth', 'g'), 'uk-width-1-5');
1497
+ html = html.replace(new RegExp('column sixth', 'g'), 'uk-width-1-6');
1498
+ html = html.replace(new RegExp('column two-third', 'g'), 'uk-width-2-3');
1499
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'uk-width-3-4');
1500
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'uk-width-5-6');
1501
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'uk-button uk-button-primary uk-button-large');
1502
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'uk-button uk-button-large');
1503
+ }
1504
+
1505
+ //To Material
1506
+ if (framework == 'material') {
1507
+ html = html.replace(new RegExp(' container', 'g'), '');
1508
+ html = html.replace(new RegExp('row clearfix', 'g'), 'mdl-grid');
1509
+ html = html.replace(new RegExp('column full', 'g'), 'mdl-cell mdl-cell--12-col');
1510
+ html = html.replace(new RegExp('column half', 'g'), 'mdl-cell mdl-cell--6-col');
1511
+ html = html.replace(new RegExp('column third', 'g'), 'mdl-cell mdl-cell--4-col');
1512
+ html = html.replace(new RegExp('column fourth', 'g'), 'mdl-cell mdl-cell--3-col');
1513
+ html = html.replace(new RegExp('column fifth', 'g'), 'mdl-cell mdl-cell--2-col');
1514
+ html = html.replace(new RegExp('column sixth', 'g'), 'mdl-cell mdl-cell--2-col');
1515
+ html = html.replace(new RegExp('column two-third', 'g'), 'mdl-cell mdl-cell--8-col');
1516
+ html = html.replace(new RegExp('column two-fourth', 'g'), 'mdl-cell mdl-cell--9-col');
1517
+ html = html.replace(new RegExp('column two-sixth', 'g'), 'mdl-cell mdl-cell--10-col');
1518
+ html = html.replace(new RegExp('btn btn-primary', 'g'), 'mdl-button mdl-js-button mdl-button--raised mdl-button--accent');
1519
+ html = html.replace(new RegExp('btn btn-default', 'g'), 'mdl-button mdl-js-button mdl-button--raised');
1520
+ }
1521
+
1522
+ html = html.replace(/{id}/g, makeid());
1523
+
1524
+ if(snippetPathReplace.length>0) {
1525
+ if (snippetPathReplace[0] != '') {
1526
+ var regex = new RegExp(snippetPathReplace[0], 'g');
1527
+ html = html.replace(regex, snippetPathReplace[1]);
1528
+ }
1529
+ }
1530
+
1531
+ html = html.replace(/\\[%IMAGE_PATH%\\]/g, designPath);
1532
+ html = html.replace(/%5B%25IMAGE_PATH%25%5D/g, designPath); //If [%IMAGE_PATH%] is encoded (inside data-html)
1533
+
1534
+ //Add html
1535
+ parent.contentbox.addIdea(html);
1536
+
1537
+ //Add contentCss
1538
+ let exist = false;
1539
+ let links = parent._cb.doc.getElementsByTagName("link");
1540
+ for (let i = 0; i < links.length; i++) {
1541
+ let src = links[i].href.toLowerCase();
1542
+ if (src.indexOf(contentCss.toLowerCase()) != -1) exist = true;
1543
+ }
1544
+
1545
+ if (!exist) wrapper.insertAdjacentHTML('beforeend', '<link data-name="contentstyle" data-class="' + contentClass + '" href="' + contentStylePath + contentCss + '" rel="stylesheet">');
1546
+ }
1547
+
1548
+ nIndex++;
1549
+ });
1550
+ });
1551
+ }
1552
+
1553
+ const showDesigns = (catId) => {
1554
+
1555
+ const designList = document.querySelector('.is-design-list');
1556
+ designList.style.opacity = 0;
1557
+ setTimeout(()=>{
1558
+ designList.innerHTML = '';
1559
+ designList.style.opacity = 1;
1560
+
1561
+ let nIndex = 0;
1562
+
1563
+ template_list.forEach(gallery=>{
1564
+ let designs = gallery.designs;
1565
+ designs.forEach(item=>{
1566
+ let isSelected = false;
1567
+ let catSplit = item.category.split(',');
1568
+ for (let j = 0; j < catSplit.length; j++) {
1569
+ if (parseInt(catSplit[j]) === parseInt(catId)) {
1570
+ isSelected = true;
1571
+ }
1572
+ }
1573
+
1574
+ item.id = nIndex; //Give id
1575
+
1576
+ if (isSelected) {
1577
+
1578
+ let html = '<button tabindex="0" class="active" data-id="' + item.id + '" data-cat=""' + item.category + '">' +
1579
+ '<img class="lzy-img" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=" data-src="' + gallery.path + item.thumbnail + '">' +
1580
+ '<span class="is-overlay"></span>' +
1581
+ '</button>';
1582
+
1583
+ if(item.type === 'glide' || item.type === 'slick') {
1584
+ if(slider==='glide') {
1585
+ if(item.type === 'glide') {
1586
+ designList.insertAdjacentHTML('beforeend', html);
1587
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1588
+ btn.addEventListener('click', (e)=>{
1589
+ const designid = btn.getAttribute('data-id');
1590
+ addDesign(designid);
1591
+ });
1592
+ }
1593
+ } else if(slider==='slick') {
1594
+ if(item.type === 'slick') {
1595
+ designList.insertAdjacentHTML('beforeend', html);
1596
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1597
+ btn.addEventListener('click', (e)=>{
1598
+ const designid = btn.getAttribute('data-id');
1599
+ addDesign(designid);
1600
+ });
1601
+ }
1602
+ } else if(slider==='all') {
1603
+ designList.insertAdjacentHTML('beforeend', html);
1604
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1605
+ btn.addEventListener('click', (e)=>{
1606
+ const designid = btn.getAttribute('data-id');
1607
+ addDesign(designid);
1608
+ });
1609
+ }
1610
+ } else if(item.type === 'navbar' ) {
1611
+ if(navbar) {
1612
+ designList.insertAdjacentHTML('beforeend', html);
1613
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1614
+ btn.addEventListener('click', (e)=>{
1615
+ const designid = btn.getAttribute('data-id');
1616
+ addDesign(designid);
1617
+ });
1618
+ }
1619
+ } else {
1620
+ designList.insertAdjacentHTML('beforeend', html);
1621
+ const btn = designList.querySelector('[data-id="' + item.id + '"]');
1622
+ btn.addEventListener('click', (e)=>{
1623
+ const designid = btn.getAttribute('data-id');
1624
+ addDesign(designid);
1625
+ });
1626
+ }
1627
+ }`;
1628
+ html += `
1629
+ nIndex++;
1630
+ });
1631
+ });
1632
+
1633
+ const arr = document.querySelectorAll('img.lzy-img')
1634
+ arr.forEach((v) => {
1635
+ imageObserver.observe(v);
1636
+ });
1637
+
1638
+ closeMegaMenu();
1639
+
1640
+ }, 200);
1641
+
1642
+ // Set active Button
1643
+ const menu = document.querySelector('.mega-menu');
1644
+ menu.setAttribute('data-active-cat', catId);
1645
+ const featuredCat = document.querySelector('.featured-categories');
1646
+ const btnActive1 = menu.querySelector('button.on');
1647
+ const btnActive2 = featuredCat.querySelector('button.on');
1648
+ if(btnActive1) btnActive1.classList.remove('on');
1649
+ if(btnActive2) btnActive2.classList.remove('on');
1650
+ const btn1 = menu.querySelector('[data-cat="' + catId + '"]');
1651
+ const btn2 = featuredCat.querySelector('[data-cat="' + catId + '"]');
1652
+ if(btn1) btn1.classList.add('on');
1653
+ if(btn2) btn2.classList.add('on');
1654
+ }
1655
+
1656
+ const renderMegaMenu = () => {
1657
+
1658
+ const menu = document.querySelector('.mega-menu');
1659
+ const menuContent = document.querySelector('.mega-menu-content');
1660
+ menuContent.innerHTML = '';
1661
+
1662
+ let catNum = 0;
1663
+ template_list.forEach(gallery=>{
1664
+ let categories = gallery.categories;
1665
+ let html = '<h2>' + gallery.name + '</h2><div class="cat' +catNum+ '"></div>';
1666
+ menuContent.insertAdjacentHTML('beforeend', html);
1667
+ const catList = menuContent.querySelector('.cat'+catNum);
1668
+ categories.forEach(categoryItem=>{
1669
+ let html= '<button data-cat="'+categoryItem.id+'">'+categoryItem.name+'</button>';
1670
+ catList.insertAdjacentHTML('beforeend', html);
1671
+ const btn = catList.querySelector('[data-cat="'+categoryItem.id+'"]');
1672
+ btn.addEventListener('click', (e)=>{
1673
+ const catId = btn.getAttribute('data-cat');
1674
+ showDesigns(catId);
1675
+
1676
+ closeMegaMenu();
1677
+ });
1678
+ });
1679
+
1680
+ catNum++;
1681
+ });
1682
+
1683
+ // Set active Button
1684
+ const catId = menu.getAttribute('data-active-cat');
1685
+ if(catId) {
1686
+ const btnActive = menu.querySelector('button.on');
1687
+ if(btnActive) btnActive.classList.remove('on');
1688
+ const btn = menu.querySelector('[data-cat="' + catId + '"]');
1689
+ if(btn) btn.classList.add('on');
1690
+ }
1691
+ }
1692
+
1693
+ const handleClick = (e) => {
1694
+ if(!e.target.closest('.mega-menu') && !e.target.closest('[data-cat="0"]')) {
1695
+ closeMegaMenu();
1696
+ }
1697
+ };
1698
+
1699
+ const showMegaMenu = () => {
1700
+ const menu = document.querySelector('.mega-menu');
1701
+ menu.style.display = 'block';
1702
+ setTimeout(()=>{
1703
+ menu.classList.add('active');
1704
+ const menuClose = menu.querySelector('.close');
1705
+ menuClose.focus();
1706
+ }, 10);
1707
+ const btn = document.querySelector('[data-cat="0"]');
1708
+ btn.classList.add('on');
1709
+
1710
+ document.addEventListener('click', handleClick); // handleClick
1711
+ }
1712
+
1713
+ const closeMegaMenu = () => {
1714
+ const menu = document.querySelector('.mega-menu.active');
1715
+ if(!menu) return;
1716
+ menu.classList.remove('active');
1717
+ setTimeout(()=>{
1718
+ menu.style.display = '';
1719
+ }, 300);
1720
+ const btn = document.querySelector('[data-cat="0"]');
1721
+ btn.classList.remove('on');
1722
+
1723
+ document.removeEventListener('keydown', handleClick); // handleClick
1724
+ }
1725
+
1726
+ const renderResize = () => {
1727
+ const btns = document.querySelectorAll('.featured-categories button');
1728
+ let viewportWidth = document.body.clientWidth;
1729
+ if(viewportWidth < 1024 && viewportWidth>=800) {
1730
+ let n = 0;
1731
+ btns.forEach(btn=>{
1732
+ if(n>=5) {
1733
+ btns[n].style.display = 'none';
1734
+ } else {
1735
+ btns[n].style.display = '';
1736
+ }
1737
+ n++;
1738
+ });
1739
+ } else if(viewportWidth < 800) {
1740
+ let n = 0;
1741
+ btns.forEach(btn=>{
1742
+ if(n>=2) {
1743
+ btns[n].style.display = 'none';
1744
+ } else {
1745
+ btns[n].style.display = '';
1746
+ }
1747
+ n++;
1748
+ });
1749
+ } else {
1750
+ let n = 0;
1751
+ btns.forEach(btn=>{
1752
+ btns[n].style.display = '';
1753
+ n++;
1754
+ });
1755
+ }
1756
+ btns[btns.length-1].style.display = '';
1757
+ };
1758
+
1759
+ const renderFeaturedCategories= () => {
1760
+ let html = '';
1761
+ const div = document.querySelector('.featured-categories');
1762
+ featuredCategories.forEach(item=>{
1763
+ html += '<button data-cat="'+item.id+'">'+item.name+'</button>';
1764
+ });
1765
+ html += '<button data-cat="0">All Categories</button>';
1766
+ div.insertAdjacentHTML('beforeend', html);
1767
+
1768
+ const menu = document.querySelector('.mega-menu');
1769
+ const btns = div.querySelectorAll('[data-cat]');
1770
+ btns.forEach(btn=>{
1771
+ btn.addEventListener('click', (e)=>{
1772
+ const catId = btn.getAttribute('data-cat');
1773
+ if(catId==='0') {
1774
+ // Show All Categories' Mega Menu
1775
+ showMegaMenu();
1776
+ } else {
1777
+ showDesigns(catId);
1778
+ }
1779
+ });
1780
+ });`;
1781
+ html += `
1782
+ const menuClose = menu.querySelector('.close');
1783
+ menuClose.addEventListener('click',()=>{
1784
+ closeMegaMenu();
1785
+ });
1786
+
1787
+ renderResize();
1788
+ }
1789
+
1790
+ document.addEventListener("DOMContentLoaded", function() {
1791
+
1792
+ renderFeaturedCategories();
1793
+
1794
+ renderMegaMenu();
1795
+
1796
+ showDesigns(defaultCat); // If not ready (not loaded yet) will show empty
1797
+
1798
+ loadJsFiles(templateJSON, (template)=>{
1799
+ // console.log(template)
1800
+ const templateAdded = template_list[template_list.length-1];
1801
+ templateAdded.path = template.path;
1802
+ templateAdded.pathReplace = template.pathReplace;
1803
+ // console.log(templateAdded);
1804
+
1805
+ renderMegaMenu();
1806
+
1807
+ const designList = document.querySelector('.is-design-list');
1808
+ if(designList.innerHTML.trim()==='') { // first load
1809
+ const cats = templateAdded.categories;
1810
+ cats.forEach(cat=>{
1811
+ if(parseInt(cat.id)===defaultCat) {
1812
+ showDesigns(defaultCat);
1813
+ }
1814
+ });
1815
+ }
1816
+ });
1817
+ })
1818
+
1819
+
1820
+ document.addEventListener('keydown', (e)=>{
1821
+ if(e.keyCode === 27) { // escape key
1822
+
1823
+ const menu = document.querySelector('.mega-menu.active');
1824
+ if(menu) {
1825
+ closeMegaMenu();
1826
+
1827
+ e.preventDefault();
1828
+ return;
1829
+ }
1830
+ }
1831
+ });
1832
+
1833
+ window.addEventListener('resize', ()=>{
1834
+ renderResize();
1835
+ });
1836
+
1837
+ applyParentStyles();
1838
+
1839
+ // Style stuff
1840
+ function applyParentStyles() {
1841
+ var cssString = '' +
1842
+ 'body {' +
1843
+ 'background: ' + parent._cb.styleSnippetBackground + ';' +
1844
+ 'color: ' + parent._cb.styleSnippetColor + ';' +
1845
+ 'margin: 0;' +
1846
+ '}' +
1847
+
1848
+ 'button {' +
1849
+ 'background: ' + parent._cb.styleSnippetTabItemBackground + ';' +
1850
+ 'color: ' + parent._cb.styleSnippetTabItemColor + ';' +
1851
+ '}' +
1852
+ 'button.on {' +
1853
+ 'background: ' + parent._cb.styleSnippetTabItemBackgroundActive + ';' +
1854
+ '}' +
1855
+ '.featured-categories {' +
1856
+ 'background-color: ' + parent._cb.styleSnippetTabsBackground + ';' +
1857
+ '}' +
1858
+
1859
+ '.dark .is-design-list > button {' +
1860
+ 'border: transparent 1px solid;' +
1861
+ '}' +
1862
+
1863
+ '.mega-menu {' +
1864
+ 'background: ' + parent._cb.styleSnippetTabsBackground + ';' +
1865
+ '}' +
1866
+
1867
+ '/* Scrollbar for modal */' +
1868
+
1869
+ '/* Darker color, because background for snippet thumbnails is always light. */' +
1870
+ '.dark * {' +
1871
+ 'scrollbar-width: thin;' +
1872
+ 'scrollbar-color: rgb(78 78 78 / 62%) auto;' +
1873
+ '}' +
1874
+ '.dark *::-webkit-scrollbar {' +
1875
+ 'width: 12px;' +
1876
+ '}' +
1877
+ '.dark *::-webkit-scrollbar-track {' +
1878
+ 'background: transparent;' +
1879
+ '}' +
1880
+ '.dark *::-webkit-scrollbar-thumb {' +
1881
+ 'background-color:rgb(78 78 78 / 62%);' +
1882
+ '}' +
1883
+
1884
+ '.colored-dark * {' +
1885
+ 'scrollbar-width: thin;' +
1886
+ 'scrollbar-color: rgb(100, 100, 100) auto;' +
1887
+ '}' +
1888
+ '.colored-dark *::-webkit-scrollbar {' +
1889
+ 'width: 12px;' +
1890
+ '}' +
1891
+ '.colored-dark *::-webkit-scrollbar-track {' +
1892
+ 'background: transparent;' +
1893
+ '}' +
1894
+ '.colored-dark *::-webkit-scrollbar-thumb {' +
1895
+ 'background-color:rgb(100, 100, 100);' +
1896
+ '}' +
1897
+
1898
+ '.colored * {' +
1899
+ 'scrollbar-width: thin;' +
1900
+ 'scrollbar-color: rgba(0, 0, 0, 0.4) auto;' +
1901
+ '}' +
1902
+ '.colored *::-webkit-scrollbar {' +
1903
+ 'width: 12px;' +
1904
+ '}' +
1905
+ '.colored *::-webkit-scrollbar-track {' +
1906
+ 'background: transparent;' +
1907
+ '}' +
1908
+ '.colored *::-webkit-scrollbar-thumb {' +
1909
+ 'background-color: rgba(0, 0, 0, 0.4);' +
1910
+ '}' +
1911
+
1912
+ '.light * {' +
1913
+ 'scrollbar-width: thin;' +
1914
+ 'scrollbar-color: rgba(0, 0, 0, 0.4) auto;' +
1915
+ '}' +
1916
+ '.light *::-webkit-scrollbar {' +
1917
+ 'width: 12px;' +
1918
+ '}' +
1919
+ '.light *::-webkit-scrollbar-track {' +
1920
+ 'background: transparent;' +
1921
+ '}' +
1922
+ '.light *::-webkit-scrollbar-thumb {' +
1923
+ 'background-color: rgba(0, 0, 0, 0.4);' +
1924
+ '}' +
1925
+
1926
+ 'svg {' +
1927
+ 'fill: ' + parent._cb.styleSnippetColor + ';' +
1928
+ '}' +
1929
+
1930
+ '.dark .is-design-list>div .is-overlay:after {' +
1931
+ 'background: rgb(78 78 78 / 13%);' +
1932
+ '}' +
1933
+ '';
1934
+
1935
+ let themestyle = document.querySelector('[data-theme-style]');
1936
+ if(themestyle) themestyle.parentNode.removeChild(themestyle);
1937
+
1938
+ var style = document.createElement("style");
1939
+ style.setAttribute('data-theme-style','');
1940
+ style.type = "text/css";
1941
+ style.innerHTML = cssString;
1942
+ document.head.appendChild(style);
1943
+
1944
+ if(parent._cb.styleDark) {
1945
+ document.body.setAttribute('class', 'dark');
1946
+ } else if(parent._cb.styleColored) {
1947
+ document.body.setAttribute('class', 'colored');
1948
+ } else if(parent._cb.styleColoredDark) {
1949
+ document.body.setAttribute('class', 'colored-dark');
1950
+ } else if(parent._cb.styleLight) {
1951
+ document.body.setAttribute('class', 'light');
1952
+ } else {
1953
+ document.body.setAttribute('class', '');
1954
+ }
1955
+ }
1956
+ </script>
1957
+ </body>
1958
+ </html>
1959
+ `;
1960
+ return html;
1961
+ }
1962
+
1963
+ getTemplatesHtml_OLD() {
1124
1964
  const designUrl1 = this.builder.designUrl1;
1125
1965
  const designUrl2 = this.builder.designUrl2;
1126
1966
  let html = `
@@ -89783,11 +90623,59 @@ class ContentBox {
89783
90623
  designUrl2: 'assets/designs/examples.js',
89784
90624
  designPath: 'assets/designs/',
89785
90625
  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/'],
90626
+
90627
+ /*
90628
+ Example:
90629
+ designUrl1: 'https://.../assets/designs/basic.js',
90630
+ designUrl2: 'https://.../assets/designs/examples.js',
90631
+ designPath: 'https://.../assets/designs/',
90632
+ designPathReplace: ['assets/', 'https://.../assets/'],
90633
+ */
90634
+ templates: [],
90635
+ // ver.5.3
90636
+
90637
+ /*
90638
+ Example: => this will replace the previous approach (designUrl1, designUrl2, designPath & designPathReplace)
90639
+ templates: [
90640
+ {
90641
+ url: 'assets/designs/basic.js',
90642
+ path: 'assets/designs/',
90643
+ pathReplace: []
90644
+ },
90645
+ {
90646
+ url: 'assets/designs/examples.js',
90647
+ path: 'assets/designs/',
90648
+ pathReplace: []
90649
+ },
90650
+ {
90651
+ url: 'assets/writing-set/basic.js',
90652
+ path: 'assets/writing-set/',
90653
+ pathReplace: []
90654
+ }
90655
+ ]
90656
+ */
90657
+ featuredCategories: [{
90658
+ id: 5,
90659
+ name: 'Random'
90660
+ }, // If apos ' is used, use: \\\'
90661
+ {
90662
+ id: 1,
90663
+ name: 'Basic'
90664
+ }, {
90665
+ id: 2,
90666
+ name: 'Slider'
90667
+ }, {
90668
+ id: 101,
90669
+ name: 'Header'
90670
+ }, {
90671
+ id: 118,
90672
+ name: 'Article'
90673
+ }, {
90674
+ id: 102,
90675
+ name: 'Photos'
90676
+ }],
90677
+ templateThumbnailSize: '',
90678
+ //small, medium
89791
90679
  // ContentBuilder
89792
90680
  scriptPath: '',
89793
90681
  snippetUrl: 'assets/minimalist-blocks/content.js',
@@ -92153,6 +93041,19 @@ class ContentBox {
92153
93041
  contentHtmlEnd: '</div></div></div>'
92154
93042
  };
92155
93043
  this.settings = Object.assign(this, defaults, settings);
93044
+ this.templateJSON = [{
93045
+ url: this.settings.designUrl1,
93046
+ path: this.settings.designPath,
93047
+ pathReplace: this.settings.designPathReplace
93048
+ }, {
93049
+ url: this.settings.designUrl2,
93050
+ path: this.settings.designPath,
93051
+ pathReplace: this.settings.designPathReplace
93052
+ }];
93053
+
93054
+ if (this.settings.templates.length !== 0 && this.settings.templateThumbnailSize === '') {
93055
+ this.settings.templateThumbnailSize = 'large';
93056
+ }
92156
93057
 
92157
93058
  if (this.settings.imageSelect !== '') {
92158
93059
  this.settings.imageselect = this.settings.imageSelect;