Skip to content

Instantly share code, notes, and snippets.

View yaroslavKas's full-sized avatar

Zaichenko Yaroslav yaroslavKas

View GitHub Profile
@yaroslavKas
yaroslavKas / js-coordinates-of-bottom-text-selection.js
Created October 4, 2017 12:38
js coordinates of bottom text selection
function getSelectionCoords(win) {
win = win || window;
var doc = win.document;
var sel = doc.selection, range, rects, rect;
var x = 0, y = 0;
if (sel) {
if (sel.type != "Control") {
range = sel.createRange();
range.collapse(true);
x = range.boundingLeft;
@yaroslavKas
yaroslavKas / custom select.html
Created February 16, 2017 08:40
Кастомный селект
<div id="select-country" class="select-country">
<p class="select-country__current-point" onclick="selectShow()">Country:<span id="current-point"><?php echo $map_data[0]->country_title; ?></span></p>
<ul class="select-country__list-point">
<?php foreach ( $map_data as $item ) { ?>
<li><a data-id="<?php echo $item->country_id; ?>" class="select-point" href="#"><?php echo $item->country_title; ?></a></li>
<?php } ?>
</ul>
</div>
@yaroslavKas
yaroslavKas / function_scroll.js
Created October 4, 2016 10:36
Фиксированный блок при скролле
document.addEventListener("DOMContentLoaded", function() {
function scrollWidget(){
var widget = document.getElementById('villa-calendar-wrapper'),
headerHeight = document.getElementById('header-outer').offsetHeight,
widgetPositionParams = widget.getBoundingClientRect(),
scrollHeight = window.pageYOffset || document.documentElement.scrollTop;
if(widgetPositionParams.top < scrollHeight){
widget.style.top = headerHeight + 20 + 'px';
@yaroslavKas
yaroslavKas / index.html
Created September 19, 2016 09:32
Стилизация input "file"
<div class="file_upload">
<button type="button">Выбрать</button>
<div>Файл не выбран</div>
<input type="file">
</div>
@yaroslavKas
yaroslavKas / blur.css
Created May 26, 2016 06:53
Форма в блюре
#form3{
top: 0;
padding: 25px 35px;
}
label {
width: 100%;
}
label input{
width: 100%;
height: 45px;
@yaroslavKas
yaroslavKas / menu_item_me_awake_when_you_scroll.js
Created May 19, 2016 13:40
МЕНЯЕМ АКТИВНЫЙ ПУНКТ МЕНЮ ПРИ ПРОКРУТКЕ СТРАНИЦЫ
var menu_selector = ".top-menu"; // Переменная должна содержать название класса или идентификатора, обертки нашего меню.
var menu = jQuery('#header').outerHeight();
jQuery("#mainnav li:first-child a").addClass("current");
function onScroll(){
var scroll_top = jQuery(document).scrollTop();
jQuery(menu_selector + " a").each(function(){
var hash = jQuery(this).attr("href");
var target = jQuery(hash);
@yaroslavKas
yaroslavKas / random.js
Created May 19, 2016 08:23
Перемешать массив
function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
@yaroslavKas
yaroslavKas / mail.html
Created May 19, 2016 08:19
Отправка формы
<form id="form2" method="post" class="headerform">
<div class="form-group">
<label>
<input type="text" class="form-control phone" name="phone" id="one_click" placeholder="+7 (___) ___-__-__" >
<input type="hidden" class="name" name="one_click" value="бляя">
</label>
</div>
<button id="submitForm" class="submit" type="submit">Заказать</button>
</form>
//надо вставить <input type="hidden" class="name" name="one_click" value="бляя">
@yaroslavKas
yaroslavKas / validation-form.css
Created May 18, 2016 13:59
Валидация формы
.error-phone.error p{
font-size: 11px;
color: #C32929;
line-height: 11px;
margin-bottom: 5px;
margin-top: 5px;
}
.error-box.error p{
font-size: 11px;
color: #C32929;
@yaroslavKas
yaroslavKas / vertical_navigation.css
Last active June 1, 2016 09:17
Кнопки вверх/низ
.wrap-bottom {
position: fixed;
right: 15px;
bottom: 25px;
}
#ToTop,
#OnBottom {
width: 36px;
}
.go-up {