Customization of Jquery Custombox

Asked

Viewed 162 times

1

Fala galera,

I found a very good plugin for lightbox that works with the modal windows of Bootstrap 3.

Documentation is limited and can be found at http://dixso.github.io/custombox/

What I need is to understand how I apply the plugin to make Modal open on page loading.

I am using the examples of the page, without changing anything, nor the ID. But I can only open the Modals with clicks, I could not open automatically.

Somebody help me?

1 answer

1


In Javascript with jQuery utilize $(document).ready that when loading the page, executes the Modal.

Javascript:

$(document).ready(function(){
    Custombox.open({
        target: '#modal',
        effect: 'fadein'
      });
});

Html:

<!-- Modal -->
<div id="modal" class="modal-demo">
    <button type="button" class="close" onclick="Custombox.close();">
        <span>&times;</span><span class="sr-only">Close</span>
    </button>
    <h4 class="title">Modal title</h4>
    <div class="text">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
</div>

$(document).ready(function(){
	Custombox.open({
        target: '#modal',
        effect: 'fadein'
      });
});
/*
 ----------------------------
 Demo
 ----------------------------
 */
iframe {
    border: none;
}
.page-header {
    margin-top: 0;
}
h1, h2, h4 {
    font-family: 'Dosis', sans-serif;
}
h1 {
    font-weight: 600;
    line-height: 36px;
    margin-bottom: 5px;
    float: left;
}
h1 > em {
    color: #fc5e5e;
    font-style: normal;
}
#version {
    float: left;
    margin: 37px 0 0 10px;
}
h2 {
    font-weight: 500;
    margin-bottom: 15px;
    font-size: 25px;
    clear: both;
}
h4 {
    font-weight: 400;
    font-size: 22px;
    line-height: 22px;
}
h4 > em {
    font-weight: 400;
    font-size: 12px;
    line-height: 12px;
    font-style: normal;
}
.share-github {
    float: left;
    margin-right: 10px;
}
.demo-content > h4 {
    margin-top: 25px;
}
.modal-demo {
    background-color: #FFF;
    width: 600px;
    border: #000 solid 1px;
    border-radius: 10px;
    box-shadow: 0 8px 6px -6px black;
    text-align: left;
    display: none;
}
.title {
    padding: 10px 20px 15px 20px;
    line-height: 18px;
    font-size: 18px;
    border-bottom: #CCC solid 1px;
}
.text {
    padding: 0 20px 20px 20px;
}
.close {
    position: absolute;
    top: 15px;
    right: 15px;
}
.bs-callout {
    padding: 20px;
    margin: 20px 0;
    border: 1px solid #eee;
    border-left-width: 5px;
    border-radius: 3px;
}
.bs-callout > h4,
.bs-callout-support {
    margin-top: 0;
}
.bs-callout:not(.bs-callout-support) > p:last-of-type {
    margin-bottom: 0;
}
.bs-callout-info {
    border-left-color: #D9EDF7;
}
#forkme {
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    z-index: 2;
}
#custompopover {
    min-width: 330px;
    max-width: 330px;
}
.table-popover:not(.table-methods) > tbody > tr:hover td {
    background-color: #D9EDF7;
    cursor: pointer;
}
.table-demo > thead > tr > th:nth-child(1){
    width: 20%;
}
.table-demo > thead > tr > th:nth-child(2),
.table-demo > thead > tr > th:nth-child(3) {
    width: 15%;
}
.table-popover td span {
    margin-top: 4px;
}
.footer {
    font-size: 11px;
    text-align: center;
    padding-bottom: 20px;
}
.download {
    margin-bottom: 10px;
    font-size: 16px;
    line-height: 16px;
    font-weight: normal;
}
#gitfork {
    display: none;
}
.tab-content-demo {
    overflow: auto;
}
@media only screen and (max-device-width: 480px) {
    #forkme,
    #custompopover {
        display: none;
    }
    #gitfork {
        display: block;
    }
}
.modal-demo .infinite {
    display: none;
    position: absolute;
    top: 10px;
    right: 45px;
}

/*
 *  Usage:
 *
 *    <div class="sk-wandering-cubes">
 *      <div class="sk-cube sk-cube1"></div>
 *      <div class="sk-cube sk-cube2"></div>
 *    </div>
 *
 */
.sk-wandering-cubes {
    margin: 0 auto;
    width: 32px;
    height: 32px;
    position: relative; }
.sk-wandering-cubes .sk-cube {
    background-color: #333;
    width: 10px;
    height: 10px;
    position: absolute;
    top: 0;
    left: 0;
    -webkit-animation: sk-wanderingCubeMove 1.8s infinite ease-in-out;
    animation: sk-wanderingCubeMove 1.8s infinite ease-in-out; }
.sk-wandering-cubes .sk-cube2 {
    -webkit-animation-delay: -0.9s;
    animation-delay: -0.9s; }

@-webkit-keyframes sk-wanderingCubeMove {
    25% {
        -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5);
        transform: translateX(42px) rotate(-90deg) scale(0.5); }
    50% {
        /* Hack to make FF rotate in the right direction */
        -webkit-transform: translateX(42px) translateY(42px) rotate(-179deg);
        transform: translateX(42px) translateY(42px) rotate(-179deg); }
    50.1% {
        -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg);
        transform: translateX(42px) translateY(42px) rotate(-180deg); }
    75% {
        -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
        transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5); }
    100% {
        -webkit-transform: rotate(-360deg);
        transform: rotate(-360deg); } }

@keyframes sk-wanderingCubeMove {
    25% {
        -webkit-transform: translateX(42px) rotate(-90deg) scale(0.5);
        transform: translateX(42px) rotate(-90deg) scale(0.5); }
    50% {
        /* Hack to make FF rotate in the right direction */
        -webkit-transform: translateX(42px) translateY(42px) rotate(-179deg);
        transform: translateX(42px) translateY(42px) rotate(-179deg); }
    50.1% {
        -webkit-transform: translateX(42px) translateY(42px) rotate(-180deg);
        transform: translateX(42px) translateY(42px) rotate(-180deg); }
    75% {
        -webkit-transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5);
        transform: translateX(0px) translateY(42px) rotate(-270deg) scale(0.5); }
    100% {
        -webkit-transform: rotate(-360deg);
        transform: rotate(-360deg); } }

div.sk-wandering-cubes .sk-cube {
    background-color: #FFF;
}
<script src="https://dixso.github.io/custombox/dist/custombox.min.js"></script>
<link href="https://dixso.github.io/custombox/dist/custombox.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Modal -->
<div id="modal" class="modal-demo">
    <button type="button" class="close" onclick="Custombox.close();">
        <span>&times;</span><span class="sr-only">Close</span>
    </button>
    <h4 class="title">Modal title</h4>
    <div class="text">
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
    </div>
</div>

  • 1

    Thanks Virgilio. The passage in question &#xA;$(document).ready(function(){&#xA; Custombox.open({&#xA; target: '#modal',&#xA; effect: 'fadein'&#xA; });&#xA;});&#xA; Did what I needed But I still don’t know how to format my comments... Sorry.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.