Skip to content
Permalink
Browse files

Partial Revert "Adding optional param to remove colon on methods. All…

…ows use inside"

This reverts commit b29e130.
  • Loading branch information...
markstory committed Apr 27, 2009
1 parent e990c5b commit 912f6589d556f391daaa768dcd11ab34682ee0c0
Showing with 12 additions and 38 deletions.
  1. +10 −24 cake/libs/view/helpers/js.php
  2. +2 −14 cake/tests/cases/libs/view/helpers/js.test.php
@@ -254,23 +254,18 @@ function __construct() {
* Create an alert message in Javascript
*
* @param string $message Message you want to alter.
* @param boolean $colon Whether you want a colon or not.
* @access public
* @return string Completed alert() call.
* @return string completed alert()
**/
function alert($message, $colon = true) {
$out = 'alert("' . $this->escape($message) . '")';
if ($colon) {
$out .= ';';
}
return $out;
function alert($message) {
return 'alert("' . $this->escape($message) . '");';
}
/**
* Redirects to a URL
*
* @param mixed $url
* @param array $options
* @return string
* @return string completed redirect in javascript
**/
function redirect($url = null) {
return 'window.location = "' . Router::url($url) . '";';
@@ -279,31 +274,22 @@ function redirect($url = null) {
* Create a confirm() message
*
* @param string $message Message you want confirmed.
* @param boolean $colon Whether you want a colon or not.
* @access public
* @return string Completed confirm() call
* @return string completed confirm()
**/
function confirm($message, $colon = true) {
$out = 'confirm("' . $this->escape($message) . '")';
if ($colon) {
$out .= ';';
}
return $out;
function confirm($message) {
return 'confirm("' . $this->escape($message) . '");';
}
/**
* Create a prompt() Javascript function
*
* @param string $message Message you want to prompt.
* @param string $default Default message
* @access public
* @return string completed prompt() call
* @return string completed prompt()
**/
function prompt($message, $default = '', $colon = true) {
$out = 'prompt("' . $this->escape($message) . '", "' . $this->escape($default) . '")';
if ($colon) {
$out .= ';';
}
return $out;
function prompt($message, $default = '') {
return 'prompt("' . $this->escape($message) . '", "' . $this->escape($default) . '");';
}
/**
* Generates a JavaScript object in JavaScript Object Notation (JSON)
@@ -302,10 +302,6 @@ function testPrompt() {
$expected = 'prompt("Hey, hey you", "hi!");';
$this->assertEqual($result, $expected);
$result = $this->JsEngine->prompt('Hey, hey you', 'hi!', false);
$expected = 'prompt("Hey, hey you", "hi!")';
$this->assertEqual($result, $expected);
$result = $this->JsEngine->prompt('"Hey"', '"hi"');
$expected = 'prompt("\"Hey\"", "\"hi\"");';
$this->assertEqual($result, $expected);
@@ -322,11 +318,7 @@ function testAlert() {
$result = $this->JsEngine->alert('"Hey"');
$expected = 'alert("\"Hey\"");';
$this->assertEqual($result, $expected);
$result = $this->JsEngine->alert('Hey there', false);
$expected = 'alert("Hey there")';
$this->assertEqual($result, $expected);
$this->assertEqual($result, $expected);
}
/**
* test confirm generation
@@ -340,11 +332,7 @@ function testConfirm() {
$result = $this->JsEngine->confirm('"Are you sure?"');
$expected = 'confirm("\"Are you sure?\"");';
$this->assertEqual($result, $expected);
$result = $this->JsEngine->confirm('"Are you sure?"', false);
$expected = 'confirm("\"Are you sure?\"")';
$this->assertEqual($result, $expected);
$this->assertEqual($result, $expected);
}
/**
* test Redirect

0 comments on commit 912f658

Please sign in to comment.
You can’t perform that action at this time.