/* The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Vegas Framework. The Initial Developer of the Original Code is ALCARAZ Marc (aka eKameleon) . Portions created by the Initial Developer are Copyright (C) 2004-2008 the Initial Developer. All Rights Reserved. Contributor(s) : */ /** * This static tool class defined each of the following methods returns a copy of the string wrapped inside an HTML tag. * For example, {@code HTMLStringFormatter.bold("test")} returns {@code test}. * Compatibility with Javascript String HTML wrappers, this methods are native in the Javascript String class. * @author eKameleon */ class vegas.string.HTMLStringFormatter { /** * Creates an HTML anchor that is used as a hypertext target. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.anchor("contents_anchor", "ekameleon link") ; * trace("anchor : " + s) ; // anchor : ekameleon link * } * @param str the string to be formatted. * @param name the name of the anchor. * @return the string formatted with the method. */ public static function anchor( str:String , name:String ):String { return '" + str + "" ; } /** * Use the big method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.big("hello world") ; * trace("big : " + s) ; // big : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function big( str:String ):String { return "" + str + "" ; } /** * Use the blink method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.big("hello world") ; * trace("big : " + s) ; // big : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function blink( str:String ):String { return "" + str + "" ; } /** * Use the bold method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.bold("hello world") ; * trace("bold : " + s) ; // bold : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function bold( str:String ):String { return "" + str + "" ; } /** * Use the fixed method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.fixed("hello world") ; * trace("fixed : " + s) ; // fixed : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function fixed( str:String ):String { return "" + str + "" ; } /** * Use the fontColor method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.fontColor("hello world" , "#FF0000" ) ; * trace("fontColor : " + s) ; // fontColor : hello world * } * @param str the string to be formatted. * @param color the string hexadecimal RGB triplet with the format rrggbb. * @return the string formatted with the method. */ public static function fontColor( str:String , color:String ):String { return "" + str + "" ; } /** * Use the fontSize method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.fontSize("hello world" , "#FF0000" ) ; * trace("fontSize : " + s) ; // fontSize : hello world * } * @param str the string to be formatted. * @param size an Integer representing the size of the font. * @return the string formatted with the method. */ public static function fontSize( str:String , size:Number ):String { return "" + str + "" ; } /** * Use the italics method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.italics("hello world") ; * trace("italics : " + s) ; // italics : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function italics( str:String ):String { return "" + str + "" ; } /** * Creates an HTML hypertext link that requests another URL. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.link("hello world", "http://ekameleon.net/blog", "_blank") ; * trace("link : " + s) ; // link : hello world * } * @param str the string to be formatted. * @param url any string that specifies the HREF of the A tag; it should be a valid URL (relative or absolute). * @param target (optional) this value defined to the anchor tag forces the load of that link into the targeted window. * @return the string formatted with the method. */ public static function link( str:String , url:String , target:String ):String { var s:String = '" ; return s ; } /** * Creates an HTML paragraph HTML string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * * var s:String = HTMLStringFormatter.paragraph("hello world") ; * trace("paragraph : " + s) ; // paragraph :

hello world

* * var s:String = HTMLStringFormatter.paragraph("hello world", "myStyle") ; * trace("paragraph : " + s) ; // paragraph :

hello world

*} * @param str the string to be formatted. * @param style (optional) the style class name of the tag. * @return the string formatted with the method. */ public static function paragraph( str:String, style:String ):String { var s:String = ' 0) { s += ' class=\"' + style + '\"' ; } ; s += '>' ; s += str + '

' ; return s ; } /** * Use the small method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.small("hello world") ; * trace("small : " + s) ; // small : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function small( str:String ):String { return "" + str + "" ; } /** * Creates an HTML span string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * * var sP:String = HTMLStringFormatter.span("hello world") ; * trace("span : " + sP) ; // span : hello world * * var sP:String = HTMLStringFormatter.span("hello world", "myStyle") ; * trace("span : " + sP) ; // span : hello world *} * @param str the string to be formatted. * @param style (optional) the style class name of the tag. * @return the string formatted with the method. */ public static function span( str:String, style:String ):String { var s:String = ' 0) { s += ' class=\"' + style + '\"' ; } ; s += '>' ; s += str + '' ; return s ; } /** * Use the strike method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.strike("hello world") ; * trace("strike : " + s) ; // strike : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function strike( str:String ):String { return "" + str + "" ; } /** * Use the sub method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.sub("hello world") ; * trace("sub : " + s) ; // sub : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function sub( str:String ):String { return "" + str + "" ; } /** * Use the sup method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.sup("hello world") ; * trace("sup : " + s) ; // sup : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function sup( str:String ):String { return "" + str + "" ; } /** * Use the underline method to format and display a string in a document. * {@code * import vegas.string.HTMLStringFormatter ; * var s:String = HTMLStringFormatter.underline("hello world") ; * trace("underline : " + s) ; // underline : hello world * } * @param str the string to be formatted. * @return the string formatted with the method. */ public static function underline( str:String ):String { return "" + str + "" ; } }