Skip to content

Instantly share code, notes, and snippets.

@PriymakVl
PriymakVl / back.js
Last active October 5, 2020 04:42
js jquery back to top page
var pxShow = 300; //height on which the button will show
var fadeInTime = 400; //how slow/fast you want the button to show
var fadeOutTime = 400; //how slow/fast you want the button to hide
var scrollSpeed = 300; //how slow/fast you want the button to scroll to top. can be a value, 'slow', 'normal' or 'fast'
// Show or hide the sticky footer button
jQuery(window).scroll(function() {
if (jQuery(window).scrollTop() >= pxShow) {
jQuery("#go-top").fadeIn(fadeInTime);
@PriymakVl
PriymakVl / get_height.js
Created September 9, 2020 15:54
get height element js method
//jquery
let height = $('.block').innerHeight();
let height = $('.block').height();
//clientHeight высота содержимого вместе с полями padding, но без полосы прокрутки.
let height = document.querySelector('.block').clientHeight;
//offsetHeight «внешняя» высота блока, включая рамки.
let height = document.querySelector('.block').offsetHeight;
@PriymakVl
PriymakVl / _form.php
Last active August 7, 2020 06:17
ckeditor yii2 добавление плагинов
// источник
// https://qna.habr.com/q/242409
<?= $form->field($model, 'ru')->widget(CKEditor::className(), [
'kcfinder' => true,
'kcfOptions' => [
'uploadURL' => '@web/upload',
'uploadDir' => '@webroot/upload',
],
'clientOptions' => [
@PriymakVl
PriymakVl / composer.txt
Created August 7, 2020 04:17
composer stability
"minimum-stability": "stable",
# если нужно меньше то
"minimum-stability": "dev",
"prefer-stable" : true,
@PriymakVl
PriymakVl / yii.txt
Last active August 5, 2020 18:18
yii2 размещение на хостинге через композер
#переходим в папку нашего сайта
cd ~/test.com
# увеличивает лимит памяти, не обязательно
php -d memory_limit=-1 /usr/local/bin/composer
#временное увеличение памяти
Мои сайты - Настройка сайта - Настройка параметров PHP - Turbo Boost
# устанавливает yii2 в папку www
@PriymakVl
PriymakVl / yii.php
Last active August 2, 2020 06:24
yii debug functions
<?php
/*
Создать файл debug.php в нутри папки config
Подключить файл в файле config/web.php
require_once(__DIR__.'/debug.php');
*/
function debug($array = false, $exit = true)
{
@PriymakVl
PriymakVl / yii.php
Last active August 2, 2020 06:08
yii clean layout
<?php
use yii\helpers\Html;
?>
<?php $this->beginPage() ?>
<html>
<head>
<?//= Html::csrfMetaTags() ?>
<? $this->head() ?>
</head>
<body>
@PriymakVl
PriymakVl / filter.js
Created August 1, 2020 09:57
js search in array diffrent methods
const array = [10, 11, 3, 20, 5];
// Array.filter() method is used to find an element in an array under specific condition.
const greaterThanTen = array.filter(element => element > 10);
console.log(greaterThanTen) //[11, 20]
// Syntax
let newArray = array.filter(callback);
// Array.find() method is used to find the first element in an array under specific condition.
@PriymakVl
PriymakVl / checked.js
Created July 29, 2020 23:42
js select value checked checkbox
$(document).ready(function() {
$('#studied').click(function() {
let selectedCheckBoxes = $('input[name="state"]:checked');
if (selectedCheckBoxes.length == 0) return alert('Не выделены слова');
let checkedValues = Array.from(selectedCheckBoxes).map(item => item.value);
location.href = '/word/studied?ids=' + checkedValues.join();
@PriymakVl
PriymakVl / listener.js
Created May 16, 2020 06:52
js event listener
document.querySelector('.products').addEventListener('change', function(e) {
let $product = e.target.closest('.product');
console.log($product);
});
document.querySelector('.products').addEventListener('change', (e) => let product = e.target.closest('.product'));