Alien-GvaScript

 view release on metacpan or  search on metacpan

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

    </div>
  </div>
  <div class="TN_node" id="Prototype_getJSON">
    <h3 class="TN_label">Prototype.getJSON</h3>
    <div class="TN_content">
      <pre>  Prototype.getJSON(url, callback)</pre>

<p>based on: getJSON function by Juriy Zaytsev <a href="http://github.com/kangax/protolicious/tree/master/get_json.js">http://github.com/kangax/protolicious/tree/master/get_json.js</a></p>
<p>A method to temporarily load JSON data (ideally hosted on a different domain and accessible via JSONP service) and send it over to callback method when ready.</p>

    </div>
  </div>
  <div class="TN_node" id="Hash_utilities">
    <h3 class="TN_label">Hash utilities</h3>
    <div class="TN_content">
        <div class="TN_node" id="Hash_expand">
    <h4 class="TN_label">Hash.expand</h4>
    <div class="TN_content">
      <pre>  var tree = Hash.expand(flat_hash);</pre>

<p>Transforms a flat structure of key-value pairs into a nested tree
structure, by splitting keys on dots.
The idea and algorithm come from <i>CGI::Expand/expand_hash</i>.</p>
<pre>  Hash.expand({a: '...', b.0.x: '...', b.0.y: '...', b.1.x: '...', b.1.y: '...'}) =&gt;
  {a: '...', b: [{x: '...', y: '...'}, {x: '...', y: '...'}]}</pre>


    </div>
  </div>
  <div class="TN_node" id="Hash_flatten">
    <h4 class="TN_label">Hash.flatten</h4>
    <div class="TN_content">
      <p>The exact opposite of Hash.expand</p>
<p>Transforms a nested tree structure into a flat hash of key-value pairs
where nested keys are joined by a dot.</p>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="String_extensions">
    <h3 class="TN_label">String extensions</h3>
    <div class="TN_content">
        <div class="TN_node" id="chomp">
    <h4 class="TN_label">chomp</h4>
    <div class="TN_content">
      <p>Strips any trailing line breaks (\r\n) from a String.</p>

    </div>
  </div>

    </div>
  </div>
  <div class="TN_node" id="Element_extensions">
    <h3 class="TN_label">Element extensions</h3>
    <div class="TN_content">
        <div class="TN_node" id="flash">
    <h4 class="TN_label">flash</h4>
    <div class="TN_content">
      <p>only applied to ['SPAN', 'DIV', 'INPUT', 'BUTTON', 'TEXTAREA', 'A'] elements.</p>
<p>used to set a classname to the element for a brief moment of time.</p>
<pre>  Element.flash(elem, {duration: I&lt;time_mes&gt;, classname: I&lt;classname_to_set&gt;});</pre>


    </div>
  </div>
  <div class="TN_node" id="hasAnyClass">
    <h4 class="TN_label">hasAnyClass</h4>
    <div class="TN_content">
      <pre>  if (Element.hasAnyClass(elem, ["class1", "class2", ...]) {...}  

  if (Element.hasAnyClass(elem, "class1") {...}</pre>

<p>Returns true if the supplied element has any of the given classes. 
For convenience, also accepts a single string instead of an array
when testing for a single class.</p>

    </div>
  </div>
  <div class="TN_node" id="getElementsByClassNames">
    <h4 class="TN_label">getElementsByClassNames</h4>
    <div class="TN_content">
      <pre>  var subElements 
     = Element.getElementsByClassNames(rootElement, ["class1", "class2", ...]);</pre>

<p>Returns an array of children of <code>rootElement</code> that have any
of the given class names.</p>

    </div>
  </div>
  <div class="TN_node" id="navigateDom">
    <h4 class="TN_label">navigateDom</h4>
    <div class="TN_content">
      <pre>  var wantedClasses = ["class1", "class2", ...];
  
  // which direction to navigate (could be "parentNode", etc.)
  var direction     = "nextSibling"; 

  // some criteria for stopping navigation (can be anything, here a stupid
  // example)
  var stopCondition = function(elem) {return elem.innerHTML.length &gt; 10}

  var nextElement
    = Element.navigateDom(startElement, direction, wantedClasses,
                          stopCondition);</pre>

<p>Returns an extended (prototype's <code>Element.extend()</code>) copy of HTMLElement.</p>
<p>Walks through the DOM in the given direction, until finding an
element that has one of the given classnames, or finding a stop
condition (in which case <code>null</code> is returned).</p>

    </div>
  </div>
  <div class="TN_node" id="autoScroll">
    <h4 class="TN_label">autoScroll</h4>
    <div class="TN_content">
      <pre>  Element.autoScroll(elem, percentage)</pre>

<p>Makes sure that <code>elem</code> is visible in the central area of 
its offset parent; if not, the parent is scrolled.



( run in 0.739 second using v1.01-cache-2.11-cpan-0bd6704ced7 )