view release on metacpan or search on metacpan
doc/html/ProtoExtensions.html view on Meta::CPAN
</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<time_mes>, classname: I<classname_to_set>});</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", ...]) {...}
lib/Alien/GvaScript/ProtoExtensions.pod view on Meta::CPAN
=head2 String extensions
=head3 chomp
Strips any trailing line breaks (\r\n) from a String.
=head2 Element extensions
=head3 flash
only applied to ['SPAN', 'DIV', 'INPUT', 'BUTTON', 'TEXTAREA', 'A'] elements.
used to set a classname to the element for a brief moment of time.
Element.flash(elem, {duration: I<time_mes>, classname: I<classname_to_set>});
=head3 hasAnyClass
if (Element.hasAnyClass(elem, ["class1", "class2", ...]) {...}
if (Element.hasAnyClass(elem, "class1") {...}
lib/Alien/GvaScript/lib/GvaScript.js view on Meta::CPAN
Form.Element.Methods.setValue = Form.Element.Methods.setValue.wrap(
function($p, element, value) {
var oldvalue = $F(element);
var _return = $p(element, value);
element.fire('value:change', {oldvalue: oldvalue, newvalue: value});
return _return;
}
);
Element.addMethods();
// adds the method flash to SPAN, DIV, INPUT, BUTTON elements
// flashes an element by adding a classname for a brief moment of time
// options: {classname: // classname to add (default: flash)
// duration: // duration in ms to keep the classname (default: 100ms)}
var _element_list = ['DIV', 'INPUT',
'BUTTON', 'TEXTAREA', 'A',
'H1', 'H2', 'H3', 'H4', 'H5'];
// for the moment, SPAN not supported on WebKit (see prototype.js bug in
// https://prototype.lighthouseapp.com/projects/8886/tickets/976-elementaddmethodsspan-fails-on-webkit)
if (!Prototype.Browser.WebKit) _element_list.push('SPAN');
Element.addMethods(_element_list, {
flash: function(element, options) {
if (element._IS_FLASHING) return;
element = $(element);
lib/Alien/GvaScript/lib/GvaScript.js view on Meta::CPAN
// <span class="left"/>
// <span class="center">
// <button accesskey="r" class="btn" style="width: auto;" id="btn_1226916357164">
// Rechercher dans Calvin
// </button>
// </span>
// <span class="right"/>
// </span>
// this will be cleaner when all application buttons are transformed into
// GvaScript.CustomButtons.Button instances
if(btnContainer.tagName.search(/^(INPUT|BUTTON)$/i) > -1) btn = btnContainer;
else {
btn = btnContainer.down('.btn');
btn.visible = function() {return btnContainer.visible();}
// support focus function on span.buttonContainer
btnContainer.focus = function() {btn.focus();}
}
if(typeof btn == 'undefined') return;
}, this);
lib/Alien/GvaScript/lib/GvaScript.js view on Meta::CPAN
if (previousBtn === btn) return; // selection already handled
// blur the previously selected button
if (previousBtn) {
previousBtn.removeClassName('btn-focus');
}
this.selectedBtn = btn;
if (btn) {
btn.addClassName('btn-focus');
try {
if(btn.tagName.search(/^(INPUT|BUTTON)$/i) > -1)
btn.focus();
else
btn.down('.btn').focus();
} catch (err) {}
}
},
// returns the next visible button
// null if none exists
nextBtn: function (btn) {
var _idx = this.buttons.indexOf(btn);
lib/Alien/GvaScript/lib/prototype.js view on Meta::CPAN
}
Element.addMethods = function(methods) {
var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag;
if (!methods) {
Object.extend(Form, Form.Methods);
Object.extend(Form.Element, Form.Element.Methods);
Object.extend(Element.Methods.ByTag, {
"FORM": Object.clone(Form.Methods),
"INPUT": Object.clone(Form.Element.Methods),
"SELECT": Object.clone(Form.Element.Methods),
"TEXTAREA": Object.clone(Form.Element.Methods),
"BUTTON": Object.clone(Form.Element.Methods)
});
}
if (arguments.length == 2) {
var tagName = methods;
methods = arguments[1];
}
lib/Alien/GvaScript/lib/prototype.js view on Meta::CPAN
_end: function() {
var element = this.element;
var originalStyles = element.retrieve('prototype_original_styles');
element.store('prototype_original_styles', null);
element.setStyle(originalStyles);
this._prepared = false;
},
_compute: function(property) {
var COMPUTATIONS = Element.Layout.COMPUTATIONS;
if (!(property in COMPUTATIONS)) {
throw "Property not found.";
}
return this._set(property, COMPUTATIONS[property].call(this, this.element));
},
toObject: function() {
var args = $A(arguments);
var keys = (args.length === 0) ? Element.Layout.PROPERTIES :
args.join(' ').split(' ');
var obj = {};
keys.each( function(key) {
if (!Element.Layout.PROPERTIES.include(key)) return;
var value = this.get(key);
lib/Alien/GvaScript/lib/prototype.js view on Meta::CPAN
inspect: function() {
return "#<Element.Layout>";
}
});
Object.extend(Element.Layout, {
PROPERTIES: $w('height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height bord...
COMPOSITE_PROPERTIES: $w('padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height'),
COMPUTATIONS: {
'height': function(element) {
if (!this._preComputing) this._begin();
var bHeight = this.get('border-box-height');
if (bHeight <= 0) {
if (!this._preComputing) this._end();
return 0;
}
var bTop = this.get('border-top'),
lib/Alien/GvaScript/lib/prototype.js view on Meta::CPAN
return getPixelValue(element, 'marginLeft');
},
'margin-right': function(element) {
return getPixelValue(element, 'marginRight');
}
}
});
if ('getBoundingClientRect' in document.documentElement) {
Object.extend(Element.Layout.COMPUTATIONS, {
'right': function(element) {
var parent = hasLayout(element.getOffsetParent());
var rect = element.getBoundingClientRect(),
pRect = parent.getBoundingClientRect();
return (pRect.right - rect.right).round();
},
'bottom': function(element) {
var parent = hasLayout(element.getOffsetParent());
src/customButtons.js view on Meta::CPAN
// <span class="left"/>
// <span class="center">
// <button accesskey="r" class="btn" style="width: auto;" id="btn_1226916357164">
// Rechercher dans Calvin
// </button>
// </span>
// <span class="right"/>
// </span>
// this will be cleaner when all application buttons are transformed into
// GvaScript.CustomButtons.Button instances
if(btnContainer.tagName.search(/^(INPUT|BUTTON)$/i) > -1) btn = btnContainer;
else {
btn = btnContainer.down('.btn');
btn.visible = function() {return btnContainer.visible();}
// support focus function on span.buttonContainer
btnContainer.focus = function() {btn.focus();}
}
if(typeof btn == 'undefined') return;
}, this);
src/customButtons.js view on Meta::CPAN
if (previousBtn === btn) return; // selection already handled
// blur the previously selected button
if (previousBtn) {
previousBtn.removeClassName('btn-focus');
}
this.selectedBtn = btn;
if (btn) {
btn.addClassName('btn-focus');
try {
if(btn.tagName.search(/^(INPUT|BUTTON)$/i) > -1)
btn.focus();
else
btn.down('.btn').focus();
} catch (err) {}
}
},
// returns the next visible button
// null if none exists
nextBtn: function (btn) {
var _idx = this.buttons.indexOf(btn);
src/protoExtensions.js view on Meta::CPAN
Form.Element.Methods.setValue = Form.Element.Methods.setValue.wrap(
function($p, element, value) {
var oldvalue = $F(element);
var _return = $p(element, value);
element.fire('value:change', {oldvalue: oldvalue, newvalue: value});
return _return;
}
);
Element.addMethods();
// adds the method flash to SPAN, DIV, INPUT, BUTTON elements
// flashes an element by adding a classname for a brief moment of time
// options: {classname: // classname to add (default: flash)
// duration: // duration in ms to keep the classname (default: 100ms)}
var _element_list = ['DIV', 'INPUT',
'BUTTON', 'TEXTAREA', 'A',
'H1', 'H2', 'H3', 'H4', 'H5'];
// for the moment, SPAN not supported on WebKit (see prototype.js bug in
// https://prototype.lighthouseapp.com/projects/8886/tickets/976-elementaddmethodsspan-fails-on-webkit)
if (!Prototype.Browser.WebKit) _element_list.push('SPAN');
Element.addMethods(_element_list, {
flash: function(element, options) {
if (element._IS_FLASHING) return;
element = $(element);
test/functional/form/validation.js view on Meta::CPAN
// [$]1###+[.##]
// [$]0.##
// [$].##
return Validation.get('IsEmpty').test(v) || /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
}],
['validate-selection', 'Please make a selection', function(v,elm){
return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
}],
['validate-one-required', 'Please select one of the above options.', function (v,elm) {
var p = elm.parentNode;
var options = p.getElementsByTagName('INPUT');
return $A(options).any(function(elm) {
return $F(elm);
});
}]
]);