/// <summary> /// 使 jQuery 中包含的页面元素转变为某种插件. /// </summary> /// <param name="setting">插件相关设置, 为 ButtonSetting, DatepickerSetting 等.</param> /// <returns>更新后的 JQueryUI.</returns> public JQueryUI Widget(WidgetSetting setting) { // If this is the plusin, do not execute this method if (null == setting || setting.WidgetType == WidgetType.custom) { return(this); } setting.Recombine( ); // Append WIDGET script this.Execute(setting.WidgetType.ToString( ), MakeOptionExpression(setting.SettingHelper.CreateOptions( ))); // Append event, such as: click( ... ) foreach (Event @event in setting.SettingHelper.Events) { if (@event.Type != EventType.none && @event.Type != EventType.__init) { this.Execute(@event.Type.ToString( ), @event.Value); } } // Append ajax calls foreach (AjaxSetting ajax in setting.Ajaxs) { this.Ajax(ajax); } return(this); }
/// <summary> /// 使页面上指定选择器的元素成为插件. /// </summary> /// <param name="selector">用于指定页面上元素的选择器.</param> /// <param name="setting">插件设置, 比如: ButtonSetting, DatepickerSetting 等.</param> /// <param name="variableName">如果不为空, 则生成同名的 javascript 脚本变量.</param> public void Widget(string selector, WidgetSetting setting, string variableName = null) { if (string.IsNullOrEmpty(selector)) { throw new ArgumentNullException("selector", "选择器不能为空"); } if (null == setting) { throw new ArgumentNullException("setting", "Widget 设置不能为空"); } this.code += "$(function(){" + (string.IsNullOrEmpty(variableName) ? string.Empty : ("window['" + variableName + "'] = ")) + new JQueryUI(selector).Widget(setting).Code + "});"; }
/// <summary> /// 使页面上指定选择器的元素成为插件. /// </summary> /// <param name="selector">用于指定页面上元素的选择器.</param> /// <param name="setting">插件设置, 比如: ButtonSetting, DatepickerSetting 等.</param> /// <param name="variableName">如果不为空, 则生成同名的 javascript 脚本变量.</param> public void Widget ( string selector, WidgetSetting setting, string variableName = null ) { if ( string.IsNullOrEmpty ( selector ) ) throw new ArgumentNullException ( "selector", "选择器不能为空" ); if ( null == setting ) throw new ArgumentNullException ( "setting", "Widget 设置不能为空" ); this.code += "$(function(){" + ( string.IsNullOrEmpty ( variableName ) ? string.Empty : ( "window['" + variableName + "'] = " ) ) + new JQueryUI ( selector ).Widget ( setting ).Code + "});"; }
/// <summary> /// 使 jQuery 中包含的页面元素转变为某种插件. /// </summary> /// <param name="setting">插件相关设置, 为 ButtonSetting, DatepickerSetting 等.</param> /// <returns>更新后的 JQueryUI.</returns> public JQueryUI Widget ( WidgetSetting setting ) { // If this is the plusin, do not execute this method if ( null == setting || setting.WidgetType == WidgetType.custom ) return this; setting.Recombine ( ); // Append WIDGET script this.Execute ( setting.WidgetType.ToString ( ), MakeOptionExpression ( setting.SettingHelper.CreateOptions ( ) ) ); // Append event, such as: click( ... ) foreach ( Event @event in setting.SettingHelper.Events ) if ( @event.Type != EventType.none && @event.Type != EventType.__init ) this.Execute ( @event.Type.ToString ( ), @event.Value ); // Append ajax calls foreach ( AjaxSetting ajax in setting.Ajaxs ) this.Ajax ( ajax ); return this; }