Skip to content

Instantly share code, notes, and snippets.

@kapitonovmaxim
kapitonovmaxim / app.js
Created January 21, 2020 06:18
Easy tabs jquery
function tabsSelect(tab, contentTab, callback) {
var tcl = $(tab);
var ct = $(contentTab);
tcl.click(function () {
if (!$(this).hasClass('active')) {
tcl.removeClass('active')
var i = $(this).index();
$(this).addClass('active');
ct.children().removeClass('active').hide().eq(i).addClass('active').fadeIn(300);
@kapitonovmaxim
kapitonovmaxim / app.js
Last active November 27, 2019 11:02
AJAX#1
const btn = document.querySelector('.btn-get-posts');
const btnAddPost = document.querySelector('.btn-add-post');
const container = document.querySelector('.container');
function getPosts(cb) {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://jsonplaceholder.typicode.com/posts');
xhr.addEventListener('load', () => {
const response = JSON.parse(xhr.responseText);
cb(response);
// jquery
$('#text').click(function (e) {
var val = $('#input').val();
if (val != '') {
if (/[^[+0-9]/.test(val)) {
var pattern = /^([a-z0-9_\.-])+@[a-z0-9-]+\.([a-z]{2,4}\.)?[a-z]{2,4}$/i;
if (pattern.test(val)) {
// $('#valid').text('E-mail введен верно');
} else {
$('#valid').text('Не верно введен e-mail');
let Tabs = function() {
let link = $('#tabs-link'),
content = $('#tabs-wrap'),
i = 0,
createTabs = function () {
function tabsLink(i) {
$(link).children(".title-item").removeClass("active");
$(link).children(".title-item").eq(i).addClass("active");
}
function tabsContent(i){
<div class="counter">
<button type="button" class="but counterBut dec">-</button>
<input type="text" class="field fieldCount" value="1" data-min="1" data-max="20">
<button type="button" class="but counterBut inc">+</button>
</div>
<script>
function catalogItemCounter(field){
var fieldCount = function(el) {
// Product Card Height
function productHeight(){
if ( $( window ).width() > 768 ){
let productHeight = {};
// создаем массив стартовых высот блоков с продуктами
$(".product").each(function(index){
let height = $(this).outerHeight();
productHeight[index] = height;
console.log("before: " + productHeight[index] );
});
<?php
require_once dirname(__FILE__).'/config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
header("Content-type: text/plain");
<?php
// provider id => array of packages
$listPackagesToInstall = array(
1 => array( // standart modx provider
'sdStore'
, 'translit'
, 'TinyMCE'
, 'FormIt'
, 'Analytics'
HTML:
<div class="wrapper">
<div class="tabs">
<span class="tab">Вкладка 1</span>
<span class="tab">Вкладка 2</span>
<span class="tab">Вкладка 3</span>
</div>
<div class="tab_content">
<div class="tab_item">Содержимое 1</div>
<div class="tab_item">Содержимое 2</div>