Brilliant :) Thanks, looks good. I'll apply it after the weekend when am
back at my dev machine.

cheers,
Ernst

On Sat, Sep 27, 2008 at 9:14 AM, Mike Nichols <[EMAIL PROTECTED]>wrote:

>
>
> Ernst
> I've uploaded the patch at
> http://support.castleproject.org/projects/MR/issues/view/MR-ISSUE-490
>
> mike
> On Sep 26, 5:08 pm, Mike Nichols <[EMAIL PROTECTED]> wrote:
> > Sure...let me clean it up and make sure it is castle code compliant.
> > Can I post it on donjon this weekend or do you need it sooner?
> >
> > On Sep 26, 8:28 am, "Ernst Naezer" <[EMAIL PROTECTED]> wrote:
> >
> > > Yeah that sounds very good, lets apply that. Can you make a patch ?
> >
> > > cheers,
> > > Ernst
> >
> > > On Fri, Sep 26, 2008 at 5:11 PM, Mike Nichols <
> [EMAIL PROTECTED]>wrote:
> >
> > > > Mine is similar but is more relaxed, letting me define any kind of
> > > > selector not just ids. So I write this in my .brailjs:
> > > > page.ReplaceHtml("#myTarget",[EMAIL PROTECTED]:"mypartial"}) or
> > > > page.ReplaceHtml(".myTarget",[EMAIL PROTECTED]:"mypartial"})
> >
> > > > On Sep 26, 2:21 am, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
> > > > > This is something that I did for my private use. It works on my
> machine,
> > > > > etc...
> >
> > > > > On Fri, Sep 26, 2008 at 12:16 PM, Ernst Naezer <
> [EMAIL PROTECTED]
> > > > >wrote:
> >
> > > > > > Hi guys,
> >
> > > > > > did anybody ever get to writing this and some test cases under
> the same
> > > > > > license as the rest of the code so we can add it to the Monorail
> base
> > > > and
> > > > > > fill that empty directory :)
> >
> > > > > > cheers,
> > > > > > Ernst
> >
> > > > > [JQueryGenerator.cs3K ]using System;
> > > > > using System.Collections.Generic;
> > > > > using Castle.MonoRail.Framework.JSGeneration;
> >
> > > > > namespace HibernatingRhinos
> > > > > {
> > > > >         public class JQueryGenerator : AbstractJSGenerator
> > > > >         {
> > > > >                 static IDictionary<string, string> positions = new
> > > > Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase)
> > > > >                 {
> > > > >                         {"before", "before"},
> > > > >             {"after", "after"},
> > > > >                         {"top", "prepend"},
> > > > >                         {"bottom", "append"},
> > > > >                         {"prepend", "prepend"},
> > > > >                         {"append", "append"}
> > > > >                 };
> >
> > > > >                 public JQueryGenerator(IJSCodeGenerator
> codeGenerator)
> > > > >                         : base(codeGenerator)
> > > > >                 {
> > > > >                 }
> >
> > > > >                 public override IJSElementGenerator
> > > > CreateElementGenerator(string root)
> > > > >                 {
> > > > >                         return new JQueryElementGenerator(this,
> root);
> > > > >                 }
> >
> > > > >                 public override void Hide(string[] ids)
> > > > >                 {
> > > > >                         SelectRelevantElements(ids);
> > > > >                         CodeGenerator.Write(".hide();");
> > > > >                 }
> >
> > > > >                 private void SelectRelevantElements(params string[]
> ids)
> > > > >                 {
> > > > >                         if (ids.Length == 0)
> > > > >                                 throw new
> InvalidOperationException("Must
> > > > pass at least one id");
> >
> > > > >                         CodeGenerator.Write("jQuery(");
> > > > >                         foreach (string id in ids)
> > > > >                         {
> > > > >                                 CodeGenerator.Write("#" + id +
> ",");
> > > > >                         }
> > > > >                         CodeGenerator.RemoveTail();
> > > > >                         CodeGenerator.Write(")");
> > > > >                 }
> >
> > > > >                 public override void InsertHtml(string position,
> string
> > > > id, object renderOptions)
> > > > >                 {
> > > > >                         string realPosition;
> > > > >                         if (positions.TryGetValue(position, out
> > > > realPosition) == false)
> > > > >                                 throw new
> > > > InvalidOperationException("Position " + position + " is invalid");
> > > > >                         SelectRelevantElements(id);
> > > > >                         CodeGenerator.Write(".");
> > > > >                         CodeGenerator.Write(realPosition);
> > > > >                         CodeGenerator.Write(");");
> > > > >                 }
> >
> > > > >                 public override void Remove(string[] ids)
> > > > >                 {
> > > > >                         SelectRelevantElements(ids);
> > > > >                         CodeGenerator.Write(".remove();");
> > > > >                 }
> >
> > > > >                 public override void Replace(string id, object
> > > > renderOptions)
> > > > >                 {
> > > > >                         SelectRelevantElements(id);
> > > > >                         CodeGenerator.Write(".replaceWith(");
> >
> > > > CodeGenerator.Write(Render(renderOptions).ToString());
> > > > >                         CodeGenerator.Write(");");
> >
> > > > >                 }
> >
> > > > >                 public override void ReplaceHtml(string id, object
> > > > renderOptions)
> > > > >                 {
> > > > >                         SelectRelevantElements(id);
> > > > >                         CodeGenerator.Write(".empty();");
> > > > >                         SelectRelevantElements(id);
> > > > >                         CodeGenerator.Write(".append(");
> >
> > > > CodeGenerator.Write(Render(renderOptions).ToString());
> > > > >                         CodeGenerator.Write(");");
> > > > >                 }
> >
> > > > >                 public override void Show(string[] ids)
> > > > >                 {
> > > > >                         SelectRelevantElements(ids);
> > > > >                         CodeGenerator.Write(".show();");
> > > > >                 }
> >
> > > > >                 public override void Toggle(string[] ids)
> > > > >                 {
> > > > >                         SelectRelevantElements(ids);
> > > > >                         CodeGenerator.Write(".toggle();");
> > > > >                 }
> > > > >         }
> >
> > > > > }
> >
> > > > > [JQueryElementGenerator.cs< 1K ]using
> > > > Castle.MonoRail.Framework.JSGeneration;
> >
> > > > > namespace HibernatingRhinos
> > > > > {
> > > > >         public class JQueryElementGenerator : IJSElementGenerator
> > > > >         {
> > > > >                 private readonly JQueryGenerator parent;
> > > > >                 private readonly string root;
> >
> > > > >                 public JQueryElementGenerator(JQueryGenerator
> parent,
> > > > string root)
> > > > >                 {
> > > > >                         this.parent = parent;
> > > > >                         this.root = root;
> > > > >                 }
> >
> > > > >                 public void ReplaceHtml(object renderOptions)
> > > > >                 {
> > > > >                         parent.ReplaceHtml(root, renderOptions);
> > > > >                 }
> >
> > > > >                 public void Replace(object renderOptions)
> > > > >                 {
> > > > >                         parent.Replace(root, renderOptions);
> > > > >                 }
> >
> > > > >                 public IJSGenerator ParentGenerator
> > > > >                 {
> > > > >                         get { return parent; }
> > > > >                 }
> > > > >         }
> >
> > > > > }
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to