public static string GetDefaultBackgroundColor() { string backgroundColor = String.Empty; if (String.IsNullOrEmpty(PageManager.Instance.CustomTheme)) { string theme = PageManager.Instance.Theme.ToString(); if (theme.ToLower() == ThemeHelper.GetName(Theme.Blue)) { backgroundColor = "#DFE8F6"; } else if (theme.ToLower() == ThemeHelper.GetName(Theme.Gray)) { backgroundColor = "#efefef"; } } return(backgroundColor); }
internal static void RegisterCommonResource(Page page) { #region powered-by string metaName = "powered-by"; string metaContent = String.Format("FineUI v{0} - 基于 ExtJS 的开源 ASP.NET 控件库 - http://fineui.com/", GlobalConfig.ProductVersion); AddContentToHead(page, CONTROL_ID_PREFIX + "comments", String.Format(META_TEMPLATE, metaName, metaContent)); #endregion // ExtJS CSS & JS 版本号,只有升级更新CSS或者JS时才需要更新。 //string extjsCSSJSVersion = "3"; //string fineuiVersion = GlobalConfig.ProductVersion; string extjsBasePath = page.ResolveUrl(GlobalConfig.GetExtjsBasePath()); #region css if (!String.IsNullOrEmpty(PageManager.Instance.CustomTheme)) { AddCssPathToHead(page, CONTROL_ID_PREFIX + "notheme.css", String.Format("{0}/res/css/notheme.css", extjsBasePath)); string themePath = String.Format("{0}/css/xtheme-{1}.css", page.ResolveUrl(PageManager.Instance.CustomThemeBasePath), PageManager.Instance.CustomTheme); AddCssPathToHead(page, CONTROL_ID_PREFIX + "custom-theme.css", themePath); AddCssPathToHead(page, CONTROL_ID_PREFIX + "ux.css", String.Format("{0}/res/css/ux.css", extjsBasePath)); } else { string themeName = ThemeHelper.GetName(PageManager.Instance.Theme); AddCssPathToHead(page, CONTROL_ID_PREFIX + themeName + ".css", String.Format("{0}/res/css/{1}.css", extjsBasePath, themeName)); } /* AddCssResourceToHead(page, CONTROL_ID_PREFIX + "notheme.css", "FineUI.res.css.notheme.css&v=" + extjsCSSJSVersion); if (!String.IsNullOrEmpty(PageManager.Instance.CustomTheme)) { string themePath = String.Format("{0}/css/xtheme-{1}.css", page.ResolveUrl(PageManager.Instance.CustomThemeBasePath), PageManager.Instance.CustomTheme); AddCssPathToHead(page, CONTROL_ID_PREFIX + "custom-theme.css", themePath); } else { var themeName = ThemeHelper.GetName(PageManager.Instance.Theme); AddCssResourceToHead(page, CONTROL_ID_PREFIX + themeName + ".css", "FineUI.res.css." + themeName + ".css&v=" + extjsCSSJSVersion); } if (GlobalConfig.GetDebugMode()) { AddCssResourceToHead(page, CONTROL_ID_PREFIX + "ux.ux.css", "FineUI.res.css.ux.ux.css&v=" + DateTime.Now.Ticks.ToString()); } else { AddCssResourceToHead(page, CONTROL_ID_PREFIX + "ux.css", "FineUI.res.css.ux.css&v=" + fineuiVersion); } * */ #endregion #region javascript if (GlobalConfig.GetDebugMode()) { AddJavascriptPathToPageBottom(page, "ext-debug.js", String.Format("{0}/ext-debug.js", extjsBasePath)); AddJavascriptPathToPageBottom(page, "x-debug.js", String.Format("{0}/x-debug.js", extjsBasePath)); } else { AddJavascriptPathToPageBottom(page, "ext.js", String.Format("{0}/ext.js", extjsBasePath)); } // 语言资源应该放在最后,其中包含对 X.js 的语言定义 string langName = LanguageHelper.GetName(PageManager.Instance.Language); AddJavascriptPathToPageBottom(page, langName + ".js", String.Format("{0}/lang/{1}.js", extjsBasePath, langName)); /* AddJavascriptIncludeToPageBottom(page, "ext-core.js", "FineUI.js.ext-core.js&v=" + extjsCSSJSVersion); AddJavascriptIncludeToPageBottom(page, "ext-foundation.js", "FineUI.js.ext-foundation.js&v=" + extjsCSSJSVersion); List<string> components = ResourceManager.Instance.JavaScriptComponentList; if (components.Contains("form")) { AddJavascriptIncludeToPageBottom(page, "ext-form.js", "FineUI.js.ext-form.js&v=" + extjsCSSJSVersion); } if (components.Contains("grid")) { AddJavascriptIncludeToPageBottom(page, "ext-grid.js", "FineUI.js.ext-grid.js&v=" + extjsCSSJSVersion); } if (GlobalConfig.GetDebugMode()) { AddJavascriptIncludeToPageBottom(page, "x-debug.js", "FineUI.js.x-debug.js&v=" + fineuiVersion); //DateTime.Now.Ticks.ToString()); } else { AddJavascriptIncludeToPageBottom(page, "x.js", "FineUI.js.x.js&v=" + fineuiVersion); } // 语言资源应该放在最后,其中包含对 X.js 的语言定义 string languageName = LanguageHelper.GetName(PageManager.Instance.Language); AddJavascriptIncludeToPageBottom(page, languageName + ".js", "FineUI.js.lang.ext-lang-" + languageName + ".js&v=" + extjsCSSJSVersion); */ #region release old code //LiteralControl boxPageStartTimeControl = new LiteralControl(); //boxPageStartTimeControl.ID = "FineUI-page-start-time"; //boxPageStartTimeControl.Text = "<script type=\"text/javascript\">var boxPageStartTime=new Date();</script>"; //page.Controls.Add(new LiteralControl("<script type=\"text/javascript\">var boxPageEndTime=new Date();</script>")); //if (GlobalConfig.GetDebugMode()) //{ // //// 注册开始下载页面脚本的时间 // //page.ClientScript.RegisterStartupScript(page.GetType(), "x_start_javascript_time", String.Format(SCRIPT_CONTENT_TEMPLATE, "var x_start_javascript_time=new Date();"), false); // AddJavascriptIncludeToPageBottom(page, "ext-base.js", "FineUI.js.lib.ext-base.js"); // AddJavascriptIncludeToPageBottom(page, "ext-all.js", "FineUI.js.lib.ext-all.js"); // AddJavascriptIncludeToPageBottom(page, "Base64.js", "FineUI.js.lib.Base64.js"); // AddJavascriptIncludeToPageBottom(page, "json2.js", "FineUI.js.lib.json2.js"); // AddJavascriptIncludeToPageBottom(page, "ux.js", "FineUI.js.ux.ux.js"); // AddJavascriptIncludeToPageBottom(page, "X.js", "FineUI.js.X.X.js"); //} //else //{ // AddJavascriptIncludeToPageBottom(page, "ext-core.js", "FineUI.js.ext-core.js"); // AddJavascriptIncludeToPageBottom(page, "ext-foundation.js", "FineUI.js.ext-foundation.js"); // foreach (string comname in new string[] { "form", "grid", "menu", "tab", "tree" }) // { // if (ResourceManager.Instance.JavaScriptComponentList.Contains(comname)) // { // AddJavascriptIncludeToPageBottom(page, "ext-" + comname + ".js", "FineUI.js.ext-" + comname + ".js"); // } // } // AddJavascriptIncludeToPageBottom(page, "x.js", "FineUI.js.x.js"); //} //if (pageManager.ApplyParentStyleJavascript) //{ // //LiteralControl jsControl = new LiteralControl(); // //jsControl.ID = "FineUI-js-inline"; // //jsControl.Text = "<script type=\"text/javascript\">" // // + "window.eval.call(window, parent.document.getElementById(\"boxJavascriptInline\").innerHTML);" // // + "</script>"; // //page.Header.Controls.AddAt(GetNextControlIndex(page), jsControl); // StringBuilder evalJsSB = new StringBuilder(); // evalJsSB.Append("<script type=\"text/javascript\">"); // evalJsSB.Append("var box_start_javascript_time=new Date();"); // evalJsSB.Append("window.eval.call(window, parent.document.getElementById(\"boxJavascriptInline\").innerHTML);"); // evalJsSB.Append("var box_end_javascript_time=new Date();"); // evalJsSB.Append("</script>"); // page.ClientScript.RegisterStartupScript(page.GetType(), "FineUI-js-inline", evalJsSB.ToString(), false); //} //else if (pageManager.EnableInlineStyleJavascript) //{ // StringBuilder jsSB = new StringBuilder(); // jsSB.Append("var box_start_javascript_time=new Date();"); // jsSB.Append(ResourceHelper.GetResourceContent("FineUI.js.ext-release.js")); // if (pageManager.Language == LanguageType.CN) // { // jsSB.Append(ResourceHelper.GetResourceContent("FineUI.js.languages.ext-lang-zh_CN.js")); // } // else if (pageManager.Language == LanguageType.TW) // { // jsSB.Append(ResourceHelper.GetResourceContent("FineUI.js.languages.ext-lang-zh_TW.js")); // } // jsSB.Append("var box_end_javascript_time=new Date();"); // //LiteralControl jsControl = new LiteralControl(); // //jsControl.ID = "FineUI-js-inline"; // //jsControl.Text = String.Format("<script type=\"text/javascript\" id=\"boxJavascriptInline\">{0}</script>", jsSB); // //page.Header.Controls.AddAt(GetNextControlIndex(page), jsControl); // page.ClientScript.RegisterStartupScript(page.GetType(), "FineUI-js-inline", // "<script type=\"text/javascript\" id=\"boxJavascriptInline\">" + jsSB.ToString() + "</script>", false); //} //else //{ //} #endregion #endregion }
internal static void RegisterCommonResource(Page page) { #region powered-by string metaName = "powered-by"; string metaContent = String.Format("FineUI v{0} - 基于 ExtJS 的开源 ASP.NET 控件库 - http://fineui.com/", GlobalConfig.ProductVersion); AddContentToHead(page, CONTROL_ID_PREFIX + "comments", String.Format(META_TEMPLATE, metaName, metaContent)); // 是否向页面输出IE=edge标识 if (PageManager.Instance.IEEdge) { AddContentToHead(page, CONTROL_ID_PREFIX + "xua", String.Format(META_TEMPLATE, "X-UA-Compatible", "IE=edge,chrome=1")); } #endregion // ExtJS CSS & JS 版本号,只有升级更新CSS或者JS时才需要更新。 //string extjsCSSJSVersion = "3"; //string fineuiVersion = GlobalConfig.ProductVersion; string extjsBasePath = page.ResolveUrl(GlobalConfig.GetJSBasePath()); #region css if (!String.IsNullOrEmpty(PageManager.Instance.CustomTheme)) { /* * AddCssPathToHead(page, CONTROL_ID_PREFIX + "notheme.css", String.Format("{0}/res/css/notheme.css", extjsBasePath)); * * string themePath = String.Format("{0}/css/xtheme-{1}.css", page.ResolveUrl(PageManager.Instance.CustomThemeBasePath), PageManager.Instance.CustomTheme); * AddCssPathToHead(page, CONTROL_ID_PREFIX + "custom-theme.css", themePath); * * AddCssPathToHead(page, CONTROL_ID_PREFIX + "ux.css", String.Format("{0}/res/css/ux.css", extjsBasePath)); */ string themeName = PageManager.Instance.CustomTheme; AddCssPathToHead(page, CONTROL_ID_PREFIX + themeName + ".css", String.Format("{0}/ext-theme-{1}/all.css?v{2}", page.ResolveUrl(PageManager.Instance.CustomThemeBasePath), themeName, GlobalConfig.ProductVersion)); } else { string themeName = ThemeHelper.GetName(PageManager.Instance.Theme); if (themeName == "blue") { themeName = "classic"; } AddCssPathToHead(page, CONTROL_ID_PREFIX + themeName + ".css", String.Format("{0}/res/ext-theme-{1}/all.css?v{2}", extjsBasePath, themeName, GlobalConfig.ProductVersion)); //AddCssPathToHead(page, CONTROL_ID_PREFIX + "ux.css", String.Format("{0}/res/css/ux.css", extjsBasePath)); } #endregion #region javascript if (GlobalConfig.GetDebugMode()) { AddJavascriptPathToPageBottom(page, "ext-part1.js", String.Format("{0}/ext-part1.js?v{1}", extjsBasePath, GlobalConfig.ProductVersion)); AddJavascriptPathToPageBottom(page, "ext-part2.js", String.Format("{0}/ext-part2.js?v{1}", extjsBasePath, GlobalConfig.ProductVersion)); } else { AddJavascriptPathToPageBottom(page, "ext-all.js", String.Format("{0}/ext-all.js?v{1}", extjsBasePath, GlobalConfig.ProductVersion)); } // Neptune需要额外的JavaScript文件 if (String.IsNullOrEmpty(PageManager.Instance.CustomTheme) && PageManager.Instance.Theme == Theme.Neptune) { AddJavascriptPathToPageBottom(page, "ext-theme-neptune.js", String.Format("{0}/ext-theme-neptune.js?v{1}", extjsBasePath, GlobalConfig.ProductVersion)); } // 语言资源应该放在最后,其中包含对 X.js 的语言定义 string langName = LanguageHelper.GetName(PageManager.Instance.Language); AddJavascriptPathToPageBottom(page, langName + ".js", String.Format("{0}/lang/{1}.js?v{2}", extjsBasePath, langName, GlobalConfig.ProductVersion)); #endregion }
/// <summary> /// 取得页面初始化时脚本 /// </summary> /// <param name="script"></param> /// <returns></returns> private string GetStartupScript(string script) { #region beforeBuilder StringBuilder beforeBuilder = new StringBuilder(); //beforeBuilder.Append("F.init();"); // ExtJS2.2的BUG,Ext.onReady会被调用两次(在ExtJS 2.2.1中已经修正) // Ext.onReady在extjsv3.1.0中依然有问题,在IE下有时会导致页面空白,不能继续执行,只有在点击Stop按钮或者重新刷新后才行。 // http://www.extjs.net/forum/showthread.php?t=69437 // http://www.extjs.com/forum/showthread.php?p=347524#post347524 // https://extjs.net/forum/showthread.php?t=86948 //beforeBuilder.Append("if(X.initialized){return;}X.initialized=true;"); // 空白图片,只在 IE6 和 IE7 下设置(默认为 http://www.sencha.com/s.gif ),其他浏览器下使用 data URL //beforeBuilder.AppendFormat("if(Ext.isIE6||Ext.isIE7){{Ext.BLANK_IMAGE_URL='{0}';}}", ResourceHelper.GetWebResourceUrl("FineUI.res.img.s.gif")); //beforeBuilder.Append("F.util.init();"); // form 相关配置 //beforeBuilder.Append("var fieldPro=Ext.form.Base.prototype;"); //beforeBuilder.AppendFormat("fieldPro.msgTarget='{0}';", MsgTargetHelper.GetName(PageManager.Instance.FormMessageTarget)); //beforeBuilder.AppendFormat("fieldPro.labelWidth={0};", PageManager.Instance.FormLabelWidth.Value); //beforeBuilder.AppendFormat("fieldPro.labelSeparator='{0}';", PageManager.Instance.FormLabelSeparator); //beforeBuilder.AppendFormat("F.util.init('{0}',{1},'{2}','{3}',{4},'{5}',{6},'{7}',{8});", // MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget), // PageManager.Instance.FormLabelWidth.Value, // PageManager.Instance.FormLabelSeparator, // //PageManager.Instance.EnableBigFont.ToString().ToLower(), // Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()), //String.Format("{0}/res/images/s.gif", GlobalConfig.GetExtjsBasePath())), //ResourceHelper.GetWebResourceUrlResAxd("FineUI.res.img.s.gif&v=1"), // //PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(), // PageManager.Instance.EnableAjaxLoading.ToString().ToLower(), // AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType), // PageManager.Instance.EnableAjax.ToString().ToLower(), // ThemeHelper.GetName(PageManager.Instance.Theme), // PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower() // ); //beforeBuilder.AppendFormat("F.util.init('{0}',{1},'{2}','{3}',{4},'{5}',{6},'{7}',{8});", // MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget), // PageManager.Instance.FormLabelWidth.Value, // PageManager.Instance.FormLabelSeparator, // //PageManager.Instance.EnableBigFont.ToString().ToLower(), // Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl()), //String.Format("{0}/res/images/s.gif", GlobalConfig.GetExtjsBasePath())), //ResourceHelper.GetWebResourceUrlResAxd("FineUI.res.img.s.gif&v=1"), // //PageManager.Instance.EnableAspnetSubmitButtonAjax.ToString().ToLower(), // PageManager.Instance.EnableAjaxLoading.ToString().ToLower(), // AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType), // PageManager.Instance.EnableAjax.ToString().ToLower(), // ThemeHelper.GetName(PageManager.Instance.Theme), // PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower() // ); JsObjectBuilder initObj = new JsObjectBuilder(); if (PageManager.Instance.FormMessageTarget != ConfigPropertyValue.FORM_MESSAGETARGET_DEFAULT) { initObj.AddProperty("msgTarget", MessageTargetHelper.GetName(PageManager.Instance.FormMessageTarget)); } if (PageManager.Instance.FormLabelWidth != ConfigPropertyValue.FORM_LABELWIDTH_DEFAULT) { initObj.AddProperty("labelWidth", PageManager.Instance.FormLabelWidth.Value); } if (PageManager.Instance.FormLabelSeparator != ConfigPropertyValue.FORM_LABELSEPARATOR_DEFAULT) { initObj.AddProperty("labelSeparator", PageManager.Instance.FormLabelSeparator); } //initObj.AddProperty("blankImageUrl", Page.ResolveUrl(ResourceHelper.GetEmptyImageUrl())); if (PageManager.Instance.EnableAjaxLoading != ConfigPropertyValue.ENABLE_AJAX_LOADING_DEFAULT) { initObj.AddProperty("enableAjaxLoading", PageManager.Instance.EnableAjaxLoading.ToString().ToLower()); } if (PageManager.Instance.AjaxLoadingType != ConfigPropertyValue.AJAX_LOADING_TYPE_DEFAULT) { initObj.AddProperty("ajaxLoadingType", AjaxLoadingTypeName.GetName(PageManager.Instance.AjaxLoadingType)); } if (PageManager.Instance.EnableAjax != ConfigPropertyValue.ENABLE_AJAX_DEFAULT) { initObj.AddProperty("enableAjax", PageManager.Instance.EnableAjax.ToString().ToLower()); } if (PageManager.Instance.Theme != Theme.Neptune) { initObj.AddProperty("theme", ThemeHelper.GetName(PageManager.Instance.Theme)); } if (PageManager.Instance.Language != ConfigPropertyValue.LANGUAGE_DEFAULT) { initObj.AddProperty("language", LanguageHelper.GetName(PageManager.Instance.Language)); } if (PageManager.Instance.EnableFormChangeConfirm) { initObj.AddProperty("formChangeConfirm", PageManager.Instance.EnableFormChangeConfirm.ToString().ToLower()); } if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT) { initObj.AddProperty("ajaxTimeout", PageManager.Instance.AjaxTimeout); } initObj.AddProperty("_version", GlobalConfig.ProductVersion); beforeBuilder.AppendFormat("F.init({0});", initObj); //if (PageManager.Instance.BeforeAjaxPostBackScript != String.Empty) //{ // beforeBuilder.AppendFormat("F.util.beforeAjaxPostBackScript=function(){{{0}}};", PageManager.Instance.BeforeAjaxPostBackScript); //} //beforeBuilder.Append("F.ajax.hookPostBack();"); //if (PageManager.Instance.EnableAjax) //{ // if (PageManager.Instance.AjaxTimeout != ConfigPropertyValue.AJAX_TIMEOUT_DEFAULT) // { // beforeBuilder.AppendFormat("Ext.Ajax.timeout={0};", PageManager.Instance.AjaxTimeout * 1000); // } //} //if (PageManager.Instance.EnableBigFont) //{ // beforeBuilder.Append("Ext.getBody().addCls('bigfont');"); //} // WindowGroup //beforeBuilder.AppendFormat("{0}=new Ext.WindowGroup();{0}.zseed=6000;", WINDOW_DEFAULT_GROUP_ID); //// CookieProvider //beforeBuilder.AppendFormat("{0}=new Ext.state.CookieProvider();", COOKIE_PROVIDER_ID); //// HiddenFields //beforeBuilder.AppendFormat("{0}=[];", HIDDEN_FIELDS_ID); // 保存页面中可输入的表单字段状态是否发生变化的隐藏字段 //innderBuilder.AppendFormat("var sn=document.createElement('input');sn.type='hidden';sn.value='false';sn.id=sn.name='{0}';Ext.getBody().query('form')[0].appendChild(sn);", PAGE_STATE_CHANGED_ID); //innderBuilder.AppendFormat("Ext.DomHelper.append(document.forms[0],{{tag:'input',type:'hidden',value:'false',id:'{0}',name:'{0}'}});", PAGE_STATE_CHANGED_ID); //beforeBuilder.AppendFormat("F.util.setHiddenFieldValue('{0}','false');", PAGE_STATE_CHANGED_ID); // 5.预加载图片 //beforeBuilder.AppendFormat("{0}=[];", PRELOAD_IMAGES_ID); //beforeBuilder.AppendFormat("{0}.push('{1}');", PRELOAD_IMAGES_ID, ResourceHelper.GetWebResourceUrl(Page, "FineUI.res.img.default.form.error-tip-corners.gif")); //beforeBuilder.AppendFormat("box_preloadImages({0});", PRELOAD_IMAGES_ID); #endregion #region afterBuilder //StringBuilder afterBuilder = new StringBuilder(); //afterBuilder.Append("\r\n"); // 注册隐藏字段 //string hiddenFieldScript = "var itemNode=Ext.get(item[0]);if(itemNode==null){Ext.DomHelper.append(document.forms[0],{tag:'input',type:'hidden',value:item[1],id:item[0],name:item[0]});}else{itemNode.dom.value=item[1];}"; //afterBuilder.AppendFormat("Ext.each({0},function(item){{{1}}},box);", HIDDEN_FIELDS_ID, hiddenFieldScript); //afterBuilder.Append("box_alertDEBUG();"); //afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}"); //afterBuilder.Append("F.util.triggerReady();"); //// 如果是回发并且允许回发注册onReady脚本 //if (!Page.IsPostBack || (Page.IsPostBack && PageManager.Instance.ExecuteOnReadyWhenPostBack)) //{ // afterBuilder.Append("if(typeof(onReady)==='function'){onReady.call(window);}"); //} //afterBuilder.Append("\r\n"); //#if DEBUG // afterBuilder.Append("window.f_render_end_time = new Date();"); //#endif #endregion // 需要注册script //string contentScript = String.Format("EXTASPNET_READY=function(){{{0}}};", beforeBuilder.ToString() + script + afterBuilder.ToString()); //contentScript += "Ext.onReady(EXTASPNET_READY);";//Ext.EventManager.on(window,'onload',function(){EXTASPNET_READY();});";//if(Ext.isIE){}else{Ext.onReady(EXTASPNET_READY);}"; string contentScript = String.Format("F.load(function(){{{0}}});", beforeBuilder.ToString() + script); //#if DEBUG // contentScript += "var x_end_time=new Date();"; //#endif #region RELEASE模式下去除换行符 if (!GlobalConfig.GetDebugMode()) { contentScript = contentScript.Replace("\r\n", ""); } #endregion string checkScript = "if(!F&&!Ext){if(confirm('ERROR: extjs folder is lost, download it now?')){window.location.href='http://fineui.com/bbs/forum.php?mod=viewthread&tid=3218';}}"; return(checkScript + contentScript); }