PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TJavaScript

TJavaScript class.

TJavaScript is a utility class containing commonly-used javascript-related functions.

Package: System\Web\Javascripts
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Wei Zhuo<weizhuo[at]gmail[dot]com>
Since: 3.0
Located at Web/Javascripts/TJavaScript.php
Methods summary
public static string
# renderScriptFiles( array $files )

Renders a list of javascript files

Renders a list of javascript files

Parameters

$files
array
URLs to the javascript files

Returns

string
rendering result
public static string
# renderScriptFile( string $file )

Renders a javascript file

Renders a javascript file

Parameters

$file
string
URL to the javascript file

Returns

string
rendering result
public static string
# renderScriptBlocks( array $scripts )

Renders a list of javascript blocks

Renders a list of javascript blocks

Parameters

$scripts
array
javascript blocks

Returns

string
rendering result
public static string
# renderScriptBlock( string $script )

Renders javascript block

Renders javascript block

Parameters

$script
string
javascript block

Returns

string
rendering result
public static string
# quoteString( string $js )

Quotes a javascript string. After processing, the string is safely enclosed within a pair of quotation marks and can serve as a javascript string.

Quotes a javascript string. After processing, the string is safely enclosed within a pair of quotation marks and can serve as a javascript string.

Parameters

$js
string
string to be quoted

Returns

string
the quoted string
public static Marks
# quoteJsLiteral( mixed $js )

Returns

Marks
a string as a javascript function. Once marke, the string is considered as a raw javascript function that is not supposed to be encoded by TJavaScript::encode()
public static
# quoteFunction( mixed $js )

Deprecated, use TJavaScript::quoteJsLiteral() instead

Deprecated, use TJavaScript::quoteJsLiteral() instead

public static boolean
# isJsLiteral( mixed $js )

Returns

boolean
true if the parameter is marked as a javascript function, i.e. if it's considered as a raw javascript function that is not supposed to be encoded by TJavaScript::encode()
public static
# isFunction( mixed $js )

Deprecated, use TJavaScript::isJsLiteral() instead

Deprecated, use TJavaScript::isJsLiteral() instead

public static string
# encode( mixed $value, boolean $toMap = true, boolean $encodeEmptyStrings = false )

Encodes a PHP variable into javascript representation.

Encodes a PHP variable into javascript representation.

Example:

$options['onLoading'] = "doit";
$options['onComplete'] = "more";
echo TJavaScript::encode($options);
//expects the following javascript code
// {'onLoading':'doit','onComplete':'more'}

For higher complexity data structures use TJavaScript::jsonEncode() and TJavaScript::jsonDecode() to serialize and unserialize.

Parameters

$value
mixed
PHP variable to be encoded
$toMap
boolean
whether the output is a map or a list.
$encodeEmptyStrings
boolean
wether to encode empty strings too. Default to false for BC.

Returns

string
the encoded string

Since

3.1.5
public static string
# jsonEncode( mixed $value, mixed $options = 0 )

Encodes a PHP variable into javascript string. This method invokes json_encode to perform the encoding.

Encodes a PHP variable into javascript string. This method invokes json_encode to perform the encoding.

Parameters

$value
mixed
variable to be encoded
$options

Returns

string
encoded string
public static mixed
# jsonDecode( string $value, boolean $assoc = false, integer $depth = 512 )

Decodes a javascript string into PHP variable. This method invokes json_decode to perform the decoding.

Decodes a javascript string into PHP variable. This method invokes json_decode to perform the decoding.

Parameters

$value
string
string to be decoded
$assoc
boolean
whether to convert returned objects to associative arrays
$depth
integer
recursion depth

Returns

mixed
decoded variable
public static minimized
# JSMin( string $code )

Minimize the size of a javascript script. This method is based on Douglas Crockford's JSMin.

Minimize the size of a javascript script. This method is based on Douglas Crockford's JSMin.

Parameters

$code
string
code that you want to minimzie

Returns

minimized
version of the code
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO