Alien-GvaScript

 view release on metacpan or  search on metacpan

doc/html/ChoiceList.html  view on Meta::CPAN

    </div>
  </div>
  <div class="TN_node" id="METHODS">
    <h2 class="TN_label">METHODS</h2>
    <div class="TN_content">
        <div class="TN_node" id="destroy">
    <h3 class="TN_label">destroy</h3>
    <div class="TN_content">
      <pre>  choiceList.destroy();</pre>

<p>This method removes all handlers attached to different
events on the choice list container.
Call this method when the choice list container is removed
from the DOM.</p>

    </div>
  </div>
  <div class="TN_node" id="fillContainer">
    <h3 class="TN_label">fillContainer</h3>
    <div class="TN_content">
      <pre>  choiceList.fillContainer(someDiv);</pre>

doc/html/CustomButtons.html  view on Meta::CPAN

</li>
</ul>

    </div>
  </div>
  <div class="TN_node" id="destroy">
    <h4 class="TN_label">destroy</h4>
    <div class="TN_content">
      <pre>  mybutton.destroy()</pre>

<p>This method removes the click handler attached to the button.
Call this method when the button is removed
from the DOM.</p>

    </div>
  </div>

    </div>
  </div>

    </div>

doc/html/CustomButtons.html  view on Meta::CPAN

</li>
</ul>

    </div>
  </div>
  <div class="TN_node" id="destroy">
    <h4 class="TN_label">destroy</h4>
    <div class="TN_content">
      <pre>  mybuttonnavigator.destroy()</pre>

<p>This method removes the different handlers attached on the buttons container.
Call this method when the buttons container is removed
from the DOM.</p>

    </div>
  </div>

    </div>
  </div>

    </div>

doc/html/CustomButtons.html  view on Meta::CPAN

  });</pre>


    </div>
  </div>
  <div class="TN_node" id="destroy">
    <h4 class="TN_label">destroy</h4>
    <div class="TN_content">
      <pre>  myactionsbar.destory();</pre>

<p>This method removes the different handlers attached on the 
buttons and their container.
Call this method when the buttons container is removed
from the DOM.</p>

    </div>
  </div>

    </div>
  </div>

doc/html/Grid.html  view on Meta::CPAN


    </div>
  </div>
  <div class="TN_node" id="destroy">
    <h3 class="TN_label">destroy</h3>
    <div class="TN_content">
      <pre>  my_grid.destroy();</pre>

<p>This method will unregister the Grid in the GvaScript.Grids namespace and 
will iteratively call the destructor on all the grid's depedencies
this removing all handlers attached.
Call this method when the grid is removed
from the DOM.</p>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="EVENTS">
    <h2 class="TN_label">EVENTS</h2>
    <div class="TN_content">
        <div class="TN_node" id="onShow">
    <h3 class="TN_label">onShow</h3>
    <div class="TN_content">
      <p>This event is triggered of the table is rendered and displayed.
Useful for attaching custom events on table records/cells.</p>

    </div>
  </div>
  <div class="TN_node" id="onHighlight">
    <h3 class="TN_label">onHighlight</h3>
    <div class="TN_content">
      <p>This event is triggered when a choice in the list is highlighted.
The event handler may use <code>event.index</code> to know the index of the
highlighted choice.</p>

