Skip to content

Instantly share code, notes, and snippets.

@slavapas
slavapas / Hide Div When Clicked Outside It
Created March 29, 2017 13:14
Hide Div When Clicked Outside It
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Vanilla Javascript DropDown Menu Example</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="menu-dropdown">Menu &#9660;</div>
@slavapas
slavapas / show-hide dropdown menu on hover-mouseout using jquery
Created March 29, 2017 13:10
show-hide dropdown menu on hover-mouseout using jquery
variant 1
------------
$(document).ready(function () {
$("#moretab").mouseenter(function(){
$("#categories").show();
});
$("#categories, #moretab").mouseleave(function(){
$("#categories").hide();
@slavapas
slavapas / How to hide dropdown menu on click outside of the element in jQuery
Created March 29, 2017 13:01
How to hide dropdown menu on click outside of the element in jQuery
$(document).on("click", function(event){
var $trigger = $(".dropdown");
if($trigger !== event.target && !$trigger.has(event.target).length){
$(".dropdown-menu").slideUp("fast");
}
});
@slavapas
slavapas / Simple Contact form using Jquery Ajax & PHP
Last active February 15, 2019 12:39
Simple Contact form using Jquery Ajax & PHP.html
Simple Contact form using Jquery Ajax & PHP
http://www.otallu.com/tutorials/simple-contact-form-using-jquery-ajax-php/
-----------------------------------------------------
HTML
-----------------------------------------------------
<form method="post" class="myform" action="process-form.php">
<input type="text" name="name" placeholder="Your Name" required><br>
<input type="email" name="email" placeholder="Your Email" required><br>
<textarea rows="4" cols="20" name="message" placeholder="Your Message"></textarea><br>
<input type="submit" name="send" value="Send"> <span class="output_message"></span>
@slavapas
slavapas / js+php+html_complete_contact_form
Last active March 21, 2017 21:25
js+php+html_complete_contact_form
/-----------------FORM--------------------------------------------------------------------------------------------------
<div id="form-content">
<form method="post" id="reg-form" autocomplete="off" onsubmit="document.getElementById('myButton').disabled=true; document.getElementById('myButton').value='Submitting, please wait...';"; >
<div class="form-group">
<input type="text" class="form-control" name="txt_fullname" id="lname" placeholder="Full Name" required />
</div>
@slavapas
slavapas / php_mail()
Created March 21, 2017 19:27
php email code
<?php
$to = "[email protected]";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = "You have a message sent from your site";
$fields = array();
$fields{"name"} = "name";
$fields{"email"} = "email";
$fields{"phone"} = "phone";
@slavapas
slavapas / form_submit_no_reload.js
Created March 21, 2017 12:58
form submit ajax no reload
$('#reg-form').submit(function(e){
e.preventDefault(); // Prevent Default Submission
$('form :submit').prop('disabled', true); // disable submit button
$.ajax({
// ajax source
})
.done(function(data){
$('form :submit').prop('disabled', false); // enable submit button
})
.fail(function(){
Keymap (Windows Users):
[
{ "keys": ["alt+shift+f"], "command": "reindent" },
]
Settings:
{
"show_definitions": false,
"auto_complete": false,
"bold_folder_labels": true,
@slavapas
slavapas / Stylus PX to REM Mixin
Created January 5, 2017 07:55 — forked from gearmobile/Stylus PX to REM Mixin
Stylus PX to REM Mixin
set-font-size(value) {
font-size: value; /* добавляем PX как подстраховку */
if (value is inherit) {
/* делаем если нет значения для шрифта */
} else {
font-size: remify(value);
}
}