Alien-GvaScript

 view release on metacpan or  search on metacpan

GvaScript_Builder.pm  view on Meta::CPAN

    print $dest_fh "\n//----------$sourcefile.js\n", <$fh>;
  }
}

sub generate_html {# regenerate html doc from pod sources
  my ($self) = @_;

  require Pod::POM;
  require Pod::POM::View::HTML;

  my @podfiles = glob ("lib/Alien/GvaScript/*.pod");
  my $parser = new Pod::POM;

  foreach my $podfile (@podfiles) {
    my $pom = $parser->parse($podfile) or die $parser->error;
    $podfile =~ m[^lib/Alien/GvaScript/(.*)\.pod];
    my $htmlfile = "doc/html/$1.html";
    print STDERR "converting $podfile ==> $htmlfile\n";
    open my $fh, ">$htmlfile" or die "open >$htmlfile: $!";
    print $fh Pod::POM::View::HTML::GvaScript->print($pom);
    close $fh;

GvaScript_Builder.pm  view on Meta::CPAN

  my ($self) = @_;

  require Pod::Simple::Wiki;
  require Pod::Simple::Wiki::Googlecode;

  # destination for wiki files
  my $dir = "blib/wiki";
  -d $dir or mkdir $dir or die "mkdir $dir: $!";

  # list of source files
  my @podfiles = glob ("lib/Alien/GvaScript/*.pod");

  # convert each file
  foreach my $podfile (@podfiles) {

    my $parser = Pod::Simple::Wiki->new('googlecode');
    $podfile =~ m[^lib/Alien/GvaScript/(.*)\.pod];
    my $wikifile = "$dir/$1.wiki";
    open my $fh, ">$wikifile" or die "open >$wikifile: $!";
    print STDERR "converting $podfile ==> $wikifile\n";

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

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="CSS">
    <h2 class="TN_label">CSS</h2>
    <div class="TN_content">
      <p>Example CSS stylesheet for styling buttons.</p>
<p>By default, css classnames are prefixed by 'gva'.</p>
<p>This can be overloaded by a global js variable: CSS_PREFIX
if declared before the inclusion of this Library</p>
<p>Notice the <b>btn-focus</b>, <b>btn-hover</b> and <b>flash</b> classnames that are used to style
the buttons in their different states.</p>
<pre>    /* IE fix: to the ridiculously wide buttons in IE */
    .gva-btn-container .btn {width:1pt;overflow:visible;}
    /* END: IE specific */
    
    .gva-actionsbar {background-color:#E8E8E8;border:1px solid #8c8c8c;border-width:1px 0px;height:25px;padding:4px 0 1px;}
    .gva-btn-container {display:inline;}
    .gva-btn-container .btn {margin:0 3px;font-size:12px;cursor:pointer;}

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

  </div>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="GvaScript_Form_Responders">
    <h2 class="TN_label">GvaScript.Form.Responders</h2>
    <div class="TN_content">
      <p>A repository of global listeners notified about every step of the GvaSript.Form lifecycle.</p>
<p>Sometimes, you need to provide generic behaviors over all GvaScript.Form(s) in a single application.</p>
<p>To achieve this, GvaScript.Form provides global Responders that will be executed for every GvaScript.Form instance.</p>
<p>Responders by default are executed <b>after</b> the instance specific event callback.</p>
  <div class="TN_node" id="METHODS">
    <h3 class="TN_label">METHODS</h3>
    <div class="TN_content">
        <div class="TN_node" id="register">
    <h4 class="TN_label">register</h4>
    <div class="TN_content">
      <pre>  GvaScript.Form.Responders.register({eventName: handler}[, {eventName: handler}[, ...]]})</pre>

<p>adding one or more global form events responders.</p>
<p>Supported <b>eventNames</b>: <code>onInit, onChange, onBeforeSubmit, onSubmit, on[XXX]</code> where <code>on[XXX]</code> is a custom event name.</p>

    </div>
  </div>
  <div class="TN_node" id="unregister">
    <h4 class="TN_label">unregister</h4>
    <div class="TN_content">
      <pre>  GvaScript.Form.Responders.unregister({eventName: handler}[, {eventName: handler}[, ...]]})</pre>

<p>unregistering one or more global form events responders.</p>

    </div>
  </div>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="GvaScript_Form_EarlyResponders">

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


<p>Note that the icons are aware if they should be active/inactive. An 'inactive' css classname would be set to differentiate.</p>

    </div>
  </div>
  <div class="TN_node" id="CSS">
    <h4 class="TN_label">CSS</h4>
    <div class="TN_content">
      <p>Easy customization of icons</p>
<p>By default, css classnames are prefixed by 'gva'.</p>
<p>This can be overloaded by a global js variable: CSS_PREFIX
if declared before the inclusion of this Library</p>
<pre>  .gva-paginatorbar {float:right;width:250px;}
  .gva-paginatorbar div {width:16px;height:16px;cursor:pointer;float:right;}
  .gva-paginatorbar div.first {background:url(page-first.gif) no-repeat top center;}
  .gva-paginatorbar div.last {background:url(page-last.gif) no-repeat top center;}
  .gva-paginatorbar div.back {background:url(page-prev.gif) no-repeat top center;}
  .gva-paginatorbar div.forward {background:url(page-next.gif) no-repeat top center;}
  .gva-paginatorbar div.inactive {cursor:default;opacity:0.25;filter:alpha(opacity=25);}
  .gva-paginatorbar div.text {text-align:center;width:140px;color:#4b34c5;font-size:10pt;}
  

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

<p>Checks if <code>cond</code> is true, and if not, generates an error 
with message <code>msg</code>.</p>

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

<p>Returns value of <code>CSS_PREFIX</code> global variable if found. If not,
default to 'gva'.</p>
<p>This value is used to prefix css classnames of html elements that are
derived in some GvaScript classes.</p>

    </div>
  </div>

    </div>
  </div>

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

    <h5 class="TN_label">treeTabIndex</h5>
    <div class="TN_content">
      <p>Which tabIndex will be assigned to the tree element
(if not already specified in markup).
The default is 0; specifying a higher value
would give a higher priority to the tree
navigator within the tabbing order.</p>
<p>Setting <code>tabIndex</code> to a negative value means
that the tree navigator receives no focus.
In that case, the keymap created for
capturing keyboard events will be  bound globally
to the <code>document</code> element (and therefore might
interact in unpredictable ways with other elements
capturing keys; so this is not a recommended setting).</p>

    </div>
  </div>
  <div class="TN_node" id="flashDuration">
    <h5 class="TN_label">flashDuration</h5>
    <div class="TN_content">
      <p>Duration (in milliseconds) of "flashing", i.e. visual feedback when a

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

}

sub install {
    my ($class, $destdir) = @_;
    if (!-d $destdir) {
        mkpath( $destdir ) 
          or die "can't create '$destdir'; $!";
    }

    my $path = $class->path();
    my @files = grep { -f $_ } glob "$path/*";
    foreach my $file (@files) {
        copy( $file, $destdir ) 
          or die "can't copy '$file' to '$destdir'; $!";
    }
}

1;

__END__

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

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'.

This can be overloaded by a global js variable: CSS_PREFIX
if declared before the inclusion of this Library

Notice the B<btn-focus>, B<btn-hover> and B<flash> classnames that are used to style
the buttons in their different states.

    /* IE fix: to the ridiculously wide buttons in IE */
    .gva-btn-container .btn {width:1pt;overflow:visible;}
    /* END: IE specific */
    
    .gva-actionsbar {background-color:#E8E8E8;border:1px solid #8c8c8c;border-width:1px 0px;height:25px;padding:4px 0 1px;}

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

=head2 METHODS 

=head3 get

  GvaScript.Forms.get(id)

finds and returns the GvaScript.Form instance where id is the unique id of the form HTMLElement. 

=head1 GvaScript.Form.Responders

A repository of global listeners notified about every step of the GvaSript.Form lifecycle.

Sometimes, you need to provide generic behaviors over all GvaScript.Form(s) in a single application.

To achieve this, GvaScript.Form provides global Responders that will be executed for every GvaScript.Form instance.

Responders by default are executed B<after> the instance specific event callback.


=head2 METHODS

=head3 register

  GvaScript.Form.Responders.register({eventName: handler}[, {eventName: handler}[, ...]]})

adding one or more global form events responders.

Supported B<eventNames>: C<onInit, onChange, onBeforeSubmit, onSubmit, on[XXX]> where C<on[XXX]> is a custom event name.

=head3 unregister

  GvaScript.Form.Responders.unregister({eventName: handler}[, {eventName: handler}[, ...]]})

unregistering one or more global form events responders.


=head1 GvaScript.Form.EarlyResponders

Identical to GvaScript.Form.Responders except that these responders would be executed B<before> the instance specific callback.

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

  </div>

Note that the icons are aware if they should be active/inactive. An 'inactive' css classname would be set to differentiate.

=head3 CSS

Easy customization of icons

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

This can be overloaded by a global js variable: CSS_PREFIX
if declared before the inclusion of this Library

  .gva-paginatorbar {float:right;width:250px;}
  .gva-paginatorbar div {width:16px;height:16px;cursor:pointer;float:right;}
  .gva-paginatorbar div.first {background:url(page-first.gif) no-repeat top center;}
  .gva-paginatorbar div.last {background:url(page-last.gif) no-repeat top center;}
  .gva-paginatorbar div.back {background:url(page-prev.gif) no-repeat top center;}
  .gva-paginatorbar div.forward {background:url(page-next.gif) no-repeat top center;}
  .gva-paginatorbar div.inactive {cursor:default;opacity:0.25;filter:alpha(opacity=25);}
  .gva-paginatorbar div.text {text-align:center;width:140px;color:#4b34c5;font-size:10pt;}

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


  ASSERT (cond, msg);

Checks if C<cond> is true, and if not, generates an error 
with message C<msg>.

=head2 CSSPREFIX

  CSSPREFIX ();

Returns value of C<CSS_PREFIX> global variable if found. If not,
default to 'gva'.

This value is used to prefix css classnames of html elements that are
derived in some GvaScript classes.

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


Which tabIndex will be assigned to the tree element
(if not already specified in markup).
The default is 0; specifying a higher value
would give a higher priority to the tree
navigator within the tabbing order.

Setting C<tabIndex> to a negative value means
that the tree navigator receives no focus.
In that case, the keymap created for
capturing keyboard events will be  bound globally
to the C<document> element (and therefore might
interact in unpredictable ways with other elements
capturing keys; so this is not a recommended setting). 



=head4 flashDuration

Duration (in milliseconds) of "flashing", i.e. visual feedback when a
key is pressed in a wrong context, like for example trying to open a

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

  stopAll:  {stopPropagation: true, preventDefault: true},
  stopNone: {stopPropagation: false, preventDefault: false}

});

