public override void WireScriptsAndValidate() { if (string.IsNullOrEmpty(DragHandleDomId)) throw ExceptionHelper.CreateException<JsonInvalidOperationException>("The DragHandleDomId was not specified for : {0}", this.ToString()); if (string.IsNullOrEmpty(DraggableDomId)) throw ExceptionHelper.CreateException<JsonInvalidOperationException>("The DraggableDomId was not specified for : {0}", this.ToString()); JsonFunction createDraggableFunction = new JsonFunction(); createDraggableFunction.JsonId = this.JsonId + "_init"; string modal = this.IsModal ? "true" : "false"; string body = "BoxMgr.CreateDialog('" + this.DraggableDomId + "', {dragHandle: '" + this.DragHandleDomId + "', modal: " + modal + "});";//, this.DraggableDomId, this.DragHandleDomId, this.IsModal ? "true": "false") if (RenderDialogButtons) body += string.Format("BoxMgr.Dialogs['{0}'].RenderDialogButtons();", this.DraggableDomId); if (!string.IsNullOrEmpty(this.OKDomId)) body += string.Format("BoxMgr.Dialogs['{0}'].SetOkId('{1}');", this.DraggableDomId, this.OKDomId); if (!string.IsNullOrEmpty(this.CancelDomId)) body += string.Format("BoxMgr.Dialogs['{0}'].SetCancelId('{1}');", this.DraggableDomId, this.CancelDomId); createDraggableFunction.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; createDraggableFunction.FunctionBody = body; this.AddJsonFunction(createDraggableFunction); }
public JsonTab() : base() { controlToRender.TagName = "span"; this.Styles[HtmlTextWriterStyle.Display] = "inline-block"; if (BrowserAccessHelper.IsIELessThanOrEqualTo(6)) this.Styles[HtmlTextWriterStyle.Width] = "100%"; this.TabHeight = 20; this.VerticalMargin = 3; this.LineWidth = 1; this.LineColor = "#000000"; this.MouseOverLineColor = "#000000"; this.BackgroundColor = "#FFFFFF"; this.MouseOverBackgroundColor = "#FFFFFF"; this.FillColor = "#787878"; this.MouseOverFillColor = "#9A9A9A"; this.TextPadding = 10; this.CornerRadius = 8; this.HorizontalMargin = 3; this.IsFirst = true; this.mouseoverFunction = new JsonFunction(); this.mouseoverFunction.ExecutionType = JavascriptExecutionTypes.Call; this.mouseoutFunction = new JsonFunction(); this.mouseoutFunction.ExecutionType = JavascriptExecutionTypes.Call; this.wireupFunction = new JsonFunction(); this.clickFunction = new JsonFunction(); this.clickFunction.ExecutionType = JavascriptExecutionTypes.Call; }
protected void CreateRegistrationScript() { if (registrationScript == null) { registrationScript = new JsonFunction(string.Format("JsonInput.RegisterAsSource('{0}', '{1}');", this.InputJsonId, this.InputElementTagName)); this.AddJsonFunction(registrationScript); } }
public JsonListInput() : base() { this.initializer = new JsonFunction(); this.initializer.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; this.initialItems = new List <JsonDataItem>(); this.AllowRemove = true; this.AutoRegisterScript = true; }
public JsonListInput() : base() { this.initializer = new JsonFunction(); this.initializer.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; this.initialItems = new List<JsonDataItem>(); this.AllowRemove = true; this.AutoRegisterScript = true; }
public JsonClientParentProxy() : base() { this.ensure = new JsonFunction(); this.ensure.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; this.AddJsonFunction(this.ensure); //this.AddJsonFunction(this); //this.ExecutionType = JavascriptExecutionTypes.Call; }
private void WireEventSources(JsonFunction wireupScript) { for (int i = 0; i < this.eventSourceDomIds.Count; i++) { string sourceId = this.eventSourceDomIds[i]; if (this.eventSourceEventNames.Count > i) { //wireupScript.AddScriptTextLine(string.Format("jQuery('id={0}').bind('{1}', {2});", sourceId, this.eventSourceEventNames[i], this.JsonId)); wireupScript.AppendScriptBody(string.Format("JSUI.AddEventHandler('{0}',{1},'{2}');", sourceId, this.JsonId, this.eventSourceEventNames[i])); } else { //wireupScript.AddScriptTextLine(string.Format("jQuery('id={0}').bind('{1}', {2});", sourceId, this.ClientEventName, this.JsonId)); wireupScript.AppendScriptBody(string.Format("JSUI.AddEventHandler('{0}',{1},'{2}');//monkey", sourceId, this.JsonId, this.ClientEventName)); } } }
public JsonSearcher() : base() { this.inputBox = new JsonTextBox(); this.searchResults = new DataBox(); this.startSearchEvent = new JsonScriptObjectEventSource(); this.MinimumCharacterCount = 3; this.attacher = new JsonFunction(); this.attacher.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; this.AddJsonFunction(this.attacher); this.AutoRegisterScript = true; this.Controls.Add(inputBox); this.Controls.Add(searchResults); this.Controls.Add(startSearchEvent); this.AddRequiredScript(typeof(JsonSearcher));//"naizari.javascript.jsoncontrols.jsonsearcher.js"); }
public override bool Equals(object obj) { if (obj is JsonFunction) { JsonFunction func = (JsonFunction)obj; if (!func.scriptsCreated) { func.CreateScript(); } return(func.ScriptText.Equals(this.ScriptText)); } else { return(base.Equals(obj)); } }
public DataBox() : base() { this.Callback = new BoxCallback(); //this.Callback.PreInvokeFunctions = new JsonFunctionDelegate(); this.Callback.Invoker = this; this.type = JsonInvokerTypes.extension; this.AddJsonFunction(this.Callback); this.ResponseFormat = JsonResponseFormats.box; this.InvokeOnce = true; //default this.ToggleEventName = "click"; this.showWorkingPreInvoke = new JsonFunction(); this.WorkingInline = true; //this.AddRequiredScript("naizari.javascript.boxcontrols.box.js"); }
private void CreateEventScript(JsonFunction targetFunction, JsonTab tabDefinition) { targetFunction.AppendScriptBodyFormat( "JSUI.GetElement('{0}').style.backgroundImage = \"url({1})\";", this.JsonId + "_mid", tabDefinition.GetTabImageUrl("MiddleSection")); targetFunction.AppendScriptBodyFormat( "JSUI.GetElement('{0}').style.backgroundImage = \"url({1})\";", this.JsonId + "_left", tabDefinition.GetTabImageUrl("FirstSide")); targetFunction.AppendScriptBodyFormat( "JSUI.GetElement('{0}').style.backgroundImage = \"url({1})\";", this.JsonId + "_right", tabDefinition.GetTabImageUrl("LastSide")); //this.AddJsonFunction(targetFunction); }
public void WireScriptsAndValidate(bool searchControls) { if (string.IsNullOrEmpty(this.EventSourceDomIds)) { throw new JsonInvalidOperationException("EventSourceDomIds was not specified: " + this.ToString()); } SetClientEventName(); SetParameterSources(); SetCallback(searchControls); controlToRender.Attributes.Add("jsonid", this.JsonId); JavascriptServer.ValidateInvoker(this); // wire scripts - new method? JsonFunction invokeScript = new JsonFunction(GetClientInvokeString()); invokeScript.JsonId = this.JsonId; // THE INVOKESCRIPT JSONID MUST MATCH THE INVOKER invokeScript.ExecutionType = JavascriptExecutionTypes.Call; JsonFunction wireupScript = new JsonFunction(); if (this.parameterSources.Count > 0) { wireupScript.AddScriptTextLine("JSUI.UseParameterSources('" + this.JsonId + "', " + GetParameterIdArray() + ");"); } if (this.type == JsonInvokerTypes.a) { this.AddRequiredJsonTag("a");//this.requiredJsonTags.Add("a"); } RegisterJsonTags(wireupScript); WireEventSources(wireupScript); wireupScript.ExecutionType = JavascriptExecutionTypes.OnParse; wireupScript.JsonId = this.JsonId + "_wireup"; this.AddJsonFunction(invokeScript); this.AddJsonFunction(wireupScript); }
public JsonSearchInput() : base() { this.searcher = new JsonSearcher(); this.Controls.Add(searcher); this.resultSelectedListener = new JsonFunction(); this.resultSelectedListener.ExecutionType = JavascriptExecutionTypes.Call; this.CanEdit = true; this.resultIdClass = "objectid"; //this.resultTypeClass = "objecttype"; this.resultTextClass = "objecttext"; this.blurListener = new JsonFunction(); this.blurListener.ExecutionType = JavascriptExecutionTypes.OnParse; this.AddJsonFunction(this.resultSelectedListener); this.AddJsonFunction(this.blurListener); this.hiddenTextValue = new JsonHiddenInput(); this.AddRequiredScript(typeof(JsonSearcher));//"naizari.javascript.jsoncontrols.jsonsearcher.js"); }
//TODO: change the name of this to AddClientDelegate public void AddDelegate(JsonFunction jsonFunction) { if (!this.functionIds.Contains(jsonFunction.JsonId)) this.functionIds.Add(jsonFunction.JsonId); }
public void RemoveJsonFunction(JsonFunction script) { if (this.scripts.ContainsKey(script.JsonId)) this.scripts.Remove(script.JsonId); }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { controlToRender.TagName = "div"; controlToRender.Attributes.CssStyle.Add("display", "none"); if (!string.IsNullOrEmpty(BoxCssClass)) { controlToRender.Attributes.Add("class", BoxCssClass); } else { controlToRender.Style.Add("width", "450px"); controlToRender.Style.Add("height", "250px"); controlToRender.Style.Add("background-color", "#FFFFFF"); controlToRender.Style.Add("border", "1px solid #000000"); } controlToRender.ID = boxId; HtmlGenericControl title = new HtmlGenericControl("div"); title.ID = titleId; title.InnerHtml = Title; if (!string.IsNullOrEmpty(TitleCssClass)) { title.Attributes.Add("class", TitleCssClass); } else { title.Style.Add("background-color", "#0000FF"); title.Style.Add("border", "1px solid #000000"); title.Style.Add("margin", "1px"); title.Style.Add("padding", "3px"); } controlToRender.Controls.Add(title); HtmlGenericControl messageText = JavascriptPage.CreateDiv(messageId); if (!string.IsNullOrEmpty(this.MessageCssClass)) { messageText.Attributes.Add("class", MessageCssClass); } else { messageText.Style.Add("height", "175px"); } controlToRender.Controls.Add(messageText); JsonFunction registration = new JsonFunction(); registration.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; string body = "\r\nif(MessageBox != 'undefined'){"; body += string.Format("\tMessageBox.RegisterMessageBox('{0}','{1}','{2}');", boxId, titleId, messageId); body += "}"; registration.FunctionBody = body; controlToRender.RenderControl(writer); registration.RenderControl(writer); // <div id="messageDiv" style="display: none; border:1px solid black; background-color: White; width: 400px;" class="modal"> // <div id="messageDrag" style="background-color: #FFCC99; padding: 3px; border:1px solid black; "><b>Patterns Setup Message</b></div> // <div id="messageText"></div><br /><br /> // </div> }
public void WireScriptsAndValidate(bool searchControls) { if (string.IsNullOrEmpty(this.EventSourceDomIds)) throw new JsonInvalidOperationException("EventSourceDomIds was not specified: " + this.ToString()); SetClientEventName(); SetParameterSources(); SetCallback(searchControls); controlToRender.Attributes.Add("jsonid", this.JsonId); JavascriptServer.ValidateInvoker(this); // wire scripts - new method? JsonFunction invokeScript = new JsonFunction(GetClientInvokeString()); invokeScript.JsonId = this.JsonId; // THE INVOKESCRIPT JSONID MUST MATCH THE INVOKER invokeScript.ExecutionType = JavascriptExecutionTypes.Call; JsonFunction wireupScript = new JsonFunction(); if(this.parameterSources.Count > 0) wireupScript.AddScriptTextLine("JSUI.UseParameterSources('" + this.JsonId + "', " + GetParameterIdArray() + ");"); if (this.type == JsonInvokerTypes.a) this.AddRequiredJsonTag("a");//this.requiredJsonTags.Add("a"); RegisterJsonTags(wireupScript); WireEventSources(wireupScript); wireupScript.ExecutionType = JavascriptExecutionTypes.OnParse; wireupScript.JsonId = this.JsonId + "_wireup"; this.AddJsonFunction(invokeScript); this.AddJsonFunction(wireupScript); }
private void RegisterJsonTags(JsonFunction wireupScript) { foreach (string tag in requiredJsonTags) { wireupScript.AddScriptTextLine(string.Format("JSUI.RegisterJsonTag('{0}');", tag)); } }
protected override void OnParameterAdded(JsonFunction function, string parameterName) { }
/// <summary> /// Appends the FunctionBody of the specified script to the FunctionBody /// of the current instance. /// </summary> /// <param name="javascriptFunction">The script to append.</param> public void AppendScriptBody(JsonFunction javascriptFunction) { this.AppendScriptBody(javascriptFunction.FunctionBody); }
protected virtual void OnParameterAdded(JsonFunction function, string parameterName) { if (this.parameters.Count > 1) throw new InvalidCallbackFunctionException(this.JsonId); }
private void UnWireEventSources(JsonFunction function) { foreach (string eventSourceDomId in this.eventSourceDomIds) { //function.AppendScriptBody(string.Format("\r\njQuery('id={0}').unbind('{1}', {2});", eventSourceDomId, this.ClientEventName, this.JsonId)); function.AppendScriptBody(string.Format("\r\nJSUI.RemoveEventHandler('{0}', {1}, '{2}');", eventSourceDomId, this.JsonId, this.ClientEventName)); } }
internal void EnsureInitScript() { string key = this.GetType().Name + "Init.js"; if (Resources.JavaScriptFriendlyNamesToQualifiedScriptPath.ContainsKey(key)) { string longKey = Resources.JavaScriptFriendlyNamesToQualifiedScriptPath[key]; if (!string.IsNullOrEmpty(longKey)) { string scriptText = Resources.JavaScript[longKey]; Type thisType = this.GetType(); foreach (string varName in BoxVariable.GetPropertyVariables(thisType)) { string propertyName = varName.Replace(BoxServer.VariablePrefix, "").Replace(BoxServer.VariableSuffix, ""); PropertyInfo prop = thisType.GetProperty(propertyName); object objValue = prop.GetValue(this, null); string value = objValue == null ? "" : objValue.ToString(); if (prop.PropertyType == typeof(DateTime)) { DateTime dateTime = (DateTime)objValue; value = dateTime.ToShortDateString() + " " + dateTime.ToLongTimeString(); } scriptText = scriptText.Replace(varName, value); } JsonFunction initScript = new JsonFunction(); initScript.Prepend = string.Format("JSUI.{0} = {1}{2};", this.JsonId, "{", "}"); initScript.FunctionBody = scriptText; this.AddJsonFunction(initScript); } } }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { controlToRender.TagName = "div"; controlToRender.Attributes.CssStyle.Add("display", "none"); if (!string.IsNullOrEmpty(BoxCssClass)) controlToRender.Attributes.Add("class", BoxCssClass); else { controlToRender.Style.Add("width", "450px"); controlToRender.Style.Add("height", "250px"); controlToRender.Style.Add("background-color", "#FFFFFF"); controlToRender.Style.Add("border", "1px solid #000000"); } controlToRender.ID = boxId; HtmlGenericControl title = new HtmlGenericControl("div"); title.ID = titleId; title.InnerHtml = Title; if (!string.IsNullOrEmpty(TitleCssClass)) { title.Attributes.Add("class", TitleCssClass); } else { title.Style.Add("background-color", "#0000FF"); title.Style.Add("border", "1px solid #000000"); title.Style.Add("margin", "1px"); title.Style.Add("padding", "3px"); } controlToRender.Controls.Add(title); HtmlGenericControl messageText = JavascriptPage.CreateDiv(messageId); if (!string.IsNullOrEmpty(this.MessageCssClass)) { messageText.Attributes.Add("class", MessageCssClass); } else { messageText.Style.Add("height", "175px"); } controlToRender.Controls.Add(messageText); JsonFunction registration = new JsonFunction(); registration.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; string body = "\r\nif(MessageBox != 'undefined'){"; body += string.Format("\tMessageBox.RegisterMessageBox('{0}','{1}','{2}');", boxId, titleId, messageId); body += "}"; registration.FunctionBody = body; controlToRender.RenderControl(writer); registration.RenderControl(writer); // <div id="messageDiv" style="display: none; border:1px solid black; background-color: White; width: 400px;" class="modal"> // <div id="messageDrag" style="background-color: #FFCC99; padding: 3px; border:1px solid black; "><b>Patterns Setup Message</b></div> // <div id="messageText"></div><br /><br /> // </div> }
public void AddJsonFunction(JsonFunction script) { if(!this.scripts.ContainsKey(script.JsonId)) this.scripts.Add(script.JsonId, script); }
/// <summary> /// /// </summary> /// <param name="writer"></param> protected override void Render(HtmlTextWriter writer) { base.Render(writer); controlToRender.Attributes.Add("id", this.DomId); controlToRender.Attributes.Add("jsonid", this.JsonId); if (PopulateInline) { if (string.IsNullOrEmpty(this.VirtualBoxPath)) throw new JsonInvalidOperationException("The VirtualBoxPath property was not set or the BoxName specified could not be found."); controlToRender.Controls.Add(new LiteralControl(BoxServer.GetHtmlString(this.VirtualBoxPath))); } controlToRender.RenderControl(writer); if (PopulateOnPageLoad) { JsonFunction retrieveBoxContentScript = new JsonFunction(); retrieveBoxContentScript.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; retrieveBoxContentScript.FunctionBody = string.Format("DataBox.GetBoxContent('{0}', '{1}');", this.DomId, this.BoxName); retrieveBoxContentScript.RenderControl(writer); } }
public override void WireScriptsAndValidate() { if (!wired) { if (string.IsNullOrEmpty(InitialImageSource)) ExceptionHelper.ThrowInvalidOperation("The InitialImageSource property was not set: ['{0}']", this.ToString()); JsonFunction wireup = new JsonFunction(); string functionBody = string.Format("window.{0} = new Effects.ImageSequenceClass('{1}', {2});", this.JsonId, this.DomId, this.EnableClick ? "true": "false"); functionBody += string.Format("\r\n{0}.AddImage('{1}', '{2}');", this.JsonId, "initial_" + this.JsonId, this.InitialImageSource); foreach (ImageNameSrcPair imageNameSrcPair in this.images) { functionBody += string.Format("\r\n{0}.AddImage('{1}', '{2}');", this.JsonId, imageNameSrcPair.Name, imageNameSrcPair.Src); } if (!string.IsNullOrEmpty(this.ClientClickFunction)) functionBody += string.Format("\r\nJSUI.AddEventHandler('{0}', {1}, 'click');", this.DomId, this.ClientClickFunction); wireup.FunctionBody = functionBody; //wireup.ExecutionType = JavascriptExecutionTypes.OnWindowLoad; this.AddJsonFunction(wireup); this.WireUp = wireup; wired = true; } }