doc/html/KeyMap.html  view on Meta::CPAN

    <div class="TN_content">
      <p>Alien::GvaScript::KeyMap - Manage maps of handlers for key events</p>

    </div>
  </div>
  <div class="TN_node" id="SYNOPSIS">
    <h2 class="TN_label">SYNOPSIS</h2>
    <div class="TN_content">
      <pre>  var rules = {
  
    // attach handlers to specific keys
    RETURN: function(event){doSomethingWith(event)},  
    C_DOWN: ctrlArrowDownHandler,       
    C_S_F7: ctrlShiftF7Handler,
  
    // special rules using regular expressions
    REGEX: [ ["",   /^[0-9]$/,      digitHandler  ],
             ["C_", /^[aeiou]$/i, ctrlVowelHandler] ], 
  
    // use Ctrl-X as a prefix for another set of rules
    C_X: KeyMap.Prefix({R: ctrlX_R_handler,
                        4: ctrlX_4_handler})
  };
  
  // create a keymap object
  var aKeyMap = new KeyMap(rules);

  // attach the corresponding handler to the keydown event (on document)
  aKeyMap.observe("keydown");
  
  // other way to attach : manually insert handler
  document.onkeydown = aKeyMap.eventHandler({preventDefault: true,
                                             ignoreShift   : true});

  // dynamically change the map
  aKeyMap.rules.push(new_rules);
  
  // idem, temporarily ignore all keys
  aKeyMap.rules.push(KeyMap.MapAllKeys(function(){}));
  
  // back to previous handling state

doc/html/KeyMap.html  view on Meta::CPAN

object (or, if running under Microsoft Internet Explorer, property
<code>cancelBubble</code> is set to true and and property <code>returnValue</code> is set
to false). This default behaviour can be disabled if necessary, 
as explained below.</p>

    </div>
  </div>
  <div class="TN_node" id="ATTACHING_TO_HTML_ELEMENTS">
    <h2 class="TN_label">ATTACHING TO HTML ELEMENTS</h2>
    <div class="TN_content">
      <p>Keymaps may be attached to HTML elements on the 
<code>keydown</code>, <code>keypress</code> or <code>keyup</code> event types.
Choosing the proper event type is important, as it
affects not only the time at which events are fired, 
but also the returned keycodes :</p>
<ul>
<li><a name="item__code_keydown__code__and__code_keyup__code_"></a><b><code>keydown</code> and <code>keyup</code></b>
<p>These are "low-level" event types that capture almost every key on 
the keyboard, including special keys like ESCAPE, F1, PAGE UP, etc.
Returned key codes remain at a raw level, i.e. they are not translated
into characters. This means that if Shift-1 is marked on your keyboard

doc/html/KeyMap.html  view on Meta::CPAN

<p>By contrast, the <code>keypress</code> event type is higher-level in that it 
performs the translation from keys to characters, according to your
specific keyboard. However, this event type only fires for 
printable characters, so you cannot observe <code>keypress</code> if
you intend to capture special keys such as arrow keys, function keys, etc.</p>
</li>
</ul>
<p>In theory, attributes such as <code>onkeydown</code> or <code>onkeypress</code> may be
used with most HTML elements; but in practice, most of them will actually
never fire the key events! So the most common and most sensible way
for capturing key events is to attach to the <code>document</code> element.</p>
<p>Events <code>keypress</code> and <code>keydown</code> will repeat if the
key is held down.</p>
<p>In order to attach the keymap to an element, you can either
use the supplied <a href="#observe">/"observe"</a> method, or call the 
<a href="#eventHandler">/"eventHandler"</a> method to get the keymap event handler, and
then use your favorite technique to attach that handler
to an element.</p>

    </div>
  </div>
  <div class="TN_node" id="METHODS">
    <h2 class="TN_label">METHODS</h2>
    <div class="TN_content">
        <div class="TN_node" id="KeyMap">
    <h3 class="TN_label"><code>KeyMap</code></h3>
    <div class="TN_content">

doc/html/KeyMap.html  view on Meta::CPAN

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="eventHandler">
    <h3 class="TN_label"><code>eventHandler</code></h3>
    <div class="TN_content">
      <pre>  document.onkeydown = aKeyMap.eventHandler(options);</pre>

<p>Generates an event handler that can be attached to an HTML element.
This method is called internally by the <a href="#observe">/"observe"</a> method.
Use <code>eventHandler</code> directly if you need fine control
on how the handler is attached to the dynamic HTML model.</p>
<p>The <code>options</code> argument is optional. If present, it should be an
inline object containing truth values for the following
keys :</p>
<ul>
<li><a name="item__code_ignoreCtrl__code_"></a><b><code>ignoreCtrl</code></b>
<p>ignore the <code>Ctrl</code> keyboard modifier</p>
</li>
<li><a name="item__code_ignoreShift__code_"></a><b><code>ignoreShift</code></b>
<p>ignore the <code>Shift</code> keyboard modifier</p>
</li>