function ASSERT (cond, msg) {
  if (!cond)
    throw new Error("Violated assertion: " + msg);
}

// detects if a global CSS_PREFIX has been set
// if yes, use it to prefix the css classes
// default to gva
function CSSPREFIX () {
    if(typeof CSS_PREFIX != 'undefined') {
        return (CSS_PREFIX)? CSS_PREFIX : 'gva';
    }
    return 'gva';
}

/**

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

    // if `separator` is not a regex, use the native `split`
    if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
        return cbSplit._nativeSplit.call(str, separator, limit);
    }

    var output = [],
        lastLastIndex = 0,
        flags = (separator.ignoreCase ? "i" : "") +
                (separator.multiline  ? "m" : "") +
                (separator.sticky     ? "y" : ""),
        separator = RegExp(separator.source, flags + "g"), // make `global` and avoid `lastIndex` issues by working with a copy
        separator2, match, lastIndex, lastLength;

    str = str + ""; // type conversion
    if (!cbSplit._compliantExecNpcg) {
        separator2 = RegExp("^" + separator.source + "$(?!\\s)", flags); // doesn't need /g or /y, but they don't hurt
    }

    /* behavior for `limit`: if it's...
    - `undefined`: no limit.
    - `NaN` or zero: return an empty array.

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

})();

// based on:
// getJSON function by Juriy Zaytsev
// http://github.com/kangax/protolicious/tree/master/get_json.js
(function(){
  var id = 0, head = $$('head')[0];
  Prototype.getJSON = function(url, callback) {
    var script = document.createElement('script'), token = '__jsonp' + id;

    // callback should be a global function
    window[token] = callback;

    // url should have "?2" parameter which is to be replaced with a global callback name
    script.src = url.replace(/\?(&|$)/, '__jsonp' + id + '$1');

    // clean up on load: remove script tag, null script variable and delete global callback function
    script.onload = function() {
      script.remove();
      script = null;
      delete window[token];
    };
    head.appendChild(script);

    // callback name should be unique
    id++;
  }

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

  },

  to_tree: function(form) {
    form = $(form);

    return Hash.expand(GvaScript.Form.to_hash(form));
  },

  fill_from_tree : (function() {

    var doc = document; // local variable is faster than global 'document'

    // IMPLEMENTATION NOTE : Form.Element.setValue() is quite similar,
    // but our treatment of arrays is different, so we have to reimplement
    var _fill_from_value = function(form, elem, val, is_init) {

      // force val into an array
      if (!(val instanceof Array)) val = [val];


      var old_value = null; // needed for value:change custom event

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

    COMMENT_NODE: 8,
    DOCUMENT_NODE: 9,
    DOCUMENT_TYPE_NODE: 10,
    DOCUMENT_FRAGMENT_NODE: 11,
    NOTATION_NODE: 12
  });
}



(function(global) {
  function shouldUseCache(tagName, attributes) {
    if (tagName === 'select') return false;
    if ('type' in attributes) return false;
    return true;
  }

  var HAS_EXTENDED_CREATE_ELEMENT_SYNTAX = (function(){
    try {
      var el = document.createElement('<input name="x">');
      return el.tagName.toLowerCase() === 'input' && el.name === 'x';
    }
    catch(err) {
      return false;
    }
  })();

  var element = global.Element;

  global.Element = function(tagName, attributes) {
    attributes = attributes || { };
    tagName = tagName.toLowerCase();
    var cache = Element.cache;

    if (HAS_EXTENDED_CREATE_ELEMENT_SYNTAX && attributes.name) {
      tagName = '<' + tagName + ' name="' + attributes.name + '">';
      delete attributes.name;
      return Element.writeAttribute(document.createElement(tagName), attributes);
    }

    if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName));

    var node = shouldUseCache(tagName, attributes) ?
     cache[tagName].cloneNode(false) : document.createElement(tagName);

    return Element.writeAttribute(node, attributes);
  };

  Object.extend(global.Element, element || { });
  if (element) global.Element.prototype = element.prototype;

})(this);

Element.idCounter = 1;
Element.cache = { };

Element._purgeElement = function(element) {
  var uid = element._prototypeUID;
  if (uid) {
    Element.stopObserving(element);

src/form.js  view on Meta::CPAN

  },

  to_tree: function(form) {
    form = $(form);

    return Hash.expand(GvaScript.Form.to_hash(form));
  },

  fill_from_tree : (function() {

    var doc = document; // local variable is faster than global 'document'

    // IMPLEMENTATION NOTE : Form.Element.setValue() is quite similar,
    // but our treatment of arrays is different, so we have to reimplement
    var _fill_from_value = function(form, elem, val, is_init) {

      // force val into an array
      if (!(val instanceof Array)) val = [val];


      var old_value = null; // needed for value:change custom event

src/protoExtensions.js  view on Meta::CPAN

  stopAll:  {stopPropagation: true, preventDefault: true},
  stopNone: {stopPropagation: false, preventDefault: false}

});

function ASSERT (cond, msg) {
  if (!cond)
    throw new Error("Violated assertion: " + msg);
}

// detects if a global CSS_PREFIX has been set
// if yes, use it to prefix the css classes
// default to gva
function CSSPREFIX () {
    if(typeof CSS_PREFIX != 'undefined') {
        return (CSS_PREFIX)? CSS_PREFIX : 'gva';
    }
    return 'gva';
}

/**

src/protoExtensions.js  view on Meta::CPAN

    // if `separator` is not a regex, use the native `split`
    if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
        return cbSplit._nativeSplit.call(str, separator, limit);
    }

    var output = [],
        lastLastIndex = 0,
        flags = (separator.ignoreCase ? "i" : "") +
                (separator.multiline  ? "m" : "") +
                (separator.sticky     ? "y" : ""),
        separator = RegExp(separator.source, flags + "g"), // make `global` and avoid `lastIndex` issues by working with a copy
        separator2, match, lastIndex, lastLength;

    str = str + ""; // type conversion
    if (!cbSplit._compliantExecNpcg) {
        separator2 = RegExp("^" + separator.source + "$(?!\\s)", flags); // doesn't need /g or /y, but they don't hurt
    }

    /* behavior for `limit`: if it's...
    - `undefined`: no limit.
    - `NaN` or zero: return an empty array.

src/protoExtensions.js  view on Meta::CPAN

})();

// based on:
// getJSON function by Juriy Zaytsev
// http://github.com/kangax/protolicious/tree/master/get_json.js
(function(){
  var id = 0, head = $$('head')[0];
  Prototype.getJSON = function(url, callback) {
    var script = document.createElement('script'), token = '__jsonp' + id;

    // callback should be a global function
    window[token] = callback;

    // url should have "?2" parameter which is to be replaced with a global callback name
    script.src = url.replace(/\?(&|$)/, '__jsonp' + id + '$1');

    // clean up on load: remove script tag, null script variable and delete global callback function
    script.onload = function() {
      script.remove();
      script = null;
      delete window[token];
    };
    head.appendChild(script);

    // callback name should be unique
    id++;
  }

test/functional/form/effects.js  view on Meta::CPAN

  },
  PAIRS: {
    'slide':  ['SlideDown','SlideUp'],
    'blind':  ['BlindDown','BlindUp'],
    'appear': ['Appear','Fade']
  },
  toggle: function(element, effect) {
    element = $(element);
    effect = (effect || 'appear').toLowerCase();
    var options = Object.extend({
      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
    }, arguments[2] || { });
    Effect[element.visible() ? 
      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
  }
};

Effect.DefaultOptions.transition = Effect.Transitions.sinoidal;

/* ------------- core effects ------------- */

