first commit
This commit is contained in:
83
application/helpers/javascript.php
Normal file
83
application/helpers/javascript.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php defined('SYSPATH') or die('No direct script access.');
|
||||
|
||||
class javascript_Core {
|
||||
|
||||
public static function open()
|
||||
{
|
||||
return '<script type="text/javascript">';
|
||||
}
|
||||
|
||||
public static function close()
|
||||
{
|
||||
return "</script>\n";
|
||||
}
|
||||
|
||||
public static function tag($script)
|
||||
{
|
||||
$js = '<script type="text/javascript">';
|
||||
$js .= "\n// <![CDATA[\n";
|
||||
$js .= $script;
|
||||
$js .= "\n// ]]>\n";
|
||||
$js .= "</script>\n";
|
||||
return $js;
|
||||
}
|
||||
public static function script($src)
|
||||
{
|
||||
$js = '<script type="text/javascript" src="';
|
||||
$js .= $src;
|
||||
$js .= '"></script>'."\n";
|
||||
return $js;
|
||||
}
|
||||
|
||||
public static function alert($message)
|
||||
{
|
||||
return "alert('$message');";
|
||||
}
|
||||
|
||||
public static function button_anchor_old($link, $name)
|
||||
{
|
||||
$link = url::site($link);
|
||||
return "<button type=\"button\" onclick=\"location.href='$link'\">$name</button>";
|
||||
}
|
||||
|
||||
public static function button_anchor_referer($link, $name)
|
||||
{
|
||||
$link = url::site($link);
|
||||
return "<button type=\"button\" onclick=\"location.href='$link?referer=' + escape( location.href )\">$name</button>";
|
||||
}
|
||||
|
||||
public static function button_anchor($link, $name)
|
||||
{
|
||||
$link = url::site($link);
|
||||
$js = "
|
||||
<script type=\"text/javascript\">
|
||||
function navigateWithReferrer(url)
|
||||
{
|
||||
var fakeLink = document.createElement('a');
|
||||
if (typeof(fakeLink.click) == 'undefined')
|
||||
location.href = url;
|
||||
else
|
||||
{
|
||||
fakeLink.href = url;
|
||||
document.body.appendChild(fakeLink);
|
||||
fakeLink.click();
|
||||
}
|
||||
}
|
||||
</script>\n";
|
||||
return $js ."<button type=\"button\" onclick=\"navigateWithReferrer('$link');\">$name</button>";
|
||||
}
|
||||
|
||||
public static function back_anchor($name)
|
||||
{
|
||||
return "<a href=\"javascript:history.back()\">$name</a>";
|
||||
}
|
||||
|
||||
public static function back_button($name)
|
||||
{
|
||||
return "<button type=\"button\" onclick=\"history.back()\">$name</button>";
|
||||
}
|
||||
public static function print_button($name)
|
||||
{
|
||||
return "<button type=\"button\" onclick=\"print()\">$name</button>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user