It's to late for the first. But there is next year to.
What you think about this:
/* when the dom's ready */
window.addEvent('domready',function() {
/* implement flipText for Strings */
String.implement({
flipText: function() {
/* define the characters */
var charset =
{a:"\u0250",b:"q",c:"\u0254",d:"p",e:"\u01DD",f:"\u025F",g:"\u0183",h:"\u0265",i:"\u0131",j:"\u027E",k:"\u029E",l:"l",m:"\u026F",n:"u",o:"o",p:"d",q:"b",r:"\u0279",s:"s",t:"\u0287",u:"n",v:"\u028C",w:"\u028D",y:"\u028E",z:"z",
1:"\u21C2",2:"\u1105",3:"\u1110",4:"\u3123",5:"\u078E" /* or u03DB
*/ ,6:"9",7:"\u3125",8:"8",9:"6",
0:"0",".":"\u02D9",",":"'","'":",",'"':",,","ÂÂ
´":",","`":",",";":"\u061B","!":"\u00A1","\u00A1":"!","?":"\u00BF","\u00BF":"?","[":"]","]":"[","(":")",")":"(","{":"}","}":"{","<":">",">":"<",_:"\u203E","\r":"\n"};
var result = '', text = this.toLowerCase(), len =
text.length - 1;
for(var x = len; x >= 0; --x) {
var c = text.charAt(x);
var r = charset[c];
result += r != undefined ? r : c;
}
return result;
}
});
/* implement flipText for Elements */
Element.implement({
flipText: function(recurse) {
/* get all of the children for this */
var elements = [this,this.getChildren()].flatten();
/* make it happen! */
elements.each(function(el) {
var children = el.getChildren();
if(!children.length) {
/* set the text of the element to this
*/
el.set('text',el.get('text').flipText());
} else if(recurse) {
children.flipText();
}
});
}
});
/* usage */
$('button').addEvent('click',function() {
$('flip-me').flipText(true);
});
});
Please look also here : http://davidwalsh.name/flip-text
On 1 Apr., 10:39, Quest <[email protected]> wrote:
> Hey there
>
> I was looking for a script to flip all text on my website for todays
> 1st april and I found this plugin for jQuery.
> I've never been working with jQuery before so I don't know how to
> rewrite this script for Moo.
> Could you take a look at it?
>
> jQuery.fn.fliptext = function(){
>
> var charset
> ={a:"\u0250",b:"q",c:"\u0254",d:"p",e:"\u01DD",f:"\u025F",g:"\u0183",h:"\u0265",i:"\u0131",j:"\u027E",k:"\u029E",l:"l",m:"\u026F",n:"u",o:"o",p:"d",q:"b",r:"\u0279",s:"s",t:"\u0287",u:"n",v:"\u028C",w:"\u028D",y:"\u028E",z:"z",
> 1:"\u21C2",2:"\u1105",3:"\u1110",4:"\u3123",5:"\u078E" /* or u03DB
> */ ,6:"9",7:"\u3125",8:"8",9:"6",
> 0:"0",".":"\u02D9",",":"'","'":",",'"':",,","ÂÂ
> ´":",","`":",",";":"\u061B","!":"\u00A1","\u00A1":"!","?":"\u00BF","\u00BF":"?","[":"]","]":"[","(":")",")":"(","{":"}","}":"{","<":">",">":"<",_:"\u203E","\r":"\n"};
>
> jQuery.expr[':'].nochildren = function(elem){
> return !elem.innerHTML.match(/\<\w/);
> };
>
> function flipStr(str) {
> var result = "";
> for (var x = str.length - 1; x >= 0; --x){
> var c = str.charAt(x);
> var r = charset[c];
> result += r != undefined ? r : c;
> }
>
> return result;
> };
>
> // we check all nodes to see if they have children by looking for <
> in their innerHTML
> // for a more pure DOM approach looking for textNodes only,
> seehttp://pastie.org/435207.txt
> this.find('*').andSelf().filter(':nochildren').each(function(){
> var flipped = flipStr((this.innerText ||
> this.textContent).toLowerCase());
> if (this.innerText) {
> this.innerText = flipped;
> } else {
> this.textContent = flipped;
> }
>
> });
>
> return this;
>
>
>
> };- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--
To unsubscribe, reply using "remove me" as the subject.