Воскресенье, 29 апреля 2018 12:58

Анимированная floating panel на jQuery для Magento

Оцените материал
(0 голосов)

Впрочем, почему именно для Magento? - jQuery ведь он и в Африке jQuery.

Попросту изначально эта симпатичная пульсирующая кнопка на jQuery была предназначена мной для одного из проектов, интернет-магазина туристической компании Tobeamerica. Результатом усилий можно полюбоваться на страницах Tobeamerica.com, код можно глянуть там же по Ctrl+U, ну либо здесь:

index.html

<script type="text/javascript" src="/jquery-git.js"></script>
<script type="text/javascript" src="/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="/style.css">

<script type="text/javascript">
jQ = jQuery.noConflict();
jQ(window).on('load', function() {
jQ(document).ready(function () {
    var x = 0;
    addCircle(x);
    setInterval(function () {
        if (x === 0) {
            x = 1;
        }
        addCircle(x);
        x++;
    }, 1200);
});

function addCircle(id) {
    jQ('body').append('<div id="' + id + '" class="circle"></div>');
    jQ('#' + id).animate({
        'width': '300px',
        'height': '300px',
        'margin-top': '-143px',
        'margin-left': '-143px',
        'opacity': '0'
    }, 4000, 'easeOutCirc');
    setInterval(function () {
        jQ('#' + id).remove();
    }, 4000);
}
});
</script>

<img class="img1" src="/pic.jpg" />
  
  <script>
  // tell the embed parent frame the height of the content
  if (window.parent && window.parent.parent){
    window.parent.parent.postMessage(["resultsFrame", {
      height: document.body.getBoundingClientRect().height,
      slug: "Y3r36"
    }], "*")
  }
</script>

 

Dev banner 3

 

css

.img1 {
    display: block;
    width: 100px;
    height: 100px;
    margin-top: -37px;
    margin-left: -37px;
    -webkit-border-radius: 60px;
    -moz-border-radius: 80px;    
    border-radius: 80px;
    position: fixed;
    top: 80%;
    left: 10%;
    z-index: 2;
    overflow: hidden;
    opacity: 0.5;
}

.circle {
    width: 0px;
    height: 0px;
    margin-top: 0px;
    margin-left: 0px;
    border: 10px solid #bb133e;
    -webkit-border-radius: 200px;
    -moz-border-radius: 200px;    
    border-radius: 200px;
    background: #2c0071;
    opacity: 0.6;
    position: fixed;
    top: 80%;
    left: 10%;
    z-index: 1;
}

 

Также можно попросту загрузить этот архив, распаковать, и открыть в браузере index.html. Работает? отлично, остальное сами.

 

Как интегрировать код в Magento? - ничего не может быть проще. Создаем виджет, содержащий показанный выше js; исключаем jquery-git.js и jquery-ui.js, если template уже и без того подгружает их. Вот, собственно, и все, осталось лишь разместить виджет на любой странице вашего Magento:

 

{{widget type="cms/widget_block" template="cms/widget/static_block/default.phtml" block_id="***"}}

 

Последнее изменениеВоскресенье, 29 апреля 2018 13:45

Оставить комментарий

Добавьте ваш комментарий