示例#1
0
        /// <summary>
        /// 获取添加选项卡的脚本
        /// </summary>
        /// <param name="tabID">选项卡ID</param>
        /// <param name="iframeUrl">IFrame地址</param>
        /// <param name="tabTitle">选项卡标题</param>
        /// <param name="iconUrl">选项卡图标</param>
        /// <param name="enableClose">是否可以关闭</param>
        /// <returns>客户端脚本</returns>
        public string GetAddTabReference(string tabID, string iframeUrl, string tabTitle, string iconUrl, bool enableClose)
        {
            if (!String.IsNullOrEmpty(iframeUrl))
            {
                iframeUrl = ResolveIFrameUrl(iframeUrl);
            }

            JsObjectBuilder options = new JsObjectBuilder();

            options.AddProperty("id", tabID);
            options.AddProperty("url", iframeUrl);
            options.AddProperty("title", tabTitle);
            options.AddProperty("closable", enableClose);

            string iconScript = String.Empty;

            if (!String.IsNullOrEmpty(iconUrl))
            {
                string className = String.Format("icon_{0}", System.Guid.NewGuid().ToString("N"));
                iconScript = String.Format("F.addCSS('{0}','{1}');", className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(iconUrl)));

                options.AddProperty("iconCls", className);
            }

            return(iconScript + String.Format("{0}.addTab({1});", ScriptID, options));
        }
示例#2
0
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <param name="message">对话框消息</param>
        /// <param name="title">对话框标题</param>
        /// <param name="messageBoxIcon"></param>
        /// <param name="okScript">点击确定按钮执行的客户端脚本</param>
        /// <param name="target">显示对话框的目标页面</param>
        /// <param name="icon"></param>
        /// <param name="iconUrl">自定义对话框图标地址</param>
        /// <returns>客户端脚本</returns>
        public static string GetShowReference(string message, string title, MessageBoxIcon messageBoxIcon, string okScript, Target target, Icon icon, string iconUrl)
        {
            if (message == null)
            {
                message = String.Empty;
            }
            if (title == null)
            {
                title = String.Empty;
            }

            string addCSSScript       = String.Empty;
            string iconScriptFragment = String.Empty;
            string resolvedIconUrl    = IconHelper.GetResolvedIconUrl(icon, iconUrl);

            Page page = HttpContext.Current.CurrentHandler as Page;

            if (page != null)
            {
                resolvedIconUrl = page.ResolveUrl(resolvedIconUrl);
            }

            // Icon 或者 IconUrl 不为空
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                string className = String.Format("box-{0}-alert-icon", System.Guid.NewGuid().ToString("N"));

                var addCSSPrefix = String.Empty;
                if (target == Target.Parent)
                {
                    addCSSPrefix = "parent.";
                }
                else if (target == Target.Top)
                {
                    addCSSPrefix = "top.";
                }
                addCSSScript = String.Format("{0}X.util.addCSS('{1}','{2}');", addCSSPrefix, className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, resolvedIconUrl));

                iconScriptFragment = String.Format("'{0}'", className);
            }
            else
            {
                iconScriptFragment = MessageBoxIconHelper.GetName(messageBoxIcon);
            }

            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");
            title   = title.Replace("\r\n", "\n").Replace("\n", "<br/>");
            string targetScript = "window";

            if (target != Target.Self)
            {
                targetScript = TargetHelper.GetScriptName(target);
            }

            if (String.IsNullOrEmpty(title) &&
                messageBoxIcon == DefaultMessageBoxIcon &&
                String.IsNullOrEmpty(okScript) &&
                String.IsNullOrEmpty(resolvedIconUrl))
            {
                return(addCSSScript + String.Format("{0}.X.alert({1});", targetScript, JsHelper.GetJsString(message)));
            }
            else
            {
                return(addCSSScript + String.Format("{0}.X.alert({1},{2},{3},{4});",
                                                    targetScript,
                                                    JsHelper.GetJsStringWithScriptTag(message),
                                                    JsHelper.GetJsString(title),
                                                    iconScriptFragment,
                                                    String.IsNullOrEmpty(okScript) ? "''" : JsHelper.GetFunction(okScript)));
            }
        }
