Skip to content

Instantly share code, notes, and snippets.

@zaurmag
zaurmag / clipping-text.php
Last active August 7, 2016 17:35
Функция обрезания текста на php
<?php
$text = strip_tags($curr->name);
if (!function_exists('truncate_words')) {
function truncate_words($text, $limit=30) {
$text=mb_substr($text,0,$limit);
/*если не пустая обрезаем до последнего пробела*/
if(mb_substr($text,mb_strlen($text)-1,1) && mb_strlen($text)==$limit) {
$textret=mb_substr($text,0,mb_strlen($text)-mb_strlen(strrchr($text,' ')));
if(!empty($textret)) {
return $textret."...";
@zaurmag
zaurmag / tabs.js
Created August 7, 2016 18:13
Табы
// ======= Tabs Function =======
(function($) {
$.fn.tabs = function() {
this.each(function() {
$(this).on('click', 'li:not(.active)', function() {
$(this)
.addClass('active').siblings().removeClass('active')
.closest('.tabs').find('.tab-block').removeClass('active').eq($(this).index()).addClass('active');
return false;
@zaurmag
zaurmag / tooltip.js
Created August 7, 2016 18:16
Плагин подсказки Tooltip
// ======= Tooltip =======
(function($) {
$.fn.easyTooltip = function(options) {
// default configuration properties
var defaults = {
xOffset: 10,
yOffset: 25,
@zaurmag
zaurmag / go-top.js
Last active August 7, 2016 18:17
Наверх
// ======= Go Top =======
(function($) {
jQuery.fn.scrollToTop = function() {
$(this).hide().removeAttr("href");
if ($(window).scrollTop() != "0") {
$(this).fadeIn("slow")
}
var scrollDiv = $(this);
$(window).scroll(function() {
@zaurmag
zaurmag / open-close-mobile-menu.js
Last active August 7, 2016 18:17
Плагин мобильного меню
// ======= Open/Close mobile Menu =======
(function($) {
$.fn.toggleMenu = function(options) {
var settings = $.extend({
closeClick: false
}, options);
return this.each(function() {
$(this).find('.hamburger').click(function() {
@zaurmag
zaurmag / ajax-magnific-popap.js
Created August 7, 2016 18:19
Ajax Magnific Popap
// ======= Ajax - Magnific Popap =======
$('.simple-ajax-popup').magnificPopup({
type: 'ajax',
tLoading: '<img src="/components/com_jshopping/images/cartajax-loading.gif" />',
closeOnContentClick: false,
showCloseBtn: false
});
@zaurmag
zaurmag / col-height.js
Created August 7, 2016 18:22
Одинаковая высота колонок
// ======= Одинаковая высота колонок =======
var max_col_height = 0;
$('.list_product .block_product').each(function() {
if ($(this).height() > max_col_height) {
max_col_height = $(this).height();
}
});
$('.list_product .block_product').height(max_col_height);
// Close Alert
@zaurmag
zaurmag / scroll-spy.js
Last active August 7, 2016 18:27
Выделение пункта меню Skroll Spy
// ======= Scroll Spy Menu =======
var lastId,
topMenu = jQuery("#main-menu"),
topMenuHeight = topMenu.outerHeight(),
menuItems = topMenu.find("a"),
scrollItems = menuItems.map(function() {
var item = jQuery(jQuery(this).attr("href"));
if (item.length) {
return item;
@zaurmag
zaurmag / animate-anchor.js
Last active August 7, 2016 18:29
Плавный скроллинг до блока
// ======= Animate Anchor =======
$(".arrow-go-down").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
}, {
duration: 500
});
return false;
});
@zaurmag
zaurmag / enquireJs.js
Last active August 7, 2016 18:31
Enquire JS
// ======= Enquire JS =======
enquire.register("screen and (max-width:1170px)", {
match: function() {
$('.menu-nav-wrapper').dropdownMenu();
},
unmatch: function() {
$('.menu-nav-wrapper').dropdownMenu({
destroy: true
});