Skip to content

Instantly share code, notes, and snippets.

View ArtemSites's full-sized avatar

Artem Kuznecov ArtemSites

View GitHub Profile
@ArtemSites
ArtemSites / readme.md
Last active March 16, 2022 19:05
jQuery-Smooth scrolling to an element on another or current page | jQuery-Плавная прокрутка до элемента на другой или на текущей странице

Плавная прокрутка до элемента на другой или на текущей странице jQuery | Smooth scrolling to an element on another or current page jQuery.

jquery.autoscrolling.js

Зависимости | Dependencies:

jquery-3.6.0.min.js

Ссылка на страницу и якорь целевого элемента | Link to the page and anchor of the target element:

<a class="desktop-menu__item" href="/history/#year2021">
	2021 год
@ArtemSites
ArtemSites / index.html
Last active September 4, 2019 12:05
Прелоадер по загрузке страницы.
<body>
<!-- Анимированный лоадер -->
<div class="wrapper-preloader">
<video autoplay loop>
<!-- or any preloader -->
<source src='<?=SITE_TEMPLATE_PATH."/assets/preloader.mp4"?>' type="video/mp4">
<source src='<?=SITE_TEMPLATE_PATH."/assets/preloader.mov"?>' type="video/mp4">
</video>
<style>
.wrapper-preloader {
@ArtemSites
ArtemSites / README
Last active February 22, 2022 11:26
Универсальный mail script - отправка формы с сайта (jQuery) | Universal mail script - submitting a form from a site (jQuery)
dependencies:
* jquery-3.4.1
@ArtemSites
ArtemSites / index.html
Last active November 28, 2019 07:31
Добавление своих меток в yandex карту.
<div class="section-map map">
<div class="map-open js-map-open-xs">
<p>Для открытия карты, кликните на нее</p>
</div>
<div id="map"></div>
<script type="text/javascript" src="https://api-maps.yandex.ru/2.1/?lang=ru_RU"></script>
<script>
ymaps.ready(function() {
var myMapBallon = {
@ArtemSites
ArtemSites / script.js
Last active July 27, 2019 12:07
Вставка дочернего файла js в родительский js файл.
//jqery method:
$.getScript('js/_child-script.js', function() {/*dependet code*/});
//js method:
var _childScript = document.createElement('script');
_childScript.src = '/js/_child-script.js';
document.head.appendChild(_cart);
_childScript.onload = function() {
//The library is loaded but not yet initialized,
@ArtemSites
ArtemSites / script.js
Created July 28, 2019 07:18
Подсчет количества элементов внутри объекта (с числовыми индексами).
someObject = {
0: 'example',
1: 'example',
2: 'example',
returnSize: function() {//Вернуть количество позиций корзины
var size = 0;
for (key in this) {
key = parseInt(key);
if (key >= 0) { //Если клююч число то прибавить к счетчику
size++;
@ArtemSites
ArtemSites / script.js
Created July 29, 2019 17:13
Обработка события нажатия на кнопки.
$(window, document).keydown(function(event) {
if (event.which == 38 || event.which == 39) { //+
event.preventDefault();
$('#shop__item-count-counter-active').next().trigger("click");
}
if (event.which == 37 || event.which == 40) { //-
event.preventDefault();
$('#shop__item-count-counter-active').prev().trigger("click");
}
if (event.which == 13) { //положить в корзину
@ArtemSites
ArtemSites / index.php
Last active February 19, 2020 13:49
Bitrix: простой скрипт отправки формы. | Bitrix: a simple form submission script.
<?
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");
$name = trim($_POST["user_name"]);
$phone = trim($_POST["user_phone"]);
$arEventField = array(
'USER_NAME' => $name,
'USER_PHONE' => $phone,
);
@ArtemSites
ArtemSites / functions.php
Last active August 4, 2019 08:08
Получить путь к теме wordpress в js файле.
function setObjThemePath() {
wp_register_script( 'my-script', 'myscript_url' );
wp_enqueue_script( 'my-script' );
$translation_array = array( 'url' => get_stylesheet_directory_uri() );
wp_localize_script( 'my-script', 'theme', $translation_array );
}
add_action( 'wp_enqueue_scripts', 'setObjThemePath' );
@ArtemSites
ArtemSites / template.php
Last active August 7, 2019 05:33
Bitrix. Вставка редактируемой области.
<section class="services">
<?$APPLICATION->IncludeComponent("bitrix:main.include","",Array(
"AREA_FILE_SHOW" => "file",
"AREA_FILE_SUFFIX" => "inc",
"EDIT_TEMPLATE" => "",
"PATH" => SITE_TEMPLATE_PATH."/includes/services/text.php"
)
);?>
</section>