XOOPS
2.6.0
Main Page
Related Pages
Classes
Files
Examples
File List
File Members
ColorPicker.php
Go to the documentation of this file.
1
<?php
2
/*
3
You may not change or alter any portion of this comment or credits
4
of supporting developers from this source code or any supporting source code
5
which is considered copyrighted (c) material of the original comment or credit authors.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
namespace
Xoops\Form
;
13
26
class
ColorPicker
extends
Text
27
{
35
public
function
__construct
(
$caption
,
$name
,
$value
=
'#FFFFFF'
)
36
{
37
parent::__construct(
$caption
,
$name
, 2, 7,
$value
,
''
);
38
}
39
45
public
function
render
()
46
{
47
$xoops
=
\Xoops::getInstance
();
48
if
(
$xoops
->theme()) {
49
$xoops
->theme()->addScript(
'include/color-picker.js'
);
50
}
else
{
51
echo
'<script type="text/javascript" src="'
.
\XoopsBaseConfig::get
(
'url'
) .
'/include/color-picker.js"></script>'
;
52
}
53
$this->
setExtra
(
' style="background-color:'
. $this->
getValue
() .
';"'
);
54
return
parent::render() .
"<button class='btn' type='button' onclick=\"return TCP.popup('"
55
.
\XoopsBaseConfig::get
(
'url'
) .
"/include/',document.getElementById('"
. $this->
getName
() .
"'));\"> ... </button>"
;
56
57
}
58
64
public
function
renderValidationJS
()
65
{
66
$eltname = $this->
getName
();
67
$eltcaption = $this->
getCaption
();
68
$eltmsg = empty($eltcaption)
69
? sprintf(\
XoopsLocale::F_ENTER
, $eltname)
70
: sprintf(\
XoopsLocale::F_ENTER
, $eltcaption);
71
72
return
"if ( !(new RegExp(\"^#[0-9a-fA-F]{6}\",\"i\").test(myform.{$eltname}.value)) )"
73
.
" { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }"
;
74
}
75
}
Xoops\Form\Element\getCaption
getCaption()
Definition:
Element.php:406
Xoops\Form\ColorPicker
Definition:
ColorPicker.php:26
Xoops\Form\Text
Definition:
Text.php:25
Xoops\getInstance
static getInstance()
Definition:
Xoops.php:160
Xoops\Form\Element\getValue
getValue($encode=false)
Definition:
Element.php:180
Xoops\Form
Definition:
BlockForm.php:12
XoopsLocaleEn_US\F_ENTER
const F_ENTER
Definition:
en_US.php:408
$xoops
$xoops
Definition:
admin.php:25
XoopsBaseConfig\get
static get($name)
Definition:
XoopsBaseConfig.php:117
Xoops\Form\Element\$caption
$caption
Definition:
Element.php:55
Xoops\Form\Element\getName
getName()
Definition:
Element.php:230
$name
$name
Definition:
force_download.php:15
Xoops\Form\Element\$value
$value
Definition:
Element.php:131
Xoops\Form\Element\setExtra
setExtra($extra, $replace=false)
Definition:
Element.php:522
Xoops\Form\ColorPicker\render
render()
Definition:
ColorPicker.php:45
Xoops\Form\ColorPicker\__construct
__construct($caption, $name, $value= '#FFFFFF')
Definition:
ColorPicker.php:35
Xoops\Form\ColorPicker\renderValidationJS
renderValidationJS()
Definition:
ColorPicker.php:64
usr64
htdocs
xoops_lib
Xoops
Form
ColorPicker.php
Generated on Fri May 22 2015 03:07:05 for XOOPS by
1.8.9.1