Skip to content

Instantly share code, notes, and snippets.

View delphinpro's full-sized avatar

Сергей delphinpro

View GitHub Profile
@delphinpro
delphinpro / jquery.spin.js
Last active May 10, 2019 09:15
Поле выбора количества
/**
* Поле выбора количества
*/
(function() {
const DATA_KEY = 'KEY_SPIN';
const REPEAT_DELAY_1 = 300;
const REPEAT_DELAY_2 = 1500;
const REPEAT_DELAY_3 = 3000;
const REPEAT_SPEED_1 = 200;
@delphinpro
delphinpro / downloadButton.php
Created November 5, 2018 11:38
Сниппет MODX — Ссылка на скачивание файла
<?php
$file = isset($file) ? $file : null;
$title = isset($title) ? $title : 'Скачать';
if (!$file) return '';
$filepath = MODX_BASE_PATH.$file;
if (!is_file($filepath) || !is_readable($filepath)) return 'Ошибка чтения файла<br>('.$file.')';
@delphinpro
delphinpro / YandexMap.vue
Created August 6, 2018 09:28
Lazy load yandex maps API
<script>/**
* Lazy load Yandex Maps API
* Отложенная загрузка выражается в том,
* что API подгружается при первом мотировании компонента.
* Если на странице нет карты, то и API не грузится.
*
* @author delphinpro <[email protected]>
* @copyright copyright © 2018 delphinpro
* @license licensed under the MIT license
*
@delphinpro
delphinpro / scrollbar-width.js
Last active July 12, 2018 14:49
Compute scrollbar width
/**
* Compute scrollbar width
*
* @author delphinpro <[email protected]>
* @copyright copyright © 2018 delphinpro
* @license licensed under the MIT license
*/
let computedWidth = null;
.map [class*="ymaps-2"][class*="-ground-pane"] {
/* Firefox 3.5+ */
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
/* Chrome 19+ & Safari 6+ */
-webkit-filter: grayscale(100%);
}
@delphinpro
delphinpro / lazyloadmodule.js
Created June 13, 2018 02:27
Lazy load module with webpack
import('./shop.js').then(module => {
module.doInit();
});
@delphinpro
delphinpro / triplets.js
Last active June 13, 2018 02:26
Разбиение больших чисел на разряды
export function triplets(str) {
// \u202f — неразрывный узкий пробел
return str.toString().replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1\u202f');
}
<?php
$file = isset($file) ? $file : '';
$cacheable = isset($cacheable) ? intval($cacheable) : 0; // 1 or 0
if (empty($file)) {
return;
}
$filePath = MODX_BASE_PATH . $file;
@delphinpro
delphinpro / CfgTv.php
Created January 29, 2018 22:11
CfgTv plugin for ModX
<?php
$e =& $modx->event;
switch ($e->name ) {
case 'OnBeforeDocFormSave':
//$logFile = MODX_BASE_PATH . DIRECTORY_SEPARATOR . 'CfgTv.log';
//file_put_contents($logFile, '');
$list_id = explode(',', $ids);
if (!in_array($_POST['id'], $list_id)) return;
/*==
*== Hexagon
*== ======================================= ==*/
$hexagon-size: 184px;
$sin60: 0.86602540;
$hexagon-height: $hexagon-size / $sin60;
.hexagon {
&, * { transition: 0.3s linear; }