[Seaside-dev] Javascript Condition with else decoration
Johan Brichau
johan at inceptive.be
Tue Sep 30 15:14:34 UTC 2014
Esteban,
As a short note, I forgot to reply that I was a tad confused by the naming of the method.
I would prefer to have something like #classicalthen: else: where the pattern stays <condition> <then> <else>, while your suggestion transforms it to <then> <condition> <else>
So, then we are down to choosing a name, which is probably why you ended up with #condition: else:
Johan
On 30 Sep 2014, at 16:48, Johan Brichau <johan at inceptive.be> wrote:
> Hi Esteban,
>
> I picked up your request and was going to look at it but ran out of time.
> The best idea is to create a ticket on https://code.google.com/p/seaside/issues/list
>
> thanks
> Johan
>
> On 30 Sep 2014, at 15:24, Esteban A. Maringolo <emaringolo at gmail.com> wrote:
>
>> No replies to this request in a week.
>> Can I have write access to the repo?
>>
>> Who is the principal maintainer of Seaside?
>>
>> Esteban A. Maringolo
>>
>>
>> 2014-09-22 17:21 GMT-03:00 Esteban A. Maringolo <emaringolo at gmail.com>:
>>> I was trying to implement a classical "if {...} else {...}" object using
>>> JSDecorations.
>>> Then I found there is a JSCondition, but there is no way to describe an
>>> "else" statement.
>>>
>>> Also there is an JSIfThenElse decoration, but it is implemented as a ternary
>>> operator (x ? y : z) instead of 'if(x){ y} else {z}'
>>>
>>> So I added an extension to JSObject, named #condition:else: and also a
>>> JSConditionElse decoration which produces the expected output.
>>>
>>> Can this be added to the main trunk of the Javascript-Core package?
>>>
>>> The changes are attached.
>>>
>>>
>>> With these modifications I was able to transform this Javascript:
>>> $('#ajaxId tbody').on( 'click', 'tr', function () {
>>> if ( $(this).hasClass('selected') ) {
>>> $(this).removeClass('selected');
>>> }
>>> else {
>>> $('#ajaxId tr.selected').removeClass('selected');
>>> $(this).addClass('selected');
>>> }
>>> } );
>>>
>>> Into this:
>>>
>>> | selClass |
>>> selClass := 'selected'.
>>> ^ (html jQuery: '#' , self ajaxId , ' tbody')
>>> on: 'click'
>>> selector: 'tr'
>>> do:
>>> ((html jQuery this removeClass: selClass)
>>> condition: (html jQuery this hasClass: selClass)
>>> else:
>>> (JSScript new
>>> add: ((html jQuery: '#' , self ajaxId , ' tr.' , selClass) removeClass:
>>> selClass);
>>> add: (html jQuery this addClass: selClass);
>>> yourself))
>>>
>>>
>>> Esteban A. Maringolo
>>>
>>> ps: An alternative solution would be to modify the JSIfThenElse, but this
>>> would require adding returns to the trueStatement and falseStatement of this
>>> class.
>> _______________________________________________
>> seaside-dev mailing list
>> seaside-dev at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/mailman/listinfo/seaside-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside-dev/attachments/20140930/4838f1a6/attachment.htm
More information about the seaside-dev
mailing list