doc/html/KeyMap.html  view on Meta::CPAN

never fire, because Ctrl-Shift-TAB key events would be encoded merely
as <code>"S_TAB"</code>.</p>

    </div>
  </div>
  <div class="TN_node" id="observe">
    <h3 class="TN_label"><code>observe</code></h3>
    <div class="TN_content">
      <pre>  aKeyMap.observe(eventType, htmlElement, options);</pre>

<p>This is the preferred way for attaching the keymap object to an HTML
element, on a given event type (<code>keydown</code>, <code>keypress</code> or <code>keyup</code>).
Arguments are optional. The default event type is <code>"keydown"</code>,
and the default element is <code>document</code>.</p>
<p>Options are passed to the <a href="#eventHandler">/"eventHandler"</a> method.
If not explicitly given, the options default
to <code>undefined</code> except for event type <code>keypress</code>, where
<code>ignoreShift</code> defaults to <code>true</code>. The reason is that the Shift
modifier heavily depends on which keyboard the user is using, and
often the user really has no choice on pressing or not the Shift key
(this would generate a different keycode). So it makes sense to just

doc/html/KeyMap.html  view on Meta::CPAN

  </div>
  <div class="TN_node" id="Prefix">
    <h3 class="TN_label"><code>Prefix</code></h3>
    <div class="TN_content">
      <pre>  main_rules = {C_X: KeyMap.Prefix({R: ctrlX_R_handler,
                                    4: ctrlX_4_handler})};</pre>

<p>Specifies that a key (here <code>Ctrl-X</code>) is a prefix to another
set of rules : the next key event will be passed to these rules,
and after that the main rules resumes normal behaviour.
Hence you can attach handlers to sequences of keys, like for
example in Emacs.</p>

    </div>
  </div>
  <div class="TN_node" id="destroy">
    <h3 class="TN_label"><code>destroy</code></h3>
    <div class="TN_content">
      <pre>  aKeyMap.destroy();</pre>

<p>This method will remove the keymap handler attached the element/document.
Call this method when the concerned element is removed from the DOM
or to deactivate the keymap handler.</p>

    </div>
  </div>

    </div>
  </div>

</div>

doc/html/TreeNavigator.html  view on Meta::CPAN

  <div class="TN_node" id="keymap">
    <h5 class="TN_label">keymap</h5>
    <div class="TN_content">
      <p>A keymap object (see <code>Keymap.js</code>). If that option is given, keyboard
handlers are pushed into that keymap; otherwise a new keymap is
created.</p>
<p>If you supply your own keymap, make
sure that:</p>
<ul>
<li>
<p>the keymap is attached to an element that properly receives keyboard
events. The document element does, but the tree DIV element does not,
unless it contains items with activated focus (with <code>tabIndex</code>
defined and positive).</p>
</li>
<li>
<p>the keymap is created with options <code>preventDefault:false</code> and
<code>stopPropagation:false</code> (because when the tree has no selected node,
the tree navigation handlers do not consume events and try to
propagate them further).</p>
</li>

lib/Alien/GvaScript/ChoiceList.pod  view on Meta::CPAN



=back

=head1 METHODS

=head2 destroy

  choiceList.destroy();

This method removes all handlers attached to different
events on the choice list container.
Call this method when the choice list container is removed
from the DOM.

=head2 fillContainer

  choiceList.fillContainer(someDiv);

This method generates HTML from the choice list, and inserts
it in the C<innerHTML> of the supplied container; furthermore,

lib/Alien/GvaScript/CustomButtons.pod  view on Meta::CPAN


optional - defaulted to 'GVA_SCRIPT_BUTTON'.

=back


=head3 destroy

  mybutton.destroy()

This method removes the click handler attached to the button.
Call this method when the button is removed
from the DOM.




