Ejemplo n.º 1
0
        /// <summary>
        /// 使页面上指定选择器的元素成为自定义插件.
        /// </summary>
        /// <param name="selector">用于指定页面上元素的选择器.</param>
        /// <param name="setting">自定义插件设置, 比如: TimerSetting, RepeaterSetting 等.</param>
        /// <param name="variableName">如果不为空, 则生成同名的 javascript 脚本变量.</param>
        public void Plusin(string selector, PlusinSetting setting, string variableName = null)
        {
            if (string.IsNullOrEmpty(selector))
            {
                throw new ArgumentNullException("selector", "选择器不能为空");
            }

            if (null == setting)
            {
                throw new ArgumentNullException("setting", "Plusin 设置不能为空");
            }

            string key = string.Format("__js{0}", setting.PlusinType);

            if (!ScriptHelper.IsBuilt(new RazorScriptHolder(this.page), key))
            {
                ScriptHelper script = new ScriptHelper( );

                //foreach
                //script.AppendCode ( setting.GetDependentScripts ( ) );

                script.Build(new RazorScriptHolder(this.page), key, ScriptBuildOption.Startup);
            }

            this.code += "$(function(){" + (string.IsNullOrEmpty(variableName) ? string.Empty : ("window['" + variableName + "'] = ")) + new JQueryUI(selector).Plusin(setting).Code + "});";
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 使 jQuery 中包含的页面元素转变为 je 中的自定义插件.
        /// </summary>
        /// <param name="setting">自定义插件相关设置, 为 TimerSetting, RepeaterSetting 等.</param>
        /// <returns>更新后的 JQueryUI.</returns>
        public JQueryUI Plusin(PlusinSetting setting)
        {
            // 这个方法引用了命名空间 plusin 里面的类, 可以新建一个 JQueryUIPlusin 类, 再将 Plusin 放到 JQueryUIPlusin 中.

            if (null == setting || setting.PlusinType == PlusinType.custom)
            {
                return(this);
            }

            setting.Recombine( );

            return(this.Execute("__" + setting.PlusinType.ToString( ), MakeOptionExpression(setting.SettingHelper.CreateOptions( ))) as JQueryUI);
        }