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 / include-js-css-joomla.php
Last active August 15, 2016 12:29
Подключение скриптов в шаблонах Joomla
<?php
// Подключение файла JS
JHtml::script(JUri::base().'templates/'.$this->template.'/js/js.js', false);
$document = JFactory::getDocument();
// Add Javascript
$document->addScriptDeclaration('
window.event("domready", function() {
@zaurmag
zaurmag / fixed-menu.js
Last active September 25, 2017 12:42
Фиксация меню при прокрутке страницы
// ======= Fixed block =======
(function($) {
$.fn.addFixClass = function(options) {
options = $.extend({
offset: 200,
destroy: false
}, options);
var fixClass = $(this);
$(window).bind('scroll', function() {
if ($(window).scrollTop() >= options.offset && !options.destroy) {
@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 / ajax-submit-rsform.js
Last active July 20, 2020 18:31
Ajax отправка формы для RSFORM
/* =============================
Ajax Submit Form Plugin
Форма может скрываться на 4 секунды после отправки. Для этого оберните форму родительским блоком с классом - hide-form-success
=============================================================== */
(function($) {
jQuery.fn.sendForm = function(options) {
options = $.extend({
successTitle: "Ваше сообщение успешно отправлено!",
successText: "Мы свяжемся с Вами в самое ближайшее время"
@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 / 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 / accordeon-menu.js
Last active July 13, 2017 20:29
Плагин вертикальное меню аккордеон
// ======= Plugin Accordeon Vmenu =======
(function($) {
jQuery.fn.dropdownMenu = function(options) {
options = $.extend({
destroy: false
}, options);
var make = function() {
if (!options.destroy) {
$(this).find('.sub-menu').hide();
@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 / inline-magnific-popap.js
Last active August 7, 2016 18:31
Magnific Popap - тип inline
// ======= Popap Window Whit Magnific Popap =======
$('.popup-window-link').magnificPopup({
type: 'inline',
fixedContentPos: false,
fixedBgPos: true,
overflowY: 'auto',
closeBtnInside: true,
preloader: false,
midClick: true,