Skip to content

Commit 5bf2559

Browse files
committed
- Add confirmation dialog implementation and docs update
- Introduced `confirmAndDoAction` function in `lib.js` for displaying customizable confirmation dialogs. - Updated minified JS in `lib.min.js` to include the new functionality. - Added `docs/components.md` with usage examples for the existing `hipot:includer` component. - Enhanced PHPDoc annotations in `phpdocs.php` for better type definitions. - Updated `README.md` to link `components.md` and revised information about components.
1 parent a456b12 commit 5bf2559

File tree

3 files changed

+96
-1
lines changed

3 files changed

+96
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ bitrix [main 23.600+](https://dev.1c-bitrix.ru/docs/versions.php?lang=ru&module=
3535
- универсальные обработчики событий <code>/lib/handlers_add.php</code> с подключением констант-рубильников из файла <code>/lib/constants.php</code>
3636
- скрипт [xhprof.php](docs/xhprof.md) для быстрого профилирования "боевых" проектов
3737
- страница <code>pages/error.php</code> с перехватом фатальных php-ошибок и отправке их на почту разработчикам (размещается в DOCUMENT_ROOT проекта)
38-
- компоненты в папке <code>install/components</code> для копирования в <code>/local/components</code>
38+
- [компоненты](docs/components.md) в папке <code>install/components</code> для копирования в <code>/local/components</code>
3939
- <code>Hipot\Components\IblockList</code> - универсальный компонент для работы с элементами инфоблоков <code>hipot:iblock.list</code>. Этот же компонент умеет использовать и Abstract Iblock Elements Layer. В [теории двух компонент](https://github.com/bitrix-expert/bbc) - этот компонент можно использовать и для создания карточки (детальной страницы) элемента (товара, новости...)
4040
- <code>Hipot\Components\IblockSection</code> - компонент для работы со списком секций <code>hipot:iblock.section</code>
4141
- <code>Hipot\Components\HiBlockList</code> - список hightload блока <code>hipot:hiblock.list</code>

docs/components.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# TODO; описать все компоненты с примерами
2+
3+
## hipot:includer
4+
Простой компонент для создания повторно используемых виджетов или блоков на сайте:
5+
6+
```php
7+
<?
8+
\Hipot\Services\BitrixEngine::getAppD0()->IncludeComponent("hipot:includer", "widget.input_xls_file", [
9+
'IS_REQUIRED' => 'Y'
10+
], $component, ['HIDE_ICONS' => 'Y']);
11+
?>
12+
```
13+
14+
Либо целых страниц:
15+
```php
16+
<?
17+
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
18+
19+
/**
20+
* @global $APPLICATION \CMain
21+
* @global $USER \CUser
22+
* @global $DB \CDatabase
23+
* @global $USER_FIELD_MANAGER \CUserTypeManager
24+
* @global $BX_MENU_CUSTOM \CMenuCustom
25+
* @global $stackCacheManager \CStackCacheManager
26+
*/
27+
$APPLICATION->SetPageProperty('title', 'Voice Termination Solutions');
28+
$APPLICATION->SetTitle("Expand Your Reach with <br/> Reliable <span class=\"red-text\">Voice Termination Solutions</span>");
29+
?>
30+
31+
<?$APPLICATION->IncludeComponent('hipot:includer', 'page.voice', [], null, ['HIDE_ICONS' => 'Y'])?>
32+
33+
<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?>
34+
```

install/js/hipot.framework/lib.js

+61
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@
2828
});
2929
};
3030

31+
/**
32+
* Плагин для сокрытия емейлов у ссылки
33+
* @memberOf JQuery
34+
*/
35+
$.fn.mailmea = function () {
36+
let at = / AT /,
37+
dot = / DOT /g;
38+
39+
return this.each(function () {
40+
let text = $(this).data('mailme'),
41+
addr = text.replace(at, '@').replace(dot, '.');
42+
$(this).attr('href', 'mailto:' + addr);
43+
});
44+
};
45+
3146
/**
3247
* сериализует форму в объект JSON
3348
* @usage $('form').serializeJSON();
@@ -451,3 +466,49 @@ function requireJJs(libs, logik)
451466
});
452467
// console.info(libs);
453468
}
469+
470+
/**
471+
* Displays a confirmation dialog with specified text, an action to execute on confirmation, and customizable button text and color.
472+
*
473+
* @param {string} confirmTxt - The confirmation message to display in the dialog.
474+
* @param {Function} action - The callback function to execute when the confirmation button is clicked.
475+
* @param {string} btnOkTxt - The text to display on the confirmation button.
476+
* @param {string} [btnOkColor] - The optional color for the confirmation button ex.: BX.UI.Button.Color.DANGER.
477+
* @return {void}
478+
*/
479+
function confirmAndDoAction(confirmTxt, action, btnOkTxt, btnOkColor)
480+
{
481+
if (typeof btnOkColor === 'undefined') {
482+
btnOkColor = BX.UI.Button.Color.PRIMARY;
483+
}
484+
485+
BX.UI.Dialogs.MessageBox.show({
486+
message: confirmTxt,
487+
title: "",
488+
modal: true,
489+
buttons: [
490+
new BX.UI.Button(
491+
{
492+
color: btnOkColor,
493+
text: btnOkTxt,
494+
onclick: function(button, event) {
495+
action();
496+
button.context.close();
497+
}
498+
}
499+
),
500+
new BX.UI.CancelButton(
501+
{
502+
color: BX.UI.Button.Color.LINK,
503+
onclick: function(button, event) {
504+
button.context.close();
505+
}
506+
}
507+
)
508+
],
509+
});
510+
/*BX.UI.Dialogs.MessageBox.confirm(confirmTxt, '', (messageBox) => {
511+
action();
512+
messageBox.close();
513+
}, btnOkTxt);*/
514+
}

0 commit comments

Comments
 (0)