/* simple scripts file for Themes.guide Bootstrap 4 theme templates */
// init Bootstrap tooltips & popovers
$("[data-toggle=popover]").popover();
$("[data-toggle=tooltip]").tooltip();
/* copy demo sources to clipboard */
function copyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Copying text command was ' + msg);
} catch (err) {
console.log('Oops, unable to copy');
}
document.body.removeChild(textArea);
return false;
}
var modalCode = $('
');
var modalDialog = $('');
var modalContent = $('');
var modalHeader = $('');
var modalBody = $('The following markup was copied to the clipboard...
');
modalHeader.appendTo(modalContent);
modalBody.appendTo(modalContent);
modalContent.appendTo(modalDialog);
modalDialog.appendTo(modalCode);
modalCode.appendTo('body');
var css = ".copyable{position:relative}.copyable .copyable-trigger{color:#333;background-color:rgba(255,255,255,.8);border:1px #888 solid;border-radius:4px;position:absolute;padding:3px 6px;top:0;right:0;z-index:102;text-decoration:none;font-family:monospace;font-size:11px;cursor:pointer;display:none}.copyable:hover .copyable-trigger{display:inline-block}";
$("head").append($(document.createElement("style"))
.html(css)
);
$('main').find('.card, .btn-group, .btn, .navbar, .modal, .form-group, .list-group, .alert, .progress, .table-responsive, .jumbotron, .badge, .nav').each(function(){
var $this = $(this);
var content = $this.get(0).outerHTML;
var arrayOfLines = content.match(/[^\r\n]+/g);
var secondLine = 0;
for (var l in arrayOfLines) {
var tabCount;
if (l>0) {
tabCount = ((arrayOfLines[l]||'').match(/[\s{4}|\t{1}]\S/g)||[]).length;
if (l==1) { secondLine = tabCount }
arrayOfLines[l] = arrayOfLines[l].replace(/\t{1}/g,'~');
arrayOfLines[l] = arrayOfLines[l].replace(/\s{4}/g,'~');
for (var i=0;i<>");
$this.append(trigger);
trigger.tooltip({
title: title,
placement: 'bottom',
trigger: 'hover'
});
trigger.on('click',function(e){
copyTextToClipboard(content);
$("#code").text(content);
$("#modalCode").modal('show');
return false;
});
});