"modern" javascript...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Thomas 'PointedEars' Lahn

    #16
    Re: "modern&qu ot; javascript...

    dhtml wrote:
    On Jul 17, 10:01 pm, Peter Michaux <petermich...@g mail.comwrote:
    >On Jul 17, 7:38 pm, RobG <rg...@iinet.ne t.auwrote:
    >>On Jul 17, 5:20 pm, dhtml <dhtmlkitc...@g mail.comwrote:
    >>>On Jul 16, 10:00 pm, RobG <rg...@iinet.ne t.auwrote:
    >>>>On Jul 17, 8:34 am, Peter Michaux <petermich...@g mail.comwrote:
    >>>Furthermor e, inline syntax prevents the registration of more than one
    >>>event handler for the element's onchange event,
    >>That's just not true:
    >> <input onchange="func1 (); func2();" ... >
    >I agree with dhtml, that is only one handler; however, Rob's sentiment
    >that these are two handlers can easily been understood. If func1
    >errors then func2 won't run in the code above. The code can be
    >modified with try-catch to make it so func2 would still run. With two
    >genuinely separate handlers this sort of business wouldn't be
    >necessary.
    >
    Event handler attributes are fine for small sites, but don't scale
    well.
    Nonsense. Downloading a script that has to retrieve the reference for every
    object in question, do the feature test, and use the detected method of
    adding an event listener is certainly less efficient than just parsing the
    markup and have the script engine act only when required.

    And you are persistently ignoring the fact that you can only cope with a
    handful of known DOMs this way.
    Often handlers need to be attached dynamically and this is where
    multiple handlers becomes a concern.
    Often? When?
    Other times, handlers need to be removed.
    Again, when?
    In these cases, it is absolutely necessary to access and modify the
    event handler in the javascript.
    No, it is not.
    Now there are two places where event handlers are modified.
    There are no places where event handlers are modified except when compiling
    the UA-native DOM Event API. There are places where event *listeners* are
    added or removed for an event for an object, which causes them to be called
    or not called by the event handler on event.
    It seems best to have just one.
    It seems best to get yourself informed before you attempt parroting nonsense
    at other people who might know better than you and the people you have
    learned this nonsense from.
    [...]
    Using a registry is another approach:
    >
    addCallback(but ton, "onmousedow n", cb);
    >
    The Registry can provide other benefits as well. The Registry can also
    work with event handler attributs, but the result will be HTML that
    looks like: <button onclick="f()" where the button's REAL onclick is
    something like wrappedFn.
    Nothing you said is exactly new here, but most of what you said is simply wrong.
    >All the current options for adding unobtrusive listeners to elements
    >in the page provide a poorer user experience than just using inline
    >handlers.
    >
    That would be true if the user didn't have to wait for all of the top
    scripts to load. Having an attribute event with a top script results
    in a slower UX. The user has to wait for the scripts to d/l and be
    evaluated.
    But adding all/most event listeners on load the document results in *no*
    user experience at all (aside from the HTML default) if the user causes an
    event before the script has added the listener to the target element.
    >That includes the Dean Edwards hack, DOM polling and adding
    >the listener as soon as the element appears, and the bottom script
    >technique. They all can leave elements visible to the user but un-
    >enlived while the page continues loading. Inline handlers don't do
    >that and so are better.
    >
    Event handler attributes work unless a bottom script is used. In that
    case, there will be errors when attempting to call an undefined
    function in the element's event handler attribute.
    There will only be errors if the corresponding event is triggered before the
    function to be called and the functions it is calling were instantiated.
    Using bottom scripts has been shown to significantly decrease page
    load time.
    Using "bottom scripts" is unreliable at best.
    If "unresponsi ve widgets during page load" is a problem, it might be
    an option to hide those widgets by using CSS and unhide them with
    javascript.
    So that nothing works when CSS is present and scripting is not? I don't
    think so.
    If javascript is not enabled, then the user would not be able to use
    those widgets anyway.
    You are confusing cause and effect. What you describe is the effect of a
    wrong design decision: to create widgets that do not work without scripting
    in the first place.
    >The only real alternative is using global event delegation but that
    >doesn't work with non-bubbling events. In the W3C DOM all events do go
    >through the capture phase. If all events in all browsers had event
    >capture then event capture delegation would be a viable technique and
    >a developer could build a complete roll-your-own event system. That
    >would likely be less efficient than using the built in system.
    >
    These things would be easier if IE were to support DOM events.
    True. However the problem of a requirement for a non-native event registry
    and different DOMs would remain.
    >I think I would rather just see the addEventListene r or something take
    >a string argument that is the CSS selector rather than farming the
    >connection between script and html to a separate sheet. Something like
    >>
    ><script type="text/javascript">
    > function validate(e, el) { ... }
    > window.addCssLi stener('.xx_val idateDateField' , validate);
    ></script>
    >>
    >This is how my roll-your-own experiment worked and that part of it I
    >thought was fine. I just didn't like the code that went into the
    >handler function.
    >
    Having the actual object before attaching any callback handler is
    useful because you actually have it. Otherwise, if the string value is
    not resolved to an element ID (or selector), then there is silent
    failure.
    There can be silent failure without that as well.


    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

    Comment

    • Jorge

      #17
      Re: &quot;modern&qu ot; javascript...

      On Jul 19, 10:06 am, dhtml <dhtmlkitc...@g mail.comwrote:
      On Jul 18, 6:13 pm, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
      >
      There's no way to detect "onmouseove r" on the iphone and there
      probably won't be.
      >
      No, there aren't onmouseover events, but we've got the much more
      interesting touch events and gesture events containing TouchEvent and
      GestureEvent objects...
      Hence dragging could be implemented as: the fingertip moves a certain amount
      of length units off the first recognized position.  Dropping: fingertip
      position is no longer recognized while the dragged object is positionedover
      a target that can handle the action.
      >
      In the latest iPhone.
      Not in the latest iPhone, but in the latest version of its software :
      iPhoneOS (v 2.0).
      A lot of users have older iphone.
      Most of them are already upgrading (online and free of charge) to
      version 2.0 right now.

      --Jorge.

      Comment

      • dhtml

        #18
        Re: &quot;modern&qu ot; javascript...

        On Jul 19, 2:37 am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
        wrote:
        dhtml wrote:
        Thomas 'PointedEars' Lahn wrote:
        dhtml wrote:
        >Peter Michaux wrote:
        >>dhtml wrote:
        >
        Please revise your vocabulary.  handleClick(), func1() and func2() are _not_
        event handlers.
        >
        func1 and func1 are callbacks for two different, unrelated objects
        that do not know about each other. Each concerned with a click event
        on the element.

        Using setAttribute/removeAttribute to [un]register callbacks is not
        guaranteed to work and in many browsers, it won't.

        If func2 needs to be removed (during execution of the loaded page),
        then there aren't any reasonably good options.

        >
        Add: using the usual methods.  As I said before, the event handler attribute
        value defines the primary event listener.  There is no good reason why
        secondary, third aso event listeners could not be added to the element, and
        it fact it is possible.
        >
        Remove: using the data stored in an event registry object; its unregister
        method can try reading the `onclick' property.
        >
        So now we're using a Registry.

        One could argue that there are no "pages requiring a lot of 'javascript'"
        had the author designed with graceful degradation and code minimization (I
        mean reducing the code to its essentials, not trimming whitespace) in mind.
        I've worked on two corporate apps had a lot of javascript.


        >
        The handling would be either: 1)  a script error if the event handler
        attribute was used. 2)  no interaction if the event handler wasn't
        attached.
        >
        That is not handling,
        The "result" would be either (1) or (2)




        >
        The tooltip belongs to an element, so it belongs in its start tag or
        content.  What is an "empty panel div"?  What would be its use?
        >
        Usually a tooltip is implemented with one div. Only one tooltip should
        ever be shown at a time.
        <div id="tooltip'></div>

        To have a panel or tooltip HTML in the HTML source can sometimes be
        simpler than creating strings of HTML in the source code, and can also
        allow for custom HTML.

        <div id="user-panel'>
        <h4>User Panel</h4>
        <div id="user-panel-contents'><!-- xhr-driven contents --></div>
        </div>

        These can also be added in the tooltip.js or panel.js, but would then
        require some sort of config param to be passed in to configure the
        panel or tooltip.

        >
        And therefore you are not in a position to lecture others about it.
        >
        This sort of comment isn't useful. It isn't related to the
        discussion.
        >
        And you can see my argument below.  Don't play stupid.
        >
        Again.

        >
        You are wrong, as I have explained.  If fingertip/stylus graffiti works(and
        I have seen the former working IRL), it is entirely possible to implement
        "onmouseove r" there.  
        The "pointing device" hovering "over" an object would no be
        detectable.
        >
        Hence dragging could be implemented as: the fingertip moves a certain
        amount of length units off the first recognized position.  Dropping:
        fingertip position is no longer recognized while the dragged object is
        positioned over a target that can handle the action.
        >
        What you are describing sounds like the touchmove event.

        And there was an update for the older iphone that supports the touch
        events.
        >
        Drag/drom would require at the very least, some sort of adapter function.
        >
        No, it would not.
        Well, because it would require checking touchmove events, not
        mousemove.
        >
        But you have to find it first.
        >
        getElementById does a pretty good job.
        >
        No, it does not.  You have trimmed the essential part of my statement: you
        have to find the *offending* element first.
        >
        Capturing bubbled events and checking the target is another good strategy.
        >
        That is beside the point.

        My point is that there is more than one useful strategies for dealing
        with event handling and considering multiple concerns and constraints,
        such as load time, user experience, and code organization.

        In RIAs I worked on, there have been callbacks [un]registered, as a
        result of other events. The registration happened either:

        1) library code
        2) page implementation code

        The registry was useful to
        * avoid replacing a previously registered callback
        * manage [un]registering during page execution
        * create an abstraction where the callbacks don't know about each
        other
        * add callbacks to document, window, or other objects that aren't HTML
        * provide a common methodology that we all agreed on and understood.
        * add callbacks to elements whose HTML event handler doesn't work
        properly (body)
        It does have some advantages.
        >
        Name one.
        >
        Good abstraction

        Garrett
        PointedEars

        Comment

        • Thomas 'PointedEars' Lahn

          #19
          Re: &quot;modern&qu ot; javascript...

          dhtml wrote:
          Thomas 'PointedEars' Lahn wrote:
          >dhtml wrote:
          >>Thomas 'PointedEars' Lahn wrote:
          >>>dhtml wrote:
          >>>>Peter Michaux wrote:
          >>>>>dhtml wrote:
          >>
          >Please revise your vocabulary. handleClick(), func1() and func2() are
          >_not_ event handlers.
          >
          func1 and func1 are callbacks for two different, unrelated objects
          that do not know about each other.
          There is only one thing that could be considered a callback here: the
          callable object created from the intrinsic event handler attribute value.
          (Have I already recommended you revised your dictionary?)

          And although both calls do not need to operate on the same object (the
          handling event does not need to be the target of their operation), a
          relation between them cannot be denied.
          Each concerned with a click event on the element.
          No doubt about that.
          Using setAttribute/removeAttribute to [un]register callbacks is not
          guaranteed to work and in many browsers, it won't.
          I did not suggest using setAttribute/removeAttribute , *you* did. IOW, it is
          just another straw man argument.
          If func2 needs to be removed (during execution of the loaded page),
          then there aren't any reasonably good options.
          Straw man again. func2() does not need to be removed.
          >Add: using the usual methods. As I said before, the event handler attribute
          >value defines the primary event listener. There is no good reason why
          >secondary, third aso event listeners could not be added to the element, and
          >it fact it is possible.
          >>
          >Remove: using the data stored in an event registry object; its unregister
          >method can try reading the `onclick' property.
          >
          So now we're using a Registry.
          I beg your pardon? I have never denied the necessity of an event registry
          for removing event listeners before.
          >One could argue that there are no "pages requiring a lot of 'javascript'"
          >had the author designed with graceful degradation and code minimization (I
          >mean reducing the code to its essentials, not trimming whitespace) in mind.
          >
          I've worked on two corporate apps had a lot of javascript.
          This does not mean anything.
          >>The handling would be either: 1) a script error if the event handler
          >>attribute was used. 2) no interaction if the event handler wasn't
          >>attached.
          >That is not handling,
          >
          The "result" would be either (1) or (2)
          Yes (there should be no quotes), but that is still not handling anything.
          >The tooltip belongs to an element, so it belongs in its start tag or
          >content. What is an "empty panel div"? What would be its use?
          >
          Usually a tooltip is implemented with one div.
          The usual way is not necessarily the correct one.
          Only one tooltip should ever be shown at a time.
          Non sequitur.
          <div id="tooltip'></div>
          >
          To have a panel or tooltip HTML in the HTML source can sometimes be
          simpler than creating strings of HTML in the source code, and can also
          allow for custom HTML.
          Again, non sequitur. I have never suggested anything else.
          <div id="user-panel'>
          <h4>User Panel</h4>
          <div id="user-panel-contents'><!-- xhr-driven contents --></div>
          </div>
          >
          These can also be added in the tooltip.js or panel.js, but would then
          require some sort of config param to be passed in to configure the
          panel or tooltip.
          Since such content would not degrade gracefully, it should be generated
          entirely dynamically. Empty elements in the markup like this one are nonsense.
          >And therefore you are not in a position to lecture others about it.
          >
          This sort of comment isn't useful. It isn't related to the
          discussion.
          Yes, it is. You have talked cluelessly about accessibility.
          >And you can see my argument below. Don't play stupid.
          >
          Again.
          Stupid is as stupid does. Do not write stupid things if you do not want
          others to comment on them, especially do not ask stupid questions then.
          >You are wrong, as I have explained. If fingertip/stylus graffiti works (and
          >I have seen the former working IRL), it is entirely possible to implement
          >"onmouseover " there.
          >
          The "pointing device" hovering "over" an object would no be
          detectable.
          True.
          >>>But you have to find it first.
          >>getElementByI d does a pretty good job.
          >No, it does not. You have trimmed the essential part of my statement: you
          >have to find the *offending* element first.
          >>
          >>Capturing bubbled events and checking the target is another good strategy.
          >That is beside the point.
          >
          My point is that there is more than one useful strategies for dealing
          with event handling and considering multiple concerns and constraints,
          such as load time, user experience, and code organization.
          True. However, with "Unobtrusiv e JavaScript" load time is greater, user
          experience is less likely to be positive, and code is organized in a sense
          that rips it further apart which makes debugging a lot harder. I do not to
          see why this could be considered a Good Thing.
          >>It does have some advantages.
          >Name one.
          >
          Good abstraction
          Abstraction, granted. But in which way good, exactly?


          PointedEars
          --
          Anyone who slaps a 'this page is best viewed with Browser X' label on
          a Web page appears to be yearning for the bad old days, before the Web,
          when you had very little chance of reading a document written on another
          computer, another word processor, or another network. -- Tim Berners-Lee

          Comment

          • Thomas 'PointedEars' Lahn

            #20
            Re: &quot;modern&qu ot; javascript...

            Thomas 'PointedEars' Lahn wrote:
            dhtml wrote:
            >Thomas 'PointedEars' Lahn wrote:
            >>dhtml wrote:
            >>>Thomas 'PointedEars' Lahn wrote:
            >>>>dhtml wrote:
            >>>>>Peter Michaux wrote:
            >>>>>>dhtml wrote:
            >>Please revise your vocabulary. handleClick(), func1() and func2() are
            >>_not_ event handlers.
            >func1 and func1 are callbacks for two different, unrelated objects
            >that do not know about each other.
            >
            There is only one thing that could be considered a callback here: the
            callable object created from the intrinsic event handler attribute value.
            (Have I already recommended you revised your dictionary?)
            >
            And although both calls do not need to operate on the same object (the
            handling event does not need to be the target of their operation), a
            relation between them cannot be denied.
            Should have been:

            And although both calls do not need to operate on the same object (the
            handling _object_ does not need to be the target of their operation),
            a relation between them cannot be denied.
            >Capturing bubbled events and checking the target is another good strategy.
            That is beside the point.
            My point is that there is more than one useful strategies for dealing
            with event handling and considering multiple concerns and constraints,
            such as load time, user experience, and code organization.
            >
            True. However, with "Unobtrusiv e JavaScript" load time is greater, user
            experience is less likely to be positive, and code is organized in a sense
            that rips it further apart which makes debugging a lot harder. I do not to
            see why this could be considered a Good Thing.
            Should have been:

            True. However, with "Unobtrusiv e JavaScript" load time is greater, user
            experience is less likely to be positive, and code is organized in a sense
            that rips it further apart which makes debugging a lot harder. I do not see
            _how_ this could be considered a Good Thing.


            PointedEars
            --
            Anyone who slaps a 'this page is best viewed with Browser X' label on
            a Web page appears to be yearning for the bad old days, before the Web,
            when you had very little chance of reading a document written on another
            computer, another word processor, or another network. -- Tim Berners-Lee

            Comment

            Working...