=head1 GvaScript.CustomButtons.ButtonNavigation

For adding support of keyboard navigation over a list of buttons.
Mostly used internally with GvaScript.CustomButtons.ActionsBar class.

lib/Alien/GvaScript/CustomButtons.pod  view on Meta::CPAN


optional - defaulted to 100

=back


=head3 destroy

  mybuttonnavigator.destroy()

This method removes the different handlers attached on the buttons container.
Call this method when the buttons container is removed
from the DOM.



=head1 GvaScript.CustomButtons.ActionsBar 

For rendering a list of Buttons and adding support of keyboard navigation

=head2 Usage

lib/Alien/GvaScript/CustomButtons.pod  view on Meta::CPAN

    className      : 'gva-btn-container'
  });




=head3 destroy

  myactionsbar.destory();

This method removes the different handlers attached on the 
buttons and their container.
Call this method when the buttons container is removed
from the DOM.


=head1 CSS

Example CSS stylesheet for styling buttons.

By default, css classnames are prefixed by 'gva'.

lib/Alien/GvaScript/Grid.pod  view on Meta::CPAN

This method renders the action buttons based on the grids actions. 
NOTE that the actions conditions will be re-evaluated.


=head2 destroy

  my_grid.destroy();

This method will unregister the Grid in the GvaScript.Grids namespace and 
will iteratively call the destructor on all the grid's depedencies
this removing all handlers attached.
Call this method when the grid is removed
from the DOM.


=head1 EVENTS

=head2 onShow

This event is triggered of the table is rendered and displayed.
Useful for attaching custom events on table records/cells.

=head2 onHighlight

This event is triggered when a choice in the list is highlighted.
The event handler may use C<event.index> to know the index of the
highlighted choice.

=head2 onPing

This event is triggered when a choice in the list is "ping-ed", i.e.

lib/Alien/GvaScript/KeyMap.pod  view on Meta::CPAN

=encoding ISO8859-1

=head1 NAME

Alien::GvaScript::KeyMap - Manage maps of handlers for key events 

=head1 SYNOPSIS

  var rules = {
  
    // attach handlers to specific keys
    RETURN: function(event){doSomethingWith(event)},  
    C_DOWN: ctrlArrowDownHandler,       
    C_S_F7: ctrlShiftF7Handler,
  
    // special rules using regular expressions
    REGEX: [ ["",   /^[0-9]$/,      digitHandler  ],
             ["C_", /^[aeiou]$/i, ctrlVowelHandler] ], 
  
    // use Ctrl-X as a prefix for another set of rules
    C_X: KeyMap.Prefix({R: ctrlX_R_handler,
                        4: ctrlX_4_handler})
  };
  
  // create a keymap object
  var aKeyMap = new KeyMap(rules);

  // attach the corresponding handler to the keydown event (on document)
  aKeyMap.observe("keydown");
  
  // other way to attach : manually insert handler
  document.onkeydown = aKeyMap.eventHandler({preventDefault: true,
                                             ignoreShift   : true});

  // dynamically change the map
  aKeyMap.rules.push(new_rules);
  
  // idem, temporarily ignore all keys
  aKeyMap.rules.push(KeyMap.MapAllKeys(function(){}));
  
  // back to previous handling state

lib/Alien/GvaScript/KeyMap.pod  view on Meta::CPAN

Further propagation of the event to other handlers is cancelled by
default : W3C methods C<event.stopPropagation()> and
C<event.preventDefault()> are called automatically by the keymap
object (or, if running under Microsoft Internet Explorer, property
C<cancelBubble> is set to true and and property C<returnValue> is set
to false). This default behaviour can be disabled if necessary, 
as explained below.

=head1 ATTACHING TO HTML ELEMENTS

Keymaps may be attached to HTML elements on the 
C<keydown>, C<keypress> or C<keyup> event types.
Choosing the proper event type is important, as it
affects not only the time at which events are fired, 
but also the returned keycodes :

=over

=item C<keydown> and C<keyup>

