本文整理汇总了PHP中yii\bootstrap\Modal类的典型用法代码示例。如果您正苦于以下问题:PHP Modal类的具体用法?PHP Modal怎么用?PHP Modal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Modal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Runs the widget.
*/
public function run()
{
// Print elfinder widget in modal
Modal::begin(['toggleButton' => false, 'id' => $this->options['id'] . '-dialog', 'size' => Modal::SIZE_LARGE]);
echo ElFinder::widget(['language' => $this->language, 'controller' => $this->controller, 'path' => $this->path, 'filter' => 'image', 'callbackFunction' => new JsExpression('function(file, id){
console.log( file.url, "' . $this->buttonOptions['id'] . '" );
$("#' . $this->options['id'] . '").val( file.url );
$("#' . $this->options['id'] . '-thumb").attr("src", file.url ).show();
$("#' . $this->options['id'] . '-dialog").modal("hide");
}'), 'path' => $this->path, 'frameOptions' => ['style' => 'width: 100%; height: 500px; border: 0px;']]);
Modal::end();
// Render input and upload button
if ($this->hasModel()) {
$attr = $this->attribute;
$hidden = $this->model->{$attr} ? '' : 'display:none;';
$replace['{image}'] = '<img id="' . $this->options['id'] . '-thumb" class="thumbnail" src="' . $this->model->{$attr} . '" style="max-width: 150px; max-height: 150px; ' . $hidden . '" />';
$replace['{input}'] = Html::activeTextInput($this->model, $this->attribute, $this->options);
} else {
$hidden = $this->value ? '' : 'display:none;';
$replace['{image}'] = '<img id="' . $this->options['id'] . '-thumb" src="' . $this->value . '" style="max-width: 150px; max-height: 150px; ' . $hidden . '" />';
$replace['{input}'] = Html::textInput($this->name, $this->value, $this->options);
}
$replace['{button}'] = Html::tag($this->buttonTag, $this->buttonName, $this->buttonOptions);
echo strtr($this->template, $replace);
// Publish assets
AssetsCallBack::register($this->getView());
if (!empty($this->multiple)) {
$this->getView()->registerJs("\n\n mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ",\n function(files, id){\n var _f = [];\n for (var i in files) { _f.push(files[i].url); }\n \$('#' + id).val(_f.join(', ')).trigger('change');\n return true;\n });\n\n \$(document).on('click','#" . $this->buttonOptions['id'] . "',\n function(){\n mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");\n }\n );");
} else {
$this->getView()->registerJs("\n\n mihaildev.elFinder.register(" . Json::encode($this->options['id']) . ", function(file, id){\n \$('#' + id).val(file.url).trigger('change');\n return true;\n });\n\n \$(document).on('click',\n '#" . $this->buttonOptions['id'] . "',\n function(){\n //mihaildev.elFinder.openManager(" . Json::encode($this->_managerOptions) . ");\n \$('#" . $this->options['id'] . "-dialog').modal('show');\n }\n );");
}
}
示例2: run
public function run()
{
Icon::map($this->view, Icon::FA);
echo "<div id='cjModalContent'>" . Icon::show('refresh fa-spin', [], Icon::FA) . "</div>";
// echo "".Icon::show('refresh fa-spin', [], Icon::FA)."";
parent::run();
}
示例3: run
/**
* Renders the widget.
*/
public function run()
{
$this->registerClientScript();
$button = Html::button(FontAwesome::icon('picture-o') . ' ' . $this->buttonLabel, $this->buttonOptions);
if ($this->iframe) {
$button .= Modal::widget(['id' => $this->getIFrameModalId(), 'header' => Html::tag('h4', $this->modalTitle, ['class' => 'modal-title']), 'size' => Modal::SIZE_LARGE, 'options' => ['class' => 'kcfinder-modal']]);
}
$thumbs = '';
if ($this->hasModel() && is_array($this->model->{$this->attribute})) {
$images = $this->model->{$this->attribute};
foreach ($images as $path) {
$thumbs .= strtr($this->thumbTemplate, ['{thumbSrc}' => $this->getThumbSrc($path), '{inputName}' => $this->getInputName(), '{inputValue}' => $path]);
}
}
$thumbs = Html::tag('ul', $thumbs, ['id' => $this->getThumbsId(), 'class' => 'kcf-thumbs']);
echo Html::tag('div', strtr($this->template, ['{button}' => $button, '{thumbs}' => $thumbs]), ['class' => 'kcf-input-group']);
}
示例4: JsExpression
echo $form->field($model, 'description')->widget(LangInputWidget::classname(), ['options' => ['type' => 'activeTextarea']]);
?>
<?php
echo $form->field($model, 'content')->widget(LangInputWidget::classname(), ['options' => ['type' => 'activeTextarea', 'redactor' => true, 'urlPreffix' => 'news/', 'form' => $form]]);
?>
</div>
<div class="tab-pane" id="tags-tab">
<?
$modalNewTag = Modal::widget([
'id' => 'new-tag-modal',
'toggleButton' => [
'label' => Yii::t('b/news/tag', 'Add new tag'),
'tag' => 'a',
'data-target' => '#new-tag-modal',
'href' => Url::toRoute(['tag/add-new-tag']),
],
'closeButton' => [
'tag' => 'button',
'label' => '<span aria-hidden="true">×</span>'
],
'clientOptions' => false,
]);
?>
<?php
echo $form->field($model, 'tagIds')->widget(SelectizeTextInput::className(), ['loadUrl' => ['tag/tags-list'], 'options' => ['class' => 'form-control'], 'clientOptions' => ['plugins' => ['remove_button', 'restore_on_backspace', 'drag_drop'], 'valueField' => 'id', 'labelField' => 'name', 'searchField' => ['name'], 'options' => new JsExpression($model->getTagItems()), 'items' => $model->getTagIds(true), 'hideSelected' => true, 'closeAfterSelect' => true]])->hint($modalNewTag);
?>
</div>
<div class="tab-pane" id="image-tab">
<?php
echo $form->field($model, 'image')->widget(FileInputWidget::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['initialPreview' => $model->getThumbFileUrl('image', 'small') ? [Html::img($model->getThumbFileUrl('image', 'small'), ['class' => 'file-preview-image'])] : []]]);
?>
示例5: getModal
public function getModal()
{
if (self::$_modal === null) {
ob_start();
ob_implicit_flush(false);
$this->optionsModal['class'] = Modal::className();
self::$_modal = Yii::createObject($this->optionsModal);
$out = self::$_modal->run();
$out = ob_get_clean() . $out;
$view = $this->getView();
$view->on($view::EVENT_END_BODY, function () use($out) {
echo $out;
});
}
return self::$_modal;
}
示例6: initializeModal
private function initializeModal(){
Modal::begin([
'id' => 'activity-modal',
'size' => $this->size,
'header' => '<h2>'. $this->modelTitle .'</h2>',
'footer' => Html::button('Close', ['class' => 'btn btn-info', 'data-dismiss' => 'modal']),
]);
Modal::end();
// Modal::begin([
// 'id' => 'activity-delete-modal',
// 'header' => '<h2>'. $this->deleteModelTitle .'</h2>',
// 'footer' => Html::button('Close', ['class' => 'btn btn-default', 'data-dismiss' => 'modal'])
// . PHP_EOL . Html::button('Delete', [
// 'class' => 'btn btn-primary btn-modal-save',
// 'id' => 'delete-role-model',
// 'data-id' => '',
// 'onClick' => new JsExpression('var id=$("#delete-role-model").attr("data-id");$.ajax({type:"'. $this->deleteVerb .'",url:"'.$this->deleteUrl.'",data:{id:id},success:function(){$.pjax.reload({container:"#'. $this->pjaxContainerId .'",timeout:2e3}),$("#activity-delete-modal").modal("hide")}});')
// ]),
// ]);
// echo 'Are You Sure To Delete This Item';
// Modal::end();
}
示例7: init
/**
* Initializes the widget.
*/
public function init()
{
$this->options = array_merge(['class' => 'modal-fs fade'], $this->options);
$padding = $this->modalBodyPadding === false ? '0' : $this->modalBodyPadding;
$this->getView()->registerCss("\n .modal-fs .modal-body{\n padding:{$padding};\n }\n ");
parent::init();
FullscreenModalAsset::register($this->getView());
}
示例8: run_iframe
/**
* iframe modal 框架模态弹出窗
*/
private function run_iframe()
{
\Yii::$app->view->on(View::EVENT_END_BODY, function () {
Modal::begin(['id' => 'iframeModal', 'header' => '<h4 class="modal-title"> Header </h4>', 'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">Close</a>', 'size' => Modal::SIZE_LARGE]);
echo '<iframe ></iframe>';
Modal::end();
});
$this->ifram_jscode();
}
示例9: run
/**
* @inheritdoc
*/
public function run()
{
parent::run();
if ($this->remote) {
$id = $this->options['id'];
$url = Url::to($this->remote);
$this->getView()->registerJs("Admin.Modal.remote('#{$id}', '{$url}');");
}
}
示例10: genModal
private function genModal()
{
$forceOptions = ['size' => Modal::SIZE_LARGE];
$modal = Modal::begin(array_merge($this->modalOptions, $forceOptions));
if ($this->fieldID !== null && $this->returnType === null) {
$this->returnType = self::RETURN_TYPE_URL;
}
$url = Url::to([$this->browserUrl, 'fieldID' => $this->fieldID, 'returnType' => $this->returnType, 'modalID' => $modal->id, 'subDir' => $this->options['subDir'], 'createDir' => $this->options['createDir'], 'changeDir' => $this->options['changeDir'], 'upload' => $this->options['upload']]);
echo '<iframe src="' . $url . '" frameborder="0" style="height:80vh;width:100%"></iframe>';
Modal::end();
}
示例11: run
public function run()
{
parent::run();
Modal::end();
echo Html::endTag('div');
$view = $this->getView();
ModalViewAsset::register($view);
$settings = ['containerSelector' => $this->containerSelector];
$context = $this->containerSelector === null ? 'teleport.$commonContainer' : "\$('{$this->containerSelector}')";
$view->registerJs("jQuery('#{$this->id}',{$context}).modalView(" . Json::encode($settings) . ");");
}
示例12: run
public function run()
{
if (is_null($this->imageOptions)) {
$this->imageOptions = ['class' => 'img-responsive'];
}
$this->imageOptions['id'] = Yii::$app->getSecurity()->generateRandomString(10);
$inputField = Html::getInputId($this->model, $this->attribute);
echo Html::beginTag('div', ['id' => $inputField . '-cutter']);
echo Html::activeFileInput($this->model, $this->attribute);
echo Html::beginTag('div', ['class' => 'preview-pane', 'style' => $this->model->{$this->attribute} ? 'display:block' : 'display:none']);
echo Html::beginTag('div', ['class' => 'preview-container']);
echo Html::img($this->model->{$this->attribute} ? $this->model->{$this->attribute} : null, ['class' => 'preview-image img-responsive']);
echo Html::endTag('div');
echo Html::endTag('div');
echo Html::checkbox($this->attribute . '-remove', false, ['label' => Yii::t('sadovojav/cutter/default', 'REMOVE')]);
Modal::begin(['header' => Html::tag('h4', Yii::t('sadovojav/cutter/default', 'CUTTER')), 'closeButton' => [], 'footer' => $this->getModalFooter($inputField), 'size' => Modal::SIZE_LARGE]);
echo Html::beginTag('div', ['class' => 'image-container']);
echo Html::img(null, $this->imageOptions);
echo Html::endTag('div');
echo Html::tag('br');
echo Html::beginTag('div', ['class' => 'row']);
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/default', 'ASPECT_RATIO'), $inputField . '-aspectRatio');
echo Html::textInput($this->attribute . '-aspectRatio', isset($this->jcropOptions['aspectRatio']) ? $this->jcropOptions['aspectRatio'] : 0, ['id' => $inputField . '-aspectRatio', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/default', 'ANGLE'), $inputField . '-dataRotate');
echo Html::textInput($this->attribute . '-cropping[dataRotate]', '', ['id' => $inputField . '-dataRotate', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/default', 'POSITION') . ' (X)', $inputField . '-dataX');
echo Html::textInput($this->attribute . '-cropping[dataX]', '', ['id' => $inputField . '-dataX', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/default', 'POSITION') . ' (Y)', $inputField . '-dataY');
echo Html::textInput($this->attribute . '-cropping[dataY]', '', ['id' => $inputField . '-dataY', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/default', 'WIDTH'), $inputField . '-dataWidth');
echo Html::textInput($this->attribute . '-cropping[dataWidth]', '', ['id' => $inputField . '-dataWidth', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::beginTag('div', ['class' => 'col-md-2']);
echo Html::label(Yii::t('sadovojav/cutter/default', 'HEIGHT'), $inputField . '-dataHeight');
echo Html::textInput($this->attribute . '-cropping[dataHeight]', '', ['id' => $inputField . '-dataHeight', 'class' => 'form-control']);
echo Html::endTag('div');
echo Html::endTag('div');
Modal::end();
echo Html::endTag('div');
$view = $this->getView();
CutterAsset::register($view);
$options = ['inputField' => $inputField, 'useWindowHeight' => $this->useWindowHeight, 'jcropOptions' => $this->jcropOptions];
$options = Json::encode($options);
$view->registerJs('jQuery("#' . $inputField . '").cutter(' . $options . ');');
}
示例13: run
/**
* @inheritdocs
*/
public function run()
{
$view = $this->getView();
parent::run();
ModalAsset::register($view);
$id = $this->options['id'];
$ajaxSubmit = $this->ajaxSubmit ? 'true' : 'false';
$js = <<<JS
jQuery('#{$id}').kbModalAjax({
url: '{$this->url}',
ajaxSubmit: {$ajaxSubmit},
});
JS;
$view->registerJs($js);
}
示例14: init
/**
* Initializes the widget.
* This method will register the bootstrap asset bundle. If you override this method,
* make sure you call the parent implementation first.
*/
public function init()
{
parent::init();
if (!isset($this->options['id'])) {
$this->options['id'] = $this->getId();
}
if (!isset($this->element) || $this->element === false) {
$this->element = 'document.body';
}
//Prepare modal dialog
ob_start();
ob_implicit_flush(false);
$this->_modal = \Yii::createObject(['class' => Modal::className(), 'header' => '<h4 class="modal-title">Карта</h4>', 'size' => Modal::SIZE_DEFAULT, 'toggleButton' => false, 'footer' => '<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>']);
$this->_modal->run();
$this->_modalHtml = ob_get_clean();
}
示例15: run
public function run()
{
$params = [];
$footer = $this->getButtons();
if ($footer) {
$params['footer'] = $footer;
}
if ($this->title) {
$params['header'] = '<h4>' . Html::encode($this->title) . '</h4>';
}
//~ if($this->updateModal) {
//~ $params['options']['data-update-modal'] = Url::to($this->updateModal);
//~ }
BaseModal::begin($params);
echo $this->content;
BaseModal::end();
}