Skip to content

Instantly share code, notes, and snippets.

@artygrand
artygrand / script.js
Created December 9, 2016 11:09
Fixed nav on scroll
var nav_offset = $('nav').offset().top,
nav_height = $('nav').outerHeight(true);
$('nav').after($('<div>').addClass('padding').css('height', nav_height));
$(window).scroll(function(){
if ($(this).scrollTop() > nav_offset){
$('nav').addClass('fixed')
} else {
$('nav').removeClass('fixed')
}
});
@artygrand
artygrand / isotope.php
Created October 22, 2016 10:43
Isotope theme for module Sydes.Album
<?php
$this->response->script[] = 'https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.1/isotope.pkgd.min.js';
?>
<div id="filters" class="button-group">
<button class="button is-checked" data-filter="*">Все</button>
<?php foreach ($result['tags'] as $tag){ ?>
<button class="button" data-filter=".<?=convertToAscii($tag);?>"><?=$tag;?></button>
<?php } ?>
</div>
@artygrand
artygrand / script.js
Created September 20, 2016 13:40
Simple stars vote script for input
$(document).ready(function(){
$('.stars').each(function(){
var input = $(this), stars = $('<div class="stars-visible"><span></span><span></span><span></span><span></span><span></span></div>')
stars.find('span').click(function(){
$(this).addClass('active').siblings().removeClass('active')
input.val(5-$(this).index())
})
input.hide().before(stars)
})
})
@artygrand
artygrand / select-theme.php
Created July 17, 2016 08:53
SyDES plugin: select theme for subsite
<?php
$app->on('after.module', 'pages/view/*', function() use($app){
$parts = explode('/', $app->response->data['fullpath']);
$themes = str_replace(DIR_TEMPLATE, '', glob(DIR_TEMPLATE . '*', GLOB_ONLYDIR));
if (in_array($parts[0], $themes)) {
$conf = $app->config_site;
$conf['template'] = $parts[0];
$app->config_site = $conf;
}
@artygrand
artygrand / context-sites.php
Created July 17, 2016 08:45
SyDES plugin: Add dropdown with all sites in context menu
<?php
$app->on('before.module', '*', function() use($app){
$app->response->context['sites'] = array(
'title' => 'Сайты',
'link' => '',
'children' => array(),
);
$allsites = $app->cache->get('allsites');
if (!$allsites){
@artygrand
artygrand / equal-height.js
Created June 21, 2016 12:30
Equal heights for catalog grid
Object.defineProperty(Array.prototype, 'chunk', {value: function(n) {
return Array.from(Array(Math.ceil(this.length/n)), (_,i)=>this.slice(i*n,i*n+n));
}});
$(window).load(function(){
$.each($('.hit-info a').toArray().chunk(4), function(index, els) {
var maxheight = 0;
$(els).each(function(){
var height = $(this).outerHeight()
if(height > maxheight) {
maxheight = height;