Mage_Core_Helper_Js Class Reference

Inheritance diagram for Mage_Core_Helper_Js:

Mage_Core_Helper_Abstract Mage_Adminhtml_Helper_Js Mage_Adminhtml_Helper_Media_Js

List of all members.

Public Member Functions

 getTranslateJson ()
 getTranslatorScript ()
 getScript ($script)
 includeScript ($file)
 includeSkinScript ($file)
 getJsUrl ($file)
 getJsSkinUrl ($file)

Protected Member Functions

 _getTranslateData ()

Protected Attributes

 $_translateData = null


Detailed Description

JavaScript helper

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Js.php.


Member Function Documentation

_getTranslateData (  )  [protected]

Retrieve JS translation array

Returns:
array

Definition at line 122 of file Js.php.

00123     {
00124         if ($this->_translateData ===null) {
00125             $this->_translateData = array(
00126                 'Please select an option.' => $this->__('Please select an option.'),
00127                 'This is a required field.' => $this->__('This is a required field.'),
00128                 'Please enter a valid number in this field.' => $this->__('Please enter a valid number in this field.'),
00129                 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.' =>
00130                     $this->__('Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.'),
00131                 'Please use letters only (a-z) in this field.' => $this->__('Please use letters only (a-z) in this field.'),
00132                 'Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.' =>
00133                     $this->__('Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter.'),
00134                 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.' =>
00135                     $this->__('Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.'),
00136                 'Please use only letters (a-z) or numbers (0-9) or spaces and # only in this field.' =>
00137                     $this->__('Please use only letters (a-z) or numbers (0-9) or spaces and # only in this field.'),
00138                 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.' =>
00139                     $this->__('Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.'),
00140                 'Please enter a valid date.' => $this->__('Please enter a valid date.'),
00141                 'Please enter a valid email address. For example johndoe@domain.com.' =>
00142                     $this->__('Please enter a valid email address. For example johndoe@domain.com.'),
00143                 'Please enter 6 or more characters.' => $this->__('Please enter 6 or more characters.'),
00144                 'Please make sure your passwords match.' => $this->__('Please make sure your passwords match.'),
00145                 'Please enter a valid URL. http:// is required' => $this->__('Please enter a valid URL. http:// is required'),
00146                 'Please enter a valid URL. For example http://www.example.com or www.example.com' =>
00147                     $this->__('Please enter a valid URL. For example http://www.example.com or www.example.com'),
00148                 'Please enter a valid social security number. For example 123-45-6789.' =>
00149                     $this->__('Please enter a valid social security number. For example 123-45-6789.'),
00150                 'Please enter a valid zip code. For example 90602 or 90602-1234.' =>
00151                     $this->__('Please enter a valid zip code. For example 90602 or 90602-1234.'),
00152                 'Please enter a valid zip code.' => $this->__('Please enter a valid zip code.'),
00153                 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.' =>
00154                     $this->__('Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.'),
00155                 'Please enter a valid $ amount. For example $100.00.' =>
00156                     $this->__('Please enter a valid $ amount. For example $100.00.'),
00157                 'Please select one of the above options.' => $this->__('Please select one of the above options.'),
00158                 'Please select one of the options.' => $this->__('Please select one of the options.'),
00159                 'Please enter a valid number in this field.' => $this->__('Please enter a valid number in this field.'),
00160                 'Please select State/Province.' => $this->__('Please select State/Province.'),
00161                 'Please enter valid password.' => $this->__('Please enter valid password.'),
00162                 'Please enter 6 or more characters. Leading or trailing spaces will be ignored.' =>
00163                     $this->__('Please enter 6 or more characters. Leading or trailing spaces will be ignored.'),
00164                 'Please use letters only (a-z or A-Z) in this field.' => $this->__('Please use letters only (a-z or A-Z) in this field.'),
00165                 'Please enter a number greater than 0 in this field.' =>
00166                     $this->__('Please enter a number greater than 0 in this field.'),
00167                 'Please enter a valid credit card number.' => $this->__('Please enter a valid credit card number.'),
00168                 'Please wait, loading...' => $this->__('Please wait, loading...'),
00169                 'Please choose to register or to checkout as a guest' => $this->__('Please choose to register or to checkout as a guest'),
00170                 'Error: Passwords do not match' => $this->__('Error: Passwords do not match'),
00171                 'Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.' =>
00172                     $this->__('Your order can not be completed at this time as there is no shipping methods available for it. Please make necessary changes in your shipping address.'),
00173                 'Please specify shipping method.' => $this->__('Please specify shipping method.'),
00174                 'Your order can not be completed at this time as there is no payment methods available for it.' =>
00175                     $this->__('Your order can not be completed at this time as there is no payment methods available for it.'),
00176                 'Please specify payment method.' => $this->__('Please specify payment method.'),
00177     
00178     //Mage_Rule
00179     
00180                 'Your session has been expired, you will be relogged in now.' => $this->__('Your session has been expired, you will be relogged in now.'),
00181                 'Incorrect credit card expiration date' => $this->__('Incorrect credit card expiration date'),
00182             );
00183             foreach ($this->_translateData as $key=>$value) {
00184                 if ($key == $value) {
00185                     unset($this->_translateData[$key]);
00186                 } 
00187             }
00188         }
00189         return $this->_translateData;
00190     }

getJsSkinUrl ( file  ) 

Retrieve skin JS file url

Parameters:
string $file
Returns:
string

Definition at line 112 of file Js.php.

00113     {
00114         return Mage::getDesign()->getSkinUrl($file, array());
00115     }

getJsUrl ( file  ) 

Retrieve JS file url

Parameters:
string $file
Returns:
string

Definition at line 101 of file Js.php.

00102     {
00103         return Mage::getBaseUrl('js').$file;
00104     }

getScript ( script  ) 

Retrieve framed javascript

Parameters:
string $script
Returns:
script

Definition at line 68 of file Js.php.

00069     {
00070         return '<script type="text/javascript">'.$script.'</script>';
00071     }

getTranslateJson (  ) 

Retrieve JSON of JS sentences translation

Returns:
string

Definition at line 46 of file Js.php.

00047     {
00048         return Zend_Json::encode($this->_getTranslateData());
00049     }

getTranslatorScript (  ) 

Retrieve JS translator initialization javascript

Returns:
string

Reimplemented in Mage_Adminhtml_Helper_Media_Js.

Definition at line 56 of file Js.php.

00057     {
00058         $script = 'var Translator = new Translate('.$this->getTranslateJson().');';
00059         return $this->getScript($script);
00060     }

includeScript ( file  ) 

Retrieve javascript include code

Parameters:
string $file
Returns:
string

Definition at line 79 of file Js.php.

00080     {
00081         return '<script type="text/javascript" src="'.$this->getJsUrl($file).'"></script>'."\n";
00082     }

includeSkinScript ( file  ) 

Retrieve

Parameters:
string $file
Returns:
string

Definition at line 90 of file Js.php.

00091     {
00092         return '<script type="text/javascript" src="'.$this->getJsSkinUrl($file).'"></script>';
00093     }


Member Data Documentation

$_translateData = null [protected]

Definition at line 39 of file Js.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:55 2009 for Magento by  doxygen 1.5.8