Skip to content

Instantly share code, notes, and snippets.

@s2ar
s2ar / jQuery. pointer-events.js
Created April 25, 2016 11:22
jQuery. pointer-events
// method beginner
var el = jQuery(this);
el.css('pointer-events','none');
// ajax code
// method end
el.css('pointer-events','auto');
@s2ar
s2ar / Bitrix.updateProductPrice.php
Created April 26, 2016 10:42
Bitrix. Обновление базовой цены минимальной ценой предложения
<?php
AddEventHandler("catalog", "OnPriceUpdate", array("MyClassUpdatePrice", "OnBeforePriceUpdateHandler"));
AddEventHandler("catalog", "OnPriceAdd", array("MyClassUpdatePrice", "OnBeforePriceUpdateHandler"));
AddEventHandler("iblock", "OnBeforeIBlockElementDelete", Array("MyClassUpdatePrice", "OnBeforeIBlockElementDeleteHandler"));
class MyClassUpdatePrice
{
function OnBeforePriceUpdateHandler($PRICE_ID, $arFields) {
if(!$arFields['PRICE']) $arFields['PRICE'] = 0;
if(!$arFields['PRODUCT_ID']) $arFields['PRODUCT_ID'] = $PRICE_ID;
@s2ar
s2ar / sort.php
Last active May 23, 2016 09:24
Множественная сортировка
<?php
/*
http://wp-kama.ru/question/php-usort-sortirovka-massiva-po-dvum-polyam
* Сортировка массива по двум параметрам с помощью usort()
*/
function _usort_object_by_time_ms($a, $b){
// поля по которым сортировать
$array = array( 'laps'=>'desc', 'time_ms'=>'asc' );
@s2ar
s2ar / cluster.icon.add.js
Last active June 10, 2016 06:54
Оформление иконки кластера (markerclustererplus library)
/**
* Adding the cluster icon to the dom.
* @ignore
*/
ClusterIcon.prototype.onAdd = function() {
this.div_ = document.createElement('DIV');
if (this.visible_) {
var pos = this.getPosFromLatLng_(this.center_);
this.div_.style.cssText = this.createCss(pos);
@s2ar
s2ar / scroll.map.js
Created June 13, 2016 07:59
Disable scroll google maps
// Disable scroll zooming and bind back the click event
var onMapMouseleaveHandler = function (event) {
var that = $(this);
that.on('click', onMapClickHandler);
that.off('mouseleave', onMapMouseleaveHandler);
//that.find('iframe').css("pointer-events", "none");
that.find('#map-wrapper').css("pointer-events", "none");
}
@s2ar
s2ar / convertPHPSizeToBytes.php
Created June 21, 2016 11:09
Максимальный размер загружаемого файла
<?php
function convertPHPSizeToBytes($sSize)
{
if ( is_numeric( $sSize) ) {
return $sSize;
}
$sSuffix = substr($sSize, -1);
$iValue = substr($sSize, 0, -1);
switch(strtoupper($sSuffix)){
case 'P':
@s2ar
s2ar / .htaccess_index
Created July 28, 2016 06:11
Redirect from index.php to
# Redirect from index.php to /
RewriteCond %{THE_REQUEST} index.php [NC]
RewriteCond %{REQUEST_URI} !/bitrix/admin/.* [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
@s2ar
s2ar / .htaccess_slash
Created July 28, 2016 12:21
Убрать слеши в htaccess
#Правило обрабатывает внутренние страницы
# http://site.ru/catalog////item///
RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
#Проверяем, повторяется ли слеш (//) более двух раз.
RewriteRule . %1/%2 [R=301,L]
#Исключаем все лишние слеши.
#удаляем слеши для главной http://site.ru/////
RewriteCond %{THE_REQUEST} ([^\s]*)\/{2,}(\?[^\s]*)?
RewriteRule (.*) / [R=301,L]
@s2ar
s2ar / num2word.php
Created August 26, 2016 09:58
Преобразование количества "цифрой" в количество "словом"
<?php
/**
* Преобразование количества "цифрой" в количество "словом"
* Чтобы было удобнее формировать массивы со склонениями, запомните ряд чисел 1-2-5,
* а потом мысленно подставляйте их в массив: (один "рубль", два "рубля", пять "рублей")
* $num = 3;
* $words = array('новость', 'новости', 'новостей');
* echo $num . ' ' . num2word($num, $words); // сколько новостей
*
* @param $n
@s2ar
s2ar / prev_next.php
Last active September 29, 2016 07:45
bitrix. prev and next link
<?php
/*
$cp = $this->__component; // объект компонента
if (is_object($cp)) {
$cp->arResult['NAV_RESULT'] = $arResult['NAV_RESULT'];
$cp->SetResultCacheKeys(Array('NAV_RESULT'));
}
*/