예제 #1
0
        protected override void InitOption(TagHelperContext context, TagHelperOutput output)
        {
            var content = output.Content.GetContent(HtmlEncoder.Default);

            if (Url.IsNotNullOrWhiteSpace())
            {
                Type    = DialogType.Frame;
                content = Url;
            }
            else if (!content.IsNotNullOrWhiteSpace())
            {
                Type = DialogType.Page;
            }

            Options.Add("type", Type);
            Options.AddIf(Title.IsNotNullOrWhiteSpace(), "title", Title);
            Options.AddIf(content.IsNotNullOrWhiteSpace(), LayuiConsts.Dialog_Content, content);
            Options.AddIf(Area.IsNotNullOrWhiteSpace(), "area", Area);
            if (HasSave)
            {
                Options.Add("btn", new[] { SaveButtonName });
                if (OnSave.IsNotNullOrWhiteSpace())
                {
                    Options.Add("yes", GetJavaScriptString($"function(){{ {OnSave} }} }}"));
                }
            }

            Options.AddIf(OnClose.IsNotNullOrWhiteSpace(), LayuiConsts.Dialog_OnClose, GetJavaScriptString($"function(){{ {OnClose} }}"));
            Options.AddIf(OnShow.IsNotNullOrWhiteSpace(), LayuiConsts.Dialog_OnShow, GetJavaScriptString($"function(){{ {OnShow} }}"));
            Options.AddIf(IsMax, LayuiConsts.Dialog_IsMax, IsMax);
            Options.AddIf(ShowMaxMin, LayuiConsts.Dialog_IsMaxMin, true);
            Options.AddIf(MaxWidth > 0, "maxWidth", MaxWidth);
            Options.AddIf(MaxHeight > 0, "maxHeight", MaxHeight);

            base.InitOption(context, output);
        }