These are "low-level" event types that capture almost every key on 

lib/Alien/GvaScript/KeyMap.pod  view on Meta::CPAN

performs the translation from keys to characters, according to your
specific keyboard. However, this event type only fires for 
printable characters, so you cannot observe C<keypress> if
you intend to capture special keys such as arrow keys, function keys, etc.

=back

In theory, attributes such as C<onkeydown> or C<onkeypress> may be
used with most HTML elements; but in practice, most of them will actually
never fire the key events! So the most common and most sensible way
for capturing key events is to attach to the C<document> element.

Events C<keypress> and C<keydown> will repeat if the
key is held down.


In order to attach the keymap to an element, you can either
use the supplied L</"observe"> method, or call the 
L</"eventHandler"> method to get the keymap event handler, and
then use your favorite technique to attach that handler
to an element.



=head1 METHODS

=head2 C<KeyMap>

  var myKeyMap = new KeyMap(rules);

lib/Alien/GvaScript/KeyMap.pod  view on Meta::CPAN

B<not> match. This is useful if you want to 
catch most key events, except 
a given set.



=head2 C<eventHandler>

  document.onkeydown = aKeyMap.eventHandler(options);

Generates an event handler that can be attached to an HTML element.
This method is called internally by the L</"observe"> method.
Use C<eventHandler> directly if you need fine control
on how the handler is attached to the dynamic HTML model.

The C<options> argument is optional. If present, it should be an
inline object containing truth values for the following
keys :

=over

=item C<ignoreCtrl>

ignore the C<Ctrl> keyboard modifier

lib/Alien/GvaScript/KeyMap.pod  view on Meta::CPAN

For example if C<ignoreCtrl> is true, then the key 
specification C<"C_S_TAB"> would
never fire, because Ctrl-Shift-TAB key events would be encoded merely
as C<"S_TAB">.


=head2 C<observe>

  aKeyMap.observe(eventType, htmlElement, options);

This is the preferred way for attaching the keymap object to an HTML
element, on a given event type (C<keydown>, C<keypress> or C<keyup>).
Arguments are optional. The default event type is C<"keydown">,
and the default element is C<document>.

Options are passed to the L</"eventHandler"> method.
If not explicitly given, the options default
to C<undefined> except for event type C<keypress>, where
C<ignoreShift> defaults to C<true>. The reason is that the Shift
modifier heavily depends on which keyboard the user is using, and
often the user really has no choice on pressing or not the Shift key

lib/Alien/GvaScript/KeyMap.pod  view on Meta::CPAN



=head2 C<Prefix>

  main_rules = {C_X: KeyMap.Prefix({R: ctrlX_R_handler,
                                    4: ctrlX_4_handler})};

Specifies that a key (here C<Ctrl-X>) is a prefix to another
set of rules : the next key event will be passed to these rules,
and after that the main rules resumes normal behaviour.
Hence you can attach handlers to sequences of keys, like for
example in Emacs.

=head2 C<destroy>

  aKeyMap.destroy();

This method will remove the keymap handler attached the element/document.
Call this method when the concerned element is removed from the DOM
or to deactivate the keymap handler.

lib/Alien/GvaScript/TreeNavigator.pod  view on Meta::CPAN

handlers are pushed into that keymap; otherwise a new keymap is
created.

If you supply your own keymap, make
sure that:

=over

=item *

the keymap is attached to an element that properly receives keyboard
events. The document element does, but the tree DIV element does not,
unless it contains items with activated focus (with C<tabIndex>
defined and positive).


=item *