示例#3
0
文件: Alert.cs 项目: goupviet/FineUI
        /// <summary>
        /// 获取显示对话框的客户端脚本
        /// </summary>
        /// <returns>客户端脚本</returns>
        public string GetShowReference()
        {
            //return GetShowReference(Message, Title, MessageBoxIcon, OkScript, Target, Icon, IconUrl);

            //if (message == null)
            //{
            //    message = String.Empty;
            //}
            //if (title == null)
            //{
            //    title = String.Empty;
            //}

            string message = "";
            string title   = "";

            if (!String.IsNullOrEmpty(Message))
            {
                message = Message;
            }
            if (!String.IsNullOrEmpty(Title))
            {
                title = Title;
            }


            string addCSSScript       = String.Empty;
            string iconScriptFragment = String.Empty;
            string resolvedIconUrl    = IconHelper.GetResolvedIconUrl(Icon, IconUrl);

            Page page = HttpContext.Current.CurrentHandler as Page;

            if (page != null)
            {
                resolvedIconUrl = page.ResolveUrl(resolvedIconUrl);
            }

            Target target = Target;

            // Icon 或者 IconUrl 不为空
            if (!String.IsNullOrEmpty(resolvedIconUrl))
            {
                string className = String.Format("f-{0}-alert-icon", System.Guid.NewGuid().ToString("N"));

                var addCSSPrefix = String.Empty;
                if (target == Target.Parent)
                {
                    addCSSPrefix = "parent.";
                }
                else if (target == Target.Top)
                {
                    addCSSPrefix = "top.";
                }
                addCSSScript = String.Format("{0}F.addCSS('{1}','{2}');", addCSSPrefix, className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, resolvedIconUrl));

                iconScriptFragment = String.Format("'{0}'", className);
            }
            else
            {
                iconScriptFragment = MessageBoxIconHelper.GetName(MessageBoxIcon);
            }

            message = message.Replace("\r\n", "\n").Replace("\n", "<br/>");
            title   = title.Replace("\r\n", "\n").Replace("\n", "<br/>");
            string targetScript = "window";

            if (target != Target.Self)
            {
                targetScript = TargetHelper.GetScriptName(target);
            }

            JsObjectBuilder jsob = new JsObjectBuilder();

            if (!String.IsNullOrEmpty(CssClass))
            {
                jsob.AddProperty("cls", CssClass);
            }
            if (!String.IsNullOrEmpty(title))
            {
                jsob.AddProperty("title", title);
            }
            if (!String.IsNullOrEmpty(OkScript))
            {
                jsob.AddProperty("ok", JsHelper.GetFunction(OkScript), true);
            }
            if (!String.IsNullOrEmpty(message))
            {
                jsob.AddProperty("message", JsHelper.EnquoteWithScriptTag(message), true);
            }
            if (!String.IsNullOrEmpty(iconScriptFragment))
            {
                jsob.AddProperty("messageIcon", iconScriptFragment, true);
            }

            return(addCSSScript + String.Format("{0}.F.alert({1});", targetScript, jsob));
        }
示例#4
0
        /// <summary>
        /// 渲染 HTML 之前调用(页面第一次加载或者普通回发)
        /// </summary>
        protected override void OnFirstPreRender()
        {
            base.OnFirstPreRender();

            #region options

            OB.AddProperty("animCollapse", false);
            OB.AddProperty("collapsible", EnableCollapse);
            OB.AddProperty("collapsed", Collapsed);

            #endregion

            #region ShowHeader

            if (ShowHeader)
            {
                //OB.AddProperty("title", String.IsNullOrEmpty(Title) ? String.Format("[{0}]", ID) : Title);

                OB.AddProperty("title", Title);
            }
            else
            {
                OB.AddProperty("header", false);
            }

            #endregion

            #region IconUrl

            if (!String.IsNullOrEmpty(IconUrl))
            {
                // Window控件的特殊处理在Window控件中
                // 添加CSS样式
                string className = String.Format("f-{0}-panelbase-icon", XID);
                AddStartupCSS(className, StyleUtil.GetNoRepeatBackgroundStyle("." + className, ResolveUrl(IconUrl)));

                OB.AddProperty("iconCls", className);

                //// 下面这种方式不行,这个样式是要添加到Head中的,而不是最外层的DIV
                //AddExtraStyle("background", StyleUtil.GetNoRepeatBackgroundStyleValue(ResolveUrl(IconUrl)));
            }

            #endregion

            #region old code

            //if (IconClassName != "") OB.AddProperty(OptionName.IconCls, IconClassName);

            // Listeners, 折叠展开
            //JsObjectBuilder listenersBuilder = new JsObjectBuilder();
            //listenersBuilder.AddProperty("collapse", String.Format("function(panel){{Ext.get('{0}').dom.value=true;}}", CollapsedHiddenField.ClientID), true);
            //listenersBuilder.AddProperty("expand", String.Format("function(panel){{Ext.get('{0}').dom.value=false;}}", CollapsedHiddenField.ClientID), true);
            //OBuilder.AddProperty("listeners", listenersBuilder.ToString(), true);


            //if (EnableCollapse)
            //{
            //    OB.Listeners.AddProperty("collapse", String.Format("function(panel){{Ext.get('{0}').dom.value=true;}}", CollapsedHiddenFieldID), true);
            //    OB.Listeners.AddProperty("expand", String.Format("function(panel){{Ext.get('{0}').dom.value=false;}}", CollapsedHiddenFieldID), true);
            //}



            //string hiddenFieldsScript = String.Empty;

            //if (EnableCollapse)
            //{
            //    hiddenFieldsScript += GetSetHiddenFieldValueScript(CollapsedHiddenFieldID, Collapsed.ToString().ToLower());
            //}

            //hiddenFieldsScript += "\r\n";

            //// 在ControlBase的RegisterControlStartupScript函数中做过处理,会把在基类中注册的脚本合并后再整体注册
            ////AddStartupScript(this, hiddenFieldsScript);
            //AddPageFirstLoadScript(hiddenFieldsScript);

            #endregion

            #region EnableCollapseEvent

            if (EnableCollapseEvent)
            {
                //string collapseScript = JsHelper.GetFunction(GetPostBackEventReference("Collapse"));
                //OB.Listeners.AddProperty("collapse", collapseScript, true);
                AddListener("collapse", GetPostBackEventReference("Collapse"));
            }

            if (EnableExpandEvent)
            {
                //string expandScript = JsHelper.GetFunction(GetPostBackEventReference("Expand"));
                //OB.Listeners.AddProperty("expand", expandScript, true);
                AddListener("expand", GetPostBackEventReference("Expand"));
            }

            #endregion
        }