Skip to content

Instantly share code, notes, and snippets.

View cave2006's full-sized avatar

Sergey Cave Lebedev cave2006

View GitHub Profile
<?php
// Image Align
$grid = $this->el('div', [
'class' => [
'uk-grid-small uk-child-width-expand uk-flex-nowrap',
'uk-flex-middle {@image_vertical_align}',
],
@cave2006
cave2006 / hide-and-seek.js
Created May 27, 2022 08:50
скрипт появления элемента после скролла страницы на определенное значение
window.addEventListener('scroll', function () {
var scrolled = window.scrollY,
coords = document.querySelector('.tm-header-mobile').clientHeight; // querySelector('.tm-header-mobile') - элемент на высоту которого определяем появление, можно использовать documentElement
document.querySelectorAll('[radicalmart-cart-module="bottom"]').forEach(module => { // querySelectorAll('[radicalmart-cart-module="bottom"]') - появляющаяся область
if (scrolled > coords) {
module.style.bottom = '0'; // module.style.bottom = '0'; - что делаем при наступлении события
} else {
module.style.bottom = '-80px' // module.style.bottom = '-80px'; - что делаем при окончании события
}
})
@cave2006
cave2006 / view-module-teml-joomla.php
Created May 16, 2022 00:55 — forked from zaurmag/view-module-teml-joomla.php
Вывод модулей в шаблоне Joomla
<?php //вывод позиции модулей
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$options = array('style' => 'xhtml');
$position = 'user1';
echo $renderer->render($position, $options, null);
?>
<!-- или -->
@cave2006
cave2006 / utm_for_radicalform.js
Last active April 26, 2022 08:38
Парсит UTM метки, создаёт скрытые поля в форме и присваивает им значения для передачи в сообщениях RadicalForm. Парсер взят из hunty/parse_utm.js
document.addEventListener('DOMContentLoaded', function () {
// Parse the URL
function getParameterByName(name) {
var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// make array
@cave2006
cave2006 / parse_utm.js
Created April 18, 2022 05:21 — forked from hunty/parse_utm.js
Парсит UTM метки и подставляет в скрытые поля
window.onload = function() {
// Parse the URL
function getParameterByName(name) {
var name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
var results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
// Give the URL parameters variable names
var source = getParameterByName('utm_source');
@cave2006
cave2006 / new-module-position-in-template.php
Created April 6, 2022 23:26
Вывод модулей в шаблоне компонента
<?php
$document = &JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$options = array('style' => 'xhtml');
$position = 'breadcrumbs';
echo $renderer->render($position, $options, null);
?>
<?php
/*
* @package RadicalMart Package
* @subpackage com_radicalmart
* @version __DEPLOY_VERSION__
* @author Delo Design - delo-design.ru
* @copyright Copyright (c) 2021 Delo Design. All rights reserved.
* @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html
* @link https://delo-design.ru/
*/
@cave2006
cave2006 / donate to robokassa
Created December 13, 2021 13:58
make one button widget to pay robokassa
<div class="el-content uk-panel uk-margin-top">
<form class="uk-form-horizontal">
<div class="uk-margin-small">
<label class="uk-form-label" for="donation-amount">Сумма пожертвования:</label>
<div class="uk-form-controls">
<div class="uk-inline uk-width-expand">
<input class="uk-input uk-text-right" id="donation-amount" type="text" placeholder="10" value="" onchange="donate(this)">
</div>
</div>
</div>
@cave2006
cave2006 / js modal link in grid and buttons (not tested).js
Last active September 14, 2023 01:52
Для того, чтоб превратить ссылки в Grid или Buttons, необходимо добавить класс '.link-to-modal'. Код проверяет на существование якоря, и если он существует, то заменяет атрибут 'uk-scroll' на 'uk-toggle' добавляя параметр 'target'. Не проверялось на Buttons, но, должно работать.
Добавить в начале строки Найти ^ Заменить 0;
^\W пробел в начале строки
\d{8} найти 8 цыфр подряд
^\d{4};92 найти В НАЧАЛЕ ЧЕТЫРЕХзначные числа после которы есть ;92
[^=]*$ любые символы, кроме "="
;(.*) все после ;
(\b\S+\b)(?=.*\1) повторение на строке
^$\n - удалить пустые строки
\d [0-9] Цифровой символ