the keymap is created with options C<preventDefault:false> and
C<stopPropagation:false> (because when the tree has no selected node,
the tree navigation handlers do not consume events and try to

lib/Alien/GvaScript/lib/GvaScript.js  view on Meta::CPAN

          form.register(query, eventname, handler);
        break;
      }
  },

  /**
    * wrapper around Element.unregister method.
    * method wrapped for special handling of form inputs
    * 'change' and 'init' events
    *
    * remove handler attached to eventname for inputs that match query
    *
    * @param {string} query : css selector to remove handlers from
    * @param {string} eventname : eventname to stop observing
    * @param {Funtion} handler : handler to stop firing oneventname
    *                            NOTE: should be identical to what was used in
    *                            register method.
    *                            {optional} : if not specified, will remove all
    *                            handlers attached to eventname for indicated selector
    * @return undefined
    */
  unregister: function(form, query, eventname, handler) {
    form = $(form);

    switch(eventname) {
      case 'change' :
        form.unregister(query, 'focus', handler);
        form.unregister(query, 'blur',  handler);
      break;

lib/Alien/GvaScript/lib/GvaScript.js  view on Meta::CPAN

                onRepeatBlockAdd    : Prototype.emptyFunction,  // called when a repeatable block gets added

                onChange         : Prototype.emptyFunction,  // called if any input/textarea value change
                onBeforeSubmit   : Prototype.emptyFunction,  // called right after form.submit
                onSubmit         : Prototype.emptyFunction,  // form submit handler
                onBeforeDestroy  : Prototype.emptyFunction   // called right before form.destroy
            }

            this.options = Object.extend(defaults, options || {});

            // attaching submitMethod to form.onsubmit event
            this.formElt.observe('submit', function() {
                // submit method only called if
                // onBeforeSubmit handler doesnot return false
                if ( this.fire('BeforeSubmit') ) return this.fire('Submit');
            }.bind(this));

            // initializing watchers
            $A(this.options.registry).each(function(w) {
                this.register(w[0], w[1], w[2]);
            }, this);

lib/Alien/GvaScript/lib/prototype.js  view on Meta::CPAN

 *--------------------------------------------------------------------------*/

var Prototype = {

  Version: '1.7',

  Browser: (function(){
    var ua = navigator.userAgent;
    var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
    return {
      IE:             !!window.attachEvent && !isOpera,
      Opera:          isOpera,
      WebKit:         ua.indexOf('AppleWebKit/') > -1,
      Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
      MobileSafari:   /Apple.*Mobile/.test(ua)
    }
  })(),

  BrowserFeatures: {
    XPath: !!document.evaluate,

lib/Alien/GvaScript/lib/prototype.js  view on Meta::CPAN

  };

  var docEl = document.documentElement;
  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl
    && 'onmouseleave' in docEl;



  var isIELegacyEvent = function(event) { return false; };

  if (window.attachEvent) {
    if (window.addEventListener) {
      isIELegacyEvent = function(event) {
        return !(event instanceof window.Event);
      };
    } else {
      isIELegacyEvent = function(event) { return true; };
    }
  }

  var _isButton;

lib/Alien/GvaScript/lib/prototype.js  view on Meta::CPAN


  function _isButtonForWebKit(event, code) {
    switch (code) {
      case 0: return event.which == 1 && !event.metaKey;
      case 1: return event.which == 2 || (event.which == 1 && event.metaKey);
      case 2: return event.which == 3;
      default: return false;
    }
  }

  if (window.attachEvent) {
    if (!window.addEventListener) {
      _isButton = _isButtonForLegacyEvents;
    } else {
      _isButton = function(event, code) {
        return isIELegacyEvent(event) ? _isButtonForLegacyEvents(event, code) :
         _isButtonForDOMEvents(event, code);
      }
    }
  } else if (Prototype.Browser.WebKit) {
    _isButton = _isButtonForWebKit;

lib/Alien/GvaScript/lib/prototype.js  view on Meta::CPAN

    pointerY: pointerY,

    stop: stop
  };

  var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
    m[name] = Event.Methods[name].methodize();
    return m;
  });

  if (window.attachEvent) {
    function _relatedTarget(event) {
      var element;
      switch (event.type) {
        case 'mouseover':
        case 'mouseenter':
          element = event.fromElement;
          break;
        case 'mouseout':
        case 'mouseleave':
          element = event.toElement;

lib/Alien/GvaScript/lib/prototype.js  view on Meta::CPAN

  function _destroyCache() {
    for (var i = 0, length = CACHE.length; i < length; i++) {
      Event.stopObserving(CACHE[i]);
      CACHE[i] = null;
    }
  }

  var CACHE = [];

  if (Prototype.Browser.IE)
    window.attachEvent('onunload', _destroyCache);

  if (Prototype.Browser.WebKit)
    window.addEventListener('unload', Prototype.emptyFunction, false);


  var _getDOMEventName = Prototype.K,
      translations = { mouseenter: "mouseover", mouseleave: "mouseout" };

  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) {
    _getDOMEventName = function(eventName) {

lib/Alien/GvaScript/lib/prototype.js  view on Meta::CPAN

    element = $(element);

    var responder = _createResponder(element, eventName, handler);

    if (!responder) return element;

    if (eventName.include(':')) {
      if (element.addEventListener)
        element.addEventListener("dataavailable", responder, false);
      else {
        element.attachEvent("ondataavailable", responder);
        element.attachEvent("onlosecapture", responder);
      }
    } else {
      var actualEventName = _getDOMEventName(eventName);

      if (element.addEventListener)
        element.addEventListener(actualEventName, responder, false);
      else
        element.attachEvent("on" + actualEventName, responder);
    }

    return element;
  }

  function stopObserving(element, eventName, handler) {
    element = $(element);

    var registry = Element.retrieve(element, 'prototype_event_registry');
    if (!registry) return element;

src/form.js  view on Meta::CPAN

          form.register(query, eventname, handler);
        break;
      }
  },

  /**
    * wrapper around Element.unregister method.
    * method wrapped for special handling of form inputs
    * 'change' and 'init' events
    *
    * remove handler attached to eventname for inputs that match query
    *
    * @param {string} query : css selector to remove handlers from
    * @param {string} eventname : eventname to stop observing
    * @param {Funtion} handler : handler to stop firing oneventname
    *                            NOTE: should be identical to what was used in
    *                            register method.
    *                            {optional} : if not specified, will remove all
    *                            handlers attached to eventname for indicated selector
    * @return undefined
    */
  unregister: function(form, query, eventname, handler) {
    form = $(form);

    switch(eventname) {
      case 'change' :
        form.unregister(query, 'focus', handler);
        form.unregister(query, 'blur',  handler);
      break;

src/form.js  view on Meta::CPAN

                onRepeatBlockAdd    : Prototype.emptyFunction,  // called when a repeatable block gets added

                onChange         : Prototype.emptyFunction,  // called if any input/textarea value change
                onBeforeSubmit   : Prototype.emptyFunction,  // called right after form.submit
                onSubmit         : Prototype.emptyFunction,  // form submit handler
                onBeforeDestroy  : Prototype.emptyFunction   // called right before form.destroy
            }

            this.options = Object.extend(defaults, options || {});

            // attaching submitMethod to form.onsubmit event
            this.formElt.observe('submit', function() {
                // submit method only called if
                // onBeforeSubmit handler doesnot return false
                if ( this.fire('BeforeSubmit') ) return this.fire('Submit');
            }.bind(this));

            // initializing watchers
            $A(this.options.registry).each(function(w) {
                this.register(w[0], w[1], w[2]);
            }, this);

test/functional/form/form.gvascript.html  view on Meta::CPAN

  <script src="effects.js"></script>
  <script src="validation.js"></script>

  <script type="text/javascript">
    /**
     * Declaring Form Global Responders
     */
  GvaScript.Form.Responders.register({
    onInit: function(gva_form) {
      gva_form.valid = new Validation(gva_form.formElt, {onSubmit:false});
      log('Form <em>[Late]</em> onInit: validation module attached')
    },

    onChange: function(gva_form, event) {
      log('Form <em>[Late]</em> onChange');
      gva_form.formElt.addClassName('form-edited');
      gva_form.formElt.removeClassName('form-error');
      
      setInfoMessage('form updated ... make sure to save.');
    },



( run in 0.890 second using v1.01-cache-2.11-cpan-524268b4103 )