test/functional/form/effects.js  view on Meta::CPAN


Effect.Queues = {
  instances: $H(),
  get: function(queueName) {
    if (!Object.isString(queueName)) return queueName;
    
    return this.instances.get(queueName) ||
      this.instances.set(queueName, new Effect.ScopedQueue());
  }
};
Effect.Queue = Effect.Queues.get('global');

Effect.Base = Class.create({
  position: null,
  start: function(options) {
    function codeForEvent(options,eventName){
      return (
        (options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
        (options[eventName] ? 'this.options.'+eventName+'(this);' : '')
      );
    }

test/functional/form/effects.js  view on Meta::CPAN

      'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+
      'this.position=pos;'+
      codeForEvent(this.options,'beforeUpdate')+
      (this.update ? 'this.update(pos);':'')+
      codeForEvent(this.options,'afterUpdate')+
      '}}');
    
    this.event('beforeStart');
    if (!this.options.sync)
      Effect.Queues.get(Object.isString(this.options.queue) ? 
        'global' : this.options.queue.scope).add(this);
  },
  loop: function(timePos) {
    if (timePos >= this.startOn) {
      if (timePos >= this.finishOn) {
        this.render(1.0);
        this.cancel();
        this.event('beforeFinish');
        if (this.finish) this.finish(); 
        this.event('afterFinish');
        return;  

test/functional/form/effects.js  view on Meta::CPAN

          frame = (pos * this.totalFrames).round();
      if (frame > this.currentFrame) {
        this.render(pos);
        this.currentFrame = frame;
      }
    }
  },
  cancel: function() {
    if (!this.options.sync)
      Effect.Queues.get(Object.isString(this.options.queue) ? 
        'global' : this.options.queue.scope).remove(this);
    this.state = 'finished';
  },
  event: function(eventName) {
    if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
    if (this.options[eventName]) this.options[eventName](this);
  },
  inspect: function() {
    var data = $H();
    for(property in this)
      if (!Object.isFunction(this[property])) data.set(property, this[property]);



( run in 0.649 second using v1.01-cache-2.11-cpan-49f99fa48dc )