예제 #1
0
        /// <summary>
        /// Set the accordion options
        /// </summary>
        protected override void PreCreateScripts()
        {
            ClientOptions.Add("header", "> h3");
            if (this.SelectedIndex == -1)
            {
                ClientOptions.Add("active", false);
            }
            else
            {
                ClientOptions.Add("active", this.SelectedIndex);
            }
            if (this.Animated)
            {
                ClientOptions.Add("animated", "slide");
            }
            else
            {
                ClientOptions.Add("animated", false);
            }
            ClientOptions.AddRaw("change", @"function(event, ui) {
$(':focusable:first', ui.newContent).focus();
}");
        }
예제 #2
0
파일: Dialog.cs 프로젝트: sharad2/dcmslive
        /// <summary>
        /// <inheritdoc />
        /// </summary>
        protected override void PreCreateScripts()
        {
            JQueryOptions buttonOptions = new JQueryOptions();

            foreach (DialogButton btn in this.Buttons)
            {
                btn.AddButtonOption(this, buttonOptions);
            }

            ClientOptions.Add("buttons", buttonOptions);

            if (Buttons.Count > 0)
            {
                // If no button has been specified as default, use the cancel button. If no cancel button, use the first one.
                DialogButton defButton = Buttons.FirstOrDefault(p => p.IsDefault);
                if (defButton == null)
                {
                    defButton = Buttons.OfType <CloseButton>().FirstOrDefault();
                }
                if (defButton == null)
                {
                    // Use the first button as default
                    defButton = Buttons[0];
                }
                ClientOptions.Add("_defButtonText", defButton.Text);
            }

            if (this.EnablePostBack)
            {
                ClientOptions.Add("_enablePostBack", true);
            }
            if (_ajax != null)
            {
                _ajax.UpdateStartupOptions(this, this.ClientOptions);
            }
            if (this.Width != Unit.Empty)
            {
                if (this.Width.Type != UnitType.Pixel)
                {
                    throw new HttpException("Dialog width can only be specified in pixels");
                }
                this.ClientOptions.Add("width", this.Width.Value.ToString());
            }

            switch (this.DialogStyle)
            {
            case DialogStyle.Default:
                break;

            case DialogStyle.Picker:
                this.ClientOptions.Add("dialogClass", "ui-pickerdialog");
                if (!this.ClientOptions.ContainsKey("modal"))
                {
                    this.ClientOptions.Add("modal", true);
                }
                break;

            case DialogStyle.AlwaysVisible:
                this.ClientOptions.Add("dialogClass", "ui-fixeddialog");
                break;

            default:
                throw new NotImplementedException();
            }
            JQueryScriptManager.Current.RegisterScripts(ScriptTypes.AjaxDialog);

            if (JQueryScriptManager.IsAjaxCall && this.Page.Form != null && _ajax != null && _ajax.UseDialog)
            {
                // Make sure we get destroyed if and when the page posts back
                string script = string.Format(@"$('#{0}').submit(function(e) {{
    $('#{1}').dialog('destroy').remove();
}});", this.Page.Form.ClientID, this.ClientID);
                JQueryScriptManager.Current.RegisterReadyScript(script);
            }
        }