Skip to content

Instantly share code, notes, and snippets.

View themavix's full-sized avatar

Artem Mukhamatianov themavix

View GitHub Profile
@themavix
themavix / ajax.php
Created August 16, 2015 22:45
Отправка XMLTHttpRequest
HTML
<input type="file" id="file">
JS
var file=document.getElementById("file"),
xhr=new XMLHttpRequest(),
form=new FormData();
file.onchange=function()
{
var upload_file=file.files[0];
@themavix
themavix / result_modifier.php
Last active August 29, 2015 14:27
Перегруппировка вывода компонента catalog.section.list
/**
* Перегруппируем компоненты меню для удобного вывода
*/
<?
$aItems = array();
$aParentItem = false;
foreach( $arResult as $aItem ) {
if( $aItem["DEPTH_LEVEL"] == 1 ) {
if( $aParentItem && ( $aParentItem["PERMISSION"] !== "D" ) ) {
//HTML
<snippet>
<content><![CDATA[
<!-- begin $1 -->
<div class="$1">
$2
</div>
<!-- end $1 -->
]]></content>
@themavix
themavix / result_modifier.php
Created June 25, 2015 02:10
Получение массива имен разделов
if($arResult['ITEMS']) { //Проверяем наличие элементов
$arSectionId = Array(); //Создаем пустой массив, куда получим ID используемых разделов
foreach($arResult['ITEMS'] as $arItem) { //Перебираем все элементы
if(!in_array($arItem['IBLOCK_SECTION_ID'], $arSectionId)) { //Если Id раздела не содержится в новом массиве $arSectionId,
$arSectionId[] = $arItem['IBLOCK_SECTION_ID']; //то добавляем id в массив
}
}
//На выходе имеем массив $arSectionId, в котором будут имена
@themavix
themavix / gist:0e0ede25b0e49129cd39
Created May 19, 2015 01:57
Стилизация селекта
$(document).ready(function(){
var f_select = function(){
var $select = $('.f-select');
var selectId = 'f-select_' + Math.floor( Math.random( ) * (100001) );
$select.addClass(selectId);
$select.css('display', 'none');
$select.after('<div class="f-custom-select" id="' + selectId + '"><div class="f-custom-select__title"><span></span></div></div><div class="f-custom-select__hidden" data-select-class="' + selectId + '"></div>');
var $f_select = $('#' + selectId);
@themavix
themavix / template.php
Created April 30, 2015 05:29
Изменение вывода компонента Bitrix на примере catalog.section.list
<!-- Изменение вывода компонента -->
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
if ($arResult['SECTIONS']) //Проверяем существует ли эллемент массива
{
?><div class="spotlight-grouping"><? //В верстку внедряем вывод из массива
foreach ($arResult['SECTIONS'] as $arSection) //Обходим все элементы
{
$pictureSrc = SITE_TEMPLATE_PATH . "/images/no-photobig.gif"; //если изображения для вывода нет, то заменяем его на стандартное и ложим в переменную